changeset 9:cd43af719f55

working on only lua
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 11:03:44 -0600
parents 08a8e09ca414
children 48b74a4e4692
files .hgignore configure.ac src/AutoBuild.h src/NLS.h src/Port.h src/SFMT/CHANGE-LOG.txt src/SFMT/LICENSE.txt src/SFMT/README.txt src/SFMT/SFMT-alti.h src/SFMT/SFMT-params.h src/SFMT/SFMT-params11213.h src/SFMT/SFMT-params1279.h src/SFMT/SFMT-params132049.h src/SFMT/SFMT-params19937.h src/SFMT/SFMT-params216091.h src/SFMT/SFMT-params2281.h src/SFMT/SFMT-params4253.h src/SFMT/SFMT-params44497.h src/SFMT/SFMT-params607.h src/SFMT/SFMT-params86243.h src/SFMT/SFMT-sse2.h src/SFMT/SFMT.c src/SFMT/SFMT.h src/VisualBoyAdvance.cfg src/common/CheatSearch.cpp src/common/CheatSearch.h src/common/Makefile.am src/common/System.h src/common/Text.cpp src/common/Text.h src/common/Util.cpp src/common/Util.h src/common/inputGlobal.h src/common/lua-engine.cpp src/common/memgzio.c src/common/memgzio.h src/common/movie.cpp src/common/movie.h src/common/nesvideos-piece.cpp src/common/nesvideos-piece.h src/common/unzip.cpp src/common/unzip.h src/common/vbalua.h src/filters/2xSaI.cpp src/filters/2xSaImmx.asm src/filters/Makefile.am src/filters/admame.cpp src/filters/bilinear.cpp src/filters/filters.h src/filters/hq2x.cpp src/filters/hq2x.h src/filters/hq3x32.cpp src/filters/hq3x32.h src/filters/hq_shared32.cpp src/filters/hq_shared32.h src/filters/interframe.cpp src/filters/interp.h src/filters/lq2x.h src/filters/motionblur.cpp src/filters/pixel.cpp src/filters/scanline.cpp src/filters/simple2x.cpp src/gb/GB.cpp src/gb/GB.h src/gb/Makefile.am src/gb/gbCheats.cpp src/gb/gbCheats.h src/gb/gbCodes.h src/gb/gbCodesCB.h src/gb/gbDis.cpp src/gb/gbGfx.cpp src/gb/gbGlobals.cpp src/gb/gbGlobals.h src/gb/gbMemory.cpp src/gb/gbMemory.h src/gb/gbPrinter.cpp src/gb/gbPrinter.h src/gb/gbSGB.cpp src/gb/gbSGB.h src/gb/gbSound.cpp src/gb/gbSound.h src/gba/EEprom.cpp src/gba/EEprom.h src/gba/Flash.cpp src/gba/Flash.h src/gba/GBA.cpp src/gba/GBA.h src/gba/GBACheats.cpp src/gba/GBACheats.h src/gba/GBAGfx.cpp src/gba/GBAGfx.h src/gba/GBAGlobals.cpp src/gba/GBAGlobals.h src/gba/GBASound.cpp src/gba/GBASound.h src/gba/GBAinline.h src/gba/Makefile.am src/gba/Mode0.cpp src/gba/Mode1.cpp src/gba/Mode2.cpp src/gba/Mode3.cpp src/gba/Mode4.cpp src/gba/Mode5.cpp src/gba/RTC.cpp src/gba/RTC.h src/gba/Sram.cpp src/gba/Sram.h src/gba/agbprint.cpp src/gba/agbprint.h src/gba/arm-new.h src/gba/armdis.cpp src/gba/armdis.h src/gba/bios.cpp src/gba/bios.h src/gba/elf.cpp src/gba/elf.h src/gba/remote.cpp src/gba/thumb.h src/gtk/.deps/gvba-configfile.Po src/gtk/.deps/gvba-filters.Po src/gtk/.deps/gvba-input.Po src/gtk/.deps/gvba-joypadconfig.Po src/gtk/.deps/gvba-main.Po src/gtk/.deps/gvba-screenarea.Po src/gtk/.deps/gvba-system.Po src/gtk/.deps/gvba-tools.Po src/gtk/.deps/gvba-window.Po src/gtk/.deps/gvba-windowcallbacks.Po src/gtk/Makefile src/gtk/Makefile.am src/gtk/configfile.cpp src/gtk/configfile.h src/gtk/filters.cpp src/gtk/filters.h src/gtk/images/Makefile src/gtk/images/Makefile.am src/gtk/images/stock-vba-wm-16.png src/gtk/images/stock-vba-wm-32.png src/gtk/images/stock-vba-wm-48.png src/gtk/images/stock-vba-wm-64.png src/gtk/images/vba-64.png src/gtk/input.cpp src/gtk/input.h src/gtk/intl.h src/gtk/joypadconfig.cpp src/gtk/joypadconfig.h src/gtk/main.cpp src/gtk/menuitem.h src/gtk/screenarea.cpp src/gtk/screenarea.h src/gtk/sigccompat.h src/gtk/system.cpp src/gtk/tools.cpp src/gtk/tools.h src/gtk/vba.glade src/gtk/window.cpp src/gtk/window.h src/gtk/windowcallbacks.cpp src/prof/Makefile.am src/prof/gmon.h src/prof/gmon_out.h src/prof/prof.cpp src/prof/prof.h src/sdl/Array.h src/sdl/Makefile.am src/sdl/RingBuffer.h src/sdl/SDL.cpp src/sdl/SoundDriver.h src/sdl/SoundSDL.cpp src/sdl/SoundSDL.h src/sdl/TestEmu.cpp src/sdl/Types.h src/sdl/debugger.cpp src/sdl/debugger.h src/sdl/expr-lex.cpp src/sdl/expr.cpp src/sdl/expr.cpp.h src/sdl/expr.l src/sdl/expr.y src/sdl/exprNode.cpp src/sdl/exprNode.h src/sdl/getopt.c src/sdl/getopt.h src/sdl/getopt1.c src/version.h src/win32/.cvsignore src/win32/7zip/7z/7zip_2005.vcproj src/win32/7zip/7z/7zip_2008.vcproj src/win32/7zip/7z/7zip_2010.vcxproj src/win32/7zip/7z/7zip_2010.vcxproj.filters src/win32/7zip/7z/C/7zCrc.c src/win32/7zip/7z/C/7zCrc.h src/win32/7zip/7z/C/Aes.c src/win32/7zip/7z/C/Aes.h src/win32/7zip/7z/C/Alloc.c src/win32/7zip/7z/C/Alloc.h src/win32/7zip/7z/C/Bra.c src/win32/7zip/7z/C/Bra.h src/win32/7zip/7z/C/Bra86.c src/win32/7zip/7z/C/BraIA64.c src/win32/7zip/7z/C/BwtSort.c src/win32/7zip/7z/C/BwtSort.h src/win32/7zip/7z/C/CpuArch.h src/win32/7zip/7z/C/HuffEnc.c src/win32/7zip/7z/C/HuffEnc.h src/win32/7zip/7z/C/LzFind.c src/win32/7zip/7z/C/LzFind.h src/win32/7zip/7z/C/LzFindMt.c src/win32/7zip/7z/C/LzFindMt.h src/win32/7zip/7z/C/LzHash.h src/win32/7zip/7z/C/LzmaDec.c src/win32/7zip/7z/C/LzmaDec.h src/win32/7zip/7z/C/LzmaEnc.c src/win32/7zip/7z/C/LzmaEnc.h src/win32/7zip/7z/C/RotateDefs.h src/win32/7zip/7z/C/Sha256.c src/win32/7zip/7z/C/Sha256.h src/win32/7zip/7z/C/Sort.c src/win32/7zip/7z/C/Sort.h src/win32/7zip/7z/C/Threads.c src/win32/7zip/7z/C/Threads.h src/win32/7zip/7z/C/Types.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zCompressionMode.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zDecode.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zDecode.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zExtract.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderInStream.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHandler.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHeader.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHeader.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zIn.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zItem.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zProperties.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zProperties.h src/win32/7zip/7z/CPP/7zip/Archive/7z/7zRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/7z/7zSpecStream.h src/win32/7zip/7z/CPP/7zip/Archive/7z/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/ArchiveExports.cpp src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Item.h src/win32/7zip/7z/CPP/7zip/Archive/BZip2/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.h src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h src/win32/7zip/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/DummyOutStream.h src/win32/7zip/7z/CPP/7zip/Archive/Common/FindSignature.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/FindSignature.h src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h src/win32/7zip/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/ItemNameUtils.h src/win32/7zip/7z/CPP/7zip/Archive/Common/MultiStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/MultiStream.h src/win32/7zip/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h src/win32/7zip/7z/CPP/7zip/Archive/Common/ParseProperties.cpp src/win32/7zip/7z/CPP/7zip/Archive/Common/ParseProperties.h src/win32/7zip/7z/CPP/7zip/Archive/Common/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/DllExports2.cpp src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHandler.h src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHeader.h src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipIn.h src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipItem.h src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipUpdate.h src/win32/7zip/7z/CPP/7zip/Archive/GZip/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/IArchive.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhCRC.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHeader.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhIn.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhItem.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzh/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaIn.h src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaItem.h src/win32/7zip/7z/CPP/7zip/Archive/Lzma/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarItem.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarItem.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h src/win32/7zip/7z/CPP/7zip/Archive/Rar/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/Split/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHeader.cpp src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHeader.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarIn.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarItem.h src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarRegister.cpp src/win32/7zip/7z/CPP/7zip/Archive/Zip/StdAfx.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHandler.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHeader.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.cpp src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItem.cpp src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItem.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItemEx.h src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp src/win32/7zip/7z/CPP/7zip/Common/CreateCoder.cpp src/win32/7zip/7z/CPP/7zip/Common/CreateCoder.h src/win32/7zip/7z/CPP/7zip/Common/DeclareArcs.h src/win32/7zip/7z/CPP/7zip/Common/DeclareCodecs.h src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.cpp src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.h src/win32/7zip/7z/CPP/7zip/Common/InBuffer.cpp src/win32/7zip/7z/CPP/7zip/Common/InBuffer.h src/win32/7zip/7z/CPP/7zip/Common/InOutTempBuffer.cpp src/win32/7zip/7z/CPP/7zip/Common/InOutTempBuffer.h src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.cpp src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.h src/win32/7zip/7z/CPP/7zip/Common/LockedStream.cpp src/win32/7zip/7z/CPP/7zip/Common/LockedStream.h src/win32/7zip/7z/CPP/7zip/Common/MemBlocks.cpp src/win32/7zip/7z/CPP/7zip/Common/MemBlocks.h src/win32/7zip/7z/CPP/7zip/Common/MethodId.cpp src/win32/7zip/7z/CPP/7zip/Common/MethodId.h src/win32/7zip/7z/CPP/7zip/Common/MethodProps.cpp src/win32/7zip/7z/CPP/7zip/Common/MethodProps.h src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.cpp src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.h src/win32/7zip/7z/CPP/7zip/Common/OutBuffer.cpp src/win32/7zip/7z/CPP/7zip/Common/OutBuffer.h src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.cpp src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.h src/win32/7zip/7z/CPP/7zip/Common/ProgressMt.cpp src/win32/7zip/7z/CPP/7zip/Common/ProgressMt.h src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.cpp src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.h src/win32/7zip/7z/CPP/7zip/Common/RegisterArc.h src/win32/7zip/7z/CPP/7zip/Common/RegisterCodec.h src/win32/7zip/7z/CPP/7zip/Common/StdAfx.h src/win32/7zip/7z/CPP/7zip/Common/StreamBinder.cpp src/win32/7zip/7z/CPP/7zip/Common/StreamBinder.h src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.cpp src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.h src/win32/7zip/7z/CPP/7zip/Common/StreamUtils.cpp src/win32/7zip/7z/CPP/7zip/Common/StreamUtils.h src/win32/7zip/7z/CPP/7zip/Common/VirtThread.cpp src/win32/7zip/7z/CPP/7zip/Common/VirtThread.h src/win32/7zip/7z/CPP/7zip/Compress/BZip2Const.h src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.cpp src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.h src/win32/7zip/7z/CPP/7zip/Compress/BZip2Decoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/BZip2Decoder.h src/win32/7zip/7z/CPP/7zip/Compress/BZip2Register.cpp src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.cpp src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.h src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Register.cpp src/win32/7zip/7z/CPP/7zip/Compress/BcjCoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/BcjCoder.h src/win32/7zip/7z/CPP/7zip/Compress/BcjRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/BitlDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/BitlDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/BitmDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/BranchCoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/BranchCoder.h src/win32/7zip/7z/CPP/7zip/Compress/BranchMisc.cpp src/win32/7zip/7z/CPP/7zip/Compress/BranchMisc.h src/win32/7zip/7z/CPP/7zip/Compress/BranchRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/ByteSwap.cpp src/win32/7zip/7z/CPP/7zip/Compress/ByteSwap.h src/win32/7zip/7z/CPP/7zip/Compress/ByteSwapRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/Codec.def src/win32/7zip/7z/CPP/7zip/Compress/CodecExports.cpp src/win32/7zip/7z/CPP/7zip/Compress/CopyCoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/CopyCoder.h src/win32/7zip/7z/CPP/7zip/Compress/CopyRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/Deflate64Register.cpp src/win32/7zip/7z/CPP/7zip/Compress/DeflateConst.h src/win32/7zip/7z/CPP/7zip/Compress/DeflateDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/DeflateDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/DeflateRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/HuffmanDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/ImplodeDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/ImplodeDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.cpp src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.h src/win32/7zip/7z/CPP/7zip/Compress/LzhDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/LzhDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/LzmaDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/LzmaDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/LzmaRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/Mtf8.h src/win32/7zip/7z/CPP/7zip/Compress/PpmdContext.h src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecode.h src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/PpmdRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/PpmdSubAlloc.h src/win32/7zip/7z/CPP/7zip/Compress/PpmdType.h src/win32/7zip/7z/CPP/7zip/Compress/RangeCoder.h src/win32/7zip/7z/CPP/7zip/Compress/RangeCoderBit.h src/win32/7zip/7z/CPP/7zip/Compress/Rar1Decoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/Rar1Decoder.h src/win32/7zip/7z/CPP/7zip/Compress/Rar2Decoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/Rar2Decoder.h src/win32/7zip/7z/CPP/7zip/Compress/Rar3Decoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/Rar3Decoder.h src/win32/7zip/7z/CPP/7zip/Compress/Rar3Vm.cpp src/win32/7zip/7z/CPP/7zip/Compress/Rar3Vm.h src/win32/7zip/7z/CPP/7zip/Compress/RarCodecsRegister.cpp src/win32/7zip/7z/CPP/7zip/Compress/ShrinkDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/ShrinkDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/StdAfx.h src/win32/7zip/7z/CPP/7zip/Compress/ZlibDecoder.cpp src/win32/7zip/7z/CPP/7zip/Compress/ZlibDecoder.h src/win32/7zip/7z/CPP/7zip/Compress/makefile src/win32/7zip/7z/CPP/7zip/Crypto/7zAes.cpp src/win32/7zip/7z/CPP/7zip/Crypto/7zAes.h src/win32/7zip/7z/CPP/7zip/Crypto/7zAesRegister.cpp src/win32/7zip/7z/CPP/7zip/Crypto/HmacSha1.cpp src/win32/7zip/7z/CPP/7zip/Crypto/HmacSha1.h src/win32/7zip/7z/CPP/7zip/Crypto/MyAes.cpp src/win32/7zip/7z/CPP/7zip/Crypto/MyAes.h src/win32/7zip/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp src/win32/7zip/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h src/win32/7zip/7z/CPP/7zip/Crypto/RandGen.cpp src/win32/7zip/7z/CPP/7zip/Crypto/RandGen.h src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.cpp src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.h src/win32/7zip/7z/CPP/7zip/Crypto/RarAes.cpp src/win32/7zip/7z/CPP/7zip/Crypto/RarAes.h src/win32/7zip/7z/CPP/7zip/Crypto/Sha1.cpp src/win32/7zip/7z/CPP/7zip/Crypto/Sha1.h src/win32/7zip/7z/CPP/7zip/Crypto/StdAfx.h src/win32/7zip/7z/CPP/7zip/Crypto/WzAes.cpp src/win32/7zip/7z/CPP/7zip/Crypto/WzAes.h src/win32/7zip/7z/CPP/7zip/Crypto/ZipCrypto.cpp src/win32/7zip/7z/CPP/7zip/Crypto/ZipCrypto.h src/win32/7zip/7z/CPP/7zip/Crypto/ZipStrong.cpp src/win32/7zip/7z/CPP/7zip/Crypto/ZipStrong.h src/win32/7zip/7z/CPP/7zip/ICoder.h src/win32/7zip/7z/CPP/7zip/IDecl.h src/win32/7zip/7z/CPP/7zip/IPassword.h src/win32/7zip/7z/CPP/7zip/IProgress.h src/win32/7zip/7z/CPP/7zip/IStream.h src/win32/7zip/7z/CPP/7zip/PropID.h src/win32/7zip/7z/CPP/Common/Buffer.h src/win32/7zip/7z/CPP/Common/CRC.cpp src/win32/7zip/7z/CPP/Common/ComTry.h src/win32/7zip/7z/CPP/Common/Defs.h src/win32/7zip/7z/CPP/Common/DynamicBuffer.h src/win32/7zip/7z/CPP/Common/InitializeStaticLib.h src/win32/7zip/7z/CPP/Common/IntToString.cpp src/win32/7zip/7z/CPP/Common/IntToString.h src/win32/7zip/7z/CPP/Common/MyCom.h src/win32/7zip/7z/CPP/Common/MyException.h src/win32/7zip/7z/CPP/Common/MyInitGuid.h src/win32/7zip/7z/CPP/Common/MyMap.cpp src/win32/7zip/7z/CPP/Common/MyMap.h src/win32/7zip/7z/CPP/Common/MyString.cpp src/win32/7zip/7z/CPP/Common/MyString.h src/win32/7zip/7z/CPP/Common/MyUnknown.h src/win32/7zip/7z/CPP/Common/MyVector.cpp src/win32/7zip/7z/CPP/Common/MyVector.h src/win32/7zip/7z/CPP/Common/MyWindows.h src/win32/7zip/7z/CPP/Common/MyXml.cpp src/win32/7zip/7z/CPP/Common/MyXml.h src/win32/7zip/7z/CPP/Common/NewHandler.cpp src/win32/7zip/7z/CPP/Common/NewHandler.h src/win32/7zip/7z/CPP/Common/StdAfx.h src/win32/7zip/7z/CPP/Common/StringConvert.cpp src/win32/7zip/7z/CPP/Common/StringConvert.h src/win32/7zip/7z/CPP/Common/StringToInt.cpp src/win32/7zip/7z/CPP/Common/StringToInt.h src/win32/7zip/7z/CPP/Common/Types.h src/win32/7zip/7z/CPP/Common/UTFConvert.cpp src/win32/7zip/7z/CPP/Common/UTFConvert.h src/win32/7zip/7z/CPP/Common/Wildcard.cpp src/win32/7zip/7z/CPP/Common/Wildcard.h src/win32/7zip/7z/CPP/Windows/Defs.h src/win32/7zip/7z/CPP/Windows/FileDir.cpp src/win32/7zip/7z/CPP/Windows/FileDir.h src/win32/7zip/7z/CPP/Windows/FileFind.cpp src/win32/7zip/7z/CPP/Windows/FileFind.h src/win32/7zip/7z/CPP/Windows/FileIO.cpp src/win32/7zip/7z/CPP/Windows/FileIO.h src/win32/7zip/7z/CPP/Windows/FileName.h src/win32/7zip/7z/CPP/Windows/Handle.h src/win32/7zip/7z/CPP/Windows/PropVariant.cpp src/win32/7zip/7z/CPP/Windows/PropVariant.h src/win32/7zip/7z/CPP/Windows/StdAfx.h src/win32/7zip/7z/CPP/Windows/Synchronization.h src/win32/7zip/7z/CPP/Windows/Thread.h src/win32/7zip/7z/CPP/Windows/Time.cpp src/win32/7zip/7z/CPP/Windows/Time.h src/win32/7zip/7z/DOC/License.txt src/win32/7zip/7z/DOC/gpl.txt src/win32/7zip/7z/DOC/readme.txt src/win32/7zip/7z/DOC/unRarLicense.txt src/win32/7zip/7zip.cpp src/win32/7zip/7zip.h src/win32/7zip/7zip.rc src/win32/7zip/7zipstreams.h src/win32/7zip/OpenArchive.cpp src/win32/7zip/OpenArchive.h src/win32/AVIWrite.cpp src/win32/AVIWrite.h src/win32/AboutDialog.cpp src/win32/AboutDialog.h src/win32/AccelEditor.cpp src/win32/AccelEditor.h src/win32/AcceleratorManager.cpp src/win32/AcceleratorManager.h src/win32/Associate.cpp src/win32/Associate.h src/win32/BitmapControl.cpp src/win32/BitmapControl.h src/win32/BugReport.cpp src/win32/BugReport.h src/win32/CmdAccelOb.cpp src/win32/CmdAccelOb.h src/win32/ColorButton.cpp src/win32/ColorButton.h src/win32/ColorControl.cpp src/win32/ColorControl.h src/win32/Commands.cpp src/win32/Direct3D.cpp src/win32/DirectDraw.cpp src/win32/DirectInput.cpp src/win32/DirectSound.cpp src/win32/Directories.cpp src/win32/Directories.h src/win32/Disassemble.cpp src/win32/Disassemble.h src/win32/Display.h src/win32/ExportGSASnapshot.cpp src/win32/ExportGSASnapshot.h src/win32/FileDlg.cpp src/win32/FileDlg.h src/win32/GBACheatsDlg.cpp src/win32/GBACheatsDlg.h src/win32/GBCheatsDlg.cpp src/win32/GBCheatsDlg.h src/win32/GBColorDlg.cpp src/win32/GBColorDlg.h src/win32/GBDisassemble.cpp src/win32/GBDisassemble.h src/win32/GBMapView.cpp src/win32/GBMapView.h src/win32/GBMemoryViewerDlg.cpp src/win32/GBMemoryViewerDlg.h src/win32/GBOamView.cpp src/win32/GBOamView.h src/win32/GBPaletteView.cpp src/win32/GBPaletteView.h src/win32/GBPrinterDlg.cpp src/win32/GBPrinterDlg.h src/win32/GBTileView.cpp src/win32/GBTileView.h src/win32/GDBConnection.cpp src/win32/GDBConnection.h src/win32/GDIDisplay.cpp src/win32/GSACodeSelect.cpp src/win32/GSACodeSelect.h src/win32/Hyperlink.cpp src/win32/Hyperlink.h src/win32/IOViewer.cpp src/win32/IOViewer.h src/win32/IOViewerRegs.h src/win32/IUpdate.h src/win32/Input.h src/win32/Joypad.cpp src/win32/Joypad.h src/win32/KeyboardEdit.cpp src/win32/KeyboardEdit.h src/win32/LangSelect.cpp src/win32/LangSelect.h src/win32/Logging.cpp src/win32/Logging.h src/win32/LuaOpenDialog.cpp src/win32/LuaOpenDialog.h src/win32/MainWnd.cpp src/win32/MainWnd.h src/win32/MainWndCheats.cpp src/win32/MainWndFile.cpp src/win32/MainWndHelp.cpp src/win32/MainWndOptions.cpp src/win32/MainWndTools.cpp src/win32/MapView.cpp src/win32/MapView.h src/win32/MaxScale.cpp src/win32/MaxScale.h src/win32/MemoryViewer.cpp src/win32/MemoryViewer.h src/win32/MemoryViewerAddressSize.cpp src/win32/MemoryViewerAddressSize.h src/win32/MemoryViewerDlg.cpp src/win32/MemoryViewerDlg.h src/win32/ModeConfirm.cpp src/win32/ModeConfirm.h src/win32/MovieCreate.cpp src/win32/MovieCreate.h src/win32/MovieOpen.cpp src/win32/MovieOpen.h src/win32/OamView.cpp src/win32/OamView.h src/win32/OpenGL.cpp src/win32/PaletteView.cpp src/win32/PaletteView.h src/win32/PaletteViewControl.cpp src/win32/PaletteViewControl.h src/win32/PerfTimer.cpp src/win32/PerfTimer.h src/win32/Reg.cpp src/win32/Reg.h src/win32/ResizeDlg.cpp src/win32/ResizeDlg.h src/win32/RewindInterval.cpp src/win32/RewindInterval.h src/win32/RomInfo.cpp src/win32/RomInfo.h src/win32/Sound.h src/win32/StringTokenizer.cpp src/win32/StringTokenizer.h src/win32/System.cpp src/win32/TextOptions.cpp src/win32/TextOptions.h src/win32/Throttle.cpp src/win32/Throttle.h src/win32/TileView.cpp src/win32/TileView.h src/win32/VBA.clw src/win32/VBA.cpp src/win32/VBA.h src/win32/VersionInfo.h src/win32/VideoMode.cpp src/win32/VideoMode.h src/win32/VisualBoyAdvance.exe.manifest src/win32/WavWriter.cpp src/win32/WavWriter.h src/win32/WinHelper.h src/win32/WinMiscUtil.cpp src/win32/WinMiscUtil.h src/win32/WinResUtil.cpp src/win32/WinResUtil.h src/win32/ZoomControl.cpp src/win32/ZoomControl.h src/win32/gbadvance.ico src/win32/ram_search.cpp src/win32/ram_search.h src/win32/ramwatch.cpp src/win32/ramwatch.h src/win32/resource.h src/win32/stdafx.cpp src/win32/stdafx.h src/win32/vba.rc src/win32/vba.rc2
diffstat 693 files changed, 23 insertions(+), 204197 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/.hgignore	Sat Mar 03 10:54:39 2012 -0600
     1.2 +++ b/.hgignore	Sat Mar 03 11:03:44 2012 -0600
     1.3 @@ -8,4 +8,5 @@
     1.4  depcomp
     1.5  autoscan.log
     1.6  configure.scan
     1.7 -*Makefile.in*
     1.8 \ No newline at end of file
     1.9 +*Makefile.in*
    1.10 +config.h.in
    1.11 \ No newline at end of file
     2.1 --- a/configure.ac	Sat Mar 03 10:54:39 2012 -0600
     2.2 +++ b/configure.ac	Sat Mar 03 11:03:44 2012 -0600
     2.3 @@ -1,5 +1,26 @@
     2.4 +AC_PREREQ([2.68])
     2.5 +
     2.6  AC_INIT([vba-rlm], [1.0])
     2.7  
     2.8 +dnl TODO: change this to gba.cpp or something
     2.9 +AC_CONFIG_SRCDIR([src/lua/src/lopcodes.c])
    2.10 +AC_CONFIG_HEADERS([config.h])
    2.11 +AC_PROG_RANLIB
    2.12 +
    2.13 +# Checks for header files.
    2.14 +AC_CHECK_HEADERS([limits.h locale.h stddef.h stdlib.h string.h unistd.h])
    2.15 +
    2.16 +# Checks for typedefs, structures, and compiler characteristics.
    2.17 +AC_TYPE_SIZE_T
    2.18 +AC_CHECK_TYPES([ptrdiff_t])
    2.19 +
    2.20 +# Checks for library functions.
    2.21 +AC_FUNC_ERROR_AT_LINE
    2.22 +AC_FUNC_MKTIME
    2.23 +AC_FUNC_REALLOC
    2.24 +AC_FUNC_STRCOLL
    2.25 +AC_CHECK_FUNCS([floor localeconv memchr modf pow setlocale sqrt strchr strcspn strerror strpbrk strrchr strstr strtoul])
    2.26 +
    2.27  AC_CONFIG_FILES([Makefile 
    2.28  	         src/Makefile
    2.29                   src/lua/Makefile])
     3.1 --- a/src/AutoBuild.h	Sat Mar 03 10:54:39 2012 -0600
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,30 +0,0 @@
     3.4 -// -*- C++ -*-
     3.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
     3.6 -// Copyright (C) 1999-2003 Forgotten
     3.7 -// Copyright (C) 2004 Forgotten and the VBA development team
     3.8 -
     3.9 -// This program is free software; you can redistribute it and/or modify
    3.10 -// it under the terms of the GNU General Public License as published by
    3.11 -// the Free Software Foundation; either version 2, or(at your option)
    3.12 -// any later version.
    3.13 -//
    3.14 -// This program is distributed in the hope that it will be useful,
    3.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 -// GNU General Public License for more details.
    3.18 -//
    3.19 -// You should have received a copy of the GNU General Public License
    3.20 -// along with this program; if not, write to the Free Software Foundation,
    3.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    3.22 -
    3.23 -#ifndef __AUTOBUILD_H__
    3.24 -#define __AUTOBUILD_H__
    3.25 -#include "version.h"
    3.26 -//change the FALSE to TRUE for autoincrement of build number
    3.27 -#define INCREMENT_VERSION FALSE
    3.28 -#define FILEVER        1,8,0,600
    3.29 -#define PRODUCTVER     1,8,0,600
    3.30 -#define STRFILEVER     "1, 8, 0, 600\0"
    3.31 -#define STRPRODUCTVER  "1, 8, 0, 600\0"
    3.32 -#endif //__AUTOBUILD_H__
    3.33 -
     4.1 --- a/src/NLS.h	Sat Mar 03 10:54:39 2012 -0600
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,52 +0,0 @@
     4.4 -#ifndef VBS_NLS_H
     4.5 -#define VBA_NLS_H
     4.6 -
     4.7 -#if _MSC_VER > 1000
     4.8 -#pragma once
     4.9 -#endif // _MSC_VER > 1000
    4.10 -
    4.11 -#define N_(String) (String)
    4.12 -
    4.13 -#define MSG_UNSUPPORTED_VBA_SGM             1
    4.14 -#define MSG_CANNOT_LOAD_SGM                 2
    4.15 -#define MSG_SAVE_GAME_NOT_USING_BIOS        3
    4.16 -#define MSG_SAVE_GAME_USING_BIOS            4
    4.17 -#define MSG_UNSUPPORTED_SAVE_TYPE           5
    4.18 -#define MSG_CANNOT_OPEN_FILE                6
    4.19 -#define MSG_BAD_ZIP_FILE                    7
    4.20 -#define MSG_NO_IMAGE_ON_ZIP                 8
    4.21 -#define MSG_ERROR_OPENING_IMAGE             9
    4.22 -#define MSG_ERROR_READING_IMAGE            10
    4.23 -#define MSG_UNSUPPORTED_BIOS_FUNCTION      11
    4.24 -#define MSG_INVALID_BIOS_FILE_SIZE         12
    4.25 -#define MSG_INVALID_CHEAT_CODE             13
    4.26 -#define MSG_UNKNOWN_ARM_OPCODE             14
    4.27 -#define MSG_UNKNOWN_THUMB_OPCODE           15
    4.28 -#define MSG_ERROR_CREATING_FILE            16
    4.29 -#define MSG_FAILED_TO_READ_SGM             17
    4.30 -#define MSG_FAILED_TO_READ_RTC             18
    4.31 -#define MSG_UNSUPPORTED_VB_SGM             19
    4.32 -#define MSG_CANNOT_LOAD_SGM_FOR            20
    4.33 -#define MSG_ERROR_OPENING_IMAGE_FROM       21
    4.34 -#define MSG_ERROR_READING_IMAGE_FROM       22
    4.35 -#define MSG_UNSUPPORTED_ROM_SIZE           23
    4.36 -#define MSG_UNSUPPORTED_RAM_SIZE           24
    4.37 -#define MSG_UNKNOWN_CARTRIDGE_TYPE         25
    4.38 -#define MSG_MAXIMUM_NUMBER_OF_CHEATS       26
    4.39 -#define MSG_INVALID_GAMESHARK_CODE         27
    4.40 -#define MSG_INVALID_GAMEGENIE_CODE         28
    4.41 -#define MSG_INVALID_CHEAT_TO_REMOVE        29
    4.42 -#define MSG_INVALID_CHEAT_CODE_ADDRESS     30
    4.43 -#define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31
    4.44 -#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE    32
    4.45 -#define MSG_INVALID_GSA_CODE               33
    4.46 -#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR     34
    4.47 -#define MSG_UNSUPPORTED_SNAPSHOT_FILE      35
    4.48 -#define MSG_UNSUPPORTED_ARM_MODE           36
    4.49 -#define MSG_UNSUPPORTED_CODE_FILE          37
    4.50 -#define MSG_GBA_CODE_WARNING               38
    4.51 -#define MSG_INVALID_CBA_CODE               39
    4.52 -#define MSG_CBA_CODE_WARNING               40
    4.53 -#define MSG_OUT_OF_MEMORY                  41
    4.54 -
    4.55 -#endif // VBA_NLS_H
     5.1 --- a/src/Port.h	Sat Mar 03 10:54:39 2012 -0600
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,178 +0,0 @@
     5.4 -#ifndef VBA_PORT_H
     5.5 -#define VBA_PORT_H
     5.6 -
     5.7 -#if _MSC_VER > 1000
     5.8 -#pragma once
     5.9 -#endif // _MSC_VER > 1000
    5.10 -
    5.11 -#include <ctime>
    5.12 -
    5.13 -#ifndef NULL
    5.14 -#define NULL 0
    5.15 -#endif
    5.16 -
    5.17 -typedef unsigned char bool8;
    5.18 -
    5.19 -#ifdef HAVE_STDINT_H
    5.20 -#include <stdint.h>
    5.21 -
    5.22 -typedef int8_t   int8;
    5.23 -typedef uint8_t  uint8;
    5.24 -typedef int16_t  int16;
    5.25 -typedef uint16_t uint16;
    5.26 -typedef int32_t  int32;
    5.27 -typedef uint32_t uint32;
    5.28 -typedef int64_t  int64;
    5.29 -typedef uint64_t uint64;
    5.30 -typedef intptr_t pint;
    5.31 -
    5.32 -#else /* Don't have stdint.h */
    5.33 -
    5.34 -#ifdef PTR_NOT_INT
    5.35 -typedef long pint;
    5.36 -#else /* pointer is int */
    5.37 -typedef int pint;
    5.38 -#endif /* PTR_NOT_INT */
    5.39 -
    5.40 -/* FIXME: Refactor this by moving out the BORLAND part and unifying typedefs */
    5.41 -#ifndef WIN32
    5.42 -typedef unsigned char  uint8;
    5.43 -typedef unsigned short uint16;
    5.44 -typedef signed char    int8;
    5.45 -typedef short          int16;
    5.46 -typedef int            int32;
    5.47 -typedef unsigned int   uint32;
    5.48 -# ifdef __GNUC__  /* long long is not part of ISO C++ */
    5.49 -__extension__ typedef long long          int64;
    5.50 -__extension__ typedef unsigned long long uint64;
    5.51 -# else
    5.52 -typedef long long          int64;
    5.53 -typedef unsigned long long uint64;
    5.54 -# endif
    5.55 -#else /* WIN32 */
    5.56 -
    5.57 -# ifdef __BORLANDC__
    5.58 -#   include <systypes.h>
    5.59 -# else
    5.60 -
    5.61 -typedef unsigned char  uint8;
    5.62 -typedef unsigned short uint16;
    5.63 -typedef signed char    int8;
    5.64 -typedef short          int16;
    5.65 -
    5.66 -# ifndef WSAAPI
    5.67 -/* winsock2.h typedefs int32 as well. */
    5.68 -typedef long int32;
    5.69 -# endif
    5.70 -
    5.71 -typedef unsigned int uint32;
    5.72 -
    5.73 -# endif /* __BORLANDC__ */
    5.74 -
    5.75 -typedef __int64          int64;
    5.76 -typedef unsigned __int64 uint64;
    5.77 -
    5.78 -#endif /* WIN32 */
    5.79 -#endif /* HAVE_STDINT_H */
    5.80 -
    5.81 -#ifndef WIN32
    5.82 -
    5.83 -#ifndef PATH_MAX
    5.84 -#define PATH_MAX 1024
    5.85 -#endif
    5.86 -
    5.87 -#define _MAX_DIR PATH_MAX
    5.88 -#define _MAX_DRIVE 1
    5.89 -#define _MAX_FNAME PATH_MAX
    5.90 -#define _MAX_EXT PATH_MAX
    5.91 -#define _MAX_PATH PATH_MAX
    5.92 -
    5.93 -#define ZeroMemory(a, b) memset((a), 0, (b))
    5.94 -
    5.95 -void _makepath(char *path, const char *drive, const char *dir,
    5.96 -               const char *fname, const char *ext);
    5.97 -void _splitpath(const char *path, char *drive, char *dir, char *fname,
    5.98 -                char *ext);
    5.99 -#else /* WIN32 */
   5.100 -#define strcasecmp stricmp
   5.101 -#define strncasecmp strnicmp
   5.102 -#endif
   5.103 -
   5.104 -typedef uint8  u8;
   5.105 -typedef uint16 u16;
   5.106 -typedef uint32 u32;
   5.107 -typedef uint64 u64;
   5.108 -typedef int8   s8;
   5.109 -typedef int16  s16;
   5.110 -typedef int32  s32;
   5.111 -typedef int64  s64;
   5.112 -
   5.113 -// for consistency
   5.114 -static inline u8 swap8(u8 v)
   5.115 -{
   5.116 -	return v;
   5.117 -}
   5.118 -
   5.119 -// swaps a 16-bit value
   5.120 -static inline u16 swap16(u16 v)
   5.121 -{
   5.122 -	return (v<<8)|(v>>8);
   5.123 -}
   5.124 -
   5.125 -// swaps a 32-bit value
   5.126 -static inline u32 swap32(u32 v)
   5.127 -{
   5.128 -	return (v<<24)|((v<<8)&0xff0000)|((v>>8)&0xff00)|(v>>24);
   5.129 -}
   5.130 -
   5.131 -#define READ8LE(x) \
   5.132 -    *((u8 *)x)
   5.133 -
   5.134 -#define WRITE8LE(x, v) \
   5.135 -    *((u8 *)x) = (v)
   5.136 -
   5.137 -#ifdef WORDS_BIGENDIAN
   5.138 -#if defined(__GNUC__) && defined(__ppc__)
   5.139 -
   5.140 -#define READ16LE(base) \
   5.141 -    ({ unsigned short lhbrxResult;       \
   5.142 -       __asm__("lhbrx %0, 0, %1" : "=r" (lhbrxResult) : "r" (base) : "memory"); \
   5.143 -       lhbrxResult; })
   5.144 -
   5.145 -#define READ32LE(base) \
   5.146 -    ({ unsigned long lwbrxResult; \
   5.147 -       __asm__("lwbrx %0, 0, %1" : "=r" (lwbrxResult) : "r" (base) : "memory"); \
   5.148 -       lwbrxResult; })
   5.149 -
   5.150 -#define WRITE16LE(base, value) \
   5.151 -    __asm__("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
   5.152 -
   5.153 -#define WRITE32LE(base, value) \
   5.154 -    __asm__("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
   5.155 -
   5.156 -#else
   5.157 -#define READ16LE(x) \
   5.158 -    swap16(*((u16 *)(x)))
   5.159 -#define READ32LE(x) \
   5.160 -    swap32(*((u32 *)(x)))
   5.161 -#define WRITE16LE(x, v) \
   5.162 -    *((u16 *)x) = swap16((v))
   5.163 -#define WRITE32LE(x, v) \
   5.164 -    *((u32 *)x) = swap32((v))
   5.165 -#endif
   5.166 -#else
   5.167 -#define READ16LE(x) \
   5.168 -    *((u16 *)x)
   5.169 -#define READ32LE(x) \
   5.170 -    *((u32 *)x)
   5.171 -#define WRITE16LE(x, v) \
   5.172 -    *((u16 *)x) = (v)
   5.173 -#define WRITE32LE(x, v) \
   5.174 -    *((u32 *)x) = (v)
   5.175 -#endif
   5.176 -
   5.177 -#ifndef CTASSERT
   5.178 -#define CTASSERT(x)  typedef char __assert ## y[(x) ? 1 : -1];
   5.179 -#endif
   5.180 -
   5.181 -#endif // VBA_PORT_H
     6.1 --- a/src/SFMT/CHANGE-LOG.txt	Sat Mar 03 10:54:39 2012 -0600
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,55 +0,0 @@
     6.4 -ver 1.3.3
     6.5 --------
     6.6 -change condition compile of do_recursion in SFMT.c
     6.7 -
     6.8 -ver 1.3.2
     6.9 --------
    6.10 -bug fix to_res53_mix and genrand_res53_mix.
    6.11 -
    6.12 -ver 1.3.1
    6.13 --------
    6.14 -gcc compile option changed form -O9 to -O3.
    6.15 -add functions genrand_res53_mix and to_res53_mix.
    6.16 -bug fix about definition of ALWAYS_INLINE.
    6.17 -add new definition PRE_ALWAYS for MSC.
    6.18 -
    6.19 -ver 1.3
    6.20 --------
    6.21 -bug fixed: -DONLY64 without -DBIG_ENIAN64 had been generating
    6.22 -wrong sequence.
    6.23 -bug fixed: There is no documentation about BIG_ENDIAN64.
    6.24 -add automatic endian check by __BIG_ENDIAN__ predefined macro.
    6.25 -bug fixed: change == in check.sh to =
    6.26 -add SFMT-params216091.h
    6.27 -add AltiVec parameter format for systems which are not osx.
    6.28 -change Makefile for systems which are not osx and support AltiVec.
    6.29 -change sample2 of howto-compile for Free BSD.
    6.30 -change source files for BORLANDC and Visual Studio.
    6.31 -change period certification code more smart.
    6.32 -add params directory.
    6.33 -
    6.34 -ver 1.2.1
    6.35 --------
    6.36 -Fix typo in SFMT-alti.c SFMT-sse2.c
    6.37 -marge SFMT-alti.c and SFMT-alti.h into SFMT-alti.h
    6.38 -marge SFMT-sse2.c and SFMT-sse2.h into SFMT-sse2.h
    6.39 -This version is not released.
    6.40 -
    6.41 -ver 1.2
    6.42 --------
    6.43 -Support many periods: 2^{607}, 2^{1279}, 2^{2281}, 2^{4253}, 2^{11213},
    6.44 -2^{19937}, 2^{44497}, 2^{86243}, 2^{132049}
    6.45 -Fix typo in LICENSE.txt.
    6.46 -Add cast to vec_perm for SFMT-alti.c, SFMT-alti64.c.
    6.47 -combine source codes.
    6.48 -
    6.49 -ver 1.1
    6.50 --------
    6.51 -The period certification method is changed from constant to function.
    6.52 -The convert functions from 32-bit and 64-bit integer to double are added.
    6.53 -The documentation is changed.
    6.54 -Sample programs are added.
    6.55 -
    6.56 -ver 1.0
    6.57 --------
    6.58 -The first version.
     7.1 --- a/src/SFMT/LICENSE.txt	Sat Mar 03 10:54:39 2012 -0600
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,29 +0,0 @@
     7.4 -Copyright (c) 2006,2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
     7.5 -University. All rights reserved.
     7.6 -
     7.7 -Redistribution and use in source and binary forms, with or without
     7.8 -modification, are permitted provided that the following conditions are
     7.9 -met:
    7.10 -
    7.11 -    * Redistributions of source code must retain the above copyright
    7.12 -      notice, this list of conditions and the following disclaimer.
    7.13 -    * Redistributions in binary form must reproduce the above
    7.14 -      copyright notice, this list of conditions and the following
    7.15 -      disclaimer in the documentation and/or other materials provided
    7.16 -      with the distribution.
    7.17 -    * Neither the name of the Hiroshima University nor the names of
    7.18 -      its contributors may be used to endorse or promote products
    7.19 -      derived from this software without specific prior written
    7.20 -      permission.
    7.21 -
    7.22 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    7.23 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    7.24 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    7.25 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    7.26 -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    7.27 -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    7.28 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    7.29 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    7.30 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    7.31 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    7.32 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     8.1 --- a/src/SFMT/README.txt	Sat Mar 03 10:54:39 2012 -0600
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,22 +0,0 @@
     8.4 - =================================================================
     8.5 - SFMT ver. 1.3.3
     8.6 - SIMD oriented Fast Mersenne Twister(SFMT)
     8.7 -
     8.8 - Mutsuo Saito (Hiroshima University) and
     8.9 - Makoto Matsumoto (Hiroshima University)
    8.10 -
    8.11 - Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
    8.12 - University. All rights reserved.
    8.13 -
    8.14 - The (modified) BSD License is applied to this software, see LICENSE.txt
    8.15 - =================================================================
    8.16 -
    8.17 - To see documents, see html/index.html.
    8.18 -
    8.19 - To make test program, see html/howto-compile.html
    8.20 -
    8.21 - If you want to redistribute and/or change source files, see LICENSE.txt.
    8.22 -
    8.23 - When you change these files and redistribute them, PLEASE write your
    8.24 - e-mail address in redistribution and write to contact YOU first if
    8.25 - users of your changed source encounter troubles.
     9.1 --- a/src/SFMT/SFMT-alti.h	Sat Mar 03 10:54:39 2012 -0600
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,156 +0,0 @@
     9.4 -/** 
     9.5 - * @file SFMT-alti.h 
     9.6 - *
     9.7 - * @brief SIMD oriented Fast Mersenne Twister(SFMT)
     9.8 - * pseudorandom number generator
     9.9 - *
    9.10 - * @author Mutsuo Saito (Hiroshima University)
    9.11 - * @author Makoto Matsumoto (Hiroshima University)
    9.12 - *
    9.13 - * Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
    9.14 - * University. All rights reserved.
    9.15 - *
    9.16 - * The new BSD License is applied to this software.
    9.17 - * see LICENSE.txt
    9.18 - */
    9.19 -
    9.20 -#ifndef SFMT_ALTI_H
    9.21 -#define SFMT_ALTI_H
    9.22 -
    9.23 -inline static vector unsigned int vec_recursion(vector unsigned int a,
    9.24 -						vector unsigned int b,
    9.25 -						vector unsigned int c,
    9.26 -						vector unsigned int d)
    9.27 -    ALWAYSINLINE;
    9.28 -
    9.29 -/**
    9.30 - * This function represents the recursion formula in AltiVec and BIG ENDIAN.
    9.31 - * @param a a 128-bit part of the interal state array
    9.32 - * @param b a 128-bit part of the interal state array
    9.33 - * @param c a 128-bit part of the interal state array
    9.34 - * @param d a 128-bit part of the interal state array
    9.35 - * @return output
    9.36 - */
    9.37 -inline static vector unsigned int vec_recursion(vector unsigned int a,
    9.38 -						vector unsigned int b,
    9.39 -						vector unsigned int c,
    9.40 -						vector unsigned int d) {
    9.41 -
    9.42 -    const vector unsigned int sl1 = ALTI_SL1;
    9.43 -    const vector unsigned int sr1 = ALTI_SR1;
    9.44 -#ifdef ONLY64
    9.45 -    const vector unsigned int mask = ALTI_MSK64;
    9.46 -    const vector unsigned char perm_sl = ALTI_SL2_PERM64;
    9.47 -    const vector unsigned char perm_sr = ALTI_SR2_PERM64;
    9.48 -#else
    9.49 -    const vector unsigned int mask = ALTI_MSK;
    9.50 -    const vector unsigned char perm_sl = ALTI_SL2_PERM;
    9.51 -    const vector unsigned char perm_sr = ALTI_SR2_PERM;
    9.52 -#endif
    9.53 -    vector unsigned int v, w, x, y, z;
    9.54 -    x = vec_perm(a, (vector unsigned int)perm_sl, perm_sl);
    9.55 -    v = a;
    9.56 -    y = vec_sr(b, sr1);
    9.57 -    z = vec_perm(c, (vector unsigned int)perm_sr, perm_sr);
    9.58 -    w = vec_sl(d, sl1);
    9.59 -    z = vec_xor(z, w);
    9.60 -    y = vec_and(y, mask);
    9.61 -    v = vec_xor(v, x);
    9.62 -    z = vec_xor(z, y);
    9.63 -    z = vec_xor(z, v);
    9.64 -    return z;
    9.65 -}
    9.66 -
    9.67 -/**
    9.68 - * This function fills the internal state array with pseudorandom
    9.69 - * integers.
    9.70 - */
    9.71 -inline static void gen_rand_all(void) {
    9.72 -    int i;
    9.73 -    vector unsigned int r, r1, r2;
    9.74 -
    9.75 -    r1 = sfmt[N - 2].s;
    9.76 -    r2 = sfmt[N - 1].s;
    9.77 -    for (i = 0; i < N - POS1; i++) {
    9.78 -	r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2);
    9.79 -	sfmt[i].s = r;
    9.80 -	r1 = r2;
    9.81 -	r2 = r;
    9.82 -    }
    9.83 -    for (; i < N; i++) {
    9.84 -	r = vec_recursion(sfmt[i].s, sfmt[i + POS1 - N].s, r1, r2);
    9.85 -	sfmt[i].s = r;
    9.86 -	r1 = r2;
    9.87 -	r2 = r;
    9.88 -    }
    9.89 -}
    9.90 -
    9.91 -/**
    9.92 - * This function fills the user-specified array with pseudorandom
    9.93 - * integers.
    9.94 - *
    9.95 - * @param array an 128-bit array to be filled by pseudorandom numbers.  
    9.96 - * @param size number of 128-bit pesudorandom numbers to be generated.
    9.97 - */
    9.98 -inline static void gen_rand_array(w128_t *array, int size) {
    9.99 -    int i, j;
   9.100 -    vector unsigned int r, r1, r2;
   9.101 -
   9.102 -    r1 = sfmt[N - 2].s;
   9.103 -    r2 = sfmt[N - 1].s;
   9.104 -    for (i = 0; i < N - POS1; i++) {
   9.105 -	r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2);
   9.106 -	array[i].s = r;
   9.107 -	r1 = r2;
   9.108 -	r2 = r;
   9.109 -    }
   9.110 -    for (; i < N; i++) {
   9.111 -	r = vec_recursion(sfmt[i].s, array[i + POS1 - N].s, r1, r2);
   9.112 -	array[i].s = r;
   9.113 -	r1 = r2;
   9.114 -	r2 = r;
   9.115 -    }
   9.116 -    /* main loop */
   9.117 -    for (; i < size - N; i++) {
   9.118 -	r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2);
   9.119 -	array[i].s = r;
   9.120 -	r1 = r2;
   9.121 -	r2 = r;
   9.122 -    }
   9.123 -    for (j = 0; j < 2 * N - size; j++) {
   9.124 -	sfmt[j].s = array[j + size - N].s;
   9.125 -    }
   9.126 -    for (; i < size; i++) {
   9.127 -	r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2);
   9.128 -	array[i].s = r;
   9.129 -	sfmt[j++].s = r;
   9.130 -	r1 = r2;
   9.131 -	r2 = r;
   9.132 -    }
   9.133 -}
   9.134 -
   9.135 -#ifndef ONLY64
   9.136 -#if defined(__APPLE__)
   9.137 -#define ALTI_SWAP (vector unsigned char) \
   9.138 -	(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11)
   9.139 -#else
   9.140 -#define ALTI_SWAP {4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11}
   9.141 -#endif
   9.142 -/**
   9.143 - * This function swaps high and low 32-bit of 64-bit integers in user
   9.144 - * specified array.
   9.145 - *
   9.146 - * @param array an 128-bit array to be swaped.
   9.147 - * @param size size of 128-bit array.
   9.148 - */
   9.149 -inline static void swap(w128_t *array, int size) {
   9.150 -    int i;
   9.151 -    const vector unsigned char perm = ALTI_SWAP;
   9.152 -
   9.153 -    for (i = 0; i < size; i++) {
   9.154 -	array[i].s = vec_perm(array[i].s, (vector unsigned int)perm, perm);
   9.155 -    }
   9.156 -}
   9.157 -#endif
   9.158 -
   9.159 -#endif
    10.1 --- a/src/SFMT/SFMT-params.h	Sat Mar 03 10:54:39 2012 -0600
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,97 +0,0 @@
    10.4 -#ifndef SFMT_PARAMS_H
    10.5 -#define SFMT_PARAMS_H
    10.6 -
    10.7 -#if !defined(MEXP)
    10.8 -#ifdef __GNUC__
    10.9 -  #warning "MEXP is not defined. I assume MEXP is 19937."
   10.10 -#endif
   10.11 -  #define MEXP 19937
   10.12 -#endif
   10.13 -/*-----------------
   10.14 -  BASIC DEFINITIONS
   10.15 -  -----------------*/
   10.16 -/** Mersenne Exponent. The period of the sequence 
   10.17 - *  is a multiple of 2^MEXP-1.
   10.18 - * #define MEXP 19937 */
   10.19 -/** SFMT generator has an internal state array of 128-bit integers,
   10.20 - * and N is its size. */
   10.21 -#define N (MEXP / 128 + 1)
   10.22 -/** N32 is the size of internal state array when regarded as an array
   10.23 - * of 32-bit integers.*/
   10.24 -#define N32 (N * 4)
   10.25 -/** N64 is the size of internal state array when regarded as an array
   10.26 - * of 64-bit integers.*/
   10.27 -#define N64 (N * 2)
   10.28 -
   10.29 -/*----------------------
   10.30 -  the parameters of SFMT
   10.31 -  following definitions are in paramsXXXX.h file.
   10.32 -  ----------------------*/
   10.33 -/** the pick up position of the array.
   10.34 -#define POS1 122 
   10.35 -*/
   10.36 -
   10.37 -/** the parameter of shift left as four 32-bit registers.
   10.38 -#define SL1 18
   10.39 - */
   10.40 -
   10.41 -/** the parameter of shift left as one 128-bit register. 
   10.42 - * The 128-bit integer is shifted by (SL2 * 8) bits. 
   10.43 -#define SL2 1 
   10.44 -*/
   10.45 -
   10.46 -/** the parameter of shift right as four 32-bit registers.
   10.47 -#define SR1 11
   10.48 -*/
   10.49 -
   10.50 -/** the parameter of shift right as one 128-bit register. 
   10.51 - * The 128-bit integer is shifted by (SL2 * 8) bits. 
   10.52 -#define SR2 1 
   10.53 -*/
   10.54 -
   10.55 -/** A bitmask, used in the recursion.  These parameters are introduced
   10.56 - * to break symmetry of SIMD.
   10.57 -#define MSK1 0xdfffffefU
   10.58 -#define MSK2 0xddfecb7fU
   10.59 -#define MSK3 0xbffaffffU
   10.60 -#define MSK4 0xbffffff6U 
   10.61 -*/
   10.62 -
   10.63 -/** These definitions are part of a 128-bit period certification vector.
   10.64 -#define PARITY1	0x00000001U
   10.65 -#define PARITY2	0x00000000U
   10.66 -#define PARITY3	0x00000000U
   10.67 -#define PARITY4	0xc98e126aU
   10.68 -*/
   10.69 -
   10.70 -#if MEXP == 607
   10.71 -  #include "SFMT-params607.h"
   10.72 -#elif MEXP == 1279
   10.73 -  #include "SFMT-params1279.h"
   10.74 -#elif MEXP == 2281
   10.75 -  #include "SFMT-params2281.h"
   10.76 -#elif MEXP == 4253
   10.77 -  #include "SFMT-params4253.h"
   10.78 -#elif MEXP == 11213
   10.79 -  #include "SFMT-params11213.h"
   10.80 -#elif MEXP == 19937
   10.81 -  #include "SFMT-params19937.h"
   10.82 -#elif MEXP == 44497
   10.83 -  #include "SFMT-params44497.h"
   10.84 -#elif MEXP == 86243
   10.85 -  #include "SFMT-params86243.h"
   10.86 -#elif MEXP == 132049
   10.87 -  #include "SFMT-params132049.h"
   10.88 -#elif MEXP == 216091
   10.89 -  #include "SFMT-params216091.h"
   10.90 -#else
   10.91 -#ifdef __GNUC__
   10.92 -  #error "MEXP is not valid."
   10.93 -  #undef MEXP
   10.94 -#else
   10.95 -  #undef MEXP
   10.96 -#endif
   10.97 -
   10.98 -#endif
   10.99 -
  10.100 -#endif /* SFMT_PARAMS_H */
    11.1 --- a/src/SFMT/SFMT-params11213.h	Sat Mar 03 10:54:39 2012 -0600
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,46 +0,0 @@
    11.4 -#ifndef SFMT_PARAMS11213_H
    11.5 -#define SFMT_PARAMS11213_H
    11.6 -
    11.7 -#define POS1	68
    11.8 -#define SL1	14
    11.9 -#define SL2	3
   11.10 -#define SR1	7
   11.11 -#define SR2	3
   11.12 -#define MSK1	0xeffff7fbU
   11.13 -#define MSK2	0xffffffefU
   11.14 -#define MSK3	0xdfdfbfffU
   11.15 -#define MSK4	0x7fffdbfdU
   11.16 -#define PARITY1	0x00000001U
   11.17 -#define PARITY2	0x00000000U
   11.18 -#define PARITY3	0xe8148000U
   11.19 -#define PARITY4	0xd0c7afa3U
   11.20 -
   11.21 -
   11.22 -/* PARAMETERS FOR ALTIVEC */
   11.23 -#if defined(__APPLE__)	/* For OSX */
   11.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   11.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   11.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   11.27 -    #define ALTI_MSK64 \
   11.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   11.29 -    #define ALTI_SL2_PERM \
   11.30 -	(vector unsigned char)(3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10)
   11.31 -    #define ALTI_SL2_PERM64 \
   11.32 -	(vector unsigned char)(3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2)
   11.33 -    #define ALTI_SR2_PERM \
   11.34 -	(vector unsigned char)(5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12)
   11.35 -    #define ALTI_SR2_PERM64 \
   11.36 -	(vector unsigned char)(13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12)
   11.37 -#else	/* For OTHER OSs(Linux?) */
   11.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   11.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   11.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   11.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   11.42 -    #define ALTI_SL2_PERM	{3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10}
   11.43 -    #define ALTI_SL2_PERM64	{3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2}
   11.44 -    #define ALTI_SR2_PERM	{5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12}
   11.45 -    #define ALTI_SR2_PERM64	{13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12}
   11.46 -#endif	/* For OSX */
   11.47 -#define IDSTR	"SFMT-11213:68-14-3-7-3:effff7fb-ffffffef-dfdfbfff-7fffdbfd"
   11.48 -
   11.49 -#endif /* SFMT_PARAMS11213_H */
    12.1 --- a/src/SFMT/SFMT-params1279.h	Sat Mar 03 10:54:39 2012 -0600
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,46 +0,0 @@
    12.4 -#ifndef SFMT_PARAMS1279_H
    12.5 -#define SFMT_PARAMS1279_H
    12.6 -
    12.7 -#define POS1	7
    12.8 -#define SL1	14
    12.9 -#define SL2	3
   12.10 -#define SR1	5
   12.11 -#define SR2	1
   12.12 -#define MSK1	0xf7fefffdU
   12.13 -#define MSK2	0x7fefcfffU
   12.14 -#define MSK3	0xaff3ef3fU
   12.15 -#define MSK4	0xb5ffff7fU
   12.16 -#define PARITY1	0x00000001U
   12.17 -#define PARITY2	0x00000000U
   12.18 -#define PARITY3	0x00000000U
   12.19 -#define PARITY4	0x20000000U
   12.20 -
   12.21 -
   12.22 -/* PARAMETERS FOR ALTIVEC */
   12.23 -#if defined(__APPLE__)	/* For OSX */
   12.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   12.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   12.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   12.27 -    #define ALTI_MSK64 \
   12.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   12.29 -    #define ALTI_SL2_PERM \
   12.30 -	(vector unsigned char)(3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10)
   12.31 -    #define ALTI_SL2_PERM64 \
   12.32 -	(vector unsigned char)(3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2)
   12.33 -    #define ALTI_SR2_PERM \
   12.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   12.35 -    #define ALTI_SR2_PERM64 \
   12.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   12.37 -#else	/* For OTHER OSs(Linux?) */
   12.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   12.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   12.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   12.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   12.42 -    #define ALTI_SL2_PERM	{3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10}
   12.43 -    #define ALTI_SL2_PERM64	{3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2}
   12.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   12.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   12.46 -#endif	/* For OSX */
   12.47 -#define IDSTR	"SFMT-1279:7-14-3-5-1:f7fefffd-7fefcfff-aff3ef3f-b5ffff7f"
   12.48 -
   12.49 -#endif /* SFMT_PARAMS1279_H */
    13.1 --- a/src/SFMT/SFMT-params132049.h	Sat Mar 03 10:54:39 2012 -0600
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,46 +0,0 @@
    13.4 -#ifndef SFMT_PARAMS132049_H
    13.5 -#define SFMT_PARAMS132049_H
    13.6 -
    13.7 -#define POS1	110
    13.8 -#define SL1	19
    13.9 -#define SL2	1
   13.10 -#define SR1	21
   13.11 -#define SR2	1
   13.12 -#define MSK1	0xffffbb5fU
   13.13 -#define MSK2	0xfb6ebf95U
   13.14 -#define MSK3	0xfffefffaU
   13.15 -#define MSK4	0xcff77fffU
   13.16 -#define PARITY1	0x00000001U
   13.17 -#define PARITY2	0x00000000U
   13.18 -#define PARITY3	0xcb520000U
   13.19 -#define PARITY4	0xc7e91c7dU
   13.20 -
   13.21 -
   13.22 -/* PARAMETERS FOR ALTIVEC */
   13.23 -#if defined(__APPLE__)	/* For OSX */
   13.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   13.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   13.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   13.27 -    #define ALTI_MSK64 \
   13.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   13.29 -    #define ALTI_SL2_PERM \
   13.30 -	(vector unsigned char)(1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8)
   13.31 -    #define ALTI_SL2_PERM64 \
   13.32 -	(vector unsigned char)(1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0)
   13.33 -    #define ALTI_SR2_PERM \
   13.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   13.35 -    #define ALTI_SR2_PERM64 \
   13.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   13.37 -#else	/* For OTHER OSs(Linux?) */
   13.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   13.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   13.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   13.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   13.42 -    #define ALTI_SL2_PERM	{1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8}
   13.43 -    #define ALTI_SL2_PERM64	{1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0}
   13.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   13.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   13.46 -#endif	/* For OSX */
   13.47 -#define IDSTR	"SFMT-132049:110-19-1-21-1:ffffbb5f-fb6ebf95-fffefffa-cff77fff"
   13.48 -
   13.49 -#endif /* SFMT_PARAMS132049_H */
    14.1 --- a/src/SFMT/SFMT-params19937.h	Sat Mar 03 10:54:39 2012 -0600
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,46 +0,0 @@
    14.4 -#ifndef SFMT_PARAMS19937_H
    14.5 -#define SFMT_PARAMS19937_H
    14.6 -
    14.7 -#define POS1	122
    14.8 -#define SL1	18
    14.9 -#define SL2	1
   14.10 -#define SR1	11
   14.11 -#define SR2	1
   14.12 -#define MSK1	0xdfffffefU
   14.13 -#define MSK2	0xddfecb7fU
   14.14 -#define MSK3	0xbffaffffU
   14.15 -#define MSK4	0xbffffff6U
   14.16 -#define PARITY1	0x00000001U
   14.17 -#define PARITY2	0x00000000U
   14.18 -#define PARITY3	0x00000000U
   14.19 -#define PARITY4	0x13c9e684U
   14.20 -
   14.21 -
   14.22 -/* PARAMETERS FOR ALTIVEC */
   14.23 -#if defined(__APPLE__)	/* For OSX */
   14.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   14.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   14.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   14.27 -    #define ALTI_MSK64 \
   14.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   14.29 -    #define ALTI_SL2_PERM \
   14.30 -	(vector unsigned char)(1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8)
   14.31 -    #define ALTI_SL2_PERM64 \
   14.32 -	(vector unsigned char)(1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0)
   14.33 -    #define ALTI_SR2_PERM \
   14.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   14.35 -    #define ALTI_SR2_PERM64 \
   14.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   14.37 -#else	/* For OTHER OSs(Linux?) */
   14.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   14.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   14.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   14.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   14.42 -    #define ALTI_SL2_PERM	{1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8}
   14.43 -    #define ALTI_SL2_PERM64	{1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0}
   14.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   14.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   14.46 -#endif	/* For OSX */
   14.47 -#define IDSTR	"SFMT-19937:122-18-1-11-1:dfffffef-ddfecb7f-bffaffff-bffffff6"
   14.48 -
   14.49 -#endif /* SFMT_PARAMS19937_H */
    15.1 --- a/src/SFMT/SFMT-params216091.h	Sat Mar 03 10:54:39 2012 -0600
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,46 +0,0 @@
    15.4 -#ifndef SFMT_PARAMS216091_H
    15.5 -#define SFMT_PARAMS216091_H
    15.6 -
    15.7 -#define POS1	627
    15.8 -#define SL1	11
    15.9 -#define SL2	3
   15.10 -#define SR1	10
   15.11 -#define SR2	1
   15.12 -#define MSK1	0xbff7bff7U
   15.13 -#define MSK2	0xbfffffffU
   15.14 -#define MSK3	0xbffffa7fU
   15.15 -#define MSK4	0xffddfbfbU
   15.16 -#define PARITY1	0xf8000001U
   15.17 -#define PARITY2	0x89e80709U
   15.18 -#define PARITY3	0x3bd2b64bU
   15.19 -#define PARITY4	0x0c64b1e4U
   15.20 -
   15.21 -
   15.22 -/* PARAMETERS FOR ALTIVEC */
   15.23 -#if defined(__APPLE__)	/* For OSX */
   15.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   15.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   15.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   15.27 -    #define ALTI_MSK64 \
   15.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   15.29 -    #define ALTI_SL2_PERM \
   15.30 -	(vector unsigned char)(3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10)
   15.31 -    #define ALTI_SL2_PERM64 \
   15.32 -	(vector unsigned char)(3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2)
   15.33 -    #define ALTI_SR2_PERM \
   15.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   15.35 -    #define ALTI_SR2_PERM64 \
   15.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   15.37 -#else	/* For OTHER OSs(Linux?) */
   15.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   15.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   15.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   15.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   15.42 -    #define ALTI_SL2_PERM	{3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10}
   15.43 -    #define ALTI_SL2_PERM64	{3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2}
   15.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   15.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   15.46 -#endif	/* For OSX */
   15.47 -#define IDSTR	"SFMT-216091:627-11-3-10-1:bff7bff7-bfffffff-bffffa7f-ffddfbfb"
   15.48 -
   15.49 -#endif /* SFMT_PARAMS216091_H */
    16.1 --- a/src/SFMT/SFMT-params2281.h	Sat Mar 03 10:54:39 2012 -0600
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,46 +0,0 @@
    16.4 -#ifndef SFMT_PARAMS2281_H
    16.5 -#define SFMT_PARAMS2281_H
    16.6 -
    16.7 -#define POS1	12
    16.8 -#define SL1	19
    16.9 -#define SL2	1
   16.10 -#define SR1	5
   16.11 -#define SR2	1
   16.12 -#define MSK1	0xbff7ffbfU
   16.13 -#define MSK2	0xfdfffffeU
   16.14 -#define MSK3	0xf7ffef7fU
   16.15 -#define MSK4	0xf2f7cbbfU
   16.16 -#define PARITY1	0x00000001U
   16.17 -#define PARITY2	0x00000000U
   16.18 -#define PARITY3	0x00000000U
   16.19 -#define PARITY4	0x41dfa600U
   16.20 -
   16.21 -
   16.22 -/* PARAMETERS FOR ALTIVEC */
   16.23 -#if defined(__APPLE__)	/* For OSX */
   16.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   16.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   16.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   16.27 -    #define ALTI_MSK64 \
   16.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   16.29 -    #define ALTI_SL2_PERM \
   16.30 -	(vector unsigned char)(1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8)
   16.31 -    #define ALTI_SL2_PERM64 \
   16.32 -	(vector unsigned char)(1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0)
   16.33 -    #define ALTI_SR2_PERM \
   16.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   16.35 -    #define ALTI_SR2_PERM64 \
   16.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   16.37 -#else	/* For OTHER OSs(Linux?) */
   16.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   16.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   16.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   16.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   16.42 -    #define ALTI_SL2_PERM	{1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8}
   16.43 -    #define ALTI_SL2_PERM64	{1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0}
   16.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   16.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   16.46 -#endif	/* For OSX */
   16.47 -#define IDSTR	"SFMT-2281:12-19-1-5-1:bff7ffbf-fdfffffe-f7ffef7f-f2f7cbbf"
   16.48 -
   16.49 -#endif /* SFMT_PARAMS2281_H */
    17.1 --- a/src/SFMT/SFMT-params4253.h	Sat Mar 03 10:54:39 2012 -0600
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,46 +0,0 @@
    17.4 -#ifndef SFMT_PARAMS4253_H
    17.5 -#define SFMT_PARAMS4253_H
    17.6 -
    17.7 -#define POS1	17
    17.8 -#define SL1	20
    17.9 -#define SL2	1
   17.10 -#define SR1	7
   17.11 -#define SR2	1
   17.12 -#define MSK1	0x9f7bffffU
   17.13 -#define MSK2	0x9fffff5fU
   17.14 -#define MSK3	0x3efffffbU
   17.15 -#define MSK4	0xfffff7bbU
   17.16 -#define PARITY1	0xa8000001U
   17.17 -#define PARITY2	0xaf5390a3U
   17.18 -#define PARITY3	0xb740b3f8U
   17.19 -#define PARITY4	0x6c11486dU
   17.20 -
   17.21 -
   17.22 -/* PARAMETERS FOR ALTIVEC */
   17.23 -#if defined(__APPLE__)	/* For OSX */
   17.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   17.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   17.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   17.27 -    #define ALTI_MSK64 \
   17.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   17.29 -    #define ALTI_SL2_PERM \
   17.30 -	(vector unsigned char)(1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8)
   17.31 -    #define ALTI_SL2_PERM64 \
   17.32 -	(vector unsigned char)(1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0)
   17.33 -    #define ALTI_SR2_PERM \
   17.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   17.35 -    #define ALTI_SR2_PERM64 \
   17.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   17.37 -#else	/* For OTHER OSs(Linux?) */
   17.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   17.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   17.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   17.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   17.42 -    #define ALTI_SL2_PERM	{1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8}
   17.43 -    #define ALTI_SL2_PERM64	{1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0}
   17.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   17.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   17.46 -#endif	/* For OSX */
   17.47 -#define IDSTR	"SFMT-4253:17-20-1-7-1:9f7bffff-9fffff5f-3efffffb-fffff7bb"
   17.48 -
   17.49 -#endif /* SFMT_PARAMS4253_H */
    18.1 --- a/src/SFMT/SFMT-params44497.h	Sat Mar 03 10:54:39 2012 -0600
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,46 +0,0 @@
    18.4 -#ifndef SFMT_PARAMS44497_H
    18.5 -#define SFMT_PARAMS44497_H
    18.6 -
    18.7 -#define POS1	330
    18.8 -#define SL1	5
    18.9 -#define SL2	3
   18.10 -#define SR1	9
   18.11 -#define SR2	3
   18.12 -#define MSK1	0xeffffffbU
   18.13 -#define MSK2	0xdfbebfffU
   18.14 -#define MSK3	0xbfbf7befU
   18.15 -#define MSK4	0x9ffd7bffU
   18.16 -#define PARITY1	0x00000001U
   18.17 -#define PARITY2	0x00000000U
   18.18 -#define PARITY3	0xa3ac4000U
   18.19 -#define PARITY4	0xecc1327aU
   18.20 -
   18.21 -
   18.22 -/* PARAMETERS FOR ALTIVEC */
   18.23 -#if defined(__APPLE__)	/* For OSX */
   18.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   18.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   18.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   18.27 -    #define ALTI_MSK64 \
   18.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   18.29 -    #define ALTI_SL2_PERM \
   18.30 -	(vector unsigned char)(3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10)
   18.31 -    #define ALTI_SL2_PERM64 \
   18.32 -	(vector unsigned char)(3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2)
   18.33 -    #define ALTI_SR2_PERM \
   18.34 -	(vector unsigned char)(5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12)
   18.35 -    #define ALTI_SR2_PERM64 \
   18.36 -	(vector unsigned char)(13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12)
   18.37 -#else	/* For OTHER OSs(Linux?) */
   18.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   18.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   18.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   18.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   18.42 -    #define ALTI_SL2_PERM	{3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10}
   18.43 -    #define ALTI_SL2_PERM64	{3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2}
   18.44 -    #define ALTI_SR2_PERM	{5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12}
   18.45 -    #define ALTI_SR2_PERM64	{13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12}
   18.46 -#endif	/* For OSX */
   18.47 -#define IDSTR	"SFMT-44497:330-5-3-9-3:effffffb-dfbebfff-bfbf7bef-9ffd7bff"
   18.48 -
   18.49 -#endif /* SFMT_PARAMS44497_H */
    19.1 --- a/src/SFMT/SFMT-params607.h	Sat Mar 03 10:54:39 2012 -0600
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,46 +0,0 @@
    19.4 -#ifndef SFMT_PARAMS607_H
    19.5 -#define SFMT_PARAMS607_H
    19.6 -
    19.7 -#define POS1	2
    19.8 -#define SL1	15
    19.9 -#define SL2	3
   19.10 -#define SR1	13
   19.11 -#define SR2	3
   19.12 -#define MSK1	0xfdff37ffU
   19.13 -#define MSK2	0xef7f3f7dU
   19.14 -#define MSK3	0xff777b7dU
   19.15 -#define MSK4	0x7ff7fb2fU
   19.16 -#define PARITY1	0x00000001U
   19.17 -#define PARITY2	0x00000000U
   19.18 -#define PARITY3	0x00000000U
   19.19 -#define PARITY4	0x5986f054U
   19.20 -
   19.21 -
   19.22 -/* PARAMETERS FOR ALTIVEC */
   19.23 -#if defined(__APPLE__)	/* For OSX */
   19.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   19.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   19.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   19.27 -    #define ALTI_MSK64 \
   19.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   19.29 -    #define ALTI_SL2_PERM \
   19.30 -	(vector unsigned char)(3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10)
   19.31 -    #define ALTI_SL2_PERM64 \
   19.32 -	(vector unsigned char)(3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2)
   19.33 -    #define ALTI_SR2_PERM \
   19.34 -	(vector unsigned char)(5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12)
   19.35 -    #define ALTI_SR2_PERM64 \
   19.36 -	(vector unsigned char)(13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12)
   19.37 -#else	/* For OTHER OSs(Linux?) */
   19.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   19.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   19.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   19.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   19.42 -    #define ALTI_SL2_PERM	{3,21,21,21,7,0,1,2,11,4,5,6,15,8,9,10}
   19.43 -    #define ALTI_SL2_PERM64	{3,4,5,6,7,29,29,29,11,12,13,14,15,0,1,2}
   19.44 -    #define ALTI_SR2_PERM	{5,6,7,0,9,10,11,4,13,14,15,8,19,19,19,12}
   19.45 -    #define ALTI_SR2_PERM64	{13,14,15,0,1,2,3,4,19,19,19,8,9,10,11,12}
   19.46 -#endif	/* For OSX */
   19.47 -#define IDSTR	"SFMT-607:2-15-3-13-3:fdff37ff-ef7f3f7d-ff777b7d-7ff7fb2f"
   19.48 -
   19.49 -#endif /* SFMT_PARAMS607_H */
    20.1 --- a/src/SFMT/SFMT-params86243.h	Sat Mar 03 10:54:39 2012 -0600
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,46 +0,0 @@
    20.4 -#ifndef SFMT_PARAMS86243_H
    20.5 -#define SFMT_PARAMS86243_H
    20.6 -
    20.7 -#define POS1	366
    20.8 -#define SL1	6
    20.9 -#define SL2	7
   20.10 -#define SR1	19
   20.11 -#define SR2	1
   20.12 -#define MSK1	0xfdbffbffU
   20.13 -#define MSK2	0xbff7ff3fU
   20.14 -#define MSK3	0xfd77efffU
   20.15 -#define MSK4	0xbf9ff3ffU
   20.16 -#define PARITY1	0x00000001U
   20.17 -#define PARITY2	0x00000000U
   20.18 -#define PARITY3	0x00000000U
   20.19 -#define PARITY4	0xe9528d85U
   20.20 -
   20.21 -
   20.22 -/* PARAMETERS FOR ALTIVEC */
   20.23 -#if defined(__APPLE__)	/* For OSX */
   20.24 -    #define ALTI_SL1	(vector unsigned int)(SL1, SL1, SL1, SL1)
   20.25 -    #define ALTI_SR1	(vector unsigned int)(SR1, SR1, SR1, SR1)
   20.26 -    #define ALTI_MSK	(vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
   20.27 -    #define ALTI_MSK64 \
   20.28 -	(vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
   20.29 -    #define ALTI_SL2_PERM \
   20.30 -	(vector unsigned char)(25,25,25,25,3,25,25,25,7,0,1,2,11,4,5,6)
   20.31 -    #define ALTI_SL2_PERM64 \
   20.32 -	(vector unsigned char)(7,25,25,25,25,25,25,25,15,0,1,2,3,4,5,6)
   20.33 -    #define ALTI_SR2_PERM \
   20.34 -	(vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14)
   20.35 -    #define ALTI_SR2_PERM64 \
   20.36 -	(vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14)
   20.37 -#else	/* For OTHER OSs(Linux?) */
   20.38 -    #define ALTI_SL1	{SL1, SL1, SL1, SL1}
   20.39 -    #define ALTI_SR1	{SR1, SR1, SR1, SR1}
   20.40 -    #define ALTI_MSK	{MSK1, MSK2, MSK3, MSK4}
   20.41 -    #define ALTI_MSK64	{MSK2, MSK1, MSK4, MSK3}
   20.42 -    #define ALTI_SL2_PERM	{25,25,25,25,3,25,25,25,7,0,1,2,11,4,5,6}
   20.43 -    #define ALTI_SL2_PERM64	{7,25,25,25,25,25,25,25,15,0,1,2,3,4,5,6}
   20.44 -    #define ALTI_SR2_PERM	{7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14}
   20.45 -    #define ALTI_SR2_PERM64	{15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14}
   20.46 -#endif	/* For OSX */
   20.47 -#define IDSTR	"SFMT-86243:366-6-7-19-1:fdbffbff-bff7ff3f-fd77efff-bf9ff3ff"
   20.48 -
   20.49 -#endif /* SFMT_PARAMS86243_H */
    21.1 --- a/src/SFMT/SFMT-sse2.h	Sat Mar 03 10:54:39 2012 -0600
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,121 +0,0 @@
    21.4 -/** 
    21.5 - * @file  SFMT-sse2.h
    21.6 - * @brief SIMD oriented Fast Mersenne Twister(SFMT) for Intel SSE2
    21.7 - *
    21.8 - * @author Mutsuo Saito (Hiroshima University)
    21.9 - * @author Makoto Matsumoto (Hiroshima University)
   21.10 - *
   21.11 - * @note We assume LITTLE ENDIAN in this file
   21.12 - *
   21.13 - * Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
   21.14 - * University. All rights reserved.
   21.15 - *
   21.16 - * The new BSD License is applied to this software, see LICENSE.txt
   21.17 - */
   21.18 -
   21.19 -#ifndef SFMT_SSE2_H
   21.20 -#define SFMT_SSE2_H
   21.21 -
   21.22 -PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b, __m128i c,
   21.23 -				   __m128i d, __m128i mask) ALWAYSINLINE;
   21.24 -
   21.25 -/**
   21.26 - * This function represents the recursion formula.
   21.27 - * @param a a 128-bit part of the interal state array
   21.28 - * @param b a 128-bit part of the interal state array
   21.29 - * @param c a 128-bit part of the interal state array
   21.30 - * @param d a 128-bit part of the interal state array
   21.31 - * @param mask 128-bit mask
   21.32 - * @return output
   21.33 - */
   21.34 -PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b, 
   21.35 -				   __m128i c, __m128i d, __m128i mask) {
   21.36 -    __m128i v, x, y, z;
   21.37 -    
   21.38 -    x = _mm_load_si128(a);
   21.39 -    y = _mm_srli_epi32(*b, SR1);
   21.40 -    z = _mm_srli_si128(c, SR2);
   21.41 -    v = _mm_slli_epi32(d, SL1);
   21.42 -    z = _mm_xor_si128(z, x);
   21.43 -    z = _mm_xor_si128(z, v);
   21.44 -    x = _mm_slli_si128(x, SL2);
   21.45 -    y = _mm_and_si128(y, mask);
   21.46 -    z = _mm_xor_si128(z, x);
   21.47 -    z = _mm_xor_si128(z, y);
   21.48 -    return z;
   21.49 -}
   21.50 -
   21.51 -/**
   21.52 - * This function fills the internal state array with pseudorandom
   21.53 - * integers.
   21.54 - */
   21.55 -inline static void gen_rand_all(void) {
   21.56 -    int i;
   21.57 -    __m128i r, r1, r2, mask;
   21.58 -    mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
   21.59 -
   21.60 -    r1 = _mm_load_si128(&sfmt[N - 2].si);
   21.61 -    r2 = _mm_load_si128(&sfmt[N - 1].si);
   21.62 -    for (i = 0; i < N - POS1; i++) {
   21.63 -	r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1].si, r1, r2, mask);
   21.64 -	_mm_store_si128(&sfmt[i].si, r);
   21.65 -	r1 = r2;
   21.66 -	r2 = r;
   21.67 -    }
   21.68 -    for (; i < N; i++) {
   21.69 -	r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1 - N].si, r1, r2, mask);
   21.70 -	_mm_store_si128(&sfmt[i].si, r);
   21.71 -	r1 = r2;
   21.72 -	r2 = r;
   21.73 -    }
   21.74 -}
   21.75 -
   21.76 -/**
   21.77 - * This function fills the user-specified array with pseudorandom
   21.78 - * integers.
   21.79 - *
   21.80 - * @param array an 128-bit array to be filled by pseudorandom numbers.  
   21.81 - * @param size number of 128-bit pesudorandom numbers to be generated.
   21.82 - */
   21.83 -inline static void gen_rand_array(w128_t *array, int size) {
   21.84 -    int i, j;
   21.85 -    __m128i r, r1, r2, mask;
   21.86 -    mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
   21.87 -
   21.88 -    r1 = _mm_load_si128(&sfmt[N - 2].si);
   21.89 -    r2 = _mm_load_si128(&sfmt[N - 1].si);
   21.90 -    for (i = 0; i < N - POS1; i++) {
   21.91 -	r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1].si, r1, r2, mask);
   21.92 -	_mm_store_si128(&array[i].si, r);
   21.93 -	r1 = r2;
   21.94 -	r2 = r;
   21.95 -    }
   21.96 -    for (; i < N; i++) {
   21.97 -	r = mm_recursion(&sfmt[i].si, &array[i + POS1 - N].si, r1, r2, mask);
   21.98 -	_mm_store_si128(&array[i].si, r);
   21.99 -	r1 = r2;
  21.100 -	r2 = r;
  21.101 -    }
  21.102 -    /* main loop */
  21.103 -    for (; i < size - N; i++) {
  21.104 -	r = mm_recursion(&array[i - N].si, &array[i + POS1 - N].si, r1, r2,
  21.105 -			 mask);
  21.106 -	_mm_store_si128(&array[i].si, r);
  21.107 -	r1 = r2;
  21.108 -	r2 = r;
  21.109 -    }
  21.110 -    for (j = 0; j < 2 * N - size; j++) {
  21.111 -	r = _mm_load_si128(&array[j + size - N].si);
  21.112 -	_mm_store_si128(&sfmt[j].si, r);
  21.113 -    }
  21.114 -    for (; i < size; i++) {
  21.115 -	r = mm_recursion(&array[i - N].si, &array[i + POS1 - N].si, r1, r2,
  21.116 -			 mask);
  21.117 -	_mm_store_si128(&array[i].si, r);
  21.118 -	_mm_store_si128(&sfmt[j++].si, r);
  21.119 -	r1 = r2;
  21.120 -	r2 = r;
  21.121 -    }
  21.122 -}
  21.123 -
  21.124 -#endif
    22.1 --- a/src/SFMT/SFMT.c	Sat Mar 03 10:54:39 2012 -0600
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,620 +0,0 @@
    22.4 -/** 
    22.5 - * @file  SFMT.c
    22.6 - * @brief SIMD oriented Fast Mersenne Twister(SFMT)
    22.7 - *
    22.8 - * @author Mutsuo Saito (Hiroshima University)
    22.9 - * @author Makoto Matsumoto (Hiroshima University)
   22.10 - *
   22.11 - * Copyright (C) 2006,2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
   22.12 - * University. All rights reserved.
   22.13 - *
   22.14 - * The new BSD License is applied to this software, see LICENSE.txt
   22.15 - */
   22.16 -#include <string.h>
   22.17 -#include <assert.h>
   22.18 -#include "SFMT.h"
   22.19 -#include "SFMT-params.h"
   22.20 -
   22.21 -#if defined(__BIG_ENDIAN__) && !defined(__amd64) && !defined(BIG_ENDIAN64)
   22.22 -#define BIG_ENDIAN64 1
   22.23 -#endif
   22.24 -#if defined(HAVE_ALTIVEC) && !defined(BIG_ENDIAN64)
   22.25 -#define BIG_ENDIAN64 1
   22.26 -#endif
   22.27 -#if defined(ONLY64) && !defined(BIG_ENDIAN64)
   22.28 -  #if defined(__GNUC__)
   22.29 -    #error "-DONLY64 must be specified with -DBIG_ENDIAN64"
   22.30 -  #endif
   22.31 -#undef ONLY64
   22.32 -#endif
   22.33 -/*------------------------------------------------------
   22.34 -  128-bit SIMD data type for Altivec, SSE2 or standard C
   22.35 -  ------------------------------------------------------*/
   22.36 -#if defined(HAVE_ALTIVEC)
   22.37 -  #if !defined(__APPLE__)
   22.38 -    #include <altivec.h>
   22.39 -  #endif
   22.40 -/** 128-bit data structure */
   22.41 -union W128_T {
   22.42 -    vector unsigned int s;
   22.43 -    uint32_t u[4];
   22.44 -};
   22.45 -/** 128-bit data type */
   22.46 -typedef union W128_T w128_t;
   22.47 -
   22.48 -#elif defined(HAVE_SSE2)
   22.49 -  #include <emmintrin.h>
   22.50 -
   22.51 -/** 128-bit data structure */
   22.52 -union W128_T {
   22.53 -    __m128i si;
   22.54 -    uint32_t u[4];
   22.55 -};
   22.56 -/** 128-bit data type */
   22.57 -typedef union W128_T w128_t;
   22.58 -
   22.59 -#else
   22.60 -
   22.61 -/** 128-bit data structure */
   22.62 -struct W128_T {
   22.63 -    uint32_t u[4];
   22.64 -};
   22.65 -/** 128-bit data type */
   22.66 -typedef struct W128_T w128_t;
   22.67 -
   22.68 -#endif
   22.69 -
   22.70 -/*--------------------------------------
   22.71 -  FILE GLOBAL VARIABLES
   22.72 -  internal state, index counter and flag 
   22.73 -  --------------------------------------*/
   22.74 -/** the 128-bit internal state array */
   22.75 -static w128_t sfmt[N];
   22.76 -/** the 32bit integer pointer to the 128-bit internal state array */
   22.77 -static uint32_t *psfmt32 = &sfmt[0].u[0];
   22.78 -#if !defined(BIG_ENDIAN64) || defined(ONLY64)
   22.79 -/** the 64bit integer pointer to the 128-bit internal state array */
   22.80 -static uint64_t *psfmt64 = (uint64_t *)&sfmt[0].u[0];
   22.81 -#endif
   22.82 -/** index counter to the 32-bit internal state array */
   22.83 -static int idx;
   22.84 -/** a flag: it is 0 if and only if the internal state is not yet
   22.85 - * initialized. */
   22.86 -static int initialized = 0;
   22.87 -/** a parity check vector which certificate the period of 2^{MEXP} */
   22.88 -static uint32_t parity[4] = {PARITY1, PARITY2, PARITY3, PARITY4};
   22.89 -
   22.90 -/*----------------
   22.91 -  STATIC FUNCTIONS
   22.92 -  ----------------*/
   22.93 -inline static int idxof(int i);
   22.94 -inline static void rshift128(w128_t *out,  w128_t const *in, int shift);
   22.95 -inline static void lshift128(w128_t *out,  w128_t const *in, int shift);
   22.96 -inline static void gen_rand_all(void);
   22.97 -inline static void gen_rand_array(w128_t *array, int size);
   22.98 -inline static uint32_t func1(uint32_t x);
   22.99 -inline static uint32_t func2(uint32_t x);
  22.100 -static void period_certification(void);
  22.101 -#if defined(BIG_ENDIAN64) && !defined(ONLY64)
  22.102 -inline static void swap(w128_t *array, int size);
  22.103 -#endif
  22.104 -
  22.105 -#if defined(HAVE_ALTIVEC)
  22.106 -  #include "SFMT-alti.h"
  22.107 -#elif defined(HAVE_SSE2)
  22.108 -  #include "SFMT-sse2.h"
  22.109 -#endif
  22.110 -
  22.111 -/**
  22.112 - * This function simulate a 64-bit index of LITTLE ENDIAN 
  22.113 - * in BIG ENDIAN machine.
  22.114 - */
  22.115 -#ifdef ONLY64
  22.116 -inline static int idxof(int i) {
  22.117 -    return i ^ 1;
  22.118 -}
  22.119 -#else
  22.120 -inline static int idxof(int i) {
  22.121 -    return i;
  22.122 -}
  22.123 -#endif
  22.124 -/**
  22.125 - * This function simulates SIMD 128-bit right shift by the standard C.
  22.126 - * The 128-bit integer given in in is shifted by (shift * 8) bits.
  22.127 - * This function simulates the LITTLE ENDIAN SIMD.
  22.128 - * @param out the output of this function
  22.129 - * @param in the 128-bit data to be shifted
  22.130 - * @param shift the shift value
  22.131 - */
  22.132 -#ifdef ONLY64
  22.133 -inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
  22.134 -    uint64_t th, tl, oh, ol;
  22.135 -
  22.136 -    th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
  22.137 -    tl = ((uint64_t)in->u[0] << 32) | ((uint64_t)in->u[1]);
  22.138 -
  22.139 -    oh = th >> (shift * 8);
  22.140 -    ol = tl >> (shift * 8);
  22.141 -    ol |= th << (64 - shift * 8);
  22.142 -    out->u[0] = (uint32_t)(ol >> 32);
  22.143 -    out->u[1] = (uint32_t)(ol & 0xffffffff);
  22.144 -    out->u[2] = (uint32_t)(oh >> 32);
  22.145 -    out->u[3] = (uint32_t)(oh & 0xffffffff);
  22.146 -}
  22.147 -#else
  22.148 -inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
  22.149 -    uint64_t th, tl, oh, ol;
  22.150 -
  22.151 -    th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
  22.152 -    tl = ((uint64_t)in->u[1] << 32) | ((uint64_t)in->u[0]);
  22.153 -
  22.154 -    oh = th >> (shift * 8);
  22.155 -    ol = tl >> (shift * 8);
  22.156 -    ol |= th << (64 - shift * 8);
  22.157 -    out->u[1] = (uint32_t)(ol >> 32);
  22.158 -    out->u[0] = (uint32_t)(ol & 0xffffffff);
  22.159 -    out->u[3] = (uint32_t)(oh >> 32);
  22.160 -    out->u[2] = (uint32_t)(oh & 0xffffffff);
  22.161 -}
  22.162 -#endif
  22.163 -/**
  22.164 - * This function simulates SIMD 128-bit left shift by the standard C.
  22.165 - * The 128-bit integer given in in is shifted by (shift * 8) bits.
  22.166 - * This function simulates the LITTLE ENDIAN SIMD.
  22.167 - * @param out the output of this function
  22.168 - * @param in the 128-bit data to be shifted
  22.169 - * @param shift the shift value
  22.170 - */
  22.171 -#ifdef ONLY64
  22.172 -inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
  22.173 -    uint64_t th, tl, oh, ol;
  22.174 -
  22.175 -    th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
  22.176 -    tl = ((uint64_t)in->u[0] << 32) | ((uint64_t)in->u[1]);
  22.177 -
  22.178 -    oh = th << (shift * 8);
  22.179 -    ol = tl << (shift * 8);
  22.180 -    oh |= tl >> (64 - shift * 8);
  22.181 -    out->u[0] = (uint32_t)(ol >> 32);
  22.182 -    out->u[1] = (uint32_t)(ol & 0xffffffff);
  22.183 -    out->u[2] = (uint32_t)(oh >> 32);
  22.184 -    out->u[3] = (uint32_t)(oh & 0xffffffff);
  22.185 -}
  22.186 -#else
  22.187 -inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
  22.188 -    uint64_t th, tl, oh, ol;
  22.189 -
  22.190 -    th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
  22.191 -    tl = ((uint64_t)in->u[1] << 32) | ((uint64_t)in->u[0]);
  22.192 -
  22.193 -    oh = th << (shift * 8);
  22.194 -    ol = tl << (shift * 8);
  22.195 -    oh |= tl >> (64 - shift * 8);
  22.196 -    out->u[1] = (uint32_t)(ol >> 32);
  22.197 -    out->u[0] = (uint32_t)(ol & 0xffffffff);
  22.198 -    out->u[3] = (uint32_t)(oh >> 32);
  22.199 -    out->u[2] = (uint32_t)(oh & 0xffffffff);
  22.200 -}
  22.201 -#endif
  22.202 -
  22.203 -/**
  22.204 - * This function represents the recursion formula.
  22.205 - * @param r output
  22.206 - * @param a a 128-bit part of the internal state array
  22.207 - * @param b a 128-bit part of the internal state array
  22.208 - * @param c a 128-bit part of the internal state array
  22.209 - * @param d a 128-bit part of the internal state array
  22.210 - */
  22.211 -#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
  22.212 -#ifdef ONLY64
  22.213 -inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
  22.214 -				w128_t *d) {
  22.215 -    w128_t x;
  22.216 -    w128_t y;
  22.217 -
  22.218 -    lshift128(&x, a, SL2);
  22.219 -    rshift128(&y, c, SR2);
  22.220 -    r->u[0] = a->u[0] ^ x.u[0] ^ ((b->u[0] >> SR1) & MSK2) ^ y.u[0] 
  22.221 -	^ (d->u[0] << SL1);
  22.222 -    r->u[1] = a->u[1] ^ x.u[1] ^ ((b->u[1] >> SR1) & MSK1) ^ y.u[1] 
  22.223 -	^ (d->u[1] << SL1);
  22.224 -    r->u[2] = a->u[2] ^ x.u[2] ^ ((b->u[2] >> SR1) & MSK4) ^ y.u[2] 
  22.225 -	^ (d->u[2] << SL1);
  22.226 -    r->u[3] = a->u[3] ^ x.u[3] ^ ((b->u[3] >> SR1) & MSK3) ^ y.u[3] 
  22.227 -	^ (d->u[3] << SL1);
  22.228 -}
  22.229 -#else
  22.230 -inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
  22.231 -				w128_t *d) {
  22.232 -    w128_t x;
  22.233 -    w128_t y;
  22.234 -
  22.235 -    lshift128(&x, a, SL2);
  22.236 -    rshift128(&y, c, SR2);
  22.237 -    r->u[0] = a->u[0] ^ x.u[0] ^ ((b->u[0] >> SR1) & MSK1) ^ y.u[0] 
  22.238 -	^ (d->u[0] << SL1);
  22.239 -    r->u[1] = a->u[1] ^ x.u[1] ^ ((b->u[1] >> SR1) & MSK2) ^ y.u[1] 
  22.240 -	^ (d->u[1] << SL1);
  22.241 -    r->u[2] = a->u[2] ^ x.u[2] ^ ((b->u[2] >> SR1) & MSK3) ^ y.u[2] 
  22.242 -	^ (d->u[2] << SL1);
  22.243 -    r->u[3] = a->u[3] ^ x.u[3] ^ ((b->u[3] >> SR1) & MSK4) ^ y.u[3] 
  22.244 -	^ (d->u[3] << SL1);
  22.245 -}
  22.246 -#endif
  22.247 -#endif
  22.248 -
  22.249 -#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
  22.250 -/**
  22.251 - * This function fills the internal state array with pseudorandom
  22.252 - * integers.
  22.253 - */
  22.254 -inline static void gen_rand_all(void) {
  22.255 -    int i;
  22.256 -    w128_t *r1, *r2;
  22.257 -
  22.258 -    r1 = &sfmt[N - 2];
  22.259 -    r2 = &sfmt[N - 1];
  22.260 -    for (i = 0; i < N - POS1; i++) {
  22.261 -	do_recursion(&sfmt[i], &sfmt[i], &sfmt[i + POS1], r1, r2);
  22.262 -	r1 = r2;
  22.263 -	r2 = &sfmt[i];
  22.264 -    }
  22.265 -    for (; i < N; i++) {
  22.266 -	do_recursion(&sfmt[i], &sfmt[i], &sfmt[i + POS1 - N], r1, r2);
  22.267 -	r1 = r2;
  22.268 -	r2 = &sfmt[i];
  22.269 -    }
  22.270 -}
  22.271 -
  22.272 -/**
  22.273 - * This function fills the user-specified array with pseudorandom
  22.274 - * integers.
  22.275 - *
  22.276 - * @param array an 128-bit array to be filled by pseudorandom numbers.  
  22.277 - * @param size number of 128-bit pseudorandom numbers to be generated.
  22.278 - */
  22.279 -inline static void gen_rand_array(w128_t *array, int size) {
  22.280 -    int i, j;
  22.281 -    w128_t *r1, *r2;
  22.282 -
  22.283 -    r1 = &sfmt[N - 2];
  22.284 -    r2 = &sfmt[N - 1];
  22.285 -    for (i = 0; i < N - POS1; i++) {
  22.286 -	do_recursion(&array[i], &sfmt[i], &sfmt[i + POS1], r1, r2);
  22.287 -	r1 = r2;
  22.288 -	r2 = &array[i];
  22.289 -    }
  22.290 -    for (; i < N; i++) {
  22.291 -	do_recursion(&array[i], &sfmt[i], &array[i + POS1 - N], r1, r2);
  22.292 -	r1 = r2;
  22.293 -	r2 = &array[i];
  22.294 -    }
  22.295 -    for (; i < size - N; i++) {
  22.296 -	do_recursion(&array[i], &array[i - N], &array[i + POS1 - N], r1, r2);
  22.297 -	r1 = r2;
  22.298 -	r2 = &array[i];
  22.299 -    }
  22.300 -    for (j = 0; j < 2 * N - size; j++) {
  22.301 -	sfmt[j] = array[j + size - N];
  22.302 -    }
  22.303 -    for (; i < size; i++, j++) {
  22.304 -	do_recursion(&array[i], &array[i - N], &array[i + POS1 - N], r1, r2);
  22.305 -	r1 = r2;
  22.306 -	r2 = &array[i];
  22.307 -	sfmt[j] = array[i];
  22.308 -    }
  22.309 -}
  22.310 -#endif
  22.311 -
  22.312 -#if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC)
  22.313 -inline static void swap(w128_t *array, int size) {
  22.314 -    int i;
  22.315 -    uint32_t x, y;
  22.316 -
  22.317 -    for (i = 0; i < size; i++) {
  22.318 -	x = array[i].u[0];
  22.319 -	y = array[i].u[2];
  22.320 -	array[i].u[0] = array[i].u[1];
  22.321 -	array[i].u[2] = array[i].u[3];
  22.322 -	array[i].u[1] = x;
  22.323 -	array[i].u[3] = y;
  22.324 -    }
  22.325 -}
  22.326 -#endif
  22.327 -/**
  22.328 - * This function represents a function used in the initialization
  22.329 - * by init_by_array
  22.330 - * @param x 32-bit integer
  22.331 - * @return 32-bit integer
  22.332 - */
  22.333 -static uint32_t func1(uint32_t x) {
  22.334 -    return (x ^ (x >> 27)) * (uint32_t)1664525UL;
  22.335 -}
  22.336 -
  22.337 -/**
  22.338 - * This function represents a function used in the initialization
  22.339 - * by init_by_array
  22.340 - * @param x 32-bit integer
  22.341 - * @return 32-bit integer
  22.342 - */
  22.343 -static uint32_t func2(uint32_t x) {
  22.344 -    return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
  22.345 -}
  22.346 -
  22.347 -/**
  22.348 - * This function certificate the period of 2^{MEXP}
  22.349 - */
  22.350 -static void period_certification(void) {
  22.351 -    int inner = 0;
  22.352 -    int i, j;
  22.353 -    uint32_t work;
  22.354 -
  22.355 -    for (i = 0; i < 4; i++)
  22.356 -	inner ^= psfmt32[idxof(i)] & parity[i];
  22.357 -    for (i = 16; i > 0; i >>= 1)
  22.358 -	inner ^= inner >> i;
  22.359 -    inner &= 1;
  22.360 -    /* check OK */
  22.361 -    if (inner == 1) {
  22.362 -	return;
  22.363 -    }
  22.364 -    /* check NG, and modification */
  22.365 -    for (i = 0; i < 4; i++) {
  22.366 -	work = 1;
  22.367 -	for (j = 0; j < 32; j++) {
  22.368 -	    if ((work & parity[i]) != 0) {
  22.369 -		psfmt32[idxof(i)] ^= work;
  22.370 -		return;
  22.371 -	    }
  22.372 -	    work = work << 1;
  22.373 -	}
  22.374 -    }
  22.375 -}
  22.376 -
  22.377 -/*----------------
  22.378 -  PUBLIC FUNCTIONS
  22.379 -  ----------------*/
  22.380 -/**
  22.381 - * This function returns the identification string.
  22.382 - * The string shows the word size, the Mersenne exponent,
  22.383 - * and all parameters of this generator.
  22.384 - */
  22.385 -const char *get_idstring(void) {
  22.386 -    return IDSTR;
  22.387 -}
  22.388 -
  22.389 -/**
  22.390 - * This function returns the minimum size of array used for \b
  22.391 - * fill_array32() function.
  22.392 - * @return minimum size of array used for fill_array32() function.
  22.393 - */
  22.394 -int get_min_array_size32(void) {
  22.395 -    return N32;
  22.396 -}
  22.397 -
  22.398 -/**
  22.399 - * This function returns the minimum size of array used for \b
  22.400 - * fill_array64() function.
  22.401 - * @return minimum size of array used for fill_array64() function.
  22.402 - */
  22.403 -int get_min_array_size64(void) {
  22.404 -    return N64;
  22.405 -}
  22.406 -
  22.407 -#ifndef ONLY64
  22.408 -/**
  22.409 - * This function generates and returns 32-bit pseudorandom number.
  22.410 - * init_gen_rand or init_by_array must be called before this function.
  22.411 - * @return 32-bit pseudorandom number
  22.412 - */
  22.413 -uint32_t gen_rand32(void) {
  22.414 -    uint32_t r;
  22.415 -
  22.416 -    assert(initialized);
  22.417 -    if (idx >= N32) {
  22.418 -	gen_rand_all();
  22.419 -	idx = 0;
  22.420 -    }
  22.421 -    r = psfmt32[idx++];
  22.422 -    return r;
  22.423 -}
  22.424 -#endif
  22.425 -/**
  22.426 - * This function generates and returns 64-bit pseudorandom number.
  22.427 - * init_gen_rand or init_by_array must be called before this function.
  22.428 - * The function gen_rand64 should not be called after gen_rand32,
  22.429 - * unless an initialization is again executed. 
  22.430 - * @return 64-bit pseudorandom number
  22.431 - */
  22.432 -uint64_t gen_rand64(void) {
  22.433 -#if defined(BIG_ENDIAN64) && !defined(ONLY64)
  22.434 -    uint32_t r1, r2;
  22.435 -#else
  22.436 -    uint64_t r;
  22.437 -#endif
  22.438 -
  22.439 -    assert(initialized);
  22.440 -    assert(idx % 2 == 0);
  22.441 -
  22.442 -    if (idx >= N32) {
  22.443 -	gen_rand_all();
  22.444 -	idx = 0;
  22.445 -    }
  22.446 -#if defined(BIG_ENDIAN64) && !defined(ONLY64)
  22.447 -    r1 = psfmt32[idx];
  22.448 -    r2 = psfmt32[idx + 1];
  22.449 -    idx += 2;
  22.450 -    return ((uint64_t)r2 << 32) | r1;
  22.451 -#else
  22.452 -    r = psfmt64[idx / 2];
  22.453 -    idx += 2;
  22.454 -    return r;
  22.455 -#endif
  22.456 -}
  22.457 -
  22.458 -#ifndef ONLY64
  22.459 -/**
  22.460 - * This function generates pseudorandom 32-bit integers in the
  22.461 - * specified array[] by one call. The number of pseudorandom integers
  22.462 - * is specified by the argument size, which must be at least 624 and a
  22.463 - * multiple of four.  The generation by this function is much faster
  22.464 - * than the following gen_rand function.
  22.465 - *
  22.466 - * For initialization, init_gen_rand or init_by_array must be called
  22.467 - * before the first call of this function. This function can not be
  22.468 - * used after calling gen_rand function, without initialization.
  22.469 - *
  22.470 - * @param array an array where pseudorandom 32-bit integers are filled
  22.471 - * by this function.  The pointer to the array must be \b "aligned"
  22.472 - * (namely, must be a multiple of 16) in the SIMD version, since it
  22.473 - * refers to the address of a 128-bit integer.  In the standard C
  22.474 - * version, the pointer is arbitrary.
  22.475 - *
  22.476 - * @param size the number of 32-bit pseudorandom integers to be
  22.477 - * generated.  size must be a multiple of 4, and greater than or equal
  22.478 - * to (MEXP / 128 + 1) * 4.
  22.479 - *
  22.480 - * @note \b memalign or \b posix_memalign is available to get aligned
  22.481 - * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
  22.482 - * returns the pointer to the aligned memory block.
  22.483 - */
  22.484 -void fill_array32(uint32_t *array, int size) {
  22.485 -    assert(initialized);
  22.486 -    assert(idx == N32);
  22.487 -    assert(size % 4 == 0);
  22.488 -    assert(size >= N32);
  22.489 -
  22.490 -    gen_rand_array((w128_t *)array, size / 4);
  22.491 -    idx = N32;
  22.492 -}
  22.493 -#endif
  22.494 -
  22.495 -/**
  22.496 - * This function generates pseudorandom 64-bit integers in the
  22.497 - * specified array[] by one call. The number of pseudorandom integers
  22.498 - * is specified by the argument size, which must be at least 312 and a
  22.499 - * multiple of two.  The generation by this function is much faster
  22.500 - * than the following gen_rand function.
  22.501 - *
  22.502 - * For initialization, init_gen_rand or init_by_array must be called
  22.503 - * before the first call of this function. This function can not be
  22.504 - * used after calling gen_rand function, without initialization.
  22.505 - *
  22.506 - * @param array an array where pseudorandom 64-bit integers are filled
  22.507 - * by this function.  The pointer to the array must be "aligned"
  22.508 - * (namely, must be a multiple of 16) in the SIMD version, since it
  22.509 - * refers to the address of a 128-bit integer.  In the standard C
  22.510 - * version, the pointer is arbitrary.
  22.511 - *
  22.512 - * @param size the number of 64-bit pseudorandom integers to be
  22.513 - * generated.  size must be a multiple of 2, and greater than or equal
  22.514 - * to (MEXP / 128 + 1) * 2
  22.515 - *
  22.516 - * @note \b memalign or \b posix_memalign is available to get aligned
  22.517 - * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
  22.518 - * returns the pointer to the aligned memory block.
  22.519 - */
  22.520 -void fill_array64(uint64_t *array, int size) {
  22.521 -    assert(initialized);
  22.522 -    assert(idx == N32);
  22.523 -    assert(size % 2 == 0);
  22.524 -    assert(size >= N64);
  22.525 -
  22.526 -    gen_rand_array((w128_t *)array, size / 2);
  22.527 -    idx = N32;
  22.528 -
  22.529 -#if defined(BIG_ENDIAN64) && !defined(ONLY64)
  22.530 -    swap((w128_t *)array, size /2);
  22.531 -#endif
  22.532 -}
  22.533 -
  22.534 -/**
  22.535 - * This function initializes the internal state array with a 32-bit
  22.536 - * integer seed.
  22.537 - *
  22.538 - * @param seed a 32-bit integer used as the seed.
  22.539 - */
  22.540 -void init_gen_rand(uint32_t seed) {
  22.541 -    int i;
  22.542 -
  22.543 -    psfmt32[idxof(0)] = seed;
  22.544 -    for (i = 1; i < N32; i++) {
  22.545 -	psfmt32[idxof(i)] = 1812433253UL * (psfmt32[idxof(i - 1)] 
  22.546 -					    ^ (psfmt32[idxof(i - 1)] >> 30))
  22.547 -	    + i;
  22.548 -    }
  22.549 -    idx = N32;
  22.550 -    period_certification();
  22.551 -    initialized = 1;
  22.552 -}
  22.553 -
  22.554 -/**
  22.555 - * This function initializes the internal state array,
  22.556 - * with an array of 32-bit integers used as the seeds
  22.557 - * @param init_key the array of 32-bit integers, used as a seed.
  22.558 - * @param key_length the length of init_key.
  22.559 - */
  22.560 -void init_by_array(uint32_t *init_key, int key_length) {
  22.561 -    int i, j, count;
  22.562 -    uint32_t r;
  22.563 -    int lag;
  22.564 -    int mid;
  22.565 -    int size = N * 4;
  22.566 -
  22.567 -    if (size >= 623) {
  22.568 -	lag = 11;
  22.569 -    } else if (size >= 68) {
  22.570 -	lag = 7;
  22.571 -    } else if (size >= 39) {
  22.572 -	lag = 5;
  22.573 -    } else {
  22.574 -	lag = 3;
  22.575 -    }
  22.576 -    mid = (size - lag) / 2;
  22.577 -
  22.578 -    memset(sfmt, 0x8b, sizeof(sfmt));
  22.579 -    if (key_length + 1 > N32) {
  22.580 -	count = key_length + 1;
  22.581 -    } else {
  22.582 -	count = N32;
  22.583 -    }
  22.584 -    r = func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid)] 
  22.585 -	      ^ psfmt32[idxof(N32 - 1)]);
  22.586 -    psfmt32[idxof(mid)] += r;
  22.587 -    r += key_length;
  22.588 -    psfmt32[idxof(mid + lag)] += r;
  22.589 -    psfmt32[idxof(0)] = r;
  22.590 -
  22.591 -    count--;
  22.592 -    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
  22.593 -	r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % N32)] 
  22.594 -		  ^ psfmt32[idxof((i + N32 - 1) % N32)]);
  22.595 -	psfmt32[idxof((i + mid) % N32)] += r;
  22.596 -	r += init_key[j] + i;
  22.597 -	psfmt32[idxof((i + mid + lag) % N32)] += r;
  22.598 -	psfmt32[idxof(i)] = r;
  22.599 -	i = (i + 1) % N32;
  22.600 -    }
  22.601 -    for (; j < count; j++) {
  22.602 -	r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % N32)] 
  22.603 -		  ^ psfmt32[idxof((i + N32 - 1) % N32)]);
  22.604 -	psfmt32[idxof((i + mid) % N32)] += r;
  22.605 -	r += i;
  22.606 -	psfmt32[idxof((i + mid + lag) % N32)] += r;
  22.607 -	psfmt32[idxof(i)] = r;
  22.608 -	i = (i + 1) % N32;
  22.609 -    }
  22.610 -    for (j = 0; j < N32; j++) {
  22.611 -	r = func2(psfmt32[idxof(i)] + psfmt32[idxof((i + mid) % N32)] 
  22.612 -		  + psfmt32[idxof((i + N32 - 1) % N32)]);
  22.613 -	psfmt32[idxof((i + mid) % N32)] ^= r;
  22.614 -	r -= i;
  22.615 -	psfmt32[idxof((i + mid + lag) % N32)] ^= r;
  22.616 -	psfmt32[idxof(i)] = r;
  22.617 -	i = (i + 1) % N32;
  22.618 -    }
  22.619 -
  22.620 -    idx = N32;
  22.621 -    period_certification();
  22.622 -    initialized = 1;
  22.623 -}
    23.1 --- a/src/SFMT/SFMT.h	Sat Mar 03 10:54:39 2012 -0600
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,165 +0,0 @@
    23.4 -/** 
    23.5 - * @file SFMT.h 
    23.6 - *
    23.7 - * @brief SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom
    23.8 - * number generator
    23.9 - *
   23.10 - * @author Mutsuo Saito (Hiroshima University)
   23.11 - * @author Makoto Matsumoto (Hiroshima University)
   23.12 - *
   23.13 - * Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
   23.14 - * University. All rights reserved.
   23.15 - *
   23.16 - * The new BSD License is applied to this software.
   23.17 - * see LICENSE.txt
   23.18 - *
   23.19 - * @note We assume that your system has inttypes.h.  If your system
   23.20 - * doesn't have inttypes.h, you have to typedef uint32_t and uint64_t,
   23.21 - * and you have to define PRIu64 and PRIx64 in this file as follows:
   23.22 - * @verbatim
   23.23 - typedef unsigned int uint32_t
   23.24 - typedef unsigned long long uint64_t  
   23.25 - #define PRIu64 "llu"
   23.26 - #define PRIx64 "llx"
   23.27 -@endverbatim
   23.28 - * uint32_t must be exactly 32-bit unsigned integer type (no more, no
   23.29 - * less), and uint64_t must be exactly 64-bit unsigned integer type.
   23.30 - * PRIu64 and PRIx64 are used for printf function to print 64-bit
   23.31 - * unsigned int and 64-bit unsigned int in hexadecimal format.
   23.32 - */
   23.33 -
   23.34 -#ifndef SFMT_H
   23.35 -#define SFMT_H
   23.36 -
   23.37 -#include <stdio.h>
   23.38 -
   23.39 -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
   23.40 -  #include <inttypes.h>
   23.41 -#elif defined(_MSC_VER) || defined(__BORLANDC__)
   23.42 -  typedef unsigned int uint32_t;
   23.43 -  typedef unsigned __int64 uint64_t;
   23.44 -  #define inline __inline
   23.45 -#else
   23.46 -  #include <inttypes.h>
   23.47 -  #if defined(__GNUC__)
   23.48 -    #define inline __inline__
   23.49 -  #endif
   23.50 -#endif
   23.51 -
   23.52 -#ifndef PRIu64
   23.53 -  #if defined(_MSC_VER) || defined(__BORLANDC__)
   23.54 -    #define PRIu64 "I64u"
   23.55 -    #define PRIx64 "I64x"
   23.56 -  #else
   23.57 -    #define PRIu64 "llu"
   23.58 -    #define PRIx64 "llx"
   23.59 -  #endif
   23.60 -#endif
   23.61 -
   23.62 -#if defined(__GNUC__)
   23.63 -#define ALWAYSINLINE __attribute__((always_inline))
   23.64 -#else
   23.65 -#define ALWAYSINLINE
   23.66 -#endif
   23.67 -
   23.68 -#if defined(_MSC_VER)
   23.69 -  #if _MSC_VER >= 1200
   23.70 -    #define PRE_ALWAYS __forceinline
   23.71 -  #else
   23.72 -    #define PRE_ALWAYS inline
   23.73 -  #endif
   23.74 -#else
   23.75 -  #define PRE_ALWAYS inline
   23.76 -#endif
   23.77 -
   23.78 -#if defined(__cplusplus) || defined(c_plusplus)
   23.79 -//extern "C" {
   23.80 -#endif
   23.81 -
   23.82 -uint32_t gen_rand32(void);
   23.83 -uint64_t gen_rand64(void);
   23.84 -void fill_array32(uint32_t *array, int size);
   23.85 -void fill_array64(uint64_t *array, int size);
   23.86 -void init_gen_rand(uint32_t seed);
   23.87 -void init_by_array(uint32_t *init_key, int key_length);
   23.88 -const char *get_idstring(void);
   23.89 -int get_min_array_size32(void);
   23.90 -int get_min_array_size64(void);
   23.91 -
   23.92 -#if defined(__cplusplus) || defined(c_plusplus)
   23.93 -//} // end extern
   23.94 -#endif
   23.95 -
   23.96 -/* These real versions are due to Isaku Wada */
   23.97 -/** generates a random number on [0,1]-real-interval */
   23.98 -inline static double to_real1(uint32_t v)
   23.99 -{
  23.100 -    return v * (1.0/4294967295.0); 
  23.101 -    /* divided by 2^32-1 */ 
  23.102 -}
  23.103 -
  23.104 -/** generates a random number on [0,1]-real-interval */
  23.105 -inline static double genrand_real1(void)
  23.106 -{
  23.107 -    return to_real1(gen_rand32());
  23.108 -}
  23.109 -
  23.110 -/** generates a random number on [0,1)-real-interval */
  23.111 -inline static double to_real2(uint32_t v)
  23.112 -{
  23.113 -    return v * (1.0/4294967296.0); 
  23.114 -    /* divided by 2^32 */
  23.115 -}
  23.116 -
  23.117 -/** generates a random number on [0,1)-real-interval */
  23.118 -inline static double genrand_real2(void)
  23.119 -{
  23.120 -    return to_real2(gen_rand32());
  23.121 -}
  23.122 -
  23.123 -/** generates a random number on (0,1)-real-interval */
  23.124 -inline static double to_real3(uint32_t v)
  23.125 -{
  23.126 -    return (((double)v) + 0.5)*(1.0/4294967296.0); 
  23.127 -    /* divided by 2^32 */
  23.128 -}
  23.129 -
  23.130 -/** generates a random number on (0,1)-real-interval */
  23.131 -inline static double genrand_real3(void)
  23.132 -{
  23.133 -    return to_real3(gen_rand32());
  23.134 -}
  23.135 -/** These real versions are due to Isaku Wada */
  23.136 -
  23.137 -/** generates a random number on [0,1) with 53-bit resolution*/
  23.138 -inline static double to_res53(uint64_t v) 
  23.139 -{ 
  23.140 -    return v * (1.0/18446744073709551616.0L);
  23.141 -}
  23.142 -
  23.143 -/** generates a random number on [0,1) with 53-bit resolution from two
  23.144 - * 32 bit integers */
  23.145 -inline static double to_res53_mix(uint32_t x, uint32_t y) 
  23.146 -{ 
  23.147 -    return to_res53(x | ((uint64_t)y << 32));
  23.148 -}
  23.149 -
  23.150 -/** generates a random number on [0,1) with 53-bit resolution
  23.151 - */
  23.152 -inline static double genrand_res53(void) 
  23.153 -{ 
  23.154 -    return to_res53(gen_rand64());
  23.155 -} 
  23.156 -
  23.157 -/** generates a random number on [0,1) with 53-bit resolution
  23.158 -    using 32bit integer.
  23.159 - */
  23.160 -inline static double genrand_res53_mix(void) 
  23.161 -{ 
  23.162 -    uint32_t x, y;
  23.163 -
  23.164 -    x = gen_rand32();
  23.165 -    y = gen_rand32();
  23.166 -    return to_res53_mix(x, y);
  23.167 -} 
  23.168 -#endif
    24.1 --- a/src/VisualBoyAdvance.cfg	Sat Mar 03 10:54:39 2012 -0600
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,213 +0,0 @@
    24.4 -# All numeric values are in hexadecimal
    24.5 -# Use TAB or EQUAL sign to separate name from value
    24.6 -
    24.7 -#
    24.8 -# Key configuration (all numbers are in hexadecimal!)
    24.9 -#
   24.10 -# Keys values are in the format YXXX where Y is the device number. 0 means
   24.11 -# keyborad and XXX is the SDL define for the desired key (read SDL_keysym.h).
   24.12 -#
   24.13 -# If Y is greater than 0, it means joystick number Y-1 and it uses the
   24.14 -# following format for XXX:
   24.15 -#
   24.16 -# - if XXX < 20, XXX is the axis number multiplied by 2. An even number means
   24.17 -#   movement to the negative side (on the X axis, it means left). An odd
   24.18 -#   number means movement to the positive side (on the X axis, it mean
   24.19 -#   right). For the Y axis, negative means up and positive means down.
   24.20 -#   X axis is usally axis number 0 and Y is axis number 1.
   24.21 -# - if 20 >= XXX > 30, then XXX is the HAT number multiplied by 4 plus the
   24.22 -#   direction: 0 for up, 1 for down, 2 for right and 3 for left. Example:
   24.23 -#   0021 is HAT 0 down, 0026 is HAT 1 right.
   24.24 -# - if 80 >= XXX > 100, XXX is the joystick button number (XXX-080).
   24.25 -#
   24.26 -# Default key configuration is (value in parenthesis):
   24.27 -#
   24.28 -# Left          Left Arrow  (0114)
   24.29 -# Right         Right Arrow (0113)
   24.30 -# Up            Up Arrow    (0111)
   24.31 -# Down          Down Arrow  (0112)
   24.32 -# A             Z           (007a)
   24.33 -# B             X           (0078)
   24.34 -# L             A           (0061)
   24.35 -# R             S           (0073)
   24.36 -# Start         ENTER       (000d)
   24.37 -# Select        BACKSPACE   (0008)
   24.38 -# Speed up      SPACE       (0020)
   24.39 -# Capture       F12         (0125)
   24.40 -#
   24.41 -Joy0_Left=0114
   24.42 -Joy0_Right=0113
   24.43 -Joy0_Up=0111
   24.44 -Joy0_Down=0112
   24.45 -Joy0_A=007a
   24.46 -Joy0_B=0078
   24.47 -Joy0_L=0061
   24.48 -Joy0_R=0073
   24.49 -Joy0_Start=000d
   24.50 -Joy0_Select=0008
   24.51 -Joy0_Speed=0020
   24.52 -Joy0_Capture=0125
   24.53 -
   24.54 -# Motion support keys. Same format as above
   24.55 -#
   24.56 -# Default keys are (value in parenthesis):
   24.57 -#
   24.58 -# Left          Numeric Pad 4 (0104)
   24.59 -# Right         Numeric Pad 6 (0106)
   24.60 -# Up            Numeric Pad 8 (0108)
   24.61 -# Down          Numeric Pad 2 (0102)
   24.62 -#
   24.63 -Motion_Left=0104
   24.64 -Motion_Right=0106
   24.65 -Motion_Up=0108
   24.66 -Motion_Down=0102
   24.67 -
   24.68 -# Frame skip setting. Allowed values are from 0 to 5 only.
   24.69 -frameSkip=2
   24.70 -
   24.71 -# Gameboy Frame skip setting. Allowed values are from 0 to 5 only.
   24.72 -gbFrameSkip=0
   24.73 -
   24.74 -# Video setting. 0=1x, 1=2x, 2=3x, 3=4x.
   24.75 -video=1
   24.76 -
   24.77 -# Use fullscreen mode. 0=false, any other value means true
   24.78 -fullScreen=0
   24.79 -
   24.80 -# Disables MMX support
   24.81 -disableMMX=1
   24.82 -
   24.83 -# Use bios file. 0=false, any other value means true
   24.84 -useBios=0
   24.85 -
   24.86 -# Bios file full path and name (ZIP not supported)
   24.87 -biosFile=none
   24.88 -
   24.89 -# Filter to use. 0=no filter, 1=TV Mode, 2=2xSaI, 3=Super 2xSaI, 4=Super Eagle
   24.90 -# 5=Pixelate, 6=Motion Blur, 7=AdvanceMAME Scale2x, 8=Simple 2x,
   24.91 -# 9=Bilinear, A=Bilinear Plus, B=hq2x, C=lq2x
   24.92 -filter=0
   24.93 -
   24.94 -# Disable status messages. 0=false, any other value means true
   24.95 -disableStatus=0
   24.96 -
   24.97 -# Enable Gameboy border. 0=false, any other value means true
   24.98 -borderOn=0
   24.99 -
  24.100 -# Gameboy emulator type. 0=automatic, 1=CGB/GBC, 2=SGB, 3=GB, 4=GBA, 5=SGB2
  24.101 -emulatorType=1
  24.102 -
  24.103 -# Enable washed colors. 0=false, any other value means true
  24.104 -colorOption=1
  24.105 -
  24.106 -# Directories. Not setting one them makes the file go the rom directory.
  24.107 -
  24.108 -# Save state directory
  24.109 -#saveDir=
  24.110 -
  24.111 -# Screen shot Capture directory
  24.112 -#captureDir=
  24.113 -
  24.114 -# Battery directory
  24.115 -#batteryDir=
  24.116 -
  24.117 -# Screen capture format
  24.118 -# 0=PNG, anything else for BMP
  24.119 -captureFormat=0
  24.120 -
  24.121 -# Sound quality
  24.122 -# 1=44 Khz, 2=22Khz, 4=11Khz
  24.123 -soundQuality=1
  24.124 -
  24.125 -# Sound Echo
  24.126 -# 0=false, anything else for true
  24.127 -soundEcho=0
  24.128 -
  24.129 -# Sound Low pass filter
  24.130 -# 0=false, anything else for true
  24.131 -soundLowPass=0
  24.132 -
  24.133 -# Sound reverse stereo
  24.134 -# 0=false, anything else for true
  24.135 -soundReverse=0
  24.136 -
  24.137 -# Remove GBA intros (not supported anymore)
  24.138 -# 0=false, anything else for true
  24.139 -# removeIntros=0
  24.140 -
  24.141 -# Save Type
  24.142 -# 0=automatic, 1=EEPROM, 2=SRAM, 3=Flash, 4=EEPROM+Sensor, 5=NONE
  24.143 -saveType=0
  24.144 -
  24.145 -# Flash size
  24.146 -# 0=64K Flash, 1=128K Flash
  24.147 -
  24.148 -flashSize=0
  24.149 -
  24.150 -# Sound volume
  24.151 -# 0=1x, 1=2x, 2=3x, 3=4x
  24.152 -soundVolume=0
  24.153 -
  24.154 -# Interframe blending
  24.155 -# 0=none, 1=motion blur, 2=smart
  24.156 -ifbType=0
  24.157 -
  24.158 -# Show emulation speed
  24.159 -# 0=none, 1=percentage, 2=detailed
  24.160 -showSpeed=1
  24.161 -
  24.162 -# Show speed in transparent mode
  24.163 -# 0=normal, anything else for transparent
  24.164 -showSpeedTransparent=1
  24.165 -
  24.166 -# Enable/Disable auto frameskip
  24.167 -# 0=disable, anything else to enable
  24.168 -autoFrameSkip=0
  24.169 -
  24.170 -# Sets the desired throttle
  24.171 -# 0=disable, 5...1000 valid throttle speeds
  24.172 -throttle=0
  24.173 -
  24.174 -# Pauses the emulator when the window is inactive
  24.175 -# 0=disable, anything else to enable
  24.176 -pauseWhenInactive=0
  24.177 -
  24.178 -# Enables AGBPrint support
  24.179 -# 0=disable, anything else to enable
  24.180 -agbPrint=0
  24.181 -
  24.182 -# Enables GBA RTC support
  24.183 -# 0=disable, anything else to enable
  24.184 -rtcEnabled=0
  24.185 -
  24.186 -# Sound OFF flag
  24.187 -# 0=sound on, anything else turns off sound
  24.188 -soundOff=0
  24.189 -
  24.190 -# Sound Enable
  24.191 -# Controls which channels are enabled: (add values)
  24.192 -#   1 - Channel 1
  24.193 -#   2 - Channel 2
  24.194 -#   4 - Channel 3
  24.195 -#   8 - Channel 4
  24.196 -# 100 - DirectSound A
  24.197 -# 200 - DirectSound B
  24.198 -# 30f=all enabled, 0=mute all
  24.199 -soundEnable=30f
  24.200 -
  24.201 -# Controls automatic SGB border
  24.202 -# 0=disable, anything else enables automatic SGB border display
  24.203 -borderAutomatic=0
  24.204 -
  24.205 -# Skip bios code
  24.206 -# 0=disable, anything else skips BIOS code
  24.207 -skipBios=0
  24.208 -
  24.209 -# The interval between the rewind saves
  24.210 -# Minimum of 0 seconds to disable rewind support, 
  24.211 -# Maximum of 60 minutes. Value in seconds (hexadecimal numbers)
  24.212 -rewindTimer=0
  24.213 -
  24.214 -# Enable enhanced save type detection
  24.215 -# 0=disable, anything else to enable (no longer used)
  24.216 -#enhancedDetection=1
    25.1 --- a/src/common/CheatSearch.cpp	Sat Mar 03 10:54:39 2012 -0600
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,371 +0,0 @@
    25.4 -#include <cstdlib>
    25.5 -#include <cstring>
    25.6 -
    25.7 -#include "CheatSearch.h"
    25.8 -
    25.9 -CheatSearchBlock cheatSearchBlocks[4];
   25.10 -
   25.11 -CheatSearchData cheatSearchData = {
   25.12 -	0,
   25.13 -	cheatSearchBlocks
   25.14 -};
   25.15 -
   25.16 -static bool cheatSearchEQ(u32 a, u32 b)
   25.17 -{
   25.18 -	return a == b;
   25.19 -}
   25.20 -
   25.21 -static bool cheatSearchNE(u32 a, u32 b)
   25.22 -{
   25.23 -	return a != b;
   25.24 -}
   25.25 -
   25.26 -static bool cheatSearchLT(u32 a, u32 b)
   25.27 -{
   25.28 -	return a < b;
   25.29 -}
   25.30 -
   25.31 -static bool cheatSearchLE(u32 a, u32 b)
   25.32 -{
   25.33 -	return a <= b;
   25.34 -}
   25.35 -
   25.36 -static bool cheatSearchGT(u32 a, u32 b)
   25.37 -{
   25.38 -	return a > b;
   25.39 -}
   25.40 -
   25.41 -static bool cheatSearchGE(u32 a, u32 b)
   25.42 -{
   25.43 -	return a >= b;
   25.44 -}
   25.45 -
   25.46 -static bool cheatSearchSignedEQ(s32 a, s32 b)
   25.47 -{
   25.48 -	return a == b;
   25.49 -}
   25.50 -
   25.51 -static bool cheatSearchSignedNE(s32 a, s32 b)
   25.52 -{
   25.53 -	return a != b;
   25.54 -}
   25.55 -
   25.56 -static bool cheatSearchSignedLT(s32 a, s32 b)
   25.57 -{
   25.58 -	return a < b;
   25.59 -}
   25.60 -
   25.61 -static bool cheatSearchSignedLE(s32 a, s32 b)
   25.62 -{
   25.63 -	return a <= b;
   25.64 -}
   25.65 -
   25.66 -static bool cheatSearchSignedGT(s32 a, s32 b)
   25.67 -{
   25.68 -	return a > b;
   25.69 -}
   25.70 -
   25.71 -static bool cheatSearchSignedGE(s32 a, s32 b)
   25.72 -{
   25.73 -	return a >= b;
   25.74 -}
   25.75 -
   25.76 -static bool (*cheatSearchFunc[])(u32, u32) = {
   25.77 -	cheatSearchEQ,
   25.78 -	cheatSearchNE,
   25.79 -	cheatSearchLT,
   25.80 -	cheatSearchLE,
   25.81 -	cheatSearchGT,
   25.82 -	cheatSearchGE
   25.83 -};
   25.84 -
   25.85 -static bool (*cheatSearchSignedFunc[])(s32, s32) = {
   25.86 -	cheatSearchSignedEQ,
   25.87 -	cheatSearchSignedNE,
   25.88 -	cheatSearchSignedLT,
   25.89 -	cheatSearchSignedLE,
   25.90 -	cheatSearchSignedGT,
   25.91 -	cheatSearchSignedGE
   25.92 -};
   25.93 -
   25.94 -void cheatSearchSetSavedAndBits(CheatSearchBlock *block)
   25.95 -{
   25.96 -	if (!block->saved)
   25.97 -	{
   25.98 -		block->saved = (u8 *)malloc(block->size);
   25.99 -		memcpy(block->saved, block->data, block->size);
  25.100 -	}
  25.101 -	if (!block->bits)
  25.102 -	{
  25.103 -		block->bits  = (u8 *)malloc(block->size >> 3);
  25.104 -		memset(block->bits, 0xff, block->size >> 3);
  25.105 -	}
  25.106 -}
  25.107 -
  25.108 -void cheatSearchZeroBlock(CheatSearchBlock *block)
  25.109 -{
  25.110 -	block->data	  = 0;
  25.111 -	block->offset = 0;
  25.112 -	block->size	  = 0;
  25.113 -	free(block->saved);
  25.114 -	free(block->bits);
  25.115 -	block->saved  = 0;
  25.116 -	block->bits	  = 0;
  25.117 -}
  25.118 -
  25.119 -void cheatSearchCleanup(CheatSearchData *cs)
  25.120 -{
  25.121 -	int count = cs->count;
  25.122 -
  25.123 -	for (int i = 0; i < count; i++)
  25.124 -	{
  25.125 -		CheatSearchBlock &block = cs->blocks[i];
  25.126 -		free(block.saved);
  25.127 -		free(block.bits);
  25.128 -		block.saved = 0;
  25.129 -		block.bits  = 0;
  25.130 -	}
  25.131 -	cs->count = 0;
  25.132 -}
  25.133 -
  25.134 -void cheatSearchStart(const CheatSearchData *cs)
  25.135 -{
  25.136 -	int count = cs->count;
  25.137 -
  25.138 -	for (int i = 0; i < count; i++)
  25.139 -	{
  25.140 -		CheatSearchBlock *block = &cs->blocks[i];
  25.141 -
  25.142 -		memset(block->bits, 0xff, block->size >> 3);
  25.143 -		memcpy(block->saved, block->data, block->size);
  25.144 -	}
  25.145 -}
  25.146 -
  25.147 -s32 cheatSearchSignedRead(u8 *data, int off, int size)
  25.148 -{
  25.149 -	u32 res = data[off++];
  25.150 -
  25.151 -	switch (size)
  25.152 -	{
  25.153 -	case BITS_8:
  25.154 -		res <<= 24;
  25.155 -		return ((s32)res) >> 24;
  25.156 -	case BITS_16:
  25.157 -		res  |= ((u32)data[off++])<<8;
  25.158 -		res <<= 16;
  25.159 -		return ((s32)res) >> 16;
  25.160 -	case BITS_32:
  25.161 -		res |= ((u32)data[off++])<<8;
  25.162 -		res |= ((u32)data[off++])<<16;
  25.163 -		res |= ((u32)data[off++])<<24;
  25.164 -		return (s32)res;
  25.165 -	}
  25.166 -	return (s32)res;
  25.167 -}
  25.168 -
  25.169 -u32 cheatSearchRead(u8 *data, int off, int size)
  25.170 -{
  25.171 -	u32 res = data[off++];
  25.172 -	if (size == BITS_16)
  25.173 -		res |= ((u32)data[off++])<<8;
  25.174 -	else if (size == BITS_32)
  25.175 -	{
  25.176 -		res |= ((u32)data[off++])<<8;
  25.177 -		res |= ((u32)data[off++])<<16;
  25.178 -		res |= ((u32)data[off++])<<24;
  25.179 -	}
  25.180 -	return res;
  25.181 -}
  25.182 -
  25.183 -void cheatSearch(const CheatSearchData *cs, int compare, int size,
  25.184 -                 bool isSigned)
  25.185 -{
  25.186 -	if (compare < 0 || compare > SEARCH_GE)
  25.187 -		return;
  25.188 -	int inc = 1;
  25.189 -	if (size == BITS_16)
  25.190 -		inc = 2;
  25.191 -	else if (size == BITS_32)
  25.192 -		inc = 4;
  25.193 -
  25.194 -	if (isSigned)
  25.195 -	{
  25.196 -		bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
  25.197 -
  25.198 -		for (int i = 0; i < cs->count; i++)
  25.199 -		{
  25.200 -			CheatSearchBlock *block = &cs->blocks[i];
  25.201 -			int size2 = block->size;
  25.202 -			u8 *bits  = block->bits;
  25.203 -			u8 *data  = block->data;
  25.204 -			u8 *saved = block->saved;
  25.205 -
  25.206 -			for (int j = 0; j < size2; j += inc)
  25.207 -			{
  25.208 -				if (IS_BIT_SET(bits, j))
  25.209 -				{
  25.210 -					s32 a = cheatSearchSignedRead(data, j, size);
  25.211 -					s32 b = cheatSearchSignedRead(saved, j, size);
  25.212 -
  25.213 -					if (!func(a, b))
  25.214 -					{
  25.215 -						CLEAR_BIT(bits, j);
  25.216 -						if (size == BITS_16)
  25.217 -							CLEAR_BIT(bits, j+1);
  25.218 -						if (size == BITS_32)
  25.219 -						{
  25.220 -							CLEAR_BIT(bits, j+2);
  25.221 -							CLEAR_BIT(bits, j+3);
  25.222 -						}
  25.223 -					}
  25.224 -				}
  25.225 -			}
  25.226 -		}
  25.227 -	}
  25.228 -	else
  25.229 -	{
  25.230 -		bool (*func)(u32, u32) = cheatSearchFunc[compare];
  25.231 -
  25.232 -		for (int i = 0; i < cs->count; i++)
  25.233 -		{
  25.234 -			CheatSearchBlock *block = &cs->blocks[i];
  25.235 -			int size2 = block->size;
  25.236 -			u8 *bits  = block->bits;
  25.237 -			u8 *data  = block->data;
  25.238 -			u8 *saved = block->saved;
  25.239 -
  25.240 -			for (int j = 0; j < size2; j += inc)
  25.241 -			{
  25.242 -				if (IS_BIT_SET(bits, j))
  25.243 -				{
  25.244 -					u32 a = cheatSearchRead(data, j, size);
  25.245 -					u32 b = cheatSearchRead(saved, j, size);
  25.246 -
  25.247 -					if (!func(a, b))
  25.248 -					{
  25.249 -						CLEAR_BIT(bits, j);
  25.250 -						if (size == BITS_16)
  25.251 -							CLEAR_BIT(bits, j+1);
  25.252 -						if (size == BITS_32)
  25.253 -						{
  25.254 -							CLEAR_BIT(bits, j+2);
  25.255 -							CLEAR_BIT(bits, j+3);
  25.256 -						}
  25.257 -					}
  25.258 -				}
  25.259 -			}
  25.260 -		}
  25.261 -	}
  25.262 -}
  25.263 -
  25.264 -void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
  25.265 -                      bool isSigned, u32 value)
  25.266 -{
  25.267 -	if (compare < 0 || compare > SEARCH_GE)
  25.268 -		return;
  25.269 -	int inc = 1;
  25.270 -	if (size == BITS_16)
  25.271 -		inc = 2;
  25.272 -	else if (size == BITS_32)
  25.273 -		inc = 4;
  25.274 -
  25.275 -	if (isSigned)
  25.276 -	{
  25.277 -		bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
  25.278 -
  25.279 -		for (int i = 0; i < cs->count; i++)
  25.280 -		{
  25.281 -			CheatSearchBlock *block = &cs->blocks[i];
  25.282 -			int size2 = block->size;
  25.283 -			u8 *bits  = block->bits;
  25.284 -			u8 *data  = block->data;
  25.285 -
  25.286 -			for (int j = 0; j < size2; j += inc)
  25.287 -			{
  25.288 -				if (IS_BIT_SET(bits, j))
  25.289 -				{
  25.290 -					s32 a = cheatSearchSignedRead(data, j, size);
  25.291 -					s32 b = (s32)value;
  25.292 -
  25.293 -					if (!func(a, b))
  25.294 -					{
  25.295 -						CLEAR_BIT(bits, j);
  25.296 -						if (size == BITS_16)
  25.297 -							CLEAR_BIT(bits, j+1);
  25.298 -						if (size == BITS_32)
  25.299 -						{
  25.300 -							CLEAR_BIT(bits, j+2);
  25.301 -							CLEAR_BIT(bits, j+3);
  25.302 -						}
  25.303 -					}
  25.304 -				}
  25.305 -			}
  25.306 -		}
  25.307 -	}
  25.308 -	else
  25.309 -	{
  25.310 -		bool (*func)(u32, u32) = cheatSearchFunc[compare];
  25.311 -
  25.312 -		for (int i = 0; i < cs->count; i++)
  25.313 -		{
  25.314 -			CheatSearchBlock *block = &cs->blocks[i];
  25.315 -			int size2 = block->size;
  25.316 -			u8 *bits  = block->bits;
  25.317 -			u8 *data  = block->data;
  25.318 -
  25.319 -			for (int j = 0; j < size2; j += inc)
  25.320 -			{
  25.321 -				if (IS_BIT_SET(bits, j))
  25.322 -				{
  25.323 -					u32 a = cheatSearchRead(data, j, size);
  25.324 -
  25.325 -					if (!func(a, value))
  25.326 -					{
  25.327 -						CLEAR_BIT(bits, j);
  25.328 -						if (size == BITS_16)
  25.329 -							CLEAR_BIT(bits, j+1);
  25.330 -						if (size == BITS_32)
  25.331 -						{
  25.332 -							CLEAR_BIT(bits, j+2);
  25.333 -							CLEAR_BIT(bits, j+3);
  25.334 -						}
  25.335 -					}
  25.336 -				}
  25.337 -			}
  25.338 -		}
  25.339 -	}
  25.340 -}
  25.341 -
  25.342 -int cheatSearchGetCount(const CheatSearchData *cs, int size)
  25.343 -{
  25.344 -	int res = 0;
  25.345 -	int inc = 1;
  25.346 -	if (size == BITS_16)
  25.347 -		inc = 2;
  25.348 -	else if (size == BITS_32)
  25.349 -		inc = 4;
  25.350 -
  25.351 -	for (int i = 0; i < cs->count; i++)
  25.352 -	{
  25.353 -		CheatSearchBlock *block = &cs->blocks[i];
  25.354 -
  25.355 -		int size2 = block->size;
  25.356 -		u8 *bits  = block->bits;
  25.357 -		for (int j = 0; j < size2; j += inc)
  25.358 -		{
  25.359 -			if (IS_BIT_SET(bits, j))
  25.360 -				res++;
  25.361 -		}
  25.362 -	}
  25.363 -	return res;
  25.364 -}
  25.365 -
  25.366 -void cheatSearchUpdateValues(const CheatSearchData *cs)
  25.367 -{
  25.368 -	for (int i = 0; i < cs->count; i++)
  25.369 -	{
  25.370 -		CheatSearchBlock *block = &cs->blocks[i];
  25.371 -
  25.372 -		memcpy(block->saved, block->data, block->size);
  25.373 -	}
  25.374 -}
    26.1 --- a/src/common/CheatSearch.h	Sat Mar 03 10:54:39 2012 -0600
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,65 +0,0 @@
    26.4 -#ifndef VBA_CHEATSEARCH_H
    26.5 -#define VBA_CHEATSEARCH_H
    26.6 -
    26.7 -#if _MSC_VER > 1000
    26.8 -#pragma once
    26.9 -#endif // _MSC_VER > 1000
   26.10 -
   26.11 -#include "../Port.h"
   26.12 -
   26.13 -struct CheatSearchBlock
   26.14 -{
   26.15 -	u8 *data;
   26.16 -	int size;
   26.17 -	u32 offset;
   26.18 -	u8 *saved;
   26.19 -	u8 *bits;
   26.20 -};
   26.21 -
   26.22 -struct CheatSearchData
   26.23 -{
   26.24 -	int count;
   26.25 -	CheatSearchBlock *blocks;
   26.26 -};
   26.27 -
   26.28 -enum
   26.29 -{
   26.30 -	SEARCH_EQ,
   26.31 -	SEARCH_NE,
   26.32 -	SEARCH_LT,
   26.33 -	SEARCH_LE,
   26.34 -	SEARCH_GT,
   26.35 -	SEARCH_GE
   26.36 -};
   26.37 -
   26.38 -enum
   26.39 -{
   26.40 -	BITS_8,
   26.41 -	BITS_16,
   26.42 -	BITS_32
   26.43 -};
   26.44 -
   26.45 -#define SET_BIT(bits, off) \
   26.46 -    (bits)[(off) >> 3] |= (1 << ((off) & 7))
   26.47 -
   26.48 -#define CLEAR_BIT(bits, off) \
   26.49 -    (bits)[(off) >> 3] &= ~(1 << ((off) & 7))
   26.50 -
   26.51 -#define IS_BIT_SET(bits, off) \
   26.52 -    (bits)[(off) >> 3] & (1 << ((off) & 7))
   26.53 -
   26.54 -extern CheatSearchData cheatSearchData;
   26.55 -extern void cheatSearchSetSavedAndBits(CheatSearchBlock *block);
   26.56 -extern void cheatSearchZeroBlock(CheatSearchBlock *block);
   26.57 -extern void cheatSearchCleanup(CheatSearchData *cs);
   26.58 -extern void cheatSearchStart(const CheatSearchData *cs);
   26.59 -extern void cheatSearch(const CheatSearchData *cs, int compare, int size,
   26.60 -                        bool isSigned);
   26.61 -extern void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
   26.62 -                             bool isSigned, u32 value);
   26.63 -extern int cheatSearchGetCount(const CheatSearchData *cs, int size);
   26.64 -extern void cheatSearchUpdateValues(const CheatSearchData *cs);
   26.65 -extern s32 cheatSearchSignedRead(u8 *data, int off, int size);
   26.66 -extern u32 cheatSearchRead(u8 *data, int off, int size);
   26.67 -
   26.68 -#endif // VBA_CHEATSEARCH_H
    27.1 --- a/src/common/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,23 +0,0 @@
    27.4 -noinst_LIBRARIES = libgbcom.a
    27.5 -
    27.6 -libgbcom_a_SOURCES = \
    27.7 -	lua-engine.cpp		\
    27.8 -	memgzio.c		\
    27.9 -	memgzio.h		\
   27.10 -	movie.cpp		\
   27.11 -	movie.h			\
   27.12 -	System.h		\
   27.13 -	Text.cpp		\
   27.14 -	Text.h			\
   27.15 -	unzip.cpp		\
   27.16 -	unzip.h			\
   27.17 -	Util.cpp		\
   27.18 -	Util.h			\
   27.19 -	vbalua.h
   27.20 -
   27.21 -AM_CPPFLAGS = \
   27.22 -	-I$(top_srcdir)/src		\
   27.23 -	-DSDL				\
   27.24 -	-DSYSCONFDIR=\"$(sysconfdir)\"
   27.25 -
   27.26 -AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@
    28.1 --- a/src/common/System.h	Sat Mar 03 10:54:39 2012 -0600
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,137 +0,0 @@
    28.4 -#ifndef VBA_SYSTEM_H
    28.5 -#define VBA_SYSTEM_H
    28.6 -
    28.7 -#if _MSC_VER > 1000
    28.8 -#pragma once
    28.9 -#endif // _MSC_VER > 1000
   28.10 -
   28.11 -#include "zlib.h"
   28.12 -#include "../Port.h"
   28.13 -
   28.14 -// c++ lacks a way to implement Smart Referrences or Delphi-Style Properties
   28.15 -// in order to maintain consistency, value-copied things should not be modified too often
   28.16 -struct EmulatedSystem
   28.17 -{
   28.18 -	// main emulation function
   28.19 -	void (*emuMain)(int);
   28.20 -	// reset emulator
   28.21 -	void (*emuReset)(bool);
   28.22 -	// clean up memory
   28.23 -	void (*emuCleanUp)();
   28.24 -	// load battery file
   28.25 -	bool (*emuReadBattery)(const char *);
   28.26 -	// write battery file
   28.27 -	bool (*emuWriteBattery)(const char *);
   28.28 -	// load battery file from stream
   28.29 -	bool (*emuReadBatteryFromStream)(gzFile);
   28.30 -	// write battery file to stream
   28.31 -	bool (*emuWriteBatteryToStream)(gzFile);
   28.32 -	// load state
   28.33 -	bool (*emuReadState)(const char *);
   28.34 -	// save state
   28.35 -	bool (*emuWriteState)(const char *);
   28.36 -	// load state from stream
   28.37 -	bool (*emuReadStateFromStream)(gzFile);
   28.38 -	// save state to stream
   28.39 -	bool (*emuWriteStateToStream)(gzFile);
   28.40 -	// load memory state (rewind)
   28.41 -	bool (*emuReadMemState)(char *, int);
   28.42 -	// write memory state (rewind)
   28.43 -	bool (*emuWriteMemState)(char *, int);
   28.44 -	// write PNG file
   28.45 -	bool (*emuWritePNG)(const char *);
   28.46 -	// write BMP file
   28.47 -	bool (*emuWriteBMP)(const char *);
   28.48 -	// emulator update CPSR (ARM only)
   28.49 -	void (*emuUpdateCPSR)();
   28.50 -	// emulator has debugger
   28.51 -	bool emuHasDebugger;
   28.52 -	// clock ticks to emulate
   28.53 -	int emuCount;
   28.54 -};
   28.55 -
   28.56 -// why not convert the value type only when doing I/O?
   28.57 -struct EmulatedSystemCounters
   28.58 -{
   28.59 -	int32 frameCount;
   28.60 -	int32 lagCount;
   28.61 -	int32 extraCount;
   28.62 -	bool8 lagged;
   28.63 -	bool8 laggedLast;
   28.64 -};
   28.65 -
   28.66 -extern struct EmulatedSystem theEmulator;
   28.67 -extern struct EmulatedSystemCounters systemCounters;
   28.68 -
   28.69 -extern void log(const char *, ...);
   28.70 -
   28.71 -extern void systemGbPrint(u8 *, int, int, int, int);
   28.72 -extern int  systemScreenCapture(int);
   28.73 -extern void systemRefreshScreen();
   28.74 -extern void systemRenderFrame();
   28.75 -extern void systemRedrawScreen();
   28.76 -extern void systemUpdateListeners();
   28.77 -// updates the joystick data
   28.78 -extern void systemSetSensorX(int32);
   28.79 -extern void systemSetSensorY(int32);
   28.80 -extern void systemResetSensor();
   28.81 -extern int32 systemGetSensorX();
   28.82 -extern int32 systemGetSensorY();
   28.83 -extern void systemUpdateMotionSensor(int);
   28.84 -extern int  systemGetDefaultJoypad();
   28.85 -extern void systemSetDefaultJoypad(int);
   28.86 -extern bool systemReadJoypads();
   28.87 -// return information about the given joystick, -1 for default joystick... the bool is for if motion sensor should be handled
   28.88 -// too
   28.89 -extern u32  systemGetOriginalJoypad(int, bool);
   28.90 -extern u32  systemGetJoypad(int, bool);
   28.91 -extern void systemSetJoypad(int, u32);
   28.92 -extern void systemClearJoypads();
   28.93 -extern void systemMessage(int, const char *, ...);
   28.94 -extern void systemScreenMessage(const char *msg, int slot = 0, int duration = 3000, const char *colorList = NULL);
   28.95 -extern bool systemSoundInit();
   28.96 -extern void systemSoundShutdown();
   28.97 -extern void systemSoundPause();
   28.98 -extern void systemSoundResume();
   28.99 -extern bool systemSoundIsPaused();
  28.100 -extern void systemSoundReset();
  28.101 -extern void systemSoundWriteToBuffer();
  28.102 -extern void systemSoundClearBuffer();
  28.103 -extern bool systemSoundCanChangeQuality();
  28.104 -extern bool systemSoundSetQuality(int quality);
  28.105 -extern u32  systemGetClock();
  28.106 -extern void systemSetTitle(const char *);
  28.107 -extern void systemShowSpeed(int);
  28.108 -extern void systemIncreaseThrottle();
  28.109 -extern void systemDecreaseThrottle();
  28.110 -extern void systemSetThrottle(int);
  28.111 -extern int  systemGetThrottle();
  28.112 -extern void systemFrame();
  28.113 -extern int  systemFramesToSkip();
  28.114 -extern bool systemIsEmulating();
  28.115 -extern void systemGbBorderOn();
  28.116 -extern bool systemIsRunningGBA();
  28.117 -extern bool systemIsSpedUp();
  28.118 -extern bool systemIsPaused();
  28.119 -extern void systemSetPause(bool pause);
  28.120 -extern bool systemPauseOnFrame();
  28.121 -
  28.122 -extern int	systemCartridgeType;
  28.123 -extern int  systemSpeed;
  28.124 -extern bool systemSoundOn;
  28.125 -extern u16  systemColorMap16[0x10000];
  28.126 -extern u32  systemColorMap32[0x10000];
  28.127 -extern u16  systemGbPalette[24];
  28.128 -extern int  systemRedShift;
  28.129 -extern int  systemGreenShift;
  28.130 -extern int  systemBlueShift;
  28.131 -extern int  systemColorDepth;
  28.132 -extern int  systemDebug;
  28.133 -extern int  systemVerbose;
  28.134 -extern int  systemFrameSkip;
  28.135 -extern int  systemSaveUpdateCounter;
  28.136 -
  28.137 -#define SYSTEM_SAVE_UPDATED 30
  28.138 -#define SYSTEM_SAVE_NOT_UPDATED 0
  28.139 -
  28.140 -#endif // VBA_SYSTEM_H
    29.1 --- a/src/common/Text.cpp	Sat Mar 03 10:54:39 2012 -0600
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,496 +0,0 @@
    29.4 -/* FCE Ultra - NES/Famicom Emulator
    29.5 - *
    29.6 - * Copyright notice for this file:
    29.7 - *  Copyright (C) 2002 Ben Parnell
    29.8 - *
    29.9 - * This program is free software; you can redistribute it and/or modify
   29.10 - * it under the terms of the GNU General Public License as published by
   29.11 - * the Free Software Foundation; either version 2 of the License, or
   29.12 - * (at your option) any later version.
   29.13 - *
   29.14 - * This program is distributed in the hope that it will be useful,
   29.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   29.17 - * GNU General Public License for more details.
   29.18 - *
   29.19 - * You should have received a copy of the GNU General Public License
   29.20 - * along with this program; if not, write to the Free Software
   29.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.22 - */
   29.23 -
   29.24 -/* Code originally from fceu/drawing.h file, adapted by Forgotten
   29.25 - */
   29.26 -#include "System.h"
   29.27 -
   29.28 -bool outlinedText = true, transparentText = false;
   29.29 -int  textColor    = 0, textMethod = 1;
   29.30 -
   29.31 -extern u32 RGB_LOW_BITS_MASK;
   29.32 -
   29.33 -static const u8 fontdata2[2048] = {
   29.34 -	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff,  0xdb, 0xff,
   29.35 -	0xc3, 0xe7, 0xff, 0x7e, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00,
   29.36 -	0x1c,
   29.37 -	0x3e, 0x1c, 0x7f, 0x7f, 0x3e, 0x1c, 0x3e, 0x08, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x3e, 0x00, 0x00, 0x18, 0x3c, 0x3c,
   29.38 -	0x18,
   29.39 -	0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,  0xff, 0xc3,
   29.40 -	0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xf0, 0xe0, 0xf0, 0xbe, 0x33, 0x33, 0x33, 0x1e, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18,
   29.41 -	0x7e,
   29.42 -	0x18, 0xfc, 0xcc, 0xfc, 0x0c, 0x0c, 0x0e, 0x0f, 0x07, 0xfe, 0xc6, 0xfe, 0xc6, 0xc6, 0xe6, 0x67, 0x03, 0x99, 0x5a, 0x3c,
   29.43 -	0xe7,
   29.44 -	0xe7, 0x3c, 0x5a, 0x99, 0x01, 0x07, 0x1f, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x40, 0x70, 0x7c, 0x7f, 0x7c, 0x70, 0x40, 0x00,
   29.45 -	0x18,
   29.46 -	0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0xfe, 0xdb, 0xdb, 0xde, 0xd8,
   29.47 -	0xd8,
   29.48 -	0xd8, 0x00, 0x7c, 0xc6, 0x1c, 0x36, 0x36, 0x1c, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c,
   29.49 -	0x7e,
   29.50 -	0x18, 0x7e, 0x3c, 0x18, 0xff, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18,
   29.51 -	0x00,
   29.52 -	0x00, 0x18, 0x30, 0x7f, 0x30, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x06, 0x7f, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
   29.53 -	0x03,
   29.54 -	0x7f, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00,
   29.55 -	0xff,
   29.56 -	0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
   29.57 -	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1e, 0x1e, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x36, 0x36, 0x36, 0x00,
   29.58 -	0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7f, 0x36, 0x7f, 0x36, 0x36, 0x00, 0x0c, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x0c, 0x00,
   29.59 -	0x00,
   29.60 -	0x63, 0x33, 0x18, 0x0c, 0x66, 0x63, 0x00, 0x1c, 0x36, 0x1c, 0x6e, 0x3b, 0x33, 0x6e, 0x00, 0x06, 0x06, 0x03, 0x00, 0x00,
   29.61 -	0x00,
   29.62 -	0x00, 0x00, 0x18, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x18, 0x00, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x66,
   29.63 -	0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
   29.64 -	0x0c,
   29.65 -	0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x60, 0x30, 0x18,
   29.66 -	0x0c,
   29.67 -	0x06, 0x03, 0x01, 0x00, 0x3e, 0x63, 0x73, 0x7b, 0x6f, 0x67, 0x3e, 0x00, 0x0c, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x3f, 0x00,
   29.68 -	0x1e,
   29.69 -	0x33, 0x30, 0x1c, 0x06, 0x33, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x30, 0x33, 0x1e, 0x00, 0x38, 0x3c, 0x36, 0x33, 0x7f,
   29.70 -	0x30,
   29.71 -	0x78, 0x00, 0x3f, 0x03, 0x1f, 0x30, 0x30, 0x33, 0x1e, 0x00, 0x1c, 0x06, 0x03, 0x1f, 0x33, 0x33, 0x1e, 0x00, 0x3f, 0x33,
   29.72 -	0x30,
   29.73 -	0x18, 0x0c, 0x0c, 0x0c, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x33, 0x3e, 0x30, 0x18, 0x0e,
   29.74 -	0x00,
   29.75 -	0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x18, 0x0c, 0x06, 0x03,
   29.76 -	0x06,
   29.77 -	0x0c, 0x18, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x1e,
   29.78 -	0x33,
   29.79 -	0x30, 0x18, 0x0c, 0x00, 0x0c, 0x00,
   29.80 -	0x3e, 0x63, 0x7b, 0x7b, 0x7b, 0x03, 0x1e, 0x00, 0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, 0x3f, 0x66, 0x66, 0x3e,
   29.81 -	0x66, 0x66, 0x3f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3c, 0x00, 0x1f, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1f, 0x00,
   29.82 -	0x7f,
   29.83 -	0x46, 0x16, 0x1e, 0x16, 0x46, 0x7f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x06, 0x0f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x73,
   29.84 -	0x66,
   29.85 -	0x7c, 0x00, 0x33, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x33, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x78, 0x30,
   29.86 -	0x30, 0x30, 0x33, 0x33, 0x1e, 0x00, 0x67, 0x66, 0x36, 0x1e, 0x36, 0x66, 0x67, 0x00, 0x0f, 0x06, 0x06, 0x06, 0x46, 0x66,
   29.87 -	0x7f,
   29.88 -	0x00, 0x63, 0x77, 0x7f, 0x7f, 0x6b, 0x63, 0x63, 0x00, 0x63, 0x67, 0x6f, 0x7b, 0x73, 0x63, 0x63, 0x00, 0x1c, 0x36, 0x63,
   29.89 -	0x63,
   29.90 -	0x63, 0x36, 0x1c, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x06, 0x06, 0x0f, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x3b, 0x1e, 0x38, 0x00,
   29.91 -	0x3f,
   29.92 -	0x66, 0x66, 0x3e, 0x36, 0x66, 0x67, 0x00, 0x1e, 0x33, 0x07, 0x0e, 0x38, 0x33, 0x1e, 0x00, 0x3f, 0x2d, 0x0c, 0x0c, 0x0c,
   29.93 -	0x0c,
   29.94 -	0x1e, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x63, 0x63,
   29.95 -	0x63,
   29.96 -	0x6b, 0x7f, 0x77, 0x63, 0x00, 0x63, 0x63, 0x36, 0x1c, 0x1c, 0x36, 0x63, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x0c, 0x1e,
   29.97 -	0x00,
   29.98 -	0x7f, 0x63, 0x31, 0x18, 0x4c, 0x66, 0x7f, 0x00, 0x1e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1e, 0x00, 0x03, 0x06, 0x0c, 0x18,
   29.99 -	0x30,
  29.100 -	0x60, 0x40, 0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
  29.101 -	0x00,
  29.102 -	0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  29.103 -	0x0c, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x6e, 0x00, 0x07, 0x06, 0x06, 0x3e,
  29.104 -	0x66, 0x66, 0x3b, 0x00, 0x00, 0x00, 0x1e, 0x33, 0x03, 0x33, 0x1e, 0x00, 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6e, 0x00,
  29.105 -	0x00,
  29.106 -	0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x1c, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x6e, 0x33, 0x33,
  29.107 -	0x3e,
  29.108 -	0x30, 0x1f, 0x07, 0x06, 0x36, 0x6e, 0x66, 0x66, 0x67, 0x00, 0x0c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x30, 0x00,
  29.109 -	0x30, 0x30, 0x30, 0x33, 0x33, 0x1e, 0x07, 0x06, 0x66, 0x36, 0x1e, 0x36, 0x67, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
  29.110 -	0x1e,
  29.111 -	0x00, 0x00, 0x00, 0x33, 0x7f, 0x7f, 0x6b, 0x63, 0x00, 0x00, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, 0x1e,
  29.112 -	0x33,
  29.113 -	0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x3b, 0x66, 0x66, 0x3e, 0x06, 0x0f, 0x00, 0x00, 0x6e, 0x33, 0x33, 0x3e, 0x30, 0x78,
  29.114 -	0x00,
  29.115 -	0x00, 0x3b, 0x6e, 0x66, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x00, 0x08, 0x0c, 0x3e, 0x0c, 0x0c,
  29.116 -	0x2c,
  29.117 -	0x18, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6e, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x00, 0x00,
  29.118 -	0x63,
  29.119 -	0x6b, 0x7f, 0x7f, 0x36, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x3e, 0x30,
  29.120 -	0x1f,
  29.121 -	0x00, 0x00, 0x3f, 0x19, 0x0c, 0x26, 0x3f, 0x00, 0x38, 0x0c, 0x0c, 0x07, 0x0c, 0x0c, 0x38, 0x00, 0x18, 0x18, 0x18, 0x00,
  29.122 -	0x18,
  29.123 -	0x18, 0x18, 0x00, 0x07, 0x0c, 0x0c, 0x38, 0x0c, 0x0c, 0x07, 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  29.124 -	0x08,
  29.125 -	0x1c, 0x36, 0x63, 0x63, 0x7f, 0x00,
  29.126 -	0x1e, 0x33, 0x03, 0x33, 0x1e, 0x18, 0x30, 0x1e, 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x38, 0x00, 0x1e, 0x33,
  29.127 -	0x3f, 0x03, 0x1e, 0x00, 0x7e, 0xc3, 0x3c, 0x60, 0x7c, 0x66, 0xfc, 0x00, 0x33, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00,
  29.128 -	0x07,
  29.129 -	0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x0c, 0x0c, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x00, 0x00, 0x1e, 0x03, 0x03,
  29.130 -	0x1e,
  29.131 -	0x30, 0x1c, 0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x06, 0x3c, 0x00, 0x33, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x07, 0x00,
  29.132 -	0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x33, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x3e, 0x63, 0x1c, 0x18, 0x18, 0x18,
  29.133 -	0x3c,
  29.134 -	0x00, 0x07, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x63, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x63, 0x00, 0x0c, 0x0c, 0x00,
  29.135 -	0x1e,
  29.136 -	0x33, 0x3f, 0x33, 0x00, 0x38, 0x00, 0x3f, 0x06, 0x1e, 0x06, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x30, 0xfe, 0x33, 0xfe, 0x00,
  29.137 -	0x7c,
  29.138 -	0x36, 0x33, 0x7f, 0x33, 0x33, 0x73, 0x00, 0x1e, 0x33, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x33, 0x00, 0x1e, 0x33,
  29.139 -	0x33,
  29.140 -	0x1e, 0x00, 0x00, 0x07, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x07,
  29.141 -	0x00,
  29.142 -	0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x33, 0x00, 0x33, 0x33, 0x3e, 0x30, 0x1f, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18,
  29.143 -	0x00,
  29.144 -	0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x00, 0x18, 0x18, 0x7e, 0x03, 0x03, 0x7e, 0x18, 0x18, 0x1c, 0x36, 0x26, 0x0f,
  29.145 -	0x06,
  29.146 -	0x67, 0x3f, 0x00, 0x33, 0x33, 0x1e, 0x3f, 0x0c, 0x3f, 0x0c, 0x0c, 0x1f, 0x33, 0x33, 0x5f, 0x63, 0xf3, 0x63, 0xe3, 0x70,
  29.147 -	0xd8,
  29.148 -	0x18, 0x3c, 0x18, 0x18, 0x1b, 0x0e,
  29.149 -	0x38, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x1c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x1e,
  29.150 -	0x33, 0x33, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x00,
  29.151 -	0x3f,
  29.152 -	0x00, 0x33, 0x37, 0x3f, 0x3b, 0x33, 0x00, 0x3c, 0x36, 0x36, 0x7c, 0x00, 0x7e, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00,
  29.153 -	0x3e,
  29.154 -	0x00, 0x00, 0x0c, 0x00, 0x0c, 0x06, 0x03, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
  29.155 -	0x00, 0x3f, 0x30, 0x30, 0x00, 0x00, 0xc3, 0x63, 0x33, 0x7b, 0xcc, 0x66, 0x33, 0xf0, 0xc3, 0x63, 0x33, 0xdb, 0xec, 0xf6,
  29.156 -	0xf3,
  29.157 -	0xc0, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x00, 0x33, 0x66,
  29.158 -	0xcc,
  29.159 -	0x66, 0x33, 0x00, 0x00, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55,
  29.160 -	0xdb,
  29.161 -	0xee, 0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f,
  29.162 -	0x18,
  29.163 -	0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x6c, 0x6c, 0x6c, 0x00, 0x00,
  29.164 -	0x00,
  29.165 -	0x00, 0x7f, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6f, 0x60, 0x6f, 0x6c, 0x6c,
  29.166 -	0x6c,
  29.167 -	0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x7f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x60,
  29.168 -	0x7f,
  29.169 -	0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0x7f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00,
  29.170 -	0x00,
  29.171 -	0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
  29.172 -	0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  29.173 -	0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
  29.174 -	0x18,
  29.175 -	0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0xec,
  29.176 -	0x6c,
  29.177 -	0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c,
  29.178 -	0xef, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xec, 0x6c,
  29.179 -	0x6c,
  29.180 -	0x6c, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xef, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff,
  29.181 -	0x00,
  29.182 -	0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
  29.183 -	0x00,
  29.184 -	0x00, 0x00, 0x00, 0xff, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xfc, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18, 0xf8,
  29.185 -	0x00,
  29.186 -	0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c,
  29.187 -	0x6c,
  29.188 -	0x6c, 0xff, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00,
  29.189 -	0x00,
  29.190 -	0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  29.191 -	0xff,
  29.192 -	0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff,
  29.193 -	0xff,
  29.194 -	0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  29.195 -	0x00, 0x00, 0x6e, 0x3b, 0x13, 0x3b, 0x6e, 0x00, 0x00, 0x1e, 0x33, 0x1f, 0x33, 0x1f, 0x03, 0x03, 0x00, 0x3f, 0x33, 0x03,
  29.196 -	0x03, 0x03, 0x03, 0x00, 0x00, 0x7f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x3f, 0x33, 0x06, 0x0c, 0x06, 0x33, 0x3f, 0x00,
  29.197 -	0x00,
  29.198 -	0x00, 0x7e, 0x1b, 0x1b, 0x1b, 0x0e, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x03, 0x00, 0x6e, 0x3b, 0x18, 0x18,
  29.199 -	0x18,
  29.200 -	0x18, 0x00, 0x3f, 0x0c, 0x1e, 0x33, 0x33, 0x1e, 0x0c, 0x3f, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x36, 0x1c, 0x00, 0x1c, 0x36,
  29.201 -	0x63, 0x63, 0x36, 0x36, 0x77, 0x00, 0x38, 0x0c, 0x18, 0x3e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e,
  29.202 -	0x00,
  29.203 -	0x00, 0x60, 0x30, 0x7e, 0xdb, 0xdb, 0x7e, 0x06, 0x03, 0x1c, 0x06, 0x03, 0x1f, 0x03, 0x06, 0x1c, 0x00, 0x1e, 0x33, 0x33,
  29.204 -	0x33,
  29.205 -	0x33, 0x33, 0x33, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x3f, 0x00,
  29.206 -	0x06,
  29.207 -	0x0c, 0x18, 0x0c, 0x06, 0x00, 0x3f, 0x00, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x00, 0x3f, 0x00, 0x70, 0xd8, 0xd8, 0x18, 0x18,
  29.208 -	0x18,
  29.209 -	0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1b, 0x1b, 0x0e, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x6e,
  29.210 -	0x3b,
  29.211 -	0x00, 0x6e, 0x3b, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
  29.212 -	0x00,
  29.213 -	0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf0, 0x30, 0x30, 0x30, 0x37, 0x36, 0x3c, 0x38, 0x1e, 0x36, 0x36, 0x36,
  29.214 -	0x36,
  29.215 -	0x00, 0x00, 0x00, 0x0e, 0x18, 0x0c, 0x06, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00,
  29.216 -	0x00,
  29.217 -	0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  29.218 -};
  29.219 -
  29.220 -static void calcColors(const int colorNum, int & lo, int & hi, int & out)
  29.221 -{
  29.222 -	int redLo, redHi, greenLo, greenHi, blueLo, blueHi;
  29.223 -
  29.224 -	if (colorNum == 0 || colorNum == 1 || colorNum == 2 || colorNum == 6) // white, red, yellow, or magenta
  29.225 -		redLo = (0xf) << systemRedShift, redHi = (0x1f) << systemRedShift;
  29.226 -	else
  29.227 -		redLo = redHi = 0;
  29.228 -
  29.229 -	if (colorNum == 0 || colorNum == 2 || colorNum == 3 || colorNum == 4) // white, yellow, green, or cyan
  29.230 -		greenLo = (0xf) << systemGreenShift, greenHi = (0x1f) << systemGreenShift;
  29.231 -	else
  29.232 -		greenLo = greenHi = 0;
  29.233 -
  29.234 -	if (colorNum == 0 || colorNum == 4 || colorNum == 5 || colorNum == 6) // white, cyan, blue, or magenta
  29.235 -		blueLo = (0xf) << systemBlueShift, blueHi = (0x1f) << systemBlueShift;
  29.236 -	else
  29.237 -		blueLo = blueHi = 0;
  29.238 -
  29.239 -	lo = redLo + greenLo + blueLo;
  29.240 -	hi = redHi + greenHi + blueHi;
  29.241 -
  29.242 -	if (colorNum == 7) // black
  29.243 -		out = 0xffffffff; // white border
  29.244 -	else
  29.245 -		out = 0;  // black border
  29.246 -}
  29.247 -
  29.248 -int lastColID = 0;
  29.249 -static void progressColorList(const char *& colorList, int & lo, int & hi, int & out)
  29.250 -{
  29.251 -	if (*colorList)
  29.252 -	{
  29.253 -		if (*colorList != lastColID)
  29.254 -		{
  29.255 -			calcColors((int)(*colorList)-1, lo, hi, out);
  29.256 -			lastColID = *colorList;
  29.257 -		}
  29.258 -		colorList++;
  29.259 -	}
  29.260 -	else
  29.261 -	{
  29.262 -		colorList = NULL;
  29.263 -	}
  29.264 -}
  29.265 -
  29.266 -static void drawTextInternal(u8 *screen, int pitch, int x, int y,
  29.267 -                             const char *string, bool trans, const char *colorList = NULL)
  29.268 -{
  29.269 -	if (colorList && !*colorList)
  29.270 -		colorList = NULL;
  29.271 -
  29.272 -	int loCol, hiCol, outCol;
  29.273 -	calcColors(textColor, loCol, hiCol, outCol);
  29.274 -
  29.275 -	lastColID = 0;
  29.276 -
  29.277 -	const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
  29.278 -	const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
  29.279 -
  29.280 -	screen += y*pitch;
  29.281 -	int inc = 2;
  29.282 -	switch (systemColorDepth)
  29.283 -	{
  29.284 -	case 24:
  29.285 -		inc = 3;
  29.286 -		break;
  29.287 -	case 32:
  29.288 -		inc = 4;
  29.289 -		break;
  29.290 -	}
  29.291 -	screen += x*inc;
  29.292 -
  29.293 -	int xpos = x;
  29.294 -	switch (systemColorDepth)
  29.295 -	{
  29.296 -	case 16:
  29.297 -	{
  29.298 -		while (*string)
  29.299 -		{
  29.300 -			char c   = *string++;
  29.301 -			u8 * scr = screen;
  29.302 -
  29.303 -			if (colorList)
  29.304 -				progressColorList(colorList, loCol, hiCol, outCol);
  29.305 -
  29.306 -			u16  mask = u16(~RGB_LOW_BITS_MASK);
  29.307 -			u16 *s = (u16 *)scr;
  29.308 -			for (int h = 0-1; h < 8+1; h++)
  29.309 -			{
  29.310 -				for (int w = 0-1; w < 8+1; w++, s++)
  29.311 -				{
  29.312 -					int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
  29.313 -
  29.314 -					int border = 0;
  29.315 -					if (outlinedText)
  29.316 -						for (int i = 0; i < 8; i++)
  29.317 -						{
  29.318 -							int h2 = h+yd[i], w2 = w+xd[i];
  29.319 -							border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
  29.320 -							if (border)
  29.321 -								break;
  29.322 -						}
  29.323 -
  29.324 -					if (trans)
  29.325 -					{
  29.326 -						if (on)
  29.327 -							*s = loCol +
  29.328 -							     ((*s & mask) >>1);
  29.329 -						else if (border)
  29.330 -						{
  29.331 -							*s = outCol +
  29.332 -							     ((*s & mask) >>1);
  29.333 -						}
  29.334 -					}
  29.335 -					else
  29.336 -					{
  29.337 -						if (on)
  29.338 -							*s = hiCol;
  29.339 -						else if (border)
  29.340 -							*s = outCol;
  29.341 -					}
  29.342 -				}
  29.343 -				scr += pitch;
  29.344 -				s    = (u16 *)scr;
  29.345 -			}
  29.346 -			screen += inc*8;
  29.347 -
  29.348 -			xpos += 8;
  29.349 -			if (xpos+8 > pitch>>1) // cut off text at right boundary
  29.350 -				break;
  29.351 -		}
  29.352 -		break;
  29.353 -	}
  29.354 -	case 24: // TODO: verify this code's correctness
  29.355 -	{
  29.356 -		while (*string)
  29.357 -		{
  29.358 -			char c   = *string++;
  29.359 -			u8 * scr = screen;
  29.360 -
  29.361 -			if (colorList)
  29.362 -				progressColorList(colorList, loCol, hiCol, outCol);
  29.363 -
  29.364 -			int h, w;
  29.365 -			u8 *s = (u8 *)scr;
  29.366 -			for (h = 0-1; h < 8+1; h++)
  29.367 -			{
  29.368 -				for (w = 0-1; w < 8+1; w++, s++)
  29.369 -				{
  29.370 -					int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
  29.371 -
  29.372 -					int border = 0;
  29.373 -					if (outlinedText)
  29.374 -						for (int i = 0; i < 8; i++)
  29.375 -						{
  29.376 -							int h2 = h+yd[i], w2 = w+xd[i];
  29.377 -							border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
  29.378 -							if (border)
  29.379 -								break;
  29.380 -						}
  29.381 -
  29.382 -					if (trans)
  29.383 -					{
  29.384 -						if (on)
  29.385 -						{
  29.386 -							u32 color = hiCol;
  29.387 -							*s     = ((color & 255)>>1)+(*s>>1);
  29.388 -							*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
  29.389 -							*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
  29.390 -						}
  29.391 -						else if (border)
  29.392 -						{
  29.393 -							u32 color = outCol;
  29.394 -							*s     = ((color & 255)>>1)+(*s>>1);
  29.395 -							*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
  29.396 -							*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
  29.397 -						}
  29.398 -					}
  29.399 -					else
  29.400 -					{
  29.401 -						if (on)
  29.402 -						{
  29.403 -							u32 color = hiCol;
  29.404 -							*s     = (color & 255);
  29.405 -							*(s+1) = (color >> 8) & 255;
  29.406 -							*(s+2) = (color >> 16) & 255;
  29.407 -						}
  29.408 -						else if (border)
  29.409 -						{
  29.410 -							u32 color = outCol;
  29.411 -							*s     = (color & 255);
  29.412 -							*(s+1) = (color >> 8) & 255;
  29.413 -							*(s+2) = (color >> 16) & 255;
  29.414 -						}
  29.415 -					}
  29.416 -				}
  29.417 -				scr += pitch;
  29.418 -				s    = (u8 *)scr;
  29.419 -			}
  29.420 -			screen += inc*8;
  29.421 -
  29.422 -			xpos += 8;
  29.423 -			if (xpos+8 > pitch/3) // cut off text at right boundary
  29.424 -				break;
  29.425 -		}
  29.426 -		break;
  29.427 -	}
  29.428 -	case 32:
  29.429 -	{
  29.430 -		while (*string)
  29.431 -		{
  29.432 -			char c   = *string++;
  29.433 -			u8 * scr = screen;
  29.434 -
  29.435 -			if (colorList)
  29.436 -				progressColorList(colorList, loCol, hiCol, outCol);
  29.437 -
  29.438 -			int  h, w;
  29.439 -			u32  mask = 0xfefefe;
  29.440 -			u32 *s    = (u32 *)scr;
  29.441 -			for (h = 0-1; h < 8+1; h++)
  29.442 -			{
  29.443 -				for (w = 0-1; w < 8+1; w++, s++)
  29.444 -				{
  29.445 -					int on = (h < 0 || w < 0 || h >= 8 || w >= 8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1;
  29.446 -
  29.447 -					int border = 0;
  29.448 -					if (outlinedText)
  29.449 -						for (int i = 0; i < 8; i++)
  29.450 -						{
  29.451 -							int h2 = h+yd[i], w2 = w+xd[i];
  29.452 -							border = (h2 < 0 || w2 < 0 || h2 >= 8 || w2 >= 8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1;
  29.453 -							if (border)
  29.454 -								break;
  29.455 -						}
  29.456 -
  29.457 -					if (trans)
  29.458 -					{
  29.459 -						if (on)
  29.460 -							*s = loCol +
  29.461 -							     ((*s & mask)>>1);
  29.462 -						else if (border)
  29.463 -						{
  29.464 -							*s = outCol +
  29.465 -							     ((*s & mask)>>1);
  29.466 -						}
  29.467 -					}
  29.468 -					else
  29.469 -					{
  29.470 -						if (on)
  29.471 -							*s = hiCol;
  29.472 -						else if (border)
  29.473 -							*s = outCol;
  29.474 -					}
  29.475 -				}
  29.476 -				scr += pitch;
  29.477 -				s    = (u32 *)scr;
  29.478 -			}
  29.479 -			screen += inc*8;
  29.480 -
  29.481 -			xpos += 8;
  29.482 -			if (xpos+8 > pitch>>2) // cut off text at right boundary
  29.483 -				break;
  29.484 -		}
  29.485 -		break;
  29.486 -	}
  29.487 -	}
  29.488 -}
  29.489 -
  29.490 -void drawText(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList)
  29.491 -{
  29.492 -	drawTextInternal(screen, pitch, x, y, string, transparentText, colorList);
  29.493 -}
  29.494 -
  29.495 -void drawTextTransp(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList)
  29.496 -{
  29.497 -	drawTextInternal(screen, pitch, x, y, string, true, colorList);
  29.498 -}
  29.499 -
    30.1 --- a/src/common/Text.h	Sat Mar 03 10:54:39 2012 -0600
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,14 +0,0 @@
    30.4 -#ifndef VBA_TEXT_H
    30.5 -#define VBA_TEXT_H
    30.6 -
    30.7 -#if _MSC_VER > 1000
    30.8 -#pragma once
    30.9 -#endif // _MSC_VER > 1000
   30.10 -
   30.11 -extern void drawText(u8 *, int, int, int, const char *, const char*cl = NULL);
   30.12 -extern void drawTextTransp(u8 *, int, int, int, const char *, const char*cl = NULL);
   30.13 -
   30.14 -extern bool outlinedText, transparentText;
   30.15 -extern int  textColor, textMethod;
   30.16 -
   30.17 -#endif // VBA_TEXT_H
    31.1 --- a/src/common/Util.cpp	Sat Mar 03 10:54:39 2012 -0600
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,1400 +0,0 @@
    31.4 -#include <cstdio>
    31.5 -#include <cstdlib>
    31.6 -#include <cstring>
    31.7 -#include <zlib.h>
    31.8 -
    31.9 -extern "C" {
   31.10 -#include <png.h>
   31.11 -}
   31.12 -
   31.13 -#if 0
   31.14 -#include "unrarlib.h"
   31.15 -#endif
   31.16 -
   31.17 -#include "unzip.h"
   31.18 -
   31.19 -#include "../NLS.h"
   31.20 -#include "System.h"
   31.21 -#include "Util.h"
   31.22 -#include "../gba/Flash.h"
   31.23 -#include "../gba/RTC.h"
   31.24 -
   31.25 -extern "C" {
   31.26 -#include "memgzio.h"
   31.27 -}
   31.28 -
   31.29 -#ifndef _MSC_VER
   31.30 -#define _stricmp strcasecmp
   31.31 -#endif // ! _MSC_VER
   31.32 -
   31.33 -extern int32 cpuSaveType;
   31.34 -
   31.35 -extern int systemColorDepth;
   31.36 -extern int systemRedShift;
   31.37 -extern int systemGreenShift;
   31.38 -extern int systemBlueShift;
   31.39 -
   31.40 -extern u16 systemColorMap16[0x10000];
   31.41 -extern u32 systemColorMap32[0x10000];
   31.42 -
   31.43 -static int	   (ZEXPORT *utilGzWriteFunc)(gzFile, voidp, unsigned int) = NULL;
   31.44 -static int	   (ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int)  = NULL;
   31.45 -static int	   (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;
   31.46 -static z_off_t (ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL;
   31.47 -static z_off_t (ZEXPORT *utilGzTellFunc)(gzFile) = NULL;
   31.48 -
   31.49 -//Kludge to get it to compile in Linux, GCC cannot convert
   31.50 -//gzwrite function pointer to the type of utilGzWriteFunc
   31.51 -//due to void* and const void* differences
   31.52 -//--Felipe 
   31.53 -int gzWrite(gzFile file, void* buf, unsigned len){
   31.54 -	return gzwrite(file,buf,len);
   31.55 -}
   31.56 -
   31.57 -void utilPutDword(u8 *p, u32 value)
   31.58 -{
   31.59 -	*p++ = value & 255;
   31.60 -	*p++ = (value >> 8) & 255;
   31.61 -	*p++ = (value >> 16) & 255;
   31.62 -	*p	 = (value >> 24) & 255;
   31.63 -}
   31.64 -
   31.65 -void utilPutWord(u8 *p, u16 value)
   31.66 -{
   31.67 -	*p++ = value & 255;
   31.68 -	*p	 = (value >> 8) & 255;
   31.69 -}
   31.70 -
   31.71 -void utilWriteBMP(u8 *b, int w, int h, int dstDepth, u8 *pix)
   31.72 -{
   31.73 -	int sizeX = w;
   31.74 -	int sizeY = h;
   31.75 -
   31.76 -	switch (dstDepth > 0 ? dstDepth : systemColorDepth)
   31.77 -	{
   31.78 -	case 16:
   31.79 -	{
   31.80 -		u16 *p = (u16 *)(pix + (w + 2) * (h) * 2); // skip first black line
   31.81 -		for (int y = 0; y < sizeY; y++)
   31.82 -		{
   31.83 -			for (int x = 0; x < sizeX; x++)
   31.84 -			{
   31.85 -				u16 v = *p++;
   31.86 -
   31.87 -				*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
   31.88 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
   31.89 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
   31.90 -			}
   31.91 -			p++; // skip black pixel for filters
   31.92 -			p++; // skip black pixel for filters
   31.93 -			p -= 2 * (w + 2);
   31.94 -		}
   31.95 -		break;
   31.96 -	}
   31.97 -	case 24:
   31.98 -	{
   31.99 -		u8 *pixU8 = (u8 *)pix + 3 * w * (h - 1);
  31.100 -		for (int y = 0; y < sizeY; y++)
  31.101 -		{
  31.102 -			for (int x = 0; x < sizeX; x++)
  31.103 -			{
  31.104 -				if (systemRedShift > systemBlueShift)
  31.105 -				{
  31.106 -					*b++ = *pixU8++; // B
  31.107 -					*b++ = *pixU8++; // G
  31.108 -					*b++ = *pixU8++; // R
  31.109 -				}
  31.110 -				else
  31.111 -				{
  31.112 -					int red	  = *pixU8++;
  31.113 -					int green = *pixU8++;
  31.114 -					int blue  = *pixU8++;
  31.115 -
  31.116 -					*b++ = blue;
  31.117 -					*b++ = green;
  31.118 -					*b++ = red;
  31.119 -				}
  31.120 -			}
  31.121 -			pixU8 -= 2 * 3 * w;
  31.122 -		}
  31.123 -		break;
  31.124 -	}
  31.125 -	case 32:
  31.126 -	{
  31.127 -		u32 *pixU32 = (u32 *)(pix + 4 * (w + 1) * (h));
  31.128 -		for (int y = 0; y < sizeY; y++)
  31.129 -		{
  31.130 -			for (int x = 0; x < sizeX; x++)
  31.131 -			{
  31.132 -				u32 v = *pixU32++;
  31.133 -
  31.134 -				*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
  31.135 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
  31.136 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
  31.137 -			}
  31.138 -			pixU32++;
  31.139 -			pixU32 -= 2 * (w + 1);
  31.140 -		}
  31.141 -		break;
  31.142 -	}
  31.143 -	}
  31.144 -}
  31.145 -
  31.146 -bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
  31.147 -{
  31.148 -	u8 writeBuffer[256 * 3];
  31.149 -
  31.150 -	FILE *fp = fopen(fileName, "wb");
  31.151 -
  31.152 -	if (!fp)
  31.153 -	{
  31.154 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName);
  31.155 -		return false;
  31.156 -	}
  31.157 -
  31.158 -	struct
  31.159 -	{
  31.160 -		u8 ident[2];
  31.161 -		u8 filesize[4];
  31.162 -		u8 reserved[4];
  31.163 -		u8 dataoffset[4];
  31.164 -		u8 headersize[4];
  31.165 -		u8 width[4];
  31.166 -		u8 height[4];
  31.167 -		u8 planes[2];
  31.168 -		u8 bitsperpixel[2];
  31.169 -		u8 compression[4];
  31.170 -		u8 datasize[4];
  31.171 -		u8 hres[4];
  31.172 -		u8 vres[4];
  31.173 -		u8 colors[4];
  31.174 -		u8 importantcolors[4];
  31.175 -		//    u8 pad[2];
  31.176 -	} bmpheader;
  31.177 -	memset(&bmpheader, 0, sizeof(bmpheader));
  31.178 -
  31.179 -	bmpheader.ident[0] = 'B';
  31.180 -	bmpheader.ident[1] = 'M';
  31.181 -
  31.182 -	u32 fsz = sizeof(bmpheader) + w * h * 3;
  31.183 -	utilPutDword(bmpheader.filesize, fsz);
  31.184 -	utilPutDword(bmpheader.dataoffset, 0x36);
  31.185 -	utilPutDword(bmpheader.headersize, 0x28);
  31.186 -	utilPutDword(bmpheader.width, w);
  31.187 -	utilPutDword(bmpheader.height, h);
  31.188 -	utilPutDword(bmpheader.planes, 1);
  31.189 -	utilPutDword(bmpheader.bitsperpixel, 24);
  31.190 -	utilPutDword(bmpheader.datasize, 3 * w * h);
  31.191 -
  31.192 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
  31.193 -
  31.194 -#if 0
  31.195 -	// FIXME: need sufficient buffer
  31.196 -	utilWriteBMP(writeBuffer, w, h, systemColorDepth, pix);
  31.197 -#else
  31.198 -	u8 *b = writeBuffer;
  31.199 -
  31.200 -	int sizeX = w;
  31.201 -	int sizeY = h;
  31.202 -
  31.203 -	switch (systemColorDepth)
  31.204 -	{
  31.205 -	case 16:
  31.206 -	{
  31.207 -		u16 *p = (u16 *)(pix + (w + 2) * (h) * 2); // skip first black line
  31.208 -		for (int y = 0; y < sizeY; y++)
  31.209 -		{
  31.210 -			for (int x = 0; x < sizeX; x++)
  31.211 -			{
  31.212 -				u16 v = *p++;
  31.213 -
  31.214 -				*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
  31.215 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
  31.216 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
  31.217 -			}
  31.218 -			p++; // skip black pixel for filters
  31.219 -			p++; // skip black pixel for filters
  31.220 -			p -= 2 * (w + 2);
  31.221 -			fwrite(writeBuffer, 1, 3 * w, fp);
  31.222 -
  31.223 -			b = writeBuffer;
  31.224 -		}
  31.225 -		break;
  31.226 -	}
  31.227 -	case 24:
  31.228 -	{
  31.229 -		u8 *pixU8 = (u8 *)pix + 3 * w * (h - 1);
  31.230 -		for (int y = 0; y < sizeY; y++)
  31.231 -		{
  31.232 -			for (int x = 0; x < sizeX; x++)
  31.233 -			{
  31.234 -				if (systemRedShift > systemBlueShift)
  31.235 -				{
  31.236 -					*b++ = *pixU8++; // B
  31.237 -					*b++ = *pixU8++; // G
  31.238 -					*b++ = *pixU8++; // R
  31.239 -				}
  31.240 -				else
  31.241 -				{
  31.242 -					int red	  = *pixU8++;
  31.243 -					int green = *pixU8++;
  31.244 -					int blue  = *pixU8++;
  31.245 -
  31.246 -					*b++ = blue;
  31.247 -					*b++ = green;
  31.248 -					*b++ = red;
  31.249 -				}
  31.250 -			}
  31.251 -			pixU8 -= 2 * 3 * w;
  31.252 -			fwrite(writeBuffer, 1, 3 * w, fp);
  31.253 -
  31.254 -			b = writeBuffer;
  31.255 -		}
  31.256 -		break;
  31.257 -	}
  31.258 -	case 32:
  31.259 -	{
  31.260 -		u32 *pixU32 = (u32 *)(pix + 4 * (w + 1) * (h));
  31.261 -		for (int y = 0; y < sizeY; y++)
  31.262 -		{
  31.263 -			for (int x = 0; x < sizeX; x++)
  31.264 -			{
  31.265 -				u32 v = *pixU32++;
  31.266 -
  31.267 -				*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
  31.268 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
  31.269 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
  31.270 -			}
  31.271 -			pixU32++;
  31.272 -			pixU32 -= 2 * (w + 1);
  31.273 -
  31.274 -			fwrite(writeBuffer, 1, 3 * w, fp);
  31.275 -
  31.276 -			b = writeBuffer;
  31.277 -		}
  31.278 -		break;
  31.279 -	}
  31.280 -	}
  31.281 -#endif
  31.282 -
  31.283 -	fclose(fp);
  31.284 -
  31.285 -	return true;
  31.286 -}
  31.287 -
  31.288 -bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
  31.289 -{
  31.290 -	u8 writeBuffer[256 * 3];
  31.291 -
  31.292 -	FILE *fp = fopen(fileName, "wb");
  31.293 -
  31.294 -	if (!fp)
  31.295 -	{
  31.296 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName);
  31.297 -		return false;
  31.298 -	}
  31.299 -
  31.300 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
  31.301 -	                                              NULL,
  31.302 -	                                              NULL,
  31.303 -	                                              NULL);
  31.304 -	if (!png_ptr)
  31.305 -	{
  31.306 -		fclose(fp);
  31.307 -		return false;
  31.308 -	}
  31.309 -
  31.310 -	png_infop info_ptr = png_create_info_struct(png_ptr);
  31.311 -
  31.312 -	if (!info_ptr)
  31.313 -	{
  31.314 -		png_destroy_write_struct(&png_ptr, NULL);
  31.315 -		fclose(fp);
  31.316 -		return false;
  31.317 -	}
  31.318 -
  31.319 -	if (setjmp(png_ptr->jmpbuf))
  31.320 -	{
  31.321 -		png_destroy_write_struct(&png_ptr, NULL);
  31.322 -		fclose(fp);
  31.323 -		return false;
  31.324 -	}
  31.325 -
  31.326 -	png_init_io(png_ptr, fp);
  31.327 -
  31.328 -	png_set_IHDR(png_ptr,
  31.329 -	             info_ptr,
  31.330 -	             w,
  31.331 -	             h,
  31.332 -	             8,
  31.333 -	             PNG_COLOR_TYPE_RGB,
  31.334 -	             PNG_INTERLACE_NONE,
  31.335 -	             PNG_COMPRESSION_TYPE_DEFAULT,
  31.336 -	             PNG_FILTER_TYPE_DEFAULT);
  31.337 -
  31.338 -	png_write_info(png_ptr, info_ptr);
  31.339 -
  31.340 -	u8 *b = writeBuffer;
  31.341 -
  31.342 -	int sizeX = w;
  31.343 -	int sizeY = h;
  31.344 -
  31.345 -	switch (systemColorDepth)
  31.346 -	{
  31.347 -	case 16:
  31.348 -	{
  31.349 -		u16 *p = (u16 *)(pix + (w + 2) * 2); // skip first black line
  31.350 -		for (int y = 0; y < sizeY; y++)
  31.351 -		{
  31.352 -			for (int x = 0; x < sizeX; x++)
  31.353 -			{
  31.354 -				u16 v = *p++;
  31.355 -
  31.356 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
  31.357 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
  31.358 -				*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
  31.359 -			}
  31.360 -			p++; // skip black pixel for filters
  31.361 -			p++; // skip black pixel for filters
  31.362 -			png_write_row(png_ptr, writeBuffer);
  31.363 -
  31.364 -			b = writeBuffer;
  31.365 -		}
  31.366 -		break;
  31.367 -	}
  31.368 -	case 24:
  31.369 -	{
  31.370 -		u8 *pixU8 = (u8 *)pix;
  31.371 -		for (int y = 0; y < sizeY; y++)
  31.372 -		{
  31.373 -			for (int x = 0; x < sizeX; x++)
  31.374 -			{
  31.375 -				if (systemRedShift < systemBlueShift)
  31.376 -				{
  31.377 -					*b++ = *pixU8++; // R
  31.378 -					*b++ = *pixU8++; // G
  31.379 -					*b++ = *pixU8++; // B
  31.380 -				}
  31.381 -				else
  31.382 -				{
  31.383 -					int blue  = *pixU8++;
  31.384 -					int green = *pixU8++;
  31.385 -					int red	  = *pixU8++;
  31.386 -
  31.387 -					*b++ = red;
  31.388 -					*b++ = green;
  31.389 -					*b++ = blue;
  31.390 -				}
  31.391 -			}
  31.392 -			png_write_row(png_ptr, writeBuffer);
  31.393 -
  31.394 -			b = writeBuffer;
  31.395 -		}
  31.396 -		break;
  31.397 -	}
  31.398 -	case 32:
  31.399 -	{
  31.400 -		u32 *pixU32 = (u32 *)(pix + 4 * (w + 1));
  31.401 -		for (int y = 0; y < sizeY; y++)
  31.402 -		{
  31.403 -			for (int x = 0; x < sizeX; x++)
  31.404 -			{
  31.405 -				u32 v = *pixU32++;
  31.406 -
  31.407 -				*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
  31.408 -				*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
  31.409 -				*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
  31.410 -			}
  31.411 -			pixU32++;
  31.412 -
  31.413 -			png_write_row(png_ptr, writeBuffer);
  31.414 -
  31.415 -			b = writeBuffer;
  31.416 -		}
  31.417 -		break;
  31.418 -	}
  31.419 -	}
  31.420 -
  31.421 -	png_write_end(png_ptr, info_ptr);
  31.422 -
  31.423 -	png_destroy_write_struct(&png_ptr, &info_ptr);
  31.424 -
  31.425 -	fclose(fp);
  31.426 -
  31.427 -	return true;
  31.428 -}
  31.429 -
  31.430 -static int utilReadInt2(FILE *f)
  31.431 -{
  31.432 -	int res = 0;
  31.433 -	int c	= fgetc(f);
  31.434 -	if (c == EOF)
  31.435 -		return -1;
  31.436 -	res = c;
  31.437 -	c	= fgetc(f);
  31.438 -	if (c == EOF)
  31.439 -		return -1;
  31.440 -	return c + (res << 8);
  31.441 -}
  31.442 -
  31.443 -static int utilReadInt3(FILE *f)
  31.444 -{
  31.445 -	int res = 0;
  31.446 -	int c	= fgetc(f);
  31.447 -	if (c == EOF)
  31.448 -		return -1;
  31.449 -	res = c;
  31.450 -	c	= fgetc(f);
  31.451 -	if (c == EOF)
  31.452 -		return -1;
  31.453 -	res = c + (res << 8);
  31.454 -	c	= fgetc(f);
  31.455 -	if (c == EOF)
  31.456 -		return -1;
  31.457 -	return c + (res << 8);
  31.458 -}
  31.459 -
  31.460 -void utilApplyIPS(const char *ips, u8 * *r, int *s)
  31.461 -{
  31.462 -	// from the IPS spec at http://zerosoft.zophar.net/ips.htm
  31.463 -	FILE *f = fopen(ips, "rb");
  31.464 -	if (!f)
  31.465 -		return;
  31.466 -	u8 *rom	 = *r;
  31.467 -	int size = *s;
  31.468 -	if (fgetc(f) == 'P' &&
  31.469 -	    fgetc(f) == 'A' &&
  31.470 -	    fgetc(f) == 'T' &&
  31.471 -	    fgetc(f) == 'C' &&
  31.472 -	    fgetc(f) == 'H')
  31.473 -	{
  31.474 -		int b;
  31.475 -		int offset;
  31.476 -		int len;
  31.477 -		for (;; )
  31.478 -		{
  31.479 -			// read offset
  31.480 -			offset = utilReadInt3(f);
  31.481 -			// if offset == EOF, end of patch
  31.482 -			if (offset == 0x454f46)
  31.483 -				break;
  31.484 -			// read length
  31.485 -			len = utilReadInt2(f);
  31.486 -			if (!len)
  31.487 -			{
  31.488 -				// len == 0, RLE block
  31.489 -				len = utilReadInt2(f);
  31.490 -				// byte to fill
  31.491 -				int c = fgetc(f);
  31.492 -				if (c == -1)
  31.493 -					break;
  31.494 -				b = (u8)c;
  31.495 -			}
  31.496 -			else
  31.497 -				b = -1;
  31.498 -			// check if we need to reallocate our ROM
  31.499 -			if ((offset + len) >= size)
  31.500 -			{
  31.501 -				size *= 2;
  31.502 -				rom	  = (u8 *)realloc(rom, size);
  31.503 -				*r	  = rom;
  31.504 -				*s	  = size;
  31.505 -			}
  31.506 -			if (b == -1)
  31.507 -			{
  31.508 -				// normal block, just read the data
  31.509 -				if (fread(&rom[offset], 1, len, f) != (size_t)len)
  31.510 -					break;
  31.511 -			}
  31.512 -			else
  31.513 -			{
  31.514 -				// fill the region with the given byte
  31.515 -				while (len--)
  31.516 -				{
  31.517 -					rom[offset++] = b;
  31.518 -				}
  31.519 -			}
  31.520 -		}
  31.521 -	}
  31.522 -	// close the file
  31.523 -	fclose(f);
  31.524 -}
  31.525 -
  31.526 -extern bool8 cpuIsMultiBoot;
  31.527 -
  31.528 -bool utilIsGBAImage(const char *file)
  31.529 -{
  31.530 -	cpuIsMultiBoot = false;
  31.531 -	if (strlen(file) > 4)
  31.532 -	{
  31.533 -		const char *p = strrchr(file, '.');
  31.534 -
  31.535 -		if (p != NULL)
  31.536 -		{
  31.537 -			if (_stricmp(p, ".gba") == 0)
  31.538 -				return true;
  31.539 -			if (_stricmp(p, ".agb") == 0)
  31.540 -				return true;
  31.541 -			if (_stricmp(p, ".bin") == 0)
  31.542 -				return true;
  31.543 -			if (_stricmp(p, ".elf") == 0)
  31.544 -				return true;
  31.545 -			if (_stricmp(p, ".mb") == 0)
  31.546 -			{
  31.547 -				cpuIsMultiBoot = true;
  31.548 -				return true;
  31.549 -			}
  31.550 -		}
  31.551 -	}
  31.552 -
  31.553 -	return false;
  31.554 -}
  31.555 -
  31.556 -bool utilIsGBImage(const char *file)
  31.557 -{
  31.558 -	if (strlen(file) > 4)
  31.559 -	{
  31.560 -		const char *p = strrchr(file, '.');
  31.561 -
  31.562 -		if (p != NULL)
  31.563 -		{
  31.564 -			if (_stricmp(p, ".gb") == 0)
  31.565 -				return true;
  31.566 -			if (_stricmp(p, ".gbc") == 0)
  31.567 -				return true;
  31.568 -			if (_stricmp(p, ".cgb") == 0)
  31.569 -				return true;
  31.570 -			if (_stricmp(p, ".sgb") == 0)
  31.571 -				return true;
  31.572 -		}
  31.573 -	}
  31.574 -
  31.575 -	return false;
  31.576 -}
  31.577 -
  31.578 -bool utilIsGBABios(const char *file)
  31.579 -{
  31.580 -	if (strlen(file) > 4)
  31.581 -	{
  31.582 -		const char *p = strrchr(file, '.');
  31.583 -
  31.584 -		if (p != NULL)
  31.585 -		{
  31.586 -			if (_stricmp(p, ".gba") == 0)
  31.587 -				return true;
  31.588 -			if (_stricmp(p, ".agb") == 0)
  31.589 -				return true;
  31.590 -			if (_stricmp(p, ".bin") == 0)
  31.591 -				return true;
  31.592 -			if (_stricmp(p, ".bios") == 0)
  31.593 -				return true;
  31.594 -			if (_stricmp(p, ".rom") == 0)
  31.595 -				return true;
  31.596 -		}
  31.597 -	}
  31.598 -
  31.599 -	return false;
  31.600 -}
  31.601 -
  31.602 -bool utilIsGBBios(const char *file)
  31.603 -{
  31.604 -	if (strlen(file) > 4)
  31.605 -	{
  31.606 -		const char *p = strrchr(file, '.');
  31.607 -
  31.608 -		if (p != NULL)
  31.609 -		{
  31.610 -			if (_stricmp(p, ".gb") == 0)
  31.611 -				return true;
  31.612 -			if (_stricmp(p, ".bin") == 0)
  31.613 -				return true;
  31.614 -			if (_stricmp(p, ".bios") == 0)
  31.615 -				return true;
  31.616 -			if (_stricmp(p, ".rom") == 0)
  31.617 -				return true;
  31.618 -		}
  31.619 -	}
  31.620 -
  31.621 -	return false;
  31.622 -}
  31.623 -
  31.624 -bool utilIsELF(const char *file)
  31.625 -{
  31.626 -	if (strlen(file) > 4)
  31.627 -	{
  31.628 -		const char *p = strrchr(file, '.');
  31.629 -
  31.630 -		if (p != NULL)
  31.631 -		{
  31.632 -			if (_stricmp(p, ".elf") == 0)
  31.633 -				return true;
  31.634 -		}
  31.635 -	}
  31.636 -	return false;
  31.637 -}
  31.638 -
  31.639 -bool utilIsZipFile(const char *file)
  31.640 -{
  31.641 -	if (strlen(file) > 4)
  31.642 -	{
  31.643 -		const char *p = strrchr(file, '.');
  31.644 -
  31.645 -		if (p != NULL)
  31.646 -		{
  31.647 -			if (_stricmp(p, ".zip") == 0)
  31.648 -				return true;
  31.649 -		}
  31.650 -	}
  31.651 -
  31.652 -	return false;
  31.653 -}
  31.654 -
  31.655 -#if 0
  31.656 -bool utilIsRarFile(const char *file)
  31.657 -{
  31.658 -	if (strlen(file) > 4)
  31.659 -	{
  31.660 -		char *p = strrchr(file, '.');
  31.661 -
  31.662 -		if (p != NULL)
  31.663 -		{
  31.664 -			if (_stricmp(p, ".rar") == 0)
  31.665 -				return true;
  31.666 -		}
  31.667 -	}
  31.668 -
  31.669 -	return false;
  31.670 -}
  31.671 -
  31.672 -#endif
  31.673 -
  31.674 -bool utilIsGzipFile(const char *file)
  31.675 -{
  31.676 -	if (strlen(file) > 3)
  31.677 -	{
  31.678 -		const char *p = strrchr(file, '.');
  31.679 -
  31.680 -		if (p != NULL)
  31.681 -		{
  31.682 -			if (_stricmp(p, ".gz") == 0)
  31.683 -				return true;
  31.684 -			if (_stricmp(p, ".z") == 0)
  31.685 -				return true;
  31.686 -		}
  31.687 -	}
  31.688 -
  31.689 -	return false;
  31.690 -}
  31.691 -
  31.692 -void utilGetBaseName(const char *file, char *buffer)
  31.693 -{
  31.694 -	strcpy(buffer, file);
  31.695 -
  31.696 -	if (utilIsGzipFile(file))
  31.697 -	{
  31.698 -		char *p = strrchr(buffer, '.');
  31.699 -
  31.700 -		if (p)
  31.701 -			*p = 0;
  31.702 -	}
  31.703 -}
  31.704 -
  31.705 -IMAGE_TYPE utilFindType(const char *file)
  31.706 -{
  31.707 -	char buffer[2048];
  31.708 -
  31.709 -	if (utilIsZipFile(file))
  31.710 -	{
  31.711 -		unzFile unz = unzOpen(file);
  31.712 -
  31.713 -		if (unz == NULL)
  31.714 -		{
  31.715 -			systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), file);
  31.716 -			return IMAGE_UNKNOWN;
  31.717 -		}
  31.718 -
  31.719 -		int r = unzGoToFirstFile(unz);
  31.720 -
  31.721 -		if (r != UNZ_OK)
  31.722 -		{
  31.723 -			unzClose(unz);
  31.724 -			systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file);
  31.725 -			return IMAGE_UNKNOWN;
  31.726 -		}
  31.727 -
  31.728 -		IMAGE_TYPE found = IMAGE_UNKNOWN;
  31.729 -
  31.730 -		unz_file_info info;
  31.731 -
  31.732 -		while (true)
  31.733 -		{
  31.734 -			r = unzGetCurrentFileInfo(unz,
  31.735 -			                          &info,
  31.736 -			                          buffer,
  31.737 -			                          sizeof(buffer),
  31.738 -			                          NULL,
  31.739 -			                          0,
  31.740 -			                          NULL,
  31.741 -			                          0);
  31.742 -
  31.743 -			if (r != UNZ_OK)
  31.744 -			{
  31.745 -				unzClose(unz);
  31.746 -				systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file);
  31.747 -				return IMAGE_UNKNOWN;
  31.748 -			}
  31.749 -
  31.750 -			if (utilIsGBAImage(buffer))
  31.751 -			{
  31.752 -				found = IMAGE_GBA;
  31.753 -				break;
  31.754 -			}
  31.755 -
  31.756 -			if (utilIsGBImage(buffer))
  31.757 -			{
  31.758 -				found = IMAGE_GB;
  31.759 -				break;
  31.760 -			}
  31.761 -
  31.762 -			r = unzGoToNextFile(unz);
  31.763 -
  31.764 -			if (r != UNZ_OK)
  31.765 -				break;
  31.766 -		}
  31.767 -		unzClose(unz);
  31.768 -
  31.769 -		if (found == IMAGE_UNKNOWN)
  31.770 -		{
  31.771 -			systemMessage(MSG_NO_IMAGE_ON_ZIP,
  31.772 -			              N_("No image found on ZIP file %s"), file);
  31.773 -			return found;
  31.774 -		}
  31.775 -		return found;
  31.776 -#if 0
  31.777 -	}
  31.778 -	else if (utilIsRarFile(file))
  31.779 -	{
  31.780 -		IMAGE_TYPE found = IMAGE_UNKNOWN;
  31.781 -
  31.782 -		ArchiveList_struct *rarList = NULL;
  31.783 -		if (urarlib_list((void *)file, (ArchiveList_struct *)&rarList))
  31.784 -		{
  31.785 -			ArchiveList_struct *p = rarList;
  31.786 -
  31.787 -			while (p)
  31.788 -			{
  31.789 -				if (utilIsGBAImage(p->item.Name))
  31.790 -				{
  31.791 -					found = IMAGE_GBA;
  31.792 -					break;
  31.793 -				}
  31.794 -
  31.795 -				if (utilIsGBImage(p->item.Name))
  31.796 -				{
  31.797 -					found = IMAGE_GB;
  31.798 -					break;
  31.799 -				}
  31.800 -				p = p->next;
  31.801 -			}
  31.802 -
  31.803 -			urarlib_freelist(rarList);
  31.804 -		}
  31.805 -		return found;
  31.806 -#endif
  31.807 -	}
  31.808 -	else
  31.809 -	{
  31.810 -		if (utilIsGzipFile(file))
  31.811 -			utilGetBaseName(file, buffer);
  31.812 -		else
  31.813 -			strcpy(buffer, file);
  31.814 -
  31.815 -		if (utilIsGBAImage(buffer))
  31.816 -			return IMAGE_GBA;
  31.817 -		if (utilIsGBImage(buffer))
  31.818 -			return IMAGE_GB;
  31.819 -	}
  31.820 -	return IMAGE_UNKNOWN;
  31.821 -}
  31.822 -
  31.823 -static int utilGetSize(int size)
  31.824 -{
  31.825 -	int res = 1;
  31.826 -	while (res < size)
  31.827 -		res <<= 1;
  31.828 -	return res;
  31.829 -}
  31.830 -
  31.831 -static u8 *utilLoadFromZip(const char *file,
  31.832 -                           bool (*accept)(const char *),
  31.833 -                           u8 *data,
  31.834 -                           int &size)
  31.835 -{
  31.836 -	char buffer[2048];
  31.837 -
  31.838 -	unzFile unz = unzOpen(file);
  31.839 -
  31.840 -	if (unz == NULL)
  31.841 -	{
  31.842 -		systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), file);
  31.843 -		return NULL;
  31.844 -	}
  31.845 -	int r = unzGoToFirstFile(unz);
  31.846 -
  31.847 -	if (r != UNZ_OK)
  31.848 -	{
  31.849 -		unzClose(unz);
  31.850 -		systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file);
  31.851 -		return NULL;
  31.852 -	}
  31.853 -
  31.854 -	bool found = false;
  31.855 -
  31.856 -	unz_file_info info;
  31.857 -
  31.858 -	while (true)
  31.859 -	{
  31.860 -		r = unzGetCurrentFileInfo(unz,
  31.861 -		                          &info,
  31.862 -		                          buffer,
  31.863 -		                          sizeof(buffer),
  31.864 -		                          NULL,
  31.865 -		                          0,
  31.866 -		                          NULL,
  31.867 -		                          0);
  31.868 -
  31.869 -		if (r != UNZ_OK)
  31.870 -		{
  31.871 -			unzClose(unz);
  31.872 -			systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file);
  31.873 -			return NULL;
  31.874 -		}
  31.875 -
  31.876 -		if (accept(buffer))
  31.877 -		{
  31.878 -			found = true;
  31.879 -			break;
  31.880 -		}
  31.881 -
  31.882 -		r = unzGoToNextFile(unz);
  31.883 -
  31.884 -		if (r != UNZ_OK)
  31.885 -			break;
  31.886 -	}
  31.887 -
  31.888 -	if (!found)
  31.889 -	{
  31.890 -		unzClose(unz);
  31.891 -		systemMessage(MSG_NO_IMAGE_ON_ZIP,
  31.892 -		              N_("No image found on ZIP file %s"), file);
  31.893 -		return NULL;
  31.894 -	}
  31.895 -
  31.896 -	int fileSize = info.uncompressed_size;
  31.897 -	if (size == 0)
  31.898 -		size = fileSize;
  31.899 -	r = unzOpenCurrentFile(unz);
  31.900 -
  31.901 -	if (r != UNZ_OK)
  31.902 -	{
  31.903 -		unzClose(unz);
  31.904 -		systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), buffer);
  31.905 -		return NULL;
  31.906 -	}
  31.907 -
  31.908 -	u8 *image = data;
  31.909 -
  31.910 -	if (image == NULL)
  31.911 -	{
  31.912 -		image = (u8 *)malloc(utilGetSize(size));
  31.913 -		if (image == NULL)
  31.914 -		{
  31.915 -			unzCloseCurrentFile(unz);
  31.916 -			unzClose(unz);
  31.917 -			systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
  31.918 -			              "data");
  31.919 -			return NULL;
  31.920 -		}
  31.921 -		size = fileSize;
  31.922 -	}
  31.923 -	int read = fileSize <= size ? fileSize : size;
  31.924 -	r = unzReadCurrentFile(unz,
  31.925 -	                       image,
  31.926 -	                       read);
  31.927 -
  31.928 -	unzCloseCurrentFile(unz);
  31.929 -	unzClose(unz);
  31.930 -
  31.931 -	if (r != (int)read)
  31.932 -	{
  31.933 -		systemMessage(MSG_ERROR_READING_IMAGE,
  31.934 -		              N_("Error reading image %s"), buffer);
  31.935 -		if (data == NULL)
  31.936 -			free(image);
  31.937 -		return NULL;
  31.938 -	}
  31.939 -
  31.940 -	size = fileSize;
  31.941 -
  31.942 -	return image;
  31.943 -}
  31.944 -
  31.945 -static u8 *utilLoadGzipFile(const char *file,
  31.946 -                            bool (*accept)(const char *),
  31.947 -                            u8 *data,
  31.948 -                            int &size)
  31.949 -{
  31.950 -	FILE *f = fopen(file, "rb");
  31.951 -
  31.952 -	if (f == NULL)
  31.953 -	{
  31.954 -		systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file);
  31.955 -		return NULL;
  31.956 -	}
  31.957 -
  31.958 -	fseek(f, -4, SEEK_END);
  31.959 -	int fileSize = fgetc(f) | (fgetc(f) << 8) | (fgetc(f) << 16) | (fgetc(f) << 24);
  31.960 -	fclose(f);
  31.961 -	if (size == 0)
  31.962 -		size = fileSize;
  31.963 -
  31.964 -	gzFile gz = gzopen(file, "rb");
  31.965 -
  31.966 -	if (gz == NULL)
  31.967 -	{
  31.968 -		// should not happen, but who knows?
  31.969 -		systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file);
  31.970 -		return NULL;
  31.971 -	}
  31.972 -
  31.973 -	u8 *image = data;
  31.974 -
  31.975 -	if (image == NULL)
  31.976 -	{
  31.977 -		image = (u8 *)malloc(utilGetSize(size));
  31.978 -		if (image == NULL)
  31.979 -		{
  31.980 -			systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
  31.981 -			              "data");
  31.982 -			fclose(f);
  31.983 -			return NULL;
  31.984 -		}
  31.985 -		size = fileSize;
  31.986 -	}
  31.987 -	int read = fileSize <= size ? fileSize : size;
  31.988 -	int r	 = gzread(gz, image, read);
  31.989 -	gzclose(gz);
  31.990 -
  31.991 -	if (r != (int)read)
  31.992 -	{
  31.993 -		systemMessage(MSG_ERROR_READING_IMAGE,
  31.994 -		              N_("Error reading image %s"), file);
  31.995 -		if (data == NULL)
  31.996 -			free(image);
  31.997 -		return NULL;
  31.998 -	}
  31.999 -
 31.1000 -	size = fileSize;
 31.1001 -
 31.1002 -	return image;
 31.1003 -}
 31.1004 -
 31.1005 -#if 0
 31.1006 -static u8 *utilLoadRarFile(const char *file,
 31.1007 -                           bool (*accept)(const char *),
 31.1008 -                           u8 *data,
 31.1009 -                           int &size)
 31.1010 -{
 31.1011 -	char buffer[2048];
 31.1012 -
 31.1013 -	ArchiveList_struct *rarList = NULL;
 31.1014 -	if (urarlib_list((void *)file, (ArchiveList_struct *)&rarList))
 31.1015 -	{
 31.1016 -		ArchiveList_struct *p = rarList;
 31.1017 -
 31.1018 -		bool found = false;
 31.1019 -		while (p)
 31.1020 -		{
 31.1021 -			if (accept(p->item.Name))
 31.1022 -			{
 31.1023 -				strcpy(buffer, p->item.Name);
 31.1024 -				found = true;
 31.1025 -				break;
 31.1026 -			}
 31.1027 -			p = p->next;
 31.1028 -		}
 31.1029 -		if (found)
 31.1030 -		{
 31.1031 -			void *memory		= NULL;
 31.1032 -			unsigned long lsize = 0;
 31.1033 -			size = p->item.UnpSize;
 31.1034 -			int r = urarlib_get((void *)&memory, &lsize, buffer, (void *)file, "");
 31.1035 -			if (!r)
 31.1036 -			{
 31.1037 -				systemMessage(MSG_ERROR_READING_IMAGE,
 31.1038 -				              N_("Error reading image %s"), buffer);
 31.1039 -				urarlib_freelist(rarList);
 31.1040 -				return NULL;
 31.1041 -			}
 31.1042 -			u8 *image = (u8 *)memory;
 31.1043 -			if (data != NULL)
 31.1044 -			{
 31.1045 -				memcpy(image, data, size);
 31.1046 -			}
 31.1047 -			urarlib_freelist(rarList);
 31.1048 -			return image;
 31.1049 -		}
 31.1050 -		systemMessage(MSG_NO_IMAGE_ON_ZIP,
 31.1051 -		              N_("No image found on RAR file %s"), file);
 31.1052 -		urarlib_freelist(rarList);
 31.1053 -		return NULL;
 31.1054 -	}
 31.1055 -	// nothing found
 31.1056 -	return NULL;
 31.1057 -}
 31.1058 -
 31.1059 -#endif
 31.1060 -
 31.1061 -// the caller is responsible for caling free(return value) to release the memory
 31.1062 -u8 *utilLoad(const char *file,
 31.1063 -             bool (*accept)(const char *),
 31.1064 -             u8 *data,
 31.1065 -             int &size)
 31.1066 -{
 31.1067 -	if (utilIsZipFile(file))
 31.1068 -	{
 31.1069 -		return utilLoadFromZip(file, accept, data, size);
 31.1070 -	}
 31.1071 -	if (utilIsGzipFile(file))
 31.1072 -	{
 31.1073 -		return utilLoadGzipFile(file, accept, data, size);
 31.1074 -	}
 31.1075 -#if 0
 31.1076 -	if (utilIsRarFile(file))
 31.1077 -	{
 31.1078 -		return utilLoadRarFile(file, accept, data, size);
 31.1079 -	}
 31.1080 -#endif
 31.1081 -
 31.1082 -	u8 *image = data;
 31.1083 -
 31.1084 -	FILE *f = fopen(file, "rb");
 31.1085 -
 31.1086 -	if (!f)
 31.1087 -	{
 31.1088 -		systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file);
 31.1089 -		return NULL;
 31.1090 -	}
 31.1091 -
 31.1092 -	fseek(f, 0, SEEK_END);
 31.1093 -	int fileSize = ftell(f);
 31.1094 -	fseek(f, 0, SEEK_SET);
 31.1095 -	if (size == 0)
 31.1096 -		size = fileSize;
 31.1097 -
 31.1098 -	if (image == NULL)
 31.1099 -	{
 31.1100 -		image = (u8 *)malloc(utilGetSize(size));
 31.1101 -		if (image == NULL)
 31.1102 -		{
 31.1103 -			systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
 31.1104 -			              "data");
 31.1105 -			fclose(f);
 31.1106 -			return NULL;
 31.1107 -		}
 31.1108 -		size = fileSize;
 31.1109 -	}
 31.1110 -	int read = fileSize <= size ? fileSize : size;
 31.1111 -	int r	 = fread(image, 1, read, f);
 31.1112 -	fclose(f);
 31.1113 -
 31.1114 -	if (r != (int)read)
 31.1115 -	{
 31.1116 -		systemMessage(MSG_ERROR_READING_IMAGE,
 31.1117 -		              N_("Error reading image %s"), file);
 31.1118 -		if (data == NULL)
 31.1119 -			free(image);
 31.1120 -		return NULL;
 31.1121 -	}
 31.1122 -
 31.1123 -	size = fileSize;
 31.1124 -
 31.1125 -	return image;
 31.1126 -}
 31.1127 -
 31.1128 -void utilWriteInt(gzFile gzFile, int32 i)
 31.1129 -{
 31.1130 -	utilGzWrite(gzFile, &i, sizeof(int32));
 31.1131 -}
 31.1132 -
 31.1133 -int32 utilReadInt(gzFile gzFile)
 31.1134 -{
 31.1135 -	int32 i = 0;
 31.1136 -	utilGzRead(gzFile, &i, sizeof(int32));
 31.1137 -	return i;
 31.1138 -}
 31.1139 -
 31.1140 -void utilReadData(gzFile gzFile, variable_desc *data)
 31.1141 -{
 31.1142 -	while (data->address)
 31.1143 -	{
 31.1144 -		utilGzRead(gzFile, data->address, data->size);
 31.1145 -		data++;
 31.1146 -	}
 31.1147 -}
 31.1148 -
 31.1149 -void utilWriteData(gzFile gzFile, variable_desc *data)
 31.1150 -{
 31.1151 -	while (data->address)
 31.1152 -	{
 31.1153 -		utilGzWrite(gzFile, data->address, data->size);
 31.1154 -		data++;
 31.1155 -	}
 31.1156 -}
 31.1157 -
 31.1158 -gzFile utilGzOpen(const char *file, const char *mode)
 31.1159 -{
 31.1160 -	utilGzWriteFunc = gzWrite;
 31.1161 -	utilGzReadFunc	= gzread;
 31.1162 -	utilGzCloseFunc = gzclose;
 31.1163 -	utilGzSeekFunc	= gzseek;
 31.1164 -	utilGzTellFunc	= gztell;
 31.1165 -
 31.1166 -	return gzopen(file, mode);
 31.1167 -}
 31.1168 -
 31.1169 -gzFile utilGzReopen(int id, const char *mode)
 31.1170 -{
 31.1171 -	utilGzWriteFunc = gzWrite;
 31.1172 -	utilGzReadFunc	= gzread;
 31.1173 -	utilGzCloseFunc = gzclose;
 31.1174 -	utilGzSeekFunc	= gzseek;
 31.1175 -	utilGzTellFunc	= gztell;
 31.1176 -
 31.1177 -	return gzdopen(id, mode);
 31.1178 -}
 31.1179 -
 31.1180 -gzFile utilMemGzOpen(char *memory, int available, char *mode)
 31.1181 -{
 31.1182 -	utilGzWriteFunc = memgzwrite;
 31.1183 -	utilGzReadFunc	= memgzread;
 31.1184 -	utilGzCloseFunc = memgzclose;
 31.1185 -	utilGzSeekFunc	= NULL;	// FIXME: not implemented...
 31.1186 -	utilGzTellFunc	= memtell;
 31.1187 -
 31.1188 -	return memgzopen(memory, available, mode);
 31.1189 -}
 31.1190 -
 31.1191 -int utilGzWrite(gzFile file, voidp buffer, unsigned int len)
 31.1192 -{
 31.1193 -	return utilGzWriteFunc(file, buffer, len);
 31.1194 -}
 31.1195 -
 31.1196 -int utilGzRead(gzFile file, voidp buffer, unsigned int len)
 31.1197 -{
 31.1198 -	return utilGzReadFunc(file, buffer, len);
 31.1199 -}
 31.1200 -
 31.1201 -int utilGzClose(gzFile file)
 31.1202 -{
 31.1203 -	return utilGzCloseFunc(file);
 31.1204 -}
 31.1205 -
 31.1206 -z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence)
 31.1207 -{
 31.1208 -	return utilGzSeekFunc(file, offset, whence);
 31.1209 -}
 31.1210 -
 31.1211 -z_off_t utilGzTell(gzFile file)
 31.1212 -{
 31.1213 -	return utilGzTellFunc(file);
 31.1214 -}
 31.1215 -
 31.1216 -void utilGBAFindSave(const u8 *data, const int size)
 31.1217 -{
 31.1218 -	u32 *p		   = (u32 *)data;
 31.1219 -	u32 *end	   = (u32 *)(data + size);
 31.1220 -	int	 saveType  = 0;
 31.1221 -	int	 flashSize = 0x10000;
 31.1222 -	bool rtcFound  = false;
 31.1223 -
 31.1224 -	while (p  < end)
 31.1225 -	{
 31.1226 -		u32 d = READ32LE(p);
 31.1227 -
 31.1228 -		if (d == 0x52504545)
 31.1229 -		{
 31.1230 -			if (memcmp(p, "EEPROM_", 7) == 0)
 31.1231 -			{
 31.1232 -				if (saveType == 0)
 31.1233 -					saveType = 1;
 31.1234 -			}
 31.1235 -		}
 31.1236 -		else if (d == 0x4D415253)
 31.1237 -		{
 31.1238 -			if (memcmp(p, "SRAM_", 5) == 0)
 31.1239 -			{
 31.1240 -				if (saveType == 0)
 31.1241 -					saveType = 2;
 31.1242 -			}
 31.1243 -		}
 31.1244 -		else if (d == 0x53414C46)
 31.1245 -		{
 31.1246 -			if (memcmp(p, "FLASH1M_", 8) == 0)
 31.1247 -			{
 31.1248 -				if (saveType == 0)
 31.1249 -				{
 31.1250 -					saveType  = 3;
 31.1251 -					flashSize = 0x20000;
 31.1252 -				}
 31.1253 -			}
 31.1254 -			else if (memcmp(p, "FLASH", 5) == 0)
 31.1255 -			{
 31.1256 -				if (saveType == 0)
 31.1257 -				{
 31.1258 -					saveType  = 3;
 31.1259 -					flashSize = 0x10000;
 31.1260 -				}
 31.1261 -			}
 31.1262 -		}
 31.1263 -		else if (d == 0x52494953)
 31.1264 -		{
 31.1265 -			if (memcmp(p, "SIIRTC_V", 8) == 0)
 31.1266 -				rtcFound = true;
 31.1267 -		}
 31.1268 -		p++;
 31.1269 -	}
 31.1270 -	// if no matches found, then set it to NONE
 31.1271 -	if (saveType == 0)
 31.1272 -	{
 31.1273 -		saveType = 5;
 31.1274 -	}
 31.1275 -	rtcEnable(rtcFound);
 31.1276 -	cpuSaveType = saveType;
 31.1277 -	flashSetSize(flashSize);
 31.1278 -}
 31.1279 -
 31.1280 -void utilUpdateSystemColorMaps()
 31.1281 -{
 31.1282 -	switch (systemColorDepth)
 31.1283 -	{
 31.1284 -	case 16:
 31.1285 -	{
 31.1286 -		for (int i = 0; i < 0x10000; i++)
 31.1287 -		{
 31.1288 -			systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
 31.1289 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 31.1290 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 31.1291 -		}
 31.1292 -		break;
 31.1293 -	}
 31.1294 -	case 24:
 31.1295 -	case 32:
 31.1296 -	{
 31.1297 -		for (int i = 0; i < 0x10000; i++)
 31.1298 -		{
 31.1299 -			systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 31.1300 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 31.1301 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 31.1302 -		}
 31.1303 -		break;
 31.1304 -	}
 31.1305 -	}
 31.1306 -}
 31.1307 -
 31.1308 -//// BIOS stuff
 31.1309 -// systemType uses the same enum values as gbEmulatorType does
 31.1310 -
 31.1311 -bool utilLoadBIOS(u8 *bios, const char *biosFileName, int systemType)
 31.1312 -{
 31.1313 -	if (bios == NULL || strlen(biosFileName) == 0)
 31.1314 -		return false;
 31.1315 -
 31.1316 -	if (systemType == 4)
 31.1317 -	{
 31.1318 -		int biosSize = 0x4000;
 31.1319 -		if (utilLoad(biosFileName, utilIsGBABios, bios, biosSize))
 31.1320 -		{
 31.1321 -			if (biosSize == 0x4000)
 31.1322 -				return true;
 31.1323 -		}
 31.1324 -	}
 31.1325 -	else
 31.1326 -	{
 31.1327 -		int biosSize = 0x100;
 31.1328 -		if (utilLoad(biosFileName, utilIsGBBios, bios, biosSize))
 31.1329 -		{
 31.1330 -			if (biosSize == 0x100)
 31.1331 -				return true;
 31.1332 -		}
 31.1333 -	}
 31.1334 -
 31.1335 -	return false;
 31.1336 -}
 31.1337 -
 31.1338 -bool utilCheckBIOS(const char *biosFileName, int systemType)
 31.1339 -{
 31.1340 -	if (strlen(biosFileName) == 0)
 31.1341 -		return false;
 31.1342 -
 31.1343 -	u8 * tempBIOS = (u8 *)malloc(systemType == 4 ? 0x4000 : 0x100);
 31.1344 -	bool result	  = utilLoadBIOS(tempBIOS, biosFileName, systemType);
 31.1345 -	free(tempBIOS);
 31.1346 -
 31.1347 -	return result;
 31.1348 -}
 31.1349 -
 31.1350 -#if 0
 31.1351 -// returns the checksum of the BIOS that will be loaded after the next restart
 31.1352 -u16 utilCalcBIOSChecksum(const u8 *bios, int systemType)
 31.1353 -{
 31.1354 -	u32	biosChecksum = 0;
 31.1355 -	if (bios)
 31.1356 -	{
 31.1357 -		int biosSize	= (systemType == 4 ? 0x4000 : 0x100);
 31.1358 -		const u16 *data = reinterpret_cast<const u16 *>(bios);
 31.1359 -		for (int i = biosSize; i > 0; i -= 2)
 31.1360 -			biosChecksum += *data++;
 31.1361 -	}
 31.1362 -
 31.1363 -	while ((biosChecksum >> 16) & 0xFFFF)
 31.1364 -		biosChecksum = (biosChecksum &0xFFFF) + ((biosChecksum >> 16) & 0xFFFF);
 31.1365 -
 31.1366 -	return biosChecksum & 0xFFFF;
 31.1367 -}
 31.1368 -#else
 31.1369 -// returns the checksum of the BIOS that will be loaded after the next restart
 31.1370 -u16 utilCalcBIOSChecksum(const u8 *bios, int systemType)
 31.1371 -{
 31.1372 -	u32	biosChecksum = 0;
 31.1373 -	if (bios)
 31.1374 -	{
 31.1375 -		int biosSize	= (systemType == 4 ? 0x4000 : 0x100);
 31.1376 -		const u32 *data = reinterpret_cast<const u32 *>(bios);
 31.1377 -		for (int i = biosSize; i > 0; i -= 4)
 31.1378 -			biosChecksum += *data++;
 31.1379 -	}
 31.1380 -
 31.1381 -	return biosChecksum & 0xFFFF;
 31.1382 -}
 31.1383 -#endif
 31.1384 -
 31.1385 -// returns the checksum of the BIOS file
 31.1386 -u16 utilCalcBIOSFileChecksum(const char *biosFileName, int systemType)
 31.1387 -{
 31.1388 -	if (strlen(biosFileName) == 0)
 31.1389 -		return 0;
 31.1390 -
 31.1391 -	u16		  biosChecksum = 0;
 31.1392 -	const int biosSize	   = (systemType == 4 ? 0x4000 : 0x100);
 31.1393 -	u8 *	  tempBIOS	   = (u8 *)malloc(biosSize);
 31.1394 -	bool	  hasBIOS	   = utilLoadBIOS(tempBIOS, biosFileName, systemType);
 31.1395 -	if (hasBIOS)
 31.1396 -	{
 31.1397 -		biosChecksum = utilCalcBIOSChecksum(tempBIOS, systemType);
 31.1398 -	}
 31.1399 -	free(tempBIOS);
 31.1400 -
 31.1401 -	return biosChecksum;
 31.1402 -}
 31.1403 -
    32.1 --- a/src/common/Util.h	Sat Mar 03 10:54:39 2012 -0600
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,64 +0,0 @@
    32.4 -#ifndef VBA_UTIL_H
    32.5 -#define VBA_UTIL_H
    32.6 -
    32.7 -#if _MSC_VER > 1000
    32.8 -#pragma once
    32.9 -#endif // _MSC_VER > 1000
   32.10 -
   32.11 -#include "zlib.h"
   32.12 -#include "../Port.h"
   32.13 -
   32.14 -enum IMAGE_TYPE
   32.15 -{
   32.16 -	IMAGE_UNKNOWN = -1,
   32.17 -	IMAGE_GBA	  = 0,
   32.18 -	IMAGE_GB	  = 1
   32.19 -};
   32.20 -
   32.21 -// save game
   32.22 -
   32.23 -typedef struct
   32.24 -{
   32.25 -	void *address;
   32.26 -	int	  size;
   32.27 -} variable_desc;
   32.28 -
   32.29 -extern void utilWriteBMP(u8 *out, int w, int h, int dstDepth, u8 *in);
   32.30 -extern bool utilWriteBMPFile(const char *, int, int, u8 *);
   32.31 -extern bool utilWritePNGFile(const char *, int, int, u8 *);
   32.32 -extern void utilApplyIPS(const char *ips, u8 * *rom, int *size);
   32.33 -extern bool utilIsGBAImage(const char *);
   32.34 -extern bool utilIsGBABios(const char *file);
   32.35 -extern bool utilIsELF(const char *file);
   32.36 -extern bool utilIsGBImage(const char *);
   32.37 -extern bool utilIsGBBios(const char *file);
   32.38 -extern bool utilIsZipFile(const char *);
   32.39 -extern bool utilIsGzipFile(const char *);
   32.40 -extern bool utilIsRarFile(const char *);
   32.41 -extern void utilGetBaseName(const char *, char *);
   32.42 -extern IMAGE_TYPE utilFindType(const char *);
   32.43 -extern u8 *	 utilLoad(const char *, bool (*)(const char *), u8 *, int &);
   32.44 -extern void	 utilPutDword(u8 *, u32);
   32.45 -extern void	 utilPutWord(u8 *, u16);
   32.46 -extern void	 utilWriteData(gzFile, variable_desc *);
   32.47 -extern void	 utilReadData(gzFile, variable_desc *);
   32.48 -extern int32 utilReadInt(gzFile);
   32.49 -extern void	 utilWriteInt(gzFile, int32);
   32.50 -extern gzFile utilGzOpen(const char *file, const char *mode);
   32.51 -extern gzFile utilGzReopen(int id, const char *mode);
   32.52 -extern gzFile utilMemGzOpen(char *memory, int available, char *mode);
   32.53 -extern int utilGzWrite(gzFile file, voidp buffer, unsigned int len);
   32.54 -extern int utilGzRead(gzFile file, voidp buffer, unsigned int len);
   32.55 -extern int utilGzClose(gzFile file);
   32.56 -extern z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence);
   32.57 -extern z_off_t utilGzTell(gzFile file);
   32.58 -extern void utilGBAFindSave(const u8 *, const int);
   32.59 -extern void utilUpdateSystemColorMaps();
   32.60 -extern bool utilLoadBIOS(u8 *bios, const char *biosFileName, int systemType);
   32.61 -extern bool utilCheckBIOS(const char *biosFileName, int systemType);
   32.62 -extern u16 utilCalcBIOSChecksum(const u8 *bios, int systemType);
   32.63 -extern u16 utilCalcBIOSFileChecksum(const char *biosFileName, int systemType);
   32.64 -
   32.65 -extern int gzWrite(gzFile file, void* buf, unsigned len);
   32.66 -
   32.67 -#endif // VBA_UTIL_H
    33.1 --- a/src/common/inputGlobal.h	Sat Mar 03 10:54:39 2012 -0600
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,48 +0,0 @@
    33.4 -#ifndef VBA_INPUT_GLOBAL_H
    33.5 -#define VBA_INPUT_GLOBAL_H
    33.6 -
    33.7 -#if _MSC_VER > 1000
    33.8 -#pragma once
    33.9 -#endif // _MSC_VER > 1000
   33.10 -
   33.11 -enum
   33.12 -{
   33.13 -	KEY_BUTTON_A, KEY_BUTTON_B,
   33.14 -	KEY_BUTTON_SELECT, KEY_BUTTON_START,
   33.15 -	KEY_RIGHT, KEY_LEFT,
   33.16 -	KEY_UP, KEY_DOWN,
   33.17 -	KEY_BUTTON_R, KEY_BUTTON_L,
   33.18 -	KEY_BUTTON_SPEED, KEY_BUTTON_CAPTURE,
   33.19 -	KEY_BUTTON_GS
   33.20 -};
   33.21 -
   33.22 -#define BUTTON_MASK_A                    (0x0001)
   33.23 -#define BUTTON_MASK_B                    (0x0002)
   33.24 -#define BUTTON_MASK_SELECT               (0x0004)
   33.25 -#define BUTTON_MASK_START                (0x0008)
   33.26 -#define BUTTON_MASK_RIGHT                (0x0010)
   33.27 -#define BUTTON_MASK_LEFT                 (0x0020)
   33.28 -#define BUTTON_MASK_UP                   (0x0040)
   33.29 -#define BUTTON_MASK_DOWN                 (0x0080)
   33.30 -#define BUTTON_MASK_R                    (0x0100)
   33.31 -#define BUTTON_MASK_L                    (0x0200)
   33.32 -#define BUTTON_GB_MASK                   (BUTTON_MASK_A|BUTTON_MASK_B|BUTTON_MASK_SELECT|BUTTON_MASK_START| \
   33.33 -                                          BUTTON_MASK_RIGHT|BUTTON_MASK_LEFT|BUTTON_MASK_UP|BUTTON_MASK_DOWN)
   33.34 -#define BUTTON_GBA_ONLY                  (BUTTON_MASK_R|BUTTON_MASK_L)
   33.35 -#define BUTTON_REGULAR_MASK              (BUTTON_GB_MASK|BUTTON_GBA_ONLY)
   33.36 -#define BUTTON_MASK_OLD_RESET            (0x0400)
   33.37 -#define BUTTON_MASK_NEW_RESET            (0x0800)
   33.38 -#define BUTTON_MASK_LEFT_MOTION          (0x1000)
   33.39 -#define BUTTON_MASK_RIGHT_MOTION         (0x2000)
   33.40 -#define BUTTON_MASK_DOWN_MOTION          (0x4000)
   33.41 -#define BUTTON_MASK_UP_MOTION            (0x8000)
   33.42 -#define BUTTON_MOTION_MASK               (BUTTON_MASK_LEFT_MOTION|BUTTON_MASK_RIGHT_MOTION|BUTTON_MASK_DOWN_MOTION| \
   33.43 -                                          BUTTON_MASK_UP_MOTION)
   33.44 -#define BUTTON_RECORDINGONLY_MASK        (BUTTON_MASK_OLD_RESET|BUTTON_MASK_NEW_RESET|BUTTON_MOTION_MASK)
   33.45 -#define BUTTON_REGULAR_RECORDING_MASK	 (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK)
   33.46 -#define BUTTON_MASK_SPEED                (0x040000)
   33.47 -#define BUTTON_MASK_CAPTURE              (0x080000)
   33.48 -#define BUTTON_MASK_GAMESHARK            (0x100000)
   33.49 -#define BUTTON_NONRECORDINGONLY_MASK     (BUTTON_MASK_SPEED|BUTTON_MASK_CAPTURE|BUTTON_MASK_GAMESHARK)
   33.50 -
   33.51 -#endif // VBA_INPUT_GLOBAL_H
    34.1 --- a/src/common/lua-engine.cpp	Sat Mar 03 10:54:39 2012 -0600
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,5102 +0,0 @@
    34.4 -#include <cstdio>
    34.5 -#include <cstdlib>
    34.6 -#include <malloc.h>
    34.7 -#include <string>
    34.8 -#include <cassert>
    34.9 -#include <cctype>
   34.10 -#include <cmath>
   34.11 -#include <ctime>
   34.12 -
   34.13 -#include <vector>
   34.14 -#include <map>
   34.15 -#include <string>
   34.16 -#include <algorithm>
   34.17 -
   34.18 -using namespace std;
   34.19 -
   34.20 -#ifdef __linux
   34.21 -	#include <unistd.h> // for unlink
   34.22 -	#include <sys/types.h>
   34.23 -	#include <sys/wait.h>
   34.24 -#endif
   34.25 -#if (defined(WIN32) && !defined(SDL))
   34.26 -	#include <direct.h>
   34.27 -	#include "../win32/stdafx.h"
   34.28 -	#include "../win32/Input.h"
   34.29 -	#include "../win32/MainWnd.h"
   34.30 -	#include "../win32/VBA.h"
   34.31 -	#include "../win32/LuaOpenDialog.h"
   34.32 -#else
   34.33 -	#define stricmp strcasecmp
   34.34 -	#define strnicmp strncasecmp
   34.35 -#endif
   34.36 -
   34.37 -#include "../Port.h"
   34.38 -#include "System.h"
   34.39 -#include "movie.h"
   34.40 -#include "../gba/GBA.h"
   34.41 -#include "../gba/GBAGlobals.h"
   34.42 -#include "../gb/GB.h"
   34.43 -#include "../gb/gbGlobals.h"
   34.44 -#include "../gba/GBASound.h"
   34.45 -
   34.46 -#ifdef _WIN32
   34.47 -#include "../win32/Sound.h"
   34.48 -//#include "../win32/WinMiscUtil.h"
   34.49 -extern CString winGetSavestateFilename(const CString &LogicalRomName, int nID);
   34.50 -#else
   34.51 -#endif
   34.52 -
   34.53 -extern "C"
   34.54 -{
   34.55 -#include "../lua/src/lua.h"
   34.56 -#include "../lua/src/lauxlib.h"
   34.57 -#include "../lua/src/lualib.h"
   34.58 -#include "../lua/src/lstate.h"
   34.59 -}
   34.60 -#include "vbalua.h"
   34.61 -
   34.62 -#include "../SFMT/SFMT.c"
   34.63 -
   34.64 -static void (*info_print)(int uid, const char *str);
   34.65 -static void (*info_onstart)(int uid);
   34.66 -static void (*info_onstop)(int uid);
   34.67 -static int	info_uid;
   34.68 -
   34.69 -#ifndef countof
   34.70 -	#define countof(a)  (sizeof(a) / sizeof(a[0]))
   34.71 -#endif
   34.72 -
   34.73 -static lua_State *LUA;
   34.74 -
   34.75 -// Are we running any code right now?
   34.76 -static char *luaScriptName = NULL;
   34.77 -
   34.78 -// Are we running any code right now?
   34.79 -static bool8 luaRunning = false;
   34.80 -
   34.81 -// True at the frame boundary, false otherwise.
   34.82 -static bool8 frameBoundary = false;
   34.83 -
   34.84 -// The execution speed we're running at.
   34.85 -static enum { SPEED_NORMAL, SPEED_NOTHROTTLE, SPEED_TURBO, SPEED_MAXIMUM } speedmode = SPEED_NORMAL;
   34.86 -
   34.87 -// Rerecord count skip mode
   34.88 -static bool8 skipRerecords = false;
   34.89 -
   34.90 -// Used by the registry to find our functions
   34.91 -static const char *frameAdvanceThread = "VBA.FrameAdvance";
   34.92 -static const char *guiCallbackTable	  = "VBA.GUI";
   34.93 -
   34.94 -// True if there's a thread waiting to run after a run of frame-advance.
   34.95 -static bool8 frameAdvanceWaiting = false;
   34.96 -
   34.97 -// We save our pause status in the case of a natural death.
   34.98 -//static bool8 wasPaused = false;
   34.99 -
  34.100 -// Transparency strength. 255=opaque, 0=so transparent it's invisible
  34.101 -static int transparencyModifier = 255;
  34.102 -
  34.103 -// Our joypads.
  34.104 -static uint32 lua_joypads[4];
  34.105 -static uint8  lua_joypads_used = 0;
  34.106 -
  34.107 -static bool8  gui_used = false;
  34.108 -static uint8 *gui_data = NULL;          // BGRA
  34.109 -
  34.110 -// Protects Lua calls from going nuts.
  34.111 -// We set this to a big number like 1000 and decrement it
  34.112 -// over time. The script gets knifed once this reaches zero.
  34.113 -static int numTries;
  34.114 -
  34.115 -// number of registered memory functions (1 per hooked byte)
  34.116 -static unsigned int numMemHooks;
  34.117 -
  34.118 -// Look in inputglobal.h for macros named like BUTTON_MASK_UP to determine the order.
  34.119 -static const char *button_mappings[] = {
  34.120 -	"A", "B", "select", "start", "right", "left", "up", "down", "R", "L"
  34.121 -};
  34.122 -
  34.123 -#ifdef _MSC_VER
  34.124 -	#define snprintf _snprintf
  34.125 -	#define vscprintf _vscprintf
  34.126 -#else
  34.127 -	#define stricmp strcasecmp
  34.128 -	#define strnicmp strncasecmp
  34.129 -	#define __forceinline __attribute__((always_inline))
  34.130 -#endif
  34.131 -
  34.132 -static const char *luaCallIDStrings[] =
  34.133 -{
  34.134 -	"CALL_BEFOREEMULATION",
  34.135 -	"CALL_AFTEREMULATION",
  34.136 -	"CALL_BEFOREEXIT"
  34.137 -};
  34.138 -
  34.139 -//make sure we have the right number of strings
  34.140 -CTASSERT(sizeof(luaCallIDStrings) / sizeof(*luaCallIDStrings) == LUACALL_COUNT)
  34.141 -
  34.142 -static const char *luaMemHookTypeStrings [] =
  34.143 -{
  34.144 -	"MEMHOOK_WRITE",
  34.145 -	"MEMHOOK_READ",
  34.146 -	"MEMHOOK_EXEC",
  34.147 -
  34.148 -	"MEMHOOK_WRITE_SUB",
  34.149 -	"MEMHOOK_READ_SUB",
  34.150 -	"MEMHOOK_EXEC_SUB",
  34.151 -};
  34.152 -
  34.153 -//make sure we have the right number of strings
  34.154 -CTASSERT(sizeof(luaMemHookTypeStrings) / sizeof(*luaMemHookTypeStrings) ==  LUAMEMHOOK_COUNT)
  34.155 -
  34.156 -static char *rawToCString(lua_State * L, int idx = 0);
  34.157 -static const char *toCString(lua_State *L, int idx = 0);
  34.158 -
  34.159 -// GBA memory I/O functions copied from win32/MemoryViewerDlg.cpp
  34.160 -static inline u8 CPUReadByteQuick(u32 addr)
  34.161 -{
  34.162 -	return ::map[addr >> 24].address[addr & ::map[addr >> 24].mask];
  34.163 -}
  34.164 -
  34.165 -static inline void CPUWriteByteQuick(u32 addr, u8 b)
  34.166 -{
  34.167 -	::map[addr >> 24].address[addr & ::map[addr >> 24].mask] = b;
  34.168 -}
  34.169 -
  34.170 -static inline u16 CPUReadHalfWordQuick(u32 addr)
  34.171 -{
  34.172 -	return *((u16 *) &::map[addr >> 24].address[addr & ::map[addr >> 24].mask]);
  34.173 -}
  34.174 -
  34.175 -static inline void CPUWriteHalfWordQuick(u32 addr, u16 b)
  34.176 -{
  34.177 -	*((u16 *) &::map[addr >> 24].address[addr & ::map[addr >> 24].mask]) = b;
  34.178 -}
  34.179 -
  34.180 -static inline u32 CPUReadMemoryQuick(u32 addr)
  34.181 -{
  34.182 -	return *((u32 *) &::map[addr >> 24].address[addr & ::map[addr >> 24].mask]);
  34.183 -}
  34.184 -
  34.185 -static inline void CPUWriteMemoryQuick(u32 addr, u32 b)
  34.186 -{
  34.187 -	*((u32 *) &::map[addr >> 24].address[addr & ::map[addr >> 24].mask]) = b;
  34.188 -}
  34.189 -
  34.190 -// GB
  34.191 -static inline u8 gbReadMemoryQuick8(u16 addr)
  34.192 -{
  34.193 -	return gbReadMemoryQuick(addr);
  34.194 -}
  34.195 -
  34.196 -static inline void gbWriteMemoryQuick8(u16 addr, u8 b)
  34.197 -{
  34.198 -	gbWriteMemoryQuick(addr, b);
  34.199 -}
  34.200 -
  34.201 -static inline u16 gbReadMemoryQuick16(u16 addr)
  34.202 -{
  34.203 -	return (gbReadMemoryQuick(addr + 1) << 8) | gbReadMemoryQuick(addr);
  34.204 -}
  34.205 -
  34.206 -static inline void gbWriteMemoryQuick16(u16 addr, u16 b)
  34.207 -{
  34.208 -	gbWriteMemoryQuick(addr, b & 0xff);
  34.209 -	gbWriteMemoryQuick(addr + 1, (b >> 8) & 0xff);
  34.210 -}
  34.211 -
  34.212 -static inline u32 gbReadMemoryQuick32(u16 addr)
  34.213 -{
  34.214 -	return (gbReadMemoryQuick(addr + 3) << 24) |
  34.215 -	       (gbReadMemoryQuick(addr + 2) << 16) |
  34.216 -	       (gbReadMemoryQuick(addr + 1) << 8) |
  34.217 -	       gbReadMemoryQuick(addr);
  34.218 -}
  34.219 -
  34.220 -static inline void gbWriteMemoryQuick32(u16 addr, u32 b)
  34.221 -{
  34.222 -	gbWriteMemoryQuick(addr, b & 0xff);
  34.223 -	gbWriteMemoryQuick(addr + 1, (b >> 8) & 0xff);
  34.224 -	gbWriteMemoryQuick(addr + 2, (b >> 16) & 0xff);
  34.225 -	gbWriteMemoryQuick(addr + 1, (b >> 24) & 0xff);
  34.226 -}
  34.227 -
  34.228 -static inline u8 gbReadROMQuick8(u32 addr)
  34.229 -{
  34.230 -	return gbReadROMQuick(addr & gbRomSizeMask);
  34.231 -}
  34.232 -
  34.233 -static inline u8 gbReadROMQuick16(u32 addr)
  34.234 -{
  34.235 -	return (gbReadROMQuick(addr+1 & gbRomSizeMask) << 8) | gbReadROMQuick(addr & gbRomSizeMask);
  34.236 -}
  34.237 -
  34.238 -static inline u8 gbReadROMQuick32(u32 addr)
  34.239 -{
  34.240 -	return (gbReadROMQuick(addr+3 & gbRomSizeMask) << 24) |
  34.241 -	       (gbReadROMQuick(addr+2 & gbRomSizeMask) << 16) |
  34.242 -	       (gbReadROMQuick(addr+1 & gbRomSizeMask) << 8) |
  34.243 -	       gbReadROMQuick(addr & gbRomSizeMask);
  34.244 -}
  34.245 -
  34.246 -typedef void (*GetColorFunc)(const uint8 *, uint8 *, uint8 *, uint8 *);
  34.247 -typedef void (*SetColorFunc)(uint8 *, uint8, uint8, uint8);
  34.248 -
  34.249 -static void getColor16(const uint8 *s, uint8 *r, uint8 *g, uint8 *b)
  34.250 -{
  34.251 -	u16 v = *(const uint16 *)s;
  34.252 -	*r = ((v >> systemBlueShift) & 0x001f) << 3;
  34.253 -	*g = ((v >> systemGreenShift) & 0x001f) << 3;
  34.254 -	*b = ((v >> systemRedShift) & 0x001f) << 3;
  34.255 -}
  34.256 -
  34.257 -static void getColor24(const uint8 *s, uint8 *r, uint8 *g, uint8 *b)
  34.258 -{
  34.259 -	if (systemRedShift > systemBlueShift)
  34.260 -		*b = s[0], *g = s[1], *r = s[2];
  34.261 -	else
  34.262 -		*r = s[0], *g = s[1], *b = s[2];
  34.263 -}
  34.264 -
  34.265 -static void getColor32(const uint8 *s, uint8 *r, uint8 *g, uint8 *b)
  34.266 -{
  34.267 -	u32 v = *(const uint32 *)s;
  34.268 -	*b = ((v >> systemBlueShift) & 0x001f) << 3;
  34.269 -	*g = ((v >> systemGreenShift) & 0x001f) << 3;
  34.270 -	*r = ((v >> systemRedShift) & 0x001f) << 3;
  34.271 -}
  34.272 -
  34.273 -static void setColor16(uint8 *s, uint8 r, uint8 g, uint8 b)
  34.274 -{
  34.275 -	*(uint16 *)s = ((b >> 3) & 0x01f) <<
  34.276 -	               systemBlueShift |
  34.277 -	               ((g >> 3) & 0x01f) <<
  34.278 -	               systemGreenShift |
  34.279 -	               ((r >> 3) & 0x01f) <<
  34.280 -	               systemRedShift;
  34.281 -}
  34.282 -
  34.283 -static void setColor24(uint8 *s, uint8 r, uint8 g, uint8 b)
  34.284 -{
  34.285 -	if (systemRedShift > systemBlueShift)
  34.286 -		s[0] = b, s[1] = g, s[2] = r;
  34.287 -	else
  34.288 -		s[0] = r, s[1] = g, s[2] = b;
  34.289 -}
  34.290 -
  34.291 -static void setColor32(uint8 *s, uint8 r, uint8 g, uint8 b)
  34.292 -{
  34.293 -	*(uint32 *)s = ((b >> 3) & 0x01f) <<
  34.294 -	               systemBlueShift |
  34.295 -	               ((g >> 3) & 0x01f) <<
  34.296 -	               systemGreenShift |
  34.297 -	               ((r >> 3) & 0x01f) <<
  34.298 -	               systemRedShift;
  34.299 -}
  34.300 -
  34.301 -static bool getColorIOFunc(int depth, GetColorFunc *getColor, SetColorFunc *setColor)
  34.302 -{
  34.303 -	switch (depth)
  34.304 -	{
  34.305 -	case 16:
  34.306 -		if (getColor)
  34.307 -			*getColor = getColor16;
  34.308 -		if (setColor)
  34.309 -			*setColor = setColor16;
  34.310 -		return true;
  34.311 -	case 24:
  34.312 -		if (getColor)
  34.313 -			*getColor = getColor24;
  34.314 -		if (setColor)
  34.315 -			*setColor = setColor24;
  34.316 -		return true;
  34.317 -	case 32:
  34.318 -		if (getColor)
  34.319 -			*getColor = getColor32;
  34.320 -		if (setColor)
  34.321 -			*setColor = setColor32;
  34.322 -		return true;
  34.323 -	default:
  34.324 -		return false;
  34.325 -	}
  34.326 -}
  34.327 -
  34.328 -/**
  34.329 - * Resets emulator speed / pause states after script exit.
  34.330 - */
  34.331 -static void VBALuaOnStop(void)
  34.332 -{
  34.333 -	luaRunning		 = false;
  34.334 -	lua_joypads_used = 0;
  34.335 -	gui_used		 = false;
  34.336 -	//if (wasPaused)
  34.337 -	//	systemSetPause(true);
  34.338 -}
  34.339 -
  34.340 -/**
  34.341 - * Asks Lua if it wants control of the emulator's speed.
  34.342 - * Returns 0 if no, 1 if yes. If yes, we also tamper with the
  34.343 - * IPPU's settings for speed ourselves, so the calling code
  34.344 - * need not do anything.
  34.345 - */
  34.346 -int VBALuaSpeed(void)
  34.347 -{
  34.348 -	if (!LUA || !luaRunning)
  34.349 -		return 0;
  34.350 -
  34.351 -	//printf("%d\n", speedmode);
  34.352 -	switch (speedmode)
  34.353 -	{
  34.354 -	/*
  34.355 -	   case SPEED_NORMAL:
  34.356 -	    return 0;
  34.357 -	   case SPEED_NOTHROTTLE:
  34.358 -	    IPPU.RenderThisFrame = true;
  34.359 -	    return 1;
  34.360 -
  34.361 -	   case SPEED_TURBO:
  34.362 -	    IPPU.SkippedFrames++;
  34.363 -	    if (IPPU.SkippedFrames >= 40) {
  34.364 -	        IPPU.SkippedFrames = 0;
  34.365 -	        IPPU.RenderThisFrame = true;
  34.366 -	    }
  34.367 -	    else
  34.368 -	        IPPU.RenderThisFrame = false;
  34.369 -	    return 1;
  34.370 -
  34.371 -	   // In mode 3, SkippedFrames is set to zero so that the frame
  34.372 -	   // skipping code doesn't try anything funny.
  34.373 -	   case SPEED_MAXIMUM:
  34.374 -	    IPPU.SkippedFrames=0;
  34.375 -	    IPPU.RenderThisFrame = false;
  34.376 -	    return 1;
  34.377 -	 */
  34.378 -	case 0: // FIXME: to get rid of the warning
  34.379 -	default:
  34.380 -		assert(false);
  34.381 -		return 0;
  34.382 -	}
  34.383 -}
  34.384 -
  34.385 -///////////////////////////
  34.386 -// vba.speedmode(string mode)
  34.387 -//
  34.388 -//   Takes control of the emulation speed
  34.389 -//   of the system. Normal is normal speed (60fps, 50 for PAL),
  34.390 -//   nothrottle disables speed control but renders every frame,
  34.391 -//   turbo renders only a few frames in order to speed up emulation,
  34.392 -
  34.393 -//   maximum renders no frames
  34.394 -static int vba_speedmode(lua_State *L)
  34.395 -{
  34.396 -	const char *mode = luaL_checkstring(L, 1);
  34.397 -
  34.398 -	if (strcasecmp(mode, "normal") == 0)
  34.399 -	{
  34.400 -		speedmode = SPEED_NORMAL;
  34.401 -	}
  34.402 -	else if (strcasecmp(mode, "nothrottle") == 0)
  34.403 -	{
  34.404 -		speedmode = SPEED_NOTHROTTLE;
  34.405 -	}
  34.406 -	else if (strcasecmp(mode, "turbo") == 0)
  34.407 -	{
  34.408 -		speedmode = SPEED_TURBO;
  34.409 -	}
  34.410 -	else if (strcasecmp(mode, "maximum") == 0)
  34.411 -	{
  34.412 -		speedmode = SPEED_MAXIMUM;
  34.413 -	}
  34.414 -	else
  34.415 -		luaL_error(L, "Invalid mode %s to vba.speedmode", mode);
  34.416 -
  34.417 -	//printf("new speed mode:  %d\n", speedmode);
  34.418 -	return 0;
  34.419 -}
  34.420 -
  34.421 -// vba.frameadvnace()
  34.422 -//
  34.423 -//  Executes a frame advance. Occurs by yielding the coroutine, then re-running
  34.424 -
  34.425 -//  when we break out.
  34.426 -static int vba_frameadvance(lua_State *L)
  34.427 -{
  34.428 -	// We're going to sleep for a frame-advance. Take notes.
  34.429 -	if (frameAdvanceWaiting)
  34.430 -		return luaL_error(L, "can't call vba.frameadvance() from here");
  34.431 -
  34.432 -	frameAdvanceWaiting = true;
  34.433 -
  34.434 -	// Don't do this! The user won't like us sending their emulator out of control!
  34.435 -	//	Settings.FrameAdvance = true;
  34.436 -	// Now we can yield to the main
  34.437 -	return lua_yield(L, 0);
  34.438 -
  34.439 -	// It's actually rather disappointing...
  34.440 -}
  34.441 -
  34.442 -// vba.pause()
  34.443 -//
  34.444 -//  Pauses the emulator, function "waits" until the user unpauses.
  34.445 -//  This function MAY be called from a non-frame boundary, but the frame
  34.446 -
  34.447 -//  finishes executing anwyays. In this case, the function returns immediately.
  34.448 -static int vba_pause(lua_State *L)
  34.449 -{
  34.450 -	systemSetPause(true);
  34.451 -	speedmode = SPEED_NORMAL;
  34.452 -
  34.453 -	// Return control if we're midway through a frame. We can't pause here.
  34.454 -	if (frameAdvanceWaiting)
  34.455 -	{
  34.456 -		return 0;
  34.457 -	}
  34.458 -
  34.459 -	// If it's on a frame boundary, we also yield.
  34.460 -	frameAdvanceWaiting = true;
  34.461 -	return lua_yield(L, 0);
  34.462 -}
  34.463 -
  34.464 -static int vba_registerbefore(lua_State *L)
  34.465 -{
  34.466 -	if (!lua_isnil(L, 1))
  34.467 -		luaL_checktype(L, 1, LUA_TFUNCTION);
  34.468 -	lua_settop(L, 1);
  34.469 -	lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEMULATION]);
  34.470 -	lua_insert(L, 1);
  34.471 -	lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEMULATION]);
  34.472 -
  34.473 -	//StopScriptIfFinished(luaStateToUIDMap[L]);
  34.474 -	return 1;
  34.475 -}
  34.476 -
  34.477 -static int vba_registerafter(lua_State *L)
  34.478 -{
  34.479 -	if (!lua_isnil(L, 1))
  34.480 -		luaL_checktype(L, 1, LUA_TFUNCTION);
  34.481 -	lua_settop(L, 1);
  34.482 -	lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTEREMULATION]);
  34.483 -	lua_insert(L, 1);
  34.484 -	lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTEREMULATION]);
  34.485 -
  34.486 -	//StopScriptIfFinished(luaStateToUIDMap[L]);
  34.487 -	return 1;
  34.488 -}
  34.489 -
  34.490 -static int vba_registerexit(lua_State *L)
  34.491 -{
  34.492 -	if (!lua_isnil(L, 1))
  34.493 -		luaL_checktype(L, 1, LUA_TFUNCTION);
  34.494 -	lua_settop(L, 1);
  34.495 -	lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]);
  34.496 -	lua_insert(L, 1);
  34.497 -	lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]);
  34.498 -
  34.499 -	//StopScriptIfFinished(luaStateToUIDMap[L]);
  34.500 -	return 1;
  34.501 -}
  34.502 -
  34.503 -static inline bool isalphaorunderscore(char c)
  34.504 -{
  34.505 -	return isalpha(c) || c == '_';
  34.506 -}
  34.507 -
  34.508 -static std::vector<const void *> s_tableAddressStack; // prevents infinite recursion of a table within a table (when cycle is
  34.509 -                                                      // found, print something like table:parent)
  34.510 -static std::vector<const void *> s_metacallStack; // prevents infinite recursion if something's __tostring returns another table
  34.511 -                                                  // that contains that something (when cycle is found, print the inner result
  34.512 -                                                  // without using __tostring)
  34.513 -
  34.514 -#define APPENDPRINT { int _n = snprintf(ptr, remaining,
  34.515 -#define END ); if (_n >= 0) { ptr += _n; remaining -= _n; } else { remaining = 0; } }
  34.516 -static void toCStringConverter(lua_State *L, int i, char * &ptr, int &remaining)
  34.517 -{
  34.518 -    if (remaining <= 0)
  34.519 -		return;
  34.520 -
  34.521 -    const char *str = ptr; // for debugging
  34.522 -
  34.523 -    // if there is a __tostring metamethod then call it
  34.524 -    int usedMeta = luaL_callmeta(L, i, "__tostring");
  34.525 -    if (usedMeta)
  34.526 -    {
  34.527 -        std::vector<const void *>::const_iterator foundCycleIter = std::find(s_metacallStack.begin(), s_metacallStack.end(), lua_topointer(L, i));
  34.528 -        if (foundCycleIter != s_metacallStack.end())
  34.529 -        {
  34.530 -            lua_pop(L, 1);
  34.531 -            usedMeta = false;
  34.532 -		}
  34.533 -        else
  34.534 -        {
  34.535 -            s_metacallStack.push_back(lua_topointer(L, i));
  34.536 -            i = lua_gettop(L);
  34.537 -		}
  34.538 -	}
  34.539 -
  34.540 -    switch (lua_type(L, i))
  34.541 -    {
  34.542 -	case LUA_TNONE:
  34.543 -		break;
  34.544 -	case LUA_TNIL:
  34.545 -		APPENDPRINT "nil" END break;
  34.546 -	case LUA_TBOOLEAN:
  34.547 -		APPENDPRINT lua_toboolean(L, i) ? "true" : "false" END break;
  34.548 -	case LUA_TSTRING : APPENDPRINT "%s", lua_tostring(L, i) END break;
  34.549 -	case LUA_TNUMBER:
  34.550 -		APPENDPRINT "%.12Lg", lua_tonumber(L, i) END break;
  34.551 -	case LUA_TFUNCTION:
  34.552 -		if ((L->base + i - 1)->value.gc->cl.c.isC)
  34.553 -		{
  34.554 -		    //lua_CFunction func = lua_tocfunction(L, i);
  34.555 -		    //std::map<lua_CFunction, const char*>::iterator iter = s_cFuncInfoMap.find(func);
  34.556 -		    //if(iter == s_cFuncInfoMap.end())
  34.557 -		    goto defcase;
  34.558 -		    //APPENDPRINT "function(%s)", iter->second END
  34.559 -		}
  34.560 -		else
  34.561 -		{
  34.562 -		    APPENDPRINT "function(" END
  34.563 -		    Proto * p = (L->base + i - 1)->value.gc->cl.l.p;
  34.564 -		    int numParams = p->numparams + (p->is_vararg ? 1 : 0);
  34.565 -		    for (int n = 0; n < p->numparams; n++)
  34.566 -		    {
  34.567 -		        APPENDPRINT "%s", getstr(p->locvars[n].varname) END
  34.568 -		        if (n != numParams - 1)
  34.569 -					APPENDPRINT "," END
  34.570 -					}
  34.571 -					if (p->is_vararg)
  34.572 -						APPENDPRINT "..." END
  34.573 -						APPENDPRINT ")" END
  34.574 -						}
  34.575 -						break;
  34.576 -defcase: default:
  34.577 -				APPENDPRINT "%s:%p", luaL_typename(L, i), lua_topointer(L, i) END break;
  34.578 -			case LUA_TTABLE:
  34.579 -				{
  34.580 -				    // first make sure there's enough stack space
  34.581 -				    if (!lua_checkstack(L, 4))
  34.582 -				    {
  34.583 -				        // note that even if lua_checkstack never returns false,
  34.584 -				        // that doesn't mean we didn't need to call it,
  34.585 -				        // because calling it retrieves stack space past LUA_MINSTACK
  34.586 -				        goto defcase;
  34.587 -					}
  34.588 -
  34.589 -				    std::vector<const void *>::const_iterator foundCycleIter =
  34.590 -				        std::find(s_tableAddressStack.begin(), s_tableAddressStack.end(), lua_topointer(L, i));
  34.591 -				    if (foundCycleIter != s_tableAddressStack.end())
  34.592 -				    {
  34.593 -				        int parentNum = s_tableAddressStack.end() - foundCycleIter;
  34.594 -				        if (parentNum > 1)
  34.595 -							APPENDPRINT "%s:parent^%d", luaL_typename(L, i), parentNum END
  34.596 -							else
  34.597 -								APPENDPRINT "%s:parent", luaL_typename(L, i) END
  34.598 -								}
  34.599 -								else
  34.600 -								{
  34.601 -								    s_tableAddressStack.push_back(lua_topointer(L, i));
  34.602 -								    struct Scope { ~Scope(){ s_tableAddressStack. pop_back(); } } scope;
  34.603 -
  34.604 -								    APPENDPRINT "{" END
  34.605 -
  34.606 -								               lua_pushnil(L); // first key
  34.607 -								    int		   keyIndex = lua_gettop(L);
  34.608 -								    int		   valueIndex = keyIndex + 1;
  34.609 -								    bool	   first = true;
  34.610 -								    bool	   skipKey = true; // true if we're still in the "array part" of the table
  34.611 -								    lua_Number arrayIndex = (lua_Number)0;
  34.612 -								    while (lua_next(L, i))
  34.613 -								    {
  34.614 -								        if (first)
  34.615 -											first = false;
  34.616 -								        else
  34.617 -											APPENDPRINT ", " END
  34.618 -											if (skipKey)
  34.619 -											{
  34.620 -											    arrayIndex += (lua_Number)1;
  34.621 -											    bool keyIsNumber = (lua_type(L, keyIndex) == LUA_TNUMBER);
  34.622 -											    skipKey = keyIsNumber && (lua_tonumber(L, keyIndex) == arrayIndex);
  34.623 -											}
  34.624 -								        if (!skipKey)
  34.625 -								        {
  34.626 -								            bool keyIsString = (lua_type(L, keyIndex) == LUA_TSTRING);
  34.627 -								            bool invalidLuaIdentifier = (!keyIsString || !isalphaorunderscore(*lua_tostring(L, keyIndex)));
  34.628 -								            if (invalidLuaIdentifier)
  34.629 -												if (keyIsString)
  34.630 -													APPENDPRINT "['" END
  34.631 -													else
  34.632 -														APPENDPRINT "[" END
  34.633 -
  34.634 -														toCStringConverter(L, keyIndex, ptr, remaining);
  34.635 -								            // key
  34.636 -
  34.637 -								            if (invalidLuaIdentifier)
  34.638 -												if (keyIsString)
  34.639 -													APPENDPRINT "']=" END
  34.640 -													else
  34.641 -														APPENDPRINT "]=" END
  34.642 -														else
  34.643 -															APPENDPRINT "=" END
  34.644 -															}
  34.645 -
  34.646 -															bool valueIsString = (lua_type(L, valueIndex) == LUA_TSTRING);
  34.647 -								            if (valueIsString)
  34.648 -												APPENDPRINT "'" END
  34.649 -
  34.650 -												toCStringConverter(L, valueIndex, ptr, remaining);  // value
  34.651 -
  34.652 -								            if (valueIsString)
  34.653 -												APPENDPRINT "'" END
  34.654 -
  34.655 -												lua_pop(L, 1);
  34.656 -
  34.657 -								            if (remaining <= 0)
  34.658 -								            {
  34.659 -								                lua_settop(L, keyIndex - 1); // stack might not be clean yet if we're breaking
  34.660 -								                                             // early
  34.661 -								                break;
  34.662 -											}
  34.663 -										}
  34.664 -								        APPENDPRINT "}" END
  34.665 -									}
  34.666 -								}
  34.667 -				        break;
  34.668 -					}
  34.669 -
  34.670 -				    if (usedMeta)
  34.671 -				    {
  34.672 -				        s_metacallStack.pop_back();
  34.673 -				        lua_pop(L, 1);
  34.674 -					}
  34.675 -				}
  34.676 -
  34.677 -				static const int s_tempStrMaxLen = 64 * 1024;
  34.678 -				static char s_tempStr [s_tempStrMaxLen];
  34.679 -
  34.680 -				static char *rawToCString(lua_State *L, int idx)
  34.681 -				{
  34.682 -				    int a = idx > 0 ? idx : 1;
  34.683 -				    int n = idx > 0 ? idx : lua_gettop(L);
  34.684 -
  34.685 -				    char *ptr = s_tempStr;
  34.686 -				    *ptr = 0;
  34.687 -
  34.688 -				    int remaining = s_tempStrMaxLen;
  34.689 -				    for (int i = a; i <= n; i++)
  34.690 -				    {
  34.691 -				        toCStringConverter(L, i, ptr, remaining);
  34.692 -				        if (i != n)
  34.693 -							APPENDPRINT " " END
  34.694 -							}
  34.695 -
  34.696 -							if (remaining < 3)
  34.697 -							{
  34.698 -							    while (remaining < 6)
  34.699 -									remaining++, ptr--;
  34.700 -							    APPENDPRINT "..." END
  34.701 -							}
  34.702 -				        APPENDPRINT "\r\n" END
  34.703 -				        // the trailing newline is so print() can avoid having to do wasteful things to print its newline
  34.704 -				        // (string copying would be wasteful and calling info.print() twice can be extremely slow)
  34.705 -				        // at the cost of functions that don't want the newline needing to trim off the last two characters
  34.706 -				        // (which is a very fast operation and thus acceptable in this case)
  34.707 -
  34.708 -				        return s_tempStr;
  34.709 -					}
  34.710 -#undef APPENDPRINT
  34.711 -#undef END
  34.712 -
  34.713 -// replacement for luaB_tostring() that is able to show the contents of tables (and formats numbers better, and show function
  34.714 -// prototypes)
  34.715 -// can be called directly from lua via tostring(), assuming tostring hasn't been reassigned
  34.716 -				    static int tostring(lua_State *L)
  34.717 -				    {
  34.718 -				        char *str = rawToCString(L);
  34.719 -				        str[strlen(str) - 2] = 0; // hack: trim off the \r\n (which is there to simplify the print function's
  34.720 -				                                  // task)
  34.721 -				        lua_pushstring(L, str);
  34.722 -				        return 1;
  34.723 -					}
  34.724 -
  34.725 -// like rawToCString, but will check if the global Lua function tostring()
  34.726 -// has been replaced with a custom function, and call that instead if so
  34.727 -				    static const char *toCString(lua_State *L, int idx)
  34.728 -				    {
  34.729 -				        int a = idx > 0 ? idx : 1;
  34.730 -				        int n = idx > 0 ? idx : lua_gettop(L);
  34.731 -				        lua_getglobal(L, "tostring");
  34.732 -				        lua_CFunction cf = lua_tocfunction(L, -1);
  34.733 -				        if (cf == tostring || lua_isnil(L, -1)) // optimization: if using our own C tostring function, we can
  34.734 -				                                                // bypass the call through Lua and all the string object
  34.735 -				                                                // allocation that would entail
  34.736 -				        {
  34.737 -				            lua_pop(L, 1);
  34.738 -				            return rawToCString(L, idx);
  34.739 -						}
  34.740 -				        else // if the user overrided the tostring function, we have to actually call it and store the
  34.741 -				             // temporarily allocated string it returns
  34.742 -				        {
  34.743 -				            lua_pushstring(L, "");
  34.744 -				            for (int i = a; i <= n; i++)
  34.745 -				            {
  34.746 -				                lua_pushvalue(L, -2); // function to be called
  34.747 -				                lua_pushvalue(L, i); // value to print
  34.748 -				                lua_call(L, 1, 1);
  34.749 -				                if (lua_tostring(L, -1) == NULL)
  34.750 -									luaL_error(L, LUA_QL("tostring") " must return a string to " LUA_QL("print"));
  34.751 -				                lua_pushstring(L, (i < n) ? " " : "\r\n");
  34.752 -				                lua_concat(L, 3);
  34.753 -							}
  34.754 -				            const char *str = lua_tostring(L, -1);
  34.755 -				            strncpy(s_tempStr, str, s_tempStrMaxLen);
  34.756 -				            s_tempStr[s_tempStrMaxLen - 1] = 0;
  34.757 -				            lua_pop(L, 2);
  34.758 -				            return s_tempStr;
  34.759 -						}
  34.760 -					}
  34.761 -
  34.762 -// replacement for luaB_print() that goes to the appropriate textbox instead of stdout
  34.763 -				    static int print(lua_State *L)
  34.764 -				    {
  34.765 -				        const char *str = toCString(L);
  34.766 -
  34.767 -				        int uid = info_uid; //luaStateToUIDMap[L->l_G->mainthread];
  34.768 -				        //LuaContextInfo& info = GetCurrentInfo();
  34.769 -
  34.770 -				        if (info_print)
  34.771 -							info_print(uid, str);
  34.772 -				        else
  34.773 -							puts(str);
  34.774 -
  34.775 -				        //worry(L, 100);
  34.776 -				        return 0;
  34.777 -					}
  34.778 -
  34.779 -				    static int printerror(lua_State *L, int idx)
  34.780 -				    {
  34.781 -				        lua_checkstack(L, lua_gettop(L) + 4);
  34.782 -
  34.783 -				        if (idx < 0)
  34.784 -							idx = lua_gettop(L) + 1 + idx;
  34.785 -
  34.786 -				        const char *str = rawToCString(L, idx);
  34.787 -
  34.788 -				        int uid = info_uid; //luaStateToUIDMap[L->l_G->mainthread];
  34.789 -				        //LuaContextInfo& info = GetCurrentInfo();
  34.790 -
  34.791 -				        if (info_print)
  34.792 -							info_print(uid, str);
  34.793 -				        else
  34.794 -							fputs(str, stderr);
  34.795 -
  34.796 -				        //worry(L, 100);
  34.797 -				        return 0;
  34.798 -					}
  34.799 -
  34.800 -// vba.message(string msg)
  34.801 -//
  34.802 -//  Displays the given message on the screen.
  34.803 -				    static int vba_message(lua_State *L)
  34.804 -				    {
  34.805 -				        const char *msg = luaL_checkstring(L, 1);
  34.806 -				        systemScreenMessage(msg);
  34.807 -
  34.808 -				        return 0;
  34.809 -					}
  34.810 -
  34.811 -// provides an easy way to copy a table from Lua
  34.812 -// (simple assignment only makes an alias, but sometimes an independent table is desired)
  34.813 -// currently this function only performs a shallow copy,
  34.814 -// but I think it should be changed to do a deep copy (possibly of configurable depth?)
  34.815 -// that maintains the internal table reference structure
  34.816 -				    static int copytable(lua_State *L)
  34.817 -				    {
  34.818 -				        int origIndex = 1; // we only care about the first argument
  34.819 -				        int origType = lua_type(L, origIndex);
  34.820 -				        if (origType == LUA_TNIL)
  34.821 -				        {
  34.822 -				            lua_pushnil(L);
  34.823 -				            return 1;
  34.824 -						}
  34.825 -				        if (origType != LUA_TTABLE)
  34.826 -				        {
  34.827 -				            luaL_typerror(L, 1, lua_typename(L, LUA_TTABLE));
  34.828 -				            lua_pushnil(L);
  34.829 -				            return 1;
  34.830 -						}
  34.831 -
  34.832 -				        lua_createtable(L, lua_objlen(L, 1), 0);
  34.833 -				        int copyIndex = lua_gettop(L);
  34.834 -
  34.835 -				        lua_pushnil(L); // first key
  34.836 -				        int keyIndex = lua_gettop(L);
  34.837 -				        int valueIndex = keyIndex + 1;
  34.838 -
  34.839 -				        while (lua_next(L, origIndex))
  34.840 -				        {
  34.841 -				            lua_pushvalue(L, keyIndex);
  34.842 -				            lua_pushvalue(L, valueIndex);
  34.843 -				            lua_rawset(L, copyIndex); // copytable[key] = value
  34.844 -				            lua_pop(L, 1);
  34.845 -						}
  34.846 -
  34.847 -				        // copy the reference to the metatable as well, if any
  34.848 -				        if (lua_getmetatable(L, origIndex))
  34.849 -							lua_setmetatable(L, copyIndex);
  34.850 -
  34.851 -				        return 1; // return the new table
  34.852 -					}
  34.853 -
  34.854 -// because print traditionally shows the address of tables,
  34.855 -// and the print function I provide instead shows the contents of tables,
  34.856 -// I also provide this function
  34.857 -// (otherwise there would be no way to see a table's address, AFAICT)
  34.858 -				    static int addressof(lua_State *L)
  34.859 -				    {
  34.860 -				        const void *ptr = lua_topointer(L, -1);
  34.861 -				        lua_pushinteger(L, (lua_Integer)ptr);
  34.862 -				        return 1;
  34.863 -					}
  34.864 -
  34.865 -				    struct registerPointerMap
  34.866 -				    {
  34.867 -				        const char *  registerName;
  34.868 -				        unsigned int *pointer;
  34.869 -				        int dataSize;
  34.870 -					};
  34.871 -
  34.872 -#define RPM_ENTRY(name, var) \
  34.873 -	{ name, (unsigned int *)&var, sizeof(var) \
  34.874 -	} \
  34.875 -	,
  34.876 -
  34.877 -				    extern gbRegister AF;
  34.878 -				    extern gbRegister BC;
  34.879 -				    extern gbRegister DE;
  34.880 -				    extern gbRegister HL;
  34.881 -				    extern gbRegister SP;
  34.882 -				    extern gbRegister PC;
  34.883 -				    extern u16 IFF;
  34.884 -
  34.885 -				    registerPointerMap regPointerMap [] = {
  34.886 -				        // gba registers
  34.887 -				        RPM_ENTRY("r0",	  reg[0].I)
  34.888 -				        RPM_ENTRY("r1",	  reg[1].I)
  34.889 -				        RPM_ENTRY("r2",	  reg[2].I)
  34.890 -				        RPM_ENTRY("r3",	  reg[3].I)
  34.891 -				        RPM_ENTRY("r4",	  reg[4].I)
  34.892 -				        RPM_ENTRY("r5",	  reg[5].I)
  34.893 -				        RPM_ENTRY("r6",	  reg[6].I)
  34.894 -				        RPM_ENTRY("r7",	  reg[7].I)
  34.895 -				        RPM_ENTRY("r8",	  reg[8].I)
  34.896 -				        RPM_ENTRY("r9",	  reg[9].I)
  34.897 -				        RPM_ENTRY("r10",  reg[10].I)
  34.898 -				        RPM_ENTRY("r11",  reg[11].I)
  34.899 -				        RPM_ENTRY("r12",  reg[12].I)
  34.900 -				        RPM_ENTRY("r13",  reg[13].I)
  34.901 -				        RPM_ENTRY("r14",  reg[14].I)
  34.902 -				        RPM_ENTRY("r15",  reg[15].I)
  34.903 -				        RPM_ENTRY("cpsr", reg[16].I)
  34.904 -				        RPM_ENTRY("spsr", reg[17].I)
  34.905 -				        // gb registers
  34.906 -				        RPM_ENTRY("a",	  AF.B.B1)
  34.907 -				        RPM_ENTRY("f",	  AF.B.B0)
  34.908 -				        RPM_ENTRY("b",	  BC.B.B1)
  34.909 -				        RPM_ENTRY("c",	  BC.B.B0)
  34.910 -				        RPM_ENTRY("d",	  DE.B.B1)
  34.911 -				        RPM_ENTRY("e",	  DE.B.B0)
  34.912 -				        RPM_ENTRY("h",	  HL.B.B1)
  34.913 -				        RPM_ENTRY("l",	  HL.B.B0)
  34.914 -				        RPM_ENTRY("af",	  AF.W)
  34.915 -				        RPM_ENTRY("bc",	  BC.W)
  34.916 -				        RPM_ENTRY("de",	  DE.W)
  34.917 -				        RPM_ENTRY("hl",	  HL.W)
  34.918 -				        RPM_ENTRY("sp",	  SP.W)
  34.919 -				        RPM_ENTRY("pc",	  PC.W)
  34.920 -				        {}
  34.921 -					};
  34.922 -
  34.923 -				    struct cpuToRegisterMap
  34.924 -				    {
  34.925 -				        const char *cpuName;
  34.926 -				        registerPointerMap *rpmap;
  34.927 -					}
  34.928 -				    cpuToRegisterMaps [] =
  34.929 -				    {
  34.930 -				        { "", regPointerMap },
  34.931 -					};
  34.932 -
  34.933 -//DEFINE_LUA_FUNCTION(memory_getregister, "cpu_dot_registername_string")
  34.934 -				    static int memory_getregister(lua_State *L)
  34.935 -				    {
  34.936 -				        const char *qualifiedRegisterName = luaL_checkstring(L, 1);
  34.937 -				        lua_settop(L, 0);
  34.938 -				        for (int cpu = 0; cpu < sizeof(cpuToRegisterMaps) / sizeof(*cpuToRegisterMaps); cpu++)
  34.939 -				        {
  34.940 -				            cpuToRegisterMap ctrm = cpuToRegisterMaps[cpu];
  34.941 -				            int cpuNameLen		  = strlen(ctrm.cpuName);
  34.942 -				            if (!strnicmp(qualifiedRegisterName, ctrm.cpuName, cpuNameLen))
  34.943 -				            {
  34.944 -				                qualifiedRegisterName += cpuNameLen;
  34.945 -				                for (int reg = 0; ctrm.rpmap[reg].dataSize; reg++)
  34.946 -				                {
  34.947 -				                    registerPointerMap rpm = ctrm.rpmap[reg];
  34.948 -				                    if (!stricmp(qualifiedRegisterName, rpm.registerName))
  34.949 -				                    {
  34.950 -				                        switch (rpm.dataSize)
  34.951 -				                        {
  34.952 -										default:
  34.953 -										case 1:
  34.954 -											lua_pushinteger(L, *(unsigned char *)rpm.pointer); break;
  34.955 -										case 2:
  34.956 -											lua_pushinteger(L, *(unsigned short *)rpm.pointer); break;
  34.957 -										case 4:
  34.958 -											lua_pushinteger(L, *(unsigned long *)rpm.pointer); break;
  34.959 -										}
  34.960 -				                        return 1;
  34.961 -									}
  34.962 -								}
  34.963 -				                lua_pushnil(L);
  34.964 -				                return 1;
  34.965 -							}
  34.966 -						}
  34.967 -				        lua_pushnil(L);
  34.968 -				        return 1;
  34.969 -					}
  34.970 -
  34.971 -//DEFINE_LUA_FUNCTION(memory_setregister, "cpu_dot_registername_string,value")
  34.972 -				    static int memory_setregister(lua_State *L)
  34.973 -				    {
  34.974 -				        const char *  qualifiedRegisterName = luaL_checkstring(L, 1);
  34.975 -				        unsigned long value = (unsigned long)(luaL_checkinteger(L, 2));
  34.976 -				        lua_settop(L, 0);
  34.977 -				        for (int cpu = 0; cpu < sizeof(cpuToRegisterMaps) / sizeof(*cpuToRegisterMaps); cpu++)
  34.978 -				        {
  34.979 -				            cpuToRegisterMap ctrm = cpuToRegisterMaps[cpu];
  34.980 -				            int cpuNameLen		  = strlen(ctrm.cpuName);
  34.981 -				            if (!strnicmp(qualifiedRegisterName, ctrm.cpuName, cpuNameLen))
  34.982 -				            {
  34.983 -				                qualifiedRegisterName += cpuNameLen;
  34.984 -				                for (int reg = 0; ctrm.rpmap[reg].dataSize; reg++)
  34.985 -				                {
  34.986 -				                    registerPointerMap rpm = ctrm.rpmap[reg];
  34.987 -				                    if (!stricmp(qualifiedRegisterName, rpm.registerName))
  34.988 -				                    {
  34.989 -				                        switch (rpm.dataSize)
  34.990 -				                        {
  34.991 -										default:
  34.992 -										case 1:
  34.993 -											*(unsigned char *)rpm.pointer = (unsigned char)(value & 0xFF); break;
  34.994 -										case 2:
  34.995 -											*(unsigned short *)rpm.pointer = (unsigned short)(value & 0xFFFF); break;
  34.996 -										case 4:
  34.997 -											*(unsigned long *)rpm.pointer = value; break;
  34.998 -										}
  34.999 -				                        return 0;
 34.1000 -									}
 34.1001 -								}
 34.1002 -				                return 0;
 34.1003 -							}
 34.1004 -						}
 34.1005 -				        return 0;
 34.1006 -					}
 34.1007 -
 34.1008 -				    void HandleCallbackError(lua_State *L)
 34.1009 -				    {
 34.1010 -				        if (L->errfunc || L->errorJmp)
 34.1011 -							luaL_error(L, "%s", lua_tostring(L, -1));
 34.1012 -				        else
 34.1013 -				        {
 34.1014 -				            lua_pushnil(LUA);
 34.1015 -				            lua_setfield(LUA, LUA_REGISTRYINDEX, guiCallbackTable);
 34.1016 -
 34.1017 -				            // Error?
 34.1018 -//#if (defined(WIN32) && !defined(SDL))
 34.1019 -//		info_print(info_uid, lua_tostring(LUA, -1)); //Clear_Sound_Buffer();
 34.1020 -// AfxGetApp()->m_pMainWnd->MessageBox(lua_tostring(LUA, -1), "Lua run error", MB_OK | MB_ICONSTOP);
 34.1021 -//#else
 34.1022 -//		fprintf(stderr, "Lua thread bombed out: %s\n", lua_tostring(LUA, -1));
 34.1023 -//#endif
 34.1024 -				            printerror(LUA, -1);
 34.1025 -				            VBALuaStop();
 34.1026 -						}
 34.1027 -					}
 34.1028 -
 34.1029 -				    void CallRegisteredLuaFunctions(LuaCallID calltype)
 34.1030 -				    {
 34.1031 -				        assert((unsigned int)calltype < (unsigned int)LUACALL_COUNT);
 34.1032 -
 34.1033 -				        const char *idstring = luaCallIDStrings[calltype];
 34.1034 -
 34.1035 -				        if (!LUA)
 34.1036 -							return;
 34.1037 -
 34.1038 -				        lua_settop(LUA, 0);
 34.1039 -				        lua_getfield(LUA, LUA_REGISTRYINDEX, idstring);
 34.1040 -
 34.1041 -				        int errorcode = 0;
 34.1042 -				        if (lua_isfunction(LUA, -1))
 34.1043 -				        {
 34.1044 -				            errorcode = lua_pcall(LUA, 0, 0, 0);
 34.1045 -				            if (errorcode)
 34.1046 -								HandleCallbackError(LUA);
 34.1047 -						}
 34.1048 -				        else
 34.1049 -				        {
 34.1050 -				            lua_pop(LUA, 1);
 34.1051 -						}
 34.1052 -					}
 34.1053 -
 34.1054 -// the purpose of this structure is to provide a way of
 34.1055 -// QUICKLY determining whether a memory address range has a hook associated with it,
 34.1056 -// with a bias toward fast rejection because the majority of addresses will not be hooked.
 34.1057 -// (it must not use any part of Lua or perform any per-script operations,
 34.1058 -//  otherwise it would definitely be too slow.)
 34.1059 -// calculating the regions when a hook is added/removed may be slow,
 34.1060 -// but this is an intentional tradeoff to obtain a high speed of checking during later execution
 34.1061 -				    struct TieredRegion
 34.1062 -				    {
 34.1063 -				        template<unsigned int maxGap>
 34.1064 -				        struct Region
 34.1065 -				        {
 34.1066 -				            struct Island
 34.1067 -				            {
 34.1068 -				                unsigned int	   start;
 34.1069 -				                unsigned int	   end;
 34.1070 -				                __forceinline bool Contains(unsigned int address, int size) const { return address < end && address + size > start; }
 34.1071 -							};
 34.1072 -				            std::vector<Island> islands;
 34.1073 -
 34.1074 -				            void Calculate(const std::vector<unsigned int> &bytes)
 34.1075 -				            {
 34.1076 -				                islands. clear();
 34.1077 -
 34.1078 -				                unsigned int lastEnd = ~0;
 34.1079 -
 34.1080 -				                std::vector<unsigned int>::const_iterator iter = bytes.begin();
 34.1081 -				                std::vector<unsigned int>::const_iterator end  = bytes.end();
 34.1082 -				                for (; iter != end; ++iter)
 34.1083 -				                {
 34.1084 -				                    unsigned int addr = *iter;
 34.1085 -				                    if (addr < lastEnd || addr > lastEnd + (long long)maxGap)
 34.1086 -				                    {
 34.1087 -				                        islands. push_back(Island());
 34.1088 -				                        islands. back().start = addr;
 34.1089 -									}
 34.1090 -				                    islands.back(). end = addr + 1;
 34.1091 -				                    lastEnd = addr + 1;
 34.1092 -								}
 34.1093 -							}
 34.1094 -
 34.1095 -				            bool Contains(unsigned int address, int size) const
 34.1096 -				            {
 34.1097 -				                for (size_t i = 0; i != islands.size(); ++i)
 34.1098 -				                {
 34.1099 -				                    if (islands[i].Contains(address, size))
 34.1100 -										return true;
 34.1101 -								}
 34.1102 -				                return false;
 34.1103 -							}
 34.1104 -						};
 34.1105 -
 34.1106 -				        Region<0xFFFFFFFF> broad;
 34.1107 -				        Region<0x1000>	   mid;
 34.1108 -				        Region<0>		   narrow;
 34.1109 -
 34.1110 -				        void Calculate(std::vector<unsigned int> &bytes)
 34.1111 -				        {
 34.1112 -				            std:: sort(bytes.begin(), bytes.end());
 34.1113 -
 34.1114 -				            broad.	Calculate(bytes);
 34.1115 -				            mid.	Calculate(bytes);
 34.1116 -				            narrow. Calculate(bytes);
 34.1117 -						}
 34.1118 -
 34.1119 -				        TieredRegion()
 34.1120 -				        {
 34.1121 -				            std::vector <unsigned int> temp;
 34.1122 -				            Calculate(temp);
 34.1123 -						}
 34.1124 -
 34.1125 -				        __forceinline int NotEmpty()
 34.1126 -				        {
 34.1127 -				            return broad.islands.size();
 34.1128 -						}
 34.1129 -
 34.1130 -				        // note: it is illegal to call this if NotEmpty() returns 0
 34.1131 -				        __forceinline bool Contains(unsigned int address, int size)
 34.1132 -				        {
 34.1133 -				            return broad.islands[0].Contains(address, size) &&
 34.1134 -				                   mid.Contains(address, size) &&
 34.1135 -				                   narrow.Contains(address, size);
 34.1136 -						}
 34.1137 -					};
 34.1138 -				    TieredRegion hookedRegions [LUAMEMHOOK_COUNT];
 34.1139 -
 34.1140 -				    static void CalculateMemHookRegions(LuaMemHookType hookType)
 34.1141 -				    {
 34.1142 -				        std::vector<unsigned int> hookedBytes;
 34.1143 -//	std::map<int, LuaContextInfo*>::iterator iter = luaContextInfo.begin();
 34.1144 -//	std::map<int, LuaContextInfo*>::iterator end = luaContextInfo.end();
 34.1145 -//	while(iter != end)
 34.1146 -//	{
 34.1147 -//		LuaContextInfo& info = *iter->second;
 34.1148 -				        if (/*info.*/ numMemHooks)
 34.1149 -				        {
 34.1150 -				            lua_State *L = LUA /*info.L*/;
 34.1151 -				            if (L)
 34.1152 -				            {
 34.1153 -				                lua_settop(L, 0);
 34.1154 -				                lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]);
 34.1155 -				                lua_pushnil(L);
 34.1156 -				                while (lua_next(L, -2))
 34.1157 -				                {
 34.1158 -				                    if (lua_isfunction(L, -1))
 34.1159 -				                    {
 34.1160 -				                        unsigned int addr = lua_tointeger(L, -2);
 34.1161 -				                        hookedBytes.push_back(addr);
 34.1162 -									}
 34.1163 -				                    lua_pop(L, 1);
 34.1164 -								}
 34.1165 -				                lua_settop(L, 0);
 34.1166 -							}
 34.1167 -						}
 34.1168 -//		++iter;
 34.1169 -//	}
 34.1170 -				        hookedRegions[hookType].Calculate(hookedBytes);
 34.1171 -					}
 34.1172 -
 34.1173 -				    static void CallRegisteredLuaMemHook_LuaMatch(unsigned int address, int size, unsigned int value, LuaMemHookType hookType)
 34.1174 -				    {
 34.1175 -//	std::map<int, LuaContextInfo*>::iterator iter = luaContextInfo.begin();
 34.1176 -//	std::map<int, LuaContextInfo*>::iterator end = luaContextInfo.end();
 34.1177 -//	while(iter != end)
 34.1178 -//	{
 34.1179 -//		LuaContextInfo& info = *iter->second;
 34.1180 -				        if (/*info.*/ numMemHooks)
 34.1181 -				        {
 34.1182 -				            lua_State *L = LUA /*info.L*/;
 34.1183 -				            if (L /* && !info.panic*/)
 34.1184 -				            {
 34.1185 -#ifdef USE_INFO_STACK
 34.1186 -				                infoStack.insert(infoStack.begin(), &info);
 34.1187 -				                struct Scope { ~Scope(){ infoStack. erase(infoStack.begin()); } } scope;
 34.1188 -#endif
 34.1189 -				                lua_settop(L, 0);
 34.1190 -				                lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]);
 34.1191 -				                for (int i = address; i != address + size; i++)
 34.1192 -				                {
 34.1193 -				                    lua_rawgeti(L, -1, i);
 34.1194 -				                    if (lua_isfunction(L, -1))
 34.1195 -				                    {
 34.1196 -				                        bool wasRunning = (luaRunning != 0) /*info.running*/;
 34.1197 -				                        luaRunning /*info.running*/ = true;
 34.1198 -				                        //RefreshScriptSpeedStatus();
 34.1199 -				                        lua_pushinteger(L, address);
 34.1200 -				                        lua_pushinteger(L, size);
 34.1201 -				                        int errorcode = lua_pcall(L, 2, 0, 0);
 34.1202 -				                        luaRunning /*info.running*/ = wasRunning;
 34.1203 -				                        //RefreshScriptSpeedStatus();
 34.1204 -				                        if (errorcode)
 34.1205 -				                        {
 34.1206 -				                            HandleCallbackError(L);
 34.1207 -				                            //int uid = iter->first;
 34.1208 -				                            //HandleCallbackError(L,info,uid,true);
 34.1209 -										}
 34.1210 -				                        break;
 34.1211 -									}
 34.1212 -				                    else
 34.1213 -				                    {
 34.1214 -				                        lua_pop(L, 1);
 34.1215 -									}
 34.1216 -								}
 34.1217 -				                lua_settop(L, 0);
 34.1218 -							}
 34.1219 -						}
 34.1220 -//		++iter;
 34.1221 -//	}
 34.1222 -					}
 34.1223 -
 34.1224 -				    void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType)
 34.1225 -				    {
 34.1226 -				        // performance critical! (called VERY frequently)
 34.1227 -				        // I suggest timing a large number of calls to this function in Release if you change anything in here,
 34.1228 -				        // before and after, because even the most innocent change can make it become 30% to 400% slower.
 34.1229 -				        // a good amount to test is: 100000000 calls with no hook set, and another 100000000 with a hook set.
 34.1230 -				        // (on my system that consistently took 200 ms total in the former case and 350 ms total in the latter
 34.1231 -				        // case)
 34.1232 -				        if (hookedRegions[hookType].NotEmpty())
 34.1233 -				        {
 34.1234 -				            //if((hookType <= LUAMEMHOOK_EXEC) && (address >= 0xE00000))
 34.1235 -				            //	address |= 0xFF0000; // account for mirroring of RAM
 34.1236 -				            if (hookedRegions[hookType].Contains(address, size))
 34.1237 -								CallRegisteredLuaMemHook_LuaMatch(address, size, value, hookType);  // something has hooked this
 34.1238 -				                                                                                    // specific address
 34.1239 -						}
 34.1240 -					}
 34.1241 -
 34.1242 -				    static int memory_registerHook(lua_State *L, LuaMemHookType hookType, int defaultSize)
 34.1243 -				    {
 34.1244 -				        // get first argument: address
 34.1245 -				        unsigned int addr = luaL_checkinteger(L, 1);
 34.1246 -				        //if((addr & ~0xFFFFFF) == ~0xFFFFFF)
 34.1247 -				        //	addr &= 0xFFFFFF;
 34.1248 -
 34.1249 -				        // get optional second argument: size
 34.1250 -				        int size	= defaultSize;
 34.1251 -				        int funcIdx = 2;
 34.1252 -				        if (lua_isnumber(L, 2))
 34.1253 -				        {
 34.1254 -				            size = luaL_checkinteger(L, 2);
 34.1255 -				            if (size < 0)
 34.1256 -				            {
 34.1257 -				                size  = -size;
 34.1258 -				                addr -= size;
 34.1259 -							}
 34.1260 -				            funcIdx++;
 34.1261 -						}
 34.1262 -
 34.1263 -				        // check last argument: callback function
 34.1264 -				        bool clearing = lua_isnil(L, funcIdx);
 34.1265 -				        if (!clearing)
 34.1266 -							luaL_checktype(L, funcIdx, LUA_TFUNCTION);
 34.1267 -				        lua_settop(L, funcIdx);
 34.1268 -
 34.1269 -				        // get the address-to-callback table for this hook type of the current script
 34.1270 -				        lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]);
 34.1271 -
 34.1272 -				        // count how many callback functions we'll be displacing
 34.1273 -				        int numFuncsAfter  = clearing ? 0 : size;
 34.1274 -				        int numFuncsBefore = 0;
 34.1275 -				        for (unsigned int i = addr; i != addr + size; i++)
 34.1276 -				        {
 34.1277 -				            lua_rawgeti(L, -1, i);
 34.1278 -				            if (lua_isfunction(L, -1))
 34.1279 -								numFuncsBefore++;
 34.1280 -				            lua_pop(L, 1);
 34.1281 -						}
 34.1282 -
 34.1283 -				        // put the callback function in the address slots
 34.1284 -				        for (unsigned int i = addr; i != addr + size; i++)
 34.1285 -				        {
 34.1286 -				            lua_pushvalue(L, -2);
 34.1287 -				            lua_rawseti(L, -2, i);
 34.1288 -						}
 34.1289 -
 34.1290 -				        // adjust the count of active hooks
 34.1291 -				        //LuaContextInfo& info = GetCurrentInfo();
 34.1292 -				        /*info.*/ numMemHooks += numFuncsAfter - numFuncsBefore;
 34.1293 -
 34.1294 -				        // re-cache regions of hooked memory across all scripts
 34.1295 -				        CalculateMemHookRegions(hookType);
 34.1296 -
 34.1297 -				        //StopScriptIfFinished(luaStateToUIDMap[L]);
 34.1298 -				        return 0;
 34.1299 -					}
 34.1300 -
 34.1301 -				    LuaMemHookType MatchHookTypeToCPU(lua_State *L, LuaMemHookType hookType)
 34.1302 -				    {
 34.1303 -				        int cpuID = 0;
 34.1304 -
 34.1305 -				        int cpunameIndex = 0;
 34.1306 -				        if (lua_type(L, 2) == LUA_TSTRING)
 34.1307 -							cpunameIndex = 2;
 34.1308 -				        else if (lua_type(L, 3) == LUA_TSTRING)
 34.1309 -							cpunameIndex = 3;
 34.1310 -
 34.1311 -				        if (cpunameIndex)
 34.1312 -				        {
 34.1313 -				            const char *cpuName = lua_tostring(L, cpunameIndex);
 34.1314 -				            if (!stricmp(cpuName, "sub"))
 34.1315 -								cpuID = 1;
 34.1316 -				            lua_remove(L, cpunameIndex);
 34.1317 -						}
 34.1318 -
 34.1319 -				        switch (cpuID)
 34.1320 -				        {
 34.1321 -						case 0:
 34.1322 -							return hookType;
 34.1323 -
 34.1324 -						case 1:
 34.1325 -							switch (hookType)
 34.1326 -							{
 34.1327 -							case LUAMEMHOOK_WRITE:
 34.1328 -								return LUAMEMHOOK_WRITE_SUB;
 34.1329 -							case LUAMEMHOOK_READ:
 34.1330 -								return LUAMEMHOOK_READ_SUB;
 34.1331 -							case LUAMEMHOOK_EXEC:
 34.1332 -								return LUAMEMHOOK_EXEC_SUB;
 34.1333 -							}
 34.1334 -						}
 34.1335 -				        return hookType;
 34.1336 -					}
 34.1337 -
 34.1338 -				    static int memory_registerwrite(lua_State *L)
 34.1339 -				    {
 34.1340 -				        return memory_registerHook(L, MatchHookTypeToCPU(L, LUAMEMHOOK_WRITE), 1);
 34.1341 -					}
 34.1342 -
 34.1343 -				    static int memory_registerread(lua_State *L)
 34.1344 -				    {
 34.1345 -				        return memory_registerHook(L, MatchHookTypeToCPU(L, LUAMEMHOOK_READ), 1);
 34.1346 -					}
 34.1347 -
 34.1348 -				    static int memory_registerexec(lua_State *L)
 34.1349 -				    {
 34.1350 -				        return memory_registerHook(L, MatchHookTypeToCPU(L, LUAMEMHOOK_EXEC), 1);
 34.1351 -					}
 34.1352 -
 34.1353 -//int vba.lagcount
 34.1354 -//
 34.1355 -
 34.1356 -//Returns the lagcounter variable
 34.1357 -				    static int vba_getlagcount(lua_State *L)
 34.1358 -				    {
 34.1359 -				        lua_pushinteger(L, systemCounters.lagCount);
 34.1360 -				        return 1;
 34.1361 -					}
 34.1362 -
 34.1363 -//int vba.lagged
 34.1364 -//
 34.1365 -//Returns true if the current frame is a lag frame
 34.1366 -				    static int vba_lagged(lua_State *L)
 34.1367 -				    {
 34.1368 -				        lua_pushboolean(L, systemCounters.laggedLast);
 34.1369 -				        return 1;
 34.1370 -					}
 34.1371 -
 34.1372 -// boolean vba.emulating()
 34.1373 -				    int vba_emulating(lua_State *L)
 34.1374 -				    {
 34.1375 -				        lua_pushboolean(L, systemIsEmulating());
 34.1376 -				        return 1;
 34.1377 -					}
 34.1378 -
 34.1379 -				    int movie_isactive(lua_State *L)
 34.1380 -				    {
 34.1381 -				        lua_pushboolean(L, VBAMovieActive());
 34.1382 -				        return 1;
 34.1383 -					}
 34.1384 -
 34.1385 -				    int movie_isrecording(lua_State *L)
 34.1386 -				    {
 34.1387 -				        lua_pushboolean(L, VBAMovieRecording());
 34.1388 -				        return 1;
 34.1389 -					}
 34.1390 -
 34.1391 -				    int movie_isplaying(lua_State *L)
 34.1392 -				    {
 34.1393 -				        lua_pushboolean(L, VBAMoviePlaying());
 34.1394 -				        return 1;
 34.1395 -					}
 34.1396 -
 34.1397 -				    int movie_getlength(lua_State *L)
 34.1398 -				    {
 34.1399 -				        if (VBAMovieActive())
 34.1400 -							lua_pushinteger(L, VBAMovieGetLength());
 34.1401 -				        else
 34.1402 -							lua_pushinteger(L, 0);
 34.1403 -				        return 1;
 34.1404 -					}
 34.1405 -
 34.1406 -				    static int memory_readbyte(lua_State *L)
 34.1407 -				    {
 34.1408 -				        u32 addr;
 34.1409 -				        u8	val;
 34.1410 -
 34.1411 -				        addr = luaL_checkinteger(L, 1);
 34.1412 -				        if (systemIsRunningGBA())
 34.1413 -				        {
 34.1414 -				            val = CPUReadByteQuick(addr);
 34.1415 -						}
 34.1416 -				        else
 34.1417 -				        {
 34.1418 -				            val = gbReadMemoryQuick8(addr);
 34.1419 -						}
 34.1420 -
 34.1421 -				        lua_pushinteger(L, val);
 34.1422 -				        return 1;
 34.1423 -					}
 34.1424 -
 34.1425 -				    static int memory_readbytesigned(lua_State *L)
 34.1426 -				    {
 34.1427 -				        u32 addr;
 34.1428 -				        s8	val;
 34.1429 -
 34.1430 -				        addr = luaL_checkinteger(L, 1);
 34.1431 -				        if (systemIsRunningGBA())
 34.1432 -				        {
 34.1433 -				            val = (s8) CPUReadByteQuick(addr);
 34.1434 -						}
 34.1435 -				        else
 34.1436 -				        {
 34.1437 -				            val = (s8) gbReadMemoryQuick8(addr);
 34.1438 -						}
 34.1439 -
 34.1440 -				        lua_pushinteger(L, val);
 34.1441 -				        return 1;
 34.1442 -					}
 34.1443 -
 34.1444 -				    static int memory_readword(lua_State *L)
 34.1445 -				    {
 34.1446 -				        u32 addr;
 34.1447 -				        u16 val;
 34.1448 -
 34.1449 -				        addr = luaL_checkinteger(L, 1);
 34.1450 -				        if (systemIsRunningGBA())
 34.1451 -				        {
 34.1452 -				            val = CPUReadHalfWordQuick(addr);
 34.1453 -						}
 34.1454 -				        else
 34.1455 -				        {
 34.1456 -				            val = gbReadMemoryQuick16(addr & 0x0000FFFF);
 34.1457 -						}
 34.1458 -
 34.1459 -				        lua_pushinteger(L, val);
 34.1460 -				        return 1;
 34.1461 -					}
 34.1462 -
 34.1463 -				    static int memory_readwordsigned(lua_State *L)
 34.1464 -				    {
 34.1465 -				        u32 addr;
 34.1466 -				        s16 val;
 34.1467 -
 34.1468 -				        addr = luaL_checkinteger(L, 1);
 34.1469 -				        if (systemIsRunningGBA())
 34.1470 -				        {
 34.1471 -				            val = (s16) CPUReadHalfWordQuick(addr);
 34.1472 -						}
 34.1473 -				        else
 34.1474 -				        {
 34.1475 -				            val = (s16) gbReadMemoryQuick16(addr);
 34.1476 -						}
 34.1477 -
 34.1478 -				        lua_pushinteger(L, val);
 34.1479 -				        return 1;
 34.1480 -					}
 34.1481 -
 34.1482 -				    static int memory_readdword(lua_State *L)
 34.1483 -				    {
 34.1484 -				        u32 addr;
 34.1485 -				        u32 val;
 34.1486 -
 34.1487 -				        addr = luaL_checkinteger(L, 1);
 34.1488 -				        if (systemIsRunningGBA())
 34.1489 -				        {
 34.1490 -				            val = CPUReadMemoryQuick(addr);
 34.1491 -						}
 34.1492 -				        else
 34.1493 -				        {
 34.1494 -				            val = gbReadMemoryQuick32(addr & 0x0000FFFF);
 34.1495 -						}
 34.1496 -
 34.1497 -				        // lua_pushinteger doesn't work properly for 32bit system, does it?
 34.1498 -				        if (val >= 0x80000000 && sizeof(int) <= 4)
 34.1499 -							lua_pushnumber(L, val);
 34.1500 -				        else
 34.1501 -							lua_pushinteger(L, val);
 34.1502 -				        return 1;
 34.1503 -					}
 34.1504 -
 34.1505 -				    static int memory_readdwordsigned(lua_State *L)
 34.1506 -				    {
 34.1507 -				        u32 addr;
 34.1508 -				        s32 val;
 34.1509 -
 34.1510 -				        addr = luaL_checkinteger(L, 1);
 34.1511 -				        if (systemIsRunningGBA())
 34.1512 -				        {
 34.1513 -				            val = (s32) CPUReadMemoryQuick(addr);
 34.1514 -						}
 34.1515 -				        else
 34.1516 -				        {
 34.1517 -				            val = (s32) gbReadMemoryQuick32(addr);
 34.1518 -						}
 34.1519 -
 34.1520 -				        lua_pushinteger(L, val);
 34.1521 -				        return 1;
 34.1522 -					}
 34.1523 -
 34.1524 -				    static int memory_readbyterange(lua_State *L)
 34.1525 -				    {
 34.1526 -				        uint32 address = luaL_checkinteger(L, 1);
 34.1527 -				        int	   length  = luaL_checkinteger(L, 2);
 34.1528 -
 34.1529 -				        if (length < 0)
 34.1530 -				        {
 34.1531 -				            address += length;
 34.1532 -				            length	 = -length;
 34.1533 -						}
 34.1534 -
 34.1535 -				        // push the array
 34.1536 -				        lua_createtable(L, abs(length), 0);
 34.1537 -
 34.1538 -				        // put all the values into the (1-based) array
 34.1539 -				        for (int a = address, n = 1; n <= length; a++, n++)
 34.1540 -				        {
 34.1541 -				            unsigned char value;
 34.1542 -
 34.1543 -				            if (systemIsRunningGBA())
 34.1544 -				            {
 34.1545 -				                value = CPUReadByteQuick(a);
 34.1546 -							}
 34.1547 -				            else
 34.1548 -				            {
 34.1549 -				                value = gbReadMemoryQuick8(a);
 34.1550 -							}
 34.1551 -
 34.1552 -				            lua_pushinteger(L, value);
 34.1553 -				            lua_rawseti(L, -2, n);
 34.1554 -						}
 34.1555 -
 34.1556 -				        return 1;
 34.1557 -					}
 34.1558 -
 34.1559 -				    static int memory_writebyte(lua_State *L)
 34.1560 -				    {
 34.1561 -				        u32 addr;
 34.1562 -				        int val;
 34.1563 -
 34.1564 -				        addr = luaL_checkinteger(L, 1);
 34.1565 -				        val	 = luaL_checkinteger(L, 2);
 34.1566 -				        if (systemIsRunningGBA())
 34.1567 -				        {
 34.1568 -				            CPUWriteByteQuick(addr, val);
 34.1569 -						}
 34.1570 -				        else
 34.1571 -				        {
 34.1572 -				            gbWriteMemoryQuick8(addr, val);
 34.1573 -						}
 34.1574 -
 34.1575 -				        CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE);
 34.1576 -				        return 0;
 34.1577 -					}
 34.1578 -
 34.1579 -				    static int memory_writeword(lua_State *L)
 34.1580 -				    {
 34.1581 -				        u32 addr;
 34.1582 -				        int val;
 34.1583 -
 34.1584 -				        addr = luaL_checkinteger(L, 1);
 34.1585 -				        val	 = luaL_checkinteger(L, 2);
 34.1586 -				        if (systemIsRunningGBA())
 34.1587 -				        {
 34.1588 -				            CPUWriteHalfWordQuick(addr, val);
 34.1589 -						}
 34.1590 -				        else
 34.1591 -				        {
 34.1592 -				            gbWriteMemoryQuick16(addr, val);
 34.1593 -						}
 34.1594 -
 34.1595 -				        CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE);
 34.1596 -				        return 0;
 34.1597 -					}
 34.1598 -
 34.1599 -				    static int memory_writedword(lua_State *L)
 34.1600 -				    {
 34.1601 -				        u32 addr;
 34.1602 -				        int val;
 34.1603 -
 34.1604 -				        addr = luaL_checkinteger(L, 1);
 34.1605 -				        val	 = luaL_checkinteger(L, 2);
 34.1606 -				        if (systemIsRunningGBA())
 34.1607 -				        {
 34.1608 -				            CPUWriteMemoryQuick(addr, val);
 34.1609 -						}
 34.1610 -				        else
 34.1611 -				        {
 34.1612 -				            gbWriteMemoryQuick32(addr, val);
 34.1613 -						}
 34.1614 -
 34.1615 -				        CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE);
 34.1616 -				        return 0;
 34.1617 -					}
 34.1618 -
 34.1619 -				    static int memory_gbromreadbyte(lua_State *L)
 34.1620 -				    {
 34.1621 -				        u32 addr;
 34.1622 -				        u8	val;
 34.1623 -
 34.1624 -				        addr = luaL_checkinteger(L, 1);
 34.1625 -				        if (systemIsRunningGBA())
 34.1626 -				        {
 34.1627 -							lua_pushnil(L);
 34.1628 -							return 1;
 34.1629 -						}
 34.1630 -				        else
 34.1631 -				        {
 34.1632 -				            val = gbReadROMQuick8(addr);
 34.1633 -						}
 34.1634 -
 34.1635 -				        lua_pushinteger(L, val);
 34.1636 -				        return 1;
 34.1637 -					}
 34.1638 -
 34.1639 -				    static int memory_gbromreadbytesigned(lua_State *L)
 34.1640 -				    {
 34.1641 -				        u32 addr;
 34.1642 -				        s8	val;
 34.1643 -
 34.1644 -				        addr = luaL_checkinteger(L, 1);
 34.1645 -				        if (systemIsRunningGBA())
 34.1646 -				        {
 34.1647 -				            lua_pushnil(L);
 34.1648 -							return 1;
 34.1649 -						}
 34.1650 -				        else
 34.1651 -				        {
 34.1652 -				            val = (s8) gbReadROMQuick8(addr);
 34.1653 -						}
 34.1654 -
 34.1655 -				        lua_pushinteger(L, val);
 34.1656 -				        return 1;
 34.1657 -					}
 34.1658 -
 34.1659 -				    static int memory_gbromreadword(lua_State *L)
 34.1660 -				    {
 34.1661 -				        u32 addr;
 34.1662 -				        u16 val;
 34.1663 -
 34.1664 -				        addr = luaL_checkinteger(L, 1);
 34.1665 -				        if (systemIsRunningGBA())
 34.1666 -				        {
 34.1667 -				            lua_pushnil(L);
 34.1668 -							return 1;
 34.1669 -						}
 34.1670 -				        else
 34.1671 -				        {
 34.1672 -				            val = gbReadROMQuick16(addr);
 34.1673 -						}
 34.1674 -
 34.1675 -				        lua_pushinteger(L, val);
 34.1676 -				        return 1;
 34.1677 -					}
 34.1678 -
 34.1679 -				    static int memory_gbromreadwordsigned(lua_State *L)
 34.1680 -				    {
 34.1681 -				        u32 addr;
 34.1682 -				        s16 val;
 34.1683 -
 34.1684 -				        addr = luaL_checkinteger(L, 1);
 34.1685 -				        if (systemIsRunningGBA())
 34.1686 -				        {
 34.1687 -				            lua_pushnil(L);
 34.1688 -							return 1;
 34.1689 -						}
 34.1690 -				        else
 34.1691 -				        {
 34.1692 -				            val = (s16) gbReadROMQuick16(addr);
 34.1693 -						}
 34.1694 -
 34.1695 -				        lua_pushinteger(L, val);
 34.1696 -				        return 1;
 34.1697 -					}
 34.1698 -
 34.1699 -				    static int memory_gbromreaddword(lua_State *L)
 34.1700 -				    {
 34.1701 -				        u32 addr;
 34.1702 -				        u32 val;
 34.1703 -
 34.1704 -				        addr = luaL_checkinteger(L, 1);
 34.1705 -				        if (systemIsRunningGBA())
 34.1706 -				        {
 34.1707 -				            lua_pushnil(L);
 34.1708 -							return 1;
 34.1709 -						}
 34.1710 -				        else
 34.1711 -				        {
 34.1712 -				            val = gbReadROMQuick32(addr);
 34.1713 -						}
 34.1714 -
 34.1715 -				        // lua_pushinteger doesn't work properly for 32bit system, does it?
 34.1716 -				        if (val >= 0x80000000 && sizeof(int) <= 4)
 34.1717 -							lua_pushnumber(L, val);
 34.1718 -				        else
 34.1719 -							lua_pushinteger(L, val);
 34.1720 -				        return 1;
 34.1721 -					}
 34.1722 -
 34.1723 -				    static int memory_gbromreaddwordsigned(lua_State *L)
 34.1724 -				    {
 34.1725 -				        u32 addr;
 34.1726 -				        s32 val;
 34.1727 -
 34.1728 -				        addr = luaL_checkinteger(L, 1);
 34.1729 -				        if (systemIsRunningGBA())
 34.1730 -				        {
 34.1731 -				            lua_pushnil(L);
 34.1732 -							return 1;
 34.1733 -						}
 34.1734 -				        else
 34.1735 -				        {
 34.1736 -				            val = (s32) gbReadROMQuick32(addr);
 34.1737 -						}
 34.1738 -
 34.1739 -				        lua_pushinteger(L, val);
 34.1740 -				        return 1;
 34.1741 -					}
 34.1742 -
 34.1743 -				    static int memory_gbromreadbyterange(lua_State *L)
 34.1744 -				    {
 34.1745 -				        uint32 address = luaL_checkinteger(L, 1);
 34.1746 -				        int	   length  = luaL_checkinteger(L, 2);
 34.1747 -
 34.1748 -				        if (length < 0)
 34.1749 -				        {
 34.1750 -				            address += length;
 34.1751 -				            length	 = -length;
 34.1752 -						}
 34.1753 -
 34.1754 -				        // push the array
 34.1755 -				        lua_createtable(L, abs(length), 0);
 34.1756 -
 34.1757 -				        // put all the values into the (1-based) array
 34.1758 -				        for (int a = address, n = 1; n <= length; a++, n++)
 34.1759 -				        {
 34.1760 -				            unsigned char value;
 34.1761 -
 34.1762 -				            if (systemIsRunningGBA())
 34.1763 -				            {
 34.1764 -				                lua_pushnil(L);
 34.1765 -								return 1;
 34.1766 -							}
 34.1767 -				            else
 34.1768 -				            {
 34.1769 -				                value = gbReadROMQuick8(a);
 34.1770 -							}
 34.1771 -
 34.1772 -				            lua_pushinteger(L, value);
 34.1773 -				            lua_rawseti(L, -2, n);
 34.1774 -						}
 34.1775 -
 34.1776 -				        return 1;
 34.1777 -					}
 34.1778 -
 34.1779 -// table joypad.get(int which = 1)
 34.1780 -//
 34.1781 -//  Reads the joypads as inputted by the user.
 34.1782 -				    static int joy_get_internal(lua_State *L, bool reportUp, bool reportDown)
 34.1783 -				    {
 34.1784 -				        // Reads the joypads as inputted by the user
 34.1785 -				        int which = luaL_checkinteger(L, 1);
 34.1786 -
 34.1787 -				        if (which < 0 || which > 4)
 34.1788 -				        {
 34.1789 -				            luaL_error(L, "Invalid input port (valid range 0-4, specified %d)", which);
 34.1790 -						}
 34.1791 -
 34.1792 -				        uint32 buttons = systemGetOriginalJoypad(which - 1, false);
 34.1793 -
 34.1794 -				        lua_newtable(L);
 34.1795 -
 34.1796 -				        int i;
 34.1797 -				        for (i = 0; i < 10; i++)
 34.1798 -				        {
 34.1799 -				            bool pressed = (buttons & (1 << i)) != 0;
 34.1800 -				            if ((pressed && reportDown) || (!pressed && reportUp))
 34.1801 -				            {
 34.1802 -				                lua_pushboolean(L, pressed);
 34.1803 -				                lua_setfield(L, -2, button_mappings[i]);
 34.1804 -							}
 34.1805 -						}
 34.1806 -
 34.1807 -				        return 1;
 34.1808 -					}
 34.1809 -
 34.1810 -// joypad.get(which)
 34.1811 -// returns a table of every game button,
 34.1812 -// true meaning currently-held and false meaning not-currently-held
 34.1813 -// (as of last frame boundary)
 34.1814 -// this WILL read input from a currently-playing movie
 34.1815 -				    static int joypad_get(lua_State *L)
 34.1816 -				    {
 34.1817 -				        return joy_get_internal(L, true, true);
 34.1818 -					}
 34.1819 -
 34.1820 -// joypad.getdown(which)
 34.1821 -// returns a table of every game button that is currently held
 34.1822 -				    static int joypad_getdown(lua_State *L)
 34.1823 -				    {
 34.1824 -				        return joy_get_internal(L, false, true);
 34.1825 -					}
 34.1826 -
 34.1827 -// joypad.getup(which)
 34.1828 -// returns a table of every game button that is not currently held
 34.1829 -				    static int joypad_getup(lua_State *L)
 34.1830 -				    {
 34.1831 -				        return joy_get_internal(L, true, false);
 34.1832 -					}
 34.1833 -
 34.1834 -// joypad.set(int which, table buttons)
 34.1835 -//
 34.1836 -//   Sets the given buttons to be pressed during the next
 34.1837 -//   frame advance. The table should have the right
 34.1838 -
 34.1839 -//   keys (no pun intended) set.
 34.1840 -				    static int joypad_set(lua_State *L)
 34.1841 -				    {
 34.1842 -				        // Which joypad we're tampering with
 34.1843 -				        int which = luaL_checkinteger(L, 1);
 34.1844 -				        if (which < 0 || which > 4)
 34.1845 -				        {
 34.1846 -				            luaL_error(L, "Invalid output port (valid range 0-4, specified %d)", which);
 34.1847 -						}
 34.1848 -
 34.1849 -				        if (which == 0)
 34.1850 -							which = systemGetDefaultJoypad();
 34.1851 -
 34.1852 -				        // And the table of buttons.
 34.1853 -				        luaL_checktype(L, 2, LUA_TTABLE);
 34.1854 -
 34.1855 -				        // Set up for taking control of the indicated controller
 34.1856 -				        lua_joypads_used	  |= 1 << (which - 1);
 34.1857 -				        lua_joypads[which - 1] = 0;
 34.1858 -
 34.1859 -				        for (int i = 0; i < 10; i++)
 34.1860 -				        {
 34.1861 -				            const char *name = button_mappings[i];
 34.1862 -				            lua_getfield(L, 2, name);
 34.1863 -				            if (!lua_isnil(L, -1))
 34.1864 -				            {
 34.1865 -				                bool pressed = lua_toboolean(L, -1) != 0;
 34.1866 -				                if (pressed)
 34.1867 -									lua_joypads[which - 1] |= 1 << i;
 34.1868 -				                else
 34.1869 -									lua_joypads[which - 1] &= ~(1 << i);
 34.1870 -							}
 34.1871 -				            lua_pop(L, 1);
 34.1872 -						}
 34.1873 -
 34.1874 -				        return 0;
 34.1875 -					}
 34.1876 -
 34.1877 -// Helper function to convert a savestate object to the filename it represents.
 34.1878 -				    static const char *savestateobj2filename(lua_State *L, int offset)
 34.1879 -				    {
 34.1880 -				        // First we get the metatable of the indicated object
 34.1881 -				        int result = lua_getmetatable(L, offset);
 34.1882 -
 34.1883 -				        if (!result)
 34.1884 -							luaL_error(L, "object not a savestate object");
 34.1885 -
 34.1886 -				        // Also check that the type entry is set
 34.1887 -				        lua_getfield(L, -1, "__metatable");
 34.1888 -				        if (strcmp(lua_tostring(L, -1), "vba Savestate") != 0)
 34.1889 -							luaL_error(L, "object not a savestate object");
 34.1890 -				        lua_pop(L, 1);
 34.1891 -
 34.1892 -				        // Now, get the field we want
 34.1893 -				        lua_getfield(L, -1, "filename");
 34.1894 -
 34.1895 -				        // Return it
 34.1896 -				        return lua_tostring(L, -1);
 34.1897 -					}
 34.1898 -
 34.1899 -// Helper function for garbage collection.
 34.1900 -				    static int savestate_gc(lua_State *L)
 34.1901 -				    {
 34.1902 -				        // The object we're collecting is on top of the stack
 34.1903 -				        lua_getmetatable(L, 1);
 34.1904 -
 34.1905 -				        // Get the filename
 34.1906 -				        const char *filename;
 34.1907 -				        lua_getfield(L, -1, "filename");
 34.1908 -				        filename = lua_tostring(L, -1);
 34.1909 -
 34.1910 -				        // Delete the file
 34.1911 -				        remove(filename);
 34.1912 -
 34.1913 -				        // We exit, and the garbage collector takes care of the rest.
 34.1914 -				        // Edit: Visual Studio needs a return value anyway, so returns 0.
 34.1915 -				        return 0;
 34.1916 -					}
 34.1917 -
 34.1918 -// object savestate.create(int which = nil)
 34.1919 -//
 34.1920 -//  Creates an object used for savestates.
 34.1921 -//  The object can be associated with a player-accessible savestate
 34.1922 -
 34.1923 -//  ("which" between 1 and 12) or not (which == nil).
 34.1924 -				    static int savestate_create(lua_State *L)
 34.1925 -				    {
 34.1926 -				        int which = -1;
 34.1927 -				        if (lua_gettop(L) >= 1)
 34.1928 -				        {
 34.1929 -				            which = luaL_checkinteger(L, 1);
 34.1930 -				            if (which < 1 || which > 12)
 34.1931 -				            {
 34.1932 -				                luaL_error(L, "invalid player's savestate %d", which);
 34.1933 -							}
 34.1934 -						}
 34.1935 -
 34.1936 -				        char stateName[2048];
 34.1937 -
 34.1938 -				        if (which > 0)
 34.1939 -				        {
 34.1940 -				            // Find an appropriate filename. This is OS specific, unfortunately.
 34.1941 -#if (defined(WIN32) && !defined(SDL))
 34.1942 -				            CString stateName = winGetSavestateFilename(theApp.gameFilename, which);
 34.1943 -#else
 34.1944 -				            extern char saveDir[2048];
 34.1945 -				            extern char filename[2048];
 34.1946 -				            extern char *sdlGetFilename(char *name);
 34.1947 -
 34.1948 -				            if (saveDir[0])
 34.1949 -								sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename), which);
 34.1950 -				            else
 34.1951 -								sprintf(stateName, "%s%d.sgm", filename, which);
 34.1952 -#endif
 34.1953 -						}
 34.1954 -				        else
 34.1955 -				        {
 34.1956 -				            char *stateNameTemp = tempnam(NULL, "snlua");
 34.1957 -				            strcpy(stateName, stateNameTemp);
 34.1958 -				            if (stateNameTemp)
 34.1959 -								free(stateNameTemp);
 34.1960 -						}
 34.1961 -
 34.1962 -				        // Our "object". We don't care about the type, we just need the memory and GC services.
 34.1963 -				        lua_newuserdata(L, 1);
 34.1964 -
 34.1965 -				        // The metatable we use, protected from Lua and contains garbage collection info and stuff.
 34.1966 -				        lua_newtable(L);
 34.1967 -
 34.1968 -				        // First, we must protect it
 34.1969 -				        lua_pushstring(L, "vba Savestate");
 34.1970 -				        lua_setfield(L, -2, "__metatable");
 34.1971 -
 34.1972 -				        // Now we need to save the file itself.
 34.1973 -				        lua_pushstring(L, stateName);
 34.1974 -				        lua_setfield(L, -2, "filename");
 34.1975 -
 34.1976 -				        // If it's an anonymous savestate, we must delete the file from disk should it be gargage collected
 34.1977 -				        if (which < 0)
 34.1978 -				        {
 34.1979 -				            lua_pushcfunction(L, savestate_gc);
 34.1980 -				            lua_setfield(L, -2, "__gc");
 34.1981 -						}
 34.1982 -
 34.1983 -				        // Set the metatable
 34.1984 -				        lua_setmetatable(L, -2);
 34.1985 -
 34.1986 -				        // Awesome. Return the object
 34.1987 -				        return 1;
 34.1988 -					}
 34.1989 -
 34.1990 -// savestate.save(object state)
 34.1991 -//
 34.1992 -
 34.1993 -//   Saves a state to the given object.
 34.1994 -				    static int savestate_save(lua_State *L)
 34.1995 -				    {
 34.1996 -				        const char *filename = savestateobj2filename(L, 1);
 34.1997 -
 34.1998 -				        //	printf("saving %s\n", filename);
 34.1999 -				        // Save states are very expensive. They take time.
 34.2000 -				        numTries--;
 34.2001 -
 34.2002 -				        bool8 retvalue = theEmulator.emuWriteState ? theEmulator.emuWriteState(filename) : false;
 34.2003 -				        if (!retvalue)
 34.2004 -				        {
 34.2005 -				            // Uh oh
 34.2006 -				            luaL_error(L, "savestate failed");
 34.2007 -						}
 34.2008 -
 34.2009 -				        return 0;
 34.2010 -					}
 34.2011 -
 34.2012 -// savestate.load(object state)
 34.2013 -//
 34.2014 -
 34.2015 -//   Loads the given state
 34.2016 -				    static int savestate_load(lua_State *L)
 34.2017 -				    {
 34.2018 -				        const char *filename = savestateobj2filename(L, 1);
 34.2019 -
 34.2020 -				        numTries--;
 34.2021 -
 34.2022 -				        //	printf("loading %s\n", filename);
 34.2023 -				        bool8 retvalue = theEmulator.emuReadState ? theEmulator.emuReadState(filename) : false;
 34.2024 -				        if (!retvalue)
 34.2025 -				        {
 34.2026 -				            // Uh oh
 34.2027 -				            luaL_error(L, "loadstate failed");
 34.2028 -						}
 34.2029 -
 34.2030 -				        return 0;
 34.2031 -					}
 34.2032 -
 34.2033 -// int vba.framecount()
 34.2034 -//
 34.2035 -
 34.2036 -//   Gets the frame counter for the movie, or the number of frames since last reset.
 34.2037 -				    int vba_framecount(lua_State *L)
 34.2038 -				    {
 34.2039 -				        if (!VBAMovieActive())
 34.2040 -				        {
 34.2041 -				            lua_pushinteger(L, systemCounters.frameCount);
 34.2042 -						}
 34.2043 -				        else
 34.2044 -				        {
 34.2045 -				            lua_pushinteger(L, VBAMovieGetFrameCounter());
 34.2046 -						}
 34.2047 -
 34.2048 -				        return 1;
 34.2049 -					}
 34.2050 -
 34.2051 -//string movie.getauthor
 34.2052 -//
 34.2053 -
 34.2054 -// returns author info field of .vbm file
 34.2055 -				    int movie_getauthor(lua_State *L)
 34.2056 -				    {
 34.2057 -				        if (!VBAMovieActive())
 34.2058 -				        {
 34.2059 -				            //lua_pushnil(L);
 34.2060 -				            lua_pushstring(L, "");
 34.2061 -				            return 1;
 34.2062 -						}
 34.2063 -
 34.2064 -				        lua_pushstring(L, VBAMovieGetAuthorInfo().c_str());
 34.2065 -				        return 1;
 34.2066 -					}
 34.2067 -
 34.2068 -//string movie.filename
 34.2069 -				    int movie_getfilename(lua_State *L)
 34.2070 -				    {
 34.2071 -				        if (!VBAMovieActive())
 34.2072 -				        {
 34.2073 -				            //lua_pushnil(L);
 34.2074 -				            lua_pushstring(L, "");
 34.2075 -				            return 1;
 34.2076 -						}
 34.2077 -
 34.2078 -				        lua_pushstring(L, VBAMovieGetFilename().c_str());
 34.2079 -				        return 1;
 34.2080 -					}
 34.2081 -
 34.2082 -// string movie.mode()
 34.2083 -//
 34.2084 -
 34.2085 -//   "record", "playback" or nil
 34.2086 -				    int movie_getmode(lua_State *L)
 34.2087 -				    {
 34.2088 -				        assert(!VBAMovieLoading());
 34.2089 -				        if (!VBAMovieActive())
 34.2090 -				        {
 34.2091 -				            lua_pushnil(L);
 34.2092 -				            return 1;
 34.2093 -						}
 34.2094 -
 34.2095 -				        if (VBAMovieRecording())
 34.2096 -							lua_pushstring(L, "record");
 34.2097 -				        else
 34.2098 -							lua_pushstring(L, "playback");
 34.2099 -				        return 1;
 34.2100 -					}
 34.2101 -
 34.2102 -				    static int movie_rerecordcount(lua_State *L)
 34.2103 -				    {
 34.2104 -				        if (VBAMovieActive())
 34.2105 -							lua_pushinteger(L, VBAMovieGetRerecordCount());
 34.2106 -				        else
 34.2107 -							lua_pushinteger(L, 0);
 34.2108 -				        return 1;
 34.2109 -					}
 34.2110 -
 34.2111 -				    static int movie_setrerecordcount(lua_State *L)
 34.2112 -				    {
 34.2113 -				        if (VBAMovieActive())
 34.2114 -							VBAMovieSetRerecordCount(luaL_checkinteger(L, 1));
 34.2115 -				        return 0;
 34.2116 -					}
 34.2117 -
 34.2118 -				    static int movie_rerecordcounting(lua_State *L)
 34.2119 -				    {
 34.2120 -				        if (lua_gettop(L) == 0)
 34.2121 -							luaL_error(L, "no parameters specified");
 34.2122 -
 34.2123 -				        skipRerecords = lua_toboolean(L, 1);
 34.2124 -				        return 0;
 34.2125 -					}
 34.2126 -
 34.2127 -// movie.stop()
 34.2128 -//
 34.2129 -
 34.2130 -//   Stops movie playback/recording. Bombs out if movie is not running.
 34.2131 -				    static int movie_stop(lua_State *L)
 34.2132 -				    {
 34.2133 -				        if (!VBAMovieActive())
 34.2134 -							luaL_error(L, "no movie");
 34.2135 -
 34.2136 -				        VBAMovieStop(false);
 34.2137 -				        return 0;
 34.2138 -					}
 34.2139 -
 34.2140 -#define LUA_SCREEN_WIDTH    256
 34.2141 -#define LUA_SCREEN_HEIGHT   239
 34.2142 -
 34.2143 -// Common code by the gui library: make sure the screen array is ready
 34.2144 -				    static void gui_prepare(void)
 34.2145 -				    {
 34.2146 -				        if (!gui_data)
 34.2147 -							gui_data = (uint8 *)malloc(LUA_SCREEN_WIDTH * LUA_SCREEN_HEIGHT * 4);
 34.2148 -				        if (!gui_used)
 34.2149 -							memset(gui_data, 0, LUA_SCREEN_WIDTH * LUA_SCREEN_HEIGHT * 4);
 34.2150 -				        gui_used = true;
 34.2151 -					}
 34.2152 -
 34.2153 -// pixform for lua graphics
 34.2154 -#define BUILD_PIXEL_ARGB8888(A, R, G, B)    (((int)(A) << 24) | ((int)(R) << 16) | ((int)(G) << 8) | (int)(B))
 34.2155 -#define DECOMPOSE_PIXEL_ARGB8888(PIX, A, R, G, B) \
 34.2156 -	{                                             \
 34.2157 -		(A) = ((PIX) >> 24) & 0xff;               \
 34.2158 -		(R) = ((PIX) >> 16) & 0xff;               \
 34.2159 -		(G) = ((PIX) >> 8) & 0xff;                \
 34.2160 -		(B) = (PIX) & 0xff;                       \
 34.2161 -	}
 34.2162 -#define LUA_BUILD_PIXEL     BUILD_PIXEL_ARGB8888
 34.2163 -#define LUA_DECOMPOSE_PIXEL DECOMPOSE_PIXEL_ARGB8888
 34.2164 -#define LUA_PIXEL_A(PIX) (((PIX) >> 24) & 0xff)
 34.2165 -#define LUA_PIXEL_R(PIX) (((PIX) >> 16) & 0xff)
 34.2166 -#define LUA_PIXEL_G(PIX) (((PIX) >> 8) & 0xff)
 34.2167 -#define LUA_PIXEL_B(PIX) ((PIX) & 0xff)
 34.2168 -
 34.2169 -				    template<class T>
 34.2170 -				    static void swap(T &one, T &two)
 34.2171 -				    {
 34.2172 -				        T temp = one;
 34.2173 -				        one = two;
 34.2174 -				        two = temp;
 34.2175 -					}
 34.2176 -
 34.2177 -// write a pixel to buffer
 34.2178 -				    static inline void blend32(uint32 *dstPixel, uint32 colour)
 34.2179 -				    {
 34.2180 -				        uint8 *dst = (uint8 *)dstPixel;
 34.2181 -				        int	   a, r, g, b;
 34.2182 -				        LUA_DECOMPOSE_PIXEL(colour, a, r, g, b);
 34.2183 -
 34.2184 -				        if (a == 255 || dst[3] == 0)
 34.2185 -				        {
 34.2186 -				            // direct copy
 34.2187 -				            *(uint32 *) (dst) = colour;
 34.2188 -						}
 34.2189 -				        else if (a == 0)
 34.2190 -				        {
 34.2191 -				            // do not copy
 34.2192 -						}
 34.2193 -				        else
 34.2194 -				        {
 34.2195 -				            // alpha-blending
 34.2196 -				            int a_dst = ((255 - a) * dst[3] + 128) / 255;
 34.2197 -				            int a_new = a + a_dst;
 34.2198 -
 34.2199 -				            dst[0] = (uint8) (((dst[0] * a_dst + b * a) + (a_new / 2)) / a_new);
 34.2200 -				            dst[1] = (uint8) (((dst[1] * a_dst + g * a) + (a_new / 2)) / a_new);
 34.2201 -				            dst[2] = (uint8) (((dst[2] * a_dst + r * a) + (a_new / 2)) / a_new);
 34.2202 -				            dst[3] = (uint8) a_new;
 34.2203 -						}
 34.2204 -					}
 34.2205 -
 34.2206 -// check if a pixel is in the lua canvas
 34.2207 -				    static inline bool gui_check_boundary(int x, int y)
 34.2208 -				    {
 34.2209 -				        return !(x < 0 || x >= LUA_SCREEN_WIDTH || y < 0 || y >= LUA_SCREEN_HEIGHT);
 34.2210 -					}
 34.2211 -
 34.2212 -// check if any part of a box is in the lua canvas
 34.2213 -				    static inline bool gui_checkbox(int x1, int y1, int x2, int y2)
 34.2214 -				    {
 34.2215 -				        if ((x1 <  0 && x2 <  0)
 34.2216 -				            || (x1 >= LUA_SCREEN_WIDTH && x2 >= LUA_SCREEN_WIDTH)
 34.2217 -				            || (y1 <  0 && y2 <  0)
 34.2218 -				            || (y1 >= LUA_SCREEN_HEIGHT && y2 >= LUA_SCREEN_HEIGHT))
 34.2219 -							return false;
 34.2220 -				        return true;
 34.2221 -					}
 34.2222 -
 34.2223 -// write a pixel to gui_data (do not check boundaries for speedup)
 34.2224 -				    static inline void gui_drawpixel_fast(int x, int y, uint32 colour)
 34.2225 -				    {
 34.2226 -				        //gui_prepare();
 34.2227 -				        blend32((uint32 *) &gui_data[(y * LUA_SCREEN_WIDTH + x) * 4], colour);
 34.2228 -					}
 34.2229 -
 34.2230 -// write a pixel to gui_data (check boundaries)
 34.2231 -				    static inline void gui_drawpixel_internal(int x, int y, uint32 colour)
 34.2232 -				    {
 34.2233 -				        //gui_prepare();
 34.2234 -				        if (gui_check_boundary(x, y))
 34.2235 -							gui_drawpixel_fast(x, y, colour);
 34.2236 -					}
 34.2237 -
 34.2238 -// draw a line on gui_data (checks boundaries)
 34.2239 -				    static void gui_drawline_internal(int x1, int y1, int x2, int y2, bool lastPixel, uint32 colour)
 34.2240 -				    {
 34.2241 -				        //gui_prepare();
 34.2242 -				        // Note: New version of Bresenham's Line Algorithm
 34.2243 -				        //
 34.2244 -				        //
 34.2245 -				        // http://groups.google.co.jp/group/rec.games.roguelike.development/browse_thread/thread/345f4c42c3b25858/29e07a3af3a450e6?show_docid=29e07a3af3a450e6
 34.2246 -				        int swappedx = 0;
 34.2247 -				        int swappedy = 0;
 34.2248 -
 34.2249 -				        int xtemp = x1 - x2;
 34.2250 -				        int ytemp = y1 - y2;
 34.2251 -				        if (xtemp == 0 && ytemp == 0)
 34.2252 -				        {
 34.2253 -				            gui_drawpixel_internal(x1, y1, colour);
 34.2254 -				            return;
 34.2255 -						}
 34.2256 -
 34.2257 -				        if (xtemp < 0)
 34.2258 -				        {
 34.2259 -				            xtemp	 = -xtemp;
 34.2260 -				            swappedx = 1;
 34.2261 -						}
 34.2262 -
 34.2263 -				        if (ytemp < 0)
 34.2264 -				        {
 34.2265 -				            ytemp	 = -ytemp;
 34.2266 -				            swappedy = 1;
 34.2267 -						}
 34.2268 -
 34.2269 -				        int delta_x = xtemp << 1;
 34.2270 -				        int delta_y = ytemp << 1;
 34.2271 -
 34.2272 -				        signed char ix = x1 > x2 ? 1 : -1;
 34.2273 -				        signed char iy = y1 > y2 ? 1 : -1;
 34.2274 -
 34.2275 -				        if (lastPixel)
 34.2276 -							gui_drawpixel_internal(x2, y2, colour);
 34.2277 -
 34.2278 -				        if (delta_x >= delta_y)
 34.2279 -				        {
 34.2280 -				            int error = delta_y - (delta_x >> 1);
 34.2281 -
 34.2282 -				            while (x2 != x1)
 34.2283 -				            {
 34.2284 -				                if (error == 0 && !swappedx)
 34.2285 -									gui_drawpixel_internal(x2 + ix, y2, colour);
 34.2286 -				                if (error >= 0)
 34.2287 -				                {
 34.2288 -				                    if (error || (ix > 0))
 34.2289 -				                    {
 34.2290 -				                        y2	  += iy;
 34.2291 -				                        error -= delta_x;
 34.2292 -									}
 34.2293 -								}
 34.2294 -
 34.2295 -				                x2 += ix;
 34.2296 -				                gui_drawpixel_internal(x2, y2, colour);
 34.2297 -				                if (error == 0 && swappedx)
 34.2298 -									gui_drawpixel_internal(x2, y2 + iy, colour);
 34.2299 -				                error += delta_y;
 34.2300 -							}
 34.2301 -						}
 34.2302 -				        else
 34.2303 -				        {
 34.2304 -				            int error = delta_x - (delta_y >> 1);
 34.2305 -
 34.2306 -				            while (y2 != y1)
 34.2307 -				            {
 34.2308 -				                if (error == 0 && !swappedy)
 34.2309 -									gui_drawpixel_internal(x2, y2 + iy, colour);
 34.2310 -				                if (error >= 0)
 34.2311 -				                {
 34.2312 -				                    if (error || (iy > 0))
 34.2313 -				                    {
 34.2314 -				                        x2	  += ix;
 34.2315 -				                        error -= delta_y;
 34.2316 -									}
 34.2317 -								}
 34.2318 -
 34.2319 -				                y2 += iy;
 34.2320 -				                gui_drawpixel_internal(x2, y2, colour);
 34.2321 -				                if (error == 0 && swappedy)
 34.2322 -									gui_drawpixel_internal(x2 + ix, y2, colour);
 34.2323 -				                error += delta_x;
 34.2324 -							}
 34.2325 -						}
 34.2326 -					}
 34.2327 -
 34.2328 -// draw a rect on gui_data
 34.2329 -				    static void gui_drawbox_internal(int x1, int y1, int x2, int y2, uint32 colour)
 34.2330 -				    {
 34.2331 -				        if (x1 > x2)
 34.2332 -							std::swap(x1, x2);
 34.2333 -				        if (y1 > y2)
 34.2334 -							std::swap(y1, y2);
 34.2335 -				        if (x1 < 0)
 34.2336 -							x1 = -1;
 34.2337 -				        if (y1 < 0)
 34.2338 -							y1 = -1;
 34.2339 -				        if (x2 >= LUA_SCREEN_WIDTH)
 34.2340 -							x2 = LUA_SCREEN_WIDTH;
 34.2341 -				        if (y2 >= LUA_SCREEN_HEIGHT)
 34.2342 -							y2 = LUA_SCREEN_HEIGHT;
 34.2343 -
 34.2344 -				        if (!gui_checkbox(x1, y1, x2, y2))
 34.2345 -							return;
 34.2346 -
 34.2347 -				        //gui_prepare();
 34.2348 -				        gui_drawline_internal(x1, y1, x2, y1, true, colour);
 34.2349 -				        gui_drawline_internal(x1, y2, x2, y2, true, colour);
 34.2350 -				        gui_drawline_internal(x1, y1, x1, y2, true, colour);
 34.2351 -				        gui_drawline_internal(x2, y1, x2, y2, true, colour);
 34.2352 -					}
 34.2353 -
 34.2354 -// draw a circle on gui_data
 34.2355 -				    static void gui_drawcircle_internal(int x0, int y0, int radius, uint32 colour)
 34.2356 -				    {
 34.2357 -				        //gui_prepare();
 34.2358 -				        if (radius < 0)
 34.2359 -							radius = -radius;
 34.2360 -				        if (radius == 0)
 34.2361 -							return;
 34.2362 -				        if (radius == 1)
 34.2363 -				        {
 34.2364 -				            gui_drawpixel_internal(x0, y0, colour);
 34.2365 -				            return;
 34.2366 -						}
 34.2367 -
 34.2368 -				        // http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
 34.2369 -				        int f	  = 1 - radius;
 34.2370 -				        int ddF_x = 1;
 34.2371 -				        int ddF_y = -2 * radius;
 34.2372 -				        int x	  = 0;
 34.2373 -				        int y	  = radius;
 34.2374 -
 34.2375 -				        if (!gui_checkbox(x0 - radius, y0 - radius, x0 + radius, y0 + radius))
 34.2376 -							return;
 34.2377 -
 34.2378 -				        gui_drawpixel_internal(x0, y0 + radius, colour);
 34.2379 -				        gui_drawpixel_internal(x0, y0 - radius, colour);
 34.2380 -				        gui_drawpixel_internal(x0 + radius, y0, colour);
 34.2381 -				        gui_drawpixel_internal(x0 - radius, y0, colour);
 34.2382 -
 34.2383 -				        // same pixel shouldn't be drawed twice,
 34.2384 -				        // because each pixel has opacity.
 34.2385 -				        // so now the routine gets ugly.
 34.2386 -				        while (true)
 34.2387 -				        {
 34.2388 -				            assert(ddF_x == 2 * x + 1);
 34.2389 -				            assert(ddF_y == -2 * y);
 34.2390 -				            assert(f == x * x + y * y - radius * radius + 2 * x - y + 1);
 34.2391 -				            if (f >= 0)
 34.2392 -				            {
 34.2393 -				                y--;
 34.2394 -				                ddF_y += 2;
 34.2395 -				                f	  += ddF_y;
 34.2396 -							}
 34.2397 -
 34.2398 -				            x++;
 34.2399 -				            ddF_x += 2;
 34.2400 -				            f	  += ddF_x;
 34.2401 -				            if (x < y)
 34.2402 -				            {
 34.2403 -				                gui_drawpixel_internal(x0 + x, y0 + y, colour);
 34.2404 -				                gui_drawpixel_internal(x0 - x, y0 + y, colour);
 34.2405 -				                gui_drawpixel_internal(x0 + x, y0 - y, colour);
 34.2406 -				                gui_drawpixel_internal(x0 - x, y0 - y, colour);
 34.2407 -				                gui_drawpixel_internal(x0 + y, y0 + x, colour);
 34.2408 -				                gui_drawpixel_internal(x0 - y, y0 + x, colour);
 34.2409 -				                gui_drawpixel_internal(x0 + y, y0 - x, colour);
 34.2410 -				                gui_drawpixel_internal(x0 - y, y0 - x, colour);
 34.2411 -							}
 34.2412 -				            else if (x == y)
 34.2413 -				            {
 34.2414 -				                gui_drawpixel_internal(x0 + x, y0 + y, colour);
 34.2415 -				                gui_drawpixel_internal(x0 - x, y0 + y, colour);
 34.2416 -				                gui_drawpixel_internal(x0 + x, y0 - y, colour);
 34.2417 -				                gui_drawpixel_internal(x0 - x, y0 - y, colour);
 34.2418 -				                break;
 34.2419 -							}
 34.2420 -				            else
 34.2421 -								break;
 34.2422 -						}
 34.2423 -					}
 34.2424 -
 34.2425 -// draw fill rect on gui_data
 34.2426 -				    static void gui_fillbox_internal(int x1, int y1, int x2, int y2, uint32 colour)
 34.2427 -				    {
 34.2428 -				        if (x1 > x2)
 34.2429 -							std::swap(x1, x2);
 34.2430 -				        if (y1 > y2)
 34.2431 -							std::swap(y1, y2);
 34.2432 -				        if (x1 < 0)
 34.2433 -							x1 = 0;
 34.2434 -				        if (y1 < 0)
 34.2435 -							y1 = 0;
 34.2436 -				        if (x2 >= LUA_SCREEN_WIDTH)
 34.2437 -							x2 = LUA_SCREEN_WIDTH - 1;
 34.2438 -				        if (y2 >= LUA_SCREEN_HEIGHT)
 34.2439 -							y2 = LUA_SCREEN_HEIGHT - 1;
 34.2440 -
 34.2441 -				        //gui_prepare();
 34.2442 -				        int ix, iy;
 34.2443 -				        for (iy = y1; iy <= y2; iy++)
 34.2444 -				        {
 34.2445 -				            for (ix = x1; ix <= x2; ix++)
 34.2446 -				            {
 34.2447 -				                gui_drawpixel_fast(ix, iy, colour);
 34.2448 -							}
 34.2449 -						}
 34.2450 -					}
 34.2451 -
 34.2452 -// fill a circle on gui_data
 34.2453 -				    static void gui_fillcircle_internal(int x0, int y0, int radius, uint32 colour)
 34.2454 -				    {
 34.2455 -				        //gui_prepare();
 34.2456 -				        if (radius < 0)
 34.2457 -							radius = -radius;
 34.2458 -				        if (radius == 0)
 34.2459 -							return;
 34.2460 -				        if (radius == 1)
 34.2461 -				        {
 34.2462 -				            gui_drawpixel_internal(x0, y0, colour);
 34.2463 -				            return;
 34.2464 -						}
 34.2465 -
 34.2466 -				        // http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
 34.2467 -				        int f	  = 1 - radius;
 34.2468 -				        int ddF_x = 1;
 34.2469 -				        int ddF_y = -2 * radius;
 34.2470 -				        int x	  = 0;
 34.2471 -				        int y	  = radius;
 34.2472 -
 34.2473 -				        if (!gui_checkbox(x0 - radius, y0 - radius, x0 + radius, y0 + radius))
 34.2474 -							return;
 34.2475 -
 34.2476 -				        gui_drawline_internal(x0, y0 - radius, x0, y0 + radius, true, colour);
 34.2477 -
 34.2478 -				        while (true)
 34.2479 -				        {
 34.2480 -				            assert(ddF_x == 2 * x + 1);
 34.2481 -				            assert(ddF_y == -2 * y);
 34.2482 -				            assert(f == x * x + y * y - radius * radius + 2 * x - y + 1);
 34.2483 -				            if (f >= 0)
 34.2484 -				            {
 34.2485 -				                y--;
 34.2486 -				                ddF_y += 2;
 34.2487 -				                f	  += ddF_y;
 34.2488 -							}
 34.2489 -
 34.2490 -				            x++;
 34.2491 -				            ddF_x += 2;
 34.2492 -				            f	  += ddF_x;
 34.2493 -
 34.2494 -				            if (x < y)
 34.2495 -				            {
 34.2496 -				                gui_drawline_internal(x0 + x, y0 - y, x0 + x, y0 + y, true, colour);
 34.2497 -				                gui_drawline_internal(x0 - x, y0 - y, x0 - x, y0 + y, true, colour);
 34.2498 -				                if (f >= 0)
 34.2499 -				                {
 34.2500 -				                    gui_drawline_internal(x0 + y, y0 - x, x0 + y, y0 + x, true, colour);
 34.2501 -				                    gui_drawline_internal(x0 - y, y0 - x, x0 - y, y0 + x, true, colour);
 34.2502 -								}
 34.2503 -							}
 34.2504 -				            else if (x == y)
 34.2505 -				            {
 34.2506 -				                gui_drawline_internal(x0 + x, y0 - y, x0 + x, y0 + y, true, colour);
 34.2507 -				                gui_drawline_internal(x0 - x, y0 - y, x0 - x, y0 + y, true, colour);
 34.2508 -				                break;
 34.2509 -							}
 34.2510 -				            else
 34.2511 -								break;
 34.2512 -						}
 34.2513 -					}
 34.2514 -
 34.2515 -// Helper for a simple hex parser
 34.2516 -				    static int hex2int(lua_State *L, char c)
 34.2517 -				    {
 34.2518 -				        if (c >= '0' && c <= '9')
 34.2519 -							return c - '0';
 34.2520 -				        if (c >= 'a' && c <= 'f')
 34.2521 -							return c - 'a' + 10;
 34.2522 -				        if (c >= 'A' && c <= 'F')
 34.2523 -							return c - 'A' + 10;
 34.2524 -				        return luaL_error(L, "invalid hex in colour");
 34.2525 -					}
 34.2526 -
 34.2527 -				    static const struct ColorMapping
 34.2528 -				    {
 34.2529 -				        const char *name;
 34.2530 -				        int			value;
 34.2531 -					}
 34.2532 -				    s_colorMapping[] =
 34.2533 -				    {
 34.2534 -				        { "white",		0xFFFFFFFF		  },
 34.2535 -				        { "black",		0x000000FF		  },
 34.2536 -				        { "clear",		0x00000000		  },
 34.2537 -				        { "gray",		0x7F7F7FFF		  },
 34.2538 -				        { "grey",		0x7F7F7FFF		  },
 34.2539 -				        { "red",		0xFF0000FF		  },
 34.2540 -				        { "orange",		0xFF7F00FF		  },
 34.2541 -				        { "yellow",		0xFFFF00FF		  },
 34.2542 -				        { "chartreuse", 0x7FFF00FF		  },
 34.2543 -				        { "green",		0x00FF00FF		  },
 34.2544 -				        { "teal",		0x00FF7FFF		  },
 34.2545 -				        { "cyan",		0x00FFFFFF		  },
 34.2546 -				        { "blue",		0x0000FFFF		  },
 34.2547 -				        { "purple",		0x7F00FFFF		  },
 34.2548 -				        { "magenta",	0xFF00FFFF		  },
 34.2549 -					};
 34.2550 -
 34.2551 -/**
 34.2552 - * Converts an integer or a string on the stack at the given
 34.2553 - * offset to a RGB32 colour. Several encodings are supported.
 34.2554 - * The user may construct their own RGB value, given a simple colour name,
 34.2555 - * or an HTML-style "#09abcd" colour. 16 bit reduction doesn't occur at this time.
 34.2556 - */
 34.2557 -				    static inline bool str2colour(uint32 *colour, lua_State *L, const char *str)
 34.2558 -				    {
 34.2559 -				        if (str[0] == '#')
 34.2560 -				        {
 34.2561 -				            int color;
 34.2562 -				            sscanf(str + 1, "%X", &color);
 34.2563 -
 34.2564 -				            int len		= strlen(str + 1);
 34.2565 -				            int missing = max(0, 8 - len);
 34.2566 -				            color <<= missing << 2;
 34.2567 -				            if (missing >= 2)
 34.2568 -								color |= 0xFF;
 34.2569 -				            *colour = color;
 34.2570 -				            return true;
 34.2571 -						}
 34.2572 -				        else
 34.2573 -				        {
 34.2574 -				            if (!strnicmp(str, "rand", 4))
 34.2575 -				            {
 34.2576 -				                *colour = gen_rand32() | 0xFF; //((rand()*255/RAND_MAX) << 8) | ((rand()*255/RAND_MAX) << 16) |
 34.2577 -				                                               // ((rand()*255/RAND_MAX) << 24) | 0xFF;
 34.2578 -				                return true;
 34.2579 -							}
 34.2580 -
 34.2581 -				            for (int i = 0; i < sizeof(s_colorMapping) / sizeof(*s_colorMapping); i++)
 34.2582 -				            {
 34.2583 -				                if (!stricmp(str, s_colorMapping[i].name))
 34.2584 -				                {
 34.2585 -				                    *colour = s_colorMapping[i].value;
 34.2586 -				                    return true;
 34.2587 -								}
 34.2588 -							}
 34.2589 -						}
 34.2590 -
 34.2591 -				        return false;
 34.2592 -					}
 34.2593 -
 34.2594 -				    static inline uint32 gui_getcolour_wrapped(lua_State *L, int offset, bool hasDefaultValue, uint32 defaultColour)
 34.2595 -				    {
 34.2596 -				        switch (lua_type(L, offset))
 34.2597 -				        {
 34.2598 -						case LUA_TSTRING:
 34.2599 -							{
 34.2600 -							    const char *str = lua_tostring(L, offset);
 34.2601 -							    uint32		colour;
 34.2602 -
 34.2603 -							    if (str2colour(&colour, L, str))
 34.2604 -									return colour;
 34.2605 -							    else
 34.2606 -							    {
 34.2607 -							        if (hasDefaultValue)
 34.2608 -										return defaultColour;
 34.2609 -							        else
 34.2610 -										return luaL_error(L, "unknown colour %s", str);
 34.2611 -								}
 34.2612 -							}
 34.2613 -
 34.2614 -						case LUA_TNUMBER:
 34.2615 -							{
 34.2616 -							    uint32 colour = (uint32) lua_tointeger(L, offset);
 34.2617 -							    return colour;
 34.2618 -							}
 34.2619 -
 34.2620 -						case LUA_TTABLE:
 34.2621 -							{
 34.2622 -							    int color = 0xFF;
 34.2623 -							    lua_pushnil(L); // first key
 34.2624 -							    int	 keyIndex	= lua_gettop(L);
 34.2625 -							    int	 valueIndex = keyIndex + 1;
 34.2626 -							    bool first		= true;
 34.2627 -							    while (lua_next(L, offset))
 34.2628 -							    {
 34.2629 -							        bool keyIsString = (lua_type(L, keyIndex) == LUA_TSTRING);
 34.2630 -							        bool keyIsNumber = (lua_type(L, keyIndex) == LUA_TNUMBER);
 34.2631 -							        int	 key		 = keyIsString ? tolower(*lua_tostring(L, keyIndex)) : (keyIsNumber ? lua_tointeger(L, keyIndex) : 0);
 34.2632 -							        int	 value		 = lua_tointeger(L, valueIndex);
 34.2633 -							        if (value < 0) value = 0;
 34.2634 -							        if (value > 255) value = 255;
 34.2635 -							        switch (key)
 34.2636 -							        {
 34.2637 -									case 1:
 34.2638 -									case 'r':
 34.2639 -										color |= value << 24; break;
 34.2640 -									case 2:
 34.2641 -									case 'g':
 34.2642 -										color |= value << 16; break;
 34.2643 -									case 3:
 34.2644 -									case 'b':
 34.2645 -										color |= value << 8; break;
 34.2646 -									case 4:
 34.2647 -									case 'a':
 34.2648 -										color = (color & ~0xFF) | value; break;
 34.2649 -									}
 34.2650 -							        lua_pop(L, 1);
 34.2651 -								}
 34.2652 -							    return color;
 34.2653 -							}   break;
 34.2654 -
 34.2655 -						case LUA_TFUNCTION:
 34.2656 -							luaL_error(L, "invalid colour"); // NYI
 34.2657 -							return 0;
 34.2658 -
 34.2659 -						default:
 34.2660 -							if (hasDefaultValue)
 34.2661 -								return defaultColour;
 34.2662 -							else
 34.2663 -								return luaL_error(L, "invalid colour");
 34.2664 -						}
 34.2665 -					}
 34.2666 -
 34.2667 -				    static uint32 gui_getcolour(lua_State *L, int offset)
 34.2668 -				    {
 34.2669 -				        uint32 colour;
 34.2670 -				        int	   a, r, g, b;
 34.2671 -
 34.2672 -				        colour = gui_getcolour_wrapped(L, offset, false, 0);
 34.2673 -				        a	   = ((colour & 0xff) * transparencyModifier) / 255;
 34.2674 -				        if (a > 255)
 34.2675 -							a = 255;
 34.2676 -				        b = (colour >> 8) & 0xff;
 34.2677 -				        g = (colour >> 16) & 0xff;
 34.2678 -				        r = (colour >> 24) & 0xff;
 34.2679 -				        return LUA_BUILD_PIXEL(a, r, g, b);
 34.2680 -					}
 34.2681 -
 34.2682 -				    static uint32 gui_optcolour(lua_State *L, int offset, uint32 defaultColour)
 34.2683 -				    {
 34.2684 -				        uint32 colour;
 34.2685 -				        int	   a, r, g, b;
 34.2686 -				        uint8  defA, defB, defG, defR;
 34.2687 -
 34.2688 -				        LUA_DECOMPOSE_PIXEL(defaultColour, defA, defR, defG, defB);
 34.2689 -				        defaultColour = (defR << 24) | (defG << 16) | (defB << 8) | defA;
 34.2690 -
 34.2691 -				        colour = gui_getcolour_wrapped(L, offset, true, defaultColour);
 34.2692 -				        a	   = ((colour & 0xff) * transparencyModifier) / 255;
 34.2693 -				        if (a > 255)
 34.2694 -							a = 255;
 34.2695 -				        b = (colour >> 8) & 0xff;
 34.2696 -				        g = (colour >> 16) & 0xff;
 34.2697 -				        r = (colour >> 24) & 0xff;
 34.2698 -				        return LUA_BUILD_PIXEL(a, r, g, b);
 34.2699 -					}
 34.2700 -
 34.2701 -// gui.drawpixel(x,y,colour)
 34.2702 -				    static int gui_drawpixel(lua_State *L)
 34.2703 -				    {
 34.2704 -				        int x = luaL_checkinteger(L, 1);
 34.2705 -				        int y = luaL_checkinteger(L, 2);
 34.2706 -
 34.2707 -				        uint32 colour = gui_getcolour(L, 3);
 34.2708 -
 34.2709 -				        //	if (!gui_check_boundary(x, y))
 34.2710 -				        //		luaL_error(L,"bad coordinates");
 34.2711 -				        gui_prepare();
 34.2712 -
 34.2713 -				        gui_drawpixel_internal(x, y, colour);
 34.2714 -
 34.2715 -				        return 0;
 34.2716 -					}
 34.2717 -
 34.2718 -// gui.drawline(x1,y1,x2,y2,color,skipFirst)
 34.2719 -				    static int gui_drawline(lua_State *L)
 34.2720 -				    {
 34.2721 -				        int	   x1, y1, x2, y2;
 34.2722 -				        uint32 color;
 34.2723 -				        x1	  = luaL_checkinteger(L, 1);
 34.2724 -				        y1	  = luaL_checkinteger(L, 2);
 34.2725 -				        x2	  = luaL_checkinteger(L, 3);
 34.2726 -				        y2	  = luaL_checkinteger(L, 4);
 34.2727 -				        color = gui_optcolour(L, 5, LUA_BUILD_PIXEL(255, 255, 255, 255));
 34.2728 -				        int skipFirst = lua_toboolean(L, 6);
 34.2729 -
 34.2730 -				        gui_prepare();
 34.2731 -
 34.2732 -				        gui_drawline_internal(x2, y2, x1, y1, !skipFirst, color);
 34.2733 -
 34.2734 -				        return 0;
 34.2735 -					}
 34.2736 -
 34.2737 -// gui.drawbox(x1, y1, x2, y2, fillcolor, outlinecolor)
 34.2738 -				    static int gui_drawbox(lua_State *L)
 34.2739 -				    {
 34.2740 -				        int	   x1, y1, x2, y2;
 34.2741 -				        uint32 fillcolor;
 34.2742 -				        uint32 outlinecolor;
 34.2743 -
 34.2744 -				        x1 = luaL_checkinteger(L, 1);
 34.2745 -				        y1 = luaL_checkinteger(L, 2);
 34.2746 -				        x2 = luaL_checkinteger(L, 3);
 34.2747 -				        y2 = luaL_checkinteger(L, 4);
 34.2748 -				        fillcolor	 = gui_optcolour(L, 5, LUA_BUILD_PIXEL(63, 255, 255, 255));
 34.2749 -				        outlinecolor = gui_optcolour(L, 6, LUA_BUILD_PIXEL(255, LUA_PIXEL_R(fillcolor), LUA_PIXEL_G(fillcolor), LUA_PIXEL_B(fillcolor)));
 34.2750 -
 34.2751 -				        if (x1 > x2)
 34.2752 -							std::swap(x1, x2);
 34.2753 -				        if (y1 > y2)
 34.2754 -							std::swap(y1, y2);
 34.2755 -
 34.2756 -				        gui_prepare();
 34.2757 -
 34.2758 -				        gui_drawbox_internal(x1, y1, x2, y2, outlinecolor);
 34.2759 -				        if ((x2 - x1) >= 2 && (y2 - y1) >= 2)
 34.2760 -							gui_fillbox_internal(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
 34.2761 -
 34.2762 -				        return 0;
 34.2763 -					}
 34.2764 -
 34.2765 -// gui.drawcircle(x0, y0, radius, colour)
 34.2766 -				    static int gui_drawcircle(lua_State *L)
 34.2767 -				    {
 34.2768 -				        int	   x, y, r;
 34.2769 -				        uint32 colour;
 34.2770 -
 34.2771 -				        x	   = luaL_checkinteger(L, 1);
 34.2772 -				        y	   = luaL_checkinteger(L, 2);
 34.2773 -				        r	   = luaL_checkinteger(L, 3);
 34.2774 -				        colour = gui_getcolour(L, 4);
 34.2775 -
 34.2776 -				        gui_prepare();
 34.2777 -
 34.2778 -				        gui_drawcircle_internal(x, y, r, colour);
 34.2779 -
 34.2780 -				        return 0;
 34.2781 -					}
 34.2782 -
 34.2783 -// gui.fillbox(x1, y1, x2, y2, colour)
 34.2784 -				    static int gui_fillbox(lua_State *L)
 34.2785 -				    {
 34.2786 -				        int	   x1, y1, x2, y2;
 34.2787 -				        uint32 colour;
 34.2788 -
 34.2789 -				        x1	   = luaL_checkinteger(L, 1);
 34.2790 -				        y1	   = luaL_checkinteger(L, 2);
 34.2791 -				        x2	   = luaL_checkinteger(L, 3);
 34.2792 -				        y2	   = luaL_checkinteger(L, 4);
 34.2793 -				        colour = gui_getcolour(L, 5);
 34.2794 -
 34.2795 -				        //	if (!gui_check_boundary(x1, y1))
 34.2796 -				        //		luaL_error(L,"bad coordinates");
 34.2797 -				        //
 34.2798 -				        //	if (!gui_check_boundary(x2, y2))
 34.2799 -				        //		luaL_error(L,"bad coordinates");
 34.2800 -				        gui_prepare();
 34.2801 -
 34.2802 -				        if (!gui_checkbox(x1, y1, x2, y2))
 34.2803 -							return 0;
 34.2804 -
 34.2805 -				        gui_fillbox_internal(x1, y1, x2, y2, colour);
 34.2806 -
 34.2807 -				        return 0;
 34.2808 -					}
 34.2809 -
 34.2810 -// gui.fillcircle(x0, y0, radius, colour)
 34.2811 -				    static int gui_fillcircle(lua_State *L)
 34.2812 -				    {
 34.2813 -				        int	   x, y, r;
 34.2814 -				        uint32 colour;
 34.2815 -
 34.2816 -				        x	   = luaL_checkinteger(L, 1);
 34.2817 -				        y	   = luaL_checkinteger(L, 2);
 34.2818 -				        r	   = luaL_checkinteger(L, 3);
 34.2819 -				        colour = gui_getcolour(L, 4);
 34.2820 -
 34.2821 -				        gui_prepare();
 34.2822 -
 34.2823 -				        gui_fillcircle_internal(x, y, r, colour);
 34.2824 -
 34.2825 -				        return 0;
 34.2826 -					}
 34.2827 -
 34.2828 -				    static int gui_getpixel(lua_State *L)
 34.2829 -				    {
 34.2830 -				        int x = luaL_checkinteger(L, 1);
 34.2831 -				        int y = luaL_checkinteger(L, 2);
 34.2832 -
 34.2833 -				        int pixWidth   = 240, pixHeight = 160;
 34.2834 -				        int scrWidth   = 240, scrHeight = 160;
 34.2835 -				        int scrOffsetX = 0, scrOffsetY = 0;
 34.2836 -				        int pitch;
 34.2837 -				        if (!systemIsRunningGBA())
 34.2838 -				        {
 34.2839 -				            if (gbBorderOn)
 34.2840 -				            {
 34.2841 -				                pixWidth   = 256, pixHeight = 224;
 34.2842 -				                scrOffsetX = 48, scrOffsetY = 40;
 34.2843 -							}
 34.2844 -				            else
 34.2845 -				            {
 34.2846 -				                pixWidth = 160, pixHeight = 144;
 34.2847 -							}
 34.2848 -				            scrWidth = 160, scrHeight = 144;
 34.2849 -						}
 34.2850 -				        pitch = pixWidth * (systemColorDepth / 8) + (systemColorDepth == 24 ? 0 : 4);
 34.2851 -				        scrOffsetY++; // don't know why it's needed
 34.2852 -
 34.2853 -				        if (!(x >= 0 && y >= 0 && x < scrWidth && y < scrHeight) /*!gui_check_boundary(x,y)*/)
 34.2854 -				        {
 34.2855 -				            lua_pushinteger(L, 0);
 34.2856 -				            lua_pushinteger(L, 0);
 34.2857 -				            lua_pushinteger(L, 0);
 34.2858 -						}
 34.2859 -				        else
 34.2860 -				        {
 34.2861 -				            switch (systemColorDepth)
 34.2862 -				            {
 34.2863 -							case 16:
 34.2864 -								{
 34.2865 -								    uint16 *screen	 = (uint16 *) (&pix[scrOffsetY * pitch + scrOffsetX * 2]);
 34.2866 -								    uint16	pixColor = screen[y * pitch / 2 + x];
 34.2867 -								    lua_pushinteger(L, (pixColor >> 8) & 0xF8); // red
 34.2868 -								    lua_pushinteger(L, (pixColor >> 3) & 0xFC); // green
 34.2869 -								    lua_pushinteger(L, (pixColor << 3) & 0xF8); // blue
 34.2870 -								}
 34.2871 -								break;
 34.2872 -							case 24:
 34.2873 -								{
 34.2874 -								    uint8 *screen = &pix[scrOffsetY * pitch + scrOffsetX * 3];
 34.2875 -								    lua_pushinteger(L, screen[y * pitch + x * 3 + 2]); // red
 34.2876 -								    lua_pushinteger(L, screen[y * pitch + x * 3 + 1]); // green
 34.2877 -								    lua_pushinteger(L, screen[y * pitch + x * 3 + 0]); // blue
 34.2878 -								}
 34.2879 -								break;
 34.2880 -							case 32:
 34.2881 -								{
 34.2882 -								    uint8 *screen = &pix[scrOffsetY * pitch + scrOffsetX * 4];
 34.2883 -								    lua_pushinteger(L, screen[y * pitch + x * 4 + 2]); // red
 34.2884 -								    lua_pushinteger(L, screen[y * pitch + x * 4 + 1]); // green
 34.2885 -								    lua_pushinteger(L, screen[y * pitch + x * 4 + 0]); // blue
 34.2886 -								}
 34.2887 -								break;
 34.2888 -							default:
 34.2889 -								lua_pushinteger(L, 0);
 34.2890 -								lua_pushinteger(L, 0);
 34.2891 -								lua_pushinteger(L, 0);
 34.2892 -								break;
 34.2893 -							}
 34.2894 -						}
 34.2895 -				        return 3;
 34.2896 -					}
 34.2897 -
 34.2898 -				    static int gui_parsecolor(lua_State *L)
 34.2899 -				    {
 34.2900 -				        int	   r, g, b, a;
 34.2901 -				        uint32 color = gui_getcolour(L, 1);
 34.2902 -				        LUA_DECOMPOSE_PIXEL(color, a, r, g, b);
 34.2903 -				        lua_pushinteger(L, r);
 34.2904 -				        lua_pushinteger(L, g);
 34.2905 -				        lua_pushinteger(L, b);
 34.2906 -				        lua_pushinteger(L, a);
 34.2907 -				        return 4;
 34.2908 -					}
 34.2909 -
 34.2910 -// gui.gdscreenshot()
 34.2911 -//
 34.2912 -//  Returns a screen shot as a string in gd's v1 file format.
 34.2913 -//  This allows us to make screen shots available without gd installed locally.
 34.2914 -//  Users can also just grab pixels via substring selection.
 34.2915 -//
 34.2916 -//  I think...  Does lua support grabbing byte values from a string? // yes, string.byte(str,offset)
 34.2917 -//  Well, either way, just install gd and do what you like with it.
 34.2918 -//  It really is easier that way.
 34.2919 -
 34.2920 -// example: gd.createFromGdStr(gui.gdscreenshot()):png("outputimage.png")
 34.2921 -				    static int gui_gdscreenshot(lua_State *L)
 34.2922 -				    {
 34.2923 -				        int xofs = 0, yofs = 0, ppl = 240, width = 240, height = 160;
 34.2924 -				        if (!systemIsRunningGBA())
 34.2925 -				        {
 34.2926 -				            if (gbBorderOn)
 34.2927 -								xofs = 48, yofs = 40, ppl = 256;
 34.2928 -				            else
 34.2929 -								ppl = 160;
 34.2930 -				            width = 160, height = 144;
 34.2931 -						}
 34.2932 -
 34.2933 -				        yofs++;
 34.2934 -
 34.2935 -				        //int pitch = (((ppl * systemColorDepth + 7)>>3)+3)&~3;
 34.2936 -				        int	   pitch  = ppl * (systemColorDepth / 8) + (systemColorDepth == 24 ? 0 : 4);
 34.2937 -				        uint8 *screen = &pix[yofs * pitch + xofs * (systemColorDepth / 8)];
 34.2938 -
 34.2939 -				        int	  size = 11 + width * height * 4;
 34.2940 -				        char *str  = new char[size + 1];
 34.2941 -				        str[size] = 0;
 34.2942 -
 34.2943 -				        unsigned char *ptr = (unsigned char *)str;
 34.2944 -
 34.2945 -				        // GD format header for truecolor image (11 bytes)
 34.2946 -				        *ptr++ = (65534 >> 8) & 0xFF;
 34.2947 -				        *ptr++ = (65534) & 0xFF;
 34.2948 -				        *ptr++ = (width >> 8) & 0xFF;
 34.2949 -				        *ptr++ = (width) & 0xFF;
 34.2950 -				        *ptr++ = (height >> 8) & 0xFF;
 34.2951 -				        *ptr++ = (height) & 0xFF;
 34.2952 -				        *ptr++ = 1;
 34.2953 -				        *ptr++ = 255;
 34.2954 -				        *ptr++ = 255;
 34.2955 -				        *ptr++ = 255;
 34.2956 -				        *ptr++ = 255;
 34.2957 -
 34.2958 -				        GetColorFunc getColor;
 34.2959 -				        getColorIOFunc(systemColorDepth, &getColor, NULL);
 34.2960 -
 34.2961 -				        int x, y;
 34.2962 -				        for (y = 0; y < height; y++)
 34.2963 -				        {
 34.2964 -				            uint8 *s = &screen[y * pitch];
 34.2965 -				            for (x = 0; x < width; x++, s += systemColorDepth / 8)
 34.2966 -				            {
 34.2967 -				                uint8 r, g, b;
 34.2968 -				                getColor(s, &r, &g, &b);
 34.2969 -
 34.2970 -				                *ptr++ = 0;
 34.2971 -				                *ptr++ = r;
 34.2972 -				                *ptr++ = g;
 34.2973 -				                *ptr++ = b;
 34.2974 -							}
 34.2975 -						}
 34.2976 -
 34.2977 -				        lua_pushlstring(L, str, size);
 34.2978 -				        delete[] str;
 34.2979 -				        return 1;
 34.2980 -					}
 34.2981 -
 34.2982 -// gui.opacity(number alphaValue)
 34.2983 -// sets the transparency of subsequent draw calls
 34.2984 -// 0.0 is completely transparent, 1.0 is completely opaque
 34.2985 -// non-integer values are supported and meaningful, as are values greater than 1.0
 34.2986 -// it is not necessary to use this function to get transparency (or the less-recommended gui.transparency() either),
 34.2987 -// because you can provide an alpha value in the color argument of each draw call.
 34.2988 -
 34.2989 -// however, it can be convenient to be able to globally modify the drawing transparency
 34.2990 -				    static int gui_setopacity(lua_State *L)
 34.2991 -				    {
 34.2992 -				        double opacF = luaL_checknumber(L, 1);
 34.2993 -				        transparencyModifier = (int)(opacF * 255);
 34.2994 -				        if (transparencyModifier < 0)
 34.2995 -							transparencyModifier = 0;
 34.2996 -				        return 0;
 34.2997 -					}
 34.2998 -
 34.2999 -// gui.transparency(int strength)
 34.3000 -//
 34.3001 -
 34.3002 -//  0 = solid,
 34.3003 -				    static int gui_transparency(lua_State *L)
 34.3004 -				    {
 34.3005 -				        double trans = luaL_checknumber(L, 1);
 34.3006 -				        transparencyModifier = (int)((4.0 - trans) / 4.0 * 255);
 34.3007 -				        if (transparencyModifier < 0)
 34.3008 -							transparencyModifier = 0;
 34.3009 -				        return 0;
 34.3010 -					}
 34.3011 -
 34.3012 -				    static const uint32 Small_Font_Data[] =
 34.3013 -				    {
 34.3014 -				        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 32
 34.3015 -				        0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000000, 0x00000700, 0x00000000, // 33	!
 34.3016 -				        0x00000000, 0x00040002, 0x00050003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 34	"
 34.3017 -				        0x00000000, 0x00040002, 0x00050403, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 35	#
 34.3018 -				        0x00000000, 0x00040300, 0x00000403, 0x00000500, 0x00070600, 0x00000706, 0x00000000, // 36	$
 34.3019 -				        0x00000000, 0x00000002, 0x00050000, 0x00000500, 0x00000005, 0x00080000, 0x00000000, // 37	%
 34.3020 -				        0x00000000, 0x00000300, 0x00050003, 0x00000500, 0x00070005, 0x00080700, 0x00000000, // 38	&
 34.3021 -				        0x00000000, 0x00000300, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 39	'
 34.3022 -				        0x00000000, 0x00000300, 0x00000003, 0x00000004, 0x00000005, 0x00000700, 0x00000000, // 40	(
 34.3023 -				        0x00000000, 0x00000300, 0x00050000, 0x00060000, 0x00070000, 0x00000700, 0x00000000, // 41	)
 34.3024 -				        0x00000000, 0x00000000, 0x00000400, 0x00060504, 0x00000600, 0x00080006, 0x00000000, // 42	*
 34.3025 -				        0x00000000, 0x00000000, 0x00000400, 0x00060504, 0x00000600, 0x00000000, 0x00000000, // 43	+
 34.3026 -				        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000600, 0x00000700, 0x00000007, // 44	,
 34.3027 -				        0x00000000, 0x00000000, 0x00000000, 0x00060504, 0x00000000, 0x00000000, 0x00000000, // 45	-
 34.3028 -				        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000700, 0x00000000, // 46	.
 34.3029 -				        0x00030000, 0x00040000, 0x00000400, 0x00000500, 0x00000005, 0x00000006, 0x00000000, // 47	/
 34.3030 -				        0x00000000, 0x00000300, 0x00050003, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 48	0
 34.3031 -				        0x00000000, 0x00000300, 0x00000403, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 49	1
 34.3032 -				        0x00000000, 0x00000302, 0x00050000, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 50	2
 34.3033 -				        0x00000000, 0x00000302, 0x00050000, 0x00000504, 0x00070000, 0x00000706, 0x00000000, // 51	3
 34.3034 -				        0x00000000, 0x00000300, 0x00000003, 0x00060004, 0x00070605, 0x00080000, 0x00000000, // 52	4
 34.3035 -				        0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00070000, 0x00000706, 0x00000000, // 53	5
 34.3036 -				        0x00000000, 0x00000300, 0x00000003, 0x00000504, 0x00070005, 0x00000700, 0x00000000, // 54	6
 34.3037 -				        0x00000000, 0x00040302, 0x00050000, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 55	7
 34.3038 -				        0x00000000, 0x00000300, 0x00050003, 0x00000500, 0x00070005, 0x00000700, 0x00000000, // 56	8
 34.3039 -				        0x00000000, 0x00000300, 0x00050003, 0x00060500, 0x00070000, 0x00000700, 0x00000000, // 57	9
 34.3040 -				        0x00000000, 0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000700, 0x00000000, // 58	:
 34.3041 -				        0x00000000, 0x00000000, 0x00000000, 0x00000500, 0x00000000, 0x00000700, 0x00000007, // 59	;
 34.3042 -				        0x00000000, 0x00040000, 0x00000400, 0x00000004, 0x00000600, 0x00080000, 0x00000000, // 60	<
 34.3043 -				        0x00000000, 0x00000000, 0x00050403, 0x00000000, 0x00070605, 0x00000000, 0x00000000, // 61	=
 34.3044 -				        0x00000000, 0x00000002, 0x00000400, 0x00060000, 0x00000600, 0x00000006, 0x00000000, // 62	>
 34.3045 -				        0x00000000, 0x00000302, 0x00050000, 0x00000500, 0x00000000, 0x00000700, 0x00000000, // 63	?
 34.3046 -				        0x00000000, 0x00000300, 0x00050400, 0x00060004, 0x00070600, 0x00000000, 0x00000000, // 64	@
 34.3047 -				        0x00000000, 0x00000300, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 65	A
 34.3048 -				        0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00070005, 0x00000706, 0x00000000, // 66	B
 34.3049 -				        0x00000000, 0x00040300, 0x00000003, 0x00000004, 0x00000005, 0x00080700, 0x00000000, // 67	C
 34.3050 -				        0x00000000, 0x00000302, 0x00050003, 0x00060004, 0x00070005, 0x00000706, 0x00000000, // 68	D
 34.3051 -				        0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00000005, 0x00080706, 0x00000000, // 69	E
 34.3052 -				        0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 70	F
 34.3053 -				        0x00000000, 0x00040300, 0x00000003, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 71	G
 34.3054 -				        0x00000000, 0x00040002, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 72	H
 34.3055 -				        0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 73	I
 34.3056 -				        0x00000000, 0x00040000, 0x00050000, 0x00060000, 0x00070005, 0x00000700, 0x00000000, // 74	J
 34.3057 -				        0x00000000, 0x00040002, 0x00050003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 75	K
 34.3058 -				        0x00000000, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00080706, 0x00000000, // 76	l
 34.3059 -				        0x00000000, 0x00040002, 0x00050403, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 77	M
 34.3060 -				        0x00000000, 0x00000302, 0x00050003, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 78	N
 34.3061 -				        0x00000000, 0x00040302, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00000000, // 79	O
 34.3062 -				        0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 80	P
 34.3063 -				        0x00000000, 0x00040302, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00090000, // 81	Q
 34.3064 -				        0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 82	R
 34.3065 -				        0x00000000, 0x00040300, 0x00000003, 0x00000500, 0x00070000, 0x00000706, 0x00000000, // 83	S
 34.3066 -				        0x00000000, 0x00040302, 0x00000400, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 84	T
 34.3067 -				        0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00000000, // 85	U
 34.3068 -				        0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00000600, 0x00000700, 0x00000000, // 86	V
 34.3069 -				        0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 87	W
 34.3070 -				        0x00000000, 0x00040002, 0x00050003, 0x00000500, 0x00070005, 0x00080006, 0x00000000, // 88	X
 34.3071 -				        0x00000000, 0x00040002, 0x00050003, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 89	Y
 34.3072 -				        0x00000000, 0x00040302, 0x00050000, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 90	Z
 34.3073 -				        0x00000000, 0x00040300, 0x00000400, 0x00000500, 0x00000600, 0x00080700, 0x00000000, // 91	[
 34.3074 -				        0x00000000, 0x00000002, 0x00000400, 0x00000500, 0x00070000, 0x00080000, 0x00000000, // 92	'\'
 34.3075 -				        0x00000000, 0x00000302, 0x00000400, 0x00000500, 0x00000600, 0x00000706, 0x00000000, // 93	]
 34.3076 -				        0x00000000, 0x00000300, 0x00050003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 94	^
 34.3077 -				        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080706, 0x00000000, // 95	_
 34.3078 -				        0x00000000, 0x00000002, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 96	`
 34.3079 -				        0x00000000, 0x00000000, 0x00050400, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 97	a
 34.3080 -				        0x00000000, 0x00000002, 0x00000003, 0x00000504, 0x00070005, 0x00000706, 0x00000000, // 98	b
 34.3081 -				        0x00000000, 0x00000000, 0x00050400, 0x00000004, 0x00000005, 0x00080700, 0x00000000, // 99	c
 34.3082 -				        0x00000000, 0x00040000, 0x00050000, 0x00060500, 0x00070005, 0x00080700, 0x00000000, // 100	d
 34.3083 -				        0x00000000, 0x00000000, 0x00050400, 0x00060504, 0x00000005, 0x00080700, 0x00000000, // 101	e
 34.3084 -				        0x00000000, 0x00040300, 0x00000003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 102	f
 34.3085 -				        0x00000000, 0x00000000, 0x00050400, 0x00060004, 0x00070600, 0x00080000, 0x00000807, // 103	g
 34.3086 -				        0x00000000, 0x00000002, 0x00000003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 104	h
 34.3087 -				        0x00000000, 0x00000300, 0x00000000, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 105	i
 34.3088 -				        0x00000000, 0x00000300, 0x00000000, 0x00000500, 0x00000600, 0x00000700, 0x00000007, // 106	j
 34.3089 -				        0x00000000, 0x00000002, 0x00000003, 0x00060004, 0x00000605, 0x00080006, 0x00000000, // 107	k
 34.3090 -				        0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000600, 0x00080000, 0x00000000, // 108	l
 34.3091 -				        0x00000000, 0x00000000, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 109	m
 34.3092 -				        0x00000000, 0x00000000, 0x00000403, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 110	n
 34.3093 -				        0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 111	o
 34.3094 -				        0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00000605, 0x00000006, 0x00000007, // 112	p
 34.3095 -				        0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070600, 0x00080000, 0x00090000, // 113	q
 34.3096 -				        0x00000000, 0x00000000, 0x00050003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 114	r
 34.3097 -				        0x00000000, 0x00000000, 0x00050400, 0x00000004, 0x00070600, 0x00000706, 0x00000000, // 115	s
 34.3098 -				        0x00000000, 0x00000300, 0x00050403, 0x00000500, 0x00000600, 0x00080000, 0x00000000, // 116	t
 34.3099 -				        0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 117	u
 34.3100 -				        0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 118	v
 34.3101 -				        0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 119	w
 34.3102 -				        0x00000000, 0x00000000, 0x00050003, 0x00000500, 0x00070005, 0x00080006, 0x00000000, // 120	x
 34.3103 -				        0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00000600, 0x00000700, 0x00000007, // 121	y
 34.3104 -				        0x00000000, 0x00000000, 0x00050403, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 122	z
 34.3105 -				        0x00000000, 0x00040300, 0x00000400, 0x00000504, 0x00000600, 0x00080700, 0x00000000, // 123	{
 34.3106 -				        0x00000000, 0x00000300, 0x00000400, 0x00000000, 0x00000600, 0x00000700, 0x00000000, // 124	|
 34.3107 -				        0x00000000, 0x00000302, 0x00000400, 0x00060500, 0x00000600, 0x00000706, 0x00000000, // 125	}
 34.3108 -				        0x00000000, 0x00000302, 0x00050000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 126	~
 34.3109 -				        0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070605, 0x00000000, 0x00000000, // 127	
 34.3110 -				        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
 34.3111 -					};
 34.3112 -
 34.3113 -				    static void PutTextInternal(const char *str, int len, short x, short y, int color, int backcolor)
 34.3114 -				    {
 34.3115 -				        int Opac	 = (color >> 24) & 0xFF;
 34.3116 -				        int backOpac = (backcolor >> 24) & 0xFF;
 34.3117 -				        int origX	 = x;
 34.3118 -
 34.3119 -				        if (!Opac && !backOpac)
 34.3120 -							return;
 34.3121 -
 34.3122 -				        while (*str && len && y < LUA_SCREEN_HEIGHT)
 34.3123 -				        {
 34.3124 -				            int c = *str++;
 34.3125 -				            while (x > LUA_SCREEN_WIDTH && c != '\n')
 34.3126 -				            {
 34.3127 -				                c = *str;
 34.3128 -				                if (c == '\0')
 34.3129 -									break;
 34.3130 -				                str++;
 34.3131 -							}
 34.3132 -
 34.3133 -				            if (c == '\n')
 34.3134 -				            {
 34.3135 -				                x  = origX;
 34.3136 -				                y += 8;
 34.3137 -				                continue;
 34.3138 -							}
 34.3139 -				            else if (c == '\t') // just in case
 34.3140 -				            {
 34.3141 -				                const int tabSpace = 8;
 34.3142 -				                x += (tabSpace - (((x - origX) / 4) % tabSpace)) * 4;
 34.3143 -				                continue;
 34.3144 -							}
 34.3145 -
 34.3146 -				            if ((unsigned int)(c - 32) >= 96)
 34.3147 -								continue;
 34.3148 -
 34.3149 -				            const unsigned char *Cur_Glyph = (const unsigned char *) &Small_Font_Data + (c - 32) * 7 * 4;
 34.3150 -
 34.3151 -				            for (int y2 = 0; y2 < 8; y2++)
 34.3152 -				            {
 34.3153 -				                unsigned int glyphLine = *((unsigned int *)Cur_Glyph + y2);
 34.3154 -				                for (int x2 = -1; x2 < 4; x2++)
 34.3155 -				                {
 34.3156 -				                    int shift	  = x2 << 3;
 34.3157 -				                    int mask	  = 0xFF << shift;
 34.3158 -				                    int intensity = (glyphLine & mask) >> shift;
 34.3159 -
 34.3160 -				                    if (intensity && x2 >= 0 && y2 < 7)
 34.3161 -				                    {
 34.3162 -				                        //int xdraw = max(0,min(LUA_SCREEN_WIDTH - 1,x+x2));
 34.3163 -				                        //int ydraw = max(0,min(LUA_SCREEN_HEIGHT - 1,y+y2));
 34.3164 -				                        //gui_drawpixel_fast(xdraw, ydraw, color);
 34.3165 -				                        gui_drawpixel_internal(x + x2, y + y2, color);
 34.3166 -									}
 34.3167 -				                    else if (backOpac)
 34.3168 -				                    {
 34.3169 -				                        for (int y3 = max(0, y2 - 1); y3 <= min(6, y2 + 1); y3++)
 34.3170 -				                        {
 34.3171 -				                            unsigned int glyphLine = *((unsigned int *)Cur_Glyph + y3);
 34.3172 -				                            for (int x3 = max(0, x2 - 1); x3 <= min(3, x2 + 1); x3++)
 34.3173 -				                            {
 34.3174 -				                                int shift = x3 << 3;
 34.3175 -				                                int mask  = 0xFF << shift;
 34.3176 -				                                intensity |= (glyphLine & mask) >> shift;
 34.3177 -				                                if (intensity)
 34.3178 -													goto draw_outline;  // speedup?
 34.3179 -											}
 34.3180 -										}
 34.3181 -
 34.3182 -draw_outline:
 34.3183 -				                        if (intensity)
 34.3184 -				                        {
 34.3185 -				                            //int xdraw = max(0,min(LUA_SCREEN_WIDTH - 1,x+x2));
 34.3186 -				                            //int ydraw = max(0,min(LUA_SCREEN_HEIGHT - 1,y+y2));
 34.3187 -				                            //gui_drawpixel_fast(xdraw, ydraw, backcolor);
 34.3188 -				                            gui_drawpixel_internal(x + x2, y + y2, backcolor);
 34.3189 -										}
 34.3190 -									}
 34.3191 -								}
 34.3192 -							}
 34.3193 -
 34.3194 -				            x += 4;
 34.3195 -				            len--;
 34.3196 -						}
 34.3197 -					}
 34.3198 -
 34.3199 -				    static int strlinelen(const char *string)
 34.3200 -				    {
 34.3201 -				        const char *s = string;
 34.3202 -				        while (*s && *s != '\n')
 34.3203 -							s++;
 34.3204 -				        if (*s)
 34.3205 -							s++;
 34.3206 -				        return s - string;
 34.3207 -					}
 34.3208 -
 34.3209 -				    static void LuaDisplayString(const char *string, int y, int x, uint32 color, uint32 outlineColor)
 34.3210 -				    {
 34.3211 -				        if (!string)
 34.3212 -							return;
 34.3213 -
 34.3214 -				        gui_prepare();
 34.3215 -
 34.3216 -				        PutTextInternal(string, strlen(string), x, y, color, outlineColor);
 34.3217 -
 34.3218 -				        /*
 34.3219 -				           const char* ptr = string;
 34.3220 -				           while(*ptr && y < LUA_SCREEN_HEIGHT)
 34.3221 -				           {
 34.3222 -				            int len = strlinelen(ptr);
 34.3223 -				            int skip = 0;
 34.3224 -				            if(len < 1) len = 1;
 34.3225 -
 34.3226 -				            // break up the line if it's too long to display otherwise
 34.3227 -				            if(len > 63)
 34.3228 -				            {
 34.3229 -				                len = 63;
 34.3230 -				                const char* ptr2 = ptr + len-1;
 34.3231 -				                for(int j = len-1; j; j--, ptr2--)
 34.3232 -				                {
 34.3233 -				                    if(*ptr2 == ' ' || *ptr2 == '\t')
 34.3234 -				                    {
 34.3235 -				                        len = j;
 34.3236 -				                        skip = 1;
 34.3237 -				                        break;
 34.3238 -				                    }
 34.3239 -				                }
 34.3240 -				            }
 34.3241 -
 34.3242 -				            int xl = 0;
 34.3243 -				            int yl = 0;
 34.3244 -				            int xh = (LUA_SCREEN_WIDTH - 1 - 1) - 4*len;
 34.3245 -				            int yh = LUA_SCREEN_HEIGHT - 1;
 34.3246 -				            int x2 = min(max(x,xl),xh);
 34.3247 -				            int y2 = min(max(y,yl),yh);
 34.3248 -
 34.3249 -				            PutTextInternal(ptr,len,x2,y2,color,outlineColor);
 34.3250 -
 34.3251 -				            ptr += len + skip;
 34.3252 -				            y += 8;
 34.3253 -				           }
 34.3254 -				         */
 34.3255 -					}
 34.3256 -
 34.3257 -// gui.text(int x, int y, string msg)
 34.3258 -//
 34.3259 -//  Displays the given text on the screen, using the same font and techniques as the
 34.3260 -
 34.3261 -//  main HUD.
 34.3262 -				    static int gui_text(lua_State *L)
 34.3263 -				    {
 34.3264 -				        //extern int font_height;
 34.3265 -				        const char *msg;
 34.3266 -				        int			x, y;
 34.3267 -				        uint32		colour, borderColour;
 34.3268 -
 34.3269 -				        x = luaL_checkinteger(L, 1);
 34.3270 -				        y = luaL_checkinteger(L, 2);
 34.3271 -				        //msg = luaL_checkstring(L, 3);
 34.3272 -				        msg = toCString(L, 3);
 34.3273 -
 34.3274 -				        //	if (x < 0 || x >= LUA_SCREEN_WIDTH || y < 0 || y >= (LUA_SCREEN_HEIGHT - font_height))
 34.3275 -				        //		luaL_error(L,"bad coordinates");
 34.3276 -				        colour		 = gui_optcolour(L, 4, LUA_BUILD_PIXEL(255, 255, 255, 255));
 34.3277 -				        borderColour = gui_optcolour(L, 5, LUA_BUILD_PIXEL(255, 0, 0, 0));
 34.3278 -
 34.3279 -				        gui_prepare();
 34.3280 -
 34.3281 -				        LuaDisplayString(msg, y, x, colour, borderColour);
 34.3282 -
 34.3283 -				        return 0;
 34.3284 -					}
 34.3285 -
 34.3286 -// gui.gdoverlay([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0])
 34.3287 -//
 34.3288 -//  Overlays the given image on the screen.
 34.3289 -
 34.3290 -// example: gui.gdoverlay(gd.createFromPng("myimage.png"):gdStr())
 34.3291 -				    static int gui_gdoverlay(lua_State *L)
 34.3292 -				    {
 34.3293 -				        int argCount = lua_gettop(L);
 34.3294 -
 34.3295 -				        int xStartDst = 0;
 34.3296 -				        int yStartDst = 0;
 34.3297 -				        int xStartSrc = 0;
 34.3298 -				        int yStartSrc = 0;
 34.3299 -
 34.3300 -				        int index = 1;
 34.3301 -				        if (lua_type(L, index) == LUA_TNUMBER)
 34.3302 -				        {
 34.3303 -				            xStartDst = lua_tointeger(L, index++);
 34.3304 -				            if (lua_type(L, index) == LUA_TNUMBER)
 34.3305 -								yStartDst = lua_tointeger(L, index++);
 34.3306 -						}
 34.3307 -
 34.3308 -				        luaL_checktype(L, index, LUA_TSTRING);
 34.3309 -
 34.3310 -				        const unsigned char *ptr = (const unsigned char *)lua_tostring(L, index++);
 34.3311 -
 34.3312 -				        if (ptr[0] != 255 || (ptr[1] != 254 && ptr[1] != 255))
 34.3313 -							luaL_error(L, "bad image data");
 34.3314 -
 34.3315 -				        bool trueColor = (ptr[1] == 254);
 34.3316 -				        ptr += 2;
 34.3317 -
 34.3318 -				        int imgwidth = *ptr++ << 8;
 34.3319 -				        imgwidth |= *ptr++;
 34.3320 -
 34.3321 -				        int width	  = imgwidth;
 34.3322 -				        int imgheight = *ptr++ << 8;
 34.3323 -				        imgheight |= *ptr++;
 34.3324 -
 34.3325 -				        int height = imgheight;
 34.3326 -				        if ((!trueColor && *ptr) || (trueColor && !*ptr))
 34.3327 -							luaL_error(L, "bad image data");
 34.3328 -				        ptr++;
 34.3329 -
 34.3330 -				        int pitch = imgwidth * (trueColor ? 4 : 1);
 34.3331 -
 34.3332 -				        if ((argCount - index + 1) >= 4)
 34.3333 -				        {
 34.3334 -				            xStartSrc = luaL_checkinteger(L, index++);
 34.3335 -				            yStartSrc = luaL_checkinteger(L, index++);
 34.3336 -				            width	  = luaL_checkinteger(L, index++);
 34.3337 -				            height	  = luaL_checkinteger(L, index++);
 34.3338 -						}
 34.3339 -
 34.3340 -				        int alphaMul = transparencyModifier;
 34.3341 -				        if (lua_isnumber(L, index))
 34.3342 -							alphaMul = (int)(alphaMul * lua_tonumber(L, index++));
 34.3343 -				        if (alphaMul <= 0)
 34.3344 -							return 0;
 34.3345 -
 34.3346 -				        // since there aren't that many possible opacity levels,
 34.3347 -				        // do the opacity modification calculations beforehand instead of per pixel
 34.3348 -				        int opacMap[256];
 34.3349 -				        for (int i = 0; i < 128; i++)
 34.3350 -				        {
 34.3351 -				            int opac = 255 - ((i << 1) | (i & 1)); // gdAlphaMax = 127, not 255
 34.3352 -				            opac = (opac * alphaMul) / 255;
 34.3353 -				            if (opac < 0)
 34.3354 -								opac = 0;
 34.3355 -				            if (opac > 255)
 34.3356 -								opac = 255;
 34.3357 -				            opacMap[i] = opac;
 34.3358 -						}
 34.3359 -
 34.3360 -				        for (int i = 128; i < 256; i++)
 34.3361 -							opacMap[i] = 0;  // what should we do for them, actually?
 34.3362 -				        int colorsTotal = 0;
 34.3363 -				        if (!trueColor)
 34.3364 -				        {
 34.3365 -				            colorsTotal	 = *ptr++ << 8;
 34.3366 -				            colorsTotal |= *ptr++;
 34.3367 -						}
 34.3368 -
 34.3369 -				        int transparent = *ptr++ << 24;
 34.3370 -				        transparent |= *ptr++ << 16;
 34.3371 -				        transparent |= *ptr++ << 8;
 34.3372 -				        transparent |= *ptr++;
 34.3373 -				        struct
 34.3374 -				        {
 34.3375 -				            uint8 r, g, b, a;
 34.3376 -						} pal[256];
 34.3377 -				        if (!trueColor)
 34.3378 -							for (int i = 0; i < 256; i++)
 34.3379 -							{
 34.3380 -							    pal[i].r = *ptr++;
 34.3381 -							    pal[i].g = *ptr++;
 34.3382 -							    pal[i].b = *ptr++;
 34.3383 -							    pal[i].a = opacMap[*ptr++];
 34.3384 -							}
 34.3385 -
 34.3386 -				        // some of clippings
 34.3387 -				        if (xStartSrc < 0)
 34.3388 -				        {
 34.3389 -				            width	  += xStartSrc;
 34.3390 -				            xStartDst -= xStartSrc;
 34.3391 -				            xStartSrc  = 0;
 34.3392 -						}
 34.3393 -
 34.3394 -				        if (yStartSrc < 0)
 34.3395 -				        {
 34.3396 -				            height	  += yStartSrc;
 34.3397 -				            yStartDst -= yStartSrc;
 34.3398 -				            yStartSrc  = 0;
 34.3399 -						}
 34.3400 -
 34.3401 -				        if (xStartSrc + width >= imgwidth)
 34.3402 -							width = imgwidth - xStartSrc;
 34.3403 -				        if (yStartSrc + height >= imgheight)
 34.3404 -							height = imgheight - yStartSrc;
 34.3405 -				        if (xStartDst < 0)
 34.3406 -				        {
 34.3407 -				            width += xStartDst;
 34.3408 -				            if (width <= 0)
 34.3409 -								return 0;
 34.3410 -				            xStartSrc = -xStartDst;
 34.3411 -				            xStartDst = 0;
 34.3412 -						}
 34.3413 -
 34.3414 -				        if (yStartDst < 0)
 34.3415 -				        {
 34.3416 -				            height += yStartDst;
 34.3417 -				            if (height <= 0)
 34.3418 -								return 0;
 34.3419 -				            yStartSrc = -yStartDst;
 34.3420 -				            yStartDst = 0;
 34.3421 -						}
 34.3422 -
 34.3423 -				        if (xStartDst + width >= LUA_SCREEN_WIDTH)
 34.3424 -							width = LUA_SCREEN_WIDTH - xStartDst;
 34.3425 -				        if (yStartDst + height >= LUA_SCREEN_HEIGHT)
 34.3426 -							height = LUA_SCREEN_HEIGHT - yStartDst;
 34.3427 -				        if (width <= 0 || height <= 0)
 34.3428 -							return 0;  // out of screen or invalid size
 34.3429 -				        gui_prepare();
 34.3430 -
 34.3431 -				        const uint8 *pix = (const uint8 *)(&ptr[yStartSrc * pitch + (xStartSrc * (trueColor ? 4 : 1))]);
 34.3432 -				        int			 bytesToNextLine = pitch - (width * (trueColor ? 4 : 1));
 34.3433 -				        if (trueColor)
 34.3434 -				        {
 34.3435 -				            for (int y = yStartDst; y < height + yStartDst && y < LUA_SCREEN_HEIGHT; y++, pix += bytesToNextLine)
 34.3436 -				            {
 34.3437 -				                for (int x = xStartDst; x < width + xStartDst && x < LUA_SCREEN_WIDTH; x++, pix += 4)
 34.3438 -				                {
 34.3439 -				                    gui_drawpixel_fast(x, y, LUA_BUILD_PIXEL(opacMap[pix[0]], pix[1], pix[2], pix[3]));
 34.3440 -								}
 34.3441 -							}
 34.3442 -						}
 34.3443 -				        else
 34.3444 -				        {
 34.3445 -				            for (int y = yStartDst; y < height + yStartDst && y < LUA_SCREEN_HEIGHT; y++, pix += bytesToNextLine)
 34.3446 -				            {
 34.3447 -				                for (int x = xStartDst; x < width + xStartDst && x < LUA_SCREEN_WIDTH; x++, pix++)
 34.3448 -				                {
 34.3449 -				                    gui_drawpixel_fast(x, y, LUA_BUILD_PIXEL(pal[*pix].a, pal[*pix].r, pal[*pix].g, pal[*pix].b));
 34.3450 -								}
 34.3451 -							}
 34.3452 -						}
 34.3453 -
 34.3454 -				        return 0;
 34.3455 -					}
 34.3456 -
 34.3457 -// function gui.register(function f)
 34.3458 -//
 34.3459 -//  This function will be called just before a graphical update.
 34.3460 -//  More complicated, but doesn't suffer any frame delays.
 34.3461 -//  Nil will be accepted in place of a function to erase
 34.3462 -//  a previously registered function, and the previous function
 34.3463 -
 34.3464 -//  (if any) is returned, or nil if none.
 34.3465 -				    static int gui_register(lua_State *L)
 34.3466 -				    {
 34.3467 -				        // We'll do this straight up.
 34.3468 -				        // First set up the stack.
 34.3469 -				        lua_settop(L, 1);
 34.3470 -
 34.3471 -				        // Verify the validity of the entry
 34.3472 -				        if (!lua_isnil(L, 1))
 34.3473 -							luaL_checktype(L, 1, LUA_TFUNCTION);
 34.3474 -
 34.3475 -				        // Get the old value
 34.3476 -				        lua_getfield(L, LUA_REGISTRYINDEX, guiCallbackTable);
 34.3477 -
 34.3478 -				        // Save the new value
 34.3479 -				        lua_pushvalue(L, 1);
 34.3480 -				        lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable);
 34.3481 -
 34.3482 -				        // The old value is on top of the stack. Return it.
 34.3483 -				        return 1;
 34.3484 -					}
 34.3485 -
 34.3486 -// string gui.popup(string message, [string type = "ok"])
 34.3487 -//
 34.3488 -
 34.3489 -//  Popup dialog!
 34.3490 -				    int gui_popup(lua_State *L)
 34.3491 -				    {
 34.3492 -				        const char *message = luaL_checkstring(L, 1);
 34.3493 -				        const char *type	= luaL_optstring(L, 2, "ok");
 34.3494 -
 34.3495 -#if (defined(WIN32) && !defined(SDL))
 34.3496 -				        int t;
 34.3497 -				        if (strcmp(type, "ok") == 0)
 34.3498 -							t = MB_OK;
 34.3499 -				        else if (strcmp(type, "yesno") == 0)
 34.3500 -							t = MB_YESNO;
 34.3501 -				        else if (strcmp(type, "yesnocancel") == 0)
 34.3502 -							t = MB_YESNOCANCEL;
 34.3503 -				        else
 34.3504 -							return luaL_error(L, "invalid popup type \"%s\"", type);
 34.3505 -
 34.3506 -				        theApp.winCheckFullscreen();
 34.3507 -				        systemSoundClearBuffer();
 34.3508 -				        int result = AfxGetApp()->m_pMainWnd->MessageBox(message, "Lua Script Pop-up", t);
 34.3509 -
 34.3510 -				        lua_settop(L, 1);
 34.3511 -
 34.3512 -				        if (t != MB_OK)
 34.3513 -				        {
 34.3514 -				            if (result == IDYES)
 34.3515 -								lua_pushstring(L, "yes");
 34.3516 -				            else if (result == IDNO)
 34.3517 -								lua_pushstring(L, "no");
 34.3518 -				            else if (result == IDCANCEL)
 34.3519 -								lua_pushstring(L, "cancel");
 34.3520 -				            else
 34.3521 -								luaL_error(L, "win32 unrecognized return value %d", result);
 34.3522 -				            return 1;
 34.3523 -						}
 34.3524 -
 34.3525 -				        // else, we don't care.
 34.3526 -				        return 0;
 34.3527 -#else
 34.3528 -				        char *t;
 34.3529 -	#ifdef __linux
 34.3530 -				        // The Linux backend has a "FromPause" variable.
 34.3531 -				        // If set to 1, assume some known external event has screwed with the flow of time.
 34.3532 -				        // Since this pauses the emulator waiting for a response, we set it to 1.
 34.3533 -// FIXME: Well, actually it doesn't
 34.3534 -//	extern int FromPause;
 34.3535 -//	FromPause = 1;
 34.3536 -
 34.3537 -				        int pid; // appease compiler
 34.3538 -
 34.3539 -				        // Before doing any work, verify the correctness of the parameters.
 34.3540 -				        if (strcmp(type, "ok") == 0)
 34.3541 -							t = "OK:100";
 34.3542 -				        else if (strcmp(type, "yesno") == 0)
 34.3543 -							t = "Yes:100,No:101";
 34.3544 -				        else if (strcmp(type, "yesnocancel") == 0)
 34.3545 -							t = "Yes:100,No:101,Cancel:102";
 34.3546 -				        else
 34.3547 -							return luaL_error(L, "invalid popup type \"%s\"", type);
 34.3548 -
 34.3549 -				        // Can we find a copy of xmessage? Search the path.
 34.3550 -				        char *path = strdup(getenv("PATH"));
 34.3551 -
 34.3552 -				        char *current = path;
 34.3553 -
 34.3554 -				        char *colon;
 34.3555 -
 34.3556 -				        int found = 0;
 34.3557 -
 34.3558 -				        while (current)
 34.3559 -				        {
 34.3560 -				            colon = strchr(current, ':');
 34.3561 -
 34.3562 -				            // Clip off the colon.
 34.3563 -				            *colon++ = 0;
 34.3564 -
 34.3565 -				            int	  len	   = strlen(current);
 34.3566 -				            char *filename = (char *)malloc(len + 12); // always give excess
 34.3567 -				            snprintf(filename, len + 12, "%s/xmessage", current);
 34.3568 -
 34.3569 -				            if (access(filename, X_OK) == 0)
 34.3570 -				            {
 34.3571 -				                free(filename);
 34.3572 -				                found = 1;
 34.3573 -				                break;
 34.3574 -							}
 34.3575 -
 34.3576 -				            // Failed, move on.
 34.3577 -				            current = colon;
 34.3578 -				            free(filename);
 34.3579 -						}
 34.3580 -
 34.3581 -				        free(path);
 34.3582 -
 34.3583 -				        // We've found it?
 34.3584 -				        if (!found)
 34.3585 -							goto use_console;
 34.3586 -
 34.3587 -				        pid = fork();
 34.3588 -				        if (pid == 0)
 34.3589 -				        { // I'm the virgin sacrifice
 34.3590 -				          // I'm gonna be dead in a matter of microseconds anyways, so wasted memory doesn't matter to me.
 34.3591 -				          // Go ahead and abuse strdup.
 34.3592 -				            char *parameters[] = { "xmessage", "-buttons", t, strdup(message), NULL };
 34.3593 -
 34.3594 -				            execvp("xmessage", parameters);
 34.3595 -
 34.3596 -				            // Aw shitty
 34.3597 -				            perror("exec xmessage");
 34.3598 -				            exit(1);
 34.3599 -						}
 34.3600 -				        else if (pid < 0) // something went wrong!!! Oh hell... use the console
 34.3601 -							goto use_console;
 34.3602 -				        else
 34.3603 -				        {
 34.3604 -				            // We're the parent. Watch for the child.
 34.3605 -				            int r;
 34.3606 -				            int res = waitpid(pid, &r, 0);
 34.3607 -				            if (res < 0) // wtf?
 34.3608 -								goto use_console;
 34.3609 -
 34.3610 -				            // The return value gets copmlicated...
 34.3611 -				            if (!WIFEXITED(r))
 34.3612 -				            {
 34.3613 -				                luaL_error(L, "don't screw with my xmessage process!");
 34.3614 -							}
 34.3615 -
 34.3616 -				            r = WEXITSTATUS(r);
 34.3617 -
 34.3618 -				            // We assume it's worked.
 34.3619 -				            if (r == 0)
 34.3620 -				            {
 34.3621 -				                return 0; // no parameters for an OK
 34.3622 -							}
 34.3623 -
 34.3624 -				            if (r == 100)
 34.3625 -				            {
 34.3626 -				                lua_pushstring(L, "yes");
 34.3627 -				                return 1;
 34.3628 -							}
 34.3629 -
 34.3630 -				            if (r == 101)
 34.3631 -				            {
 34.3632 -				                lua_pushstring(L, "no");
 34.3633 -				                return 1;
 34.3634 -							}
 34.3635 -
 34.3636 -				            if (r == 102)
 34.3637 -				            {
 34.3638 -				                lua_pushstring(L, "cancel");
 34.3639 -				                return 1;
 34.3640 -							}
 34.3641 -
 34.3642 -				            // Wtf?
 34.3643 -				            return luaL_error(L, "popup failed due to unknown results involving xmessage (%d)", r);
 34.3644 -						}
 34.3645 -
 34.3646 -use_console:
 34.3647 -	#endif
 34.3648 -
 34.3649 -				        // All else has failed
 34.3650 -				        if (strcmp(type, "ok") == 0)
 34.3651 -							t = "";
 34.3652 -				        else if (strcmp(type, "yesno") == 0)
 34.3653 -							t = "yn";
 34.3654 -				        else if (strcmp(type, "yesnocancel") == 0)
 34.3655 -							t = "ync";
 34.3656 -				        else
 34.3657 -							return luaL_error(L, "invalid popup type \"%s\"", type);
 34.3658 -
 34.3659 -				        fprintf(stderr, "Lua Message: %s\n", message);
 34.3660 -
 34.3661 -				        while (true)
 34.3662 -				        {
 34.3663 -				            char buffer[64];
 34.3664 -
 34.3665 -				            // We don't want parameters
 34.3666 -				            if (!t[0])
 34.3667 -				            {
 34.3668 -				                fprintf(stderr, "[Press Enter]");
 34.3669 -				                fgets(buffer, sizeof(buffer), stdin);
 34.3670 -
 34.3671 -				                // We're done
 34.3672 -				                return 0;
 34.3673 -							}
 34.3674 -
 34.3675 -				            fprintf(stderr, "(%s): ", t);
 34.3676 -				            fgets(buffer, sizeof(buffer), stdin);
 34.3677 -
 34.3678 -				            // Check if the option is in the list
 34.3679 -				            if (strchr(t, tolower(buffer[0])))
 34.3680 -				            {
 34.3681 -				                switch (tolower(buffer[0]))
 34.3682 -				                {
 34.3683 -								case 'y':
 34.3684 -									lua_pushstring(L, "yes");
 34.3685 -									return 1;
 34.3686 -								case 'n':
 34.3687 -									lua_pushstring(L, "no");
 34.3688 -									return 1;
 34.3689 -								case 'c':
 34.3690 -									lua_pushstring(L, "cancel");
 34.3691 -									return 1;
 34.3692 -								default:
 34.3693 -									luaL_error(L, "internal logic error in console based prompts for gui.popup");
 34.3694 -								}
 34.3695 -							}
 34.3696 -
 34.3697 -				            // We fell through, so we assume the user answered wrong and prompt again.
 34.3698 -						}
 34.3699 -
 34.3700 -				        // Nothing here, since the only way out is in the loop.
 34.3701 -#endif
 34.3702 -					}
 34.3703 -
 34.3704 -#if (defined(WIN32) && !defined(SDL))
 34.3705 -				    const char  *s_keyToName[256] =
 34.3706 -				    {
 34.3707 -				        NULL,
 34.3708 -				        "leftclick",
 34.3709 -				        "rightclick",
 34.3710 -				        NULL,
 34.3711 -				        "middleclick",
 34.3712 -				        NULL,
 34.3713 -				        NULL,
 34.3714 -				        NULL,
 34.3715 -				        "backspace",
 34.3716 -				        "tab",
 34.3717 -				        NULL,
 34.3718 -				        NULL,
 34.3719 -				        NULL,
 34.3720 -				        "enter",
 34.3721 -				        NULL,
 34.3722 -				        NULL,
 34.3723 -				        "shift",       // 0x10
 34.3724 -				        "control",
 34.3725 -				        "alt",
 34.3726 -				        "pause",
 34.3727 -				        "capslock",
 34.3728 -				        NULL,
 34.3729 -				        NULL,
 34.3730 -				        NULL,
 34.3731 -				        NULL,
 34.3732 -				        NULL,
 34.3733 -				        NULL,
 34.3734 -				        "escape",
 34.3735 -				        NULL,
 34.3736 -				        NULL,
 34.3737 -				        NULL,
 34.3738 -				        NULL,
 34.3739 -				        "space",       // 0x20
 34.3740 -				        "pageup",
 34.3741 -				        "pagedown",
 34.3742 -				        "end",
 34.3743 -				        "home",
 34.3744 -				        "left",
 34.3745 -				        "up",
 34.3746 -				        "right",
 34.3747 -				        "down",
 34.3748 -				        NULL,
 34.3749 -				        NULL,
 34.3750 -				        NULL,
 34.3751 -				        NULL,
 34.3752 -				        "insert",
 34.3753 -				        "delete",
 34.3754 -				        NULL,
 34.3755 -				        "0",		   "1",			   "2",			   "3",			   "4",		   "5",		  "6",		 "7",		"8",	   "9",
 34.3756 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,
 34.3757 -				        "A",		   "B",			   "C",			   "D",			   "E",		   "F",		  "G",		 "H",		"I",	   "J",
 34.3758 -				        "K",		   "L",			   "M",			   "N",			   "O",		   "P",		  "Q",		 "R",		"S",	   "T",
 34.3759 -				        "U",		   "V",			   "W",			   "X",			   "Y",		   "Z",
 34.3760 -				        NULL,
 34.3761 -				        NULL,
 34.3762 -				        NULL,
 34.3763 -				        NULL,
 34.3764 -				        NULL,
 34.3765 -				        "numpad0",	   "numpad1",	   "numpad2",	   "numpad3",	   "numpad4",  "numpad5", "numpad6", "numpad7", "numpad8", "numpad9",
 34.3766 -				        "numpad*",	   "numpad+",
 34.3767 -				        NULL,
 34.3768 -				        "numpad-",	   "numpad.",	   "numpad/",
 34.3769 -				        "F1",		   "F2",		   "F3",		   "F4",		   "F5",	   "F6",	  "F7",		 "F8",		"F9",	   "F10",	  "F11",
 34.3770 -				        "F12",
 34.3771 -				        "F13",		   "F14",		   "F15",		   "F16",		   "F17",	   "F18",	  "F19",	 "F20",		"F21",	   "F22",	  "F23",
 34.3772 -				        "F24",
 34.3773 -				        NULL,
 34.3774 -				        NULL,
 34.3775 -				        NULL,
 34.3776 -				        NULL,
 34.3777 -				        NULL,
 34.3778 -				        NULL,
 34.3779 -				        NULL,
 34.3780 -				        NULL,
 34.3781 -				        "numlock",
 34.3782 -				        "scrolllock",
 34.3783 -				        NULL,          // 0x92
 34.3784 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,		NULL,	   NULL,	  NULL,
 34.3785 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,		NULL,	   NULL,
 34.3786 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,		NULL,
 34.3787 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,
 34.3788 -				        NULL,          // 0xB9
 34.3789 -				        "semicolon",
 34.3790 -				        "plus",
 34.3791 -				        "comma",
 34.3792 -				        "minus",
 34.3793 -				        "period",
 34.3794 -				        "slash",
 34.3795 -				        "tilde",
 34.3796 -				        NULL,          // 0xC1
 34.3797 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,		NULL,
 34.3798 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,		 NULL,
 34.3799 -				        NULL,		   NULL,		   NULL,		   NULL,		   NULL,	   NULL,	  NULL,
 34.3800 -				        NULL,          // 0xDA
 34.3801 -				        "leftbracket",
 34.3802 -				        "backslash",
 34.3803 -				        "rightbracket",
 34.3804 -				        "quote",
 34.3805 -					};
 34.3806 -#endif
 34.3807 -
 34.3808 -// input.get()
 34.3809 -// takes no input, returns a lua table of entries representing the current input state,
 34.3810 -// independent of the joypad buttons the emulated game thinks are pressed
 34.3811 -// for example:
 34.3812 -//   if the user is holding the W key and the left mouse button
 34.3813 -//   and has the mouse at the bottom-right corner of the game screen,
 34.3814 -
 34.3815 -//   then this would return {W=true, leftclick=true, xmouse=255, ymouse=223}
 34.3816 -				    static int input_getcurrentinputstatus(lua_State *L)
 34.3817 -				    {
 34.3818 -				        lua_newtable(L);
 34.3819 -
 34.3820 -#if (defined(WIN32) && !defined(SDL))
 34.3821 -				        // keyboard and mouse button status
 34.3822 -				        {
 34.3823 -				            unsigned char keys[256];
 34.3824 -				            if (true /*!GUI.BackgroundInput*/) // TODO: background input
 34.3825 -				            {
 34.3826 -				                if (GetKeyboardState(keys))
 34.3827 -				                {
 34.3828 -				                    for (int i = 1; i < 255; i++)
 34.3829 -				                    {
 34.3830 -				                        int mask = (i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL) ? 0x01 : 0x80;
 34.3831 -				                        if (keys[i] & mask)
 34.3832 -				                        {
 34.3833 -				                            const char *name = s_keyToName[i];
 34.3834 -				                            if (name)
 34.3835 -				                            {
 34.3836 -				                                lua_pushboolean(L, true);
 34.3837 -				                                lua_setfield(L, -2, name);
 34.3838 -											}
 34.3839 -										}
 34.3840 -									}
 34.3841 -								}
 34.3842 -							}
 34.3843 -				            else // use a slightly different method that will detect background input:
 34.3844 -				            {
 34.3845 -				                for (int i = 1; i < 255; i++)
 34.3846 -				                {
 34.3847 -				                    const char *name = s_keyToName[i];
 34.3848 -				                    if (name)
 34.3849 -				                    {
 34.3850 -				                        int active;
 34.3851 -				                        if (i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL)
 34.3852 -											active = GetKeyState(i) & 0x01;
 34.3853 -				                        else
 34.3854 -											active = GetAsyncKeyState(i) & 0x8000;
 34.3855 -				                        if (active)
 34.3856 -				                        {
 34.3857 -				                            lua_pushboolean(L, true);
 34.3858 -				                            lua_setfield(L, -2, name);
 34.3859 -										}
 34.3860 -									}
 34.3861 -								}
 34.3862 -							}
 34.3863 -						}
 34.3864 -
 34.3865 -				        // mouse position in game screen pixel coordinates
 34.3866 -				        {
 34.3867 -				            POINT mouse;
 34.3868 -
 34.3869 -				            int xofs = 0, yofs = 0, width = 240, height = 160;
 34.3870 -				            if (!systemIsRunningGBA())
 34.3871 -				            {
 34.3872 -				                if (gbBorderOn)
 34.3873 -									width = 256, height = 224, xofs = 48, yofs = 40;
 34.3874 -				                else
 34.3875 -									width = 160, height = 144;
 34.3876 -							}
 34.3877 -
 34.3878 -				            GetCursorPos(&mouse);
 34.3879 -				            AfxGetApp()->m_pMainWnd->ScreenToClient(&mouse);
 34.3880 -
 34.3881 -				            // game screen is always fully stretched to window size,
 34.3882 -				            // with no aspect rate correction, or something like that.
 34.3883 -				            RECT clientRect;
 34.3884 -				            AfxGetApp()->m_pMainWnd->GetClientRect(&clientRect);
 34.3885 -
 34.3886 -				            int wndWidth  = clientRect.right - clientRect.left;
 34.3887 -				            int wndHeight = clientRect.bottom - clientRect.top;
 34.3888 -				            mouse.x = (LONG) (mouse.x * ((float)width / wndWidth)) - xofs;
 34.3889 -				            mouse.y = (LONG) (mouse.y * ((float)height / wndHeight)) - yofs;
 34.3890 -
 34.3891 -				            lua_pushinteger(L, mouse.x);
 34.3892 -				            lua_setfield(L, -2, "xmouse");
 34.3893 -				            lua_pushinteger(L, mouse.y);
 34.3894 -				            lua_setfield(L, -2, "ymouse");
 34.3895 -						}
 34.3896 -
 34.3897 -#else
 34.3898 -				        // NYI (well, return an empty table)
 34.3899 -#endif
 34.3900 -				        return 1;
 34.3901 -					}
 34.3902 -
 34.3903 -				    static int avi_framecount(lua_State *L)
 34.3904 -				    {
 34.3905 -	#ifdef WIN32
 34.3906 -				        if (theApp.aviRecorder != NULL)
 34.3907 -				        {
 34.3908 -				            lua_pushinteger(L, theApp.aviRecorder->videoFrames());
 34.3909 -						}
 34.3910 -				        else
 34.3911 -	#endif
 34.3912 -				        {
 34.3913 -				            lua_pushinteger(L, 0);
 34.3914 -						}
 34.3915 -				        return 1;
 34.3916 -					}
 34.3917 -
 34.3918 -				    static int avi_pause(lua_State *L)
 34.3919 -				    {
 34.3920 -	#ifdef WIN32
 34.3921 -				        if (theApp.aviRecorder != NULL)
 34.3922 -							theApp.aviRecorder->Pause(true);
 34.3923 -	#endif
 34.3924 -				        return 1;
 34.3925 -					}
 34.3926 -
 34.3927 -				    static int avi_resume(lua_State *L)
 34.3928 -				    {
 34.3929 -	#ifdef WIN32
 34.3930 -				        if (theApp.aviRecorder != NULL)
 34.3931 -							theApp.aviRecorder->Pause(false);
 34.3932 -	#endif
 34.3933 -				        return 1;
 34.3934 -					}
 34.3935 -
 34.3936 -					static int sound_get(lua_State *L)
 34.3937 -					{
 34.3938 -						extern int32 soundLevel1;
 34.3939 -						extern int32 soundLevel2;
 34.3940 -						extern int32 soundBalance;
 34.3941 -						extern int32 soundMasterOn;
 34.3942 -						extern int32 soundVIN;
 34.3943 -						extern int32 sound1On;
 34.3944 -						extern int32 sound1EnvelopeVolume;
 34.3945 -						extern int32 sound2On;
 34.3946 -						extern int32 sound2EnvelopeVolume;
 34.3947 -						extern int32 sound3On;
 34.3948 -						extern int32 sound3OutputLevel;
 34.3949 -						extern int32 sound3Bank;
 34.3950 -						extern int32 sound3DataSize;
 34.3951 -						extern int32 sound3ForcedOutput;
 34.3952 -						extern int32 sound4On;
 34.3953 -						extern int32 sound4EnvelopeVolume;
 34.3954 -						extern u8 sound3WaveRam[0x20];
 34.3955 -
 34.3956 -						int freqReg;
 34.3957 -						double freq;
 34.3958 -						double leftvolscale;
 34.3959 -						double rightvolscale;
 34.3960 -						double panpot;
 34.3961 -						bool gba = systemIsRunningGBA();
 34.3962 -						u8* gbMem = gba ? ioMem : gbMemory;
 34.3963 -						const int rNR10 = gba ? 0x60 : 0xff10;
 34.3964 -						const int rNR11 = gba ? 0x62 : 0xff11;
 34.3965 -						const int rNR12 = gba ? 0x63 : 0xff12;
 34.3966 -						const int rNR13 = gba ? 0x64 : 0xff13;
 34.3967 -						const int rNR14 = gba ? 0x65 : 0xff14;
 34.3968 -						const int rNR21 = gba ? 0x68 : 0xff16;
 34.3969 -						const int rNR22 = gba ? 0x69 : 0xff17;
 34.3970 -						const int rNR23 = gba ? 0x6c : 0xff18;
 34.3971 -						const int rNR24 = gba ? 0x6d : 0xff19;
 34.3972 -						const int rNR30 = gba ? 0x70 : 0xff1a;
 34.3973 -						const int rNR31 = gba ? 0x72 : 0xff1b;
 34.3974 -						const int rNR32 = gba ? 0x73 : 0xff1c;
 34.3975 -						const int rNR33 = gba ? 0x74 : 0xff1d;
 34.3976 -						const int rNR34 = gba ? 0x75 : 0xff1e;
 34.3977 -						const int rNR41 = gba ? 0x78 : 0xff20;
 34.3978 -						const int rNR42 = gba ? 0x79 : 0xff21;
 34.3979 -						const int rNR43 = gba ? 0x7c : 0xff22;
 34.3980 -						const int rNR44 = gba ? 0x7d : 0xff23;
 34.3981 -						const int rNR50 = gba ? 0x80 : 0xff24;
 34.3982 -						const int rNR51 = gba ? 0x81 : 0xff25;
 34.3983 -						const int rNR52 = gba ? 0x84 : 0xff26;
 34.3984 -						const int rWAVE_RAM = gba ? 0x90 : 0xff30;
 34.3985 -
 34.3986 -						const int32 _soundVIN = 0x88; // gba ? 0x88 : soundVIN;
 34.3987 -						const bool soundVINLeft = ((_soundVIN & 0x80) != 0);
 34.3988 -						const bool soundVINRight = ((_soundVIN & 0x08) != 0);
 34.3989 -
 34.3990 -						lua_newtable(L);
 34.3991 -
 34.3992 -						// square1
 34.3993 -						lua_newtable(L);
 34.3994 -						if(sound1On == 0 || soundMasterOn == 0)
 34.3995 -						{
 34.3996 -							lua_pushnumber(L, 0.0);
 34.3997 -							panpot = 0.5;
 34.3998 -						}
 34.3999 -						else
 34.4000 -						{
 34.4001 -							double envVolume = sound1EnvelopeVolume / 15.0;
 34.4002 -							if (soundVINLeft && (soundBalance & 0x10) != 0)
 34.4003 -								leftvolscale = ((soundLevel2 / 7.0) * envVolume);
 34.4004 -							else
 34.4005 -								leftvolscale = 0.0;
 34.4006 -							if (soundVINRight && (soundBalance & 0x01) != 0)
 34.4007 -								rightvolscale = ((soundLevel1 / 7.0) * envVolume);
 34.4008 -							else
 34.4009 -								rightvolscale = 0.0;
 34.4010 -							if ((leftvolscale + rightvolscale) != 0)
 34.4011 -								panpot = rightvolscale / (leftvolscale + rightvolscale);
 34.4012 -							else
 34.4013 -								panpot = 0.5;
 34.4014 -							lua_pushnumber(L, (leftvolscale + rightvolscale) / 2.0);
 34.4015 -						}
 34.4016 -						lua_setfield(L, -2, "volume");
 34.4017 -						lua_pushnumber(L, panpot);
 34.4018 -						lua_setfield(L, -2, "panpot");
 34.4019 -						freqReg = (((int)(gbMem[rNR14] & 7) << 8) | gbMem[rNR13]);
 34.4020 -						freq = 131072.0 / (2048 - freqReg);
 34.4021 -						lua_pushnumber(L, freq);
 34.4022 -						lua_setfield(L, -2, "frequency");
 34.4023 -						lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
 34.4024 -						lua_setfield(L, -2, "midikey");
 34.4025 -						lua_pushinteger(L, (gbMem[rNR11] & 0xC0) >> 6);
 34.4026 -						lua_setfield(L, -2, "duty");
 34.4027 -						lua_newtable(L);
 34.4028 -						lua_pushinteger(L, freqReg);
 34.4029 -						lua_setfield(L, -2, "frequency");
 34.4030 -						lua_setfield(L, -2, "regs");
 34.4031 -						lua_setfield(L, -2, "square1");
 34.4032 -						// square2
 34.4033 -						lua_newtable(L);
 34.4034 -						if(sound2On == 0 || soundMasterOn == 0)
 34.4035 -						{
 34.4036 -							lua_pushnumber(L, 0.0);
 34.4037 -							panpot = 0.5;
 34.4038 -						}
 34.4039 -						else
 34.4040 -						{
 34.4041 -							double envVolume = sound2EnvelopeVolume / 15.0;
 34.4042 -							if (soundVINLeft && (soundBalance & 0x20) != 0)
 34.4043 -								leftvolscale = ((soundLevel2 / 7.0) * envVolume);
 34.4044 -							else
 34.4045 -								leftvolscale = 0.0;
 34.4046 -							if (soundVINRight && (soundBalance & 0x02) != 0)
 34.4047 -								rightvolscale = ((soundLevel1 / 7.0) * envVolume);
 34.4048 -							else
 34.4049 -								rightvolscale = 0.0;
 34.4050 -							if ((leftvolscale + rightvolscale) != 0)
 34.4051 -								panpot = rightvolscale / (leftvolscale + rightvolscale);
 34.4052 -							else
 34.4053 -								panpot = 0.5;
 34.4054 -							lua_pushnumber(L, (leftvolscale + rightvolscale) / 2.0);
 34.4055 -						}
 34.4056 -						lua_setfield(L, -2, "volume");
 34.4057 -						lua_pushnumber(L, panpot);
 34.4058 -						lua_setfield(L, -2, "panpot");
 34.4059 -						freqReg = (((int)(gbMem[rNR24] & 7) << 8) | gbMem[rNR23]);
 34.4060 -						freq = 131072.0 / (2048 - freqReg);
 34.4061 -						lua_pushnumber(L, freq);
 34.4062 -						lua_setfield(L, -2, "frequency");
 34.4063 -						lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
 34.4064 -						lua_setfield(L, -2, "midikey");
 34.4065 -						lua_pushinteger(L, (gbMem[rNR21] & 0xC0) >> 6);
 34.4066 -						lua_setfield(L, -2, "duty");
 34.4067 -						lua_newtable(L);
 34.4068 -						lua_pushinteger(L, freqReg);
 34.4069 -						lua_setfield(L, -2, "frequency");
 34.4070 -						lua_setfield(L, -2, "regs");
 34.4071 -						lua_setfield(L, -2, "square2");
 34.4072 -						// wavememory
 34.4073 -						lua_newtable(L);
 34.4074 -						if(sound3On == 0 || soundMasterOn == 0)
 34.4075 -						{
 34.4076 -							lua_pushnumber(L, 0.0);
 34.4077 -							panpot = 0.5;
 34.4078 -						}
 34.4079 -						else
 34.4080 -						{
 34.4081 -							double envVolume;
 34.4082 -							if (gba && sound3ForcedOutput != 0)
 34.4083 -								envVolume = 0.75;
 34.4084 -							else
 34.4085 -							{
 34.4086 -								double volTable[4] = { 0.0, 1.0, 0.5, 0.25 };
 34.4087 -								envVolume = volTable[sound3OutputLevel & 3];
 34.4088 -							}
 34.4089 -
 34.4090 -							if (soundVINLeft && (soundBalance & 0x40) != 0)
 34.4091 -								leftvolscale = ((soundLevel2 / 7.0) * envVolume);
 34.4092 -							else
 34.4093 -								leftvolscale = 0.0;
 34.4094 -							if (soundVINRight && (soundBalance & 0x04) != 0)
 34.4095 -								rightvolscale = ((soundLevel1 / 7.0) * envVolume);
 34.4096 -							else
 34.4097 -								rightvolscale = 0.0;
 34.4098 -							if ((leftvolscale + rightvolscale) != 0)
 34.4099 -								panpot = rightvolscale / (leftvolscale + rightvolscale);
 34.4100 -							else
 34.4101 -								panpot = 0.5;
 34.4102 -							lua_pushnumber(L, (leftvolscale + rightvolscale) / 2.0);
 34.4103 -						}
 34.4104 -						lua_setfield(L, -2, "volume");
 34.4105 -						lua_pushnumber(L, panpot);
 34.4106 -						lua_setfield(L, -2, "panpot");
 34.4107 -						int waveMemSamples = 32;
 34.4108 -						if (gba)
 34.4109 -						{
 34.4110 -							lua_pushlstring(L, (const char *) &sound3WaveRam[sound3Bank * 0x10], sound3DataSize ? 0x20 : 0x10);
 34.4111 -							waveMemSamples = sound3DataSize ? 64 : 32;
 34.4112 -						}
 34.4113 -						else
 34.4114 -						{
 34.4115 -							lua_pushlstring(L, (const char *) &gbMem[rWAVE_RAM], 0x10);
 34.4116 -						}
 34.4117 -						lua_setfield(L, -2, "waveform");
 34.4118 -						freqReg = (((int)(gbMem[rNR34] & 7) << 8) | gbMem[rNR33]);
 34.4119 -						freq = 2097152.0 / (waveMemSamples * (2048 - freqReg));
 34.4120 -						lua_pushnumber(L, freq);
 34.4121 -						lua_setfield(L, -2, "frequency");
 34.4122 -						lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
 34.4123 -						lua_setfield(L, -2, "midikey");
 34.4124 -						lua_newtable(L);
 34.4125 -						lua_pushinteger(L, freqReg);
 34.4126 -						lua_setfield(L, -2, "frequency");
 34.4127 -						lua_setfield(L, -2, "regs");
 34.4128 -						lua_setfield(L, -2, "wavememory");
 34.4129 -						// noise
 34.4130 -						lua_newtable(L);
 34.4131 -						if(sound4On == 0 || soundMasterOn == 0)
 34.4132 -						{
 34.4133 -							lua_pushnumber(L, 0.0);
 34.4134 -							panpot = 0.5;
 34.4135 -						}
 34.4136 -						else
 34.4137 -						{
 34.4138 -							double envVolume = sound4EnvelopeVolume / 15.0;
 34.4139 -							if (soundVINLeft && (soundBalance & 0x80) != 0)
 34.4140 -								leftvolscale = ((soundLevel2 / 7.0) * envVolume);
 34.4141 -							else
 34.4142 -								leftvolscale = 0.0;
 34.4143 -							if (soundVINRight && (soundBalance & 0x08) != 0)
 34.4144 -								rightvolscale = ((soundLevel1 / 7.0) * envVolume);
 34.4145 -							else
 34.4146 -								rightvolscale = 0.0;
 34.4147 -							if ((leftvolscale + rightvolscale) != 0)
 34.4148 -								panpot = rightvolscale / (leftvolscale + rightvolscale);
 34.4149 -							else
 34.4150 -								panpot = 0.5;
 34.4151 -							lua_pushnumber(L, (leftvolscale + rightvolscale) / 2.0);
 34.4152 -						}
 34.4153 -						lua_setfield(L, -2, "volume");
 34.4154 -						lua_pushnumber(L, panpot);
 34.4155 -						lua_setfield(L, -2, "panpot");
 34.4156 -						const int gbNoiseFreqTable[8] = { 1, 2, 4, 6, 8, 10, 12, 14 };
 34.4157 -						freqReg = gbNoiseFreqTable[gbMem[rNR43] & 7] << (1 + (gbMem[rNR43] >> 4));
 34.4158 -						lua_pushboolean(L, (gbMem[rNR43] & 8) != 0);
 34.4159 -						lua_setfield(L, -2, "short");
 34.4160 -						freq = 1048576.0 / freqReg;
 34.4161 -						lua_pushnumber(L, freq);
 34.4162 -						lua_setfield(L, -2, "frequency");
 34.4163 -						lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
 34.4164 -						lua_setfield(L, -2, "midikey");
 34.4165 -						lua_newtable(L);
 34.4166 -						lua_pushinteger(L, freqReg);
 34.4167 -						lua_setfield(L, -2, "frequency");
 34.4168 -						lua_setfield(L, -2, "regs");
 34.4169 -						lua_setfield(L, -2, "noise");
 34.4170 -
 34.4171 -						return 1;
 34.4172 -					}
 34.4173 -
 34.4174 -// same as math.random, but uses SFMT instead of C rand()
 34.4175 -// FIXME: this function doesn't care multi-instance,
 34.4176 -
 34.4177 -//        original math.random either though (Lua 5.1)
 34.4178 -				    static int sfmt_random(lua_State *L)
 34.4179 -				    {
 34.4180 -				        lua_Number r = (lua_Number) genrand_real2();
 34.4181 -				        switch (lua_gettop(L))
 34.4182 -				        { // check number of arguments
 34.4183 -						case 0:
 34.4184 -							{ // no arguments
 34.4185 -							    lua_pushnumber(L, r); // Number between 0 and 1
 34.4186 -							    break;
 34.4187 -							}
 34.4188 -
 34.4189 -						case 1:
 34.4190 -							{ // only upper limit
 34.4191 -							    int u = luaL_checkint(L, 1);
 34.4192 -							    luaL_argcheck(L, 1 <= u, 1, "interval is empty");
 34.4193 -							    lua_pushnumber(L, floor(r * u) + 1); // int between 1 and `u'
 34.4194 -							    break;
 34.4195 -							}
 34.4196 -
 34.4197 -						case 2:
 34.4198 -							{ // lower and upper limits
 34.4199 -							    int l = luaL_checkint(L, 1);
 34.4200 -							    int u = luaL_checkint(L, 2);
 34.4201 -							    luaL_argcheck(L, l <= u, 2, "interval is empty");
 34.4202 -							    lua_pushnumber(L, floor(r * (u - l + 1)) + l); // int between `l' and `u'
 34.4203 -							    break;
 34.4204 -							}
 34.4205 -
 34.4206 -						default:
 34.4207 -							return luaL_error(L, "wrong number of arguments");
 34.4208 -						}
 34.4209 -
 34.4210 -				        return 1;
 34.4211 -					}
 34.4212 -
 34.4213 -// same as math.randomseed, but uses SFMT instead of C srand()
 34.4214 -// FIXME: this function doesn't care multi-instance,
 34.4215 -
 34.4216 -//        original math.randomseed either though (Lua 5.1)
 34.4217 -				    static int sfmt_randomseed(lua_State *L)
 34.4218 -				    {
 34.4219 -				        init_gen_rand(luaL_checkint(L, 1));
 34.4220 -				        return 0;
 34.4221 -					}
 34.4222 -
 34.4223 -// the following bit operations are ported from LuaBitOp 1.0.1,
 34.4224 -// because it can handle the sign bit (bit 31) correctly.
 34.4225 -
 34.4226 -/*
 34.4227 -** Lua BitOp -- a bit operations library for Lua 5.1.
 34.4228 -** http://bitop.luajit.org/
 34.4229 -**
 34.4230 -** Copyright (C) 2008-2009 Mike Pall. All rights reserved.
 34.4231 -**
 34.4232 -** Permission is hereby granted, free of charge, to any person obtaining
 34.4233 -** a copy of this software and associated documentation files (the
 34.4234 -** "Software"), to deal in the Software without restriction, including
 34.4235 -** without limitation the rights to use, copy, modify, merge, publish,
 34.4236 -** distribute, sublicense, and/or sell copies of the Software, and to
 34.4237 -** permit persons to whom the Software is furnished to do so, subject to
 34.4238 -** the following conditions:
 34.4239 -**
 34.4240 -** The above copyright notice and this permission notice shall be
 34.4241 -** included in all copies or substantial portions of the Software.
 34.4242 -**
 34.4243 -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 34.4244 -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 34.4245 -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 34.4246 -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 34.4247 -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 34.4248 -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 34.4249 -** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 34.4250 -**
 34.4251 -** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
 34.4252 -*/
 34.4253 -
 34.4254 -#ifdef _MSC_VER
 34.4255 -/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */
 34.4256 -				    typedef __int32			 int32_t;
 34.4257 -				    typedef unsigned __int32 uint32_t;
 34.4258 -				    typedef unsigned __int64 uint64_t;
 34.4259 -#else
 34.4260 -#include <stdint.h>
 34.4261 -#endif
 34.4262 -
 34.4263 -				    typedef int32_t	 SBits;
 34.4264 -				    typedef uint32_t UBits;
 34.4265 -
 34.4266 -				    typedef union
 34.4267 -				    {
 34.4268 -				        lua_Number n;
 34.4269 -#ifdef LUA_NUMBER_DOUBLE
 34.4270 -				        uint64_t b;
 34.4271 -#else
 34.4272 -				        UBits b;
 34.4273 -#endif
 34.4274 -					} BitNum;
 34.4275 -
 34.4276 -/* Convert argument to bit type. */
 34.4277 -				    static UBits barg(lua_State *L, int idx)
 34.4278 -				    {
 34.4279 -				        BitNum bn;
 34.4280 -				        UBits  b;
 34.4281 -				        bn.n = lua_tonumber(L, idx);
 34.4282 -#if defined(LUA_NUMBER_DOUBLE)
 34.4283 -				        bn.n += 6755399441055744.0; /* 2^52+2^51 */
 34.4284 -#ifdef SWAPPED_DOUBLE
 34.4285 -				        b = (UBits)(bn.b >> 32);
 34.4286 -#else
 34.4287 -				        b = (UBits)(bn.b & 0xffffffff);
 34.4288 -#endif
 34.4289 -#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \
 34.4290 -				        defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
 34.4291 -				        defined(LUA_NUMBER_LLONG)
 34.4292 -				        if (sizeof(UBits) == sizeof(lua_Number))
 34.4293 -							b = bn.b;
 34.4294 -				        else
 34.4295 -							b = (UBits)(SBits)bn.n;
 34.4296 -#elif defined(LUA_NUMBER_FLOAT)
 34.4297 -#error "A 'float' lua_Number type is incompatible with this library"
 34.4298 -#else
 34.4299 -#error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
 34.4300 -#endif
 34.4301 -				        if (b == 0 && !lua_isnumber(L, idx))
 34.4302 -							luaL_typerror(L, idx, "number");
 34.4303 -				        return b;
 34.4304 -					}
 34.4305 -
 34.4306 -/* Return bit type. */
 34.4307 -#define BRET(b)  lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1;
 34.4308 -
 34.4309 -				    static int bit_tobit(lua_State *L) { BRET(barg(L, 1)) }
 34.4310 -				    static int bit_bnot(lua_State *L) { BRET(~barg(L, 1)) }
 34.4311 -
 34.4312 -#define BIT_OP(func, opr) \
 34.4313 -	static int func(lua_State * L) { int i; UBits b = barg(L, 1); \
 34.4314 -				                     for (i = lua_gettop(L); i > 1; i--) \
 34.4315 -										 b opr barg(L, i); BRET(b) }
 34.4316 -				    BIT_OP(bit_band, &= )
 34.4317 -				    BIT_OP(bit_bor, |= )
 34.4318 -				    BIT_OP(bit_bxor, ^= )
 34.4319 -
 34.4320 -#define bshl(b, n)  (b << n)
 34.4321 -#define bshr(b, n)  (b >> n)
 34.4322 -#define bsar(b, n)  ((SBits)b >> n)
 34.4323 -#define brol(b, n)  ((b << n) | (b >> (32 - n)))
 34.4324 -#define bror(b, n)  ((b << (32 - n)) | (b >> n))
 34.4325 -#define BIT_SH(func, fn) \
 34.4326 -	static int func(lua_State * L) { \
 34.4327 -		UBits b = barg(L, 1); UBits n = barg(L, 2) & 31; BRET(fn(b, n)) }
 34.4328 -				    BIT_SH(bit_lshift, bshl)
 34.4329 -				    BIT_SH(bit_rshift, bshr)
 34.4330 -				    BIT_SH(bit_arshift, bsar)
 34.4331 -				    BIT_SH(bit_rol, brol)
 34.4332 -				    BIT_SH(bit_ror, bror)
 34.4333 -
 34.4334 -				    static int bit_bswap(lua_State *L)
 34.4335 -				    {
 34.4336 -				        UBits b = barg(L, 1);
 34.4337 -				        b = (b >> 24) | ((b >> 8) & 0xff00) | ((b & 0xff00) << 8) | (b << 24);
 34.4338 -				        BRET(b)
 34.4339 -					}
 34.4340 -
 34.4341 -				    static int bit_tohex(lua_State *L)
 34.4342 -				    {
 34.4343 -				        UBits		b		  = barg(L, 1);
 34.4344 -				        SBits		n		  = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2);
 34.4345 -				        const char *hexdigits = "0123456789abcdef";
 34.4346 -				        char		buf[8];
 34.4347 -				        int			i;
 34.4348 -				        if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
 34.4349 -				        if (n > 8) n = 8;
 34.4350 -				        for (i = (int)n; --i >= 0; )
 34.4351 -				        {
 34.4352 -				            buf[i] = hexdigits[b & 15]; b >>= 4;
 34.4353 -						}
 34.4354 -				        lua_pushlstring(L, buf, (size_t)n);
 34.4355 -				        return 1;
 34.4356 -					}
 34.4357 -
 34.4358 -				    static const struct luaL_Reg bit_funcs[] = {
 34.4359 -				        { "tobit",	 bit_tobit	 },
 34.4360 -				        { "bnot",	 bit_bnot	 },
 34.4361 -				        { "band",	 bit_band	 },
 34.4362 -				        { "bor",	 bit_bor	 },
 34.4363 -				        { "bxor",	 bit_bxor	 },
 34.4364 -				        { "lshift",	 bit_lshift	 },
 34.4365 -				        { "rshift",	 bit_rshift	 },
 34.4366 -				        { "arshift", bit_arshift },
 34.4367 -				        { "rol",	 bit_rol	 },
 34.4368 -				        { "ror",	 bit_ror	 },
 34.4369 -				        { "bswap",	 bit_bswap	 },
 34.4370 -				        { "tohex",	 bit_tohex	 },
 34.4371 -				        { NULL,		 NULL		 }
 34.4372 -					};
 34.4373 -
 34.4374 -/* Signed right-shifts are implementation-defined per C89/C99.
 34.4375 -** But the de facto standard are arithmetic right-shifts on two's
 34.4376 -** complement CPUs. This behaviour is required here, so test for it.
 34.4377 -*/
 34.4378 -#define BAD_SAR     (bsar(-8, 2) != (SBits) - 2)
 34.4379 -
 34.4380 -				    bool luabitop_validate(lua_State *L) // originally named as luaopen_bit
 34.4381 -				    {
 34.4382 -				        UBits b;
 34.4383 -				        lua_pushnumber(L, (lua_Number)1437217655L);
 34.4384 -				        b = barg(L, -1);
 34.4385 -				        if (b != (UBits)1437217655L || BAD_SAR) /* Perform a simple self-test. */
 34.4386 -				        {
 34.4387 -				            const char *msg = "compiled with incompatible luaconf.h";
 34.4388 -#ifdef LUA_NUMBER_DOUBLE
 34.4389 -#ifdef WIN32
 34.4390 -				            if (b == (UBits)1610612736L)
 34.4391 -								msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
 34.4392 -#endif
 34.4393 -				            if (b == (UBits)1127743488L)
 34.4394 -								msg = "not compiled with SWAPPED_DOUBLE";
 34.4395 -#endif
 34.4396 -				            if (BAD_SAR)
 34.4397 -								msg = "arithmetic right-shift broken";
 34.4398 -				            luaL_error(L, "bit library self-test failed (%s)", msg);
 34.4399 -				            return false;
 34.4400 -						}
 34.4401 -				        return true;
 34.4402 -					}
 34.4403 -
 34.4404 -// LuaBitOp ends here
 34.4405 -
 34.4406 -				    static int bit_bshift_emulua(lua_State *L)
 34.4407 -				    {
 34.4408 -				        int shift = luaL_checkinteger(L, 2);
 34.4409 -				        if (shift < 0)
 34.4410 -				        {
 34.4411 -				            lua_pushinteger(L, -shift);
 34.4412 -				            lua_replace(L, 2);
 34.4413 -				            return bit_lshift(L);
 34.4414 -						}
 34.4415 -				        else
 34.4416 -							return bit_rshift(L);
 34.4417 -					}
 34.4418 -
 34.4419 -				    static int bitbit(lua_State *L)
 34.4420 -				    {
 34.4421 -				        int rv		= 0;
 34.4422 -				        int numArgs = lua_gettop(L);
 34.4423 -				        for (int i = 1; i <= numArgs; i++)
 34.4424 -				        {
 34.4425 -				            int where = luaL_checkinteger(L, i);
 34.4426 -				            if (where >= 0 && where < 32)
 34.4427 -								rv |= (1 << where);
 34.4428 -						}
 34.4429 -				        lua_settop(L, 0);
 34.4430 -				        BRET(rv);
 34.4431 -					}
 34.4432 -
 34.4433 -// The function called periodically to ensure Lua doesn't run amok.
 34.4434 -				    static void VBALuaHookFunction(lua_State *L, lua_Debug *dbg)
 34.4435 -				    {
 34.4436 -				        if (numTries-- == 0)
 34.4437 -				        {
 34.4438 -				            int kill = 0;
 34.4439 -
 34.4440 -#if (defined(WIN32) && !defined(SDL))
 34.4441 -				            // Uh oh
 34.4442 -				            theApp.winCheckFullscreen();
 34.4443 -				            systemSoundClearBuffer();
 34.4444 -				            int ret = AfxGetApp()->m_pMainWnd->MessageBox(
 34.4445 -				                "The Lua script running has been running a long time. It may have gone crazy. Kill it?\n\n(No = don't check anymore either)",
 34.4446 -				                "Lua Script Gone Nuts?",
 34.4447 -				                MB_YESNO);
 34.4448 -
 34.4449 -				            if (ret == IDYES)
 34.4450 -				            {
 34.4451 -				                kill = 1;
 34.4452 -							}
 34.4453 -
 34.4454 -#else
 34.4455 -				            fprintf(
 34.4456 -				                stderr,
 34.4457 -				                "The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n");
 34.4458 -
 34.4459 -				            char buffer[64];
 34.4460 -				            while (true)
 34.4461 -				            {
 34.4462 -				                fprintf(stderr, "(y/n): ");
 34.4463 -				                fgets(buffer, sizeof(buffer), stdin);
 34.4464 -				                if (buffer[0] == 'y' || buffer[0] == 'Y')
 34.4465 -				                {
 34.4466 -				                    kill = 1;
 34.4467 -				                    break;
 34.4468 -								}
 34.4469 -
 34.4470 -				                if (buffer[0] == 'n' || buffer[0] == 'N')
 34.4471 -									break;
 34.4472 -							}
 34.4473 -#endif
 34.4474 -				            if (kill)
 34.4475 -				            {
 34.4476 -				                luaL_error(L, "Killed by user request.");
 34.4477 -				                VBALuaOnStop();
 34.4478 -							}
 34.4479 -
 34.4480 -				            // else, kill the debug hook.
 34.4481 -				            lua_sethook(L, NULL, 0, 0);
 34.4482 -						}
 34.4483 -					}
 34.4484 -
 34.4485 -				    static const struct luaL_reg vbalib[] = {
 34.4486 -				        //	{"speedmode", vba_speedmode},	// TODO: NYI
 34.4487 -				        { "frameadvance",	vba_frameadvance	  },
 34.4488 -				        { "pause",			vba_pause			  },
 34.4489 -				        { "framecount",		vba_framecount		  },
 34.4490 -				        { "lagcount",		vba_getlagcount		  },
 34.4491 -				        { "lagged",			vba_lagged			  },
 34.4492 -				        { "emulating",		vba_emulating		  },
 34.4493 -				        { "registerbefore", vba_registerbefore	  },
 34.4494 -				        { "registerafter",	vba_registerafter	  },
 34.4495 -				        { "registerexit",	vba_registerexit	  },
 34.4496 -				        { "message",		vba_message			  },
 34.4497 -				        { "print",			print				  }, // sure, why not
 34.4498 -				        { NULL,				NULL				  }
 34.4499 -					};
 34.4500 -
 34.4501 -				    static const struct luaL_reg memorylib[] = {
 34.4502 -				        { "readbyte",				memory_readbyte				},
 34.4503 -				        { "readbytesigned",			memory_readbytesigned		},
 34.4504 -				        { "readword",				memory_readword				},
 34.4505 -				        { "readwordsigned",			memory_readwordsigned		},
 34.4506 -				        { "readdword",				memory_readdword			},
 34.4507 -				        { "readdwordsigned",		memory_readdwordsigned		},
 34.4508 -				        { "readbyterange",			memory_readbyterange		},
 34.4509 -				        { "writebyte",				memory_writebyte			},
 34.4510 -				        { "writeword",				memory_writeword			},
 34.4511 -				        { "writedword",				memory_writedword			},
 34.4512 -				        { "getregister",			memory_getregister			},
 34.4513 -				        { "setregister",			memory_setregister			},
 34.4514 -						{ "gbromreadbyte",			memory_gbromreadbyte		},
 34.4515 -						{ "gbromreadbytesigned",	memory_gbromreadbytesigned	},
 34.4516 -						{ "gbromreadword",			memory_gbromreadword		},
 34.4517 -						{ "gbromreadwordsigned",	memory_gbromreadwordsigned	},
 34.4518 -						{ "gbromreaddword",			memory_gbromreaddword		},
 34.4519 -						{ "gbromreaddwordsigned",	memory_gbromreaddwordsigned	},
 34.4520 -						{ "gbromreadbyterange",		memory_gbromreadbyterange	},
 34.4521 -
 34.4522 -				        // alternate naming scheme for word and double-word and unsigned
 34.4523 -				        { "readbyteunsigned",		memory_readbyte				},
 34.4524 -				        { "readwordunsigned",		memory_readword				},
 34.4525 -				        { "readdwordunsigned",		memory_readdword			},
 34.4526 -				        { "readshort",				memory_readword				},
 34.4527 -				        { "readshortunsigned",		memory_readword				},
 34.4528 -				        { "readshortsigned",		memory_readwordsigned		},
 34.4529 -				        { "readlong",				memory_readdword			},
 34.4530 -				        { "readlongunsigned",		memory_readdword			},
 34.4531 -						{ "readlongsigned",			memory_readdwordsigned		},
 34.4532 -				        { "writeshort",				memory_writeword			},
 34.4533 -				        { "writelong",				memory_writedword			},
 34.4534 -						{ "gbromreadbyteunsigned",	memory_gbromreadbyte		},
 34.4535 -						{ "gbromreadwordunsigned",	memory_gbromreadword		},
 34.4536 -						{ "gbromreaddwordunsigned",	memory_gbromreaddword		},
 34.4537 -						{ "gbromreadshort",			memory_gbromreadword		},
 34.4538 -						{ "gbromreadshortunsigned",	memory_gbromreadword		},
 34.4539 -						{ "gbromreadshortsigned",	memory_gbromreadwordsigned	},
 34.4540 -						{ "gbromreadlong",			memory_gbromreaddword		},
 34.4541 -						{ "gbromreadlongunsigned",	memory_gbromreaddword		},
 34.4542 -						{ "gbromreadlongsigned",	memory_gbromreaddwordsigned	},
 34.4543 -
 34.4544 -				        // memory hooks
 34.4545 -				        { "registerwrite",	   memory_registerwrite			 },
 34.4546 -				        //{"registerread", memory_registerread},
 34.4547 -				        { "registerexec",	   memory_registerexec			 },
 34.4548 -				        // alternate names
 34.4549 -				        { "register",		   memory_registerwrite			 },
 34.4550 -				        { "registerrun",	   memory_registerexec			 },
 34.4551 -				        { "registerexecute",   memory_registerexec			 },
 34.4552 -
 34.4553 -				        { NULL,				   NULL							 }
 34.4554 -					};
 34.4555 -
 34.4556 -				    static const struct luaL_reg joypadlib[] = {
 34.4557 -				        { "get",	  joypad_get	  },
 34.4558 -				        { "getdown",  joypad_getdown  },
 34.4559 -				        { "getup",	  joypad_getup	  },
 34.4560 -				        { "set",	  joypad_set	  },
 34.4561 -
 34.4562 -				        // alternative names
 34.4563 -				        { "read",	  joypad_get	  },
 34.4564 -				        { "write",	  joypad_set	  },
 34.4565 -				        { "readdown", joypad_getdown  },
 34.4566 -				        { "readup",	  joypad_getup	  },
 34.4567 -				        { NULL,		  NULL			  }
 34.4568 -					};
 34.4569 -
 34.4570 -				    static const struct luaL_reg savestatelib[] = {
 34.4571 -				        { "create", savestate_create },
 34.4572 -				        { "save",	savestate_save	 },
 34.4573 -				        { "load",	savestate_load	 },
 34.4574 -
 34.4575 -				        { NULL,		NULL			 }
 34.4576 -					};
 34.4577 -
 34.4578 -				    static const struct luaL_reg movielib[] = {
 34.4579 -				        { "active",			  movie_isactive				},
 34.4580 -				        { "recording",		  movie_isrecording				},
 34.4581 -				        { "playing",		  movie_isplaying				},
 34.4582 -				        { "mode",			  movie_getmode					},
 34.4583 -
 34.4584 -				        { "length",			  movie_getlength				},
 34.4585 -				        { "author",			  movie_getauthor				},
 34.4586 -				        { "name",			  movie_getfilename				},
 34.4587 -				        { "rerecordcount",	  movie_rerecordcount			},
 34.4588 -				        { "setrerecordcount", movie_setrerecordcount		},
 34.4589 -
 34.4590 -				        { "rerecordcounting", movie_rerecordcounting		},
 34.4591 -				        { "framecount",		  vba_framecount				}, // for those familiar with
 34.4592 -				                                                              // other emulators that have
 34.4593 -				                                                              // movie.framecount()
 34.4594 -				                                                              // instead of
 34.4595 -				                                                              // emulatorname.framecount()
 34.4596 -
 34.4597 -				        { "stop",			  movie_stop					},
 34.4598 -
 34.4599 -				        // alternative names
 34.4600 -				        { "close",			  movie_stop					},
 34.4601 -				        { "getauthor",		  movie_getauthor				},
 34.4602 -				        { "getname",		  movie_getfilename				},
 34.4603 -				        { NULL,				  NULL							}
 34.4604 -					};
 34.4605 -
 34.4606 -				    static const struct luaL_reg guilib[] = {
 34.4607 -				        { "register",	  gui_register		   },
 34.4608 -				        { "text",		  gui_text			   },
 34.4609 -				        { "box",		  gui_drawbox		   },
 34.4610 -				        { "line",		  gui_drawline		   },
 34.4611 -				        { "pixel",		  gui_drawpixel		   },
 34.4612 -				        { "opacity",	  gui_setopacity	   },
 34.4613 -				        { "transparency", gui_transparency	   },
 34.4614 -				        { "popup",		  gui_popup			   },
 34.4615 -				        { "parsecolor",	  gui_parsecolor	   },
 34.4616 -				        { "gdscreenshot", gui_gdscreenshot	   },
 34.4617 -				        { "gdoverlay",	  gui_gdoverlay		   },
 34.4618 -				        { "getpixel",	  gui_getpixel		   },
 34.4619 -
 34.4620 -				        // alternative names
 34.4621 -				        { "drawtext",	  gui_text			   },
 34.4622 -				        { "drawbox",	  gui_drawbox		   },
 34.4623 -				        { "drawline",	  gui_drawline		   },
 34.4624 -				        { "drawpixel",	  gui_drawpixel		   },
 34.4625 -				        { "setpixel",	  gui_drawpixel		   },
 34.4626 -				        { "writepixel",	  gui_drawpixel		   },
 34.4627 -				        { "rect",		  gui_drawbox		   },
 34.4628 -				        { "drawrect",	  gui_drawbox		   },
 34.4629 -				        { "drawimage",	  gui_gdoverlay		   },
 34.4630 -				        { "image",		  gui_gdoverlay		   },
 34.4631 -				        { "readpixel",	  gui_getpixel		   },
 34.4632 -				        { NULL,			  NULL				   }
 34.4633 -					};
 34.4634 -
 34.4635 -				    static const struct luaL_reg inputlib[] = {
 34.4636 -				        { "get",  input_getcurrentinputstatus  },
 34.4637 -
 34.4638 -				        // alternative names
 34.4639 -				        { "read", input_getcurrentinputstatus  },
 34.4640 -				        { NULL,	  NULL						   }
 34.4641 -					};
 34.4642 -
 34.4643 -				    static const struct luaL_reg soundlib[] = {
 34.4644 -				        { "get",  sound_get                    },
 34.4645 -
 34.4646 -				        // alternative names
 34.4647 -				        { NULL,	  NULL						   }
 34.4648 -					};
 34.4649 -
 34.4650 -// gocha: since vba dumps avi so badly,
 34.4651 -// I add avilib as a workaround for enhanced video encoding.
 34.4652 -				    static const struct luaL_reg avilib[] = {
 34.4653 -				        { "framecount", avi_framecount },
 34.4654 -				        { "pause",		avi_pause	   },
 34.4655 -				        { "resume",		avi_resume	   },
 34.4656 -				        { NULL,			NULL		   }
 34.4657 -					};
 34.4658 -
 34.4659 -				    void CallExitFunction(void)
 34.4660 -				    {
 34.4661 -				        if (!LUA)
 34.4662 -							return;
 34.4663 -
 34.4664 -				        lua_settop(LUA, 0);
 34.4665 -				        lua_getfield(LUA, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]);
 34.4666 -
 34.4667 -				        int errorcode = 0;
 34.4668 -				        if (lua_isfunction(LUA, -1))
 34.4669 -				        {
 34.4670 -				            errorcode = lua_pcall(LUA, 0, 0, 0);
 34.4671 -						}
 34.4672 -
 34.4673 -				        if (errorcode)
 34.4674 -							HandleCallbackError(LUA);
 34.4675 -					}
 34.4676 -
 34.4677 -				    void VBALuaFrameBoundary(void)
 34.4678 -				    {
 34.4679 -				        //	printf("Lua Frame\n");
 34.4680 -
 34.4681 -				        lua_joypads_used = 0;
 34.4682 -
 34.4683 -				        // HA!
 34.4684 -				        if (!LUA || !luaRunning)
 34.4685 -							return;
 34.4686 -
 34.4687 -				        // Our function needs calling
 34.4688 -				        lua_settop(LUA, 0);
 34.4689 -				        lua_getfield(LUA, LUA_REGISTRYINDEX, frameAdvanceThread);
 34.4690 -
 34.4691 -				        lua_State *thread = lua_tothread(LUA, 1);
 34.4692 -
 34.4693 -				        // Lua calling C must know that we're busy inside a frame boundary
 34.4694 -				        frameBoundary		= true;
 34.4695 -				        frameAdvanceWaiting = false;
 34.4696 -
 34.4697 -				        numTries = 1000;
 34.4698 -
 34.4699 -				        int result = lua_resume(thread, 0);
 34.4700 -
 34.4701 -				        if (result == LUA_YIELD)
 34.4702 -				        {
 34.4703 -				            // Okay, we're fine with that.
 34.4704 -						}
 34.4705 -				        else if (result != 0)
 34.4706 -				        {
 34.4707 -				            // Done execution by bad causes
 34.4708 -				            VBALuaOnStop();
 34.4709 -				            lua_pushnil(LUA);
 34.4710 -				            lua_setfield(LUA, LUA_REGISTRYINDEX, frameAdvanceThread);
 34.4711 -				            lua_pushnil(LUA);
 34.4712 -				            lua_setfield(LUA, LUA_REGISTRYINDEX, guiCallbackTable);
 34.4713 -
 34.4714 -				            // Error?
 34.4715 -//#if (defined(WIN32) && !defined(SDL))
 34.4716 -//		info_print(info_uid, lua_tostring(thread, -1)); //Clear_Sound_Buffer();
 34.4717 -// AfxGetApp()->m_pMainWnd->MessageBox(lua_tostring(thread, -1), "Lua run error", MB_OK | MB_ICONSTOP);
 34.4718 -//#else
 34.4719 -//		fprintf(stderr, "Lua thread bombed out: %s\n", lua_tostring(thread, -1));
 34.4720 -//#endif
 34.4721 -				            printerror(thread, -1);
 34.4722 -						}
 34.4723 -				        else
 34.4724 -				        {
 34.4725 -				            VBALuaOnStop();
 34.4726 -				            printf("Script died of natural causes.\n");
 34.4727 -						}
 34.4728 -
 34.4729 -				        // Past here, VBA actually runs, so any Lua code is called mid-frame. We must
 34.4730 -				        // not do anything too stupid, so let ourselves know.
 34.4731 -				        frameBoundary = false;
 34.4732 -
 34.4733 -				        if (!frameAdvanceWaiting)
 34.4734 -				        {
 34.4735 -				            VBALuaOnStop();
 34.4736 -						}
 34.4737 -					}
 34.4738 -
 34.4739 -/**
 34.4740 - * Loads and runs the given Lua script.
 34.4741 - * The emulator MUST be paused for this function to be
 34.4742 - * called. Otherwise, all frame boundary assumptions go out the window.
 34.4743 - *
 34.4744 - * Returns true on success, false on failure.
 34.4745 - */
 34.4746 -				    int VBALoadLuaCode(const char *filename)
 34.4747 -				    {
 34.4748 -				        static bool sfmtInitialized = false;
 34.4749 -				        if (!sfmtInitialized)
 34.4750 -				        {
 34.4751 -				            init_gen_rand((unsigned)time(NULL));
 34.4752 -				            sfmtInitialized = true;
 34.4753 -						}
 34.4754 -
 34.4755 -				        if (filename != luaScriptName)
 34.4756 -				        {
 34.4757 -				            if (luaScriptName)
 34.4758 -								free(luaScriptName);
 34.4759 -				            luaScriptName = strdup(filename);
 34.4760 -						}
 34.4761 -
 34.4762 -				        //stop any lua we might already have had running
 34.4763 -				        VBALuaStop();
 34.4764 -
 34.4765 -				        // Set current directory from filename (for dofile)
 34.4766 -				        char  dir[_MAX_PATH];
 34.4767 -				        char *slash, *backslash;
 34.4768 -				        strcpy(dir, filename);
 34.4769 -				        slash	  = strrchr(dir, '/');
 34.4770 -				        backslash = strrchr(dir, '\\');
 34.4771 -				        if (!slash || (backslash && backslash < slash))
 34.4772 -							slash = backslash;
 34.4773 -				        if (slash)
 34.4774 -				        {
 34.4775 -				            slash[1] = '\0'; // keep slash itself for some reasons
 34.4776 -				            chdir(dir);
 34.4777 -						}
 34.4778 -
 34.4779 -				        if (!LUA)
 34.4780 -				        {
 34.4781 -				            LUA = lua_open();
 34.4782 -				            luaL_openlibs(LUA);
 34.4783 -
 34.4784 -				            luaL_register(LUA, "emu", vbalib); // added for better cross-emulator compatibility
 34.4785 -				            luaL_register(LUA, "vba", vbalib); // kept for backward compatibility
 34.4786 -				            luaL_register(LUA, "memory", memorylib);
 34.4787 -				            luaL_register(LUA, "joypad", joypadlib);
 34.4788 -				            luaL_register(LUA, "savestate", savestatelib);
 34.4789 -				            luaL_register(LUA, "movie", movielib);
 34.4790 -				            luaL_register(LUA, "gui", guilib);
 34.4791 -				            luaL_register(LUA, "input", inputlib);
 34.4792 -				            luaL_register(LUA, "sound", soundlib);
 34.4793 -				            luaL_register(LUA, "bit", bit_funcs); // LuaBitOp library
 34.4794 -				            luaL_register(LUA, "avi", avilib); // workaround for enhanced video encoding
 34.4795 -				            lua_settop(LUA, 0); // clean the stack, because each call to luaL_register leaves a table on top
 34.4796 -
 34.4797 -				            // register a few utility functions outside of libraries (in the global namespace)
 34.4798 -				            lua_register(LUA, "print", print);
 34.4799 -				            lua_register(LUA, "tostring", tostring);
 34.4800 -				            lua_register(LUA, "addressof", addressof);
 34.4801 -				            lua_register(LUA, "copytable", copytable);
 34.4802 -
 34.4803 -				            // old bit operation functions
 34.4804 -				            lua_register(LUA, "AND", bit_band);
 34.4805 -				            lua_register(LUA, "OR", bit_bor);
 34.4806 -				            lua_register(LUA, "XOR", bit_bxor);
 34.4807 -				            lua_register(LUA, "SHIFT", bit_bshift_emulua);
 34.4808 -				            lua_register(LUA, "BIT", bitbit);
 34.4809 -
 34.4810 -				            luabitop_validate(LUA);
 34.4811 -
 34.4812 -				            lua_pushstring(LUA, "math");
 34.4813 -				            lua_gettable(LUA, LUA_GLOBALSINDEX);
 34.4814 -				            lua_pushcfunction(LUA, sfmt_random);
 34.4815 -				            lua_setfield(LUA, -2, "random");
 34.4816 -				            lua_pushcfunction(LUA, sfmt_randomseed);
 34.4817 -				            lua_setfield(LUA, -2, "randomseed");
 34.4818 -				            lua_settop(LUA, 0);
 34.4819 -
 34.4820 -				            // push arrays for storing hook functions in
 34.4821 -				            for (int i = 0; i < LUAMEMHOOK_COUNT; i++)
 34.4822 -				            {
 34.4823 -				                lua_newtable(LUA);
 34.4824 -				                lua_setfield(LUA, LUA_REGISTRYINDEX, luaMemHookTypeStrings[i]);
 34.4825 -							}
 34.4826 -						}
 34.4827 -
 34.4828 -				        // We make our thread NOW because we want it at the bottom of the stack.
 34.4829 -				        // If all goes wrong, we let the garbage collector remove it.
 34.4830 -				        lua_State *thread = lua_newthread(LUA);
 34.4831 -
 34.4832 -				        // Load the data
 34.4833 -				        int result = luaL_loadfile(LUA, filename);
 34.4834 -
 34.4835 -				        if (result)
 34.4836 -				        {
 34.4837 -//#if (defined(WIN32) && !defined(SDL))
 34.4838 -//		info_print(info_uid, lua_tostring(LUA, -1)); //Clear_Sound_Buffer();
 34.4839 -// AfxGetApp()->m_pMainWnd->MessageBox(lua_tostring(LUA, -1), "Lua load error", MB_OK | MB_ICONSTOP);
 34.4840 -//#else
 34.4841 -//		fprintf(stderr, "Failed to compile file: %s\n", lua_tostring(LUA, -1));
 34.4842 -//#endif
 34.4843 -				            printerror(LUA, -1);
 34.4844 -
 34.4845 -				            // Wipe the stack. Our thread
 34.4846 -				            lua_settop(LUA, 0);
 34.4847 -				            return 0; // Oh shit.
 34.4848 -						}
 34.4849 -
 34.4850 -				        // Get our function into it
 34.4851 -				        lua_xmove(LUA, thread, 1);
 34.4852 -
 34.4853 -				        // Save the thread to the registry. This is why I make the thread FIRST.
 34.4854 -				        lua_setfield(LUA, LUA_REGISTRYINDEX, frameAdvanceThread);
 34.4855 -
 34.4856 -				        // Initialize settings
 34.4857 -				        luaRunning = true;
 34.4858 -				        skipRerecords		 = false;
 34.4859 -				        numMemHooks			 = 0;
 34.4860 -				        transparencyModifier = 255; // opaque
 34.4861 -				        lua_joypads_used	 = 0; // not used
 34.4862 -				        //wasPaused = systemIsPaused();
 34.4863 -				        //systemSetPause(false);
 34.4864 -
 34.4865 -				        // Set up our protection hook to be executed once every 10,000 bytecode instructions.
 34.4866 -				        lua_sethook(thread, VBALuaHookFunction, LUA_MASKCOUNT, 10000);
 34.4867 -
 34.4868 -#ifdef WIN32
 34.4869 -				        info_print	 = PrintToWindowConsole;
 34.4870 -				        info_onstart = WinLuaOnStart;
 34.4871 -				        info_onstop	 = WinLuaOnStop;
 34.4872 -				        if (!LuaConsoleHWnd)
 34.4873 -							LuaConsoleHWnd = CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_LUA),
 34.4874 -							                              AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) DlgLuaScriptDialog);
 34.4875 -				        info_uid = (int)LuaConsoleHWnd;
 34.4876 -#else
 34.4877 -				        info_print	 = NULL;
 34.4878 -				        info_onstart = NULL;
 34.4879 -				        info_onstop	 = NULL;
 34.4880 -#endif
 34.4881 -				        if (info_onstart)
 34.4882 -							info_onstart(info_uid);
 34.4883 -
 34.4884 -				        // And run it right now. :)
 34.4885 -				        VBALuaFrameBoundary();
 34.4886 -				        systemRenderFrame();
 34.4887 -
 34.4888 -				        // We're done.
 34.4889 -				        return 1;
 34.4890 -					}
 34.4891 -
 34.4892 -/**
 34.4893 - * Equivalent to repeating the last VBALoadLuaCode() call.
 34.4894 - */
 34.4895 -				    int VBAReloadLuaCode(void)
 34.4896 -				    {
 34.4897 -				        if (!luaScriptName)
 34.4898 -				        {
 34.4899 -				            systemScreenMessage("There's no script to reload.");
 34.4900 -				            return 0;
 34.4901 -						}
 34.4902 -				        else
 34.4903 -							return VBALoadLuaCode(luaScriptName);
 34.4904 -					}
 34.4905 -
 34.4906 -/**
 34.4907 - * Terminates a running Lua script by killing the whole Lua engine.
 34.4908 - *
 34.4909 - * Always safe to call, except from within a lua call itself (duh).
 34.4910 - *
 34.4911 - */
 34.4912 -				    void VBALuaStop(void)
 34.4913 -				    {
 34.4914 -				        //already killed
 34.4915 -				        if (!LUA)
 34.4916 -							return;
 34.4917 -
 34.4918 -				        //execute the user's shutdown callbacks
 34.4919 -				        CallExitFunction();
 34.4920 -
 34.4921 -				        /*info.*/ numMemHooks = 0;
 34.4922 -				        for (int i = 0; i < LUAMEMHOOK_COUNT; i++)
 34.4923 -							CalculateMemHookRegions((LuaMemHookType)i);
 34.4924 -
 34.4925 -				        //sometimes iup uninitializes com
 34.4926 -				        //MBG TODO - test whether this is really necessary. i dont think it is
 34.4927 -#if (defined(WIN32) && !defined(SDL))
 34.4928 -				        CoInitialize(0);
 34.4929 -#endif
 34.4930 -
 34.4931 -				        if (info_onstop)
 34.4932 -							info_onstop(info_uid);
 34.4933 -
 34.4934 -				        //lua_gc(LUA,LUA_GCCOLLECT,0);
 34.4935 -				        lua_close(LUA); // this invokes our garbage collectors for us
 34.4936 -				        LUA = NULL;
 34.4937 -				        VBALuaOnStop();
 34.4938 -					}
 34.4939 -
 34.4940 -/**
 34.4941 - * Returns true if there is a Lua script running.
 34.4942 - *
 34.4943 - */
 34.4944 -				    int VBALuaRunning(void)
 34.4945 -				    {
 34.4946 -				        // FIXME: return false when no callback functions are registered.
 34.4947 -				        return (int) (LUA != NULL); // should return true if callback functions are active.
 34.4948 -					}
 34.4949 -
 34.4950 -/**
 34.4951 - * Returns true if Lua would like to steal the given joypad control.
 34.4952 - *
 34.4953 - * Range is 0 through 3
 34.4954 - */
 34.4955 -				    int VBALuaUsingJoypad(int which)
 34.4956 -				    {
 34.4957 -				        if (which < 0 || which > 3)
 34.4958 -							which = systemGetDefaultJoypad();
 34.4959 -				        return lua_joypads_used & (1 << which);
 34.4960 -					}
 34.4961 -
 34.4962 -/**
 34.4963 - * Reads the buttons Lua is feeding for the given joypad, in the same
 34.4964 - * format as the OS-specific code.
 34.4965 - *
 34.4966 - * <del>This function must not be called more than once per frame. </del>Ideally exactly once
 34.4967 - * per frame (if VBALuaUsingJoypad says it's safe to do so)
 34.4968 - */
 34.4969 -				    int VBALuaReadJoypad(int which)
 34.4970 -				    {
 34.4971 -				        if (which < 0 || which > 3)
 34.4972 -							which = systemGetDefaultJoypad();
 34.4973 -
 34.4974 -				        //lua_joypads_used &= ~(1 << which);
 34.4975 -				        return lua_joypads[which];
 34.4976 -					}
 34.4977 -
 34.4978 -/**
 34.4979 - * If this function returns true, the movie code should NOT increment
 34.4980 - * the rerecord count for a load-state.
 34.4981 - *
 34.4982 - * This function will not return true if a script is not running.
 34.4983 - */
 34.4984 -				    bool8 VBALuaRerecordCountSkip(void)
 34.4985 -				    {
 34.4986 -				        // FIXME: return true if (there are any active callback functions && skipRerecords)
 34.4987 -				        return LUA && luaRunning && skipRerecords;
 34.4988 -					}
 34.4989 -
 34.4990 -/**
 34.4991 - * Given a screen with the indicated resolution,
 34.4992 - * draw the current GUI onto it.
 34.4993 - */
 34.4994 -				    void VBALuaGui(uint8 *screen, int ppl, int width, int height)
 34.4995 -				    {
 34.4996 -				        if (!LUA /* || !luaRunning*/)
 34.4997 -							return;
 34.4998 -
 34.4999 -				        // First, check if we're being called by anybody
 34.5000 -				        lua_getfield(LUA, LUA_REGISTRYINDEX, guiCallbackTable);
 34.5001 -
 34.5002 -				        if (lua_isfunction(LUA, -1))
 34.5003 -				        {
 34.5004 -				            // We call it now
 34.5005 -				            numTries = 1000;
 34.5006 -
 34.5007 -				            int ret = lua_pcall(LUA, 0, 0, 0);
 34.5008 -				            if (ret != 0)
 34.5009 -				            {
 34.5010 -				                // This is grounds for trashing the function
 34.5011 -				                // Note: This must be done before the messagebox pops up,
 34.5012 -				                //       otherwise the messagebox will cause a paint event which causes a weird
 34.5013 -				                //       infinite call sequence that makes Snes9x silently exit with error code 3,
 34.5014 -				                //       if a Lua GUI function crashes. (nitsuja)
 34.5015 -				                lua_pushnil(LUA);
 34.5016 -				                lua_setfield(LUA, LUA_REGISTRYINDEX, guiCallbackTable);
 34.5017 -
 34.5018 -//#if (defined(WIN32) && !defined(SDL))
 34.5019 -//			info_print(info_uid, lua_tostring(LUA, -1)); //AfxGetApp()->m_pMainWnd->MessageBox(lua_tostring(LUA, -1), "Lua Error
 34.5020 -// in GUI function", MB_OK);
 34.5021 -//#else
 34.5022 -//			fprintf(stderr, "Lua error in gui.register function: %s\n", lua_tostring(LUA, -1));
 34.5023 -//#endif
 34.5024 -				                printerror(LUA, -1);
 34.5025 -							}
 34.5026 -						}
 34.5027 -
 34.5028 -				        // And wreak the stack
 34.5029 -				        lua_settop(LUA, 0);
 34.5030 -
 34.5031 -				        if (!gui_used)
 34.5032 -							return;
 34.5033 -
 34.5034 -				        gui_used = false;
 34.5035 -
 34.5036 -				        int x, y;
 34.5037 -
 34.5038 -				        //int pitch = (((ppl * systemColorDepth + 7)>>3)+3)&~3;
 34.5039 -				        int pitch = ppl * (systemColorDepth / 8) + (systemColorDepth == 24 ? 0 : 4);
 34.5040 -
 34.5041 -				        if (width > LUA_SCREEN_WIDTH)
 34.5042 -							width = LUA_SCREEN_WIDTH;
 34.5043 -				        if (height > LUA_SCREEN_HEIGHT)
 34.5044 -							height = LUA_SCREEN_HEIGHT;
 34.5045 -
 34.5046 -				        GetColorFunc getColor;
 34.5047 -				        SetColorFunc setColor;
 34.5048 -				        getColorIOFunc(systemColorDepth, &getColor, &setColor);
 34.5049 -
 34.5050 -				        for (y = 0; y < height; y++)
 34.5051 -				        {
 34.5052 -				            uint8 *scr = &screen[y * pitch];
 34.5053 -				            for (x = 0; x < width; x++, scr += systemColorDepth / 8)
 34.5054 -				            {
 34.5055 -				                const uint8 gui_alpha = gui_data[(y * LUA_SCREEN_WIDTH + x) * 4 + 3];
 34.5056 -				                if (gui_alpha == 0)
 34.5057 -				                {
 34.5058 -				                    // do nothing
 34.5059 -				                    continue;
 34.5060 -								}
 34.5061 -
 34.5062 -				                const uint8 gui_red	  = gui_data[(y * LUA_SCREEN_WIDTH + x) * 4 + 2];
 34.5063 -				                const uint8 gui_green = gui_data[(y * LUA_SCREEN_WIDTH + x) * 4 + 1];
 34.5064 -				                const uint8 gui_blue  = gui_data[(y * LUA_SCREEN_WIDTH + x) * 4];
 34.5065 -				                int			red, green, blue;
 34.5066 -
 34.5067 -				                if (gui_alpha == 255)
 34.5068 -				                {
 34.5069 -				                    // direct copy
 34.5070 -				                    red	  = gui_red;
 34.5071 -				                    green = gui_green;
 34.5072 -				                    blue  = gui_blue;
 34.5073 -								}
 34.5074 -				                else
 34.5075 -				                {
 34.5076 -				                    // alpha-blending
 34.5077 -				                    uint8 scr_red, scr_green, scr_blue;
 34.5078 -				                    getColor(scr, &scr_red, &scr_green, &scr_blue);
 34.5079 -				                    red	  = (((int)gui_red - scr_red) * gui_alpha / 255 + scr_red) & 255;
 34.5080 -				                    green = (((int)gui_green - scr_green) * gui_alpha / 255 + scr_green) & 255;
 34.5081 -				                    blue  = (((int)gui_blue - scr_blue) * gui_alpha / 255 + scr_blue) & 255;
 34.5082 -								}
 34.5083 -
 34.5084 -				                setColor(scr, (uint8) red, (uint8) green, (uint8) blue);
 34.5085 -							}
 34.5086 -						}
 34.5087 -
 34.5088 -				        return;
 34.5089 -					}
 34.5090 -
 34.5091 -				    void VBALuaClearGui(void)
 34.5092 -				    {
 34.5093 -				        gui_used = false;
 34.5094 -					}
 34.5095 -
 34.5096 -				    lua_State *VBAGetLuaState()
 34.5097 -				    {
 34.5098 -				        return LUA;
 34.5099 -					}
 34.5100 -
 34.5101 -				    char *VBAGetLuaScriptName()
 34.5102 -				    {
 34.5103 -				        return luaScriptName;
 34.5104 -					}
 34.5105 -
    35.1 --- a/src/common/memgzio.c	Sat Mar 03 10:54:39 2012 -0600
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,791 +0,0 @@
    35.4 -/* gzio.c -- IO on .gz files
    35.5 - * Copyright (C) 1995-2002 Jean-loup Gailly.
    35.6 - * For conditions of distribution and use, see copyright notice in zlib.h
    35.7 - *
    35.8 - * Compile this file with -DNO_DEFLATE to avoid the compression code.
    35.9 - */
   35.10 -
   35.11 -/* memgzio.c - IO on .gz files in memory
   35.12 - * Adapted from original gzio.c from zlib library by Forgotten
   35.13 - */
   35.14 -
   35.15 -/* @(#) $Id: memgzio.c,v 1.5 2006/06/06 21:04:20 spacy51 Exp $ */
   35.16 -
   35.17 -#include <stdio.h>
   35.18 -#include <stdarg.h>
   35.19 -#include <stdlib.h>
   35.20 -#include <string.h>
   35.21 -#include <errno.h>
   35.22 -
   35.23 -#include "memgzio.h"
   35.24 -
   35.25 -#ifndef local
   35.26 -#define local static
   35.27 -#endif
   35.28 -
   35.29 -#ifndef DEF_MEM_LEVEL
   35.30 -#  define DEF_MEM_LEVEL 8
   35.31 -#endif
   35.32 -
   35.33 -#ifndef OS_CODE
   35.34 -#define OS_CODE 3
   35.35 -#endif
   35.36 -
   35.37 -#ifndef zmemcpy
   35.38 -#define zmemcpy memcpy
   35.39 -#endif
   35.40 -
   35.41 -/*struct internal_state {int dummy;};*/ /* for buggy compilers */
   35.42 -
   35.43 -#ifndef Z_BUFSIZE
   35.44 -#  ifdef MAXSEG_64K
   35.45 -#    define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
   35.46 -#  else
   35.47 -#    define Z_BUFSIZE 16384
   35.48 -#  endif
   35.49 -#endif
   35.50 -#ifndef Z_PRINTF_BUFSIZE
   35.51 -#  define Z_PRINTF_BUFSIZE 4096
   35.52 -#endif
   35.53 -
   35.54 -#define ALLOC(size) malloc(size)
   35.55 -#define TRYFREE(p) \
   35.56 -	{if (p)                            \
   35.57 -		 free(p);}
   35.58 -
   35.59 -static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
   35.60 -
   35.61 -/* gzip flag byte */
   35.62 -#define ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
   35.63 -#define HEAD_CRC     0x02 /* bit 1 set: header CRC present */
   35.64 -#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
   35.65 -#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
   35.66 -#define COMMENT      0x10 /* bit 4 set: file comment present */
   35.67 -#define RESERVED     0xE0 /* bits 5..7: reserved */
   35.68 -
   35.69 -typedef struct _MemFile
   35.70 -{
   35.71 -	char *memory;
   35.72 -	char *next;
   35.73 -	int   available;
   35.74 -	int   error;
   35.75 -	char  mode;
   35.76 -} MEMFILE;
   35.77 -
   35.78 -typedef struct mem_stream
   35.79 -{
   35.80 -	z_stream stream;
   35.81 -	int      z_err;   /* error code for last stream operation */
   35.82 -	int      z_eof;   /* set if end of input file */
   35.83 -	MEMFILE *file;    /* memoru file */
   35.84 -	Byte *   inbuf;   /* input buffer */
   35.85 -	Byte *   outbuf;  /* output buffer */
   35.86 -	uLong    crc;     /* crc32 of uncompressed data */
   35.87 -	char *   msg;     /* error message */
   35.88 -	int      transparent; /* 1 if input file is not a .gz file */
   35.89 -	char     mode;    /* 'w' or 'r' */
   35.90 -	long     startpos; /* start of compressed data in file (header skipped) */
   35.91 -} mem_stream;
   35.92 -
   35.93 -local gzFile gz_open      OF((char *memory, const int available, const char *mode));
   35.94 -local int do_flush        OF((gzFile file, int flush));
   35.95 -local int get_byte     OF((mem_stream *s));
   35.96 -local void check_header OF((mem_stream *s));
   35.97 -local int destroy      OF((mem_stream *s));
   35.98 -local void putLong      OF((MEMFILE *file, uLong x));
   35.99 -local uLong getLong      OF((mem_stream *s));
  35.100 -
  35.101 -local MEMFILE *memOpen(char *memory, int available, char mode)
  35.102 -{
  35.103 -	MEMFILE *f;
  35.104 -
  35.105 -	if (available <= 8)
  35.106 -		return NULL;
  35.107 -
  35.108 -	if (mode != 'w' && mode != 'r')
  35.109 -		return NULL;
  35.110 -
  35.111 -	f = (MEMFILE *)malloc(sizeof(MEMFILE));
  35.112 -
  35.113 -	f->memory = memory;
  35.114 -	f->mode   = mode;
  35.115 -	f->error  = 0;
  35.116 -
  35.117 -	if (mode == 'w')
  35.118 -	{
  35.119 -		f->available         = available - 8;
  35.120 -		f->next              = memory + 8;
  35.121 -		memory[0]            = 'V';
  35.122 -		memory[1]            = 'B';
  35.123 -		memory[2]            = 'A';
  35.124 -		memory[3]            = ' ';
  35.125 -		*((int *)(memory+4)) = 0;
  35.126 -	}
  35.127 -	else
  35.128 -	{
  35.129 -		if (memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' ||
  35.130 -		    memory[3] != ' ')
  35.131 -		{
  35.132 -			free(f);
  35.133 -			return NULL;
  35.134 -		}
  35.135 -		f->available = *((int *)(memory+4));
  35.136 -		f->next      = memory+8;
  35.137 -	}
  35.138 -
  35.139 -	return f;
  35.140 -}
  35.141 -
  35.142 -local size_t memWrite(const void *buffer, size_t size, size_t count,
  35.143 -                      MEMFILE *file)
  35.144 -{
  35.145 -	size_t total = size*count;
  35.146 -
  35.147 -	if (file->mode != 'w')
  35.148 -	{
  35.149 -		file->error = 1;
  35.150 -		return 0;
  35.151 -	}
  35.152 -
  35.153 -	if (total > (size_t)file->available)
  35.154 -	{
  35.155 -		total = file->available;
  35.156 -	}
  35.157 -	memcpy(file->next, buffer, total);
  35.158 -	file->available -= (int)total;
  35.159 -	file->next      += total;
  35.160 -	return total;
  35.161 -}
  35.162 -
  35.163 -local size_t memRead(void *buffer, size_t size, size_t count,
  35.164 -                     MEMFILE *file)
  35.165 -{
  35.166 -	size_t total = size*count;
  35.167 -
  35.168 -	if (file->mode != 'r')
  35.169 -	{
  35.170 -		file->error = 1;
  35.171 -		return 0;
  35.172 -	}
  35.173 -
  35.174 -	if (file->available == 0)
  35.175 -		return -1;
  35.176 -
  35.177 -	if (total > (size_t)file->available)
  35.178 -	{
  35.179 -		total = file->available;
  35.180 -	}
  35.181 -	memcpy(buffer, file->next, total);
  35.182 -	file->available -= (int)total;
  35.183 -	file->next      += total;
  35.184 -	return total;
  35.185 -}
  35.186 -
  35.187 -local int memPutc(int c, MEMFILE *file)
  35.188 -{
  35.189 -	if (file->mode != 'w')
  35.190 -	{
  35.191 -		file->error = 1;
  35.192 -		return -1;
  35.193 -	}
  35.194 -
  35.195 -	if (file->available >= 1)
  35.196 -	{
  35.197 -		*file->next++ = c;
  35.198 -		file->available--;
  35.199 -	}
  35.200 -	else
  35.201 -		return -1;
  35.202 -
  35.203 -	return c;
  35.204 -}
  35.205 -
  35.206 -local long memTell(MEMFILE *f)
  35.207 -{
  35.208 -	return (long)(f->next - f->memory) - 8;
  35.209 -}
  35.210 -
  35.211 -local int memError(MEMFILE *f)
  35.212 -{
  35.213 -	return f->error;
  35.214 -}
  35.215 -
  35.216 -local int memClose(MEMFILE *f)
  35.217 -{
  35.218 -	if (f->mode == 'w')
  35.219 -	{
  35.220 -		*((int *)(f->memory+4)) = memTell(f);
  35.221 -	}
  35.222 -	free(f);
  35.223 -	return 0;
  35.224 -}
  35.225 -
  35.226 -local int memPrintf(MEMFILE *f, const char *format, ...)
  35.227 -{
  35.228 -	char    buffer[80];
  35.229 -	va_list list;
  35.230 -	int     len;
  35.231 -
  35.232 -	va_start(list, format);
  35.233 -	len = vsprintf(buffer, format, list);
  35.234 -	va_end(list);
  35.235 -
  35.236 -	return (int)memWrite(buffer, 1, len, f);
  35.237 -}
  35.238 -
  35.239 -/* ===========================================================================
  35.240 -     Opens a gzip (.gz) file for reading or writing. The mode parameter
  35.241 -   is as in fopen ("rb" or "wb"). The file is given either by file descriptor
  35.242 -   or path name (if fd == -1).
  35.243 -     gz_open return NULL if the file could not be opened or if there was
  35.244 -   insufficient memory to allocate the (de)compression state; errno
  35.245 -   can be checked to distinguish the two cases (if errno is zero, the
  35.246 -   zlib error is Z_MEM_ERROR).
  35.247 - */
  35.248 -local gzFile gz_open(memory, available, mode)
  35.249 -char *memory;
  35.250 -const int   available;
  35.251 -const char *mode;
  35.252 -{
  35.253 -	int         err;
  35.254 -	int         level    = Z_DEFAULT_COMPRESSION; /* compression level */
  35.255 -	int         strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
  35.256 -	char *      p        = (char *)mode;
  35.257 -	mem_stream *s;
  35.258 -	char        fmode[80]; /* copy of mode, without the compression level */
  35.259 -	char *      m = fmode;
  35.260 -
  35.261 -	s = (mem_stream *)ALLOC(sizeof(mem_stream));
  35.262 -	if (!s)
  35.263 -		return Z_NULL;
  35.264 -
  35.265 -	s->stream.zalloc   = (alloc_func)0;
  35.266 -	s->stream.zfree    = (free_func)0;
  35.267 -	s->stream.opaque   = (voidpf)0;
  35.268 -	s->stream.next_in  = s->inbuf = Z_NULL;
  35.269 -	s->stream.next_out = s->outbuf = Z_NULL;
  35.270 -	s->stream.avail_in = s->stream.avail_out = 0;
  35.271 -	s->z_err           = Z_OK;
  35.272 -	s->z_eof           = 0;
  35.273 -	s->crc             = crc32(0L, Z_NULL, 0);
  35.274 -	s->msg             = NULL;
  35.275 -	s->transparent     = 0;
  35.276 -	s->file            = NULL;
  35.277 -
  35.278 -	s->mode = '\0';
  35.279 -	do
  35.280 -	{
  35.281 -		if (*p == 'r')
  35.282 -			s->mode = 'r';
  35.283 -		if (*p == 'w' || *p == 'a')
  35.284 -			s->mode = 'w';
  35.285 -		if (*p >= '0' && *p <= '9')
  35.286 -		{
  35.287 -			level = *p - '0';
  35.288 -		}
  35.289 -		else if (*p == 'f')
  35.290 -		{
  35.291 -			strategy = Z_FILTERED;
  35.292 -		}
  35.293 -		else if (*p == 'h')
  35.294 -		{
  35.295 -			strategy = Z_HUFFMAN_ONLY;
  35.296 -		}
  35.297 -		else
  35.298 -		{
  35.299 -			*m++ = *p; /* copy the mode */
  35.300 -		}
  35.301 -	}
  35.302 -	while (*p++ && m != fmode + sizeof(fmode));
  35.303 -	if (s->mode == '\0')
  35.304 -		return destroy(s), (gzFile)Z_NULL;
  35.305 -
  35.306 -	if (s->mode == 'w')
  35.307 -	{
  35.308 -#ifdef NO_DEFLATE
  35.309 -		err = Z_STREAM_ERROR;
  35.310 -#else
  35.311 -		err = deflateInit2(&(s->stream), level,
  35.312 -		                   Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
  35.313 -		/* windowBits is passed < 0 to suppress zlib header */
  35.314 -
  35.315 -		s->stream.next_out = s->outbuf = (Byte *)ALLOC(Z_BUFSIZE);
  35.316 -#endif
  35.317 -		if (err != Z_OK || s->outbuf == Z_NULL)
  35.318 -		{
  35.319 -			return destroy(s), (gzFile)Z_NULL;
  35.320 -		}
  35.321 -	}
  35.322 -	else
  35.323 -	{
  35.324 -		s->stream.next_in = s->inbuf = (Byte *)ALLOC(Z_BUFSIZE);
  35.325 -
  35.326 -		err = inflateInit2(&(s->stream), -MAX_WBITS);
  35.327 -		/* windowBits is passed < 0 to tell that there is no zlib header.
  35.328 -		 * Note that in this case inflate *requires* an extra "dummy" byte
  35.329 -		 * after the compressed stream in order to complete decompression and
  35.330 -		 * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
  35.331 -		 * present after the compressed stream.
  35.332 -		 */
  35.333 -		if (err != Z_OK || s->inbuf == Z_NULL)
  35.334 -		{
  35.335 -			return destroy(s), (gzFile)Z_NULL;
  35.336 -		}
  35.337 -	}
  35.338 -	s->stream.avail_out = Z_BUFSIZE;
  35.339 -
  35.340 -	errno   = 0;
  35.341 -	s->file = memOpen(memory, available, s->mode);
  35.342 -
  35.343 -	if (s->file == NULL)
  35.344 -	{
  35.345 -		return destroy(s), (gzFile)Z_NULL;
  35.346 -	}
  35.347 -
  35.348 -	if (s->mode == 'w')
  35.349 -	{
  35.350 -		/* Write a very simple .gz header:
  35.351 -		 */
  35.352 -		memPrintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
  35.353 -		          Z_DEFLATED, 0 /*flags*/, 0, 0, 0, 0 /*time*/, 0 /*xflags*/, OS_CODE);
  35.354 -		s->startpos = 10L;
  35.355 -		/* We use 10L instead of ftell(s->file) to because ftell causes an
  35.356 -		 * fflush on some systems. This version of the library doesn't use
  35.357 -		 * startpos anyway in write mode, so this initialization is not
  35.358 -		 * necessary.
  35.359 -		 */
  35.360 -	}
  35.361 -	else
  35.362 -	{
  35.363 -		check_header(s); /* skip the .gz header */
  35.364 -		s->startpos = (memTell(s->file) - s->stream.avail_in);
  35.365 -	}
  35.366 -
  35.367 -	return (gzFile)s;
  35.368 -}
  35.369 -
  35.370 -/* ===========================================================================
  35.371 -     Opens a gzip (.gz) file for reading or writing.
  35.372 - */
  35.373 -gzFile ZEXPORT memgzopen(memory, available, mode)
  35.374 -char *memory;
  35.375 -int         available;
  35.376 -const char *mode;
  35.377 -{
  35.378 -	return gz_open(memory, available, mode);
  35.379 -}
  35.380 -
  35.381 -/* ===========================================================================
  35.382 -     Read a byte from a mem_stream; update next_in and avail_in. Return EOF
  35.383 -   for end of file.
  35.384 -   IN assertion: the stream s has been sucessfully opened for reading.
  35.385 - */
  35.386 -local int get_byte(s)
  35.387 -mem_stream *s;
  35.388 -{
  35.389 -	if (s->z_eof)
  35.390 -		return EOF;
  35.391 -	if (s->stream.avail_in == 0)
  35.392 -	{
  35.393 -		errno = 0;
  35.394 -		s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
  35.395 -		if (s->stream.avail_in == 0)
  35.396 -		{
  35.397 -			s->z_eof = 1;
  35.398 -			if (memError(s->file))
  35.399 -				s->z_err = Z_ERRNO;
  35.400 -			return EOF;
  35.401 -		}
  35.402 -		s->stream.next_in = s->inbuf;
  35.403 -	}
  35.404 -	s->stream.avail_in--;
  35.405 -	return *(s->stream.next_in)++;
  35.406 -}
  35.407 -
  35.408 -/* ===========================================================================
  35.409 -      Check the gzip header of a mem_stream opened for reading. Set the stream
  35.410 -    mode to transparent if the gzip magic header is not present; set s->err
  35.411 -    to Z_DATA_ERROR if the magic header is present but the rest of the header
  35.412 -    is incorrect.
  35.413 -    IN assertion: the stream s has already been created sucessfully;
  35.414 -       s->stream.avail_in is zero for the first time, but may be non-zero
  35.415 -       for concatenated .gz files.
  35.416 - */
  35.417 -local void check_header(s)
  35.418 -mem_stream *s;
  35.419 -{
  35.420 -	int  method; /* method byte */
  35.421 -	int  flags; /* flags byte */
  35.422 -	uInt len;
  35.423 -	int  c;
  35.424 -
  35.425 -	/* Check the gzip magic header */
  35.426 -	for (len = 0; len < 2; len++)
  35.427 -	{
  35.428 -		c = get_byte(s);
  35.429 -		if (c != gz_magic[len])
  35.430 -		{
  35.431 -			if (len != 0)
  35.432 -				s->stream.avail_in++, s->stream.next_in--;
  35.433 -			if (c != EOF)
  35.434 -			{
  35.435 -				s->stream.avail_in++, s->stream.next_in--;
  35.436 -				s->transparent = 1;
  35.437 -			}
  35.438 -			s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
  35.439 -			return;
  35.440 -		}
  35.441 -	}
  35.442 -	method = get_byte(s);
  35.443 -	flags  = get_byte(s);
  35.444 -	if (method != Z_DEFLATED || (flags & RESERVED) != 0)
  35.445 -	{
  35.446 -		s->z_err = Z_DATA_ERROR;
  35.447 -		return;
  35.448 -	}
  35.449 -
  35.450 -	/* Discard time, xflags and OS code: */
  35.451 -	for (len = 0; len < 6; len++)
  35.452 -		(void)get_byte(s);
  35.453 -
  35.454 -	if ((flags & EXTRA_FIELD) != 0)   /* skip the extra field */
  35.455 -	{
  35.456 -		len  =  (uInt)get_byte(s);
  35.457 -		len += ((uInt)get_byte(s))<<8;
  35.458 -		/* len is garbage if EOF but the loop below will quit anyway */
  35.459 -		while (len-- != 0 && get_byte(s) != EOF)
  35.460 -			;
  35.461 -	}
  35.462 -	if ((flags & ORIG_NAME) != 0)   /* skip the original file name */
  35.463 -	{
  35.464 -		while ((c = get_byte(s)) != 0 && c != EOF)
  35.465 -			;
  35.466 -	}
  35.467 -	if ((flags & COMMENT) != 0)     /* skip the .gz file comment */
  35.468 -	{
  35.469 -		while ((c = get_byte(s)) != 0 && c != EOF)
  35.470 -			;
  35.471 -	}
  35.472 -	if ((flags & HEAD_CRC) != 0)    /* skip the header crc */
  35.473 -	{
  35.474 -		for (len = 0; len < 2; len++)
  35.475 -			(void)get_byte(s);
  35.476 -	}
  35.477 -	s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
  35.478 -}
  35.479 -
  35.480 -/* ===========================================================================
  35.481 - * Cleanup then free the given mem_stream. Return a zlib error code.
  35.482 -   Try freeing in the reverse order of allocations.
  35.483 - */
  35.484 -local int destroy(s)
  35.485 -mem_stream *s;
  35.486 -{
  35.487 -	int err = Z_OK;
  35.488 -
  35.489 -	if (!s)
  35.490 -		return Z_STREAM_ERROR;
  35.491 -
  35.492 -	TRYFREE(s->msg);
  35.493 -
  35.494 -	if (s->stream.state != NULL)
  35.495 -	{
  35.496 -		if (s->mode == 'w')
  35.497 -		{
  35.498 -#ifdef NO_DEFLATE
  35.499 -			err = Z_STREAM_ERROR;
  35.500 -#else
  35.501 -			err = deflateEnd(&(s->stream));
  35.502 -#endif
  35.503 -		}
  35.504 -		else if (s->mode == 'r')
  35.505 -		{
  35.506 -			err = inflateEnd(&(s->stream));
  35.507 -		}
  35.508 -	}
  35.509 -	if (s->file != NULL && memClose(s->file))
  35.510 -	{
  35.511 -#ifdef ESPIPE
  35.512 -		if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
  35.513 -#endif
  35.514 -		err = Z_ERRNO;
  35.515 -	}
  35.516 -	if (s->z_err < 0)
  35.517 -		err = s->z_err;
  35.518 -
  35.519 -	TRYFREE(s->inbuf);
  35.520 -	TRYFREE(s->outbuf);
  35.521 -	TRYFREE(s);
  35.522 -	return err;
  35.523 -}
  35.524 -
  35.525 -/* ===========================================================================
  35.526 -     Reads the given number of uncompressed bytes from the compressed file.
  35.527 -   gzread returns the number of bytes actually read (0 for end of file).
  35.528 - */
  35.529 -int ZEXPORT memgzread(file, buf, len)
  35.530 -gzFile file;
  35.531 -voidp    buf;
  35.532 -unsigned len;
  35.533 -{
  35.534 -	mem_stream *s     = (mem_stream *)file;
  35.535 -	Bytef *     start = (Bytef *)buf; /* starting point for crc computation */
  35.536 -	Byte *      next_out; /* == stream.next_out but not forced far (for MSDOS) */
  35.537 -
  35.538 -	if (s == NULL || s->mode != 'r')
  35.539 -		return Z_STREAM_ERROR;
  35.540 -
  35.541 -	if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)
  35.542 -		return -1;
  35.543 -	if (s->z_err == Z_STREAM_END)
  35.544 -		return 0;                            /* EOF */
  35.545 -
  35.546 -	next_out = (Byte *)buf;
  35.547 -	s->stream.next_out  = (Bytef *)buf;
  35.548 -	s->stream.avail_out = len;
  35.549 -
  35.550 -	while (s->stream.avail_out != 0)
  35.551 -	{
  35.552 -		if (s->transparent)
  35.553 -		{
  35.554 -			/* Copy first the lookahead bytes: */
  35.555 -			uInt n = s->stream.avail_in;
  35.556 -			if (n > s->stream.avail_out)
  35.557 -				n = s->stream.avail_out;
  35.558 -			if (n > 0)
  35.559 -			{
  35.560 -				zmemcpy(s->stream.next_out, s->stream.next_in, n);
  35.561 -				next_out += n;
  35.562 -				s->stream.next_out   = next_out;
  35.563 -				s->stream.next_in   += n;
  35.564 -				s->stream.avail_out -= n;
  35.565 -				s->stream.avail_in  -= n;
  35.566 -			}
  35.567 -			if (s->stream.avail_out > 0)
  35.568 -			{
  35.569 -				s->stream.avail_out -= (uInt)memRead(next_out, 1, s->stream.avail_out, s->file);
  35.570 -			}
  35.571 -			len -= s->stream.avail_out;
  35.572 -			s->stream.total_in  += (uLong)len;
  35.573 -			s->stream.total_out += (uLong)len;
  35.574 -			if (len == 0)
  35.575 -				s->z_eof = 1;
  35.576 -			return (int)len;
  35.577 -		}
  35.578 -		if (s->stream.avail_in == 0 && !s->z_eof)
  35.579 -		{
  35.580 -			errno = 0;
  35.581 -			s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
  35.582 -			if (s->stream.avail_in == 0)
  35.583 -			{
  35.584 -				s->z_eof = 1;
  35.585 -				if (memError(s->file))
  35.586 -				{
  35.587 -					s->z_err = Z_ERRNO;
  35.588 -					break;
  35.589 -				}
  35.590 -			}
  35.591 -			s->stream.next_in = s->inbuf;
  35.592 -		}
  35.593 -		s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
  35.594 -
  35.595 -		if (s->z_err == Z_STREAM_END)
  35.596 -		{
  35.597 -			/* Check CRC and original size */
  35.598 -			s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
  35.599 -			start  = s->stream.next_out;
  35.600 -
  35.601 -			if (getLong(s) != s->crc)
  35.602 -			{
  35.603 -				s->z_err = Z_DATA_ERROR;
  35.604 -			}
  35.605 -			else
  35.606 -			{
  35.607 -				(void)getLong(s);
  35.608 -				/* The uncompressed length returned by above getlong() may
  35.609 -				 * be different from s->stream.total_out) in case of
  35.610 -				 * concatenated .gz files. Check for such files:
  35.611 -				 */
  35.612 -				check_header(s);
  35.613 -				if (s->z_err == Z_OK)
  35.614 -				{
  35.615 -					uLong total_in  = s->stream.total_in;
  35.616 -					uLong total_out = s->stream.total_out;
  35.617 -
  35.618 -					inflateReset(&(s->stream));
  35.619 -					s->stream.total_in  = total_in;
  35.620 -					s->stream.total_out = total_out;
  35.621 -					s->crc = crc32(0L, Z_NULL, 0);
  35.622 -				}
  35.623 -			}
  35.624 -		}
  35.625 -		if (s->z_err != Z_OK || s->z_eof)
  35.626 -			break;
  35.627 -	}
  35.628 -	s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
  35.629 -
  35.630 -	return (int)(len - s->stream.avail_out);
  35.631 -}
  35.632 -
  35.633 -#ifndef NO_DEFLATE
  35.634 -/* ===========================================================================
  35.635 -     Writes the given number of uncompressed bytes into the compressed file.
  35.636 -   gzwrite returns the number of bytes actually written (0 in case of error).
  35.637 - */
  35.638 -int ZEXPORT memgzwrite(file, buf, len)
  35.639 -gzFile file;
  35.640 -const voidp buf;
  35.641 -unsigned    len;
  35.642 -{
  35.643 -	mem_stream *s = (mem_stream *)file;
  35.644 -
  35.645 -	if (s == NULL || s->mode != 'w')
  35.646 -		return Z_STREAM_ERROR;
  35.647 -
  35.648 -	s->stream.next_in  = (Bytef *)buf;
  35.649 -	s->stream.avail_in = len;
  35.650 -
  35.651 -	while (s->stream.avail_in != 0)
  35.652 -	{
  35.653 -		if (s->stream.avail_out == 0)
  35.654 -		{
  35.655 -			s->stream.next_out = s->outbuf;
  35.656 -			if (memWrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE)
  35.657 -			{
  35.658 -				s->z_err = Z_ERRNO;
  35.659 -				break;
  35.660 -			}
  35.661 -			s->stream.avail_out = Z_BUFSIZE;
  35.662 -		}
  35.663 -		s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
  35.664 -		if (s->z_err != Z_OK)
  35.665 -			break;
  35.666 -	}
  35.667 -	s->crc = crc32(s->crc, (const Bytef *)buf, len);
  35.668 -
  35.669 -	return (int)(len - s->stream.avail_in);
  35.670 -}
  35.671 -#endif
  35.672 -/* ===========================================================================
  35.673 -     Flushes all pending output into the compressed file. The parameter
  35.674 -   flush is as in the deflate() function.
  35.675 - */
  35.676 -local int do_flush(file, flush)
  35.677 -gzFile file;
  35.678 -int flush;
  35.679 -{
  35.680 -	uInt        len;
  35.681 -	int         done = 0;
  35.682 -	mem_stream *s    = (mem_stream *)file;
  35.683 -
  35.684 -	if (s == NULL || s->mode != 'w')
  35.685 -		return Z_STREAM_ERROR;
  35.686 -
  35.687 -	s->stream.avail_in = 0; /* should be zero already anyway */
  35.688 -
  35.689 -	for (;;)
  35.690 -	{
  35.691 -		len = Z_BUFSIZE - s->stream.avail_out;
  35.692 -
  35.693 -		if (len != 0)
  35.694 -		{
  35.695 -			if ((uInt)memWrite(s->outbuf, 1, len, s->file) != len)
  35.696 -			{
  35.697 -				s->z_err = Z_ERRNO;
  35.698 -				return Z_ERRNO;
  35.699 -			}
  35.700 -			s->stream.next_out  = s->outbuf;
  35.701 -			s->stream.avail_out = Z_BUFSIZE;
  35.702 -		}
  35.703 -		if (done)
  35.704 -			break;
  35.705 -		s->z_err = deflate(&(s->stream), flush);
  35.706 -
  35.707 -		/* Ignore the second of two consecutive flushes: */
  35.708 -		if (len == 0 && s->z_err == Z_BUF_ERROR)
  35.709 -			s->z_err = Z_OK;
  35.710 -
  35.711 -		/* deflate has finished flushing only when it hasn't used up
  35.712 -		 * all the available space in the output buffer:
  35.713 -		 */
  35.714 -		done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
  35.715 -
  35.716 -		if (s->z_err != Z_OK && s->z_err != Z_STREAM_END)
  35.717 -			break;
  35.718 -	}
  35.719 -	return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
  35.720 -}
  35.721 -
  35.722 -/* ===========================================================================
  35.723 -   Outputs a long in LSB order to the given file
  35.724 - */
  35.725 -local void putLong(file, x)
  35.726 -MEMFILE *file;
  35.727 -uLong x;
  35.728 -{
  35.729 -	int n;
  35.730 -	for (n = 0; n < 4; n++)
  35.731 -	{
  35.732 -		memPutc((int)(x & 0xff), file);
  35.733 -		x >>= 8;
  35.734 -	}
  35.735 -}
  35.736 -
  35.737 -/* ===========================================================================
  35.738 -   Reads a long in LSB order from the given mem_stream. Sets z_err in case
  35.739 -   of error.
  35.740 - */
  35.741 -local uLong getLong(s)
  35.742 -mem_stream *s;
  35.743 -{
  35.744 -	uLong x = (uLong)get_byte(s);
  35.745 -	int   c;
  35.746 -
  35.747 -	x += ((uLong)get_byte(s))<<8;
  35.748 -	x += ((uLong)get_byte(s))<<16;
  35.749 -	c  = get_byte(s);
  35.750 -	if (c == EOF)
  35.751 -		s->z_err = Z_DATA_ERROR;
  35.752 -	x += ((uLong)c)<<24;
  35.753 -	return x;
  35.754 -}
  35.755 -
  35.756 -/* ===========================================================================
  35.757 -     Flushes all pending output if necessary, closes the compressed file
  35.758 -   and deallocates all the (de)compression state.
  35.759 - */
  35.760 -int ZEXPORT memgzclose(file)
  35.761 -gzFile file;
  35.762 -{
  35.763 -	int         err;
  35.764 -	mem_stream *s = (mem_stream *)file;
  35.765 -
  35.766 -	if (s == NULL)
  35.767 -		return Z_STREAM_ERROR;
  35.768 -
  35.769 -	if (s->mode == 'w')
  35.770 -	{
  35.771 -#ifdef NO_DEFLATE
  35.772 -		return Z_STREAM_ERROR;
  35.773 -#else
  35.774 -		err = do_flush(file, Z_FINISH);
  35.775 -		if (err != Z_OK)
  35.776 -			return destroy((mem_stream *)file);
  35.777 -
  35.778 -		putLong(s->file, s->crc);
  35.779 -		putLong(s->file, s->stream.total_in);
  35.780 -#endif
  35.781 -	}
  35.782 -	return destroy((mem_stream *)file);
  35.783 -}
  35.784 -
  35.785 -long ZEXPORT memtell(file)
  35.786 -gzFile file;
  35.787 -{
  35.788 -	mem_stream *s = (mem_stream *)file;
  35.789 -
  35.790 -	if (s == NULL)
  35.791 -		return Z_STREAM_ERROR;
  35.792 -
  35.793 -	return memTell(s->file);
  35.794 -}
    36.1 --- a/src/common/memgzio.h	Sat Mar 03 10:54:39 2012 -0600
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,23 +0,0 @@
    36.4 -#ifndef MEMGZIO_H
    36.5 -#define MEMGZIO_H
    36.6 -
    36.7 -/* gzio.c -- IO on .gz files
    36.8 - * Copyright (C) 1995-2002 Jean-loup Gailly.
    36.9 - * For conditions of distribution and use, see copyright notice in zlib.h
   36.10 - *
   36.11 - * Compile this file with -DNO_DEFLATE to avoid the compression code.
   36.12 - */
   36.13 -
   36.14 -/* memgzio.c - IO on .gz files in memory
   36.15 - * Adapted from original gzio.c from zlib library by Forgotten
   36.16 - */
   36.17 -
   36.18 -#include <zlib.h>
   36.19 -
   36.20 -gzFile ZEXPORT memgzopen(char *memory, int available, const char *mode);
   36.21 -int ZEXPORT memgzread(gzFile file, voidp buf, unsigned len);
   36.22 -int ZEXPORT memgzwrite(gzFile file, const voidp buf, unsigned len);
   36.23 -int ZEXPORT memgzclose(gzFile file);
   36.24 -long ZEXPORT memtell(gzFile file);
   36.25 -
   36.26 -#endif // MEMGZIO_H
    37.1 --- a/src/common/movie.cpp	Sat Mar 03 10:54:39 2012 -0600
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,1772 +0,0 @@
    37.4 -#include <cstdio>
    37.5 -#include <cctype>
    37.6 -#include <cstdlib>
    37.7 -#include <cstring>
    37.8 -#include <cassert>
    37.9 -#include <algorithm>
   37.10 -
   37.11 -using namespace std;
   37.12 -
   37.13 -#ifdef HAVE_STRINGS_H
   37.14 -#   include <strings.h>
   37.15 -#endif
   37.16 -
   37.17 -#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP)
   37.18 -#   include <unistd.h>
   37.19 -#   include <sys/types.h>
   37.20 -#   include <sys/stat.h>
   37.21 -#   include <climits>
   37.22 -#   define stricmp strcasecmp
   37.23 -// FIXME: this is wrong, but we don't want buffer overflow
   37.24 -#   if defined _MAX_PATH
   37.25 -#       undef _MAX_PATH
   37.26 -//#       define _MAX_PATH 128
   37.27 -#       define _MAX_PATH 260
   37.28 -#   endif
   37.29 -#endif
   37.30 -
   37.31 -#ifdef WIN32
   37.32 -#   include <io.h>
   37.33 -#   ifndef W_OK
   37.34 -#       define W_OK 2
   37.35 -#   endif
   37.36 -#   define ftruncate chsize
   37.37 -#endif
   37.38 -
   37.39 -#include "movie.h"
   37.40 -#include "System.h"
   37.41 -#include "../gba/GBA.h"
   37.42 -#include "../gba/GBAGlobals.h"
   37.43 -#include "../gba/RTC.h"
   37.44 -#include "../gb/GB.h"
   37.45 -#include "../gb/gbGlobals.h"
   37.46 -#include "inputGlobal.h"
   37.47 -#include "unzip.h"
   37.48 -#include "Util.h"
   37.49 -
   37.50 -#include "vbalua.h"
   37.51 -
   37.52 -#if (defined(WIN32) && !defined(SDL))
   37.53 -#   include "../win32/stdafx.h"
   37.54 -#   include "../win32/MainWnd.h"
   37.55 -#   include "../win32/VBA.h"
   37.56 -#   include "../win32/WinMiscUtil.h"
   37.57 -#endif
   37.58 -
   37.59 -extern int emulating; // from system.cpp
   37.60 -extern u16 currentButtons[4];     // from System.cpp
   37.61 -extern u16 lastKeys;
   37.62 -
   37.63 -SMovie Movie;
   37.64 -bool   loadingMovie = false;
   37.65 -
   37.66 -// probably bad idea to have so many global variables, but I hate to recompile almost everything after editing VBA.h
   37.67 -bool autoConvertMovieWhenPlaying = false;
   37.68 -
   37.69 -static u16 initialInputs[4] = { 0 };
   37.70 -
   37.71 -static bool resetSignaled	  = false;
   37.72 -static bool resetSignaledLast = false;
   37.73 -
   37.74 -static int prevEmulatorType, prevBorder, prevWinBorder, prevBorderAuto;
   37.75 -
   37.76 -// little-endian integer pop/push functions:
   37.77 -static inline uint32 Pop32(const uint8 * &ptr)
   37.78 -{
   37.79 -	uint32 v = (ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24));
   37.80 -	ptr += 4;
   37.81 -	return v;
   37.82 -}
   37.83 -
   37.84 -static inline uint16 Pop16(const uint8 * &ptr) /* const version */
   37.85 -{
   37.86 -	uint16 v = (ptr[0] | (ptr[1] << 8));
   37.87 -	ptr += 2;
   37.88 -	return v;
   37.89 -}
   37.90 -
   37.91 -static inline uint16 Pop16(uint8 * &ptr) /* non-const version */
   37.92 -{
   37.93 -	uint16 v = (ptr[0] | (ptr[1] << 8));
   37.94 -	ptr += 2;
   37.95 -	return v;
   37.96 -}
   37.97 -
   37.98 -static inline uint8 Pop8(const uint8 * &ptr)
   37.99 -{
  37.100 -	return *(ptr)++;
  37.101 -}
  37.102 -
  37.103 -static inline void Push32(uint32 v, uint8 * &ptr)
  37.104 -{
  37.105 -	ptr[0] = (uint8)(v & 0xff);
  37.106 -	ptr[1] = (uint8)((v >> 8) & 0xff);
  37.107 -	ptr[2] = (uint8)((v >> 16) & 0xff);
  37.108 -	ptr[3] = (uint8)((v >> 24) & 0xff);
  37.109 -	ptr	  += 4;
  37.110 -}
  37.111 -
  37.112 -static inline void Push16(uint16 v, uint8 * &ptr)
  37.113 -{
  37.114 -	ptr[0] = (uint8)(v & 0xff);
  37.115 -	ptr[1] = (uint8)((v >> 8) & 0xff);
  37.116 -	ptr	  += 2;
  37.117 -}
  37.118 -
  37.119 -static inline void Push8(uint8 v, uint8 * &ptr)
  37.120 -{
  37.121 -	*ptr++ = v;
  37.122 -}
  37.123 -
  37.124 -// little-endian integer read/write functions:
  37.125 -static inline uint16 Read16(const uint8 *ptr)
  37.126 -{
  37.127 -	return ptr[0] | (ptr[1] << 8);
  37.128 -}
  37.129 -
  37.130 -static inline void Write16(uint16 v, uint8 *ptr)
  37.131 -{
  37.132 -	ptr[0] = uint8(v & 0xff);
  37.133 -	ptr[1] = uint8((v >> 8) & 0xff);
  37.134 -}
  37.135 -
  37.136 -static long file_length(FILE *fp)
  37.137 -{
  37.138 -	long cur_pos = ftell(fp);
  37.139 -	fseek(fp, 0, SEEK_END);
  37.140 -	long length = ftell(fp);
  37.141 -	fseek(fp, cur_pos, SEEK_SET);
  37.142 -	return length;
  37.143 -}
  37.144 -
  37.145 -static int bytes_per_frame(SMovie &mov)
  37.146 -{
  37.147 -	int num_controllers = 0;
  37.148 -
  37.149 -	for (int i = 0; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS; ++i)
  37.150 -		if (mov.header.controllerFlags & MOVIE_CONTROLLER(i))
  37.151 -			++num_controllers;
  37.152 -
  37.153 -	return CONTROLLER_DATA_SIZE * num_controllers;
  37.154 -}
  37.155 -
  37.156 -static void reserve_buffer_space(uint32 space_needed)
  37.157 -{
  37.158 -	if (space_needed > Movie.inputBufferSize)
  37.159 -	{
  37.160 -		uint32 ptr_offset	= Movie.inputBufferPtr - Movie.inputBuffer;
  37.161 -		uint32 alloc_chunks = (space_needed - 1) / BUFFER_GROWTH_SIZE + 1;
  37.162 -		uint32 old_size     = Movie.inputBufferSize;
  37.163 -		Movie.inputBufferSize = BUFFER_GROWTH_SIZE * alloc_chunks;
  37.164 -		Movie.inputBuffer	  = (uint8 *)realloc(Movie.inputBuffer, Movie.inputBufferSize);
  37.165 -		// FIXME: this only fixes the random input problem during dma-frame-skip, but not the skip
  37.166 -		memset(Movie.inputBuffer + old_size, 0, Movie.inputBufferSize - old_size);
  37.167 -		Movie.inputBufferPtr  = Movie.inputBuffer + ptr_offset;
  37.168 -	}
  37.169 -}
  37.170 -
  37.171 -static int read_movie_header(FILE *file, SMovie &movie)
  37.172 -{
  37.173 -	assert(file != NULL);
  37.174 -	assert(VBM_HEADER_SIZE == sizeof(SMovieFileHeader)); // sanity check on the header type definition
  37.175 -
  37.176 -	uint8 headerData [VBM_HEADER_SIZE];
  37.177 -
  37.178 -	if (fread(headerData, 1, VBM_HEADER_SIZE, file) != VBM_HEADER_SIZE)
  37.179 -		return MOVIE_WRONG_FORMAT;  // if we failed to read in all VBM_HEADER_SIZE bytes of the header
  37.180 -
  37.181 -	const uint8 *	  ptr	 = headerData;
  37.182 -	SMovieFileHeader &header = movie.header;
  37.183 -
  37.184 -	header.magic = Pop32(ptr);
  37.185 -	if (header.magic != VBM_MAGIC)
  37.186 -		return MOVIE_WRONG_FORMAT;
  37.187 -
  37.188 -	header.version = Pop32(ptr);
  37.189 -	if (header.version != VBM_VERSION)
  37.190 -		return MOVIE_WRONG_VERSION;
  37.191 -
  37.192 -	header.uid = Pop32(ptr);
  37.193 -	header.length_frames  = Pop32(ptr) + 1;    // HACK: add 1 to the length for compatibility
  37.194 -	header.rerecord_count = Pop32(ptr);
  37.195 -
  37.196 -	header.startFlags	   = Pop8(ptr);
  37.197 -	header.controllerFlags = Pop8(ptr);
  37.198 -	header.typeFlags	   = Pop8(ptr);
  37.199 -	header.optionFlags	   = Pop8(ptr);
  37.200 -
  37.201 -	header.saveType		  = Pop32(ptr);
  37.202 -	header.flashSize	  = Pop32(ptr);
  37.203 -	header.gbEmulatorType = Pop32(ptr);
  37.204 -
  37.205 -	for (int i = 0; i < 12; i++)
  37.206 -		header.romTitle[i] = Pop8(ptr);
  37.207 -
  37.208 -	header.minorVersion = Pop8(ptr);
  37.209 -
  37.210 -	header.romCRC = Pop8(ptr);
  37.211 -	header.romOrBiosChecksum = Pop16(ptr);
  37.212 -	header.romGameCode		 = Pop32(ptr);
  37.213 -
  37.214 -	header.offset_to_savestate		 = Pop32(ptr);
  37.215 -	header.offset_to_controller_data = Pop32(ptr);
  37.216 -
  37.217 -	return MOVIE_SUCCESS;
  37.218 -}
  37.219 -
  37.220 -static void write_movie_header(FILE *file, const SMovie &movie)
  37.221 -{
  37.222 -	assert(ftell(file) == 0); // we assume file points to beginning of movie file
  37.223 -
  37.224 -	uint8  headerData [VBM_HEADER_SIZE];
  37.225 -	uint8 *ptr = headerData;
  37.226 -	const SMovieFileHeader &header = movie.header;
  37.227 -
  37.228 -	Push32(header.magic, ptr);
  37.229 -	Push32(header.version, ptr);
  37.230 -
  37.231 -	Push32(header.uid, ptr);
  37.232 -	Push32(header.length_frames - 1, ptr);     // HACK: reduce the length by 1 for compatibility with certain faulty old tools
  37.233 -	                                           // like TME
  37.234 -	Push32(header.rerecord_count, ptr);
  37.235 -
  37.236 -	Push8(header.startFlags, ptr);
  37.237 -	Push8(header.controllerFlags, ptr);
  37.238 -	Push8(header.typeFlags, ptr);
  37.239 -	Push8(header.optionFlags, ptr);
  37.240 -
  37.241 -	Push32(header.saveType, ptr);
  37.242 -	Push32(header.flashSize, ptr);
  37.243 -	Push32(header.gbEmulatorType, ptr);
  37.244 -
  37.245 -	for (int i = 0; i < 12; ++i)
  37.246 -		Push8(header.romTitle[i], ptr);
  37.247 -
  37.248 -	Push8(header.minorVersion, ptr);
  37.249 -
  37.250 -	Push8(header.romCRC, ptr);
  37.251 -	Push16(header.romOrBiosChecksum, ptr);
  37.252 -	Push32(header.romGameCode, ptr);
  37.253 -
  37.254 -	Push32(header.offset_to_savestate, ptr);
  37.255 -	Push32(header.offset_to_controller_data, ptr);
  37.256 -
  37.257 -	fwrite(headerData, 1, VBM_HEADER_SIZE, file);
  37.258 -}
  37.259 -
  37.260 -static void flush_movie_header()
  37.261 -{
  37.262 -	assert(Movie.file != 0 && "logical error!");
  37.263 -	if (!Movie.file)
  37.264 -		return;
  37.265 -
  37.266 -	long originalPos = ftell(Movie.file);
  37.267 -
  37.268 -	// (over-)write the header
  37.269 -	fseek(Movie.file, 0, SEEK_SET);
  37.270 -	write_movie_header(Movie.file, Movie);
  37.271 -
  37.272 -	fflush(Movie.file);
  37.273 -
  37.274 -	fseek(Movie.file, originalPos, SEEK_SET);
  37.275 -}
  37.276 -
  37.277 -static void flush_movie_frames()
  37.278 -{
  37.279 -	assert(Movie.file && "logical error!");
  37.280 -	if (!Movie.file)
  37.281 -		return;
  37.282 -
  37.283 -	long originalPos = ftell(Movie.file);
  37.284 -
  37.285 -	// overwrite the controller data
  37.286 -	fseek(Movie.file, Movie.header.offset_to_controller_data, SEEK_SET);
  37.287 -	fwrite(Movie.inputBuffer, 1, Movie.bytesPerFrame * Movie.header.length_frames, Movie.file);
  37.288 -
  37.289 -	fflush(Movie.file);
  37.290 -
  37.291 -	fseek(Movie.file, originalPos, SEEK_SET);
  37.292 -}
  37.293 -
  37.294 -static void truncate_movie(long length)
  37.295 -{
  37.296 -	// truncate movie to length
  37.297 -	// NOTE: it's certain that the savestate block is never after the
  37.298 -	//       controller data block, because the VBM format decrees it.
  37.299 -
  37.300 -	assert(Movie.file && length >= 0);
  37.301 -	if (!Movie.file || length < 0)
  37.302 -		return;
  37.303 -
  37.304 -	assert(Movie.header.offset_to_savestate <= Movie.header.offset_to_controller_data);
  37.305 -	if (Movie.header.offset_to_savestate > Movie.header.offset_to_controller_data)
  37.306 -		return;
  37.307 -
  37.308 -	Movie.header.length_frames = length;
  37.309 -	flush_movie_header();
  37.310 -	const long truncLen = long(Movie.header.offset_to_controller_data + Movie.bytesPerFrame * length);
  37.311 -	if (file_length(Movie.file) != truncLen)
  37.312 -	{
  37.313 -		ftruncate(fileno(Movie.file), truncLen);
  37.314 -	}
  37.315 -}
  37.316 -
  37.317 -static void remember_input_state()
  37.318 -{
  37.319 -	for (int i = 0; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS; ++i)
  37.320 -	{
  37.321 -		if (systemCartridgeType == 0)
  37.322 -		{
  37.323 -			initialInputs[i] = u16(~P1 & 0x03FF);
  37.324 -		}
  37.325 -		else
  37.326 -		{
  37.327 -			extern int32 gbJoymask[4];
  37.328 -			for (int i = 0; i < 4; ++i)
  37.329 -				initialInputs[i] = u16(gbJoymask[i] & 0xFFFF);
  37.330 -		}
  37.331 -	}
  37.332 -}
  37.333 -
  37.334 -static void change_state(MovieState new_state)
  37.335 -{
  37.336 -#if (defined(WIN32) && !defined(SDL))
  37.337 -	theApp.frameSearching	   = false;
  37.338 -	theApp.frameSearchSkipping = false;
  37.339 -#endif
  37.340 -
  37.341 -	if (new_state == MOVIE_STATE_NONE)
  37.342 -	{
  37.343 -		Movie.pauseFrame = -1;
  37.344 -
  37.345 -		if (Movie.state == MOVIE_STATE_NONE)
  37.346 -			return;
  37.347 -
  37.348 -		truncate_movie(Movie.header.length_frames);
  37.349 -
  37.350 -		fclose(Movie.file);
  37.351 -		Movie.file		   = NULL;
  37.352 -		Movie.currentFrame = 0;
  37.353 -#if (defined(WIN32) && !defined(SDL))
  37.354 -		// undo changes to border settings
  37.355 -		{
  37.356 -			gbBorderOn = prevBorder;
  37.357 -			theApp.winGbBorderOn = prevWinBorder;
  37.358 -			gbBorderAutomatic	 = prevBorderAuto;
  37.359 -			systemGbBorderOn();
  37.360 -		}
  37.361 -#endif
  37.362 -		gbEmulatorType = prevEmulatorType;
  37.363 -
  37.364 -		extern int32 gbDMASpeedVersion;
  37.365 -		gbDMASpeedVersion = 1;
  37.366 -
  37.367 -		extern int32 gbEchoRAMFixOn;
  37.368 -		gbEchoRAMFixOn = 1;
  37.369 -
  37.370 -		gbNullInputHackTempEnabled = gbNullInputHackEnabled;
  37.371 -
  37.372 -		if (Movie.inputBuffer)
  37.373 -		{
  37.374 -			free(Movie.inputBuffer);
  37.375 -			Movie.inputBuffer = NULL;
  37.376 -		}
  37.377 -	}
  37.378 -	else if (new_state == MOVIE_STATE_PLAY)
  37.379 -	{
  37.380 -		assert(Movie.file);
  37.381 -
  37.382 -		// this would cause problems if not dealt with
  37.383 -		if (Movie.currentFrame >= Movie.header.length_frames)
  37.384 -		{
  37.385 -			new_state = MOVIE_STATE_END;
  37.386 -			Movie.inputBufferPtr = Movie.inputBuffer + Movie.bytesPerFrame * Movie.header.length_frames;
  37.387 -		}
  37.388 -	}
  37.389 -	else if (new_state == MOVIE_STATE_RECORD)
  37.390 -	{
  37.391 -		assert(Movie.file);
  37.392 -
  37.393 -		// this would cause problems if not dealt with
  37.394 -		if (Movie.currentFrame > Movie.header.length_frames)
  37.395 -		{
  37.396 -			new_state = MOVIE_STATE_END;
  37.397 -			Movie.inputBufferPtr = Movie.inputBuffer + Movie.bytesPerFrame * Movie.header.length_frames;
  37.398 -		}
  37.399 -
  37.400 -		fseek(Movie.file, Movie.header.offset_to_controller_data + Movie.bytesPerFrame * Movie.currentFrame, SEEK_SET);
  37.401 -	}
  37.402 -
  37.403 -	if (new_state == MOVIE_STATE_END && Movie.state != MOVIE_STATE_END)
  37.404 -	{
  37.405 -#if defined(SDL)		
  37.406 -		systemClearJoypads();
  37.407 -#endif
  37.408 -		systemScreenMessage("Movie end");
  37.409 -	}
  37.410 -
  37.411 -	Movie.state = new_state;
  37.412 -
  37.413 -	// checking for movie end
  37.414 -	bool willPause = false;
  37.415 -
  37.416 -	// if the movie's been set to pause at a certain frame
  37.417 -	if (Movie.state != MOVIE_STATE_NONE && Movie.pauseFrame >= 0 && Movie.currentFrame == (uint32)Movie.pauseFrame)
  37.418 -	{
  37.419 -		Movie.pauseFrame = -1;
  37.420 -		willPause		 = true;
  37.421 -	}
  37.422 -
  37.423 -	if (Movie.state == MOVIE_STATE_END)
  37.424 -	{
  37.425 -		if (Movie.currentFrame == Movie.header.length_frames)
  37.426 -		{
  37.427 -#if (defined(WIN32) && !defined(SDL))
  37.428 -			if (theApp.movieOnEndPause)
  37.429 -			{
  37.430 -				willPause = true;
  37.431 -			}
  37.432 -#else
  37.433 -			// SDL FIXME
  37.434 -#endif
  37.435 -
  37.436 -#if (defined(WIN32) && !defined(SDL))
  37.437 -			switch (theApp.movieOnEndBehavior)
  37.438 -			{
  37.439 -			case 1:
  37.440 -				// the old behavior
  37.441 -				//VBAMovieRestart();
  37.442 -				break;
  37.443 -			case 2:
  37.444 -#else
  37.445 -			// SDL FIXME
  37.446 -#endif
  37.447 -				if (Movie.RecordedThisSession)
  37.448 -				{
  37.449 -					// if user has been recording this movie since the last time it started playing,
  37.450 -					// they probably don't want the movie to end now during playback,
  37.451 -					// so switch back to recording when it reaches the end
  37.452 -					VBAMovieSwitchToRecording();
  37.453 -					systemScreenMessage("Recording resumed");
  37.454 -					willPause = true;
  37.455 -				}
  37.456 -#if (defined(WIN32) && !defined(SDL))
  37.457 -				break;
  37.458 -			case 3:
  37.459 -				// keep open
  37.460 -				break;
  37.461 -			case 0:
  37.462 -				// fall through
  37.463 -			default:
  37.464 -				// close movie
  37.465 -				//VBAMovieStop(false);
  37.466 -				break;
  37.467 -			}
  37.468 -#else
  37.469 -				// SDL FIXME
  37.470 -#endif
  37.471 -		}
  37.472 -#if 1
  37.473 -		else if (Movie.currentFrame > Movie.header.length_frames)
  37.474 -		{
  37.475 -#if (defined(WIN32) && !defined(SDL))
  37.476 -			switch (theApp.movieOnEndBehavior)
  37.477 -			{
  37.478 -			case 1:
  37.479 -				// FIXME: this should be delayed till the current frame ends
  37.480 -				VBAMovieRestart();
  37.481 -				break;
  37.482 -			case 2:
  37.483 -				// nothing
  37.484 -				break;
  37.485 -			case 3:
  37.486 -				// keep open
  37.487 -				break;
  37.488 -			case 0:
  37.489 -				// fall through
  37.490 -			default:
  37.491 -				// close movie
  37.492 -				VBAMovieStop(false);
  37.493 -				break;
  37.494 -			}
  37.495 -#else
  37.496 -			// SDLFIXME
  37.497 -#endif
  37.498 -		}
  37.499 -#endif
  37.500 -	} // end if (Movie.state == MOVIE_STATE_END)
  37.501 -
  37.502 -	if (willPause)
  37.503 -	{
  37.504 -		systemSetPause(true);
  37.505 -	}
  37.506 -}
  37.507 -
  37.508 -void VBAMovieInit()
  37.509 -{
  37.510 -	memset(&Movie, 0, sizeof(Movie));
  37.511 -	Movie.state		 = MOVIE_STATE_NONE;
  37.512 -	Movie.pauseFrame = -1;
  37.513 -
  37.514 -	resetSignaled	  = false;
  37.515 -	resetSignaledLast = false;
  37.516 -}
  37.517 -
  37.518 -void VBAMovieGetRomInfo(const SMovie &movieInfo, char romTitle [12], uint32 &romGameCode, uint16 &checksum, uint8 &crc)
  37.519 -{
  37.520 -	if (systemCartridgeType == 0) // GBA
  37.521 -	{
  37.522 -		extern u8 *bios, *rom;
  37.523 -		memcpy(romTitle, &rom[0xa0], 12); // GBA TITLE
  37.524 -		memcpy(&romGameCode, &rom[0xac], 4); // GBA ROM GAME CODE
  37.525 -		if ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0)
  37.526 -			checksum = utilCalcBIOSChecksum(bios, 4);  // GBA BIOS CHECKSUM
  37.527 -		else
  37.528 -			checksum = 0;
  37.529 -		crc = rom[0xbd]; // GBA ROM CRC
  37.530 -	}
  37.531 -	else // non-GBA
  37.532 -	{
  37.533 -		extern u8 *gbRom;
  37.534 -		memcpy(romTitle, &gbRom[0x134], 12); // GB TITLE (note this can be 15 but is truncated to 12)
  37.535 -		romGameCode = (uint32)gbRom[0x146]; // GB ROM UNIT CODE
  37.536 -
  37.537 -		checksum = (gbRom[0x14e] << 8) | gbRom[0x14f]; // GB ROM CHECKSUM, read from big-endian
  37.538 -		crc		 = gbRom[0x14d]; // GB ROM CRC
  37.539 -	}
  37.540 -}
  37.541 -
  37.542 -#ifdef SDL
  37.543 -static void GetBatterySaveName(char *buffer)
  37.544 -{
  37.545 -	extern char batteryDir[2048], filename[2048];     // from SDL.cpp
  37.546 -	extern char *sdlGetFilename(char *name);     // from SDL.cpp
  37.547 -	if (batteryDir[0])
  37.548 -		sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
  37.549 -	else
  37.550 -		sprintf(buffer, "%s.sav", filename);
  37.551 -}
  37.552 -
  37.553 -#endif
  37.554 -
  37.555 -static void SetPlayEmuSettings()
  37.556 -{
  37.557 -	prevEmulatorType = gbEmulatorType;
  37.558 -	gbEmulatorType	 = Movie.header.gbEmulatorType;
  37.559 -
  37.560 -#if (defined(WIN32) && !defined(SDL))
  37.561 -//    theApp.removeIntros   = false;
  37.562 -	theApp.skipBiosFile = (Movie.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE) != 0;
  37.563 -	theApp.useBiosFile	= (Movie.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
  37.564 -#else
  37.565 -	extern int	 saveType, sdlRtcEnable, sdlFlashSize;   // from SDL.cpp
  37.566 -	extern bool8 useBios, skipBios, removeIntros;     // from SDL.cpp
  37.567 -	useBios		 = (Movie.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
  37.568 -	skipBios	 = (Movie.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE) != 0;
  37.569 -	removeIntros = false /*(Movie.header.optionFlags & MOVIE_SETTING_REMOVEINTROS) != 0*/;
  37.570 -#endif
  37.571 -
  37.572 -	extern void SetPrefetchHack(bool);
  37.573 -	if (systemCartridgeType == 0)    // lag disablement applies only to GBA
  37.574 -		SetPrefetchHack((Movie.header.optionFlags & MOVIE_SETTING_LAGHACK) != 0);
  37.575 -
  37.576 -	gbNullInputHackTempEnabled = ((Movie.header.optionFlags & MOVIE_SETTING_GBINPUTHACK) != 0);
  37.577 -
  37.578 -	// some GB/GBC games depend on the sound rate, so just use the highest one
  37.579 -	systemSoundSetQuality(1);
  37.580 -	useOldFrameTiming = false;
  37.581 -
  37.582 -	extern int32 gbDMASpeedVersion;
  37.583 -	if ((Movie.header.optionFlags & MOVIE_SETTING_GBCFF55FIX) != 0)
  37.584 -		gbDMASpeedVersion = 1;
  37.585 -	else
  37.586 -		gbDMASpeedVersion = 0;     // old CGB HDMA5 timing was used
  37.587 -
  37.588 -	extern int32 gbEchoRAMFixOn;
  37.589 -	if ((Movie.header.optionFlags & MOVIE_SETTING_GBECHORAMFIX) != 0)
  37.590 -		gbEchoRAMFixOn = 1;
  37.591 -	else
  37.592 -		gbEchoRAMFixOn = 0;
  37.593 -
  37.594 -#if (defined(WIN32) && !defined(SDL))
  37.595 -	rtcEnable((Movie.header.optionFlags & MOVIE_SETTING_RTCENABLE) != 0);
  37.596 -	theApp.winSaveType	= Movie.header.saveType;
  37.597 -	theApp.winFlashSize = Movie.header.flashSize;
  37.598 -
  37.599 -	prevBorder	   = gbBorderOn;
  37.600 -	prevWinBorder  = theApp.winGbBorderOn;
  37.601 -	prevBorderAuto = gbBorderAutomatic;
  37.602 -	if ((gbEmulatorType == 2 || gbEmulatorType == 5)
  37.603 -	    && !theApp.hideMovieBorder) // games played in SGB mode can have a border
  37.604 -	{
  37.605 -		gbBorderOn = true;
  37.606 -		theApp.winGbBorderOn = true;
  37.607 -		gbBorderAutomatic	 = false;
  37.608 -	}
  37.609 -	else
  37.610 -	{
  37.611 -		gbBorderOn = false;
  37.612 -		theApp.winGbBorderOn = false;
  37.613 -		gbBorderAutomatic	 = false;
  37.614 -		if (theApp.hideMovieBorder)
  37.615 -		{
  37.616 -			theApp.hideMovieBorder = false;
  37.617 -			prevBorder = false;     // it might be expected behaviour that it stays hidden after the movie
  37.618 -		}
  37.619 -	}
  37.620 -	systemGbBorderOn();
  37.621 -#else
  37.622 -	sdlRtcEnable = (Movie.header.optionFlags & MOVIE_SETTING_RTCENABLE) != 0;
  37.623 -	saveType	 = Movie.header.saveType;
  37.624 -	sdlFlashSize = Movie.header.flashSize;
  37.625 -#endif
  37.626 -}
  37.627 -
  37.628 -static void HardResetAndSRAMClear()
  37.629 -{
  37.630 -#if (defined(WIN32) && !defined(SDL))
  37.631 -	winEraseBatteryFile(); // delete the damn SRAM file and keep it from being resurrected from RAM
  37.632 -	MainWnd *temp = ((MainWnd *)theApp.m_pMainWnd);
  37.633 -	if (!temp->winFileRun(true)) // restart running the game
  37.634 -	{
  37.635 -		temp->winFileClose();
  37.636 -	}
  37.637 -#else
  37.638 -	char fname [1024];
  37.639 -	GetBatterySaveName(fname);
  37.640 -	remove(fname);     // delete the damn SRAM file
  37.641 -
  37.642 -	// Henceforth, emuCleanUp means "clear out SRAM"
  37.643 -	//theEmulator.emuCleanUp();     // keep it from being resurrected from RAM <--This is wrong, it'll deallocate all variables --Felipe
  37.644 -
  37.645 -	/// FIXME the correct SDL code to call for a full restart isn't in a function yet
  37.646 -	theEmulator.emuReset(false);
  37.647 -#endif
  37.648 -}
  37.649 -
  37.650 -int VBAMovieOpen(const char *filename, bool8 read_only)
  37.651 -{
  37.652 -	loadingMovie = true;
  37.653 -	uint8 movieReadOnly = read_only ? 1 : 0;
  37.654 -
  37.655 -	FILE * file;
  37.656 -	STREAM stream;
  37.657 -	int	   result;
  37.658 -	int	   fn;
  37.659 -
  37.660 -	char movie_filename[_MAX_PATH];
  37.661 -#ifdef WIN32
  37.662 -	_fullpath(movie_filename, filename, _MAX_PATH);
  37.663 -#else
  37.664 -	// SDL FIXME: convert to fullpath
  37.665 -	strncpy(movie_filename, filename, _MAX_PATH);
  37.666 -	movie_filename[_MAX_PATH - 1] = '\0';
  37.667 -#endif
  37.668 -
  37.669 -	if (movie_filename[0] == '\0')
  37.670 -	{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.671 -
  37.672 -	if (!emulating)
  37.673 -	{ loadingMovie = false; return MOVIE_UNKNOWN_ERROR; }
  37.674 -
  37.675 -//	bool alreadyOpen = (Movie.file != NULL && _stricmp(movie_filename, Movie.filename) == 0);
  37.676 -
  37.677 -//	if (alreadyOpen)
  37.678 -	change_state(MOVIE_STATE_NONE);     // have to stop current movie before trying to re-open it
  37.679 -
  37.680 -	if (!(file = fopen(movie_filename, "rb+")))
  37.681 -		if (!(file = fopen(movie_filename, "rb")))
  37.682 -		{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.683 -	//else
  37.684 -	//	movieReadOnly = 2; // we have to open the movie twice, no need to do this both times
  37.685 -
  37.686 -//	if (!alreadyOpen)
  37.687 -//		change_state(MOVIE_STATE_NONE); // stop current movie when we're able to open the other one
  37.688 -//
  37.689 -//	if (!(file = fopen(movie_filename, "rb+")))
  37.690 -//		if(!(file = fopen(movie_filename, "rb")))
  37.691 -//			{loadingMovie = false; return MOVIE_FILE_NOT_FOUND;}
  37.692 -//		else
  37.693 -//			movieReadOnly = 2;
  37.694 -
  37.695 -	// clear out the current movie
  37.696 -	VBAMovieInit();
  37.697 -
  37.698 -	// read header
  37.699 -	if ((result = read_movie_header(file, Movie)) != MOVIE_SUCCESS)
  37.700 -	{
  37.701 -		fclose(file);
  37.702 -		{ loadingMovie = false; return result; }
  37.703 -	}
  37.704 -
  37.705 -	// set emulator settings that make the movie more likely to stay synchronized
  37.706 -	SetPlayEmuSettings();
  37.707 -
  37.708 -//	extern bool systemLoadBIOS();
  37.709 -//	if (!systemLoadBIOS())
  37.710 -//	{ loadingMovie = false; return MOVIE_UNKNOWN_ERROR; }
  37.711 -
  37.712 -	// read the metadata / author info from file
  37.713 -	fread(Movie.authorInfo, 1, MOVIE_METADATA_SIZE, file);
  37.714 -	fn = dup(fileno(file)); // XXX: why does this fail?? it returns -1 but errno == 0
  37.715 -	fclose(file);
  37.716 -
  37.717 -	// apparently this lseek is necessary
  37.718 -	lseek(fn, Movie.header.offset_to_savestate, SEEK_SET);
  37.719 -	if (!(stream = utilGzReopen(fn, "rb")))
  37.720 -		if (!(stream = utilGzOpen(movie_filename, "rb")))
  37.721 -		{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.722 -		else
  37.723 -			fn = dup(fileno(file));
  37.724 -	// in case the above dup failed but opening the file normally doesn't fail
  37.725 -
  37.726 -	if (Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT)
  37.727 -	{
  37.728 -		// load the snapshot
  37.729 -		result = theEmulator.emuReadStateFromStream(stream) ? MOVIE_SUCCESS : MOVIE_WRONG_FORMAT;
  37.730 -
  37.731 -		// FIXME: Kludge for conversion
  37.732 -		remember_input_state();
  37.733 -	}
  37.734 -	else if (Movie.header.startFlags & MOVIE_START_FROM_SRAM)
  37.735 -	{
  37.736 -		// 'soft' reset:
  37.737 -		theEmulator.emuReset(false);
  37.738 -
  37.739 -		// load the SRAM
  37.740 -		result = theEmulator.emuReadBatteryFromStream(stream) ? MOVIE_SUCCESS : MOVIE_WRONG_FORMAT;
  37.741 -	}
  37.742 -	else
  37.743 -	{
  37.744 -		HardResetAndSRAMClear();
  37.745 -	}
  37.746 -
  37.747 -	utilGzClose(stream);
  37.748 -
  37.749 -	if (result != MOVIE_SUCCESS)
  37.750 -	{ loadingMovie = false; return result; }
  37.751 -
  37.752 -//	if (!(file = fopen(movie_filename, /*read_only ? "rb" :*/ "rb+"))) // want to be able to switch out of read-only later
  37.753 -//	{
  37.754 -//		if(!Movie.readOnly || !(file = fopen(movie_filename, "rb"))) // try read-only if failed
  37.755 -//			return MOVIE_FILE_NOT_FOUND;
  37.756 -//	}
  37.757 -	if (!(file = fopen(movie_filename, "rb+")))
  37.758 -		if (!(file = fopen(movie_filename, "rb")))
  37.759 -		{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.760 -		else
  37.761 -			movieReadOnly = 2;
  37.762 -
  37.763 -	// recalculate length of movie from the file size
  37.764 -	Movie.bytesPerFrame = bytes_per_frame(Movie);
  37.765 -	fseek(file, 0, SEEK_END);
  37.766 -	long fileSize = ftell(file);
  37.767 -	Movie.header.length_frames = (fileSize - Movie.header.offset_to_controller_data) / Movie.bytesPerFrame;
  37.768 -
  37.769 -	if (fseek(file, Movie.header.offset_to_controller_data, SEEK_SET))
  37.770 -	{ fclose(file); loadingMovie = false; return MOVIE_WRONG_FORMAT; }
  37.771 -
  37.772 -	strcpy(Movie.filename, movie_filename);
  37.773 -	Movie.file = file;
  37.774 -	Movie.inputBufferPtr	  = Movie.inputBuffer;
  37.775 -	Movie.currentFrame		  = 0;
  37.776 -	Movie.readOnly			  = movieReadOnly;
  37.777 -	Movie.RecordedThisSession = false;
  37.778 -
  37.779 -	// read controller data
  37.780 -	uint32 to_read = Movie.bytesPerFrame * Movie.header.length_frames;
  37.781 -	reserve_buffer_space(to_read);
  37.782 -	fread(Movie.inputBuffer, 1, to_read, file);
  37.783 -
  37.784 -	change_state(MOVIE_STATE_PLAY);
  37.785 -
  37.786 -	char messageString[64] = "Movie ";
  37.787 -	bool converted		   = false;
  37.788 -	if (autoConvertMovieWhenPlaying)
  37.789 -	{
  37.790 -		int result = VBAMovieConvertCurrent();
  37.791 -		if (result == MOVIE_SUCCESS)
  37.792 -			strcat(messageString, "converted and ");
  37.793 -		else if (result == MOVIE_WRONG_VERSION)
  37.794 -			strcat(messageString, "higher revision ");
  37.795 -	}
  37.796 -
  37.797 -	if (Movie.state == MOVIE_STATE_PLAY)
  37.798 -		strcat(messageString, "replaying ");
  37.799 -	else
  37.800 -		strcat(messageString, "finished ");
  37.801 -	if (Movie.readOnly)
  37.802 -		strcat(messageString, "(read)");
  37.803 -	else
  37.804 -		strcat(messageString, "(edit)");
  37.805 -	systemScreenMessage(messageString);
  37.806 -
  37.807 -	VBAUpdateButtonPressDisplay();
  37.808 -	VBAUpdateFrameCountDisplay();
  37.809 -	systemRefreshScreen();
  37.810 -
  37.811 -	{ loadingMovie = false; return MOVIE_SUCCESS; }
  37.812 -}
  37.813 -
  37.814 -static void SetRecordEmuSettings()
  37.815 -{
  37.816 -	Movie.header.optionFlags = 0;
  37.817 -#if (defined(WIN32) && !defined(SDL))
  37.818 -	if (theApp.useBiosFile)
  37.819 -		Movie.header.optionFlags |= MOVIE_SETTING_USEBIOSFILE;
  37.820 -	if (theApp.skipBiosFile)
  37.821 -		Movie.header.optionFlags |= MOVIE_SETTING_SKIPBIOSFILE;
  37.822 -	if (rtcIsEnabled())
  37.823 -		Movie.header.optionFlags |= MOVIE_SETTING_RTCENABLE;
  37.824 -	Movie.header.saveType  = theApp.winSaveType;
  37.825 -	Movie.header.flashSize = theApp.winFlashSize;
  37.826 -#else
  37.827 -	extern int	 saveType, sdlRtcEnable, sdlFlashSize;   // from SDL.cpp
  37.828 -	extern bool8 useBios, skipBios;     // from SDL.cpp
  37.829 -	if (useBios)
  37.830 -		Movie.header.optionFlags |= MOVIE_SETTING_USEBIOSFILE;
  37.831 -	if (skipBios)
  37.832 -		Movie.header.optionFlags |= MOVIE_SETTING_SKIPBIOSFILE;
  37.833 -	if (sdlRtcEnable)
  37.834 -		Movie.header.optionFlags |= MOVIE_SETTING_RTCENABLE;
  37.835 -	Movie.header.saveType  = saveType;
  37.836 -	Movie.header.flashSize = sdlFlashSize;
  37.837 -#endif
  37.838 -	prevEmulatorType = Movie.header.gbEmulatorType = gbEmulatorType;
  37.839 -
  37.840 -	if (!memLagTempEnabled)
  37.841 -		Movie.header.optionFlags |= MOVIE_SETTING_LAGHACK;
  37.842 -
  37.843 -	if (gbNullInputHackTempEnabled)
  37.844 -		Movie.header.optionFlags |= MOVIE_SETTING_GBINPUTHACK;
  37.845 -
  37.846 -	Movie.header.optionFlags |= MOVIE_SETTING_GBCFF55FIX;
  37.847 -	extern int32 gbDMASpeedVersion;
  37.848 -	gbDMASpeedVersion = 1;
  37.849 -
  37.850 -	Movie.header.optionFlags |= MOVIE_SETTING_GBECHORAMFIX;
  37.851 -	extern int32 gbEchoRAMFixOn;
  37.852 -	gbEchoRAMFixOn = 1;
  37.853 -
  37.854 -	// some GB/GBC games depend on the sound rate, so just use the highest one
  37.855 -	systemSoundSetQuality(1);
  37.856 -
  37.857 -	useOldFrameTiming = false;
  37.858 -
  37.859 -#if (defined(WIN32) && !defined(SDL))
  37.860 -//    theApp.removeIntros   = false;
  37.861 -
  37.862 -	prevBorder	   = gbBorderOn;
  37.863 -	prevWinBorder  = theApp.winGbBorderOn;
  37.864 -	prevBorderAuto = gbBorderAutomatic;
  37.865 -	if (gbEmulatorType == 2 || gbEmulatorType == 5)     // only games played in SGB mode will have a border
  37.866 -	{
  37.867 -		gbBorderOn = true;
  37.868 -		theApp.winGbBorderOn = true;
  37.869 -		gbBorderAutomatic	 = false;
  37.870 -	}
  37.871 -	else
  37.872 -	{
  37.873 -		gbBorderOn = false;
  37.874 -		theApp.winGbBorderOn = false;
  37.875 -		gbBorderAutomatic	 = false;
  37.876 -	}
  37.877 -	systemGbBorderOn();
  37.878 -#else
  37.879 -	/// SDLFIXME
  37.880 -#endif
  37.881 -}
  37.882 -
  37.883 -uint16 VBAMovieGetCurrentInputOf(int controllerNum, bool normalOnly)
  37.884 -{
  37.885 -	if (controllerNum < 0 || controllerNum >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS)
  37.886 -		return 0;
  37.887 -
  37.888 -	return normalOnly ? (currentButtons[controllerNum] & BUTTON_REGULAR_MASK) : currentButtons[controllerNum];
  37.889 -}
  37.890 -
  37.891 -int VBAMovieCreate(const char *filename, const char *authorInfo, uint8 startFlags, uint8 controllerFlags, uint8 typeFlags)
  37.892 -{
  37.893 -	// make sure at least one controller is enabled
  37.894 -	if ((controllerFlags & MOVIE_CONTROLLERS_ANY_MASK) == 0)
  37.895 -		return MOVIE_WRONG_FORMAT;
  37.896 -
  37.897 -	if (!emulating)
  37.898 -		return MOVIE_UNKNOWN_ERROR;
  37.899 -
  37.900 -	loadingMovie = true;
  37.901 -
  37.902 -	FILE * file;
  37.903 -	STREAM stream;
  37.904 -	int	   fn;
  37.905 -
  37.906 -	char movie_filename [_MAX_PATH];
  37.907 -#ifdef WIN32
  37.908 -	_fullpath(movie_filename, filename, _MAX_PATH);
  37.909 -#else
  37.910 -	// FIXME: convert to fullpath
  37.911 -	strncpy(movie_filename, filename, _MAX_PATH);
  37.912 -	movie_filename[_MAX_PATH - 1] = '\0';
  37.913 -#endif
  37.914 -
  37.915 -	bool alreadyOpen = (Movie.file != NULL && stricmp(movie_filename, Movie.filename) == 0);
  37.916 -
  37.917 -	if (alreadyOpen)
  37.918 -		change_state(MOVIE_STATE_NONE);  // have to stop current movie before trying to re-open it
  37.919 -
  37.920 -	if (movie_filename[0] == '\0')
  37.921 -	{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.922 -
  37.923 -	if (!(file = fopen(movie_filename, "wb")))
  37.924 -	{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.925 -
  37.926 -	if (!alreadyOpen)
  37.927 -		change_state(MOVIE_STATE_NONE);  // stop current movie when we're able to open the other one
  37.928 -
  37.929 -	// clear out the current movie
  37.930 -	VBAMovieInit();
  37.931 -
  37.932 -	// fill in the movie's header
  37.933 -	Movie.header.uid   = (uint32)time(NULL);
  37.934 -	Movie.header.magic = VBM_MAGIC;
  37.935 -	Movie.header.version		 = VBM_VERSION;
  37.936 -	Movie.header.rerecord_count	 = 0;
  37.937 -	Movie.header.length_frames	 = 0;
  37.938 -	Movie.header.startFlags		 = startFlags;
  37.939 -	Movie.header.controllerFlags = controllerFlags;
  37.940 -	Movie.header.typeFlags		 = typeFlags;
  37.941 -	Movie.header.minorVersion	 = VBM_REVISION;
  37.942 -
  37.943 -	// set emulator settings that make the movie more likely to stay synchronized when it's later played back
  37.944 -	SetRecordEmuSettings();
  37.945 -
  37.946 -	// set ROM and BIOS checksums and stuff
  37.947 -	VBAMovieGetRomInfo(Movie, Movie.header.romTitle, Movie.header.romGameCode, Movie.header.romOrBiosChecksum, Movie.header.romCRC);
  37.948 -
  37.949 -	// write the header to file
  37.950 -	write_movie_header(file, Movie);
  37.951 -
  37.952 -	// copy over the metadata / author info
  37.953 -	VBAMovieSetMetadata(authorInfo);
  37.954 -
  37.955 -	// write the metadata / author info to file
  37.956 -	fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file);
  37.957 -
  37.958 -	// write snapshot or SRAM if applicable
  37.959 -	if (Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT
  37.960 -	    || Movie.header.startFlags & MOVIE_START_FROM_SRAM)
  37.961 -	{
  37.962 -		Movie.header.offset_to_savestate = (uint32)ftell(file);
  37.963 -
  37.964 -		// close the file and reopen it as a stream:
  37.965 -
  37.966 -		fn = dup(fileno(file));
  37.967 -		fclose(file);
  37.968 -
  37.969 -		if (!(stream = utilGzReopen(fn, "ab"))) // append mode to start at end, no seek necessary
  37.970 -		{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
  37.971 -
  37.972 -		// write the save data:
  37.973 -		if (Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT)
  37.974 -		{
  37.975 -			// save snapshot
  37.976 -			if (!theEmulator.emuWriteStateToStream(stream))
  37.977 -			{
  37.978 -				utilGzClose(stream);
  37.979 -				{ loadingMovie = false; return MOVIE_UNKNOWN_ERROR; }
  37.980 -			}
  37.981 -		}
  37.982 -		else if (Movie.header.startFlags & MOVIE_START_FROM_SRAM)
  37.983 -		{
  37.984 -			// save SRAM
  37.985 -			if (!theEmulator.emuWriteBatteryToStream(stream))
  37.986 -			{
  37.987 -				utilGzClose(stream);
  37.988 -				{ loadingMovie = false; return MOVIE_UNKNOWN_ERROR; }
  37.989 -			}
  37.990 -
  37.991 -			// 'soft' reset:
  37.992 -			theEmulator.emuReset(false);
  37.993 -		}
  37.994 -
  37.995 -		utilGzClose(stream);
  37.996 -
  37.997 -		// reopen the file and seek back to the end
  37.998 -
  37.999 -		if (!(file = fopen(movie_filename, "rb+")))
 37.1000 -		{ loadingMovie = false; return MOVIE_FILE_NOT_FOUND; }
 37.1001 -
 37.1002 -		fseek(file, 0, SEEK_END);
 37.1003 -	}
 37.1004 -	else // no snapshot or SRAM
 37.1005 -	{
 37.1006 -		HardResetAndSRAMClear();
 37.1007 -	}
 37.1008 -
 37.1009 -	Movie.header.offset_to_controller_data = (uint32)ftell(file);
 37.1010 -
 37.1011 -	strcpy(Movie.filename, movie_filename);
 37.1012 -	Movie.file = file;
 37.1013 -	Movie.bytesPerFrame		  = bytes_per_frame(Movie);
 37.1014 -	Movie.inputBufferPtr	  = Movie.inputBuffer;
 37.1015 -	Movie.currentFrame		  = 0;
 37.1016 -	Movie.readOnly			  = false;
 37.1017 -	Movie.RecordedThisSession = true;
 37.1018 -
 37.1019 -	change_state(MOVIE_STATE_RECORD);
 37.1020 -
 37.1021 -	systemScreenMessage("Recording movie...");
 37.1022 -	{ loadingMovie = false; return MOVIE_SUCCESS; }
 37.1023 -}
 37.1024 -
 37.1025 -void VBAUpdateButtonPressDisplay()
 37.1026 -{
 37.1027 -	uint32 keys = currentButtons[0] & BUTTON_REGULAR_RECORDING_MASK;
 37.1028 -
 37.1029 -	const static char KeyMap[]	 =  { 'A', 'B', 's', 'S', '>', '<', '^', 'v', 'R', 'L', '!', '?', '{', '}', 'v', '^' };
 37.1030 -	const static int  KeyOrder[] = { 5, 6, 4, 7, 0, 1, 9, 8, 3, 2, 12, 15, 13, 14, 11, 10 }; // < ^ > v   A B  L R  S s  { = } _
 37.1031 -	                                                                                         // ? !
 37.1032 -	char buffer[256];
 37.1033 -	sprintf(buffer, "                    ");
 37.1034 -
 37.1035 -#ifndef WIN32
 37.1036 -	// don't bother color-coding autofire and such
 37.1037 -	int i;
 37.1038 -	for (i = 0; i < 15; i++)
 37.1039 -	{
 37.1040 -		int j	 = KeyOrder[i];
 37.1041 -		int mask = (1 << (j));
 37.1042 -		buffer[strlen("    ") + i] = ((keys & mask) != 0) ? KeyMap[j] : ' ';
 37.1043 -	}
 37.1044 -
 37.1045 -	systemScreenMessage(buffer, 2, -1);
 37.1046 -#else
 37.1047 -	const bool eraseAll		= !theApp.inputDisplay;
 37.1048 -	uint32	   autoHeldKeys = eraseAll ? 0 : theApp.autoHold & BUTTON_REGULAR_RECORDING_MASK;
 37.1049 -	uint32	   autoFireKeys = eraseAll ? 0 : (theApp.autoFire | theApp.autoFire2) & BUTTON_REGULAR_RECORDING_MASK;
 37.1050 -	uint32	   pressedKeys	= eraseAll ? 0 : keys;
 37.1051 -
 37.1052 -	char colorList[64];
 37.1053 -	memset(colorList, 1, strlen(buffer));
 37.1054 -
 37.1055 -	if (!eraseAll)
 37.1056 -	{
 37.1057 -		for (int i = 0; i < 15; i++)
 37.1058 -		{
 37.1059 -			const int  j		 = KeyOrder[i];
 37.1060 -			const int  mask		 = (1 << (j));
 37.1061 -			bool	   pressed	 = (pressedKeys  & mask) != 0;
 37.1062 -			const bool autoHeld	 = (autoHeldKeys & mask) != 0;
 37.1063 -			const bool autoFired = (autoFireKeys & mask) != 0;
 37.1064 -			const bool erased	 = (lastKeys & mask) != 0 && (!pressed && !autoHeld && !autoFired);
 37.1065 -			extern int textMethod;
 37.1066 -			if (textMethod != 2 && (autoHeld || (autoFired && !pressed) || erased))
 37.1067 -			{
 37.1068 -				int colorNum = 1;     // default is white
 37.1069 -				if (autoHeld)
 37.1070 -					colorNum += (pressed ? 2 : 1);     // yellow if pressed, red if not
 37.1071 -				else if (autoFired)
 37.1072 -					colorNum += 5;     // blue if autofired and not currently pressed
 37.1073 -				else if (erased)
 37.1074 -					colorNum += 8;     // black on black
 37.1075 -
 37.1076 -				colorList[strlen("    ") + i] = colorNum;
 37.1077 -				pressed = true;
 37.1078 -			}
 37.1079 -			buffer[strlen("    ") + i] = pressed ? KeyMap[j] : ' ';
 37.1080 -		}
 37.1081 -	}
 37.1082 -
 37.1083 -	lastKeys  = currentButtons[0];
 37.1084 -	lastKeys |= theApp.autoHold & BUTTON_REGULAR_RECORDING_MASK;
 37.1085 -	lastKeys |= (theApp.autoFire | theApp.autoFire2) & BUTTON_REGULAR_RECORDING_MASK;
 37.1086 -
 37.1087 -	systemScreenMessage(buffer, 2, -1, colorList);
 37.1088 -#endif
 37.1089 -}
 37.1090 -
 37.1091 -void VBAUpdateFrameCountDisplay()
 37.1092 -{
 37.1093 -	const int MAGICAL_NUMBER = 64;  // FIXME: this won't do any better, but only to remind you of sz issues
 37.1094 -	char	  frameDisplayString[MAGICAL_NUMBER];
 37.1095 -	char	  lagFrameDisplayString[MAGICAL_NUMBER];
 37.1096 -	char      extraCountDisplayString[MAGICAL_NUMBER];
 37.1097 -
 37.1098 -#if (defined(WIN32) && !defined(SDL))
 37.1099 -	if (theApp.frameCounter)
 37.1100 -#else
 37.1101 -	/// SDL FIXME
 37.1102 -#endif
 37.1103 -	{
 37.1104 -		switch (Movie.state)
 37.1105 -		{
 37.1106 -		case MOVIE_STATE_PLAY:
 37.1107 -		case MOVIE_STATE_END:
 37.1108 -		{
 37.1109 -			sprintf(frameDisplayString, "%d / %d", Movie.currentFrame, Movie.header.length_frames);
 37.1110 -			if (!Movie.readOnly)
 37.1111 -				strcat(frameDisplayString, " (edit)");
 37.1112 -			break;
 37.1113 -		}
 37.1114 -		case MOVIE_STATE_RECORD:
 37.1115 -		{
 37.1116 -			sprintf(frameDisplayString, "%d (record)", Movie.currentFrame);
 37.1117 -			break;
 37.1118 -		}
 37.1119 -		default:
 37.1120 -		{
 37.1121 -			sprintf(frameDisplayString, "%d (no movie)", systemCounters.frameCount);
 37.1122 -			break;
 37.1123 -		}
 37.1124 -		}
 37.1125 -
 37.1126 -#if (defined(WIN32) && !defined(SDL))
 37.1127 -		if (theApp.lagCounter)
 37.1128 -#else
 37.1129 -		/// SDL FIXME
 37.1130 -#endif
 37.1131 -		{
 37.1132 -//			sprintf(lagFrameDisplayString, " %c %d", systemCounters.laggedLast ? '*' : '|', systemCounters.lagCount);
 37.1133 -			sprintf(lagFrameDisplayString, " | %d%s", systemCounters.lagCount, systemCounters.laggedLast ? " *" : "");
 37.1134 -			strcat(frameDisplayString, lagFrameDisplayString);
 37.1135 -		}
 37.1136 -
 37.1137 -#if (defined(WIN32) && !defined(SDL))
 37.1138 -		if (theApp.extraCounter)
 37.1139 -#else
 37.1140 -		/// SDL FIXME
 37.1141 -#endif
 37.1142 -		{
 37.1143 -			sprintf(extraCountDisplayString, " | %d", systemCounters.frameCount - systemCounters.extraCount);
 37.1144 -			strcat(frameDisplayString, extraCountDisplayString);
 37.1145 -		}
 37.1146 -	}
 37.1147 -#if (defined(WIN32) && !defined(SDL))
 37.1148 -	else
 37.1149 -	{
 37.1150 -		frameDisplayString[0] = '\0';
 37.1151 -	}
 37.1152 -#else
 37.1153 -	/// SDL FIXME
 37.1154 -#endif
 37.1155 -	systemScreenMessage(frameDisplayString, 1, -1);
 37.1156 -}
 37.1157 -
 37.1158 -// this function should only be called once every frame
 37.1159 -void VBAMovieUpdateState()
 37.1160 -{
 37.1161 -	++Movie.currentFrame;
 37.1162 -
 37.1163 -	if (Movie.state == MOVIE_STATE_PLAY)
 37.1164 -	{
 37.1165 -		Movie.inputBufferPtr += Movie.bytesPerFrame;
 37.1166 -		if (Movie.currentFrame >= Movie.header.length_frames)
 37.1167 -		{
 37.1168 -			// the movie ends anyway; what to do next depends on the settings
 37.1169 -			change_state(MOVIE_STATE_END);
 37.1170 -		}
 37.1171 -	}
 37.1172 -	else if (Movie.state == MOVIE_STATE_RECORD)
 37.1173 -	{
 37.1174 -		// use first fseek?
 37.1175 -		fwrite(Movie.inputBufferPtr, 1, Movie.bytesPerFrame, Movie.file);
 37.1176 -		Movie.header.length_frames = Movie.currentFrame;
 37.1177 -		Movie.inputBufferPtr	 += Movie.bytesPerFrame;
 37.1178 -		Movie.RecordedThisSession = true;
 37.1179 -		flush_movie_header();
 37.1180 -	}
 37.1181 -	else if (Movie.state == MOVIE_STATE_END)
 37.1182 -	{
 37.1183 -		change_state(MOVIE_STATE_END);
 37.1184 -	}
 37.1185 -}
 37.1186 -
 37.1187 -void VBAMovieRead(int i, bool /*sensor*/)
 37.1188 -{
 37.1189 -	if (Movie.state != MOVIE_STATE_PLAY)
 37.1190 -		return;
 37.1191 -
 37.1192 -	if (i < 0 || i >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS)
 37.1193 -		return;      // not a controller we're recognizing
 37.1194 -
 37.1195 -	if (Movie.header.controllerFlags & MOVIE_CONTROLLER(i))
 37.1196 -	{
 37.1197 -		currentButtons[i] = Read16(Movie.inputBufferPtr + CONTROLLER_DATA_SIZE * i);
 37.1198 -	}
 37.1199 -	else
 37.1200 -	{
 37.1201 -		currentButtons[i] = 0;        // pretend the controller is disconnected
 37.1202 -	}
 37.1203 -
 37.1204 -	if ((currentButtons[i] & BUTTON_MASK_NEW_RESET) != 0)
 37.1205 -		resetSignaled = true;
 37.1206 -}
 37.1207 -
 37.1208 -void VBAMovieWrite(int i, bool /*sensor*/)
 37.1209 -{
 37.1210 -	if (Movie.state != MOVIE_STATE_RECORD)
 37.1211 -		return;
 37.1212 -
 37.1213 -	if (i < 0 || i >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS)
 37.1214 -		return;      // not a controller we're recognizing
 37.1215 -
 37.1216 -	reserve_buffer_space((uint32)((Movie.inputBufferPtr - Movie.inputBuffer) + Movie.bytesPerFrame));
 37.1217 -
 37.1218 -	if (Movie.header.controllerFlags & MOVIE_CONTROLLER(i))
 37.1219 -	{
 37.1220 -		// get the current controller data
 37.1221 -		uint16 buttonData = currentButtons[i];
 37.1222 -
 37.1223 -		// mask away the irrelevent bits
 37.1224 -		buttonData &= BUTTON_REGULAR_MASK | BUTTON_MOTION_MASK;
 37.1225 -
 37.1226 -		// soft-reset "button" for 1 frame if the game is reset while recording
 37.1227 -		if (resetSignaled)
 37.1228 -		{
 37.1229 -			buttonData |= BUTTON_MASK_NEW_RESET;
 37.1230 -		}
 37.1231 -
 37.1232 -		// backward compatibility kludge
 37.1233 -		if (resetSignaledLast)
 37.1234 -		{
 37.1235 -			buttonData |= BUTTON_MASK_OLD_RESET;
 37.1236 -		}
 37.1237 -
 37.1238 -		Write16(buttonData, Movie.inputBufferPtr + CONTROLLER_DATA_SIZE * i);
 37.1239 -
 37.1240 -		// and for display
 37.1241 -		currentButtons[i] = buttonData;
 37.1242 -	}
 37.1243 -	else
 37.1244 -	{
 37.1245 -		// pretend the controller is disconnected (otherwise input it gives could cause desync since we're not writing it to the
 37.1246 -		// movie)
 37.1247 -		currentButtons[i] = 0;
 37.1248 -	}
 37.1249 -}
 37.1250 -
 37.1251 -void VBAMovieStop(bool8 suppress_message)
 37.1252 -{
 37.1253 -	if (Movie.state != MOVIE_STATE_NONE)
 37.1254 -	{
 37.1255 -		change_state(MOVIE_STATE_NONE);
 37.1256 -		if (!suppress_message)
 37.1257 -			systemScreenMessage("Movie stop");
 37.1258 -	}
 37.1259 -}
 37.1260 -
 37.1261 -int VBAMovieGetInfo(const char *filename, SMovie *info)
 37.1262 -{
 37.1263 -	assert(info != NULL);
 37.1264 -	if (info == NULL)
 37.1265 -		return -1;
 37.1266 -
 37.1267 -	FILE *	file;
 37.1268 -	int		result;
 37.1269 -	SMovie &local_movie = *info;
 37.1270 -
 37.1271 -	memset(info, 0, sizeof(*info));
 37.1272 -	if (filename[0] == '\0')
 37.1273 -		return MOVIE_FILE_NOT_FOUND;
 37.1274 -	if (!(file = fopen(filename, "rb")))
 37.1275 -		return MOVIE_FILE_NOT_FOUND;
 37.1276 -
 37.1277 -	// read header
 37.1278 -	if ((result = (read_movie_header(file, local_movie))) != MOVIE_SUCCESS)
 37.1279 -	{
 37.1280 -		fclose(file);
 37.1281 -		return result;
 37.1282 -	}
 37.1283 -
 37.1284 -	// read the metadata / author info from file
 37.1285 -	fread(local_movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file);
 37.1286 -
 37.1287 -	strncpy(local_movie.filename, filename, _MAX_PATH);
 37.1288 -	local_movie.filename[_MAX_PATH - 1] = '\0';
 37.1289 -
 37.1290 -	if (Movie.file != NULL && stricmp(local_movie.filename, Movie.filename) == 0) // alreadyOpen
 37.1291 -	{
 37.1292 -		local_movie.bytesPerFrame		 = Movie.bytesPerFrame;
 37.1293 -		local_movie.header.length_frames = Movie.header.length_frames;
 37.1294 -	}
 37.1295 -	else
 37.1296 -	{
 37.1297 -		// recalculate length of movie from the file size
 37.1298 -		local_movie.bytesPerFrame = bytes_per_frame(local_movie);
 37.1299 -		fseek(file, 0, SEEK_END);
 37.1300 -		int fileSize = ftell(file);
 37.1301 -		local_movie.header.length_frames =
 37.1302 -		    (fileSize - local_movie.header.offset_to_controller_data) / local_movie.bytesPerFrame;
 37.1303 -	}
 37.1304 -
 37.1305 -	fclose(file);
 37.1306 -
 37.1307 -	if (access(filename, W_OK))
 37.1308 -		info->readOnly = true;
 37.1309 -
 37.1310 -	return MOVIE_SUCCESS;
 37.1311 -}
 37.1312 -
 37.1313 -bool8 VBAMovieActive()
 37.1314 -{
 37.1315 -	return (Movie.state != MOVIE_STATE_NONE);
 37.1316 -}
 37.1317 -
 37.1318 -bool8 VBAMovieLoading()
 37.1319 -{
 37.1320 -	return loadingMovie;
 37.1321 -}
 37.1322 -
 37.1323 -bool8 VBAMoviePlaying()
 37.1324 -{
 37.1325 -	return (Movie.state == MOVIE_STATE_PLAY);
 37.1326 -}
 37.1327 -
 37.1328 -bool8 VBAMovieRecording()
 37.1329 -{
 37.1330 -	return (Movie.state == MOVIE_STATE_RECORD);
 37.1331 -}
 37.1332 -
 37.1333 -bool8 VBAMovieReadOnly()
 37.1334 -{
 37.1335 -	if (!VBAMovieActive())
 37.1336 -		return false;
 37.1337 -
 37.1338 -	return Movie.readOnly;
 37.1339 -}
 37.1340 -
 37.1341 -void VBAMovieToggleReadOnly()
 37.1342 -{
 37.1343 -	if (!VBAMovieActive())
 37.1344 -		return;
 37.1345 -
 37.1346 -	if (Movie.readOnly != 2)
 37.1347 -	{
 37.1348 -		Movie.readOnly = !Movie.readOnly;
 37.1349 -
 37.1350 -		systemScreenMessage(Movie.readOnly ? "Movie now read-only" : "Movie now editable");
 37.1351 -	}
 37.1352 -	else
 37.1353 -	{
 37.1354 -		systemScreenMessage("Can't toggle read-only movie");
 37.1355 -	}
 37.1356 -}
 37.1357 -
 37.1358 -uint32 VBAMovieGetVersion()
 37.1359 -{
 37.1360 -	if (!VBAMovieActive())
 37.1361 -		return 0;
 37.1362 -
 37.1363 -	return Movie.header.version;
 37.1364 -}
 37.1365 -
 37.1366 -uint32 VBAMovieGetMinorVersion()
 37.1367 -{
 37.1368 -	if (!VBAMovieActive())
 37.1369 -		return 0;
 37.1370 -
 37.1371 -	return Movie.header.minorVersion;
 37.1372 -}
 37.1373 -
 37.1374 -uint32 VBAMovieGetId()
 37.1375 -{
 37.1376 -	if (!VBAMovieActive())
 37.1377 -		return 0;
 37.1378 -
 37.1379 -	return Movie.header.uid;
 37.1380 -}
 37.1381 -
 37.1382 -uint32 VBAMovieGetLength()
 37.1383 -{
 37.1384 -	if (!VBAMovieActive())
 37.1385 -		return 0;
 37.1386 -
 37.1387 -	return Movie.header.length_frames;
 37.1388 -}
 37.1389 -
 37.1390 -uint32 VBAMovieGetFrameCounter()
 37.1391 -{
 37.1392 -	if (!VBAMovieActive())
 37.1393 -		return 0;
 37.1394 -
 37.1395 -	return Movie.currentFrame;
 37.1396 -}
 37.1397 -
 37.1398 -uint32 VBAMovieGetRerecordCount()
 37.1399 -{
 37.1400 -	if (!VBAMovieActive())
 37.1401 -		return 0;
 37.1402 -
 37.1403 -	return Movie.header.rerecord_count;
 37.1404 -}
 37.1405 -
 37.1406 -uint32 VBAMovieSetRerecordCount(uint32 newRerecordCount)
 37.1407 -{
 37.1408 -	uint32 oldRerecordCount = 0;
 37.1409 -	if (!VBAMovieActive())
 37.1410 -		return 0;
 37.1411 -
 37.1412 -	oldRerecordCount = Movie.header.rerecord_count;
 37.1413 -	Movie.header.rerecord_count = newRerecordCount;
 37.1414 -	return oldRerecordCount;
 37.1415 -}
 37.1416 -
 37.1417 -std::string VBAMovieGetAuthorInfo()
 37.1418 -{
 37.1419 -	if (!VBAMovieActive())
 37.1420 -		return "";
 37.1421 -
 37.1422 -	return Movie.authorInfo;
 37.1423 -}
 37.1424 -
 37.1425 -std::string VBAMovieGetFilename()
 37.1426 -{
 37.1427 -	if (!VBAMovieActive())
 37.1428 -		return "";
 37.1429 -
 37.1430 -	return Movie.filename;
 37.1431 -}
 37.1432 -
 37.1433 -void VBAMovieFreeze(uint8 * *buf, uint32 *size)
 37.1434 -{
 37.1435 -	// sanity check
 37.1436 -	if (!VBAMovieActive())
 37.1437 -	{
 37.1438 -		return;
 37.1439 -	}
 37.1440 -
 37.1441 -	*buf  = NULL;
 37.1442 -	*size = 0;
 37.1443 -
 37.1444 -	// compute size needed for the buffer
 37.1445 -	// room for header.uid, currentFrame, and header.length_frames
 37.1446 -	uint32 size_needed = sizeof(Movie.header.uid) + sizeof(Movie.currentFrame) + sizeof(Movie.header.length_frames);
 37.1447 -	size_needed += (uint32)(Movie.bytesPerFrame * Movie.header.length_frames);
 37.1448 -	*buf		 = new uint8[size_needed];
 37.1449 -	*size		 = size_needed;
 37.1450 -
 37.1451 -	uint8 *ptr = *buf;
 37.1452 -	if (!ptr)
 37.1453 -	{
 37.1454 -		return;
 37.1455 -	}
 37.1456 -
 37.1457 -	Push32(Movie.header.uid, ptr);
 37.1458 -	Push32(Movie.currentFrame, ptr);
 37.1459 -	Push32(Movie.header.length_frames - 1, ptr);   // HACK: shorten the length by 1 for backward compatibility
 37.1460 -
 37.1461 -	memcpy(ptr, Movie.inputBuffer, Movie.bytesPerFrame * Movie.header.length_frames);
 37.1462 -}
 37.1463 -
 37.1464 -int VBAMovieUnfreeze(const uint8 *buf, uint32 size)
 37.1465 -{
 37.1466 -	// sanity check
 37.1467 -	if (!VBAMovieActive())
 37.1468 -	{
 37.1469 -		return MOVIE_NOT_FROM_A_MOVIE;
 37.1470 -	}
 37.1471 -
 37.1472 -	const uint8 *ptr = buf;
 37.1473 -	if (size < sizeof(Movie.header.uid) + sizeof(Movie.currentFrame) + sizeof(Movie.header.length_frames))
 37.1474 -	{
 37.1475 -		return MOVIE_WRONG_FORMAT;
 37.1476 -	}
 37.1477 -
 37.1478 -	uint32 movie_id		 = Pop32(ptr);
 37.1479 -	uint32 current_frame = Pop32(ptr);
 37.1480 -	uint32 end_frame	 = Pop32(ptr) + 1;     // HACK: restore the length for backward compatibility
 37.1481 -	uint32 space_needed	 = Movie.bytesPerFrame * end_frame;
 37.1482 -
 37.1483 -	if (movie_id != Movie.header.uid)
 37.1484 -		return MOVIE_NOT_FROM_THIS_MOVIE;
 37.1485 -
 37.1486 -	if (space_needed > size)
 37.1487 -		return MOVIE_WRONG_FORMAT;
 37.1488 -
 37.1489 -	if (Movie.readOnly)
 37.1490 -	{
 37.1491 -		// here, we are going to keep the input data from the movie file
 37.1492 -		// and simply rewind to the currentFrame pointer
 37.1493 -		// this will cause a desync if the savestate is not in sync // <-- NOT ANYMORE
 37.1494 -		// with the on-disk recording data, but it's easily solved
 37.1495 -		// by loading another savestate or playing the movie from the beginning
 37.1496 -
 37.1497 -		// don't allow loading a state inconsistent with the current movie
 37.1498 -		uint32 length_history = min(current_frame, Movie.header.length_frames);
 37.1499 -		if (end_frame < length_history)
 37.1500 -			return MOVIE_SNAPSHOT_INCONSISTENT;
 37.1501 -
 37.1502 -		uint32 space_shared = Movie.bytesPerFrame * length_history;
 37.1503 -		if (memcmp(Movie.inputBuffer, ptr, space_shared))
 37.1504 -			return MOVIE_SNAPSHOT_INCONSISTENT;
 37.1505 -
 37.1506 -		Movie.currentFrame	 = current_frame;
 37.1507 -		Movie.inputBufferPtr = Movie.inputBuffer + Movie.bytesPerFrame * min(current_frame, Movie.header.length_frames);
 37.1508 -	}
 37.1509 -	else
 37.1510 -	{
 37.1511 -		// here, we are going to take the input data from the savestate
 37.1512 -		// and make it the input data for the current movie, then continue
 37.1513 -		// writing new input data at the currentFrame pointer
 37.1514 -		Movie.currentFrame		   = current_frame;
 37.1515 -		Movie.header.length_frames = end_frame;
 37.1516 -		if (!VBALuaRerecordCountSkip())
 37.1517 -			++Movie.header.rerecord_count;
 37.1518 -
 37.1519 -		Movie.RecordedThisSession = true;
 37.1520 -
 37.1521 -		// do this before calling reserve_buffer_space()
 37.1522 -		Movie.inputBufferPtr = Movie.inputBuffer + Movie.bytesPerFrame * min(current_frame, Movie.header.length_frames);
 37.1523 -		reserve_buffer_space(space_needed);
 37.1524 -		memcpy(Movie.inputBuffer, ptr, space_needed);
 37.1525 -
 37.1526 -		// for consistency, no auto movie conversion here since we don't auto convert the corresponding savestate
 37.1527 -		flush_movie_header();
 37.1528 -		flush_movie_frames();
 37.1529 -	}
 37.1530 -
 37.1531 -	change_state(MOVIE_STATE_PLAY);	// check for movie end
 37.1532 -
 37.1533 -	// necessary!
 37.1534 -	resetSignaled	  = false;
 37.1535 -	resetSignaledLast = false;
 37.1536 -
 37.1537 -	// necessary to check if there's a reset signal at the previous frame
 37.1538 -	if (current_frame > 0)
 37.1539 -	{
 37.1540 -		const u8 NEW_RESET = u8(BUTTON_MASK_NEW_RESET >> 8);
 37.1541 -		for (int i = 0; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS; ++i)
 37.1542 -		{
 37.1543 -			if ((Movie.header.controllerFlags & MOVIE_CONTROLLER(i)) && (*(Movie.inputBufferPtr+1- Movie.bytesPerFrame) & NEW_RESET))
 37.1544 -			{
 37.1545 -				resetSignaledLast = true;
 37.1546 -				break;
 37.1547 -			}
 37.1548 -		}
 37.1549 -	}
 37.1550 -
 37.1551 -	return MOVIE_SUCCESS;
 37.1552 -}
 37.1553 -
 37.1554 -bool VBAMovieEnded()
 37.1555 -{
 37.1556 -	return (Movie.state == MOVIE_STATE_END);
 37.1557 -//	return (Movie.state != MOVIE_STATE_NONE && Movie.currentFrame >= Movie.header.length_frames);
 37.1558 -}
 37.1559 -
 37.1560 -bool VBAMovieAllowsRerecording()
 37.1561 -{
 37.1562 -	bool allows = (Movie.state != MOVIE_STATE_NONE) && (Movie.currentFrame <= Movie.header.length_frames);
 37.1563 -	return /*!VBAMovieReadOnly() &&*/ allows;
 37.1564 -}
 37.1565 -
 37.1566 -bool VBAMovieSwitchToPlaying()
 37.1567 -{
 37.1568 -	if (!VBAMovieActive())
 37.1569 -		return false;
 37.1570 -
 37.1571 -	if (!Movie.readOnly)
 37.1572 -	{
 37.1573 -		VBAMovieToggleReadOnly();
 37.1574 -	}
 37.1575 -
 37.1576 -	change_state(MOVIE_STATE_PLAY);
 37.1577 -	if (Movie.state == MOVIE_STATE_PLAY)
 37.1578 -		systemScreenMessage("Movie replay (continue)");
 37.1579 -	else
 37.1580 -		systemScreenMessage("Movie end");
 37.1581 -
 37.1582 -	return true;
 37.1583 -}
 37.1584 -
 37.1585 -bool VBAMovieSwitchToRecording()
 37.1586 -{
 37.1587 -	if (!VBAMovieAllowsRerecording())
 37.1588 -		return false;
 37.1589 -
 37.1590 -	if (Movie.readOnly)
 37.1591 -	{
 37.1592 -		VBAMovieToggleReadOnly();
 37.1593 -	}
 37.1594 -
 37.1595 -	if (!VBALuaRerecordCountSkip())
 37.1596 -		++Movie.header.rerecord_count;
 37.1597 -
 37.1598 -	change_state(MOVIE_STATE_RECORD);
 37.1599 -	systemScreenMessage("Movie re-record");
 37.1600 -
 37.1601 -	//truncate_movie(Movie.currentFrame);
 37.1602 -
 37.1603 -	return true;
 37.1604 -}
 37.1605 -
 37.1606 -uint32 VBAMovieGetState()
 37.1607 -{
 37.1608 -	// ?
 37.1609 -	if (!VBAMovieActive())
 37.1610 -		return MOVIE_STATE_NONE;
 37.1611 -
 37.1612 -	return Movie.state;
 37.1613 -}
 37.1614 -
 37.1615 -void VBAMovieSignalReset()
 37.1616 -{
 37.1617 -	if (VBAMovieActive())
 37.1618 -		resetSignaled = true;
 37.1619 -}
 37.1620 -
 37.1621 -void VBAMovieResetIfRequested()
 37.1622 -{
 37.1623 -	if (resetSignaled)
 37.1624 -	{
 37.1625 -		theEmulator.emuReset(false);
 37.1626 -		resetSignaled	  = false;
 37.1627 -		resetSignaledLast = true;
 37.1628 -	}
 37.1629 -	else
 37.1630 -	{
 37.1631 -		resetSignaledLast = false;
 37.1632 -	}
 37.1633 -}
 37.1634 -
 37.1635 -void VBAMovieSetMetadata(const char *info)
 37.1636 -{
 37.1637 -	if (!memcmp(Movie.authorInfo, info, MOVIE_METADATA_SIZE))
 37.1638 -		return;
 37.1639 -
 37.1640 -	memcpy(Movie.authorInfo, info, MOVIE_METADATA_SIZE); // strncpy would omit post-0 bytes
 37.1641 -	Movie.authorInfo[MOVIE_METADATA_SIZE - 1] = '\0';
 37.1642 -
 37.1643 -	if (Movie.file)
 37.1644 -	{
 37.1645 -		// (over-)write the header
 37.1646 -		fseek(Movie.file, 0, SEEK_SET);
 37.1647 -		write_movie_header(Movie.file, Movie);
 37.1648 -
 37.1649 -		// write the metadata / author info to file
 37.1650 -		fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, Movie.file);
 37.1651 -
 37.1652 -		fflush(Movie.file);
 37.1653 -	}
 37.1654 -}
 37.1655 -
 37.1656 -void VBAMovieRestart()
 37.1657 -{
 37.1658 -	if (VBAMovieActive())
 37.1659 -	{
 37.1660 -		systemSoundClearBuffer();
 37.1661 -
 37.1662 -		bool8 modified = Movie.RecordedThisSession;
 37.1663 -
 37.1664 -		VBAMovieStop(true);
 37.1665 -
 37.1666 -		char movieName [_MAX_PATH];
 37.1667 -		strncpy(movieName, Movie.filename, _MAX_PATH);
 37.1668 -		movieName[_MAX_PATH - 1] = '\0';
 37.1669 -		VBAMovieOpen(movieName, Movie.readOnly); // can't just pass in Movie.filename, since VBAMovieOpen clears out Movie's
 37.1670 -		                                         // variables
 37.1671 -
 37.1672 -		Movie.RecordedThisSession = modified;
 37.1673 -
 37.1674 -		systemScreenMessage("Movie replay (restart)");
 37.1675 -	}
 37.1676 -}
 37.1677 -
 37.1678 -int VBAMovieGetPauseAt()
 37.1679 -{
 37.1680 -	return Movie.pauseFrame;
 37.1681 -}
 37.1682 -
 37.1683 -void VBAMovieSetPauseAt(int at)
 37.1684 -{
 37.1685 -	Movie.pauseFrame = at;
 37.1686 -}
 37.1687 -
 37.1688 -///////////////////////
 37.1689 -// movie tools
 37.1690 -
 37.1691 -// FIXME: is it safe to convert/flush a movie while recording it (considering fseek() problem)?
 37.1692 -int VBAMovieConvertCurrent()
 37.1693 -{
 37.1694 -	if (!VBAMovieActive())
 37.1695 -	{
 37.1696 -		return MOVIE_NOTHING;
 37.1697 -	}
 37.1698 -
 37.1699 -	if (Movie.header.minorVersion > VBM_REVISION)
 37.1700 -	{
 37.1701 -		return MOVIE_WRONG_VERSION;
 37.1702 -	}
 37.1703 -
 37.1704 -	if (Movie.header.minorVersion == VBM_REVISION)
 37.1705 -	{
 37.1706 -		return MOVIE_NOTHING;
 37.1707 -	}
 37.1708 -
 37.1709 -	Movie.header.minorVersion = VBM_REVISION;
 37.1710 -
 37.1711 -	if (Movie.header.length_frames == 0) // this could happen
 37.1712 -	{
 37.1713 -		truncate_movie(0);
 37.1714 -		return MOVIE_SUCCESS;
 37.1715 -	}
 37.1716 -
 37.1717 -	// fix movies recorded from snapshots
 37.1718 -	if (Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT)
 37.1719 -	{
 37.1720 -		uint8 *firstFramePtr = Movie.inputBuffer;
 37.1721 -		for (int i = 0; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS; ++i)
 37.1722 -		{
 37.1723 -			if (Movie.header.controllerFlags & MOVIE_CONTROLLER(i))
 37.1724 -			{
 37.1725 -				Push16(initialInputs[i], firstFramePtr);
 37.1726 -				// note: this is correct since Push16 advances the dest pointer by sizeof u16
 37.1727 -			}
 37.1728 -		}
 37.1729 -	}
 37.1730 -
 37.1731 -	// convert old resets to new ones
 37.1732 -	const u8 OLD_RESET = u8(BUTTON_MASK_OLD_RESET >> 8);
 37.1733 -	const u8 NEW_RESET = u8(BUTTON_MASK_NEW_RESET >> 8);
 37.1734 -	for (int i = 0; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS; ++i)
 37.1735 -	{
 37.1736 -		if (Movie.header.controllerFlags & MOVIE_CONTROLLER(i))
 37.1737 -		{
 37.1738 -			uint8 *startPtr = Movie.inputBuffer + sizeof(u16) * i + 1;
 37.1739 -			uint8 *endPtr	= Movie.inputBuffer + Movie.bytesPerFrame * (Movie.header.length_frames - 1);
 37.1740 -			for (; startPtr < endPtr; startPtr += Movie.bytesPerFrame)
 37.1741 -			{
 37.1742 -				if (startPtr[Movie.bytesPerFrame] & OLD_RESET)
 37.1743 -				{
 37.1744 -					startPtr[0] |= NEW_RESET;
 37.1745 -				}
 37.1746 -			}
 37.1747 -		}
 37.1748 -	}
 37.1749 -
 37.1750 -	flush_movie_header();
 37.1751 -	flush_movie_frames();
 37.1752 -	return MOVIE_SUCCESS;
 37.1753 -}
 37.1754 -
 37.1755 -bool VBAMovieTuncateAtCurrentFrame()
 37.1756 -{
 37.1757 -	if (!VBAMovieActive())
 37.1758 -		return false;
 37.1759 -
 37.1760 -	truncate_movie(Movie.currentFrame);
 37.1761 -	change_state(MOVIE_STATE_END);
 37.1762 -	systemScreenMessage("Movie truncated");
 37.1763 -
 37.1764 -	return true;
 37.1765 -}
 37.1766 -
 37.1767 -bool VBAMovieFixHeader()
 37.1768 -{
 37.1769 -	if (!VBAMovieActive())
 37.1770 -		return false;
 37.1771 -
 37.1772 -	flush_movie_header();
 37.1773 -	systemScreenMessage("Movie header fixed");
 37.1774 -	return true;
 37.1775 -}
    38.1 --- a/src/common/movie.h	Sat Mar 03 10:54:39 2012 -0600
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,190 +0,0 @@
    38.4 -#ifndef VBA_MOVIE_H
    38.5 -#define VBA_MOVIE_H
    38.6 -
    38.7 -#if _MSC_VER > 1000
    38.8 -#pragma once
    38.9 -#endif // _MSC_VER > 1000
   38.10 -
   38.11 -#include <ctime>
   38.12 -#include <string>
   38.13 -
   38.14 -#include "../Port.h"
   38.15 -
   38.16 -#define ZLIB
   38.17 -///#ifdef ZLIB
   38.18 -#ifndef WIN32
   38.19 -#include "zlib.h"
   38.20 -#endif
   38.21 -
   38.22 -#ifndef MOVIE_SUCCESS
   38.23 -#  define MOVIE_SUCCESS 1
   38.24 -#  define MOVIE_NOTHING 0
   38.25 -#  define MOVIE_WRONG_FORMAT (-1)
   38.26 -#  define MOVIE_WRONG_VERSION (-2)
   38.27 -#  define MOVIE_FILE_NOT_FOUND (-3)
   38.28 -#  define MOVIE_NOT_FROM_THIS_MOVIE (-4)
   38.29 -#  define MOVIE_NOT_FROM_A_MOVIE (-5)
   38.30 -#  define MOVIE_SNAPSHOT_INCONSISTENT (-6)
   38.31 -#  define MOVIE_UNKNOWN_ERROR (-7)
   38.32 -#endif
   38.33 -
   38.34 -#define VBM_MAGIC (0x1a4D4256) // VBM0x1a
   38.35 -#define VBM_VERSION (1)
   38.36 -#define VBM_HEADER_SIZE (64)
   38.37 -#define CONTROLLER_DATA_SIZE (2)
   38.38 -#define BUFFER_GROWTH_SIZE (4096)
   38.39 -#define MOVIE_METADATA_SIZE (192)
   38.40 -#define MOVIE_METADATA_AUTHOR_SIZE (64)
   38.41 -
   38.42 -// revision 1 uses (?) insted of (!) as reset
   38.43 -#define VBM_REVISION   (1)
   38.44 -
   38.45 -#define MOVIE_START_FROM_SNAPSHOT   (1<<0)
   38.46 -#define MOVIE_START_FROM_SRAM       (1<<1)
   38.47 -
   38.48 -#define MOVIE_CONTROLLER(i)         (1<<(i))
   38.49 -#define MOVIE_CONTROLLERS_ANY_MASK  (MOVIE_CONTROLLER(0)|MOVIE_CONTROLLER(1)|MOVIE_CONTROLLER(2)|MOVIE_CONTROLLER(3))
   38.50 -#define MOVIE_NUM_OF_POSSIBLE_CONTROLLERS   (4)
   38.51 -
   38.52 -#define MOVIE_TYPE_GBA              (1<<0)
   38.53 -#define MOVIE_TYPE_GBC              (1<<1)
   38.54 -#define MOVIE_TYPE_SGB              (1<<2)
   38.55 -
   38.56 -#define MOVIE_SETTING_USEBIOSFILE   (1<<0)
   38.57 -#define MOVIE_SETTING_SKIPBIOSFILE  (1<<1)
   38.58 -#define MOVIE_SETTING_RTCENABLE     (1<<2)
   38.59 -#define MOVIE_SETTING_GBINPUTHACK   (1<<3)
   38.60 -#define MOVIE_SETTING_LAGHACK       (1<<4)
   38.61 -#define MOVIE_SETTING_GBCFF55FIX    (1<<5)
   38.62 -#define MOVIE_SETTING_GBECHORAMFIX  (1<<6)
   38.63 -
   38.64 -#define STREAM gzFile
   38.65 -/*#define READ_STREAM(p,l,s) gzread (s,p,l)
   38.66 - #define WRITE_STREAM(p,l,s) gzwrite (s,p,l)
   38.67 - #define OPEN_STREAM(f,m) gzopen (f,m)
   38.68 - #define REOPEN_STREAM(f,m) gzdopen (f,m)
   38.69 - #define FIND_STREAM(f)	gztell(f)
   38.70 - #define REVERT_STREAM(f,o,s)  gzseek(f,o,s)
   38.71 - #define CLOSE_STREAM(s) gzclose (s)
   38.72 - #else
   38.73 - #define STREAM FILE *
   38.74 - #define READ_STREAM(p,l,s) fread (p,1,l,s)
   38.75 - #define WRITE_STREAM(p,l,s) fwrite (p,1,l,s)
   38.76 - #define OPEN_STREAM(f,m) fopen (f,m)
   38.77 - #define REOPEN_STREAM(f,m) fdopen (f,m)
   38.78 - #define FIND_STREAM(f)	ftell(f)
   38.79 - #define REVERT_STREAM(f,o,s)	 fseek(f,o,s)
   38.80 - #define CLOSE_STREAM(s) fclose (s)
   38.81 - #endif*/
   38.82 -
   38.83 -enum MovieState
   38.84 -{
   38.85 -	MOVIE_STATE_NONE = 0,
   38.86 -	MOVIE_STATE_PLAY,
   38.87 -	MOVIE_STATE_RECORD,
   38.88 -	MOVIE_STATE_END
   38.89 -};
   38.90 -
   38.91 -struct SMovieFileHeader
   38.92 -{
   38.93 -	uint32 magic;       // VBM0x1a
   38.94 -	uint32 version;     // 1
   38.95 -	int32  uid;         // used to match savestates to a particular movie
   38.96 -	uint32 length_frames;
   38.97 -	uint32 rerecord_count;
   38.98 -	uint8  startFlags;
   38.99 -	uint8  controllerFlags;
  38.100 -	uint8  typeFlags;
  38.101 -	uint8  optionFlags;
  38.102 -	uint32 saveType;        // emulator setting value
  38.103 -	uint32 flashSize;       // emulator setting value
  38.104 -	uint32 gbEmulatorType;  // emulator setting value
  38.105 -	char   romTitle [12];
  38.106 -	uint8  minorVersion;	// minor version/revision of the current movie version
  38.107 -	uint8  romCRC;						// the CRC of the ROM used while recording
  38.108 -	uint16 romOrBiosChecksum;			// the Checksum of the ROM used while recording, or a CRC of the BIOS if GBA
  38.109 -	uint32 romGameCode;					// the Game Code of the ROM used while recording, or "\0\0\0\0" if not GBA
  38.110 -	uint32 offset_to_savestate;         // offset to the savestate or SRAM inside file, set to 0 if unused
  38.111 -	uint32 offset_to_controller_data;   // offset to the controller data inside file
  38.112 -};
  38.113 -
  38.114 -struct SMovie
  38.115 -{
  38.116 -	enum   MovieState state;
  38.117 -	char   filename[/*_MAX_PATH*/ 260]; // FIXME: should use a string instead
  38.118 -	FILE*  file;
  38.119 -	uint8  readOnly;
  38.120 -	int32  pauseFrame;	// FIXME: byte size
  38.121 -
  38.122 -	SMovieFileHeader header;
  38.123 -	char  authorInfo[MOVIE_METADATA_SIZE];
  38.124 -
  38.125 -	uint32 currentFrame;    // should == length_frame when recording, and be < length_frames when playing
  38.126 -	uint32 bytesPerFrame;
  38.127 -	uint8* inputBuffer;
  38.128 -	uint32 inputBufferSize;
  38.129 -	uint8* inputBufferPtr;
  38.130 -
  38.131 -	// bool8 doesn't make much sense if it is meant to solve any portability problem,
  38.132 -	//   because there's no guarantee that true == 1 and false == 0 (or TRUE == 1 and FALSE == 0) on all platforms.
  38.133 -	//   while using user-defined boolean types might impact on performance.
  38.134 -	//   the more reliable (and faster!) way to maintain cross-platform I/O compatibility is
  38.135 -	//   to manually map from/to built-in boolean types to/from fixed-sized types value by value ONLY when doing I/O
  38.136 -	//   e.g. bool(true) <-> u8(1) and <-> bool(false) <-> u8(0), BOOL(TRUE) <-> s32(-1) and BOOL(FALSE) <-> s32(0) etc.
  38.137 -	bool8 RecordedThisSession;
  38.138 -};
  38.139 -
  38.140 -// methods used by the user-interface code
  38.141 -int VBAMovieOpen(const char *filename, bool8 read_only);
  38.142 -int VBAMovieCreate(const char *filename, const char *authorInfo, uint8 startFlags, uint8 controllerFlags, uint8 typeFlags);
  38.143 -int VBAMovieGetInfo(const char *filename, SMovie*info);
  38.144 -void VBAMovieGetRomInfo(const SMovie &movieInfo, char romTitle[12], uint32 &romGameCode, uint16 &checksum, uint8 &crc);
  38.145 -void VBAMovieStop(bool8 suppress_message);
  38.146 -const char *VBAChooseMovieFilename(bool8 read_only);
  38.147 -
  38.148 -// methods used by the emulation
  38.149 -void VBAMovieInit();
  38.150 -void VBAMovieUpdateState();
  38.151 -void VBAMovieRead(int controllerNum = 0, bool sensor = false);
  38.152 -void VBAMovieWrite(int controllerNum = 0, bool sensor = false);
  38.153 -void VBAUpdateButtonPressDisplay();
  38.154 -void VBAUpdateFrameCountDisplay();
  38.155 -//bool8 VBAMovieRewind (uint32 at_frame);
  38.156 -void VBAMovieFreeze(uint8 **buf, uint32 *size);
  38.157 -int VBAMovieUnfreeze(const uint8 *buf, uint32 size);
  38.158 -void VBAMovieRestart();
  38.159 -
  38.160 -// accessor functions
  38.161 -bool8 VBAMovieActive();
  38.162 -bool8 VBAMovieLoading();
  38.163 -bool8 VBAMoviePlaying();
  38.164 -bool8 VBAMovieRecording();
  38.165 -// the following accessors return 0/false if !VBAMovieActive()
  38.166 -uint8 VBAMovieReadOnly();
  38.167 -uint32 VBAMovieGetVersion();
  38.168 -uint32 VBAMovieGetMinorVersion();
  38.169 -uint32 VBAMovieGetId();
  38.170 -uint32 VBAMovieGetLength();
  38.171 -uint32 VBAMovieGetFrameCounter();
  38.172 -uint32 VBAMovieGetState();
  38.173 -uint32 VBAMovieGetRerecordCount ();
  38.174 -uint32 VBAMovieSetRerecordCount (uint32 newRerecordCount);
  38.175 -std::string VBAMovieGetAuthorInfo();
  38.176 -std::string VBAMovieGetFilename();
  38.177 -
  38.178 -uint16 VBAMovieGetCurrentInputOf(int controllerNum, bool normalOnly = true);
  38.179 -void VBAMovieSignalReset();
  38.180 -void VBAMovieResetIfRequested();
  38.181 -void VBAMovieSetMetadata(const char *info);
  38.182 -void VBAMovieToggleReadOnly();
  38.183 -bool VBAMovieEnded();
  38.184 -bool VBAMovieAllowsRerecording();
  38.185 -bool VBAMovieSwitchToPlaying();
  38.186 -bool VBAMovieSwitchToRecording();
  38.187 -int  VBAMovieGetPauseAt();
  38.188 -void VBAMovieSetPauseAt(int at);
  38.189 -int  VBAMovieConvertCurrent();
  38.190 -bool VBAMovieTuncateAtCurrentFrame();
  38.191 -bool VBAMovieFixHeader();
  38.192 -
  38.193 -#endif // VBA_MOVIE_H
    39.1 --- a/src/common/nesvideos-piece.cpp	Sat Mar 03 10:54:39 2012 -0600
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,525 +0,0 @@
    39.4 -#include <cmath>
    39.5 -#include <cstdio>
    39.6 -#include <string>
    39.7 -#include <vector>
    39.8 -
    39.9 -/* Note: This module assumes everyone uses RGB15 as display depth */
   39.10 -
   39.11 -static std::string VIDEO_CMD =
   39.12 -    "mencoder - -o test0.avi"
   39.13 -    " -noskip -mc 0"
   39.14 -    " -ovc lavc"
   39.15 -    " -oac mp3lame"
   39.16 -    " -lameopts preset=256:aq=2:mode=3"
   39.17 -    " -lavcopts vcodec=ffv1:context=0:format=BGR32:coder=0:vstrict=-1"
   39.18 -    " >& mencoder.log";
   39.19 -
   39.20 -static void FlushWrite(FILE* fp, const unsigned char*buf, unsigned length);
   39.21 -
   39.22 -#define BGR24 (0x42475218)  // BGR24 fourcc
   39.23 -#define BGR16 (0x42475210)  // BGR16 fourcc
   39.24 -#define BGR15 (0x4247520F)  // BGR15 fourcc
   39.25 -
   39.26 -static FILE* (*openFunc)  (const char*, const char*) = NULL;
   39.27 -static int (*closeFunc) (FILE*) = NULL;
   39.28 -
   39.29 -#if (defined(WIN32) || defined(win32)) // capital is standard, but check for either
   39.30 - #include <cstdlib>
   39.31 - #define popen _popen;
   39.32 - #define pclose _pclose;
   39.33 -#endif
   39.34 -
   39.35 -#define u32(n) (n)&255,((n)>>8)&255,((n)>>16)&255,((n)>>24)&255
   39.36 -#define u16(n) (n)&255,((n)>>8)&255
   39.37 -#define s4(s) s[0],s[1],s[2],s[3]
   39.38 -
   39.39 -static const unsigned FPS_SCALE = (0x1000000);
   39.40 -
   39.41 -// general-purpose A/V sync debugging, ignored unless explicitly enabled with NESVideoEnableDebugging
   39.42 -static void (*debugVideoMessageFunc)(const char *msg) = NULL;
   39.43 -static void (*debugAudioMessageFunc)(const char *msg) = NULL;
   39.44 -// logo adds 1 "frame" to audio, so offset that (A/V frames shouldn't necessarily match up depending on the rates, but should at least make them start out matching in case they do)
   39.45 -static unsigned audioFramesWritten=0, videoFramesWritten=1;
   39.46 -static double audioSecondsWritten=0, videoSecondsWritten=0;
   39.47 -
   39.48 -
   39.49 -static class AVI
   39.50 -{
   39.51 -    FILE* avifp;
   39.52 -    
   39.53 -    bool KnowVideo;
   39.54 -    unsigned width;
   39.55 -    unsigned height;
   39.56 -    unsigned fps_scaled;
   39.57 -    std::vector<unsigned char> VideoBuffer;
   39.58 -    
   39.59 -    bool KnowAudio;
   39.60 -    unsigned rate;
   39.61 -    unsigned chans;
   39.62 -    unsigned bits;
   39.63 -    std::vector<unsigned char> AudioBuffer;
   39.64 -    
   39.65 -public:
   39.66 -    AVI() :
   39.67 -        avifp(NULL),
   39.68 -        KnowVideo(false),
   39.69 -        KnowAudio(false)
   39.70 -    {
   39.71 -    }
   39.72 -    ~AVI()
   39.73 -    {
   39.74 -        if(avifp) closeFunc(avifp);
   39.75 -    }
   39.76 -    
   39.77 -    void Audio(unsigned r,unsigned b,unsigned c,
   39.78 -               const unsigned char*d, unsigned nsamples)
   39.79 -    {
   39.80 -        if(!KnowAudio)
   39.81 -        {
   39.82 -            rate = r;
   39.83 -            chans = c;
   39.84 -            bits = b;
   39.85 -            KnowAudio = true;
   39.86 -            CheckFlushing();
   39.87 -        }
   39.88 -        unsigned bytes = nsamples*chans*(bits/8);
   39.89 -
   39.90 -		if(debugAudioMessageFunc)
   39.91 -		{
   39.92 -			audioFramesWritten++;
   39.93 -			audioSecondsWritten += (double)nsamples / (double)rate; // += bytes times seconds per byte
   39.94 -			char temp [64];
   39.95 -			sprintf(temp, "A: %.2lf s, %d f", audioSecondsWritten, audioFramesWritten);
   39.96 -			debugAudioMessageFunc(temp);
   39.97 -		}
   39.98 -
   39.99 -        if(KnowVideo)
  39.100 -            SendAudioFrame(d, bytes);
  39.101 -        else
  39.102 -        {
  39.103 -            AudioBuffer.insert(AudioBuffer.end(), d, d+bytes);
  39.104 -            fprintf(stderr, "Buffering %u bytes of audio\n", bytes);
  39.105 -        }
  39.106 -    }
  39.107 -    void Video(unsigned w,unsigned h,unsigned f, const unsigned char*d)
  39.108 -    {
  39.109 -        if(!KnowVideo)
  39.110 -        {
  39.111 -            width=w;
  39.112 -            height=h;
  39.113 -            fps_scaled=f;
  39.114 -            KnowVideo = true;
  39.115 -            CheckFlushing();
  39.116 -        }
  39.117 -        
  39.118 -        unsigned bytes = width*height*2;
  39.119 -        
  39.120 -        //std::vector<unsigned char> tmp(bytes, 'k');
  39.121 -        //d = &tmp[0];
  39.122 -
  39.123 -		if(debugVideoMessageFunc)
  39.124 -		{
  39.125 -			videoFramesWritten++;
  39.126 -			videoSecondsWritten += (double)FPS_SCALE / (double)fps_scaled; // += seconds per frame
  39.127 -			char temp [64];
  39.128 -			sprintf(temp, "V: %.2lf s, %d f", videoSecondsWritten, videoFramesWritten);
  39.129 -			debugVideoMessageFunc(temp);
  39.130 -		}
  39.131 -
  39.132 -        if(KnowAudio)
  39.133 -            SendVideoFrame(d, bytes);
  39.134 -        else
  39.135 -        {
  39.136 -            VideoBuffer.insert(VideoBuffer.end(), d, d+bytes);
  39.137 -            fprintf(stderr, "Buffering %u bytes of video\n", bytes);
  39.138 -        }
  39.139 -    }
  39.140 -
  39.141 -private:
  39.142 -    void CheckFlushing()
  39.143 -    {
  39.144 -        //AudioBuffer.clear();
  39.145 -        //VideoBuffer.clear();
  39.146 -        
  39.147 -        if(KnowAudio && KnowVideo)
  39.148 -        {
  39.149 -            unsigned last_offs;
  39.150 -            
  39.151 -            // Flush Audio
  39.152 -            
  39.153 -            last_offs = 0;
  39.154 -            while(last_offs < AudioBuffer.size())
  39.155 -            {
  39.156 -                unsigned bytes = rate / (fps_scaled / FPS_SCALE);
  39.157 -                bytes *= chans*(bits/8);
  39.158 -                
  39.159 -                unsigned remain = AudioBuffer.size() - last_offs;
  39.160 -                if(bytes > remain) bytes = remain;
  39.161 -                if(!bytes) break;
  39.162 -                
  39.163 -                unsigned begin = last_offs;
  39.164 -                last_offs += bytes;
  39.165 -                SendAudioFrame(&AudioBuffer[begin], bytes);
  39.166 -            }
  39.167 -            AudioBuffer.erase(AudioBuffer.begin(), AudioBuffer.begin()+last_offs);
  39.168 -            
  39.169 -            // Flush Video
  39.170 -            
  39.171 -            last_offs = 0;
  39.172 -            while(last_offs < VideoBuffer.size())
  39.173 -            {
  39.174 -                unsigned bytes  = width*height*2;
  39.175 -                unsigned remain = VideoBuffer.size() - last_offs;
  39.176 -                if(bytes > remain) bytes = remain;
  39.177 -                if(!bytes)break;
  39.178 -                
  39.179 -                unsigned begin = last_offs;
  39.180 -                last_offs += bytes;
  39.181 -                SendVideoFrame(&VideoBuffer[begin], bytes);
  39.182 -            }
  39.183 -            VideoBuffer.erase(VideoBuffer.begin(), VideoBuffer.begin()+last_offs);
  39.184 -        }
  39.185 -    }
  39.186 -    
  39.187 -    void SendVideoFrame(const unsigned char* vidbuf, unsigned framesize)
  39.188 -    {
  39.189 -        CheckBegin();
  39.190 -        
  39.191 -        //fprintf(stderr, "Writing 00dc of %u bytes\n", framesize);
  39.192 -        
  39.193 -        const unsigned char header[] = { s4("00dc"), u32(framesize) };
  39.194 -        FlushWrite(avifp, header, sizeof(header));
  39.195 -        FlushWrite(avifp, vidbuf, framesize);
  39.196 -    }
  39.197 -
  39.198 -    void SendAudioFrame(const unsigned char* audbuf, unsigned framesize)
  39.199 -    {
  39.200 -        CheckBegin();
  39.201 -        
  39.202 -        //fprintf(stderr, "Writing 01wb of %u bytes\n", framesize);
  39.203 -        
  39.204 -        const unsigned char header[] = { s4("01wb"), u32(framesize) };
  39.205 -        FlushWrite(avifp, header, sizeof(header));
  39.206 -        FlushWrite(avifp, audbuf, framesize);
  39.207 -    }
  39.208 -
  39.209 -    void CheckBegin()
  39.210 -    {
  39.211 -        if(avifp) return;
  39.212 -        
  39.213 -		if(!openFunc) openFunc = popen; // default
  39.214 -		if(!closeFunc) closeFunc = pclose; // default
  39.215 -
  39.216 -        avifp = openFunc(VIDEO_CMD.c_str(), "wb");
  39.217 -        if(!avifp) return;
  39.218 -
  39.219 -        const unsigned fourcc = BGR16;
  39.220 -        const unsigned framesize = width*height*2;
  39.221 -        
  39.222 -        const unsigned aud_rate  = rate;
  39.223 -        const unsigned aud_chans = chans;
  39.224 -        const unsigned aud_bits  = bits;
  39.225 -
  39.226 -        const unsigned nframes    = 0; //unknown
  39.227 -        const unsigned scale      = FPS_SCALE;
  39.228 -        const unsigned scaled_fps = fps_scaled;
  39.229 -        
  39.230 -        const unsigned SIZE_strh_vids = 4 + 4*2 + 2*2 + 8*4 + 2*4;
  39.231 -        const unsigned SIZE_strf_vids = 4*3 + 2*2 + 4*6;
  39.232 -        const unsigned SIZE_strl_vids = 4+ 4+(4+SIZE_strh_vids) + 4+(4+SIZE_strf_vids);
  39.233 -
  39.234 -        const unsigned SIZE_strh_auds = 4 + 4*3 + 2*2 + 4*8 + 2*4;
  39.235 -        const unsigned SIZE_strf_auds = 2*2 + 4*2 + 2*3;
  39.236 -        const unsigned SIZE_strl_auds = 4+ 4+(4+SIZE_strh_auds) + 4+(4+SIZE_strf_auds);
  39.237 -        
  39.238 -        const unsigned SIZE_avih = 4*12;
  39.239 -        const unsigned SIZE_hdrl = 4+4+ (4+SIZE_avih) + 4 + (4+SIZE_strl_vids) + 4 + (4+SIZE_strl_auds);
  39.240 -        const unsigned SIZE_movi = 4 + nframes*(4+4+framesize);
  39.241 -        const unsigned SIZE_avi = 4+4+ (4+SIZE_hdrl) + 4 + (4+SIZE_movi);
  39.242 -        
  39.243 -        const unsigned char AVIheader[] =
  39.244 -        {
  39.245 -            s4("RIFF"),
  39.246 -            u32(SIZE_avi),
  39.247 -            s4("AVI "),   
  39.248 -            
  39.249 -            // HEADER
  39.250 -
  39.251 -            s4("LIST"),   
  39.252 -            u32(SIZE_hdrl),
  39.253 -             s4("hdrl"),   
  39.254 -             
  39.255 -             s4("avih"),
  39.256 -             u32(SIZE_avih),
  39.257 -              u32(0),
  39.258 -              u32(0),
  39.259 -              u32(0),
  39.260 -              u32(0),
  39.261 -              u32(nframes),
  39.262 -              u32(0),
  39.263 -              u32(2), // two streams
  39.264 -              u32(0),
  39.265 -              u32(0),
  39.266 -              u32(0),
  39.267 -              u32(0),
  39.268 -              u32(0),
  39.269 -             
  39.270 -             // VIDEO HEADER
  39.271 -             
  39.272 -             s4("LIST"),
  39.273 -             u32(SIZE_strl_vids),
  39.274 -              s4("strl"),   
  39.275 -              
  39.276 -               s4("strh"),
  39.277 -               u32(SIZE_strh_vids),
  39.278 -                s4("vids"),
  39.279 -                u32(0),
  39.280 -                u32(0),
  39.281 -                u16(0),
  39.282 -                u16(0),
  39.283 -                u32(0),
  39.284 -                u32(scale),
  39.285 -                u32(scaled_fps),
  39.286 -                u32(0),
  39.287 -                u32(0),
  39.288 -                u32(0),
  39.289 -                u32(0),
  39.290 -                u32(0),
  39.291 -                u16(0),
  39.292 -                u16(0),
  39.293 -                u16(0),
  39.294 -                u16(0),
  39.295 -               
  39.296 -               s4("strf"),
  39.297 -               u32(SIZE_strf_vids),
  39.298 -                u32(0),
  39.299 -                u32(width),
  39.300 -                u32(height),
  39.301 -                u16(0),
  39.302 -                u16(0),
  39.303 -                u32(fourcc),
  39.304 -                u32(0),
  39.305 -                u32(0),
  39.306 -                u32(0),
  39.307 -                u32(0),
  39.308 -                u32(0),
  39.309 -             
  39.310 -             // AUDIO HEADER
  39.311 -             
  39.312 -             s4("LIST"),
  39.313 -             u32(SIZE_strl_auds),
  39.314 -              s4("strl"),   
  39.315 -              
  39.316 -               s4("strh"),
  39.317 -               u32(SIZE_strh_auds),
  39.318 -                s4("auds"),
  39.319 -                u32(0), //fourcc
  39.320 -                u32(0), //handler
  39.321 -                u32(0), //flags
  39.322 -                u16(0), //prio
  39.323 -                u16(0), //lang
  39.324 -                u32(0), //init frames
  39.325 -                u32(1), //scale
  39.326 -                u32(aud_rate),
  39.327 -                u32(0), //start
  39.328 -                u32(0), //rate*length
  39.329 -                u32(1048576), //suggested bufsize
  39.330 -                u32(0), //quality
  39.331 -                u32(aud_chans * (aud_bits / 8)), //sample size
  39.332 -                u16(0), //frame size
  39.333 -                u16(0),
  39.334 -                u16(0),
  39.335 -                u16(0),
  39.336 -               
  39.337 -               s4("strf"),
  39.338 -               u32(SIZE_strf_auds),
  39.339 -                u16(1), // pcm format
  39.340 -                u16(aud_chans),
  39.341 -                u32(aud_rate),
  39.342 -                u32(aud_rate * aud_chans * (aud_bits/8)), // samples per second
  39.343 -                u16(aud_chans * (aud_bits/8)), //block align
  39.344 -                u16(aud_bits), //bits
  39.345 -                u16(0), //cbSize
  39.346 -
  39.347 -            // MOVIE
  39.348 -
  39.349 -            s4("LIST"),
  39.350 -            u32(SIZE_movi),
  39.351 -             s4("movi")
  39.352 -        };
  39.353 -          
  39.354 -        FlushWrite(avifp, AVIheader, sizeof(AVIheader));
  39.355 -    }
  39.356 -} AVI;
  39.357 -
  39.358 -extern "C"
  39.359 -{
  39.360 -    int LoggingEnabled = 0; /* 0=no, 1=yes, 2=recording! */
  39.361 -
  39.362 -    const char* NESVideoGetVideoCmd()
  39.363 -    {
  39.364 -        return VIDEO_CMD.c_str();
  39.365 -    }
  39.366 -    void NESVideoSetVideoCmd(const char *cmd)
  39.367 -    {
  39.368 -        VIDEO_CMD = cmd;
  39.369 -    }
  39.370 -	void NESVideoEnableDebugging( void videoMessageFunc(const char *msg), void audioMessageFunc(const char *msg) )
  39.371 -	{
  39.372 -		debugVideoMessageFunc = videoMessageFunc;
  39.373 -		debugAudioMessageFunc = audioMessageFunc;
  39.374 -	}
  39.375 -	void NESVideoSetFileFuncs( FILE* open(const char *,const char *), int close(FILE*) )
  39.376 -	{
  39.377 -		openFunc = open;
  39.378 -		closeFunc = close;
  39.379 -	}
  39.380 -
  39.381 -    void NESVideoLoggingVideo
  39.382 -        (const void*data, unsigned width,unsigned height,
  39.383 -         unsigned fps_scaled
  39.384 -        )
  39.385 -    {
  39.386 -        if(LoggingEnabled < 2) return;
  39.387 -        
  39.388 -        unsigned LogoFrames = fps_scaled >> 24;
  39.389 -
  39.390 -        static bool First = true;
  39.391 -        if(First)
  39.392 -        {
  39.393 -            First=false;
  39.394 -            /* Bisqwit's logo addition routine. */
  39.395 -            /* If you don't have his files, this function does nothing
  39.396 -             * and it does not matter at all.
  39.397 -             */
  39.398 -            
  39.399 -            const char *background =
  39.400 -                width==320 ? "logo320_240"
  39.401 -              : width==160 ? "logo160_144"
  39.402 -              : width==240 ? "logo240_160"
  39.403 -              : height>224 ? "logo256_240"
  39.404 -              :              "logo256_224";
  39.405 -            
  39.406 -            /* Note: This should be 1 second long. */
  39.407 -            for(unsigned frame = 0; frame < LogoFrames; ++frame)
  39.408 -            {
  39.409 -                char Buf[4096];
  39.410 -                sprintf(Buf, "/shares/home/bisqwit/povray/nesvlogo/%s_f%u.tga",
  39.411 -                    background, frame);
  39.412 -                
  39.413 -                FILE*fp = fopen(Buf, "rb");
  39.414 -                if(!fp) // write blackness when missing frames to keep the intro 1 second long:
  39.415 -				{
  39.416 -			        unsigned bytes = width*height*2;
  39.417 -					unsigned char* buf = (unsigned char*)malloc(bytes);
  39.418 -					if(buf)
  39.419 -					{
  39.420 -						memset(buf,0,bytes);
  39.421 -						AVI.Video(width,height,fps_scaled, buf);
  39.422 -						if(debugVideoMessageFunc) videoFramesWritten--;
  39.423 -						free(buf);
  39.424 -					}
  39.425 -				}
  39.426 -				else // write 1 frame of the logo:
  39.427 -				{
  39.428 -					int idlen = fgetc(fp);
  39.429 -					/* Silently ignore all other header data.
  39.430 -					 * These files are assumed to be uncompressed BGR24 tga files with Y swapped.
  39.431 -					 * Even their geometry is assumed to match perfectly.
  39.432 -					 */
  39.433 -					fseek(fp, 1+1+2+2+1+ /*org*/2+2+ /*geo*/2+2+ 1+1+idlen, SEEK_CUR);
  39.434 -
  39.435 -					bool yflip=true;
  39.436 -					std::vector<unsigned char> data(width*height*3);
  39.437 -					for(unsigned y=height; y-->0; )
  39.438 -						fread(&data[y*width*3], 1, width*3, fp);
  39.439 -					fclose(fp);
  39.440 -	                
  39.441 -					std::vector<unsigned short> result(width*height);
  39.442 -					for(unsigned pos=0, max=result.size(); pos<max; ++pos)
  39.443 -					{
  39.444 -						unsigned usepos = pos;
  39.445 -						if(yflip)
  39.446 -						{
  39.447 -							unsigned y = pos/width;
  39.448 -							usepos = (usepos%width) + (height-y-1)*width;
  39.449 -						}
  39.450 -	                    
  39.451 -						unsigned B = data[usepos*3+0];
  39.452 -						unsigned G = data[usepos*3+1];
  39.453 -						unsigned R = data[usepos*3+2];
  39.454 -						result[pos] = ((B*31/255)<<0)
  39.455 -									| ((G*63/255)<<5)
  39.456 -									| ((R*31/255)<<11);
  39.457 -					}
  39.458 -					AVI.Video(width,height,fps_scaled, (const unsigned char*)&result[0]);
  39.459 -					if(debugVideoMessageFunc) videoFramesWritten--;
  39.460 -				}
  39.461 -            }
  39.462 -        }
  39.463 -        AVI.Video(width,height,fps_scaled,  (const unsigned char*) data);
  39.464 -    }
  39.465 -
  39.466 -    void NESVideoLoggingAudio
  39.467 -        (const void*data,
  39.468 -         unsigned rate, unsigned bits, unsigned chans,
  39.469 -         unsigned nsamples)
  39.470 -    {
  39.471 -        if(LoggingEnabled < 2) return;
  39.472 -
  39.473 -        static bool First = true;
  39.474 -        if(First)
  39.475 -        {
  39.476 -            First=false;
  39.477 -            
  39.478 -			const unsigned n = rate; // assumes 1 second of logo to write silence for
  39.479 -            if(n > 0)
  39.480 -			{
  39.481 -				unsigned bytes = n*chans*(bits/8);
  39.482 -				unsigned char* buf = (unsigned char*)malloc(bytes);
  39.483 -				if(buf)
  39.484 -				{
  39.485 -					memset(buf,0,bytes);
  39.486 -					AVI.Audio(rate,bits,chans, buf, n);
  39.487 -					free(buf);
  39.488 -				}
  39.489 -			}
  39.490 -        }
  39.491 -        
  39.492 -        AVI.Audio(rate,bits,chans, (const unsigned char*) data, nsamples);
  39.493 -    }
  39.494 -} /* extern "C" */
  39.495 -
  39.496 -
  39.497 -
  39.498 -static void FlushWrite(FILE* fp, const unsigned char*buf, unsigned length)
  39.499 -{
  39.500 -///	unsigned failures = 0;
  39.501 -///	const static int FAILURE_THRESH = 8092; // don't want to loop infinitely if we keep failing to make progress - actually maybe you would want this, so the checking is disabled
  39.502 -    while(length > 0 /*&& failures < FAILURE_THRESH*/)
  39.503 -    {
  39.504 -        unsigned written = fwrite(buf, 1, length, fp);
  39.505 -///		if(written == 0)
  39.506 -///			failures++;
  39.507 -///		else
  39.508 -///		{
  39.509 -			length -= written;
  39.510 -			buf += written;
  39.511 -///			failures = 0;
  39.512 -///		}
  39.513 -    }
  39.514 -///	if(failures >= FAILURE_THRESH)
  39.515 -///	{
  39.516 -///		fprintf(stderr, "FlushWrite() failed to write %d bytes %d times - giving up.", length, failures);
  39.517 -///		LoggingEnabled = 0;
  39.518 -///	}
  39.519 -}
  39.520 -
  39.521 -// for the UB tech
  39.522 -#undef BGR24
  39.523 -#undef BGR16
  39.524 -#undef BGR15
  39.525 -
  39.526 -#undef u32
  39.527 -#undef u16
  39.528 -#undef s4
    40.1 --- a/src/common/nesvideos-piece.h	Sat Mar 03 10:54:39 2012 -0600
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,48 +0,0 @@
    40.4 -#ifndef NESVPIECEhh
    40.5 -#define NESVPIECEhh
    40.6 -
    40.7 -#define NESVIDEOS_LOGGING 1
    40.8 -
    40.9 -#ifdef __cplusplus
   40.10 -extern "C" {
   40.11 -#endif
   40.12 -
   40.13 -/* Is video logging enabled? 0=no, 1=yes, 2=active. Default value: 0 */ 
   40.14 -extern int LoggingEnabled; 
   40.15 -
   40.16 -/* Get and set the video recording command (shell command) */ 
   40.17 -extern const char* NESVideoGetVideoCmd(); 
   40.18 -extern void NESVideoSetVideoCmd(const char *cmd);
   40.19 -
   40.20 -/* Tells to use these functions for obtaining/releasing FILE pointers for writing - if not specified, popen/pclose are used. */
   40.21 -extern void NESVideoSetFileFuncs( FILE* openFunc(const char *,const char *), int closeFunc(FILE*) );
   40.22 -
   40.23 -/* Tells to call these functions per frame with amounts (seconds and frames) of video and audio progress */
   40.24 -extern void NESVideoEnableDebugging( void videoMessageFunc(const char *msg), void audioMessageFunc(const char *msg) );
   40.25 -
   40.26 -/* Save 1 frame of video. (Assumed to be 16-bit RGB) */ 
   40.27 -/* FPS is scaled by 24 bits (*0x1000000) */
   40.28 -/* Does not do anything if LoggingEnabled<2. */ 
   40.29 -extern void NESVideoLoggingVideo
   40.30 -    (const void*data, unsigned width, unsigned height,
   40.31 -     unsigned fps_scaled); 
   40.32 -
   40.33 -/* Save N bytes of audio. bytes_per_second is required on the first call. */ 
   40.34 -/* Does not do anything if LoggingEnabled<2. */ 
   40.35 -/* The interval of calling this function is not important, as long as all the audio
   40.36 - * data is eventually written without too big delay (5 seconds is too big)
   40.37 - * This function may be called multiple times per video frame, or once per a few video
   40.38 - * frames, or anything in between. Just that all audio data must be written exactly once,
   40.39 - * and in order. */ 
   40.40 -extern void NESVideoLoggingAudio
   40.41 -    (const void*data,
   40.42 -     unsigned rate, unsigned bits, unsigned chans,
   40.43 -     unsigned nsamples);
   40.44 -/* nsamples*chans*(bits/8) = bytes in *data. */
   40.45 -/*     rate*chans*(bits/8) = bytes per second. */
   40.46 -
   40.47 -#ifdef __cplusplus
   40.48 -}
   40.49 -#endif
   40.50 -
   40.51 -#endif
    41.1 --- a/src/common/unzip.cpp	Sat Mar 03 10:54:39 2012 -0600
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,1208 +0,0 @@
    41.4 -/* unzip.c -- IO on .zip files using zlib
    41.5 -   Version 0.15 beta, Mar 19th, 1998,
    41.6 -
    41.7 -   Read unzip.h for more info
    41.8 - */
    41.9 -
   41.10 -#include <cstdio>
   41.11 -#include <cstdlib>
   41.12 -#include <cstring>
   41.13 -#include "zlib.h"
   41.14 -#include "unzip.h"
   41.15 -
   41.16 -#ifdef NO_ERRNO_H
   41.17 -extern int errno;
   41.18 -#else
   41.19 -#   include <cerrno>
   41.20 -#endif
   41.21 -
   41.22 -#ifndef local
   41.23 -#  define local static
   41.24 -#endif
   41.25 -/* compile with -Dlocal if your debugger can't find static symbols */
   41.26 -
   41.27 -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
   41.28 -    !defined(CASESENSITIVITYDEFAULT_NO)
   41.29 -#define CASESENSITIVITYDEFAULT_NO
   41.30 -#endif
   41.31 -
   41.32 -#ifndef UNZ_BUFSIZE
   41.33 -#define UNZ_BUFSIZE (16384)
   41.34 -#endif
   41.35 -
   41.36 -#ifndef UNZ_MAXFILENAMEINZIP
   41.37 -#define UNZ_MAXFILENAMEINZIP (256)
   41.38 -#endif
   41.39 -
   41.40 -#ifndef ALLOC
   41.41 -# define ALLOC(size) (malloc(size))
   41.42 -#endif
   41.43 -#ifndef TRYFREE
   41.44 -# define TRYFREE(p) {if (p) \
   41.45 -						 free(p);}
   41.46 -#endif
   41.47 -
   41.48 -#define SIZECENTRALDIRITEM (0x2e)
   41.49 -#define SIZEZIPLOCALHEADER (0x1e)
   41.50 -
   41.51 -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
   41.52 -
   41.53 -#ifndef SEEK_CUR
   41.54 -#define SEEK_CUR    1
   41.55 -#endif
   41.56 -
   41.57 -#ifndef SEEK_END
   41.58 -#define SEEK_END    2
   41.59 -#endif
   41.60 -
   41.61 -#ifndef SEEK_SET
   41.62 -#define SEEK_SET    0
   41.63 -#endif
   41.64 -
   41.65 -const char unz_copyright[] =
   41.66 -    " unzip 0.15 Copyright 1998 Gilles Vollant ";
   41.67 -
   41.68 -/* unz_file_info_interntal contain internal info about a file in zipfile*/
   41.69 -typedef struct unz_file_info_internal_s
   41.70 -{
   41.71 -	uLong offset_curfile; /* relative offset of local header 4 bytes */
   41.72 -} unz_file_info_internal;
   41.73 -
   41.74 -/* file_in_zip_read_info_s contain internal information about a file in zipfile,
   41.75 -    when reading and decompress it */
   41.76 -typedef struct
   41.77 -{
   41.78 -	char *   read_buffer;           /* internal buffer for compressed data */
   41.79 -	z_stream stream;                /* zLib stream structure for inflate */
   41.80 -
   41.81 -	uLong pos_in_zipfile;           /* position in byte on the zipfile, for fseek*/
   41.82 -	uLong stream_initialised;       /* flag set if stream structure is initialised*/
   41.83 -
   41.84 -	uLong offset_local_extrafield;    /* offset of the local extra field */
   41.85 -	uInt  size_local_extrafield;    /* size of the local extra field */
   41.86 -	uLong pos_local_extrafield;       /* position in the local extra field in read*/
   41.87 -
   41.88 -	uLong crc32;                    /* crc32 of all data uncompressed */
   41.89 -	uLong crc32_wait;               /* crc32 we must obtain after decompress all */
   41.90 -	uLong rest_read_compressed;     /* number of byte to be decompressed */
   41.91 -	uLong rest_read_uncompressed;    /*number of byte to be obtained after decomp*/
   41.92 -	FILE* file;                     /* io structore of the zipfile */
   41.93 -	uLong compression_method;       /* compression method (0==store) */
   41.94 -	uLong byte_before_the_zipfile;    /* byte before the zipfile, (>0 for sfx)*/
   41.95 -} file_in_zip_read_info_s;
   41.96 -
   41.97 -/* unz_s contain internal information about the zipfile
   41.98 - */
   41.99 -typedef struct
  41.100 -{
  41.101 -	FILE*file;                      /* io structore of the zipfile */
  41.102 -	unz_global_info gi;           /* public global information */
  41.103 -	uLong byte_before_the_zipfile;    /* byte before the zipfile, (>0 for sfx)*/
  41.104 -	uLong num_file;                 /* number of the current file in the zipfile*/
  41.105 -	uLong pos_in_central_dir;       /* pos of the current file in the central dir*/
  41.106 -	uLong current_file_ok;          /* flag about the usability of the current file*/
  41.107 -	uLong central_pos;              /* position of the beginning of the central dir*/
  41.108 -
  41.109 -	uLong size_central_dir;         /* size of the central directory  */
  41.110 -	uLong offset_central_dir;       /* offset of start of central directory with
  41.111 -									                               respect to the starting disk number */
  41.112 -
  41.113 -	unz_file_info cur_file_info;     /* public info about the current file in zip*/
  41.114 -	unz_file_info_internal  cur_file_info_internal;    /* private info about it*/
  41.115 -	file_in_zip_read_info_s*pfile_in_zip_read;  /* structure about the current
  41.116 -												   file if we are decompressing it */
  41.117 -} unz_s;
  41.118 -
  41.119 -/* ===========================================================================
  41.120 -     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
  41.121 -   for end of file.
  41.122 -   IN assertion: the stream s has been sucessfully opened for reading.
  41.123 - */
  41.124 -
  41.125 -local int unzlocal_getByte(FILE *fin, int *pi)
  41.126 -{
  41.127 -	unsigned char c;
  41.128 -	int err = fread(&c, 1, 1, fin);
  41.129 -	if (err == 1)
  41.130 -	{
  41.131 -		*pi = (int)c;
  41.132 -		return UNZ_OK;
  41.133 -	}
  41.134 -	else
  41.135 -	{
  41.136 -		if (ferror(fin))
  41.137 -			return UNZ_ERRNO;
  41.138 -		else
  41.139 -			return UNZ_EOF;
  41.140 -	}
  41.141 -}
  41.142 -
  41.143 -/* ===========================================================================
  41.144 -   Reads a long in LSB order from the given gz_stream. Sets
  41.145 - */
  41.146 -local int unzlocal_getShort(FILE *fin, uLong *pX)
  41.147 -{
  41.148 -	uLong x ;
  41.149 -	int   i;
  41.150 -	int   err;
  41.151 -
  41.152 -	err = unzlocal_getByte(fin, &i);
  41.153 -	x   = (uLong)i;
  41.154 -
  41.155 -	if (err == UNZ_OK)
  41.156 -		err = unzlocal_getByte(fin, &i);
  41.157 -	x += ((uLong)i)<<8;
  41.158 -
  41.159 -	if (err == UNZ_OK)
  41.160 -		*pX = x;
  41.161 -	else
  41.162 -		*pX = 0;
  41.163 -	return err;
  41.164 -}
  41.165 -
  41.166 -local int unzlocal_getLong(FILE *fin, uLong *pX)
  41.167 -{
  41.168 -	uLong x ;
  41.169 -	int   i;
  41.170 -	int   err;
  41.171 -
  41.172 -	err = unzlocal_getByte(fin, &i);
  41.173 -	x   = (uLong)i;
  41.174 -
  41.175 -	if (err == UNZ_OK)
  41.176 -		err = unzlocal_getByte(fin, &i);
  41.177 -	x += ((uLong)i)<<8;
  41.178 -
  41.179 -	if (err == UNZ_OK)
  41.180 -		err = unzlocal_getByte(fin, &i);
  41.181 -	x += ((uLong)i)<<16;
  41.182 -
  41.183 -	if (err == UNZ_OK)
  41.184 -		err = unzlocal_getByte(fin, &i);
  41.185 -	x += ((uLong)i)<<24;
  41.186 -
  41.187 -	if (err == UNZ_OK)
  41.188 -		*pX = x;
  41.189 -	else
  41.190 -		*pX = 0;
  41.191 -	return err;
  41.192 -}
  41.193 -
  41.194 -/* My own strcmpi / strcasecmp */
  41.195 -local int strcmpcasenosensitive_internal(const char *fileName1,
  41.196 -                                         const char *fileName2)
  41.197 -{
  41.198 -	for (;;)
  41.199 -	{
  41.200 -		char c1 = *(fileName1++);
  41.201 -		char c2 = *(fileName2++);
  41.202 -		if ((c1 >= 'a') && (c1 <= 'z'))
  41.203 -			c1 -= 0x20;
  41.204 -		if ((c2 >= 'a') && (c2 <= 'z'))
  41.205 -			c2 -= 0x20;
  41.206 -		if (c1 == '\0')
  41.207 -			return ((c2 == '\0') ? 0 : -1);
  41.208 -		if (c2 == '\0')
  41.209 -			return 1;
  41.210 -		if (c1 < c2)
  41.211 -			return -1;
  41.212 -		if (c1 > c2)
  41.213 -			return 1;
  41.214 -	}
  41.215 -}
  41.216 -
  41.217 -#ifdef  CASESENSITIVITYDEFAULT_NO
  41.218 -#define CASESENSITIVITYDEFAULTVALUE 2
  41.219 -#else
  41.220 -#define CASESENSITIVITYDEFAULTVALUE 1
  41.221 -#endif
  41.222 -
  41.223 -#ifndef STRCMPCASENOSENTIVEFUNCTION
  41.224 -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
  41.225 -#endif
  41.226 -
  41.227 -/*
  41.228 -   Compare two filename (fileName1,fileName2).
  41.229 -   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
  41.230 -   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
  41.231 -                                                                or strcasecmp)
  41.232 -   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
  41.233 -        (like 1 on Unix, 2 on Windows)
  41.234 -
  41.235 - */
  41.236 -extern int ZEXPORT unzStringFileNameCompare(const char *fileName1,
  41.237 -                                            const char *fileName2,
  41.238 -                                            int iCaseSensitivity)
  41.239 -{
  41.240 -	if (iCaseSensitivity == 0)
  41.241 -		iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE;
  41.242 -
  41.243 -	if (iCaseSensitivity == 1)
  41.244 -		return strcmp(fileName1, fileName2);
  41.245 -
  41.246 -	return STRCMPCASENOSENTIVEFUNCTION(fileName1, fileName2);
  41.247 -}
  41.248 -
  41.249 -#define BUFREADCOMMENT (0x400)
  41.250 -
  41.251 -/*
  41.252 -   Locate the Central directory of a zipfile (at the end, just before
  41.253 -    the global comment)
  41.254 - */
  41.255 -local uLong unzlocal_SearchCentralDir(FILE *fin)
  41.256 -{
  41.257 -	unsigned char*buf;
  41.258 -	uLong         uSizeFile;
  41.259 -	uLong         uBackRead;
  41.260 -	uLong         uMaxBack  = 0xffff; /* maximum size of global comment */
  41.261 -	uLong         uPosFound = 0;
  41.262 -
  41.263 -	if (fseek(fin, 0, SEEK_END) != 0)
  41.264 -		return 0;
  41.265 -
  41.266 -	uSizeFile = ftell(fin);
  41.267 -
  41.268 -	if (uMaxBack > uSizeFile)
  41.269 -		uMaxBack = uSizeFile;
  41.270 -
  41.271 -	buf = (unsigned char *)ALLOC(BUFREADCOMMENT+4);
  41.272 -	if (buf == NULL)
  41.273 -		return 0;
  41.274 -
  41.275 -	uBackRead = 4;
  41.276 -	while (uBackRead < uMaxBack)
  41.277 -	{
  41.278 -		uLong uReadSize, uReadPos ;
  41.279 -		int   i;
  41.280 -		if (uBackRead+BUFREADCOMMENT > uMaxBack)
  41.281 -			uBackRead = uMaxBack;
  41.282 -		else
  41.283 -			uBackRead += BUFREADCOMMENT;
  41.284 -		uReadPos = uSizeFile-uBackRead ;
  41.285 -
  41.286 -		uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
  41.287 -		            (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
  41.288 -		if (fseek(fin, uReadPos, SEEK_SET) != 0)
  41.289 -			break;
  41.290 -
  41.291 -		if (fread(buf, (uInt)uReadSize, 1, fin) != 1)
  41.292 -			break;
  41.293 -
  41.294 -		for (i = (int)uReadSize-3; (i--) > 0;)
  41.295 -			if (((*(buf+i)) == 0x50) && ((*(buf+i+1)) == 0x4b) &&
  41.296 -			    ((*(buf+i+2)) == 0x05) && ((*(buf+i+3)) == 0x06))
  41.297 -			{
  41.298 -				uPosFound = uReadPos+i;
  41.299 -				break;
  41.300 -			}
  41.301 -
  41.302 -		if (uPosFound != 0)
  41.303 -			break;
  41.304 -	}
  41.305 -	TRYFREE(buf);
  41.306 -	return uPosFound;
  41.307 -}
  41.308 -
  41.309 -/*
  41.310 -   Open a Zip file. path contain the full pathname (by example,
  41.311 -     on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
  41.312 -         "zlib/zlib109.zip".
  41.313 -         If the zipfile cannot be opened (file don't exist or in not valid), the
  41.314 -           return value is NULL.
  41.315 -     Else, the return value is a unzFile Handle, usable with other function
  41.316 -           of this unzip package.
  41.317 - */
  41.318 -extern unzFile ZEXPORT unzOpen(const char *path)
  41.319 -{
  41.320 -	unz_s  us;
  41.321 -	unz_s *s;
  41.322 -	uLong  central_pos, uL;
  41.323 -	FILE * fin ;
  41.324 -
  41.325 -	uLong number_disk;              /* number of the current dist, used for
  41.326 -									                               spaning ZIP, unsupported, always 0*/
  41.327 -	uLong number_disk_with_CD;      /* number the the disk with central dir, used
  41.328 -									                               for spaning ZIP, unsupported, always 0*/
  41.329 -	uLong number_entry_CD;          /* total number of entries in
  41.330 -									   the central dir
  41.331 -									   (same than number_entry on nospan) */
  41.332 -
  41.333 -	int err = UNZ_OK;
  41.334 -
  41.335 -	if (unz_copyright[0] != ' ')
  41.336 -		return NULL;
  41.337 -
  41.338 -	fin = fopen(path, "rb");
  41.339 -	if (fin == NULL)
  41.340 -		return NULL;
  41.341 -
  41.342 -	central_pos = unzlocal_SearchCentralDir(fin);
  41.343 -	if (central_pos == 0)
  41.344 -		err = UNZ_ERRNO;
  41.345 -
  41.346 -	if (fseek(fin, central_pos, SEEK_SET) != 0)
  41.347 -		err = UNZ_ERRNO;
  41.348 -
  41.349 -	/* the signature, already checked */
  41.350 -	if (unzlocal_getLong(fin, &uL) != UNZ_OK)
  41.351 -		err = UNZ_ERRNO;
  41.352 -
  41.353 -	/* number of this disk */
  41.354 -	if (unzlocal_getShort(fin, &number_disk) != UNZ_OK)
  41.355 -		err = UNZ_ERRNO;
  41.356 -
  41.357 -	/* number of the disk with the start of the central directory */
  41.358 -	if (unzlocal_getShort(fin, &number_disk_with_CD) != UNZ_OK)
  41.359 -		err = UNZ_ERRNO;
  41.360 -
  41.361 -	/* total number of entries in the central dir on this disk */
  41.362 -	if (unzlocal_getShort(fin, &us.gi.number_entry) != UNZ_OK)
  41.363 -		err = UNZ_ERRNO;
  41.364 -
  41.365 -	/* total number of entries in the central dir */
  41.366 -	if (unzlocal_getShort(fin, &number_entry_CD) != UNZ_OK)
  41.367 -		err = UNZ_ERRNO;
  41.368 -
  41.369 -	if ((number_entry_CD != us.gi.number_entry) ||
  41.370 -	    (number_disk_with_CD != 0) ||
  41.371 -	    (number_disk != 0))
  41.372 -		err = UNZ_BADZIPFILE;
  41.373 -
  41.374 -	/* size of the central directory */
  41.375 -	if (unzlocal_getLong(fin, &us.size_central_dir) != UNZ_OK)
  41.376 -		err = UNZ_ERRNO;
  41.377 -
  41.378 -	/* offset of start of central directory with respect to the
  41.379 -	      starting disk number */
  41.380 -	if (unzlocal_getLong(fin, &us.offset_central_dir) != UNZ_OK)
  41.381 -		err = UNZ_ERRNO;
  41.382 -
  41.383 -	/* zipfile comment length */
  41.384 -	if (unzlocal_getShort(fin, &us.gi.size_comment) != UNZ_OK)
  41.385 -		err = UNZ_ERRNO;
  41.386 -
  41.387 -	if ((central_pos < us.offset_central_dir+us.size_central_dir) &&
  41.388 -	    (err == UNZ_OK))
  41.389 -		err = UNZ_BADZIPFILE;
  41.390 -
  41.391 -	if (err != UNZ_OK)
  41.392 -	{
  41.393 -		fclose(fin);
  41.394 -		return NULL;
  41.395 -	}
  41.396 -
  41.397 -	us.file = fin;
  41.398 -	us.byte_before_the_zipfile = central_pos -
  41.399 -	                             (us.offset_central_dir+us.size_central_dir);
  41.400 -	us.central_pos       = central_pos;
  41.401 -	us.pfile_in_zip_read = NULL;
  41.402 -
  41.403 -	s  = (unz_s *)ALLOC(sizeof(unz_s));
  41.404 -	*s = us;
  41.405 -	unzGoToFirstFile((unzFile)s);
  41.406 -	return (unzFile)s;
  41.407 -}
  41.408 -
  41.409 -/*
  41.410 -   Close a ZipFile opened with unzipOpen.
  41.411 -   If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
  41.412 -    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
  41.413 -   return UNZ_OK if there is no problem. */
  41.414 -extern int ZEXPORT unzClose(unzFile file)
  41.415 -{
  41.416 -	unz_s*s;
  41.417 -	if (file == NULL)
  41.418 -		return UNZ_PARAMERROR;
  41.419 -	s = (unz_s *)file;
  41.420 -
  41.421 -	if (s->pfile_in_zip_read != NULL)
  41.422 -		unzCloseCurrentFile(file);
  41.423 -
  41.424 -	fclose(s->file);
  41.425 -	TRYFREE(s);
  41.426 -	return UNZ_OK;
  41.427 -}
  41.428 -
  41.429 -/*
  41.430 -   Write info about the ZipFile in the *pglobal_info structure.
  41.431 -   No preparation of the structure is needed
  41.432 -   return UNZ_OK if there is no problem. */
  41.433 -extern int ZEXPORT unzGetGlobalInfo(unzFile file,
  41.434 -                                    unz_global_info *pglobal_info)
  41.435 -{
  41.436 -	unz_s*s;
  41.437 -	if (file == NULL)
  41.438 -		return UNZ_PARAMERROR;
  41.439 -	s = (unz_s *)file;
  41.440 -	*pglobal_info = s->gi;
  41.441 -	return UNZ_OK;
  41.442 -}
  41.443 -
  41.444 -/*
  41.445 -   Translate date/time from Dos format to tm_unz (readable more easilty)
  41.446 - */
  41.447 -local void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz *ptm)
  41.448 -{
  41.449 -	uLong uDate;
  41.450 -	uDate        = (uLong)(ulDosDate>>16);
  41.451 -	ptm->tm_mday = (uInt)(uDate&0x1f) ;
  41.452 -	ptm->tm_mon  =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
  41.453 -	ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
  41.454 -
  41.455 -	ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
  41.456 -	ptm->tm_min  =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
  41.457 -	ptm->tm_sec  =  (uInt) (2*(ulDosDate&0x1f)) ;
  41.458 -}
  41.459 -
  41.460 -/*
  41.461 -   Get Info about the current file in the zipfile, with internal only info
  41.462 - */
  41.463 -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
  41.464 -                                                  unz_file_info *pfile_info,
  41.465 -                                                  unz_file_info_internal
  41.466 -                                                  *pfile_info_internal,
  41.467 -                                                  char *szFileName,
  41.468 -                                                  uLong fileNameBufferSize,
  41.469 -                                                  void *extraField,
  41.470 -                                                  uLong extraFieldBufferSize,
  41.471 -                                                  char *szComment,
  41.472 -                                                  uLong commentBufferSize));
  41.473 -
  41.474 -local int unzlocal_GetCurrentFileInfoInternal(unzFile file,
  41.475 -                                              unz_file_info *pfile_info,
  41.476 -                                              unz_file_info_internal *pfile_info_internal,
  41.477 -                                              char *szFileName,
  41.478 -                                              uLong fileNameBufferSize,
  41.479 -                                              void *extraField,
  41.480 -                                              uLong extraFieldBufferSize,
  41.481 -                                              char *szComment,
  41.482 -                                              uLong commentBufferSize)
  41.483 -{
  41.484 -	unz_s*        s;
  41.485 -	unz_file_info file_info;
  41.486 -	unz_file_info_internal file_info_internal;
  41.487 -	int   err = UNZ_OK;
  41.488 -	uLong uMagic;
  41.489 -	long  lSeek = 0;
  41.490 -
  41.491 -	if (file == NULL)
  41.492 -		return UNZ_PARAMERROR;
  41.493 -	s = (unz_s *)file;
  41.494 -	if (fseek(s->file, s->pos_in_central_dir+s->byte_before_the_zipfile, SEEK_SET) != 0)
  41.495 -		err = UNZ_ERRNO;
  41.496 -
  41.497 -	/* we check the magic */
  41.498 -	if (err == UNZ_OK)
  41.499 -		if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK)
  41.500 -			err = UNZ_ERRNO;
  41.501 -		else if (uMagic != 0x02014b50)
  41.502 -			err = UNZ_BADZIPFILE;
  41.503 -
  41.504 -	if (unzlocal_getShort(s->file, &file_info.version) != UNZ_OK)
  41.505 -		err = UNZ_ERRNO;
  41.506 -
  41.507 -	if (unzlocal_getShort(s->file, &file_info.version_needed) != UNZ_OK)
  41.508 -		err = UNZ_ERRNO;
  41.509 -
  41.510 -	if (unzlocal_getShort(s->file, &file_info.flag) != UNZ_OK)
  41.511 -		err = UNZ_ERRNO;
  41.512 -
  41.513 -	if (unzlocal_getShort(s->file, &file_info.compression_method) != UNZ_OK)
  41.514 -		err = UNZ_ERRNO;
  41.515 -
  41.516 -	if (unzlocal_getLong(s->file, &file_info.dosDate) != UNZ_OK)
  41.517 -		err = UNZ_ERRNO;
  41.518 -
  41.519 -	unzlocal_DosDateToTmuDate(file_info.dosDate, &file_info.tmu_date);
  41.520 -
  41.521 -	if (unzlocal_getLong(s->file, &file_info.crc) != UNZ_OK)
  41.522 -		err = UNZ_ERRNO;
  41.523 -
  41.524 -	if (unzlocal_getLong(s->file, &file_info.compressed_size) != UNZ_OK)
  41.525 -		err = UNZ_ERRNO;
  41.526 -
  41.527 -	if (unzlocal_getLong(s->file, &file_info.uncompressed_size) != UNZ_OK)
  41.528 -		err = UNZ_ERRNO;
  41.529 -
  41.530 -	if (unzlocal_getShort(s->file, &file_info.size_filename) != UNZ_OK)
  41.531 -		err = UNZ_ERRNO;
  41.532 -
  41.533 -	if (unzlocal_getShort(s->file, &file_info.size_file_extra) != UNZ_OK)
  41.534 -		err = UNZ_ERRNO;
  41.535 -
  41.536 -	if (unzlocal_getShort(s->file, &file_info.size_file_comment) != UNZ_OK)
  41.537 -		err = UNZ_ERRNO;
  41.538 -
  41.539 -	if (unzlocal_getShort(s->file, &file_info.disk_num_start) != UNZ_OK)
  41.540 -		err = UNZ_ERRNO;
  41.541 -
  41.542 -	if (unzlocal_getShort(s->file, &file_info.internal_fa) != UNZ_OK)
  41.543 -		err = UNZ_ERRNO;
  41.544 -
  41.545 -	if (unzlocal_getLong(s->file, &file_info.external_fa) != UNZ_OK)
  41.546 -		err = UNZ_ERRNO;
  41.547 -
  41.548 -	if (unzlocal_getLong(s->file, &file_info_internal.offset_curfile) != UNZ_OK)
  41.549 -		err = UNZ_ERRNO;
  41.550 -
  41.551 -	lSeek += file_info.size_filename;
  41.552 -	if ((err == UNZ_OK) && (szFileName != NULL))
  41.553 -	{
  41.554 -		uLong uSizeRead ;
  41.555 -		if (file_info.size_filename < fileNameBufferSize)
  41.556 -		{
  41.557 -			*(szFileName+file_info.size_filename) = '\0';
  41.558 -			uSizeRead = file_info.size_filename;
  41.559 -		}
  41.560 -		else
  41.561 -			uSizeRead = fileNameBufferSize;
  41.562 -
  41.563 -		if ((file_info.size_filename > 0) && (fileNameBufferSize > 0))
  41.564 -			if (fread(szFileName, (uInt)uSizeRead, 1, s->file) != 1)
  41.565 -				err = UNZ_ERRNO;
  41.566 -		lSeek -= uSizeRead;
  41.567 -	}
  41.568 -
  41.569 -	if ((err == UNZ_OK) && (extraField != NULL))
  41.570 -	{
  41.571 -		uLong uSizeRead ;
  41.572 -		if (file_info.size_file_extra < extraFieldBufferSize)
  41.573 -			uSizeRead = file_info.size_file_extra;
  41.574 -		else
  41.575 -			uSizeRead = extraFieldBufferSize;
  41.576 -
  41.577 -		if (lSeek != 0)
  41.578 -			if (fseek(s->file, lSeek, SEEK_CUR) == 0)
  41.579 -				lSeek = 0;
  41.580 -			else
  41.581 -				err = UNZ_ERRNO;
  41.582 -		if ((file_info.size_file_extra > 0) && (extraFieldBufferSize > 0))
  41.583 -			if (fread(extraField, (uInt)uSizeRead, 1, s->file) != 1)
  41.584 -				err = UNZ_ERRNO;
  41.585 -		lSeek += file_info.size_file_extra - uSizeRead;
  41.586 -	}
  41.587 -	else
  41.588 -		lSeek += file_info.size_file_extra;
  41.589 -
  41.590 -	if ((err == UNZ_OK) && (szComment != NULL))
  41.591 -	{
  41.592 -		uLong uSizeRead ;
  41.593 -		if (file_info.size_file_comment < commentBufferSize)
  41.594 -		{
  41.595 -			*(szComment+file_info.size_file_comment) = '\0';
  41.596 -			uSizeRead = file_info.size_file_comment;
  41.597 -		}
  41.598 -		else
  41.599 -			uSizeRead = commentBufferSize;
  41.600 -
  41.601 -		if (lSeek != 0)
  41.602 -			if (fseek(s->file, lSeek, SEEK_CUR) == 0)
  41.603 -				lSeek = 0;
  41.604 -			else
  41.605 -				err = UNZ_ERRNO;
  41.606 -		if ((file_info.size_file_comment > 0) && (commentBufferSize > 0))
  41.607 -			if (fread(szComment, (uInt)uSizeRead, 1, s->file) != 1)
  41.608 -				err = UNZ_ERRNO;
  41.609 -		lSeek += file_info.size_file_comment - uSizeRead;
  41.610 -	}
  41.611 -	else
  41.612 -		lSeek += file_info.size_file_comment;
  41.613 -
  41.614 -	if ((err == UNZ_OK) && (pfile_info != NULL))
  41.615 -		*pfile_info = file_info;
  41.616 -
  41.617 -	if ((err == UNZ_OK) && (pfile_info_internal != NULL))
  41.618 -		*pfile_info_internal = file_info_internal;
  41.619 -
  41.620 -	return err;
  41.621 -}
  41.622 -
  41.623 -/*
  41.624 -   Write info about the ZipFile in the *pglobal_info structure.
  41.625 -   No preparation of the structure is needed
  41.626 -   return UNZ_OK if there is no problem.
  41.627 - */
  41.628 -extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
  41.629 -                                         unz_file_info *pfile_info,
  41.630 -                                         char *szFileName,
  41.631 -                                         uLong fileNameBufferSize,
  41.632 -                                         void *extraField,
  41.633 -                                         uLong extraFieldBufferSize,
  41.634 -                                         char *szComment,
  41.635 -                                         uLong commentBufferSize)
  41.636 -{
  41.637 -	return unzlocal_GetCurrentFileInfoInternal(file, pfile_info, NULL,
  41.638 -	                                           szFileName, fileNameBufferSize,
  41.639 -	                                           extraField, extraFieldBufferSize,
  41.640 -	                                           szComment, commentBufferSize);
  41.641 -}
  41.642 -
  41.643 -/*
  41.644 -   Set the current file of the zipfile to the first file.
  41.645 -   return UNZ_OK if there is no problem
  41.646 - */
  41.647 -extern int ZEXPORT unzGoToFirstFile(unzFile file)
  41.648 -{
  41.649 -	int   err = UNZ_OK;
  41.650 -	unz_s*s;
  41.651 -	if (file == NULL)
  41.652 -		return UNZ_PARAMERROR;
  41.653 -	s = (unz_s *)file;
  41.654 -	s->pos_in_central_dir = s->offset_central_dir;
  41.655 -	s->num_file = 0;
  41.656 -	err         = unzlocal_GetCurrentFileInfoInternal(file, &s->cur_file_info,
  41.657 -	                                                  &s->cur_file_info_internal,
  41.658 -	                                                  NULL, 0, NULL, 0, NULL, 0);
  41.659 -	s->current_file_ok = (err == UNZ_OK);
  41.660 -	return err;
  41.661 -}
  41.662 -
  41.663 -/*
  41.664 -   Set the current file of the zipfile to the next file.
  41.665 -   return UNZ_OK if there is no problem
  41.666 -   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
  41.667 - */
  41.668 -extern int ZEXPORT unzGoToNextFile(unzFile file)
  41.669 -{
  41.670 -	unz_s*s;
  41.671 -	int   err;
  41.672 -
  41.673 -	if (file == NULL)
  41.674 -		return UNZ_PARAMERROR;
  41.675 -	s = (unz_s *)file;
  41.676 -	if (!s->current_file_ok)
  41.677 -		return UNZ_END_OF_LIST_OF_FILE;
  41.678 -	if (s->num_file+1 == s->gi.number_entry)
  41.679 -		return UNZ_END_OF_LIST_OF_FILE;
  41.680 -
  41.681 -	s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
  41.682 -	                         s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
  41.683 -	s->num_file++;
  41.684 -	err = unzlocal_GetCurrentFileInfoInternal(file, &s->cur_file_info,
  41.685 -	                                          &s->cur_file_info_internal,
  41.686 -	                                          NULL, 0, NULL, 0, NULL, 0);
  41.687 -	s->current_file_ok = (err == UNZ_OK);
  41.688 -	return err;
  41.689 -}
  41.690 -
  41.691 -/*
  41.692 -   Try locate the file szFileName in the zipfile.
  41.693 -   For the iCaseSensitivity signification, see unzipStringFileNameCompare
  41.694 -
  41.695 -   return value :
  41.696 -   UNZ_OK if the file is found. It becomes the current file.
  41.697 -   UNZ_END_OF_LIST_OF_FILE if the file is not found
  41.698 - */
  41.699 -extern int ZEXPORT unzLocateFile(unzFile file,
  41.700 -                                 const char *szFileName,
  41.701 -                                 int iCaseSensitivity)
  41.702 -{
  41.703 -	unz_s*s;
  41.704 -	int   err;
  41.705 -
  41.706 -	uLong num_fileSaved;
  41.707 -	uLong pos_in_central_dirSaved;
  41.708 -
  41.709 -	if (file == NULL)
  41.710 -		return UNZ_PARAMERROR;
  41.711 -
  41.712 -	if (strlen(szFileName) >= UNZ_MAXFILENAMEINZIP)
  41.713 -		return UNZ_PARAMERROR;
  41.714 -
  41.715 -	s = (unz_s *)file;
  41.716 -	if (!s->current_file_ok)
  41.717 -		return UNZ_END_OF_LIST_OF_FILE;
  41.718 -
  41.719 -	num_fileSaved = s->num_file;
  41.720 -	pos_in_central_dirSaved = s->pos_in_central_dir;
  41.721 -
  41.722 -	err = unzGoToFirstFile(file);
  41.723 -
  41.724 -	while (err == UNZ_OK)
  41.725 -	{
  41.726 -		char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
  41.727 -		unzGetCurrentFileInfo(file, NULL,
  41.728 -		                      szCurrentFileName, sizeof(szCurrentFileName)-1,
  41.729 -		                      NULL, 0, NULL, 0);
  41.730 -		if (unzStringFileNameCompare(szCurrentFileName,
  41.731 -		                             szFileName, iCaseSensitivity) == 0)
  41.732 -			return UNZ_OK;
  41.733 -		err = unzGoToNextFile(file);
  41.734 -	}
  41.735 -
  41.736 -	s->num_file = num_fileSaved ;
  41.737 -	s->pos_in_central_dir = pos_in_central_dirSaved ;
  41.738 -	return err;
  41.739 -}
  41.740 -
  41.741 -/*
  41.742 -   Read the local header of the current zipfile
  41.743 -   Check the coherency of the local header and info in the end of central
  41.744 -        directory about this file
  41.745 -   store in *piSizeVar the size of extra info in local header
  41.746 -        (filename and size of extra field data)
  41.747 - */
  41.748 -local int unzlocal_CheckCurrentFileCoherencyHeader(unz_s *s,
  41.749 -                                                   uInt *piSizeVar,
  41.750 -                                                   uLong *poffset_local_extrafield,
  41.751 -                                                   uInt *psize_local_extrafield)
  41.752 -{
  41.753 -	uLong uMagic, uData, uFlags;
  41.754 -	uLong size_filename;
  41.755 -	uLong size_extra_field;
  41.756 -	int   err = UNZ_OK;
  41.757 -
  41.758 -	*piSizeVar = 0;
  41.759 -	*poffset_local_extrafield = 0;
  41.760 -	*psize_local_extrafield   = 0;
  41.761 -
  41.762 -	if (fseek(s->file, s->cur_file_info_internal.offset_curfile +
  41.763 -	          s->byte_before_the_zipfile, SEEK_SET) != 0)
  41.764 -		return UNZ_ERRNO;
  41.765 -
  41.766 -	if (err == UNZ_OK)
  41.767 -		if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK)
  41.768 -			err = UNZ_ERRNO;
  41.769 -		else if (uMagic != 0x04034b50)
  41.770 -			err = UNZ_BADZIPFILE;
  41.771 -
  41.772 -	if (unzlocal_getShort(s->file, &uData) != UNZ_OK)
  41.773 -		err = UNZ_ERRNO;
  41.774 -/*
  41.775 -        else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
  41.776 -                err=UNZ_BADZIPFILE;
  41.777 - */
  41.778 -	if (unzlocal_getShort(s->file, &uFlags) != UNZ_OK)
  41.779 -		err = UNZ_ERRNO;
  41.780 -
  41.781 -	if (unzlocal_getShort(s->file, &uData) != UNZ_OK)
  41.782 -		err = UNZ_ERRNO;
  41.783 -	else if ((err == UNZ_OK) && (uData != s->cur_file_info.compression_method))
  41.784 -		err = UNZ_BADZIPFILE;
  41.785 -
  41.786 -	if ((err == UNZ_OK) && (s->cur_file_info.compression_method != 0) &&
  41.787 -	    (s->cur_file_info.compression_method != Z_DEFLATED))
  41.788 -		err = UNZ_BADZIPFILE;
  41.789 -
  41.790 -	if (unzlocal_getLong(s->file, &uData) != UNZ_OK)    /* date/time */
  41.791 -		err = UNZ_ERRNO;
  41.792 -
  41.793 -	if (unzlocal_getLong(s->file, &uData) != UNZ_OK)    /* crc */
  41.794 -		err = UNZ_ERRNO;
  41.795 -	else if ((err == UNZ_OK) && (uData != s->cur_file_info.crc) &&
  41.796 -	         ((uFlags & 8) == 0))
  41.797 -		err = UNZ_BADZIPFILE;
  41.798 -
  41.799 -	if (unzlocal_getLong(s->file, &uData) != UNZ_OK)    /* size compr */
  41.800 -		err = UNZ_ERRNO;
  41.801 -	else if ((err == UNZ_OK) && (uData != s->cur_file_info.compressed_size) &&
  41.802 -	         ((uFlags & 8) == 0))
  41.803 -		err = UNZ_BADZIPFILE;
  41.804 -
  41.805 -	if (unzlocal_getLong(s->file, &uData) != UNZ_OK)    /* size uncompr */
  41.806 -		err = UNZ_ERRNO;
  41.807 -	else if ((err == UNZ_OK) && (uData != s->cur_file_info.uncompressed_size) &&
  41.808 -	         ((uFlags & 8) == 0))
  41.809 -		err = UNZ_BADZIPFILE;
  41.810 -
  41.811 -	if (unzlocal_getShort(s->file, &size_filename) != UNZ_OK)
  41.812 -		err = UNZ_ERRNO;
  41.813 -	else if ((err == UNZ_OK) && (size_filename != s->cur_file_info.size_filename))
  41.814 -		err = UNZ_BADZIPFILE;
  41.815 -
  41.816 -	*piSizeVar += (uInt)size_filename;
  41.817 -
  41.818 -	if (unzlocal_getShort(s->file, &size_extra_field) != UNZ_OK)
  41.819 -		err = UNZ_ERRNO;
  41.820 -	*poffset_local_extrafield = s->cur_file_info_internal.offset_curfile +
  41.821 -	                            SIZEZIPLOCALHEADER + size_filename;
  41.822 -	*psize_local_extrafield = (uInt)size_extra_field;
  41.823 -
  41.824 -	*piSizeVar += (uInt)size_extra_field;
  41.825 -
  41.826 -	return err;
  41.827 -}
  41.828 -
  41.829 -/*
  41.830 -   Open for reading data the current file in the zipfile.
  41.831 -   If there is no error and the file is opened, the return value is UNZ_OK.
  41.832 - */
  41.833 -extern int ZEXPORT unzOpenCurrentFile(unzFile file)
  41.834 -{
  41.835 -	int   err = UNZ_OK;
  41.836 -	int   Store;
  41.837 -	uInt  iSizeVar;
  41.838 -	unz_s*s;
  41.839 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
  41.840 -	uLong offset_local_extrafield;      /* offset of the local extra field */
  41.841 -	uInt  size_local_extrafield;        /* size of the local extra field */
  41.842 -
  41.843 -	if (file == NULL)
  41.844 -		return UNZ_PARAMERROR;
  41.845 -	s = (unz_s *)file;
  41.846 -	if (!s->current_file_ok)
  41.847 -		return UNZ_PARAMERROR;
  41.848 -
  41.849 -	if (s->pfile_in_zip_read != NULL)
  41.850 -		unzCloseCurrentFile(file);
  41.851 -
  41.852 -	if (unzlocal_CheckCurrentFileCoherencyHeader(s, &iSizeVar,
  41.853 -	                                             &offset_local_extrafield, &size_local_extrafield) != UNZ_OK)
  41.854 -		return UNZ_BADZIPFILE;
  41.855 -
  41.856 -	pfile_in_zip_read_info = (file_in_zip_read_info_s *)
  41.857 -	                         ALLOC(sizeof(file_in_zip_read_info_s));
  41.858 -	if (pfile_in_zip_read_info == NULL)
  41.859 -		return UNZ_INTERNALERROR;
  41.860 -
  41.861 -	pfile_in_zip_read_info->read_buffer = (char *)ALLOC(UNZ_BUFSIZE);
  41.862 -	pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
  41.863 -	pfile_in_zip_read_info->size_local_extrafield   = size_local_extrafield;
  41.864 -	pfile_in_zip_read_info->pos_local_extrafield    = 0;
  41.865 -
  41.866 -	if (pfile_in_zip_read_info->read_buffer == NULL)
  41.867 -	{
  41.868 -		TRYFREE(pfile_in_zip_read_info);
  41.869 -		return UNZ_INTERNALERROR;
  41.870 -	}
  41.871 -
  41.872 -	pfile_in_zip_read_info->stream_initialised = 0;
  41.873 -
  41.874 -	if ((s->cur_file_info.compression_method != 0) &&
  41.875 -	    (s->cur_file_info.compression_method != Z_DEFLATED))
  41.876 -		err = UNZ_BADZIPFILE;
  41.877 -	Store = s->cur_file_info.compression_method == 0;
  41.878 -
  41.879 -	pfile_in_zip_read_info->crc32_wait         = s->cur_file_info.crc;
  41.880 -	pfile_in_zip_read_info->crc32              = 0;
  41.881 -	pfile_in_zip_read_info->compression_method =
  41.882 -	    s->cur_file_info.compression_method;
  41.883 -	pfile_in_zip_read_info->file = s->file;
  41.884 -	pfile_in_zip_read_info->byte_before_the_zipfile = s->byte_before_the_zipfile;
  41.885 -
  41.886 -	pfile_in_zip_read_info->stream.total_out = 0;
  41.887 -
  41.888 -	if (!Store)
  41.889 -	{
  41.890 -		pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
  41.891 -		pfile_in_zip_read_info->stream.zfree  = (free_func)0;
  41.892 -		pfile_in_zip_read_info->stream.opaque = (voidpf)0;
  41.893 -
  41.894 -		err = inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
  41.895 -		if (err == Z_OK)
  41.896 -			pfile_in_zip_read_info->stream_initialised = 1;
  41.897 -		/* windowBits is passed < 0 to tell that there is no zlib header.
  41.898 -		 * Note that in this case inflate *requires* an extra "dummy" byte
  41.899 -		 * after the compressed stream in order to complete decompression and
  41.900 -		 * return Z_STREAM_END.
  41.901 -		 * In unzip, i don't wait absolutely Z_STREAM_END because I known the
  41.902 -		 * size of both compressed and uncompressed data
  41.903 -		 */
  41.904 -	}
  41.905 -	pfile_in_zip_read_info->rest_read_compressed =
  41.906 -	    s->cur_file_info.compressed_size ;
  41.907 -	pfile_in_zip_read_info->rest_read_uncompressed =
  41.908 -	    s->cur_file_info.uncompressed_size ;
  41.909 -
  41.910 -	pfile_in_zip_read_info->pos_in_zipfile =
  41.911 -	    s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
  41.912 -	    iSizeVar;
  41.913 -
  41.914 -	pfile_in_zip_read_info->stream.avail_in = (uInt)0;
  41.915 -
  41.916 -	s->pfile_in_zip_read = pfile_in_zip_read_info;
  41.917 -	return UNZ_OK;
  41.918 -}
  41.919 -
  41.920 -/*
  41.921 -   Read bytes from the current file.
  41.922 -   buf contain buffer where data must be copied
  41.923 -   len the size of buf.
  41.924 -
  41.925 -   return the number of byte copied if somes bytes are copied
  41.926 -   return 0 if the end of file was reached
  41.927 -   return <0 with error code if there is an error
  41.928 -    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
  41.929 - */
  41.930 -extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
  41.931 -{
  41.932 -	int   err   = UNZ_OK;
  41.933 -	uInt  iRead = 0;
  41.934 -	unz_s*s;
  41.935 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
  41.936 -	if (file == NULL)
  41.937 -		return UNZ_PARAMERROR;
  41.938 -	s = (unz_s *)file;
  41.939 -	pfile_in_zip_read_info = s->pfile_in_zip_read;
  41.940 -
  41.941 -	if (pfile_in_zip_read_info == NULL)
  41.942 -		return UNZ_PARAMERROR;
  41.943 -
  41.944 -	if ((pfile_in_zip_read_info->read_buffer == NULL))
  41.945 -		return UNZ_END_OF_LIST_OF_FILE;
  41.946 -	if (len == 0)
  41.947 -		return 0;
  41.948 -
  41.949 -	pfile_in_zip_read_info->stream.next_out = (Bytef *)buf;
  41.950 -
  41.951 -	pfile_in_zip_read_info->stream.avail_out = (uInt)len;
  41.952 -
  41.953 -	if (len > pfile_in_zip_read_info->rest_read_uncompressed)
  41.954 -		pfile_in_zip_read_info->stream.avail_out =
  41.955 -		    (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
  41.956 -
  41.957 -	while (pfile_in_zip_read_info->stream.avail_out > 0)
  41.958 -	{
  41.959 -		if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
  41.960 -		    (pfile_in_zip_read_info->rest_read_compressed > 0))
  41.961 -		{
  41.962 -			uInt uReadThis = UNZ_BUFSIZE;
  41.963 -			if (pfile_in_zip_read_info->rest_read_compressed < uReadThis)
  41.964 -				uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
  41.965 -			if (uReadThis == 0)
  41.966 -				return UNZ_EOF;
  41.967 -			if (fseek(pfile_in_zip_read_info->file,
  41.968 -			          pfile_in_zip_read_info->pos_in_zipfile +
  41.969 -			          pfile_in_zip_read_info->byte_before_the_zipfile, SEEK_SET) != 0)
  41.970 -				return UNZ_ERRNO;
  41.971 -			if (fread(pfile_in_zip_read_info->read_buffer, uReadThis, 1,
  41.972 -			          pfile_in_zip_read_info->file) != 1)
  41.973 -				return UNZ_ERRNO;
  41.974 -			pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
  41.975 -
  41.976 -			pfile_in_zip_read_info->rest_read_compressed -= uReadThis;
  41.977 -
  41.978 -			pfile_in_zip_read_info->stream.next_in =
  41.979 -			    (Bytef *)pfile_in_zip_read_info->read_buffer;
  41.980 -			pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
  41.981 -		}
  41.982 -
  41.983 -		if (pfile_in_zip_read_info->compression_method == 0)
  41.984 -		{
  41.985 -			uInt uDoCopy, i ;
  41.986 -			if (pfile_in_zip_read_info->stream.avail_out <
  41.987 -			    pfile_in_zip_read_info->stream.avail_in)
  41.988 -				uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
  41.989 -			else
  41.990 -				uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
  41.991 -
  41.992 -			for (i = 0; i < uDoCopy; i++)
  41.993 -				*(pfile_in_zip_read_info->stream.next_out+i) =
  41.994 -				    *(pfile_in_zip_read_info->stream.next_in+i);
  41.995 -
  41.996 -			pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
  41.997 -			                                      pfile_in_zip_read_info->stream.next_out,
  41.998 -			                                      uDoCopy);
  41.999 -			pfile_in_zip_read_info->rest_read_uncompressed -= uDoCopy;
 41.1000 -			pfile_in_zip_read_info->stream.avail_in        -= uDoCopy;
 41.1001 -			pfile_in_zip_read_info->stream.avail_out       -= uDoCopy;
 41.1002 -			pfile_in_zip_read_info->stream.next_out        += uDoCopy;
 41.1003 -			pfile_in_zip_read_info->stream.next_in         += uDoCopy;
 41.1004 -			pfile_in_zip_read_info->stream.total_out       += uDoCopy;
 41.1005 -			iRead += uDoCopy;
 41.1006 -		}
 41.1007 -		else
 41.1008 -		{
 41.1009 -			uLong        uTotalOutBefore, uTotalOutAfter;
 41.1010 -			const Bytef *bufBefore;
 41.1011 -			uLong        uOutThis;
 41.1012 -			int flush = Z_SYNC_FLUSH;
 41.1013 -
 41.1014 -			uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
 41.1015 -			bufBefore       = pfile_in_zip_read_info->stream.next_out;
 41.1016 -
 41.1017 -			/*
 41.1018 -			   if ((pfile_in_zip_read_info->rest_read_uncompressed ==
 41.1019 -			         pfile_in_zip_read_info->stream.avail_out) &&
 41.1020 -			        (pfile_in_zip_read_info->rest_read_compressed == 0))
 41.1021 -			        flush = Z_FINISH;
 41.1022 -			 */
 41.1023 -			err = inflate(&pfile_in_zip_read_info->stream, flush);
 41.1024 -
 41.1025 -			uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
 41.1026 -			uOutThis       = uTotalOutAfter-uTotalOutBefore;
 41.1027 -
 41.1028 -			pfile_in_zip_read_info->crc32 =
 41.1029 -			    crc32(pfile_in_zip_read_info->crc32, bufBefore,
 41.1030 -			          (uInt)(uOutThis));
 41.1031 -
 41.1032 -			pfile_in_zip_read_info->rest_read_uncompressed -=
 41.1033 -			    uOutThis;
 41.1034 -
 41.1035 -			iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
 41.1036 -
 41.1037 -			if (err == Z_STREAM_END)
 41.1038 -				return (iRead == 0) ? UNZ_EOF : iRead;
 41.1039 -			if (err != Z_OK)
 41.1040 -				break;
 41.1041 -		}
 41.1042 -	}
 41.1043 -
 41.1044 -	if (err == Z_OK)
 41.1045 -		return iRead;
 41.1046 -	return err;
 41.1047 -}
 41.1048 -
 41.1049 -/*
 41.1050 -   Give the current position in uncompressed data
 41.1051 - */
 41.1052 -extern z_off_t ZEXPORT unztell(unzFile file)
 41.1053 -{
 41.1054 -	unz_s*s;
 41.1055 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
 41.1056 -	if (file == NULL)
 41.1057 -		return UNZ_PARAMERROR;
 41.1058 -	s = (unz_s *)file;
 41.1059 -	pfile_in_zip_read_info = s->pfile_in_zip_read;
 41.1060 -
 41.1061 -	if (pfile_in_zip_read_info == NULL)
 41.1062 -		return UNZ_PARAMERROR;
 41.1063 -
 41.1064 -	return (z_off_t)pfile_in_zip_read_info->stream.total_out;
 41.1065 -}
 41.1066 -
 41.1067 -/*
 41.1068 -   return 1 if the end of file was reached, 0 elsewhere
 41.1069 - */
 41.1070 -extern int ZEXPORT unzeof(unzFile file)
 41.1071 -{
 41.1072 -	unz_s*s;
 41.1073 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
 41.1074 -	if (file == NULL)
 41.1075 -		return UNZ_PARAMERROR;
 41.1076 -	s = (unz_s *)file;
 41.1077 -	pfile_in_zip_read_info = s->pfile_in_zip_read;
 41.1078 -
 41.1079 -	if (pfile_in_zip_read_info == NULL)
 41.1080 -		return UNZ_PARAMERROR;
 41.1081 -
 41.1082 -	if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
 41.1083 -		return 1;
 41.1084 -	else
 41.1085 -		return 0;
 41.1086 -}
 41.1087 -
 41.1088 -/*
 41.1089 -   Read extra field from the current file (opened by unzOpenCurrentFile)
 41.1090 -   This is the local-header version of the extra field (sometimes, there is
 41.1091 -    more info in the local-header version than in the central-header)
 41.1092 -
 41.1093 -   if buf==NULL, it return the size of the local extra field that can be read
 41.1094 -
 41.1095 -   if buf!=NULL, len is the size of the buffer, the extra header is copied in
 41.1096 -        buf.
 41.1097 -   the return value is the number of bytes copied in buf, or (if <0)
 41.1098 -        the error code
 41.1099 - */
 41.1100 -extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
 41.1101 -{
 41.1102 -	unz_s*s;
 41.1103 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
 41.1104 -	uInt  read_now;
 41.1105 -	uLong size_to_read;
 41.1106 -
 41.1107 -	if (file == NULL)
 41.1108 -		return UNZ_PARAMERROR;
 41.1109 -	s = (unz_s *)file;
 41.1110 -	pfile_in_zip_read_info = s->pfile_in_zip_read;
 41.1111 -
 41.1112 -	if (pfile_in_zip_read_info == NULL)
 41.1113 -		return UNZ_PARAMERROR;
 41.1114 -
 41.1115 -	size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
 41.1116 -	                pfile_in_zip_read_info->pos_local_extrafield);
 41.1117 -
 41.1118 -	if (buf == NULL)
 41.1119 -		return (int)size_to_read;
 41.1120 -
 41.1121 -	if (len > size_to_read)
 41.1122 -		read_now = (uInt)size_to_read;
 41.1123 -	else
 41.1124 -		read_now = (uInt)len ;
 41.1125 -
 41.1126 -	if (read_now == 0)
 41.1127 -		return 0;
 41.1128 -
 41.1129 -	if (fseek(pfile_in_zip_read_info->file,
 41.1130 -	          pfile_in_zip_read_info->offset_local_extrafield +
 41.1131 -	          pfile_in_zip_read_info->pos_local_extrafield, SEEK_SET) != 0)
 41.1132 -		return UNZ_ERRNO;
 41.1133 -
 41.1134 -	if (fread(buf, (uInt)size_to_read, 1, pfile_in_zip_read_info->file) != 1)
 41.1135 -		return UNZ_ERRNO;
 41.1136 -
 41.1137 -	return (int)read_now;
 41.1138 -}
 41.1139 -
 41.1140 -/*
 41.1141 -   Close the file in zip opened with unzipOpenCurrentFile
 41.1142 -   Return UNZ_CRCERROR if all the file was read but the CRC is not good
 41.1143 - */
 41.1144 -extern int ZEXPORT unzCloseCurrentFile(unzFile file)
 41.1145 -{
 41.1146 -	int err = UNZ_OK;
 41.1147 -
 41.1148 -	unz_s*s;
 41.1149 -	file_in_zip_read_info_s*pfile_in_zip_read_info;
 41.1150 -	if (file == NULL)
 41.1151 -		return UNZ_PARAMERROR;
 41.1152 -	s = (unz_s *)file;
 41.1153 -	pfile_in_zip_read_info = s->pfile_in_zip_read;
 41.1154 -
 41.1155 -	if (pfile_in_zip_read_info == NULL)
 41.1156 -		return UNZ_PARAMERROR;
 41.1157 -
 41.1158 -	if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
 41.1159 -	{
 41.1160 -		if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
 41.1161 -			err = UNZ_CRCERROR;
 41.1162 -	}
 41.1163 -
 41.1164 -	TRYFREE(pfile_in_zip_read_info->read_buffer);
 41.1165 -	pfile_in_zip_read_info->read_buffer = NULL;
 41.1166 -	if (pfile_in_zip_read_info->stream_initialised)
 41.1167 -		inflateEnd(&pfile_in_zip_read_info->stream);
 41.1168 -
 41.1169 -	pfile_in_zip_read_info->stream_initialised = 0;
 41.1170 -	TRYFREE(pfile_in_zip_read_info);
 41.1171 -
 41.1172 -	s->pfile_in_zip_read = NULL;
 41.1173 -
 41.1174 -	return err;
 41.1175 -}
 41.1176 -
 41.1177 -/*
 41.1178 -   Get the global comment string of the ZipFile, in the szComment buffer.
 41.1179 -   uSizeBuf is the size of the szComment buffer.
 41.1180 -   return the number of byte copied or an error code <0
 41.1181 - */
 41.1182 -extern int ZEXPORT unzGetGlobalComment(unzFile file,
 41.1183 -                                       char *szComment,
 41.1184 -                                       uLong uSizeBuf)
 41.1185 -{
 41.1186 -	//int err=UNZ_OK;
 41.1187 -	unz_s*s;
 41.1188 -	uLong uReadThis ;
 41.1189 -	if (file == NULL)
 41.1190 -		return UNZ_PARAMERROR;
 41.1191 -	s = (unz_s *)file;
 41.1192 -
 41.1193 -	uReadThis = uSizeBuf;
 41.1194 -	if (uReadThis > s->gi.size_comment)
 41.1195 -		uReadThis = s->gi.size_comment;
 41.1196 -
 41.1197 -	if (fseek(s->file, s->central_pos+22, SEEK_SET) != 0)
 41.1198 -		return UNZ_ERRNO;
 41.1199 -
 41.1200 -	if (uReadThis > 0)
 41.1201 -	{
 41.1202 -		*szComment = '\0';
 41.1203 -		if (fread(szComment, (uInt)uReadThis, 1, s->file) != 1)
 41.1204 -			return UNZ_ERRNO;
 41.1205 -	}
 41.1206 -
 41.1207 -	if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
 41.1208 -		*(szComment+s->gi.size_comment) = '\0';
 41.1209 -	return (int)uReadThis;
 41.1210 -}
 41.1211 -
    42.1 --- a/src/common/unzip.h	Sat Mar 03 10:54:39 2012 -0600
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,275 +0,0 @@
    42.4 -/* unzip.h -- IO for uncompress .zip files using zlib 
    42.5 -   Version 0.15 beta, Mar 19th, 1998,
    42.6 -
    42.7 -   Copyright (C) 1998 Gilles Vollant
    42.8 -
    42.9 -   This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
   42.10 -     WinZip, InfoZip tools and compatible.
   42.11 -   Encryption and multi volume ZipFile (span) are not supported.
   42.12 -   Old compressions used by old PKZip 1.x are not supported
   42.13 -
   42.14 -   THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
   42.15 -   CAN CHANGE IN FUTURE VERSION !!
   42.16 -   I WAIT FEEDBACK at mail info@winimage.com
   42.17 -   Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
   42.18 -
   42.19 -   Condition of use and distribution are the same than zlib :
   42.20 -
   42.21 -  This software is provided 'as-is', without any express or implied
   42.22 -  warranty.  In no event will the authors be held liable for any damages
   42.23 -  arising from the use of this software.
   42.24 -
   42.25 -  Permission is granted to anyone to use this software for any purpose,
   42.26 -  including commercial applications, and to alter it and redistribute it
   42.27 -  freely, subject to the following restrictions:
   42.28 -
   42.29 -  1. The origin of this software must not be misrepresented; you must not
   42.30 -     claim that you wrote the original software. If you use this software
   42.31 -     in a product, an acknowledgment in the product documentation would be
   42.32 -     appreciated but is not required.
   42.33 -  2. Altered source versions must be plainly marked as such, and must not be
   42.34 -     misrepresented as being the original software.
   42.35 -  3. This notice may not be removed or altered from any source distribution.
   42.36 -
   42.37 -
   42.38 -*/
   42.39 -/* for more info about .ZIP format, see 
   42.40 -      ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
   42.41 -   PkWare has also a specification at :
   42.42 -      ftp://ftp.pkware.com/probdesc.zip */
   42.43 -
   42.44 -#ifndef _unz_H
   42.45 -#define _unz_H
   42.46 -
   42.47 -#ifdef __cplusplus
   42.48 -extern "C" {
   42.49 -#endif
   42.50 -
   42.51 -#ifndef _ZLIB_H
   42.52 -#include "zlib.h"
   42.53 -#endif
   42.54 -
   42.55 -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
   42.56 -/* like the STRICT of WIN32, we define a pointer that cannot be converted
   42.57 -    from (void*) without cast */
   42.58 -typedef struct TagunzFile__ { int unused; } unzFile__; 
   42.59 -typedef unzFile__ *unzFile;
   42.60 -#else
   42.61 -typedef voidp unzFile;
   42.62 -#endif
   42.63 -
   42.64 -
   42.65 -#define UNZ_OK                                  (0)
   42.66 -#define UNZ_END_OF_LIST_OF_FILE (-100)
   42.67 -#define UNZ_ERRNO               (Z_ERRNO)
   42.68 -#define UNZ_EOF                 (0)
   42.69 -#define UNZ_PARAMERROR                  (-102)
   42.70 -#define UNZ_BADZIPFILE                  (-103)
   42.71 -#define UNZ_INTERNALERROR               (-104)
   42.72 -#define UNZ_CRCERROR                    (-105)
   42.73 -
   42.74 -/* tm_unz contain date/time info */
   42.75 -typedef struct tm_unz_s 
   42.76 -{
   42.77 -        uInt tm_sec;            /* seconds after the minute - [0,59] */
   42.78 -        uInt tm_min;            /* minutes after the hour - [0,59] */
   42.79 -        uInt tm_hour;           /* hours since midnight - [0,23] */
   42.80 -        uInt tm_mday;           /* day of the month - [1,31] */
   42.81 -        uInt tm_mon;            /* months since January - [0,11] */
   42.82 -        uInt tm_year;           /* years - [1980..2044] */
   42.83 -} tm_unz;
   42.84 -
   42.85 -/* unz_global_info structure contain global data about the ZIPfile
   42.86 -   These data comes from the end of central dir */
   42.87 -typedef struct unz_global_info_s
   42.88 -{
   42.89 -        uLong number_entry;         /* total number of entries in
   42.90 -                                       the central dir on this disk */
   42.91 -        uLong size_comment;         /* size of the global comment of the zipfile */
   42.92 -} unz_global_info;
   42.93 -
   42.94 -
   42.95 -/* unz_file_info contain information about a file in the zipfile */
   42.96 -typedef struct unz_file_info_s
   42.97 -{
   42.98 -    uLong version;              /* version made by                 2 bytes */
   42.99 -    uLong version_needed;       /* version needed to extract       2 bytes */
  42.100 -    uLong flag;                 /* general purpose bit flag        2 bytes */
  42.101 -    uLong compression_method;   /* compression method              2 bytes */
  42.102 -    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
  42.103 -    uLong crc;                  /* crc-32                          4 bytes */
  42.104 -    uLong compressed_size;      /* compressed size                 4 bytes */ 
  42.105 -    uLong uncompressed_size;    /* uncompressed size               4 bytes */ 
  42.106 -    uLong size_filename;        /* filename length                 2 bytes */
  42.107 -    uLong size_file_extra;      /* extra field length              2 bytes */
  42.108 -    uLong size_file_comment;    /* file comment length             2 bytes */
  42.109 -
  42.110 -    uLong disk_num_start;       /* disk number start               2 bytes */
  42.111 -    uLong internal_fa;          /* internal file attributes        2 bytes */
  42.112 -    uLong external_fa;          /* external file attributes        4 bytes */
  42.113 -
  42.114 -    tm_unz tmu_date;
  42.115 -} unz_file_info;
  42.116 -
  42.117 -extern int ZEXPORT  unzStringFileNameCompare OF ((const char* fileName1,
  42.118 -                                                 const char* fileName2,
  42.119 -                                                 int iCaseSensitivity));
  42.120 -/*
  42.121 -   Compare two filename (fileName1,fileName2).
  42.122 -   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
  42.123 -   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
  42.124 -                                                                or strcasecmp)
  42.125 -   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
  42.126 -        (like 1 on Unix, 2 on Windows)
  42.127 -*/
  42.128 -
  42.129 -
  42.130 -extern unzFile ZEXPORT  unzOpen OF((const char *path));
  42.131 -/*
  42.132 -  Open a Zip file. path contain the full pathname (by example,
  42.133 -     on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
  42.134 -         "zlib/zlib111.zip".
  42.135 -         If the zipfile cannot be opened (file don't exist or in not valid), the
  42.136 -           return value is NULL.
  42.137 -     Else, the return value is a unzFile Handle, usable with other function
  42.138 -           of this unzip package.
  42.139 -*/
  42.140 -
  42.141 -extern int ZEXPORT  unzClose OF((unzFile file));
  42.142 -/*
  42.143 -  Close a ZipFile opened with unzipOpen.
  42.144 -  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
  42.145 -    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
  42.146 -  return UNZ_OK if there is no problem. */
  42.147 -
  42.148 -extern int ZEXPORT  unzGetGlobalInfo OF((unzFile file,
  42.149 -                                        unz_global_info *pglobal_info));
  42.150 -/*
  42.151 -  Write info about the ZipFile in the *pglobal_info structure.
  42.152 -  No preparation of the structure is needed
  42.153 -  return UNZ_OK if there is no problem. */
  42.154 -
  42.155 -
  42.156 -extern int ZEXPORT  unzGetGlobalComment OF((unzFile file,
  42.157 -                                           char *szComment,
  42.158 -                                           uLong uSizeBuf));
  42.159 -/*
  42.160 -  Get the global comment string of the ZipFile, in the szComment buffer.
  42.161 -  uSizeBuf is the size of the szComment buffer.
  42.162 -  return the number of byte copied or an error code <0
  42.163 -*/
  42.164 -
  42.165 -
  42.166 -/***************************************************************************/
  42.167 -/* Unzip package allow you browse the directory of the zipfile */
  42.168 -
  42.169 -extern int ZEXPORT  unzGoToFirstFile OF((unzFile file));
  42.170 -/*
  42.171 -  Set the current file of the zipfile to the first file.
  42.172 -  return UNZ_OK if there is no problem
  42.173 -*/
  42.174 -
  42.175 -extern int ZEXPORT  unzGoToNextFile OF((unzFile file));
  42.176 -/*
  42.177 -  Set the current file of the zipfile to the next file.
  42.178 -  return UNZ_OK if there is no problem
  42.179 -  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
  42.180 -*/
  42.181 -
  42.182 -extern int ZEXPORT  unzLocateFile OF((unzFile file, 
  42.183 -                                     const char *szFileName,
  42.184 -                                     int iCaseSensitivity));
  42.185 -/*
  42.186 -  Try locate the file szFileName in the zipfile.
  42.187 -  For the iCaseSensitivity signification, see unzStringFileNameCompare
  42.188 -
  42.189 -  return value :
  42.190 -  UNZ_OK if the file is found. It becomes the current file.
  42.191 -  UNZ_END_OF_LIST_OF_FILE if the file is not found
  42.192 -*/
  42.193 -
  42.194 -
  42.195 -extern int ZEXPORT  unzGetCurrentFileInfo OF((unzFile file,
  42.196 -                                             unz_file_info *pfile_info,
  42.197 -                                             char *szFileName,
  42.198 -                                             uLong fileNameBufferSize,
  42.199 -                                             void *extraField,
  42.200 -                                             uLong extraFieldBufferSize,
  42.201 -                                             char *szComment,
  42.202 -                                             uLong commentBufferSize));
  42.203 -/*
  42.204 -  Get Info about the current file
  42.205 -  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
  42.206 -            the current file
  42.207 -  if szFileName!=NULL, the filemane string will be copied in szFileName
  42.208 -                        (fileNameBufferSize is the size of the buffer)
  42.209 -  if extraField!=NULL, the extra field information will be copied in extraField
  42.210 -                        (extraFieldBufferSize is the size of the buffer).
  42.211 -                        This is the Central-header version of the extra field
  42.212 -  if szComment!=NULL, the comment string of the file will be copied in szComment
  42.213 -                        (commentBufferSize is the size of the buffer)
  42.214 -*/
  42.215 -
  42.216 -/***************************************************************************/
  42.217 -/* for reading the content of the current zipfile, you can open it, read data
  42.218 -   from it, and close it (you can close it before reading all the file)
  42.219 -   */
  42.220 -
  42.221 -extern int ZEXPORT  unzOpenCurrentFile OF((unzFile file));
  42.222 -/*
  42.223 -  Open for reading data the current file in the zipfile.
  42.224 -  If there is no error, the return value is UNZ_OK.
  42.225 -*/
  42.226 -
  42.227 -extern int ZEXPORT  unzCloseCurrentFile OF((unzFile file));
  42.228 -/*
  42.229 -  Close the file in zip opened with unzOpenCurrentFile
  42.230 -  Return UNZ_CRCERROR if all the file was read but the CRC is not good
  42.231 -*/
  42.232 -
  42.233 -                                                                                                
  42.234 -extern int ZEXPORT  unzReadCurrentFile OF((unzFile file, 
  42.235 -                                          voidp buf,
  42.236 -                                          unsigned len));
  42.237 -/*
  42.238 -  Read bytes from the current file (opened by unzOpenCurrentFile)
  42.239 -  buf contain buffer where data must be copied
  42.240 -  len the size of buf.
  42.241 -
  42.242 -  return the number of byte copied if somes bytes are copied
  42.243 -  return 0 if the end of file was reached
  42.244 -  return <0 with error code if there is an error
  42.245 -    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
  42.246 -*/
  42.247 -
  42.248 -extern z_off_t ZEXPORT  unztell OF((unzFile file));
  42.249 -/*
  42.250 -  Give the current position in uncompressed data
  42.251 -*/
  42.252 -
  42.253 -extern int ZEXPORT  unzeof OF((unzFile file));
  42.254 -/*
  42.255 -  return 1 if the end of file was reached, 0 elsewhere 
  42.256 -*/
  42.257 -
  42.258 -extern int ZEXPORT  unzGetLocalExtrafield OF((unzFile file,
  42.259 -                                             voidp buf,
  42.260 -                                             unsigned len));
  42.261 -/*
  42.262 -  Read extra field from the current file (opened by unzOpenCurrentFile)
  42.263 -  This is the local-header version of the extra field (sometimes, there is
  42.264 -    more info in the local-header version than in the central-header)
  42.265 -
  42.266 -  if buf==NULL, it return the size of the local extra field
  42.267 -
  42.268 -  if buf!=NULL, len is the size of the buffer, the extra header is copied in
  42.269 -        buf.
  42.270 -  the return value is the number of bytes copied in buf, or (if <0) 
  42.271 -        the error code
  42.272 -*/
  42.273 -
  42.274 -#ifdef __cplusplus
  42.275 -}
  42.276 -#endif
  42.277 -
  42.278 -#endif /* _unz_H */
    43.1 --- a/src/common/vbalua.h	Sat Mar 03 10:54:39 2012 -0600
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,52 +0,0 @@
    43.4 -#ifndef VBA_LUA_H
    43.5 -#define VBA_LUA_H
    43.6 -
    43.7 -#if _MSC_VER > 1000
    43.8 -#pragma once
    43.9 -#endif // _MSC_VER > 1000
   43.10 -
   43.11 -enum LuaCallID
   43.12 -{
   43.13 -	LUACALL_BEFOREEMULATION,
   43.14 -	LUACALL_AFTEREMULATION,
   43.15 -	LUACALL_BEFOREEXIT,
   43.16 -
   43.17 -	LUACALL_COUNT
   43.18 -};
   43.19 -void CallRegisteredLuaFunctions(LuaCallID calltype);
   43.20 -
   43.21 -enum LuaMemHookType
   43.22 -{
   43.23 -	LUAMEMHOOK_WRITE,
   43.24 -	LUAMEMHOOK_READ,
   43.25 -	LUAMEMHOOK_EXEC,
   43.26 -	LUAMEMHOOK_WRITE_SUB,
   43.27 -	LUAMEMHOOK_READ_SUB,
   43.28 -	LUAMEMHOOK_EXEC_SUB,
   43.29 -
   43.30 -	LUAMEMHOOK_COUNT
   43.31 -};
   43.32 -void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType);
   43.33 -
   43.34 -// Just forward function declarations
   43.35 -
   43.36 -void VBALuaFrameBoundary();
   43.37 -int VBALoadLuaCode(const char *filename);
   43.38 -int VBAReloadLuaCode();
   43.39 -void VBALuaStop();
   43.40 -int VBALuaRunning();
   43.41 -
   43.42 -int VBALuaUsingJoypad(int);
   43.43 -int VBALuaReadJoypad(int);
   43.44 -int VBALuaSpeed();
   43.45 -bool8 VBALuaRerecordCountSkip();
   43.46 -
   43.47 -void VBALuaGui(uint8 *screen, int ppl, int width, int height);
   43.48 -void VBALuaClearGui();
   43.49 -
   43.50 -char* VBAGetLuaScriptName();
   43.51 -
   43.52 -// And some interesting REVERSE declarations!
   43.53 -char *VBAGetFreezeFilename(int slot);
   43.54 -
   43.55 -#endif // VBA_LUA_H
    44.1 --- a/src/filters/2xSaI.cpp	Sat Mar 03 10:54:39 2012 -0600
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,1434 +0,0 @@
    44.4 -#include "../common/System.h"
    44.5 -
    44.6 -extern "C"
    44.7 -{
    44.8 -#ifdef MMX
    44.9 -	void _2xSaILine(u8 *srcPtr, u8 *deltaPtr, u32 srcPitch,
   44.10 -	                u32 width, u8 *dstPtr, u32 dstPitch);
   44.11 -	void _2xSaISuperEagleLine(u8 *srcPtr, u8 *deltaPtr,
   44.12 -	                          u32 srcPitch, u32 width,
   44.13 -	                          u8 *dstPtr, u32 dstPitch);
   44.14 -	void _2xSaISuper2xSaILine(u8 *srcPtr, u8 *deltaPtr,
   44.15 -	                          u32 srcPitch, u32 width,
   44.16 -	                          u8 *dstPtr, u32 dstPitch);
   44.17 -	void Init_2xSaIMMX(u32 BitFormat);
   44.18 -	void BilinearMMX(u16 *A, u16 *B, u16 *C, u16 *D,
   44.19 -	                 u16 *dx, u16 *dy, u8 *dP);
   44.20 -	void BilinearMMXGrid0(u16 *A, u16 *B, u16 *C, u16 *D,
   44.21 -	                      u16 *dx, u16 *dy, u8 *dP);
   44.22 -	void BilinearMMXGrid1(u16 *A, u16 *B, u16 *C, u16 *D,
   44.23 -	                      u16 *dx, u16 *dy, u8 *dP);
   44.24 -	void EndMMX();
   44.25 -
   44.26 -	bool cpu_mmx = 1;
   44.27 -#endif
   44.28 -}
   44.29 -static u32 colorMask	 = 0xF7DEF7DE;
   44.30 -static u32 lowPixelMask	 = 0x08210821;
   44.31 -static u32 qcolorMask	 = 0xE79CE79C;
   44.32 -static u32 qlowpixelMask = 0x18631863;
   44.33 -static u32 redblueMask	 = 0xF81F;
   44.34 -static u32 greenMask	 = 0x7E0;
   44.35 -
   44.36 -u32 qRGB_COLOR_MASK[2] = { 0xF7DEF7DE, 0xF7DEF7DE };
   44.37 -
   44.38 -extern void hq2x_init(unsigned);
   44.39 -
   44.40 -int Init_2xSaI(u32 BitFormat)
   44.41 -{
   44.42 -	if (systemColorDepth == 16)
   44.43 -	{
   44.44 -		if (BitFormat == 565)
   44.45 -		{
   44.46 -			colorMask		   = 0xF7DEF7DE;
   44.47 -			lowPixelMask	   = 0x08210821;
   44.48 -			qcolorMask		   = 0xE79CE79C;
   44.49 -			qlowpixelMask	   = 0x18631863;
   44.50 -			redblueMask		   = 0xF81F;
   44.51 -			greenMask		   = 0x7E0;
   44.52 -			qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE;
   44.53 -			hq2x_init(16);
   44.54 -		}
   44.55 -		else if (BitFormat == 555)
   44.56 -		{
   44.57 -			colorMask		   = 0x7BDE7BDE;
   44.58 -			lowPixelMask	   = 0x04210421;
   44.59 -			qcolorMask		   = 0x739C739C;
   44.60 -			qlowpixelMask	   = 0x0C630C63;
   44.61 -			redblueMask		   = 0x7C1F;
   44.62 -			greenMask		   = 0x3E0;
   44.63 -			qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE;
   44.64 -			hq2x_init(15);
   44.65 -		}
   44.66 -		else
   44.67 -		{
   44.68 -			return 0;
   44.69 -		}
   44.70 -	}
   44.71 -	else if (systemColorDepth == 32)
   44.72 -	{
   44.73 -		colorMask		   = 0xfefefe;
   44.74 -		lowPixelMask	   = 0x010101;
   44.75 -		qcolorMask		   = 0xfcfcfc;
   44.76 -		qlowpixelMask	   = 0x030303;
   44.77 -		qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe;
   44.78 -		hq2x_init(32);
   44.79 -	}
   44.80 -	else
   44.81 -		return 0;
   44.82 -
   44.83 -#ifdef MMX
   44.84 -	Init_2xSaIMMX(BitFormat);
   44.85 -#endif
   44.86 -
   44.87 -	return 1;
   44.88 -}
   44.89 -
   44.90 -static inline int GetResult1(u32 A, u32 B, u32 C, u32 D,
   44.91 -                             u32 /* E */)
   44.92 -{
   44.93 -	int x = 0;
   44.94 -	int y = 0;
   44.95 -	int r = 0;
   44.96 -
   44.97 -	if (A == C)
   44.98 -		x += 1;
   44.99 -	else if (B == C)
  44.100 -		y += 1;
  44.101 -	if (A == D)
  44.102 -		x += 1;
  44.103 -	else if (B == D)
  44.104 -		y += 1;
  44.105 -	if (x <= 1)
  44.106 -		r += 1;
  44.107 -	if (y <= 1)
  44.108 -		r -= 1;
  44.109 -	return r;
  44.110 -}
  44.111 -
  44.112 -static inline int GetResult2(u32 A, u32 B, u32 C, u32 D,
  44.113 -                             u32 /* E */)
  44.114 -{
  44.115 -	int x = 0;
  44.116 -	int y = 0;
  44.117 -	int r = 0;
  44.118 -
  44.119 -	if (A == C)
  44.120 -		x += 1;
  44.121 -	else if (B == C)
  44.122 -		y += 1;
  44.123 -	if (A == D)
  44.124 -		x += 1;
  44.125 -	else if (B == D)
  44.126 -		y += 1;
  44.127 -	if (x <= 1)
  44.128 -		r -= 1;
  44.129 -	if (y <= 1)
  44.130 -		r += 1;
  44.131 -	return r;
  44.132 -}
  44.133 -
  44.134 -static inline int GetResult(u32 A, u32 B, u32 C, u32 D)
  44.135 -{
  44.136 -	int x = 0;
  44.137 -	int y = 0;
  44.138 -	int r = 0;
  44.139 -
  44.140 -	if (A == C)
  44.141 -		x += 1;
  44.142 -	else if (B == C)
  44.143 -		y += 1;
  44.144 -	if (A == D)
  44.145 -		x += 1;
  44.146 -	else if (B == D)
  44.147 -		y += 1;
  44.148 -	if (x <= 1)
  44.149 -		r += 1;
  44.150 -	if (y <= 1)
  44.151 -		r -= 1;
  44.152 -	return r;
  44.153 -}
  44.154 -
  44.155 -static inline u32 INTERPOLATE(u32 A, u32 B)
  44.156 -{
  44.157 -	if (A != B)
  44.158 -	{
  44.159 -		return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) +
  44.160 -		        (A & B & lowPixelMask));
  44.161 -	}
  44.162 -	else
  44.163 -		return A;
  44.164 -}
  44.165 -
  44.166 -static inline u32 Q_INTERPOLATE(u32 A, u32 B, u32 C, u32 D)
  44.167 -{
  44.168 -	register u32 x = ((A & qcolorMask) >> 2) +
  44.169 -	                 ((B & qcolorMask) >> 2) +
  44.170 -	                 ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
  44.171 -	register u32 y = (A & qlowpixelMask) +
  44.172 -	                 (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask);
  44.173 -
  44.174 -	y = (y >> 2) & qlowpixelMask;
  44.175 -	return x + y;
  44.176 -}
  44.177 -
  44.178 -static inline int GetResult1_32(u32 A, u32 B, u32 C, u32 D,
  44.179 -                                u32 /* E */)
  44.180 -{
  44.181 -	int x = 0;
  44.182 -	int y = 0;
  44.183 -	int r = 0;
  44.184 -
  44.185 -	if (A == C)
  44.186 -		x += 1;
  44.187 -	else if (B == C)
  44.188 -		y += 1;
  44.189 -	if (A == D)
  44.190 -		x += 1;
  44.191 -	else if (B == D)
  44.192 -		y += 1;
  44.193 -	if (x <= 1)
  44.194 -		r += 1;
  44.195 -	if (y <= 1)
  44.196 -		r -= 1;
  44.197 -	return r;
  44.198 -}
  44.199 -
  44.200 -static inline int GetResult2_32(u32 A, u32 B, u32 C, u32 D,
  44.201 -                                u32 /* E */)
  44.202 -{
  44.203 -	int x = 0;
  44.204 -	int y = 0;
  44.205 -	int r = 0;
  44.206 -
  44.207 -	if (A == C)
  44.208 -		x += 1;
  44.209 -	else if (B == C)
  44.210 -		y += 1;
  44.211 -	if (A == D)
  44.212 -		x += 1;
  44.213 -	else if (B == D)
  44.214 -		y += 1;
  44.215 -	if (x <= 1)
  44.216 -		r -= 1;
  44.217 -	if (y <= 1)
  44.218 -		r += 1;
  44.219 -	return r;
  44.220 -}
  44.221 -
  44.222 -#define BLUE_MASK565 0x001F001F
  44.223 -#define RED_MASK565 0xF800F800
  44.224 -#define GREEN_MASK565 0x07E007E0
  44.225 -
  44.226 -#define BLUE_MASK555 0x001F001F
  44.227 -#define RED_MASK555 0x7C007C00
  44.228 -#define GREEN_MASK555 0x03E003E0
  44.229 -
  44.230 -void Super2xSaI(u8 *srcPtr, u32 srcPitch,
  44.231 -                u8 *deltaPtr, u8 *dstPtr, u32 dstPitch,
  44.232 -                int width, int height)
  44.233 -{
  44.234 -	u16 *bP;
  44.235 -	u8 * dP;
  44.236 -	u32	 inc_bP;
  44.237 -	u32	 Nextline = srcPitch >> 1;
  44.238 -#ifdef MMX
  44.239 -	if (cpu_mmx)
  44.240 -	{
  44.241 -		for (; height; height--)
  44.242 -		{
  44.243 -			_2xSaISuper2xSaILine(srcPtr, deltaPtr, srcPitch, width,
  44.244 -			                     dstPtr, dstPitch);
  44.245 -			srcPtr	 += srcPitch;
  44.246 -			dstPtr	 += dstPitch * 2;
  44.247 -			deltaPtr += srcPitch;
  44.248 -		}
  44.249 -	}
  44.250 -	else
  44.251 -#endif
  44.252 -	{
  44.253 -		inc_bP = 1;
  44.254 -
  44.255 -		for (; height; height--)
  44.256 -		{
  44.257 -			bP = (u16 *) srcPtr;
  44.258 -			dP = (u8 *) dstPtr;
  44.259 -
  44.260 -			for (u32 finish = width; finish; finish -= inc_bP)
  44.261 -			{
  44.262 -				u32 color4, color5, color6;
  44.263 -				u32 color1, color2, color3;
  44.264 -				u32 colorA0, colorA1, colorA2, colorA3,
  44.265 -				    colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
  44.266 -				u32 product1a, product1b, product2a, product2b;
  44.267 -
  44.268 -				//---------------------------------------    B1 B2
  44.269 -				//                                         4  5  6 S2
  44.270 -				//                                         1  2  3 S1
  44.271 -				//                                           A1 A2
  44.272 -
  44.273 -				colorB0 = *(bP - Nextline - 1);
  44.274 -				colorB1 = *(bP - Nextline);
  44.275 -				colorB2 = *(bP - Nextline + 1);
  44.276 -				colorB3 = *(bP - Nextline + 2);
  44.277 -
  44.278 -				color4	= *(bP - 1);
  44.279 -				color5	= *(bP);
  44.280 -				color6	= *(bP + 1);
  44.281 -				colorS2 = *(bP + 2);
  44.282 -
  44.283 -				color1	= *(bP + Nextline - 1);
  44.284 -				color2	= *(bP + Nextline);
  44.285 -				color3	= *(bP + Nextline + 1);
  44.286 -				colorS1 = *(bP + Nextline + 2);
  44.287 -
  44.288 -				colorA0 = *(bP + Nextline + Nextline - 1);
  44.289 -				colorA1 = *(bP + Nextline + Nextline);
  44.290 -				colorA2 = *(bP + Nextline + Nextline + 1);
  44.291 -				colorA3 = *(bP + Nextline + Nextline + 2);
  44.292 -
  44.293 -				//--------------------------------------
  44.294 -				if (color2 == color6 && color5 != color3)
  44.295 -				{
  44.296 -					product2b = product1b = color2;
  44.297 -				}
  44.298 -				else if (color5 == color3 && color2 != color6)
  44.299 -				{
  44.300 -					product2b = product1b = color5;
  44.301 -				}
  44.302 -				else if (color5 == color3 && color2 == color6)
  44.303 -				{
  44.304 -					register int r = 0;
  44.305 -
  44.306 -					r += GetResult(color6, color5, color1, colorA1);
  44.307 -					r += GetResult(color6, color5, color4, colorB1);
  44.308 -					r += GetResult(color6, color5, colorA2, colorS1);
  44.309 -					r += GetResult(color6, color5, colorB2, colorS2);
  44.310 -
  44.311 -					if (r > 0)
  44.312 -						product2b = product1b = color6;
  44.313 -					else if (r < 0)
  44.314 -						product2b = product1b = color5;
  44.315 -					else
  44.316 -					{
  44.317 -						product2b = product1b = INTERPOLATE(color5, color6);
  44.318 -					}
  44.319 -				}
  44.320 -				else
  44.321 -				{
  44.322 -					if (color6 == color3 && color3 == colorA1
  44.323 -					    && color2 != colorA2 && color3 != colorA0)
  44.324 -						product2b =
  44.325 -						    Q_INTERPOLATE(color3, color3, color3, color2);
  44.326 -					else if (color5 == color2 && color2 == colorA2
  44.327 -					         && colorA1 != color3 && color2 != colorA3)
  44.328 -						product2b =
  44.329 -						    Q_INTERPOLATE(color2, color2, color2, color3);
  44.330 -					else
  44.331 -						product2b = INTERPOLATE(color2, color3);
  44.332 -
  44.333 -					if (color6 == color3 && color6 == colorB1
  44.334 -					    && color5 != colorB2 && color6 != colorB0)
  44.335 -						product1b =
  44.336 -						    Q_INTERPOLATE(color6, color6, color6, color5);
  44.337 -					else if (color5 == color2 && color5 == colorB2
  44.338 -					         && colorB1 != color6 && color5 != colorB3)
  44.339 -						product1b =
  44.340 -						    Q_INTERPOLATE(color6, color5, color5, color5);
  44.341 -					else
  44.342 -						product1b = INTERPOLATE(color5, color6);
  44.343 -				}
  44.344 -
  44.345 -				if (color5 == color3 && color2 != color6 && color4 == color5
  44.346 -				    && color5 != colorA2)
  44.347 -					product2a = INTERPOLATE(color2, color5);
  44.348 -				else
  44.349 -					if (color5 == color1 && color6 == color5
  44.350 -					    && color4 != color2 && color5 != colorA0)
  44.351 -						product2a = INTERPOLATE(color2, color5);
  44.352 -					else
  44.353 -						product2a = color2;
  44.354 -
  44.355 -				if (color2 == color6 && color5 != color3 && color1 == color2
  44.356 -				    && color2 != colorB2)
  44.357 -					product1a = INTERPOLATE(color2, color5);
  44.358 -				else
  44.359 -					if (color4 == color2 && color3 == color2
  44.360 -					    && color1 != color5 && color2 != colorB0)
  44.361 -						product1a = INTERPOLATE(color2, color5);
  44.362 -					else
  44.363 -						product1a = color5;
  44.364 -
  44.365 -#ifdef WORDS_BIGENDIAN
  44.366 -				product1a = (product1a << 16) | product1b;
  44.367 -				product2a = (product2a << 16) | product2b;
  44.368 -#else
  44.369 -				product1a = product1a | (product1b << 16);
  44.370 -				product2a = product2a | (product2b << 16);
  44.371 -#endif
  44.372 -
  44.373 -				*((u32 *) dP) = product1a;
  44.374 -				*((u32 *) (dP + dstPitch)) = product2a;
  44.375 -
  44.376 -				bP += inc_bP;
  44.377 -				dP += sizeof(u32);
  44.378 -			}                   // end of for ( finish= width etc..)
  44.379 -
  44.380 -			srcPtr	 += srcPitch;
  44.381 -			dstPtr	 += dstPitch << 1;
  44.382 -			deltaPtr += srcPitch;
  44.383 -		}               // endof: for (; height; height--)
  44.384 -	}
  44.385 -}
  44.386 -
  44.387 -void Super2xSaI32(u8 *srcPtr, u32 srcPitch,
  44.388 -                  u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch,
  44.389 -                  int width, int height)
  44.390 -{
  44.391 -	u32 *bP;
  44.392 -	u32 *dP;
  44.393 -	u32	 inc_bP;
  44.394 -	u32	 Nextline = srcPitch >> 2;
  44.395 -	inc_bP = 1;
  44.396 -
  44.397 -	for (; height; height--)
  44.398 -	{
  44.399 -		bP = (u32 *) srcPtr;
  44.400 -		dP = (u32 *) dstPtr;
  44.401 -
  44.402 -		for (u32 finish = width; finish; finish -= inc_bP)
  44.403 -		{
  44.404 -			u32 color4, color5, color6;
  44.405 -			u32 color1, color2, color3;
  44.406 -			u32 colorA0, colorA1, colorA2, colorA3,
  44.407 -			    colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
  44.408 -			u32 product1a, product1b, product2a, product2b;
  44.409 -
  44.410 -			//---------------------------------------    B1 B2
  44.411 -			//                                         4  5  6 S2
  44.412 -			//                                         1  2  3 S1
  44.413 -			//                                           A1 A2
  44.414 -
  44.415 -			colorB0 = *(bP - Nextline - 1);
  44.416 -			colorB1 = *(bP - Nextline);
  44.417 -			colorB2 = *(bP - Nextline + 1);
  44.418 -			colorB3 = *(bP - Nextline + 2);
  44.419 -
  44.420 -			color4	= *(bP - 1);
  44.421 -			color5	= *(bP);
  44.422 -			color6	= *(bP + 1);
  44.423 -			colorS2 = *(bP + 2);
  44.424 -
  44.425 -			color1	= *(bP + Nextline - 1);
  44.426 -			color2	= *(bP + Nextline);
  44.427 -			color3	= *(bP + Nextline + 1);
  44.428 -			colorS1 = *(bP + Nextline + 2);
  44.429 -
  44.430 -			colorA0 = *(bP + Nextline + Nextline - 1);
  44.431 -			colorA1 = *(bP + Nextline + Nextline);
  44.432 -			colorA2 = *(bP + Nextline + Nextline + 1);
  44.433 -			colorA3 = *(bP + Nextline + Nextline + 2);
  44.434 -
  44.435 -			//--------------------------------------
  44.436 -			if (color2 == color6 && color5 != color3)
  44.437 -			{
  44.438 -				product2b = product1b = color2;
  44.439 -			}
  44.440 -			else if (color5 == color3 && color2 != color6)
  44.441 -			{
  44.442 -				product2b = product1b = color5;
  44.443 -			}
  44.444 -			else if (color5 == color3 && color2 == color6)
  44.445 -			{
  44.446 -				register int r = 0;
  44.447 -
  44.448 -				r += GetResult(color6, color5, color1, colorA1);
  44.449 -				r += GetResult(color6, color5, color4, colorB1);
  44.450 -				r += GetResult(color6, color5, colorA2, colorS1);
  44.451 -				r += GetResult(color6, color5, colorB2, colorS2);
  44.452 -
  44.453 -				if (r > 0)
  44.454 -					product2b = product1b = color6;
  44.455 -				else if (r < 0)
  44.456 -					product2b = product1b = color5;
  44.457 -				else
  44.458 -				{
  44.459 -					product2b = product1b = INTERPOLATE(color5, color6);
  44.460 -				}
  44.461 -			}
  44.462 -			else
  44.463 -			{
  44.464 -				if (color6 == color3 && color3 == colorA1
  44.465 -				    && color2 != colorA2 && color3 != colorA0)
  44.466 -					product2b =
  44.467 -					    Q_INTERPOLATE(color3, color3, color3, color2);
  44.468 -				else if (color5 == color2 && color2 == colorA2
  44.469 -				         && colorA1 != color3 && color2 != colorA3)
  44.470 -					product2b =
  44.471 -					    Q_INTERPOLATE(color2, color2, color2, color3);
  44.472 -				else
  44.473 -					product2b = INTERPOLATE(color2, color3);
  44.474 -
  44.475 -				if (color6 == color3 && color6 == colorB1
  44.476 -				    && color5 != colorB2 && color6 != colorB0)
  44.477 -					product1b =
  44.478 -					    Q_INTERPOLATE(color6, color6, color6, color5);
  44.479 -				else if (color5 == color2 && color5 == colorB2
  44.480 -				         && colorB1 != color6 && color5 != colorB3)
  44.481 -					product1b =
  44.482 -					    Q_INTERPOLATE(color6, color5, color5, color5);
  44.483 -				else
  44.484 -					product1b = INTERPOLATE(color5, color6);
  44.485 -			}
  44.486 -
  44.487 -			if (color5 == color3 && color2 != color6 && color4 == color5
  44.488 -			    && color5 != colorA2)
  44.489 -				product2a = INTERPOLATE(color2, color5);
  44.490 -			else
  44.491 -				if (color5 == color1 && color6 == color5
  44.492 -				    && color4 != color2 && color5 != colorA0)
  44.493 -					product2a = INTERPOLATE(color2, color5);
  44.494 -				else
  44.495 -					product2a = color2;
  44.496 -
  44.497 -			if (color2 == color6 && color5 != color3 && color1 == color2
  44.498 -			    && color2 != colorB2)
  44.499 -				product1a = INTERPOLATE(color2, color5);
  44.500 -			else
  44.501 -				if (color4 == color2 && color3 == color2
  44.502 -				    && color1 != color5 && color2 != colorB0)
  44.503 -					product1a = INTERPOLATE(color2, color5);
  44.504 -				else
  44.505 -					product1a = color5;
  44.506 -			*(dP)	  = product1a;
  44.507 -			*(dP + 1) = product1b;
  44.508 -			*(dP + (dstPitch >> 2))		= product2a;
  44.509 -			*(dP + (dstPitch >> 2) + 1) = product2b;
  44.510 -
  44.511 -			bP += inc_bP;
  44.512 -			dP += 2;
  44.513 -		}                   // end of for ( finish= width etc..)
  44.514 -
  44.515 -		srcPtr += srcPitch;
  44.516 -		dstPtr += dstPitch << 1;
  44.517 -		//        deltaPtr += srcPitch;
  44.518 -	}               // endof: for (; height; height--)
  44.519 -}
  44.520 -
  44.521 -void SuperEagle(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
  44.522 -                u8 *dstPtr, u32 dstPitch, int width, int height)
  44.523 -{
  44.524 -	u8 * dP;
  44.525 -	u16 *bP;
  44.526 -	u16 *xP;
  44.527 -	u32	 inc_bP;
  44.528 -
  44.529 -#ifdef MMX
  44.530 -	if (cpu_mmx)
  44.531 -	{
  44.532 -		for (; height; height--)
  44.533 -		{
  44.534 -			_2xSaISuperEagleLine(srcPtr, deltaPtr, srcPitch, width,
  44.535 -			                     dstPtr, dstPitch);
  44.536 -			srcPtr	 += srcPitch;
  44.537 -			dstPtr	 += dstPitch * 2;
  44.538 -			deltaPtr += srcPitch;
  44.539 -		}
  44.540 -	}
  44.541 -	else
  44.542 -#endif
  44.543 -	{
  44.544 -		inc_bP = 1;
  44.545 -
  44.546 -		u32 Nextline = srcPitch >> 1;
  44.547 -
  44.548 -		for (; height; height--)
  44.549 -		{
  44.550 -			bP = (u16 *) srcPtr;
  44.551 -			xP = (u16 *) deltaPtr;
  44.552 -			dP = dstPtr;
  44.553 -			for (u32 finish = width; finish; finish -= inc_bP)
  44.554 -			{
  44.555 -				u32 color4, color5, color6;
  44.556 -				u32 color1, color2, color3;
  44.557 -				u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
  44.558 -				u32 product1a, product1b, product2a, product2b;
  44.559 -
  44.560 -				colorB1 = *(bP - Nextline);
  44.561 -				colorB2 = *(bP - Nextline + 1);
  44.562 -
  44.563 -				color4	= *(bP - 1);
  44.564 -				color5	= *(bP);
  44.565 -				color6	= *(bP + 1);
  44.566 -				colorS2 = *(bP + 2);
  44.567 -
  44.568 -				color1	= *(bP + Nextline - 1);
  44.569 -				color2	= *(bP + Nextline);
  44.570 -				color3	= *(bP + Nextline + 1);
  44.571 -				colorS1 = *(bP + Nextline + 2);
  44.572 -
  44.573 -				colorA1 = *(bP + Nextline + Nextline);
  44.574 -				colorA2 = *(bP + Nextline + Nextline + 1);
  44.575 -
  44.576 -				// --------------------------------------
  44.577 -				if (color2 == color6 && color5 != color3)
  44.578 -				{
  44.579 -					product1b = product2a = color2;
  44.580 -					if ((color1 == color2) || (color6 == colorB2))
  44.581 -					{
  44.582 -						product1a = INTERPOLATE(color2, color5);
  44.583 -						product1a = INTERPOLATE(color2, product1a);
  44.584 -						//                       product1a = color2;
  44.585 -					}
  44.586 -					else
  44.587 -					{
  44.588 -						product1a = INTERPOLATE(color5, color6);
  44.589 -					}
  44.590 -
  44.591 -					if ((color6 == colorS2) || (color2 == colorA1))
  44.592 -					{
  44.593 -						product2b = INTERPOLATE(color2, color3);
  44.594 -						product2b = INTERPOLATE(color2, product2b);
  44.595 -						//                       product2b = color2;
  44.596 -					}
  44.597 -					else
  44.598 -					{
  44.599 -						product2b = INTERPOLATE(color2, color3);
  44.600 -					}
  44.601 -				}
  44.602 -				else if (color5 == color3 && color2 != color6)
  44.603 -				{
  44.604 -					product2b = product1a = color5;
  44.605 -
  44.606 -					if ((colorB1 == color5) || (color3 == colorS1))
  44.607 -					{
  44.608 -						product1b = INTERPOLATE(color5, color6);
  44.609 -						product1b = INTERPOLATE(color5, product1b);
  44.610 -						//                       product1b = color5;
  44.611 -					}
  44.612 -					else
  44.613 -					{
  44.614 -						product1b = INTERPOLATE(color5, color6);
  44.615 -					}
  44.616 -
  44.617 -					if ((color3 == colorA2) || (color4 == color5))
  44.618 -					{
  44.619 -						product2a = INTERPOLATE(color5, color2);
  44.620 -						product2a = INTERPOLATE(color5, product2a);
  44.621 -						//                       product2a = color5;
  44.622 -					}
  44.623 -					else
  44.624 -					{
  44.625 -						product2a = INTERPOLATE(color2, color3);
  44.626 -					}
  44.627 -				}
  44.628 -				else if (color5 == color3 && color2 == color6)
  44.629 -				{
  44.630 -					register int r = 0;
  44.631 -
  44.632 -					r += GetResult(color6, color5, color1, colorA1);
  44.633 -					r += GetResult(color6, color5, color4, colorB1);
  44.634 -					r += GetResult(color6, color5, colorA2, colorS1);
  44.635 -					r += GetResult(color6, color5, colorB2, colorS2);
  44.636 -
  44.637 -					if (r > 0)
  44.638 -					{
  44.639 -						product1b = product2a = color2;
  44.640 -						product1a = product2b = INTERPOLATE(color5, color6);
  44.641 -					}
  44.642 -					else if (r < 0)
  44.643 -					{
  44.644 -						product2b = product1a = color5;
  44.645 -						product1b = product2a = INTERPOLATE(color5, color6);
  44.646 -					}
  44.647 -					else
  44.648 -					{
  44.649 -						product2b = product1a = color5;
  44.650 -						product1b = product2a = color2;
  44.651 -					}
  44.652 -				}
  44.653 -				else
  44.654 -				{
  44.655 -					product2b = product1a = INTERPOLATE(color2, color6);
  44.656 -					product2b =
  44.657 -					    Q_INTERPOLATE(color3, color3, color3, product2b);
  44.658 -					product1a =
  44.659 -					    Q_INTERPOLATE(color5, color5, color5, product1a);
  44.660 -
  44.661 -					product2a = product1b = INTERPOLATE(color5, color3);
  44.662 -					product2a =
  44.663 -					    Q_INTERPOLATE(color2, color2, color2, product2a);
  44.664 -					product1b =
  44.665 -					    Q_INTERPOLATE(color6, color6, color6, product1b);
  44.666 -
  44.667 -					//                    product1a = color5;
  44.668 -					//                    product1b = color6;
  44.669 -					//                    product2a = color2;
  44.670 -					//                    product2b = color3;
  44.671 -				}
  44.672 -#ifdef WORDS_BIGENDIAN
  44.673 -				product1a = (product1a << 16) | product1b;
  44.674 -				product2a = (product2a << 16) | product2b;
  44.675 -#else
  44.676 -				product1a = product1a | (product1b << 16);
  44.677 -				product2a = product2a | (product2b << 16);
  44.678 -#endif
  44.679 -
  44.680 -				*((u32 *) dP) = product1a;
  44.681 -				*((u32 *) (dP + dstPitch)) = product2a;
  44.682 -				*xP = color5;
  44.683 -
  44.684 -				bP += inc_bP;
  44.685 -				xP += inc_bP;
  44.686 -				dP += sizeof(u32);
  44.687 -			}           // end of for ( finish= width etc..)
  44.688 -
  44.689 -			srcPtr	 += srcPitch;
  44.690 -			dstPtr	 += dstPitch << 1;
  44.691 -			deltaPtr += srcPitch;
  44.692 -		}               // endof: for (height; height; height--)
  44.693 -	}
  44.694 -}
  44.695 -
  44.696 -void SuperEagle32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
  44.697 -                  u8 *dstPtr, u32 dstPitch, int width, int height)
  44.698 -{
  44.699 -	u32 *dP;
  44.700 -	u32 *bP;
  44.701 -	u32 *xP;
  44.702 -	u32	 inc_bP;
  44.703 -
  44.704 -	inc_bP = 1;
  44.705 -
  44.706 -	u32 Nextline = srcPitch >> 2;
  44.707 -
  44.708 -	for (; height; height--)
  44.709 -	{
  44.710 -		bP = (u32 *) srcPtr;
  44.711 -		xP = (u32 *) deltaPtr;
  44.712 -		dP = (u32 *)dstPtr;
  44.713 -		for (u32 finish = width; finish; finish -= inc_bP)
  44.714 -		{
  44.715 -			u32 color4, color5, color6;
  44.716 -			u32 color1, color2, color3;
  44.717 -			u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
  44.718 -			u32 product1a, product1b, product2a, product2b;
  44.719 -
  44.720 -			colorB1 = *(bP - Nextline);
  44.721 -			colorB2 = *(bP - Nextline + 1);
  44.722 -
  44.723 -			color4	= *(bP - 1);
  44.724 -			color5	= *(bP);
  44.725 -			color6	= *(bP + 1);
  44.726 -			colorS2 = *(bP + 2);
  44.727 -
  44.728 -			color1	= *(bP + Nextline - 1);
  44.729 -			color2	= *(bP + Nextline);
  44.730 -			color3	= *(bP + Nextline + 1);
  44.731 -			colorS1 = *(bP + Nextline + 2);
  44.732 -
  44.733 -			colorA1 = *(bP + Nextline + Nextline);
  44.734 -			colorA2 = *(bP + Nextline + Nextline + 1);
  44.735 -
  44.736 -			// --------------------------------------
  44.737 -			if (color2 == color6 && color5 != color3)
  44.738 -			{
  44.739 -				product1b = product2a = color2;
  44.740 -				if ((color1 == color2) || (color6 == colorB2))
  44.741 -				{
  44.742 -					product1a = INTERPOLATE(color2, color5);
  44.743 -					product1a = INTERPOLATE(color2, product1a);
  44.744 -					//                       product1a = color2;
  44.745 -				}
  44.746 -				else
  44.747 -				{
  44.748 -					product1a = INTERPOLATE(color5, color6);
  44.749 -				}
  44.750 -
  44.751 -				if ((color6 == colorS2) || (color2 == colorA1))
  44.752 -				{
  44.753 -					product2b = INTERPOLATE(color2, color3);
  44.754 -					product2b = INTERPOLATE(color2, product2b);
  44.755 -					//                       product2b = color2;
  44.756 -				}
  44.757 -				else
  44.758 -				{
  44.759 -					product2b = INTERPOLATE(color2, color3);
  44.760 -				}
  44.761 -			}
  44.762 -			else if (color5 == color3 && color2 != color6)
  44.763 -			{
  44.764 -				product2b = product1a = color5;
  44.765 -
  44.766 -				if ((colorB1 == color5) || (color3 == colorS1))
  44.767 -				{
  44.768 -					product1b = INTERPOLATE(color5, color6);
  44.769 -					product1b = INTERPOLATE(color5, product1b);
  44.770 -					//                       product1b = color5;
  44.771 -				}
  44.772 -				else
  44.773 -				{
  44.774 -					product1b = INTERPOLATE(color5, color6);
  44.775 -				}
  44.776 -
  44.777 -				if ((color3 == colorA2) || (color4 == color5))
  44.778 -				{
  44.779 -					product2a = INTERPOLATE(color5, color2);
  44.780 -					product2a = INTERPOLATE(color5, product2a);
  44.781 -					//                       product2a = color5;
  44.782 -				}
  44.783 -				else
  44.784 -				{
  44.785 -					product2a = INTERPOLATE(color2, color3);
  44.786 -				}
  44.787 -			}
  44.788 -			else if (color5 == color3 && color2 == color6)
  44.789 -			{
  44.790 -				register int r = 0;
  44.791 -
  44.792 -				r += GetResult(color6, color5, color1, colorA1);
  44.793 -				r += GetResult(color6, color5, color4, colorB1);
  44.794 -				r += GetResult(color6, color5, colorA2, colorS1);
  44.795 -				r += GetResult(color6, color5, colorB2, colorS2);
  44.796 -
  44.797 -				if (r > 0)
  44.798 -				{
  44.799 -					product1b = product2a = color2;
  44.800 -					product1a = product2b = INTERPOLATE(color5, color6);
  44.801 -				}
  44.802 -				else if (r < 0)
  44.803 -				{
  44.804 -					product2b = product1a = color5;
  44.805 -					product1b = product2a = INTERPOLATE(color5, color6);
  44.806 -				}
  44.807 -				else
  44.808 -				{
  44.809 -					product2b = product1a = color5;
  44.810 -					product1b = product2a = color2;
  44.811 -				}
  44.812 -			}
  44.813 -			else
  44.814 -			{
  44.815 -				product2b = product1a = INTERPOLATE(color2, color6);
  44.816 -				product2b =
  44.817 -				    Q_INTERPOLATE(color3, color3, color3, product2b);
  44.818 -				product1a =
  44.819 -				    Q_INTERPOLATE(color5, color5, color5, product1a);
  44.820 -
  44.821 -				product2a = product1b = INTERPOLATE(color5, color3);
  44.822 -				product2a =
  44.823 -				    Q_INTERPOLATE(color2, color2, color2, product2a);
  44.824 -				product1b =
  44.825 -				    Q_INTERPOLATE(color6, color6, color6, product1b);
  44.826 -
  44.827 -				//                    product1a = color5;
  44.828 -				//                    product1b = color6;
  44.829 -				//                    product2a = color2;
  44.830 -				//                    product2b = color3;
  44.831 -			}
  44.832 -			*(dP)	  = product1a;
  44.833 -			*(dP + 1) = product1b;
  44.834 -			*(dP + (dstPitch >> 2))		= product2a;
  44.835 -			*(dP + (dstPitch >> 2) + 1) = product2b;
  44.836 -			*xP = color5;
  44.837 -
  44.838 -			bP += inc_bP;
  44.839 -			xP += inc_bP;
  44.840 -			dP += 2;
  44.841 -		}             // end of for ( finish= width etc..)
  44.842 -
  44.843 -		srcPtr	 += srcPitch;
  44.844 -		dstPtr	 += dstPitch << 1;
  44.845 -		deltaPtr += srcPitch;
  44.846 -	}                 // endof: for (height; height; height--)
  44.847 -}
  44.848 -
  44.849 -void _2xSaI(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
  44.850 -            u8 *dstPtr, u32 dstPitch, int width, int height)
  44.851 -{
  44.852 -	u8 * dP;
  44.853 -	u16 *bP;
  44.854 -	u32	 inc_bP;
  44.855 -
  44.856 -#ifdef MMX
  44.857 -	if (cpu_mmx)
  44.858 -	{
  44.859 -		for (; height; height -= 1)
  44.860 -		{
  44.861 -			_2xSaILine(srcPtr, deltaPtr, srcPitch, width, dstPtr, dstPitch);
  44.862 -			srcPtr	 += srcPitch;
  44.863 -			dstPtr	 += dstPitch * 2;
  44.864 -			deltaPtr += srcPitch;
  44.865 -		}
  44.866 -	}
  44.867 -	else
  44.868 -#endif
  44.869 -	{
  44.870 -		inc_bP = 1;
  44.871 -
  44.872 -		u32 Nextline = srcPitch >> 1;
  44.873 -
  44.874 -		for (; height; height--)
  44.875 -		{
  44.876 -			bP = (u16 *) srcPtr;
  44.877 -			dP = dstPtr;
  44.878 -
  44.879 -			for (u32 finish = width; finish; finish -= inc_bP)
  44.880 -			{
  44.881 -				register u32 colorA, colorB;
  44.882 -				u32 colorC, colorD,
  44.883 -				    colorE, colorF, colorG, colorH,
  44.884 -				    colorI, colorJ, colorK, colorL,
  44.885 -
  44.886 -				    colorM, colorN, colorO, colorP;
  44.887 -				u32 product, product1, product2;
  44.888 -
  44.889 -				//---------------------------------------
  44.890 -				// Map of the pixels:                    I|E F|J
  44.891 -				//                                       G|A B|K
  44.892 -				//                                       H|C D|L
  44.893 -				//                                       M|N O|P
  44.894 -				colorI = *(bP - Nextline - 1);
  44.895 -				colorE = *(bP - Nextline);
  44.896 -				colorF = *(bP - Nextline + 1);
  44.897 -				colorJ = *(bP - Nextline + 2);
  44.898 -
  44.899 -				colorG = *(bP - 1);
  44.900 -				colorA = *(bP);
  44.901 -				colorB = *(bP + 1);
  44.902 -				colorK = *(bP + 2);
  44.903 -
  44.904 -				colorH = *(bP + Nextline - 1);
  44.905 -				colorC = *(bP + Nextline);
  44.906 -				colorD = *(bP + Nextline + 1);
  44.907 -				colorL = *(bP + Nextline + 2);
  44.908 -
  44.909 -				colorM = *(bP + Nextline + Nextline - 1);
  44.910 -				colorN = *(bP + Nextline + Nextline);
  44.911 -				colorO = *(bP + Nextline + Nextline + 1);
  44.912 -				colorP = *(bP + Nextline + Nextline + 2);
  44.913 -
  44.914 -				if ((colorA == colorD) && (colorB != colorC))
  44.915 -				{
  44.916 -					if (((colorA == colorE) && (colorB == colorL)) ||
  44.917 -					    ((colorA == colorC) && (colorA == colorF)
  44.918 -					     && (colorB != colorE) && (colorB == colorJ)))
  44.919 -					{
  44.920 -						product = colorA;
  44.921 -					}
  44.922 -					else
  44.923 -					{
  44.924 -						product = INTERPOLATE(colorA, colorB);
  44.925 -					}
  44.926 -
  44.927 -					if (((colorA == colorG) && (colorC == colorO)) ||
  44.928 -					    ((colorA == colorB) && (colorA == colorH)
  44.929 -					     && (colorG != colorC) && (colorC == colorM)))
  44.930 -					{
  44.931 -						product1 = colorA;
  44.932 -					}
  44.933 -					else
  44.934 -					{
  44.935 -						product1 = INTERPOLATE(colorA, colorC);
  44.936 -					}
  44.937 -					product2 = colorA;
  44.938 -				}
  44.939 -				else if ((colorB == colorC) && (colorA != colorD))
  44.940 -				{
  44.941 -					if (((colorB == colorF) && (colorA == colorH)) ||
  44.942 -					    ((colorB == colorE) && (colorB == colorD)
  44.943 -					     && (colorA != colorF) && (colorA == colorI)))
  44.944 -					{
  44.945 -						product = colorB;
  44.946 -					}
  44.947 -					else
  44.948 -					{
  44.949 -						product = INTERPOLATE(colorA, colorB);
  44.950 -					}
  44.951 -
  44.952 -					if (((colorC == colorH) && (colorA == colorF)) ||
  44.953 -					    ((colorC == colorG) && (colorC == colorD)
  44.954 -					     && (colorA != colorH) && (colorA == colorI)))
  44.955 -					{
  44.956 -						product1 = colorC;
  44.957 -					}
  44.958 -					else
  44.959 -					{
  44.960 -						product1 = INTERPOLATE(colorA, colorC);
  44.961 -					}
  44.962 -					product2 = colorB;
  44.963 -				}
  44.964 -				else if ((colorA == colorD) && (colorB == colorC))
  44.965 -				{
  44.966 -					if (colorA == colorB)
  44.967 -					{
  44.968 -						product	 = colorA;
  44.969 -						product1 = colorA;
  44.970 -						product2 = colorA;
  44.971 -					}
  44.972 -					else
  44.973 -					{
  44.974 -						register int r = 0;
  44.975 -
  44.976 -						product1 = INTERPOLATE(colorA, colorC);
  44.977 -						product	 = INTERPOLATE(colorA, colorB);
  44.978 -
  44.979 -						r +=
  44.980 -						    GetResult1(colorA, colorB, colorG, colorE,
  44.981 -						               colorI);
  44.982 -						r +=
  44.983 -						    GetResult2(colorB, colorA, colorK, colorF,
  44.984 -						               colorJ);
  44.985 -						r +=
  44.986 -						    GetResult2(colorB, colorA, colorH, colorN,
  44.987 -						               colorM);
  44.988 -						r +=
  44.989 -						    GetResult1(colorA, colorB, colorL, colorO,
  44.990 -						               colorP);
  44.991 -
  44.992 -						if (r > 0)
  44.993 -							product2 = colorA;
  44.994 -						else if (r < 0)
  44.995 -							product2 = colorB;
  44.996 -						else
  44.997 -						{
  44.998 -							product2 =
  44.999 -							    Q_INTERPOLATE(colorA, colorB, colorC,
 44.1000 -							                  colorD);
 44.1001 -						}
 44.1002 -					}
 44.1003 -				}
 44.1004 -				else
 44.1005 -				{
 44.1006 -					product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD);
 44.1007 -
 44.1008 -					if ((colorA == colorC) && (colorA == colorF)
 44.1009 -					    && (colorB != colorE) && (colorB == colorJ))
 44.1010 -					{
 44.1011 -						product = colorA;
 44.1012 -					}
 44.1013 -					else if ((colorB == colorE) && (colorB == colorD)
 44.1014 -					         && (colorA != colorF) && (colorA == colorI))
 44.1015 -					{
 44.1016 -						product = colorB;
 44.1017 -					}
 44.1018 -					else
 44.1019 -					{
 44.1020 -						product = INTERPOLATE(colorA, colorB);
 44.1021 -					}
 44.1022 -
 44.1023 -					if ((colorA == colorB) && (colorA == colorH)
 44.1024 -					    && (colorG != colorC) && (colorC == colorM))
 44.1025 -					{
 44.1026 -						product1 = colorA;
 44.1027 -					}
 44.1028 -					else if ((colorC == colorG) && (colorC == colorD)
 44.1029 -					         && (colorA != colorH) && (colorA == colorI))
 44.1030 -					{
 44.1031 -						product1 = colorC;
 44.1032 -					}
 44.1033 -					else
 44.1034 -					{
 44.1035 -						product1 = INTERPOLATE(colorA, colorC);
 44.1036 -					}
 44.1037 -				}
 44.1038 -
 44.1039 -#ifdef WORDS_BIGENDIAN
 44.1040 -				product	 = (colorA << 16) | product;
 44.1041 -				product1 = (product1 << 16) | product2;
 44.1042 -#else
 44.1043 -				product	 = colorA | (product << 16);
 44.1044 -				product1 = product1 | (product2 << 16);
 44.1045 -#endif
 44.1046 -				*((s32 *) dP) = product;
 44.1047 -				*((u32 *) (dP + dstPitch)) = product1;
 44.1048 -
 44.1049 -				bP += inc_bP;
 44.1050 -				dP += sizeof(u32);
 44.1051 -			}           // end of for ( finish= width etc..)
 44.1052 -
 44.1053 -			srcPtr	 += srcPitch;
 44.1054 -			dstPtr	 += dstPitch << 1;
 44.1055 -			deltaPtr += srcPitch;
 44.1056 -		}               // endof: for (height; height; height--)
 44.1057 -	}
 44.1058 -}
 44.1059 -
 44.1060 -void _2xSaI32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
 44.1061 -              u8 *dstPtr, u32 dstPitch, int width, int height)
 44.1062 -{
 44.1063 -	u32 *dP;
 44.1064 -	u32 *bP;
 44.1065 -	u32	 inc_bP = 1;
 44.1066 -
 44.1067 -	u32 Nextline = srcPitch >> 2;
 44.1068 -
 44.1069 -	for (; height; height--)
 44.1070 -	{
 44.1071 -		bP = (u32 *) srcPtr;
 44.1072 -		dP = (u32 *) dstPtr;
 44.1073 -
 44.1074 -		for (u32 finish = width; finish; finish -= inc_bP)
 44.1075 -		{
 44.1076 -			register u32 colorA, colorB;
 44.1077 -			u32 colorC, colorD,
 44.1078 -			    colorE, colorF, colorG, colorH,
 44.1079 -			    colorI, colorJ, colorK, colorL,
 44.1080 -
 44.1081 -			    colorM, colorN, colorO, colorP;
 44.1082 -			u32 product, product1, product2;
 44.1083 -
 44.1084 -			//---------------------------------------
 44.1085 -			// Map of the pixels:                    I|E F|J
 44.1086 -			//                                       G|A B|K
 44.1087 -			//                                       H|C D|L
 44.1088 -			//                                       M|N O|P
 44.1089 -			colorI = *(bP - Nextline - 1);
 44.1090 -			colorE = *(bP - Nextline);
 44.1091 -			colorF = *(bP - Nextline + 1);
 44.1092 -			colorJ = *(bP - Nextline + 2);
 44.1093 -
 44.1094 -			colorG = *(bP - 1);
 44.1095 -			colorA = *(bP);
 44.1096 -			colorB = *(bP + 1);
 44.1097 -			colorK = *(bP + 2);
 44.1098 -
 44.1099 -			colorH = *(bP + Nextline - 1);
 44.1100 -			colorC = *(bP + Nextline);
 44.1101 -			colorD = *(bP + Nextline + 1);
 44.1102 -			colorL = *(bP + Nextline + 2);
 44.1103 -
 44.1104 -			colorM = *(bP + Nextline + Nextline - 1);
 44.1105 -			colorN = *(bP + Nextline + Nextline);
 44.1106 -			colorO = *(bP + Nextline + Nextline + 1);
 44.1107 -			colorP = *(bP + Nextline + Nextline + 2);
 44.1108 -
 44.1109 -			if ((colorA == colorD) && (colorB != colorC))
 44.1110 -			{
 44.1111 -				if (((colorA == colorE) && (colorB == colorL)) ||
 44.1112 -				    ((colorA == colorC) && (colorA == colorF)
 44.1113 -				     && (colorB != colorE) && (colorB == colorJ)))
 44.1114 -				{
 44.1115 -					product = colorA;
 44.1116 -				}
 44.1117 -				else
 44.1118 -				{
 44.1119 -					product = INTERPOLATE(colorA, colorB);
 44.1120 -				}
 44.1121 -
 44.1122 -				if (((colorA == colorG) && (colorC == colorO)) ||
 44.1123 -				    ((colorA == colorB) && (colorA == colorH)
 44.1124 -				     && (colorG != colorC) && (colorC == colorM)))
 44.1125 -				{
 44.1126 -					product1 = colorA;
 44.1127 -				}
 44.1128 -				else
 44.1129 -				{
 44.1130 -					product1 = INTERPOLATE(colorA, colorC);
 44.1131 -				}
 44.1132 -				product2 = colorA;
 44.1133 -			}
 44.1134 -			else if ((colorB == colorC) && (colorA != colorD))
 44.1135 -			{
 44.1136 -				if (((colorB == colorF) && (colorA == colorH)) ||
 44.1137 -				    ((colorB == colorE) && (colorB == colorD)
 44.1138 -				     && (colorA != colorF) && (colorA == colorI)))
 44.1139 -				{
 44.1140 -					product = colorB;
 44.1141 -				}
 44.1142 -				else
 44.1143 -				{
 44.1144 -					product = INTERPOLATE(colorA, colorB);
 44.1145 -				}
 44.1146 -
 44.1147 -				if (((colorC == colorH) && (colorA == colorF)) ||
 44.1148 -				    ((colorC == colorG) && (colorC == colorD)
 44.1149 -				     && (colorA != colorH) && (colorA == colorI)))
 44.1150 -				{
 44.1151 -					product1 = colorC;
 44.1152 -				}
 44.1153 -				else
 44.1154 -				{
 44.1155 -					product1 = INTERPOLATE(colorA, colorC);
 44.1156 -				}
 44.1157 -				product2 = colorB;
 44.1158 -			}
 44.1159 -			else if ((colorA == colorD) && (colorB == colorC))
 44.1160 -			{
 44.1161 -				if (colorA == colorB)
 44.1162 -				{
 44.1163 -					product	 = colorA;
 44.1164 -					product1 = colorA;
 44.1165 -					product2 = colorA;
 44.1166 -				}
 44.1167 -				else
 44.1168 -				{
 44.1169 -					register int r = 0;
 44.1170 -
 44.1171 -					product1 = INTERPOLATE(colorA, colorC);
 44.1172 -					product	 = INTERPOLATE(colorA, colorB);
 44.1173 -
 44.1174 -					r +=
 44.1175 -					    GetResult1(colorA, colorB, colorG, colorE,
 44.1176 -					               colorI);
 44.1177 -					r +=
 44.1178 -					    GetResult2(colorB, colorA, colorK, colorF,
 44.1179 -					               colorJ);
 44.1180 -					r +=
 44.1181 -					    GetResult2(colorB, colorA, colorH, colorN,
 44.1182 -					               colorM);
 44.1183 -					r +=
 44.1184 -					    GetResult1(colorA, colorB, colorL, colorO,
 44.1185 -					               colorP);
 44.1186 -
 44.1187 -					if (r > 0)
 44.1188 -						product2 = colorA;
 44.1189 -					else if (r < 0)
 44.1190 -						product2 = colorB;
 44.1191 -					else
 44.1192 -					{
 44.1193 -						product2 =
 44.1194 -						    Q_INTERPOLATE(colorA, colorB, colorC,
 44.1195 -						                  colorD);
 44.1196 -					}
 44.1197 -				}
 44.1198 -			}
 44.1199 -			else
 44.1200 -			{
 44.1201 -				product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD);
 44.1202 -
 44.1203 -				if ((colorA == colorC) && (colorA == colorF)
 44.1204 -				    && (colorB != colorE) && (colorB == colorJ))
 44.1205 -				{
 44.1206 -					product = colorA;
 44.1207 -				}
 44.1208 -				else if ((colorB == colorE) && (colorB == colorD)
 44.1209 -				         && (colorA != colorF) && (colorA == colorI))
 44.1210 -				{
 44.1211 -					product = colorB;
 44.1212 -				}
 44.1213 -				else
 44.1214 -				{
 44.1215 -					product = INTERPOLATE(colorA, colorB);
 44.1216 -				}
 44.1217 -
 44.1218 -				if ((colorA == colorB) && (colorA == colorH)
 44.1219 -				    && (colorG != colorC) && (colorC == colorM))
 44.1220 -				{
 44.1221 -					product1 = colorA;
 44.1222 -				}
 44.1223 -				else if ((colorC == colorG) && (colorC == colorD)
 44.1224 -				         && (colorA != colorH) && (colorA == colorI))
 44.1225 -				{
 44.1226 -					product1 = colorC;
 44.1227 -				}
 44.1228 -				else
 44.1229 -				{
 44.1230 -					product1 = INTERPOLATE(colorA, colorC);
 44.1231 -				}
 44.1232 -			}
 44.1233 -			*(dP)	  = colorA;
 44.1234 -			*(dP + 1) = product;
 44.1235 -			*(dP + (dstPitch >> 2))		= product1;
 44.1236 -			*(dP + (dstPitch >> 2) + 1) = product2;
 44.1237 -
 44.1238 -			bP += inc_bP;
 44.1239 -			dP += 2;
 44.1240 -		}             // end of for ( finish= width etc..)
 44.1241 -
 44.1242 -		srcPtr += srcPitch;
 44.1243 -		dstPtr += dstPitch << 1;
 44.1244 -		//    deltaPtr += srcPitch;
 44.1245 -	}                 // endof: for (height; height; height--)
 44.1246 -}
 44.1247 -
 44.1248 -static u32 Bilinear(u32 A, u32 B, u32 x)
 44.1249 -{
 44.1250 -	unsigned long areaA, areaB;
 44.1251 -	unsigned long result;
 44.1252 -
 44.1253 -	if (A == B)
 44.1254 -		return A;
 44.1255 -
 44.1256 -	areaB = (x >> 11) & 0x1f;   // reduce 16 bit fraction to 5 bits
 44.1257 -	areaA = 0x20 - areaB;
 44.1258 -
 44.1259 -	A = (A & redblueMask) | ((A & greenMask) << 16);
 44.1260 -	B = (B & redblueMask) | ((B & greenMask) << 16);
 44.1261 -
 44.1262 -	result = ((areaA * A) + (areaB * B)) >> 5;
 44.1263 -
 44.1264 -	return (result & redblueMask) | ((result >> 16) & greenMask);
 44.1265 -}
 44.1266 -
 44.1267 -static u32 Bilinear4(u32 A, u32 B, u32 C, u32 D, u32 x,
 44.1268 -                     u32 y)
 44.1269 -{
 44.1270 -	unsigned long areaA, areaB, areaC, areaD;
 44.1271 -	unsigned long result, xy;
 44.1272 -
 44.1273 -	x  = (x >> 11) & 0x1f;
 44.1274 -	y  = (y >> 11) & 0x1f;
 44.1275 -	xy = (x * y) >> 5;
 44.1276 -
 44.1277 -	A = (A & redblueMask) | ((A & greenMask) << 16);
 44.1278 -	B = (B & redblueMask) | ((B & greenMask) << 16);
 44.1279 -	C = (C & redblueMask) | ((C & greenMask) << 16);
 44.1280 -	D = (D & redblueMask) | ((D & greenMask) << 16);
 44.1281 -
 44.1282 -	areaA = 0x20 + xy - x - y;
 44.1283 -	areaB = x - xy;
 44.1284 -	areaC = y - xy;
 44.1285 -	areaD = xy;
 44.1286 -
 44.1287 -	result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5;
 44.1288 -
 44.1289 -	return (result & redblueMask) | ((result >> 16) & greenMask);
 44.1290 -}
 44.1291 -
 44.1292 -void Scale_2xSaI(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
 44.1293 -                 u8 *dstPtr, u32 dstPitch,
 44.1294 -                 u32 dstWidth, u32 dstHeight, int width, int height)
 44.1295 -{
 44.1296 -	u8 * dP;
 44.1297 -	u16 *bP;
 44.1298 -
 44.1299 -	u32 w;
 44.1300 -	u32 h;
 44.1301 -	u32 dw;
 44.1302 -	u32 dh;
 44.1303 -	u32 hfinish;
 44.1304 -	u32 wfinish;
 44.1305 -
 44.1306 -	u32 Nextline = srcPitch >> 1;
 44.1307 -
 44.1308 -	wfinish = (width - 1) << 16; // convert to fixed point
 44.1309 -	dw		= wfinish / (dstWidth - 1);
 44.1310 -	hfinish = (height - 1) << 16; // convert to fixed point
 44.1311 -	dh		= hfinish / (dstHeight - 1);
 44.1312 -
 44.1313 -	for (h = 0; h < hfinish; h += dh)
 44.1314 -	{
 44.1315 -		u32 y1, y2;
 44.1316 -
 44.1317 -		y1 = h & 0xffff; // fraction part of fixed point
 44.1318 -		bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch));
 44.1319 -		dP = dstPtr;
 44.1320 -		y2 = 0x10000 - y1;
 44.1321 -
 44.1322 -		w = 0;
 44.1323 -
 44.1324 -		for (; w < wfinish; )
 44.1325 -		{
 44.1326 -			u32 A, B, C, D;
 44.1327 -			u32 E, F, G, H;
 44.1328 -			u32 I, J, K, L;
 44.1329 -			u32 x1, x2, a1, f1, f2;
 44.1330 -			u32 position, product1;
 44.1331 -
 44.1332 -			position = w >> 16;
 44.1333 -			A		 = bP[position]; // current pixel
 44.1334 -			B		 = bP[position + 1]; // next pixel
 44.1335 -			C		 = bP[position + Nextline];
 44.1336 -			D		 = bP[position + Nextline + 1];
 44.1337 -			E		 = bP[position - Nextline];
 44.1338 -			F		 = bP[position - Nextline + 1];
 44.1339 -			G		 = bP[position - 1];
 44.1340 -			H		 = bP[position + Nextline - 1];
 44.1341 -			I		 = bP[position + 2];
 44.1342 -			J		 = bP[position + Nextline + 2];
 44.1343 -			K		 = bP[position + Nextline + Nextline];
 44.1344 -			L		 = bP[position + Nextline + Nextline + 1];
 44.1345 -
 44.1346 -			x1 = w & 0xffff; // fraction part of fixed point
 44.1347 -			x2 = 0x10000 - x1;
 44.1348 -
 44.1349 -			/*0*/
 44.1350 -			if (A == B && C == D && A == C)
 44.1351 -				product1 = A;
 44.1352 -			else /*1*/ if (A == D && B != C)
 44.1353 -			{
 44.1354 -				f1 = (x1 >> 1) + (0x10000 >> 2);
 44.1355 -				f2 = (y1 >> 1) + (0x10000 >> 2);
 44.1356 -				if (y1 <= f1 && A == J && A != E) // close to B
 44.1357 -				{
 44.1358 -					a1		 = f1 - y1;
 44.1359 -					product1 = Bilinear(A, B, a1);
 44.1360 -				}
 44.1361 -				else if (y1 >= f1 && A == G && A != L)  // close to C
 44.1362 -				{
 44.1363 -					a1		 = y1 - f1;
 44.1364 -					product1 = Bilinear(A, C, a1);
 44.1365 -				}
 44.1366 -				else if (x1 >= f2 && A == E && A != J) // close to B
 44.1367 -				{
 44.1368 -					a1		 = x1 - f2;
 44.1369 -					product1 = Bilinear(A, B, a1);
 44.1370 -				}
 44.1371 -				else if (x1 <= f2 && A == L && A != G) // close to C
 44.1372 -				{
 44.1373 -					a1		 = f2 - x1;
 44.1374 -					product1 = Bilinear(A, C, a1);
 44.1375 -				}
 44.1376 -				else if (y1 >= x1) // close to C
 44.1377 -				{
 44.1378 -					a1		 = y1 - x1;
 44.1379 -					product1 = Bilinear(A, C, a1);
 44.1380 -				}
 44.1381 -				else if (y1 <= x1) // close to B
 44.1382 -				{
 44.1383 -					a1		 = x1 - y1;
 44.1384 -					product1 = Bilinear(A, B, a1);
 44.1385 -				}
 44.1386 -			}
 44.1387 -			else
 44.1388 -				/*2*/
 44.1389 -				if (B == C && A != D)
 44.1390 -				{
 44.1391 -					f1 = (x1 >> 1) + (0x10000 >> 2);
 44.1392 -					f2 = (y1 >> 1) + (0x10000 >> 2);
 44.1393 -					if (y2 >= f1 && B == H && B != F) // close to A
 44.1394 -					{
 44.1395 -						a1		 = y2 - f1;
 44.1396 -						product1 = Bilinear(B, A, a1);
 44.1397 -					}
 44.1398 -					else if (y2 <= f1 && B == I && B != K) // close to D
 44.1399 -					{
 44.1400 -						a1		 = f1 - y2;
 44.1401 -						product1 = Bilinear(B, D, a1);
 44.1402 -					}
 44.1403 -					else if (x2 >= f2 && B == F && B != H) // close to A
 44.1404 -					{
 44.1405 -						a1		 = x2 - f2;
 44.1406 -						product1 = Bilinear(B, A, a1);
 44.1407 -					}
 44.1408 -					else if (x2 <= f2 && B == K && B != I) // close to D
 44.1409 -					{
 44.1410 -						a1		 = f2 - x2;
 44.1411 -						product1 = Bilinear(B, D, a1);
 44.1412 -					}
 44.1413 -					else if (y2 >= x1) // close to A
 44.1414 -					{
 44.1415 -						a1		 = y2 - x1;
 44.1416 -						product1 = Bilinear(B, A, a1);
 44.1417 -					}
 44.1418 -					else if (y2 <= x1) // close to D
 44.1419 -					{
 44.1420 -						a1		 = x1 - y2;
 44.1421 -						product1 = Bilinear(B, D, a1);
 44.1422 -					}
 44.1423 -				}
 44.1424 -				/*3*/
 44.1425 -				else
 44.1426 -				{
 44.1427 -					product1 = Bilinear4(A, B, C, D, x1, y1);
 44.1428 -				}
 44.1429 -
 44.1430 -			//end First Pixel
 44.1431 -			*(u32 *) dP = product1;
 44.1432 -			dP += 2;
 44.1433 -			w  += dw;
 44.1434 -		}
 44.1435 -		dstPtr += dstPitch;
 44.1436 -	}
 44.1437 -}
    45.1 --- a/src/filters/2xSaImmx.asm	Sat Mar 03 10:54:39 2012 -0600
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,2109 +0,0 @@
    45.4 -;/*---------------------------------------------------------------------*
    45.5 -; * The following (piece of) code, (part of) the 2xSaI engine,          *
    45.6 -; * copyright (c) 1999 - 2001 by Derek Liauw Kie Fa.                    *
    45.7 -; * Non-Commercial use of this software is allowed and is encouraged,   *
    45.8 -; * provided that appropriate credit be given.                          *
    45.9 -; * You may freely modify this code, but I request                      *
   45.10 -; * that any improvements to the engine be submitted to me, so          *
   45.11 -; * that I can implement these improvements in newer versions of        *
   45.12 -; * the software.                                                       *
   45.13 -; * If you need more information, have any comments or suggestions,     *
   45.14 -; * you can e-mail me. My e-mail: derek-liauw@usa.net.                  *
   45.15 -; *---------------------------------------------------------------------*/
   45.16 -
   45.17 -;----------------------
   45.18 -; 2xSaI version 0.59 WIP, soon to become version 0.60
   45.19 -;----------------------
   45.20 -
   45.21 -;%define FAR_POINTER
   45.22 -
   45.23 -
   45.24 -
   45.25 -          BITS 32
   45.26 -%ifdef __DJGPP__
   45.27 -          GLOBAL __2xSaILine
   45.28 -          GLOBAL __2xSaISuperEagleLine
   45.29 -                  GLOBAL __2xSaISuper2xSaILine
   45.30 -          GLOBAL _Init_2xSaIMMX
   45.31 -%else
   45.32 -          GLOBAL _2xSaILine
   45.33 -          GLOBAL _2xSaISuperEagleLine
   45.34 -                  GLOBAL _2xSaISuper2xSaILine
   45.35 -          GLOBAL Init_2xSaIMMX
   45.36 -%endif
   45.37 -          SECTION .text ALIGN = 32
   45.38 -
   45.39 -%ifdef FAR_POINTER
   45.40 -;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width,
   45.41 -;                        uint8 *dstPtr, uint32 dstPitch, uint16 dstSegment);
   45.42 -%else
   45.43 -;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width,
   45.44 -;                        uint8 *dstPtr, uint32 dstPitch);
   45.45 -%endif
   45.46 -
   45.47 -srcPtr        equ 8
   45.48 -deltaPtr      equ 12
   45.49 -srcPitch      equ 16
   45.50 -width         equ 20
   45.51 -dstOffset     equ 24
   45.52 -dstPitch      equ 28
   45.53 -dstSegment    equ 32
   45.54 -
   45.55 -
   45.56 -
   45.57 -
   45.58 -colorB0   equ -2
   45.59 -colorB1   equ 0
   45.60 -colorB2   equ 2
   45.61 -colorB3   equ 4
   45.62 -
   45.63 -color7   equ -2
   45.64 -color8   equ 0
   45.65 -color9   equ 2
   45.66 -
   45.67 -color4   equ -2
   45.68 -color5   equ 0
   45.69 -color6   equ 2
   45.70 -colorS2   equ 4
   45.71 -
   45.72 -color1   equ -2
   45.73 -color2   equ 0
   45.74 -color3   equ 2
   45.75 -colorS1   equ 4
   45.76 -
   45.77 -colorA0   equ -2
   45.78 -colorA1   equ 0
   45.79 -colorA2   equ 2
   45.80 -colorA3   equ 4
   45.81 -
   45.82 -
   45.83 -
   45.84 -
   45.85 -%ifdef __DJGPP__
   45.86 -__2xSaISuper2xSaILine:
   45.87 -%else
   45.88 -_2xSaISuper2xSaILine:
   45.89 -%endif
   45.90 -; Store some stuff
   45.91 -         push ebp
   45.92 -         mov ebp, esp
   45.93 -         pushad
   45.94 -
   45.95 -; Prepare the destination
   45.96 -%ifdef FAR_POINTER
   45.97 -         ; Set the selector
   45.98 -         mov eax, [ebp+dstSegment]
   45.99 -         mov fs, ax
  45.100 -%endif
  45.101 -         mov edx, [ebp+dstOffset]         ; edx points to the screen
  45.102 -; Prepare the source
  45.103 -         ; eax points to colorA
  45.104 -         mov eax, [ebp+srcPtr]                          ;eax points to colorA
  45.105 -         mov ebx, [ebp+srcPitch]                        ;ebx contains the source pitch
  45.106 -         mov ecx, [ebp+width]                           ;ecx contains the number of pixels to process
  45.107 -         ; eax now points to colorB1
  45.108 -         sub eax, ebx                                           ;eax points to B1 which is the base 
  45.109 -
  45.110 -; Main Loop
  45.111 -.Loop:   push ecx
  45.112 -
  45.113 -         ;-----Check Delta------------------
  45.114 -         mov ecx, [ebp+deltaPtr]
  45.115 -
  45.116 -
  45.117 -                ;load source img
  45.118 -         movq mm0, [eax+colorB0]
  45.119 -         movq mm1, [eax+colorB3]
  45.120 -         movq mm2, [eax+ebx+color4]
  45.121 -         movq mm3, [eax+ebx+colorS2]
  45.122 -         movq mm4, [eax+ebx+ebx+color1]
  45.123 -         movq mm5, [eax+ebx+ebx+colorS1]
  45.124 -         push eax
  45.125 -         add eax, ebx
  45.126 -         movq mm6, [eax+ebx+ebx+colorA0]
  45.127 -         movq mm7, [eax+ebx+ebx+colorA3]
  45.128 -         pop eax
  45.129 -
  45.130 -                ;compare to delta
  45.131 -         pcmpeqw mm0, [ecx+2+colorB0]
  45.132 -         pcmpeqw mm1, [ecx+2+colorB3]
  45.133 -         pcmpeqw mm2, [ecx+ebx+2+color4]
  45.134 -         pcmpeqw mm3, [ecx+ebx+2+colorS2]
  45.135 -         pcmpeqw mm4, [ecx+ebx+ebx+2+color1]
  45.136 -         pcmpeqw mm5, [ecx+ebx+ebx+2+colorS1]
  45.137 -         add ecx, ebx
  45.138 -         pcmpeqw mm6, [ecx+ebx+ebx+2+colorA0]
  45.139 -         pcmpeqw mm7, [ecx+ebx+ebx+2+colorA3]
  45.140 -         sub ecx, ebx
  45.141 -
  45.142 -
  45.143 -                ;compose results
  45.144 -         pand mm0, mm1
  45.145 -         pand mm2, mm3
  45.146 -         pand mm4, mm5
  45.147 -         pand mm6, mm7
  45.148 -         pand mm0, mm2
  45.149 -         pand mm4, mm6
  45.150 -         pxor mm7, mm7
  45.151 -         pand mm0, mm4
  45.152 -         movq mm6, [eax+colorB0]
  45.153 -         pcmpeqw mm7, mm0                       ;did any compare give us a zero ?
  45.154 -
  45.155 -         movq [ecx+2+colorB0], mm6
  45.156 -
  45.157 -         packsswb mm7, mm7
  45.158 -         movd ecx, mm7
  45.159 -         test ecx, ecx                          
  45.160 -         jz near .SKIP_PROCESS          ;no, so we can skip
  45.161 -
  45.162 -         ;End Delta
  45.163 -
  45.164 -         ;---------------------------------
  45.165 -         movq mm0, [eax+ebx+color5]
  45.166 -         movq mm1, [eax+ebx+color6]
  45.167 -         movq mm2, mm0
  45.168 -         movq mm3, mm1
  45.169 -         movq mm4, mm0
  45.170 -         movq mm5, mm1
  45.171 -
  45.172 -         pand mm0, [colorMask]
  45.173 -         pand mm1, [colorMask]
  45.174 -
  45.175 -         psrlw mm0, 1
  45.176 -         psrlw mm1, 1
  45.177 -
  45.178 -         pand mm3, [lowPixelMask]
  45.179 -         paddw mm0, mm1
  45.180 -
  45.181 -         pand mm3, mm2
  45.182 -         paddw mm0, mm3                ;mm0 contains the interpolated values
  45.183 -         movq [I56Pixel], mm0
  45.184 -         movq mm7, mm0
  45.185 -
  45.186 -         ;-------------------
  45.187 -         movq mm0, mm7
  45.188 -         movq mm1, mm4  ;5,5,5,6
  45.189 -         movq mm2, mm0
  45.190 -         movq mm3, mm1
  45.191 -
  45.192 -         pand mm0, [colorMask]
  45.193 -         pand mm1, [colorMask]
  45.194 -
  45.195 -         psrlw mm0, 1
  45.196 -         psrlw mm1, 1
  45.197 -
  45.198 -         pand mm3, [lowPixelMask]
  45.199 -         paddw mm0, mm1
  45.200 -
  45.201 -         pand mm3, mm2
  45.202 -         paddw mm0, mm3                ;mm0 contains the interpolated values
  45.203 -         movq [I5556Pixel], mm0
  45.204 -         ;--------------------
  45.205 -
  45.206 -         movq mm0, mm7
  45.207 -         movq mm1, mm5  ;6,6,6,5
  45.208 -         movq mm2, mm0
  45.209 -         movq mm3, mm1
  45.210 -
  45.211 -         pand mm0, [colorMask]
  45.212 -         pand mm1, [colorMask]
  45.213 -
  45.214 -         psrlw mm0, 1
  45.215 -         psrlw mm1, 1
  45.216 -
  45.217 -         pand mm3, [lowPixelMask]
  45.218 -         paddw mm0, mm1
  45.219 -
  45.220 -         pand mm3, mm2
  45.221 -         paddw mm0, mm3
  45.222 -         movq [I5666Pixel], mm0
  45.223 -
  45.224 -         ;-------------------------
  45.225 -         ;-------------------------
  45.226 -         movq mm0, [eax+ebx+ebx+color2]
  45.227 -         movq mm1, [eax+ebx+ebx+color3]
  45.228 -         movq mm2, mm0
  45.229 -         movq mm3, mm1
  45.230 -         movq mm4, mm0
  45.231 -         movq mm5, mm1
  45.232 -
  45.233 -         pand mm0, [colorMask]
  45.234 -         pand mm1, [colorMask]
  45.235 -
  45.236 -         psrlw mm0, 1
  45.237 -         psrlw mm1, 1
  45.238 -
  45.239 -         pand mm3, [lowPixelMask]
  45.240 -         paddw mm0, mm1
  45.241 -
  45.242 -         pand mm3, mm2
  45.243 -         paddw mm0, mm3
  45.244 -         movq [I23Pixel], mm0
  45.245 -         movq mm7, mm0
  45.246 -
  45.247 -         ;---------------------
  45.248 -         movq mm0, mm7
  45.249 -         movq mm1, mm4  ;2,2,2,3
  45.250 -         movq mm2, mm0
  45.251 -         movq mm3, mm1
  45.252 -
  45.253 -         pand mm0, [colorMask]
  45.254 -         pand mm1, [colorMask]
  45.255 -
  45.256 -         psrlw mm0, 1
  45.257 -         psrlw mm1, 1
  45.258 -
  45.259 -         pand mm3, [lowPixelMask]
  45.260 -         paddw mm0, mm1
  45.261 -
  45.262 -         pand mm3, mm2
  45.263 -         paddw mm0, mm3
  45.264 -         movq [I2223Pixel], mm0
  45.265 -
  45.266 -         ;----------------------
  45.267 -         movq mm0, mm7
  45.268 -         movq mm1, mm5  ;3,3,3,2
  45.269 -         movq mm2, mm0
  45.270 -         movq mm3, mm1
  45.271 -
  45.272 -         pand mm0, [colorMask]
  45.273 -         pand mm1, [colorMask]
  45.274 -
  45.275 -         psrlw mm0, 1
  45.276 -         psrlw mm1, 1
  45.277 -
  45.278 -         pand mm3, [lowPixelMask]
  45.279 -         paddw mm0, mm1
  45.280 -
  45.281 -         pand mm3, mm2
  45.282 -         paddw mm0, mm3
  45.283 -         movq [I2333Pixel], mm0
  45.284 -
  45.285 -
  45.286 -         ;--------------------
  45.287 -;////////////////////////////////
  45.288 -; Decide which "branch" to take
  45.289 -;--------------------------------
  45.290 -         movq mm0, [eax+ebx+color5]
  45.291 -         movq mm1, [eax+ebx+color6]
  45.292 -         movq mm6, mm0
  45.293 -         movq mm7, mm1
  45.294 -         pcmpeqw mm0, [eax+ebx+ebx+color3]
  45.295 -         pcmpeqw mm1, [eax+ebx+ebx+color2]
  45.296 -         pcmpeqw mm6, mm7
  45.297 -
  45.298 -         movq mm2, mm0
  45.299 -         movq mm3, mm0
  45.300 -
  45.301 -         pand mm0, mm1       ;colorA == colorD && colorB == colorC
  45.302 -         pxor mm7, mm7
  45.303 -
  45.304 -         pcmpeqw mm2, mm7
  45.305 -         pand mm6, mm0
  45.306 -         pand mm2, mm1       ;colorA != colorD && colorB == colorC
  45.307 -
  45.308 -         pcmpeqw mm1, mm7
  45.309 -
  45.310 -         pand mm1, mm3       ;colorA == colorD && colorB != colorC
  45.311 -         pxor mm0, mm6
  45.312 -         por mm1, mm6
  45.313 -         movq mm7, mm0
  45.314 -         movq [Mask26], mm2
  45.315 -         packsswb mm7, mm7
  45.316 -         movq [Mask35], mm1
  45.317 -
  45.318 -         movd ecx, mm7
  45.319 -         test ecx, ecx
  45.320 -         jz near .SKIP_GUESS
  45.321 -
  45.322 -;---------------------------------------------
  45.323 -         movq mm6, mm0
  45.324 -         movq mm4, [eax+ebx+colorA]
  45.325 -         movq mm5, [eax+ebx+colorB]
  45.326 -         pxor mm7, mm7
  45.327 -         pand mm6, [ONE]
  45.328 -
  45.329 -         movq mm0, [eax+colorE]
  45.330 -         movq mm1, [eax+ebx+colorG]
  45.331 -         movq mm2, mm0
  45.332 -         movq mm3, mm1
  45.333 -         pcmpeqw mm0, mm4
  45.334 -         pcmpeqw mm1, mm4
  45.335 -         pcmpeqw mm2, mm5
  45.336 -         pcmpeqw mm3, mm5
  45.337 -         pand mm0, mm6
  45.338 -         pand mm1, mm6
  45.339 -         pand mm2, mm6
  45.340 -         pand mm3, mm6
  45.341 -         paddw mm0, mm1
  45.342 -         paddw mm2, mm3
  45.343 -
  45.344 -         pxor mm3, mm3
  45.345 -         pcmpgtw mm0, mm6
  45.346 -         pcmpgtw mm2, mm6
  45.347 -         pcmpeqw mm0, mm3
  45.348 -         pcmpeqw mm2, mm3
  45.349 -         pand mm0, mm6
  45.350 -         pand mm2, mm6
  45.351 -         paddw mm7, mm0
  45.352 -         psubw mm7, mm2
  45.353 -
  45.354 -         movq mm0, [eax+colorF]
  45.355 -         movq mm1, [eax+ebx+colorK]
  45.356 -         movq mm2, mm0
  45.357 -         movq mm3, mm1
  45.358 -         pcmpeqw mm0, mm4
  45.359 -         pcmpeqw mm1, mm4
  45.360 -         pcmpeqw mm2, mm5
  45.361 -         pcmpeqw mm3, mm5
  45.362 -         pand mm0, mm6
  45.363 -         pand mm1, mm6
  45.364 -         pand mm2, mm6
  45.365 -         pand mm3, mm6
  45.366 -         paddw mm0, mm1
  45.367 -         paddw mm2, mm3
  45.368 -
  45.369 -         pxor mm3, mm3
  45.370 -         pcmpgtw mm0, mm6
  45.371 -         pcmpgtw mm2, mm6
  45.372 -         pcmpeqw mm0, mm3
  45.373 -         pcmpeqw mm2, mm3
  45.374 -         pand mm0, mm6
  45.375 -         pand mm2, mm6
  45.376 -         paddw mm7, mm0
  45.377 -         psubw mm7, mm2
  45.378 -
  45.379 -         push eax
  45.380 -         add eax, ebx
  45.381 -         movq mm0, [eax+ebx+colorH]
  45.382 -         movq mm1, [eax+ebx+ebx+colorN]
  45.383 -         movq mm2, mm0
  45.384 -         movq mm3, mm1
  45.385 -         pcmpeqw mm0, mm4
  45.386 -         pcmpeqw mm1, mm4
  45.387 -         pcmpeqw mm2, mm5
  45.388 -         pcmpeqw mm3, mm5
  45.389 -         pand mm0, mm6
  45.390 -         pand mm1, mm6
  45.391 -         pand mm2, mm6
  45.392 -         pand mm3, mm6
  45.393 -         paddw mm0, mm1
  45.394 -         paddw mm2, mm3
  45.395 -
  45.396 -         pxor mm3, mm3
  45.397 -         pcmpgtw mm0, mm6
  45.398 -         pcmpgtw mm2, mm6
  45.399 -         pcmpeqw mm0, mm3
  45.400 -         pcmpeqw mm2, mm3
  45.401 -         pand mm0, mm6
  45.402 -         pand mm2, mm6
  45.403 -         paddw mm7, mm0
  45.404 -         psubw mm7, mm2
  45.405 -
  45.406 -         movq mm0, [eax+ebx+colorL]
  45.407 -         movq mm1, [eax+ebx+ebx+colorO]
  45.408 -         movq mm2, mm0
  45.409 -         movq mm3, mm1
  45.410 -         pcmpeqw mm0, mm4
  45.411 -         pcmpeqw mm1, mm4
  45.412 -         pcmpeqw mm2, mm5
  45.413 -         pcmpeqw mm3, mm5
  45.414 -         pand mm0, mm6
  45.415 -         pand mm1, mm6
  45.416 -         pand mm2, mm6
  45.417 -         pand mm3, mm6
  45.418 -         paddw mm0, mm1
  45.419 -         paddw mm2, mm3
  45.420 -
  45.421 -         pxor mm3, mm3
  45.422 -         pcmpgtw mm0, mm6
  45.423 -         pcmpgtw mm2, mm6
  45.424 -         pcmpeqw mm0, mm3
  45.425 -         pcmpeqw mm2, mm3
  45.426 -         pand mm0, mm6
  45.427 -         pand mm2, mm6
  45.428 -         paddw mm7, mm0
  45.429 -         psubw mm7, mm2
  45.430 -
  45.431 -         pop eax
  45.432 -         movq mm1, mm7
  45.433 -         pxor mm0, mm0
  45.434 -         pcmpgtw mm7, mm0
  45.435 -         pcmpgtw mm0, mm1
  45.436 -
  45.437 -         por mm7, [Mask35]
  45.438 -         por mm0, [Mask26] 
  45.439 -         movq [Mask35], mm7
  45.440 -         movq [Mask26], mm0
  45.441 -
  45.442 -.SKIP_GUESS:
  45.443 -
  45.444 -         ;Start the ASSEMBLY !!!        eh... compose all the results together to form the final image...
  45.445 -
  45.446 -                 
  45.447 -         movq mm0, [eax+ebx+color5]
  45.448 -         movq mm1, [eax+ebx+ebx+color2]
  45.449 -         movq mm2, mm0
  45.450 -         movq mm3, mm1
  45.451 -         movq mm4, mm0
  45.452 -         movq mm5, mm1
  45.453 -
  45.454 -         pand mm0, [colorMask]
  45.455 -         pand mm1, [colorMask]
  45.456 -
  45.457 -         psrlw mm0, 1
  45.458 -         psrlw mm1, 1
  45.459 -
  45.460 -         pand mm3, [lowPixelMask]
  45.461 -         paddw mm0, mm1
  45.462 -
  45.463 -         pand mm3, mm2
  45.464 -         paddw mm0, mm3                ;mm0 contains the interpolated values
  45.465 -                 ;---------------------------
  45.466 -
  45.467 -
  45.468 -
  45.469 -%ifdef dfhsdfhsdahdsfhdsfh
  45.470 -
  45.471 -                if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2)
  45.472 -                   product2a = INTERPOLATE (color2, color5);
  45.473 -                else
  45.474 -                if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0)
  45.475 -                   product2a = INTERPOLATE(color2, color5);
  45.476 -                else
  45.477 -                   product2a = color2;
  45.478 -
  45.479 -                if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2)
  45.480 -                   product1a = INTERPOLATE (color2, color5);
  45.481 -                else
  45.482 -                if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0)
  45.483 -                   product1a = INTERPOLATE(color2, color5);
  45.484 -                else
  45.485 -                   product1a = color5;
  45.486 -
  45.487 -%endif
  45.488 -
  45.489 -
  45.490 -                 movq mm7, [Mask26]
  45.491 -                 movq mm6, [eax+colorB2]
  45.492 -                 movq mm5, [eax+ebx+ebx+color2]
  45.493 -                 movq mm4, [eax+ebx+ebx+color1]
  45.494 -                 pcmpeqw mm4, mm5
  45.495 -                 pcmpeqw mm6, mm5
  45.496 -                 pxor mm5, mm5
  45.497 -                 pand mm7, mm4
  45.498 -                 pcmpeqw mm6, mm5
  45.499 -                 pand mm7, mm6
  45.500 -
  45.501 -
  45.502 -
  45.503 -                 movq mm6, [eax+ebx+ebx+color3]
  45.504 -                 movq mm5, [eax+ebx+ebx+color2]
  45.505 -                 movq mm4, [eax+ebx+ebx+color1]
  45.506 -                 movq mm2, [eax+ebx+color5]
  45.507 -                 movq mm1, [eax+ebx+color4]
  45.508 -                 movq mm3, [eax+colorB0]
  45.509 -
  45.510 -                 pcmpeqw mm2, mm4
  45.511 -                 pcmpeqw mm6, mm5
  45.512 -                 pcmpeqw mm1, mm5
  45.513 -                 pcmpeqw mm3, mm5
  45.514 -                 pxor mm5, mm5
  45.515 -                 pcmpeqw mm2, mm5
  45.516 -                 pcmpeqw mm3, mm5
  45.517 -                 pand mm6, mm1
  45.518 -                 pand mm2, mm3
  45.519 -                 pand mm6, mm2
  45.520 -                 por mm7, mm6
  45.521 -
  45.522 -                 
  45.523 -                 movq mm6, mm7
  45.524 -                 pcmpeqw mm6, mm5
  45.525 -                 pand mm7, mm0
  45.526 -
  45.527 -                 movq mm1, [eax+ebx+color5]
  45.528 -                 pand mm6, mm1
  45.529 -                 por mm7, mm6
  45.530 -                 movq [final1a], mm7                    ;finished  1a
  45.531 -
  45.532 -
  45.533 -         
  45.534 -             ;--------------------------------           
  45.535 -
  45.536 -                 movq mm7, [Mask35]
  45.537 -                 push eax
  45.538 -                 add eax, ebx
  45.539 -                 movq mm6, [eax+ebx+ebx+colorA2]
  45.540 -                 pop eax
  45.541 -                 movq mm5, [eax+ebx+color5]
  45.542 -                 movq mm4, [eax+ebx+color4]
  45.543 -                 pcmpeqw mm4, mm5
  45.544 -                 pcmpeqw mm6, mm5
  45.545 -                 pxor mm5, mm5
  45.546 -                 pand mm7, mm4
  45.547 -                 pcmpeqw mm6, mm5
  45.548 -                 pand mm7, mm6
  45.549 -
  45.550 -
  45.551 -
  45.552 -                 movq mm6, [eax+ebx+color6]
  45.553 -                 movq mm5, [eax+ebx+color5]
  45.554 -                 movq mm4, [eax+ebx+color4]
  45.555 -                 movq mm2, [eax+ebx+ebx+color2]
  45.556 -                 movq mm1, [eax+ebx+ebx+color1]
  45.557 -                 push eax
  45.558 -                 add eax, ebx
  45.559 -                 movq mm3, [eax+ebx+ebx+colorA0]
  45.560 -                 pop eax
  45.561 -
  45.562 -                 pcmpeqw mm2, mm4
  45.563 -                 pcmpeqw mm6, mm5
  45.564 -                 pcmpeqw mm1, mm5
  45.565 -                 pcmpeqw mm3, mm5
  45.566 -                 pxor mm5, mm5
  45.567 -                 pcmpeqw mm2, mm5
  45.568 -                 pcmpeqw mm3, mm5
  45.569 -                 pand mm6, mm1
  45.570 -                 pand mm2, mm3
  45.571 -                 pand mm6, mm2
  45.572 -                 por mm7, mm6
  45.573 -
  45.574 -                 
  45.575 -                 movq mm6, mm7
  45.576 -                 pcmpeqw mm6, mm5
  45.577 -                 pand mm7, mm0
  45.578 -
  45.579 -                 movq mm1, [eax+ebx+ebx+color2]
  45.580 -                 pand mm6, mm1
  45.581 -                 por mm7, mm6
  45.582 -                 movq [final2a], mm7                    ;finished  2a
  45.583 -
  45.584 -
  45.585 -                 ;--------------------------------------------
  45.586 - 
  45.587 -
  45.588 -%ifdef dfhsdfhsdahdsfhdsfh
  45.589 -                   if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0)
  45.590 -                      product2b = Q_INTERPOLATE (color3, color3, color3, color2);
  45.591 -                   else
  45.592 -                   if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3)
  45.593 -                      product2b = Q_INTERPOLATE (color2, color2, color2, color3);
  45.594 -                   else
  45.595 -                      product2b = INTERPOLATE (color2, color3);
  45.596 -
  45.597 -                   if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0)
  45.598 -                      product1b = Q_INTERPOLATE (color6, color6, color6, color5);
  45.599 -                   else
  45.600 -                   if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3)
  45.601 -                      product1b = Q_INTERPOLATE (color6, color5, color5, color5);
  45.602 -                   else
  45.603 -                      product1b = INTERPOLATE (color5, color6);
  45.604 -%endif
  45.605 -
  45.606 -                 push eax
  45.607 -                 add eax, ebx
  45.608 -                 pxor mm7, mm7
  45.609 -                 movq mm0, [eax+ebx+ebx+colorA0]
  45.610 -                 movq mm1, [eax+ebx+ebx+colorA1]
  45.611 -                 movq mm2, [eax+ebx+ebx+colorA2]
  45.612 -                 movq mm3, [eax+ebx+ebx+colorA3]
  45.613 -                 pop eax
  45.614 -                 movq mm4, [eax+ebx+ebx+color2]
  45.615 -                 movq mm5, [eax+ebx+ebx+color3]
  45.616 -                 movq mm6, [eax+ebx+color6]
  45.617 -
  45.618 -                 pcmpeqw mm6, mm5
  45.619 -                 pcmpeqw mm1, mm5
  45.620 -                 pcmpeqw mm4, mm2
  45.621 -                 pcmpeqw mm0, mm5
  45.622 -                 pcmpeqw mm4, mm7
  45.623 -                 pcmpeqw mm0, mm7
  45.624 -                 pand mm0, mm4
  45.625 -                 pand mm6, mm1
  45.626 -                 pand mm0, mm6
  45.627 -
  45.628 -
  45.629 -                 push eax
  45.630 -                 add eax, ebx
  45.631 -                 movq mm1, [eax+ebx+ebx+colorA1]
  45.632 -                 pop eax
  45.633 -                 movq mm4, [eax+ebx+ebx+color2]
  45.634 -                 movq mm5, [eax+ebx+color5]
  45.635 -                 movq mm6, [eax+ebx+ebx+color3]
  45.636 -
  45.637 -                 pcmpeqw mm5, mm4
  45.638 -                 pcmpeqw mm2, mm4
  45.639 -                 pcmpeqw mm1, mm6
  45.640 -                 pcmpeqw mm3, mm4
  45.641 -                 pcmpeqw mm1, mm7
  45.642 -                 pcmpeqw mm3, mm7
  45.643 -                 pand mm2, mm5
  45.644 -                 pand mm1, mm3
  45.645 -                 pand mm1, mm2
  45.646 -
  45.647 -
  45.648 -                 movq mm7, mm0
  45.649 -                 por mm7, mm1
  45.650 -
  45.651 -                 movq mm4, [Mask35]
  45.652 -                 movq mm3, [Mask26]
  45.653 -                 
  45.654 -                 movq mm6, mm4
  45.655 -                 pand mm6, mm7
  45.656 -                 pxor mm4, mm6
  45.657 -
  45.658 -                 movq mm6, mm3
  45.659 -                 pand mm6, mm7
  45.660 -                 pxor mm3, mm6
  45.661 -
  45.662 -                 movq mm2, mm0
  45.663 -                 movq mm7, [I2333Pixel]
  45.664 -                 movq mm6, [I2223Pixel]
  45.665 -                 movq mm5, [I23Pixel]
  45.666 -
  45.667 -
  45.668 -                 por mm2, mm4
  45.669 -                 pand mm4, [eax+ebx+ebx+color3]
  45.670 -                 por mm2, mm3
  45.671 -                 pand mm3, [eax+ebx+ebx+color2]
  45.672 -                 por mm2, mm1
  45.673 -                 pand mm0, mm7
  45.674 -                 pand mm1, mm6
  45.675 -                 pxor mm7, mm7
  45.676 -                 pcmpeqw mm2, mm7
  45.677 -                 por mm0, mm1
  45.678 -                 por mm3, mm4
  45.679 -                 pand mm2, mm5
  45.680 -                 por mm0, mm3
  45.681 -                 por mm0, mm2
  45.682 -                 movq [final2b], mm0
  45.683 -
  45.684 -                 ;-----------------------------------
  45.685 -                 
  45.686 -
  45.687 -                 pxor mm7, mm7
  45.688 -                 movq mm0, [eax+colorB0]
  45.689 -                 movq mm1, [eax+colorB1]
  45.690 -                 movq mm2, [eax+colorB2]
  45.691 -                 movq mm3, [eax+colorB3]
  45.692 -                 movq mm4, [eax+ebx+color5]
  45.693 -                 movq mm5, [eax+ebx+color6]
  45.694 -                 movq mm6, [eax+ebx+ebx+color3]
  45.695 -
  45.696 -                 pcmpeqw mm6, mm5
  45.697 -                 pcmpeqw mm1, mm5
  45.698 -                 pcmpeqw mm4, mm2
  45.699 -                 pcmpeqw mm0, mm5
  45.700 -                 pcmpeqw mm4, mm7
  45.701 -                 pcmpeqw mm0, mm7
  45.702 -                 pand mm0, mm4
  45.703 -                 pand mm6, mm1
  45.704 -                 pand mm0, mm6
  45.705 -
  45.706 -                 movq mm1, [eax+colorB1]
  45.707 -                 movq mm4, [eax+ebx+color5]
  45.708 -                 movq mm5, [eax+ebx+ebx+color2]
  45.709 -                 movq mm6, [eax+ebx+color6]
  45.710 -
  45.711 -                 pcmpeqw mm5, mm4
  45.712 -                 pcmpeqw mm2, mm4
  45.713 -                 pcmpeqw mm1, mm6
  45.714 -                 pcmpeqw mm3, mm4
  45.715 -                 pcmpeqw mm1, mm7
  45.716 -                 pcmpeqw mm3, mm7
  45.717 -                 pand mm2, mm5
  45.718 -                 pand mm1, mm3
  45.719 -                 pand mm1, mm2
  45.720 -
  45.721 -
  45.722 -                 movq mm7, mm0
  45.723 -                 por mm7, mm1
  45.724 -
  45.725 -                 movq mm4, [Mask35]
  45.726 -                 movq mm3, [Mask26]
  45.727 -                 
  45.728 -                 movq mm6, mm4
  45.729 -                 pand mm6, mm7
  45.730 -                 pxor mm4, mm6
  45.731 -
  45.732 -                 movq mm6, mm3
  45.733 -                 pand mm6, mm7
  45.734 -                 pxor mm3, mm6
  45.735 -
  45.736 -                 movq mm2, mm0
  45.737 -                 movq mm7, [I5666Pixel]
  45.738 -                 movq mm6, [I5556Pixel]
  45.739 -                 movq mm5, [I56Pixel]
  45.740 -
  45.741 -
  45.742 -                 por mm2, mm4
  45.743 -                 pand mm4, [eax+ebx+color5]
  45.744 -                 por mm2, mm3
  45.745 -                 pand mm3, [eax+ebx+color6]
  45.746 -                 por mm2, mm1
  45.747 -                 pand mm0, mm7
  45.748 -                 pand mm1, mm6
  45.749 -                 pxor mm7, mm7
  45.750 -                 pcmpeqw mm2, mm7
  45.751 -                 por mm0, mm1
  45.752 -                 por mm3, mm4
  45.753 -                 pand mm2, mm5
  45.754 -                 por mm0, mm3
  45.755 -                 por mm0, mm2
  45.756 -                 movq [final1b], mm0
  45.757 -                 
  45.758 -          ;---------
  45.759 -
  45.760 -                 movq mm0, [final1a]
  45.761 -                 movq mm4, [final2a]
  45.762 -                 movq mm2, [final1b]
  45.763 -                 movq mm6, [final2b]
  45.764 -
  45.765 -
  45.766 -                 movq mm1, mm0
  45.767 -                 movq mm5, mm4
  45.768 -
  45.769 -
  45.770 -         punpcklwd mm0, mm2
  45.771 -         punpckhwd mm1, mm2
  45.772 -
  45.773 -         punpcklwd mm4, mm6
  45.774 -         punpckhwd mm5, mm6
  45.775 -
  45.776 -
  45.777 -%ifdef FAR_POINTER
  45.778 -         movq [fs:edx], mm0
  45.779 -         movq [fs:edx+8], mm1
  45.780 -         push edx
  45.781 -         add edx, [ebp+dstPitch]
  45.782 -         movq [fs:edx], mm4
  45.783 -         movq [fs:edx+8], mm5
  45.784 -         pop edx
  45.785 -%else
  45.786 -         movq [edx], mm0
  45.787 -         movq [edx+8], mm1
  45.788 -         push edx
  45.789 -         add edx, [ebp+dstPitch]
  45.790 -         movq [edx], mm4
  45.791 -         movq [edx+8], mm5
  45.792 -         pop edx
  45.793 -%endif
  45.794 -.SKIP_PROCESS:
  45.795 -         mov ecx, [ebp+deltaPtr]
  45.796 -         add ecx, 8
  45.797 -         mov [ebp+deltaPtr], ecx
  45.798 -         add edx, 16
  45.799 -         add eax, 8
  45.800 -
  45.801 -         pop ecx
  45.802 -         sub ecx, 4
  45.803 -         cmp ecx, 0
  45.804 -         jg  near .Loop
  45.805 -
  45.806 -; Restore some stuff
  45.807 -         popad
  45.808 -         mov esp, ebp
  45.809 -         pop ebp
  45.810 -         emms
  45.811 -         ret
  45.812 -
  45.813 -
  45.814 -;-------------------------------------------------------------------------
  45.815 -;-------------------------------------------------------------------------
  45.816 -;-------------------------------------------------------------------------
  45.817 -;-------------------------------------------------------------------------
  45.818 -;-------------------------------------------------------------------------
  45.819 -;-------------------------------------------------------------------------
  45.820 -;-------------------------------------------------------------------------
  45.821 -
  45.822 -
  45.823 -
  45.824 -%ifdef __DJGPP__
  45.825 -__2xSaISuperEagleLine:
  45.826 -%else
  45.827 -_2xSaISuperEagleLine:
  45.828 -%endif
  45.829 -; Store some stuff
  45.830 -         push ebp
  45.831 -         mov ebp, esp
  45.832 -         pushad
  45.833 -
  45.834 -; Prepare the destination
  45.835 -%ifdef FAR_POINTER
  45.836 -         ; Set the selector
  45.837 -         mov eax, [ebp+dstSegment]
  45.838 -         mov fs, ax
  45.839 -%endif
  45.840 -         mov edx, [ebp+dstOffset]         ; edx points to the screen
  45.841 -; Prepare the source
  45.842 -         ; eax points to colorA
  45.843 -         mov eax, [ebp+srcPtr]
  45.844 -         mov ebx, [ebp+srcPitch]
  45.845 -         mov ecx, [ebp+width]
  45.846 -         ; eax now points to colorB1
  45.847 -         sub eax, ebx
  45.848 -
  45.849 -; Main Loop
  45.850 -.Loop:   push ecx
  45.851 -
  45.852 -         ;-----Check Delta------------------
  45.853 -         mov ecx, [ebp+deltaPtr]
  45.854 -
  45.855 -         movq mm0, [eax+colorB0]
  45.856 -         movq mm1, [eax+colorB3]
  45.857 -         movq mm2, [eax+ebx+color4]
  45.858 -         movq mm3, [eax+ebx+colorS2]
  45.859 -         movq mm4, [eax+ebx+ebx+color1]
  45.860 -         movq mm5, [eax+ebx+ebx+colorS1]
  45.861 -         push eax
  45.862 -         add eax, ebx
  45.863 -         movq mm6, [eax+ebx+ebx+colorA0]
  45.864 -         movq mm7, [eax+ebx+ebx+colorA3]
  45.865 -         pop eax
  45.866 -
  45.867 -         pcmpeqw mm0, [ecx+2+colorB0]
  45.868 -         pcmpeqw mm1, [ecx+2+colorB3]
  45.869 -         pcmpeqw mm2, [ecx+ebx+2+color4]
  45.870 -         pcmpeqw mm3, [ecx+ebx+2+colorS2]
  45.871 -         pcmpeqw mm4, [ecx+ebx+ebx+2+color1]
  45.872 -         pcmpeqw mm5, [ecx+ebx+ebx+2+colorS1]
  45.873 -         add ecx, ebx
  45.874 -         pcmpeqw mm6, [ecx+ebx+ebx+2+colorA0]
  45.875 -         pcmpeqw mm7, [ecx+ebx+ebx+2+colorA3]
  45.876 -         sub ecx, ebx
  45.877 -
  45.878 -
  45.879 -         pand mm0, mm1
  45.880 -         pand mm2, mm3
  45.881 -         pand mm4, mm5
  45.882 -         pand mm6, mm7
  45.883 -         pand mm0, mm2
  45.884 -         pand mm4, mm6
  45.885 -         pxor mm7, mm7
  45.886 -         pand mm0, mm4
  45.887 -         movq mm6, [eax+colorB0]
  45.888 -         pcmpeqw mm7, mm0
  45.889 -
  45.890 -         movq [ecx+2+colorB0], mm6
  45.891 -
  45.892 -         packsswb mm7, mm7
  45.893 -         movd ecx, mm7
  45.894 -         test ecx, ecx
  45.895 -         jz near .SKIP_PROCESS
  45.896 -
  45.897 -         ;End Delta
  45.898 -
  45.899 -         ;---------------------------------
  45.900 -         movq mm0, [eax+ebx+color5]
  45.901 -         movq mm1, [eax+ebx+color6]
  45.902 -         movq mm2, mm0
  45.903 -         movq mm3, mm1
  45.904 -         movq mm4, mm0
  45.905 -         movq mm5, mm1
  45.906 -
  45.907 -         pand mm0, [colorMask]
  45.908 -         pand mm1, [colorMask]
  45.909 -
  45.910 -         psrlw mm0, 1
  45.911 -         psrlw mm1, 1
  45.912 -
  45.913 -         pand mm3, [lowPixelMask]
  45.914 -         paddw mm0, mm1
  45.915 -
  45.916 -         pand mm3, mm2
  45.917 -         paddw mm0, mm3                ;mm0 contains the interpolated values
  45.918 -         movq [I56Pixel], mm0
  45.919 -         movq mm7, mm0
  45.920 -
  45.921 -         ;-------------------
  45.922 -         movq mm0, mm7
  45.923 -         movq mm1, mm4  ;5,5,5,6
  45.924 -         movq mm2, mm0
  45.925 -         movq mm3, mm1
  45.926 -
  45.927 -         pand mm0, [colorMask]
  45.928 -         pand mm1, [colorMask]
  45.929 -
  45.930 -         psrlw mm0, 1
  45.931 -         psrlw mm1, 1
  45.932 -
  45.933 -         pand mm3, [lowPixelMask]
  45.934 -         paddw mm0, mm1
  45.935 -
  45.936 -         pand mm3, mm2
  45.937 -         paddw mm0, mm3                ;mm0 contains the interpolated values
  45.938 -         movq [product1a], mm0
  45.939 -         ;--------------------
  45.940 -
  45.941 -         movq mm0, mm7
  45.942 -         movq mm1, mm5  ;6,6,6,5
  45.943 -         movq mm2, mm0
  45.944 -         movq mm3, mm1
  45.945 -
  45.946 -         pand mm0, [colorMask]
  45.947 -         pand mm1, [colorMask]
  45.948 -
  45.949 -         psrlw mm0, 1
  45.950 -         psrlw mm1, 1
  45.951 -
  45.952 -         pand mm3, [lowPixelMask]
  45.953 -         paddw mm0, mm1
  45.954 -
  45.955 -         pand mm3, mm2
  45.956 -         paddw mm0, mm3
  45.957 -         movq [product1b], mm0
  45.958 -
  45.959 -         ;-------------------------
  45.960 -         ;-------------------------
  45.961 -         movq mm0, [eax+ebx+ebx+color2]
  45.962 -         movq mm1, [eax+ebx+ebx+color3]
  45.963 -         movq mm2, mm0
  45.964 -         movq mm3, mm1
  45.965 -         movq mm4, mm0
  45.966 -         movq mm5, mm1
  45.967 -
  45.968 -         pand mm0, [colorMask]
  45.969 -         pand mm1, [colorMask]
  45.970 -
  45.971 -         psrlw mm0, 1
  45.972 -         psrlw mm1, 1
  45.973 -
  45.974 -         pand mm3, [lowPixelMask]
  45.975 -         paddw mm0, mm1
  45.976 -
  45.977 -         pand mm3, mm2
  45.978 -         paddw mm0, mm3
  45.979 -         movq [I23Pixel], mm0
  45.980 -         movq mm7, mm0
  45.981 -
  45.982 -         ;---------------------
  45.983 -         movq mm0, mm7
  45.984 -         movq mm1, mm4  ;2,2,2,3
  45.985 -         movq mm2, mm0
  45.986 -         movq mm3, mm1
  45.987 -
  45.988 -         pand mm0, [colorMask]
  45.989 -         pand mm1, [colorMask]
  45.990 -
  45.991 -         psrlw mm0, 1
  45.992 -         psrlw mm1, 1
  45.993 -
  45.994 -         pand mm3, [lowPixelMask]
  45.995 -         paddw mm0, mm1
  45.996 -
  45.997 -         pand mm3, mm2
  45.998 -         paddw mm0, mm3
  45.999 -         movq [product2a], mm0
 45.1000 -
 45.1001 -         ;----------------------
 45.1002 -         movq mm0, mm7
 45.1003 -         movq mm1, mm5  ;3,3,3,2
 45.1004 -         movq mm2, mm0
 45.1005 -         movq mm3, mm1
 45.1006 -
 45.1007 -         pand mm0, [colorMask]
 45.1008 -         pand mm1, [colorMask]
 45.1009 -
 45.1010 -         psrlw mm0, 1
 45.1011 -         psrlw mm1, 1
 45.1012 -
 45.1013 -         pand mm3, [lowPixelMask]
 45.1014 -         paddw mm0, mm1
 45.1015 -
 45.1016 -         pand mm3, mm2
 45.1017 -         paddw mm0, mm3
 45.1018 -         movq [product2b], mm0
 45.1019 -
 45.1020 -
 45.1021 -         ;////////////////////////////////
 45.1022 -         ; Decide which "branch" to take
 45.1023 -         ;--------------------------------
 45.1024 -         movq mm4, [eax+ebx+color5]
 45.1025 -         movq mm5, [eax+ebx+color6]
 45.1026 -         movq mm6, [eax+ebx+ebx+color3]
 45.1027 -         movq mm7, [eax+ebx+ebx+color2]
 45.1028 -
 45.1029 -         pxor mm3, mm3
 45.1030 -         movq mm0, mm4
 45.1031 -         movq mm1, mm5
 45.1032 -
 45.1033 -         pcmpeqw mm0, mm6
 45.1034 -         pcmpeqw mm1, mm7
 45.1035 -         pcmpeqw mm1, mm3
 45.1036 -         pand mm0, mm1
 45.1037 -         movq [Mask35], mm0
 45.1038 -
 45.1039 -         movq mm0, [eax+ebx+ebx+colorS1]
 45.1040 -         movq mm1, [eax+ebx+color4]
 45.1041 -         push eax
 45.1042 -         add eax, ebx
 45.1043 -         movq mm2, [eax+ebx+ebx+colorA2]
 45.1044 -         pop eax
 45.1045 -         movq mm3, [eax+colorB1]
 45.1046 -         pcmpeqw mm0, mm4
 45.1047 -         pcmpeqw mm1, mm4
 45.1048 -         pcmpeqw mm2, mm4
 45.1049 -         pcmpeqw mm3, mm4
 45.1050 -         pand mm0, mm1
 45.1051 -         pand mm2, mm3
 45.1052 -         por mm0, mm2
 45.1053 -         pand mm0, [Mask35]
 45.1054 -         movq [Mask35b], mm0
 45.1055 -
 45.1056 -         ;-----------
 45.1057 -         pxor mm3, mm3
 45.1058 -         movq mm0, mm4
 45.1059 -         movq mm1, mm5
 45.1060 -
 45.1061 -         pcmpeqw mm0, mm6
 45.1062 -         pcmpeqw mm1, mm7
 45.1063 -         pcmpeqw mm0, mm3
 45.1064 -         pand mm0, mm1
 45.1065 -         movq [Mask26], mm0
 45.1066 -
 45.1067 -         movq mm0, [eax+ebx+ebx+color1]
 45.1068 -         movq mm1, [eax+ebx+colorS2]
 45.1069 -         push eax
 45.1070 -         add eax, ebx
 45.1071 -         movq mm2, [eax+ebx+ebx+colorA1]
 45.1072 -         pop eax
 45.1073 -         movq mm3, [eax+colorB2]
 45.1074 -         pcmpeqw mm0, mm5
 45.1075 -         pcmpeqw mm1, mm5
 45.1076 -         pcmpeqw mm2, mm5
 45.1077 -         pcmpeqw mm3, mm5
 45.1078 -         pand mm0, mm1
 45.1079 -         pand mm2, mm3
 45.1080 -         por mm0, mm2
 45.1081 -         pand mm0, [Mask26]
 45.1082 -         movq [Mask26b], mm0
 45.1083 -
 45.1084 -         ;--------------------
 45.1085 -         movq mm0, mm4
 45.1086 -         movq mm1, mm5
 45.1087 -         movq mm2, mm0
 45.1088 -
 45.1089 -         pcmpeqw mm2, mm1
 45.1090 -         pcmpeqw mm0, mm6
 45.1091 -         pcmpeqw mm1, mm7
 45.1092 -         pand mm0, mm1
 45.1093 -         pand mm2, mm0
 45.1094 -         pxor mm0, mm2
 45.1095 -         movq mm7, mm0
 45.1096 -
 45.1097 -         ;------------------
 45.1098 -         packsswb mm7, mm7
 45.1099 -         movd ecx, mm7
 45.1100 -         test ecx, ecx
 45.1101 -         jz near .SKIP_GUESS
 45.1102 -
 45.1103 -;---------------------------------------------
 45.1104 -; Map of the pixels:                    I|E F|J
 45.1105 -;                                       G|A B|K
 45.1106 -;                                       H|C D|L
 45.1107 -;                                       M|N O|P
 45.1108 -         movq mm6, mm0
 45.1109 -         movq mm4, [eax+ebx+color5]
 45.1110 -         movq mm5, [eax+ebx+color6]
 45.1111 -         pxor mm7, mm7
 45.1112 -         pand mm6, [ONE]
 45.1113 -
 45.1114 -         movq mm0, [eax+colorB1]
 45.1115 -         movq mm1, [eax+ebx+color4]
 45.1116 -         movq mm2, mm0
 45.1117 -         movq mm3, mm1
 45.1118 -         pcmpeqw mm0, mm4
 45.1119 -         pcmpeqw mm1, mm4
 45.1120 -         pcmpeqw mm2, mm5
 45.1121 -         pcmpeqw mm3, mm5
 45.1122 -         pand mm0, mm6
 45.1123 -         pand mm1, mm6
 45.1124 -         pand mm2, mm6
 45.1125 -         pand mm3, mm6
 45.1126 -         paddw mm0, mm1
 45.1127 -         paddw mm2, mm3
 45.1128 -
 45.1129 -         pxor mm3, mm3
 45.1130 -         pcmpgtw mm0, mm6
 45.1131 -         pcmpgtw mm2, mm6
 45.1132 -         pcmpeqw mm0, mm3
 45.1133 -         pcmpeqw mm2, mm3
 45.1134 -         pand mm0, mm6
 45.1135 -         pand mm2, mm6
 45.1136 -         paddw mm7, mm0
 45.1137 -         psubw mm7, mm2
 45.1138 -
 45.1139 -         movq mm0, [eax+colorB2]
 45.1140 -         movq mm1, [eax+ebx+colorS2]
 45.1141 -         movq mm2, mm0
 45.1142 -         movq mm3, mm1
 45.1143 -         pcmpeqw mm0, mm4
 45.1144 -         pcmpeqw mm1, mm4
 45.1145 -         pcmpeqw mm2, mm5
 45.1146 -         pcmpeqw mm3, mm5
 45.1147 -         pand mm0, mm6
 45.1148 -         pand mm1, mm6
 45.1149 -         pand mm2, mm6
 45.1150 -         pand mm3, mm6
 45.1151 -         paddw mm0, mm1
 45.1152 -         paddw mm2, mm3
 45.1153 -
 45.1154 -         pxor mm3, mm3
 45.1155 -         pcmpgtw mm0, mm6
 45.1156 -         pcmpgtw mm2, mm6
 45.1157 -         pcmpeqw mm0, mm3
 45.1158 -         pcmpeqw mm2, mm3
 45.1159 -         pand mm0, mm6
 45.1160 -         pand mm2, mm6
 45.1161 -         paddw mm7, mm0
 45.1162 -         psubw mm7, mm2
 45.1163 -
 45.1164 -         push eax
 45.1165 -         add eax, ebx
 45.1166 -         movq mm0, [eax+ebx+color1]
 45.1167 -         movq mm1, [eax+ebx+ebx+colorA1]
 45.1168 -         movq mm2, mm0
 45.1169 -         movq mm3, mm1
 45.1170 -         pcmpeqw mm0, mm4
 45.1171 -         pcmpeqw mm1, mm4
 45.1172 -         pcmpeqw mm2, mm5
 45.1173 -         pcmpeqw mm3, mm5
 45.1174 -         pand mm0, mm6
 45.1175 -         pand mm1, mm6
 45.1176 -         pand mm2, mm6
 45.1177 -         pand mm3, mm6
 45.1178 -         paddw mm0, mm1
 45.1179 -         paddw mm2, mm3
 45.1180 -
 45.1181 -         pxor mm3, mm3
 45.1182 -         pcmpgtw mm0, mm6
 45.1183 -         pcmpgtw mm2, mm6
 45.1184 -         pcmpeqw mm0, mm3
 45.1185 -         pcmpeqw mm2, mm3
 45.1186 -         pand mm0, mm6
 45.1187 -         pand mm2, mm6
 45.1188 -         paddw mm7, mm0
 45.1189 -         psubw mm7, mm2
 45.1190 -
 45.1191 -         movq mm0, [eax+ebx+colorS1]
 45.1192 -         movq mm1, [eax+ebx+ebx+colorA2]
 45.1193 -         movq mm2, mm0
 45.1194 -         movq mm3, mm1
 45.1195 -         pcmpeqw mm0, mm4
 45.1196 -         pcmpeqw mm1, mm4
 45.1197 -         pcmpeqw mm2, mm5
 45.1198 -         pcmpeqw mm3, mm5
 45.1199 -         pand mm0, mm6
 45.1200 -         pand mm1, mm6
 45.1201 -         pand mm2, mm6
 45.1202 -         pand mm3, mm6
 45.1203 -         paddw mm0, mm1
 45.1204 -         paddw mm2, mm3
 45.1205 -
 45.1206 -         pxor mm3, mm3
 45.1207 -         pcmpgtw mm0, mm6
 45.1208 -         pcmpgtw mm2, mm6
 45.1209 -         pcmpeqw mm0, mm3
 45.1210 -         pcmpeqw mm2, mm3
 45.1211 -         pand mm0, mm6
 45.1212 -         pand mm2, mm6
 45.1213 -         paddw mm7, mm0
 45.1214 -         psubw mm7, mm2
 45.1215 -
 45.1216 -         pop eax
 45.1217 -         movq mm1, mm7
 45.1218 -         pxor mm0, mm0
 45.1219 -         pcmpgtw mm7, mm0
 45.1220 -         pcmpgtw mm0, mm1
 45.1221 -
 45.1222 -         por mm7, [Mask35]
 45.1223 -         por mm0, [Mask26]
 45.1224 -         movq [Mask35], mm7
 45.1225 -         movq [Mask26], mm0
 45.1226 -
 45.1227 -.SKIP_GUESS:
 45.1228 -         ;Start the ASSEMBLY !!!
 45.1229 -
 45.1230 -         movq mm4, [Mask35]
 45.1231 -         movq mm5, [Mask26]
 45.1232 -         movq mm6, [Mask35b]
 45.1233 -         movq mm7, [Mask26b]
 45.1234 -
 45.1235 -         movq mm0, [eax+ebx+color5]
 45.1236 -         movq mm1, [eax+ebx+color6]
 45.1237 -         movq mm2, [eax+ebx+ebx+color2]
 45.1238 -         movq mm3, [eax+ebx+ebx+color3]
 45.1239 -         pcmpeqw mm0, mm2
 45.1240 -         pcmpeqw mm1, mm3
 45.1241 -         movq mm2, mm4
 45.1242 -         movq mm3, mm5
 45.1243 -         por mm0, mm1
 45.1244 -         por mm2, mm3
 45.1245 -         pand mm2, mm0
 45.1246 -         pxor mm0, mm2
 45.1247 -         movq mm3, mm0
 45.1248 -
 45.1249 -         movq mm2, mm0
 45.1250 -         pxor mm0, mm0
 45.1251 -         por mm2, mm4
 45.1252 -         pxor mm4, mm6
 45.1253 -         por mm2, mm5
 45.1254 -         pxor mm5, mm7
 45.1255 -         pcmpeqw mm2, mm0
 45.1256 -         ;----------------
 45.1257 -
 45.1258 -         movq mm0, [eax+ebx+color5]
 45.1259 -         movq mm1, mm3
 45.1260 -         por mm1, mm4
 45.1261 -         por mm1, mm6
 45.1262 -         pand mm0, mm1
 45.1263 -         movq mm1, mm5
 45.1264 -         pand mm1, [I56Pixel]
 45.1265 -         por mm0, mm1
 45.1266 -         movq mm1, mm7
 45.1267 -         pand mm1, [product1b]
 45.1268 -         por mm0, mm1
 45.1269 -         movq mm1, mm2
 45.1270 -         pand mm1, [product1a]
 45.1271 -         por mm0, mm1
 45.1272 -         movq [final1a], mm0
 45.1273 -
 45.1274 -         movq mm0, [eax+ebx+color6]
 45.1275 -         movq mm1, mm3
 45.1276 -         por mm1, mm5
 45.1277 -         por mm1, mm7
 45.1278 -         pand mm0, mm1
 45.1279 -         movq mm1, mm4
 45.1280 -         pand mm1, [I56Pixel]
 45.1281 -         por mm0, mm1
 45.1282 -         movq mm1, mm6
 45.1283 -         pand mm1, [product1a]
 45.1284 -         por mm0, mm1
 45.1285 -         movq mm1, mm2
 45.1286 -         pand mm1, [product1b]
 45.1287 -         por mm0, mm1
 45.1288 -         movq [final1b], mm0
 45.1289 -
 45.1290 -         movq mm0, [eax+ebx+ebx+color2]
 45.1291 -         movq mm1, mm3
 45.1292 -         por mm1, mm5
 45.1293 -         por mm1, mm7
 45.1294 -         pand mm0, mm1
 45.1295 -         movq mm1, mm4
 45.1296 -         pand mm1, [I23Pixel]
 45.1297 -         por mm0, mm1
 45.1298 -         movq mm1, mm6
 45.1299 -         pand mm1, [product2b]
 45.1300 -         por mm0, mm1
 45.1301 -         movq mm1, mm2
 45.1302 -         pand mm1, [product2a]
 45.1303 -         por mm0, mm1
 45.1304 -         movq [final2a], mm0
 45.1305 -
 45.1306 -         movq mm0, [eax+ebx+ebx+color3]
 45.1307 -         movq mm1, mm3
 45.1308 -         por mm1, mm4
 45.1309 -         por mm1, mm6
 45.1310 -         pand mm0, mm1
 45.1311 -         movq mm1, mm5
 45.1312 -         pand mm1, [I23Pixel]
 45.1313 -         por mm0, mm1
 45.1314 -         movq mm1, mm7
 45.1315 -         pand mm1, [product2a]
 45.1316 -         por mm0, mm1
 45.1317 -         movq mm1, mm2
 45.1318 -         pand mm1, [product2b]
 45.1319 -         por mm0, mm1
 45.1320 -         movq [final2b], mm0
 45.1321 -
 45.1322 -
 45.1323 -         movq mm0, [final1a]
 45.1324 -         movq mm2, [final1b]
 45.1325 -         movq mm1, mm0
 45.1326 -         movq mm4, [final2a]
 45.1327 -         movq mm6, [final2b]
 45.1328 -         movq mm5, mm4
 45.1329 -         punpcklwd mm0, mm2
 45.1330 -         punpckhwd mm1, mm2
 45.1331 -         punpcklwd mm4, mm6
 45.1332 -         punpckhwd mm5, mm6
 45.1333 -
 45.1334 -
 45.1335 -
 45.1336 -
 45.1337 -%ifdef FAR_POINTER
 45.1338 -         movq [fs:edx], mm0
 45.1339 -         movq [fs:edx+8], mm1
 45.1340 -         push edx
 45.1341 -         add edx, [ebp+dstPitch]
 45.1342 -         movq [fs:edx], mm4
 45.1343 -         movq [fs:edx+8], mm5
 45.1344 -         pop edx
 45.1345 -%else
 45.1346 -         movq [edx], mm0
 45.1347 -         movq [edx+8], mm1
 45.1348 -         push edx
 45.1349 -         add edx, [ebp+dstPitch]
 45.1350 -         movq [edx], mm4
 45.1351 -         movq [edx+8], mm5
 45.1352 -         pop edx
 45.1353 -%endif
 45.1354 -.SKIP_PROCESS:
 45.1355 -         mov ecx, [ebp+deltaPtr]
 45.1356 -         add ecx, 8
 45.1357 -         mov [ebp+deltaPtr], ecx
 45.1358 -         add edx, 16
 45.1359 -         add eax, 8
 45.1360 -
 45.1361 -         pop ecx
 45.1362 -         sub ecx, 4
 45.1363 -         cmp ecx, 0
 45.1364 -         jg  near .Loop
 45.1365 -
 45.1366 -; Restore some stuff
 45.1367 -         popad
 45.1368 -         mov esp, ebp
 45.1369 -         pop ebp
 45.1370 -         emms
 45.1371 -         ret
 45.1372 -
 45.1373 -
 45.1374 -;-------------------------------------------------------------------------
 45.1375 -;-------------------------------------------------------------------------
 45.1376 -;-------------------------------------------------------------------------
 45.1377 -;-------------------------------------------------------------------------
 45.1378 -;-------------------------------------------------------------------------
 45.1379 -;-------------------------------------------------------------------------
 45.1380 -;-------------------------------------------------------------------------
 45.1381 -
 45.1382 -
 45.1383 -;This is version 0.50
 45.1384 -colorI   equ -2
 45.1385 -colorE   equ 0
 45.1386 -colorF   equ 2
 45.1387 -colorJ   equ 4
 45.1388 -
 45.1389 -colorG   equ -2
 45.1390 -colorA   equ 0
 45.1391 -colorB   equ 2
 45.1392 -colorK   equ 4
 45.1393 -
 45.1394 -colorH   equ -2
 45.1395 -colorC   equ 0
 45.1396 -colorD   equ 2
 45.1397 -colorL   equ 4
 45.1398 -
 45.1399 -colorM   equ -2
 45.1400 -colorN   equ 0
 45.1401 -colorO   equ 2
 45.1402 -colorP   equ 4
 45.1403 -
 45.1404 -%ifdef __DJGPP__
 45.1405 -__2xSaILine:
 45.1406 -%else
 45.1407 -_2xSaILine:
 45.1408 -%endif
 45.1409 -; Store some stuff
 45.1410 -         push ebp
 45.1411 -         mov ebp, esp
 45.1412 -         pushad
 45.1413 -
 45.1414 -; Prepare the destination
 45.1415 -%ifdef FAR_POINTER
 45.1416 -         ; Set the selector
 45.1417 -         mov eax, [ebp+dstSegment]
 45.1418 -         mov fs, ax
 45.1419 -%endif
 45.1420 -         mov edx, [ebp+dstOffset]         ; edx points to the screen
 45.1421 -; Prepare the source
 45.1422 -         ; eax points to colorA
 45.1423 -         mov eax, [ebp+srcPtr]
 45.1424 -         mov ebx, [ebp+srcPitch]
 45.1425 -         mov ecx, [ebp+width]
 45.1426 -         ; eax now points to colorE
 45.1427 -         sub eax, ebx
 45.1428 -
 45.1429 -
 45.1430 -; Main Loop
 45.1431 -.Loop:   push ecx
 45.1432 -
 45.1433 -         ;-----Check Delta------------------
 45.1434 -         mov ecx, [ebp+deltaPtr]
 45.1435 -
 45.1436 -         movq mm0, [eax+colorI]
 45.1437 -         movq mm1, [eax+colorJ]
 45.1438 -         movq mm2, [eax+ebx+colorG]
 45.1439 -         movq mm3, [eax+ebx+colorK]
 45.1440 -         movq mm4, [eax+ebx+ebx+colorH]
 45.1441 -         movq mm5, [eax+ebx+ebx+colorL]
 45.1442 -         push eax
 45.1443 -         add eax, ebx
 45.1444 -         movq mm6, [eax+ebx+ebx+colorM]
 45.1445 -         movq mm7, [eax+ebx+ebx+colorP]
 45.1446 -         pop eax
 45.1447 -
 45.1448 -         pcmpeqw mm0, [ecx+2+colorI]
 45.1449 -         pcmpeqw mm1, [ecx+2+colorK]
 45.1450 -         pcmpeqw mm2, [ecx+ebx+2+colorG]
 45.1451 -         pcmpeqw mm3, [ecx+ebx+2+colorK]
 45.1452 -         pcmpeqw mm4, [ecx+ebx+ebx+2+colorH]
 45.1453 -         pcmpeqw mm5, [ecx+ebx+ebx+2+colorL]
 45.1454 -         add ecx, ebx
 45.1455 -         pcmpeqw mm6, [ecx+ebx+ebx+2+colorM]
 45.1456 -         pcmpeqw mm7, [ecx+ebx+ebx+2+colorP]
 45.1457 -         sub ecx, ebx
 45.1458 -
 45.1459 -
 45.1460 -         pand mm0, mm1
 45.1461 -         pand mm2, mm3
 45.1462 -         pand mm4, mm5
 45.1463 -         pand mm6, mm7
 45.1464 -         pand mm0, mm2
 45.1465 -         pand mm4, mm6
 45.1466 -         pxor mm7, mm7
 45.1467 -         pand mm0, mm4
 45.1468 -         movq mm6, [eax+colorI]
 45.1469 -         pcmpeqw mm7, mm0
 45.1470 -
 45.1471 -         movq [ecx+2+colorI], mm6
 45.1472 -
 45.1473 -         packsswb mm7, mm7
 45.1474 -         movd ecx, mm7
 45.1475 -         test ecx, ecx
 45.1476 -         jz near .SKIP_PROCESS
 45.1477 -
 45.1478 -         ;End Delta
 45.1479 -
 45.1480 -         ;---------------------------------
 45.1481 -
 45.1482 -
 45.1483 -;1
 45.1484 -         ;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorE) && (colorB == colorL)
 45.1485 -         movq mm0, [eax+ebx+colorA]        ;mm0 and mm1 contain colorA
 45.1486 -         movq mm2, [eax+ebx+colorB]        ;mm2 and mm3 contain colorB
 45.1487 -
 45.1488 -         movq mm1, mm0
 45.1489 -         movq mm3, mm2
 45.1490 -
 45.1491 -         pcmpeqw mm0, [eax+ebx+ebx+colorD]
 45.1492 -         pcmpeqw mm1, [eax+colorE]
 45.1493 -         pcmpeqw mm2, [eax+ebx+ebx+colorL]
 45.1494 -         pcmpeqw mm3, [eax+ebx+ebx+colorC]
 45.1495 -
 45.1496 -         pand mm0, mm1
 45.1497 -         pxor mm1, mm1
 45.1498 -         pand mm0, mm2
 45.1499 -         pcmpeqw mm3, mm1
 45.1500 -         pand mm0, mm3                 ;result in mm0
 45.1501 -
 45.1502 -         ;if ((colorA == colorC) && (colorB != colorE) && (colorA == colorF) && (colorB == colorJ)
 45.1503 -         movq mm4, [eax+ebx+colorA]        ;mm4 and mm5 contain colorA
 45.1504 -         movq mm6, [eax+ebx+colorB]        ;mm6 and mm7 contain colorB
 45.1505 -         movq mm5, mm4
 45.1506 -         movq mm7, mm6
 45.1507 -
 45.1508 -         pcmpeqw mm4, [eax+ebx+ebx+colorC]
 45.1509 -         pcmpeqw mm5, [eax+colorF]
 45.1510 -         pcmpeqw mm6, [eax+colorJ]
 45.1511 -         pcmpeqw mm7, [eax+colorE]
 45.1512 -
 45.1513 -         pand mm4, mm5
 45.1514 -         pxor mm5, mm5
 45.1515 -         pand mm4, mm6
 45.1516 -         pcmpeqw mm7, mm5
 45.1517 -         pand mm4, mm7                 ;result in mm4
 45.1518 -
 45.1519 -         por mm0, mm4                  ;combine the masks
 45.1520 -         movq [Mask1], mm0
 45.1521 -
 45.1522 -         ;--------------------------------------------
 45.1523 -
 45.1524 -;2
 45.1525 -         ;if ((colorB == colorC) && (colorA != colorD) && (colorB == colorF) && (colorA == colorH)
 45.1526 -         movq mm0, [eax+ebx+colorB]        ;mm0 and mm1 contain colorB
 45.1527 -         movq mm2, [eax+ebx+colorA]        ;mm2 and mm3 contain colorA
 45.1528 -         movq mm1, mm0
 45.1529 -         movq mm3, mm2
 45.1530 -
 45.1531 -         pcmpeqw mm0, [eax+ebx+ebx+colorC]
 45.1532 -         pcmpeqw mm1, [eax+colorF]
 45.1533 -         pcmpeqw mm2, [eax+ebx+ebx+colorH]
 45.1534 -         pcmpeqw mm3, [eax+ebx+ebx+colorD]
 45.1535 -
 45.1536 -         pand mm0, mm1
 45.1537 -         pxor mm1, mm1
 45.1538 -         pand mm0, mm2
 45.1539 -         pcmpeqw mm3, mm1
 45.1540 -         pand mm0, mm3                 ;result in mm0
 45.1541 -
 45.1542 -         ;if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)
 45.1543 -         movq mm4, [eax+ebx+colorB]        ;mm4 and mm5 contain colorB
 45.1544 -         movq mm6, [eax+ebx+colorA]        ;mm6 and mm7 contain colorA
 45.1545 -         movq mm5, mm4
 45.1546 -         movq mm7, mm6
 45.1547 -
 45.1548 -         pcmpeqw mm4, [eax+ebx+ebx+colorD]
 45.1549 -         pcmpeqw mm5, [eax+colorE]
 45.1550 -         pcmpeqw mm6, [eax+colorI]
 45.1551 -         pcmpeqw mm7, [eax+colorF]
 45.1552 -
 45.1553 -         pand mm4, mm5
 45.1554 -         pxor mm5, mm5
 45.1555 -         pand mm4, mm6
 45.1556 -         pcmpeqw mm7, mm5
 45.1557 -         pand mm4, mm7                 ;result in mm4
 45.1558 -
 45.1559 -         por mm0, mm4                  ;combine the masks
 45.1560 -         movq [Mask2], mm0
 45.1561 -
 45.1562 -
 45.1563 -;interpolate colorA and colorB
 45.1564 -         movq mm0, [eax+ebx+colorA]
 45.1565 -         movq mm1, [eax+ebx+colorB]
 45.1566 -
 45.1567 -         movq mm2, mm0
 45.1568 -         movq mm3, mm1
 45.1569 -
 45.1570 -         pand mm0, [colorMask]
 45.1571 -         pand mm1, [colorMask]
 45.1572 -
 45.1573 -         psrlw mm0, 1
 45.1574 -         psrlw mm1, 1
 45.1575 -
 45.1576 -         pand mm3, [lowPixelMask]
 45.1577 -         paddw mm0, mm1
 45.1578 -
 45.1579 -         pand mm3, mm2
 45.1580 -         paddw mm0, mm3                ;mm0 contains the interpolated values
 45.1581 -
 45.1582 -         ;assemble the pixels
 45.1583 -         movq mm1, [eax+ebx+colorA]
 45.1584 -         movq mm2, [eax+ebx+colorB]
 45.1585 -
 45.1586 -         movq mm3, [Mask1]
 45.1587 -         movq mm5, mm1
 45.1588 -         movq mm4, [Mask2]
 45.1589 -         movq mm6, mm1
 45.1590 -
 45.1591 -         pand mm1, mm3
 45.1592 -         por mm3, mm4
 45.1593 -         pxor mm7, mm7
 45.1594 -         pand mm2, mm4
 45.1595 -
 45.1596 -         pcmpeqw mm3, mm7
 45.1597 -         por mm1, mm2
 45.1598 -         pand mm0, mm3
 45.1599 -
 45.1600 -         por mm0, mm1
 45.1601 -
 45.1602 -         punpcklwd mm5, mm0
 45.1603 -         punpckhwd mm6, mm0
 45.1604 -
 45.1605 -%ifdef FAR_POINTER
 45.1606 -         movq [fs:edx], mm5
 45.1607 -         movq [fs:edx+8], mm6
 45.1608 -%else
 45.1609 -         movq [edx], mm5
 45.1610 -         movq [edx+8], mm6
 45.1611 -%endif
 45.1612 -
 45.1613 -;------------------------------------------------
 45.1614 -;        Create the Nextline
 45.1615 -;------------------------------------------------
 45.1616 -;3       ;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorG) && (colorC == colorO)
 45.1617 -         movq mm0, [eax+ebx+colorA]        ;mm0 and mm1 contain colorA
 45.1618 -         movq mm2, [eax+ebx+ebx+colorC]        ;mm2 and mm3 contain colorC
 45.1619 -         movq mm1, mm0
 45.1620 -         movq mm3, mm2
 45.1621 -
 45.1622 -         push eax
 45.1623 -         add eax, ebx
 45.1624 -         pcmpeqw mm0, [eax+ebx+colorD]
 45.1625 -         pcmpeqw mm1, [eax+colorG]
 45.1626 -         pcmpeqw mm2, [eax+ebx+ebx+colorO]
 45.1627 -         pcmpeqw mm3, [eax+colorB]
 45.1628 -         pop eax
 45.1629 -
 45.1630 -         pand mm0, mm1
 45.1631 -         pxor mm1, mm1
 45.1632 -         pand mm0, mm2
 45.1633 -         pcmpeqw mm3, mm1
 45.1634 -         pand mm0, mm3                 ;result in mm0
 45.1635 -
 45.1636 -         ;if ((colorA == colorB) && (colorG != colorC) && (colorA == colorH) && (colorC == colorM)
 45.1637 -         movq mm4, [eax+ebx+colorA]        ;mm4 and mm5 contain colorA
 45.1638 -         movq mm6, [eax+ebx+ebx+colorC]        ;mm6 and mm7 contain colorC
 45.1639 -         movq mm5, mm4
 45.1640 -         movq mm7, mm6
 45.1641 -
 45.1642 -         push eax
 45.1643 -         add eax, ebx
 45.1644 -         pcmpeqw mm4, [eax+ebx+colorH]
 45.1645 -         pcmpeqw mm5, [eax+colorB]
 45.1646 -         pcmpeqw mm6, [eax+ebx+ebx+colorM]
 45.1647 -         pcmpeqw mm7, [eax+colorG]
 45.1648 -         pop eax
 45.1649 -
 45.1650 -         pand mm4, mm5
 45.1651 -         pxor mm5, mm5
 45.1652 -         pand mm4, mm6
 45.1653 -         pcmpeqw mm7, mm5
 45.1654 -         pand mm4, mm7                 ;result in mm4
 45.1655 -
 45.1656 -         por mm0, mm4                  ;combine the masks
 45.1657 -         movq [Mask1], mm0
 45.1658 -         ;--------------------------------------------
 45.1659 -
 45.1660 -;4
 45.1661 -         ;if ((colorB == colorC) && (colorA != colorD) && (colorC == colorH) && (colorA == colorF)
 45.1662 -         movq mm0, [eax+ebx+ebx+colorC]        ;mm0 and mm1 contain colorC
 45.1663 -         movq mm2, [eax+ebx+colorA]        ;mm2 and mm3 contain colorA
 45.1664 -         movq mm1, mm0
 45.1665 -         movq mm3, mm2
 45.1666 -
 45.1667 -         pcmpeqw mm0, [eax+ebx+colorB]
 45.1668 -         pcmpeqw mm1, [eax+ebx+ebx+colorH]
 45.1669 -         pcmpeqw mm2, [eax+colorF]
 45.1670 -         pcmpeqw mm3, [eax+ebx+ebx+colorD]
 45.1671 -
 45.1672 -         pand mm0, mm1
 45.1673 -         pxor mm1, mm1
 45.1674 -         pand mm0, mm2
 45.1675 -         pcmpeqw mm3, mm1
 45.1676 -         pand mm0, mm3                 ;result in mm0
 45.1677 -
 45.1678 -         ;if ((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI)
 45.1679 -         movq mm4, [eax+ebx+ebx+colorC]        ;mm4 and mm5 contain colorC
 45.1680 -         movq mm6, [eax+ebx+colorA]        ;mm6 and mm7 contain colorA
 45.1681 -         movq mm5, mm4
 45.1682 -         movq mm7, mm6
 45.1683 -
 45.1684 -         pcmpeqw mm4, [eax+ebx+ebx+colorD]
 45.1685 -         pcmpeqw mm5, [eax+ebx+colorG]
 45.1686 -         pcmpeqw mm6, [eax+colorI]
 45.1687 -         pcmpeqw mm7, [eax+ebx+ebx+colorH]
 45.1688 -
 45.1689 -         pand mm4, mm5
 45.1690 -         pxor mm5, mm5
 45.1691 -         pand mm4, mm6
 45.1692 -         pcmpeqw mm7, mm5
 45.1693 -         pand mm4, mm7                 ;result in mm4
 45.1694 -
 45.1695 -         por mm0, mm4                  ;combine the masks
 45.1696 -         movq [Mask2], mm0
 45.1697 -         ;----------------------------------------------
 45.1698 -
 45.1699 -;interpolate colorA and colorC
 45.1700 -         movq mm0, [eax+ebx+colorA]
 45.1701 -         movq mm1, [eax+ebx+ebx+colorC]
 45.1702 -
 45.1703 -         movq mm2, mm0
 45.1704 -         movq mm3, mm1
 45.1705 -
 45.1706 -         pand mm0, [colorMask]
 45.1707 -         pand mm1, [colorMask]
 45.1708 -
 45.1709 -         psrlw mm0, 1
 45.1710 -         psrlw mm1, 1
 45.1711 -
 45.1712 -         pand mm3, [lowPixelMask]
 45.1713 -         paddw mm0, mm1
 45.1714 -
 45.1715 -         pand mm3, mm2
 45.1716 -         paddw mm0, mm3                ;mm0 contains the interpolated values
 45.1717 -         ;-------------
 45.1718 -
 45.1719 -         ;assemble the pixels
 45.1720 -         movq mm1, [eax+ebx+colorA]
 45.1721 -         movq mm2, [eax+ebx+ebx+colorC]
 45.1722 -
 45.1723 -         movq mm3, [Mask1]
 45.1724 -         movq mm4, [Mask2]
 45.1725 -
 45.1726 -         pand mm1, mm3
 45.1727 -         pand mm2, mm4
 45.1728 -
 45.1729 -         por mm3, mm4
 45.1730 -         pxor mm7, mm7
 45.1731 -         por mm1, mm2
 45.1732 -
 45.1733 -         pcmpeqw mm3, mm7
 45.1734 -         pand mm0, mm3
 45.1735 -         por mm0, mm1
 45.1736 -         movq [ACPixel], mm0
 45.1737 -
 45.1738 -;////////////////////////////////
 45.1739 -; Decide which "branch" to take
 45.1740 -;--------------------------------
 45.1741 -         movq mm0, [eax+ebx+colorA]
 45.1742 -         movq mm1, [eax+ebx+colorB]
 45.1743 -         movq mm6, mm0
 45.1744 -         movq mm7, mm1
 45.1745 -         pcmpeqw mm0, [eax+ebx+ebx+colorD]
 45.1746 -         pcmpeqw mm1, [eax+ebx+ebx+colorC]
 45.1747 -         pcmpeqw mm6, mm7
 45.1748 -
 45.1749 -         movq mm2, mm0
 45.1750 -         movq mm3, mm0
 45.1751 -
 45.1752 -         pand mm0, mm1       ;colorA == colorD && colorB == colorC
 45.1753 -         pxor mm7, mm7
 45.1754 -
 45.1755 -         pcmpeqw mm2, mm7
 45.1756 -         pand mm6, mm0
 45.1757 -         pand mm2, mm1       ;colorA != colorD && colorB == colorC
 45.1758 -
 45.1759 -         pcmpeqw mm1, mm7
 45.1760 -
 45.1761 -         pand mm1, mm3       ;colorA == colorD && colorB != colorC
 45.1762 -         pxor mm0, mm6
 45.1763 -         por mm1, mm6
 45.1764 -         movq mm7, mm0
 45.1765 -         movq [Mask2], mm2
 45.1766 -         packsswb mm7, mm7
 45.1767 -         movq [Mask1], mm1
 45.1768 -
 45.1769 -         movd ecx, mm7
 45.1770 -         test ecx, ecx
 45.1771 -         jz near .SKIP_GUESS
 45.1772 -
 45.1773 -;---------------------------------------------
 45.1774 -; Map of the pixels:                    I|E F|J
 45.1775 -;                                       G|A B|K
 45.1776 -;                                       H|C D|L
 45.1777 -;                                       M|N O|P
 45.1778 -         movq mm6, mm0
 45.1779 -         movq mm4, [eax+ebx+colorA]
 45.1780 -         movq mm5, [eax+ebx+colorB]
 45.1781 -         pxor mm7, mm7
 45.1782 -         pand mm6, [ONE]
 45.1783 -
 45.1784 -         movq mm0, [eax+colorE]
 45.1785 -         movq mm1, [eax+ebx+colorG]
 45.1786 -         movq mm2, mm0
 45.1787 -         movq mm3, mm1
 45.1788 -         pcmpeqw mm0, mm4
 45.1789 -         pcmpeqw mm1, mm4
 45.1790 -         pcmpeqw mm2, mm5
 45.1791 -         pcmpeqw mm3, mm5
 45.1792 -         pand mm0, mm6
 45.1793 -         pand mm1, mm6
 45.1794 -         pand mm2, mm6
 45.1795 -         pand mm3, mm6
 45.1796 -         paddw mm0, mm1
 45.1797 -         paddw mm2, mm3
 45.1798 -
 45.1799 -         pxor mm3, mm3
 45.1800 -         pcmpgtw mm0, mm6
 45.1801 -         pcmpgtw mm2, mm6
 45.1802 -         pcmpeqw mm0, mm3
 45.1803 -         pcmpeqw mm2, mm3
 45.1804 -         pand mm0, mm6
 45.1805 -         pand mm2, mm6
 45.1806 -         paddw mm7, mm0
 45.1807 -         psubw mm7, mm2
 45.1808 -
 45.1809 -         movq mm0, [eax+colorF]
 45.1810 -         movq mm1, [eax+ebx+colorK]
 45.1811 -         movq mm2, mm0
 45.1812 -         movq mm3, mm1
 45.1813 -         pcmpeqw mm0, mm4
 45.1814 -         pcmpeqw mm1, mm4
 45.1815 -         pcmpeqw mm2, mm5
 45.1816 -         pcmpeqw mm3, mm5
 45.1817 -         pand mm0, mm6
 45.1818 -         pand mm1, mm6
 45.1819 -         pand mm2, mm6
 45.1820 -         pand mm3, mm6
 45.1821 -         paddw mm0, mm1
 45.1822 -         paddw mm2, mm3
 45.1823 -
 45.1824 -         pxor mm3, mm3
 45.1825 -         pcmpgtw mm0, mm6
 45.1826 -         pcmpgtw mm2, mm6
 45.1827 -         pcmpeqw mm0, mm3
 45.1828 -         pcmpeqw mm2, mm3
 45.1829 -         pand mm0, mm6
 45.1830 -         pand mm2, mm6
 45.1831 -         paddw mm7, mm0
 45.1832 -         psubw mm7, mm2
 45.1833 -
 45.1834 -         push eax
 45.1835 -         add eax, ebx
 45.1836 -         movq mm0, [eax+ebx+colorH]
 45.1837 -         movq mm1, [eax+ebx+ebx+colorN]
 45.1838 -         movq mm2, mm0
 45.1839 -         movq mm3, mm1
 45.1840 -         pcmpeqw mm0, mm4
 45.1841 -         pcmpeqw mm1, mm4
 45.1842 -         pcmpeqw mm2, mm5
 45.1843 -         pcmpeqw mm3, mm5
 45.1844 -         pand mm0, mm6
 45.1845 -         pand mm1, mm6
 45.1846 -         pand mm2, mm6
 45.1847 -         pand mm3, mm6
 45.1848 -         paddw mm0, mm1
 45.1849 -         paddw mm2, mm3
 45.1850 -
 45.1851 -         pxor mm3, mm3
 45.1852 -         pcmpgtw mm0, mm6
 45.1853 -         pcmpgtw mm2, mm6
 45.1854 -         pcmpeqw mm0, mm3
 45.1855 -         pcmpeqw mm2, mm3
 45.1856 -         pand mm0, mm6
 45.1857 -         pand mm2, mm6
 45.1858 -         paddw mm7, mm0
 45.1859 -         psubw mm7, mm2
 45.1860 -
 45.1861 -         movq mm0, [eax+ebx+colorL]
 45.1862 -         movq mm1, [eax+ebx+ebx+colorO]
 45.1863 -         movq mm2, mm0
 45.1864 -         movq mm3, mm1
 45.1865 -         pcmpeqw mm0, mm4
 45.1866 -         pcmpeqw mm1, mm4
 45.1867 -         pcmpeqw mm2, mm5
 45.1868 -         pcmpeqw mm3, mm5
 45.1869 -         pand mm0, mm6
 45.1870 -         pand mm1, mm6
 45.1871 -         pand mm2, mm6
 45.1872 -         pand mm3, mm6
 45.1873 -         paddw mm0, mm1
 45.1874 -         paddw mm2, mm3
 45.1875 -
 45.1876 -         pxor mm3, mm3
 45.1877 -         pcmpgtw mm0, mm6
 45.1878 -         pcmpgtw mm2, mm6
 45.1879 -         pcmpeqw mm0, mm3
 45.1880 -         pcmpeqw mm2, mm3
 45.1881 -         pand mm0, mm6
 45.1882 -         pand mm2, mm6
 45.1883 -         paddw mm7, mm0
 45.1884 -         psubw mm7, mm2
 45.1885 -
 45.1886 -         pop eax
 45.1887 -         movq mm1, mm7
 45.1888 -         pxor mm0, mm0
 45.1889 -         pcmpgtw mm7, mm0
 45.1890 -         pcmpgtw mm0, mm1
 45.1891 -
 45.1892 -         por mm7, [Mask1]
 45.1893 -         por mm0, [Mask2]
 45.1894 -         movq [Mask1], mm7
 45.1895 -         movq [Mask2], mm0
 45.1896 -
 45.1897 -.SKIP_GUESS:
 45.1898 -         ;----------------------------
 45.1899 -         ;interpolate A, B, C and D
 45.1900 -         movq mm0, [eax+ebx+colorA]
 45.1901 -         movq mm1, [eax+ebx+colorB]
 45.1902 -         movq mm4, mm0
 45.1903 -         movq mm2, [eax+ebx+ebx+colorC]
 45.1904 -         movq mm5, mm1
 45.1905 -         movq mm3, [qcolorMask]
 45.1906 -         movq mm6, mm2
 45.1907 -         movq mm7, [qlowpixelMask]
 45.1908 -
 45.1909 -         pand mm0, mm3
 45.1910 -         pand mm1, mm3
 45.1911 -         pand mm2, mm3
 45.1912 -         pand mm3, [eax+ebx+ebx+colorD]
 45.1913 -
 45.1914 -         psrlw mm0, 2
 45.1915 -         pand mm4, mm7
 45.1916 -         psrlw mm1, 2
 45.1917 -         pand mm5, mm7
 45.1918 -         psrlw mm2, 2
 45.1919 -         pand mm6, mm7
 45.1920 -         psrlw mm3, 2
 45.1921 -         pand mm7, [eax+ebx+ebx+colorD]
 45.1922 -
 45.1923 -         paddw mm0, mm1
 45.1924 -         paddw mm2, mm3
 45.1925 -
 45.1926 -         paddw mm4, mm5
 45.1927 -         paddw mm6, mm7
 45.1928 -
 45.1929 -         paddw mm4, mm6
 45.1930 -         paddw mm0, mm2
 45.1931 -         psrlw mm4, 2
 45.1932 -         pand mm4, [qlowpixelMask]
 45.1933 -         paddw mm0, mm4      ;mm0 contains the interpolated value of A, B, C and D
 45.1934 -
 45.1935 -;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 45.1936 -         ;assemble the pixels
 45.1937 -         movq mm1, [Mask1]
 45.1938 -         movq mm2, [Mask2]
 45.1939 -         movq mm4, [eax+ebx+colorA]
 45.1940 -         movq mm5, [eax+ebx+colorB]
 45.1941 -         pand mm4, mm1
 45.1942 -         pand mm5, mm2
 45.1943 -
 45.1944 -         pxor mm7, mm7
 45.1945 -         por mm1, mm2
 45.1946 -         por mm4, mm5
 45.1947 -         pcmpeqw mm1, mm7
 45.1948 -         pand mm0, mm1
 45.1949 -         por mm4, mm0        ;mm4 contains the diagonal pixels
 45.1950 -
 45.1951 -         movq mm0, [ACPixel]
 45.1952 -         movq mm1, mm0
 45.1953 -         punpcklwd mm0, mm4
 45.1954 -         punpckhwd mm1, mm4
 45.1955 -
 45.1956 -         push edx
 45.1957 -         add edx, [ebp+dstPitch]
 45.1958 -
 45.1959 -%ifdef FAR_POINTER
 45.1960 -         movq [fs:edx], mm0
 45.1961 -         movq [fs:edx+8], mm1
 45.1962 -%else
 45.1963 -         movq [edx], mm0
 45.1964 -         movq [edx+8], mm1
 45.1965 -%endif
 45.1966 -         pop edx
 45.1967 -
 45.1968 -.SKIP_PROCESS:
 45.1969 -         mov ecx, [ebp+deltaPtr]
 45.1970 -         add ecx, 8
 45.1971 -         mov [ebp+deltaPtr], ecx
 45.1972 -         add edx, 16
 45.1973 -         add eax, 8
 45.1974 -
 45.1975 -         pop ecx
 45.1976 -         sub ecx, 4
 45.1977 -         cmp ecx, 0
 45.1978 -         jg  near .Loop
 45.1979 -
 45.1980 -; Restore some stuff
 45.1981 -         popad
 45.1982 -         mov esp, ebp
 45.1983 -         pop ebp
 45.1984 -         emms
 45.1985 -         ret
 45.1986 -
 45.1987 -;-------------------------------------------------------------------------
 45.1988 -;-------------------------------------------------------------------------
 45.1989 -;-------------------------------------------------------------------------
 45.1990 -;-------------------------------------------------------------------------
 45.1991 -;-------------------------------------------------------------------------
 45.1992 -;-------------------------------------------------------------------------
 45.1993 -;-------------------------------------------------------------------------
 45.1994 -
 45.1995 -%ifdef __DJGPP__
 45.1996 -_Init_2xSaIMMX:
 45.1997 -%else
 45.1998 -Init_2xSaIMMX:
 45.1999 -%endif
 45.2000 -; Store some stuff
 45.2001 -         push ebp
 45.2002 -         mov ebp, esp
 45.2003 -         push edx
 45.2004 -
 45.2005 -
 45.2006 -;Damn thing doesn't work
 45.2007 -;        mov eax,1
 45.2008 -;        cpuid
 45.2009 -;        test edx, 0x00800000     ;test bit 23
 45.2010 -;        jz end2 ;bit not set => no MMX detected
 45.2011 -
 45.2012 -         mov eax, [ebp+8]         ;PixelFormat
 45.2013 -         cmp eax, 555
 45.2014 -         jz Bits555
 45.2015 -         cmp eax, 565
 45.2016 -         jz Bits565
 45.2017 -end2:
 45.2018 -         mov eax, 1
 45.2019 -         jmp end3
 45.2020 -Bits555:
 45.2021 -         mov edx, 0x7BDE7BDE
 45.2022 -         mov eax, colorMask
 45.2023 -         mov [eax], edx
 45.2024 -         mov [eax+4], edx
 45.2025 -         mov edx, 0x04210421
 45.2026 -         mov eax, lowPixelMask
 45.2027 -         mov [eax], edx
 45.2028 -         mov [eax+4], edx
 45.2029 -         mov edx, 0x739C739C
 45.2030 -         mov eax, qcolorMask
 45.2031 -         mov [eax], edx
 45.2032 -         mov [eax+4], edx
 45.2033 -         mov edx, 0x0C630C63
 45.2034 -         mov eax, qlowpixelMask
 45.2035 -         mov [eax], edx
 45.2036 -         mov [eax+4], edx
 45.2037 -         mov eax, 0
 45.2038 -         jmp end3
 45.2039 -Bits565:
 45.2040 -         mov edx, 0xF7DEF7DE
 45.2041 -         mov eax, colorMask
 45.2042 -         mov [eax], edx
 45.2043 -         mov [eax+4], edx
 45.2044 -         mov edx, 0x08210821
 45.2045 -         mov eax, lowPixelMask
 45.2046 -         mov [eax], edx
 45.2047 -         mov [eax+4], edx
 45.2048 -         mov edx, 0xE79CE79C
 45.2049 -         mov eax, qcolorMask
 45.2050 -         mov [eax], edx
 45.2051 -         mov [eax+4], edx
 45.2052 -         mov edx, 0x18631863
 45.2053 -         mov eax, qlowpixelMask
 45.2054 -         mov [eax], edx
 45.2055 -         mov [eax+4], edx
 45.2056 -         mov eax, 0
 45.2057 -         jmp end3
 45.2058 -end3:   
 45.2059 -         pop edx
 45.2060 -         mov esp, ebp
 45.2061 -         pop ebp
 45.2062 -         ret
 45.2063 -
 45.2064 -
 45.2065 -;-------------------------------------------------------------------------
 45.2066 -;-------------------------------------------------------------------------
 45.2067 -;-------------------------------------------------------------------------
 45.2068 -;-------------------------------------------------------------------------
 45.2069 -;-------------------------------------------------------------------------
 45.2070 -;-------------------------------------------------------------------------
 45.2071 -;-------------------------------------------------------------------------
 45.2072 -
 45.2073 -        SECTION .data ALIGN = 32
 45.2074 -;Some constants
 45.2075 -colorMask     dd 0xF7DEF7DE,0xF7DEF7DE
 45.2076 -lowPixelMask  dd 0x08210821,0x08210821
 45.2077 -
 45.2078 -qcolorMask    dd 0xE79CE79C,0xE79CE79C
 45.2079 -qlowpixelMask dd 0x18631863,0x18631863
 45.2080 -
 45.2081 -darkenMask    dd 0xC718C718,0xC718C718
 45.2082 -GreenMask     dd 0x07E007E0,0x07E007E0
 45.2083 -RedBlueMask   dd 0xF81FF81F,0xF81FF81F
 45.2084 -
 45.2085 -FALSE         dd 0x00000000,0x00000000
 45.2086 -TRUE          dd 0xffffffff,0xffffffff
 45.2087 -ONE           dd 0x00010001,0x00010001
 45.2088 -
 45.2089 -
 45.2090 -        SECTION .bss ALIGN = 32
 45.2091 -ACPixel       resb 8
 45.2092 -Mask1         resb 8
 45.2093 -Mask2         resb 8
 45.2094 -
 45.2095 -I56Pixel      resb 8
 45.2096 -I23Pixel      resb 8
 45.2097 -I5556Pixel    resb 8
 45.2098 -I2223Pixel    resb 8
 45.2099 -I5666Pixel    resb 8
 45.2100 -I2333Pixel    resb 8
 45.2101 -Mask26        resb 8
 45.2102 -Mask35        resb 8
 45.2103 -Mask26b       resb 8
 45.2104 -Mask35b       resb 8
 45.2105 -product1a     resb 8
 45.2106 -product1b     resb 8
 45.2107 -product2a     resb 8
 45.2108 -product2b     resb 8
 45.2109 -final1a       resb 8
 45.2110 -final1b       resb 8
 45.2111 -final2a       resb 8
 45.2112 -final2b       resb 8
    46.1 --- a/src/filters/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,22 +0,0 @@
    46.4 -SUFFIXES = .asm
    46.5 -
    46.6 -noinst_LIBRARIES = lib386.a libfilter.a
    46.7 -
    46.8 -lib386_a_SOURCES = 2xSaImmx.asm
    46.9 -
   46.10 -.asm.o:
   46.11 -	$(NASM) -f elf -o $@ $<
   46.12 -
   46.13 -libfilter_a_SOURCES = \
   46.14 -	2xSaI.cpp		\
   46.15 -	admame.cpp		\
   46.16 -	bilinear.cpp		\
   46.17 -	hq2x.cpp		\
   46.18 -	hq2x.h			\
   46.19 -	interframe.cpp		\
   46.20 -	interp.h		\
   46.21 -	lq2x.h			\
   46.22 -	motionblur.cpp		\
   46.23 -	pixel.cpp		\
   46.24 -	scanline.cpp		\
   46.25 -	simple2x.cpp
    47.1 --- a/src/filters/admame.cpp	Sat Mar 03 10:54:39 2012 -0600
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,1036 +0,0 @@
    47.4 -/*
    47.5 - * This file is part of the Advance project.
    47.6 - *
    47.7 - * Copyright (C) 1999-2002 Andrea Mazzoleni
    47.8 - *
    47.9 - * This program is free software; you can redistribute it and/or modify
   47.10 - * it under the terms of the GNU General Public License as published by
   47.11 - * the Free Software Foundation; either version 2 of the License, or
   47.12 - * (at your option) any later version.
   47.13 - *
   47.14 - * This program is distributed in the hope that it will be useful,
   47.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   47.17 - * GNU General Public License for more details.
   47.18 - *
   47.19 - * You should have received a copy of the GNU General Public License
   47.20 - * along with this program; if not, write to the Free Software
   47.21 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   47.22 - *
   47.23 - * In addition, as a special exception, Andrea Mazzoleni
   47.24 - * gives permission to link the code of this program with
   47.25 - * the MAME library (or with modified versions of MAME that use the
   47.26 - * same license as MAME), and distribute linked combinations including
   47.27 - * the two.  You must obey the GNU General Public License in all
   47.28 - * respects for all of the code used other than MAME.  If you modify
   47.29 - * this file, you may extend this exception to your version of the
   47.30 - * file, but you are not obligated to do so.  If you do not wish to
   47.31 - * do so, delete this exception statement from your version.
   47.32 - */
   47.33 -
   47.34 -/*
   47.35 - * Alternatively at the previous license terms, you are allowed to use this
   47.36 - * code in your program with these conditions:
   47.37 - * - the program is not used in commercial activities.
   47.38 - * - the whole source code of the program is released with the binary.
   47.39 - */
   47.40 -
   47.41 -#include "../Port.h"
   47.42 -
   47.43 -#ifdef MMX
   47.44 -extern "C" bool cpu_mmx;
   47.45 -#endif
   47.46 -
   47.47 -static void internal_scale2x_16_def(u16 *dst, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
   47.48 -{
   47.49 -	/* first pixel */
   47.50 -	dst[0] = src1[0];
   47.51 -	if (src1[1] == src0[0] && src2[0] != src0[0])
   47.52 -		dst[1] = src0[0];
   47.53 -	else
   47.54 -		dst[1] = src1[0];
   47.55 -	++src0;
   47.56 -	++src1;
   47.57 -	++src2;
   47.58 -	dst += 2;
   47.59 -
   47.60 -	/* central pixels */
   47.61 -	count -= 2;
   47.62 -	while (count)
   47.63 -	{
   47.64 -		if (src0[0] != src2[0] && src1[-1] != src1[1])
   47.65 -		{
   47.66 -			dst[0] = src1[-1] == src0[0] ? src0[0] : src1[0];
   47.67 -			dst[1] = src1[1] == src0[0] ? src0[0] : src1[0];
   47.68 -		}
   47.69 -		else
   47.70 -		{
   47.71 -			dst[0] = src1[0];
   47.72 -			dst[1] = src1[0];
   47.73 -		}
   47.74 -
   47.75 -		++src0;
   47.76 -		++src1;
   47.77 -		++src2;
   47.78 -		dst += 2;
   47.79 -		--count;
   47.80 -	}
   47.81 -
   47.82 -	/* last pixel */
   47.83 -	if (src1[-1] == src0[0] && src2[0] != src0[0])
   47.84 -		dst[0] = src0[0];
   47.85 -	else
   47.86 -		dst[0] = src1[0];
   47.87 -	dst[1] = src1[0];
   47.88 -}
   47.89 -
   47.90 -static void internal_scale2x_32_def(u32 *dst,
   47.91 -                                    const u32 *src0,
   47.92 -                                    const u32 *src1,
   47.93 -                                    const u32 *src2,
   47.94 -                                    unsigned count)
   47.95 -{
   47.96 -	/* first pixel */
   47.97 -	dst[0] = src1[0];
   47.98 -	if (src1[1] == src0[0] && src2[0] != src0[0])
   47.99 -		dst[1] = src0[0];
  47.100 -	else
  47.101 -		dst[1] = src1[0];
  47.102 -	++src0;
  47.103 -	++src1;
  47.104 -	++src2;
  47.105 -	dst += 2;
  47.106 -
  47.107 -	/* central pixels */
  47.108 -	count -= 2;
  47.109 -	while (count)
  47.110 -	{
  47.111 -		if (src0[0] != src2[0] && src1[-1] != src1[1])
  47.112 -		{
  47.113 -			dst[0] = src1[-1] == src0[0] ? src0[0] : src1[0];
  47.114 -			dst[1] = src1[1] == src0[0] ? src0[0] : src1[0];
  47.115 -		}
  47.116 -		else
  47.117 -		{
  47.118 -			dst[0] = src1[0];
  47.119 -			dst[1] = src1[0];
  47.120 -		}
  47.121 -
  47.122 -		++src0;
  47.123 -		++src1;
  47.124 -		++src2;
  47.125 -		dst += 2;
  47.126 -		--count;
  47.127 -	}
  47.128 -
  47.129 -	/* last pixel */
  47.130 -	if (src1[-1] == src0[0] && src2[0] != src0[0])
  47.131 -		dst[0] = src0[0];
  47.132 -	else
  47.133 -		dst[0] = src1[0];
  47.134 -	dst[1] = src1[0];
  47.135 -}
  47.136 -
  47.137 -#ifdef MMX
  47.138 -static void internal_scale2x_16_mmx_single(u16 *dst, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
  47.139 -{
  47.140 -	/* always do the first and last run */
  47.141 -	count -= 2 * 4;
  47.142 -
  47.143 -#ifdef __GNUC__
  47.144 -	__asm__ __volatile__ (
  47.145 -	    /* first run */
  47.146 -	    /* set the current, current_pre, current_next registers */
  47.147 -	    "movq 0(%1), %%mm0\n"
  47.148 -	    "movq 0(%1),%%mm7\n"
  47.149 -	    "movq 8(%1),%%mm1\n"
  47.150 -	    "psllq $48,%%mm0\n"
  47.151 -	    "psllq $48,%%mm1\n"
  47.152 -	    "psrlq $48, %%mm0\n"
  47.153 -	    "movq %%mm7,%%mm2\n"
  47.154 -	    "movq %%mm7,%%mm3\n"
  47.155 -	    "psllq $16,%%mm2\n"
  47.156 -	    "psrlq $16,%%mm3\n"
  47.157 -	    "por %%mm2,%%mm0\n"
  47.158 -	    "por %%mm3,%%mm1\n"
  47.159 -
  47.160 -	    /* current_upper */
  47.161 -	    "movq (%0),%%mm6\n"
  47.162 -
  47.163 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.164 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.165 -	    "movq %%mm0,%%mm2\n"
  47.166 -	    "movq %%mm1,%%mm4\n"
  47.167 -	    "movq %%mm0,%%mm3\n"
  47.168 -	    "movq %%mm1,%%mm5\n"
  47.169 -	    "pcmpeqw %%mm6,%%mm2\n"
  47.170 -	    "pcmpeqw %%mm6,%%mm4\n"
  47.171 -	    "pcmpeqw (%2),%%mm3\n"
  47.172 -	    "pcmpeqw (%2),%%mm5\n"
  47.173 -	    "pandn %%mm2,%%mm3\n"
  47.174 -	    "pandn %%mm4,%%mm5\n"
  47.175 -	    "movq %%mm0,%%mm2\n"
  47.176 -	    "movq %%mm1,%%mm4\n"
  47.177 -	    "pcmpeqw %%mm1,%%mm2\n"
  47.178 -	    "pcmpeqw %%mm0,%%mm4\n"
  47.179 -	    "pandn %%mm3,%%mm2\n"
  47.180 -	    "pandn %%mm5,%%mm4\n"
  47.181 -	    "movq %%mm2,%%mm3\n"
  47.182 -	    "movq %%mm4,%%mm5\n"
  47.183 -	    "pand %%mm6,%%mm2\n"
  47.184 -	    "pand %%mm6,%%mm4\n"
  47.185 -	    "pandn %%mm7,%%mm3\n"
  47.186 -	    "pandn %%mm7,%%mm5\n"
  47.187 -	    "por %%mm3,%%mm2\n"
  47.188 -	    "por %%mm5,%%mm4\n"
  47.189 -
  47.190 -	    /* set *dst */
  47.191 -	    "movq %%mm2,%%mm3\n"
  47.192 -	    "punpcklwd %%mm4,%%mm2\n"
  47.193 -	    "punpckhwd %%mm4,%%mm3\n"
  47.194 -	    "movq %%mm2,(%3)\n"
  47.195 -	    "movq %%mm3,8(%3)\n"
  47.196 -
  47.197 -	    /* next */
  47.198 -	    "addl $8,%0\n"
  47.199 -	    "addl $8,%1\n"
  47.200 -	    "addl $8,%2\n"
  47.201 -	    "addl $16,%3\n"
  47.202 -
  47.203 -	    /* central runs */
  47.204 -	    "shrl $2,%4\n"
  47.205 -	    "jz 1f\n"
  47.206 -
  47.207 -	    "0:\n"
  47.208 -
  47.209 -	    /* set the current, current_pre, current_next registers */
  47.210 -	    "movq -8(%1),%%mm0\n"
  47.211 -	    "movq (%1),%%mm7\n"
  47.212 -	    "movq 8(%1),%%mm1\n"
  47.213 -	    "psrlq $48,%%mm0\n"
  47.214 -	    "psllq $48,%%mm1\n"
  47.215 -	    "movq %%mm7,%%mm2\n"
  47.216 -	    "movq %%mm7,%%mm3\n"
  47.217 -	    "psllq $16,%%mm2\n"
  47.218 -	    "psrlq $16,%%mm3\n"
  47.219 -	    "por %%mm2,%%mm0\n"
  47.220 -	    "por %%mm3,%%mm1\n"
  47.221 -
  47.222 -	    /* current_upper */
  47.223 -	    "movq (%0),%%mm6\n"
  47.224 -
  47.225 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.226 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.227 -	    "movq %%mm0,%%mm2\n"
  47.228 -	    "movq %%mm1,%%mm4\n"
  47.229 -	    "movq %%mm0,%%mm3\n"
  47.230 -	    "movq %%mm1,%%mm5\n"
  47.231 -	    "pcmpeqw %%mm6,%%mm2\n"
  47.232 -	    "pcmpeqw %%mm6,%%mm4\n"
  47.233 -	    "pcmpeqw (%2),%%mm3\n"
  47.234 -	    "pcmpeqw (%2),%%mm5\n"
  47.235 -	    "pandn %%mm2,%%mm3\n"
  47.236 -	    "pandn %%mm4,%%mm5\n"
  47.237 -	    "movq %%mm0,%%mm2\n"
  47.238 -	    "movq %%mm1,%%mm4\n"
  47.239 -	    "pcmpeqw %%mm1,%%mm2\n"
  47.240 -	    "pcmpeqw %%mm0,%%mm4\n"
  47.241 -	    "pandn %%mm3,%%mm2\n"
  47.242 -	    "pandn %%mm5,%%mm4\n"
  47.243 -	    "movq %%mm2,%%mm3\n"
  47.244 -	    "movq %%mm4,%%mm5\n"
  47.245 -	    "pand %%mm6,%%mm2\n"
  47.246 -	    "pand %%mm6,%%mm4\n"
  47.247 -	    "pandn %%mm7,%%mm3\n"
  47.248 -	    "pandn %%mm7,%%mm5\n"
  47.249 -	    "por %%mm3,%%mm2\n"
  47.250 -	    "por %%mm5,%%mm4\n"
  47.251 -
  47.252 -	    /* set *dst */
  47.253 -	    "movq %%mm2,%%mm3\n"
  47.254 -	    "punpcklwd %%mm4,%%mm2\n"
  47.255 -	    "punpckhwd %%mm4,%%mm3\n"
  47.256 -	    "movq %%mm2,(%3)\n"
  47.257 -	    "movq %%mm3,8(%3)\n"
  47.258 -
  47.259 -	    /* next */
  47.260 -	    "addl $8,%0\n"
  47.261 -	    "addl $8,%1\n"
  47.262 -	    "addl $8,%2\n"
  47.263 -	    "addl $16,%3\n"
  47.264 -
  47.265 -	    "decl %4\n"
  47.266 -	    "jnz 0b\n"
  47.267 -	    "1:\n"
  47.268 -
  47.269 -	    /* final run */
  47.270 -	    /* set the current, current_pre, current_next registers */
  47.271 -	    "movq (%1),%%mm1\n"
  47.272 -	    "movq (%1),%%mm7\n"
  47.273 -	    "movq -8(%1),%%mm0\n"
  47.274 -	    "psrlq $48,%%mm1\n"
  47.275 -	    "psrlq $48,%%mm0\n"
  47.276 -	    "psllq $48,%%mm1\n"
  47.277 -	    "movq %%mm7,%%mm2\n"
  47.278 -	    "movq %%mm7,%%mm3\n"
  47.279 -	    "psllq $16,%%mm2\n"
  47.280 -	    "psrlq $16,%%mm3\n"
  47.281 -	    "por %%mm2,%%mm0\n"
  47.282 -	    "por %%mm3,%%mm1\n"
  47.283 -
  47.284 -	    /* current_upper */
  47.285 -	    "movq (%0),%%mm6\n"
  47.286 -
  47.287 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.288 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.289 -	    "movq %%mm0,%%mm2\n"
  47.290 -	    "movq %%mm1,%%mm4\n"
  47.291 -	    "movq %%mm0,%%mm3\n"
  47.292 -	    "movq %%mm1,%%mm5\n"
  47.293 -	    "pcmpeqw %%mm6,%%mm2\n"
  47.294 -	    "pcmpeqw %%mm6,%%mm4\n"
  47.295 -	    "pcmpeqw (%2),%%mm3\n"
  47.296 -	    "pcmpeqw (%2),%%mm5\n"
  47.297 -	    "pandn %%mm2,%%mm3\n"
  47.298 -	    "pandn %%mm4,%%mm5\n"
  47.299 -	    "movq %%mm0,%%mm2\n"
  47.300 -	    "movq %%mm1,%%mm4\n"
  47.301 -	    "pcmpeqw %%mm1,%%mm2\n"
  47.302 -	    "pcmpeqw %%mm0,%%mm4\n"
  47.303 -	    "pandn %%mm3,%%mm2\n"
  47.304 -	    "pandn %%mm5,%%mm4\n"
  47.305 -	    "movq %%mm2,%%mm3\n"
  47.306 -	    "movq %%mm4,%%mm5\n"
  47.307 -	    "pand %%mm6,%%mm2\n"
  47.308 -	    "pand %%mm6,%%mm4\n"
  47.309 -	    "pandn %%mm7,%%mm3\n"
  47.310 -	    "pandn %%mm7,%%mm5\n"
  47.311 -	    "por %%mm3,%%mm2\n"
  47.312 -	    "por %%mm5,%%mm4\n"
  47.313 -
  47.314 -	    /* set *dst */
  47.315 -	    "movq %%mm2,%%mm3\n"
  47.316 -	    "punpcklwd %%mm4,%%mm2\n"
  47.317 -	    "punpckhwd %%mm4,%%mm3\n"
  47.318 -	    "movq %%mm2,(%3)\n"
  47.319 -	    "movq %%mm3,8(%3)\n"
  47.320 -	    "emms\n"
  47.321 -
  47.322 -		: "+r" (src0), "+r" (src1), "+r" (src2), "+r" (dst), "+r" (count)
  47.323 -		:
  47.324 -		: "cc"
  47.325 -	    );
  47.326 -#else
  47.327 -	__asm {
  47.328 -		mov eax, src0;
  47.329 -		mov ebx, src1;
  47.330 -		mov ecx, src2;
  47.331 -		mov edx, dst;
  47.332 -		mov esi, count;
  47.333 -
  47.334 -		/* first run */
  47.335 -		/* set the current, current_pre, current_next registers */
  47.336 -		movq  mm0, qword ptr [ebx];
  47.337 -		movq  mm7, qword ptr [ebx];
  47.338 -		movq  mm1, qword ptr [ebx + 8];
  47.339 -		psllq mm0, 48;
  47.340 -		psllq mm1, 48;
  47.341 -		psrlq mm0, 48;
  47.342 -		movq  mm2, mm7;
  47.343 -		movq  mm3, mm7;
  47.344 -		psllq mm2, 16;
  47.345 -		psrlq mm3, 16;
  47.346 -		por	  mm0, mm2;
  47.347 -		por	  mm1, mm3;
  47.348 -
  47.349 -		/* current_upper */
  47.350 -		movq mm6, qword ptr [eax];
  47.351 -
  47.352 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.353 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.354 -		movq	mm2, mm0;
  47.355 -		movq	mm4, mm1;
  47.356 -		movq	mm3, mm0;
  47.357 -		movq	mm5, mm1;
  47.358 -		pcmpeqw mm2, mm6;
  47.359 -		pcmpeqw mm4, mm6;
  47.360 -		pcmpeqw mm3, qword ptr [ecx];
  47.361 -		pcmpeqw mm5, qword ptr [ecx];
  47.362 -		pandn	mm3, mm2;
  47.363 -		pandn	mm5, mm4;
  47.364 -		movq	mm2, mm0;
  47.365 -		movq	mm4, mm1;
  47.366 -		pcmpeqw mm2, mm1;
  47.367 -		pcmpeqw mm4, mm0;
  47.368 -		pandn	mm2, mm3;
  47.369 -		pandn	mm4, mm5;
  47.370 -		movq	mm3, mm2;
  47.371 -		movq	mm5, mm4;
  47.372 -		pand	mm2, mm6;
  47.373 -		pand	mm4, mm6;
  47.374 -		pandn	mm3, mm7;
  47.375 -		pandn	mm5, mm7;
  47.376 -		por		mm2, mm3;
  47.377 -		por		mm4, mm5;
  47.378 -
  47.379 -		/* set *dst0 */
  47.380 -		movq	   mm3, mm2;
  47.381 -		punpcklwd  mm2, mm4;
  47.382 -		punpckhwd  mm3, mm4;
  47.383 -		movq qword ptr [edx], mm2;
  47.384 -		movq qword ptr [edx + 8], mm3;
  47.385 -
  47.386 -		/* next */
  47.387 -		add eax, 8;
  47.388 -		add ebx, 8;
  47.389 -		add ecx, 8;
  47.390 -		add edx, 16;
  47.391 -
  47.392 -		/* central runs */
  47.393 -		shr esi, 2;
  47.394 -		jz	label1;
  47.395 -		align 4;
  47.396 -label0:
  47.397 -
  47.398 -		/* set the current, current_pre, current_next registers */
  47.399 -		movq mm0, qword ptr [ebx - 8];
  47.400 -		movq  mm7, qword ptr [ebx];
  47.401 -		movq  mm1, qword ptr [ebx + 8];
  47.402 -		psrlq mm0, 48;
  47.403 -		psllq mm1, 48;
  47.404 -		movq  mm2, mm7;
  47.405 -		movq  mm3, mm7;
  47.406 -		psllq mm2, 16;
  47.407 -		psrlq mm3, 16;
  47.408 -		por	  mm0, mm2;
  47.409 -		por	  mm1, mm3;
  47.410 -
  47.411 -		/* current_upper */
  47.412 -		movq mm6, qword ptr [eax];
  47.413 -
  47.414 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.415 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.416 -		movq	mm2, mm0;
  47.417 -		movq	mm4, mm1;
  47.418 -		movq	mm3, mm0;
  47.419 -		movq	mm5, mm1;
  47.420 -		pcmpeqw mm2, mm6;
  47.421 -		pcmpeqw mm4, mm6;
  47.422 -		pcmpeqw mm3, qword ptr [ecx];
  47.423 -		pcmpeqw mm5, qword ptr [ecx];
  47.424 -		pandn	mm3, mm2;
  47.425 -		pandn	mm5, mm4;
  47.426 -		movq	mm2, mm0;
  47.427 -		movq	mm4, mm1;
  47.428 -		pcmpeqw mm2, mm1;
  47.429 -		pcmpeqw mm4, mm0;
  47.430 -		pandn	mm2, mm3;
  47.431 -		pandn	mm4, mm5;
  47.432 -		movq	mm3, mm2;
  47.433 -		movq	mm5, mm4;
  47.434 -		pand	mm2, mm6;
  47.435 -		pand	mm4, mm6;
  47.436 -		pandn	mm3, mm7;
  47.437 -		pandn	mm5, mm7;
  47.438 -		por		mm2, mm3;
  47.439 -		por		mm4, mm5;
  47.440 -
  47.441 -		/* set *dst */
  47.442 -		movq	   mm3, mm2;
  47.443 -		punpcklwd  mm2, mm4;
  47.444 -		punpckhwd  mm3, mm4;
  47.445 -		movq qword ptr [edx], mm2;
  47.446 -		movq qword ptr [edx + 8], mm3;
  47.447 -
  47.448 -		/* next */
  47.449 -		add eax, 8;
  47.450 -		add ebx, 8;
  47.451 -		add ecx, 8;
  47.452 -		add edx, 16;
  47.453 -
  47.454 -		dec esi;
  47.455 -		jnz label0;
  47.456 -label1:
  47.457 -
  47.458 -		/* final run */
  47.459 -		/* set the current, current_pre, current_next registers */
  47.460 -		movq mm1, qword ptr [ebx];
  47.461 -		movq  mm7, qword ptr [ebx];
  47.462 -		movq  mm0, qword ptr [ebx - 8];
  47.463 -		psrlq mm1, 48;
  47.464 -		psrlq mm0, 48;
  47.465 -		psllq mm1, 48;
  47.466 -		movq  mm2, mm7;
  47.467 -		movq  mm3, mm7;
  47.468 -		psllq mm2, 16;
  47.469 -		psrlq mm3, 16;
  47.470 -		por	  mm0, mm2;
  47.471 -		por	  mm1, mm3;
  47.472 -
  47.473 -		/* current_upper */
  47.474 -		movq mm6, qword ptr [eax];
  47.475 -
  47.476 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.477 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.478 -		movq	mm2, mm0;
  47.479 -		movq	mm4, mm1;
  47.480 -		movq	mm3, mm0;
  47.481 -		movq	mm5, mm1;
  47.482 -		pcmpeqw mm2, mm6;
  47.483 -		pcmpeqw mm4, mm6;
  47.484 -		pcmpeqw mm3, qword ptr [ecx];
  47.485 -		pcmpeqw mm5, qword ptr [ecx];
  47.486 -		pandn	mm3, mm2;
  47.487 -		pandn	mm5, mm4;
  47.488 -		movq	mm2, mm0;
  47.489 -		movq	mm4, mm1;
  47.490 -		pcmpeqw mm2, mm1;
  47.491 -		pcmpeqw mm4, mm0;
  47.492 -		pandn	mm2, mm3;
  47.493 -		pandn	mm4, mm5;
  47.494 -		movq	mm3, mm2;
  47.495 -		movq	mm5, mm4;
  47.496 -		pand	mm2, mm6;
  47.497 -		pand	mm4, mm6;
  47.498 -		pandn	mm3, mm7;
  47.499 -		pandn	mm5, mm7;
  47.500 -		por		mm2, mm3;
  47.501 -		por		mm4, mm5;
  47.502 -
  47.503 -		/* set *dst */
  47.504 -		movq	   mm3, mm2;
  47.505 -		punpcklwd  mm2, mm4;
  47.506 -		punpckhwd  mm3, mm4;
  47.507 -		movq qword ptr [edx], mm2;
  47.508 -		movq qword ptr [edx + 8], mm3;
  47.509 -
  47.510 -		mov src0, eax;
  47.511 -		mov src1, ebx;
  47.512 -		mov src2, ecx;
  47.513 -		mov dst, edx;
  47.514 -		mov count, esi;
  47.515 -
  47.516 -		emms;
  47.517 -	}
  47.518 -#endif
  47.519 -}
  47.520 -
  47.521 -static void internal_scale2x_32_mmx_single(u32 *dst, const u32 *src0, const u32 *src1, const u32 *src2, unsigned count)
  47.522 -{
  47.523 -	/* always do the first and last run */
  47.524 -	count -= 2 * 2;
  47.525 -
  47.526 -#ifdef __GNUC__
  47.527 -	__asm__ __volatile__ (
  47.528 -	    /* first run */
  47.529 -	    /* set the current, current_pre, current_next registers */
  47.530 -	    "movq 0(%1),%%mm0\n"
  47.531 -	    "movq 0(%1),%%mm7\n"
  47.532 -	    "movq 8(%1),%%mm1\n"
  47.533 -	    "psllq $32,%%mm0\n"
  47.534 -	    "psllq $32,%%mm1\n"
  47.535 -	    "psrlq $32,%%mm0\n"
  47.536 -	    "movq %%mm7,%%mm2\n"
  47.537 -	    "movq %%mm7,%%mm3\n"
  47.538 -	    "psllq $32,%%mm2\n"
  47.539 -	    "psrlq $32,%%mm3\n"
  47.540 -	    "por %%mm2,%%mm0\n"
  47.541 -	    "por %%mm3,%%mm1\n"
  47.542 -
  47.543 -	    /* current_upper */
  47.544 -	    "movq (%0),%%mm6\n"
  47.545 -
  47.546 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.547 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.548 -	    "movq %%mm0,%%mm2\n"
  47.549 -	    "movq %%mm1,%%mm4\n"
  47.550 -	    "movq %%mm0,%%mm3\n"
  47.551 -	    "movq %%mm1,%%mm5\n"
  47.552 -	    "pcmpeqd %%mm6,%%mm2\n"
  47.553 -	    "pcmpeqd %%mm6,%%mm4\n"
  47.554 -	    "pcmpeqd (%2),%%mm3\n"
  47.555 -	    "pcmpeqd (%2),%%mm5\n"
  47.556 -	    "pandn %%mm2,%%mm3\n"
  47.557 -	    "pandn %%mm4,%%mm5\n"
  47.558 -	    "movq %%mm0,%%mm2\n"
  47.559 -	    "movq %%mm1,%%mm4\n"
  47.560 -	    "pcmpeqd %%mm1,%%mm2\n"
  47.561 -	    "pcmpeqd %%mm0,%%mm4\n"
  47.562 -	    "pandn %%mm3,%%mm2\n"
  47.563 -	    "pandn %%mm5,%%mm4\n"
  47.564 -	    "movq %%mm2,%%mm3\n"
  47.565 -	    "movq %%mm4,%%mm5\n"
  47.566 -	    "pand %%mm6,%%mm2\n"
  47.567 -	    "pand %%mm6,%%mm4\n"
  47.568 -	    "pandn %%mm7,%%mm3\n"
  47.569 -	    "pandn %%mm7,%%mm5\n"
  47.570 -	    "por %%mm3,%%mm2\n"
  47.571 -	    "por %%mm5,%%mm4\n"
  47.572 -
  47.573 -	    /* set *dst */
  47.574 -	    "movq %%mm2,%%mm3\n"
  47.575 -	    "punpckldq %%mm4,%%mm2\n"
  47.576 -	    "punpckhdq %%mm4,%%mm3\n"
  47.577 -	    "movq %%mm2,(%3)\n"
  47.578 -	    "movq %%mm3, 8(%3)\n"
  47.579 -
  47.580 -	    /* next */
  47.581 -	    "addl $8,%0\n"
  47.582 -	    "addl $8,%1\n"
  47.583 -	    "addl $8,%2\n"
  47.584 -	    "addl $16,%3\n"
  47.585 -
  47.586 -	    /* central runs */
  47.587 -	    "shrl $1,%4\n"
  47.588 -	    "jz 1f\n"
  47.589 -
  47.590 -	    "0:\n"
  47.591 -
  47.592 -	    /* set the current, current_pre, current_next registers */
  47.593 -	    "movq -8(%1),%%mm0\n"
  47.594 -	    "movq (%1),%%mm7\n"
  47.595 -	    "movq 8(%1),%%mm1\n"
  47.596 -	    "psrlq $32,%%mm0\n"
  47.597 -	    "psllq $32,%%mm1\n"
  47.598 -	    "movq %%mm7,%%mm2\n"
  47.599 -	    "movq %%mm7,%%mm3\n"
  47.600 -	    "psllq $32,%%mm2\n"
  47.601 -	    "psrlq $32,%%mm3\n"
  47.602 -	    "por %%mm2,%%mm0\n"
  47.603 -	    "por %%mm3,%%mm1\n"
  47.604 -
  47.605 -	    /* current_upper */
  47.606 -	    "movq (%0),%%mm6\n"
  47.607 -
  47.608 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.609 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.610 -	    "movq %%mm0,%%mm2\n"
  47.611 -	    "movq %%mm1,%%mm4\n"
  47.612 -	    "movq %%mm0,%%mm3\n"
  47.613 -	    "movq %%mm1,%%mm5\n"
  47.614 -	    "pcmpeqd %%mm6,%%mm2\n"
  47.615 -	    "pcmpeqd %%mm6,%%mm4\n"
  47.616 -	    "pcmpeqd (%2),%%mm3\n"
  47.617 -	    "pcmpeqd (%2),%%mm5\n"
  47.618 -	    "pandn %%mm2,%%mm3\n"
  47.619 -	    "pandn %%mm4,%%mm5\n"
  47.620 -	    "movq %%mm0,%%mm2\n"
  47.621 -	    "movq %%mm1,%%mm4\n"
  47.622 -	    "pcmpeqd %%mm1,%%mm2\n"
  47.623 -	    "pcmpeqd %%mm0,%%mm4\n"
  47.624 -	    "pandn %%mm3,%%mm2\n"
  47.625 -	    "pandn %%mm5,%%mm4\n"
  47.626 -	    "movq %%mm2,%%mm3\n"
  47.627 -	    "movq %%mm4,%%mm5\n"
  47.628 -	    "pand %%mm6,%%mm2\n"
  47.629 -	    "pand %%mm6,%%mm4\n"
  47.630 -	    "pandn %%mm7,%%mm3\n"
  47.631 -	    "pandn %%mm7,%%mm5\n"
  47.632 -	    "por %%mm3,%%mm2\n"
  47.633 -	    "por %%mm5,%%mm4\n"
  47.634 -
  47.635 -	    /* set *dst */
  47.636 -	    "movq %%mm2,%%mm3\n"
  47.637 -	    "punpckldq %%mm4,%%mm2\n"
  47.638 -	    "punpckhdq %%mm4,%%mm3\n"
  47.639 -	    "movq %%mm2,(%3)\n"
  47.640 -	    "movq %%mm3,8(%3)\n"
  47.641 -
  47.642 -	    /* next */
  47.643 -	    "addl $8,%0\n"
  47.644 -	    "addl $8,%1\n"
  47.645 -	    "addl $8,%2\n"
  47.646 -	    "addl $16,%3\n"
  47.647 -
  47.648 -	    "decl %4\n"
  47.649 -	    "jnz 0b\n"
  47.650 -	    "1:\n"
  47.651 -
  47.652 -	    /* final run */
  47.653 -	    /* set the current, current_pre, current_next registers */
  47.654 -	    "movq (%1),%%mm1\n"
  47.655 -	    "movq (%1),%%mm7\n"
  47.656 -	    "movq -8(%1), %%mm0\n"
  47.657 -	    "psrlq $32,%%mm1\n"
  47.658 -	    "psrlq $32,%%mm0\n"
  47.659 -	    "psllq $32,%%mm1\n"
  47.660 -	    "movq %%mm7,%%mm2\n"
  47.661 -	    "movq %%mm7,%%mm3\n"
  47.662 -	    "psllq $32,%%mm2\n"
  47.663 -	    "psrlq $32,%%mm3\n"
  47.664 -	    "por %%mm2,%%mm0\n"
  47.665 -	    "por %%mm3,%%mm1\n"
  47.666 -
  47.667 -	    /* current_upper */
  47.668 -	    "movq (%0),%%mm6\n"
  47.669 -
  47.670 -	    /* compute the upper-left pixel for dst on %%mm2 */
  47.671 -	    /* compute the upper-right pixel for dst on %%mm4 */
  47.672 -	    "movq %%mm0,%%mm2\n"
  47.673 -	    "movq %%mm1,%%mm4\n"
  47.674 -	    "movq %%mm0,%%mm3\n"
  47.675 -	    "movq %%mm1,%%mm5\n"
  47.676 -	    "pcmpeqd %%mm6,%%mm2\n"
  47.677 -	    "pcmpeqd %%mm6,%%mm4\n"
  47.678 -	    "pcmpeqd (%2),%%mm3\n"
  47.679 -	    "pcmpeqd (%2),%%mm5\n"
  47.680 -	    "pandn %%mm2,%%mm3\n"
  47.681 -	    "pandn %%mm4,%%mm5\n"
  47.682 -	    "movq %%mm0,%%mm2\n"
  47.683 -	    "movq %%mm1,%%mm4\n"
  47.684 -	    "pcmpeqd %%mm1,%%mm2\n"
  47.685 -	    "pcmpeqd %%mm0,%%mm4\n"
  47.686 -	    "pandn %%mm3,%%mm2\n"
  47.687 -	    "pandn %%mm5,%%mm4\n"
  47.688 -	    "movq %%mm2,%%mm3\n"
  47.689 -	    "movq %%mm4,%%mm5\n"
  47.690 -	    "pand %%mm6,%%mm2\n"
  47.691 -	    "pand %%mm6,%%mm4\n"
  47.692 -	    "pandn %%mm7,%%mm3\n"
  47.693 -	    "pandn %%mm7,%%mm5\n"
  47.694 -	    "por %%mm3,%%mm2\n"
  47.695 -	    "por %%mm5,%%mm4\n"
  47.696 -
  47.697 -	    /* set *dst */
  47.698 -	    "movq %%mm2,%%mm3\n"
  47.699 -	    "punpckldq %%mm4,%%mm2\n"
  47.700 -	    "punpckhdq %%mm4,%%mm3\n"
  47.701 -	    "movq %%mm2,(%3)\n"
  47.702 -	    "movq %%mm3,8(%3)\n"
  47.703 -	    "emms\n"
  47.704 -
  47.705 -		: "+r" (src0), "+r" (src1), "+r" (src2), "+r" (dst), "+r" (count)
  47.706 -		:
  47.707 -		: "cc"
  47.708 -	    );
  47.709 -#else
  47.710 -	__asm {
  47.711 -		mov eax, src0;
  47.712 -		mov ebx, src1;
  47.713 -		mov ecx, src2;
  47.714 -		mov edx, dst;
  47.715 -		mov esi, count;
  47.716 -
  47.717 -		/* first run */
  47.718 -		/* set the current, current_pre, current_next registers */
  47.719 -		movq  mm0, qword ptr [ebx];
  47.720 -		movq  mm7, qword ptr [ebx];
  47.721 -		movq  mm1, qword ptr [ebx + 8];
  47.722 -		psllq mm0, 32;
  47.723 -		psllq mm1, 32;
  47.724 -		psrlq mm0, 32;
  47.725 -		movq  mm2, mm7;
  47.726 -		movq  mm3, mm7;
  47.727 -		psllq mm2, 32;
  47.728 -		psrlq mm3, 32;
  47.729 -		por	  mm0, mm2;
  47.730 -		por	  mm1, mm3;
  47.731 -
  47.732 -		/* current_upper */
  47.733 -		movq mm6, qword ptr [eax];
  47.734 -
  47.735 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.736 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.737 -		movq	mm2, mm0;
  47.738 -		movq	mm4, mm1;
  47.739 -		movq	mm3, mm0;
  47.740 -		movq	mm5, mm1;
  47.741 -		pcmpeqd mm2, mm6;
  47.742 -		pcmpeqd mm4, mm6;
  47.743 -		pcmpeqd mm3, qword ptr [ecx];
  47.744 -		pcmpeqd mm5, qword ptr [ecx];
  47.745 -		pandn	mm3, mm2;
  47.746 -		pandn	mm5, mm4;
  47.747 -		movq	mm2, mm0;
  47.748 -		movq	mm4, mm1;
  47.749 -		pcmpeqd mm2, mm1;
  47.750 -		pcmpeqd mm4, mm0;
  47.751 -		pandn	mm2, mm3;
  47.752 -		pandn	mm4, mm5;
  47.753 -		movq	mm3, mm2;
  47.754 -		movq	mm5, mm4;
  47.755 -		pand	mm2, mm6;
  47.756 -		pand	mm4, mm6;
  47.757 -		pandn	mm3, mm7;
  47.758 -		pandn	mm5, mm7;
  47.759 -		por		mm2, mm3;
  47.760 -		por		mm4, mm5;
  47.761 -
  47.762 -		/* set *dst */
  47.763 -		movq	   mm3, mm2;
  47.764 -		punpckldq  mm2, mm4;
  47.765 -		punpckhdq  mm3, mm4;
  47.766 -		movq qword ptr [edx], mm2;
  47.767 -		movq qword ptr [edx + 8], mm3;
  47.768 -
  47.769 -		/* next */
  47.770 -		add eax, 8;
  47.771 -		add ebx, 8;
  47.772 -		add ecx, 8;
  47.773 -		add edx, 16;
  47.774 -
  47.775 -		/* central runs */
  47.776 -		shr esi, 1;
  47.777 -		jz	label1;
  47.778 -label0:
  47.779 -
  47.780 -		/* set the current, current_pre, current_next registers */
  47.781 -		movq mm0, qword ptr [ebx - 8];
  47.782 -		movq  mm7, qword ptr [ebx];
  47.783 -		movq  mm1, qword ptr [ebx + 8];
  47.784 -		psrlq mm0, 32;
  47.785 -		psllq mm1, 32;
  47.786 -		movq  mm2, mm7;
  47.787 -		movq  mm3, mm7;
  47.788 -		psllq mm2, 32;
  47.789 -		psrlq mm3, 32;
  47.790 -		por	  mm0, mm2;
  47.791 -		por	  mm1, mm3;
  47.792 -
  47.793 -		/* current_upper */
  47.794 -		movq mm6, qword ptr[eax];
  47.795 -
  47.796 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.797 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.798 -		movq	mm2, mm0;
  47.799 -		movq	mm4, mm1;
  47.800 -		movq	mm3, mm0;
  47.801 -		movq	mm5, mm1;
  47.802 -		pcmpeqd mm2, mm6;
  47.803 -		pcmpeqd mm4, mm6;
  47.804 -		pcmpeqd mm3, qword ptr[ecx];
  47.805 -		pcmpeqd mm5, qword ptr[ecx];
  47.806 -		pandn	mm3, mm2;
  47.807 -		pandn	mm5, mm4;
  47.808 -		movq	mm2, mm0;
  47.809 -		movq	mm4, mm1;
  47.810 -		pcmpeqd mm2, mm1;
  47.811 -		pcmpeqd mm4, mm0;
  47.812 -		pandn	mm2, mm3;
  47.813 -		pandn	mm4, mm5;
  47.814 -		movq	mm3, mm2;
  47.815 -		movq	mm5, mm4;
  47.816 -		pand	mm2, mm6;
  47.817 -		pand	mm4, mm6;
  47.818 -		pandn	mm3, mm7;
  47.819 -		pandn	mm5, mm7;
  47.820 -		por		mm2, mm3;
  47.821 -		por		mm4, mm5;
  47.822 -
  47.823 -		/* set *dst */
  47.824 -		movq	   mm3, mm2;
  47.825 -		punpckldq  mm2, mm4;
  47.826 -		punpckhdq  mm3, mm4;
  47.827 -		movq qword ptr [edx], mm2;
  47.828 -		movq qword ptr [edx + 8], mm3;
  47.829 -
  47.830 -		/* next */
  47.831 -		add eax, 8;
  47.832 -		add ebx, 8;
  47.833 -		add ecx, 8;
  47.834 -		add edx, 16;
  47.835 -
  47.836 -		dec esi;
  47.837 -		jnz label0;
  47.838 -label1:
  47.839 -
  47.840 -		/* final run */
  47.841 -		/* set the current, current_pre, current_next registers */
  47.842 -		movq mm1, qword ptr [ebx];
  47.843 -		movq  mm7, qword ptr [ebx];
  47.844 -		movq  mm0, qword ptr [ebx - 8];
  47.845 -		psrlq mm1, 32;
  47.846 -		psrlq mm0, 32;
  47.847 -		psllq mm1, 32;
  47.848 -		movq  mm2, mm7;
  47.849 -		movq  mm3, mm7;
  47.850 -		psllq mm2, 32;
  47.851 -		psrlq mm3, 32;
  47.852 -		por	  mm0, mm2;
  47.853 -		por	  mm1, mm3;
  47.854 -
  47.855 -		/* current_upper */
  47.856 -		movq mm6, qword ptr [eax];
  47.857 -
  47.858 -		/* compute the upper-left pixel for dst on %%mm2 */
  47.859 -		/* compute the upper-right pixel for dst on %%mm4 */
  47.860 -		movq	mm2, mm0;
  47.861 -		movq	mm4, mm1;
  47.862 -		movq	mm3, mm0;
  47.863 -		movq	mm5, mm1;
  47.864 -		pcmpeqd mm2, mm6;
  47.865 -		pcmpeqd mm4, mm6;
  47.866 -		pcmpeqd mm3, qword ptr [ecx];
  47.867 -		pcmpeqd mm5, qword ptr [ecx];
  47.868 -		pandn	mm3, mm2;
  47.869 -		pandn	mm5, mm4;
  47.870 -		movq	mm2, mm0;
  47.871 -		movq	mm4, mm1;
  47.872 -		pcmpeqd mm2, mm1;
  47.873 -		pcmpeqd mm4, mm0;
  47.874 -		pandn	mm2, mm3;
  47.875 -		pandn	mm4, mm5;
  47.876 -		movq	mm3, mm2;
  47.877 -		movq	mm5, mm4;
  47.878 -		pand	mm2, mm6;
  47.879 -		pand	mm4, mm6;
  47.880 -		pandn	mm3, mm7;
  47.881 -		pandn	mm5, mm7;
  47.882 -		por		mm2, mm3;
  47.883 -		por		mm4, mm5;
  47.884 -
  47.885 -		/* set *dst */
  47.886 -		movq	   mm3, mm2;
  47.887 -		punpckldq  mm2, mm4;
  47.888 -		punpckhdq  mm3, mm4;
  47.889 -		movq qword ptr [edx], mm2;
  47.890 -		movq qword ptr [edx + 8], mm3;
  47.891 -
  47.892 -		mov src0, eax;
  47.893 -		mov src1, ebx;
  47.894 -		mov src2, ecx;
  47.895 -		mov dst, edx;
  47.896 -		mov count, esi;
  47.897 -
  47.898 -		emms;
  47.899 -	}
  47.900 -#endif
  47.901 -}
  47.902 -
  47.903 -static void internal_scale2x_16_mmx(u16 *dst0, u16 *dst1, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
  47.904 -{
  47.905 -	//	assert( count >= 2*4 );
  47.906 -	internal_scale2x_16_mmx_single(dst0, src0, src1, src2, count);
  47.907 -	internal_scale2x_16_mmx_single(dst1, src2, src1, src0, count);
  47.908 -}
  47.909 -
  47.910 -static void internal_scale2x_32_mmx(u32 *dst0, u32 *dst1, const u32 *src0, const u32 *src1, const u32 *src2, unsigned count)
  47.911 -{
  47.912 -	//	assert( count >= 2*2 );
  47.913 -	internal_scale2x_32_mmx_single(dst0, src0, src1, src2, count);
  47.914 -	internal_scale2x_32_mmx_single(dst1, src2, src1, src0, count);
  47.915 -}
  47.916 -
  47.917 -#endif
  47.918 -
  47.919 -void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  47.920 -              u8 *dstPtr, u32 dstPitch, int width, int height)
  47.921 -{
  47.922 -	u16 *dst0 = (u16 *)dstPtr;
  47.923 -	u16 *dst1 = dst0 + (dstPitch >> 1);
  47.924 -
  47.925 -	u16 *src0 = (u16 *)srcPtr;
  47.926 -	u16 *src1 = src0 + (srcPitch >> 1);
  47.927 -	u16 *src2 = src1 + (srcPitch >> 1);
  47.928 -#ifdef MMX
  47.929 -	if (cpu_mmx)
  47.930 -	{
  47.931 -		internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width);
  47.932 -
  47.933 -		int count = height;
  47.934 -
  47.935 -		count -= 2;
  47.936 -		while (count)
  47.937 -		{
  47.938 -			dst0 += dstPitch;
  47.939 -			dst1 += dstPitch;
  47.940 -			internal_scale2x_16_mmx(dst0, dst1, src0, src1, src2, width);
  47.941 -			src0  = src1;
  47.942 -			src1  = src2;
  47.943 -			src2 += srcPitch >> 1;
  47.944 -			--count;
  47.945 -		}
  47.946 -		dst0 += dstPitch;
  47.947 -		dst1 += dstPitch;
  47.948 -		internal_scale2x_16_mmx(dst0, dst1, src0, src1, src1, width);
  47.949 -	}
  47.950 -	else
  47.951 -	{
  47.952 -#endif
  47.953 -	internal_scale2x_16_def(dst0, src0, src0, src1, width);
  47.954 -	internal_scale2x_16_def(dst1, src1, src0, src0, width);
  47.955 -
  47.956 -	int count = height;
  47.957 -
  47.958 -	count -= 2;
  47.959 -	while (count)
  47.960 -	{
  47.961 -		dst0 += dstPitch;
  47.962 -		dst1 += dstPitch;
  47.963 -		internal_scale2x_16_def(dst0, src0, src1, src2, width);
  47.964 -		internal_scale2x_16_def(dst1, src2, src1, src0, width);
  47.965 -		src0  = src1;
  47.966 -		src1  = src2;
  47.967 -		src2 += srcPitch >> 1;
  47.968 -		--count;
  47.969 -	}
  47.970 -	dst0 += dstPitch;
  47.971 -	dst1 += dstPitch;
  47.972 -	internal_scale2x_16_def(dst0, src0, src1, src1, width);
  47.973 -	internal_scale2x_16_def(dst1, src1, src1, src0, width);
  47.974 -#ifdef MMX
  47.975 -}
  47.976 -
  47.977 -#endif
  47.978 -}
  47.979 -
  47.980 -void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  47.981 -                u8 *dstPtr, u32 dstPitch, int width, int height)
  47.982 -{
  47.983 -	u32 *dst0 = (u32 *)dstPtr;
  47.984 -	u32 *dst1 = dst0 + (dstPitch >> 2);
  47.985 -
  47.986 -	u32 *src0 = (u32 *)srcPtr;
  47.987 -	u32 *src1 = src0 + (srcPitch >> 2);
  47.988 -	u32 *src2 = src1 + (srcPitch >> 2);
  47.989 -#ifdef MMX
  47.990 -	if (cpu_mmx)
  47.991 -	{
  47.992 -		internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width);
  47.993 -
  47.994 -		int count = height;
  47.995 -
  47.996 -		count -= 2;
  47.997 -		while (count)
  47.998 -		{
  47.999 -			dst0 += dstPitch >> 1;
 47.1000 -			dst1 += dstPitch >> 1;
 47.1001 -			internal_scale2x_32_mmx(dst0, dst1, src0, src1, src2, width);
 47.1002 -			src0  = src1;
 47.1003 -			src1  = src2;
 47.1004 -			src2 += srcPitch >> 2;
 47.1005 -			--count;
 47.1006 -		}
 47.1007 -		dst0 += dstPitch >> 1;
 47.1008 -		dst1 += dstPitch >> 1;
 47.1009 -		internal_scale2x_32_mmx(dst0, dst1, src0, src1, src1, width);
 47.1010 -	}
 47.1011 -	else
 47.1012 -	{
 47.1013 -#endif
 47.1014 -	internal_scale2x_32_def(dst0, src0, src0, src1, width);
 47.1015 -	internal_scale2x_32_def(dst1, src1, src0, src0, width);
 47.1016 -
 47.1017 -	int count = height;
 47.1018 -
 47.1019 -	count -= 2;
 47.1020 -	while (count)
 47.1021 -	{
 47.1022 -		dst0 += dstPitch >> 1;
 47.1023 -		dst1 += dstPitch >> 1;
 47.1024 -		internal_scale2x_32_def(dst0, src0, src1, src2, width);
 47.1025 -		internal_scale2x_32_def(dst1, src2, src1, src0, width);
 47.1026 -		src0  = src1;
 47.1027 -		src1  = src2;
 47.1028 -		src2 += srcPitch >> 2;
 47.1029 -		--count;
 47.1030 -	}
 47.1031 -	dst0 += dstPitch >> 1;
 47.1032 -	dst1 += dstPitch >> 1;
 47.1033 -	internal_scale2x_32_def(dst0, src0, src1, src1, width);
 47.1034 -	internal_scale2x_32_def(dst1, src1, src1, src0, width);
 47.1035 -#ifdef MMX
 47.1036 -}
 47.1037 -
 47.1038 -#endif
 47.1039 -}
    48.1 --- a/src/filters/bilinear.cpp	Sat Mar 03 10:54:39 2012 -0600
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,418 +0,0 @@
    48.4 -/**     Code adapted from Exult source code by Forgotten
    48.5 -**	Scale.cc - Trying to scale with bilinear interpolation.
    48.6 -**
    48.7 -**	Written: 6/14/00 - JSF
    48.8 -**/
    48.9 -
   48.10 -#include "../common/System.h"
   48.11 -
   48.12 -static u8 row_cur[3 * 322];
   48.13 -static u8 row_next[3 * 322];
   48.14 -
   48.15 -static u8 *rgb_row_cur	= row_cur;
   48.16 -static u8 *rgb_row_next = row_next;
   48.17 -
   48.18 -#ifdef RGB
   48.19 -#undef RGB  // wingdi.h has it
   48.20 -#endif
   48.21 -#define RGB(r, g, b) \
   48.22 -    ((r) >> 3) << systemRedShift | \
   48.23 -    ((g) >> 3) << systemGreenShift | \
   48.24 -    ((b) >> 3) << systemBlueShift \
   48.25 -
   48.26 -static void fill_rgb_row_16(u16 *from, int src_width, u8 *row, int width)
   48.27 -{
   48.28 -	u8 *copy_start = row + src_width * 3;
   48.29 -	u8 *all_stop   = row + width * 3;
   48.30 -	while (row < copy_start)
   48.31 -	{
   48.32 -		u16 color = *from++;
   48.33 -		*row++ = ((color >> systemRedShift) & 0x1f) << 3;
   48.34 -		*row++ = ((color >> systemGreenShift) & 0x1f) << 3;
   48.35 -		*row++ = ((color >> systemBlueShift) & 0x1f) << 3;
   48.36 -	}
   48.37 -	// any remaining elements to be written to 'row' are a replica of the
   48.38 -	// preceding pixel
   48.39 -	u8 *p = row - 3;
   48.40 -	while (row < all_stop)
   48.41 -	{
   48.42 -		// we're guaranteed three elements per pixel; could unroll the loop
   48.43 -		// further, especially with a Duff's Device, but the gains would be
   48.44 -		// probably limited (judging by profiler output)
   48.45 -		*row++ = *p++;
   48.46 -		*row++ = *p++;
   48.47 -		*row++ = *p++;
   48.48 -	}
   48.49 -}
   48.50 -
   48.51 -static void fill_rgb_row_32(u32 *from, int src_width, u8 *row, int width)
   48.52 -{
   48.53 -	u8 *copy_start = row + src_width * 3;
   48.54 -	u8 *all_stop   = row + width * 3;
   48.55 -	while (row < copy_start)
   48.56 -	{
   48.57 -		u32 color = *from++;
   48.58 -		*row++ = ((color >> systemRedShift) & 0x1f) << 3;
   48.59 -		*row++ = ((color >> systemGreenShift) & 0x1f) << 3;
   48.60 -		*row++ = ((color >> systemBlueShift) & 0x1f) << 3;
   48.61 -	}
   48.62 -	// any remaining elements to be written to 'row' are a replica of the
   48.63 -	// preceding pixel
   48.64 -	u8 *p = row - 3;
   48.65 -	while (row < all_stop)
   48.66 -	{
   48.67 -		// we're guaranteed three elements per pixel; could unroll the loop
   48.68 -		// further, especially with a Duff's Device, but the gains would be
   48.69 -		// probably limited (judging by profiler output)
   48.70 -		*row++ = *p++;
   48.71 -		*row++ = *p++;
   48.72 -		*row++ = *p++;
   48.73 -	}
   48.74 -}
   48.75 -
   48.76 -void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
   48.77 -              u8 *dstPtr, u32 dstPitch, int width, int height)
   48.78 -{
   48.79 -	u16 *to		= (u16 *)dstPtr;
   48.80 -	u16 *to_odd = (u16 *)(dstPtr + dstPitch);
   48.81 -
   48.82 -	int	 from_width = width;
   48.83 -	u16 *from		= (u16 *)srcPtr;
   48.84 -	fill_rgb_row_16(from, from_width, rgb_row_cur, width + 1);
   48.85 -
   48.86 -	for (int y = 0; y < height; y++)
   48.87 -	{
   48.88 -		u16 *from_orig = from;
   48.89 -		u16 *to_orig   = to;
   48.90 -
   48.91 -		if (y + 1 < height)
   48.92 -			fill_rgb_row_16(from + width + 2, from_width, rgb_row_next,
   48.93 -			                width + 1);
   48.94 -		else
   48.95 -			fill_rgb_row_16(from, from_width, rgb_row_next, width + 1);
   48.96 -
   48.97 -		// every pixel in the src region, is extended to 4 pixels in the
   48.98 -		// destination, arranged in a square 'quad'; if the current src
   48.99 -		// pixel is 'a', then in what follows 'b' is the src pixel to the
  48.100 -		// right, 'c' is the src pixel below, and 'd' is the src pixel to
  48.101 -		// the right and down
  48.102 -		u8 *cur_row	 = rgb_row_cur;
  48.103 -		u8 *next_row = rgb_row_next;
  48.104 -		u8 *ar		 = cur_row++;
  48.105 -		u8 *ag		 = cur_row++;
  48.106 -		u8 *ab		 = cur_row++;
  48.107 -		u8 *cr		 = next_row++;
  48.108 -		u8 *cg		 = next_row++;
  48.109 -		u8 *cb		 = next_row++;
  48.110 -		for (int x = 0; x < width; x++)
  48.111 -		{
  48.112 -			u8 *br = cur_row++;
  48.113 -			u8 *bg = cur_row++;
  48.114 -			u8 *bb = cur_row++;
  48.115 -			u8 *dr = next_row++;
  48.116 -			u8 *dg = next_row++;
  48.117 -			u8 *db = next_row++;
  48.118 -
  48.119 -			// upper left pixel in quad: just copy it in
  48.120 -			*to++ = RGB(*ar, *ag, *ab);
  48.121 -
  48.122 -			// upper right
  48.123 -			*to++ = RGB((*ar + *br) >> 1, (*ag + *bg) >> 1, (*ab + *bb) >> 1);
  48.124 -
  48.125 -			// lower left
  48.126 -			*to_odd++ = RGB((*ar + *cr) >> 1, (*ag + *cg) >> 1, (*ab + *cb) >> 1);
  48.127 -
  48.128 -			// lower right
  48.129 -			*to_odd++ = RGB((*ar + *br + *cr + *dr) >> 2,
  48.130 -			                (*ag + *bg + *cg + *dg) >> 2,
  48.131 -			                (*ab + *bb + *cb + *db) >> 2);
  48.132 -
  48.133 -			// 'b' becomes 'a', 'd' becomes 'c'
  48.134 -			ar = br;
  48.135 -			ag = bg;
  48.136 -			ab = bb;
  48.137 -			cr = dr;
  48.138 -			cg = dg;
  48.139 -			cb = db;
  48.140 -		}
  48.141 -
  48.142 -		// the "next" rgb row becomes the current; the old current rgb row is
  48.143 -		// recycled and serves as the new "next" row
  48.144 -		u8 *temp;
  48.145 -		temp		 = rgb_row_cur;
  48.146 -		rgb_row_cur	 = rgb_row_next;
  48.147 -		rgb_row_next = temp;
  48.148 -
  48.149 -		// update the pointers for start of next pair of lines
  48.150 -		from   = (u16 *)((u8 *)from_orig + srcPitch);
  48.151 -		to	   = (u16 *)((u8 *)to_orig + (dstPitch << 1));
  48.152 -		to_odd = (u16 *)((u8 *)to + dstPitch);
  48.153 -	}
  48.154 -}
  48.155 -
  48.156 -void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  48.157 -                  u8 *dstPtr, u32 dstPitch, int width, int height)
  48.158 -{
  48.159 -	u16 *to		= (u16 *)dstPtr;
  48.160 -	u16 *to_odd = (u16 *)(dstPtr + dstPitch);
  48.161 -
  48.162 -	int	 from_width = width;
  48.163 -	u16 *from		= (u16 *)srcPtr;
  48.164 -	fill_rgb_row_16(from, from_width, rgb_row_cur, width + 1);
  48.165 -
  48.166 -	for (int y = 0; y < height; y++)
  48.167 -	{
  48.168 -		u16 *from_orig = from;
  48.169 -		u16 *to_orig   = to;
  48.170 -
  48.171 -		if (y + 1 < height)
  48.172 -			fill_rgb_row_16(from + width + 2, from_width, rgb_row_next,
  48.173 -			                width + 1);
  48.174 -		else
  48.175 -			fill_rgb_row_16(from, from_width, rgb_row_next, width + 1);
  48.176 -
  48.177 -		// every pixel in the src region, is extended to 4 pixels in the
  48.178 -		// destination, arranged in a square 'quad'; if the current src
  48.179 -		// pixel is 'a', then in what follows 'b' is the src pixel to the
  48.180 -		// right, 'c' is the src pixel below, and 'd' is the src pixel to
  48.181 -		// the right and down
  48.182 -		u8 *cur_row	 = rgb_row_cur;
  48.183 -		u8 *next_row = rgb_row_next;
  48.184 -		u8 *ar		 = cur_row++;
  48.185 -		u8 *ag		 = cur_row++;
  48.186 -		u8 *ab		 = cur_row++;
  48.187 -		u8 *cr		 = next_row++;
  48.188 -		u8 *cg		 = next_row++;
  48.189 -		u8 *cb		 = next_row++;
  48.190 -		for (int x = 0; x < width; x++)
  48.191 -		{
  48.192 -			u8 *br = cur_row++;
  48.193 -			u8 *bg = cur_row++;
  48.194 -			u8 *bb = cur_row++;
  48.195 -			u8 *dr = next_row++;
  48.196 -			u8 *dg = next_row++;
  48.197 -			u8 *db = next_row++;
  48.198 -
  48.199 -			// upper left pixel in quad: just copy it in
  48.200 -			//*to++ = manip.rgb(*ar, *ag, *ab);
  48.201 -#ifdef USE_ORIGINAL_BILINEAR_PLUS
  48.202 -			*to++ = RGB(
  48.203 -			    (((*ar) << 2) + ((*ar)) + (*cr + *br + *br)) >> 3,
  48.204 -			    (((*ag) << 2) + ((*ag)) + (*cg + *bg + *bg)) >> 3,
  48.205 -			    (((*ab) << 2) + ((*ab)) + (*cb + *bb + *bb)) >> 3);
  48.206 -#else
  48.207 -			*to++ = RGB(
  48.208 -			    (((*ar) << 3) + ((*ar) << 1) + (*cr + *br + *br + *cr)) >> 4,
  48.209 -			    (((*ag) << 3) + ((*ag) << 1) + (*cg + *bg + *bg + *cg)) >> 4,
  48.210 -			    (((*ab) << 3) + ((*ab) << 1) + (*cb + *bb + *bb + *cb)) >> 4);
  48.211 -#endif
  48.212 -
  48.213 -			// upper right
  48.214 -			*to++ = RGB((*ar + *br) >> 1, (*ag + *bg) >> 1, (*ab + *bb) >> 1);
  48.215 -
  48.216 -			// lower left
  48.217 -			*to_odd++ = RGB((*ar + *cr) >> 1, (*ag + *cg) >> 1, (*ab + *cb) >> 1);
  48.218 -
  48.219 -			// lower right
  48.220 -			*to_odd++ = RGB((*ar + *br + *cr + *dr) >> 2,
  48.221 -			                (*ag + *bg + *cg + *dg) >> 2,
  48.222 -			                (*ab + *bb + *cb + *db) >> 2);
  48.223 -
  48.224 -			// 'b' becomes 'a', 'd' becomes 'c'
  48.225 -			ar = br;
  48.226 -			ag = bg;
  48.227 -			ab = bb;
  48.228 -			cr = dr;
  48.229 -			cg = dg;
  48.230 -			cb = db;
  48.231 -		}
  48.232 -
  48.233 -		// the "next" rgb row becomes the current; the old current rgb row is
  48.234 -		// recycled and serves as the new "next" row
  48.235 -		u8 *temp;
  48.236 -		temp		 = rgb_row_cur;
  48.237 -		rgb_row_cur	 = rgb_row_next;
  48.238 -		rgb_row_next = temp;
  48.239 -
  48.240 -		// update the pointers for start of next pair of lines
  48.241 -		from   = (u16 *)((u8 *)from_orig + srcPitch);
  48.242 -		to	   = (u16 *)((u8 *)to_orig + (dstPitch << 1));
  48.243 -		to_odd = (u16 *)((u8 *)to + dstPitch);
  48.244 -	}
  48.245 -}
  48.246 -
  48.247 -void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  48.248 -                u8 *dstPtr, u32 dstPitch, int width, int height)
  48.249 -{
  48.250 -	u32 *to		= (u32 *)dstPtr;
  48.251 -	u32 *to_odd = (u32 *)(dstPtr + dstPitch);
  48.252 -
  48.253 -	int from_width = width;
  48.254 -	if (width + 1 < from_width)
  48.255 -		from_width = width + 1;
  48.256 -	u32 *from = (u32 *)srcPtr;
  48.257 -	fill_rgb_row_32(from, from_width, rgb_row_cur, width + 1);
  48.258 -
  48.259 -	for (int y = 0; y < height; y++)
  48.260 -	{
  48.261 -		u32 *from_orig = from;
  48.262 -		u32 *to_orig   = to;
  48.263 -
  48.264 -		if (y + 1 < height)
  48.265 -			fill_rgb_row_32(from + width + 1, from_width, rgb_row_next,
  48.266 -			                width + 1);
  48.267 -		else
  48.268 -			fill_rgb_row_32(from, from_width, rgb_row_next, width + 1);
  48.269 -
  48.270 -		// every pixel in the src region, is extended to 4 pixels in the
  48.271 -		// destination, arranged in a square 'quad'; if the current src
  48.272 -		// pixel is 'a', then in what follows 'b' is the src pixel to the
  48.273 -		// right, 'c' is the src pixel below, and 'd' is the src pixel to
  48.274 -		// the right and down
  48.275 -		u8 *cur_row	 = rgb_row_cur;
  48.276 -		u8 *next_row = rgb_row_next;
  48.277 -		u8 *ar		 = cur_row++;
  48.278 -		u8 *ag		 = cur_row++;
  48.279 -		u8 *ab		 = cur_row++;
  48.280 -		u8 *cr		 = next_row++;
  48.281 -		u8 *cg		 = next_row++;
  48.282 -		u8 *cb		 = next_row++;
  48.283 -		for (int x = 0; x < width; x++)
  48.284 -		{
  48.285 -			u8 *br = cur_row++;
  48.286 -			u8 *bg = cur_row++;
  48.287 -			u8 *bb = cur_row++;
  48.288 -			u8 *dr = next_row++;
  48.289 -			u8 *dg = next_row++;
  48.290 -			u8 *db = next_row++;
  48.291 -
  48.292 -			// upper left pixel in quad: just copy it in
  48.293 -			*to++ = RGB(*ar, *ag, *ab);
  48.294 -
  48.295 -			// upper right
  48.296 -			*to++ = RGB((*ar + *br) >> 1, (*ag + *bg) >> 1, (*ab + *bb) >> 1);
  48.297 -
  48.298 -			// lower left
  48.299 -			*to_odd++ = RGB((*ar + *cr) >> 1, (*ag + *cg) >> 1, (*ab + *cb) >> 1);
  48.300 -
  48.301 -			// lower right
  48.302 -			*to_odd++ = RGB((*ar + *br + *cr + *dr) >> 2,
  48.303 -			                (*ag + *bg + *cg + *dg) >> 2,
  48.304 -			                (*ab + *bb + *cb + *db) >> 2);
  48.305 -
  48.306 -			// 'b' becomes 'a', 'd' becomes 'c'
  48.307 -			ar = br;
  48.308 -			ag = bg;
  48.309 -			ab = bb;
  48.310 -			cr = dr;
  48.311 -			cg = dg;
  48.312 -			cb = db;
  48.313 -		}
  48.314 -
  48.315 -		// the "next" rgb row becomes the current; the old current rgb row is
  48.316 -		// recycled and serves as the new "next" row
  48.317 -		u8 *temp;
  48.318 -		temp		 = rgb_row_cur;
  48.319 -		rgb_row_cur	 = rgb_row_next;
  48.320 -		rgb_row_next = temp;
  48.321 -
  48.322 -		// update the pointers for start of next pair of lines
  48.323 -		from   = (u32 *)((u8 *)from_orig + srcPitch);
  48.324 -		to	   = (u32 *)((u8 *)to_orig + (dstPitch << 1));
  48.325 -		to_odd = (u32 *)((u8 *)to + dstPitch);
  48.326 -	}
  48.327 -}
  48.328 -
  48.329 -void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  48.330 -                    u8 *dstPtr, u32 dstPitch, int width, int height)
  48.331 -{
  48.332 -	u32 *to		= (u32 *)dstPtr;
  48.333 -	u32 *to_odd = (u32 *)(dstPtr + dstPitch);
  48.334 -
  48.335 -	int from_width = width;
  48.336 -	if (width + 1 < from_width)
  48.337 -		from_width = width + 1;
  48.338 -	u32 *from = (u32 *)srcPtr;
  48.339 -	fill_rgb_row_32(from, from_width, rgb_row_cur, width + 1);
  48.340 -
  48.341 -	for (int y = 0; y < height; y++)
  48.342 -	{
  48.343 -		u32 *from_orig = from;
  48.344 -		u32 *to_orig   = to;
  48.345 -
  48.346 -		if (y + 1 < height)
  48.347 -			fill_rgb_row_32(from + width + 1, from_width, rgb_row_next,
  48.348 -			                width + 1);
  48.349 -		else
  48.350 -			fill_rgb_row_32(from, from_width, rgb_row_next, width + 1);
  48.351 -
  48.352 -		// every pixel in the src region, is extended to 4 pixels in the
  48.353 -		// destination, arranged in a square 'quad'; if the current src
  48.354 -		// pixel is 'a', then in what follows 'b' is the src pixel to the
  48.355 -		// right, 'c' is the src pixel below, and 'd' is the src pixel to
  48.356 -		// the right and down
  48.357 -		u8 *cur_row	 = rgb_row_cur;
  48.358 -		u8 *next_row = rgb_row_next;
  48.359 -		u8 *ar		 = cur_row++;
  48.360 -		u8 *ag		 = cur_row++;
  48.361 -		u8 *ab		 = cur_row++;
  48.362 -		u8 *cr		 = next_row++;
  48.363 -		u8 *cg		 = next_row++;
  48.364 -		u8 *cb		 = next_row++;
  48.365 -		for (int x = 0; x < width; x++)
  48.366 -		{
  48.367 -			u8 *br = cur_row++;
  48.368 -			u8 *bg = cur_row++;
  48.369 -			u8 *bb = cur_row++;
  48.370 -			u8 *dr = next_row++;
  48.371 -			u8 *dg = next_row++;
  48.372 -			u8 *db = next_row++;
  48.373 -
  48.374 -			// upper left pixel in quad: just copy it in
  48.375 -			//*to++ = manip.rgb(*ar, *ag, *ab);
  48.376 -#ifdef USE_ORIGINAL_BILINEAR_PLUS
  48.377 -			*to++ = RGB(
  48.378 -			    (((*ar) << 2) + ((*ar)) + (*cr + *br + *br)) >> 3,
  48.379 -			    (((*ag) << 2) + ((*ag)) + (*cg + *bg + *bg)) >> 3,
  48.380 -			    (((*ab) << 2) + ((*ab)) + (*cb + *bb + *bb)) >> 3);
  48.381 -#else
  48.382 -			*to++ = RGB(
  48.383 -			    (((*ar) << 3) + ((*ar) << 1) + (*cr + *br + *br + *cr)) >> 4,
  48.384 -			    (((*ag) << 3) + ((*ag) << 1) + (*cg + *bg + *bg + *cg)) >> 4,
  48.385 -			    (((*ab) << 3) + ((*ab) << 1) + (*cb + *bb + *bb + *cb)) >> 4);
  48.386 -#endif
  48.387 -
  48.388 -			// upper right
  48.389 -			*to++ = RGB((*ar + *br) >> 1, (*ag + *bg) >> 1, (*ab + *bb) >> 1);
  48.390 -
  48.391 -			// lower left
  48.392 -			*to_odd++ = RGB((*ar + *cr) >> 1, (*ag + *cg) >> 1, (*ab + *cb) >> 1);
  48.393 -
  48.394 -			// lower right
  48.395 -			*to_odd++ = RGB((*ar + *br + *cr + *dr) >> 2,
  48.396 -			                (*ag + *bg + *cg + *dg) >> 2,
  48.397 -			                (*ab + *bb + *cb + *db) >> 2);
  48.398 -
  48.399 -			// 'b' becomes 'a', 'd' becomes 'c'
  48.400 -			ar = br;
  48.401 -			ag = bg;
  48.402 -			ab = bb;
  48.403 -			cr = dr;
  48.404 -			cg = dg;
  48.405 -			cb = db;
  48.406 -		}
  48.407 -
  48.408 -		// the "next" rgb row becomes the current; the old current rgb row is
  48.409 -		// recycled and serves as the new "next" row
  48.410 -		u8 *temp;
  48.411 -		temp		 = rgb_row_cur;
  48.412 -		rgb_row_cur	 = rgb_row_next;
  48.413 -		rgb_row_next = temp;
  48.414 -
  48.415 -		// update the pointers for start of next pair of lines
  48.416 -		from   = (u32 *)((u8 *)from_orig + srcPitch);
  48.417 -		to	   = (u32 *)((u8 *)to_orig + (dstPitch << 1));
  48.418 -		to_odd = (u32 *)((u8 *)to + dstPitch);
  48.419 -	}
  48.420 -}
  48.421 -
    49.1 --- a/src/filters/filters.h	Sat Mar 03 10:54:39 2012 -0600
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,58 +0,0 @@
    49.4 -
    49.5 -#ifndef VBA_FILTERS_H
    49.6 -#define VBA_FILTERS_H
    49.7 -
    49.8 -#if _MSC_VER > 1000
    49.9 -#pragma once
   49.10 -#endif // _MSC_VER > 1000
   49.11 -
   49.12 -extern void Pixelate2x16(u8*, u32, u8*, u8*, u32, int, int);
   49.13 -extern void Pixelate2x32(u8*, u32, u8*, u8*, u32, int, int);
   49.14 -extern void (*Pixelate3x16)(u8*, u32, u8*, u8*, u32, int, int);
   49.15 -extern void (*Pixelate3x32)(u8*, u32, u8*, u8*, u32, int, int);
   49.16 -extern void (*Pixelate4x16)(u8*, u32, u8*, u8*, u32, int, int);
   49.17 -extern void (*Pixelate4x32)(u8*, u32, u8*, u8*, u32, int, int);
   49.18 -extern void MotionBlur(u8*, u32, u8*, u8*, u32, int, int);
   49.19 -extern void MotionBlur32(u8*, u32, u8*, u8*, u32, int, int);
   49.20 -extern void _2xSaI(u8*, u32, u8*, u8*, u32, int, int);
   49.21 -extern void _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
   49.22 -extern void Super2xSaI(u8*, u32, u8*, u8*, u32, int, int);
   49.23 -extern void Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
   49.24 -extern void SuperEagle(u8*, u32, u8*, u8*, u32, int, int);
   49.25 -extern void SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
   49.26 -extern void AdMame2x(u8*, u32, u8*, u8*, u32, int, int);
   49.27 -extern void AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
   49.28 -extern void Simple2x16(u8*, u32, u8*, u8*, u32, int, int);
   49.29 -extern void Simple2x32(u8*, u32, u8*, u8*, u32, int, int);
   49.30 -extern void (*Simple3x16)(u8*, u32, u8*, u8*, u32, int, int);
   49.31 -extern void (*Simple3x32)(u8*, u32, u8*, u8*, u32, int, int);
   49.32 -extern void (*Simple4x16)(u8*, u32, u8*, u8*, u32, int, int);
   49.33 -extern void (*Simple4x32)(u8*, u32, u8*, u8*, u32, int, int);
   49.34 -extern void Bilinear(u8*, u32, u8*, u8*, u32, int, int);
   49.35 -extern void Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
   49.36 -extern void BilinearPlus(u8*, u32, u8*, u8*, u32, int, int);
   49.37 -extern void BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
   49.38 -extern void Scanlines(u8*, u32, u8*, u8*, u32, int, int);
   49.39 -extern void Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
   49.40 -extern void ScanlinesTV(u8*, u32, u8*, u8*, u32, int, int);
   49.41 -extern void ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
   49.42 -extern void hq2x(u8*, u32, u8*, u8*, u32, int, int);
   49.43 -extern void hq2x32(u8*, u32, u8*, u8*, u32, int, int);
   49.44 -extern void hq2xS(u8*, u32, u8*, u8*, u32, int, int);
   49.45 -extern void hq2xS32(u8*, u32, u8*, u8*, u32, int, int);
   49.46 -extern void lq2x(u8*, u32, u8*, u8*, u32, int, int);
   49.47 -extern void lq2x32(u8*, u32, u8*, u8*, u32, int, int);
   49.48 -extern void hq3x(u8*, u32, u8*, u8*, u32, int, int);
   49.49 -extern void hq3x32(u8*, u32, u8*, u8*, u32, int, int);
   49.50 -extern void hq3xS(u8*, u32, u8*, u8*, u32, int, int);
   49.51 -extern void hq3xS32(u8*, u32, u8*, u8*, u32, int, int);
   49.52 -
   49.53 -extern void SmartIB(u8*, u32, int, int);
   49.54 -extern void SmartIB32(u8*, u32, int, int);
   49.55 -extern void MotionBlurIB(u8*, u32, int, int);
   49.56 -extern void InterlaceIB(u8*, u32, int, int);
   49.57 -extern void MotionBlurIB32(u8*, u32, int, int);
   49.58 -
   49.59 -extern void InterframeCleanup();
   49.60 -
   49.61 -#endif // VBA_FILTERS_H
    50.1 --- a/src/filters/hq2x.cpp	Sat Mar 03 10:54:39 2012 -0600
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,966 +0,0 @@
    50.4 -/*
    50.5 - * This file is part of the Advance project.
    50.6 - *
    50.7 - * Copyright (C) 2003 Andrea Mazzoleni
    50.8 - *
    50.9 - * This program is free software; you can redistribute it and/or modify
   50.10 - * it under the terms of the GNU General Public License as published by
   50.11 - * the Free Software Foundation; either version 2 of the License, or
   50.12 - * (at your option) any later version.
   50.13 - *
   50.14 - * This program is distributed in the hope that it will be useful,
   50.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   50.17 - * GNU General Public License for more details.
   50.18 - *
   50.19 - * You should have received a copy of the GNU General Public License
   50.20 - * along with this program; if not, write to the Free Software
   50.21 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   50.22 - *
   50.23 - * In addition, as a special exception, Andrea Mazzoleni
   50.24 - * gives permission to link the code of this program with
   50.25 - * the MAME library (or with modified versions of MAME that use the
   50.26 - * same license as MAME), and distribute linked combinations including
   50.27 - * the two.  You must obey the GNU General Public License in all
   50.28 - * respects for all of the code used other than MAME.  If you modify
   50.29 - * this file, you may extend this exception to your version of the
   50.30 - * file, but you are not obligated to do so.  If you do not wish to
   50.31 - * do so, delete this exception statement from your version.
   50.32 - */
   50.33 -#include "../Port.h"
   50.34 -#include "interp.h"
   50.35 -
   50.36 -unsigned interp_mask[2];
   50.37 -unsigned interp_bits_per_pixel;
   50.38 -
   50.39 -/***************************************************************************/
   50.40 -/* HQ2x C implementation */
   50.41 -
   50.42 -/*
   50.43 - * This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin
   50.44 - */
   50.45 -
   50.46 -static void hq2x_16_def(u16 *dst0, u16 *dst1, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
   50.47 -{
   50.48 -	unsigned i;
   50.49 -
   50.50 -	for (i = 0; i < count; ++i)
   50.51 -	{
   50.52 -		unsigned char mask;
   50.53 -
   50.54 -		u16 c[9];
   50.55 -
   50.56 -		c[1] = src0[0];
   50.57 -		c[4] = src1[0];
   50.58 -		c[7] = src2[0];
   50.59 -
   50.60 -		if (i > 0)
   50.61 -		{
   50.62 -			c[0] = src0[-1];
   50.63 -			c[3] = src1[-1];
   50.64 -			c[6] = src2[-1];
   50.65 -		}
   50.66 -		else
   50.67 -		{
   50.68 -			c[0] = c[1];
   50.69 -			c[3] = c[4];
   50.70 -			c[6] = c[7];
   50.71 -		}
   50.72 -
   50.73 -		if (i < count - 1)
   50.74 -		{
   50.75 -			c[2] = src0[1];
   50.76 -			c[5] = src1[1];
   50.77 -			c[8] = src2[1];
   50.78 -		}
   50.79 -		else
   50.80 -		{
   50.81 -			c[2] = c[1];
   50.82 -			c[5] = c[4];
   50.83 -			c[8] = c[7];
   50.84 -		}
   50.85 -
   50.86 -		mask = 0;
   50.87 -
   50.88 -		if (interp_16_diff(c[0], c[4]))
   50.89 -			mask |= 1 << 0;
   50.90 -		if (interp_16_diff(c[1], c[4]))
   50.91 -			mask |= 1 << 1;
   50.92 -		if (interp_16_diff(c[2], c[4]))
   50.93 -			mask |= 1 << 2;
   50.94 -		if (interp_16_diff(c[3], c[4]))
   50.95 -			mask |= 1 << 3;
   50.96 -		if (interp_16_diff(c[5], c[4]))
   50.97 -			mask |= 1 << 4;
   50.98 -		if (interp_16_diff(c[6], c[4]))
   50.99 -			mask |= 1 << 5;
  50.100 -		if (interp_16_diff(c[7], c[4]))
  50.101 -			mask |= 1 << 6;
  50.102 -		if (interp_16_diff(c[8], c[4]))
  50.103 -			mask |= 1 << 7;
  50.104 -
  50.105 -#define P0 dst0[0]
  50.106 -#define P1 dst0[1]
  50.107 -#define P2 dst1[0]
  50.108 -#define P3 dst1[1]
  50.109 -#define MUR interp_16_diff(c[1], c[5]) // top-right
  50.110 -#define MDR interp_16_diff(c[5], c[7]) // bottom-right
  50.111 -#define MDL interp_16_diff(c[7], c[3]) // bottom-left
  50.112 -#define MUL interp_16_diff(c[3], c[1]) // top-left
  50.113 -#define IC(p0) c[p0]
  50.114 -#define I11(p0, p1) interp_16_11(c[p0], c[p1])
  50.115 -#define I211(p0, p1, p2) interp_16_211(c[p0], c[p1], c[p2])
  50.116 -#define I31(p0, p1) interp_16_31(c[p0], c[p1])
  50.117 -#define I332(p0, p1, p2) interp_16_332(c[p0], c[p1], c[p2])
  50.118 -#define I431(p0, p1, p2) interp_16_431(c[p0], c[p1], c[p2])
  50.119 -#define I521(p0, p1, p2) interp_16_521(c[p0], c[p1], c[p2])
  50.120 -#define I53(p0, p1) interp_16_53(c[p0], c[p1])
  50.121 -#define I611(p0, p1, p2) interp_16_611(c[p0], c[p1], c[p2])
  50.122 -#define I71(p0, p1) interp_16_71(c[p0], c[p1])
  50.123 -#define I772(p0, p1, p2) interp_16_772(c[p0], c[p1], c[p2])
  50.124 -#define I97(p0, p1) interp_16_97(c[p0], c[p1])
  50.125 -#define I1411(p0, p1, p2) interp_16_1411(c[p0], c[p1], c[p2])
  50.126 -#define I151(p0, p1) interp_16_151(c[p0], c[p1])
  50.127 -
  50.128 -		switch (mask)
  50.129 -		{
  50.130 -#include "hq2x.h"
  50.131 -		}
  50.132 -
  50.133 -#undef P0
  50.134 -#undef P1
  50.135 -#undef P2
  50.136 -#undef P3
  50.137 -#undef MUR
  50.138 -#undef MDR
  50.139 -#undef MDL
  50.140 -#undef MUL
  50.141 -#undef IC
  50.142 -#undef I11
  50.143 -#undef I211
  50.144 -#undef I31
  50.145 -#undef I332
  50.146 -#undef I431
  50.147 -#undef I521
  50.148 -#undef I53
  50.149 -#undef I611
  50.150 -#undef I71
  50.151 -#undef I772
  50.152 -#undef I97
  50.153 -#undef I1411
  50.154 -#undef I151
  50.155 -
  50.156 -		src0 += 1;
  50.157 -		src1 += 1;
  50.158 -		src2 += 1;
  50.159 -		dst0 += 2;
  50.160 -		dst1 += 2;
  50.161 -	}
  50.162 -}
  50.163 -
  50.164 -static void hq2x_32_def(u32 *dst0, u32 *dst1, const u32 *src0, const u32 *src1, const u32 *src2, unsigned count)
  50.165 -{
  50.166 -	unsigned i;
  50.167 -
  50.168 -	for (i = 0; i < count; ++i)
  50.169 -	{
  50.170 -		unsigned char mask;
  50.171 -
  50.172 -		u32 c[9];
  50.173 -
  50.174 -		c[1] = src0[0];
  50.175 -		c[4] = src1[0];
  50.176 -		c[7] = src2[0];
  50.177 -
  50.178 -		if (i > 0)
  50.179 -		{
  50.180 -			c[0] = src0[-1];
  50.181 -			c[3] = src1[-1];
  50.182 -			c[6] = src2[-1];
  50.183 -		}
  50.184 -		else
  50.185 -		{
  50.186 -			c[0] = c[1];
  50.187 -			c[3] = c[4];
  50.188 -			c[6] = c[7];
  50.189 -		}
  50.190 -
  50.191 -		if (i < count - 1)
  50.192 -		{
  50.193 -			c[2] = src0[1];
  50.194 -			c[5] = src1[1];
  50.195 -			c[8] = src2[1];
  50.196 -		}
  50.197 -		else
  50.198 -		{
  50.199 -			c[2] = c[1];
  50.200 -			c[5] = c[4];
  50.201 -			c[8] = c[7];
  50.202 -		}
  50.203 -
  50.204 -		mask = 0;
  50.205 -
  50.206 -		if (interp_32_diff(c[0], c[4]))
  50.207 -			mask |= 1 << 0;
  50.208 -		if (interp_32_diff(c[1], c[4]))
  50.209 -			mask |= 1 << 1;
  50.210 -		if (interp_32_diff(c[2], c[4]))
  50.211 -			mask |= 1 << 2;
  50.212 -		if (interp_32_diff(c[3], c[4]))
  50.213 -			mask |= 1 << 3;
  50.214 -		if (interp_32_diff(c[5], c[4]))
  50.215 -			mask |= 1 << 4;
  50.216 -		if (interp_32_diff(c[6], c[4]))
  50.217 -			mask |= 1 << 5;
  50.218 -		if (interp_32_diff(c[7], c[4]))
  50.219 -			mask |= 1 << 6;
  50.220 -		if (interp_32_diff(c[8], c[4]))
  50.221 -			mask |= 1 << 7;
  50.222 -
  50.223 -#define P0 dst0[0]
  50.224 -#define P1 dst0[1]
  50.225 -#define P2 dst1[0]
  50.226 -#define P3 dst1[1]
  50.227 -#define MUR interp_32_diff(c[1], c[5]) // top-right
  50.228 -#define MDR interp_32_diff(c[5], c[7]) // bottom-right
  50.229 -#define MDL interp_32_diff(c[7], c[3]) // bottom-left
  50.230 -#define MUL interp_32_diff(c[3], c[1]) // top-left
  50.231 -#define IC(p0) c[p0]
  50.232 -#define I11(p0, p1) interp_32_11(c[p0], c[p1])
  50.233 -#define I211(p0, p1, p2) interp_32_211(c[p0], c[p1], c[p2])
  50.234 -#define I31(p0, p1) interp_32_31(c[p0], c[p1])
  50.235 -#define I332(p0, p1, p2) interp_32_332(c[p0], c[p1], c[p2])
  50.236 -#define I431(p0, p1, p2) interp_32_431(c[p0], c[p1], c[p2])
  50.237 -#define I521(p0, p1, p2) interp_32_521(c[p0], c[p1], c[p2])
  50.238 -#define I53(p0, p1) interp_32_53(c[p0], c[p1])
  50.239 -#define I611(p0, p1, p2) interp_32_611(c[p0], c[p1], c[p2])
  50.240 -#define I71(p0, p1) interp_32_71(c[p0], c[p1])
  50.241 -#define I772(p0, p1, p2) interp_32_772(c[p0], c[p1], c[p2])
  50.242 -#define I97(p0, p1) interp_32_97(c[p0], c[p1])
  50.243 -#define I1411(p0, p1, p2) interp_32_1411(c[p0], c[p1], c[p2])
  50.244 -#define I151(p0, p1) interp_32_151(c[p0], c[p1])
  50.245 -
  50.246 -		switch (mask)
  50.247 -		{
  50.248 -#include "hq2x.h"
  50.249 -		}
  50.250 -
  50.251 -#undef P0
  50.252 -#undef P1
  50.253 -#undef P2
  50.254 -#undef P3
  50.255 -#undef MUR
  50.256 -#undef MDR
  50.257 -#undef MDL
  50.258 -#undef MUL
  50.259 -#undef IC
  50.260 -#undef I11
  50.261 -#undef I211
  50.262 -#undef I31
  50.263 -#undef I332
  50.264 -#undef I431
  50.265 -#undef I521
  50.266 -#undef I53
  50.267 -#undef I611
  50.268 -#undef I71
  50.269 -#undef I772
  50.270 -#undef I97
  50.271 -#undef I1411
  50.272 -#undef I151
  50.273 -
  50.274 -		src0 += 1;
  50.275 -		src1 += 1;
  50.276 -		src2 += 1;
  50.277 -		dst0 += 2;
  50.278 -		dst1 += 2;
  50.279 -	}
  50.280 -}
  50.281 -
  50.282 -/***************************************************************************/
  50.283 -/* HQ2xS C implementation */
  50.284 -
  50.285 -/*
  50.286 - * This effect is derived from the hq2x effect made by Maxim Stepin
  50.287 - */
  50.288 -
  50.289 -static void hq2xS_16_def(u16 *dst0, u16 *dst1, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
  50.290 -{
  50.291 -	unsigned i;
  50.292 -
  50.293 -	for (i = 0; i < count; ++i)
  50.294 -	{
  50.295 -		unsigned char mask;
  50.296 -
  50.297 -		u16 c[9];
  50.298 -
  50.299 -		c[1] = src0[0];
  50.300 -		c[4] = src1[0];
  50.301 -		c[7] = src2[0];
  50.302 -
  50.303 -		c[0] = src0[-1];
  50.304 -		c[3] = src1[-1];
  50.305 -		c[6] = src2[-1];
  50.306 -
  50.307 -		c[2] = src0[1];
  50.308 -		c[5] = src1[1];
  50.309 -		c[8] = src2[1];
  50.310 -
  50.311 -		mask = 0;
  50.312 -
  50.313 -		// hq2xS dynamic edge detection:
  50.314 -		// simply comparing the center color against its surroundings will give bad results in many cases,
  50.315 -		// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
  50.316 -		int brightArray[9];
  50.317 -		int maxBright = 0, minBright = 999999;
  50.318 -		for (int j = 0; j < 9; j++)
  50.319 -		{
  50.320 -			int r, g, b;
  50.321 -			if (interp_bits_per_pixel == 16)
  50.322 -			{
  50.323 -				b = (int)((c[j] & 0x1F)) << 3;
  50.324 -				g = (int)((c[j] & 0x7E0)) >> 3;
  50.325 -				r = (int)((c[j] & 0xF800)) >> 8;
  50.326 -			}
  50.327 -			else
  50.328 -			{
  50.329 -				b = (int)((c[j] & 0x1F)) << 3;
  50.330 -				g = (int)((c[j] & 0x3E0)) >> 2;
  50.331 -				r = (int)((c[j] & 0x7C00)) >> 7;
  50.332 -			}
  50.333 -			const int bright = r + r + r + g + g + g + b + b;
  50.334 -			if (bright > maxBright) maxBright = bright;
  50.335 -			if (bright < minBright) minBright = bright;
  50.336 -
  50.337 -			brightArray[j] = bright;
  50.338 -		}
  50.339 -		int diffBright = ((maxBright - minBright) * 7) >> 4;
  50.340 -		if (diffBright > 7)
  50.341 -		{
  50.342 -		#define ABS(x) ((x) < 0 ? -(x) : (x))
  50.343 -
  50.344 -			const int centerBright = brightArray[4];
  50.345 -			if (ABS(brightArray[0] - centerBright) > diffBright)
  50.346 -				mask |= 1 << 0;
  50.347 -			if (ABS(brightArray[1] - centerBright) > diffBright)
  50.348 -				mask |= 1 << 1;
  50.349 -			if (ABS(brightArray[2] - centerBright) > diffBright)
  50.350 -				mask |= 1 << 2;
  50.351 -			if (ABS(brightArray[3] - centerBright) > diffBright)
  50.352 -				mask |= 1 << 3;
  50.353 -			if (ABS(brightArray[5] - centerBright) > diffBright)
  50.354 -				mask |= 1 << 4;
  50.355 -			if (ABS(brightArray[6] - centerBright) > diffBright)
  50.356 -				mask |= 1 << 5;
  50.357 -			if (ABS(brightArray[7] - centerBright) > diffBright)
  50.358 -				mask |= 1 << 6;
  50.359 -			if (ABS(brightArray[8] - centerBright) > diffBright)
  50.360 -				mask |= 1 << 7;
  50.361 -		}
  50.362 -
  50.363 -#define P0 dst0[0]
  50.364 -#define P1 dst0[1]
  50.365 -#define P2 dst1[0]
  50.366 -#define P3 dst1[1]
  50.367 -#define MUR false //(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right
  50.368 -#define MDR false //(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right
  50.369 -#define MDL false //(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left
  50.370 -#define MUL false //(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left
  50.371 -#define IC(p0) c[p0]
  50.372 -#define I11(p0, p1) interp_16_11(c[p0], c[p1])
  50.373 -#define I211(p0, p1, p2) interp_16_211(c[p0], c[p1], c[p2])
  50.374 -#define I31(p0, p1) interp_16_31(c[p0], c[p1])
  50.375 -#define I332(p0, p1, p2) interp_16_332(c[p0], c[p1], c[p2])
  50.376 -#define I431(p0, p1, p2) interp_16_431(c[p0], c[p1], c[p2])
  50.377 -#define I521(p0, p1, p2) interp_16_521(c[p0], c[p1], c[p2])
  50.378 -#define I53(p0, p1) interp_16_53(c[p0], c[p1])
  50.379 -#define I611(p0, p1, p2) interp_16_611(c[p0], c[p1], c[p2])
  50.380 -#define I71(p0, p1) interp_16_71(c[p0], c[p1])
  50.381 -#define I772(p0, p1, p2) interp_16_772(c[p0], c[p1], c[p2])
  50.382 -#define I97(p0, p1) interp_16_97(c[p0], c[p1])
  50.383 -#define I1411(p0, p1, p2) interp_16_1411(c[p0], c[p1], c[p2])
  50.384 -#define I151(p0, p1) interp_16_151(c[p0], c[p1])
  50.385 -
  50.386 -		switch (mask)
  50.387 -		{
  50.388 -#include "hq2x.h"
  50.389 -		}
  50.390 -
  50.391 -#undef P0
  50.392 -#undef P1
  50.393 -#undef P2
  50.394 -#undef P3
  50.395 -#undef MUR
  50.396 -#undef MDR
  50.397 -#undef MDL
  50.398 -#undef MUL
  50.399 -#undef IC
  50.400 -#undef I11
  50.401 -#undef I211
  50.402 -#undef I31
  50.403 -#undef I332
  50.404 -#undef I431
  50.405 -#undef I521
  50.406 -#undef I53
  50.407 -#undef I611
  50.408 -#undef I71
  50.409 -#undef I772
  50.410 -#undef I97
  50.411 -#undef I1411
  50.412 -#undef I151
  50.413 -
  50.414 -		src0 += 1;
  50.415 -		src1 += 1;
  50.416 -		src2 += 1;
  50.417 -		dst0 += 2;
  50.418 -		dst1 += 2;
  50.419 -	}
  50.420 -}
  50.421 -
  50.422 -static void hq2xS_32_def(u32 *dst0, u32 *dst1, const u32 *src0, const u32 *src1, const u32 *src2, unsigned count)
  50.423 -{
  50.424 -	unsigned i;
  50.425 -
  50.426 -	for (i = 0; i < count; ++i)
  50.427 -	{
  50.428 -		unsigned char mask;
  50.429 -
  50.430 -		u32 c[9];
  50.431 -
  50.432 -		c[1] = src0[0];
  50.433 -		c[4] = src1[0];
  50.434 -		c[7] = src2[0];
  50.435 -
  50.436 -		c[0] = src0[-1];
  50.437 -		c[3] = src1[-1];
  50.438 -		c[6] = src2[-1];
  50.439 -
  50.440 -		c[2] = src0[1];
  50.441 -		c[5] = src1[1];
  50.442 -		c[8] = src2[1];
  50.443 -
  50.444 -		mask = 0;
  50.445 -
  50.446 -		// hq2xS dynamic edge detection:
  50.447 -		// simply comparing the center color against its surroundings will give bad results in many cases,
  50.448 -		// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
  50.449 -		int brightArray[9];
  50.450 -		int maxBright = 0, minBright = 999999;
  50.451 -		for (int j = 0; j < 9; j++)
  50.452 -		{
  50.453 -			const int b		 = (int)((c[j] & 0xF8));
  50.454 -			const int g		 = (int)((c[j] & 0xF800)) >> 8;
  50.455 -			const int r		 = (int)((c[j] & 0xF80000)) >> 16;
  50.456 -			const int bright = r + r + r + g + g + g + b + b;
  50.457 -			if (bright > maxBright) maxBright = bright;
  50.458 -			if (bright < minBright) minBright = bright;
  50.459 -
  50.460 -			brightArray[j] = bright;
  50.461 -		}
  50.462 -		int diffBright = ((maxBright - minBright) * 7) >> 4;
  50.463 -		if (diffBright > 7)
  50.464 -		{
  50.465 -		#define ABS(x) ((x) < 0 ? -(x) : (x))
  50.466 -
  50.467 -			const int centerBright = brightArray[4];
  50.468 -			if (ABS(brightArray[0] - centerBright) > diffBright)
  50.469 -				mask |= 1 << 0;
  50.470 -			if (ABS(brightArray[1] - centerBright) > diffBright)
  50.471 -				mask |= 1 << 1;
  50.472 -			if (ABS(brightArray[2] - centerBright) > diffBright)
  50.473 -				mask |= 1 << 2;
  50.474 -			if (ABS(brightArray[3] - centerBright) > diffBright)
  50.475 -				mask |= 1 << 3;
  50.476 -			if (ABS(brightArray[5] - centerBright) > diffBright)
  50.477 -				mask |= 1 << 4;
  50.478 -			if (ABS(brightArray[6] - centerBright) > diffBright)
  50.479 -				mask |= 1 << 5;
  50.480 -			if (ABS(brightArray[7] - centerBright) > diffBright)
  50.481 -				mask |= 1 << 6;
  50.482 -			if (ABS(brightArray[8] - centerBright) > diffBright)
  50.483 -				mask |= 1 << 7;
  50.484 -		}
  50.485 -
  50.486 -#define P0 dst0[0]
  50.487 -#define P1 dst0[1]
  50.488 -#define P2 dst1[0]
  50.489 -#define P3 dst1[1]
  50.490 -#define MUR false //(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right
  50.491 -#define MDR false //(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right
  50.492 -#define MDL false //(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left
  50.493 -#define MUL false //(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left
  50.494 -#define IC(p0) c[p0]
  50.495 -#define I11(p0, p1) interp_32_11(c[p0], c[p1])
  50.496 -#define I211(p0, p1, p2) interp_32_211(c[p0], c[p1], c[p2])
  50.497 -#define I31(p0, p1) interp_32_31(c[p0], c[p1])
  50.498 -#define I332(p0, p1, p2) interp_32_332(c[p0], c[p1], c[p2])
  50.499 -#define I431(p0, p1, p2) interp_32_431(c[p0], c[p1], c[p2])
  50.500 -#define I521(p0, p1, p2) interp_32_521(c[p0], c[p1], c[p2])
  50.501 -#define I53(p0, p1) interp_32_53(c[p0], c[p1])
  50.502 -#define I611(p0, p1, p2) interp_32_611(c[p0], c[p1], c[p2])
  50.503 -#define I71(p0, p1) interp_32_71(c[p0], c[p1])
  50.504 -#define I772(p0, p1, p2) interp_32_772(c[p0], c[p1], c[p2])
  50.505 -#define I97(p0, p1) interp_32_97(c[p0], c[p1])
  50.506 -#define I1411(p0, p1, p2) interp_32_1411(c[p0], c[p1], c[p2])
  50.507 -#define I151(p0, p1) interp_32_151(c[p0], c[p1])
  50.508 -
  50.509 -		switch (mask)
  50.510 -		{
  50.511 -#include "hq2x.h"
  50.512 -		}
  50.513 -
  50.514 -#undef P0
  50.515 -#undef P1
  50.516 -#undef P2
  50.517 -#undef P3
  50.518 -#undef MUR
  50.519 -#undef MDR
  50.520 -#undef MDL
  50.521 -#undef MUL
  50.522 -#undef IC
  50.523 -#undef I11
  50.524 -#undef I211
  50.525 -#undef I31
  50.526 -#undef I332
  50.527 -#undef I431
  50.528 -#undef I521
  50.529 -#undef I53
  50.530 -#undef I611
  50.531 -#undef I71
  50.532 -#undef I772
  50.533 -#undef I97
  50.534 -#undef I1411
  50.535 -#undef I151
  50.536 -
  50.537 -		src0 += 1;
  50.538 -		src1 += 1;
  50.539 -		src2 += 1;
  50.540 -		dst0 += 2;
  50.541 -		dst1 += 2;
  50.542 -	}
  50.543 -}
  50.544 -
  50.545 -/***************************************************************************/
  50.546 -/* LQ2x C implementation */
  50.547 -
  50.548 -/*
  50.549 - * This effect is derived from the hq2x effect made by Maxim Stepin
  50.550 - */
  50.551 -
  50.552 -static void lq2x_16_def(u16 *dst0, u16 *dst1, const u16 *src0, const u16 *src1, const u16 *src2, unsigned count)
  50.553 -{
  50.554 -	unsigned i;
  50.555 -
  50.556 -	for (i = 0; i < count; ++i)
  50.557 -	{
  50.558 -		unsigned char mask;
  50.559 -
  50.560 -		u16 c[9];
  50.561 -
  50.562 -		c[1] = src0[0];
  50.563 -		c[4] = src1[0];
  50.564 -		c[7] = src2[0];
  50.565 -
  50.566 -		if (i > 0)
  50.567 -		{
  50.568 -			c[0] = src0[-1];
  50.569 -			c[3] = src1[-1];
  50.570 -			c[6] = src2[-1];
  50.571 -		}
  50.572 -		else
  50.573 -		{
  50.574 -			c[0] = c[1];
  50.575 -			c[3] = c[4];
  50.576 -			c[6] = c[7];
  50.577 -		}
  50.578 -
  50.579 -		if (i < count - 1)
  50.580 -		{
  50.581 -			c[2] = src0[1];
  50.582 -			c[5] = src1[1];
  50.583 -			c[8] = src2[1];
  50.584 -		}
  50.585 -		else
  50.586 -		{
  50.587 -			c[2] = c[1];
  50.588 -			c[5] = c[4];
  50.589 -			c[8] = c[7];
  50.590 -		}
  50.591 -
  50.592 -		mask = 0;
  50.593 -
  50.594 -		if (c[0] != c[4])
  50.595 -			mask |= 1 << 0;
  50.596 -		if (c[1] != c[4])
  50.597 -			mask |= 1 << 1;
  50.598 -		if (c[2] != c[4])
  50.599 -			mask |= 1 << 2;
  50.600 -		if (c[3] != c[4])
  50.601 -			mask |= 1 << 3;
  50.602 -		if (c[5] != c[4])
  50.603 -			mask |= 1 << 4;
  50.604 -		if (c[6] != c[4])
  50.605 -			mask |= 1 << 5;
  50.606 -		if (c[7] != c[4])
  50.607 -			mask |= 1 << 6;
  50.608 -		if (c[8] != c[4])
  50.609 -			mask |= 1 << 7;
  50.610 -
  50.611 -#define P0 dst0[0]
  50.612 -#define P1 dst0[1]
  50.613 -#define P2 dst1[0]
  50.614 -#define P3 dst1[1]
  50.615 -#define MUR (c[1] != c[5])
  50.616 -#define MDR (c[5] != c[7])
  50.617 -#define MDL (c[7] != c[3])
  50.618 -#define MUL (c[3] != c[1])
  50.619 -#define IC(p0) c[p0]
  50.620 -#define I11(p0, p1) interp_16_11(c[p0], c[p1])
  50.621 -#define I211(p0, p1, p2) interp_16_211(c[p0], c[p1], c[p2])
  50.622 -#define I31(p0, p1) interp_16_31(c[p0], c[p1])
  50.623 -#define I332(p0, p1, p2) interp_16_332(c[p0], c[p1], c[p2])
  50.624 -#define I431(p0, p1, p2) interp_16_431(c[p0], c[p1], c[p2])
  50.625 -#define I521(p0, p1, p2) interp_16_521(c[p0], c[p1], c[p2])
  50.626 -#define I53(p0, p1) interp_16_53(c[p0], c[p1])
  50.627 -#define I611(p0, p1, p2) interp_16_611(c[p0], c[p1], c[p2])
  50.628 -#define I71(p0, p1) interp_16_71(c[p0], c[p1])
  50.629 -#define I772(p0, p1, p2) interp_16_772(c[p0], c[p1], c[p2])
  50.630 -#define I97(p0, p1) interp_16_97(c[p0], c[p1])
  50.631 -#define I1411(p0, p1, p2) interp_16_1411(c[p0], c[p1], c[p2])
  50.632 -#define I151(p0, p1) interp_16_151(c[p0], c[p1])
  50.633 -
  50.634 -		switch (mask)
  50.635 -		{
  50.636 -#include "lq2x.h"
  50.637 -		}
  50.638 -
  50.639 -#undef P0
  50.640 -#undef P1
  50.641 -#undef P2
  50.642 -#undef P3
  50.643 -#undef MUR
  50.644 -#undef MDR
  50.645 -#undef MDL
  50.646 -#undef MUL
  50.647 -#undef IC
  50.648 -#undef I11
  50.649 -#undef I211
  50.650 -#undef I31
  50.651 -#undef I332
  50.652 -#undef I431
  50.653 -#undef I521
  50.654 -#undef I53
  50.655 -#undef I611
  50.656 -#undef I71
  50.657 -#undef I772
  50.658 -#undef I97
  50.659 -#undef I1411
  50.660 -#undef I151
  50.661 -
  50.662 -		src0 += 1;
  50.663 -		src1 += 1;
  50.664 -		src2 += 1;
  50.665 -		dst0 += 2;
  50.666 -		dst1 += 2;
  50.667 -	}
  50.668 -}
  50.669 -
  50.670 -static void lq2x_32_def(u32 *dst0, u32 *dst1, const u32 *src0, const u32 *src1, const u32 *src2, unsigned count)
  50.671 -{
  50.672 -	unsigned i;
  50.673 -
  50.674 -	for (i = 0; i < count; ++i)
  50.675 -	{
  50.676 -		unsigned char mask;
  50.677 -
  50.678 -		u32 c[9];
  50.679 -
  50.680 -		c[1] = src0[0];
  50.681 -		c[4] = src1[0];
  50.682 -		c[7] = src2[0];
  50.683 -
  50.684 -		if (i > 0)
  50.685 -		{
  50.686 -			c[0] = src0[-1];
  50.687 -			c[3] = src1[-1];
  50.688 -			c[6] = src2[-1];
  50.689 -		}
  50.690 -		else
  50.691 -		{
  50.692 -			c[0] = c[1];
  50.693 -			c[3] = c[4];
  50.694 -			c[6] = c[7];
  50.695 -		}
  50.696 -
  50.697 -		if (i < count - 1)
  50.698 -		{
  50.699 -			c[2] = src0[1];
  50.700 -			c[5] = src1[1];
  50.701 -			c[8] = src2[1];
  50.702 -		}
  50.703 -		else
  50.704 -		{
  50.705 -			c[2] = c[1];
  50.706 -			c[5] = c[4];
  50.707 -			c[8] = c[7];
  50.708 -		}
  50.709 -
  50.710 -		mask = 0;
  50.711 -
  50.712 -		if (c[0] != c[4])
  50.713 -			mask |= 1 << 0;
  50.714 -		if (c[1] != c[4])
  50.715 -			mask |= 1 << 1;
  50.716 -		if (c[2] != c[4])
  50.717 -			mask |= 1 << 2;
  50.718 -		if (c[3] != c[4])
  50.719 -			mask |= 1 << 3;
  50.720 -		if (c[5] != c[4])
  50.721 -			mask |= 1 << 4;
  50.722 -		if (c[6] != c[4])
  50.723 -			mask |= 1 << 5;
  50.724 -		if (c[7] != c[4])
  50.725 -			mask |= 1 << 6;
  50.726 -		if (c[8] != c[4])
  50.727 -			mask |= 1 << 7;
  50.728 -
  50.729 -#define P0 dst0[0]
  50.730 -#define P1 dst0[1]
  50.731 -#define P2 dst1[0]
  50.732 -#define P3 dst1[1]
  50.733 -#define MUR (c[1] != c[5])
  50.734 -#define MDR (c[5] != c[7])
  50.735 -#define MDL (c[7] != c[3])
  50.736 -#define MUL (c[3] != c[1])
  50.737 -#define IC(p0) c[p0]
  50.738 -#define I11(p0, p1) interp_32_11(c[p0], c[p1])
  50.739 -#define I211(p0, p1, p2) interp_32_211(c[p0], c[p1], c[p2])
  50.740 -#define I31(p0, p1) interp_32_31(c[p0], c[p1])
  50.741 -#define I332(p0, p1, p2) interp_32_332(c[p0], c[p1], c[p2])
  50.742 -#define I431(p0, p1, p2) interp_32_431(c[p0], c[p1], c[p2])
  50.743 -#define I521(p0, p1, p2) interp_32_521(c[p0], c[p1], c[p2])
  50.744 -#define I53(p0, p1) interp_32_53(c[p0], c[p1])
  50.745 -#define I611(p0, p1, p2) interp_32_611(c[p0], c[p1], c[p2])
  50.746 -#define I71(p0, p1) interp_32_71(c[p0], c[p1])
  50.747 -#define I772(p0, p1, p2) interp_32_772(c[p0], c[p1], c[p2])
  50.748 -#define I97(p0, p1) interp_32_97(c[p0], c[p1])
  50.749 -#define I1411(p0, p1, p2) interp_32_1411(c[p0], c[p1], c[p2])
  50.750 -#define I151(p0, p1) interp_32_151(c[p0], c[p1])
  50.751 -
  50.752 -		switch (mask)
  50.753 -		{
  50.754 -#include "lq2x.h"
  50.755 -		}
  50.756 -
  50.757 -#undef P0
  50.758 -#undef P1
  50.759 -#undef P2
  50.760 -#undef P3
  50.761 -#undef MUR
  50.762 -#undef MDR
  50.763 -#undef MDL
  50.764 -#undef MUL
  50.765 -#undef IC
  50.766 -#undef I11
  50.767 -#undef I211
  50.768 -#undef I31
  50.769 -#undef I332
  50.770 -#undef I431
  50.771 -#undef I521
  50.772 -#undef I53
  50.773 -#undef I611
  50.774 -#undef I71
  50.775 -#undef I772
  50.776 -#undef I97
  50.777 -#undef I1411
  50.778 -#undef I151
  50.779 -
  50.780 -		src0 += 1;
  50.781 -		src1 += 1;
  50.782 -		src2 += 1;
  50.783 -		dst0 += 2;
  50.784 -		dst1 += 2;
  50.785 -	}
  50.786 -}
  50.787 -
  50.788 -void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.789 -          u8 *dstPtr, u32 dstPitch, int width, int height)
  50.790 -{
  50.791 -	u16 *dst0 = (u16 *)dstPtr;
  50.792 -	u16 *dst1 = dst0 + (dstPitch >> 1);
  50.793 -
  50.794 -	u16 *src0 = (u16 *)srcPtr;
  50.795 -	u16 *src1 = src0 + (srcPitch >> 1);
  50.796 -	u16 *src2 = src1 + (srcPitch >> 1);
  50.797 -
  50.798 -	hq2x_16_def(dst0, dst1, src0, src0, src1, width);
  50.799 -
  50.800 -	int count = height;
  50.801 -
  50.802 -	count -= 2;
  50.803 -	while (count)
  50.804 -	{
  50.805 -		dst0 += dstPitch;
  50.806 -		dst1 += dstPitch;
  50.807 -		hq2x_16_def(dst0, dst1, src0, src1, src2, width);
  50.808 -		src0  = src1;
  50.809 -		src1  = src2;
  50.810 -		src2 += srcPitch >> 1;
  50.811 -		--count;
  50.812 -	}
  50.813 -	dst0 += dstPitch;
  50.814 -	dst1 += dstPitch;
  50.815 -	hq2x_16_def(dst0, dst1, src0, src1, src1, width);
  50.816 -}
  50.817 -
  50.818 -void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.819 -            u8 *dstPtr, u32 dstPitch, int width, int height)
  50.820 -{
  50.821 -	u32 *dst0 = (u32 *)dstPtr;
  50.822 -	u32 *dst1 = dst0 + (dstPitch >> 2);
  50.823 -
  50.824 -	u32 *src0 = (u32 *)srcPtr;
  50.825 -	u32 *src1 = src0 + (srcPitch >> 2);
  50.826 -	u32 *src2 = src1 + (srcPitch >> 2);
  50.827 -	hq2x_32_def(dst0, dst1, src0, src0, src1, width);
  50.828 -
  50.829 -	int count = height;
  50.830 -
  50.831 -	count -= 2;
  50.832 -	while (count)
  50.833 -	{
  50.834 -		dst0 += dstPitch >> 1;
  50.835 -		dst1 += dstPitch >> 1;
  50.836 -		hq2x_32_def(dst0, dst1, src0, src1, src2, width);
  50.837 -		src0  = src1;
  50.838 -		src1  = src2;
  50.839 -		src2 += srcPitch >> 2;
  50.840 -		--count;
  50.841 -	}
  50.842 -	dst0 += dstPitch >> 1;
  50.843 -	dst1 += dstPitch >> 1;
  50.844 -	hq2x_32_def(dst0, dst1, src0, src1, src1, width);
  50.845 -}
  50.846 -
  50.847 -void hq2xS(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.848 -           u8 *dstPtr, u32 dstPitch, int width, int height)
  50.849 -{
  50.850 -	u16 *dst0 = (u16 *)dstPtr;
  50.851 -	u16 *dst1 = dst0 + (dstPitch >> 1);
  50.852 -
  50.853 -	u16 *src0 = (u16 *)srcPtr;
  50.854 -	u16 *src1 = src0 + (srcPitch >> 1);
  50.855 -	u16 *src2 = src1 + (srcPitch >> 1);
  50.856 -
  50.857 -	hq2xS_16_def(dst0, dst1, src0, src0, src1, width);
  50.858 -
  50.859 -	int count = height;
  50.860 -
  50.861 -	count -= 2;
  50.862 -	while (count)
  50.863 -	{
  50.864 -		dst0 += dstPitch;
  50.865 -		dst1 += dstPitch;
  50.866 -		hq2xS_16_def(dst0, dst1, src0, src1, src2, width);
  50.867 -		src0  = src1;
  50.868 -		src1  = src2;
  50.869 -		src2 += srcPitch >> 1;
  50.870 -		--count;
  50.871 -	}
  50.872 -	dst0 += dstPitch;
  50.873 -	dst1 += dstPitch;
  50.874 -	hq2xS_16_def(dst0, dst1, src0, src1, src1, width);
  50.875 -}
  50.876 -
  50.877 -void hq2xS32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.878 -             u8 *dstPtr, u32 dstPitch, int width, int height)
  50.879 -{
  50.880 -	u32 *dst0 = (u32 *)dstPtr;
  50.881 -	u32 *dst1 = dst0 + (dstPitch >> 2);
  50.882 -
  50.883 -	u32 *src0 = (u32 *)srcPtr;
  50.884 -	u32 *src1 = src0 + (srcPitch >> 2);
  50.885 -	u32 *src2 = src1 + (srcPitch >> 2);
  50.886 -	hq2xS_32_def(dst0, dst1, src0, src0, src1, width);
  50.887 -
  50.888 -	int count = height;
  50.889 -
  50.890 -	count -= 2;
  50.891 -	while (count)
  50.892 -	{
  50.893 -		dst0 += dstPitch >> 1;
  50.894 -		dst1 += dstPitch >> 1;
  50.895 -		hq2xS_32_def(dst0, dst1, src0, src1, src2, width);
  50.896 -		src0  = src1;
  50.897 -		src1  = src2;
  50.898 -		src2 += srcPitch >> 2;
  50.899 -		--count;
  50.900 -	}
  50.901 -	dst0 += dstPitch >> 1;
  50.902 -	dst1 += dstPitch >> 1;
  50.903 -	hq2xS_32_def(dst0, dst1, src0, src1, src1, width);
  50.904 -}
  50.905 -
  50.906 -void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.907 -          u8 *dstPtr, u32 dstPitch, int width, int height)
  50.908 -{
  50.909 -	u16 *dst0 = (u16 *)dstPtr;
  50.910 -	u16 *dst1 = dst0 + (dstPitch >> 1);
  50.911 -
  50.912 -	u16 *src0 = (u16 *)srcPtr;
  50.913 -	u16 *src1 = src0 + (srcPitch >> 1);
  50.914 -	u16 *src2 = src1 + (srcPitch >> 1);
  50.915 -
  50.916 -	lq2x_16_def(dst0, dst1, src0, src0, src1, width);
  50.917 -
  50.918 -	int count = height;
  50.919 -
  50.920 -	count -= 2;
  50.921 -	while (count)
  50.922 -	{
  50.923 -		dst0 += dstPitch;
  50.924 -		dst1 += dstPitch;
  50.925 -		lq2x_16_def(dst0, dst1, src0, src1, src2, width);
  50.926 -		src0  = src1;
  50.927 -		src1  = src2;
  50.928 -		src2 += srcPitch >> 1;
  50.929 -		--count;
  50.930 -	}
  50.931 -	dst0 += dstPitch;
  50.932 -	dst1 += dstPitch;
  50.933 -	lq2x_16_def(dst0, dst1, src0, src1, src1, width);
  50.934 -}
  50.935 -
  50.936 -void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  50.937 -            u8 *dstPtr, u32 dstPitch, int width, int height)
  50.938 -{
  50.939 -	u32 *dst0 = (u32 *)dstPtr;
  50.940 -	u32 *dst1 = dst0 + (dstPitch >> 2);
  50.941 -
  50.942 -	u32 *src0 = (u32 *)srcPtr;
  50.943 -	u32 *src1 = src0 + (srcPitch >> 2);
  50.944 -	u32 *src2 = src1 + (srcPitch >> 2);
  50.945 -	lq2x_32_def(dst0, dst1, src0, src0, src1, width);
  50.946 -
  50.947 -	int count = height;
  50.948 -
  50.949 -	count -= 2;
  50.950 -	while (count)
  50.951 -	{
  50.952 -		dst0 += dstPitch >> 1;
  50.953 -		dst1 += dstPitch >> 1;
  50.954 -		lq2x_32_def(dst0, dst1, src0, src1, src2, width);
  50.955 -		src0  = src1;
  50.956 -		src1  = src2;
  50.957 -		src2 += srcPitch >> 2;
  50.958 -		--count;
  50.959 -	}
  50.960 -	dst0 += dstPitch >> 1;
  50.961 -	dst1 += dstPitch >> 1;
  50.962 -	lq2x_32_def(dst0, dst1, src0, src1, src1, width);
  50.963 -}
  50.964 -
  50.965 -void hq2x_init(unsigned bits_per_pixel)
  50.966 -{
  50.967 -	interp_set(bits_per_pixel);
  50.968 -}
  50.969 -
    51.1 --- a/src/filters/hq2x.h	Sat Mar 03 10:54:39 2012 -0600
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,1824 +0,0 @@
    51.4 -case 0 : 
    51.5 -case 1 : 
    51.6 -case 4 : 
    51.7 -case 5 : 
    51.8 -case 32 : 
    51.9 -case 33 : 
   51.10 -case 36 : 
   51.11 -case 37 : 
   51.12 -case 128 : 
   51.13 -case 129 : 
   51.14 -case 132 : 
   51.15 -case 133 : 
   51.16 -case 160 : 
   51.17 -case 161 : 
   51.18 -case 164 : 
   51.19 -case 165 : 
   51.20 -{
   51.21 -  P0 = I211(4, 1, 3);
   51.22 -  P1 = I211(4, 1, 5);
   51.23 -  P2 = I211(4, 3, 7);
   51.24 -  P3 = I211(4, 5, 7);
   51.25 -} break;
   51.26 -case 2 : 
   51.27 -case 34 : 
   51.28 -case 130 : 
   51.29 -case 162 : 
   51.30 -{
   51.31 -  P0 = I31(4, 0);
   51.32 -  P1 = I31(4, 2);
   51.33 -  P2 = I211(4, 3, 7);
   51.34 -  P3 = I211(4, 5, 7);
   51.35 -} break;
   51.36 -case 3 : 
   51.37 -case 35 : 
   51.38 -case 131 : 
   51.39 -case 163 : 
   51.40 -{
   51.41 -  P0 = I31(4, 3);
   51.42 -  P1 = I31(4, 2);
   51.43 -  P2 = I211(4, 3, 7);
   51.44 -  P3 = I211(4, 5, 7);
   51.45 -} break;
   51.46 -case 6 : 
   51.47 -case 38 : 
   51.48 -case 134 : 
   51.49 -case 166 : 
   51.50 -{
   51.51 -  P0 = I31(4, 0);
   51.52 -  P1 = I31(4, 5);
   51.53 -  P2 = I211(4, 3, 7);
   51.54 -  P3 = I211(4, 5, 7);
   51.55 -} break;
   51.56 -case 7 : 
   51.57 -case 39 : 
   51.58 -case 135 : 
   51.59 -case 167 : 
   51.60 -{
   51.61 -  P0 = I31(4, 3);
   51.62 -  P1 = I31(4, 5);
   51.63 -  P2 = I211(4, 3, 7);
   51.64 -  P3 = I211(4, 5, 7);
   51.65 -} break;
   51.66 -case 8 : 
   51.67 -case 12 : 
   51.68 -case 136 : 
   51.69 -case 140 : 
   51.70 -{
   51.71 -  P0 = I31(4, 0);
   51.72 -  P1 = I211(4, 1, 5);
   51.73 -  P2 = I31(4, 6);
   51.74 -  P3 = I211(4, 5, 7);
   51.75 -} break;
   51.76 -case 9 : 
   51.77 -case 13 : 
   51.78 -case 137 : 
   51.79 -case 141 : 
   51.80 -{
   51.81 -  P0 = I31(4, 1);
   51.82 -  P1 = I211(4, 1, 5);
   51.83 -  P2 = I31(4, 6);
   51.84 -  P3 = I211(4, 5, 7);
   51.85 -} break;
   51.86 -case 10 : 
   51.87 -case 138 : 
   51.88 -{
   51.89 -  P1 = I31(4, 2);
   51.90 -  P2 = I31(4, 6);
   51.91 -  P3 = I211(4, 5, 7);
   51.92 -  if (MUL) {
   51.93 -    P0 = I31(4, 0);
   51.94 -  } else {
   51.95 -    P0 = I211(4, 1, 3);
   51.96 -  }
   51.97 -} break;
   51.98 -case 11 : 
   51.99 -case 139 : 
  51.100 -{
  51.101 -  P1 = I31(4, 2);
  51.102 -  P2 = I31(4, 6);
  51.103 -  P3 = I211(4, 5, 7);
  51.104 -  if (MUL) {
  51.105 -    P0 = IC(4);
  51.106 -  } else {
  51.107 -    P0 = I211(4, 1, 3);
  51.108 -  }
  51.109 -} break;
  51.110 -case 14 : 
  51.111 -case 142 : 
  51.112 -{
  51.113 -  P2 = I31(4, 6);
  51.114 -  P3 = I211(4, 5, 7);
  51.115 -  if (MUL) {
  51.116 -    P0 = I31(4, 0);
  51.117 -    P1 = I31(4, 5);
  51.118 -  } else {
  51.119 -    P0 = I332(1, 3, 4);
  51.120 -    P1 = I521(4, 1, 5);
  51.121 -  }
  51.122 -} break;
  51.123 -case 15 : 
  51.124 -case 143 : 
  51.125 -{
  51.126 -  P2 = I31(4, 6);
  51.127 -  P3 = I211(4, 5, 7);
  51.128 -  if (MUL) {
  51.129 -    P0 = IC(4);
  51.130 -    P1 = I31(4, 5);
  51.131 -  } else {
  51.132 -    P0 = I332(1, 3, 4);
  51.133 -    P1 = I521(4, 1, 5);
  51.134 -  }
  51.135 -} break;
  51.136 -case 16 : 
  51.137 -case 17 : 
  51.138 -case 48 : 
  51.139 -case 49 : 
  51.140 -{
  51.141 -  P0 = I211(4, 1, 3);
  51.142 -  P1 = I31(4, 2);
  51.143 -  P2 = I211(4, 3, 7);
  51.144 -  P3 = I31(4, 8);
  51.145 -} break;
  51.146 -case 18 : 
  51.147 -case 50 : 
  51.148 -{
  51.149 -  P0 = I31(4, 0);
  51.150 -  P2 = I211(4, 3, 7);
  51.151 -  P3 = I31(4, 8);
  51.152 -  if (MUR) {
  51.153 -    P1 = I31(4, 2);
  51.154 -  } else {
  51.155 -    P1 = I211(4, 1, 5);
  51.156 -  }
  51.157 -} break;
  51.158 -case 19 : 
  51.159 -case 51 : 
  51.160 -{
  51.161 -  P2 = I211(4, 3, 7);
  51.162 -  P3 = I31(4, 8);
  51.163 -  if (MUR) {
  51.164 -    P0 = I31(4, 3);
  51.165 -    P1 = I31(4, 2);
  51.166 -  } else {
  51.167 -    P0 = I521(4, 1, 3);
  51.168 -    P1 = I332(1, 5, 4);
  51.169 -  }
  51.170 -} break;
  51.171 -case 20 : 
  51.172 -case 21 : 
  51.173 -case 52 : 
  51.174 -case 53 : 
  51.175 -{
  51.176 -  P0 = I211(4, 1, 3);
  51.177 -  P1 = I31(4, 1);
  51.178 -  P2 = I211(4, 3, 7);
  51.179 -  P3 = I31(4, 8);
  51.180 -} break;
  51.181 -case 22 : 
  51.182 -case 54 : 
  51.183 -{
  51.184 -  P0 = I31(4, 0);
  51.185 -  P2 = I211(4, 3, 7);
  51.186 -  P3 = I31(4, 8);
  51.187 -  if (MUR) {
  51.188 -    P1 = IC(4);
  51.189 -  } else {
  51.190 -    P1 = I211(4, 1, 5);
  51.191 -  }
  51.192 -} break;
  51.193 -case 23 : 
  51.194 -case 55 : 
  51.195 -{
  51.196 -  P2 = I211(4, 3, 7);
  51.197 -  P3 = I31(4, 8);
  51.198 -  if (MUR) {
  51.199 -    P0 = I31(4, 3);
  51.200 -    P1 = IC(4);
  51.201 -  } else {
  51.202 -    P0 = I521(4, 1, 3);
  51.203 -    P1 = I332(1, 5, 4);
  51.204 -  }
  51.205 -} break;
  51.206 -case 24 : 
  51.207 -case 66 : 
  51.208 -{
  51.209 -  P0 = I31(4, 0);
  51.210 -  P1 = I31(4, 2);
  51.211 -  P2 = I31(4, 6);
  51.212 -  P3 = I31(4, 8);
  51.213 -} break;
  51.214 -case 25 : 
  51.215 -{
  51.216 -  P0 = I31(4, 1);
  51.217 -  P1 = I31(4, 2);
  51.218 -  P2 = I31(4, 6);
  51.219 -  P3 = I31(4, 8);
  51.220 -} break;
  51.221 -case 26 : 
  51.222 -case 31 : 
  51.223 -case 95 : 
  51.224 -{
  51.225 -  P2 = I31(4, 6);
  51.226 -  P3 = I31(4, 8);
  51.227 -  if (MUL) {
  51.228 -    P0 = IC(4);
  51.229 -  } else {
  51.230 -    P0 = I211(4, 1, 3);
  51.231 -  }
  51.232 -  if (MUR) {
  51.233 -    P1 = IC(4);
  51.234 -  } else {
  51.235 -    P1 = I211(4, 1, 5);
  51.236 -  }
  51.237 -} break;
  51.238 -case 27 : 
  51.239 -case 75 : 
  51.240 -{
  51.241 -  P1 = I31(4, 2);
  51.242 -  P2 = I31(4, 6);
  51.243 -  P3 = I31(4, 8);
  51.244 -  if (MUL) {
  51.245 -    P0 = IC(4);
  51.246 -  } else {
  51.247 -    P0 = I211(4, 1, 3);
  51.248 -  }
  51.249 -} break;
  51.250 -case 28 : 
  51.251 -{
  51.252 -  P0 = I31(4, 0);
  51.253 -  P1 = I31(4, 1);
  51.254 -  P2 = I31(4, 6);
  51.255 -  P3 = I31(4, 8);
  51.256 -} break;
  51.257 -case 29 : 
  51.258 -{
  51.259 -  P0 = I31(4, 1);
  51.260 -  P1 = I31(4, 1);
  51.261 -  P2 = I31(4, 6);
  51.262 -  P3 = I31(4, 8);
  51.263 -} break;
  51.264 -case 30 : 
  51.265 -case 86 : 
  51.266 -{
  51.267 -  P0 = I31(4, 0);
  51.268 -  P2 = I31(4, 6);
  51.269 -  P3 = I31(4, 8);
  51.270 -  if (MUR) {
  51.271 -    P1 = IC(4);
  51.272 -  } else {
  51.273 -    P1 = I211(4, 1, 5);
  51.274 -  }
  51.275 -} break;
  51.276 -case 40 : 
  51.277 -case 44 : 
  51.278 -case 168 : 
  51.279 -case 172 : 
  51.280 -{
  51.281 -  P0 = I31(4, 0);
  51.282 -  P1 = I211(4, 1, 5);
  51.283 -  P2 = I31(4, 7);
  51.284 -  P3 = I211(4, 5, 7);
  51.285 -} break;
  51.286 -case 41 : 
  51.287 -case 45 : 
  51.288 -case 169 : 
  51.289 -case 173 : 
  51.290 -{
  51.291 -  P0 = I31(4, 1);
  51.292 -  P1 = I211(4, 1, 5);
  51.293 -  P2 = I31(4, 7);
  51.294 -  P3 = I211(4, 5, 7);
  51.295 -} break;
  51.296 -case 42 : 
  51.297 -case 170 : 
  51.298 -{
  51.299 -  P1 = I31(4, 2);
  51.300 -  P3 = I211(4, 5, 7);
  51.301 -  if (MUL) {
  51.302 -    P0 = I31(4, 0);
  51.303 -    P2 = I31(4, 7);
  51.304 -  } else {
  51.305 -    P0 = I332(1, 3, 4);
  51.306 -    P2 = I521(4, 3, 7);
  51.307 -  }
  51.308 -} break;
  51.309 -case 43 : 
  51.310 -case 171 : 
  51.311 -{
  51.312 -  P1 = I31(4, 2);
  51.313 -  P3 = I211(4, 5, 7);
  51.314 -  if (MUL) {
  51.315 -    P0 = IC(4);
  51.316 -    P2 = I31(4, 7);
  51.317 -  } else {
  51.318 -    P0 = I332(1, 3, 4);
  51.319 -    P2 = I521(4, 3, 7);
  51.320 -  }
  51.321 -} break;
  51.322 -case 46 : 
  51.323 -case 174 : 
  51.324 -{
  51.325 -  P1 = I31(4, 5);
  51.326 -  P2 = I31(4, 7);
  51.327 -  P3 = I211(4, 5, 7);
  51.328 -  if (MUL) {
  51.329 -    P0 = I31(4, 0);
  51.330 -  } else {
  51.331 -    P0 = I611(4, 1, 3);
  51.332 -  }
  51.333 -} break;
  51.334 -case 47 : 
  51.335 -case 175 : 
  51.336 -{
  51.337 -  P1 = I31(4, 5);
  51.338 -  P2 = I31(4, 7);
  51.339 -  P3 = I211(4, 5, 7);
  51.340 -  if (MUL) {
  51.341 -    P0 = IC(4);
  51.342 -  } else {
  51.343 -    P0 = I1411(4, 1, 3);
  51.344 -  }
  51.345 -} break;
  51.346 -case 56 : 
  51.347 -{
  51.348 -  P0 = I31(4, 0);
  51.349 -  P1 = I31(4, 2);
  51.350 -  P2 = I31(4, 7);
  51.351 -  P3 = I31(4, 8);
  51.352 -} break;
  51.353 -case 57 : 
  51.354 -{
  51.355 -  P0 = I31(4, 1);
  51.356 -  P1 = I31(4, 2);
  51.357 -  P2 = I31(4, 7);
  51.358 -  P3 = I31(4, 8);
  51.359 -} break;
  51.360 -case 58 : 
  51.361 -{
  51.362 -  P2 = I31(4, 7);
  51.363 -  P3 = I31(4, 8);
  51.364 -  if (MUL) {
  51.365 -    P0 = I31(4, 0);
  51.366 -  } else {
  51.367 -    P0 = I611(4, 1, 3);
  51.368 -  }
  51.369 -  if (MUR) {
  51.370 -    P1 = I31(4, 2);
  51.371 -  } else {
  51.372 -    P1 = I611(4, 1, 5);
  51.373 -  }
  51.374 -} break;
  51.375 -case 59 : 
  51.376 -{
  51.377 -  P2 = I31(4, 7);
  51.378 -  P3 = I31(4, 8);
  51.379 -  if (MUL) {
  51.380 -    P0 = IC(4);
  51.381 -  } else {
  51.382 -    P0 = I211(4, 1, 3);
  51.383 -  }
  51.384 -  if (MUR) {
  51.385 -    P1 = I31(4, 2);
  51.386 -  } else {
  51.387 -    P1 = I611(4, 1, 5);
  51.388 -  }
  51.389 -} break;
  51.390 -case 60 : 
  51.391 -{
  51.392 -  P0 = I31(4, 0);
  51.393 -  P1 = I31(4, 1);
  51.394 -  P2 = I31(4, 7);
  51.395 -  P3 = I31(4, 8);
  51.396 -} break;
  51.397 -case 61 : 
  51.398 -{
  51.399 -  P0 = I31(4, 1);
  51.400 -  P1 = I31(4, 1);
  51.401 -  P2 = I31(4, 7);
  51.402 -  P3 = I31(4, 8);
  51.403 -} break;
  51.404 -case 62 : 
  51.405 -{
  51.406 -  P0 = I31(4, 0);
  51.407 -  P2 = I31(4, 7);
  51.408 -  P3 = I31(4, 8);
  51.409 -  if (MUR) {
  51.410 -    P1 = IC(4);
  51.411 -  } else {
  51.412 -    P1 = I211(4, 1, 5);
  51.413 -  }
  51.414 -} break;
  51.415 -case 63 : 
  51.416 -{
  51.417 -  P2 = I31(4, 7);
  51.418 -  P3 = I31(4, 8);
  51.419 -  if (MUL) {
  51.420 -    P0 = IC(4);
  51.421 -  } else {
  51.422 -    P0 = I1411(4, 1, 3);
  51.423 -  }
  51.424 -  if (MUR) {
  51.425 -    P1 = IC(4);
  51.426 -  } else {
  51.427 -    P1 = I211(4, 1, 5);
  51.428 -  }
  51.429 -} break;
  51.430 -case 64 : 
  51.431 -case 65 : 
  51.432 -case 68 : 
  51.433 -case 69 : 
  51.434 -{
  51.435 -  P0 = I211(4, 1, 3);
  51.436 -  P1 = I211(4, 1, 5);
  51.437 -  P2 = I31(4, 6);
  51.438 -  P3 = I31(4, 8);
  51.439 -} break;
  51.440 -case 67 : 
  51.441 -{
  51.442 -  P0 = I31(4, 3);
  51.443 -  P1 = I31(4, 2);
  51.444 -  P2 = I31(4, 6);
  51.445 -  P3 = I31(4, 8);
  51.446 -} break;
  51.447 -case 70 : 
  51.448 -{
  51.449 -  P0 = I31(4, 0);
  51.450 -  P1 = I31(4, 5);
  51.451 -  P2 = I31(4, 6);
  51.452 -  P3 = I31(4, 8);
  51.453 -} break;
  51.454 -case 71 : 
  51.455 -{
  51.456 -  P0 = I31(4, 3);
  51.457 -  P1 = I31(4, 5);
  51.458 -  P2 = I31(4, 6);
  51.459 -  P3 = I31(4, 8);
  51.460 -} break;
  51.461 -case 72 : 
  51.462 -case 76 : 
  51.463 -{
  51.464 -  P0 = I31(4, 0);
  51.465 -  P1 = I211(4, 1, 5);
  51.466 -  P3 = I31(4, 8);
  51.467 -  if (MDL) {
  51.468 -    P2 = I31(4, 6);
  51.469 -  } else {
  51.470 -    P2 = I211(4, 3, 7);
  51.471 -  }
  51.472 -} break;
  51.473 -case 73 : 
  51.474 -case 77 : 
  51.475 -{
  51.476 -  P1 = I211(4, 1, 5);
  51.477 -  P3 = I31(4, 8);
  51.478 -  if (MDL) {
  51.479 -    P0 = I31(4, 1);
  51.480 -    P2 = I31(4, 6);
  51.481 -  } else {
  51.482 -    P0 = I521(4, 3, 1);
  51.483 -    P2 = I332(3, 7, 4);
  51.484 -  }
  51.485 -} break;
  51.486 -case 74 : 
  51.487 -case 107 : 
  51.488 -case 123 : 
  51.489 -{
  51.490 -  P1 = I31(4, 2);
  51.491 -  P3 = I31(4, 8);
  51.492 -  if (MDL) {
  51.493 -    P2 = IC(4);
  51.494 -  } else {
  51.495 -    P2 = I211(4, 3, 7);
  51.496 -  }
  51.497 -  if (MUL) {
  51.498 -    P0 = IC(4);
  51.499 -  } else {
  51.500 -    P0 = I211(4, 1, 3);
  51.501 -  }
  51.502 -} break;
  51.503 -case 78 : 
  51.504 -{
  51.505 -  P1 = I31(4, 5);
  51.506 -  P3 = I31(4, 8);
  51.507 -  if (MDL) {
  51.508 -    P2 = I31(4, 6);
  51.509 -  } else {
  51.510 -    P2 = I611(4, 3, 7);
  51.511 -  }
  51.512 -  if (MUL) {
  51.513 -    P0 = I31(4, 0);
  51.514 -  } else {
  51.515 -    P0 = I611(4, 1, 3);
  51.516 -  }
  51.517 -} break;
  51.518 -case 79 : 
  51.519 -{
  51.520 -  P1 = I31(4, 5);
  51.521 -  P3 = I31(4, 8);
  51.522 -  if (MDL) {
  51.523 -    P2 = I31(4, 6);
  51.524 -  } else {
  51.525 -    P2 = I611(4, 3, 7);
  51.526 -  }
  51.527 -  if (MUL) {
  51.528 -    P0 = IC(4);
  51.529 -  } else {
  51.530 -    P0 = I211(4, 1, 3);
  51.531 -  }
  51.532 -} break;
  51.533 -case 80 : 
  51.534 -case 81 : 
  51.535 -{
  51.536 -  P0 = I211(4, 1, 3);
  51.537 -  P1 = I31(4, 2);
  51.538 -  P2 = I31(4, 6);
  51.539 -  if (MDR) {
  51.540 -    P3 = I31(4, 8);
  51.541 -  } else {
  51.542 -    P3 = I211(4, 5, 7);
  51.543 -  }
  51.544 -} break;
  51.545 -case 82 : 
  51.546 -case 214 : 
  51.547 -case 222 : 
  51.548 -{
  51.549 -  P0 = I31(4, 0);
  51.550 -  P2 = I31(4, 6);
  51.551 -  if (MDR) {
  51.552 -    P3 = IC(4);
  51.553 -  } else {
  51.554 -    P3 = I211(4, 5, 7);
  51.555 -  }
  51.556 -  if (MUR) {
  51.557 -    P1 = IC(4);
  51.558 -  } else {
  51.559 -    P1 = I211(4, 1, 5);
  51.560 -  }
  51.561 -} break;
  51.562 -case 83 : 
  51.563 -{
  51.564 -  P0 = I31(4, 3);
  51.565 -  P2 = I31(4, 6);
  51.566 -  if (MDR) {
  51.567 -    P3 = I31(4, 8);
  51.568 -  } else {
  51.569 -    P3 = I611(4, 5, 7);
  51.570 -  }
  51.571 -  if (MUR) {
  51.572 -    P1 = I31(4, 2);
  51.573 -  } else {
  51.574 -    P1 = I611(4, 1, 5);
  51.575 -  }
  51.576 -} break;
  51.577 -case 84 : 
  51.578 -case 85 : 
  51.579 -{
  51.580 -  P0 = I211(4, 1, 3);
  51.581 -  P2 = I31(4, 6);
  51.582 -  if (MDR) {
  51.583 -    P1 = I31(4, 1);
  51.584 -    P3 = I31(4, 8);
  51.585 -  } else {
  51.586 -    P1 = I521(4, 5, 1);
  51.587 -    P3 = I332(5, 7, 4);
  51.588 -  }
  51.589 -} break;
  51.590 -case 87 : 
  51.591 -{
  51.592 -  P0 = I31(4, 3);
  51.593 -  P2 = I31(4, 6);
  51.594 -  if (MDR) {
  51.595 -    P3 = I31(4, 8);
  51.596 -  } else {
  51.597 -    P3 = I611(4, 5, 7);
  51.598 -  }
  51.599 -  if (MUR) {
  51.600 -    P1 = IC(4);
  51.601 -  } else {
  51.602 -    P1 = I211(4, 1, 5);
  51.603 -  }
  51.604 -} break;
  51.605 -case 88 : 
  51.606 -case 248 : 
  51.607 -case 250 : 
  51.608 -{
  51.609 -  P0 = I31(4, 0);
  51.610 -  P1 = I31(4, 2);
  51.611 -  if (MDL) {
  51.612 -    P2 = IC(4);
  51.613 -  } else {
  51.614 -    P2 = I211(4, 3, 7);
  51.615 -  }
  51.616 -  if (MDR) {
  51.617 -    P3 = IC(4);
  51.618 -  } else {
  51.619 -    P3 = I211(4, 5, 7);
  51.620 -  }
  51.621 -} break;
  51.622 -case 89 : 
  51.623 -{
  51.624 -  P0 = I31(4, 1);
  51.625 -  P1 = I31(4, 2);
  51.626 -  if (MDL) {
  51.627 -    P2 = I31(4, 6);
  51.628 -  } else {
  51.629 -    P2 = I611(4, 3, 7);
  51.630 -  }
  51.631 -  if (MDR) {
  51.632 -    P3 = I31(4, 8);
  51.633 -  } else {
  51.634 -    P3 = I611(4, 5, 7);
  51.635 -  }
  51.636 -} break;
  51.637 -case 90 : 
  51.638 -{
  51.639 -  if (MDL) {
  51.640 -    P2 = I31(4, 6);
  51.641 -  } else {
  51.642 -    P2 = I611(4, 3, 7);
  51.643 -  }
  51.644 -  if (MDR) {
  51.645 -    P3 = I31(4, 8);
  51.646 -  } else {
  51.647 -    P3 = I611(4, 5, 7);
  51.648 -  }
  51.649 -  if (MUL) {
  51.650 -    P0 = I31(4, 0);
  51.651 -  } else {
  51.652 -    P0 = I611(4, 1, 3);
  51.653 -  }
  51.654 -  if (MUR) {
  51.655 -    P1 = I31(4, 2);
  51.656 -  } else {
  51.657 -    P1 = I611(4, 1, 5);
  51.658 -  }
  51.659 -} break;
  51.660 -case 91 : 
  51.661 -{
  51.662 -  if (MDL) {
  51.663 -    P2 = I31(4, 6);
  51.664 -  } else {
  51.665 -    P2 = I611(4, 3, 7);
  51.666 -  }
  51.667 -  if (MDR) {
  51.668 -    P3 = I31(4, 8);
  51.669 -  } else {
  51.670 -    P3 = I611(4, 5, 7);
  51.671 -  }
  51.672 -  if (MUL) {
  51.673 -    P0 = IC(4);
  51.674 -  } else {
  51.675 -    P0 = I211(4, 1, 3);
  51.676 -  }
  51.677 -  if (MUR) {
  51.678 -    P1 = I31(4, 2);
  51.679 -  } else {
  51.680 -    P1 = I611(4, 1, 5);
  51.681 -  }
  51.682 -} break;
  51.683 -case 92 : 
  51.684 -{
  51.685 -  P0 = I31(4, 0);
  51.686 -  P1 = I31(4, 1);
  51.687 -  if (MDL) {
  51.688 -    P2 = I31(4, 6);
  51.689 -  } else {
  51.690 -    P2 = I611(4, 3, 7);
  51.691 -  }
  51.692 -  if (MDR) {
  51.693 -    P3 = I31(4, 8);
  51.694 -  } else {
  51.695 -    P3 = I611(4, 5, 7);
  51.696 -  }
  51.697 -} break;
  51.698 -case 93 : 
  51.699 -{
  51.700 -  P0 = I31(4, 1);
  51.701 -  P1 = I31(4, 1);
  51.702 -  if (MDL) {
  51.703 -    P2 = I31(4, 6);
  51.704 -  } else {
  51.705 -    P2 = I611(4, 3, 7);
  51.706 -  }
  51.707 -  if (MDR) {
  51.708 -    P3 = I31(4, 8);
  51.709 -  } else {
  51.710 -    P3 = I611(4, 5, 7);
  51.711 -  }
  51.712 -} break;
  51.713 -case 94 : 
  51.714 -{
  51.715 -  if (MDL) {
  51.716 -    P2 = I31(4, 6);
  51.717 -  } else {
  51.718 -    P2 = I611(4, 3, 7);
  51.719 -  }
  51.720 -  if (MDR) {
  51.721 -    P3 = I31(4, 8);
  51.722 -  } else {
  51.723 -    P3 = I611(4, 5, 7);
  51.724 -  }
  51.725 -  if (MUL) {
  51.726 -    P0 = I31(4, 0);
  51.727 -  } else {
  51.728 -    P0 = I611(4, 1, 3);
  51.729 -  }
  51.730 -  if (MUR) {
  51.731 -    P1 = IC(4);
  51.732 -  } else {
  51.733 -    P1 = I211(4, 1, 5);
  51.734 -  }
  51.735 -} break;
  51.736 -case 96 : 
  51.737 -case 97 : 
  51.738 -case 100 : 
  51.739 -case 101 : 
  51.740 -{
  51.741 -  P0 = I211(4, 1, 3);
  51.742 -  P1 = I211(4, 1, 5);
  51.743 -  P2 = I31(4, 3);
  51.744 -  P3 = I31(4, 8);
  51.745 -} break;
  51.746 -case 98 : 
  51.747 -{
  51.748 -  P0 = I31(4, 0);
  51.749 -  P1 = I31(4, 2);
  51.750 -  P2 = I31(4, 3);
  51.751 -  P3 = I31(4, 8);
  51.752 -} break;
  51.753 -case 99 : 
  51.754 -{
  51.755 -  P0 = I31(4, 3);
  51.756 -  P1 = I31(4, 2);
  51.757 -  P2 = I31(4, 3);
  51.758 -  P3 = I31(4, 8);
  51.759 -} break;
  51.760 -case 102 : 
  51.761 -{
  51.762 -  P0 = I31(4, 0);
  51.763 -  P1 = I31(4, 5);
  51.764 -  P2 = I31(4, 3);
  51.765 -  P3 = I31(4, 8);
  51.766 -} break;
  51.767 -case 103 : 
  51.768 -{
  51.769 -  P0 = I31(4, 3);
  51.770 -  P1 = I31(4, 5);
  51.771 -  P2 = I31(4, 3);
  51.772 -  P3 = I31(4, 8);
  51.773 -} break;
  51.774 -case 104 : 
  51.775 -case 108 : 
  51.776 -{
  51.777 -  P0 = I31(4, 0);
  51.778 -  P1 = I211(4, 1, 5);
  51.779 -  P3 = I31(4, 8);
  51.780 -  if (MDL) {
  51.781 -    P2 = IC(4);
  51.782 -  } else {
  51.783 -    P2 = I211(4, 3, 7);
  51.784 -  }
  51.785 -} break;
  51.786 -case 105 : 
  51.787 -case 109 : 
  51.788 -{
  51.789 -  P1 = I211(4, 1, 5);
  51.790 -  P3 = I31(4, 8);
  51.791 -  if (MDL) {
  51.792 -    P0 = I31(4, 1);
  51.793 -    P2 = IC(4);
  51.794 -  } else {
  51.795 -    P0 = I521(4, 3, 1);
  51.796 -    P2 = I332(3, 7, 4);
  51.797 -  }
  51.798 -} break;
  51.799 -case 106 : 
  51.800 -case 120 : 
  51.801 -{
  51.802 -  P0 = I31(4, 0);
  51.803 -  P1 = I31(4, 2);
  51.804 -  P3 = I31(4, 8);
  51.805 -  if (MDL) {
  51.806 -    P2 = IC(4);
  51.807 -  } else {
  51.808 -    P2 = I211(4, 3, 7);
  51.809 -  }
  51.810 -} break;
  51.811 -case 110 : 
  51.812 -{
  51.813 -  P0 = I31(4, 0);
  51.814 -  P1 = I31(4, 5);
  51.815 -  P3 = I31(4, 8);
  51.816 -  if (MDL) {
  51.817 -    P2 = IC(4);
  51.818 -  } else {
  51.819 -    P2 = I211(4, 3, 7);
  51.820 -  }
  51.821 -} break;
  51.822 -case 111 : 
  51.823 -{
  51.824 -  P1 = I31(4, 5);
  51.825 -  P3 = I31(4, 8);
  51.826 -  if (MDL) {
  51.827 -    P2 = IC(4);
  51.828 -  } else {
  51.829 -    P2 = I211(4, 3, 7);
  51.830 -  }
  51.831 -  if (MUL) {
  51.832 -    P0 = IC(4);
  51.833 -  } else {
  51.834 -    P0 = I1411(4, 1, 3);
  51.835 -  }
  51.836 -} break;
  51.837 -case 112 : 
  51.838 -case 113 : 
  51.839 -{
  51.840 -  P0 = I211(4, 1, 3);
  51.841 -  P1 = I31(4, 2);
  51.842 -  if (MDR) {
  51.843 -    P2 = I31(4, 3);
  51.844 -    P3 = I31(4, 8);
  51.845 -  } else {
  51.846 -    P2 = I521(4, 7, 3);
  51.847 -    P3 = I332(5, 7, 4);
  51.848 -  }
  51.849 -} break;
  51.850 -case 114 : 
  51.851 -{
  51.852 -  P0 = I31(4, 0);
  51.853 -  P2 = I31(4, 3);
  51.854 -  if (MDR) {
  51.855 -    P3 = I31(4, 8);
  51.856 -  } else {
  51.857 -    P3 = I611(4, 5, 7);
  51.858 -  }
  51.859 -  if (MUR) {
  51.860 -    P1 = I31(4, 2);
  51.861 -  } else {
  51.862 -    P1 = I611(4, 1, 5);
  51.863 -  }
  51.864 -} break;
  51.865 -case 115 : 
  51.866 -{
  51.867 -  P0 = I31(4, 3);
  51.868 -  P2 = I31(4, 3);
  51.869 -  if (MDR) {
  51.870 -    P3 = I31(4, 8);
  51.871 -  } else {
  51.872 -    P3 = I611(4, 5, 7);
  51.873 -  }
  51.874 -  if (MUR) {
  51.875 -    P1 = I31(4, 2);
  51.876 -  } else {
  51.877 -    P1 = I611(4, 1, 5);
  51.878 -  }
  51.879 -} break;
  51.880 -case 116 : 
  51.881 -case 117 : 
  51.882 -{
  51.883 -  P0 = I211(4, 1, 3);
  51.884 -  P1 = I31(4, 1);
  51.885 -  P2 = I31(4, 3);
  51.886 -  if (MDR) {
  51.887 -    P3 = I31(4, 8);
  51.888 -  } else {
  51.889 -    P3 = I611(4, 5, 7);
  51.890 -  }
  51.891 -} break;
  51.892 -case 118 : 
  51.893 -{
  51.894 -  P0 = I31(4, 0);
  51.895 -  P2 = I31(4, 3);
  51.896 -  P3 = I31(4, 8);
  51.897 -  if (MUR) {
  51.898 -    P1 = IC(4);
  51.899 -  } else {
  51.900 -    P1 = I211(4, 1, 5);
  51.901 -  }
  51.902 -} break;
  51.903 -case 119 : 
  51.904 -{
  51.905 -  P2 = I31(4, 3);
  51.906 -  P3 = I31(4, 8);
  51.907 -  if (MUR) {
  51.908 -    P0 = I31(4, 3);
  51.909 -    P1 = IC(4);
  51.910 -  } else {
  51.911 -    P0 = I521(4, 1, 3);
  51.912 -    P1 = I332(1, 5, 4);
  51.913 -  }
  51.914 -} break;
  51.915 -case 121 : 
  51.916 -{
  51.917 -  P0 = I31(4, 1);
  51.918 -  P1 = I31(4, 2);
  51.919 -  if (MDL) {
  51.920 -    P2 = IC(4);
  51.921 -  } else {
  51.922 -    P2 = I211(4, 3, 7);
  51.923 -  }
  51.924 -  if (MDR) {
  51.925 -    P3 = I31(4, 8);
  51.926 -  } else {
  51.927 -    P3 = I611(4, 5, 7);
  51.928 -  }
  51.929 -} break;
  51.930 -case 122 : 
  51.931 -{
  51.932 -  if (MDL) {
  51.933 -    P2 = IC(4);
  51.934 -  } else {
  51.935 -    P2 = I211(4, 3, 7);
  51.936 -  }
  51.937 -  if (MDR) {
  51.938 -    P3 = I31(4, 8);
  51.939 -  } else {
  51.940 -    P3 = I611(4, 5, 7);
  51.941 -  }
  51.942 -  if (MUL) {
  51.943 -    P0 = I31(4, 0);
  51.944 -  } else {
  51.945 -    P0 = I611(4, 1, 3);
  51.946 -  }
  51.947 -  if (MUR) {
  51.948 -    P1 = I31(4, 2);
  51.949 -  } else {
  51.950 -    P1 = I611(4, 1, 5);
  51.951 -  }
  51.952 -} break;
  51.953 -case 124 : 
  51.954 -{
  51.955 -  P0 = I31(4, 0);
  51.956 -  P1 = I31(4, 1);
  51.957 -  P3 = I31(4, 8);
  51.958 -  if (MDL) {
  51.959 -    P2 = IC(4);
  51.960 -  } else {
  51.961 -    P2 = I211(4, 3, 7);
  51.962 -  }
  51.963 -} break;
  51.964 -case 125 : 
  51.965 -{
  51.966 -  P1 = I31(4, 1);
  51.967 -  P3 = I31(4, 8);
  51.968 -  if (MDL) {
  51.969 -    P0 = I31(4, 1);
  51.970 -    P2 = IC(4);
  51.971 -  } else {
  51.972 -    P0 = I521(4, 3, 1);
  51.973 -    P2 = I332(3, 7, 4);
  51.974 -  }
  51.975 -} break;
  51.976 -case 126 : 
  51.977 -{
  51.978 -  P0 = I31(4, 0);
  51.979 -  P3 = I31(4, 8);
  51.980 -  if (MDL) {
  51.981 -    P2 = IC(4);
  51.982 -  } else {
  51.983 -    P2 = I211(4, 3, 7);
  51.984 -  }
  51.985 -  if (MUR) {
  51.986 -    P1 = IC(4);
  51.987 -  } else {
  51.988 -    P1 = I211(4, 1, 5);
  51.989 -  }
  51.990 -} break;
  51.991 -case 127 : 
  51.992 -{
  51.993 -  P3 = I31(4, 8);
  51.994 -  if (MDL) {
  51.995 -    P2 = IC(4);
  51.996 -  } else {
  51.997 -    P2 = I211(4, 3, 7);
  51.998 -  }
  51.999 -  if (MUL) {
 51.1000 -    P0 = IC(4);
 51.1001 -  } else {
 51.1002 -    P0 = I1411(4, 1, 3);
 51.1003 -  }
 51.1004 -  if (MUR) {
 51.1005 -    P1 = IC(4);
 51.1006 -  } else {
 51.1007 -    P1 = I211(4, 1, 5);
 51.1008 -  }
 51.1009 -} break;
 51.1010 -case 144 : 
 51.1011 -case 145 : 
 51.1012 -case 176 : 
 51.1013 -case 177 : 
 51.1014 -{
 51.1015 -  P0 = I211(4, 1, 3);
 51.1016 -  P1 = I31(4, 2);
 51.1017 -  P2 = I211(4, 3, 7);
 51.1018 -  P3 = I31(4, 7);
 51.1019 -} break;
 51.1020 -case 146 : 
 51.1021 -case 178 : 
 51.1022 -{
 51.1023 -  P0 = I31(4, 0);
 51.1024 -  P2 = I211(4, 3, 7);
 51.1025 -  if (MUR) {
 51.1026 -    P1 = I31(4, 2);
 51.1027 -    P3 = I31(4, 7);
 51.1028 -  } else {
 51.1029 -    P1 = I332(1, 5, 4);
 51.1030 -    P3 = I521(4, 5, 7);
 51.1031 -  }
 51.1032 -} break;
 51.1033 -case 147 : 
 51.1034 -case 179 : 
 51.1035 -{
 51.1036 -  P0 = I31(4, 3);
 51.1037 -  P2 = I211(4, 3, 7);
 51.1038 -  P3 = I31(4, 7);
 51.1039 -  if (MUR) {
 51.1040 -    P1 = I31(4, 2);
 51.1041 -  } else {
 51.1042 -    P1 = I611(4, 1, 5);
 51.1043 -  }
 51.1044 -} break;
 51.1045 -case 148 : 
 51.1046 -case 149 : 
 51.1047 -case 180 : 
 51.1048 -case 181 : 
 51.1049 -{
 51.1050 -  P0 = I211(4, 1, 3);
 51.1051 -  P1 = I31(4, 1);
 51.1052 -  P2 = I211(4, 3, 7);
 51.1053 -  P3 = I31(4, 7);
 51.1054 -} break;
 51.1055 -case 150 : 
 51.1056 -case 182 : 
 51.1057 -{
 51.1058 -  P0 = I31(4, 0);
 51.1059 -  P2 = I211(4, 3, 7);
 51.1060 -  if (MUR) {
 51.1061 -    P1 = IC(4);
 51.1062 -    P3 = I31(4, 7);
 51.1063 -  } else {
 51.1064 -    P1 = I332(1, 5, 4);
 51.1065 -    P3 = I521(4, 5, 7);
 51.1066 -  }
 51.1067 -} break;
 51.1068 -case 151 : 
 51.1069 -case 183 : 
 51.1070 -{
 51.1071 -  P0 = I31(4, 3);
 51.1072 -  P2 = I211(4, 3, 7);
 51.1073 -  P3 = I31(4, 7);
 51.1074 -  if (MUR) {
 51.1075 -    P1 = IC(4);
 51.1076 -  } else {
 51.1077 -    P1 = I1411(4, 1, 5);
 51.1078 -  }
 51.1079 -} break;
 51.1080 -case 152 : 
 51.1081 -{
 51.1082 -  P0 = I31(4, 0);
 51.1083 -  P1 = I31(4, 2);
 51.1084 -  P2 = I31(4, 6);
 51.1085 -  P3 = I31(4, 7);
 51.1086 -} break;
 51.1087 -case 153 : 
 51.1088 -{
 51.1089 -  P0 = I31(4, 1);
 51.1090 -  P1 = I31(4, 2);
 51.1091 -  P2 = I31(4, 6);
 51.1092 -  P3 = I31(4, 7);
 51.1093 -} break;
 51.1094 -case 154 : 
 51.1095 -{
 51.1096 -  P2 = I31(4, 6);
 51.1097 -  P3 = I31(4, 7);
 51.1098 -  if (MUL) {
 51.1099 -    P0 = I31(4, 0);
 51.1100 -  } else {
 51.1101 -    P0 = I611(4, 1, 3);
 51.1102 -  }
 51.1103 -  if (MUR) {
 51.1104 -    P1 = I31(4, 2);
 51.1105 -  } else {
 51.1106 -    P1 = I611(4, 1, 5);
 51.1107 -  }
 51.1108 -} break;
 51.1109 -case 155 : 
 51.1110 -{
 51.1111 -  P1 = I31(4, 2);
 51.1112 -  P2 = I31(4, 6);
 51.1113 -  P3 = I31(4, 7);
 51.1114 -  if (MUL) {
 51.1115 -    P0 = IC(4);
 51.1116 -  } else {
 51.1117 -    P0 = I211(4, 1, 3);
 51.1118 -  }
 51.1119 -} break;
 51.1120 -case 156 : 
 51.1121 -{
 51.1122 -  P0 = I31(4, 0);
 51.1123 -  P1 = I31(4, 1);
 51.1124 -  P2 = I31(4, 6);
 51.1125 -  P3 = I31(4, 7);
 51.1126 -} break;
 51.1127 -case 157 : 
 51.1128 -{
 51.1129 -  P0 = I31(4, 1);
 51.1130 -  P1 = I31(4, 1);
 51.1131 -  P2 = I31(4, 6);
 51.1132 -  P3 = I31(4, 7);
 51.1133 -} break;
 51.1134 -case 158 : 
 51.1135 -{
 51.1136 -  P2 = I31(4, 6);
 51.1137 -  P3 = I31(4, 7);
 51.1138 -  if (MUL) {
 51.1139 -    P0 = I31(4, 0);
 51.1140 -  } else {
 51.1141 -    P0 = I611(4, 1, 3);
 51.1142 -  }
 51.1143 -  if (MUR) {
 51.1144 -    P1 = IC(4);
 51.1145 -  } else {
 51.1146 -    P1 = I211(4, 1, 5);
 51.1147 -  }
 51.1148 -} break;
 51.1149 -case 159 : 
 51.1150 -{
 51.1151 -  P2 = I31(4, 6);
 51.1152 -  P3 = I31(4, 7);
 51.1153 -  if (MUL) {
 51.1154 -    P0 = IC(4);
 51.1155 -  } else {
 51.1156 -    P0 = I211(4, 1, 3);
 51.1157 -  }
 51.1158 -  if (MUR) {
 51.1159 -    P1 = IC(4);
 51.1160 -  } else {
 51.1161 -    P1 = I1411(4, 1, 5);
 51.1162 -  }
 51.1163 -} break;
 51.1164 -case 184 : 
 51.1165 -{
 51.1166 -  P0 = I31(4, 0);
 51.1167 -  P1 = I31(4, 2);
 51.1168 -  P2 = I31(4, 7);
 51.1169 -  P3 = I31(4, 7);
 51.1170 -} break;
 51.1171 -case 185 : 
 51.1172 -{
 51.1173 -  P0 = I31(4, 1);
 51.1174 -  P1 = I31(4, 2);
 51.1175 -  P2 = I31(4, 7);
 51.1176 -  P3 = I31(4, 7);
 51.1177 -} break;
 51.1178 -case 186 : 
 51.1179 -{
 51.1180 -  P2 = I31(4, 7);
 51.1181 -  P3 = I31(4, 7);
 51.1182 -  if (MUL) {
 51.1183 -    P0 = I31(4, 0);
 51.1184 -  } else {
 51.1185 -    P0 = I611(4, 1, 3);
 51.1186 -  }
 51.1187 -  if (MUR) {
 51.1188 -    P1 = I31(4, 2);
 51.1189 -  } else {
 51.1190 -    P1 = I611(4, 1, 5);
 51.1191 -  }
 51.1192 -} break;
 51.1193 -case 187 : 
 51.1194 -{
 51.1195 -  P1 = I31(4, 2);
 51.1196 -  P3 = I31(4, 7);
 51.1197 -  if (MUL) {
 51.1198 -    P0 = IC(4);
 51.1199 -    P2 = I31(4, 7);
 51.1200 -  } else {
 51.1201 -    P0 = I332(1, 3, 4);
 51.1202 -    P2 = I521(4, 3, 7);
 51.1203 -  }
 51.1204 -} break;
 51.1205 -case 188 : 
 51.1206 -{
 51.1207 -  P0 = I31(4, 0);
 51.1208 -  P1 = I31(4, 1);
 51.1209 -  P2 = I31(4, 7);
 51.1210 -  P3 = I31(4, 7);
 51.1211 -} break;
 51.1212 -case 189 : 
 51.1213 -{
 51.1214 -  P0 = I31(4, 1);
 51.1215 -  P1 = I31(4, 1);
 51.1216 -  P2 = I31(4, 7);
 51.1217 -  P3 = I31(4, 7);
 51.1218 -} break;
 51.1219 -case 190 : 
 51.1220 -{
 51.1221 -  P0 = I31(4, 0);
 51.1222 -  P2 = I31(4, 7);
 51.1223 -  if (MUR) {
 51.1224 -    P1 = IC(4);
 51.1225 -    P3 = I31(4, 7);
 51.1226 -  } else {
 51.1227 -    P1 = I332(1, 5, 4);
 51.1228 -    P3 = I521(4, 5, 7);
 51.1229 -  }
 51.1230 -} break;
 51.1231 -case 191 : 
 51.1232 -{
 51.1233 -  P2 = I31(4, 7);
 51.1234 -  P3 = I31(4, 7);
 51.1235 -  if (MUL) {
 51.1236 -    P0 = IC(4);
 51.1237 -  } else {
 51.1238 -    P0 = I1411(4, 1, 3);
 51.1239 -  }
 51.1240 -  if (MUR) {
 51.1241 -    P1 = IC(4);
 51.1242 -  } else {
 51.1243 -    P1 = I1411(4, 1, 5);
 51.1244 -  }
 51.1245 -} break;
 51.1246 -case 192 : 
 51.1247 -case 193 : 
 51.1248 -case 196 : 
 51.1249 -case 197 : 
 51.1250 -{
 51.1251 -  P0 = I211(4, 1, 3);
 51.1252 -  P1 = I211(4, 1, 5);
 51.1253 -  P2 = I31(4, 6);
 51.1254 -  P3 = I31(4, 5);
 51.1255 -} break;
 51.1256 -case 194 : 
 51.1257 -{
 51.1258 -  P0 = I31(4, 0);
 51.1259 -  P1 = I31(4, 2);
 51.1260 -  P2 = I31(4, 6);
 51.1261 -  P3 = I31(4, 5);
 51.1262 -} break;
 51.1263 -case 195 : 
 51.1264 -{
 51.1265 -  P0 = I31(4, 3);
 51.1266 -  P1 = I31(4, 2);
 51.1267 -  P2 = I31(4, 6);
 51.1268 -  P3 = I31(4, 5);
 51.1269 -} break;
 51.1270 -case 198 : 
 51.1271 -{
 51.1272 -  P0 = I31(4, 0);
 51.1273 -  P1 = I31(4, 5);
 51.1274 -  P2 = I31(4, 6);
 51.1275 -  P3 = I31(4, 5);
 51.1276 -} break;
 51.1277 -case 199 : 
 51.1278 -{
 51.1279 -  P0 = I31(4, 3);
 51.1280 -  P1 = I31(4, 5);
 51.1281 -  P2 = I31(4, 6);
 51.1282 -  P3 = I31(4, 5);
 51.1283 -} break;
 51.1284 -case 200 : 
 51.1285 -case 204 : 
 51.1286 -{
 51.1287 -  P0 = I31(4, 0);
 51.1288 -  P1 = I211(4, 1, 5);
 51.1289 -  if (MDL) {
 51.1290 -    P2 = I31(4, 6);
 51.1291 -    P3 = I31(4, 5);
 51.1292 -  } else {
 51.1293 -    P2 = I332(3, 7, 4);
 51.1294 -    P3 = I521(4, 7, 5);
 51.1295 -  }
 51.1296 -} break;
 51.1297 -case 201 : 
 51.1298 -case 205 : 
 51.1299 -{
 51.1300 -  P0 = I31(4, 1);
 51.1301 -  P1 = I211(4, 1, 5);
 51.1302 -  P3 = I31(4, 5);
 51.1303 -  if (MDL) {
 51.1304 -    P2 = I31(4, 6);
 51.1305 -  } else {
 51.1306 -    P2 = I611(4, 3, 7);
 51.1307 -  }
 51.1308 -} break;
 51.1309 -case 202 : 
 51.1310 -{
 51.1311 -  P1 = I31(4, 2);
 51.1312 -  P3 = I31(4, 5);
 51.1313 -  if (MDL) {
 51.1314 -    P2 = I31(4, 6);
 51.1315 -  } else {
 51.1316 -    P2 = I611(4, 3, 7);
 51.1317 -  }
 51.1318 -  if (MUL) {
 51.1319 -    P0 = I31(4, 0);
 51.1320 -  } else {
 51.1321 -    P0 = I611(4, 1, 3);
 51.1322 -  }
 51.1323 -} break;
 51.1324 -case 203 : 
 51.1325 -{
 51.1326 -  P1 = I31(4, 2);
 51.1327 -  P2 = I31(4, 6);
 51.1328 -  P3 = I31(4, 5);
 51.1329 -  if (MUL) {
 51.1330 -    P0 = IC(4);
 51.1331 -  } else {
 51.1332 -    P0 = I211(4, 1, 3);
 51.1333 -  }
 51.1334 -} break;
 51.1335 -case 206 : 
 51.1336 -{
 51.1337 -  P1 = I31(4, 5);
 51.1338 -  P3 = I31(4, 5);
 51.1339 -  if (MDL) {
 51.1340 -    P2 = I31(4, 6);
 51.1341 -  } else {
 51.1342 -    P2 = I611(4, 3, 7);
 51.1343 -  }
 51.1344 -  if (MUL) {
 51.1345 -    P0 = I31(4, 0);
 51.1346 -  } else {
 51.1347 -    P0 = I611(4, 1, 3);
 51.1348 -  }
 51.1349 -} break;
 51.1350 -case 207 : 
 51.1351 -{
 51.1352 -  P2 = I31(4, 6);
 51.1353 -  P3 = I31(4, 5);
 51.1354 -  if (MUL) {
 51.1355 -    P0 = IC(4);
 51.1356 -    P1 = I31(4, 5);
 51.1357 -  } else {
 51.1358 -    P0 = I332(1, 3, 4);
 51.1359 -    P1 = I521(4, 1, 5);
 51.1360 -  }
 51.1361 -} break;
 51.1362 -case 208 : 
 51.1363 -case 209 : 
 51.1364 -{
 51.1365 -  P0 = I211(4, 1, 3);
 51.1366 -  P1 = I31(4, 2);
 51.1367 -  P2 = I31(4, 6);
 51.1368 -  if (MDR) {
 51.1369 -    P3 = IC(4);
 51.1370 -  } else {
 51.1371 -    P3 = I211(4, 5, 7);
 51.1372 -  }
 51.1373 -} break;
 51.1374 -case 210 : 
 51.1375 -case 216 : 
 51.1376 -{
 51.1377 -  P0 = I31(4, 0);
 51.1378 -  P1 = I31(4, 2);
 51.1379 -  P2 = I31(4, 6);
 51.1380 -  if (MDR) {
 51.1381 -    P3 = IC(4);
 51.1382 -  } else {
 51.1383 -    P3 = I211(4, 5, 7);
 51.1384 -  }
 51.1385 -} break;
 51.1386 -case 211 : 
 51.1387 -{
 51.1388 -  P0 = I31(4, 3);
 51.1389 -  P1 = I31(4, 2);
 51.1390 -  P2 = I31(4, 6);
 51.1391 -  if (MDR) {
 51.1392 -    P3 = IC(4);
 51.1393 -  } else {
 51.1394 -    P3 = I211(4, 5, 7);
 51.1395 -  }
 51.1396 -} break;
 51.1397 -case 212 : 
 51.1398 -case 213 : 
 51.1399 -{
 51.1400 -  P0 = I211(4, 1, 3);
 51.1401 -  P2 = I31(4, 6);
 51.1402 -  if (MDR) {
 51.1403 -    P1 = I31(4, 1);
 51.1404 -    P3 = IC(4);
 51.1405 -  } else {
 51.1406 -    P1 = I521(4, 5, 1);
 51.1407 -    P3 = I332(5, 7, 4);
 51.1408 -  }
 51.1409 -} break;
 51.1410 -case 215 : 
 51.1411 -{
 51.1412 -  P0 = I31(4, 3);
 51.1413 -  P2 = I31(4, 6);
 51.1414 -  if (MDR) {
 51.1415 -    P3 = IC(4);
 51.1416 -  } else {
 51.1417 -    P3 = I211(4, 5, 7);
 51.1418 -  }
 51.1419 -  if (MUR) {
 51.1420 -    P1 = IC(4);
 51.1421 -  } else {
 51.1422 -    P1 = I1411(4, 1, 5);
 51.1423 -  }
 51.1424 -} break;
 51.1425 -case 217 : 
 51.1426 -{
 51.1427 -  P0 = I31(4, 1);
 51.1428 -  P1 = I31(4, 2);
 51.1429 -  P2 = I31(4, 6);
 51.1430 -  if (MDR) {
 51.1431 -    P3 = IC(4);
 51.1432 -  } else {
 51.1433 -    P3 = I211(4, 5, 7);
 51.1434 -  }
 51.1435 -} break;
 51.1436 -case 218 : 
 51.1437 -{
 51.1438 -  if (MDL) {
 51.1439 -    P2 = I31(4, 6);
 51.1440 -  } else {
 51.1441 -    P2 = I611(4, 3, 7);
 51.1442 -  }
 51.1443 -  if (MDR) {
 51.1444 -    P3 = IC(4);
 51.1445 -  } else {
 51.1446 -    P3 = I211(4, 5, 7);
 51.1447 -  }
 51.1448 -  if (MUL) {
 51.1449 -    P0 = I31(4, 0);
 51.1450 -  } else {
 51.1451 -    P0 = I611(4, 1, 3);
 51.1452 -  }
 51.1453 -  if (MUR) {
 51.1454 -    P1 = I31(4, 2);
 51.1455 -  } else {
 51.1456 -    P1 = I611(4, 1, 5);
 51.1457 -  }
 51.1458 -} break;
 51.1459 -case 219 : 
 51.1460 -{
 51.1461 -  P1 = I31(4, 2);
 51.1462 -  P2 = I31(4, 6);
 51.1463 -  if (MDR) {
 51.1464 -    P3 = IC(4);
 51.1465 -  } else {
 51.1466 -    P3 = I211(4, 5, 7);
 51.1467 -  }
 51.1468 -  if (MUL) {
 51.1469 -    P0 = IC(4);
 51.1470 -  } else {
 51.1471 -    P0 = I211(4, 1, 3);
 51.1472 -  }
 51.1473 -} break;
 51.1474 -case 220 : 
 51.1475 -{
 51.1476 -  P0 = I31(4, 0);
 51.1477 -  P1 = I31(4, 1);
 51.1478 -  if (MDL) {
 51.1479 -    P2 = I31(4, 6);
 51.1480 -  } else {
 51.1481 -    P2 = I611(4, 3, 7);
 51.1482 -  }
 51.1483 -  if (MDR) {
 51.1484 -    P3 = IC(4);
 51.1485 -  } else {
 51.1486 -    P3 = I211(4, 5, 7);
 51.1487 -  }
 51.1488 -} break;
 51.1489 -case 221 : 
 51.1490 -{
 51.1491 -  P0 = I31(4, 1);
 51.1492 -  P2 = I31(4, 6);
 51.1493 -  if (MDR) {
 51.1494 -    P1 = I31(4, 1);
 51.1495 -    P3 = IC(4);
 51.1496 -  } else {
 51.1497 -    P1 = I521(4, 5, 1);
 51.1498 -    P3 = I332(5, 7, 4);
 51.1499 -  }
 51.1500 -} break;
 51.1501 -case 223 : 
 51.1502 -{
 51.1503 -  P2 = I31(4, 6);
 51.1504 -  if (MDR) {
 51.1505 -    P3 = IC(4);
 51.1506 -  } else {
 51.1507 -    P3 = I211(4, 5, 7);
 51.1508 -  }
 51.1509 -  if (MUL) {
 51.1510 -    P0 = IC(4);
 51.1511 -  } else {
 51.1512 -    P0 = I211(4, 1, 3);
 51.1513 -  }
 51.1514 -  if (MUR) {
 51.1515 -    P1 = IC(4);
 51.1516 -  } else {
 51.1517 -    P1 = I1411(4, 1, 5);
 51.1518 -  }
 51.1519 -} break;
 51.1520 -case 224 : 
 51.1521 -case 225 : 
 51.1522 -case 228 : 
 51.1523 -case 229 : 
 51.1524 -{
 51.1525 -  P0 = I211(4, 1, 3);
 51.1526 -  P1 = I211(4, 1, 5);
 51.1527 -  P2 = I31(4, 3);
 51.1528 -  P3 = I31(4, 5);
 51.1529 -} break;
 51.1530 -case 226 : 
 51.1531 -{
 51.1532 -  P0 = I31(4, 0);
 51.1533 -  P1 = I31(4, 2);
 51.1534 -  P2 = I31(4, 3);
 51.1535 -  P3 = I31(4, 5);
 51.1536 -} break;
 51.1537 -case 227 : 
 51.1538 -{
 51.1539 -  P0 = I31(4, 3);
 51.1540 -  P1 = I31(4, 2);
 51.1541 -  P2 = I31(4, 3);
 51.1542 -  P3 = I31(4, 5);
 51.1543 -} break;
 51.1544 -case 230 : 
 51.1545 -{
 51.1546 -  P0 = I31(4, 0);
 51.1547 -  P1 = I31(4, 5);
 51.1548 -  P2 = I31(4, 3);
 51.1549 -  P3 = I31(4, 5);
 51.1550 -} break;
 51.1551 -case 231 : 
 51.1552 -{
 51.1553 -  P0 = I31(4, 3);
 51.1554 -  P1 = I31(4, 5);
 51.1555 -  P2 = I31(4, 3);
 51.1556 -  P3 = I31(4, 5);
 51.1557 -} break;
 51.1558 -case 232 : 
 51.1559 -case 236 : 
 51.1560 -{
 51.1561 -  P0 = I31(4, 0);
 51.1562 -  P1 = I211(4, 1, 5);
 51.1563 -  if (MDL) {
 51.1564 -    P2 = IC(4);
 51.1565 -    P3 = I31(4, 5);
 51.1566 -  } else {
 51.1567 -    P2 = I332(3, 7, 4);
 51.1568 -    P3 = I521(4, 7, 5);
 51.1569 -  }
 51.1570 -} break;
 51.1571 -case 233 : 
 51.1572 -case 237 : 
 51.1573 -{
 51.1574 -  P0 = I31(4, 1);
 51.1575 -  P1 = I211(4, 1, 5);
 51.1576 -  P3 = I31(4, 5);
 51.1577 -  if (MDL) {
 51.1578 -    P2 = IC(4);
 51.1579 -  } else {
 51.1580 -    P2 = I1411(4, 3, 7);
 51.1581 -  }
 51.1582 -} break;
 51.1583 -case 234 : 
 51.1584 -{
 51.1585 -  P1 = I31(4, 2);
 51.1586 -  P3 = I31(4, 5);
 51.1587 -  if (MDL) {
 51.1588 -    P2 = IC(4);
 51.1589 -  } else {
 51.1590 -    P2 = I211(4, 3, 7);
 51.1591 -  }
 51.1592 -  if (MUL) {
 51.1593 -    P0 = I31(4, 0);
 51.1594 -  } else {
 51.1595 -    P0 = I611(4, 1, 3);
 51.1596 -  }
 51.1597 -} break;
 51.1598 -case 235 : 
 51.1599 -{
 51.1600 -  P1 = I31(4, 2);
 51.1601 -  P3 = I31(4, 5);
 51.1602 -  if (MDL) {
 51.1603 -    P2 = IC(4);
 51.1604 -  } else {
 51.1605 -    P2 = I1411(4, 3, 7);
 51.1606 -  }
 51.1607 -  if (MUL) {
 51.1608 -    P0 = IC(4);
 51.1609 -  } else {
 51.1610 -    P0 = I211(4, 1, 3);
 51.1611 -  }
 51.1612 -} break;
 51.1613 -case 238 : 
 51.1614 -{
 51.1615 -  P0 = I31(4, 0);
 51.1616 -  P1 = I31(4, 5);
 51.1617 -  if (MDL) {
 51.1618 -    P2 = IC(4);
 51.1619 -    P3 = I31(4, 5);
 51.1620 -  } else {
 51.1621 -    P2 = I332(3, 7, 4);
 51.1622 -    P3 = I521(4, 7, 5);
 51.1623 -  }
 51.1624 -} break;
 51.1625 -case 239 : 
 51.1626 -{
 51.1627 -  P1 = I31(4, 5);
 51.1628 -  P3 = I31(4, 5);
 51.1629 -  if (MDL) {
 51.1630 -    P2 = IC(4);
 51.1631 -  } else {
 51.1632 -    P2 = I1411(4, 3, 7);
 51.1633 -  }
 51.1634 -  if (MUL) {
 51.1635 -    P0 = IC(4);
 51.1636 -  } else {
 51.1637 -    P0 = I1411(4, 1, 3);
 51.1638 -  }
 51.1639 -} break;
 51.1640 -case 240 : 
 51.1641 -case 241 : 
 51.1642 -{
 51.1643 -  P0 = I211(4, 1, 3);
 51.1644 -  P1 = I31(4, 2);
 51.1645 -  if (MDR) {
 51.1646 -    P2 = I31(4, 3);
 51.1647 -    P3 = IC(4);
 51.1648 -  } else {
 51.1649 -    P2 = I521(4, 7, 3);
 51.1650 -    P3 = I332(5, 7, 4);
 51.1651 -  }
 51.1652 -} break;
 51.1653 -case 242 : 
 51.1654 -{
 51.1655 -  P0 = I31(4, 0);
 51.1656 -  P2 = I31(4, 3);
 51.1657 -  if (MDR) {
 51.1658 -    P3 = IC(4);
 51.1659 -  } else {
 51.1660 -    P3 = I211(4, 5, 7);
 51.1661 -  }
 51.1662 -  if (MUR) {
 51.1663 -    P1 = I31(4, 2);
 51.1664 -  } else {
 51.1665 -    P1 = I611(4, 1, 5);
 51.1666 -  }
 51.1667 -} break;
 51.1668 -case 243 : 
 51.1669 -{
 51.1670 -  P0 = I31(4, 3);
 51.1671 -  P1 = I31(4, 2);
 51.1672 -  if (MDR) {
 51.1673 -    P2 = I31(4, 3);
 51.1674 -    P3 = IC(4);
 51.1675 -  } else {
 51.1676 -    P2 = I521(4, 7, 3);
 51.1677 -    P3 = I332(5, 7, 4);
 51.1678 -  }
 51.1679 -} break;
 51.1680 -case 244 : 
 51.1681 -case 245 : 
 51.1682 -{
 51.1683 -  P0 = I211(4, 1, 3);
 51.1684 -  P1 = I31(4, 1);
 51.1685 -  P2 = I31(4, 3);
 51.1686 -  if (MDR) {
 51.1687 -    P3 = IC(4);
 51.1688 -  } else {
 51.1689 -    P3 = I1411(4, 5, 7);
 51.1690 -  }
 51.1691 -} break;
 51.1692 -case 246 : 
 51.1693 -{
 51.1694 -  P0 = I31(4, 0);
 51.1695 -  P2 = I31(4, 3);
 51.1696 -  if (MDR) {
 51.1697 -    P3 = IC(4);
 51.1698 -  } else {
 51.1699 -    P3 = I1411(4, 5, 7);
 51.1700 -  }
 51.1701 -  if (MUR) {
 51.1702 -    P1 = IC(4);
 51.1703 -  } else {
 51.1704 -    P1 = I211(4, 1, 5);
 51.1705 -  }
 51.1706 -} break;
 51.1707 -case 247 : 
 51.1708 -{
 51.1709 -  P0 = I31(4, 3);
 51.1710 -  P2 = I31(4, 3);
 51.1711 -  if (MDR) {
 51.1712 -    P3 = IC(4);
 51.1713 -  } else {
 51.1714 -    P3 = I1411(4, 5, 7);
 51.1715 -  }
 51.1716 -  if (MUR) {
 51.1717 -    P1 = IC(4);
 51.1718 -  } else {
 51.1719 -    P1 = I1411(4, 1, 5);
 51.1720 -  }
 51.1721 -} break;
 51.1722 -case 249 : 
 51.1723 -{
 51.1724 -  P0 = I31(4, 1);
 51.1725 -  P1 = I31(4, 2);
 51.1726 -  if (MDL) {
 51.1727 -    P2 = IC(4);
 51.1728 -  } else {
 51.1729 -    P2 = I1411(4, 3, 7);
 51.1730 -  }
 51.1731 -  if (MDR) {
 51.1732 -    P3 = IC(4);
 51.1733 -  } else {
 51.1734 -    P3 = I211(4, 5, 7);
 51.1735 -  }
 51.1736 -} break;
 51.1737 -case 251 : 
 51.1738 -{
 51.1739 -  P1 = I31(4, 2);
 51.1740 -  if (MDL) {
 51.1741 -    P2 = IC(4);
 51.1742 -  } else {
 51.1743 -    P2 = I1411(4, 3, 7);
 51.1744 -  }
 51.1745 -  if (MDR) {
 51.1746 -    P3 = IC(4);
 51.1747 -  } else {
 51.1748 -    P3 = I211(4, 5, 7);
 51.1749 -  }
 51.1750 -  if (MUL) {
 51.1751 -    P0 = IC(4);
 51.1752 -  } else {
 51.1753 -    P0 = I211(4, 1, 3);
 51.1754 -  }
 51.1755 -} break;
 51.1756 -case 252 : 
 51.1757 -{
 51.1758 -  P0 = I31(4, 0);
 51.1759 -  P1 = I31(4, 1);
 51.1760 -  if (MDL) {
 51.1761 -    P2 = IC(4);
 51.1762 -  } else {
 51.1763 -    P2 = I211(4, 3, 7);
 51.1764 -  }
 51.1765 -  if (MDR) {
 51.1766 -    P3 = IC(4);
 51.1767 -  } else {
 51.1768 -    P3 = I1411(4, 5, 7);
 51.1769 -  }
 51.1770 -} break;
 51.1771 -case 253 : 
 51.1772 -{
 51.1773 -  P0 = I31(4, 1);
 51.1774 -  P1 = I31(4, 1);
 51.1775 -  if (MDL) {
 51.1776 -    P2 = IC(4);
 51.1777 -  } else {
 51.1778 -    P2 = I1411(4, 3, 7);
 51.1779 -  }
 51.1780 -  if (MDR) {
 51.1781 -    P3 = IC(4);
 51.1782 -  } else {
 51.1783 -    P3 = I1411(4, 5, 7);
 51.1784 -  }
 51.1785 -} break;
 51.1786 -case 254 : 
 51.1787 -{
 51.1788 -  P0 = I31(4, 0);
 51.1789 -  if (MDL) {
 51.1790 -    P2 = IC(4);
 51.1791 -  } else {
 51.1792 -    P2 = I211(4, 3, 7);
 51.1793 -  }
 51.1794 -  if (MDR) {
 51.1795 -    P3 = IC(4);
 51.1796 -  } else {
 51.1797 -    P3 = I1411(4, 5, 7);
 51.1798 -  }
 51.1799 -  if (MUR) {
 51.1800 -    P1 = IC(4);
 51.1801 -  } else {
 51.1802 -    P1 = I211(4, 1, 5);
 51.1803 -  }
 51.1804 -} break;
 51.1805 -case 255 : 
 51.1806 -{
 51.1807 -  if (MDL) {
 51.1808 -    P2 = IC(4);
 51.1809 -  } else {
 51.1810 -    P2 = I1411(4, 3, 7);
 51.1811 -  }
 51.1812 -  if (MDR) {
 51.1813 -    P3 = IC(4);
 51.1814 -  } else {
 51.1815 -    P3 = I1411(4, 5, 7);
 51.1816 -  }
 51.1817 -  if (MUL) {
 51.1818 -    P0 = IC(4);
 51.1819 -  } else {
 51.1820 -    P0 = I1411(4, 1, 3);
 51.1821 -  }
 51.1822 -  if (MUR) {
 51.1823 -    P1 = IC(4);
 51.1824 -  } else {
 51.1825 -    P1 = I1411(4, 1, 5);
 51.1826 -  }
 51.1827 -} break;
    52.1 --- a/src/filters/hq3x32.cpp	Sat Mar 03 10:54:39 2012 -0600
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,445 +0,0 @@
    52.4 -#include "../Port.h"
    52.5 -#include "hq_shared32.h"
    52.6 -#include "interp.h"
    52.7 -
    52.8 -#define SIZE_PIXEL 2 // 16bit = 2 bytes
    52.9 -#define PIXELTYPE unsigned short
   52.10 -#define Interp1 Interp1_16
   52.11 -#define Interp2 Interp2_16
   52.12 -#define Interp3 Interp3_16
   52.13 -#define Interp4 Interp4_16
   52.14 -#define Interp5 Interp5_16
   52.15 -
   52.16 -void hq3x(unsigned char *pIn,  unsigned int srcPitch,
   52.17 -          unsigned char *,
   52.18 -          unsigned char *pOut, unsigned int dstPitch,
   52.19 -          int Xres, int Yres)
   52.20 -{
   52.21 -	int i, j;
   52.22 -	unsigned int line;
   52.23 -	PIXELTYPE	 c[10];
   52.24 -
   52.25 -	// +----+----+----+
   52.26 -	// |    |    |    |
   52.27 -	// | c1 | c2 | c3 |
   52.28 -	// +----+----+----+
   52.29 -	// |    |    |    |
   52.30 -	// | c4 | c5 | c6 |
   52.31 -	// +----+----+----+
   52.32 -	// |    |    |    |
   52.33 -	// | c7 | c8 | c9 |
   52.34 -	// +----+----+----+
   52.35 -
   52.36 -	for (j = 0; j < Yres; j++)
   52.37 -	{
   52.38 -		if ((j > 0) || (j < Yres - 1))
   52.39 -			line = srcPitch;
   52.40 -		else
   52.41 -			line = 0;
   52.42 -
   52.43 -		for (i = 0; i < Xres; i++)
   52.44 -		{
   52.45 -			c[2] = *((PIXELTYPE *)(pIn - line));
   52.46 -			c[5] = *((PIXELTYPE *)(pIn));
   52.47 -			c[8] = *((PIXELTYPE *)(pIn + line));
   52.48 -
   52.49 -			if (i > 0)
   52.50 -			{
   52.51 -				c[1] = *((PIXELTYPE *)(pIn - line - SIZE_PIXEL));
   52.52 -				c[4] = *((PIXELTYPE *)(pIn        - SIZE_PIXEL));
   52.53 -				c[7] = *((PIXELTYPE *)(pIn + line - SIZE_PIXEL));
   52.54 -			}
   52.55 -			else
   52.56 -			{
   52.57 -				c[1] = c[2];
   52.58 -				c[4] = c[5];
   52.59 -				c[7] = c[8];
   52.60 -			}
   52.61 -
   52.62 -			if (i < Xres - 1)
   52.63 -			{
   52.64 -				c[3] = *((PIXELTYPE *)(pIn - line + SIZE_PIXEL));
   52.65 -				c[6] = *((PIXELTYPE *)(pIn        + SIZE_PIXEL));
   52.66 -				c[9] = *((PIXELTYPE *)(pIn + line + SIZE_PIXEL));
   52.67 -			}
   52.68 -			else
   52.69 -			{
   52.70 -				c[3] = c[2];
   52.71 -				c[6] = c[5];
   52.72 -				c[9] = c[8];
   52.73 -			}
   52.74 -
   52.75 -			int pattern = 0;
   52.76 -
   52.77 -			if (interp_16_diff(c[1], c[5]))
   52.78 -				pattern |= 1 << 0;
   52.79 -			if (interp_16_diff(c[2], c[5]))
   52.80 -				pattern |= 1 << 1;
   52.81 -			if (interp_16_diff(c[3], c[5]))
   52.82 -				pattern |= 1 << 2;
   52.83 -			if (interp_16_diff(c[4], c[5]))
   52.84 -				pattern |= 1 << 3;
   52.85 -			if (interp_16_diff(c[6], c[5]))
   52.86 -				pattern |= 1 << 4;
   52.87 -			if (interp_16_diff(c[7], c[5]))
   52.88 -				pattern |= 1 << 5;
   52.89 -			if (interp_16_diff(c[8], c[5]))
   52.90 -				pattern |= 1 << 6;
   52.91 -			if (interp_16_diff(c[9], c[5]))
   52.92 -				pattern |= 1 << 7;
   52.93 -
   52.94 -#define Diff interp_16_diff
   52.95 -#include "hq3x32.h"
   52.96 -#undef Diff
   52.97 -			pIn	 += SIZE_PIXEL;
   52.98 -			pOut += 3 << 1;
   52.99 -		}
  52.100 -		pIn	 += srcPitch - (Xres << 1);
  52.101 -		pOut += dstPitch - (3 * Xres << 1);
  52.102 -		pOut += dstPitch << 1;
  52.103 -		//	pIn+=SIZE_PIXEL;
  52.104 -		//	pOut+=3*SIZE_PIXEL;
  52.105 -		//}
  52.106 -		//pIn+=srcPitch-(4*Xres);
  52.107 -		//pOut+=dstPitch-(3*Xres*SIZE_PIXEL);
  52.108 -		//pOut+=2*dstPitch;
  52.109 -	}
  52.110 -}
  52.111 -
  52.112 -void hq3xS(unsigned char *pIn,  unsigned int srcPitch,
  52.113 -           unsigned char *,
  52.114 -           unsigned char *pOut, unsigned int dstPitch,
  52.115 -           int Xres, int Yres)
  52.116 -{
  52.117 -	int i, j;
  52.118 -	PIXELTYPE c[10];
  52.119 -
  52.120 -	// +----+----+----+
  52.121 -	// |    |    |    |
  52.122 -	// | c1 | c2 | c3 |
  52.123 -	// +----+----+----+
  52.124 -	// |    |    |    |
  52.125 -	// | c4 | c5 | c6 |
  52.126 -	// +----+----+----+
  52.127 -	// |    |    |    |
  52.128 -	// | c7 | c8 | c9 |
  52.129 -	// +----+----+----+
  52.130 -
  52.131 -	for (j = 0; j < Yres; j++)
  52.132 -	{
  52.133 -		for (i = 0; i < Xres; i++)
  52.134 -		{
  52.135 -			c[2] = *((PIXELTYPE *)(pIn - srcPitch));
  52.136 -			c[5] = *((PIXELTYPE *)(pIn));
  52.137 -			c[8] = *((PIXELTYPE *)(pIn + srcPitch));
  52.138 -
  52.139 -			c[1] = *((PIXELTYPE *)(pIn - srcPitch - SIZE_PIXEL));
  52.140 -			c[4] = *((PIXELTYPE *)(pIn        - SIZE_PIXEL));
  52.141 -			c[7] = *((PIXELTYPE *)(pIn + srcPitch - SIZE_PIXEL));
  52.142 -
  52.143 -			c[3] = *((PIXELTYPE *)(pIn - srcPitch + SIZE_PIXEL));
  52.144 -			c[6] = *((PIXELTYPE *)(pIn        + SIZE_PIXEL));
  52.145 -			c[9] = *((PIXELTYPE *)(pIn + srcPitch + SIZE_PIXEL));
  52.146 -
  52.147 -			int pattern = 0;
  52.148 -
  52.149 -			// hq3xS dynamic edge detection:
  52.150 -			// simply comparing the center color against its surroundings will give bad results in many cases,
  52.151 -			// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
  52.152 -			int brightArray[10];
  52.153 -			int maxBright = 0, minBright = 999999;
  52.154 -			for (int j = 1; j < 10; j++)
  52.155 -			{
  52.156 -				int r, g, b;
  52.157 -				if (interp_bits_per_pixel == 16)
  52.158 -				{
  52.159 -					b = (int)((c[j] & 0x1F)) << 3;
  52.160 -					g = (int)((c[j] & 0x7E0)) >> 3;
  52.161 -					r = (int)((c[j] & 0xF800)) >> 8;
  52.162 -				}
  52.163 -				else
  52.164 -				{
  52.165 -					b = (int)((c[j] & 0x1F)) << 3;
  52.166 -					g = (int)((c[j] & 0x3E0)) >> 2;
  52.167 -					r = (int)((c[j] & 0x7C00)) >> 7;
  52.168 -				}
  52.169 -				const int bright = r + r + r + g + g + g + b + b;
  52.170 -				if (bright > maxBright) maxBright = bright;
  52.171 -				if (bright < minBright) minBright = bright;
  52.172 -
  52.173 -				brightArray[j] = bright;
  52.174 -			}
  52.175 -			const int diffBright = ((maxBright - minBright) * 7) >> 4;
  52.176 -			if (diffBright > 7)
  52.177 -			{
  52.178 -				#define ABS(x) ((x) < 0 ? -(x) : (x))
  52.179 -
  52.180 -				const int centerBright = brightArray[5];
  52.181 -				if (ABS(brightArray[1] - centerBright) > diffBright)
  52.182 -					pattern |= 1 << 0;
  52.183 -				if (ABS(brightArray[2] - centerBright) > diffBright)
  52.184 -					pattern |= 1 << 1;
  52.185 -				if (ABS(brightArray[3] - centerBright) > diffBright)
  52.186 -					pattern |= 1 << 2;
  52.187 -				if (ABS(brightArray[4] - centerBright) > diffBright)
  52.188 -					pattern |= 1 << 3;
  52.189 -				if (ABS(brightArray[6] - centerBright) > diffBright)
  52.190 -					pattern |= 1 << 4;
  52.191 -				if (ABS(brightArray[7] - centerBright) > diffBright)
  52.192 -					pattern |= 1 << 5;
  52.193 -				if (ABS(brightArray[8] - centerBright) > diffBright)
  52.194 -					pattern |= 1 << 6;
  52.195 -				if (ABS(brightArray[9] - centerBright) > diffBright)
  52.196 -					pattern |= 1 << 7;
  52.197 -			}
  52.198 -
  52.199 -#define Diff(x, y) false //(ABS((x) - (y)) > diffBright)
  52.200 -#undef cget
  52.201 -#define cget(x) brightArray[x]
  52.202 -#include "hq3x32.h"
  52.203 -#undef cget
  52.204 -#undef Diff
  52.205 -			pIn	 += SIZE_PIXEL;
  52.206 -			pOut += 3 << 1;
  52.207 -		}
  52.208 -		pIn	 += srcPitch - (Xres << 1);
  52.209 -		pOut += dstPitch - (3 * Xres << 1);
  52.210 -		pOut += dstPitch << 1;
  52.211 -		//	pIn+=SIZE_PIXEL;
  52.212 -		//	pOut+=3*SIZE_PIXEL;
  52.213 -		//}
  52.214 -		//pIn+=srcPitch-(4*Xres);
  52.215 -		//pOut+=dstPitch-(3*Xres*SIZE_PIXEL);
  52.216 -		//pOut+=2*dstPitch;
  52.217 -	}
  52.218 -}
  52.219 -
  52.220 -#undef Interp1
  52.221 -#undef Interp2
  52.222 -#undef Interp3
  52.223 -#undef Interp4
  52.224 -#undef Interp5
  52.225 -#undef SIZE_PIXEL
  52.226 -#undef PIXELTYPE
  52.227 -#define SIZE_PIXEL 4 // 32bit = 4 bytes
  52.228 -#define PIXELTYPE unsigned int
  52.229 -
  52.230 -void hq3x32(unsigned char *pIn,  unsigned int srcPitch,
  52.231 -            unsigned char *,
  52.232 -            unsigned char *pOut, unsigned int dstPitch,
  52.233 -            int Xres, int Yres)
  52.234 -{
  52.235 -	unsigned int YUV1, YUV2;
  52.236 -	int i, j, k;
  52.237 -	unsigned int line;
  52.238 -	PIXELTYPE c[10];
  52.239 -
  52.240 -	// +----+----+----+
  52.241 -	// |    |    |    |
  52.242 -	// | c1 | c2 | c3 |
  52.243 -	// +----+----+----+
  52.244 -	// |    |    |    |
  52.245 -	// | c4 | c5 | c6 |
  52.246 -	// +----+----+----+
  52.247 -	// |    |    |    |
  52.248 -	// | c7 | c8 | c9 |
  52.249 -	// +----+----+----+
  52.250 -
  52.251 -	for (j = 0; j < Yres; j++)
  52.252 -	{
  52.253 -		if ((j > 0) && (j < Yres - 1))
  52.254 -			line = srcPitch;
  52.255 -		else
  52.256 -			line = 0;
  52.257 -
  52.258 -		for (i = 0; i < Xres; i++)
  52.259 -		{
  52.260 -			c[2] = *((PIXELTYPE *)(pIn - line));
  52.261 -			c[5] = *((PIXELTYPE *)(pIn));
  52.262 -			c[8] = *((PIXELTYPE *)(pIn + line));
  52.263 -
  52.264 -			if (i > 0)
  52.265 -			{
  52.266 -				c[1] = *((PIXELTYPE *)(pIn - line - SIZE_PIXEL));
  52.267 -				c[4] = *((PIXELTYPE *)(pIn        - SIZE_PIXEL));
  52.268 -				c[7] = *((PIXELTYPE *)(pIn + line - SIZE_PIXEL));
  52.269 -			}
  52.270 -			else
  52.271 -			{
  52.272 -				c[1] = c[2];
  52.273 -				c[4] = c[5];
  52.274 -				c[7] = c[8];
  52.275 -			}
  52.276 -
  52.277 -			if (i < Xres - 1)
  52.278 -			{
  52.279 -				c[3] = *((PIXELTYPE *)(pIn - line + SIZE_PIXEL));
  52.280 -				c[6] = *((PIXELTYPE *)(pIn        + SIZE_PIXEL));
  52.281 -				c[9] = *((PIXELTYPE *)(pIn + line + SIZE_PIXEL));
  52.282 -			}
  52.283 -			else
  52.284 -			{
  52.285 -				c[3] = c[2];
  52.286 -				c[6] = c[5];
  52.287 -				c[9] = c[8];
  52.288 -			}
  52.289 -
  52.290 -			int pattern = 0;
  52.291 -			int flag	= 1;
  52.292 -
  52.293 -			YUV1 = RGBtoYUV(c[5]);
  52.294 -
  52.295 -			for (k = 1; k <= 9; k++)
  52.296 -			{
  52.297 -				if (k == 5) continue;
  52.298 -
  52.299 -				if (c[k] != c[5])
  52.300 -				{
  52.301 -					YUV2 = RGBtoYUV(c[k]);
  52.302 -					if (
  52.303 -					    (abs32((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
  52.304 -					    (abs32((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
  52.305 -					    (abs32((YUV1 & Vmask) - (YUV2 & Vmask)) > trV)
  52.306 -					    )
  52.307 -						pattern |= flag;
  52.308 -				}
  52.309 -				flag <<= 1;
  52.310 -			}
  52.311 -
  52.312 -#include "hq3x32.h"
  52.313 -			pIn	 += SIZE_PIXEL;
  52.314 -			pOut += 3 << 2;
  52.315 -		}
  52.316 -		pIn	 += srcPitch - (Xres << 2);
  52.317 -		pOut += dstPitch - (3 * Xres << 2);
  52.318 -		pOut += dstPitch << 1;
  52.319 -		//	pIn+=SIZE_PIXEL;
  52.320 -		//	pOut+=3*SIZE_PIXEL;
  52.321 -		//}
  52.322 -		//pIn+=srcPitch-(4*Xres);
  52.323 -		//pOut+=dstPitch-(3*Xres*SIZE_PIXEL);
  52.324 -		//pOut+=2*dstPitch;
  52.325 -	}
  52.326 -}
  52.327 -
  52.328 -void hq3xS32(unsigned char *pIn,  unsigned int srcPitch,
  52.329 -             unsigned char *,
  52.330 -             unsigned char *pOut, unsigned int dstPitch,
  52.331 -             int Xres, int Yres)
  52.332 -{
  52.333 -	int i, j;
  52.334 -	unsigned int line;
  52.335 -	PIXELTYPE c[10];
  52.336 -
  52.337 -	// +----+----+----+
  52.338 -	// |    |    |    |
  52.339 -	// | c1 | c2 | c3 |
  52.340 -	// +----+----+----+
  52.341 -	// |    |    |    |
  52.342 -	// | c4 | c5 | c6 |
  52.343 -	// +----+----+----+
  52.344 -	// |    |    |    |
  52.345 -	// | c7 | c8 | c9 |
  52.346 -	// +----+----+----+
  52.347 -
  52.348 -	for (j = 0; j < Yres; j++)
  52.349 -	{
  52.350 -		if ((j > 0) && (j < Yres - 1))
  52.351 -			line = srcPitch;
  52.352 -		else
  52.353 -			line = 0;
  52.354 -
  52.355 -		for (i = 0; i < Xres; i++)
  52.356 -		{
  52.357 -			c[2] = *((PIXELTYPE *)(pIn - line));
  52.358 -			c[5] = *((PIXELTYPE *)(pIn));
  52.359 -			c[8] = *((PIXELTYPE *)(pIn + line));
  52.360 -
  52.361 -			if (i > 0)
  52.362 -			{
  52.363 -				c[1] = *((PIXELTYPE *)(pIn - line - SIZE_PIXEL));
  52.364 -				c[4] = *((PIXELTYPE *)(pIn        - SIZE_PIXEL));
  52.365 -				c[7] = *((PIXELTYPE *)(pIn + line - SIZE_PIXEL));
  52.366 -			}
  52.367 -			else
  52.368 -			{
  52.369 -				c[1] = c[2];
  52.370 -				c[4] = c[5];
  52.371 -				c[7] = c[8];
  52.372 -			}
  52.373 -
  52.374 -			if (i < Xres - 1)
  52.375 -			{
  52.376 -				c[3] = *((PIXELTYPE *)(pIn - line + SIZE_PIXEL));
  52.377 -				c[6] = *((PIXELTYPE *)(pIn        + SIZE_PIXEL));
  52.378 -				c[9] = *((PIXELTYPE *)(pIn + line + SIZE_PIXEL));
  52.379 -			}
  52.380 -			else
  52.381 -			{
  52.382 -				c[3] = c[2];
  52.383 -				c[6] = c[5];
  52.384 -				c[9] = c[8];
  52.385 -			}
  52.386 -
  52.387 -			int pattern = 0;
  52.388 -
  52.389 -			// hq3xS dynamic edge detection:
  52.390 -			// simply comparing the center color against its surroundings will give bad results in many cases,
  52.391 -			// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
  52.392 -			int brightArray[10];
  52.393 -			int maxBright = 0, minBright = 999999;
  52.394 -			for (int j = 1; j < 10; j++)
  52.395 -			{
  52.396 -				const int b		 = (int)((c[j] & 0xF8));
  52.397 -				const int g		 = (int)((c[j] & 0xF800)) >> 8;
  52.398 -				const int r		 = (int)((c[j] & 0xF80000)) >> 16;
  52.399 -				const int bright = r + r + r + g + g + g + b + b;
  52.400 -				if (bright > maxBright) maxBright = bright;
  52.401 -				if (bright < minBright) minBright = bright;
  52.402 -
  52.403 -				brightArray[j] = bright;
  52.404 -			}
  52.405 -			int diffBright = ((maxBright - minBright) * 7) >> 4;
  52.406 -			if (diffBright > 7)
  52.407 -			{
  52.408 -				#define ABS(x) ((x) < 0 ? -(x) : (x))
  52.409 -
  52.410 -				const int centerBright = brightArray[5];
  52.411 -				if (ABS(brightArray[1] - centerBright) > diffBright)
  52.412 -					pattern |= 1 << 0;
  52.413 -				if (ABS(brightArray[2] - centerBright) > diffBright)
  52.414 -					pattern |= 1 << 1;
  52.415 -				if (ABS(brightArray[3] - centerBright) > diffBright)
  52.416 -					pattern |= 1 << 2;
  52.417 -				if (ABS(brightArray[4] - centerBright) > diffBright)
  52.418 -					pattern |= 1 << 3;
  52.419 -				if (ABS(brightArray[6] - centerBright) > diffBright)
  52.420 -					pattern |= 1 << 4;
  52.421 -				if (ABS(brightArray[7] - centerBright) > diffBright)
  52.422 -					pattern |= 1 << 5;
  52.423 -				if (ABS(brightArray[8] - centerBright) > diffBright)
  52.424 -					pattern |= 1 << 6;
  52.425 -				if (ABS(brightArray[9] - centerBright) > diffBright)
  52.426 -					pattern |= 1 << 7;
  52.427 -			}
  52.428 -
  52.429 -#define Diff(x, y) false //(ABS((x) - (y)) > diffBright)
  52.430 -#undef cget
  52.431 -#define cget(x) brightArray[x]
  52.432 -#include "hq3x32.h"
  52.433 -#undef cget
  52.434 -#undef Diff
  52.435 -			pIn	 += SIZE_PIXEL;
  52.436 -			pOut += 3 << 2;
  52.437 -		}
  52.438 -		pIn	 += srcPitch - (Xres << 2);
  52.439 -		pOut += dstPitch - (3 * Xres << 2);
  52.440 -		pOut += dstPitch << 1;
  52.441 -		//	pIn+=SIZE_PIXEL;
  52.442 -		//	pOut+=3*SIZE_PIXEL;
  52.443 -		//}
  52.444 -		//pIn+=srcPitch-(4*Xres);
  52.445 -		//pOut+=dstPitch-(3*Xres*SIZE_PIXEL);
  52.446 -		//pOut+=2*dstPitch;
  52.447 -	}
  52.448 -}
  52.449 \ No newline at end of file
    53.1 --- a/src/filters/hq3x32.h	Sat Mar 03 10:54:39 2012 -0600
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,3674 +0,0 @@
    53.4 -#define PIXEL00_1M  Interp1( pOut, c[5], c[1]       );
    53.5 -#define PIXEL00_1U  Interp1( pOut, c[5], c[2]       );
    53.6 -#define PIXEL00_1L  Interp1( pOut, c[5], c[4]       );
    53.7 -#define PIXEL00_2   Interp2( pOut, c[5], c[4], c[2] );
    53.8 -#define PIXEL00_4   Interp4( pOut, c[5], c[4], c[2] );
    53.9 -#define PIXEL00_5   Interp5( pOut, c[4], c[2]       );
   53.10 -#define PIXEL00_C   *((PIXELTYPE*)(pOut)) = c[5];
   53.11 -
   53.12 -#define PIXEL01_1   Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
   53.13 -#define PIXEL01_3   Interp3( pOut+SIZE_PIXEL, c[5], c[2] );
   53.14 -#define PIXEL01_6   Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
   53.15 -#define PIXEL01_C   *((PIXELTYPE*)(pOut+SIZE_PIXEL)) = c[5];
   53.16 -
   53.17 -#define PIXEL02_1M  Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]       );
   53.18 -#define PIXEL02_1U  Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]       );
   53.19 -#define PIXEL02_1R  Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]       );
   53.20 -#define PIXEL02_2   Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
   53.21 -#define PIXEL02_4   Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
   53.22 -#define PIXEL02_5   Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]       );
   53.23 -#define PIXEL02_C   *((PIXELTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
   53.24 -
   53.25 -#define PIXEL10_1   Interp1( pOut+dstPitch, c[5], c[4] );
   53.26 -#define PIXEL10_3   Interp3( pOut+dstPitch, c[5], c[4] );
   53.27 -#define PIXEL10_6   Interp1( pOut+dstPitch, c[4], c[5] );
   53.28 -#define PIXEL10_C   *((PIXELTYPE*)(pOut+dstPitch)) = c[5];
   53.29 -
   53.30 -#define PIXEL11     *((PIXELTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
   53.31 -
   53.32 -#define PIXEL12_1   Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
   53.33 -#define PIXEL12_3   Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
   53.34 -#define PIXEL12_6   Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] );
   53.35 -#define PIXEL12_C   *((PIXELTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
   53.36 -
   53.37 -#define PIXEL20_1M  Interp1( pOut+dstPitch+dstPitch, c[5], c[7]       );
   53.38 -#define PIXEL20_1D  Interp1( pOut+dstPitch+dstPitch, c[5], c[8]       );
   53.39 -#define PIXEL20_1L  Interp1( pOut+dstPitch+dstPitch, c[5], c[4]       );
   53.40 -#define PIXEL20_2   Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
   53.41 -#define PIXEL20_4   Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
   53.42 -#define PIXEL20_5   Interp5( pOut+dstPitch+dstPitch, c[8], c[4]       );
   53.43 -#define PIXEL20_C   *((PIXELTYPE*)(pOut+dstPitch+dstPitch)) = c[5];
   53.44 -
   53.45 -#define PIXEL21_1   Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
   53.46 -#define PIXEL21_3   Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
   53.47 -#define PIXEL21_6   Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
   53.48 -#define PIXEL21_C   *((PIXELTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
   53.49 -
   53.50 -#define PIXEL22_1M  Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]       );
   53.51 -#define PIXEL22_1D  Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]       );
   53.52 -#define PIXEL22_1R  Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]       );
   53.53 -#define PIXEL22_2   Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
   53.54 -#define PIXEL22_4   Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
   53.55 -#define PIXEL22_5   Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8]       );
   53.56 -#define PIXEL22_C   *((PIXELTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
   53.57 -
   53.58 -#ifndef cget
   53.59 -#define cget(x) c[x]
   53.60 -#endif
   53.61 -
   53.62 -      switch (pattern)
   53.63 -      {
   53.64 -        case 0:
   53.65 -        case 1:
   53.66 -        case 4:
   53.67 -        case 32:
   53.68 -        case 128:
   53.69 -        case 5:
   53.70 -        case 132:
   53.71 -        case 160:
   53.72 -        case 33:
   53.73 -        case 129:
   53.74 -        case 36:
   53.75 -        case 133:
   53.76 -        case 164:
   53.77 -        case 161:
   53.78 -        case 37:
   53.79 -        case 165:
   53.80 -        {
   53.81 -          PIXEL00_2
   53.82 -          PIXEL01_1
   53.83 -          PIXEL02_2
   53.84 -          PIXEL10_1
   53.85 -          PIXEL11
   53.86 -          PIXEL12_1
   53.87 -          PIXEL20_2
   53.88 -          PIXEL21_1
   53.89 -          PIXEL22_2
   53.90 -          break;
   53.91 -        }
   53.92 -        case 2:
   53.93 -        case 34:
   53.94 -        case 130:
   53.95 -        case 162:
   53.96 -        {
   53.97 -          PIXEL00_1M
   53.98 -          PIXEL01_C
   53.99 -          PIXEL02_1M
  53.100 -          PIXEL10_1
  53.101 -          PIXEL11
  53.102 -          PIXEL12_1
  53.103 -          PIXEL20_2
  53.104 -          PIXEL21_1
  53.105 -          PIXEL22_2
  53.106 -          break;
  53.107 -        }
  53.108 -        case 16:
  53.109 -        case 17:
  53.110 -        case 48:
  53.111 -        case 49:
  53.112 -        {
  53.113 -          PIXEL00_2
  53.114 -          PIXEL01_1
  53.115 -          PIXEL02_1M
  53.116 -          PIXEL10_1
  53.117 -          PIXEL11
  53.118 -          PIXEL12_C
  53.119 -          PIXEL20_2
  53.120 -          PIXEL21_1
  53.121 -          PIXEL22_1M
  53.122 -          break;
  53.123 -        }
  53.124 -        case 64:
  53.125 -        case 65:
  53.126 -        case 68:
  53.127 -        case 69:
  53.128 -        {
  53.129 -          PIXEL00_2
  53.130 -          PIXEL01_1
  53.131 -          PIXEL02_2
  53.132 -          PIXEL10_1
  53.133 -          PIXEL11
  53.134 -          PIXEL12_1
  53.135 -          PIXEL20_1M
  53.136 -          PIXEL21_C
  53.137 -          PIXEL22_1M
  53.138 -          break;
  53.139 -        }
  53.140 -        case 8:
  53.141 -        case 12:
  53.142 -        case 136:
  53.143 -        case 140:
  53.144 -        {
  53.145 -          PIXEL00_1M
  53.146 -          PIXEL01_1
  53.147 -          PIXEL02_2
  53.148 -          PIXEL10_C
  53.149 -          PIXEL11
  53.150 -          PIXEL12_1
  53.151 -          PIXEL20_1M
  53.152 -          PIXEL21_1
  53.153 -          PIXEL22_2
  53.154 -          break;
  53.155 -        }
  53.156 -        case 3:
  53.157 -        case 35:
  53.158 -        case 131:
  53.159 -        case 163:
  53.160 -        {
  53.161 -          PIXEL00_1L
  53.162 -          PIXEL01_C
  53.163 -          PIXEL02_1M
  53.164 -          PIXEL10_1
  53.165 -          PIXEL11
  53.166 -          PIXEL12_1
  53.167 -          PIXEL20_2
  53.168 -          PIXEL21_1
  53.169 -          PIXEL22_2
  53.170 -          break;
  53.171 -        }
  53.172 -        case 6:
  53.173 -        case 38:
  53.174 -        case 134:
  53.175 -        case 166:
  53.176 -        {
  53.177 -          PIXEL00_1M
  53.178 -          PIXEL01_C
  53.179 -          PIXEL02_1R
  53.180 -          PIXEL10_1
  53.181 -          PIXEL11
  53.182 -          PIXEL12_1
  53.183 -          PIXEL20_2
  53.184 -          PIXEL21_1
  53.185 -          PIXEL22_2
  53.186 -          break;
  53.187 -        }
  53.188 -        case 20:
  53.189 -        case 21:
  53.190 -        case 52:
  53.191 -        case 53:
  53.192 -        {
  53.193 -          PIXEL00_2
  53.194 -          PIXEL01_1
  53.195 -          PIXEL02_1U
  53.196 -          PIXEL10_1
  53.197 -          PIXEL11
  53.198 -          PIXEL12_C
  53.199 -          PIXEL20_2
  53.200 -          PIXEL21_1
  53.201 -          PIXEL22_1M
  53.202 -          break;
  53.203 -        }
  53.204 -        case 144:
  53.205 -        case 145:
  53.206 -        case 176:
  53.207 -        case 177:
  53.208 -        {
  53.209 -          PIXEL00_2
  53.210 -          PIXEL01_1
  53.211 -          PIXEL02_1M
  53.212 -          PIXEL10_1
  53.213 -          PIXEL11
  53.214 -          PIXEL12_C
  53.215 -          PIXEL20_2
  53.216 -          PIXEL21_1
  53.217 -          PIXEL22_1D
  53.218 -          break;
  53.219 -        }
  53.220 -        case 192:
  53.221 -        case 193:
  53.222 -        case 196:
  53.223 -        case 197:
  53.224 -        {
  53.225 -          PIXEL00_2
  53.226 -          PIXEL01_1
  53.227 -          PIXEL02_2
  53.228 -          PIXEL10_1
  53.229 -          PIXEL11
  53.230 -          PIXEL12_1
  53.231 -          PIXEL20_1M
  53.232 -          PIXEL21_C
  53.233 -          PIXEL22_1R
  53.234 -          break;
  53.235 -        }
  53.236 -        case 96:
  53.237 -        case 97:
  53.238 -        case 100:
  53.239 -        case 101:
  53.240 -        {
  53.241 -          PIXEL00_2
  53.242 -          PIXEL01_1
  53.243 -          PIXEL02_2
  53.244 -          PIXEL10_1
  53.245 -          PIXEL11
  53.246 -          PIXEL12_1
  53.247 -          PIXEL20_1L
  53.248 -          PIXEL21_C
  53.249 -          PIXEL22_1M
  53.250 -          break;
  53.251 -        }
  53.252 -        case 40:
  53.253 -        case 44:
  53.254 -        case 168:
  53.255 -        case 172:
  53.256 -        {
  53.257 -          PIXEL00_1M
  53.258 -          PIXEL01_1
  53.259 -          PIXEL02_2
  53.260 -          PIXEL10_C
  53.261 -          PIXEL11
  53.262 -          PIXEL12_1
  53.263 -          PIXEL20_1D
  53.264 -          PIXEL21_1
  53.265 -          PIXEL22_2
  53.266 -          break;
  53.267 -        }
  53.268 -        case 9:
  53.269 -        case 13:
  53.270 -        case 137:
  53.271 -        case 141:
  53.272 -        {
  53.273 -          PIXEL00_1U
  53.274 -          PIXEL01_1
  53.275 -          PIXEL02_2
  53.276 -          PIXEL10_C
  53.277 -          PIXEL11
  53.278 -          PIXEL12_1
  53.279 -          PIXEL20_1M
  53.280 -          PIXEL21_1
  53.281 -          PIXEL22_2
  53.282 -          break;
  53.283 -        }
  53.284 -        case 18:
  53.285 -        case 50:
  53.286 -        {
  53.287 -          PIXEL00_1M
  53.288 -			  
  53.289 -		if (Diff(cget(2), cget(6)))
  53.290 -          {
  53.291 -            PIXEL01_C
  53.292 -            PIXEL02_1M
  53.293 -            PIXEL12_C
  53.294 -          }
  53.295 -          else
  53.296 -          {
  53.297 -            PIXEL01_3
  53.298 -            PIXEL02_4
  53.299 -            PIXEL12_3
  53.300 -          }
  53.301 -          PIXEL10_1
  53.302 -          PIXEL11
  53.303 -          PIXEL20_2
  53.304 -          PIXEL21_1
  53.305 -          PIXEL22_1M
  53.306 -          break;
  53.307 -        }
  53.308 -        case 80:
  53.309 -        case 81:
  53.310 -        {
  53.311 -          PIXEL00_2
  53.312 -          PIXEL01_1
  53.313 -          PIXEL02_1M
  53.314 -          PIXEL10_1
  53.315 -          PIXEL11
  53.316 -          PIXEL20_1M
  53.317 -          if (Diff(cget(6), cget(8)))
  53.318 -          {
  53.319 -            PIXEL12_C
  53.320 -            PIXEL21_C
  53.321 -            PIXEL22_1M
  53.322 -          }
  53.323 -          else
  53.324 -          {
  53.325 -            PIXEL12_3
  53.326 -            PIXEL21_3
  53.327 -            PIXEL22_4
  53.328 -          }
  53.329 -          break;
  53.330 -        }
  53.331 -        case 72:
  53.332 -        case 76:
  53.333 -        {
  53.334 -          PIXEL00_1M
  53.335 -          PIXEL01_1
  53.336 -          PIXEL02_2
  53.337 -          PIXEL11
  53.338 -          PIXEL12_1
  53.339 -          if (Diff(cget(8), cget(4)))
  53.340 -          {
  53.341 -            PIXEL10_C
  53.342 -            PIXEL20_1M
  53.343 -            PIXEL21_C
  53.344 -          }
  53.345 -          else
  53.346 -          {
  53.347 -            PIXEL10_3
  53.348 -            PIXEL20_4
  53.349 -            PIXEL21_3
  53.350 -          }
  53.351 -          PIXEL22_1M
  53.352 -          break;
  53.353 -        }
  53.354 -        case 10:
  53.355 -        case 138:
  53.356 -        {
  53.357 -          if (Diff(cget(4), cget(2)))
  53.358 -          {
  53.359 -            PIXEL00_1M
  53.360 -            PIXEL01_C
  53.361 -            PIXEL10_C
  53.362 -          }
  53.363 -          else
  53.364 -          {
  53.365 -            PIXEL00_4
  53.366 -            PIXEL01_3
  53.367 -            PIXEL10_3
  53.368 -          }
  53.369 -          PIXEL02_1M
  53.370 -          PIXEL11
  53.371 -          PIXEL12_1
  53.372 -          PIXEL20_1M
  53.373 -          PIXEL21_1
  53.374 -          PIXEL22_2
  53.375 -          break;
  53.376 -        }
  53.377 -        case 66:
  53.378 -        {
  53.379 -          PIXEL00_1M
  53.380 -          PIXEL01_C
  53.381 -          PIXEL02_1M
  53.382 -          PIXEL10_1
  53.383 -          PIXEL11
  53.384 -          PIXEL12_1
  53.385 -          PIXEL20_1M
  53.386 -          PIXEL21_C
  53.387 -          PIXEL22_1M
  53.388 -          break;
  53.389 -        }
  53.390 -        case 24:
  53.391 -        {
  53.392 -          PIXEL00_1M
  53.393 -          PIXEL01_1
  53.394 -          PIXEL02_1M
  53.395 -          PIXEL10_C
  53.396 -          PIXEL11
  53.397 -          PIXEL12_C
  53.398 -          PIXEL20_1M
  53.399 -          PIXEL21_1
  53.400 -          PIXEL22_1M
  53.401 -          break;
  53.402 -        }
  53.403 -        case 7:
  53.404 -        case 39:
  53.405 -        case 135:
  53.406 -        {
  53.407 -          PIXEL00_1L
  53.408 -          PIXEL01_C
  53.409 -          PIXEL02_1R
  53.410 -          PIXEL10_1
  53.411 -          PIXEL11
  53.412 -          PIXEL12_1
  53.413 -          PIXEL20_2
  53.414 -          PIXEL21_1
  53.415 -          PIXEL22_2
  53.416 -          break;
  53.417 -        }
  53.418 -        case 148:
  53.419 -        case 149:
  53.420 -        case 180:
  53.421 -        {
  53.422 -          PIXEL00_2
  53.423 -          PIXEL01_1
  53.424 -          PIXEL02_1U
  53.425 -          PIXEL10_1
  53.426 -          PIXEL11
  53.427 -          PIXEL12_C
  53.428 -          PIXEL20_2
  53.429 -          PIXEL21_1
  53.430 -          PIXEL22_1D
  53.431 -          break;
  53.432 -        }
  53.433 -        case 224:
  53.434 -        case 228:
  53.435 -        case 225:
  53.436 -        {
  53.437 -          PIXEL00_2
  53.438 -          PIXEL01_1
  53.439 -          PIXEL02_2
  53.440 -          PIXEL10_1
  53.441 -          PIXEL11
  53.442 -          PIXEL12_1
  53.443 -          PIXEL20_1L
  53.444 -          PIXEL21_C
  53.445 -          PIXEL22_1R
  53.446 -          break;
  53.447 -        }
  53.448 -        case 41:
  53.449 -        case 169:
  53.450 -        case 45:
  53.451 -        {
  53.452 -          PIXEL00_1U
  53.453 -          PIXEL01_1
  53.454 -          PIXEL02_2
  53.455 -          PIXEL10_C
  53.456 -          PIXEL11
  53.457 -          PIXEL12_1
  53.458 -          PIXEL20_1D
  53.459 -          PIXEL21_1
  53.460 -          PIXEL22_2
  53.461 -          break;
  53.462 -        }
  53.463 -        case 22:
  53.464 -        case 54:
  53.465 -        {
  53.466 -          PIXEL00_1M
  53.467 -          if (Diff(cget(2), cget(6)))
  53.468 -          {
  53.469 -            PIXEL01_C
  53.470 -            PIXEL02_C
  53.471 -            PIXEL12_C
  53.472 -          }
  53.473 -          else
  53.474 -          {
  53.475 -            PIXEL01_3
  53.476 -            PIXEL02_4
  53.477 -            PIXEL12_3
  53.478 -          }
  53.479 -          PIXEL10_1
  53.480 -          PIXEL11
  53.481 -          PIXEL20_2
  53.482 -          PIXEL21_1
  53.483 -          PIXEL22_1M
  53.484 -          break;
  53.485 -        }
  53.486 -        case 208:
  53.487 -        case 209:
  53.488 -        {
  53.489 -          PIXEL00_2
  53.490 -          PIXEL01_1
  53.491 -          PIXEL02_1M
  53.492 -          PIXEL10_1
  53.493 -          PIXEL11
  53.494 -          PIXEL20_1M
  53.495 -          if (Diff(cget(6), cget(8)))
  53.496 -          {
  53.497 -            PIXEL12_C
  53.498 -            PIXEL21_C
  53.499 -            PIXEL22_C
  53.500 -          }
  53.501 -          else
  53.502 -          {
  53.503 -            PIXEL12_3
  53.504 -            PIXEL21_3
  53.505 -            PIXEL22_4
  53.506 -          }
  53.507 -          break;
  53.508 -        }
  53.509 -        case 104:
  53.510 -        case 108:
  53.511 -        {
  53.512 -          PIXEL00_1M
  53.513 -          PIXEL01_1
  53.514 -          PIXEL02_2
  53.515 -          PIXEL11
  53.516 -          PIXEL12_1
  53.517 -          if (Diff(cget(8), cget(4)))
  53.518 -          {
  53.519 -            PIXEL10_C
  53.520 -            PIXEL20_C
  53.521 -            PIXEL21_C
  53.522 -          }
  53.523 -          else
  53.524 -          {
  53.525 -            PIXEL10_3
  53.526 -            PIXEL20_4
  53.527 -            PIXEL21_3
  53.528 -          }
  53.529 -          PIXEL22_1M
  53.530 -          break;
  53.531 -        }
  53.532 -        case 11:
  53.533 -        case 139:
  53.534 -        {
  53.535 -          if (Diff(cget(4), cget(2)))
  53.536 -          {
  53.537 -            PIXEL00_C
  53.538 -            PIXEL01_C
  53.539 -            PIXEL10_C
  53.540 -          }
  53.541 -          else
  53.542 -          {
  53.543 -            PIXEL00_4
  53.544 -            PIXEL01_3
  53.545 -            PIXEL10_3
  53.546 -          }
  53.547 -          PIXEL02_1M
  53.548 -          PIXEL11
  53.549 -          PIXEL12_1
  53.550 -          PIXEL20_1M
  53.551 -          PIXEL21_1
  53.552 -          PIXEL22_2
  53.553 -          break;
  53.554 -        }
  53.555 -        case 19:
  53.556 -        case 51:
  53.557 -        {
  53.558 -          if (Diff(cget(2), cget(6)))
  53.559 -          {
  53.560 -            PIXEL00_1L
  53.561 -            PIXEL01_C
  53.562 -            PIXEL02_1M
  53.563 -            PIXEL12_C
  53.564 -          }
  53.565 -          else
  53.566 -          {
  53.567 -            PIXEL00_2
  53.568 -            PIXEL01_6
  53.569 -            PIXEL02_5
  53.570 -            PIXEL12_1
  53.571 -          }
  53.572 -          PIXEL10_1
  53.573 -          PIXEL11
  53.574 -          PIXEL20_2
  53.575 -          PIXEL21_1
  53.576 -          PIXEL22_1M
  53.577 -          break;
  53.578 -        }
  53.579 -        case 146:
  53.580 -        case 178:
  53.581 -        {
  53.582 -          if (Diff(cget(2), cget(6)))
  53.583 -          {
  53.584 -            PIXEL01_C
  53.585 -            PIXEL02_1M
  53.586 -            PIXEL12_C
  53.587 -            PIXEL22_1D
  53.588 -          }
  53.589 -          else
  53.590 -          {
  53.591 -            PIXEL01_1
  53.592 -            PIXEL02_5
  53.593 -            PIXEL12_6
  53.594 -            PIXEL22_2
  53.595 -          }
  53.596 -          PIXEL00_1M
  53.597 -          PIXEL10_1
  53.598 -          PIXEL11
  53.599 -          PIXEL20_2
  53.600 -          PIXEL21_1
  53.601 -          break;
  53.602 -        }
  53.603 -        case 84:
  53.604 -        case 85:
  53.605 -        {
  53.606 -          if (Diff(cget(6), cget(8)))
  53.607 -          {
  53.608 -            PIXEL02_1U
  53.609 -            PIXEL12_C
  53.610 -            PIXEL21_C
  53.611 -            PIXEL22_1M
  53.612 -          }
  53.613 -          else
  53.614 -          {
  53.615 -            PIXEL02_2
  53.616 -            PIXEL12_6
  53.617 -            PIXEL21_1
  53.618 -            PIXEL22_5
  53.619 -          }
  53.620 -          PIXEL00_2
  53.621 -          PIXEL01_1
  53.622 -          PIXEL10_1
  53.623 -          PIXEL11
  53.624 -          PIXEL20_1M
  53.625 -          break;
  53.626 -        }
  53.627 -        case 112:
  53.628 -        case 113:
  53.629 -        {
  53.630 -          if (Diff(cget(6), cget(8)))
  53.631 -          {
  53.632 -            PIXEL12_C
  53.633 -            PIXEL20_1L
  53.634 -            PIXEL21_C
  53.635 -            PIXEL22_1M
  53.636 -          }
  53.637 -          else
  53.638 -          {
  53.639 -            PIXEL12_1
  53.640 -            PIXEL20_2
  53.641 -            PIXEL21_6
  53.642 -            PIXEL22_5
  53.643 -          }
  53.644 -          PIXEL00_2
  53.645 -          PIXEL01_1
  53.646 -          PIXEL02_1M
  53.647 -          PIXEL10_1
  53.648 -          PIXEL11
  53.649 -          break;
  53.650 -        }
  53.651 -        case 200:
  53.652 -        case 204:
  53.653 -        {
  53.654 -          if (Diff(cget(8), cget(4)))
  53.655 -          {
  53.656 -            PIXEL10_C
  53.657 -            PIXEL20_1M
  53.658 -            PIXEL21_C
  53.659 -            PIXEL22_1R
  53.660 -          }
  53.661 -          else
  53.662 -          {
  53.663 -            PIXEL10_1
  53.664 -            PIXEL20_5
  53.665 -            PIXEL21_6
  53.666 -            PIXEL22_2
  53.667 -          }
  53.668 -          PIXEL00_1M
  53.669 -          PIXEL01_1
  53.670 -          PIXEL02_2
  53.671 -          PIXEL11
  53.672 -          PIXEL12_1
  53.673 -          break;
  53.674 -        }
  53.675 -        case 73:
  53.676 -        case 77:
  53.677 -        {
  53.678 -          if (Diff(cget(8), cget(4)))
  53.679 -          {
  53.680 -            PIXEL00_1U
  53.681 -            PIXEL10_C
  53.682 -            PIXEL20_1M
  53.683 -            PIXEL21_C
  53.684 -          }
  53.685 -          else
  53.686 -          {
  53.687 -            PIXEL00_2
  53.688 -            PIXEL10_6
  53.689 -            PIXEL20_5
  53.690 -            PIXEL21_1
  53.691 -          }
  53.692 -          PIXEL01_1
  53.693 -          PIXEL02_2
  53.694 -          PIXEL11
  53.695 -          PIXEL12_1
  53.696 -          PIXEL22_1M
  53.697 -          break;
  53.698 -        }
  53.699 -        case 42:
  53.700 -        case 170:
  53.701 -        {
  53.702 -          if (Diff(cget(4), cget(2)))
  53.703 -          {
  53.704 -            PIXEL00_1M
  53.705 -            PIXEL01_C
  53.706 -            PIXEL10_C
  53.707 -            PIXEL20_1D
  53.708 -          }
  53.709 -          else
  53.710 -          {
  53.711 -            PIXEL00_5
  53.712 -            PIXEL01_1
  53.713 -            PIXEL10_6
  53.714 -            PIXEL20_2
  53.715 -          }
  53.716 -          PIXEL02_1M
  53.717 -          PIXEL11
  53.718 -          PIXEL12_1
  53.719 -          PIXEL21_1
  53.720 -          PIXEL22_2
  53.721 -          break;
  53.722 -        }
  53.723 -        case 14:
  53.724 -        case 142:
  53.725 -        {
  53.726 -          if (Diff(cget(4), cget(2)))
  53.727 -          {
  53.728 -            PIXEL00_1M
  53.729 -            PIXEL01_C
  53.730 -            PIXEL02_1R
  53.731 -            PIXEL10_C
  53.732 -          }
  53.733 -          else
  53.734 -          {
  53.735 -            PIXEL00_5
  53.736 -            PIXEL01_6
  53.737 -            PIXEL02_2
  53.738 -            PIXEL10_1
  53.739 -          }
  53.740 -          PIXEL11
  53.741 -          PIXEL12_1
  53.742 -          PIXEL20_1M
  53.743 -          PIXEL21_1
  53.744 -          PIXEL22_2
  53.745 -          break;
  53.746 -        }
  53.747 -        case 67:
  53.748 -        {
  53.749 -          PIXEL00_1L
  53.750 -          PIXEL01_C
  53.751 -          PIXEL02_1M
  53.752 -          PIXEL10_1
  53.753 -          PIXEL11
  53.754 -          PIXEL12_1
  53.755 -          PIXEL20_1M
  53.756 -          PIXEL21_C
  53.757 -          PIXEL22_1M
  53.758 -          break;
  53.759 -        }
  53.760 -        case 70:
  53.761 -        {
  53.762 -          PIXEL00_1M
  53.763 -          PIXEL01_C
  53.764 -          PIXEL02_1R
  53.765 -          PIXEL10_1
  53.766 -          PIXEL11
  53.767 -          PIXEL12_1
  53.768 -          PIXEL20_1M
  53.769 -          PIXEL21_C
  53.770 -          PIXEL22_1M
  53.771 -          break;
  53.772 -        }
  53.773 -        case 28:
  53.774 -        {
  53.775 -          PIXEL00_1M
  53.776 -          PIXEL01_1
  53.777 -          PIXEL02_1U
  53.778 -          PIXEL10_C
  53.779 -          PIXEL11
  53.780 -          PIXEL12_C
  53.781 -          PIXEL20_1M
  53.782 -          PIXEL21_1
  53.783 -          PIXEL22_1M
  53.784 -          break;
  53.785 -        }
  53.786 -        case 152:
  53.787 -        {
  53.788 -          PIXEL00_1M
  53.789 -          PIXEL01_1
  53.790 -          PIXEL02_1M
  53.791 -          PIXEL10_C
  53.792 -          PIXEL11
  53.793 -          PIXEL12_C
  53.794 -          PIXEL20_1M
  53.795 -          PIXEL21_1
  53.796 -          PIXEL22_1D
  53.797 -          break;
  53.798 -        }
  53.799 -        case 194:
  53.800 -        {
  53.801 -          PIXEL00_1M
  53.802 -          PIXEL01_C
  53.803 -          PIXEL02_1M
  53.804 -          PIXEL10_1
  53.805 -          PIXEL11
  53.806 -          PIXEL12_1
  53.807 -          PIXEL20_1M
  53.808 -          PIXEL21_C
  53.809 -          PIXEL22_1R
  53.810 -          break;
  53.811 -        }
  53.812 -        case 98:
  53.813 -        {
  53.814 -          PIXEL00_1M
  53.815 -          PIXEL01_C
  53.816 -          PIXEL02_1M
  53.817 -          PIXEL10_1
  53.818 -          PIXEL11
  53.819 -          PIXEL12_1
  53.820 -          PIXEL20_1L
  53.821 -          PIXEL21_C
  53.822 -          PIXEL22_1M
  53.823 -          break;
  53.824 -        }
  53.825 -        case 56:
  53.826 -        {
  53.827 -          PIXEL00_1M
  53.828 -          PIXEL01_1
  53.829 -          PIXEL02_1M
  53.830 -          PIXEL10_C
  53.831 -          PIXEL11
  53.832 -          PIXEL12_C
  53.833 -          PIXEL20_1D
  53.834 -          PIXEL21_1
  53.835 -          PIXEL22_1M
  53.836 -          break;
  53.837 -        }
  53.838 -        case 25:
  53.839 -        {
  53.840 -          PIXEL00_1U
  53.841 -          PIXEL01_1
  53.842 -          PIXEL02_1M
  53.843 -          PIXEL10_C
  53.844 -          PIXEL11
  53.845 -          PIXEL12_C
  53.846 -          PIXEL20_1M
  53.847 -          PIXEL21_1
  53.848 -          PIXEL22_1M
  53.849 -          break;
  53.850 -        }
  53.851 -        case 26:
  53.852 -        case 31:
  53.853 -        {
  53.854 -          if (Diff(cget(4), cget(2)))
  53.855 -          {
  53.856 -            PIXEL00_C
  53.857 -            PIXEL10_C
  53.858 -          }
  53.859 -          else
  53.860 -          {
  53.861 -            PIXEL00_4
  53.862 -            PIXEL10_3
  53.863 -          }
  53.864 -          PIXEL01_C
  53.865 -          if (Diff(cget(2), cget(6)))
  53.866 -          {
  53.867 -            PIXEL02_C
  53.868 -            PIXEL12_C
  53.869 -          }
  53.870 -          else
  53.871 -          {
  53.872 -            PIXEL02_4
  53.873 -            PIXEL12_3
  53.874 -          }
  53.875 -          PIXEL11
  53.876 -          PIXEL20_1M
  53.877 -          PIXEL21_1
  53.878 -          PIXEL22_1M
  53.879 -          break;
  53.880 -        }
  53.881 -        case 82:
  53.882 -        case 214:
  53.883 -        {
  53.884 -          PIXEL00_1M
  53.885 -          if (Diff(cget(2), cget(6)))
  53.886 -          {
  53.887 -            PIXEL01_C
  53.888 -            PIXEL02_C
  53.889 -          }
  53.890 -          else
  53.891 -          {
  53.892 -            PIXEL01_3
  53.893 -            PIXEL02_4
  53.894 -          }
  53.895 -          PIXEL10_1
  53.896 -          PIXEL11
  53.897 -          PIXEL12_C
  53.898 -          PIXEL20_1M
  53.899 -          if (Diff(cget(6), cget(8)))
  53.900 -          {
  53.901 -            PIXEL21_C
  53.902 -            PIXEL22_C
  53.903 -          }
  53.904 -          else
  53.905 -          {
  53.906 -            PIXEL21_3
  53.907 -            PIXEL22_4
  53.908 -          }
  53.909 -          break;
  53.910 -        }
  53.911 -        case 88:
  53.912 -        case 248:
  53.913 -        {
  53.914 -          PIXEL00_1M
  53.915 -          PIXEL01_1
  53.916 -          PIXEL02_1M
  53.917 -          PIXEL11
  53.918 -          if (Diff(cget(8), cget(4)))
  53.919 -          {
  53.920 -            PIXEL10_C
  53.921 -            PIXEL20_C
  53.922 -          }
  53.923 -          else
  53.924 -          {
  53.925 -            PIXEL10_3
  53.926 -            PIXEL20_4
  53.927 -          }
  53.928 -          PIXEL21_C
  53.929 -          if (Diff(cget(6), cget(8)))
  53.930 -          {
  53.931 -            PIXEL12_C
  53.932 -            PIXEL22_C
  53.933 -          }
  53.934 -          else
  53.935 -          {
  53.936 -            PIXEL12_3
  53.937 -            PIXEL22_4
  53.938 -          }
  53.939 -          break;
  53.940 -        }
  53.941 -        case 74:
  53.942 -        case 107:
  53.943 -        {
  53.944 -          if (Diff(cget(4), cget(2)))
  53.945 -          {
  53.946 -            PIXEL00_C
  53.947 -            PIXEL01_C
  53.948 -          }
  53.949 -          else
  53.950 -          {
  53.951 -            PIXEL00_4
  53.952 -            PIXEL01_3
  53.953 -          }
  53.954 -          PIXEL02_1M
  53.955 -          PIXEL10_C
  53.956 -          PIXEL11
  53.957 -          PIXEL12_1
  53.958 -          if (Diff(cget(8), cget(4)))
  53.959 -          {
  53.960 -            PIXEL20_C
  53.961 -            PIXEL21_C
  53.962 -          }
  53.963 -          else
  53.964 -          {
  53.965 -            PIXEL20_4
  53.966 -            PIXEL21_3
  53.967 -          }
  53.968 -          PIXEL22_1M
  53.969 -          break;
  53.970 -        }
  53.971 -        case 27:
  53.972 -        {
  53.973 -          if (Diff(cget(4), cget(2)))
  53.974 -          {
  53.975 -            PIXEL00_C
  53.976 -            PIXEL01_C
  53.977 -            PIXEL10_C
  53.978 -          }
  53.979 -          else
  53.980 -          {
  53.981 -            PIXEL00_4
  53.982 -            PIXEL01_3
  53.983 -            PIXEL10_3
  53.984 -          }
  53.985 -          PIXEL02_1M
  53.986 -          PIXEL11
  53.987 -          PIXEL12_C
  53.988 -          PIXEL20_1M
  53.989 -          PIXEL21_1
  53.990 -          PIXEL22_1M
  53.991 -          break;
  53.992 -        }
  53.993 -        case 86:
  53.994 -        {
  53.995 -          PIXEL00_1M
  53.996 -          if (Diff(cget(2), cget(6)))
  53.997 -          {
  53.998 -            PIXEL01_C
  53.999 -            PIXEL02_C
 53.1000 -            PIXEL12_C
 53.1001 -          }
 53.1002 -          else
 53.1003 -          {
 53.1004 -            PIXEL01_3
 53.1005 -            PIXEL02_4
 53.1006 -            PIXEL12_3
 53.1007 -          }
 53.1008 -          PIXEL10_1
 53.1009 -          PIXEL11
 53.1010 -          PIXEL20_1M
 53.1011 -          PIXEL21_C
 53.1012 -          PIXEL22_1M
 53.1013 -          break;
 53.1014 -        }
 53.1015 -        case 216:
 53.1016 -        {
 53.1017 -          PIXEL00_1M
 53.1018 -          PIXEL01_1
 53.1019 -          PIXEL02_1M
 53.1020 -          PIXEL10_C
 53.1021 -          PIXEL11
 53.1022 -          PIXEL20_1M
 53.1023 -          if (Diff(cget(6), cget(8)))
 53.1024 -          {
 53.1025 -            PIXEL12_C
 53.1026 -            PIXEL21_C
 53.1027 -            PIXEL22_C
 53.1028 -          }
 53.1029 -          else
 53.1030 -          {
 53.1031 -            PIXEL12_3
 53.1032 -            PIXEL21_3
 53.1033 -            PIXEL22_4
 53.1034 -          }
 53.1035 -          break;
 53.1036 -        }
 53.1037 -        case 106:
 53.1038 -        {
 53.1039 -          PIXEL00_1M
 53.1040 -          PIXEL01_C
 53.1041 -          PIXEL02_1M
 53.1042 -          PIXEL11
 53.1043 -          PIXEL12_1
 53.1044 -          if (Diff(cget(8), cget(4)))
 53.1045 -          {
 53.1046 -            PIXEL10_C
 53.1047 -            PIXEL20_C
 53.1048 -            PIXEL21_C
 53.1049 -          }
 53.1050 -          else
 53.1051 -          {
 53.1052 -            PIXEL10_3
 53.1053 -            PIXEL20_4
 53.1054 -            PIXEL21_3
 53.1055 -          }
 53.1056 -          PIXEL22_1M
 53.1057 -          break;
 53.1058 -        }
 53.1059 -        case 30:
 53.1060 -        {
 53.1061 -          PIXEL00_1M
 53.1062 -          if (Diff(cget(2), cget(6)))
 53.1063 -          {
 53.1064 -            PIXEL01_C
 53.1065 -            PIXEL02_C
 53.1066 -            PIXEL12_C
 53.1067 -          }
 53.1068 -          else
 53.1069 -          {
 53.1070 -            PIXEL01_3
 53.1071 -            PIXEL02_4
 53.1072 -            PIXEL12_3
 53.1073 -          }
 53.1074 -          PIXEL10_C
 53.1075 -          PIXEL11
 53.1076 -          PIXEL20_1M
 53.1077 -          PIXEL21_1
 53.1078 -          PIXEL22_1M
 53.1079 -          break;
 53.1080 -        }
 53.1081 -        case 210:
 53.1082 -        {
 53.1083 -          PIXEL00_1M
 53.1084 -          PIXEL01_C
 53.1085 -          PIXEL02_1M
 53.1086 -          PIXEL10_1
 53.1087 -          PIXEL11
 53.1088 -          PIXEL20_1M
 53.1089 -          if (Diff(cget(6), cget(8)))
 53.1090 -          {
 53.1091 -            PIXEL12_C
 53.1092 -            PIXEL21_C
 53.1093 -            PIXEL22_C
 53.1094 -          }
 53.1095 -          else
 53.1096 -          {
 53.1097 -            PIXEL12_3
 53.1098 -            PIXEL21_3
 53.1099 -            PIXEL22_4
 53.1100 -          }
 53.1101 -          break;
 53.1102 -        }
 53.1103 -        case 120:
 53.1104 -        {
 53.1105 -          PIXEL00_1M
 53.1106 -          PIXEL01_1
 53.1107 -          PIXEL02_1M
 53.1108 -          PIXEL11
 53.1109 -          PIXEL12_C
 53.1110 -          if (Diff(cget(8), cget(4)))
 53.1111 -          {
 53.1112 -            PIXEL10_C
 53.1113 -            PIXEL20_C
 53.1114 -            PIXEL21_C
 53.1115 -          }
 53.1116 -          else
 53.1117 -          {
 53.1118 -            PIXEL10_3
 53.1119 -            PIXEL20_4
 53.1120 -            PIXEL21_3
 53.1121 -          }
 53.1122 -          PIXEL22_1M
 53.1123 -          break;
 53.1124 -        }
 53.1125 -        case 75:
 53.1126 -        {
 53.1127 -          if (Diff(cget(4), cget(2)))
 53.1128 -          {
 53.1129 -            PIXEL00_C
 53.1130 -            PIXEL01_C
 53.1131 -            PIXEL10_C
 53.1132 -          }
 53.1133 -          else
 53.1134 -          {
 53.1135 -            PIXEL00_4
 53.1136 -            PIXEL01_3
 53.1137 -            PIXEL10_3
 53.1138 -          }
 53.1139 -          PIXEL02_1M
 53.1140 -          PIXEL11
 53.1141 -          PIXEL12_1
 53.1142 -          PIXEL20_1M
 53.1143 -          PIXEL21_C
 53.1144 -          PIXEL22_1M
 53.1145 -          break;
 53.1146 -        }
 53.1147 -        case 29:
 53.1148 -        {
 53.1149 -          PIXEL00_1U
 53.1150 -          PIXEL01_1
 53.1151 -          PIXEL02_1U
 53.1152 -          PIXEL10_C
 53.1153 -          PIXEL11
 53.1154 -          PIXEL12_C
 53.1155 -          PIXEL20_1M
 53.1156 -          PIXEL21_1
 53.1157 -          PIXEL22_1M
 53.1158 -          break;
 53.1159 -        }
 53.1160 -        case 198:
 53.1161 -        {
 53.1162 -          PIXEL00_1M
 53.1163 -          PIXEL01_C
 53.1164 -          PIXEL02_1R
 53.1165 -          PIXEL10_1
 53.1166 -          PIXEL11
 53.1167 -          PIXEL12_1
 53.1168 -          PIXEL20_1M
 53.1169 -          PIXEL21_C
 53.1170 -          PIXEL22_1R
 53.1171 -          break;
 53.1172 -        }
 53.1173 -        case 184:
 53.1174 -        {
 53.1175 -          PIXEL00_1M
 53.1176 -          PIXEL01_1
 53.1177 -          PIXEL02_1M
 53.1178 -          PIXEL10_C
 53.1179 -          PIXEL11
 53.1180 -          PIXEL12_C
 53.1181 -          PIXEL20_1D
 53.1182 -          PIXEL21_1
 53.1183 -          PIXEL22_1D
 53.1184 -          break;
 53.1185 -        }
 53.1186 -        case 99:
 53.1187 -        {
 53.1188 -          PIXEL00_1L
 53.1189 -          PIXEL01_C
 53.1190 -          PIXEL02_1M
 53.1191 -          PIXEL10_1
 53.1192 -          PIXEL11
 53.1193 -          PIXEL12_1
 53.1194 -          PIXEL20_1L
 53.1195 -          PIXEL21_C
 53.1196 -          PIXEL22_1M
 53.1197 -          break;
 53.1198 -        }
 53.1199 -        case 57:
 53.1200 -        {
 53.1201 -          PIXEL00_1U
 53.1202 -          PIXEL01_1
 53.1203 -          PIXEL02_1M
 53.1204 -          PIXEL10_C
 53.1205 -          PIXEL11
 53.1206 -          PIXEL12_C
 53.1207 -          PIXEL20_1D
 53.1208 -          PIXEL21_1
 53.1209 -          PIXEL22_1M
 53.1210 -          break;
 53.1211 -        }
 53.1212 -        case 71:
 53.1213 -        {
 53.1214 -          PIXEL00_1L
 53.1215 -          PIXEL01_C
 53.1216 -          PIXEL02_1R
 53.1217 -          PIXEL10_1
 53.1218 -          PIXEL11
 53.1219 -          PIXEL12_1
 53.1220 -          PIXEL20_1M
 53.1221 -          PIXEL21_C
 53.1222 -          PIXEL22_1M
 53.1223 -          break;
 53.1224 -        }
 53.1225 -        case 156:
 53.1226 -        {
 53.1227 -          PIXEL00_1M
 53.1228 -          PIXEL01_1
 53.1229 -          PIXEL02_1U
 53.1230 -          PIXEL10_C
 53.1231 -          PIXEL11
 53.1232 -          PIXEL12_C
 53.1233 -          PIXEL20_1M
 53.1234 -          PIXEL21_1
 53.1235 -          PIXEL22_1D
 53.1236 -          break;
 53.1237 -        }
 53.1238 -        case 226:
 53.1239 -        {
 53.1240 -          PIXEL00_1M
 53.1241 -          PIXEL01_C
 53.1242 -          PIXEL02_1M
 53.1243 -          PIXEL10_1
 53.1244 -          PIXEL11
 53.1245 -          PIXEL12_1
 53.1246 -          PIXEL20_1L
 53.1247 -          PIXEL21_C
 53.1248 -          PIXEL22_1R
 53.1249 -          break;
 53.1250 -        }
 53.1251 -        case 60:
 53.1252 -        {
 53.1253 -          PIXEL00_1M
 53.1254 -          PIXEL01_1
 53.1255 -          PIXEL02_1U
 53.1256 -          PIXEL10_C
 53.1257 -          PIXEL11
 53.1258 -          PIXEL12_C
 53.1259 -          PIXEL20_1D
 53.1260 -          PIXEL21_1
 53.1261 -          PIXEL22_1M
 53.1262 -          break;
 53.1263 -        }
 53.1264 -        case 195:
 53.1265 -        {
 53.1266 -          PIXEL00_1L
 53.1267 -          PIXEL01_C
 53.1268 -          PIXEL02_1M
 53.1269 -          PIXEL10_1
 53.1270 -          PIXEL11
 53.1271 -          PIXEL12_1
 53.1272 -          PIXEL20_1M
 53.1273 -          PIXEL21_C
 53.1274 -          PIXEL22_1R
 53.1275 -          break;
 53.1276 -        }
 53.1277 -        case 102:
 53.1278 -        {
 53.1279 -          PIXEL00_1M
 53.1280 -          PIXEL01_C
 53.1281 -          PIXEL02_1R
 53.1282 -          PIXEL10_1
 53.1283 -          PIXEL11
 53.1284 -          PIXEL12_1
 53.1285 -          PIXEL20_1L
 53.1286 -          PIXEL21_C
 53.1287 -          PIXEL22_1M
 53.1288 -          break;
 53.1289 -        }
 53.1290 -        case 153:
 53.1291 -        {
 53.1292 -          PIXEL00_1U
 53.1293 -          PIXEL01_1
 53.1294 -          PIXEL02_1M
 53.1295 -          PIXEL10_C
 53.1296 -          PIXEL11
 53.1297 -          PIXEL12_C
 53.1298 -          PIXEL20_1M
 53.1299 -          PIXEL21_1
 53.1300 -          PIXEL22_1D
 53.1301 -          break;
 53.1302 -        }
 53.1303 -        case 58:
 53.1304 -        {
 53.1305 -          if (Diff(cget(4), cget(2)))
 53.1306 -          {
 53.1307 -            PIXEL00_1M
 53.1308 -          }
 53.1309 -          else
 53.1310 -          {
 53.1311 -            PIXEL00_2
 53.1312 -          }
 53.1313 -          PIXEL01_C
 53.1314 -          if (Diff(cget(2), cget(6)))
 53.1315 -          {
 53.1316 -            PIXEL02_1M
 53.1317 -          }
 53.1318 -          else
 53.1319 -          {
 53.1320 -            PIXEL02_2
 53.1321 -          }
 53.1322 -          PIXEL10_C
 53.1323 -          PIXEL11
 53.1324 -          PIXEL12_C
 53.1325 -          PIXEL20_1D
 53.1326 -          PIXEL21_1
 53.1327 -          PIXEL22_1M
 53.1328 -          break;
 53.1329 -        }
 53.1330 -        case 83:
 53.1331 -        {
 53.1332 -          PIXEL00_1L
 53.1333 -          PIXEL01_C
 53.1334 -          if (Diff(cget(2), cget(6)))
 53.1335 -          {
 53.1336 -            PIXEL02_1M
 53.1337 -          }
 53.1338 -          else
 53.1339 -          {
 53.1340 -            PIXEL02_2
 53.1341 -          }
 53.1342 -          PIXEL10_1
 53.1343 -          PIXEL11
 53.1344 -          PIXEL12_C
 53.1345 -          PIXEL20_1M
 53.1346 -          PIXEL21_C
 53.1347 -          if (Diff(cget(6), cget(8)))
 53.1348 -          {
 53.1349 -            PIXEL22_1M
 53.1350 -          }
 53.1351 -          else
 53.1352 -          {
 53.1353 -            PIXEL22_2
 53.1354 -          }
 53.1355 -          break;
 53.1356 -        }
 53.1357 -        case 92:
 53.1358 -        {
 53.1359 -          PIXEL00_1M
 53.1360 -          PIXEL01_1
 53.1361 -          PIXEL02_1U
 53.1362 -          PIXEL10_C
 53.1363 -          PIXEL11
 53.1364 -          PIXEL12_C
 53.1365 -          if (Diff(cget(8), cget(4)))
 53.1366 -          {
 53.1367 -            PIXEL20_1M
 53.1368 -          }
 53.1369 -          else
 53.1370 -          {
 53.1371 -            PIXEL20_2
 53.1372 -          }
 53.1373 -          PIXEL21_C
 53.1374 -          if (Diff(cget(6), cget(8)))
 53.1375 -          {
 53.1376 -            PIXEL22_1M
 53.1377 -          }
 53.1378 -          else
 53.1379 -          {
 53.1380 -            PIXEL22_2
 53.1381 -          }
 53.1382 -          break;
 53.1383 -        }
 53.1384 -        case 202:
 53.1385 -        {
 53.1386 -          if (Diff(cget(4), cget(2)))
 53.1387 -          {
 53.1388 -            PIXEL00_1M
 53.1389 -          }
 53.1390 -          else
 53.1391 -          {
 53.1392 -            PIXEL00_2
 53.1393 -          }
 53.1394 -          PIXEL01_C
 53.1395 -          PIXEL02_1M
 53.1396 -          PIXEL10_C
 53.1397 -          PIXEL11
 53.1398 -          PIXEL12_1
 53.1399 -          if (Diff(cget(8), cget(4)))
 53.1400 -          {
 53.1401 -            PIXEL20_1M
 53.1402 -          }
 53.1403 -          else
 53.1404 -          {
 53.1405 -            PIXEL20_2
 53.1406 -          }
 53.1407 -          PIXEL21_C
 53.1408 -          PIXEL22_1R
 53.1409 -          break;
 53.1410 -        }
 53.1411 -        case 78:
 53.1412 -        {
 53.1413 -          if (Diff(cget(4), cget(2)))
 53.1414 -          {
 53.1415 -            PIXEL00_1M
 53.1416 -          }
 53.1417 -          else
 53.1418 -          {
 53.1419 -            PIXEL00_2
 53.1420 -          }
 53.1421 -          PIXEL01_C
 53.1422 -          PIXEL02_1R
 53.1423 -          PIXEL10_C
 53.1424 -          PIXEL11
 53.1425 -          PIXEL12_1
 53.1426 -          if (Diff(cget(8), cget(4)))
 53.1427 -          {
 53.1428 -            PIXEL20_1M
 53.1429 -          }
 53.1430 -          else
 53.1431 -          {
 53.1432 -            PIXEL20_2
 53.1433 -          }
 53.1434 -          PIXEL21_C
 53.1435 -          PIXEL22_1M
 53.1436 -          break;
 53.1437 -        }
 53.1438 -        case 154:
 53.1439 -        {
 53.1440 -          if (Diff(cget(4), cget(2)))
 53.1441 -          {
 53.1442 -            PIXEL00_1M
 53.1443 -          }
 53.1444 -          else
 53.1445 -          {
 53.1446 -            PIXEL00_2
 53.1447 -          }
 53.1448 -          PIXEL01_C
 53.1449 -          if (Diff(cget(2), cget(6)))
 53.1450 -          {
 53.1451 -            PIXEL02_1M
 53.1452 -          }
 53.1453 -          else
 53.1454 -          {
 53.1455 -            PIXEL02_2
 53.1456 -          }
 53.1457 -          PIXEL10_C
 53.1458 -          PIXEL11
 53.1459 -          PIXEL12_C
 53.1460 -          PIXEL20_1M
 53.1461 -          PIXEL21_1
 53.1462 -          PIXEL22_1D
 53.1463 -          break;
 53.1464 -        }
 53.1465 -        case 114:
 53.1466 -        {
 53.1467 -          PIXEL00_1M
 53.1468 -          PIXEL01_C
 53.1469 -          if (Diff(cget(2), cget(6)))
 53.1470 -          {
 53.1471 -            PIXEL02_1M
 53.1472 -          }
 53.1473 -          else
 53.1474 -          {
 53.1475 -            PIXEL02_2
 53.1476 -          }
 53.1477 -          PIXEL10_1
 53.1478 -          PIXEL11
 53.1479 -          PIXEL12_C
 53.1480 -          PIXEL20_1L
 53.1481 -          PIXEL21_C
 53.1482 -          if (Diff(cget(6), cget(8)))
 53.1483 -          {
 53.1484 -            PIXEL22_1M
 53.1485 -          }
 53.1486 -          else
 53.1487 -          {
 53.1488 -            PIXEL22_2
 53.1489 -          }
 53.1490 -          break;
 53.1491 -        }
 53.1492 -        case 89:
 53.1493 -        {
 53.1494 -          PIXEL00_1U
 53.1495 -          PIXEL01_1
 53.1496 -          PIXEL02_1M
 53.1497 -          PIXEL10_C
 53.1498 -          PIXEL11
 53.1499 -          PIXEL12_C
 53.1500 -          if (Diff(cget(8), cget(4)))
 53.1501 -          {
 53.1502 -            PIXEL20_1M
 53.1503 -          }
 53.1504 -          else
 53.1505 -          {
 53.1506 -            PIXEL20_2
 53.1507 -          }
 53.1508 -          PIXEL21_C
 53.1509 -          if (Diff(cget(6), cget(8)))
 53.1510 -          {
 53.1511 -            PIXEL22_1M
 53.1512 -          }
 53.1513 -          else
 53.1514 -          {
 53.1515 -            PIXEL22_2
 53.1516 -          }
 53.1517 -          break;
 53.1518 -        }
 53.1519 -        case 90:
 53.1520 -        {
 53.1521 -          if (Diff(cget(4), cget(2)))
 53.1522 -          {
 53.1523 -            PIXEL00_1M
 53.1524 -          }
 53.1525 -          else
 53.1526 -          {
 53.1527 -            PIXEL00_2
 53.1528 -          }
 53.1529 -          PIXEL01_C
 53.1530 -          if (Diff(cget(2), cget(6)))
 53.1531 -          {
 53.1532 -            PIXEL02_1M
 53.1533 -          }
 53.1534 -          else
 53.1535 -          {
 53.1536 -            PIXEL02_2
 53.1537 -          }
 53.1538 -          PIXEL10_C
 53.1539 -          PIXEL11
 53.1540 -          PIXEL12_C
 53.1541 -          if (Diff(cget(8), cget(4)))
 53.1542 -          {
 53.1543 -            PIXEL20_1M
 53.1544 -          }
 53.1545 -          else
 53.1546 -          {
 53.1547 -            PIXEL20_2
 53.1548 -          }
 53.1549 -          PIXEL21_C
 53.1550 -          if (Diff(cget(6), cget(8)))
 53.1551 -          {
 53.1552 -            PIXEL22_1M
 53.1553 -          }
 53.1554 -          else
 53.1555 -          {
 53.1556 -            PIXEL22_2
 53.1557 -          }
 53.1558 -          break;
 53.1559 -        }
 53.1560 -        case 55:
 53.1561 -        case 23:
 53.1562 -        {
 53.1563 -          if (Diff(cget(2), cget(6)))
 53.1564 -          {
 53.1565 -            PIXEL00_1L
 53.1566 -            PIXEL01_C
 53.1567 -            PIXEL02_C
 53.1568 -            PIXEL12_C
 53.1569 -          }
 53.1570 -          else
 53.1571 -          {
 53.1572 -            PIXEL00_2
 53.1573 -            PIXEL01_6
 53.1574 -            PIXEL02_5
 53.1575 -            PIXEL12_1
 53.1576 -          }
 53.1577 -          PIXEL10_1
 53.1578 -          PIXEL11
 53.1579 -          PIXEL20_2
 53.1580 -          PIXEL21_1
 53.1581 -          PIXEL22_1M
 53.1582 -          break;
 53.1583 -        }
 53.1584 -        case 182:
 53.1585 -        case 150:
 53.1586 -        {
 53.1587 -          if (Diff(cget(2), cget(6)))
 53.1588 -          {
 53.1589 -            PIXEL01_C
 53.1590 -            PIXEL02_C
 53.1591 -            PIXEL12_C
 53.1592 -            PIXEL22_1D
 53.1593 -          }
 53.1594 -          else
 53.1595 -          {
 53.1596 -            PIXEL01_1
 53.1597 -            PIXEL02_5
 53.1598 -            PIXEL12_6
 53.1599 -            PIXEL22_2
 53.1600 -          }
 53.1601 -          PIXEL00_1M
 53.1602 -          PIXEL10_1
 53.1603 -          PIXEL11
 53.1604 -          PIXEL20_2
 53.1605 -          PIXEL21_1
 53.1606 -          break;
 53.1607 -        }
 53.1608 -        case 213:
 53.1609 -        case 212:
 53.1610 -        {
 53.1611 -          if (Diff(cget(6), cget(8)))
 53.1612 -          {
 53.1613 -            PIXEL02_1U
 53.1614 -            PIXEL12_C
 53.1615 -            PIXEL21_C
 53.1616 -            PIXEL22_C
 53.1617 -          }
 53.1618 -          else
 53.1619 -          {
 53.1620 -            PIXEL02_2
 53.1621 -            PIXEL12_6
 53.1622 -            PIXEL21_1
 53.1623 -            PIXEL22_5
 53.1624 -          }
 53.1625 -          PIXEL00_2
 53.1626 -          PIXEL01_1
 53.1627 -          PIXEL10_1
 53.1628 -          PIXEL11
 53.1629 -          PIXEL20_1M
 53.1630 -          break;
 53.1631 -        }
 53.1632 -        case 241:
 53.1633 -        case 240:
 53.1634 -        {
 53.1635 -          if (Diff(cget(6), cget(8)))
 53.1636 -          {
 53.1637 -            PIXEL12_C
 53.1638 -            PIXEL20_1L
 53.1639 -            PIXEL21_C
 53.1640 -            PIXEL22_C
 53.1641 -          }
 53.1642 -          else
 53.1643 -          {
 53.1644 -            PIXEL12_1
 53.1645 -            PIXEL20_2
 53.1646 -            PIXEL21_6
 53.1647 -            PIXEL22_5
 53.1648 -          }
 53.1649 -          PIXEL00_2
 53.1650 -          PIXEL01_1
 53.1651 -          PIXEL02_1M
 53.1652 -          PIXEL10_1
 53.1653 -          PIXEL11
 53.1654 -          break;
 53.1655 -        }
 53.1656 -        case 236:
 53.1657 -        case 232:
 53.1658 -        {
 53.1659 -          if (Diff(cget(8), cget(4)))
 53.1660 -          {
 53.1661 -            PIXEL10_C
 53.1662 -            PIXEL20_C
 53.1663 -            PIXEL21_C
 53.1664 -            PIXEL22_1R
 53.1665 -          }
 53.1666 -          else
 53.1667 -          {
 53.1668 -            PIXEL10_1
 53.1669 -            PIXEL20_5
 53.1670 -            PIXEL21_6
 53.1671 -            PIXEL22_2
 53.1672 -          }
 53.1673 -          PIXEL00_1M
 53.1674 -          PIXEL01_1
 53.1675 -          PIXEL02_2
 53.1676 -          PIXEL11
 53.1677 -          PIXEL12_1
 53.1678 -          break;
 53.1679 -        }
 53.1680 -        case 109:
 53.1681 -        case 105:
 53.1682 -        {
 53.1683 -          if (Diff(cget(8), cget(4)))
 53.1684 -          {
 53.1685 -            PIXEL00_1U
 53.1686 -            PIXEL10_C
 53.1687 -            PIXEL20_C
 53.1688 -            PIXEL21_C
 53.1689 -          }
 53.1690 -          else
 53.1691 -          {
 53.1692 -            PIXEL00_2
 53.1693 -            PIXEL10_6
 53.1694 -            PIXEL20_5
 53.1695 -            PIXEL21_1
 53.1696 -          }
 53.1697 -          PIXEL01_1
 53.1698 -          PIXEL02_2
 53.1699 -          PIXEL11
 53.1700 -          PIXEL12_1
 53.1701 -          PIXEL22_1M
 53.1702 -          break;
 53.1703 -        }
 53.1704 -        case 171:
 53.1705 -        case 43:
 53.1706 -        {
 53.1707 -          if (Diff(cget(4), cget(2)))
 53.1708 -          {
 53.1709 -            PIXEL00_C
 53.1710 -            PIXEL01_C
 53.1711 -            PIXEL10_C
 53.1712 -            PIXEL20_1D
 53.1713 -          }
 53.1714 -          else
 53.1715 -          {
 53.1716 -            PIXEL00_5
 53.1717 -            PIXEL01_1
 53.1718 -            PIXEL10_6
 53.1719 -            PIXEL20_2
 53.1720 -          }
 53.1721 -          PIXEL02_1M
 53.1722 -          PIXEL11
 53.1723 -          PIXEL12_1
 53.1724 -          PIXEL21_1
 53.1725 -          PIXEL22_2
 53.1726 -          break;
 53.1727 -        }
 53.1728 -        case 143:
 53.1729 -        case 15:
 53.1730 -        {
 53.1731 -          if (Diff(cget(4), cget(2)))
 53.1732 -          {
 53.1733 -            PIXEL00_C
 53.1734 -            PIXEL01_C
 53.1735 -            PIXEL02_1R
 53.1736 -            PIXEL10_C
 53.1737 -          }
 53.1738 -          else
 53.1739 -          {
 53.1740 -            PIXEL00_5
 53.1741 -            PIXEL01_6
 53.1742 -            PIXEL02_2
 53.1743 -            PIXEL10_1
 53.1744 -          }
 53.1745 -          PIXEL11
 53.1746 -          PIXEL12_1
 53.1747 -          PIXEL20_1M
 53.1748 -          PIXEL21_1
 53.1749 -          PIXEL22_2
 53.1750 -          break;
 53.1751 -        }
 53.1752 -        case 124:
 53.1753 -        {
 53.1754 -          PIXEL00_1M
 53.1755 -          PIXEL01_1
 53.1756 -          PIXEL02_1U
 53.1757 -          PIXEL11
 53.1758 -          PIXEL12_C
 53.1759 -          if (Diff(cget(8), cget(4)))
 53.1760 -          {
 53.1761 -            PIXEL10_C
 53.1762 -            PIXEL20_C
 53.1763 -            PIXEL21_C
 53.1764 -          }
 53.1765 -          else
 53.1766 -          {
 53.1767 -            PIXEL10_3
 53.1768 -            PIXEL20_4
 53.1769 -            PIXEL21_3
 53.1770 -          }
 53.1771 -          PIXEL22_1M
 53.1772 -          break;
 53.1773 -        }
 53.1774 -        case 203:
 53.1775 -        {
 53.1776 -          if (Diff(cget(4), cget(2)))
 53.1777 -          {
 53.1778 -            PIXEL00_C
 53.1779 -            PIXEL01_C
 53.1780 -            PIXEL10_C
 53.1781 -          }
 53.1782 -          else
 53.1783 -          {
 53.1784 -            PIXEL00_4
 53.1785 -            PIXEL01_3
 53.1786 -            PIXEL10_3
 53.1787 -          }
 53.1788 -          PIXEL02_1M
 53.1789 -          PIXEL11
 53.1790 -          PIXEL12_1
 53.1791 -          PIXEL20_1M
 53.1792 -          PIXEL21_C
 53.1793 -          PIXEL22_1R
 53.1794 -          break;
 53.1795 -        }
 53.1796 -        case 62:
 53.1797 -        {
 53.1798 -          PIXEL00_1M
 53.1799 -          if (Diff(cget(2), cget(6)))
 53.1800 -          {
 53.1801 -            PIXEL01_C
 53.1802 -            PIXEL02_C
 53.1803 -            PIXEL12_C
 53.1804 -          }
 53.1805 -          else
 53.1806 -          {
 53.1807 -            PIXEL01_3
 53.1808 -            PIXEL02_4
 53.1809 -            PIXEL12_3
 53.1810 -          }
 53.1811 -          PIXEL10_C
 53.1812 -          PIXEL11
 53.1813 -          PIXEL20_1D
 53.1814 -          PIXEL21_1
 53.1815 -          PIXEL22_1M
 53.1816 -          break;
 53.1817 -        }
 53.1818 -        case 211:
 53.1819 -        {
 53.1820 -          PIXEL00_1L
 53.1821 -          PIXEL01_C
 53.1822 -          PIXEL02_1M
 53.1823 -          PIXEL10_1
 53.1824 -          PIXEL11
 53.1825 -          PIXEL20_1M
 53.1826 -          if (Diff(cget(6), cget(8)))
 53.1827 -          {
 53.1828 -            PIXEL12_C
 53.1829 -            PIXEL21_C
 53.1830 -            PIXEL22_C
 53.1831 -          }
 53.1832 -          else
 53.1833 -          {
 53.1834 -            PIXEL12_3
 53.1835 -            PIXEL21_3
 53.1836 -            PIXEL22_4
 53.1837 -          }
 53.1838 -          break;
 53.1839 -        }
 53.1840 -        case 118:
 53.1841 -        {
 53.1842 -          PIXEL00_1M
 53.1843 -          if (Diff(cget(2), cget(6)))
 53.1844 -          {
 53.1845 -            PIXEL01_C
 53.1846 -            PIXEL02_C
 53.1847 -            PIXEL12_C
 53.1848 -          }
 53.1849 -          else
 53.1850 -          {
 53.1851 -            PIXEL01_3
 53.1852 -            PIXEL02_4
 53.1853 -            PIXEL12_3
 53.1854 -          }
 53.1855 -          PIXEL10_1
 53.1856 -          PIXEL11
 53.1857 -          PIXEL20_1L
 53.1858 -          PIXEL21_C
 53.1859 -          PIXEL22_1M
 53.1860 -          break;
 53.1861 -        }
 53.1862 -        case 217:
 53.1863 -        {
 53.1864 -          PIXEL00_1U
 53.1865 -          PIXEL01_1
 53.1866 -          PIXEL02_1M
 53.1867 -          PIXEL10_C
 53.1868 -          PIXEL11
 53.1869 -          PIXEL20_1M
 53.1870 -          if (Diff(cget(6), cget(8)))
 53.1871 -          {
 53.1872 -            PIXEL12_C
 53.1873 -            PIXEL21_C
 53.1874 -            PIXEL22_C
 53.1875 -          }
 53.1876 -          else
 53.1877 -          {
 53.1878 -            PIXEL12_3
 53.1879 -            PIXEL21_3
 53.1880 -            PIXEL22_4
 53.1881 -          }
 53.1882 -          break;
 53.1883 -        }
 53.1884 -        case 110:
 53.1885 -        {
 53.1886 -          PIXEL00_1M
 53.1887 -          PIXEL01_C
 53.1888 -          PIXEL02_1R
 53.1889 -          PIXEL11
 53.1890 -          PIXEL12_1
 53.1891 -          if (Diff(cget(8), cget(4)))
 53.1892 -          {
 53.1893 -            PIXEL10_C
 53.1894 -            PIXEL20_C
 53.1895 -            PIXEL21_C
 53.1896 -          }
 53.1897 -          else
 53.1898 -          {
 53.1899 -            PIXEL10_3
 53.1900 -            PIXEL20_4
 53.1901 -            PIXEL21_3
 53.1902 -          }
 53.1903 -          PIXEL22_1M
 53.1904 -          break;
 53.1905 -        }
 53.1906 -        case 155:
 53.1907 -        {
 53.1908 -          if (Diff(cget(4), cget(2)))
 53.1909 -          {
 53.1910 -            PIXEL00_C
 53.1911 -            PIXEL01_C
 53.1912 -            PIXEL10_C
 53.1913 -          }
 53.1914 -          else
 53.1915 -          {
 53.1916 -            PIXEL00_4
 53.1917 -            PIXEL01_3
 53.1918 -            PIXEL10_3
 53.1919 -          }
 53.1920 -          PIXEL02_1M
 53.1921 -          PIXEL11
 53.1922 -          PIXEL12_C
 53.1923 -          PIXEL20_1M
 53.1924 -          PIXEL21_1
 53.1925 -          PIXEL22_1D
 53.1926 -          break;
 53.1927 -        }
 53.1928 -        case 188:
 53.1929 -        {
 53.1930 -          PIXEL00_1M
 53.1931 -          PIXEL01_1
 53.1932 -          PIXEL02_1U
 53.1933 -          PIXEL10_C
 53.1934 -          PIXEL11
 53.1935 -          PIXEL12_C
 53.1936 -          PIXEL20_1D
 53.1937 -          PIXEL21_1
 53.1938 -          PIXEL22_1D
 53.1939 -          break;
 53.1940 -        }
 53.1941 -        case 185:
 53.1942 -        {
 53.1943 -          PIXEL00_1U
 53.1944 -          PIXEL01_1
 53.1945 -          PIXEL02_1M
 53.1946 -          PIXEL10_C
 53.1947 -          PIXEL11
 53.1948 -          PIXEL12_C
 53.1949 -          PIXEL20_1D
 53.1950 -          PIXEL21_1
 53.1951 -          PIXEL22_1D
 53.1952 -          break;
 53.1953 -        }
 53.1954 -        case 61:
 53.1955 -        {
 53.1956 -          PIXEL00_1U
 53.1957 -          PIXEL01_1
 53.1958 -          PIXEL02_1U
 53.1959 -          PIXEL10_C
 53.1960 -          PIXEL11
 53.1961 -          PIXEL12_C
 53.1962 -          PIXEL20_1D
 53.1963 -          PIXEL21_1
 53.1964 -          PIXEL22_1M
 53.1965 -          break;
 53.1966 -        }
 53.1967 -        case 157:
 53.1968 -        {
 53.1969 -          PIXEL00_1U
 53.1970 -          PIXEL01_1
 53.1971 -          PIXEL02_1U
 53.1972 -          PIXEL10_C
 53.1973 -          PIXEL11
 53.1974 -          PIXEL12_C
 53.1975 -          PIXEL20_1M
 53.1976 -          PIXEL21_1
 53.1977 -          PIXEL22_1D
 53.1978 -          break;
 53.1979 -        }
 53.1980 -        case 103:
 53.1981 -        {
 53.1982 -          PIXEL00_1L
 53.1983 -          PIXEL01_C
 53.1984 -          PIXEL02_1R
 53.1985 -          PIXEL10_1
 53.1986 -          PIXEL11
 53.1987 -          PIXEL12_1
 53.1988 -          PIXEL20_1L
 53.1989 -          PIXEL21_C
 53.1990 -          PIXEL22_1M
 53.1991 -          break;
 53.1992 -        }
 53.1993 -        case 227:
 53.1994 -        {
 53.1995 -          PIXEL00_1L
 53.1996 -          PIXEL01_C
 53.1997 -          PIXEL02_1M
 53.1998 -          PIXEL10_1
 53.1999 -          PIXEL11
 53.2000 -          PIXEL12_1
 53.2001 -          PIXEL20_1L
 53.2002 -          PIXEL21_C
 53.2003 -          PIXEL22_1R
 53.2004 -          break;
 53.2005 -        }
 53.2006 -        case 230:
 53.2007 -        {
 53.2008 -          PIXEL00_1M
 53.2009 -          PIXEL01_C
 53.2010 -          PIXEL02_1R
 53.2011 -          PIXEL10_1
 53.2012 -          PIXEL11
 53.2013 -          PIXEL12_1
 53.2014 -          PIXEL20_1L
 53.2015 -          PIXEL21_C
 53.2016 -          PIXEL22_1R
 53.2017 -          break;
 53.2018 -        }
 53.2019 -        case 199:
 53.2020 -        {
 53.2021 -          PIXEL00_1L
 53.2022 -          PIXEL01_C
 53.2023 -          PIXEL02_1R
 53.2024 -          PIXEL10_1
 53.2025 -          PIXEL11
 53.2026 -          PIXEL12_1
 53.2027 -          PIXEL20_1M
 53.2028 -          PIXEL21_C
 53.2029 -          PIXEL22_1R
 53.2030 -          break;
 53.2031 -        }
 53.2032 -        case 220:
 53.2033 -        {
 53.2034 -          PIXEL00_1M
 53.2035 -          PIXEL01_1
 53.2036 -          PIXEL02_1U
 53.2037 -          PIXEL10_C
 53.2038 -          PIXEL11
 53.2039 -          if (Diff(cget(8), cget(4)))
 53.2040 -          {
 53.2041 -            PIXEL20_1M
 53.2042 -          }
 53.2043 -          else
 53.2044 -          {
 53.2045 -            PIXEL20_2
 53.2046 -          }
 53.2047 -          if (Diff(cget(6), cget(8)))
 53.2048 -          {
 53.2049 -            PIXEL12_C
 53.2050 -            PIXEL21_C
 53.2051 -            PIXEL22_C
 53.2052 -          }
 53.2053 -          else
 53.2054 -          {
 53.2055 -            PIXEL12_3
 53.2056 -            PIXEL21_3
 53.2057 -            PIXEL22_4
 53.2058 -          }
 53.2059 -          break;
 53.2060 -        }
 53.2061 -        case 158:
 53.2062 -        {
 53.2063 -          if (Diff(cget(4), cget(2)))
 53.2064 -          {
 53.2065 -            PIXEL00_1M
 53.2066 -          }
 53.2067 -          else
 53.2068 -          {
 53.2069 -            PIXEL00_2
 53.2070 -          }
 53.2071 -          if (Diff(cget(2), cget(6)))
 53.2072 -          {
 53.2073 -            PIXEL01_C
 53.2074 -            PIXEL02_C
 53.2075 -            PIXEL12_C
 53.2076 -          }
 53.2077 -          else
 53.2078 -          {
 53.2079 -            PIXEL01_3
 53.2080 -            PIXEL02_4
 53.2081 -            PIXEL12_3
 53.2082 -          }
 53.2083 -          PIXEL10_C
 53.2084 -          PIXEL11
 53.2085 -          PIXEL20_1M
 53.2086 -          PIXEL21_1
 53.2087 -          PIXEL22_1D
 53.2088 -          break;
 53.2089 -        }
 53.2090 -        case 234:
 53.2091 -        {
 53.2092 -          if (Diff(cget(4), cget(2)))
 53.2093 -          {
 53.2094 -            PIXEL00_1M
 53.2095 -          }
 53.2096 -          else
 53.2097 -          {
 53.2098 -            PIXEL00_2
 53.2099 -          }
 53.2100 -          PIXEL01_C
 53.2101 -          PIXEL02_1M
 53.2102 -          PIXEL11
 53.2103 -          PIXEL12_1
 53.2104 -          if (Diff(cget(8), cget(4)))
 53.2105 -          {
 53.2106 -            PIXEL10_C
 53.2107 -            PIXEL20_C
 53.2108 -            PIXEL21_C
 53.2109 -          }
 53.2110 -          else
 53.2111 -          {
 53.2112 -            PIXEL10_3
 53.2113 -            PIXEL20_4
 53.2114 -            PIXEL21_3
 53.2115 -          }
 53.2116 -          PIXEL22_1R
 53.2117 -          break;
 53.2118 -        }
 53.2119 -        case 242:
 53.2120 -        {
 53.2121 -          PIXEL00_1M
 53.2122 -          PIXEL01_C
 53.2123 -          if (Diff(cget(2), cget(6)))
 53.2124 -          {
 53.2125 -            PIXEL02_1M
 53.2126 -          }
 53.2127 -          else
 53.2128 -          {
 53.2129 -            PIXEL02_2
 53.2130 -          }
 53.2131 -          PIXEL10_1
 53.2132 -          PIXEL11
 53.2133 -          PIXEL20_1L
 53.2134 -          if (Diff(cget(6), cget(8)))
 53.2135 -          {
 53.2136 -            PIXEL12_C
 53.2137 -            PIXEL21_C
 53.2138 -            PIXEL22_C
 53.2139 -          }
 53.2140 -          else
 53.2141 -          {
 53.2142 -            PIXEL12_3
 53.2143 -            PIXEL21_3
 53.2144 -            PIXEL22_4
 53.2145 -          }
 53.2146 -          break;
 53.2147 -        }
 53.2148 -        case 59:
 53.2149 -        {
 53.2150 -          if (Diff(cget(4), cget(2)))
 53.2151 -          {
 53.2152 -            PIXEL00_C
 53.2153 -            PIXEL01_C
 53.2154 -            PIXEL10_C
 53.2155 -          }
 53.2156 -          else
 53.2157 -          {
 53.2158 -            PIXEL00_4
 53.2159 -            PIXEL01_3
 53.2160 -            PIXEL10_3
 53.2161 -          }
 53.2162 -          if (Diff(cget(2), cget(6)))
 53.2163 -          {
 53.2164 -            PIXEL02_1M
 53.2165 -          }
 53.2166 -          else
 53.2167 -          {
 53.2168 -            PIXEL02_2
 53.2169 -          }
 53.2170 -          PIXEL11
 53.2171 -          PIXEL12_C
 53.2172 -          PIXEL20_1D
 53.2173 -          PIXEL21_1
 53.2174 -          PIXEL22_1M
 53.2175 -          break;
 53.2176 -        }
 53.2177 -        case 121:
 53.2178 -        {
 53.2179 -          PIXEL00_1U
 53.2180 -          PIXEL01_1
 53.2181 -          PIXEL02_1M
 53.2182 -          PIXEL11
 53.2183 -          PIXEL12_C
 53.2184 -          if (Diff(cget(8), cget(4)))
 53.2185 -          {
 53.2186 -            PIXEL10_C
 53.2187 -            PIXEL20_C
 53.2188 -            PIXEL21_C
 53.2189 -          }
 53.2190 -          else
 53.2191 -          {
 53.2192 -            PIXEL10_3
 53.2193 -            PIXEL20_4
 53.2194 -            PIXEL21_3
 53.2195 -          }
 53.2196 -          if (Diff(cget(6), cget(8)))
 53.2197 -          {
 53.2198 -            PIXEL22_1M
 53.2199 -          }
 53.2200 -          else
 53.2201 -          {
 53.2202 -            PIXEL22_2
 53.2203 -          }
 53.2204 -          break;
 53.2205 -        }
 53.2206 -        case 87:
 53.2207 -        {
 53.2208 -          PIXEL00_1L
 53.2209 -          if (Diff(cget(2), cget(6)))
 53.2210 -          {
 53.2211 -            PIXEL01_C
 53.2212 -            PIXEL02_C
 53.2213 -            PIXEL12_C
 53.2214 -          }
 53.2215 -          else
 53.2216 -          {
 53.2217 -            PIXEL01_3
 53.2218 -            PIXEL02_4
 53.2219 -            PIXEL12_3
 53.2220 -          }
 53.2221 -          PIXEL10_1
 53.2222 -          PIXEL11
 53.2223 -          PIXEL20_1M
 53.2224 -          PIXEL21_C
 53.2225 -          if (Diff(cget(6), cget(8)))
 53.2226 -          {
 53.2227 -            PIXEL22_1M
 53.2228 -          }
 53.2229 -          else
 53.2230 -          {
 53.2231 -            PIXEL22_2
 53.2232 -          }
 53.2233 -          break;
 53.2234 -        }
 53.2235 -        case 79:
 53.2236 -        {
 53.2237 -          if (Diff(cget(4), cget(2)))
 53.2238 -          {
 53.2239 -            PIXEL00_C
 53.2240 -            PIXEL01_C
 53.2241 -            PIXEL10_C
 53.2242 -          }
 53.2243 -          else
 53.2244 -          {
 53.2245 -            PIXEL00_4
 53.2246 -            PIXEL01_3
 53.2247 -            PIXEL10_3
 53.2248 -          }
 53.2249 -          PIXEL02_1R
 53.2250 -          PIXEL11
 53.2251 -          PIXEL12_1
 53.2252 -          if (Diff(cget(8), cget(4)))
 53.2253 -          {
 53.2254 -            PIXEL20_1M
 53.2255 -          }
 53.2256 -          else
 53.2257 -          {
 53.2258 -            PIXEL20_2
 53.2259 -          }
 53.2260 -          PIXEL21_C
 53.2261 -          PIXEL22_1M
 53.2262 -          break;
 53.2263 -        }
 53.2264 -        case 122:
 53.2265 -        {
 53.2266 -          if (Diff(cget(4), cget(2)))
 53.2267 -          {
 53.2268 -            PIXEL00_1M
 53.2269 -          }
 53.2270 -          else
 53.2271 -          {
 53.2272 -            PIXEL00_2
 53.2273 -          }
 53.2274 -          PIXEL01_C
 53.2275 -          if (Diff(cget(2), cget(6)))
 53.2276 -          {
 53.2277 -            PIXEL02_1M
 53.2278 -          }
 53.2279 -          else
 53.2280 -          {
 53.2281 -            PIXEL02_2
 53.2282 -          }
 53.2283 -          PIXEL11
 53.2284 -          PIXEL12_C
 53.2285 -          if (Diff(cget(8), cget(4)))
 53.2286 -          {
 53.2287 -            PIXEL10_C
 53.2288 -            PIXEL20_C
 53.2289 -            PIXEL21_C
 53.2290 -          }
 53.2291 -          else
 53.2292 -          {
 53.2293 -            PIXEL10_3
 53.2294 -            PIXEL20_4
 53.2295 -            PIXEL21_3
 53.2296 -          }
 53.2297 -          if (Diff(cget(6), cget(8)))
 53.2298 -          {
 53.2299 -            PIXEL22_1M
 53.2300 -          }
 53.2301 -          else
 53.2302 -          {
 53.2303 -            PIXEL22_2
 53.2304 -          }
 53.2305 -          break;
 53.2306 -        }
 53.2307 -        case 94:
 53.2308 -        {
 53.2309 -          if (Diff(cget(4), cget(2)))
 53.2310 -          {
 53.2311 -            PIXEL00_1M
 53.2312 -          }
 53.2313 -          else
 53.2314 -          {
 53.2315 -            PIXEL00_2
 53.2316 -          }
 53.2317 -          if (Diff(cget(2), cget(6)))
 53.2318 -          {
 53.2319 -            PIXEL01_C
 53.2320 -            PIXEL02_C
 53.2321 -            PIXEL12_C
 53.2322 -          }
 53.2323 -          else
 53.2324 -          {
 53.2325 -            PIXEL01_3
 53.2326 -            PIXEL02_4
 53.2327 -            PIXEL12_3
 53.2328 -          }
 53.2329 -          PIXEL10_C
 53.2330 -          PIXEL11
 53.2331 -          if (Diff(cget(8), cget(4)))
 53.2332 -          {
 53.2333 -            PIXEL20_1M
 53.2334 -          }
 53.2335 -          else
 53.2336 -          {
 53.2337 -            PIXEL20_2
 53.2338 -          }
 53.2339 -          PIXEL21_C
 53.2340 -          if (Diff(cget(6), cget(8)))
 53.2341 -          {
 53.2342 -            PIXEL22_1M
 53.2343 -          }
 53.2344 -          else
 53.2345 -          {
 53.2346 -            PIXEL22_2
 53.2347 -          }
 53.2348 -          break;
 53.2349 -        }
 53.2350 -        case 218:
 53.2351 -        {
 53.2352 -          if (Diff(cget(4), cget(2)))
 53.2353 -          {
 53.2354 -            PIXEL00_1M
 53.2355 -          }
 53.2356 -          else
 53.2357 -          {
 53.2358 -            PIXEL00_2
 53.2359 -          }
 53.2360 -          PIXEL01_C
 53.2361 -          if (Diff(cget(2), cget(6)))
 53.2362 -          {
 53.2363 -            PIXEL02_1M
 53.2364 -          }
 53.2365 -          else
 53.2366 -          {
 53.2367 -            PIXEL02_2
 53.2368 -          }
 53.2369 -          PIXEL10_C
 53.2370 -          PIXEL11
 53.2371 -          if (Diff(cget(8), cget(4)))
 53.2372 -          {
 53.2373 -            PIXEL20_1M
 53.2374 -          }
 53.2375 -          else
 53.2376 -          {
 53.2377 -            PIXEL20_2
 53.2378 -          }
 53.2379 -          if (Diff(cget(6), cget(8)))
 53.2380 -          {
 53.2381 -            PIXEL12_C
 53.2382 -            PIXEL21_C
 53.2383 -            PIXEL22_C
 53.2384 -          }
 53.2385 -          else
 53.2386 -          {
 53.2387 -            PIXEL12_3
 53.2388 -            PIXEL21_3
 53.2389 -            PIXEL22_4
 53.2390 -          }
 53.2391 -          break;
 53.2392 -        }
 53.2393 -        case 91:
 53.2394 -        {
 53.2395 -          if (Diff(cget(4), cget(2)))
 53.2396 -          {
 53.2397 -            PIXEL00_C
 53.2398 -            PIXEL01_C
 53.2399 -            PIXEL10_C
 53.2400 -          }
 53.2401 -          else
 53.2402 -          {
 53.2403 -            PIXEL00_4
 53.2404 -            PIXEL01_3
 53.2405 -            PIXEL10_3
 53.2406 -          }
 53.2407 -          if (Diff(cget(2), cget(6)))
 53.2408 -          {
 53.2409 -            PIXEL02_1M
 53.2410 -          }
 53.2411 -          else
 53.2412 -          {
 53.2413 -            PIXEL02_2
 53.2414 -          }
 53.2415 -          PIXEL11
 53.2416 -          PIXEL12_C
 53.2417 -          if (Diff(cget(8), cget(4)))
 53.2418 -          {
 53.2419 -            PIXEL20_1M
 53.2420 -          }
 53.2421 -          else
 53.2422 -          {
 53.2423 -            PIXEL20_2
 53.2424 -          }
 53.2425 -          PIXEL21_C
 53.2426 -          if (Diff(cget(6), cget(8)))
 53.2427 -          {
 53.2428 -            PIXEL22_1M
 53.2429 -          }
 53.2430 -          else
 53.2431 -          {
 53.2432 -            PIXEL22_2
 53.2433 -          }
 53.2434 -          break;
 53.2435 -        }
 53.2436 -        case 229:
 53.2437 -        {
 53.2438 -          PIXEL00_2
 53.2439 -          PIXEL01_1
 53.2440 -          PIXEL02_2
 53.2441 -          PIXEL10_1
 53.2442 -          PIXEL11
 53.2443 -          PIXEL12_1
 53.2444 -          PIXEL20_1L
 53.2445 -          PIXEL21_C
 53.2446 -          PIXEL22_1R
 53.2447 -          break;
 53.2448 -        }
 53.2449 -        case 167:
 53.2450 -        {
 53.2451 -          PIXEL00_1L
 53.2452 -          PIXEL01_C
 53.2453 -          PIXEL02_1R
 53.2454 -          PIXEL10_1
 53.2455 -          PIXEL11
 53.2456 -          PIXEL12_1
 53.2457 -          PIXEL20_2
 53.2458 -          PIXEL21_1
 53.2459 -          PIXEL22_2
 53.2460 -          break;
 53.2461 -        }
 53.2462 -        case 173:
 53.2463 -        {
 53.2464 -          PIXEL00_1U
 53.2465 -          PIXEL01_1
 53.2466 -          PIXEL02_2
 53.2467 -          PIXEL10_C
 53.2468 -          PIXEL11
 53.2469 -          PIXEL12_1
 53.2470 -          PIXEL20_1D
 53.2471 -          PIXEL21_1
 53.2472 -          PIXEL22_2
 53.2473 -          break;
 53.2474 -        }
 53.2475 -        case 181:
 53.2476 -        {
 53.2477 -          PIXEL00_2
 53.2478 -          PIXEL01_1
 53.2479 -          PIXEL02_1U
 53.2480 -          PIXEL10_1
 53.2481 -          PIXEL11
 53.2482 -          PIXEL12_C
 53.2483 -          PIXEL20_2
 53.2484 -          PIXEL21_1
 53.2485 -          PIXEL22_1D
 53.2486 -          break;
 53.2487 -        }
 53.2488 -        case 186:
 53.2489 -        {
 53.2490 -          if (Diff(cget(4), cget(2)))
 53.2491 -          {
 53.2492 -            PIXEL00_1M
 53.2493 -          }
 53.2494 -          else
 53.2495 -          {
 53.2496 -            PIXEL00_2
 53.2497 -          }
 53.2498 -          PIXEL01_C
 53.2499 -          if (Diff(cget(2), cget(6)))
 53.2500 -          {
 53.2501 -            PIXEL02_1M
 53.2502 -          }
 53.2503 -          else
 53.2504 -          {
 53.2505 -            PIXEL02_2
 53.2506 -          }
 53.2507 -          PIXEL10_C
 53.2508 -          PIXEL11
 53.2509 -          PIXEL12_C
 53.2510 -          PIXEL20_1D
 53.2511 -          PIXEL21_1
 53.2512 -          PIXEL22_1D
 53.2513 -          break;
 53.2514 -        }
 53.2515 -        case 115:
 53.2516 -        {
 53.2517 -          PIXEL00_1L
 53.2518 -          PIXEL01_C
 53.2519 -          if (Diff(cget(2), cget(6)))
 53.2520 -          {
 53.2521 -            PIXEL02_1M
 53.2522 -          }
 53.2523 -          else
 53.2524 -          {
 53.2525 -            PIXEL02_2
 53.2526 -          }
 53.2527 -          PIXEL10_1
 53.2528 -          PIXEL11
 53.2529 -          PIXEL12_C
 53.2530 -          PIXEL20_1L
 53.2531 -          PIXEL21_C
 53.2532 -          if (Diff(cget(6), cget(8)))
 53.2533 -          {
 53.2534 -            PIXEL22_1M
 53.2535 -          }
 53.2536 -          else
 53.2537 -          {
 53.2538 -            PIXEL22_2
 53.2539 -          }
 53.2540 -          break;
 53.2541 -        }
 53.2542 -        case 93:
 53.2543 -        {
 53.2544 -          PIXEL00_1U
 53.2545 -          PIXEL01_1
 53.2546 -          PIXEL02_1U
 53.2547 -          PIXEL10_C
 53.2548 -          PIXEL11
 53.2549 -          PIXEL12_C
 53.2550 -          if (Diff(cget(8), cget(4)))
 53.2551 -          {
 53.2552 -            PIXEL20_1M
 53.2553 -          }
 53.2554 -          else
 53.2555 -          {
 53.2556 -            PIXEL20_2
 53.2557 -          }
 53.2558 -          PIXEL21_C
 53.2559 -          if (Diff(cget(6), cget(8)))
 53.2560 -          {
 53.2561 -            PIXEL22_1M
 53.2562 -          }
 53.2563 -          else
 53.2564 -          {
 53.2565 -            PIXEL22_2
 53.2566 -          }
 53.2567 -          break;
 53.2568 -        }
 53.2569 -        case 206:
 53.2570 -        {
 53.2571 -          if (Diff(cget(4), cget(2)))
 53.2572 -          {
 53.2573 -            PIXEL00_1M
 53.2574 -          }
 53.2575 -          else
 53.2576 -          {
 53.2577 -            PIXEL00_2
 53.2578 -          }
 53.2579 -          PIXEL01_C
 53.2580 -          PIXEL02_1R
 53.2581 -          PIXEL10_C
 53.2582 -          PIXEL11
 53.2583 -          PIXEL12_1
 53.2584 -          if (Diff(cget(8), cget(4)))
 53.2585 -          {
 53.2586 -            PIXEL20_1M
 53.2587 -          }
 53.2588 -          else
 53.2589 -          {
 53.2590 -            PIXEL20_2
 53.2591 -          }
 53.2592 -          PIXEL21_C
 53.2593 -          PIXEL22_1R
 53.2594 -          break;
 53.2595 -        }
 53.2596 -        case 205:
 53.2597 -        case 201:
 53.2598 -        {
 53.2599 -          PIXEL00_1U
 53.2600 -          PIXEL01_1
 53.2601 -          PIXEL02_2
 53.2602 -          PIXEL10_C
 53.2603 -          PIXEL11
 53.2604 -          PIXEL12_1
 53.2605 -          if (Diff(cget(8), cget(4)))
 53.2606 -          {
 53.2607 -            PIXEL20_1M
 53.2608 -          }
 53.2609 -          else
 53.2610 -          {
 53.2611 -            PIXEL20_2
 53.2612 -          }
 53.2613 -          PIXEL21_C
 53.2614 -          PIXEL22_1R
 53.2615 -          break;
 53.2616 -        }
 53.2617 -        case 174:
 53.2618 -        case 46:
 53.2619 -        {
 53.2620 -          if (Diff(cget(4), cget(2)))
 53.2621 -          {
 53.2622 -            PIXEL00_1M
 53.2623 -          }
 53.2624 -          else
 53.2625 -          {
 53.2626 -            PIXEL00_2
 53.2627 -          }
 53.2628 -          PIXEL01_C
 53.2629 -          PIXEL02_1R
 53.2630 -          PIXEL10_C
 53.2631 -          PIXEL11
 53.2632 -          PIXEL12_1
 53.2633 -          PIXEL20_1D
 53.2634 -          PIXEL21_1
 53.2635 -          PIXEL22_2
 53.2636 -          break;
 53.2637 -        }
 53.2638 -        case 179:
 53.2639 -        case 147:
 53.2640 -        {
 53.2641 -          PIXEL00_1L
 53.2642 -          PIXEL01_C
 53.2643 -          if (Diff(cget(2), cget(6)))
 53.2644 -          {
 53.2645 -            PIXEL02_1M
 53.2646 -          }
 53.2647 -          else
 53.2648 -          {
 53.2649 -            PIXEL02_2
 53.2650 -          }
 53.2651 -          PIXEL10_1
 53.2652 -          PIXEL11
 53.2653 -          PIXEL12_C
 53.2654 -          PIXEL20_2
 53.2655 -          PIXEL21_1
 53.2656 -          PIXEL22_1D
 53.2657 -          break;
 53.2658 -        }
 53.2659 -        case 117:
 53.2660 -        case 116:
 53.2661 -        {
 53.2662 -          PIXEL00_2
 53.2663 -          PIXEL01_1
 53.2664 -          PIXEL02_1U
 53.2665 -          PIXEL10_1
 53.2666 -          PIXEL11
 53.2667 -          PIXEL12_C
 53.2668 -          PIXEL20_1L
 53.2669 -          PIXEL21_C
 53.2670 -          if (Diff(cget(6), cget(8)))
 53.2671 -          {
 53.2672 -            PIXEL22_1M
 53.2673 -          }
 53.2674 -          else
 53.2675 -          {
 53.2676 -            PIXEL22_2
 53.2677 -          }
 53.2678 -          break;
 53.2679 -        }
 53.2680 -        case 189:
 53.2681 -        {
 53.2682 -          PIXEL00_1U
 53.2683 -          PIXEL01_1
 53.2684 -          PIXEL02_1U
 53.2685 -          PIXEL10_C
 53.2686 -          PIXEL11
 53.2687 -          PIXEL12_C
 53.2688 -          PIXEL20_1D
 53.2689 -          PIXEL21_1
 53.2690 -          PIXEL22_1D
 53.2691 -          break;
 53.2692 -        }
 53.2693 -        case 231:
 53.2694 -        {
 53.2695 -          PIXEL00_1L
 53.2696 -          PIXEL01_C
 53.2697 -          PIXEL02_1R
 53.2698 -          PIXEL10_1
 53.2699 -          PIXEL11
 53.2700 -          PIXEL12_1
 53.2701 -          PIXEL20_1L
 53.2702 -          PIXEL21_C
 53.2703 -          PIXEL22_1R
 53.2704 -          break;
 53.2705 -        }
 53.2706 -        case 126:
 53.2707 -        {
 53.2708 -          PIXEL00_1M
 53.2709 -          if (Diff(cget(2), cget(6)))
 53.2710 -          {
 53.2711 -            PIXEL01_C
 53.2712 -            PIXEL02_C
 53.2713 -            PIXEL12_C
 53.2714 -          }
 53.2715 -          else
 53.2716 -          {
 53.2717 -            PIXEL01_3
 53.2718 -            PIXEL02_4
 53.2719 -            PIXEL12_3
 53.2720 -          }
 53.2721 -          PIXEL11
 53.2722 -          if (Diff(cget(8), cget(4)))
 53.2723 -          {
 53.2724 -            PIXEL10_C
 53.2725 -            PIXEL20_C
 53.2726 -            PIXEL21_C
 53.2727 -          }
 53.2728 -          else
 53.2729 -          {
 53.2730 -            PIXEL10_3
 53.2731 -            PIXEL20_4
 53.2732 -            PIXEL21_3
 53.2733 -          }
 53.2734 -          PIXEL22_1M
 53.2735 -          break;
 53.2736 -        }
 53.2737 -        case 219:
 53.2738 -        {
 53.2739 -          if (Diff(cget(4), cget(2)))
 53.2740 -          {
 53.2741 -            PIXEL00_C
 53.2742 -            PIXEL01_C
 53.2743 -            PIXEL10_C
 53.2744 -          }
 53.2745 -          else
 53.2746 -          {
 53.2747 -            PIXEL00_4
 53.2748 -            PIXEL01_3
 53.2749 -            PIXEL10_3
 53.2750 -          }
 53.2751 -          PIXEL02_1M
 53.2752 -          PIXEL11
 53.2753 -          PIXEL20_1M
 53.2754 -          if (Diff(cget(6), cget(8)))
 53.2755 -          {
 53.2756 -            PIXEL12_C
 53.2757 -            PIXEL21_C
 53.2758 -            PIXEL22_C
 53.2759 -          }
 53.2760 -          else
 53.2761 -          {
 53.2762 -            PIXEL12_3
 53.2763 -            PIXEL21_3
 53.2764 -            PIXEL22_4
 53.2765 -          }
 53.2766 -          break;
 53.2767 -        }
 53.2768 -        case 125:
 53.2769 -        {
 53.2770 -          if (Diff(cget(8), cget(4)))
 53.2771 -          {
 53.2772 -            PIXEL00_1U
 53.2773 -            PIXEL10_C
 53.2774 -            PIXEL20_C
 53.2775 -            PIXEL21_C
 53.2776 -          }
 53.2777 -          else
 53.2778 -          {
 53.2779 -            PIXEL00_2
 53.2780 -            PIXEL10_6
 53.2781 -            PIXEL20_5
 53.2782 -            PIXEL21_1
 53.2783 -          }
 53.2784 -          PIXEL01_1
 53.2785 -          PIXEL02_1U
 53.2786 -          PIXEL11
 53.2787 -          PIXEL12_C
 53.2788 -          PIXEL22_1M
 53.2789 -          break;
 53.2790 -        }
 53.2791 -        case 221:
 53.2792 -        {
 53.2793 -          if (Diff(cget(6), cget(8)))
 53.2794 -          {
 53.2795 -            PIXEL02_1U
 53.2796 -            PIXEL12_C
 53.2797 -            PIXEL21_C
 53.2798 -            PIXEL22_C
 53.2799 -          }
 53.2800 -          else
 53.2801 -          {
 53.2802 -            PIXEL02_2
 53.2803 -            PIXEL12_6
 53.2804 -            PIXEL21_1
 53.2805 -            PIXEL22_5
 53.2806 -          }
 53.2807 -          PIXEL00_1U
 53.2808 -          PIXEL01_1
 53.2809 -          PIXEL10_C
 53.2810 -          PIXEL11
 53.2811 -          PIXEL20_1M
 53.2812 -          break;
 53.2813 -        }
 53.2814 -        case 207:
 53.2815 -        {
 53.2816 -          if (Diff(cget(4), cget(2)))
 53.2817 -          {
 53.2818 -            PIXEL00_C
 53.2819 -            PIXEL01_C
 53.2820 -            PIXEL02_1R
 53.2821 -            PIXEL10_C
 53.2822 -          }
 53.2823 -          else
 53.2824 -          {
 53.2825 -            PIXEL00_5
 53.2826 -            PIXEL01_6
 53.2827 -            PIXEL02_2
 53.2828 -            PIXEL10_1
 53.2829 -          }
 53.2830 -          PIXEL11
 53.2831 -          PIXEL12_1
 53.2832 -          PIXEL20_1M
 53.2833 -          PIXEL21_C
 53.2834 -          PIXEL22_1R
 53.2835 -          break;
 53.2836 -        }
 53.2837 -        case 238:
 53.2838 -        {
 53.2839 -          if (Diff(cget(8), cget(4)))
 53.2840 -          {
 53.2841 -            PIXEL10_C
 53.2842 -            PIXEL20_C
 53.2843 -            PIXEL21_C
 53.2844 -            PIXEL22_1R
 53.2845 -          }
 53.2846 -          else
 53.2847 -          {
 53.2848 -            PIXEL10_1
 53.2849 -            PIXEL20_5
 53.2850 -            PIXEL21_6
 53.2851 -            PIXEL22_2
 53.2852 -          }
 53.2853 -          PIXEL00_1M
 53.2854 -          PIXEL01_C
 53.2855 -          PIXEL02_1R
 53.2856 -          PIXEL11
 53.2857 -          PIXEL12_1
 53.2858 -          break;
 53.2859 -        }
 53.2860 -        case 190:
 53.2861 -        {
 53.2862 -          if (Diff(cget(2), cget(6)))
 53.2863 -          {
 53.2864 -            PIXEL01_C
 53.2865 -            PIXEL02_C
 53.2866 -            PIXEL12_C
 53.2867 -            PIXEL22_1D
 53.2868 -          }
 53.2869 -          else
 53.2870 -          {
 53.2871 -            PIXEL01_1
 53.2872 -            PIXEL02_5
 53.2873 -            PIXEL12_6
 53.2874 -            PIXEL22_2
 53.2875 -          }
 53.2876 -          PIXEL00_1M
 53.2877 -          PIXEL10_C
 53.2878 -          PIXEL11
 53.2879 -          PIXEL20_1D
 53.2880 -          PIXEL21_1
 53.2881 -          break;
 53.2882 -        }
 53.2883 -        case 187:
 53.2884 -        {
 53.2885 -          if (Diff(cget(4), cget(2)))
 53.2886 -          {
 53.2887 -            PIXEL00_C
 53.2888 -            PIXEL01_C
 53.2889 -            PIXEL10_C
 53.2890 -            PIXEL20_1D
 53.2891 -          }
 53.2892 -          else
 53.2893 -          {
 53.2894 -            PIXEL00_5
 53.2895 -            PIXEL01_1
 53.2896 -            PIXEL10_6
 53.2897 -            PIXEL20_2
 53.2898 -          }
 53.2899 -          PIXEL02_1M
 53.2900 -          PIXEL11
 53.2901 -          PIXEL12_C
 53.2902 -          PIXEL21_1
 53.2903 -          PIXEL22_1D
 53.2904 -          break;
 53.2905 -        }
 53.2906 -        case 243:
 53.2907 -        {
 53.2908 -          if (Diff(cget(6), cget(8)))
 53.2909 -          {
 53.2910 -            PIXEL12_C
 53.2911 -            PIXEL20_1L
 53.2912 -            PIXEL21_C
 53.2913 -            PIXEL22_C
 53.2914 -          }
 53.2915 -          else
 53.2916 -          {
 53.2917 -            PIXEL12_1
 53.2918 -            PIXEL20_2
 53.2919 -            PIXEL21_6
 53.2920 -            PIXEL22_5
 53.2921 -          }
 53.2922 -          PIXEL00_1L
 53.2923 -          PIXEL01_C
 53.2924 -          PIXEL02_1M
 53.2925 -          PIXEL10_1
 53.2926 -          PIXEL11
 53.2927 -          break;
 53.2928 -        }
 53.2929 -        case 119:
 53.2930 -        {
 53.2931 -          if (Diff(cget(2), cget(6)))
 53.2932 -          {
 53.2933 -            PIXEL00_1L
 53.2934 -            PIXEL01_C
 53.2935 -            PIXEL02_C
 53.2936 -            PIXEL12_C
 53.2937 -          }
 53.2938 -          else
 53.2939 -          {
 53.2940 -            PIXEL00_2
 53.2941 -            PIXEL01_6
 53.2942 -            PIXEL02_5
 53.2943 -            PIXEL12_1
 53.2944 -          }
 53.2945 -          PIXEL10_1
 53.2946 -          PIXEL11
 53.2947 -          PIXEL20_1L
 53.2948 -          PIXEL21_C
 53.2949 -          PIXEL22_1M
 53.2950 -          break;
 53.2951 -        }
 53.2952 -        case 237:
 53.2953 -        case 233:
 53.2954 -        {
 53.2955 -          PIXEL00_1U
 53.2956 -          PIXEL01_1
 53.2957 -          PIXEL02_2
 53.2958 -          PIXEL10_C
 53.2959 -          PIXEL11
 53.2960 -          PIXEL12_1
 53.2961 -          if (Diff(cget(8), cget(4)))
 53.2962 -          {
 53.2963 -            PIXEL20_C
 53.2964 -          }
 53.2965 -          else
 53.2966 -          {
 53.2967 -            PIXEL20_2
 53.2968 -          }
 53.2969 -          PIXEL21_C
 53.2970 -          PIXEL22_1R
 53.2971 -          break;
 53.2972 -        }
 53.2973 -        case 175:
 53.2974 -        case 47:
 53.2975 -        {
 53.2976 -          if (Diff(cget(4), cget(2)))
 53.2977 -          {
 53.2978 -            PIXEL00_C
 53.2979 -          }
 53.2980 -          else
 53.2981 -          {
 53.2982 -            PIXEL00_2
 53.2983 -          }
 53.2984 -          PIXEL01_C
 53.2985 -          PIXEL02_1R
 53.2986 -          PIXEL10_C
 53.2987 -          PIXEL11
 53.2988 -          PIXEL12_1
 53.2989 -          PIXEL20_1D
 53.2990 -          PIXEL21_1
 53.2991 -          PIXEL22_2
 53.2992 -          break;
 53.2993 -        }
 53.2994 -        case 183:
 53.2995 -        case 151:
 53.2996 -        {
 53.2997 -          PIXEL00_1L
 53.2998 -          PIXEL01_C
 53.2999 -          if (Diff(cget(2), cget(6)))
 53.3000 -          {
 53.3001 -            PIXEL02_C
 53.3002 -          }
 53.3003 -          else
 53.3004 -          {
 53.3005 -            PIXEL02_2
 53.3006 -          }
 53.3007 -          PIXEL10_1
 53.3008 -          PIXEL11
 53.3009 -          PIXEL12_C
 53.3010 -          PIXEL20_2
 53.3011 -          PIXEL21_1
 53.3012 -          PIXEL22_1D
 53.3013 -          break;
 53.3014 -        }
 53.3015 -        case 245:
 53.3016 -        case 244:
 53.3017 -        {
 53.3018 -          PIXEL00_2
 53.3019 -          PIXEL01_1
 53.3020 -          PIXEL02_1U
 53.3021 -          PIXEL10_1
 53.3022 -          PIXEL11
 53.3023 -          PIXEL12_C
 53.3024 -          PIXEL20_1L
 53.3025 -          PIXEL21_C
 53.3026 -          if (Diff(cget(6), cget(8)))
 53.3027 -          {
 53.3028 -            PIXEL22_C
 53.3029 -          }
 53.3030 -          else
 53.3031 -          {
 53.3032 -            PIXEL22_2
 53.3033 -          }
 53.3034 -          break;
 53.3035 -        }
 53.3036 -        case 250:
 53.3037 -        {
 53.3038 -          PIXEL00_1M
 53.3039 -          PIXEL01_C
 53.3040 -          PIXEL02_1M
 53.3041 -          PIXEL11
 53.3042 -          if (Diff(cget(8), cget(4)))
 53.3043 -          {
 53.3044 -            PIXEL10_C
 53.3045 -            PIXEL20_C
 53.3046 -          }
 53.3047 -          else
 53.3048 -          {
 53.3049 -            PIXEL10_3
 53.3050 -            PIXEL20_4
 53.3051 -          }
 53.3052 -          PIXEL21_C
 53.3053 -          if (Diff(cget(6), cget(8)))
 53.3054 -          {
 53.3055 -            PIXEL12_C
 53.3056 -            PIXEL22_C
 53.3057 -          }
 53.3058 -          else
 53.3059 -          {
 53.3060 -            PIXEL12_3
 53.3061 -            PIXEL22_4
 53.3062 -          }
 53.3063 -          break;
 53.3064 -        }
 53.3065 -        case 123:
 53.3066 -        {
 53.3067 -          if (Diff(cget(4), cget(2)))
 53.3068 -          {
 53.3069 -            PIXEL00_C
 53.3070 -            PIXEL01_C
 53.3071 -          }
 53.3072 -          else
 53.3073 -          {
 53.3074 -            PIXEL00_4
 53.3075 -            PIXEL01_3
 53.3076 -          }
 53.3077 -          PIXEL02_1M
 53.3078 -          PIXEL10_C
 53.3079 -          PIXEL11
 53.3080 -          PIXEL12_C
 53.3081 -          if (Diff(cget(8), cget(4)))
 53.3082 -          {
 53.3083 -            PIXEL20_C
 53.3084 -            PIXEL21_C
 53.3085 -          }
 53.3086 -          else
 53.3087 -          {
 53.3088 -            PIXEL20_4
 53.3089 -            PIXEL21_3
 53.3090 -          }
 53.3091 -          PIXEL22_1M
 53.3092 -          break;
 53.3093 -        }
 53.3094 -        case 95:
 53.3095 -        {
 53.3096 -          if (Diff(cget(4), cget(2)))
 53.3097 -          {
 53.3098 -            PIXEL00_C
 53.3099 -            PIXEL10_C
 53.3100 -          }
 53.3101 -          else
 53.3102 -          {
 53.3103 -            PIXEL00_4
 53.3104 -            PIXEL10_3
 53.3105 -          }
 53.3106 -          PIXEL01_C
 53.3107 -          if (Diff(cget(2), cget(6)))
 53.3108 -          {
 53.3109 -            PIXEL02_C
 53.3110 -            PIXEL12_C
 53.3111 -          }
 53.3112 -          else
 53.3113 -          {
 53.3114 -            PIXEL02_4
 53.3115 -            PIXEL12_3
 53.3116 -          }
 53.3117 -          PIXEL11
 53.3118 -          PIXEL20_1M
 53.3119 -          PIXEL21_C
 53.3120 -          PIXEL22_1M
 53.3121 -          break;
 53.3122 -        }
 53.3123 -        case 222:
 53.3124 -        {
 53.3125 -          PIXEL00_1M
 53.3126 -          if (Diff(cget(2), cget(6)))
 53.3127 -          {
 53.3128 -            PIXEL01_C
 53.3129 -            PIXEL02_C
 53.3130 -          }
 53.3131 -          else
 53.3132 -          {
 53.3133 -            PIXEL01_3
 53.3134 -            PIXEL02_4
 53.3135 -          }
 53.3136 -          PIXEL10_C
 53.3137 -          PIXEL11
 53.3138 -          PIXEL12_C
 53.3139 -          PIXEL20_1M
 53.3140 -          if (Diff(cget(6), cget(8)))
 53.3141 -          {
 53.3142 -            PIXEL21_C
 53.3143 -            PIXEL22_C
 53.3144 -          }
 53.3145 -          else
 53.3146 -          {
 53.3147 -            PIXEL21_3
 53.3148 -            PIXEL22_4
 53.3149 -          }
 53.3150 -          break;
 53.3151 -        }
 53.3152 -        case 252:
 53.3153 -        {
 53.3154 -          PIXEL00_1M
 53.3155 -          PIXEL01_1
 53.3156 -          PIXEL02_1U
 53.3157 -          PIXEL11
 53.3158 -          PIXEL12_C
 53.3159 -          if (Diff(cget(8), cget(4)))
 53.3160 -          {
 53.3161 -            PIXEL10_C
 53.3162 -            PIXEL20_C
 53.3163 -          }
 53.3164 -          else
 53.3165 -          {
 53.3166 -            PIXEL10_3
 53.3167 -            PIXEL20_4
 53.3168 -          }
 53.3169 -          PIXEL21_C
 53.3170 -          if (Diff(cget(6), cget(8)))
 53.3171 -          {
 53.3172 -            PIXEL22_C
 53.3173 -          }
 53.3174 -          else
 53.3175 -          {
 53.3176 -            PIXEL22_2
 53.3177 -          }
 53.3178 -          break;
 53.3179 -        }
 53.3180 -        case 249:
 53.3181 -        {
 53.3182 -          PIXEL00_1U
 53.3183 -          PIXEL01_1
 53.3184 -          PIXEL02_1M
 53.3185 -          PIXEL10_C
 53.3186 -          PIXEL11
 53.3187 -          if (Diff(cget(8), cget(4)))
 53.3188 -          {
 53.3189 -            PIXEL20_C
 53.3190 -          }
 53.3191 -          else
 53.3192 -          {
 53.3193 -            PIXEL20_2
 53.3194 -          }
 53.3195 -          PIXEL21_C
 53.3196 -          if (Diff(cget(6), cget(8)))
 53.3197 -          {
 53.3198 -            PIXEL12_C
 53.3199 -            PIXEL22_C
 53.3200 -          }
 53.3201 -          else
 53.3202 -          {
 53.3203 -            PIXEL12_3
 53.3204 -            PIXEL22_4
 53.3205 -          }
 53.3206 -          break;
 53.3207 -        }
 53.3208 -        case 235:
 53.3209 -        {
 53.3210 -          if (Diff(cget(4), cget(2)))
 53.3211 -          {
 53.3212 -            PIXEL00_C
 53.3213 -            PIXEL01_C
 53.3214 -          }
 53.3215 -          else
 53.3216 -          {
 53.3217 -            PIXEL00_4
 53.3218 -            PIXEL01_3
 53.3219 -          }
 53.3220 -          PIXEL02_1M
 53.3221 -          PIXEL10_C
 53.3222 -          PIXEL11
 53.3223 -          PIXEL12_1
 53.3224 -          if (Diff(cget(8), cget(4)))
 53.3225 -          {
 53.3226 -            PIXEL20_C
 53.3227 -          }
 53.3228 -          else
 53.3229 -          {
 53.3230 -            PIXEL20_2
 53.3231 -          }
 53.3232 -          PIXEL21_C
 53.3233 -          PIXEL22_1R
 53.3234 -          break;
 53.3235 -        }
 53.3236 -        case 111:
 53.3237 -        {
 53.3238 -          if (Diff(cget(4), cget(2)))
 53.3239 -          {
 53.3240 -            PIXEL00_C
 53.3241 -          }
 53.3242 -          else
 53.3243 -          {
 53.3244 -            PIXEL00_2
 53.3245 -          }
 53.3246 -          PIXEL01_C
 53.3247 -          PIXEL02_1R
 53.3248 -          PIXEL10_C
 53.3249 -          PIXEL11
 53.3250 -          PIXEL12_1
 53.3251 -          if (Diff(cget(8), cget(4)))
 53.3252 -          {
 53.3253 -            PIXEL20_C
 53.3254 -            PIXEL21_C
 53.3255 -          }
 53.3256 -          else
 53.3257 -          {
 53.3258 -            PIXEL20_4
 53.3259 -            PIXEL21_3
 53.3260 -          }
 53.3261 -          PIXEL22_1M
 53.3262 -          break;
 53.3263 -        }
 53.3264 -        case 63:
 53.3265 -        {
 53.3266 -          if (Diff(cget(4), cget(2)))
 53.3267 -          {
 53.3268 -            PIXEL00_C
 53.3269 -          }
 53.3270 -          else
 53.3271 -          {
 53.3272 -            PIXEL00_2
 53.3273 -          }
 53.3274 -          PIXEL01_C
 53.3275 -          if (Diff(cget(2), cget(6)))
 53.3276 -          {
 53.3277 -            PIXEL02_C
 53.3278 -            PIXEL12_C
 53.3279 -          }
 53.3280 -          else
 53.3281 -          {
 53.3282 -            PIXEL02_4
 53.3283 -            PIXEL12_3
 53.3284 -          }
 53.3285 -          PIXEL10_C
 53.3286 -          PIXEL11
 53.3287 -          PIXEL20_1D
 53.3288 -          PIXEL21_1
 53.3289 -          PIXEL22_1M
 53.3290 -          break;
 53.3291 -        }
 53.3292 -        case 159:
 53.3293 -        {
 53.3294 -          if (Diff(cget(4), cget(2)))
 53.3295 -          {
 53.3296 -            PIXEL00_C
 53.3297 -            PIXEL10_C
 53.3298 -          }
 53.3299 -          else
 53.3300 -          {
 53.3301 -            PIXEL00_4
 53.3302 -            PIXEL10_3
 53.3303 -          }
 53.3304 -          PIXEL01_C
 53.3305 -          if (Diff(cget(2), cget(6)))
 53.3306 -          {
 53.3307 -            PIXEL02_C
 53.3308 -          }
 53.3309 -          else
 53.3310 -          {
 53.3311 -            PIXEL02_2
 53.3312 -          }
 53.3313 -          PIXEL11
 53.3314 -          PIXEL12_C
 53.3315 -          PIXEL20_1M
 53.3316 -          PIXEL21_1
 53.3317 -          PIXEL22_1D
 53.3318 -          break;
 53.3319 -        }
 53.3320 -        case 215:
 53.3321 -        {
 53.3322 -          PIXEL00_1L
 53.3323 -          PIXEL01_C
 53.3324 -          if (Diff(cget(2), cget(6)))
 53.3325 -          {
 53.3326 -            PIXEL02_C
 53.3327 -          }
 53.3328 -          else
 53.3329 -          {
 53.3330 -            PIXEL02_2
 53.3331 -          }
 53.3332 -          PIXEL10_1
 53.3333 -          PIXEL11
 53.3334 -          PIXEL12_C
 53.3335 -          PIXEL20_1M
 53.3336 -          if (Diff(cget(6), cget(8)))
 53.3337 -          {
 53.3338 -            PIXEL21_C
 53.3339 -            PIXEL22_C
 53.3340 -          }
 53.3341 -          else
 53.3342 -          {
 53.3343 -            PIXEL21_3
 53.3344 -            PIXEL22_4
 53.3345 -          }
 53.3346 -          break;
 53.3347 -        }
 53.3348 -        case 246:
 53.3349 -        {
 53.3350 -          PIXEL00_1M
 53.3351 -          if (Diff(cget(2), cget(6)))
 53.3352 -          {
 53.3353 -            PIXEL01_C
 53.3354 -            PIXEL02_C
 53.3355 -          }
 53.3356 -          else
 53.3357 -          {
 53.3358 -            PIXEL01_3
 53.3359 -            PIXEL02_4
 53.3360 -          }
 53.3361 -          PIXEL10_1
 53.3362 -          PIXEL11
 53.3363 -          PIXEL12_C
 53.3364 -          PIXEL20_1L
 53.3365 -          PIXEL21_C
 53.3366 -          if (Diff(cget(6), cget(8)))
 53.3367 -          {
 53.3368 -            PIXEL22_C
 53.3369 -          }
 53.3370 -          else
 53.3371 -          {
 53.3372 -            PIXEL22_2
 53.3373 -          }
 53.3374 -          break;
 53.3375 -        }
 53.3376 -        case 254:
 53.3377 -        {
 53.3378 -          PIXEL00_1M
 53.3379 -          if (Diff(cget(2), cget(6)))
 53.3380 -          {
 53.3381 -            PIXEL01_C
 53.3382 -            PIXEL02_C
 53.3383 -          }
 53.3384 -          else
 53.3385 -          {
 53.3386 -            PIXEL01_3
 53.3387 -            PIXEL02_4
 53.3388 -          }
 53.3389 -          PIXEL11
 53.3390 -          if (Diff(cget(8), cget(4)))
 53.3391 -          {
 53.3392 -            PIXEL10_C
 53.3393 -            PIXEL20_C
 53.3394 -          }
 53.3395 -          else
 53.3396 -          {
 53.3397 -            PIXEL10_3
 53.3398 -            PIXEL20_4
 53.3399 -          }
 53.3400 -          if (Diff(cget(6), cget(8)))
 53.3401 -          {
 53.3402 -            PIXEL12_C
 53.3403 -            PIXEL21_C
 53.3404 -            PIXEL22_C
 53.3405 -          }
 53.3406 -          else
 53.3407 -          {
 53.3408 -            PIXEL12_3
 53.3409 -            PIXEL21_3
 53.3410 -            PIXEL22_2
 53.3411 -          }
 53.3412 -          break;
 53.3413 -        }
 53.3414 -        case 253:
 53.3415 -        {
 53.3416 -          PIXEL00_1U
 53.3417 -          PIXEL01_1
 53.3418 -          PIXEL02_1U
 53.3419 -          PIXEL10_C
 53.3420 -          PIXEL11
 53.3421 -          PIXEL12_C
 53.3422 -          if (Diff(cget(8), cget(4)))
 53.3423 -          {
 53.3424 -            PIXEL20_C
 53.3425 -          }
 53.3426 -          else
 53.3427 -          {
 53.3428 -            PIXEL20_2
 53.3429 -          }
 53.3430 -          PIXEL21_C
 53.3431 -          if (Diff(cget(6), cget(8)))
 53.3432 -          {
 53.3433 -            PIXEL22_C
 53.3434 -          }
 53.3435 -          else
 53.3436 -          {
 53.3437 -            PIXEL22_2
 53.3438 -          }
 53.3439 -          break;
 53.3440 -        }
 53.3441 -        case 251:
 53.3442 -        {
 53.3443 -          if (Diff(cget(4), cget(2)))
 53.3444 -          {
 53.3445 -            PIXEL00_C
 53.3446 -            PIXEL01_C
 53.3447 -          }
 53.3448 -          else
 53.3449 -          {
 53.3450 -            PIXEL00_4
 53.3451 -            PIXEL01_3
 53.3452 -          }
 53.3453 -          PIXEL02_1M
 53.3454 -          PIXEL11
 53.3455 -          if (Diff(cget(8), cget(4)))
 53.3456 -          {
 53.3457 -            PIXEL10_C
 53.3458 -            PIXEL20_C
 53.3459 -            PIXEL21_C
 53.3460 -          }
 53.3461 -          else
 53.3462 -          {
 53.3463 -            PIXEL10_3
 53.3464 -            PIXEL20_2
 53.3465 -            PIXEL21_3
 53.3466 -          }
 53.3467 -          if (Diff(cget(6), cget(8)))
 53.3468 -          {
 53.3469 -            PIXEL12_C
 53.3470 -            PIXEL22_C
 53.3471 -          }
 53.3472 -          else
 53.3473 -          {
 53.3474 -            PIXEL12_3
 53.3475 -            PIXEL22_4
 53.3476 -          }
 53.3477 -          break;
 53.3478 -        }
 53.3479 -        case 239:
 53.3480 -        {
 53.3481 -          if (Diff(cget(4), cget(2)))
 53.3482 -          {
 53.3483 -            PIXEL00_C
 53.3484 -          }
 53.3485 -          else
 53.3486 -          {
 53.3487 -            PIXEL00_2
 53.3488 -          }
 53.3489 -          PIXEL01_C
 53.3490 -          PIXEL02_1R
 53.3491 -          PIXEL10_C
 53.3492 -          PIXEL11
 53.3493 -          PIXEL12_1
 53.3494 -          if (Diff(cget(8), cget(4)))
 53.3495 -          {
 53.3496 -            PIXEL20_C
 53.3497 -          }
 53.3498 -          else
 53.3499 -          {
 53.3500 -            PIXEL20_2
 53.3501 -          }
 53.3502 -          PIXEL21_C
 53.3503 -          PIXEL22_1R
 53.3504 -          break;
 53.3505 -        }
 53.3506 -        case 127:
 53.3507 -        {
 53.3508 -          if (Diff(cget(4), cget(2)))
 53.3509 -          {
 53.3510 -            PIXEL00_C
 53.3511 -            PIXEL01_C
 53.3512 -            PIXEL10_C
 53.3513 -          }
 53.3514 -          else
 53.3515 -          {
 53.3516 -            PIXEL00_2
 53.3517 -            PIXEL01_3
 53.3518 -            PIXEL10_3
 53.3519 -          }
 53.3520 -          if (Diff(cget(2), cget(6)))
 53.3521 -          {
 53.3522 -            PIXEL02_C
 53.3523 -            PIXEL12_C
 53.3524 -          }
 53.3525 -          else
 53.3526 -          {
 53.3527 -            PIXEL02_4
 53.3528 -            PIXEL12_3
 53.3529 -          }
 53.3530 -          PIXEL11
 53.3531 -          if (Diff(cget(8), cget(4)))
 53.3532 -          {
 53.3533 -            PIXEL20_C
 53.3534 -            PIXEL21_C
 53.3535 -          }
 53.3536 -          else
 53.3537 -          {
 53.3538 -            PIXEL20_4
 53.3539 -            PIXEL21_3
 53.3540 -          }
 53.3541 -          PIXEL22_1M
 53.3542 -          break;
 53.3543 -        }
 53.3544 -        case 191:
 53.3545 -        {
 53.3546 -          if (Diff(cget(4), cget(2)))
 53.3547 -          {
 53.3548 -            PIXEL00_C
 53.3549 -          }
 53.3550 -          else
 53.3551 -          {
 53.3552 -            PIXEL00_2
 53.3553 -          }
 53.3554 -          PIXEL01_C
 53.3555 -          if (Diff(cget(2), cget(6)))
 53.3556 -          {
 53.3557 -            PIXEL02_C
 53.3558 -          }
 53.3559 -          else
 53.3560 -          {
 53.3561 -            PIXEL02_2
 53.3562 -          }
 53.3563 -          PIXEL10_C
 53.3564 -          PIXEL11
 53.3565 -          PIXEL12_C
 53.3566 -          PIXEL20_1D
 53.3567 -          PIXEL21_1
 53.3568 -          PIXEL22_1D
 53.3569 -          break;
 53.3570 -        }
 53.3571 -        case 223:
 53.3572 -        {
 53.3573 -          if (Diff(cget(4), cget(2)))
 53.3574 -          {
 53.3575 -            PIXEL00_C
 53.3576 -            PIXEL10_C
 53.3577 -          }
 53.3578 -          else
 53.3579 -          {
 53.3580 -            PIXEL00_4
 53.3581 -            PIXEL10_3
 53.3582 -          }
 53.3583 -          if (Diff(cget(2), cget(6)))
 53.3584 -          {
 53.3585 -            PIXEL01_C
 53.3586 -            PIXEL02_C
 53.3587 -            PIXEL12_C
 53.3588 -          }
 53.3589 -          else
 53.3590 -          {
 53.3591 -            PIXEL01_3
 53.3592 -            PIXEL02_2
 53.3593 -            PIXEL12_3
 53.3594 -          }
 53.3595 -          PIXEL11
 53.3596 -          PIXEL20_1M
 53.3597 -          if (Diff(cget(6), cget(8)))
 53.3598 -          {
 53.3599 -            PIXEL21_C
 53.3600 -            PIXEL22_C
 53.3601 -          }
 53.3602 -          else
 53.3603 -          {
 53.3604 -            PIXEL21_3
 53.3605 -            PIXEL22_4
 53.3606 -          }
 53.3607 -          break;
 53.3608 -        }
 53.3609 -        case 247:
 53.3610 -        {
 53.3611 -          PIXEL00_1L
 53.3612 -          PIXEL01_C
 53.3613 -          if (Diff(cget(2), cget(6)))
 53.3614 -          {
 53.3615 -            PIXEL02_C
 53.3616 -          }
 53.3617 -          else
 53.3618 -          {
 53.3619 -            PIXEL02_2
 53.3620 -          }
 53.3621 -          PIXEL10_1
 53.3622 -          PIXEL11
 53.3623 -          PIXEL12_C
 53.3624 -          PIXEL20_1L
 53.3625 -          PIXEL21_C
 53.3626 -          if (Diff(cget(6), cget(8)))
 53.3627 -          {
 53.3628 -            PIXEL22_C
 53.3629 -          }
 53.3630 -          else
 53.3631 -          {
 53.3632 -            PIXEL22_2
 53.3633 -          }
 53.3634 -          break;
 53.3635 -        }
 53.3636 -        case 255:
 53.3637 -        {
 53.3638 -          if (Diff(cget(4), cget(2)))
 53.3639 -          {
 53.3640 -            PIXEL00_C
 53.3641 -          }
 53.3642 -          else
 53.3643 -          {
 53.3644 -            PIXEL00_2
 53.3645 -          }
 53.3646 -          PIXEL01_C
 53.3647 -          if (Diff(cget(2), cget(6)))
 53.3648 -          {
 53.3649 -            PIXEL02_C
 53.3650 -          }
 53.3651 -          else
 53.3652 -          {
 53.3653 -            PIXEL02_2
 53.3654 -          }
 53.3655 -          PIXEL10_C
 53.3656 -          PIXEL11
 53.3657 -          PIXEL12_C
 53.3658 -          if (Diff(cget(8), cget(4)))
 53.3659 -          {
 53.3660 -            PIXEL20_C
 53.3661 -          }
 53.3662 -          else
 53.3663 -          {
 53.3664 -            PIXEL20_2
 53.3665 -          }
 53.3666 -          PIXEL21_C
 53.3667 -          if (Diff(cget(6), cget(8)))
 53.3668 -          {
 53.3669 -            PIXEL22_C
 53.3670 -          }
 53.3671 -          else
 53.3672 -          {
 53.3673 -            PIXEL22_2
 53.3674 -          }
 53.3675 -          break;
 53.3676 -        }
 53.3677 -      }
    54.1 --- a/src/filters/hq_shared32.cpp	Sat Mar 03 10:54:39 2012 -0600
    54.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.3 @@ -1,389 +0,0 @@
    54.4 -#include "../Port.h"
    54.5 -#include "hq_shared32.h"
    54.6 -#include "interp.h"
    54.7 -
    54.8 -const unsigned __int64 reg_blank = 0x0000000000000000;
    54.9 -const unsigned __int64 const7	 = 0x0000000700070007;
   54.10 -const unsigned __int64 treshold	 = 0x0000000000300706;
   54.11 -
   54.12 -void Interp1(unsigned char *pc, unsigned int c1, unsigned int c2)
   54.13 -{
   54.14 -	//*((int*)pc) = (c1*3+c2)/4;
   54.15 -
   54.16 -#ifdef MMX
   54.17 -	__asm
   54.18 -	{
   54.19 -		mov eax, pc
   54.20 -		movd mm1, c1
   54.21 -		movd mm2, c2
   54.22 -		movq mm0, mm1
   54.23 -		pslld mm0, 2
   54.24 -		psubd mm0, mm1
   54.25 -		paddd mm0, mm2
   54.26 -		psrld mm0, 2
   54.27 -		movd    [eax], mm0
   54.28 -		    EMMS
   54.29 -	}
   54.30 -#else
   54.31 -	__asm
   54.32 -	{
   54.33 -		mov eax, pc
   54.34 -		mov edx, c1
   54.35 -		shl edx, 2
   54.36 -		add edx, c2
   54.37 -		sub edx, c1
   54.38 -		shr edx, 2
   54.39 -		mov        [eax], edx
   54.40 -	}
   54.41 -#endif
   54.42 -}
   54.43 -
   54.44 -void Interp2(unsigned char *pc, unsigned int c1, unsigned int c2, unsigned int c3)
   54.45 -{
   54.46 -	//*((int*)pc) = (c1*2+c2+c3)/4;
   54.47 -
   54.48 -#ifdef MMX
   54.49 -	__asm
   54.50 -	{
   54.51 -		mov eax, pc
   54.52 -		movd mm0, c1
   54.53 -		movd mm1, c2
   54.54 -		movd mm2, c3
   54.55 -		pslld mm0, 1
   54.56 -		paddd mm0, mm1
   54.57 -		paddd mm0, mm2
   54.58 -		psrad mm0, 2
   54.59 -		movd [eax], mm0
   54.60 -		    EMMS
   54.61 -	}
   54.62 -#else
   54.63 -	__asm
   54.64 -	{
   54.65 -		mov eax, pc
   54.66 -		mov edx, c1
   54.67 -		shl edx, 1
   54.68 -		add edx, c2
   54.69 -		add edx, c3
   54.70 -		shr edx, 2
   54.71 -		mov        [eax], edx
   54.72 -	}
   54.73 -#endif
   54.74 -}
   54.75 -
   54.76 -void Interp3(unsigned char *pc, unsigned int c1, unsigned int c2)
   54.77 -{
   54.78 -	//*((int*)pc) = (c1*7+c2)/8;
   54.79 -	//*((int*)pc) = ((((c1 & 0x00FF00)*7 + (c2 & 0x00FF00) ) & 0x0007F800) +
   54.80 -	//	            (((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
   54.81 -
   54.82 -#ifdef MMX
   54.83 -	__asm
   54.84 -	{
   54.85 -		mov eax, pc
   54.86 -		movd mm1, c1
   54.87 -		movd mm2, c2
   54.88 -		punpcklbw mm1, reg_blank
   54.89 -		punpcklbw mm2, reg_blank
   54.90 -		pmullw mm1, const7
   54.91 -		paddw mm1, mm2
   54.92 -		psrlw mm1, 3
   54.93 -		packuswb mm1, reg_blank
   54.94 -		    movd       [eax], mm1
   54.95 -		    EMMS
   54.96 -	}
   54.97 -#else
   54.98 -	__asm
   54.99 -	{
  54.100 -		mov eax, c1
  54.101 -		mov ebx, c2
  54.102 -		mov ecx, eax
  54.103 -		shl ecx, 3
  54.104 -		sub ecx, eax
  54.105 -		add ecx, ebx
  54.106 -		shr ecx, 3
  54.107 -		mov eax, pc
  54.108 -		    mov     [eax], ecx
  54.109 -	}
  54.110 -#endif
  54.111 -}
  54.112 -
  54.113 -void Interp4(unsigned char *pc, unsigned int c1, unsigned int c2, unsigned int c3)
  54.114 -{
  54.115 -	//*((int*)pc) = (c1*2+(c2+c3)*7)/16;
  54.116 -	//*((int*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*7 ) & 0x000FF000) +
  54.117 -	//              (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4;
  54.118 -
  54.119 -#ifdef MMX
  54.120 -	__asm
  54.121 -	{
  54.122 -		mov eax, pc
  54.123 -		movd mm1, c1
  54.124 -		movd mm2, c2
  54.125 -		movd mm3, c3
  54.126 -		punpcklbw mm1, reg_blank
  54.127 -		punpcklbw mm2, reg_blank
  54.128 -		punpcklbw mm3, reg_blank
  54.129 -		psllw mm1, 1
  54.130 -		paddw mm2, mm3
  54.131 -		pmullw mm2, const7
  54.132 -		paddw mm1, mm2
  54.133 -		psrlw mm1, 4
  54.134 -		packuswb mm1, reg_blank
  54.135 -		    movd       [eax], mm1
  54.136 -		    EMMS
  54.137 -	}
  54.138 -#else
  54.139 -
  54.140 -	__asm
  54.141 -	{
  54.142 -		mov eax, [c1]
  54.143 -		and     eax, 0FF00h
  54.144 -		shl eax, 1
  54.145 -		mov ecx, [c2]
  54.146 -		and     ecx, 0FF00h
  54.147 -		mov edx, [c3]
  54.148 -		and     edx, 0FF00h
  54.149 -		add ecx, edx
  54.150 -		imul ecx, ecx, 7
  54.151 -		add eax, ecx
  54.152 -		and     eax, 0FF000h
  54.153 -
  54.154 -		mov ebx, [c1]
  54.155 -		and     ebx, 0FF00FFh
  54.156 -		shl ebx, 1
  54.157 -		mov ecx, [c2]
  54.158 -		and     ecx, 0FF00FFh
  54.159 -		mov edx, [c3]
  54.160 -		and     edx, 0FF00FFh
  54.161 -		add ecx, edx
  54.162 -		imul ecx, ecx, 7
  54.163 -		add ebx, ecx
  54.164 -		and     ebx, 0FF00FF0h
  54.165 -
  54.166 -		add eax, ebx
  54.167 -		shr eax, 4
  54.168 -
  54.169 -		mov ebx, pc
  54.170 -		    mov     [ebx], eax
  54.171 -	}
  54.172 -#endif
  54.173 -}
  54.174 -
  54.175 -void Interp5(unsigned char *pc, unsigned int c1, unsigned int c2)
  54.176 -{
  54.177 -	//*((int*)pc) = (c1+c2)/2;
  54.178 -
  54.179 -#ifdef MMX
  54.180 -	__asm
  54.181 -	{
  54.182 -		mov eax, pc
  54.183 -		movd mm0, c1
  54.184 -		movd mm1, c2
  54.185 -		paddd mm0, mm1
  54.186 -		psrad mm0, 1
  54.187 -		movd    [eax], mm0
  54.188 -		    EMMS
  54.189 -	}
  54.190 -#else
  54.191 -	__asm
  54.192 -	{
  54.193 -		mov eax, pc
  54.194 -		mov edx, c1
  54.195 -		add edx, c2
  54.196 -		shr edx, 1
  54.197 -		mov        [eax], edx
  54.198 -	}
  54.199 -#endif
  54.200 -}
  54.201 -
  54.202 -void Interp1_16(unsigned char *pc, unsigned short c1, unsigned short c2)
  54.203 -{
  54.204 -	*((unsigned short *)pc) = interp_16_31(c1, c2);
  54.205 -	//*((int*)pc) = (c1*3+c2)/4;
  54.206 -}
  54.207 -
  54.208 -void Interp2_16(unsigned char *pc, unsigned short c1, unsigned short c2, unsigned short c3)
  54.209 -{
  54.210 -	*((unsigned short *)pc) = interp_16_211(c1, c2, c3);
  54.211 -	//*((int*)pc) = (c1*2+c2+c3)/4;
  54.212 -}
  54.213 -
  54.214 -void Interp3_16(unsigned char *pc, unsigned short c1, unsigned short c2)
  54.215 -{
  54.216 -	*((unsigned short *)pc) = interp_16_71(c1, c2);
  54.217 -//	*((unsigned short*)pc) = (c1*7+c2)/8;
  54.218 -//	*((unsigned short*)pc) = ((((c1 & 0x00FF00)*7 + (c2 & 0x00FF00) ) & 0x0007F800) +
  54.219 -//		            (((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
  54.220 -}
  54.221 -
  54.222 -void Interp4_16(unsigned char *pc, unsigned short c1, unsigned short c2, unsigned short c3)
  54.223 -{
  54.224 -	*((unsigned short *)pc) = interp_16_772(c2, c3, c1);
  54.225 -//	*((unsigned short*)pc) = (c1*2+(c2+c3)*7)/16;
  54.226 -//	*((unsigned short*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*7 ) & 0x000FF000) +
  54.227 -//	              (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4;
  54.228 -}
  54.229 -
  54.230 -void Interp5_16(unsigned char *pc, unsigned short c1, unsigned short c2)
  54.231 -{
  54.232 -	*((unsigned short *)pc) = interp_16_11(c1, c2);
  54.233 -}
  54.234 -
  54.235 -bool Diff(unsigned int c1, unsigned int c2)
  54.236 -{
  54.237 -	unsigned int
  54.238 -	    YUV1 = RGBtoYUV(c1),
  54.239 -	    YUV2 = RGBtoYUV(c2);
  54.240 -
  54.241 -	if (YUV1 == YUV2) return false;  // Save some processing power
  54.242 -
  54.243 -#ifdef MMX
  54.244 -	unsigned int retval;
  54.245 -	__asm
  54.246 -	{
  54.247 -		mov eax, 0x7FFFFFFF
  54.248 -		movd mm7, eax; mm7 = ABS_MASK = 0x7FFFFFFF
  54.249 -
  54.250 -		; Copy source colors in first reg
  54.251 -		movd mm0, YUV1
  54.252 -		movd mm1, YUV2
  54.253 -
  54.254 -		mov eax, 0x00FF0000
  54.255 -		movd mm6, eax; mm6 = Ymask = 0x00FF0000
  54.256 -
  54.257 -		; Calculate color Y difference
  54.258 -		movq mm2, mm0
  54.259 -		movq mm3, mm1
  54.260 -		pand mm2, mm6
  54.261 -		pand mm3, mm6
  54.262 -		psubd mm2, mm3
  54.263 -		pand mm2, mm7
  54.264 -
  54.265 -		mov eax, 0x0000FF00
  54.266 -		movd mm6, eax; mm6 = Umask = 0x0000FF00
  54.267 -
  54.268 -		; Calculate color U difference
  54.269 -		movq mm3, mm0
  54.270 -		movq mm4, mm1
  54.271 -		pand mm3, mm6
  54.272 -		pand mm4, mm6
  54.273 -		psubd mm3, mm4
  54.274 -		pand mm3, mm7
  54.275 -
  54.276 -		mov eax, 0x000000FF
  54.277 -		movd mm6, eax; mm6 = Vmask = 0x000000FF
  54.278 -
  54.279 -		; Calculate color V difference
  54.280 -		movq mm4, mm0
  54.281 -		movq mm5, mm1
  54.282 -		pand mm4, mm6
  54.283 -		pand mm5, mm6
  54.284 -		psubd mm4, mm5
  54.285 -		pand mm4, mm7
  54.286 -
  54.287 -		mov eax, 0x00300000
  54.288 -		movd mm5, eax; mm5 = trY = 0x00300000
  54.289 -		                           mov eax, 0x00000700
  54.290 -		movd mm6, eax; mm6 = trU = 0x00000700
  54.291 -		                           mov eax, 0x00000006
  54.292 -		movd mm7, eax; mm7 = trV = 0x00000006
  54.293 -
  54.294 -		; Compare the results
  54.295 -		pcmpgtd mm2, trY
  54.296 -		pcmpgtd mm3, trU
  54.297 -		pcmpgtd mm4, trV
  54.298 -		por mm2, mm3
  54.299 -		por mm2, mm4
  54.300 -
  54.301 -		movd retval, mm2
  54.302 -
  54.303 -		        EMMS
  54.304 -	}
  54.305 -	return (retval != 0);
  54.306 -#else
  54.307 -	return
  54.308 -	    (abs32((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
  54.309 -	    (abs32((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
  54.310 -	    (abs32((YUV1 & Vmask) - (YUV2 & Vmask)) > trV);
  54.311 -#endif
  54.312 -}
  54.313 -
  54.314 -unsigned int RGBtoYUV(unsigned int c)
  54.315 -{   // Division through 3 slows down the emulation about 10% !!!
  54.316 -#ifdef MMX
  54.317 -	unsigned int retval;
  54.318 -	__asm
  54.319 -	{
  54.320 -		movd mm0, c
  54.321 -		movq mm1, mm0
  54.322 -		movq mm2, mm0; mm0 = mm1 = mm2 = c
  54.323 -
  54.324 -		                                 mov eax, 0x000000FF
  54.325 -		movd mm5, eax; mm5 = REDMASK = 0x000000FF
  54.326 -		                               mov eax, 0x0000FF00
  54.327 -		movd mm6, eax; mm6 = GREENMASK = 0x0000FF00
  54.328 -		                                 mov eax, 0x00FF0000
  54.329 -		movd mm7, eax; mm7 = BLUEMASK = 0x00FF0000
  54.330 -
  54.331 -		                                pand mm0, mm5
  54.332 -		pand mm1, mm6
  54.333 -		pand mm2, mm7; mm0 = R mm1 = G mm2 = B
  54.334 -
  54.335 -		                                     movq mm3, mm0
  54.336 -		paddd mm3, mm1
  54.337 -		paddd mm3, mm2
  54.338 -		;       psrld mm3, 2; mm3 = Y
  54.339 -		;       pslld mm3, 16
  54.340 -		pslld mm3, 14; mm3 = Y << 16
  54.341 -
  54.342 -		                     mov eax, 512
  54.343 -		movd mm7, eax; mm7 = 128 << 2 = 512
  54.344 -
  54.345 -		                                movq mm4, mm0
  54.346 -		psubd mm4, mm2
  54.347 -		;       psrld mm4, 2
  54.348 -		;       paddd mm4, mm7; mm4 = U
  54.349 -		;       pslld mm4, 8; mm4 = U << 8
  54.350 -		                            paddd mm4, mm7
  54.351 -		pslld mm4, 6
  54.352 -
  54.353 -		mov eax, 128
  54.354 -		movd mm7, eax; mm7 = 128
  54.355 -
  54.356 -		                     movq mm5, mm1
  54.357 -		pslld mm5, 1
  54.358 -		psubd mm5, mm0
  54.359 -		psubd mm5, mm2
  54.360 -		psrld mm5, 3
  54.361 -		paddd mm5, mm7; mm5 = V
  54.362 -
  54.363 -		                      paddd mm5, mm4
  54.364 -		paddd mm5, mm3
  54.365 -
  54.366 -		movd retval, mm5
  54.367 -
  54.368 -		EMMS
  54.369 -	}
  54.370 -	return retval;
  54.371 -#else
  54.372 -	unsigned char r, g, b, Y, u, v;
  54.373 -	r = (c & 0x000000FF);
  54.374 -	g = (c & 0x0000FF00) >> 8;
  54.375 -	b = (c & 0x00FF0000) >> 16;
  54.376 -	Y = (r + g + b) >> 2;
  54.377 -	u = 128 + ((r - b) >> 2);
  54.378 -	v = 128 + ((-r + 2 * g - b) >> 3);
  54.379 -	return (Y << 16) + (u << 8) + v;
  54.380 -
  54.381 -	// Extremely High Quality Code
  54.382 -	//unsigned char r, g, b;
  54.383 -	//r = c & 0xFF;
  54.384 -	//g = (c >> 8) & 0xFF;
  54.385 -	//b = (c >> 16) & 0xFF;
  54.386 -	//unsigned char y, u, v;
  54.387 -	//y = (0.256788 * r  +  0.504129 * g  +  0.097906 * b) + 16;
  54.388 -	//u = (-0.148223 * r  -  0.290993 * g  +  0.439216 * b) + 128;
  54.389 -	//v = (0.439216 * r  -  0.367788 * g  -  0.071427 * b) + 128;
  54.390 -	//return (y << 16) + (u << 8) + v;
  54.391 -#endif
  54.392 -}
  54.393 \ No newline at end of file
    55.1 --- a/src/filters/hq_shared32.h	Sat Mar 03 10:54:39 2012 -0600
    55.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.3 @@ -1,31 +0,0 @@
    55.4 -#ifndef VBA_HQ_SHARED32_H
    55.5 -#define VBA_HQ_SHARED32_H
    55.6 -
    55.7 -#if _MSC_VER > 1000
    55.8 -#pragma once
    55.9 -#endif // _MSC_VER > 1000
   55.10 -
   55.11 -#define abs32(value) (value & 0x7FFFFFFF)
   55.12 -#define abs16(value) (value & 0x7FFF)
   55.13 -
   55.14 -const int Ymask = 0x00FF0000;
   55.15 -const int Umask = 0x0000FF00;
   55.16 -const int Vmask = 0x000000FF;
   55.17 -const int trY   = 0x00300000;
   55.18 -const int trU   = 0x00000700;
   55.19 -const int trV   = 0x00000006;
   55.20 -
   55.21 -void Interp1(unsigned char *pc, unsigned int c1, unsigned int c2);
   55.22 -void Interp2(unsigned char *pc, unsigned int c1, unsigned int c2, unsigned int c3);
   55.23 -void Interp3(unsigned char *pc, unsigned int c1, unsigned int c2);
   55.24 -void Interp4(unsigned char *pc, unsigned int c1, unsigned int c2, unsigned int c3);
   55.25 -void Interp5(unsigned char *pc, unsigned int c1, unsigned int c2);
   55.26 -void Interp1_16(unsigned char *pc, unsigned short c1, unsigned short c2);
   55.27 -void Interp2_16(unsigned char *pc, unsigned short c1, unsigned short c2, unsigned short c3);
   55.28 -void Interp3_16(unsigned char *pc, unsigned short c1, unsigned short c2);
   55.29 -void Interp4_16(unsigned char *pc, unsigned short c1, unsigned short c2, unsigned short c3);
   55.30 -void Interp5_16(unsigned char *pc, unsigned short c1, unsigned short c2);
   55.31 -bool Diff(unsigned int c1, unsigned int c2);
   55.32 -unsigned int RGBtoYUV(unsigned int c);
   55.33 -
   55.34 -#endif // VBA_HQ_SHARED32_H
    56.1 --- a/src/filters/interframe.cpp	Sat Mar 03 10:54:39 2012 -0600
    56.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.3 @@ -1,630 +0,0 @@
    56.4 -#include <cstdlib>
    56.5 -#include <cstring>
    56.6 -#include "../Port.h"
    56.7 -
    56.8 -#ifdef MMX
    56.9 -extern "C" bool cpu_mmx;
   56.10 -#endif
   56.11 -
   56.12 -/*
   56.13 - * Thanks to Kawaks' Mr. K for the code
   56.14 -
   56.15 -   Incorporated into vba by Anthony Di Franco
   56.16 - */
   56.17 -
   56.18 -static u8 *frm1 = NULL;
   56.19 -static u8 *frm2 = NULL;
   56.20 -static u8 *frm3 = NULL;
   56.21 -
   56.22 -extern u32 RGB_LOW_BITS_MASK;
   56.23 -extern u32 qRGB_COLOR_MASK[2];
   56.24 -
   56.25 -static void Init()
   56.26 -{
   56.27 -	frm1 = (u8 *)calloc(322 * 242, 4);
   56.28 -	// 1 frame ago
   56.29 -	frm2 = (u8 *)calloc(322 * 242, 4);
   56.30 -	// 2 frames ago
   56.31 -	frm3 = (u8 *)calloc(322 * 242, 4);
   56.32 -	// 3 frames ago
   56.33 -}
   56.34 -
   56.35 -void InterframeCleanup()
   56.36 -{
   56.37 -	if (frm1)
   56.38 -		free(frm1);
   56.39 -	if (frm2)
   56.40 -		free(frm2);
   56.41 -	if (frm3)
   56.42 -		free(frm3);
   56.43 -	frm1 = frm2 = frm3 = NULL;
   56.44 -}
   56.45 -
   56.46 -#ifdef MMX
   56.47 -static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
   56.48 -{
   56.49 -	u16 *src0 = (u16 *)srcPtr;
   56.50 -	u16 *src1 = (u16 *)frm1;
   56.51 -	u16 *src2 = (u16 *)frm2;
   56.52 -	u16 *src3 = (u16 *)frm3;
   56.53 -
   56.54 -	int count = width >> 2;
   56.55 -
   56.56 -	for (int i = 0; i < height; i++)
   56.57 -	{
   56.58 -#ifdef __GNUC__
   56.59 -		asm volatile (
   56.60 -		    "push %4\n"
   56.61 -		    "movq 0(%5), %%mm7\n"       // colorMask
   56.62 -		    "0:\n"
   56.63 -		    "movq 0(%0), %%mm0\n"       // src0
   56.64 -		    "movq 0(%1), %%mm1\n"       // src1
   56.65 -		    "movq 0(%2), %%mm2\n"       // src2
   56.66 -		    "movq 0(%3), %%mm3\n"       // src3
   56.67 -		    "movq %%mm0, 0(%3)\n"       // src3 = src0
   56.68 -		    "movq %%mm0, %%mm4\n"
   56.69 -		    "movq %%mm1, %%mm5\n"
   56.70 -		    "pcmpeqw %%mm2, %%mm5\n"       // src1 == src2 (A)
   56.71 -		    "pcmpeqw %%mm3, %%mm4\n"       // src3 == src0 (B)
   56.72 -		    "por %%mm5, %%mm4\n"       // A | B
   56.73 -		    "movq %%mm2, %%mm5\n"
   56.74 -		    "pcmpeqw %%mm0, %%mm5\n"       // src0 == src2 (C)
   56.75 -		    "pcmpeqw %%mm1, %%mm3\n"       // src1 == src3 (D)
   56.76 -		    "por %%mm3, %%mm5\n"       // C|D
   56.77 -		    "pandn %%mm5, %%mm4\n"       // (!(A|B))&(C|D)
   56.78 -		    "movq %%mm0, %%mm2\n"
   56.79 -		    "pand %%mm7, %%mm2\n"       // color & colorMask
   56.80 -		    "pand %%mm7, %%mm1\n"       // src1 & colorMask
   56.81 -		    "psrlw $1, %%mm2\n"       // (color & colorMask) >> 1 (E)
   56.82 -		    "psrlw $1, %%mm1\n"       // (src & colorMask) >> 1 (F)
   56.83 -		    "paddw %%mm2, %%mm1\n"       // E+F
   56.84 -		    "pand %%mm4, %%mm1\n"       // (E+F) & res
   56.85 -		    "pandn %%mm0, %%mm4\n"       // color& !res
   56.86 -
   56.87 -		    "por %%mm1, %%mm4\n"
   56.88 -		    "movq %%mm4, 0(%0)\n"       // src0 = res
   56.89 -
   56.90 -		    "addl $8, %0\n"
   56.91 -		    "addl $8, %1\n"
   56.92 -		    "addl $8, %2\n"
   56.93 -		    "addl $8, %3\n"
   56.94 -
   56.95 -		    "decl %4\n"
   56.96 -		    "jnz 0b\n"
   56.97 -		    "pop %4\n"
   56.98 -		    "emms\n"
   56.99 -			: "+r" (src0), "+r" (src1), "+r" (src2), "+r" (src3)
  56.100 -			: "r" (count), "r" (qRGB_COLOR_MASK)
  56.101 -		    );
  56.102 -#else
  56.103 -		__asm {
  56.104 -			movq mm7, qword ptr [qRGB_COLOR_MASK];
  56.105 -			mov	 eax, src0;
  56.106 -			mov	 ebx, src1;
  56.107 -			mov	 ecx, src2;
  56.108 -			mov	 edx, src3;
  56.109 -			mov	 edi, count;
  56.110 -label0:
  56.111 -			movq mm0, qword ptr [eax]; // src0
  56.112 -			movq	   mm1, qword ptr [ebx]; // src1
  56.113 -			movq	   mm2, qword ptr [ecx]; // src2
  56.114 -			movq	   mm3, qword ptr [edx]; // src3
  56.115 -			movq qword ptr [edx], mm0; // src3 = src0
  56.116 -			movq	   mm4, mm0;
  56.117 -			movq	   mm5, mm1;
  56.118 -			pcmpeqw	   mm5, mm2; // src1 == src2 (A)
  56.119 -			pcmpeqw	   mm4, mm3; // src3 == src0 (B)
  56.120 -			por		   mm4, mm5; // A | B
  56.121 -			movq	   mm5, mm2;
  56.122 -			pcmpeqw	   mm5, mm0; // src0 == src2 (C)
  56.123 -			pcmpeqw	   mm3, mm1; // src1 == src3 (D)
  56.124 -			por		   mm5, mm3; // C|D
  56.125 -			pandn	   mm4, mm5; // (!(A|B))&(C|D)
  56.126 -			movq	   mm2, mm0;
  56.127 -			pand	   mm2, mm7; // color & colorMask
  56.128 -			pand	   mm1, mm7; // src1 & colorMask
  56.129 -			psrlw	   mm2, 1; // (color & colorMask) >> 1 (E)
  56.130 -			psrlw	   mm1, 1; // (src & colorMask) >> 1 (F)
  56.131 -			paddw	   mm1, mm2; // E+F
  56.132 -			pand	   mm1, mm4; // (E+F) & res
  56.133 -			pandn	   mm4, mm0; // color & !res
  56.134 -
  56.135 -			por		   mm4, mm1;
  56.136 -			movq qword ptr [eax], mm4; // src0 = res
  56.137 -
  56.138 -			add eax, 8;
  56.139 -			add ebx, 8;
  56.140 -			add ecx, 8;
  56.141 -			add edx, 8;
  56.142 -
  56.143 -			dec edi;
  56.144 -			jnz label0;
  56.145 -			mov src0, eax;
  56.146 -			mov src1, ebx;
  56.147 -			mov src2, ecx;
  56.148 -			mov src3, edx;
  56.149 -			emms;
  56.150 -		}
  56.151 -#endif
  56.152 -		src0 += 2;
  56.153 -		src1 += 2;
  56.154 -		src2 += 2;
  56.155 -		src3 += 2;
  56.156 -	}
  56.157 -
  56.158 -	/* Swap buffers around */
  56.159 -	u8 *temp = frm1;
  56.160 -	frm1 = frm3;
  56.161 -	frm3 = frm2;
  56.162 -	frm2 = temp;
  56.163 -}
  56.164 -
  56.165 -#endif
  56.166 -
  56.167 -void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.168 -{
  56.169 -	if (frm1 == NULL)
  56.170 -	{
  56.171 -		Init();
  56.172 -	}
  56.173 -#ifdef MMX
  56.174 -	if (cpu_mmx)
  56.175 -	{
  56.176 -		SmartIB_MMX(srcPtr, srcPitch, width, height);
  56.177 -		return;
  56.178 -	}
  56.179 -#endif
  56.180 -
  56.181 -	u16 colorMask = ~RGB_LOW_BITS_MASK;
  56.182 -
  56.183 -	u16 *src0 = (u16 *)srcPtr;
  56.184 -	u16 *src1 = (u16 *)frm1;
  56.185 -	u16 *src2 = (u16 *)frm2;
  56.186 -	u16 *src3 = (u16 *)frm3;
  56.187 -
  56.188 -	int sPitch = srcPitch >> 1;
  56.189 -
  56.190 -	int pos = 0;
  56.191 -	for (int j = 0; j < height; j++)
  56.192 -		for (int i = 0; i < sPitch; i++)
  56.193 -		{
  56.194 -			u16 color = src0[pos];
  56.195 -			src0[pos] =
  56.196 -			    (src1[pos] != src2[pos]) &&
  56.197 -			    (src3[pos] != color) &&
  56.198 -			    ((color == src2[pos]) || (src1[pos] == src3[pos]))
  56.199 -			    ? (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)) :
  56.200 -			    color;
  56.201 -			src3[pos] = color; /* oldest buffer now holds newest frame */
  56.202 -			pos++;
  56.203 -		}
  56.204 -
  56.205 -	/* Swap buffers around */
  56.206 -	u8 *temp = frm1;
  56.207 -	frm1 = frm3;
  56.208 -	frm3 = frm2;
  56.209 -	frm2 = temp;
  56.210 -}
  56.211 -
  56.212 -#ifdef MMX
  56.213 -static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.214 -{
  56.215 -	u32 *src0 = (u32 *)srcPtr;
  56.216 -	u32 *src1 = (u32 *)frm1;
  56.217 -	u32 *src2 = (u32 *)frm2;
  56.218 -	u32 *src3 = (u32 *)frm3;
  56.219 -
  56.220 -	int count = width >> 1;
  56.221 -
  56.222 -	for (int i = 0; i < height; i++)
  56.223 -	{
  56.224 -#ifdef __GNUC__
  56.225 -		asm volatile (
  56.226 -		    "push %4\n"
  56.227 -		    "movq 0(%5), %%mm7\n"       // colorMask
  56.228 -		    "0:\n"
  56.229 -		    "movq 0(%0), %%mm0\n"       // src0
  56.230 -		    "movq 0(%1), %%mm1\n"       // src1
  56.231 -		    "movq 0(%2), %%mm2\n"       // src2
  56.232 -		    "movq 0(%3), %%mm3\n"       // src3
  56.233 -		    "movq %%mm0, 0(%3)\n"       // src3 = src0
  56.234 -		    "movq %%mm0, %%mm4\n"
  56.235 -		    "movq %%mm1, %%mm5\n"
  56.236 -		    "pcmpeqd %%mm2, %%mm5\n"       // src1 == src2 (A)
  56.237 -		    "pcmpeqd %%mm3, %%mm4\n"       // src3 == src0 (B)
  56.238 -		    "por %%mm5, %%mm4\n"       // A | B
  56.239 -		    "movq %%mm2, %%mm5\n"
  56.240 -		    "pcmpeqd %%mm0, %%mm5\n"       // src0 == src2 (C)
  56.241 -		    "pcmpeqd %%mm1, %%mm3\n"       // src1 == src3 (D)
  56.242 -		    "por %%mm3, %%mm5\n"       // C|D
  56.243 -		    "pandn %%mm5, %%mm4\n"       // (!(A|B))&(C|D)
  56.244 -		    "movq %%mm0, %%mm2\n"
  56.245 -		    "pand %%mm7, %%mm2\n"       // color & colorMask
  56.246 -		    "pand %%mm7, %%mm1\n"       // src1 & colorMask
  56.247 -		    "psrld $1, %%mm2\n"       // (color & colorMask) >> 1 (E)
  56.248 -		    "psrld $1, %%mm1\n"       // (src & colorMask) >> 1 (F)
  56.249 -		    "paddd %%mm2, %%mm1\n"       // E+F
  56.250 -		    "pand %%mm4, %%mm1\n"       // (E+F) & res
  56.251 -		    "pandn %%mm0, %%mm4\n"       // color& !res
  56.252 -
  56.253 -		    "por %%mm1, %%mm4\n"
  56.254 -		    "movq %%mm4, 0(%0)\n"       // src0 = res
  56.255 -
  56.256 -		    "addl $8, %0\n"
  56.257 -		    "addl $8, %1\n"
  56.258 -		    "addl $8, %2\n"
  56.259 -		    "addl $8, %3\n"
  56.260 -
  56.261 -		    "decl %4\n"
  56.262 -		    "jnz 0b\n"
  56.263 -		    "pop %4\n"
  56.264 -		    "emms\n"
  56.265 -			: "+r" (src0), "+r" (src1), "+r" (src2), "+r" (src3)
  56.266 -			: "r" (count), "r" (qRGB_COLOR_MASK)
  56.267 -		    );
  56.268 -#else
  56.269 -		__asm {
  56.270 -			movq mm7, qword ptr [qRGB_COLOR_MASK];
  56.271 -			mov	 eax, src0;
  56.272 -			mov	 ebx, src1;
  56.273 -			mov	 ecx, src2;
  56.274 -			mov	 edx, src3;
  56.275 -			mov	 edi, count;
  56.276 -label0:
  56.277 -			movq mm0, qword ptr [eax]; // src0
  56.278 -			movq	   mm1, qword ptr [ebx]; // src1
  56.279 -			movq	   mm2, qword ptr [ecx]; // src2
  56.280 -			movq	   mm3, qword ptr [edx]; // src3
  56.281 -			movq qword ptr [edx], mm0; // src3 = src0
  56.282 -			movq	   mm4, mm0;
  56.283 -			movq	   mm5, mm1;
  56.284 -			pcmpeqd	   mm5, mm2; // src1 == src2 (A)
  56.285 -			pcmpeqd	   mm4, mm3; // src3 == src0 (B)
  56.286 -			por		   mm4, mm5; // A | B
  56.287 -			movq	   mm5, mm2;
  56.288 -			pcmpeqd	   mm5, mm0; // src0 == src2 (C)
  56.289 -			pcmpeqd	   mm3, mm1; // src1 == src3 (D)
  56.290 -			por		   mm5, mm3; // C|D
  56.291 -			pandn	   mm4, mm5; // (!(A|B))&(C|D)
  56.292 -			movq	   mm2, mm0;
  56.293 -			pand	   mm2, mm7; // color & colorMask
  56.294 -			pand	   mm1, mm7; // src1 & colorMask
  56.295 -			psrld	   mm2, 1; // (color & colorMask) >> 1 (E)
  56.296 -			psrld	   mm1, 1; // (src & colorMask) >> 1 (F)
  56.297 -			paddd	   mm1, mm2; // E+F
  56.298 -			pand	   mm1, mm4; // (E+F) & res
  56.299 -			pandn	   mm4, mm0; // color & !res
  56.300 -
  56.301 -			por		   mm4, mm1;
  56.302 -			movq qword ptr [eax], mm4; // src0 = res
  56.303 -
  56.304 -			add eax, 8;
  56.305 -			add ebx, 8;
  56.306 -			add ecx, 8;
  56.307 -			add edx, 8;
  56.308 -
  56.309 -			dec edi;
  56.310 -			jnz label0;
  56.311 -			mov src0, eax;
  56.312 -			mov src1, ebx;
  56.313 -			mov src2, ecx;
  56.314 -			mov src3, edx;
  56.315 -			emms;
  56.316 -		}
  56.317 -#endif
  56.318 -
  56.319 -		src0++;
  56.320 -		src1++;
  56.321 -		src2++;
  56.322 -		src3++;
  56.323 -	}
  56.324 -	/* Swap buffers around */
  56.325 -	u8 *temp = frm1;
  56.326 -	frm1 = frm3;
  56.327 -	frm3 = frm2;
  56.328 -	frm2 = temp;
  56.329 -}
  56.330 -
  56.331 -#endif
  56.332 -
  56.333 -void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.334 -{
  56.335 -	if (frm1 == NULL)
  56.336 -	{
  56.337 -		Init();
  56.338 -	}
  56.339 -#ifdef MMX
  56.340 -	if (cpu_mmx)
  56.341 -	{
  56.342 -		SmartIB32_MMX(srcPtr, srcPitch, width, height);
  56.343 -		return;
  56.344 -	}
  56.345 -#endif
  56.346 -
  56.347 -	u32 *src0 = (u32 *)srcPtr;
  56.348 -	u32 *src1 = (u32 *)frm1;
  56.349 -	u32 *src2 = (u32 *)frm2;
  56.350 -	u32 *src3 = (u32 *)frm3;
  56.351 -
  56.352 -	u32 colorMask = 0xfefefe;
  56.353 -
  56.354 -	int sPitch = srcPitch >> 2;
  56.355 -	int pos	   = 0;
  56.356 -
  56.357 -	for (int j = 0; j < height; j++)
  56.358 -		for (int i = 0; i < sPitch; i++)
  56.359 -		{
  56.360 -			u32 color = src0[pos];
  56.361 -			src0[pos] =
  56.362 -			    (src1[pos] != src2[pos]) &&
  56.363 -			    (src3[pos] != color) &&
  56.364 -			    ((color == src2[pos]) || (src1[pos] == src3[pos]))
  56.365 -			    ? (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)) :
  56.366 -			    color;
  56.367 -			src3[pos] = color; /* oldest buffer now holds newest frame */
  56.368 -			pos++;
  56.369 -		}
  56.370 -
  56.371 -	/* Swap buffers around */
  56.372 -	u8 *temp = frm1;
  56.373 -	frm1 = frm3;
  56.374 -	frm3 = frm2;
  56.375 -	frm2 = temp;
  56.376 -}
  56.377 -
  56.378 -#ifdef MMX
  56.379 -static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.380 -{
  56.381 -	u16 *src0 = (u16 *)srcPtr;
  56.382 -	u16 *src1 = (u16 *)frm1;
  56.383 -
  56.384 -	int count = width >> 2;
  56.385 -
  56.386 -	for (int i = 0; i < height; i++)
  56.387 -	{
  56.388 -#ifdef __GNUC__
  56.389 -		asm volatile (
  56.390 -		    "push %2\n"
  56.391 -		    "movq 0(%3), %%mm7\n"       // colorMask
  56.392 -		    "0:\n"
  56.393 -		    "movq 0(%0), %%mm0\n"       // src0
  56.394 -		    "movq 0(%1), %%mm1\n"       // src1
  56.395 -		    "movq %%mm0, 0(%1)\n"       // src1 = src0
  56.396 -		    "pand %%mm7, %%mm0\n"       // color & colorMask
  56.397 -		    "pand %%mm7, %%mm1\n"       // src1 & colorMask
  56.398 -		    "psrlw $1, %%mm0\n"       // (color & colorMask) >> 1 (E)
  56.399 -		    "psrlw $1, %%mm1\n"       // (src & colorMask) >> 1 (F)
  56.400 -		    "paddw %%mm1, %%mm0\n"       // E+F
  56.401 -
  56.402 -		    "movq %%mm0, 0(%0)\n"       // src0 = res
  56.403 -
  56.404 -		    "addl $8, %0\n"
  56.405 -		    "addl $8, %1\n"
  56.406 -
  56.407 -		    "decl %2\n"
  56.408 -		    "jnz 0b\n"
  56.409 -		    "pop %2\n"
  56.410 -		    "emms\n"
  56.411 -			: "+r" (src0), "+r" (src1)
  56.412 -			: "r" (count), "r" (qRGB_COLOR_MASK)
  56.413 -		    );
  56.414 -#else
  56.415 -		__asm {
  56.416 -			movq mm7, qword ptr [qRGB_COLOR_MASK];
  56.417 -			mov	 eax, src0;
  56.418 -			mov	 ebx, src1;
  56.419 -			mov	 edi, count;
  56.420 -label0:
  56.421 -			movq mm0, qword ptr [eax]; // src0
  56.422 -			movq	   mm1, qword ptr [ebx]; // src1
  56.423 -			movq qword ptr [ebx], mm0; // src1 = src0
  56.424 -			pand	   mm0, mm7; // color & colorMask
  56.425 -			pand	   mm1, mm7; // src1 & colorMask
  56.426 -			psrlw	   mm0, 1; // (color & colorMask) >> 1 (E)
  56.427 -			psrlw	   mm1, 1; // (src & colorMask) >> 1 (F)
  56.428 -			paddw	   mm0, mm1; // E+F
  56.429 -
  56.430 -			movq qword ptr [eax], mm0; // src0 = res
  56.431 -
  56.432 -			add eax, 8;
  56.433 -			add ebx, 8;
  56.434 -
  56.435 -			dec edi;
  56.436 -			jnz label0;
  56.437 -			mov src0, eax;
  56.438 -			mov src1, ebx;
  56.439 -			emms;
  56.440 -		}
  56.441 -#endif
  56.442 -		src0 += 2;
  56.443 -		src1 += 2;
  56.444 -	}
  56.445 -}
  56.446 -
  56.447 -#endif
  56.448 -
  56.449 -void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.450 -{
  56.451 -	if (frm1 == NULL)
  56.452 -	{
  56.453 -		Init();
  56.454 -	}
  56.455 -
  56.456 -#ifdef MMX
  56.457 -	if (cpu_mmx)
  56.458 -	{
  56.459 -		MotionBlurIB_MMX(srcPtr, srcPitch, width, height);
  56.460 -		return;
  56.461 -	}
  56.462 -#endif
  56.463 -
  56.464 -	u16 colorMask = ~RGB_LOW_BITS_MASK;
  56.465 -
  56.466 -	u16 *src0 = (u16 *)srcPtr;
  56.467 -	u16 *src1 = (u16 *)frm1;
  56.468 -
  56.469 -	int sPitch = srcPitch >> 1;
  56.470 -
  56.471 -	int pos = 0;
  56.472 -	for (int j = 0; j < height; j++)
  56.473 -		for (int i = 0; i < sPitch; i++)
  56.474 -		{
  56.475 -			u16 color = src0[pos];
  56.476 -			src0[pos] =
  56.477 -			    (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1));
  56.478 -			src1[pos] = color;
  56.479 -			pos++;
  56.480 -		}
  56.481 -}
  56.482 -
  56.483 -#ifdef MMX
  56.484 -static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.485 -{
  56.486 -	u32 *src0 = (u32 *)srcPtr;
  56.487 -	u32 *src1 = (u32 *)frm1;
  56.488 -
  56.489 -	int count = width >> 1;
  56.490 -
  56.491 -	for (int i = 0; i < height; i++)
  56.492 -	{
  56.493 -#ifdef __GNUC__
  56.494 -		asm volatile (
  56.495 -		    "push %2\n"
  56.496 -		    "movq 0(%3), %%mm7\n"       // colorMask
  56.497 -		    "0:\n"
  56.498 -		    "movq 0(%0), %%mm0\n"       // src0
  56.499 -		    "movq 0(%1), %%mm1\n"       // src1
  56.500 -		    "movq %%mm0, 0(%1)\n"       // src1 = src0
  56.501 -		    "pand %%mm7, %%mm0\n"       // color & colorMask
  56.502 -		    "pand %%mm7, %%mm1\n"       // src1 & colorMask
  56.503 -		    "psrld $1, %%mm0\n"       // (color & colorMask) >> 1 (E)
  56.504 -		    "psrld $1, %%mm1\n"       // (src & colorMask) >> 1 (F)
  56.505 -		    "paddd %%mm1, %%mm0\n"       // E+F
  56.506 -
  56.507 -		    "movq %%mm0, 0(%0)\n"       // src0 = res
  56.508 -
  56.509 -		    "addl $8, %0\n"
  56.510 -		    "addl $8, %1\n"
  56.511 -
  56.512 -		    "decl %2\n"
  56.513 -		    "jnz 0b\n"
  56.514 -		    "pop %2\n"
  56.515 -		    "emms\n"
  56.516 -			: "+r" (src0), "+r" (src1)
  56.517 -			: "r" (count), "r" (qRGB_COLOR_MASK)
  56.518 -		    );
  56.519 -#else
  56.520 -		__asm {
  56.521 -			movq mm7, qword ptr [qRGB_COLOR_MASK];
  56.522 -			mov	 eax, src0;
  56.523 -			mov	 ebx, src1;
  56.524 -			mov	 edi, count;
  56.525 -label0:
  56.526 -			movq mm0, qword ptr [eax]; // src0
  56.527 -			movq	   mm1, qword ptr [ebx]; // src1
  56.528 -			movq qword ptr [ebx], mm0; // src1 = src0
  56.529 -			pand	   mm0, mm7; // color & colorMask
  56.530 -			pand	   mm1, mm7; // src1 & colorMask
  56.531 -			psrld	   mm0, 1; // (color & colorMask) >> 1 (E)
  56.532 -			psrld	   mm1, 1; // (src & colorMask) >> 1 (F)
  56.533 -			paddd	   mm0, mm1; // E+F
  56.534 -
  56.535 -			movq qword ptr [eax], mm0; // src0 = res
  56.536 -
  56.537 -			add eax, 8;
  56.538 -			add ebx, 8;
  56.539 -
  56.540 -			dec edi;
  56.541 -			jnz label0;
  56.542 -			mov src0, eax;
  56.543 -			mov src1, ebx;
  56.544 -			emms;
  56.545 -		}
  56.546 -#endif
  56.547 -		src0++;
  56.548 -		src1++;
  56.549 -	}
  56.550 -}
  56.551 -
  56.552 -#endif
  56.553 -
  56.554 -void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.555 -{
  56.556 -	if (frm1 == NULL)
  56.557 -	{
  56.558 -		Init();
  56.559 -	}
  56.560 -
  56.561 -#ifdef MMX
  56.562 -	if (cpu_mmx)
  56.563 -	{
  56.564 -		MotionBlurIB32_MMX(srcPtr, srcPitch, width, height);
  56.565 -		return;
  56.566 -	}
  56.567 -#endif
  56.568 -
  56.569 -	u32 *src0 = (u32 *)srcPtr;
  56.570 -	u32 *src1 = (u32 *)frm1;
  56.571 -
  56.572 -	u32 colorMask = 0xfefefe;
  56.573 -
  56.574 -	int sPitch = srcPitch >> 2;
  56.575 -	int pos	   = 0;
  56.576 -
  56.577 -	for (int j = 0; j < height; j++)
  56.578 -		for (int i = 0; i < sPitch; i++)
  56.579 -		{
  56.580 -			u32 color = src0[pos];
  56.581 -			src0[pos] = (((color & colorMask) >> 1) +
  56.582 -			             ((src1[pos] & colorMask) >> 1));
  56.583 -			src1[pos] = color;
  56.584 -			pos++;
  56.585 -		}
  56.586 -}
  56.587 -
  56.588 -static int count = 0;
  56.589 -
  56.590 -void InterlaceIB(u8 *srcPtr, u32 srcPitch, int width, int height)
  56.591 -{
  56.592 -	if (frm1 == NULL)
  56.593 -	{
  56.594 -		Init();
  56.595 -	}
  56.596 -
  56.597 -	u16 colorMask = ~RGB_LOW_BITS_MASK;
  56.598 -
  56.599 -	u16 *src0 = (u16 *)srcPtr;
  56.600 -	u16 *src1 = (u16 *)frm1;
  56.601 -
  56.602 -	int sPitch = srcPitch >> 1;
  56.603 -
  56.604 -	int pos = 0;
  56.605 -	for (int j = 0; j < height; j++)
  56.606 -	{
  56.607 -		bool render = count ? (j & 1) != 0 : (j & 1) == 0;
  56.608 -		if (render)
  56.609 -		{
  56.610 -			for (int i = 0; i < sPitch; i++)
  56.611 -			{
  56.612 -				u16 color = src0[pos];
  56.613 -				src0[pos] =
  56.614 -				    (((color & colorMask) >> 1) + ((((src1[pos] & colorMask) >> 1) & colorMask) >> 1));
  56.615 -				src1[pos] = color;
  56.616 -				pos++;
  56.617 -			}
  56.618 -		}
  56.619 -		else
  56.620 -		{
  56.621 -			for (int i = 0; i < sPitch; i++)
  56.622 -			{
  56.623 -				u16 color = src0[pos];
  56.624 -				src0[pos] =
  56.625 -				    (((((color & colorMask) >> 1) & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1));
  56.626 -				src1[pos] = color;
  56.627 -				pos++;
  56.628 -			}
  56.629 -		}
  56.630 -	}
  56.631 -	count = count ^ 1;
  56.632 -}
  56.633 -
    57.1 --- a/src/filters/interp.h	Sat Mar 03 10:54:39 2012 -0600
    57.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.3 @@ -1,351 +0,0 @@
    57.4 -/*
    57.5 - * This file is part of the Advance project.
    57.6 - *
    57.7 - * Copyright (C) 2003 Andrea Mazzoleni
    57.8 - *
    57.9 - * This program is free software; you can redistribute it and/or modify
   57.10 - * it under the terms of the GNU General Public License as published by
   57.11 - * the Free Software Foundation; either version 2 of the License, or
   57.12 - * (at your option) any later version.
   57.13 - *
   57.14 - * This program is distributed in the hope that it will be useful,
   57.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   57.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   57.17 - * GNU General Public License for more details.
   57.18 - *
   57.19 - * You should have received a copy of the GNU General Public License
   57.20 - * along with this program; if not, write to the Free Software
   57.21 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   57.22 - *
   57.23 - * In addition, as a special exception, Andrea Mazzoleni
   57.24 - * gives permission to link the code of this program with
   57.25 - * the MAME library (or with modified versions of MAME that use the
   57.26 - * same license as MAME), and distribute linked combinations including
   57.27 - * the two.  You must obey the GNU General Public License in all
   57.28 - * respects for all of the code used other than MAME.  If you modify
   57.29 - * this file, you may extend this exception to your version of the
   57.30 - * file, but you are not obligated to do so.  If you do not wish to
   57.31 - * do so, delete this exception statement from your version.
   57.32 - */
   57.33 -
   57.34 -#ifndef __INTERP_H
   57.35 -#define __INTERP_H
   57.36 -
   57.37 -/***************************************************************************/
   57.38 -/* Basic types */
   57.39 -
   57.40 -/***************************************************************************/
   57.41 -/* interpolation */
   57.42 -
   57.43 -extern unsigned interp_mask[2];
   57.44 -extern unsigned interp_bits_per_pixel;
   57.45 -
   57.46 -#define INTERP_16_MASK_1(v) (v & interp_mask[0])
   57.47 -#define INTERP_16_MASK_2(v) (v & interp_mask[1])
   57.48 -
   57.49 -static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
   57.50 -{
   57.51 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8)
   57.52 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8);
   57.53 -}
   57.54 -
   57.55 -static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
   57.56 -{
   57.57 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8)
   57.58 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8);
   57.59 -}
   57.60 -
   57.61 -static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
   57.62 -{
   57.63 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8)
   57.64 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8);
   57.65 -}
   57.66 -
   57.67 -static inline u16 interp_16_71(u16 p1, u16 p2)
   57.68 -{
   57.69 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8)
   57.70 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8);
   57.71 -}
   57.72 -
   57.73 -static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
   57.74 -{
   57.75 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4)
   57.76 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4);
   57.77 -}
   57.78 -
   57.79 -static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
   57.80 -{
   57.81 -  return INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16)
   57.82 -    | INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16);
   57.83 -}
   57.84 -
   57.85 -static inline u16 interp_16_11(u16 p1, u16 p2)
   57.86 -{
   57.87 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2)
   57.88 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2);
   57.89 -}
   57.90 -
   57.91 -static inline u16 interp_16_31(u16 p1, u16 p2)
   57.92 -{
   57.93 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4)
   57.94 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4);
   57.95 -}
   57.96 -
   57.97 -static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
   57.98 -{
   57.99 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16)
  57.100 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16);
  57.101 -}
  57.102 -
  57.103 -static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
  57.104 -{
  57.105 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8)
  57.106 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8);
  57.107 -}
  57.108 -
  57.109 -static inline u16 interp_16_53(u16 p1, u16 p2)
  57.110 -{
  57.111 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8)
  57.112 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8);
  57.113 -}
  57.114 -
  57.115 -static inline u16 interp_16_151(u16 p1, u16 p2)
  57.116 -{
  57.117 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16)
  57.118 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16);
  57.119 -}
  57.120 -
  57.121 -static inline u16 interp_16_97(u16 p1, u16 p2)
  57.122 -{
  57.123 -  return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16)
  57.124 -    | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16);
  57.125 -}
  57.126 -
  57.127 -#define INTERP_32_MASK_1(v) (v & 0xFF00FF)
  57.128 -#define INTERP_32_MASK_2(v) (v & 0x00FF00)
  57.129 -
  57.130 -static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3)
  57.131 -{
  57.132 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8)
  57.133 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8);
  57.134 -}
  57.135 -
  57.136 -static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3)
  57.137 -{
  57.138 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8)
  57.139 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8);
  57.140 -}
  57.141 -
  57.142 -static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3)
  57.143 -{
  57.144 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4)
  57.145 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4);
  57.146 -}
  57.147 -
  57.148 -static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3)
  57.149 -{
  57.150 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8)
  57.151 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8);
  57.152 -}
  57.153 -
  57.154 -static inline u32 interp_32_71(u32 p1, u32 p2)
  57.155 -{
  57.156 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8)
  57.157 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8);
  57.158 -}
  57.159 -
  57.160 -static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3)
  57.161 -{
  57.162 -  return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16)
  57.163 -    | INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16);
  57.164 -}
  57.165 -
  57.166 -static inline u32 interp_32_11(u32 p1, u32 p2)
  57.167 -{
  57.168 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2)
  57.169 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2);
  57.170 -}
  57.171 -
  57.172 -static inline u32 interp_32_31(u32 p1, u32 p2)
  57.173 -{
  57.174 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4)
  57.175 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4);
  57.176 -}
  57.177 -
  57.178 -static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3)
  57.179 -{
  57.180 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16)
  57.181 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16);
  57.182 -}
  57.183 -
  57.184 -static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3)
  57.185 -{
  57.186 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8)
  57.187 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8);
  57.188 -}
  57.189 -
  57.190 -static inline u32 interp_32_53(u32 p1, u32 p2)
  57.191 -{
  57.192 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8)
  57.193 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8);
  57.194 -}
  57.195 -
  57.196 -static inline u32 interp_32_151(u32 p1, u32 p2)
  57.197 -{
  57.198 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16)
  57.199 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16);
  57.200 -}
  57.201 -
  57.202 -static inline u32 interp_32_97(u32 p1, u32 p2)
  57.203 -{
  57.204 -  return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16)
  57.205 -    | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16);
  57.206 -}
  57.207 -
  57.208 -/***************************************************************************/
  57.209 -/* diff */
  57.210 -
  57.211 -#define INTERP_Y_LIMIT (0x30*4)
  57.212 -#define INTERP_U_LIMIT (0x07*4)
  57.213 -#define INTERP_V_LIMIT (0x06*8)
  57.214 -
  57.215 -static int interp_16_diff(u16 p1, u16 p2)
  57.216 -{
  57.217 -  int r, g, b;
  57.218 -  int y, u, v;
  57.219 -
  57.220 -  if (p1 == p2)
  57.221 -    return 0;
  57.222 -
  57.223 -  if (interp_bits_per_pixel == 16) {
  57.224 -    b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
  57.225 -    g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3;
  57.226 -    r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
  57.227 -  } else {
  57.228 -    b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
  57.229 -    g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2;
  57.230 -    r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7;
  57.231 -  }
  57.232 -
  57.233 -  y = r + g + b;
  57.234 -  u = r - b;
  57.235 -  v = -r + 2*g - b;
  57.236 -
  57.237 -  if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
  57.238 -    return 1;
  57.239 -
  57.240 -  if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
  57.241 -    return 1;
  57.242 -
  57.243 -  if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
  57.244 -    return 1;
  57.245 -
  57.246 -return 0;
  57.247 -}
  57.248 -
  57.249 -static int interp_32_diff(u32 p1, u32 p2)
  57.250 -{
  57.251 -  int r, g, b;
  57.252 -  int y, u, v;
  57.253 -
  57.254 -  if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8))
  57.255 -    return 0;
  57.256 -
  57.257 -  b = (int)((p1 & 0xFF) - (p2 & 0xFF));
  57.258 -  g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8;
  57.259 -  r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16;
  57.260 -
  57.261 -  y = r + g + b;
  57.262 -  u = r - b;
  57.263 -  v = -r + 2*g - b;
  57.264 -
  57.265 -  if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
  57.266 -    return 1;
  57.267 -
  57.268 -  if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
  57.269 -    return 1;
  57.270 -
  57.271 -  if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
  57.272 -    return 1;
  57.273 -
  57.274 -  return 0;
  57.275 -}
  57.276 -
  57.277 -
  57.278 -#define INTERP_LIMIT2 (96000)
  57.279 -#define ABS(x) ((x) < 0 ? -(x) : (x))
  57.280 -#define MAX(x,y) ((x) > (y) ? (x) : (y))
  57.281 -#define MIN(x,y) ((x) < (y) ? (x) : (y))
  57.282 -
  57.283 -static int interp_16_diff2(u16 p1, u16 p2)
  57.284 -{
  57.285 -  int r, g, b;
  57.286 -  int y, u, v;
  57.287 -
  57.288 -  if ((p1 & 0xF79E) == (p2 & 0xF79E))
  57.289 -    return 0;
  57.290 -
  57.291 -  if (interp_bits_per_pixel == 16) {
  57.292 -    b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
  57.293 -    g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3;
  57.294 -    r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
  57.295 -  } else {
  57.296 -    b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
  57.297 -    g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2;
  57.298 -    r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7;
  57.299 -  }
  57.300 -
  57.301 -//  yb =  30*r + 58*g + 12*b;
  57.302 -  y =  33*r + 36*g + 31*b;
  57.303 -  u = -14*r - 29*g + 44*b; 
  57.304 -  v =  62*r - 51*g - 10*b;
  57.305 -
  57.306 -  if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2)
  57.307 -    return 1;
  57.308 -  return 0;
  57.309 -}
  57.310 -
  57.311 -static int interp_32_diff2(u32 p1, u32 p2)
  57.312 -{
  57.313 -  int r, g, b;
  57.314 -  int y, u, v;
  57.315 -
  57.316 -  if ((p1 & 0xF0F0F0) == (p2 & 0xF0F0F0))
  57.317 -    return 0;
  57.318 -
  57.319 -  b = (int)((p1 & 0xF8) - (p2 & 0xF8));
  57.320 -  g = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
  57.321 -  r = (int)((p1 & 0xF80000) - (p2 & 0xF80000)) >> 16;
  57.322 -
  57.323 -//  y =  30*r + 58*g + 12*b;
  57.324 -  y =  33*r + 36*g + 31*b;
  57.325 -  u = -14*r - 29*g + 44*b; 
  57.326 -  v =  62*r - 51*g - 10*b;
  57.327 -
  57.328 -  if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2)
  57.329 -    return 1;
  57.330 -
  57.331 -  return 0;
  57.332 -}
  57.333 -
  57.334 -static void interp_set(unsigned bits_per_pixel)
  57.335 -{
  57.336 -  interp_bits_per_pixel = bits_per_pixel;
  57.337 -
  57.338 -  switch (bits_per_pixel) {
  57.339 -  case 15 :
  57.340 -    interp_mask[0] = 0x7C1F;
  57.341 -    interp_mask[1] = 0x03E0;
  57.342 -    break;
  57.343 -  case 16 :
  57.344 -    interp_mask[0] = 0xF81F;
  57.345 -    interp_mask[1] = 0x07E0;
  57.346 -    break;
  57.347 -  case 32 :
  57.348 -    interp_mask[0] = 0xFF00FF;
  57.349 -    interp_mask[1] = 0x00FF00;
  57.350 -    break;
  57.351 -  }
  57.352 -}
  57.353 -
  57.354 -#endif
    58.1 --- a/src/filters/lq2x.h	Sat Mar 03 10:54:39 2012 -0600
    58.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.3 @@ -1,1284 +0,0 @@
    58.4 -case 0 : 
    58.5 -case 2 : 
    58.6 -case 4 : 
    58.7 -case 6 : 
    58.8 -case 8 : 
    58.9 -case 12 : 
   58.10 -case 16 : 
   58.11 -case 20 : 
   58.12 -case 24 : 
   58.13 -case 28 : 
   58.14 -case 32 : 
   58.15 -case 34 : 
   58.16 -case 36 : 
   58.17 -case 38 : 
   58.18 -case 40 : 
   58.19 -case 44 : 
   58.20 -case 48 : 
   58.21 -case 52 : 
   58.22 -case 56 : 
   58.23 -case 60 : 
   58.24 -case 64 : 
   58.25 -case 66 : 
   58.26 -case 68 : 
   58.27 -case 70 : 
   58.28 -case 96 : 
   58.29 -case 98 : 
   58.30 -case 100 : 
   58.31 -case 102 : 
   58.32 -case 128 : 
   58.33 -case 130 : 
   58.34 -case 132 : 
   58.35 -case 134 : 
   58.36 -case 136 : 
   58.37 -case 140 : 
   58.38 -case 144 : 
   58.39 -case 148 : 
   58.40 -case 152 : 
   58.41 -case 156 : 
   58.42 -case 160 : 
   58.43 -case 162 : 
   58.44 -case 164 : 
   58.45 -case 166 : 
   58.46 -case 168 : 
   58.47 -case 172 : 
   58.48 -case 176 : 
   58.49 -case 180 : 
   58.50 -case 184 : 
   58.51 -case 188 : 
   58.52 -case 192 : 
   58.53 -case 194 : 
   58.54 -case 196 : 
   58.55 -case 198 : 
   58.56 -case 224 : 
   58.57 -case 226 : 
   58.58 -case 228 : 
   58.59 -case 230 : 
   58.60 -{
   58.61 -  P0 = IC(0);
   58.62 -  P1 = IC(0);
   58.63 -  P2 = IC(0);
   58.64 -  P3 = IC(0);
   58.65 -} break;
   58.66 -case 1 : 
   58.67 -case 5 : 
   58.68 -case 9 : 
   58.69 -case 13 : 
   58.70 -case 17 : 
   58.71 -case 21 : 
   58.72 -case 25 : 
   58.73 -case 29 : 
   58.74 -case 33 : 
   58.75 -case 37 : 
   58.76 -case 41 : 
   58.77 -case 45 : 
   58.78 -case 49 : 
   58.79 -case 53 : 
   58.80 -case 57 : 
   58.81 -case 61 : 
   58.82 -case 65 : 
   58.83 -case 69 : 
   58.84 -case 97 : 
   58.85 -case 101 : 
   58.86 -case 129 : 
   58.87 -case 133 : 
   58.88 -case 137 : 
   58.89 -case 141 : 
   58.90 -case 145 : 
   58.91 -case 149 : 
   58.92 -case 153 : 
   58.93 -case 157 : 
   58.94 -case 161 : 
   58.95 -case 165 : 
   58.96 -case 169 : 
   58.97 -case 173 : 
   58.98 -case 177 : 
   58.99 -case 181 : 
  58.100 -case 185 : 
  58.101 -case 189 : 
  58.102 -case 193 : 
  58.103 -case 197 : 
  58.104 -case 225 : 
  58.105 -case 229 : 
  58.106 -{
  58.107 -  P0 = IC(1);
  58.108 -  P1 = IC(1);
  58.109 -  P2 = IC(1);
  58.110 -  P3 = IC(1);
  58.111 -} break;
  58.112 -case 3 : 
  58.113 -case 35 : 
  58.114 -case 67 : 
  58.115 -case 99 : 
  58.116 -case 131 : 
  58.117 -case 163 : 
  58.118 -case 195 : 
  58.119 -case 227 : 
  58.120 -{
  58.121 -  P0 = IC(2);
  58.122 -  P1 = IC(2);
  58.123 -  P2 = IC(2);
  58.124 -  P3 = IC(2);
  58.125 -} break;
  58.126 -case 7 : 
  58.127 -case 39 : 
  58.128 -case 71 : 
  58.129 -case 103 : 
  58.130 -case 135 : 
  58.131 -case 167 : 
  58.132 -case 199 : 
  58.133 -case 231 : 
  58.134 -{
  58.135 -  P0 = IC(3);
  58.136 -  P1 = IC(3);
  58.137 -  P2 = IC(3);
  58.138 -  P3 = IC(3);
  58.139 -} break;
  58.140 -case 10 : 
  58.141 -case 138 : 
  58.142 -{
  58.143 -  P1 = IC(0);
  58.144 -  P2 = IC(0);
  58.145 -  P3 = IC(0);
  58.146 -  if (MUL) {
  58.147 -    P0 = IC(0);
  58.148 -  } else {
  58.149 -    P0 = I211(0, 1, 3);
  58.150 -  }
  58.151 -} break;
  58.152 -case 11 : 
  58.153 -case 27 : 
  58.154 -case 75 : 
  58.155 -case 139 : 
  58.156 -case 155 : 
  58.157 -case 203 : 
  58.158 -{
  58.159 -  P1 = IC(2);
  58.160 -  P2 = IC(2);
  58.161 -  P3 = IC(2);
  58.162 -  if (MUL) {
  58.163 -    P0 = IC(2);
  58.164 -  } else {
  58.165 -    P0 = I211(2, 1, 3);
  58.166 -  }
  58.167 -} break;
  58.168 -case 14 : 
  58.169 -case 142 : 
  58.170 -{
  58.171 -  P2 = IC(0);
  58.172 -  P3 = IC(0);
  58.173 -  if (MUL) {
  58.174 -    P0 = IC(0);
  58.175 -    P1 = IC(0);
  58.176 -  } else {
  58.177 -    P0 = I332(1, 3, 0);
  58.178 -    P1 = I31(0, 1);
  58.179 -  }
  58.180 -} break;
  58.181 -case 15 : 
  58.182 -case 143 : 
  58.183 -case 207 : 
  58.184 -{
  58.185 -  P2 = IC(4);
  58.186 -  P3 = IC(4);
  58.187 -  if (MUL) {
  58.188 -    P0 = IC(4);
  58.189 -    P1 = IC(4);
  58.190 -  } else {
  58.191 -    P0 = I332(1, 3, 4);
  58.192 -    P1 = I31(4, 1);
  58.193 -  }
  58.194 -} break;
  58.195 -case 18 : 
  58.196 -case 22 : 
  58.197 -case 30 : 
  58.198 -case 50 : 
  58.199 -case 54 : 
  58.200 -case 62 : 
  58.201 -case 86 : 
  58.202 -case 118 : 
  58.203 -{
  58.204 -  P0 = IC(0);
  58.205 -  P2 = IC(0);
  58.206 -  P3 = IC(0);
  58.207 -  if (MUR) {
  58.208 -    P1 = IC(0);
  58.209 -  } else {
  58.210 -    P1 = I211(0, 1, 5);
  58.211 -  }
  58.212 -} break;
  58.213 -case 19 : 
  58.214 -case 51 : 
  58.215 -{
  58.216 -  P2 = IC(2);
  58.217 -  P3 = IC(2);
  58.218 -  if (MUR) {
  58.219 -    P0 = IC(2);
  58.220 -    P1 = IC(2);
  58.221 -  } else {
  58.222 -    P0 = I31(2, 1);
  58.223 -    P1 = I332(1, 5, 2);
  58.224 -  }
  58.225 -} break;
  58.226 -case 23 : 
  58.227 -case 55 : 
  58.228 -case 119 : 
  58.229 -{
  58.230 -  P2 = IC(3);
  58.231 -  P3 = IC(3);
  58.232 -  if (MUR) {
  58.233 -    P0 = IC(3);
  58.234 -    P1 = IC(3);
  58.235 -  } else {
  58.236 -    P0 = I31(3, 1);
  58.237 -    P1 = I332(1, 5, 3);
  58.238 -  }
  58.239 -} break;
  58.240 -case 26 : 
  58.241 -{
  58.242 -  P2 = IC(0);
  58.243 -  P3 = IC(0);
  58.244 -  if (MUL) {
  58.245 -    P0 = IC(0);
  58.246 -  } else {
  58.247 -    P0 = I211(0, 1, 3);
  58.248 -  }
  58.249 -  if (MUR) {
  58.250 -    P1 = IC(0);
  58.251 -  } else {
  58.252 -    P1 = I211(0, 1, 5);
  58.253 -  }
  58.254 -} break;
  58.255 -case 31 : 
  58.256 -case 95 : 
  58.257 -{
  58.258 -  P2 = IC(4);
  58.259 -  P3 = IC(4);
  58.260 -  if (MUL) {
  58.261 -    P0 = IC(4);
  58.262 -  } else {
  58.263 -    P0 = I211(4, 1, 3);
  58.264 -  }
  58.265 -  if (MUR) {
  58.266 -    P1 = IC(4);
  58.267 -  } else {
  58.268 -    P1 = I211(4, 1, 5);
  58.269 -  }
  58.270 -} break;
  58.271 -case 42 : 
  58.272 -case 170 : 
  58.273 -{
  58.274 -  P1 = IC(0);
  58.275 -  P3 = IC(0);
  58.276 -  if (MUL) {
  58.277 -    P0 = IC(0);
  58.278 -    P2 = IC(0);
  58.279 -  } else {
  58.280 -    P0 = I332(1, 3, 0);
  58.281 -    P2 = I31(0, 3);
  58.282 -  }
  58.283 -} break;
  58.284 -case 43 : 
  58.285 -case 171 : 
  58.286 -case 187 : 
  58.287 -{
  58.288 -  P1 = IC(2);
  58.289 -  P3 = IC(2);
  58.290 -  if (MUL) {
  58.291 -    P0 = IC(2);
  58.292 -    P2 = IC(2);
  58.293 -  } else {
  58.294 -    P0 = I332(1, 3, 2);
  58.295 -    P2 = I31(2, 3);
  58.296 -  }
  58.297 -} break;
  58.298 -case 46 : 
  58.299 -case 174 : 
  58.300 -{
  58.301 -  P1 = IC(0);
  58.302 -  P2 = IC(0);
  58.303 -  P3 = IC(0);
  58.304 -  if (MUL) {
  58.305 -    P0 = IC(0);
  58.306 -  } else {
  58.307 -    P0 = I611(0, 1, 3);
  58.308 -  }
  58.309 -} break;
  58.310 -case 47 : 
  58.311 -case 175 : 
  58.312 -{
  58.313 -  P1 = IC(4);
  58.314 -  P2 = IC(4);
  58.315 -  P3 = IC(4);
  58.316 -  if (MUL) {
  58.317 -    P0 = IC(4);
  58.318 -  } else {
  58.319 -    P0 = I1411(4, 1, 3);
  58.320 -  }
  58.321 -} break;
  58.322 -case 58 : 
  58.323 -case 154 : 
  58.324 -case 186 : 
  58.325 -{
  58.326 -  P2 = IC(0);
  58.327 -  P3 = IC(0);
  58.328 -  if (MUL) {
  58.329 -    P0 = IC(0);
  58.330 -  } else {
  58.331 -    P0 = I611(0, 1, 3);
  58.332 -  }
  58.333 -  if (MUR) {
  58.334 -    P1 = IC(0);
  58.335 -  } else {
  58.336 -    P1 = I611(0, 1, 5);
  58.337 -  }
  58.338 -} break;
  58.339 -case 59 : 
  58.340 -{
  58.341 -  P2 = IC(2);
  58.342 -  P3 = IC(2);
  58.343 -  if (MUL) {
  58.344 -    P0 = IC(2);
  58.345 -  } else {
  58.346 -    P0 = I211(2, 1, 3);
  58.347 -  }
  58.348 -  if (MUR) {
  58.349 -    P1 = IC(2);
  58.350 -  } else {
  58.351 -    P1 = I611(2, 1, 5);
  58.352 -  }
  58.353 -} break;
  58.354 -case 63 : 
  58.355 -{
  58.356 -  P2 = IC(4);
  58.357 -  P3 = IC(4);
  58.358 -  if (MUL) {
  58.359 -    P0 = IC(4);
  58.360 -  } else {
  58.361 -    P0 = I1411(4, 1, 3);
  58.362 -  }
  58.363 -  if (MUR) {
  58.364 -    P1 = IC(4);
  58.365 -  } else {
  58.366 -    P1 = I211(4, 1, 5);
  58.367 -  }
  58.368 -} break;
  58.369 -case 72 : 
  58.370 -case 76 : 
  58.371 -case 104 : 
  58.372 -case 106 : 
  58.373 -case 108 : 
  58.374 -case 110 : 
  58.375 -case 120 : 
  58.376 -case 124 : 
  58.377 -{
  58.378 -  P0 = IC(0);
  58.379 -  P1 = IC(0);
  58.380 -  P3 = IC(0);
  58.381 -  if (MDL) {
  58.382 -    P2 = IC(0);
  58.383 -  } else {
  58.384 -    P2 = I211(0, 3, 7);
  58.385 -  }
  58.386 -} break;
  58.387 -case 73 : 
  58.388 -case 77 : 
  58.389 -case 105 : 
  58.390 -case 109 : 
  58.391 -case 125 : 
  58.392 -{
  58.393 -  P1 = IC(1);
  58.394 -  P3 = IC(1);
  58.395 -  if (MDL) {
  58.396 -    P0 = IC(1);
  58.397 -    P2 = IC(1);
  58.398 -  } else {
  58.399 -    P0 = I31(1, 3);
  58.400 -    P2 = I332(3, 7, 1);
  58.401 -  }
  58.402 -} break;
  58.403 -case 74 : 
  58.404 -{
  58.405 -  P1 = IC(0);
  58.406 -  P3 = IC(0);
  58.407 -  if (MDL) {
  58.408 -    P2 = IC(0);
  58.409 -  } else {
  58.410 -    P2 = I211(0, 3, 7);
  58.411 -  }
  58.412 -  if (MUL) {
  58.413 -    P0 = IC(0);
  58.414 -  } else {
  58.415 -    P0 = I211(0, 1, 3);
  58.416 -  }
  58.417 -} break;
  58.418 -case 78 : 
  58.419 -case 202 : 
  58.420 -case 206 : 
  58.421 -{
  58.422 -  P1 = IC(0);
  58.423 -  P3 = IC(0);
  58.424 -  if (MDL) {
  58.425 -    P2 = IC(0);
  58.426 -  } else {
  58.427 -    P2 = I611(0, 3, 7);
  58.428 -  }
  58.429 -  if (MUL) {
  58.430 -    P0 = IC(0);
  58.431 -  } else {
  58.432 -    P0 = I611(0, 1, 3);
  58.433 -  }
  58.434 -} break;
  58.435 -case 79 : 
  58.436 -{
  58.437 -  P1 = IC(4);
  58.438 -  P3 = IC(4);
  58.439 -  if (MDL) {
  58.440 -    P2 = IC(4);
  58.441 -  } else {
  58.442 -    P2 = I611(4, 3, 7);
  58.443 -  }
  58.444 -  if (MUL) {
  58.445 -    P0 = IC(4);
  58.446 -  } else {
  58.447 -    P0 = I211(4, 1, 3);
  58.448 -  }
  58.449 -} break;
  58.450 -case 80 : 
  58.451 -case 208 : 
  58.452 -case 210 : 
  58.453 -case 216 : 
  58.454 -{
  58.455 -  P0 = IC(0);
  58.456 -  P1 = IC(0);
  58.457 -  P2 = IC(0);
  58.458 -  if (MDR) {
  58.459 -    P3 = IC(0);
  58.460 -  } else {
  58.461 -    P3 = I211(0, 5, 7);
  58.462 -  }
  58.463 -} break;
  58.464 -case 81 : 
  58.465 -case 209 : 
  58.466 -case 217 : 
  58.467 -{
  58.468 -  P0 = IC(1);
  58.469 -  P1 = IC(1);
  58.470 -  P2 = IC(1);
  58.471 -  if (MDR) {
  58.472 -    P3 = IC(1);
  58.473 -  } else {
  58.474 -    P3 = I211(1, 5, 7);
  58.475 -  }
  58.476 -} break;
  58.477 -case 82 : 
  58.478 -case 214 : 
  58.479 -case 222 : 
  58.480 -{
  58.481 -  P0 = IC(0);
  58.482 -  P2 = IC(0);
  58.483 -  if (MDR) {
  58.484 -    P3 = IC(0);
  58.485 -  } else {
  58.486 -    P3 = I211(0, 5, 7);
  58.487 -  }
  58.488 -  if (MUR) {
  58.489 -    P1 = IC(0);
  58.490 -  } else {
  58.491 -    P1 = I211(0, 1, 5);
  58.492 -  }
  58.493 -} break;
  58.494 -case 83 : 
  58.495 -case 115 : 
  58.496 -{
  58.497 -  P0 = IC(2);
  58.498 -  P2 = IC(2);
  58.499 -  if (MDR) {
  58.500 -    P3 = IC(2);
  58.501 -  } else {
  58.502 -    P3 = I611(2, 5, 7);
  58.503 -  }
  58.504 -  if (MUR) {
  58.505 -    P1 = IC(2);
  58.506 -  } else {
  58.507 -    P1 = I611(2, 1, 5);
  58.508 -  }
  58.509 -} break;
  58.510 -case 84 : 
  58.511 -case 212 : 
  58.512 -{
  58.513 -  P0 = IC(0);
  58.514 -  P2 = IC(0);
  58.515 -  if (MDR) {
  58.516 -    P1 = IC(0);
  58.517 -    P3 = IC(0);
  58.518 -  } else {
  58.519 -    P1 = I31(0, 5);
  58.520 -    P3 = I332(5, 7, 0);
  58.521 -  }
  58.522 -} break;
  58.523 -case 85 : 
  58.524 -case 213 : 
  58.525 -case 221 : 
  58.526 -{
  58.527 -  P0 = IC(1);
  58.528 -  P2 = IC(1);
  58.529 -  if (MDR) {
  58.530 -    P1 = IC(1);
  58.531 -    P3 = IC(1);
  58.532 -  } else {
  58.533 -    P1 = I31(1, 5);
  58.534 -    P3 = I332(5, 7, 1);
  58.535 -  }
  58.536 -} break;
  58.537 -case 87 : 
  58.538 -{
  58.539 -  P0 = IC(3);
  58.540 -  P2 = IC(3);
  58.541 -  if (MDR) {
  58.542 -    P3 = IC(3);
  58.543 -  } else {
  58.544 -    P3 = I611(3, 5, 7);
  58.545 -  }
  58.546 -  if (MUR) {
  58.547 -    P1 = IC(3);
  58.548 -  } else {
  58.549 -    P1 = I211(3, 1, 5);
  58.550 -  }
  58.551 -} break;
  58.552 -case 88 : 
  58.553 -case 248 : 
  58.554 -case 250 : 
  58.555 -{
  58.556 -  P0 = IC(0);
  58.557 -  P1 = IC(0);
  58.558 -  if (MDL) {
  58.559 -    P2 = IC(0);
  58.560 -  } else {
  58.561 -    P2 = I211(0, 3, 7);
  58.562 -  }
  58.563 -  if (MDR) {
  58.564 -    P3 = IC(0);
  58.565 -  } else {
  58.566 -    P3 = I211(0, 5, 7);
  58.567 -  }
  58.568 -} break;
  58.569 -case 89 : 
  58.570 -case 93 : 
  58.571 -{
  58.572 -  P0 = IC(1);
  58.573 -  P1 = IC(1);
  58.574 -  if (MDL) {
  58.575 -    P2 = IC(1);
  58.576 -  } else {
  58.577 -    P2 = I611(1, 3, 7);
  58.578 -  }
  58.579 -  if (MDR) {
  58.580 -    P3 = IC(1);
  58.581 -  } else {
  58.582 -    P3 = I611(1, 5, 7);
  58.583 -  }
  58.584 -} break;
  58.585 -case 90 : 
  58.586 -{
  58.587 -  if (MDL) {
  58.588 -    P2 = IC(0);
  58.589 -  } else {
  58.590 -    P2 = I611(0, 3, 7);
  58.591 -  }
  58.592 -  if (MDR) {
  58.593 -    P3 = IC(0);
  58.594 -  } else {
  58.595 -    P3 = I611(0, 5, 7);
  58.596 -  }
  58.597 -  if (MUL) {
  58.598 -    P0 = IC(0);
  58.599 -  } else {
  58.600 -    P0 = I611(0, 1, 3);
  58.601 -  }
  58.602 -  if (MUR) {
  58.603 -    P1 = IC(0);
  58.604 -  } else {
  58.605 -    P1 = I611(0, 1, 5);
  58.606 -  }
  58.607 -} break;
  58.608 -case 91 : 
  58.609 -{
  58.610 -  if (MDL) {
  58.611 -    P2 = IC(2);
  58.612 -  } else {
  58.613 -    P2 = I611(2, 3, 7);
  58.614 -  }
  58.615 -  if (MDR) {
  58.616 -    P3 = IC(2);
  58.617 -  } else {
  58.618 -    P3 = I611(2, 5, 7);
  58.619 -  }
  58.620 -  if (MUL) {
  58.621 -    P0 = IC(2);
  58.622 -  } else {
  58.623 -    P0 = I211(2, 1, 3);
  58.624 -  }
  58.625 -  if (MUR) {
  58.626 -    P1 = IC(2);
  58.627 -  } else {
  58.628 -    P1 = I611(2, 1, 5);
  58.629 -  }
  58.630 -} break;
  58.631 -case 92 : 
  58.632 -{
  58.633 -  P0 = IC(0);
  58.634 -  P1 = IC(0);
  58.635 -  if (MDL) {
  58.636 -    P2 = IC(0);
  58.637 -  } else {
  58.638 -    P2 = I611(0, 3, 7);
  58.639 -  }
  58.640 -  if (MDR) {
  58.641 -    P3 = IC(0);
  58.642 -  } else {
  58.643 -    P3 = I611(0, 5, 7);
  58.644 -  }
  58.645 -} break;
  58.646 -case 94 : 
  58.647 -{
  58.648 -  if (MDL) {
  58.649 -    P2 = IC(0);
  58.650 -  } else {
  58.651 -    P2 = I611(0, 3, 7);
  58.652 -  }
  58.653 -  if (MDR) {
  58.654 -    P3 = IC(0);
  58.655 -  } else {
  58.656 -    P3 = I611(0, 5, 7);
  58.657 -  }
  58.658 -  if (MUL) {
  58.659 -    P0 = IC(0);
  58.660 -  } else {
  58.661 -    P0 = I611(0, 1, 3);
  58.662 -  }
  58.663 -  if (MUR) {
  58.664 -    P1 = IC(0);
  58.665 -  } else {
  58.666 -    P1 = I211(0, 1, 5);
  58.667 -  }
  58.668 -} break;
  58.669 -case 107 : 
  58.670 -case 123 : 
  58.671 -{
  58.672 -  P1 = IC(2);
  58.673 -  P3 = IC(2);
  58.674 -  if (MDL) {
  58.675 -    P2 = IC(2);
  58.676 -  } else {
  58.677 -    P2 = I211(2, 3, 7);
  58.678 -  }
  58.679 -  if (MUL) {
  58.680 -    P0 = IC(2);
  58.681 -  } else {
  58.682 -    P0 = I211(2, 1, 3);
  58.683 -  }
  58.684 -} break;
  58.685 -case 111 : 
  58.686 -{
  58.687 -  P1 = IC(4);
  58.688 -  P3 = IC(4);
  58.689 -  if (MDL) {
  58.690 -    P2 = IC(4);
  58.691 -  } else {
  58.692 -    P2 = I211(4, 3, 7);
  58.693 -  }
  58.694 -  if (MUL) {
  58.695 -    P0 = IC(4);
  58.696 -  } else {
  58.697 -    P0 = I1411(4, 1, 3);
  58.698 -  }
  58.699 -} break;
  58.700 -case 112 : 
  58.701 -case 240 : 
  58.702 -{
  58.703 -  P0 = IC(0);
  58.704 -  P1 = IC(0);
  58.705 -  if (MDR) {
  58.706 -    P2 = IC(0);
  58.707 -    P3 = IC(0);
  58.708 -  } else {
  58.709 -    P2 = I31(0, 7);
  58.710 -    P3 = I332(5, 7, 0);
  58.711 -  }
  58.712 -} break;
  58.713 -case 113 : 
  58.714 -case 241 : 
  58.715 -{
  58.716 -  P0 = IC(1);
  58.717 -  P1 = IC(1);
  58.718 -  if (MDR) {
  58.719 -    P2 = IC(1);
  58.720 -    P3 = IC(1);
  58.721 -  } else {
  58.722 -    P2 = I31(1, 7);
  58.723 -    P3 = I332(5, 7, 1);
  58.724 -  }
  58.725 -} break;
  58.726 -case 114 : 
  58.727 -{
  58.728 -  P0 = IC(0);
  58.729 -  P2 = IC(0);
  58.730 -  if (MDR) {
  58.731 -    P3 = IC(0);
  58.732 -  } else {
  58.733 -    P3 = I611(0, 5, 7);
  58.734 -  }
  58.735 -  if (MUR) {
  58.736 -    P1 = IC(0);
  58.737 -  } else {
  58.738 -    P1 = I611(0, 1, 5);
  58.739 -  }
  58.740 -} break;
  58.741 -case 116 : 
  58.742 -{
  58.743 -  P0 = IC(0);
  58.744 -  P1 = IC(0);
  58.745 -  P2 = IC(0);
  58.746 -  if (MDR) {
  58.747 -    P3 = IC(0);
  58.748 -  } else {
  58.749 -    P3 = I611(0, 5, 7);
  58.750 -  }
  58.751 -} break;
  58.752 -case 117 : 
  58.753 -{
  58.754 -  P0 = IC(1);
  58.755 -  P1 = IC(1);
  58.756 -  P2 = IC(1);
  58.757 -  if (MDR) {
  58.758 -    P3 = IC(1);
  58.759 -  } else {
  58.760 -    P3 = I611(1, 5, 7);
  58.761 -  }
  58.762 -} break;
  58.763 -case 121 : 
  58.764 -{
  58.765 -  P0 = IC(1);
  58.766 -  P1 = IC(1);
  58.767 -  if (MDL) {
  58.768 -    P2 = IC(1);
  58.769 -  } else {
  58.770 -    P2 = I211(1, 3, 7);
  58.771 -  }
  58.772 -  if (MDR) {
  58.773 -    P3 = IC(1);
  58.774 -  } else {
  58.775 -    P3 = I611(1, 5, 7);
  58.776 -  }
  58.777 -} break;
  58.778 -case 122 : 
  58.779 -{
  58.780 -  if (MDL) {
  58.781 -    P2 = IC(0);
  58.782 -  } else {
  58.783 -    P2 = I211(0, 3, 7);
  58.784 -  }
  58.785 -  if (MDR) {
  58.786 -    P3 = IC(0);
  58.787 -  } else {
  58.788 -    P3 = I611(0, 5, 7);
  58.789 -  }
  58.790 -  if (MUL) {
  58.791 -    P0 = IC(0);
  58.792 -  } else {
  58.793 -    P0 = I611(0, 1, 3);
  58.794 -  }
  58.795 -  if (MUR) {
  58.796 -    P1 = IC(0);
  58.797 -  } else {
  58.798 -    P1 = I611(0, 1, 5);
  58.799 -  }
  58.800 -} break;
  58.801 -case 126 : 
  58.802 -{
  58.803 -  P0 = IC(0);
  58.804 -  P3 = IC(0);
  58.805 -  if (MDL) {
  58.806 -    P2 = IC(0);
  58.807 -  } else {
  58.808 -    P2 = I211(0, 3, 7);
  58.809 -  }
  58.810 -  if (MUR) {
  58.811 -    P1 = IC(0);
  58.812 -  } else {
  58.813 -    P1 = I211(0, 1, 5);
  58.814 -  }
  58.815 -} break;
  58.816 -case 127 : 
  58.817 -{
  58.818 -  P3 = IC(4);
  58.819 -  if (MDL) {
  58.820 -    P2 = IC(4);
  58.821 -  } else {
  58.822 -    P2 = I211(4, 3, 7);
  58.823 -  }
  58.824 -  if (MUL) {
  58.825 -    P0 = IC(4);
  58.826 -  } else {
  58.827 -    P0 = I1411(4, 1, 3);
  58.828 -  }
  58.829 -  if (MUR) {
  58.830 -    P1 = IC(4);
  58.831 -  } else {
  58.832 -    P1 = I211(4, 1, 5);
  58.833 -  }
  58.834 -} break;
  58.835 -case 146 : 
  58.836 -case 150 : 
  58.837 -case 178 : 
  58.838 -case 182 : 
  58.839 -case 190 : 
  58.840 -{
  58.841 -  P0 = IC(0);
  58.842 -  P2 = IC(0);
  58.843 -  if (MUR) {
  58.844 -    P1 = IC(0);
  58.845 -    P3 = IC(0);
  58.846 -  } else {
  58.847 -    P1 = I332(1, 5, 0);
  58.848 -    P3 = I31(0, 5);
  58.849 -  }
  58.850 -} break;
  58.851 -case 147 : 
  58.852 -case 179 : 
  58.853 -{
  58.854 -  P0 = IC(2);
  58.855 -  P2 = IC(2);
  58.856 -  P3 = IC(2);
  58.857 -  if (MUR) {
  58.858 -    P1 = IC(2);
  58.859 -  } else {
  58.860 -    P1 = I611(2, 1, 5);
  58.861 -  }
  58.862 -} break;
  58.863 -case 151 : 
  58.864 -case 183 : 
  58.865 -{
  58.866 -  P0 = IC(3);
  58.867 -  P2 = IC(3);
  58.868 -  P3 = IC(3);
  58.869 -  if (MUR) {
  58.870 -    P1 = IC(3);
  58.871 -  } else {
  58.872 -    P1 = I1411(3, 1, 5);
  58.873 -  }
  58.874 -} break;
  58.875 -case 158 : 
  58.876 -{
  58.877 -  P2 = IC(0);
  58.878 -  P3 = IC(0);
  58.879 -  if (MUL) {
  58.880 -    P0 = IC(0);
  58.881 -  } else {
  58.882 -    P0 = I611(0, 1, 3);
  58.883 -  }
  58.884 -  if (MUR) {
  58.885 -    P1 = IC(0);
  58.886 -  } else {
  58.887 -    P1 = I211(0, 1, 5);
  58.888 -  }
  58.889 -} break;
  58.890 -case 159 : 
  58.891 -{
  58.892 -  P2 = IC(4);
  58.893 -  P3 = IC(4);
  58.894 -  if (MUL) {
  58.895 -    P0 = IC(4);
  58.896 -  } else {
  58.897 -    P0 = I211(4, 1, 3);
  58.898 -  }
  58.899 -  if (MUR) {
  58.900 -    P1 = IC(4);
  58.901 -  } else {
  58.902 -    P1 = I1411(4, 1, 5);
  58.903 -  }
  58.904 -} break;
  58.905 -case 191 : 
  58.906 -{
  58.907 -  P2 = IC(4);
  58.908 -  P3 = IC(4);
  58.909 -  if (MUL) {
  58.910 -    P0 = IC(4);
  58.911 -  } else {
  58.912 -    P0 = I1411(4, 1, 3);
  58.913 -  }
  58.914 -  if (MUR) {
  58.915 -    P1 = IC(4);
  58.916 -  } else {
  58.917 -    P1 = I1411(4, 1, 5);
  58.918 -  }
  58.919 -} break;
  58.920 -case 200 : 
  58.921 -case 204 : 
  58.922 -case 232 : 
  58.923 -case 236 : 
  58.924 -case 238 : 
  58.925 -{
  58.926 -  P0 = IC(0);
  58.927 -  P1 = IC(0);
  58.928 -  if (MDL) {
  58.929 -    P2 = IC(0);
  58.930 -    P3 = IC(0);
  58.931 -  } else {
  58.932 -    P2 = I332(3, 7, 0);
  58.933 -    P3 = I31(0, 7);
  58.934 -  }
  58.935 -} break;
  58.936 -case 201 : 
  58.937 -case 205 : 
  58.938 -{
  58.939 -  P0 = IC(1);
  58.940 -  P1 = IC(1);
  58.941 -  P3 = IC(1);
  58.942 -  if (MDL) {
  58.943 -    P2 = IC(1);
  58.944 -  } else {
  58.945 -    P2 = I611(1, 3, 7);
  58.946 -  }
  58.947 -} break;
  58.948 -case 211 : 
  58.949 -{
  58.950 -  P0 = IC(2);
  58.951 -  P1 = IC(2);
  58.952 -  P2 = IC(2);
  58.953 -  if (MDR) {
  58.954 -    P3 = IC(2);
  58.955 -  } else {
  58.956 -    P3 = I211(2, 5, 7);
  58.957 -  }
  58.958 -} break;
  58.959 -case 215 : 
  58.960 -{
  58.961 -  P0 = IC(3);
  58.962 -  P2 = IC(3);
  58.963 -  if (MDR) {
  58.964 -    P3 = IC(3);
  58.965 -  } else {
  58.966 -    P3 = I211(3, 5, 7);
  58.967 -  }
  58.968 -  if (MUR) {
  58.969 -    P1 = IC(3);
  58.970 -  } else {
  58.971 -    P1 = I1411(3, 1, 5);
  58.972 -  }
  58.973 -} break;
  58.974 -case 218 : 
  58.975 -{
  58.976 -  if (MDL) {
  58.977 -    P2 = IC(0);
  58.978 -  } else {
  58.979 -    P2 = I611(0, 3, 7);
  58.980 -  }
  58.981 -  if (MDR) {
  58.982 -    P3 = IC(0);
  58.983 -  } else {
  58.984 -    P3 = I211(0, 5, 7);
  58.985 -  }
  58.986 -  if (MUL) {
  58.987 -    P0 = IC(0);
  58.988 -  } else {
  58.989 -    P0 = I611(0, 1, 3);
  58.990 -  }
  58.991 -  if (MUR) {
  58.992 -    P1 = IC(0);
  58.993 -  } else {
  58.994 -    P1 = I611(0, 1, 5);
  58.995 -  }
  58.996 -} break;
  58.997 -case 219 : 
  58.998 -{
  58.999 -  P1 = IC(2);
 58.1000 -  P2 = IC(2);
 58.1001 -  if (MDR) {
 58.1002 -    P3 = IC(2);
 58.1003 -  } else {
 58.1004 -    P3 = I211(2, 5, 7);
 58.1005 -  }
 58.1006 -  if (MUL) {
 58.1007 -    P0 = IC(2);
 58.1008 -  } else {
 58.1009 -    P0 = I211(2, 1, 3);
 58.1010 -  }
 58.1011 -} break;
 58.1012 -case 220 : 
 58.1013 -{
 58.1014 -  P0 = IC(0);
 58.1015 -  P1 = IC(0);
 58.1016 -  if (MDL) {
 58.1017 -    P2 = IC(0);
 58.1018 -  } else {
 58.1019 -    P2 = I611(0, 3, 7);
 58.1020 -  }
 58.1021 -  if (MDR) {
 58.1022 -    P3 = IC(0);
 58.1023 -  } else {
 58.1024 -    P3 = I211(0, 5, 7);
 58.1025 -  }
 58.1026 -} break;
 58.1027 -case 223 : 
 58.1028 -{
 58.1029 -  P2 = IC(4);
 58.1030 -  if (MDR) {
 58.1031 -    P3 = IC(4);
 58.1032 -  } else {
 58.1033 -    P3 = I211(4, 5, 7);
 58.1034 -  }
 58.1035 -  if (MUL) {
 58.1036 -    P0 = IC(4);
 58.1037 -  } else {
 58.1038 -    P0 = I211(4, 1, 3);
 58.1039 -  }
 58.1040 -  if (MUR) {
 58.1041 -    P1 = IC(4);
 58.1042 -  } else {
 58.1043 -    P1 = I1411(4, 1, 5);
 58.1044 -  }
 58.1045 -} break;
 58.1046 -case 233 : 
 58.1047 -case 237 : 
 58.1048 -{
 58.1049 -  P0 = IC(1);
 58.1050 -  P1 = IC(1);
 58.1051 -  P3 = IC(1);
 58.1052 -  if (MDL) {
 58.1053 -    P2 = IC(1);
 58.1054 -  } else {
 58.1055 -    P2 = I1411(1, 3, 7);
 58.1056 -  }
 58.1057 -} break;
 58.1058 -case 234 : 
 58.1059 -{
 58.1060 -  P1 = IC(0);
 58.1061 -  P3 = IC(0);
 58.1062 -  if (MDL) {
 58.1063 -    P2 = IC(0);
 58.1064 -  } else {
 58.1065 -    P2 = I211(0, 3, 7);
 58.1066 -  }
 58.1067 -  if (MUL) {
 58.1068 -    P0 = IC(0);
 58.1069 -  } else {
 58.1070 -    P0 = I611(0, 1, 3);
 58.1071 -  }
 58.1072 -} break;
 58.1073 -case 235 : 
 58.1074 -{
 58.1075 -  P1 = IC(2);
 58.1076 -  P3 = IC(2);
 58.1077 -  if (MDL) {
 58.1078 -    P2 = IC(2);
 58.1079 -  } else {
 58.1080 -    P2 = I1411(2, 3, 7);
 58.1081 -  }
 58.1082 -  if (MUL) {
 58.1083 -    P0 = IC(2);
 58.1084 -  } else {
 58.1085 -    P0 = I211(2, 1, 3);
 58.1086 -  }
 58.1087 -} break;
 58.1088 -case 239 : 
 58.1089 -{
 58.1090 -  P1 = IC(4);
 58.1091 -  P3 = IC(4);
 58.1092 -  if (MDL) {
 58.1093 -    P2 = IC(4);
 58.1094 -  } else {
 58.1095 -    P2 = I1411(4, 3, 7);
 58.1096 -  }
 58.1097 -  if (MUL) {
 58.1098 -    P0 = IC(4);
 58.1099 -  } else {
 58.1100 -    P0 = I1411(4, 1, 3);
 58.1101 -  }
 58.1102 -} break;
 58.1103 -case 242 : 
 58.1104 -{
 58.1105 -  P0 = IC(0);
 58.1106 -  P2 = IC(0);
 58.1107 -  if (MDR) {
 58.1108 -    P3 = IC(0);
 58.1109 -  } else {
 58.1110 -    P3 = I211(0, 5, 7);
 58.1111 -  }
 58.1112 -  if (MUR) {
 58.1113 -    P1 = IC(0);
 58.1114 -  } else {
 58.1115 -    P1 = I611(0, 1, 5);
 58.1116 -  }
 58.1117 -} break;
 58.1118 -case 243 : 
 58.1119 -{
 58.1120 -  P0 = IC(2);
 58.1121 -  P1 = IC(2);
 58.1122 -  if (MDR) {
 58.1123 -    P2 = IC(2);
 58.1124 -    P3 = IC(2);
 58.1125 -  } else {
 58.1126 -    P2 = I31(2, 7);
 58.1127 -    P3 = I332(5, 7, 2);
 58.1128 -  }
 58.1129 -} break;
 58.1130 -case 244 : 
 58.1131 -{
 58.1132 -  P0 = IC(0);
 58.1133 -  P1 = IC(0);
 58.1134 -  P2 = IC(0);
 58.1135 -  if (MDR) {
 58.1136 -    P3 = IC(0);
 58.1137 -  } else {
 58.1138 -    P3 = I1411(0, 5, 7);
 58.1139 -  }
 58.1140 -} break;
 58.1141 -case 245 : 
 58.1142 -{
 58.1143 -  P0 = IC(1);
 58.1144 -  P1 = IC(1);
 58.1145 -  P2 = IC(1);
 58.1146 -  if (MDR) {
 58.1147 -    P3 = IC(1);
 58.1148 -  } else {
 58.1149 -    P3 = I1411(1, 5, 7);
 58.1150 -  }
 58.1151 -} break;
 58.1152 -case 246 : 
 58.1153 -{
 58.1154 -  P0 = IC(0);
 58.1155 -  P2 = IC(0);
 58.1156 -  if (MDR) {
 58.1157 -    P3 = IC(0);
 58.1158 -  } else {
 58.1159 -    P3 = I1411(0, 5, 7);
 58.1160 -  }
 58.1161 -  if (MUR) {
 58.1162 -    P1 = IC(0);
 58.1163 -  } else {
 58.1164 -    P1 = I211(0, 1, 5);
 58.1165 -  }
 58.1166 -} break;
 58.1167 -case 247 : 
 58.1168 -{
 58.1169 -  P0 = IC(3);
 58.1170 -  P2 = IC(3);
 58.1171 -  if (MDR) {
 58.1172 -    P3 = IC(3);
 58.1173 -  } else {
 58.1174 -    P3 = I1411(3, 5, 7);
 58.1175 -  }
 58.1176 -  if (MUR) {
 58.1177 -    P1 = IC(3);
 58.1178 -  } else {
 58.1179 -    P1 = I1411(3, 1, 5);
 58.1180 -  }
 58.1181 -} break;
 58.1182 -case 249 : 
 58.1183 -{
 58.1184 -  P0 = IC(1);
 58.1185 -  P1 = IC(1);
 58.1186 -  if (MDL) {
 58.1187 -    P2 = IC(1);
 58.1188 -  } else {
 58.1189 -    P2 = I1411(1, 3, 7);
 58.1190 -  }
 58.1191 -  if (MDR) {
 58.1192 -    P3 = IC(1);
 58.1193 -  } else {
 58.1194 -    P3 = I211(1, 5, 7);
 58.1195 -  }
 58.1196 -} break;
 58.1197 -case 251 : 
 58.1198 -{
 58.1199 -  P1 = IC(2);
 58.1200 -  if (MDL) {
 58.1201 -    P2 = IC(2);
 58.1202 -  } else {
 58.1203 -    P2 = I1411(2, 3, 7);
 58.1204 -  }
 58.1205 -  if (MDR) {
 58.1206 -    P3 = IC(2);
 58.1207 -  } else {
 58.1208 -    P3 = I211(2, 5, 7);
 58.1209 -  }
 58.1210 -  if (MUL) {
 58.1211 -    P0 = IC(2);
 58.1212 -  } else {
 58.1213 -    P0 = I211(2, 1, 3);
 58.1214 -  }
 58.1215 -} break;
 58.1216 -case 252 : 
 58.1217 -{
 58.1218 -  P0 = IC(0);
 58.1219 -  P1 = IC(0);
 58.1220 -  if (MDL) {
 58.1221 -    P2 = IC(0);
 58.1222 -  } else {
 58.1223 -    P2 = I211(0, 3, 7);
 58.1224 -  }
 58.1225 -  if (MDR) {
 58.1226 -    P3 = IC(0);
 58.1227 -  } else {
 58.1228 -    P3 = I1411(0, 5, 7);
 58.1229 -  }
 58.1230 -} break;
 58.1231 -case 253 : 
 58.1232 -{
 58.1233 -  P0 = IC(1);
 58.1234 -  P1 = IC(1);
 58.1235 -  if (MDL) {
 58.1236 -    P2 = IC(1);
 58.1237 -  } else {
 58.1238 -    P2 = I1411(1, 3, 7);
 58.1239 -  }
 58.1240 -  if (MDR) {
 58.1241 -    P3 = IC(1);
 58.1242 -  } else {
 58.1243 -    P3 = I1411(1, 5, 7);
 58.1244 -  }
 58.1245 -} break;
 58.1246 -case 254 : 
 58.1247 -{
 58.1248 -  P0 = IC(0);
 58.1249 -  if (MDL) {
 58.1250 -    P2 = IC(0);
 58.1251 -  } else {
 58.1252 -    P2 = I211(0, 3, 7);
 58.1253 -  }
 58.1254 -  if (MDR) {
 58.1255 -    P3 = IC(0);
 58.1256 -  } else {
 58.1257 -    P3 = I1411(0, 5, 7);
 58.1258 -  }
 58.1259 -  if (MUR) {
 58.1260 -    P1 = IC(0);
 58.1261 -  } else {
 58.1262 -    P1 = I211(0, 1, 5);
 58.1263 -  }
 58.1264 -} break;
 58.1265 -case 255 : 
 58.1266 -{
 58.1267 -  if (MDL) {
 58.1268 -    P2 = IC(4);
 58.1269 -  } else {
 58.1270 -    P2 = I1411(4, 3, 7);
 58.1271 -  }
 58.1272 -  if (MDR) {
 58.1273 -    P3 = IC(4);
 58.1274 -  } else {
 58.1275 -    P3 = I1411(4, 5, 7);
 58.1276 -  }
 58.1277 -  if (MUL) {
 58.1278 -    P0 = IC(4);
 58.1279 -  } else {
 58.1280 -    P0 = I1411(4, 1, 3);
 58.1281 -  }
 58.1282 -  if (MUR) {
 58.1283 -    P1 = IC(4);
 58.1284 -  } else {
 58.1285 -    P1 = I1411(4, 1, 5);
 58.1286 -  }
 58.1287 -} break;
    59.1 --- a/src/filters/motionblur.cpp	Sat Mar 03 10:54:39 2012 -0600
    59.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.3 @@ -1,183 +0,0 @@
    59.4 -#include "../Port.h"
    59.5 -
    59.6 -extern u32 RGB_LOW_BITS_MASK;
    59.7 -
    59.8 -void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
    59.9 -                u8 *dstPtr, u32 dstPitch, int width, int height)
   59.10 -{
   59.11 -	u8 *nextLine, *finish;
   59.12 -	u32 colorMask	 = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
   59.13 -	u32 lowPixelMask = RGB_LOW_BITS_MASK;
   59.14 -
   59.15 -	nextLine = dstPtr + dstPitch;
   59.16 -
   59.17 -	do
   59.18 -	{
   59.19 -		u32 *bP = (u32 *) srcPtr;
   59.20 -		u32 *xP = (u32 *) deltaPtr;
   59.21 -		u32 *dP = (u32 *) dstPtr;
   59.22 -		u32 *nL = (u32 *) nextLine;
   59.23 -		u32	 currentPixel;
   59.24 -		u32	 nextPixel;
   59.25 -		u32	 currentDelta;
   59.26 -		u32	 nextDelta;
   59.27 -
   59.28 -		finish	  = (u8 *) bP + ((width + 2) << 1);
   59.29 -		nextPixel = *bP++;
   59.30 -		nextDelta = *xP++;
   59.31 -
   59.32 -		do
   59.33 -		{
   59.34 -			currentPixel = nextPixel;
   59.35 -			currentDelta = nextDelta;
   59.36 -			nextPixel	 = *bP++;
   59.37 -			nextDelta	 = *xP++;
   59.38 -
   59.39 -			if (currentPixel != currentDelta)
   59.40 -			{
   59.41 -				u32 colorA, product, colorB;
   59.42 -
   59.43 -				*(xP - 2) = currentPixel;
   59.44 -#ifdef WORDS_BIGENDIAN
   59.45 -				colorA = currentPixel >> 16;
   59.46 -				colorB = currentDelta >> 16;
   59.47 -#else
   59.48 -				colorA = currentPixel & 0xffff;
   59.49 -				colorB = currentDelta & 0xffff;
   59.50 -#endif
   59.51 -
   59.52 -				product =   ((((colorA & colorMask) >> 1) +
   59.53 -				              ((colorB & colorMask) >> 1) +
   59.54 -				              (colorA & colorB & lowPixelMask)));
   59.55 -
   59.56 -				*(dP) = product | product << 16;
   59.57 -				*(nL) = product | product << 16;
   59.58 -
   59.59 -#ifdef WORDS_BIGENDIAN
   59.60 -				colorA = (currentPixel & 0xffff);
   59.61 -				colorB = (currentDelta & 0xffff);
   59.62 -#else
   59.63 -				colorA = currentPixel >> 16;
   59.64 -				colorB = currentDelta >> 16;
   59.65 -#endif
   59.66 -				product = ((((colorA & colorMask) >> 1) +
   59.67 -				            ((colorB & colorMask) >> 1) +
   59.68 -				            (colorA & colorB & lowPixelMask)));
   59.69 -
   59.70 -				*(dP + 1) = product | product << 16;
   59.71 -				*(nL + 1) = product | product << 16;
   59.72 -			}
   59.73 -			else
   59.74 -			{
   59.75 -				u32 colorA, product;
   59.76 -
   59.77 -				*(xP - 2) = currentPixel;
   59.78 -#ifdef WORDS_BIGENDIAN
   59.79 -				colorA = currentPixel >> 16;
   59.80 -#else
   59.81 -				colorA = currentPixel & 0xffff;
   59.82 -#endif
   59.83 -
   59.84 -				product = colorA;
   59.85 -
   59.86 -				*(dP) = product | product << 16;
   59.87 -				*(nL) = product | product << 16;
   59.88 -#ifdef WORDS_BIGENDIAN
   59.89 -				colorA = (currentPixel & 0xffff);
   59.90 -#else
   59.91 -				colorA = currentPixel >> 16;
   59.92 -#endif
   59.93 -				product = colorA;
   59.94 -
   59.95 -				*(dP + 1) = product | product << 16;
   59.96 -				*(nL + 1) = product | product << 16;
   59.97 -			}
   59.98 -
   59.99 -			dP += 2;
  59.100 -			nL += 2;
  59.101 -		}
  59.102 -		while ((u8 *) bP < finish);
  59.103 -
  59.104 -		deltaPtr += srcPitch;
  59.105 -		srcPtr	 += srcPitch;
  59.106 -		dstPtr	 += dstPitch << 1;
  59.107 -		nextLine += dstPitch << 1;
  59.108 -	}
  59.109 -	while (--height);
  59.110 -}
  59.111 -
  59.112 -void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
  59.113 -                  u8 *dstPtr, u32 dstPitch, int width, int height)
  59.114 -{
  59.115 -	u8 *nextLine, *finish;
  59.116 -	u32 colorMask	 = ~RGB_LOW_BITS_MASK;
  59.117 -	u32 lowPixelMask = RGB_LOW_BITS_MASK;
  59.118 -
  59.119 -	nextLine = dstPtr + dstPitch;
  59.120 -
  59.121 -	do
  59.122 -	{
  59.123 -		u32 *bP = (u32 *) srcPtr;
  59.124 -		u32 *xP = (u32 *) deltaPtr;
  59.125 -		u32 *dP = (u32 *) dstPtr;
  59.126 -		u32 *nL = (u32 *) nextLine;
  59.127 -		u32	 currentPixel;
  59.128 -		u32	 nextPixel;
  59.129 -		u32	 currentDelta;
  59.130 -		u32	 nextDelta;
  59.131 -
  59.132 -		finish	  = (u8 *) bP + ((width + 1) << 2);
  59.133 -		nextPixel = *bP++;
  59.134 -		nextDelta = *xP++;
  59.135 -
  59.136 -		do
  59.137 -		{
  59.138 -			currentPixel = nextPixel;
  59.139 -			currentDelta = nextDelta;
  59.140 -			nextPixel	 = *bP++;
  59.141 -			nextDelta	 = *xP++;
  59.142 -
  59.143 -			u32 colorA, product, colorB;
  59.144 -
  59.145 -			*(xP - 2) = currentPixel;
  59.146 -			colorA	  = currentPixel;
  59.147 -			colorB	  = currentDelta;
  59.148 -
  59.149 -			product =   ((((colorA & colorMask) >> 1) +
  59.150 -			              ((colorB & colorMask) >> 1) +
  59.151 -			              (colorA & colorB & lowPixelMask)));
  59.152 -
  59.153 -			*(dP)	  = product;
  59.154 -			*(dP + 1) = product;
  59.155 -			*(nL)	  = product;
  59.156 -			*(nL + 1) = product;
  59.157 -
  59.158 -			*(xP - 1) = nextPixel;
  59.159 -
  59.160 -			colorA = nextPixel;
  59.161 -			colorB = nextDelta;
  59.162 -
  59.163 -			product = ((((colorA & colorMask) >> 1) +
  59.164 -			            ((colorB & colorMask) >> 1) +
  59.165 -			            (colorA & colorB & lowPixelMask)));
  59.166 -
  59.167 -			*(dP + 2) = product;
  59.168 -			*(dP + 3) = product;
  59.169 -			*(nL + 2) = product;
  59.170 -			*(nL + 3) = product;
  59.171 -
  59.172 -			nextPixel = *bP++;
  59.173 -			nextDelta = *xP++;
  59.174 -
  59.175 -			dP += 4;
  59.176 -			nL += 4;
  59.177 -		}
  59.178 -		while ((u8 *) bP < finish);
  59.179 -
  59.180 -		deltaPtr += srcPitch;
  59.181 -		srcPtr	 += srcPitch;
  59.182 -		dstPtr	 += dstPitch << 1;
  59.183 -		nextLine += dstPitch << 1;
  59.184 -	}
  59.185 -	while (--height);
  59.186 -}
    60.1 --- a/src/filters/pixel.cpp	Sat Mar 03 10:54:39 2012 -0600
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,196 +0,0 @@
    60.4 -#include "../Port.h"
    60.5 -
    60.6 -extern u32 RGB_LOW_BITS_MASK;
    60.7 -
    60.8 -void Pixelate2x16(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
    60.9 -                  u8 *dstPtr, u32 dstPitch, int width, int height)
   60.10 -{
   60.11 -	u8 *nextLine, *finish;
   60.12 -	u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
   60.13 -	colorMask = (colorMask >> 2) & (colorMask >> 1);
   60.14 -
   60.15 -	nextLine = dstPtr + dstPitch;
   60.16 -
   60.17 -	do
   60.18 -	{
   60.19 -		u32 *bP = (u32 *) srcPtr;
   60.20 -		u32 *xP = (u32 *) deltaPtr;
   60.21 -		u32 *dP = (u32 *) dstPtr;
   60.22 -		u32 *nL = (u32 *) nextLine;
   60.23 -		u32  currentPixel;
   60.24 -		u32  nextPixel;
   60.25 -		u32  currentDelta;
   60.26 -		u32  nextDelta;
   60.27 -
   60.28 -		finish    = (u8 *) bP + ((width+2) << 1);
   60.29 -		nextPixel = *bP++;
   60.30 -		nextDelta = *xP++;
   60.31 -
   60.32 -		do
   60.33 -		{
   60.34 -			currentPixel = nextPixel;
   60.35 -			currentDelta = nextDelta;
   60.36 -			nextPixel    = *bP++;
   60.37 -			nextDelta    = *xP++;
   60.38 -
   60.39 -			if ((nextPixel != nextDelta) || (currentPixel != currentDelta))
   60.40 -			{
   60.41 -				u32 colorA, colorB, product;
   60.42 -
   60.43 -				*(xP - 2) = currentPixel;
   60.44 -#ifdef WORDS_BIGENDIAN
   60.45 -				colorA = currentPixel >> 16;
   60.46 -				colorB = currentPixel & 0xffff;
   60.47 -#else
   60.48 -				colorA = currentPixel & 0xffff;
   60.49 -				colorB = currentPixel >> 16;
   60.50 -#endif
   60.51 -				product = (colorA >> 2) & colorMask;
   60.52 -
   60.53 -#ifdef WORDS_BIGENDIAN
   60.54 -				*(nL) = (product << 16) | (product);
   60.55 -				*(dP) = (colorA << 16) | product;
   60.56 -#else
   60.57 -				*(nL) = product | (product << 16);
   60.58 -				*(dP) = colorA | (product << 16);
   60.59 -#endif
   60.60 -
   60.61 -#ifdef WORDS_BIGENDIAN
   60.62 -				colorA = nextPixel >> 16;
   60.63 -#else
   60.64 -				colorA = nextPixel & 0xffff;
   60.65 -#endif
   60.66 -				product = (colorB >> 2) & colorMask;
   60.67 -#ifdef WORDS_BIGENDIAN
   60.68 -				*(nL + 1) = (product << 16) | (product);
   60.69 -				*(dP + 1) = (colorB << 16) | (product);
   60.70 -#else
   60.71 -				*(nL + 1) = (product) | (product << 16);
   60.72 -				*(dP + 1) = (colorB) | (product << 16);
   60.73 -#endif
   60.74 -			}
   60.75 -
   60.76 -			dP += 2;
   60.77 -			nL += 2;
   60.78 -		}
   60.79 -		while ((u8 *) bP < finish);
   60.80 -
   60.81 -		deltaPtr += srcPitch;
   60.82 -		srcPtr   += srcPitch;
   60.83 -		dstPtr   += dstPitch << 1;
   60.84 -		nextLine += dstPitch << 1;
   60.85 -	}
   60.86 -	while (--height);
   60.87 -}
   60.88 -
   60.89 -void Pixelate2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
   60.90 -                  u8 *dstPtr, u32 dstPitch, int width, int height)
   60.91 -{
   60.92 -	u8 *nextLine, *finish;
   60.93 -	u32 colorMask = ((u32)~RGB_LOW_BITS_MASK >> 2) & ((u32)~RGB_LOW_BITS_MASK >> 1);
   60.94 -
   60.95 -	nextLine = dstPtr + dstPitch;
   60.96 -
   60.97 -	do
   60.98 -	{
   60.99 -		u32 *bP = (u32 *) srcPtr;
  60.100 -		//    u32 *xP = (u32 *) deltaPtr;
  60.101 -		u32 *dP = (u32 *) dstPtr;
  60.102 -		u32 *nL = (u32 *) nextLine;
  60.103 -		u32  currentPixel;
  60.104 -		u32  nextPixel;
  60.105 -
  60.106 -		finish    = (u8 *) bP + ((width+1) << 2);
  60.107 -		nextPixel = *bP++;
  60.108 -
  60.109 -		do
  60.110 -		{
  60.111 -			u32 product;
  60.112 -
  60.113 -			currentPixel = nextPixel;
  60.114 -			nextPixel    = *bP++;
  60.115 -			product = (currentPixel >> 2) & colorMask;
  60.116 -			*(nL)   = product;
  60.117 -			*(nL+1) = product;
  60.118 -			*(dP)   = currentPixel;
  60.119 -			*(dP+1) = product;
  60.120 -
  60.121 -			currentPixel = nextPixel;
  60.122 -			nextPixel = *bP++;
  60.123 -			product   = (currentPixel >> 2) & colorMask;
  60.124 -			*(nL + 2) = product;
  60.125 -			*(nL + 3) = product;
  60.126 -			*(dP + 2) = currentPixel;
  60.127 -			*(dP + 3) = product;
  60.128 -
  60.129 -			dP += 4;
  60.130 -			nL += 4;
  60.131 -		}
  60.132 -		while ((u8 *) bP < finish);
  60.133 -
  60.134 -		srcPtr   += srcPitch;
  60.135 -		dstPtr   += dstPitch << 1;
  60.136 -		nextLine += dstPitch << 1;
  60.137 -	}
  60.138 -	while (--height);
  60.139 -}
  60.140 -
  60.141 -// generic Pixelate Nx magnification filter
  60.142 -template <int magnification, typename ColorType>
  60.143 -void PixelateNx(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  60.144 -                u8 *dstPtr, u32 dstPitch, int width, int height)
  60.145 -{
  60.146 -	ColorType colorMask = ((ColorType)~RGB_LOW_BITS_MASK >> 2) & ((ColorType)~RGB_LOW_BITS_MASK >> 1);
  60.147 -
  60.148 -	srcPitch      = srcPitch / sizeof(ColorType) - width;
  60.149 -	u32 dstNextP  = dstPitch / sizeof(ColorType);
  60.150 -	u32 dstNextL  = (dstNextP - width) * magnification; // skip to the next magnificated 'line'
  60.151 -	dstNextP     -= magnification;
  60.152 -
  60.153 -	u32 offset    = (dstPitch + sizeof(ColorType)) * magnification - dstPitch;
  60.154 -
  60.155 -	ColorType *src   = (ColorType *)srcPtr;
  60.156 -	ColorType *dst   = (ColorType *)dstPtr;
  60.157 -
  60.158 -	do // per src line
  60.159 -	{
  60.160 -		u8 *finishP = (u8 *)dst + offset;
  60.161 -		for (int x = 0; x < width; ++x) // per pixel in line
  60.162 -		{
  60.163 -			ColorType col    = *src;
  60.164 -			ColorType *dst2  = dst;
  60.165 -			u8 *finishM = (u8 *)(dst + magnification);
  60.166 -
  60.167 -			ColorType product = (col >> 2) & colorMask;
  60.168 -			do
  60.169 -			{
  60.170 -				*dst2 = product;
  60.171 -			} while ((u8 *)++dst2 < finishM);
  60.172 -			dst2    += dstNextP;
  60.173 -			finishM += dstPitch;
  60.174 -			do // dst magnificated pixel
  60.175 -			{
  60.176 -				*dst2++ = product;
  60.177 -				do
  60.178 -				{
  60.179 -					*dst2 = col;
  60.180 -				} while ((u8 *)++dst2 < finishM);
  60.181 -				dst2    += dstNextP;
  60.182 -				finishM += dstPitch;
  60.183 -			} while ((u8 *)dst2 < finishP);
  60.184 -
  60.185 -			++src;
  60.186 -			dst     += magnification;
  60.187 -			finishP += magnification * sizeof(ColorType);
  60.188 -		}
  60.189 -		src += srcPitch;
  60.190 -		dst += dstNextL;
  60.191 -	} while (--height);
  60.192 -}
  60.193 -
  60.194 -typedef void (*PixelateNxFP)(u8*, u32, u8*, u8*, u32, int, int);
  60.195 -
  60.196 -PixelateNxFP Pixelate3x16 = PixelateNx<3, u16>;
  60.197 -PixelateNxFP Pixelate3x32 = PixelateNx<3, u32>;
  60.198 -PixelateNxFP Pixelate4x16 = PixelateNx<4, u16>;
  60.199 -PixelateNxFP Pixelate4x32 = PixelateNx<4, u32>;
    61.1 --- a/src/filters/scanline.cpp	Sat Mar 03 10:54:39 2012 -0600
    61.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.3 @@ -1,225 +0,0 @@
    61.4 -#include "../Port.h"
    61.5 -
    61.6 -extern u32 RGB_LOW_BITS_MASK;
    61.7 -
    61.8 -void Scanlines(u8 *srcPtr, u32 srcPitch, u8 *,
    61.9 -               u8 *dstPtr, u32 dstPitch, int width, int height)
   61.10 -{
   61.11 -	u8 *nextLine, *finish;
   61.12 -
   61.13 -	nextLine = dstPtr + dstPitch;
   61.14 -
   61.15 -	do
   61.16 -	{
   61.17 -		u32 *bP = (u32 *) srcPtr;
   61.18 -		u32 *dP = (u32 *) dstPtr;
   61.19 -		u32 *nL = (u32 *) nextLine;
   61.20 -		u32	 currentPixel;
   61.21 -		u32	 nextPixel;
   61.22 -
   61.23 -		finish	  = (u8 *) bP + ((width + 2) << 1);
   61.24 -		nextPixel = *bP++;
   61.25 -
   61.26 -		do
   61.27 -		{
   61.28 -			currentPixel = nextPixel;
   61.29 -			nextPixel	 = *bP++;
   61.30 -			u32 colorA, colorB;
   61.31 -
   61.32 -#ifdef WORDS_BIGENDIAN
   61.33 -			colorA = currentPixel >> 16;
   61.34 -			colorB = currentPixel & 0xffff;
   61.35 -#else
   61.36 -			colorA = currentPixel & 0xffff;
   61.37 -			colorB = currentPixel >> 16;
   61.38 -#endif
   61.39 -
   61.40 -			*(dP) = colorA | colorA << 16;
   61.41 -			*(nL) = 0;
   61.42 -
   61.43 -#ifdef WORDS_BIGENDIAN
   61.44 -			colorA = nextPixel >> 16;
   61.45 -#else
   61.46 -			colorA = nextPixel & 0xffff;
   61.47 -#endif
   61.48 -
   61.49 -			*(dP + 1) = colorB | (colorB << 16);
   61.50 -			*(nL + 1) = 0;
   61.51 -
   61.52 -			dP += 2;
   61.53 -			nL += 2;
   61.54 -		}
   61.55 -		while ((u8 *) bP < finish);
   61.56 -
   61.57 -		srcPtr	 += srcPitch;
   61.58 -		dstPtr	 += dstPitch << 1;
   61.59 -		nextLine += dstPitch << 1;
   61.60 -	}
   61.61 -	while (--height);
   61.62 -}
   61.63 -
   61.64 -void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
   61.65 -                 u8 *dstPtr, u32 dstPitch, int width, int height)
   61.66 -{
   61.67 -	u8 *nextLine, *finish;
   61.68 -
   61.69 -	nextLine = dstPtr + dstPitch;
   61.70 -
   61.71 -	do
   61.72 -	{
   61.73 -		u32 *bP = (u32 *) srcPtr;
   61.74 -		u32 *dP = (u32 *) dstPtr;
   61.75 -		u32 *nL = (u32 *) nextLine;
   61.76 -		u32	 currentPixel;
   61.77 -		u32	 nextPixel;
   61.78 -
   61.79 -		finish	  = (u8 *) bP + ((width + 1) << 2);
   61.80 -		nextPixel = *bP++;
   61.81 -
   61.82 -		do
   61.83 -		{
   61.84 -			currentPixel = nextPixel;
   61.85 -			nextPixel	 = *bP++;
   61.86 -
   61.87 -			u32 colorA, colorB;
   61.88 -
   61.89 -			colorA = currentPixel;
   61.90 -			colorB = nextPixel;
   61.91 -
   61.92 -			*(dP)	  = colorA;
   61.93 -			*(dP + 1) = colorA;
   61.94 -			*(nL)	  = 0;
   61.95 -			*(nL + 1) = 0;
   61.96 -
   61.97 -			*(dP + 2) = colorB;
   61.98 -			*(dP + 3) = colorB;
   61.99 -			*(nL + 2) = 0;
  61.100 -			*(nL + 3) = 0;
  61.101 -
  61.102 -			nextPixel = *bP++;
  61.103 -
  61.104 -			dP += 4;
  61.105 -			nL += 4;
  61.106 -		}
  61.107 -		while ((u8 *) bP < finish);
  61.108 -
  61.109 -		srcPtr	 += srcPitch;
  61.110 -		dstPtr	 += dstPitch << 1;
  61.111 -		nextLine += dstPitch << 1;
  61.112 -	}
  61.113 -	while (--height);
  61.114 -}
  61.115 -
  61.116 -void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  61.117 -                 u8 *dstPtr, u32 dstPitch, int width, int height)
  61.118 -{
  61.119 -	u8 *nextLine, *finish;
  61.120 -	u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
  61.121 -
  61.122 -	nextLine = dstPtr + dstPitch;
  61.123 -
  61.124 -	do
  61.125 -	{
  61.126 -		u32 *bP = (u32 *) srcPtr;
  61.127 -		u32 *dP = (u32 *) dstPtr;
  61.128 -		u32 *nL = (u32 *) nextLine;
  61.129 -		u32	 currentPixel;
  61.130 -		u32	 nextPixel;
  61.131 -
  61.132 -		finish	  = (u8 *) bP + ((width + 2) << 1);
  61.133 -		nextPixel = *bP++;
  61.134 -
  61.135 -		do
  61.136 -		{
  61.137 -			currentPixel = nextPixel;
  61.138 -			nextPixel	 = *bP++;
  61.139 -
  61.140 -			u32 colorA, colorB;
  61.141 -
  61.142 -#ifdef WORDS_BIGENDIAN
  61.143 -			colorA = currentPixel >> 16;
  61.144 -			colorB = currentPixel & 0xFFFF;
  61.145 -#else
  61.146 -			colorA = currentPixel & 0xFFFF;
  61.147 -			colorB = currentPixel >> 16;
  61.148 -#endif
  61.149 -
  61.150 -			*(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) +
  61.151 -			                            ((colorB & colorMask) >> 1))) << 16;
  61.152 -			colorA	= ((colorA & colorMask) >> 1);
  61.153 -			colorA += ((colorA & colorMask) >> 1);
  61.154 -			*(nL)	= colorA;
  61.155 -
  61.156 -			colorA = nextPixel & 0xFFFF;
  61.157 -
  61.158 -			*(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) +
  61.159 -			                                ((colorB & colorMask) >> 1))) << 16;
  61.160 -			colorB	= ((colorB & colorMask) >> 1);
  61.161 -			colorB += ((colorB & colorMask) >> 1);
  61.162 -
  61.163 -			*(nL + 1) = colorB;
  61.164 -
  61.165 -			dP += 2;
  61.166 -			nL += 2;
  61.167 -		}
  61.168 -		while ((u8 *) bP < finish);
  61.169 -
  61.170 -		srcPtr	 += srcPitch;
  61.171 -		dstPtr	 += dstPitch << 1;
  61.172 -		nextLine += dstPitch << 1;
  61.173 -	}
  61.174 -	while (--height);
  61.175 -}
  61.176 -
  61.177 -void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  61.178 -                   u8 *dstPtr, u32 dstPitch, int width, int height)
  61.179 -{
  61.180 -	u8 *nextLine, *finish;
  61.181 -	u32 colorMask = ~RGB_LOW_BITS_MASK;
  61.182 -
  61.183 -	nextLine = dstPtr + dstPitch;
  61.184 -
  61.185 -	do
  61.186 -	{
  61.187 -		u32 *bP = (u32 *) srcPtr;
  61.188 -		u32 *dP = (u32 *) dstPtr;
  61.189 -		u32 *nL = (u32 *) nextLine;
  61.190 -		u32	 currentPixel;
  61.191 -		u32	 nextPixel;
  61.192 -
  61.193 -		finish	  = (u8 *) bP + ((width + 1) << 2);
  61.194 -		nextPixel = *bP++;
  61.195 -
  61.196 -		do
  61.197 -		{
  61.198 -			currentPixel = nextPixel;
  61.199 -			nextPixel	 = *bP++;
  61.200 -
  61.201 -			u32 colorA, colorB, temp;
  61.202 -
  61.203 -			colorA = currentPixel;
  61.204 -			colorB = nextPixel;
  61.205 -
  61.206 -			*(dP)	  = colorA;
  61.207 -			*(dP + 1) = temp = ((colorA & colorMask) >> 1) +
  61.208 -			                   ((colorB & colorMask) >> 1);
  61.209 -			temp	= ((temp & colorMask) >> 1);
  61.210 -			temp   += ((temp & colorMask) >> 1);
  61.211 -			colorA	= ((colorA & colorMask) >> 1);
  61.212 -			colorA += ((colorA & colorMask) >> 1);
  61.213 -
  61.214 -			*(nL)	  = colorA;
  61.215 -			*(nL + 1) = temp;
  61.216 -
  61.217 -			dP += 2;
  61.218 -			nL += 2;
  61.219 -		}
  61.220 -		while ((u8 *) bP < finish);
  61.221 -
  61.222 -		srcPtr	 += srcPitch;
  61.223 -		dstPtr	 += dstPitch << 1;
  61.224 -		nextLine += dstPitch << 1;
  61.225 -	}
  61.226 -	while (--height);
  61.227 -}
  61.228 -
    62.1 --- a/src/filters/simple2x.cpp	Sat Mar 03 10:54:39 2012 -0600
    62.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.3 @@ -1,189 +0,0 @@
    62.4 -#include "../Port.h"
    62.5 -
    62.6 -void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
    62.7 -                u8 *dstPtr, u32 dstPitch, int width, int height)
    62.8 -{
    62.9 -	u8 *nextLine, *finish;
   62.10 -
   62.11 -	nextLine = dstPtr + dstPitch;
   62.12 -
   62.13 -	do
   62.14 -	{
   62.15 -		u32 *bP = (u32 *) srcPtr;
   62.16 -		u32 *dP = (u32 *) dstPtr;
   62.17 -		u32 *nL = (u32 *) nextLine;
   62.18 -		u32	 currentPixel;
   62.19 -
   62.20 -		finish		 = (u8 *) bP + ((width + 2) << 1);
   62.21 -		currentPixel = *bP++;
   62.22 -
   62.23 -		do
   62.24 -		{
   62.25 -#ifdef WORDS_BIGENDIAN
   62.26 -			u32 color = currentPixel >> 16;
   62.27 -#else
   62.28 -			u32 color = currentPixel & 0xffff;
   62.29 -#endif
   62.30 -
   62.31 -			color = color | (color << 16);
   62.32 -
   62.33 -			*(dP) = color;
   62.34 -			*(nL) = color;
   62.35 -
   62.36 -#ifdef WORDS_BIGENDIAN
   62.37 -			color = currentPixel & 0xffff;
   62.38 -#else
   62.39 -			color = currentPixel >> 16;
   62.40 -#endif
   62.41 -			color	  = color | (color << 16);
   62.42 -			*(dP + 1) = color;
   62.43 -			*(nL + 1) = color;
   62.44 -
   62.45 -			currentPixel = *bP++;
   62.46 -
   62.47 -			dP += 2;
   62.48 -			nL += 2;
   62.49 -		}
   62.50 -		while ((u8 *) bP < finish);
   62.51 -
   62.52 -		srcPtr	 += srcPitch;
   62.53 -		dstPtr	 += dstPitch << 1;
   62.54 -		nextLine += dstPitch << 1;
   62.55 -	}
   62.56 -	while (--height);
   62.57 -}
   62.58 -
   62.59 -void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
   62.60 -                u8 *dstPtr, u32 dstPitch, int width, int height)
   62.61 -{
   62.62 -	u8 *nextLine, *finish;
   62.63 -
   62.64 -	nextLine = dstPtr + dstPitch;
   62.65 -
   62.66 -	do
   62.67 -	{
   62.68 -		u32 *bP = (u32 *) srcPtr;
   62.69 -		u32 *dP = (u32 *) dstPtr;
   62.70 -		u32 *nL = (u32 *) nextLine;
   62.71 -		u32	 currentPixel;
   62.72 -
   62.73 -		finish		 = (u8 *) bP + ((width + 1) << 2);
   62.74 -		currentPixel = *bP++;
   62.75 -
   62.76 -		do
   62.77 -		{
   62.78 -			u32 color = currentPixel;
   62.79 -
   62.80 -			*(dP)	  = color;
   62.81 -			*(dP + 1) = color;
   62.82 -			*(nL)	  = color;
   62.83 -			*(nL + 1) = color;
   62.84 -
   62.85 -			currentPixel = *bP++;
   62.86 -
   62.87 -			dP += 2;
   62.88 -			nL += 2;
   62.89 -		}
   62.90 -		while ((u8 *) bP < finish);
   62.91 -
   62.92 -		srcPtr	 += srcPitch;
   62.93 -		dstPtr	 += dstPitch << 1;
   62.94 -		nextLine += dstPitch << 1;
   62.95 -	}
   62.96 -	while (--height);
   62.97 -}
   62.98 -
   62.99 -#if 0
  62.100 -// generic Simple Nx magnification filter
  62.101 -template <int magnification, typename ColorType>
  62.102 -void SimpleNx(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  62.103 -              u8 *dstPtr, u32 dstPitch, int width, int height)
  62.104 -{
  62.105 -	srcPitch = srcPitch / sizeof(ColorType) - width;
  62.106 -	u32 dstNextP = dstPitch / sizeof(ColorType);
  62.107 -	u32 dstNextL = (dstNextP - width) * magnification;  // skip to the next magnificated 'line'
  62.108 -	dstNextP -= magnification;
  62.109 -
  62.110 -	u32 offset = (dstPitch + sizeof(ColorType)) * magnification - dstPitch;
  62.111 -
  62.112 -	ColorType *src = (ColorType *)srcPtr;
  62.113 -	ColorType *dst = (ColorType *)dstPtr;
  62.114 -
  62.115 -	do // per src line
  62.116 -	{
  62.117 -		u8 *finishP = (u8 *)dst + offset;
  62.118 -		for (int x = 0; x < width; ++x) // per pixel in line
  62.119 -		{
  62.120 -			ColorType  col	   = *src;
  62.121 -			ColorType *dst2	   = dst;
  62.122 -			u8 *	   finishM = (u8 *)(dst + magnification);
  62.123 -			do // dst magnificated pixel
  62.124 -			{
  62.125 -				do
  62.126 -				{
  62.127 -					*dst2 = col;
  62.128 -				}
  62.129 -				while ((u8 *)++dst2 < finishM);
  62.130 -				dst2	+= dstNextP;
  62.131 -				finishM += dstPitch;
  62.132 -			}
  62.133 -			while ((u8 *)dst2 < finishP);
  62.134 -
  62.135 -			++src;
  62.136 -			dst		+= magnification;
  62.137 -			finishP += magnification * sizeof(ColorType);
  62.138 -		}
  62.139 -		src += srcPitch;
  62.140 -		dst += dstNextL;
  62.141 -	}
  62.142 -	while (--height);
  62.143 -}
  62.144 -
  62.145 -#else
  62.146 -
  62.147 -// generic Simple Nx magnification filter
  62.148 -template <int magnification, typename ColorType>
  62.149 -void SimpleNx(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  62.150 -              u8 *dstPtr, u32 dstPitch, int width, int height)
  62.151 -{
  62.152 -	srcPitch  = srcPitch / sizeof(ColorType) - width;
  62.153 -	dstPitch /= sizeof(ColorType);
  62.154 -	u32 dstBlank = (dstPitch - width) * magnification; // skip to the next magnificated 'line'
  62.155 -	dstPitch -= magnification;
  62.156 -
  62.157 -	ColorType *src = (ColorType *)srcPtr;
  62.158 -	ColorType *dst = (ColorType *)dstPtr;
  62.159 -
  62.160 -	do // per src line
  62.161 -	{
  62.162 -		for (int x = 0; x < width; ++x) // per pixel in src line
  62.163 -		{
  62.164 -			ColorType  col	= *src;
  62.165 -			ColorType *dst2 = dst;
  62.166 -			for (int dy = 0; dy < magnification; ++dy) // dst magnificated pixel
  62.167 -			{
  62.168 -				for (int dx = 0; dx < magnification; ++dx)
  62.169 -				{
  62.170 -					*dst2 = col;
  62.171 -					++dst2;
  62.172 -				}
  62.173 -				dst2 += dstPitch;
  62.174 -			}
  62.175 -
  62.176 -			++src;
  62.177 -			dst += magnification;
  62.178 -		}
  62.179 -		src += srcPitch;
  62.180 -		dst += dstBlank;
  62.181 -	}
  62.182 -	while (--height);
  62.183 -}
  62.184 -
  62.185 -#endif
  62.186 -
  62.187 -typedef void (*SimpleNxFP)(u8 *, u32, u8 *, u8 *, u32, int, int);
  62.188 -
  62.189 -SimpleNxFP Simple3x16 = SimpleNx<3, u16>;
  62.190 -SimpleNxFP Simple3x32 = SimpleNx<3, u32>;
  62.191 -SimpleNxFP Simple4x16 = SimpleNx<4, u16>;
  62.192 -SimpleNxFP Simple4x32 = SimpleNx<4, u32>;
    63.1 --- a/src/gb/GB.cpp	Sat Mar 03 10:54:39 2012 -0600
    63.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.3 @@ -1,3918 +0,0 @@
    63.4 -#include <cstdio>
    63.5 -#include <cstdlib>
    63.6 -#include <cstring>
    63.7 -#include <cassert>
    63.8 -
    63.9 -#include "../Port.h"
   63.10 -#include "../NLS.h"
   63.11 -#include "GB.h"
   63.12 -#include "gbCheats.h"
   63.13 -#include "gbGlobals.h"
   63.14 -#include "gbMemory.h"
   63.15 -#include "gbSGB.h"
   63.16 -#include "gbSound.h"
   63.17 -#include "../common/unzip.h"
   63.18 -#include "../common/Util.h"
   63.19 -#include "../common/System.h"
   63.20 -#include "../common/movie.h"
   63.21 -#include "../common/vbalua.h"
   63.22 -
   63.23 -#ifdef __GNUC__
   63.24 -#define _stricmp strcasecmp
   63.25 -#endif
   63.26 -
   63.27 -// FIXME: constant (GB) or boolean (GBA)?!
   63.28 -#define C_FLAG 0x10
   63.29 -#define H_FLAG 0x20
   63.30 -#define N_FLAG 0x40
   63.31 -#define Z_FLAG 0x80
   63.32 -extern soundtick_t GB_USE_TICKS_AS;
   63.33 -
   63.34 -u8 *		 origPix = NULL;
   63.35 -extern u8 *	 pix;
   63.36 -extern u32	 extButtons;
   63.37 -extern bool8 capturePrevious;
   63.38 -extern int32 captureNumber;
   63.39 -extern bool8 speedup;
   63.40 -
   63.41 -bool gbUpdateSizes();
   63.42 -
   63.43 -// debugging
   63.44 -bool memorydebug = false;
   63.45 -char gbBuffer[2048];
   63.46 -
   63.47 -extern u16 gbLineMix[160];
   63.48 -
   63.49 -// mappers
   63.50 -void (*mapper)(u16, u8)	   = NULL;
   63.51 -void (*mapperRAM)(u16, u8) = NULL;
   63.52 -u8	 (*mapperReadRAM)(u16) = NULL;
   63.53 -
   63.54 -// registers
   63.55 -gbRegister PC;
   63.56 -gbRegister SP;
   63.57 -gbRegister AF;
   63.58 -gbRegister BC;
   63.59 -gbRegister DE;
   63.60 -gbRegister HL;
   63.61 -u16		   IFF;
   63.62 -// 0xff04
   63.63 -u8 register_DIV = 0;
   63.64 -// 0xff05
   63.65 -u8 register_TIMA = 0;
   63.66 -// 0xff06
   63.67 -u8 register_TMA = 0;
   63.68 -// 0xff07
   63.69 -u8 register_TAC = 0;
   63.70 -// 0xff0f
   63.71 -u8 register_IF = 0;
   63.72 -// 0xff40
   63.73 -u8 register_LCDC = 0;
   63.74 -// 0xff41
   63.75 -u8 register_STAT = 0;
   63.76 -// 0xff42
   63.77 -u8 register_SCY = 0;
   63.78 -// 0xff43
   63.79 -u8 register_SCX = 0;
   63.80 -// 0xff44
   63.81 -u8 register_LY = 0;
   63.82 -// 0xff45
   63.83 -u8 register_LYC = 0;
   63.84 -// 0xff46
   63.85 -u8 register_DMA = 0;
   63.86 -// 0xff4a
   63.87 -u8 register_WY = 0;
   63.88 -// 0xff4b
   63.89 -u8 register_WX = 0;
   63.90 -// 0xff4f
   63.91 -u8 register_VBK = 0;
   63.92 -// 0xff51
   63.93 -u8 register_HDMA1 = 0;
   63.94 -// 0xff52
   63.95 -u8 register_HDMA2 = 0;
   63.96 -// 0xff53
   63.97 -u8 register_HDMA3 = 0;
   63.98 -// 0xff54
   63.99 -u8 register_HDMA4 = 0;
  63.100 -// 0xff55
  63.101 -u8 register_HDMA5 = 0;
  63.102 -// 0xff70
  63.103 -u8 register_SVBK = 0;
  63.104 -// 0xffff
  63.105 -u8 register_IE = 0;
  63.106 -
  63.107 -// ticks definition
  63.108 -int32 GBDIV_CLOCK_TICKS = 64;
  63.109 -int32 GBLCD_MODE_0_CLOCK_TICKS	 = 51;
  63.110 -int32 GBLCD_MODE_1_CLOCK_TICKS	 = 1140;
  63.111 -int32 GBLCD_MODE_2_CLOCK_TICKS	 = 20;
  63.112 -int32 GBLCD_MODE_3_CLOCK_TICKS	 = 43;
  63.113 -int32 GBLY_INCREMENT_CLOCK_TICKS = 114;
  63.114 -int32 GBTIMER_MODE_0_CLOCK_TICKS = 256;
  63.115 -int32 GBTIMER_MODE_1_CLOCK_TICKS = 4;
  63.116 -int32 GBTIMER_MODE_2_CLOCK_TICKS = 16;
  63.117 -int32 GBTIMER_MODE_3_CLOCK_TICKS = 64;
  63.118 -int32 GBSERIAL_CLOCK_TICKS		 = 128;
  63.119 -int32 GBSYNCHRONIZE_CLOCK_TICKS	 = 52920;
  63.120 -
  63.121 -// state variables
  63.122 -
  63.123 -// interrupt
  63.124 -int32 gbInterrupt	  = 0;
  63.125 -int32 gbInterruptWait = 0;
  63.126 -// serial
  63.127 -int32 gbSerialOn	= 0;
  63.128 -int32 gbSerialTicks = 0;
  63.129 -int32 gbSerialBits	= 0;
  63.130 -// timer
  63.131 -int32 gbTimerOn			= 0;
  63.132 -int32 gbTimerTicks		= 0;
  63.133 -int32 gbTimerClockTicks = 0;
  63.134 -int32 gbTimerMode		= 0;
  63.135 -// lcd
  63.136 -int32 gbLcdMode	 = 2;
  63.137 -int32 gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS;
  63.138 -int32 gbLcdLYIncrementTicks = 0;
  63.139 -// div
  63.140 -int32 gbDivTicks = GBDIV_CLOCK_TICKS;
  63.141 -// cgb
  63.142 -int32 gbVramBank		= 0;
  63.143 -int32 gbWramBank		= 1;
  63.144 -int32 gbHdmaSource		= 0x0000;
  63.145 -int32 gbHdmaDestination = 0x8000;
  63.146 -int32 gbHdmaBytes		= 0x0000;
  63.147 -int32 gbHdmaOn = 0;
  63.148 -int32 gbSpeed  = 0;
  63.149 -// frame counting
  63.150 -int32 gbFrameCount	   = 0;
  63.151 -int32 gbFrameSkip	   = 0;
  63.152 -int32 gbFrameSkipCount = 0;
  63.153 -// timing
  63.154 -u32	  gbLastTime		 = 0;
  63.155 -u32	  gbElapsedTime		 = 0;
  63.156 -u32	  gbTimeNow			 = 0;
  63.157 -int32 gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS;
  63.158 -int32 gbDMASpeedVersion	 = 1;
  63.159 -// emulator features
  63.160 -int32 gbBattery	   = 0;
  63.161 -int32 gbJoymask[4] = { 0, 0, 0, 0 };
  63.162 -
  63.163 -int32 gbEchoRAMFixOn = 1;
  63.164 -
  63.165 -static bool newFrame = true;
  63.166 -static bool pauseAfterFrameAdvance = false;
  63.167 -
  63.168 -int32 gbRomSizes[] = { 0x00008000, // 32K
  63.169 -	                   0x00010000, // 64K
  63.170 -	                   0x00020000, // 128K
  63.171 -	                   0x00040000, // 256K
  63.172 -	                   0x00080000, // 512K
  63.173 -	                   0x00100000, // 1024K
  63.174 -	                   0x00200000, // 2048K
  63.175 -	                   0x00400000, // 4096K
  63.176 -	                   0x00800000 // 8192K
  63.177 -};
  63.178 -int32 gbRomSizesMasks[] = { 0x00007fff,
  63.179 -	                        0x0000ffff,
  63.180 -	                        0x0001ffff,
  63.181 -	                        0x0003ffff,
  63.182 -	                        0x0007ffff,
  63.183 -	                        0x000fffff,
  63.184 -	                        0x001fffff,
  63.185 -	                        0x003fffff,
  63.186 -	                        0x007fffff };
  63.187 -
  63.188 -int32 gbRamSizes[6] = { 0x00000000, // 0K
  63.189 -	                    0x00000800, // 2K
  63.190 -	                    0x00002000, // 8K
  63.191 -	                    0x00008000, // 32K
  63.192 -	                    0x00020000, // 128K
  63.193 -	                    0x00010000 // 64K
  63.194 -};
  63.195 -
  63.196 -int32 gbRamSizesMasks[6] = { 0x00000000,
  63.197 -	                         0x000007ff,
  63.198 -	                         0x00001fff,
  63.199 -	                         0x00007fff,
  63.200 -	                         0x0001ffff,
  63.201 -	                         0x0000ffff };
  63.202 -
  63.203 -int32 gbCycles[] =
  63.204 -{
  63.205 -//  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  63.206 -	1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1,  // 0
  63.207 -	1, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1,  // 1
  63.208 -	2, 3, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1,  // 2
  63.209 -	2, 3, 2, 2, 3, 3, 3, 1, 2, 2, 2, 2, 1, 1, 2, 1,  // 3
  63.210 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // 4
  63.211 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // 5
  63.212 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // 6
  63.213 -	2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1,  // 7
  63.214 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // 8
  63.215 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // 9
  63.216 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // a
  63.217 -	1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,  // b
  63.218 -	2, 3, 3, 4, 3, 4, 2, 4, 2, 4, 3, 2, 3, 6, 2, 4,  // c
  63.219 -	2, 3, 3, 0, 3, 4, 2, 4, 2, 4, 3, 0, 3, 0, 2, 4,  // d
  63.220 -	3, 3, 2, 0, 0, 4, 2, 4, 4, 1, 4, 0, 0, 0, 2, 4,  // e
  63.221 -	3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4   // f
  63.222 -};
  63.223 -
  63.224 -int32 gbCyclesCB[] =
  63.225 -{
  63.226 -//  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  63.227 -	2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,  // 0
  63.228 -	2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,  // 1
  63.229 -	2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,  // 2
  63.230 -	2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,  // 3
  63.231 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 4
  63.232 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 5
  63.233 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 6
  63.234 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 7
  63.235 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 8
  63.236 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // 9
  63.237 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // a
  63.238 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // b
  63.239 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // c
  63.240 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // d
  63.241 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,  // e
  63.242 -	2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2   // f
  63.243 -};
  63.244 -
  63.245 -u16 DAATable[] =
  63.246 -{
  63.247 -	0x0080, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700,
  63.248 -	0x0800, 0x0900, 0x1020, 0x1120, 0x1220, 0x1320, 0x1420, 0x1520,
  63.249 -	0x1000, 0x1100, 0x1200, 0x1300, 0x1400, 0x1500, 0x1600, 0x1700,
  63.250 -	0x1800, 0x1900, 0x2020, 0x2120, 0x2220, 0x2320, 0x2420, 0x2520,
  63.251 -	0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2600, 0x2700,
  63.252 -	0x2800, 0x2900, 0x3020, 0x3120, 0x3220, 0x3320, 0x3420, 0x3520,
  63.253 -	0x3000, 0x3100, 0x3200, 0x3300, 0x3400, 0x3500, 0x3600, 0x3700,
  63.254 -	0x3800, 0x3900, 0x4020, 0x4120, 0x4220, 0x4320, 0x4420, 0x4520,
  63.255 -	0x4000, 0x4100, 0x4200, 0x4300, 0x4400, 0x4500, 0x4600, 0x4700,
  63.256 -	0x4800, 0x4900, 0x5020, 0x5120, 0x5220, 0x5320, 0x5420, 0x5520,
  63.257 -	0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x5500, 0x5600, 0x5700,
  63.258 -	0x5800, 0x5900, 0x6020, 0x6120, 0x6220, 0x6320, 0x6420, 0x6520,
  63.259 -	0x6000, 0x6100, 0x6200, 0x6300, 0x6400, 0x6500, 0x6600, 0x6700,
  63.260 -	0x6800, 0x6900, 0x7020, 0x7120, 0x7220, 0x7320, 0x7420, 0x7520,
  63.261 -	0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
  63.262 -	0x7800, 0x7900, 0x8020, 0x8120, 0x8220, 0x8320, 0x8420, 0x8520,
  63.263 -	0x8000, 0x8100, 0x8200, 0x8300, 0x8400, 0x8500, 0x8600, 0x8700,
  63.264 -	0x8800, 0x8900, 0x9020, 0x9120, 0x9220, 0x9320, 0x9420, 0x9520,
  63.265 -	0x9000, 0x9100, 0x9200, 0x9300, 0x9400, 0x9500, 0x9600, 0x9700,
  63.266 -	0x9800, 0x9900, 0x00B0, 0x0130, 0x0230, 0x0330, 0x0430, 0x0530,
  63.267 -	0x0090, 0x0110, 0x0210, 0x0310, 0x0410, 0x0510, 0x0610, 0x0710,
  63.268 -	0x0810, 0x0910, 0x1030, 0x1130, 0x1230, 0x1330, 0x1430, 0x1530,
  63.269 -	0x1010, 0x1110, 0x1210, 0x1310, 0x1410, 0x1510, 0x1610, 0x1710,
  63.270 -	0x1810, 0x1910, 0x2030, 0x2130, 0x2230, 0x2330, 0x2430, 0x2530,
  63.271 -	0x2010, 0x2110, 0x2210, 0x2310, 0x2410, 0x2510, 0x2610, 0x2710,
  63.272 -	0x2810, 0x2910, 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530,
  63.273 -	0x3010, 0x3110, 0x3210, 0x3310, 0x3410, 0x3510, 0x3610, 0x3710,
  63.274 -	0x3810, 0x3910, 0x4030, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530,
  63.275 -	0x4010, 0x4110, 0x4210, 0x4310, 0x4410, 0x4510, 0x4610, 0x4710,
  63.276 -	0x4810, 0x4910, 0x5030, 0x5130, 0x5230, 0x5330, 0x5430, 0x5530,
  63.277 -	0x5010, 0x5110, 0x5210, 0x5310, 0x5410, 0x5510, 0x5610, 0x5710,
  63.278 -	0x5810, 0x5910, 0x6030, 0x6130, 0x6230, 0x6330, 0x6430, 0x6530,
  63.279 -	0x6010, 0x6110, 0x6210, 0x6310, 0x6410, 0x6510, 0x6610, 0x6710,
  63.280 -	0x6810, 0x6910, 0x7030, 0x7130, 0x7230, 0x7330, 0x7430, 0x7530,
  63.281 -	0x7010, 0x7110, 0x7210, 0x7310, 0x7410, 0x7510, 0x7610, 0x7710,
  63.282 -	0x7810, 0x7910, 0x8030, 0x8130, 0x8230, 0x8330, 0x8430, 0x8530,
  63.283 -	0x8010, 0x8110, 0x8210, 0x8310, 0x8410, 0x8510, 0x8610, 0x8710,
  63.284 -	0x8810, 0x8910, 0x9030, 0x9130, 0x9230, 0x9330, 0x9430, 0x9530,
  63.285 -	0x9010, 0x9110, 0x9210, 0x9310, 0x9410, 0x9510, 0x9610, 0x9710,
  63.286 -	0x9810, 0x9910, 0xA030, 0xA130, 0xA230, 0xA330, 0xA430, 0xA530,
  63.287 -	0xA010, 0xA110, 0xA210, 0xA310, 0xA410, 0xA510, 0xA610, 0xA710,
  63.288 -	0xA810, 0xA910, 0xB030, 0xB130, 0xB230, 0xB330, 0xB430, 0xB530,
  63.289 -	0xB010, 0xB110, 0xB210, 0xB310, 0xB410, 0xB510, 0xB610, 0xB710,
  63.290 -	0xB810, 0xB910, 0xC030, 0xC130, 0xC230, 0xC330, 0xC430, 0xC530,
  63.291 -	0xC010, 0xC110, 0xC210, 0xC310, 0xC410, 0xC510, 0xC610, 0xC710,
  63.292 -	0xC810, 0xC910, 0xD030, 0xD130, 0xD230, 0xD330, 0xD430, 0xD530,
  63.293 -	0xD010, 0xD110, 0xD210, 0xD310, 0xD410, 0xD510, 0xD610, 0xD710,
  63.294 -	0xD810, 0xD910, 0xE030, 0xE130, 0xE230, 0xE330, 0xE430, 0xE530,
  63.295 -	0xE010, 0xE110, 0xE210, 0xE310, 0xE410, 0xE510, 0xE610, 0xE710,
  63.296 -	0xE810, 0xE910, 0xF030, 0xF130, 0xF230, 0xF330, 0xF430, 0xF530,
  63.297 -	0xF010, 0xF110, 0xF210, 0xF310, 0xF410, 0xF510, 0xF610, 0xF710,
  63.298 -	0xF810, 0xF910, 0x00B0, 0x0130, 0x0230, 0x0330, 0x0430, 0x0530,
  63.299 -	0x0090, 0x0110, 0x0210, 0x0310, 0x0410, 0x0510, 0x0610, 0x0710,
  63.300 -	0x0810, 0x0910, 0x1030, 0x1130, 0x1230, 0x1330, 0x1430, 0x1530,
  63.301 -	0x1010, 0x1110, 0x1210, 0x1310, 0x1410, 0x1510, 0x1610, 0x1710,
  63.302 -	0x1810, 0x1910, 0x2030, 0x2130, 0x2230, 0x2330, 0x2430, 0x2530,
  63.303 -	0x2010, 0x2110, 0x2210, 0x2310, 0x2410, 0x2510, 0x2610, 0x2710,
  63.304 -	0x2810, 0x2910, 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530,
  63.305 -	0x3010, 0x3110, 0x3210, 0x3310, 0x3410, 0x3510, 0x3610, 0x3710,
  63.306 -	0x3810, 0x3910, 0x4030, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530,
  63.307 -	0x4010, 0x4110, 0x4210, 0x4310, 0x4410, 0x4510, 0x4610, 0x4710,
  63.308 -	0x4810, 0x4910, 0x5030, 0x5130, 0x5230, 0x5330, 0x5430, 0x5530,
  63.309 -	0x5010, 0x5110, 0x5210, 0x5310, 0x5410, 0x5510, 0x5610, 0x5710,
  63.310 -	0x5810, 0x5910, 0x6030, 0x6130, 0x6230, 0x6330, 0x6430, 0x6530,
  63.311 -	0x0600, 0x0700, 0x0800, 0x0900, 0x0A00, 0x0B00, 0x0C00, 0x0D00,
  63.312 -	0x0E00, 0x0F00, 0x1020, 0x1120, 0x1220, 0x1320, 0x1420, 0x1520,
  63.313 -	0x1600, 0x1700, 0x1800, 0x1900, 0x1A00, 0x1B00, 0x1C00, 0x1D00,
  63.314 -	0x1E00, 0x1F00, 0x2020, 0x2120, 0x2220, 0x2320, 0x2420, 0x2520,
  63.315 -	0x2600, 0x2700, 0x2800, 0x2900, 0x2A00, 0x2B00, 0x2C00, 0x2D00,
  63.316 -	0x2E00, 0x2F00, 0x3020, 0x3120, 0x3220, 0x3320, 0x3420, 0x3520,
  63.317 -	0x3600, 0x3700, 0x3800, 0x3900, 0x3A00, 0x3B00, 0x3C00, 0x3D00,
  63.318 -	0x3E00, 0x3F00, 0x4020, 0x4120, 0x4220, 0x4320, 0x4420, 0x4520,
  63.319 -	0x4600, 0x4700, 0x4800, 0x4900, 0x4A00, 0x4B00, 0x4C00, 0x4D00,
  63.320 -	0x4E00, 0x4F00, 0x5020, 0x5120, 0x5220, 0x5320, 0x5420, 0x5520,
  63.321 -	0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x5B00, 0x5C00, 0x5D00,
  63.322 -	0x5E00, 0x5F00, 0x6020, 0x6120, 0x6220, 0x6320, 0x6420, 0x6520,
  63.323 -	0x6600, 0x6700, 0x6800, 0x6900, 0x6A00, 0x6B00, 0x6C00, 0x6D00,
  63.324 -	0x6E00, 0x6F00, 0x7020, 0x7120, 0x7220, 0x7320, 0x7420, 0x7520,
  63.325 -	0x7600, 0x7700, 0x7800, 0x7900, 0x7A00, 0x7B00, 0x7C00, 0x7D00,
  63.326 -	0x7E00, 0x7F00, 0x8020, 0x8120, 0x8220, 0x8320, 0x8420, 0x8520,
  63.327 -	0x8600, 0x8700, 0x8800, 0x8900, 0x8A00, 0x8B00, 0x8C00, 0x8D00,
  63.328 -	0x8E00, 0x8F00, 0x9020, 0x9120, 0x9220, 0x9320, 0x9420, 0x9520,
  63.329 -	0x9600, 0x9700, 0x9800, 0x9900, 0x9A00, 0x9B00, 0x9C00, 0x9D00,
  63.330 -	0x9E00, 0x9F00, 0x00B0, 0x0130, 0x0230, 0x0330, 0x0430, 0x0530,
  63.331 -	0x0610, 0x0710, 0x0810, 0x0910, 0x0A10, 0x0B10, 0x0C10, 0x0D10,
  63.332 -	0x0E10, 0x0F10, 0x1030, 0x1130, 0x1230, 0x1330, 0x1430, 0x1530,
  63.333 -	0x1610, 0x1710, 0x1810, 0x1910, 0x1A10, 0x1B10, 0x1C10, 0x1D10,
  63.334 -	0x1E10, 0x1F10, 0x2030, 0x2130, 0x2230, 0x2330, 0x2430, 0x2530,
  63.335 -	0x2610, 0x2710, 0x2810, 0x2910, 0x2A10, 0x2B10, 0x2C10, 0x2D10,
  63.336 -	0x2E10, 0x2F10, 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530,
  63.337 -	0x3610, 0x3710, 0x3810, 0x3910, 0x3A10, 0x3B10, 0x3C10, 0x3D10,
  63.338 -	0x3E10, 0x3F10, 0x4030, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530,
  63.339 -	0x4610, 0x4710, 0x4810, 0x4910, 0x4A10, 0x4B10, 0x4C10, 0x4D10,
  63.340 -	0x4E10, 0x4F10, 0x5030, 0x5130, 0x5230, 0x5330, 0x5430, 0x5530,
  63.341 -	0x5610, 0x5710, 0x5810, 0x5910, 0x5A10, 0x5B10, 0x5C10, 0x5D10,
  63.342 -	0x5E10, 0x5F10, 0x6030, 0x6130, 0x6230, 0x6330, 0x6430, 0x6530,
  63.343 -	0x6610, 0x6710, 0x6810, 0x6910, 0x6A10, 0x6B10, 0x6C10, 0x6D10,
  63.344 -	0x6E10, 0x6F10, 0x7030, 0x7130, 0x7230, 0x7330, 0x7430, 0x7530,
  63.345 -	0x7610, 0x7710, 0x7810, 0x7910, 0x7A10, 0x7B10, 0x7C10, 0x7D10,
  63.346 -	0x7E10, 0x7F10, 0x8030, 0x8130, 0x8230, 0x8330, 0x8430, 0x8530,
  63.347 -	0x8610, 0x8710, 0x8810, 0x8910, 0x8A10, 0x8B10, 0x8C10, 0x8D10,
  63.348 -	0x8E10, 0x8F10, 0x9030, 0x9130, 0x9230, 0x9330, 0x9430, 0x9530,
  63.349 -	0x9610, 0x9710, 0x9810, 0x9910, 0x9A10, 0x9B10, 0x9C10, 0x9D10,
  63.350 -	0x9E10, 0x9F10, 0xA030, 0xA130, 0xA230, 0xA330, 0xA430, 0xA530,
  63.351 -	0xA610, 0xA710, 0xA810, 0xA910, 0xAA10, 0xAB10, 0xAC10, 0xAD10,
  63.352 -	0xAE10, 0xAF10, 0xB030, 0xB130, 0xB230, 0xB330, 0xB430, 0xB530,
  63.353 -	0xB610, 0xB710, 0xB810, 0xB910, 0xBA10, 0xBB10, 0xBC10, 0xBD10,
  63.354 -	0xBE10, 0xBF10, 0xC030, 0xC130, 0xC230, 0xC330, 0xC430, 0xC530,
  63.355 -	0xC610, 0xC710, 0xC810, 0xC910, 0xCA10, 0xCB10, 0xCC10, 0xCD10,
  63.356 -	0xCE10, 0xCF10, 0xD030, 0xD130, 0xD230, 0xD330, 0xD430, 0xD530,
  63.357 -	0xD610, 0xD710, 0xD810, 0xD910, 0xDA10, 0xDB10, 0xDC10, 0xDD10,
  63.358 -	0xDE10, 0xDF10, 0xE030, 0xE130, 0xE230, 0xE330, 0xE430, 0xE530,
  63.359 -	0xE610, 0xE710, 0xE810, 0xE910, 0xEA10, 0xEB10, 0xEC10, 0xED10,
  63.360 -	0xEE10, 0xEF10, 0xF030, 0xF130, 0xF230, 0xF330, 0xF430, 0xF530,
  63.361 -	0xF610, 0xF710, 0xF810, 0xF910, 0xFA10, 0xFB10, 0xFC10, 0xFD10,
  63.362 -	0xFE10, 0xFF10, 0x00B0, 0x0130, 0x0230, 0x0330, 0x0430, 0x0530,
  63.363 -	0x0610, 0x0710, 0x0810, 0x0910, 0x0A10, 0x0B10, 0x0C10, 0x0D10,
  63.364 -	0x0E10, 0x0F10, 0x1030, 0x1130, 0x1230, 0x1330, 0x1430, 0x1530,
  63.365 -	0x1610, 0x1710, 0x1810, 0x1910, 0x1A10, 0x1B10, 0x1C10, 0x1D10,
  63.366 -	0x1E10, 0x1F10, 0x2030, 0x2130, 0x2230, 0x2330, 0x2430, 0x2530,
  63.367 -	0x2610, 0x2710, 0x2810, 0x2910, 0x2A10, 0x2B10, 0x2C10, 0x2D10,
  63.368 -	0x2E10, 0x2F10, 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530,
  63.369 -	0x3610, 0x3710, 0x3810, 0x3910, 0x3A10, 0x3B10, 0x3C10, 0x3D10,
  63.370 -	0x3E10, 0x3F10, 0x4030, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530,
  63.371 -	0x4610, 0x4710, 0x4810, 0x4910, 0x4A10, 0x4B10, 0x4C10, 0x4D10,
  63.372 -	0x4E10, 0x4F10, 0x5030, 0x5130, 0x5230, 0x5330, 0x5430, 0x5530,
  63.373 -	0x5610, 0x5710, 0x5810, 0x5910, 0x5A10, 0x5B10, 0x5C10, 0x5D10,
  63.374 -	0x5E10, 0x5F10, 0x6030, 0x6130, 0x6230, 0x6330, 0x6430, 0x6530,
  63.375 -	0x00C0, 0x0140, 0x0240, 0x0340, 0x0440, 0x0540, 0x0640, 0x0740,
  63.376 -	0x0840, 0x0940, 0x0440, 0x0540, 0x0640, 0x0740, 0x0840, 0x0940,
  63.377 -	0x1040, 0x1140, 0x1240, 0x1340, 0x1440, 0x1540, 0x1640, 0x1740,
  63.378 -	0x1840, 0x1940, 0x1440, 0x1540, 0x1640, 0x1740, 0x1840, 0x1940,
  63.379 -	0x2040, 0x2140, 0x2240, 0x2340, 0x2440, 0x2540, 0x2640, 0x2740,
  63.380 -	0x2840, 0x2940, 0x2440, 0x2540, 0x2640, 0x2740, 0x2840, 0x2940,
  63.381 -	0x3040, 0x3140, 0x3240, 0x3340, 0x3440, 0x3540, 0x3640, 0x3740,
  63.382 -	0x3840, 0x3940, 0x3440, 0x3540, 0x3640, 0x3740, 0x3840, 0x3940,
  63.383 -	0x4040, 0x4140, 0x4240, 0x4340, 0x4440, 0x4540, 0x4640, 0x4740,
  63.384 -	0x4840, 0x4940, 0x4440, 0x4540, 0x4640, 0x4740, 0x4840, 0x4940,
  63.385 -	0x5040, 0x5140, 0x5240, 0x5340, 0x5440, 0x5540, 0x5640, 0x5740,
  63.386 -	0x5840, 0x5940, 0x5440, 0x5540, 0x5640, 0x5740, 0x5840, 0x5940,
  63.387 -	0x6040, 0x6140, 0x6240, 0x6340, 0x6440, 0x6540, 0x6640, 0x6740,
  63.388 -	0x6840, 0x6940, 0x6440, 0x6540, 0x6640, 0x6740, 0x6840, 0x6940,
  63.389 -	0x7040, 0x7140, 0x7240, 0x7340, 0x7440, 0x7540, 0x7640, 0x7740,
  63.390 -	0x7840, 0x7940, 0x7440, 0x7540, 0x7640, 0x7740, 0x7840, 0x7940,
  63.391 -	0x8040, 0x8140, 0x8240, 0x8340, 0x8440, 0x8540, 0x8640, 0x8740,
  63.392 -	0x8840, 0x8940, 0x8440, 0x8540, 0x8640, 0x8740, 0x8840, 0x8940,
  63.393 -	0x9040, 0x9140, 0x9240, 0x9340, 0x9440, 0x9540, 0x9640, 0x9740,
  63.394 -	0x9840, 0x9940, 0x3450, 0x3550, 0x3650, 0x3750, 0x3850, 0x3950,
  63.395 -	0x4050, 0x4150, 0x4250, 0x4350, 0x4450, 0x4550, 0x4650, 0x4750,
  63.396 -	0x4850, 0x4950, 0x4450, 0x4550, 0x4650, 0x4750, 0x4850, 0x4950,
  63.397 -	0x5050, 0x5150, 0x5250, 0x5350, 0x5450, 0x5550, 0x5650, 0x5750,
  63.398 -	0x5850, 0x5950, 0x5450, 0x5550, 0x5650, 0x5750, 0x5850, 0x5950,
  63.399 -	0x6050, 0x6150, 0x6250, 0x6350, 0x6450, 0x6550, 0x6650, 0x6750,
  63.400 -	0x6850, 0x6950, 0x6450, 0x6550, 0x6650, 0x6750, 0x6850, 0x6950,
  63.401 -	0x7050, 0x7150, 0x7250, 0x7350, 0x7450, 0x7550, 0x7650, 0x7750,
  63.402 -	0x7850, 0x7950, 0x7450, 0x7550, 0x7650, 0x7750, 0x7850, 0x7950,
  63.403 -	0x8050, 0x8150, 0x8250, 0x8350, 0x8450, 0x8550, 0x8650, 0x8750,
  63.404 -	0x8850, 0x8950, 0x8450, 0x8550, 0x8650, 0x8750, 0x8850, 0x8950,
  63.405 -	0x9050, 0x9150, 0x9250, 0x9350, 0x9450, 0x9550, 0x9650, 0x9750,
  63.406 -	0x9850, 0x9950, 0x9450, 0x9550, 0x9650, 0x9750, 0x9850, 0x9950,
  63.407 -	0xA050, 0xA150, 0xA250, 0xA350, 0xA450, 0xA550, 0xA650, 0xA750,
  63.408 -	0xA850, 0xA950, 0xA450, 0xA550, 0xA650, 0xA750, 0xA850, 0xA950,
  63.409 -	0xB050, 0xB150, 0xB250, 0xB350, 0xB450, 0xB550, 0xB650, 0xB750,
  63.410 -	0xB850, 0xB950, 0xB450, 0xB550, 0xB650, 0xB750, 0xB850, 0xB950,
  63.411 -	0xC050, 0xC150, 0xC250, 0xC350, 0xC450, 0xC550, 0xC650, 0xC750,
  63.412 -	0xC850, 0xC950, 0xC450, 0xC550, 0xC650, 0xC750, 0xC850, 0xC950,
  63.413 -	0xD050, 0xD150, 0xD250, 0xD350, 0xD450, 0xD550, 0xD650, 0xD750,
  63.414 -	0xD850, 0xD950, 0xD450, 0xD550, 0xD650, 0xD750, 0xD850, 0xD950,
  63.415 -	0xE050, 0xE150, 0xE250, 0xE350, 0xE450, 0xE550, 0xE650, 0xE750,
  63.416 -	0xE850, 0xE950, 0xE450, 0xE550, 0xE650, 0xE750, 0xE850, 0xE950,
  63.417 -	0xF050, 0xF150, 0xF250, 0xF350, 0xF450, 0xF550, 0xF650, 0xF750,
  63.418 -	0xF850, 0xF950, 0xF450, 0xF550, 0xF650, 0xF750, 0xF850, 0xF950,
  63.419 -	0x00D0, 0x0150, 0x0250, 0x0350, 0x0450, 0x0550, 0x0650, 0x0750,
  63.420 -	0x0850, 0x0950, 0x0450, 0x0550, 0x0650, 0x0750, 0x0850, 0x0950,
  63.421 -	0x1050, 0x1150, 0x1250, 0x1350, 0x1450, 0x1550, 0x1650, 0x1750,
  63.422 -	0x1850, 0x1950, 0x1450, 0x1550, 0x1650, 0x1750, 0x1850, 0x1950,
  63.423 -	0x2050, 0x2150, 0x2250, 0x2350, 0x2450, 0x2550, 0x2650, 0x2750,
  63.424 -	0x2850, 0x2950, 0x2450, 0x2550, 0x2650, 0x2750, 0x2850, 0x2950,
  63.425 -	0x3050, 0x3150, 0x3250, 0x3350, 0x3450, 0x3550, 0x3650, 0x3750,
  63.426 -	0x3850, 0x3950, 0x3450, 0x3550, 0x3650, 0x3750, 0x3850, 0x3950,
  63.427 -	0x4050, 0x4150, 0x4250, 0x4350, 0x4450, 0x4550, 0x4650, 0x4750,
  63.428 -	0x4850, 0x4950, 0x4450, 0x4550, 0x4650, 0x4750, 0x4850, 0x4950,
  63.429 -	0x5050, 0x5150, 0x5250, 0x5350, 0x5450, 0x5550, 0x5650, 0x5750,
  63.430 -	0x5850, 0x5950, 0x5450, 0x5550, 0x5650, 0x5750, 0x5850, 0x5950,
  63.431 -	0x6050, 0x6150, 0x6250, 0x6350, 0x6450, 0x6550, 0x6650, 0x6750,
  63.432 -	0x6850, 0x6950, 0x6450, 0x6550, 0x6650, 0x6750, 0x6850, 0x6950,
  63.433 -	0x7050, 0x7150, 0x7250, 0x7350, 0x7450, 0x7550, 0x7650, 0x7750,
  63.434 -	0x7850, 0x7950, 0x7450, 0x7550, 0x7650, 0x7750, 0x7850, 0x7950,
  63.435 -	0x8050, 0x8150, 0x8250, 0x8350, 0x8450, 0x8550, 0x8650, 0x8750,
  63.436 -	0x8850, 0x8950, 0x8450, 0x8550, 0x8650, 0x8750, 0x8850, 0x8950,
  63.437 -	0x9050, 0x9150, 0x9250, 0x9350, 0x9450, 0x9550, 0x9650, 0x9750,
  63.438 -	0x9850, 0x9950, 0x9450, 0x9550, 0x9650, 0x9750, 0x9850, 0x9950,
  63.439 -	0xFA60, 0xFB60, 0xFC60, 0xFD60, 0xFE60, 0xFF60, 0x00C0, 0x0140,
  63.440 -	0x0240, 0x0340, 0x0440, 0x0540, 0x0640, 0x0740, 0x0840, 0x0940,
  63.441 -	0x0A60, 0x0B60, 0x0C60, 0x0D60, 0x0E60, 0x0F60, 0x1040, 0x1140,
  63.442 -	0x1240, 0x1340, 0x1440, 0x1540, 0x1640, 0x1740, 0x1840, 0x1940,
  63.443 -	0x1A60, 0x1B60, 0x1C60, 0x1D60, 0x1E60, 0x1F60, 0x2040, 0x2140,
  63.444 -	0x2240, 0x2340, 0x2440, 0x2540, 0x2640, 0x2740, 0x2840, 0x2940,
  63.445 -	0x2A60, 0x2B60, 0x2C60, 0x2D60, 0x2E60, 0x2F60, 0x3040, 0x3140,
  63.446 -	0x3240, 0x3340, 0x3440, 0x3540, 0x3640, 0x3740, 0x3840, 0x3940,
  63.447 -	0x3A60, 0x3B60, 0x3C60, 0x3D60, 0x3E60, 0x3F60, 0x4040, 0x4140,
  63.448 -	0x4240, 0x4340, 0x4440, 0x4540, 0x4640, 0x4740, 0x4840, 0x4940,
  63.449 -	0x4A60, 0x4B60, 0x4C60, 0x4D60, 0x4E60, 0x4F60, 0x5040, 0x5140,
  63.450 -	0x5240, 0x5340, 0x5440, 0x5540, 0x5640, 0x5740, 0x5840, 0x5940,
  63.451 -	0x5A60, 0x5B60, 0x5C60, 0x5D60, 0x5E60, 0x5F60, 0x6040, 0x6140,
  63.452 -	0x6240, 0x6340, 0x6440, 0x6540, 0x6640, 0x6740, 0x6840, 0x6940,
  63.453 -	0x6A60, 0x6B60, 0x6C60, 0x6D60, 0x6E60, 0x6F60, 0x7040, 0x7140,
  63.454 -	0x7240, 0x7340, 0x7440, 0x7540, 0x7640, 0x7740, 0x7840, 0x7940,
  63.455 -	0x7A60, 0x7B60, 0x7C60, 0x7D60, 0x7E60, 0x7F60, 0x8040, 0x8140,
  63.456 -	0x8240, 0x8340, 0x8440, 0x8540, 0x8640, 0x8740, 0x8840, 0x8940,
  63.457 -	0x8A60, 0x8B60, 0x8C60, 0x8D60, 0x8E60, 0x8F60, 0x9040, 0x9140,
  63.458 -	0x9240, 0x9340, 0x3450, 0x3550, 0x3650, 0x3750, 0x3850, 0x3950,
  63.459 -	0x3A70, 0x3B70, 0x3C70, 0x3D70, 0x3E70, 0x3F70, 0x4050, 0x4150,
  63.460 -	0x4250, 0x4350, 0x4450, 0x4550, 0x4650, 0x4750, 0x4850, 0x4950,
  63.461 -	0x4A70, 0x4B70, 0x4C70, 0x4D70, 0x4E70, 0x4F70, 0x5050, 0x5150,
  63.462 -	0x5250, 0x5350, 0x5450, 0x5550, 0x5650, 0x5750, 0x5850, 0x5950,
  63.463 -	0x5A70, 0x5B70, 0x5C70, 0x5D70, 0x5E70, 0x5F70, 0x6050, 0x6150,
  63.464 -	0x6250, 0x6350, 0x6450, 0x6550, 0x6650, 0x6750, 0x6850, 0x6950,
  63.465 -	0x6A70, 0x6B70, 0x6C70, 0x6D70, 0x6E70, 0x6F70, 0x7050, 0x7150,
  63.466 -	0x7250, 0x7350, 0x7450, 0x7550, 0x7650, 0x7750, 0x7850, 0x7950,
  63.467 -	0x7A70, 0x7B70, 0x7C70, 0x7D70, 0x7E70, 0x7F70, 0x8050, 0x8150,
  63.468 -	0x8250, 0x8350, 0x8450, 0x8550, 0x8650, 0x8750, 0x8850, 0x8950,
  63.469 -	0x8A70, 0x8B70, 0x8C70, 0x8D70, 0x8E70, 0x8F70, 0x9050, 0x9150,
  63.470 -	0x9250, 0x9350, 0x9450, 0x9550, 0x9650, 0x9750, 0x9850, 0x9950,
  63.471 -	0x9A70, 0x9B70, 0x9C70, 0x9D70, 0x9E70, 0x9F70, 0xA050, 0xA150,
  63.472 -	0xA250, 0xA350, 0xA450, 0xA550, 0xA650, 0xA750, 0xA850, 0xA950,
  63.473 -	0xAA70, 0xAB70, 0xAC70, 0xAD70, 0xAE70, 0xAF70, 0xB050, 0xB150,
  63.474 -	0xB250, 0xB350, 0xB450, 0xB550, 0xB650, 0xB750, 0xB850, 0xB950,
  63.475 -	0xBA70, 0xBB70, 0xBC70, 0xBD70, 0xBE70, 0xBF70, 0xC050, 0xC150,
  63.476 -	0xC250, 0xC350, 0xC450, 0xC550, 0xC650, 0xC750, 0xC850, 0xC950,
  63.477 -	0xCA70, 0xCB70, 0xCC70, 0xCD70, 0xCE70, 0xCF70, 0xD050, 0xD150,
  63.478 -	0xD250, 0xD350, 0xD450, 0xD550, 0xD650, 0xD750, 0xD850, 0xD950,
  63.479 -	0xDA70, 0xDB70, 0xDC70, 0xDD70, 0xDE70, 0xDF70, 0xE050, 0xE150,
  63.480 -	0xE250, 0xE350, 0xE450, 0xE550, 0xE650, 0xE750, 0xE850, 0xE950,
  63.481 -	0xEA70, 0xEB70, 0xEC70, 0xED70, 0xEE70, 0xEF70, 0xF050, 0xF150,
  63.482 -	0xF250, 0xF350, 0xF450, 0xF550, 0xF650, 0xF750, 0xF850, 0xF950,
  63.483 -	0xFA70, 0xFB70, 0xFC70, 0xFD70, 0xFE70, 0xFF70, 0x00D0, 0x0150,
  63.484 -	0x0250, 0x0350, 0x0450, 0x0550, 0x0650, 0x0750, 0x0850, 0x0950,
  63.485 -	0x0A70, 0x0B70, 0x0C70, 0x0D70, 0x0E70, 0x0F70, 0x1050, 0x1150,
  63.486 -	0x1250, 0x1350, 0x1450, 0x1550, 0x1650, 0x1750, 0x1850, 0x1950,
  63.487 -	0x1A70, 0x1B70, 0x1C70, 0x1D70, 0x1E70, 0x1F70, 0x2050, 0x2150,
  63.488 -	0x2250, 0x2350, 0x2450, 0x2550, 0x2650, 0x2750, 0x2850, 0x2950,
  63.489 -	0x2A70, 0x2B70, 0x2C70, 0x2D70, 0x2E70, 0x2F70, 0x3050, 0x3150,
  63.490 -	0x3250, 0x3350, 0x3450, 0x3550, 0x3650, 0x3750, 0x3850, 0x3950,
  63.491 -	0x3A70, 0x3B70, 0x3C70, 0x3D70, 0x3E70, 0x3F70, 0x4050, 0x4150,
  63.492 -	0x4250, 0x4350, 0x4450, 0x4550, 0x4650, 0x4750, 0x4850, 0x4950,
  63.493 -	0x4A70, 0x4B70, 0x4C70, 0x4D70, 0x4E70, 0x4F70, 0x5050, 0x5150,
  63.494 -	0x5250, 0x5350, 0x5450, 0x5550, 0x5650, 0x5750, 0x5850, 0x5950,
  63.495 -	0x5A70, 0x5B70, 0x5C70, 0x5D70, 0x5E70, 0x5F70, 0x6050, 0x6150,
  63.496 -	0x6250, 0x6350, 0x6450, 0x6550, 0x6650, 0x6750, 0x6850, 0x6950,
  63.497 -	0x6A70, 0x6B70, 0x6C70, 0x6D70, 0x6E70, 0x6F70, 0x7050, 0x7150,
  63.498 -	0x7250, 0x7350, 0x7450, 0x7550, 0x7650, 0x7750, 0x7850, 0x7950,
  63.499 -	0x7A70, 0x7B70, 0x7C70, 0x7D70, 0x7E70, 0x7F70, 0x8050, 0x8150,
  63.500 -	0x8250, 0x8350, 0x8450, 0x8550, 0x8650, 0x8750, 0x8850, 0x8950,
  63.501 -	0x8A70, 0x8B70, 0x8C70, 0x8D70, 0x8E70, 0x8F70, 0x9050, 0x9150,
  63.502 -	0x9250, 0x9350, 0x9450, 0x9550, 0x9650, 0x9750, 0x9850, 0x9950,
  63.503 -};
  63.504 -
  63.505 -u8 ZeroTable[] =
  63.506 -{
  63.507 -	0x80, 0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.508 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.509 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.510 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.511 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.512 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.513 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.514 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.515 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.516 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.517 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.518 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.519 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.520 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.521 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,
  63.522 -	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0,	0,	  0
  63.523 -};
  63.524 -
  63.525 -#define GBSAVE_GAME_VERSION_1 1
  63.526 -#define GBSAVE_GAME_VERSION_2 2
  63.527 -#define GBSAVE_GAME_VERSION_3 3
  63.528 -#define GBSAVE_GAME_VERSION_4 4
  63.529 -#define GBSAVE_GAME_VERSION_5 5
  63.530 -#define GBSAVE_GAME_VERSION_6 6
  63.531 -#define GBSAVE_GAME_VERSION_7 7
  63.532 -#define GBSAVE_GAME_VERSION_8 8
  63.533 -#define GBSAVE_GAME_VERSION_9 9
  63.534 -#define GBSAVE_GAME_VERSION_10 10
  63.535 -#define GBSAVE_GAME_VERSION_11 11
  63.536 -#define GBSAVE_GAME_VERSION_12 12
  63.537 -#define GBSAVE_GAME_VERSION_13 13
  63.538 -#define GBSAVE_GAME_VERSION GBSAVE_GAME_VERSION_13
  63.539 -
  63.540 -int inline gbGetValue(int min, int max, int v)
  63.541 -{
  63.542 -	return (int)(min + (float)(max - min) * (2.0 * (v / 31.0) - (v / 31.0) * (v / 31.0)));
  63.543 -}
  63.544 -
  63.545 -void gbGenFilter()
  63.546 -{
  63.547 -	for (int r = 0; r < 32; r++)
  63.548 -	{
  63.549 -		for (int g = 0; g < 32; g++)
  63.550 -		{
  63.551 -			for (int b = 0; b < 32; b++)
  63.552 -			{
  63.553 -				int nr = gbGetValue(gbGetValue(4, 14, g),
  63.554 -				                    gbGetValue(24, 29, g), r) - 4;
  63.555 -				int ng = gbGetValue(gbGetValue(4 + gbGetValue(0, 5, r),
  63.556 -				                               14 + gbGetValue(0, 3, r), b),
  63.557 -				                    gbGetValue(24 + gbGetValue(0, 3, r),
  63.558 -				                               29 + gbGetValue(0, 1, r), b), g) - 4;
  63.559 -				int nb = gbGetValue(gbGetValue(4 + gbGetValue(0, 5, r),
  63.560 -				                               14 + gbGetValue(0, 3, r), g),
  63.561 -				                    gbGetValue(24 + gbGetValue(0, 3, r),
  63.562 -				                               29 + gbGetValue(0, 1, r), g), b) - 4;
  63.563 -				gbColorFilter[(b << 10) | (g << 5) | r] = (nb << 10) | (ng << 5) | nr;
  63.564 -			}
  63.565 -		}
  63.566 -	}
  63.567 -}
  63.568 -
  63.569 -void gbCopyMemory(u16 d, u16 s, int count)
  63.570 -{
  63.571 -	while (count)
  63.572 -	{
  63.573 -		gbWriteMemoryQuick(d, gbReadMemoryQuick(s));
  63.574 -		s++;
  63.575 -		d++;
  63.576 -		count--;
  63.577 -	}
  63.578 -}
  63.579 -
  63.580 -void gbDoHdma()
  63.581 -{
  63.582 -	gbCopyMemory(gbHdmaDestination, gbHdmaSource, 0x10);
  63.583 -
  63.584 -	gbHdmaDestination += 0x10;
  63.585 -	gbHdmaSource	  += 0x10;
  63.586 -
  63.587 -	register_HDMA2 = (register_HDMA2 + 0x10) & 0xFF;
  63.588 -	if (register_HDMA2 == 0x00)
  63.589 -		register_HDMA1++;
  63.590 -
  63.591 -	register_HDMA4 = (register_HDMA4 + 0x10) & 0xFF;
  63.592 -	if (register_HDMA4 == 0x00)
  63.593 -		register_HDMA3++;
  63.594 -
  63.595 -	if (gbHdmaDestination == 0x96b0)
  63.596 -		gbHdmaBytes = gbHdmaBytes;
  63.597 -	gbHdmaBytes -= 0x10;
  63.598 -	register_HDMA5--;
  63.599 -	if (register_HDMA5 == 0xff)
  63.600 -		gbHdmaOn = 0;
  63.601 -}
  63.602 -
  63.603 -// fix for Harley and Lego Racers
  63.604 -void gbCompareLYToLYC()
  63.605 -{
  63.606 -	if (register_LY == register_LYC)
  63.607 -	{
  63.608 -		// mark that we have a match
  63.609 -		register_STAT |= 4;
  63.610 -
  63.611 -		// check if we need an interrupt
  63.612 -		if ((register_STAT & 0x40) && (register_IE & 2))
  63.613 -			gbInterrupt |= 2;
  63.614 -	}
  63.615 -	else   // no match
  63.616 -		register_STAT &= 0xfb;
  63.617 -}
  63.618 -
  63.619 -// FIXME: horrible kludge to workaround the frame timing bug
  63.620 -static int32 s_gbJoymask[4] = { 0, 0, 0, 0 };
  63.621 -
  63.622 -void gbWriteMemoryWrapped(register u16 address, register u8 value)
  63.623 -{
  63.624 -	if (address < 0x8000)
  63.625 -	{
  63.626 -#ifndef FINAL_VERSION
  63.627 -		if (memorydebug && (address > 0x3fff || address < 0x2000))
  63.628 -		{
  63.629 -			log("Memory register write %04x=%02x PC=%04x\n",
  63.630 -			    address,
  63.631 -			    value,
  63.632 -			    PC.W);
  63.633 -		}
  63.634 -#endif
  63.635 -		if (mapper)
  63.636 -			(*mapper)(address, value);
  63.637 -		return;
  63.638 -	}
  63.639 -
  63.640 -	if (address < 0xa000)
  63.641 -	{
  63.642 -		gbWriteMemoryQuick(address, value);
  63.643 -		return;
  63.644 -	}
  63.645 -
  63.646 -	if (address < 0xc000)
  63.647 -	{
  63.648 -#ifndef FINAL_VERSION
  63.649 -		if (memorydebug)
  63.650 -		{
  63.651 -			log("Memory register write %04x=%02x PC=%04x\n",
  63.652 -			    address,
  63.653 -			    value,
  63.654 -			    PC.W);
  63.655 -		}
  63.656 -#endif
  63.657 -
  63.658 -		if (mapper)
  63.659 -			(*mapperRAM)(address, value);
  63.660 -		return;
  63.661 -	}
  63.662 -
  63.663 -	if (address < 0xfe00)
  63.664 -	{
  63.665 -		gbWriteMemoryQuick(address, value);
  63.666 -		return;
  63.667 -	}
  63.668 -
  63.669 -	if (address < 0xff00)
  63.670 -	{
  63.671 -		gbMemory[address] = value;
  63.672 -		return;
  63.673 -	}
  63.674 -
  63.675 -	switch (address & 0x00ff)
  63.676 -	{
  63.677 -	case 0x00:
  63.678 -	{
  63.679 -		gbMemory[0xff00] = ((gbMemory[0xff00] & 0xcf) |
  63.680 -		                    (value & 0x30));
  63.681 -		if (gbSgbMode)
  63.682 -		{
  63.683 -			gbSgbDoBitTransfer(value);
  63.684 -		}
  63.685 -
  63.686 -		return;
  63.687 -	}
  63.688 -
  63.689 -	case 0x01:
  63.690 -	{
  63.691 -		gbMemory[0xff01] = value;
  63.692 -		return;
  63.693 -	}
  63.694 -
  63.695 -	// serial control
  63.696 -	case 0x02:
  63.697 -	{
  63.698 -		gbSerialOn		 = (value & 0x80);
  63.699 -		gbMemory[0xff02] = value;
  63.700 -		if (gbSerialOn)
  63.701 -		{
  63.702 -			gbSerialTicks = GBSERIAL_CLOCK_TICKS;
  63.703 -#ifdef LINK_EMULATION
  63.704 -			if (linkConnected)
  63.705 -			{
  63.706 -				if (value & 1)
  63.707 -				{
  63.708 -					linkSendByte(0x100 | gbMemory[0xFF01]);
  63.709 -					Sleep(5);
  63.710 -				}
  63.711 -			}
  63.712 -#endif
  63.713 -		}
  63.714 -
  63.715 -		gbSerialBits = 0;
  63.716 -		return;
  63.717 -	}
  63.718 -
  63.719 -	// DIV register resets on any write
  63.720 -	case 0x04:
  63.721 -	{
  63.722 -		register_DIV = 0;
  63.723 -		return;
  63.724 -	}
  63.725 -	case 0x05:
  63.726 -		register_TIMA = value;
  63.727 -		return;
  63.728 -
  63.729 -	case 0x06:
  63.730 -		register_TMA = value;
  63.731 -		return;
  63.732 -
  63.733 -	// TIMER control
  63.734 -	case 0x07:
  63.735 -	{
  63.736 -		register_TAC = value;
  63.737 -
  63.738 -		gbTimerOn	= (value & 4);
  63.739 -		gbTimerMode = value & 3;
  63.740 -		//    register_TIMA = register_TMA;
  63.741 -		switch (gbTimerMode)
  63.742 -		{
  63.743 -		case 0:
  63.744 -			gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_0_CLOCK_TICKS;
  63.745 -			break;
  63.746 -		case 1:
  63.747 -			gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_1_CLOCK_TICKS;
  63.748 -			break;
  63.749 -		case 2:
  63.750 -			gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_2_CLOCK_TICKS;
  63.751 -			break;
  63.752 -		case 3:
  63.753 -			gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_3_CLOCK_TICKS;
  63.754 -			break;
  63.755 -		}
  63.756 -		return;
  63.757 -	}
  63.758 -
  63.759 -	case 0x0f:
  63.760 -	{
  63.761 -		register_IF = value;
  63.762 -		gbInterrupt = value;
  63.763 -		return;
  63.764 -	}
  63.765 -
  63.766 -	case 0x10:
  63.767 -	case 0x11:
  63.768 -	case 0x12:
  63.769 -	case 0x13:
  63.770 -	case 0x14:
  63.771 -	case 0x15:
  63.772 -	case 0x16:
  63.773 -	case 0x17:
  63.774 -	case 0x18:
  63.775 -	case 0x19:
  63.776 -	case 0x1a:
  63.777 -	case 0x1b:
  63.778 -	case 0x1c:
  63.779 -	case 0x1d:
  63.780 -	case 0x1e:
  63.781 -	case 0x1f:
  63.782 -	case 0x20:
  63.783 -	case 0x21:
  63.784 -	case 0x22:
  63.785 -	case 0x23:
  63.786 -	case 0x24:
  63.787 -	case 0x25:
  63.788 -	case 0x26:
  63.789 -	{
  63.790 -		SOUND_EVENT(address, value);
  63.791 -		return;
  63.792 -	}
  63.793 -	case 0x40:
  63.794 -	{
  63.795 -		int lcdChange = (register_LCDC & 0x80) ^ (value & 0x80);
  63.796 -
  63.797 -		if (lcdChange)
  63.798 -		{
  63.799 -			if (value & 0x80)
  63.800 -			{
  63.801 -				gbLcdTicks	   = GBLCD_MODE_1_CLOCK_TICKS;
  63.802 -				gbLcdMode	   = 0;
  63.803 -				register_STAT &= 0xfc;
  63.804 -				register_LY	   = 0x00;
  63.805 -				// FIXME: horrible workaround
  63.806 -				if (gbNullInputHackTempEnabled && !useOldFrameTiming)
  63.807 -					memcpy(gbJoymask, s_gbJoymask, sizeof(gbJoymask));
  63.808 -			}
  63.809 -			else
  63.810 -			{
  63.811 -				gbLcdTicks	   = 0;
  63.812 -				gbLcdMode	   = 0;
  63.813 -				register_STAT &= 0xfc;
  63.814 -				register_LY	   = 0x00;
  63.815 -				// FIXME: horrible workaround
  63.816 -				memcpy(s_gbJoymask, gbJoymask, sizeof(gbJoymask));
  63.817 -				if (gbNullInputHackTempEnabled && !useOldFrameTiming)
  63.818 -					memset(gbJoymask, 0, sizeof(gbJoymask));
  63.819 -			}
  63.820 -			//      compareLYToLYC();
  63.821 -		}
  63.822 -		// don't draw the window if it was not enabled and not being drawn before
  63.823 -		if (!(register_LCDC & 0x20) && (value & 0x20) && gbWindowLine == -1 &&
  63.824 -		    register_LY > register_WY)
  63.825 -			gbWindowLine = 144;
  63.826 -
  63.827 -		register_LCDC = value;
  63.828 -
  63.829 -		return;
  63.830 -	}
  63.831 -
  63.832 -	// STAT
  63.833 -	case 0x41:
  63.834 -	{
  63.835 -		//register_STAT = (register_STAT & 0x87) |
  63.836 -		//      (value & 0x7c);
  63.837 -		register_STAT = (value & 0xf8) | (register_STAT & 0x07);     // fix ?
  63.838 -		// GB bug from Devrs FAQ
  63.839 -		if (!gbCgbMode && (register_LCDC & 0x80) && gbLcdMode < 2)
  63.840 -			gbInterrupt |= 2;
  63.841 -		return;
  63.842 -	}
  63.843 -
  63.844 -	// SCY
  63.845 -	case 0x42:
  63.846 -	{
  63.847 -		register_SCY = value;
  63.848 -		return;
  63.849 -	}
  63.850 -
  63.851 -	// SCX
  63.852 -	case 0x43:
  63.853 -	{
  63.854 -		register_SCX = value;
  63.855 -		return;
  63.856 -	}
  63.857 -
  63.858 -	// LY
  63.859 -	case 0x44:
  63.860 -	{
  63.861 -		// read only
  63.862 -		return;
  63.863 -	}
  63.864 -
  63.865 -	// LYC
  63.866 -	case 0x45:
  63.867 -	{
  63.868 -		register_LYC = value;
  63.869 -		if ((register_LCDC & 0x80))
  63.870 -		{
  63.871 -			gbCompareLYToLYC();
  63.872 -		}
  63.873 -		return;
  63.874 -	}
  63.875 -
  63.876 -	// DMA!
  63.877 -	case 0x46:
  63.878 -	{
  63.879 -		int source = value * 0x0100;
  63.880 -
  63.881 -		gbCopyMemory(0xfe00,
  63.882 -		             source,
  63.883 -		             0xa0);
  63.884 -		register_DMA = value;
  63.885 -		return;
  63.886 -	}
  63.887 -
  63.888 -	// BGP
  63.889 -	case 0x47:
  63.890 -	{
  63.891 -		gbBgp[0] = value & 0x03;
  63.892 -		gbBgp[1] = (value & 0x0c) >> 2;
  63.893 -		gbBgp[2] = (value & 0x30) >> 4;
  63.894 -		gbBgp[3] = (value & 0xc0) >> 6;
  63.895 -		break;
  63.896 -	}
  63.897 -
  63.898 -	// OBP0
  63.899 -	case 0x48:
  63.900 -	{
  63.901 -		gbObp0[0] = value & 0x03;
  63.902 -		gbObp0[1] = (value & 0x0c) >> 2;
  63.903 -		gbObp0[2] = (value & 0x30) >> 4;
  63.904 -		gbObp0[3] = (value & 0xc0) >> 6;
  63.905 -		break;
  63.906 -	}
  63.907 -
  63.908 -	// OBP1
  63.909 -	case 0x49:
  63.910 -	{
  63.911 -		gbObp1[0] = value & 0x03;
  63.912 -		gbObp1[1] = (value & 0x0c) >> 2;
  63.913 -		gbObp1[2] = (value & 0x30) >> 4;
  63.914 -		gbObp1[3] = (value & 0xc0) >> 6;
  63.915 -		break;
  63.916 -	}
  63.917 -
  63.918 -	case 0x4a:
  63.919 -		register_WY = value;
  63.920 -		return;
  63.921 -
  63.922 -	case 0x4b:
  63.923 -		register_WX = value;
  63.924 -		return;
  63.925 -
  63.926 -	// KEY1
  63.927 -	case 0x4d:
  63.928 -	{
  63.929 -		if (gbCgbMode)
  63.930 -		{
  63.931 -			gbMemory[0xff4d] = (gbMemory[0xff4d] & 0x80) | (value & 1);
  63.932 -			return;
  63.933 -		}
  63.934 -		break;
  63.935 -	}
  63.936 -
  63.937 -	// VBK
  63.938 -	case 0x4f:
  63.939 -	{
  63.940 -		if (gbCgbMode)
  63.941 -		{
  63.942 -			value = value & 1;
  63.943 -			if (value == gbVramBank)
  63.944 -				return;
  63.945 -
  63.946 -			int vramAddress = value * 0x2000;
  63.947 -			gbMemoryMap[0x08] = &gbVram[vramAddress];
  63.948 -			gbMemoryMap[0x09] = &gbVram[vramAddress + 0x1000];
  63.949 -
  63.950 -			gbVramBank	 = value;
  63.951 -			register_VBK = value;
  63.952 -		}
  63.953 -		return;
  63.954 -		break;
  63.955 -	}
  63.956 -
  63.957 -	// HDMA1
  63.958 -	case 0x51:
  63.959 -	{
  63.960 -		if (gbCgbMode)
  63.961 -		{
  63.962 -			if (value > 0x7f && value < 0xa0)
  63.963 -				value = 0;
  63.964 -
  63.965 -			gbHdmaSource = (value << 8) | (register_HDMA2 & 0xf0);
  63.966 -
  63.967 -			register_HDMA1 = value;
  63.968 -			return;
  63.969 -		}
  63.970 -		break;
  63.971 -	}
  63.972 -
  63.973 -	// HDMA2
  63.974 -	case 0x52:
  63.975 -	{
  63.976 -		if (gbCgbMode)
  63.977 -		{
  63.978 -			value = value & 0xf0;
  63.979 -
  63.980 -			gbHdmaSource = (register_HDMA1 << 8) | (value);
  63.981 -
  63.982 -			register_HDMA2 = value;
  63.983 -			return;
  63.984 -		}
  63.985 -		break;
  63.986 -	}
  63.987 -
  63.988 -	// HDMA3
  63.989 -	case 0x53:
  63.990 -	{
  63.991 -		if (gbCgbMode)
  63.992 -		{
  63.993 -			value = value & 0x1f;
  63.994 -			gbHdmaDestination  = (value << 8) | (register_HDMA4 & 0xf0);
  63.995 -			gbHdmaDestination += 0x8000;
  63.996 -			register_HDMA3	   = value;
  63.997 -			return;
  63.998 -		}
  63.999 -		break;
 63.1000 -	}
 63.1001 -
 63.1002 -	// HDMA4
 63.1003 -	case 0x54:
 63.1004 -	{
 63.1005 -		if (gbCgbMode)
 63.1006 -		{
 63.1007 -			value = value & 0xf0;
 63.1008 -			gbHdmaDestination  = ((register_HDMA3 & 0x1f) << 8) | value;
 63.1009 -			gbHdmaDestination += 0x8000;
 63.1010 -			register_HDMA4	   = value;
 63.1011 -			return;
 63.1012 -		}
 63.1013 -		break;
 63.1014 -	}
 63.1015 -
 63.1016 -	// HDMA5
 63.1017 -	case 0x55:
 63.1018 -	{
 63.1019 -		if (gbCgbMode)
 63.1020 -		{
 63.1021 -			gbHdmaBytes = 16 + (value & 0x7f) * 16;
 63.1022 -			if (gbHdmaOn)
 63.1023 -			{
 63.1024 -				if (value & 0x80)
 63.1025 -				{
 63.1026 -					register_HDMA5 = (value & 0x7f);
 63.1027 -				}
 63.1028 -				else
 63.1029 -				{
 63.1030 -					register_HDMA5 = 0xff;
 63.1031 -					gbHdmaOn	   = 0;
 63.1032 -				}
 63.1033 -			}
 63.1034 -			else
 63.1035 -			{
 63.1036 -				if (value & 0x80)
 63.1037 -				{
 63.1038 -					gbHdmaOn	   = 1;
 63.1039 -					register_HDMA5 = value & 0x7f;
 63.1040 -					if (gbLcdMode == 0)
 63.1041 -						gbDoHdma();
 63.1042 -				}
 63.1043 -				else
 63.1044 -				{
 63.1045 -					// we need to take the time it takes to complete the transfer into
 63.1046 -					// account... according to GB DEV FAQs, the setup time is the same
 63.1047 -					// for single and double speed, but the actual transfer takes the
 63.1048 -					// same time // (is that a typo?)
 63.1049 -					switch (gbDMASpeedVersion)
 63.1050 -					{
 63.1051 -					case 1:     // I believe this is more correct
 63.1052 -						// the lower 7 bits of FF55 specify the Transfer Length (divided by 16, minus 1)
 63.1053 -						// and we make gbDmaTicks twice as many cycles at double speed to make the transfer take the same time
 63.1054 -						if (gbSpeed)
 63.1055 -							gbDmaTicks = 16 * ((value & 0x7f) + 1);
 63.1056 -						else
 63.1057 -							gbDmaTicks = 8 * ((value & 0x7f) + 1);
 63.1058 -						break;
 63.1059 -					case 0:     // here for backward compatibility
 63.1060 -						// I think this was a guess that approximates the above in most but not all games
 63.1061 -						if (gbSpeed)
 63.1062 -							gbDmaTicks = 231 + 16 * (value & 0x7f);
 63.1063 -						else
 63.1064 -							gbDmaTicks = 231 + 8 * (value & 0x7f);
 63.1065 -						break;
 63.1066 -					default:     // shouldn't happen
 63.1067 -						//assert(0);
 63.1068 -						break;
 63.1069 -					}
 63.1070 -					gbCopyMemory(gbHdmaDestination, gbHdmaSource, gbHdmaBytes);
 63.1071 -					gbHdmaDestination += gbHdmaBytes;
 63.1072 -					gbHdmaSource	  += gbHdmaBytes;
 63.1073 -
 63.1074 -					register_HDMA3 = ((gbHdmaDestination - 0x8000) >> 8) & 0x1f;
 63.1075 -					register_HDMA4 = gbHdmaDestination & 0xf0;
 63.1076 -					register_HDMA1 = (gbHdmaSource >> 8) & 0xff;
 63.1077 -					register_HDMA2 = gbHdmaSource & 0xf0;
 63.1078 -				}
 63.1079 -			}
 63.1080 -			return;
 63.1081 -		}
 63.1082 -		break;
 63.1083 -	}
 63.1084 -
 63.1085 -	// BCPS
 63.1086 -	case 0x68:
 63.1087 -	{
 63.1088 -		if (gbCgbMode)
 63.1089 -		{
 63.1090 -			int paletteIndex = (value & 0x3f) >> 1;
 63.1091 -			int paletteHiLo	 = (value & 0x01);
 63.1092 -
 63.1093 -			gbMemory[0xff68] = value;
 63.1094 -			gbMemory[0xff69] = (paletteHiLo ?
 63.1095 -			                    (gbPalette[paletteIndex] >> 8) :
 63.1096 -			                    (gbPalette[paletteIndex] & 0x00ff));
 63.1097 -			return;
 63.1098 -		}
 63.1099 -		break;
 63.1100 -	}
 63.1101 -
 63.1102 -	// BCPD
 63.1103 -	case 0x69:
 63.1104 -	{
 63.1105 -		if (gbCgbMode)
 63.1106 -		{
 63.1107 -			int v = gbMemory[0xff68];
 63.1108 -			int paletteIndex = (v & 0x3f) >> 1;
 63.1109 -			int paletteHiLo	 = (v & 0x01);
 63.1110 -			gbMemory[0xff69]		= value;
 63.1111 -			gbPalette[paletteIndex] = (paletteHiLo ?
 63.1112 -			                           ((value << 8) | (gbPalette[paletteIndex] & 0xff)) :
 63.1113 -			                           ((gbPalette[paletteIndex] & 0xff00) | (value))) & 0x7fff;
 63.1114 -
 63.1115 -			if (gbMemory[0xff68] & 0x80)
 63.1116 -			{
 63.1117 -				int index = ((gbMemory[0xff68] & 0x3f) + 1) & 0x3f;
 63.1118 -
 63.1119 -				gbMemory[0xff68] = (gbMemory[0xff68] & 0x80) | index;
 63.1120 -
 63.1121 -				gbMemory[0xff69] = (index & 1 ?
 63.1122 -				                    (gbPalette[index >> 1] >> 8) :
 63.1123 -				                    (gbPalette[index >> 1] & 0x00ff));
 63.1124 -			}
 63.1125 -			return;
 63.1126 -		}
 63.1127 -		break;
 63.1128 -	}
 63.1129 -
 63.1130 -	// OCPS
 63.1131 -	case 0x6a:
 63.1132 -	{
 63.1133 -		if (gbCgbMode)
 63.1134 -		{
 63.1135 -			int paletteIndex = (value & 0x3f) >> 1;
 63.1136 -			int paletteHiLo	 = (value & 0x01);
 63.1137 -
 63.1138 -			paletteIndex += 32;
 63.1139 -
 63.1140 -			gbMemory[0xff6a] = value;
 63.1141 -			gbMemory[0xff6b] = (paletteHiLo ?
 63.1142 -			                    (gbPalette[paletteIndex] >> 8) :
 63.1143 -			                    (gbPalette[paletteIndex] & 0x00ff));
 63.1144 -			return;
 63.1145 -		}
 63.1146 -		break;
 63.1147 -	}
 63.1148 -
 63.1149 -	// OCPD
 63.1150 -	case 0x6b:
 63.1151 -	{
 63.1152 -		if (gbCgbMode)
 63.1153 -		{
 63.1154 -			int v = gbMemory[0xff6a];
 63.1155 -			int paletteIndex = (v & 0x3f) >> 1;
 63.1156 -			int paletteHiLo	 = (v & 0x01);
 63.1157 -
 63.1158 -			paletteIndex += 32;
 63.1159 -
 63.1160 -			gbMemory[0xff6b]		= value;
 63.1161 -			gbPalette[paletteIndex] = (paletteHiLo ?
 63.1162 -			                           ((value << 8) | (gbPalette[paletteIndex] & 0xff)) :
 63.1163 -			                           ((gbPalette[paletteIndex] & 0xff00) | (value))) & 0x7fff;
 63.1164 -			if (gbMemory[0xff6a] & 0x80)
 63.1165 -			{
 63.1166 -				int index = ((gbMemory[0xff6a] & 0x3f) + 1) & 0x3f;
 63.1167 -
 63.1168 -				gbMemory[0xff6a] = (gbMemory[0xff6a] & 0x80) | index;
 63.1169 -
 63.1170 -				gbMemory[0xff6b] = (index & 1 ?
 63.1171 -				                    (gbPalette[(index >> 1) + 32] >> 8) :
 63.1172 -				                    (gbPalette[(index >> 1) + 32] & 0x00ff));
 63.1173 -			}
 63.1174 -			return;
 63.1175 -		}
 63.1176 -		break;
 63.1177 -	}
 63.1178 -
 63.1179 -	// SVBK
 63.1180 -	case 0x70:
 63.1181 -	{
 63.1182 -		if (gbCgbMode)
 63.1183 -		{
 63.1184 -			value = value & 7;
 63.1185 -
 63.1186 -			int bank = value;
 63.1187 -			if (value == 0)
 63.1188 -				bank = 1;
 63.1189 -
 63.1190 -			if (bank == gbWramBank)
 63.1191 -				return;
 63.1192 -
 63.1193 -			int wramAddress = bank * 0x1000;
 63.1194 -			gbMemoryMap[0x0d] = &gbWram[wramAddress];
 63.1195 -
 63.1196 -			gbWramBank	  = bank;
 63.1197 -			register_SVBK = value;
 63.1198 -			return;
 63.1199 -		}
 63.1200 -		break;
 63.1201 -	}
 63.1202 -
 63.1203 -	case 0xff:
 63.1204 -	{
 63.1205 -		register_IE	 = value;
 63.1206 -		register_IF &= value;
 63.1207 -		return;
 63.1208 -	}
 63.1209 -	}
 63.1210 -
 63.1211 -	gbWriteMemoryQuick(address, value);
 63.1212 -}
 63.1213 -
 63.1214 -u8 gbReadOpcode(register u16 address)
 63.1215 -{
 63.1216 -	if (gbCheatMap[address])
 63.1217 -		return gbCheatRead(address);
 63.1218 -
 63.1219 -	// the following fix does more than Echo RAM fix, anyway...
 63.1220 -	switch (gbEchoRAMFixOn ? (address >> 12) & 0x000f : address & 0xf000)
 63.1221 -	{
 63.1222 -	case 0x0a:
 63.1223 -	case 0x0b:
 63.1224 -		if (mapperReadRAM)
 63.1225 -			return mapperReadRAM(address);
 63.1226 -		break;
 63.1227 -	case 0x0f:
 63.1228 -		if (address > 0xff00)
 63.1229 -		{
 63.1230 -			switch (address & 0x00ff)
 63.1231 -			{
 63.1232 -			case 0x04:
 63.1233 -				return register_DIV;
 63.1234 -			case 0x05:
 63.1235 -				return register_TIMA;
 63.1236 -			case 0x06:
 63.1237 -				return register_TMA;
 63.1238 -			case 0x07:
 63.1239 -				return (0xf8 | register_TAC);
 63.1240 -			case 0x0f:
 63.1241 -				return (0xe0 | register_IF);
 63.1242 -			case 0x40:
 63.1243 -				return register_LCDC;
 63.1244 -			case 0x41:
 63.1245 -				return (0x80 | register_STAT);
 63.1246 -			case 0x42:
 63.1247 -				return register_SCY;
 63.1248 -			case 0x43:
 63.1249 -				return register_SCX;
 63.1250 -			case 0x44:
 63.1251 -				return register_LY;
 63.1252 -			case 0x45:
 63.1253 -				return register_LYC;
 63.1254 -			case 0x46:
 63.1255 -				return register_DMA;
 63.1256 -			case 0x4a:
 63.1257 -				return register_WY;
 63.1258 -			case 0x4b:
 63.1259 -				return register_WX;
 63.1260 -			case 0x4f:
 63.1261 -				return (0xfe | register_VBK);
 63.1262 -			case 0x51:
 63.1263 -				return register_HDMA1;
 63.1264 -			case 0x52:
 63.1265 -				return register_HDMA2;
 63.1266 -			case 0x53:
 63.1267 -				return register_HDMA3;
 63.1268 -			case 0x54:
 63.1269 -				return register_HDMA4;
 63.1270 -			case 0x55:
 63.1271 -				return register_HDMA5;
 63.1272 -			case 0x70:
 63.1273 -				return (0xf8 | register_SVBK);
 63.1274 -			case 0xff:
 63.1275 -				return register_IE;
 63.1276 -			}
 63.1277 -		}
 63.1278 -		break;
 63.1279 -	}
 63.1280 -	return gbReadMemoryQuick(address);
 63.1281 -}
 63.1282 -
 63.1283 -void gbWriteMemory(register u16 address, register u8 value)
 63.1284 -{
 63.1285 -	gbWriteMemoryWrapped(address, value);
 63.1286 -	CallRegisteredLuaMemHook(address, 1, value, LUAMEMHOOK_WRITE);
 63.1287 -}
 63.1288 -
 63.1289 -u8 gbReadMemory(register u16 address)
 63.1290 -{
 63.1291 -	if (gbCheatMap[address])
 63.1292 -		return gbCheatRead(address);
 63.1293 -
 63.1294 -	if (address < 0xa000)
 63.1295 -		return gbReadMemoryQuick(address);
 63.1296 -
 63.1297 -	if (address < 0xc000)
 63.1298 -	{
 63.1299 -#ifndef FINAL_VERSION
 63.1300 -		if (memorydebug)
 63.1301 -		{
 63.1302 -			log("Memory register read %04x PC=%04x\n",
 63.1303 -			    address,
 63.1304 -			    PC.W);
 63.1305 -		}
 63.1306 -#endif
 63.1307 -
 63.1308 -		if (mapperReadRAM)
 63.1309 -			return mapperReadRAM(address);
 63.1310 -		return gbReadMemoryQuick(address);
 63.1311 -	}
 63.1312 -
 63.1313 -	if (address >= 0xff00)
 63.1314 -	{
 63.1315 -		switch (address & 0x00ff)
 63.1316 -		{
 63.1317 -		case 0x00:
 63.1318 -		{
 63.1319 -			if (gbSgbMode)
 63.1320 -			{
 63.1321 -				gbSgbReadingController |= 4;
 63.1322 -				gbSgbResetPacketState();
 63.1323 -			}
 63.1324 -
 63.1325 -			int b = gbMemory[0xff00];
 63.1326 -
 63.1327 -			if ((b & 0x30) == 0x20)
 63.1328 -			{
 63.1329 -				b &= 0xf0;
 63.1330 -
 63.1331 -				int joy = 0;
 63.1332 -				if (gbSgbMode && gbSgbMultiplayer)
 63.1333 -				{
 63.1334 -					switch (gbSgbNextController)
 63.1335 -					{
 63.1336 -					case 0x0f:
 63.1337 -						joy = 0;
 63.1338 -						break;
 63.1339 -					case 0x0e:
 63.1340 -						joy = 1;
 63.1341 -						break;
 63.1342 -					case 0x0d:
 63.1343 -						joy = 2;
 63.1344 -						break;
 63.1345 -					case 0x0c:
 63.1346 -						joy = 3;
 63.1347 -						break;
 63.1348 -					default:
 63.1349 -						joy = 0;
 63.1350 -					}
 63.1351 -				}
 63.1352 -				int joystate = gbJoymask[joy];
 63.1353 -				if (!(joystate & 128))
 63.1354 -					b |= 0x08;
 63.1355 -				if (!(joystate & 64))
 63.1356 -					b |= 0x04;
 63.1357 -				if (!(joystate & 32))
 63.1358 -					b |= 0x02;
 63.1359 -				if (!(joystate & 16))
 63.1360 -					b |= 0x01;
 63.1361 -
 63.1362 -				gbMemory[0xff00] = b;
 63.1363 -			}
 63.1364 -			else if ((b & 0x30) == 0x10)
 63.1365 -			{
 63.1366 -				b &= 0xf0;
 63.1367 -
 63.1368 -				int joy = 0;
 63.1369 -				if (gbSgbMode && gbSgbMultiplayer)
 63.1370 -				{
 63.1371 -					switch (gbSgbNextController)
 63.1372 -					{
 63.1373 -					case 0x0f:
 63.1374 -						joy = 0;
 63.1375 -						break;
 63.1376 -					case 0x0e:
 63.1377 -						joy = 1;
 63.1378 -						break;
 63.1379 -					case 0x0d:
 63.1380 -						joy = 2;
 63.1381 -						break;
 63.1382 -					case 0x0c:
 63.1383 -						joy = 3;
 63.1384 -						break;
 63.1385 -					default:
 63.1386 -						joy = 0;
 63.1387 -					}
 63.1388 -				}
 63.1389 -				int joystate = gbJoymask[joy];
 63.1390 -				if (!(joystate & 8))
 63.1391 -					b |= 0x08;
 63.1392 -				if (!(joystate & 4))
 63.1393 -					b |= 0x04;
 63.1394 -				if (!(joystate & 2))
 63.1395 -					b |= 0x02;
 63.1396 -				if (!(joystate & 1))
 63.1397 -					b |= 0x01;
 63.1398 -
 63.1399 -				gbMemory[0xff00] = b;
 63.1400 -			}
 63.1401 -			else
 63.1402 -			{
 63.1403 -				if (gbSgbMode && gbSgbMultiplayer)
 63.1404 -				{
 63.1405 -					gbMemory[0xff00] = 0xf0 | gbSgbNextController;
 63.1406 -				}
 63.1407 -				else
 63.1408 -				{
 63.1409 -					gbMemory[0xff00] = 0xff;
 63.1410 -				}
 63.1411 -			}
 63.1412 -		}
 63.1413 -			GBSystemCounters.lagged = false;
 63.1414 -			return gbMemory[0xff00];
 63.1415 -			break;
 63.1416 -		case 0x01:
 63.1417 -			return gbMemory[0xff01];
 63.1418 -		case 0x04:
 63.1419 -			return register_DIV;
 63.1420 -		case 0x05:
 63.1421 -			return register_TIMA;
 63.1422 -		case 0x06:
 63.1423 -			return register_TMA;
 63.1424 -		case 0x07:
 63.1425 -			return (0xf8 | register_TAC);
 63.1426 -		case 0x0f:
 63.1427 -			return (0xe0 | register_IF);
 63.1428 -		case 0x40:
 63.1429 -			return register_LCDC;
 63.1430 -		case 0x41:
 63.1431 -			return (0x80 | register_STAT);
 63.1432 -		case 0x42:
 63.1433 -			return register_SCY;
 63.1434 -		case 0x43:
 63.1435 -			return register_SCX;
 63.1436 -		case 0x44:
 63.1437 -			return register_LY;
 63.1438 -		case 0x45:
 63.1439 -			return register_LYC;
 63.1440 -		case 0x46:
 63.1441 -			return register_DMA;
 63.1442 -		case 0x4a:
 63.1443 -			return register_WY;
 63.1444 -		case 0x4b:
 63.1445 -			return register_WX;
 63.1446 -		case 0x4f:
 63.1447 -			return (0xfe | register_VBK);
 63.1448 -		case 0x51:
 63.1449 -			return register_HDMA1;
 63.1450 -		case 0x52:
 63.1451 -			return register_HDMA2;
 63.1452 -		case 0x53:
 63.1453 -			return register_HDMA3;
 63.1454 -		case 0x54:
 63.1455 -			return register_HDMA4;
 63.1456 -		case 0x55:
 63.1457 -			return register_HDMA5;
 63.1458 -		case 0x70:
 63.1459 -			return (0xf8 | register_SVBK);
 63.1460 -		case 0xff:
 63.1461 -			return register_IE;
 63.1462 -		}
 63.1463 -	}
 63.1464 -
 63.1465 -	return gbReadMemoryQuick(address);
 63.1466 -}
 63.1467 -
 63.1468 -void gbVblank_interrupt()
 63.1469 -{
 63.1470 -	if (IFF & 0x80)
 63.1471 -	{
 63.1472 -		PC.W++;
 63.1473 -		IFF &= 0x7f;
 63.1474 -	}
 63.1475 -	gbInterrupt &= 0xfe;
 63.1476 -
 63.1477 -	IFF			&= 0x7e;
 63.1478 -	register_IF &= 0xfe;
 63.1479 -
 63.1480 -	gbWriteMemory(--SP.W, PC.B.B1);
 63.1481 -	gbWriteMemory(--SP.W, PC.B.B0);
 63.1482 -	PC.W = 0x40;
 63.1483 -}
 63.1484 -
 63.1485 -void gbLcd_interrupt()
 63.1486 -{
 63.1487 -	if (IFF & 0x80)
 63.1488 -	{
 63.1489 -		PC.W++;
 63.1490 -		IFF &= 0x7f;
 63.1491 -	}
 63.1492 -	gbInterrupt &= 0xfd;
 63.1493 -	IFF			&= 0x7e;
 63.1494 -	register_IF &= 0xfd;
 63.1495 -
 63.1496 -	gbWriteMemory(--SP.W, PC.B.B1);
 63.1497 -	gbWriteMemory(--SP.W, PC.B.B0);
 63.1498 -
 63.1499 -	PC.W = 0x48;
 63.1500 -}
 63.1501 -
 63.1502 -void gbTimer_interrupt()
 63.1503 -{
 63.1504 -	if (IFF & 0x80)
 63.1505 -	{
 63.1506 -		PC.W++;
 63.1507 -		IFF &= 0x7f;
 63.1508 -	}
 63.1509 -	IFF			&= 0x7e;
 63.1510 -	gbInterrupt &= 0xfb;
 63.1511 -	register_IF &= 0xfb;
 63.1512 -
 63.1513 -	gbWriteMemory(--SP.W, PC.B.B1);
 63.1514 -	gbWriteMemory(--SP.W, PC.B.B0);
 63.1515 -
 63.1516 -	PC.W = 0x50;
 63.1517 -}
 63.1518 -
 63.1519 -void gbSerial_interrupt()
 63.1520 -{
 63.1521 -	if (IFF & 0x80)
 63.1522 -	{
 63.1523 -		PC.W++;
 63.1524 -		IFF &= 0x7f;
 63.1525 -	}
 63.1526 -	IFF			&= 0x7e;
 63.1527 -	gbInterrupt &= 0xf7;
 63.1528 -	register_IF &= 0xf7;
 63.1529 -
 63.1530 -	gbWriteMemory(--SP.W, PC.B.B1);
 63.1531 -	gbWriteMemory(--SP.W, PC.B.B0);
 63.1532 -
 63.1533 -	PC.W = 0x58;
 63.1534 -}
 63.1535 -
 63.1536 -void gbJoypad_interrupt()
 63.1537 -{
 63.1538 -	if (IFF & 0x80)
 63.1539 -	{
 63.1540 -		PC.W++;
 63.1541 -		IFF &= 0x7f;
 63.1542 -	}
 63.1543 -	IFF			&= 0x7e;
 63.1544 -	gbInterrupt &= 0xef;
 63.1545 -	register_IF &= 0xef;
 63.1546 -
 63.1547 -	gbWriteMemory(--SP.W, PC.B.B1);
 63.1548 -	gbWriteMemory(--SP.W, PC.B.B0);
 63.1549 -
 63.1550 -	PC.W = 0x60;
 63.1551 -}
 63.1552 -
 63.1553 -void gbSpeedSwitch()
 63.1554 -{
 63.1555 -	if (gbSpeed == 0)
 63.1556 -	{
 63.1557 -		gbSpeed = 1;
 63.1558 -		GBLCD_MODE_0_CLOCK_TICKS   = 51 * 2; //127; //51 * 2;
 63.1559 -		GBLCD_MODE_1_CLOCK_TICKS   = 1140 * 2;
 63.1560 -		GBLCD_MODE_2_CLOCK_TICKS   = 20 * 2; //52; //20 * 2;
 63.1561 -		GBLCD_MODE_3_CLOCK_TICKS   = 43 * 2; //99; //43 * 2;
 63.1562 -		GBDIV_CLOCK_TICKS		   = 64 * 2;
 63.1563 -		GBLY_INCREMENT_CLOCK_TICKS = 114 * 2;
 63.1564 -		GBTIMER_MODE_0_CLOCK_TICKS = 256; //256*2;
 63.1565 -		GBTIMER_MODE_1_CLOCK_TICKS = 4; //4*2;
 63.1566 -		GBTIMER_MODE_2_CLOCK_TICKS = 16; //16*2;
 63.1567 -		GBTIMER_MODE_3_CLOCK_TICKS = 64; //64*2;
 63.1568 -		GBSERIAL_CLOCK_TICKS	   = 128 * 2;
 63.1569 -		gbDivTicks *= 2;
 63.1570 -		gbLcdTicks *= 2;
 63.1571 -		gbLcdLYIncrementTicks *= 2;
 63.1572 -		//    timerTicks *= 2;
 63.1573 -		//    timerClockTicks *= 2;
 63.1574 -		gbSerialTicks	 *= 2;
 63.1575 -		SOUND_CLOCK_TICKS = soundQuality * GB_USE_TICKS_AS * 2;
 63.1576 -		soundTicks		 *= 2;
 63.1577 -		//    synchronizeTicks *= 2;
 63.1578 -		//    SYNCHRONIZE_CLOCK_TICKS *= 2;
 63.1579 -	}
 63.1580 -	else
 63.1581 -	{
 63.1582 -		gbSpeed = 0;
 63.1583 -		GBLCD_MODE_0_CLOCK_TICKS   = 51;
 63.1584 -		GBLCD_MODE_1_CLOCK_TICKS   = 1140;
 63.1585 -		GBLCD_MODE_2_CLOCK_TICKS   = 20;
 63.1586 -		GBLCD_MODE_3_CLOCK_TICKS   = 43;
 63.1587 -		GBDIV_CLOCK_TICKS		   = 64;
 63.1588 -		GBLY_INCREMENT_CLOCK_TICKS = 114;
 63.1589 -		GBTIMER_MODE_0_CLOCK_TICKS = 256;
 63.1590 -		GBTIMER_MODE_1_CLOCK_TICKS = 4;
 63.1591 -		GBTIMER_MODE_2_CLOCK_TICKS = 16;
 63.1592 -		GBTIMER_MODE_3_CLOCK_TICKS = 64;
 63.1593 -		GBSERIAL_CLOCK_TICKS	   = 128;
 63.1594 -		gbDivTicks /= 2;
 63.1595 -		gbLcdTicks /= 2;
 63.1596 -		gbLcdLYIncrementTicks /= 2;
 63.1597 -		//    timerTicks /= 2;
 63.1598 -		//    timerClockTicks /= 2;
 63.1599 -		gbSerialTicks	 /= 2;
 63.1600 -		SOUND_CLOCK_TICKS = soundQuality * GB_USE_TICKS_AS;
 63.1601 -		soundTicks		 /= 2;
 63.1602 -		//    synchronizeTicks /= 2;
 63.1603 -		//    SYNCHRONIZE_CLOCK_TICKS /= 2;
 63.1604 -	}
 63.1605 -}
 63.1606 -
 63.1607 -void gbGetHardwareType()
 63.1608 -{
 63.1609 -	gbCgbMode = 0;
 63.1610 -	if (gbRom[0x143] & 0x80)
 63.1611 -	{
 63.1612 -		if (gbEmulatorType == 0 ||
 63.1613 -		    gbEmulatorType == 1 ||
 63.1614 -		    gbEmulatorType == 4 ||
 63.1615 -		    gbEmulatorType == 5 ||
 63.1616 -		    (gbRom[0x146] != 0x03 && (gbEmulatorType == 2)))
 63.1617 -		{
 63.1618 -			gbCgbMode = 1;
 63.1619 -		}
 63.1620 -	}
 63.1621 -
 63.1622 -	if (gbSgbMode == 2)
 63.1623 -	{
 63.1624 -		gbSgbMode = 0;
 63.1625 -		return;
 63.1626 -	}
 63.1627 -
 63.1628 -	gbSgbMode = 0;
 63.1629 -	if (gbRom[0x146] == 0x03)
 63.1630 -	{
 63.1631 -		if (gbEmulatorType == 0 ||
 63.1632 -		    gbEmulatorType == 2 ||
 63.1633 -		    gbEmulatorType == 5 ||
 63.1634 -		    (!(gbRom[0x143] & 0x80) && (gbEmulatorType == 1 || gbEmulatorType == 4)))
 63.1635 -			gbSgbMode = 1;
 63.1636 -	}
 63.1637 -}
 63.1638 -
 63.1639 -void gbReset(bool userReset)
 63.1640 -{
 63.1641 -	// movie must be closed while opening/creating a movie
 63.1642 -	if (userReset && VBAMovieRecording())
 63.1643 -	{
 63.1644 -		VBAMovieSignalReset();
 63.1645 -		return;
 63.1646 -	}
 63.1647 -
 63.1648 -	if (!VBAMovieActive())
 63.1649 -	{
 63.1650 -		GBSystemCounters.frameCount = 0;
 63.1651 -		GBSystemCounters.lagCount	= 0;
 63.1652 -		GBSystemCounters.extraCount = 0;
 63.1653 -		GBSystemCounters.lagged		= true;
 63.1654 -		GBSystemCounters.laggedLast = true;
 63.1655 -	}
 63.1656 -
 63.1657 -	SP.W = 0xfffe;
 63.1658 -	AF.W = 0x01b0;
 63.1659 -	BC.W = 0x0013;
 63.1660 -	DE.W = 0x00d8;
 63.1661 -	HL.W = 0x014d;
 63.1662 -	PC.W = 0x0100;
 63.1663 -	IFF	 = 0;
 63.1664 -	gbInterrupt		= 1;
 63.1665 -	gbInterruptWait = 0;
 63.1666 -
 63.1667 -	register_DIV   = 0;
 63.1668 -	register_TIMA  = 0;
 63.1669 -	register_TMA   = 0;
 63.1670 -	register_TAC   = 0;
 63.1671 -	register_IF	   = 1;
 63.1672 -	register_LCDC  = 0x91;
 63.1673 -	register_STAT  = 0;
 63.1674 -	register_SCY   = 0;
 63.1675 -	register_SCX   = 0;
 63.1676 -	register_LY	   = 0;
 63.1677 -	register_LYC   = 0;
 63.1678 -	register_DMA   = 0;
 63.1679 -	register_WY	   = 0;
 63.1680 -	register_WX	   = 0;
 63.1681 -	register_VBK   = 0;
 63.1682 -	register_HDMA1 = 0;
 63.1683 -	register_HDMA2 = 0;
 63.1684 -	register_HDMA3 = 0;
 63.1685 -	register_HDMA4 = 0;
 63.1686 -	register_HDMA5 = 0;
 63.1687 -	register_SVBK  = 0;
 63.1688 -	register_IE	   = 0;
 63.1689 -
 63.1690 -	gbGetHardwareType();
 63.1691 -	if (gbCgbMode)
 63.1692 -	{
 63.1693 -		if (!gbVram)
 63.1694 -			gbVram = (u8 *)malloc(0x4000 + 4);
 63.1695 -		if (!gbWram)
 63.1696 -			gbWram = (u8 *)malloc(0x8000 + 4);
 63.1697 -		memset(gbVram, 0, 0x4000 + 4);
 63.1698 -		memset(gbWram, 0, 0x8000 + 4);
 63.1699 -	}
 63.1700 -	else
 63.1701 -	{
 63.1702 -		if (gbVram)
 63.1703 -		{
 63.1704 -			free(gbVram);
 63.1705 -			gbVram = NULL;
 63.1706 -		}
 63.1707 -		if (gbWram)
 63.1708 -		{
 63.1709 -			free(gbWram);
 63.1710 -			gbWram = NULL;
 63.1711 -		}
 63.1712 -	}
 63.1713 -
 63.1714 -	// clean LineBuffer
 63.1715 -	if (gbLineBuffer)
 63.1716 -		memset(gbLineBuffer, 0, 160 * sizeof(u16));
 63.1717 -	// clean Pix
 63.1718 -	if (pix)
 63.1719 -		memset(pix, 0, 4 * 257 * 226);
 63.1720 -
 63.1721 -	if (gbCgbMode)
 63.1722 -	{
 63.1723 -		if (gbSgbMode)
 63.1724 -		{
 63.1725 -			if (gbEmulatorType == 5)
 63.1726 -				AF.W = 0xffb0;
 63.1727 -			else
 63.1728 -				AF.W = 0x01b0;
 63.1729 -			BC.W = 0x0013;
 63.1730 -			DE.W = 0x00d8;
 63.1731 -			HL.W = 0x014d;
 63.1732 -		}
 63.1733 -		else
 63.1734 -		{
 63.1735 -			AF.W = 0x11b0;
 63.1736 -			BC.W = 0x0000;
 63.1737 -			DE.W = 0xff56;
 63.1738 -			HL.W = 0x000d;
 63.1739 -		}
 63.1740 -		if (gbEmulatorType == 4)
 63.1741 -			BC.B.B1 |= 0x01;
 63.1742 -
 63.1743 -		register_HDMA5	 = 0xff;
 63.1744 -		gbMemory[0xff68] = 0xc0;
 63.1745 -		gbMemory[0xff6a] = 0xc0;
 63.1746 -
 63.1747 -		for (int i = 0; i < 64; i++)
 63.1748 -			gbPalette[i] = 0x7fff;
 63.1749 -	}
 63.1750 -	else
 63.1751 -	{
 63.1752 -		for (int i = 0; i < 8; i++)
 63.1753 -			gbPalette[i] = systemGbPalette[gbPaletteOption * 8 + i];
 63.1754 -	}
 63.1755 -
 63.1756 -	if (gbSpeed)
 63.1757 -	{
 63.1758 -		gbSpeedSwitch();
 63.1759 -		gbMemory[0xff4d] = 0;
 63.1760 -	}
 63.1761 -
 63.1762 -	gbDivTicks = GBDIV_CLOCK_TICKS;
 63.1763 -	gbLcdMode  = 2;
 63.1764 -	gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS;
 63.1765 -	gbLcdLYIncrementTicks = 0;
 63.1766 -	gbTimerTicks		  = 0;
 63.1767 -	gbTimerClockTicks	  = 0;
 63.1768 -	gbSerialTicks		  = 0;
 63.1769 -	gbSerialBits		  = 0;
 63.1770 -	gbSerialOn			  = 0;
 63.1771 -	gbWindowLine		  = -1;
 63.1772 -	gbTimerOn			  = 0;
 63.1773 -	gbTimerMode			  = 0;
 63.1774 -	//  gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS;
 63.1775 -	gbSpeed		 = 0;
 63.1776 -	gbJoymask[0] = gbJoymask[1] = gbJoymask[2] = gbJoymask[3] = 0;
 63.1777 -
 63.1778 -	// FIXME: horrible kludge
 63.1779 -	memset(s_gbJoymask, 0, sizeof(s_gbJoymask));
 63.1780 -
 63.1781 -	if (gbCgbMode)
 63.1782 -	{
 63.1783 -		gbSpeed	 = 0;
 63.1784 -		gbHdmaOn = 0;
 63.1785 -		gbHdmaSource	  = 0x0000;
 63.1786 -		gbHdmaDestination = 0x8000;
 63.1787 -		gbVramBank		  = 0;
 63.1788 -		gbWramBank		  = 1;
 63.1789 -		register_LY		  = 0x90;
 63.1790 -		gbLcdMode		  = 1;
 63.1791 -	}
 63.1792 -
 63.1793 -	if (gbSgbMode)
 63.1794 -	{
 63.1795 -		gbSgbReset();
 63.1796 -	}
 63.1797 -
 63.1798 -	for (int i = 0; i < 4; i++)
 63.1799 -		gbBgp[i] = gbObp0[i] = gbObp1[i] = i;
 63.1800 -
 63.1801 -	memset(&gbDataMBC1, 0, sizeof(gbDataMBC1));
 63.1802 -	gbDataMBC1.mapperROMBank = 1;
 63.1803 -
 63.1804 -	gbDataMBC2.mapperRAMEnable = 0;
 63.1805 -	gbDataMBC2.mapperROMBank   = 1;
 63.1806 -
 63.1807 -	memset(&gbDataMBC3, 0, 6 * sizeof(int32));
 63.1808 -	gbDataMBC3.mapperROMBank = 1;
 63.1809 -
 63.1810 -	memset(&gbDataMBC5, 0, sizeof(gbDataMBC5));
 63.1811 -	gbDataMBC5.mapperROMBank = 1;
 63.1812 -	switch (gbRom[0x147])
 63.1813 -	{
 63.1814 -	case 0x1c:
 63.1815 -	case 0x1d:
 63.1816 -	case 0x1e:
 63.1817 -		gbDataMBC5.isRumbleCartridge = 1;
 63.1818 -	}
 63.1819 -
 63.1820 -	memset(&gbDataHuC1, 0, sizeof(gbDataHuC1));
 63.1821 -	gbDataHuC1.mapperROMBank = 1;
 63.1822 -
 63.1823 -	memset(&gbDataHuC3, 0, sizeof(gbDataHuC3));
 63.1824 -	gbDataHuC3.mapperROMBank = 1;
 63.1825 -
 63.1826 -	gbMemoryMap[0x00] = &gbRom[0x0000];
 63.1827 -	gbMemoryMap[0x01] = &gbRom[0x1000];
 63.1828 -	gbMemoryMap[0x02] = &gbRom[0x2000];
 63.1829 -	gbMemoryMap[0x03] = &gbRom[0x3000];
 63.1830 -	gbMemoryMap[0x04] = &gbRom[0x4000];
 63.1831 -	gbMemoryMap[0x05] = &gbRom[0x5000];
 63.1832 -	gbMemoryMap[0x06] = &gbRom[0x6000];
 63.1833 -	gbMemoryMap[0x07] = &gbRom[0x7000];
 63.1834 -	if (gbCgbMode)
 63.1835 -	{
 63.1836 -		gbMemoryMap[0x08] = &gbVram[0x0000];
 63.1837 -		gbMemoryMap[0x09] = &gbVram[0x1000];
 63.1838 -		gbMemoryMap[0x0a] = &gbMemory[0xa000];
 63.1839 -		gbMemoryMap[0x0b] = &gbMemory[0xb000];
 63.1840 -		gbMemoryMap[0x0c] = &gbMemory[0xc000];
 63.1841 -		gbMemoryMap[0x0d] = &gbWram[0x1000];
 63.1842 -		gbMemoryMap[0x0e] = &gbMemory[0xe000];
 63.1843 -		gbMemoryMap[0x0f] = &gbMemory[0xf000];
 63.1844 -	}
 63.1845 -	else
 63.1846 -	{
 63.1847 -		gbMemoryMap[0x08] = &gbMemory[0x8000];
 63.1848 -		gbMemoryMap[0x09] = &gbMemory[0x9000];
 63.1849 -		gbMemoryMap[0x0a] = &gbMemory[0xa000];
 63.1850 -		gbMemoryMap[0x0b] = &gbMemory[0xb000];
 63.1851 -		gbMemoryMap[0x0c] = &gbMemory[0xc000];
 63.1852 -		gbMemoryMap[0x0d] = &gbMemory[0xd000];
 63.1853 -		gbMemoryMap[0x0e] = &gbMemory[0xe000];
 63.1854 -		gbMemoryMap[0x0f] = &gbMemory[0xf000];
 63.1855 -	}
 63.1856 -
 63.1857 -	if (gbRam)
 63.1858 -	{
 63.1859 -		gbMemoryMap[0x0a] = &gbRam[0x0000];
 63.1860 -		gbMemoryMap[0x0b] = &gbRam[0x1000];
 63.1861 -	}
 63.1862 -
 63.1863 -	gbSoundReset();
 63.1864 -
 63.1865 -	systemResetSensor();
 63.1866 -
 63.1867 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 63.1868 -
 63.1869 -	gbLastTime	 = systemGetClock();
 63.1870 -	gbFrameCount = 0;
 63.1871 -
 63.1872 -	systemRefreshScreen();
 63.1873 -}
 63.1874 -
 63.1875 -void gbWriteSaveMBC1(const char *name)
 63.1876 -{
 63.1877 -	FILE *gzFile = fopen(name, "wb");
 63.1878 -
 63.1879 -	if (gzFile == NULL)
 63.1880 -	{
 63.1881 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name);
 63.1882 -		return;
 63.1883 -	}
 63.1884 -
 63.1885 -	fwrite(gbRam,
 63.1886 -	       1,
 63.1887 -	       gbRamSize,
 63.1888 -	       gzFile);
 63.1889 -
 63.1890 -	fclose(gzFile);
 63.1891 -}
 63.1892 -
 63.1893 -void gbWriteSaveMBC2(const char *name)
 63.1894 -{
 63.1895 -	FILE *file = fopen(name, "wb");
 63.1896 -
 63.1897 -	if (file == NULL)
 63.1898 -	{
 63.1899 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name);
 63.1900 -		return;
 63.1901 -	}
 63.1902 -
 63.1903 -	fwrite(&gbMemory[0xa000],
 63.1904 -	       1,
 63.1905 -	       256,
 63.1906 -	       file);
 63.1907 -
 63.1908 -	fclose(file);
 63.1909 -}
 63.1910 -
 63.1911 -void gbWriteSaveMBC3(const char *name, bool extendedSave)
 63.1912 -{
 63.1913 -	FILE *gzFile = fopen(name, "wb");
 63.1914 -
 63.1915 -	if (gzFile == NULL)
 63.1916 -	{
 63.1917 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name);
 63.1918 -		return;
 63.1919 -	}
 63.1920 -
 63.1921 -	fwrite(gbRam,
 63.1922 -	       1,
 63.1923 -	       gbRamSize,
 63.1924 -	       gzFile);
 63.1925 -
 63.1926 -	if (extendedSave)
 63.1927 -	{
 63.1928 -		//assert(sizeof(time_t) == 4);
 63.1929 -		fwrite(&gbDataMBC3.mapperSeconds,
 63.1930 -		       1,
 63.1931 -		       10 * sizeof(int32) + /*sizeof(time_t)*/4,
 63.1932 -		       gzFile);
 63.1933 -	}
 63.1934 -
 63.1935 -	fclose(gzFile);
 63.1936 -}
 63.1937 -
 63.1938 -void gbWriteSaveMBC5(const char *name)
 63.1939 -{
 63.1940 -	FILE *gzFile = fopen(name, "wb");
 63.1941 -
 63.1942 -	if (gzFile == NULL)
 63.1943 -	{
 63.1944 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name);
 63.1945 -		return;
 63.1946 -	}
 63.1947 -
 63.1948 -	fwrite(gbRam,
 63.1949 -	       1,
 63.1950 -	       gbRamSize,
 63.1951 -	       gzFile);
 63.1952 -
 63.1953 -	fclose(gzFile);
 63.1954 -}
 63.1955 -
 63.1956 -void gbWriteSaveMBC7(const char *name)
 63.1957 -{
 63.1958 -	FILE *file = fopen(name, "wb");
 63.1959 -
 63.1960 -	if (file == NULL)
 63.1961 -	{
 63.1962 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name);
 63.1963 -		return;
 63.1964 -	}
 63.1965 -
 63.1966 -	fwrite(&gbMemory[0xa000],
 63.1967 -	       1,
 63.1968 -	       256,
 63.1969 -	       file);
 63.1970 -
 63.1971 -	fclose(file);
 63.1972 -}
 63.1973 -
 63.1974 -bool gbReadSaveMBC1(const char *name)
 63.1975 -{
 63.1976 -	gzFile gzFile = gzopen(name, "rb");
 63.1977 -
 63.1978 -	if (gzFile == NULL)
 63.1979 -	{
 63.1980 -		return false;
 63.1981 -	}
 63.1982 -
 63.1983 -	int read = gzread(gzFile,
 63.1984 -	                  gbRam,
 63.1985 -	                  gbRamSize);
 63.1986 -
 63.1987 -	if (read != gbRamSize)
 63.1988 -	{
 63.1989 -		systemMessage(MSG_FAILED_TO_READ_SGM, N_("Failed to read complete save game %s (%d)"), name, read);
 63.1990 -		gzclose(gzFile);
 63.1991 -		return false;
 63.1992 -	}
 63.1993 -
 63.1994 -	gzclose(gzFile);
 63.1995 -	return true;
 63.1996 -}
 63.1997 -
 63.1998 -bool gbReadSaveMBC2(const char *name)
 63.1999 -{
 63.2000 -	FILE *file = fopen(name, "rb");
 63.2001 -
 63.2002 -	if (file == NULL)
 63.2003 -	{
 63.2004 -		return false;
 63.2005 -	}
 63.2006 -
 63.2007 -	int read = fread(&gbMemory[0xa000],
 63.2008 -	                 1,
 63.2009 -	                 256,
 63.2010 -	                 file);
 63.2011 -
 63.2012 -	if (read != 256)
 63.2013 -	{
 63.2014 -		systemMessage(MSG_FAILED_TO_READ_SGM,
 63.2015 -		              N_("Failed to read complete save game %s (%d)"), name, read);
 63.2016 -		fclose(file);
 63.2017 -		return false;
 63.2018 -	}
 63.2019 -
 63.2020 -	fclose(file);
 63.2021 -	return true;
 63.2022 -}
 63.2023 -
 63.2024 -bool gbReadSaveMBC3(const char *name)
 63.2025 -{
 63.2026 -	gzFile gzFile = gzopen(name, "rb");
 63.2027 -
 63.2028 -	if (gzFile == NULL)
 63.2029 -	{
 63.2030 -		return false;
 63.2031 -	}
 63.2032 -
 63.2033 -	int read = gzread(gzFile,
 63.2034 -	                  gbRam,
 63.2035 -	                  gbRamSize);
 63.2036 -
 63.2037 -	bool res = true;
 63.2038 -
 63.2039 -	if (read != gbRamSize)
 63.2040 -	{
 63.2041 -		systemMessage(MSG_FAILED_TO_READ_SGM,
 63.2042 -		              N_("Failed to read complete save game %s (%d)"), name, read);
 63.2043 -	}
 63.2044 -	else
 63.2045 -	{
 63.2046 -		//assert(sizeof(time_t) == 4);
 63.2047 -		read = gzread(gzFile,
 63.2048 -		              &gbDataMBC3.mapperSeconds,
 63.2049 -		              sizeof(int32) * 10 + /*sizeof(time_t)*/4);
 63.2050 -
 63.2051 -		if (read != (sizeof(int32) * 10 + /*sizeof(time_t)*/4) && read != 0)
 63.2052 -		{
 63.2053 -			systemMessage(MSG_FAILED_TO_READ_RTC,
 63.2054 -			              N_("Failed to read RTC from save game %s (continuing)"),
 63.2055 -			              name);
 63.2056 -			res = false;
 63.2057 -		}
 63.2058 -	}
 63.2059 -
 63.2060 -	gzclose(gzFile);
 63.2061 -	return res;
 63.2062 -}
 63.2063 -
 63.2064 -bool gbReadSaveMBC5(const char *name)
 63.2065 -{
 63.2066 -	gzFile gzFile = gzopen(name, "rb");
 63.2067 -
 63.2068 -	if (gzFile == NULL)
 63.2069 -	{
 63.2070 -		return false;
 63.2071 -	}
 63.2072 -
 63.2073 -	int read = gzread(gzFile,
 63.2074 -	                  gbRam,
 63.2075 -	                  gbRamSize);
 63.2076 -
 63.2077 -	if (read != gbRamSize)
 63.2078 -	{
 63.2079 -		systemMessage(MSG_FAILED_TO_READ_SGM,
 63.2080 -		              N_("Failed to read complete save game %s (%d)"), name, read);
 63.2081 -		gzclose(gzFile);
 63.2082 -		return false;
 63.2083 -	}
 63.2084 -
 63.2085 -	gzclose(gzFile);
 63.2086 -	return true;
 63.2087 -}
 63.2088 -
 63.2089 -bool gbReadSaveMBC7(const char *name)
 63.2090 -{
 63.2091 -	FILE *file = fopen(name, "rb");
 63.2092 -
 63.2093 -	if (file == NULL)
 63.2094 -	{
 63.2095 -		return false;
 63.2096 -	}
 63.2097 -
 63.2098 -	int read = fread(&gbMemory[0xa000],
 63.2099 -	                 1,
 63.2100 -	                 256,
 63.2101 -	                 file);
 63.2102 -
 63.2103 -	if (read != 256)
 63.2104 -	{
 63.2105 -		systemMessage(MSG_FAILED_TO_READ_SGM,
 63.2106 -		              N_("Failed to read complete save game %s (%d)"), name, read);
 63.2107 -		fclose(file);
 63.2108 -		return false;
 63.2109 -	}
 63.2110 -
 63.2111 -	fclose(file);
 63.2112 -	return true;
 63.2113 -}
 63.2114 -
 63.2115 -#if 0
 63.2116 -bool gbLoadBIOS(const char *biosFileName, bool useBiosFile)
 63.2117 -{
 63.2118 -	useBios = false;
 63.2119 -	if (useBiosFile)
 63.2120 -	{
 63.2121 -		useBios = utilLoadBIOS(bios, biosFileName, gbEmulatorType);
 63.2122 -		if (!useBios)
 63.2123 -		{
 63.2124 -			systemMessage(MSG_INVALID_BIOS_FILE_SIZE, N_("Invalid BOOTROM file"));
 63.2125 -		}
 63.2126 -	}
 63.2127 -	return useBios;
 63.2128 -}
 63.2129 -#endif
 63.2130 -
 63.2131 -void gbInit()
 63.2132 -{
 63.2133 -	gbGenFilter();
 63.2134 -	gbSgbInit();    // calls gbSgbReset()... whatever
 63.2135 -
 63.2136 -	gbMemory = (u8 *)malloc(65536 + 4);
 63.2137 -	memset(gbMemory, 0, 65536 + 4);
 63.2138 -	memset(gbPalette, 0, 2 * 128);
 63.2139 -
 63.2140 -	// HACK: +4 at start to accomodate the 2xSaI filter reading out of bounds of the leftmost pixel
 63.2141 -	origPix = (u8 *)calloc(1, 4 * 257 * 226 + 4);
 63.2142 -	pix		= origPix + 4;
 63.2143 -
 63.2144 -	gbLineBuffer = (u16 *)malloc(160 * sizeof(u16));
 63.2145 -}
 63.2146 -
 63.2147 -bool gbWriteBatteryFile(const char *file, bool extendedSave)
 63.2148 -{
 63.2149 -	if (gbBattery)
 63.2150 -	{
 63.2151 -		int type = gbRom[0x147];
 63.2152 -
 63.2153 -		switch (type)
 63.2154 -		{
 63.2155 -		case 0x03:
 63.2156 -			gbWriteSaveMBC1(file);
 63.2157 -			break;
 63.2158 -		case 0x06:
 63.2159 -			gbWriteSaveMBC2(file);
 63.2160 -			break;
 63.2161 -		case 0x0f:
 63.2162 -		case 0x10:
 63.2163 -		case 0x13:
 63.2164 -			gbWriteSaveMBC3(file, extendedSave);
 63.2165 -			break;
 63.2166 -		case 0x1b:
 63.2167 -		case 0x1e:
 63.2168 -			gbWriteSaveMBC5(file);
 63.2169 -			break;
 63.2170 -		case 0x22:
 63.2171 -			gbWriteSaveMBC7(file);
 63.2172 -			break;
 63.2173 -		case 0xff:
 63.2174 -			gbWriteSaveMBC1(file);
 63.2175 -			break;
 63.2176 -		}
 63.2177 -	}
 63.2178 -	return true;
 63.2179 -}
 63.2180 -
 63.2181 -bool gbWriteBatteryFile(const char *file)
 63.2182 -{
 63.2183 -	gbWriteBatteryFile(file, true);
 63.2184 -	return true;
 63.2185 -}
 63.2186 -
 63.2187 -bool gbWriteBatteryToStream(gzFile gzfile)
 63.2188 -{
 63.2189 -	// the GB save code is ugly, so rather than convert it all to use gzFiles, just save it to a temp file...
 63.2190 -#define TEMP_SAVE_FNAME ("tempvbawrite.sav")
 63.2191 -	bool retVal = gbWriteBatteryFile(TEMP_SAVE_FNAME, true);
 63.2192 -
 63.2193 -	// ...open the temp file and figure out its size...
 63.2194 -	FILE *fileTemp = fopen(TEMP_SAVE_FNAME, "rb");
 63.2195 -	if (fileTemp == NULL)
 63.2196 -		return false;
 63.2197 -	fseek(fileTemp, 0, SEEK_END);
 63.2198 -	int len = (int) ftell(fileTemp);
 63.2199 -
 63.2200 -	// ...copy over the temp file...
 63.2201 -	char *temp = new char [len];
 63.2202 -	fseek(fileTemp, 0, SEEK_SET);
 63.2203 -	if (fread(temp, len, 1, fileTemp) != 1)
 63.2204 -	{
 63.2205 -		delete [] temp;
 63.2206 -		fclose(fileTemp);
 63.2207 -		return false;
 63.2208 -	}
 63.2209 -	fclose(fileTemp);
 63.2210 -	utilGzWrite(gzfile, temp, len);
 63.2211 -	delete [] temp;
 63.2212 -
 63.2213 -	// ... and delete the temp file
 63.2214 -	remove(TEMP_SAVE_FNAME);
 63.2215 -#undef TEMP_SAVE_FNAME
 63.2216 -
 63.2217 -	return retVal;
 63.2218 -}
 63.2219 -
 63.2220 -bool gbReadBatteryFile(const char *file)
 63.2221 -{
 63.2222 -	bool res = false;
 63.2223 -	if (gbBattery)
 63.2224 -	{
 63.2225 -		int type = gbRom[0x147];
 63.2226 -
 63.2227 -		switch (type)
 63.2228 -		{
 63.2229 -		case 0x03:
 63.2230 -			res = gbReadSaveMBC1(file);
 63.2231 -			break;
 63.2232 -		case 0x06:
 63.2233 -			res = gbReadSaveMBC2(file);
 63.2234 -			break;
 63.2235 -		case 0x0f:
 63.2236 -		case 0x10:
 63.2237 -		case 0x13:
 63.2238 -			if (!gbReadSaveMBC3(file))
 63.2239 -			{
 63.2240 -				struct tm *lt;
 63.2241 -				time_t tmp; //Small kludge to get it working on some systems where time_t has size 8.
 63.2242 -
 63.2243 -				if (VBAMovieActive() || VBAMovieLoading())
 63.2244 -				{
 63.2245 -					gbDataMBC3.mapperLastTime = VBAMovieGetId() + VBAMovieGetFrameCounter() / 60;
 63.2246 -					lt = gmtime(&tmp);
 63.2247 -					gbDataMBC3.mapperLastTime=(u32)tmp;
 63.2248 -				}
 63.2249 -				else
 63.2250 -				{
 63.2251 -					time(&tmp);
 63.2252 -					gbDataMBC3.mapperLastTime=(u32)tmp;
 63.2253 -					lt = localtime(&tmp);
 63.2254 -				}
 63.2255 -				systemScreenMessage(ctime(&tmp), 4);
 63.2256 -				gbDataMBC3.mapperLastTime=(u32)tmp;
 63.2257 -
 63.2258 -				gbDataMBC3.mapperSeconds = lt->tm_sec;
 63.2259 -				gbDataMBC3.mapperMinutes = lt->tm_min;
 63.2260 -				gbDataMBC3.mapperHours	 = lt->tm_hour;
 63.2261 -				gbDataMBC3.mapperDays	 = lt->tm_yday & 255;
 63.2262 -				gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) |
 63.2263 -				                           (lt->tm_yday > 255 ? 1 : 0);
 63.2264 -				res = false;
 63.2265 -				break;
 63.2266 -			}
 63.2267 -			time_t tmp;
 63.2268 -			systemScreenMessage(ctime(&tmp), 4);
 63.2269 -			gbDataMBC3.mapperLastTime=(u32)tmp;
 63.2270 -			res = true;
 63.2271 -			break;
 63.2272 -		case 0x1b:
 63.2273 -		case 0x1e:
 63.2274 -			res = gbReadSaveMBC5(file);
 63.2275 -			break;
 63.2276 -		case 0x22:
 63.2277 -			res = gbReadSaveMBC7(file);
 63.2278 -		case 0xff:
 63.2279 -			res = gbReadSaveMBC1(file);
 63.2280 -			break;
 63.2281 -		}
 63.2282 -	}
 63.2283 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 63.2284 -	return res;
 63.2285 -}
 63.2286 -
 63.2287 -bool gbReadBatteryFromStream(gzFile gzfile)
 63.2288 -{
 63.2289 -	// the GB save code is ugly, so rather than convert it all to use gzFiles, just copy it to temp RAM...
 63.2290 -#define TEMP_SAVE_FNAME ("tempvbaread.sav")
 63.2291 -	int	  pos	 = gztell(gzfile);
 63.2292 -	int	  buflen = 1024;
 63.2293 -	// ...make a temp file and write it there...
 63.2294 -	FILE *fileTemp = fopen(TEMP_SAVE_FNAME, "wb");
 63.2295 -	if (fileTemp == NULL)
 63.2296 -		return false;
 63.2297 -	int gzDeflated;
 63.2298 -	char *temp	 = new char [buflen];
 63.2299 -	while ((gzDeflated = utilGzRead(gzfile, temp, buflen)) != 0)
 63.2300 -	{
 63.2301 -		if (gzDeflated == -1 || fwrite(temp, gzDeflated, 1, fileTemp) != 1)
 63.2302 -		{
 63.2303 -			delete [] temp;
 63.2304 -			fclose(fileTemp);
 63.2305 -			gzseek(gzfile, pos, SEEK_SET); /// FIXME: leaves pos in gzfile before save instead of after it (everything that
 63.2306 -			                               // calls this right now does a seek afterwards so it doesn't matter for now, but it's
 63.2307 -			                               // still bad)
 63.2308 -			return false;
 63.2309 -		}
 63.2310 -	}
 63.2311 -	gzseek(gzfile, pos, SEEK_SET); /// FIXME: leaves pos in gzfile before save instead of after it (everything that calls this
 63.2312 -	                               // right now does a seek afterwards so it doesn't matter for now, but it's still bad)
 63.2313 -	fclose(fileTemp);
 63.2314 -	delete [] temp;
 63.2315 -
 63.2316 -	// ... load from the temp file...
 63.2317 -	bool retVal = gbReadBatteryFile(TEMP_SAVE_FNAME);
 63.2318 -
 63.2319 -	// ... and delete the temp file
 63.2320 -	remove(TEMP_SAVE_FNAME);
 63.2321 -#undef TEMP_SAVE_FNAME
 63.2322 -
 63.2323 -	return retVal;
 63.2324 -}
 63.2325 -
 63.2326 -bool gbReadGSASnapshot(const char *fileName)
 63.2327 -{
 63.2328 -	FILE *file = fopen(fileName, "rb");
 63.2329 -
 63.2330 -	if (!file)
 63.2331 -	{
 63.2332 -		systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName);
 63.2333 -		return false;
 63.2334 -	}
 63.2335 -
 63.2336 -	//  long size = ftell(file);
 63.2337 -	fseek(file, 0x4, SEEK_SET);
 63.2338 -	char buffer[16];
 63.2339 -	char buffer2[16];
 63.2340 -	fread(buffer, 1, 15, file);
 63.2341 -	buffer[15] = 0;
 63.2342 -	memcpy(buffer2, &gbRom[0x134], 15);
 63.2343 -	buffer2[15] = 0;
 63.2344 -	if (memcmp(buffer, buffer2, 15))
 63.2345 -	{
 63.2346 -		systemMessage(MSG_CANNOT_IMPORT_SNAPSHOT_FOR,
 63.2347 -		              N_("Cannot import snapshot for %s. Current game is %s"),
 63.2348 -		              buffer,
 63.2349 -		              buffer2);
 63.2350 -		fclose(file);
 63.2351 -		return false;
 63.2352 -	}
 63.2353 -	fseek(file, 0x13, SEEK_SET);
 63.2354 -	int read   = 0;
 63.2355 -	int toRead = 0;
 63.2356 -	switch (gbRom[0x147])
 63.2357 -	{
 63.2358 -	case 0x03:
 63.2359 -	case 0x0f:
 63.2360 -	case 0x10:
 63.2361 -	case 0x13:
 63.2362 -	case 0x1b:
 63.2363 -	case 0x1e:
 63.2364 -	case 0xff:
 63.2365 -		read   = fread(gbRam, 1, gbRamSize, file);
 63.2366 -		toRead = gbRamSize;
 63.2367 -		break;
 63.2368 -	case 0x06:
 63.2369 -	case 0x22:
 63.2370 -		read   = fread(&gbMemory[0xa000], 1, 256, file);
 63.2371 -		toRead = 256;
 63.2372 -		break;
 63.2373 -	default:
 63.2374 -		systemMessage(MSG_UNSUPPORTED_SNAPSHOT_FILE,
 63.2375 -		              N_("Unsupported snapshot file %s"),
 63.2376 -		              fileName);
 63.2377 -		fclose(file);
 63.2378 -		return false;
 63.2379 -	}
 63.2380 -	fclose(file);
 63.2381 -	gbReset();
 63.2382 -	return true;
 63.2383 -}
 63.2384 -
 63.2385 -variable_desc gbSaveGameStruct[] =
 63.2386 -{
 63.2387 -	{ &PC.W,					   sizeof(u16)						 },
 63.2388 -	{ &SP.W,					   sizeof(u16)						 },
 63.2389 -	{ &AF.W,					   sizeof(u16)						 },
 63.2390 -	{ &BC.W,					   sizeof(u16)						 },
 63.2391 -	{ &DE.W,					   sizeof(u16)						 },
 63.2392 -	{ &HL.W,					   sizeof(u16)						 },
 63.2393 -	{ &IFF,						   sizeof(u8)						 },
 63.2394 -	{ &GBLCD_MODE_0_CLOCK_TICKS,   sizeof(int32)					 },
 63.2395 -	{ &GBLCD_MODE_1_CLOCK_TICKS,   sizeof(int32)					 },
 63.2396 -	{ &GBLCD_MODE_2_CLOCK_TICKS,   sizeof(int32)					 },
 63.2397 -	{ &GBLCD_MODE_3_CLOCK_TICKS,   sizeof(int32)					 },
 63.2398 -	{ &GBDIV_CLOCK_TICKS,		   sizeof(int32)					 },
 63.2399 -	{ &GBLY_INCREMENT_CLOCK_TICKS, sizeof(int32)					 },
 63.2400 -	{ &GBTIMER_MODE_0_CLOCK_TICKS, sizeof(int32)					 },
 63.2401 -	{ &GBTIMER_MODE_1_CLOCK_TICKS, sizeof(int32)					 },
 63.2402 -	{ &GBTIMER_MODE_2_CLOCK_TICKS, sizeof(int32)					 },
 63.2403 -	{ &GBTIMER_MODE_3_CLOCK_TICKS, sizeof(int32)					 },
 63.2404 -	{ &GBSERIAL_CLOCK_TICKS,	   sizeof(int32)					 },
 63.2405 -	{ &GBSYNCHRONIZE_CLOCK_TICKS,  sizeof(int32)					 },
 63.2406 -	{ &gbDivTicks,				   sizeof(int32)					 },
 63.2407 -	{ &gbLcdMode,				   sizeof(int32)					 },
 63.2408 -	{ &gbLcdTicks,				   sizeof(int32)					 },
 63.2409 -	{ &gbLcdLYIncrementTicks,	   sizeof(int32)					 },
 63.2410 -	{ &gbTimerTicks,			   sizeof(int32)					 },
 63.2411 -	{ &gbTimerClockTicks,		   sizeof(int32)					 },
 63.2412 -	{ &gbSerialTicks,			   sizeof(int32)					 },
 63.2413 -	{ &gbSerialBits,			   sizeof(int32)					 },
 63.2414 -	{ &gbInterrupt,				   sizeof(int32)					 },
 63.2415 -	{ &gbInterruptWait,			   sizeof(int32)					 },
 63.2416 -	{ &gbSynchronizeTicks,		   sizeof(int32)					 },
 63.2417 -	{ &gbTimerOn,				   sizeof(int32)					 },
 63.2418 -	{ &gbTimerMode,				   sizeof(int32)					 },
 63.2419 -	{ &gbSerialOn,				   sizeof(int32)					 },
 63.2420 -	{ &gbWindowLine,			   sizeof(int32)					 },
 63.2421 -	{ &gbCgbMode,				   sizeof(int32)					 },
 63.2422 -	{ &gbVramBank,				   sizeof(int32)					 },
 63.2423 -	{ &gbWramBank,				   sizeof(int32)					 },
 63.2424 -	{ &gbHdmaSource,			   sizeof(int32)					 },
 63.2425 -	{ &gbHdmaDestination,		   sizeof(int32)					 },
 63.2426 -	{ &gbHdmaBytes,				   sizeof(int32)					 },
 63.2427 -	{ &gbHdmaOn,				   sizeof(int32)					 },
 63.2428 -	{ &gbSpeed,					   sizeof(int32)					 },
 63.2429 -	{ &gbSgbMode,				   sizeof(int32)					 },
 63.2430 -	{ &register_DIV,			   sizeof(u8)						 },
 63.2431 -	{ &register_TIMA,			   sizeof(u8)						 },
 63.2432 -	{ &register_TMA,			   sizeof(u8)						 },
 63.2433 -	{ &register_TAC,			   sizeof(u8)						 },
 63.2434 -	{ &register_IF,				   sizeof(u8)						 },
 63.2435 -	{ &register_LCDC,			   sizeof(u8)						 },
 63.2436 -	{ &register_STAT,			   sizeof(u8)						 },
 63.2437 -	{ &register_SCY,			   sizeof(u8)						 },
 63.2438 -	{ &register_SCX,			   sizeof(u8)						 },
 63.2439 -	{ &register_LY,				   sizeof(u8)						 },
 63.2440 -	{ &register_LYC,			   sizeof(u8)						 },
 63.2441 -	{ &register_DMA,			   sizeof(u8)						 },
 63.2442 -	{ &register_WY,				   sizeof(u8)						 },
 63.2443 -	{ &register_WX,				   sizeof(u8)						 },
 63.2444 -	{ &register_VBK,			   sizeof(u8)						 },
 63.2445 -	{ &register_HDMA1,			   sizeof(u8)						 },
 63.2446 -	{ &register_HDMA2,			   sizeof(u8)						 },
 63.2447 -	{ &register_HDMA3,			   sizeof(u8)						 },
 63.2448 -	{ &register_HDMA4,			   sizeof(u8)						 },
 63.2449 -	{ &register_HDMA5,			   sizeof(u8)						 },
 63.2450 -	{ &register_SVBK,			   sizeof(u8)						 },
 63.2451 -	{ &register_IE,				   sizeof(u8)						 },
 63.2452 -	{ &gbBgp[0],				   sizeof(u8)						 },
 63.2453 -	{ &gbBgp[1],				   sizeof(u8)						 },
 63.2454 -	{ &gbBgp[2],				   sizeof(u8)						 },
 63.2455 -	{ &gbBgp[3],				   sizeof(u8)						 },
 63.2456 -	{ &gbObp0[0],				   sizeof(u8)						 },
 63.2457 -	{ &gbObp0[1],				   sizeof(u8)						 },
 63.2458 -	{ &gbObp0[2],				   sizeof(u8)						 },
 63.2459 -	{ &gbObp0[3],				   sizeof(u8)						 },
 63.2460 -	{ &gbObp1[0],				   sizeof(u8)						 },
 63.2461 -	{ &gbObp1[1],				   sizeof(u8)						 },
 63.2462 -	{ &gbObp1[2],				   sizeof(u8)						 },
 63.2463 -	{ &gbObp1[3],				   sizeof(u8)						 },
 63.2464 -	{ NULL,						   0								 }
 63.2465 -};
 63.2466 -
 63.2467 -bool gbWriteSaveStateToStream(gzFile gzFile)
 63.2468 -{
 63.2469 -	utilWriteInt(gzFile, GBSAVE_GAME_VERSION);
 63.2470 -
 63.2471 -	utilGzWrite(gzFile, &gbRom[0x134], 15);
 63.2472 -
 63.2473 -	utilWriteData(gzFile, gbSaveGameStruct);
 63.2474 -
 63.2475 -	utilGzWrite(gzFile, &IFF, 2);
 63.2476 -
 63.2477 -	if (gbSgbMode)
 63.2478 -	{
 63.2479 -		gbSgbSaveGame(gzFile);
 63.2480 -	}
 63.2481 -
 63.2482 -	utilGzWrite(gzFile, &gbDataMBC1, sizeof(gbDataMBC1));
 63.2483 -	utilGzWrite(gzFile, &gbDataMBC2, sizeof(gbDataMBC2));
 63.2484 -	//assert(sizeof(time_t) == 4);
 63.2485 -	utilGzWrite(gzFile, &gbDataMBC3, sizeof(gbDataMBC3));
 63.2486 -	utilGzWrite(gzFile, &gbDataMBC5, sizeof(gbDataMBC5));
 63.2487 -	utilGzWrite(gzFile, &gbDataHuC1, sizeof(gbDataHuC1));
 63.2488 -	utilGzWrite(gzFile, &gbDataHuC3, sizeof(gbDataHuC3));
 63.2489 -
 63.2490 -	// yes, this definitely needs to be saved, or loading paused games will show a black screen
 63.2491 -	// this is also necessary to be consistent with what the GBA saving does
 63.2492 -	utilGzWrite(gzFile, pix, 4 * 257 * 226);
 63.2493 -
 63.2494 -	utilGzWrite(gzFile, gbPalette, 128 * sizeof(u16));
 63.2495 -	// todo: remove
 63.2496 -	utilGzWrite(gzFile, gbPalette, 128 * sizeof(u16));
 63.2497 -
 63.2498 -	utilGzWrite(gzFile, &gbMemory[0x8000], 0x8000);
 63.2499 -
 63.2500 -	if (gbRamSize && gbRam)
 63.2501 -	{
 63.2502 -		utilGzWrite(gzFile, gbRam, gbRamSize);
 63.2503 -	}
 63.2504 -
 63.2505 -	if (gbCgbMode)
 63.2506 -	{
 63.2507 -		utilGzWrite(gzFile, gbVram, 0x4000);
 63.2508 -		utilGzWrite(gzFile, gbWram, 0x8000);
 63.2509 -	}
 63.2510 -
 63.2511 -	gbSoundSaveGame(gzFile);
 63.2512 -
 63.2513 -	gbCheatsSaveGame(gzFile);
 63.2514 -
 63.2515 -	// new to re-recording version:
 63.2516 -	{
 63.2517 -		extern int32 sensorX, sensorY;
 63.2518 -		utilGzWrite(gzFile, &sensorX, sizeof(sensorX));
 63.2519 -		utilGzWrite(gzFile, &sensorY, sizeof(sensorY));
 63.2520 -		utilGzWrite(gzFile, gbJoymask, 4 * sizeof(*gbJoymask)); // this has to be saved or old input will incorrectly get
 63.2521 -		                                                        // carried
 63.2522 -		                                                        // back on loading a snapshot!
 63.2523 -
 63.2524 -		bool8 movieActive = VBAMovieActive();
 63.2525 -		utilGzWrite(gzFile, &movieActive, sizeof(movieActive));
 63.2526 -		if (movieActive)
 63.2527 -		{
 63.2528 -			uint8 *movie_freeze_buf	 = NULL;
 63.2529 -			uint32 movie_freeze_size = 0;
 63.2530 -
 63.2531 -			VBAMovieFreeze(&movie_freeze_buf, &movie_freeze_size);
 63.2532 -			if (movie_freeze_buf)
 63.2533 -			{
 63.2534 -				utilGzWrite(gzFile, &movie_freeze_size, sizeof(movie_freeze_size));
 63.2535 -				utilGzWrite(gzFile, movie_freeze_buf, movie_freeze_size);
 63.2536 -				delete [] movie_freeze_buf;
 63.2537 -			}
 63.2538 -			else
 63.2539 -			{
 63.2540 -				systemMessage(0, N_("Failed to save movie snapshot."));
 63.2541 -				return false;
 63.2542 -			}
 63.2543 -		}
 63.2544 -		utilGzWrite(gzFile, &GBSystemCounters.frameCount, sizeof(GBSystemCounters.frameCount));
 63.2545 -	}
 63.2546 -
 63.2547 -	// new to rerecording 19.4 wip (svn r22+):
 63.2548 -	{
 63.2549 -		utilGzWrite(gzFile, &GBSystemCounters.lagCount, sizeof(GBSystemCounters.lagCount));
 63.2550 -		utilGzWrite(gzFile, &GBSystemCounters.lagged, sizeof(GBSystemCounters.lagged));
 63.2551 -		utilGzWrite(gzFile, &GBSystemCounters.laggedLast, sizeof(GBSystemCounters.laggedLast));
 63.2552 -	}
 63.2553 -
 63.2554 -	return true;
 63.2555 -}
 63.2556 -
 63.2557 -bool gbWriteMemSaveState(char *memory, int available)
 63.2558 -{
 63.2559 -	gzFile gzFile = utilMemGzOpen(memory, available, "w");
 63.2560 -
 63.2561 -	if (gzFile == NULL)
 63.2562 -	{
 63.2563 -		return false;
 63.2564 -	}
 63.2565 -
 63.2566 -	bool res = gbWriteSaveStateToStream(gzFile);
 63.2567 -
 63.2568 -	long pos = utilGzTell(gzFile) + 8;
 63.2569 -
 63.2570 -	if (pos >= (available))
 63.2571 -		res = false;
 63.2572 -
 63.2573 -	utilGzClose(gzFile);
 63.2574 -
 63.2575 -	return res;
 63.2576 -}
 63.2577 -
 63.2578 -bool gbWriteSaveState(const char *name)
 63.2579 -{
 63.2580 -	gzFile gzFile = utilGzOpen(name, "wb");
 63.2581 -
 63.2582 -	if (gzFile == NULL)
 63.2583 -		return false;
 63.2584 -
 63.2585 -	bool res = gbWriteSaveStateToStream(gzFile);
 63.2586 -
 63.2587 -	utilGzClose(gzFile);
 63.2588 -	return res;
 63.2589 -}
 63.2590 -
 63.2591 -static int	tempStateID	  = 0;
 63.2592 -static int	tempFailCount = 0;
 63.2593 -static bool backupSafe	  = true;
 63.2594 -
 63.2595 -bool gbReadSaveStateFromStream(gzFile gzFile)
 63.2596 -{
 63.2597 -	int	 type;
 63.2598 -	char tempBackupName [128];
 63.2599 -	if (backupSafe)
 63.2600 -	{
 63.2601 -		sprintf(tempBackupName, "gbatempsave%d.sav", tempStateID++);
 63.2602 -		gbWriteSaveState(tempBackupName);
 63.2603 -	}
 63.2604 -
 63.2605 -	int version = utilReadInt(gzFile);
 63.2606 -
 63.2607 -	if (version > GBSAVE_GAME_VERSION || version < 0)
 63.2608 -	{
 63.2609 -		systemMessage(MSG_UNSUPPORTED_VB_SGM,
 63.2610 -		              N_("Unsupported VisualBoy save game version %d"), version);
 63.2611 -		goto failedLoadGB;
 63.2612 -	}
 63.2613 -
 63.2614 -	u8 romname[20];
 63.2615 -
 63.2616 -	utilGzRead(gzFile, romname, 15);
 63.2617 -
 63.2618 -	if (memcmp(&gbRom[0x134], romname, 15) != 0)
 63.2619 -	{
 63.2620 -		systemMessage(MSG_CANNOT_LOAD_SGM_FOR,
 63.2621 -		              N_("Cannot load save game for %s. Playing %s"),
 63.2622 -		              romname, &gbRom[0x134]);
 63.2623 -		goto failedLoadGB;
 63.2624 -	}
 63.2625 -
 63.2626 -	utilReadData(gzFile, gbSaveGameStruct);
 63.2627 -
 63.2628 -	if (version >= GBSAVE_GAME_VERSION_7)
 63.2629 -	{
 63.2630 -		utilGzRead(gzFile, &IFF, 2);
 63.2631 -	}
 63.2632 -
 63.2633 -	if (gbSgbMode)
 63.2634 -	{
 63.2635 -		gbSgbReadGame(gzFile, version);
 63.2636 -	}
 63.2637 -	else
 63.2638 -	{
 63.2639 -		gbSgbMask = 0; // loading a game at the wrong time causes no display
 63.2640 -	}
 63.2641 -
 63.2642 -	utilGzRead(gzFile, &gbDataMBC1, sizeof(gbDataMBC1));
 63.2643 -	utilGzRead(gzFile, &gbDataMBC2, sizeof(gbDataMBC2));
 63.2644 -	if (version < GBSAVE_GAME_VERSION_4)
 63.2645 -		// prior to version 4, there was no adjustment for the time the game
 63.2646 -		// was last played, so we have less to read. This needs update if the
 63.2647 -		// structure changes again.
 63.2648 -		utilGzRead(gzFile, &gbDataMBC3, sizeof(int32) * 10);
 63.2649 -	else
 63.2650 -	{
 63.2651 -		//assert(sizeof(time_t) == 4);
 63.2652 -		utilGzRead(gzFile, &gbDataMBC3, sizeof(gbDataMBC3));
 63.2653 -	}
 63.2654 -	utilGzRead(gzFile, &gbDataMBC5, sizeof(gbDataMBC5));
 63.2655 -	utilGzRead(gzFile, &gbDataHuC1, sizeof(gbDataHuC1));
 63.2656 -	utilGzRead(gzFile, &gbDataHuC3, sizeof(gbDataHuC3));
 63.2657 -
 63.2658 -	if (version >= GBSAVE_GAME_VERSION_12)
 63.2659 -	{
 63.2660 -		utilGzRead(gzFile, pix, 4 * 257 * 226);
 63.2661 -	}
 63.2662 -	else
 63.2663 -	{
 63.2664 -		memset(pix, 0, 257 * 226 * sizeof(u32));
 63.2665 -//		if(version < GBSAVE_GAME_VERSION_5)
 63.2666 -//			utilGzRead(gzFile, pix, 256*224*sizeof(u16));
 63.2667 -	}
 63.2668 -
 63.2669 -	if (version < GBSAVE_GAME_VERSION_6)
 63.2670 -	{
 63.2671 -		utilGzRead(gzFile, gbPalette, 64 * sizeof(u16));
 63.2672 -	}
 63.2673 -	else
 63.2674 -		utilGzRead(gzFile, gbPalette, 128 * sizeof(u16));
 63.2675 -
 63.2676 -	// todo: remove
 63.2677 -	utilGzRead(gzFile, gbPalette, 128 * sizeof(u16));
 63.2678 -
 63.2679 -	if (version < GBSAVE_GAME_VERSION_10)
 63.2680 -	{
 63.2681 -		if (!gbCgbMode && !gbSgbMode)
 63.2682 -		{
 63.2683 -			for (int i = 0; i < 8; i++)
 63.2684 -				gbPalette[i] = systemGbPalette[gbPaletteOption * 8 + i];
 63.2685 -		}
 63.2686 -	}
 63.2687 -
 63.2688 -	utilGzRead(gzFile, &gbMemory[0x8000], 0x8000);
 63.2689 -
 63.2690 -	if (gbRamSize && gbRam)
 63.2691 -	{
 63.2692 -		utilGzRead(gzFile, gbRam, gbRamSize);
 63.2693 -	}
 63.2694 -
 63.2695 -	gbMemoryMap[0x00] = &gbRom[0x0000];
 63.2696 -	gbMemoryMap[0x01] = &gbRom[0x1000];
 63.2697 -	gbMemoryMap[0x02] = &gbRom[0x2000];
 63.2698 -	gbMemoryMap[0x03] = &gbRom[0x3000];
 63.2699 -	gbMemoryMap[0x04] = &gbRom[0x4000];
 63.2700 -	gbMemoryMap[0x05] = &gbRom[0x5000];
 63.2701 -	gbMemoryMap[0x06] = &gbRom[0x6000];
 63.2702 -	gbMemoryMap[0x07] = &gbRom[0x7000];
 63.2703 -	gbMemoryMap[0x08] = &gbMemory[0x8000];
 63.2704 -	gbMemoryMap[0x09] = &gbMemory[0x9000];
 63.2705 -	gbMemoryMap[0x0a] = &gbMemory[0xa000];
 63.2706 -	gbMemoryMap[0x0b] = &gbMemory[0xb000];
 63.2707 -	gbMemoryMap[0x0c] = &gbMemory[0xc000];
 63.2708 -	gbMemoryMap[0x0d] = &gbMemory[0xd000];
 63.2709 -	gbMemoryMap[0x0e] = &gbMemory[0xe000];
 63.2710 -	gbMemoryMap[0x0f] = &gbMemory[0xf000];
 63.2711 -
 63.2712 -	type = gbRom[0x147];
 63.2713 -
 63.2714 -	switch (type)
 63.2715 -	{
 63.2716 -	case 0x00:
 63.2717 -	case 0x01:
 63.2718 -	case 0x02:
 63.2719 -	case 0x03:
 63.2720 -		// MBC 1
 63.2721 -		memoryUpdateMapMBC1();
 63.2722 -		break;
 63.2723 -	case 0x05:
 63.2724 -	case 0x06:
 63.2725 -		// MBC2
 63.2726 -		memoryUpdateMapMBC2();
 63.2727 -		break;
 63.2728 -	case 0x0f:
 63.2729 -	case 0x10:
 63.2730 -	case 0x11:
 63.2731 -	case 0x12:
 63.2732 -	case 0x13:
 63.2733 -		// MBC 3
 63.2734 -		memoryUpdateMapMBC3();
 63.2735 -		break;
 63.2736 -	case 0x19:
 63.2737 -	case 0x1a:
 63.2738 -	case 0x1b:
 63.2739 -		// MBC5
 63.2740 -		memoryUpdateMapMBC5();
 63.2741 -		break;
 63.2742 -	case 0x1c:
 63.2743 -	case 0x1d:
 63.2744 -	case 0x1e:
 63.2745 -		// MBC 5 Rumble
 63.2746 -		memoryUpdateMapMBC5();
 63.2747 -		break;
 63.2748 -	case 0x22:
 63.2749 -		// MBC 7
 63.2750 -		memoryUpdateMapMBC7();
 63.2751 -		break;
 63.2752 -	case 0xfe:
 63.2753 -		// HuC3
 63.2754 -		memoryUpdateMapHuC3();
 63.2755 -		break;
 63.2756 -	case 0xff:
 63.2757 -		// HuC1
 63.2758 -		memoryUpdateMapHuC1();
 63.2759 -		break;
 63.2760 -	}
 63.2761 -
 63.2762 -	if (gbCgbMode)
 63.2763 -	{
 63.2764 -		if (!gbVram)
 63.2765 -			gbVram = (u8 *)malloc(0x4000 + 4);
 63.2766 -		if (!gbWram)
 63.2767 -			gbWram = (u8 *)malloc(0x8000 + 4);
 63.2768 -		utilGzRead(gzFile, gbVram, 0x4000);
 63.2769 -		utilGzRead(gzFile, gbWram, 0x8000);
 63.2770 -
 63.2771 -		int value = register_SVBK;
 63.2772 -		if (value == 0)
 63.2773 -			value = 1;
 63.2774 -
 63.2775 -		gbMemoryMap[0x08] = &gbVram[register_VBK * 0x2000];
 63.2776 -		gbMemoryMap[0x09] = &gbVram[register_VBK * 0x2000 + 0x1000];
 63.2777 -		gbMemoryMap[0x0d] = &gbWram[value * 0x1000];
 63.2778 -	}
 63.2779 -	else
 63.2780 -	{
 63.2781 -		if (gbVram)
 63.2782 -		{
 63.2783 -			free(gbVram);
 63.2784 -			gbVram = NULL;
 63.2785 -		}
 63.2786 -		if (gbWram)
 63.2787 -		{
 63.2788 -			free(gbWram);
 63.2789 -			gbWram = NULL;
 63.2790 -		}
 63.2791 -	}
 63.2792 -
 63.2793 -	gbSoundReadGame(version, gzFile);
 63.2794 -
 63.2795 -#if 0
 63.2796 -	if (gbBorderOn)
 63.2797 -	{
 63.2798 -		gbSgbRenderBorder();
 63.2799 -	}
 63.2800 -
 63.2801 -	systemRefreshScreen();
 63.2802 -#endif
 63.2803 -
 63.2804 -	if (version > GBSAVE_GAME_VERSION_1)
 63.2805 -		gbCheatsReadGame(gzFile, version);
 63.2806 -
 63.2807 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 63.2808 -
 63.2809 -	if (version >= GBSAVE_GAME_VERSION_11) // new to re-recording version:
 63.2810 -	{
 63.2811 -		extern int32 sensorX, sensorY; // from SDL.cpp
 63.2812 -		utilGzRead(gzFile, &sensorX, sizeof(sensorX));
 63.2813 -		utilGzRead(gzFile, &sensorY, sizeof(sensorY));
 63.2814 -		utilGzRead(gzFile, gbJoymask, 4 * sizeof(*gbJoymask)); // this has to be saved or old input will incorrectly get carried
 63.2815 -		                                                       // back on loading a snapshot!
 63.2816 -
 63.2817 -		bool8 movieSnapshot;
 63.2818 -		utilGzRead(gzFile, &movieSnapshot, sizeof(movieSnapshot));
 63.2819 -		if (VBAMovieActive() && !movieSnapshot)
 63.2820 -		{
 63.2821 -			systemMessage(0, N_("Can't load a non-movie snapshot while a movie is active."));
 63.2822 -			goto failedLoadGB;
 63.2823 -		}
 63.2824 -
 63.2825 -		if (movieSnapshot) // even if a movie isn't active we still want to parse through this in case other stuff is added
 63.2826 -		                   // later on in the save format
 63.2827 -		{
 63.2828 -			uint32 movieInputDataSize = 0;
 63.2829 -			utilGzRead(gzFile, &movieInputDataSize, sizeof(movieInputDataSize));
 63.2830 -			uint8 *local_movie_data = new uint8 [movieInputDataSize];
 63.2831 -			int	   readBytes		= utilGzRead(gzFile, local_movie_data, movieInputDataSize);
 63.2832 -			if (readBytes != movieInputDataSize)
 63.2833 -			{
 63.2834 -				systemMessage(0, N_("Corrupt movie snapshot."));
 63.2835 -				if (local_movie_data)
 63.2836 -					delete [] local_movie_data;
 63.2837 -				goto failedLoadGB;
 63.2838 -			}
 63.2839 -			int code = VBAMovieUnfreeze(local_movie_data, movieInputDataSize);
 63.2840 -			if (local_movie_data)
 63.2841 -				delete [] local_movie_data;
 63.2842 -			if (code != MOVIE_SUCCESS && VBAMovieActive())
 63.2843 -			{
 63.2844 -				char errStr [1024];
 63.2845 -				strcpy(errStr, "Failed to load movie snapshot");
 63.2846 -				switch (code)
 63.2847 -				{
 63.2848 -				case MOVIE_NOT_FROM_THIS_MOVIE:
 63.2849 -					strcat(errStr, ";\nSnapshot not from this movie"); break;
 63.2850 -				case MOVIE_NOT_FROM_A_MOVIE:
 63.2851 -					strcat(errStr, ";\nNot a movie snapshot"); break;                    // shouldn't get here...
 63.2852 -				case MOVIE_SNAPSHOT_INCONSISTENT:
 63.2853 -					strcat(errStr, ";\nSnapshot inconsistent with movie"); break;
 63.2854 -				case MOVIE_WRONG_FORMAT:
 63.2855 -					strcat(errStr, ";\nWrong format"); break;
 63.2856 -				}
 63.2857 -				strcat(errStr, ".");
 63.2858 -				systemMessage(0, N_(errStr));
 63.2859 -				goto failedLoadGB;
 63.2860 -			}
 63.2861 -		}
 63.2862 -		utilGzRead(gzFile, &GBSystemCounters.frameCount, sizeof(GBSystemCounters.frameCount));
 63.2863 -	}
 63.2864 -
 63.2865 -	if (version >= GBSAVE_GAME_VERSION_13)   // new to rerecording 19.4 wip (svn r22+):
 63.2866 -	{
 63.2867 -		utilGzRead(gzFile, &GBSystemCounters.lagCount, sizeof(GBSystemCounters.lagCount));
 63.2868 -		utilGzRead(gzFile, &GBSystemCounters.lagged, sizeof(GBSystemCounters.lagged));
 63.2869 -		utilGzRead(gzFile, &GBSystemCounters.laggedLast, sizeof(GBSystemCounters.laggedLast));
 63.2870 -	}
 63.2871 -
 63.2872 -	if (backupSafe)
 63.2873 -	{
 63.2874 -		remove(tempBackupName);
 63.2875 -		tempFailCount = 0;
 63.2876 -	}
 63.2877 -
 63.2878 -	for (int i = 0; i < 4; ++i)
 63.2879 -		systemSetJoypad(i, gbJoymask[i] & 0xFFFF);
 63.2880 -
 63.2881 -	// FIXME: horrible kludge
 63.2882 -	memcpy(s_gbJoymask, gbJoymask, sizeof(gbJoymask));
 63.2883 -
 63.2884 -	VBAUpdateButtonPressDisplay();
 63.2885 -	VBAUpdateFrameCountDisplay();
 63.2886 -	systemRefreshScreen();
 63.2887 -	return true;
 63.2888 -
 63.2889 -failedLoadGB:
 63.2890 -	if (backupSafe)
 63.2891 -	{
 63.2892 -		tempFailCount++;
 63.2893 -		if (tempFailCount < 3) // fail no more than 2 times in a row
 63.2894 -			gbReadSaveState(tempBackupName);
 63.2895 -		remove(tempBackupName);
 63.2896 -	}
 63.2897 -	return false;
 63.2898 -}
 63.2899 -
 63.2900 -bool gbReadMemSaveState(char *memory, int available)
 63.2901 -{
 63.2902 -	gzFile gzFile = utilMemGzOpen(memory, available, "r");
 63.2903 -
 63.2904 -	backupSafe = false;
 63.2905 -	bool res = gbReadSaveStateFromStream(gzFile);
 63.2906 -	backupSafe = true;
 63.2907 -
 63.2908 -	utilGzClose(gzFile);
 63.2909 -
 63.2910 -	return res;
 63.2911 -}
 63.2912 -
 63.2913 -bool gbReadSaveState(const char *name)
 63.2914 -{
 63.2915 -	gzFile gzFile = utilGzOpen(name, "rb");
 63.2916 -
 63.2917 -	if (gzFile == NULL)
 63.2918 -	{
 63.2919 -		return false;
 63.2920 -	}
 63.2921 -
 63.2922 -	bool res = gbReadSaveStateFromStream(gzFile);
 63.2923 -
 63.2924 -	utilGzClose(gzFile);
 63.2925 -
 63.2926 -	return res;
 63.2927 -}
 63.2928 -
 63.2929 -bool gbWritePNGFile(const char *fileName)
 63.2930 -{
 63.2931 -	if (gbBorderOn)
 63.2932 -		return utilWritePNGFile(fileName, 256, 224, pix);
 63.2933 -	return utilWritePNGFile(fileName, 160, 144, pix);
 63.2934 -}
 63.2935 -
 63.2936 -bool gbWriteBMPFile(const char *fileName)
 63.2937 -{
 63.2938 -	if (gbBorderOn)
 63.2939 -		return utilWriteBMPFile(fileName, 256, 224, pix);
 63.2940 -	return utilWriteBMPFile(fileName, 160, 144, pix);
 63.2941 -}
 63.2942 -
 63.2943 -void gbCleanUp()
 63.2944 -{
 63.2945 -	newFrame	  = true;
 63.2946 -
 63.2947 -	GBSystemCounters.frameCount = 0;
 63.2948 -	GBSystemCounters.lagCount	= 0;
 63.2949 -	GBSystemCounters.extraCount = 0;
 63.2950 -	GBSystemCounters.lagged		= true;
 63.2951 -	GBSystemCounters.laggedLast = true;
 63.2952 -
 63.2953 -	if (gbRam != NULL)
 63.2954 -	{
 63.2955 -		free(gbRam);
 63.2956 -		gbRam = NULL;
 63.2957 -	}
 63.2958 -
 63.2959 -	if (gbRom != NULL)
 63.2960 -	{
 63.2961 -		free(gbRom);
 63.2962 -		gbRom = NULL;
 63.2963 -	}
 63.2964 -
 63.2965 -	if (gbMemory != NULL)
 63.2966 -	{
 63.2967 -		free(gbMemory);
 63.2968 -		gbMemory = NULL;
 63.2969 -	}
 63.2970 -
 63.2971 -	if (gbLineBuffer != NULL)
 63.2972 -	{
 63.2973 -		free(gbLineBuffer);
 63.2974 -		gbLineBuffer = NULL;
 63.2975 -	}
 63.2976 -
 63.2977 -	if (origPix != NULL)
 63.2978 -	{
 63.2979 -		free(origPix);
 63.2980 -		origPix = NULL;
 63.2981 -	}
 63.2982 -	pix = NULL;
 63.2983 -
 63.2984 -	gbSgbShutdown();
 63.2985 -
 63.2986 -	if (gbVram != NULL)
 63.2987 -	{
 63.2988 -		free(gbVram);
 63.2989 -		gbVram = NULL;
 63.2990 -	}
 63.2991 -
 63.2992 -	if (gbWram != NULL)
 63.2993 -	{
 63.2994 -		free(gbWram);
 63.2995 -		gbWram = NULL;
 63.2996 -	}
 63.2997 -
 63.2998 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 63.2999 -
 63.3000 -	memset(gbJoymask, 0, sizeof(gbJoymask));
 63.3001 -	// FIXME: horrible kludge
 63.3002 -	memset(s_gbJoymask, 0, sizeof(s_gbJoymask));
 63.3003 -
 63.3004 -	systemClearJoypads();
 63.3005 -	systemResetSensor();
 63.3006 -
 63.3007 -//	gbLastTime = gbFrameCount = 0;
 63.3008 -	systemRefreshScreen();
 63.3009 -}
 63.3010 -
 63.3011 -bool gbLoadRom(const char *szFile)
 63.3012 -{
 63.3013 -	int size = 0;
 63.3014 -
 63.3015 -	if (gbRom != NULL)
 63.3016 -	{
 63.3017 -		gbCleanUp();
 63.3018 -	}
 63.3019 -
 63.3020 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 63.3021 -
 63.3022 -	gbRom = utilLoad(szFile,
 63.3023 -	                 utilIsGBImage,
 63.3024 -	                 NULL,
 63.3025 -	                 size);
 63.3026 -	if (!gbRom)
 63.3027 -		return false;
 63.3028 -
 63.3029 -	gbRomSize = size;
 63.3030 -
 63.3031 -	return gbUpdateSizes();
 63.3032 -}
 63.3033 -
 63.3034 -bool gbUpdateSizes()
 63.3035 -{
 63.3036 -	if (gbRom[0x148] > 8)
 63.3037 -	{
 63.3038 -		systemMessage(MSG_UNSUPPORTED_ROM_SIZE,
 63.3039 -		              N_("Unsupported rom size %02x"), gbRom[0x148]);
 63.3040 -		return false;
 63.3041 -	}
 63.3042 -
 63.3043 -	if (gbRomSize < gbRomSizes[gbRom[0x148]])
 63.3044 -	{
 63.3045 -		gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
 63.3046 -	}
 63.3047 -	gbRomSize	  = gbRomSizes[gbRom[0x148]];
 63.3048 -	gbRomSizeMask = gbRomSizesMasks[gbRom[0x148]];
 63.3049 -
 63.3050 -	if (gbRom[0x149] > 5)
 63.3051 -	{
 63.3052 -		systemMessage(MSG_UNSUPPORTED_RAM_SIZE,
 63.3053 -		              N_("Unsupported ram size %02x"), gbRom[0x149]);
 63.3054 -		return false;
 63.3055 -	}
 63.3056 -
 63.3057 -	gbRamSize	  = gbRamSizes[gbRom[0x149]];
 63.3058 -	gbRamSizeMask = gbRamSizesMasks[gbRom[0x149]];
 63.3059 -
 63.3060 -	if (gbRamSize)
 63.3061 -	{
 63.3062 -		gbRam = (u8 *)malloc(gbRamSize + 4);
 63.3063 -		memset(gbRam, 0xFF, gbRamSize + 4);
 63.3064 -	}
 63.3065 -
 63.3066 -	int type = gbRom[0x147];
 63.3067 -
 63.3068 -	mapperReadRAM = NULL;
 63.3069 -
 63.3070 -	switch (type)
 63.3071 -	{
 63.3072 -	case 0x00:
 63.3073 -	case 0x01:
 63.3074 -	case 0x02:
 63.3075 -	case 0x03:
 63.3076 -		// MBC 1
 63.3077 -		mapper	  = mapperMBC1ROM;
 63.3078 -		mapperRAM = mapperMBC1RAM;
 63.3079 -		break;
 63.3080 -	case 0x05:
 63.3081 -	case 0x06:
 63.3082 -		// MBC2
 63.3083 -		mapper		  = mapperMBC2ROM;
 63.3084 -		mapperRAM	  = mapperMBC2RAM;
 63.3085 -		gbRamSize	  = 0x200;
 63.3086 -		gbRamSizeMask = 0x1ff;
 63.3087 -		break;
 63.3088 -	case 0x0f:
 63.3089 -	case 0x10:
 63.3090 -	case 0x11:
 63.3091 -	case 0x12:
 63.3092 -	case 0x13:
 63.3093 -		// MBC 3
 63.3094 -		mapper		  = mapperMBC3ROM;
 63.3095 -		mapperRAM	  = mapperMBC3RAM;
 63.3096 -		mapperReadRAM = mapperMBC3ReadRAM;
 63.3097 -		break;
 63.3098 -	case 0x19:
 63.3099 -	case 0x1a:
 63.3100 -	case 0x1b:
 63.3101 -		// MBC5
 63.3102 -		mapper	  = mapperMBC5ROM;
 63.3103 -		mapperRAM = mapperMBC5RAM;
 63.3104 -		break;
 63.3105 -	case 0x1c:
 63.3106 -	case 0x1d:
 63.3107 -	case 0x1e:
 63.3108 -		// MBC 5 Rumble
 63.3109 -		mapper	  = mapperMBC5ROM;
 63.3110 -		mapperRAM = mapperMBC5RAM;
 63.3111 -		break;
 63.3112 -	case 0x22:
 63.3113 -		// MBC 7
 63.3114 -		mapper		  = mapperMBC7ROM;
 63.3115 -		mapperRAM	  = mapperMBC7RAM;
 63.3116 -		mapperReadRAM = mapperMBC7ReadRAM;
 63.3117 -		break;
 63.3118 -	case 0xfe:
 63.3119 -		// HuC3
 63.3120 -		mapper		  = mapperHuC3ROM;
 63.3121 -		mapperRAM	  = mapperHuC3RAM;
 63.3122 -		mapperReadRAM = mapperHuC3ReadRAM;
 63.3123 -		break;
 63.3124 -	case 0xff:
 63.3125 -		// HuC1
 63.3126 -		mapper	  = mapperHuC1ROM;
 63.3127 -		mapperRAM = mapperHuC1RAM;
 63.3128 -		break;
 63.3129 -	default:
 63.3130 -		systemMessage(MSG_UNKNOWN_CARTRIDGE_TYPE,
 63.3131 -		              N_("Unknown cartridge type %02x"), type);
 63.3132 -		return false;
 63.3133 -	}
 63.3134 -
 63.3135 -	switch (type)
 63.3136 -	{
 63.3137 -	case 0x03:
 63.3138 -	case 0x06:
 63.3139 -	case 0x0f:
 63.3140 -	case 0x10:
 63.3141 -	case 0x13:
 63.3142 -	case 0x1b:
 63.3143 -	case 0x1d:
 63.3144 -	case 0x1e:
 63.3145 -	case 0x22:
 63.3146 -	case 0xff:
 63.3147 -		gbBattery = 1;
 63.3148 -		break;
 63.3149 -	}
 63.3150 -
 63.3151 -	gbInit();
 63.3152 -	gbReset();
 63.3153 -
 63.3154 -	return true;
 63.3155 -}
 63.3156 -
 63.3157 -void gbEmulate(int ticksToStop)
 63.3158 -{
 63.3159 -	gbRegister tempRegister;
 63.3160 -	u8		   tempValue;
 63.3161 -	s8		   offset;
 63.3162 -
 63.3163 -	int clockTicks = 0;
 63.3164 -	gbDmaTicks = 0;
 63.3165 -
 63.3166 -	register int opcode = 0;
 63.3167 -
 63.3168 -	u32 newmask = 0;
 63.3169 -	if (newFrame)
 63.3170 -	{
 63.3171 -		extern void VBAOnExitingFrameBoundary();
 63.3172 -		VBAOnExitingFrameBoundary();
 63.3173 -
 63.3174 -		// update joystick information
 63.3175 -		systemReadJoypads();
 63.3176 -
 63.3177 -		bool sensor = (gbRom[0x147] == 0x22);
 63.3178 -
 63.3179 -		// read joystick
 63.3180 -		if (gbSgbMode && gbSgbMultiplayer)
 63.3181 -		{
 63.3182 -			if (gbSgbFourPlayers)
 63.3183 -			{
 63.3184 -				gbJoymask[0] = systemGetJoypad(0, sensor);
 63.3185 -				gbJoymask[1] = systemGetJoypad(1, false);
 63.3186 -				gbJoymask[2] = systemGetJoypad(2, false);
 63.3187 -				gbJoymask[3] = systemGetJoypad(3, false);
 63.3188 -			}
 63.3189 -			else
 63.3190 -			{
 63.3191 -				gbJoymask[0] = systemGetJoypad(0, sensor);
 63.3192 -				gbJoymask[1] = systemGetJoypad(1, false);
 63.3193 -			}
 63.3194 -		}
 63.3195 -		else
 63.3196 -		{
 63.3197 -			gbJoymask[0] = systemGetJoypad(0, sensor);
 63.3198 -		}
 63.3199 -
 63.3200 -		// FIXME: horrible kludge
 63.3201 -		memcpy(s_gbJoymask, gbJoymask, sizeof(gbJoymask));
 63.3202 -
 63.3203 -//		if (sensor)
 63.3204 -//			systemUpdateMotionSensor(0);
 63.3205 -
 63.3206 -		newmask = gbJoymask[0];
 63.3207 -		if (newmask & 0xFF)
 63.3208 -		{
 63.3209 -			gbInterrupt |= 16;
 63.3210 -		}
 63.3211 -
 63.3212 -		extButtons = (newmask >> 18);
 63.3213 -		speedup	   = (extButtons & 1) != 0;
 63.3214 -
 63.3215 -		VBAMovieResetIfRequested();
 63.3216 -
 63.3217 -		CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION);
 63.3218 -
 63.3219 -		newFrame = false;
 63.3220 -	}
 63.3221 -
 63.3222 -	for (;; )
 63.3223 -	{
 63.3224 -#ifndef FINAL_VERSION
 63.3225 -		if (systemDebug)
 63.3226 -		{
 63.3227 -			if (!(IFF & 0x80))
 63.3228 -			{
 63.3229 -				if (systemDebug > 1)
 63.3230 -				{
 63.3231 -					sprintf(gbBuffer, "PC=%04x AF=%04x BC=%04x DE=%04x HL=%04x SP=%04x I=%04x\n",
 63.3232 -					        PC.W, AF.W, BC.W, DE.W, HL.W, SP.W, IFF);
 63.3233 -				}
 63.3234 -				else
 63.3235 -				{
 63.3236 -					sprintf(gbBuffer, "PC=%04x I=%02x\n", PC.W, IFF);
 63.3237 -				}
 63.3238 -				log(gbBuffer);
 63.3239 -			}
 63.3240 -		}
 63.3241 -#endif
 63.3242 -		if (IFF & 0x80)
 63.3243 -		{
 63.3244 -			if (register_LCDC & 0x80)
 63.3245 -			{
 63.3246 -				clockTicks = gbLcdTicks;
 63.3247 -			}
 63.3248 -			else
 63.3249 -				clockTicks = 100;
 63.3250 -
 63.3251 -			if (gbLcdMode == 1 && (gbLcdLYIncrementTicks < clockTicks))
 63.3252 -				clockTicks = gbLcdLYIncrementTicks;
 63.3253 -
 63.3254 -			if (gbSerialOn && (gbSerialTicks < clockTicks))
 63.3255 -				clockTicks = gbSerialTicks;
 63.3256 -
 63.3257 -			if (gbTimerOn && (gbTimerTicks < clockTicks))
 63.3258 -				clockTicks = gbTimerTicks;
 63.3259 -
 63.3260 -			if (soundTicks && (soundTicks < clockTicks))
 63.3261 -				clockTicks = soundTicks;
 63.3262 -		}
 63.3263 -		else
 63.3264 -		{
 63.3265 -			opcode = gbReadOpcode(PC.W);
 63.3266 -			CallRegisteredLuaMemHook(PC.W, 1, opcode, LUAMEMHOOK_EXEC);
 63.3267 -			PC.W++;
 63.3268 -
 63.3269 -			if (IFF & 0x100)
 63.3270 -			{
 63.3271 -				IFF &= 0xff;
 63.3272 -				PC.W--;
 63.3273 -			}
 63.3274 -
 63.3275 -			clockTicks = gbCycles[opcode];
 63.3276 -
 63.3277 -			switch (opcode)
 63.3278 -			{
 63.3279 -			case 0xCB:
 63.3280 -				// extended opcode
 63.3281 -				//CallRegisteredLuaMemHook(PC.W, 1, opcode, LUAMEMHOOK_EXEC);	// is this desired?
 63.3282 -				opcode	   = gbReadOpcode(PC.W++);
 63.3283 -				clockTicks = gbCyclesCB[opcode];
 63.3284 -				switch (opcode)
 63.3285 -				{
 63.3286 -#include "gbCodesCB.h"
 63.3287 -				}
 63.3288 -				break;
 63.3289 -#include "gbCodes.h"
 63.3290 -			}
 63.3291 -		}
 63.3292 -
 63.3293 -		if (!emulating)
 63.3294 -			return;
 63.3295 -
 63.3296 -		if (gbDmaTicks)
 63.3297 -		{
 63.3298 -			clockTicks += gbDmaTicks;
 63.3299 -			gbDmaTicks	= 0;
 63.3300 -		}
 63.3301 -
 63.3302 -		if (gbSgbMode)
 63.3303 -		{
 63.3304 -			if (gbSgbPacketTimeout)
 63.3305 -			{
 63.3306 -				gbSgbPacketTimeout -= clockTicks;
 63.3307 -
 63.3308 -				if (gbSgbPacketTimeout <= 0)
 63.3309 -					gbSgbResetPacketState();
 63.3310 -			}
 63.3311 -		}
 63.3312 -
 63.3313 -		ticksToStop -= clockTicks;
 63.3314 -
 63.3315 -		// DIV register emulation
 63.3316 -		gbDivTicks -= clockTicks;
 63.3317 -		while (gbDivTicks <= 0)
 63.3318 -		{
 63.3319 -			register_DIV++;
 63.3320 -			gbDivTicks += GBDIV_CLOCK_TICKS;
 63.3321 -		}
 63.3322 -
 63.3323 -		if (register_LCDC & 0x80)
 63.3324 -		{
 63.3325 -			// LCD stuff
 63.3326 -			gbLcdTicks -= clockTicks;
 63.3327 -			if (gbLcdMode == 1)
 63.3328 -			{
 63.3329 -				// during V-BLANK,we need to increment LY at the same rate!
 63.3330 -				gbLcdLYIncrementTicks -= clockTicks;
 63.3331 -				while (gbLcdLYIncrementTicks <= 0)
 63.3332 -				{
 63.3333 -					gbLcdLYIncrementTicks += GBLY_INCREMENT_CLOCK_TICKS;
 63.3334 -
 63.3335 -					if (register_LY < 153)
 63.3336 -					{
 63.3337 -						register_LY++;
 63.3338 -
 63.3339 -						gbCompareLYToLYC();
 63.3340 -
 63.3341 -						if (register_LY >= 153)
 63.3342 -							gbLcdLYIncrementTicks = 6;
 63.3343 -					}
 63.3344 -					else
 63.3345 -					{
 63.3346 -						register_LY = 0x00;
 63.3347 -						// reset the window line
 63.3348 -						gbWindowLine = -1;
 63.3349 -						gbLcdLYIncrementTicks = GBLY_INCREMENT_CLOCK_TICKS * 2;
 63.3350 -						gbCompareLYToLYC();
 63.3351 -					}
 63.3352 -				}
 63.3353 -			}
 63.3354 -
 63.3355 -			// our counter is off, see what we need to do
 63.3356 -			while (gbLcdTicks <= 0)
 63.3357 -			{
 63.3358 -				int framesToSkip = systemFramesToSkip();
 63.3359 -
 63.3360 -				switch (gbLcdMode)
 63.3361 -				{
 63.3362 -				case 0:
 63.3363 -					// H-Blank
 63.3364 -					register_LY++;
 63.3365 -
 63.3366 -					gbCompareLYToLYC();
 63.3367 -
 63.3368 -					// check if we reached the V-Blank period
 63.3369 -					if (register_LY == 144)
 63.3370 -					{
 63.3371 -						// Yes, V-Blank
 63.3372 -						// set the LY increment counter
 63.3373 -						gbLcdLYIncrementTicks = gbLcdTicks + GBLY_INCREMENT_CLOCK_TICKS;
 63.3374 -						gbLcdTicks += GBLCD_MODE_1_CLOCK_TICKS;
 63.3375 -						gbLcdMode	= 1;
 63.3376 -						if (register_LCDC & 0x80)
 63.3377 -						{
 63.3378 -							gbInterrupt	   |= 1; // V-Blank interrupt
 63.3379 -							gbInterruptWait = 6;
 63.3380 -							if (register_STAT & 0x10)
 63.3381 -								gbInterrupt |= 2;
 63.3382 -						}
 63.3383 -
 63.3384 -						systemFrame();
 63.3385 -
 63.3386 -						++gbFrameCount;
 63.3387 -						u32 currentTime = systemGetClock();
 63.3388 -						if (currentTime - gbLastTime >= 1000)
 63.3389 -						{
 63.3390 -							systemShowSpeed(int(float(gbFrameCount) * 100000 / (float(currentTime - gbLastTime) * 60) + .5f));
 63.3391 -							gbLastTime	 = currentTime;
 63.3392 -							gbFrameCount = 0;
 63.3393 -						}
 63.3394 -
 63.3395 -						++GBSystemCounters.frameCount;
 63.3396 -						if (GBSystemCounters.lagged)
 63.3397 -						{
 63.3398 -							++GBSystemCounters.lagCount;
 63.3399 -						}
 63.3400 -						GBSystemCounters.laggedLast = GBSystemCounters.lagged;
 63.3401 -						GBSystemCounters.lagged		= true;
 63.3402 -
 63.3403 -						extern void VBAOnEnteringFrameBoundary();
 63.3404 -						VBAOnEnteringFrameBoundary();
 63.3405 -
 63.3406 -						newFrame = true;
 63.3407 -
 63.3408 -						pauseAfterFrameAdvance = systemPauseOnFrame();
 63.3409 -
 63.3410 -						if (gbFrameSkipCount >= framesToSkip || pauseAfterFrameAdvance)
 63.3411 -						{
 63.3412 -							if (gbBorderOn)
 63.3413 -								gbSgbRenderBorder();  // clear unnecessary things on border (e.g. in-game text message)
 63.3414 -
 63.3415 -							systemRenderFrame();
 63.3416 -							gbFrameSkipCount = 0;
 63.3417 -
 63.3418 -							bool capturePressed = (extButtons & 2) != 0;
 63.3419 -							if (capturePressed && !capturePrevious)
 63.3420 -							{
 63.3421 -								captureNumber = systemScreenCapture(captureNumber);
 63.3422 -							}
 63.3423 -							capturePrevious = capturePressed && !pauseAfterFrameAdvance;
 63.3424 -						}
 63.3425 -						else
 63.3426 -						{
 63.3427 -							++gbFrameSkipCount;
 63.3428 -						}
 63.3429 -
 63.3430 -						if (pauseAfterFrameAdvance)
 63.3431 -						{
 63.3432 -							systemSetPause(true);
 63.3433 -						}
 63.3434 -					}
 63.3435 -					else
 63.3436 -					{
 63.3437 -						// go the the OAM being accessed mode
 63.3438 -						gbLcdTicks += GBLCD_MODE_2_CLOCK_TICKS;
 63.3439 -						gbLcdMode	= 2;
 63.3440 -
 63.3441 -						// only one LCD interrupt per line. may need to generalize...
 63.3442 -						if (!(register_STAT & 0x40) ||
 63.3443 -						    (register_LY != register_LYC))
 63.3444 -						{
 63.3445 -							if ((register_STAT & 0x28) == 0x20)
 63.3446 -								gbInterrupt |= 2;
 63.3447 -						}
 63.3448 -					}
 63.3449 -
 63.3450 -					break;
 63.3451 -				case 1:
 63.3452 -					// V-Blank
 63.3453 -					// next mode is OAM being accessed mode
 63.3454 -					gbLcdTicks += GBLCD_MODE_2_CLOCK_TICKS;
 63.3455 -					gbLcdMode	= 2;
 63.3456 -					if (!(register_STAT & 0x40) ||
 63.3457 -					    (register_LY != register_LYC))
 63.3458 -					{
 63.3459 -						if ((register_STAT & 0x28) == 0x20)
 63.3460 -							gbInterrupt |= 2;
 63.3461 -					}
 63.3462 -					break;
 63.3463 -				case 2:
 63.3464 -					// OAM being accessed mode
 63.3465 -
 63.3466 -					// next mode is OAM and VRAM in use
 63.3467 -					gbLcdTicks += GBLCD_MODE_3_CLOCK_TICKS;
 63.3468 -					gbLcdMode	= 3;
 63.3469 -					break;
 63.3470 -				case 3:
 63.3471 -					// OAM and VRAM in use
 63.3472 -					// next mode is H-Blank
 63.3473 -					if (register_LY < 144)
 63.3474 -					{
 63.3475 -						if (!gbSgbMask)
 63.3476 -						{
 63.3477 -							if (gbFrameSkipCount >= framesToSkip || pauseAfterFrameAdvance)
 63.3478 -							{
 63.3479 -								gbRenderLine();
 63.3480 -								gbDrawSprites();
 63.3481 -
 63.3482 -								switch (systemColorDepth)
 63.3483 -								{
 63.3484 -								case 16:
 63.3485 -
 63.3486 -								{
 63.3487 -									u16 *dest = (u16 *)pix +
 63.3488 -									            (gbBorderLineSkip + 2) * (register_LY + gbBorderRowSkip + 1)
 63.3489 -									            + gbBorderColumnSkip;
 63.3490 -									for (int x = 0; x < 160; )
 63.3491 -									{
 63.3492 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3493 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3494 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3495 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3496 -
 63.3497 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3498 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3499 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3500 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3501 -
 63.3502 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3503 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3504 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3505 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3506 -
 63.3507 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3508 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3509 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3510 -										*dest++ = systemColorMap16[gbLineMix[x++]];
 63.3511 -									}
 63.3512 -									if (gbBorderOn)
 63.3513 -										dest += gbBorderColumnSkip;
 63.3514 -									*dest++ = 0;     // for filters that read one pixel more
 63.3515 -									break;
 63.3516 -								}
 63.3517 -								case 24:
 63.3518 -
 63.3519 -								{
 63.3520 -									u8 *dest = (u8 *)pix +
 63.3521 -									           3 * (gbBorderLineSkip * (register_LY + gbBorderRowSkip) +
 63.3522 -									                gbBorderColumnSkip);
 63.3523 -									for (int x = 0; x < 160; )
 63.3524 -									{
 63.3525 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3526 -										dest += 3;
 63.3527 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3528 -										dest += 3;
 63.3529 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3530 -										dest += 3;
 63.3531 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3532 -										dest += 3;
 63.3533 -
 63.3534 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3535 -										dest += 3;
 63.3536 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3537 -										dest += 3;
 63.3538 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3539 -										dest += 3;
 63.3540 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3541 -										dest += 3;
 63.3542 -
 63.3543 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3544 -										dest += 3;
 63.3545 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3546 -										dest += 3;
 63.3547 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3548 -										dest += 3;
 63.3549 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3550 -										dest += 3;
 63.3551 -
 63.3552 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3553 -										dest += 3;
 63.3554 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3555 -										dest += 3;
 63.3556 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3557 -										dest += 3;
 63.3558 -										*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
 63.3559 -										dest += 3;
 63.3560 -									}
 63.3561 -									break;
 63.3562 -								}
 63.3563 -								case 32:
 63.3564 -
 63.3565 -								{
 63.3566 -									u32 *dest = (u32 *)pix +
 63.3567 -									            (gbBorderLineSkip + 1) * (register_LY + gbBorderRowSkip + 1)
 63.3568 -									            + gbBorderColumnSkip;
 63.3569 -									for (int x = 0; x < 160; )
 63.3570 -									{
 63.3571 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3572 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3573 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3574 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3575 -
 63.3576 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3577 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3578 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3579 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3580 -
 63.3581 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3582 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3583 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3584 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3585 -
 63.3586 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3587 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3588 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3589 -										*dest++ = systemColorMap32[gbLineMix[x++]];
 63.3590 -									}
 63.3591 -									break;
 63.3592 -								}
 63.3593 -								}
 63.3594 -							}
 63.3595 -						}
 63.3596 -					}
 63.3597 -					gbLcdTicks += GBLCD_MODE_0_CLOCK_TICKS;
 63.3598 -					gbLcdMode	= 0;
 63.3599 -					// only one LCD interrupt per line. may need to generalize...
 63.3600 -					if (!(register_STAT & 0x40) ||
 63.3601 -					    (register_LY != register_LYC))
 63.3602 -					{
 63.3603 -						if (register_STAT & 0x08)
 63.3604 -							gbInterrupt |= 2;
 63.3605 -					}
 63.3606 -					if (gbHdmaOn)
 63.3607 -					{
 63.3608 -						gbDoHdma();
 63.3609 -					}
 63.3610 -					break;
 63.3611 -				}
 63.3612 -				// mark the correct lcd mode on STAT register
 63.3613 -				register_STAT = (register_STAT & 0xfc) | gbLcdMode;
 63.3614 -			}
 63.3615 -		}
 63.3616 -
 63.3617 -		// serial emulation
 63.3618 -		if (gbSerialOn)
 63.3619 -		{
 63.3620 -#ifdef LINK_EMULATION
 63.3621 -			if (linkConnected)
 63.3622 -			{
 63.3623 -				gbSerialTicks -= clockTicks;
 63.3624 -
 63.3625 -				while (gbSerialTicks <= 0)
 63.3626 -				{
 63.3627 -					// increment number of shifted bits
 63.3628 -					gbSerialBits++;
 63.3629 -					linkProc();
 63.3630 -					if (gbSerialOn && (gbMemory[0xff02] & 1))
 63.3631 -					{
 63.3632 -						if (gbSerialBits == 8)
 63.3633 -						{
 63.3634 -							gbSerialBits	  = 0;
 63.3635 -							gbMemory[0xff01]  = 0xff;
 63.3636 -							gbMemory[0xff02] &= 0x7f;
 63.3637 -							gbSerialOn		  = 0;
 63.3638 -							gbInterrupt		 |= 8;
 63.3639 -							gbSerialTicks	  = 0;
 63.3640 -						}
 63.3641 -					}
 63.3642 -					gbSerialTicks += GBSERIAL_CLOCK_TICKS;
 63.3643 -				}
 63.3644 -			}
 63.3645 -			else
 63.3646 -			{
 63.3647 -#endif
 63.3648 -			if (gbMemory[0xff02] & 1)
 63.3649 -			{
 63.3650 -				gbSerialTicks -= clockTicks;
 63.3651 -
 63.3652 -				// overflow
 63.3653 -				while (gbSerialTicks <= 0)
 63.3654 -				{
 63.3655 -					// shift serial byte to right and put a 1 bit in its place
 63.3656 -					//      gbMemory[0xff01] = 0x80 | (gbMemory[0xff01]>>1);
 63.3657 -					// increment number of shifted bits
 63.3658 -					gbSerialBits++;
 63.3659 -					if (gbSerialBits == 8)
 63.3660 -					{
 63.3661 -						// end of transmission
 63.3662 -						if (gbSerialFunction)    // external device
 63.3663 -							gbMemory[0xff01] = gbSerialFunction(gbMemory[0xff01]);
 63.3664 -						else
 63.3665 -							gbMemory[0xff01] = 0xff;
 63.3666 -						gbSerialTicks	  = 0;
 63.3667 -						gbMemory[0xff02] &= 0x7f;
 63.3668 -						gbSerialOn		  = 0;
 63.3669 -						gbInterrupt		 |= 8;
 63.3670 -						gbSerialBits	  = 0;
 63.3671 -					}
 63.3672 -					else
 63.3673 -						gbSerialTicks += GBSERIAL_CLOCK_TICKS;
 63.3674 -				}
 63.3675 -			}
 63.3676 -#ifdef LINK_EMULATION
 63.3677 -		}
 63.3678 -#endif
 63.3679 -		}
 63.3680 -
 63.3681 -		// timer emulation
 63.3682 -		if (gbTimerOn)
 63.3683 -		{
 63.3684 -			gbTimerTicks -= clockTicks;
 63.3685 -
 63.3686 -			while (gbTimerTicks <= 0)
 63.3687 -			{
 63.3688 -				register_TIMA++;
 63.3689 -
 63.3690 -				if (register_TIMA == 0)
 63.3691 -				{
 63.3692 -					// timer overflow!
 63.3693 -
 63.3694 -					// reload timer modulo
 63.3695 -					register_TIMA = register_TMA;
 63.3696 -
 63.3697 -					// flag interrupt
 63.3698 -					gbInterrupt |= 4;
 63.3699 -				}
 63.3700 -
 63.3701 -				gbTimerTicks += gbTimerClockTicks;
 63.3702 -			}
 63.3703 -		}
 63.3704 -
 63.3705 -		/*
 63.3706 -		   if(soundOffFlag)
 63.3707 -		   {
 63.3708 -		   if(synchronize && !speedup)
 63.3709 -		   {
 63.3710 -		   synchronizeTicks -= clockTicks;
 63.3711 -
 63.3712 -		   while(synchronizeTicks < 0)
 63.3713 -		   {
 63.3714 -		   synchronizeTicks += SYNCHRONIZE_CLOCK_TICKS;
 63.3715 -
 63.3716 -		   DWORD now = timeGetTime();
 63.3717 -		   gbElapsedTime += (now - timeNow);
 63.3718 -
 63.3719 -		   if(gbElapsedTime < 50)
 63.3720 -		   {
 63.3721 -		   DWORD diff = 50 - gbElapsedTime;
 63.3722 -		   Sleep(diff);
 63.3723 -		   timeNow = timeGetTime();
 63.3724 -		   elapsedTime = timeNow - now - diff;
 63.3725 -		   if((int)elapsedTime < 0)
 63.3726 -		   elapsedTime = 0;
 63.3727 -		   } else
 63.3728 -		   {
 63.3729 -		   timeNow = timeGetTime();
 63.3730 -		   elapsedTime = 0;
 63.3731 -		   }
 63.3732 -		   }
 63.3733 -		   }
 63.3734 -		   }
 63.3735 -		 */
 63.3736 -
 63.3737 -		soundTicks -= clockTicks;
 63.3738 -		while (soundTicks < 0) // must be < 1 when soundtick_t is real data type
 63.3739 -		{
 63.3740 -			soundTicks += SOUND_CLOCK_TICKS;
 63.3741 -
 63.3742 -			gbSoundTick();
 63.3743 -		}
 63.3744 -
 63.3745 -		register_IF = gbInterrupt;
 63.3746 -
 63.3747 -		if (IFF & 0x20)
 63.3748 -		{
 63.3749 -			IFF &= 0xdf;
 63.3750 -			IFF |= 0x01;
 63.3751 -			gbInterruptWait = 0;
 63.3752 -		}
 63.3753 -		else if (gbInterrupt)
 63.3754 -		{
 63.3755 -			if (gbInterruptWait == 0)
 63.3756 -			{
 63.3757 -				//        gbInterruptWait = 0;
 63.3758 -
 63.3759 -				if (IFF & 0x01)
 63.3760 -				{
 63.3761 -					if ((gbInterrupt & 1) && (register_IE & 1))
 63.3762 -					{
 63.3763 -						gbVblank_interrupt();
 63.3764 -						continue;
 63.3765 -					}
 63.3766 -
 63.3767 -					if ((gbInterrupt & 2) && (register_IE & 2))
 63.3768 -					{
 63.3769 -						gbLcd_interrupt();
 63.3770 -						continue;
 63.3771 -					}
 63.3772 -
 63.3773 -					if ((gbInterrupt & 4) && (register_IE & 4))
 63.3774 -					{
 63.3775 -						gbTimer_interrupt();
 63.3776 -						continue;
 63.3777 -					}
 63.3778 -
 63.3779 -					if ((gbInterrupt & 8) && (register_IE & 8))
 63.3780 -					{
 63.3781 -						gbSerial_interrupt();
 63.3782 -						continue;
 63.3783 -					}
 63.3784 -
 63.3785 -					if ((gbInterrupt & 16) && (register_IE & 16))
 63.3786 -					{
 63.3787 -						gbJoypad_interrupt();
 63.3788 -						continue;
 63.3789 -					}
 63.3790 -				}
 63.3791 -			}
 63.3792 -			else
 63.3793 -			{
 63.3794 -				gbInterruptWait -= clockTicks;
 63.3795 -				if (gbInterruptWait < 0)
 63.3796 -					gbInterruptWait = 0;
 63.3797 -			}
 63.3798 -		}
 63.3799 -
 63.3800 -		if (useOldFrameTiming)
 63.3801 -		{
 63.3802 -			// old timing code
 63.3803 -			if (ticksToStop > 0)
 63.3804 -				continue;
 63.3805 -		}
 63.3806 -		else
 63.3807 -		{
 63.3808 -			if (!newFrame && (register_LCDC & 0x80) != 0)
 63.3809 -				continue;
 63.3810 -		}
 63.3811 -
 63.3812 -		if (!(register_LCDC & 0x80))
 63.3813 -		{
 63.3814 -			if (!useOldFrameTiming)
 63.3815 -			{
 63.3816 -				// FIXME: since register_LY can be reset to 0 by some games, frame length is variable
 63.3817 -				// and infinite loops can occurr
 63.3818 -				// for now, it IS necessary to do something on this condition or games like
 63.3819 -				// Megaman would freeze upon low-level restart interrupt sequence (Start+Select+A+B).
 63.3820 -				// the only sensible way to fix this issue is to implement the RIGHT frame timing
 63.3821 -#ifdef WANTS_INCOMPLETE_WORKAROUND
 63.3822 -				if (systemReadJoypads())
 63.3823 -				{
 63.3824 -					if (gbSgbMode && gbSgbMultiplayer)
 63.3825 -					{
 63.3826 -						if (gbSgbFourPlayers)
 63.3827 -						{
 63.3828 -							gbJoymask[0] = systemGetJoypad(0, false);
 63.3829 -							gbJoymask[1] = systemGetJoypad(1, false);
 63.3830 -							gbJoymask[2] = systemGetJoypad(2, false);
 63.3831 -							gbJoymask[3] = systemGetJoypad(3, false);
 63.3832 -						}
 63.3833 -						else
 63.3834 -						{
 63.3835 -							gbJoymask[0] = systemGetJoypad(0, false);
 63.3836 -							gbJoymask[1] = systemGetJoypad(1, false);
 63.3837 -						}
 63.3838 -					}
 63.3839 -					else
 63.3840 -					{
 63.3841 -						gbJoymask[0] = systemGetJoypad(0, false);
 63.3842 -					}
 63.3843 -				}
 63.3844 -				else
 63.3845 -					gbJoymask[0] = gbJoymask[1] = gbJoymask[2] = gbJoymask[3] = 0;
 63.3846 -#else
 63.3847 -#endif
 63.3848 -			}
 63.3849 -		}
 63.3850 -
 63.3851 -		// makes sure frames are really divided across input sampling boundaries which occur at a constant rate
 63.3852 -		if (newFrame || useOldFrameTiming)
 63.3853 -		{
 63.3854 -///			extern void VBAOnEnteringFrameBoundary();
 63.3855 -///			VBAOnEnteringFrameBoundary();
 63.3856 -
 63.3857 -			break;
 63.3858 -		}
 63.3859 -	}
 63.3860 -}
 63.3861 -
 63.3862 -struct EmulatedSystem GBSystem =
 63.3863 -{
 63.3864 -	// emuMain
 63.3865 -	gbEmulate,
 63.3866 -	// emuReset
 63.3867 -	gbReset,
 63.3868 -	// emuCleanUp
 63.3869 -	gbCleanUp,
 63.3870 -	// emuReadBattery
 63.3871 -	gbReadBatteryFile,
 63.3872 -	// emuWriteBattery
 63.3873 -	gbWriteBatteryFile,
 63.3874 -	// emuReadBatteryFromStream
 63.3875 -	gbReadBatteryFromStream,
 63.3876 -	// emuWriteBatteryToStream
 63.3877 -	gbWriteBatteryToStream,
 63.3878 -	// emuReadState
 63.3879 -	gbReadSaveState,
 63.3880 -	// emuWriteState
 63.3881 -	gbWriteSaveState,
 63.3882 -	// emuReadStateFromStream
 63.3883 -	gbReadSaveStateFromStream,
 63.3884 -	// emuWriteStateToStream
 63.3885 -	gbWriteSaveStateToStream,
 63.3886 -	// emuReadMemState
 63.3887 -	gbReadMemSaveState,
 63.3888 -	// emuWriteMemState
 63.3889 -	gbWriteMemSaveState,
 63.3890 -	// emuWritePNG
 63.3891 -	gbWritePNGFile,
 63.3892 -	// emuWriteBMP
 63.3893 -	gbWriteBMPFile,
 63.3894 -	// emuUpdateCPSR
 63.3895 -	NULL,
 63.3896 -	// emuHasDebugger
 63.3897 -	false,
 63.3898 -	// emuCount
 63.3899 -#ifdef FINAL_VERSION
 63.3900 -	70000 / 4,
 63.3901 -#else
 63.3902 -	1000,
 63.3903 -#endif
 63.3904 -};
 63.3905 -
 63.3906 -// is there a reason to use more than one set of counters?
 63.3907 -EmulatedSystemCounters &GBSystemCounters = systemCounters;
 63.3908 -
 63.3909 -/*
 63.3910 -   EmulatedSystemCounters GBSystemCounters =
 63.3911 -   {
 63.3912 -    // frameCount
 63.3913 -    0,
 63.3914 -    // lagCount
 63.3915 -    0,
 63.3916 -    // lagged
 63.3917 -    true,
 63.3918 -    // laggedLast
 63.3919 -    true,
 63.3920 -   };
 63.3921 - */
    64.1 --- a/src/gb/GB.h	Sat Mar 03 10:54:39 2012 -0600
    64.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.3 @@ -1,50 +0,0 @@
    64.4 -#ifndef VBA_GB_H
    64.5 -#define VBA_GB_H
    64.6 -
    64.7 -#if _MSC_VER > 1000
    64.8 -#pragma once
    64.9 -#endif // _MSC_VER > 1000
   64.10 -
   64.11 -#include "zlib.h"
   64.12 -#include "../Port.h"
   64.13 -
   64.14 -typedef union
   64.15 -{
   64.16 -	struct
   64.17 -	{
   64.18 -#ifdef WORDS_BIGENDIAN
   64.19 -		u8 B1, B0;
   64.20 -#else
   64.21 -		u8 B0, B1;
   64.22 -#endif
   64.23 -	} B;
   64.24 -	u16 W;
   64.25 -} gbRegister;
   64.26 -
   64.27 -extern bool gbLoadRom(const char *);
   64.28 -extern void gbEmulate(int);
   64.29 -extern bool gbIsGameboyRom(const char *);
   64.30 -extern void gbSoundReset();
   64.31 -extern void gbSoundSetQuality(int);
   64.32 -extern void gbReset(bool userReset = false);
   64.33 -extern void gbCleanUp();
   64.34 -extern bool gbWriteBatteryFile(const char *);
   64.35 -extern bool gbWriteBatteryFile(const char *, bool);
   64.36 -extern bool gbWriteBatteryToStream(gzFile);
   64.37 -extern bool gbReadBatteryFile(const char *);
   64.38 -extern bool gbReadBatteryFromStream(gzFile);
   64.39 -extern bool gbWriteSaveState(const char *);
   64.40 -extern bool gbWriteMemSaveState(char *, int);
   64.41 -extern bool gbReadSaveState(const char *);
   64.42 -extern bool gbReadMemSaveState(char *, int);
   64.43 -extern bool gbReadSaveStateFromStream(gzFile);
   64.44 -extern bool gbWriteSaveStateToStream(gzFile);
   64.45 -extern void gbSgbRenderBorder();
   64.46 -extern bool gbWritePNGFile(const char *);
   64.47 -extern bool gbWriteBMPFile(const char *);
   64.48 -extern bool gbReadGSASnapshot(const char *);
   64.49 -
   64.50 -extern struct EmulatedSystem GBSystem;
   64.51 -extern struct EmulatedSystemCounters &GBSystemCounters;
   64.52 -
   64.53 -#endif // VBA_GB_H
    65.1 --- a/src/gb/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
    65.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.3 @@ -1,21 +0,0 @@
    65.4 -noinst_LIBRARIES = libgb.a
    65.5 -
    65.6 -libgb_a_SOURCES = \
    65.7 -	gbCheats.cpp	\
    65.8 -	gbCheats.h	\
    65.9 -	gbCodesCB.h	\
   65.10 -	gbCodes.h	\
   65.11 -	GB.cpp		\
   65.12 -	GB.h		\
   65.13 -	gbDis.cpp	\
   65.14 -	gbGfx.cpp	\
   65.15 -	gbGlobals.cpp	\
   65.16 -	gbGlobals.h	\
   65.17 -	gbMemory.cpp	\
   65.18 -	gbMemory.h	\
   65.19 -	gbPrinter.cpp	\
   65.20 -	gbPrinter.h	\
   65.21 -	gbSGB.cpp	\
   65.22 -	gbSGB.h		\
   65.23 -	gbSound.cpp	\
   65.24 -	gbSound.h
    66.1 --- a/src/gb/gbCheats.cpp	Sat Mar 03 10:54:39 2012 -0600
    66.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.3 @@ -1,477 +0,0 @@
    66.4 -#include <cstdio>
    66.5 -#include <cstdlib>
    66.6 -#include <cctype>
    66.7 -#include <cstring>
    66.8 -
    66.9 -#include "../NLS.h"
   66.10 -#include "../common/System.h"
   66.11 -#include "../common/Util.h"
   66.12 -
   66.13 -#include "gbCheats.h"
   66.14 -#include "gbGlobals.h"
   66.15 -
   66.16 -gbCheat gbCheatList[100];
   66.17 -int     gbCheatNumber = 0;
   66.18 -bool    gbCheatMap[0x10000];
   66.19 -
   66.20 -extern bool8 cheatsEnabled;
   66.21 -
   66.22 -#define GBCHEAT_IS_HEX(a) (((a) >= 'A' && (a) <= 'F') || ((a) >= '0' && (a) <= '9'))
   66.23 -#define GBCHEAT_HEX_VALUE(a) ((a) >= 'A' ? (a) - 'A' + 10 : (a) - '0')
   66.24 -
   66.25 -void gbCheatUpdateMap()
   66.26 -{
   66.27 -	memset(gbCheatMap, 0, 0x10000);
   66.28 -
   66.29 -	for (int i = 0; i < gbCheatNumber; i++)
   66.30 -	{
   66.31 -		if (gbCheatList[i].enabled)
   66.32 -			gbCheatMap[gbCheatList[i].address] = true;
   66.33 -	}
   66.34 -}
   66.35 -
   66.36 -void gbCheatsSaveGame(gzFile gzFile)
   66.37 -{
   66.38 -	utilWriteInt(gzFile, gbCheatNumber);
   66.39 -	if (gbCheatNumber)
   66.40 -		utilGzWrite(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber);
   66.41 -}
   66.42 -
   66.43 -void gbCheatsReadGame(gzFile gzFile, int version)
   66.44 -{
   66.45 -	if (version <= 8)
   66.46 -	{
   66.47 -		int gbGgOn = utilReadInt(gzFile);
   66.48 -
   66.49 -		if (gbGgOn)
   66.50 -		{
   66.51 -			int       n = utilReadInt(gzFile);
   66.52 -			gbXxCheat tmpCheat;
   66.53 -			for (int i = 0; i < n; i++)
   66.54 -			{
   66.55 -				utilGzRead(gzFile, &tmpCheat, sizeof(gbXxCheat));
   66.56 -				gbAddGgCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc);
   66.57 -			}
   66.58 -		}
   66.59 -
   66.60 -		int gbGsOn = utilReadInt(gzFile);
   66.61 -
   66.62 -		if (gbGsOn)
   66.63 -		{
   66.64 -			int       n = utilReadInt(gzFile);
   66.65 -			gbXxCheat tmpCheat;
   66.66 -			for (int i = 0; i < n; i++)
   66.67 -			{
   66.68 -				utilGzRead(gzFile, &tmpCheat, sizeof(gbXxCheat));
   66.69 -				gbAddGsCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc);
   66.70 -			}
   66.71 -		}
   66.72 -	}
   66.73 -	else
   66.74 -	{
   66.75 -		gbCheatNumber = utilReadInt(gzFile);
   66.76 -
   66.77 -		if (gbCheatNumber)
   66.78 -		{
   66.79 -			utilGzRead(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber);
   66.80 -		}
   66.81 -	}
   66.82 -
   66.83 -	gbCheatUpdateMap();
   66.84 -}
   66.85 -
   66.86 -void gbCheatsSaveCheatList(const char *file)
   66.87 -{
   66.88 -	if (gbCheatNumber == 0)
   66.89 -		return;
   66.90 -	FILE *f = fopen(file, "wb");
   66.91 -	if (f == NULL)
   66.92 -		return;
   66.93 -	int version = 1;
   66.94 -	fwrite(&version, 1, sizeof(version), f);
   66.95 -	int type = 1;
   66.96 -	fwrite(&type, 1, sizeof(type), f);
   66.97 -	fwrite(&gbCheatNumber, 1, sizeof(gbCheatNumber), f);
   66.98 -	fwrite(gbCheatList, 1, sizeof(gbCheatList), f);
   66.99 -	fclose(f);
  66.100 -}
  66.101 -
  66.102 -bool gbCheatsLoadCheatList(const char *file)
  66.103 -{
  66.104 -	gbCheatNumber = 0;
  66.105 -
  66.106 -	gbCheatUpdateMap();
  66.107 -
  66.108 -	int count = 0;
  66.109 -
  66.110 -	FILE *f = fopen(file, "rb");
  66.111 -
  66.112 -	if (f == NULL)
  66.113 -		return false;
  66.114 -
  66.115 -	int version = 0;
  66.116 -
  66.117 -	if (fread(&version, 1, sizeof(version), f) != sizeof(version))
  66.118 -	{
  66.119 -		fclose(f);
  66.120 -		return false;
  66.121 -	}
  66.122 -
  66.123 -	if (version != 1)
  66.124 -	{
  66.125 -		systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
  66.126 -		              N_("Unsupported cheat list version %d"), version);
  66.127 -		fclose(f);
  66.128 -		return false;
  66.129 -	}
  66.130 -
  66.131 -	int type = 0;
  66.132 -	if (fread(&type, 1, sizeof(type), f) != sizeof(type))
  66.133 -	{
  66.134 -		fclose(f);
  66.135 -		return false;
  66.136 -	}
  66.137 -
  66.138 -	if (type != 1)
  66.139 -	{
  66.140 -		systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE,
  66.141 -		              N_("Unsupported cheat list type %d"), type);
  66.142 -		fclose(f);
  66.143 -		return false;
  66.144 -	}
  66.145 -
  66.146 -	if (fread(&count, 1, sizeof(count), f) != sizeof(count))
  66.147 -	{
  66.148 -		fclose(f);
  66.149 -		return false;
  66.150 -	}
  66.151 -
  66.152 -	if (fread(gbCheatList, 1, sizeof(gbCheatList), f) != sizeof(gbCheatList))
  66.153 -	{
  66.154 -		fclose(f);
  66.155 -		return false;
  66.156 -	}
  66.157 -
  66.158 -	fclose(f);
  66.159 -	gbCheatNumber = count;
  66.160 -	gbCheatUpdateMap();
  66.161 -
  66.162 -	return true;
  66.163 -}
  66.164 -
  66.165 -bool gbVerifyGsCode(const char *code)
  66.166 -{
  66.167 -	int len = strlen(code);
  66.168 -
  66.169 -	if (len == 0)
  66.170 -		return true;
  66.171 -
  66.172 -	if (len != 8)
  66.173 -		return false;
  66.174 -
  66.175 -	for (int i = 0; i < 8; i++)
  66.176 -		if (!GBCHEAT_IS_HEX(code[i]))
  66.177 -			return false;
  66.178 -
  66.179 -	int address = GBCHEAT_HEX_VALUE(code[6]) << 12 |
  66.180 -	              GBCHEAT_HEX_VALUE(code[7]) << 8 |
  66.181 -	              GBCHEAT_HEX_VALUE(code[4]) << 4 |
  66.182 -	              GBCHEAT_HEX_VALUE(code[5]);
  66.183 -
  66.184 -	if (address < 0xa000 ||
  66.185 -	    address > 0xdfff)
  66.186 -		return false;
  66.187 -
  66.188 -	return true;
  66.189 -}
  66.190 -
  66.191 -void gbAddGsCheat(const char *code, const char *desc)
  66.192 -{
  66.193 -	if (gbCheatNumber > 99)
  66.194 -	{
  66.195 -		systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
  66.196 -		              N_("Maximum number of cheats reached."));
  66.197 -		return;
  66.198 -	}
  66.199 -
  66.200 -	if (!gbVerifyGsCode(code))
  66.201 -	{
  66.202 -		systemMessage(MSG_INVALID_GAMESHARK_CODE,
  66.203 -		              N_("Invalid GameShark code: %s"), code);
  66.204 -		return;
  66.205 -	}
  66.206 -
  66.207 -	int i = gbCheatNumber;
  66.208 -
  66.209 -	strcpy(gbCheatList[i].cheatCode, code);
  66.210 -	strcpy(gbCheatList[i].cheatDesc, desc);
  66.211 -
  66.212 -	gbCheatList[i].code = GBCHEAT_HEX_VALUE(code[0]) << 4 |
  66.213 -	                      GBCHEAT_HEX_VALUE(code[1]);
  66.214 -
  66.215 -	gbCheatList[i].value = GBCHEAT_HEX_VALUE(code[2]) << 4 |
  66.216 -	                       GBCHEAT_HEX_VALUE(code[3]);
  66.217 -
  66.218 -	gbCheatList[i].address = GBCHEAT_HEX_VALUE(code[6]) << 12 |
  66.219 -	                         GBCHEAT_HEX_VALUE(code[7]) << 8 |
  66.220 -	                         GBCHEAT_HEX_VALUE(code[4]) << 4 |
  66.221 -	                         GBCHEAT_HEX_VALUE(code[5]);
  66.222 -
  66.223 -	gbCheatList[i].compare = 0;
  66.224 -
  66.225 -	gbCheatList[i].enabled = true;
  66.226 -
  66.227 -	gbCheatMap[gbCheatList[i].address] = true;
  66.228 -
  66.229 -	gbCheatNumber++;
  66.230 -}
  66.231 -
  66.232 -bool gbVerifyGgCode(const char *code)
  66.233 -{
  66.234 -	int len = strlen(code);
  66.235 -
  66.236 -	if (len != 11 &&
  66.237 -	    len != 7 &&
  66.238 -	    len != 6 &&
  66.239 -	    len != 0)
  66.240 -		return false;
  66.241 -
  66.242 -	if (len == 0)
  66.243 -		return true;
  66.244 -
  66.245 -	if (!GBCHEAT_IS_HEX(code[0]))
  66.246 -		return false;
  66.247 -	if (!GBCHEAT_IS_HEX(code[1]))
  66.248 -		return false;
  66.249 -	if (!GBCHEAT_IS_HEX(code[2]))
  66.250 -		return false;
  66.251 -	if (code[3] != '-')
  66.252 -		return false;
  66.253 -	if (!GBCHEAT_IS_HEX(code[4]))
  66.254 -		return false;
  66.255 -	if (!GBCHEAT_IS_HEX(code[5]))
  66.256 -		return false;
  66.257 -	if (!GBCHEAT_IS_HEX(code[6]))
  66.258 -		return false;
  66.259 -	if (code[7] != 0)
  66.260 -	{
  66.261 -		if (code[7] != '-')
  66.262 -			return false;
  66.263 -		if (code[8] != 0)
  66.264 -		{
  66.265 -			if (!GBCHEAT_IS_HEX(code[8]))
  66.266 -				return false;
  66.267 -			if (!GBCHEAT_IS_HEX(code[9]))
  66.268 -				return false;
  66.269 -			if (!GBCHEAT_IS_HEX(code[10]))
  66.270 -				return false;
  66.271 -		}
  66.272 -	}
  66.273 -
  66.274 -	//  int replace = (GBCHEAT_HEX_VALUE(code[0]) << 4) +
  66.275 -	//    GBCHEAT_HEX_VALUE(code[1]);
  66.276 -
  66.277 -	int address = (GBCHEAT_HEX_VALUE(code[2]) << 8) +
  66.278 -	              (GBCHEAT_HEX_VALUE(code[4]) << 4) +
  66.279 -	              (GBCHEAT_HEX_VALUE(code[5])) +
  66.280 -	              ((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12);
  66.281 -
  66.282 -	if (address >= 0x8000 && address <= 0x9fff)
  66.283 -		return false;
  66.284 -
  66.285 -	if (address >= 0xc000)
  66.286 -		return false;
  66.287 -
  66.288 -	if (code[7] == 0 || code[8] == '0')
  66.289 -		return true;
  66.290 -
  66.291 -	int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) +
  66.292 -	              (GBCHEAT_HEX_VALUE(code[10]));
  66.293 -	compare  = compare ^ 0xff;
  66.294 -	compare  = (compare >> 2) | ((compare << 6) & 0xc0);
  66.295 -	compare ^= 0x45;
  66.296 -
  66.297 -	int cloak = (GBCHEAT_HEX_VALUE(code[8])) ^ (GBCHEAT_HEX_VALUE(code[9]));
  66.298 -
  66.299 -	if (cloak >= 1 && cloak <= 7)
  66.300 -		return false;
  66.301 -
  66.302 -	return true;
  66.303 -}
  66.304 -
  66.305 -void gbAddGgCheat(const char *code, const char *desc)
  66.306 -{
  66.307 -	if (gbCheatNumber > 99)
  66.308 -	{
  66.309 -		systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
  66.310 -		              N_("Maximum number of cheats reached."));
  66.311 -		return;
  66.312 -	}
  66.313 -
  66.314 -	if (!gbVerifyGgCode(code))
  66.315 -	{
  66.316 -		systemMessage(MSG_INVALID_GAMEGENIE_CODE,
  66.317 -		              N_("Invalid GameGenie code: %s"), code);
  66.318 -		return;
  66.319 -	}
  66.320 -
  66.321 -	int i = gbCheatNumber;
  66.322 -
  66.323 -	int len = strlen(code);
  66.324 -
  66.325 -	strcpy(gbCheatList[i].cheatCode, code);
  66.326 -	strcpy(gbCheatList[i].cheatDesc, desc);
  66.327 -
  66.328 -	gbCheatList[i].code  = 1;
  66.329 -	gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) +
  66.330 -	                       GBCHEAT_HEX_VALUE(code[1]);
  66.331 -
  66.332 -	gbCheatList[i].address = (GBCHEAT_HEX_VALUE(code[2]) << 8) +
  66.333 -	                         (GBCHEAT_HEX_VALUE(code[4]) << 4) +
  66.334 -	                         (GBCHEAT_HEX_VALUE(code[5])) +
  66.335 -	                         ((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12);
  66.336 -
  66.337 -	gbCheatList[i].compare = 0;
  66.338 -
  66.339 -	if (len != 7 && len != 8)
  66.340 -	{
  66.341 -		int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) +
  66.342 -		              (GBCHEAT_HEX_VALUE(code[10]));
  66.343 -		compare  = compare ^ 0xff;
  66.344 -		compare  = (compare >> 2) | ((compare << 6) & 0xc0);
  66.345 -		compare ^= 0x45;
  66.346 -
  66.347 -		gbCheatList[i].compare = compare;
  66.348 -		gbCheatList[i].code    = 0;
  66.349 -	}
  66.350 -
  66.351 -	gbCheatList[i].enabled = true;
  66.352 -
  66.353 -	gbCheatMap[gbCheatList[i].address] = true;
  66.354 -
  66.355 -	gbCheatNumber++;
  66.356 -}
  66.357 -
  66.358 -void gbCheatRemove(int i)
  66.359 -{
  66.360 -	if (i < 0 || i >= gbCheatNumber)
  66.361 -	{
  66.362 -		systemMessage(MSG_INVALID_CHEAT_TO_REMOVE,
  66.363 -		              N_("Invalid cheat to remove %d"), i);
  66.364 -		return;
  66.365 -	}
  66.366 -
  66.367 -	if ((i+1) <  gbCheatNumber)
  66.368 -	{
  66.369 -		memcpy(&gbCheatList[i], &gbCheatList[i+1], sizeof(gbCheat)*
  66.370 -		       (gbCheatNumber-i-1));
  66.371 -	}
  66.372 -
  66.373 -	gbCheatNumber--;
  66.374 -
  66.375 -	gbCheatUpdateMap();
  66.376 -}
  66.377 -
  66.378 -void gbCheatRemoveAll()
  66.379 -{
  66.380 -	gbCheatNumber = 0;
  66.381 -	gbCheatUpdateMap();
  66.382 -}
  66.383 -
  66.384 -void gbCheatEnable(int i)
  66.385 -{
  66.386 -	if (i >= 0 && i < gbCheatNumber)
  66.387 -	{
  66.388 -		if (!gbCheatList[i].enabled)
  66.389 -		{
  66.390 -			gbCheatList[i].enabled = true;
  66.391 -			gbCheatUpdateMap();
  66.392 -		}
  66.393 -	}
  66.394 -}
  66.395 -
  66.396 -void gbCheatDisable(int i)
  66.397 -{
  66.398 -	if (i >= 0 && i < gbCheatNumber)
  66.399 -	{
  66.400 -		if (gbCheatList[i].enabled)
  66.401 -		{
  66.402 -			gbCheatList[i].enabled = false;
  66.403 -			gbCheatUpdateMap();
  66.404 -		}
  66.405 -	}
  66.406 -}
  66.407 -
  66.408 -bool gbCheatReadGSCodeFile(const char *fileName)
  66.409 -{
  66.410 -	FILE *file = fopen(fileName, "rb");
  66.411 -
  66.412 -	if (!file)
  66.413 -		return false;
  66.414 -
  66.415 -	fseek(file, 0x18, SEEK_SET);
  66.416 -	int count = 0;
  66.417 -	fread(&count, 1, 2, file);
  66.418 -	int dummy = 0;
  66.419 -	gbCheatRemoveAll();
  66.420 -	char desc[13];
  66.421 -	char code[9];
  66.422 -	int  i;
  66.423 -	for (i = 0; i < count; i++)
  66.424 -	{
  66.425 -		fread(&dummy, 1, 2, file);
  66.426 -		fread(desc, 1, 12, file);
  66.427 -		desc[12] = 0;
  66.428 -		fread(code, 1, 8, file);
  66.429 -		code[8] = 0;
  66.430 -		gbAddGsCheat(code, desc);
  66.431 -	}
  66.432 -
  66.433 -	for (i = 0; i < gbCheatNumber; i++)
  66.434 -		gbCheatDisable(i);
  66.435 -
  66.436 -	fclose(file);
  66.437 -	return true;
  66.438 -}
  66.439 -
  66.440 -u8 gbCheatRead(u16 address)
  66.441 -{
  66.442 -	if (!cheatsEnabled)
  66.443 -		return gbReadMemoryQuick(address);
  66.444 -
  66.445 -	for (int i = 0; i < gbCheatNumber; i++)
  66.446 -	{
  66.447 -		if (gbCheatList[i].enabled && gbCheatList[i].address == address)
  66.448 -		{
  66.449 -			switch (gbCheatList[i].code)
  66.450 -			{
  66.451 -			case 0x100: // GameGenie support
  66.452 -				if (gbReadMemoryQuick(address) == gbCheatList[i].compare)
  66.453 -					return gbCheatList[i].value;
  66.454 -				break;
  66.455 -			case 0x00:
  66.456 -			case 0x01:
  66.457 -			case 0x80:
  66.458 -				return gbCheatList[i].value;
  66.459 -			case 0x90:
  66.460 -			case 0x91:
  66.461 -			case 0x92:
  66.462 -			case 0x93:
  66.463 -			case 0x94:
  66.464 -			case 0x95:
  66.465 -			case 0x96:
  66.466 -			case 0x97:
  66.467 -				if (address >= 0xd000 && address < 0xe000)
  66.468 -				{
  66.469 -					if (((gbMemoryMap[0x0d] - gbWram)/0x1000) ==
  66.470 -					    (gbCheatList[i].code - 0x90))
  66.471 -						return gbCheatList[i].value;
  66.472 -				}
  66.473 -				else
  66.474 -					return gbCheatList[i].value;
  66.475 -			}
  66.476 -		}
  66.477 -	}
  66.478 -	return gbReadMemoryQuick(address);
  66.479 -}
  66.480 -
    67.1 --- a/src/gb/gbCheats.h	Sat Mar 03 10:54:39 2012 -0600
    67.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.3 @@ -1,44 +0,0 @@
    67.4 -#ifndef VBA_GB_CHEATS_H
    67.5 -#define VBA_GB_CHEATS_H
    67.6 -
    67.7 -#if _MSC_VER > 1000
    67.8 -#pragma once
    67.9 -#endif // _MSC_VER > 1000
   67.10 -
   67.11 -struct gbXxCheat
   67.12 -{
   67.13 -	char cheatDesc[100];
   67.14 -	char cheatCode[20];
   67.15 -};
   67.16 -
   67.17 -struct gbCheat
   67.18 -{
   67.19 -	char cheatCode[20];
   67.20 -	char cheatDesc[32];
   67.21 -	u16  address;
   67.22 -	int  code;
   67.23 -	u8   compare;
   67.24 -	u8   value;
   67.25 -	bool enabled;
   67.26 -};
   67.27 -
   67.28 -extern void gbCheatsSaveGame(gzFile);
   67.29 -extern void gbCheatsReadGame(gzFile, int);
   67.30 -extern void gbCheatsSaveCheatList(const char *);
   67.31 -extern bool gbCheatsLoadCheatList(const char *);
   67.32 -extern bool gbCheatReadGSCodeFile(const char *);
   67.33 -
   67.34 -extern void gbAddGsCheat(const char *, const char *);
   67.35 -extern void gbAddGgCheat(const char *, const char *);
   67.36 -extern void gbCheatRemove(int);
   67.37 -extern void gbCheatRemoveAll();
   67.38 -extern void gbCheatEnable(int);
   67.39 -extern void gbCheatDisable(int);
   67.40 -extern u8 gbCheatRead(u16);
   67.41 -
   67.42 -extern int     gbCheatNumber;
   67.43 -extern gbCheat gbCheatList[100];
   67.44 -extern bool    gbCheatMap[0x10000];
   67.45 -
   67.46 -#endif // VBA_GB_CHEATS_H
   67.47 -
    68.1 --- a/src/gb/gbCodes.h	Sat Mar 03 10:54:39 2012 -0600
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,1388 +0,0 @@
    68.4 - case 0x00: 
    68.5 -   // NOP
    68.6 -   break;
    68.7 - case 0x01: 
    68.8 -   // LD BC, NNNN
    68.9 -   BC.B.B0=gbReadMemory(PC.W++);
   68.10 -   BC.B.B1=gbReadMemory(PC.W++);
   68.11 -   break;
   68.12 - case 0x02:
   68.13 -   // LD (BC),A
   68.14 -   gbWriteMemory(BC.W,AF.B.B1);
   68.15 -   break;
   68.16 - case 0x03:
   68.17 -   // INC BC
   68.18 -   BC.W++;
   68.19 -   break;
   68.20 - case 0x04: 
   68.21 -   // INC B
   68.22 -   BC.B.B1++; 
   68.23 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| (BC.B.B1&0x0F? 0:H_FLAG);
   68.24 -   break;
   68.25 - case 0x05:
   68.26 -   // DEC B
   68.27 -   BC.B.B1--; 
   68.28 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]|
   68.29 -     ((BC.B.B1&0x0F)==0x0F? H_FLAG:0);
   68.30 -   break;
   68.31 - case 0x06:
   68.32 -   // LD B, NN
   68.33 -   BC.B.B1=gbReadOpcode(PC.W++);
   68.34 -   break;
   68.35 - case 0x07:
   68.36 -   // RLCA
   68.37 -   tempValue=AF.B.B1&0x80? C_FLAG:0;
   68.38 -   AF.B.B1=((AF.B.B1<<1)|(AF.B.B1>>7)) & 0xFF;
   68.39 -   AF.B.B0=tempValue;
   68.40 -   break;
   68.41 - case 0x08:
   68.42 -   // LD (NNNN), SP
   68.43 -   tempRegister.B.B0=gbReadOpcode(PC.W++);
   68.44 -   tempRegister.B.B1=gbReadOpcode(PC.W++);
   68.45 -   gbWriteMemory(tempRegister.W++,SP.B.B0);
   68.46 -   gbWriteMemory(tempRegister.W,SP.B.B1);
   68.47 -   break;
   68.48 - case 0x09:
   68.49 -   // ADD HL,BC
   68.50 -   tempRegister.W=(HL.W+BC.W)&0xFFFF;
   68.51 -   AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^BC.W^tempRegister.W)&0x1000? H_FLAG:0)|
   68.52 -     (((long)HL.W+(long)BC.W)&0x10000? C_FLAG:0);
   68.53 -   HL.W=tempRegister.W;
   68.54 -   break;
   68.55 - case 0x0a:
   68.56 -   // LD A,(BC)
   68.57 -   AF.B.B1=gbReadMemory(BC.W);
   68.58 -   break;
   68.59 - case 0x0b:
   68.60 -   // DEC BC
   68.61 -   BC.W--;
   68.62 -   break;   
   68.63 - case 0x0c:
   68.64 -   // INC C
   68.65 -   BC.B.B0++;
   68.66 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]| (BC.B.B0&0x0F? 0:H_FLAG);
   68.67 -   break;
   68.68 - case 0x0d:
   68.69 -   // DEC C
   68.70 -   BC.B.B0--;
   68.71 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]|
   68.72 -     ((BC.B.B0&0x0F)==0x0F? H_FLAG:0);
   68.73 -   break;   
   68.74 - case 0x0e:
   68.75 -   // LD C, NN
   68.76 -   BC.B.B0=gbReadOpcode(PC.W++);
   68.77 -   break;
   68.78 - case 0x0f:
   68.79 -   // RRCA
   68.80 -   tempValue=AF.B.B1&0x01;
   68.81 -   AF.B.B1=(AF.B.B1>>1)|(tempValue? 0x80:0);
   68.82 -   AF.B.B0=(tempValue<<4);
   68.83 -   break;
   68.84 - case 0x10:
   68.85 -   // STOP
   68.86 -   opcode = gbReadOpcode(PC.W++);
   68.87 -   if(gbCgbMode) {
   68.88 -     if(gbReadMemoryQuick(0xff4d) & 1) {
   68.89 -       gbSpeedSwitch();
   68.90 -       
   68.91 -       if(gbSpeed == 0)
   68.92 -         gbWriteMemoryQuick(0xff4d, 0x00);
   68.93 -       else
   68.94 -         gbWriteMemoryQuick(0xff4d, 0x80);
   68.95 -     }
   68.96 -   }
   68.97 -   break;
   68.98 - case 0x11:
   68.99 -   // LD DE, NNNN
  68.100 -   DE.B.B0=gbReadMemory(PC.W++);
  68.101 -   DE.B.B1=gbReadMemory(PC.W++);
  68.102 -   break;
  68.103 - case 0x12:
  68.104 -   // LD (DE),A
  68.105 -   gbWriteMemory(DE.W,AF.B.B1);
  68.106 -   break;
  68.107 - case 0x13:
  68.108 -   // INC DE
  68.109 -   DE.W++;
  68.110 -   break;
  68.111 - case 0x14:
  68.112 -   // INC D
  68.113 -   DE.B.B1++;
  68.114 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]| (DE.B.B1&0x0F? 0:H_FLAG);
  68.115 -   break;
  68.116 - case 0x15:
  68.117 -   // DEC D
  68.118 -   DE.B.B1--;
  68.119 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]|
  68.120 -     ((DE.B.B1&0x0F)==0x0F? H_FLAG:0);
  68.121 -   break;
  68.122 - case 0x16:
  68.123 -   //  LD D,NN
  68.124 -   DE.B.B1=gbReadOpcode(PC.W++);
  68.125 -   break;
  68.126 - case 0x17:
  68.127 -   // RLA
  68.128 -   tempValue=AF.B.B1&0x80? C_FLAG:0;
  68.129 -   AF.B.B1=((AF.B.B1<<1)|((AF.B.B0&C_FLAG)>>4)) & 0xFF;
  68.130 -   AF.B.B0=tempValue;
  68.131 -   break;
  68.132 - case 0x18:
  68.133 -   // JR NN
  68.134 -   PC.W+=(s8)gbReadMemory(PC.W)+1;
  68.135 -   break;
  68.136 - case 0x19:
  68.137 -   // ADD HL,DE
  68.138 -   tempRegister.W=(HL.W+DE.W)&0xFFFF;
  68.139 -   AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^DE.W^tempRegister.W)&0x1000? H_FLAG:0)|
  68.140 -     (((long)HL.W+(long)DE.W)&0x10000? C_FLAG:0);
  68.141 -   HL.W=tempRegister.W;
  68.142 -   break;
  68.143 - case 0x1a:
  68.144 -   // LD A,(DE)
  68.145 -   AF.B.B1=gbReadMemory(DE.W);
  68.146 -   break;   
  68.147 - case 0x1b:
  68.148 -   // DEC DE
  68.149 -   DE.W--;
  68.150 -   break;
  68.151 - case 0x1c:
  68.152 -   // INC E
  68.153 -   DE.B.B0++;
  68.154 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]| (DE.B.B0&0x0F? 0:H_FLAG);
  68.155 -   break;
  68.156 - case 0x1d:
  68.157 -   // DEC E
  68.158 -   DE.B.B0--;
  68.159 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]|
  68.160 -     ((DE.B.B0&0x0F)==0x0F? H_FLAG:0);
  68.161 -   break;
  68.162 - case 0x1e:
  68.163 -   // LD E,NN
  68.164 -   DE.B.B0=gbReadOpcode(PC.W++);
  68.165 -   break;   
  68.166 - case 0x1f:
  68.167 -   // RRA
  68.168 -   tempValue=AF.B.B1&0x01;
  68.169 -   AF.B.B1=(AF.B.B1>>1)|(AF.B.B0&C_FLAG? 0x80:0);
  68.170 -   AF.B.B0=(tempValue<<4);
  68.171 -   break;
  68.172 - case 0x20:
  68.173 -   // JR NZ,NN
  68.174 -   if(AF.B.B0&Z_FLAG)
  68.175 -     PC.W++;
  68.176 -   else {
  68.177 -     PC.W+=(s8)gbReadMemory(PC.W)+1;
  68.178 -     clockTicks++;
  68.179 -   }
  68.180 -   break;
  68.181 - case 0x21:
  68.182 -   // LD HL,NNNN
  68.183 -   HL.B.B0=gbReadMemory(PC.W++);
  68.184 -   HL.B.B1=gbReadMemory(PC.W++);
  68.185 -   break;   
  68.186 - case 0x22:
  68.187 -   // LDI (HL),A
  68.188 -   gbWriteMemory(HL.W++,AF.B.B1);
  68.189 -   break;
  68.190 - case 0x23:
  68.191 -   // INC HL
  68.192 -   HL.W++;
  68.193 -   break;
  68.194 - case 0x24:
  68.195 -   // INC H
  68.196 -   HL.B.B1++;
  68.197 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]| (HL.B.B1&0x0F? 0:H_FLAG);
  68.198 -   break;
  68.199 - case 0x25:
  68.200 -   // DEC H
  68.201 -   HL.B.B1--;
  68.202 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]|
  68.203 -     ((HL.B.B1&0x0F)==0x0F? H_FLAG:0);
  68.204 -   break;
  68.205 - case 0x26:
  68.206 -   // LD H,NN
  68.207 -   HL.B.B1=gbReadOpcode(PC.W++);
  68.208 -   break;
  68.209 - case 0x27:
  68.210 -   // DAA
  68.211 -   tempRegister.W=AF.B.B1;
  68.212 -   if(AF.B.B0&C_FLAG) tempRegister.W|=256;
  68.213 -   if(AF.B.B0&H_FLAG) tempRegister.W|=512;
  68.214 -   if(AF.B.B0&N_FLAG) tempRegister.W|=1024;
  68.215 -   AF.W=DAATable[tempRegister.W];
  68.216 -   break;
  68.217 - case 0x28:
  68.218 -   // JR Z,NN
  68.219 -   if(AF.B.B0&Z_FLAG) {
  68.220 -     PC.W+=(s8)gbReadMemory(PC.W)+1;
  68.221 -     clockTicks++;
  68.222 -   } else
  68.223 -     PC.W++;
  68.224 -   break;
  68.225 - case 0x29:
  68.226 -   // ADD HL,HL
  68.227 -   tempRegister.W=(HL.W+HL.W)&0xFFFF; AF.B.B0= (AF.B.B0 & Z_FLAG)|
  68.228 -                             ((HL.W^HL.W^tempRegister.W)&0x1000? H_FLAG:0)|
  68.229 -                             (((long)HL.W+(long)HL.W)&0x10000? C_FLAG:0);
  68.230 -   HL.W=tempRegister.W;
  68.231 -   break;
  68.232 - case 0x2a:
  68.233 -   // LDI A,(HL)
  68.234 -   AF.B.B1 = gbReadMemory(HL.W++);
  68.235 -   break;
  68.236 - case 0x2b:
  68.237 -   // DEC HL
  68.238 -   HL.W--;
  68.239 -   break;   
  68.240 - case 0x2c:
  68.241 -   // INC L
  68.242 -   HL.B.B0++;
  68.243 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]| (HL.B.B0&0x0F? 0:H_FLAG);
  68.244 -   break;
  68.245 - case 0x2d:
  68.246 -   // DEC L
  68.247 -   HL.B.B0--;
  68.248 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]|
  68.249 -     ((HL.B.B0&0x0F)==0x0F? H_FLAG:0);
  68.250 -   break;
  68.251 - case 0x2e:
  68.252 -   // LD L,NN
  68.253 -   HL.B.B0=gbReadOpcode(PC.W++);
  68.254 -   break;   
  68.255 - case 0x2f:
  68.256 -   // CPL
  68.257 -   AF.B.B1 ^= 255;
  68.258 -   AF.B.B0|=N_FLAG|H_FLAG;
  68.259 -   break;
  68.260 - case 0x30:
  68.261 -   // JR NC,NN
  68.262 -   if(AF.B.B0&C_FLAG)
  68.263 -     PC.W++;
  68.264 -   else {
  68.265 -     PC.W+=(s8)gbReadMemory(PC.W)+1;
  68.266 -     clockTicks++;
  68.267 -   }
  68.268 -   break;
  68.269 - case 0x31:
  68.270 -   // LD SP,NNNN
  68.271 -   SP.B.B0=gbReadMemory(PC.W++);
  68.272 -   SP.B.B1=gbReadMemory(PC.W++);
  68.273 -   break;
  68.274 - case 0x32:
  68.275 -   // LDD (HL),A
  68.276 -   gbWriteMemory(HL.W--,AF.B.B1);
  68.277 -   break;
  68.278 - case 0x33:
  68.279 -   // INC SP
  68.280 -   SP.W++;
  68.281 -   break;
  68.282 - case 0x34:
  68.283 -   // INC (HL)
  68.284 -   tempValue=(gbReadMemory(HL.W)+1) & 0xFF;
  68.285 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[tempValue]| (tempValue&0x0F? 0:H_FLAG);
  68.286 -   gbWriteMemory(HL.W,tempValue);
  68.287 -   break;
  68.288 - case 0x35:
  68.289 -   // DEC (HL)
  68.290 -   tempValue=(gbReadMemory(HL.W)-1) & 0xFF;
  68.291 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[tempValue]|
  68.292 -     ((tempValue&0x0F)==0x0F? H_FLAG:0);gbWriteMemory(HL.W,tempValue);
  68.293 -   break;
  68.294 - case 0x36:
  68.295 -   // LD (HL),NN
  68.296 -   gbWriteMemory(HL.W,gbReadOpcode(PC.W++));
  68.297 -   break;
  68.298 - case 0x37:
  68.299 -   // SCF
  68.300 -   AF.B.B0 = AF.B.B0 & Z_FLAG | C_FLAG;
  68.301 -   break;   
  68.302 -case 0x38:
  68.303 -  // JR C,NN
  68.304 -  if(AF.B.B0&C_FLAG) {
  68.305 -    PC.W+=(s8)gbReadMemory(PC.W)+1;
  68.306 -    clockTicks ++;
  68.307 -  } else
  68.308 -    PC.W++;
  68.309 -  break;
  68.310 - case 0x39:
  68.311 -   // ADD HL,SP
  68.312 -   tempRegister.W=(HL.W+SP.W)&0xFFFF;
  68.313 -   AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^SP.W^tempRegister.W)&0x1000? H_FLAG:0)|
  68.314 -     (((long)HL.W+(long)SP.W)&0x10000? C_FLAG:0);
  68.315 -   HL.W=tempRegister.W;
  68.316 -   break;
  68.317 - case 0x3a:
  68.318 -   // LDD A,(HL)
  68.319 -   AF.B.B1 = gbReadMemory(HL.W--);
  68.320 -   break;
  68.321 - case 0x3b:
  68.322 -   // DEC SP
  68.323 -   SP.W--;
  68.324 -   break;
  68.325 - case 0x3c:
  68.326 -   // INC A
  68.327 -   AF.B.B1++;
  68.328 -   AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]| (AF.B.B1&0x0F? 0:H_FLAG);
  68.329 -   break;
  68.330 - case 0x3d:
  68.331 -   // DEC A
  68.332 -   AF.B.B1--;
  68.333 -   AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]|
  68.334 -     ((AF.B.B1&0x0F)==0x0F? H_FLAG:0);
  68.335 -   break;
  68.336 - case 0x3e:
  68.337 -   // LD A,NN
  68.338 -   AF.B.B1=gbReadOpcode(PC.W++);
  68.339 -   break;
  68.340 - case 0x3f:
  68.341 -   // CCF
  68.342 -   AF.B.B0^=C_FLAG;AF.B.B0&=~(N_FLAG|H_FLAG);
  68.343 -   break;
  68.344 - case 0x40:
  68.345 -   // LD B,B
  68.346 -   BC.B.B1=BC.B.B1;
  68.347 -   break;
  68.348 - case 0x41:
  68.349 -   // LD B,C
  68.350 -   BC.B.B1=BC.B.B0;
  68.351 -   break;
  68.352 - case 0x42:
  68.353 -   // LD B,D
  68.354 -   BC.B.B1=DE.B.B1;
  68.355 -   break;
  68.356 - case 0x43:
  68.357 -   // LD B,E
  68.358 -   BC.B.B1=DE.B.B0;
  68.359 -   break;
  68.360 - case 0x44:
  68.361 -   // LD B,H
  68.362 -   BC.B.B1=HL.B.B1;
  68.363 -   break;
  68.364 - case 0x45:
  68.365 -   // LD B,L
  68.366 -   BC.B.B1=HL.B.B0;
  68.367 -   break;
  68.368 - case 0x46:
  68.369 -   // LD B,(HL)
  68.370 -   BC.B.B1=gbReadMemory(HL.W);
  68.371 -   break;
  68.372 - case 0x47:
  68.373 -   // LD B,A
  68.374 -   BC.B.B1=AF.B.B1;
  68.375 -   break;
  68.376 - case 0x48:
  68.377 -   // LD C,B
  68.378 -   BC.B.B0=BC.B.B1;
  68.379 -   break;
  68.380 - case 0x49:
  68.381 -   // LD C,C
  68.382 -   BC.B.B0=BC.B.B0;
  68.383 -   break;
  68.384 - case 0x4a:
  68.385 -   // LD C,D
  68.386 -   BC.B.B0=DE.B.B1;
  68.387 -   break;
  68.388 - case 0x4b:
  68.389 -   // LD C,E
  68.390 -   BC.B.B0=DE.B.B0;
  68.391 -   break;
  68.392 - case 0x4c:
  68.393 -   // LD C,H
  68.394 -   BC.B.B0=HL.B.B1;
  68.395 -   break;
  68.396 - case 0x4d:
  68.397 -   // LD C,L
  68.398 -   BC.B.B0=HL.B.B0;
  68.399 -   break;
  68.400 - case 0x4e:
  68.401 -   // LD C,(HL)
  68.402 -   BC.B.B0=gbReadMemory(HL.W);
  68.403 -   break;
  68.404 - case 0x4f:
  68.405 -   // LD C,A
  68.406 -   BC.B.B0=AF.B.B1;
  68.407 -   break;
  68.408 - case 0x50:
  68.409 -   // LD D,B
  68.410 -   DE.B.B1=BC.B.B1;
  68.411 -   break;
  68.412 - case 0x51:
  68.413 -   // LD D,C
  68.414 -   DE.B.B1=BC.B.B0;
  68.415 -   break;
  68.416 - case 0x52:
  68.417 -   // LD D,D
  68.418 -   DE.B.B1=DE.B.B1;
  68.419 -   break;
  68.420 - case 0x53:
  68.421 -   // LD D,E
  68.422 -   DE.B.B1=DE.B.B0;
  68.423 -   break;
  68.424 - case 0x54:
  68.425 -   // LD D,H
  68.426 -   DE.B.B1=HL.B.B1;
  68.427 -   break;
  68.428 - case 0x55:
  68.429 -   // LD D,L
  68.430 -   DE.B.B1=HL.B.B0;
  68.431 -   break;
  68.432 - case 0x56:
  68.433 -   // LD D,(HL)
  68.434 -   DE.B.B1=gbReadMemory(HL.W);
  68.435 -   break;
  68.436 - case 0x57:
  68.437 -   // LD D,A
  68.438 -   DE.B.B1=AF.B.B1;
  68.439 -   break;
  68.440 - case 0x58:
  68.441 -   // LD E,B
  68.442 -   DE.B.B0=BC.B.B1;
  68.443 -   break;
  68.444 - case 0x59:
  68.445 -   // LD E,C
  68.446 -   DE.B.B0=BC.B.B0;
  68.447 -   break;
  68.448 - case 0x5a:
  68.449 -   // LD E,D
  68.450 -   DE.B.B0=DE.B.B1;
  68.451 -   break;
  68.452 - case 0x5b:
  68.453 -   // LD E,E
  68.454 -   DE.B.B0=DE.B.B0;
  68.455 -   break;
  68.456 - case 0x5c:
  68.457 -   // LD E,H
  68.458 -   DE.B.B0=HL.B.B1;
  68.459 -   break;
  68.460 - case 0x5d:
  68.461 -   // LD E,L
  68.462 -   DE.B.B0=HL.B.B0;
  68.463 -   break;
  68.464 - case 0x5e:
  68.465 -   // LD E,(HL)
  68.466 -   DE.B.B0=gbReadMemory(HL.W);
  68.467 -   break;
  68.468 - case 0x5f:
  68.469 -   // LD E,A
  68.470 -   DE.B.B0=AF.B.B1;
  68.471 -   break;
  68.472 - case 0x60:
  68.473 -   // LD H,B
  68.474 -   HL.B.B1=BC.B.B1;
  68.475 -   break;
  68.476 - case 0x61:
  68.477 -   // LD H,C
  68.478 -   HL.B.B1=BC.B.B0;
  68.479 -   break;
  68.480 - case 0x62:
  68.481 -   // LD H,D
  68.482 -   HL.B.B1=DE.B.B1;
  68.483 -   break;
  68.484 - case 0x63:
  68.485 -   // LD H,E
  68.486 -   HL.B.B1=DE.B.B0;
  68.487 -   break;
  68.488 - case 0x64:
  68.489 -   // LD H,H
  68.490 -   HL.B.B1=HL.B.B1;
  68.491 -   break;
  68.492 - case 0x65:
  68.493 -   // LD H,L
  68.494 -   HL.B.B1=HL.B.B0;
  68.495 -   break;
  68.496 - case 0x66:
  68.497 -   // LD H,(HL)
  68.498 -   HL.B.B1=gbReadMemory(HL.W);
  68.499 -   break;
  68.500 - case 0x67:
  68.501 -   // LD H,A
  68.502 -   HL.B.B1=AF.B.B1;
  68.503 -   break;
  68.504 - case 0x68:
  68.505 -   // LD L,B
  68.506 -   HL.B.B0=BC.B.B1;
  68.507 -   break;
  68.508 - case 0x69:
  68.509 -   // LD L,C
  68.510 -   HL.B.B0=BC.B.B0;
  68.511 -   break;
  68.512 - case 0x6a:
  68.513 -   // LD L,D
  68.514 -   HL.B.B0=DE.B.B1;
  68.515 -   break;
  68.516 - case 0x6b:
  68.517 -   // LD L,E
  68.518 -   HL.B.B0=DE.B.B0;
  68.519 -   break;
  68.520 - case 0x6c:
  68.521 -   // LD L,H
  68.522 -   HL.B.B0=HL.B.B1;
  68.523 -   break;
  68.524 - case 0x6d:
  68.525 -   // LD L,L
  68.526 -   HL.B.B0=HL.B.B0;
  68.527 -   break;
  68.528 - case 0x6e:
  68.529 -   // LD L,(HL)
  68.530 -   HL.B.B0=gbReadMemory(HL.W);
  68.531 -   break;
  68.532 - case 0x6f:
  68.533 -   // LD L,A
  68.534 -   HL.B.B0=AF.B.B1;
  68.535 -   break;
  68.536 - case 0x70:
  68.537 -   // LD (HL),B
  68.538 -   gbWriteMemory(HL.W,BC.B.B1);
  68.539 -   break;
  68.540 - case 0x71:
  68.541 -   // LD (HL),C
  68.542 -   gbWriteMemory(HL.W,BC.B.B0);
  68.543 -   break;
  68.544 - case 0x72:
  68.545 -   // LD (HL),D
  68.546 -   gbWriteMemory(HL.W,DE.B.B1);
  68.547 -   break;
  68.548 - case 0x73:
  68.549 -   // LD (HL),E
  68.550 -   gbWriteMemory(HL.W,DE.B.B0);
  68.551 -   break;
  68.552 - case 0x74:
  68.553 -   // LD (HL),H
  68.554 -   gbWriteMemory(HL.W,HL.B.B1);
  68.555 -   break;
  68.556 - case 0x75:
  68.557 -   // LD (HL),L
  68.558 -   gbWriteMemory(HL.W,HL.B.B0);
  68.559 -   break;
  68.560 - case 0x76:
  68.561 -   // HALT
  68.562 -   if(IFF & 1) {
  68.563 -     PC.W--;
  68.564 -     IFF |= 0x80;
  68.565 -   } else {
  68.566 -     if((register_IE & register_IF) > 0)
  68.567 -       IFF |= 0x100;
  68.568 -     else {
  68.569 -       PC.W--;
  68.570 -       IFF |= 0x81;
  68.571 -     }
  68.572 -   }
  68.573 -   break;
  68.574 - case 0x77:
  68.575 -   // LD (HL),A
  68.576 -   gbWriteMemory(HL.W,AF.B.B1);
  68.577 -   break;
  68.578 - case 0x78:
  68.579 -   // LD A,B
  68.580 -   AF.B.B1=BC.B.B1;
  68.581 -   break;
  68.582 - case 0x79:
  68.583 -   // LD A,C
  68.584 -   AF.B.B1=BC.B.B0;
  68.585 -   break;
  68.586 - case 0x7a:
  68.587 -   // LD A,D
  68.588 -   AF.B.B1=DE.B.B1;
  68.589 -   break;
  68.590 - case 0x7b:
  68.591 -   // LD A,E
  68.592 -   AF.B.B1=DE.B.B0;
  68.593 -   break;
  68.594 - case 0x7c:
  68.595 -   // LD A,H
  68.596 -   AF.B.B1=HL.B.B1;
  68.597 -   break;
  68.598 - case 0x7d:
  68.599 -   // LD A,L
  68.600 -   AF.B.B1=HL.B.B0;
  68.601 -   break;
  68.602 - case 0x7e:
  68.603 -   // LD A,(HL)
  68.604 -   AF.B.B1=gbReadMemory(HL.W);
  68.605 -   break;
  68.606 - case 0x7f:
  68.607 -   // LD A,A
  68.608 -   AF.B.B1=AF.B.B1;
  68.609 -   break;
  68.610 - case 0x80:
  68.611 -   // ADD B
  68.612 -   tempRegister.W=AF.B.B1+BC.B.B1;
  68.613 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.614 -     ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.615 -   AF.B.B1=tempRegister.B.B0;
  68.616 -   break;
  68.617 - case 0x81:
  68.618 -   // ADD C
  68.619 -   tempRegister.W=AF.B.B1+BC.B.B0;
  68.620 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.621 -     ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.622 -   AF.B.B1=tempRegister.B.B0;
  68.623 -   break;
  68.624 - case 0x82:
  68.625 -   // ADD D
  68.626 -   tempRegister.W=AF.B.B1+DE.B.B1;
  68.627 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.628 -     ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.629 -   AF.B.B1=tempRegister.B.B0;
  68.630 -   break;
  68.631 - case 0x83:
  68.632 -   // ADD E
  68.633 -   tempRegister.W=AF.B.B1+DE.B.B0;
  68.634 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.635 -     ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.636 -   AF.B.B1=tempRegister.B.B0;
  68.637 -   break;
  68.638 - case 0x84:
  68.639 -   // ADD H
  68.640 -   tempRegister.W=AF.B.B1+HL.B.B1;
  68.641 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.642 -     ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.643 -   AF.B.B1=tempRegister.B.B0;
  68.644 -   break;
  68.645 - case 0x85:
  68.646 -   // ADD L
  68.647 -   tempRegister.W=AF.B.B1+HL.B.B0;
  68.648 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.649 -     ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.650 -   AF.B.B1=tempRegister.B.B0;
  68.651 -   break;
  68.652 - case 0x86:
  68.653 -   // ADD (HL)
  68.654 -   tempValue=gbReadMemory(HL.W);
  68.655 -   tempRegister.W=AF.B.B1+tempValue;
  68.656 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.657 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.658 -   AF.B.B1=tempRegister.B.B0;
  68.659 -   break;
  68.660 - case 0x87:
  68.661 -   // ADD A
  68.662 -   tempRegister.W=AF.B.B1+AF.B.B1;
  68.663 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.664 -     ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0);
  68.665 -   AF.B.B1=tempRegister.B.B0;
  68.666 -   break;
  68.667 - case 0x88:
  68.668 -   // ADC B:
  68.669 -   tempRegister.W=AF.B.B1+BC.B.B1+(AF.B.B0&C_FLAG ? 1 : 0);
  68.670 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.671 -     ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.672 -   AF.B.B1=tempRegister.B.B0;
  68.673 -   break;
  68.674 - case 0x89:
  68.675 -   // ADC C
  68.676 -   tempRegister.W=AF.B.B1+BC.B.B0+(AF.B.B0&C_FLAG ? 1 : 0);
  68.677 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.678 -     ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.679 -   AF.B.B1=tempRegister.B.B0;
  68.680 -   break;
  68.681 - case 0x8a:
  68.682 -   // ADC D
  68.683 -   tempRegister.W=AF.B.B1+DE.B.B1+(AF.B.B0&C_FLAG ? 1 : 0);
  68.684 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.685 -     ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.686 -   AF.B.B1=tempRegister.B.B0;
  68.687 -   break;
  68.688 - case 0x8b:
  68.689 -   // ADC E
  68.690 -   tempRegister.W=AF.B.B1+DE.B.B0+(AF.B.B0&C_FLAG ? 1 : 0);
  68.691 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.692 -     ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.693 -   AF.B.B1=tempRegister.B.B0;
  68.694 -   break;
  68.695 - case 0x8c:
  68.696 -   // ADC H
  68.697 -   tempRegister.W=AF.B.B1+HL.B.B1+(AF.B.B0&C_FLAG ? 1 : 0);
  68.698 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.699 -     ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); AF.B.B1=tempRegister.B.B0;
  68.700 -   break;
  68.701 - case 0x8d:
  68.702 -   // ADC L
  68.703 -   tempRegister.W=AF.B.B1+HL.B.B0+(AF.B.B0&C_FLAG ? 1 : 0);
  68.704 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.705 -     ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.706 -   AF.B.B1=tempRegister.B.B0;
  68.707 -   break;
  68.708 - case 0x8e:
  68.709 -   // ADC (HL)
  68.710 -   tempValue=gbReadMemory(HL.W);
  68.711 -   tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0);
  68.712 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.713 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.714 -   AF.B.B1=tempRegister.B.B0;
  68.715 -   break;
  68.716 - case 0x8f:
  68.717 -   // ADC A
  68.718 -   tempRegister.W=AF.B.B1+AF.B.B1+(AF.B.B0&C_FLAG ? 1 : 0);
  68.719 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.720 -     ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.721 -   AF.B.B1=tempRegister.B.B0;
  68.722 -   break;
  68.723 - case 0x90:
  68.724 -   // SUB B
  68.725 -   tempRegister.W=AF.B.B1-BC.B.B1;
  68.726 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.727 -     ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.728 -   AF.B.B1=tempRegister.B.B0;
  68.729 -   break;
  68.730 - case 0x91:
  68.731 -   // SUB C
  68.732 -   tempRegister.W=AF.B.B1-BC.B.B0;
  68.733 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.734 -     ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.735 -   AF.B.B1=tempRegister.B.B0;
  68.736 -   break;
  68.737 - case 0x92:
  68.738 -   // SUB D
  68.739 -   tempRegister.W=AF.B.B1-DE.B.B1;
  68.740 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.741 -     ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.742 -   AF.B.B1=tempRegister.B.B0;
  68.743 -   break;
  68.744 - case 0x93:
  68.745 -   // SUB E
  68.746 -   tempRegister.W=AF.B.B1-DE.B.B0;
  68.747 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.748 -     ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.749 -   AF.B.B1=tempRegister.B.B0;
  68.750 -   break;
  68.751 - case 0x94:
  68.752 -   // SUB H
  68.753 -   tempRegister.W=AF.B.B1-HL.B.B1;
  68.754 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.755 -     ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.756 -   AF.B.B1=tempRegister.B.B0;
  68.757 -   break;
  68.758 - case 0x95:
  68.759 -   // SUB L
  68.760 -   tempRegister.W=AF.B.B1-HL.B.B0;
  68.761 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.762 -     ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.763 -   AF.B.B1=tempRegister.B.B0;
  68.764 -   break;
  68.765 - case 0x96:
  68.766 -   // SUB (HL)
  68.767 -   tempValue=gbReadMemory(HL.W);
  68.768 -   tempRegister.W=AF.B.B1-tempValue;
  68.769 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.770 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.771 -   AF.B.B1=tempRegister.B.B0;
  68.772 -   break;
  68.773 - case 0x97:
  68.774 -   // SUB A
  68.775 -   AF.B.B1=0;
  68.776 -   AF.B.B0=N_FLAG|Z_FLAG;
  68.777 -   break;
  68.778 - case 0x98:
  68.779 -   // SBC B
  68.780 -   tempRegister.W=AF.B.B1-BC.B.B1-(AF.B.B0&C_FLAG ? 1 : 0);
  68.781 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.782 -     ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.783 -   AF.B.B1=tempRegister.B.B0;
  68.784 -   break;
  68.785 - case 0x99:
  68.786 -   // SBC C
  68.787 -   tempRegister.W=AF.B.B1-BC.B.B0-(AF.B.B0&C_FLAG ? 1 : 0);
  68.788 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.789 -     ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.790 -   AF.B.B1=tempRegister.B.B0;
  68.791 -   break;
  68.792 - case 0x9a:
  68.793 -   // SBC D
  68.794 -   tempRegister.W=AF.B.B1-DE.B.B1-(AF.B.B0&C_FLAG ? 1 : 0);
  68.795 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.796 -     ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.797 -   AF.B.B1=tempRegister.B.B0;
  68.798 -   break;
  68.799 - case 0x9b:
  68.800 -   // SBC E
  68.801 -   tempRegister.W=AF.B.B1-DE.B.B0-(AF.B.B0&C_FLAG ? 1 : 0);
  68.802 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.803 -     ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.804 -   AF.B.B1=tempRegister.B.B0;
  68.805 -   break;
  68.806 - case 0x9c:
  68.807 -   // SBC H
  68.808 -   tempRegister.W=AF.B.B1-HL.B.B1-(AF.B.B0&C_FLAG ? 1 : 0);
  68.809 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.810 -     ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.811 -   AF.B.B1=tempRegister.B.B0;
  68.812 -   break;
  68.813 - case 0x9d:
  68.814 -   // SBC L
  68.815 -   tempRegister.W=AF.B.B1-HL.B.B0-(AF.B.B0&C_FLAG ? 1 : 0);
  68.816 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.817 -     ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.818 -   AF.B.B1=tempRegister.B.B0;
  68.819 -   break;
  68.820 - case 0x9e:
  68.821 -   // SBC (HL)
  68.822 -   tempValue=gbReadMemory(HL.W);
  68.823 -   tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0);
  68.824 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.825 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.826 -   AF.B.B1=tempRegister.B.B0;
  68.827 -   break;
  68.828 - case 0x9f:
  68.829 -   // SBC A
  68.830 -   tempRegister.W=AF.B.B1-AF.B.B1-(AF.B.B0&C_FLAG ? 1 : 0);
  68.831 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.832 -     ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.833 -   AF.B.B1=tempRegister.B.B0;
  68.834 -   break;
  68.835 - case 0xa0:
  68.836 -   // AND B
  68.837 -   AF.B.B1&=BC.B.B1;
  68.838 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.839 -   break;
  68.840 - case 0xa1:
  68.841 -   // AND C
  68.842 -   AF.B.B1&=BC.B.B0;
  68.843 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.844 -   break;
  68.845 - case 0xa2:
  68.846 -   // AND_D
  68.847 -   AF.B.B1&=DE.B.B1;
  68.848 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.849 -   break;
  68.850 - case 0xa3:
  68.851 -   // AND E
  68.852 -   AF.B.B1&=DE.B.B0;
  68.853 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.854 -   break;
  68.855 - case 0xa4:
  68.856 -   // AND H
  68.857 -   AF.B.B1&=HL.B.B1;
  68.858 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.859 -   break;
  68.860 - case 0xa5:
  68.861 -   // AND L
  68.862 -   AF.B.B1&=HL.B.B0;
  68.863 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.864 -   break;
  68.865 - case 0xa6:
  68.866 -   // AND (HL)
  68.867 -   tempValue=gbReadMemory(HL.W);
  68.868 -   AF.B.B1&=tempValue;
  68.869 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.870 -   break;
  68.871 - case 0xa7:
  68.872 -   // AND A
  68.873 -   AF.B.B1&=AF.B.B1;
  68.874 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
  68.875 -   break;
  68.876 - case 0xa8:
  68.877 -   // XOR B
  68.878 -   AF.B.B1^=BC.B.B1;
  68.879 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.880 -   break;
  68.881 - case 0xa9:
  68.882 -   // XOR C
  68.883 -   AF.B.B1^=BC.B.B0;
  68.884 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.885 -   break;
  68.886 - case 0xaa:
  68.887 -   // XOR D
  68.888 -   AF.B.B1^=DE.B.B1;
  68.889 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.890 -   break;
  68.891 - case 0xab:
  68.892 -   // XOR E
  68.893 -   AF.B.B1^=DE.B.B0;
  68.894 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.895 -   break;
  68.896 - case 0xac:
  68.897 -   // XOR H
  68.898 -   AF.B.B1^=HL.B.B1;
  68.899 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.900 -   break;
  68.901 - case 0xad:
  68.902 -   // XOR L
  68.903 -   AF.B.B1^=HL.B.B0;
  68.904 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.905 -   break;
  68.906 - case 0xae:
  68.907 -   // XOR (HL)
  68.908 -   tempValue=gbReadMemory(HL.W);
  68.909 -   AF.B.B1^=tempValue;
  68.910 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.911 -   break;
  68.912 - case 0xaf:
  68.913 -   // XOR A
  68.914 -   AF.B.B1=0;
  68.915 -   AF.B.B0=Z_FLAG;
  68.916 -   break;
  68.917 - case 0xb0:
  68.918 -   // OR B
  68.919 -   AF.B.B1|=BC.B.B1;
  68.920 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.921 -   break;
  68.922 - case 0xb1:
  68.923 -   // OR C
  68.924 -   AF.B.B1|=BC.B.B0;
  68.925 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.926 -   break;
  68.927 - case 0xb2:
  68.928 -   // OR D
  68.929 -   AF.B.B1|=DE.B.B1;
  68.930 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.931 -   break;
  68.932 - case 0xb3:
  68.933 -   // OR E
  68.934 -   AF.B.B1|=DE.B.B0;
  68.935 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.936 -   break;
  68.937 - case 0xb4:
  68.938 -   // OR H
  68.939 -   AF.B.B1|=HL.B.B1;
  68.940 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.941 -   break;
  68.942 - case 0xb5:
  68.943 -   // OR L
  68.944 -   AF.B.B1|=HL.B.B0;
  68.945 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.946 -   break;
  68.947 - case 0xb6:
  68.948 -   // OR (HL)
  68.949 -   tempValue=gbReadMemory(HL.W);
  68.950 -   AF.B.B1|=tempValue;
  68.951 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.952 -   break;
  68.953 - case 0xb7:
  68.954 -   // OR A
  68.955 -   AF.B.B1|=AF.B.B1;
  68.956 -   AF.B.B0=ZeroTable[AF.B.B1];
  68.957 -   break;
  68.958 - case 0xb8:
  68.959 -   // CP B:
  68.960 -   tempRegister.W=AF.B.B1-BC.B.B1;
  68.961 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.962 -     ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.963 -   break;
  68.964 - case 0xb9:
  68.965 -   // CP C
  68.966 -   tempRegister.W=AF.B.B1-BC.B.B0;
  68.967 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.968 -     ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.969 -   break;
  68.970 - case 0xba:
  68.971 -   // CP D
  68.972 -   tempRegister.W=AF.B.B1-DE.B.B1;
  68.973 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.974 -     ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.975 -   break;
  68.976 - case 0xbb:
  68.977 -   // CP E
  68.978 -   tempRegister.W=AF.B.B1-DE.B.B0;
  68.979 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.980 -     ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.981 -   break;
  68.982 - case 0xbc:
  68.983 -   // CP H
  68.984 -   tempRegister.W=AF.B.B1-HL.B.B1;
  68.985 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.986 -     ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.987 -   break;
  68.988 - case 0xbd:
  68.989 -   // CP L
  68.990 -   tempRegister.W=AF.B.B1-HL.B.B0;
  68.991 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.992 -     ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0);
  68.993 -   break;
  68.994 - case 0xbe:
  68.995 -   // CP (HL)
  68.996 -   tempValue=gbReadMemory(HL.W);
  68.997 -   tempRegister.W=AF.B.B1-tempValue;
  68.998 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
  68.999 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
 68.1000 -   break;
 68.1001 - case 0xbf:
 68.1002 -   // CP A
 68.1003 -   AF.B.B0=N_FLAG|Z_FLAG;
 68.1004 -   break;
 68.1005 - case 0xc0:
 68.1006 -   // RET NZ
 68.1007 -   if(!(AF.B.B0&Z_FLAG)) {
 68.1008 -     PC.B.B0=gbReadMemory(SP.W++);
 68.1009 -     PC.B.B1=gbReadMemory(SP.W++);
 68.1010 -     clockTicks += 3;
 68.1011 -   }
 68.1012 -   break;
 68.1013 - case 0xc1:
 68.1014 -   // POP BC
 68.1015 -   BC.B.B0=gbReadMemory(SP.W++);
 68.1016 -   BC.B.B1=gbReadMemory(SP.W++);
 68.1017 -   break;
 68.1018 - case 0xc2:
 68.1019 -   // JP NZ,NNNN
 68.1020 -   if(AF.B.B0&Z_FLAG)
 68.1021 -     PC.W+=2;
 68.1022 -   else {
 68.1023 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1024 -     tempRegister.B.B1=gbReadMemory(PC.W);
 68.1025 -     PC.W=tempRegister.W;
 68.1026 -     clockTicks++;
 68.1027 -   }
 68.1028 -   break;
 68.1029 - case 0xc3:
 68.1030 -   // JP NNNN
 68.1031 -   tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1032 -   tempRegister.B.B1=gbReadMemory(PC.W);
 68.1033 -   PC.W=tempRegister.W;
 68.1034 -   break;
 68.1035 - case 0xc4:
 68.1036 -   // CALL NZ,NNNN
 68.1037 -   if(AF.B.B0&Z_FLAG)
 68.1038 -     PC.W+=2;
 68.1039 -   else {
 68.1040 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1041 -     tempRegister.B.B1=gbReadMemory(PC.W++);
 68.1042 -     gbWriteMemory(--SP.W,PC.B.B1);
 68.1043 -     gbWriteMemory(--SP.W,PC.B.B0);
 68.1044 -     PC.W=tempRegister.W;
 68.1045 -     clockTicks += 3;
 68.1046 -   }
 68.1047 -   break;
 68.1048 - case 0xc5:
 68.1049 -   // PUSH BC
 68.1050 -   gbWriteMemory(--SP.W,BC.B.B1);
 68.1051 -   gbWriteMemory(--SP.W,BC.B.B0);
 68.1052 -   break;
 68.1053 - case 0xc6:
 68.1054 -   // ADD NN
 68.1055 -   tempValue=gbReadOpcode(PC.W++);
 68.1056 -   tempRegister.W=AF.B.B1+tempValue;
 68.1057 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
 68.1058 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0);
 68.1059 -   AF.B.B1=tempRegister.B.B0;
 68.1060 -   break;
 68.1061 - case 0xc7:
 68.1062 -   // RST 00
 68.1063 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1064 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1065 -   PC.W=0x0000;
 68.1066 -   break;
 68.1067 - case 0xc8:
 68.1068 -   // RET Z
 68.1069 -   if(AF.B.B0&Z_FLAG) {
 68.1070 -     PC.B.B0=gbReadMemory(SP.W++);
 68.1071 -     PC.B.B1=gbReadMemory(SP.W++);
 68.1072 -     clockTicks += 3;
 68.1073 -   }
 68.1074 -   break;
 68.1075 - case 0xc9:
 68.1076 -   // RET
 68.1077 -   PC.B.B0=gbReadMemory(SP.W++);
 68.1078 -   PC.B.B1=gbReadMemory(SP.W++);
 68.1079 -   break;
 68.1080 - case 0xca:
 68.1081 -   // JP Z,NNNN
 68.1082 -   if(AF.B.B0&Z_FLAG) {
 68.1083 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1084 -     tempRegister.B.B1=gbReadMemory(PC.W);
 68.1085 -     PC.W=tempRegister.W;
 68.1086 -     clockTicks++;
 68.1087 -   } else
 68.1088 -     PC.W+=2;
 68.1089 -   break;
 68.1090 -   // CB done outside
 68.1091 - case 0xcc:
 68.1092 -   // CALL Z,NNNN
 68.1093 -   if(AF.B.B0&Z_FLAG) {
 68.1094 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1095 -     tempRegister.B.B1=gbReadMemory(PC.W++);
 68.1096 -     gbWriteMemory(--SP.W,PC.B.B1);
 68.1097 -     gbWriteMemory(--SP.W,PC.B.B0);
 68.1098 -     PC.W=tempRegister.W;
 68.1099 -     clockTicks += 3;
 68.1100 -   } else
 68.1101 -     PC.W+=2;
 68.1102 -   break;
 68.1103 - case 0xcd:
 68.1104 -   // CALL NNNN
 68.1105 -   tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1106 -   tempRegister.B.B1=gbReadMemory(PC.W++);
 68.1107 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1108 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1109 -   PC.W=tempRegister.W;
 68.1110 -   break;
 68.1111 - case 0xce:
 68.1112 -   // ADC NN
 68.1113 -   tempValue=gbReadOpcode(PC.W++);
 68.1114 -   tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0);
 68.1115 -   AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
 68.1116 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
 68.1117 -   AF.B.B1=tempRegister.B.B0;
 68.1118 -   break;
 68.1119 - case 0xcf:
 68.1120 -   // RST 08
 68.1121 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1122 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1123 -   PC.W=0x0008;
 68.1124 -   break;
 68.1125 - case 0xd0:
 68.1126 -   // RET NC
 68.1127 -   if(!(AF.B.B0&C_FLAG)) {
 68.1128 -     PC.B.B0=gbReadMemory(SP.W++);
 68.1129 -     PC.B.B1=gbReadMemory(SP.W++);
 68.1130 -     clockTicks += 3;
 68.1131 -   }
 68.1132 -   break;
 68.1133 - case 0xd1:
 68.1134 -   // POP DE
 68.1135 -   DE.B.B0=gbReadMemory(SP.W++);
 68.1136 -   DE.B.B1=gbReadMemory(SP.W++);
 68.1137 -   break;
 68.1138 - case 0xd2:
 68.1139 -   // JP NC,NNNN
 68.1140 -   if(AF.B.B0&C_FLAG)
 68.1141 -     PC.W+=2;
 68.1142 -   else {
 68.1143 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1144 -     tempRegister.B.B1=gbReadMemory(PC.W);
 68.1145 -     PC.W=tempRegister.W;
 68.1146 -     clockTicks++;
 68.1147 -   }
 68.1148 -   break;
 68.1149 -   // D3 illegal
 68.1150 - case 0xd4:
 68.1151 -   // CALL NC,NNNN
 68.1152 -   if(AF.B.B0&C_FLAG)
 68.1153 -     PC.W+=2;
 68.1154 -   else {
 68.1155 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1156 -     tempRegister.B.B1=gbReadMemory(PC.W++);
 68.1157 -     gbWriteMemory(--SP.W,PC.B.B1);
 68.1158 -     gbWriteMemory(--SP.W,PC.B.B0);
 68.1159 -     PC.W=tempRegister.W;
 68.1160 -     clockTicks += 3;
 68.1161 -   }
 68.1162 -   break;
 68.1163 - case 0xd5:
 68.1164 -   // PUSH DE
 68.1165 -   gbWriteMemory(--SP.W,DE.B.B1);
 68.1166 -   gbWriteMemory(--SP.W,DE.B.B0);
 68.1167 -   break;
 68.1168 - case 0xd6:
 68.1169 -   // SUB NN
 68.1170 -   tempValue=gbReadOpcode(PC.W++);
 68.1171 -   tempRegister.W=AF.B.B1-tempValue;
 68.1172 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
 68.1173 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
 68.1174 -   AF.B.B1=tempRegister.B.B0;
 68.1175 -   break;
 68.1176 - case 0xd7:
 68.1177 -   // RST 10
 68.1178 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1179 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1180 -   PC.W=0x0010;
 68.1181 -   break;
 68.1182 - case 0xd8:
 68.1183 -   // RET C
 68.1184 -   if(AF.B.B0&C_FLAG) {
 68.1185 -     PC.B.B0=gbReadMemory(SP.W++);
 68.1186 -     PC.B.B1=gbReadMemory(SP.W++);
 68.1187 -     clockTicks += 4;
 68.1188 -   }
 68.1189 -   break;
 68.1190 - case 0xd9:
 68.1191 -   // RETI
 68.1192 -   PC.B.B0=gbReadMemory(SP.W++);
 68.1193 -   PC.B.B1=gbReadMemory(SP.W++);
 68.1194 -   IFF |= 0x01;
 68.1195 -   break;
 68.1196 - case 0xda:
 68.1197 -   // JP C,NNNN
 68.1198 -   if(AF.B.B0&C_FLAG) {
 68.1199 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1200 -     tempRegister.B.B1=gbReadMemory(PC.W);
 68.1201 -     PC.W=tempRegister.W;
 68.1202 -     clockTicks++;
 68.1203 -   } else
 68.1204 -     PC.W+=2;
 68.1205 -   break;
 68.1206 -   // DB illegal
 68.1207 - case 0xdc:
 68.1208 -   // CALL C,NNNN
 68.1209 -   if(AF.B.B0&C_FLAG) {
 68.1210 -     tempRegister.B.B0=gbReadMemory(PC.W++);
 68.1211 -     tempRegister.B.B1=gbReadMemory(PC.W++);
 68.1212 -     gbWriteMemory(--SP.W,PC.B.B1);
 68.1213 -     gbWriteMemory(--SP.W,PC.B.B0);
 68.1214 -     PC.W=tempRegister.W;
 68.1215 -     clockTicks += 3;
 68.1216 -   } else
 68.1217 -     PC.W+=2;
 68.1218 -   break;
 68.1219 -   // DD illegal
 68.1220 - case 0xde:
 68.1221 -   // SBC NN
 68.1222 -   tempValue=gbReadOpcode(PC.W++);
 68.1223 -   tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0);
 68.1224 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
 68.1225 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
 68.1226 -   AF.B.B1=tempRegister.B.B0;
 68.1227 -   break;
 68.1228 - case 0xdf:
 68.1229 -   // RST 18
 68.1230 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1231 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1232 -   PC.W=0x0018;
 68.1233 -   break;
 68.1234 - case 0xe0:
 68.1235 -   // LD (FF00+NN),A
 68.1236 -   gbWriteMemory(0xff00 + gbReadOpcode(PC.W++),AF.B.B1);
 68.1237 -   break;
 68.1238 - case 0xe1:
 68.1239 -   // POP HL
 68.1240 -   HL.B.B0=gbReadMemory(SP.W++);
 68.1241 -   HL.B.B1=gbReadMemory(SP.W++);
 68.1242 -   break;
 68.1243 - case 0xe2:
 68.1244 -   // LD (FF00+C),A
 68.1245 -   gbWriteMemory(0xff00 + BC.B.B0,AF.B.B1);
 68.1246 -   break;
 68.1247 -   // E3 illegal
 68.1248 -   // E4 illegal
 68.1249 - case 0xe5:
 68.1250 -   // PUSH HL
 68.1251 -   gbWriteMemory(--SP.W,HL.B.B1);
 68.1252 -   gbWriteMemory(--SP.W,HL.B.B0);
 68.1253 -   break;
 68.1254 - case 0xe6:
 68.1255 -   // AND NN
 68.1256 -   tempValue=gbReadOpcode(PC.W++);
 68.1257 -   AF.B.B1&=tempValue;
 68.1258 -   AF.B.B0=H_FLAG|ZeroTable[AF.B.B1];
 68.1259 -   break;
 68.1260 - case 0xe7:
 68.1261 -   // RST 20
 68.1262 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1263 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1264 -   PC.W=0x0020;
 68.1265 -   break;
 68.1266 - case 0xe8:
 68.1267 -   // ADD SP,NN
 68.1268 -   offset = (s8)gbReadOpcode(PC.W++);
 68.1269 -   
 68.1270 -   if(offset >= 0) {
 68.1271 -     tempRegister.W = SP.W + offset;
 68.1272 -     AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) |
 68.1273 -       ((SP.W^offset^tempRegister.W)&0x1000? H_FLAG:0);
 68.1274 -     SP.W = tempRegister.W;
 68.1275 -   } else {
 68.1276 -     tempRegister.W = SP.W + offset;
 68.1277 -     AF.B.B0 = (SP.W < tempRegister.W ? C_FLAG : 0) |
 68.1278 -       ((SP.W^offset^tempRegister.W)&0x1000?H_FLAG:0);
 68.1279 -     SP.W = tempRegister.W;
 68.1280 -   }
 68.1281 -   break;
 68.1282 - case 0xe9:
 68.1283 -   // LD PC,HL
 68.1284 -   PC.W=HL.W;
 68.1285 -   break;
 68.1286 - case 0xea:
 68.1287 -   // LD (NNNN),A
 68.1288 -   tempRegister.B.B0=gbReadOpcode(PC.W++);
 68.1289 -   tempRegister.B.B1=gbReadOpcode(PC.W++);
 68.1290 -   gbWriteMemory(tempRegister.W,AF.B.B1);
 68.1291 -   break;
 68.1292 -   // EB illegal
 68.1293 -   // EC illegal
 68.1294 -   // ED illegal
 68.1295 - case 0xee:
 68.1296 -   // XOR NN
 68.1297 -   tempValue=gbReadOpcode(PC.W++);
 68.1298 -   AF.B.B1^=tempValue;
 68.1299 -   AF.B.B0=ZeroTable[AF.B.B1];
 68.1300 -   break;
 68.1301 - case 0xef:
 68.1302 -   // RST 28
 68.1303 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1304 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1305 -   PC.W=0x0028;
 68.1306 -   break;
 68.1307 - case 0xf0:
 68.1308 -   // LD A,(FF00+NN)
 68.1309 -   AF.B.B1 = gbReadMemory(0xff00+gbReadOpcode(PC.W++));
 68.1310 -   break;
 68.1311 - case 0xf1:
 68.1312 -   // POP AF
 68.1313 -   AF.B.B0=gbReadMemory(SP.W++);
 68.1314 -   AF.B.B1=gbReadMemory(SP.W++);
 68.1315 -   break;
 68.1316 - case 0xf2:
 68.1317 -   // LD A,(FF00+C)
 68.1318 -   AF.B.B1 = gbReadMemory(0xff00+BC.B.B0);
 68.1319 -   break;
 68.1320 - case 0xf3:
 68.1321 -   // DI
 68.1322 - //   IFF&=0xFE;
 68.1323 -   IFF&=(~0x21);
 68.1324 -   break;
 68.1325 -   // F4 illegal
 68.1326 - case 0xf5:
 68.1327 -   // PUSH AF
 68.1328 -   gbWriteMemory(--SP.W,AF.B.B1);
 68.1329 -   gbWriteMemory(--SP.W,AF.B.B0);
 68.1330 -   break;
 68.1331 - case 0xf6:
 68.1332 -   // OR NN
 68.1333 -   tempValue=gbReadOpcode(PC.W++);
 68.1334 -   AF.B.B1|=tempValue;
 68.1335 -   AF.B.B0=ZeroTable[AF.B.B1];
 68.1336 -   break;
 68.1337 - case 0xf7:
 68.1338 -   // RST 30
 68.1339 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1340 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1341 -   PC.W=0x0030;
 68.1342 -   break;
 68.1343 - case 0xf8:
 68.1344 -   // LD HL,SP+NN
 68.1345 -   offset = (s8)gbReadOpcode(PC.W++);
 68.1346 -   if(offset >= 0) {
 68.1347 -     tempRegister.W = SP.W + offset;
 68.1348 -     AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) |
 68.1349 -       ((SP.W^offset^tempRegister.W)&0x1000? H_FLAG:0);
 68.1350 -     HL.W = tempRegister.W;
 68.1351 -   } else {
 68.1352 -     tempRegister.W = SP.W + offset;
 68.1353 -     AF.B.B0 = (SP.W < tempRegister.W ? C_FLAG : 0) |
 68.1354 -       ((SP.W^offset^tempRegister.W)&0x1000?H_FLAG:0);
 68.1355 -     HL.W = tempRegister.W;
 68.1356 -   }
 68.1357 -   break;
 68.1358 - case 0xf9:
 68.1359 -   // LD SP,HL
 68.1360 -   SP.W=HL.W;
 68.1361 -   break;
 68.1362 - case 0xfa:
 68.1363 -   // LD A,(NNNN)
 68.1364 -   tempRegister.B.B0=gbReadOpcode(PC.W++);
 68.1365 -   tempRegister.B.B1=gbReadOpcode(PC.W++);
 68.1366 -   AF.B.B1=gbReadMemory(tempRegister.W);
 68.1367 -   break;
 68.1368 - case 0xfb:
 68.1369 -   // EI
 68.1370 -   IFF|=0x20;
 68.1371 -   break;
 68.1372 -   // FC illegal
 68.1373 -   // FD illegal
 68.1374 - case 0xfe:
 68.1375 -   // CP NN
 68.1376 -   tempValue=gbReadOpcode(PC.W++);
 68.1377 -   tempRegister.W=AF.B.B1-tempValue;
 68.1378 -   AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]|
 68.1379 -     ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0);
 68.1380 -   break;
 68.1381 - case 0xff:
 68.1382 -   // RST 38
 68.1383 -   gbWriteMemory(--SP.W,PC.B.B1);
 68.1384 -   gbWriteMemory(--SP.W,PC.B.B0);
 68.1385 -   PC.W=0x0038;
 68.1386 -   break;
 68.1387 - default:
 68.1388 -   systemMessage(0, N_("Unknown opcode %02x at %04x"),
 68.1389 -                 gbReadOpcode(PC.W-1),PC.W-1);
 68.1390 -   emulating = false;
 68.1391 -   return;
    69.1 --- a/src/gb/gbCodesCB.h	Sat Mar 03 10:54:39 2012 -0600
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,1269 +0,0 @@
    69.4 - case 0x00:
    69.5 -   // RLC B
    69.6 -   AF.B.B0 = (BC.B.B1 & 0x80)?C_FLAG:0;
    69.7 -   BC.B.B1 = ((BC.B.B1<<1) | (BC.B.B1>>7)) & 0xFF;
    69.8 -   AF.B.B0 |= ZeroTable[BC.B.B1];
    69.9 -   break;
   69.10 - case 0x01:
   69.11 -   // RLC C
   69.12 -   AF.B.B0 = (BC.B.B0 & 0x80)?C_FLAG:0;
   69.13 -   BC.B.B0 = ((BC.B.B0<<1) | (BC.B.B0>>7)) & 0xFF;
   69.14 -   AF.B.B0 |= ZeroTable[BC.B.B0];
   69.15 -   break;
   69.16 - case 0x02:
   69.17 -   // RLC D
   69.18 -   AF.B.B0 = (DE.B.B1 & 0x80)?C_FLAG:0;
   69.19 -   DE.B.B1 = ((DE.B.B1<<1) | (DE.B.B1>>7)) & 0xFF;
   69.20 -   AF.B.B0 |= ZeroTable[DE.B.B1];
   69.21 -   break;
   69.22 - case 0x03:
   69.23 -   // RLC E
   69.24 -   AF.B.B0 = (DE.B.B0 & 0x80)?C_FLAG:0;
   69.25 -   DE.B.B0 = ((DE.B.B0<<1) | (DE.B.B0>>7)) & 0xFF;
   69.26 -   AF.B.B0 |= ZeroTable[DE.B.B0];
   69.27 -   break;
   69.28 - case 0x04:
   69.29 -   // RLC H
   69.30 -   AF.B.B0 = (HL.B.B1 & 0x80)?C_FLAG:0;
   69.31 -   HL.B.B1 = ((HL.B.B1<<1) | (HL.B.B1>>7)) & 0xFF;
   69.32 -   AF.B.B0 |= ZeroTable[HL.B.B1];
   69.33 -   break;
   69.34 - case 0x05:
   69.35 -   // RLC L
   69.36 -   AF.B.B0 = (HL.B.B0 & 0x80)?C_FLAG:0;
   69.37 -   HL.B.B0 = ((HL.B.B0<<1) | (HL.B.B0>>7)) & 0xFF;
   69.38 -   AF.B.B0 |= ZeroTable[HL.B.B0];
   69.39 -   break;
   69.40 - case 0x06:
   69.41 -   // RLC (HL)
   69.42 -   tempValue=gbReadMemory(HL.W);
   69.43 -   AF.B.B0 = (tempValue & 0x80)?C_FLAG:0;
   69.44 -   tempValue = ((tempValue<<1) | (tempValue>>7)) & 0xFF;
   69.45 -   AF.B.B0 |= ZeroTable[tempValue];
   69.46 -   gbWriteMemory(HL.W,tempValue);
   69.47 -   break;
   69.48 - case 0x07:
   69.49 -   // RLC A
   69.50 -   AF.B.B0 = (AF.B.B1 & 0x80)?C_FLAG:0;
   69.51 -   AF.B.B1 = ((AF.B.B1<<1) | (AF.B.B1>>7)) & 0xFF;
   69.52 -   AF.B.B0 |= ZeroTable[AF.B.B1];
   69.53 -   break;
   69.54 - case 0x08:
   69.55 -   // RRC B
   69.56 -   AF.B.B0=(BC.B.B1&0x01 ? C_FLAG : 0);
   69.57 -   BC.B.B1=((BC.B.B1>>1)|(BC.B.B1<<7)) & 0xFF;
   69.58 -   AF.B.B0|=ZeroTable[BC.B.B1];
   69.59 -   break;
   69.60 - case 0x09:
   69.61 -   // RRC C
   69.62 -   AF.B.B0=(BC.B.B0&0x01 ? C_FLAG : 0);
   69.63 -   BC.B.B0=((BC.B.B0>>1)|(BC.B.B0<<7)) & 0xFF;
   69.64 -   AF.B.B0|=ZeroTable[BC.B.B0];
   69.65 -   break;
   69.66 - case 0x0a:
   69.67 -   // RRC D
   69.68 -   AF.B.B0=(DE.B.B1&0x01 ? C_FLAG : 0);
   69.69 -   DE.B.B1=((DE.B.B1>>1)|(DE.B.B1<<7)) & 0xFF;
   69.70 -   AF.B.B0|=ZeroTable[DE.B.B1];
   69.71 -   break;
   69.72 - case 0x0b:
   69.73 -   // RRC E
   69.74 -   AF.B.B0=(DE.B.B0&0x01 ? C_FLAG : 0);
   69.75 -   DE.B.B0=((DE.B.B0>>1)|(DE.B.B0<<7)) & 0xFF;
   69.76 -   AF.B.B0|=ZeroTable[DE.B.B0];
   69.77 -   break;
   69.78 - case 0x0c:
   69.79 -   // RRC H
   69.80 -   AF.B.B0=(HL.B.B1&0x01 ? C_FLAG : 0);
   69.81 -   HL.B.B1=((HL.B.B1>>1)|(HL.B.B1<<7)) & 0xFF;
   69.82 -   AF.B.B0|=ZeroTable[HL.B.B1];
   69.83 -   break;
   69.84 - case 0x0d:
   69.85 -   // RRC L
   69.86 -   AF.B.B0=(HL.B.B0&0x01 ? C_FLAG : 0);
   69.87 -   HL.B.B0=((HL.B.B0>>1)|(HL.B.B0<<7)) & 0xFF;
   69.88 -   AF.B.B0|=ZeroTable[HL.B.B0];
   69.89 -   break;
   69.90 - case 0x0e:
   69.91 -   // RRC (HL)
   69.92 -   tempValue=gbReadMemory(HL.W);
   69.93 -   AF.B.B0=(tempValue&0x01 ? C_FLAG : 0);
   69.94 -   tempValue=((tempValue>>1)|(tempValue<<7)) & 0xFF;
   69.95 -   AF.B.B0|=ZeroTable[tempValue];
   69.96 -   gbWriteMemory(HL.W,tempValue);
   69.97 -   break;
   69.98 - case 0x0f:
   69.99 -   // RRC A
  69.100 -   AF.B.B0=(AF.B.B1&0x01 ? C_FLAG : 0);
  69.101 -   AF.B.B1=((AF.B.B1>>1)|(AF.B.B1<<7)) & 0xFF;
  69.102 -   AF.B.B0|=ZeroTable[AF.B.B1];
  69.103 -   break;
  69.104 - case 0x10:
  69.105 -   // RL B
  69.106 -   if(BC.B.B1&0x80) {
  69.107 -     BC.B.B1=((BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.108 -     AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG;
  69.109 -   } else {
  69.110 -     BC.B.B1=((BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.111 -     AF.B.B0=ZeroTable[BC.B.B1];
  69.112 -   }
  69.113 -   break;
  69.114 - case 0x11:
  69.115 -   // RL C
  69.116 -   if(BC.B.B0&0x80) {
  69.117 -     BC.B.B0=((BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.118 -     AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG;
  69.119 -   } else {
  69.120 -     BC.B.B0=((BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.121 -     AF.B.B0=ZeroTable[BC.B.B0];
  69.122 -   }
  69.123 -   break;
  69.124 - case 0x12:
  69.125 -   // RL D
  69.126 -   if(DE.B.B1&0x80) {
  69.127 -     DE.B.B1=((DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.128 -     AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG;
  69.129 -   } else {
  69.130 -     DE.B.B1=((DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.131 -     AF.B.B0=ZeroTable[DE.B.B1];
  69.132 -   }
  69.133 -   break;
  69.134 - case 0x13:
  69.135 -   // RL E
  69.136 -   if(DE.B.B0&0x80) {
  69.137 -     DE.B.B0=((DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.138 -     AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG;
  69.139 -   } else {
  69.140 -     DE.B.B0=((DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.141 -     AF.B.B0=ZeroTable[DE.B.B0];
  69.142 -   }
  69.143 -   break;
  69.144 - case 0x14:
  69.145 -   // RL H
  69.146 -   if(HL.B.B1&0x80) {
  69.147 -     HL.B.B1=((HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.148 -     AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG;
  69.149 -   } else {
  69.150 -     HL.B.B1=((HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.151 -     AF.B.B0=ZeroTable[HL.B.B1];
  69.152 -   }
  69.153 -   break;
  69.154 - case 0x15:
  69.155 -   // RL L
  69.156 -   if(HL.B.B0&0x80) {
  69.157 -     HL.B.B0=((HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.158 -     AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG;
  69.159 -   } else {
  69.160 -     HL.B.B0=((HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.161 -     AF.B.B0=ZeroTable[HL.B.B0];
  69.162 -   }
  69.163 -   break;
  69.164 - case 0x16:
  69.165 -   // RL (HL)
  69.166 -   tempValue=gbReadMemory(HL.W);
  69.167 -   if(tempValue&0x80) {
  69.168 -     tempValue=((tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.169 -     AF.B.B0=ZeroTable[tempValue]|C_FLAG;
  69.170 -   } else {
  69.171 -     tempValue=((tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.172 -     AF.B.B0=ZeroTable[tempValue];
  69.173 -   }
  69.174 -   gbWriteMemory(HL.W,tempValue);
  69.175 -   break;
  69.176 - case 0x17:
  69.177 -   // RL A
  69.178 -   if(AF.B.B1&0x80) {
  69.179 -     AF.B.B1=((AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.180 -     AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG;
  69.181 -   } else {
  69.182 -     AF.B.B1=((AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
  69.183 -     AF.B.B0=ZeroTable[AF.B.B1];
  69.184 -   }
  69.185 -   break;
  69.186 - case 0x18:
  69.187 -   // RR B
  69.188 -   if(BC.B.B1&0x01) {
  69.189 -     BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.190 -     AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG;
  69.191 -   } else {
  69.192 -     BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.193 -     AF.B.B0=ZeroTable[BC.B.B1];
  69.194 -   }
  69.195 -   break;
  69.196 - case 0x19:
  69.197 -   // RR C
  69.198 -   if(BC.B.B0&0x01) {
  69.199 -     BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.200 -     AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG;
  69.201 -   } else {
  69.202 -     BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.203 -     AF.B.B0=ZeroTable[BC.B.B0];
  69.204 -   }
  69.205 -   break;
  69.206 - case 0x1a:
  69.207 -   // RR D
  69.208 -   if(DE.B.B1&0x01) {
  69.209 -     DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.210 -     AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG;
  69.211 -   } else {
  69.212 -     DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.213 -     AF.B.B0=ZeroTable[DE.B.B1];
  69.214 -   }
  69.215 -   break;
  69.216 - case 0x1b:
  69.217 -   // RR E
  69.218 -   if(DE.B.B0&0x01) {
  69.219 -     DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.220 -     AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG;
  69.221 -   } else {
  69.222 -     DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.223 -     AF.B.B0=ZeroTable[DE.B.B0];
  69.224 -   }
  69.225 -   break;
  69.226 - case 0x1c:
  69.227 -   // RR H
  69.228 -   if(HL.B.B1&0x01) {
  69.229 -     HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.230 -     AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG;
  69.231 -   } else {
  69.232 -     HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.233 -     AF.B.B0=ZeroTable[HL.B.B1];
  69.234 -   }
  69.235 -   break;
  69.236 - case 0x1d:
  69.237 -   // RR L
  69.238 -   if(HL.B.B0&0x01) {
  69.239 -     HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.240 -     AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG;
  69.241 -   } else {
  69.242 -     HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.243 -     AF.B.B0=ZeroTable[HL.B.B0];
  69.244 -   }
  69.245 -   break;
  69.246 - case 0x1e:
  69.247 -   // RR (HL)
  69.248 -   tempValue=gbReadMemory(HL.W);
  69.249 -   if(tempValue&0x01) {
  69.250 -     tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.251 -     AF.B.B0=ZeroTable[tempValue]|C_FLAG;
  69.252 -   } else {
  69.253 -     tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.254 -     AF.B.B0=ZeroTable[tempValue];
  69.255 -   }
  69.256 -   gbWriteMemory(HL.W,tempValue);
  69.257 -   break;
  69.258 - case 0x1f:
  69.259 -   // RR A
  69.260 -   if(AF.B.B1&0x01) {
  69.261 -     AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.262 -     AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG;
  69.263 -   } else {
  69.264 -     AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
  69.265 -     AF.B.B0=ZeroTable[AF.B.B1];
  69.266 -   }
  69.267 -   break;
  69.268 - case 0x20:
  69.269 -   // SLA B
  69.270 -   AF.B.B0=(BC.B.B1&0x80?C_FLAG : 0);
  69.271 -   BC.B.B1<<=1;
  69.272 -   AF.B.B0|=ZeroTable[BC.B.B1];
  69.273 -   break;
  69.274 - case 0x21:
  69.275 -   // SLA C
  69.276 -   AF.B.B0=(BC.B.B0&0x80?C_FLAG : 0);
  69.277 -   BC.B.B0<<=1;
  69.278 -   AF.B.B0|=ZeroTable[BC.B.B0];
  69.279 -   break;
  69.280 - case 0x22:
  69.281 -   // SLA D
  69.282 -   AF.B.B0=(DE.B.B1&0x80?C_FLAG : 0);
  69.283 -   DE.B.B1<<=1;
  69.284 -   AF.B.B0|=ZeroTable[DE.B.B1];
  69.285 -   break;
  69.286 - case 0x23:
  69.287 -   // SLA E
  69.288 -   AF.B.B0=(DE.B.B0&0x80?C_FLAG : 0);
  69.289 -   DE.B.B0<<=1;
  69.290 -   AF.B.B0|=ZeroTable[DE.B.B0];
  69.291 -   break;
  69.292 - case 0x24:
  69.293 -   // SLA H
  69.294 -   AF.B.B0=(HL.B.B1&0x80?C_FLAG : 0);
  69.295 -   HL.B.B1<<=1;
  69.296 -   AF.B.B0|=ZeroTable[HL.B.B1];
  69.297 -   break;
  69.298 - case 0x25:
  69.299 -   // SLA L
  69.300 -   AF.B.B0=(HL.B.B0&0x80?C_FLAG : 0);
  69.301 -   HL.B.B0<<=1;
  69.302 -   AF.B.B0|=ZeroTable[HL.B.B0];
  69.303 -   break;
  69.304 - case 0x26:
  69.305 -   // SLA (HL)
  69.306 -   tempValue=gbReadMemory(HL.W);
  69.307 -   AF.B.B0=(tempValue&0x80?C_FLAG : 0);
  69.308 -   tempValue<<=1;
  69.309 -   AF.B.B0|=ZeroTable[tempValue];
  69.310 -   gbWriteMemory(HL.W,tempValue);
  69.311 -   break;
  69.312 - case 0x27:
  69.313 -   // SLA A
  69.314 -   AF.B.B0=(AF.B.B1&0x80?C_FLAG : 0);
  69.315 -   AF.B.B1<<=1;
  69.316 -   AF.B.B0|=ZeroTable[AF.B.B1];
  69.317 -   break;
  69.318 - case 0x28:
  69.319 -   // SRA B
  69.320 -   AF.B.B0=(BC.B.B1&0x01 ? C_FLAG: 0);
  69.321 -   BC.B.B1=(BC.B.B1>>1)|(BC.B.B1&0x80);
  69.322 -   AF.B.B0|=ZeroTable[BC.B.B1];
  69.323 -   break;
  69.324 - case 0x29:
  69.325 -   // SRA C
  69.326 -   AF.B.B0=(BC.B.B0&0x01 ? C_FLAG: 0);
  69.327 -   BC.B.B0=(BC.B.B0>>1)|(BC.B.B0&0x80);
  69.328 -   AF.B.B0|=ZeroTable[BC.B.B0];
  69.329 -   break;
  69.330 - case 0x2a:
  69.331 -   // SRA D
  69.332 -   AF.B.B0=(DE.B.B1&0x01 ? C_FLAG: 0);
  69.333 -   DE.B.B1=(DE.B.B1>>1)|(DE.B.B1&0x80);
  69.334 -   AF.B.B0|=ZeroTable[DE.B.B1];
  69.335 -   break;
  69.336 - case 0x2b:
  69.337 -   // SRA E
  69.338 -   AF.B.B0=(DE.B.B0&0x01 ? C_FLAG: 0);
  69.339 -   DE.B.B0=(DE.B.B0>>1)|(DE.B.B0&0x80);
  69.340 -   AF.B.B0|=ZeroTable[DE.B.B0];
  69.341 -   break;
  69.342 - case 0x2c:
  69.343 -   // SRA H
  69.344 -   AF.B.B0=(HL.B.B1&0x01 ? C_FLAG: 0);
  69.345 -   HL.B.B1=(HL.B.B1>>1)|(HL.B.B1&0x80);
  69.346 -   AF.B.B0|=ZeroTable[HL.B.B1];
  69.347 -   break;
  69.348 - case 0x2d:
  69.349 -   // SRA L
  69.350 -   AF.B.B0=(HL.B.B0&0x01 ? C_FLAG: 0);
  69.351 -   HL.B.B0=(HL.B.B0>>1)|(HL.B.B0&0x80);
  69.352 -   AF.B.B0|=ZeroTable[HL.B.B0];
  69.353 -   break;
  69.354 - case 0x2e:
  69.355 -   // SRA (HL)
  69.356 -   tempValue=gbReadMemory(HL.W);
  69.357 -   AF.B.B0=(tempValue&0x01 ? C_FLAG: 0);
  69.358 -   tempValue=(tempValue>>1)|(tempValue&0x80);
  69.359 -   AF.B.B0|=ZeroTable[tempValue];
  69.360 -   gbWriteMemory(HL.W,tempValue);
  69.361 -   break;
  69.362 - case 0x2f:
  69.363 -   // SRA A
  69.364 -   AF.B.B0=(AF.B.B1&0x01 ? C_FLAG: 0);
  69.365 -   AF.B.B1=(AF.B.B1>>1)|(AF.B.B1&0x80);
  69.366 -   AF.B.B0|=ZeroTable[AF.B.B1];
  69.367 -   break;
  69.368 - case 0x30:
  69.369 -   // SWAP B
  69.370 -   BC.B.B1 = (BC.B.B1&0xf0)>>4 | (BC.B.B1&0x0f)<<4;
  69.371 -   AF.B.B0 = ZeroTable[BC.B.B1];
  69.372 -   break;
  69.373 - case 0x31:
  69.374 -   // SWAP C
  69.375 -   BC.B.B0 = (BC.B.B0&0xf0)>>4 | (BC.B.B0&0x0f)<<4;
  69.376 -   AF.B.B0 = ZeroTable[BC.B.B0];
  69.377 -   break;
  69.378 - case 0x32:
  69.379 -  // SWAP D
  69.380 -  DE.B.B1 = (DE.B.B1&0xf0)>>4 | (DE.B.B1&0x0f)<<4;
  69.381 -  AF.B.B0 = ZeroTable[DE.B.B1];
  69.382 -  break;
  69.383 - case 0x33:
  69.384 -   // SWAP E
  69.385 -   DE.B.B0 = (DE.B.B0&0xf0)>>4 | (DE.B.B0&0x0f)<<4;
  69.386 -   AF.B.B0 = ZeroTable[DE.B.B0];
  69.387 -   break;
  69.388 - case 0x34:
  69.389 -   // SWAP H
  69.390 -   HL.B.B1 = (HL.B.B1&0xf0)>>4 | (HL.B.B1&0x0f)<<4;
  69.391 -   AF.B.B0 = ZeroTable[HL.B.B1];
  69.392 -   break;
  69.393 - case 0x35:
  69.394 -   // SWAP L
  69.395 -   HL.B.B0 = (HL.B.B0&0xf0)>>4 | (HL.B.B0&0x0f)<<4;
  69.396 -   AF.B.B0 = ZeroTable[HL.B.B0];
  69.397 -   break;
  69.398 - case 0x36:
  69.399 -   // SWAP (HL)
  69.400 -   tempValue=gbReadMemory(HL.W);
  69.401 -   tempValue = (tempValue&0xf0)>>4 | (tempValue&0x0f)<<4;
  69.402 -   AF.B.B0 = ZeroTable[tempValue];
  69.403 -   gbWriteMemory(HL.W,tempValue);
  69.404 -   break;
  69.405 - case 0x37:
  69.406 -   // SWAP A
  69.407 -   AF.B.B1 = (AF.B.B1&0xf0)>>4 | (AF.B.B1&0x0f)<<4;
  69.408 -   AF.B.B0 = ZeroTable[AF.B.B1];
  69.409 -   break;
  69.410 - case 0x38:
  69.411 -   // SRL B
  69.412 -   AF.B.B0=(BC.B.B1&0x01)?C_FLAG:0;
  69.413 -   BC.B.B1>>=1;
  69.414 -   AF.B.B0|=ZeroTable[BC.B.B1];
  69.415 -   break;
  69.416 - case 0x39:
  69.417 -   // SRL C
  69.418 -   AF.B.B0=(BC.B.B0&0x01)?C_FLAG:0;
  69.419 -   BC.B.B0>>=1;
  69.420 -   AF.B.B0|=ZeroTable[BC.B.B0];
  69.421 -   break;
  69.422 - case 0x3a:
  69.423 -   // SRL D
  69.424 -   AF.B.B0=(DE.B.B1&0x01)?C_FLAG:0;
  69.425 -   DE.B.B1>>=1;
  69.426 -   AF.B.B0|=ZeroTable[DE.B.B1];
  69.427 -   break;
  69.428 - case 0x3b:
  69.429 -   // SRL E
  69.430 -   AF.B.B0=(DE.B.B0&0x01)?C_FLAG:0;
  69.431 -   DE.B.B0>>=1;
  69.432 -   AF.B.B0|=ZeroTable[DE.B.B0];
  69.433 -   break;
  69.434 - case 0x3c:
  69.435 -   // SRL H
  69.436 -   AF.B.B0=(HL.B.B1&0x01)?C_FLAG:0;
  69.437 -   HL.B.B1>>=1;
  69.438 -   AF.B.B0|=ZeroTable[HL.B.B1];
  69.439 -   break;
  69.440 - case 0x3d:
  69.441 -   // SRL L
  69.442 -   AF.B.B0=(HL.B.B0&0x01)?C_FLAG:0;
  69.443 -   HL.B.B0>>=1;
  69.444 -   AF.B.B0|=ZeroTable[HL.B.B0];
  69.445 -   break;
  69.446 - case 0x3e:
  69.447 -   // SRL (HL)
  69.448 -   tempValue=gbReadMemory(HL.W);
  69.449 -   AF.B.B0=(tempValue&0x01)?C_FLAG:0;
  69.450 -   tempValue>>=1;
  69.451 -   AF.B.B0|=ZeroTable[tempValue];
  69.452 -   gbWriteMemory(HL.W,tempValue);
  69.453 -   break;
  69.454 - case 0x3f:
  69.455 -   // SRL A
  69.456 -   AF.B.B0=(AF.B.B1&0x01)?C_FLAG:0;
  69.457 -   AF.B.B1>>=1;
  69.458 -   AF.B.B0|=ZeroTable[AF.B.B1];
  69.459 -   break;
  69.460 - case 0x40:
  69.461 -   // BIT 0,B
  69.462 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<0)? 0:Z_FLAG);
  69.463 -   break;
  69.464 - case 0x41:
  69.465 -   // BIT 0,C
  69.466 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<0)? 0:Z_FLAG);
  69.467 -   break;
  69.468 - case 0x42:
  69.469 -   // BIT 0,D
  69.470 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<0)? 0:Z_FLAG);
  69.471 -   break;
  69.472 - case 0x43:
  69.473 -   // BIT 0,E
  69.474 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<0)? 0:Z_FLAG);
  69.475 -   break;
  69.476 - case 0x44:
  69.477 -   // BIT 0,H
  69.478 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<0)? 0:Z_FLAG);
  69.479 -   break;
  69.480 - case 0x45:
  69.481 -   // BIT 0,L
  69.482 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<0)? 0:Z_FLAG);
  69.483 -   break;
  69.484 - case 0x46:
  69.485 -   // BIT 0,(HL)
  69.486 -   tempValue=gbReadMemory(HL.W);
  69.487 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<0)? 0:Z_FLAG);
  69.488 -   break;
  69.489 - case 0x47:
  69.490 -   // BIT 0,A
  69.491 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<0)? 0:Z_FLAG);
  69.492 -   break;
  69.493 - case 0x48:
  69.494 -   // BIT 1,B
  69.495 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<1)? 0:Z_FLAG);
  69.496 -   break;
  69.497 - case 0x49:
  69.498 -   // BIT 1,C
  69.499 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<1)? 0:Z_FLAG);
  69.500 -   break;
  69.501 - case 0x4a:
  69.502 -   // BIT 1,D
  69.503 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<1)? 0:Z_FLAG);
  69.504 -   break;
  69.505 - case 0x4b:
  69.506 -   // BIT 1,E
  69.507 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<1)? 0:Z_FLAG);
  69.508 -   break;
  69.509 - case 0x4c:
  69.510 -   // BIT 1,H
  69.511 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<1)? 0:Z_FLAG);
  69.512 -   break;
  69.513 - case 0x4d:
  69.514 -   // BIT 1,L
  69.515 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<1)? 0:Z_FLAG);
  69.516 -   break;
  69.517 - case 0x4e:
  69.518 -   // BIT 1,(HL)
  69.519 -   tempValue=gbReadMemory(HL.W);
  69.520 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<1)? 0:Z_FLAG);
  69.521 -   break;
  69.522 - case 0x4f:
  69.523 -   // BIT 1,A
  69.524 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<1)? 0:Z_FLAG);
  69.525 -   break;
  69.526 - case 0x50:
  69.527 -   // BIT 2,B
  69.528 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<2)? 0:Z_FLAG);
  69.529 -   break;
  69.530 - case 0x51:
  69.531 -   // BIT 2,C
  69.532 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<2)? 0:Z_FLAG);
  69.533 -   break;
  69.534 - case 0x52:
  69.535 -   // BIT 2,D
  69.536 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<2)? 0:Z_FLAG);
  69.537 -   break;
  69.538 - case 0x53:
  69.539 -   // BIT 2,E
  69.540 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<2)? 0:Z_FLAG);
  69.541 -   break;
  69.542 - case 0x54:
  69.543 -   // BIT 2,H
  69.544 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<2)? 0:Z_FLAG);
  69.545 -   break;
  69.546 - case 0x55:
  69.547 -   // BIT 2,L
  69.548 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<2)? 0:Z_FLAG);
  69.549 -   break;
  69.550 - case 0x56:
  69.551 -   // BIT 2,(HL)
  69.552 -   tempValue=gbReadMemory(HL.W);
  69.553 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<2)? 0:Z_FLAG);
  69.554 -   break;
  69.555 - case 0x57:
  69.556 -   // BIT 2,A
  69.557 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<2)? 0:Z_FLAG);
  69.558 -   break;
  69.559 - case 0x58:
  69.560 -   // BIT 3,B
  69.561 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<3)? 0:Z_FLAG);
  69.562 -   break;
  69.563 - case 0x59:
  69.564 -   // BIT 3,C
  69.565 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<3)? 0:Z_FLAG);
  69.566 -   break;
  69.567 - case 0x5a:
  69.568 -   // BIT 3,D
  69.569 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<3)? 0:Z_FLAG);
  69.570 -   break;
  69.571 - case 0x5b:
  69.572 -   // BIT 3,E
  69.573 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<3)? 0:Z_FLAG);
  69.574 -   break;
  69.575 - case 0x5c:
  69.576 -   // BIT 3,H
  69.577 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<3)? 0:Z_FLAG);
  69.578 -   break;
  69.579 - case 0x5d:
  69.580 -   // BIT 3,L
  69.581 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<3)? 0:Z_FLAG);
  69.582 -   break;
  69.583 - case 0x5e:
  69.584 -   // BIT 3,(HL)
  69.585 -   tempValue=gbReadMemory(HL.W);
  69.586 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<3)? 0:Z_FLAG);
  69.587 -   break;
  69.588 - case 0x5f:
  69.589 -   // BIT 3,A
  69.590 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<3)? 0:Z_FLAG);
  69.591 -   break;
  69.592 - case 0x60:
  69.593 -   // BIT 4,B
  69.594 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<4)? 0:Z_FLAG);
  69.595 -   break;
  69.596 - case 0x61:
  69.597 -   // BIT 4,C
  69.598 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<4)? 0:Z_FLAG);
  69.599 -   break;
  69.600 - case 0x62:
  69.601 -   // BIT 4,D
  69.602 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<4)? 0:Z_FLAG);
  69.603 -   break;
  69.604 - case 0x63:
  69.605 -   // BIT 4,E
  69.606 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<4)? 0:Z_FLAG);
  69.607 -   break;
  69.608 - case 0x64:
  69.609 -   // BIT 4,H
  69.610 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<4)? 0:Z_FLAG);
  69.611 -   break;
  69.612 - case 0x65:
  69.613 -   // BIT 4,L
  69.614 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<4)? 0:Z_FLAG);
  69.615 -   break;
  69.616 - case 0x66:
  69.617 -   // BIT 4,(HL)
  69.618 -   tempValue=gbReadMemory(HL.W);
  69.619 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<4)? 0:Z_FLAG);
  69.620 -   break;
  69.621 - case 0x67:
  69.622 -   // BIT 4,A
  69.623 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<4)? 0:Z_FLAG);
  69.624 -   break;
  69.625 - case 0x68:
  69.626 -   // BIT 5,B
  69.627 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<5)? 0:Z_FLAG);
  69.628 -   break;
  69.629 - case 0x69:
  69.630 -   // BIT 5,C
  69.631 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<5)? 0:Z_FLAG);
  69.632 -   break;
  69.633 - case 0x6a:
  69.634 -   // BIT 5,D
  69.635 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<5)? 0:Z_FLAG);
  69.636 -   break;
  69.637 - case 0x6b:
  69.638 -   // BIT 5,E
  69.639 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<5)? 0:Z_FLAG);
  69.640 -   break;
  69.641 - case 0x6c:
  69.642 -   // BIT 5,H
  69.643 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<5)? 0:Z_FLAG);
  69.644 -   break;
  69.645 - case 0x6d:
  69.646 -   // BIT 5,L
  69.647 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<5)? 0:Z_FLAG);
  69.648 -   break;
  69.649 - case 0x6e:
  69.650 -   // BIT 5,(HL)
  69.651 -   tempValue=gbReadMemory(HL.W);
  69.652 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<5)? 0:Z_FLAG);
  69.653 -   break;
  69.654 - case 0x6f:
  69.655 -   // BIT 5,A
  69.656 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<5)? 0:Z_FLAG);
  69.657 -   break;
  69.658 - case 0x70:
  69.659 -   // BIT 6,B
  69.660 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<6)? 0:Z_FLAG);
  69.661 -   break;
  69.662 - case 0x71:
  69.663 -   // BIT 6,C
  69.664 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<6)? 0:Z_FLAG);
  69.665 -   break;
  69.666 - case 0x72:
  69.667 -   // BIT 6,D
  69.668 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<6)? 0:Z_FLAG);
  69.669 -   break;
  69.670 - case 0x73:
  69.671 -   // BIT 6,E
  69.672 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<6)? 0:Z_FLAG);
  69.673 -   break;
  69.674 - case 0x74:
  69.675 -   // BIT 6,H
  69.676 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<6)? 0:Z_FLAG);
  69.677 -   break;
  69.678 - case 0x75:
  69.679 -   // BIT 6,L
  69.680 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<6)? 0:Z_FLAG);
  69.681 -   break;
  69.682 - case 0x76:
  69.683 -   // BIT 6,(HL)
  69.684 -   tempValue=gbReadMemory(HL.W);
  69.685 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<6)? 0:Z_FLAG);
  69.686 -   break;
  69.687 - case 0x77:
  69.688 -   // BIT 6,A
  69.689 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<6)? 0:Z_FLAG);
  69.690 -   break;
  69.691 - case 0x78:
  69.692 -   // BIT 7,B
  69.693 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<7)? 0:Z_FLAG);
  69.694 -   break;
  69.695 - case 0x79:
  69.696 -   // BIT 7,C
  69.697 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<7)? 0:Z_FLAG);
  69.698 -   break;
  69.699 - case 0x7a:
  69.700 -   // BIT 7,D
  69.701 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<7)? 0:Z_FLAG);
  69.702 -   break;
  69.703 - case 0x7b:
  69.704 -   // BIT 7,E
  69.705 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<7)? 0:Z_FLAG);
  69.706 -   break;
  69.707 - case 0x7c:
  69.708 -   // BIT 7,H
  69.709 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<7)? 0:Z_FLAG);
  69.710 -   break;
  69.711 - case 0x7d:
  69.712 -   // BIT 7,L
  69.713 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<7)? 0:Z_FLAG);
  69.714 -   break;
  69.715 - case 0x7e:
  69.716 -   // BIT 7,(HL)
  69.717 -   tempValue=gbReadMemory(HL.W);
  69.718 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<7)? 0:Z_FLAG);
  69.719 -   break;
  69.720 - case 0x7f:
  69.721 -   // BIT 7,A
  69.722 -   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<7)? 0:Z_FLAG);
  69.723 -   break;
  69.724 - case 0x80:
  69.725 -   // RES 0,B
  69.726 -   BC.B.B1&=~(1<<0);
  69.727 -   break;
  69.728 - case 0x81:
  69.729 -   // RES 0,C
  69.730 -   BC.B.B0&=~(1<<0);
  69.731 -   break;
  69.732 - case 0x82:
  69.733 -   // RES 0,D
  69.734 -   DE.B.B1&=~(1<<0);
  69.735 -   break;
  69.736 - case 0x83:
  69.737 -   // RES 0,E
  69.738 -   DE.B.B0&=~(1<<0);
  69.739 -   break;
  69.740 - case 0x84:
  69.741 -   // RES 0,H
  69.742 -   HL.B.B1&=~(1<<0);
  69.743 -   break;
  69.744 - case 0x85:
  69.745 -   // RES 0,L
  69.746 -   HL.B.B0&=~(1<<0);
  69.747 -   break;
  69.748 - case 0x86:
  69.749 -   // RES 0,(HL)
  69.750 -   tempValue=gbReadMemory(HL.W);
  69.751 -   tempValue&=~(1<<0);
  69.752 -   gbWriteMemory(HL.W,tempValue);
  69.753 -   break;
  69.754 - case 0x87:
  69.755 -   // RES 0,A
  69.756 -   AF.B.B1&=~(1<<0);
  69.757 -   break;
  69.758 - case 0x88:
  69.759 -   // RES 1,B
  69.760 -   BC.B.B1&=~(1<<1);
  69.761 -   break;
  69.762 - case 0x89:
  69.763 -   // RES 1,C
  69.764 -   BC.B.B0&=~(1<<1);
  69.765 -   break;
  69.766 - case 0x8a:
  69.767 -   // RES 1,D
  69.768 -   DE.B.B1&=~(1<<1);
  69.769 -   break;
  69.770 - case 0x8b:
  69.771 -   // RES 1,E
  69.772 -   DE.B.B0&=~(1<<1);
  69.773 -   break;
  69.774 - case 0x8c:
  69.775 -   // RES 1,H
  69.776 -   HL.B.B1&=~(1<<1);
  69.777 -   break;
  69.778 - case 0x8d:
  69.779 -   // RES 1,L
  69.780 -   HL.B.B0&=~(1<<1);
  69.781 -   break;
  69.782 - case 0x8e:
  69.783 -   // RES 1,(HL)
  69.784 -   tempValue=gbReadMemory(HL.W);
  69.785 -   tempValue&=~(1<<1);
  69.786 -   gbWriteMemory(HL.W,tempValue);
  69.787 -   break;
  69.788 - case 0x8f:
  69.789 -   // RES 1,A
  69.790 -   AF.B.B1&=~(1<<1);
  69.791 -   break;
  69.792 - case 0x90:
  69.793 -   // RES 2,B
  69.794 -   BC.B.B1&=~(1<<2);
  69.795 -   break;
  69.796 - case 0x91:
  69.797 -   // RES 2,C
  69.798 -   BC.B.B0&=~(1<<2);
  69.799 -   break;
  69.800 - case 0x92:
  69.801 -   // RES 2,D
  69.802 -   DE.B.B1&=~(1<<2);
  69.803 -   break;
  69.804 - case 0x93:
  69.805 -   // RES 2,E
  69.806 -   DE.B.B0&=~(1<<2);
  69.807 -   break;
  69.808 - case 0x94:
  69.809 -   // RES 2,H
  69.810 -   HL.B.B1&=~(1<<2);
  69.811 -   break;
  69.812 - case 0x95:
  69.813 -   // RES 2,L
  69.814 -   HL.B.B0&=~(1<<2);
  69.815 -   break;
  69.816 - case 0x96:
  69.817 -   // RES 2,(HL)
  69.818 -   tempValue=gbReadMemory(HL.W);
  69.819 -   tempValue&=~(1<<2);
  69.820 -   gbWriteMemory(HL.W,tempValue);
  69.821 -   break;
  69.822 - case 0x97:
  69.823 -   // RES 2,A
  69.824 -   AF.B.B1&=~(1<<2);
  69.825 -   break;
  69.826 - case 0x98:
  69.827 -   // RES 3,B
  69.828 -   BC.B.B1&=~(1<<3);
  69.829 -   break;
  69.830 - case 0x99:
  69.831 -   // RES 3,C
  69.832 -   BC.B.B0&=~(1<<3);
  69.833 -   break;
  69.834 - case 0x9a:
  69.835 -   // RES 3,D
  69.836 -   DE.B.B1&=~(1<<3);
  69.837 -   break;
  69.838 - case 0x9b:
  69.839 -   // RES 3,E
  69.840 -   DE.B.B0&=~(1<<3);
  69.841 -   break;
  69.842 - case 0x9c:
  69.843 -   // RES 3,H
  69.844 -   HL.B.B1&=~(1<<3);
  69.845 -   break;
  69.846 - case 0x9d:
  69.847 -   // RES 3,L
  69.848 -   HL.B.B0&=~(1<<3);
  69.849 -   break;
  69.850 - case 0x9e:
  69.851 -   // RES 3,(HL)
  69.852 -   tempValue=gbReadMemory(HL.W);
  69.853 -   tempValue&=~(1<<3);
  69.854 -   gbWriteMemory(HL.W,tempValue);
  69.855 -   break;
  69.856 - case 0x9f:
  69.857 -   // RES 3,A
  69.858 -   AF.B.B1&=~(1<<3);
  69.859 -   break;
  69.860 - case 0xa0:
  69.861 -   // RES 4,B
  69.862 -   BC.B.B1&=~(1<<4);
  69.863 -   break;
  69.864 - case 0xa1:
  69.865 -   // RES 4,C
  69.866 -   BC.B.B0&=~(1<<4);
  69.867 -   break;
  69.868 - case 0xa2:
  69.869 -   // RES 4,D
  69.870 -   DE.B.B1&=~(1<<4);
  69.871 -   break;
  69.872 - case 0xa3:
  69.873 -   // RES 4,E
  69.874 -   DE.B.B0&=~(1<<4);
  69.875 -   break;
  69.876 - case 0xa4:
  69.877 -   // RES 4,H
  69.878 -   HL.B.B1&=~(1<<4);
  69.879 -   break;
  69.880 - case 0xa5:
  69.881 -   // RES 4,L
  69.882 -   HL.B.B0&=~(1<<4);
  69.883 -   break;
  69.884 - case 0xa6:
  69.885 -   // RES 4,(HL)
  69.886 -   tempValue=gbReadMemory(HL.W);
  69.887 -   tempValue&=~(1<<4);
  69.888 -   gbWriteMemory(HL.W,tempValue);
  69.889 -   break;
  69.890 - case 0xa7:
  69.891 -   // RES 4,A
  69.892 -   AF.B.B1&=~(1<<4);
  69.893 -   break;
  69.894 - case 0xa8:
  69.895 -   // RES 5,B
  69.896 -   BC.B.B1&=~(1<<5);
  69.897 -   break;
  69.898 - case 0xa9:
  69.899 -   // RES 5,C
  69.900 -   BC.B.B0&=~(1<<5);
  69.901 -   break;
  69.902 - case 0xaa:
  69.903 -   // RES 5,D
  69.904 -   DE.B.B1&=~(1<<5);
  69.905 -   break;
  69.906 - case 0xab:
  69.907 -   // RES 5,E
  69.908 -   DE.B.B0&=~(1<<5);
  69.909 -   break;
  69.910 - case 0xac:
  69.911 -   // RES 5,H
  69.912 -   HL.B.B1&=~(1<<5);
  69.913 -   break;
  69.914 - case 0xad:
  69.915 -   // RES 5,L
  69.916 -   HL.B.B0&=~(1<<5);
  69.917 -   break;
  69.918 - case 0xae:
  69.919 -   // RES 5,(HL)
  69.920 -   tempValue=gbReadMemory(HL.W);
  69.921 -   tempValue&=~(1<<5);
  69.922 -   gbWriteMemory(HL.W,tempValue);
  69.923 -   break;
  69.924 - case 0xaf:
  69.925 -   // RES 5,A
  69.926 -   AF.B.B1&=~(1<<5);
  69.927 -   break;
  69.928 - case 0xb0:
  69.929 -   // RES 6,B
  69.930 -   BC.B.B1&=~(1<<6);
  69.931 -   break;
  69.932 - case 0xb1:
  69.933 -   // RES 6,C
  69.934 -   BC.B.B0&=~(1<<6);
  69.935 -   break;
  69.936 - case 0xb2:
  69.937 -   // RES 6,D
  69.938 -   DE.B.B1&=~(1<<6);
  69.939 -   break;
  69.940 - case 0xb3:
  69.941 -   // RES 6,E
  69.942 -   DE.B.B0&=~(1<<6);
  69.943 -   break;
  69.944 - case 0xb4:
  69.945 -   // RES 6,H
  69.946 -   HL.B.B1&=~(1<<6);
  69.947 -   break;
  69.948 - case 0xb5:
  69.949 -   // RES 6,L
  69.950 -   HL.B.B0&=~(1<<6);
  69.951 -   break;
  69.952 - case 0xb6:
  69.953 -   // RES 6,(HL)
  69.954 -   tempValue=gbReadMemory(HL.W);
  69.955 -   tempValue&=~(1<<6);
  69.956 -   gbWriteMemory(HL.W,tempValue);
  69.957 -   break;
  69.958 - case 0xb7:
  69.959 -   // RES 6,A
  69.960 -   AF.B.B1&=~(1<<6);
  69.961 -   break;
  69.962 - case 0xb8:
  69.963 -   // RES 7,B
  69.964 -   BC.B.B1&=~(1<<7);
  69.965 -   break;
  69.966 - case 0xb9:
  69.967 -   // RES 7,C
  69.968 -   BC.B.B0&=~(1<<7);
  69.969 -   break;
  69.970 - case 0xba:
  69.971 -   // RES 7,D
  69.972 -   DE.B.B1&=~(1<<7);
  69.973 -   break;
  69.974 - case 0xbb:
  69.975 -   // RES 7,E
  69.976 -   DE.B.B0&=~(1<<7);
  69.977 -   break;
  69.978 - case 0xbc:
  69.979 -   // RES 7,H
  69.980 -   HL.B.B1&=~(1<<7);
  69.981 -   break;
  69.982 - case 0xbd:
  69.983 -   // RES 7,L
  69.984 -   HL.B.B0&=~(1<<7);
  69.985 -   break;
  69.986 - case 0xbe:
  69.987 -   // RES 7,(HL)
  69.988 -   tempValue=gbReadMemory(HL.W);
  69.989 -   tempValue&=~(1<<7);
  69.990 -   gbWriteMemory(HL.W,tempValue);
  69.991 -   break;
  69.992 - case 0xbf:
  69.993 -   // RES 7,A
  69.994 -   AF.B.B1&=~(1<<7);
  69.995 -   break;
  69.996 - case 0xc0:
  69.997 -   // SET 0,B
  69.998 -   BC.B.B1|=1<<0;
  69.999 -   break;
 69.1000 - case 0xc1:
 69.1001 -   // SET 0,C
 69.1002 -   BC.B.B0|=1<<0;
 69.1003 -   break;
 69.1004 - case 0xc2:
 69.1005 -   // SET 0,D
 69.1006 -   DE.B.B1|=1<<0;
 69.1007 -   break;
 69.1008 - case 0xc3:
 69.1009 -   // SET 0,E
 69.1010 -   DE.B.B0|=1<<0;
 69.1011 -   break;
 69.1012 - case 0xc4:
 69.1013 -   // SET 0,H
 69.1014 -   HL.B.B1|=1<<0;
 69.1015 -   break;
 69.1016 - case 0xc5:
 69.1017 -   // SET 0,L
 69.1018 -   HL.B.B0|=1<<0;
 69.1019 -   break;
 69.1020 - case 0xc6:
 69.1021 -   // SET 0,(HL)
 69.1022 -   tempValue=gbReadMemory(HL.W);
 69.1023 -   tempValue|=1<<0;
 69.1024 -   gbWriteMemory(HL.W,tempValue);
 69.1025 -   break;
 69.1026 - case 0xc7:
 69.1027 -   // SET 0,A
 69.1028 -   AF.B.B1|=1<<0;
 69.1029 -   break;
 69.1030 - case 0xc8:
 69.1031 -   // SET 1,B
 69.1032 -   BC.B.B1|=1<<1;
 69.1033 -   break;
 69.1034 - case 0xc9:
 69.1035 -   // SET 1,C
 69.1036 -   BC.B.B0|=1<<1;
 69.1037 -   break;
 69.1038 - case 0xca:
 69.1039 -   // SET 1,D
 69.1040 -   DE.B.B1|=1<<1;
 69.1041 -   break;
 69.1042 - case 0xcb:
 69.1043 -   // SET 1,E
 69.1044 -   DE.B.B0|=1<<1;
 69.1045 -   break;
 69.1046 - case 0xcc:
 69.1047 -   // SET 1,H
 69.1048 -   HL.B.B1|=1<<1;
 69.1049 -   break;
 69.1050 - case 0xcd:
 69.1051 -   // SET 1,L
 69.1052 -   HL.B.B0|=1<<1;
 69.1053 -   break;
 69.1054 - case 0xce:
 69.1055 -   // SET 1,(HL)
 69.1056 -   tempValue=gbReadMemory(HL.W);
 69.1057 -   tempValue|=1<<1;
 69.1058 -   gbWriteMemory(HL.W,tempValue);
 69.1059 -   break;
 69.1060 - case 0xcf:
 69.1061 -   // SET 1,A
 69.1062 -   AF.B.B1|=1<<1;
 69.1063 -   break;
 69.1064 - case 0xd0:
 69.1065 -   // SET 2,B
 69.1066 -   BC.B.B1|=1<<2;
 69.1067 -   break;
 69.1068 - case 0xd1:
 69.1069 -   // SET 2,C
 69.1070 -   BC.B.B0|=1<<2;
 69.1071 -   break;
 69.1072 - case 0xd2:
 69.1073 -   // SET 2,D
 69.1074 -   DE.B.B1|=1<<2;
 69.1075 -   break;
 69.1076 - case 0xd3:
 69.1077 -   // SET 2,E
 69.1078 -   DE.B.B0|=1<<2;
 69.1079 -   break;
 69.1080 - case 0xd4:
 69.1081 -   // SET 2,H
 69.1082 -   HL.B.B1|=1<<2;
 69.1083 -   break;
 69.1084 - case 0xd5:
 69.1085 -   // SET 2,L
 69.1086 -   HL.B.B0|=1<<2;
 69.1087 -   break;
 69.1088 - case 0xd6:
 69.1089 -   // SET 2,(HL)
 69.1090 -   tempValue=gbReadMemory(HL.W);
 69.1091 -   tempValue|=1<<2;
 69.1092 -   gbWriteMemory(HL.W,tempValue);
 69.1093 -   break;
 69.1094 - case 0xd7:
 69.1095 -   // SET 2,A
 69.1096 -   AF.B.B1|=1<<2;
 69.1097 -   break;
 69.1098 - case 0xd8:
 69.1099 -   // SET 3,B
 69.1100 -   BC.B.B1|=1<<3;
 69.1101 -   break;
 69.1102 - case 0xd9:
 69.1103 -   // SET 3,C
 69.1104 -   BC.B.B0|=1<<3;
 69.1105 -   break;
 69.1106 - case 0xda:
 69.1107 -   // SET 3,D
 69.1108 -   DE.B.B1|=1<<3;
 69.1109 -   break;
 69.1110 - case 0xdb:
 69.1111 -   // SET 3,E
 69.1112 -   DE.B.B0|=1<<3;
 69.1113 -   break;
 69.1114 - case 0xdc:
 69.1115 -   // SET 3,H
 69.1116 -   HL.B.B1|=1<<3;
 69.1117 -   break;
 69.1118 - case 0xdd:
 69.1119 -   // SET 3,L
 69.1120 -   HL.B.B0|=1<<3;
 69.1121 -   break;
 69.1122 - case 0xde:
 69.1123 -   // SET 3,(HL)
 69.1124 -   tempValue=gbReadMemory(HL.W);
 69.1125 -   tempValue|=1<<3;
 69.1126 -   gbWriteMemory(HL.W,tempValue);
 69.1127 -   break;
 69.1128 - case 0xdf:
 69.1129 -   // SET 3,A
 69.1130 -   AF.B.B1|=1<<3;
 69.1131 -   break;
 69.1132 - case 0xe0:
 69.1133 -   // SET 4,B
 69.1134 -   BC.B.B1|=1<<4;
 69.1135 -   break;
 69.1136 - case 0xe1:
 69.1137 -   // SET 4,C
 69.1138 -   BC.B.B0|=1<<4;
 69.1139 -   break;
 69.1140 - case 0xe2:
 69.1141 -   // SET 4,D
 69.1142 -   DE.B.B1|=1<<4;
 69.1143 -   break;
 69.1144 - case 0xe3:
 69.1145 -   // SET 4,E
 69.1146 -   DE.B.B0|=1<<4;
 69.1147 -   break;
 69.1148 - case 0xe4:
 69.1149 -   // SET 4,H
 69.1150 -   HL.B.B1|=1<<4;
 69.1151 -   break;
 69.1152 - case 0xe5:
 69.1153 -   // SET 4,L
 69.1154 -   HL.B.B0|=1<<4;
 69.1155 -   break;
 69.1156 - case 0xe6:
 69.1157 -   // SET 4,(HL)
 69.1158 -   tempValue=gbReadMemory(HL.W);
 69.1159 -   tempValue|=1<<4;
 69.1160 -   gbWriteMemory(HL.W,tempValue);
 69.1161 -   break;
 69.1162 - case 0xe7:
 69.1163 -   // SET 4,A
 69.1164 -   AF.B.B1|=1<<4;
 69.1165 -   break;
 69.1166 - case 0xe8:
 69.1167 -   // SET 5,B
 69.1168 -   BC.B.B1|=1<<5;
 69.1169 -   break;
 69.1170 - case 0xe9:
 69.1171 -   // SET 5,C
 69.1172 -   BC.B.B0|=1<<5;
 69.1173 -   break;
 69.1174 - case 0xea:
 69.1175 -   // SET 5,D
 69.1176 -   DE.B.B1|=1<<5;
 69.1177 -   break;
 69.1178 - case 0xeb:
 69.1179 -   // SET 5,E
 69.1180 -   DE.B.B0|=1<<5;
 69.1181 -   break;
 69.1182 - case 0xec:
 69.1183 -   // SET 5,H
 69.1184 -   HL.B.B1|=1<<5;
 69.1185 -   break;
 69.1186 - case 0xed:
 69.1187 -   // SET 5,L
 69.1188 -   HL.B.B0|=1<<5;
 69.1189 -   break;
 69.1190 - case 0xee:
 69.1191 -   // SET 5,(HL)
 69.1192 -   tempValue=gbReadMemory(HL.W);
 69.1193 -   tempValue|=1<<5;
 69.1194 -   gbWriteMemory(HL.W,tempValue);
 69.1195 -   break;
 69.1196 - case 0xef:
 69.1197 -   // SET 5,A
 69.1198 -   AF.B.B1|=1<<5;
 69.1199 -   break;
 69.1200 - case 0xf0:
 69.1201 -   // SET 6,B
 69.1202 -   BC.B.B1|=1<<6;
 69.1203 -   break;
 69.1204 - case 0xf1:
 69.1205 -   // SET 6,C
 69.1206 -   BC.B.B0|=1<<6;
 69.1207 -   break;
 69.1208 - case 0xf2:
 69.1209 -   // SET 6,D
 69.1210 -   DE.B.B1|=1<<6;
 69.1211 -   break;
 69.1212 - case 0xf3:
 69.1213 -   // SET 6,E
 69.1214 -   DE.B.B0|=1<<6;
 69.1215 -   break;
 69.1216 - case 0xf4:
 69.1217 -   // SET 6,H
 69.1218 -   HL.B.B1|=1<<6;
 69.1219 -   break;
 69.1220 - case 0xf5:
 69.1221 -   // SET 6,L
 69.1222 -   HL.B.B0|=1<<6;
 69.1223 -   break;
 69.1224 - case 0xf6:
 69.1225 -   // SET 6,(HL)
 69.1226 -   tempValue=gbReadMemory(HL.W);
 69.1227 -   tempValue|=1<<6;
 69.1228 -   gbWriteMemory(HL.W,tempValue);
 69.1229 -   break;
 69.1230 - case 0xf7:
 69.1231 -   // SET 6,A
 69.1232 -   AF.B.B1|=1<<6;
 69.1233 -   break;
 69.1234 - case 0xf8:
 69.1235 -   // SET 7,B
 69.1236 -   BC.B.B1|=1<<7;
 69.1237 -   break;
 69.1238 - case 0xf9:
 69.1239 -   // SET 7,C
 69.1240 -   BC.B.B0|=1<<7;
 69.1241 -   break;
 69.1242 - case 0xfa:
 69.1243 -   // SET 7,D
 69.1244 -   DE.B.B1|=1<<7;
 69.1245 -   break;
 69.1246 - case 0xfb:
 69.1247 -   // SET 7,E
 69.1248 -   DE.B.B0|=1<<7;
 69.1249 -   break;
 69.1250 - case 0xfc:
 69.1251 -   // SET 7,H
 69.1252 -   HL.B.B1|=1<<7;
 69.1253 -   break;
 69.1254 - case 0xfd:
 69.1255 -   // SET 7,L
 69.1256 -   HL.B.B0|=1<<7;
 69.1257 -   break;
 69.1258 - case 0xfe:
 69.1259 -   // SET 7,(HL)
 69.1260 -   tempValue=gbReadMemory(HL.W);
 69.1261 -   tempValue|=1<<7;
 69.1262 -   gbWriteMemory(HL.W,tempValue);
 69.1263 -   break;
 69.1264 - case 0xff:
 69.1265 -   // SET 7,A
 69.1266 -   AF.B.B1|=1<<7;
 69.1267 -   break;
 69.1268 - default:
 69.1269 -   systemMessage(0, N_("Unknown opcode %02x at %04x"),
 69.1270 -                 gbReadOpcode(PC.W-1),PC.W-1);
 69.1271 -   emulating = false;
 69.1272 -   return;
    70.1 --- a/src/gb/gbDis.cpp	Sat Mar 03 10:54:39 2012 -0600
    70.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.3 @@ -1,239 +0,0 @@
    70.4 -#include <cstdio>
    70.5 -#include <cstring>
    70.6 -
    70.7 -#include "gbGlobals.h"
    70.8 -
    70.9 -typedef struct
   70.10 -{
   70.11 -	u8    mask;
   70.12 -	u8    value;
   70.13 -	char *mnen;
   70.14 -} GBOPCODE;
   70.15 -
   70.16 -static char *registers[] =
   70.17 -{ "B", "C", "D", "E", "H", "L", "(HL)", "A" };
   70.18 -
   70.19 -static char *registers16[] =
   70.20 -{ "BC", "DE", "HL", "SP", // for some operations
   70.21 -  "BC", "DE", "HL", "AF" };   // for push/pop
   70.22 -
   70.23 -static char *cond[] =
   70.24 -{ "NZ", "Z", "NC", "C" };
   70.25 -
   70.26 -static char hexDigits[16] = {
   70.27 -	'0', '1', '2', '3', '4', '5', '6', '7',
   70.28 -	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
   70.29 -};
   70.30 -
   70.31 -static GBOPCODE opcodes[] = {
   70.32 -	{ 0xff, 0x00, "NOP"            },
   70.33 -	{ 0xcf, 0x01, "LD %R4,%W"      },
   70.34 -	{ 0xff, 0x02, "LD (BC),A"      },
   70.35 -	{ 0xcf, 0x03, "INC %R4"        },
   70.36 -	{ 0xc7, 0x04, "INC %r3"        },
   70.37 -	{ 0xc7, 0x05, "DEC %r3"        },
   70.38 -	{ 0xc7, 0x06, "LD %r3,%B"      },
   70.39 -	{ 0xff, 0x07, "RLCA"           },
   70.40 -	{ 0xff, 0x08, "LD (%W),SP"     },
   70.41 -	{ 0xcf, 0x09, "ADD HL,%R4"     },
   70.42 -	{ 0xff, 0x0a, "LD A,(BC)"      },
   70.43 -	{ 0xcf, 0x0b, "DEC %R4"        },
   70.44 -	{ 0xff, 0x0f, "RRCA"           },
   70.45 -	{ 0xff, 0x10, "STOP"           },
   70.46 -	{ 0xff, 0x12, "LD (DE),A"      },
   70.47 -	{ 0xff, 0x17, "RLA"            },
   70.48 -	{ 0xff, 0x18, "JR %d"          },
   70.49 -	{ 0xff, 0x1a, "LD A,(DE)"      },
   70.50 -	{ 0xff, 0x1f, "RRA"            },
   70.51 -	{ 0xe7, 0x20, "JR %c3,%d"      },
   70.52 -	{ 0xff, 0x22, "LDI (HL),A"     },
   70.53 -	{ 0xff, 0x27, "DAA"            },
   70.54 -	{ 0xff, 0x2a, "LDI A,(HL)"     },
   70.55 -	{ 0xff, 0x2f, "CPL"            },
   70.56 -	{ 0xff, 0x32, "LDD (HL),A"     },
   70.57 -	{ 0xff, 0x37, "SCF"            },
   70.58 -	{ 0xff, 0x3a, "LDD A,(HL)"     },
   70.59 -	{ 0xff, 0x3f, "CCF"            },
   70.60 -	{ 0xff, 0x76, "HALT"           },
   70.61 -	{ 0xc0, 0x40, "LD %r3,%r0"     },
   70.62 -	{ 0xf8, 0x80, "ADD A,%r0"      },
   70.63 -	{ 0xf8, 0x88, "ADC A,%r0"      },
   70.64 -	{ 0xf8, 0x90, "SUB %r0"        },
   70.65 -	{ 0xf8, 0x98, "SBC A,%r0"      },
   70.66 -	{ 0xf8, 0xa0, "AND %r0"        },
   70.67 -	{ 0xf8, 0xa8, "XOR %r0"        },
   70.68 -	{ 0xf8, 0xb0, "OR %r0"         },
   70.69 -	{ 0xf8, 0xb8, "CP %r0"         },
   70.70 -	{ 0xe7, 0xc0, "RET %c3"        },
   70.71 -	{ 0xcf, 0xc1, "POP %t4"        },
   70.72 -	{ 0xe7, 0xc2, "JP %c3,%W"      },
   70.73 -	{ 0xff, 0xc3, "JP %W"          },
   70.74 -	{ 0xe7, 0xc4, "CALL %c3,%W"    },
   70.75 -	{ 0xcf, 0xc5, "PUSH %t4"       },
   70.76 -	{ 0xff, 0xc6, "ADD A,%B"       },
   70.77 -	{ 0xc7, 0xc7, "RST %P"         },
   70.78 -	{ 0xff, 0xc9, "RET"            },
   70.79 -	{ 0xff, 0xcd, "CALL %W"        },
   70.80 -	{ 0xff, 0xce, "ADC %B"         },
   70.81 -	{ 0xff, 0xd6, "SUB %B"         },
   70.82 -	{ 0xff, 0xd9, "RETI"           },
   70.83 -	{ 0xff, 0xde, "SBC %B"         },
   70.84 -	{ 0xff, 0xe0, "LD (FF%B),A"    },
   70.85 -	{ 0xff, 0xe2, "LD (FF00h+C),A" },
   70.86 -	{ 0xff, 0xe6, "AND %B"         },
   70.87 -	{ 0xff, 0xe8, "ADD SP,%D"      },
   70.88 -	{ 0xff, 0xe9, "LD PC,HL"       },
   70.89 -	{ 0xff, 0xea, "LD (%W),A"      },
   70.90 -	{ 0xff, 0xee, "XOR %B"         },
   70.91 -	{ 0xff, 0xf0, "LD A,(FF%B)"    },
   70.92 -	{ 0xff, 0xf2, "LD A,(FF00h+C)" },
   70.93 -	{ 0xff, 0xf3, "DI"             },
   70.94 -	{ 0xff, 0xf6, "OR %B"          },
   70.95 -	{ 0xff, 0xf8, "LD HL,SP%D"     },
   70.96 -	{ 0xff, 0xf9, "LD SP,HL"       },
   70.97 -	{ 0xff, 0xfa, "LD A,(%W)"      },
   70.98 -	{ 0xff, 0xfb, "EI"             },
   70.99 -	{ 0xff, 0xfe, "CP %B"          },
  70.100 -	{ 0x00, 0x00, "DB %B"          }
  70.101 -};
  70.102 -
  70.103 -static GBOPCODE cbOpcodes[] = {
  70.104 -	{ 0xf8, 0x00, "RLC %r0"    },
  70.105 -	{ 0xf8, 0x08, "RRC %r0"    },
  70.106 -	{ 0xf8, 0x10, "RL %r0"     },
  70.107 -	{ 0xf8, 0x18, "RR %r0"     },
  70.108 -	{ 0xf8, 0x20, "SLA %r0"    },
  70.109 -	{ 0xf8, 0x28, "SRA %r0"    },
  70.110 -	{ 0xf8, 0x30, "SWAP %r0"   },
  70.111 -	{ 0xf8, 0x38, "SRL %r0"    },
  70.112 -	{ 0xc0, 0x40, "BIT %b,%r0" },
  70.113 -	{ 0xc0, 0x80, "RES %b,%r0" },
  70.114 -	{ 0xc0, 0xc0, "SET %b,%r0" },
  70.115 -	{ 0x00, 0x00, "DB CBh,%B"  }
  70.116 -};
  70.117 -
  70.118 -static char *addHex(char *p, u8 value)
  70.119 -{
  70.120 -	*p++ = hexDigits[value >> 4];
  70.121 -	*p++ = hexDigits[value & 15];
  70.122 -	return p;
  70.123 -}
  70.124 -
  70.125 -static char *addHex16(char *p, u16 value)
  70.126 -{
  70.127 -	p = addHex(p, value>>8);
  70.128 -	return addHex(p, value & 255);
  70.129 -}
  70.130 -
  70.131 -static char *addStr(char *p, char *s)
  70.132 -{
  70.133 -	while (*s)
  70.134 -	{
  70.135 -		*p++ = *s++;
  70.136 -	}
  70.137 -	return p;
  70.138 -}
  70.139 -
  70.140 -int gbDis(char *buffer, u16 address)
  70.141 -{
  70.142 -	char *p     = buffer;
  70.143 -	int   instr = 1;
  70.144 -	u16   addr  = address;
  70.145 -	sprintf(p, "%04x        ", address);
  70.146 -	p += 12;
  70.147 -
  70.148 -	u8 opcode = gbReadMemoryQuick(address);
  70.149 -	address++;
  70.150 -	char *    mnen;
  70.151 -	GBOPCODE *op;
  70.152 -	if (opcode == 0xcb)
  70.153 -	{
  70.154 -		opcode = gbReadMemoryQuick(address);
  70.155 -		address++;
  70.156 -		instr++;
  70.157 -		op = cbOpcodes;
  70.158 -	}
  70.159 -	else
  70.160 -	{
  70.161 -		op = opcodes;
  70.162 -	}
  70.163 -	while (op->value != (opcode & op->mask))
  70.164 -		op++;
  70.165 -	mnen = op->mnen;
  70.166 -
  70.167 -	u8  b0, b1;
  70.168 -	s8  disp;
  70.169 -	int shift;
  70.170 -
  70.171 -	while (*mnen)
  70.172 -	{
  70.173 -		if (*mnen == '%')
  70.174 -		{
  70.175 -			mnen++;
  70.176 -			switch (*mnen++)
  70.177 -			{
  70.178 -			case 'W':
  70.179 -				b0 = gbReadMemoryQuick(address);
  70.180 -				address++;
  70.181 -				b1 = gbReadMemoryQuick(address);
  70.182 -				address++;
  70.183 -				p      = addHex16(p, b0|b1<<8);
  70.184 -				instr += 2;
  70.185 -				*p++   = 'h';
  70.186 -				break;
  70.187 -			case 'B':
  70.188 -				p    = addHex(p, gbReadMemoryQuick(address));
  70.189 -				*p++ = 'h';
  70.190 -				address++;
  70.191 -				instr++;
  70.192 -				break;
  70.193 -			case 'D':
  70.194 -				disp = gbReadMemoryQuick(address);
  70.195 -				if (disp >= 0)
  70.196 -					*p++ = '+';
  70.197 -				p += sprintf(p, "%d", disp);
  70.198 -				instr++;
  70.199 -				break;
  70.200 -			case 'd':
  70.201 -				disp = gbReadMemoryQuick(address);
  70.202 -				address++;
  70.203 -				p    = addHex16(p, address+disp);
  70.204 -				*p++ = 'h';
  70.205 -				instr++;
  70.206 -				break;
  70.207 -			case 'b':
  70.208 -				// kind of a hack, but it works :-)
  70.209 -				*p++ = hexDigits[(opcode >> 3) & 7];
  70.210 -				break;
  70.211 -			case 'r':
  70.212 -				shift = *mnen++ - '0';
  70.213 -				p     = addStr(p, registers[(opcode >> shift) & 7]);
  70.214 -				break;
  70.215 -			case 'R':
  70.216 -				shift = *mnen++ - '0';
  70.217 -				p     = addStr(p, registers16[(opcode >> shift) & 3]);
  70.218 -				break;
  70.219 -			case 't':
  70.220 -				shift = *mnen++ - '0';
  70.221 -				p     = addStr(p, registers16[4+((opcode >> shift) & 3)]);
  70.222 -				break;
  70.223 -			case 'P':
  70.224 -				p = addHex(p, ((opcode >> 3) & 7) * 8);
  70.225 -				break;
  70.226 -			case 'c':
  70.227 -				shift = *mnen++ - '0';
  70.228 -				p     = addStr(p, cond[(opcode >> shift) & 3]);
  70.229 -				break;
  70.230 -			}
  70.231 -		}
  70.232 -		else
  70.233 -			*p++ = *mnen++;
  70.234 -	}
  70.235 -	for (int i = 0; i < instr; i++)
  70.236 -	{
  70.237 -		u16 a = addr + i;
  70.238 -		addHex(buffer+5+i*2, gbReadMemoryQuick(a));
  70.239 -	}
  70.240 -	*p = 0;
  70.241 -	return instr;
  70.242 -}
    71.1 --- a/src/gb/gbGfx.cpp	Sat Mar 03 10:54:39 2012 -0600
    71.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.3 @@ -1,552 +0,0 @@
    71.4 -#include <cstring>
    71.5 -
    71.6 -#include "gbGlobals.h"
    71.7 -#include "gbSGB.h"
    71.8 -
    71.9 -extern int32 layerSettings;
   71.10 -
   71.11 -u8 gbInvertTab[256] = {
   71.12 -	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
   71.13 -	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
   71.14 -	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
   71.15 -	0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
   71.16 -	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
   71.17 -	0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
   71.18 -	0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
   71.19 -	0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
   71.20 -	0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
   71.21 -	0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
   71.22 -	0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
   71.23 -	0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
   71.24 -	0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
   71.25 -	0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
   71.26 -	0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
   71.27 -	0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
   71.28 -	0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
   71.29 -	0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
   71.30 -	0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
   71.31 -	0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
   71.32 -	0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
   71.33 -	0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
   71.34 -	0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
   71.35 -	0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
   71.36 -	0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
   71.37 -	0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
   71.38 -	0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
   71.39 -	0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
   71.40 -	0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
   71.41 -	0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
   71.42 -	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
   71.43 -	0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
   71.44 -};
   71.45 -
   71.46 -u16 gbLineMix[160];
   71.47 -
   71.48 -void gbRenderLine()
   71.49 -{
   71.50 -	u8 *bank0;
   71.51 -	u8 *bank1;
   71.52 -	if (gbCgbMode)
   71.53 -	{
   71.54 -		bank0 = &gbVram[0x0000];
   71.55 -		bank1 = &gbVram[0x2000];
   71.56 -	}
   71.57 -	else
   71.58 -	{
   71.59 -		bank0 = &gbMemory[0x8000];
   71.60 -		bank1 = NULL;
   71.61 -	}
   71.62 -
   71.63 -	int tile_map = 0x1800;
   71.64 -	if ((register_LCDC & 8) != 0)
   71.65 -		tile_map = 0x1c00;
   71.66 -
   71.67 -	int tile_pattern = 0x0800;
   71.68 -
   71.69 -	if ((register_LCDC & 16) != 0)
   71.70 -		tile_pattern = 0x0000;
   71.71 -
   71.72 -	int x = 0;
   71.73 -	int y = register_LY;
   71.74 -
   71.75 -	if (y >= 144)
   71.76 -		return;
   71.77 -
   71.78 -	//  int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip;
   71.79 -
   71.80 -	int sx = register_SCX;
   71.81 -	int sy = register_SCY;
   71.82 -
   71.83 -	sy += y;
   71.84 -
   71.85 -	sy &= 255;
   71.86 -
   71.87 -	int tx = sx >> 3;
   71.88 -	int ty = sy >> 3;
   71.89 -
   71.90 -	int bx = 1 << (7 - (sx & 7));
   71.91 -	int by = sy & 7;
   71.92 -
   71.93 -	int tile_map_line_y = tile_map + ty * 32;
   71.94 -
   71.95 -	int tile_map_address = tile_map_line_y + tx;
   71.96 -
   71.97 -	u8 attrs = 0;
   71.98 -	if (bank1 != NULL)
   71.99 -		attrs = bank1[tile_map_address];
  71.100 -
  71.101 -	u8 tile = bank0[tile_map_address];
  71.102 -
  71.103 -	tile_map_address++;
  71.104 -
  71.105 -	if ((register_LCDC & 16) == 0)
  71.106 -	{
  71.107 -		if (tile < 128)
  71.108 -			tile += 128;
  71.109 -		else
  71.110 -			tile -= 128;
  71.111 -	}
  71.112 -
  71.113 -	int tile_pattern_address = tile_pattern + tile * 16 + by*2;
  71.114 -
  71.115 -	if (register_LCDC & 0x80)
  71.116 -	{
  71.117 -		if ((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100))
  71.118 -		{
  71.119 -			while (x < 160)
  71.120 -			{
  71.121 -				u8 tile_a = 0;
  71.122 -				u8 tile_b = 0;
  71.123 -
  71.124 -				if (attrs & 0x40)
  71.125 -				{
  71.126 -					tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
  71.127 -				}
  71.128 -
  71.129 -				if (attrs & 0x08)
  71.130 -				{
  71.131 -					tile_a = bank1[tile_pattern_address++];
  71.132 -					tile_b = bank1[tile_pattern_address];
  71.133 -				}
  71.134 -				else
  71.135 -				{
  71.136 -					tile_a = bank0[tile_pattern_address++];
  71.137 -					tile_b = bank0[tile_pattern_address];
  71.138 -				}
  71.139 -
  71.140 -				if (attrs & 0x20)
  71.141 -				{
  71.142 -					tile_a = gbInvertTab[tile_a];
  71.143 -					tile_b = gbInvertTab[tile_b];
  71.144 -				}
  71.145 -
  71.146 -				while (bx > 0)
  71.147 -				{
  71.148 -					u8 c = (tile_a & bx) ? 1 : 0;
  71.149 -					c += ((tile_b & bx) ? 2 : 0);
  71.150 -
  71.151 -					gbLineBuffer[x] = c; // mark the gbLineBuffer color
  71.152 -
  71.153 -					if (attrs & 0x80)
  71.154 -						gbLineBuffer[x] |= 0x300;
  71.155 -
  71.156 -					if (gbCgbMode)
  71.157 -					{
  71.158 -						c = c + (attrs & 7)*4;
  71.159 -					}
  71.160 -					else
  71.161 -					{
  71.162 -						c = gbBgp[c];
  71.163 -						if (gbSgbMode && !gbCgbMode)
  71.164 -						{
  71.165 -							int dx = x >> 3;
  71.166 -							int dy = y >> 3;
  71.167 -
  71.168 -							int palette = gbSgbATF[dy * 20 + dx];
  71.169 -
  71.170 -							if (c == 0)
  71.171 -								palette = 0;
  71.172 -
  71.173 -							c = c + 4*palette;
  71.174 -						}
  71.175 -					}
  71.176 -					gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] :
  71.177 -					               gbPalette[c];
  71.178 -					x++;
  71.179 -					if (x >= 160)
  71.180 -						break;
  71.181 -					bx >>= 1;
  71.182 -				}
  71.183 -				tx++;
  71.184 -				if (tx == 32)
  71.185 -					tx = 0;
  71.186 -				bx = 128;
  71.187 -
  71.188 -				if (bank1)
  71.189 -					attrs = bank1[tile_map_line_y + tx];
  71.190 -
  71.191 -				tile = bank0[tile_map_line_y + tx];
  71.192 -
  71.193 -				if ((register_LCDC & 16) == 0)
  71.194 -				{
  71.195 -					if (tile < 128)
  71.196 -						tile += 128;
  71.197 -					else
  71.198 -						tile -= 128;
  71.199 -				}
  71.200 -				tile_pattern_address = tile_pattern + tile * 16 + by * 2;
  71.201 -			}
  71.202 -		}
  71.203 -		else
  71.204 -		{
  71.205 -			for (int i = 0; i < 160; i++)
  71.206 -			{
  71.207 -				gbLineMix[i]    = gbPalette[0];
  71.208 -				gbLineBuffer[i] = 0;
  71.209 -			}
  71.210 -		}
  71.211 -
  71.212 -		// do the window display
  71.213 -		if ((register_LCDC & 0x20) && (layerSettings & 0x2000))
  71.214 -		{
  71.215 -			int wy = register_WY;
  71.216 -
  71.217 -			if (y >= wy)
  71.218 -			{
  71.219 -				int wx = register_WX;
  71.220 -				wx -= 7;
  71.221 -
  71.222 -				if (wx <= 159 && gbWindowLine <= 143)
  71.223 -				{
  71.224 -					tile_map = 0x1800;
  71.225 -
  71.226 -					if ((register_LCDC & 0x40) != 0)
  71.227 -						tile_map = 0x1c00;
  71.228 -
  71.229 -					if (gbWindowLine == -1)
  71.230 -					{
  71.231 -						gbWindowLine = 0;
  71.232 -					}
  71.233 -
  71.234 -					tx = 0;
  71.235 -					ty = gbWindowLine >> 3;
  71.236 -
  71.237 -					bx = 128;
  71.238 -					by = gbWindowLine & 7;
  71.239 -
  71.240 -					if (wx < 0)
  71.241 -					{
  71.242 -						bx >>= (-wx);
  71.243 -						wx   = 0;
  71.244 -					}
  71.245 -
  71.246 -					tile_map_line_y = tile_map + ty * 32;
  71.247 -
  71.248 -					tile_map_address = tile_map_line_y + tx;
  71.249 -
  71.250 -					x = wx;
  71.251 -
  71.252 -					tile = bank0[tile_map_address];
  71.253 -					u8 attrs = 0;
  71.254 -					if (bank1)
  71.255 -						attrs = bank1[tile_map_address];
  71.256 -					tile_map_address++;
  71.257 -
  71.258 -					if ((register_LCDC & 16) == 0)
  71.259 -					{
  71.260 -						if (tile < 128)
  71.261 -							tile += 128;
  71.262 -						else
  71.263 -							tile -= 128;
  71.264 -					}
  71.265 -
  71.266 -					tile_pattern_address = tile_pattern + tile * 16 + by*2;
  71.267 -
  71.268 -					while (x < 160)
  71.269 -					{
  71.270 -						u8 tile_a = 0;
  71.271 -						u8 tile_b = 0;
  71.272 -
  71.273 -						if (attrs & 0x40)
  71.274 -						{
  71.275 -							tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
  71.276 -						}
  71.277 -
  71.278 -						if (attrs & 0x08)
  71.279 -						{
  71.280 -							tile_a = bank1[tile_pattern_address++];
  71.281 -							tile_b = bank1[tile_pattern_address];
  71.282 -						}
  71.283 -						else
  71.284 -						{
  71.285 -							tile_a = bank0[tile_pattern_address++];
  71.286 -							tile_b = bank0[tile_pattern_address];
  71.287 -						}
  71.288 -
  71.289 -						if (attrs & 0x20)
  71.290 -						{
  71.291 -							tile_a = gbInvertTab[tile_a];
  71.292 -							tile_b = gbInvertTab[tile_b];
  71.293 -						}
  71.294 -
  71.295 -						while (bx > 0)
  71.296 -						{
  71.297 -							u8 c = (tile_a & bx) != 0 ? 1 : 0;
  71.298 -							c += ((tile_b & bx) != 0 ? 2 : 0);
  71.299 -
  71.300 -							if (attrs & 0x80)
  71.301 -								gbLineBuffer[x] = 0x300 + c;
  71.302 -							else
  71.303 -								gbLineBuffer[x] = 0x100 + c;
  71.304 -
  71.305 -							if (gbCgbMode)
  71.306 -							{
  71.307 -								c = c + (attrs & 7) * 4;
  71.308 -							}
  71.309 -							else
  71.310 -							{
  71.311 -								c = gbBgp[c];
  71.312 -								if (gbSgbMode && !gbCgbMode)
  71.313 -								{
  71.314 -									int dx = x >> 3;
  71.315 -									int dy = y >> 3;
  71.316 -
  71.317 -									int palette = gbSgbATF[dy * 20 + dx];
  71.318 -
  71.319 -									if (c == 0)
  71.320 -										palette = 0;
  71.321 -
  71.322 -									c = c + 4*palette;
  71.323 -								}
  71.324 -							}
  71.325 -							gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] :
  71.326 -							               gbPalette[c];
  71.327 -							x++;
  71.328 -							if (x >= 160)
  71.329 -								break;
  71.330 -							bx >>= 1;
  71.331 -						}
  71.332 -						tx++;
  71.333 -						if (tx == 32)
  71.334 -							tx = 0;
  71.335 -						bx   = 128;
  71.336 -						tile = bank0[tile_map_line_y + tx];
  71.337 -						if (bank1)
  71.338 -							attrs = bank1[tile_map_line_y + tx];
  71.339 -
  71.340 -						if ((register_LCDC & 16) == 0)
  71.341 -						{
  71.342 -							if (tile < 128)
  71.343 -								tile += 128;
  71.344 -							else
  71.345 -								tile -= 128;
  71.346 -						}
  71.347 -						tile_pattern_address = tile_pattern + tile * 16 + by * 2;
  71.348 -					}
  71.349 -					gbWindowLine++;
  71.350 -				}
  71.351 -			}
  71.352 -		}
  71.353 -	}
  71.354 -	else
  71.355 -	{
  71.356 -		for (int i = 0; i < 160; i++)
  71.357 -		{
  71.358 -			gbLineMix[i]    = gbPalette[0];
  71.359 -			gbLineBuffer[i] = 0;
  71.360 -		}
  71.361 -	}
  71.362 -}
  71.363 -
  71.364 -void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
  71.365 -                      int size, int spriteNumber)
  71.366 -{
  71.367 -	u8 *bank0;
  71.368 -	u8 *bank1;
  71.369 -	if (gbCgbMode)
  71.370 -	{
  71.371 -		if (register_VBK & 1)
  71.372 -		{
  71.373 -			bank0 = &gbVram[0x0000];
  71.374 -			bank1 = &gbVram[0x2000];
  71.375 -		}
  71.376 -		else
  71.377 -		{
  71.378 -			bank0 = &gbVram[0x0000];
  71.379 -			bank1 = &gbVram[0x2000];
  71.380 -		}
  71.381 -	}
  71.382 -	else
  71.383 -	{
  71.384 -		bank0 = &gbMemory[0x8000];
  71.385 -		bank1 = NULL;
  71.386 -	}
  71.387 -
  71.388 -	int init = 0x0000;
  71.389 -
  71.390 -	//  int yLine = (y+gbBorderRowSkip) * gbBorderLineSkip;
  71.391 -
  71.392 -	u8 *pal = gbObp0;
  71.393 -
  71.394 -	int flipx = (flags & 0x20);
  71.395 -	int flipy = (flags & 0x40);
  71.396 -
  71.397 -	if ((flags & 0x10))
  71.398 -		pal = gbObp1;
  71.399 -
  71.400 -	if (flipy)
  71.401 -	{
  71.402 -		t = (size ? 15 : 7) - t;
  71.403 -	}
  71.404 -
  71.405 -	int prio =  flags & 0x80;
  71.406 -
  71.407 -	int address = init + tile * 16 + 2*t;
  71.408 -	int a       = 0;
  71.409 -	int b       = 0;
  71.410 -
  71.411 -	if (gbCgbMode && flags & 0x08)
  71.412 -	{
  71.413 -		a = bank1[address++];
  71.414 -		b = bank1[address++];
  71.415 -	}
  71.416 -	else
  71.417 -	{
  71.418 -		a = bank0[address++];
  71.419 -		b = bank0[address++];
  71.420 -	}
  71.421 -
  71.422 -	for (int xx = 0; xx < 8; xx++)
  71.423 -	{
  71.424 -		u8 mask = 1 << (7-xx);
  71.425 -		u8 c    = 0;
  71.426 -		if ((a & mask))
  71.427 -			c++;
  71.428 -		if ((b & mask))
  71.429 -			c += 2;
  71.430 -
  71.431 -		if (c == 0)
  71.432 -			continue;
  71.433 -
  71.434 -		int xxx = xx+x;
  71.435 -		if (flipx)
  71.436 -			xxx = (7-xx+x);
  71.437 -
  71.438 -		if (xxx < 0 || xxx > 159)
  71.439 -			continue;
  71.440 -
  71.441 -		u16 color = gbLineBuffer[xxx];
  71.442 -
  71.443 -		if (prio)
  71.444 -		{
  71.445 -			if (color < 0x200 && ((color & 0xFF) != 0))
  71.446 -				continue;
  71.447 -		}
  71.448 -		if (color >= 0x300 && color != 0x300)
  71.449 -			continue;
  71.450 -		else if (color >= 0x200 && color < 0x300)
  71.451 -		{
  71.452 -			int sprite = color & 0xff;
  71.453 -
  71.454 -			int spriteX = gbMemory[0xfe00 + 4 * sprite + 1] - 8;
  71.455 -
  71.456 -			if (spriteX == x)
  71.457 -			{
  71.458 -				if (sprite < spriteNumber)
  71.459 -					continue;
  71.460 -			}
  71.461 -			else
  71.462 -			{
  71.463 -				if (gbCgbMode)
  71.464 -				{
  71.465 -					if (sprite < spriteNumber)
  71.466 -						continue;
  71.467 -				}
  71.468 -				else
  71.469 -				{
  71.470 -					if (spriteX < x+8)
  71.471 -						continue;
  71.472 -				}
  71.473 -			}
  71.474 -		}
  71.475 -
  71.476 -		gbLineBuffer[xxx] = 0x200 + spriteNumber;
  71.477 -
  71.478 -		// make sure that sprites will work even in CGB mode
  71.479 -		if (gbCgbMode)
  71.480 -		{
  71.481 -			c = c + (flags & 0x07)*4 + 32;
  71.482 -		}
  71.483 -		else
  71.484 -		{
  71.485 -			c = pal[c];
  71.486 -
  71.487 -			if (gbSgbMode && !gbCgbMode)
  71.488 -			{
  71.489 -				int dx = xxx >> 3;
  71.490 -				int dy = y >> 3;
  71.491 -
  71.492 -				int palette = gbSgbATF[dy * 20 + dx];
  71.493 -
  71.494 -				if (c == 0)
  71.495 -					palette = 0;
  71.496 -
  71.497 -				c = c + 4*palette;
  71.498 -			}
  71.499 -			else
  71.500 -			{
  71.501 -				c += 4;
  71.502 -			}
  71.503 -		}
  71.504 -
  71.505 -		gbLineMix[xxx] = gbColorOption ? gbColorFilter[gbPalette[c]] :
  71.506 -		                 gbPalette[c];
  71.507 -	}
  71.508 -}
  71.509 -
  71.510 -void gbDrawSprites()
  71.511 -{
  71.512 -	int x     = 0;
  71.513 -	int y     = 0;
  71.514 -	int count = 0;
  71.515 -
  71.516 -	int size = (register_LCDC & 4);
  71.517 -
  71.518 -	if (!(register_LCDC & 0x80))
  71.519 -		return;
  71.520 -
  71.521 -	if ((register_LCDC & 2) && (layerSettings & 0x1000))
  71.522 -	{
  71.523 -		int yc = register_LY;
  71.524 -
  71.525 -		int address = 0xfe00;
  71.526 -		for (int i = 0; i < 40; i++)
  71.527 -		{
  71.528 -			y = gbMemory[address++];
  71.529 -			x = gbMemory[address++];
  71.530 -			int tile = gbMemory[address++];
  71.531 -			if (size)
  71.532 -				tile &= 254;
  71.533 -			int flags = gbMemory[address++];
  71.534 -
  71.535 -			if (x > 0 && y > 0 && x < 168 && y < 160)
  71.536 -			{
  71.537 -				// check if sprite intersects current line
  71.538 -				int t = yc -y + 16;
  71.539 -				if (size && t >= 0 && t < 16)
  71.540 -				{
  71.541 -					gbDrawSpriteTile(tile, x-8, yc, t, flags, size, i);
  71.542 -					count++;
  71.543 -				}
  71.544 -				else if (!size && t >= 0 && t < 8)
  71.545 -				{
  71.546 -					gbDrawSpriteTile(tile, x-8, yc, t, flags, size, i);
  71.547 -					count++;
  71.548 -				}
  71.549 -			}
  71.550 -			// sprite limit reached!
  71.551 -			if (count >= 10)
  71.552 -				break;
  71.553 -		}
  71.554 -	}
  71.555 -}
    72.1 --- a/src/gb/gbGlobals.cpp	Sat Mar 03 10:54:39 2012 -0600
    72.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.3 @@ -1,39 +0,0 @@
    72.4 -#include "../Port.h"
    72.5 -#include "GB.h"
    72.6 -
    72.7 -u8 *gbMemoryMap[16];
    72.8 -
    72.9 -int32 gbRomSizeMask = 0;
   72.10 -int32 gbRomSize     = 0;
   72.11 -int32 gbRamSizeMask = 0;
   72.12 -int32 gbRamSize     = 0;
   72.13 -
   72.14 -u8 * gbMemory     = NULL;
   72.15 -u8 * gbVram       = NULL;
   72.16 -u8 * gbRom        = NULL;
   72.17 -u8 * gbRam        = NULL;
   72.18 -u8 * gbWram       = NULL;
   72.19 -u16 *gbLineBuffer = NULL;
   72.20 -
   72.21 -u16   gbPalette[128];
   72.22 -u8    gbBgp[4] = { 0, 1, 2, 3};
   72.23 -u8    gbObp0[4] = { 0, 1, 2, 3};
   72.24 -u8    gbObp1[4] = { 0, 1, 2, 3};
   72.25 -int32 gbWindowLine = -1;
   72.26 -
   72.27 -int32 gbCgbMode = 0;
   72.28 -
   72.29 -u16   gbColorFilter[32768];
   72.30 -int32 gbColorOption      = 0;
   72.31 -int32 gbPaletteOption    = 0;
   72.32 -int32 gbEmulatorType     = 0;
   72.33 -int32 gbBorderOn         = 1;
   72.34 -int32 gbBorderAutomatic  = 0;
   72.35 -int32 gbBorderLineSkip   = 160;
   72.36 -int32 gbBorderRowSkip    = 0;
   72.37 -int32 gbBorderColumnSkip = 0;
   72.38 -int32 gbDmaTicks         = 0;
   72.39 -bool8 gbNullInputHackEnabled	 = false;
   72.40 -bool8 gbNullInputHackTempEnabled = false;
   72.41 -
   72.42 -u8 (*gbSerialFunction)(u8) = NULL;
    73.1 --- a/src/gb/gbGlobals.h	Sat Mar 03 10:54:39 2012 -0600
    73.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.3 @@ -1,95 +0,0 @@
    73.4 -#ifndef VBA_GB_GLOBALS_H
    73.5 -#define VBA_GB_GLOBALS_H
    73.6 -
    73.7 -#if _MSC_VER > 1000
    73.8 -#pragma once
    73.9 -#endif // _MSC_VER > 1000
   73.10 -
   73.11 -#include "../Port.h"
   73.12 -
   73.13 -extern int32 gbRomSizeMask;
   73.14 -extern int32 gbRomSize;
   73.15 -extern int32 gbRamSize;
   73.16 -extern int32 gbRamSizeMask;
   73.17 -
   73.18 -extern u8 * gbRom;
   73.19 -extern u8 * gbRam;
   73.20 -extern u8 * gbVram;
   73.21 -extern u8 * gbWram;
   73.22 -extern u8 * gbMemory;
   73.23 -extern u16 *gbLineBuffer;
   73.24 -
   73.25 -extern u8 *gbMemoryMap[16];
   73.26 -
   73.27 -inline u8 gbReadMemoryQuick(u16 address)
   73.28 -{
   73.29 -	extern int32 gbEchoRAMFixOn;
   73.30 -	if (gbEchoRAMFixOn)
   73.31 -	{
   73.32 -		if (address >= 0xe000 && address < 0xfe00)
   73.33 -		{
   73.34 -			address -= 0x2000;
   73.35 -		}
   73.36 -	}
   73.37 -	return gbMemoryMap[address>>12][address&0xfff];
   73.38 -}
   73.39 -
   73.40 -inline void gbWriteMemoryQuick(u16 address, u8 value)
   73.41 -{
   73.42 -	extern int32 gbEchoRAMFixOn;
   73.43 -	if (gbEchoRAMFixOn)
   73.44 -	{
   73.45 -		if (address >= 0xe000 && address < 0xfe00)
   73.46 -		{
   73.47 -			address -= 0x2000;
   73.48 -		}
   73.49 -	}
   73.50 -	gbMemoryMap[address>>12][address&0xfff] = value;
   73.51 -}
   73.52 -
   73.53 -inline u8 gbReadROMQuick(u32 address)
   73.54 -{
   73.55 -	return gbRom[address];
   73.56 -}
   73.57 -
   73.58 -extern int32 gbFrameSkip;
   73.59 -extern u16   gbColorFilter[32768];
   73.60 -extern int32 gbColorOption;
   73.61 -extern int32 gbPaletteOption;
   73.62 -extern int32 gbEmulatorType;
   73.63 -extern int32 gbBorderOn;
   73.64 -extern int32 gbBorderAutomatic;
   73.65 -extern int32 gbCgbMode;
   73.66 -extern int32 gbSgbMode;
   73.67 -extern int32 gbWindowLine;
   73.68 -extern int32 gbSpeed;
   73.69 -extern u8    gbBgp[4];
   73.70 -extern u8    gbObp0[4];
   73.71 -extern u8    gbObp1[4];
   73.72 -extern u16   gbPalette[128];
   73.73 -
   73.74 -extern u8 register_LCDC;
   73.75 -extern u8 register_LY;
   73.76 -extern u8 register_SCY;
   73.77 -extern u8 register_SCX;
   73.78 -extern u8 register_WY;
   73.79 -extern u8 register_WX;
   73.80 -extern u8 register_VBK;
   73.81 -
   73.82 -extern int emulating;
   73.83 -
   73.84 -extern int32 gbBorderLineSkip;
   73.85 -extern int32 gbBorderRowSkip;
   73.86 -extern int32 gbBorderColumnSkip;
   73.87 -extern int32 gbDmaTicks;
   73.88 -
   73.89 -extern bool8 useOldFrameTiming;
   73.90 -extern bool8 gbNullInputHackEnabled;
   73.91 -extern bool8 gbNullInputHackTempEnabled;
   73.92 -
   73.93 -extern void gbRenderLine();
   73.94 -extern void gbDrawSprites();
   73.95 -
   73.96 -extern u8 (*gbSerialFunction)(u8);
   73.97 -
   73.98 -#endif // VBA_GB_GLOBALS_H
    74.1 --- a/src/gb/gbMemory.cpp	Sat Mar 03 10:54:39 2012 -0600
    74.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.3 @@ -1,1070 +0,0 @@
    74.4 -#include "gbGlobals.h"
    74.5 -#include "gbMemory.h"
    74.6 -#include "../common/System.h"
    74.7 -#include "../common/movie.h"
    74.8 -
    74.9 -mapperMBC1 gbDataMBC1 = {
   74.10 -	0, // RAM enable
   74.11 -	1, // ROM bank
   74.12 -	0, // RAM bank
   74.13 -	0, // memory model
   74.14 -	0, // ROM high address
   74.15 -	0 // RAM address
   74.16 -};
   74.17 -
   74.18 -// MBC1 ROM write registers
   74.19 -void mapperMBC1ROM(u16 address, u8 value)
   74.20 -{
   74.21 -	int tmpAddress = 0;
   74.22 -
   74.23 -	switch (address & 0x6000)
   74.24 -	{
   74.25 -	case 0x0000: // RAM enable register
   74.26 -		gbDataMBC1.mapperRAMEnable = ((value & 0x0a) == 0x0a ? 1 : 0);
   74.27 -		break;
   74.28 -	case 0x2000: // ROM bank select
   74.29 -		//    value = value & 0x1f;
   74.30 -		if (value == 0)
   74.31 -			value = 1;
   74.32 -		if (value == gbDataMBC1.mapperROMBank)
   74.33 -			break;
   74.34 -
   74.35 -		tmpAddress = value << 14;
   74.36 -
   74.37 -		// check current model
   74.38 -		if (gbDataMBC1.mapperMemoryModel == 0)
   74.39 -		{
   74.40 -			// model is 16/8, so we have a high address in use
   74.41 -			tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19;
   74.42 -		}
   74.43 -
   74.44 -		tmpAddress &= gbRomSizeMask;
   74.45 -		gbDataMBC1.mapperROMBank = value;
   74.46 -		gbMemoryMap[0x04]        = &gbRom[tmpAddress];
   74.47 -		gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
   74.48 -		gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
   74.49 -		gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
   74.50 -		break;
   74.51 -	case 0x4000: // RAM bank select
   74.52 -		if (gbDataMBC1.mapperMemoryModel == 1)
   74.53 -		{
   74.54 -			// 4/32 model, RAM bank switching provided
   74.55 -			value = value & 0x03;
   74.56 -			if (value == gbDataMBC1.mapperRAMBank)
   74.57 -				break;
   74.58 -			tmpAddress                  = value << 13;
   74.59 -			tmpAddress                 &= gbRamSizeMask;
   74.60 -			gbMemoryMap[0x0a]           = &gbRam[tmpAddress];
   74.61 -			gbMemoryMap[0x0b]           = &gbRam[tmpAddress + 0x1000];
   74.62 -			gbDataMBC1.mapperRAMBank    = value;
   74.63 -			gbDataMBC1.mapperRAMAddress = tmpAddress;
   74.64 -		}
   74.65 -		else
   74.66 -		{
   74.67 -			// 16/8, set the high address
   74.68 -			gbDataMBC1.mapperROMHighAddress = value & 0x03;
   74.69 -			tmpAddress        = gbDataMBC1.mapperROMBank << 14;
   74.70 -			tmpAddress       |= (gbDataMBC1.mapperROMHighAddress) << 19;
   74.71 -			tmpAddress       &= gbRomSizeMask;
   74.72 -			gbMemoryMap[0x04] = &gbRom[tmpAddress];
   74.73 -			gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
   74.74 -			gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
   74.75 -			gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
   74.76 -		}
   74.77 -		break;
   74.78 -	case 0x6000: // memory model select
   74.79 -		gbDataMBC1.mapperMemoryModel = value & 1;
   74.80 -		break;
   74.81 -	}
   74.82 -}
   74.83 -
   74.84 -// MBC1 RAM write
   74.85 -void mapperMBC1RAM(u16 address, u8 value)
   74.86 -{
   74.87 -	if (gbDataMBC1.mapperRAMEnable)
   74.88 -	{
   74.89 -		if (gbRamSize)
   74.90 -		{
   74.91 -			gbWriteMemoryQuick(address, value);
   74.92 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
   74.93 -		}
   74.94 -	}
   74.95 -}
   74.96 -
   74.97 -void memoryUpdateMapMBC1()
   74.98 -{
   74.99 -	int tmpAddress = gbDataMBC1.mapperROMBank << 14;
  74.100 -
  74.101 -	// check current model
  74.102 -	if (gbDataMBC1.mapperMemoryModel == 1)
  74.103 -	{
  74.104 -		// model is 16/8, so we have a high address in use
  74.105 -		tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19;
  74.106 -	}
  74.107 -
  74.108 -	tmpAddress       &= gbRomSizeMask;
  74.109 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.110 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.111 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.112 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.113 -
  74.114 -	if (gbRamSize)
  74.115 -	{
  74.116 -		gbMemoryMap[0x0a] = &gbRam[gbDataMBC1.mapperRAMAddress];
  74.117 -		gbMemoryMap[0x0b] = &gbRam[gbDataMBC1.mapperRAMAddress + 0x1000];
  74.118 -	}
  74.119 -}
  74.120 -
  74.121 -mapperMBC2 gbDataMBC2 = {
  74.122 -	0, // RAM enable
  74.123 -	1 // ROM bank
  74.124 -};
  74.125 -
  74.126 -// MBC2 ROM write registers
  74.127 -void mapperMBC2ROM(u16 address, u8 value)
  74.128 -{
  74.129 -	switch (address & 0x6000)
  74.130 -	{
  74.131 -	case 0x0000: // RAM enable
  74.132 -		if (!(address & 0x0100))
  74.133 -		{
  74.134 -			gbDataMBC2.mapperRAMEnable = (value & 0x0f) == 0x0a;
  74.135 -		}
  74.136 -		break;
  74.137 -	case 0x2000: // ROM bank select
  74.138 -		if (address & 0x0100)
  74.139 -		{
  74.140 -			value &= 0x0f;
  74.141 -
  74.142 -			if (value == 0)
  74.143 -				value = 1;
  74.144 -			if (gbDataMBC2.mapperROMBank != value)
  74.145 -			{
  74.146 -				gbDataMBC2.mapperROMBank = value;
  74.147 -
  74.148 -				int tmpAddress = value << 14;
  74.149 -
  74.150 -				tmpAddress &= gbRomSizeMask;
  74.151 -
  74.152 -				gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.153 -				gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.154 -				gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.155 -				gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.156 -			}
  74.157 -		}
  74.158 -		break;
  74.159 -	}
  74.160 -}
  74.161 -
  74.162 -// MBC2 RAM write
  74.163 -void mapperMBC2RAM(u16 address, u8 value)
  74.164 -{
  74.165 -	if (gbDataMBC2.mapperRAMEnable)
  74.166 -	{
  74.167 -		if (gbRamSize && address < 0xa200)
  74.168 -		{
  74.169 -			gbWriteMemoryQuick(address, value);
  74.170 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.171 -		}
  74.172 -	}
  74.173 -}
  74.174 -
  74.175 -void memoryUpdateMapMBC2()
  74.176 -{
  74.177 -	int tmpAddress = gbDataMBC2.mapperROMBank << 14;
  74.178 -
  74.179 -	tmpAddress &= gbRomSizeMask;
  74.180 -
  74.181 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.182 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.183 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.184 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.185 -}
  74.186 -
  74.187 -mapperMBC3 gbDataMBC3 = {
  74.188 -	0, // RAM enable
  74.189 -	1, // ROM bank
  74.190 -	0, // RAM bank
  74.191 -	0, // RAM address
  74.192 -	0, // timer clock latch
  74.193 -	0, // timer clock register
  74.194 -	0, // timer seconds
  74.195 -	0, // timer minutes
  74.196 -	0, // timer hours
  74.197 -	0, // timer days
  74.198 -	0, // timer control
  74.199 -	0, // timer latched seconds
  74.200 -	0, // timer latched minutes
  74.201 -	0, // timer latched hours
  74.202 -	0, // timer latched days
  74.203 -	0, // timer latched control
  74.204 -	(time_t)-1 // last time
  74.205 -};
  74.206 -
  74.207 -void memoryUpdateMBC3Clock()
  74.208 -{
  74.209 -	time_t now;
  74.210 -
  74.211 -	if (VBAMovieActive() || VBAMovieLoading())
  74.212 -		now = (time_t)(VBAMovieGetId() + VBAMovieGetFrameCounter()/60); /// FIXME: is /60 the right factor?
  74.213 -	else
  74.214 -		now = time(NULL);
  74.215 -
  74.216 -	time_t diff = now - gbDataMBC3.mapperLastTime;
  74.217 -	if (diff > 0)
  74.218 -	{
  74.219 -		// update the clock according to the last update time
  74.220 -		gbDataMBC3.mapperSeconds += (int)(diff % 60);
  74.221 -		if (gbDataMBC3.mapperSeconds > 59)
  74.222 -		{
  74.223 -			gbDataMBC3.mapperSeconds -= 60;
  74.224 -			gbDataMBC3.mapperMinutes++;
  74.225 -		}
  74.226 -
  74.227 -		diff /= 60;
  74.228 -
  74.229 -		gbDataMBC3.mapperMinutes += (int)(diff % 60);
  74.230 -		if (gbDataMBC3.mapperMinutes > 60)
  74.231 -		{
  74.232 -			gbDataMBC3.mapperMinutes -= 60;
  74.233 -			gbDataMBC3.mapperHours++;
  74.234 -		}
  74.235 -
  74.236 -		diff /= 60;
  74.237 -
  74.238 -		gbDataMBC3.mapperHours += (int)(diff % 24);
  74.239 -		if (gbDataMBC3.mapperHours > 24)
  74.240 -		{
  74.241 -			gbDataMBC3.mapperHours -= 24;
  74.242 -			gbDataMBC3.mapperDays++;
  74.243 -		}
  74.244 -		diff /= 24;
  74.245 -
  74.246 -		gbDataMBC3.mapperDays += (int)diff;
  74.247 -		if (gbDataMBC3.mapperDays > 255)
  74.248 -		{
  74.249 -			if (gbDataMBC3.mapperDays > 511)
  74.250 -			{
  74.251 -				gbDataMBC3.mapperDays    %= 512;
  74.252 -				gbDataMBC3.mapperControl |= 0x80;
  74.253 -			}
  74.254 -			gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) |
  74.255 -			                           (gbDataMBC3.mapperDays > 255 ? 1 : 0);
  74.256 -		}
  74.257 -	}
  74.258 -	gbDataMBC3.mapperLastTime = now;
  74.259 -}
  74.260 -
  74.261 -// MBC3 ROM write registers
  74.262 -void mapperMBC3ROM(u16 address, u8 value)
  74.263 -{
  74.264 -	int tmpAddress = 0;
  74.265 -
  74.266 -	switch (address & 0x6000)
  74.267 -	{
  74.268 -	case 0x0000: // RAM enable register
  74.269 -		gbDataMBC3.mapperRAMEnable = ((value & 0x0a) == 0x0a ? 1 : 0);
  74.270 -		break;
  74.271 -	case 0x2000: // ROM bank select
  74.272 -		value = value & 0x7f;
  74.273 -		if (value == 0)
  74.274 -			value = 1;
  74.275 -		if (value == gbDataMBC3.mapperROMBank)
  74.276 -			break;
  74.277 -
  74.278 -		tmpAddress = value << 14;
  74.279 -
  74.280 -		tmpAddress &= gbRomSizeMask;
  74.281 -		gbDataMBC3.mapperROMBank = value;
  74.282 -		gbMemoryMap[0x04]        = &gbRom[tmpAddress];
  74.283 -		gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
  74.284 -		gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
  74.285 -		gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
  74.286 -
  74.287 -		break;
  74.288 -	case 0x4000: // RAM bank select
  74.289 -		if (value < 8)
  74.290 -		{
  74.291 -			if (value == gbDataMBC3.mapperRAMBank)
  74.292 -				break;
  74.293 -			tmpAddress                  = value << 13;
  74.294 -			tmpAddress                 &= gbRamSizeMask;
  74.295 -			gbMemoryMap[0x0a]           = &gbRam[tmpAddress];
  74.296 -			gbMemoryMap[0x0b]           = &gbRam[tmpAddress + 0x1000];
  74.297 -			gbDataMBC3.mapperRAMBank    = value;
  74.298 -			gbDataMBC3.mapperRAMAddress = tmpAddress;
  74.299 -		}
  74.300 -		else
  74.301 -		{
  74.302 -			if (gbDataMBC3.mapperRAMEnable)
  74.303 -			{
  74.304 -				gbDataMBC3.mapperRAMBank = -1;
  74.305 -
  74.306 -				gbDataMBC3.mapperClockRegister = value;
  74.307 -			}
  74.308 -		}
  74.309 -		break;
  74.310 -	case 0x6000: // clock latch
  74.311 -		if (gbDataMBC3.mapperClockLatch == 0 && value == 1)
  74.312 -		{
  74.313 -			memoryUpdateMBC3Clock();
  74.314 -			gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds;
  74.315 -			gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes;
  74.316 -			gbDataMBC3.mapperLHours   = gbDataMBC3.mapperHours;
  74.317 -			gbDataMBC3.mapperLDays    = gbDataMBC3.mapperDays;
  74.318 -			gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl;
  74.319 -		}
  74.320 -		if (value == 0x00 || value == 0x01)
  74.321 -			gbDataMBC3.mapperClockLatch = value;
  74.322 -		break;
  74.323 -	}
  74.324 -}
  74.325 -
  74.326 -// MBC3 RAM write
  74.327 -void mapperMBC3RAM(u16 address, u8 value)
  74.328 -{
  74.329 -	if (gbDataMBC3.mapperRAMEnable)
  74.330 -	{
  74.331 -		if (gbDataMBC3.mapperRAMBank != -1)
  74.332 -		{
  74.333 -			if (gbRamSize)
  74.334 -			{
  74.335 -				gbWriteMemoryQuick(address, value);
  74.336 -				systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.337 -			}
  74.338 -		}
  74.339 -		else
  74.340 -		{
  74.341 -			time_t tmp; //Small kludge to get it working on some 64 bit systems.
  74.342 -			if (VBAMovieActive() || VBAMovieLoading())
  74.343 -				gbDataMBC3.mapperLastTime = VBAMovieGetId() + VBAMovieGetFrameCounter()/60;
  74.344 -			else {
  74.345 -				time(&tmp);
  74.346 -				gbDataMBC3.mapperLastTime=(u32)tmp;
  74.347 -			}
  74.348 -			systemScreenMessage(ctime(&tmp), 4);
  74.349 -			gbDataMBC3.mapperLastTime=(u32)tmp;
  74.350 -
  74.351 -			switch (gbDataMBC3.mapperClockRegister)
  74.352 -			{
  74.353 -			case 0x08:
  74.354 -				gbDataMBC3.mapperSeconds = value;
  74.355 -				break;
  74.356 -			case 0x09:
  74.357 -				gbDataMBC3.mapperMinutes = value;
  74.358 -				break;
  74.359 -			case 0x0a:
  74.360 -				gbDataMBC3.mapperHours = value;
  74.361 -				break;
  74.362 -			case 0x0b:
  74.363 -				gbDataMBC3.mapperDays = value;
  74.364 -				break;
  74.365 -			case 0x0c:
  74.366 -				if (gbDataMBC3.mapperControl & 0x80)
  74.367 -					gbDataMBC3.mapperControl = 0x80 | value;
  74.368 -				else
  74.369 -					gbDataMBC3.mapperControl = value;
  74.370 -				break;
  74.371 -			}
  74.372 -		}
  74.373 -	}
  74.374 -}
  74.375 -
  74.376 -// MBC3 read RAM
  74.377 -u8 mapperMBC3ReadRAM(u16 address)
  74.378 -{
  74.379 -	if (gbDataMBC3.mapperRAMEnable)
  74.380 -	{
  74.381 -		if (gbDataMBC3.mapperRAMBank != -1)
  74.382 -		{
  74.383 -			return gbReadMemoryQuick(address);
  74.384 -		}
  74.385 -
  74.386 -		switch (gbDataMBC3.mapperClockRegister)
  74.387 -		{
  74.388 -		case 0x08:
  74.389 -			return gbDataMBC3.mapperLSeconds;
  74.390 -			break;
  74.391 -		case 0x09:
  74.392 -			return gbDataMBC3.mapperLMinutes;
  74.393 -			break;
  74.394 -		case 0x0a:
  74.395 -			return gbDataMBC3.mapperLHours;
  74.396 -			break;
  74.397 -		case 0x0b:
  74.398 -			return gbDataMBC3.mapperLDays;
  74.399 -			break;
  74.400 -		case 0x0c:
  74.401 -			return gbDataMBC3.mapperLControl;
  74.402 -		}
  74.403 -	}
  74.404 -	return 0;
  74.405 -}
  74.406 -
  74.407 -void memoryUpdateMapMBC3()
  74.408 -{
  74.409 -	int tmpAddress = gbDataMBC3.mapperROMBank << 14;
  74.410 -
  74.411 -	tmpAddress &= gbRomSizeMask;
  74.412 -
  74.413 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.414 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.415 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.416 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.417 -
  74.418 -	if (gbDataMBC3.mapperRAMBank >= 0 && gbRamSize)
  74.419 -	{
  74.420 -		tmpAddress        = gbDataMBC3.mapperRAMBank << 13;
  74.421 -		tmpAddress       &= gbRamSizeMask;
  74.422 -		gbMemoryMap[0x0a] = &gbRam[tmpAddress];
  74.423 -		gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
  74.424 -	}
  74.425 -}
  74.426 -
  74.427 -mapperMBC5 gbDataMBC5 = {
  74.428 -	0, // RAM enable
  74.429 -	1, // ROM bank
  74.430 -	0, // RAM bank
  74.431 -	0, // ROM high address
  74.432 -	0, // RAM address
  74.433 -	0 // is rumble cartridge?
  74.434 -};
  74.435 -
  74.436 -// MBC5 ROM write registers
  74.437 -void mapperMBC5ROM(u16 address, u8 value)
  74.438 -{
  74.439 -	int tmpAddress = 0;
  74.440 -
  74.441 -	switch (address & 0x6000)
  74.442 -	{
  74.443 -	case 0x0000: // RAM enable register
  74.444 -		gbDataMBC5.mapperRAMEnable = ((value & 0x0a) == 0x0a ? 1 : 0);
  74.445 -		break;
  74.446 -	case 0x2000: // ROM bank select
  74.447 -		if (address < 0x3000)
  74.448 -		{
  74.449 -			value = value & 0xff;
  74.450 -			if (value == gbDataMBC5.mapperROMBank)
  74.451 -				break;
  74.452 -
  74.453 -			tmpAddress = (value << 14) | (gbDataMBC5.mapperROMHighAddress << 22) ;
  74.454 -
  74.455 -			tmpAddress &= gbRomSizeMask;
  74.456 -			gbDataMBC5.mapperROMBank = value;
  74.457 -			gbMemoryMap[0x04]        = &gbRom[tmpAddress];
  74.458 -			gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
  74.459 -			gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
  74.460 -			gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
  74.461 -		}
  74.462 -		else
  74.463 -		{
  74.464 -			value = value & 1;
  74.465 -			if (value == gbDataMBC5.mapperROMHighAddress)
  74.466 -				break;
  74.467 -
  74.468 -			tmpAddress = (gbDataMBC5.mapperROMBank << 14) | (value << 22);
  74.469 -
  74.470 -			tmpAddress &= gbRomSizeMask;
  74.471 -			gbDataMBC5.mapperROMHighAddress = value;
  74.472 -			gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.473 -			gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.474 -			gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.475 -			gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.476 -		}
  74.477 -		break;
  74.478 -	case 0x4000: // RAM bank select
  74.479 -		if (gbDataMBC5.isRumbleCartridge)
  74.480 -			value &= 0x07;
  74.481 -		else
  74.482 -			value &= 0x0f;
  74.483 -		if (value == gbDataMBC5.mapperRAMBank)
  74.484 -			break;
  74.485 -		tmpAddress  = value << 13;
  74.486 -		tmpAddress &= gbRamSizeMask;
  74.487 -		if (gbRamSize)
  74.488 -		{
  74.489 -			gbMemoryMap[0x0a] = &gbRam[tmpAddress];
  74.490 -			gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
  74.491 -
  74.492 -			gbDataMBC5.mapperRAMBank    = value;
  74.493 -			gbDataMBC5.mapperRAMAddress = tmpAddress;
  74.494 -		}
  74.495 -		break;
  74.496 -	}
  74.497 -}
  74.498 -
  74.499 -// MBC5 RAM write
  74.500 -void mapperMBC5RAM(u16 address, u8 value)
  74.501 -{
  74.502 -	if (gbDataMBC5.mapperRAMEnable)
  74.503 -	{
  74.504 -		if (gbRamSize)
  74.505 -		{
  74.506 -			gbWriteMemoryQuick(address, value);
  74.507 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.508 -		}
  74.509 -	}
  74.510 -}
  74.511 -
  74.512 -void memoryUpdateMapMBC5()
  74.513 -{
  74.514 -	int tmpAddress = (gbDataMBC5.mapperROMBank << 14) |
  74.515 -	                 (gbDataMBC5.mapperROMHighAddress << 22) ;
  74.516 -
  74.517 -	tmpAddress       &= gbRomSizeMask;
  74.518 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.519 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.520 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.521 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.522 -
  74.523 -	if (gbRamSize)
  74.524 -	{
  74.525 -		tmpAddress        = gbDataMBC5.mapperRAMBank << 13;
  74.526 -		tmpAddress       &= gbRamSizeMask;
  74.527 -		gbMemoryMap[0x0a] = &gbRam[tmpAddress];
  74.528 -		gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
  74.529 -	}
  74.530 -}
  74.531 -
  74.532 -mapperMBC7 gbDataMBC7 = {
  74.533 -	0, // RAM enable
  74.534 -	1, // ROM bank
  74.535 -	0, // RAM bank
  74.536 -	0, // RAM address
  74.537 -	0, // chip select
  74.538 -	0, // ??
  74.539 -	0, // mapper state
  74.540 -	0, // buffer for receiving serial data
  74.541 -	0, // idle state
  74.542 -	0, // count of bits received
  74.543 -	0, // command received
  74.544 -	0, // address received
  74.545 -	0, // write enable
  74.546 -	0, // value to return on ram
  74.547 -};
  74.548 -
  74.549 -// MBC7 ROM write registers
  74.550 -void mapperMBC7ROM(u16 address, u8 value)
  74.551 -{
  74.552 -	int tmpAddress = 0;
  74.553 -
  74.554 -	switch (address & 0x6000)
  74.555 -	{
  74.556 -	case 0x0000:
  74.557 -		break;
  74.558 -	case 0x2000: // ROM bank select
  74.559 -		value = value & 0x7f;
  74.560 -		if (value == 0)
  74.561 -			value = 1;
  74.562 -
  74.563 -		if (value == gbDataMBC7.mapperROMBank)
  74.564 -			break;
  74.565 -
  74.566 -		tmpAddress = (value << 14);
  74.567 -
  74.568 -		tmpAddress &= gbRomSizeMask;
  74.569 -		gbDataMBC7.mapperROMBank = value;
  74.570 -		gbMemoryMap[0x04]        = &gbRom[tmpAddress];
  74.571 -		gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
  74.572 -		gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
  74.573 -		gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
  74.574 -		break;
  74.575 -	case 0x4000: // RAM bank select/enable
  74.576 -		if (value < 8)
  74.577 -		{
  74.578 -			tmpAddress        = (value&3) << 13;
  74.579 -			tmpAddress       &= gbRamSizeMask;
  74.580 -			gbMemoryMap[0x0a] = &gbMemory[0xa000];
  74.581 -			gbMemoryMap[0x0b] = &gbMemory[0xb000];
  74.582 -
  74.583 -			gbDataMBC7.mapperRAMBank    = value;
  74.584 -			gbDataMBC7.mapperRAMAddress = tmpAddress;
  74.585 -			gbDataMBC7.mapperRAMEnable  = 0;
  74.586 -		}
  74.587 -		else
  74.588 -		{
  74.589 -			gbDataMBC7.mapperRAMEnable = 0;
  74.590 -		}
  74.591 -		break;
  74.592 -	}
  74.593 -}
  74.594 -
  74.595 -// MBC7 read RAM
  74.596 -u8 mapperMBC7ReadRAM(u16 address)
  74.597 -{
  74.598 -	switch (address & 0xa0f0)
  74.599 -	{
  74.600 -	case 0xa000:
  74.601 -	case 0xa010:
  74.602 -	case 0xa060:
  74.603 -	case 0xa070:
  74.604 -		return 0;
  74.605 -	case 0xa020:
  74.606 -		// sensor X low byte
  74.607 -		return systemGetSensorX() & 255;
  74.608 -	case 0xa030:
  74.609 -		// sensor X high byte
  74.610 -		return systemGetSensorX() >> 8;
  74.611 -	case 0xa040:
  74.612 -		// sensor Y low byte
  74.613 -		return systemGetSensorY() & 255;
  74.614 -	case 0xa050:
  74.615 -		// sensor Y high byte
  74.616 -		return systemGetSensorY() >> 8;
  74.617 -	case 0xa080:
  74.618 -		return gbDataMBC7.value;
  74.619 -	}
  74.620 -	return 0xff;
  74.621 -}
  74.622 -
  74.623 -// MBC7 RAM write
  74.624 -void mapperMBC7RAM(u16 address, u8 value)
  74.625 -{
  74.626 -	if (address == 0xa080)
  74.627 -	{
  74.628 -		// special processing needed
  74.629 -		int oldCs = gbDataMBC7.cs, oldSk = gbDataMBC7.sk;
  74.630 -
  74.631 -		gbDataMBC7.cs = value>>7;
  74.632 -		gbDataMBC7.sk = (value>>6)&1;
  74.633 -
  74.634 -		if (!oldCs && gbDataMBC7.cs)
  74.635 -		{
  74.636 -			if (gbDataMBC7.state == 5)
  74.637 -			{
  74.638 -				if (gbDataMBC7.writeEnable)
  74.639 -				{
  74.640 -					gbWriteMemoryQuick(0xa000+gbDataMBC7.address*2, gbDataMBC7.buffer>>8);
  74.641 -					gbWriteMemoryQuick(0xa000+gbDataMBC7.address*2+1, gbDataMBC7.buffer&0xff);
  74.642 -					systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.643 -				}
  74.644 -				gbDataMBC7.state = 0;
  74.645 -				gbDataMBC7.value = 1;
  74.646 -			}
  74.647 -			else
  74.648 -			{
  74.649 -				gbDataMBC7.idle  = true;
  74.650 -				gbDataMBC7.state = 0;
  74.651 -			}
  74.652 -		}
  74.653 -
  74.654 -		if (!oldSk && gbDataMBC7.sk)
  74.655 -		{
  74.656 -			if (gbDataMBC7.idle)
  74.657 -			{
  74.658 -				if (value & 0x02)
  74.659 -				{
  74.660 -					gbDataMBC7.idle  = false;
  74.661 -					gbDataMBC7.count = 0;
  74.662 -					gbDataMBC7.state = 1;
  74.663 -				}
  74.664 -			}
  74.665 -			else
  74.666 -			{
  74.667 -				switch (gbDataMBC7.state)
  74.668 -				{
  74.669 -				case 1:
  74.670 -					// receiving command
  74.671 -					gbDataMBC7.buffer <<= 1;
  74.672 -					gbDataMBC7.buffer  |= (value & 0x02) ? 1 : 0;
  74.673 -					gbDataMBC7.count++;
  74.674 -					if (gbDataMBC7.count == 2)
  74.675 -					{
  74.676 -						// finished receiving command
  74.677 -						gbDataMBC7.state = 2;
  74.678 -						gbDataMBC7.count = 0;
  74.679 -						gbDataMBC7.code  = gbDataMBC7.buffer & 3;
  74.680 -					}
  74.681 -					break;
  74.682 -				case 2:
  74.683 -					// receive address
  74.684 -					gbDataMBC7.buffer <<= 1;
  74.685 -					gbDataMBC7.buffer  |= (value&0x02) ? 1 : 0;
  74.686 -					gbDataMBC7.count++;
  74.687 -					if (gbDataMBC7.count == 8)
  74.688 -					{
  74.689 -						// finish receiving
  74.690 -						gbDataMBC7.state   = 3;
  74.691 -						gbDataMBC7.count   = 0;
  74.692 -						gbDataMBC7.address = gbDataMBC7.buffer&0xff;
  74.693 -						if (gbDataMBC7.code == 0)
  74.694 -						{
  74.695 -							if ((gbDataMBC7.address>>6) == 0)
  74.696 -							{
  74.697 -								gbDataMBC7.writeEnable = 0;
  74.698 -								gbDataMBC7.state       = 0;
  74.699 -							}
  74.700 -							else if ((gbDataMBC7.address>>6) == 3)
  74.701 -							{
  74.702 -								gbDataMBC7.writeEnable = 1;
  74.703 -								gbDataMBC7.state       = 0;
  74.704 -							}
  74.705 -						}
  74.706 -					}
  74.707 -					break;
  74.708 -				case 3:
  74.709 -					gbDataMBC7.buffer <<= 1;
  74.710 -					gbDataMBC7.buffer  |= (value&0x02) ? 1 : 0;
  74.711 -					gbDataMBC7.count++;
  74.712 -
  74.713 -					switch (gbDataMBC7.code)
  74.714 -					{
  74.715 -					case 0:
  74.716 -						if (gbDataMBC7.count == 16)
  74.717 -						{
  74.718 -							if ((gbDataMBC7.address>>6) == 0)
  74.719 -							{
  74.720 -								gbDataMBC7.writeEnable = 0;
  74.721 -								gbDataMBC7.state       = 0;
  74.722 -							}
  74.723 -							else if ((gbDataMBC7.address>>6) == 1)
  74.724 -							{
  74.725 -								if (gbDataMBC7.writeEnable)
  74.726 -								{
  74.727 -									for (int i = 0; i < 256; i++)
  74.728 -									{
  74.729 -										gbWriteMemoryQuick(0xa000+i*2, gbDataMBC7.buffer >> 8);
  74.730 -										gbWriteMemoryQuick(0xa000+i*2+1, gbDataMBC7.buffer & 0xff);
  74.731 -										systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.732 -									}
  74.733 -								}
  74.734 -								gbDataMBC7.state = 5;
  74.735 -							}
  74.736 -							else if ((gbDataMBC7.address>>6) == 2)
  74.737 -							{
  74.738 -								if (gbDataMBC7.writeEnable)
  74.739 -								{
  74.740 -									for (int i = 0; i < 256; i++)
  74.741 -										WRITE16LE((u16 *)&gbMemory[0xa000+i*2], 0xffff);
  74.742 -									systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.743 -								}
  74.744 -								gbDataMBC7.state = 5;
  74.745 -							}
  74.746 -							else if ((gbDataMBC7.address>>6) == 3)
  74.747 -							{
  74.748 -								gbDataMBC7.writeEnable = 1;
  74.749 -								gbDataMBC7.state       = 0;
  74.750 -							}
  74.751 -							gbDataMBC7.count = 0;
  74.752 -						}
  74.753 -						break;
  74.754 -					case 1:
  74.755 -						if (gbDataMBC7.count == 16)
  74.756 -						{
  74.757 -							gbDataMBC7.count = 0;
  74.758 -							gbDataMBC7.state = 5;
  74.759 -							gbDataMBC7.value = 0;
  74.760 -						}
  74.761 -						break;
  74.762 -					case 2:
  74.763 -						if (gbDataMBC7.count == 1)
  74.764 -						{
  74.765 -							gbDataMBC7.state  = 4;
  74.766 -							gbDataMBC7.count  = 0;
  74.767 -							gbDataMBC7.buffer = (gbReadMemoryQuick(0xa000+gbDataMBC7.address*2)<<8)|
  74.768 -							                    (gbReadMemoryQuick(0xa000+gbDataMBC7.address*2+1));
  74.769 -						}
  74.770 -						break;
  74.771 -					case 3:
  74.772 -						if (gbDataMBC7.count == 16)
  74.773 -						{
  74.774 -							gbDataMBC7.count  = 0;
  74.775 -							gbDataMBC7.state  = 5;
  74.776 -							gbDataMBC7.value  = 0;
  74.777 -							gbDataMBC7.buffer = 0xffff;
  74.778 -						}
  74.779 -						break;
  74.780 -					}
  74.781 -					break;
  74.782 -				}
  74.783 -			}
  74.784 -		}
  74.785 -
  74.786 -		if (oldSk && !gbDataMBC7.sk)
  74.787 -		{
  74.788 -			if (gbDataMBC7.state == 4)
  74.789 -			{
  74.790 -				gbDataMBC7.value    = (gbDataMBC7.buffer & 0x8000) ? 1 : 0;
  74.791 -				gbDataMBC7.buffer <<= 1;
  74.792 -				gbDataMBC7.count++;
  74.793 -				if (gbDataMBC7.count == 16)
  74.794 -				{
  74.795 -					gbDataMBC7.count = 0;
  74.796 -					gbDataMBC7.state = 0;
  74.797 -				}
  74.798 -			}
  74.799 -		}
  74.800 -	}
  74.801 -}
  74.802 -
  74.803 -void memoryUpdateMapMBC7()
  74.804 -{
  74.805 -	int tmpAddress = (gbDataMBC5.mapperROMBank << 14);
  74.806 -
  74.807 -	tmpAddress       &= gbRomSizeMask;
  74.808 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.809 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.810 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.811 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.812 -}
  74.813 -
  74.814 -mapperHuC1 gbDataHuC1 = {
  74.815 -	0, // RAM enable
  74.816 -	1, // ROM bank
  74.817 -	0, // RAM bank
  74.818 -	0, // memory model
  74.819 -	0, // ROM high address
  74.820 -	0 // RAM address
  74.821 -};
  74.822 -
  74.823 -// HuC1 ROM write registers
  74.824 -void mapperHuC1ROM(u16 address, u8 value)
  74.825 -{
  74.826 -	int tmpAddress = 0;
  74.827 -
  74.828 -	switch (address & 0x6000)
  74.829 -	{
  74.830 -	case 0x0000: // RAM enable register
  74.831 -		gbDataHuC1.mapperRAMEnable = ((value & 0x0a) == 0x0a ? 1 : 0);
  74.832 -		break;
  74.833 -	case 0x2000: // ROM bank select
  74.834 -		value = value & 0x3f;
  74.835 -		if (value == 0)
  74.836 -			value = 1;
  74.837 -		if (value == gbDataHuC1.mapperROMBank)
  74.838 -			break;
  74.839 -
  74.840 -		tmpAddress = value << 14;
  74.841 -
  74.842 -		tmpAddress &= gbRomSizeMask;
  74.843 -		gbDataHuC1.mapperROMBank = value;
  74.844 -		gbMemoryMap[0x04]        = &gbRom[tmpAddress];
  74.845 -		gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
  74.846 -		gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
  74.847 -		gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
  74.848 -		break;
  74.849 -	case 0x4000: // RAM bank select
  74.850 -		if (gbDataHuC1.mapperMemoryModel == 1)
  74.851 -		{
  74.852 -			// 4/32 model, RAM bank switching provided
  74.853 -			value = value & 0x03;
  74.854 -			if (value == gbDataHuC1.mapperRAMBank)
  74.855 -				break;
  74.856 -			tmpAddress                  = value << 13;
  74.857 -			tmpAddress                 &= gbRamSizeMask;
  74.858 -			gbMemoryMap[0x0a]           = &gbRam[tmpAddress];
  74.859 -			gbMemoryMap[0x0b]           = &gbRam[tmpAddress + 0x1000];
  74.860 -			gbDataHuC1.mapperRAMBank    = value;
  74.861 -			gbDataHuC1.mapperRAMAddress = tmpAddress;
  74.862 -		}
  74.863 -		else
  74.864 -		{
  74.865 -			// 16/8, set the high address
  74.866 -			gbDataHuC1.mapperROMHighAddress = value & 0x03;
  74.867 -			tmpAddress        = gbDataHuC1.mapperROMBank << 14;
  74.868 -			tmpAddress       |= (gbDataHuC1.mapperROMHighAddress) << 19;
  74.869 -			tmpAddress       &= gbRomSizeMask;
  74.870 -			gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.871 -			gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.872 -			gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.873 -			gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.874 -		}
  74.875 -		break;
  74.876 -	case 0x6000: // memory model select
  74.877 -		gbDataHuC1.mapperMemoryModel = value & 1;
  74.878 -		break;
  74.879 -	}
  74.880 -}
  74.881 -
  74.882 -// HuC1 RAM write
  74.883 -void mapperHuC1RAM(u16 address, u8 value)
  74.884 -{
  74.885 -	if (gbDataHuC1.mapperRAMEnable)
  74.886 -	{
  74.887 -		if (gbRamSize)
  74.888 -		{
  74.889 -			gbWriteMemoryQuick(address, value);
  74.890 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.891 -		}
  74.892 -	}
  74.893 -}
  74.894 -
  74.895 -void memoryUpdateMapHuC1()
  74.896 -{
  74.897 -	int tmpAddress = gbDataHuC1.mapperROMBank << 14;
  74.898 -
  74.899 -	tmpAddress &= gbRomSizeMask;
  74.900 -
  74.901 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
  74.902 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
  74.903 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
  74.904 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
  74.905 -
  74.906 -	if (gbRamSize)
  74.907 -	{
  74.908 -		tmpAddress        = gbDataHuC1.mapperRAMBank << 13;
  74.909 -		tmpAddress       &= gbRamSizeMask;
  74.910 -		gbMemoryMap[0x0a] = &gbRam[tmpAddress];
  74.911 -		gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
  74.912 -	}
  74.913 -}
  74.914 -
  74.915 -mapperHuC3 gbDataHuC3 = {
  74.916 -	0, // RAM enable
  74.917 -	1, // ROM bank
  74.918 -	0, // RAM bank
  74.919 -	0, // RAM address
  74.920 -	0, // RAM flag
  74.921 -	0 // RAM read value
  74.922 -};
  74.923 -
  74.924 -// HuC3 ROM write registers
  74.925 -void mapperHuC3ROM(u16 address, u8 value)
  74.926 -{
  74.927 -	int tmpAddress = 0;
  74.928 -
  74.929 -	switch (address & 0x6000)
  74.930 -	{
  74.931 -	case 0x0000: // RAM enable register
  74.932 -		gbDataHuC3.mapperRAMEnable = (value == 0x0a ? 1 : 0);
  74.933 -		gbDataHuC3.mapperRAMFlag   = value;
  74.934 -		if (gbDataHuC3.mapperRAMFlag != 0x0a)
  74.935 -			gbDataHuC3.mapperRAMBank = -1;
  74.936 -		break;
  74.937 -	case 0x2000: // ROM bank select
  74.938 -		value = value & 0x7f;
  74.939 -		if (value == 0)
  74.940 -			value = 1;
  74.941 -		if (value == gbDataHuC3.mapperROMBank)
  74.942 -			break;
  74.943 -
  74.944 -		tmpAddress = value << 14;
  74.945 -
  74.946 -		tmpAddress &= gbRomSizeMask;
  74.947 -		gbDataHuC3.mapperROMBank = value;
  74.948 -		gbMemoryMap[0x04]        = &gbRom[tmpAddress];
  74.949 -		gbMemoryMap[0x05]        = &gbRom[tmpAddress + 0x1000];
  74.950 -		gbMemoryMap[0x06]        = &gbRom[tmpAddress + 0x2000];
  74.951 -		gbMemoryMap[0x07]        = &gbRom[tmpAddress + 0x3000];
  74.952 -		break;
  74.953 -	case 0x4000: // RAM bank select
  74.954 -		value = value & 0x03;
  74.955 -		if (value == gbDataHuC3.mapperRAMBank)
  74.956 -			break;
  74.957 -		tmpAddress                  = value << 13;
  74.958 -		tmpAddress                 &= gbRamSizeMask;
  74.959 -		gbMemoryMap[0x0a]           = &gbRam[tmpAddress];
  74.960 -		gbMemoryMap[0x0b]           = &gbRam[tmpAddress + 0x1000];
  74.961 -		gbDataHuC3.mapperRAMBank    = value;
  74.962 -		gbDataHuC3.mapperRAMAddress = tmpAddress;
  74.963 -		break;
  74.964 -	case 0x6000: // nothing to do!
  74.965 -		break;
  74.966 -	}
  74.967 -}
  74.968 -
  74.969 -// HuC3 read RAM
  74.970 -u8 mapperHuC3ReadRAM(u16 address)
  74.971 -{
  74.972 -	if (gbDataHuC3.mapperRAMFlag > 0x0b &&
  74.973 -	    gbDataHuC3.mapperRAMFlag < 0x0e)
  74.974 -	{
  74.975 -		if (gbDataHuC3.mapperRAMFlag != 0x0c)
  74.976 -			return 1;
  74.977 -		return gbDataHuC3.mapperRAMValue;
  74.978 -	}
  74.979 -	else
  74.980 -		return gbReadMemoryQuick(address);
  74.981 -}
  74.982 -
  74.983 -// HuC3 RAM write
  74.984 -void mapperHuC3RAM(u16 address, u8 value)
  74.985 -{
  74.986 -	int32 *p;
  74.987 -
  74.988 -	if (gbDataHuC3.mapperRAMFlag < 0x0b ||
  74.989 -	    gbDataHuC3.mapperRAMFlag > 0x0e)
  74.990 -	{
  74.991 -		if (gbDataHuC3.mapperRAMEnable)
  74.992 -		{
  74.993 -			if (gbRamSize)
  74.994 -			{
  74.995 -				gbWriteMemoryQuick(address, value);
  74.996 -				systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  74.997 -			}
  74.998 -		}
  74.999 -	}
 74.1000 -	else
 74.1001 -	{
 74.1002 -		if (gbDataHuC3.mapperRAMFlag == 0x0b)
 74.1003 -		{
 74.1004 -			if (value == 0x62)
 74.1005 -			{
 74.1006 -				gbDataHuC3.mapperRAMValue = 1;
 74.1007 -			}
 74.1008 -			else
 74.1009 -			{
 74.1010 -				switch (value & 0xf0)
 74.1011 -				{
 74.1012 -				case 0x10:
 74.1013 -					p = &gbDataHuC3.mapperRegister2;
 74.1014 -					gbDataHuC3.mapperRAMValue = *(p+gbDataHuC3.mapperRegister1++);
 74.1015 -					if (gbDataHuC3.mapperRegister1 > 6)
 74.1016 -						gbDataHuC3.mapperRegister1 = 0;
 74.1017 -					break;
 74.1018 -				case 0x30:
 74.1019 -					p = &gbDataHuC3.mapperRegister2;
 74.1020 -					*(p+gbDataHuC3.mapperRegister1++) = value & 0x0f;
 74.1021 -					if (gbDataHuC3.mapperRegister1 > 6)
 74.1022 -						gbDataHuC3.mapperRegister1 = 0;
 74.1023 -					gbDataHuC3.mapperAddress =
 74.1024 -					    (gbDataHuC3.mapperRegister6 << 24) |
 74.1025 -					    (gbDataHuC3.mapperRegister5 << 16) |
 74.1026 -					    (gbDataHuC3.mapperRegister4 <<  8) |
 74.1027 -					    (gbDataHuC3.mapperRegister3 <<  4) |
 74.1028 -					    (gbDataHuC3.mapperRegister2);
 74.1029 -					break;
 74.1030 -				case 0x40:
 74.1031 -					gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0xf0) |
 74.1032 -					                             (value & 0x0f);
 74.1033 -					gbDataHuC3.mapperRegister2 = (gbDataHuC3.mapperAddress & 0x0f);
 74.1034 -					gbDataHuC3.mapperRegister3 = ((gbDataHuC3.mapperAddress>>4)&0x0f);
 74.1035 -					gbDataHuC3.mapperRegister4 = ((gbDataHuC3.mapperAddress>>8)&0x0f);
 74.1036 -					gbDataHuC3.mapperRegister5 = ((gbDataHuC3.mapperAddress>>16)&0x0f);
 74.1037 -					gbDataHuC3.mapperRegister6 = ((gbDataHuC3.mapperAddress>>24)&0x0f);
 74.1038 -					gbDataHuC3.mapperRegister7 = 0;
 74.1039 -					gbDataHuC3.mapperRegister8 = 0;
 74.1040 -					gbDataHuC3.mapperRAMValue  = 0;
 74.1041 -					break;
 74.1042 -				case 0x50:
 74.1043 -					gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) |
 74.1044 -					                             ((value << 4)&0x0f);
 74.1045 -					break;
 74.1046 -				default:
 74.1047 -					gbDataHuC3.mapperRAMValue = 1;
 74.1048 -					break;
 74.1049 -				}
 74.1050 -			}
 74.1051 -		}
 74.1052 -	}
 74.1053 -}
 74.1054 -
 74.1055 -void memoryUpdateMapHuC3()
 74.1056 -{
 74.1057 -	int tmpAddress = gbDataHuC3.mapperROMBank << 14;
 74.1058 -
 74.1059 -	tmpAddress       &= gbRomSizeMask;
 74.1060 -	gbMemoryMap[0x04] = &gbRom[tmpAddress];
 74.1061 -	gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
 74.1062 -	gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
 74.1063 -	gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
 74.1064 -
 74.1065 -	if (gbRamSize)
 74.1066 -	{
 74.1067 -		tmpAddress        = gbDataHuC3.mapperRAMBank << 13;
 74.1068 -		tmpAddress       &= gbRamSizeMask;
 74.1069 -		gbMemoryMap[0x0a] = &gbRam[tmpAddress];
 74.1070 -		gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
 74.1071 -	}
 74.1072 -}
 74.1073 -
    75.1 --- a/src/gb/gbMemory.h	Sat Mar 03 10:54:39 2012 -0600
    75.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.3 @@ -1,142 +0,0 @@
    75.4 -#ifndef VBA_GB_MEMORY_H
    75.5 -#define VBA_GB_MEMORY_H
    75.6 -
    75.7 -#if _MSC_VER > 1000
    75.8 -#pragma once
    75.9 -#endif // _MSC_VER > 1000
   75.10 -
   75.11 -#include "../Port.h"
   75.12 -
   75.13 -struct mapperMBC1
   75.14 -{
   75.15 -	int32 mapperRAMEnable;
   75.16 -	int32 mapperROMBank;
   75.17 -	int32 mapperRAMBank;
   75.18 -	int32 mapperMemoryModel;
   75.19 -	int32 mapperROMHighAddress;
   75.20 -	int32 mapperRAMAddress;
   75.21 -};
   75.22 -
   75.23 -struct mapperMBC2
   75.24 -{
   75.25 -	int32 mapperRAMEnable;
   75.26 -	int32 mapperROMBank;
   75.27 -};
   75.28 -
   75.29 -struct mapperMBC3
   75.30 -{
   75.31 -	int32  mapperRAMEnable;
   75.32 -	int32  mapperROMBank;
   75.33 -	int32  mapperRAMBank;
   75.34 -	int32  mapperRAMAddress;
   75.35 -	int32  mapperClockLatch;
   75.36 -	int32  mapperClockRegister;
   75.37 -	int32  mapperSeconds;
   75.38 -	int32  mapperMinutes;
   75.39 -	int32  mapperHours;
   75.40 -	int32  mapperDays;
   75.41 -	int32  mapperControl;
   75.42 -	int32  mapperLSeconds;
   75.43 -	int32  mapperLMinutes;
   75.44 -	int32  mapperLHours;
   75.45 -	int32  mapperLDays;
   75.46 -	int32  mapperLControl;
   75.47 -	//time_t mapperLastTime;
   75.48 -	u32 mapperLastTime;
   75.49 -};
   75.50 -
   75.51 -struct mapperMBC5
   75.52 -{
   75.53 -	int32 mapperRAMEnable;
   75.54 -	int32 mapperROMBank;
   75.55 -	int32 mapperRAMBank;
   75.56 -	int32 mapperROMHighAddress;
   75.57 -	int32 mapperRAMAddress;
   75.58 -	int32 isRumbleCartridge;
   75.59 -};
   75.60 -
   75.61 -struct mapperMBC7
   75.62 -{
   75.63 -	int32 mapperRAMEnable;
   75.64 -	int32 mapperROMBank;
   75.65 -	int32 mapperRAMBank;
   75.66 -	int32 mapperRAMAddress;
   75.67 -	int32 cs;
   75.68 -	int32 sk;
   75.69 -	int32 state;
   75.70 -	int32 buffer;
   75.71 -	int32 idle;
   75.72 -	int32 count;
   75.73 -	int32 code;
   75.74 -	int32 address;
   75.75 -	int32 writeEnable;
   75.76 -	int32 value;
   75.77 -};
   75.78 -
   75.79 -struct mapperHuC1
   75.80 -{
   75.81 -	int32 mapperRAMEnable;
   75.82 -	int32 mapperROMBank;
   75.83 -	int32 mapperRAMBank;
   75.84 -	int32 mapperMemoryModel;
   75.85 -	int32 mapperROMHighAddress;
   75.86 -	int32 mapperRAMAddress;
   75.87 -};
   75.88 -
   75.89 -struct mapperHuC3
   75.90 -{
   75.91 -	int32 mapperRAMEnable;
   75.92 -	int32 mapperROMBank;
   75.93 -	int32 mapperRAMBank;
   75.94 -	int32 mapperRAMAddress;
   75.95 -	int32 mapperAddress;
   75.96 -	int32 mapperRAMFlag;
   75.97 -	int32 mapperRAMValue;
   75.98 -	int32 mapperRegister1;
   75.99 -	int32 mapperRegister2;
  75.100 -	int32 mapperRegister3;
  75.101 -	int32 mapperRegister4;
  75.102 -	int32 mapperRegister5;
  75.103 -	int32 mapperRegister6;
  75.104 -	int32 mapperRegister7;
  75.105 -	int32 mapperRegister8;
  75.106 -};
  75.107 -
  75.108 -extern mapperMBC1 gbDataMBC1;
  75.109 -extern mapperMBC2 gbDataMBC2;
  75.110 -extern mapperMBC3 gbDataMBC3;
  75.111 -extern mapperMBC5 gbDataMBC5;
  75.112 -extern mapperHuC1 gbDataHuC1;
  75.113 -extern mapperHuC3 gbDataHuC3;
  75.114 -
  75.115 -void mapperMBC1ROM(u16, u8);
  75.116 -void mapperMBC1RAM(u16, u8);
  75.117 -void mapperMBC2ROM(u16, u8);
  75.118 -void mapperMBC2RAM(u16, u8);
  75.119 -void mapperMBC3ROM(u16, u8);
  75.120 -void mapperMBC3RAM(u16, u8);
  75.121 -u8   mapperMBC3ReadRAM(u16);
  75.122 -void mapperMBC5ROM(u16, u8);
  75.123 -void mapperMBC5RAM(u16, u8);
  75.124 -void mapperMBC7ROM(u16, u8);
  75.125 -void mapperMBC7RAM(u16, u8);
  75.126 -u8   mapperMBC7ReadRAM(u16);
  75.127 -void mapperHuC1ROM(u16, u8);
  75.128 -void mapperHuC1RAM(u16, u8);
  75.129 -void mapperHuC3ROM(u16, u8);
  75.130 -void mapperHuC3RAM(u16, u8);
  75.131 -u8   mapperHuC3ReadRAM(u16);
  75.132 -
  75.133 -//extern void (*mapper)(u16,u8);
  75.134 -//extern void (*mapperRAM)(u16,u8);
  75.135 -//extern u8 (*mapperReadRAM)(u16);
  75.136 -
  75.137 -extern void memoryUpdateMapMBC1();
  75.138 -extern void memoryUpdateMapMBC2();
  75.139 -extern void memoryUpdateMapMBC3();
  75.140 -extern void memoryUpdateMapMBC5();
  75.141 -extern void memoryUpdateMapMBC7();
  75.142 -extern void memoryUpdateMapHuC1();
  75.143 -extern void memoryUpdateMapHuC3();
  75.144 -
  75.145 -#endif // VBA_GB_MEMORY
    76.1 --- a/src/gb/gbPrinter.cpp	Sat Mar 03 10:54:39 2012 -0600
    76.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.3 @@ -1,234 +0,0 @@
    76.4 -#include <cstdio>
    76.5 -#include <cstring>
    76.6 -
    76.7 -#include "../common/System.h"
    76.8 -#include "gbPrinter.h"
    76.9 -
   76.10 -u8  gbPrinterStatus = 0;
   76.11 -int gbPrinterState  = 0;
   76.12 -u8  gbPrinterData[0x280*9];
   76.13 -u8  gbPrinterPacket[0x400];
   76.14 -int gbPrinterCount     = 0;
   76.15 -int gbPrinterDataCount = 0;
   76.16 -int gbPrinterDataSize  = 0;
   76.17 -int gbPrinterResult    = 0;
   76.18 -
   76.19 -bool gbPrinterCheckCRC()
   76.20 -{
   76.21 -	u16 crc = 0;
   76.22 -
   76.23 -	for (int i = 2; i < (6+gbPrinterDataSize); i++)
   76.24 -	{
   76.25 -		crc += gbPrinterPacket[i];
   76.26 -	}
   76.27 -
   76.28 -	int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
   76.29 -	             (gbPrinterPacket[7+gbPrinterDataSize]<<8);
   76.30 -
   76.31 -	return msgCrc == crc;
   76.32 -}
   76.33 -
   76.34 -void gbPrinterReset()
   76.35 -{
   76.36 -	gbPrinterState     = 0;
   76.37 -	gbPrinterDataSize  = 0;
   76.38 -	gbPrinterDataCount = 0;
   76.39 -	gbPrinterCount     = 0;
   76.40 -	gbPrinterStatus    = 0;
   76.41 -	gbPrinterResult    = 0;
   76.42 -}
   76.43 -
   76.44 -void gbPrinterShowData()
   76.45 -{
   76.46 -	systemGbPrint(gbPrinterData,
   76.47 -	              gbPrinterPacket[6],
   76.48 -	              gbPrinterPacket[7],
   76.49 -	              gbPrinterPacket[8],
   76.50 -	              gbPrinterPacket[9]);
   76.51 -	/*
   76.52 -	   allegro_init();
   76.53 -	   install_keyboard();
   76.54 -	   set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
   76.55 -	   PALETTE pal;
   76.56 -	   pal[0].r = 255;
   76.57 -	   pal[0].g = 255;
   76.58 -	   pal[0].b = 255;
   76.59 -	   pal[1].r = 168;
   76.60 -	   pal[1].g = 168;
   76.61 -	   pal[1].b = 168;
   76.62 -	   pal[2].r = 96;
   76.63 -	   pal[2].g = 96;
   76.64 -	   pal[2].b = 96;
   76.65 -	   pal[3].r = 0;
   76.66 -	   pal[3].g = 0;
   76.67 -	   pal[3].b = 0;
   76.68 -	   set_palette(pal);
   76.69 -	   acquire_screen();
   76.70 -	   u8 *data = gbPrinterData;
   76.71 -	   for(int y = 0; y < 0x12; y++) {
   76.72 -	   for(int x = 0; x < 0x14; x++) {
   76.73 -	    for(int k = 0; k < 8; k++) {
   76.74 -	      int a = *data++;
   76.75 -	      int b = *data++;
   76.76 -	      for(int j = 0; j < 8; j++) {
   76.77 -	        int mask = 1 << (7-j);
   76.78 -	        int c = 0;
   76.79 -	        if(a & mask)
   76.80 -	          c++;
   76.81 -	        if(b & mask)
   76.82 -	          c+=2;
   76.83 -	        putpixel(screen, x*8+j, y*8+k, c);
   76.84 -	      }
   76.85 -	    }
   76.86 -	   }
   76.87 -	   }
   76.88 -	   release_screen();
   76.89 -	   while(!keypressed()) {
   76.90 -	   }
   76.91 -	 */
   76.92 -}
   76.93 -
   76.94 -void gbPrinterReceiveData()
   76.95 -{
   76.96 -	if (gbPrinterPacket[3]) // compressed
   76.97 -	{
   76.98 -		u8 *data = &gbPrinterPacket[6];
   76.99 -		u8 *dest = &gbPrinterData[gbPrinterDataCount];
  76.100 -		int len  = 0;
  76.101 -		while (len < gbPrinterDataSize)
  76.102 -		{
  76.103 -			u8 control = *data++;
  76.104 -			if (control & 0x80) // repeated data
  76.105 -			{
  76.106 -				control &= 0x7f;
  76.107 -				control += 2;
  76.108 -				memset(dest, *data++, control);
  76.109 -				len  += control;
  76.110 -				dest += control;
  76.111 -			}
  76.112 -			else // raw data
  76.113 -			{
  76.114 -				control++;
  76.115 -				memcpy(dest, data, control);
  76.116 -				dest += control;
  76.117 -				data += control;
  76.118 -				len  += control;
  76.119 -			}
  76.120 -		}
  76.121 -	}
  76.122 -	else
  76.123 -	{
  76.124 -		memcpy(&gbPrinterData[gbPrinterDataCount],
  76.125 -		       &gbPrinterPacket[6],
  76.126 -		       gbPrinterDataSize);
  76.127 -		gbPrinterDataCount += gbPrinterDataSize;
  76.128 -	}
  76.129 -}
  76.130 -
  76.131 -void gbPrinterCommand()
  76.132 -{
  76.133 -	switch (gbPrinterPacket[2])
  76.134 -	{
  76.135 -	case 0x01:
  76.136 -		// reset/initialize packet
  76.137 -		gbPrinterDataCount = 0;
  76.138 -		gbPrinterStatus    = 0;
  76.139 -		break;
  76.140 -	case 0x02:
  76.141 -		// print packet
  76.142 -		gbPrinterShowData();
  76.143 -		break;
  76.144 -	case 0x04:
  76.145 -		// data packet
  76.146 -		gbPrinterReceiveData();
  76.147 -		break;
  76.148 -	case 0x0f:
  76.149 -		// NUL packet
  76.150 -		break;
  76.151 -	}
  76.152 -}
  76.153 -
  76.154 -u8 gbPrinterSend(u8 byte)
  76.155 -{
  76.156 -	switch (gbPrinterState)
  76.157 -	{
  76.158 -	case 0:
  76.159 -		gbPrinterCount = 0;
  76.160 -		// receiving preamble
  76.161 -		if (byte == 0x88)
  76.162 -		{
  76.163 -			gbPrinterPacket[gbPrinterCount++] = byte;
  76.164 -			gbPrinterState++;
  76.165 -		}
  76.166 -		else
  76.167 -		{
  76.168 -			// todo: handle failure
  76.169 -			gbPrinterReset();
  76.170 -		}
  76.171 -		break;
  76.172 -	case 1:
  76.173 -		// receiving preamble
  76.174 -		if (byte == 0x33)
  76.175 -		{
  76.176 -			gbPrinterPacket[gbPrinterCount++] = byte;
  76.177 -			gbPrinterState++;
  76.178 -		}
  76.179 -		else
  76.180 -		{
  76.181 -			// todo: handle failure
  76.182 -			gbPrinterReset();
  76.183 -		}
  76.184 -		break;
  76.185 -	case 2:
  76.186 -		// receiving header
  76.187 -		gbPrinterPacket[gbPrinterCount++] = byte;
  76.188 -		if (gbPrinterCount == 6)
  76.189 -		{
  76.190 -			gbPrinterState++;
  76.191 -			gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
  76.192 -		}
  76.193 -		break;
  76.194 -	case 3:
  76.195 -		// receiving data
  76.196 -		if (gbPrinterDataSize)
  76.197 -		{
  76.198 -			gbPrinterPacket[gbPrinterCount++] = byte;
  76.199 -			if (gbPrinterCount == (6+gbPrinterDataSize))
  76.200 -			{
  76.201 -				gbPrinterState++;
  76.202 -			}
  76.203 -			break;
  76.204 -		}
  76.205 -		gbPrinterState++;
  76.206 -	// intentionally move to next if no data to receive
  76.207 -	case 4:
  76.208 -		// receiving CRC
  76.209 -		gbPrinterPacket[gbPrinterCount++] = byte;
  76.210 -		gbPrinterState++;
  76.211 -		break;
  76.212 -	case 5:
  76.213 -		// receiving CRC-2
  76.214 -		gbPrinterPacket[gbPrinterCount++] = byte;
  76.215 -		if (gbPrinterCheckCRC())
  76.216 -		{
  76.217 -			gbPrinterCommand();
  76.218 -		}
  76.219 -		gbPrinterState++;
  76.220 -		break;
  76.221 -	case 6:
  76.222 -		// receiving dummy 1
  76.223 -		gbPrinterPacket[gbPrinterCount++] = byte;
  76.224 -		gbPrinterResult = 0x81;
  76.225 -		gbPrinterState++;
  76.226 -		break;
  76.227 -	case 7:
  76.228 -		// receiving dummy 2
  76.229 -		gbPrinterPacket[gbPrinterCount++] = byte;
  76.230 -		gbPrinterResult = gbPrinterStatus;
  76.231 -		gbPrinterState  = 0;
  76.232 -		gbPrinterCount  = 0;
  76.233 -		break;
  76.234 -	}
  76.235 -	return gbPrinterResult;
  76.236 -}
  76.237 -
    77.1 --- a/src/gb/gbPrinter.h	Sat Mar 03 10:54:39 2012 -0600
    77.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.3 @@ -1,10 +0,0 @@
    77.4 -#ifndef VBA_GB_PRINTER_H
    77.5 -#define VBA_GB_PRINTER_H
    77.6 -
    77.7 -#if _MSC_VER > 1000
    77.8 -#pragma once
    77.9 -#endif // _MSC_VER > 1000
   77.10 -
   77.11 -extern u8 gbPrinterSend(u8 byte);
   77.12 -
   77.13 -#endif // VBA_GB_PRINTER_H
    78.1 --- a/src/gb/gbSGB.cpp	Sat Mar 03 10:54:39 2012 -0600
    78.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.3 @@ -1,997 +0,0 @@
    78.4 -#include <cstdlib>
    78.5 -#include <cstring>
    78.6 -
    78.7 -#include "../common/System.h"
    78.8 -#include "../common/Util.h"
    78.9 -#include "GB.h"
   78.10 -#include "gbGlobals.h"
   78.11 -#include "../common/movie.h"
   78.12 -
   78.13 -extern u8 * pix;
   78.14 -
   78.15 -#define GBSGB_NONE            0
   78.16 -#define GBSGB_RESET           1
   78.17 -#define GBSGB_PACKET_TRANSMIT 2
   78.18 -
   78.19 -u8 gbSgbBorderChar [32 * 256];
   78.20 -u8 gbSgbBorder [2048];
   78.21 -
   78.22 -int32 gbSgbCGBSupport	   = 0;
   78.23 -int32 gbSgbMask			   = 0;
   78.24 -int32 gbSgbMode			   = 0;
   78.25 -int32 gbSgbPacketState	   = GBSGB_NONE;
   78.26 -int32 gbSgbBit			   = 0;
   78.27 -int32 gbSgbPacketTimeout   = 0;
   78.28 -int32 GBSGB_PACKET_TIMEOUT = 66666;
   78.29 -u8	  gbSgbPacket[16 * 7];
   78.30 -int32 gbSgbPacketNBits		 = 0;
   78.31 -int32 gbSgbPacketByte		 = 0;
   78.32 -int32 gbSgbPacketNumber		 = 0;
   78.33 -int32 gbSgbMultiplayer		 = 0;
   78.34 -int32 gbSgbFourPlayers		 = 0;
   78.35 -u8	  gbSgbNextController	 = 0x0f;
   78.36 -u8	  gbSgbReadingController = 0;
   78.37 -u16	  gbSgbSCPPalette[4 * 512];
   78.38 -u8	  gbSgbATF[20 * 18];
   78.39 -u8	  gbSgbATFList[45 * 20 * 18];
   78.40 -u8	  gbSgbScreenBuffer[4160];
   78.41 -
   78.42 -inline void gbSgbDraw24Bit(u8 *p, u16 v)
   78.43 -{
   78.44 -	*((u32 *) p) = systemColorMap32[v];
   78.45 -}
   78.46 -
   78.47 -inline void gbSgbDraw32Bit(u32 *p, u16 v)
   78.48 -{
   78.49 -	*p = systemColorMap32[v];
   78.50 -}
   78.51 -
   78.52 -inline void gbSgbDraw16Bit(u16 *p, u16 v)
   78.53 -{
   78.54 -	*p = systemColorMap16[v];
   78.55 -}
   78.56 -
   78.57 -void gbSgbReset()
   78.58 -{
   78.59 -	gbSgbPacketTimeout = 0;
   78.60 -	gbSgbCGBSupport	   = 0;
   78.61 -	gbSgbMask			   = 0;
   78.62 -	gbSgbPacketState	   = GBSGB_NONE;
   78.63 -	gbSgbBit			   = 0;
   78.64 -	gbSgbPacketNBits	   = 0;
   78.65 -	gbSgbPacketNumber	   = 0;
   78.66 -	gbSgbMultiplayer	   = 0;
   78.67 -	gbSgbFourPlayers	   = 0;
   78.68 -	gbSgbNextController	   = 0x0f;
   78.69 -	gbSgbReadingController = 0;
   78.70 -
   78.71 -	memset(gbSgbSCPPalette, 0, 512 * 4);
   78.72 -	memset(gbSgbATF, 0, 20 * 18);
   78.73 -	memset(gbSgbATFList, 0, 45 * 20 * 18);
   78.74 -	memset(gbSgbPacket, 0, 16 * 7);
   78.75 -	memset(gbSgbBorderChar, 0, 32 * 256);
   78.76 -	memset(gbSgbBorder, 0, 2048);
   78.77 -
   78.78 -	int i;
   78.79 -	for (i = 1; i < 2048; i += 2)
   78.80 -	{
   78.81 -		gbSgbBorder[i] = 1 << 2;
   78.82 -	}
   78.83 -
   78.84 -	for (i = 0; i < 4; i++)
   78.85 -	{
   78.86 -		gbPalette[i * 4]	 = (0x1f) | (0x1f << 5) | (0x1f << 10);
   78.87 -		gbPalette[i * 4 + 1] = (0x15) | (0x15 << 5) | (0x15 << 10);
   78.88 -		gbPalette[i * 4 + 2] = (0x0c) | (0x0c << 5) | (0x0c << 10);
   78.89 -		gbPalette[i * 4 + 3] = 0;
   78.90 -	}
   78.91 -}
   78.92 -
   78.93 -void gbSgbInit()
   78.94 -{
   78.95 -	gbSgbReset();
   78.96 -}
   78.97 -
   78.98 -void gbSgbShutdown()
   78.99 -{
  78.100 -	memset(gbSgbBorderChar, 0, 32 * 256);
  78.101 -	memset(gbSgbBorder, 0, 2048);
  78.102 -}
  78.103 -
  78.104 -void gbSgbFillScreen(u16 color)
  78.105 -{
  78.106 -	switch (systemColorDepth)
  78.107 -	{
  78.108 -	case 16:
  78.109 -	{
  78.110 -		for (int y = 0; y < 144; y++)
  78.111 -		{
  78.112 -			int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 2) +
  78.113 -			            gbBorderColumnSkip;
  78.114 -			u16 *dest = (u16 *)pix + yLine;
  78.115 -			for (register int x = 0; x < 160; x++)
  78.116 -				gbSgbDraw16Bit(dest++, color);
  78.117 -		}
  78.118 -	}
  78.119 -	break;
  78.120 -	case 24:
  78.121 -	{
  78.122 -		for (int y = 0; y < 144; y++)
  78.123 -		{
  78.124 -			int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip + gbBorderColumnSkip;
  78.125 -			u8 *dest  = (u8 *)pix + yLine * 3;
  78.126 -			for (register int x = 0; x < 160; x++)
  78.127 -			{
  78.128 -				gbSgbDraw24Bit(dest, color);
  78.129 -				dest += 3;
  78.130 -			}
  78.131 -		}
  78.132 -	}
  78.133 -	break;
  78.134 -	case 32:
  78.135 -	{
  78.136 -		for (int y = 0; y < 144; y++)
  78.137 -		{
  78.138 -			int	 yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 1) + gbBorderColumnSkip;
  78.139 -			u32 *dest  = (u32 *)pix + yLine;
  78.140 -			for (register int x = 0; x < 160; x++)
  78.141 -			{
  78.142 -				gbSgbDraw32Bit(dest++, color);
  78.143 -			}
  78.144 -		}
  78.145 -	}
  78.146 -	break;
  78.147 -	}
  78.148 -}
  78.149 -
  78.150 -void gbSgbRenderScreenToBuffer()
  78.151 -{
  78.152 -	u16 mapAddress = 0x9800;
  78.153 -
  78.154 -	if (register_LCDC & 0x08)
  78.155 -		mapAddress = 0x9c00;
  78.156 -
  78.157 -	u16 patternAddress = 0x8800;
  78.158 -
  78.159 -	int flag = 1;
  78.160 -
  78.161 -	if (register_LCDC & 0x10)
  78.162 -	{
  78.163 -		patternAddress = 0x8000;
  78.164 -		flag = 0;
  78.165 -	}
  78.166 -
  78.167 -	u8 *toAddress = gbSgbScreenBuffer;
  78.168 -
  78.169 -	for (int i = 0; i < 13; i++)
  78.170 -	{
  78.171 -		for (int j = 0; j < 20; j++)
  78.172 -		{
  78.173 -			int tile = gbReadMemoryQuick(mapAddress);
  78.174 -			mapAddress++;
  78.175 -
  78.176 -			if (flag)
  78.177 -			{
  78.178 -				if (tile > 127)
  78.179 -					tile -= 128;
  78.180 -				else
  78.181 -					tile += 128;
  78.182 -			}
  78.183 -			for (int k = 0; k < 16; k++)
  78.184 -				*toAddress++ = gbReadMemoryQuick(patternAddress + tile * 16 + k);
  78.185 -		}
  78.186 -		mapAddress += 12;
  78.187 -	}
  78.188 -}
  78.189 -
  78.190 -void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
  78.191 -{
  78.192 -	u16 *dest	= (u16 *)pix + ((y + 1) * (256 + 2)) + x;
  78.193 -	u8 * dest8	= (u8 *)pix + ((y * 256) + x) * 3;
  78.194 -	u32 *dest32 = (u32 *)pix + ((y + 1) * 257) + x;
  78.195 -
  78.196 -	u8 *tileAddress	 = &gbSgbBorderChar[tile * 32];
  78.197 -	u8 *tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
  78.198 -
  78.199 -	u8 l = 8;
  78.200 -
  78.201 -	u8 palette = ((attr >> 2) & 7);
  78.202 -
  78.203 -	if (palette < 4)
  78.204 -		palette += 4;
  78.205 -
  78.206 -	palette *= 16;
  78.207 -
  78.208 -	u8 xx = 0;
  78.209 -	u8 yy = 0;
  78.210 -
  78.211 -	int flipX = attr & 0x40;
  78.212 -	int flipY = attr & 0x80;
  78.213 -
  78.214 -	while (l > 0)
  78.215 -	{
  78.216 -		u8 mask = 0x80;
  78.217 -		u8 a	= *tileAddress++;
  78.218 -		u8 b	= *tileAddress++;
  78.219 -		u8 c	= *tileAddress2++;
  78.220 -		u8 d	= *tileAddress2++;
  78.221 -
  78.222 -		while (mask > 0)
  78.223 -		{
  78.224 -			u8 color = 0;
  78.225 -			if (a & mask)
  78.226 -				color++;
  78.227 -			if (b & mask)
  78.228 -				color += 2;
  78.229 -			if (c & mask)
  78.230 -				color += 4;
  78.231 -			if (d & mask)
  78.232 -				color += 8;
  78.233 -
  78.234 -			u8 xxx = xx;
  78.235 -			u8 yyy = yy;
  78.236 -
  78.237 -			if (flipX)
  78.238 -				xxx = 7 - xx;
  78.239 -			if (flipY)
  78.240 -				yyy = 7 - yy;
  78.241 -
  78.242 -			u8 realx = x + xxx;
  78.243 -			u8 realy = y + yyy;
  78.244 -
  78.245 -			u16 c = gbPalette[palette + color];
  78.246 -			if (!color)
  78.247 -				c = gbPalette[0];
  78.248 -			if ((realy < 40 || realy >= 184) || (realx < 48 || realx >= 208))
  78.249 -			{
  78.250 -				switch (systemColorDepth)
  78.251 -				{
  78.252 -				case 16:
  78.253 -					gbSgbDraw16Bit(dest + yyy * (256 + 2) + xxx, c);
  78.254 -					break;
  78.255 -				case 24:
  78.256 -					gbSgbDraw24Bit(dest8 + (yyy * 256 + xxx) * 3, c);
  78.257 -					break;
  78.258 -				case 32:
  78.259 -					gbSgbDraw32Bit(dest32 + yyy * (256 + 1) + xxx, c);
  78.260 -					break;
  78.261 -				}
  78.262 -			}
  78.263 -
  78.264 -			mask >>= 1;
  78.265 -
  78.266 -			xx++;
  78.267 -		}
  78.268 -		yy++;
  78.269 -		xx = 0;
  78.270 -		l--;
  78.271 -		mask = 0x80;
  78.272 -	}
  78.273 -}
  78.274 -
  78.275 -void gbSgbRenderBorder()
  78.276 -{
  78.277 -	if (gbBorderOn)
  78.278 -	{
  78.279 -		u8 *fromAddress = gbSgbBorder;
  78.280 -
  78.281 -		for (u8 y = 0; y < 28; y++)
  78.282 -		{
  78.283 -			for (u8 x = 0; x < 32; x++)
  78.284 -			{
  78.285 -				u8 tile = *fromAddress++;
  78.286 -				u8 attr = *fromAddress++;
  78.287 -
  78.288 -				gbSgbDrawBorderTile(x * 8, y * 8, tile, attr);
  78.289 -			}
  78.290 -		}
  78.291 -	}
  78.292 -}
  78.293 -
  78.294 -void gbSgbPicture()
  78.295 -{
  78.296 -	gbSgbRenderScreenToBuffer();
  78.297 -
  78.298 -	memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
  78.299 -
  78.300 -	u16 *paletteAddr = (u16 *)&gbSgbScreenBuffer[2048];
  78.301 -
  78.302 -	for (int i = 64; i < 128; i++)
  78.303 -	{
  78.304 -		gbPalette[i] = READ16LE(paletteAddr++);
  78.305 -	}
  78.306 -
  78.307 -	gbSgbCGBSupport |= 4;
  78.308 -
  78.309 -	if (gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4)
  78.310 -	{
  78.311 -		gbBorderOn = 1;
  78.312 -		systemGbBorderOn();
  78.313 -	}
  78.314 -
  78.315 -	if (gbBorderOn && !gbSgbMask)
  78.316 -		gbSgbRenderBorder();
  78.317 -
  78.318 -	if (gbSgbMode && gbCgbMode && gbSgbCGBSupport > 4)
  78.319 -	{
  78.320 -		gbSgbCGBSupport = 0;
  78.321 -		gbSgbMode		= 2;
  78.322 -		gbSgbMask		= 0;
  78.323 -		gbSgbRenderBorder();
  78.324 -		gbReset();
  78.325 -	}
  78.326 -
  78.327 -	if (gbSgbCGBSupport > 4)
  78.328 -		gbSgbCGBSupport = 0;
  78.329 -}
  78.330 -
  78.331 -void gbSgbSetPalette(int a, int b, u16 *p)
  78.332 -{
  78.333 -	u16 bit00 = READ16LE(p++);
  78.334 -	int i;
  78.335 -
  78.336 -	for (i = 1; i < 4; i++)
  78.337 -	{
  78.338 -		gbPalette[a * 4 + i] = READ16LE(p++);
  78.339 -	}
  78.340 -
  78.341 -	for (i = 1; i < 4; i++)
  78.342 -	{
  78.343 -		gbPalette[b * 4 + i] = READ16LE(p++);
  78.344 -	}
  78.345 -
  78.346 -	gbPalette[0] = gbPalette[4] = gbPalette[8] = gbPalette[12] = bit00;
  78.347 -	if (gbBorderOn && !gbSgbMask)
  78.348 -		gbSgbRenderBorder();
  78.349 -}
  78.350 -
  78.351 -void gbSgbScpPalette()
  78.352 -{
  78.353 -	gbSgbRenderScreenToBuffer();
  78.354 -
  78.355 -	u16 *fromAddress = (u16 *)gbSgbScreenBuffer;
  78.356 -
  78.357 -	for (int i = 0; i < 512 * 4; i++)
  78.358 -	{
  78.359 -		gbSgbSCPPalette[i] = READ16LE(fromAddress++);
  78.360 -	}
  78.361 -}
  78.362 -
  78.363 -void gbSgbSetATF(int n)
  78.364 -{
  78.365 -	if (n < 0)
  78.366 -		n = 0;
  78.367 -	if (n > 44)
  78.368 -		n = 44;
  78.369 -	memcpy(gbSgbATF, &gbSgbATFList[n * 20 * 18], 20 * 18);
  78.370 -
  78.371 -	if (gbSgbPacket[1] & 0x40)
  78.372 -	{
  78.373 -		gbSgbMask = 0;
  78.374 -		if (gbBorderOn)
  78.375 -			gbSgbRenderBorder();
  78.376 -	}
  78.377 -}
  78.378 -
  78.379 -void gbSgbSetPalette()
  78.380 -{
  78.381 -	u16 pal = READ16LE((((u16 *)&gbSgbPacket[1]))) & 511;
  78.382 -	memcpy(&gbPalette[0], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
  78.383 -
  78.384 -	pal = READ16LE((((u16 *)&gbSgbPacket[3]))) & 511;
  78.385 -	memcpy(&gbPalette[4], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
  78.386 -
  78.387 -	pal = READ16LE((((u16 *)&gbSgbPacket[5]))) & 511;
  78.388 -	memcpy(&gbPalette[8], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
  78.389 -
  78.390 -	pal = READ16LE((((u16 *)&gbSgbPacket[7]))) & 511;
  78.391 -	memcpy(&gbPalette[12], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
  78.392 -
  78.393 -	u8 atf = gbSgbPacket[9];
  78.394 -
  78.395 -	if (atf & 0x80)
  78.396 -	{
  78.397 -		gbSgbSetATF(atf & 0x3f);
  78.398 -	}
  78.399 -
  78.400 -	if (atf & 0x40)
  78.401 -	{
  78.402 -		gbSgbMask = 0;
  78.403 -		if (gbBorderOn)
  78.404 -			gbSgbRenderBorder();
  78.405 -	}
  78.406 -}
  78.407 -
  78.408 -void gbSgbAttributeBlock()
  78.409 -{
  78.410 -	u8 *fromAddress = &gbSgbPacket[1];
  78.411 -
  78.412 -	u8 nDataSet = *fromAddress++;
  78.413 -	if (nDataSet > 12)
  78.414 -		nDataSet = 12;
  78.415 -	if (nDataSet == 0)
  78.416 -		nDataSet = 1;
  78.417 -
  78.418 -	while (nDataSet)
  78.419 -	{
  78.420 -		u8 controlCode		  = (*fromAddress++) & 7;
  78.421 -		u8 paletteDesignation = (*fromAddress++) & 0x3f;
  78.422 -		u8 startH = (*fromAddress++) & 0x1f;
  78.423 -		u8 startV = (*fromAddress++) & 0x1f;
  78.424 -		u8 endH	  = (*fromAddress++) & 0x1f;
  78.425 -		u8 endV	  = (*fromAddress++) & 0x1f;
  78.426 -
  78.427 -		u8 *toAddress = gbSgbATF;
  78.428 -
  78.429 -		for (u8 y = 0; y < 18; y++)
  78.430 -		{
  78.431 -			for (u8 x = 0; x < 20; x++)
  78.432 -			{
  78.433 -				if (x < startH || y < startV ||
  78.434 -				    x > endH || y > endV)
  78.435 -				{
  78.436 -					// outside
  78.437 -					if (controlCode & 0x04)
  78.438 -						*toAddress = (paletteDesignation >> 4) & 0x03;
  78.439 -				}
  78.440 -				else if (x > startH && x < endH &&
  78.441 -				         y > startV && y < endV)
  78.442 -				{
  78.443 -					// inside
  78.444 -					if (controlCode & 0x01)
  78.445 -						*toAddress = paletteDesignation & 0x03;
  78.446 -				}
  78.447 -				else
  78.448 -				{
  78.449 -					// surrounding line
  78.450 -					if (controlCode & 0x02)
  78.451 -						*toAddress = (paletteDesignation >> 2) & 0x03;
  78.452 -					else if (controlCode == 0x01)
  78.453 -						*toAddress = paletteDesignation & 0x03;
  78.454 -				}
  78.455 -				toAddress++;
  78.456 -			}
  78.457 -		}
  78.458 -		nDataSet--;
  78.459 -	}
  78.460 -}
  78.461 -
  78.462 -void gbSgbSetColumnPalette(u8 col, u8 p)
  78.463 -{
  78.464 -	//  if(col < 0)
  78.465 -	//    col = 0;
  78.466 -	if (col > 19)
  78.467 -		col = 19;
  78.468 -
  78.469 -	p &= 3;
  78.470 -
  78.471 -	u8 *toAddress = &gbSgbATF[col];
  78.472 -
  78.473 -	for (u8 y = 0; y < 18; y++)
  78.474 -	{
  78.475 -		*toAddress = p;
  78.476 -		toAddress += 20;
  78.477 -	}
  78.478 -}
  78.479 -
  78.480 -void gbSgbSetRowPalette(u8 row, u8 p)
  78.481 -{
  78.482 -	//  if(row < 0)
  78.483 -	//    row = 0;
  78.484 -	if (row > 17)
  78.485 -		row = 17;
  78.486 -
  78.487 -	p &= 3;
  78.488 -
  78.489 -	u8 *toAddress = &gbSgbATF[row * 20];
  78.490 -
  78.491 -	for (u8 x = 0; x < 20; x++)
  78.492 -	{
  78.493 -		*toAddress++ = p;
  78.494 -	}
  78.495 -}
  78.496 -
  78.497 -void gbSgbAttributeDivide()
  78.498 -{
  78.499 -	u8 control = gbSgbPacket[1];
  78.500 -	u8 coord   = gbSgbPacket[2];
  78.501 -	u8 colorBR = control & 3;
  78.502 -	u8 colorAL = (control >> 2) & 3;
  78.503 -	u8 colorOL = (control >> 4) & 3;
  78.504 -
  78.505 -	if (control & 0x40)
  78.506 -	{
  78.507 -		if (coord > 17)
  78.508 -			coord = 17;
  78.509 -
  78.510 -		for (u8 i = 0; i < 18; i++)
  78.511 -		{
  78.512 -			if (i < coord)
  78.513 -				gbSgbSetRowPalette(i, colorAL);
  78.514 -			else if (i > coord)
  78.515 -				gbSgbSetRowPalette(i, colorBR);
  78.516 -			else
  78.517 -				gbSgbSetRowPalette(i, colorOL);
  78.518 -		}
  78.519 -	}
  78.520 -	else
  78.521 -	{
  78.522 -		if (coord > 19)
  78.523 -			coord = 19;
  78.524 -
  78.525 -		for (u8 i = 0; i < 20; i++)
  78.526 -		{
  78.527 -			if (i < coord)
  78.528 -				gbSgbSetColumnPalette(i, colorAL);
  78.529 -			else if (i > coord)
  78.530 -				gbSgbSetColumnPalette(i, colorBR);
  78.531 -			else
  78.532 -				gbSgbSetColumnPalette(i, colorOL);
  78.533 -		}
  78.534 -	}
  78.535 -}
  78.536 -
  78.537 -void gbSgbAttributeLine()
  78.538 -{
  78.539 -	u8 *fromAddress = &gbSgbPacket[1];
  78.540 -
  78.541 -	u8 nDataSet = *fromAddress++;
  78.542 -
  78.543 -	if (nDataSet > 0x6e)
  78.544 -		nDataSet = 0x6e;
  78.545 -
  78.546 -	while (nDataSet)
  78.547 -	{
  78.548 -		u8 line = *fromAddress++;
  78.549 -		u8 num	= line & 0x1f;
  78.550 -		u8 pal	= (line >> 5) & 0x03;
  78.551 -		if (line & 0x80)
  78.552 -		{
  78.553 -			if (num > 17)
  78.554 -				num = 17;
  78.555 -			gbSgbSetRowPalette(num, pal);
  78.556 -		}
  78.557 -		else
  78.558 -		{
  78.559 -			if (num > 19)
  78.560 -				num = 19;
  78.561 -			gbSgbSetColumnPalette(num, pal);
  78.562 -		}
  78.563 -		nDataSet--;
  78.564 -	}
  78.565 -}
  78.566 -
  78.567 -void gbSgbAttributeCharacter()
  78.568 -{
  78.569 -	u8	startH	 = gbSgbPacket[1] & 0x1f;
  78.570 -	u8	startV	 = gbSgbPacket[2] & 0x1f;
  78.571 -	int nDataSet = READ16LE(((u16 *)&gbSgbPacket[3]));
  78.572 -	int style	 = gbSgbPacket[5] & 1;
  78.573 -	if (startH > 19)
  78.574 -		startH = 19;
  78.575 -	if (startV > 17)
  78.576 -		startV = 17;
  78.577 -
  78.578 -	u8	s = 6;
  78.579 -	u8 *fromAddress = &gbSgbPacket[6];
  78.580 -	u8	v = *fromAddress++;
  78.581 -
  78.582 -	if (style)
  78.583 -	{
  78.584 -		while (nDataSet)
  78.585 -		{
  78.586 -			u8 p = (v >> s) & 3;
  78.587 -			gbSgbATF[startV * 20 + startH] = p;
  78.588 -			startV++;
  78.589 -			if (startV == 18)
  78.590 -			{
  78.591 -				startV = 0;
  78.592 -				startH++;
  78.593 -				if (startH == 20)
  78.594 -					break;
  78.595 -			}
  78.596 -
  78.597 -			if (s)
  78.598 -				s -= 2;
  78.599 -			else
  78.600 -			{
  78.601 -				s = 6;
  78.602 -				v = *fromAddress++;
  78.603 -				nDataSet--;
  78.604 -			}
  78.605 -		}
  78.606 -	}
  78.607 -	else
  78.608 -	{
  78.609 -		while (nDataSet)
  78.610 -		{
  78.611 -			u8 p = (v >> s) & 3;
  78.612 -			gbSgbATF[startV * 20 + startH] = p;
  78.613 -			startH++;
  78.614 -			if (startH == 20)
  78.615 -			{
  78.616 -				startH = 0;
  78.617 -				startV++;
  78.618 -				if (startV == 18)
  78.619 -					break;
  78.620 -			}
  78.621 -
  78.622 -			if (s)
  78.623 -				s -= 2;
  78.624 -			else
  78.625 -			{
  78.626 -				s = 6;
  78.627 -				v = *fromAddress++;
  78.628 -				nDataSet--;
  78.629 -			}
  78.630 -		}
  78.631 -	}
  78.632 -}
  78.633 -
  78.634 -void gbSgbSetATFList()
  78.635 -{
  78.636 -	gbSgbRenderScreenToBuffer();
  78.637 -
  78.638 -	u8 *fromAddress = gbSgbScreenBuffer;
  78.639 -	u8 *toAddress	= gbSgbATFList;
  78.640 -
  78.641 -	for (int i = 0; i < 45; i++)
  78.642 -	{
  78.643 -		for (int j = 0; j < 90; j++)
  78.644 -		{
  78.645 -			u8 v = *fromAddress++;
  78.646 -			u8 s = 6;
  78.647 -			if (i == 2)
  78.648 -				s = 6;
  78.649 -			for (int k = 0; k < 4; k++)
  78.650 -			{
  78.651 -				*toAddress++ = (v >> s) & 0x03;
  78.652 -				s -= 2;
  78.653 -			}
  78.654 -		}
  78.655 -	}
  78.656 -}
  78.657 -
  78.658 -void gbSgbMaskEnable()
  78.659 -{
  78.660 -	int gbSgbMaskFlag = gbSgbPacket[1] & 3;
  78.661 -
  78.662 -	gbSgbMask = gbSgbMaskFlag;
  78.663 -
  78.664 -	switch (gbSgbMaskFlag)
  78.665 -	{
  78.666 -	case 1:
  78.667 -		break;
  78.668 -	case 2:
  78.669 -		gbSgbFillScreen(0x0000);
  78.670 -		//    memset(&gbPalette[0], 0, 128*sizeof(u16));
  78.671 -		break;
  78.672 -	case 3:
  78.673 -		gbSgbFillScreen(gbPalette[0]);
  78.674 -		break;
  78.675 -	}
  78.676 -	if (!gbSgbMask)
  78.677 -	{
  78.678 -		if (gbBorderOn)
  78.679 -			gbSgbRenderBorder();
  78.680 -	}
  78.681 -}
  78.682 -
  78.683 -void gbSgbChrTransfer()
  78.684 -{
  78.685 -	gbSgbRenderScreenToBuffer();
  78.686 -
  78.687 -	int address = (gbSgbPacket[1] & 1) * (128 * 32);
  78.688 -
  78.689 -	if (gbSgbPacket[1] & 1)
  78.690 -		gbSgbCGBSupport |= 2;
  78.691 -	else
  78.692 -		gbSgbCGBSupport |= 1;
  78.693 -
  78.694 -	memcpy(&gbSgbBorderChar[address], gbSgbScreenBuffer, 128 * 32);
  78.695 -
  78.696 -	if (gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4)
  78.697 -	{
  78.698 -		gbBorderOn = 1;
  78.699 -		systemGbBorderOn();
  78.700 -	}
  78.701 -
  78.702 -	if (gbBorderOn && !gbSgbMask)
  78.703 -		gbSgbRenderBorder();
  78.704 -
  78.705 -	if (gbSgbMode && gbCgbMode && gbSgbCGBSupport == 7)
  78.706 -	{
  78.707 -		gbSgbCGBSupport = 0;
  78.708 -		gbSgbMode		= 2;
  78.709 -		gbSgbMask		= 0;
  78.710 -		gbSgbRenderBorder();
  78.711 -		gbReset();
  78.712 -	}
  78.713 -
  78.714 -	if (gbSgbCGBSupport > 4)
  78.715 -		gbSgbCGBSupport = 0;
  78.716 -}
  78.717 -
  78.718 -void gbSgbMultiRequest()
  78.719 -{
  78.720 -	if (gbSgbPacket[1] & 1)
  78.721 -	{
  78.722 -		gbSgbMultiplayer = 1;
  78.723 -		if (gbSgbPacket[1] & 2)
  78.724 -			gbSgbFourPlayers = 1;
  78.725 -		else
  78.726 -			gbSgbFourPlayers = 0;
  78.727 -		gbSgbNextController = 0x0e;
  78.728 -	}
  78.729 -	else
  78.730 -	{
  78.731 -		gbSgbFourPlayers	= 0;
  78.732 -		gbSgbMultiplayer	= 0;
  78.733 -		gbSgbNextController = 0x0f;
  78.734 -	}
  78.735 -}
  78.736 -
  78.737 -void gbSgbCommand()
  78.738 -{
  78.739 -	int command = gbSgbPacket[0] >> 3;
  78.740 -	//  int nPacket = gbSgbPacket[0] & 7;
  78.741 -
  78.742 -	switch (command)
  78.743 -	{
  78.744 -	case 0x00:
  78.745 -		gbSgbSetPalette(0, 1, (u16 *)&gbSgbPacket[1]);
  78.746 -		break;
  78.747 -	case 0x01:
  78.748 -		gbSgbSetPalette(2, 3, (u16 *)&gbSgbPacket[1]);
  78.749 -		break;
  78.750 -	case 0x02:
  78.751 -		gbSgbSetPalette(0, 3, (u16 *)&gbSgbPacket[1]);
  78.752 -		break;
  78.753 -	case 0x03:
  78.754 -		gbSgbSetPalette(1, 2, (u16 *)&gbSgbPacket[1]);
  78.755 -		break;
  78.756 -	case 0x04:
  78.757 -		gbSgbAttributeBlock();
  78.758 -		break;
  78.759 -	case 0x05:
  78.760 -		gbSgbAttributeLine();
  78.761 -		break;
  78.762 -	case 0x06:
  78.763 -		gbSgbAttributeDivide();
  78.764 -		break;
  78.765 -	case 0x07:
  78.766 -		gbSgbAttributeCharacter();
  78.767 -		break;
  78.768 -	case 0x0a:
  78.769 -		gbSgbSetPalette();
  78.770 -		break;
  78.771 -	case 0x0b:
  78.772 -		gbSgbScpPalette();
  78.773 -		break;
  78.774 -	case 0x11:
  78.775 -		gbSgbMultiRequest();
  78.776 -		break;
  78.777 -	case 0x13:
  78.778 -		gbSgbChrTransfer();
  78.779 -		break;
  78.780 -	case 0x14:
  78.781 -		gbSgbPicture();
  78.782 -		break;
  78.783 -	case 0x15:
  78.784 -		gbSgbSetATFList();
  78.785 -		break;
  78.786 -	case 0x16:
  78.787 -		gbSgbSetATF(gbSgbPacket[1] & 0x3f);
  78.788 -		break;
  78.789 -	case 0x17:
  78.790 -		gbSgbMaskEnable();
  78.791 -		break;
  78.792 -	}
  78.793 -}
  78.794 -
  78.795 -void gbSgbResetPacketState()
  78.796 -{
  78.797 -	gbSgbPacketState   = GBSGB_NONE;
  78.798 -	gbSgbPacketTimeout = 0;
  78.799 -}
  78.800 -
  78.801 -void gbSgbDoBitTransfer(u8 value)
  78.802 -{
  78.803 -	value = value & 0x30;
  78.804 -	switch (gbSgbPacketState)
  78.805 -	{
  78.806 -	case GBSGB_NONE:
  78.807 -		if (value == 0)
  78.808 -		{
  78.809 -			gbSgbPacketState   = GBSGB_RESET;
  78.810 -			gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT;
  78.811 -		}
  78.812 -		else if (value == 0x30)
  78.813 -		{
  78.814 -			if (gbSgbMultiplayer)
  78.815 -			{
  78.816 -				if ((gbSgbReadingController & 7) == 7)
  78.817 -				{
  78.818 -					gbSgbReadingController = 0;
  78.819 -					if (gbSgbMultiplayer)
  78.820 -					{
  78.821 -						gbSgbNextController--;
  78.822 -						if (gbSgbFourPlayers)
  78.823 -						{
  78.824 -							if (gbSgbNextController == 0x0b)
  78.825 -								gbSgbNextController = 0x0f;
  78.826 -						}
  78.827 -						else
  78.828 -						{
  78.829 -							if (gbSgbNextController == 0x0d)
  78.830 -								gbSgbNextController = 0x0f;
  78.831 -						}
  78.832 -					}
  78.833 -				}
  78.834 -				else
  78.835 -				{
  78.836 -					gbSgbReadingController &= 3;
  78.837 -				}
  78.838 -			}
  78.839 -			gbSgbPacketTimeout = 0;
  78.840 -		}
  78.841 -		else
  78.842 -		{
  78.843 -			if (value == 0x10)
  78.844 -				gbSgbReadingController |= 0x2;
  78.845 -			else if (value == 0x20)
  78.846 -				gbSgbReadingController |= 0x01;
  78.847 -			gbSgbPacketTimeout = 0;
  78.848 -		}
  78.849 -		gbSgbPacketTimeout = 0;
  78.850 -		break;
  78.851 -	case GBSGB_RESET:
  78.852 -		if (value == 0x30)
  78.853 -		{
  78.854 -			gbSgbPacketState   = GBSGB_PACKET_TRANSMIT;
  78.855 -			gbSgbPacketByte	   = 0;
  78.856 -			gbSgbPacketNBits   = 0;
  78.857 -			gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT;
  78.858 -		}
  78.859 -		else if (value == 0x00)
  78.860 -		{
  78.861 -			gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT;
  78.862 -			gbSgbPacketState   = GBSGB_RESET;
  78.863 -		}
  78.864 -		else
  78.865 -		{
  78.866 -			gbSgbPacketState   = GBSGB_NONE;
  78.867 -			gbSgbPacketTimeout = 0;
  78.868 -		}
  78.869 -		break;
  78.870 -	case GBSGB_PACKET_TRANSMIT:
  78.871 -		if (value == 0)
  78.872 -		{
  78.873 -			gbSgbPacketState   = GBSGB_RESET;
  78.874 -			gbSgbPacketTimeout = 0;
  78.875 -		}
  78.876 -		else if (value == 0x30)
  78.877 -		{
  78.878 -			if (gbSgbPacketNBits == 128)
  78.879 -			{
  78.880 -				gbSgbPacketNBits = 0;
  78.881 -				gbSgbPacketByte	 = 0;
  78.882 -				gbSgbPacketNumber++;
  78.883 -				gbSgbPacketTimeout = 0;
  78.884 -				if (gbSgbPacketNumber == (gbSgbPacket[0] & 7))
  78.885 -				{
  78.886 -					gbSgbCommand();
  78.887 -					gbSgbPacketNumber  = 0;
  78.888 -					gbSgbPacketState   = GBSGB_NONE;
  78.889 -					gbSgbPacketTimeout = 0;
  78.890 -				}
  78.891 -			}
  78.892 -			else
  78.893 -			{
  78.894 -				if (gbSgbPacketNBits < 128)
  78.895 -				{
  78.896 -					gbSgbPacket[gbSgbPacketNumber * 16 + gbSgbPacketByte] >>= 1;
  78.897 -					gbSgbPacket[gbSgbPacketNumber * 16 + gbSgbPacketByte]  |= gbSgbBit;
  78.898 -					gbSgbPacketNBits++;
  78.899 -					if (!(gbSgbPacketNBits & 7))
  78.900 -					{
  78.901 -						gbSgbPacketByte++;
  78.902 -					}
  78.903 -					gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT;
  78.904 -				}
  78.905 -			}
  78.906 -		}
  78.907 -		else
  78.908 -		{
  78.909 -			if (value == 0x20)
  78.910 -				gbSgbBit = 0x00;
  78.911 -			else
  78.912 -				gbSgbBit = 0x80;
  78.913 -			gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT;
  78.914 -		}
  78.915 -		gbSgbReadingController = 0;
  78.916 -		break;
  78.917 -	default:
  78.918 -		gbSgbPacketState   = GBSGB_NONE;
  78.919 -		gbSgbPacketTimeout = 0;
  78.920 -		break;
  78.921 -	}
  78.922 -}
  78.923 -
  78.924 -variable_desc gbSgbSaveStruct[] = {
  78.925 -	{ &gbSgbMask,			   sizeof(int32) },
  78.926 -	{ &gbSgbPacketState,	   sizeof(int32) },
  78.927 -	{ &gbSgbBit,			   sizeof(int32) },
  78.928 -	{ &gbSgbPacketNBits,	   sizeof(int32) },
  78.929 -	{ &gbSgbPacketByte,		   sizeof(int32) },
  78.930 -	{ &gbSgbPacketNumber,	   sizeof(int32) },
  78.931 -	{ &gbSgbMultiplayer,	   sizeof(int32) },
  78.932 -	{ &gbSgbNextController,	   sizeof(u8)	 },
  78.933 -	{ &gbSgbReadingController, sizeof(u8)	 },
  78.934 -	{ NULL,					   0			 }
  78.935 -};
  78.936 -
  78.937 -variable_desc gbSgbSaveStructV3[] = {
  78.938 -	{ &gbSgbMask,			   sizeof(int32) },
  78.939 -	{ &gbSgbPacketState,	   sizeof(int32) },
  78.940 -	{ &gbSgbBit,			   sizeof(int32) },
  78.941 -	{ &gbSgbPacketNBits,	   sizeof(int32) },
  78.942 -	{ &gbSgbPacketByte,		   sizeof(int32) },
  78.943 -	{ &gbSgbPacketNumber,	   sizeof(int32) },
  78.944 -	{ &gbSgbMultiplayer,	   sizeof(int32) },
  78.945 -	{ &gbSgbNextController,	   sizeof(u8)	 },
  78.946 -	{ &gbSgbReadingController, sizeof(u8)	 },
  78.947 -	{ &gbSgbFourPlayers,	   sizeof(int32) },
  78.948 -	{ NULL,					   0			 }
  78.949 -};
  78.950 -
  78.951 -void gbSgbSaveGame(gzFile gzFile)
  78.952 -{
  78.953 -	utilWriteData(gzFile, gbSgbSaveStructV3);
  78.954 -
  78.955 -	utilGzWrite(gzFile, gbSgbBorder, 2048);
  78.956 -	utilGzWrite(gzFile, gbSgbBorderChar, 32 * 256);
  78.957 -
  78.958 -	utilGzWrite(gzFile, gbSgbPacket, 16 * 7);
  78.959 -
  78.960 -	utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
  78.961 -	utilGzWrite(gzFile, gbSgbATF, 20 * 18);
  78.962 -	utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18);
  78.963 -
  78.964 -	utilGzWrite(gzFile, gbSgbScreenBuffer, 4160);
  78.965 -	utilGzWrite(gzFile, &gbSgbMode, sizeof(gbSgbMode));
  78.966 -	utilGzWrite(gzFile, &gbSgbCGBSupport, sizeof(gbSgbCGBSupport));
  78.967 -	utilGzWrite(gzFile, &gbSgbPacketTimeout, sizeof(gbSgbPacketTimeout));
  78.968 -}
  78.969 -
  78.970 -void gbSgbReadGame(gzFile gzFile, int version)
  78.971 -{
  78.972 -	if (version >= 3)
  78.973 -		utilReadData(gzFile, gbSgbSaveStructV3);
  78.974 -	else
  78.975 -	{
  78.976 -		utilReadData(gzFile, gbSgbSaveStruct);
  78.977 -		gbSgbFourPlayers = 0;
  78.978 -	}
  78.979 -
  78.980 -	if (version >= 8)
  78.981 -	{
  78.982 -		utilGzRead(gzFile, gbSgbBorder, 2048);
  78.983 -		utilGzRead(gzFile, gbSgbBorderChar, 32 * 256);
  78.984 -	}
  78.985 -
  78.986 -	utilGzRead(gzFile, gbSgbPacket, 16 * 7);
  78.987 -
  78.988 -	utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
  78.989 -	utilGzRead(gzFile, gbSgbATF, 20 * 18);
  78.990 -	utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18);
  78.991 -
  78.992 -	if (version >= 11)
  78.993 -	{
  78.994 -		utilGzRead(gzFile, gbSgbScreenBuffer, 4160);
  78.995 -		utilGzRead(gzFile, &gbSgbMode, sizeof(gbSgbMode));
  78.996 -		utilGzRead(gzFile, &gbSgbCGBSupport, sizeof(gbSgbCGBSupport));
  78.997 -		utilGzRead(gzFile, &gbSgbPacketTimeout, sizeof(gbSgbPacketTimeout));
  78.998 -	}
  78.999 -}
 78.1000 -
    79.1 --- a/src/gb/gbSGB.h	Sat Mar 03 10:54:39 2012 -0600
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,30 +0,0 @@
    79.4 -#ifndef VBA_GB_SGB_H
    79.5 -#define VBA_GB_SGB_H
    79.6 -
    79.7 -#if _MSC_VER > 1000
    79.8 -#pragma once
    79.9 -#endif // _MSC_VER > 1000
   79.10 -
   79.11 -#include "zlib.h"
   79.12 -#include "../Port.h"
   79.13 -
   79.14 -void gbSgbInit();
   79.15 -void gbSgbShutdown();
   79.16 -void gbSgbCommand();
   79.17 -void gbSgbResetPacketState();
   79.18 -void gbSgbReset();
   79.19 -void gbSgbDoBitTransfer(u8);
   79.20 -void gbSgbSaveGame(gzFile);
   79.21 -void gbSgbReadGame(gzFile, int version);
   79.22 -void gbSgbRenderBorder();
   79.23 -
   79.24 -extern u8    gbSgbATF[20*18];
   79.25 -extern int32 gbSgbMode;
   79.26 -extern int32 gbSgbMask;
   79.27 -extern int32 gbSgbMultiplayer;
   79.28 -extern u8    gbSgbNextController;
   79.29 -extern int32 gbSgbPacketTimeout;
   79.30 -extern u8    gbSgbReadingController;
   79.31 -extern int32 gbSgbFourPlayers;
   79.32 -
   79.33 -#endif // VBA_GB_SGB_H
    80.1 --- a/src/gb/gbSound.cpp	Sat Mar 03 10:54:39 2012 -0600
    80.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.3 @@ -1,1139 +0,0 @@
    80.4 -#ifdef WIN32
    80.5 -#   include "../win32/stdafx.h"
    80.6 -#   include "../win32/VBA.h"
    80.7 -#endif
    80.8 -
    80.9 -#include <cstring>
   80.10 -#include <cassert>
   80.11 -
   80.12 -#include "../common/System.h"
   80.13 -#include "../common/Util.h"
   80.14 -//#include "../Blip_Buffer.h"
   80.15 -#include "gbGlobals.h"
   80.16 -#include "gbSound.h"
   80.17 -
   80.18 -#ifndef countof
   80.19 -#define countof(a)  (sizeof(a) / sizeof(a[0]))
   80.20 -#endif
   80.21 -
   80.22 -extern u8	 soundBuffer[6][735];
   80.23 -extern u16	 soundFinalWave[1470];
   80.24 -extern u16	 soundFrameSound[735 * 30 * 2];
   80.25 -extern int32 soundVolume;
   80.26 -
   80.27 -soundtick_t GB_USE_TICKS_AS = 24; // (1048576.0/44100.0); // FIXME: (4194304.0/70224.0)(fps) vs 60.0fps?
   80.28 -
   80.29 -#define SOUND_MAGIC   0x60000000
   80.30 -#define SOUND_MAGIC_2 0x30000000
   80.31 -#define NOISE_MAGIC   (2097152.0 / 44100.0)
   80.32 -
   80.33 -extern int32 speed;
   80.34 -
   80.35 -extern u8 soundWavePattern[4][32];
   80.36 -
   80.37 -extern u32		   soundBufferLen;
   80.38 -extern u32		   soundBufferTotalLen;
   80.39 -extern int32	   soundQuality;
   80.40 -extern int32	   soundPaused;
   80.41 -extern int32	   soundPlay;
   80.42 -extern soundtick_t soundTicks;
   80.43 -extern soundtick_t SOUND_CLOCK_TICKS;
   80.44 -extern u32		   soundNextPosition;
   80.45 -
   80.46 -extern int32 soundLevel1;
   80.47 -extern int32 soundLevel2;
   80.48 -extern int32 soundBalance;
   80.49 -extern int32 soundMasterOn;
   80.50 -extern u32	 soundIndex;
   80.51 -extern u32	 soundBufferIndex;
   80.52 -extern int32 soundFrameSoundWritten;
   80.53 -int32		 soundVIN = 0;
   80.54 -extern int32 soundDebug;
   80.55 -
   80.56 -extern int32 sound1On;
   80.57 -extern int32 sound1ATL;
   80.58 -extern int32 sound1Skip;
   80.59 -extern int32 sound1Index;
   80.60 -extern int32 sound1Continue;
   80.61 -extern int32 sound1EnvelopeVolume;
   80.62 -extern int32 sound1EnvelopeATL;
   80.63 -extern int32 sound1EnvelopeUpDown;
   80.64 -extern int32 sound1EnvelopeATLReload;
   80.65 -extern int32 sound1SweepATL;
   80.66 -extern int32 sound1SweepATLReload;
   80.67 -extern int32 sound1SweepSteps;
   80.68 -extern int32 sound1SweepUpDown;
   80.69 -extern int32 sound1SweepStep;
   80.70 -extern u8 *	 sound1Wave;
   80.71 -
   80.72 -extern int32 sound2On;
   80.73 -extern int32 sound2ATL;
   80.74 -extern int32 sound2Skip;
   80.75 -extern int32 sound2Index;
   80.76 -extern int32 sound2Continue;
   80.77 -extern int32 sound2EnvelopeVolume;
   80.78 -extern int32 sound2EnvelopeATL;
   80.79 -extern int32 sound2EnvelopeUpDown;
   80.80 -extern int32 sound2EnvelopeATLReload;
   80.81 -extern u8 *	 sound2Wave;
   80.82 -
   80.83 -extern int32 sound3On;
   80.84 -extern int32 sound3ATL;
   80.85 -extern int32 sound3Skip;
   80.86 -extern int32 sound3Index;
   80.87 -extern int32 sound3Continue;
   80.88 -extern int32 sound3OutputLevel;
   80.89 -extern int32 sound3Last;
   80.90 -
   80.91 -extern int32 sound4On;
   80.92 -extern int32 sound4Clock;
   80.93 -extern int32 sound4ATL;
   80.94 -extern int32 sound4Skip;
   80.95 -extern int32 sound4Index;
   80.96 -extern int32 sound4ShiftRight;
   80.97 -extern int32 sound4ShiftSkip;
   80.98 -extern int32 sound4ShiftIndex;
   80.99 -extern int32 sound4NSteps;
  80.100 -extern int32 sound4CountDown;
  80.101 -extern int32 sound4Continue;
  80.102 -extern int32 sound4EnvelopeVolume;
  80.103 -extern int32 sound4EnvelopeATL;
  80.104 -extern int32 sound4EnvelopeUpDown;
  80.105 -extern int32 sound4EnvelopeATLReload;
  80.106 -
  80.107 -extern int32 soundEnableFlag;
  80.108 -extern int32 soundMutedFlag;
  80.109 -
  80.110 -extern int32 soundFreqRatio[8];
  80.111 -extern int32 soundShiftClock[16];
  80.112 -
  80.113 -extern s16	 soundFilter[4000];
  80.114 -extern s16	 soundLeft[5];
  80.115 -extern s16	 soundRight[5];
  80.116 -extern int32 soundEchoIndex;
  80.117 -extern bool8 soundEcho;
  80.118 -extern bool8 soundLowPass;
  80.119 -extern bool8 soundReverse;
  80.120 -extern bool8 soundOffFlag;
  80.121 -
  80.122 -bool8 gbDigitalSound = false;
  80.123 -
  80.124 -void gbSoundEvent(register u16 address, register int data)
  80.125 -{
  80.126 -	int freq = 0;
  80.127 -
  80.128 -	gbMemory[address] = data;
  80.129 -
  80.130 -#ifndef FINAL_VERSION
  80.131 -	if (soundDebug)
  80.132 -	{
  80.133 -		// don't translate. debug only
  80.134 -		log("Sound event: %08lx %02x\n", address, data);
  80.135 -	}
  80.136 -#endif
  80.137 -	switch (address)
  80.138 -	{
  80.139 -	case NR10:
  80.140 -		sound1SweepATL	  = sound1SweepATLReload = 344 * ((data >> 4) & 7);
  80.141 -		sound1SweepSteps  = data & 7;
  80.142 -		sound1SweepUpDown = data & 0x08;
  80.143 -		sound1SweepStep	  = 0;
  80.144 -		break;
  80.145 -	case NR11:
  80.146 -		sound1Wave = soundWavePattern[data >> 6];
  80.147 -		sound1ATL  = 172 * (64 - (data & 0x3f));
  80.148 -		break;
  80.149 -	case NR12:
  80.150 -		sound1EnvelopeVolume	= data >> 4;
  80.151 -		sound1EnvelopeUpDown	= data & 0x08;
  80.152 -		sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (data & 7);
  80.153 -		break;
  80.154 -	case NR13:
  80.155 -		freq	  = (((int)(gbMemory[NR14] & 7)) << 8) | data;
  80.156 -		sound1ATL = 172 * (64 - (gbMemory[NR11] & 0x3f));
  80.157 -		freq	  = 2048 - freq;
  80.158 -		if (freq)
  80.159 -		{
  80.160 -			sound1Skip = SOUND_MAGIC / freq;
  80.161 -		}
  80.162 -		else
  80.163 -			sound1Skip = 0;
  80.164 -		break;
  80.165 -	case NR14:
  80.166 -		freq = (((int)(data & 7) << 8) | gbMemory[NR13]);
  80.167 -		freq = 2048 - freq;
  80.168 -		sound1ATL	   = 172 * (64 - (gbMemory[NR11] & 0x3f));
  80.169 -		sound1Continue = data & 0x40;
  80.170 -		if (freq)
  80.171 -		{
  80.172 -			sound1Skip = SOUND_MAGIC / freq;
  80.173 -		}
  80.174 -		else
  80.175 -			sound1Skip = 0;
  80.176 -		if (data & 0x80)
  80.177 -		{
  80.178 -			gbMemory[NR52]		|= 1;
  80.179 -			sound1EnvelopeVolume = gbMemory[NR12] >> 4;
  80.180 -			sound1EnvelopeUpDown = gbMemory[NR12] & 0x08;
  80.181 -			sound1ATL = 172 * (64 - (gbMemory[NR11] & 0x3f));
  80.182 -			sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (gbMemory[NR12] & 7);
  80.183 -			sound1SweepATL			= sound1SweepATLReload = 344 * ((gbMemory[NR10] >> 4) & 7);
  80.184 -			sound1SweepSteps		= gbMemory[NR10] & 7;
  80.185 -			sound1SweepUpDown		= gbMemory[NR10] & 0x08;
  80.186 -			sound1SweepStep			= 0;
  80.187 -
  80.188 -			sound1Index = 0;
  80.189 -			sound1On	= 1;
  80.190 -		}
  80.191 -		break;
  80.192 -	case NR21:
  80.193 -		sound2Wave = soundWavePattern[data >> 6];
  80.194 -		sound2ATL  = 172 * (64 - (data & 0x3f));
  80.195 -		break;
  80.196 -	case NR22:
  80.197 -		sound2EnvelopeVolume	= data >> 4;
  80.198 -		sound2EnvelopeUpDown	= data & 0x08;
  80.199 -		sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (data & 7);
  80.200 -		break;
  80.201 -	case NR23:
  80.202 -		freq	  = (((int)(gbMemory[NR24] & 7)) << 8) | data;
  80.203 -		sound2ATL = 172 * (64 - (gbMemory[NR21] & 0x3f));
  80.204 -		freq	  = 2048 - freq;
  80.205 -		if (freq)
  80.206 -		{
  80.207 -			sound2Skip = SOUND_MAGIC / freq;
  80.208 -		}
  80.209 -		else
  80.210 -			sound2Skip = 0;
  80.211 -		break;
  80.212 -	case NR24:
  80.213 -		freq = (((int)(data & 7) << 8) | gbMemory[NR23]);
  80.214 -		freq = 2048 - freq;
  80.215 -		sound2ATL	   = 172 * (64 - (gbMemory[NR21] & 0x3f));
  80.216 -		sound2Continue = data & 0x40;
  80.217 -		if (freq)
  80.218 -		{
  80.219 -			sound2Skip = SOUND_MAGIC / freq;
  80.220 -		}
  80.221 -		else
  80.222 -			sound2Skip = 0;
  80.223 -		if (data & 0x80)
  80.224 -		{
  80.225 -			gbMemory[NR52]		|= 2;
  80.226 -			sound2EnvelopeVolume = gbMemory[NR22] >> 4;
  80.227 -			sound2EnvelopeUpDown = gbMemory[NR22] & 0x08;
  80.228 -			sound2ATL = 172 * (64 - (gbMemory[NR21] & 0x3f));
  80.229 -			sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (gbMemory[NR22] & 7);
  80.230 -
  80.231 -			sound2Index = 0;
  80.232 -			sound2On	= 1;
  80.233 -		}
  80.234 -		break;
  80.235 -	case NR30:
  80.236 -		if (!(data & 0x80))
  80.237 -		{
  80.238 -			gbMemory[NR52] &= 0xfb;
  80.239 -			sound3On		= 0;
  80.240 -		}
  80.241 -		break;
  80.242 -	case NR31:
  80.243 -		sound3ATL = 172 * (256 - data);
  80.244 -		break;
  80.245 -	case NR32:
  80.246 -		sound3OutputLevel = (data >> 5) & 3;
  80.247 -		break;
  80.248 -	case NR33:
  80.249 -		freq = 2048 - (((int)(gbMemory[NR34] & 7) << 8) | data);
  80.250 -		if (freq)
  80.251 -		{
  80.252 -			sound3Skip = SOUND_MAGIC_2 / freq;
  80.253 -		}
  80.254 -		else
  80.255 -			sound3Skip = 0;
  80.256 -		break;
  80.257 -	case NR34:
  80.258 -		freq = 2048 - (((data & 7) << 8) | (int)gbMemory[NR33]);
  80.259 -		if (freq)
  80.260 -		{
  80.261 -			sound3Skip = SOUND_MAGIC_2 / freq;
  80.262 -		}
  80.263 -		else
  80.264 -		{
  80.265 -			sound3Skip = 0;
  80.266 -		}
  80.267 -		sound3Continue = data & 0x40;
  80.268 -		if ((data & 0x80) && (gbMemory[NR30] & 0x80))
  80.269 -		{
  80.270 -			gbMemory[NR52] |= 4;
  80.271 -			sound3ATL		= 172 * (256 - gbMemory[NR31]);
  80.272 -			sound3Index		= 0;
  80.273 -			sound3On		= 1;
  80.274 -		}
  80.275 -		break;
  80.276 -	case NR41:
  80.277 -		sound4ATL = 172 * (64 - (data & 0x3f));
  80.278 -		break;
  80.279 -	case NR42:
  80.280 -		sound4EnvelopeVolume	= data >> 4;
  80.281 -		sound4EnvelopeUpDown	= data & 0x08;
  80.282 -		sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (data & 7);
  80.283 -		break;
  80.284 -	case NR43:
  80.285 -		freq		 = soundFreqRatio[data & 7];
  80.286 -		sound4NSteps = data & 0x08;
  80.287 -
  80.288 -		sound4Skip = freq * NOISE_MAGIC;
  80.289 -
  80.290 -		sound4Clock = data >> 4;
  80.291 -
  80.292 -		freq = freq / soundShiftClock[sound4Clock];
  80.293 -
  80.294 -		sound4ShiftSkip = freq * NOISE_MAGIC;
  80.295 -
  80.296 -		break;
  80.297 -	case NR44:
  80.298 -		sound4Continue = data & 0x40;
  80.299 -		if (data & 0x80)
  80.300 -		{
  80.301 -			gbMemory[NR52]		|= 8;
  80.302 -			sound4EnvelopeVolume = gbMemory[NR42] >> 4;
  80.303 -			sound4EnvelopeUpDown = gbMemory[NR42] & 0x08;
  80.304 -			sound4ATL = 172 * (64 - (gbMemory[NR41] & 0x3f));
  80.305 -			sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (gbMemory[NR42] & 7);
  80.306 -
  80.307 -			sound4On = 1;
  80.308 -
  80.309 -			sound4Index		 = 0;
  80.310 -			sound4ShiftIndex = 0;
  80.311 -
  80.312 -			freq = soundFreqRatio[gbMemory[NR43] & 7];
  80.313 -
  80.314 -			sound4Skip = freq * NOISE_MAGIC;
  80.315 -
  80.316 -			sound4NSteps = gbMemory[NR43] & 0x08;
  80.317 -
  80.318 -			freq = freq / soundShiftClock[gbMemory[NR43] >> 4];
  80.319 -
  80.320 -			sound4ShiftSkip = freq * NOISE_MAGIC;
  80.321 -			if (sound4NSteps)
  80.322 -				sound4ShiftRight = 0x7f;
  80.323 -			else
  80.324 -				sound4ShiftRight = 0x7fff;
  80.325 -		}
  80.326 -		break;
  80.327 -	case NR50:
  80.328 -		soundVIN	= data & 0x88;
  80.329 -		soundLevel1 = data & 7;
  80.330 -		soundLevel2 = (data >> 4) & 7;
  80.331 -		break;
  80.332 -	case NR51:
  80.333 -		soundBalance	  = (data & soundEnableFlag);
  80.334 -		gbMemory[address] = data;
  80.335 -		break;
  80.336 -	case NR52:
  80.337 -		soundMasterOn = data & 0x80;
  80.338 -		if (!(data & 0x80))
  80.339 -		{
  80.340 -			sound1On = 0;
  80.341 -			sound2On = 0;
  80.342 -			sound3On = 0;
  80.343 -			sound4On = 0;
  80.344 -		}
  80.345 -		break;
  80.346 -	}
  80.347 -
  80.348 -	gbDigitalSound = true;
  80.349 -
  80.350 -	if (sound1On && sound1EnvelopeVolume != 0)
  80.351 -		gbDigitalSound = false;
  80.352 -	if (sound2On && sound2EnvelopeVolume != 0)
  80.353 -		gbDigitalSound = false;
  80.354 -	if (sound3On && sound3OutputLevel != 0)
  80.355 -		gbDigitalSound = false;
  80.356 -	if (sound4On && sound4EnvelopeVolume != 0)
  80.357 -		gbDigitalSound = false;
  80.358 -}
  80.359 -
  80.360 -void gbSoundChannel1()
  80.361 -{
  80.362 -	int vol = sound1EnvelopeVolume;
  80.363 -
  80.364 -	int freq = 0;
  80.365 -
  80.366 -	int value = 0;
  80.367 -
  80.368 -	if (sound1On && (sound1ATL || !sound1Continue))
  80.369 -	{
  80.370 -		sound1Index += soundQuality * sound1Skip;
  80.371 -		sound1Index &= 0x1fffffff;
  80.372 -
  80.373 -		value = ((s8)sound1Wave[sound1Index >> 24]) * vol;
  80.374 -	}
  80.375 -
  80.376 -	soundBuffer[0][soundIndex] = value;
  80.377 -
  80.378 -	if (sound1On)
  80.379 -	{
  80.380 -		if (sound1ATL)
  80.381 -		{
  80.382 -			sound1ATL -= soundQuality;
  80.383 -
  80.384 -			if (sound1ATL <= 0 && sound1Continue)
  80.385 -			{
  80.386 -				gbMemory[NR52] &= 0xfe;
  80.387 -				sound1On		= 0;
  80.388 -			}
  80.389 -		}
  80.390 -
  80.391 -		if (sound1EnvelopeATL)
  80.392 -		{
  80.393 -			sound1EnvelopeATL -= soundQuality;
  80.394 -
  80.395 -			if (sound1EnvelopeATL <= 0)
  80.396 -			{
  80.397 -				if (sound1EnvelopeUpDown)
  80.398 -				{
  80.399 -					if (sound1EnvelopeVolume < 15)
  80.400 -						sound1EnvelopeVolume++;
  80.401 -				}
  80.402 -				else
  80.403 -				{
  80.404 -					if (sound1EnvelopeVolume)
  80.405 -						sound1EnvelopeVolume--;
  80.406 -				}
  80.407 -
  80.408 -				sound1EnvelopeATL += sound1EnvelopeATLReload;
  80.409 -			}
  80.410 -		}
  80.411 -
  80.412 -		if (sound1SweepATL)
  80.413 -		{
  80.414 -			sound1SweepATL -= soundQuality;
  80.415 -
  80.416 -			if (sound1SweepATL <= 0)
  80.417 -			{
  80.418 -				freq = (((int)(gbMemory[NR14] & 7) << 8) | gbMemory[NR13]);
  80.419 -
  80.420 -				int updown = 1;
  80.421 -
  80.422 -				if (sound1SweepUpDown)
  80.423 -					updown = -1;
  80.424 -
  80.425 -				int newfreq = 0;
  80.426 -				if (sound1SweepSteps)
  80.427 -				{
  80.428 -					newfreq = freq + updown * freq / (1 << sound1SweepSteps);
  80.429 -					if (newfreq == freq)
  80.430 -						newfreq = 0;
  80.431 -				}
  80.432 -				else
  80.433 -					newfreq = freq;
  80.434 -
  80.435 -				if (newfreq < 0)
  80.436 -				{
  80.437 -					sound1SweepATL += sound1SweepATLReload;
  80.438 -				}
  80.439 -				else if (newfreq > 2047)
  80.440 -				{
  80.441 -					sound1SweepATL	= 0;
  80.442 -					sound1On		= 0;
  80.443 -					gbMemory[NR52] &= 0xfe;
  80.444 -				}
  80.445 -				else
  80.446 -				{
  80.447 -					sound1SweepATL += sound1SweepATLReload;
  80.448 -					sound1Skip		= SOUND_MAGIC / (2048 - newfreq);
  80.449 -
  80.450 -					gbMemory[NR13] = newfreq & 0xff;
  80.451 -					gbMemory[NR14] = (gbMemory[NR14] & 0xf8) | ((newfreq >> 8) & 7);
  80.452 -				}
  80.453 -			}
  80.454 -		}
  80.455 -	}
  80.456 -}
  80.457 -
  80.458 -void gbSoundChannel2()
  80.459 -{
  80.460 -	//  int freq = 0;
  80.461 -	int vol = sound2EnvelopeVolume;
  80.462 -
  80.463 -	int value = 0;
  80.464 -
  80.465 -	if (sound2On && (sound2ATL || !sound2Continue))
  80.466 -	{
  80.467 -		sound2Index += soundQuality * sound2Skip;
  80.468 -		sound2Index &= 0x1fffffff;
  80.469 -
  80.470 -		value = ((s8)sound2Wave[sound2Index >> 24]) * vol;
  80.471 -	}
  80.472 -
  80.473 -	soundBuffer[1][soundIndex] = value;
  80.474 -
  80.475 -	if (sound2On)
  80.476 -	{
  80.477 -		if (sound2ATL)
  80.478 -		{
  80.479 -			sound2ATL -= soundQuality;
  80.480 -
  80.481 -			if (sound2ATL <= 0 && sound2Continue)
  80.482 -			{
  80.483 -				gbMemory[NR52] &= 0xfd;
  80.484 -				sound2On		= 0;
  80.485 -			}
  80.486 -		}
  80.487 -
  80.488 -		if (sound2EnvelopeATL)
  80.489 -		{
  80.490 -			sound2EnvelopeATL -= soundQuality;
  80.491 -
  80.492 -			if (sound2EnvelopeATL <= 0)
  80.493 -			{
  80.494 -				if (sound2EnvelopeUpDown)
  80.495 -				{
  80.496 -					if (sound2EnvelopeVolume < 15)
  80.497 -						sound2EnvelopeVolume++;
  80.498 -				}
  80.499 -				else
  80.500 -				{
  80.501 -					if (sound2EnvelopeVolume)
  80.502 -						sound2EnvelopeVolume--;
  80.503 -				}
  80.504 -				sound2EnvelopeATL += sound2EnvelopeATLReload;
  80.505 -			}
  80.506 -		}
  80.507 -	}
  80.508 -}
  80.509 -
  80.510 -void gbSoundChannel3()
  80.511 -{
  80.512 -	int value = sound3Last;
  80.513 -
  80.514 -	if (sound3On && (sound3ATL || !sound3Continue))
  80.515 -	{
  80.516 -		sound3Index += soundQuality * sound3Skip;
  80.517 -		sound3Index &= 0x1fffffff;
  80.518 -
  80.519 -		value = gbMemory[0xff30 + (sound3Index >> 25)];
  80.520 -
  80.521 -		if ((sound3Index & 0x01000000))
  80.522 -		{
  80.523 -			value &= 0x0f;
  80.524 -		}
  80.525 -		else
  80.526 -		{
  80.527 -			value >>= 4;
  80.528 -		}
  80.529 -
  80.530 -		value -= 8;
  80.531 -		value *= 2;
  80.532 -
  80.533 -		switch (sound3OutputLevel)
  80.534 -		{
  80.535 -		case 0:
  80.536 -			value = 0;
  80.537 -			break;
  80.538 -		case 1:
  80.539 -			break;
  80.540 -		case 2:
  80.541 -			value = (value >> 1);
  80.542 -			break;
  80.543 -		case 3:
  80.544 -			value = (value >> 2);
  80.545 -			break;
  80.546 -		}
  80.547 -		//value += 1;
  80.548 -		sound3Last = value;
  80.549 -	}
  80.550 -
  80.551 -	soundBuffer[2][soundIndex] = value;
  80.552 -
  80.553 -	if (sound3On)
  80.554 -	{
  80.555 -		if (sound3ATL)
  80.556 -		{
  80.557 -			sound3ATL -= soundQuality;
  80.558 -
  80.559 -			if (sound3ATL <= 0 && sound3Continue)
  80.560 -			{
  80.561 -				gbMemory[NR52] &= 0xfb;
  80.562 -				sound3On		= 0;
  80.563 -			}
  80.564 -		}
  80.565 -	}
  80.566 -}
  80.567 -
  80.568 -void gbSoundChannel4()
  80.569 -{
  80.570 -	int vol = sound4EnvelopeVolume;
  80.571 -
  80.572 -	int value = 0;
  80.573 -
  80.574 -	if (sound4Clock <= 0x0c)
  80.575 -	{
  80.576 -		if (sound4On && (sound4ATL || !sound4Continue))
  80.577 -		{
  80.578 -	  #define NOISE_ONE_SAMP_SCALE  0x200000
  80.579 -
  80.580 -			sound4Index		 += soundQuality * sound4Skip;
  80.581 -			sound4ShiftIndex += soundQuality * sound4ShiftSkip;
  80.582 -
  80.583 -			if (sound4NSteps)
  80.584 -			{
  80.585 -				while (sound4ShiftIndex >= NOISE_ONE_SAMP_SCALE)
  80.586 -				{
  80.587 -					sound4ShiftRight = (((sound4ShiftRight << 6) ^
  80.588 -					                     (sound4ShiftRight << 5)) & 0x40) |
  80.589 -					                   (sound4ShiftRight >> 1);
  80.590 -					sound4ShiftIndex -= NOISE_ONE_SAMP_SCALE;
  80.591 -				}
  80.592 -			}
  80.593 -			else
  80.594 -			{
  80.595 -				while (sound4ShiftIndex >= NOISE_ONE_SAMP_SCALE)
  80.596 -				{
  80.597 -					sound4ShiftRight = (((sound4ShiftRight << 14) ^
  80.598 -					                     (sound4ShiftRight << 13)) & 0x4000) |
  80.599 -					                   (sound4ShiftRight >> 1);
  80.600 -
  80.601 -					sound4ShiftIndex -= NOISE_ONE_SAMP_SCALE;
  80.602 -				}
  80.603 -			}
  80.604 -
  80.605 -			sound4Index		 %= NOISE_ONE_SAMP_SCALE;
  80.606 -			sound4ShiftIndex %= NOISE_ONE_SAMP_SCALE;
  80.607 -
  80.608 -			value = ((sound4ShiftRight & 1) * 2 - 1) * vol;
  80.609 -		}
  80.610 -		else
  80.611 -		{
  80.612 -			value = 0;
  80.613 -		}
  80.614 -	}
  80.615 -
  80.616 -	soundBuffer[3][soundIndex] = value;
  80.617 -
  80.618 -	if (sound4On)
  80.619 -	{
  80.620 -		if (sound4ATL)
  80.621 -		{
  80.622 -			sound4ATL -= soundQuality;
  80.623 -
  80.624 -			if (sound4ATL <= 0 && sound4Continue)
  80.625 -			{
  80.626 -				gbMemory[NR52] &= 0xfd;
  80.627 -				sound4On		= 0;
  80.628 -			}
  80.629 -		}
  80.630 -
  80.631 -		if (sound4EnvelopeATL)
  80.632 -		{
  80.633 -			sound4EnvelopeATL -= soundQuality;
  80.634 -
  80.635 -			if (sound4EnvelopeATL <= 0)
  80.636 -			{
  80.637 -				if (sound4EnvelopeUpDown)
  80.638 -				{
  80.639 -					if (sound4EnvelopeVolume < 15)
  80.640 -						sound4EnvelopeVolume++;
  80.641 -				}
  80.642 -				else
  80.643 -				{
  80.644 -					if (sound4EnvelopeVolume)
  80.645 -						sound4EnvelopeVolume--;
  80.646 -				}
  80.647 -				sound4EnvelopeATL += sound4EnvelopeATLReload;
  80.648 -			}
  80.649 -		}
  80.650 -	}
  80.651 -}
  80.652 -
  80.653 -void gbSoundMix()
  80.654 -{
  80.655 -	int res = 0;
  80.656 -
  80.657 -	if (gbMemory)
  80.658 -		soundBalance = (gbMemory[NR51] & soundEnableFlag & ~soundMutedFlag);
  80.659 -
  80.660 -	if (soundBalance & 16)
  80.661 -	{
  80.662 -		res += ((s8)soundBuffer[0][soundIndex]);
  80.663 -	}
  80.664 -	if (soundBalance & 32)
  80.665 -	{
  80.666 -		res += ((s8)soundBuffer[1][soundIndex]);
  80.667 -	}
  80.668 -	if (soundBalance & 64)
  80.669 -	{
  80.670 -		res += ((s8)soundBuffer[2][soundIndex]);
  80.671 -	}
  80.672 -	if (soundBalance & 128)
  80.673 -	{
  80.674 -		res += ((s8)soundBuffer[3][soundIndex]);
  80.675 -	}
  80.676 -
  80.677 -	if (gbDigitalSound)
  80.678 -		res = soundLevel1 * 256;
  80.679 -	else
  80.680 -		res *= soundLevel1 * 60;
  80.681 -
  80.682 -	if (soundEcho)
  80.683 -	{
  80.684 -		res *= 2;
  80.685 -		res += soundFilter[soundEchoIndex];
  80.686 -		res /= 2;
  80.687 -		soundFilter[soundEchoIndex++] = res;
  80.688 -	}
  80.689 -
  80.690 -	if (soundLowPass)
  80.691 -	{
  80.692 -		soundLeft[4] = soundLeft[3];
  80.693 -		soundLeft[3] = soundLeft[2];
  80.694 -		soundLeft[2] = soundLeft[1];
  80.695 -		soundLeft[1] = soundLeft[0];
  80.696 -		soundLeft[0] = res;
  80.697 -		res = (soundLeft[4] + 2 * soundLeft[3] + 8 * soundLeft[2] + 2 * soundLeft[1] +
  80.698 -		       soundLeft[0]) / 14;
  80.699 -	}
  80.700 -
  80.701 -	bool noSpecialEffects = false;
  80.702 -#if (defined(WIN32) && !defined(SDL))
  80.703 -	if (theApp.soundRecording || theApp.aviRecording || theApp.nvAudioLog)
  80.704 -		noSpecialEffects = true;
  80.705 -#endif
  80.706 -
  80.707 -	if (!noSpecialEffects)
  80.708 -	{
  80.709 -		switch (soundVolume)
  80.710 -		{
  80.711 -		case 0:
  80.712 -		case 1:
  80.713 -		case 2:
  80.714 -		case 3:
  80.715 -			res *= (soundVolume + 1);
  80.716 -			break;
  80.717 -		case 4:
  80.718 -			res >>= 2;
  80.719 -			break;
  80.720 -		case 5:
  80.721 -			res >>= 1;
  80.722 -			break;
  80.723 -		}
  80.724 -	}
  80.725 -
  80.726 -	if (res > 32767)
  80.727 -		res = 32767;
  80.728 -	if (res < -32768)
  80.729 -		res = -32768;
  80.730 -
  80.731 -	if (soundReverse && !noSpecialEffects)
  80.732 -	{
  80.733 -		soundFinalWave[++soundBufferIndex] = res;
  80.734 -		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
  80.735 -			/*assert(false)*/;
  80.736 -		else
  80.737 -			soundFrameSound[++soundFrameSoundWritten] = res;
  80.738 -	}
  80.739 -	else
  80.740 -	{
  80.741 -		soundFinalWave[soundBufferIndex++] = res;
  80.742 -		if (soundFrameSoundWritten >= countof(soundFrameSound))
  80.743 -			/*assert(false)*/;
  80.744 -		else
  80.745 -			soundFrameSound[soundFrameSoundWritten++] = res;
  80.746 -	}
  80.747 -
  80.748 -	res = 0;
  80.749 -
  80.750 -	if (soundBalance & 1)
  80.751 -	{
  80.752 -		res += ((s8)soundBuffer[0][soundIndex]);
  80.753 -	}
  80.754 -	if (soundBalance & 2)
  80.755 -	{
  80.756 -		res += ((s8)soundBuffer[1][soundIndex]);
  80.757 -	}
  80.758 -	if (soundBalance & 4)
  80.759 -	{
  80.760 -		res += ((s8)soundBuffer[2][soundIndex]);
  80.761 -	}
  80.762 -	if (soundBalance & 8)
  80.763 -	{
  80.764 -		res += ((s8)soundBuffer[3][soundIndex]);
  80.765 -	}
  80.766 -
  80.767 -	if (gbDigitalSound)
  80.768 -		res = soundLevel2 * 256;
  80.769 -	else
  80.770 -		res *= soundLevel2 * 60;
  80.771 -
  80.772 -	if (soundEcho)
  80.773 -	{
  80.774 -		res *= 2;
  80.775 -		res += soundFilter[soundEchoIndex];
  80.776 -		res /= 2;
  80.777 -		soundFilter[soundEchoIndex++] = res;
  80.778 -
  80.779 -		if (soundEchoIndex >= 4000)
  80.780 -			soundEchoIndex = 0;
  80.781 -	}
  80.782 -
  80.783 -	if (soundLowPass)
  80.784 -	{
  80.785 -		soundRight[4] = soundRight[3];
  80.786 -		soundRight[3] = soundRight[2];
  80.787 -		soundRight[2] = soundRight[1];
  80.788 -		soundRight[1] = soundRight[0];
  80.789 -		soundRight[0] = res;
  80.790 -		res = (soundRight[4] + 2 * soundRight[3] + 8 * soundRight[2] + 2 * soundRight[1] +
  80.791 -		       soundRight[0]) / 14;
  80.792 -	}
  80.793 -
  80.794 -	if (!noSpecialEffects)
  80.795 -	{
  80.796 -		switch (soundVolume)
  80.797 -		{
  80.798 -		case 0:
  80.799 -		case 1:
  80.800 -		case 2:
  80.801 -		case 3:
  80.802 -			res *= (soundVolume + 1);
  80.803 -			break;
  80.804 -		case 4:
  80.805 -			res >>= 2;
  80.806 -			break;
  80.807 -		case 5:
  80.808 -			res >>= 1;
  80.809 -			break;
  80.810 -		}
  80.811 -	}
  80.812 -
  80.813 -	if (res > 32767)
  80.814 -		res = 32767;
  80.815 -	if (res < -32768)
  80.816 -		res = -32768;
  80.817 -
  80.818 -	if (soundReverse && !noSpecialEffects)
  80.819 -	{
  80.820 -		soundFinalWave[-1 + soundBufferIndex++]		   = res;
  80.821 -		if ((soundFrameSoundWritten) >= countof(soundFrameSound))
  80.822 -			/*assert(false)*/;
  80.823 -		else
  80.824 -			soundFrameSound[-1 + soundFrameSoundWritten++] = res;
  80.825 -	}
  80.826 -	else
  80.827 -	{
  80.828 -		soundFinalWave[soundBufferIndex++]			  = res;
  80.829 -		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
  80.830 -			/*assert(false)*/;
  80.831 -		else
  80.832 -			soundFrameSound[soundFrameSoundWritten++] = res;
  80.833 -	}
  80.834 -}
  80.835 -
  80.836 -void gbSoundTick()
  80.837 -{
  80.838 -	if (systemSoundOn)
  80.839 -	{
  80.840 -		if (soundMasterOn)
  80.841 -		{
  80.842 -			gbSoundChannel1();
  80.843 -			gbSoundChannel2();
  80.844 -			gbSoundChannel3();
  80.845 -			gbSoundChannel4();
  80.846 -
  80.847 -			gbSoundMix();
  80.848 -		}
  80.849 -		else
  80.850 -		{
  80.851 -			soundFinalWave[soundBufferIndex++] = 0;
  80.852 -			soundFinalWave[soundBufferIndex++] = 0;
  80.853 -			if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
  80.854 -				/*assert(false)*/;
  80.855 -			else
  80.856 -			{
  80.857 -				soundFrameSound[soundFrameSoundWritten++] = 0;
  80.858 -				soundFrameSound[soundFrameSoundWritten++] = 0;
  80.859 -			}
  80.860 -		}
  80.861 -
  80.862 -		soundIndex++;
  80.863 -
  80.864 -		if (2 * soundBufferIndex >= soundBufferLen)
  80.865 -		{
  80.866 -			if (systemSoundOn)
  80.867 -			{
  80.868 -				if (soundPaused)
  80.869 -				{
  80.870 -					extern void soundResume();
  80.871 -					soundResume();
  80.872 -				}
  80.873 -
  80.874 -				systemSoundWriteToBuffer();
  80.875 -			}
  80.876 -			soundIndex		 = 0;
  80.877 -			soundBufferIndex = 0;
  80.878 -		}
  80.879 -	}
  80.880 -}
  80.881 -
  80.882 -void gbSoundReset()
  80.883 -{
  80.884 -	soundPaused		  = 1;
  80.885 -	soundPlay		  = 0;
  80.886 -	SOUND_CLOCK_TICKS = soundQuality * GB_USE_TICKS_AS;
  80.887 -//  soundTicks = SOUND_CLOCK_TICKS;
  80.888 -	soundTicks		  = 0;
  80.889 -	soundNextPosition = 0;
  80.890 -	soundMasterOn	  = 1;
  80.891 -	soundIndex		  = 0;
  80.892 -	soundBufferIndex  = 0;
  80.893 -	soundLevel1		  = 7;
  80.894 -	soundLevel2		  = 7;
  80.895 -	soundVIN = 0;
  80.896 -
  80.897 -	sound1On = 0;
  80.898 -	sound1ATL = 0;
  80.899 -	sound1Skip = 0;
  80.900 -	sound1Index = 0;
  80.901 -	sound1Continue = 0;
  80.902 -	sound1EnvelopeVolume	= 0;
  80.903 -	sound1EnvelopeATL		= 0;
  80.904 -	sound1EnvelopeUpDown	= 0;
  80.905 -	sound1EnvelopeATLReload = 0;
  80.906 -	sound1SweepATL			= 0;
  80.907 -	sound1SweepATLReload	= 0;
  80.908 -	sound1SweepSteps		= 0;
  80.909 -	sound1SweepUpDown		= 0;
  80.910 -	sound1SweepStep			= 0;
  80.911 -	sound1Wave				= soundWavePattern[2];
  80.912 -
  80.913 -	sound2On = 0;
  80.914 -	sound2ATL = 0;
  80.915 -	sound2Skip = 0;
  80.916 -	sound2Index = 0;
  80.917 -	sound2Continue = 0;
  80.918 -	sound2EnvelopeVolume	= 0;
  80.919 -	sound2EnvelopeATL		= 0;
  80.920 -	sound2EnvelopeUpDown	= 0;
  80.921 -	sound2EnvelopeATLReload = 0;
  80.922 -	sound2Wave				= soundWavePattern[2];
  80.923 -
  80.924 -	sound3On = 0;
  80.925 -	sound3ATL		  = 0;
  80.926 -	sound3Skip		  = 0;
  80.927 -	sound3Index		  = 0;
  80.928 -	sound3Continue	  = 0;
  80.929 -	sound3OutputLevel = 0;
  80.930 -
  80.931 -	sound4On = 0;
  80.932 -	sound4Clock = 0;
  80.933 -	sound4ATL = 0;
  80.934 -	sound4Skip = 0;
  80.935 -	sound4Index = 0;
  80.936 -	sound4ShiftRight		= 0x7f;
  80.937 -	sound4NSteps			= 0;
  80.938 -	sound4CountDown			= 0;
  80.939 -	sound4Continue			= 0;
  80.940 -	sound4EnvelopeVolume	= 0;
  80.941 -	sound4EnvelopeATL		= 0;
  80.942 -	sound4EnvelopeUpDown	= 0;
  80.943 -	sound4EnvelopeATLReload = 0;
  80.944 -
  80.945 -	// don't translate
  80.946 -	if (soundDebug)
  80.947 -	{
  80.948 -		log("*** Sound Init ***\n");
  80.949 -	}
  80.950 -
  80.951 -	gbSoundEvent(0xff10, 0x80);
  80.952 -	gbSoundEvent(0xff11, 0xbf);
  80.953 -	gbSoundEvent(0xff12, 0xf3);
  80.954 -	gbSoundEvent(0xff14, 0xbf);
  80.955 -	gbSoundEvent(0xff16, 0x3f);
  80.956 -	gbSoundEvent(0xff17, 0x00);
  80.957 -	gbSoundEvent(0xff19, 0xbf);
  80.958 -
  80.959 -	gbSoundEvent(0xff1a, 0x7f);
  80.960 -	gbSoundEvent(0xff1b, 0xff);
  80.961 -	gbSoundEvent(0xff1c, 0xbf);
  80.962 -	gbSoundEvent(0xff1e, 0xbf);
  80.963 -
  80.964 -	gbSoundEvent(0xff20, 0xff);
  80.965 -	gbSoundEvent(0xff21, 0x00);
  80.966 -	gbSoundEvent(0xff22, 0x00);
  80.967 -	gbSoundEvent(0xff23, 0xbf);
  80.968 -	gbSoundEvent(0xff24, 0x77);
  80.969 -	gbSoundEvent(0xff25, 0xf3);
  80.970 -
  80.971 -	gbSoundEvent(0xff26, 0xf0);
  80.972 -
  80.973 -	// don't translate
  80.974 -	if (soundDebug)
  80.975 -	{
  80.976 -		log("*** Sound Init Complete ***\n");
  80.977 -	}
  80.978 -
  80.979 -	sound1On = 0;
  80.980 -	sound2On = 0;
  80.981 -	sound3On = 0;
  80.982 -	sound4On = 0;
  80.983 -
  80.984 -	int addr = 0xff30;
  80.985 -
  80.986 -	while (addr < 0xff40)
  80.987 -	{
  80.988 -		gbMemory[addr++] = 0x00;
  80.989 -		gbMemory[addr++] = 0xff;
  80.990 -	}
  80.991 -
  80.992 -	memset(soundFinalWave, 0x00, soundBufferLen);
  80.993 -
  80.994 -	memset(soundFilter, 0, sizeof(soundFilter));
  80.995 -	soundEchoIndex = 0;
  80.996 -}
  80.997 -
  80.998 -extern bool soundInit();
  80.999 -extern void soundShutdown();
 80.1000 -
 80.1001 -void gbSoundSetQuality(int quality)
 80.1002 -{
 80.1003 -	if (soundQuality != quality && systemSoundCanChangeQuality())
 80.1004 -	{
 80.1005 -		if (!soundOffFlag)
 80.1006 -			soundShutdown();
 80.1007 -		soundQuality	  = quality;
 80.1008 -		soundNextPosition = 0;
 80.1009 -		if (!soundOffFlag)
 80.1010 -			soundInit();
 80.1011 -		SOUND_CLOCK_TICKS = (gbSpeed ? 2 : 1) * GB_USE_TICKS_AS * soundQuality;
 80.1012 -		soundIndex		  = 0;
 80.1013 -		soundBufferIndex  = 0;
 80.1014 -	}
 80.1015 -	else
 80.1016 -	{
 80.1017 -		soundNextPosition = 0;
 80.1018 -		SOUND_CLOCK_TICKS = (gbSpeed ? 2 : 1) * GB_USE_TICKS_AS * soundQuality;
 80.1019 -		soundIndex		  = 0;
 80.1020 -		soundBufferIndex  = 0;
 80.1021 -	}
 80.1022 -}
 80.1023 -
 80.1024 -static int32 soundTicks_int32;
 80.1025 -static int32 SOUND_CLOCK_TICKS_int32;
 80.1026 -variable_desc gbSoundSaveStruct[] = {
 80.1027 -	{ &soundPaused,				sizeof(int32)					  },
 80.1028 -	{ &soundPlay,				sizeof(int32)					  },
 80.1029 -	{ &soundTicks_int32,		sizeof(int32)					  },
 80.1030 -	{ &SOUND_CLOCK_TICKS_int32, sizeof(int32)					  },
 80.1031 -	{ &soundLevel1,				sizeof(int32)					  },
 80.1032 -	{ &soundLevel2,				sizeof(int32)					  },
 80.1033 -	{ &soundBalance,			sizeof(int32)					  },
 80.1034 -	{ &soundMasterOn,			sizeof(int32)					  },
 80.1035 -	{ &soundIndex,				sizeof(int32)					  },
 80.1036 -	{ &soundVIN,				sizeof(int32)					  },
 80.1037 -	{ &sound1On,				sizeof(int32)					  },
 80.1038 -	{ &sound1ATL,				sizeof(int32)					  },
 80.1039 -	{ &sound1Skip,				sizeof(int32)					  },
 80.1040 -	{ &sound1Index,				sizeof(int32)					  },
 80.1041 -	{ &sound1Continue,			sizeof(int32)					  },
 80.1042 -	{ &sound1EnvelopeVolume,	sizeof(int32)					  },
 80.1043 -	{ &sound1EnvelopeATL,		sizeof(int32)					  },
 80.1044 -	{ &sound1EnvelopeATLReload, sizeof(int32)					  },
 80.1045 -	{ &sound1EnvelopeUpDown,	sizeof(int32)					  },
 80.1046 -	{ &sound1SweepATL,			sizeof(int32)					  },
 80.1047 -	{ &sound1SweepATLReload,	sizeof(int32)					  },
 80.1048 -	{ &sound1SweepSteps,		sizeof(int32)					  },
 80.1049 -	{ &sound1SweepUpDown,		sizeof(int32)					  },
 80.1050 -	{ &sound1SweepStep,			sizeof(int32)					  },
 80.1051 -	{ &sound2On,				sizeof(int32)					  },
 80.1052 -	{ &sound2ATL,				sizeof(int32)					  },
 80.1053 -	{ &sound2Skip,				sizeof(int32)					  },
 80.1054 -	{ &sound2Index,				sizeof(int32)					  },
 80.1055 -	{ &sound2Continue,			sizeof(int32)					  },
 80.1056 -	{ &sound2EnvelopeVolume,	sizeof(int32)					  },
 80.1057 -	{ &sound2EnvelopeATL,		sizeof(int32)					  },
 80.1058 -	{ &sound2EnvelopeATLReload, sizeof(int32)					  },
 80.1059 -	{ &sound2EnvelopeUpDown,	sizeof(int32)					  },
 80.1060 -	{ &sound3On,				sizeof(int32)					  },
 80.1061 -	{ &sound3ATL,				sizeof(int32)					  },
 80.1062 -	{ &sound3Skip,				sizeof(int32)					  },
 80.1063 -	{ &sound3Index,				sizeof(int32)					  },
 80.1064 -	{ &sound3Continue,			sizeof(int32)					  },
 80.1065 -	{ &sound3OutputLevel,		sizeof(int32)					  },
 80.1066 -	{ &sound4On,				sizeof(int32)					  },
 80.1067 -	{ &sound4ATL,				sizeof(int32)					  },
 80.1068 -	{ &sound4Skip,				sizeof(int32)					  },
 80.1069 -	{ &sound4Index,				sizeof(int32)					  },
 80.1070 -	{ &sound4Clock,				sizeof(int32)					  },
 80.1071 -	{ &sound4ShiftRight,		sizeof(int32)					  },
 80.1072 -	{ &sound4ShiftSkip,			sizeof(int32)					  },
 80.1073 -	{ &sound4ShiftIndex,		sizeof(int32)					  },
 80.1074 -	{ &sound4NSteps,			sizeof(int32)					  },
 80.1075 -	{ &sound4CountDown,			sizeof(int32)					  },
 80.1076 -	{ &sound4Continue,			sizeof(int32)					  },
 80.1077 -	{ &sound4EnvelopeVolume,	sizeof(int32)					  },
 80.1078 -	{ &sound4EnvelopeATL,		sizeof(int32)					  },
 80.1079 -	{ &sound4EnvelopeATLReload, sizeof(int32)					  },
 80.1080 -	{ &sound4EnvelopeUpDown,	sizeof(int32)					  },
 80.1081 -	{ &soundEnableFlag,			sizeof(int32)					  },
 80.1082 -	{ NULL,						0								  }
 80.1083 -};
 80.1084 -
 80.1085 -//variable_desc gbSoundSaveStructV2[] = {
 80.1086 -//  { &soundTicks, sizeof(soundtick_t) },
 80.1087 -//  { &SOUND_CLOCK_TICKS, sizeof(soundtick_t) },
 80.1088 -//  { &GB_USE_TICKS_AS, sizeof(soundtick_t) },
 80.1089 -//  { NULL, 0 }
 80.1090 -//};
 80.1091 -
 80.1092 -void gbSoundSaveGame(gzFile gzFile)
 80.1093 -{
 80.1094 -	soundTicks_int32		= (int32) soundTicks;
 80.1095 -	SOUND_CLOCK_TICKS_int32 = (int32) SOUND_CLOCK_TICKS;
 80.1096 -
 80.1097 -	utilWriteData(gzFile, gbSoundSaveStruct);
 80.1098 -
 80.1099 -	utilGzWrite(gzFile, soundBuffer, 4 * 735);
 80.1100 -	utilGzWrite(gzFile, soundFinalWave, 2 * 735);
 80.1101 -	utilGzWrite(gzFile, &soundQuality, sizeof(int32));
 80.1102 -
 80.1103 -	//utilWriteData(gzFile, gbSoundSaveStructV2);
 80.1104 -}
 80.1105 -
 80.1106 -void gbSoundReadGame(int version, gzFile gzFile)
 80.1107 -{
 80.1108 -	int32 oldSoundPaused = soundPaused;
 80.1109 -	int32 oldSoundEnableFlag = soundEnableFlag;
 80.1110 -	utilReadData(gzFile, gbSoundSaveStruct);
 80.1111 -	soundPaused = oldSoundPaused;
 80.1112 -	soundEnableFlag = oldSoundEnableFlag;
 80.1113 -
 80.1114 -	soundBufferIndex = soundIndex * 2;
 80.1115 -
 80.1116 -	utilGzRead(gzFile, soundBuffer, 4 * 735);
 80.1117 -	utilGzRead(gzFile, soundFinalWave, 2 * 735);
 80.1118 -
 80.1119 -	if (version >= 7)
 80.1120 -	{
 80.1121 -		int quality = 1;
 80.1122 -		utilGzRead(gzFile, &quality, sizeof(int32));
 80.1123 -		gbSoundSetQuality(quality);
 80.1124 -	}
 80.1125 -	else
 80.1126 -	{
 80.1127 -		soundQuality = -1;
 80.1128 -		gbSoundSetQuality(1);
 80.1129 -	}
 80.1130 -
 80.1131 -	sound1Wave = soundWavePattern[gbMemory[NR11] >> 6];
 80.1132 -	sound2Wave = soundWavePattern[gbMemory[NR21] >> 6];
 80.1133 -
 80.1134 -	//if(version >= 14) {
 80.1135 -	//  utilReadData(gzFile, gbSoundSaveStructV2);
 80.1136 -	//}
 80.1137 -	//else {
 80.1138 -	soundTicks		  = (soundtick_t) soundTicks_int32;
 80.1139 -	SOUND_CLOCK_TICKS = (soundtick_t) SOUND_CLOCK_TICKS_int32;
 80.1140 -	//}
 80.1141 -}
 80.1142 -
    81.1 --- a/src/gb/gbSound.h	Sat Mar 03 10:54:39 2012 -0600
    81.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.3 @@ -1,51 +0,0 @@
    81.4 -#ifndef VBA_GB_SOUND_H
    81.5 -#define VBA_GB_SOUND_H
    81.6 -
    81.7 -#if _MSC_VER > 1000
    81.8 -#pragma once
    81.9 -#endif // _MSC_VER > 1000
   81.10 -
   81.11 -#define NR10 0xff10
   81.12 -#define NR11 0xff11
   81.13 -#define NR12 0xff12
   81.14 -#define NR13 0xff13
   81.15 -#define NR14 0xff14
   81.16 -#define NR21 0xff16
   81.17 -#define NR22 0xff17
   81.18 -#define NR23 0xff18
   81.19 -#define NR24 0xff19
   81.20 -#define NR30 0xff1a
   81.21 -#define NR31 0xff1b
   81.22 -#define NR32 0xff1c
   81.23 -#define NR33 0xff1d
   81.24 -#define NR34 0xff1e
   81.25 -#define NR41 0xff20
   81.26 -#define NR42 0xff21
   81.27 -#define NR43 0xff22
   81.28 -#define NR44 0xff23
   81.29 -#define NR50 0xff24
   81.30 -#define NR51 0xff25
   81.31 -#define NR52 0xff26
   81.32 -
   81.33 -#define SOUND_EVENT(address, value) \
   81.34 -    gbSoundEvent(address, value)
   81.35 -
   81.36 -extern void gbSoundTick();
   81.37 -extern void gbSoundPause();
   81.38 -extern void gbSoundResume();
   81.39 -extern void gbSoundEnable(int);
   81.40 -extern void gbSoundDisable(int);
   81.41 -extern int gbSoundGetEnable();
   81.42 -extern void gbSoundReset();
   81.43 -extern void gbSoundSaveGame(gzFile);
   81.44 -extern void gbSoundReadGame(int, gzFile);
   81.45 -extern void gbSoundEvent(register u16, register int);
   81.46 -extern void gbSoundSetQuality(int);
   81.47 -
   81.48 -typedef int32 soundtick_t;
   81.49 -
   81.50 -extern soundtick_t soundTicks;
   81.51 -extern int32       soundQuality;
   81.52 -extern soundtick_t SOUND_CLOCK_TICKS;
   81.53 -
   81.54 -#endif // VBA_GB_SOUND_H
    82.1 --- a/src/gba/EEprom.cpp	Sat Mar 03 10:54:39 2012 -0600
    82.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.3 @@ -1,210 +0,0 @@
    82.4 -#include <cstring>
    82.5 -
    82.6 -#include "GBA.h" // for SAVE_GAME_VERSION_3
    82.7 -#include "EEprom.h"
    82.8 -#include "../common/System.h"
    82.9 -#include "../common/Util.h"
   82.10 -
   82.11 -extern int32 cpuDmaCount;
   82.12 -
   82.13 -int32 eepromMode    = EEPROM_IDLE;
   82.14 -int32 eepromByte    = 0;
   82.15 -int32 eepromBits    = 0;
   82.16 -int32 eepromAddress = 0;
   82.17 -u8    eepromData[0x2000];
   82.18 -u8    eepromBuffer[16];
   82.19 -bool8 eepromInUse = false;
   82.20 -int32 eepromSize  = 512;
   82.21 -
   82.22 -variable_desc eepromSaveData[] = {
   82.23 -	{ &eepromMode,		sizeof(int32) },
   82.24 -	{ &eepromByte,		sizeof(int32) },
   82.25 -	{ &eepromBits,		sizeof(int32) },
   82.26 -	{ &eepromAddress,	sizeof(int32) },
   82.27 -	{ &eepromInUse,		sizeof(bool8) },
   82.28 -	{ &eepromData[0],             512 },
   82.29 -	{ &eepromBuffer[0],            16 },
   82.30 -	{ NULL,							0 }
   82.31 -};
   82.32 -
   82.33 -void eepromReset()
   82.34 -{
   82.35 -	eepromMode    = EEPROM_IDLE;
   82.36 -	eepromByte    = 0;
   82.37 -	eepromBits    = 0;
   82.38 -	eepromAddress = 0;
   82.39 -	eepromInUse   = false;
   82.40 -	eepromSize    = 512;
   82.41 -}
   82.42 -
   82.43 -void eepromErase()
   82.44 -{
   82.45 -	memset(eepromData, 0, 0x2000*sizeof(u8));
   82.46 -	eepromMode    = EEPROM_IDLE;
   82.47 -	eepromByte    = 0;
   82.48 -	eepromBits    = 0;
   82.49 -	eepromAddress = 0;
   82.50 -	memset(eepromBuffer, 0, 16*sizeof(u8));
   82.51 -	eepromInUse = false;
   82.52 -	eepromSize  = 512;
   82.53 -}
   82.54 -
   82.55 -void eepromSaveGame(gzFile gzFile)
   82.56 -{
   82.57 -	utilWriteData(gzFile, eepromSaveData);
   82.58 -	utilWriteInt(gzFile, eepromSize);
   82.59 -	utilGzWrite(gzFile, eepromData, 0x2000);
   82.60 -}
   82.61 -
   82.62 -void eepromReadGame(gzFile gzFile, int version)
   82.63 -{
   82.64 -	utilReadData(gzFile, eepromSaveData);
   82.65 -	if (version >= SAVE_GAME_VERSION_3)
   82.66 -	{
   82.67 -		eepromSize = utilReadInt(gzFile);
   82.68 -		utilGzRead(gzFile, eepromData, 0x2000);
   82.69 -	}
   82.70 -	else
   82.71 -	{
   82.72 -		// prior to 0.7.1, only 4K EEPROM was supported
   82.73 -		eepromSize = 512;
   82.74 -	}
   82.75 -}
   82.76 -
   82.77 -int eepromRead(u32 /* address */)
   82.78 -{
   82.79 -	switch (eepromMode)
   82.80 -	{
   82.81 -	case EEPROM_IDLE:
   82.82 -	case EEPROM_READADDRESS:
   82.83 -	case EEPROM_WRITEDATA:
   82.84 -		return 1;
   82.85 -	case EEPROM_READDATA:
   82.86 -	{
   82.87 -		eepromBits++;
   82.88 -		if (eepromBits == 4)
   82.89 -		{
   82.90 -			eepromMode = EEPROM_READDATA2;
   82.91 -			eepromBits = 0;
   82.92 -			eepromByte = 0;
   82.93 -		}
   82.94 -		return 0;
   82.95 -	}
   82.96 -	case EEPROM_READDATA2:
   82.97 -	{
   82.98 -		int data    = 0;
   82.99 -		int address = eepromAddress << 3;
  82.100 -		int mask    = 1 << (7 - (eepromBits & 7));
  82.101 -		data = (eepromData[address+eepromByte] & mask) ? 1 : 0;
  82.102 -		eepromBits++;
  82.103 -		if ((eepromBits & 7) == 0)
  82.104 -			eepromByte++;
  82.105 -		if (eepromBits == 0x40)
  82.106 -			eepromMode = EEPROM_IDLE;
  82.107 -		return data;
  82.108 -	}
  82.109 -	default:
  82.110 -		return 0;
  82.111 -	}
  82.112 -	return 1;
  82.113 -}
  82.114 -
  82.115 -void eepromWrite(u32 /* address */, u8 value)
  82.116 -{
  82.117 -	if (cpuDmaCount == 0)
  82.118 -		return;
  82.119 -	int bit = value & 1;
  82.120 -	switch (eepromMode)
  82.121 -	{
  82.122 -	case EEPROM_IDLE:
  82.123 -		eepromByte = 0;
  82.124 -		eepromBits = 1;
  82.125 -		eepromBuffer[eepromByte] = bit;
  82.126 -		eepromMode = EEPROM_READADDRESS;
  82.127 -		break;
  82.128 -	case EEPROM_READADDRESS:
  82.129 -		eepromBuffer[eepromByte] <<= 1;
  82.130 -		eepromBuffer[eepromByte]  |= bit;
  82.131 -		eepromBits++;
  82.132 -		if ((eepromBits & 7) == 0)
  82.133 -		{
  82.134 -			eepromByte++;
  82.135 -		}
  82.136 -		if (cpuDmaCount == 0x11 || cpuDmaCount == 0x51)
  82.137 -		{
  82.138 -			if (eepromBits == 0x11)
  82.139 -			{
  82.140 -				eepromInUse   = true;
  82.141 -				eepromSize    = 0x2000;
  82.142 -				eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) |
  82.143 -				                ((eepromBuffer[1] & 0xFF));
  82.144 -				if (!(eepromBuffer[0] & 0x40))
  82.145 -				{
  82.146 -					eepromBuffer[0] = bit;
  82.147 -					eepromBits      = 1;
  82.148 -					eepromByte      = 0;
  82.149 -					eepromMode      = EEPROM_WRITEDATA;
  82.150 -				}
  82.151 -				else
  82.152 -				{
  82.153 -					eepromMode = EEPROM_READDATA;
  82.154 -					eepromByte = 0;
  82.155 -					eepromBits = 0;
  82.156 -				}
  82.157 -			}
  82.158 -		}
  82.159 -		else
  82.160 -		{
  82.161 -			if (eepromBits == 9)
  82.162 -			{
  82.163 -				eepromInUse   = true;
  82.164 -				eepromAddress = (eepromBuffer[0] & 0x3F);
  82.165 -				if (!(eepromBuffer[0] & 0x40))
  82.166 -				{
  82.167 -					eepromBuffer[0] = bit;
  82.168 -					eepromBits      = 1;
  82.169 -					eepromByte      = 0;
  82.170 -					eepromMode      = EEPROM_WRITEDATA;
  82.171 -				}
  82.172 -				else
  82.173 -				{
  82.174 -					eepromMode = EEPROM_READDATA;
  82.175 -					eepromByte = 0;
  82.176 -					eepromBits = 0;
  82.177 -				}
  82.178 -			}
  82.179 -		}
  82.180 -		break;
  82.181 -	case EEPROM_READDATA:
  82.182 -	case EEPROM_READDATA2:
  82.183 -		// should we reset here?
  82.184 -		eepromMode = EEPROM_IDLE;
  82.185 -		break;
  82.186 -	case EEPROM_WRITEDATA:
  82.187 -		eepromBuffer[eepromByte] <<= 1;
  82.188 -		eepromBuffer[eepromByte]  |= bit;
  82.189 -		eepromBits++;
  82.190 -		if ((eepromBits & 7) == 0)
  82.191 -		{
  82.192 -			eepromByte++;
  82.193 -		}
  82.194 -		if (eepromBits == 0x40)
  82.195 -		{
  82.196 -			eepromInUse = true;
  82.197 -			// write data;
  82.198 -			for (int i = 0; i < 8; i++)
  82.199 -			{
  82.200 -				eepromData[(eepromAddress << 3) + i] = eepromBuffer[i];
  82.201 -			}
  82.202 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  82.203 -		}
  82.204 -		else if (eepromBits == 0x41)
  82.205 -		{
  82.206 -			eepromMode = EEPROM_IDLE;
  82.207 -			eepromByte = 0;
  82.208 -			eepromBits = 0;
  82.209 -		}
  82.210 -		break;
  82.211 -	}
  82.212 -}
  82.213 -
    83.1 --- a/src/gba/EEprom.h	Sat Mar 03 10:54:39 2012 -0600
    83.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.3 @@ -1,27 +0,0 @@
    83.4 -#ifndef VBA_EEPROM_H
    83.5 -#define VBA_EEPROM_H
    83.6 -
    83.7 -#if _MSC_VER > 1000
    83.8 -#pragma once
    83.9 -#endif // _MSC_VER > 1000
   83.10 -
   83.11 -#include "zlib.h"
   83.12 -#include "../Port.h"
   83.13 -
   83.14 -extern void eepromSaveGame(gzFile gzFile);
   83.15 -extern void eepromReadGame(gzFile gzFile, int version);
   83.16 -extern int eepromRead(u32 address);
   83.17 -extern void eepromWrite(u32 address, u8 value);
   83.18 -extern void eepromReset();
   83.19 -extern void eepromErase();
   83.20 -extern u8    eepromData[0x2000];
   83.21 -extern bool8 eepromInUse;
   83.22 -extern int32 eepromSize;
   83.23 -
   83.24 -#define EEPROM_IDLE           0
   83.25 -#define EEPROM_READADDRESS    1
   83.26 -#define EEPROM_READDATA       2
   83.27 -#define EEPROM_READDATA2      3
   83.28 -#define EEPROM_WRITEDATA      4
   83.29 -
   83.30 -#endif // VBA_EEPROM_H
    84.1 --- a/src/gba/Flash.cpp	Sat Mar 03 10:54:39 2012 -0600
    84.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.3 @@ -1,285 +0,0 @@
    84.4 -#include <cstdio>
    84.5 -#include <cstring>
    84.6 -
    84.7 -#include "Flash.h"
    84.8 -#include "GBA.h"
    84.9 -#include "GBAGlobals.h"
   84.10 -#include "Sram.h"
   84.11 -#include "../common/System.h"
   84.12 -#include "../common/Util.h"
   84.13 -
   84.14 -#define FLASH_READ_ARRAY         0
   84.15 -#define FLASH_CMD_1              1
   84.16 -#define FLASH_CMD_2              2
   84.17 -#define FLASH_AUTOSELECT         3
   84.18 -#define FLASH_CMD_3              4
   84.19 -#define FLASH_CMD_4              5
   84.20 -#define FLASH_CMD_5              6
   84.21 -#define FLASH_ERASE_COMPLETE     7
   84.22 -#define FLASH_PROGRAM            8
   84.23 -#define FLASH_SETBANK            9
   84.24 -
   84.25 -u8    flashSaveMemory[0x20000 + 4];
   84.26 -int32 flashState          = FLASH_READ_ARRAY;
   84.27 -int32 flashReadState      = FLASH_READ_ARRAY;
   84.28 -int32 flashSize           = 0x10000;
   84.29 -int32 flashDeviceID       = 0x1b;
   84.30 -int32 flashManufacturerID = 0x32;
   84.31 -int32 flashBank           = 0;
   84.32 -
   84.33 -static variable_desc flashSaveData[] = {
   84.34 -	{ &flashState,         sizeof(int32) },
   84.35 -	{ &flashReadState,     sizeof(int32) },
   84.36 -	{ &flashSaveMemory[0],       0x10000 },
   84.37 -	{ NULL,                            0 }
   84.38 -};
   84.39 -
   84.40 -static variable_desc flashSaveData2[] = {
   84.41 -	{ &flashState,         sizeof(int32) },
   84.42 -	{ &flashReadState,     sizeof(int32) },
   84.43 -	{ &flashSize,          sizeof(int32) },
   84.44 -	{ &flashSaveMemory[0],       0x20000 },
   84.45 -	{ NULL,                            0 }
   84.46 -};
   84.47 -
   84.48 -static variable_desc flashSaveData3[] = {
   84.49 -	{ &flashState,         sizeof(int32) },
   84.50 -	{ &flashReadState,     sizeof(int32) },
   84.51 -	{ &flashSize,          sizeof(int32) },
   84.52 -	{ &flashBank,          sizeof(int32) },
   84.53 -	{ &flashSaveMemory[0],       0x20000 },
   84.54 -	{ NULL,                            0 }
   84.55 -};
   84.56 -
   84.57 -void flashReset()
   84.58 -{
   84.59 -	flashState     = FLASH_READ_ARRAY;
   84.60 -	flashReadState = FLASH_READ_ARRAY;
   84.61 -	flashBank      = 0;
   84.62 -}
   84.63 -
   84.64 -void flashErase()
   84.65 -{
   84.66 -	memset(flashSaveMemory, 0, 0x20000*sizeof(u8));
   84.67 -	flashState          = FLASH_READ_ARRAY;
   84.68 -	flashReadState      = FLASH_READ_ARRAY;
   84.69 -	flashSize           = 0x10000;
   84.70 -	flashDeviceID       = 0x1b;
   84.71 -	flashManufacturerID = 0x32;
   84.72 -	flashBank           = 0;
   84.73 -}
   84.74 -
   84.75 -void flashSaveGame(gzFile gzFile)
   84.76 -{
   84.77 -	utilWriteData(gzFile, flashSaveData3);
   84.78 -}
   84.79 -
   84.80 -void flashReadGame(gzFile gzFile, int version)
   84.81 -{
   84.82 -	if (version < SAVE_GAME_VERSION_5)
   84.83 -		utilReadData(gzFile, flashSaveData);
   84.84 -	else if (version < SAVE_GAME_VERSION_7)
   84.85 -	{
   84.86 -		utilReadData(gzFile, flashSaveData2);
   84.87 -		flashBank = 0;
   84.88 -		flashSetSize(flashSize);
   84.89 -	}
   84.90 -	else
   84.91 -	{
   84.92 -		utilReadData(gzFile, flashSaveData3);
   84.93 -	}
   84.94 -}
   84.95 -
   84.96 -void flashSetSize(int size)
   84.97 -{
   84.98 -	//  log("Setting flash size to %d\n", size);
   84.99 -	flashSize = size;
  84.100 -	if (size == 0x10000)
  84.101 -	{
  84.102 -		flashDeviceID       = 0x1b;
  84.103 -		flashManufacturerID = 0x32;
  84.104 -	}
  84.105 -	else
  84.106 -	{
  84.107 -		flashDeviceID       = 0x13; //0x09;
  84.108 -		flashManufacturerID = 0x62; //0xc2;
  84.109 -	}
  84.110 -}
  84.111 -
  84.112 -u8 flashRead(u32 address)
  84.113 -{
  84.114 -	//  log("Reading %08x from %08x\n", address, reg[15].I);
  84.115 -	//  log("Current read state is %d\n", flashReadState);
  84.116 -	address &= 0xFFFF;
  84.117 -
  84.118 -	switch (flashReadState)
  84.119 -	{
  84.120 -	case FLASH_READ_ARRAY:
  84.121 -		return flashSaveMemory[(flashBank << 16) + address];
  84.122 -	case FLASH_AUTOSELECT:
  84.123 -		switch (address & 0xFF)
  84.124 -		{
  84.125 -		case 0:
  84.126 -			// manufacturer ID
  84.127 -			return u8(flashManufacturerID);
  84.128 -		case 1:
  84.129 -			// device ID
  84.130 -			return u8(flashDeviceID);
  84.131 -		}
  84.132 -		break;
  84.133 -	case FLASH_ERASE_COMPLETE:
  84.134 -		flashState     = FLASH_READ_ARRAY;
  84.135 -		flashReadState = FLASH_READ_ARRAY;
  84.136 -		return 0xFF;
  84.137 -	}
  84.138 -	;
  84.139 -	return 0;
  84.140 -}
  84.141 -
  84.142 -void flashSaveDecide(u32 address, u8 byte)
  84.143 -{
  84.144 -	//  log("Deciding save type %08x\n", address);
  84.145 -	if (address == 0x0e005555)
  84.146 -	{
  84.147 -		saveType        = 2;
  84.148 -		cpuSaveGameFunc = flashWrite;
  84.149 -	}
  84.150 -	else
  84.151 -	{
  84.152 -		saveType        = 1;
  84.153 -		cpuSaveGameFunc = sramWrite;
  84.154 -	}
  84.155 -
  84.156 -	(*cpuSaveGameFunc)(address, byte);
  84.157 -}
  84.158 -
  84.159 -void flashWrite(u32 address, u8 byte)
  84.160 -{
  84.161 -	//  log("Writing %02x at %08x\n", byte, address);
  84.162 -	//  log("Current state is %d\n", flashState);
  84.163 -	address &= 0xFFFF;
  84.164 -	switch (flashState)
  84.165 -	{
  84.166 -	case FLASH_READ_ARRAY:
  84.167 -		if (address == 0x5555 && byte == 0xAA)
  84.168 -			flashState = FLASH_CMD_1;
  84.169 -		break;
  84.170 -	case FLASH_CMD_1:
  84.171 -		if (address == 0x2AAA && byte == 0x55)
  84.172 -			flashState = FLASH_CMD_2;
  84.173 -		else
  84.174 -			flashState = FLASH_READ_ARRAY;
  84.175 -		break;
  84.176 -	case FLASH_CMD_2:
  84.177 -		if (address == 0x5555)
  84.178 -		{
  84.179 -			if (byte == 0x90)
  84.180 -			{
  84.181 -				flashState     = FLASH_AUTOSELECT;
  84.182 -				flashReadState = FLASH_AUTOSELECT;
  84.183 -			}
  84.184 -			else if (byte == 0x80)
  84.185 -			{
  84.186 -				flashState = FLASH_CMD_3;
  84.187 -			}
  84.188 -			else if (byte == 0xF0)
  84.189 -			{
  84.190 -				flashState     = FLASH_READ_ARRAY;
  84.191 -				flashReadState = FLASH_READ_ARRAY;
  84.192 -			}
  84.193 -			else if (byte == 0xA0)
  84.194 -			{
  84.195 -				flashState = FLASH_PROGRAM;
  84.196 -			}
  84.197 -			else if (byte == 0xB0 && flashSize == 0x20000)
  84.198 -			{
  84.199 -				flashState = FLASH_SETBANK;
  84.200 -			}
  84.201 -			else
  84.202 -			{
  84.203 -				flashState     = FLASH_READ_ARRAY;
  84.204 -				flashReadState = FLASH_READ_ARRAY;
  84.205 -			}
  84.206 -		}
  84.207 -		else
  84.208 -		{
  84.209 -			flashState     = FLASH_READ_ARRAY;
  84.210 -			flashReadState = FLASH_READ_ARRAY;
  84.211 -		}
  84.212 -		break;
  84.213 -	case FLASH_CMD_3:
  84.214 -		if (address == 0x5555 && byte == 0xAA)
  84.215 -		{
  84.216 -			flashState = FLASH_CMD_4;
  84.217 -		}
  84.218 -		else
  84.219 -		{
  84.220 -			flashState     = FLASH_READ_ARRAY;
  84.221 -			flashReadState = FLASH_READ_ARRAY;
  84.222 -		}
  84.223 -		break;
  84.224 -	case FLASH_CMD_4:
  84.225 -		if (address == 0x2AAA && byte == 0x55)
  84.226 -		{
  84.227 -			flashState = FLASH_CMD_5;
  84.228 -		}
  84.229 -		else
  84.230 -		{
  84.231 -			flashState     = FLASH_READ_ARRAY;
  84.232 -			flashReadState = FLASH_READ_ARRAY;
  84.233 -		}
  84.234 -		break;
  84.235 -	case FLASH_CMD_5:
  84.236 -		if (byte == 0x30)
  84.237 -		{
  84.238 -			// SECTOR ERASE
  84.239 -			memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)],
  84.240 -			       0,
  84.241 -			       0x1000);
  84.242 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  84.243 -			flashReadState = FLASH_ERASE_COMPLETE;
  84.244 -		}
  84.245 -		else if (byte == 0x10)
  84.246 -		{
  84.247 -			// CHIP ERASE
  84.248 -			memset(flashSaveMemory, 0, flashSize);
  84.249 -			systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  84.250 -			flashReadState = FLASH_ERASE_COMPLETE;
  84.251 -		}
  84.252 -		else
  84.253 -		{
  84.254 -			flashState     = FLASH_READ_ARRAY;
  84.255 -			flashReadState = FLASH_READ_ARRAY;
  84.256 -		}
  84.257 -		break;
  84.258 -	case FLASH_AUTOSELECT:
  84.259 -		if (byte == 0xF0)
  84.260 -		{
  84.261 -			flashState     = FLASH_READ_ARRAY;
  84.262 -			flashReadState = FLASH_READ_ARRAY;
  84.263 -		}
  84.264 -		else if (address == 0x5555 && byte == 0xAA)
  84.265 -			flashState = FLASH_CMD_1;
  84.266 -		else
  84.267 -		{
  84.268 -			flashState     = FLASH_READ_ARRAY;
  84.269 -			flashReadState = FLASH_READ_ARRAY;
  84.270 -		}
  84.271 -		break;
  84.272 -	case FLASH_PROGRAM:
  84.273 -		flashSaveMemory[(flashBank<<16)+address] = byte;
  84.274 -		systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  84.275 -		flashState     = FLASH_READ_ARRAY;
  84.276 -		flashReadState = FLASH_READ_ARRAY;
  84.277 -		break;
  84.278 -	case FLASH_SETBANK:
  84.279 -		if (address == 0)
  84.280 -		{
  84.281 -			flashBank = (byte & 1);
  84.282 -		}
  84.283 -		flashState     = FLASH_READ_ARRAY;
  84.284 -		flashReadState = FLASH_READ_ARRAY;
  84.285 -		break;
  84.286 -	}
  84.287 -}
  84.288 -
    85.1 --- a/src/gba/Flash.h	Sat Mar 03 10:54:39 2012 -0600
    85.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.3 @@ -1,23 +0,0 @@
    85.4 -#ifndef VBA_FLASH_H
    85.5 -#define VBA_FLASH_H
    85.6 -
    85.7 -#if _MSC_VER > 1000
    85.8 -#pragma once
    85.9 -#endif // _MSC_VER > 1000
   85.10 -
   85.11 -#include "zlib.h"
   85.12 -#include "../Port.h"
   85.13 -
   85.14 -extern void flashSaveGame(gzFile gzFile);
   85.15 -extern void flashReadGame(gzFile gzFile, int version);
   85.16 -extern u8 flashRead(u32 address);
   85.17 -extern void flashWrite(u32 address, u8 byte);
   85.18 -extern u8 flashSaveMemory[0x20000 + 4];
   85.19 -extern void flashSaveDecide(u32 address, u8 byte);
   85.20 -extern void flashReset();
   85.21 -extern void flashErase();
   85.22 -extern void flashSetSize(int size);
   85.23 -
   85.24 -extern int32 flashSize;
   85.25 -
   85.26 -#endif // VBA_FLASH_H
    86.1 --- a/src/gba/GBA.cpp	Sat Mar 03 10:54:39 2012 -0600
    86.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.3 @@ -1,4567 +0,0 @@
    86.4 -#include <cstdio>
    86.5 -#include <cstdlib>
    86.6 -#include <cstdarg>
    86.7 -#include <cstring>
    86.8 -
    86.9 -#include "../Port.h"
   86.10 -#include "../NLS.h"
   86.11 -#include "GBA.h"
   86.12 -//#include "GBAGlobals.h"
   86.13 -#include "GBACheats.h" // FIXME: SDL requires this included before "GBAinline.h"
   86.14 -#include "GBAinline.h"
   86.15 -#include "GBAGfx.h"
   86.16 -#include "GBASound.h"
   86.17 -#include "EEprom.h"
   86.18 -#include "Flash.h"
   86.19 -#include "Sram.h"
   86.20 -#include "bios.h"
   86.21 -#include "elf.h"
   86.22 -#include "agbprint.h"
   86.23 -#include "../common/unzip.h"
   86.24 -#include "../common/Util.h"
   86.25 -#include "../common/movie.h"
   86.26 -#include "../common/vbalua.h"
   86.27 -
   86.28 -#ifdef PROFILING
   86.29 -#include "../prof/prof.h"
   86.30 -#endif
   86.31 -
   86.32 -#define UPDATE_REG(address, value) WRITE16LE(((u16 *)&ioMem[address]), value)
   86.33 -
   86.34 -#ifdef __GNUC__
   86.35 -#define _stricmp strcasecmp
   86.36 -#endif
   86.37 -
   86.38 -#define CPU_BREAK_LOOP \
   86.39 -    cpuSavedTicks	 = cpuSavedTicks - *extCpuLoopTicks; \
   86.40 -    *extCpuLoopTicks = *extClockTicks;
   86.41 -
   86.42 -#define CPU_BREAK_LOOP_2 \
   86.43 -    cpuSavedTicks	 = cpuSavedTicks - *extCpuLoopTicks; \
   86.44 -    *extCpuLoopTicks = *extClockTicks; \
   86.45 -    *extTicks		 = *extClockTicks;
   86.46 -
   86.47 -int32 cpuDmaTicksToUpdate = 0;
   86.48 -int32 cpuDmaCount		  = 0;
   86.49 -bool8 cpuDmaHack		  = 0;
   86.50 -u32	  cpuDmaLast		  = 0;
   86.51 -int32 dummyAddress		  = 0;
   86.52 -
   86.53 -int32 *extCpuLoopTicks = NULL;
   86.54 -int32 *extClockTicks   = NULL;
   86.55 -int32 *extTicks		   = NULL;
   86.56 -
   86.57 -#if (defined(WIN32) && !defined(SDL))
   86.58 -HANDLE mapROM;        // shared memory handles
   86.59 -HANDLE mapWORKRAM;
   86.60 -HANDLE mapBIOS;
   86.61 -HANDLE mapIRAM;
   86.62 -HANDLE mapPALETTERAM;
   86.63 -HANDLE mapVRAM;
   86.64 -HANDLE mapOAM;
   86.65 -HANDLE mapPIX;
   86.66 -HANDLE mapIOMEM;
   86.67 -#endif
   86.68 -
   86.69 -int32 gbaSaveType = 0;      // used to remember the save type on reset
   86.70 -bool8 intState	  = false;
   86.71 -bool8 stopState	  = false;
   86.72 -bool8 holdState	  = false;
   86.73 -int32 holdType	  = 0;
   86.74 -bool8 cpuSramEnabled		 = true;
   86.75 -bool8 cpuFlashEnabled		 = true;
   86.76 -bool8 cpuEEPROMEnabled		 = true;
   86.77 -bool8 cpuEEPROMSensorEnabled = false;
   86.78 -
   86.79 -#ifdef PROFILING
   86.80 -int profilingTicks		  = 0;
   86.81 -int profilingTicksReload  = 0;
   86.82 -static char *profilBuffer = NULL;
   86.83 -static int	 profilSize	  = 0;
   86.84 -static u32	 profilLowPC  = 0;
   86.85 -static int	 profilScale  = 0;
   86.86 -#endif
   86.87 -bool8 freezeWorkRAM[0x40000];
   86.88 -bool8 freezeInternalRAM[0x8000];
   86.89 -int32 lcdTicks = 960;
   86.90 -bool8 timer0On = false;
   86.91 -int32 timer0Ticks		= 0;
   86.92 -int32 timer0Reload		= 0;
   86.93 -int32 timer0ClockReload = 0;
   86.94 -bool8 timer1On			= false;
   86.95 -int32 timer1Ticks		= 0;
   86.96 -int32 timer1Reload		= 0;
   86.97 -int32 timer1ClockReload = 0;
   86.98 -bool8 timer2On			= false;
   86.99 -int32 timer2Ticks		= 0;
  86.100 -int32 timer2Reload		= 0;
  86.101 -int32 timer2ClockReload = 0;
  86.102 -bool8 timer3On			= false;
  86.103 -int32 timer3Ticks		= 0;
  86.104 -int32 timer3Reload		= 0;
  86.105 -int32 timer3ClockReload = 0;
  86.106 -u32	  dma0Source		= 0;
  86.107 -u32	  dma0Dest			= 0;
  86.108 -u32	  dma1Source		= 0;
  86.109 -u32	  dma1Dest			= 0;
  86.110 -u32	  dma2Source		= 0;
  86.111 -u32	  dma2Dest			= 0;
  86.112 -u32	  dma3Source		= 0;
  86.113 -u32	  dma3Dest			= 0;
  86.114 -void  (*cpuSaveGameFunc)(u32, u8) = flashSaveDecide;
  86.115 -void  (*renderLine)() = mode0RenderLine;
  86.116 -bool8 fxOn = false;
  86.117 -bool8 windowOn		 = false;
  86.118 -int32 frameSkipCount = 0;
  86.119 -u32	  gbaLastTime	 = 0;
  86.120 -int32 gbaFrameCount	 = 0;
  86.121 -bool8 prefetchActive = false, prefetchPrevActive = false, prefetchApplies = false;
  86.122 -char  buffer[1024];
  86.123 -FILE *out = NULL;
  86.124 -
  86.125 -static bool newFrame = true;
  86.126 -static bool pauseAfterFrameAdvance = false;
  86.127 -
  86.128 -const int32 TIMER_TICKS[4] = {
  86.129 -	1,
  86.130 -	64,
  86.131 -	256,
  86.132 -	1024
  86.133 -};
  86.134 -
  86.135 -const int32 thumbCycles[] = {
  86.136 -//  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  86.137 -	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 0
  86.138 -	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 1
  86.139 -	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 2
  86.140 -	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 3
  86.141 -	1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,  // 4
  86.142 -	2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  // 5
  86.143 -	2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,  // 6
  86.144 -	2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,  // 7
  86.145 -	2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,  // 8
  86.146 -	2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,  // 9
  86.147 -	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  // a
  86.148 -	1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1,  // b
  86.149 -	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  // c
  86.150 -	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,  // d
  86.151 -	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  // e
  86.152 -	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2   // f
  86.153 -};
  86.154 -
  86.155 -const int32 gamepakRamWaitState[4] = { 4, 3, 2, 8 };
  86.156 -const int32 gamepakWaitState[8] =  { 4, 3, 2, 8, 4, 3, 2, 8 };
  86.157 -const int32 gamepakWaitState0[8] = { 2, 2, 2, 2, 1, 1, 1, 1 };
  86.158 -const int32 gamepakWaitState1[8] = { 4, 4, 4, 4, 1, 1, 1, 1 };
  86.159 -const int32 gamepakWaitState2[8] = { 8, 8, 8, 8, 1, 1, 1, 1 };
  86.160 -
  86.161 -int32 memoryWait[16] =
  86.162 -{ 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 };
  86.163 -int32 memoryWait32[16] =
  86.164 -{ 0, 0, 9, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 0 };
  86.165 -int32 memoryWaitSeq[16] =
  86.166 -{ 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 4, 4, 8, 8, 4, 0 };
  86.167 -int32 memoryWaitSeq32[16] =
  86.168 -{ 2, 0, 3, 0, 0, 2, 2, 0, 4, 4, 8, 8, 16, 16, 8, 0 };
  86.169 -int32 memoryWaitFetch[16] =
  86.170 -{ 3, 0, 3, 0, 0, 1, 1, 0, 4, 4, 4, 4, 4, 4, 4, 0 };
  86.171 -int32 memoryWaitFetch32[16] =
  86.172 -{ 6, 0, 6, 0, 0, 2, 2, 0, 8, 8, 8, 8, 8, 8, 8, 0 };
  86.173 -
  86.174 -const int32 cpuMemoryWait[16] = {
  86.175 -	0, 0, 2, 0, 0, 0, 0, 0,
  86.176 -	2, 2, 2, 2, 2, 2, 0, 0
  86.177 -};
  86.178 -const int32 cpuMemoryWait32[16] = {
  86.179 -	0, 0, 3, 0, 0, 0, 0, 0,
  86.180 -	3, 3, 3, 3, 3, 3, 0, 0
  86.181 -};
  86.182 -
  86.183 -const bool8 memory32[16] = {
  86.184 -	true, false, false, true, true, false, false, true, false, false, false, false, false, false, true, false
  86.185 -};
  86.186 -
  86.187 -u8 biosProtected[4];
  86.188 -
  86.189 -u8 cpuBitsSet[256];
  86.190 -u8 cpuLowestBitSet[256];
  86.191 -
  86.192 -#ifdef WORDS_BIGENDIAN
  86.193 -bool8 cpuBiosSwapped = false;
  86.194 -#endif
  86.195 -
  86.196 -u32 myROM[] = {
  86.197 -	0xEA000006,
  86.198 -	0xEA000093,
  86.199 -	0xEA000006,
  86.200 -	0x00000000,
  86.201 -	0x00000000,
  86.202 -	0x00000000,
  86.203 -	0xEA000088,
  86.204 -	0x00000000,
  86.205 -	0xE3A00302,
  86.206 -	0xE1A0F000,
  86.207 -	0xE92D5800,
  86.208 -	0xE55EC002,
  86.209 -	0xE28FB03C,
  86.210 -	0xE79BC10C,
  86.211 -	0xE14FB000,
  86.212 -	0xE92D0800,
  86.213 -	0xE20BB080,
  86.214 -	0xE38BB01F,
  86.215 -	0xE129F00B,
  86.216 -	0xE92D4004,
  86.217 -	0xE1A0E00F,
  86.218 -	0xE12FFF1C,
  86.219 -	0xE8BD4004,
  86.220 -	0xE3A0C0D3,
  86.221 -	0xE129F00C,
  86.222 -	0xE8BD0800,
  86.223 -	0xE169F00B,
  86.224 -	0xE8BD5800,
  86.225 -	0xE1B0F00E,
  86.226 -	0x0000009C,
  86.227 -	0x0000009C,
  86.228 -	0x0000009C,
  86.229 -	0x0000009C,
  86.230 -	0x000001F8,
  86.231 -	0x000001F0,
  86.232 -	0x000000AC,
  86.233 -	0x000000A0,
  86.234 -	0x000000FC,
  86.235 -	0x00000168,
  86.236 -	0xE12FFF1E,
  86.237 -	0xE1A03000,
  86.238 -	0xE1A00001,
  86.239 -	0xE1A01003,
  86.240 -	0xE2113102,
  86.241 -	0x42611000,
  86.242 -	0xE033C040,
  86.243 -	0x22600000,
  86.244 -	0xE1B02001,
  86.245 -	0xE15200A0,
  86.246 -	0x91A02082,
  86.247 -	0x3AFFFFFC,
  86.248 -	0xE1500002,
  86.249 -	0xE0A33003,
  86.250 -	0x20400002,
  86.251 -	0xE1320001,
  86.252 -	0x11A020A2,
  86.253 -	0x1AFFFFF9,
  86.254 -	0xE1A01000,
  86.255 -	0xE1A00003,
  86.256 -	0xE1B0C08C,
  86.257 -	0x22600000,
  86.258 -	0x42611000,
  86.259 -	0xE12FFF1E,
  86.260 -	0xE92D0010,
  86.261 -	0xE1A0C000,
  86.262 -	0xE3A01001,
  86.263 -	0xE1500001,
  86.264 -	0x81A000A0,
  86.265 -	0x81A01081,
  86.266 -	0x8AFFFFFB,
  86.267 -	0xE1A0000C,
  86.268 -	0xE1A04001,
  86.269 -	0xE3A03000,
  86.270 -	0xE1A02001,
  86.271 -	0xE15200A0,
  86.272 -	0x91A02082,
  86.273 -	0x3AFFFFFC,
  86.274 -	0xE1500002,
  86.275 -	0xE0A33003,
  86.276 -	0x20400002,
  86.277 -	0xE1320001,
  86.278 -	0x11A020A2,
  86.279 -	0x1AFFFFF9,
  86.280 -	0xE0811003,
  86.281 -	0xE1B010A1,
  86.282 -	0xE1510004,
  86.283 -	0x3AFFFFEE,
  86.284 -	0xE1A00004,
  86.285 -	0xE8BD0010,
  86.286 -	0xE12FFF1E,
  86.287 -	0xE0010090,
  86.288 -	0xE1A01741,
  86.289 -	0xE2611000,
  86.290 -	0xE3A030A9,
  86.291 -	0xE0030391,
  86.292 -	0xE1A03743,
  86.293 -	0xE2833E39,
  86.294 -	0xE0030391,
  86.295 -	0xE1A03743,
  86.296 -	0xE2833C09,
  86.297 -	0xE283301C,
  86.298 -	0xE0030391,
  86.299 -	0xE1A03743,
  86.300 -	0xE2833C0F,
  86.301 -	0xE28330B6,
  86.302 -	0xE0030391,
  86.303 -	0xE1A03743,
  86.304 -	0xE2833C16,
  86.305 -	0xE28330AA,
  86.306 -	0xE0030391,
  86.307 -	0xE1A03743,
  86.308 -	0xE2833A02,
  86.309 -	0xE2833081,
  86.310 -	0xE0030391,
  86.311 -	0xE1A03743,
  86.312 -	0xE2833C36,
  86.313 -	0xE2833051,
  86.314 -	0xE0030391,
  86.315 -	0xE1A03743,
  86.316 -	0xE2833CA2,
  86.317 -	0xE28330F9,
  86.318 -	0xE0000093,
  86.319 -	0xE1A00840,
  86.320 -	0xE12FFF1E,
  86.321 -	0xE3A00001,
  86.322 -	0xE3A01001,
  86.323 -	0xE92D4010,
  86.324 -	0xE3A0C301,
  86.325 -	0xE3A03000,
  86.326 -	0xE3A04001,
  86.327 -	0xE3500000,
  86.328 -	0x1B000004,
  86.329 -	0xE5CC3301,
  86.330 -	0xEB000002,
  86.331 -	0x0AFFFFFC,
  86.332 -	0xE8BD4010,
  86.333 -	0xE12FFF1E,
  86.334 -	0xE5CC3208,
  86.335 -	0xE15C20B8,
  86.336 -	0xE0110002,
  86.337 -	0x10200002,
  86.338 -	0x114C00B8,
  86.339 -	0xE5CC4208,
  86.340 -	0xE12FFF1E,
  86.341 -	0xE92D500F,
  86.342 -	0xE3A00301,
  86.343 -	0xE1A0E00F,
  86.344 -	0xE510F004,
  86.345 -	0xE8BD500F,
  86.346 -	0xE25EF004,
  86.347 -	0xE59FD044,
  86.348 -	0xE92D5000,
  86.349 -	0xE14FC000,
  86.350 -	0xE10FE000,
  86.351 -	0xE92D5000,
  86.352 -	0xE3A0C302,
  86.353 -	0xE5DCE09C,
  86.354 -	0xE35E00A5,
  86.355 -	0x1A000004,
  86.356 -	0x05DCE0B4,
  86.357 -	0x021EE080,
  86.358 -	0xE28FE004,
  86.359 -	0x159FF018,
  86.360 -	0x059FF018,
  86.361 -	0xE59FD018,
  86.362 -	0xE8BD5000,
  86.363 -	0xE169F00C,
  86.364 -	0xE8BD5000,
  86.365 -	0xE25EF004,
  86.366 -	0x03007FF0,
  86.367 -	0x09FE2000,
  86.368 -	0x09FFC000,
  86.369 -	0x03007FE0
  86.370 -};
  86.371 -
  86.372 -variable_desc saveGameStruct[] = {
  86.373 -	{ &DISPCNT,			  sizeof(u16)				 },
  86.374 -	{ &DISPSTAT,		  sizeof(u16)				 },
  86.375 -	{ &VCOUNT,			  sizeof(u16)				 },
  86.376 -	{ &BG0CNT,			  sizeof(u16)				 },
  86.377 -	{ &BG1CNT,			  sizeof(u16)				 },
  86.378 -	{ &BG2CNT,			  sizeof(u16)				 },
  86.379 -	{ &BG3CNT,			  sizeof(u16)				 },
  86.380 -	{ &BG0HOFS,			  sizeof(u16)				 },
  86.381 -	{ &BG0VOFS,			  sizeof(u16)				 },
  86.382 -	{ &BG1HOFS,			  sizeof(u16)				 },
  86.383 -	{ &BG1VOFS,			  sizeof(u16)				 },
  86.384 -	{ &BG2HOFS,			  sizeof(u16)				 },
  86.385 -	{ &BG2VOFS,			  sizeof(u16)				 },
  86.386 -	{ &BG3HOFS,			  sizeof(u16)				 },
  86.387 -	{ &BG3VOFS,			  sizeof(u16)				 },
  86.388 -	{ &BG2PA,			  sizeof(u16)				 },
  86.389 -	{ &BG2PB,			  sizeof(u16)				 },
  86.390 -	{ &BG2PC,			  sizeof(u16)				 },
  86.391 -	{ &BG2PD,			  sizeof(u16)				 },
  86.392 -	{ &BG2X_L,			  sizeof(u16)				 },
  86.393 -	{ &BG2X_H,			  sizeof(u16)				 },
  86.394 -	{ &BG2Y_L,			  sizeof(u16)				 },
  86.395 -	{ &BG2Y_H,			  sizeof(u16)				 },
  86.396 -	{ &BG3PA,			  sizeof(u16)				 },
  86.397 -	{ &BG3PB,			  sizeof(u16)				 },
  86.398 -	{ &BG3PC,			  sizeof(u16)				 },
  86.399 -	{ &BG3PD,			  sizeof(u16)				 },
  86.400 -	{ &BG3X_L,			  sizeof(u16)				 },
  86.401 -	{ &BG3X_H,			  sizeof(u16)				 },
  86.402 -	{ &BG3Y_L,			  sizeof(u16)				 },
  86.403 -	{ &BG3Y_H,			  sizeof(u16)				 },
  86.404 -	{ &WIN0H,			  sizeof(u16)				 },
  86.405 -	{ &WIN1H,			  sizeof(u16)				 },
  86.406 -	{ &WIN0V,			  sizeof(u16)				 },
  86.407 -	{ &WIN1V,			  sizeof(u16)				 },
  86.408 -	{ &WININ,			  sizeof(u16)				 },
  86.409 -	{ &WINOUT,			  sizeof(u16)				 },
  86.410 -	{ &MOSAIC,			  sizeof(u16)				 },
  86.411 -	{ &BLDMOD,			  sizeof(u16)				 },
  86.412 -	{ &COLEV,			  sizeof(u16)				 },
  86.413 -	{ &COLY,			  sizeof(u16)				 },
  86.414 -	{ &DM0SAD_L,		  sizeof(u16)				 },
  86.415 -	{ &DM0SAD_H,		  sizeof(u16)				 },
  86.416 -	{ &DM0DAD_L,		  sizeof(u16)				 },
  86.417 -	{ &DM0DAD_H,		  sizeof(u16)				 },
  86.418 -	{ &DM0CNT_L,		  sizeof(u16)				 },
  86.419 -	{ &DM0CNT_H,		  sizeof(u16)				 },
  86.420 -	{ &DM1SAD_L,		  sizeof(u16)				 },
  86.421 -	{ &DM1SAD_H,		  sizeof(u16)				 },
  86.422 -	{ &DM1DAD_L,		  sizeof(u16)				 },
  86.423 -	{ &DM1DAD_H,		  sizeof(u16)				 },
  86.424 -	{ &DM1CNT_L,		  sizeof(u16)				 },
  86.425 -	{ &DM1CNT_H,		  sizeof(u16)				 },
  86.426 -	{ &DM2SAD_L,		  sizeof(u16)				 },
  86.427 -	{ &DM2SAD_H,		  sizeof(u16)				 },
  86.428 -	{ &DM2DAD_L,		  sizeof(u16)				 },
  86.429 -	{ &DM2DAD_H,		  sizeof(u16)				 },
  86.430 -	{ &DM2CNT_L,		  sizeof(u16)				 },
  86.431 -	{ &DM2CNT_H,		  sizeof(u16)				 },
  86.432 -	{ &DM3SAD_L,		  sizeof(u16)				 },
  86.433 -	{ &DM3SAD_H,		  sizeof(u16)				 },
  86.434 -	{ &DM3DAD_L,		  sizeof(u16)				 },
  86.435 -	{ &DM3DAD_H,		  sizeof(u16)				 },
  86.436 -	{ &DM3CNT_L,		  sizeof(u16)				 },
  86.437 -	{ &DM3CNT_H,		  sizeof(u16)				 },
  86.438 -	{ &TM0D,			  sizeof(u16)				 },
  86.439 -	{ &TM0CNT,			  sizeof(u16)				 },
  86.440 -	{ &TM1D,			  sizeof(u16)				 },
  86.441 -	{ &TM1CNT,			  sizeof(u16)				 },
  86.442 -	{ &TM2D,			  sizeof(u16)				 },
  86.443 -	{ &TM2CNT,			  sizeof(u16)				 },
  86.444 -	{ &TM3D,			  sizeof(u16)				 },
  86.445 -	{ &TM3CNT,			  sizeof(u16)				 },
  86.446 -	{ &P1,				  sizeof(u16)				 },
  86.447 -	{ &IE,				  sizeof(u16)				 },
  86.448 -	{ &IF,				  sizeof(u16)				 },
  86.449 -	{ &IME,				  sizeof(u16)				 },
  86.450 -	{ &holdState,		  sizeof(bool8)				 },
  86.451 -	{ &holdType,		  sizeof(int32)				 },
  86.452 -	{ &lcdTicks,		  sizeof(int32)				 },
  86.453 -	{ &timer0On,		  sizeof(bool8)				 },
  86.454 -	{ &timer0Ticks,		  sizeof(int32)				 },
  86.455 -	{ &timer0Reload,	  sizeof(int32)				 },
  86.456 -	{ &timer0ClockReload, sizeof(int32)				 },
  86.457 -	{ &timer1On,		  sizeof(bool8)				 },
  86.458 -	{ &timer1Ticks,		  sizeof(int32)				 },
  86.459 -	{ &timer1Reload,	  sizeof(int32)				 },
  86.460 -	{ &timer1ClockReload, sizeof(int32)				 },
  86.461 -	{ &timer2On,		  sizeof(bool8)				 },
  86.462 -	{ &timer2Ticks,		  sizeof(int32)				 },
  86.463 -	{ &timer2Reload,	  sizeof(int32)				 },
  86.464 -	{ &timer2ClockReload, sizeof(int32)				 },
  86.465 -	{ &timer3On,		  sizeof(bool8)				 },
  86.466 -	{ &timer3Ticks,		  sizeof(int32)				 },
  86.467 -	{ &timer3Reload,	  sizeof(int32)				 },
  86.468 -	{ &timer3ClockReload, sizeof(int32)				 },
  86.469 -	{ &dma0Source,		  sizeof(u32)				 },
  86.470 -	{ &dma0Dest,		  sizeof(u32)				 },
  86.471 -	{ &dma1Source,		  sizeof(u32)				 },
  86.472 -	{ &dma1Dest,		  sizeof(u32)				 },
  86.473 -	{ &dma2Source,		  sizeof(u32)				 },
  86.474 -	{ &dma2Dest,		  sizeof(u32)				 },
  86.475 -	{ &dma3Source,		  sizeof(u32)				 },
  86.476 -	{ &dma3Dest,		  sizeof(u32)				 },
  86.477 -	{ &fxOn,			  sizeof(bool8)				 },
  86.478 -	{ &windowOn,		  sizeof(bool8)				 },
  86.479 -	{ &N_FLAG,			  sizeof(bool8)				 },
  86.480 -	{ &C_FLAG,			  sizeof(bool8)				 },
  86.481 -	{ &Z_FLAG,			  sizeof(bool8)				 },
  86.482 -	{ &V_FLAG,			  sizeof(bool8)				 },
  86.483 -	{ &armState,		  sizeof(bool8)				 },
  86.484 -	{ &armIrqEnable,	  sizeof(bool8)				 },
  86.485 -	{ &armNextPC,		  sizeof(u32)				 },
  86.486 -	{ &armMode,			  sizeof(int32)				 },
  86.487 -	{ &saveType,		  sizeof(int32)				 },
  86.488 -	{ NULL,				  0							 }
  86.489 -};
  86.490 -
  86.491 -//int cpuLoopTicks = 0;
  86.492 -int cpuSavedTicks = 0;
  86.493 -
  86.494 -#ifdef PROFILING
  86.495 -void cpuProfil(char *buf, int size, u32 lowPC, int scale)
  86.496 -{
  86.497 -	profilBuffer = buf;
  86.498 -	profilSize	 = size;
  86.499 -	profilLowPC	 = lowPC;
  86.500 -	profilScale	 = scale;
  86.501 -}
  86.502 -
  86.503 -void cpuEnableProfiling(int hz)
  86.504 -{
  86.505 -	if (hz == 0)
  86.506 -		hz = 100;
  86.507 -	profilingTicks = profilingTicksReload = 16777216 / hz;
  86.508 -	profSetHertz(hz);
  86.509 -}
  86.510 -
  86.511 -#endif
  86.512 -
  86.513 -inline int CPUUpdateTicksAccess32(u32 address)
  86.514 -{
  86.515 -	return memoryWait32[(address >> 24) & 15];
  86.516 -}
  86.517 -
  86.518 -inline int CPUUpdateTicksAccess16(u32 address)
  86.519 -{
  86.520 -	return memoryWait[(address >> 24) & 15];
  86.521 -}
  86.522 -
  86.523 -inline int CPUUpdateTicksAccessSeq32(u32 address)
  86.524 -{
  86.525 -	return memoryWaitSeq32[(address >> 24) & 15];
  86.526 -}
  86.527 -
  86.528 -inline int CPUUpdateTicksAccessSeq16(u32 address)
  86.529 -{
  86.530 -	return memoryWaitSeq[(address >> 24) & 15];
  86.531 -}
  86.532 -
  86.533 -inline int CPUUpdateTicks()
  86.534 -{
  86.535 -	int cpuLoopTicks = lcdTicks;
  86.536 -
  86.537 -	if (soundTicks < cpuLoopTicks)
  86.538 -		cpuLoopTicks = soundTicks;
  86.539 -
  86.540 -	if (timer0On && !(TM0CNT & 4) && (timer0Ticks < cpuLoopTicks))
  86.541 -	{
  86.542 -		cpuLoopTicks = timer0Ticks;
  86.543 -	}
  86.544 -	if (timer1On && !(TM1CNT & 4) && (timer1Ticks < cpuLoopTicks))
  86.545 -	{
  86.546 -		cpuLoopTicks = timer1Ticks;
  86.547 -	}
  86.548 -	if (timer2On && !(TM2CNT & 4) && (timer2Ticks < cpuLoopTicks))
  86.549 -	{
  86.550 -		cpuLoopTicks = timer2Ticks;
  86.551 -	}
  86.552 -	if (timer3On && !(TM3CNT & 4) && (timer3Ticks < cpuLoopTicks))
  86.553 -	{
  86.554 -		cpuLoopTicks = timer3Ticks;
  86.555 -	}
  86.556 -#ifdef PROFILING
  86.557 -	if (profilingTicksReload != 0)
  86.558 -	{
  86.559 -		if (profilingTicks < cpuLoopTicks)
  86.560 -		{
  86.561 -			cpuLoopTicks = profilingTicks;
  86.562 -		}
  86.563 -	}
  86.564 -#endif
  86.565 -	cpuSavedTicks = cpuLoopTicks;
  86.566 -	return cpuLoopTicks;
  86.567 -}
  86.568 -
  86.569 -void CPUUpdateWindow0()
  86.570 -{
  86.571 -	int x00 = WIN0H >> 8;
  86.572 -	int x01 = WIN0H & 255;
  86.573 -
  86.574 -	if (x00 <= x01)
  86.575 -	{
  86.576 -		for (int i = 0; i < 240; i++)
  86.577 -		{
  86.578 -			gfxInWin0[i] = (i >= x00 && i < x01);
  86.579 -		}
  86.580 -	}
  86.581 -	else
  86.582 -	{
  86.583 -		for (int i = 0; i < 240; i++)
  86.584 -		{
  86.585 -			gfxInWin0[i] = (i >= x00 || i < x01);
  86.586 -		}
  86.587 -	}
  86.588 -}
  86.589 -
  86.590 -void CPUUpdateWindow1()
  86.591 -{
  86.592 -	int x00 = WIN1H >> 8;
  86.593 -	int x01 = WIN1H & 255;
  86.594 -
  86.595 -	if (x00 <= x01)
  86.596 -	{
  86.597 -		for (int i = 0; i < 240; i++)
  86.598 -		{
  86.599 -			gfxInWin1[i] = (i >= x00 && i < x01);
  86.600 -		}
  86.601 -	}
  86.602 -	else
  86.603 -	{
  86.604 -		for (int i = 0; i < 240; i++)
  86.605 -		{
  86.606 -			gfxInWin1[i] = (i >= x00 || i < x01);
  86.607 -		}
  86.608 -	}
  86.609 -}
  86.610 -
  86.611 -#define CLEAR_ARRAY(a) \
  86.612 -	{ \
  86.613 -		u32 *array = (a); \
  86.614 -		for (int i = 0; i < 240; i++) { \
  86.615 -			*array++ = 0x80000000; \
  86.616 -		} \
  86.617 -	} \
  86.618 -
  86.619 -void CPUUpdateRenderBuffers(bool force)
  86.620 -{
  86.621 -	if (!(layerEnable & 0x0100) || force)
  86.622 -	{
  86.623 -		CLEAR_ARRAY(line0);
  86.624 -	}
  86.625 -	if (!(layerEnable & 0x0200) || force)
  86.626 -	{
  86.627 -		CLEAR_ARRAY(line1);
  86.628 -	}
  86.629 -	if (!(layerEnable & 0x0400) || force)
  86.630 -	{
  86.631 -		CLEAR_ARRAY(line2);
  86.632 -	}
  86.633 -	if (!(layerEnable & 0x0800) || force)
  86.634 -	{
  86.635 -		CLEAR_ARRAY(line3);
  86.636 -	}
  86.637 -}
  86.638 -
  86.639 -bool CPUWriteStateToStream(gzFile gzFile)
  86.640 -{
  86.641 -	utilWriteInt(gzFile, SAVE_GAME_VERSION);
  86.642 -
  86.643 -	utilGzWrite(gzFile, &rom[0xa0], 16);
  86.644 -
  86.645 -	utilWriteInt(gzFile, useBios);
  86.646 -
  86.647 -	utilGzWrite(gzFile, &reg[0], sizeof(reg));
  86.648 -
  86.649 -	utilWriteData(gzFile, saveGameStruct);
  86.650 -
  86.651 -	// new to version 0.7.1
  86.652 -	utilWriteInt(gzFile, stopState);
  86.653 -	// new to version 0.8
  86.654 -	utilWriteInt(gzFile, intState);
  86.655 -
  86.656 -	utilGzWrite(gzFile, internalRAM, 0x8000);
  86.657 -	utilGzWrite(gzFile, paletteRAM, 0x400);
  86.658 -	utilGzWrite(gzFile, workRAM, 0x40000);
  86.659 -	utilGzWrite(gzFile, vram, 0x20000);
  86.660 -	utilGzWrite(gzFile, oam, 0x400);
  86.661 -	utilGzWrite(gzFile, pix, 4 * 241 * 162);
  86.662 -	utilGzWrite(gzFile, ioMem, 0x400);
  86.663 -
  86.664 -	eepromSaveGame(gzFile);
  86.665 -	flashSaveGame(gzFile);
  86.666 -	soundSaveGame(gzFile);
  86.667 -
  86.668 -	cheatsSaveGame(gzFile);
  86.669 -
  86.670 -	// version 1.5
  86.671 -	rtcSaveGame(gzFile);
  86.672 -
  86.673 -	// SAVE_GAME_VERSION_9 (new to re-recording version which is based on 1.72)
  86.674 -	{
  86.675 -		extern int32 sensorX, sensorY; // from SDL.cpp
  86.676 -		utilGzWrite(gzFile, &sensorX, sizeof(sensorX));
  86.677 -		utilGzWrite(gzFile, &sensorY, sizeof(sensorY));
  86.678 -		bool8 movieActive = VBAMovieActive();
  86.679 -		utilGzWrite(gzFile, &movieActive, sizeof(movieActive));
  86.680 -		if (movieActive)
  86.681 -		{
  86.682 -			uint8 *movie_freeze_buf	 = NULL;
  86.683 -			uint32 movie_freeze_size = 0;
  86.684 -
  86.685 -			VBAMovieFreeze(&movie_freeze_buf, &movie_freeze_size);
  86.686 -			if (movie_freeze_buf)
  86.687 -			{
  86.688 -				utilGzWrite(gzFile, &movie_freeze_size, sizeof(movie_freeze_size));
  86.689 -				utilGzWrite(gzFile, movie_freeze_buf, movie_freeze_size);
  86.690 -				delete [] movie_freeze_buf;
  86.691 -			}
  86.692 -			else
  86.693 -			{
  86.694 -				systemMessage(0, N_("Failed to save movie snapshot."));
  86.695 -				return false;
  86.696 -			}
  86.697 -		}
  86.698 -		utilGzWrite(gzFile, &GBASystemCounters.frameCount, sizeof(GBASystemCounters.frameCount));
  86.699 -	}
  86.700 -
  86.701 -	// SAVE_GAME_VERSION_10
  86.702 -	{
  86.703 -		utilGzWrite(gzFile, memoryWait, 16 * sizeof(int32));
  86.704 -		utilGzWrite(gzFile, memoryWait32, 16 * sizeof(int32));
  86.705 -		utilGzWrite(gzFile, memoryWaitSeq, 16 * sizeof(int32));
  86.706 -		utilGzWrite(gzFile, memoryWaitSeq32, 16 * sizeof(int32));
  86.707 -		utilGzWrite(gzFile, memoryWaitFetch, 16 * sizeof(int32));
  86.708 -		utilGzWrite(gzFile, memoryWaitFetch32, 16 * sizeof(int32));
  86.709 -	}
  86.710 -
  86.711 -	// SAVE_GAME_VERSION_11
  86.712 -	{
  86.713 -		utilGzWrite(gzFile, &prefetchActive, sizeof(bool8));
  86.714 -		utilGzWrite(gzFile, &prefetchPrevActive, sizeof(bool8));
  86.715 -		utilGzWrite(gzFile, &prefetchApplies, sizeof(bool8));
  86.716 -	}
  86.717 -
  86.718 -	// SAVE_GAME_VERSION_12
  86.719 -	{
  86.720 -		utilGzWrite(gzFile, &memLagTempEnabled, sizeof(bool8)); // necessary
  86.721 -		utilGzWrite(gzFile, &speedHack, sizeof(bool8)); // just in case it's ever used...
  86.722 -	}
  86.723 -
  86.724 -	// SAVE_GAME_VERSION_13
  86.725 -	{
  86.726 -		utilGzWrite(gzFile, &GBASystemCounters.lagCount, sizeof(GBASystemCounters.lagCount));
  86.727 -		utilGzWrite(gzFile, &GBASystemCounters.lagged, sizeof(GBASystemCounters.lagged));
  86.728 -		utilGzWrite(gzFile, &GBASystemCounters.laggedLast, sizeof(GBASystemCounters.laggedLast));
  86.729 -	}
  86.730 -
  86.731 -	return true;
  86.732 -}
  86.733 -
  86.734 -bool CPUWriteState(const char *file)
  86.735 -{
  86.736 -	gzFile gzFile = utilGzOpen(file, "wb");
  86.737 -
  86.738 -	if (gzFile == NULL)
  86.739 -	{
  86.740 -		systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), file);
  86.741 -		return false;
  86.742 -	}
  86.743 -
  86.744 -	bool res = CPUWriteStateToStream(gzFile);
  86.745 -
  86.746 -	utilGzClose(gzFile);
  86.747 -
  86.748 -	return res;
  86.749 -}
  86.750 -
  86.751 -bool CPUWriteMemState(char *memory, int available)
  86.752 -{
  86.753 -	gzFile gzFile = utilMemGzOpen(memory, available, "w");
  86.754 -
  86.755 -	if (gzFile == NULL)
  86.756 -	{
  86.757 -		return false;
  86.758 -	}
  86.759 -
  86.760 -	bool res = CPUWriteStateToStream(gzFile);
  86.761 -
  86.762 -	long pos = utilGzTell(gzFile) + 8;
  86.763 -
  86.764 -	if (pos >= (available))
  86.765 -		res = false;
  86.766 -
  86.767 -	utilGzClose(gzFile);
  86.768 -
  86.769 -	return res;
  86.770 -}
  86.771 -
  86.772 -static int	tempStateID	  = 0;
  86.773 -static int	tempFailCount = 0;
  86.774 -static bool backupSafe	  = true;
  86.775 -
  86.776 -bool CPUReadStateFromStream(gzFile gzFile)
  86.777 -{
  86.778 -	bool8 ub;
  86.779 -	char  tempBackupName [128];
  86.780 -	if (backupSafe)
  86.781 -	{
  86.782 -		sprintf(tempBackupName, "gbatempsave%d.sav", tempStateID++);
  86.783 -		CPUWriteState(tempBackupName);
  86.784 -	}
  86.785 -
  86.786 -	int version = utilReadInt(gzFile);
  86.787 -
  86.788 -	if (version > SAVE_GAME_VERSION || version < SAVE_GAME_VERSION_1)
  86.789 -	{
  86.790 -		systemMessage(MSG_UNSUPPORTED_VBA_SGM,
  86.791 -		              N_("Unsupported VisualBoyAdvance save game version %d"),
  86.792 -		              version);
  86.793 -		goto failedLoad;
  86.794 -	}
  86.795 -
  86.796 -	u8 romname[17];
  86.797 -
  86.798 -	utilGzRead(gzFile, romname, 16);
  86.799 -
  86.800 -	if (memcmp(&rom[0xa0], romname, 16) != 0)
  86.801 -	{
  86.802 -		romname[16] = 0;
  86.803 -		for (int i = 0; i < 16; i++)
  86.804 -			if (romname[i] < 32)
  86.805 -				romname[i] = 32;
  86.806 -		systemMessage(MSG_CANNOT_LOAD_SGM, N_("Cannot load save game for %s"), romname);
  86.807 -		goto failedLoad;
  86.808 -	}
  86.809 -
  86.810 -	ub = utilReadInt(gzFile) ? true : false;
  86.811 -
  86.812 -	if (ub != useBios)
  86.813 -	{
  86.814 -		if (useBios)
  86.815 -			systemMessage(MSG_SAVE_GAME_NOT_USING_BIOS,
  86.816 -			              N_("Save game is not using the BIOS files"));
  86.817 -		else
  86.818 -			systemMessage(MSG_SAVE_GAME_USING_BIOS,
  86.819 -			              N_("Save game is using the BIOS file"));
  86.820 -		goto failedLoad;
  86.821 -	}
  86.822 -
  86.823 -	utilGzRead(gzFile, &reg[0], sizeof(reg));
  86.824 -
  86.825 -	utilReadData(gzFile, saveGameStruct);
  86.826 -
  86.827 -	if (version < SAVE_GAME_VERSION_3)
  86.828 -		stopState = false;
  86.829 -	else
  86.830 -		stopState = utilReadInt(gzFile) ? true : false;
  86.831 -
  86.832 -	if (version < SAVE_GAME_VERSION_4)
  86.833 -		intState = false;
  86.834 -	else
  86.835 -		intState = utilReadInt(gzFile) ? true : false;
  86.836 -
  86.837 -	utilGzRead(gzFile, internalRAM, 0x8000);
  86.838 -	utilGzRead(gzFile, paletteRAM, 0x400);
  86.839 -	utilGzRead(gzFile, workRAM, 0x40000);
  86.840 -	utilGzRead(gzFile, vram, 0x20000);
  86.841 -	utilGzRead(gzFile, oam, 0x400);
  86.842 -	if (version < SAVE_GAME_VERSION_6)
  86.843 -		utilGzRead(gzFile, pix, 4 * 240 * 160);
  86.844 -	else
  86.845 -		utilGzRead(gzFile, pix, 4 * 241 * 162);
  86.846 -	utilGzRead(gzFile, ioMem, 0x400);
  86.847 -
  86.848 -	eepromReadGame(gzFile, version);
  86.849 -	flashReadGame(gzFile, version);
  86.850 -	soundReadGame(gzFile, version);
  86.851 -
  86.852 -	if (version > SAVE_GAME_VERSION_1)
  86.853 -	{
  86.854 -		cheatsReadGame(gzFile);
  86.855 -	}
  86.856 -	if (version > SAVE_GAME_VERSION_6)
  86.857 -	{
  86.858 -		rtcReadGame(gzFile);
  86.859 -	}
  86.860 -
  86.861 -	if (version <= SAVE_GAME_VERSION_7)
  86.862 -	{
  86.863 -		u32 temp;
  86.864 -#define SWAP(a, b, c) \
  86.865 -	temp = (a); \
  86.866 -	(a)	 = (b) << 16 | (c); \
  86.867 -	(b)	 = (temp) >> 16; \
  86.868 -	(c)	 = (temp) & 0xFFFF;
  86.869 -
  86.870 -		SWAP(dma0Source, DM0SAD_H, DM0SAD_L);
  86.871 -		SWAP(dma0Dest,   DM0DAD_H, DM0DAD_L);
  86.872 -		SWAP(dma1Source, DM1SAD_H, DM1SAD_L);
  86.873 -		SWAP(dma1Dest,   DM1DAD_H, DM1DAD_L);
  86.874 -		SWAP(dma2Source, DM2SAD_H, DM2SAD_L);
  86.875 -		SWAP(dma2Dest,   DM2DAD_H, DM2DAD_L);
  86.876 -		SWAP(dma3Source, DM3SAD_H, DM3SAD_L);
  86.877 -		SWAP(dma3Dest,   DM3DAD_H, DM3DAD_L);
  86.878 -	}
  86.879 -
  86.880 -	// set pointers!
  86.881 -	layerEnable = layerSettings & DISPCNT;
  86.882 -
  86.883 -	CPUUpdateRender();
  86.884 -	CPUUpdateRenderBuffers(true);
  86.885 -	CPUUpdateWindow0();
  86.886 -	CPUUpdateWindow1();
  86.887 -	gbaSaveType = 0;
  86.888 -	switch (saveType)
  86.889 -	{
  86.890 -	case 0:
  86.891 -		cpuSaveGameFunc = flashSaveDecide;
  86.892 -		break;
  86.893 -	case 1:
  86.894 -		cpuSaveGameFunc = sramWrite;
  86.895 -		gbaSaveType		= 1;
  86.896 -		break;
  86.897 -	case 2:
  86.898 -		cpuSaveGameFunc = flashWrite;
  86.899 -		gbaSaveType		= 2;
  86.900 -		break;
  86.901 -	default:
  86.902 -		systemMessage(MSG_UNSUPPORTED_SAVE_TYPE,
  86.903 -		              N_("Unsupported save type %d"), saveType);
  86.904 -		break;
  86.905 -	}
  86.906 -	if (eepromInUse)
  86.907 -		gbaSaveType = 3;
  86.908 -
  86.909 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
  86.910 -
  86.911 -	if (version >= SAVE_GAME_VERSION_9) // new to re-recording version:
  86.912 -	{
  86.913 -		extern int32 sensorX, sensorY; // from SDL.cpp
  86.914 -		utilGzRead(gzFile, &sensorX, sizeof(sensorX));
  86.915 -		utilGzRead(gzFile, &sensorY, sizeof(sensorY));
  86.916 -
  86.917 -		bool8 movieSnapshot;
  86.918 -		utilGzRead(gzFile, &movieSnapshot, sizeof(movieSnapshot));
  86.919 -		if (VBAMovieActive() && !movieSnapshot)
  86.920 -		{
  86.921 -			systemMessage(0, N_("Can't load a non-movie snapshot while a movie is active."));
  86.922 -			goto failedLoad;
  86.923 -		}
  86.924 -
  86.925 -		if (movieSnapshot) // even if a movie isn't active we still want to parse through this in case other stuff is added
  86.926 -		                   // later on in the save format
  86.927 -		{
  86.928 -			uint32 movieInputDataSize = 0;
  86.929 -			utilGzRead(gzFile, &movieInputDataSize, sizeof(movieInputDataSize));
  86.930 -			uint8 *local_movie_data = new uint8[movieInputDataSize];
  86.931 -			int	   readBytes		= utilGzRead(gzFile, local_movie_data, movieInputDataSize);
  86.932 -			if (readBytes != movieInputDataSize)
  86.933 -			{
  86.934 -				systemMessage(0, N_("Corrupt movie snapshot."));
  86.935 -				if (local_movie_data)
  86.936 -					delete [] local_movie_data;
  86.937 -				goto failedLoad;
  86.938 -			}
  86.939 -			int code = VBAMovieUnfreeze(local_movie_data, movieInputDataSize);
  86.940 -			if (local_movie_data)
  86.941 -				delete [] local_movie_data;
  86.942 -			if (code != MOVIE_SUCCESS && VBAMovieActive())
  86.943 -			{
  86.944 -				char errStr [1024];
  86.945 -				strcpy(errStr, "Failed to load movie snapshot");
  86.946 -				switch (code)
  86.947 -				{
  86.948 -				case MOVIE_NOT_FROM_THIS_MOVIE:
  86.949 -					strcat(errStr, ";\nSnapshot not from this movie"); break;
  86.950 -				case MOVIE_NOT_FROM_A_MOVIE:
  86.951 -					strcat(errStr, ";\nNot a movie snapshot"); break;                   // shouldn't get here...
  86.952 -				case MOVIE_SNAPSHOT_INCONSISTENT:
  86.953 -					strcat(errStr, ";\nSnapshot inconsistent with movie"); break;
  86.954 -				case MOVIE_WRONG_FORMAT:
  86.955 -					strcat(errStr, ";\nWrong format"); break;
  86.956 -				}
  86.957 -				strcat(errStr, ".");
  86.958 -				systemMessage(0, N_(errStr));
  86.959 -				goto failedLoad;
  86.960 -			}
  86.961 -		}
  86.962 -		utilGzRead(gzFile, &GBASystemCounters.frameCount, sizeof(GBASystemCounters.frameCount));
  86.963 -	}
  86.964 -	if (version >= SAVE_GAME_VERSION_10)
  86.965 -	{
  86.966 -		utilGzRead(gzFile, memoryWait, 16 * sizeof(int32));
  86.967 -		utilGzRead(gzFile, memoryWait32, 16 * sizeof(int32));
  86.968 -		utilGzRead(gzFile, memoryWaitSeq, 16 * sizeof(int32));
  86.969 -		utilGzRead(gzFile, memoryWaitSeq32, 16 * sizeof(int32));
  86.970 -		utilGzRead(gzFile, memoryWaitFetch, 16 * sizeof(int32));
  86.971 -		utilGzRead(gzFile, memoryWaitFetch32, 16 * sizeof(int32));
  86.972 -	}
  86.973 -	if (version >= SAVE_GAME_VERSION_11)
  86.974 -	{
  86.975 -		utilGzRead(gzFile, &prefetchActive, sizeof(bool8));
  86.976 -		//if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600);
  86.977 -		//if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600);
  86.978 -		utilGzRead(gzFile, &prefetchPrevActive, sizeof(bool8));
  86.979 -		utilGzRead(gzFile, &prefetchApplies, sizeof(bool8));
  86.980 -	}
  86.981 -	if (version >= SAVE_GAME_VERSION_12)
  86.982 -	{
  86.983 -		utilGzRead(gzFile, &memLagTempEnabled, sizeof(bool8)); // necessary
  86.984 -		utilGzRead(gzFile, &speedHack, sizeof(bool8)); // just in case it's ever used...
  86.985 -	}
  86.986 -	if (version >= SAVE_GAME_VERSION_13)
  86.987 -	{
  86.988 -		utilGzRead(gzFile, &GBASystemCounters.lagCount, sizeof(GBASystemCounters.lagCount));
  86.989 -		utilGzRead(gzFile, &GBASystemCounters.lagged, sizeof(GBASystemCounters.lagged));
  86.990 -		utilGzRead(gzFile, &GBASystemCounters.laggedLast, sizeof(GBASystemCounters.laggedLast));
  86.991 -	}
  86.992 -
  86.993 -	if (backupSafe)
  86.994 -	{
  86.995 -		remove(tempBackupName);
  86.996 -		tempFailCount = 0;
  86.997 -	}
  86.998 -	systemSetJoypad(0, ~P1 & 0x3FF);
  86.999 -	VBAUpdateButtonPressDisplay();
 86.1000 -	VBAUpdateFrameCountDisplay();
 86.1001 -	systemRefreshScreen();
 86.1002 -	return true;
 86.1003 -
 86.1004 -failedLoad:
 86.1005 -	if (backupSafe)
 86.1006 -	{
 86.1007 -		tempFailCount++;
 86.1008 -		if (tempFailCount < 3) // fail no more than 2 times in a row
 86.1009 -			CPUReadState(tempBackupName);
 86.1010 -		remove(tempBackupName);
 86.1011 -	}
 86.1012 -	return false;
 86.1013 -}
 86.1014 -
 86.1015 -bool CPUReadMemState(char *memory, int available)
 86.1016 -{
 86.1017 -	gzFile gzFile = utilMemGzOpen(memory, available, "r");
 86.1018 -
 86.1019 -	backupSafe = false;
 86.1020 -	bool res = CPUReadStateFromStream(gzFile);
 86.1021 -	backupSafe = true;
 86.1022 -
 86.1023 -	utilGzClose(gzFile);
 86.1024 -
 86.1025 -	return res;
 86.1026 -}
 86.1027 -
 86.1028 -bool CPUReadState(const char *file)
 86.1029 -{
 86.1030 -	gzFile gzFile = utilGzOpen(file, "rb");
 86.1031 -
 86.1032 -	if (gzFile == NULL)
 86.1033 -		return false;
 86.1034 -
 86.1035 -	bool res = CPUReadStateFromStream(gzFile);
 86.1036 -
 86.1037 -	utilGzClose(gzFile);
 86.1038 -
 86.1039 -	return res;
 86.1040 -}
 86.1041 -
 86.1042 -bool CPUExportEepromFile(const char *fileName)
 86.1043 -{
 86.1044 -	if (eepromInUse)
 86.1045 -	{
 86.1046 -		FILE *file = fopen(fileName, "wb");
 86.1047 -
 86.1048 -		if (!file)
 86.1049 -		{
 86.1050 -			systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"),
 86.1051 -			              fileName);
 86.1052 -			return false;
 86.1053 -		}
 86.1054 -
 86.1055 -		for (int i = 0; i < eepromSize; )
 86.1056 -		{
 86.1057 -			for (int j = 0; j < 8; j++)
 86.1058 -			{
 86.1059 -				if (fwrite(&eepromData[i + 7 - j], 1, 1, file) != 1)
 86.1060 -				{
 86.1061 -					fclose(file);
 86.1062 -					return false;
 86.1063 -				}
 86.1064 -			}
 86.1065 -			i += 8;
 86.1066 -		}
 86.1067 -		fclose(file);
 86.1068 -	}
 86.1069 -	return true;
 86.1070 -}
 86.1071 -
 86.1072 -bool CPUWriteBatteryToStream(gzFile gzFile)
 86.1073 -{
 86.1074 -	if (!gzFile)
 86.1075 -		return false;
 86.1076 -
 86.1077 -	utilWriteInt(gzFile, SAVE_GAME_VERSION);
 86.1078 -
 86.1079 -	// for simplicity, we put both types of battery files should be in the stream, even if one's empty
 86.1080 -	eepromSaveGame(gzFile);
 86.1081 -	flashSaveGame(gzFile);
 86.1082 -
 86.1083 -	return true;
 86.1084 -}
 86.1085 -
 86.1086 -bool CPUWriteBatteryFile(const char *fileName)
 86.1087 -{
 86.1088 -	if (gbaSaveType == 0)
 86.1089 -	{
 86.1090 -		if (eepromInUse)
 86.1091 -			gbaSaveType = 3;
 86.1092 -		else
 86.1093 -			switch (saveType)
 86.1094 -			{
 86.1095 -			case 1:
 86.1096 -				gbaSaveType = 1;
 86.1097 -				break;
 86.1098 -			case 2:
 86.1099 -				gbaSaveType = 2;
 86.1100 -				break;
 86.1101 -			}
 86.1102 -	}
 86.1103 -
 86.1104 -	if (gbaSaveType)
 86.1105 -	{
 86.1106 -		FILE *file = fopen(fileName, "wb");
 86.1107 -
 86.1108 -		if (!file)
 86.1109 -		{
 86.1110 -			systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"),
 86.1111 -			              fileName);
 86.1112 -			return false;
 86.1113 -		}
 86.1114 -
 86.1115 -		// only save if Flash/Sram in use or EEprom in use
 86.1116 -		if (gbaSaveType != 3)
 86.1117 -		{
 86.1118 -			if (gbaSaveType == 2)
 86.1119 -			{
 86.1120 -				if (fwrite(flashSaveMemory, 1, flashSize, file) != (size_t)flashSize)
 86.1121 -				{
 86.1122 -					fclose(file);
 86.1123 -					return false;
 86.1124 -				}
 86.1125 -			}
 86.1126 -			else
 86.1127 -			{
 86.1128 -				if (fwrite(flashSaveMemory, 1, 0x10000, file) != 0x10000)
 86.1129 -				{
 86.1130 -					fclose(file);
 86.1131 -					return false;
 86.1132 -				}
 86.1133 -			}
 86.1134 -		}
 86.1135 -		else
 86.1136 -		{
 86.1137 -			if (fwrite(eepromData, 1, eepromSize, file) != (size_t)eepromSize)
 86.1138 -			{
 86.1139 -				fclose(file);
 86.1140 -				return false;
 86.1141 -			}
 86.1142 -		}
 86.1143 -		fclose(file);
 86.1144 -	}
 86.1145 -
 86.1146 -	return true;
 86.1147 -}
 86.1148 -
 86.1149 -bool CPUReadGSASnapshot(const char *fileName)
 86.1150 -{
 86.1151 -	int	  i;
 86.1152 -	FILE *file = fopen(fileName, "rb");
 86.1153 -
 86.1154 -	if (!file)
 86.1155 -	{
 86.1156 -		systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName);
 86.1157 -		return false;
 86.1158 -	}
 86.1159 -
 86.1160 -	// check file size to know what we should read
 86.1161 -	fseek(file, 0, SEEK_END);
 86.1162 -
 86.1163 -	// long size = ftell(file);
 86.1164 -	fseek(file, 0x0, SEEK_SET);
 86.1165 -	fread(&i, 1, 4, file);
 86.1166 -	fseek(file, i, SEEK_CUR); // Skip SharkPortSave
 86.1167 -	fseek(file, 4, SEEK_CUR); // skip some sort of flag
 86.1168 -	fread(&i, 1, 4, file); // name length
 86.1169 -	fseek(file, i, SEEK_CUR); // skip name
 86.1170 -	fread(&i, 1, 4, file); // desc length
 86.1171 -	fseek(file, i, SEEK_CUR); // skip desc
 86.1172 -	fread(&i, 1, 4, file); // notes length
 86.1173 -	fseek(file, i, SEEK_CUR); // skip notes
 86.1174 -	int saveSize;
 86.1175 -	fread(&saveSize, 1, 4, file); // read length
 86.1176 -	saveSize -= 0x1c; // remove header size
 86.1177 -	char buffer[17];
 86.1178 -	char buffer2[17];
 86.1179 -	fread(buffer, 1, 16, file);
 86.1180 -	buffer[16] = 0;
 86.1181 -	for (i = 0; i < 16; i++)
 86.1182 -		if (buffer[i] < 32)
 86.1183 -			buffer[i] = 32;
 86.1184 -	memcpy(buffer2, &rom[0xa0], 16);
 86.1185 -	buffer2[16] = 0;
 86.1186 -	for (i = 0; i < 16; i++)
 86.1187 -		if (buffer2[i] < 32)
 86.1188 -			buffer2[i] = 32;
 86.1189 -	if (memcmp(buffer, buffer2, 16))
 86.1190 -	{
 86.1191 -		systemMessage(MSG_CANNOT_IMPORT_SNAPSHOT_FOR,
 86.1192 -		              N_("Cannot import snapshot for %s. Current game is %s"),
 86.1193 -		              buffer,
 86.1194 -		              buffer2);
 86.1195 -		fclose(file);
 86.1196 -		return false;
 86.1197 -	}
 86.1198 -	fseek(file, 12, SEEK_CUR); // skip some flags
 86.1199 -	if (saveSize >= 65536)
 86.1200 -	{
 86.1201 -		if (fread(flashSaveMemory, 1, saveSize, file) != (size_t)saveSize)
 86.1202 -		{
 86.1203 -			fclose(file);
 86.1204 -			return false;
 86.1205 -		}
 86.1206 -	}
 86.1207 -	else
 86.1208 -	{
 86.1209 -		systemMessage(MSG_UNSUPPORTED_SNAPSHOT_FILE,
 86.1210 -		              N_("Unsupported snapshot file %s"),
 86.1211 -		              fileName);
 86.1212 -		fclose(file);
 86.1213 -		return false;
 86.1214 -	}
 86.1215 -	fclose(file);
 86.1216 -	CPUReset();
 86.1217 -	return true;
 86.1218 -}
 86.1219 -
 86.1220 -bool CPUWriteGSASnapshot(const char *fileName,
 86.1221 -                         const char *title,
 86.1222 -                         const char *desc,
 86.1223 -                         const char *notes)
 86.1224 -{
 86.1225 -	FILE *file = fopen(fileName, "wb");
 86.1226 -
 86.1227 -	if (!file)
 86.1228 -	{
 86.1229 -		systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName);
 86.1230 -		return false;
 86.1231 -	}
 86.1232 -
 86.1233 -	u8 buffer[17];
 86.1234 -
 86.1235 -	utilPutDword(buffer, 0x0d); // SharkPortSave length
 86.1236 -	fwrite(buffer, 1, 4, file);
 86.1237 -	fwrite("SharkPortSave", 1, 0x0d, file);
 86.1238 -	utilPutDword(buffer, 0x000f0000);
 86.1239 -	fwrite(buffer, 1, 4, file); // save type 0x000f0000 = GBA save
 86.1240 -	utilPutDword(buffer, strlen(title));
 86.1241 -	fwrite(buffer, 1, 4, file); // title length
 86.1242 -	fwrite(title, 1, strlen(title), file);
 86.1243 -	utilPutDword(buffer, strlen(desc));
 86.1244 -	fwrite(buffer, 1, 4, file); // desc length
 86.1245 -	fwrite(desc, 1, strlen(desc), file);
 86.1246 -	utilPutDword(buffer, strlen(notes));
 86.1247 -	fwrite(buffer, 1, 4, file); // notes length
 86.1248 -	fwrite(notes, 1, strlen(notes), file);
 86.1249 -	int saveSize = 0x10000;
 86.1250 -	if (gbaSaveType == 2)
 86.1251 -		saveSize = flashSize;
 86.1252 -	int totalSize = saveSize + 0x1c;
 86.1253 -
 86.1254 -	utilPutDword(buffer, totalSize); // length of remainder of save - CRC
 86.1255 -	fwrite(buffer, 1, 4, file);
 86.1256 -
 86.1257 -	char temp[0x2001c];
 86.1258 -	memset(temp, 0, 28);
 86.1259 -	memcpy(temp, &rom[0xa0], 16); // copy internal name
 86.1260 -	temp[0x10] = rom[0xbe]; // reserved area (old checksum)
 86.1261 -	temp[0x11] = rom[0xbf]; // reserved area (old checksum)
 86.1262 -	temp[0x12] = rom[0xbd]; // complement check
 86.1263 -	temp[0x13] = rom[0xb0]; // maker
 86.1264 -	temp[0x14] = 1; // 1 save ?
 86.1265 -	memcpy(&temp[0x1c], flashSaveMemory, saveSize); // copy save
 86.1266 -	fwrite(temp, 1, totalSize, file); // write save + header
 86.1267 -	u32 crc = 0;
 86.1268 -
 86.1269 -	for (int i = 0; i < totalSize; i++)
 86.1270 -	{
 86.1271 -		crc += ((u32)temp[i] << (crc % 0x18));
 86.1272 -	}
 86.1273 -
 86.1274 -	utilPutDword(buffer, crc);
 86.1275 -	fwrite(buffer, 1, 4, file); // CRC?
 86.1276 -
 86.1277 -	fclose(file);
 86.1278 -	return true;
 86.1279 -}
 86.1280 -
 86.1281 -bool CPUImportEepromFile(const char *fileName)
 86.1282 -{
 86.1283 -	FILE *file = fopen(fileName, "rb");
 86.1284 -
 86.1285 -	if (!file)
 86.1286 -		return false;
 86.1287 -
 86.1288 -	// check file size to know what we should read
 86.1289 -	fseek(file, 0, SEEK_END);
 86.1290 -
 86.1291 -	long size = ftell(file);
 86.1292 -	fseek(file, 0, SEEK_SET);
 86.1293 -	if (size == 512 || size == 0x2000)
 86.1294 -	{
 86.1295 -		if (fread(eepromData, 1, size, file) != (size_t)size)
 86.1296 -		{
 86.1297 -			fclose(file);
 86.1298 -			return false;
 86.1299 -		}
 86.1300 -		for (int i = 0; i < size; )
 86.1301 -		{
 86.1302 -			u8 tmp = eepromData[i];
 86.1303 -			eepromData[i]	  = eepromData[7 - i];
 86.1304 -			eepromData[7 - i] = tmp;
 86.1305 -			i++;
 86.1306 -			tmp = eepromData[i];
 86.1307 -			eepromData[i]	  = eepromData[7 - i];
 86.1308 -			eepromData[7 - i] = tmp;
 86.1309 -			i++;
 86.1310 -			tmp = eepromData[i];
 86.1311 -			eepromData[i]	  = eepromData[7 - i];
 86.1312 -			eepromData[7 - i] = tmp;
 86.1313 -			i++;
 86.1314 -			tmp = eepromData[i];
 86.1315 -			eepromData[i]	  = eepromData[7 - i];
 86.1316 -			eepromData[7 - i] = tmp;
 86.1317 -			i++;
 86.1318 -			i += 4;
 86.1319 -		}
 86.1320 -	}
 86.1321 -	else
 86.1322 -	{
 86.1323 -		fclose(file);
 86.1324 -		return false;
 86.1325 -	}
 86.1326 -	fclose(file);
 86.1327 -	return true;
 86.1328 -}
 86.1329 -
 86.1330 -bool CPUReadBatteryFromStream(gzFile gzFile)
 86.1331 -{
 86.1332 -	if (!gzFile)
 86.1333 -		return false;
 86.1334 -
 86.1335 -	int version = utilReadInt(gzFile);
 86.1336 -
 86.1337 -	// for simplicity, we put both types of battery files should be in the stream, even if one's empty
 86.1338 -	eepromReadGame(gzFile, version);
 86.1339 -	flashReadGame(gzFile, version);
 86.1340 -
 86.1341 -	return true;
 86.1342 -}
 86.1343 -
 86.1344 -bool CPUReadBatteryFile(const char *fileName)
 86.1345 -{
 86.1346 -	FILE *file = fopen(fileName, "rb");
 86.1347 -
 86.1348 -	if (!file)
 86.1349 -		return false;
 86.1350 -
 86.1351 -	// check file size to know what we should read
 86.1352 -	fseek(file, 0, SEEK_END);
 86.1353 -
 86.1354 -	long size = ftell(file);
 86.1355 -	fseek(file, 0, SEEK_SET);
 86.1356 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 86.1357 -
 86.1358 -	if (size == 512 || size == 0x2000)
 86.1359 -	{
 86.1360 -		if (fread(eepromData, 1, size, file) != (size_t)size)
 86.1361 -		{
 86.1362 -			fclose(file);
 86.1363 -			return false;
 86.1364 -		}
 86.1365 -	}
 86.1366 -	else
 86.1367 -	{
 86.1368 -		if (size == 0x20000)
 86.1369 -		{
 86.1370 -			if (fread(flashSaveMemory, 1, 0x20000, file) != 0x20000)
 86.1371 -			{
 86.1372 -				fclose(file);
 86.1373 -				return false;
 86.1374 -			}
 86.1375 -			flashSetSize(0x20000);
 86.1376 -		}
 86.1377 -		else
 86.1378 -		{
 86.1379 -			if (fread(flashSaveMemory, 1, 0x10000, file) != 0x10000)
 86.1380 -			{
 86.1381 -				fclose(file);
 86.1382 -				return false;
 86.1383 -			}
 86.1384 -			flashSetSize(0x10000);
 86.1385 -		}
 86.1386 -	}
 86.1387 -	fclose(file);
 86.1388 -	return true;
 86.1389 -}
 86.1390 -
 86.1391 -bool CPUWritePNGFile(const char *fileName)
 86.1392 -{
 86.1393 -	return utilWritePNGFile(fileName, 240, 160, pix);
 86.1394 -}
 86.1395 -
 86.1396 -bool CPUWriteBMPFile(const char *fileName)
 86.1397 -{
 86.1398 -	return utilWriteBMPFile(fileName, 240, 160, pix);
 86.1399 -}
 86.1400 -
 86.1401 -void CPUCleanUp()
 86.1402 -{
 86.1403 -	newFrame	  = true;
 86.1404 -
 86.1405 -	GBASystemCounters.frameCount = 0;
 86.1406 -	GBASystemCounters.lagCount	 = 0;
 86.1407 -	GBASystemCounters.extraCount = 0;
 86.1408 -	GBASystemCounters.lagged	 = true;
 86.1409 -	GBASystemCounters.laggedLast = true;
 86.1410 -
 86.1411 -#ifdef PROFILING
 86.1412 -	if (profilingTicksReload)
 86.1413 -	{
 86.1414 -		profCleanup();
 86.1415 -	}
 86.1416 -#endif
 86.1417 -
 86.1418 -#if (defined(WIN32) && !defined(SDL))
 86.1419 -	#define FreeMappedMem(name, mapName, offset) \
 86.1420 -	if (name != NULL) { \
 86.1421 -		UnmapViewOfFile((name) - (offset)); \
 86.1422 -		name = NULL; \
 86.1423 -		CloseHandle(mapName); \
 86.1424 -	}
 86.1425 -#else
 86.1426 -	#define FreeMappedMem(name, mapName, offset) \
 86.1427 -	if (name != NULL) { \
 86.1428 -		free(name); \
 86.1429 -		name = NULL; \
 86.1430 -	}
 86.1431 -#endif
 86.1432 -
 86.1433 -	FreeMappedMem(rom, mapROM, 0);
 86.1434 -	FreeMappedMem(vram, mapVRAM, 0);
 86.1435 -	FreeMappedMem(paletteRAM, mapPALETTERAM, 0);
 86.1436 -	FreeMappedMem(internalRAM, mapIRAM, 0);
 86.1437 -	FreeMappedMem(workRAM, mapWORKRAM, 0);
 86.1438 -	FreeMappedMem(bios, mapBIOS, 0);
 86.1439 -	FreeMappedMem(pix, mapPIX, 4);
 86.1440 -	FreeMappedMem(oam, mapOAM, 0);
 86.1441 -	FreeMappedMem(ioMem, mapIOMEM, 0);
 86.1442 -
 86.1443 -	eepromErase();
 86.1444 -	flashErase();
 86.1445 -
 86.1446 -	elfCleanUp();
 86.1447 -
 86.1448 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 86.1449 -
 86.1450 -	systemClearJoypads();
 86.1451 -	systemResetSensor();
 86.1452 -
 86.1453 -//	gbaLastTime = gbaFrameCount = 0;
 86.1454 -	systemRefreshScreen();
 86.1455 -}
 86.1456 -
 86.1457 -int CPULoadRom(const char *szFile)
 86.1458 -{
 86.1459 -	int size = 0x2000000;
 86.1460 -
 86.1461 -	if (rom != NULL)
 86.1462 -	{
 86.1463 -		CPUCleanUp();
 86.1464 -	}
 86.1465 -
 86.1466 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 86.1467 -
 86.1468 -	// size+4 is so RAM search and watch are safe to read any byte in the allocated region as a 4-byte int
 86.1469 -#if (defined(WIN32) && !defined(SDL))
 86.1470 -	#define AllocMappedMem(name, mapName, nameStr, size, useCalloc, offset) \
 86.1471 -	mapName = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (size) + (offset) + (4), nameStr); \
 86.1472 -	if ((mapName) && GetLastError() == ERROR_ALREADY_EXISTS) { \
 86.1473 -		CloseHandle(mapName); \
 86.1474 -		mapName = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (size) + (offset) + (4), NULL); \
 86.1475 -	} \
 86.1476 -	name = (u8 *)MapViewOfFile(mapName, FILE_MAP_WRITE, 0, 0, 0) + (offset); \
 86.1477 -	if ((name) == NULL) { \
 86.1478 -		systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), nameStr); \
 86.1479 -		CPUCleanUp(); \
 86.1480 -		return 0; \
 86.1481 -	} \
 86.1482 -	memset(name, 0, size + 4);
 86.1483 -#else
 86.1484 -	#define AllocMappedMem(name, mapName, nameStr, size, useCalloc, offset) \
 86.1485 -	name = (u8 *)(useCalloc ? calloc(1, size + 4) : malloc(size + 4)); \
 86.1486 -	if ((name) == NULL) { \
 86.1487 -		systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), nameStr); \
 86.1488 -		CPUCleanUp(); \
 86.1489 -		return 0; \
 86.1490 -	} \
 86.1491 -	memset(name, 0, size + 4);
 86.1492 -#endif
 86.1493 -
 86.1494 -	AllocMappedMem(rom, mapROM, "vbaROM", 0x2000000, false, 0);
 86.1495 -	AllocMappedMem(workRAM, mapWORKRAM, "vbaWORKRAM", 0x40000, true, 0);
 86.1496 -
 86.1497 -	u8 *whereToLoad = rom;
 86.1498 -	if (cpuIsMultiBoot)
 86.1499 -		whereToLoad = workRAM;
 86.1500 -
 86.1501 -	if (utilIsELF(szFile))
 86.1502 -	{
 86.1503 -		FILE *f = fopen(szFile, "rb");
 86.1504 -		if (!f)
 86.1505 -		{
 86.1506 -			systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"),
 86.1507 -			              szFile);
 86.1508 -			FreeMappedMem(rom, mapROM, 0);
 86.1509 -			FreeMappedMem(workRAM, mapWORKRAM, 0);
 86.1510 -			return 0;
 86.1511 -		}
 86.1512 -		bool res = elfRead(szFile, size, f);
 86.1513 -		if (!res || size == 0)
 86.1514 -		{
 86.1515 -			FreeMappedMem(rom, mapROM, 0);
 86.1516 -			FreeMappedMem(workRAM, mapWORKRAM, 0);
 86.1517 -			elfCleanUp();
 86.1518 -			return 0;
 86.1519 -		}
 86.1520 -	}
 86.1521 -	else if (!utilLoad(szFile,
 86.1522 -	                   utilIsGBAImage,
 86.1523 -	                   whereToLoad,
 86.1524 -	                   size))
 86.1525 -	{
 86.1526 -		FreeMappedMem(rom, mapROM, 0);
 86.1527 -		FreeMappedMem(workRAM, mapWORKRAM, 0);
 86.1528 -		return 0;
 86.1529 -	}
 86.1530 -
 86.1531 -	u16 *temp = (u16 *)(rom + ((size + 1) & ~1));
 86.1532 -	int	 i;
 86.1533 -	for (i = (size + 1) & ~1; i < 0x2000000; i += 2)
 86.1534 -	{
 86.1535 -		WRITE16LE(temp, (i >> 1) & 0xFFFF);
 86.1536 -		temp++;
 86.1537 -	}
 86.1538 -
 86.1539 -	AllocMappedMem(bios, mapBIOS, "vbaBIOS", 0x4000, true, 0);
 86.1540 -	AllocMappedMem(internalRAM, mapIRAM, "vbaIRAM", 0x8000, true, 0);
 86.1541 -	AllocMappedMem(paletteRAM, mapPALETTERAM, "vbaPALETTERAM", 0x400, true, 0);
 86.1542 -	AllocMappedMem(vram, mapVRAM, "vbaVRAM", 0x20000, true, 0);
 86.1543 -	AllocMappedMem(oam, mapOAM, "vbaOAM", 0x400, true, 0);
 86.1544 -
 86.1545 -	// HACK: +4 at start to accomodate the 2xSaI filter reading out of bounds of the leftmost pixel
 86.1546 -	AllocMappedMem(pix, mapPIX, "vbaPIX", 4 * 241 * 162, true, 4);
 86.1547 -	AllocMappedMem(ioMem, mapIOMEM, "vbaIOMEM", 0x400, true, 0);
 86.1548 -
 86.1549 -	CPUUpdateRenderBuffers(true);
 86.1550 -
 86.1551 -	return size;
 86.1552 -}
 86.1553 -
 86.1554 -void CPUUpdateRender()
 86.1555 -{
 86.1556 -	switch (DISPCNT & 7)
 86.1557 -	{
 86.1558 -	case 0:
 86.1559 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1560 -		    cpuDisableSfx)
 86.1561 -			renderLine = mode0RenderLine;
 86.1562 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1563 -			renderLine = mode0RenderLineNoWindow;
 86.1564 -		else
 86.1565 -			renderLine = mode0RenderLineAll;
 86.1566 -		break;
 86.1567 -	case 1:
 86.1568 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1569 -		    cpuDisableSfx)
 86.1570 -			renderLine = mode1RenderLine;
 86.1571 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1572 -			renderLine = mode1RenderLineNoWindow;
 86.1573 -		else
 86.1574 -			renderLine = mode1RenderLineAll;
 86.1575 -		break;
 86.1576 -	case 2:
 86.1577 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1578 -		    cpuDisableSfx)
 86.1579 -			renderLine = mode2RenderLine;
 86.1580 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1581 -			renderLine = mode2RenderLineNoWindow;
 86.1582 -		else
 86.1583 -			renderLine = mode2RenderLineAll;
 86.1584 -		break;
 86.1585 -	case 3:
 86.1586 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1587 -		    cpuDisableSfx)
 86.1588 -			renderLine = mode3RenderLine;
 86.1589 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1590 -			renderLine = mode3RenderLineNoWindow;
 86.1591 -		else
 86.1592 -			renderLine = mode3RenderLineAll;
 86.1593 -		break;
 86.1594 -	case 4:
 86.1595 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1596 -		    cpuDisableSfx)
 86.1597 -			renderLine = mode4RenderLine;
 86.1598 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1599 -			renderLine = mode4RenderLineNoWindow;
 86.1600 -		else
 86.1601 -			renderLine = mode4RenderLineAll;
 86.1602 -		break;
 86.1603 -	case 5:
 86.1604 -		if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
 86.1605 -		    cpuDisableSfx)
 86.1606 -			renderLine = mode5RenderLine;
 86.1607 -		else if (fxOn && !windowOn && !(layerEnable & 0x8000))
 86.1608 -			renderLine = mode5RenderLineNoWindow;
 86.1609 -		else
 86.1610 -			renderLine = mode5RenderLineAll;
 86.1611 -	default:
 86.1612 -		break;
 86.1613 -	}
 86.1614 -}
 86.1615 -
 86.1616 -void CPUUpdateCPSR()
 86.1617 -{
 86.1618 -	u32 CPSR = reg[16].I & 0x40;
 86.1619 -	if (N_FLAG)
 86.1620 -		CPSR |= 0x80000000;
 86.1621 -	if (Z_FLAG)
 86.1622 -		CPSR |= 0x40000000;
 86.1623 -	if (C_FLAG)
 86.1624 -		CPSR |= 0x20000000;
 86.1625 -	if (V_FLAG)
 86.1626 -		CPSR |= 0x10000000;
 86.1627 -	if (!armState)
 86.1628 -		CPSR |= 0x00000020;
 86.1629 -	if (!armIrqEnable)
 86.1630 -		CPSR |= 0x80;
 86.1631 -	CPSR	 |= (armMode & 0x1F);
 86.1632 -	reg[16].I = CPSR;
 86.1633 -}
 86.1634 -
 86.1635 -void CPUUpdateFlags(bool breakLoop)
 86.1636 -{
 86.1637 -	u32 CPSR = reg[16].I;
 86.1638 -
 86.1639 -	N_FLAG		 = (CPSR & 0x80000000) ? true : false;
 86.1640 -	Z_FLAG		 = (CPSR & 0x40000000) ? true : false;
 86.1641 -	C_FLAG		 = (CPSR & 0x20000000) ? true : false;
 86.1642 -	V_FLAG		 = (CPSR & 0x10000000) ? true : false;
 86.1643 -	armState	 = (CPSR & 0x20) ? false : true;
 86.1644 -	armIrqEnable = (CPSR & 0x80) ? false : true;
 86.1645 -	if (breakLoop)
 86.1646 -	{
 86.1647 -		if (armIrqEnable && (IF & IE) && (IME & 1))
 86.1648 -		{
 86.1649 -			CPU_BREAK_LOOP_2;
 86.1650 -		}
 86.1651 -	}
 86.1652 -}
 86.1653 -
 86.1654 -void CPUUpdateFlags()
 86.1655 -{
 86.1656 -	CPUUpdateFlags(true);
 86.1657 -}
 86.1658 -
 86.1659 -#ifdef WORDS_BIGENDIAN
 86.1660 -static void CPUSwap(volatile u32 *a, volatile u32 *b)
 86.1661 -{
 86.1662 -	volatile u32 c = *b;
 86.1663 -	*b = *a;
 86.1664 -	*a = c;
 86.1665 -}
 86.1666 -
 86.1667 -#else
 86.1668 -static void CPUSwap(u32 *a, u32 *b)
 86.1669 -{
 86.1670 -	u32 c = *b;
 86.1671 -	*b = *a;
 86.1672 -	*a = c;
 86.1673 -}
 86.1674 -
 86.1675 -#endif
 86.1676 -
 86.1677 -void CPUSwitchMode(int mode, bool saveState, bool breakLoop)
 86.1678 -{
 86.1679 -	//  if(armMode == mode)
 86.1680 -	//    return;
 86.1681 -
 86.1682 -	CPUUpdateCPSR();
 86.1683 -
 86.1684 -	switch (armMode)
 86.1685 -	{
 86.1686 -	case 0x10:
 86.1687 -	case 0x1F:
 86.1688 -		reg[R13_USR].I = reg[13].I;
 86.1689 -		reg[R14_USR].I = reg[14].I;
 86.1690 -		reg[17].I	   = reg[16].I;
 86.1691 -		break;
 86.1692 -	case 0x11:
 86.1693 -		CPUSwap(&reg[R8_FIQ].I, &reg[8].I);
 86.1694 -		CPUSwap(&reg[R9_FIQ].I, &reg[9].I);
 86.1695 -		CPUSwap(&reg[R10_FIQ].I, &reg[10].I);
 86.1696 -		CPUSwap(&reg[R11_FIQ].I, &reg[11].I);
 86.1697 -		CPUSwap(&reg[R12_FIQ].I, &reg[12].I);
 86.1698 -		reg[R13_FIQ].I	= reg[13].I;
 86.1699 -		reg[R14_FIQ].I	= reg[14].I;
 86.1700 -		reg[SPSR_FIQ].I = reg[17].I;
 86.1701 -		break;
 86.1702 -	case 0x12:
 86.1703 -		reg[R13_IRQ].I	= reg[13].I;
 86.1704 -		reg[R14_IRQ].I	= reg[14].I;
 86.1705 -		reg[SPSR_IRQ].I =  reg[17].I;
 86.1706 -		break;
 86.1707 -	case 0x13:
 86.1708 -		reg[R13_SVC].I	= reg[13].I;
 86.1709 -		reg[R14_SVC].I	= reg[14].I;
 86.1710 -		reg[SPSR_SVC].I =  reg[17].I;
 86.1711 -		break;
 86.1712 -	case 0x17:
 86.1713 -		reg[R13_ABT].I	= reg[13].I;
 86.1714 -		reg[R14_ABT].I	= reg[14].I;
 86.1715 -		reg[SPSR_ABT].I =  reg[17].I;
 86.1716 -		break;
 86.1717 -	case 0x1b:
 86.1718 -		reg[R13_UND].I	= reg[13].I;
 86.1719 -		reg[R14_UND].I	= reg[14].I;
 86.1720 -		reg[SPSR_UND].I =  reg[17].I;
 86.1721 -		break;
 86.1722 -	}
 86.1723 -
 86.1724 -	u32 CPSR = reg[16].I;
 86.1725 -	u32 SPSR = reg[17].I;
 86.1726 -
 86.1727 -	switch (mode)
 86.1728 -	{
 86.1729 -	case 0x10:
 86.1730 -	case 0x1F:
 86.1731 -		reg[13].I = reg[R13_USR].I;
 86.1732 -		reg[14].I = reg[R14_USR].I;
 86.1733 -		reg[16].I = SPSR;
 86.1734 -		break;
 86.1735 -	case 0x11:
 86.1736 -		CPUSwap(&reg[8].I, &reg[R8_FIQ].I);
 86.1737 -		CPUSwap(&reg[9].I, &reg[R9_FIQ].I);
 86.1738 -		CPUSwap(&reg[10].I, &reg[R10_FIQ].I);
 86.1739 -		CPUSwap(&reg[11].I, &reg[R11_FIQ].I);
 86.1740 -		CPUSwap(&reg[12].I, &reg[R12_FIQ].I);
 86.1741 -		reg[13].I = reg[R13_FIQ].I;
 86.1742 -		reg[14].I = reg[R14_FIQ].I;
 86.1743 -		if (saveState)
 86.1744 -			reg[17].I = CPSR;
 86.1745 -		else
 86.1746 -			reg[17].I = reg[SPSR_FIQ].I;
 86.1747 -		break;
 86.1748 -	case 0x12:
 86.1749 -		reg[13].I = reg[R13_IRQ].I;
 86.1750 -		reg[14].I = reg[R14_IRQ].I;
 86.1751 -		reg[16].I = SPSR;
 86.1752 -		if (saveState)
 86.1753 -			reg[17].I = CPSR;
 86.1754 -		else
 86.1755 -			reg[17].I = reg[SPSR_IRQ].I;
 86.1756 -		break;
 86.1757 -	case 0x13:
 86.1758 -		reg[13].I = reg[R13_SVC].I;
 86.1759 -		reg[14].I = reg[R14_SVC].I;
 86.1760 -		reg[16].I = SPSR;
 86.1761 -		if (saveState)
 86.1762 -			reg[17].I = CPSR;
 86.1763 -		else
 86.1764 -			reg[17].I = reg[SPSR_SVC].I;
 86.1765 -		break;
 86.1766 -	case 0x17:
 86.1767 -		reg[13].I = reg[R13_ABT].I;
 86.1768 -		reg[14].I = reg[R14_ABT].I;
 86.1769 -		reg[16].I = SPSR;
 86.1770 -		if (saveState)
 86.1771 -			reg[17].I = CPSR;
 86.1772 -		else
 86.1773 -			reg[17].I = reg[SPSR_ABT].I;
 86.1774 -		break;
 86.1775 -	case 0x1b:
 86.1776 -		reg[13].I = reg[R13_UND].I;
 86.1777 -		reg[14].I = reg[R14_UND].I;
 86.1778 -		reg[16].I = SPSR;
 86.1779 -		if (saveState)
 86.1780 -			reg[17].I = CPSR;
 86.1781 -		else
 86.1782 -			reg[17].I = reg[SPSR_UND].I;
 86.1783 -		break;
 86.1784 -	default:
 86.1785 -		systemMessage(MSG_UNSUPPORTED_ARM_MODE, N_("Unsupported ARM mode %02x"), mode);
 86.1786 -		break;
 86.1787 -	}
 86.1788 -	armMode = mode;
 86.1789 -	CPUUpdateFlags(breakLoop);
 86.1790 -	CPUUpdateCPSR();
 86.1791 -}
 86.1792 -
 86.1793 -void CPUSwitchMode(int mode, bool saveState)
 86.1794 -{
 86.1795 -	CPUSwitchMode(mode, saveState, true);
 86.1796 -}
 86.1797 -
 86.1798 -void CPUUndefinedException()
 86.1799 -{
 86.1800 -	u32	 PC = reg[15].I;
 86.1801 -	bool savedArmState = armState;
 86.1802 -	CPUSwitchMode(0x1b, true, false);
 86.1803 -	reg[14].I	 = PC - (savedArmState ? 4 : 2);
 86.1804 -	reg[15].I	 = 0x04;
 86.1805 -	armState	 = true;
 86.1806 -	armIrqEnable = false;
 86.1807 -	armNextPC	 = 0x04;
 86.1808 -	reg[15].I	+= 4;
 86.1809 -}
 86.1810 -
 86.1811 -void CPUSoftwareInterrupt()
 86.1812 -{
 86.1813 -	u32	 PC = reg[15].I;
 86.1814 -	bool savedArmState = armState;
 86.1815 -	CPUSwitchMode(0x13, true, false);
 86.1816 -	reg[14].I	 = PC - (savedArmState ? 4 : 2);
 86.1817 -	reg[15].I	 = 0x08;
 86.1818 -	armState	 = true;
 86.1819 -	armIrqEnable = false;
 86.1820 -	armNextPC	 = 0x08;
 86.1821 -	reg[15].I	+= 4;
 86.1822 -}
 86.1823 -
 86.1824 -void CPUSoftwareInterrupt(int comment)
 86.1825 -{
 86.1826 -	static bool disableMessage = false;
 86.1827 -	if (armState)
 86.1828 -		comment >>= 16;
 86.1829 -#ifdef BKPT_SUPPORT
 86.1830 -	if (comment == 0xff)
 86.1831 -	{
 86.1832 -		extern void (*dbgOutput)(char *, u32);
 86.1833 -		dbgOutput(NULL, reg[0].I);
 86.1834 -		return;
 86.1835 -	}
 86.1836 -#endif
 86.1837 -#ifdef PROFILING
 86.1838 -	if (comment == 0xfe)
 86.1839 -	{
 86.1840 -		profStartup(reg[0].I, reg[1].I);
 86.1841 -		return;
 86.1842 -	}
 86.1843 -	if (comment == 0xfd)
 86.1844 -	{
 86.1845 -		profControl(reg[0].I);
 86.1846 -		return;
 86.1847 -	}
 86.1848 -	if (comment == 0xfc)
 86.1849 -	{
 86.1850 -		profCleanup();
 86.1851 -		return;
 86.1852 -	}
 86.1853 -	if (comment == 0xfb)
 86.1854 -	{
 86.1855 -		profCount();
 86.1856 -		return;
 86.1857 -	}
 86.1858 -#endif
 86.1859 -	if (comment == 0xfa)
 86.1860 -	{
 86.1861 -		agbPrintFlush();
 86.1862 -		return;
 86.1863 -	}
 86.1864 -#ifdef SDL
 86.1865 -	if (comment == 0xf9)
 86.1866 -	{
 86.1867 -		emulating = 0;
 86.1868 -		CPU_BREAK_LOOP_2;
 86.1869 -		return;
 86.1870 -	}
 86.1871 -#endif
 86.1872 -	if (useBios)
 86.1873 -	{
 86.1874 -#ifdef GBA_LOGGING
 86.1875 -		if (systemVerbose & VERBOSE_SWI)
 86.1876 -		{
 86.1877 -			log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment,
 86.1878 -			    armState ? armNextPC - 4 : armNextPC - 2,
 86.1879 -			    reg[0].I,
 86.1880 -			    reg[1].I,
 86.1881 -			    reg[2].I,
 86.1882 -			    VCOUNT);
 86.1883 -		}
 86.1884 -#endif
 86.1885 -		CPUSoftwareInterrupt();
 86.1886 -		return;
 86.1887 -	}
 86.1888 -	// This would be correct, but it causes problems if uncommented
 86.1889 -	//  else {
 86.1890 -	//    biosProtected = 0xe3a02004;
 86.1891 -	//  }
 86.1892 -
 86.1893 -	switch (comment)
 86.1894 -	{
 86.1895 -	case 0x00:
 86.1896 -		BIOS_SoftReset();
 86.1897 -		break;
 86.1898 -	case 0x01:
 86.1899 -		BIOS_RegisterRamReset();
 86.1900 -		break;
 86.1901 -	case 0x02:
 86.1902 -#ifdef GBA_LOGGING
 86.1903 -		if (systemVerbose & VERBOSE_SWI)
 86.1904 -		{
 86.1905 -			log("Halt: (VCOUNT = %2d)\n",
 86.1906 -			    VCOUNT);
 86.1907 -		}
 86.1908 -#endif
 86.1909 -		holdState = true;
 86.1910 -		holdType  = -1;
 86.1911 -		break;
 86.1912 -	case 0x03:
 86.1913 -#ifdef GBA_LOGGING
 86.1914 -		if (systemVerbose & VERBOSE_SWI)
 86.1915 -		{
 86.1916 -			log("Stop: (VCOUNT = %2d)\n",
 86.1917 -			    VCOUNT);
 86.1918 -		}
 86.1919 -#endif
 86.1920 -		holdState = true;
 86.1921 -		holdType  = -1;
 86.1922 -		stopState = true;
 86.1923 -		break;
 86.1924 -	case 0x04:
 86.1925 -#ifdef GBA_LOGGING
 86.1926 -		if (systemVerbose & VERBOSE_SWI)
 86.1927 -		{
 86.1928 -			log("IntrWait: 0x%08x,0x%08x (VCOUNT = %2d)\n",
 86.1929 -			    reg[0].I,
 86.1930 -			    reg[1].I,
 86.1931 -			    VCOUNT);
 86.1932 -		}
 86.1933 -#endif
 86.1934 -		CPUSoftwareInterrupt();
 86.1935 -		break;
 86.1936 -	case 0x05:
 86.1937 -#ifdef GBA_LOGGING
 86.1938 -		if (systemVerbose & VERBOSE_SWI)
 86.1939 -		{
 86.1940 -			log("VBlankIntrWait: (VCOUNT = %2d)\n",
 86.1941 -			    VCOUNT);
 86.1942 -		}
 86.1943 -#endif
 86.1944 -		CPUSoftwareInterrupt();
 86.1945 -		break;
 86.1946 -	case 0x06:
 86.1947 -		CPUSoftwareInterrupt();
 86.1948 -		break;
 86.1949 -	case 0x07:
 86.1950 -		CPUSoftwareInterrupt();
 86.1951 -		break;
 86.1952 -	case 0x08:
 86.1953 -		BIOS_Sqrt();
 86.1954 -		break;
 86.1955 -	case 0x09:
 86.1956 -		BIOS_ArcTan();
 86.1957 -		break;
 86.1958 -	case 0x0A:
 86.1959 -		BIOS_ArcTan2();
 86.1960 -		break;
 86.1961 -	case 0x0B:
 86.1962 -		BIOS_CpuSet();
 86.1963 -		break;
 86.1964 -	case 0x0C:
 86.1965 -		BIOS_CpuFastSet();
 86.1966 -		break;
 86.1967 -	case 0x0E:
 86.1968 -		BIOS_BgAffineSet();
 86.1969 -		break;
 86.1970 -	case 0x0F:
 86.1971 -		BIOS_ObjAffineSet();
 86.1972 -		break;
 86.1973 -	case 0x10:
 86.1974 -		BIOS_BitUnPack();
 86.1975 -		break;
 86.1976 -	case 0x11:
 86.1977 -		BIOS_LZ77UnCompWram();
 86.1978 -		break;
 86.1979 -	case 0x12:
 86.1980 -		BIOS_LZ77UnCompVram();
 86.1981 -		break;
 86.1982 -	case 0x13:
 86.1983 -		BIOS_HuffUnComp();
 86.1984 -		break;
 86.1985 -	case 0x14:
 86.1986 -		BIOS_RLUnCompWram();
 86.1987 -		break;
 86.1988 -	case 0x15:
 86.1989 -		BIOS_RLUnCompVram();
 86.1990 -		break;
 86.1991 -	case 0x16:
 86.1992 -		BIOS_Diff8bitUnFilterWram();
 86.1993 -		break;
 86.1994 -	case 0x17:
 86.1995 -		BIOS_Diff8bitUnFilterVram();
 86.1996 -		break;
 86.1997 -	case 0x18:
 86.1998 -		BIOS_Diff16bitUnFilter();
 86.1999 -		break;
 86.2000 -	case 0x19:
 86.2001 -#ifdef GBA_LOGGING
 86.2002 -		if (systemVerbose & VERBOSE_SWI)
 86.2003 -		{
 86.2004 -			log("SoundBiasSet: 0x%08x (VCOUNT = %2d)\n",
 86.2005 -			    reg[0].I,
 86.2006 -			    VCOUNT);
 86.2007 -		}
 86.2008 -#endif
 86.2009 -		if (reg[0].I)
 86.2010 -			soundPause();
 86.2011 -		else
 86.2012 -			soundResume();
 86.2013 -		break;
 86.2014 -	case 0x1F:
 86.2015 -		BIOS_MidiKey2Freq();
 86.2016 -		break;
 86.2017 -	case 0x2A:
 86.2018 -		BIOS_SndDriverJmpTableCopy();
 86.2019 -	// let it go, because we don't really emulate this function // FIXME (?)
 86.2020 -	default:
 86.2021 -#ifdef GBA_LOGGING
 86.2022 -		if (systemVerbose & VERBOSE_SWI)
 86.2023 -		{
 86.2024 -			log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment,
 86.2025 -			    armState ? armNextPC - 4 : armNextPC - 2,
 86.2026 -			    reg[0].I,
 86.2027 -			    reg[1].I,
 86.2028 -			    reg[2].I,
 86.2029 -			    VCOUNT);
 86.2030 -		}
 86.2031 -#endif
 86.2032 -
 86.2033 -		if (!disableMessage)
 86.2034 -		{
 86.2035 -			systemMessage(MSG_UNSUPPORTED_BIOS_FUNCTION,
 86.2036 -			              N_(
 86.2037 -			                  "Unsupported BIOS function %02x called from %08x. A BIOS file is needed in order to get correct behaviour."),
 86.2038 -			              comment,
 86.2039 -			              armMode ? armNextPC - 4 : armNextPC - 2);
 86.2040 -			disableMessage = true;
 86.2041 -		}
 86.2042 -		break;
 86.2043 -	}
 86.2044 -}
 86.2045 -
 86.2046 -void CPUCompareVCOUNT()
 86.2047 -{
 86.2048 -	if (VCOUNT == (DISPSTAT >> 8))
 86.2049 -	{
 86.2050 -		DISPSTAT |= 4;
 86.2051 -		UPDATE_REG(0x04, DISPSTAT);
 86.2052 -
 86.2053 -		if (DISPSTAT & 0x20)
 86.2054 -		{
 86.2055 -			IF |= 4;
 86.2056 -			UPDATE_REG(0x202, IF);
 86.2057 -		}
 86.2058 -	}
 86.2059 -	else
 86.2060 -	{
 86.2061 -		DISPSTAT &= 0xFFFB;
 86.2062 -		UPDATE_REG(0x4, DISPSTAT);
 86.2063 -	}
 86.2064 -}
 86.2065 -
 86.2066 -void doDMA(u32 &s, u32 &d, u32 si, u32 di, u32 c, int transfer32)
 86.2067 -{
 86.2068 -	int sm = s >> 24;
 86.2069 -	int dm = d >> 24;
 86.2070 -
 86.2071 -	int sc = c;
 86.2072 -
 86.2073 -	cpuDmaCount = c;
 86.2074 -
 86.2075 -	if (transfer32)
 86.2076 -	{
 86.2077 -		s &= 0xFFFFFFFC;
 86.2078 -		if (s < 0x02000000 && (reg[15].I >> 24))
 86.2079 -		{
 86.2080 -			while (c != 0)
 86.2081 -			{
 86.2082 -				CPUWriteMemory(d, 0);
 86.2083 -				d += di;
 86.2084 -				c--;
 86.2085 -			}
 86.2086 -		}
 86.2087 -		else
 86.2088 -		{
 86.2089 -			while (c != 0)
 86.2090 -			{
 86.2091 -				CPUWriteMemory(d, CPUReadMemory(s));
 86.2092 -				d += di;
 86.2093 -				s += si;
 86.2094 -				c--;
 86.2095 -			}
 86.2096 -		}
 86.2097 -	}
 86.2098 -	else
 86.2099 -	{
 86.2100 -		s &= 0xFFFFFFFE;
 86.2101 -		si = (int)si >> 1;
 86.2102 -		di = (int)di >> 1;
 86.2103 -		if (s < 0x02000000 && (reg[15].I >> 24))
 86.2104 -		{
 86.2105 -			while (c != 0)
 86.2106 -			{
 86.2107 -				CPUWriteHalfWord(d, 0);
 86.2108 -				d += di;
 86.2109 -				c--;
 86.2110 -			}
 86.2111 -		}
 86.2112 -		else
 86.2113 -		{
 86.2114 -			while (c != 0)
 86.2115 -			{
 86.2116 -				cpuDmaLast = CPUReadHalfWord(s);
 86.2117 -				CPUWriteHalfWord(d, cpuDmaLast);
 86.2118 -				d += di;
 86.2119 -				s += si;
 86.2120 -				c--;
 86.2121 -			}
 86.2122 -		}
 86.2123 -	}
 86.2124 -
 86.2125 -	cpuDmaCount = 0;
 86.2126 -
 86.2127 -	int sw = 1 + memoryWaitSeq[sm & 15];
 86.2128 -	int dw = 1 + memoryWaitSeq[dm & 15];
 86.2129 -
 86.2130 -	int totalTicks = 0;
 86.2131 -
 86.2132 -	if (transfer32)
 86.2133 -	{
 86.2134 -		if (!memory32[sm & 15])
 86.2135 -			sw <<= 1;
 86.2136 -		if (!memory32[dm & 15])
 86.2137 -			dw <<= 1;
 86.2138 -	}
 86.2139 -
 86.2140 -	totalTicks = (sw + dw) * sc;
 86.2141 -
 86.2142 -	cpuDmaTicksToUpdate += totalTicks;
 86.2143 -
 86.2144 -	if (*extCpuLoopTicks >= 0)
 86.2145 -	{
 86.2146 -		CPU_BREAK_LOOP;
 86.2147 -	}
 86.2148 -}
 86.2149 -
 86.2150 -void CPUCheckDMA(int reason, int dmamask)
 86.2151 -{
 86.2152 -	cpuDmaHack = 0;
 86.2153 -	// DMA 0
 86.2154 -	if ((DM0CNT_H & 0x8000) && (dmamask & 1))
 86.2155 -	{
 86.2156 -		if (((DM0CNT_H >> 12) & 3) == reason)
 86.2157 -		{
 86.2158 -			u32 sourceIncrement = 4;
 86.2159 -			u32 destIncrement	= 4;
 86.2160 -			switch ((DM0CNT_H >> 7) & 3)
 86.2161 -			{
 86.2162 -			case 0:
 86.2163 -				break;
 86.2164 -			case 1:
 86.2165 -				sourceIncrement = (u32) - 4;
 86.2166 -				break;
 86.2167 -			case 2:
 86.2168 -				sourceIncrement = 0;
 86.2169 -				break;
 86.2170 -			}
 86.2171 -			switch ((DM0CNT_H >> 5) & 3)
 86.2172 -			{
 86.2173 -			case 0:
 86.2174 -				break;
 86.2175 -			case 1:
 86.2176 -				destIncrement = (u32) - 4;
 86.2177 -				break;
 86.2178 -			case 2:
 86.2179 -				destIncrement = 0;
 86.2180 -				break;
 86.2181 -			}
 86.2182 -#ifdef GBA_LOGGING
 86.2183 -			if (systemVerbose & VERBOSE_DMA0)
 86.2184 -			{
 86.2185 -				int count = (DM0CNT_L ? DM0CNT_L : 0x4000) << 1;
 86.2186 -				if (DM0CNT_H & 0x0400)
 86.2187 -					count <<= 1;
 86.2188 -				log("DMA0: s=%08x d=%08x c=%04x count=%08x\n", dma0Source, dma0Dest,
 86.2189 -				    DM0CNT_H,
 86.2190 -				    count);
 86.2191 -			}
 86.2192 -#endif
 86.2193 -			doDMA(dma0Source, dma0Dest, sourceIncrement, destIncrement,
 86.2194 -			      DM0CNT_L ? DM0CNT_L : 0x4000,
 86.2195 -			      DM0CNT_H & 0x0400);
 86.2196 -			cpuDmaHack = 1;
 86.2197 -			if (DM0CNT_H & 0x4000)
 86.2198 -			{
 86.2199 -				IF |= 0x0100;
 86.2200 -				UPDATE_REG(0x202, IF);
 86.2201 -			}
 86.2202 -
 86.2203 -			if (((DM0CNT_H >> 5) & 3) == 3)
 86.2204 -			{
 86.2205 -				dma0Dest = DM0DAD_L | (DM0DAD_H << 16);
 86.2206 -			}
 86.2207 -
 86.2208 -			if (!(DM0CNT_H & 0x0200) || (reason == 0))
 86.2209 -			{
 86.2210 -				DM0CNT_H &= 0x7FFF;
 86.2211 -				UPDATE_REG(0xBA, DM0CNT_H);
 86.2212 -			}
 86.2213 -		}
 86.2214 -	}
 86.2215 -
 86.2216 -	// DMA 1
 86.2217 -	if ((DM1CNT_H & 0x8000) && (dmamask & 2))
 86.2218 -	{
 86.2219 -		if (((DM1CNT_H >> 12) & 3) == reason)
 86.2220 -		{
 86.2221 -			u32 sourceIncrement = 4;
 86.2222 -			u32 destIncrement	= 4;
 86.2223 -			switch ((DM1CNT_H >> 7) & 3)
 86.2224 -			{
 86.2225 -			case 0:
 86.2226 -				break;
 86.2227 -			case 1:
 86.2228 -				sourceIncrement = (u32) - 4;
 86.2229 -				break;
 86.2230 -			case 2:
 86.2231 -				sourceIncrement = 0;
 86.2232 -				break;
 86.2233 -			}
 86.2234 -			switch ((DM1CNT_H >> 5) & 3)
 86.2235 -			{
 86.2236 -			case 0:
 86.2237 -				break;
 86.2238 -			case 1:
 86.2239 -				destIncrement = (u32) - 4;
 86.2240 -				break;
 86.2241 -			case 2:
 86.2242 -				destIncrement = 0;
 86.2243 -				break;
 86.2244 -			}
 86.2245 -			if (reason == 3)
 86.2246 -			{
 86.2247 -#ifdef GBA_LOGGING
 86.2248 -				if (systemVerbose & VERBOSE_DMA1)
 86.2249 -				{
 86.2250 -					log("DMA1: s=%08x d=%08x c=%04x count=%08x\n", dma1Source, dma1Dest,
 86.2251 -					    DM1CNT_H,
 86.2252 -					    16);
 86.2253 -				}
 86.2254 -#endif
 86.2255 -				doDMA(dma1Source, dma1Dest, sourceIncrement, 0, 4,
 86.2256 -				      0x0400);
 86.2257 -			}
 86.2258 -			else
 86.2259 -			{
 86.2260 -#ifdef GBA_LOGGING
 86.2261 -				if (systemVerbose & VERBOSE_DMA1)
 86.2262 -				{
 86.2263 -					int count = (DM1CNT_L ? DM1CNT_L : 0x4000) << 1;
 86.2264 -					if (DM1CNT_H & 0x0400)
 86.2265 -						count <<= 1;
 86.2266 -					log("DMA1: s=%08x d=%08x c=%04x count=%08x\n", dma1Source, dma1Dest,
 86.2267 -					    DM1CNT_H,
 86.2268 -					    count);
 86.2269 -				}
 86.2270 -#endif
 86.2271 -				doDMA(dma1Source, dma1Dest, sourceIncrement, destIncrement,
 86.2272 -				      DM1CNT_L ? DM1CNT_L : 0x4000,
 86.2273 -				      DM1CNT_H & 0x0400);
 86.2274 -			}
 86.2275 -			cpuDmaHack = 1;
 86.2276 -
 86.2277 -			if (DM1CNT_H & 0x4000)
 86.2278 -			{
 86.2279 -				IF |= 0x0200;
 86.2280 -				UPDATE_REG(0x202, IF);
 86.2281 -			}
 86.2282 -
 86.2283 -			if (((DM1CNT_H >> 5) & 3) == 3)
 86.2284 -			{
 86.2285 -				dma1Dest = DM1DAD_L | (DM1DAD_H << 16);
 86.2286 -			}
 86.2287 -
 86.2288 -			if (!(DM1CNT_H & 0x0200) || (reason == 0))
 86.2289 -			{
 86.2290 -				DM1CNT_H &= 0x7FFF;
 86.2291 -				UPDATE_REG(0xC6, DM1CNT_H);
 86.2292 -			}
 86.2293 -		}
 86.2294 -	}
 86.2295 -
 86.2296 -	// DMA 2
 86.2297 -	if ((DM2CNT_H & 0x8000) && (dmamask & 4))
 86.2298 -	{
 86.2299 -		if (((DM2CNT_H >> 12) & 3) == reason)
 86.2300 -		{
 86.2301 -			u32 sourceIncrement = 4;
 86.2302 -			u32 destIncrement	= 4;
 86.2303 -			switch ((DM2CNT_H >> 7) & 3)
 86.2304 -			{
 86.2305 -			case 0:
 86.2306 -				break;
 86.2307 -			case 1:
 86.2308 -				sourceIncrement = (u32) - 4;
 86.2309 -				break;
 86.2310 -			case 2:
 86.2311 -				sourceIncrement = 0;
 86.2312 -				break;
 86.2313 -			}
 86.2314 -			switch ((DM2CNT_H >> 5) & 3)
 86.2315 -			{
 86.2316 -			case 0:
 86.2317 -				break;
 86.2318 -			case 1:
 86.2319 -				destIncrement = (u32) - 4;
 86.2320 -				break;
 86.2321 -			case 2:
 86.2322 -				destIncrement = 0;
 86.2323 -				break;
 86.2324 -			}
 86.2325 -			if (reason == 3)
 86.2326 -			{
 86.2327 -#ifdef GBA_LOGGING
 86.2328 -				if (systemVerbose & VERBOSE_DMA2)
 86.2329 -				{
 86.2330 -					int count = (4) << 2;
 86.2331 -					log("DMA2: s=%08x d=%08x c=%04x count=%08x\n", dma2Source, dma2Dest,
 86.2332 -					    DM2CNT_H,
 86.2333 -					    count);
 86.2334 -				}
 86.2335 -#endif
 86.2336 -				doDMA(dma2Source, dma2Dest, sourceIncrement, 0, 4,
 86.2337 -				      0x0400);
 86.2338 -			}
 86.2339 -			else
 86.2340 -			{
 86.2341 -#ifdef GBA_LOGGING
 86.2342 -				if (systemVerbose & VERBOSE_DMA2)
 86.2343 -				{
 86.2344 -					int count = (DM2CNT_L ? DM2CNT_L : 0x4000) << 1;
 86.2345 -					if (DM2CNT_H & 0x0400)
 86.2346 -						count <<= 1;
 86.2347 -					log("DMA2: s=%08x d=%08x c=%04x count=%08x\n", dma2Source, dma2Dest,
 86.2348 -					    DM2CNT_H,
 86.2349 -					    count);
 86.2350 -				}
 86.2351 -#endif
 86.2352 -				doDMA(dma2Source, dma2Dest, sourceIncrement, destIncrement,
 86.2353 -				      DM2CNT_L ? DM2CNT_L : 0x4000,
 86.2354 -				      DM2CNT_H & 0x0400);
 86.2355 -			}
 86.2356 -			cpuDmaHack = 1;
 86.2357 -			if (DM2CNT_H & 0x4000)
 86.2358 -			{
 86.2359 -				IF |= 0x0400;
 86.2360 -				UPDATE_REG(0x202, IF);
 86.2361 -			}
 86.2362 -
 86.2363 -			if (((DM2CNT_H >> 5) & 3) == 3)
 86.2364 -			{
 86.2365 -				dma2Dest = DM2DAD_L | (DM2DAD_H << 16);
 86.2366 -			}
 86.2367 -
 86.2368 -			if (!(DM2CNT_H & 0x0200) || (reason == 0))
 86.2369 -			{
 86.2370 -				DM2CNT_H &= 0x7FFF;
 86.2371 -				UPDATE_REG(0xD2, DM2CNT_H);
 86.2372 -			}
 86.2373 -		}
 86.2374 -	}
 86.2375 -
 86.2376 -	// DMA 3
 86.2377 -	if ((DM3CNT_H & 0x8000) && (dmamask & 8))
 86.2378 -	{
 86.2379 -		if (((DM3CNT_H >> 12) & 3) == reason)
 86.2380 -		{
 86.2381 -			u32 sourceIncrement = 4;
 86.2382 -			u32 destIncrement	= 4;
 86.2383 -			switch ((DM3CNT_H >> 7) & 3)
 86.2384 -			{
 86.2385 -			case 0:
 86.2386 -				break;
 86.2387 -			case 1:
 86.2388 -				sourceIncrement = (u32) - 4;
 86.2389 -				break;
 86.2390 -			case 2:
 86.2391 -				sourceIncrement = 0;
 86.2392 -				break;
 86.2393 -			}
 86.2394 -			switch ((DM3CNT_H >> 5) & 3)
 86.2395 -			{
 86.2396 -			case 0:
 86.2397 -				break;
 86.2398 -			case 1:
 86.2399 -				destIncrement = (u32) - 4;
 86.2400 -				break;
 86.2401 -			case 2:
 86.2402 -				destIncrement = 0;
 86.2403 -				break;
 86.2404 -			}
 86.2405 -#ifdef GBA_LOGGING
 86.2406 -			if (systemVerbose & VERBOSE_DMA3)
 86.2407 -			{
 86.2408 -				int count = (DM3CNT_L ? DM3CNT_L : 0x10000) << 1;
 86.2409 -				if (DM3CNT_H & 0x0400)
 86.2410 -					count <<= 1;
 86.2411 -				log("DMA3: s=%08x d=%08x c=%04x count=%08x\n", dma3Source, dma3Dest,
 86.2412 -				    DM3CNT_H,
 86.2413 -				    count);
 86.2414 -			}
 86.2415 -#endif
 86.2416 -			doDMA(dma3Source, dma3Dest, sourceIncrement, destIncrement,
 86.2417 -			      DM3CNT_L ? DM3CNT_L : 0x10000,
 86.2418 -			      DM3CNT_H & 0x0400);
 86.2419 -			if (DM3CNT_H & 0x4000)
 86.2420 -			{
 86.2421 -				IF |= 0x0800;
 86.2422 -				UPDATE_REG(0x202, IF);
 86.2423 -			}
 86.2424 -
 86.2425 -			if (((DM3CNT_H >> 5) & 3) == 3)
 86.2426 -			{
 86.2427 -				dma3Dest = DM3DAD_L | (DM3DAD_H << 16);
 86.2428 -			}
 86.2429 -
 86.2430 -			if (!(DM3CNT_H & 0x0200) || (reason == 0))
 86.2431 -			{
 86.2432 -				DM3CNT_H &= 0x7FFF;
 86.2433 -				UPDATE_REG(0xDE, DM3CNT_H);
 86.2434 -			}
 86.2435 -		}
 86.2436 -	}
 86.2437 -	cpuDmaHack = 0;
 86.2438 -}
 86.2439 -
 86.2440 -void CPUUpdateRegister(u32 address, u16 value)
 86.2441 -{
 86.2442 -	switch (address)
 86.2443 -	{
 86.2444 -	case 0x00:
 86.2445 -	{
 86.2446 -		bool change	  = ((DISPCNT ^ value) & 0x80) ? true : false;
 86.2447 -		bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false;
 86.2448 -		DISPCNT = (value & 0xFFF7);
 86.2449 -		UPDATE_REG(0x00, DISPCNT);
 86.2450 -		layerEnable = layerSettings & value;
 86.2451 -		windowOn	= (layerEnable & 0x6000) ? true : false;
 86.2452 -		if (change && !((value & 0x80)))
 86.2453 -		{
 86.2454 -			if (!(DISPSTAT & 1))
 86.2455 -			{
 86.2456 -				lcdTicks = 960;
 86.2457 -				//      VCOUNT = 0;
 86.2458 -				//      UPDATE_REG(0x06, VCOUNT);
 86.2459 -				DISPSTAT &= 0xFFFC;
 86.2460 -				UPDATE_REG(0x04, DISPSTAT);
 86.2461 -				CPUCompareVCOUNT();
 86.2462 -			}
 86.2463 -			//        (*renderLine)();
 86.2464 -		}
 86.2465 -		CPUUpdateRender();
 86.2466 -		// we only care about changes in BG0-BG3
 86.2467 -		if (changeBG)
 86.2468 -			CPUUpdateRenderBuffers(false);
 86.2469 -		//      CPUUpdateTicks();
 86.2470 -		break;
 86.2471 -	}
 86.2472 -	case 0x04:
 86.2473 -		DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7);
 86.2474 -		UPDATE_REG(0x04, DISPSTAT);
 86.2475 -		break;
 86.2476 -	case 0x06:
 86.2477 -		// not writable
 86.2478 -		break;
 86.2479 -	case 0x08:
 86.2480 -		BG0CNT = (value & 0xDFCF);
 86.2481 -		UPDATE_REG(0x08, BG0CNT);
 86.2482 -		break;
 86.2483 -	case 0x0A:
 86.2484 -		BG1CNT = (value & 0xDFCF);
 86.2485 -		UPDATE_REG(0x0A, BG1CNT);
 86.2486 -		break;
 86.2487 -	case 0x0C:
 86.2488 -		BG2CNT = (value & 0xFFCF);
 86.2489 -		UPDATE_REG(0x0C, BG2CNT);
 86.2490 -		break;
 86.2491 -	case 0x0E:
 86.2492 -		BG3CNT = (value & 0xFFCF);
 86.2493 -		UPDATE_REG(0x0E, BG3CNT);
 86.2494 -		break;
 86.2495 -	case 0x10:
 86.2496 -		BG0HOFS = value & 511;
 86.2497 -		UPDATE_REG(0x10, BG0HOFS);
 86.2498 -		break;
 86.2499 -	case 0x12:
 86.2500 -		BG0VOFS = value & 511;
 86.2501 -		UPDATE_REG(0x12, BG0VOFS);
 86.2502 -		break;
 86.2503 -	case 0x14:
 86.2504 -		BG1HOFS = value & 511;
 86.2505 -		UPDATE_REG(0x14, BG1HOFS);
 86.2506 -		break;
 86.2507 -	case 0x16:
 86.2508 -		BG1VOFS = value & 511;
 86.2509 -		UPDATE_REG(0x16, BG1VOFS);
 86.2510 -		break;
 86.2511 -	case 0x18:
 86.2512 -		BG2HOFS = value & 511;
 86.2513 -		UPDATE_REG(0x18, BG2HOFS);
 86.2514 -		break;
 86.2515 -	case 0x1A:
 86.2516 -		BG2VOFS = value & 511;
 86.2517 -		UPDATE_REG(0x1A, BG2VOFS);
 86.2518 -		break;
 86.2519 -	case 0x1C:
 86.2520 -		BG3HOFS = value & 511;
 86.2521 -		UPDATE_REG(0x1C, BG3HOFS);
 86.2522 -		break;
 86.2523 -	case 0x1E:
 86.2524 -		BG3VOFS = value & 511;
 86.2525 -		UPDATE_REG(0x1E, BG3VOFS);
 86.2526 -		break;
 86.2527 -	case 0x20:
 86.2528 -		BG2PA = value;
 86.2529 -		UPDATE_REG(0x20, BG2PA);
 86.2530 -		break;
 86.2531 -	case 0x22:
 86.2532 -		BG2PB = value;
 86.2533 -		UPDATE_REG(0x22, BG2PB);
 86.2534 -		break;
 86.2535 -	case 0x24:
 86.2536 -		BG2PC = value;
 86.2537 -		UPDATE_REG(0x24, BG2PC);
 86.2538 -		break;
 86.2539 -	case 0x26:
 86.2540 -		BG2PD = value;
 86.2541 -		UPDATE_REG(0x26, BG2PD);
 86.2542 -		break;
 86.2543 -	case 0x28:
 86.2544 -		BG2X_L = value;
 86.2545 -		UPDATE_REG(0x28, BG2X_L);
 86.2546 -		gfxBG2Changed |= 1;
 86.2547 -		break;
 86.2548 -	case 0x2A:
 86.2549 -		BG2X_H = (value & 0xFFF);
 86.2550 -		UPDATE_REG(0x2A, BG2X_H);
 86.2551 -		gfxBG2Changed |= 1;
 86.2552 -		break;
 86.2553 -	case 0x2C:
 86.2554 -		BG2Y_L = value;
 86.2555 -		UPDATE_REG(0x2C, BG2Y_L);
 86.2556 -		gfxBG2Changed |= 2;
 86.2557 -		break;
 86.2558 -	case 0x2E:
 86.2559 -		BG2Y_H = value & 0xFFF;
 86.2560 -		UPDATE_REG(0x2E, BG2Y_H);
 86.2561 -		gfxBG2Changed |= 2;
 86.2562 -		break;
 86.2563 -	case 0x30:
 86.2564 -		BG3PA = value;
 86.2565 -		UPDATE_REG(0x30, BG3PA);
 86.2566 -		break;
 86.2567 -	case 0x32:
 86.2568 -		BG3PB = value;
 86.2569 -		UPDATE_REG(0x32, BG3PB);
 86.2570 -		break;
 86.2571 -	case 0x34:
 86.2572 -		BG3PC = value;
 86.2573 -		UPDATE_REG(0x34, BG3PC);
 86.2574 -		break;
 86.2575 -	case 0x36:
 86.2576 -		BG3PD = value;
 86.2577 -		UPDATE_REG(0x36, BG3PD);
 86.2578 -		break;
 86.2579 -	case 0x38:
 86.2580 -		BG3X_L = value;
 86.2581 -		UPDATE_REG(0x38, BG3X_L);
 86.2582 -		gfxBG3Changed |= 1;
 86.2583 -		break;
 86.2584 -	case 0x3A:
 86.2585 -		BG3X_H = value & 0xFFF;
 86.2586 -		UPDATE_REG(0x3A, BG3X_H);
 86.2587 -		gfxBG3Changed |= 1;
 86.2588 -		break;
 86.2589 -	case 0x3C:
 86.2590 -		BG3Y_L = value;
 86.2591 -		UPDATE_REG(0x3C, BG3Y_L);
 86.2592 -		gfxBG3Changed |= 2;
 86.2593 -		break;
 86.2594 -	case 0x3E:
 86.2595 -		BG3Y_H = value & 0xFFF;
 86.2596 -		UPDATE_REG(0x3E, BG3Y_H);
 86.2597 -		gfxBG3Changed |= 2;
 86.2598 -		break;
 86.2599 -	case 0x40:
 86.2600 -		WIN0H = value;
 86.2601 -		UPDATE_REG(0x40, WIN0H);
 86.2602 -		CPUUpdateWindow0();
 86.2603 -		break;
 86.2604 -	case 0x42:
 86.2605 -		WIN1H = value;
 86.2606 -		UPDATE_REG(0x42, WIN1H);
 86.2607 -		CPUUpdateWindow1();
 86.2608 -		break;
 86.2609 -	case 0x44:
 86.2610 -		WIN0V = value;
 86.2611 -		UPDATE_REG(0x44, WIN0V);
 86.2612 -		break;
 86.2613 -	case 0x46:
 86.2614 -		WIN1V = value;
 86.2615 -		UPDATE_REG(0x46, WIN1V);
 86.2616 -		break;
 86.2617 -	case 0x48:
 86.2618 -		WININ = value & 0x3F3F;
 86.2619 -		UPDATE_REG(0x48, WININ);
 86.2620 -		break;
 86.2621 -	case 0x4A:
 86.2622 -		WINOUT = value & 0x3F3F;
 86.2623 -		UPDATE_REG(0x4A, WINOUT);
 86.2624 -		break;
 86.2625 -	case 0x4C:
 86.2626 -		MOSAIC = value;
 86.2627 -		UPDATE_REG(0x4C, MOSAIC);
 86.2628 -		break;
 86.2629 -	case 0x50:
 86.2630 -		BLDMOD = value & 0x3FFF;
 86.2631 -		UPDATE_REG(0x50, BLDMOD);
 86.2632 -		fxOn = ((BLDMOD >> 6) & 3) != 0;
 86.2633 -		CPUUpdateRender();
 86.2634 -		break;
 86.2635 -	case 0x52:
 86.2636 -		COLEV = value & 0x1F1F;
 86.2637 -		UPDATE_REG(0x52, COLEV);
 86.2638 -		break;
 86.2639 -	case 0x54:
 86.2640 -		COLY = value & 0x1F;
 86.2641 -		UPDATE_REG(0x54, COLY);
 86.2642 -		break;
 86.2643 -	case 0x60:
 86.2644 -	case 0x62:
 86.2645 -	case 0x64:
 86.2646 -	case 0x68:
 86.2647 -	case 0x6c:
 86.2648 -	case 0x70:
 86.2649 -	case 0x72:
 86.2650 -	case 0x74:
 86.2651 -	case 0x78:
 86.2652 -	case 0x7c:
 86.2653 -	case 0x80:
 86.2654 -	case 0x84:
 86.2655 -		soundEvent(address & 0xFF, (u8)(value & 0xFF));
 86.2656 -		soundEvent((address & 0xFF) + 1, (u8)(value >> 8));
 86.2657 -		break;
 86.2658 -	case 0x82:
 86.2659 -	case 0x88:
 86.2660 -	case 0xa0:
 86.2661 -	case 0xa2:
 86.2662 -	case 0xa4:
 86.2663 -	case 0xa6:
 86.2664 -	case 0x90:
 86.2665 -	case 0x92:
 86.2666 -	case 0x94:
 86.2667 -	case 0x96:
 86.2668 -	case 0x98:
 86.2669 -	case 0x9a:
 86.2670 -	case 0x9c:
 86.2671 -	case 0x9e:
 86.2672 -		soundEvent(address & 0xFF, value);
 86.2673 -		break;
 86.2674 -	case 0xB0:
 86.2675 -		DM0SAD_L = value;
 86.2676 -		UPDATE_REG(0xB0, DM0SAD_L);
 86.2677 -		break;
 86.2678 -	case 0xB2:
 86.2679 -		DM0SAD_H = value & 0x07FF;
 86.2680 -		UPDATE_REG(0xB2, DM0SAD_H);
 86.2681 -		break;
 86.2682 -	case 0xB4:
 86.2683 -		DM0DAD_L = value;
 86.2684 -		UPDATE_REG(0xB4, DM0DAD_L);
 86.2685 -		break;
 86.2686 -	case 0xB6:
 86.2687 -		DM0DAD_H = value & 0x07FF;
 86.2688 -		UPDATE_REG(0xB6, DM0DAD_H);
 86.2689 -		break;
 86.2690 -	case 0xB8:
 86.2691 -		DM0CNT_L = value & 0x3FFF;
 86.2692 -		UPDATE_REG(0xB8, 0);
 86.2693 -		break;
 86.2694 -	case 0xBA:
 86.2695 -	{
 86.2696 -		bool start = ((DM0CNT_H ^ value) & 0x8000) ? true : false;
 86.2697 -		value &= 0xF7E0;
 86.2698 -
 86.2699 -		DM0CNT_H = value;
 86.2700 -		UPDATE_REG(0xBA, DM0CNT_H);
 86.2701 -
 86.2702 -		if (start && (value & 0x8000))
 86.2703 -		{
 86.2704 -			dma0Source = DM0SAD_L | (DM0SAD_H << 16);
 86.2705 -			dma0Dest   = DM0DAD_L | (DM0DAD_H << 16);
 86.2706 -			CPUCheckDMA(0, 1);
 86.2707 -		}
 86.2708 -		break;
 86.2709 -	}
 86.2710 -	case 0xBC:
 86.2711 -		DM1SAD_L = value;
 86.2712 -		UPDATE_REG(0xBC, DM1SAD_L);
 86.2713 -		break;
 86.2714 -	case 0xBE:
 86.2715 -		DM1SAD_H = value & 0x0FFF;
 86.2716 -		UPDATE_REG(0xBE, DM1SAD_H);
 86.2717 -		break;
 86.2718 -	case 0xC0:
 86.2719 -		DM1DAD_L = value;
 86.2720 -		UPDATE_REG(0xC0, DM1DAD_L);
 86.2721 -		break;
 86.2722 -	case 0xC2:
 86.2723 -		DM1DAD_H = value & 0x07FF;
 86.2724 -		UPDATE_REG(0xC2, DM1DAD_H);
 86.2725 -		break;
 86.2726 -	case 0xC4:
 86.2727 -		DM1CNT_L = value & 0x3FFF;
 86.2728 -		UPDATE_REG(0xC4, 0);
 86.2729 -		break;
 86.2730 -	case 0xC6:
 86.2731 -	{
 86.2732 -		bool start = ((DM1CNT_H ^ value) & 0x8000) ? true : false;
 86.2733 -		value &= 0xF7E0;
 86.2734 -
 86.2735 -		DM1CNT_H = value;
 86.2736 -		UPDATE_REG(0xC6, DM1CNT_H);
 86.2737 -
 86.2738 -		if (start && (value & 0x8000))
 86.2739 -		{
 86.2740 -			dma1Source = DM1SAD_L | (DM1SAD_H << 16);
 86.2741 -			dma1Dest   = DM1DAD_L | (DM1DAD_H << 16);
 86.2742 -			CPUCheckDMA(0, 2);
 86.2743 -		}
 86.2744 -		break;
 86.2745 -	}
 86.2746 -	case 0xC8:
 86.2747 -		DM2SAD_L = value;
 86.2748 -		UPDATE_REG(0xC8, DM2SAD_L);
 86.2749 -		break;
 86.2750 -	case 0xCA:
 86.2751 -		DM2SAD_H = value & 0x0FFF;
 86.2752 -		UPDATE_REG(0xCA, DM2SAD_H);
 86.2753 -		break;
 86.2754 -	case 0xCC:
 86.2755 -		DM2DAD_L = value;
 86.2756 -		UPDATE_REG(0xCC, DM2DAD_L);
 86.2757 -		break;
 86.2758 -	case 0xCE:
 86.2759 -		DM2DAD_H = value & 0x07FF;
 86.2760 -		UPDATE_REG(0xCE, DM2DAD_H);
 86.2761 -		break;
 86.2762 -	case 0xD0:
 86.2763 -		DM2CNT_L = value & 0x3FFF;
 86.2764 -		UPDATE_REG(0xD0, 0);
 86.2765 -		break;
 86.2766 -	case 0xD2:
 86.2767 -	{
 86.2768 -		bool start = ((DM2CNT_H ^ value) & 0x8000) ? true : false;
 86.2769 -
 86.2770 -		value &= 0xF7E0;
 86.2771 -
 86.2772 -		DM2CNT_H = value;
 86.2773 -		UPDATE_REG(0xD2, DM2CNT_H);
 86.2774 -
 86.2775 -		if (start && (value & 0x8000))
 86.2776 -		{
 86.2777 -			dma2Source = DM2SAD_L | (DM2SAD_H << 16);
 86.2778 -			dma2Dest   = DM2DAD_L | (DM2DAD_H << 16);
 86.2779 -
 86.2780 -			CPUCheckDMA(0, 4);
 86.2781 -		}
 86.2782 -		break;
 86.2783 -	}
 86.2784 -	case 0xD4:
 86.2785 -		DM3SAD_L = value;
 86.2786 -		UPDATE_REG(0xD4, DM3SAD_L);
 86.2787 -		break;
 86.2788 -	case 0xD6:
 86.2789 -		DM3SAD_H = value & 0x0FFF;
 86.2790 -		UPDATE_REG(0xD6, DM3SAD_H);
 86.2791 -		break;
 86.2792 -	case 0xD8:
 86.2793 -		DM3DAD_L = value;
 86.2794 -		UPDATE_REG(0xD8, DM3DAD_L);
 86.2795 -		break;
 86.2796 -	case 0xDA:
 86.2797 -		DM3DAD_H = value & 0x0FFF;
 86.2798 -		UPDATE_REG(0xDA, DM3DAD_H);
 86.2799 -		break;
 86.2800 -	case 0xDC:
 86.2801 -		DM3CNT_L = value;
 86.2802 -		UPDATE_REG(0xDC, 0);
 86.2803 -		break;
 86.2804 -	case 0xDE:
 86.2805 -	{
 86.2806 -		bool start = ((DM3CNT_H ^ value) & 0x8000) ? true : false;
 86.2807 -
 86.2808 -		value &= 0xFFE0;
 86.2809 -
 86.2810 -		DM3CNT_H = value;
 86.2811 -		UPDATE_REG(0xDE, DM3CNT_H);
 86.2812 -
 86.2813 -		if (start && (value & 0x8000))
 86.2814 -		{
 86.2815 -			dma3Source = DM3SAD_L | (DM3SAD_H << 16);
 86.2816 -			dma3Dest   = DM3DAD_L | (DM3DAD_H << 16);
 86.2817 -			CPUCheckDMA(0, 8);
 86.2818 -		}
 86.2819 -		break;
 86.2820 -	}
 86.2821 -	case 0x100:
 86.2822 -		timer0Reload = value;
 86.2823 -		break;
 86.2824 -	case 0x102:
 86.2825 -		timer0Ticks = timer0ClockReload = TIMER_TICKS[value & 3];
 86.2826 -		if (!timer0On && (value & 0x80))
 86.2827 -		{
 86.2828 -			// reload the counter
 86.2829 -			TM0D = timer0Reload;
 86.2830 -			if (timer0ClockReload == 1)
 86.2831 -				timer0Ticks = 0x10000 - TM0D;
 86.2832 -			UPDATE_REG(0x100, TM0D);
 86.2833 -		}
 86.2834 -		timer0On = value & 0x80 ? true : false;
 86.2835 -		TM0CNT	 = value & 0xC7;
 86.2836 -		UPDATE_REG(0x102, TM0CNT);
 86.2837 -		//    CPUUpdateTicks();
 86.2838 -		break;
 86.2839 -	case 0x104:
 86.2840 -		timer1Reload = value;
 86.2841 -		break;
 86.2842 -	case 0x106:
 86.2843 -		timer1Ticks = timer1ClockReload = TIMER_TICKS[value & 3];
 86.2844 -		if (!timer1On && (value & 0x80))
 86.2845 -		{
 86.2846 -			// reload the counter
 86.2847 -			TM1D = timer1Reload;
 86.2848 -			if (timer1ClockReload == 1)
 86.2849 -				timer1Ticks = 0x10000 - TM1D;
 86.2850 -			UPDATE_REG(0x104, TM1D);
 86.2851 -		}
 86.2852 -		timer1On = value & 0x80 ? true : false;
 86.2853 -		TM1CNT	 = value & 0xC7;
 86.2854 -		UPDATE_REG(0x106, TM1CNT);
 86.2855 -		break;
 86.2856 -	case 0x108:
 86.2857 -		timer2Reload = value;
 86.2858 -		break;
 86.2859 -	case 0x10A:
 86.2860 -		timer2Ticks = timer2ClockReload = TIMER_TICKS[value & 3];
 86.2861 -		if (!timer2On && (value & 0x80))
 86.2862 -		{
 86.2863 -			// reload the counter
 86.2864 -			TM2D = timer2Reload;
 86.2865 -			if (timer2ClockReload == 1)
 86.2866 -				timer2Ticks = 0x10000 - TM2D;
 86.2867 -			UPDATE_REG(0x108, TM2D);
 86.2868 -		}
 86.2869 -		timer2On = value & 0x80 ? true : false;
 86.2870 -		TM2CNT	 = value & 0xC7;
 86.2871 -		UPDATE_REG(0x10A, TM2CNT);
 86.2872 -		break;
 86.2873 -	case 0x10C:
 86.2874 -		timer3Reload = value;
 86.2875 -		break;
 86.2876 -	case 0x10E:
 86.2877 -		timer3Ticks = timer3ClockReload = TIMER_TICKS[value & 3];
 86.2878 -		if (!timer3On && (value & 0x80))
 86.2879 -		{
 86.2880 -			// reload the counter
 86.2881 -			TM3D = timer3Reload;
 86.2882 -			if (timer3ClockReload == 1)
 86.2883 -				timer3Ticks = 0x10000 - TM3D;
 86.2884 -			UPDATE_REG(0x10C, TM3D);
 86.2885 -		}
 86.2886 -		timer3On = value & 0x80 ? true : false;
 86.2887 -		TM3CNT	 = value & 0xC7;
 86.2888 -		UPDATE_REG(0x10E, TM3CNT);
 86.2889 -		break;
 86.2890 -	case 0x128:
 86.2891 -		if (value & 0x80)
 86.2892 -		{
 86.2893 -			value &= 0xff7f;
 86.2894 -			if (value & 1 && (value & 0x4000))
 86.2895 -			{
 86.2896 -				UPDATE_REG(0x12a, 0xFF);
 86.2897 -				IF |= 0x80;
 86.2898 -				UPDATE_REG(0x202, IF);
 86.2899 -				value &= 0x7f7f;
 86.2900 -			}
 86.2901 -		}
 86.2902 -		UPDATE_REG(0x128, value);
 86.2903 -		break;
 86.2904 -	case 0x130:
 86.2905 -		P1 |= (value & 0x3FF);
 86.2906 -		UPDATE_REG(0x130, P1);
 86.2907 -		break;
 86.2908 -	case 0x132:
 86.2909 -		UPDATE_REG(0x132, value & 0xC3FF);
 86.2910 -		break;
 86.2911 -	case 0x200:
 86.2912 -		IE = value & 0x3FFF;
 86.2913 -		UPDATE_REG(0x200, IE);
 86.2914 -		if ((IME & 1) && (IF & IE) && armIrqEnable)
 86.2915 -		{
 86.2916 -			CPU_BREAK_LOOP_2;
 86.2917 -		}
 86.2918 -		break;
 86.2919 -	case 0x202:
 86.2920 -		IF ^= (value & IF);
 86.2921 -		UPDATE_REG(0x202, IF);
 86.2922 -		break;
 86.2923 -	case 0x204:
 86.2924 -	{
 86.2925 -		int i;
 86.2926 -		memoryWait[0x0e] = memoryWaitSeq[0x0e] = gamepakRamWaitState[value & 3];
 86.2927 -
 86.2928 -		if (!speedHack)
 86.2929 -		{
 86.2930 -			memoryWait[0x08]	= memoryWait[0x09] = gamepakWaitState[(value >> 2) & 7];
 86.2931 -			memoryWaitSeq[0x08] = memoryWaitSeq[0x09] =
 86.2932 -			                          gamepakWaitState0[(value >> 2) & 7];
 86.2933 -
 86.2934 -			memoryWait[0x0a]	= memoryWait[0x0b] = gamepakWaitState[(value >> 5) & 7];
 86.2935 -			memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] =
 86.2936 -			                          gamepakWaitState1[(value >> 5) & 7];
 86.2937 -
 86.2938 -			memoryWait[0x0c]	= memoryWait[0x0d] = gamepakWaitState[(value >> 8) & 7];
 86.2939 -			memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] =
 86.2940 -			                          gamepakWaitState2[(value >> 8) & 7];
 86.2941 -		}
 86.2942 -		else
 86.2943 -		{
 86.2944 -			memoryWait[0x08]	= memoryWait[0x09] = 4;
 86.2945 -			memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = 2;
 86.2946 -
 86.2947 -			memoryWait[0x0a]	= memoryWait[0x0b] = 4;
 86.2948 -			memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] = 4;
 86.2949 -
 86.2950 -			memoryWait[0x0c]	= memoryWait[0x0d] = 4;
 86.2951 -			memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] = 8;
 86.2952 -		}
 86.2953 -		for (i = 0; i < 16; i++)
 86.2954 -		{
 86.2955 -			memoryWaitFetch32[i] = memoryWait32[i] = memoryWait[i] *
 86.2956 -			                                         (memory32[i] ? 1 : 2);
 86.2957 -			memoryWaitFetch[i] = memoryWait[i];
 86.2958 -		}
 86.2959 -		memoryWaitFetch32[3] += 1;
 86.2960 -		memoryWaitFetch32[2] += 3;
 86.2961 -
 86.2962 -		prefetchActive	= false;
 86.2963 -		prefetchApplies = false;
 86.2964 -		if (value & 0x4000)
 86.2965 -		{
 86.2966 -			for (i = 8; i < 16; i++)
 86.2967 -			{
 86.2968 -				memoryWaitFetch32[i] = 2 * cpuMemoryWait[i];
 86.2969 -				memoryWaitFetch[i]	 = cpuMemoryWait[i];
 86.2970 -			}
 86.2971 -			if (((value & 3) == 3))
 86.2972 -			{
 86.2973 -				if (!memLagTempEnabled)
 86.2974 -				{
 86.2975 -					memoryWaitFetch[8]--; // hack to prevent inaccurately extreme lag at some points of many games (possibly
 86.2976 -					                      // from no pre-fetch emulation)
 86.2977 -					                      /// FIXME: how correct is this? Should it set the fetch to 0 or change fetch32 or
 86.2978 -					                      // anything else?
 86.2979 -
 86.2980 -					prefetchActive = true;
 86.2981 -				}
 86.2982 -				prefetchApplies = true;
 86.2983 -			}
 86.2984 -		}
 86.2985 -		//if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600);
 86.2986 -		//if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600);
 86.2987 -		prefetchPrevActive = prefetchActive;
 86.2988 -
 86.2989 -		UPDATE_REG(0x204, value);
 86.2990 -		break;
 86.2991 -	}
 86.2992 -	case 0x208:
 86.2993 -		IME = value & 1;
 86.2994 -		UPDATE_REG(0x208, IME);
 86.2995 -		if ((IME & 1) && (IF & IE) && armIrqEnable)
 86.2996 -		{
 86.2997 -			CPU_BREAK_LOOP_2;
 86.2998 -		}
 86.2999 -		break;
 86.3000 -	case 0x300:
 86.3001 -		if (value != 0)
 86.3002 -			value &= 0xFFFE;
 86.3003 -		UPDATE_REG(0x300, value);
 86.3004 -		break;
 86.3005 -	default:
 86.3006 -		UPDATE_REG(address & 0x3FE, value);
 86.3007 -		break;
 86.3008 -	}
 86.3009 -}
 86.3010 -
 86.3011 -void CPUWriteHalfWordWrapped(u32 address, u16 value)
 86.3012 -{
 86.3013 -#ifdef GBA_LOGGING
 86.3014 -	if (address & 1)
 86.3015 -	{
 86.3016 -		if (systemVerbose & VERBOSE_UNALIGNED_MEMORY)
 86.3017 -		{
 86.3018 -			log("Unaligned halfword write: %04x to %08x from %08x\n",
 86.3019 -			    value,
 86.3020 -			    address,
 86.3021 -			    armMode ? armNextPC - 4 : armNextPC - 2);
 86.3022 -		}
 86.3023 -	}
 86.3024 -#endif
 86.3025 -
 86.3026 -	switch (address >> 24)
 86.3027 -	{
 86.3028 -	case 2:
 86.3029 -#ifdef SDL
 86.3030 -		if (*((u16 *)&freezeWorkRAM[address & 0x3FFFE]))
 86.3031 -			cheatsWriteHalfWord((u16 *)&workRAM[address & 0x3FFFE],
 86.3032 -			                    value,
 86.3033 -			                    *((u16 *)&freezeWorkRAM[address & 0x3FFFE]));
 86.3034 -		else
 86.3035 -#endif
 86.3036 -		WRITE16LE(((u16 *)&workRAM[address & 0x3FFFE]), value);
 86.3037 -		break;
 86.3038 -	case 3:
 86.3039 -#ifdef SDL
 86.3040 -		if (*((u16 *)&freezeInternalRAM[address & 0x7ffe]))
 86.3041 -			cheatsWriteHalfWord((u16 *)&internalRAM[address & 0x7ffe],
 86.3042 -			                    value,
 86.3043 -			                    *((u16 *)&freezeInternalRAM[address & 0x7ffe]));
 86.3044 -		else
 86.3045 -#endif
 86.3046 -		WRITE16LE(((u16 *)&internalRAM[address & 0x7ffe]), value);
 86.3047 -		break;
 86.3048 -	case 4:
 86.3049 -		CPUUpdateRegister(address & 0x3fe, value);
 86.3050 -		break;
 86.3051 -	case 5:
 86.3052 -		WRITE16LE(((u16 *)&paletteRAM[address & 0x3fe]), value);
 86.3053 -		break;
 86.3054 -	case 6:
 86.3055 -		if (address & 0x10000)
 86.3056 -			WRITE16LE(((u16 *)&vram[address & 0x17ffe]), value);
 86.3057 -		else
 86.3058 -			WRITE16LE(((u16 *)&vram[address & 0x1fffe]), value);
 86.3059 -		break;
 86.3060 -	case 7:
 86.3061 -		WRITE16LE(((u16 *)&oam[address & 0x3fe]), value);
 86.3062 -		break;
 86.3063 -	case 8:
 86.3064 -	case 9:
 86.3065 -		if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
 86.3066 -		{
 86.3067 -			if (!rtcWrite(address, value))
 86.3068 -				goto unwritable;
 86.3069 -		}
 86.3070 -		else if (!agbPrintWrite(address, value))
 86.3071 -			goto unwritable;
 86.3072 -		break;
 86.3073 -	case 13:
 86.3074 -		if (cpuEEPROMEnabled)
 86.3075 -		{
 86.3076 -			eepromWrite(address, (u8)(value & 0xFF));
 86.3077 -			break;
 86.3078 -		}
 86.3079 -		goto unwritable;
 86.3080 -	case 14:
 86.3081 -		if (!eepromInUse | cpuSramEnabled | cpuFlashEnabled)
 86.3082 -		{
 86.3083 -			(*cpuSaveGameFunc)(address, (u8)(value & 0xFF));
 86.3084 -			break;
 86.3085 -		}
 86.3086 -		goto unwritable;
 86.3087 -	default:
 86.3088 -unwritable:
 86.3089 -#ifdef GBA_LOGGING
 86.3090 -		if (systemVerbose & VERBOSE_ILLEGAL_WRITE)
 86.3091 -		{
 86.3092 -			log("Illegal halfword write: %04x to %08x from %08x\n",
 86.3093 -			    value,
 86.3094 -			    address,
 86.3095 -			    armMode ? armNextPC - 4 : armNextPC - 2);
 86.3096 -		}
 86.3097 -#endif
 86.3098 -		break;
 86.3099 -	}
 86.3100 -}
 86.3101 -
 86.3102 -void CPUWriteHalfWord(u32 address, u16 value)
 86.3103 -{
 86.3104 -	CPUWriteHalfWordWrapped(address, value);
 86.3105 -	CallRegisteredLuaMemHook(address, 2, value, LUAMEMHOOK_WRITE);
 86.3106 -}
 86.3107 -
 86.3108 -void CPUWriteByteWrapped(u32 address, u8 b)
 86.3109 -{
 86.3110 -	switch (address >> 24)
 86.3111 -	{
 86.3112 -	case 2:
 86.3113 -#ifdef SDL
 86.3114 -		if (freezeWorkRAM[address & 0x3FFFF])
 86.3115 -			cheatsWriteByte(&workRAM[address & 0x3FFFF], b);
 86.3116 -		else
 86.3117 -#endif
 86.3118 -		workRAM[address & 0x3FFFF] = b;
 86.3119 -		break;
 86.3120 -	case 3:
 86.3121 -#ifdef SDL
 86.3122 -		if (freezeInternalRAM[address & 0x7fff])
 86.3123 -			cheatsWriteByte(&internalRAM[address & 0x7fff], b);
 86.3124 -		else
 86.3125 -#endif
 86.3126 -		internalRAM[address & 0x7fff] = b;
 86.3127 -		break;
 86.3128 -	case 4:
 86.3129 -		switch (address & 0x3FF)
 86.3130 -		{
 86.3131 -		case 0x301:
 86.3132 -			if (b == 0x80)
 86.3133 -				stopState = true;
 86.3134 -			holdState = 1;
 86.3135 -			holdType  = -1;
 86.3136 -			break;
 86.3137 -		case 0x60:
 86.3138 -		case 0x61:
 86.3139 -		case 0x62:
 86.3140 -		case 0x63:
 86.3141 -		case 0x64:
 86.3142 -		case 0x65:
 86.3143 -		case 0x68:
 86.3144 -		case 0x69:
 86.3145 -		case 0x6c:
 86.3146 -		case 0x6d:
 86.3147 -		case 0x70:
 86.3148 -		case 0x71:
 86.3149 -		case 0x72:
 86.3150 -		case 0x73:
 86.3151 -		case 0x74:
 86.3152 -		case 0x75:
 86.3153 -		case 0x78:
 86.3154 -		case 0x79:
 86.3155 -		case 0x7c:
 86.3156 -		case 0x7d:
 86.3157 -		case 0x80:
 86.3158 -		case 0x81:
 86.3159 -		case 0x84:
 86.3160 -		case 0x85:
 86.3161 -		case 0x90:
 86.3162 -		case 0x91:
 86.3163 -		case 0x92:
 86.3164 -		case 0x93:
 86.3165 -		case 0x94:
 86.3166 -		case 0x95:
 86.3167 -		case 0x96:
 86.3168 -		case 0x97:
 86.3169 -		case 0x98:
 86.3170 -		case 0x99:
 86.3171 -		case 0x9a:
 86.3172 -		case 0x9b:
 86.3173 -		case 0x9c:
 86.3174 -		case 0x9d:
 86.3175 -		case 0x9e:
 86.3176 -		case 0x9f:
 86.3177 -			soundEvent(address & 0xFF, b);
 86.3178 -			break;
 86.3179 -		default:
 86.3180 -			//      if(address & 1) {
 86.3181 -			//        CPUWriteHalfWord(address-1, (CPUReadHalfWord(address-1)&0x00FF)|((int)b<<8));
 86.3182 -			//      } else
 86.3183 -			if (address & 1)
 86.3184 -				CPUUpdateRegister(address & 0x3fe,
 86.3185 -				                  ((READ16LE(((u16 *)&ioMem[address & 0x3fe])))
 86.3186 -				                   & 0x00FF) |
 86.3187 -				                  b << 8);
 86.3188 -			else
 86.3189 -				CPUUpdateRegister(address & 0x3fe,
 86.3190 -				                  ((READ16LE(((u16 *)&ioMem[address & 0x3fe])) & 0xFF00) | b));
 86.3191 -		}
 86.3192 -		break;
 86.3193 -	case 5:
 86.3194 -		// no need to switch
 86.3195 -		*((u16 *)&paletteRAM[address & 0x3FE]) = (b << 8) | b;
 86.3196 -		break;
 86.3197 -	case 6:
 86.3198 -		// no need to switch
 86.3199 -		if (address & 0x10000)
 86.3200 -			*((u16 *)&vram[address & 0x17FFE]) = (b << 8) | b;
 86.3201 -		else
 86.3202 -			*((u16 *)&vram[address & 0x1FFFE]) = (b << 8) | b;
 86.3203 -		break;
 86.3204 -	case 7:
 86.3205 -		// no need to switch
 86.3206 -		*((u16 *)&oam[address & 0x3FE]) = (b << 8) | b;
 86.3207 -		break;
 86.3208 -	case 13:
 86.3209 -		if (cpuEEPROMEnabled)
 86.3210 -		{
 86.3211 -			eepromWrite(address, b);
 86.3212 -			break;
 86.3213 -		}
 86.3214 -		goto unwritable;
 86.3215 -	case 14:
 86.3216 -		if (!eepromInUse | cpuSramEnabled | cpuFlashEnabled)
 86.3217 -		{
 86.3218 -			(*cpuSaveGameFunc)(address, b);
 86.3219 -			break;
 86.3220 -		}
 86.3221 -	// default
 86.3222 -	default:
 86.3223 -unwritable:
 86.3224 -#ifdef GBA_LOGGING
 86.3225 -		if (systemVerbose & VERBOSE_ILLEGAL_WRITE)
 86.3226 -		{
 86.3227 -			log("Illegal byte write: %02x to %08x from %08x\n",
 86.3228 -			    b,
 86.3229 -			    address,
 86.3230 -			    armMode ? armNextPC - 4 : armNextPC - 2);
 86.3231 -		}
 86.3232 -#endif
 86.3233 -		break;
 86.3234 -	}
 86.3235 -}
 86.3236 -
 86.3237 -void CPUWriteByte(u32 address, u8 b)
 86.3238 -{
 86.3239 -	CPUWriteByteWrapped(address, b);
 86.3240 -	CallRegisteredLuaMemHook(address, 1, b, LUAMEMHOOK_WRITE);
 86.3241 -}
 86.3242 -
 86.3243 -bool CPULoadBios(const char *biosFileName, bool useBiosFile)
 86.3244 -{
 86.3245 -	useBios = false;
 86.3246 -	if (useBiosFile)
 86.3247 -	{
 86.3248 -		useBios = utilLoadBIOS(bios, biosFileName, 4);
 86.3249 -		if (!useBios)
 86.3250 -		{
 86.3251 -			systemMessage(MSG_INVALID_BIOS_FILE_SIZE, N_("Invalid GBA BIOS file"));
 86.3252 -		}
 86.3253 -	}
 86.3254 -
 86.3255 -	if (!useBios)
 86.3256 -	{
 86.3257 -		// load internal BIOS
 86.3258 -		memcpy(bios, myROM, sizeof(myROM));
 86.3259 -	}
 86.3260 -
 86.3261 -	return useBios;
 86.3262 -}
 86.3263 -
 86.3264 -void CPUInit()
 86.3265 -{
 86.3266 -#ifdef WORDS_BIGENDIAN
 86.3267 -	if (!cpuBiosSwapped)
 86.3268 -	{
 86.3269 -		for (unsigned int i = 0; i < sizeof(myROM) / 4; i++)
 86.3270 -		{
 86.3271 -			WRITE32LE(&myROM[i], myROM[i]);
 86.3272 -		}
 86.3273 -		cpuBiosSwapped = true;
 86.3274 -	}
 86.3275 -#endif
 86.3276 -	gbaSaveType = 0;
 86.3277 -	eepromInUse = 0;
 86.3278 -	saveType	= 0;
 86.3279 -
 86.3280 -	if (!useBios)
 86.3281 -	{
 86.3282 -		// load internal BIOS
 86.3283 -		memcpy(bios, myROM, sizeof(myROM));
 86.3284 -	}
 86.3285 -
 86.3286 -	biosProtected[0] = 0x00;
 86.3287 -	biosProtected[1] = 0xf0;
 86.3288 -	biosProtected[2] = 0x29;
 86.3289 -	biosProtected[3] = 0xe1;
 86.3290 -
 86.3291 -	int i = 0;
 86.3292 -	for (i = 0; i < 256; i++)
 86.3293 -	{
 86.3294 -		int cpuBitSetCount = 0;
 86.3295 -		int j;
 86.3296 -		for (j = 0; j < 8; j++)
 86.3297 -			if (i & (1 << j))
 86.3298 -				cpuBitSetCount++;
 86.3299 -		cpuBitsSet[i] = cpuBitSetCount;
 86.3300 -
 86.3301 -		for (j = 0; j < 8; j++)
 86.3302 -			if (i & (1 << j))
 86.3303 -				break;
 86.3304 -		cpuLowestBitSet[i] = j;
 86.3305 -	}
 86.3306 -
 86.3307 -	for (i = 0; i < 0x400; i++)
 86.3308 -		ioReadable[i] = true;
 86.3309 -	for (i = 0x10; i < 0x48; i++)
 86.3310 -		ioReadable[i] = false;
 86.3311 -	for (i = 0x4c; i < 0x50; i++)
 86.3312 -		ioReadable[i] = false;
 86.3313 -	for (i = 0x54; i < 0x60; i++)
 86.3314 -		ioReadable[i] = false;
 86.3315 -	for (i = 0x8c; i < 0x90; i++)
 86.3316 -		ioReadable[i] = false;
 86.3317 -	for (i = 0xa0; i < 0xb8; i++)
 86.3318 -		ioReadable[i] = false;
 86.3319 -	for (i = 0xbc; i < 0xc4; i++)
 86.3320 -		ioReadable[i] = false;
 86.3321 -	for (i = 0xc8; i < 0xd0; i++)
 86.3322 -		ioReadable[i] = false;
 86.3323 -	for (i = 0xd4; i < 0xdc; i++)
 86.3324 -		ioReadable[i] = false;
 86.3325 -	for (i = 0xe0; i < 0x100; i++)
 86.3326 -		ioReadable[i] = false;
 86.3327 -	for (i = 0x110; i < 0x120; i++)
 86.3328 -		ioReadable[i] = false;
 86.3329 -	for (i = 0x12c; i < 0x130; i++)
 86.3330 -		ioReadable[i] = false;
 86.3331 -	for (i = 0x138; i < 0x140; i++)
 86.3332 -		ioReadable[i] = false;
 86.3333 -	for (i = 0x144; i < 0x150; i++)
 86.3334 -		ioReadable[i] = false;
 86.3335 -	for (i = 0x15c; i < 0x200; i++)
 86.3336 -		ioReadable[i] = false;
 86.3337 -	for (i = 0x20c; i < 0x300; i++)
 86.3338 -		ioReadable[i] = false;
 86.3339 -	for (i = 0x304; i < 0x400; i++)
 86.3340 -		ioReadable[i] = false;
 86.3341 -
 86.3342 -	*((u16 *)&rom[0x1fe209c]) = 0xdffa;  // SWI 0xFA
 86.3343 -	*((u16 *)&rom[0x1fe209e]) = 0x4770;  // BX LR
 86.3344 -
 86.3345 -	{
 86.3346 -		int32 origMemoryWaitFetch[16]	= { 3, 0, 3, 0, 0, 1, 1, 0, 4, 4, 4, 4, 4, 4, 4, 0 };
 86.3347 -		int32 origMemoryWaitFetch32[16] = { 6, 0, 6, 0, 0, 2, 2, 0, 8, 8, 8, 8, 8, 8, 8, 0 };
 86.3348 -		memcpy(memoryWaitFetch, origMemoryWaitFetch, 16 * sizeof(int32));
 86.3349 -		memcpy(memoryWaitFetch32, origMemoryWaitFetch32, 16 * sizeof(int32));
 86.3350 -	}
 86.3351 -}
 86.3352 -
 86.3353 -void CPUReset(bool userReset)
 86.3354 -{
 86.3355 -	// movie must be closed while opening/creating a movie
 86.3356 -	if (userReset && VBAMovieRecording())
 86.3357 -	{
 86.3358 -		VBAMovieSignalReset();
 86.3359 -		return;
 86.3360 -	}
 86.3361 -
 86.3362 -	if (!VBAMovieActive())
 86.3363 -	{
 86.3364 -		GBASystemCounters.frameCount = 0;
 86.3365 -		GBASystemCounters.lagCount	 = 0;
 86.3366 -		GBASystemCounters.extraCount = 0;
 86.3367 -		GBASystemCounters.lagged	 = true;
 86.3368 -		GBASystemCounters.laggedLast = true;
 86.3369 -	}
 86.3370 -
 86.3371 -	if (gbaSaveType == 0)
 86.3372 -	{
 86.3373 -		if (eepromInUse)
 86.3374 -			gbaSaveType = 3;
 86.3375 -		else
 86.3376 -			switch (saveType)
 86.3377 -			{
 86.3378 -			case 1:
 86.3379 -				gbaSaveType = 1;
 86.3380 -				break;
 86.3381 -			case 2:
 86.3382 -				gbaSaveType = 2;
 86.3383 -				break;
 86.3384 -			}
 86.3385 -	}
 86.3386 -
 86.3387 -	rtcReset();
 86.3388 -	// clean registers
 86.3389 -	memset(&reg[0], 0, sizeof(reg));
 86.3390 -	// clean OAM
 86.3391 -	memset(oam, 0, 0x400);
 86.3392 -	// clean palette
 86.3393 -	memset(paletteRAM, 0, 0x400);
 86.3394 -	// clean picture
 86.3395 -	memset(pix, 0, 4 * 241 * 162);
 86.3396 -	// clean vram
 86.3397 -	memset(vram, 0, 0x20000);
 86.3398 -	// clean io memory
 86.3399 -	memset(ioMem, 0, 0x400);
 86.3400 -	// clean RAM
 86.3401 -	memset(internalRAM, 0, 0x8000); /// FIXME: is it unsafe to erase ALL of this? Even the init code doesn't.
 86.3402 -	memset(workRAM, 0, 0x40000); /// ditto
 86.3403 -
 86.3404 -	DISPCNT	 = 0x0080;
 86.3405 -	DISPSTAT = 0x0000;
 86.3406 -	VCOUNT	 = 0x0000;
 86.3407 -	BG0CNT	 = 0x0000;
 86.3408 -	BG1CNT	 = 0x0000;
 86.3409 -	BG2CNT	 = 0x0000;
 86.3410 -	BG3CNT	 = 0x0000;
 86.3411 -	BG0HOFS	 = 0x0000;
 86.3412 -	BG0VOFS	 = 0x0000;
 86.3413 -	BG1HOFS	 = 0x0000;
 86.3414 -	BG1VOFS	 = 0x0000;
 86.3415 -	BG2HOFS	 = 0x0000;
 86.3416 -	BG2VOFS	 = 0x0000;
 86.3417 -	BG3HOFS	 = 0x0000;
 86.3418 -	BG3VOFS	 = 0x0000;
 86.3419 -	BG2PA	 = 0x0100;
 86.3420 -	BG2PB	 = 0x0000;
 86.3421 -	BG2PC	 = 0x0000;
 86.3422 -	BG2PD	 = 0x0100;
 86.3423 -	BG2X_L	 = 0x0000;
 86.3424 -	BG2X_H	 = 0x0000;
 86.3425 -	BG2Y_L	 = 0x0000;
 86.3426 -	BG2Y_H	 = 0x0000;
 86.3427 -	BG3PA	 = 0x0100;
 86.3428 -	BG3PB	 = 0x0000;
 86.3429 -	BG3PC	 = 0x0000;
 86.3430 -	BG3PD	 = 0x0100;
 86.3431 -	BG3X_L	 = 0x0000;
 86.3432 -	BG3X_H	 = 0x0000;
 86.3433 -	BG3Y_L	 = 0x0000;
 86.3434 -	BG3Y_H	 = 0x0000;
 86.3435 -	WIN0H	 = 0x0000;
 86.3436 -	WIN1H	 = 0x0000;
 86.3437 -	WIN0V	 = 0x0000;
 86.3438 -	WIN1V	 = 0x0000;
 86.3439 -	WININ	 = 0x0000;
 86.3440 -	WINOUT	 = 0x0000;
 86.3441 -	MOSAIC	 = 0x0000;
 86.3442 -	BLDMOD	 = 0x0000;
 86.3443 -	COLEV	 = 0x0000;
 86.3444 -	COLY	 = 0x0000;
 86.3445 -	DM0SAD_L = 0x0000;
 86.3446 -	DM0SAD_H = 0x0000;
 86.3447 -	DM0DAD_L = 0x0000;
 86.3448 -	DM0DAD_H = 0x0000;
 86.3449 -	DM0CNT_L = 0x0000;
 86.3450 -	DM0CNT_H = 0x0000;
 86.3451 -	DM1SAD_L = 0x0000;
 86.3452 -	DM1SAD_H = 0x0000;
 86.3453 -	DM1DAD_L = 0x0000;
 86.3454 -	DM1DAD_H = 0x0000;
 86.3455 -	DM1CNT_L = 0x0000;
 86.3456 -	DM1CNT_H = 0x0000;
 86.3457 -	DM2SAD_L = 0x0000;
 86.3458 -	DM2SAD_H = 0x0000;
 86.3459 -	DM2DAD_L = 0x0000;
 86.3460 -	DM2DAD_H = 0x0000;
 86.3461 -	DM2CNT_L = 0x0000;
 86.3462 -	DM2CNT_H = 0x0000;
 86.3463 -	DM3SAD_L = 0x0000;
 86.3464 -	DM3SAD_H = 0x0000;
 86.3465 -	DM3DAD_L = 0x0000;
 86.3466 -	DM3DAD_H = 0x0000;
 86.3467 -	DM3CNT_L = 0x0000;
 86.3468 -	DM3CNT_H = 0x0000;
 86.3469 -	TM0D	 = 0x0000;
 86.3470 -	TM0CNT	 = 0x0000;
 86.3471 -	TM1D	 = 0x0000;
 86.3472 -	TM1CNT	 = 0x0000;
 86.3473 -	TM2D	 = 0x0000;
 86.3474 -	TM2CNT	 = 0x0000;
 86.3475 -	TM3D	 = 0x0000;
 86.3476 -	TM3CNT	 = 0x0000;
 86.3477 -	P1		 = 0x03FF;
 86.3478 -	IE		 = 0x0000;
 86.3479 -	IF		 = 0x0000;
 86.3480 -	IME		 = 0x0000;
 86.3481 -
 86.3482 -	armMode = 0x1F;
 86.3483 -
 86.3484 -	if (cpuIsMultiBoot)
 86.3485 -	{
 86.3486 -		reg[13].I	   = 0x03007F00;
 86.3487 -		reg[15].I	   = 0x02000000;
 86.3488 -		reg[16].I	   = 0x00000000;
 86.3489 -		reg[R13_IRQ].I = 0x03007FA0;
 86.3490 -		reg[R13_SVC].I = 0x03007FE0;
 86.3491 -		armIrqEnable   = true;
 86.3492 -	}
 86.3493 -	else
 86.3494 -	{
 86.3495 -		if (useBios && !skipBios)
 86.3496 -		{
 86.3497 -			reg[15].I	 = 0x00000000;
 86.3498 -			armMode		 = 0x13;
 86.3499 -			armIrqEnable = false;
 86.3500 -		}
 86.3501 -		else
 86.3502 -		{
 86.3503 -			reg[13].I	   = 0x03007F00;
 86.3504 -			reg[15].I	   = 0x08000000;
 86.3505 -			reg[16].I	   = 0x00000000;
 86.3506 -			reg[R13_IRQ].I = 0x03007FA0;
 86.3507 -			reg[R13_SVC].I = 0x03007FE0;
 86.3508 -			armIrqEnable   = true;
 86.3509 -		}
 86.3510 -	}
 86.3511 -	armState = true;
 86.3512 -	C_FLAG	 = V_FLAG = N_FLAG = Z_FLAG = false;
 86.3513 -	UPDATE_REG(0x00, DISPCNT);
 86.3514 -	UPDATE_REG(0x20, BG2PA);
 86.3515 -	UPDATE_REG(0x26, BG2PD);
 86.3516 -	UPDATE_REG(0x30, BG3PA);
 86.3517 -	UPDATE_REG(0x36, BG3PD);
 86.3518 -	UPDATE_REG(0x130, P1);
 86.3519 -	UPDATE_REG(0x88, 0x200);
 86.3520 -
 86.3521 -	// disable FIQ
 86.3522 -	reg[16].I |= 0x40;
 86.3523 -	CPUUpdateCPSR();
 86.3524 -
 86.3525 -	armNextPC  = reg[15].I;
 86.3526 -	reg[15].I += 4;
 86.3527 -
 86.3528 -	// reset internal state
 86.3529 -	holdState = false;
 86.3530 -	holdType  = 0;
 86.3531 -
 86.3532 -	biosProtected[0] = 0x00;
 86.3533 -	biosProtected[1] = 0xf0;
 86.3534 -	biosProtected[2] = 0x29;
 86.3535 -	biosProtected[3] = 0xe1;
 86.3536 -
 86.3537 -	BIOS_RegisterRamReset();
 86.3538 -
 86.3539 -	lcdTicks = 960;
 86.3540 -	timer0On = false;
 86.3541 -	timer0Ticks		  = 0;
 86.3542 -	timer0Reload	  = 0;
 86.3543 -	timer0ClockReload = 0;
 86.3544 -	timer1On		  = false;
 86.3545 -	timer1Ticks		  = 0;
 86.3546 -	timer1Reload	  = 0;
 86.3547 -	timer1ClockReload = 0;
 86.3548 -	timer2On		  = false;
 86.3549 -	timer2Ticks		  = 0;
 86.3550 -	timer2Reload	  = 0;
 86.3551 -	timer2ClockReload = 0;
 86.3552 -	timer3On		  = false;
 86.3553 -	timer3Ticks		  = 0;
 86.3554 -	timer3Reload	  = 0;
 86.3555 -	timer3ClockReload = 0;
 86.3556 -	dma0Source		  = 0;
 86.3557 -	dma0Dest		  = 0;
 86.3558 -	dma1Source		  = 0;
 86.3559 -	dma1Dest		  = 0;
 86.3560 -	dma2Source		  = 0;
 86.3561 -	dma2Dest		  = 0;
 86.3562 -	dma3Source		  = 0;
 86.3563 -	dma3Dest		  = 0;
 86.3564 -	cpuSaveGameFunc	  = flashSaveDecide;
 86.3565 -	renderLine		  = mode0RenderLine;
 86.3566 -	fxOn			  = false;
 86.3567 -	windowOn		  = false;
 86.3568 -	frameSkipCount	  = 0;
 86.3569 -	saveType		  = 0;
 86.3570 -	layerEnable		  = DISPCNT & layerSettings;
 86.3571 -
 86.3572 -	CPUUpdateRenderBuffers(true);
 86.3573 -
 86.3574 -	for (int i = 0; i < 256; i++)
 86.3575 -	{
 86.3576 -		map[i].address = (u8 *)&dummyAddress;
 86.3577 -		map[i].mask	   = 0;
 86.3578 -	}
 86.3579 -
 86.3580 -	map[0].address	= bios;
 86.3581 -	map[0].mask		= 0x3FFF;
 86.3582 -	map[2].address	= workRAM;
 86.3583 -	map[2].mask		= 0x3FFFF;
 86.3584 -	map[3].address	= internalRAM;
 86.3585 -	map[3].mask		= 0x7FFF;
 86.3586 -	map[4].address	= ioMem;
 86.3587 -	map[4].mask		= 0x3FF;
 86.3588 -	map[5].address	= paletteRAM;
 86.3589 -	map[5].mask		= 0x3FF;
 86.3590 -	map[6].address	= vram;
 86.3591 -	map[6].mask		= 0x1FFFF;
 86.3592 -	map[7].address	= oam;
 86.3593 -	map[7].mask		= 0x3FF;
 86.3594 -	map[8].address	= rom;
 86.3595 -	map[8].mask		= 0x1FFFFFF;
 86.3596 -	map[9].address	= rom;
 86.3597 -	map[9].mask		= 0x1FFFFFF;
 86.3598 -	map[10].address = rom;
 86.3599 -	map[10].mask	= 0x1FFFFFF;
 86.3600 -	map[12].address = rom;
 86.3601 -	map[12].mask	= 0x1FFFFFF;
 86.3602 -	map[14].address = flashSaveMemory;
 86.3603 -	map[14].mask	= 0xFFFF;
 86.3604 -
 86.3605 -	eepromReset();
 86.3606 -	flashReset();
 86.3607 -
 86.3608 -	soundReset();
 86.3609 -
 86.3610 -	CPUUpdateWindow0();
 86.3611 -	CPUUpdateWindow1();
 86.3612 -
 86.3613 -	// make sure registers are correctly initialized if not using BIOS
 86.3614 -	if (!useBios)
 86.3615 -	{
 86.3616 -		if (cpuIsMultiBoot)
 86.3617 -			BIOS_RegisterRamReset(0xfe);
 86.3618 -		else
 86.3619 -			BIOS_RegisterRamReset(0xff);
 86.3620 -	}
 86.3621 -	else
 86.3622 -	{
 86.3623 -		if (cpuIsMultiBoot)
 86.3624 -			BIOS_RegisterRamReset(0xfe);
 86.3625 -	}
 86.3626 -
 86.3627 -	switch (cpuSaveType)
 86.3628 -	{
 86.3629 -	case 0: // automatic
 86.3630 -		cpuSramEnabled		   = true;
 86.3631 -		cpuFlashEnabled		   = true;
 86.3632 -		cpuEEPROMEnabled	   = true;
 86.3633 -		cpuEEPROMSensorEnabled = false;
 86.3634 -		break;
 86.3635 -	case 1: // EEPROM
 86.3636 -		cpuSramEnabled		   = false;
 86.3637 -		cpuFlashEnabled		   = false;
 86.3638 -		cpuEEPROMEnabled	   = true;
 86.3639 -		cpuEEPROMSensorEnabled = false;
 86.3640 -		break;
 86.3641 -	case 2: // SRAM
 86.3642 -		cpuSramEnabled		   = true;
 86.3643 -		cpuFlashEnabled		   = false;
 86.3644 -		cpuEEPROMEnabled	   = false;
 86.3645 -		cpuEEPROMSensorEnabled = false;
 86.3646 -		cpuSaveGameFunc		   = sramWrite;
 86.3647 -		break;
 86.3648 -	case 3: // FLASH
 86.3649 -		cpuSramEnabled		   = false;
 86.3650 -		cpuFlashEnabled		   = true;
 86.3651 -		cpuEEPROMEnabled	   = false;
 86.3652 -		cpuEEPROMSensorEnabled = false;
 86.3653 -		cpuSaveGameFunc		   = flashWrite;
 86.3654 -		break;
 86.3655 -	case 4: // EEPROM+Sensor
 86.3656 -		cpuSramEnabled		   = false;
 86.3657 -		cpuFlashEnabled		   = false;
 86.3658 -		cpuEEPROMEnabled	   = true;
 86.3659 -		cpuEEPROMSensorEnabled = true;
 86.3660 -		break;
 86.3661 -	case 5: // NONE
 86.3662 -		cpuSramEnabled		   = false;
 86.3663 -		cpuFlashEnabled		   = false;
 86.3664 -		cpuEEPROMEnabled	   = false;
 86.3665 -		cpuEEPROMSensorEnabled = false;
 86.3666 -		break;
 86.3667 -	}
 86.3668 -
 86.3669 -	systemResetSensor();
 86.3670 -
 86.3671 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 86.3672 -
 86.3673 -	gbaLastTime	  = systemGetClock();
 86.3674 -	gbaFrameCount = 0;
 86.3675 -
 86.3676 -	systemRefreshScreen();
 86.3677 -}
 86.3678 -
 86.3679 -void CPUInterrupt()
 86.3680 -{
 86.3681 -	u32	 PC			= reg[15].I;
 86.3682 -	bool savedState = armState;
 86.3683 -	CPUSwitchMode(0x12, true, false);
 86.3684 -	reg[14].I = PC;
 86.3685 -	if (!savedState)
 86.3686 -		reg[14].I += 2;
 86.3687 -	reg[15].I	 = 0x18;
 86.3688 -	armState	 = true;
 86.3689 -	armIrqEnable = false;
 86.3690 -
 86.3691 -	armNextPC  = reg[15].I;
 86.3692 -	reg[15].I += 4;
 86.3693 -
 86.3694 -	//  if(!holdState)
 86.3695 -	biosProtected[0] = 0x02;
 86.3696 -	biosProtected[1] = 0xc0;
 86.3697 -	biosProtected[2] = 0x5e;
 86.3698 -	biosProtected[3] = 0xe5;
 86.3699 -}
 86.3700 -
 86.3701 -void TogglePrefetchHack()
 86.3702 -{
 86.3703 -	memLagTempEnabled = !memLagTempEnabled;
 86.3704 -
 86.3705 -	if (emulating)
 86.3706 -	{
 86.3707 -		extern bool8 prefetchActive, prefetchPrevActive, prefetchApplies;
 86.3708 -		if (prefetchApplies && prefetchActive == memLagTempEnabled)
 86.3709 -		{
 86.3710 -			prefetchActive = !prefetchActive;
 86.3711 -			//if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600);
 86.3712 -			//if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600);
 86.3713 -			extern int32 memoryWaitFetch [16];
 86.3714 -			if (prefetchActive)
 86.3715 -				memoryWaitFetch[8]--;
 86.3716 -			else
 86.3717 -				memoryWaitFetch[8]++;
 86.3718 -			prefetchPrevActive = prefetchActive;
 86.3719 -		}
 86.3720 -	}
 86.3721 -}
 86.3722 -
 86.3723 -void SetPrefetchHack(bool set)
 86.3724 -{
 86.3725 -	if ((bool)memLagTempEnabled == set)
 86.3726 -		TogglePrefetchHack();
 86.3727 -}
 86.3728 -
 86.3729 -#ifdef SDL
 86.3730 -void log(const char *defaultMsg, ...)
 86.3731 -{
 86.3732 -	char	buffer[2048];
 86.3733 -	va_list valist;
 86.3734 -
 86.3735 -	va_start(valist, defaultMsg);
 86.3736 -	vsprintf(buffer, defaultMsg, valist);
 86.3737 -
 86.3738 -	if (out == NULL)
 86.3739 -	{
 86.3740 -		out = fopen("trace.log", "w");
 86.3741 -	}
 86.3742 -
 86.3743 -	fputs(buffer, out);
 86.3744 -
 86.3745 -	va_end(valist);
 86.3746 -}
 86.3747 -
 86.3748 -#else
 86.3749 -extern void winlog(const char *, ...);
 86.3750 -#endif
 86.3751 -
 86.3752 -void CPULoop(int _ticks)
 86.3753 -{
 86.3754 -	int32 ticks = _ticks;
 86.3755 -	int32 clockTicks;
 86.3756 -	int32 cpuLoopTicks	= 0;
 86.3757 -	int32 timerOverflow = 0;
 86.3758 -	// variables used by the CPU core
 86.3759 -
 86.3760 -	extCpuLoopTicks = &cpuLoopTicks;
 86.3761 -	extClockTicks	= &clockTicks;
 86.3762 -	extTicks		= &ticks;
 86.3763 -
 86.3764 -	cpuLoopTicks = CPUUpdateTicks();
 86.3765 -	if (cpuLoopTicks > ticks)
 86.3766 -	{
 86.3767 -		cpuLoopTicks  = ticks;
 86.3768 -		cpuSavedTicks = ticks;
 86.3769 -	}
 86.3770 -
 86.3771 -	if (intState)
 86.3772 -	{
 86.3773 -		cpuLoopTicks  = 5;
 86.3774 -		cpuSavedTicks = 5;
 86.3775 -	}
 86.3776 -
 86.3777 -	if (newFrame)
 86.3778 -	{
 86.3779 -		extern void VBAOnExitingFrameBoundary();
 86.3780 -		VBAOnExitingFrameBoundary();
 86.3781 -
 86.3782 -		// update joystick information
 86.3783 -		systemReadJoypads();
 86.3784 -
 86.3785 -		u32 joy = systemGetJoypad(0, cpuEEPROMSensorEnabled);
 86.3786 -
 86.3787 -//		if (cpuEEPROMSensorEnabled)
 86.3788 -//			systemUpdateMotionSensor(0);
 86.3789 -
 86.3790 -		P1 = 0x03FF ^ (joy & 0x3FF);
 86.3791 -		UPDATE_REG(0x130, P1);
 86.3792 -		u16 P1CNT = READ16LE(((u16 *)&ioMem[0x132]));
 86.3793 -		// this seems wrong, but there are cases where the game
 86.3794 -		// can enter the stop state without requesting an IRQ from
 86.3795 -		// the joypad.
 86.3796 -		if ((P1CNT & 0x4000) || stopState)
 86.3797 -		{
 86.3798 -			u16 p1 = (0x3FF ^ P1) & 0x3FF;
 86.3799 -			if (P1CNT & 0x8000)
 86.3800 -			{
 86.3801 -				if (p1 == (P1CNT & 0x3FF))
 86.3802 -				{
 86.3803 -					IF |= 0x1000;
 86.3804 -					UPDATE_REG(0x202, IF);
 86.3805 -				}
 86.3806 -			}
 86.3807 -			else
 86.3808 -			{
 86.3809 -				if (p1 & P1CNT)
 86.3810 -				{
 86.3811 -					IF |= 0x1000;
 86.3812 -					UPDATE_REG(0x202, IF);
 86.3813 -				}
 86.3814 -			}
 86.3815 -		}
 86.3816 -
 86.3817 -		// HACK: some special "buttons"
 86.3818 -		extButtons = (joy >> 18);
 86.3819 -		speedup	   = (extButtons & 1) != 0;
 86.3820 -
 86.3821 -		VBAMovieResetIfRequested();
 86.3822 -
 86.3823 -		CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION);
 86.3824 -
 86.3825 -		newFrame = false;
 86.3826 -	}
 86.3827 -
 86.3828 -	for (;; )
 86.3829 -	{
 86.3830 -#ifndef FINAL_VERSION
 86.3831 -		if (systemDebug)
 86.3832 -		{
 86.3833 -			if (systemDebug >= 10 && !holdState)
 86.3834 -			{
 86.3835 -				CPUUpdateCPSR();
 86.3836 -				sprintf(
 86.3837 -				    buffer,
 86.3838 -				    "R00=%08x R01=%08x R02=%08x R03=%08x R04=%08x R05=%08x R06=%08x R07=%08x R08=%08x"
 86.3839 -				    "R09=%08x R10=%08x R11=%08x R12=%08x R13=%08x R14=%08x R15=%08x R16=%08x R17=%08x\n",
 86.3840 -				    reg[0].I,
 86.3841 -				    reg[1].I,
 86.3842 -				    reg[2].I,
 86.3843 -				    reg[3].I,
 86.3844 -				    reg[4].I,
 86.3845 -				    reg[5].I,
 86.3846 -				    reg[6].I,
 86.3847 -				    reg[7].I,
 86.3848 -				    reg[8].I,
 86.3849 -				    reg[9].I,
 86.3850 -				    reg[10].I,
 86.3851 -				    reg[11].I,
 86.3852 -				    reg[12].I,
 86.3853 -				    reg[13].I,
 86.3854 -				    reg[14].I,
 86.3855 -				    reg[15].I,
 86.3856 -				    reg[16].I,
 86.3857 -				    reg[17].I);
 86.3858 -#ifdef SDL
 86.3859 -				log(buffer);
 86.3860 -#else
 86.3861 -				winlog(buffer);
 86.3862 -#endif
 86.3863 -			}
 86.3864 -			else if (!holdState)
 86.3865 -			{
 86.3866 -				sprintf(buffer, "PC=%08x\n", armNextPC);
 86.3867 -#ifdef SDL
 86.3868 -				log(buffer);
 86.3869 -#else
 86.3870 -				winlog(buffer);
 86.3871 -#endif
 86.3872 -			}
 86.3873 -		}
 86.3874 -#endif
 86.3875 -
 86.3876 -		if (!holdState)
 86.3877 -		{
 86.3878 -			if (armState)
 86.3879 -			{
 86.3880 -				CallRegisteredLuaMemHook(armNextPC, 4, CPUReadMemoryQuick(armNextPC), LUAMEMHOOK_EXEC);
 86.3881 -#include "arm-new.h"
 86.3882 -			}
 86.3883 -			else
 86.3884 -			{
 86.3885 -				CallRegisteredLuaMemHook(armNextPC, 2, CPUReadHalfWordQuick(armNextPC), LUAMEMHOOK_EXEC);
 86.3886 -#include "thumb.h"
 86.3887 -			}
 86.3888 -		}
 86.3889 -		else
 86.3890 -		{
 86.3891 -			clockTicks = lcdTicks;
 86.3892 -
 86.3893 -			if (soundTicks < clockTicks)
 86.3894 -				clockTicks = soundTicks;
 86.3895 -
 86.3896 -			if (timer0On && (timer0Ticks < clockTicks))
 86.3897 -			{
 86.3898 -				clockTicks = timer0Ticks;
 86.3899 -			}
 86.3900 -			if (timer1On && (timer1Ticks < clockTicks))
 86.3901 -			{
 86.3902 -				clockTicks = timer1Ticks;
 86.3903 -			}
 86.3904 -			if (timer2On && (timer2Ticks < clockTicks))
 86.3905 -			{
 86.3906 -				clockTicks = timer2Ticks;
 86.3907 -			}
 86.3908 -			if (timer3On && (timer3Ticks < clockTicks))
 86.3909 -			{
 86.3910 -				clockTicks = timer3Ticks;
 86.3911 -			}
 86.3912 -#ifdef PROFILING
 86.3913 -			if (profilingTicksReload != 0)
 86.3914 -			{
 86.3915 -				if (profilingTicks < clockTicks)
 86.3916 -				{
 86.3917 -					clockTicks = profilingTicks;
 86.3918 -				}
 86.3919 -			}
 86.3920 -#endif
 86.3921 -		}
 86.3922 -
 86.3923 -		cpuLoopTicks -= clockTicks;
 86.3924 -		if ((cpuLoopTicks <= 0))
 86.3925 -		{
 86.3926 -			if (cpuSavedTicks)
 86.3927 -			{
 86.3928 -				clockTicks = cpuSavedTicks; // + cpuLoopTicks;
 86.3929 -			}
 86.3930 -			cpuDmaTicksToUpdate = -cpuLoopTicks;
 86.3931 -
 86.3932 -updateLoop:
 86.3933 -			lcdTicks -= clockTicks;
 86.3934 -
 86.3935 -			if (lcdTicks <= 0)
 86.3936 -			{
 86.3937 -				if (DISPSTAT & 1) // V-BLANK
 86.3938 -				{ // if in V-Blank mode, keep computing...
 86.3939 -					if (DISPSTAT & 2)
 86.3940 -					{
 86.3941 -						lcdTicks += 960;
 86.3942 -						VCOUNT++;
 86.3943 -						UPDATE_REG(0x06, VCOUNT);
 86.3944 -						DISPSTAT &= 0xFFFD;
 86.3945 -						UPDATE_REG(0x04, DISPSTAT);
 86.3946 -						CPUCompareVCOUNT();
 86.3947 -					}
 86.3948 -					else
 86.3949 -					{
 86.3950 -						lcdTicks += 272;
 86.3951 -						DISPSTAT |= 2;
 86.3952 -						UPDATE_REG(0x04, DISPSTAT);
 86.3953 -						if (DISPSTAT & 16)
 86.3954 -						{
 86.3955 -							IF |= 2;
 86.3956 -							UPDATE_REG(0x202, IF);
 86.3957 -						}
 86.3958 -					}
 86.3959 -
 86.3960 -					if (VCOUNT >= 228)
 86.3961 -					{
 86.3962 -						DISPSTAT &= 0xFFFC;
 86.3963 -						UPDATE_REG(0x04, DISPSTAT);
 86.3964 -						VCOUNT = 0;
 86.3965 -						UPDATE_REG(0x06, VCOUNT);
 86.3966 -						CPUCompareVCOUNT();
 86.3967 -					}
 86.3968 -				}
 86.3969 -				else
 86.3970 -				{
 86.3971 -					int framesToSkip = systemFramesToSkip();
 86.3972 -
 86.3973 -					if (DISPSTAT & 2)
 86.3974 -					{
 86.3975 -						// if in H-Blank, leave it and move to drawing mode
 86.3976 -						VCOUNT++;
 86.3977 -						UPDATE_REG(0x06, VCOUNT);
 86.3978 -
 86.3979 -						lcdTicks += 960;
 86.3980 -						DISPSTAT &= 0xFFFD;
 86.3981 -						if (VCOUNT == 160)
 86.3982 -						{
 86.3983 -							DISPSTAT |= 1;
 86.3984 -							DISPSTAT &= 0xFFFD;
 86.3985 -							UPDATE_REG(0x04, DISPSTAT);
 86.3986 -							if (DISPSTAT & 0x0008)
 86.3987 -							{
 86.3988 -								IF |= 1;
 86.3989 -								UPDATE_REG(0x202, IF);
 86.3990 -							}
 86.3991 -							CPUCheckDMA(1, 0x0f);
 86.3992 -
 86.3993 -							systemFrame();
 86.3994 -
 86.3995 -							++gbaFrameCount;
 86.3996 -							u32 gbaCurrentTime = systemGetClock();
 86.3997 -							if (gbaCurrentTime - gbaLastTime >= 1000)
 86.3998 -							{
 86.3999 -								systemShowSpeed(int(float(gbaFrameCount) * 100000 / (float(gbaCurrentTime - gbaLastTime) * 60) + .5f));
 86.4000 -								gbaLastTime	  = gbaCurrentTime;
 86.4001 -								gbaFrameCount = 0;
 86.4002 -							}
 86.4003 -
 86.4004 -							++GBASystemCounters.frameCount;
 86.4005 -							if (GBASystemCounters.lagged)
 86.4006 -							{
 86.4007 -								++GBASystemCounters.lagCount;
 86.4008 -							}
 86.4009 -							GBASystemCounters.laggedLast = GBASystemCounters.lagged;
 86.4010 -							GBASystemCounters.lagged	 = true;
 86.4011 -
 86.4012 -							if (cheatsEnabled)
 86.4013 -								cheatsCheckKeys(P1 ^ 0x3FF, extButtons);
 86.4014 -
 86.4015 -							extern void VBAOnEnteringFrameBoundary();
 86.4016 -							VBAOnEnteringFrameBoundary();
 86.4017 -
 86.4018 -							newFrame = true;
 86.4019 -
 86.4020 -							pauseAfterFrameAdvance = systemPauseOnFrame();
 86.4021 -
 86.4022 -							if (frameSkipCount >= framesToSkip || pauseAfterFrameAdvance)
 86.4023 -							{
 86.4024 -								systemRenderFrame();
 86.4025 -								frameSkipCount = 0;
 86.4026 -
 86.4027 -								bool capturePressed = (extButtons & 2) != 0;
 86.4028 -								if (capturePressed && !capturePrevious)
 86.4029 -								{
 86.4030 -									captureNumber = systemScreenCapture(captureNumber);
 86.4031 -								}
 86.4032 -								capturePrevious = capturePressed && !pauseAfterFrameAdvance;
 86.4033 -							}
 86.4034 -							else
 86.4035 -							{
 86.4036 -								++frameSkipCount;
 86.4037 -							}
 86.4038 -
 86.4039 -							if (pauseAfterFrameAdvance)
 86.4040 -							{
 86.4041 -								systemSetPause(true);
 86.4042 -							}
 86.4043 -						}
 86.4044 -
 86.4045 -						UPDATE_REG(0x04, DISPSTAT);
 86.4046 -						CPUCompareVCOUNT();
 86.4047 -					}
 86.4048 -					else
 86.4049 -					{
 86.4050 -						if (frameSkipCount >= framesToSkip || pauseAfterFrameAdvance)
 86.4051 -						{
 86.4052 -							(*renderLine)();
 86.4053 -
 86.4054 -							switch (systemColorDepth)
 86.4055 -							{
 86.4056 -							case 16:
 86.4057 -							{
 86.4058 -								u16 *dest = (u16 *)pix + 242 * (VCOUNT + 1);
 86.4059 -								for (int x = 0; x < 240; )
 86.4060 -								{
 86.4061 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4062 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4063 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4064 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4065 -
 86.4066 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4067 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4068 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4069 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4070 -
 86.4071 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4072 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4073 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4074 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4075 -
 86.4076 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4077 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4078 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4079 -									*dest++ = systemColorMap16[lineMix[x++] & 0xFFFF];
 86.4080 -								}
 86.4081 -								// for filters that read past the screen
 86.4082 -								*dest++ = 0;
 86.4083 -								break;
 86.4084 -							}
 86.4085 -							case 24:
 86.4086 -							{
 86.4087 -								u8 *dest = (u8 *)pix + 240 * VCOUNT * 3;
 86.4088 -								for (int x = 0; x < 240; )
 86.4089 -								{
 86.4090 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4091 -									dest += 3;
 86.4092 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4093 -									dest += 3;
 86.4094 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4095 -									dest += 3;
 86.4096 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4097 -									dest += 3;
 86.4098 -
 86.4099 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4100 -									dest += 3;
 86.4101 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4102 -									dest += 3;
 86.4103 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4104 -									dest += 3;
 86.4105 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4106 -									dest += 3;
 86.4107 -
 86.4108 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4109 -									dest += 3;
 86.4110 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4111 -									dest += 3;
 86.4112 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4113 -									dest += 3;
 86.4114 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4115 -									dest += 3;
 86.4116 -
 86.4117 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4118 -									dest += 3;
 86.4119 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4120 -									dest += 3;
 86.4121 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4122 -									dest += 3;
 86.4123 -									*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4124 -									dest += 3;
 86.4125 -								}
 86.4126 -								break;
 86.4127 -							}
 86.4128 -							case 32:
 86.4129 -							{
 86.4130 -								u32 *dest = (u32 *)pix + 241 * (VCOUNT + 1);
 86.4131 -								for (int x = 0; x < 240; )
 86.4132 -								{
 86.4133 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4134 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4135 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4136 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4137 -
 86.4138 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4139 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4140 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4141 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4142 -
 86.4143 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4144 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4145 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4146 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4147 -
 86.4148 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4149 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4150 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4151 -									*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
 86.4152 -								}
 86.4153 -								break;
 86.4154 -							}
 86.4155 -							}
 86.4156 -						}
 86.4157 -						// entering H-Blank
 86.4158 -						DISPSTAT |= 2;
 86.4159 -						UPDATE_REG(0x04, DISPSTAT);
 86.4160 -						lcdTicks += 272;
 86.4161 -						CPUCheckDMA(2, 0x0f);
 86.4162 -						if (DISPSTAT & 16)
 86.4163 -						{
 86.4164 -							IF |= 2;
 86.4165 -							UPDATE_REG(0x202, IF);
 86.4166 -						}
 86.4167 -					}
 86.4168 -				}
 86.4169 -			}
 86.4170 -
 86.4171 -			if (!stopState)
 86.4172 -			{
 86.4173 -				if (timer0On)
 86.4174 -				{
 86.4175 -					if (timer0ClockReload == 1)
 86.4176 -					{
 86.4177 -						u32 tm0d = TM0D + clockTicks;
 86.4178 -						if (tm0d > 0xffff)
 86.4179 -						{
 86.4180 -							tm0d += timer0Reload;
 86.4181 -							timerOverflow |= 1;
 86.4182 -							soundTimerOverflow(0);
 86.4183 -							if (TM0CNT & 0x40)
 86.4184 -							{
 86.4185 -								IF |= 0x08;
 86.4186 -								UPDATE_REG(0x202, IF);
 86.4187 -							}
 86.4188 -						}
 86.4189 -						TM0D		= tm0d & 0xFFFF;
 86.4190 -						timer0Ticks = 0x10000 - TM0D;
 86.4191 -						UPDATE_REG(0x100, TM0D);
 86.4192 -					}
 86.4193 -					else
 86.4194 -					{
 86.4195 -						timer0Ticks -= clockTicks;
 86.4196 -						if (timer0Ticks <= 0)
 86.4197 -						{
 86.4198 -							timer0Ticks += timer0ClockReload;
 86.4199 -							TM0D++;
 86.4200 -							if (TM0D == 0)
 86.4201 -							{
 86.4202 -								TM0D = timer0Reload;
 86.4203 -								timerOverflow |= 1;
 86.4204 -								soundTimerOverflow(0);
 86.4205 -								if (TM0CNT & 0x40)
 86.4206 -								{
 86.4207 -									IF |= 0x08;
 86.4208 -									UPDATE_REG(0x202, IF);
 86.4209 -								}
 86.4210 -							}
 86.4211 -							UPDATE_REG(0x100, TM0D);
 86.4212 -						}
 86.4213 -					}
 86.4214 -				}
 86.4215 -
 86.4216 -				if (timer1On)
 86.4217 -				{
 86.4218 -					if (TM1CNT & 4)
 86.4219 -					{
 86.4220 -						if (timerOverflow & 1)
 86.4221 -						{
 86.4222 -							TM1D++;
 86.4223 -							if (TM1D == 0)
 86.4224 -							{
 86.4225 -								TM1D += timer1Reload;
 86.4226 -								timerOverflow |= 2;
 86.4227 -								soundTimerOverflow(1);
 86.4228 -								if (TM1CNT & 0x40)
 86.4229 -								{
 86.4230 -									IF |= 0x10;
 86.4231 -									UPDATE_REG(0x202, IF);
 86.4232 -								}
 86.4233 -							}
 86.4234 -							UPDATE_REG(0x104, TM1D);
 86.4235 -						}
 86.4236 -					}
 86.4237 -					else
 86.4238 -					{
 86.4239 -						if (timer1ClockReload == 1)
 86.4240 -						{
 86.4241 -							u32 tm1d = TM1D + clockTicks;
 86.4242 -							if (tm1d > 0xffff)
 86.4243 -							{
 86.4244 -								tm1d += timer1Reload;
 86.4245 -								timerOverflow |= 2;
 86.4246 -								soundTimerOverflow(1);
 86.4247 -								if (TM1CNT & 0x40)
 86.4248 -								{
 86.4249 -									IF |= 0x10;
 86.4250 -									UPDATE_REG(0x202, IF);
 86.4251 -								}
 86.4252 -							}
 86.4253 -							TM1D		= tm1d & 0xFFFF;
 86.4254 -							timer1Ticks = 0x10000 - TM1D;
 86.4255 -							UPDATE_REG(0x104, TM1D);
 86.4256 -						}
 86.4257 -						else
 86.4258 -						{
 86.4259 -							timer1Ticks -= clockTicks;
 86.4260 -							if (timer1Ticks <= 0)
 86.4261 -							{
 86.4262 -								timer1Ticks += timer1ClockReload;
 86.4263 -								TM1D++;
 86.4264 -
 86.4265 -								if (TM1D == 0)
 86.4266 -								{
 86.4267 -									TM1D = timer1Reload;
 86.4268 -									timerOverflow |= 2;
 86.4269 -									soundTimerOverflow(1);
 86.4270 -									if (TM1CNT & 0x40)
 86.4271 -									{
 86.4272 -										IF |= 0x10;
 86.4273 -										UPDATE_REG(0x202, IF);
 86.4274 -									}
 86.4275 -								}
 86.4276 -								UPDATE_REG(0x104, TM1D);
 86.4277 -							}
 86.4278 -						}
 86.4279 -					}
 86.4280 -				}
 86.4281 -
 86.4282 -				if (timer2On)
 86.4283 -				{
 86.4284 -					if (TM2CNT & 4)
 86.4285 -					{
 86.4286 -						if (timerOverflow & 2)
 86.4287 -						{
 86.4288 -							TM2D++;
 86.4289 -							if (TM2D == 0)
 86.4290 -							{
 86.4291 -								TM2D += timer2Reload;
 86.4292 -								timerOverflow |= 4;
 86.4293 -								if (TM2CNT & 0x40)
 86.4294 -								{
 86.4295 -									IF |= 0x20;
 86.4296 -									UPDATE_REG(0x202, IF);
 86.4297 -								}
 86.4298 -							}
 86.4299 -							UPDATE_REG(0x108, TM2D);
 86.4300 -						}
 86.4301 -					}
 86.4302 -					else
 86.4303 -					{
 86.4304 -						if (timer2ClockReload == 1)
 86.4305 -						{
 86.4306 -							u32 tm2d = TM2D + clockTicks;
 86.4307 -							if (tm2d > 0xffff)
 86.4308 -							{
 86.4309 -								tm2d += timer2Reload;
 86.4310 -								timerOverflow |= 4;
 86.4311 -								if (TM2CNT & 0x40)
 86.4312 -								{
 86.4313 -									IF |= 0x20;
 86.4314 -									UPDATE_REG(0x202, IF);
 86.4315 -								}
 86.4316 -							}
 86.4317 -							TM2D		= tm2d & 0xFFFF;
 86.4318 -							timer2Ticks = 0x10000 - TM2D;
 86.4319 -							UPDATE_REG(0x108, TM2D);
 86.4320 -						}
 86.4321 -						else
 86.4322 -						{
 86.4323 -							timer2Ticks -= clockTicks;
 86.4324 -							if (timer2Ticks <= 0)
 86.4325 -							{
 86.4326 -								timer2Ticks += timer2ClockReload;
 86.4327 -								TM2D++;
 86.4328 -
 86.4329 -								if (TM2D == 0)
 86.4330 -								{
 86.4331 -									TM2D = timer2Reload;
 86.4332 -									timerOverflow |= 4;
 86.4333 -									if (TM2CNT & 0x40)
 86.4334 -									{
 86.4335 -										IF |= 0x20;
 86.4336 -										UPDATE_REG(0x202, IF);
 86.4337 -									}
 86.4338 -								}
 86.4339 -								UPDATE_REG(0x108, TM2D);
 86.4340 -							}
 86.4341 -						}
 86.4342 -					}
 86.4343 -				}
 86.4344 -
 86.4345 -				if (timer3On)
 86.4346 -				{
 86.4347 -					if (TM3CNT & 4)
 86.4348 -					{
 86.4349 -						if (timerOverflow & 4)
 86.4350 -						{
 86.4351 -							TM3D++;
 86.4352 -							if (TM3D == 0)
 86.4353 -							{
 86.4354 -								TM3D += timer3Reload;
 86.4355 -								if (TM3CNT & 0x40)
 86.4356 -								{
 86.4357 -									IF |= 0x40;
 86.4358 -									UPDATE_REG(0x202, IF);
 86.4359 -								}
 86.4360 -							}
 86.4361 -							UPDATE_REG(0x10c, TM3D);
 86.4362 -						}
 86.4363 -					}
 86.4364 -					else
 86.4365 -					{
 86.4366 -						if (timer3ClockReload == 1)
 86.4367 -						{
 86.4368 -							u32 tm3d = TM3D + clockTicks;
 86.4369 -							if (tm3d > 0xffff)
 86.4370 -							{
 86.4371 -								tm3d += timer3Reload;
 86.4372 -								if (TM3CNT & 0x40)
 86.4373 -								{
 86.4374 -									IF |= 0x40;
 86.4375 -									UPDATE_REG(0x202, IF);
 86.4376 -								}
 86.4377 -							}
 86.4378 -							TM3D		= tm3d & 0xFFFF;
 86.4379 -							timer3Ticks = 0x10000 - TM3D;
 86.4380 -							UPDATE_REG(0x10C, TM3D);
 86.4381 -						}
 86.4382 -						else
 86.4383 -						{
 86.4384 -							timer3Ticks -= clockTicks;
 86.4385 -							if (timer3Ticks <= 0)
 86.4386 -							{
 86.4387 -								timer3Ticks += timer3ClockReload;
 86.4388 -								TM3D++;
 86.4389 -
 86.4390 -								if (TM3D == 0)
 86.4391 -								{
 86.4392 -									TM3D = timer3Reload;
 86.4393 -									if (TM3CNT & 0x40)
 86.4394 -									{
 86.4395 -										IF |= 0x40;
 86.4396 -										UPDATE_REG(0x202, IF);
 86.4397 -									}
 86.4398 -								}
 86.4399 -								UPDATE_REG(0x10C, TM3D);
 86.4400 -							}
 86.4401 -						}
 86.4402 -					}
 86.4403 -				}
 86.4404 -			}
 86.4405 -			// we shouldn't be doing sound in stop state, but we lose synchronization
 86.4406 -			// if sound is disabled, so in stop state, soundTick will just produce
 86.4407 -			// mute sound
 86.4408 -			soundTicks -= clockTicks;
 86.4409 -			if (soundTicks < 1)
 86.4410 -			{
 86.4411 -				soundTick();
 86.4412 -				soundTicks += SOUND_CLOCK_TICKS;
 86.4413 -			}
 86.4414 -			timerOverflow = 0;
 86.4415 -
 86.4416 -#ifdef PROFILING
 86.4417 -			profilingTicks -= clockTicks;
 86.4418 -			if (profilingTicks <= 0)
 86.4419 -			{
 86.4420 -				profilingTicks += profilingTicksReload;
 86.4421 -				if (profilBuffer && profilSize)
 86.4422 -				{
 86.4423 -					u16 *b	= (u16 *)profilBuffer;
 86.4424 -					int	 pc = ((reg[15].I - profilLowPC) * profilScale) / 0x10000;
 86.4425 -					if (pc >= 0 && pc < profilSize)
 86.4426 -					{
 86.4427 -						b[pc]++;
 86.4428 -					}
 86.4429 -				}
 86.4430 -			}
 86.4431 -#endif
 86.4432 -
 86.4433 -			ticks		-= clockTicks;
 86.4434 -			cpuLoopTicks = CPUUpdateTicks();
 86.4435 -
 86.4436 -			// FIXME: it is too bad that it is still not determined whether the loop can be exited at this point
 86.4437 -			if (cpuDmaTicksToUpdate > 0)
 86.4438 -			{
 86.4439 -				clockTicks = cpuSavedTicks;
 86.4440 -				if (clockTicks > cpuDmaTicksToUpdate)
 86.4441 -					clockTicks = cpuDmaTicksToUpdate;
 86.4442 -				cpuDmaTicksToUpdate -= clockTicks;
 86.4443 -				if (cpuDmaTicksToUpdate < 0)
 86.4444 -					cpuDmaTicksToUpdate = 0;
 86.4445 -				goto updateLoop;    // this is evil
 86.4446 -			}
 86.4447 -
 86.4448 -			if (IF && (IME & 1) && armIrqEnable)
 86.4449 -			{
 86.4450 -				int res = IF & IE;
 86.4451 -				if (stopState)
 86.4452 -					res &= 0x3080;
 86.4453 -				if (res)
 86.4454 -				{
 86.4455 -					if (intState)
 86.4456 -					{
 86.4457 -						CPUInterrupt();
 86.4458 -						intState = false;
 86.4459 -						if (holdState)
 86.4460 -						{
 86.4461 -							holdState = false;
 86.4462 -							stopState = false;
 86.4463 -						}
 86.4464 -					}
 86.4465 -					else
 86.4466 -					{
 86.4467 -						if (!holdState)
 86.4468 -						{
 86.4469 -							intState	  = true;
 86.4470 -							cpuLoopTicks  = 5;
 86.4471 -							cpuSavedTicks = 5;
 86.4472 -						}
 86.4473 -						else
 86.4474 -						{
 86.4475 -							CPUInterrupt();
 86.4476 -							if (holdState)
 86.4477 -							{
 86.4478 -								holdState = false;
 86.4479 -								stopState = false;
 86.4480 -							}
 86.4481 -						}
 86.4482 -					}
 86.4483 -				}
 86.4484 -			}
 86.4485 -
 86.4486 -			if (useOldFrameTiming)
 86.4487 -			{
 86.4488 -				if (ticks <= 0)
 86.4489 -				{
 86.4490 -					newFrame = true;
 86.4491 -					break;
 86.4492 -				}
 86.4493 -			}
 86.4494 -			else if (newFrame)
 86.4495 -			{
 86.4496 -				// FIXME: it should be enough to use frameBoundary only if there were no need for supporting the old timing
 86.4497 -				// but is there still any GBA .vbm that uses the old timing?
 86.4498 -///				extern void VBAOnEnteringFrameBoundary();
 86.4499 -///				VBAOnEnteringFrameBoundary();
 86.4500 -
 86.4501 -				break;
 86.4502 -			}
 86.4503 -		}
 86.4504 -	}
 86.4505 -}
 86.4506 -
 86.4507 -struct EmulatedSystem GBASystem =
 86.4508 -{
 86.4509 -	// emuMain
 86.4510 -	CPULoop,
 86.4511 -	// emuReset
 86.4512 -	CPUReset,
 86.4513 -	// emuCleanUp
 86.4514 -	CPUCleanUp,
 86.4515 -	// emuReadBattery
 86.4516 -	CPUReadBatteryFile,
 86.4517 -	// emuWriteBattery
 86.4518 -	CPUWriteBatteryFile,
 86.4519 -	// emuReadBatteryFromStream
 86.4520 -	CPUReadBatteryFromStream,
 86.4521 -	// emuWriteBatteryToStream
 86.4522 -	CPUWriteBatteryToStream,
 86.4523 -	// emuReadState
 86.4524 -	CPUReadState,
 86.4525 -	// emuWriteState
 86.4526 -	CPUWriteState,
 86.4527 -	// emuReadStateFromStream
 86.4528 -	CPUReadStateFromStream,
 86.4529 -	// emuWriteStateToStream
 86.4530 -	CPUWriteStateToStream,
 86.4531 -	// emuReadMemState
 86.4532 -	CPUReadMemState,
 86.4533 -	// emuWriteMemState
 86.4534 -	CPUWriteMemState,
 86.4535 -	// emuWritePNG
 86.4536 -	CPUWritePNGFile,
 86.4537 -	// emuWriteBMP
 86.4538 -	CPUWriteBMPFile,
 86.4539 -	// emuUpdateCPSR
 86.4540 -	CPUUpdateCPSR,
 86.4541 -	// emuHasDebugger
 86.4542 -	true,
 86.4543 -	// emuCount
 86.4544 -#ifdef FINAL_VERSION
 86.4545 -	250000,
 86.4546 -#else
 86.4547 -	5000,
 86.4548 -#endif
 86.4549 -};
 86.4550 -
 86.4551 -// is there a reason to use more than one set of counters?
 86.4552 -EmulatedSystemCounters &GBASystemCounters = systemCounters;
 86.4553 -
 86.4554 -/*
 86.4555 -   EmulatedSystemCounters GBASystemCounters =
 86.4556 -   {
 86.4557 -    // frameCount
 86.4558 -    0,
 86.4559 -    // lagCount
 86.4560 -    0,
 86.4561 -    // lagged
 86.4562 -    true,
 86.4563 -    // laggedLast
 86.4564 -    true,
 86.4565 -   };
 86.4566 - */
 86.4567 -
 86.4568 -
 86.4569 -#undef CPU_BREAK_LOOP
 86.4570 -#undef CPU_BREAK_LOOP2
    87.1 --- a/src/gba/GBA.h	Sat Mar 03 10:54:39 2012 -0600
    87.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.3 @@ -1,122 +0,0 @@
    87.4 -#ifndef VBA_GBA_H
    87.5 -#define VBA_GBA_H
    87.6 -
    87.7 -#if _MSC_VER > 1000
    87.8 -#pragma once
    87.9 -#endif // _MSC_VER > 1000
   87.10 -
   87.11 -#include "zlib.h"
   87.12 -#include "../Port.h"
   87.13 -
   87.14 -#if (defined(WIN32) && !defined(SDL))
   87.15 -#include "../win32/stdafx.h" // for HANDLE
   87.16 -//#include <windows.h> // for HANDLE
   87.17 -// NOTE: if you get this error:
   87.18 -// #error WINDOWS.H already included.  MFC apps must not #include <windows.h>
   87.19 -// it is probably because stdafx.h is getting included at the wrong place
   87.20 -// (i.e. after anything else) in a file, or your precompiled headers are otherwise wrong
   87.21 -#endif
   87.22 -
   87.23 -#define SAVE_GAME_VERSION_1 1
   87.24 -#define SAVE_GAME_VERSION_2 2
   87.25 -#define SAVE_GAME_VERSION_3 3
   87.26 -#define SAVE_GAME_VERSION_4 4
   87.27 -#define SAVE_GAME_VERSION_5 5
   87.28 -#define SAVE_GAME_VERSION_6 6
   87.29 -#define SAVE_GAME_VERSION_7 7
   87.30 -#define SAVE_GAME_VERSION_8 8
   87.31 -#define SAVE_GAME_VERSION_9 9
   87.32 -#define SAVE_GAME_VERSION_10 10
   87.33 -#define SAVE_GAME_VERSION_11 11
   87.34 -#define SAVE_GAME_VERSION_12 12
   87.35 -#define SAVE_GAME_VERSION_13 13
   87.36 -#define SAVE_GAME_VERSION  SAVE_GAME_VERSION_13
   87.37 -
   87.38 -#if (defined(WIN32) && !defined(SDL))
   87.39 -extern HANDLE mapROM;        // shared memory handles
   87.40 -extern HANDLE mapWORKRAM;
   87.41 -extern HANDLE mapBIOS;
   87.42 -extern HANDLE mapIRAM;
   87.43 -extern HANDLE mapPALETTERAM;
   87.44 -extern HANDLE mapVRAM;
   87.45 -extern HANDLE mapOAM;
   87.46 -extern HANDLE mapPIX;
   87.47 -extern HANDLE mapIOMEM;
   87.48 -#endif
   87.49 -
   87.50 -/*
   87.51 -extern reg_pair reg[45];
   87.52 -extern u8       biosProtected[4];
   87.53 -
   87.54 -extern bool8 N_FLAG;
   87.55 -extern bool8 Z_FLAG;
   87.56 -extern bool8 C_FLAG;
   87.57 -extern bool8 V_FLAG;
   87.58 -extern bool8 armIrqEnable;
   87.59 -extern bool8 armState;
   87.60 -extern int32 armMode;
   87.61 -*/
   87.62 -extern void  (*cpuSaveGameFunc)(u32, u8);
   87.63 -
   87.64 -extern bool8 freezeWorkRAM[0x40000];
   87.65 -extern bool8 freezeInternalRAM[0x8000];
   87.66 -extern bool CPUReadGSASnapshot(const char *);
   87.67 -extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
   87.68 -extern bool CPUWriteBatteryFile(const char *);
   87.69 -extern bool CPUReadBatteryFile(const char *);
   87.70 -extern bool CPUWriteBatteryToStream(gzFile);
   87.71 -extern bool CPUReadBatteryFromStream(gzFile);
   87.72 -extern bool CPUExportEepromFile(const char *);
   87.73 -extern bool CPUImportEepromFile(const char *);
   87.74 -extern bool CPUWritePNGFile(const char *);
   87.75 -extern bool CPUWriteBMPFile(const char *);
   87.76 -extern void CPUCleanUp();
   87.77 -extern void CPUUpdateRender();
   87.78 -extern void CPUUpdateRenderBuffers(bool force);
   87.79 -extern bool CPUReadMemState(char *, int);
   87.80 -extern bool CPUReadState(const char *);
   87.81 -extern bool CPUWriteMemState(char *, int);
   87.82 -extern bool CPUWriteState(const char *);
   87.83 -extern bool CPUReadStateFromStream(gzFile);
   87.84 -extern bool CPUWriteStateToStream(gzFile);
   87.85 -extern int CPULoadRom(const char *);
   87.86 -extern void CPUUpdateRegister(u32, u16);
   87.87 -extern void CPUWriteHalfWord(u32, u16);
   87.88 -extern void CPUWriteByte(u32, u8);
   87.89 -extern bool CPULoadBios(const char *, bool);
   87.90 -extern void CPUInit();
   87.91 -extern void CPUReset(bool userReset = false);
   87.92 -extern void CPULoop(int);
   87.93 -extern void CPUCheckDMA(int, int);
   87.94 -#ifdef PROFILING
   87.95 -extern void cpuProfil(char *buffer, int, u32, int);
   87.96 -extern void cpuEnableProfiling(int hz);
   87.97 -#endif
   87.98 -
   87.99 -extern struct EmulatedSystem GBASystem;
  87.100 -extern struct EmulatedSystemCounters &GBASystemCounters;
  87.101 -
  87.102 -#define R13_IRQ  18
  87.103 -#define R14_IRQ  19
  87.104 -#define SPSR_IRQ 20
  87.105 -#define R13_USR  26
  87.106 -#define R14_USR  27
  87.107 -#define R13_SVC  28
  87.108 -#define R14_SVC  29
  87.109 -#define SPSR_SVC 30
  87.110 -#define R13_ABT  31
  87.111 -#define R14_ABT  32
  87.112 -#define SPSR_ABT 33
  87.113 -#define R13_UND  34
  87.114 -#define R14_UND  35
  87.115 -#define SPSR_UND 36
  87.116 -#define R8_FIQ   37
  87.117 -#define R9_FIQ   38
  87.118 -#define R10_FIQ  39
  87.119 -#define R11_FIQ  40
  87.120 -#define R12_FIQ  41
  87.121 -#define R13_FIQ  42
  87.122 -#define R14_FIQ  43
  87.123 -#define SPSR_FIQ 44
  87.124 -
  87.125 -#endif // VBA_GBA_H
    88.1 --- a/src/gba/GBACheats.cpp	Sat Mar 03 10:54:39 2012 -0600
    88.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.3 @@ -1,1822 +0,0 @@
    88.4 -#include <cstdio>
    88.5 -#include <cctype>
    88.6 -#include <cstring>
    88.7 -
    88.8 -#include "../common/System.h"
    88.9 -#include "../common/Util.h"
   88.10 -#include "../NLS.h"
   88.11 -#include "GBACheats.h"
   88.12 -#include "GBA.h"
   88.13 -#include "GBAinline.h"
   88.14 -#include "GBAGlobals.h"
   88.15 -
   88.16 -/**
   88.17 - * Gameshark code types:
   88.18 - *
   88.19 - * NNNNNNNN 001DC0DE - ID code for the game (game 4 character name) from ROM
   88.20 - * DEADFACE XXXXXXXX - changes decryption seeds
   88.21 - * 0AAAAAAA 000000YY - 8-bit constant write
   88.22 - * 1AAAAAAA 0000YYYY - 16-bit constant write
   88.23 - * 2AAAAAAA YYYYYYYY - 32-bit constant write
   88.24 - * 3AAAAAAA YYYYYYYY - ??
   88.25 - * 6AAAAAAA 0000YYYY - 16-bit ROM Patch (address >> 1)
   88.26 - * 6AAAAAAA 1000YYYY - 16-bit ROM Patch ? (address >> 1)
   88.27 - * 6AAAAAAA 2000YYYY - 16-bit ROM Patch ? (address >> 1)
   88.28 - * 8A1AAAAA 000000YY - 8-bit button write
   88.29 - * 8A2AAAAA 0000YYYY - 16-bit button write
   88.30 - * 8A3AAAAA YYYYYYYY - 32-bit button write
   88.31 - * 80F00000 0000YYYY - button slow motion
   88.32 - * DAAAAAAA 0000YYYY - if address contains 16-bit value enable next code
   88.33 - * FAAAAAAA 0000YYYY - Master code function
   88.34 - *
   88.35 - * CodeBreaker codes types:
   88.36 - *
   88.37 - * 0000AAAA 000Y - Game CRC (Y are flags: 8 - CRC, 2 - DI)
   88.38 - * 1AAAAAAA YYYY - Master Code function (store address at ((YYYY << 0x16)
   88.39 - *                 + 0x08000100))
   88.40 - * 2AAAAAAA YYYY - 16-bit or
   88.41 - * 3AAAAAAA YYYY - 8-bit constant write
   88.42 - * 4AAAAAAA YYYY - Slide code
   88.43 - * XXXXCCCC IIII   (C is count and I is address increment, X is value incr.)
   88.44 - * 5AAAAAAA CCCC - Super code (Write bytes to address, CCCC is count)
   88.45 - * BBBBBBBB BBBB
   88.46 - * 6AAAAAAA YYYY - 16-bit and
   88.47 - * 7AAAAAAA YYYY - if address contains 16-bit value enable next code
   88.48 - * 8AAAAAAA YYYY - 16-bit constant write
   88.49 - * 9AAAAAAA YYYY - change decryption (when first code only?)
   88.50 - * AAAAAAAA YYYY - if address does not contain 16-bit value enable next code
   88.51 - * BAAAAAAA YYYY - if 16-bit < YYYY
   88.52 - * CAAAAAAA YYYY - if 16-bit > YYYY
   88.53 - * D0000020 YYYY - if button keys equal value enable next code
   88.54 - * EAAAAAAA YYYY - increase value stored in address
   88.55 - */
   88.56 -#define UNKNOWN_CODE           -1
   88.57 -#define INT_8_BIT_WRITE        0
   88.58 -#define INT_16_BIT_WRITE       1
   88.59 -#define INT_32_BIT_WRITE       2
   88.60 -#define GSA_16_BIT_ROM_PATCH   3
   88.61 -#define GSA_8_BIT_GS_WRITE     4
   88.62 -#define GSA_16_BIT_GS_WRITE    5
   88.63 -#define GSA_32_BIT_GS_WRITE    6
   88.64 -#define CBA_IF_KEYS_PRESSED    7
   88.65 -#define CBA_IF_TRUE            8
   88.66 -#define CBA_SLIDE_CODE         9
   88.67 -#define CBA_IF_FALSE           10
   88.68 -#define CBA_AND                11
   88.69 -#define GSA_8_BIT_GS_WRITE2    12
   88.70 -#define GSA_16_BIT_GS_WRITE2   13
   88.71 -#define GSA_32_BIT_GS_WRITE2   14
   88.72 -#define GSA_16_BIT_ROM_PATCH2  15
   88.73 -#define GSA_8_BIT_SLIDE        16
   88.74 -#define GSA_16_BIT_SLIDE       17
   88.75 -#define GSA_32_BIT_SLIDE       18
   88.76 -#define GSA_8_BIT_IF_TRUE      19
   88.77 -#define GSA_32_BIT_IF_TRUE     20
   88.78 -#define GSA_8_BIT_IF_FALSE     21
   88.79 -#define GSA_32_BIT_IF_FALSE    22
   88.80 -#define GSA_8_BIT_FILL         23
   88.81 -#define GSA_16_BIT_FILL        24
   88.82 -#define GSA_8_BIT_IF_TRUE2     25
   88.83 -#define GSA_16_BIT_IF_TRUE2    26
   88.84 -#define GSA_32_BIT_IF_TRUE2    27
   88.85 -#define GSA_8_BIT_IF_FALSE2    28
   88.86 -#define GSA_16_BIT_IF_FALSE2   29
   88.87 -#define GSA_32_BIT_IF_FALSE2   30
   88.88 -#define GSA_SLOWDOWN           31
   88.89 -#define CBA_ADD                32
   88.90 -#define CBA_OR                 33
   88.91 -#define CBA_LT                 34
   88.92 -#define CBA_GT                 35
   88.93 -#define CBA_SUPER              36
   88.94 -
   88.95 -CheatsData cheatsList[100];
   88.96 -int        cheatsNumber = 0;
   88.97 -
   88.98 -u8   cheatsCBASeedBuffer[0x30];
   88.99 -u32  cheatsCBASeed[4];
  88.100 -u32  cheatsCBATemporaryValue = 0;
  88.101 -u16  cheatsCBATable[256];
  88.102 -bool cheatsCBATableGenerated = false;
  88.103 -
  88.104 -u8 cheatsCBACurrentSeed[12] = {
  88.105 -	0x00, 0x00, 0x00, 0x00,
  88.106 -	0x00, 0x00, 0x00, 0x00,
  88.107 -	0x00, 0x00, 0x00, 0x00
  88.108 -};
  88.109 -
  88.110 -#define CHEAT_IS_HEX(a) (((a) >= 'A' && (a) <= 'F') || ((a) >= '0' && (a) <= '9'))
  88.111 -
  88.112 -#define CHEAT_PATCH_ROM_16BIT(a, v) \
  88.113 -    WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v);
  88.114 -
  88.115 -static bool isMultilineWithData(int i)
  88.116 -{
  88.117 -	// we consider it a multiline code if it has more than one line of data
  88.118 -	// otherwise, it can still be considered a single code
  88.119 -	if (i < cheatsNumber && i >= 0)
  88.120 -		switch (cheatsList[i].size)
  88.121 -		{
  88.122 -		case INT_8_BIT_WRITE:
  88.123 -		case INT_16_BIT_WRITE:
  88.124 -		case INT_32_BIT_WRITE:
  88.125 -		case GSA_16_BIT_ROM_PATCH:
  88.126 -		case GSA_8_BIT_GS_WRITE:
  88.127 -		case GSA_16_BIT_GS_WRITE:
  88.128 -		case GSA_32_BIT_GS_WRITE:
  88.129 -		case CBA_AND:
  88.130 -		case CBA_IF_KEYS_PRESSED:
  88.131 -		case CBA_IF_TRUE:
  88.132 -		case CBA_IF_FALSE:
  88.133 -		case GSA_8_BIT_IF_TRUE:
  88.134 -		case GSA_32_BIT_IF_TRUE:
  88.135 -		case GSA_8_BIT_IF_FALSE:
  88.136 -		case GSA_32_BIT_IF_FALSE:
  88.137 -		case GSA_8_BIT_FILL:
  88.138 -		case GSA_16_BIT_FILL:
  88.139 -		case GSA_8_BIT_IF_TRUE2:
  88.140 -		case GSA_16_BIT_IF_TRUE2:
  88.141 -		case GSA_32_BIT_IF_TRUE2:
  88.142 -		case GSA_8_BIT_IF_FALSE2:
  88.143 -		case GSA_16_BIT_IF_FALSE2:
  88.144 -		case GSA_32_BIT_IF_FALSE2:
  88.145 -		case GSA_SLOWDOWN:
  88.146 -		case CBA_ADD:
  88.147 -		case CBA_OR:
  88.148 -			return false;
  88.149 -		// the codes below have two lines of data
  88.150 -		case CBA_SLIDE_CODE:
  88.151 -		case GSA_8_BIT_GS_WRITE2:
  88.152 -		case GSA_16_BIT_GS_WRITE2:
  88.153 -		case GSA_32_BIT_GS_WRITE2:
  88.154 -		case GSA_16_BIT_ROM_PATCH2:
  88.155 -		case GSA_8_BIT_SLIDE:
  88.156 -		case GSA_16_BIT_SLIDE:
  88.157 -		case GSA_32_BIT_SLIDE:
  88.158 -		case CBA_LT:
  88.159 -		case CBA_GT:
  88.160 -		case CBA_SUPER:
  88.161 -			return true;
  88.162 -		}
  88.163 -	return false;
  88.164 -}
  88.165 -
  88.166 -static int getCodeLength(int num)
  88.167 -{
  88.168 -	if (num >= cheatsNumber || num < 0)
  88.169 -		return 1;
  88.170 -
  88.171 -	// this is for all the codes that are true multiline
  88.172 -	switch (cheatsList[num].size)
  88.173 -	{
  88.174 -	case INT_8_BIT_WRITE:
  88.175 -	case INT_16_BIT_WRITE:
  88.176 -	case INT_32_BIT_WRITE:
  88.177 -	case GSA_16_BIT_ROM_PATCH:
  88.178 -	case GSA_8_BIT_GS_WRITE:
  88.179 -	case GSA_16_BIT_GS_WRITE:
  88.180 -	case GSA_32_BIT_GS_WRITE:
  88.181 -	case CBA_AND:
  88.182 -	case GSA_8_BIT_FILL:
  88.183 -	case GSA_16_BIT_FILL:
  88.184 -	case GSA_SLOWDOWN:
  88.185 -	case CBA_ADD:
  88.186 -	case CBA_OR:
  88.187 -		return 1;
  88.188 -	case CBA_IF_KEYS_PRESSED:
  88.189 -	case CBA_IF_TRUE:
  88.190 -	case CBA_IF_FALSE:
  88.191 -	case CBA_SLIDE_CODE:
  88.192 -	case GSA_8_BIT_GS_WRITE2:
  88.193 -	case GSA_16_BIT_GS_WRITE2:
  88.194 -	case GSA_32_BIT_GS_WRITE2:
  88.195 -	case GSA_16_BIT_ROM_PATCH2:
  88.196 -	case GSA_8_BIT_SLIDE:
  88.197 -	case GSA_16_BIT_SLIDE:
  88.198 -	case GSA_32_BIT_SLIDE:
  88.199 -	case GSA_8_BIT_IF_TRUE:
  88.200 -	case GSA_32_BIT_IF_TRUE:
  88.201 -	case GSA_8_BIT_IF_FALSE:
  88.202 -	case GSA_32_BIT_IF_FALSE:
  88.203 -	case CBA_LT:
  88.204 -	case CBA_GT:
  88.205 -		return 2;
  88.206 -	case GSA_8_BIT_IF_TRUE2:
  88.207 -	case GSA_16_BIT_IF_TRUE2:
  88.208 -	case GSA_32_BIT_IF_TRUE2:
  88.209 -	case GSA_8_BIT_IF_FALSE2:
  88.210 -	case GSA_16_BIT_IF_FALSE2:
  88.211 -	case GSA_32_BIT_IF_FALSE2:
  88.212 -		return 3;
  88.213 -	case CBA_SUPER:
  88.214 -		return (cheatsList[num].value+5)/6;
  88.215 -	}
  88.216 -	return 1;
  88.217 -}
  88.218 -
  88.219 -int cheatsCheckKeys(u32 keys, u32 extended)
  88.220 -{
  88.221 -	int ticks = 0;
  88.222 -	for (int i = 0; i < cheatsNumber; i++)
  88.223 -	{
  88.224 -		if (!cheatsList[i].enabled)
  88.225 -		{
  88.226 -			// make sure we skip other lines in this code
  88.227 -			i += getCodeLength(i)-1;
  88.228 -			continue;
  88.229 -		}
  88.230 -		switch (cheatsList[i].size)
  88.231 -		{
  88.232 -		case INT_8_BIT_WRITE:
  88.233 -			CPUWriteByte(cheatsList[i].address, cheatsList[i].value);
  88.234 -			break;
  88.235 -		case INT_16_BIT_WRITE:
  88.236 -			CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);
  88.237 -			break;
  88.238 -		case INT_32_BIT_WRITE:
  88.239 -			CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
  88.240 -			break;
  88.241 -		case GSA_16_BIT_ROM_PATCH:
  88.242 -			if ((cheatsList[i].status & 1) == 0)
  88.243 -			{
  88.244 -				if (CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value)
  88.245 -				{
  88.246 -					cheatsList[i].oldValue = CPUReadHalfWord(cheatsList[i].address);
  88.247 -					cheatsList[i].status  |= 1;
  88.248 -					CHEAT_PATCH_ROM_16BIT(cheatsList[i].address, cheatsList[i].value);
  88.249 -				}
  88.250 -			}
  88.251 -			break;
  88.252 -		case GSA_8_BIT_GS_WRITE:
  88.253 -			if (extended & 4)
  88.254 -			{
  88.255 -				CPUWriteByte(cheatsList[i].address, cheatsList[i].value);
  88.256 -			}
  88.257 -			break;
  88.258 -		case GSA_16_BIT_GS_WRITE:
  88.259 -			if (extended & 4)
  88.260 -			{
  88.261 -				CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);
  88.262 -			}
  88.263 -			break;
  88.264 -		case GSA_32_BIT_GS_WRITE:
  88.265 -			if (extended & 4)
  88.266 -			{
  88.267 -				CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
  88.268 -			}
  88.269 -			break;
  88.270 -		case CBA_IF_KEYS_PRESSED:
  88.271 -		{
  88.272 -			u16 value = cheatsList[i].value;
  88.273 -			u32 addr  = cheatsList[i].address;
  88.274 -			if ((addr & 0x30) == 0x20)
  88.275 -			{
  88.276 -				if ((keys & value) != value)
  88.277 -				{
  88.278 -					i++;
  88.279 -				}
  88.280 -			}
  88.281 -			else if ((addr & 0x30) == 0x10)
  88.282 -			{
  88.283 -				if ((keys & value) == value)
  88.284 -				{
  88.285 -					i++;
  88.286 -				}
  88.287 -			}
  88.288 -			break;
  88.289 -		}
  88.290 -		case CBA_IF_TRUE:
  88.291 -			if (CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value)
  88.292 -			{
  88.293 -				i++;
  88.294 -			}
  88.295 -			break;
  88.296 -		case CBA_SLIDE_CODE:
  88.297 -		{
  88.298 -			u32 address = cheatsList[i].address;
  88.299 -			u16 value   = cheatsList[i].value;
  88.300 -			i++;
  88.301 -			if (i < cheatsNumber)
  88.302 -			{
  88.303 -				int count = (cheatsList[i].address & 0xFFFF);
  88.304 -				u16 vinc  = (cheatsList[i].address >> 16) & 0xFFFF;
  88.305 -				int inc   = cheatsList[i].value;
  88.306 -
  88.307 -				for (int x = 0; x < count; x++)
  88.308 -				{
  88.309 -					CPUWriteHalfWord(address, value);
  88.310 -					address += inc;
  88.311 -					value   += vinc;
  88.312 -				}
  88.313 -			}
  88.314 -			break;
  88.315 -		}
  88.316 -		case CBA_IF_FALSE:
  88.317 -			if (CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value)
  88.318 -			{
  88.319 -				i++;
  88.320 -			}
  88.321 -			break;
  88.322 -		case CBA_AND:
  88.323 -			CPUWriteHalfWord(cheatsList[i].address,
  88.324 -			                 CPUReadHalfWord(cheatsList[i].address) &
  88.325 -			                 cheatsList[i].value);
  88.326 -			break;
  88.327 -		case GSA_8_BIT_GS_WRITE2:
  88.328 -			i++;
  88.329 -			if (i < cheatsNumber)
  88.330 -			{
  88.331 -				if (extended & 4)
  88.332 -				{
  88.333 -					CPUWriteByte(cheatsList[i-1].value, cheatsList[i].address);
  88.334 -				}
  88.335 -			}
  88.336 -			break;
  88.337 -		case GSA_16_BIT_GS_WRITE2:
  88.338 -			i++;
  88.339 -			if (i < cheatsNumber)
  88.340 -			{
  88.341 -				if (extended & 4)
  88.342 -				{
  88.343 -					CPUWriteHalfWord(cheatsList[i-1].value, cheatsList[i].address);
  88.344 -				}
  88.345 -			}
  88.346 -			break;
  88.347 -		case GSA_32_BIT_GS_WRITE2:
  88.348 -			i++;
  88.349 -			if (i < cheatsNumber)
  88.350 -			{
  88.351 -				if (extended & 4)
  88.352 -				{
  88.353 -					CPUWriteMemory(cheatsList[i-1].value, cheatsList[i].address);
  88.354 -				}
  88.355 -			}
  88.356 -			break;
  88.357 -		case GSA_16_BIT_ROM_PATCH2:
  88.358 -			i++;
  88.359 -			if (i < cheatsNumber)
  88.360 -			{
  88.361 -				if ((cheatsList[i-1].status & 1) == 0)
  88.362 -				{
  88.363 -					u32 addr = ((cheatsList[i-1].value & 0x00FFFFFF) << 1) + 0x8000000;
  88.364 -					if (CPUReadHalfWord(addr) != (cheatsList[i].address & 0xFFFF))
  88.365 -					{
  88.366 -						cheatsList[i-1].oldValue = CPUReadHalfWord(addr);
  88.367 -						cheatsList[i-1].status  |= 1;
  88.368 -						CHEAT_PATCH_ROM_16BIT(addr, cheatsList[i].address & 0xFFFF);
  88.369 -					}
  88.370 -				}
  88.371 -			}
  88.372 -			break;
  88.373 -		case GSA_8_BIT_SLIDE:
  88.374 -			i++;
  88.375 -			if (i < cheatsNumber)
  88.376 -			{
  88.377 -				u32 addr  = cheatsList[i-1].value;
  88.378 -				u8  value = cheatsList[i].address;
  88.379 -				int vinc  = (cheatsList[i].value >> 24) & 255;
  88.380 -				int count = (cheatsList[i].value >> 16) & 255;
  88.381 -				int ainc  = (cheatsList[i].value & 0xffff);
  88.382 -				while (count > 0)
  88.383 -				{
  88.384 -					CPUWriteByte(addr, value);
  88.385 -					value += vinc;
  88.386 -					addr  += ainc;
  88.387 -					count--;
  88.388 -				}
  88.389 -			}
  88.390 -			break;
  88.391 -		case GSA_16_BIT_SLIDE:
  88.392 -			i++;
  88.393 -			if (i < cheatsNumber)
  88.394 -			{
  88.395 -				u32 addr  = cheatsList[i-1].value;
  88.396 -				u16 value = cheatsList[i].address;
  88.397 -				int vinc  = (cheatsList[i].value >> 24) & 255;
  88.398 -				int count = (cheatsList[i].value >> 16) & 255;
  88.399 -				int ainc  = (cheatsList[i].value & 0xffff)*2;
  88.400 -				while (count > 0)
  88.401 -				{
  88.402 -					CPUWriteHalfWord(addr, value);
  88.403 -					value += vinc;
  88.404 -					addr  += ainc;
  88.405 -					count--;
  88.406 -				}
  88.407 -			}
  88.408 -			break;
  88.409 -		case GSA_32_BIT_SLIDE:
  88.410 -			i++;
  88.411 -			if (i < cheatsNumber)
  88.412 -			{
  88.413 -				u32 addr  = cheatsList[i-1].value;
  88.414 -				u32 value = cheatsList[i].address;
  88.415 -				int vinc  = (cheatsList[i].value >> 24) & 255;
  88.416 -				int count = (cheatsList[i].value >> 16) & 255;
  88.417 -				int ainc  = (cheatsList[i].value & 0xffff)*4;
  88.418 -				while (count > 0)
  88.419 -				{
  88.420 -					CPUWriteMemory(addr, value);
  88.421 -					value += vinc;
  88.422 -					addr  += ainc;
  88.423 -					count--;
  88.424 -				}
  88.425 -			}
  88.426 -			break;
  88.427 -		case GSA_8_BIT_IF_TRUE:
  88.428 -			if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value)
  88.429 -			{
  88.430 -				i++;
  88.431 -			}
  88.432 -			break;
  88.433 -		case GSA_32_BIT_IF_TRUE:
  88.434 -			if (CPUReadMemory(cheatsList[i].address) != cheatsList[i].value)
  88.435 -			{
  88.436 -				i++;
  88.437 -			}
  88.438 -			break;
  88.439 -		case GSA_8_BIT_IF_FALSE:
  88.440 -			if (CPUReadByte(cheatsList[i].address) == cheatsList[i].value)
  88.441 -			{
  88.442 -				i++;
  88.443 -			}
  88.444 -			break;
  88.445 -		case GSA_32_BIT_IF_FALSE:
  88.446 -			if (CPUReadMemory(cheatsList[i].address) == cheatsList[i].value)
  88.447 -			{
  88.448 -				i++;
  88.449 -			}
  88.450 -			break;
  88.451 -		case GSA_8_BIT_FILL:
  88.452 -		{
  88.453 -			u32 addr = cheatsList[i].address;
  88.454 -			u8  v    = cheatsList[i].value & 0xff;
  88.455 -			u32 end  = addr + (cheatsList[i].value >> 8);
  88.456 -			do
  88.457 -			{
  88.458 -				CPUWriteByte(addr, v);
  88.459 -				addr++;
  88.460 -			}
  88.461 -			while (addr <= end);
  88.462 -			break;
  88.463 -		}
  88.464 -		case GSA_16_BIT_FILL:
  88.465 -		{
  88.466 -			u32 addr = cheatsList[i].address;
  88.467 -			u16 v    = cheatsList[i].value & 0xffff;
  88.468 -			u32 end  = addr + ((cheatsList[i].value >> 16) << 1);
  88.469 -			do
  88.470 -			{
  88.471 -				CPUWriteHalfWord(addr, v);
  88.472 -				addr += 2;
  88.473 -			}
  88.474 -			while (addr <= end);
  88.475 -			break;
  88.476 -		}
  88.477 -		case GSA_8_BIT_IF_TRUE2:
  88.478 -			if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value)
  88.479 -			{
  88.480 -				i += 2;
  88.481 -			}
  88.482 -			break;
  88.483 -		case GSA_16_BIT_IF_TRUE2:
  88.484 -			if (CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value)
  88.485 -			{
  88.486 -				i += 2;
  88.487 -			}
  88.488 -			break;
  88.489 -		case GSA_32_BIT_IF_TRUE2:
  88.490 -			if (CPUReadMemory(cheatsList[i].address) != cheatsList[i].value)
  88.491 -			{
  88.492 -				i += 2;
  88.493 -			}
  88.494 -			break;
  88.495 -		case GSA_8_BIT_IF_FALSE2:
  88.496 -			if (CPUReadByte(cheatsList[i].address) == cheatsList[i].value)
  88.497 -			{
  88.498 -				i += 2;
  88.499 -			}
  88.500 -			break;
  88.501 -		case GSA_16_BIT_IF_FALSE2:
  88.502 -			if (CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value)
  88.503 -			{
  88.504 -				i += 2;
  88.505 -			}
  88.506 -			break;
  88.507 -		case GSA_32_BIT_IF_FALSE2:
  88.508 -			if (CPUReadMemory(cheatsList[i].address) == cheatsList[i].value)
  88.509 -			{
  88.510 -				i += 2;
  88.511 -			}
  88.512 -			break;
  88.513 -		case GSA_SLOWDOWN:
  88.514 -			// check if button was pressed and released, if so toggle our state
  88.515 -			if ((cheatsList[i].status & 4) && !(extended & 4))
  88.516 -				cheatsList[i].status ^= 1;
  88.517 -			if (extended & 4)
  88.518 -				cheatsList[i].status |= 4;
  88.519 -			else
  88.520 -				cheatsList[i].status &= ~4;
  88.521 -
  88.522 -			if (cheatsList[i].status & 1)
  88.523 -				ticks += 2*256*((cheatsList[i].value >> 8) & 255);
  88.524 -			break;
  88.525 -		case CBA_ADD:
  88.526 -			CPUWriteHalfWord(cheatsList[i].address,
  88.527 -			                 CPUReadHalfWord(cheatsList[i].address) +
  88.528 -			                 (u16)cheatsList[i].value);
  88.529 -			break;
  88.530 -		case CBA_OR:
  88.531 -			CPUWriteHalfWord(cheatsList[i].address,
  88.532 -			                 CPUReadHalfWord(cheatsList[i].address) |
  88.533 -			                 cheatsList[i].value);
  88.534 -			break;
  88.535 -		case CBA_LT:
  88.536 -			if (CPUReadHalfWord(cheatsList[i].address) >= cheatsList[i].value)
  88.537 -				i++;
  88.538 -			break;
  88.539 -		case CBA_GT:
  88.540 -			if (CPUReadHalfWord(cheatsList[i].address) <= cheatsList[i].value)
  88.541 -				i++;
  88.542 -			break;
  88.543 -		case CBA_SUPER:
  88.544 -		{
  88.545 -			int count   = 2*cheatsList[i].value;
  88.546 -			u32 address = cheatsList[i].address;
  88.547 -			for (int x = 0; x < count; x++)
  88.548 -			{
  88.549 -				u8  b;
  88.550 -				int res = x % 6;
  88.551 -				if (res < 4)
  88.552 -					b = (cheatsList[i].address >> (24-8*res)) & 0xFF;
  88.553 -				else
  88.554 -					b = (cheatsList[i].value >> (8 - 8*(res-4))) & 0x0FF;
  88.555 -				CPUWriteByte(address, b);
  88.556 -				address++;
  88.557 -				if (x && !res)
  88.558 -					i++;
  88.559 -			}
  88.560 -			if (count % 6)
  88.561 -				i++;
  88.562 -			break;
  88.563 -		}
  88.564 -		}
  88.565 -	}
  88.566 -	return ticks;
  88.567 -}
  88.568 -
  88.569 -void cheatsAdd(const char *codeStr,
  88.570 -               const char *desc,
  88.571 -               u32 address,
  88.572 -               u32 value,
  88.573 -               int code,
  88.574 -               int size)
  88.575 -{
  88.576 -	if (cheatsNumber < 100)
  88.577 -	{
  88.578 -		int x = cheatsNumber;
  88.579 -		cheatsList[x].code    = code;
  88.580 -		cheatsList[x].size    = size;
  88.581 -		cheatsList[x].address = address;
  88.582 -		cheatsList[x].value   = value;
  88.583 -		strcpy(cheatsList[x].codestring, codeStr);
  88.584 -		strcpy(cheatsList[x].desc, desc);
  88.585 -		cheatsList[x].enabled = true;
  88.586 -		cheatsList[x].status  = 0;
  88.587 -
  88.588 -		// we only store the old value for this simple codes. ROM patching
  88.589 -		// is taken care when it actually patches the ROM
  88.590 -		switch (cheatsList[x].size)
  88.591 -		{
  88.592 -		case INT_8_BIT_WRITE:
  88.593 -			cheatsList[x].oldValue = CPUReadByte(address);
  88.594 -			break;
  88.595 -		case INT_16_BIT_WRITE:
  88.596 -			cheatsList[x].oldValue = CPUReadHalfWord(address);
  88.597 -			break;
  88.598 -		case INT_32_BIT_WRITE:
  88.599 -			cheatsList[x].oldValue = CPUReadMemory(address);
  88.600 -			break;
  88.601 -		}
  88.602 -		cheatsNumber++;
  88.603 -	}
  88.604 -}
  88.605 -
  88.606 -void cheatsDelete(int number, bool restore)
  88.607 -{
  88.608 -	if (number < cheatsNumber && number >= 0)
  88.609 -	{
  88.610 -		int x = number;
  88.611 -
  88.612 -		if (restore)
  88.613 -		{
  88.614 -			switch (cheatsList[x].size)
  88.615 -			{
  88.616 -			case INT_8_BIT_WRITE:
  88.617 -				CPUWriteByte(cheatsList[x].address, (u8)cheatsList[x].oldValue);
  88.618 -				break;
  88.619 -			case INT_16_BIT_WRITE:
  88.620 -				CPUWriteHalfWord(cheatsList[x].address, (u16)cheatsList[x].oldValue);
  88.621 -				break;
  88.622 -			case INT_32_BIT_WRITE:
  88.623 -				CPUWriteMemory(cheatsList[x].address, cheatsList[x].oldValue);
  88.624 -				break;
  88.625 -			case GSA_16_BIT_ROM_PATCH:
  88.626 -				if (cheatsList[x].status & 1)
  88.627 -				{
  88.628 -					cheatsList[x].status &= ~1;
  88.629 -					CHEAT_PATCH_ROM_16BIT(cheatsList[x].address,
  88.630 -					                      cheatsList[x].oldValue);
  88.631 -				}
  88.632 -				break;
  88.633 -			case GSA_16_BIT_ROM_PATCH2:
  88.634 -				if (cheatsList[x].status & 1)
  88.635 -				{
  88.636 -					cheatsList[x].status &= ~1;
  88.637 -					CHEAT_PATCH_ROM_16BIT(((cheatsList[x].value & 0x00FFFFFF) << 1)+
  88.638 -					                      0x8000000,
  88.639 -					                      cheatsList[x].oldValue);
  88.640 -				}
  88.641 -				break;
  88.642 -			}
  88.643 -		}
  88.644 -		if ((x+1) <  cheatsNumber)
  88.645 -		{
  88.646 -			memcpy(&cheatsList[x], &cheatsList[x+1], sizeof(CheatsData)*
  88.647 -			       (cheatsNumber-x-1));
  88.648 -		}
  88.649 -		cheatsNumber--;
  88.650 -	}
  88.651 -}
  88.652 -
  88.653 -void cheatsDeleteAll(bool restore)
  88.654 -{
  88.655 -	for (int i = cheatsNumber-1; i >= 0; i--)
  88.656 -	{
  88.657 -		cheatsDelete(i, restore);
  88.658 -	}
  88.659 -}
  88.660 -
  88.661 -void cheatsEnable(int i)
  88.662 -{
  88.663 -	if (i >= 0 && i < cheatsNumber)
  88.664 -	{
  88.665 -		cheatsList[i].enabled = true;
  88.666 -	}
  88.667 -}
  88.668 -
  88.669 -void cheatsDisable(int i)
  88.670 -{
  88.671 -	if (i >= 0 && i < cheatsNumber)
  88.672 -	{
  88.673 -		switch (cheatsList[i].size)
  88.674 -		{
  88.675 -		case GSA_16_BIT_ROM_PATCH:
  88.676 -			if (cheatsList[i].status & 1)
  88.677 -			{
  88.678 -				cheatsList[i].status &= ~1;
  88.679 -				CHEAT_PATCH_ROM_16BIT(cheatsList[i].address,
  88.680 -				                      cheatsList[i].oldValue);
  88.681 -			}
  88.682 -			break;
  88.683 -		case GSA_16_BIT_ROM_PATCH2:
  88.684 -			if (cheatsList[i].status & 1)
  88.685 -			{
  88.686 -				cheatsList[i].status &= ~1;
  88.687 -				CHEAT_PATCH_ROM_16BIT(((cheatsList[i].value & 0x00FFFFFF) << 1)+
  88.688 -				                      0x8000000,
  88.689 -				                      cheatsList[i].oldValue);
  88.690 -			}
  88.691 -			break;
  88.692 -		}
  88.693 -		cheatsList[i].enabled = false;
  88.694 -	}
  88.695 -}
  88.696 -
  88.697 -bool cheatsVerifyCheatCode(const char *code, const char *desc)
  88.698 -{
  88.699 -	int len = strlen(code);
  88.700 -	if (len != 11 && len != 13 && len != 17)
  88.701 -	{
  88.702 -		systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code);
  88.703 -		return false;
  88.704 -	}
  88.705 -
  88.706 -	if (code[8] != ':')
  88.707 -	{
  88.708 -		systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code);
  88.709 -		return false;
  88.710 -	}
  88.711 -
  88.712 -	int i;
  88.713 -	for (i = 0; i < 8; i++)
  88.714 -	{
  88.715 -		if (!CHEAT_IS_HEX(code[i]))
  88.716 -		{
  88.717 -			// wrong cheat
  88.718 -			systemMessage(MSG_INVALID_CHEAT_CODE,
  88.719 -			              N_("Invalid cheat code '%s'"), code);
  88.720 -			return false;
  88.721 -		}
  88.722 -	}
  88.723 -	for (i = 9; i < len; i++)
  88.724 -	{
  88.725 -		if (!CHEAT_IS_HEX(code[i]))
  88.726 -		{
  88.727 -			// wrong cheat
  88.728 -			systemMessage(MSG_INVALID_CHEAT_CODE,
  88.729 -			              N_("Invalid cheat code '%s'"), code);
  88.730 -			return false;
  88.731 -		}
  88.732 -	}
  88.733 -
  88.734 -	u32 address = 0;
  88.735 -	u32 value   = 0;
  88.736 -
  88.737 -	char buffer[10];
  88.738 -	strncpy(buffer, code, 8);
  88.739 -	buffer[8] = 0;
  88.740 -	sscanf(buffer, "%x", &address);
  88.741 -
  88.742 -	switch (address >> 24)
  88.743 -	{
  88.744 -	case 2:
  88.745 -	case 3:
  88.746 -		break;
  88.747 -	default:
  88.748 -		systemMessage(MSG_INVALID_CHEAT_CODE_ADDRESS,
  88.749 -		              N_("Invalid cheat code address: %08x"),
  88.750 -		              address);
  88.751 -		return false;
  88.752 -	}
  88.753 -
  88.754 -	strncpy(buffer, &code[9], 8);
  88.755 -	sscanf(buffer, "%x", &value);
  88.756 -	int type = 0;
  88.757 -	if (len == 13)
  88.758 -		type = 1;
  88.759 -	if (len == 17)
  88.760 -		type = 2;
  88.761 -	cheatsAdd(code, desc, address, value, type, type);
  88.762 -	return true;
  88.763 -}
  88.764 -
  88.765 -void cheatsAddCheatCode(const char *code, const char *desc)
  88.766 -{
  88.767 -	cheatsVerifyCheatCode(code, desc);
  88.768 -}
  88.769 -
  88.770 -void cheatsDecryptGSACode(u32& address, u32& value, bool v3)
  88.771 -{
  88.772 -	u32  rollingseed = 0xC6EF3720;
  88.773 -	u32  seeds_v1[]  =  { 0x09F4FBBD, 0x9681884A, 0x352027E9, 0xF3DEE5A7 };
  88.774 -	u32  seeds_v3[]  = { 0x7AA9648F, 0x7FAE6994, 0xC0EFAAD5, 0x42712C57 };
  88.775 -	u32 *seeds       = v3 ? seeds_v3 : seeds_v1;
  88.776 -
  88.777 -	int bitsleft = 32;
  88.778 -	while (bitsleft > 0)
  88.779 -	{
  88.780 -		value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^
  88.781 -		          ((address >> 5) + seeds[3]));
  88.782 -		address -= ((((value << 4) + seeds[0]) ^ (value + rollingseed)) ^
  88.783 -		            ((value >> 5) + seeds[1]));
  88.784 -		rollingseed -= 0x9E3779B9;
  88.785 -		bitsleft--;
  88.786 -	}
  88.787 -}
  88.788 -
  88.789 -void cheatsAddGSACode(const char *code, const char *desc, bool v3)
  88.790 -{
  88.791 -	if (strlen(code) != 16)
  88.792 -	{
  88.793 -		// wrong cheat
  88.794 -		systemMessage(MSG_INVALID_GSA_CODE,
  88.795 -		              N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY"));
  88.796 -		return;
  88.797 -	}
  88.798 -
  88.799 -	int i;
  88.800 -	for (i = 0; i < 16; i++)
  88.801 -	{
  88.802 -		if (!CHEAT_IS_HEX(code[i]))
  88.803 -		{
  88.804 -			// wrong cheat
  88.805 -			systemMessage(MSG_INVALID_GSA_CODE,
  88.806 -			              N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY"));
  88.807 -			return;
  88.808 -		}
  88.809 -	}
  88.810 -
  88.811 -	char buffer[10];
  88.812 -	strncpy(buffer, code, 8);
  88.813 -	buffer[8] = 0;
  88.814 -	u32 address;
  88.815 -	sscanf(buffer, "%x", &address);
  88.816 -	strncpy(buffer, &code[8], 8);
  88.817 -	buffer[8] = 0;
  88.818 -	u32 value;
  88.819 -	sscanf(buffer, "%x", &value);
  88.820 -
  88.821 -	cheatsDecryptGSACode(address, value, v3);
  88.822 -
  88.823 -	if (value == 0x1DC0DE)
  88.824 -	{
  88.825 -		u32 gamecode = READ32LE(((u32 *)&rom[0xac]));
  88.826 -		if (gamecode != address)
  88.827 -		{
  88.828 -			char buffer[5];
  88.829 -			*((u32 *)buffer) = address;
  88.830 -			buffer[4]        = 0;
  88.831 -			char buffer2[5];
  88.832 -			*((u32 *)buffer2) = READ32LE(((u32 *)&rom[0xac]));
  88.833 -			buffer2[4]        = 0;
  88.834 -			systemMessage(MSG_GBA_CODE_WARNING,
  88.835 -			              N_("Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly."),
  88.836 -			              buffer, buffer2);
  88.837 -		}
  88.838 -		cheatsAdd(code, desc, address & 0x0FFFFFFF, value, v3 ? 257 : 256,
  88.839 -		          UNKNOWN_CODE);
  88.840 -		return;
  88.841 -	}
  88.842 -	if (isMultilineWithData(cheatsNumber-1))
  88.843 -	{
  88.844 -		cheatsAdd(code, desc, address, value, v3 ? 257 : 256, UNKNOWN_CODE);
  88.845 -		return;
  88.846 -	}
  88.847 -	if (v3)
  88.848 -	{
  88.849 -		int type = (address >> 25) & 127;
  88.850 -		u32 addr = (address & 0x00F00000) << 4 | (address & 0x0003FFFF);
  88.851 -		switch (type)
  88.852 -		{
  88.853 -		case 0x00:
  88.854 -			if (address == 0)
  88.855 -			{
  88.856 -				type = (value >> 25) & 127;
  88.857 -				addr = (value & 0x00F00000) << 4 | (value & 0x0003FFFF);
  88.858 -				switch (type)
  88.859 -				{
  88.860 -				case 0x04:
  88.861 -					cheatsAdd(code, desc, 0, value & 0x00FFFFFF, 257, GSA_SLOWDOWN);
  88.862 -					break;
  88.863 -				case 0x08:
  88.864 -					cheatsAdd(code, desc, 0, addr, 257, GSA_8_BIT_GS_WRITE2);
  88.865 -					break;
  88.866 -				case 0x09:
  88.867 -					cheatsAdd(code, desc, 0, addr, 257, GSA_16_BIT_GS_WRITE2);
  88.868 -					break;
  88.869 -				case 0x0a:
  88.870 -					cheatsAdd(code, desc, 0, addr, 257, GSA_32_BIT_GS_WRITE2);
  88.871 -					break;
  88.872 -				case 0x0c:
  88.873 -				case 0x0d:
  88.874 -				case 0x0e:
  88.875 -				case 0x0f:
  88.876 -					cheatsAdd(code, desc, 0, value & 0x00FFFFFF, 257, GSA_16_BIT_ROM_PATCH2);
  88.877 -					break;
  88.878 -				case 0x40:
  88.879 -					cheatsAdd(code, desc, 0, addr, 257, GSA_8_BIT_SLIDE);
  88.880 -					break;
  88.881 -				case 0x41:
  88.882 -					cheatsAdd(code, desc, 0, addr, 257, GSA_16_BIT_SLIDE);
  88.883 -					break;
  88.884 -				case 0x42:
  88.885 -					cheatsAdd(code, desc, 0, addr, 257, GSA_32_BIT_SLIDE);
  88.886 -					break;
  88.887 -				default:
  88.888 -					cheatsAdd(code, desc, address, value, 257, UNKNOWN_CODE);
  88.889 -					break;
  88.890 -				}
  88.891 -			}
  88.892 -			else
  88.893 -				cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_FILL);
  88.894 -			break;
  88.895 -		case 0x01:
  88.896 -			cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_FILL);
  88.897 -			break;
  88.898 -		case 0x02:
  88.899 -			cheatsAdd(code, desc, addr, value, 257, INT_32_BIT_WRITE);
  88.900 -			break;
  88.901 -		case 0x04:
  88.902 -			cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_TRUE);
  88.903 -			break;
  88.904 -		case 0x05:
  88.905 -			cheatsAdd(code, desc, addr, value, 257, CBA_IF_TRUE);
  88.906 -			break;
  88.907 -		case 0x06:
  88.908 -			cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_TRUE);
  88.909 -			break;
  88.910 -		case 0x08:
  88.911 -			cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_FALSE);
  88.912 -			break;
  88.913 -		case 0x09:
  88.914 -			cheatsAdd(code, desc, addr, value, 257, CBA_IF_FALSE);
  88.915 -			break;
  88.916 -		case 0x0a:
  88.917 -			cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_FALSE);
  88.918 -			break;
  88.919 -		case 0x24:
  88.920 -			cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_TRUE2);
  88.921 -			break;
  88.922 -		case 0x25:
  88.923 -			cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_IF_TRUE2);
  88.924 -			break;
  88.925 -		case 0x26:
  88.926 -			cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_TRUE2);
  88.927 -			break;
  88.928 -		case 0x28:
  88.929 -			cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_FALSE2);
  88.930 -			break;
  88.931 -		case 0x29:
  88.932 -			cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_IF_FALSE2);
  88.933 -			break;
  88.934 -		case 0x2a:
  88.935 -			cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_FALSE2);
  88.936 -			break;
  88.937 -		default:
  88.938 -			cheatsAdd(code, desc, address, value, 257, UNKNOWN_CODE);
  88.939 -			break;
  88.940 -		}
  88.941 -	}
  88.942 -	else
  88.943 -	{
  88.944 -		int type = (address >> 28) & 15;
  88.945 -		switch (type)
  88.946 -		{
  88.947 -		case 0:
  88.948 -		case 1:
  88.949 -		case 2:
  88.950 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256, type);
  88.951 -			break;
  88.952 -		case 6:
  88.953 -			address <<= 1;
  88.954 -			type      = (address >> 28) & 15;
  88.955 -			if (type == 0x0c)
  88.956 -			{
  88.957 -				cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256,
  88.958 -				          GSA_16_BIT_ROM_PATCH);
  88.959 -				break;
  88.960 -			}
  88.961 -			// unsupported code
  88.962 -			cheatsAdd(code, desc, address, value, 256,
  88.963 -			          UNKNOWN_CODE);
  88.964 -			break;
  88.965 -		case 8:
  88.966 -			switch ((address >> 20) & 15)
  88.967 -			{
  88.968 -			case 1:
  88.969 -				cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256,
  88.970 -				          GSA_8_BIT_GS_WRITE);
  88.971 -				break;
  88.972 -			case 2:
  88.973 -				cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256,
  88.974 -				          GSA_16_BIT_GS_WRITE);
  88.975 -				break;
  88.976 -			case 3:
  88.977 -				cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256,
  88.978 -				          GSA_32_BIT_GS_WRITE);
  88.979 -			case 15:
  88.980 -				cheatsAdd(code, desc, 0, value & 0xFF00, 256, GSA_SLOWDOWN);
  88.981 -				break;
  88.982 -			default:
  88.983 -				// unsupported code
  88.984 -				cheatsAdd(code, desc, address, value, 256,
  88.985 -				          UNKNOWN_CODE);
  88.986 -				break;
  88.987 -			}
  88.988 -			break;
  88.989 -		case 0x0d:
  88.990 -			if (address != 0xDEADFACE)
  88.991 -			{
  88.992 -				cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256,
  88.993 -				          CBA_IF_TRUE);
  88.994 -			}
  88.995 -			else
  88.996 -				cheatsAdd(code, desc, address, value, 256,
  88.997 -				          UNKNOWN_CODE);
  88.998 -			break;
  88.999 -		default:
 88.1000 -			// unsupported code
 88.1001 -			cheatsAdd(code, desc, address, value, 256,
 88.1002 -			          UNKNOWN_CODE);
 88.1003 -			break;
 88.1004 -		}
 88.1005 -	}
 88.1006 -}
 88.1007 -
 88.1008 -bool cheatsImportGSACodeFile(const char *name, int game, bool v3)
 88.1009 -{
 88.1010 -	FILE *f = fopen(name, "rb");
 88.1011 -	if (!f)
 88.1012 -		return false;
 88.1013 -
 88.1014 -	int games = 0;
 88.1015 -	int len   = 0;
 88.1016 -	fseek(f, 0x1e, SEEK_CUR);
 88.1017 -	fread(&games, 1, 4, f);
 88.1018 -	bool found = false;
 88.1019 -	int  g     = 0;
 88.1020 -	while (games > 0)
 88.1021 -	{
 88.1022 -		if (g == game)
 88.1023 -		{
 88.1024 -			found = true;
 88.1025 -			break;
 88.1026 -		}
 88.1027 -		fread(&len, 1, 4, f);
 88.1028 -		fseek(f, len, SEEK_CUR);
 88.1029 -		int codes = 0;
 88.1030 -		fread(&codes, 1, 4, f);
 88.1031 -		while (codes > 0)
 88.1032 -		{
 88.1033 -			fread(&len, 1, 4, f);
 88.1034 -			fseek(f, len, SEEK_CUR);
 88.1035 -			fseek(f, 8, SEEK_CUR);
 88.1036 -			fread(&len, 1, 4, f);
 88.1037 -			fseek(f, len*12, SEEK_CUR);
 88.1038 -			codes--;
 88.1039 -		}
 88.1040 -		games--;
 88.1041 -		g++;
 88.1042 -	}
 88.1043 -	if (found)
 88.1044 -	{
 88.1045 -		char desc[256];
 88.1046 -		char code[17];
 88.1047 -		fread(&len, 1, 4, f);
 88.1048 -		fseek(f, len, SEEK_CUR);
 88.1049 -		int codes = 0;
 88.1050 -		fread(&codes, 1, 4, f);
 88.1051 -		while (codes > 0)
 88.1052 -		{
 88.1053 -			fread(&len, 1, 4, f);
 88.1054 -			fread(desc, 1, len, f);
 88.1055 -			desc[len] = 0;
 88.1056 -			desc[31]  = 0;
 88.1057 -			fread(&len, 1, 4, f);
 88.1058 -			fseek(f, len, SEEK_CUR);
 88.1059 -			fseek(f, 4, SEEK_CUR);
 88.1060 -			fread(&len, 1, 4, f);
 88.1061 -			while (len)
 88.1062 -			{
 88.1063 -				fseek(f, 4, SEEK_CUR);
 88.1064 -				fread(code, 1, 8, f);
 88.1065 -				fseek(f, 4, SEEK_CUR);
 88.1066 -				fread(&code[8], 1, 8, f);
 88.1067 -				code[16] = 0;
 88.1068 -				cheatsAddGSACode(code, desc, v3);
 88.1069 -				len -= 2;
 88.1070 -			}
 88.1071 -			codes--;
 88.1072 -		}
 88.1073 -	}
 88.1074 -	fclose(f);
 88.1075 -	return false;
 88.1076 -}
 88.1077 -
 88.1078 -void cheatsCBAReverseArray(u8 *array, u8 *dest)
 88.1079 -{
 88.1080 -	dest[0] = array[3];
 88.1081 -	dest[1] = array[2];
 88.1082 -	dest[2] = array[1];
 88.1083 -	dest[3] = array[0];
 88.1084 -	dest[4] = array[5];
 88.1085 -	dest[5] = array[4];
 88.1086 -}
 88.1087 -
 88.1088 -void chatsCBAScramble(u8 *array, int count, u8 b)
 88.1089 -{
 88.1090 -	u8 *x  = array + (count >> 3);
 88.1091 -	u8 *y  = array + (b >> 3);
 88.1092 -	u32 z  = *x & (1 << (count & 7));
 88.1093 -	u32 x0 = (*x & (~(1 << (count & 7))));
 88.1094 -	if (z != 0)
 88.1095 -		z = 1;
 88.1096 -	if ((*y & (1 << (b & 7))) != 0)
 88.1097 -		x0 |= (1 << (count & 7));
 88.1098 -	*x = x0;
 88.1099 -	u32 temp = *y & (~(1 << (b & 7)));
 88.1100 -	if (z != 0)
 88.1101 -		temp |= (1 << (b & 7));
 88.1102 -	*y = temp;
 88.1103 -}
 88.1104 -
 88.1105 -u32 cheatsCBAGetValue(u8 *array)
 88.1106 -{
 88.1107 -	return array[0] | array[1]<<8 | array[2] << 16 | array[3]<<24;
 88.1108 -}
 88.1109 -
 88.1110 -u16 cheatsCBAGetData(u8 *array)
 88.1111 -{
 88.1112 -	return array[4] | array[5]<<8;
 88.1113 -}
 88.1114 -
 88.1115 -void cheatsCBAArrayToValue(u8 *array, u8 *dest)
 88.1116 -{
 88.1117 -	dest[0] = array[3];
 88.1118 -	dest[1] = array[2];
 88.1119 -	dest[2] = array[1];
 88.1120 -	dest[3] = array[0];
 88.1121 -	dest[4] = array[5];
 88.1122 -	dest[5] = array[4];
 88.1123 -}
 88.1124 -
 88.1125 -void cheatsCBAParseSeedCode(u32 address, u32 value, u32 *array)
 88.1126 -{
 88.1127 -	array[0] = 1;
 88.1128 -	array[1] = value & 0xFF;
 88.1129 -	array[2] = (address >> 0x10) & 0xFF;
 88.1130 -	array[3] = (value >> 8) & 0xFF;
 88.1131 -	array[4] = (address >> 0x18) & 0x0F;
 88.1132 -	array[5] = address & 0xFFFF;
 88.1133 -	array[6] = address;
 88.1134 -	array[7] = value;
 88.1135 -}
 88.1136 -
 88.1137 -u32 cheatsCBAEncWorker()
 88.1138 -{
 88.1139 -	u32 x = (cheatsCBATemporaryValue * 0x41c64e6d) + 0x3039;
 88.1140 -	u32 y = (x * 0x41c64e6d) + 0x3039;
 88.1141 -	u32 z = x >> 0x10;
 88.1142 -	x = ((y >> 0x10) & 0x7fff) << 0x0f;
 88.1143 -	z = (z << 0x1e) | x;
 88.1144 -	x = (y * 0x41c64e6d) + 0x3039;
 88.1145 -	cheatsCBATemporaryValue = x;
 88.1146 -	return z | ((x >> 0x10) & 0x7fff);
 88.1147 -}
 88.1148 -
 88.1149 -#define ROR(v, s) \
 88.1150 -    (((v) >> (s)) | (((v) & ((1 << (s))-1)) << (32 - (s))))
 88.1151 -
 88.1152 -u32 cheatsCBACalcIndex(u32 x, u32 y)
 88.1153 -{
 88.1154 -	if (y != 0)
 88.1155 -	{
 88.1156 -		if (y == 1)
 88.1157 -			x = 0;
 88.1158 -		else if (x == y)
 88.1159 -			x = 0;
 88.1160 -		if (y < 1)
 88.1161 -			return x;
 88.1162 -		else if (x < y)
 88.1163 -			return x;
 88.1164 -		u32 x0 = 1;
 88.1165 -
 88.1166 -		while (y < 0x10000000)
 88.1167 -		{
 88.1168 -			if (y < x)
 88.1169 -			{
 88.1170 -				y  = y << 4;
 88.1171 -				x0 = x0 << 4;
 88.1172 -			}
 88.1173 -			else
 88.1174 -				break;
 88.1175 -		}
 88.1176 -
 88.1177 -		while (y < 0x80000000)
 88.1178 -		{
 88.1179 -			if (y < x)
 88.1180 -			{
 88.1181 -				y  = y << 1;
 88.1182 -				x0 = x0 << 1;
 88.1183 -			}
 88.1184 -			else
 88.1185 -				break;
 88.1186 -		}
 88.1187 -
 88.1188 -loop:
 88.1189 -		u32 z = 0;
 88.1190 -		if (x >= y)
 88.1191 -			x -= y;
 88.1192 -		if (x >= (y >> 1))
 88.1193 -		{
 88.1194 -			x -= (y >> 1);
 88.1195 -			z |= ROR(x0, 1);
 88.1196 -		}
 88.1197 -		if (x >= (y >> 2))
 88.1198 -		{
 88.1199 -			x -= (y >> 2);
 88.1200 -			z |= ROR(x0, 2);
 88.1201 -		}
 88.1202 -		if (x >= (y >> 3))
 88.1203 -		{
 88.1204 -			x -= (y >> 3);
 88.1205 -			z |= ROR(x0, 3);
 88.1206 -		}
 88.1207 -
 88.1208 -		u32 temp = x0;
 88.1209 -
 88.1210 -		if (x != 0)
 88.1211 -		{
 88.1212 -			x0 = x0 >> 4;
 88.1213 -			if (x0 != 0)
 88.1214 -			{
 88.1215 -				y = y >> 4;
 88.1216 -				goto loop;
 88.1217 -			}
 88.1218 -		}
 88.1219 -
 88.1220 -		z = z & 0xe0000000;
 88.1221 -
 88.1222 -		if (z != 0)
 88.1223 -		{
 88.1224 -			if ((temp & 7) == 0)
 88.1225 -				return x;
 88.1226 -		}
 88.1227 -		else
 88.1228 -			return x;
 88.1229 -
 88.1230 -		if ((z & ROR(temp, 3)) != 0)
 88.1231 -			x += y >> 3;
 88.1232 -		if ((z & ROR(temp, 2)) != 0)
 88.1233 -			x += y >> 2;
 88.1234 -		if ((z & ROR(temp, 1)) != 0)
 88.1235 -			x += y >> 1;
 88.1236 -		return x;
 88.1237 -	}
 88.1238 -	else
 88.1239 -	{}
 88.1240 -	// should not happen in the current code
 88.1241 -	return 0;
 88.1242 -}
 88.1243 -
 88.1244 -void cheatsCBAUpdateSeedBuffer(u32 a, u8 *buffer, int count)
 88.1245 -{
 88.1246 -	int i;
 88.1247 -	for (i = 0; i < count; i++)
 88.1248 -		buffer[i] = i;
 88.1249 -	for (i = 0; (u32)i < a; i++)
 88.1250 -	{
 88.1251 -		u32 a = cheatsCBACalcIndex(cheatsCBAEncWorker(), count);
 88.1252 -		u32 b = cheatsCBACalcIndex(cheatsCBAEncWorker(), count);
 88.1253 -		u32 t = buffer[a];
 88.1254 -		buffer[a] = buffer[b];
 88.1255 -		buffer[b] = t;
 88.1256 -	}
 88.1257 -}
 88.1258 -
 88.1259 -void cheatsCBAChangeEncryption(u32 *seed)
 88.1260 -{
 88.1261 -	int i;
 88.1262 -
 88.1263 -	cheatsCBATemporaryValue = (seed[1] ^ 0x1111);
 88.1264 -	cheatsCBAUpdateSeedBuffer(0x50, cheatsCBASeedBuffer, 0x30);
 88.1265 -	cheatsCBATemporaryValue = 0x4efad1c3;
 88.1266 -
 88.1267 -	for (i = 0; (u32)i < seed[4]; i++)
 88.1268 -	{
 88.1269 -		cheatsCBATemporaryValue = cheatsCBAEncWorker();
 88.1270 -	}
 88.1271 -	cheatsCBASeed[2] = cheatsCBAEncWorker();
 88.1272 -	cheatsCBASeed[3] = cheatsCBAEncWorker();
 88.1273 -
 88.1274 -	cheatsCBATemporaryValue = seed[3] ^ 0xf254;
 88.1275 -
 88.1276 -	for (i = 0; (u32)i < seed[3]; i++)
 88.1277 -	{
 88.1278 -		cheatsCBATemporaryValue = cheatsCBAEncWorker();
 88.1279 -	}
 88.1280 -
 88.1281 -	cheatsCBASeed[0] = cheatsCBAEncWorker();
 88.1282 -	cheatsCBASeed[1] = cheatsCBAEncWorker();
 88.1283 -
 88.1284 -	*((u32 *)&cheatsCBACurrentSeed[0]) = seed[6];
 88.1285 -	*((u32 *)&cheatsCBACurrentSeed[4]) = seed[7];
 88.1286 -	*((u32 *)&cheatsCBACurrentSeed[8]) = 0;
 88.1287 -}
 88.1288 -
 88.1289 -u16 cheatsCBAGenValue(u32 x, u32 y, u32 z)
 88.1290 -{
 88.1291 -	y <<= 0x10;
 88.1292 -	z <<= 0x10;
 88.1293 -	x <<= 0x18;
 88.1294 -	u32 x0 = (int)y >> 0x10;
 88.1295 -	z = (int)z >> 0x10;
 88.1296 -	x = (int)x >> 0x10;
 88.1297 -	for (int i = 0; i < 8; i++)
 88.1298 -	{
 88.1299 -		u32 temp = z ^ x;
 88.1300 -		if ((int)temp >= 0)
 88.1301 -		{
 88.1302 -			temp = z << 0x11;
 88.1303 -		}
 88.1304 -		else
 88.1305 -		{
 88.1306 -			temp  = z << 0x01;
 88.1307 -			temp ^= x0;
 88.1308 -			temp  = temp << 0x10;
 88.1309 -		}
 88.1310 -		z    = (int)temp >> 0x10;
 88.1311 -		temp = x << 0x11;
 88.1312 -		x    = (int)temp >> 0x10;
 88.1313 -	}
 88.1314 -	return z & 0xffff;
 88.1315 -}
 88.1316 -
 88.1317 -void cheatsCBAGenTable()
 88.1318 -{
 88.1319 -	for (int i = 0; i < 0x100; i++)
 88.1320 -	{
 88.1321 -		cheatsCBATable[i] = cheatsCBAGenValue(i, 0x1021, 0);
 88.1322 -	}
 88.1323 -	cheatsCBATableGenerated = true;
 88.1324 -}
 88.1325 -
 88.1326 -u16 cheatsCBACalcCRC(u8 *rom, int count)
 88.1327 -{
 88.1328 -	u32 crc = 0xffffffff;
 88.1329 -
 88.1330 -	if (count & 3)
 88.1331 -	{
 88.1332 -		// 0x08000EAE
 88.1333 -	}
 88.1334 -	else
 88.1335 -	{
 88.1336 -		count = (count >> 2) - 1;
 88.1337 -		if (count != -1)
 88.1338 -		{
 88.1339 -			while (count != -1)
 88.1340 -			{
 88.1341 -				crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
 88.1342 -				                                       ^ *rom++]) << 0x10) >> 0x10;
 88.1343 -				crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
 88.1344 -				                                       ^ *rom++]) << 0x10) >> 0x10;
 88.1345 -				crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
 88.1346 -				                                       ^ *rom++]) << 0x10) >> 0x10;
 88.1347 -				crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
 88.1348 -				                                       ^ *rom++]) << 0x10) >> 0x10;
 88.1349 -				count--;
 88.1350 -			}
 88.1351 -		}
 88.1352 -	}
 88.1353 -	return crc & 0xffff;
 88.1354 -}
 88.1355 -
 88.1356 -void cheatsCBADecrypt(u8 *decrypt)
 88.1357 -{
 88.1358 -	u8  buffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 88.1359 -	u8 *array     = &buffer[1];
 88.1360 -
 88.1361 -	cheatsCBAReverseArray(decrypt, array);
 88.1362 -
 88.1363 -	for (int count = 0x2f; count >= 0; count--)
 88.1364 -	{
 88.1365 -		chatsCBAScramble(array, count, cheatsCBASeedBuffer[count]);
 88.1366 -	}
 88.1367 -	cheatsCBAArrayToValue(array, decrypt);
 88.1368 -	*((u32 *)decrypt) = cheatsCBAGetValue(decrypt) ^
 88.1369 -	                    cheatsCBASeed[0];
 88.1370 -	*((u16 *)(decrypt+4)) = (cheatsCBAGetData(decrypt) ^
 88.1371 -	                         cheatsCBASeed[1]) & 0xffff;
 88.1372 -
 88.1373 -	cheatsCBAReverseArray(decrypt, array);
 88.1374 -
 88.1375 -	u32 cs = cheatsCBAGetValue(cheatsCBACurrentSeed);
 88.1376 -	for (int i = 0; i <= 4; i++)
 88.1377 -	{
 88.1378 -		array[i] = ((cs >> 8) ^ array[i+1]) ^ array[i] ;
 88.1379 -	}
 88.1380 -
 88.1381 -	array[5] = (cs >> 8) ^ array[5];
 88.1382 -
 88.1383 -	for (int j = 5; j >= 0; j--)
 88.1384 -	{
 88.1385 -		array[j] = (cs ^ array[j-1]) ^ array[j];
 88.1386 -	}
 88.1387 -
 88.1388 -	cheatsCBAArrayToValue(array, decrypt);
 88.1389 -
 88.1390 -	*((u32 *)decrypt) = cheatsCBAGetValue(decrypt)
 88.1391 -	                    ^ cheatsCBASeed[2];
 88.1392 -	*((u16 *)(decrypt+4)) = (cheatsCBAGetData(decrypt)
 88.1393 -	                         ^ cheatsCBASeed[3]) & 0xffff;
 88.1394 -}
 88.1395 -
 88.1396 -int cheatsCBAGetCount()
 88.1397 -{
 88.1398 -	int count = 0;
 88.1399 -	for (int i = 0; i < cheatsNumber; i++)
 88.1400 -	{
 88.1401 -		if (cheatsList[i].code == 512)
 88.1402 -			count++;
 88.1403 -	}
 88.1404 -	return count;
 88.1405 -}
 88.1406 -
 88.1407 -bool cheatsCBAShouldDecrypt()
 88.1408 -{
 88.1409 -	for (int i = 0; i < cheatsNumber; i++)
 88.1410 -	{
 88.1411 -		if (cheatsList[i].code == 512)
 88.1412 -		{
 88.1413 -			return (cheatsList[i].codestring[0] == '9');
 88.1414 -		}
 88.1415 -	}
 88.1416 -	return false;
 88.1417 -}
 88.1418 -
 88.1419 -void cheatsAddCBACode(const char *code, const char *desc)
 88.1420 -{
 88.1421 -	if (strlen(code) != 13)
 88.1422 -	{
 88.1423 -		// wrong cheat
 88.1424 -		systemMessage(MSG_INVALID_CBA_CODE,
 88.1425 -		              N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
 88.1426 -		return;
 88.1427 -	}
 88.1428 -
 88.1429 -	int i;
 88.1430 -	for (i = 0; i < 8; i++)
 88.1431 -	{
 88.1432 -		if (!CHEAT_IS_HEX(code[i]))
 88.1433 -		{
 88.1434 -			// wrong cheat
 88.1435 -			systemMessage(MSG_INVALID_CBA_CODE,
 88.1436 -			              N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
 88.1437 -			return;
 88.1438 -		}
 88.1439 -	}
 88.1440 -
 88.1441 -	if (code[8] != ' ')
 88.1442 -	{
 88.1443 -		systemMessage(MSG_INVALID_CBA_CODE,
 88.1444 -		              N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
 88.1445 -		return;
 88.1446 -	}
 88.1447 -
 88.1448 -	for (i = 9; i < 13; i++)
 88.1449 -	{
 88.1450 -		if (!CHEAT_IS_HEX(code[i]))
 88.1451 -		{
 88.1452 -			// wrong cheat
 88.1453 -			systemMessage(MSG_INVALID_CBA_CODE,
 88.1454 -			              N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
 88.1455 -			return;
 88.1456 -		}
 88.1457 -	}
 88.1458 -
 88.1459 -	char buffer[10];
 88.1460 -	strncpy(buffer, code, 8);
 88.1461 -	buffer[8] = 0;
 88.1462 -	u32 address;
 88.1463 -	sscanf(buffer, "%x", &address);
 88.1464 -	strncpy(buffer, &code[9], 4);
 88.1465 -	buffer[4] = 0;
 88.1466 -	u32 value;
 88.1467 -	sscanf(buffer, "%x", &value);
 88.1468 -
 88.1469 -	u8 array[8] = {
 88.1470 -		address &255,
 88.1471 -		(address >> 8) & 255,
 88.1472 -		(address >> 16) & 255,
 88.1473 -		(address >> 24) & 255,
 88.1474 -		(value & 255),
 88.1475 -		(value >> 8) & 255,
 88.1476 -		0,
 88.1477 -		0
 88.1478 -	};
 88.1479 -
 88.1480 -	if (cheatsCBAGetCount() == 0 &&
 88.1481 -	    (address >> 28) == 9)
 88.1482 -	{
 88.1483 -		u32 seed[8];
 88.1484 -		cheatsCBAParseSeedCode(address, value, seed);
 88.1485 -		cheatsCBAChangeEncryption(seed);
 88.1486 -		cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, UNKNOWN_CODE);
 88.1487 -	}
 88.1488 -	else
 88.1489 -	{
 88.1490 -		if (cheatsCBAShouldDecrypt())
 88.1491 -			cheatsCBADecrypt(array);
 88.1492 -
 88.1493 -		address = READ32LE(((u32 *)array));
 88.1494 -		value   = READ16LE(((u16 *)&array[4]));
 88.1495 -
 88.1496 -		int type = (address >> 28) & 15;
 88.1497 -
 88.1498 -		if (isMultilineWithData(cheatsNumber-1))
 88.1499 -		{
 88.1500 -			cheatsAdd(code, desc, address, value, 512, UNKNOWN_CODE);
 88.1501 -			return;
 88.1502 -		}
 88.1503 -
 88.1504 -		switch (type)
 88.1505 -		{
 88.1506 -		case 0x00:
 88.1507 -		{
 88.1508 -			if (!cheatsCBATableGenerated)
 88.1509 -				cheatsCBAGenTable();
 88.1510 -			u32 crc = cheatsCBACalcCRC(rom, 0x10000);
 88.1511 -			if (crc != address)
 88.1512 -			{
 88.1513 -				systemMessage(MSG_CBA_CODE_WARNING,
 88.1514 -				              N_("Warning: Codes seem to be for a different game.\nCodes may not work correctly."));
 88.1515 -			}
 88.1516 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1517 -			          UNKNOWN_CODE);
 88.1518 -			break;
 88.1519 -		}
 88.1520 -		case 0x02:
 88.1521 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1522 -			          CBA_OR);
 88.1523 -			break;
 88.1524 -		case 0x03:
 88.1525 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1526 -			          INT_8_BIT_WRITE);
 88.1527 -			break;
 88.1528 -		case 0x04:
 88.1529 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1530 -			          CBA_SLIDE_CODE);
 88.1531 -			break;
 88.1532 -		case 0x05:
 88.1533 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1534 -			          CBA_SUPER);
 88.1535 -			break;
 88.1536 -		case 0x06:
 88.1537 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1538 -			          CBA_AND);
 88.1539 -			break;
 88.1540 -		case 0x07:
 88.1541 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1542 -			          CBA_IF_TRUE);
 88.1543 -			break;
 88.1544 -		case 0x08:
 88.1545 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1546 -			          INT_16_BIT_WRITE);
 88.1547 -			break;
 88.1548 -		case 0x0a:
 88.1549 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1550 -			          CBA_IF_FALSE);
 88.1551 -			break;
 88.1552 -		case 0x0b:
 88.1553 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1554 -			          CBA_LT);
 88.1555 -			break;
 88.1556 -		case 0x0c:
 88.1557 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1558 -			          CBA_GT);
 88.1559 -			break;
 88.1560 -		case 0x0d:
 88.1561 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1562 -			          CBA_IF_KEYS_PRESSED);
 88.1563 -			break;
 88.1564 -		case 0x0e:
 88.1565 -			cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512,
 88.1566 -			          CBA_ADD);
 88.1567 -			break;
 88.1568 -		default:
 88.1569 -			// unsupported code
 88.1570 -			cheatsAdd(code, desc, address & 0xFFFFFFFF, value, 512,
 88.1571 -			          UNKNOWN_CODE);
 88.1572 -			break;
 88.1573 -		}
 88.1574 -	}
 88.1575 -}
 88.1576 -
 88.1577 -void cheatsSaveGame(gzFile file)
 88.1578 -{
 88.1579 -	utilWriteInt(file, cheatsNumber);
 88.1580 -
 88.1581 -	utilGzWrite(file, cheatsList, sizeof(cheatsList));
 88.1582 -}
 88.1583 -
 88.1584 -void cheatsReadGame(gzFile file)
 88.1585 -{
 88.1586 -	cheatsNumber = 0;
 88.1587 -
 88.1588 -	cheatsNumber = utilReadInt(file);
 88.1589 -
 88.1590 -	utilGzRead(file, cheatsList, sizeof(cheatsList));
 88.1591 -
 88.1592 -	bool firstCodeBreaker = true;
 88.1593 -
 88.1594 -	for (int i = 0; i < cheatsNumber; i++)
 88.1595 -	{
 88.1596 -		cheatsList[i].status = 0;
 88.1597 -		if (!cheatsList[i].codestring[0])
 88.1598 -		{
 88.1599 -			switch (cheatsList[i].size)
 88.1600 -			{
 88.1601 -			case 0:
 88.1602 -				sprintf(cheatsList[i].codestring, "%08x:%02x", cheatsList[i].address,
 88.1603 -				        cheatsList[i].value);
 88.1604 -				break;
 88.1605 -			case 1:
 88.1606 -				sprintf(cheatsList[i].codestring, "%08x:%04x", cheatsList[i].address,
 88.1607 -				        cheatsList[i].value);
 88.1608 -				break;
 88.1609 -			case 2:
 88.1610 -				sprintf(cheatsList[i].codestring, "%08x:%08x", cheatsList[i].address,
 88.1611 -				        cheatsList[i].value);
 88.1612 -				break;
 88.1613 -			}
 88.1614 -		}
 88.1615 -
 88.1616 -		if (cheatsList[i].enabled)
 88.1617 -		{
 88.1618 -			cheatsEnable(i);
 88.1619 -		}
 88.1620 -
 88.1621 -		if (cheatsList[i].code == 512 && firstCodeBreaker)
 88.1622 -		{
 88.1623 -			firstCodeBreaker = false;
 88.1624 -			char buffer[10];
 88.1625 -			strncpy(buffer, cheatsList[i].codestring, 8);
 88.1626 -			buffer[8] = 0;
 88.1627 -			u32 address;
 88.1628 -			sscanf(buffer, "%x", &address);
 88.1629 -			if ((address >> 28) == 9)
 88.1630 -			{
 88.1631 -				strncpy(buffer, &cheatsList[i].codestring[9], 4);
 88.1632 -				buffer[4] = 0;
 88.1633 -				u32 value;
 88.1634 -				sscanf(buffer, "%x", &value);
 88.1635 -
 88.1636 -				u32 seed[8];
 88.1637 -				cheatsCBAParseSeedCode(address, value, seed);
 88.1638 -				cheatsCBAChangeEncryption(seed);
 88.1639 -			}
 88.1640 -		}
 88.1641 -	}
 88.1642 -}
 88.1643 -
 88.1644 -void cheatsSaveCheatList(const char *file)
 88.1645 -{
 88.1646 -	if (cheatsNumber == 0)
 88.1647 -		return;
 88.1648 -	FILE *f = fopen(file, "wb");
 88.1649 -	if (f == NULL)
 88.1650 -		return;
 88.1651 -	int version = 1;
 88.1652 -	fwrite(&version, 1, sizeof(version), f);
 88.1653 -	int type = 0;
 88.1654 -	fwrite(&type, 1, sizeof(type), f);
 88.1655 -	fwrite(&cheatsNumber, 1, sizeof(cheatsNumber), f);
 88.1656 -	fwrite(cheatsList, 1, sizeof(cheatsList), f);
 88.1657 -	fclose(f);
 88.1658 -}
 88.1659 -
 88.1660 -bool cheatsLoadCheatList(const char *file)
 88.1661 -{
 88.1662 -	cheatsNumber = 0;
 88.1663 -
 88.1664 -	int count = 0;
 88.1665 -
 88.1666 -	FILE *f = fopen(file, "rb");
 88.1667 -
 88.1668 -	if (f == NULL)
 88.1669 -		return false;
 88.1670 -
 88.1671 -	int version = 0;
 88.1672 -
 88.1673 -	if (fread(&version, 1, sizeof(version), f) != sizeof(version))
 88.1674 -	{
 88.1675 -		fclose(f);
 88.1676 -		return false;
 88.1677 -	}
 88.1678 -
 88.1679 -	if (version != 1)
 88.1680 -	{
 88.1681 -		systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
 88.1682 -		              N_("Unsupported cheat list version %d"), version);
 88.1683 -		fclose(f);
 88.1684 -		return false;
 88.1685 -	}
 88.1686 -
 88.1687 -	int type = 0;
 88.1688 -	if (fread(&type, 1, sizeof(type), f) != sizeof(type))
 88.1689 -	{
 88.1690 -		fclose(f);
 88.1691 -		return false;
 88.1692 -	}
 88.1693 -
 88.1694 -	if (type != 0)
 88.1695 -	{
 88.1696 -		systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE,
 88.1697 -		              N_("Unsupported cheat list type %d"), type);
 88.1698 -		fclose(f);
 88.1699 -		return false;
 88.1700 -	}
 88.1701 -
 88.1702 -	if (fread(&count, 1, sizeof(count), f) != sizeof(count))
 88.1703 -	{
 88.1704 -		fclose(f);
 88.1705 -		return false;
 88.1706 -	}
 88.1707 -
 88.1708 -	if (fread(cheatsList, 1, sizeof(cheatsList), f) != sizeof(cheatsList))
 88.1709 -	{
 88.1710 -		fclose(f);
 88.1711 -		return false;
 88.1712 -	}
 88.1713 -
 88.1714 -	bool firstCodeBreaker = true;
 88.1715 -
 88.1716 -	for (int i = 0; i < count; i++)
 88.1717 -	{
 88.1718 -		cheatsList[i].status = 0; // remove old status as it is not used
 88.1719 -		if (!cheatsList[i].codestring[0])
 88.1720 -		{
 88.1721 -			switch (cheatsList[i].size)
 88.1722 -			{
 88.1723 -			case 0:
 88.1724 -				sprintf(cheatsList[i].codestring, "%08x:%02x", cheatsList[i].address,
 88.1725 -				        cheatsList[i].value);
 88.1726 -				break;
 88.1727 -			case 1:
 88.1728 -				sprintf(cheatsList[i].codestring, "%08x:%04x", cheatsList[i].address,
 88.1729 -				        cheatsList[i].value);
 88.1730 -				break;
 88.1731 -			case 2:
 88.1732 -				sprintf(cheatsList[i].codestring, "%08x:%08x", cheatsList[i].address,
 88.1733 -				        cheatsList[i].value);
 88.1734 -				break;
 88.1735 -			}
 88.1736 -		}
 88.1737 -
 88.1738 -		if (cheatsList[i].code == 512 && firstCodeBreaker)
 88.1739 -		{
 88.1740 -			firstCodeBreaker = false;
 88.1741 -			char buffer[10];
 88.1742 -			strncpy(buffer, cheatsList[i].codestring, 8);
 88.1743 -			buffer[8] = 0;
 88.1744 -			u32 address;
 88.1745 -			sscanf(buffer, "%x", &address);
 88.1746 -			if ((address >> 28) == 9)
 88.1747 -			{
 88.1748 -				strncpy(buffer, &cheatsList[i].codestring[9], 4);
 88.1749 -				buffer[4] = 0;
 88.1750 -				u32 value;
 88.1751 -				sscanf(buffer, "%x", &value);
 88.1752 -
 88.1753 -				u32 seed[8];
 88.1754 -				cheatsCBAParseSeedCode(address, value, seed);
 88.1755 -				cheatsCBAChangeEncryption(seed);
 88.1756 -			}
 88.1757 -		}
 88.1758 -	}
 88.1759 -	cheatsNumber = count;
 88.1760 -	fclose(f);
 88.1761 -	return true;
 88.1762 -}
 88.1763 -
 88.1764 -extern int *extCpuLoopTicks;
 88.1765 -extern int *extClockTicks;
 88.1766 -extern int *extTicks;
 88.1767 -extern int  cpuSavedTicks;
 88.1768 -
 88.1769 -extern void debuggerBreakOnWrite(u32 *, u32, u32, int);
 88.1770 -
 88.1771 -#define CPU_BREAK_LOOP2 \
 88.1772 -    cpuSavedTicks    = cpuSavedTicks - *extCpuLoopTicks; \
 88.1773 -    *extCpuLoopTicks = *extClockTicks; \
 88.1774 -    *extTicks        = *extClockTicks;
 88.1775 -
 88.1776 -void cheatsWriteMemory(u32 *address, u32 value, u32 mask)
 88.1777 -{
 88.1778 -#ifdef BKPT_SUPPORT
 88.1779 -#ifdef SDL
 88.1780 -	if (cheatsNumber == 0)
 88.1781 -	{
 88.1782 -		debuggerBreakOnWrite(address, *address, value, 2);
 88.1783 -		CPU_BREAK_LOOP2;
 88.1784 -		*address = value;
 88.1785 -		return;
 88.1786 -	}
 88.1787 -#endif
 88.1788 -#endif
 88.1789 -}
 88.1790 -
 88.1791 -void cheatsWriteHalfWord(u16 *address, u16 value, u16 mask)
 88.1792 -{
 88.1793 -#ifdef BKPT_SUPPORT
 88.1794 -#ifdef SDL
 88.1795 -	if (cheatsNumber == 0)
 88.1796 -	{
 88.1797 -		debuggerBreakOnWrite((u32 *)address, *address, value, 1);
 88.1798 -		CPU_BREAK_LOOP2;
 88.1799 -		*address = value;
 88.1800 -		return;
 88.1801 -	}
 88.1802 -#endif
 88.1803 -#endif
 88.1804 -}
 88.1805 -
 88.1806 -#if defined BKPT_SUPPORT && defined SDL
 88.1807 -void cheatsWriteByte(u8 *address, u8 value)
 88.1808 -#else
 88.1809 -void cheatsWriteByte(u8 *, u8)
 88.1810 -#endif
 88.1811 -{
 88.1812 -#ifdef BKPT_SUPPORT
 88.1813 -#ifdef SDL
 88.1814 -	if (cheatsNumber == 0)
 88.1815 -	{
 88.1816 -		debuggerBreakOnWrite((u32 *)address, *address, value, 0);
 88.1817 -		CPU_BREAK_LOOP2;
 88.1818 -		*address = value;
 88.1819 -		return;
 88.1820 -	}
 88.1821 -#endif
 88.1822 -#endif
 88.1823 -}
 88.1824 -
 88.1825 -#undef CPU_BREAK_LOOP2
    89.1 --- a/src/gba/GBACheats.h	Sat Mar 03 10:54:39 2012 -0600
    89.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.3 @@ -1,44 +0,0 @@
    89.4 -#ifndef VBA_GBA_CHEATS_H
    89.5 -#define VBA_GBA_CHEATS_H
    89.6 -
    89.7 -#if _MSC_VER > 1000
    89.8 -#pragma once
    89.9 -#endif // _MSC_VER > 1000
   89.10 -
   89.11 -#include "zlib.h"
   89.12 -#include "../Port.h"
   89.13 -
   89.14 -struct CheatsData
   89.15 -{
   89.16 -	int  code;
   89.17 -	int  size;
   89.18 -	int  status;
   89.19 -	bool enabled;
   89.20 -	u32  address;
   89.21 -	u32  value;
   89.22 -	u32  oldValue;
   89.23 -	char codestring[20];
   89.24 -	char desc[32];
   89.25 -};
   89.26 -
   89.27 -extern void cheatsAdd(const char *, const char *, u32, u32, int, int);
   89.28 -extern void cheatsAddCheatCode(const char *code, const char *desc);
   89.29 -extern void cheatsAddGSACode(const char *code, const char *desc, bool v3);
   89.30 -extern void cheatsAddCBACode(const char *code, const char *desc);
   89.31 -extern bool cheatsImportGSACodeFile(const char *name, int game, bool v3);
   89.32 -extern void cheatsDelete(int number, bool restore);
   89.33 -extern void cheatsDeleteAll(bool restore);
   89.34 -extern void cheatsEnable(int number);
   89.35 -extern void cheatsDisable(int number);
   89.36 -extern void cheatsSaveGame(gzFile file);
   89.37 -extern void cheatsReadGame(gzFile file);
   89.38 -extern void cheatsSaveCheatList(const char *file);
   89.39 -extern bool cheatsLoadCheatList(const char *file);
   89.40 -extern void       cheatsWriteMemory(u32 *, u32, u32);
   89.41 -extern void       cheatsWriteHalfWord(u16 *, u16, u16);
   89.42 -extern void       cheatsWriteByte(u8 *, u8);
   89.43 -extern int        cheatsCheckKeys(u32, u32);
   89.44 -extern int        cheatsNumber;
   89.45 -extern CheatsData cheatsList[100];
   89.46 -
   89.47 -#endif // GBA_CHEATS_H
    90.1 --- a/src/gba/GBAGfx.cpp	Sat Mar 03 10:54:39 2012 -0600
    90.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.3 @@ -1,35 +0,0 @@
    90.4 -#include "../Port.h"
    90.5 -#include "GBAGfx.h"
    90.6 -
    90.7 -int coeff[32] = {
    90.8 -	0,   1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
    90.9 -	16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
   90.10 -};
   90.11 -
   90.12 -// some of the rendering code in gfx.h (such as mode 0 line 1298)
   90.13 -// renders outside the given buffer (past 239) which corrupts other memory,
   90.14 -// so rather than find all places in that code that need to be fixed,
   90.15 -// just give it enough extra scratch space to use
   90.16 -
   90.17 -u32  line0[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.18 -u32  line1[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.19 -u32  line2[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.20 -u32  line3[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.21 -u32  lineOBJ[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.22 -u32  lineOBJWin[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.23 -u32  lineMix[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.24 -bool gfxInWin0[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.25 -bool gfxInWin1[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   90.26 -
   90.27 -int gfxBG2Changed = 0;
   90.28 -int gfxBG3Changed = 0;
   90.29 -
   90.30 -int gfxBG2X       = 0;
   90.31 -int gfxBG2Y       = 0;
   90.32 -int gfxBG2LastX   = 0;
   90.33 -int gfxBG2LastY   = 0;
   90.34 -int gfxBG3X       = 0;
   90.35 -int gfxBG3Y       = 0;
   90.36 -int gfxBG3LastX   = 0;
   90.37 -int gfxBG3LastY   = 0;
   90.38 -int gfxLastVCOUNT = 0;
    91.1 --- a/src/gba/GBAGfx.h	Sat Mar 03 10:54:39 2012 -0600
    91.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.3 @@ -1,1791 +0,0 @@
    91.4 -#ifndef VBA_GBA_GFX_H
    91.5 -#define VBA_GBA_GFX_H
    91.6 -
    91.7 -#if _MSC_VER > 1000
    91.8 -#pragma once
    91.9 -#endif // _MSC_VER > 1000
   91.10 -
   91.11 -#include "../Port.h"
   91.12 -#include "GBA.h"
   91.13 -#include "GBAGlobals.h"
   91.14 -
   91.15 -//#define SPRITE_DEBUG
   91.16 -
   91.17 -void gfxDrawTextScreen(u16, u16, u16, u32 *);
   91.18 -void gfxDrawRotScreen(u16,
   91.19 -                      u16, u16,
   91.20 -                      u16, u16,
   91.21 -                      u16, u16,
   91.22 -                      u16, u16,
   91.23 -                      int&, int&,
   91.24 -                      int,
   91.25 -                      u32 *);
   91.26 -void gfxDrawRotScreen16Bit(u16,
   91.27 -                           u16, u16,
   91.28 -                           u16, u16,
   91.29 -                           u16, u16,
   91.30 -                           u16, u16,
   91.31 -                           int&, int&,
   91.32 -                           int,
   91.33 -                           u32 *);
   91.34 -void gfxDrawRotScreen256(u16,
   91.35 -                         u16, u16,
   91.36 -                         u16, u16,
   91.37 -                         u16, u16,
   91.38 -                         u16, u16,
   91.39 -                         int&, int&,
   91.40 -                         int,
   91.41 -                         u32 *);
   91.42 -void gfxDrawRotScreen16Bit160(u16,
   91.43 -                              u16, u16,
   91.44 -                              u16, u16,
   91.45 -                              u16, u16,
   91.46 -                              u16, u16,
   91.47 -                              int&, int&,
   91.48 -                              int,
   91.49 -                              u32 *);
   91.50 -void gfxDrawSprites(u32 *);
   91.51 -void gfxIncreaseBrightness(u32 *line, int coeff);
   91.52 -void gfxDecreaseBrightness(u32 *line, int coeff);
   91.53 -void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb);
   91.54 -
   91.55 -void mode0RenderLine();
   91.56 -void mode0RenderLineNoWindow();
   91.57 -void mode0RenderLineAll();
   91.58 -
   91.59 -void mode1RenderLine();
   91.60 -void mode1RenderLineNoWindow();
   91.61 -void mode1RenderLineAll();
   91.62 -
   91.63 -void mode2RenderLine();
   91.64 -void mode2RenderLineNoWindow();
   91.65 -void mode2RenderLineAll();
   91.66 -
   91.67 -void mode3RenderLine();
   91.68 -void mode3RenderLineNoWindow();
   91.69 -void mode3RenderLineAll();
   91.70 -
   91.71 -void mode4RenderLine();
   91.72 -void mode4RenderLineNoWindow();
   91.73 -void mode4RenderLineAll();
   91.74 -
   91.75 -void mode5RenderLine();
   91.76 -void mode5RenderLineNoWindow();
   91.77 -void mode5RenderLineAll();
   91.78 -
   91.79 -extern int  coeff[32];
   91.80 -
   91.81 -#define LINE_BUFFER_OVERFLOW_LEEWAY (512-240)
   91.82 -
   91.83 -extern u32  line0[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.84 -extern u32  line1[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.85 -extern u32  line2[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.86 -extern u32  line3[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.87 -extern u32  lineOBJ[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.88 -extern u32  lineOBJWin[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.89 -extern u32  lineMix[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.90 -extern bool gfxInWin0[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.91 -extern bool gfxInWin1[240+LINE_BUFFER_OVERFLOW_LEEWAY];
   91.92 -
   91.93 -extern int gfxBG2Changed;
   91.94 -extern int gfxBG3Changed;
   91.95 -
   91.96 -extern int gfxBG2X;
   91.97 -extern int gfxBG2Y;
   91.98 -extern int gfxBG2LastX;
   91.99 -extern int gfxBG2LastY;
  91.100 -extern int gfxBG3X;
  91.101 -extern int gfxBG3Y;
  91.102 -extern int gfxBG3LastX;
  91.103 -extern int gfxBG3LastY;
  91.104 -extern int gfxLastVCOUNT;
  91.105 -
  91.106 -inline void gfxClearArray(u32 *array)
  91.107 -{
  91.108 -	for (int i = 0; i < 240; i++)
  91.109 -	{
  91.110 -		*array++ = 0x80000000;
  91.111 -	}
  91.112 -}
  91.113 -
  91.114 -inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
  91.115 -                              u32 *line)
  91.116 -{
  91.117 -	u16 *palette    = (u16 *)paletteRAM;
  91.118 -	u8 * charBase   = &vram[((control >> 2) & 0x03) * 0x4000];
  91.119 -	u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
  91.120 -	u32  prio       = ((control & 3)<<25) + 0x1000000;
  91.121 -	int  sizeX      = 256;
  91.122 -	int  sizeY      = 256;
  91.123 -	switch ((control >> 14) & 3)
  91.124 -	{
  91.125 -	case 0:
  91.126 -		break;
  91.127 -	case 1:
  91.128 -		sizeX = 512;
  91.129 -		break;
  91.130 -	case 2:
  91.131 -		sizeY = 512;
  91.132 -		break;
  91.133 -	case 3:
  91.134 -		sizeX = 512;
  91.135 -		sizeY = 512;
  91.136 -		break;
  91.137 -	}
  91.138 -
  91.139 -	int maskX = sizeX-1;
  91.140 -	int maskY = sizeY-1;
  91.141 -
  91.142 -	bool mosaicOn = (control & 0x40) ? true : false;
  91.143 -
  91.144 -	int xxx     = hofs & maskX;
  91.145 -	int yyy     = (vofs + VCOUNT) & maskY;
  91.146 -	int mosaicX = (MOSAIC & 0x000F)+1;
  91.147 -	int mosaicY = ((MOSAIC & 0x00F0)>>4)+1;
  91.148 -
  91.149 -	if (mosaicOn)
  91.150 -	{
  91.151 -		if ((VCOUNT % mosaicY) != 0)
  91.152 -		{
  91.153 -			mosaicY = (VCOUNT / mosaicY) * mosaicY;
  91.154 -			yyy     = (vofs + mosaicY) & maskY;
  91.155 -		}
  91.156 -	}
  91.157 -
  91.158 -	if (yyy > 255 && sizeY > 256)
  91.159 -	{
  91.160 -		yyy        &= 255;
  91.161 -		screenBase += 0x400;
  91.162 -		if (sizeX > 256)
  91.163 -			screenBase += 0x400;
  91.164 -	}
  91.165 -
  91.166 -	int yshift = ((yyy>>3)<<5);
  91.167 -	if ((control) & 0x80)
  91.168 -	{
  91.169 -		u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
  91.170 -		for (int x = 0; x < 240; x++)
  91.171 -		{
  91.172 -			u16 data = READ16LE(screenSource);
  91.173 -
  91.174 -			int tile  = data & 0x3FF;
  91.175 -			int tileX = (xxx & 7);
  91.176 -			int tileY = yyy & 7;
  91.177 -
  91.178 -			if (data & 0x0400)
  91.179 -				tileX = 7 - tileX;
  91.180 -			if (data & 0x0800)
  91.181 -				tileY = 7 - tileY;
  91.182 -
  91.183 -			u8 color = charBase[tile * 64 + tileY * 8 + tileX];
  91.184 -
  91.185 -			line[x] = color ? (READ16LE(&palette[color]) | prio) : 0x80000000;
  91.186 -
  91.187 -			if (data & 0x0400)
  91.188 -			{
  91.189 -				if (tileX == 0)
  91.190 -					screenSource++;
  91.191 -			}
  91.192 -			else if (tileX == 7)
  91.193 -				screenSource++;
  91.194 -			xxx++;
  91.195 -			if (xxx == 256)
  91.196 -			{
  91.197 -				if (sizeX > 256)
  91.198 -					screenSource = screenBase + 0x400 + yshift;
  91.199 -				else
  91.200 -				{
  91.201 -					screenSource = screenBase + yshift;
  91.202 -					xxx = 0;
  91.203 -				}
  91.204 -			}
  91.205 -			else if (xxx >= sizeX)
  91.206 -			{
  91.207 -				xxx = 0;
  91.208 -				screenSource = screenBase + yshift;
  91.209 -			}
  91.210 -		}
  91.211 -	}
  91.212 -	else
  91.213 -	{
  91.214 -		u16 *screenSource = screenBase + 0x400*(xxx>>8)+((xxx&255)>>3) +
  91.215 -		                    yshift;
  91.216 -		for (int x = 0; x < 240; x++)
  91.217 -		{
  91.218 -			u16 data = READ16LE(screenSource);
  91.219 -
  91.220 -			int tile  = data & 0x3FF;
  91.221 -			int tileX = (xxx & 7);
  91.222 -			int tileY = yyy & 7;
  91.223 -
  91.224 -			if (data & 0x0400)
  91.225 -				tileX = 7 - tileX;
  91.226 -			if (data & 0x0800)
  91.227 -				tileY = 7 - tileY;
  91.228 -
  91.229 -			u8 color = charBase[(tile<<5) + (tileY<<2) + (tileX>>1)];
  91.230 -
  91.231 -			if (tileX & 1)
  91.232 -			{
  91.233 -				color = (color >> 4);
  91.234 -			}
  91.235 -			else
  91.236 -			{
  91.237 -				color &= 0x0F;
  91.238 -			}
  91.239 -
  91.240 -			int pal = (READ16LE(screenSource)>>8) & 0xF0;
  91.241 -			line[x] = color ? (READ16LE(&palette[pal + color])|prio) : 0x80000000;
  91.242 -
  91.243 -			if (data & 0x0400)
  91.244 -			{
  91.245 -				if (tileX == 0)
  91.246 -					screenSource++;
  91.247 -			}
  91.248 -			else if (tileX == 7)
  91.249 -				screenSource++;
  91.250 -			xxx++;
  91.251 -			if (xxx == 256)
  91.252 -			{
  91.253 -				if (sizeX > 256)
  91.254 -					screenSource = screenBase + 0x400 + yshift;
  91.255 -				else
  91.256 -				{
  91.257 -					screenSource = screenBase + yshift;
  91.258 -					xxx = 0;
  91.259 -				}
  91.260 -			}
  91.261 -			else if (xxx >= sizeX)
  91.262 -			{
  91.263 -				xxx = 0;
  91.264 -				screenSource = screenBase + yshift;
  91.265 -			}
  91.266 -		}
  91.267 -	}
  91.268 -	if (mosaicOn)
  91.269 -	{
  91.270 -		if (mosaicX > 1)
  91.271 -		{
  91.272 -			int m = 1;
  91.273 -			for (int i = 0; i < 239; i++)
  91.274 -			{
  91.275 -				line[i+1] = line[i];
  91.276 -				m++;
  91.277 -				if (m == mosaicX)
  91.278 -				{
  91.279 -					m = 1;
  91.280 -					i++;
  91.281 -				}
  91.282 -			}
  91.283 -		}
  91.284 -	}
  91.285 -}
  91.286 -
  91.287 -inline void gfxDrawRotScreen(u16 control,
  91.288 -                             u16 x_l, u16 x_h,
  91.289 -                             u16 y_l, u16 y_h,
  91.290 -                             u16 pa,  u16 pb,
  91.291 -                             u16 pc,  u16 pd,
  91.292 -                             int& currentX, int& currentY,
  91.293 -                             int changed,
  91.294 -                             u32 *line)
  91.295 -{
  91.296 -	u16 *palette    = (u16 *)paletteRAM;
  91.297 -	u8 * charBase   = &vram[((control >> 2) & 0x03) * 0x4000];
  91.298 -	u8 * screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800];
  91.299 -	int  prio       = ((control & 3) << 25) + 0x1000000;
  91.300 -
  91.301 -	int sizeX = 128;
  91.302 -	int sizeY = 128;
  91.303 -	switch ((control >> 14) & 3)
  91.304 -	{
  91.305 -	case 0:
  91.306 -		break;
  91.307 -	case 1:
  91.308 -		sizeX = sizeY = 256;
  91.309 -		break;
  91.310 -	case 2:
  91.311 -		sizeX = sizeY = 512;
  91.312 -		break;
  91.313 -	case 3:
  91.314 -		sizeX = sizeY = 1024;
  91.315 -		break;
  91.316 -	}
  91.317 -
  91.318 -	int dx = pa & 0x7FFF;
  91.319 -	if (pa & 0x8000)
  91.320 -		dx |= 0xFFFF8000;
  91.321 -	int dmx = pb & 0x7FFF;
  91.322 -	if (pb & 0x8000)
  91.323 -		dmx |= 0xFFFF8000;
  91.324 -	int dy = pc & 0x7FFF;
  91.325 -	if (pc & 0x8000)
  91.326 -		dy |= 0xFFFF8000;
  91.327 -	int dmy = pd & 0x7FFFF;
  91.328 -	if (pd & 0x8000)
  91.329 -		dmy |= 0xFFFF8000;
  91.330 -
  91.331 -	if (VCOUNT == 0)
  91.332 -		changed = 3;
  91.333 -
  91.334 -	if (changed & 1)
  91.335 -	{
  91.336 -		currentX = (x_l) | ((x_h & 0x07FF)<<16);
  91.337 -		if (x_h & 0x0800)
  91.338 -			currentX |= 0xF8000000;
  91.339 -	}
  91.340 -	else
  91.341 -	{
  91.342 -		currentX += dmx;
  91.343 -	}
  91.344 -
  91.345 -	if (changed & 2)
  91.346 -	{
  91.347 -		currentY = (y_l) | ((y_h & 0x07FF)<<16);
  91.348 -		if (y_h & 0x0800)
  91.349 -			currentY |= 0xF8000000;
  91.350 -	}
  91.351 -	else
  91.352 -	{
  91.353 -		currentY += dmy;
  91.354 -	}
  91.355 -
  91.356 -	int realX = currentX;
  91.357 -	int realY = currentY;
  91.358 -
  91.359 -	if (control & 0x40)
  91.360 -	{
  91.361 -		int mosaicY = ((MOSAIC & 0xF0)>>4) + 1;
  91.362 -		int y       = (VCOUNT % mosaicY);
  91.363 -		realX -= y*dmx;
  91.364 -		realY -= y*dmy;
  91.365 -	}
  91.366 -
  91.367 -	int xxx = (realX >> 8);
  91.368 -	int yyy = (realY >> 8);
  91.369 -
  91.370 -	if (control & 0x2000)
  91.371 -	{
  91.372 -		xxx %= sizeX;
  91.373 -		yyy %= sizeY;
  91.374 -		if (xxx < 0)
  91.375 -			xxx += sizeX;
  91.376 -		if (yyy < 0)
  91.377 -			yyy += sizeY;
  91.378 -	}
  91.379 -
  91.380 -	if (control & 0x80)
  91.381 -	{
  91.382 -		for (int x = 0; x < 240; x++)
  91.383 -		{
  91.384 -			if (xxx < 0 ||
  91.385 -			    yyy < 0 ||
  91.386 -			    xxx >= sizeX ||
  91.387 -			    yyy >= sizeY)
  91.388 -			{
  91.389 -				line[x] = 0x80000000;
  91.390 -			}
  91.391 -			else
  91.392 -			{
  91.393 -				int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
  91.394 -
  91.395 -				int tileX = (xxx & 7);
  91.396 -				int tileY = yyy & 7;
  91.397 -
  91.398 -				u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
  91.399 -
  91.400 -				line[x] = color ? (READ16LE(&palette[color])|prio) : 0x80000000;
  91.401 -			}
  91.402 -			realX += dx;
  91.403 -			realY += dy;
  91.404 -
  91.405 -			xxx = (realX >> 8);
  91.406 -			yyy = (realY >> 8);
  91.407 -
  91.408 -			if (control & 0x2000)
  91.409 -			{
  91.410 -				xxx %= sizeX;
  91.411 -				yyy %= sizeY;
  91.412 -				if (xxx < 0)
  91.413 -					xxx += sizeX;
  91.414 -				if (yyy < 0)
  91.415 -					yyy += sizeY;
  91.416 -			}
  91.417 -		}
  91.418 -	}
  91.419 -	else
  91.420 -	{
  91.421 -		for (int x = 0; x < 240; x++)
  91.422 -		{
  91.423 -			if (xxx < 0 ||
  91.424 -			    yyy < 0 ||
  91.425 -			    xxx >= sizeX ||
  91.426 -			    yyy >= sizeY)
  91.427 -			{
  91.428 -				line[x] = 0x80000000;
  91.429 -			}
  91.430 -			else
  91.431 -			{
  91.432 -				int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
  91.433 -
  91.434 -				int tileX = (xxx & 7);
  91.435 -				int tileY = yyy & 7;
  91.436 -
  91.437 -				u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
  91.438 -
  91.439 -				line[x] = color ? (READ16LE(&palette[color])|prio) : 0x80000000;
  91.440 -			}
  91.441 -			realX += dx;
  91.442 -			realY += dy;
  91.443 -
  91.444 -			xxx = (realX >> 8);
  91.445 -			yyy = (realY >> 8);
  91.446 -
  91.447 -			if (control & 0x2000)
  91.448 -			{
  91.449 -				xxx %= sizeX;
  91.450 -				yyy %= sizeY;
  91.451 -				if (xxx < 0)
  91.452 -					xxx += sizeX;
  91.453 -				if (yyy < 0)
  91.454 -					yyy += sizeY;
  91.455 -			}
  91.456 -		}
  91.457 -	}
  91.458 -
  91.459 -	if (control & 0x40)
  91.460 -	{
  91.461 -		int mosaicX = (MOSAIC & 0xF) + 1;
  91.462 -		if (mosaicX > 1)
  91.463 -		{
  91.464 -			int m = 1;
  91.465 -			for (int i = 0; i < 239; i++)
  91.466 -			{
  91.467 -				line[i+1] = line[i];
  91.468 -				m++;
  91.469 -				if (m == mosaicX)
  91.470 -				{
  91.471 -					m = 1;
  91.472 -					i++;
  91.473 -				}
  91.474 -			}
  91.475 -		}
  91.476 -	}
  91.477 -}
  91.478 -
  91.479 -inline void gfxDrawRotScreen16Bit(u16 control,
  91.480 -                                  u16 x_l, u16 x_h,
  91.481 -                                  u16 y_l, u16 y_h,
  91.482 -                                  u16 pa,  u16 pb,
  91.483 -                                  u16 pc,  u16 pd,
  91.484 -                                  int& currentX, int& currentY,
  91.485 -                                  int changed,
  91.486 -                                  u32 *line)
  91.487 -{
  91.488 -	u16 *screenBase = (u16 *)&vram[0];
  91.489 -	int  prio       = ((control & 3) << 25) + 0x1000000;
  91.490 -	int  sizeX      = 240;
  91.491 -	int  sizeY      = 160;
  91.492 -
  91.493 -	int startX = (x_l) | ((x_h & 0x07FF)<<16);
  91.494 -	if (x_h & 0x0800)
  91.495 -		startX |= 0xF8000000;
  91.496 -	int startY = (y_l) | ((y_h & 0x07FF)<<16);
  91.497 -	if (y_h & 0x0800)
  91.498 -		startY |= 0xF8000000;
  91.499 -
  91.500 -	int dx = pa & 0x7FFF;
  91.501 -	if (pa & 0x8000)
  91.502 -		dx |= 0xFFFF8000;
  91.503 -	int dmx = pb & 0x7FFF;
  91.504 -	if (pb & 0x8000)
  91.505 -		dmx |= 0xFFFF8000;
  91.506 -	int dy = pc & 0x7FFF;
  91.507 -	if (pc & 0x8000)
  91.508 -		dy |= 0xFFFF8000;
  91.509 -	int dmy = pd & 0x7FFFF;
  91.510 -	if (pd & 0x8000)
  91.511 -		dmy |= 0xFFFF8000;
  91.512 -
  91.513 -	if (VCOUNT == 0)
  91.514 -		changed = 3;
  91.515 -
  91.516 -	if (changed & 1)
  91.517 -	{
  91.518 -		currentX = (x_l) | ((x_h & 0x07FF)<<16);
  91.519 -		if (x_h & 0x0800)
  91.520 -			currentX |= 0xF8000000;
  91.521 -	}
  91.522 -	else
  91.523 -		currentX += dmx;
  91.524 -
  91.525 -	if (changed & 2)
  91.526 -	{
  91.527 -		currentY = (y_l) | ((y_h & 0x07FF)<<16);
  91.528 -		if (y_h & 0x0800)
  91.529 -			currentY |= 0xF8000000;
  91.530 -	}
  91.531 -	else
  91.532 -	{
  91.533 -		currentY += dmy;
  91.534 -	}
  91.535 -
  91.536 -	int realX = currentX;
  91.537 -	int realY = currentY;
  91.538 -
  91.539 -	if (control & 0x40)
  91.540 -	{
  91.541 -		int mosaicY = ((MOSAIC & 0xF0)>>4) + 1;
  91.542 -		int y       = (VCOUNT % mosaicY);
  91.543 -		realX -= y*dmx;
  91.544 -		realY -= y*dmy;
  91.545 -	}
  91.546 -
  91.547 -	int xxx = (realX >> 8);
  91.548 -	int yyy = (realY >> 8);
  91.549 -
  91.550 -	for (int x = 0; x < 240; x++)
  91.551 -	{
  91.552 -		if (xxx < 0 ||
  91.553 -		    yyy < 0 ||
  91.554 -		    xxx >= sizeX ||
  91.555 -		    yyy >= sizeY)
  91.556 -		{
  91.557 -			line[x] = 0x80000000;
  91.558 -		}
  91.559 -		else
  91.560 -		{
  91.561 -			line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
  91.562 -		}
  91.563 -		realX += dx;
  91.564 -		realY += dy;
  91.565 -
  91.566 -		xxx = (realX >> 8);
  91.567 -		yyy = (realY >> 8);
  91.568 -	}
  91.569 -
  91.570 -	if (control & 0x40)
  91.571 -	{
  91.572 -		int mosaicX = (MOSAIC & 0xF) + 1;
  91.573 -		if (mosaicX > 1)
  91.574 -		{
  91.575 -			int m = 1;
  91.576 -			for (int i = 0; i < 239; i++)
  91.577 -			{
  91.578 -				line[i+1] = line[i];
  91.579 -				m++;
  91.580 -				if (m == mosaicX)
  91.581 -				{
  91.582 -					m = 1;
  91.583 -					i++;
  91.584 -				}
  91.585 -			}
  91.586 -		}
  91.587 -	}
  91.588 -}
  91.589 -
  91.590 -inline void gfxDrawRotScreen256(u16 control,
  91.591 -                                u16 x_l, u16 x_h,
  91.592 -                                u16 y_l, u16 y_h,
  91.593 -                                u16 pa,  u16 pb,
  91.594 -                                u16 pc,  u16 pd,
  91.595 -                                int &currentX, int& currentY,
  91.596 -                                int changed,
  91.597 -                                u32 *line)
  91.598 -{
  91.599 -	u16 *palette    = (u16 *)paletteRAM;
  91.600 -	u8 * screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000];
  91.601 -	int  prio       = ((control & 3) << 25) + 0x1000000;
  91.602 -	int  sizeX      = 240;
  91.603 -	int  sizeY      = 160;
  91.604 -
  91.605 -	int startX = (x_l) | ((x_h & 0x07FF)<<16);
  91.606 -	if (x_h & 0x0800)
  91.607 -		startX |= 0xF8000000;
  91.608 -	int startY = (y_l) | ((y_h & 0x07FF)<<16);
  91.609 -	if (y_h & 0x0800)
  91.610 -		startY |= 0xF8000000;
  91.611 -
  91.612 -	int dx = pa & 0x7FFF;
  91.613 -	if (pa & 0x8000)
  91.614 -		dx |= 0xFFFF8000;
  91.615 -	int dmx = pb & 0x7FFF;
  91.616 -	if (pb & 0x8000)
  91.617 -		dmx |= 0xFFFF8000;
  91.618 -	int dy = pc & 0x7FFF;
  91.619 -	if (pc & 0x8000)
  91.620 -		dy |= 0xFFFF8000;
  91.621 -	int dmy = pd & 0x7FFFF;
  91.622 -	if (pd & 0x8000)
  91.623 -		dmy |= 0xFFFF8000;
  91.624 -
  91.625 -	if (VCOUNT == 0)
  91.626 -		changed = 3;
  91.627 -
  91.628 -	if (changed & 1)
  91.629 -	{
  91.630 -		currentX = (x_l) | ((x_h & 0x07FF)<<16);
  91.631 -		if (x_h & 0x0800)
  91.632 -			currentX |= 0xF8000000;
  91.633 -	}
  91.634 -	else
  91.635 -	{
  91.636 -		currentX += dmx;
  91.637 -	}
  91.638 -
  91.639 -	if (changed & 2)
  91.640 -	{
  91.641 -		currentY = (y_l) | ((y_h & 0x07FF)<<16);
  91.642 -		if (y_h & 0x0800)
  91.643 -			currentY |= 0xF8000000;
  91.644 -	}
  91.645 -	else
  91.646 -	{
  91.647 -		currentY += dmy;
  91.648 -	}
  91.649 -
  91.650 -	int realX = currentX;
  91.651 -	int realY = currentY;
  91.652 -
  91.653 -	if (control & 0x40)
  91.654 -	{
  91.655 -		int mosaicY = ((MOSAIC & 0xF0)>>4) + 1;
  91.656 -		int y       = (VCOUNT / mosaicY) * mosaicY;
  91.657 -		realX = startX + y*dmx;
  91.658 -		realY = startY + y*dmy;
  91.659 -	}
  91.660 -
  91.661 -	int xxx = (realX >> 8);
  91.662 -	int yyy = (realY >> 8);
  91.663 -
  91.664 -	for (int x = 0; x < 240; x++)
  91.665 -	{
  91.666 -		if (xxx < 0 ||
  91.667 -		    yyy < 0 ||
  91.668 -		    xxx >= sizeX ||
  91.669 -		    yyy >= sizeY)
  91.670 -		{
  91.671 -			line[x] = 0x80000000;
  91.672 -		}
  91.673 -		else
  91.674 -		{
  91.675 -			u8 color = screenBase[yyy * 240 + xxx];
  91.676 -
  91.677 -			line[x] = color ? (READ16LE(&palette[color])|prio) : 0x80000000;
  91.678 -		}
  91.679 -		realX += dx;
  91.680 -		realY += dy;
  91.681 -
  91.682 -		xxx = (realX >> 8);
  91.683 -		yyy = (realY >> 8);
  91.684 -	}
  91.685 -
  91.686 -	if (control & 0x40)
  91.687 -	{
  91.688 -		int mosaicX = (MOSAIC & 0xF) + 1;
  91.689 -		if (mosaicX > 1)
  91.690 -		{
  91.691 -			int m = 1;
  91.692 -			for (int i = 0; i < 239; i++)
  91.693 -			{
  91.694 -				line[i+1] = line[i];
  91.695 -				m++;
  91.696 -				if (m == mosaicX)
  91.697 -				{
  91.698 -					m = 1;
  91.699 -					i++;
  91.700 -				}
  91.701 -			}
  91.702 -		}
  91.703 -	}
  91.704 -}
  91.705 -
  91.706 -inline void gfxDrawRotScreen16Bit160(u16 control,
  91.707 -                                     u16 x_l, u16 x_h,
  91.708 -                                     u16 y_l, u16 y_h,
  91.709 -                                     u16 pa,  u16 pb,
  91.710 -                                     u16 pc,  u16 pd,
  91.711 -                                     int& currentX, int& currentY,
  91.712 -                                     int changed,
  91.713 -                                     u32 *line)
  91.714 -{
  91.715 -	u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] :
  91.716 -	                  (u16 *)&vram[0];
  91.717 -	int prio  = ((control & 3) << 25) + 0x1000000;
  91.718 -	int sizeX = 160;
  91.719 -	int sizeY = 128;
  91.720 -
  91.721 -	int startX = (x_l) | ((x_h & 0x07FF)<<16);
  91.722 -	if (x_h & 0x0800)
  91.723 -		startX |= 0xF8000000;
  91.724 -	int startY = (y_l) | ((y_h & 0x07FF)<<16);
  91.725 -	if (y_h & 0x0800)
  91.726 -		startY |= 0xF8000000;
  91.727 -
  91.728 -	int dx = pa & 0x7FFF;
  91.729 -	if (pa & 0x8000)
  91.730 -		dx |= 0xFFFF8000;
  91.731 -	int dmx = pb & 0x7FFF;
  91.732 -	if (pb & 0x8000)
  91.733 -		dmx |= 0xFFFF8000;
  91.734 -	int dy = pc & 0x7FFF;
  91.735 -	if (pc & 0x8000)
  91.736 -		dy |= 0xFFFF8000;
  91.737 -	int dmy = pd & 0x7FFFF;
  91.738 -	if (pd & 0x8000)
  91.739 -		dmy |= 0xFFFF8000;
  91.740 -
  91.741 -	if (VCOUNT == 0)
  91.742 -		changed = 3;
  91.743 -
  91.744 -	if (changed & 1)
  91.745 -	{
  91.746 -		currentX = (x_l) | ((x_h & 0x07FF)<<16);
  91.747 -		if (x_h & 0x0800)
  91.748 -			currentX |= 0xF8000000;
  91.749 -	}
  91.750 -	else
  91.751 -	{
  91.752 -		currentX += dmx;
  91.753 -	}
  91.754 -
  91.755 -	if (changed & 2)
  91.756 -	{
  91.757 -		currentY = (y_l) | ((y_h & 0x07FF)<<16);
  91.758 -		if (y_h & 0x0800)
  91.759 -			currentY |= 0xF8000000;
  91.760 -	}
  91.761 -	else
  91.762 -	{
  91.763 -		currentY += dmy;
  91.764 -	}
  91.765 -
  91.766 -	int realX = currentX;
  91.767 -	int realY = currentY;
  91.768 -
  91.769 -	if (control & 0x40)
  91.770 -	{
  91.771 -		int mosaicY = ((MOSAIC & 0xF0)>>4) + 1;
  91.772 -		int y       = (VCOUNT / mosaicY) * mosaicY;
  91.773 -		realX = startX + y*dmx;
  91.774 -		realY = startY + y*dmy;
  91.775 -	}
  91.776 -
  91.777 -	int xxx = (realX >> 8);
  91.778 -	int yyy = (realY >> 8);
  91.779 -
  91.780 -	for (int x = 0; x < 240; x++)
  91.781 -	{
  91.782 -		if (xxx < 0 ||
  91.783 -		    yyy < 0 ||
  91.784 -		    xxx >= sizeX ||
  91.785 -		    yyy >= sizeY)
  91.786 -		{
  91.787 -			line[x] = 0x80000000;
  91.788 -		}
  91.789 -		else
  91.790 -		{
  91.791 -			line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
  91.792 -		}
  91.793 -		realX += dx;
  91.794 -		realY += dy;
  91.795 -
  91.796 -		xxx = (realX >> 8);
  91.797 -		yyy = (realY >> 8);
  91.798 -	}
  91.799 -
  91.800 -	if (control & 0x40)
  91.801 -	{
  91.802 -		int mosaicX = (MOSAIC & 0xF) + 1;
  91.803 -		if (mosaicX > 1)
  91.804 -		{
  91.805 -			int m = 1;
  91.806 -			for (int i = 0; i < 239; i++)
  91.807 -			{
  91.808 -				line[i+1] = line[i];
  91.809 -				m++;
  91.810 -				if (m == mosaicX)
  91.811 -				{
  91.812 -					m = 1;
  91.813 -					i++;
  91.814 -				}
  91.815 -			}
  91.816 -		}
  91.817 -	}
  91.818 -}
  91.819 -
  91.820 -inline void gfxDrawSprites(u32 *lineOBJ)
  91.821 -{
  91.822 -	int m = 0;
  91.823 -	gfxClearArray(lineOBJ);
  91.824 -	if (layerEnable & 0x1000)
  91.825 -	{
  91.826 -		u16 *sprites       = (u16 *)oam;
  91.827 -		u16 *spritePalette = &((u16 *)paletteRAM)[256];
  91.828 -		int  mosaicY       = ((MOSAIC & 0xF000)>>12) + 1;
  91.829 -		int  mosaicX       = ((MOSAIC & 0xF00)>>8) + 1;
  91.830 -		for (int x = 0; x < 128; x++)
  91.831 -		{
  91.832 -			u16 a0 = READ16LE(sprites++);
  91.833 -			u16 a1 = READ16LE(sprites++);
  91.834 -			u16 a2 = READ16LE(sprites++);
  91.835 -			sprites++;
  91.836 -
  91.837 -			// ignore OBJ-WIN
  91.838 -			if ((a0 & 0x0c00) == 0x0800)
  91.839 -				continue;
  91.840 -
  91.841 -			int sizeY = 8;
  91.842 -			int sizeX = 8;
  91.843 -
  91.844 -			switch (((a0 >>12) & 0x0c)|(a1>>14))
  91.845 -			{
  91.846 -			case 0:
  91.847 -				break;
  91.848 -			case 1:
  91.849 -				sizeX = sizeY = 16;
  91.850 -				break;
  91.851 -			case 2:
  91.852 -				sizeX = sizeY = 32;
  91.853 -				break;
  91.854 -			case 3:
  91.855 -				sizeX = sizeY = 64;
  91.856 -				break;
  91.857 -			case 4:
  91.858 -				sizeX = 16;
  91.859 -				break;
  91.860 -			case 5:
  91.861 -				sizeX = 32;
  91.862 -				break;
  91.863 -			case 6:
  91.864 -				sizeX = 32;
  91.865 -				sizeY = 16;
  91.866 -				break;
  91.867 -			case 7:
  91.868 -				sizeX = 64;
  91.869 -				sizeY = 32;
  91.870 -				break;
  91.871 -			case 8:
  91.872 -				sizeY = 16;
  91.873 -				break;
  91.874 -			case 9:
  91.875 -				sizeY = 32;
  91.876 -				break;
  91.877 -			case 10:
  91.878 -				sizeX = 16;
  91.879 -				sizeY = 32;
  91.880 -				break;
  91.881 -			case 11:
  91.882 -				sizeX = 32;
  91.883 -				sizeY = 64;
  91.884 -				break;
  91.885 -			default:
  91.886 -				continue;
  91.887 -			}
  91.888 -
  91.889 -#ifdef SPRITE_DEBUG
  91.890 -			int maskX = sizeX-1;
  91.891 -			int maskY = sizeY-1;
  91.892 -#endif
  91.893 -
  91.894 -			int sy = (a0 & 255);
  91.895 -
  91.896 -			if (sy > 160)
  91.897 -				sy -= 256;
  91.898 -
  91.899 -			if (a0 & 0x0100)
  91.900 -			{
  91.901 -				int fieldX = sizeX;
  91.902 -				int fieldY = sizeY;
  91.903 -				if (a0 & 0x0200)
  91.904 -				{
  91.905 -					fieldX <<= 1;
  91.906 -					fieldY <<= 1;
  91.907 -				}
  91.908 -
  91.909 -				int t = VCOUNT - sy;
  91.910 -				if ((t >= 0) && (t < fieldY))
  91.911 -				{
  91.912 -					int sx = (a1 & 0x1FF);
  91.913 -					if ((sx < 240) || (((sx + fieldX) & 511) < 240))
  91.914 -					{
  91.915 -						// int t2 = t - (fieldY >> 1);
  91.916 -						int  rot = (a1 >> 9) & 0x1F;
  91.917 -						u16 *OAM = (u16 *)oam;
  91.918 -						int  dx  = READ16LE(&OAM[3 + (rot << 4)]);
  91.919 -						if (dx & 0x8000)
  91.920 -							dx |= 0xFFFF8000;
  91.921 -						int dmx = READ16LE(&OAM[7 + (rot << 4)]);
  91.922 -						if (dmx & 0x8000)
  91.923 -							dmx |= 0xFFFF8000;
  91.924 -						int dy = READ16LE(&OAM[11 + (rot << 4)]);
  91.925 -						if (dy & 0x8000)
  91.926 -							dy |= 0xFFFF8000;
  91.927 -						int dmy = READ16LE(&OAM[15 + (rot << 4)]);
  91.928 -						if (dmy & 0x8000)
  91.929 -							dmy |= 0xFFFF8000;
  91.930 -
  91.931 -						if (a0 & 0x1000)
  91.932 -						{
  91.933 -							t -= (t % mosaicY);
  91.934 -						}
  91.935 -
  91.936 -						int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
  91.937 -						            + t * dmx;
  91.938 -						int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
  91.939 -						            + t * dmy;
  91.940 -
  91.941 -						u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
  91.942 -
  91.943 -						if (a0 & 0x2000)
  91.944 -						{
  91.945 -							int c = (a2 & 0x3FF);
  91.946 -							if ((DISPCNT & 7) > 2 && (c < 512))
  91.947 -								continue;
  91.948 -							int inc = 32;
  91.949 -							if (DISPCNT & 0x40)
  91.950 -								inc = sizeX >> 2;
  91.951 -							else
  91.952 -								c &= 0x3FE;
  91.953 -							for (int x = 0; x < fieldX; x++)
  91.954 -							{
  91.955 -								int xxx = realX >> 8;
  91.956 -								int yyy = realY >> 8;
  91.957 -
  91.958 -								if (xxx < 0 || xxx >= sizeX ||
  91.959 -								    yyy < 0 || yyy >= sizeY ||
  91.960 -								    sx >= 240)
  91.961 -									;
  91.962 -								else
  91.963 -								{
  91.964 -									u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
  91.965 -									                             + ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
  91.966 -									                             (xxx & 7))&0x7FFF)];
  91.967 -									if ((color == 0) && (((prio >> 25)&3) <
  91.968 -									                     ((lineOBJ[sx]>>25)&3)))
  91.969 -									{
  91.970 -										lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
  91.971 -										if ((a0 & 0x1000) && m)
  91.972 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
  91.973 -									}
  91.974 -									else if ((color) && (prio < (lineOBJ[sx]&0xFF000000)))
  91.975 -									{
  91.976 -										lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio;
  91.977 -										if ((a0 & 0x1000) && m)
  91.978 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
  91.979 -									}
  91.980 -
  91.981 -									if (a0 & 0x1000)
  91.982 -									{
  91.983 -										m++;
  91.984 -										if (m == mosaicX)
  91.985 -											m = 0;
  91.986 -									}
  91.987 -#ifdef SPRITE_DEBUG
  91.988 -									if (t == 0 || t == maskY || x == 0 || x == maskX)
  91.989 -										lineOBJ[sx] = 0x001F;
  91.990 -#endif
  91.991 -								}
  91.992 -								sx     = (sx+1)&511;;
  91.993 -								realX += dx;
  91.994 -								realY += dy;
  91.995 -							}
  91.996 -						}
  91.997 -						else
  91.998 -						{
  91.999 -							int c = (a2 & 0x3FF);
 91.1000 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1001 -								continue;
 91.1002 -
 91.1003 -							int inc = 32;
 91.1004 -							if (DISPCNT & 0x40)
 91.1005 -								inc = sizeX >> 3;
 91.1006 -							int palette = (a2 >> 8) & 0xF0;
 91.1007 -							for (int x = 0; x < fieldX; x++)
 91.1008 -							{
 91.1009 -								int xxx = realX >> 8;
 91.1010 -								int yyy = realY >> 8;
 91.1011 -								if (xxx < 0 || xxx >= sizeX ||
 91.1012 -								    yyy < 0 || yyy >= sizeY ||
 91.1013 -								    sx >= 240)
 91.1014 -									;
 91.1015 -								else
 91.1016 -								{
 91.1017 -									u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
 91.1018 -									                             + ((yyy & 7)<<2) + ((xxx >> 3)<<5) +
 91.1019 -									                             ((xxx & 7)>>1))&0x7FFF)];
 91.1020 -									if (xxx & 1)
 91.1021 -										color >>= 4;
 91.1022 -									else
 91.1023 -										color &= 0x0F;
 91.1024 -
 91.1025 -									if ((color == 0) && (((prio >> 25)&3) <
 91.1026 -									                     ((lineOBJ[sx]>>25)&3)))
 91.1027 -									{
 91.1028 -										lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
 91.1029 -										if ((a0 & 0x1000) && m)
 91.1030 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1031 -									}
 91.1032 -									else if ((color) && (prio < (lineOBJ[sx]&0xFF000000)))
 91.1033 -									{
 91.1034 -										lineOBJ[sx] = READ16LE(&spritePalette[palette+color]) | prio;
 91.1035 -										if ((a0 & 0x1000) && m)
 91.1036 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1037 -									}
 91.1038 -								}
 91.1039 -								if ((a0 & 0x1000) && m)
 91.1040 -								{
 91.1041 -									m++;
 91.1042 -									if (m == mosaicX)
 91.1043 -										m = 0;
 91.1044 -								}
 91.1045 -
 91.1046 -#ifdef SPRITE_DEBUG
 91.1047 -								if (t == 0 || t == maskY || x == 0 || x == maskX)
 91.1048 -									lineOBJ[sx] = 0x001F;
 91.1049 -#endif
 91.1050 -								sx     = (sx+1)&511;;
 91.1051 -								realX += dx;
 91.1052 -								realY += dy;
 91.1053 -							}
 91.1054 -						}
 91.1055 -					}
 91.1056 -				}
 91.1057 -			}
 91.1058 -			else
 91.1059 -			{
 91.1060 -				int t = VCOUNT - sy;
 91.1061 -				if ((t >= 0) && (t < sizeY))
 91.1062 -				{
 91.1063 -					int sx = (a1 & 0x1FF);
 91.1064 -					if (((sx < 240) || (((sx+sizeX)&511) < 240)) && !(a0 & 0x0200))
 91.1065 -					{
 91.1066 -						if (a0 & 0x2000)
 91.1067 -						{
 91.1068 -							if (a1 & 0x2000)
 91.1069 -								t = sizeY - t - 1;
 91.1070 -							int c = (a2 & 0x3FF);
 91.1071 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1072 -								continue;
 91.1073 -
 91.1074 -							int inc = 32;
 91.1075 -							if (DISPCNT & 0x40)
 91.1076 -							{
 91.1077 -								inc = sizeX >> 2;
 91.1078 -							}
 91.1079 -							else
 91.1080 -							{
 91.1081 -								c &= 0x3FE;
 91.1082 -							}
 91.1083 -							int xxx = 0;
 91.1084 -							if (a1 & 0x1000)
 91.1085 -								xxx = sizeX-1;
 91.1086 -
 91.1087 -							if (a0 & 0x1000)
 91.1088 -							{
 91.1089 -								t -= (t % mosaicY);
 91.1090 -							}
 91.1091 -
 91.1092 -							int address = 0x10000 + ((((c+ (t>>3) * inc) << 5)
 91.1093 -							                          + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF);
 91.1094 -
 91.1095 -							if (a1 & 0x1000)
 91.1096 -								xxx = 7;
 91.1097 -							u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
 91.1098 -
 91.1099 -							for (int xx = 0; xx < sizeX; xx++)
 91.1100 -							{
 91.1101 -								if (sx < 240)
 91.1102 -								{
 91.1103 -									u8 color = vram[address];
 91.1104 -									if ((color == 0) && (((prio >> 25)&3) <
 91.1105 -									                     ((lineOBJ[sx]>>25)&3)))
 91.1106 -									{
 91.1107 -										lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
 91.1108 -										if ((a0 & 0x1000) && m)
 91.1109 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1110 -									}
 91.1111 -									else if ((color) && (prio < (lineOBJ[sx]&0xFF000000)))
 91.1112 -									{
 91.1113 -										lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio;
 91.1114 -										if ((a0 & 0x1000) && m)
 91.1115 -											lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1116 -									}
 91.1117 -
 91.1118 -									if (a0 & 0x1000)
 91.1119 -									{
 91.1120 -										m++;
 91.1121 -										if (m == mosaicX)
 91.1122 -											m = 0;
 91.1123 -									}
 91.1124 -
 91.1125 -#ifdef SPRITE_DEBUG
 91.1126 -									if (t == 0 || t == maskY || xx == 0 || xx == maskX)
 91.1127 -										lineOBJ[sx] = 0x001F;
 91.1128 -#endif
 91.1129 -								}
 91.1130 -
 91.1131 -								sx = (sx+1) & 511;
 91.1132 -								if (a1 & 0x1000)
 91.1133 -								{
 91.1134 -									xxx--;
 91.1135 -									address--;
 91.1136 -									if (xxx == -1)
 91.1137 -									{
 91.1138 -										address -= 56;
 91.1139 -										xxx      = 7;
 91.1140 -									}
 91.1141 -									if (address < 0x10000)
 91.1142 -										address += 0x8000;
 91.1143 -								}
 91.1144 -								else
 91.1145 -								{
 91.1146 -									xxx++;
 91.1147 -									address++;
 91.1148 -									if (xxx == 8)
 91.1149 -									{
 91.1150 -										address += 56;
 91.1151 -										xxx      = 0;
 91.1152 -									}
 91.1153 -									if (address > 0x17fff)
 91.1154 -										address -= 0x8000;
 91.1155 -								}
 91.1156 -							}
 91.1157 -						}
 91.1158 -						else
 91.1159 -						{
 91.1160 -							if (a1 & 0x2000)
 91.1161 -								t = sizeY - t - 1;
 91.1162 -							int c = (a2 & 0x3FF);
 91.1163 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1164 -								continue;
 91.1165 -
 91.1166 -							int inc = 32;
 91.1167 -							if (DISPCNT & 0x40)
 91.1168 -							{
 91.1169 -								inc = sizeX >> 3;
 91.1170 -							}
 91.1171 -							int xxx = 0;
 91.1172 -							if (a1 & 0x1000)
 91.1173 -								xxx = sizeX - 1;
 91.1174 -
 91.1175 -							if (a0 & 0x1000)
 91.1176 -							{
 91.1177 -								t -= (t % mosaicY);
 91.1178 -							}
 91.1179 -
 91.1180 -							int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
 91.1181 -							                          + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF);
 91.1182 -							u32 prio    = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
 91.1183 -							int palette = (a2 >> 8) & 0xF0;
 91.1184 -							if (a1 & 0x1000)
 91.1185 -							{
 91.1186 -								xxx = 7;
 91.1187 -								for (int xx = sizeX - 1; xx >= 0; xx--)
 91.1188 -								{
 91.1189 -									if (sx < 240)
 91.1190 -									{
 91.1191 -										u8 color = vram[address];
 91.1192 -										if (xx & 1)
 91.1193 -										{
 91.1194 -											color = (color >> 4);
 91.1195 -										}
 91.1196 -										else
 91.1197 -											color &= 0x0F;
 91.1198 -
 91.1199 -										if ((color == 0) && (((prio >> 25)&3) <
 91.1200 -										                     ((lineOBJ[sx]>>25)&3)))
 91.1201 -										{
 91.1202 -											lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
 91.1203 -											if ((a0 & 0x1000) && m)
 91.1204 -												lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1205 -										}
 91.1206 -										else if ((color) && (prio < (lineOBJ[sx]&0xFF000000)))
 91.1207 -										{
 91.1208 -											lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio;
 91.1209 -											if ((a0 & 0x1000) && m)
 91.1210 -												lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1211 -										}
 91.1212 -									}
 91.1213 -									if (a0 & 0x1000)
 91.1214 -									{
 91.1215 -										m++;
 91.1216 -										if (m == mosaicX)
 91.1217 -											m = 0;
 91.1218 -									}
 91.1219 -#ifdef SPRITE_DEBUG
 91.1220 -									if (t == 0 || t == maskY || xx == 0 || xx == maskX)
 91.1221 -										lineOBJ[sx] = 0x001F;
 91.1222 -#endif
 91.1223 -									sx = (sx+1) & 511;
 91.1224 -									xxx--;
 91.1225 -									if (!(xx & 1))
 91.1226 -										address--;
 91.1227 -									if (xxx == -1)
 91.1228 -									{
 91.1229 -										xxx      = 7;
 91.1230 -										address -= 28;
 91.1231 -									}
 91.1232 -									if (address < 0x10000)
 91.1233 -										address += 0x8000;
 91.1234 -								}
 91.1235 -							}
 91.1236 -							else
 91.1237 -							{
 91.1238 -								for (int xx = 0; xx < sizeX; xx++)
 91.1239 -								{
 91.1240 -									if (sx < 240)
 91.1241 -									{
 91.1242 -										u8 color = vram[address];
 91.1243 -										if (xx & 1)
 91.1244 -										{
 91.1245 -											color = (color >> 4);
 91.1246 -										}
 91.1247 -										else
 91.1248 -											color &= 0x0F;
 91.1249 -
 91.1250 -										if ((color == 0) && (((prio >> 25)&3) <
 91.1251 -										                     ((lineOBJ[sx]>>25)&3)))
 91.1252 -										{
 91.1253 -											lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
 91.1254 -											if ((a0 & 0x1000) && m)
 91.1255 -												lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1256 -										}
 91.1257 -										else if ((color) && (prio < (lineOBJ[sx]&0xFF000000)))
 91.1258 -										{
 91.1259 -											lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio;
 91.1260 -											if ((a0 & 0x1000) && m)
 91.1261 -												lineOBJ[sx] = (lineOBJ[sx-1] & 0xF9FFFFFF) | prio;
 91.1262 -										}
 91.1263 -									}
 91.1264 -									if (a0 & 0x1000)
 91.1265 -									{
 91.1266 -										m++;
 91.1267 -										if (m == mosaicX)
 91.1268 -											m = 0;
 91.1269 -									}
 91.1270 -#ifdef SPRITE_DEBUG
 91.1271 -									if (t == 0 || t == maskY || xx == 0 || xx == maskX)
 91.1272 -										lineOBJ[sx] = 0x001F;
 91.1273 -#endif
 91.1274 -									sx = (sx+1) & 511;
 91.1275 -									xxx++;
 91.1276 -									if (xx & 1)
 91.1277 -										address++;
 91.1278 -									if (xxx == 8)
 91.1279 -									{
 91.1280 -										address += 28;
 91.1281 -										xxx      = 0;
 91.1282 -									}
 91.1283 -									if (address > 0x17fff)
 91.1284 -										address -= 0x8000;
 91.1285 -								}
 91.1286 -							}
 91.1287 -						}
 91.1288 -					}
 91.1289 -				}
 91.1290 -			}
 91.1291 -		}
 91.1292 -	}
 91.1293 -}
 91.1294 -
 91.1295 -inline void gfxDrawOBJWin(u32 *lineOBJWin)
 91.1296 -{
 91.1297 -	gfxClearArray(lineOBJWin);
 91.1298 -	if (layerEnable & 0x8000)
 91.1299 -	{
 91.1300 -		u16 *sprites = (u16 *)oam;
 91.1301 -		// u16 *spritePalette = &((u16 *)paletteRAM)[256];
 91.1302 -		for (int x = 0; x < 128; x++)
 91.1303 -		{
 91.1304 -			u16 a0 = READ16LE(sprites++);
 91.1305 -			u16 a1 = READ16LE(sprites++);
 91.1306 -			u16 a2 = READ16LE(sprites++);
 91.1307 -			sprites++;
 91.1308 -
 91.1309 -			// ignore non OBJ-WIN
 91.1310 -			if ((a0 & 0x0c00) != 0x0800)
 91.1311 -				continue;
 91.1312 -
 91.1313 -			int sizeY = 8;
 91.1314 -			int sizeX = 8;
 91.1315 -
 91.1316 -			switch (((a0 >>12) & 0x0c)|(a1>>14))
 91.1317 -			{
 91.1318 -			case 0:
 91.1319 -				break;
 91.1320 -			case 1:
 91.1321 -				sizeX = sizeY = 16;
 91.1322 -				break;
 91.1323 -			case 2:
 91.1324 -				sizeX = sizeY = 32;
 91.1325 -				break;
 91.1326 -			case 3:
 91.1327 -				sizeX = sizeY = 64;
 91.1328 -				break;
 91.1329 -			case 4:
 91.1330 -				sizeX = 16;
 91.1331 -				break;
 91.1332 -			case 5:
 91.1333 -				sizeX = 32;
 91.1334 -				break;
 91.1335 -			case 6:
 91.1336 -				sizeX = 32;
 91.1337 -				sizeY = 16;
 91.1338 -				break;
 91.1339 -			case 7:
 91.1340 -				sizeX = 64;
 91.1341 -				sizeY = 32;
 91.1342 -				break;
 91.1343 -			case 8:
 91.1344 -				sizeY = 16;
 91.1345 -				break;
 91.1346 -			case 9:
 91.1347 -				sizeY = 32;
 91.1348 -				break;
 91.1349 -			case 10:
 91.1350 -				sizeX = 16;
 91.1351 -				sizeY = 32;
 91.1352 -				break;
 91.1353 -			case 11:
 91.1354 -				sizeX = 32;
 91.1355 -				sizeY = 64;
 91.1356 -				break;
 91.1357 -			default:
 91.1358 -				continue;
 91.1359 -			}
 91.1360 -
 91.1361 -			int sy = (a0 & 255);
 91.1362 -
 91.1363 -			if (sy > 160)
 91.1364 -				sy -= 256;
 91.1365 -
 91.1366 -			if (a0 & 0x0100)
 91.1367 -			{
 91.1368 -				int fieldX = sizeX;
 91.1369 -				int fieldY = sizeY;
 91.1370 -				if (a0 & 0x0200)
 91.1371 -				{
 91.1372 -					fieldX <<= 1;
 91.1373 -					fieldY <<= 1;
 91.1374 -				}
 91.1375 -
 91.1376 -				int t = VCOUNT - sy;
 91.1377 -				if ((t >= 0) && (t < fieldY))
 91.1378 -				{
 91.1379 -					int sx = (a1 & 0x1FF);
 91.1380 -					if ((sx < 240) || (((sx + fieldX) & 511) < 240))
 91.1381 -					{
 91.1382 -						// int t2 = t - (fieldY >> 1);
 91.1383 -						int  rot = (a1 >> 9) & 0x1F;
 91.1384 -						u16 *OAM = (u16 *)oam;
 91.1385 -						int  dx  = READ16LE(&OAM[3 + (rot << 4)]);
 91.1386 -						if (dx & 0x8000)
 91.1387 -							dx |= 0xFFFF8000;
 91.1388 -						int dmx = READ16LE(&OAM[7 + (rot << 4)]);
 91.1389 -						if (dmx & 0x8000)
 91.1390 -							dmx |= 0xFFFF8000;
 91.1391 -						int dy = READ16LE(&OAM[11 + (rot << 4)]);
 91.1392 -						if (dy & 0x8000)
 91.1393 -							dy |= 0xFFFF8000;
 91.1394 -						int dmy = READ16LE(&OAM[15 + (rot << 4)]);
 91.1395 -						if (dmy & 0x8000)
 91.1396 -							dmy |= 0xFFFF8000;
 91.1397 -
 91.1398 -						int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
 91.1399 -						            + t * dmx;
 91.1400 -						int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
 91.1401 -						            + t * dmy;
 91.1402 -
 91.1403 -						// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
 91.1404 -
 91.1405 -						if (a0 & 0x2000)
 91.1406 -						{
 91.1407 -							int c = (a2 & 0x3FF);
 91.1408 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1409 -								continue;
 91.1410 -							int inc = 32;
 91.1411 -							if (DISPCNT & 0x40)
 91.1412 -								inc = sizeX >> 2;
 91.1413 -							else
 91.1414 -								c &= 0x3FE;
 91.1415 -							for (int x = 0; x < fieldX; x++)
 91.1416 -							{
 91.1417 -								int xxx = realX >> 8;
 91.1418 -								int yyy = realY >> 8;
 91.1419 -
 91.1420 -								if (xxx < 0 || xxx >= sizeX ||
 91.1421 -								    yyy < 0 || yyy >= sizeY)
 91.1422 -								{}
 91.1423 -								else
 91.1424 -								{
 91.1425 -									u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
 91.1426 -									                             + ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
 91.1427 -									                             (xxx & 7))&0x7fff)];
 91.1428 -									if (color)
 91.1429 -									{
 91.1430 -										lineOBJWin[sx] = 1;
 91.1431 -									}
 91.1432 -								}
 91.1433 -								sx     = (sx+1)&511;;
 91.1434 -								realX += dx;
 91.1435 -								realY += dy;
 91.1436 -							}
 91.1437 -						}
 91.1438 -						else
 91.1439 -						{
 91.1440 -							int c = (a2 & 0x3FF);
 91.1441 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1442 -								continue;
 91.1443 -
 91.1444 -							int inc = 32;
 91.1445 -							if (DISPCNT & 0x40)
 91.1446 -								inc = sizeX >> 3;
 91.1447 -							// int palette = (a2 >> 8) & 0xF0;
 91.1448 -							for (int x = 0; x < fieldX; x++)
 91.1449 -							{
 91.1450 -								int xxx = realX >> 8;
 91.1451 -								int yyy = realY >> 8;
 91.1452 -
 91.1453 -								//              if(x == 0 || x == (sizeX-1) ||
 91.1454 -								//                 t == 0 || t == (sizeY-1)) {
 91.1455 -								//                lineOBJ[sx] = 0x001F | prio;
 91.1456 -								//              } else {
 91.1457 -								if (xxx < 0 || xxx >= sizeX ||
 91.1458 -								    yyy < 0 || yyy >= sizeY)
 91.1459 -								{}
 91.1460 -								else
 91.1461 -								{
 91.1462 -									u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
 91.1463 -									                             + ((yyy & 7)<<2) + ((xxx >> 3)<<5) +
 91.1464 -									                             ((xxx & 7)>>1))&0x7fff)];
 91.1465 -									if (xxx & 1)
 91.1466 -										color >>= 4;
 91.1467 -									else
 91.1468 -										color &= 0x0F;
 91.1469 -
 91.1470 -									if (color)
 91.1471 -									{
 91.1472 -										lineOBJWin[sx] = 1;
 91.1473 -									}
 91.1474 -								}
 91.1475 -								//            }
 91.1476 -								sx     = (sx+1)&511;;
 91.1477 -								realX += dx;
 91.1478 -								realY += dy;
 91.1479 -							}
 91.1480 -						}
 91.1481 -					}
 91.1482 -				}
 91.1483 -			}
 91.1484 -			else
 91.1485 -			{
 91.1486 -				int t = VCOUNT - sy;
 91.1487 -				if ((t >= 0) && (t < sizeY))
 91.1488 -				{
 91.1489 -					int sx = (a1 & 0x1FF);
 91.1490 -					if (((sx < 240) || (((sx+sizeX)&511) < 240)) && !(a0 & 0x0200))
 91.1491 -					{
 91.1492 -						if (a0 & 0x2000)
 91.1493 -						{
 91.1494 -							if (a1 & 0x2000)
 91.1495 -								t = sizeY - t - 1;
 91.1496 -							int c = (a2 & 0x3FF);
 91.1497 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1498 -								continue;
 91.1499 -
 91.1500 -							int inc = 32;
 91.1501 -							if (DISPCNT & 0x40)
 91.1502 -							{
 91.1503 -								inc = sizeX >> 2;
 91.1504 -							}
 91.1505 -							else
 91.1506 -							{
 91.1507 -								c &= 0x3FE;
 91.1508 -							}
 91.1509 -							int xxx = 0;
 91.1510 -							if (a1 & 0x1000)
 91.1511 -								xxx = sizeX-1;
 91.1512 -							int address = 0x10000 + ((((c+ (t>>3) * inc) << 5)
 91.1513 -							                          + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7))&0x7fff);
 91.1514 -							if (a1 & 0x1000)
 91.1515 -								xxx = 7;
 91.1516 -							// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
 91.1517 -							for (int xx = 0; xx < sizeX; xx++)
 91.1518 -							{
 91.1519 -								if (sx < 240)
 91.1520 -								{
 91.1521 -									u8 color = vram[address];
 91.1522 -									if (color)
 91.1523 -									{
 91.1524 -										lineOBJWin[sx] = 1;
 91.1525 -									}
 91.1526 -								}
 91.1527 -
 91.1528 -								sx = (sx+1) & 511;
 91.1529 -								if (a1 & 0x1000)
 91.1530 -								{
 91.1531 -									xxx--;
 91.1532 -									address--;
 91.1533 -									if (xxx == -1)
 91.1534 -									{
 91.1535 -										address -= 56;
 91.1536 -										xxx      = 7;
 91.1537 -									}
 91.1538 -									if (address < 0x10000)
 91.1539 -										address += 0x8000;
 91.1540 -								}
 91.1541 -								else
 91.1542 -								{
 91.1543 -									xxx++;
 91.1544 -									address++;
 91.1545 -									if (xxx == 8)
 91.1546 -									{
 91.1547 -										address += 56;
 91.1548 -										xxx      = 0;
 91.1549 -									}
 91.1550 -									if (address > 0x17fff)
 91.1551 -										address -= 0x8000;
 91.1552 -								}
 91.1553 -							}
 91.1554 -						}
 91.1555 -						else
 91.1556 -						{
 91.1557 -							if (a1 & 0x2000)
 91.1558 -								t = sizeY - t - 1;
 91.1559 -							int c = (a2 & 0x3FF);
 91.1560 -							if ((DISPCNT & 7) > 2 && (c < 512))
 91.1561 -								continue;
 91.1562 -
 91.1563 -							int inc = 32;
 91.1564 -							if (DISPCNT & 0x40)
 91.1565 -							{
 91.1566 -								inc = sizeX >> 3;
 91.1567 -							}
 91.1568 -							int xxx = 0;
 91.1569 -							if (a1 & 0x1000)
 91.1570 -								xxx = sizeX - 1;
 91.1571 -							int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
 91.1572 -							                          + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff);
 91.1573 -							// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
 91.1574 -							// int palette = (a2 >> 8) & 0xF0;
 91.1575 -							if (a1 & 0x1000)
 91.1576 -							{
 91.1577 -								xxx = 7;
 91.1578 -								for (int xx = sizeX - 1; xx >= 0; xx--)
 91.1579 -								{
 91.1580 -									if (sx < 240)
 91.1581 -									{
 91.1582 -										u8 color = vram[address];
 91.1583 -										if (xx & 1)
 91.1584 -										{
 91.1585 -											color = (color >> 4);
 91.1586 -										}
 91.1587 -										else
 91.1588 -											color &= 0x0F;
 91.1589 -
 91.1590 -										if (color)
 91.1591 -										{
 91.1592 -											lineOBJWin[sx] = 1;
 91.1593 -										}
 91.1594 -									}
 91.1595 -									sx = (sx+1) & 511;
 91.1596 -									xxx--;
 91.1597 -									if (!(xx & 1))
 91.1598 -										address--;
 91.1599 -									if (xxx == -1)
 91.1600 -									{
 91.1601 -										xxx      = 7;
 91.1602 -										address -= 28;
 91.1603 -									}
 91.1604 -									if (address < 0x10000)
 91.1605 -										address += 0x8000;
 91.1606 -								}
 91.1607 -							}
 91.1608 -							else
 91.1609 -							{
 91.1610 -								for (int xx = 0; xx < sizeX; xx++)
 91.1611 -								{
 91.1612 -									if (sx < 240)
 91.1613 -									{
 91.1614 -										u8 color = vram[address];
 91.1615 -										if (xx & 1)
 91.1616 -										{
 91.1617 -											color = (color >> 4);
 91.1618 -										}
 91.1619 -										else
 91.1620 -											color &= 0x0F;
 91.1621 -
 91.1622 -										if (color)
 91.1623 -										{
 91.1624 -											lineOBJWin[sx] = 1;
 91.1625 -										}
 91.1626 -									}
 91.1627 -									sx = (sx+1) & 511;
 91.1628 -									xxx++;
 91.1629 -									if (xx & 1)
 91.1630 -										address++;
 91.1631 -									if (xxx == 8)
 91.1632 -									{
 91.1633 -										address += 28;
 91.1634 -										xxx      = 0;
 91.1635 -									}
 91.1636 -									if (address > 0x17fff)
 91.1637 -										address -= 0x8000;
 91.1638 -								}
 91.1639 -							}
 91.1640 -						}
 91.1641 -					}
 91.1642 -				}
 91.1643 -			}
 91.1644 -		}
 91.1645 -	}
 91.1646 -}
 91.1647 -
 91.1648 -inline u32 gfxIncreaseBrightness(u32 color, int coeff)
 91.1649 -{
 91.1650 -	int r = (color & 0x1F);
 91.1651 -	int g = ((color >> 5) & 0x1F);
 91.1652 -	int b = ((color >> 10) & 0x1F);
 91.1653 -
 91.1654 -	r = r + (((31 - r) * coeff) >> 4);
 91.1655 -	g = g + (((31 - g) * coeff) >> 4);
 91.1656 -	b = b + (((31 - b) * coeff) >> 4);
 91.1657 -	if (r > 31)
 91.1658 -		r = 31;
 91.1659 -	if (g > 31)
 91.1660 -		g = 31;
 91.1661 -	if (b > 31)
 91.1662 -		b = 31;
 91.1663 -	color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1664 -	return color;
 91.1665 -}
 91.1666 -
 91.1667 -inline void gfxIncreaseBrightness(u32 *line, int coeff)
 91.1668 -{
 91.1669 -	for (int x = 0; x < 240; x++)
 91.1670 -	{
 91.1671 -		u32 color = *line;
 91.1672 -		int r     = (color & 0x1F);
 91.1673 -		int g     = ((color >> 5) & 0x1F);
 91.1674 -		int b     = ((color >> 10) & 0x1F);
 91.1675 -
 91.1676 -		r = r + (((31 - r) * coeff) >> 4);
 91.1677 -		g = g + (((31 - g) * coeff) >> 4);
 91.1678 -		b = b + (((31 - b) * coeff) >> 4);
 91.1679 -		if (r > 31)
 91.1680 -			r = 31;
 91.1681 -		if (g > 31)
 91.1682 -			g = 31;
 91.1683 -		if (b > 31)
 91.1684 -			b = 31;
 91.1685 -		*line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1686 -	}
 91.1687 -}
 91.1688 -
 91.1689 -inline u32 gfxDecreaseBrightness(u32 color, int coeff)
 91.1690 -{
 91.1691 -	int r = (color & 0x1F);
 91.1692 -	int g = ((color >> 5) & 0x1F);
 91.1693 -	int b = ((color >> 10) & 0x1F);
 91.1694 -
 91.1695 -	r = r - ((r * coeff) >> 4);
 91.1696 -	g = g - ((g * coeff) >> 4);
 91.1697 -	b = b - ((b * coeff) >> 4);
 91.1698 -	if (r < 0)
 91.1699 -		r = 0;
 91.1700 -	if (g < 0)
 91.1701 -		g = 0;
 91.1702 -	if (b < 0)
 91.1703 -		b = 0;
 91.1704 -	color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1705 -
 91.1706 -	return color;
 91.1707 -}
 91.1708 -
 91.1709 -inline void gfxDecreaseBrightness(u32 *line, int coeff)
 91.1710 -{
 91.1711 -	for (int x = 0; x < 240; x++)
 91.1712 -	{
 91.1713 -		u32 color = *line;
 91.1714 -		int r     = (color & 0x1F);
 91.1715 -		int g     = ((color >> 5) & 0x1F);
 91.1716 -		int b     = ((color >> 10) & 0x1F);
 91.1717 -
 91.1718 -		r = r - ((r * coeff) >> 4);
 91.1719 -		g = g - ((g * coeff) >> 4);
 91.1720 -		b = b - ((b * coeff) >> 4);
 91.1721 -		if (r < 0)
 91.1722 -			r = 0;
 91.1723 -		if (g < 0)
 91.1724 -			g = 0;
 91.1725 -		if (b < 0)
 91.1726 -			b = 0;
 91.1727 -		*line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1728 -	}
 91.1729 -}
 91.1730 -
 91.1731 -inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb)
 91.1732 -{
 91.1733 -	if (color < 0x80000000)
 91.1734 -	{
 91.1735 -		int r  = (color & 0x1F);
 91.1736 -		int g  = ((color >> 5) & 0x1F);
 91.1737 -		int b  = ((color >> 10) & 0x1F);
 91.1738 -		int r0 = (color2 & 0x1F);
 91.1739 -		int g0 = ((color2 >> 5) & 0x1F);
 91.1740 -		int b0 = ((color2 >> 10) & 0x1F);
 91.1741 -
 91.1742 -		r = ((r * ca) >> 4) + ((r0 * cb) >> 4);
 91.1743 -		g = ((g * ca) >> 4) + ((g0 * cb) >> 4);
 91.1744 -		b = ((b * ca) >> 4) + ((b0 * cb) >> 4);
 91.1745 -
 91.1746 -		if (r > 31)
 91.1747 -			r = 31;
 91.1748 -		if (g > 31)
 91.1749 -			g = 31;
 91.1750 -		if (b > 31)
 91.1751 -			b = 31;
 91.1752 -
 91.1753 -		return (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1754 -	}
 91.1755 -	return color;
 91.1756 -}
 91.1757 -
 91.1758 -inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb)
 91.1759 -{
 91.1760 -	for (int x = 0; x < 240; x++)
 91.1761 -	{
 91.1762 -		u32 color = *ta;
 91.1763 -		if (color < 0x80000000)
 91.1764 -		{
 91.1765 -			int r      = (color & 0x1F);
 91.1766 -			int g      = ((color >> 5) & 0x1F);
 91.1767 -			int b      = ((color >> 10) & 0x1F);
 91.1768 -			u32 color2 = (*tb++);
 91.1769 -			int r0     = (color2 & 0x1F);
 91.1770 -			int g0     = ((color2 >> 5) & 0x1F);
 91.1771 -			int b0     = ((color2 >> 10) & 0x1F);
 91.1772 -
 91.1773 -			r = ((r * ca) >> 4) + ((r0 * cb) >> 4);
 91.1774 -			g = ((g * ca) >> 4) + ((g0 * cb) >> 4);
 91.1775 -			b = ((b * ca) >> 4) + ((b0 * cb) >> 4);
 91.1776 -
 91.1777 -			if (r > 31)
 91.1778 -				r = 31;
 91.1779 -			if (g > 31)
 91.1780 -				g = 31;
 91.1781 -			if (b > 31)
 91.1782 -				b = 31;
 91.1783 -
 91.1784 -			*ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
 91.1785 -		}
 91.1786 -		else
 91.1787 -		{
 91.1788 -			ta++;
 91.1789 -			tb++;
 91.1790 -		}
 91.1791 -	}
 91.1792 -}
 91.1793 -
 91.1794 -#endif // VBA_GBA_GFX_H
    92.1 --- a/src/gba/GBAGlobals.cpp	Sat Mar 03 10:54:39 2012 -0600
    92.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.3 @@ -1,123 +0,0 @@
    92.4 -#include "GBAGlobals.h"
    92.5 -
    92.6 -reg_pair  reg[45];
    92.7 -memoryMap map[256];
    92.8 -bool8	  ioReadable[0x400];
    92.9 -bool8	  N_FLAG			   = 0;
   92.10 -bool8	  C_FLAG			   = 0;
   92.11 -bool8	  Z_FLAG			   = 0;
   92.12 -bool8	  V_FLAG			   = 0;
   92.13 -bool8	  armState			   = true;
   92.14 -bool8	  armIrqEnable		   = true;
   92.15 -u32		  armNextPC			   = 0x00000000;
   92.16 -int32	  armMode			   = 0x1f;
   92.17 -u32		  stop				   = 0x08000568;
   92.18 -int32	  saveType			   = 0;
   92.19 -bool8	  useBios			   = false;
   92.20 -bool8	  skipBios			   = false;
   92.21 -int32	  frameSkip			   = 1;
   92.22 -u32		  extButtons		   = 0;
   92.23 -bool8	  capturePrevious	   = false;
   92.24 -int32	  captureNumber		   = 0;
   92.25 -bool8	  speedup			   = false;
   92.26 -bool8	  synchronize		   = true;
   92.27 -bool8	  cpuDisableSfx		   = false;
   92.28 -bool8	  cpuIsMultiBoot	   = false;
   92.29 -bool8	  parseDebug		   = true;
   92.30 -int32	  layerSettings		   = 0xff00;
   92.31 -int32	  layerEnable		   = 0xff00;
   92.32 -bool8	  speedHack			   = false;
   92.33 -bool8	  memLagEnabled		   = false;
   92.34 -bool8	  memLagTempEnabled	   = false;
   92.35 -bool8	  useOldFrameTiming	   = false;
   92.36 -int32	  cpuSaveType		   = 0;
   92.37 -bool8	  cpuEnhancedDetection = true;
   92.38 -bool8	  cheatsEnabled		   = true;
   92.39 -
   92.40 -u8 *bios		= NULL;
   92.41 -u8 *rom			= NULL;
   92.42 -u8 *internalRAM = NULL;
   92.43 -u8 *workRAM		= NULL;
   92.44 -u8 *paletteRAM	= NULL;
   92.45 -u8 *vram		= NULL;
   92.46 -u8 *pix			= NULL;
   92.47 -u8 *oam			= NULL;
   92.48 -u8 *ioMem		= NULL;
   92.49 -
   92.50 -u16 DISPCNT	 = 0x0080;
   92.51 -u16 DISPSTAT = 0x0000;
   92.52 -u16 VCOUNT	 = 0x0000;
   92.53 -u16 BG0CNT	 = 0x0000;
   92.54 -u16 BG1CNT	 = 0x0000;
   92.55 -u16 BG2CNT	 = 0x0000;
   92.56 -u16 BG3CNT	 = 0x0000;
   92.57 -u16 BG0HOFS	 = 0x0000;
   92.58 -u16 BG0VOFS	 = 0x0000;
   92.59 -u16 BG1HOFS	 = 0x0000;
   92.60 -u16 BG1VOFS	 = 0x0000;
   92.61 -u16 BG2HOFS	 = 0x0000;
   92.62 -u16 BG2VOFS	 = 0x0000;
   92.63 -u16 BG3HOFS	 = 0x0000;
   92.64 -u16 BG3VOFS	 = 0x0000;
   92.65 -u16 BG2PA	 = 0x0100;
   92.66 -u16 BG2PB	 = 0x0000;
   92.67 -u16 BG2PC	 = 0x0000;
   92.68 -u16 BG2PD	 = 0x0100;
   92.69 -u16 BG2X_L	 = 0x0000;
   92.70 -u16 BG2X_H	 = 0x0000;
   92.71 -u16 BG2Y_L	 = 0x0000;
   92.72 -u16 BG2Y_H	 = 0x0000;
   92.73 -u16 BG3PA	 = 0x0100;
   92.74 -u16 BG3PB	 = 0x0000;
   92.75 -u16 BG3PC	 = 0x0000;
   92.76 -u16 BG3PD	 = 0x0100;
   92.77 -u16 BG3X_L	 = 0x0000;
   92.78 -u16 BG3X_H	 = 0x0000;
   92.79 -u16 BG3Y_L	 = 0x0000;
   92.80 -u16 BG3Y_H	 = 0x0000;
   92.81 -u16 WIN0H	 = 0x0000;
   92.82 -u16 WIN1H	 = 0x0000;
   92.83 -u16 WIN0V	 = 0x0000;
   92.84 -u16 WIN1V	 = 0x0000;
   92.85 -u16 WININ	 = 0x0000;
   92.86 -u16 WINOUT	 = 0x0000;
   92.87 -u16 MOSAIC	 = 0x0000;
   92.88 -u16 BLDMOD	 = 0x0000;
   92.89 -u16 COLEV	 = 0x0000;
   92.90 -u16 COLY	 = 0x0000;
   92.91 -u16 DM0SAD_L = 0x0000;
   92.92 -u16 DM0SAD_H = 0x0000;
   92.93 -u16 DM0DAD_L = 0x0000;
   92.94 -u16 DM0DAD_H = 0x0000;
   92.95 -u16 DM0CNT_L = 0x0000;
   92.96 -u16 DM0CNT_H = 0x0000;
   92.97 -u16 DM1SAD_L = 0x0000;
   92.98 -u16 DM1SAD_H = 0x0000;
   92.99 -u16 DM1DAD_L = 0x0000;
  92.100 -u16 DM1DAD_H = 0x0000;
  92.101 -u16 DM1CNT_L = 0x0000;
  92.102 -u16 DM1CNT_H = 0x0000;
  92.103 -u16 DM2SAD_L = 0x0000;
  92.104 -u16 DM2SAD_H = 0x0000;
  92.105 -u16 DM2DAD_L = 0x0000;
  92.106 -u16 DM2DAD_H = 0x0000;
  92.107 -u16 DM2CNT_L = 0x0000;
  92.108 -u16 DM2CNT_H = 0x0000;
  92.109 -u16 DM3SAD_L = 0x0000;
  92.110 -u16 DM3SAD_H = 0x0000;
  92.111 -u16 DM3DAD_L = 0x0000;
  92.112 -u16 DM3DAD_H = 0x0000;
  92.113 -u16 DM3CNT_L = 0x0000;
  92.114 -u16 DM3CNT_H = 0x0000;
  92.115 -u16 TM0D	 = 0x0000;
  92.116 -u16 TM0CNT	 = 0x0000;
  92.117 -u16 TM1D	 = 0x0000;
  92.118 -u16 TM1CNT	 = 0x0000;
  92.119 -u16 TM2D	 = 0x0000;
  92.120 -u16 TM2CNT	 = 0x0000;
  92.121 -u16 TM3D	 = 0x0000;
  92.122 -u16 TM3CNT	 = 0x0000;
  92.123 -u16 P1		 = 0xFFFF;
  92.124 -u16 IE		 = 0x0000;
  92.125 -u16 IF		 = 0x0000;
  92.126 -u16 IME		 = 0x0000;
    93.1 --- a/src/gba/GBAGlobals.h	Sat Mar 03 10:54:39 2012 -0600
    93.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.3 @@ -1,208 +0,0 @@
    93.4 -#ifndef VBA_GBA_GLOBALS_H
    93.5 -#define VBA_GBA_GLOBALS_H
    93.6 -
    93.7 -#if _MSC_VER > 1000
    93.8 -#pragma once
    93.9 -#endif // _MSC_VER > 1000
   93.10 -
   93.11 -#include "../Port.h"
   93.12 -
   93.13 -#define VERBOSE_SWI                  1
   93.14 -#define VERBOSE_UNALIGNED_MEMORY     2
   93.15 -#define VERBOSE_ILLEGAL_WRITE        4
   93.16 -#define VERBOSE_ILLEGAL_READ         8
   93.17 -#define VERBOSE_DMA0                16
   93.18 -#define VERBOSE_DMA1                32
   93.19 -#define VERBOSE_DMA2                64
   93.20 -#define VERBOSE_DMA3               128
   93.21 -#define VERBOSE_UNDEFINED          256
   93.22 -#define VERBOSE_AGBPRINT           512
   93.23 -
   93.24 -// moved from armdis.cpp
   93.25 -#define debuggerReadMemory(addr) \
   93.26 -    READ32LE(&map[(addr) >> 24].address[(addr) & map[(addr) >> 24].mask])
   93.27 -
   93.28 -#define debuggerReadHalfWord(addr) \
   93.29 -    READ16LE(&map[(addr) >> 24].address[(addr) & map[(addr) >> 24].mask])
   93.30 -
   93.31 -#define debuggerReadByte(addr) \
   93.32 -    READ8LE(&map[(addr) >> 24].address[(addr) & map[(addr) >> 24].mask])
   93.33 -
   93.34 -#define debuggerWriteMemory(addr, value) \
   93.35 -    WRITE32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]), (value))
   93.36 -
   93.37 -#define debuggerWriteHalfWord(addr, value) \
   93.38 -    WRITE16LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]), (value))
   93.39 -
   93.40 -#define debuggerWriteByte(addr, value) \
   93.41 -    WRITE8LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]), (value))
   93.42 -
   93.43 -// moved from GBA.h
   93.44 -typedef struct
   93.45 -{
   93.46 -	u8 *address;
   93.47 -	u32 mask;
   93.48 -} memoryMap;
   93.49 -
   93.50 -#ifndef NO_GBA_MAP
   93.51 -extern memoryMap map[256];
   93.52 -#endif
   93.53 -
   93.54 -// moved from GBA.h
   93.55 -typedef union
   93.56 -{
   93.57 -	struct
   93.58 -	{
   93.59 -#ifdef WORDS_BIGENDIAN
   93.60 -		u8 B3;
   93.61 -		u8 B2;
   93.62 -		u8 B1;
   93.63 -		u8 B0;
   93.64 -#else
   93.65 -		u8 B0;
   93.66 -		u8 B1;
   93.67 -		u8 B2;
   93.68 -		u8 B3;
   93.69 -#endif
   93.70 -	} B;
   93.71 -	struct
   93.72 -	{
   93.73 -#ifdef WORDS_BIGENDIAN
   93.74 -		u16 W1;
   93.75 -		u16 W0;
   93.76 -#else
   93.77 -		u16 W0;
   93.78 -		u16 W1;
   93.79 -#endif
   93.80 -	} W;
   93.81 -#ifdef WORDS_BIGENDIAN
   93.82 -	volatile u32 I;
   93.83 -#else
   93.84 -	u32 I;
   93.85 -#endif
   93.86 -} reg_pair;
   93.87 -
   93.88 -extern reg_pair reg[45];
   93.89 -extern u8		biosProtected[4];
   93.90 -extern bool8	ioReadable[0x400];
   93.91 -extern bool8	N_FLAG;
   93.92 -extern bool8	C_FLAG;
   93.93 -extern bool8	Z_FLAG;
   93.94 -extern bool8	V_FLAG;
   93.95 -extern bool8	armState;
   93.96 -extern bool8	armIrqEnable;
   93.97 -extern u32		armNextPC;
   93.98 -extern int32	armMode;
   93.99 -extern u32		stop;
  93.100 -extern int32	saveType;
  93.101 -extern bool8	useBios;
  93.102 -extern bool8	skipBios;
  93.103 -extern int32	frameSkip;
  93.104 -extern u32		extButtons;
  93.105 -extern bool8	capturePrevious;
  93.106 -extern int32	captureNumber;
  93.107 -extern bool8	speedup;
  93.108 -extern bool8	synchronize;
  93.109 -extern bool8	cpuDisableSfx;
  93.110 -extern bool8	cpuIsMultiBoot;
  93.111 -extern bool8	parseDebug;
  93.112 -extern int32	layerSettings;
  93.113 -extern int32	layerEnable;
  93.114 -extern bool8	speedHack;
  93.115 -extern bool8	memLagEnabled, memLagTempEnabled;
  93.116 -extern bool8	useOldFrameTiming;
  93.117 -extern int32	cpuSaveType;
  93.118 -extern bool8	cpuEnhancedDetection;
  93.119 -extern bool8	cheatsEnabled;
  93.120 -
  93.121 -extern int emulating;
  93.122 -
  93.123 -extern u8 *bios;
  93.124 -extern u8 *rom;
  93.125 -extern u8 *internalRAM;
  93.126 -extern u8 *workRAM;
  93.127 -extern u8 *paletteRAM;
  93.128 -extern u8 *vram;
  93.129 -extern u8 *pix;
  93.130 -extern u8 *oam;
  93.131 -extern u8 *ioMem;
  93.132 -
  93.133 -extern u16 DISPCNT;
  93.134 -extern u16 DISPSTAT;
  93.135 -extern u16 VCOUNT;
  93.136 -extern u16 BG0CNT;
  93.137 -extern u16 BG1CNT;
  93.138 -extern u16 BG2CNT;
  93.139 -extern u16 BG3CNT;
  93.140 -extern u16 BG0HOFS;
  93.141 -extern u16 BG0VOFS;
  93.142 -extern u16 BG1HOFS;
  93.143 -extern u16 BG1VOFS;
  93.144 -extern u16 BG2HOFS;
  93.145 -extern u16 BG2VOFS;
  93.146 -extern u16 BG3HOFS;
  93.147 -extern u16 BG3VOFS;
  93.148 -extern u16 BG2PA;
  93.149 -extern u16 BG2PB;
  93.150 -extern u16 BG2PC;
  93.151 -extern u16 BG2PD;
  93.152 -extern u16 BG2X_L;
  93.153 -extern u16 BG2X_H;
  93.154 -extern u16 BG2Y_L;
  93.155 -extern u16 BG2Y_H;
  93.156 -extern u16 BG3PA;
  93.157 -extern u16 BG3PB;
  93.158 -extern u16 BG3PC;
  93.159 -extern u16 BG3PD;
  93.160 -extern u16 BG3X_L;
  93.161 -extern u16 BG3X_H;
  93.162 -extern u16 BG3Y_L;
  93.163 -extern u16 BG3Y_H;
  93.164 -extern u16 WIN0H;
  93.165 -extern u16 WIN1H;
  93.166 -extern u16 WIN0V;
  93.167 -extern u16 WIN1V;
  93.168 -extern u16 WININ;
  93.169 -extern u16 WINOUT;
  93.170 -extern u16 MOSAIC;
  93.171 -extern u16 BLDMOD;
  93.172 -extern u16 COLEV;
  93.173 -extern u16 COLY;
  93.174 -extern u16 DM0SAD_L;
  93.175 -extern u16 DM0SAD_H;
  93.176 -extern u16 DM0DAD_L;
  93.177 -extern u16 DM0DAD_H;
  93.178 -extern u16 DM0CNT_L;
  93.179 -extern u16 DM0CNT_H;
  93.180 -extern u16 DM1SAD_L;
  93.181 -extern u16 DM1SAD_H;
  93.182 -extern u16 DM1DAD_L;
  93.183 -extern u16 DM1DAD_H;
  93.184 -extern u16 DM1CNT_L;
  93.185 -extern u16 DM1CNT_H;
  93.186 -extern u16 DM2SAD_L;
  93.187 -extern u16 DM2SAD_H;
  93.188 -extern u16 DM2DAD_L;
  93.189 -extern u16 DM2DAD_H;
  93.190 -extern u16 DM2CNT_L;
  93.191 -extern u16 DM2CNT_H;
  93.192 -extern u16 DM3SAD_L;
  93.193 -extern u16 DM3SAD_H;
  93.194 -extern u16 DM3DAD_L;
  93.195 -extern u16 DM3DAD_H;
  93.196 -extern u16 DM3CNT_L;
  93.197 -extern u16 DM3CNT_H;
  93.198 -extern u16 TM0D;
  93.199 -extern u16 TM0CNT;
  93.200 -extern u16 TM1D;
  93.201 -extern u16 TM1CNT;
  93.202 -extern u16 TM2D;
  93.203 -extern u16 TM2CNT;
  93.204 -extern u16 TM3D;
  93.205 -extern u16 TM3CNT;
  93.206 -extern u16 P1;
  93.207 -extern u16 IE;
  93.208 -extern u16 IF;
  93.209 -extern u16 IME;
  93.210 -
  93.211 -#endif // VBA_GBA_GLOBALS_H
    94.1 --- a/src/gba/GBASound.cpp	Sat Mar 03 10:54:39 2012 -0600
    94.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.3 @@ -1,1542 +0,0 @@
    94.4 -#if (defined(WIN32) && !defined(SDL))
    94.5 -#   include "../win32/stdafx.h"
    94.6 -#   include "../win32/VBA.h"
    94.7 -#endif
    94.8 -
    94.9 -#include <cstring>
   94.10 -#include <cassert>
   94.11 -
   94.12 -#include "GBASound.h"
   94.13 -#include "../common/System.h" // SDL build needs this
   94.14 -#include "../common/Util.h"
   94.15 -#include "GBA.h"
   94.16 -#include "GBAGlobals.h"
   94.17 -
   94.18 -#ifndef countof
   94.19 -#define countof(a)  (sizeof(a) / sizeof(a[0]))
   94.20 -#endif
   94.21 -
   94.22 -soundtick_t USE_TICKS_AS = 380; // (16777216.0/44100.0); // FIXME: (16777216.0/280896.0)(fps) vs 60.0fps?
   94.23 -
   94.24 -#define SOUND_MAGIC   0x60000000
   94.25 -#define SOUND_MAGIC_2 0x30000000
   94.26 -#define NOISE_MAGIC (2097152.0 / 44100.0)
   94.27 -
   94.28 -extern bool8 stopState;
   94.29 -
   94.30 -u8 soundWavePattern[4][32] = {
   94.31 -	{ 0x01, 0x01, 0x01, 0x01,
   94.32 -	  0xff, 0xff, 0xff, 0xff,
   94.33 -	  0xff, 0xff, 0xff, 0xff,
   94.34 -	  0xff, 0xff, 0xff, 0xff,
   94.35 -	  0xff, 0xff, 0xff, 0xff,
   94.36 -	  0xff, 0xff, 0xff, 0xff,
   94.37 -	  0xff, 0xff, 0xff, 0xff,
   94.38 -	  0xff, 0xff, 0xff, 0xff },
   94.39 -	{ 0x01, 0x01, 0x01, 0x01,
   94.40 -	  0x01, 0x01, 0x01, 0x01,
   94.41 -	  0xff, 0xff, 0xff, 0xff,
   94.42 -	  0xff, 0xff, 0xff, 0xff,
   94.43 -	  0xff, 0xff, 0xff, 0xff,
   94.44 -	  0xff, 0xff, 0xff, 0xff,
   94.45 -	  0xff, 0xff, 0xff, 0xff,
   94.46 -	  0xff, 0xff, 0xff, 0xff },
   94.47 -	{ 0x01, 0x01, 0x01, 0x01,
   94.48 -	  0x01, 0x01, 0x01, 0x01,
   94.49 -	  0x01, 0x01, 0x01, 0x01,
   94.50 -	  0x01, 0x01, 0x01, 0x01,
   94.51 -	  0xff, 0xff, 0xff, 0xff,
   94.52 -	  0xff, 0xff, 0xff, 0xff,
   94.53 -	  0xff, 0xff, 0xff, 0xff,
   94.54 -	  0xff, 0xff, 0xff, 0xff },
   94.55 -	{ 0x01, 0x01, 0x01, 0x01,
   94.56 -	  0x01, 0x01, 0x01, 0x01,
   94.57 -	  0x01, 0x01, 0x01, 0x01,
   94.58 -	  0x01, 0x01, 0x01, 0x01,
   94.59 -	  0x01, 0x01, 0x01, 0x01,
   94.60 -	  0x01, 0x01, 0x01, 0x01,
   94.61 -	  0xff, 0xff, 0xff, 0xff,
   94.62 -	  0xff, 0xff, 0xff, 0xff }
   94.63 -};
   94.64 -
   94.65 -int32 soundFreqRatio[8] = {
   94.66 -	1048576, // 0
   94.67 -	524288, // 1
   94.68 -	262144, // 2
   94.69 -	174763, // 3
   94.70 -	131072, // 4
   94.71 -	104858, // 5
   94.72 -	87381, // 6
   94.73 -	74898  // 7
   94.74 -};
   94.75 -
   94.76 -int32 soundShiftClock[16] = {
   94.77 -	2,   // 0
   94.78 -	4,   // 1
   94.79 -	8,   // 2
   94.80 -	16,  // 3
   94.81 -	32,  // 4
   94.82 -	64,  // 5
   94.83 -	128, // 6
   94.84 -	256, // 7
   94.85 -	512, // 8
   94.86 -	1024, // 9
   94.87 -	2048, // 10
   94.88 -	4096, // 11
   94.89 -	8192, // 12
   94.90 -	16384, // 13
   94.91 -	1,   // 14
   94.92 -	1    // 15
   94.93 -};
   94.94 -
   94.95 -int32 soundVolume = 0;
   94.96 -
   94.97 -u8	soundBuffer[6][735];
   94.98 -u16 soundFinalWave[1470];
   94.99 -u16 soundFrameSound[735 * 30 * 2]; // for avi logging
  94.100 -
  94.101 -u32			soundBufferLen		= 1470;
  94.102 -u32			soundBufferTotalLen = 14700;
  94.103 -int32		soundQuality		= 2;
  94.104 -int32		soundPaused			= 1;
  94.105 -int32		soundPlay			= 0;
  94.106 -soundtick_t soundTicks			= soundQuality * USE_TICKS_AS;
  94.107 -soundtick_t SOUND_CLOCK_TICKS	= soundQuality * USE_TICKS_AS;
  94.108 -u32			soundNextPosition	= 0;
  94.109 -
  94.110 -int32 soundLevel1 = 0;
  94.111 -int32 soundLevel2 = 0;
  94.112 -int32 soundBalance = 0;
  94.113 -int32 soundMasterOn = 0;
  94.114 -u32	  soundIndex = 0;
  94.115 -u32	  soundBufferIndex		 = 0;
  94.116 -int32 soundFrameSoundWritten = 0;
  94.117 -int32 soundDebug			 = 0;
  94.118 -bool8 soundOffFlag			 = false;
  94.119 -
  94.120 -int32 sound1On = 0;
  94.121 -int32 sound1ATL = 0;
  94.122 -int32 sound1Skip = 0;
  94.123 -int32 sound1Index = 0;
  94.124 -int32 sound1Continue = 0;
  94.125 -int32 sound1EnvelopeVolume	  = 0;
  94.126 -int32 sound1EnvelopeATL		  = 0;
  94.127 -int32 sound1EnvelopeUpDown	  = 0;
  94.128 -int32 sound1EnvelopeATLReload = 0;
  94.129 -int32 sound1SweepATL		  = 0;
  94.130 -int32 sound1SweepATLReload	  = 0;
  94.131 -int32 sound1SweepSteps		  = 0;
  94.132 -int32 sound1SweepUpDown		  = 0;
  94.133 -int32 sound1SweepStep		  = 0;
  94.134 -u8 *  sound1Wave			  = soundWavePattern[2];
  94.135 -
  94.136 -int32 sound2On = 0;
  94.137 -int32 sound2ATL = 0;
  94.138 -int32 sound2Skip = 0;
  94.139 -int32 sound2Index = 0;
  94.140 -int32 sound2Continue = 0;
  94.141 -int32 sound2EnvelopeVolume	  = 0;
  94.142 -int32 sound2EnvelopeATL		  = 0;
  94.143 -int32 sound2EnvelopeUpDown	  = 0;
  94.144 -int32 sound2EnvelopeATLReload = 0;
  94.145 -u8 *  sound2Wave			  = soundWavePattern[2];
  94.146 -
  94.147 -int32 sound3On = 0;
  94.148 -int32 sound3ATL			= 0;
  94.149 -int32 sound3Skip		= 0;
  94.150 -int32 sound3Index		= 0;
  94.151 -int32 sound3Continue	= 0;
  94.152 -int32 sound3OutputLevel = 0;
  94.153 -int32 sound3Last		= 0;
  94.154 -u8	  sound3WaveRam[0x20];
  94.155 -int32 sound3Bank		 = 0;
  94.156 -int32 sound3DataSize	 = 0;
  94.157 -int32 sound3ForcedOutput = 0;
  94.158 -
  94.159 -int32 sound4On = 0;
  94.160 -int32 sound4Clock = 0;
  94.161 -int32 sound4ATL = 0;
  94.162 -int32 sound4Skip = 0;
  94.163 -int32 sound4Index = 0;
  94.164 -int32 sound4ShiftRight		  = 0x7f;
  94.165 -int32 sound4ShiftSkip		  = 0;
  94.166 -int32 sound4ShiftIndex		  = 0;
  94.167 -int32 sound4NSteps			  = 0;
  94.168 -int32 sound4CountDown		  = 0;
  94.169 -int32 sound4Continue		  = 0;
  94.170 -int32 sound4EnvelopeVolume	  = 0;
  94.171 -int32 sound4EnvelopeATL		  = 0;
  94.172 -int32 sound4EnvelopeUpDown	  = 0;
  94.173 -int32 sound4EnvelopeATLReload = 0;
  94.174 -
  94.175 -int32 soundControl = 0;
  94.176 -
  94.177 -int32 soundDSFifoAIndex		 = 0;
  94.178 -int32 soundDSFifoACount		 = 0;
  94.179 -int32 soundDSFifoAWriteIndex = 0;
  94.180 -bool8 soundDSAEnabled		 = false;
  94.181 -int32 soundDSATimer = 0;
  94.182 -u8	  soundDSFifoA[32];
  94.183 -u8	  soundDSAValue = 0;
  94.184 -
  94.185 -int32 soundDSFifoBIndex		 = 0;
  94.186 -int32 soundDSFifoBCount		 = 0;
  94.187 -int32 soundDSFifoBWriteIndex = 0;
  94.188 -bool8 soundDSBEnabled		 = false;
  94.189 -int32 soundDSBTimer = 0;
  94.190 -u8	  soundDSFifoB[32];
  94.191 -u8	  soundDSBValue = 0;
  94.192 -
  94.193 -int32 soundEnableFlag = 0x3ff;
  94.194 -int32 soundMutedFlag  = 0;
  94.195 -
  94.196 -s16	  soundFilter[4000];
  94.197 -s16	  soundRight[5] = { 0, 0, 0, 0, 0 };
  94.198 -s16	  soundLeft[5] = { 0, 0, 0, 0, 0 };
  94.199 -int32 soundEchoIndex = 0;
  94.200 -bool8 soundEcho		 = false;
  94.201 -bool8 soundLowPass	 = false;
  94.202 -bool8 soundReverse	 = false;
  94.203 -
  94.204 -static int32  soundTicks_int32;
  94.205 -static int32  SOUND_CLOCK_TICKS_int32;
  94.206 -static int32  soundDSBValue_int32;
  94.207 -variable_desc soundSaveStruct[] = {
  94.208 -	{ &soundPaused,				sizeof(int32)					  },
  94.209 -	{ &soundPlay,				sizeof(int32)					  },
  94.210 -	{ &soundTicks_int32,		sizeof(int32)					  },
  94.211 -	{ &SOUND_CLOCK_TICKS_int32, sizeof(int32)					  },
  94.212 -	{ &soundLevel1,				sizeof(int32)					  },
  94.213 -	{ &soundLevel2,				sizeof(int32)					  },
  94.214 -	{ &soundBalance,			sizeof(int32)					  },
  94.215 -	{ &soundMasterOn,			sizeof(int32)					  },
  94.216 -	{ &soundIndex,				sizeof(int32)					  },
  94.217 -	{ &sound1On,				sizeof(int32)					  },
  94.218 -	{ &sound1ATL,				sizeof(int32)					  },
  94.219 -	{ &sound1Skip,				sizeof(int32)					  },
  94.220 -	{ &sound1Index,				sizeof(int32)					  },
  94.221 -	{ &sound1Continue,			sizeof(int32)					  },
  94.222 -	{ &sound1EnvelopeVolume,	sizeof(int32)					  },
  94.223 -	{ &sound1EnvelopeATL,		sizeof(int32)					  },
  94.224 -	{ &sound1EnvelopeATLReload, sizeof(int32)					  },
  94.225 -	{ &sound1EnvelopeUpDown,	sizeof(int32)					  },
  94.226 -	{ &sound1SweepATL,			sizeof(int32)					  },
  94.227 -	{ &sound1SweepATLReload,	sizeof(int32)					  },
  94.228 -	{ &sound1SweepSteps,		sizeof(int32)					  },
  94.229 -	{ &sound1SweepUpDown,		sizeof(int32)					  },
  94.230 -	{ &sound1SweepStep,			sizeof(int32)					  },
  94.231 -	{ &sound2On,				sizeof(int32)					  },
  94.232 -	{ &sound2ATL,				sizeof(int32)					  },
  94.233 -	{ &sound2Skip,				sizeof(int32)					  },
  94.234 -	{ &sound2Index,				sizeof(int32)					  },
  94.235 -	{ &sound2Continue,			sizeof(int32)					  },
  94.236 -	{ &sound2EnvelopeVolume,	sizeof(int32)					  },
  94.237 -	{ &sound2EnvelopeATL,		sizeof(int32)					  },
  94.238 -	{ &sound2EnvelopeATLReload, sizeof(int32)					  },
  94.239 -	{ &sound2EnvelopeUpDown,	sizeof(int32)					  },
  94.240 -	{ &sound3On,				sizeof(int32)					  },
  94.241 -	{ &sound3ATL,				sizeof(int32)					  },
  94.242 -	{ &sound3Skip,				sizeof(int32)					  },
  94.243 -	{ &sound3Index,				sizeof(int32)					  },
  94.244 -	{ &sound3Continue,			sizeof(int32)					  },
  94.245 -	{ &sound3OutputLevel,		sizeof(int32)					  },
  94.246 -	{ &sound4On,				sizeof(int32)					  },
  94.247 -	{ &sound4ATL,				sizeof(int32)					  },
  94.248 -	{ &sound4Skip,				sizeof(int32)					  },
  94.249 -	{ &sound4Index,				sizeof(int32)					  },
  94.250 -	{ &sound4Clock,				sizeof(int32)					  },
  94.251 -	{ &sound4ShiftRight,		sizeof(int32)					  },
  94.252 -	{ &sound4ShiftSkip,			sizeof(int32)					  },
  94.253 -	{ &sound4ShiftIndex,		sizeof(int32)					  },
  94.254 -	{ &sound4NSteps,			sizeof(int32)					  },
  94.255 -	{ &sound4CountDown,			sizeof(int32)					  },
  94.256 -	{ &sound4Continue,			sizeof(int32)					  },
  94.257 -	{ &sound4EnvelopeVolume,	sizeof(int32)					  },
  94.258 -	{ &sound4EnvelopeATL,		sizeof(int32)					  },
  94.259 -	{ &sound4EnvelopeATLReload, sizeof(int32)					  },
  94.260 -	{ &sound4EnvelopeUpDown,	sizeof(int32)					  },
  94.261 -	{ &soundEnableFlag,			sizeof(int32)					  },
  94.262 -	{ &soundControl,			sizeof(int32)					  },
  94.263 -	{ &soundDSFifoAIndex,		sizeof(int32)					  },
  94.264 -	{ &soundDSFifoACount,		sizeof(int32)					  },
  94.265 -	{ &soundDSFifoAWriteIndex,	sizeof(int32)					  },
  94.266 -	{ &soundDSAEnabled,			sizeof(bool8)					  },
  94.267 -	{ &soundDSATimer,			sizeof(int32)					  },
  94.268 -	{ &soundDSFifoA[0],			32								  },
  94.269 -	{ &soundDSAValue,			sizeof(u8)						  },
  94.270 -	{ &soundDSFifoBIndex,		sizeof(int32)					  },
  94.271 -	{ &soundDSFifoBCount,		sizeof(int32)					  },
  94.272 -	{ &soundDSFifoBWriteIndex,	sizeof(int32)					  },
  94.273 -	{ &soundDSBEnabled,			sizeof(int32)					  },
  94.274 -	{ &soundDSBTimer,			sizeof(int32)					  },
  94.275 -	{ &soundDSFifoB[0],			32								  },
  94.276 -	{ &soundDSBValue_int32,		sizeof(int32)					  }, // save as int32 because of a mistake of the past.
  94.277 -	{ &soundBuffer[0][0],		6 * 735							  },
  94.278 -	{ &soundFinalWave[0],		2 * 735							  },
  94.279 -	{ NULL,						0								  }
  94.280 -};
  94.281 -
  94.282 -variable_desc soundSaveStructV2[] = {
  94.283 -	{ &sound3WaveRam[0],   0x20							},
  94.284 -	{ &sound3Bank,		   sizeof(int32)				},
  94.285 -	{ &sound3DataSize,	   sizeof(int32)				},
  94.286 -	{ &sound3ForcedOutput, sizeof(int32)				},
  94.287 -	{ NULL,				   0							}
  94.288 -};
  94.289 -
  94.290 -//variable_desc soundSaveStructV3[] = {
  94.291 -//  { &soundTicks, sizeof(soundtick_t) },
  94.292 -//  { &SOUND_CLOCK_TICKS, sizeof(soundtick_t) },
  94.293 -//  { &USE_TICKS_AS, sizeof(soundtick_t) },
  94.294 -//  { NULL, 0 }
  94.295 -//};
  94.296 -
  94.297 -void soundEvent(u32 address, u8 data)
  94.298 -{
  94.299 -	int freq = 0;
  94.300 -
  94.301 -	switch (address)
  94.302 -	{
  94.303 -	case NR10:
  94.304 -		data &= 0x7f;
  94.305 -		sound1SweepATL	  = sound1SweepATLReload = 344 * ((data >> 4) & 7);
  94.306 -		sound1SweepSteps  = data & 7;
  94.307 -		sound1SweepUpDown = data & 0x08;
  94.308 -		sound1SweepStep	  = 0;
  94.309 -		ioMem[address]	  = data;
  94.310 -		break;
  94.311 -	case NR11:
  94.312 -		sound1Wave	   = soundWavePattern[data >> 6];
  94.313 -		sound1ATL	   = 172 * (64 - (data & 0x3f));
  94.314 -		ioMem[address] = data;
  94.315 -		break;
  94.316 -	case NR12:
  94.317 -		sound1EnvelopeUpDown	= data & 0x08;
  94.318 -		sound1EnvelopeATLReload = 689 * (data & 7);
  94.319 -		if ((data & 0xF8) == 0)
  94.320 -			sound1EnvelopeVolume = 0;
  94.321 -		ioMem[address] = data;
  94.322 -		break;
  94.323 -	case NR13:
  94.324 -		freq	  = (((int)(ioMem[NR14] & 7)) << 8) | data;
  94.325 -		sound1ATL = 172 * (64 - (ioMem[NR11] & 0x3f));
  94.326 -		freq	  = 2048 - freq;
  94.327 -		if (freq)
  94.328 -		{
  94.329 -			sound1Skip = SOUND_MAGIC / freq;
  94.330 -		}
  94.331 -		else
  94.332 -			sound1Skip = 0;
  94.333 -		ioMem[address] = data;
  94.334 -		break;
  94.335 -	case NR14:
  94.336 -		data &= 0xC7;
  94.337 -		freq = (((int)(data & 7) << 8) | ioMem[NR13]);
  94.338 -		freq = 2048 - freq;
  94.339 -		sound1ATL	   = 172 * (64 - (ioMem[NR11] & 0x3f));
  94.340 -		sound1Continue = data & 0x40;
  94.341 -		if (freq)
  94.342 -		{
  94.343 -			sound1Skip = SOUND_MAGIC / freq;
  94.344 -		}
  94.345 -		else
  94.346 -			sound1Skip = 0;
  94.347 -		if (data & 0x80)
  94.348 -		{
  94.349 -			ioMem[NR52] |= 1;
  94.350 -			sound1EnvelopeVolume = ioMem[NR12] >> 4;
  94.351 -			sound1EnvelopeUpDown = ioMem[NR12] & 0x08;
  94.352 -			sound1ATL = 172 * (64 - (ioMem[NR11] & 0x3f));
  94.353 -			sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (ioMem[NR12] & 7);
  94.354 -			sound1SweepATL			= sound1SweepATLReload = 344 * ((ioMem[NR10] >> 4) & 7);
  94.355 -			sound1SweepSteps		= ioMem[NR10] & 7;
  94.356 -			sound1SweepUpDown		= ioMem[NR10] & 0x08;
  94.357 -			sound1SweepStep			= 0;
  94.358 -
  94.359 -			sound1Index = 0;
  94.360 -			sound1On	= 1;
  94.361 -		}
  94.362 -		ioMem[address] = data;
  94.363 -		break;
  94.364 -	case NR21:
  94.365 -		sound2Wave	   = soundWavePattern[data >> 6];
  94.366 -		sound2ATL	   = 172 * (64 - (data & 0x3f));
  94.367 -		ioMem[address] = data;
  94.368 -		break;
  94.369 -	case NR22:
  94.370 -		sound2EnvelopeUpDown	= data & 0x08;
  94.371 -		sound2EnvelopeATLReload = 689 * (data & 7);
  94.372 -		if ((data & 0xF8) == 0)
  94.373 -			sound2EnvelopeVolume = 0;
  94.374 -		ioMem[address] = data;
  94.375 -		break;
  94.376 -	case NR23:
  94.377 -		freq	  = (((int)(ioMem[NR24] & 7)) << 8) | data;
  94.378 -		sound2ATL = 172 * (64 - (ioMem[NR21] & 0x3f));
  94.379 -		freq	  = 2048 - freq;
  94.380 -		if (freq)
  94.381 -		{
  94.382 -			sound2Skip = SOUND_MAGIC / freq;
  94.383 -		}
  94.384 -		else
  94.385 -			sound2Skip = 0;
  94.386 -		ioMem[address] = data;
  94.387 -		break;
  94.388 -	case NR24:
  94.389 -		data &= 0xC7;
  94.390 -		freq = (((int)(data & 7) << 8) | ioMem[NR23]);
  94.391 -		freq = 2048 - freq;
  94.392 -		sound2ATL	   = 172 * (64 - (ioMem[NR21] & 0x3f));
  94.393 -		sound2Continue = data & 0x40;
  94.394 -		if (freq)
  94.395 -		{
  94.396 -			sound2Skip = SOUND_MAGIC / freq;
  94.397 -		}
  94.398 -		else
  94.399 -			sound2Skip = 0;
  94.400 -		if (data & 0x80)
  94.401 -		{
  94.402 -			ioMem[NR52] |= 2;
  94.403 -			sound2EnvelopeVolume = ioMem[NR22] >> 4;
  94.404 -			sound2EnvelopeUpDown = ioMem[NR22] & 0x08;
  94.405 -			sound2ATL = 172 * (64 - (ioMem[NR21] & 0x3f));
  94.406 -			sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (ioMem[NR22] & 7);
  94.407 -
  94.408 -			sound2Index = 0;
  94.409 -			sound2On	= 1;
  94.410 -		}
  94.411 -		ioMem[address] = data;
  94.412 -		break;
  94.413 -	case NR30:
  94.414 -		data &= 0xe0;
  94.415 -		if (!(data & 0x80))
  94.416 -		{
  94.417 -			ioMem[NR52] &= 0xfb;
  94.418 -			sound3On	 = 0;
  94.419 -		}
  94.420 -		if (((data >> 6) & 1) != sound3Bank)
  94.421 -			memcpy(&ioMem[0x90], &sound3WaveRam[(((data >> 6) & 1) * 0x10) ^ 0x10],
  94.422 -			       0x10);
  94.423 -		sound3Bank	   = (data >> 6) & 1;
  94.424 -		sound3DataSize = (data >> 5) & 1;
  94.425 -		ioMem[address] = data;
  94.426 -		break;
  94.427 -	case NR31:
  94.428 -		sound3ATL	   = 172 * (256 - data);
  94.429 -		ioMem[address] = data;
  94.430 -		break;
  94.431 -	case NR32:
  94.432 -		data &= 0xe0;
  94.433 -		sound3OutputLevel  = (data >> 5) & 3;
  94.434 -		sound3ForcedOutput = (data >> 7) & 1;
  94.435 -		ioMem[address]	   = data;
  94.436 -		break;
  94.437 -	case NR33:
  94.438 -		freq = 2048 - (((int)(ioMem[NR34] & 7) << 8) | data);
  94.439 -		if (freq)
  94.440 -		{
  94.441 -			sound3Skip = SOUND_MAGIC_2 / freq;
  94.442 -		}
  94.443 -		else
  94.444 -			sound3Skip = 0;
  94.445 -		ioMem[address] = data;
  94.446 -		break;
  94.447 -	case NR34:
  94.448 -		data &= 0xc7;
  94.449 -		freq  = 2048 - (((data & 7) << 8) | (int)ioMem[NR33]);
  94.450 -		if (freq)
  94.451 -		{
  94.452 -			sound3Skip = SOUND_MAGIC_2 / freq;
  94.453 -		}
  94.454 -		else
  94.455 -		{
  94.456 -			sound3Skip = 0;
  94.457 -		}
  94.458 -		sound3Continue = data & 0x40;
  94.459 -		if ((data & 0x80) && (ioMem[NR30] & 0x80))
  94.460 -		{
  94.461 -			ioMem[NR52] |= 4;
  94.462 -			sound3ATL	 = 172 * (256 - ioMem[NR31]);
  94.463 -			sound3Index	 = 0;
  94.464 -			sound3On	 = 1;
  94.465 -		}
  94.466 -		ioMem[address] = data;
  94.467 -		break;
  94.468 -	case NR41:
  94.469 -		data &= 0x3f;
  94.470 -		sound4ATL	   = 172 * (64 - (data & 0x3f));
  94.471 -		ioMem[address] = data;
  94.472 -		break;
  94.473 -	case NR42:
  94.474 -		sound4EnvelopeUpDown	= data & 0x08;
  94.475 -		sound4EnvelopeATLReload = 689 * (data & 7);
  94.476 -		if ((data & 0xF8) == 0)
  94.477 -			sound4EnvelopeVolume = 0;
  94.478 -		ioMem[address] = data;
  94.479 -		break;
  94.480 -	case NR43:
  94.481 -		freq		 = soundFreqRatio[data & 7];
  94.482 -		sound4NSteps = data & 0x08;
  94.483 -
  94.484 -		sound4Skip = freq * NOISE_MAGIC;
  94.485 -
  94.486 -		sound4Clock = data >> 4;
  94.487 -
  94.488 -		freq = freq / soundShiftClock[sound4Clock];
  94.489 -
  94.490 -		sound4ShiftSkip = freq * NOISE_MAGIC;
  94.491 -		ioMem[address]	= data;
  94.492 -		break;
  94.493 -	case NR44:
  94.494 -		data &= 0xc0;
  94.495 -		sound4Continue = data & 0x40;
  94.496 -		if (data & 0x80)
  94.497 -		{
  94.498 -			ioMem[NR52] |= 8;
  94.499 -			sound4EnvelopeVolume = ioMem[NR42] >> 4;
  94.500 -			sound4EnvelopeUpDown = ioMem[NR42] & 0x08;
  94.501 -			sound4ATL = 172 * (64 - (ioMem[NR41] & 0x3f));
  94.502 -			sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (ioMem[NR42] & 7);
  94.503 -
  94.504 -			sound4On = 1;
  94.505 -
  94.506 -			sound4Index		 = 0;
  94.507 -			sound4ShiftIndex = 0;
  94.508 -
  94.509 -			freq = soundFreqRatio[ioMem[NR43] & 7];
  94.510 -
  94.511 -			sound4Skip = freq * NOISE_MAGIC;
  94.512 -
  94.513 -			sound4NSteps = ioMem[NR43] & 0x08;
  94.514 -
  94.515 -			freq = freq / soundShiftClock[ioMem[NR43] >> 4];
  94.516 -
  94.517 -			sound4ShiftSkip = freq * NOISE_MAGIC;
  94.518 -			if (sound4NSteps)
  94.519 -				sound4ShiftRight = 0x7f;
  94.520 -			else
  94.521 -				sound4ShiftRight = 0x7fff;
  94.522 -		}
  94.523 -		ioMem[address] = data;
  94.524 -		break;
  94.525 -	case NR50:
  94.526 -		data &= 0x77;
  94.527 -		soundLevel1	   = data & 7;
  94.528 -		soundLevel2	   = (data >> 4) & 7;
  94.529 -		ioMem[address] = data;
  94.530 -		break;
  94.531 -	case NR51:
  94.532 -		soundBalance   = (data & soundEnableFlag);
  94.533 -		ioMem[address] = data;
  94.534 -		break;
  94.535 -	case NR52:
  94.536 -		data &= 0x80;
  94.537 -		data |= ioMem[NR52] & 15;
  94.538 -		soundMasterOn = data & 0x80;
  94.539 -		if (!(data & 0x80))
  94.540 -		{
  94.541 -			sound1On = 0;
  94.542 -			sound2On = 0;
  94.543 -			sound3On = 0;
  94.544 -			sound4On = 0;
  94.545 -		}
  94.546 -		ioMem[address] = data;
  94.547 -		break;
  94.548 -	case 0x90:
  94.549 -	case 0x91:
  94.550 -	case 0x92:
  94.551 -	case 0x93:
  94.552 -	case 0x94:
  94.553 -	case 0x95:
  94.554 -	case 0x96:
  94.555 -	case 0x97:
  94.556 -	case 0x98:
  94.557 -	case 0x99:
  94.558 -	case 0x9a:
  94.559 -	case 0x9b:
  94.560 -	case 0x9c:
  94.561 -	case 0x9d:
  94.562 -	case 0x9e:
  94.563 -	case 0x9f:
  94.564 -		sound3WaveRam[(sound3Bank * 0x10) ^ 0x10 + (address & 15)] = data;
  94.565 -		break;
  94.566 -	}
  94.567 -}
  94.568 -
  94.569 -void soundEvent(u32 address, u16 data)
  94.570 -{
  94.571 -	switch (address)
  94.572 -	{
  94.573 -	case SGCNT0_H:
  94.574 -		data		&= 0xFF0F;
  94.575 -		soundControl = data & 0x770F;;
  94.576 -		if (data & 0x0800)
  94.577 -		{
  94.578 -			soundDSFifoAWriteIndex = 0;
  94.579 -			soundDSFifoAIndex	   = 0;
  94.580 -			soundDSFifoACount	   = 0;
  94.581 -			soundDSAValue = 0;
  94.582 -			memset(soundDSFifoA, 0, 32);
  94.583 -		}
  94.584 -		soundDSAEnabled = (data & 0x0300) ? true : false;
  94.585 -		soundDSATimer	= (data & 0x0400) ? 1 : 0;
  94.586 -		if (data & 0x8000)
  94.587 -		{
  94.588 -			soundDSFifoBWriteIndex = 0;
  94.589 -			soundDSFifoBIndex	   = 0;
  94.590 -			soundDSFifoBCount	   = 0;
  94.591 -			soundDSBValue = 0;
  94.592 -			memset(soundDSFifoB, 0, 32);
  94.593 -		}
  94.594 -		soundDSBEnabled = (data & 0x3000) ? true : false;
  94.595 -		soundDSBTimer	= (data & 0x4000) ? 1 : 0;
  94.596 -		*((u16 *)&ioMem[address]) = data;
  94.597 -		break;
  94.598 -	case FIFOA_L:
  94.599 -	case FIFOA_H:
  94.600 -		soundDSFifoA[soundDSFifoAWriteIndex++] = data & 0xFF;
  94.601 -		soundDSFifoA[soundDSFifoAWriteIndex++] = data >> 8;
  94.602 -		soundDSFifoACount		 += 2;
  94.603 -		soundDSFifoAWriteIndex	 &= 31;
  94.604 -		*((u16 *)&ioMem[address]) = data;
  94.605 -		break;
  94.606 -	case FIFOB_L:
  94.607 -	case FIFOB_H:
  94.608 -		soundDSFifoB[soundDSFifoBWriteIndex++] = data & 0xFF;
  94.609 -		soundDSFifoB[soundDSFifoBWriteIndex++] = data >> 8;
  94.610 -		soundDSFifoBCount		 += 2;
  94.611 -		soundDSFifoBWriteIndex	 &= 31;
  94.612 -		*((u16 *)&ioMem[address]) = data;
  94.613 -		break;
  94.614 -	case 0x88:
  94.615 -		data &= 0xC3FF;
  94.616 -		*((u16 *)&ioMem[address]) = data;
  94.617 -		break;
  94.618 -	case 0x90:
  94.619 -	case 0x92:
  94.620 -	case 0x94:
  94.621 -	case 0x96:
  94.622 -	case 0x98:
  94.623 -	case 0x9a:
  94.624 -	case 0x9c:
  94.625 -	case 0x9e:
  94.626 -		*((u16 *)&sound3WaveRam[(sound3Bank * 0x10) ^ 0x10 + (address & 14)]) = data;
  94.627 -		*((u16 *)&ioMem[address]) = data;
  94.628 -		break;
  94.629 -	}
  94.630 -}
  94.631 -
  94.632 -void soundChannel1()
  94.633 -{
  94.634 -	int vol = sound1EnvelopeVolume;
  94.635 -
  94.636 -	int freq  = 0;
  94.637 -	int value = 0;
  94.638 -
  94.639 -	if (sound1On && (sound1ATL || !sound1Continue))
  94.640 -	{
  94.641 -		sound1Index += soundQuality * sound1Skip;
  94.642 -		sound1Index &= 0x1fffffff;
  94.643 -
  94.644 -		value = ((s8)sound1Wave[sound1Index >> 24]) * vol;
  94.645 -	}
  94.646 -
  94.647 -	soundBuffer[0][soundIndex] = value;
  94.648 -
  94.649 -	if (sound1On)
  94.650 -	{
  94.651 -		if (sound1ATL)
  94.652 -		{
  94.653 -			sound1ATL -= soundQuality;
  94.654 -
  94.655 -			if (sound1ATL <= 0 && sound1Continue)
  94.656 -			{
  94.657 -				ioMem[NR52] &= 0xfe;
  94.658 -				sound1On	 = 0;
  94.659 -			}
  94.660 -		}
  94.661 -
  94.662 -		if (sound1EnvelopeATL)
  94.663 -		{
  94.664 -			sound1EnvelopeATL -= soundQuality;
  94.665 -
  94.666 -			if (sound1EnvelopeATL <= 0)
  94.667 -			{
  94.668 -				if (sound1EnvelopeUpDown)
  94.669 -				{
  94.670 -					if (sound1EnvelopeVolume < 15)
  94.671 -						sound1EnvelopeVolume++;
  94.672 -				}
  94.673 -				else
  94.674 -				{
  94.675 -					if (sound1EnvelopeVolume)
  94.676 -						sound1EnvelopeVolume--;
  94.677 -				}
  94.678 -
  94.679 -				sound1EnvelopeATL += sound1EnvelopeATLReload;
  94.680 -			}
  94.681 -		}
  94.682 -
  94.683 -		if (sound1SweepATL)
  94.684 -		{
  94.685 -			sound1SweepATL -= soundQuality;
  94.686 -
  94.687 -			if (sound1SweepATL <= 0)
  94.688 -			{
  94.689 -				freq = (((int)(ioMem[NR14] & 7) << 8) | ioMem[NR13]);
  94.690 -
  94.691 -				int updown = 1;
  94.692 -
  94.693 -				if (sound1SweepUpDown)
  94.694 -					updown = -1;
  94.695 -
  94.696 -				int newfreq = 0;
  94.697 -				if (sound1SweepSteps)
  94.698 -				{
  94.699 -					newfreq = freq + updown * freq / (1 << sound1SweepSteps);
  94.700 -					if (newfreq == freq)
  94.701 -						newfreq = 0;
  94.702 -				}
  94.703 -				else
  94.704 -					newfreq = freq;
  94.705 -
  94.706 -				if (newfreq < 0)
  94.707 -				{
  94.708 -					sound1SweepATL += sound1SweepATLReload;
  94.709 -				}
  94.710 -				else if (newfreq > 2047)
  94.711 -				{
  94.712 -					sound1SweepATL = 0;
  94.713 -					sound1On	   = 0;
  94.714 -					ioMem[NR52]	  &= 0xfe;
  94.715 -				}
  94.716 -				else
  94.717 -				{
  94.718 -					sound1SweepATL += sound1SweepATLReload;
  94.719 -					sound1Skip		= SOUND_MAGIC / (2048 - newfreq);
  94.720 -
  94.721 -					ioMem[NR13] = newfreq & 0xff;
  94.722 -					ioMem[NR14] = (ioMem[NR14] & 0xf8) | ((newfreq >> 8) & 7);
  94.723 -				}
  94.724 -			}
  94.725 -		}
  94.726 -	}
  94.727 -}
  94.728 -
  94.729 -void soundChannel2()
  94.730 -{
  94.731 -	//  int freq = 0;
  94.732 -	int vol = sound2EnvelopeVolume;
  94.733 -
  94.734 -	int value = 0;
  94.735 -
  94.736 -	if (sound2On && (sound2ATL || !sound2Continue))
  94.737 -	{
  94.738 -		sound2Index += soundQuality * sound2Skip;
  94.739 -		sound2Index &= 0x1fffffff;
  94.740 -
  94.741 -		value = ((s8)sound2Wave[sound2Index >> 24]) * vol;
  94.742 -	}
  94.743 -
  94.744 -	soundBuffer[1][soundIndex] = value;
  94.745 -
  94.746 -	if (sound2On)
  94.747 -	{
  94.748 -		if (sound2ATL)
  94.749 -		{
  94.750 -			sound2ATL -= soundQuality;
  94.751 -
  94.752 -			if (sound2ATL <= 0 && sound2Continue)
  94.753 -			{
  94.754 -				ioMem[NR52] &= 0xfd;
  94.755 -				sound2On	 = 0;
  94.756 -			}
  94.757 -		}
  94.758 -
  94.759 -		if (sound2EnvelopeATL)
  94.760 -		{
  94.761 -			sound2EnvelopeATL -= soundQuality;
  94.762 -
  94.763 -			if (sound2EnvelopeATL <= 0)
  94.764 -			{
  94.765 -				if (sound2EnvelopeUpDown)
  94.766 -				{
  94.767 -					if (sound2EnvelopeVolume < 15)
  94.768 -						sound2EnvelopeVolume++;
  94.769 -				}
  94.770 -				else
  94.771 -				{
  94.772 -					if (sound2EnvelopeVolume)
  94.773 -						sound2EnvelopeVolume--;
  94.774 -				}
  94.775 -				sound2EnvelopeATL += sound2EnvelopeATLReload;
  94.776 -			}
  94.777 -		}
  94.778 -	}
  94.779 -}
  94.780 -
  94.781 -void soundChannel3()
  94.782 -{
  94.783 -	int value = sound3Last;
  94.784 -
  94.785 -	if (sound3On && (sound3ATL || !sound3Continue))
  94.786 -	{
  94.787 -		sound3Index += soundQuality * sound3Skip;
  94.788 -		if (sound3DataSize)
  94.789 -		{
  94.790 -			sound3Index &= 0x3fffffff;
  94.791 -			value		 = sound3WaveRam[sound3Index >> 25];
  94.792 -		}
  94.793 -		else
  94.794 -		{
  94.795 -			sound3Index &= 0x1fffffff;
  94.796 -			value		 = sound3WaveRam[sound3Bank * 0x10 + (sound3Index >> 25)];
  94.797 -		}
  94.798 -
  94.799 -		if ((sound3Index & 0x01000000))
  94.800 -		{
  94.801 -			value &= 0x0f;
  94.802 -		}
  94.803 -		else
  94.804 -		{
  94.805 -			value >>= 4;
  94.806 -		}
  94.807 -
  94.808 -		value -= 8;
  94.809 -		value *= 2;
  94.810 -
  94.811 -		if (sound3ForcedOutput)
  94.812 -		{
  94.813 -			value = ((value >> 1) + value) >> 1;
  94.814 -		}
  94.815 -		else
  94.816 -		{
  94.817 -			switch (sound3OutputLevel)
  94.818 -			{
  94.819 -			case 0:
  94.820 -				value = 0;
  94.821 -				break;
  94.822 -			case 1:
  94.823 -				break;
  94.824 -			case 2:
  94.825 -				value = (value >> 1);
  94.826 -				break;
  94.827 -			case 3:
  94.828 -				value = (value >> 2);
  94.829 -				break;
  94.830 -			}
  94.831 -		}
  94.832 -		//value += 1;
  94.833 -		sound3Last = value;
  94.834 -	}
  94.835 -
  94.836 -	soundBuffer[2][soundIndex] = value;
  94.837 -
  94.838 -	if (sound3On)
  94.839 -	{
  94.840 -		if (sound3ATL)
  94.841 -		{
  94.842 -			sound3ATL -= soundQuality;
  94.843 -
  94.844 -			if (sound3ATL <= 0 && sound3Continue)
  94.845 -			{
  94.846 -				ioMem[NR52] &= 0xfb;
  94.847 -				sound3On	 = 0;
  94.848 -			}
  94.849 -		}
  94.850 -	}
  94.851 -}
  94.852 -
  94.853 -void soundChannel4()
  94.854 -{
  94.855 -	int vol = sound4EnvelopeVolume;
  94.856 -
  94.857 -	int value = 0;
  94.858 -
  94.859 -	if (sound4Clock <= 0x0c)
  94.860 -	{
  94.861 -		if (sound4On && (sound4ATL || !sound4Continue))
  94.862 -		{
  94.863 -	  #define NOISE_ONE_SAMP_SCALE  0x200000
  94.864 -
  94.865 -			sound4Index		 += soundQuality * sound4Skip;
  94.866 -			sound4ShiftIndex += soundQuality * sound4ShiftSkip;
  94.867 -
  94.868 -			if (sound4NSteps)
  94.869 -			{
  94.870 -				while (sound4ShiftIndex >= NOISE_ONE_SAMP_SCALE)
  94.871 -				{
  94.872 -					sound4ShiftRight = (((sound4ShiftRight << 6) ^
  94.873 -					                     (sound4ShiftRight << 5)) & 0x40) |
  94.874 -					                   (sound4ShiftRight >> 1);
  94.875 -					sound4ShiftIndex -= NOISE_ONE_SAMP_SCALE;
  94.876 -				}
  94.877 -			}
  94.878 -			else
  94.879 -			{
  94.880 -				while (sound4ShiftIndex >= NOISE_ONE_SAMP_SCALE)
  94.881 -				{
  94.882 -					sound4ShiftRight = (((sound4ShiftRight << 14) ^
  94.883 -					                     (sound4ShiftRight << 13)) & 0x4000) |
  94.884 -					                   (sound4ShiftRight >> 1);
  94.885 -
  94.886 -					sound4ShiftIndex -= NOISE_ONE_SAMP_SCALE;
  94.887 -				}
  94.888 -			}
  94.889 -
  94.890 -			sound4Index		 %= NOISE_ONE_SAMP_SCALE;
  94.891 -			sound4ShiftIndex %= NOISE_ONE_SAMP_SCALE;
  94.892 -
  94.893 -			value = ((sound4ShiftRight & 1) * 2 - 1) * vol;
  94.894 -		}
  94.895 -		else
  94.896 -		{
  94.897 -			value = 0;
  94.898 -		}
  94.899 -	}
  94.900 -
  94.901 -	soundBuffer[3][soundIndex] = value;
  94.902 -
  94.903 -	if (sound4On)
  94.904 -	{
  94.905 -		if (sound4ATL)
  94.906 -		{
  94.907 -			sound4ATL -= soundQuality;
  94.908 -
  94.909 -			if (sound4ATL <= 0 && sound4Continue)
  94.910 -			{
  94.911 -				ioMem[NR52] &= 0xfd;
  94.912 -				sound4On	 = 0;
  94.913 -			}
  94.914 -		}
  94.915 -
  94.916 -		if (sound4EnvelopeATL)
  94.917 -		{
  94.918 -			sound4EnvelopeATL -= soundQuality;
  94.919 -
  94.920 -			if (sound4EnvelopeATL <= 0)
  94.921 -			{
  94.922 -				if (sound4EnvelopeUpDown)
  94.923 -				{
  94.924 -					if (sound4EnvelopeVolume < 15)
  94.925 -						sound4EnvelopeVolume++;
  94.926 -				}
  94.927 -				else
  94.928 -				{
  94.929 -					if (sound4EnvelopeVolume)
  94.930 -						sound4EnvelopeVolume--;
  94.931 -				}
  94.932 -				sound4EnvelopeATL += sound4EnvelopeATLReload;
  94.933 -			}
  94.934 -		}
  94.935 -	}
  94.936 -}
  94.937 -
  94.938 -void soundDirectSoundA()
  94.939 -{
  94.940 -	soundBuffer[4][soundIndex] = soundDSAValue;
  94.941 -}
  94.942 -
  94.943 -void soundDirectSoundATimer()
  94.944 -{
  94.945 -	if (soundDSAEnabled)
  94.946 -	{
  94.947 -		if (soundDSFifoACount <= 16)
  94.948 -		{
  94.949 -			CPUCheckDMA(3, 2);
  94.950 -			if (soundDSFifoACount <= 16)
  94.951 -			{
  94.952 -				soundEvent(FIFOA_L, (u16)0);
  94.953 -				soundEvent(FIFOA_H, (u16)0);
  94.954 -				soundEvent(FIFOA_L, (u16)0);
  94.955 -				soundEvent(FIFOA_H, (u16)0);
  94.956 -				soundEvent(FIFOA_L, (u16)0);
  94.957 -				soundEvent(FIFOA_H, (u16)0);
  94.958 -				soundEvent(FIFOA_L, (u16)0);
  94.959 -				soundEvent(FIFOA_H, (u16)0);
  94.960 -			}
  94.961 -		}
  94.962 -
  94.963 -		soundDSAValue	  = (soundDSFifoA[soundDSFifoAIndex]);
  94.964 -		soundDSFifoAIndex = (++soundDSFifoAIndex) & 31;
  94.965 -		soundDSFifoACount--;
  94.966 -	}
  94.967 -	else
  94.968 -		soundDSAValue = 0;
  94.969 -}
  94.970 -
  94.971 -void soundDirectSoundB()
  94.972 -{
  94.973 -	soundBuffer[5][soundIndex] = soundDSBValue;
  94.974 -}
  94.975 -
  94.976 -void soundDirectSoundBTimer()
  94.977 -{
  94.978 -	if (soundDSBEnabled)
  94.979 -	{
  94.980 -		if (soundDSFifoBCount <= 16)
  94.981 -		{
  94.982 -			CPUCheckDMA(3, 4);
  94.983 -			if (soundDSFifoBCount <= 16)
  94.984 -			{
  94.985 -				soundEvent(FIFOB_L, (u16)0);
  94.986 -				soundEvent(FIFOB_H, (u16)0);
  94.987 -				soundEvent(FIFOB_L, (u16)0);
  94.988 -				soundEvent(FIFOB_H, (u16)0);
  94.989 -				soundEvent(FIFOB_L, (u16)0);
  94.990 -				soundEvent(FIFOB_H, (u16)0);
  94.991 -				soundEvent(FIFOB_L, (u16)0);
  94.992 -				soundEvent(FIFOB_H, (u16)0);
  94.993 -			}
  94.994 -		}
  94.995 -
  94.996 -		soundDSBValue	  = (soundDSFifoB[soundDSFifoBIndex]);
  94.997 -		soundDSFifoBIndex = (++soundDSFifoBIndex) & 31;
  94.998 -		soundDSFifoBCount--;
  94.999 -	}
 94.1000 -	else
 94.1001 -	{
 94.1002 -		soundDSBValue = 0;
 94.1003 -	}
 94.1004 -}
 94.1005 -
 94.1006 -void soundTimerOverflow(int timer)
 94.1007 -{
 94.1008 -	if (soundDSAEnabled && (soundDSATimer == timer))
 94.1009 -	{
 94.1010 -		soundDirectSoundATimer();
 94.1011 -	}
 94.1012 -	if (soundDSBEnabled && (soundDSBTimer == timer))
 94.1013 -	{
 94.1014 -		soundDirectSoundBTimer();
 94.1015 -	}
 94.1016 -}
 94.1017 -
 94.1018 -void soundMix()
 94.1019 -{
 94.1020 -	int res		 = 0;
 94.1021 -	int cgbRes	 = 0;
 94.1022 -	int ratio	 = ioMem[0x82] & 3;
 94.1023 -	int dsaRatio = ioMem[0x82] & 4;
 94.1024 -	int dsbRatio = ioMem[0x82] & 8;
 94.1025 -
 94.1026 -	if (ioMem)
 94.1027 -		soundBalance = (ioMem[NR51] & soundEnableFlag & ~soundMutedFlag);
 94.1028 -
 94.1029 -	if (soundBalance & 16)
 94.1030 -	{
 94.1031 -		cgbRes = ((s8)soundBuffer[0][soundIndex]);
 94.1032 -	}
 94.1033 -	if (soundBalance & 32)
 94.1034 -	{
 94.1035 -		cgbRes += ((s8)soundBuffer[1][soundIndex]);
 94.1036 -	}
 94.1037 -	if (soundBalance & 64)
 94.1038 -	{
 94.1039 -		cgbRes += ((s8)soundBuffer[2][soundIndex]);
 94.1040 -	}
 94.1041 -	if (soundBalance & 128)
 94.1042 -	{
 94.1043 -		cgbRes += ((s8)soundBuffer[3][soundIndex]);
 94.1044 -	}
 94.1045 -
 94.1046 -	if ((soundControl & 0x0200) && (soundEnableFlag & 0x100))
 94.1047 -	{
 94.1048 -		if (!dsaRatio)
 94.1049 -			res = ((s8)soundBuffer[4][soundIndex]) >> 1;
 94.1050 -		else
 94.1051 -			res = ((s8)soundBuffer[4][soundIndex]);
 94.1052 -	}
 94.1053 -
 94.1054 -	if ((soundControl & 0x2000) && (soundEnableFlag & 0x200))
 94.1055 -	{
 94.1056 -		if (!dsbRatio)
 94.1057 -			res += ((s8)soundBuffer[5][soundIndex]) >> 1;
 94.1058 -		else
 94.1059 -			res += ((s8)soundBuffer[5][soundIndex]);
 94.1060 -	}
 94.1061 -
 94.1062 -	res	   = (res * 170);
 94.1063 -	cgbRes = (cgbRes * 52 * soundLevel1);
 94.1064 -
 94.1065 -	switch (ratio)
 94.1066 -	{
 94.1067 -	case 0:
 94.1068 -	case 3: // prohibited, but 25%
 94.1069 -		cgbRes >>= 2;
 94.1070 -		break;
 94.1071 -	case 1:
 94.1072 -		cgbRes >>= 1;
 94.1073 -		break;
 94.1074 -	case 2:
 94.1075 -		break;
 94.1076 -	}
 94.1077 -
 94.1078 -	res += cgbRes;
 94.1079 -
 94.1080 -	if (soundEcho)
 94.1081 -	{
 94.1082 -		res *= 2;
 94.1083 -		res += soundFilter[soundEchoIndex];
 94.1084 -		res /= 2;
 94.1085 -		soundFilter[soundEchoIndex++] = res;
 94.1086 -	}
 94.1087 -
 94.1088 -	if (soundLowPass)
 94.1089 -	{
 94.1090 -		soundLeft[4] = soundLeft[3];
 94.1091 -		soundLeft[3] = soundLeft[2];
 94.1092 -		soundLeft[2] = soundLeft[1];
 94.1093 -		soundLeft[1] = soundLeft[0];
 94.1094 -		soundLeft[0] = res;
 94.1095 -		res = (soundLeft[4] + 2 * soundLeft[3] + 8 * soundLeft[2] + 2 * soundLeft[1] +
 94.1096 -		       soundLeft[0]) / 14;
 94.1097 -	}
 94.1098 -
 94.1099 -	bool noSpecialEffects = false;
 94.1100 -#if (defined(WIN32) && !defined(SDL))
 94.1101 -	if (theApp.soundRecording || theApp.aviRecording || theApp.nvAudioLog)
 94.1102 -		noSpecialEffects = true;
 94.1103 -#endif
 94.1104 -
 94.1105 -	if (!noSpecialEffects)
 94.1106 -	{
 94.1107 -		switch (soundVolume)
 94.1108 -		{
 94.1109 -		case 0:
 94.1110 -		case 1:
 94.1111 -		case 2:
 94.1112 -		case 3:
 94.1113 -			res *= (soundVolume + 1);
 94.1114 -			break;
 94.1115 -		case 4:
 94.1116 -			res >>= 2;
 94.1117 -			break;
 94.1118 -		case 5:
 94.1119 -			res >>= 1;
 94.1120 -			break;
 94.1121 -		}
 94.1122 -	}
 94.1123 -
 94.1124 -	if (res > 32767)
 94.1125 -		res = 32767;
 94.1126 -	if (res < -32768)
 94.1127 -		res = -32768;
 94.1128 -
 94.1129 -	if (soundReverse && !noSpecialEffects)
 94.1130 -	{
 94.1131 -		soundFinalWave[++soundBufferIndex] = res;
 94.1132 -		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
 94.1133 -			/*assert(false)*/;
 94.1134 -		else
 94.1135 -			soundFrameSound[++soundFrameSoundWritten] = res;
 94.1136 -	}
 94.1137 -	else
 94.1138 -	{
 94.1139 -		soundFinalWave[soundBufferIndex++] = res;
 94.1140 -		if (soundFrameSoundWritten >= countof(soundFrameSound))
 94.1141 -			/*assert(false)*/;
 94.1142 -		else
 94.1143 -			soundFrameSound[soundFrameSoundWritten++] = res;
 94.1144 -	}
 94.1145 -
 94.1146 -	res	   = 0;
 94.1147 -	cgbRes = 0;
 94.1148 -
 94.1149 -	if (soundBalance & 1)
 94.1150 -	{
 94.1151 -		cgbRes = ((s8)soundBuffer[0][soundIndex]);
 94.1152 -	}
 94.1153 -	if (soundBalance & 2)
 94.1154 -	{
 94.1155 -		cgbRes += ((s8)soundBuffer[1][soundIndex]);
 94.1156 -	}
 94.1157 -	if (soundBalance & 4)
 94.1158 -	{
 94.1159 -		cgbRes += ((s8)soundBuffer[2][soundIndex]);
 94.1160 -	}
 94.1161 -	if (soundBalance & 8)
 94.1162 -	{
 94.1163 -		cgbRes += ((s8)soundBuffer[3][soundIndex]);
 94.1164 -	}
 94.1165 -
 94.1166 -	if ((soundControl & 0x0100) && (soundEnableFlag & 0x100))
 94.1167 -	{
 94.1168 -		if (!dsaRatio)
 94.1169 -			res = ((s8)soundBuffer[4][soundIndex]) >> 1;
 94.1170 -		else
 94.1171 -			res = ((s8)soundBuffer[4][soundIndex]);
 94.1172 -	}
 94.1173 -
 94.1174 -	if ((soundControl & 0x1000) && (soundEnableFlag & 0x200))
 94.1175 -	{
 94.1176 -		if (!dsbRatio)
 94.1177 -			res += ((s8)soundBuffer[5][soundIndex]) >> 1;
 94.1178 -		else
 94.1179 -			res += ((s8)soundBuffer[5][soundIndex]);
 94.1180 -	}
 94.1181 -
 94.1182 -	res	   = (res * 170);
 94.1183 -	cgbRes = (cgbRes * 52 * soundLevel1);
 94.1184 -
 94.1185 -	switch (ratio)
 94.1186 -	{
 94.1187 -	case 0:
 94.1188 -	case 3: // prohibited, but 25%
 94.1189 -		cgbRes >>= 2;
 94.1190 -		break;
 94.1191 -	case 1:
 94.1192 -		cgbRes >>= 1;
 94.1193 -		break;
 94.1194 -	case 2:
 94.1195 -		break;
 94.1196 -	}
 94.1197 -
 94.1198 -	res += cgbRes;
 94.1199 -
 94.1200 -	if (soundEcho)
 94.1201 -	{
 94.1202 -		res *= 2;
 94.1203 -		res += soundFilter[soundEchoIndex];
 94.1204 -		res /= 2;
 94.1205 -		soundFilter[soundEchoIndex++] = res;
 94.1206 -
 94.1207 -		if (soundEchoIndex >= 4000)
 94.1208 -			soundEchoIndex = 0;
 94.1209 -	}
 94.1210 -
 94.1211 -	if (soundLowPass)
 94.1212 -	{
 94.1213 -		soundRight[4] = soundRight[3];
 94.1214 -		soundRight[3] = soundRight[2];
 94.1215 -		soundRight[2] = soundRight[1];
 94.1216 -		soundRight[1] = soundRight[0];
 94.1217 -		soundRight[0] = res;
 94.1218 -		res = (soundRight[4] + 2 * soundRight[3] + 8 * soundRight[2] + 2 * soundRight[1] +
 94.1219 -		       soundRight[0]) / 14;
 94.1220 -	}
 94.1221 -
 94.1222 -	if (!noSpecialEffects)
 94.1223 -	{
 94.1224 -		switch (soundVolume)
 94.1225 -		{
 94.1226 -		case 0:
 94.1227 -		case 1:
 94.1228 -		case 2:
 94.1229 -		case 3:
 94.1230 -			res *= (soundVolume + 1);
 94.1231 -			break;
 94.1232 -		case 4:
 94.1233 -			res >>= 2;
 94.1234 -			break;
 94.1235 -		case 5:
 94.1236 -			res >>= 1;
 94.1237 -			break;
 94.1238 -		}
 94.1239 -	}
 94.1240 -
 94.1241 -	if (res > 32767)
 94.1242 -		res = 32767;
 94.1243 -	if (res < -32768)
 94.1244 -		res = -32768;
 94.1245 -
 94.1246 -	if (soundReverse && !noSpecialEffects)
 94.1247 -	{
 94.1248 -		soundFinalWave[-1 + soundBufferIndex++]		   = res;
 94.1249 -		if ((soundFrameSoundWritten) >= countof(soundFrameSound))
 94.1250 -			/*assert(false)*/;
 94.1251 -		else
 94.1252 -			soundFrameSound[-1 + soundFrameSoundWritten++] = res;
 94.1253 -	}
 94.1254 -	else
 94.1255 -	{
 94.1256 -		soundFinalWave[soundBufferIndex++]			  = res;
 94.1257 -		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
 94.1258 -			/*assert(false)*/;
 94.1259 -		else
 94.1260 -			soundFrameSound[soundFrameSoundWritten++] = res;
 94.1261 -	}
 94.1262 -}
 94.1263 -
 94.1264 -void soundTick()
 94.1265 -{
 94.1266 -	if (systemSoundOn)
 94.1267 -	{
 94.1268 -		if (soundMasterOn && !stopState)
 94.1269 -		{
 94.1270 -			soundChannel1();
 94.1271 -			soundChannel2();
 94.1272 -			soundChannel3();
 94.1273 -			soundChannel4();
 94.1274 -			soundDirectSoundA();
 94.1275 -			soundDirectSoundB();
 94.1276 -			soundMix();
 94.1277 -		}
 94.1278 -		else
 94.1279 -		{
 94.1280 -			soundFinalWave[soundBufferIndex++] = 0;
 94.1281 -			soundFinalWave[soundBufferIndex++] = 0;
 94.1282 -			if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
 94.1283 -				/*assert(false)*/;
 94.1284 -			else
 94.1285 -			{
 94.1286 -				soundFrameSound[soundFrameSoundWritten++] = 0;
 94.1287 -				soundFrameSound[soundFrameSoundWritten++] = 0;
 94.1288 -			}
 94.1289 -		}
 94.1290 -
 94.1291 -		soundIndex++;
 94.1292 -
 94.1293 -		if (2 * soundBufferIndex >= soundBufferLen)
 94.1294 -		{
 94.1295 -			if (systemSoundOn)
 94.1296 -			{
 94.1297 -				if (soundPaused)
 94.1298 -				{
 94.1299 -					soundResume();
 94.1300 -				}
 94.1301 -
 94.1302 -				systemSoundWriteToBuffer();
 94.1303 -			}
 94.1304 -			soundIndex		 = 0;
 94.1305 -			soundBufferIndex = 0;
 94.1306 -		}
 94.1307 -	}
 94.1308 -}
 94.1309 -
 94.1310 -void soundShutdown()
 94.1311 -{
 94.1312 -	systemSoundShutdown();
 94.1313 -}
 94.1314 -
 94.1315 -void soundPause()
 94.1316 -{
 94.1317 -	systemSoundPause();
 94.1318 -}
 94.1319 -
 94.1320 -void soundResume()
 94.1321 -{
 94.1322 -	systemSoundResume();
 94.1323 -}
 94.1324 -
 94.1325 -void soundEnableChannels(int channels)
 94.1326 -{
 94.1327 -	int c = (channels & 0x0f) << 4;
 94.1328 -	soundEnableFlag |= ((channels & 0x30f) | c);
 94.1329 -}
 94.1330 -
 94.1331 -void soundDisableChannels(int channels)
 94.1332 -{
 94.1333 -	int c = (channels & 0x0f) << 4;
 94.1334 -	soundEnableFlag &= ~((channels & 0x30f) | c);
 94.1335 -}
 94.1336 -
 94.1337 -int soundGetEnabledChannels()
 94.1338 -{
 94.1339 -	return (soundEnableFlag & 0x30f);
 94.1340 -}
 94.1341 -
 94.1342 -#if 0
 94.1343 -// unused
 94.1344 -void soundMuteChannels(int channels)
 94.1345 -{
 94.1346 -	soundMutedFlag |= channels & 0x30f;
 94.1347 -}
 94.1348 -
 94.1349 -void soundUnmuteChannels(int channels)
 94.1350 -{
 94.1351 -	soundMutedFlag &= ~(channels & 0x30f);
 94.1352 -}
 94.1353 -
 94.1354 -int soundGetMutedChannels()
 94.1355 -{
 94.1356 -	return (soundMutedFlag & 0x30f);
 94.1357 -}
 94.1358 -#endif
 94.1359 -
 94.1360 -void soundReset()
 94.1361 -{
 94.1362 -	systemSoundReset();
 94.1363 -
 94.1364 -	soundPaused		  = 1;
 94.1365 -	soundPlay		  = 0;
 94.1366 -	SOUND_CLOCK_TICKS = soundQuality * USE_TICKS_AS;
 94.1367 -	soundTicks		  = SOUND_CLOCK_TICKS;
 94.1368 -	soundNextPosition = 0;
 94.1369 -	soundMasterOn	  = 1;
 94.1370 -	soundIndex		  = 0;
 94.1371 -	soundBufferIndex  = 0;
 94.1372 -	soundLevel1		  = 7;
 94.1373 -	soundLevel2		  = 7;
 94.1374 -
 94.1375 -	sound1On = 0;
 94.1376 -	sound1ATL = 0;
 94.1377 -	sound1Skip = 0;
 94.1378 -	sound1Index = 0;
 94.1379 -	sound1Continue = 0;
 94.1380 -	sound1EnvelopeVolume	= 0;
 94.1381 -	sound1EnvelopeATL		= 0;
 94.1382 -	sound1EnvelopeUpDown	= 0;
 94.1383 -	sound1EnvelopeATLReload = 0;
 94.1384 -	sound1SweepATL			= 0;
 94.1385 -	sound1SweepATLReload	= 0;
 94.1386 -	sound1SweepSteps		= 0;
 94.1387 -	sound1SweepUpDown		= 0;
 94.1388 -	sound1SweepStep			= 0;
 94.1389 -	sound1Wave				= soundWavePattern[2];
 94.1390 -
 94.1391 -	sound2On = 0;
 94.1392 -	sound2ATL = 0;
 94.1393 -	sound2Skip = 0;
 94.1394 -	sound2Index = 0;
 94.1395 -	sound2Continue = 0;
 94.1396 -	sound2EnvelopeVolume	= 0;
 94.1397 -	sound2EnvelopeATL		= 0;
 94.1398 -	sound2EnvelopeUpDown	= 0;
 94.1399 -	sound2EnvelopeATLReload = 0;
 94.1400 -	sound2Wave				= soundWavePattern[2];
 94.1401 -
 94.1402 -	sound3On = 0;
 94.1403 -	sound3ATL = 0;
 94.1404 -	sound3Skip		   = 0;
 94.1405 -	sound3Index		   = 0;
 94.1406 -	sound3Continue	   = 0;
 94.1407 -	sound3OutputLevel  = 0;
 94.1408 -	sound3Last		   = 0;
 94.1409 -	sound3Bank		   = 0;
 94.1410 -	sound3DataSize	   = 0;
 94.1411 -	sound3ForcedOutput = 0;
 94.1412 -
 94.1413 -	sound4On = 0;
 94.1414 -	sound4Clock = 0;
 94.1415 -	sound4ATL = 0;
 94.1416 -	sound4Skip = 0;
 94.1417 -	sound4Index = 0;
 94.1418 -	sound4ShiftRight		= 0x7f;
 94.1419 -	sound4NSteps			= 0;
 94.1420 -	sound4CountDown			= 0;
 94.1421 -	sound4Continue			= 0;
 94.1422 -	sound4EnvelopeVolume	= 0;
 94.1423 -	sound4EnvelopeATL		= 0;
 94.1424 -	sound4EnvelopeUpDown	= 0;
 94.1425 -	sound4EnvelopeATLReload = 0;
 94.1426 -
 94.1427 -	sound1On = 0;
 94.1428 -	sound2On = 0;
 94.1429 -	sound3On = 0;
 94.1430 -	sound4On = 0;
 94.1431 -
 94.1432 -	int addr = 0x90;
 94.1433 -
 94.1434 -	while (addr < 0xA0)
 94.1435 -	{
 94.1436 -		ioMem[addr++] = 0x00;
 94.1437 -		ioMem[addr++] = 0xff;
 94.1438 -	}
 94.1439 -
 94.1440 -	addr = 0;
 94.1441 -	while (addr < 0x20)
 94.1442 -	{
 94.1443 -		sound3WaveRam[addr++] = 0x00;
 94.1444 -		sound3WaveRam[addr++] = 0xff;
 94.1445 -	}
 94.1446 -
 94.1447 -	memset(soundFinalWave, 0, soundBufferLen);
 94.1448 -
 94.1449 -	memset(soundFilter, 0, sizeof(soundFilter));
 94.1450 -	soundEchoIndex = 0;
 94.1451 -}
 94.1452 -
 94.1453 -bool soundInit()
 94.1454 -{
 94.1455 -	if (systemSoundInit())
 94.1456 -	{
 94.1457 -		memset(soundBuffer[0], 0, 735 * 2);
 94.1458 -		memset(soundBuffer[1], 0, 735 * 2);
 94.1459 -		memset(soundBuffer[2], 0, 735 * 2);
 94.1460 -		memset(soundBuffer[3], 0, 735 * 2);
 94.1461 -
 94.1462 -		memset(soundFinalWave, 0, soundBufferLen);
 94.1463 -
 94.1464 -		soundPaused = 1;
 94.1465 -		return true;
 94.1466 -	}
 94.1467 -	return false;
 94.1468 -}
 94.1469 -
 94.1470 -void soundSetQuality(int quality)
 94.1471 -{
 94.1472 -	if (soundQuality != quality && systemSoundCanChangeQuality())
 94.1473 -	{
 94.1474 -		if (!soundOffFlag)
 94.1475 -			soundShutdown();
 94.1476 -		soundQuality	  = quality;
 94.1477 -		soundNextPosition = 0;
 94.1478 -		if (!soundOffFlag)
 94.1479 -			soundInit();
 94.1480 -		SOUND_CLOCK_TICKS = USE_TICKS_AS * soundQuality;
 94.1481 -		soundIndex		  = 0;
 94.1482 -		soundBufferIndex  = 0;
 94.1483 -	}
 94.1484 -	else if (soundQuality != quality)
 94.1485 -	{
 94.1486 -		soundNextPosition = 0;
 94.1487 -		SOUND_CLOCK_TICKS = USE_TICKS_AS * soundQuality;
 94.1488 -		soundIndex		  = 0;
 94.1489 -		soundBufferIndex  = 0;
 94.1490 -	}
 94.1491 -}
 94.1492 -
 94.1493 -void soundSaveGame(gzFile gzFile)
 94.1494 -{
 94.1495 -	soundTicks_int32		= (int32) soundTicks;
 94.1496 -	SOUND_CLOCK_TICKS_int32 = (int32) SOUND_CLOCK_TICKS;
 94.1497 -	soundDSBValue_int32		= (int32) soundDSBValue;
 94.1498 -
 94.1499 -	utilWriteData(gzFile, soundSaveStruct);
 94.1500 -	utilWriteData(gzFile, soundSaveStructV2);
 94.1501 -
 94.1502 -	utilGzWrite(gzFile, &soundQuality, sizeof(int32));
 94.1503 -	//utilWriteData(gzFile, soundSaveStructV3);
 94.1504 -}
 94.1505 -
 94.1506 -void soundReadGame(gzFile gzFile, int version)
 94.1507 -{
 94.1508 -	int32 oldSoundPaused = soundPaused;
 94.1509 -	int32 oldSoundEnableFlag = soundEnableFlag;
 94.1510 -	utilReadData(gzFile, soundSaveStruct);
 94.1511 -	soundPaused = oldSoundPaused;
 94.1512 -	soundEnableFlag = oldSoundEnableFlag;
 94.1513 -
 94.1514 -	if (version >= SAVE_GAME_VERSION_3)
 94.1515 -	{
 94.1516 -		utilReadData(gzFile, soundSaveStructV2);
 94.1517 -	}
 94.1518 -	else
 94.1519 -	{
 94.1520 -		sound3Bank		   = (ioMem[NR30] >> 6) & 1;
 94.1521 -		sound3DataSize	   = (ioMem[NR30] >> 5) & 1;
 94.1522 -		sound3ForcedOutput = (ioMem[NR32] >> 7) & 1;
 94.1523 -		// nothing better to do here...
 94.1524 -		memcpy(&sound3WaveRam[0x00], &ioMem[0x90], 0x10);
 94.1525 -		memcpy(&sound3WaveRam[0x10], &ioMem[0x90], 0x10);
 94.1526 -	}
 94.1527 -	soundBufferIndex = soundIndex * 2;
 94.1528 -
 94.1529 -	int quality = 1;
 94.1530 -	utilGzRead(gzFile, &quality, sizeof(int32));
 94.1531 -	soundSetQuality(quality);
 94.1532 -
 94.1533 -	sound1Wave = soundWavePattern[ioMem[NR11] >> 6];
 94.1534 -	sound2Wave = soundWavePattern[ioMem[NR21] >> 6];
 94.1535 -
 94.1536 -	//if(version >= SAVE_GAME_VERSION_14) {
 94.1537 -	//  utilReadData(gzFile, soundSaveStructV3);
 94.1538 -	//}
 94.1539 -	//else {
 94.1540 -	soundTicks		  = (soundtick_t) soundTicks_int32;
 94.1541 -	SOUND_CLOCK_TICKS = (soundtick_t) SOUND_CLOCK_TICKS_int32;
 94.1542 -	//}
 94.1543 -	soundDSBValue = (u8) (soundDSBValue_int32 & 0xff);
 94.1544 -}
 94.1545 -
    95.1 --- a/src/gba/GBASound.h	Sat Mar 03 10:54:39 2012 -0600
    95.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.3 @@ -1,73 +0,0 @@
    95.4 -#ifndef VBA_GBA_SOUND_H
    95.5 -#define VBA_GBA_SOUND_H
    95.6 -
    95.7 -#if _MSC_VER > 1000
    95.8 -#pragma once
    95.9 -#endif // _MSC_VER > 1000
   95.10 -
   95.11 -#include "zlib.h"
   95.12 -#include "../Port.h"
   95.13 -
   95.14 -#define NR10 0x60
   95.15 -#define NR11 0x62
   95.16 -#define NR12 0x63
   95.17 -#define NR13 0x64
   95.18 -#define NR14 0x65
   95.19 -#define NR21 0x68
   95.20 -#define NR22 0x69
   95.21 -#define NR23 0x6c
   95.22 -#define NR24 0x6d
   95.23 -#define NR30 0x70
   95.24 -#define NR31 0x72
   95.25 -#define NR32 0x73
   95.26 -#define NR33 0x74
   95.27 -#define NR34 0x75
   95.28 -#define NR41 0x78
   95.29 -#define NR42 0x79
   95.30 -#define NR43 0x7c
   95.31 -#define NR44 0x7d
   95.32 -#define NR50 0x80
   95.33 -#define NR51 0x81
   95.34 -#define NR52 0x84
   95.35 -#define SGCNT0_H 0x82
   95.36 -#define FIFOA_L 0xa0
   95.37 -#define FIFOA_H 0xa2
   95.38 -#define FIFOB_L 0xa4
   95.39 -#define FIFOB_H 0xa6
   95.40 -
   95.41 -extern void soundTick();
   95.42 -extern void soundShutdown();
   95.43 -extern bool soundInit();
   95.44 -extern void soundPause();
   95.45 -extern void soundResume();
   95.46 -extern void soundEnableChannels(int);
   95.47 -extern void soundDisableChannels(int);
   95.48 -extern int  soundGetEnabledChannels();
   95.49 -extern void soundReset();
   95.50 -extern void soundSaveGame(gzFile);
   95.51 -extern void soundReadGame(gzFile, int);
   95.52 -extern void soundEvent(u32, u8);
   95.53 -extern void soundEvent(u32, u16);
   95.54 -extern void soundTimerOverflow(int);
   95.55 -extern void soundSetQuality(int);
   95.56 -
   95.57 -typedef int32 soundtick_t;
   95.58 -
   95.59 -extern soundtick_t SOUND_CLOCK_TICKS;
   95.60 -extern soundtick_t soundTicks;
   95.61 -extern int32       soundPaused;
   95.62 -extern bool8       soundOffFlag;
   95.63 -extern int32       soundQuality;
   95.64 -extern u32         soundBufferLen;
   95.65 -extern u32         soundBufferTotalLen;
   95.66 -extern u32         soundNextPosition;
   95.67 -extern u16         soundFinalWave[1470];
   95.68 -extern u16         soundFrameSound[735*30*2];
   95.69 -extern int32       soundFrameSoundWritten;
   95.70 -extern int32       soundVolume;
   95.71 -
   95.72 -extern bool8 soundEcho;
   95.73 -extern bool8 soundLowPass;
   95.74 -extern bool8 soundReverse;
   95.75 -
   95.76 -#endif // VBA_GBA_SOUND_H
    96.1 --- a/src/gba/GBAinline.h	Sat Mar 03 10:54:39 2012 -0600
    96.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.3 @@ -1,490 +0,0 @@
    96.4 -#ifndef VBA_GBAINLINE_H
    96.5 -#define VBA_GBAINLINE_H
    96.6 -
    96.7 -#if _MSC_VER > 1000
    96.8 -#pragma once
    96.9 -#endif // _MSC_VER > 1000
   96.10 -
   96.11 -#include "../Port.h"
   96.12 -#include "../common/System.h"
   96.13 -#include "../common/vbalua.h"
   96.14 -#include "GBAGlobals.h"
   96.15 -#include "EEprom.h"
   96.16 -#include "Flash.h"
   96.17 -#include "RTC.h"
   96.18 -
   96.19 -extern bool8 cpuSramEnabled;
   96.20 -extern bool8 cpuFlashEnabled;
   96.21 -extern bool8 cpuEEPROMEnabled;
   96.22 -extern bool8 cpuEEPROMSensorEnabled;
   96.23 -
   96.24 -#define CPUReadByteQuick(addr) \
   96.25 -    map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
   96.26 -
   96.27 -#define CPUReadHalfWordQuick(addr) \
   96.28 -    READ16LE(((u16 *)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
   96.29 -
   96.30 -#define CPUReadMemoryQuick(addr) \
   96.31 -    READ32LE(((u32 *)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
   96.32 -
   96.33 -//inline u32 CPUReadMemoryQuick(u32 addr)
   96.34 -//{
   96.35 -//	u32 addrShift = (addr)>>24;
   96.36 -//	u32 rt = (addr) & map[addrShift].mask;
   96.37 -//	return READ32LE(((u32*)&map[addrShift].address[rt]));
   96.38 -//}
   96.39 -
   96.40 -inline u32 CPUReadMemory(u32 address)
   96.41 -{
   96.42 -#ifdef GBA_LOGGING
   96.43 -	if (address & 3)
   96.44 -	{
   96.45 -		if (systemVerbose & VERBOSE_UNALIGNED_MEMORY)
   96.46 -		{
   96.47 -			log("Unaligned word read: %08x at %08x\n", address, armMode ?
   96.48 -			    armNextPC - 4 : armNextPC - 2);
   96.49 -		}
   96.50 -	}
   96.51 -#endif
   96.52 -
   96.53 -	u32 value;
   96.54 -	switch (address >> 24)
   96.55 -	{
   96.56 -	case 0:
   96.57 -		if (reg[15].I >> 24)
   96.58 -		{
   96.59 -			if (address < 0x4000)
   96.60 -			{
   96.61 -#ifdef GBA_LOGGING
   96.62 -				if (systemVerbose & VERBOSE_ILLEGAL_READ)
   96.63 -				{
   96.64 -					log("Illegal word read: %08x at %08x\n", address, armMode ?
   96.65 -					    armNextPC - 4 : armNextPC - 2);
   96.66 -				}
   96.67 -#endif
   96.68 -
   96.69 -				value = READ32LE(((u32 *)&biosProtected));
   96.70 -			}
   96.71 -			else
   96.72 -				goto unreadable;
   96.73 -		}
   96.74 -		else
   96.75 -			value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
   96.76 -		break;
   96.77 -	case 2:
   96.78 -		value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
   96.79 -		break;
   96.80 -	case 3:
   96.81 -		value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
   96.82 -		break;
   96.83 -	case 4:
   96.84 -		if ((address < 0x4000400) && ioReadable[address & 0x3fc])
   96.85 -		{
   96.86 -			if (ioReadable[(address & 0x3fc) + 2])
   96.87 -			{
   96.88 -				if (address >= 0x400012d && address <= 0x4000131)
   96.89 -					GBASystemCounters.lagged = false;
   96.90 -				value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
   96.91 -			}
   96.92 -			else
   96.93 -			{
   96.94 -				if (address >= 0x400012f && address <= 0x4000131)
   96.95 -					GBASystemCounters.lagged = false;
   96.96 -				value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
   96.97 -			}
   96.98 -		}
   96.99 -		else
  96.100 -			goto unreadable;
  96.101 -		break;
  96.102 -	case 5:
  96.103 -		value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
  96.104 -		break;
  96.105 -	case 6:
  96.106 -		value = READ32LE(((u32 *)&vram[address & 0x1fffc]));
  96.107 -		break;
  96.108 -	case 7:
  96.109 -		value = READ32LE(((u32 *)&oam[address & 0x3FC]));
  96.110 -		break;
  96.111 -	case 8:
  96.112 -	case 9:
  96.113 -	case 10:
  96.114 -	case 11:
  96.115 -	case 12:
  96.116 -		value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
  96.117 -		break;
  96.118 -	case 13:
  96.119 -		if (cpuEEPROMEnabled)
  96.120 -			// no need to swap this
  96.121 -			return eepromRead(address);
  96.122 -		goto unreadable;
  96.123 -	case 14:
  96.124 -		if (cpuFlashEnabled | cpuSramEnabled)
  96.125 -			// no need to swap this
  96.126 -			return flashRead(address);
  96.127 -	// default
  96.128 -	default:
  96.129 -unreadable:
  96.130 -#ifdef GBA_LOGGING
  96.131 -		if (systemVerbose & VERBOSE_ILLEGAL_READ)
  96.132 -		{
  96.133 -			log("Illegal word read: %08x at %08x\n", address, armMode ?
  96.134 -			    armNextPC - 4 : armNextPC - 2);
  96.135 -		}
  96.136 -#endif
  96.137 -
  96.138 -		//    if(ioMem[0x205] & 0x40) {
  96.139 -		if (armState)
  96.140 -		{
  96.141 -			value = CPUReadMemoryQuick(reg[15].I);
  96.142 -		}
  96.143 -		else
  96.144 -		{
  96.145 -			value = CPUReadHalfWordQuick(reg[15].I) |
  96.146 -			        CPUReadHalfWordQuick(reg[15].I) << 16;
  96.147 -		}
  96.148 -		//  } else {
  96.149 -		//      value = *((u32 *)&bios[address & 0x3ffc]);
  96.150 -		//    }
  96.151 -		//        return 0xFFFFFFFF;
  96.152 -	}
  96.153 -
  96.154 -	if (address & 3)
  96.155 -	{
  96.156 -#ifdef C_CORE
  96.157 -		int shift = (address & 3) << 3;
  96.158 -		value = (value >> shift) | (value << (32 - shift));
  96.159 -#else
  96.160 -#ifdef __GNUC__
  96.161 -		asm ("and $3, %%ecx;"
  96.162 -		     "shl $3 ,%%ecx;"
  96.163 -		     "ror %%cl, %0"
  96.164 -			 : "=r" (value)
  96.165 -			 : "r" (value), "c" (address));
  96.166 -#else
  96.167 -		__asm {
  96.168 -			mov ecx, address;
  96.169 -			and ecx, 3;
  96.170 -			shl ecx, 3;
  96.171 -			ror [dword ptr value], cl;
  96.172 -		}
  96.173 -#endif
  96.174 -#endif
  96.175 -	}
  96.176 -	return value;
  96.177 -}
  96.178 -
  96.179 -extern u32 myROM[];
  96.180 -
  96.181 -inline u32 CPUReadHalfWord(u32 address)
  96.182 -{
  96.183 -#ifdef GBA_LOGGING
  96.184 -	if (address & 1)
  96.185 -	{
  96.186 -		if (systemVerbose & VERBOSE_UNALIGNED_MEMORY)
  96.187 -		{
  96.188 -			log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
  96.189 -			    armNextPC - 4 : armNextPC - 2);
  96.190 -		}
  96.191 -	}
  96.192 -#endif
  96.193 -
  96.194 -	u32 value;
  96.195 -
  96.196 -	switch (address >> 24)
  96.197 -	{
  96.198 -	case 0:
  96.199 -		if (reg[15].I >> 24)
  96.200 -		{
  96.201 -			if (address < 0x4000)
  96.202 -			{
  96.203 -#ifdef GBA_LOGGING
  96.204 -				if (systemVerbose & VERBOSE_ILLEGAL_READ)
  96.205 -				{
  96.206 -					log("Illegal halfword read: %08x at %08x\n", address, armMode ?
  96.207 -					    armNextPC - 4 : armNextPC - 2);
  96.208 -				}
  96.209 -#endif
  96.210 -				value = READ16LE(((u16 *)&biosProtected[address&2]));
  96.211 -			}
  96.212 -			else
  96.213 -				goto unreadable;
  96.214 -		}
  96.215 -		else
  96.216 -			value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
  96.217 -		break;
  96.218 -	case 2:
  96.219 -		value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
  96.220 -		break;
  96.221 -	case 3:
  96.222 -		value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
  96.223 -		break;
  96.224 -	case 4:
  96.225 -		if ((address < 0x4000400) && ioReadable[address & 0x3fe])
  96.226 -		{
  96.227 -			if (address >= 0x400012f && address <= 0x4000131)
  96.228 -				GBASystemCounters.lagged = false;
  96.229 -			value =  READ16LE(((u16 *)&ioMem[address & 0x3fe]));
  96.230 -		}
  96.231 -		else
  96.232 -			goto unreadable;
  96.233 -		break;
  96.234 -	case 5:
  96.235 -		value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
  96.236 -		break;
  96.237 -	case 6:
  96.238 -		value = READ16LE(((u16 *)&vram[address & 0x1fffe]));
  96.239 -		break;
  96.240 -	case 7:
  96.241 -		value = READ16LE(((u16 *)&oam[address & 0x3fe]));
  96.242 -		break;
  96.243 -	case 8:
  96.244 -	case 9:
  96.245 -	case 10:
  96.246 -	case 11:
  96.247 -	case 12:
  96.248 -		if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
  96.249 -			value = rtcRead(address);
  96.250 -		else
  96.251 -			value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
  96.252 -		break;
  96.253 -	case 13:
  96.254 -		if (cpuEEPROMEnabled)
  96.255 -			// no need to swap this
  96.256 -			return eepromRead(address);
  96.257 -		goto unreadable;
  96.258 -	case 14:
  96.259 -		if (cpuFlashEnabled | cpuSramEnabled)
  96.260 -			// no need to swap this
  96.261 -			return flashRead(address);
  96.262 -	// default
  96.263 -	default:
  96.264 -unreadable:
  96.265 -#ifdef GBA_LOGGING
  96.266 -		if (systemVerbose & VERBOSE_ILLEGAL_READ)
  96.267 -		{
  96.268 -			log("Illegal halfword read: %08x at %08x\n", address, armMode ?
  96.269 -			    armNextPC - 4 : armNextPC - 2);
  96.270 -		}
  96.271 -#endif
  96.272 -		extern bool8 cpuDmaHack;
  96.273 -		extern u32   cpuDmaLast;
  96.274 -		extern int32 cpuDmaCount;
  96.275 -		if (cpuDmaHack && cpuDmaCount)
  96.276 -		{
  96.277 -			value = (u16)cpuDmaLast;
  96.278 -		}
  96.279 -		else
  96.280 -		{
  96.281 -			if (armState)
  96.282 -			{
  96.283 -				value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
  96.284 -			}
  96.285 -			else
  96.286 -			{
  96.287 -				value = CPUReadHalfWordQuick(reg[15].I);
  96.288 -			}
  96.289 -		}
  96.290 -		//    return value;
  96.291 -		//    if(address & 1)
  96.292 -		//      value = (value >> 8) | ((value & 0xFF) << 24);
  96.293 -		//    return 0xFFFF;
  96.294 -		break;
  96.295 -	}
  96.296 -
  96.297 -	if (address & 1)
  96.298 -	{
  96.299 -		value = (value >> 8) | (value << 24);
  96.300 -	}
  96.301 -
  96.302 -	return value;
  96.303 -}
  96.304 -
  96.305 -inline u16 CPUReadHalfWordSigned(u32 address)
  96.306 -{
  96.307 -	u16 value = CPUReadHalfWord(address);
  96.308 -	if ((address & 1))
  96.309 -		value = (s8)value;
  96.310 -	return value;
  96.311 -}
  96.312 -
  96.313 -inline u8 CPUReadByte(u32 address)
  96.314 -{
  96.315 -	switch (address >> 24)
  96.316 -	{
  96.317 -	case 0:
  96.318 -		if (reg[15].I >> 24)
  96.319 -		{
  96.320 -			if (address < 0x4000)
  96.321 -			{
  96.322 -#ifdef GBA_LOGGING
  96.323 -				if (systemVerbose & VERBOSE_ILLEGAL_READ)
  96.324 -				{
  96.325 -					log("Illegal byte read: %08x at %08x\n", address, armMode ?
  96.326 -					    armNextPC - 4 : armNextPC - 2);
  96.327 -				}
  96.328 -#endif
  96.329 -				return biosProtected[address & 3];
  96.330 -			}
  96.331 -			else
  96.332 -				goto unreadable;
  96.333 -		}
  96.334 -		return bios[address & 0x3FFF];
  96.335 -	case 2:
  96.336 -		return workRAM[address & 0x3FFFF];
  96.337 -	case 3:
  96.338 -		return internalRAM[address & 0x7fff];
  96.339 -	case 4:
  96.340 -		if ((address < 0x4000400) && ioReadable[address & 0x3ff])
  96.341 -		{
  96.342 -			if (address == 0x4000130 || address == 0x4000131)
  96.343 -				GBASystemCounters.lagged = false;
  96.344 -			return ioMem[address & 0x3ff];
  96.345 -		}
  96.346 -		else
  96.347 -			goto unreadable;
  96.348 -	case 5:
  96.349 -		return paletteRAM[address & 0x3ff];
  96.350 -	case 6:
  96.351 -		return vram[address & 0x1ffff];
  96.352 -	case 7:
  96.353 -		return oam[address & 0x3ff];
  96.354 -	case 8:
  96.355 -	case 9:
  96.356 -	case 10:
  96.357 -	case 11:
  96.358 -	case 12:
  96.359 -		return rom[address & 0x1FFFFFF];
  96.360 -	case 13:
  96.361 -		if (cpuEEPROMEnabled)
  96.362 -			return eepromRead(address);
  96.363 -		goto unreadable;
  96.364 -	case 14:
  96.365 -		if (cpuSramEnabled | cpuFlashEnabled)
  96.366 -			return flashRead(address);
  96.367 -		if (cpuEEPROMSensorEnabled)
  96.368 -		{
  96.369 -			switch (address & 0x00008f00)
  96.370 -			{
  96.371 -			case 0x8200:
  96.372 -				return systemGetSensorX() & 255;
  96.373 -			case 0x8300:
  96.374 -				return (systemGetSensorX() >> 8)|0x80;
  96.375 -			case 0x8400:
  96.376 -				return systemGetSensorY() & 255;
  96.377 -			case 0x8500:
  96.378 -				return systemGetSensorY() >> 8;
  96.379 -			}
  96.380 -		}
  96.381 -	// default
  96.382 -	default:
  96.383 -unreadable:
  96.384 -#ifdef GBA_LOGGING
  96.385 -		if (systemVerbose & VERBOSE_ILLEGAL_READ)
  96.386 -		{
  96.387 -			log("Illegal byte read: %08x at %08x\n", address, armMode ?
  96.388 -			    armNextPC - 4 : armNextPC - 2);
  96.389 -		}
  96.390 -#endif
  96.391 -
  96.392 -		if (armState)
  96.393 -		{
  96.394 -			return CPUReadByteQuick(reg[15].I+(address & 3));
  96.395 -		}
  96.396 -		else
  96.397 -		{
  96.398 -			return CPUReadByteQuick(reg[15].I+(address & 1));
  96.399 -		}
  96.400 -		//    return 0xFF;
  96.401 -		break;
  96.402 -	}
  96.403 -}
  96.404 -
  96.405 -inline void CPUWriteMemoryWrapped(u32 address, u32 value)
  96.406 -{
  96.407 -#ifdef GBA_LOGGING
  96.408 -	if (address & 3)
  96.409 -	{
  96.410 -		if (systemVerbose & VERBOSE_UNALIGNED_MEMORY)
  96.411 -		{
  96.412 -			log("Unaliagned word write: %08x to %08x from %08x\n",
  96.413 -			    value,
  96.414 -			    address,
  96.415 -			    armMode ? armNextPC - 4 : armNextPC - 2);
  96.416 -		}
  96.417 -	}
  96.418 -#endif
  96.419 -
  96.420 -	switch (address >> 24)
  96.421 -	{
  96.422 -	case 0x02:
  96.423 -#ifdef SDL
  96.424 -		if (*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
  96.425 -			cheatsWriteMemory((u32 *)&workRAM[address & 0x3FFFC],
  96.426 -			                  value,
  96.427 -			                  *((u32 *)&freezeWorkRAM[address & 0x3FFFC]));
  96.428 -		else
  96.429 -#endif
  96.430 -		WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
  96.431 -		break;
  96.432 -	case 0x03:
  96.433 -#ifdef SDL
  96.434 -		if (*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
  96.435 -			cheatsWriteMemory((u32 *)&internalRAM[address & 0x7FFC],
  96.436 -			                  value,
  96.437 -			                  *((u32 *)&freezeInternalRAM[address & 0x7ffc]));
  96.438 -		else
  96.439 -#endif
  96.440 -		WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
  96.441 -		break;
  96.442 -	case 0x04:
  96.443 -		CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
  96.444 -		CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
  96.445 -		break;
  96.446 -	case 0x05:
  96.447 -		WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
  96.448 -		break;
  96.449 -	case 0x06:
  96.450 -		if (address & 0x10000)
  96.451 -			WRITE32LE(((u32 *)&vram[address & 0x17ffc]), value);
  96.452 -		else
  96.453 -			WRITE32LE(((u32 *)&vram[address & 0x1fffc]), value);
  96.454 -		break;
  96.455 -	case 0x07:
  96.456 -		WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
  96.457 -		break;
  96.458 -	case 0x0D:
  96.459 -		if (cpuEEPROMEnabled)
  96.460 -		{
  96.461 -			eepromWrite(address, value);
  96.462 -			break;
  96.463 -		}
  96.464 -		goto unwritable;
  96.465 -	case 0x0E:
  96.466 -		if (!eepromInUse | cpuSramEnabled | cpuFlashEnabled)
  96.467 -		{
  96.468 -			(*cpuSaveGameFunc)(address, (u8)value);
  96.469 -			break;
  96.470 -		}
  96.471 -	// default
  96.472 -	default:
  96.473 -unwritable:
  96.474 -#ifdef GBA_LOGGING
  96.475 -		if (systemVerbose & VERBOSE_ILLEGAL_WRITE)
  96.476 -		{
  96.477 -			log("Illegal word write: %08x to %08x from %08x\n",
  96.478 -			    value,
  96.479 -			    address,
  96.480 -			    armMode ? armNextPC - 4 : armNextPC - 2);
  96.481 -		}
  96.482 -#endif
  96.483 -		break;
  96.484 -	}
  96.485 -}
  96.486 -
  96.487 -inline void CPUWriteMemory(u32 address, u32 value)
  96.488 -{
  96.489 -	CPUWriteMemoryWrapped(address, value);
  96.490 -	CallRegisteredLuaMemHook(address, 4, value, LUAMEMHOOK_WRITE);
  96.491 -}
  96.492 -
  96.493 -#endif // VBA_GBAINLINE_H
    97.1 --- a/src/gba/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
    97.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.3 @@ -1,46 +0,0 @@
    97.4 -noinst_LIBRARIES = libgba.a
    97.5 -
    97.6 -libgba_a_SOURCES = \
    97.7 -	agbprint.cpp		\
    97.8 -	agbprint.h		\
    97.9 -	arm-new.h		\
   97.10 -	armdis.cpp		\
   97.11 -	armdis.h		\
   97.12 -	bios.cpp		\
   97.13 -	bios.h			\
   97.14 -	elf.cpp			\
   97.15 -	elf.h			\
   97.16 -	Cheats.cpp		\
   97.17 -	Cheats.h		\
   97.18 -	EEprom.cpp		\
   97.19 -	EEprom.h		\
   97.20 -	Flash.cpp		\
   97.21 -	Flash.h			\
   97.22 -	GBA.cpp			\
   97.23 -	GBA.h			\
   97.24 -	GBAinline.h		\
   97.25 -	GBAGfx.cpp		\
   97.26 -	GBAGfx.h		\
   97.27 -	Globals.cpp		\
   97.28 -	Globals.h		\
   97.29 -	Mode0.cpp		\
   97.30 -	Mode1.cpp		\
   97.31 -	Mode2.cpp		\
   97.32 -	Mode3.cpp		\
   97.33 -	Mode4.cpp		\
   97.34 -	Mode5.cpp		\
   97.35 -	remote.cpp		\
   97.36 -	RTC.cpp			\
   97.37 -	RTC.h			\
   97.38 -	Sound.cpp		\
   97.39 -	Sound.h			\
   97.40 -	Sram.cpp		\
   97.41 -	Sram.h			\
   97.42 -	thumb.h
   97.43 -
   97.44 -AM_CPPFLAGS = \
   97.45 -	-I$(top_srcdir)/src		\
   97.46 -	-DSDL				\
   97.47 -	-DSYSCONFDIR=\"$(sysconfdir)\"
   97.48 -
   97.49 -AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@
    98.1 --- a/src/gba/Mode0.cpp	Sat Mar 03 10:54:39 2012 -0600
    98.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.3 @@ -1,633 +0,0 @@
    98.4 -#include "GBAGfx.h"
    98.5 -#include "GBAGlobals.h"
    98.6 -
    98.7 -void mode0RenderLine()
    98.8 -{
    98.9 -	u16 *palette = (u16 *)paletteRAM;
   98.10 -
   98.11 -	if (DISPCNT & 0x80)
   98.12 -	{
   98.13 -		for (int x = 0; x < 240; x++)
   98.14 -		{
   98.15 -			lineMix[x] = 0x7fff;
   98.16 -		}
   98.17 -		return;
   98.18 -	}
   98.19 -
   98.20 -	if (layerEnable & 0x0100)
   98.21 -	{
   98.22 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
   98.23 -	}
   98.24 -
   98.25 -	if (layerEnable & 0x0200)
   98.26 -	{
   98.27 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
   98.28 -	}
   98.29 -
   98.30 -	if (layerEnable & 0x0400)
   98.31 -	{
   98.32 -		gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
   98.33 -	}
   98.34 -
   98.35 -	if (layerEnable & 0x0800)
   98.36 -	{
   98.37 -		gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
   98.38 -	}
   98.39 -
   98.40 -	gfxDrawSprites(lineOBJ);
   98.41 -
   98.42 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
   98.43 -
   98.44 -	for (int x = 0; x < 240; x++)
   98.45 -	{
   98.46 -		u32 color = backdrop;
   98.47 -		u8  top   = 0x20;
   98.48 -
   98.49 -		if (line0[x] < color)
   98.50 -		{
   98.51 -			color = line0[x];
   98.52 -			top   = 0x01;
   98.53 -		}
   98.54 -
   98.55 -		if ((u8)(line1[x]>>24) < (u8)(color >> 24))
   98.56 -		{
   98.57 -			color = line1[x];
   98.58 -			top   = 0x02;
   98.59 -		}
   98.60 -
   98.61 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24))
   98.62 -		{
   98.63 -			color = line2[x];
   98.64 -			top   = 0x04;
   98.65 -		}
   98.66 -
   98.67 -		if ((u8)(line3[x]>>24) < (u8)(color >> 24))
   98.68 -		{
   98.69 -			color = line3[x];
   98.70 -			top   = 0x08;
   98.71 -		}
   98.72 -
   98.73 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
   98.74 -		{
   98.75 -			color = lineOBJ[x];
   98.76 -			top   = 0x10;
   98.77 -		}
   98.78 -
   98.79 -		if ((top & 0x10) && (color & 0x00010000))
   98.80 -		{
   98.81 -			// semi-transparent OBJ
   98.82 -			u32 back = backdrop;
   98.83 -			u8  top2 = 0x20;
   98.84 -
   98.85 -			if ((u8)(line0[x]>>24) < (u8)(back >> 24))
   98.86 -			{
   98.87 -				back = line0[x];
   98.88 -				top2 = 0x01;
   98.89 -			}
   98.90 -
   98.91 -			if ((u8)(line1[x]>>24) < (u8)(back >> 24))
   98.92 -			{
   98.93 -				back = line1[x];
   98.94 -				top2 = 0x02;
   98.95 -			}
   98.96 -
   98.97 -			if ((u8)(line2[x]>>24) < (u8)(back >> 24))
   98.98 -			{
   98.99 -				back = line2[x];
  98.100 -				top2 = 0x04;
  98.101 -			}
  98.102 -
  98.103 -			if ((u8)(line3[x]>>24) < (u8)(back >> 24))
  98.104 -			{
  98.105 -				back = line3[x];
  98.106 -				top2 = 0x08;
  98.107 -			}
  98.108 -
  98.109 -			if (top2 & (BLDMOD>>8))
  98.110 -				color = gfxAlphaBlend(color, back,
  98.111 -				                      coeff[COLEV & 0x1F],
  98.112 -				                      coeff[(COLEV >> 8) & 0x1F]);
  98.113 -			else
  98.114 -			{
  98.115 -				switch ((BLDMOD >> 6) & 3)
  98.116 -				{
  98.117 -				case 2:
  98.118 -					if (BLDMOD & top)
  98.119 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.120 -					break;
  98.121 -				case 3:
  98.122 -					if (BLDMOD & top)
  98.123 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.124 -					break;
  98.125 -				}
  98.126 -			}
  98.127 -		}
  98.128 -
  98.129 -		lineMix[x] = color;
  98.130 -	}
  98.131 -}
  98.132 -
  98.133 -void mode0RenderLineNoWindow()
  98.134 -{
  98.135 -	u16 *palette = (u16 *)paletteRAM;
  98.136 -
  98.137 -	if (DISPCNT & 0x80)
  98.138 -	{
  98.139 -		for (int x = 0; x < 240; x++)
  98.140 -		{
  98.141 -			lineMix[x] = 0x7fff;
  98.142 -		}
  98.143 -		return;
  98.144 -	}
  98.145 -
  98.146 -	if (layerEnable & 0x0100)
  98.147 -	{
  98.148 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
  98.149 -	}
  98.150 -
  98.151 -	if (layerEnable & 0x0200)
  98.152 -	{
  98.153 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
  98.154 -	}
  98.155 -
  98.156 -	if (layerEnable & 0x0400)
  98.157 -	{
  98.158 -		gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
  98.159 -	}
  98.160 -
  98.161 -	if (layerEnable & 0x0800)
  98.162 -	{
  98.163 -		gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
  98.164 -	}
  98.165 -
  98.166 -	gfxDrawSprites(lineOBJ);
  98.167 -
  98.168 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  98.169 -
  98.170 -	int effect = (BLDMOD >> 6) & 3;
  98.171 -
  98.172 -	for (int x = 0; x < 240; x++)
  98.173 -	{
  98.174 -		u32 color = backdrop;
  98.175 -		u8  top   = 0x20;
  98.176 -
  98.177 -		if (line0[x] < color)
  98.178 -		{
  98.179 -			color = line0[x];
  98.180 -			top   = 0x01;
  98.181 -		}
  98.182 -
  98.183 -		if (line1[x] < (color & 0xFF000000))
  98.184 -		{
  98.185 -			color = line1[x];
  98.186 -			top   = 0x02;
  98.187 -		}
  98.188 -
  98.189 -		if (line2[x] < (color & 0xFF000000))
  98.190 -		{
  98.191 -			color = line2[x];
  98.192 -			top   = 0x04;
  98.193 -		}
  98.194 -
  98.195 -		if (line3[x] < (color & 0xFF000000))
  98.196 -		{
  98.197 -			color = line3[x];
  98.198 -			top   = 0x08;
  98.199 -		}
  98.200 -
  98.201 -		if (lineOBJ[x] < (color & 0xFF000000))
  98.202 -		{
  98.203 -			color = lineOBJ[x];
  98.204 -			top   = 0x10;
  98.205 -		}
  98.206 -
  98.207 -		if (!(color & 0x00010000))
  98.208 -		{
  98.209 -			switch (effect)
  98.210 -			{
  98.211 -			case 0:
  98.212 -				break;
  98.213 -			case 1:
  98.214 -			{
  98.215 -				if (top & BLDMOD)
  98.216 -				{
  98.217 -					u32 back = backdrop;
  98.218 -					u8  top2 = 0x20;
  98.219 -					if (line0[x] < back)
  98.220 -					{
  98.221 -						if (top != 0x01)
  98.222 -						{
  98.223 -							back = line0[x];
  98.224 -							top2 = 0x01;
  98.225 -						}
  98.226 -					}
  98.227 -
  98.228 -					if (line1[x] < (back & 0xFF000000))
  98.229 -					{
  98.230 -						if (top != 0x02)
  98.231 -						{
  98.232 -							back = line1[x];
  98.233 -							top2 = 0x02;
  98.234 -						}
  98.235 -					}
  98.236 -
  98.237 -					if (line2[x] < (back & 0xFF000000))
  98.238 -					{
  98.239 -						if (top != 0x04)
  98.240 -						{
  98.241 -							back = line2[x];
  98.242 -							top2 = 0x04;
  98.243 -						}
  98.244 -					}
  98.245 -
  98.246 -					if (line3[x] < (back & 0xFF000000))
  98.247 -					{
  98.248 -						if (top != 0x08)
  98.249 -						{
  98.250 -							back = line3[x];
  98.251 -							top2 = 0x08;
  98.252 -						}
  98.253 -					}
  98.254 -
  98.255 -					if (lineOBJ[x] < (back & 0xFF000000))
  98.256 -					{
  98.257 -						if (top != 0x10)
  98.258 -						{
  98.259 -							back = lineOBJ[x];
  98.260 -							top2 = 0x10;
  98.261 -						}
  98.262 -					}
  98.263 -
  98.264 -					if (top2 & (BLDMOD>>8))
  98.265 -						color = gfxAlphaBlend(color, back,
  98.266 -						                      coeff[COLEV & 0x1F],
  98.267 -						                      coeff[(COLEV >> 8) & 0x1F]);
  98.268 -				}
  98.269 -				break;
  98.270 -			}
  98.271 -			case 2:
  98.272 -				if (BLDMOD & top)
  98.273 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.274 -				break;
  98.275 -			case 3:
  98.276 -				if (BLDMOD & top)
  98.277 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.278 -				break;
  98.279 -			}
  98.280 -		}
  98.281 -		else
  98.282 -		{
  98.283 -			// semi-transparent OBJ
  98.284 -			u32 back = backdrop;
  98.285 -			u8  top2 = 0x20;
  98.286 -
  98.287 -			if (line0[x] < back)
  98.288 -			{
  98.289 -				back = line0[x];
  98.290 -				top2 = 0x01;
  98.291 -			}
  98.292 -
  98.293 -			if (line1[x] < (back & 0xFF000000))
  98.294 -			{
  98.295 -				back = line1[x];
  98.296 -				top2 = 0x02;
  98.297 -			}
  98.298 -
  98.299 -			if (line2[x] < (back & 0xFF000000))
  98.300 -			{
  98.301 -				back = line2[x];
  98.302 -				top2 = 0x04;
  98.303 -			}
  98.304 -
  98.305 -			if (line3[x] < (back & 0xFF000000))
  98.306 -			{
  98.307 -				back = line3[x];
  98.308 -				top2 = 0x08;
  98.309 -			}
  98.310 -
  98.311 -			if (top2 & (BLDMOD>>8))
  98.312 -				color = gfxAlphaBlend(color, back,
  98.313 -				                      coeff[COLEV & 0x1F],
  98.314 -				                      coeff[(COLEV >> 8) & 0x1F]);
  98.315 -			else
  98.316 -			{
  98.317 -				switch ((BLDMOD >> 6) & 3)
  98.318 -				{
  98.319 -				case 2:
  98.320 -					if (BLDMOD & top)
  98.321 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.322 -					break;
  98.323 -				case 3:
  98.324 -					if (BLDMOD & top)
  98.325 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.326 -					break;
  98.327 -				}
  98.328 -			}
  98.329 -		}
  98.330 -
  98.331 -		lineMix[x] = color;
  98.332 -	}
  98.333 -}
  98.334 -
  98.335 -void mode0RenderLineAll()
  98.336 -{
  98.337 -	u16 *palette = (u16 *)paletteRAM;
  98.338 -
  98.339 -	if (DISPCNT & 0x80)
  98.340 -	{
  98.341 -		for (int x = 0; x < 240; x++)
  98.342 -		{
  98.343 -			lineMix[x] = 0x7fff;
  98.344 -		}
  98.345 -		return;
  98.346 -	}
  98.347 -
  98.348 -	bool inWindow0 = false;
  98.349 -	bool inWindow1 = false;
  98.350 -
  98.351 -	if (layerEnable & 0x2000)
  98.352 -	{
  98.353 -		u8 v0 = WIN0V >> 8;
  98.354 -		u8 v1 = WIN0V & 255;
  98.355 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
  98.356 -		if (v1 >= v0)
  98.357 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
  98.358 -		else
  98.359 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
  98.360 -	}
  98.361 -	if (layerEnable & 0x4000)
  98.362 -	{
  98.363 -		u8 v0 = WIN1V >> 8;
  98.364 -		u8 v1 = WIN1V & 255;
  98.365 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
  98.366 -		if (v1 >= v0)
  98.367 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
  98.368 -		else
  98.369 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
  98.370 -	}
  98.371 -
  98.372 -	if ((layerEnable & 0x0100))
  98.373 -	{
  98.374 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
  98.375 -	}
  98.376 -
  98.377 -	if ((layerEnable & 0x0200))
  98.378 -	{
  98.379 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
  98.380 -	}
  98.381 -
  98.382 -	if ((layerEnable & 0x0400))
  98.383 -	{
  98.384 -		gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
  98.385 -	}
  98.386 -
  98.387 -	if ((layerEnable & 0x0800))
  98.388 -	{
  98.389 -		gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
  98.390 -	}
  98.391 -
  98.392 -	gfxDrawSprites(lineOBJ);
  98.393 -	gfxDrawOBJWin(lineOBJWin);
  98.394 -
  98.395 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  98.396 -
  98.397 -	u8 inWin0Mask = WININ & 0xFF;
  98.398 -	u8 inWin1Mask = WININ >> 8;
  98.399 -	u8 outMask    = WINOUT & 0xFF;
  98.400 -
  98.401 -	for (int x = 0; x < 240; x++)
  98.402 -	{
  98.403 -		u32 color = backdrop;
  98.404 -		u8  top   = 0x20;
  98.405 -		u8  mask  = outMask;
  98.406 -
  98.407 -		if (!(lineOBJWin[x] & 0x80000000))
  98.408 -		{
  98.409 -			mask = WINOUT >> 8;
  98.410 -		}
  98.411 -
  98.412 -		if (inWindow1)
  98.413 -		{
  98.414 -			if (gfxInWin1[x])
  98.415 -				mask = inWin1Mask;
  98.416 -		}
  98.417 -
  98.418 -		if (inWindow0)
  98.419 -		{
  98.420 -			if (gfxInWin0[x])
  98.421 -			{
  98.422 -				mask = inWin0Mask;
  98.423 -			}
  98.424 -		}
  98.425 -
  98.426 -		if ((mask & 1) && (line0[x] < color))
  98.427 -		{
  98.428 -			color = line0[x];
  98.429 -			top   = 0x01;
  98.430 -		}
  98.431 -
  98.432 -		if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24)))
  98.433 -		{
  98.434 -			color = line1[x];
  98.435 -			top   = 0x02;
  98.436 -		}
  98.437 -
  98.438 -		if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24)))
  98.439 -		{
  98.440 -			color = line2[x];
  98.441 -			top   = 0x04;
  98.442 -		}
  98.443 -
  98.444 -		if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24)))
  98.445 -		{
  98.446 -			color = line3[x];
  98.447 -			top   = 0x08;
  98.448 -		}
  98.449 -
  98.450 -		if ((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)))
  98.451 -		{
  98.452 -			color = lineOBJ[x];
  98.453 -			top   = 0x10;
  98.454 -		}
  98.455 -
  98.456 -		// special FX on in the window
  98.457 -		if (mask & 32)
  98.458 -		{
  98.459 -			if (!(color & 0x00010000))
  98.460 -			{
  98.461 -				switch ((BLDMOD >> 6) & 3)
  98.462 -				{
  98.463 -				case 0:
  98.464 -					break;
  98.465 -				case 1:
  98.466 -				{
  98.467 -					if (top & BLDMOD)
  98.468 -					{
  98.469 -						u32 back = backdrop;
  98.470 -						u8  top2 = 0x20;
  98.471 -						if ((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24))
  98.472 -						{
  98.473 -							if (top != 0x01)
  98.474 -							{
  98.475 -								back = line0[x];
  98.476 -								top2 = 0x01;
  98.477 -							}
  98.478 -						}
  98.479 -
  98.480 -						if ((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24))
  98.481 -						{
  98.482 -							if (top != 0x02)
  98.483 -							{
  98.484 -								back = line1[x];
  98.485 -								top2 = 0x02;
  98.486 -							}
  98.487 -						}
  98.488 -
  98.489 -						if ((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24))
  98.490 -						{
  98.491 -							if (top != 0x04)
  98.492 -							{
  98.493 -								back = line2[x];
  98.494 -								top2 = 0x04;
  98.495 -							}
  98.496 -						}
  98.497 -
  98.498 -						if ((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24))
  98.499 -						{
  98.500 -							if (top != 0x08)
  98.501 -							{
  98.502 -								back = line3[x];
  98.503 -								top2 = 0x08;
  98.504 -							}
  98.505 -						}
  98.506 -
  98.507 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
  98.508 -						{
  98.509 -							if (top != 0x10)
  98.510 -							{
  98.511 -								back = lineOBJ[x];
  98.512 -								top2 = 0x10;
  98.513 -							}
  98.514 -						}
  98.515 -
  98.516 -						if (top2 & (BLDMOD>>8))
  98.517 -							color = gfxAlphaBlend(color, back,
  98.518 -							                      coeff[COLEV & 0x1F],
  98.519 -							                      coeff[(COLEV >> 8) & 0x1F]);
  98.520 -					}
  98.521 -					break;
  98.522 -				}
  98.523 -				case 2:
  98.524 -					if (BLDMOD & top)
  98.525 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.526 -					break;
  98.527 -				case 3:
  98.528 -					if (BLDMOD & top)
  98.529 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.530 -					break;
  98.531 -				}
  98.532 -			}
  98.533 -			else
  98.534 -			{
  98.535 -				// semi-transparent OBJ
  98.536 -				u32 back = backdrop;
  98.537 -				u8  top2 = 0x20;
  98.538 -
  98.539 -				if ((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24)))
  98.540 -				{
  98.541 -					back = line0[x];
  98.542 -					top2 = 0x01;
  98.543 -				}
  98.544 -
  98.545 -				if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24)))
  98.546 -				{
  98.547 -					back = line1[x];
  98.548 -					top2 = 0x02;
  98.549 -				}
  98.550 -
  98.551 -				if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24)))
  98.552 -				{
  98.553 -					back = line2[x];
  98.554 -					top2 = 0x04;
  98.555 -				}
  98.556 -
  98.557 -				if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24)))
  98.558 -				{
  98.559 -					back = line3[x];
  98.560 -					top2 = 0x08;
  98.561 -				}
  98.562 -
  98.563 -				if (top2 & (BLDMOD>>8))
  98.564 -					color = gfxAlphaBlend(color, back,
  98.565 -					                      coeff[COLEV & 0x1F],
  98.566 -					                      coeff[(COLEV >> 8) & 0x1F]);
  98.567 -				else
  98.568 -				{
  98.569 -					switch ((BLDMOD >> 6) & 3)
  98.570 -					{
  98.571 -					case 2:
  98.572 -						if (BLDMOD & top)
  98.573 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.574 -						break;
  98.575 -					case 3:
  98.576 -						if (BLDMOD & top)
  98.577 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.578 -						break;
  98.579 -					}
  98.580 -				}
  98.581 -			}
  98.582 -		}
  98.583 -		else if (color & 0x00010000)
  98.584 -		{
  98.585 -			// semi-transparent OBJ
  98.586 -			u32 back = backdrop;
  98.587 -			u8  top2 = 0x20;
  98.588 -
  98.589 -			if ((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24)))
  98.590 -			{
  98.591 -				back = line0[x];
  98.592 -				top2 = 0x01;
  98.593 -			}
  98.594 -
  98.595 -			if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24)))
  98.596 -			{
  98.597 -				back = line1[x];
  98.598 -				top2 = 0x02;
  98.599 -			}
  98.600 -
  98.601 -			if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24)))
  98.602 -			{
  98.603 -				back = line2[x];
  98.604 -				top2 = 0x04;
  98.605 -			}
  98.606 -
  98.607 -			if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24)))
  98.608 -			{
  98.609 -				back = line3[x];
  98.610 -				top2 = 0x08;
  98.611 -			}
  98.612 -
  98.613 -			if (top2 & (BLDMOD>>8))
  98.614 -				color = gfxAlphaBlend(color, back,
  98.615 -				                      coeff[COLEV & 0x1F],
  98.616 -				                      coeff[(COLEV >> 8) & 0x1F]);
  98.617 -			else
  98.618 -			{
  98.619 -				switch ((BLDMOD >> 6) & 3)
  98.620 -				{
  98.621 -				case 2:
  98.622 -					if (BLDMOD & top)
  98.623 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  98.624 -					break;
  98.625 -				case 3:
  98.626 -					if (BLDMOD & top)
  98.627 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  98.628 -					break;
  98.629 -				}
  98.630 -			}
  98.631 -		}
  98.632 -
  98.633 -		lineMix[x] = color;
  98.634 -	}
  98.635 -}
  98.636 -
    99.1 --- a/src/gba/Mode1.cpp	Sat Mar 03 10:54:39 2012 -0600
    99.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.3 @@ -1,580 +0,0 @@
    99.4 -#include "GBAGfx.h"
    99.5 -#include "GBAGlobals.h"
    99.6 -
    99.7 -void mode1RenderLine()
    99.8 -{
    99.9 -	u16 *palette = (u16 *)paletteRAM;
   99.10 -
   99.11 -	if (DISPCNT & 0x80)
   99.12 -	{
   99.13 -		for (int x = 0; x < 240; x++)
   99.14 -		{
   99.15 -			lineMix[x] = 0x7fff;
   99.16 -		}
   99.17 -		gfxLastVCOUNT = VCOUNT;
   99.18 -		return;
   99.19 -	}
   99.20 -
   99.21 -	if (layerEnable & 0x0100)
   99.22 -	{
   99.23 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
   99.24 -	}
   99.25 -
   99.26 -	if (layerEnable & 0x0200)
   99.27 -	{
   99.28 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
   99.29 -	}
   99.30 -
   99.31 -	if (layerEnable & 0x0400)
   99.32 -	{
   99.33 -		int changed = gfxBG2Changed;
   99.34 -		if (gfxLastVCOUNT > VCOUNT)
   99.35 -			changed = 3;
   99.36 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
   99.37 -		                 BG2PA, BG2PB, BG2PC, BG2PD,
   99.38 -		                 gfxBG2X, gfxBG2Y, changed, line2);
   99.39 -	}
   99.40 -
   99.41 -	gfxDrawSprites(lineOBJ);
   99.42 -
   99.43 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
   99.44 -
   99.45 -	for (int x = 0; x < 240; x++)
   99.46 -	{
   99.47 -		u32 color = backdrop;
   99.48 -		u8  top   = 0x20;
   99.49 -
   99.50 -		if (line0[x] < color)
   99.51 -		{
   99.52 -			color = line0[x];
   99.53 -			top   = 0x01;
   99.54 -		}
   99.55 -
   99.56 -		if ((u8)(line1[x]>>24) < (u8)(color >> 24))
   99.57 -		{
   99.58 -			color = line1[x];
   99.59 -			top   = 0x02;
   99.60 -		}
   99.61 -
   99.62 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24))
   99.63 -		{
   99.64 -			color = line2[x];
   99.65 -			top   = 0x04;
   99.66 -		}
   99.67 -
   99.68 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
   99.69 -		{
   99.70 -			color = lineOBJ[x];
   99.71 -			top   = 0x10;
   99.72 -		}
   99.73 -
   99.74 -		if ((top & 0x10) && (color & 0x00010000))
   99.75 -		{
   99.76 -			// semi-transparent OBJ
   99.77 -			u32 back = backdrop;
   99.78 -			u8  top2 = 0x20;
   99.79 -
   99.80 -			if ((u8)(line0[x]>>24) < (u8)(back >> 24))
   99.81 -			{
   99.82 -				back = line0[x];
   99.83 -				top2 = 0x01;
   99.84 -			}
   99.85 -
   99.86 -			if ((u8)(line1[x]>>24) < (u8)(back >> 24))
   99.87 -			{
   99.88 -				back = line1[x];
   99.89 -				top2 = 0x02;
   99.90 -			}
   99.91 -
   99.92 -			if ((u8)(line2[x]>>24) < (u8)(back >> 24))
   99.93 -			{
   99.94 -				back = line2[x];
   99.95 -				top2 = 0x04;
   99.96 -			}
   99.97 -
   99.98 -			if (top2 & (BLDMOD>>8))
   99.99 -				color = gfxAlphaBlend(color, back,
  99.100 -				                      coeff[COLEV & 0x1F],
  99.101 -				                      coeff[(COLEV >> 8) & 0x1F]);
  99.102 -			else
  99.103 -			{
  99.104 -				switch ((BLDMOD >> 6) & 3)
  99.105 -				{
  99.106 -				case 2:
  99.107 -					if (BLDMOD & top)
  99.108 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.109 -					break;
  99.110 -				case 3:
  99.111 -					if (BLDMOD & top)
  99.112 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.113 -					break;
  99.114 -				}
  99.115 -			}
  99.116 -		}
  99.117 -
  99.118 -		lineMix[x] = color;
  99.119 -	}
  99.120 -	gfxBG2Changed = 0;
  99.121 -	gfxLastVCOUNT = VCOUNT;
  99.122 -}
  99.123 -
  99.124 -void mode1RenderLineNoWindow()
  99.125 -{
  99.126 -	u16 *palette = (u16 *)paletteRAM;
  99.127 -
  99.128 -	if (DISPCNT & 0x80)
  99.129 -	{
  99.130 -		for (int x = 0; x < 240; x++)
  99.131 -		{
  99.132 -			lineMix[x] = 0x7fff;
  99.133 -		}
  99.134 -		gfxLastVCOUNT = VCOUNT;
  99.135 -		return;
  99.136 -	}
  99.137 -
  99.138 -	if (layerEnable & 0x0100)
  99.139 -	{
  99.140 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
  99.141 -	}
  99.142 -
  99.143 -	if (layerEnable & 0x0200)
  99.144 -	{
  99.145 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
  99.146 -	}
  99.147 -
  99.148 -	if (layerEnable & 0x0400)
  99.149 -	{
  99.150 -		int changed = gfxBG2Changed;
  99.151 -		if (gfxLastVCOUNT > VCOUNT)
  99.152 -			changed = 3;
  99.153 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
  99.154 -		                 BG2PA, BG2PB, BG2PC, BG2PD,
  99.155 -		                 gfxBG2X, gfxBG2Y, changed, line2);
  99.156 -	}
  99.157 -
  99.158 -	gfxDrawSprites(lineOBJ);
  99.159 -
  99.160 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  99.161 -
  99.162 -	for (int x = 0; x < 240; x++)
  99.163 -	{
  99.164 -		u32 color = backdrop;
  99.165 -		u8  top   = 0x20;
  99.166 -
  99.167 -		if (line0[x] < color)
  99.168 -		{
  99.169 -			color = line0[x];
  99.170 -			top   = 0x01;
  99.171 -		}
  99.172 -
  99.173 -		if ((u8)(line1[x]>>24) < (u8)(color >> 24))
  99.174 -		{
  99.175 -			color = line1[x];
  99.176 -			top   = 0x02;
  99.177 -		}
  99.178 -
  99.179 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24))
  99.180 -		{
  99.181 -			color = line2[x];
  99.182 -			top   = 0x04;
  99.183 -		}
  99.184 -
  99.185 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
  99.186 -		{
  99.187 -			color = lineOBJ[x];
  99.188 -			top   = 0x10;
  99.189 -		}
  99.190 -
  99.191 -		if (!(color & 0x00010000))
  99.192 -		{
  99.193 -			switch ((BLDMOD >> 6) & 3)
  99.194 -			{
  99.195 -			case 0:
  99.196 -				break;
  99.197 -			case 1:
  99.198 -			{
  99.199 -				if (top & BLDMOD)
  99.200 -				{
  99.201 -					u32 back = backdrop;
  99.202 -					u8  top2 = 0x20;
  99.203 -					if ((u8)(line0[x]>>24) < (u8)(back >> 24))
  99.204 -					{
  99.205 -						if (top != 0x01)
  99.206 -						{
  99.207 -							back = line0[x];
  99.208 -							top2 = 0x01;
  99.209 -						}
  99.210 -					}
  99.211 -
  99.212 -					if ((u8)(line1[x]>>24) < (u8)(back >> 24))
  99.213 -					{
  99.214 -						if (top != 0x02)
  99.215 -						{
  99.216 -							back = line1[x];
  99.217 -							top2 = 0x02;
  99.218 -						}
  99.219 -					}
  99.220 -
  99.221 -					if ((u8)(line2[x]>>24) < (u8)(back >> 24))
  99.222 -					{
  99.223 -						if (top != 0x04)
  99.224 -						{
  99.225 -							back = line2[x];
  99.226 -							top2 = 0x04;
  99.227 -						}
  99.228 -					}
  99.229 -
  99.230 -					if ((u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
  99.231 -					{
  99.232 -						if (top != 0x10)
  99.233 -						{
  99.234 -							back = lineOBJ[x];
  99.235 -							top2 = 0x10;
  99.236 -						}
  99.237 -					}
  99.238 -
  99.239 -					if (top2 & (BLDMOD>>8))
  99.240 -						color = gfxAlphaBlend(color, back,
  99.241 -						                      coeff[COLEV & 0x1F],
  99.242 -						                      coeff[(COLEV >> 8) & 0x1F]);
  99.243 -				}
  99.244 -				break;
  99.245 -			}
  99.246 -			case 2:
  99.247 -				if (BLDMOD & top)
  99.248 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.249 -				break;
  99.250 -			case 3:
  99.251 -				if (BLDMOD & top)
  99.252 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.253 -				break;
  99.254 -			}
  99.255 -		}
  99.256 -		else
  99.257 -		{
  99.258 -			// semi-transparent OBJ
  99.259 -			u32 back = backdrop;
  99.260 -			u8  top2 = 0x20;
  99.261 -
  99.262 -			if ((u8)(line0[x]>>24) < (u8)(back >> 24))
  99.263 -			{
  99.264 -				back = line0[x];
  99.265 -				top2 = 0x01;
  99.266 -			}
  99.267 -
  99.268 -			if ((u8)(line1[x]>>24) < (u8)(back >> 24))
  99.269 -			{
  99.270 -				back = line1[x];
  99.271 -				top2 = 0x02;
  99.272 -			}
  99.273 -
  99.274 -			if ((u8)(line2[x]>>24) < (u8)(back >> 24))
  99.275 -			{
  99.276 -				back = line2[x];
  99.277 -				top2 = 0x04;
  99.278 -			}
  99.279 -
  99.280 -			if (top2 & (BLDMOD>>8))
  99.281 -				color = gfxAlphaBlend(color, back,
  99.282 -				                      coeff[COLEV & 0x1F],
  99.283 -				                      coeff[(COLEV >> 8) & 0x1F]);
  99.284 -			else
  99.285 -			{
  99.286 -				switch ((BLDMOD >> 6) & 3)
  99.287 -				{
  99.288 -				case 2:
  99.289 -					if (BLDMOD & top)
  99.290 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.291 -					break;
  99.292 -				case 3:
  99.293 -					if (BLDMOD & top)
  99.294 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.295 -					break;
  99.296 -				}
  99.297 -			}
  99.298 -		}
  99.299 -
  99.300 -		lineMix[x] = color;
  99.301 -	}
  99.302 -	gfxBG2Changed = 0;
  99.303 -	gfxLastVCOUNT = VCOUNT;
  99.304 -}
  99.305 -
  99.306 -void mode1RenderLineAll()
  99.307 -{
  99.308 -	u16 *palette = (u16 *)paletteRAM;
  99.309 -
  99.310 -	if (DISPCNT & 0x80)
  99.311 -	{
  99.312 -		for (int x = 0; x < 240; x++)
  99.313 -		{
  99.314 -			lineMix[x] = 0x7fff;
  99.315 -		}
  99.316 -		gfxLastVCOUNT = VCOUNT;
  99.317 -		return;
  99.318 -	}
  99.319 -
  99.320 -	bool inWindow0 = false;
  99.321 -	bool inWindow1 = false;
  99.322 -
  99.323 -	if (layerEnable & 0x2000)
  99.324 -	{
  99.325 -		u8 v0 = WIN0V >> 8;
  99.326 -		u8 v1 = WIN0V & 255;
  99.327 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
  99.328 -		if (v1 >= v0)
  99.329 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
  99.330 -		else
  99.331 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
  99.332 -	}
  99.333 -	if (layerEnable & 0x4000)
  99.334 -	{
  99.335 -		u8 v0 = WIN1V >> 8;
  99.336 -		u8 v1 = WIN1V & 255;
  99.337 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
  99.338 -		if (v1 >= v0)
  99.339 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
  99.340 -		else
  99.341 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
  99.342 -	}
  99.343 -
  99.344 -	if (layerEnable & 0x0100)
  99.345 -	{
  99.346 -		gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
  99.347 -	}
  99.348 -
  99.349 -	if (layerEnable & 0x0200)
  99.350 -	{
  99.351 -		gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
  99.352 -	}
  99.353 -
  99.354 -	if (layerEnable & 0x0400)
  99.355 -	{
  99.356 -		int changed = gfxBG2Changed;
  99.357 -		if (gfxLastVCOUNT > VCOUNT)
  99.358 -			changed = 3;
  99.359 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
  99.360 -		                 BG2PA, BG2PB, BG2PC, BG2PD,
  99.361 -		                 gfxBG2X, gfxBG2Y, changed, line2);
  99.362 -	}
  99.363 -
  99.364 -	gfxDrawSprites(lineOBJ);
  99.365 -	gfxDrawOBJWin(lineOBJWin);
  99.366 -
  99.367 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  99.368 -
  99.369 -	u8 inWin0Mask = WININ & 0xFF;
  99.370 -	u8 inWin1Mask = WININ >> 8;
  99.371 -	u8 outMask    = WINOUT & 0xFF;
  99.372 -
  99.373 -	for (int x = 0; x < 240; x++)
  99.374 -	{
  99.375 -		u32 color = backdrop;
  99.376 -		u8  top   = 0x20;
  99.377 -		u8  mask  = outMask;
  99.378 -
  99.379 -		if (!(lineOBJWin[x] & 0x80000000))
  99.380 -		{
  99.381 -			mask = WINOUT >> 8;
  99.382 -		}
  99.383 -
  99.384 -		if (inWindow1)
  99.385 -		{
  99.386 -			if (gfxInWin1[x])
  99.387 -				mask = inWin1Mask;
  99.388 -		}
  99.389 -
  99.390 -		if (inWindow0)
  99.391 -		{
  99.392 -			if (gfxInWin0[x])
  99.393 -			{
  99.394 -				mask = inWin0Mask;
  99.395 -			}
  99.396 -		}
  99.397 -
  99.398 -		if (line0[x] < color && (mask & 1))
  99.399 -		{
  99.400 -			color = line0[x];
  99.401 -			top   = 0x01;
  99.402 -		}
  99.403 -
  99.404 -		if ((u8)(line1[x]>>24) < (u8)(color >> 24) && (mask & 2))
  99.405 -		{
  99.406 -			color = line1[x];
  99.407 -			top   = 0x02;
  99.408 -		}
  99.409 -
  99.410 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24) && (mask & 4))
  99.411 -		{
  99.412 -			color = line2[x];
  99.413 -			top   = 0x04;
  99.414 -		}
  99.415 -
  99.416 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16))
  99.417 -		{
  99.418 -			color = lineOBJ[x];
  99.419 -			top   = 0x10;
  99.420 -		}
  99.421 -
  99.422 -		// special FX on the window
  99.423 -		if (mask & 32)
  99.424 -		{
  99.425 -			if (!(color & 0x00010000))
  99.426 -			{
  99.427 -				switch ((BLDMOD >> 6) & 3)
  99.428 -				{
  99.429 -				case 0:
  99.430 -					break;
  99.431 -				case 1:
  99.432 -				{
  99.433 -					if (top & BLDMOD)
  99.434 -					{
  99.435 -						u32 back = backdrop;
  99.436 -						u8  top2 = 0x20;
  99.437 -						if ((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24))
  99.438 -						{
  99.439 -							if (top != 0x01)
  99.440 -							{
  99.441 -								back = line0[x];
  99.442 -								top2 = 0x01;
  99.443 -							}
  99.444 -						}
  99.445 -
  99.446 -						if ((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24))
  99.447 -						{
  99.448 -							if (top != 0x02)
  99.449 -							{
  99.450 -								back = line1[x];
  99.451 -								top2 = 0x02;
  99.452 -							}
  99.453 -						}
  99.454 -
  99.455 -						if ((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24))
  99.456 -						{
  99.457 -							if (top != 0x04)
  99.458 -							{
  99.459 -								back = line2[x];
  99.460 -								top2 = 0x04;
  99.461 -							}
  99.462 -						}
  99.463 -
  99.464 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
  99.465 -						{
  99.466 -							if (top != 0x10)
  99.467 -							{
  99.468 -								back = lineOBJ[x];
  99.469 -								top2 = 0x10;
  99.470 -							}
  99.471 -						}
  99.472 -
  99.473 -						if (top2 & (BLDMOD>>8))
  99.474 -							color = gfxAlphaBlend(color, back,
  99.475 -							                      coeff[COLEV & 0x1F],
  99.476 -							                      coeff[(COLEV >> 8) & 0x1F]);
  99.477 -					}
  99.478 -					break;
  99.479 -				}
  99.480 -				case 2:
  99.481 -					if (BLDMOD & top)
  99.482 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.483 -					break;
  99.484 -				case 3:
  99.485 -					if (BLDMOD & top)
  99.486 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.487 -					break;
  99.488 -				}
  99.489 -			}
  99.490 -			else
  99.491 -			{
  99.492 -				// semi-transparent OBJ
  99.493 -				u32 back = backdrop;
  99.494 -				u8  top2 = 0x20;
  99.495 -
  99.496 -				if ((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24))
  99.497 -				{
  99.498 -					back = line0[x];
  99.499 -					top2 = 0x01;
  99.500 -				}
  99.501 -
  99.502 -				if ((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24))
  99.503 -				{
  99.504 -					back = line1[x];
  99.505 -					top2 = 0x02;
  99.506 -				}
  99.507 -
  99.508 -				if ((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24))
  99.509 -				{
  99.510 -					back = line2[x];
  99.511 -					top2 = 0x04;
  99.512 -				}
  99.513 -
  99.514 -				if (top2 & (BLDMOD>>8))
  99.515 -					color = gfxAlphaBlend(color, back,
  99.516 -					                      coeff[COLEV & 0x1F],
  99.517 -					                      coeff[(COLEV >> 8) & 0x1F]);
  99.518 -				else
  99.519 -				{
  99.520 -					switch ((BLDMOD >> 6) & 3)
  99.521 -					{
  99.522 -					case 2:
  99.523 -						if (BLDMOD & top)
  99.524 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.525 -						break;
  99.526 -					case 3:
  99.527 -						if (BLDMOD & top)
  99.528 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.529 -						break;
  99.530 -					}
  99.531 -				}
  99.532 -			}
  99.533 -		}
  99.534 -		else if (color & 0x00010000)
  99.535 -		{
  99.536 -			// semi-transparent OBJ
  99.537 -			u32 back = backdrop;
  99.538 -			u8  top2 = 0x20;
  99.539 -
  99.540 -			if ((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24))
  99.541 -			{
  99.542 -				back = line0[x];
  99.543 -				top2 = 0x01;
  99.544 -			}
  99.545 -
  99.546 -			if ((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24))
  99.547 -			{
  99.548 -				back = line1[x];
  99.549 -				top2 = 0x02;
  99.550 -			}
  99.551 -
  99.552 -			if ((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24))
  99.553 -			{
  99.554 -				back = line2[x];
  99.555 -				top2 = 0x04;
  99.556 -			}
  99.557 -
  99.558 -			if (top2 & (BLDMOD>>8))
  99.559 -				color = gfxAlphaBlend(color, back,
  99.560 -				                      coeff[COLEV & 0x1F],
  99.561 -				                      coeff[(COLEV >> 8) & 0x1F]);
  99.562 -			else
  99.563 -			{
  99.564 -				switch ((BLDMOD >> 6) & 3)
  99.565 -				{
  99.566 -				case 2:
  99.567 -					if (BLDMOD & top)
  99.568 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  99.569 -					break;
  99.570 -				case 3:
  99.571 -					if (BLDMOD & top)
  99.572 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  99.573 -					break;
  99.574 -				}
  99.575 -			}
  99.576 -		}
  99.577 -
  99.578 -		lineMix[x] = color;
  99.579 -	}
  99.580 -	gfxBG2Changed = 0;
  99.581 -	gfxLastVCOUNT = VCOUNT;
  99.582 -}
  99.583 -
   100.1 --- a/src/gba/Mode2.cpp	Sat Mar 03 10:54:39 2012 -0600
   100.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.3 @@ -1,530 +0,0 @@
   100.4 -#include "GBAGfx.h"
   100.5 -#include "GBAGlobals.h"
   100.6 -
   100.7 -void mode2RenderLine()
   100.8 -{
   100.9 -	u16 *palette = (u16 *)paletteRAM;
  100.10 -
  100.11 -	if (DISPCNT & 0x80)
  100.12 -	{
  100.13 -		for (int x = 0; x < 240; x++)
  100.14 -		{
  100.15 -			lineMix[x] = 0x7fff;
  100.16 -		}
  100.17 -		gfxLastVCOUNT = VCOUNT;
  100.18 -		return;
  100.19 -	}
  100.20 -
  100.21 -	if (layerEnable & 0x0400)
  100.22 -	{
  100.23 -		int changed = gfxBG2Changed;
  100.24 -		if (gfxLastVCOUNT > VCOUNT)
  100.25 -			changed = 3;
  100.26 -
  100.27 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
  100.28 -		                 BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
  100.29 -		                 changed, line2);
  100.30 -	}
  100.31 -
  100.32 -	if (layerEnable & 0x0800)
  100.33 -	{
  100.34 -		int changed = gfxBG3Changed;
  100.35 -		if (gfxLastVCOUNT > VCOUNT)
  100.36 -			changed = 3;
  100.37 -
  100.38 -		gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
  100.39 -		                 BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
  100.40 -		                 changed, line3);
  100.41 -	}
  100.42 -
  100.43 -	gfxDrawSprites(lineOBJ);
  100.44 -
  100.45 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  100.46 -
  100.47 -	for (int x = 0; x < 240; x++)
  100.48 -	{
  100.49 -		u32 color = backdrop;
  100.50 -		u8  top   = 0x20;
  100.51 -
  100.52 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24))
  100.53 -		{
  100.54 -			color = line2[x];
  100.55 -			top   = 0x04;
  100.56 -		}
  100.57 -
  100.58 -		if ((u8)(line3[x]>>24) < (u8)(color >> 24))
  100.59 -		{
  100.60 -			color = line3[x];
  100.61 -			top   = 0x08;
  100.62 -		}
  100.63 -
  100.64 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
  100.65 -		{
  100.66 -			color = lineOBJ[x];
  100.67 -			top   = 0x10;
  100.68 -		}
  100.69 -
  100.70 -		if ((top & 0x10) && (color & 0x00010000))
  100.71 -		{
  100.72 -			// semi-transparent OBJ
  100.73 -			u32 back = backdrop;
  100.74 -			u8  top2 = 0x20;
  100.75 -
  100.76 -			if ((u8)(line2[x]>>24) < (u8)(back >> 24))
  100.77 -			{
  100.78 -				back = line2[x];
  100.79 -				top2 = 0x04;
  100.80 -			}
  100.81 -
  100.82 -			if ((u8)(line3[x]>>24) < (u8)(back >> 24))
  100.83 -			{
  100.84 -				back = line3[x];
  100.85 -				top2 = 0x08;
  100.86 -			}
  100.87 -
  100.88 -			if (top2 & (BLDMOD>>8))
  100.89 -				color = gfxAlphaBlend(color, back,
  100.90 -				                      coeff[COLEV & 0x1F],
  100.91 -				                      coeff[(COLEV >> 8) & 0x1F]);
  100.92 -			else
  100.93 -			{
  100.94 -				switch ((BLDMOD >> 6) & 3)
  100.95 -				{
  100.96 -				case 2:
  100.97 -					if (BLDMOD & top)
  100.98 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  100.99 -					break;
 100.100 -				case 3:
 100.101 -					if (BLDMOD & top)
 100.102 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.103 -					break;
 100.104 -				}
 100.105 -			}
 100.106 -		}
 100.107 -
 100.108 -		lineMix[x] = color;
 100.109 -	}
 100.110 -	gfxBG2Changed = 0;
 100.111 -	gfxBG3Changed = 0;
 100.112 -	gfxLastVCOUNT = VCOUNT;
 100.113 -}
 100.114 -
 100.115 -void mode2RenderLineNoWindow()
 100.116 -{
 100.117 -	u16 *palette = (u16 *)paletteRAM;
 100.118 -
 100.119 -	if (DISPCNT & 0x80)
 100.120 -	{
 100.121 -		for (int x = 0; x < 240; x++)
 100.122 -		{
 100.123 -			lineMix[x] = 0x7fff;
 100.124 -		}
 100.125 -		gfxLastVCOUNT = VCOUNT;
 100.126 -		return;
 100.127 -	}
 100.128 -
 100.129 -	if (layerEnable & 0x0400)
 100.130 -	{
 100.131 -		int changed = gfxBG2Changed;
 100.132 -		if (gfxLastVCOUNT > VCOUNT)
 100.133 -			changed = 3;
 100.134 -
 100.135 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
 100.136 -		                 BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
 100.137 -		                 changed, line2);
 100.138 -	}
 100.139 -
 100.140 -	if (layerEnable & 0x0800)
 100.141 -	{
 100.142 -		int changed = gfxBG3Changed;
 100.143 -		if (gfxLastVCOUNT > VCOUNT)
 100.144 -			changed = 3;
 100.145 -
 100.146 -		gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
 100.147 -		                 BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
 100.148 -		                 changed, line3);
 100.149 -	}
 100.150 -
 100.151 -	gfxDrawSprites(lineOBJ);
 100.152 -
 100.153 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
 100.154 -
 100.155 -	for (int x = 0; x < 240; x++)
 100.156 -	{
 100.157 -		u32 color = backdrop;
 100.158 -		u8  top   = 0x20;
 100.159 -
 100.160 -		if ((u8)(line2[x]>>24) < (u8)(color >> 24))
 100.161 -		{
 100.162 -			color = line2[x];
 100.163 -			top   = 0x04;
 100.164 -		}
 100.165 -
 100.166 -		if ((u8)(line3[x]>>24) < (u8)(color >> 24))
 100.167 -		{
 100.168 -			color = line3[x];
 100.169 -			top   = 0x08;
 100.170 -		}
 100.171 -
 100.172 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
 100.173 -		{
 100.174 -			color = lineOBJ[x];
 100.175 -			top   = 0x10;
 100.176 -		}
 100.177 -
 100.178 -		if (!(color & 0x00010000))
 100.179 -		{
 100.180 -			switch ((BLDMOD >> 6) & 3)
 100.181 -			{
 100.182 -			case 0:
 100.183 -				break;
 100.184 -			case 1:
 100.185 -			{
 100.186 -				if (top & BLDMOD)
 100.187 -				{
 100.188 -					u32 back = backdrop;
 100.189 -					u8  top2 = 0x20;
 100.190 -
 100.191 -					if ((u8)(line2[x]>>24) < (u8)(back >> 24))
 100.192 -					{
 100.193 -						if (top != 0x04)
 100.194 -						{
 100.195 -							back = line2[x];
 100.196 -							top2 = 0x04;
 100.197 -						}
 100.198 -					}
 100.199 -
 100.200 -					if ((u8)(line3[x]>>24) < (u8)(back >> 24))
 100.201 -					{
 100.202 -						if (top != 0x08)
 100.203 -						{
 100.204 -							back = line3[x];
 100.205 -							top2 = 0x08;
 100.206 -						}
 100.207 -					}
 100.208 -
 100.209 -					if ((u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 100.210 -					{
 100.211 -						if (top != 0x10)
 100.212 -						{
 100.213 -							back = lineOBJ[x];
 100.214 -							top2 = 0x10;
 100.215 -						}
 100.216 -					}
 100.217 -
 100.218 -					if (top2 & (BLDMOD>>8))
 100.219 -						color = gfxAlphaBlend(color, back,
 100.220 -						                      coeff[COLEV & 0x1F],
 100.221 -						                      coeff[(COLEV >> 8) & 0x1F]);
 100.222 -				}
 100.223 -				break;
 100.224 -			}
 100.225 -			case 2:
 100.226 -				if (BLDMOD & top)
 100.227 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 100.228 -				break;
 100.229 -			case 3:
 100.230 -				if (BLDMOD & top)
 100.231 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.232 -				break;
 100.233 -			}
 100.234 -		}
 100.235 -		else
 100.236 -		{
 100.237 -			// semi-transparent OBJ
 100.238 -			u32 back = backdrop;
 100.239 -			u8  top2 = 0x20;
 100.240 -
 100.241 -			if ((u8)(line2[x]>>24) < (u8)(back >> 24))
 100.242 -			{
 100.243 -				back = line2[x];
 100.244 -				top2 = 0x04;
 100.245 -			}
 100.246 -
 100.247 -			if ((u8)(line3[x]>>24) < (u8)(back >> 24))
 100.248 -			{
 100.249 -				back = line3[x];
 100.250 -				top2 = 0x08;
 100.251 -			}
 100.252 -
 100.253 -			if (top2 & (BLDMOD>>8))
 100.254 -				color = gfxAlphaBlend(color, back,
 100.255 -				                      coeff[COLEV & 0x1F],
 100.256 -				                      coeff[(COLEV >> 8) & 0x1F]);
 100.257 -			else
 100.258 -			{
 100.259 -				switch ((BLDMOD >> 6) & 3)
 100.260 -				{
 100.261 -				case 2:
 100.262 -					if (BLDMOD & top)
 100.263 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 100.264 -					break;
 100.265 -				case 3:
 100.266 -					if (BLDMOD & top)
 100.267 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.268 -					break;
 100.269 -				}
 100.270 -			}
 100.271 -		}
 100.272 -
 100.273 -		lineMix[x] = color;
 100.274 -	}
 100.275 -	gfxBG2Changed = 0;
 100.276 -	gfxBG3Changed = 0;
 100.277 -	gfxLastVCOUNT = VCOUNT;
 100.278 -}
 100.279 -
 100.280 -void mode2RenderLineAll()
 100.281 -{
 100.282 -	u16 *palette = (u16 *)paletteRAM;
 100.283 -
 100.284 -	if (DISPCNT & 0x80)
 100.285 -	{
 100.286 -		for (int x = 0; x < 240; x++)
 100.287 -		{
 100.288 -			lineMix[x] = 0x7fff;
 100.289 -		}
 100.290 -		gfxLastVCOUNT = VCOUNT;
 100.291 -		return;
 100.292 -	}
 100.293 -
 100.294 -	bool inWindow0 = false;
 100.295 -	bool inWindow1 = false;
 100.296 -
 100.297 -	if (layerEnable & 0x2000)
 100.298 -	{
 100.299 -		u8 v0 = WIN0V >> 8;
 100.300 -		u8 v1 = WIN0V & 255;
 100.301 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
 100.302 -		if (v1 >= v0)
 100.303 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
 100.304 -		else
 100.305 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
 100.306 -	}
 100.307 -	if (layerEnable & 0x4000)
 100.308 -	{
 100.309 -		u8 v0 = WIN1V >> 8;
 100.310 -		u8 v1 = WIN1V & 255;
 100.311 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
 100.312 -		if (v1 >= v0)
 100.313 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
 100.314 -		else
 100.315 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
 100.316 -	}
 100.317 -
 100.318 -	if (layerEnable & 0x0400)
 100.319 -	{
 100.320 -		int changed = gfxBG2Changed;
 100.321 -		if (gfxLastVCOUNT > VCOUNT)
 100.322 -			changed = 3;
 100.323 -
 100.324 -		gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
 100.325 -		                 BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
 100.326 -		                 changed, line2);
 100.327 -	}
 100.328 -
 100.329 -	if (layerEnable & 0x0800)
 100.330 -	{
 100.331 -		int changed = gfxBG3Changed;
 100.332 -		if (gfxLastVCOUNT > VCOUNT)
 100.333 -			changed = 3;
 100.334 -
 100.335 -		gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
 100.336 -		                 BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
 100.337 -		                 changed, line3);
 100.338 -	}
 100.339 -
 100.340 -	gfxDrawSprites(lineOBJ);
 100.341 -	gfxDrawOBJWin(lineOBJWin);
 100.342 -
 100.343 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
 100.344 -
 100.345 -	u8 inWin0Mask = WININ & 0xFF;
 100.346 -	u8 inWin1Mask = WININ >> 8;
 100.347 -	u8 outMask    = WINOUT & 0xFF;
 100.348 -
 100.349 -	for (int x = 0; x < 240; x++)
 100.350 -	{
 100.351 -		u32 color = backdrop;
 100.352 -		u8  top   = 0x20;
 100.353 -		u8  mask  = outMask;
 100.354 -
 100.355 -		if (!(lineOBJWin[x] & 0x80000000))
 100.356 -		{
 100.357 -			mask = WINOUT >> 8;
 100.358 -		}
 100.359 -
 100.360 -		if (inWindow1)
 100.361 -		{
 100.362 -			if (gfxInWin1[x])
 100.363 -				mask = inWin1Mask;
 100.364 -		}
 100.365 -
 100.366 -		if (inWindow0)
 100.367 -		{
 100.368 -			if (gfxInWin0[x])
 100.369 -			{
 100.370 -				mask = inWin0Mask;
 100.371 -			}
 100.372 -		}
 100.373 -
 100.374 -		if (line2[x] < color && (mask & 4))
 100.375 -		{
 100.376 -			color = line2[x];
 100.377 -			top   = 0x04;
 100.378 -		}
 100.379 -
 100.380 -		if ((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8))
 100.381 -		{
 100.382 -			color = line3[x];
 100.383 -			top   = 0x08;
 100.384 -		}
 100.385 -
 100.386 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16))
 100.387 -		{
 100.388 -			color = lineOBJ[x];
 100.389 -			top   = 0x10;
 100.390 -		}
 100.391 -
 100.392 -		if (mask & 32)
 100.393 -		{
 100.394 -			if (!(color & 0x00010000))
 100.395 -			{
 100.396 -				switch ((BLDMOD >> 6) & 3)
 100.397 -				{
 100.398 -				case 0:
 100.399 -					break;
 100.400 -				case 1:
 100.401 -				{
 100.402 -					if (top & BLDMOD)
 100.403 -					{
 100.404 -						u32 back = backdrop;
 100.405 -						u8  top2 = 0x20;
 100.406 -
 100.407 -						if ((mask & 4) && line2[x] < back)
 100.408 -						{
 100.409 -							if (top != 0x04)
 100.410 -							{
 100.411 -								back = line2[x];
 100.412 -								top2 = 0x04;
 100.413 -							}
 100.414 -						}
 100.415 -
 100.416 -						if ((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24))
 100.417 -						{
 100.418 -							if (top != 0x08)
 100.419 -							{
 100.420 -								back = line3[x];
 100.421 -								top2 = 0x08;
 100.422 -							}
 100.423 -						}
 100.424 -
 100.425 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 100.426 -						{
 100.427 -							if (top != 0x10)
 100.428 -							{
 100.429 -								back = lineOBJ[x];
 100.430 -								top2 = 0x10;
 100.431 -							}
 100.432 -						}
 100.433 -
 100.434 -						if (top2 & (BLDMOD>>8))
 100.435 -							color = gfxAlphaBlend(color, back,
 100.436 -							                      coeff[COLEV & 0x1F],
 100.437 -							                      coeff[(COLEV >> 8) & 0x1F]);
 100.438 -					}
 100.439 -					break;
 100.440 -				}
 100.441 -				case 2:
 100.442 -					if (BLDMOD & top)
 100.443 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 100.444 -					break;
 100.445 -				case 3:
 100.446 -					if (BLDMOD & top)
 100.447 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.448 -					break;
 100.449 -				}
 100.450 -			}
 100.451 -			else
 100.452 -			{
 100.453 -				// semi-transparent OBJ
 100.454 -				u32 back = backdrop;
 100.455 -				u8  top2 = 0x20;
 100.456 -
 100.457 -				if ((mask & 4) && line2[x] < back)
 100.458 -				{
 100.459 -					back = line2[x];
 100.460 -					top2 = 0x04;
 100.461 -				}
 100.462 -
 100.463 -				if ((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24))
 100.464 -				{
 100.465 -					back = line3[x];
 100.466 -					top2 = 0x08;
 100.467 -				}
 100.468 -
 100.469 -				if (top2 & (BLDMOD>>8))
 100.470 -					color = gfxAlphaBlend(color, back,
 100.471 -					                      coeff[COLEV & 0x1F],
 100.472 -					                      coeff[(COLEV >> 8) & 0x1F]);
 100.473 -				else
 100.474 -				{
 100.475 -					switch ((BLDMOD >> 6) & 3)
 100.476 -					{
 100.477 -					case 2:
 100.478 -						if (BLDMOD & top)
 100.479 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 100.480 -						break;
 100.481 -					case 3:
 100.482 -						if (BLDMOD & top)
 100.483 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.484 -						break;
 100.485 -					}
 100.486 -				}
 100.487 -			}
 100.488 -		}
 100.489 -		else if (color & 0x00010000)
 100.490 -		{
 100.491 -			// semi-transparent OBJ
 100.492 -			u32 back = backdrop;
 100.493 -			u8  top2 = 0x20;
 100.494 -
 100.495 -			if ((mask & 4) && line2[x] < back)
 100.496 -			{
 100.497 -				back = line2[x];
 100.498 -				top2 = 0x04;
 100.499 -			}
 100.500 -
 100.501 -			if ((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24))
 100.502 -			{
 100.503 -				back = line3[x];
 100.504 -				top2 = 0x08;
 100.505 -			}
 100.506 -
 100.507 -			if (top2 & (BLDMOD>>8))
 100.508 -				color = gfxAlphaBlend(color, back,
 100.509 -				                      coeff[COLEV & 0x1F],
 100.510 -				                      coeff[(COLEV >> 8) & 0x1F]);
 100.511 -			else
 100.512 -			{
 100.513 -				switch ((BLDMOD >> 6) & 3)
 100.514 -				{
 100.515 -				case 2:
 100.516 -					if (BLDMOD & top)
 100.517 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 100.518 -					break;
 100.519 -				case 3:
 100.520 -					if (BLDMOD & top)
 100.521 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 100.522 -					break;
 100.523 -				}
 100.524 -			}
 100.525 -		}
 100.526 -
 100.527 -		lineMix[x] = color;
 100.528 -	}
 100.529 -	gfxBG2Changed = 0;
 100.530 -	gfxBG3Changed = 0;
 100.531 -	gfxLastVCOUNT = VCOUNT;
 100.532 -}
 100.533 -
   101.1 --- a/src/gba/Mode3.cpp	Sat Mar 03 10:54:39 2012 -0600
   101.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.3 @@ -1,443 +0,0 @@
   101.4 -#include "GBAGfx.h"
   101.5 -#include "GBAGlobals.h"
   101.6 -
   101.7 -void mode3RenderLine()
   101.8 -{
   101.9 -	u16 *palette = (u16 *)paletteRAM;
  101.10 -
  101.11 -	if (DISPCNT & 0x80)
  101.12 -	{
  101.13 -		for (int x = 0; x < 240; x++)
  101.14 -		{
  101.15 -			lineMix[x] = 0x7fff;
  101.16 -		}
  101.17 -		gfxLastVCOUNT = VCOUNT;
  101.18 -		return;
  101.19 -	}
  101.20 -
  101.21 -	if (layerEnable & 0x0400)
  101.22 -	{
  101.23 -		int changed = gfxBG2Changed;
  101.24 -
  101.25 -		if (gfxLastVCOUNT > VCOUNT)
  101.26 -			changed = 3;
  101.27 -
  101.28 -		gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
  101.29 -		                      BG2Y_L, BG2Y_H, BG2PA, BG2PB,
  101.30 -		                      BG2PC, BG2PD,
  101.31 -		                      gfxBG2X, gfxBG2Y, changed,
  101.32 -		                      line2);
  101.33 -	}
  101.34 -
  101.35 -	gfxDrawSprites(lineOBJ);
  101.36 -
  101.37 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
  101.38 -
  101.39 -	for (int x = 0; x < 240; x++)
  101.40 -	{
  101.41 -		u32 color = background;
  101.42 -		u8  top   = 0x20;
  101.43 -
  101.44 -		if (line2[x] < color)
  101.45 -		{
  101.46 -			color = line2[x];
  101.47 -			top   = 0x04;
  101.48 -		}
  101.49 -
  101.50 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))
  101.51 -		{
  101.52 -			color = lineOBJ[x];
  101.53 -			top   = 0x10;
  101.54 -		}
  101.55 -
  101.56 -		if ((top & 0x10) && (color & 0x00010000))
  101.57 -		{
  101.58 -			// semi-transparent OBJ
  101.59 -			u32 back = background;
  101.60 -			u8  top2 = 0x20;
  101.61 -
  101.62 -			if (line2[x] < back)
  101.63 -			{
  101.64 -				back = line2[x];
  101.65 -				top2 = 0x04;
  101.66 -			}
  101.67 -
  101.68 -			if (top2 & (BLDMOD>>8))
  101.69 -				color = gfxAlphaBlend(color, back,
  101.70 -				                      coeff[COLEV & 0x1F],
  101.71 -				                      coeff[(COLEV >> 8) & 0x1F]);
  101.72 -			else
  101.73 -			{
  101.74 -				switch ((BLDMOD >> 6) & 3)
  101.75 -				{
  101.76 -				case 2:
  101.77 -					if (BLDMOD & top)
  101.78 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  101.79 -					break;
  101.80 -				case 3:
  101.81 -					if (BLDMOD & top)
  101.82 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  101.83 -					break;
  101.84 -				}
  101.85 -			}
  101.86 -		}
  101.87 -
  101.88 -		lineMix[x] = color;
  101.89 -	}
  101.90 -	gfxBG2Changed = 0;
  101.91 -	gfxLastVCOUNT = VCOUNT;
  101.92 -}
  101.93 -
  101.94 -void mode3RenderLineNoWindow()
  101.95 -{
  101.96 -	u16 *palette = (u16 *)paletteRAM;
  101.97 -
  101.98 -	if (DISPCNT & 0x80)
  101.99 -	{
 101.100 -		for (int x = 0; x < 240; x++)
 101.101 -		{
 101.102 -			lineMix[x] = 0x7fff;
 101.103 -		}
 101.104 -		gfxLastVCOUNT = VCOUNT;
 101.105 -		return;
 101.106 -	}
 101.107 -
 101.108 -	if (layerEnable & 0x0400)
 101.109 -	{
 101.110 -		int changed = gfxBG2Changed;
 101.111 -
 101.112 -		if (gfxLastVCOUNT > VCOUNT)
 101.113 -			changed = 3;
 101.114 -
 101.115 -		gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
 101.116 -		                      BG2Y_L, BG2Y_H, BG2PA, BG2PB,
 101.117 -		                      BG2PC, BG2PD,
 101.118 -		                      gfxBG2X, gfxBG2Y, changed,
 101.119 -		                      line2);
 101.120 -	}
 101.121 -
 101.122 -	gfxDrawSprites(lineOBJ);
 101.123 -
 101.124 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
 101.125 -
 101.126 -	for (int x = 0; x < 240; x++)
 101.127 -	{
 101.128 -		u32 color = background;
 101.129 -		u8  top   = 0x20;
 101.130 -
 101.131 -		if (line2[x] < color)
 101.132 -		{
 101.133 -			color = line2[x];
 101.134 -			top   = 0x04;
 101.135 -		}
 101.136 -
 101.137 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))
 101.138 -		{
 101.139 -			color = lineOBJ[x];
 101.140 -			top   = 0x10;
 101.141 -		}
 101.142 -
 101.143 -		if (!(color & 0x00010000))
 101.144 -		{
 101.145 -			switch ((BLDMOD >> 6) & 3)
 101.146 -			{
 101.147 -			case 0:
 101.148 -				break;
 101.149 -			case 1:
 101.150 -			{
 101.151 -				if (top & BLDMOD)
 101.152 -				{
 101.153 -					u32 back = background;
 101.154 -					u8  top2 = 0x20;
 101.155 -
 101.156 -					if (line2[x] < back)
 101.157 -					{
 101.158 -						if (top != 0x04)
 101.159 -						{
 101.160 -							back = line2[x];
 101.161 -							top2 = 0x04;
 101.162 -						}
 101.163 -					}
 101.164 -
 101.165 -					if ((u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 101.166 -					{
 101.167 -						if (top != 0x10)
 101.168 -						{
 101.169 -							back = lineOBJ[x];
 101.170 -							top2 = 0x10;
 101.171 -						}
 101.172 -					}
 101.173 -
 101.174 -					if (top2 & (BLDMOD>>8))
 101.175 -						color = gfxAlphaBlend(color, back,
 101.176 -						                      coeff[COLEV & 0x1F],
 101.177 -						                      coeff[(COLEV >> 8) & 0x1F]);
 101.178 -				}
 101.179 -				break;
 101.180 -			}
 101.181 -			case 2:
 101.182 -				if (BLDMOD & top)
 101.183 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 101.184 -				break;
 101.185 -			case 3:
 101.186 -				if (BLDMOD & top)
 101.187 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 101.188 -				break;
 101.189 -			}
 101.190 -		}
 101.191 -		else
 101.192 -		{
 101.193 -			// semi-transparent OBJ
 101.194 -			u32 back = background;
 101.195 -			u8  top2 = 0x20;
 101.196 -
 101.197 -			if (line2[x] < back)
 101.198 -			{
 101.199 -				back = line2[x];
 101.200 -				top2 = 0x04;
 101.201 -			}
 101.202 -
 101.203 -			if (top2 & (BLDMOD>>8))
 101.204 -				color = gfxAlphaBlend(color, back,
 101.205 -				                      coeff[COLEV & 0x1F],
 101.206 -				                      coeff[(COLEV >> 8) & 0x1F]);
 101.207 -			else
 101.208 -			{
 101.209 -				switch ((BLDMOD >> 6) & 3)
 101.210 -				{
 101.211 -				case 2:
 101.212 -					if (BLDMOD & top)
 101.213 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 101.214 -					break;
 101.215 -				case 3:
 101.216 -					if (BLDMOD & top)
 101.217 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 101.218 -					break;
 101.219 -				}
 101.220 -			}
 101.221 -		}
 101.222 -
 101.223 -		lineMix[x] = color;
 101.224 -	}
 101.225 -	gfxBG2Changed = 0;
 101.226 -	gfxLastVCOUNT = VCOUNT;
 101.227 -}
 101.228 -
 101.229 -void mode3RenderLineAll()
 101.230 -{
 101.231 -	u16 *palette = (u16 *)paletteRAM;
 101.232 -
 101.233 -	if (DISPCNT & 0x80)
 101.234 -	{
 101.235 -		for (int x = 0; x < 240; x++)
 101.236 -		{
 101.237 -			lineMix[x] = 0x7fff;
 101.238 -		}
 101.239 -		gfxLastVCOUNT = VCOUNT;
 101.240 -		return;
 101.241 -	}
 101.242 -
 101.243 -	bool inWindow0 = false;
 101.244 -	bool inWindow1 = false;
 101.245 -
 101.246 -	if (layerEnable & 0x2000)
 101.247 -	{
 101.248 -		u8 v0 = WIN0V >> 8;
 101.249 -		u8 v1 = WIN0V & 255;
 101.250 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
 101.251 -		if (v1 >= v0)
 101.252 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
 101.253 -		else
 101.254 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
 101.255 -	}
 101.256 -	if (layerEnable & 0x4000)
 101.257 -	{
 101.258 -		u8 v0 = WIN1V >> 8;
 101.259 -		u8 v1 = WIN1V & 255;
 101.260 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
 101.261 -		if (v1 >= v0)
 101.262 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
 101.263 -		else
 101.264 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
 101.265 -	}
 101.266 -
 101.267 -	if (layerEnable & 0x0400)
 101.268 -	{
 101.269 -		int changed = gfxBG2Changed;
 101.270 -
 101.271 -		if (gfxLastVCOUNT > VCOUNT)
 101.272 -			changed = 3;
 101.273 -
 101.274 -		gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
 101.275 -		                      BG2Y_L, BG2Y_H, BG2PA, BG2PB,
 101.276 -		                      BG2PC, BG2PD,
 101.277 -		                      gfxBG2X, gfxBG2Y, changed,
 101.278 -		                      line2);
 101.279 -	}
 101.280 -
 101.281 -	gfxDrawSprites(lineOBJ);
 101.282 -	gfxDrawOBJWin(lineOBJWin);
 101.283 -
 101.284 -	u8 inWin0Mask = WININ & 0xFF;
 101.285 -	u8 inWin1Mask = WININ >> 8;
 101.286 -	u8 outMask    = WINOUT & 0xFF;
 101.287 -
 101.288 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
 101.289 -
 101.290 -	for (int x = 0; x < 240; x++)
 101.291 -	{
 101.292 -		u32 color = background;
 101.293 -		u8  top   = 0x20;
 101.294 -		u8  mask  = outMask;
 101.295 -
 101.296 -		if (!(lineOBJWin[x] & 0x80000000))
 101.297 -		{
 101.298 -			mask = WINOUT >> 8;
 101.299 -		}
 101.300 -
 101.301 -		if (inWindow1)
 101.302 -		{
 101.303 -			if (gfxInWin1[x])
 101.304 -				mask = inWin1Mask;
 101.305 -		}
 101.306 -
 101.307 -		if (inWindow0)
 101.308 -		{
 101.309 -			if (gfxInWin0[x])
 101.310 -			{
 101.311 -				mask = inWin0Mask;
 101.312 -			}
 101.313 -		}
 101.314 -
 101.315 -		if ((mask & 4) && (line2[x] < color))
 101.316 -		{
 101.317 -			color = line2[x];
 101.318 -			top   = 0x04;
 101.319 -		}
 101.320 -
 101.321 -		if ((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24)))
 101.322 -		{
 101.323 -			color = lineOBJ[x];
 101.324 -			top   = 0x10;
 101.325 -		}
 101.326 -
 101.327 -		if (mask & 32)
 101.328 -		{
 101.329 -			if (!(color & 0x00010000))
 101.330 -			{
 101.331 -				switch ((BLDMOD >> 6) & 3)
 101.332 -				{
 101.333 -				case 0:
 101.334 -					break;
 101.335 -				case 1:
 101.336 -				{
 101.337 -					if (top & BLDMOD)
 101.338 -					{
 101.339 -						u32 back = background;
 101.340 -						u8  top2 = 0x20;
 101.341 -
 101.342 -						if ((mask & 4) && line2[x] < back)
 101.343 -						{
 101.344 -							if (top != 0x04)
 101.345 -							{
 101.346 -								back = line2[x];
 101.347 -								top2 = 0x04;
 101.348 -							}
 101.349 -						}
 101.350 -
 101.351 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 101.352 -						{
 101.353 -							if (top != 0x10)
 101.354 -							{
 101.355 -								back = lineOBJ[x];
 101.356 -								top2 = 0x10;
 101.357 -							}
 101.358 -						}
 101.359 -
 101.360 -						if (top2 & (BLDMOD>>8))
 101.361 -							color = gfxAlphaBlend(color, back,
 101.362 -							                      coeff[COLEV & 0x1F],
 101.363 -							                      coeff[(COLEV >> 8) & 0x1F]);
 101.364 -					}
 101.365 -					break;
 101.366 -				}
 101.367 -				case 2:
 101.368 -					if (BLDMOD & top)
 101.369 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 101.370 -					break;
 101.371 -				case 3:
 101.372 -					if (BLDMOD & top)
 101.373 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 101.374 -					break;
 101.375 -				}
 101.376 -			}
 101.377 -			else
 101.378 -			{
 101.379 -				// semi-transparent OBJ
 101.380 -				u32 back = background;
 101.381 -				u8  top2 = 0x20;
 101.382 -
 101.383 -				if ((mask & 4) && line2[x] < back)
 101.384 -				{
 101.385 -					back = line2[x];
 101.386 -					top2 = 0x04;
 101.387 -				}
 101.388 -
 101.389 -				if (top2 & (BLDMOD>>8))
 101.390 -					color = gfxAlphaBlend(color, back,
 101.391 -					                      coeff[COLEV & 0x1F],
 101.392 -					                      coeff[(COLEV >> 8) & 0x1F]);
 101.393 -				else
 101.394 -				{
 101.395 -					switch ((BLDMOD >> 6) & 3)
 101.396 -					{
 101.397 -					case 2:
 101.398 -						if (BLDMOD & top)
 101.399 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 101.400 -						break;
 101.401 -					case 3:
 101.402 -						if (BLDMOD & top)
 101.403 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 101.404 -						break;
 101.405 -					}
 101.406 -				}
 101.407 -			}
 101.408 -		}
 101.409 -		else if (color & 0x00010000)
 101.410 -		{
 101.411 -			// semi-transparent OBJ
 101.412 -			u32 back = background;
 101.413 -			u8  top2 = 0x20;
 101.414 -
 101.415 -			if ((mask & 4) && line2[x] < back)
 101.416 -			{
 101.417 -				back = line2[x];
 101.418 -				top2 = 0x04;
 101.419 -			}
 101.420 -
 101.421 -			if (top2 & (BLDMOD>>8))
 101.422 -				color = gfxAlphaBlend(color, back,
 101.423 -				                      coeff[COLEV & 0x1F],
 101.424 -				                      coeff[(COLEV >> 8) & 0x1F]);
 101.425 -			else
 101.426 -			{
 101.427 -				switch ((BLDMOD >> 6) & 3)
 101.428 -				{
 101.429 -				case 2:
 101.430 -					if (BLDMOD & top)
 101.431 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 101.432 -					break;
 101.433 -				case 3:
 101.434 -					if (BLDMOD & top)
 101.435 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 101.436 -					break;
 101.437 -				}
 101.438 -			}
 101.439 -		}
 101.440 -
 101.441 -		lineMix[x] = color;
 101.442 -	}
 101.443 -	gfxBG2Changed = 0;
 101.444 -	gfxLastVCOUNT = VCOUNT;
 101.445 -}
 101.446 -
   102.1 --- a/src/gba/Mode4.cpp	Sat Mar 03 10:54:39 2012 -0600
   102.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.3 @@ -1,440 +0,0 @@
   102.4 -#include "GBAGfx.h"
   102.5 -#include "GBAGlobals.h"
   102.6 -
   102.7 -void mode4RenderLine()
   102.8 -{
   102.9 -	u16 *palette = (u16 *)paletteRAM;
  102.10 -
  102.11 -	if (DISPCNT & 0x0080)
  102.12 -	{
  102.13 -		for (int x = 0; x < 240; x++)
  102.14 -		{
  102.15 -			lineMix[x] = 0x7fff;
  102.16 -		}
  102.17 -		gfxLastVCOUNT = VCOUNT;
  102.18 -		return;
  102.19 -	}
  102.20 -
  102.21 -	if (layerEnable & 0x400)
  102.22 -	{
  102.23 -		int changed = gfxBG2Changed;
  102.24 -
  102.25 -		if (gfxLastVCOUNT > VCOUNT)
  102.26 -			changed = 3;
  102.27 -
  102.28 -		gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
  102.29 -		                    BG2PA, BG2PB, BG2PC, BG2PD,
  102.30 -		                    gfxBG2X, gfxBG2Y, changed,
  102.31 -		                    line2);
  102.32 -	}
  102.33 -
  102.34 -	gfxDrawSprites(lineOBJ);
  102.35 -
  102.36 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
  102.37 -
  102.38 -	for (int x = 0; x < 240; x++)
  102.39 -	{
  102.40 -		u32 color = backdrop;
  102.41 -		u8  top   = 0x20;
  102.42 -
  102.43 -		if (line2[x] < color)
  102.44 -		{
  102.45 -			color = line2[x];
  102.46 -			top   = 0x04;
  102.47 -		}
  102.48 -
  102.49 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
  102.50 -		{
  102.51 -			color = lineOBJ[x];
  102.52 -			top   = 0x10;
  102.53 -		}
  102.54 -
  102.55 -		if ((top & 0x10) && (color & 0x00010000))
  102.56 -		{
  102.57 -			// semi-transparent OBJ
  102.58 -			u32 back = backdrop;
  102.59 -			u8  top2 = 0x20;
  102.60 -
  102.61 -			if (line2[x] < back)
  102.62 -			{
  102.63 -				back = line2[x];
  102.64 -				top2 = 0x04;
  102.65 -			}
  102.66 -
  102.67 -			if (top2 & (BLDMOD>>8))
  102.68 -				color = gfxAlphaBlend(color, back,
  102.69 -				                      coeff[COLEV & 0x1F],
  102.70 -				                      coeff[(COLEV >> 8) & 0x1F]);
  102.71 -			else
  102.72 -			{
  102.73 -				switch ((BLDMOD >> 6) & 3)
  102.74 -				{
  102.75 -				case 2:
  102.76 -					if (BLDMOD & top)
  102.77 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  102.78 -					break;
  102.79 -				case 3:
  102.80 -					if (BLDMOD & top)
  102.81 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  102.82 -					break;
  102.83 -				}
  102.84 -			}
  102.85 -		}
  102.86 -
  102.87 -		lineMix[x] = color;
  102.88 -	}
  102.89 -	gfxBG2Changed = 0;
  102.90 -	gfxLastVCOUNT = VCOUNT;
  102.91 -}
  102.92 -
  102.93 -void mode4RenderLineNoWindow()
  102.94 -{
  102.95 -	u16 *palette = (u16 *)paletteRAM;
  102.96 -
  102.97 -	if (DISPCNT & 0x0080)
  102.98 -	{
  102.99 -		for (int x = 0; x < 240; x++)
 102.100 -		{
 102.101 -			lineMix[x] = 0x7fff;
 102.102 -		}
 102.103 -		gfxLastVCOUNT = VCOUNT;
 102.104 -		return;
 102.105 -	}
 102.106 -
 102.107 -	if (layerEnable & 0x400)
 102.108 -	{
 102.109 -		int changed = gfxBG2Changed;
 102.110 -
 102.111 -		if (gfxLastVCOUNT > VCOUNT)
 102.112 -			changed = 3;
 102.113 -
 102.114 -		gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
 102.115 -		                    BG2PA, BG2PB, BG2PC, BG2PD,
 102.116 -		                    gfxBG2X, gfxBG2Y, changed,
 102.117 -		                    line2);
 102.118 -	}
 102.119 -
 102.120 -	gfxDrawSprites(lineOBJ);
 102.121 -
 102.122 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
 102.123 -
 102.124 -	for (int x = 0; x < 240; x++)
 102.125 -	{
 102.126 -		u32 color = backdrop;
 102.127 -		u8  top   = 0x20;
 102.128 -
 102.129 -		if (line2[x] < color)
 102.130 -		{
 102.131 -			color = line2[x];
 102.132 -			top   = 0x04;
 102.133 -		}
 102.134 -
 102.135 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
 102.136 -		{
 102.137 -			color = lineOBJ[x];
 102.138 -			top   = 0x10;
 102.139 -		}
 102.140 -
 102.141 -		if (!(color & 0x00010000))
 102.142 -		{
 102.143 -			switch ((BLDMOD >> 6) & 3)
 102.144 -			{
 102.145 -			case 0:
 102.146 -				break;
 102.147 -			case 1:
 102.148 -			{
 102.149 -				if (top & BLDMOD)
 102.150 -				{
 102.151 -					u32 back = backdrop;
 102.152 -					u8  top2 = 0x20;
 102.153 -
 102.154 -					if (line2[x] < back)
 102.155 -					{
 102.156 -						if (top != 0x04)
 102.157 -						{
 102.158 -							back = line2[x];
 102.159 -							top2 = 0x04;
 102.160 -						}
 102.161 -					}
 102.162 -
 102.163 -					if ((u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 102.164 -					{
 102.165 -						if (top != 0x10)
 102.166 -						{
 102.167 -							back = lineOBJ[x];
 102.168 -							top2 = 0x10;
 102.169 -						}
 102.170 -					}
 102.171 -
 102.172 -					if (top2 & (BLDMOD>>8))
 102.173 -						color = gfxAlphaBlend(color, back,
 102.174 -						                      coeff[COLEV & 0x1F],
 102.175 -						                      coeff[(COLEV >> 8) & 0x1F]);
 102.176 -				}
 102.177 -				break;
 102.178 -			}
 102.179 -			case 2:
 102.180 -				if (BLDMOD & top)
 102.181 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 102.182 -				break;
 102.183 -			case 3:
 102.184 -				if (BLDMOD & top)
 102.185 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 102.186 -				break;
 102.187 -			}
 102.188 -		}
 102.189 -		else
 102.190 -		{
 102.191 -			// semi-transparent OBJ
 102.192 -			u32 back = backdrop;
 102.193 -			u8  top2 = 0x20;
 102.194 -
 102.195 -			if (line2[x] < back)
 102.196 -			{
 102.197 -				back = line2[x];
 102.198 -				top2 = 0x04;
 102.199 -			}
 102.200 -
 102.201 -			if (top2 & (BLDMOD>>8))
 102.202 -				color = gfxAlphaBlend(color, back,
 102.203 -				                      coeff[COLEV & 0x1F],
 102.204 -				                      coeff[(COLEV >> 8) & 0x1F]);
 102.205 -			else
 102.206 -			{
 102.207 -				switch ((BLDMOD >> 6) & 3)
 102.208 -				{
 102.209 -				case 2:
 102.210 -					if (BLDMOD & top)
 102.211 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 102.212 -					break;
 102.213 -				case 3:
 102.214 -					if (BLDMOD & top)
 102.215 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 102.216 -					break;
 102.217 -				}
 102.218 -			}
 102.219 -		}
 102.220 -
 102.221 -		lineMix[x] = color;
 102.222 -	}
 102.223 -	gfxBG2Changed = 0;
 102.224 -	gfxLastVCOUNT = VCOUNT;
 102.225 -}
 102.226 -
 102.227 -void mode4RenderLineAll()
 102.228 -{
 102.229 -	u16 *palette = (u16 *)paletteRAM;
 102.230 -
 102.231 -	if (DISPCNT & 0x0080)
 102.232 -	{
 102.233 -		for (int x = 0; x < 240; x++)
 102.234 -		{
 102.235 -			lineMix[x] = 0x7fff;
 102.236 -		}
 102.237 -		gfxLastVCOUNT = VCOUNT;
 102.238 -		return;
 102.239 -	}
 102.240 -
 102.241 -	bool inWindow0 = false;
 102.242 -	bool inWindow1 = false;
 102.243 -
 102.244 -	if (layerEnable & 0x2000)
 102.245 -	{
 102.246 -		u8 v0 = WIN0V >> 8;
 102.247 -		u8 v1 = WIN0V & 255;
 102.248 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
 102.249 -		if (v1 >= v0)
 102.250 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
 102.251 -		else
 102.252 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
 102.253 -	}
 102.254 -	if (layerEnable & 0x4000)
 102.255 -	{
 102.256 -		u8 v0 = WIN1V >> 8;
 102.257 -		u8 v1 = WIN1V & 255;
 102.258 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
 102.259 -		if (v1 >= v0)
 102.260 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
 102.261 -		else
 102.262 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
 102.263 -	}
 102.264 -
 102.265 -	if (layerEnable & 0x400)
 102.266 -	{
 102.267 -		int changed = gfxBG2Changed;
 102.268 -
 102.269 -		if (gfxLastVCOUNT > VCOUNT)
 102.270 -			changed = 3;
 102.271 -
 102.272 -		gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
 102.273 -		                    BG2PA, BG2PB, BG2PC, BG2PD,
 102.274 -		                    gfxBG2X, gfxBG2Y, changed,
 102.275 -		                    line2);
 102.276 -	}
 102.277 -
 102.278 -	gfxDrawSprites(lineOBJ);
 102.279 -	gfxDrawOBJWin(lineOBJWin);
 102.280 -
 102.281 -	u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
 102.282 -
 102.283 -	u8 inWin0Mask = WININ & 0xFF;
 102.284 -	u8 inWin1Mask = WININ >> 8;
 102.285 -	u8 outMask    = WINOUT & 0xFF;
 102.286 -
 102.287 -	for (int x = 0; x < 240; x++)
 102.288 -	{
 102.289 -		u32 color = backdrop;
 102.290 -		u8  top   = 0x20;
 102.291 -		u8  mask  = outMask;
 102.292 -
 102.293 -		if (!(lineOBJWin[x] & 0x80000000))
 102.294 -		{
 102.295 -			mask = WINOUT >> 8;
 102.296 -		}
 102.297 -
 102.298 -		if (inWindow1)
 102.299 -		{
 102.300 -			if (gfxInWin1[x])
 102.301 -				mask = inWin1Mask;
 102.302 -		}
 102.303 -
 102.304 -		if (inWindow0)
 102.305 -		{
 102.306 -			if (gfxInWin0[x])
 102.307 -			{
 102.308 -				mask = inWin0Mask;
 102.309 -			}
 102.310 -		}
 102.311 -
 102.312 -		if ((mask & 4) && (line2[x] < color))
 102.313 -		{
 102.314 -			color = line2[x];
 102.315 -			top   = 0x04;
 102.316 -		}
 102.317 -
 102.318 -		if ((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24)))
 102.319 -		{
 102.320 -			color = lineOBJ[x];
 102.321 -			top   = 0x10;
 102.322 -		}
 102.323 -
 102.324 -		if (mask & 32)
 102.325 -		{
 102.326 -			if (!(color & 0x00010000))
 102.327 -			{
 102.328 -				switch ((BLDMOD >> 6) & 3)
 102.329 -				{
 102.330 -				case 0:
 102.331 -					break;
 102.332 -				case 1:
 102.333 -				{
 102.334 -					if (top & BLDMOD)
 102.335 -					{
 102.336 -						u32 back = backdrop;
 102.337 -						u8  top2 = 0x20;
 102.338 -
 102.339 -						if ((mask & 4) && line2[x] < back)
 102.340 -						{
 102.341 -							if (top != 0x04)
 102.342 -							{
 102.343 -								back = line2[x];
 102.344 -								top2 = 0x04;
 102.345 -							}
 102.346 -						}
 102.347 -
 102.348 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 102.349 -						{
 102.350 -							if (top != 0x10)
 102.351 -							{
 102.352 -								back = lineOBJ[x];
 102.353 -								top2 = 0x10;
 102.354 -							}
 102.355 -						}
 102.356 -
 102.357 -						if (top2 & (BLDMOD>>8))
 102.358 -							color = gfxAlphaBlend(color, back,
 102.359 -							                      coeff[COLEV & 0x1F],
 102.360 -							                      coeff[(COLEV >> 8) & 0x1F]);
 102.361 -					}
 102.362 -					break;
 102.363 -				}
 102.364 -				case 2:
 102.365 -					if (BLDMOD & top)
 102.366 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 102.367 -					break;
 102.368 -				case 3:
 102.369 -					if (BLDMOD & top)
 102.370 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 102.371 -					break;
 102.372 -				}
 102.373 -			}
 102.374 -			else
 102.375 -			{
 102.376 -				// semi-transparent OBJ
 102.377 -				u32 back = backdrop;
 102.378 -				u8  top2 = 0x20;
 102.379 -
 102.380 -				if ((mask & 4) && line2[x] < back)
 102.381 -				{
 102.382 -					back = line2[x];
 102.383 -					top2 = 0x04;
 102.384 -				}
 102.385 -
 102.386 -				if (top2 & (BLDMOD>>8))
 102.387 -					color = gfxAlphaBlend(color, back,
 102.388 -					                      coeff[COLEV & 0x1F],
 102.389 -					                      coeff[(COLEV >> 8) & 0x1F]);
 102.390 -				else
 102.391 -				{
 102.392 -					switch ((BLDMOD >> 6) & 3)
 102.393 -					{
 102.394 -					case 2:
 102.395 -						if (BLDMOD & top)
 102.396 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 102.397 -						break;
 102.398 -					case 3:
 102.399 -						if (BLDMOD & top)
 102.400 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 102.401 -						break;
 102.402 -					}
 102.403 -				}
 102.404 -			}
 102.405 -		}
 102.406 -		else if (color & 0x00010000)
 102.407 -		{
 102.408 -			// semi-transparent OBJ
 102.409 -			u32 back = backdrop;
 102.410 -			u8  top2 = 0x20;
 102.411 -
 102.412 -			if ((mask & 4) && line2[x] < back)
 102.413 -			{
 102.414 -				back = line2[x];
 102.415 -				top2 = 0x04;
 102.416 -			}
 102.417 -
 102.418 -			if (top2 & (BLDMOD>>8))
 102.419 -				color = gfxAlphaBlend(color, back,
 102.420 -				                      coeff[COLEV & 0x1F],
 102.421 -				                      coeff[(COLEV >> 8) & 0x1F]);
 102.422 -			else
 102.423 -			{
 102.424 -				switch ((BLDMOD >> 6) & 3)
 102.425 -				{
 102.426 -				case 2:
 102.427 -					if (BLDMOD & top)
 102.428 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 102.429 -					break;
 102.430 -				case 3:
 102.431 -					if (BLDMOD & top)
 102.432 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 102.433 -					break;
 102.434 -				}
 102.435 -			}
 102.436 -		}
 102.437 -
 102.438 -		lineMix[x] = color;
 102.439 -	}
 102.440 -	gfxBG2Changed = 0;
 102.441 -	gfxLastVCOUNT = VCOUNT;
 102.442 -}
 102.443 -
   103.1 --- a/src/gba/Mode5.cpp	Sat Mar 03 10:54:39 2012 -0600
   103.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.3 @@ -1,443 +0,0 @@
   103.4 -#include "GBAGfx.h"
   103.5 -#include "GBAGlobals.h"
   103.6 -
   103.7 -void mode5RenderLine()
   103.8 -{
   103.9 -	if (DISPCNT & 0x0080)
  103.10 -	{
  103.11 -		for (int x = 0; x < 240; x++)
  103.12 -		{
  103.13 -			lineMix[x] = 0x7fff;
  103.14 -		}
  103.15 -		gfxLastVCOUNT = VCOUNT;
  103.16 -		return;
  103.17 -	}
  103.18 -
  103.19 -	u16 *palette = (u16 *)paletteRAM;
  103.20 -
  103.21 -	if (layerEnable & 0x0400)
  103.22 -	{
  103.23 -		int changed = gfxBG2Changed;
  103.24 -
  103.25 -		if (gfxLastVCOUNT > VCOUNT)
  103.26 -			changed = 3;
  103.27 -
  103.28 -		gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
  103.29 -		                         BG2Y_L, BG2Y_H, BG2PA, BG2PB,
  103.30 -		                         BG2PC, BG2PD,
  103.31 -		                         gfxBG2X, gfxBG2Y, changed,
  103.32 -		                         line2);
  103.33 -	}
  103.34 -
  103.35 -	gfxDrawSprites(lineOBJ);
  103.36 -
  103.37 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
  103.38 -
  103.39 -	for (int x = 0; x < 240; x++)
  103.40 -	{
  103.41 -		u32 color = background;
  103.42 -		u8  top   = 0x20;
  103.43 -
  103.44 -		if (line2[x] < color)
  103.45 -		{
  103.46 -			color = line2[x];
  103.47 -			top   = 0x04;
  103.48 -		}
  103.49 -
  103.50 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))
  103.51 -		{
  103.52 -			color = lineOBJ[x];
  103.53 -			top   = 0x10;
  103.54 -		}
  103.55 -
  103.56 -		if ((top & 0x10) && (color & 0x00010000))
  103.57 -		{
  103.58 -			// semi-transparent OBJ
  103.59 -			u32 back = background;
  103.60 -			u8  top2 = 0x20;
  103.61 -
  103.62 -			if (line2[x] < back)
  103.63 -			{
  103.64 -				back = line2[x];
  103.65 -				top2 = 0x04;
  103.66 -			}
  103.67 -
  103.68 -			if (top2 & (BLDMOD>>8))
  103.69 -				color = gfxAlphaBlend(color, back,
  103.70 -				                      coeff[COLEV & 0x1F],
  103.71 -				                      coeff[(COLEV >> 8) & 0x1F]);
  103.72 -			else
  103.73 -			{
  103.74 -				switch ((BLDMOD >> 6) & 3)
  103.75 -				{
  103.76 -				case 2:
  103.77 -					if (BLDMOD & top)
  103.78 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
  103.79 -					break;
  103.80 -				case 3:
  103.81 -					if (BLDMOD & top)
  103.82 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
  103.83 -					break;
  103.84 -				}
  103.85 -			}
  103.86 -		}
  103.87 -
  103.88 -		lineMix[x] = color;
  103.89 -	}
  103.90 -	gfxBG2Changed = 0;
  103.91 -	gfxLastVCOUNT = VCOUNT;
  103.92 -}
  103.93 -
  103.94 -void mode5RenderLineNoWindow()
  103.95 -{
  103.96 -	if (DISPCNT & 0x0080)
  103.97 -	{
  103.98 -		for (int x = 0; x < 240; x++)
  103.99 -		{
 103.100 -			lineMix[x] = 0x7fff;
 103.101 -		}
 103.102 -		gfxLastVCOUNT = VCOUNT;
 103.103 -		return;
 103.104 -	}
 103.105 -
 103.106 -	u16 *palette = (u16 *)paletteRAM;
 103.107 -
 103.108 -	if (layerEnable & 0x0400)
 103.109 -	{
 103.110 -		int changed = gfxBG2Changed;
 103.111 -
 103.112 -		if (gfxLastVCOUNT > VCOUNT)
 103.113 -			changed = 3;
 103.114 -
 103.115 -		gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
 103.116 -		                         BG2Y_L, BG2Y_H, BG2PA, BG2PB,
 103.117 -		                         BG2PC, BG2PD,
 103.118 -		                         gfxBG2X, gfxBG2Y, changed,
 103.119 -		                         line2);
 103.120 -	}
 103.121 -
 103.122 -	gfxDrawSprites(lineOBJ);
 103.123 -
 103.124 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
 103.125 -
 103.126 -	for (int x = 0; x < 240; x++)
 103.127 -	{
 103.128 -		u32 color = background;
 103.129 -		u8  top   = 0x20;
 103.130 -
 103.131 -		if (line2[x] < color)
 103.132 -		{
 103.133 -			color = line2[x];
 103.134 -			top   = 0x04;
 103.135 -		}
 103.136 -
 103.137 -		if ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))
 103.138 -		{
 103.139 -			color = lineOBJ[x];
 103.140 -			top   = 0x10;
 103.141 -		}
 103.142 -
 103.143 -		if (!(color & 0x00010000))
 103.144 -		{
 103.145 -			switch ((BLDMOD >> 6) & 3)
 103.146 -			{
 103.147 -			case 0:
 103.148 -				break;
 103.149 -			case 1:
 103.150 -			{
 103.151 -				if (top & BLDMOD)
 103.152 -				{
 103.153 -					u32 back = background;
 103.154 -					u8  top2 = 0x20;
 103.155 -
 103.156 -					if (line2[x] < back)
 103.157 -					{
 103.158 -						if (top != 0x04)
 103.159 -						{
 103.160 -							back = line2[x];
 103.161 -							top2 = 0x04;
 103.162 -						}
 103.163 -					}
 103.164 -
 103.165 -					if ((u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 103.166 -					{
 103.167 -						if (top != 0x10)
 103.168 -						{
 103.169 -							back = lineOBJ[x];
 103.170 -							top2 = 0x10;
 103.171 -						}
 103.172 -					}
 103.173 -
 103.174 -					if (top2 & (BLDMOD>>8))
 103.175 -						color = gfxAlphaBlend(color, back,
 103.176 -						                      coeff[COLEV & 0x1F],
 103.177 -						                      coeff[(COLEV >> 8) & 0x1F]);
 103.178 -				}
 103.179 -				break;
 103.180 -			}
 103.181 -			case 2:
 103.182 -				if (BLDMOD & top)
 103.183 -					color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 103.184 -				break;
 103.185 -			case 3:
 103.186 -				if (BLDMOD & top)
 103.187 -					color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 103.188 -				break;
 103.189 -			}
 103.190 -		}
 103.191 -		else
 103.192 -		{
 103.193 -			// semi-transparent OBJ
 103.194 -			u32 back = background;
 103.195 -			u8  top2 = 0x20;
 103.196 -
 103.197 -			if (line2[x] < back)
 103.198 -			{
 103.199 -				back = line2[x];
 103.200 -				top2 = 0x04;
 103.201 -			}
 103.202 -
 103.203 -			if (top2 & (BLDMOD>>8))
 103.204 -				color = gfxAlphaBlend(color, back,
 103.205 -				                      coeff[COLEV & 0x1F],
 103.206 -				                      coeff[(COLEV >> 8) & 0x1F]);
 103.207 -			else
 103.208 -			{
 103.209 -				switch ((BLDMOD >> 6) & 3)
 103.210 -				{
 103.211 -				case 2:
 103.212 -					if (BLDMOD & top)
 103.213 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 103.214 -					break;
 103.215 -				case 3:
 103.216 -					if (BLDMOD & top)
 103.217 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 103.218 -					break;
 103.219 -				}
 103.220 -			}
 103.221 -		}
 103.222 -
 103.223 -		lineMix[x] = color;
 103.224 -	}
 103.225 -	gfxBG2Changed = 0;
 103.226 -	gfxLastVCOUNT = VCOUNT;
 103.227 -}
 103.228 -
 103.229 -void mode5RenderLineAll()
 103.230 -{
 103.231 -	if (DISPCNT & 0x0080)
 103.232 -	{
 103.233 -		for (int x = 0; x < 240; x++)
 103.234 -		{
 103.235 -			lineMix[x] = 0x7fff;
 103.236 -		}
 103.237 -		gfxLastVCOUNT = VCOUNT;
 103.238 -		return;
 103.239 -	}
 103.240 -
 103.241 -	u16 *palette = (u16 *)paletteRAM;
 103.242 -
 103.243 -	if (layerEnable & 0x0400)
 103.244 -	{
 103.245 -		int changed = gfxBG2Changed;
 103.246 -
 103.247 -		if (gfxLastVCOUNT > VCOUNT)
 103.248 -			changed = 3;
 103.249 -
 103.250 -		gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
 103.251 -		                         BG2Y_L, BG2Y_H, BG2PA, BG2PB,
 103.252 -		                         BG2PC, BG2PD,
 103.253 -		                         gfxBG2X, gfxBG2Y, changed,
 103.254 -		                         line2);
 103.255 -	}
 103.256 -
 103.257 -	gfxDrawSprites(lineOBJ);
 103.258 -	gfxDrawOBJWin(lineOBJWin);
 103.259 -
 103.260 -	bool inWindow0 = false;
 103.261 -	bool inWindow1 = false;
 103.262 -
 103.263 -	if (layerEnable & 0x2000)
 103.264 -	{
 103.265 -		u8 v0 = WIN0V >> 8;
 103.266 -		u8 v1 = WIN0V & 255;
 103.267 -		inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
 103.268 -		if (v1 >= v0)
 103.269 -			inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
 103.270 -		else
 103.271 -			inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
 103.272 -	}
 103.273 -	if (layerEnable & 0x4000)
 103.274 -	{
 103.275 -		u8 v0 = WIN1V >> 8;
 103.276 -		u8 v1 = WIN1V & 255;
 103.277 -		inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
 103.278 -		if (v1 >= v0)
 103.279 -			inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
 103.280 -		else
 103.281 -			inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
 103.282 -	}
 103.283 -
 103.284 -	u8 inWin0Mask = WININ & 0xFF;
 103.285 -	u8 inWin1Mask = WININ >> 8;
 103.286 -	u8 outMask    = WINOUT & 0xFF;
 103.287 -
 103.288 -	u32 background = (READ16LE(&palette[0]) | 0x30000000);
 103.289 -
 103.290 -	for (int x = 0; x < 240; x++)
 103.291 -	{
 103.292 -		u32 color = background;
 103.293 -		u8  top   = 0x20;
 103.294 -		u8  mask  = outMask;
 103.295 -
 103.296 -		if (!(lineOBJWin[x] & 0x80000000))
 103.297 -		{
 103.298 -			mask = WINOUT >> 8;
 103.299 -		}
 103.300 -
 103.301 -		if (inWindow1)
 103.302 -		{
 103.303 -			if (gfxInWin1[x])
 103.304 -				mask = inWin1Mask;
 103.305 -		}
 103.306 -
 103.307 -		if (inWindow0)
 103.308 -		{
 103.309 -			if (gfxInWin0[x])
 103.310 -			{
 103.311 -				mask = inWin0Mask;
 103.312 -			}
 103.313 -		}
 103.314 -
 103.315 -		if ((mask & 4) && (line2[x] < color))
 103.316 -		{
 103.317 -			color = line2[x];
 103.318 -			top   = 0x04;
 103.319 -		}
 103.320 -
 103.321 -		if ((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24)))
 103.322 -		{
 103.323 -			color = lineOBJ[x];
 103.324 -			top   = 0x10;
 103.325 -		}
 103.326 -
 103.327 -		if (mask & 32)
 103.328 -		{
 103.329 -			if (!(color & 0x00010000))
 103.330 -			{
 103.331 -				switch ((BLDMOD >> 6) & 3)
 103.332 -				{
 103.333 -				case 0:
 103.334 -					break;
 103.335 -				case 1:
 103.336 -				{
 103.337 -					if (top & BLDMOD)
 103.338 -					{
 103.339 -						u32 back = background;
 103.340 -						u8  top2 = 0x20;
 103.341 -
 103.342 -						if ((mask & 4) && line2[x] < back)
 103.343 -						{
 103.344 -							if (top != 0x04)
 103.345 -							{
 103.346 -								back = line2[x];
 103.347 -								top2 = 0x04;
 103.348 -							}
 103.349 -						}
 103.350 -
 103.351 -						if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
 103.352 -						{
 103.353 -							if (top != 0x10)
 103.354 -							{
 103.355 -								back = lineOBJ[x];
 103.356 -								top2 = 0x10;
 103.357 -							}
 103.358 -						}
 103.359 -
 103.360 -						if (top2 & (BLDMOD>>8))
 103.361 -							color = gfxAlphaBlend(color, back,
 103.362 -							                      coeff[COLEV & 0x1F],
 103.363 -							                      coeff[(COLEV >> 8) & 0x1F]);
 103.364 -					}
 103.365 -					break;
 103.366 -				}
 103.367 -				case 2:
 103.368 -					if (BLDMOD & top)
 103.369 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 103.370 -					break;
 103.371 -				case 3:
 103.372 -					if (BLDMOD & top)
 103.373 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 103.374 -					break;
 103.375 -				}
 103.376 -			}
 103.377 -			else
 103.378 -			{
 103.379 -				// semi-transparent OBJ
 103.380 -				u32 back = background;
 103.381 -				u8  top2 = 0x20;
 103.382 -
 103.383 -				if ((mask & 4) && line2[x] < back)
 103.384 -				{
 103.385 -					back = line2[x];
 103.386 -					top2 = 0x04;
 103.387 -				}
 103.388 -
 103.389 -				if (top2 & (BLDMOD>>8))
 103.390 -					color = gfxAlphaBlend(color, back,
 103.391 -					                      coeff[COLEV & 0x1F],
 103.392 -					                      coeff[(COLEV >> 8) & 0x1F]);
 103.393 -				else
 103.394 -				{
 103.395 -					switch ((BLDMOD >> 6) & 3)
 103.396 -					{
 103.397 -					case 2:
 103.398 -						if (BLDMOD & top)
 103.399 -							color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 103.400 -						break;
 103.401 -					case 3:
 103.402 -						if (BLDMOD & top)
 103.403 -							color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 103.404 -						break;
 103.405 -					}
 103.406 -				}
 103.407 -			}
 103.408 -		}
 103.409 -		else if (color & 0x00010000)
 103.410 -		{
 103.411 -			// semi-transparent OBJ
 103.412 -			u32 back = background;
 103.413 -			u8  top2 = 0x20;
 103.414 -
 103.415 -			if ((mask & 4) && line2[x] < back)
 103.416 -			{
 103.417 -				back = line2[x];
 103.418 -				top2 = 0x04;
 103.419 -			}
 103.420 -
 103.421 -			if (top2 & (BLDMOD>>8))
 103.422 -				color = gfxAlphaBlend(color, back,
 103.423 -				                      coeff[COLEV & 0x1F],
 103.424 -				                      coeff[(COLEV >> 8) & 0x1F]);
 103.425 -			else
 103.426 -			{
 103.427 -				switch ((BLDMOD >> 6) & 3)
 103.428 -				{
 103.429 -				case 2:
 103.430 -					if (BLDMOD & top)
 103.431 -						color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
 103.432 -					break;
 103.433 -				case 3:
 103.434 -					if (BLDMOD & top)
 103.435 -						color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
 103.436 -					break;
 103.437 -				}
 103.438 -			}
 103.439 -		}
 103.440 -
 103.441 -		lineMix[x] = color;
 103.442 -	}
 103.443 -	gfxBG2Changed = 0;
 103.444 -	gfxLastVCOUNT = VCOUNT;
 103.445 -}
 103.446 -
   104.1 --- a/src/gba/RTC.cpp	Sat Mar 03 10:54:39 2012 -0600
   104.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.3 @@ -1,240 +0,0 @@
   104.4 -#include <cstring>
   104.5 -
   104.6 -#include "../Port.h"
   104.7 -#include "../NLS.h"
   104.8 -#include "../common/System.h" // systemMessage
   104.9 -#include "../common/Util.h"
  104.10 -#include "../common/movie.h"
  104.11 -#include "GBAGlobals.h"
  104.12 -
  104.13 -enum RTCSTATE { IDLE, COMMAND, DATA, READDATA };
  104.14 -
  104.15 -typedef struct
  104.16 -{
  104.17 -	u8       byte0;
  104.18 -	u8       byte1;
  104.19 -	u8       byte2;
  104.20 -	u8       command;
  104.21 -	int      dataLen;
  104.22 -	int      bits;
  104.23 -	RTCSTATE state;
  104.24 -	u8       data[12];
  104.25 -	// reserved variables for future
  104.26 -	u8   reserved[12];
  104.27 -	bool reserved2;
  104.28 -	u32  reserved3;
  104.29 -} RTCCLOCKDATA;
  104.30 -
  104.31 -static RTCCLOCKDATA rtcClockData;
  104.32 -static bool         rtcEnabled = false;
  104.33 -
  104.34 -void rtcEnable(bool enable)
  104.35 -{
  104.36 -	rtcEnabled = enable;
  104.37 -}
  104.38 -
  104.39 -bool rtcIsEnabled()
  104.40 -{
  104.41 -	return rtcEnabled;
  104.42 -}
  104.43 -
  104.44 -u16 rtcRead(u32 address)
  104.45 -{
  104.46 -	if (rtcEnabled)
  104.47 -	{
  104.48 -		if (address == 0x80000c8)
  104.49 -			return rtcClockData.byte2;
  104.50 -		else if (address == 0x80000c6)
  104.51 -			return rtcClockData.byte1;
  104.52 -		else if (address == 0x80000c4)
  104.53 -		{
  104.54 -			return rtcClockData.byte0;
  104.55 -		}
  104.56 -	}
  104.57 -
  104.58 -	return READ16LE((&rom[address & 0x1FFFFFE]));
  104.59 -}
  104.60 -
  104.61 -static u8 toBCD(u8 value)
  104.62 -{
  104.63 -	value = value % 100;
  104.64 -	int l = value % 10;
  104.65 -	int h = value / 10;
  104.66 -	return h * 16 + l;
  104.67 -}
  104.68 -
  104.69 -bool rtcWrite(u32 address, u16 value)
  104.70 -{
  104.71 -	if (!rtcEnabled)
  104.72 -		return false;
  104.73 -
  104.74 -	if (address == 0x80000c8)
  104.75 -	{
  104.76 -		rtcClockData.byte2 = (u8)value; // enable ?
  104.77 -	}
  104.78 -	else if (address == 0x80000c6)
  104.79 -	{
  104.80 -		rtcClockData.byte1 = (u8)value; // read/write
  104.81 -	}
  104.82 -	else if (address == 0x80000c4)
  104.83 -	{
  104.84 -		if (rtcClockData.byte2 & 1)
  104.85 -		{
  104.86 -			if (rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5)
  104.87 -			{
  104.88 -				rtcClockData.state   = COMMAND;
  104.89 -				rtcClockData.bits    = 0;
  104.90 -				rtcClockData.command = 0;
  104.91 -			}
  104.92 -			else if (!(rtcClockData.byte0 & 1) && (value & 1)) // bit transfer
  104.93 -			{
  104.94 -				rtcClockData.byte0 = (u8)value;
  104.95 -				switch (rtcClockData.state)
  104.96 -				{
  104.97 -				case COMMAND:
  104.98 -					rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits);
  104.99 -					rtcClockData.bits++;
 104.100 -					if (rtcClockData.bits == 8)
 104.101 -					{
 104.102 -						rtcClockData.bits = 0;
 104.103 -						switch (rtcClockData.command)
 104.104 -						{
 104.105 -						case 0x60:
 104.106 -							// not sure what this command does but it doesn't take parameters
 104.107 -							// maybe it is a reset or stop
 104.108 -							rtcClockData.state = IDLE;
 104.109 -							rtcClockData.bits  = 0;
 104.110 -							break;
 104.111 -						case 0x62:
 104.112 -							// this sets the control state but not sure what those values are
 104.113 -							rtcClockData.state   = READDATA;
 104.114 -							rtcClockData.dataLen = 1;
 104.115 -							break;
 104.116 -						case 0x63:
 104.117 -							rtcClockData.dataLen = 1;
 104.118 -							rtcClockData.data[0] = 0x40;
 104.119 -							rtcClockData.state   = DATA;
 104.120 -							break;
 104.121 -						case 0x65:
 104.122 -						{
 104.123 -							struct tm *newtime;
 104.124 -							time_t     long_time;
 104.125 -
 104.126 -							if (VBAMovieActive() || VBAMovieLoading())
 104.127 -							{
 104.128 -								long_time = VBAMovieGetId() + VBAMovieGetFrameCounter()/60;
 104.129 -								newtime   = gmtime(&long_time);
 104.130 -							}
 104.131 -							else
 104.132 -							{
 104.133 -								time(&long_time);      /* Get time as long integer. */
 104.134 -								newtime = localtime(&long_time); /* Convert to local time. */
 104.135 -							}
 104.136 -
 104.137 -							rtcClockData.dataLen = 7;
 104.138 -							rtcClockData.data[0] = toBCD(newtime->tm_year);
 104.139 -							rtcClockData.data[1] = toBCD(newtime->tm_mon+1);
 104.140 -							rtcClockData.data[2] = toBCD(newtime->tm_mday);
 104.141 -							rtcClockData.data[3] = 0;
 104.142 -							rtcClockData.data[4] = toBCD(newtime->tm_hour);
 104.143 -							rtcClockData.data[5] = toBCD(newtime->tm_min);
 104.144 -							rtcClockData.data[6] = toBCD(newtime->tm_sec);
 104.145 -							rtcClockData.state   = DATA;
 104.146 -							break;
 104.147 -						}
 104.148 -						case 0x67:
 104.149 -						{
 104.150 -							struct tm *newtime;
 104.151 -							time_t     long_time;
 104.152 -
 104.153 -							if (VBAMovieActive() || VBAMovieLoading())
 104.154 -							{
 104.155 -								long_time = VBAMovieGetId() + VBAMovieGetFrameCounter()/60;
 104.156 -								newtime   = gmtime(&long_time);
 104.157 -							}
 104.158 -							else
 104.159 -							{
 104.160 -								time(&long_time);      /* Get time as long integer. */
 104.161 -								newtime = localtime(&long_time); /* Convert to local time. */
 104.162 -							}
 104.163 -
 104.164 -							rtcClockData.dataLen = 3;
 104.165 -							rtcClockData.data[0] = toBCD(newtime->tm_hour);
 104.166 -							rtcClockData.data[1] = toBCD(newtime->tm_min);
 104.167 -							rtcClockData.data[2] = toBCD(newtime->tm_sec);
 104.168 -							rtcClockData.state   = DATA;
 104.169 -							break;
 104.170 -						}
 104.171 -						default:
 104.172 -							systemMessage(0, N_("Unknown RTC command %02x"), rtcClockData.command);
 104.173 -							rtcClockData.state = IDLE;
 104.174 -							break;
 104.175 -						}
 104.176 -					}
 104.177 -					break;
 104.178 -				case DATA:
 104.179 -					if (rtcClockData.byte1 & 2)
 104.180 -					{}
 104.181 -					else
 104.182 -					{
 104.183 -						rtcClockData.byte0 = (rtcClockData.byte0 & ~2) |
 104.184 -						                     ((rtcClockData.data[rtcClockData.bits >> 3] >>
 104.185 -						                       (rtcClockData.bits & 7)) & 1)*2;
 104.186 -						rtcClockData.bits++;
 104.187 -						if (rtcClockData.bits == 8*rtcClockData.dataLen)
 104.188 -						{
 104.189 -							rtcClockData.bits  = 0;
 104.190 -							rtcClockData.state = IDLE;
 104.191 -						}
 104.192 -					}
 104.193 -					break;
 104.194 -				case READDATA:
 104.195 -					if (!(rtcClockData.byte1 & 2))
 104.196 -					{}
 104.197 -					else
 104.198 -					{
 104.199 -						rtcClockData.data[rtcClockData.bits >> 3] =
 104.200 -						    (rtcClockData.data[rtcClockData.bits >> 3] >> 1) |
 104.201 -						    ((value << 6) & 128);
 104.202 -						rtcClockData.bits++;
 104.203 -						if (rtcClockData.bits == 8*rtcClockData.dataLen)
 104.204 -						{
 104.205 -							rtcClockData.bits  = 0;
 104.206 -							rtcClockData.state = IDLE;
 104.207 -						}
 104.208 -					}
 104.209 -					break;
 104.210 -				default:
 104.211 -					break;
 104.212 -				}
 104.213 -			}
 104.214 -			else
 104.215 -				rtcClockData.byte0 = (u8)value;
 104.216 -		}
 104.217 -	}
 104.218 -	return true;
 104.219 -}
 104.220 -
 104.221 -void rtcReset()
 104.222 -{
 104.223 -	memset(&rtcClockData, 0, sizeof(rtcClockData));
 104.224 -
 104.225 -	rtcClockData.byte0   = 0;
 104.226 -	rtcClockData.byte1   = 0;
 104.227 -	rtcClockData.byte2   = 0;
 104.228 -	rtcClockData.command = 0;
 104.229 -	rtcClockData.dataLen = 0;
 104.230 -	rtcClockData.bits    = 0;
 104.231 -	rtcClockData.state   = IDLE;
 104.232 -}
 104.233 -
 104.234 -void rtcSaveGame(gzFile gzFile)
 104.235 -{
 104.236 -	utilGzWrite(gzFile, &rtcClockData, sizeof(rtcClockData));
 104.237 -}
 104.238 -
 104.239 -void rtcReadGame(gzFile gzFile)
 104.240 -{
 104.241 -	utilGzRead(gzFile, &rtcClockData, sizeof(rtcClockData));
 104.242 -}
 104.243 -
   105.1 --- a/src/gba/RTC.h	Sat Mar 03 10:54:39 2012 -0600
   105.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.3 @@ -1,17 +0,0 @@
   105.4 -#ifndef VBA_RTC_H
   105.5 -#define VBA_RTC_H
   105.6 -
   105.7 -#if _MSC_VER > 1000
   105.8 -#pragma once
   105.9 -#endif // _MSC_VER > 1000
  105.10 -
  105.11 -extern u16 rtcRead(u32 address);
  105.12 -extern bool rtcWrite(u32 address, u16 value);
  105.13 -extern void rtcEnable(bool);
  105.14 -extern bool rtcIsEnabled();
  105.15 -extern void rtcReset();
  105.16 -
  105.17 -extern void rtcReadGame(gzFile gzFile);
  105.18 -extern void rtcSaveGame(gzFile gzFile);
  105.19 -
  105.20 -#endif // VBA_RTC_H
   106.1 --- a/src/gba/Sram.cpp	Sat Mar 03 10:54:39 2012 -0600
   106.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.3 @@ -1,15 +0,0 @@
   106.4 -#include "../common/System.h"
   106.5 -#include "Flash.h"
   106.6 -#include "Sram.h"
   106.7 -
   106.8 -u8 sramRead(u32 address)
   106.9 -{
  106.10 -	return flashSaveMemory[address & 0xFFFF];
  106.11 -}
  106.12 -
  106.13 -void sramWrite(u32 address, u8 byte)
  106.14 -{
  106.15 -	flashSaveMemory[address & 0xFFFF] = byte;
  106.16 -	systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
  106.17 -}
  106.18 -
   107.1 --- a/src/gba/Sram.h	Sat Mar 03 10:54:39 2012 -0600
   107.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.3 @@ -1,11 +0,0 @@
   107.4 -#ifndef VBA_SRAM_H
   107.5 -#define VBA_SRAM_H
   107.6 -
   107.7 -#if _MSC_VER > 1000
   107.8 -#pragma once
   107.9 -#endif // _MSC_VER > 1000
  107.10 -
  107.11 -extern u8 sramRead(u32 address);
  107.12 -extern void sramWrite(u32 address, u8 byte);
  107.13 -
  107.14 -#endif // VBA_SRAM_H
   108.1 --- a/src/gba/agbprint.cpp	Sat Mar 03 10:54:39 2012 -0600
   108.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.3 @@ -1,82 +0,0 @@
   108.4 -#include <cstdio>
   108.5 -#include <cstring>
   108.6 -
   108.7 -#include "GBAGlobals.h"
   108.8 -
   108.9 -extern void (*dbgOutput)(char *, u32);
  108.10 -extern int systemVerbose;
  108.11 -
  108.12 -static bool agbPrintEnabled = false;
  108.13 -static bool agbPrintProtect = false;
  108.14 -
  108.15 -bool agbPrintWrite(u32 address, u16 value)
  108.16 -{
  108.17 -	if (agbPrintEnabled)
  108.18 -	{
  108.19 -		if (address == 0x9fe2ffe) // protect
  108.20 -		{
  108.21 -			agbPrintProtect = (value != 0);
  108.22 -			debuggerWriteHalfWord(address, value);
  108.23 -			return true;
  108.24 -		}
  108.25 -		else
  108.26 -		{
  108.27 -			if (agbPrintProtect &&
  108.28 -			    ((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure
  108.29 -			     || (address >= 0x8fd0000 && address <= 0x8fdffff)
  108.30 -			     || (address >= 0x9fd0000 && address <= 0x9fdffff)))
  108.31 -			{
  108.32 -				debuggerWriteHalfWord(address, value);
  108.33 -				return true;
  108.34 -			}
  108.35 -		}
  108.36 -	}
  108.37 -	return false;
  108.38 -}
  108.39 -
  108.40 -void agbPrintReset()
  108.41 -{
  108.42 -	agbPrintProtect = false;
  108.43 -}
  108.44 -
  108.45 -void agbPrintEnable(bool enable)
  108.46 -{
  108.47 -	agbPrintEnabled = enable;
  108.48 -}
  108.49 -
  108.50 -bool agbPrintIsEnabled()
  108.51 -{
  108.52 -	return agbPrintEnabled;
  108.53 -}
  108.54 -
  108.55 -void agbPrintFlush()
  108.56 -{
  108.57 -	u16 get = debuggerReadHalfWord(0x9fe20fc);
  108.58 -	u16 put = debuggerReadHalfWord(0x9fe20fe);
  108.59 -
  108.60 -	u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
  108.61 -	if (address != 0xfd0000 && address != 0x1fd0000)
  108.62 -	{
  108.63 -		dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
  108.64 -		// get rid of the text otherwise we will continue to be called
  108.65 -		debuggerWriteHalfWord(0x9fe20fc, put);
  108.66 -		return;
  108.67 -	}
  108.68 -
  108.69 -	u8 *data = &rom[address];
  108.70 -
  108.71 -	while (get != put)
  108.72 -	{
  108.73 -		char c = data[get++];
  108.74 -		char s[2];
  108.75 -		s[0] = c;
  108.76 -		s[1] = 0;
  108.77 -
  108.78 -		if (systemVerbose & VERBOSE_AGBPRINT)
  108.79 -			dbgOutput(s, 0);
  108.80 -		if (c == '\n')
  108.81 -			break;
  108.82 -	}
  108.83 -	debuggerWriteHalfWord(0x9fe20fc, get);
  108.84 -}
  108.85 -
   109.1 --- a/src/gba/agbprint.h	Sat Mar 03 10:54:39 2012 -0600
   109.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   109.3 @@ -1,14 +0,0 @@
   109.4 -#ifndef VBA_AGBPRINT_H
   109.5 -#define VBA_AGBPRINT_H
   109.6 -
   109.7 -#if _MSC_VER > 1000
   109.8 -#pragma once
   109.9 -#endif // _MSC_VER > 1000
  109.10 -
  109.11 -extern void agbPrintEnable(bool);
  109.12 -extern bool agbPrintIsEnabled();
  109.13 -extern void agbPrintReset();
  109.14 -extern bool agbPrintWrite(u32, u16);
  109.15 -extern void agbPrintFlush();
  109.16 -
  109.17 -#endif // VBA_AGBPRINT_H
   110.1 --- a/src/gba/arm-new.h	Sat Mar 03 10:54:39 2012 -0600
   110.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.3 @@ -1,7453 +0,0 @@
   110.4 -#ifdef BKPT_SUPPORT
   110.5 -#define CONSOLE_OUTPUT(a, b) \
   110.6 -    extern void (*dbgOutput)(char *, u32); \
   110.7 -    if ((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) { \
   110.8 -		dbgOutput((a), (b)); \
   110.9 -	}
  110.10 -#else
  110.11 -#define CONSOLE_OUTPUT(a, b)
  110.12 -#endif
  110.13 -
  110.14 -#define OP_AND \
  110.15 -    reg[dest].I = reg[(opcode >> 16) & 15].I & value; \
  110.16 -    CONSOLE_OUTPUT(NULL, reg[2].I);
  110.17 -
  110.18 -#define OP_ANDS \
  110.19 -    reg[dest].I = reg[(opcode >> 16) & 15].I & value; \
  110.20 -      \
  110.21 -    N_FLAG = (reg[dest].I & 0x80000000) ? true : false; \
  110.22 -    Z_FLAG = (reg[dest].I) ? false : true; \
  110.23 -    C_FLAG = C_OUT;
  110.24 -
  110.25 -#define OP_EOR \
  110.26 -    reg[dest].I = reg[(opcode >> 16) & 15].I ^ value;
  110.27 -
  110.28 -#define OP_EORS \
  110.29 -    reg[dest].I = reg[(opcode >> 16) & 15].I ^ value; \
  110.30 -      \
  110.31 -    N_FLAG = (reg[dest].I & 0x80000000) ? true : false; \
  110.32 -    Z_FLAG = (reg[dest].I) ? false : true; \
  110.33 -    C_FLAG = C_OUT;
  110.34 -#ifdef C_CORE
  110.35 -#define NEG(i) ((i) >> 31)
  110.36 -#define POS(i) ((~(i)) >> 31)
  110.37 -#define ADDCARRY(a, b, c) \
  110.38 -    C_FLAG = ((NEG(a) & NEG(b)) | \
  110.39 -              (NEG(a) & POS(c)) | \
  110.40 -              (NEG(b) & POS(c))) ? true : false;
  110.41 -#define ADDOVERFLOW(a, b, c) \
  110.42 -    V_FLAG = ((NEG(a) & NEG(b) & POS(c)) | \
  110.43 -              (POS(a) & POS(b) & NEG(c))) ? true : false;
  110.44 -#define SUBCARRY(a, b, c) \
  110.45 -    C_FLAG = ((NEG(a) & POS(b)) | \
  110.46 -              (NEG(a) & POS(c)) | \
  110.47 -              (POS(b) & POS(c))) ? true : false;
  110.48 -#define SUBOVERFLOW(a, b, c) \
  110.49 -    V_FLAG = ((NEG(a) & POS(b) & POS(c)) | \
  110.50 -              (POS(a) & NEG(b) & NEG(c))) ? true : false;
  110.51 -#define OP_SUB \
  110.52 -	{ \
  110.53 -		reg[dest].I = reg[base].I - value; \
  110.54 -	}
  110.55 -#define OP_SUBS \
  110.56 -	{ \
  110.57 -		u32 lhs = reg[base].I; \
  110.58 -		u32 rhs = value; \
  110.59 -		u32 res = lhs - rhs; \
  110.60 -		reg[dest].I = res; \
  110.61 -		Z_FLAG		= (res == 0) ? true : false; \
  110.62 -		N_FLAG		= NEG(res) ? true : false; \
  110.63 -		SUBCARRY(lhs, rhs, res); \
  110.64 -		SUBOVERFLOW(lhs, rhs, res); \
  110.65 -	}
  110.66 -#define OP_RSB \
  110.67 -	{ \
  110.68 -		reg[dest].I = value - reg[base].I; \
  110.69 -	}
  110.70 -#define OP_RSBS \
  110.71 -	{ \
  110.72 -		u32 lhs = reg[base].I; \
  110.73 -		u32 rhs = value; \
  110.74 -		u32 res = rhs - lhs; \
  110.75 -		reg[dest].I = res; \
  110.76 -		Z_FLAG		= (res == 0) ? true : false; \
  110.77 -		N_FLAG		= NEG(res) ? true : false; \
  110.78 -		SUBCARRY(rhs, lhs, res); \
  110.79 -		SUBOVERFLOW(rhs, lhs, res); \
  110.80 -	}
  110.81 -#define OP_ADD \
  110.82 -	{ \
  110.83 -		reg[dest].I = reg[base].I + value; \
  110.84 -	}
  110.85 -#define OP_ADDS \
  110.86 -	{ \
  110.87 -		u32 lhs = reg[base].I; \
  110.88 -		u32 rhs = value; \
  110.89 -		u32 res = lhs + rhs; \
  110.90 -		reg[dest].I = res; \
  110.91 -		Z_FLAG		= (res == 0) ? true : false; \
  110.92 -		N_FLAG		= NEG(res) ? true : false; \
  110.93 -		ADDCARRY(lhs, rhs, res); \
  110.94 -		ADDOVERFLOW(lhs, rhs, res); \
  110.95 -	}
  110.96 -#define OP_ADC \
  110.97 -	{ \
  110.98 -		reg[dest].I = reg[base].I + value + (u32)C_FLAG; \
  110.99 -	}
 110.100 -#define OP_ADCS \
 110.101 -	{ \
 110.102 -		u32 lhs = reg[base].I; \
 110.103 -		u32 rhs = value; \
 110.104 -		u32 res = lhs + rhs + (u32)C_FLAG; \
 110.105 -		reg[dest].I = res; \
 110.106 -		Z_FLAG		= (res == 0) ? true : false; \
 110.107 -		N_FLAG		= NEG(res) ? true : false; \
 110.108 -		ADDCARRY(lhs, rhs, res); \
 110.109 -		ADDOVERFLOW(lhs, rhs, res); \
 110.110 -	}
 110.111 -#define OP_SBC \
 110.112 -	{ \
 110.113 -		reg[dest].I = reg[base].I - value - !((u32)C_FLAG); \
 110.114 -	}
 110.115 -#define OP_SBCS \
 110.116 -	{ \
 110.117 -		u32 lhs = reg[base].I; \
 110.118 -		u32 rhs = value; \
 110.119 -		u32 res = lhs - rhs - !((u32)C_FLAG); \
 110.120 -		reg[dest].I = res; \
 110.121 -		Z_FLAG		= (res == 0) ? true : false; \
 110.122 -		N_FLAG		= NEG(res) ? true : false; \
 110.123 -		SUBCARRY(lhs, rhs, res); \
 110.124 -		SUBOVERFLOW(lhs, rhs, res); \
 110.125 -	}
 110.126 -#define OP_RSC \
 110.127 -	{ \
 110.128 -		reg[dest].I = value - reg[base].I - !((u32)C_FLAG); \
 110.129 -	}
 110.130 -#define OP_RSCS \
 110.131 -	{ \
 110.132 -		u32 lhs = reg[base].I; \
 110.133 -		u32 rhs = value; \
 110.134 -		u32 res = rhs - lhs - !((u32)C_FLAG); \
 110.135 -		reg[dest].I = res; \
 110.136 -		Z_FLAG		= (res == 0) ? true : false; \
 110.137 -		N_FLAG		= NEG(res) ? true : false; \
 110.138 -		SUBCARRY(rhs, lhs, res); \
 110.139 -		SUBOVERFLOW(rhs, lhs, res); \
 110.140 -	}
 110.141 -#define OP_CMP \
 110.142 -	{ \
 110.143 -		u32 lhs = reg[base].I; \
 110.144 -		u32 rhs = value; \
 110.145 -		u32 res = lhs - rhs; \
 110.146 -		Z_FLAG = (res == 0) ? true : false; \
 110.147 -		N_FLAG = NEG(res) ? true : false; \
 110.148 -		SUBCARRY(lhs, rhs, res); \
 110.149 -		SUBOVERFLOW(lhs, rhs, res); \
 110.150 -	}
 110.151 -#define OP_CMN \
 110.152 -	{ \
 110.153 -		u32 lhs = reg[base].I; \
 110.154 -		u32 rhs = value; \
 110.155 -		u32 res = lhs + rhs; \
 110.156 -		Z_FLAG = (res == 0) ? true : false; \
 110.157 -		N_FLAG = NEG(res) ? true : false; \
 110.158 -		ADDCARRY(lhs, rhs, res); \
 110.159 -		ADDOVERFLOW(lhs, rhs, res); \
 110.160 -	}
 110.161 -
 110.162 -#define LOGICAL_LSL_REG \
 110.163 -	{ \
 110.164 -		u32 v = reg[opcode & 0x0f].I; \
 110.165 -		C_OUT = (v >> (32 - shift)) & 1 ? true : false; \
 110.166 -		value = v << shift; \
 110.167 -	}
 110.168 -#define LOGICAL_LSR_REG \
 110.169 -	{ \
 110.170 -		u32 v = reg[opcode & 0x0f].I; \
 110.171 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.172 -		value = v >> shift; \
 110.173 -	}
 110.174 -#define LOGICAL_ASR_REG \
 110.175 -	{ \
 110.176 -		u32 v = reg[opcode & 0x0f].I; \
 110.177 -		C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false; \
 110.178 -		value = (s32)v >> (int)shift; \
 110.179 -	}
 110.180 -#define LOGICAL_ROR_REG \
 110.181 -	{ \
 110.182 -		u32 v = reg[opcode & 0x0f].I; \
 110.183 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.184 -		value = ((v << (32 - shift)) | \
 110.185 -		         (v >> shift)); \
 110.186 -	}
 110.187 -#define LOGICAL_RRX_REG \
 110.188 -	{ \
 110.189 -		u32 v = reg[opcode & 0x0f].I; \
 110.190 -		shift = (int)C_FLAG; \
 110.191 -		C_OUT = (v  & 1) ? true : false; \
 110.192 -		value = ((v >> 1) | \
 110.193 -		         (shift << 31)); \
 110.194 -	}
 110.195 -#define LOGICAL_ROR_IMM \
 110.196 -	{ \
 110.197 -		u32 v = opcode & 0xff; \
 110.198 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.199 -		value = ((v << (32 - shift)) | \
 110.200 -		         (v >> shift)); \
 110.201 -	}
 110.202 -#define ARITHMETIC_LSL_REG \
 110.203 -	{ \
 110.204 -		u32 v = reg[opcode & 0x0f].I; \
 110.205 -		value = v << shift; \
 110.206 -	}
 110.207 -#define ARITHMETIC_LSR_REG \
 110.208 -	{ \
 110.209 -		u32 v = reg[opcode & 0x0f].I; \
 110.210 -		value = v >> shift; \
 110.211 -	}
 110.212 -#define ARITHMETIC_ASR_REG \
 110.213 -	{ \
 110.214 -		u32 v = reg[opcode & 0x0f].I; \
 110.215 -		value = (s32)v >> (int)shift; \
 110.216 -	}
 110.217 -#define ARITHMETIC_ROR_REG \
 110.218 -	{ \
 110.219 -		u32 v = reg[opcode & 0x0f].I; \
 110.220 -		value = ((v << (32 - shift)) | \
 110.221 -		         (v >> shift)); \
 110.222 -	}
 110.223 -#define ARITHMETIC_RRX_REG \
 110.224 -	{ \
 110.225 -		u32 v = reg[opcode & 0x0f].I; \
 110.226 -		shift = (int)C_FLAG; \
 110.227 -		value = ((v >> 1) | \
 110.228 -		         (shift << 31)); \
 110.229 -	}
 110.230 -#define ARITHMETIC_ROR_IMM \
 110.231 -	{ \
 110.232 -		u32 v = opcode & 0xff; \
 110.233 -		value = ((v << (32 - shift)) | \
 110.234 -		         (v >> shift)); \
 110.235 -	}
 110.236 -#define ROR_IMM_MSR \
 110.237 -	{ \
 110.238 -		u32 v = opcode & 0xff; \
 110.239 -		value = ((v << (32 - shift)) | \
 110.240 -		         (v >> shift)); \
 110.241 -	}
 110.242 -#define ROR_VALUE \
 110.243 -	{ \
 110.244 -		value = ((value << (32 - shift)) | \
 110.245 -		         (value >> shift)); \
 110.246 -	}
 110.247 -#define RCR_VALUE \
 110.248 -	{ \
 110.249 -		shift = (int)C_FLAG; \
 110.250 -		value = ((value >> 1) | \
 110.251 -		         (shift << 31)); \
 110.252 -	}
 110.253 -#else
 110.254 -#ifdef __GNUC__
 110.255 -		#ifdef __POWERPC__
 110.256 -			#define OP_SUB \
 110.257 -	{ \
 110.258 -		reg[dest].I = reg[base].I - value; \
 110.259 -	}
 110.260 -			#define OP_SUBS \
 110.261 -	{ \
 110.262 -		register int Flags;                             \
 110.263 -		register int Result;                            \
 110.264 -		asm volatile ("subco. %0, %2, %3\n"              \
 110.265 -		              "mcrxr cr1\n"                       \
 110.266 -		              "mfcr %1\n"                         \
 110.267 -					  : "=r" (Result),                    \
 110.268 -		              "=r" (Flags)                      \
 110.269 -					  : "r" (reg[base].I),                \
 110.270 -		              "r" (value)                       \
 110.271 -		              );                                  \
 110.272 -		reg[dest].I = Result;                           \
 110.273 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.274 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.275 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.276 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.277 -	}
 110.278 -			#define OP_RSB \
 110.279 -	{ \
 110.280 -		reg[dest].I = value - reg[base].I; \
 110.281 -	}
 110.282 -			#define OP_RSBS \
 110.283 -	{ \
 110.284 -		register int Flags;                             \
 110.285 -		register int Result;                            \
 110.286 -		asm volatile ("subfco. %0, %2, %3\n"             \
 110.287 -		              "mcrxr cr1\n"                       \
 110.288 -		              "mfcr %1\n"                         \
 110.289 -					  : "=r" (Result),                    \
 110.290 -		              "=r" (Flags)                      \
 110.291 -					  : "r" (reg[base].I),                \
 110.292 -		              "r" (value)                       \
 110.293 -		              );                                  \
 110.294 -		reg[dest].I = Result;                           \
 110.295 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.296 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.297 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.298 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.299 -	}
 110.300 -			#define OP_ADD \
 110.301 -	{ \
 110.302 -		reg[dest].I = reg[base].I + value; \
 110.303 -	}
 110.304 -
 110.305 -			#define OP_ADDS \
 110.306 -	{ \
 110.307 -		register int Flags;                             \
 110.308 -		register int Result;                            \
 110.309 -		asm volatile ("addco. %0, %2, %3\n"              \
 110.310 -		              "mcrxr cr1\n"                       \
 110.311 -		              "mfcr %1\n"                         \
 110.312 -					  : "=r" (Result),                    \
 110.313 -		              "=r" (Flags)                      \
 110.314 -					  : "r" (reg[base].I),                \
 110.315 -		              "r" (value)                       \
 110.316 -		              );                                  \
 110.317 -		reg[dest].I = Result;                           \
 110.318 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.319 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.320 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.321 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.322 -	}
 110.323 -			#define OP_ADC \
 110.324 -	{ \
 110.325 -		reg[dest].I = reg[base].I + value + (u32)C_FLAG; \
 110.326 -	}
 110.327 -			#define OP_ADCS \
 110.328 -	{ \
 110.329 -		register int Flags;                             \
 110.330 -		register int Result;                            \
 110.331 -		asm volatile ("mtspr xer, %4\n"                  \
 110.332 -		              "addeo. %0, %2, %3\n"              \
 110.333 -		              "mcrxr cr1\n"                      \
 110.334 -		              "mfcr      %1\n"                   \
 110.335 -					  : "=r" (Result),                   \
 110.336 -		              "=r" (Flags)                     \
 110.337 -					  : "r" (reg[base].I),               \
 110.338 -		              "r" (value),                     \
 110.339 -		              "r" (C_FLAG << 29)               \
 110.340 -		              );                                 \
 110.341 -		reg[dest].I = Result;                           \
 110.342 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.343 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.344 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.345 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.346 -	}
 110.347 -			#define OP_SBC \
 110.348 -	{ \
 110.349 -		reg[dest].I = reg[base].I - value - (C_FLAG ^ 1); \
 110.350 -	}
 110.351 -			#define OP_SBCS \
 110.352 -	{ \
 110.353 -		register int Flags;                             \
 110.354 -		register int Result;                            \
 110.355 -		asm volatile ("mtspr xer, %4\n"                  \
 110.356 -		              "subfeo. %0, %3, %2\n"             \
 110.357 -		              "mcrxr cr1\n"                      \
 110.358 -		              "mfcr      %1\n"                   \
 110.359 -					  : "=r" (Result),                   \
 110.360 -		              "=r" (Flags)                     \
 110.361 -					  : "r" (reg[base].I),               \
 110.362 -		              "r" (value),                     \
 110.363 -		              "r" (C_FLAG << 29)               \
 110.364 -		              );                                 \
 110.365 -		reg[dest].I = Result;                           \
 110.366 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.367 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.368 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.369 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.370 -	}
 110.371 -			#define OP_RSC \
 110.372 -	{ \
 110.373 -		reg[dest].I = value - reg[base].I - (C_FLAG ^ 1); \
 110.374 -	}
 110.375 -			#define OP_RSCS \
 110.376 -	{ \
 110.377 -		register int Flags;                             \
 110.378 -		register int Result;                            \
 110.379 -		asm volatile ("mtspr xer, %4\n"                  \
 110.380 -		              "subfeo. %0, %2, %3\n"             \
 110.381 -		              "mcrxr cr1\n"                      \
 110.382 -		              "mfcr      %1\n"                   \
 110.383 -					  : "=r" (Result),                   \
 110.384 -		              "=r" (Flags)                     \
 110.385 -					  : "r" (reg[base].I),               \
 110.386 -		              "r" (value),                     \
 110.387 -		              "r" (C_FLAG << 29)               \
 110.388 -		              );                                 \
 110.389 -		reg[dest].I = Result;                           \
 110.390 -		Z_FLAG		= (Flags >> 29) & 1;                     \
 110.391 -		N_FLAG		= (Flags >> 31) & 1;                     \
 110.392 -		C_FLAG		= (Flags >> 25) & 1;                     \
 110.393 -		V_FLAG		= (Flags >> 26) & 1;                     \
 110.394 -	}
 110.395 -			#define OP_CMP \
 110.396 -	{ \
 110.397 -		register int Flags;                             \
 110.398 -		register int Result;                            \
 110.399 -		asm volatile ("subco. %0, %2, %3\n"              \
 110.400 -		              "mcrxr cr1\n"                       \
 110.401 -		              "mfcr %1\n"                         \
 110.402 -					  : "=r" (Result),                    \
 110.403 -		              "=r" (Flags)                      \
 110.404 -					  : "r" (reg[base].I),                \
 110.405 -		              "r" (value)                       \
 110.406 -		              );                                  \
 110.407 -		Z_FLAG = (Flags >> 29) & 1;                     \
 110.408 -		N_FLAG = (Flags >> 31) & 1;                     \
 110.409 -		C_FLAG = (Flags >> 25) & 1;                     \
 110.410 -		V_FLAG = (Flags >> 26) & 1;                     \
 110.411 -	}
 110.412 -			#define OP_CMN \
 110.413 -	{ \
 110.414 -		register int Flags;                             \
 110.415 -		register int Result;                            \
 110.416 -		asm volatile ("addco. %0, %2, %3\n"              \
 110.417 -		              "mcrxr cr1\n"                       \
 110.418 -		              "mfcr %1\n"                         \
 110.419 -					  : "=r" (Result),                    \
 110.420 -		              "=r" (Flags)                      \
 110.421 -					  : "r" (reg[base].I),                \
 110.422 -		              "r" (value)                       \
 110.423 -		              );                                  \
 110.424 -		Z_FLAG = (Flags >> 29) & 1;                     \
 110.425 -		N_FLAG = (Flags >> 31) & 1;                     \
 110.426 -		C_FLAG = (Flags >> 25) & 1;                     \
 110.427 -		V_FLAG = (Flags >> 26) & 1;                     \
 110.428 -	}
 110.429 -
 110.430 -			#define LOGICAL_LSL_REG \
 110.431 -	{ \
 110.432 -		u32 v = reg[opcode & 0x0f].I; \
 110.433 -		C_OUT = (v >> (32 - shift)) & 1 ? true : false; \
 110.434 -		value = v << shift; \
 110.435 -	}
 110.436 -			#define LOGICAL_LSR_REG \
 110.437 -	{ \
 110.438 -		u32 v = reg[opcode & 0x0f].I; \
 110.439 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.440 -		value = v >> shift; \
 110.441 -	}
 110.442 -			#define LOGICAL_ASR_REG \
 110.443 -	{ \
 110.444 -		u32 v = reg[opcode & 0x0f].I; \
 110.445 -		C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false; \
 110.446 -		value = (s32)v >> (int)shift; \
 110.447 -	}
 110.448 -			#define LOGICAL_ROR_REG \
 110.449 -	{ \
 110.450 -		u32 v = reg[opcode & 0x0f].I; \
 110.451 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.452 -		value = ((v << (32 - shift)) | \
 110.453 -		         (v >> shift)); \
 110.454 -	}
 110.455 -			#define LOGICAL_RRX_REG \
 110.456 -	{ \
 110.457 -		u32 v = reg[opcode & 0x0f].I; \
 110.458 -		shift = (int)C_FLAG; \
 110.459 -		C_OUT = (v  & 1) ? true : false; \
 110.460 -		value = ((v >> 1) | \
 110.461 -		         (shift << 31)); \
 110.462 -	}
 110.463 -			#define LOGICAL_ROR_IMM \
 110.464 -	{ \
 110.465 -		u32 v = opcode & 0xff; \
 110.466 -		C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
 110.467 -		value = ((v << (32 - shift)) | \
 110.468 -		         (v >> shift)); \
 110.469 -	}
 110.470 -			#define ARITHMETIC_LSL_REG \
 110.471 -	{ \
 110.472 -		u32 v = reg[opcode & 0x0f].I; \
 110.473 -		value = v << shift; \
 110.474 -	}
 110.475 -			#define ARITHMETIC_LSR_REG \
 110.476 -	{ \
 110.477 -		u32 v = reg[opcode & 0x0f].I; \
 110.478 -		value = v >> shift; \
 110.479 -	}
 110.480 -			#define ARITHMETIC_ASR_REG \
 110.481 -	{ \
 110.482 -		u32 v = reg[opcode & 0x0f].I; \
 110.483 -		value = (s32)v >> (int)shift; \
 110.484 -	}
 110.485 -			#define ARITHMETIC_ROR_REG \
 110.486 -	{ \
 110.487 -		u32 v = reg[opcode & 0x0f].I; \
 110.488 -		value = ((v << (32 - shift)) | \
 110.489 -		         (v >> shift)); \
 110.490 -	}
 110.491 -			#define ARITHMETIC_RRX_REG \
 110.492 -	{ \
 110.493 -		u32 v = reg[opcode & 0x0f].I; \
 110.494 -		shift = (int)C_FLAG; \
 110.495 -		value = ((v >> 1) | \
 110.496 -		         (shift << 31)); \
 110.497 -	}
 110.498 -			#define ARITHMETIC_ROR_IMM \
 110.499 -	{ \
 110.500 -		u32 v = opcode & 0xff; \
 110.501 -		value = ((v << (32 - shift)) | \
 110.502 -		         (v >> shift)); \
 110.503 -	}
 110.504 -			#define ROR_IMM_MSR \
 110.505 -	{ \
 110.506 -		u32 v = opcode & 0xff; \
 110.507 -		value = ((v << (32 - shift)) | \
 110.508 -		         (v >> shift)); \
 110.509 -	}
 110.510 -			#define ROR_VALUE \
 110.511 -	{ \
 110.512 -		value = ((value << (32 - shift)) | \
 110.513 -		         (value >> shift)); \
 110.514 -	}
 110.515 -			#define RCR_VALUE \
 110.516 -	{ \
 110.517 -		shift = (int)C_FLAG; \
 110.518 -		value = ((value >> 1) | \
 110.519 -		         (shift << 31)); \
 110.520 -	}
 110.521 -#else
 110.522 -#define OP_SUB \
 110.523 -    asm ("sub %1, %%ebx;" \
 110.524 -		 : "=b" (reg[dest].I) \
 110.525 -		 : "r" (value), "b" (reg[base].I));
 110.526 -
 110.527 -#define OP_SUBS \
 110.528 -    asm ("sub %1, %%ebx;" \
 110.529 -         "setsb N_FLAG;" \
 110.530 -         "setzb Z_FLAG;" \
 110.531 -         "setncb C_FLAG;" \
 110.532 -         "setob V_FLAG;" \
 110.533 -		 : "=b" (reg[dest].I) \
 110.534 -		 : "r" (value), "b" (reg[base].I));
 110.535 -
 110.536 -#define OP_RSB \
 110.537 -    asm  ("sub %1, %%ebx;" \
 110.538 -		  : "=b" (reg[dest].I) \
 110.539 -		  : "r" (reg[base].I), "b" (value));
 110.540 -
 110.541 -#define OP_RSBS \
 110.542 -    asm  ("sub %1, %%ebx;" \
 110.543 -          "setsb N_FLAG;" \
 110.544 -          "setzb Z_FLAG;" \
 110.545 -          "setncb C_FLAG;" \
 110.546 -          "setob V_FLAG;" \
 110.547 -		  : "=b" (reg[dest].I) \
 110.548 -		  : "r" (reg[base].I), "b" (value));
 110.549 -
 110.550 -#define OP_ADD \
 110.551 -    asm  ("add %1, %%ebx;" \
 110.552 -		  : "=b" (reg[dest].I) \
 110.553 -		  : "r" (value), "b" (reg[base].I));
 110.554 -
 110.555 -#define OP_ADDS \
 110.556 -    asm  ("add %1, %%ebx;" \
 110.557 -          "setsb N_FLAG;" \
 110.558 -          "setzb Z_FLAG;" \
 110.559 -          "setcb C_FLAG;" \
 110.560 -          "setob V_FLAG;" \
 110.561 -		  : "=b" (reg[dest].I) \
 110.562 -		  : "r" (value), "b" (reg[base].I));
 110.563 -
 110.564 -#define OP_ADC \
 110.565 -    asm  ("bt $0, C_FLAG;" \
 110.566 -          "adc %1, %%ebx;" \
 110.567 -		  : "=b" (reg[dest].I) \
 110.568 -		  : "r" (value), "b" (reg[base].I));
 110.569 -
 110.570 -#define OP_ADCS \
 110.571 -    asm  ("bt $0, C_FLAG;" \
 110.572 -          "adc %1, %%ebx;" \
 110.573 -          "setsb N_FLAG;" \
 110.574 -          "setzb Z_FLAG;" \
 110.575 -          "setcb C_FLAG;" \
 110.576 -          "setob V_FLAG;" \
 110.577 -		  : "=b" (reg[dest].I) \
 110.578 -		  : "r" (value), "b" (reg[base].I));
 110.579 -
 110.580 -#define OP_SBC \
 110.581 -    asm  ("bt $0, C_FLAG;" \
 110.582 -          "cmc;" \
 110.583 -          "sbb %1, %%ebx;" \
 110.584 -		  : "=b" (reg[dest].I) \
 110.585 -		  : "r" (value), "b" (reg[base].I));
 110.586 -
 110.587 -#define OP_SBCS \
 110.588 -    asm  ("bt $0, C_FLAG;" \
 110.589 -          "cmc;" \
 110.590 -          "sbb %1, %%ebx;" \
 110.591 -          "setsb N_FLAG;" \
 110.592 -          "setzb Z_FLAG;" \
 110.593 -          "setncb C_FLAG;" \
 110.594 -          "setob V_FLAG;" \
 110.595 -		  : "=b" (reg[dest].I) \
 110.596 -		  : "r" (value), "b" (reg[base].I));
 110.597 -#define OP_RSC \
 110.598 -    asm  ("bt $0, C_FLAG;" \
 110.599 -          "cmc;" \
 110.600 -          "sbb %1, %%ebx;" \
 110.601 -		  : "=b" (reg[dest].I) \
 110.602 -		  : "r" (reg[base].I), "b" (value));
 110.603 -
 110.604 -#define OP_RSCS \
 110.605 -    asm  ("bt $0, C_FLAG;" \
 110.606 -          "cmc;" \
 110.607 -          "sbb %1, %%ebx;" \
 110.608 -          "setsb N_FLAG;" \
 110.609 -          "setzb Z_FLAG;" \
 110.610 -          "setncb C_FLAG;" \
 110.611 -          "setob V_FLAG;" \
 110.612 -		  : "=b" (reg[dest].I) \
 110.613 -		  : "r" (reg[base].I), "b" (value));
 110.614 -#define OP_CMP \
 110.615 -    asm  ("sub %0, %1;" \
 110.616 -          "setsb N_FLAG;" \
 110.617 -          "setzb Z_FLAG;" \
 110.618 -          "setncb C_FLAG;" \
 110.619 -          "setob V_FLAG;" \
 110.620 -		  : \
 110.621 -		  : "r" (value), "r" (reg[base].I));
 110.622 -
 110.623 -#define OP_CMN \
 110.624 -    asm  ("add %0, %1;" \
 110.625 -          "setsb N_FLAG;" \
 110.626 -          "setzb Z_FLAG;" \
 110.627 -          "setcb C_FLAG;" \
 110.628 -          "setob V_FLAG;" \
 110.629 -		  : \
 110.630 -		  : "r" (value), "r" (reg[base].I));
 110.631 -#define LOGICAL_LSL_REG \
 110.632 -    asm ("shl %%cl, %%eax;" \
 110.633 -         "setcb %%cl;" \
 110.634 -		 : "=a" (value), "=c" (C_OUT) \
 110.635 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.636 -
 110.637 -#define LOGICAL_LSR_REG \
 110.638 -    asm ("shr %%cl, %%eax;" \
 110.639 -         "setcb %%cl;" \
 110.640 -		 : "=a" (value), "=c" (C_OUT) \
 110.641 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.642 -
 110.643 -#define LOGICAL_ASR_REG \
 110.644 -    asm ("sar %%cl, %%eax;" \
 110.645 -         "setcb %%cl;" \
 110.646 -		 : "=a" (value), "=c" (C_OUT) \
 110.647 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.648 -
 110.649 -#define LOGICAL_ROR_REG \
 110.650 -    asm ("ror %%cl, %%eax;" \
 110.651 -         "setcb %%cl;" \
 110.652 -		 : "=a" (value), "=c" (C_OUT) \
 110.653 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.654 -
 110.655 -#define LOGICAL_RRX_REG \
 110.656 -    asm ("bt $0, C_FLAG;" \
 110.657 -         "rcr $1, %%eax;" \
 110.658 -         "setcb %%cl;" \
 110.659 -		 : "=a" (value), "=c" (C_OUT) \
 110.660 -		 : "a" (reg[opcode & 0x0f].I));
 110.661 -
 110.662 -#define LOGICAL_ROR_IMM \
 110.663 -    asm ("ror %%cl, %%eax;" \
 110.664 -         "setcb %%cl;" \
 110.665 -		 : "=a" (value), "=c" (C_OUT) \
 110.666 -		 : "a" (opcode & 0xff), "c" (shift));
 110.667 -#define ARITHMETIC_LSL_REG \
 110.668 -    asm ("\
 110.669 -             shl %%cl, %%eax;" \
 110.670 -		 : "=a" (value) \
 110.671 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.672 -
 110.673 -#define ARITHMETIC_LSR_REG \
 110.674 -    asm ("\
 110.675 -             shr %%cl, %%eax;" \
 110.676 -		 : "=a" (value) \
 110.677 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.678 -
 110.679 -#define ARITHMETIC_ASR_REG \
 110.680 -    asm ("\
 110.681 -             sar %%cl, %%eax;" \
 110.682 -		 : "=a" (value) \
 110.683 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.684 -
 110.685 -#define ARITHMETIC_ROR_REG \
 110.686 -    asm ("\
 110.687 -             ror %%cl, %%eax;" \
 110.688 -		 : "=a" (value) \
 110.689 -		 : "a" (reg[opcode & 0x0f].I), "c" (shift));
 110.690 -
 110.691 -#define ARITHMETIC_RRX_REG \
 110.692 -    asm ("\
 110.693 -             bt $0, C_FLAG;\
 110.694 -             rcr $1, %%eax;" \
 110.695 -		 : "=a" (value) \
 110.696 -		 : "a" (reg[opcode & 0x0f].I));
 110.697 -
 110.698 -#define ARITHMETIC_ROR_IMM \
 110.699 -    asm ("\
 110.700 -             ror %%cl, %%eax;" \
 110.701 -		 : "=a" (value) \
 110.702 -		 : "a" (opcode & 0xff), "c" (shift));
 110.703 -#define ROR_IMM_MSR \
 110.704 -    asm ("ror %%cl, %%eax;" \
 110.705 -		 : "=a" (value) \
 110.706 -		 : "a" (opcode & 0xFF), "c" (shift));
 110.707 -#define ROR_VALUE \
 110.708 -    asm ("ror %%cl, %0" \
 110.709 -		 : "=r" (value) \
 110.710 -		 : "r" (value), "c" (shift));
 110.711 -#define RCR_VALUE \
 110.712 -    asm ("bt $0, C_FLAG;" \
 110.713 -         "rcr $1, %0" \
 110.714 -		 : "=r" (value) \
 110.715 -		 : "r" (value));
 110.716 -#endif
 110.717 -#else
 110.718 -#define OP_SUB \
 110.719 -	{ \
 110.720 -		__asm mov ebx, base \
 110.721 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.722 -		__asm sub ebx, value \
 110.723 -		__asm mov eax, dest \
 110.724 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.725 -	}
 110.726 -
 110.727 -#define OP_SUBS \
 110.728 -	{ \
 110.729 -		__asm mov ebx, base \
 110.730 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.731 -		__asm sub ebx, value \
 110.732 -		__asm mov eax, dest \
 110.733 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.734 -		__asm sets byte ptr N_FLAG \
 110.735 -		__asm setz byte ptr Z_FLAG \
 110.736 -		__asm setnc byte ptr C_FLAG \
 110.737 -		__asm seto byte ptr V_FLAG \
 110.738 -	}
 110.739 -
 110.740 -#define OP_RSB \
 110.741 -	{ \
 110.742 -		__asm mov ebx, base \
 110.743 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.744 -		__asm mov eax, value \
 110.745 -		__asm sub eax, ebx \
 110.746 -		__asm mov ebx, dest \
 110.747 -		__asm mov dword ptr [OFFSET reg + 4 * ebx], eax \
 110.748 -	}
 110.749 -
 110.750 -#define OP_RSBS \
 110.751 -	{ \
 110.752 -		__asm mov ebx, base \
 110.753 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.754 -		__asm mov eax, value \
 110.755 -		__asm sub eax, ebx \
 110.756 -		__asm mov ebx, dest \
 110.757 -		__asm mov dword ptr [OFFSET reg + 4 * ebx], eax \
 110.758 -		__asm sets byte ptr N_FLAG \
 110.759 -		__asm setz byte ptr Z_FLAG \
 110.760 -		__asm setnc byte ptr C_FLAG \
 110.761 -		__asm seto byte ptr V_FLAG \
 110.762 -	}
 110.763 -
 110.764 -#define OP_ADD \
 110.765 -	{ \
 110.766 -		__asm mov ebx, base \
 110.767 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.768 -		__asm add ebx, value \
 110.769 -		__asm mov eax, dest \
 110.770 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.771 -	}
 110.772 -
 110.773 -#define OP_ADDS \
 110.774 -	{ \
 110.775 -		__asm mov ebx, base \
 110.776 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.777 -		__asm add ebx, value \
 110.778 -		__asm mov eax, dest \
 110.779 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.780 -		__asm sets byte ptr N_FLAG \
 110.781 -		__asm setz byte ptr Z_FLAG \
 110.782 -		__asm setc byte ptr C_FLAG \
 110.783 -		__asm seto byte ptr V_FLAG \
 110.784 -	}
 110.785 -
 110.786 -#define OP_ADC \
 110.787 -	{ \
 110.788 -		__asm mov ebx, base \
 110.789 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.790 -		__asm bt word ptr C_FLAG, 0 \
 110.791 -		__asm adc ebx, value \
 110.792 -		__asm mov eax, dest \
 110.793 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.794 -	}
 110.795 -
 110.796 -#define OP_ADCS \
 110.797 -	{ \
 110.798 -		__asm mov ebx, base \
 110.799 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.800 -		__asm bt word ptr C_FLAG, 0 \
 110.801 -		__asm adc ebx, value \
 110.802 -		__asm mov eax, dest \
 110.803 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.804 -		__asm sets byte ptr N_FLAG \
 110.805 -		__asm setz byte ptr Z_FLAG \
 110.806 -		__asm setc byte ptr C_FLAG \
 110.807 -		__asm seto byte ptr V_FLAG \
 110.808 -	}
 110.809 -
 110.810 -#define OP_SBC \
 110.811 -	{ \
 110.812 -		__asm mov ebx, base \
 110.813 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.814 -		__asm mov eax, value \
 110.815 -		__asm bt word ptr C_FLAG, 0 \
 110.816 -		__asm cmc \
 110.817 -		__asm sbb ebx, eax \
 110.818 -		__asm mov eax, dest \
 110.819 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.820 -	}
 110.821 -
 110.822 -#define OP_SBCS \
 110.823 -	{ \
 110.824 -		__asm mov ebx, base \
 110.825 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 110.826 -		__asm mov eax, value \
 110.827 -		__asm bt word ptr C_FLAG, 0 \
 110.828 -		__asm cmc \
 110.829 -		__asm sbb ebx, eax \
 110.830 -		__asm mov eax, dest \
 110.831 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.832 -		__asm sets byte ptr N_FLAG \
 110.833 -		__asm setz byte ptr Z_FLAG \
 110.834 -		__asm setnc byte ptr C_FLAG \
 110.835 -		__asm seto byte ptr V_FLAG \
 110.836 -	}
 110.837 -#define OP_RSC \
 110.838 -	{ \
 110.839 -		__asm mov ebx, value \
 110.840 -		__asm mov eax, base \
 110.841 -		__asm mov eax, dword ptr[OFFSET reg + 4 * eax] \
 110.842 -		__asm bt word ptr C_FLAG, 0 \
 110.843 -		__asm cmc \
 110.844 -		__asm sbb ebx, eax \
 110.845 -		__asm mov eax, dest \
 110.846 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.847 -	}
 110.848 -
 110.849 -#define OP_RSCS \
 110.850 -	{ \
 110.851 -		__asm mov ebx, value \
 110.852 -		__asm mov eax, base \
 110.853 -		__asm mov eax, dword ptr[OFFSET reg + 4 * eax] \
 110.854 -		__asm bt word ptr C_FLAG, 0 \
 110.855 -		__asm cmc \
 110.856 -		__asm sbb ebx, eax \
 110.857 -		__asm mov eax, dest \
 110.858 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 110.859 -		__asm sets byte ptr N_FLAG \
 110.860 -		__asm setz byte ptr Z_FLAG \
 110.861 -		__asm setnc byte ptr C_FLAG \
 110.862 -		__asm seto byte ptr V_FLAG \
 110.863 -	}
 110.864 -#define OP_CMP \
 110.865 -	{ \
 110.866 -		__asm mov eax, base \
 110.867 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 110.868 -		__asm sub ebx, value \
 110.869 -		__asm sets byte ptr N_FLAG \
 110.870 -		__asm setz byte ptr Z_FLAG \
 110.871 -		__asm setnc byte ptr C_FLAG \
 110.872 -		__asm seto byte ptr V_FLAG \
 110.873 -	}
 110.874 -
 110.875 -#define OP_CMN \
 110.876 -	{ \
 110.877 -		__asm mov eax, base \
 110.878 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 110.879 -		__asm add ebx, value \
 110.880 -		__asm sets byte ptr N_FLAG \
 110.881 -		__asm setz byte ptr Z_FLAG \
 110.882 -		__asm setc byte ptr C_FLAG \
 110.883 -		__asm seto byte ptr V_FLAG \
 110.884 -	}
 110.885 -#define LOGICAL_LSL_REG \
 110.886 -    __asm mov eax, opcode \
 110.887 -    __asm and eax, 0x0f \
 110.888 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.889 -    __asm mov cl, byte ptr shift \
 110.890 -    __asm shl eax, cl \
 110.891 -    __asm mov value, eax \
 110.892 -    __asm setc byte ptr C_OUT
 110.893 -
 110.894 -#define LOGICAL_LSR_REG \
 110.895 -    __asm mov eax, opcode \
 110.896 -    __asm and eax, 0x0f \
 110.897 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.898 -    __asm mov cl, byte ptr shift \
 110.899 -    __asm shr eax, cl \
 110.900 -    __asm mov value, eax \
 110.901 -    __asm setc byte ptr C_OUT
 110.902 -
 110.903 -#define LOGICAL_ASR_REG \
 110.904 -    __asm mov eax, opcode \
 110.905 -    __asm and eax, 0x0f \
 110.906 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.907 -    __asm mov cl, byte ptr shift \
 110.908 -    __asm sar eax, cl \
 110.909 -    __asm mov value, eax \
 110.910 -    __asm setc byte ptr C_OUT
 110.911 -
 110.912 -#define LOGICAL_ROR_REG \
 110.913 -    __asm mov eax, opcode \
 110.914 -    __asm and eax, 0x0F \
 110.915 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.916 -    __asm mov cl, byte ptr shift \
 110.917 -    __asm ror eax, cl \
 110.918 -    __asm mov value, eax \
 110.919 -    __asm setc byte ptr C_OUT
 110.920 -
 110.921 -#define LOGICAL_RRX_REG \
 110.922 -    __asm mov eax, opcode \
 110.923 -    __asm and eax, 0x0F \
 110.924 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.925 -    __asm bt word ptr C_OUT, 0 \
 110.926 -    __asm rcr eax, 1 \
 110.927 -    __asm mov value, eax \
 110.928 -    __asm setc byte ptr C_OUT
 110.929 -
 110.930 -#define LOGICAL_ROR_IMM \
 110.931 -    __asm mov eax, opcode \
 110.932 -    __asm and eax, 0xff \
 110.933 -    __asm mov cl, byte ptr shift \
 110.934 -    __asm ror eax, cl \
 110.935 -    __asm mov value, eax \
 110.936 -    __asm setc byte ptr C_OUT
 110.937 -#define ARITHMETIC_LSL_REG \
 110.938 -    __asm mov eax, opcode \
 110.939 -    __asm and eax, 0x0f \
 110.940 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.941 -    __asm mov cl, byte ptr shift \
 110.942 -    __asm shl eax, cl \
 110.943 -    __asm mov value, eax
 110.944 -
 110.945 -#define ARITHMETIC_LSR_REG \
 110.946 -    __asm mov eax, opcode \
 110.947 -    __asm and eax, 0x0f \
 110.948 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.949 -    __asm mov cl, byte ptr shift \
 110.950 -    __asm shr eax, cl \
 110.951 -    __asm mov value, eax
 110.952 -
 110.953 -#define ARITHMETIC_ASR_REG \
 110.954 -    __asm mov eax, opcode \
 110.955 -    __asm and eax, 0x0f \
 110.956 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.957 -    __asm mov cl, byte ptr shift \
 110.958 -    __asm sar eax, cl \
 110.959 -    __asm mov value, eax
 110.960 -
 110.961 -#define ARITHMETIC_ROR_REG \
 110.962 -    __asm mov eax, opcode \
 110.963 -    __asm and eax, 0x0F \
 110.964 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.965 -    __asm mov cl, byte ptr shift \
 110.966 -    __asm ror eax, cl \
 110.967 -    __asm mov value, eax
 110.968 -
 110.969 -#define ARITHMETIC_RRX_REG \
 110.970 -    __asm mov eax, opcode \
 110.971 -    __asm and eax, 0x0F \
 110.972 -    __asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 110.973 -    __asm bt word ptr C_FLAG, 0 \
 110.974 -    __asm rcr eax, 1 \
 110.975 -    __asm mov value, eax
 110.976 -
 110.977 -#define ARITHMETIC_ROR_IMM \
 110.978 -    __asm mov eax, opcode \
 110.979 -    __asm and eax, 0xff \
 110.980 -    __asm mov cl, byte ptr shift \
 110.981 -    __asm ror eax, cl \
 110.982 -    __asm mov value, eax
 110.983 -#define ROR_IMM_MSR \
 110.984 -	{ \
 110.985 -		__asm mov eax, opcode \
 110.986 -		          __asm and eax, 0xff \
 110.987 -		__asm mov cl, byte ptr shift \
 110.988 -		__asm ror eax, CL \
 110.989 -		__asm mov value, eax \
 110.990 -	}
 110.991 -#define ROR_VALUE \
 110.992 -	{ \
 110.993 -		__asm mov cl, byte ptr shift \
 110.994 -		__asm ror dword ptr value, cl \
 110.995 -	}
 110.996 -#define RCR_VALUE \
 110.997 -	{ \
 110.998 -		__asm mov cl, byte ptr shift \
 110.999 -		__asm bt word ptr C_FLAG, 0 \
110.1000 -		__asm rcr dword ptr value, 1 \
110.1001 -	}
110.1002 -#endif
110.1003 -#endif
110.1004 -
110.1005 -#define OP_TST \
110.1006 -    u32 res = reg[base].I & value; \
110.1007 -    N_FLAG	= (res & 0x80000000) ? true : false; \
110.1008 -    Z_FLAG	= (res) ? false : true; \
110.1009 -    C_FLAG	= C_OUT;
110.1010 -
110.1011 -#define OP_TEQ \
110.1012 -    u32 res = reg[base].I ^ value; \
110.1013 -    N_FLAG	= (res & 0x80000000) ? true : false; \
110.1014 -    Z_FLAG	= (res) ? false : true; \
110.1015 -    C_FLAG	= C_OUT;
110.1016 -
110.1017 -#define OP_ORR \
110.1018 -    reg[dest].I = reg[base].I | value;
110.1019 -
110.1020 -#define OP_ORRS \
110.1021 -    reg[dest].I = reg[base].I | value; \
110.1022 -    N_FLAG		= (reg[dest].I & 0x80000000) ? true : false; \
110.1023 -    Z_FLAG		= (reg[dest].I) ? false : true; \
110.1024 -    C_FLAG		= C_OUT;
110.1025 -
110.1026 -#define OP_MOV \
110.1027 -    reg[dest].I = value;
110.1028 -
110.1029 -#define OP_MOVS \
110.1030 -    reg[dest].I = value; \
110.1031 -    N_FLAG		= (reg[dest].I & 0x80000000) ? true : false; \
110.1032 -    Z_FLAG		= (reg[dest].I) ? false : true; \
110.1033 -    C_FLAG		= C_OUT;
110.1034 -
110.1035 -#define OP_BIC \
110.1036 -    reg[dest].I = reg[base].I & (~value);
110.1037 -
110.1038 -#define OP_BICS \
110.1039 -    reg[dest].I = reg[base].I & (~value); \
110.1040 -    N_FLAG		= (reg[dest].I & 0x80000000) ? true : false; \
110.1041 -    Z_FLAG		= (reg[dest].I) ? false : true; \
110.1042 -    C_FLAG		= C_OUT;
110.1043 -
110.1044 -#define OP_MVN \
110.1045 -    reg[dest].I = ~value;
110.1046 -
110.1047 -#define OP_MVNS \
110.1048 -    reg[dest].I = ~value; \
110.1049 -    N_FLAG		= (reg[dest].I & 0x80000000) ? true : false; \
110.1050 -    Z_FLAG		= (reg[dest].I) ? false : true; \
110.1051 -    C_FLAG		= C_OUT;
110.1052 -
110.1053 -#define CASE_16(BASE) \
110.1054 -case BASE: \
110.1055 -case BASE + 1: \
110.1056 -case BASE + 2: \
110.1057 -case BASE + 3: \
110.1058 -case BASE + 4: \
110.1059 -case BASE + 5: \
110.1060 -case BASE + 6: \
110.1061 -case BASE + 7: \
110.1062 -case BASE + 8: \
110.1063 -case BASE + 9: \
110.1064 -case BASE + 10: \
110.1065 -case BASE + 11: \
110.1066 -case BASE + 12: \
110.1067 -case BASE + 13: \
110.1068 -case BASE + 14: \
110.1069 -case BASE + 15:
110.1070 -
110.1071 -#define CASE_256(BASE) \
110.1072 -    CASE_16(BASE) \
110.1073 -    CASE_16(BASE + 0x10) \
110.1074 -    CASE_16(BASE + 0x20) \
110.1075 -    CASE_16(BASE + 0x30) \
110.1076 -    CASE_16(BASE + 0x40) \
110.1077 -    CASE_16(BASE + 0x50) \
110.1078 -    CASE_16(BASE + 0x60) \
110.1079 -    CASE_16(BASE + 0x70) \
110.1080 -    CASE_16(BASE + 0x80) \
110.1081 -    CASE_16(BASE + 0x90) \
110.1082 -    CASE_16(BASE + 0xa0) \
110.1083 -    CASE_16(BASE + 0xb0) \
110.1084 -    CASE_16(BASE + 0xc0) \
110.1085 -    CASE_16(BASE + 0xd0) \
110.1086 -    CASE_16(BASE + 0xe0) \
110.1087 -    CASE_16(BASE + 0xf0)
110.1088 -
110.1089 -#define LOGICAL_DATA_OPCODE(OPCODE, OPCODE2, BASE) \
110.1090 -case BASE: \
110.1091 -case BASE + 8: \
110.1092 -{ \
110.1093 -	/* OP Rd,Rb,Rm LSL # */ \
110.1094 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1095 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1096 -	int	 dest  = (opcode >> 12) & 15; \
110.1097 -	bool C_OUT = C_FLAG; \
110.1098 -	u32	 value; \
110.1099 -      \
110.1100 -	if (shift) { \
110.1101 -		LOGICAL_LSL_REG \
110.1102 -	} else { \
110.1103 -		value = reg[opcode & 0x0F].I; \
110.1104 -	} \
110.1105 -	if (dest == 15) { \
110.1106 -		OPCODE2 \
110.1107 -		/* todo */ \
110.1108 -		if (opcode & 0x00100000) { \
110.1109 -			clockTicks++; \
110.1110 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1111 -		} \
110.1112 -		if (armState) { \
110.1113 -			reg[15].I &= 0xFFFFFFFC; \
110.1114 -			armNextPC  = reg[15].I; \
110.1115 -			reg[15].I += 4; \
110.1116 -		} else { \
110.1117 -			reg[15].I &= 0xFFFFFFFE; \
110.1118 -			armNextPC  = reg[15].I; \
110.1119 -			reg[15].I += 2; \
110.1120 -		} \
110.1121 -	} else { \
110.1122 -		OPCODE \
110.1123 -	} \
110.1124 -} \
110.1125 -break; \
110.1126 -case BASE + 2: \
110.1127 -case BASE + 10: \
110.1128 -{ \
110.1129 -	/* OP Rd,Rb,Rm LSR # */ \
110.1130 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1131 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1132 -	int	 dest  = (opcode >> 12) & 15; \
110.1133 -	bool C_OUT = C_FLAG; \
110.1134 -	u32	 value; \
110.1135 -	if (shift) { \
110.1136 -		LOGICAL_LSR_REG \
110.1137 -	} else { \
110.1138 -		value = 0; \
110.1139 -		C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false; \
110.1140 -	} \
110.1141 -      \
110.1142 -	if (dest == 15) { \
110.1143 -		OPCODE2 \
110.1144 -		/* todo */ \
110.1145 -		if (opcode & 0x00100000) { \
110.1146 -			clockTicks++; \
110.1147 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1148 -		} \
110.1149 -		if (armState) { \
110.1150 -			reg[15].I &= 0xFFFFFFFC; \
110.1151 -			armNextPC  = reg[15].I; \
110.1152 -			reg[15].I += 4; \
110.1153 -		} else { \
110.1154 -			reg[15].I &= 0xFFFFFFFE; \
110.1155 -			armNextPC  = reg[15].I; \
110.1156 -			reg[15].I += 2; \
110.1157 -		} \
110.1158 -	} else { \
110.1159 -		OPCODE \
110.1160 -	} \
110.1161 -} \
110.1162 -break; \
110.1163 -case BASE + 4: \
110.1164 -case BASE + 12: \
110.1165 -{ \
110.1166 -	/* OP Rd,Rb,Rm ASR # */ \
110.1167 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1168 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1169 -	int	 dest  = (opcode >> 12) & 15; \
110.1170 -	bool C_OUT = C_FLAG; \
110.1171 -	u32	 value; \
110.1172 -	if (shift) { \
110.1173 -		LOGICAL_ASR_REG \
110.1174 -	} else { \
110.1175 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.1176 -			value = 0xFFFFFFFF; \
110.1177 -			C_OUT = true; \
110.1178 -		} else { \
110.1179 -			value = 0; \
110.1180 -			C_OUT = false; \
110.1181 -		}                   \
110.1182 -	} \
110.1183 -      \
110.1184 -	if (dest == 15) { \
110.1185 -		OPCODE2 \
110.1186 -		/* todo */ \
110.1187 -		if (opcode & 0x00100000) { \
110.1188 -			clockTicks++; \
110.1189 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1190 -		} \
110.1191 -		if (armState) { \
110.1192 -			reg[15].I &= 0xFFFFFFFC; \
110.1193 -			armNextPC  = reg[15].I; \
110.1194 -			reg[15].I += 4; \
110.1195 -		} else { \
110.1196 -			reg[15].I &= 0xFFFFFFFE; \
110.1197 -			armNextPC  = reg[15].I; \
110.1198 -			reg[15].I += 2; \
110.1199 -		} \
110.1200 -	} else { \
110.1201 -		OPCODE \
110.1202 -	} \
110.1203 -} \
110.1204 -break; \
110.1205 -case BASE + 6: \
110.1206 -case BASE + 14: \
110.1207 -{ \
110.1208 -	/* OP Rd,Rb,Rm ROR # */ \
110.1209 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1210 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1211 -	int	 dest  = (opcode >> 12) & 15; \
110.1212 -	bool C_OUT = C_FLAG; \
110.1213 -	u32	 value; \
110.1214 -	if (shift) { \
110.1215 -		LOGICAL_ROR_REG \
110.1216 -	} else { \
110.1217 -		LOGICAL_RRX_REG \
110.1218 -	} \
110.1219 -	if (dest == 15) { \
110.1220 -		OPCODE2 \
110.1221 -		/* todo */ \
110.1222 -		if (opcode & 0x00100000) { \
110.1223 -			clockTicks++; \
110.1224 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1225 -		} \
110.1226 -		if (armState) { \
110.1227 -			reg[15].I &= 0xFFFFFFFC; \
110.1228 -			armNextPC  = reg[15].I; \
110.1229 -			reg[15].I += 4; \
110.1230 -		} else { \
110.1231 -			reg[15].I &= 0xFFFFFFFE; \
110.1232 -			armNextPC  = reg[15].I; \
110.1233 -			reg[15].I += 2; \
110.1234 -		} \
110.1235 -	} else { \
110.1236 -		OPCODE \
110.1237 -	} \
110.1238 -} \
110.1239 -break; \
110.1240 -case BASE + 1: \
110.1241 -{ \
110.1242 -	/* OP Rd,Rb,Rm LSL Rs */ \
110.1243 -	clockTicks++; \
110.1244 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1245 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1246 -	int	 dest  = (opcode >> 12) & 15; \
110.1247 -	bool C_OUT = C_FLAG; \
110.1248 -	u32	 value; \
110.1249 -	if (shift) { \
110.1250 -		if (shift == 32) { \
110.1251 -			value = 0; \
110.1252 -			C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false); \
110.1253 -		} else if (shift < 32) { \
110.1254 -			LOGICAL_LSL_REG \
110.1255 -		} else { \
110.1256 -			value = 0; \
110.1257 -			C_OUT = false; \
110.1258 -		} \
110.1259 -	} else { \
110.1260 -		value = reg[opcode & 0x0F].I; \
110.1261 -	} \
110.1262 -	if (dest == 15) { \
110.1263 -		OPCODE2 \
110.1264 -		/* todo */ \
110.1265 -		if (opcode & 0x00100000) { \
110.1266 -			clockTicks++; \
110.1267 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1268 -		} \
110.1269 -		if (armState) { \
110.1270 -			reg[15].I &= 0xFFFFFFFC; \
110.1271 -			armNextPC  = reg[15].I; \
110.1272 -			reg[15].I += 4; \
110.1273 -		} else { \
110.1274 -			reg[15].I &= 0xFFFFFFFE; \
110.1275 -			armNextPC  = reg[15].I; \
110.1276 -			reg[15].I += 2; \
110.1277 -		} \
110.1278 -	} else { \
110.1279 -		OPCODE \
110.1280 -	} \
110.1281 -} \
110.1282 -break; \
110.1283 -case BASE + 3: \
110.1284 -{ \
110.1285 -	/* OP Rd,Rb,Rm LSR Rs */ \
110.1286 -	clockTicks++; \
110.1287 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1288 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1289 -	int	 dest  = (opcode >> 12) & 15; \
110.1290 -	bool C_OUT = C_FLAG; \
110.1291 -	u32	 value; \
110.1292 -	if (shift) { \
110.1293 -		if (shift == 32) { \
110.1294 -			value = 0; \
110.1295 -			C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false); \
110.1296 -		} else if (shift < 32) { \
110.1297 -			LOGICAL_LSR_REG \
110.1298 -		} else { \
110.1299 -			value = 0; \
110.1300 -			C_OUT = false; \
110.1301 -		} \
110.1302 -	} else { \
110.1303 -		value = reg[opcode & 0x0F].I; \
110.1304 -	} \
110.1305 -	if (dest == 15) { \
110.1306 -		OPCODE2 \
110.1307 -		/* todo */ \
110.1308 -		if (opcode & 0x00100000) { \
110.1309 -			clockTicks++; \
110.1310 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1311 -		} \
110.1312 -		if (armState) { \
110.1313 -			reg[15].I &= 0xFFFFFFFC; \
110.1314 -			armNextPC  = reg[15].I; \
110.1315 -			reg[15].I += 4; \
110.1316 -		} else { \
110.1317 -			reg[15].I &= 0xFFFFFFFE; \
110.1318 -			armNextPC  = reg[15].I; \
110.1319 -			reg[15].I += 2; \
110.1320 -		} \
110.1321 -	} else { \
110.1322 -		OPCODE \
110.1323 -	} \
110.1324 -} \
110.1325 -break; \
110.1326 -case BASE + 5: \
110.1327 -{ \
110.1328 -	/* OP Rd,Rb,Rm ASR Rs */ \
110.1329 -	clockTicks++; \
110.1330 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1331 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1332 -	int	 dest  = (opcode >> 12) & 15; \
110.1333 -	bool C_OUT = C_FLAG; \
110.1334 -	u32	 value; \
110.1335 -	if (shift < 32) { \
110.1336 -		if (shift) { \
110.1337 -			LOGICAL_ASR_REG \
110.1338 -		} else { \
110.1339 -			value = reg[opcode & 0x0F].I; \
110.1340 -		} \
110.1341 -	} else { \
110.1342 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.1343 -			value = 0xFFFFFFFF; \
110.1344 -			C_OUT = true; \
110.1345 -		} else { \
110.1346 -			value = 0; \
110.1347 -			C_OUT = false; \
110.1348 -		} \
110.1349 -	} \
110.1350 -	if (dest == 15) { \
110.1351 -		OPCODE2 \
110.1352 -		/* todo */ \
110.1353 -		if (opcode & 0x00100000) { \
110.1354 -			clockTicks++; \
110.1355 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1356 -		} \
110.1357 -		if (armState) { \
110.1358 -			reg[15].I &= 0xFFFFFFFC; \
110.1359 -			armNextPC  = reg[15].I; \
110.1360 -			reg[15].I += 4; \
110.1361 -		} else { \
110.1362 -			reg[15].I &= 0xFFFFFFFE; \
110.1363 -			armNextPC  = reg[15].I; \
110.1364 -			reg[15].I += 2; \
110.1365 -		} \
110.1366 -	} else { \
110.1367 -		OPCODE \
110.1368 -	} \
110.1369 -} \
110.1370 -break; \
110.1371 -case BASE + 7: \
110.1372 -{ \
110.1373 -	/* OP Rd,Rb,Rm ROR Rs */ \
110.1374 -	clockTicks++; \
110.1375 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1376 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1377 -	int	 dest  = (opcode >> 12) & 15; \
110.1378 -	bool C_OUT = C_FLAG; \
110.1379 -	u32	 value; \
110.1380 -	if (shift) { \
110.1381 -		shift &= 0x1f; \
110.1382 -		if (shift) { \
110.1383 -			LOGICAL_ROR_REG \
110.1384 -		} else { \
110.1385 -			value = reg[opcode & 0x0F].I; \
110.1386 -			C_OUT = (value & 0x80000000 ? true : false); \
110.1387 -		} \
110.1388 -	} else { \
110.1389 -		value = reg[opcode & 0x0F].I; \
110.1390 -		C_OUT = (value & 0x80000000 ? true : false); \
110.1391 -	} \
110.1392 -	if (dest == 15) { \
110.1393 -		OPCODE2 \
110.1394 -		/* todo */ \
110.1395 -		if (opcode & 0x00100000) { \
110.1396 -			clockTicks++; \
110.1397 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1398 -		} \
110.1399 -		if (armState) { \
110.1400 -			reg[15].I &= 0xFFFFFFFC; \
110.1401 -			armNextPC  = reg[15].I; \
110.1402 -			reg[15].I += 4; \
110.1403 -		} else { \
110.1404 -			reg[15].I &= 0xFFFFFFFE; \
110.1405 -			armNextPC  = reg[15].I; \
110.1406 -			reg[15].I += 2; \
110.1407 -		} \
110.1408 -	} else { \
110.1409 -		OPCODE \
110.1410 -	} \
110.1411 -} \
110.1412 -break; \
110.1413 -case BASE + 0x200: \
110.1414 -case BASE + 0x201: \
110.1415 -case BASE + 0x202: \
110.1416 -case BASE + 0x203: \
110.1417 -case BASE + 0x204: \
110.1418 -case BASE + 0x205: \
110.1419 -case BASE + 0x206: \
110.1420 -case BASE + 0x207: \
110.1421 -case BASE + 0x208: \
110.1422 -case BASE + 0x209: \
110.1423 -case BASE + 0x20a: \
110.1424 -case BASE + 0x20b: \
110.1425 -case BASE + 0x20c: \
110.1426 -case BASE + 0x20d: \
110.1427 -case BASE + 0x20e: \
110.1428 -case BASE + 0x20f: \
110.1429 -{ \
110.1430 -	int	 shift = (opcode & 0xF00) >> 7; \
110.1431 -	int	 base  = (opcode >> 16) & 0x0F; \
110.1432 -	int	 dest  = (opcode >> 12) & 0x0F; \
110.1433 -	bool C_OUT = C_FLAG; \
110.1434 -	u32	 value; \
110.1435 -	if (shift) { \
110.1436 -		LOGICAL_ROR_IMM \
110.1437 -	} else { \
110.1438 -		value = opcode & 0xff; \
110.1439 -	} \
110.1440 -	if (dest == 15) { \
110.1441 -		OPCODE2 \
110.1442 -		/* todo */ \
110.1443 -		if (opcode & 0x00100000) { \
110.1444 -			clockTicks++; \
110.1445 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1446 -		} \
110.1447 -		if (armState) { \
110.1448 -			reg[15].I &= 0xFFFFFFFC; \
110.1449 -			armNextPC  = reg[15].I; \
110.1450 -			reg[15].I += 4; \
110.1451 -		} else { \
110.1452 -			reg[15].I &= 0xFFFFFFFE; \
110.1453 -			armNextPC  = reg[15].I; \
110.1454 -			reg[15].I += 2; \
110.1455 -		} \
110.1456 -	} else { \
110.1457 -		OPCODE \
110.1458 -	} \
110.1459 -} \
110.1460 -break;
110.1461 -
110.1462 -#define LOGICAL_DATA_OPCODE_WITHOUT_base(OPCODE, OPCODE2, BASE) \
110.1463 -case BASE: \
110.1464 -case BASE + 8: \
110.1465 -{ \
110.1466 -	/* OP Rd,Rb,Rm LSL # */ \
110.1467 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1468 -	int	 dest  = (opcode >> 12) & 15; \
110.1469 -	bool C_OUT = C_FLAG; \
110.1470 -	u32	 value; \
110.1471 -      \
110.1472 -	if (shift) { \
110.1473 -		LOGICAL_LSL_REG \
110.1474 -	} else { \
110.1475 -		value = reg[opcode & 0x0F].I; \
110.1476 -	} \
110.1477 -	if (dest == 15) { \
110.1478 -		OPCODE2 \
110.1479 -		/* todo */ \
110.1480 -		if (opcode & 0x00100000) { \
110.1481 -			clockTicks++; \
110.1482 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1483 -		} \
110.1484 -		if (armState) { \
110.1485 -			reg[15].I &= 0xFFFFFFFC; \
110.1486 -			armNextPC  = reg[15].I; \
110.1487 -			reg[15].I += 4; \
110.1488 -		} else { \
110.1489 -			reg[15].I &= 0xFFFFFFFE; \
110.1490 -			armNextPC  = reg[15].I; \
110.1491 -			reg[15].I += 2; \
110.1492 -		} \
110.1493 -	} else { \
110.1494 -		OPCODE \
110.1495 -	} \
110.1496 -} \
110.1497 -break; \
110.1498 -case BASE + 2: \
110.1499 -case BASE + 10: \
110.1500 -{ \
110.1501 -	/* OP Rd,Rb,Rm LSR # */ \
110.1502 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1503 -	int	 dest  = (opcode >> 12) & 15; \
110.1504 -	bool C_OUT = C_FLAG; \
110.1505 -	u32	 value; \
110.1506 -	if (shift) { \
110.1507 -		LOGICAL_LSR_REG \
110.1508 -	} else { \
110.1509 -		value = 0; \
110.1510 -		C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false; \
110.1511 -	} \
110.1512 -      \
110.1513 -	if (dest == 15) { \
110.1514 -		OPCODE2 \
110.1515 -		/* todo */ \
110.1516 -		if (opcode & 0x00100000) { \
110.1517 -			clockTicks++; \
110.1518 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1519 -		} \
110.1520 -		if (armState) { \
110.1521 -			reg[15].I &= 0xFFFFFFFC; \
110.1522 -			armNextPC  = reg[15].I; \
110.1523 -			reg[15].I += 4; \
110.1524 -		} else { \
110.1525 -			reg[15].I &= 0xFFFFFFFE; \
110.1526 -			armNextPC  = reg[15].I; \
110.1527 -			reg[15].I += 2; \
110.1528 -		} \
110.1529 -	} else { \
110.1530 -		OPCODE \
110.1531 -	} \
110.1532 -} \
110.1533 -break; \
110.1534 -case BASE + 4: \
110.1535 -case BASE + 12: \
110.1536 -{ \
110.1537 -	/* OP Rd,Rb,Rm ASR # */ \
110.1538 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1539 -	int	 dest  = (opcode >> 12) & 15; \
110.1540 -	bool C_OUT = C_FLAG; \
110.1541 -	u32	 value; \
110.1542 -	if (shift) { \
110.1543 -		LOGICAL_ASR_REG \
110.1544 -	} else { \
110.1545 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.1546 -			value = 0xFFFFFFFF; \
110.1547 -			C_OUT = true; \
110.1548 -		} else { \
110.1549 -			value = 0; \
110.1550 -			C_OUT = false; \
110.1551 -		}                   \
110.1552 -	} \
110.1553 -      \
110.1554 -	if (dest == 15) { \
110.1555 -		OPCODE2 \
110.1556 -		/* todo */ \
110.1557 -		if (opcode & 0x00100000) { \
110.1558 -			clockTicks++; \
110.1559 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1560 -		} \
110.1561 -		if (armState) { \
110.1562 -			reg[15].I &= 0xFFFFFFFC; \
110.1563 -			armNextPC  = reg[15].I; \
110.1564 -			reg[15].I += 4; \
110.1565 -		} else { \
110.1566 -			reg[15].I &= 0xFFFFFFFE; \
110.1567 -			armNextPC  = reg[15].I; \
110.1568 -			reg[15].I += 2; \
110.1569 -		} \
110.1570 -	} else { \
110.1571 -		OPCODE \
110.1572 -	} \
110.1573 -} \
110.1574 -break; \
110.1575 -case BASE + 6: \
110.1576 -case BASE + 14: \
110.1577 -{ \
110.1578 -	/* OP Rd,Rb,Rm ROR # */ \
110.1579 -	int	 shift = (opcode >> 7) & 0x1F; \
110.1580 -	int	 dest  = (opcode >> 12) & 15; \
110.1581 -	bool C_OUT = C_FLAG; \
110.1582 -	u32	 value; \
110.1583 -	if (shift) { \
110.1584 -		LOGICAL_ROR_REG \
110.1585 -	} else { \
110.1586 -		LOGICAL_RRX_REG \
110.1587 -	} \
110.1588 -	if (dest == 15) { \
110.1589 -		OPCODE2 \
110.1590 -		/* todo */ \
110.1591 -		if (opcode & 0x00100000) { \
110.1592 -			clockTicks++; \
110.1593 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1594 -		} \
110.1595 -		if (armState) { \
110.1596 -			reg[15].I &= 0xFFFFFFFC; \
110.1597 -			armNextPC  = reg[15].I; \
110.1598 -			reg[15].I += 4; \
110.1599 -		} else { \
110.1600 -			reg[15].I &= 0xFFFFFFFE; \
110.1601 -			armNextPC  = reg[15].I; \
110.1602 -			reg[15].I += 2; \
110.1603 -		} \
110.1604 -	} else { \
110.1605 -		OPCODE \
110.1606 -	} \
110.1607 -} \
110.1608 -break; \
110.1609 -case BASE + 1: \
110.1610 -{ \
110.1611 -	/* OP Rd,Rb,Rm LSL Rs */ \
110.1612 -	clockTicks++; \
110.1613 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1614 -	int	 dest  = (opcode >> 12) & 15; \
110.1615 -	bool C_OUT = C_FLAG; \
110.1616 -	u32	 value; \
110.1617 -	if (shift) { \
110.1618 -		if (shift == 32) { \
110.1619 -			value = 0; \
110.1620 -			C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false); \
110.1621 -		} else if (shift < 32) { \
110.1622 -			LOGICAL_LSL_REG \
110.1623 -		} else { \
110.1624 -			value = 0; \
110.1625 -			C_OUT = false; \
110.1626 -		} \
110.1627 -	} else { \
110.1628 -		value = reg[opcode & 0x0F].I; \
110.1629 -	} \
110.1630 -	if (dest == 15) { \
110.1631 -		OPCODE2 \
110.1632 -		/* todo */ \
110.1633 -		if (opcode & 0x00100000) { \
110.1634 -			clockTicks++; \
110.1635 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1636 -		} \
110.1637 -		if (armState) { \
110.1638 -			reg[15].I &= 0xFFFFFFFC; \
110.1639 -			armNextPC  = reg[15].I; \
110.1640 -			reg[15].I += 4; \
110.1641 -		} else { \
110.1642 -			reg[15].I &= 0xFFFFFFFE; \
110.1643 -			armNextPC  = reg[15].I; \
110.1644 -			reg[15].I += 2; \
110.1645 -		} \
110.1646 -	} else { \
110.1647 -		OPCODE \
110.1648 -	} \
110.1649 -} \
110.1650 -break; \
110.1651 -case BASE + 3: \
110.1652 -{ \
110.1653 -	/* OP Rd,Rb,Rm LSR Rs */ \
110.1654 -	clockTicks++; \
110.1655 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1656 -	int	 dest  = (opcode >> 12) & 15; \
110.1657 -	bool C_OUT = C_FLAG; \
110.1658 -	u32	 value; \
110.1659 -	if (shift) { \
110.1660 -		if (shift == 32) { \
110.1661 -			value = 0; \
110.1662 -			C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false); \
110.1663 -		} else if (shift < 32) { \
110.1664 -			LOGICAL_LSR_REG \
110.1665 -		} else { \
110.1666 -			value = 0; \
110.1667 -			C_OUT = false; \
110.1668 -		} \
110.1669 -	} else { \
110.1670 -		value = reg[opcode & 0x0F].I; \
110.1671 -	} \
110.1672 -	if (dest == 15) { \
110.1673 -		OPCODE2 \
110.1674 -		/* todo */ \
110.1675 -		if (opcode & 0x00100000) { \
110.1676 -			clockTicks++; \
110.1677 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1678 -		} \
110.1679 -		if (armState) { \
110.1680 -			reg[15].I &= 0xFFFFFFFC; \
110.1681 -			armNextPC  = reg[15].I; \
110.1682 -			reg[15].I += 4; \
110.1683 -		} else { \
110.1684 -			reg[15].I &= 0xFFFFFFFE; \
110.1685 -			armNextPC  = reg[15].I; \
110.1686 -			reg[15].I += 2; \
110.1687 -		} \
110.1688 -	} else { \
110.1689 -		OPCODE \
110.1690 -	} \
110.1691 -} \
110.1692 -break; \
110.1693 -case BASE + 5: \
110.1694 -{ \
110.1695 -	/* OP Rd,Rb,Rm ASR Rs */ \
110.1696 -	clockTicks++; \
110.1697 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1698 -	int	 dest  = (opcode >> 12) & 15; \
110.1699 -	bool C_OUT = C_FLAG; \
110.1700 -	u32	 value; \
110.1701 -	if (shift < 32) { \
110.1702 -		if (shift) { \
110.1703 -			LOGICAL_ASR_REG \
110.1704 -		} else { \
110.1705 -			value = reg[opcode & 0x0F].I; \
110.1706 -		} \
110.1707 -	} else { \
110.1708 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.1709 -			value = 0xFFFFFFFF; \
110.1710 -			C_OUT = true; \
110.1711 -		} else { \
110.1712 -			value = 0; \
110.1713 -			C_OUT = false; \
110.1714 -		} \
110.1715 -	} \
110.1716 -	if (dest == 15) { \
110.1717 -		OPCODE2 \
110.1718 -		/* todo */ \
110.1719 -		if (opcode & 0x00100000) { \
110.1720 -			clockTicks++; \
110.1721 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1722 -		} \
110.1723 -		if (armState) { \
110.1724 -			reg[15].I &= 0xFFFFFFFC; \
110.1725 -			armNextPC  = reg[15].I; \
110.1726 -			reg[15].I += 4; \
110.1727 -		} else { \
110.1728 -			reg[15].I &= 0xFFFFFFFE; \
110.1729 -			armNextPC  = reg[15].I; \
110.1730 -			reg[15].I += 2; \
110.1731 -		} \
110.1732 -	} else { \
110.1733 -		OPCODE \
110.1734 -	} \
110.1735 -} \
110.1736 -break; \
110.1737 -case BASE + 7: \
110.1738 -{ \
110.1739 -	/* OP Rd,Rb,Rm ROR Rs */ \
110.1740 -	clockTicks++; \
110.1741 -	int	 shift = reg[(opcode >> 8) & 15].B.B0; \
110.1742 -	int	 dest  = (opcode >> 12) & 15; \
110.1743 -	bool C_OUT = C_FLAG; \
110.1744 -	u32	 value; \
110.1745 -	if (shift) { \
110.1746 -		shift &= 0x1f; \
110.1747 -		if (shift) { \
110.1748 -			LOGICAL_ROR_REG \
110.1749 -		} else { \
110.1750 -			value = reg[opcode & 0x0F].I; \
110.1751 -			C_OUT = (value & 0x80000000 ? true : false); \
110.1752 -		} \
110.1753 -	} else { \
110.1754 -		value = reg[opcode & 0x0F].I; \
110.1755 -		C_OUT = (value & 0x80000000 ? true : false); \
110.1756 -	} \
110.1757 -	if (dest == 15) { \
110.1758 -		OPCODE2 \
110.1759 -		/* todo */ \
110.1760 -		if (opcode & 0x00100000) { \
110.1761 -			clockTicks++; \
110.1762 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1763 -		} \
110.1764 -		if (armState) { \
110.1765 -			reg[15].I &= 0xFFFFFFFC; \
110.1766 -			armNextPC  = reg[15].I; \
110.1767 -			reg[15].I += 4; \
110.1768 -		} else { \
110.1769 -			reg[15].I &= 0xFFFFFFFE; \
110.1770 -			armNextPC  = reg[15].I; \
110.1771 -			reg[15].I += 2; \
110.1772 -		} \
110.1773 -	} else { \
110.1774 -		OPCODE \
110.1775 -	} \
110.1776 -} \
110.1777 -break; \
110.1778 -case BASE + 0x200: \
110.1779 -case BASE + 0x201: \
110.1780 -case BASE + 0x202: \
110.1781 -case BASE + 0x203: \
110.1782 -case BASE + 0x204: \
110.1783 -case BASE + 0x205: \
110.1784 -case BASE + 0x206: \
110.1785 -case BASE + 0x207: \
110.1786 -case BASE + 0x208: \
110.1787 -case BASE + 0x209: \
110.1788 -case BASE + 0x20a: \
110.1789 -case BASE + 0x20b: \
110.1790 -case BASE + 0x20c: \
110.1791 -case BASE + 0x20d: \
110.1792 -case BASE + 0x20e: \
110.1793 -case BASE + 0x20f: \
110.1794 -{ \
110.1795 -	int	 shift = (opcode & 0xF00) >> 7; \
110.1796 -	int	 dest  = (opcode >> 12) & 0x0F; \
110.1797 -	bool C_OUT = C_FLAG; \
110.1798 -	u32	 value; \
110.1799 -	if (shift) { \
110.1800 -		LOGICAL_ROR_IMM \
110.1801 -	} else { \
110.1802 -		value = opcode & 0xff; \
110.1803 -	} \
110.1804 -	if (dest == 15) { \
110.1805 -		OPCODE2 \
110.1806 -		/* todo */ \
110.1807 -		if (opcode & 0x00100000) { \
110.1808 -			clockTicks++; \
110.1809 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1810 -		} \
110.1811 -		if (armState) { \
110.1812 -			reg[15].I &= 0xFFFFFFFC; \
110.1813 -			armNextPC  = reg[15].I; \
110.1814 -			reg[15].I += 4; \
110.1815 -		} else { \
110.1816 -			reg[15].I &= 0xFFFFFFFE; \
110.1817 -			armNextPC  = reg[15].I; \
110.1818 -			reg[15].I += 2; \
110.1819 -		} \
110.1820 -	} else { \
110.1821 -		OPCODE \
110.1822 -	} \
110.1823 -} \
110.1824 -break;
110.1825 -
110.1826 -#define ARITHMETIC_DATA_OPCODE(OPCODE, OPCODE2, BASE) \
110.1827 -case BASE: \
110.1828 -case BASE + 8: \
110.1829 -{ \
110.1830 -	/* OP Rd,Rb,Rm LSL # */ \
110.1831 -	int base  = (opcode >> 16) & 0x0F; \
110.1832 -	int shift = (opcode >> 7) & 0x1F; \
110.1833 -	int dest  = (opcode >> 12) & 15; \
110.1834 -	u32 value; \
110.1835 -	if (shift) { \
110.1836 -		ARITHMETIC_LSL_REG \
110.1837 -	} else { \
110.1838 -		value = reg[opcode & 0x0F].I; \
110.1839 -	} \
110.1840 -	if (dest == 15) { \
110.1841 -		OPCODE2 \
110.1842 -		/* todo */ \
110.1843 -		if (opcode & 0x00100000) { \
110.1844 -			clockTicks++; \
110.1845 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1846 -		} \
110.1847 -		if (armState) { \
110.1848 -			reg[15].I &= 0xFFFFFFFC; \
110.1849 -			armNextPC  = reg[15].I; \
110.1850 -			reg[15].I += 4; \
110.1851 -		} else { \
110.1852 -			reg[15].I &= 0xFFFFFFFE; \
110.1853 -			armNextPC  = reg[15].I; \
110.1854 -			reg[15].I += 2; \
110.1855 -		} \
110.1856 -	} else { \
110.1857 -		OPCODE \
110.1858 -	} \
110.1859 -} \
110.1860 -break; \
110.1861 -case BASE + 2: \
110.1862 -case BASE + 10: \
110.1863 -{ \
110.1864 -	/* OP Rd,Rb,Rm LSR # */ \
110.1865 -	int base  = (opcode >> 16) & 0x0F; \
110.1866 -	int shift = (opcode >> 7) & 0x1F; \
110.1867 -	int dest  = (opcode >> 12) & 15; \
110.1868 -	u32 value; \
110.1869 -	if (shift) { \
110.1870 -		ARITHMETIC_LSR_REG \
110.1871 -	} else { \
110.1872 -		value = 0; \
110.1873 -	} \
110.1874 -	if (dest == 15) { \
110.1875 -		OPCODE2 \
110.1876 -		/* todo */ \
110.1877 -		if (opcode & 0x00100000) { \
110.1878 -			clockTicks++; \
110.1879 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1880 -		} \
110.1881 -		if (armState) { \
110.1882 -			reg[15].I &= 0xFFFFFFFC; \
110.1883 -			armNextPC  = reg[15].I; \
110.1884 -			reg[15].I += 4; \
110.1885 -		} else { \
110.1886 -			reg[15].I &= 0xFFFFFFFE; \
110.1887 -			armNextPC  = reg[15].I; \
110.1888 -			reg[15].I += 2; \
110.1889 -		} \
110.1890 -	} else { \
110.1891 -		OPCODE \
110.1892 -	} \
110.1893 -} \
110.1894 -break; \
110.1895 -case BASE + 4: \
110.1896 -case BASE + 12: \
110.1897 -{ \
110.1898 -	/* OP Rd,Rb,Rm ASR # */ \
110.1899 -	int base  = (opcode >> 16) & 0x0F; \
110.1900 -	int shift = (opcode >> 7) & 0x1F; \
110.1901 -	int dest  = (opcode >> 12) & 15; \
110.1902 -	u32 value; \
110.1903 -	if (shift) { \
110.1904 -		ARITHMETIC_ASR_REG \
110.1905 -	} else { \
110.1906 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.1907 -			value = 0xFFFFFFFF; \
110.1908 -		} else value = 0; \
110.1909 -	} \
110.1910 -	if (dest == 15) { \
110.1911 -		OPCODE2 \
110.1912 -		/* todo */ \
110.1913 -		if (opcode & 0x00100000) { \
110.1914 -			clockTicks++; \
110.1915 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1916 -		} \
110.1917 -		if (armState) { \
110.1918 -			reg[15].I &= 0xFFFFFFFC; \
110.1919 -			armNextPC  = reg[15].I; \
110.1920 -			reg[15].I += 4; \
110.1921 -		} else { \
110.1922 -			reg[15].I &= 0xFFFFFFFE; \
110.1923 -			armNextPC  = reg[15].I; \
110.1924 -			reg[15].I += 2; \
110.1925 -		} \
110.1926 -	} else { \
110.1927 -		OPCODE \
110.1928 -	} \
110.1929 -} \
110.1930 -break; \
110.1931 -case BASE + 6: \
110.1932 -case BASE + 14: \
110.1933 -{ \
110.1934 -	/* OP Rd,Rb,Rm ROR # */ \
110.1935 -	int base  = (opcode >> 16) & 0x0F; \
110.1936 -	int shift = (opcode >> 7) & 0x1F; \
110.1937 -	int dest  = (opcode >> 12) & 15; \
110.1938 -	u32 value; \
110.1939 -	if (shift) { \
110.1940 -		ARITHMETIC_ROR_REG \
110.1941 -	} else { \
110.1942 -		ARITHMETIC_RRX_REG \
110.1943 -	} \
110.1944 -	if (dest == 15) { \
110.1945 -		OPCODE2 \
110.1946 -		/* todo */ \
110.1947 -		if (opcode & 0x00100000) { \
110.1948 -			clockTicks++; \
110.1949 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1950 -		} \
110.1951 -		if (armState) { \
110.1952 -			reg[15].I &= 0xFFFFFFFC; \
110.1953 -			armNextPC  = reg[15].I; \
110.1954 -			reg[15].I += 4; \
110.1955 -		} else { \
110.1956 -			reg[15].I &= 0xFFFFFFFE; \
110.1957 -			armNextPC  = reg[15].I; \
110.1958 -			reg[15].I += 2; \
110.1959 -		} \
110.1960 -	} else { \
110.1961 -		OPCODE \
110.1962 -	} \
110.1963 -} \
110.1964 -break; \
110.1965 -case BASE + 1: \
110.1966 -{ \
110.1967 -	/* OP Rd,Rb,Rm LSL Rs */ \
110.1968 -	clockTicks++; \
110.1969 -	int base  = (opcode >> 16) & 0x0F; \
110.1970 -	int shift = reg[(opcode >> 8) & 15].B.B0; \
110.1971 -	int dest  = (opcode >> 12) & 15; \
110.1972 -	u32 value; \
110.1973 -	if (shift) { \
110.1974 -		if (shift == 32) { \
110.1975 -			value = 0; \
110.1976 -		} else if (shift < 32) { \
110.1977 -			ARITHMETIC_LSL_REG \
110.1978 -		} else value = 0; \
110.1979 -	} else { \
110.1980 -		value = reg[opcode & 0x0F].I; \
110.1981 -	} \
110.1982 -	if (dest == 15) { \
110.1983 -		OPCODE2 \
110.1984 -		/* todo */ \
110.1985 -		if (opcode & 0x00100000) { \
110.1986 -			clockTicks++; \
110.1987 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.1988 -		} \
110.1989 -		if (armState) { \
110.1990 -			reg[15].I &= 0xFFFFFFFC; \
110.1991 -			armNextPC  = reg[15].I; \
110.1992 -			reg[15].I += 4; \
110.1993 -		} else { \
110.1994 -			reg[15].I &= 0xFFFFFFFE; \
110.1995 -			armNextPC  = reg[15].I; \
110.1996 -			reg[15].I += 2; \
110.1997 -		} \
110.1998 -	} else { \
110.1999 -		OPCODE \
110.2000 -	} \
110.2001 -} \
110.2002 -break; \
110.2003 -case BASE + 3: \
110.2004 -{ \
110.2005 -	/* OP Rd,Rb,Rm LSR Rs */ \
110.2006 -	clockTicks++; \
110.2007 -	int base  = (opcode >> 16) & 0x0F; \
110.2008 -	int shift = reg[(opcode >> 8) & 15].B.B0; \
110.2009 -	int dest  = (opcode >> 12) & 15; \
110.2010 -	u32 value; \
110.2011 -	if (shift) { \
110.2012 -		if (shift == 32) { \
110.2013 -			value = 0; \
110.2014 -		} else if (shift < 32) { \
110.2015 -			ARITHMETIC_LSR_REG \
110.2016 -		} else value = 0; \
110.2017 -	} else { \
110.2018 -		value = reg[opcode & 0x0F].I; \
110.2019 -	} \
110.2020 -	if (dest == 15) { \
110.2021 -		OPCODE2 \
110.2022 -		/* todo */ \
110.2023 -		if (opcode & 0x00100000) { \
110.2024 -			clockTicks++; \
110.2025 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.2026 -		} \
110.2027 -		if (armState) { \
110.2028 -			reg[15].I &= 0xFFFFFFFC; \
110.2029 -			armNextPC  = reg[15].I; \
110.2030 -			reg[15].I += 4; \
110.2031 -		} else { \
110.2032 -			reg[15].I &= 0xFFFFFFFE; \
110.2033 -			armNextPC  = reg[15].I; \
110.2034 -			reg[15].I += 2; \
110.2035 -		} \
110.2036 -	} else { \
110.2037 -		OPCODE \
110.2038 -	} \
110.2039 -} \
110.2040 -break; \
110.2041 -case BASE + 5: \
110.2042 -{ \
110.2043 -	/* OP Rd,Rb,Rm ASR Rs */ \
110.2044 -	clockTicks++; \
110.2045 -	int base  = (opcode >> 16) & 0x0F; \
110.2046 -	int shift = reg[(opcode >> 8) & 15].B.B0; \
110.2047 -	int dest  = (opcode >> 12) & 15; \
110.2048 -	u32 value; \
110.2049 -	if (shift < 32) { \
110.2050 -		if (shift) { \
110.2051 -			ARITHMETIC_ASR_REG \
110.2052 -		} else { \
110.2053 -			value = reg[opcode & 0x0F].I; \
110.2054 -		} \
110.2055 -	} else { \
110.2056 -		if (reg[opcode & 0x0F].I & 0x80000000) { \
110.2057 -			value = 0xFFFFFFFF; \
110.2058 -		} else value = 0; \
110.2059 -	} \
110.2060 -	if (dest == 15) { \
110.2061 -		OPCODE2 \
110.2062 -		/* todo */ \
110.2063 -		if (opcode & 0x00100000) { \
110.2064 -			clockTicks++; \
110.2065 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.2066 -		} \
110.2067 -		if (armState) { \
110.2068 -			reg[15].I &= 0xFFFFFFFC; \
110.2069 -			armNextPC  = reg[15].I; \
110.2070 -			reg[15].I += 4; \
110.2071 -		} else { \
110.2072 -			reg[15].I &= 0xFFFFFFFE; \
110.2073 -			armNextPC  = reg[15].I; \
110.2074 -			reg[15].I += 2; \
110.2075 -		} \
110.2076 -	} else { \
110.2077 -		OPCODE \
110.2078 -	} \
110.2079 -} \
110.2080 -break; \
110.2081 -case BASE + 7: \
110.2082 -{ \
110.2083 -	/* OP Rd,Rb,Rm ROR Rs */ \
110.2084 -	clockTicks++; \
110.2085 -	int base  = (opcode >> 16) & 0x0F; \
110.2086 -	int shift = reg[(opcode >> 8) & 15].B.B0; \
110.2087 -	int dest  = (opcode >> 12) & 15; \
110.2088 -	u32 value; \
110.2089 -	if (shift) { \
110.2090 -		shift &= 0x1f; \
110.2091 -		if (shift) { \
110.2092 -			ARITHMETIC_ROR_REG \
110.2093 -		} else { \
110.2094 -			value = reg[opcode & 0x0F].I; \
110.2095 -		} \
110.2096 -	} else { \
110.2097 -		value = reg[opcode & 0x0F].I; \
110.2098 -	} \
110.2099 -	if (dest == 15) { \
110.2100 -		OPCODE2 \
110.2101 -		/* todo */ \
110.2102 -		if (opcode & 0x00100000) { \
110.2103 -			clockTicks++; \
110.2104 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.2105 -		} \
110.2106 -		if (armState) { \
110.2107 -			reg[15].I &= 0xFFFFFFFC; \
110.2108 -			armNextPC  = reg[15].I; \
110.2109 -			reg[15].I += 4; \
110.2110 -		} else { \
110.2111 -			reg[15].I &= 0xFFFFFFFE; \
110.2112 -			armNextPC  = reg[15].I; \
110.2113 -			reg[15].I += 2; \
110.2114 -		} \
110.2115 -	} else { \
110.2116 -		OPCODE \
110.2117 -	} \
110.2118 -} \
110.2119 -break; \
110.2120 -case BASE + 0x200: \
110.2121 -case BASE + 0x201: \
110.2122 -case BASE + 0x202: \
110.2123 -case BASE + 0x203: \
110.2124 -case BASE + 0x204: \
110.2125 -case BASE + 0x205: \
110.2126 -case BASE + 0x206: \
110.2127 -case BASE + 0x207: \
110.2128 -case BASE + 0x208: \
110.2129 -case BASE + 0x209: \
110.2130 -case BASE + 0x20a: \
110.2131 -case BASE + 0x20b: \
110.2132 -case BASE + 0x20c: \
110.2133 -case BASE + 0x20d: \
110.2134 -case BASE + 0x20e: \
110.2135 -case BASE + 0x20f: \
110.2136 -{ \
110.2137 -	int shift = (opcode & 0xF00) >> 7; \
110.2138 -	int base  = (opcode >> 16) & 0x0F; \
110.2139 -	int dest  = (opcode >> 12) & 0x0F; \
110.2140 -	u32 value; \
110.2141 -	{ \
110.2142 -		ARITHMETIC_ROR_IMM \
110.2143 -	} \
110.2144 -	if (dest == 15) { \
110.2145 -		OPCODE2 \
110.2146 -		/* todo */ \
110.2147 -		if (opcode & 0x00100000) { \
110.2148 -			clockTicks++; \
110.2149 -			CPUSwitchMode(reg[17].I & 0x1f, false); \
110.2150 -		} \
110.2151 -		if (armState) { \
110.2152 -			reg[15].I &= 0xFFFFFFFC; \
110.2153 -			armNextPC  = reg[15].I; \
110.2154 -			reg[15].I += 4; \
110.2155 -		} else { \
110.2156 -			reg[15].I &= 0xFFFFFFFE; \
110.2157 -			armNextPC  = reg[15].I; \
110.2158 -			reg[15].I += 2; \
110.2159 -		} \
110.2160 -	} else { \
110.2161 -		OPCODE \
110.2162 -	} \
110.2163 -} \
110.2164 -break;
110.2165 -
110.2166 -u32 opcode = CPUReadMemoryQuick(armNextPC);
110.2167 -
110.2168 -clockTicks = memoryWaitFetch32[(armNextPC >> 24) & 15];
110.2169 -
110.2170 -#ifndef FINAL_VERSION
110.2171 -if (armNextPC == stop)
110.2172 -{
110.2173 -	armNextPC++;
110.2174 -}
110.2175 -#endif
110.2176 -
110.2177 -armNextPC  = reg[15].I;
110.2178 -reg[15].I += 4;
110.2179 -int cond = opcode >> 28;
110.2180 -// suggested optimization for frequent cases
110.2181 -bool cond_res;
110.2182 -if (cond == 0x0e)
110.2183 -{
110.2184 -	cond_res = true;
110.2185 -}
110.2186 -else
110.2187 -{
110.2188 -	switch (cond)
110.2189 -	{
110.2190 -	case 0x00: // EQ
110.2191 -		cond_res = Z_FLAG;
110.2192 -		break;
110.2193 -	case 0x01: // NE
110.2194 -		cond_res = !Z_FLAG;
110.2195 -		break;
110.2196 -	case 0x02: // CS
110.2197 -		cond_res = C_FLAG;
110.2198 -		break;
110.2199 -	case 0x03: // CC
110.2200 -		cond_res = !C_FLAG;
110.2201 -		break;
110.2202 -	case 0x04: // MI
110.2203 -		cond_res = N_FLAG;
110.2204 -		break;
110.2205 -	case 0x05: // PL
110.2206 -		cond_res = !N_FLAG;
110.2207 -		break;
110.2208 -	case 0x06: // VS
110.2209 -		cond_res = V_FLAG;
110.2210 -		break;
110.2211 -	case 0x07: // VC
110.2212 -		cond_res = !V_FLAG;
110.2213 -		break;
110.2214 -	case 0x08: // HI
110.2215 -		cond_res = C_FLAG && !Z_FLAG;
110.2216 -		break;
110.2217 -	case 0x09: // LS
110.2218 -		cond_res = !C_FLAG || Z_FLAG;
110.2219 -		break;
110.2220 -	case 0x0A: // GE
110.2221 -		cond_res = N_FLAG == V_FLAG;
110.2222 -		break;
110.2223 -	case 0x0B: // LT
110.2224 -		cond_res = N_FLAG != V_FLAG;
110.2225 -		break;
110.2226 -	case 0x0C: // GT
110.2227 -		cond_res = !Z_FLAG && (N_FLAG == V_FLAG);
110.2228 -		break;
110.2229 -	case 0x0D: // LE
110.2230 -		cond_res = Z_FLAG || (N_FLAG != V_FLAG);
110.2231 -		break;
110.2232 -	case 0x0E:
110.2233 -		cond_res = true;
110.2234 -		break;
110.2235 -	case 0x0F:
110.2236 -	default:
110.2237 -		// ???
110.2238 -		cond_res = false;
110.2239 -		break;
110.2240 -	}
110.2241 -}
110.2242 -
110.2243 -if (cond_res)
110.2244 -{
110.2245 -	switch (((opcode >> 16) & 0xFF0) | ((opcode >> 4) & 0x0F))
110.2246 -	{
110.2247 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND,  OP_AND, 0x000);
110.2248 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_ANDS, OP_AND, 0x010);
110.2249 -	case 0x009:
110.2250 -	{
110.2251 -		// MUL Rd, Rm, Rs
110.2252 -		int dest = (opcode >> 16) & 0x0F;
110.2253 -		int mult = (opcode & 0x0F);
110.2254 -		u32 rs	 = reg[(opcode >> 8) & 0x0F].I;
110.2255 -		reg[dest].I = reg[mult].I * rs;
110.2256 -		if (((s32)rs) < 0)
110.2257 -			rs = ~rs;
110.2258 -		if ((rs & 0xFFFFFF00) == 0)
110.2259 -			clockTicks += 2;
110.2260 -		else if ((rs & 0xFFFF0000) == 0)
110.2261 -			clockTicks += 3;
110.2262 -		else if ((rs & 0xFF000000) == 0)
110.2263 -			clockTicks += 4;
110.2264 -		else
110.2265 -			clockTicks += 5;
110.2266 -	}
110.2267 -	break;
110.2268 -	case 0x019:
110.2269 -	{
110.2270 -		// MULS Rd, Rm, Rs
110.2271 -		int dest = (opcode >> 16) & 0x0F;
110.2272 -		int mult = (opcode & 0x0F);
110.2273 -		u32 rs	 = reg[(opcode >> 8) & 0x0F].I;
110.2274 -		reg[dest].I = reg[mult].I * rs;
110.2275 -		N_FLAG		= (reg[dest].I & 0x80000000) ? true : false;
110.2276 -		Z_FLAG		= (reg[dest].I) ? false : true;
110.2277 -		if (((s32)rs) < 0)
110.2278 -			rs = ~rs;
110.2279 -		if ((rs & 0xFFFFFF00) == 0)
110.2280 -			clockTicks += 2;
110.2281 -		else if ((rs & 0xFFFF0000) == 0)
110.2282 -			clockTicks += 3;
110.2283 -		else if ((rs & 0xFF000000) == 0)
110.2284 -			clockTicks += 4;
110.2285 -		else
110.2286 -			clockTicks += 5;
110.2287 -	}
110.2288 -	break;
110.2289 -	case 0x00b:
110.2290 -	case 0x02b:
110.2291 -	{
110.2292 -		// STRH Rd, [Rn], -Rm
110.2293 -		int base	= (opcode >> 16) & 0x0F;
110.2294 -		int dest	= (opcode >> 12) & 0x0F;
110.2295 -		u32 address = reg[base].I;
110.2296 -		int offset	= reg[opcode & 0x0F].I;
110.2297 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2298 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2299 -		address	   -= offset;
110.2300 -		reg[base].I = address;
110.2301 -	}
110.2302 -	break;
110.2303 -	case 0x04b:
110.2304 -	case 0x06b:
110.2305 -	{
110.2306 -		// STRH Rd, [Rn], #-offset
110.2307 -		int base	= (opcode >> 16) & 0x0F;
110.2308 -		int dest	= (opcode >> 12) & 0x0F;
110.2309 -		u32 address = reg[base].I;
110.2310 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2311 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2312 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2313 -		address	   -= offset;
110.2314 -		reg[base].I = address;
110.2315 -	}
110.2316 -	break;
110.2317 -	case 0x08b:
110.2318 -	case 0x0ab:
110.2319 -	{
110.2320 -		// STRH Rd, [Rn], Rm
110.2321 -		int base	= (opcode >> 16) & 0x0F;
110.2322 -		int dest	= (opcode >> 12) & 0x0F;
110.2323 -		u32 address = reg[base].I;
110.2324 -		int offset	= reg[opcode & 0x0F].I;
110.2325 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2326 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2327 -		address	   += offset;
110.2328 -		reg[base].I = address;
110.2329 -	}
110.2330 -	break;
110.2331 -	case 0x0cb:
110.2332 -	case 0x0eb:
110.2333 -	{
110.2334 -		// STRH Rd, [Rn], #offset
110.2335 -		int base	= (opcode >> 16) & 0x0F;
110.2336 -		int dest	= (opcode >> 12) & 0x0F;
110.2337 -		u32 address = reg[base].I;
110.2338 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2339 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2340 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2341 -		address	   += offset;
110.2342 -		reg[base].I = address;
110.2343 -	}
110.2344 -	break;
110.2345 -	case 0x10b:
110.2346 -	{
110.2347 -		// STRH Rd, [Rn, -Rm]
110.2348 -		int base	= (opcode >> 16) & 0x0F;
110.2349 -		int dest	= (opcode >> 12) & 0x0F;
110.2350 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2351 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2352 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2353 -	}
110.2354 -	break;
110.2355 -	case 0x12b:
110.2356 -	{
110.2357 -		// STRH Rd, [Rn, -Rm]!
110.2358 -		int base	= (opcode >> 16) & 0x0F;
110.2359 -		int dest	= (opcode >> 12) & 0x0F;
110.2360 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2361 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2362 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2363 -		reg[base].I = address;
110.2364 -	}
110.2365 -	break;
110.2366 -	case 0x14b:
110.2367 -	{
110.2368 -		// STRH Rd, [Rn, -#offset]
110.2369 -		int base	= (opcode >> 16) & 0x0F;
110.2370 -		int dest	= (opcode >> 12) & 0x0F;
110.2371 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2372 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2373 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2374 -	}
110.2375 -	break;
110.2376 -	case 0x16b:
110.2377 -	{
110.2378 -		// STRH Rd, [Rn, -#offset]!
110.2379 -		int base	= (opcode >> 16) & 0x0F;
110.2380 -		int dest	= (opcode >> 12) & 0x0F;
110.2381 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2382 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2383 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2384 -		reg[base].I = address;
110.2385 -	}
110.2386 -	break;
110.2387 -	case 0x18b:
110.2388 -	{
110.2389 -		// STRH Rd, [Rn, Rm]
110.2390 -		int base	= (opcode >> 16) & 0x0F;
110.2391 -		int dest	= (opcode >> 12) & 0x0F;
110.2392 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2393 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2394 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2395 -	}
110.2396 -	break;
110.2397 -	case 0x1ab:
110.2398 -	{
110.2399 -		// STRH Rd, [Rn, Rm]!
110.2400 -		int base	= (opcode >> 16) & 0x0F;
110.2401 -		int dest	= (opcode >> 12) & 0x0F;
110.2402 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2403 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2404 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2405 -		reg[base].I = address;
110.2406 -	}
110.2407 -	break;
110.2408 -	case 0x1cb:
110.2409 -	{
110.2410 -		// STRH Rd, [Rn, #offset]
110.2411 -		int base	= (opcode >> 16) & 0x0F;
110.2412 -		int dest	= (opcode >> 12) & 0x0F;
110.2413 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2414 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2415 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2416 -	}
110.2417 -	break;
110.2418 -	case 0x1eb:
110.2419 -	{
110.2420 -		// STRH Rd, [Rn, #offset]!
110.2421 -		int base	= (opcode >> 16) & 0x0F;
110.2422 -		int dest	= (opcode >> 12) & 0x0F;
110.2423 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2424 -		clockTicks += 4 + CPUUpdateTicksAccess16(address);
110.2425 -		CPUWriteHalfWord(address, reg[dest].W.W0);
110.2426 -		reg[base].I = address;
110.2427 -	}
110.2428 -	break;
110.2429 -	case 0x01b:
110.2430 -	case 0x03b:
110.2431 -	{
110.2432 -		// LDRH Rd, [Rn], -Rm
110.2433 -		int base	= (opcode >> 16) & 0x0F;
110.2434 -		int dest	= (opcode >> 12) & 0x0F;
110.2435 -		u32 address = reg[base].I;
110.2436 -		int offset	= reg[opcode & 0x0F].I;
110.2437 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2438 -		reg[dest].I = CPUReadHalfWord(address);
110.2439 -		if (dest != base)
110.2440 -		{
110.2441 -			address	   -= offset;
110.2442 -			reg[base].I = address;
110.2443 -		}
110.2444 -	}
110.2445 -	break;
110.2446 -	case 0x05b:
110.2447 -	case 0x07b:
110.2448 -	{
110.2449 -		// LDRH Rd, [Rn], #-offset
110.2450 -		int base	= (opcode >> 16) & 0x0F;
110.2451 -		int dest	= (opcode >> 12) & 0x0F;
110.2452 -		u32 address = reg[base].I;
110.2453 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2454 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2455 -		reg[dest].I = CPUReadHalfWord(address);
110.2456 -		if (dest != base)
110.2457 -		{
110.2458 -			address	   -= offset;
110.2459 -			reg[base].I = address;
110.2460 -		}
110.2461 -	}
110.2462 -	break;
110.2463 -	case 0x09b:
110.2464 -	case 0x0bb:
110.2465 -	{
110.2466 -		// LDRH Rd, [Rn], Rm
110.2467 -		int base	= (opcode >> 16) & 0x0F;
110.2468 -		int dest	= (opcode >> 12) & 0x0F;
110.2469 -		u32 address = reg[base].I;
110.2470 -		int offset	= reg[opcode & 0x0F].I;
110.2471 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2472 -		reg[dest].I = CPUReadHalfWord(address);
110.2473 -		if (dest != base)
110.2474 -		{
110.2475 -			address	   += offset;
110.2476 -			reg[base].I = address;
110.2477 -		}
110.2478 -	}
110.2479 -	break;
110.2480 -	case 0x0db:
110.2481 -	case 0x0fb:
110.2482 -	{
110.2483 -		// LDRH Rd, [Rn], #offset
110.2484 -		int base	= (opcode >> 16) & 0x0F;
110.2485 -		int dest	= (opcode >> 12) & 0x0F;
110.2486 -		u32 address = reg[base].I;
110.2487 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2488 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2489 -		reg[dest].I = CPUReadHalfWord(address);
110.2490 -		if (dest != base)
110.2491 -		{
110.2492 -			address	   += offset;
110.2493 -			reg[base].I = address;
110.2494 -		}
110.2495 -	}
110.2496 -	break;
110.2497 -	case 0x11b:
110.2498 -	{
110.2499 -		// LDRH Rd, [Rn, -Rm]
110.2500 -		int base	= (opcode >> 16) & 0x0F;
110.2501 -		int dest	= (opcode >> 12) & 0x0F;
110.2502 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2503 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2504 -		reg[dest].I = CPUReadHalfWord(address);
110.2505 -	}
110.2506 -	break;
110.2507 -	case 0x13b:
110.2508 -	{
110.2509 -		// LDRH Rd, [Rn, -Rm]!
110.2510 -		int base	= (opcode >> 16) & 0x0F;
110.2511 -		int dest	= (opcode >> 12) & 0x0F;
110.2512 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2513 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2514 -		reg[dest].I = CPUReadHalfWord(address);
110.2515 -		if (dest != base)
110.2516 -			reg[base].I = address;
110.2517 -	}
110.2518 -	break;
110.2519 -	case 0x15b:
110.2520 -	{
110.2521 -		// LDRH Rd, [Rn, -#offset]
110.2522 -		int base	= (opcode >> 16) & 0x0F;
110.2523 -		int dest	= (opcode >> 12) & 0x0F;
110.2524 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2525 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2526 -		reg[dest].I = CPUReadHalfWord(address);
110.2527 -	}
110.2528 -	break;
110.2529 -	case 0x17b:
110.2530 -	{
110.2531 -		// LDRH Rd, [Rn, -#offset]!
110.2532 -		int base	= (opcode >> 16) & 0x0F;
110.2533 -		int dest	= (opcode >> 12) & 0x0F;
110.2534 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2535 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2536 -		reg[dest].I = CPUReadHalfWord(address);
110.2537 -		if (dest != base)
110.2538 -			reg[base].I = address;
110.2539 -	}
110.2540 -	break;
110.2541 -	case 0x19b:
110.2542 -	{
110.2543 -		// LDRH Rd, [Rn, Rm]
110.2544 -		int base	= (opcode >> 16) & 0x0F;
110.2545 -		int dest	= (opcode >> 12) & 0x0F;
110.2546 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2547 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2548 -		reg[dest].I = CPUReadHalfWord(address);
110.2549 -	}
110.2550 -	break;
110.2551 -	case 0x1bb:
110.2552 -	{
110.2553 -		// LDRH Rd, [Rn, Rm]!
110.2554 -		int base	= (opcode >> 16) & 0x0F;
110.2555 -		int dest	= (opcode >> 12) & 0x0F;
110.2556 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2557 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2558 -		reg[dest].I = CPUReadHalfWord(address);
110.2559 -		if (dest != base)
110.2560 -			reg[base].I = address;
110.2561 -	}
110.2562 -	break;
110.2563 -	case 0x1db:
110.2564 -	{
110.2565 -		// LDRH Rd, [Rn, #offset]
110.2566 -		int base	= (opcode >> 16) & 0x0F;
110.2567 -		int dest	= (opcode >> 12) & 0x0F;
110.2568 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2569 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2570 -		reg[dest].I = CPUReadHalfWord(address);
110.2571 -	}
110.2572 -	break;
110.2573 -	case 0x1fb:
110.2574 -	{
110.2575 -		// LDRH Rd, [Rn, #offset]!
110.2576 -		int base	= (opcode >> 16) & 0x0F;
110.2577 -		int dest	= (opcode >> 12) & 0x0F;
110.2578 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2579 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2580 -		reg[dest].I = CPUReadHalfWord(address);
110.2581 -		if (dest != base)
110.2582 -			reg[base].I = address;
110.2583 -	}
110.2584 -	break;
110.2585 -	case 0x01d:
110.2586 -	case 0x03d:
110.2587 -	{
110.2588 -		// LDRSB Rd, [Rn], -Rm
110.2589 -		int base	= (opcode >> 16) & 0x0F;
110.2590 -		int dest	= (opcode >> 12) & 0x0F;
110.2591 -		u32 address = reg[base].I;
110.2592 -		int offset	= reg[opcode & 0x0F].I;
110.2593 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2594 -		reg[dest].I = (s8)CPUReadByte(address);
110.2595 -		if (dest != base)
110.2596 -		{
110.2597 -			address	   -= offset;
110.2598 -			reg[base].I = address;
110.2599 -		}
110.2600 -	}
110.2601 -	break;
110.2602 -	case 0x05d:
110.2603 -	case 0x07d:
110.2604 -	{
110.2605 -		// LDRSB Rd, [Rn], #-offset
110.2606 -		int base	= (opcode >> 16) & 0x0F;
110.2607 -		int dest	= (opcode >> 12) & 0x0F;
110.2608 -		u32 address = reg[base].I;
110.2609 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2610 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2611 -		reg[dest].I = (s8)CPUReadByte(address);
110.2612 -		if (dest != base)
110.2613 -		{
110.2614 -			address	   -= offset;
110.2615 -			reg[base].I = address;
110.2616 -		}
110.2617 -	}
110.2618 -	break;
110.2619 -	case 0x09d:
110.2620 -	case 0x0bd:
110.2621 -	{
110.2622 -		// LDRSB Rd, [Rn], Rm
110.2623 -		int base	= (opcode >> 16) & 0x0F;
110.2624 -		int dest	= (opcode >> 12) & 0x0F;
110.2625 -		u32 address = reg[base].I;
110.2626 -		int offset	= reg[opcode & 0x0F].I;
110.2627 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2628 -		reg[dest].I = (s8)CPUReadByte(address);
110.2629 -		if (dest != base)
110.2630 -		{
110.2631 -			address	   += offset;
110.2632 -			reg[base].I = address;
110.2633 -		}
110.2634 -	}
110.2635 -	break;
110.2636 -	case 0x0dd:
110.2637 -	case 0x0fd:
110.2638 -	{
110.2639 -		// LDRSB Rd, [Rn], #offset
110.2640 -		int base	= (opcode >> 16) & 0x0F;
110.2641 -		int dest	= (opcode >> 12) & 0x0F;
110.2642 -		u32 address = reg[base].I;
110.2643 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2644 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2645 -		reg[dest].I = (s8)CPUReadByte(address);
110.2646 -		if (dest != base)
110.2647 -		{
110.2648 -			address	   += offset;
110.2649 -			reg[base].I = address;
110.2650 -		}
110.2651 -	}
110.2652 -	break;
110.2653 -	case 0x11d:
110.2654 -	{
110.2655 -		// LDRSB Rd, [Rn, -Rm]
110.2656 -		int base	= (opcode >> 16) & 0x0F;
110.2657 -		int dest	= (opcode >> 12) & 0x0F;
110.2658 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2659 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2660 -		reg[dest].I = (s8)CPUReadByte(address);
110.2661 -	}
110.2662 -	break;
110.2663 -	case 0x13d:
110.2664 -	{
110.2665 -		// LDRSB Rd, [Rn, -Rm]!
110.2666 -		int base	= (opcode >> 16) & 0x0F;
110.2667 -		int dest	= (opcode >> 12) & 0x0F;
110.2668 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2669 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2670 -		reg[dest].I = (s8)CPUReadByte(address);
110.2671 -		if (dest != base)
110.2672 -			reg[base].I = address;
110.2673 -	}
110.2674 -	break;
110.2675 -	case 0x15d:
110.2676 -	{
110.2677 -		// LDRSB Rd, [Rn, -#offset]
110.2678 -		int base	= (opcode >> 16) & 0x0F;
110.2679 -		int dest	= (opcode >> 12) & 0x0F;
110.2680 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2681 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2682 -		reg[dest].I = (s8)CPUReadByte(address);
110.2683 -	}
110.2684 -	break;
110.2685 -	case 0x17d:
110.2686 -	{
110.2687 -		// LDRSB Rd, [Rn, -#offset]!
110.2688 -		int base	= (opcode >> 16) & 0x0F;
110.2689 -		int dest	= (opcode >> 12) & 0x0F;
110.2690 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2691 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2692 -		reg[dest].I = (s8)CPUReadByte(address);
110.2693 -		if (dest != base)
110.2694 -			reg[base].I = address;
110.2695 -	}
110.2696 -	break;
110.2697 -	case 0x19d:
110.2698 -	{
110.2699 -		// LDRSB Rd, [Rn, Rm]
110.2700 -		int base	= (opcode >> 16) & 0x0F;
110.2701 -		int dest	= (opcode >> 12) & 0x0F;
110.2702 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2703 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2704 -		reg[dest].I = (s8)CPUReadByte(address);
110.2705 -	}
110.2706 -	break;
110.2707 -	case 0x1bd:
110.2708 -	{
110.2709 -		// LDRSB Rd, [Rn, Rm]!
110.2710 -		int base	= (opcode >> 16) & 0x0F;
110.2711 -		int dest	= (opcode >> 12) & 0x0F;
110.2712 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2713 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2714 -		reg[dest].I = (s8)CPUReadByte(address);
110.2715 -		if (dest != base)
110.2716 -			reg[base].I = address;
110.2717 -	}
110.2718 -	break;
110.2719 -	case 0x1dd:
110.2720 -	{
110.2721 -		// LDRSB Rd, [Rn, #offset]
110.2722 -		int base	= (opcode >> 16) & 0x0F;
110.2723 -		int dest	= (opcode >> 12) & 0x0F;
110.2724 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2725 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2726 -		reg[dest].I = (s8)CPUReadByte(address);
110.2727 -	}
110.2728 -	break;
110.2729 -	case 0x1fd:
110.2730 -	{
110.2731 -		// LDRSB Rd, [Rn, #offset]!
110.2732 -		int base	= (opcode >> 16) & 0x0F;
110.2733 -		int dest	= (opcode >> 12) & 0x0F;
110.2734 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2735 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2736 -		reg[dest].I = (s8)CPUReadByte(address);
110.2737 -		if (dest != base)
110.2738 -			reg[base].I = address;
110.2739 -	}
110.2740 -	break;
110.2741 -	case 0x01f:
110.2742 -	case 0x03f:
110.2743 -	{
110.2744 -		// LDRSH Rd, [Rn], -Rm
110.2745 -		int base	= (opcode >> 16) & 0x0F;
110.2746 -		int dest	= (opcode >> 12) & 0x0F;
110.2747 -		u32 address = reg[base].I;
110.2748 -		int offset	= reg[opcode & 0x0F].I;
110.2749 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2750 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2751 -		if (dest != base)
110.2752 -		{
110.2753 -			address	   -= offset;
110.2754 -			reg[base].I = address;
110.2755 -		}
110.2756 -	}
110.2757 -	break;
110.2758 -	case 0x05f:
110.2759 -	case 0x07f:
110.2760 -	{
110.2761 -		// LDRSH Rd, [Rn], #-offset
110.2762 -		int base	= (opcode >> 16) & 0x0F;
110.2763 -		int dest	= (opcode >> 12) & 0x0F;
110.2764 -		u32 address = reg[base].I;
110.2765 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2766 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2767 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2768 -		if (dest != base)
110.2769 -		{
110.2770 -			address	   -= offset;
110.2771 -			reg[base].I = address;
110.2772 -		}
110.2773 -	}
110.2774 -	break;
110.2775 -	case 0x09f:
110.2776 -	case 0x0bf:
110.2777 -	{
110.2778 -		// LDRSH Rd, [Rn], Rm
110.2779 -		int base	= (opcode >> 16) & 0x0F;
110.2780 -		int dest	= (opcode >> 12) & 0x0F;
110.2781 -		u32 address = reg[base].I;
110.2782 -		int offset	= reg[opcode & 0x0F].I;
110.2783 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2784 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2785 -		if (dest != base)
110.2786 -		{
110.2787 -			address	   += offset;
110.2788 -			reg[base].I = address;
110.2789 -		}
110.2790 -	}
110.2791 -	break;
110.2792 -	case 0x0df:
110.2793 -	case 0x0ff:
110.2794 -	{
110.2795 -		// LDRSH Rd, [Rn], #offset
110.2796 -		int base	= (opcode >> 16) & 0x0F;
110.2797 -		int dest	= (opcode >> 12) & 0x0F;
110.2798 -		u32 address = reg[base].I;
110.2799 -		int offset	= (opcode & 0x0F) | ((opcode >> 4) & 0xF0);
110.2800 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2801 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2802 -		if (dest != base)
110.2803 -		{
110.2804 -			address	   += offset;
110.2805 -			reg[base].I = address;
110.2806 -		}
110.2807 -	}
110.2808 -	break;
110.2809 -	case 0x11f:
110.2810 -	{
110.2811 -		// LDRSH Rd, [Rn, -Rm]
110.2812 -		int base	= (opcode >> 16) & 0x0F;
110.2813 -		int dest	= (opcode >> 12) & 0x0F;
110.2814 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2815 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2816 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2817 -	}
110.2818 -	break;
110.2819 -	case 0x13f:
110.2820 -	{
110.2821 -		// LDRSH Rd, [Rn, -Rm]!
110.2822 -		int base	= (opcode >> 16) & 0x0F;
110.2823 -		int dest	= (opcode >> 12) & 0x0F;
110.2824 -		u32 address = reg[base].I - reg[opcode & 0x0F].I;
110.2825 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2826 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2827 -		if (dest != base)
110.2828 -			reg[base].I = address;
110.2829 -	}
110.2830 -	break;
110.2831 -	case 0x15f:
110.2832 -	{
110.2833 -		// LDRSH Rd, [Rn, -#offset]
110.2834 -		int base	= (opcode >> 16) & 0x0F;
110.2835 -		int dest	= (opcode >> 12) & 0x0F;
110.2836 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2837 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2838 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2839 -	}
110.2840 -	break;
110.2841 -	case 0x17f:
110.2842 -	{
110.2843 -		// LDRSH Rd, [Rn, -#offset]!
110.2844 -		int base	= (opcode >> 16) & 0x0F;
110.2845 -		int dest	= (opcode >> 12) & 0x0F;
110.2846 -		u32 address = reg[base].I - ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2847 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2848 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2849 -		if (dest != base)
110.2850 -			reg[base].I = address;
110.2851 -	}
110.2852 -	break;
110.2853 -	case 0x19f:
110.2854 -	{
110.2855 -		// LDRSH Rd, [Rn, Rm]
110.2856 -		int base	= (opcode >> 16) & 0x0F;
110.2857 -		int dest	= (opcode >> 12) & 0x0F;
110.2858 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2859 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2860 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2861 -	}
110.2862 -	break;
110.2863 -	case 0x1bf:
110.2864 -	{
110.2865 -		// LDRSH Rd, [Rn, Rm]!
110.2866 -		int base	= (opcode >> 16) & 0x0F;
110.2867 -		int dest	= (opcode >> 12) & 0x0F;
110.2868 -		u32 address = reg[base].I + reg[opcode & 0x0F].I;
110.2869 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2870 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2871 -		if (dest != base)
110.2872 -			reg[base].I = address;
110.2873 -	}
110.2874 -	break;
110.2875 -	case 0x1df:
110.2876 -	{
110.2877 -		// LDRSH Rd, [Rn, #offset]
110.2878 -		int base	= (opcode >> 16) & 0x0F;
110.2879 -		int dest	= (opcode >> 12) & 0x0F;
110.2880 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2881 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2882 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2883 -	}
110.2884 -	break;
110.2885 -	case 0x1ff:
110.2886 -	{
110.2887 -		// LDRSH Rd, [Rn, #offset]!
110.2888 -		int base	= (opcode >> 16) & 0x0F;
110.2889 -		int dest	= (opcode >> 12) & 0x0F;
110.2890 -		u32 address = reg[base].I + ((opcode & 0x0F) | ((opcode >> 4) & 0xF0));
110.2891 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.2892 -		reg[dest].I = (s16)CPUReadHalfWordSigned(address);
110.2893 -		if (dest != base)
110.2894 -			reg[base].I = address;
110.2895 -	}
110.2896 -	break;
110.2897 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EOR,  OP_EOR, 0x020);
110.2898 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EORS, OP_EOR, 0x030);
110.2899 -	case 0x029:
110.2900 -	{
110.2901 -		// MLA Rd, Rm, Rs, Rn
110.2902 -		int dest = (opcode >> 16) & 0x0F;
110.2903 -		int mult = (opcode & 0x0F);
110.2904 -		u32 rs	 = reg[(opcode >> 8) & 0x0F].I;
110.2905 -		reg[dest].I = reg[mult].I * rs + reg[(opcode >> 12) & 0x0f].I;
110.2906 -		if (((s32)rs) < 0)
110.2907 -			rs = ~rs;
110.2908 -		if ((rs & 0xFFFFFF00) == 0)
110.2909 -			clockTicks += 3;
110.2910 -		else if ((rs & 0xFFFF0000) == 0)
110.2911 -			clockTicks += 4;
110.2912 -		else if ((rs & 0xFF000000) == 0)
110.2913 -			clockTicks += 5;
110.2914 -		else
110.2915 -			clockTicks += 6;
110.2916 -	}
110.2917 -	break;
110.2918 -	case 0x039:
110.2919 -	{
110.2920 -		// MLAS Rd, Rm, Rs, Rn
110.2921 -		int dest = (opcode >> 16) & 0x0F;
110.2922 -		int mult = (opcode & 0x0F);
110.2923 -		u32 rs	 = reg[(opcode >> 8) & 0x0F].I;
110.2924 -		reg[dest].I = reg[mult].I * rs + reg[(opcode >> 12) & 0x0f].I;
110.2925 -		N_FLAG		= (reg[dest].I & 0x80000000) ? true : false;
110.2926 -		Z_FLAG		= (reg[dest].I) ? false : true;
110.2927 -		if (((s32)rs) < 0)
110.2928 -			rs = ~rs;
110.2929 -		if ((rs & 0xFFFFFF00) == 0)
110.2930 -			clockTicks += 3;
110.2931 -		else if ((rs & 0xFFFF0000) == 0)
110.2932 -			clockTicks += 4;
110.2933 -		else if ((rs & 0xFF000000) == 0)
110.2934 -			clockTicks += 5;
110.2935 -		else
110.2936 -			clockTicks += 6;
110.2937 -	}
110.2938 -	break;
110.2939 -		ARITHMETIC_DATA_OPCODE(OP_SUB,  OP_SUB, 0x040);
110.2940 -		ARITHMETIC_DATA_OPCODE(OP_SUBS, OP_SUB, 0x050);
110.2941 -		ARITHMETIC_DATA_OPCODE(OP_RSB,  OP_RSB, 0x060);
110.2942 -		ARITHMETIC_DATA_OPCODE(OP_RSBS, OP_RSB, 0x070);
110.2943 -		ARITHMETIC_DATA_OPCODE(OP_ADD,  OP_ADD, 0x080);
110.2944 -		ARITHMETIC_DATA_OPCODE(OP_ADDS, OP_ADD, 0x090);
110.2945 -	case 0x089:
110.2946 -	{
110.2947 -		// UMULL RdLo, RdHi, Rn, Rs
110.2948 -		u32 umult	= reg[(opcode & 0x0F)].I;
110.2949 -		u32 usource = reg[(opcode >> 8) & 0x0F].I;
110.2950 -		int destLo	= (opcode >> 12) & 0x0F;
110.2951 -		int destHi	= (opcode >> 16) & 0x0F;
110.2952 -		u64 uTemp	= ((u64)umult) * ((u64)usource);
110.2953 -		reg[destLo].I = (u32)(uTemp & 0xFFFFFFFF);
110.2954 -		reg[destHi].I = (u32)(uTemp >> 32);
110.2955 -		if ((usource & 0xFFFFFF00) == 0)
110.2956 -			clockTicks += 2;
110.2957 -		else if ((usource & 0xFFFF0000) == 0)
110.2958 -			clockTicks += 3;
110.2959 -		else if ((usource & 0xFF000000) == 0)
110.2960 -			clockTicks += 4;
110.2961 -		else
110.2962 -			clockTicks += 5;
110.2963 -	}
110.2964 -	break;
110.2965 -	case 0x099:
110.2966 -	{
110.2967 -		// UMULLS RdLo, RdHi, Rn, Rs
110.2968 -		u32 umult	= reg[(opcode & 0x0F)].I;
110.2969 -		u32 usource = reg[(opcode >> 8) & 0x0F].I;
110.2970 -		int destLo	= (opcode >> 12) & 0x0F;
110.2971 -		int destHi	= (opcode >> 16) & 0x0F;
110.2972 -		u64 uTemp	= ((u64)umult) * ((u64)usource);
110.2973 -		reg[destLo].I = (u32)(uTemp & 0xFFFFFFFF);
110.2974 -		reg[destHi].I = (u32)(uTemp >> 32);
110.2975 -		Z_FLAG		  = (uTemp) ? false : true;
110.2976 -		N_FLAG		  = (reg[destHi].I & 0x80000000) ? true : false;
110.2977 -		if ((usource & 0xFFFFFF00) == 0)
110.2978 -			clockTicks += 2;
110.2979 -		else if ((usource & 0xFFFF0000) == 0)
110.2980 -			clockTicks += 3;
110.2981 -		else if ((usource & 0xFF000000) == 0)
110.2982 -			clockTicks += 4;
110.2983 -		else
110.2984 -			clockTicks += 5;
110.2985 -	}
110.2986 -	break;
110.2987 -		ARITHMETIC_DATA_OPCODE(OP_ADC,  OP_ADC, 0x0a0);
110.2988 -		ARITHMETIC_DATA_OPCODE(OP_ADCS, OP_ADC, 0x0b0);
110.2989 -	case 0x0a9:
110.2990 -	{
110.2991 -		// UMLAL RdLo, RdHi, Rn, Rs
110.2992 -		u32 umult	= reg[(opcode & 0x0F)].I;
110.2993 -		u32 usource = reg[(opcode >> 8) & 0x0F].I;
110.2994 -		int destLo	= (opcode >> 12) & 0x0F;
110.2995 -		int destHi	= (opcode >> 16) & 0x0F;
110.2996 -		u64 uTemp	= (u64)reg[destHi].I;
110.2997 -		uTemp		<<= 32;
110.2998 -		uTemp		 |= (u64)reg[destLo].I;
110.2999 -		uTemp		 += ((u64)umult) * ((u64)usource);
110.3000 -		reg[destLo].I = (u32)(uTemp & 0xFFFFFFFF);
110.3001 -		reg[destHi].I = (u32)(uTemp >> 32);
110.3002 -		if ((usource & 0xFFFFFF00) == 0)
110.3003 -			clockTicks += 3;
110.3004 -		else if ((usource & 0xFFFF0000) == 0)
110.3005 -			clockTicks += 4;
110.3006 -		else if ((usource & 0xFF000000) == 0)
110.3007 -			clockTicks += 5;
110.3008 -		else
110.3009 -			clockTicks += 6;
110.3010 -	}
110.3011 -	break;
110.3012 -	case 0x0b9:
110.3013 -	{
110.3014 -		// UMLALS RdLo, RdHi, Rn, Rs
110.3015 -		u32 umult	= reg[(opcode & 0x0F)].I;
110.3016 -		u32 usource = reg[(opcode >> 8) & 0x0F].I;
110.3017 -		int destLo	= (opcode >> 12) & 0x0F;
110.3018 -		int destHi	= (opcode >> 16) & 0x0F;
110.3019 -		u64 uTemp	= (u64)reg[destHi].I;
110.3020 -		uTemp		<<= 32;
110.3021 -		uTemp		 |= (u64)reg[destLo].I;
110.3022 -		uTemp		 += ((u64)umult) * ((u64)usource);
110.3023 -		reg[destLo].I = (u32)(uTemp & 0xFFFFFFFF);
110.3024 -		reg[destHi].I = (u32)(uTemp >> 32);
110.3025 -		Z_FLAG		  = (uTemp) ? false : true;
110.3026 -		N_FLAG		  = (reg[destHi].I & 0x80000000) ? true : false;
110.3027 -		if ((usource & 0xFFFFFF00) == 0)
110.3028 -			clockTicks += 3;
110.3029 -		else if ((usource & 0xFFFF0000) == 0)
110.3030 -			clockTicks += 4;
110.3031 -		else if ((usource & 0xFF000000) == 0)
110.3032 -			clockTicks += 5;
110.3033 -		else
110.3034 -			clockTicks += 6;
110.3035 -	}
110.3036 -	break;
110.3037 -		ARITHMETIC_DATA_OPCODE(OP_SBC,  OP_SBC, 0x0c0);
110.3038 -		ARITHMETIC_DATA_OPCODE(OP_SBCS, OP_SBC, 0x0d0);
110.3039 -	case 0x0c9:
110.3040 -	{
110.3041 -		// SMULL RdLo, RdHi, Rm, Rs
110.3042 -		int destLo = (opcode >> 12) & 0x0F;
110.3043 -		int destHi = (opcode >> 16) & 0x0F;
110.3044 -		u32 rs	   = reg[(opcode >> 8) & 0x0F].I;
110.3045 -		s64 m	   = (s32)reg[(opcode & 0x0F)].I;
110.3046 -		s64 s	   = (s32)rs;
110.3047 -		s64 sTemp  = m * s;
110.3048 -		reg[destLo].I = (u32)(sTemp & 0xFFFFFFFF);
110.3049 -		reg[destHi].I = (u32)(sTemp >> 32);
110.3050 -		if (((s32)rs) < 0)
110.3051 -			rs = ~rs;
110.3052 -		if ((rs & 0xFFFFFF00) == 0)
110.3053 -			clockTicks += 2;
110.3054 -		else if ((rs & 0xFFFF0000) == 0)
110.3055 -			clockTicks += 3;
110.3056 -		else if ((rs & 0xFF000000) == 0)
110.3057 -			clockTicks += 4;
110.3058 -		else
110.3059 -			clockTicks += 5;
110.3060 -	}
110.3061 -	break;
110.3062 -	case 0x0d9:
110.3063 -	{
110.3064 -		// SMULLS RdLo, RdHi, Rm, Rs
110.3065 -		int destLo = (opcode >> 12) & 0x0F;
110.3066 -		int destHi = (opcode >> 16) & 0x0F;
110.3067 -		u32 rs	   = reg[(opcode >> 8) & 0x0F].I;
110.3068 -		s64 m	   = (s32)reg[(opcode & 0x0F)].I;
110.3069 -		s64 s	   = (s32)rs;
110.3070 -		s64 sTemp  = m * s;
110.3071 -		reg[destLo].I = (u32)(sTemp & 0xFFFFFFFF);
110.3072 -		reg[destHi].I = (u32)(sTemp >> 32);
110.3073 -		Z_FLAG		  = (sTemp) ? false : true;
110.3074 -		N_FLAG		  = (sTemp < 0) ? true : false;
110.3075 -		if (((s32)rs) < 0)
110.3076 -			rs = ~rs;
110.3077 -		if ((rs & 0xFFFFFF00) == 0)
110.3078 -			clockTicks += 2;
110.3079 -		else if ((rs & 0xFFFF0000) == 0)
110.3080 -			clockTicks += 3;
110.3081 -		else if ((rs & 0xFF000000) == 0)
110.3082 -			clockTicks += 4;
110.3083 -		else
110.3084 -			clockTicks += 5;
110.3085 -	}
110.3086 -	break;
110.3087 -		ARITHMETIC_DATA_OPCODE(OP_RSC,  OP_RSC, 0x0e0);
110.3088 -		ARITHMETIC_DATA_OPCODE(OP_RSCS, OP_RSC, 0x0f0);
110.3089 -	case 0x0e9:
110.3090 -	{
110.3091 -		// SMLAL RdLo, RdHi, Rm, Rs
110.3092 -		int destLo = (opcode >> 12) & 0x0F;
110.3093 -		int destHi = (opcode >> 16) & 0x0F;
110.3094 -		u32 rs	   = reg[(opcode >> 8) & 0x0F].I;
110.3095 -		s64 m	   = (s32)reg[(opcode & 0x0F)].I;
110.3096 -		s64 s	   = (s32)rs;
110.3097 -		s64 sTemp  = (u64)reg[destHi].I;
110.3098 -		sTemp		<<= 32;
110.3099 -		sTemp		 |= (u64)reg[destLo].I;
110.3100 -		sTemp		 += m * s;
110.3101 -		reg[destLo].I = (u32)(sTemp & 0xFFFFFFFF);
110.3102 -		reg[destHi].I = (u32)(sTemp >> 32);
110.3103 -		if (((s32)rs) < 0)
110.3104 -			rs = ~rs;
110.3105 -		if ((rs & 0xFFFFFF00) == 0)
110.3106 -			clockTicks += 3;
110.3107 -		else if ((rs & 0xFFFF0000) == 0)
110.3108 -			clockTicks += 4;
110.3109 -		else if ((rs & 0xFF000000) == 0)
110.3110 -			clockTicks += 5;
110.3111 -		else
110.3112 -			clockTicks += 6;
110.3113 -	}
110.3114 -	break;
110.3115 -	case 0x0f9:
110.3116 -	{
110.3117 -		// SMLALS RdLo, RdHi, Rm, Rs
110.3118 -		int destLo = (opcode >> 12) & 0x0F;
110.3119 -		int destHi = (opcode >> 16) & 0x0F;
110.3120 -		u32 rs	   = reg[(opcode >> 8) & 0x0F].I;
110.3121 -		s64 m	   = (s32)reg[(opcode & 0x0F)].I;
110.3122 -		s64 s	   = (s32)rs;
110.3123 -		s64 sTemp  = (u64)reg[destHi].I;
110.3124 -		sTemp		<<= 32;
110.3125 -		sTemp		 |= (u64)reg[destLo].I;
110.3126 -		sTemp		 += m * s;
110.3127 -		reg[destLo].I = (u32)(sTemp & 0xFFFFFFFF);
110.3128 -		reg[destHi].I = (u32)(sTemp >> 32);
110.3129 -		Z_FLAG		  = (sTemp) ? false : true;
110.3130 -		N_FLAG		  = (sTemp < 0) ? true : false;
110.3131 -		if (((s32)rs) < 0)
110.3132 -			rs = ~rs;
110.3133 -		if ((rs & 0xFFFFFF00) == 0)
110.3134 -			clockTicks += 3;
110.3135 -		else if ((rs & 0xFFFF0000) == 0)
110.3136 -			clockTicks += 4;
110.3137 -		else if ((rs & 0xFF000000) == 0)
110.3138 -			clockTicks += 5;
110.3139 -		else
110.3140 -			clockTicks += 6;
110.3141 -	}
110.3142 -	break;
110.3143 -		LOGICAL_DATA_OPCODE(OP_TST, OP_TST, 0x110);
110.3144 -	case 0x100:
110.3145 -		// MRS Rd, CPSR
110.3146 -		// TODO: check if right instruction....
110.3147 -		CPUUpdateCPSR();
110.3148 -		reg[(opcode >> 12) & 0x0F].I = reg[16].I;
110.3149 -		break;
110.3150 -	case 0x109:
110.3151 -	{
110.3152 -		// SWP Rd, Rm, [Rn]
110.3153 -		u32 address = reg[(opcode >> 16) & 15].I;
110.3154 -		u32 temp	= CPUReadMemory(address);
110.3155 -		CPUWriteMemory(address, reg[opcode & 15].I);
110.3156 -		reg[(opcode >> 12) & 15].I = temp;
110.3157 -	}
110.3158 -	break;
110.3159 -		LOGICAL_DATA_OPCODE(OP_TEQ, OP_TEQ, 0x130);
110.3160 -	case 0x120:
110.3161 -	{
110.3162 -		// MSR CPSR_fields, Rm
110.3163 -		CPUUpdateCPSR();
110.3164 -		u32 value	 = reg[opcode & 15].I;
110.3165 -		u32 newValue = reg[16].I;
110.3166 -		if (armMode > 0x10)
110.3167 -		{
110.3168 -			if (opcode & 0x00010000)
110.3169 -				newValue = (newValue & 0xFFFFFF00) | (value & 0x000000FF);
110.3170 -			if (opcode & 0x00020000)
110.3171 -				newValue = (newValue & 0xFFFF00FF) | (value & 0x0000FF00);
110.3172 -			if (opcode & 0x00040000)
110.3173 -				newValue = (newValue & 0xFF00FFFF) | (value & 0x00FF0000);
110.3174 -		}
110.3175 -		if (opcode & 0x00080000)
110.3176 -			newValue = (newValue & 0x00FFFFFF) | (value & 0xFF000000);
110.3177 -		newValue |= 0x10;
110.3178 -		CPUSwitchMode(newValue & 0x1f, false);
110.3179 -		reg[16].I = newValue;
110.3180 -		CPUUpdateFlags();
110.3181 -	}
110.3182 -	break;
110.3183 -	case 0x121:
110.3184 -	{
110.3185 -		// BX Rm
110.3186 -		// TODO: check if right instruction...
110.3187 -		clockTicks += 3;
110.3188 -		int base = opcode & 0x0F;
110.3189 -		armState = reg[base].I & 1 ? false : true;
110.3190 -		if (armState)
110.3191 -		{
110.3192 -			reg[15].I  = reg[base].I & 0xFFFFFFFC;
110.3193 -			armNextPC  = reg[15].I;
110.3194 -			reg[15].I += 4;
110.3195 -		}
110.3196 -		else
110.3197 -		{
110.3198 -			reg[15].I  = reg[base].I & 0xFFFFFFFE;
110.3199 -			armNextPC  = reg[15].I;
110.3200 -			reg[15].I += 2;
110.3201 -		}
110.3202 -	}
110.3203 -	break;
110.3204 -		ARITHMETIC_DATA_OPCODE(OP_CMP, OP_CMP, 0x150);
110.3205 -	case 0x140:
110.3206 -		// MRS Rd, SPSR
110.3207 -		// TODO: check if right instruction...
110.3208 -		reg[(opcode >> 12) & 0x0F].I = reg[17].I;
110.3209 -		break;
110.3210 -	case 0x149:
110.3211 -	{
110.3212 -		// SWPB Rd, Rm, [Rn]
110.3213 -		u32 address = reg[(opcode >> 16) & 15].I;
110.3214 -		u32 temp	= CPUReadByte(address);
110.3215 -		CPUWriteByte(address, reg[opcode & 15].B.B0);
110.3216 -		reg[(opcode >> 12) & 15].I = temp;
110.3217 -	}
110.3218 -	break;
110.3219 -		ARITHMETIC_DATA_OPCODE(OP_CMN, OP_CMN, 0x170);
110.3220 -	case 0x160:
110.3221 -	{
110.3222 -		// MSR SPSR_fields, Rm
110.3223 -		u32 value = reg[opcode & 15].I;
110.3224 -		if (armMode > 0x10 && armMode < 0x1f)
110.3225 -		{
110.3226 -			if (opcode & 0x00010000)
110.3227 -				reg[17].I = (reg[17].I & 0xFFFFFF00) | (value & 0x000000FF);
110.3228 -			if (opcode & 0x00020000)
110.3229 -				reg[17].I = (reg[17].I & 0xFFFF00FF) | (value & 0x0000FF00);
110.3230 -			if (opcode & 0x00040000)
110.3231 -				reg[17].I = (reg[17].I & 0xFF00FFFF) | (value & 0x00FF0000);
110.3232 -			if (opcode & 0x00080000)
110.3233 -				reg[17].I = (reg[17].I & 0x00FFFFFF) | (value & 0xFF000000);
110.3234 -		}
110.3235 -	}
110.3236 -	break;
110.3237 -		LOGICAL_DATA_OPCODE(OP_ORR,  OP_ORR, 0x180);
110.3238 -		LOGICAL_DATA_OPCODE(OP_ORRS, OP_ORR, 0x190);
110.3239 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOV,  OP_MOV, 0x1a0);
110.3240 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOVS, OP_MOV, 0x1b0);
110.3241 -		LOGICAL_DATA_OPCODE(OP_BIC,  OP_BIC, 0x1c0);
110.3242 -		LOGICAL_DATA_OPCODE(OP_BICS, OP_BIC, 0x1d0);
110.3243 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVN,  OP_MVN, 0x1e0);
110.3244 -		LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVNS, OP_MVN, 0x1f0);
110.3245 -#ifdef BKPT_SUPPORT
110.3246 -	case 0x127:
110.3247 -	case 0x7ff: // for GDB support
110.3248 -		extern void (*dbgSignal)(int, int);
110.3249 -		reg[15].I -= 4;
110.3250 -		armNextPC -= 4;
110.3251 -		dbgSignal(5, (opcode & 0x0f) | ((opcode >> 4) & 0xfff0));
110.3252 -		return;
110.3253 -#endif
110.3254 -	case 0x320:
110.3255 -	case 0x321:
110.3256 -	case 0x322:
110.3257 -	case 0x323:
110.3258 -	case 0x324:
110.3259 -	case 0x325:
110.3260 -	case 0x326:
110.3261 -	case 0x327:
110.3262 -	case 0x328:
110.3263 -	case 0x329:
110.3264 -	case 0x32a:
110.3265 -	case 0x32b:
110.3266 -	case 0x32c:
110.3267 -	case 0x32d:
110.3268 -	case 0x32e:
110.3269 -	case 0x32f:
110.3270 -	{
110.3271 -		// MSR CPSR_fields, #
110.3272 -		CPUUpdateCPSR();
110.3273 -		u32 value = opcode & 0xFF;
110.3274 -		int shift = (opcode & 0xF00) >> 7;
110.3275 -		if (shift)
110.3276 -		{
110.3277 -			ROR_IMM_MSR;
110.3278 -		}
110.3279 -		u32 newValue = reg[16].I;
110.3280 -		if (armMode > 0x10)
110.3281 -		{
110.3282 -			if (opcode & 0x00010000)
110.3283 -				newValue = (newValue & 0xFFFFFF00) | (value & 0x000000FF);
110.3284 -			if (opcode & 0x00020000)
110.3285 -				newValue = (newValue & 0xFFFF00FF) | (value & 0x0000FF00);
110.3286 -			if (opcode & 0x00040000)
110.3287 -				newValue = (newValue & 0xFF00FFFF) | (value & 0x00FF0000);
110.3288 -		}
110.3289 -		if (opcode & 0x00080000)
110.3290 -			newValue = (newValue & 0x00FFFFFF) | (value & 0xFF000000);
110.3291 -
110.3292 -		newValue |= 0x10;
110.3293 -
110.3294 -		CPUSwitchMode(newValue & 0x1f, false);
110.3295 -		reg[16].I = newValue;
110.3296 -		CPUUpdateFlags();
110.3297 -	}
110.3298 -	break;
110.3299 -	case 0x360:
110.3300 -	case 0x361:
110.3301 -	case 0x362:
110.3302 -	case 0x363:
110.3303 -	case 0x364:
110.3304 -	case 0x365:
110.3305 -	case 0x366:
110.3306 -	case 0x367:
110.3307 -	case 0x368:
110.3308 -	case 0x369:
110.3309 -	case 0x36a:
110.3310 -	case 0x36b:
110.3311 -	case 0x36c:
110.3312 -	case 0x36d:
110.3313 -	case 0x36e:
110.3314 -	case 0x36f:
110.3315 -	{
110.3316 -		// MSR SPSR_fields, #
110.3317 -		if (armMode > 0x10 && armMode < 0x1f)
110.3318 -		{
110.3319 -			u32 value = opcode & 0xFF;
110.3320 -			int shift = (opcode & 0xF00) >> 7;
110.3321 -			if (shift)
110.3322 -			{
110.3323 -				ROR_IMM_MSR;
110.3324 -			}
110.3325 -			if (opcode & 0x00010000)
110.3326 -				reg[17].I = (reg[17].I & 0xFFFFFF00) | (value & 0x000000FF);
110.3327 -			if (opcode & 0x00020000)
110.3328 -				reg[17].I = (reg[17].I & 0xFFFF00FF) | (value & 0x0000FF00);
110.3329 -			if (opcode & 0x00040000)
110.3330 -				reg[17].I = (reg[17].I & 0xFF00FFFF) | (value & 0x00FF0000);
110.3331 -			if (opcode & 0x00080000)
110.3332 -				reg[17].I = (reg[17].I & 0x00FFFFFF) | (value & 0xFF000000);
110.3333 -		}
110.3334 -	}
110.3335 -	break;
110.3336 -		CASE_16(0x400)
110.3337 -		// T versions shouldn't be different on GBA
110.3338 -		CASE_16(0x420)
110.3339 -		{
110.3340 -			// STR Rd, [Rn], -#
110.3341 -			int offset	= opcode & 0xFFF;
110.3342 -			int dest	= (opcode >> 12) & 15;
110.3343 -			int base	= (opcode >> 16) & 15;
110.3344 -			u32 address = reg[base].I;
110.3345 -			CPUWriteMemory(address, reg[dest].I);
110.3346 -			reg[base].I = address - offset;
110.3347 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3348 -		}
110.3349 -		break;
110.3350 -		CASE_16(0x480)
110.3351 -		// T versions shouldn't be different on GBA
110.3352 -		CASE_16(0x4a0)
110.3353 -		{
110.3354 -			// STR Rd, [Rn], #
110.3355 -			int offset	= opcode & 0xFFF;
110.3356 -			int dest	= (opcode >> 12) & 15;
110.3357 -			int base	= (opcode >> 16) & 15;
110.3358 -			u32 address = reg[base].I;
110.3359 -			CPUWriteMemory(address, reg[dest].I);
110.3360 -			reg[base].I = address + offset;
110.3361 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3362 -		}
110.3363 -		break;
110.3364 -		CASE_16(0x500)
110.3365 -		{
110.3366 -			// STR Rd, [Rn, -#]
110.3367 -			int offset	= opcode & 0xFFF;
110.3368 -			int dest	= (opcode >> 12) & 15;
110.3369 -			int base	= (opcode >> 16) & 15;
110.3370 -			u32 address = reg[base].I - offset;
110.3371 -			CPUWriteMemory(address, reg[dest].I);
110.3372 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3373 -		}
110.3374 -		break;
110.3375 -		CASE_16(0x520)
110.3376 -		{
110.3377 -			// STR Rd, [Rn, -#]!
110.3378 -			int offset	= opcode & 0xFFF;
110.3379 -			int dest	= (opcode >> 12) & 15;
110.3380 -			int base	= (opcode >> 16) & 15;
110.3381 -			u32 address = reg[base].I - offset;
110.3382 -			reg[base].I = address;
110.3383 -			CPUWriteMemory(address, reg[dest].I);
110.3384 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3385 -		}
110.3386 -		break;
110.3387 -		CASE_16(0x580)
110.3388 -		{
110.3389 -			// STR Rd, [Rn, #]
110.3390 -			int offset	= opcode & 0xFFF;
110.3391 -			int dest	= (opcode >> 12) & 15;
110.3392 -			int base	= (opcode >> 16) & 15;
110.3393 -			u32 address = reg[base].I + offset;
110.3394 -			CPUWriteMemory(address, reg[dest].I);
110.3395 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3396 -		}
110.3397 -		break;
110.3398 -		CASE_16(0x5a0)
110.3399 -		{
110.3400 -			// STR Rd, [Rn, #]!
110.3401 -			int offset	= opcode & 0xFFF;
110.3402 -			int dest	= (opcode >> 12) & 15;
110.3403 -			int base	= (opcode >> 16) & 15;
110.3404 -			u32 address = reg[base].I + offset;
110.3405 -			reg[base].I = address;
110.3406 -			CPUWriteMemory(address, reg[dest].I);
110.3407 -			clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3408 -		}
110.3409 -		break;
110.3410 -		CASE_16(0x410)
110.3411 -		{
110.3412 -			// LDR Rd, [Rn], -#
110.3413 -			int offset	= opcode & 0xFFF;
110.3414 -			int dest	= (opcode >> 12) & 15;
110.3415 -			int base	= (opcode >> 16) & 15;
110.3416 -			u32 address = reg[base].I;
110.3417 -			reg[dest].I = CPUReadMemory(address);
110.3418 -			if (dest != base)
110.3419 -				reg[base].I -= offset;
110.3420 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3421 -			if (dest == 15)
110.3422 -			{
110.3423 -				clockTicks += 2;
110.3424 -				reg[15].I  &= 0xFFFFFFFC;
110.3425 -				armNextPC	= reg[15].I;
110.3426 -				reg[15].I  += 4;
110.3427 -			}
110.3428 -		}
110.3429 -		break;
110.3430 -		CASE_16(0x430)
110.3431 -		{
110.3432 -			// LDRT Rd, [Rn], -#
110.3433 -			int offset	= opcode & 0xFFF;
110.3434 -			int dest	= (opcode >> 12) & 15;
110.3435 -			int base	= (opcode >> 16) & 15;
110.3436 -			u32 address = reg[base].I;
110.3437 -			reg[dest].I = CPUReadMemory(address);
110.3438 -			if (dest != base)
110.3439 -				reg[base].I -= offset;
110.3440 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3441 -		}
110.3442 -		break;
110.3443 -		CASE_16(0x490)
110.3444 -		{
110.3445 -			// LDR Rd, [Rn], #
110.3446 -			int offset	= opcode & 0xFFF;
110.3447 -			int dest	= (opcode >> 12) & 15;
110.3448 -			int base	= (opcode >> 16) & 15;
110.3449 -			u32 address = reg[base].I;
110.3450 -			reg[dest].I = CPUReadMemory(address);
110.3451 -			if (dest != base)
110.3452 -				reg[base].I += offset;
110.3453 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3454 -			if (dest == 15)
110.3455 -			{
110.3456 -				clockTicks += 2;
110.3457 -				reg[15].I  &= 0xFFFFFFFC;
110.3458 -				armNextPC	= reg[15].I;
110.3459 -				reg[15].I  += 4;
110.3460 -			}
110.3461 -		}
110.3462 -		break;
110.3463 -		CASE_16(0x4b0)
110.3464 -		{
110.3465 -			// LDRT Rd, [Rn], #
110.3466 -			int offset	= opcode & 0xFFF;
110.3467 -			int dest	= (opcode >> 12) & 15;
110.3468 -			int base	= (opcode >> 16) & 15;
110.3469 -			u32 address = reg[base].I;
110.3470 -			reg[dest].I = CPUReadMemory(address);
110.3471 -			if (dest != base)
110.3472 -				reg[base].I += offset;
110.3473 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3474 -		}
110.3475 -		break;
110.3476 -		CASE_16(0x510)
110.3477 -		{
110.3478 -			// LDR Rd, [Rn, -#]
110.3479 -			int offset	= opcode & 0xFFF;
110.3480 -			int dest	= (opcode >> 12) & 15;
110.3481 -			int base	= (opcode >> 16) & 15;
110.3482 -			u32 address = reg[base].I - offset;
110.3483 -			reg[dest].I = CPUReadMemory(address);
110.3484 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3485 -			if (dest == 15)
110.3486 -			{
110.3487 -				clockTicks += 2;
110.3488 -				reg[15].I  &= 0xFFFFFFFC;
110.3489 -				armNextPC	= reg[15].I;
110.3490 -				reg[15].I  += 4;
110.3491 -			}
110.3492 -		}
110.3493 -		break;
110.3494 -		CASE_16(0x530)
110.3495 -		{
110.3496 -			// LDR Rd, [Rn, -#]!
110.3497 -			int offset	= opcode & 0xFFF;
110.3498 -			int dest	= (opcode >> 12) & 15;
110.3499 -			int base	= (opcode >> 16) & 15;
110.3500 -			u32 address = reg[base].I - offset;
110.3501 -			reg[dest].I = CPUReadMemory(address);
110.3502 -			if (dest != base)
110.3503 -				reg[base].I = address;
110.3504 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3505 -			if (dest == 15)
110.3506 -			{
110.3507 -				clockTicks += 2;
110.3508 -				reg[15].I  &= 0xFFFFFFFC;
110.3509 -				armNextPC	= reg[15].I;
110.3510 -				reg[15].I  += 4;
110.3511 -			}
110.3512 -		}
110.3513 -		break;
110.3514 -		CASE_16(0x590)
110.3515 -		{
110.3516 -			// LDR Rd, [Rn, #]
110.3517 -			int offset	= opcode & 0xFFF;
110.3518 -			int dest	= (opcode >> 12) & 15;
110.3519 -			int base	= (opcode >> 16) & 15;
110.3520 -			u32 address = reg[base].I + offset;
110.3521 -			reg[dest].I = CPUReadMemory(address);
110.3522 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3523 -			if (dest == 15)
110.3524 -			{
110.3525 -				clockTicks += 2;
110.3526 -				reg[15].I  &= 0xFFFFFFFC;
110.3527 -				armNextPC	= reg[15].I;
110.3528 -				reg[15].I  += 4;
110.3529 -			}
110.3530 -		}
110.3531 -		break;
110.3532 -		CASE_16(0x5b0)
110.3533 -		{
110.3534 -			// LDR Rd, [Rn, #]!
110.3535 -			int offset	= opcode & 0xFFF;
110.3536 -			int dest	= (opcode >> 12) & 15;
110.3537 -			int base	= (opcode >> 16) & 15;
110.3538 -			u32 address = reg[base].I + offset;
110.3539 -			reg[dest].I = CPUReadMemory(address);
110.3540 -			if (dest != base)
110.3541 -				reg[base].I = address;
110.3542 -			clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.3543 -			if (dest == 15)
110.3544 -			{
110.3545 -				clockTicks += 2;
110.3546 -				reg[15].I  &= 0xFFFFFFFC;
110.3547 -				armNextPC	= reg[15].I;
110.3548 -				reg[15].I  += 4;
110.3549 -			}
110.3550 -		}
110.3551 -		break;
110.3552 -		CASE_16(0x440)
110.3553 -		// T versions shouldn't be different on GBA
110.3554 -		CASE_16(0x460)
110.3555 -		{
110.3556 -			// STRB Rd, [Rn], -#
110.3557 -			int offset	= opcode & 0xFFF;
110.3558 -			int dest	= (opcode >> 12) & 15;
110.3559 -			int base	= (opcode >> 16) & 15;
110.3560 -			u32 address = reg[base].I;
110.3561 -			CPUWriteByte(address, reg[dest].B.B0);
110.3562 -			reg[base].I = address - offset;
110.3563 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3564 -		}
110.3565 -		break;
110.3566 -		CASE_16(0x4c0)
110.3567 -		// T versions shouldn't be different on GBA
110.3568 -		CASE_16(0x4e0)
110.3569 -		// STRB Rd, [Rn], #
110.3570 -		{
110.3571 -			int offset	= opcode & 0xFFF;
110.3572 -			int dest	= (opcode >> 12) & 15;
110.3573 -			int base	= (opcode >> 16) & 15;
110.3574 -			u32 address = reg[base].I;
110.3575 -			CPUWriteByte(address, reg[dest].B.B0);
110.3576 -			reg[base].I = address + offset;
110.3577 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3578 -		}
110.3579 -		break;
110.3580 -		CASE_16(0x540)
110.3581 -		{
110.3582 -			// STRB Rd, [Rn, -#]
110.3583 -			int offset	= opcode & 0xFFF;
110.3584 -			int dest	= (opcode >> 12) & 15;
110.3585 -			int base	= (opcode >> 16) & 15;
110.3586 -			u32 address = reg[base].I - offset;
110.3587 -			CPUWriteByte(address, reg[dest].B.B0);
110.3588 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3589 -		}
110.3590 -		break;
110.3591 -		CASE_16(0x560)
110.3592 -		{
110.3593 -			// STRB Rd, [Rn, -#]!
110.3594 -			int offset	= opcode & 0xFFF;
110.3595 -			int dest	= (opcode >> 12) & 15;
110.3596 -			int base	= (opcode >> 16) & 15;
110.3597 -			u32 address = reg[base].I - offset;
110.3598 -			reg[base].I = address;
110.3599 -			CPUWriteByte(address, reg[dest].B.B0);
110.3600 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3601 -		}
110.3602 -		break;
110.3603 -		CASE_16(0x5c0)
110.3604 -		{
110.3605 -			// STRB Rd, [Rn, #]
110.3606 -			int offset	= opcode & 0xFFF;
110.3607 -			int dest	= (opcode >> 12) & 15;
110.3608 -			int base	= (opcode >> 16) & 15;
110.3609 -			u32 address = reg[base].I + offset;
110.3610 -			CPUWriteByte(address, reg[dest].B.B0);
110.3611 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3612 -		}
110.3613 -		break;
110.3614 -		CASE_16(0x5e0)
110.3615 -		{
110.3616 -			// STRB Rd, [Rn, #]!
110.3617 -			int offset	= opcode & 0xFFF;
110.3618 -			int dest	= (opcode >> 12) & 15;
110.3619 -			int base	= (opcode >> 16) & 15;
110.3620 -			u32 address = reg[base].I + offset;
110.3621 -			reg[base].I = address;
110.3622 -			CPUWriteByte(address, reg[dest].I);
110.3623 -			clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.3624 -		}
110.3625 -		break;
110.3626 -		CASE_16(0x450)
110.3627 -		// T versions shouldn't be different
110.3628 -		CASE_16(0x470)
110.3629 -		{
110.3630 -			// LDRB Rd, [Rn], -#
110.3631 -			int offset	= opcode & 0xFFF;
110.3632 -			int dest	= (opcode >> 12) & 15;
110.3633 -			int base	= (opcode >> 16) & 15;
110.3634 -			u32 address = reg[base].I;
110.3635 -			reg[dest].I = CPUReadByte(address);
110.3636 -			if (dest != base)
110.3637 -				reg[base].I -= offset;
110.3638 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3639 -		}
110.3640 -		break;
110.3641 -		CASE_16(0x4d0)
110.3642 -		CASE_16(0x4f0) // T versions should not be different
110.3643 -		{
110.3644 -			// LDRB Rd, [Rn], #
110.3645 -			int offset	= opcode & 0xFFF;
110.3646 -			int dest	= (opcode >> 12) & 15;
110.3647 -			int base	= (opcode >> 16) & 15;
110.3648 -			u32 address = reg[base].I;
110.3649 -			reg[dest].I = CPUReadByte(address);
110.3650 -			if (dest != base)
110.3651 -				reg[base].I += offset;
110.3652 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3653 -		}
110.3654 -		break;
110.3655 -		CASE_16(0x550)
110.3656 -		{
110.3657 -			// LDRB Rd, [Rn, -#]
110.3658 -			int offset	= opcode & 0xFFF;
110.3659 -			int dest	= (opcode >> 12) & 15;
110.3660 -			int base	= (opcode >> 16) & 15;
110.3661 -			u32 address = reg[base].I - offset;
110.3662 -			reg[dest].I = CPUReadByte(address);
110.3663 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3664 -		}
110.3665 -		break;
110.3666 -		CASE_16(0x570)
110.3667 -		{
110.3668 -			// LDRB Rd, [Rn, -#]!
110.3669 -			int offset	= opcode & 0xFFF;
110.3670 -			int dest	= (opcode >> 12) & 15;
110.3671 -			int base	= (opcode >> 16) & 15;
110.3672 -			u32 address = reg[base].I - offset;
110.3673 -			reg[dest].I = CPUReadByte(address);
110.3674 -			if (dest != base)
110.3675 -				reg[base].I = address;
110.3676 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3677 -		}
110.3678 -		break;
110.3679 -		CASE_16(0x5d0)
110.3680 -		{
110.3681 -			// LDRB Rd, [Rn, #]
110.3682 -			int offset	= opcode & 0xFFF;
110.3683 -			int dest	= (opcode >> 12) & 15;
110.3684 -			int base	= (opcode >> 16) & 15;
110.3685 -			u32 address = reg[base].I + offset;
110.3686 -			reg[dest].I = CPUReadByte(address);
110.3687 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3688 -		}
110.3689 -		break;
110.3690 -		CASE_16(0x5f0)
110.3691 -		{
110.3692 -			// LDRB Rd, [Rn, #]!
110.3693 -			int offset	= opcode & 0xFFF;
110.3694 -			int dest	= (opcode >> 12) & 15;
110.3695 -			int base	= (opcode >> 16) & 15;
110.3696 -			u32 address = reg[base].I + offset;
110.3697 -			reg[dest].I = CPUReadByte(address);
110.3698 -			if (dest != base)
110.3699 -				reg[base].I = address;
110.3700 -			clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.3701 -		}
110.3702 -		break;
110.3703 -	case 0x600:
110.3704 -	case 0x608:
110.3705 -	// T versions are the same
110.3706 -	case 0x620:
110.3707 -	case 0x628:
110.3708 -	{
110.3709 -		// STR Rd, [Rn], -Rm, LSL #
110.3710 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.3711 -		int dest	= (opcode >> 12) & 15;
110.3712 -		int base	= (opcode >> 16) & 15;
110.3713 -		u32 address = reg[base].I;
110.3714 -		CPUWriteMemory(address, reg[dest].I);
110.3715 -		reg[base].I = address - offset;
110.3716 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3717 -	}
110.3718 -	break;
110.3719 -	case 0x602:
110.3720 -	case 0x60a:
110.3721 -	// T versions are the same
110.3722 -	case 0x622:
110.3723 -	case 0x62a:
110.3724 -	{
110.3725 -		// STR Rd, [Rn], -Rm, LSR #
110.3726 -		int shift	= (opcode >> 7) & 31;
110.3727 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.3728 -		int dest	= (opcode >> 12) & 15;
110.3729 -		int base	= (opcode >> 16) & 15;
110.3730 -		u32 address = reg[base].I;
110.3731 -		CPUWriteMemory(address, reg[dest].I);
110.3732 -		reg[base].I = address - offset;
110.3733 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3734 -	}
110.3735 -	break;
110.3736 -	case 0x604:
110.3737 -	case 0x60c:
110.3738 -	// T versions are the same
110.3739 -	case 0x624:
110.3740 -	case 0x62c:
110.3741 -	{
110.3742 -		// STR Rd, [Rn], -Rm, ASR #
110.3743 -		int shift = (opcode >> 7) & 31;
110.3744 -		int offset;
110.3745 -		if (shift)
110.3746 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.3747 -		else if (reg[opcode & 15].I & 0x80000000)
110.3748 -			offset = 0xFFFFFFFF;
110.3749 -		else
110.3750 -			offset = 0;
110.3751 -		int dest	= (opcode >> 12) & 15;
110.3752 -		int base	= (opcode >> 16) & 15;
110.3753 -		u32 address = reg[base].I;
110.3754 -		CPUWriteMemory(address, reg[dest].I);
110.3755 -		reg[base].I = address - offset;
110.3756 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3757 -	}
110.3758 -	break;
110.3759 -	case 0x606:
110.3760 -	case 0x60e:
110.3761 -	// T versions are the same
110.3762 -	case 0x626:
110.3763 -	case 0x62e:
110.3764 -	{
110.3765 -		// STR Rd, [Rn], -Rm, ROR #
110.3766 -		int shift = (opcode >> 7) & 31;
110.3767 -		u32 value = reg[opcode & 15].I;
110.3768 -		if (shift)
110.3769 -		{
110.3770 -			ROR_VALUE;
110.3771 -		}
110.3772 -		else
110.3773 -		{
110.3774 -			RCR_VALUE;
110.3775 -		}
110.3776 -		int dest	= (opcode >> 12) & 15;
110.3777 -		int base	= (opcode >> 16) & 15;
110.3778 -		u32 address = reg[base].I;
110.3779 -		CPUWriteMemory(address, reg[dest].I);
110.3780 -		reg[base].I = address - value;
110.3781 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3782 -	}
110.3783 -	break;
110.3784 -	case 0x680:
110.3785 -	case 0x688:
110.3786 -	// T versions are the same
110.3787 -	case 0x6a0:
110.3788 -	case 0x6a8:
110.3789 -	{
110.3790 -		// STR Rd, [Rn], Rm, LSL #
110.3791 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.3792 -		int dest	= (opcode >> 12) & 15;
110.3793 -		int base	= (opcode >> 16) & 15;
110.3794 -		u32 address = reg[base].I;
110.3795 -		CPUWriteMemory(address, reg[dest].I);
110.3796 -		reg[base].I = address + offset;
110.3797 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3798 -	}
110.3799 -	break;
110.3800 -	case 0x682:
110.3801 -	case 0x68a:
110.3802 -	// T versions are the same
110.3803 -	case 0x6a2:
110.3804 -	case 0x6aa:
110.3805 -	{
110.3806 -		// STR Rd, [Rn], Rm, LSR #
110.3807 -		int shift	= (opcode >> 7) & 31;
110.3808 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.3809 -		int dest	= (opcode >> 12) & 15;
110.3810 -		int base	= (opcode >> 16) & 15;
110.3811 -		u32 address = reg[base].I;
110.3812 -		CPUWriteMemory(address, reg[dest].I);
110.3813 -		reg[base].I = address + offset;
110.3814 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3815 -	}
110.3816 -	break;
110.3817 -	case 0x684:
110.3818 -	case 0x68c:
110.3819 -	// T versions are the same
110.3820 -	case 0x6a4:
110.3821 -	case 0x6ac:
110.3822 -	{
110.3823 -		// STR Rd, [Rn], Rm, ASR #
110.3824 -		int shift = (opcode >> 7) & 31;
110.3825 -		int offset;
110.3826 -		if (shift)
110.3827 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.3828 -		else if (reg[opcode & 15].I & 0x80000000)
110.3829 -			offset = 0xFFFFFFFF;
110.3830 -		else
110.3831 -			offset = 0;
110.3832 -		int dest	= (opcode >> 12) & 15;
110.3833 -		int base	= (opcode >> 16) & 15;
110.3834 -		u32 address = reg[base].I;
110.3835 -		CPUWriteMemory(address, reg[dest].I);
110.3836 -		reg[base].I = address + offset;
110.3837 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3838 -	}
110.3839 -	break;
110.3840 -	case 0x686:
110.3841 -	case 0x68e:
110.3842 -	// T versions are the same
110.3843 -	case 0x6a6:
110.3844 -	case 0x6ae:
110.3845 -	{
110.3846 -		// STR Rd, [Rn], Rm, ROR #
110.3847 -		int shift = (opcode >> 7) & 31;
110.3848 -		u32 value = reg[opcode & 15].I;
110.3849 -		if (shift)
110.3850 -		{
110.3851 -			ROR_VALUE;
110.3852 -		}
110.3853 -		else
110.3854 -		{
110.3855 -			RCR_VALUE;
110.3856 -		}
110.3857 -		int dest	= (opcode >> 12) & 15;
110.3858 -		int base	= (opcode >> 16) & 15;
110.3859 -		u32 address = reg[base].I;
110.3860 -		CPUWriteMemory(address, reg[dest].I);
110.3861 -		reg[base].I = address + value;
110.3862 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3863 -	}
110.3864 -	break;
110.3865 -	case 0x700:
110.3866 -	case 0x708:
110.3867 -	{
110.3868 -		// STR Rd, [Rn, -Rm, LSL #]
110.3869 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.3870 -		int dest	= (opcode >> 12) & 15;
110.3871 -		int base	= (opcode >> 16) & 15;
110.3872 -		u32 address = reg[base].I - offset;
110.3873 -		CPUWriteMemory(address, reg[dest].I);
110.3874 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3875 -	}
110.3876 -	break;
110.3877 -	case 0x702:
110.3878 -	case 0x70a:
110.3879 -	{
110.3880 -		// STR Rd, [Rn, -Rm, LSR #]
110.3881 -		int shift	= (opcode >> 7) & 31;
110.3882 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.3883 -		int dest	= (opcode >> 12) & 15;
110.3884 -		int base	= (opcode >> 16) & 15;
110.3885 -		u32 address = reg[base].I - offset;
110.3886 -		CPUWriteMemory(address, reg[dest].I);
110.3887 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3888 -	}
110.3889 -	break;
110.3890 -	case 0x704:
110.3891 -	case 0x70c:
110.3892 -	{
110.3893 -		// STR Rd, [Rn, -Rm, ASR #]
110.3894 -		int shift = (opcode >> 7) & 31;
110.3895 -		int offset;
110.3896 -		if (shift)
110.3897 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.3898 -		else if (reg[opcode & 15].I & 0x80000000)
110.3899 -			offset = 0xFFFFFFFF;
110.3900 -		else
110.3901 -			offset = 0;
110.3902 -		int dest	= (opcode >> 12) & 15;
110.3903 -		int base	= (opcode >> 16) & 15;
110.3904 -		u32 address = reg[base].I - offset;
110.3905 -		CPUWriteMemory(address, reg[dest].I);
110.3906 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3907 -	}
110.3908 -	break;
110.3909 -	case 0x706:
110.3910 -	case 0x70e:
110.3911 -	{
110.3912 -		// STR Rd, [Rn, -Rm, ROR #]
110.3913 -		int shift = (opcode >> 7) & 31;
110.3914 -		u32 value = reg[opcode & 15].I;
110.3915 -		if (shift)
110.3916 -		{
110.3917 -			ROR_VALUE;
110.3918 -		}
110.3919 -		else
110.3920 -		{
110.3921 -			RCR_VALUE;
110.3922 -		}
110.3923 -		int dest	= (opcode >> 12) & 15;
110.3924 -		int base	= (opcode >> 16) & 15;
110.3925 -		u32 address = reg[base].I - value;
110.3926 -		CPUWriteMemory(address, reg[dest].I);
110.3927 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3928 -	}
110.3929 -	break;
110.3930 -	case 0x720:
110.3931 -	case 0x728:
110.3932 -	{
110.3933 -		// STR Rd, [Rn, -Rm, LSL #]!
110.3934 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.3935 -		int dest	= (opcode >> 12) & 15;
110.3936 -		int base	= (opcode >> 16) & 15;
110.3937 -		u32 address = reg[base].I - offset;
110.3938 -		reg[base].I = address;
110.3939 -		CPUWriteMemory(address, reg[dest].I);
110.3940 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3941 -	}
110.3942 -	break;
110.3943 -	case 0x722:
110.3944 -	case 0x72a:
110.3945 -	{
110.3946 -		// STR Rd, [Rn, -Rm, LSR #]!
110.3947 -		int shift	= (opcode >> 7) & 31;
110.3948 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.3949 -		int dest	= (opcode >> 12) & 15;
110.3950 -		int base	= (opcode >> 16) & 15;
110.3951 -		u32 address = reg[base].I - offset;
110.3952 -		reg[base].I = address;
110.3953 -		CPUWriteMemory(address, reg[dest].I);
110.3954 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3955 -	}
110.3956 -	break;
110.3957 -	case 0x724:
110.3958 -	case 0x72c:
110.3959 -	{
110.3960 -		// STR Rd, [Rn, -Rm, ASR #]!
110.3961 -		int shift = (opcode >> 7) & 31;
110.3962 -		int offset;
110.3963 -		if (shift)
110.3964 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.3965 -		else if (reg[opcode & 15].I & 0x80000000)
110.3966 -			offset = 0xFFFFFFFF;
110.3967 -		else
110.3968 -			offset = 0;
110.3969 -		int dest	= (opcode >> 12) & 15;
110.3970 -		int base	= (opcode >> 16) & 15;
110.3971 -		u32 address = reg[base].I - offset;
110.3972 -		reg[base].I = address;
110.3973 -		CPUWriteMemory(address, reg[dest].I);
110.3974 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3975 -	}
110.3976 -	break;
110.3977 -	case 0x726:
110.3978 -	case 0x72e:
110.3979 -	{
110.3980 -		// STR Rd, [Rn, -Rm, ROR #]!
110.3981 -		int shift = (opcode >> 7) & 31;
110.3982 -		u32 value = reg[opcode & 15].I;
110.3983 -		if (shift)
110.3984 -		{
110.3985 -			ROR_VALUE;
110.3986 -		}
110.3987 -		else
110.3988 -		{
110.3989 -			RCR_VALUE;
110.3990 -		}
110.3991 -		int dest	= (opcode >> 12) & 15;
110.3992 -		int base	= (opcode >> 16) & 15;
110.3993 -		u32 address = reg[base].I - value;
110.3994 -		reg[base].I = address;
110.3995 -		CPUWriteMemory(address, reg[dest].I);
110.3996 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.3997 -	}
110.3998 -	break;
110.3999 -	case 0x780:
110.4000 -	case 0x788:
110.4001 -	{
110.4002 -		// STR Rd, [Rn, Rm, LSL #]
110.4003 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4004 -		int dest	= (opcode >> 12) & 15;
110.4005 -		int base	= (opcode >> 16) & 15;
110.4006 -		u32 address = reg[base].I + offset;
110.4007 -		CPUWriteMemory(address, reg[dest].I);
110.4008 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4009 -	}
110.4010 -	break;
110.4011 -	case 0x782:
110.4012 -	case 0x78a:
110.4013 -	{
110.4014 -		// STR Rd, [Rn, Rm, LSR #]
110.4015 -		int shift	= (opcode >> 7) & 31;
110.4016 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4017 -		int dest	= (opcode >> 12) & 15;
110.4018 -		int base	= (opcode >> 16) & 15;
110.4019 -		u32 address = reg[base].I + offset;
110.4020 -		CPUWriteMemory(address, reg[dest].I);
110.4021 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4022 -	}
110.4023 -	break;
110.4024 -	case 0x784:
110.4025 -	case 0x78c:
110.4026 -	{
110.4027 -		// STR Rd, [Rn, Rm, ASR #]
110.4028 -		int shift = (opcode >> 7) & 31;
110.4029 -		int offset;
110.4030 -		if (shift)
110.4031 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4032 -		else if (reg[opcode & 15].I & 0x80000000)
110.4033 -			offset = 0xFFFFFFFF;
110.4034 -		else
110.4035 -			offset = 0;
110.4036 -		int dest	= (opcode >> 12) & 15;
110.4037 -		int base	= (opcode >> 16) & 15;
110.4038 -		u32 address = reg[base].I + offset;
110.4039 -		CPUWriteMemory(address, reg[dest].I);
110.4040 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4041 -	}
110.4042 -	break;
110.4043 -	case 0x786:
110.4044 -	case 0x78e:
110.4045 -	{
110.4046 -		// STR Rd, [Rn, Rm, ROR #]
110.4047 -		int shift = (opcode >> 7) & 31;
110.4048 -		u32 value = reg[opcode & 15].I;
110.4049 -		if (shift)
110.4050 -		{
110.4051 -			ROR_VALUE;
110.4052 -		}
110.4053 -		else
110.4054 -		{
110.4055 -			RCR_VALUE;
110.4056 -		}
110.4057 -		int dest	= (opcode >> 12) & 15;
110.4058 -		int base	= (opcode >> 16) & 15;
110.4059 -		u32 address = reg[base].I + value;
110.4060 -		CPUWriteMemory(address, reg[dest].I);
110.4061 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4062 -	}
110.4063 -	break;
110.4064 -	case 0x7a0:
110.4065 -	case 0x7a8:
110.4066 -	{
110.4067 -		// STR Rd, [Rn, Rm, LSL #]!
110.4068 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4069 -		int dest	= (opcode >> 12) & 15;
110.4070 -		int base	= (opcode >> 16) & 15;
110.4071 -		u32 address = reg[base].I + offset;
110.4072 -		reg[base].I = address;
110.4073 -		CPUWriteMemory(address, reg[dest].I);
110.4074 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4075 -	}
110.4076 -	break;
110.4077 -	case 0x7a2:
110.4078 -	case 0x7aa:
110.4079 -	{
110.4080 -		// STR Rd, [Rn, Rm, LSR #]!
110.4081 -		int shift	= (opcode >> 7) & 31;
110.4082 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4083 -		int dest	= (opcode >> 12) & 15;
110.4084 -		int base	= (opcode >> 16) & 15;
110.4085 -		u32 address = reg[base].I + offset;
110.4086 -		reg[base].I = address;
110.4087 -		CPUWriteMemory(address, reg[dest].I);
110.4088 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4089 -	}
110.4090 -	break;
110.4091 -	case 0x7a4:
110.4092 -	case 0x7ac:
110.4093 -	{
110.4094 -		// STR Rd, [Rn, Rm, ASR #]!
110.4095 -		int shift = (opcode >> 7) & 31;
110.4096 -		int offset;
110.4097 -		if (shift)
110.4098 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4099 -		else if (reg[opcode & 15].I & 0x80000000)
110.4100 -			offset = 0xFFFFFFFF;
110.4101 -		else
110.4102 -			offset = 0;
110.4103 -		int dest	= (opcode >> 12) & 15;
110.4104 -		int base	= (opcode >> 16) & 15;
110.4105 -		u32 address = reg[base].I + offset;
110.4106 -		reg[base].I = address;
110.4107 -		CPUWriteMemory(address, reg[dest].I);
110.4108 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4109 -	}
110.4110 -	break;
110.4111 -	case 0x7a6:
110.4112 -	case 0x7ae:
110.4113 -	{
110.4114 -		// STR Rd, [Rn, Rm, ROR #]!
110.4115 -		int shift = (opcode >> 7) & 31;
110.4116 -		u32 value = reg[opcode & 15].I;
110.4117 -		if (shift)
110.4118 -		{
110.4119 -			ROR_VALUE;
110.4120 -		}
110.4121 -		else
110.4122 -		{
110.4123 -			RCR_VALUE;
110.4124 -		}
110.4125 -		int dest	= (opcode >> 12) & 15;
110.4126 -		int base	= (opcode >> 16) & 15;
110.4127 -		u32 address = reg[base].I + value;
110.4128 -		reg[base].I = address;
110.4129 -		CPUWriteMemory(address, reg[dest].I);
110.4130 -		clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.4131 -	}
110.4132 -	break;
110.4133 -	case 0x610:
110.4134 -	case 0x618:
110.4135 -	// T versions are the same
110.4136 -	case 0x630:
110.4137 -	case 0x638:
110.4138 -	{
110.4139 -		// LDR Rd, [Rn], -Rm, LSL #
110.4140 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4141 -		int dest	= (opcode >> 12) & 15;
110.4142 -		int base	= (opcode >> 16) & 15;
110.4143 -		u32 address = reg[base].I;
110.4144 -		reg[dest].I = CPUReadMemory(address);
110.4145 -		if (dest != base)
110.4146 -			reg[base].I = address - offset;
110.4147 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4148 -		if (dest == 15)
110.4149 -		{
110.4150 -			clockTicks += 2;
110.4151 -			reg[15].I  &= 0xFFFFFFFC;
110.4152 -			armNextPC	= reg[15].I;
110.4153 -			reg[15].I  += 4;
110.4154 -		}
110.4155 -	}
110.4156 -	break;
110.4157 -	case 0x612:
110.4158 -	case 0x61a:
110.4159 -	// T versions are the same
110.4160 -	case 0x632:
110.4161 -	case 0x63a:
110.4162 -	{
110.4163 -		// LDR Rd, [Rn], -Rm, LSR #
110.4164 -		int shift	= (opcode >> 7) & 31;
110.4165 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4166 -		int dest	= (opcode >> 12) & 15;
110.4167 -		int base	= (opcode >> 16) & 15;
110.4168 -		u32 address = reg[base].I;
110.4169 -		reg[dest].I = CPUReadMemory(address);
110.4170 -		if (dest != base)
110.4171 -			reg[base].I = address - offset;
110.4172 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4173 -		if (dest == 15)
110.4174 -		{
110.4175 -			clockTicks += 2;
110.4176 -			reg[15].I  &= 0xFFFFFFFC;
110.4177 -			armNextPC	= reg[15].I;
110.4178 -			reg[15].I  += 4;
110.4179 -		}
110.4180 -	}
110.4181 -	break;
110.4182 -	case 0x614:
110.4183 -	case 0x61c:
110.4184 -	// T versions are the same
110.4185 -	case 0x634:
110.4186 -	case 0x63c:
110.4187 -	{
110.4188 -		// LDR Rd, [Rn], -Rm, ASR #
110.4189 -		int shift = (opcode >> 7) & 31;
110.4190 -		int offset;
110.4191 -		if (shift)
110.4192 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4193 -		else if (reg[opcode & 15].I & 0x80000000)
110.4194 -			offset = 0xFFFFFFFF;
110.4195 -		else
110.4196 -			offset = 0;
110.4197 -		int dest	= (opcode >> 12) & 15;
110.4198 -		int base	= (opcode >> 16) & 15;
110.4199 -		u32 address = reg[base].I;
110.4200 -		reg[dest].I = CPUReadMemory(address);
110.4201 -		if (dest != base)
110.4202 -			reg[base].I = address - offset;
110.4203 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4204 -		if (dest == 15)
110.4205 -		{
110.4206 -			clockTicks += 2;
110.4207 -			reg[15].I  &= 0xFFFFFFFC;
110.4208 -			armNextPC	= reg[15].I;
110.4209 -			reg[15].I  += 4;
110.4210 -		}
110.4211 -	}
110.4212 -	break;
110.4213 -	case 0x616:
110.4214 -	case 0x61e:
110.4215 -	// T versions are the same
110.4216 -	case 0x636:
110.4217 -	case 0x63e:
110.4218 -	{
110.4219 -		// LDR Rd, [Rn], -Rm, ROR #
110.4220 -		int shift = (opcode >> 7) & 31;
110.4221 -		u32 value = reg[opcode & 15].I;
110.4222 -		if (shift)
110.4223 -		{
110.4224 -			ROR_VALUE;
110.4225 -		}
110.4226 -		else
110.4227 -		{
110.4228 -			RCR_VALUE;
110.4229 -		}
110.4230 -		int dest	= (opcode >> 12) & 15;
110.4231 -		int base	= (opcode >> 16) & 15;
110.4232 -		u32 address = reg[base].I;
110.4233 -		reg[dest].I = CPUReadMemory(address);
110.4234 -		if (dest != base)
110.4235 -			reg[base].I = address - value;
110.4236 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4237 -		if (dest == 15)
110.4238 -		{
110.4239 -			clockTicks += 2;
110.4240 -			reg[15].I  &= 0xFFFFFFFC;
110.4241 -			armNextPC	= reg[15].I;
110.4242 -			reg[15].I  += 4;
110.4243 -		}
110.4244 -	}
110.4245 -	break;
110.4246 -	case 0x690:
110.4247 -	case 0x698:
110.4248 -	// T versions are the same
110.4249 -	case 0x6b0:
110.4250 -	case 0x6b8:
110.4251 -	{
110.4252 -		// LDR Rd, [Rn], Rm, LSL #
110.4253 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4254 -		int dest	= (opcode >> 12) & 15;
110.4255 -		int base	= (opcode >> 16) & 15;
110.4256 -		u32 address = reg[base].I;
110.4257 -		reg[dest].I = CPUReadMemory(address);
110.4258 -		if (dest != base)
110.4259 -			reg[base].I = address + offset;
110.4260 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4261 -		if (dest == 15)
110.4262 -		{
110.4263 -			clockTicks += 2;
110.4264 -			reg[15].I  &= 0xFFFFFFFC;
110.4265 -			armNextPC	= reg[15].I;
110.4266 -			reg[15].I  += 4;
110.4267 -		}
110.4268 -	}
110.4269 -	break;
110.4270 -	case 0x692:
110.4271 -	case 0x69a:
110.4272 -	// T versions are the same
110.4273 -	case 0x6b2:
110.4274 -	case 0x6ba:
110.4275 -	{
110.4276 -		// LDR Rd, [Rn], Rm, LSR #
110.4277 -		int shift	= (opcode >> 7) & 31;
110.4278 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4279 -		int dest	= (opcode >> 12) & 15;
110.4280 -		int base	= (opcode >> 16) & 15;
110.4281 -		u32 address = reg[base].I;
110.4282 -		reg[dest].I = CPUReadMemory(address);
110.4283 -		if (dest != base)
110.4284 -			reg[base].I = address + offset;
110.4285 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4286 -		if (dest == 15)
110.4287 -		{
110.4288 -			clockTicks += 2;
110.4289 -			reg[15].I  &= 0xFFFFFFFC;
110.4290 -			armNextPC	= reg[15].I;
110.4291 -			reg[15].I  += 4;
110.4292 -		}
110.4293 -	}
110.4294 -	break;
110.4295 -	case 0x694:
110.4296 -	case 0x69c:
110.4297 -	// T versions are the same
110.4298 -	case 0x6b4:
110.4299 -	case 0x6bc:
110.4300 -	{
110.4301 -		// LDR Rd, [Rn], Rm, ASR #
110.4302 -		int shift = (opcode >> 7) & 31;
110.4303 -		int offset;
110.4304 -		if (shift)
110.4305 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4306 -		else if (reg[opcode & 15].I & 0x80000000)
110.4307 -			offset = 0xFFFFFFFF;
110.4308 -		else
110.4309 -			offset = 0;
110.4310 -		int dest	= (opcode >> 12) & 15;
110.4311 -		int base	= (opcode >> 16) & 15;
110.4312 -		u32 address = reg[base].I;
110.4313 -		reg[dest].I = CPUReadMemory(address);
110.4314 -		if (dest != base)
110.4315 -			reg[base].I = address + offset;
110.4316 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4317 -		if (dest == 15)
110.4318 -		{
110.4319 -			clockTicks += 2;
110.4320 -			reg[15].I  &= 0xFFFFFFFC;
110.4321 -			armNextPC	= reg[15].I;
110.4322 -			reg[15].I  += 4;
110.4323 -		}
110.4324 -	}
110.4325 -	break;
110.4326 -	case 0x696:
110.4327 -	case 0x69e:
110.4328 -	// T versions are the same
110.4329 -	case 0x6b6:
110.4330 -	case 0x6be:
110.4331 -	{
110.4332 -		// LDR Rd, [Rn], Rm, ROR #
110.4333 -		int shift = (opcode >> 7) & 31;
110.4334 -		u32 value = reg[opcode & 15].I;
110.4335 -		if (shift)
110.4336 -		{
110.4337 -			ROR_VALUE;
110.4338 -		}
110.4339 -		else
110.4340 -		{
110.4341 -			RCR_VALUE;
110.4342 -		}
110.4343 -		int dest	= (opcode >> 12) & 15;
110.4344 -		int base	= (opcode >> 16) & 15;
110.4345 -		u32 address = reg[base].I;
110.4346 -		reg[dest].I = CPUReadMemory(address);
110.4347 -		if (dest != base)
110.4348 -			reg[base].I = address + value;
110.4349 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4350 -		if (dest == 15)
110.4351 -		{
110.4352 -			clockTicks += 2;
110.4353 -			reg[15].I  &= 0xFFFFFFFC;
110.4354 -			armNextPC	= reg[15].I;
110.4355 -			reg[15].I  += 4;
110.4356 -		}
110.4357 -	}
110.4358 -	break;
110.4359 -	case 0x710:
110.4360 -	case 0x718:
110.4361 -	{
110.4362 -		// LDR Rd, [Rn, -Rm, LSL #]
110.4363 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4364 -		int dest	= (opcode >> 12) & 15;
110.4365 -		int base	= (opcode >> 16) & 15;
110.4366 -		u32 address = reg[base].I - offset;
110.4367 -		reg[dest].I = CPUReadMemory(address);
110.4368 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4369 -		if (dest == 15)
110.4370 -		{
110.4371 -			clockTicks += 2;
110.4372 -			reg[15].I  &= 0xFFFFFFFC;
110.4373 -			armNextPC	= reg[15].I;
110.4374 -			reg[15].I  += 4;
110.4375 -		}
110.4376 -	}
110.4377 -	break;
110.4378 -	case 0x712:
110.4379 -	case 0x71a:
110.4380 -	{
110.4381 -		// LDR Rd, [Rn, -Rm, LSR #]
110.4382 -		int shift	= (opcode >> 7) & 31;
110.4383 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4384 -		int dest	= (opcode >> 12) & 15;
110.4385 -		int base	= (opcode >> 16) & 15;
110.4386 -		u32 address = reg[base].I - offset;
110.4387 -		reg[dest].I = CPUReadMemory(address);
110.4388 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4389 -		if (dest == 15)
110.4390 -		{
110.4391 -			clockTicks += 2;
110.4392 -			reg[15].I  &= 0xFFFFFFFC;
110.4393 -			armNextPC	= reg[15].I;
110.4394 -			reg[15].I  += 4;
110.4395 -		}
110.4396 -	}
110.4397 -	break;
110.4398 -	case 0x714:
110.4399 -	case 0x71c:
110.4400 -	{
110.4401 -		// LDR Rd, [Rn, -Rm, ASR #]
110.4402 -		int shift = (opcode >> 7) & 31;
110.4403 -		int offset;
110.4404 -		if (shift)
110.4405 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4406 -		else if (reg[opcode & 15].I & 0x80000000)
110.4407 -			offset = 0xFFFFFFFF;
110.4408 -		else
110.4409 -			offset = 0;
110.4410 -		int dest	= (opcode >> 12) & 15;
110.4411 -		int base	= (opcode >> 16) & 15;
110.4412 -		u32 address = reg[base].I - offset;
110.4413 -		reg[dest].I = CPUReadMemory(address);
110.4414 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4415 -		if (dest == 15)
110.4416 -		{
110.4417 -			clockTicks += 2;
110.4418 -			reg[15].I  &= 0xFFFFFFFC;
110.4419 -			armNextPC	= reg[15].I;
110.4420 -			reg[15].I  += 4;
110.4421 -		}
110.4422 -	}
110.4423 -	break;
110.4424 -	case 0x716:
110.4425 -	case 0x71e:
110.4426 -	{
110.4427 -		// LDR Rd, [Rn, -Rm, ROR #]
110.4428 -		int shift = (opcode >> 7) & 31;
110.4429 -		u32 value = reg[opcode & 15].I;
110.4430 -		if (shift)
110.4431 -		{
110.4432 -			ROR_VALUE;
110.4433 -		}
110.4434 -		else
110.4435 -		{
110.4436 -			RCR_VALUE;
110.4437 -		}
110.4438 -		int dest	= (opcode >> 12) & 15;
110.4439 -		int base	= (opcode >> 16) & 15;
110.4440 -		u32 address = reg[base].I - value;
110.4441 -		reg[dest].I = CPUReadMemory(address);
110.4442 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4443 -		if (dest == 15)
110.4444 -		{
110.4445 -			clockTicks += 2;
110.4446 -			reg[15].I  &= 0xFFFFFFFC;
110.4447 -			armNextPC	= reg[15].I;
110.4448 -			reg[15].I  += 4;
110.4449 -		}
110.4450 -	}
110.4451 -	break;
110.4452 -	case 0x730:
110.4453 -	case 0x738:
110.4454 -	{
110.4455 -		// LDR Rd, [Rn, -Rm, LSL #]!
110.4456 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4457 -		int dest	= (opcode >> 12) & 15;
110.4458 -		int base	= (opcode >> 16) & 15;
110.4459 -		u32 address = reg[base].I - offset;
110.4460 -		reg[dest].I = CPUReadMemory(address);
110.4461 -		if (dest != base)
110.4462 -			reg[base].I = address;
110.4463 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4464 -		if (dest == 15)
110.4465 -		{
110.4466 -			clockTicks += 2;
110.4467 -			reg[15].I  &= 0xFFFFFFFC;
110.4468 -			armNextPC	= reg[15].I;
110.4469 -			reg[15].I  += 4;
110.4470 -		}
110.4471 -	}
110.4472 -	break;
110.4473 -	case 0x732:
110.4474 -	case 0x73a:
110.4475 -	{
110.4476 -		// LDR Rd, [Rn, -Rm, LSR #]!
110.4477 -		int shift	= (opcode >> 7) & 31;
110.4478 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4479 -		int dest	= (opcode >> 12) & 15;
110.4480 -		int base	= (opcode >> 16) & 15;
110.4481 -		u32 address = reg[base].I - offset;
110.4482 -		reg[dest].I = CPUReadMemory(address);
110.4483 -		if (dest != base)
110.4484 -			reg[base].I = address;
110.4485 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4486 -		if (dest == 15)
110.4487 -		{
110.4488 -			clockTicks += 2;
110.4489 -			reg[15].I  &= 0xFFFFFFFC;
110.4490 -			armNextPC	= reg[15].I;
110.4491 -			reg[15].I  += 4;
110.4492 -		}
110.4493 -	}
110.4494 -	break;
110.4495 -	case 0x734:
110.4496 -	case 0x73c:
110.4497 -	{
110.4498 -		// LDR Rd, [Rn, -Rm, ASR #]!
110.4499 -		int shift = (opcode >> 7) & 31;
110.4500 -		int offset;
110.4501 -		if (shift)
110.4502 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4503 -		else if (reg[opcode & 15].I & 0x80000000)
110.4504 -			offset = 0xFFFFFFFF;
110.4505 -		else
110.4506 -			offset = 0;
110.4507 -		int dest	= (opcode >> 12) & 15;
110.4508 -		int base	= (opcode >> 16) & 15;
110.4509 -		u32 address = reg[base].I - offset;
110.4510 -		reg[dest].I = CPUReadMemory(address);
110.4511 -		if (dest != base)
110.4512 -			reg[base].I = address;
110.4513 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4514 -		if (dest == 15)
110.4515 -		{
110.4516 -			clockTicks += 2;
110.4517 -			reg[15].I  &= 0xFFFFFFFC;
110.4518 -			armNextPC	= reg[15].I;
110.4519 -			reg[15].I  += 4;
110.4520 -		}
110.4521 -	}
110.4522 -	break;
110.4523 -	case 0x736:
110.4524 -	case 0x73e:
110.4525 -	{
110.4526 -		// LDR Rd, [Rn, -Rm, ROR #]!
110.4527 -		int shift = (opcode >> 7) & 31;
110.4528 -		u32 value = reg[opcode & 15].I;
110.4529 -		if (shift)
110.4530 -		{
110.4531 -			ROR_VALUE;
110.4532 -		}
110.4533 -		else
110.4534 -		{
110.4535 -			RCR_VALUE;
110.4536 -		}
110.4537 -		int dest	= (opcode >> 12) & 15;
110.4538 -		int base	= (opcode >> 16) & 15;
110.4539 -		u32 address = reg[base].I - value;
110.4540 -		reg[dest].I = CPUReadMemory(address);
110.4541 -		if (dest != base)
110.4542 -			reg[base].I = address;
110.4543 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4544 -		if (dest == 15)
110.4545 -		{
110.4546 -			clockTicks += 2;
110.4547 -			reg[15].I  &= 0xFFFFFFFC;
110.4548 -			armNextPC	= reg[15].I;
110.4549 -			reg[15].I  += 4;
110.4550 -		}
110.4551 -	}
110.4552 -	break;
110.4553 -	case 0x790:
110.4554 -	case 0x798:
110.4555 -	{
110.4556 -		// LDR Rd, [Rn, Rm, LSL #]
110.4557 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4558 -		int dest	= (opcode >> 12) & 15;
110.4559 -		int base	= (opcode >> 16) & 15;
110.4560 -		u32 address = reg[base].I + offset;
110.4561 -		reg[dest].I = CPUReadMemory(address);
110.4562 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4563 -		if (dest == 15)
110.4564 -		{
110.4565 -			clockTicks += 2;
110.4566 -			reg[15].I  &= 0xFFFFFFFC;
110.4567 -			armNextPC	= reg[15].I;
110.4568 -			reg[15].I  += 4;
110.4569 -		}
110.4570 -	}
110.4571 -	break;
110.4572 -	case 0x792:
110.4573 -	case 0x79a:
110.4574 -	{
110.4575 -		// LDR Rd, [Rn, Rm, LSR #]
110.4576 -		int shift	= (opcode >> 7) & 31;
110.4577 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4578 -		int dest	= (opcode >> 12) & 15;
110.4579 -		int base	= (opcode >> 16) & 15;
110.4580 -		u32 address = reg[base].I + offset;
110.4581 -		reg[dest].I = CPUReadMemory(address);
110.4582 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4583 -		if (dest == 15)
110.4584 -		{
110.4585 -			clockTicks += 2;
110.4586 -			reg[15].I  &= 0xFFFFFFFC;
110.4587 -			armNextPC	= reg[15].I;
110.4588 -			reg[15].I  += 4;
110.4589 -		}
110.4590 -	}
110.4591 -	break;
110.4592 -	case 0x794:
110.4593 -	case 0x79c:
110.4594 -	{
110.4595 -		// LDR Rd, [Rn, Rm, ASR #]
110.4596 -		int shift = (opcode >> 7) & 31;
110.4597 -		int offset;
110.4598 -		if (shift)
110.4599 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4600 -		else if (reg[opcode & 15].I & 0x80000000)
110.4601 -			offset = 0xFFFFFFFF;
110.4602 -		else
110.4603 -			offset = 0;
110.4604 -		int dest	= (opcode >> 12) & 15;
110.4605 -		int base	= (opcode >> 16) & 15;
110.4606 -		u32 address = reg[base].I + offset;
110.4607 -		reg[dest].I = CPUReadMemory(address);
110.4608 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4609 -		if (dest == 15)
110.4610 -		{
110.4611 -			clockTicks += 2;
110.4612 -			reg[15].I  &= 0xFFFFFFFC;
110.4613 -			armNextPC	= reg[15].I;
110.4614 -			reg[15].I  += 4;
110.4615 -		}
110.4616 -	}
110.4617 -	break;
110.4618 -	case 0x796:
110.4619 -	case 0x79e:
110.4620 -	{
110.4621 -		// LDR Rd, [Rn, Rm, ROR #]
110.4622 -		int shift = (opcode >> 7) & 31;
110.4623 -		u32 value = reg[opcode & 15].I;
110.4624 -		if (shift)
110.4625 -		{
110.4626 -			ROR_VALUE;
110.4627 -		}
110.4628 -		else
110.4629 -		{
110.4630 -			RCR_VALUE;
110.4631 -		}
110.4632 -		int dest	= (opcode >> 12) & 15;
110.4633 -		int base	= (opcode >> 16) & 15;
110.4634 -		u32 address = reg[base].I + value;
110.4635 -		reg[dest].I = CPUReadMemory(address);
110.4636 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4637 -		if (dest == 15)
110.4638 -		{
110.4639 -			clockTicks += 2;
110.4640 -			reg[15].I  &= 0xFFFFFFFC;
110.4641 -			armNextPC	= reg[15].I;
110.4642 -			reg[15].I  += 4;
110.4643 -		}
110.4644 -	}
110.4645 -	break;
110.4646 -	case 0x7b0:
110.4647 -	case 0x7b8:
110.4648 -	{
110.4649 -		// LDR Rd, [Rn, Rm, LSL #]!
110.4650 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4651 -		int dest	= (opcode >> 12) & 15;
110.4652 -		int base	= (opcode >> 16) & 15;
110.4653 -		u32 address = reg[base].I + offset;
110.4654 -		reg[dest].I = CPUReadMemory(address);
110.4655 -		if (dest != base)
110.4656 -			reg[base].I = address;
110.4657 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4658 -		if (dest == 15)
110.4659 -		{
110.4660 -			clockTicks += 2;
110.4661 -			reg[15].I  &= 0xFFFFFFFC;
110.4662 -			armNextPC	= reg[15].I;
110.4663 -			reg[15].I  += 4;
110.4664 -		}
110.4665 -	}
110.4666 -	break;
110.4667 -	case 0x7b2:
110.4668 -	case 0x7ba:
110.4669 -	{
110.4670 -		// LDR Rd, [Rn, Rm, LSR #]!
110.4671 -		int shift	= (opcode >> 7) & 31;
110.4672 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4673 -		int dest	= (opcode >> 12) & 15;
110.4674 -		int base	= (opcode >> 16) & 15;
110.4675 -		u32 address = reg[base].I + offset;
110.4676 -		reg[dest].I = CPUReadMemory(address);
110.4677 -		if (dest != base)
110.4678 -			reg[base].I = address;
110.4679 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4680 -		if (dest == 15)
110.4681 -		{
110.4682 -			clockTicks += 2;
110.4683 -			reg[15].I  &= 0xFFFFFFFC;
110.4684 -			armNextPC	= reg[15].I;
110.4685 -			reg[15].I  += 4;
110.4686 -		}
110.4687 -	}
110.4688 -	break;
110.4689 -	case 0x7b4:
110.4690 -	case 0x7bc:
110.4691 -	{
110.4692 -		// LDR Rd, [Rn, Rm, ASR #]!
110.4693 -		int shift = (opcode >> 7) & 31;
110.4694 -		int offset;
110.4695 -		if (shift)
110.4696 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4697 -		else if (reg[opcode & 15].I & 0x80000000)
110.4698 -			offset = 0xFFFFFFFF;
110.4699 -		else
110.4700 -			offset = 0;
110.4701 -		int dest	= (opcode >> 12) & 15;
110.4702 -		int base	= (opcode >> 16) & 15;
110.4703 -		u32 address = reg[base].I + offset;
110.4704 -		reg[dest].I = CPUReadMemory(address);
110.4705 -		if (dest != base)
110.4706 -			reg[base].I = address;
110.4707 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4708 -		if (dest == 15)
110.4709 -		{
110.4710 -			clockTicks += 2;
110.4711 -			reg[15].I  &= 0xFFFFFFFC;
110.4712 -			armNextPC	= reg[15].I;
110.4713 -			reg[15].I  += 4;
110.4714 -		}
110.4715 -	}
110.4716 -	break;
110.4717 -	case 0x7b6:
110.4718 -	case 0x7be:
110.4719 -	{
110.4720 -		// LDR Rd, [Rn, Rm, ROR #]!
110.4721 -		int shift = (opcode >> 7) & 31;
110.4722 -		u32 value = reg[opcode & 15].I;
110.4723 -		if (shift)
110.4724 -		{
110.4725 -			ROR_VALUE;
110.4726 -		}
110.4727 -		else
110.4728 -		{
110.4729 -			RCR_VALUE;
110.4730 -		}
110.4731 -		int dest	= (opcode >> 12) & 15;
110.4732 -		int base	= (opcode >> 16) & 15;
110.4733 -		u32 address = reg[base].I + value;
110.4734 -		reg[dest].I = CPUReadMemory(address);
110.4735 -		if (dest != base)
110.4736 -			reg[base].I = address;
110.4737 -		clockTicks += 3 + CPUUpdateTicksAccess32(address);
110.4738 -		if (dest == 15)
110.4739 -		{
110.4740 -			clockTicks += 2;
110.4741 -			reg[15].I  &= 0xFFFFFFFC;
110.4742 -			armNextPC	= reg[15].I;
110.4743 -			reg[15].I  += 4;
110.4744 -		}
110.4745 -	}
110.4746 -	break;
110.4747 -	case 0x640:
110.4748 -	case 0x648:
110.4749 -	// T versions are the same
110.4750 -	case 0x660:
110.4751 -	case 0x668:
110.4752 -	{
110.4753 -		// STRB Rd, [Rn], -Rm, LSL #
110.4754 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4755 -		int dest	= (opcode >> 12) & 15;
110.4756 -		int base	= (opcode >> 16) & 15;
110.4757 -		u32 address = reg[base].I;
110.4758 -		CPUWriteByte(address, reg[dest].B.B0);
110.4759 -		reg[base].I = address - offset;
110.4760 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4761 -	}
110.4762 -	break;
110.4763 -	case 0x642:
110.4764 -	case 0x64a:
110.4765 -	// T versions are the same
110.4766 -	case 0x662:
110.4767 -	case 0x66a:
110.4768 -	{
110.4769 -		// STRB Rd, [Rn], -Rm, LSR #
110.4770 -		int shift	= (opcode >> 7) & 31;
110.4771 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4772 -		int dest	= (opcode >> 12) & 15;
110.4773 -		int base	= (opcode >> 16) & 15;
110.4774 -		u32 address = reg[base].I;
110.4775 -		CPUWriteByte(address, reg[dest].B.B0);
110.4776 -		reg[base].I = address - offset;
110.4777 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4778 -	}
110.4779 -	break;
110.4780 -	case 0x644:
110.4781 -	case 0x64c:
110.4782 -	// T versions are the same
110.4783 -	case 0x664:
110.4784 -	case 0x66c:
110.4785 -	{
110.4786 -		// STRB Rd, [Rn], -Rm, ASR #
110.4787 -		int shift = (opcode >> 7) & 31;
110.4788 -		int offset;
110.4789 -		if (shift)
110.4790 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4791 -		else if (reg[opcode & 15].I & 0x80000000)
110.4792 -			offset = 0xFFFFFFFF;
110.4793 -		else
110.4794 -			offset = 0;
110.4795 -		int dest	= (opcode >> 12) & 15;
110.4796 -		int base	= (opcode >> 16) & 15;
110.4797 -		u32 address = reg[base].I;
110.4798 -		CPUWriteByte(address, reg[dest].B.B0);
110.4799 -		reg[base].I = address - offset;
110.4800 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4801 -	}
110.4802 -	break;
110.4803 -	case 0x646:
110.4804 -	case 0x64e:
110.4805 -	// T versions are the same
110.4806 -	case 0x666:
110.4807 -	case 0x66e:
110.4808 -	{
110.4809 -		// STRB Rd, [Rn], -Rm, ROR #
110.4810 -		int shift = (opcode >> 7) & 31;
110.4811 -		u32 value = reg[opcode & 15].I;
110.4812 -		if (shift)
110.4813 -		{
110.4814 -			ROR_VALUE;
110.4815 -		}
110.4816 -		else
110.4817 -		{
110.4818 -			RCR_VALUE;
110.4819 -		}
110.4820 -		int dest	= (opcode >> 12) & 15;
110.4821 -		int base	= (opcode >> 16) & 15;
110.4822 -		u32 address = reg[base].I;
110.4823 -		CPUWriteByte(address, reg[dest].B.B0);
110.4824 -		reg[base].I = address - value;
110.4825 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4826 -	}
110.4827 -	break;
110.4828 -	case 0x6c0:
110.4829 -	case 0x6c8:
110.4830 -	// T versions are the same
110.4831 -	case 0x6e0:
110.4832 -	case 0x6e8:
110.4833 -	{
110.4834 -		// STRB Rd, [Rn], Rm, LSL #
110.4835 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4836 -		int dest	= (opcode >> 12) & 15;
110.4837 -		int base	= (opcode >> 16) & 15;
110.4838 -		u32 address = reg[base].I;
110.4839 -		CPUWriteByte(address, reg[dest].B.B0);
110.4840 -		reg[base].I = address + offset;
110.4841 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4842 -	}
110.4843 -	break;
110.4844 -	case 0x6c2:
110.4845 -	case 0x6ca:
110.4846 -	// T versions are the same
110.4847 -	case 0x6e2:
110.4848 -	case 0x6ea:
110.4849 -	{
110.4850 -		// STRB Rd, [Rn], Rm, LSR #
110.4851 -		int shift	= (opcode >> 7) & 31;
110.4852 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4853 -		int dest	= (opcode >> 12) & 15;
110.4854 -		int base	= (opcode >> 16) & 15;
110.4855 -		u32 address = reg[base].I;
110.4856 -		CPUWriteByte(address, reg[dest].B.B0);
110.4857 -		reg[base].I = address + offset;
110.4858 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4859 -	}
110.4860 -	break;
110.4861 -	case 0x6c4:
110.4862 -	case 0x6cc:
110.4863 -	// T versions are the same
110.4864 -	case 0x6e4:
110.4865 -	case 0x6ec:
110.4866 -	{
110.4867 -		// STR Rd, [Rn], Rm, ASR #
110.4868 -		int shift = (opcode >> 7) & 31;
110.4869 -		int offset;
110.4870 -		if (shift)
110.4871 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4872 -		else if (reg[opcode & 15].I & 0x80000000)
110.4873 -			offset = 0xFFFFFFFF;
110.4874 -		else
110.4875 -			offset = 0;
110.4876 -		int dest	= (opcode >> 12) & 15;
110.4877 -		int base	= (opcode >> 16) & 15;
110.4878 -		u32 address = reg[base].I;
110.4879 -		CPUWriteByte(address, reg[dest].B.B0);
110.4880 -		reg[base].I = address + offset;
110.4881 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4882 -	}
110.4883 -	break;
110.4884 -	case 0x6c6:
110.4885 -	case 0x6ce:
110.4886 -	// T versions are the same
110.4887 -	case 0x6e6:
110.4888 -	case 0x6ee:
110.4889 -	{
110.4890 -		// STRB Rd, [Rn], Rm, ROR #
110.4891 -		int shift = (opcode >> 7) & 31;
110.4892 -		u32 value = reg[opcode & 15].I;
110.4893 -		if (shift)
110.4894 -		{
110.4895 -			ROR_VALUE;
110.4896 -		}
110.4897 -		else
110.4898 -		{
110.4899 -			RCR_VALUE;
110.4900 -		}
110.4901 -		int dest	= (opcode >> 12) & 15;
110.4902 -		int base	= (opcode >> 16) & 15;
110.4903 -		u32 address = reg[base].I;
110.4904 -		CPUWriteByte(address, reg[dest].B.B0);
110.4905 -		reg[base].I = address + value;
110.4906 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4907 -	}
110.4908 -	break;
110.4909 -	case 0x740:
110.4910 -	case 0x748:
110.4911 -	{
110.4912 -		// STRB Rd, [Rn, -Rm, LSL #]
110.4913 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4914 -		int dest	= (opcode >> 12) & 15;
110.4915 -		int base	= (opcode >> 16) & 15;
110.4916 -		u32 address = reg[base].I - offset;
110.4917 -		CPUWriteByte(address, reg[dest].B.B0);
110.4918 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4919 -	}
110.4920 -	break;
110.4921 -	case 0x742:
110.4922 -	case 0x74a:
110.4923 -	{
110.4924 -		// STRB Rd, [Rn, -Rm, LSR #]
110.4925 -		int shift	= (opcode >> 7) & 31;
110.4926 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4927 -		int dest	= (opcode >> 12) & 15;
110.4928 -		int base	= (opcode >> 16) & 15;
110.4929 -		u32 address = reg[base].I - offset;
110.4930 -		CPUWriteByte(address, reg[dest].B.B0);
110.4931 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4932 -	}
110.4933 -	break;
110.4934 -	case 0x744:
110.4935 -	case 0x74c:
110.4936 -	{
110.4937 -		// STRB Rd, [Rn, -Rm, ASR #]
110.4938 -		int shift = (opcode >> 7) & 31;
110.4939 -		int offset;
110.4940 -		if (shift)
110.4941 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.4942 -		else if (reg[opcode & 15].I & 0x80000000)
110.4943 -			offset = 0xFFFFFFFF;
110.4944 -		else
110.4945 -			offset = 0;
110.4946 -		int dest	= (opcode >> 12) & 15;
110.4947 -		int base	= (opcode >> 16) & 15;
110.4948 -		u32 address = reg[base].I - offset;
110.4949 -		CPUWriteByte(address, reg[dest].B.B0);
110.4950 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4951 -	}
110.4952 -	break;
110.4953 -	case 0x746:
110.4954 -	case 0x74e:
110.4955 -	{
110.4956 -		// STRB Rd, [Rn, -Rm, ROR #]
110.4957 -		int shift = (opcode >> 7) & 31;
110.4958 -		u32 value = reg[opcode & 15].I;
110.4959 -		if (shift)
110.4960 -		{
110.4961 -			ROR_VALUE;
110.4962 -		}
110.4963 -		else
110.4964 -		{
110.4965 -			RCR_VALUE;
110.4966 -		}
110.4967 -		int dest	= (opcode >> 12) & 15;
110.4968 -		int base	= (opcode >> 16) & 15;
110.4969 -		u32 address = reg[base].I - value;
110.4970 -		CPUWriteByte(address, reg[dest].B.B0);
110.4971 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4972 -	}
110.4973 -	break;
110.4974 -	case 0x760:
110.4975 -	case 0x768:
110.4976 -	{
110.4977 -		// STRB Rd, [Rn, -Rm, LSL #]!
110.4978 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.4979 -		int dest	= (opcode >> 12) & 15;
110.4980 -		int base	= (opcode >> 16) & 15;
110.4981 -		u32 address = reg[base].I - offset;
110.4982 -		reg[base].I = address;
110.4983 -		CPUWriteByte(address, reg[dest].B.B0);
110.4984 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4985 -	}
110.4986 -	break;
110.4987 -	case 0x762:
110.4988 -	case 0x76a:
110.4989 -	{
110.4990 -		// STRB Rd, [Rn, -Rm, LSR #]!
110.4991 -		int shift	= (opcode >> 7) & 31;
110.4992 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.4993 -		int dest	= (opcode >> 12) & 15;
110.4994 -		int base	= (opcode >> 16) & 15;
110.4995 -		u32 address = reg[base].I - offset;
110.4996 -		reg[base].I = address;
110.4997 -		CPUWriteByte(address, reg[dest].B.B0);
110.4998 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.4999 -	}
110.5000 -	break;
110.5001 -	case 0x764:
110.5002 -	case 0x76c:
110.5003 -	{
110.5004 -		// STRB Rd, [Rn, -Rm, ASR #]!
110.5005 -		int shift = (opcode >> 7) & 31;
110.5006 -		int offset;
110.5007 -		if (shift)
110.5008 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5009 -		else if (reg[opcode & 15].I & 0x80000000)
110.5010 -			offset = 0xFFFFFFFF;
110.5011 -		else
110.5012 -			offset = 0;
110.5013 -		int dest	= (opcode >> 12) & 15;
110.5014 -		int base	= (opcode >> 16) & 15;
110.5015 -		u32 address = reg[base].I - offset;
110.5016 -		reg[base].I = address;
110.5017 -		CPUWriteByte(address, reg[dest].B.B0);
110.5018 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5019 -	}
110.5020 -	break;
110.5021 -	case 0x766:
110.5022 -	case 0x76e:
110.5023 -	{
110.5024 -		// STRB Rd, [Rn, -Rm, ROR #]!
110.5025 -		int shift = (opcode >> 7) & 31;
110.5026 -		u32 value = reg[opcode & 15].I;
110.5027 -		if (shift)
110.5028 -		{
110.5029 -			ROR_VALUE;
110.5030 -		}
110.5031 -		else
110.5032 -		{
110.5033 -			RCR_VALUE;
110.5034 -		}
110.5035 -		int dest	= (opcode >> 12) & 15;
110.5036 -		int base	= (opcode >> 16) & 15;
110.5037 -		u32 address = reg[base].I - value;
110.5038 -		reg[base].I = address;
110.5039 -		CPUWriteByte(address, reg[dest].B.B0);
110.5040 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5041 -	}
110.5042 -	break;
110.5043 -	case 0x7c0:
110.5044 -	case 0x7c8:
110.5045 -	{
110.5046 -		// STRB Rd, [Rn, Rm, LSL #]
110.5047 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5048 -		int dest	= (opcode >> 12) & 15;
110.5049 -		int base	= (opcode >> 16) & 15;
110.5050 -		u32 address = reg[base].I + offset;
110.5051 -		CPUWriteByte(address, reg[dest].B.B0);
110.5052 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5053 -	}
110.5054 -	break;
110.5055 -	case 0x7c2:
110.5056 -	case 0x7ca:
110.5057 -	{
110.5058 -		// STRB Rd, [Rn, Rm, LSR #]
110.5059 -		int shift	= (opcode >> 7) & 31;
110.5060 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5061 -		int dest	= (opcode >> 12) & 15;
110.5062 -		int base	= (opcode >> 16) & 15;
110.5063 -		u32 address = reg[base].I + offset;
110.5064 -		CPUWriteByte(address, reg[dest].B.B0);
110.5065 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5066 -	}
110.5067 -	break;
110.5068 -	case 0x7c4:
110.5069 -	case 0x7cc:
110.5070 -	{
110.5071 -		// STRB Rd, [Rn, Rm, ASR #]
110.5072 -		int shift = (opcode >> 7) & 31;
110.5073 -		int offset;
110.5074 -		if (shift)
110.5075 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5076 -		else if (reg[opcode & 15].I & 0x80000000)
110.5077 -			offset = 0xFFFFFFFF;
110.5078 -		else
110.5079 -			offset = 0;
110.5080 -		int dest	= (opcode >> 12) & 15;
110.5081 -		int base	= (opcode >> 16) & 15;
110.5082 -		u32 address = reg[base].I + offset;
110.5083 -		CPUWriteByte(address, reg[dest].B.B0);
110.5084 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5085 -	}
110.5086 -	break;
110.5087 -	case 0x7c6:
110.5088 -	case 0x7ce:
110.5089 -	{
110.5090 -		// STRB Rd, [Rn, Rm, ROR #]
110.5091 -		int shift = (opcode >> 7) & 31;
110.5092 -		u32 value = reg[opcode & 15].I;
110.5093 -		if (shift)
110.5094 -		{
110.5095 -			ROR_VALUE;
110.5096 -		}
110.5097 -		else
110.5098 -		{
110.5099 -			RCR_VALUE;
110.5100 -		}
110.5101 -		int dest	= (opcode >> 12) & 15;
110.5102 -		int base	= (opcode >> 16) & 15;
110.5103 -		u32 address = reg[base].I + value;
110.5104 -		CPUWriteByte(address, reg[dest].B.B0);
110.5105 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5106 -	}
110.5107 -	break;
110.5108 -	case 0x7e0:
110.5109 -	case 0x7e8:
110.5110 -	{
110.5111 -		// STRB Rd, [Rn, Rm, LSL #]!
110.5112 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5113 -		int dest	= (opcode >> 12) & 15;
110.5114 -		int base	= (opcode >> 16) & 15;
110.5115 -		u32 address = reg[base].I + offset;
110.5116 -		reg[base].I = address;
110.5117 -		CPUWriteByte(address, reg[dest].B.B0);
110.5118 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5119 -	}
110.5120 -	break;
110.5121 -	case 0x7e2:
110.5122 -	case 0x7ea:
110.5123 -	{
110.5124 -		// STRB Rd, [Rn, Rm, LSR #]!
110.5125 -		int shift	= (opcode >> 7) & 31;
110.5126 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5127 -		int dest	= (opcode >> 12) & 15;
110.5128 -		int base	= (opcode >> 16) & 15;
110.5129 -		u32 address = reg[base].I + offset;
110.5130 -		reg[base].I = address;
110.5131 -		CPUWriteByte(address, reg[dest].B.B0);
110.5132 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5133 -	}
110.5134 -	break;
110.5135 -	case 0x7e4:
110.5136 -	case 0x7ec:
110.5137 -	{
110.5138 -		// STRB Rd, [Rn, Rm, ASR #]!
110.5139 -		int shift = (opcode >> 7) & 31;
110.5140 -		int offset;
110.5141 -		if (shift)
110.5142 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5143 -		else if (reg[opcode & 15].I & 0x80000000)
110.5144 -			offset = 0xFFFFFFFF;
110.5145 -		else
110.5146 -			offset = 0;
110.5147 -		int dest	= (opcode >> 12) & 15;
110.5148 -		int base	= (opcode >> 16) & 15;
110.5149 -		u32 address = reg[base].I + offset;
110.5150 -		reg[base].I = address;
110.5151 -		CPUWriteByte(address, reg[dest].B.B0);
110.5152 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5153 -	}
110.5154 -	break;
110.5155 -	case 0x7e6:
110.5156 -	case 0x7ee:
110.5157 -	{
110.5158 -		// STRB Rd, [Rn, Rm, ROR #]!
110.5159 -		int shift = (opcode >> 7) & 31;
110.5160 -		u32 value = reg[opcode & 15].I;
110.5161 -		if (shift)
110.5162 -		{
110.5163 -			ROR_VALUE;
110.5164 -		}
110.5165 -		else
110.5166 -		{
110.5167 -			RCR_VALUE;
110.5168 -		}
110.5169 -		int dest	= (opcode >> 12) & 15;
110.5170 -		int base	= (opcode >> 16) & 15;
110.5171 -		u32 address = reg[base].I + value;
110.5172 -		reg[base].I = address;
110.5173 -		CPUWriteByte(address, reg[dest].B.B0);
110.5174 -		clockTicks += 2 + CPUUpdateTicksAccess16(address);
110.5175 -	}
110.5176 -	break;
110.5177 -	case 0x650:
110.5178 -	case 0x658:
110.5179 -	// T versions are the same
110.5180 -	case 0x670:
110.5181 -	case 0x678:
110.5182 -	{
110.5183 -		// LDRB Rd, [Rn], -Rm, LSL #
110.5184 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5185 -		int dest	= (opcode >> 12) & 15;
110.5186 -		int base	= (opcode >> 16) & 15;
110.5187 -		u32 address = reg[base].I;
110.5188 -		reg[dest].I = CPUReadByte(address);
110.5189 -		if (dest != base)
110.5190 -			reg[base].I = address - offset;
110.5191 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5192 -	}
110.5193 -	break;
110.5194 -	case 0x652:
110.5195 -	case 0x65a:
110.5196 -	// T versions are the same
110.5197 -	case 0x672:
110.5198 -	case 0x67a:
110.5199 -	{
110.5200 -		// LDRB Rd, [Rn], -Rm, LSR #
110.5201 -		int shift	= (opcode >> 7) & 31;
110.5202 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5203 -		int dest	= (opcode >> 12) & 15;
110.5204 -		int base	= (opcode >> 16) & 15;
110.5205 -		u32 address = reg[base].I;
110.5206 -		reg[dest].I = CPUReadByte(address);
110.5207 -		if (dest != base)
110.5208 -			reg[base].I = address - offset;
110.5209 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5210 -	}
110.5211 -	break;
110.5212 -	case 0x654:
110.5213 -	case 0x65c:
110.5214 -	// T versions are the same
110.5215 -	case 0x674:
110.5216 -	case 0x67c:
110.5217 -	{
110.5218 -		// LDRB Rd, [Rn], -Rm, ASR #
110.5219 -		int shift = (opcode >> 7) & 31;
110.5220 -		int offset;
110.5221 -		if (shift)
110.5222 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5223 -		else if (reg[opcode & 15].I & 0x80000000)
110.5224 -			offset = 0xFFFFFFFF;
110.5225 -		else
110.5226 -			offset = 0;
110.5227 -		int dest	= (opcode >> 12) & 15;
110.5228 -		int base	= (opcode >> 16) & 15;
110.5229 -		u32 address = reg[base].I;
110.5230 -		reg[dest].I = CPUReadByte(address);
110.5231 -		if (dest != base)
110.5232 -			reg[base].I = address - offset;
110.5233 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5234 -	}
110.5235 -	break;
110.5236 -	case 0x656:
110.5237 -	case 0x65e:
110.5238 -	// T versions are the same
110.5239 -	case 0x676:
110.5240 -	case 0x67e:
110.5241 -	{
110.5242 -		// LDRB Rd, [Rn], -Rm, ROR #
110.5243 -		int shift = (opcode >> 7) & 31;
110.5244 -		u32 value = reg[opcode & 15].I;
110.5245 -		if (shift)
110.5246 -		{
110.5247 -			ROR_VALUE;
110.5248 -		}
110.5249 -		else
110.5250 -		{
110.5251 -			RCR_VALUE;
110.5252 -		}
110.5253 -		int dest	= (opcode >> 12) & 15;
110.5254 -		int base	= (opcode >> 16) & 15;
110.5255 -		u32 address = reg[base].I;
110.5256 -		reg[dest].I = CPUReadByte(address);
110.5257 -		if (dest != base)
110.5258 -			reg[base].I = address - value;
110.5259 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5260 -	}
110.5261 -	break;
110.5262 -	case 0x6d0:
110.5263 -	case 0x6d8:
110.5264 -	// T versions are the same
110.5265 -	case 0x6f0:
110.5266 -	case 0x6f8:
110.5267 -	{
110.5268 -		// LDRB Rd, [Rn], Rm, LSL #
110.5269 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5270 -		int dest	= (opcode >> 12) & 15;
110.5271 -		int base	= (opcode >> 16) & 15;
110.5272 -		u32 address = reg[base].I;
110.5273 -		reg[dest].I = CPUReadByte(address);
110.5274 -		if (dest != base)
110.5275 -			reg[base].I = address + offset;
110.5276 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5277 -	}
110.5278 -	break;
110.5279 -	case 0x6d2:
110.5280 -	case 0x6da:
110.5281 -	// T versions are the same
110.5282 -	case 0x6f2:
110.5283 -	case 0x6fa:
110.5284 -	{
110.5285 -		// LDRB Rd, [Rn], Rm, LSR #
110.5286 -		int shift	= (opcode >> 7) & 31;
110.5287 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5288 -		int dest	= (opcode >> 12) & 15;
110.5289 -		int base	= (opcode >> 16) & 15;
110.5290 -		u32 address = reg[base].I;
110.5291 -		reg[dest].I = CPUReadByte(address);
110.5292 -		if (dest != base)
110.5293 -			reg[base].I = address + offset;
110.5294 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5295 -	}
110.5296 -	break;
110.5297 -	case 0x6d4:
110.5298 -	case 0x6dc:
110.5299 -	// T versions are the same
110.5300 -	case 0x6f4:
110.5301 -	case 0x6fc:
110.5302 -	{
110.5303 -		// LDRB Rd, [Rn], Rm, ASR #
110.5304 -		int shift = (opcode >> 7) & 31;
110.5305 -		int offset;
110.5306 -		if (shift)
110.5307 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5308 -		else if (reg[opcode & 15].I & 0x80000000)
110.5309 -			offset = 0xFFFFFFFF;
110.5310 -		else
110.5311 -			offset = 0;
110.5312 -		int dest	= (opcode >> 12) & 15;
110.5313 -		int base	= (opcode >> 16) & 15;
110.5314 -		u32 address = reg[base].I;
110.5315 -		reg[dest].I = CPUReadByte(address);
110.5316 -		if (dest != base)
110.5317 -			reg[base].I = address + offset;
110.5318 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5319 -	}
110.5320 -	break;
110.5321 -	case 0x6d6:
110.5322 -	case 0x6de:
110.5323 -	// T versions are the same
110.5324 -	case 0x6f6:
110.5325 -	case 0x6fe:
110.5326 -	{
110.5327 -		// LDRB Rd, [Rn], Rm, ROR #
110.5328 -		int shift = (opcode >> 7) & 31;
110.5329 -		u32 value = reg[opcode & 15].I;
110.5330 -		if (shift)
110.5331 -		{
110.5332 -			ROR_VALUE;
110.5333 -		}
110.5334 -		else
110.5335 -		{
110.5336 -			RCR_VALUE;
110.5337 -		}
110.5338 -		int dest	= (opcode >> 12) & 15;
110.5339 -		int base	= (opcode >> 16) & 15;
110.5340 -		u32 address = reg[base].I;
110.5341 -		reg[dest].I = CPUReadByte(address);
110.5342 -		if (dest != base)
110.5343 -			reg[base].I = address + value;
110.5344 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5345 -	}
110.5346 -	break;
110.5347 -	case 0x750:
110.5348 -	case 0x758:
110.5349 -	{
110.5350 -		// LDRB Rd, [Rn, -Rm, LSL #]
110.5351 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5352 -		int dest	= (opcode >> 12) & 15;
110.5353 -		int base	= (opcode >> 16) & 15;
110.5354 -		u32 address = reg[base].I - offset;
110.5355 -		reg[dest].I = CPUReadByte(address);
110.5356 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5357 -	}
110.5358 -	break;
110.5359 -	case 0x752:
110.5360 -	case 0x75a:
110.5361 -	{
110.5362 -		// LDRB Rd, [Rn, -Rm, LSR #]
110.5363 -		int shift	= (opcode >> 7) & 31;
110.5364 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5365 -		int dest	= (opcode >> 12) & 15;
110.5366 -		int base	= (opcode >> 16) & 15;
110.5367 -		u32 address = reg[base].I - offset;
110.5368 -		reg[dest].I = CPUReadByte(address);
110.5369 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5370 -	}
110.5371 -	break;
110.5372 -	case 0x754:
110.5373 -	case 0x75c:
110.5374 -	{
110.5375 -		// LDRB Rd, [Rn, -Rm, ASR #]
110.5376 -		int shift = (opcode >> 7) & 31;
110.5377 -		int offset;
110.5378 -		if (shift)
110.5379 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5380 -		else if (reg[opcode & 15].I & 0x80000000)
110.5381 -			offset = 0xFFFFFFFF;
110.5382 -		else
110.5383 -			offset = 0;
110.5384 -		int dest	= (opcode >> 12) & 15;
110.5385 -		int base	= (opcode >> 16) & 15;
110.5386 -		u32 address = reg[base].I - offset;
110.5387 -		reg[dest].I = CPUReadByte(address);
110.5388 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5389 -	}
110.5390 -	break;
110.5391 -	case 0x756:
110.5392 -	case 0x75e:
110.5393 -	{
110.5394 -		// LDRB Rd, [Rn, -Rm, ROR #]
110.5395 -		int shift = (opcode >> 7) & 31;
110.5396 -		u32 value = reg[opcode & 15].I;
110.5397 -		if (shift)
110.5398 -		{
110.5399 -			ROR_VALUE;
110.5400 -		}
110.5401 -		else
110.5402 -		{
110.5403 -			RCR_VALUE;
110.5404 -		}
110.5405 -		int dest	= (opcode >> 12) & 15;
110.5406 -		int base	= (opcode >> 16) & 15;
110.5407 -		u32 address = reg[base].I - value;
110.5408 -		reg[dest].I = CPUReadByte(address);
110.5409 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5410 -	}
110.5411 -	break;
110.5412 -	case 0x770:
110.5413 -	case 0x778:
110.5414 -	{
110.5415 -		// LDRB Rd, [Rn, -Rm, LSL #]!
110.5416 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5417 -		int dest	= (opcode >> 12) & 15;
110.5418 -		int base	= (opcode >> 16) & 15;
110.5419 -		u32 address = reg[base].I - offset;
110.5420 -		reg[dest].I = CPUReadByte(address);
110.5421 -		if (dest != base)
110.5422 -			reg[base].I = address;
110.5423 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5424 -	}
110.5425 -	break;
110.5426 -	case 0x772:
110.5427 -	case 0x77a:
110.5428 -	{
110.5429 -		// LDRB Rd, [Rn, -Rm, LSR #]!
110.5430 -		int shift	= (opcode >> 7) & 31;
110.5431 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5432 -		int dest	= (opcode >> 12) & 15;
110.5433 -		int base	= (opcode >> 16) & 15;
110.5434 -		u32 address = reg[base].I - offset;
110.5435 -		reg[dest].I = CPUReadByte(address);
110.5436 -		if (dest != base)
110.5437 -			reg[base].I = address;
110.5438 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5439 -	}
110.5440 -	break;
110.5441 -	case 0x774:
110.5442 -	case 0x77c:
110.5443 -	{
110.5444 -		// LDRB Rd, [Rn, -Rm, ASR #]!
110.5445 -		int shift = (opcode >> 7) & 31;
110.5446 -		int offset;
110.5447 -		if (shift)
110.5448 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5449 -		else if (reg[opcode & 15].I & 0x80000000)
110.5450 -			offset = 0xFFFFFFFF;
110.5451 -		else
110.5452 -			offset = 0;
110.5453 -		int dest	= (opcode >> 12) & 15;
110.5454 -		int base	= (opcode >> 16) & 15;
110.5455 -		u32 address = reg[base].I - offset;
110.5456 -		reg[dest].I = CPUReadByte(address);
110.5457 -		if (dest != base)
110.5458 -			reg[base].I = address;
110.5459 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5460 -	}
110.5461 -	break;
110.5462 -	case 0x776:
110.5463 -	case 0x77e:
110.5464 -	{
110.5465 -		// LDRB Rd, [Rn, -Rm, ROR #]!
110.5466 -		int shift = (opcode >> 7) & 31;
110.5467 -		u32 value = reg[opcode & 15].I;
110.5468 -		if (shift)
110.5469 -		{
110.5470 -			ROR_VALUE;
110.5471 -		}
110.5472 -		else
110.5473 -		{
110.5474 -			RCR_VALUE;
110.5475 -		}
110.5476 -		int dest	= (opcode >> 12) & 15;
110.5477 -		int base	= (opcode >> 16) & 15;
110.5478 -		u32 address = reg[base].I - value;
110.5479 -		reg[dest].I = CPUReadByte(address);
110.5480 -		if (dest != base)
110.5481 -			reg[base].I = address;
110.5482 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5483 -	}
110.5484 -	break;
110.5485 -	case 0x7d0:
110.5486 -	case 0x7d8:
110.5487 -	{
110.5488 -		// LDRB Rd, [Rn, Rm, LSL #]
110.5489 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5490 -		int dest	= (opcode >> 12) & 15;
110.5491 -		int base	= (opcode >> 16) & 15;
110.5492 -		u32 address = reg[base].I + offset;
110.5493 -		reg[dest].I = CPUReadByte(address);
110.5494 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5495 -	}
110.5496 -	break;
110.5497 -	case 0x7d2:
110.5498 -	case 0x7da:
110.5499 -	{
110.5500 -		// LDRB Rd, [Rn, Rm, LSR #]
110.5501 -		int shift	= (opcode >> 7) & 31;
110.5502 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5503 -		int dest	= (opcode >> 12) & 15;
110.5504 -		int base	= (opcode >> 16) & 15;
110.5505 -		u32 address = reg[base].I + offset;
110.5506 -		reg[dest].I = CPUReadByte(address);
110.5507 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5508 -	}
110.5509 -	break;
110.5510 -	case 0x7d4:
110.5511 -	case 0x7dc:
110.5512 -	{
110.5513 -		// LDRB Rd, [Rn, Rm, ASR #]
110.5514 -		int shift = (opcode >> 7) & 31;
110.5515 -		int offset;
110.5516 -		if (shift)
110.5517 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5518 -		else if (reg[opcode & 15].I & 0x80000000)
110.5519 -			offset = 0xFFFFFFFF;
110.5520 -		else
110.5521 -			offset = 0;
110.5522 -		int dest	= (opcode >> 12) & 15;
110.5523 -		int base	= (opcode >> 16) & 15;
110.5524 -		u32 address = reg[base].I + offset;
110.5525 -		reg[dest].I = CPUReadByte(address);
110.5526 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5527 -	}
110.5528 -	break;
110.5529 -	case 0x7d6:
110.5530 -	case 0x7de:
110.5531 -	{
110.5532 -		// LDRB Rd, [Rn, Rm, ROR #]
110.5533 -		int shift = (opcode >> 7) & 31;
110.5534 -		u32 value = reg[opcode & 15].I;
110.5535 -		if (shift)
110.5536 -		{
110.5537 -			ROR_VALUE;
110.5538 -		}
110.5539 -		else
110.5540 -		{
110.5541 -			RCR_VALUE;
110.5542 -		}
110.5543 -		int dest	= (opcode >> 12) & 15;
110.5544 -		int base	= (opcode >> 16) & 15;
110.5545 -		u32 address = reg[base].I + value;
110.5546 -		reg[dest].I = CPUReadByte(address);
110.5547 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5548 -	}
110.5549 -	break;
110.5550 -	case 0x7f0:
110.5551 -	case 0x7f8:
110.5552 -	{
110.5553 -		// LDRB Rd, [Rn, Rm, LSL #]!
110.5554 -		int offset	= reg[opcode & 15].I << ((opcode >> 7) & 31);
110.5555 -		int dest	= (opcode >> 12) & 15;
110.5556 -		int base	= (opcode >> 16) & 15;
110.5557 -		u32 address = reg[base].I + offset;
110.5558 -		reg[dest].I = CPUReadByte(address);
110.5559 -		if (dest != base)
110.5560 -			reg[base].I = address;
110.5561 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5562 -	}
110.5563 -	break;
110.5564 -	case 0x7f2:
110.5565 -	case 0x7fa:
110.5566 -	{
110.5567 -		// LDRB Rd, [Rn, Rm, LSR #]!
110.5568 -		int shift	= (opcode >> 7) & 31;
110.5569 -		int offset	= shift ? reg[opcode & 15].I >> shift : 0;
110.5570 -		int dest	= (opcode >> 12) & 15;
110.5571 -		int base	= (opcode >> 16) & 15;
110.5572 -		u32 address = reg[base].I + offset;
110.5573 -		reg[dest].I = CPUReadByte(address);
110.5574 -		if (dest != base)
110.5575 -			reg[base].I = address;
110.5576 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5577 -	}
110.5578 -	break;
110.5579 -	case 0x7f4:
110.5580 -	case 0x7fc:
110.5581 -	{
110.5582 -		// LDRB Rd, [Rn, Rm, ASR #]!
110.5583 -		int shift = (opcode >> 7) & 31;
110.5584 -		int offset;
110.5585 -		if (shift)
110.5586 -			offset = (int)((s32)reg[opcode & 15].I >> shift);
110.5587 -		else if (reg[opcode & 15].I & 0x80000000)
110.5588 -			offset = 0xFFFFFFFF;
110.5589 -		else
110.5590 -			offset = 0;
110.5591 -		int dest	= (opcode >> 12) & 15;
110.5592 -		int base	= (opcode >> 16) & 15;
110.5593 -		u32 address = reg[base].I + offset;
110.5594 -		reg[dest].I = CPUReadByte(address);
110.5595 -		if (dest != base)
110.5596 -			reg[base].I = address;
110.5597 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5598 -	}
110.5599 -	break;
110.5600 -	case 0x7f6:
110.5601 -	case 0x7fe:
110.5602 -	{
110.5603 -		// LDRB Rd, [Rn, Rm, ROR #]!
110.5604 -		int shift = (opcode >> 7) & 31;
110.5605 -		u32 value = reg[opcode & 15].I;
110.5606 -		if (shift)
110.5607 -		{
110.5608 -			ROR_VALUE;
110.5609 -		}
110.5610 -		else
110.5611 -		{
110.5612 -			RCR_VALUE;
110.5613 -		}
110.5614 -		int dest	= (opcode >> 12) & 15;
110.5615 -		int base	= (opcode >> 16) & 15;
110.5616 -		u32 address = reg[base].I + value;
110.5617 -		reg[dest].I = CPUReadByte(address);
110.5618 -		if (dest != base)
110.5619 -			reg[base].I = address;
110.5620 -		clockTicks += 3 + CPUUpdateTicksAccess16(address);
110.5621 -	}
110.5622 -	break;
110.5623 -#define STMW_REG(val, num) \
110.5624 -	if (opcode & (val)) { \
110.5625 -		CPUWriteMemory(address, reg[(num)].I); \
110.5626 -		if (!offset) { \
110.5627 -			reg[base].I = temp; \
110.5628 -			clockTicks += 1 + CPUUpdateTicksAccess32(address); \
110.5629 -			offset		= 1; \
110.5630 -		} else { \
110.5631 -			clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); \
110.5632 -		} \
110.5633 -		address += 4; \
110.5634 -	}
110.5635 -#define STM_REG(val, num) \
110.5636 -	if (opcode & (val)) { \
110.5637 -		CPUWriteMemory(address, reg[(num)].I); \
110.5638 -		if (!offset) { \
110.5639 -			clockTicks += 1 + CPUUpdateTicksAccess32(address); \
110.5640 -			offset		= 1; \
110.5641 -		} else { \
110.5642 -			clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); \
110.5643 -		} \
110.5644 -		address += 4; \
110.5645 -	}
110.5646 -
110.5647 -		CASE_16(0x800)
110.5648 -		// STMDA Rn, {Rlist}
110.5649 -		{
110.5650 -			int base = (opcode & 0x000F0000) >> 16;
110.5651 -			u32 temp = reg[base].I -
110.5652 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.5653 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.5654 -			clockTicks += 2;
110.5655 -			int offset = 0;
110.5656 -			STM_REG(1, 0);
110.5657 -			STM_REG(2, 1);
110.5658 -			STM_REG(4, 2);
110.5659 -			STM_REG(8, 3);
110.5660 -			STM_REG(16, 4);
110.5661 -			STM_REG(32, 5);
110.5662 -			STM_REG(64, 6);
110.5663 -			STM_REG(128, 7);
110.5664 -			STM_REG(256, 8);
110.5665 -			STM_REG(512, 9);
110.5666 -			STM_REG(1024, 10);
110.5667 -			STM_REG(2048, 11);
110.5668 -			STM_REG(4096, 12);
110.5669 -			STM_REG(8192, 13);
110.5670 -			STM_REG(16384, 14);
110.5671 -			if (opcode & 32768)
110.5672 -			{
110.5673 -				CPUWriteMemory(address, reg[15].I + 4);
110.5674 -				if (!offset)
110.5675 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5676 -				else
110.5677 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5678 -			}
110.5679 -		}
110.5680 -		break;
110.5681 -		CASE_16(0x820)
110.5682 -		{
110.5683 -			// STMDA Rn!, {Rlist}
110.5684 -			int base = (opcode & 0x000F0000) >> 16;
110.5685 -			u32 temp = reg[base].I -
110.5686 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.5687 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.5688 -			clockTicks += 2;
110.5689 -			int offset = 0;
110.5690 -
110.5691 -			STMW_REG(1, 0);
110.5692 -			STMW_REG(2, 1);
110.5693 -			STMW_REG(4, 2);
110.5694 -			STMW_REG(8, 3);
110.5695 -			STMW_REG(16, 4);
110.5696 -			STMW_REG(32, 5);
110.5697 -			STMW_REG(64, 6);
110.5698 -			STMW_REG(128, 7);
110.5699 -			STMW_REG(256, 8);
110.5700 -			STMW_REG(512, 9);
110.5701 -			STMW_REG(1024, 10);
110.5702 -			STMW_REG(2048, 11);
110.5703 -			STMW_REG(4096, 12);
110.5704 -			STMW_REG(8192, 13);
110.5705 -			STMW_REG(16384, 14);
110.5706 -			if (opcode & 32768)
110.5707 -			{
110.5708 -				CPUWriteMemory(address, reg[15].I + 4);
110.5709 -				if (!offset)
110.5710 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5711 -				else
110.5712 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5713 -				reg[base].I = temp;
110.5714 -			}
110.5715 -		}
110.5716 -		break;
110.5717 -		CASE_16(0x840)
110.5718 -		{
110.5719 -			// STMDA Rn, {Rlist}^
110.5720 -			int base = (opcode & 0x000F0000) >> 16;
110.5721 -			u32 temp = reg[base].I -
110.5722 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.5723 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.5724 -			clockTicks += 2;
110.5725 -			int offset = 0;
110.5726 -
110.5727 -			STM_REG(1, 0);
110.5728 -			STM_REG(2, 1);
110.5729 -			STM_REG(4, 2);
110.5730 -			STM_REG(8, 3);
110.5731 -			STM_REG(16, 4);
110.5732 -			STM_REG(32, 5);
110.5733 -			STM_REG(64, 6);
110.5734 -			STM_REG(128, 7);
110.5735 -
110.5736 -			if (armMode == 0x11)
110.5737 -			{
110.5738 -				STM_REG(256, R8_FIQ);
110.5739 -				STM_REG(512, R9_FIQ);
110.5740 -				STM_REG(1024, R10_FIQ);
110.5741 -				STM_REG(2048, R11_FIQ);
110.5742 -				STM_REG(4096, R12_FIQ);
110.5743 -			}
110.5744 -			else
110.5745 -			{
110.5746 -				STM_REG(256, 8);
110.5747 -				STM_REG(512, 9);
110.5748 -				STM_REG(1024, 10);
110.5749 -				STM_REG(2048, 11);
110.5750 -				STM_REG(4096, 12);
110.5751 -			}
110.5752 -
110.5753 -			if (armMode != 0x10 && armMode != 0x1f)
110.5754 -			{
110.5755 -				STM_REG(8192, R13_USR);
110.5756 -				STM_REG(16384, R14_USR);
110.5757 -			}
110.5758 -			else
110.5759 -			{
110.5760 -				STM_REG(8192, 13);
110.5761 -				STM_REG(16384, 14);
110.5762 -			}
110.5763 -
110.5764 -			if (opcode & 32768)
110.5765 -			{
110.5766 -				CPUWriteMemory(address, reg[15].I + 4);
110.5767 -				if (!offset)
110.5768 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5769 -				else
110.5770 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5771 -			}
110.5772 -		}
110.5773 -		break;
110.5774 -		CASE_16(0x860)
110.5775 -		{
110.5776 -			// STMDA Rn!, {Rlist}^
110.5777 -			int base = (opcode & 0x000F0000) >> 16;
110.5778 -			u32 temp = reg[base].I -
110.5779 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.5780 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.5781 -			clockTicks += 2;
110.5782 -			int offset = 0;
110.5783 -
110.5784 -			STMW_REG(1, 0);
110.5785 -			STMW_REG(2, 1);
110.5786 -			STMW_REG(4, 2);
110.5787 -			STMW_REG(8, 3);
110.5788 -			STMW_REG(16, 4);
110.5789 -			STMW_REG(32, 5);
110.5790 -			STMW_REG(64, 6);
110.5791 -			STMW_REG(128, 7);
110.5792 -
110.5793 -			if (armMode == 0x11)
110.5794 -			{
110.5795 -				STMW_REG(256, R8_FIQ);
110.5796 -				STMW_REG(512, R9_FIQ);
110.5797 -				STMW_REG(1024, R10_FIQ);
110.5798 -				STMW_REG(2048, R11_FIQ);
110.5799 -				STMW_REG(4096, R12_FIQ);
110.5800 -			}
110.5801 -			else
110.5802 -			{
110.5803 -				STMW_REG(256, 8);
110.5804 -				STMW_REG(512, 9);
110.5805 -				STMW_REG(1024, 10);
110.5806 -				STMW_REG(2048, 11);
110.5807 -				STMW_REG(4096, 12);
110.5808 -			}
110.5809 -
110.5810 -			if (armMode != 0x10 && armMode != 0x1f)
110.5811 -			{
110.5812 -				STMW_REG(8192, R13_USR);
110.5813 -				STMW_REG(16384, R14_USR);
110.5814 -			}
110.5815 -			else
110.5816 -			{
110.5817 -				STMW_REG(8192, 13);
110.5818 -				STMW_REG(16384, 14);
110.5819 -			}
110.5820 -
110.5821 -			if (opcode & 32768)
110.5822 -			{
110.5823 -				CPUWriteMemory(address, reg[15].I + 4);
110.5824 -				if (!offset)
110.5825 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5826 -				else
110.5827 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5828 -				reg[base].I = temp;
110.5829 -			}
110.5830 -		}
110.5831 -		break;
110.5832 -
110.5833 -		CASE_16(0x880)
110.5834 -		{
110.5835 -			// STMIA Rn, {Rlist}
110.5836 -			int base	= (opcode & 0x000F0000) >> 16;
110.5837 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.5838 -			clockTicks += 2;
110.5839 -			int offset = 0;
110.5840 -			STM_REG(1, 0);
110.5841 -			STM_REG(2, 1);
110.5842 -			STM_REG(4, 2);
110.5843 -			STM_REG(8, 3);
110.5844 -			STM_REG(16, 4);
110.5845 -			STM_REG(32, 5);
110.5846 -			STM_REG(64, 6);
110.5847 -			STM_REG(128, 7);
110.5848 -			STM_REG(256, 8);
110.5849 -			STM_REG(512, 9);
110.5850 -			STM_REG(1024, 10);
110.5851 -			STM_REG(2048, 11);
110.5852 -			STM_REG(4096, 12);
110.5853 -			STM_REG(8192, 13);
110.5854 -			STM_REG(16384, 14);
110.5855 -			if (opcode & 32768)
110.5856 -			{
110.5857 -				CPUWriteMemory(address, reg[15].I + 4);
110.5858 -				if (!offset)
110.5859 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5860 -				else
110.5861 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5862 -			}
110.5863 -		}
110.5864 -		break;
110.5865 -		CASE_16(0x8a0)
110.5866 -		{
110.5867 -			// STMIA Rn!, {Rlist}
110.5868 -			int base	= (opcode & 0x000F0000) >> 16;
110.5869 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.5870 -			clockTicks += 2;
110.5871 -			int offset = 0;
110.5872 -			u32 temp   = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] +
110.5873 -			                                cpuBitsSet[(opcode >> 8) & 255]);
110.5874 -			STMW_REG(1, 0);
110.5875 -			STMW_REG(2, 1);
110.5876 -			STMW_REG(4, 2);
110.5877 -			STMW_REG(8, 3);
110.5878 -			STMW_REG(16, 4);
110.5879 -			STMW_REG(32, 5);
110.5880 -			STMW_REG(64, 6);
110.5881 -			STMW_REG(128, 7);
110.5882 -			STMW_REG(256, 8);
110.5883 -			STMW_REG(512, 9);
110.5884 -			STMW_REG(1024, 10);
110.5885 -			STMW_REG(2048, 11);
110.5886 -			STMW_REG(4096, 12);
110.5887 -			STMW_REG(8192, 13);
110.5888 -			STMW_REG(16384, 14);
110.5889 -			if (opcode & 32768)
110.5890 -			{
110.5891 -				CPUWriteMemory(address, reg[15].I + 4);
110.5892 -				if (!offset)
110.5893 -				{
110.5894 -					reg[base].I = temp;
110.5895 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5896 -				}
110.5897 -				else
110.5898 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5899 -			}
110.5900 -		}
110.5901 -		break;
110.5902 -		CASE_16(0x8c0)
110.5903 -		{
110.5904 -			// STMIA Rn, {Rlist}^
110.5905 -			int base	= (opcode & 0x000F0000) >> 16;
110.5906 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.5907 -			clockTicks += 2;
110.5908 -			int offset = 0;
110.5909 -			STM_REG(1, 0);
110.5910 -			STM_REG(2, 1);
110.5911 -			STM_REG(4, 2);
110.5912 -			STM_REG(8, 3);
110.5913 -			STM_REG(16, 4);
110.5914 -			STM_REG(32, 5);
110.5915 -			STM_REG(64, 6);
110.5916 -			STM_REG(128, 7);
110.5917 -			if (armMode == 0x11)
110.5918 -			{
110.5919 -				STM_REG(256, R8_FIQ);
110.5920 -				STM_REG(512, R9_FIQ);
110.5921 -				STM_REG(1024, R10_FIQ);
110.5922 -				STM_REG(2048, R11_FIQ);
110.5923 -				STM_REG(4096, R12_FIQ);
110.5924 -			}
110.5925 -			else
110.5926 -			{
110.5927 -				STM_REG(256, 8);
110.5928 -				STM_REG(512, 9);
110.5929 -				STM_REG(1024, 10);
110.5930 -				STM_REG(2048, 11);
110.5931 -				STM_REG(4096, 12);
110.5932 -			}
110.5933 -			if (armMode != 0x10 && armMode != 0x1f)
110.5934 -			{
110.5935 -				STM_REG(8192, R13_USR);
110.5936 -				STM_REG(16384, R14_USR);
110.5937 -			}
110.5938 -			else
110.5939 -			{
110.5940 -				STM_REG(8192, 13);
110.5941 -				STM_REG(16384, 14);
110.5942 -			}
110.5943 -			if (opcode & 32768)
110.5944 -			{
110.5945 -				CPUWriteMemory(address, reg[15].I + 4);
110.5946 -				if (!offset)
110.5947 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.5948 -				else
110.5949 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.5950 -			}
110.5951 -		}
110.5952 -		break;
110.5953 -		CASE_16(0x8e0)
110.5954 -		{
110.5955 -			// STMIA Rn!, {Rlist}^
110.5956 -			int base	= (opcode & 0x000F0000) >> 16;
110.5957 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.5958 -			clockTicks += 2;
110.5959 -			int offset = 0;
110.5960 -			u32 temp   = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] +
110.5961 -			                                cpuBitsSet[(opcode >> 8) & 255]);
110.5962 -			STMW_REG(1, 0);
110.5963 -			STMW_REG(2, 1);
110.5964 -			STMW_REG(4, 2);
110.5965 -			STMW_REG(8, 3);
110.5966 -			STMW_REG(16, 4);
110.5967 -			STMW_REG(32, 5);
110.5968 -			STMW_REG(64, 6);
110.5969 -			STMW_REG(128, 7);
110.5970 -			if (armMode == 0x11)
110.5971 -			{
110.5972 -				STMW_REG(256, R8_FIQ);
110.5973 -				STMW_REG(512, R9_FIQ);
110.5974 -				STMW_REG(1024, R10_FIQ);
110.5975 -				STMW_REG(2048, R11_FIQ);
110.5976 -				STMW_REG(4096, R12_FIQ);
110.5977 -			}
110.5978 -			else
110.5979 -			{
110.5980 -				STMW_REG(256, 8);
110.5981 -				STMW_REG(512, 9);
110.5982 -				STMW_REG(1024, 10);
110.5983 -				STMW_REG(2048, 11);
110.5984 -				STMW_REG(4096, 12);
110.5985 -			}
110.5986 -			if (armMode != 0x10 && armMode != 0x1f)
110.5987 -			{
110.5988 -				STMW_REG(8192, R13_USR);
110.5989 -				STMW_REG(16384, R14_USR);
110.5990 -			}
110.5991 -			else
110.5992 -			{
110.5993 -				STMW_REG(8192, 13);
110.5994 -				STMW_REG(16384, 14);
110.5995 -			}
110.5996 -			if (opcode & 32768)
110.5997 -			{
110.5998 -				CPUWriteMemory(address, reg[15].I + 4);
110.5999 -				if (!offset)
110.6000 -				{
110.6001 -					reg[base].I = temp;
110.6002 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6003 -				}
110.6004 -				else
110.6005 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6006 -			}
110.6007 -		}
110.6008 -		break;
110.6009 -
110.6010 -		CASE_16(0x900)
110.6011 -		{
110.6012 -			// STMDB Rn, {Rlist}
110.6013 -			int base = (opcode & 0x000F0000) >> 16;
110.6014 -			u32 temp = reg[base].I -
110.6015 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6016 -			u32 address = temp & 0xFFFFFFFC;
110.6017 -			clockTicks += 2;
110.6018 -			int offset = 0;
110.6019 -			STM_REG(1, 0);
110.6020 -			STM_REG(2, 1);
110.6021 -			STM_REG(4, 2);
110.6022 -			STM_REG(8, 3);
110.6023 -			STM_REG(16, 4);
110.6024 -			STM_REG(32, 5);
110.6025 -			STM_REG(64, 6);
110.6026 -			STM_REG(128, 7);
110.6027 -			STM_REG(256, 8);
110.6028 -			STM_REG(512, 9);
110.6029 -			STM_REG(1024, 10);
110.6030 -			STM_REG(2048, 11);
110.6031 -			STM_REG(4096, 12);
110.6032 -			STM_REG(8192, 13);
110.6033 -			STM_REG(16384, 14);
110.6034 -			if (opcode & 32768)
110.6035 -			{
110.6036 -				CPUWriteMemory(address, reg[15].I + 4);
110.6037 -				if (!offset)
110.6038 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6039 -				else
110.6040 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6041 -			}
110.6042 -		}
110.6043 -		break;
110.6044 -		CASE_16(0x920)
110.6045 -		{
110.6046 -			// STMDB Rn!, {Rlist}
110.6047 -			int base = (opcode & 0x000F0000) >> 16;
110.6048 -			u32 temp = reg[base].I -
110.6049 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6050 -			u32 address = temp & 0xFFFFFFFC;
110.6051 -			clockTicks += 2;
110.6052 -			int offset = 0;
110.6053 -
110.6054 -			STMW_REG(1, 0);
110.6055 -			STMW_REG(2, 1);
110.6056 -			STMW_REG(4, 2);
110.6057 -			STMW_REG(8, 3);
110.6058 -			STMW_REG(16, 4);
110.6059 -			STMW_REG(32, 5);
110.6060 -			STMW_REG(64, 6);
110.6061 -			STMW_REG(128, 7);
110.6062 -			STMW_REG(256, 8);
110.6063 -			STMW_REG(512, 9);
110.6064 -			STMW_REG(1024, 10);
110.6065 -			STMW_REG(2048, 11);
110.6066 -			STMW_REG(4096, 12);
110.6067 -			STMW_REG(8192, 13);
110.6068 -			STMW_REG(16384, 14);
110.6069 -			if (opcode & 32768)
110.6070 -			{
110.6071 -				CPUWriteMemory(address, reg[15].I + 4);
110.6072 -				if (!offset)
110.6073 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6074 -				else
110.6075 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6076 -				reg[base].I = temp;
110.6077 -			}
110.6078 -		}
110.6079 -		break;
110.6080 -		CASE_16(0x940)
110.6081 -		{
110.6082 -			// STMDB Rn, {Rlist}^
110.6083 -			int base = (opcode & 0x000F0000) >> 16;
110.6084 -			u32 temp = reg[base].I -
110.6085 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6086 -			u32 address = temp & 0xFFFFFFFC;
110.6087 -			clockTicks += 2;
110.6088 -			int offset = 0;
110.6089 -
110.6090 -			STM_REG(1, 0);
110.6091 -			STM_REG(2, 1);
110.6092 -			STM_REG(4, 2);
110.6093 -			STM_REG(8, 3);
110.6094 -			STM_REG(16, 4);
110.6095 -			STM_REG(32, 5);
110.6096 -			STM_REG(64, 6);
110.6097 -			STM_REG(128, 7);
110.6098 -
110.6099 -			if (armMode == 0x11)
110.6100 -			{
110.6101 -				STM_REG(256, R8_FIQ);
110.6102 -				STM_REG(512, R9_FIQ);
110.6103 -				STM_REG(1024, R10_FIQ);
110.6104 -				STM_REG(2048, R11_FIQ);
110.6105 -				STM_REG(4096, R12_FIQ);
110.6106 -			}
110.6107 -			else
110.6108 -			{
110.6109 -				STM_REG(256, 8);
110.6110 -				STM_REG(512, 9);
110.6111 -				STM_REG(1024, 10);
110.6112 -				STM_REG(2048, 11);
110.6113 -				STM_REG(4096, 12);
110.6114 -			}
110.6115 -
110.6116 -			if (armMode != 0x10 && armMode != 0x1f)
110.6117 -			{
110.6118 -				STM_REG(8192, R13_USR);
110.6119 -				STM_REG(16384, R14_USR);
110.6120 -			}
110.6121 -			else
110.6122 -			{
110.6123 -				STM_REG(8192, 13);
110.6124 -				STM_REG(16384, 14);
110.6125 -			}
110.6126 -
110.6127 -			if (opcode & 32768)
110.6128 -			{
110.6129 -				CPUWriteMemory(address, reg[15].I + 4);
110.6130 -				if (!offset)
110.6131 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6132 -				else
110.6133 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6134 -			}
110.6135 -		}
110.6136 -		break;
110.6137 -		CASE_16(0x960)
110.6138 -		{
110.6139 -			// STMDB Rn!, {Rlist}^
110.6140 -			int base = (opcode & 0x000F0000) >> 16;
110.6141 -			u32 temp = reg[base].I -
110.6142 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6143 -			u32 address = temp & 0xFFFFFFFC;
110.6144 -			clockTicks += 2;
110.6145 -			int offset = 0;
110.6146 -
110.6147 -			STMW_REG(1, 0);
110.6148 -			STMW_REG(2, 1);
110.6149 -			STMW_REG(4, 2);
110.6150 -			STMW_REG(8, 3);
110.6151 -			STMW_REG(16, 4);
110.6152 -			STMW_REG(32, 5);
110.6153 -			STMW_REG(64, 6);
110.6154 -			STMW_REG(128, 7);
110.6155 -
110.6156 -			if (armMode == 0x11)
110.6157 -			{
110.6158 -				STMW_REG(256, R8_FIQ);
110.6159 -				STMW_REG(512, R9_FIQ);
110.6160 -				STMW_REG(1024, R10_FIQ);
110.6161 -				STMW_REG(2048, R11_FIQ);
110.6162 -				STMW_REG(4096, R12_FIQ);
110.6163 -			}
110.6164 -			else
110.6165 -			{
110.6166 -				STMW_REG(256, 8);
110.6167 -				STMW_REG(512, 9);
110.6168 -				STMW_REG(1024, 10);
110.6169 -				STMW_REG(2048, 11);
110.6170 -				STMW_REG(4096, 12);
110.6171 -			}
110.6172 -
110.6173 -			if (armMode != 0x10 && armMode != 0x1f)
110.6174 -			{
110.6175 -				STMW_REG(8192, R13_USR);
110.6176 -				STMW_REG(16384, R14_USR);
110.6177 -			}
110.6178 -			else
110.6179 -			{
110.6180 -				STMW_REG(8192, 13);
110.6181 -				STMW_REG(16384, 14);
110.6182 -			}
110.6183 -
110.6184 -			if (opcode & 32768)
110.6185 -			{
110.6186 -				CPUWriteMemory(address, reg[15].I + 4);
110.6187 -				if (!offset)
110.6188 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6189 -				else
110.6190 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6191 -				reg[base].I = temp;
110.6192 -			}
110.6193 -		}
110.6194 -		break;
110.6195 -
110.6196 -		CASE_16(0x980)
110.6197 -		// STMIB Rn, {Rlist}
110.6198 -		{
110.6199 -			int base	= (opcode & 0x000F0000) >> 16;
110.6200 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.6201 -			clockTicks += 2;
110.6202 -			int offset = 0;
110.6203 -			STM_REG(1, 0);
110.6204 -			STM_REG(2, 1);
110.6205 -			STM_REG(4, 2);
110.6206 -			STM_REG(8, 3);
110.6207 -			STM_REG(16, 4);
110.6208 -			STM_REG(32, 5);
110.6209 -			STM_REG(64, 6);
110.6210 -			STM_REG(128, 7);
110.6211 -			STM_REG(256, 8);
110.6212 -			STM_REG(512, 9);
110.6213 -			STM_REG(1024, 10);
110.6214 -			STM_REG(2048, 11);
110.6215 -			STM_REG(4096, 12);
110.6216 -			STM_REG(8192, 13);
110.6217 -			STM_REG(16384, 14);
110.6218 -			if (opcode & 32768)
110.6219 -			{
110.6220 -				CPUWriteMemory(address, reg[15].I + 4);
110.6221 -				if (!offset)
110.6222 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6223 -				else
110.6224 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6225 -			}
110.6226 -		}
110.6227 -		break;
110.6228 -		CASE_16(0x9a0)
110.6229 -		{
110.6230 -			// STMIB Rn!, {Rlist}
110.6231 -			int base	= (opcode & 0x000F0000) >> 16;
110.6232 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.6233 -			clockTicks += 2;
110.6234 -			int offset = 0;
110.6235 -			u32 temp   = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] +
110.6236 -			                                cpuBitsSet[(opcode >> 8) & 255]);
110.6237 -			STMW_REG(1, 0);
110.6238 -			STMW_REG(2, 1);
110.6239 -			STMW_REG(4, 2);
110.6240 -			STMW_REG(8, 3);
110.6241 -			STMW_REG(16, 4);
110.6242 -			STMW_REG(32, 5);
110.6243 -			STMW_REG(64, 6);
110.6244 -			STMW_REG(128, 7);
110.6245 -			STMW_REG(256, 8);
110.6246 -			STMW_REG(512, 9);
110.6247 -			STMW_REG(1024, 10);
110.6248 -			STMW_REG(2048, 11);
110.6249 -			STMW_REG(4096, 12);
110.6250 -			STMW_REG(8192, 13);
110.6251 -			STMW_REG(16384, 14);
110.6252 -			if (opcode & 32768)
110.6253 -			{
110.6254 -				CPUWriteMemory(address, reg[15].I + 4);
110.6255 -				if (!offset)
110.6256 -				{
110.6257 -					reg[base].I = temp;
110.6258 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6259 -				}
110.6260 -				else
110.6261 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6262 -			}
110.6263 -		}
110.6264 -		break;
110.6265 -		CASE_16(0x9c0)
110.6266 -		{
110.6267 -			// STMIB Rn, {Rlist}^
110.6268 -			int base	= (opcode & 0x000F0000) >> 16;
110.6269 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.6270 -			clockTicks += 2;
110.6271 -			int offset = 0;
110.6272 -			STM_REG(1, 0);
110.6273 -			STM_REG(2, 1);
110.6274 -			STM_REG(4, 2);
110.6275 -			STM_REG(8, 3);
110.6276 -			STM_REG(16, 4);
110.6277 -			STM_REG(32, 5);
110.6278 -			STM_REG(64, 6);
110.6279 -			STM_REG(128, 7);
110.6280 -			if (armMode == 0x11)
110.6281 -			{
110.6282 -				STM_REG(256, R8_FIQ);
110.6283 -				STM_REG(512, R9_FIQ);
110.6284 -				STM_REG(1024, R10_FIQ);
110.6285 -				STM_REG(2048, R11_FIQ);
110.6286 -				STM_REG(4096, R12_FIQ);
110.6287 -			}
110.6288 -			else
110.6289 -			{
110.6290 -				STM_REG(256, 8);
110.6291 -				STM_REG(512, 9);
110.6292 -				STM_REG(1024, 10);
110.6293 -				STM_REG(2048, 11);
110.6294 -				STM_REG(4096, 12);
110.6295 -			}
110.6296 -			if (armMode != 0x10 && armMode != 0x1f)
110.6297 -			{
110.6298 -				STM_REG(8192, R13_USR);
110.6299 -				STM_REG(16384, R14_USR);
110.6300 -			}
110.6301 -			else
110.6302 -			{
110.6303 -				STM_REG(8192, 13);
110.6304 -				STM_REG(16384, 14);
110.6305 -			}
110.6306 -			if (opcode & 32768)
110.6307 -			{
110.6308 -				CPUWriteMemory(address, reg[15].I + 4);
110.6309 -				if (!offset)
110.6310 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6311 -				else
110.6312 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6313 -			}
110.6314 -		}
110.6315 -		break;
110.6316 -		CASE_16(0x9e0)
110.6317 -		{
110.6318 -			// STMIB Rn!, {Rlist}^
110.6319 -			int base	= (opcode & 0x000F0000) >> 16;
110.6320 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.6321 -			clockTicks += 2;
110.6322 -			int offset = 0;
110.6323 -			u32 temp   = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] +
110.6324 -			                                cpuBitsSet[(opcode >> 8) & 255]);
110.6325 -			STMW_REG(1, 0);
110.6326 -			STMW_REG(2, 1);
110.6327 -			STMW_REG(4, 2);
110.6328 -			STMW_REG(8, 3);
110.6329 -			STMW_REG(16, 4);
110.6330 -			STMW_REG(32, 5);
110.6331 -			STMW_REG(64, 6);
110.6332 -			STMW_REG(128, 7);
110.6333 -			if (armMode == 0x11)
110.6334 -			{
110.6335 -				STMW_REG(256, R8_FIQ);
110.6336 -				STMW_REG(512, R9_FIQ);
110.6337 -				STMW_REG(1024, R10_FIQ);
110.6338 -				STMW_REG(2048, R11_FIQ);
110.6339 -				STMW_REG(4096, R12_FIQ);
110.6340 -			}
110.6341 -			else
110.6342 -			{
110.6343 -				STMW_REG(256, 8);
110.6344 -				STMW_REG(512, 9);
110.6345 -				STMW_REG(1024, 10);
110.6346 -				STMW_REG(2048, 11);
110.6347 -				STMW_REG(4096, 12);
110.6348 -			}
110.6349 -			if (armMode != 0x10 && armMode != 0x1f)
110.6350 -			{
110.6351 -				STMW_REG(8192, R13_USR);
110.6352 -				STMW_REG(16384, R14_USR);
110.6353 -			}
110.6354 -			else
110.6355 -			{
110.6356 -				STMW_REG(8192, 13);
110.6357 -				STMW_REG(16384, 14);
110.6358 -			}
110.6359 -			if (opcode & 32768)
110.6360 -			{
110.6361 -				CPUWriteMemory(address, reg[15].I + 4);
110.6362 -				if (!offset)
110.6363 -				{
110.6364 -					reg[base].I = temp;
110.6365 -					clockTicks += 1 + CPUUpdateTicksAccess32(address);
110.6366 -				}
110.6367 -				else
110.6368 -					clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);
110.6369 -			}
110.6370 -		}
110.6371 -		break;
110.6372 -
110.6373 -#define LDM_REG(val, num) \
110.6374 -	if (opcode & (val)) { \
110.6375 -		reg[(num)].I = CPUReadMemory(address); \
110.6376 -		if (offset) \
110.6377 -			clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); \
110.6378 -		else { \
110.6379 -			clockTicks += 1 + CPUUpdateTicksAccess32(address); \
110.6380 -			offset		= 1; \
110.6381 -		} \
110.6382 -		address += 4; \
110.6383 -	}
110.6384 -
110.6385 -		CASE_16(0x810)
110.6386 -		{
110.6387 -			// LDMDA Rn, {Rlist}
110.6388 -			int base = (opcode & 0x000F0000) >> 16;
110.6389 -			u32 temp = reg[base].I -
110.6390 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6391 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.6392 -			clockTicks += 2;
110.6393 -			int offset = 0;
110.6394 -			LDM_REG(1, 0);
110.6395 -			LDM_REG(2, 1);
110.6396 -			LDM_REG(4, 2);
110.6397 -			LDM_REG(8, 3);
110.6398 -			LDM_REG(16, 4);
110.6399 -			LDM_REG(32, 5);
110.6400 -			LDM_REG(64, 6);
110.6401 -			LDM_REG(128, 7);
110.6402 -			LDM_REG(256, 8);
110.6403 -			LDM_REG(512, 9);
110.6404 -			LDM_REG(1024, 10);
110.6405 -			LDM_REG(2048, 11);
110.6406 -			LDM_REG(4096, 12);
110.6407 -			LDM_REG(8192, 13);
110.6408 -			LDM_REG(16384, 14);
110.6409 -			if (opcode & 32768)
110.6410 -			{
110.6411 -				reg[15].I = CPUReadMemory(address);
110.6412 -				if (!offset)
110.6413 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6414 -				else
110.6415 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6416 -				armNextPC  = reg[15].I;
110.6417 -				reg[15].I += 4;
110.6418 -			}
110.6419 -		}
110.6420 -		break;
110.6421 -		CASE_16(0x830)
110.6422 -		{
110.6423 -			// LDMDA Rn!, {Rlist}
110.6424 -			int base = (opcode & 0x000F0000) >> 16;
110.6425 -			u32 temp = reg[base].I -
110.6426 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6427 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.6428 -			clockTicks += 2;
110.6429 -			int offset = 0;
110.6430 -			LDM_REG(1, 0);
110.6431 -			LDM_REG(2, 1);
110.6432 -			LDM_REG(4, 2);
110.6433 -			LDM_REG(8, 3);
110.6434 -			LDM_REG(16, 4);
110.6435 -			LDM_REG(32, 5);
110.6436 -			LDM_REG(64, 6);
110.6437 -			LDM_REG(128, 7);
110.6438 -			LDM_REG(256, 8);
110.6439 -			LDM_REG(512, 9);
110.6440 -			LDM_REG(1024, 10);
110.6441 -			LDM_REG(2048, 11);
110.6442 -			LDM_REG(4096, 12);
110.6443 -			LDM_REG(8192, 13);
110.6444 -			LDM_REG(16384, 14);
110.6445 -			if (opcode & 32768)
110.6446 -			{
110.6447 -				reg[15].I = CPUReadMemory(address);
110.6448 -				if (!offset)
110.6449 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6450 -				else
110.6451 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6452 -				armNextPC  = reg[15].I;
110.6453 -				reg[15].I += 4;
110.6454 -			}
110.6455 -			if (!(opcode & (1 << base)))
110.6456 -				reg[base].I = temp;
110.6457 -		}
110.6458 -		break;
110.6459 -		CASE_16(0x850)
110.6460 -		{
110.6461 -			// LDMDA Rn, {Rlist}^
110.6462 -			int base = (opcode & 0x000F0000) >> 16;
110.6463 -			u32 temp = reg[base].I -
110.6464 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6465 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.6466 -			clockTicks += 2;
110.6467 -			int offset = 0;
110.6468 -			if (opcode & 0x8000)
110.6469 -			{
110.6470 -				LDM_REG(1, 0);
110.6471 -				LDM_REG(2, 1);
110.6472 -				LDM_REG(4, 2);
110.6473 -				LDM_REG(8, 3);
110.6474 -				LDM_REG(16, 4);
110.6475 -				LDM_REG(32, 5);
110.6476 -				LDM_REG(64, 6);
110.6477 -				LDM_REG(128, 7);
110.6478 -				LDM_REG(256, 8);
110.6479 -				LDM_REG(512, 9);
110.6480 -				LDM_REG(1024, 10);
110.6481 -				LDM_REG(2048, 11);
110.6482 -				LDM_REG(4096, 12);
110.6483 -				LDM_REG(8192, 13);
110.6484 -				LDM_REG(16384, 14);
110.6485 -
110.6486 -				reg[15].I = CPUReadMemory(address);
110.6487 -				if (!offset)
110.6488 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6489 -				else
110.6490 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6491 -
110.6492 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.6493 -				if (armState)
110.6494 -				{
110.6495 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.6496 -					reg[15].I = armNextPC + 4;
110.6497 -				}
110.6498 -				else
110.6499 -				{
110.6500 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.6501 -					reg[15].I = armNextPC + 2;
110.6502 -				}
110.6503 -			}
110.6504 -			else
110.6505 -			{
110.6506 -				LDM_REG(1, 0);
110.6507 -				LDM_REG(2, 1);
110.6508 -				LDM_REG(4, 2);
110.6509 -				LDM_REG(8, 3);
110.6510 -				LDM_REG(16, 4);
110.6511 -				LDM_REG(32, 5);
110.6512 -				LDM_REG(64, 6);
110.6513 -				LDM_REG(128, 7);
110.6514 -
110.6515 -				if (armMode == 0x11)
110.6516 -				{
110.6517 -					LDM_REG(256, R8_FIQ);
110.6518 -					LDM_REG(512, R9_FIQ);
110.6519 -					LDM_REG(1024, R10_FIQ);
110.6520 -					LDM_REG(2048, R11_FIQ);
110.6521 -					LDM_REG(4096, R12_FIQ);
110.6522 -				}
110.6523 -				else
110.6524 -				{
110.6525 -					LDM_REG(256, 8);
110.6526 -					LDM_REG(512, 9);
110.6527 -					LDM_REG(1024, 10);
110.6528 -					LDM_REG(2048, 11);
110.6529 -					LDM_REG(4096, 12);
110.6530 -				}
110.6531 -
110.6532 -				if (armMode != 0x10 && armMode != 0x1f)
110.6533 -				{
110.6534 -					LDM_REG(8192, R13_USR);
110.6535 -					LDM_REG(16384, R14_USR);
110.6536 -				}
110.6537 -				else
110.6538 -				{
110.6539 -					LDM_REG(8192, 13);
110.6540 -					LDM_REG(16384, 14);
110.6541 -				}
110.6542 -			}
110.6543 -		}
110.6544 -		break;
110.6545 -		CASE_16(0x870)
110.6546 -		{
110.6547 -			// LDMDA Rn!, {Rlist}^
110.6548 -			int base = (opcode & 0x000F0000) >> 16;
110.6549 -			u32 temp = reg[base].I -
110.6550 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6551 -			u32 address = (temp + 4) & 0xFFFFFFFC;
110.6552 -			clockTicks += 2;
110.6553 -			int offset = 0;
110.6554 -			if (opcode & 0x8000)
110.6555 -			{
110.6556 -				LDM_REG(1, 0);
110.6557 -				LDM_REG(2, 1);
110.6558 -				LDM_REG(4, 2);
110.6559 -				LDM_REG(8, 3);
110.6560 -				LDM_REG(16, 4);
110.6561 -				LDM_REG(32, 5);
110.6562 -				LDM_REG(64, 6);
110.6563 -				LDM_REG(128, 7);
110.6564 -				LDM_REG(256, 8);
110.6565 -				LDM_REG(512, 9);
110.6566 -				LDM_REG(1024, 10);
110.6567 -				LDM_REG(2048, 11);
110.6568 -				LDM_REG(4096, 12);
110.6569 -				LDM_REG(8192, 13);
110.6570 -				LDM_REG(16384, 14);
110.6571 -
110.6572 -				reg[15].I = CPUReadMemory(address);
110.6573 -				if (!offset)
110.6574 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6575 -				else
110.6576 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6577 -
110.6578 -				if (!(opcode & (1 << base)))
110.6579 -					reg[base].I = temp;
110.6580 -
110.6581 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.6582 -				if (armState)
110.6583 -				{
110.6584 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.6585 -					reg[15].I = armNextPC + 4;
110.6586 -				}
110.6587 -				else
110.6588 -				{
110.6589 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.6590 -					reg[15].I = armNextPC + 2;
110.6591 -				}
110.6592 -			}
110.6593 -			else
110.6594 -			{
110.6595 -				LDM_REG(1, 0);
110.6596 -				LDM_REG(2, 1);
110.6597 -				LDM_REG(4, 2);
110.6598 -				LDM_REG(8, 3);
110.6599 -				LDM_REG(16, 4);
110.6600 -				LDM_REG(32, 5);
110.6601 -				LDM_REG(64, 6);
110.6602 -				LDM_REG(128, 7);
110.6603 -
110.6604 -				if (armMode == 0x11)
110.6605 -				{
110.6606 -					LDM_REG(256, R8_FIQ);
110.6607 -					LDM_REG(512, R9_FIQ);
110.6608 -					LDM_REG(1024, R10_FIQ);
110.6609 -					LDM_REG(2048, R11_FIQ);
110.6610 -					LDM_REG(4096, R12_FIQ);
110.6611 -				}
110.6612 -				else
110.6613 -				{
110.6614 -					LDM_REG(256, 8);
110.6615 -					LDM_REG(512, 9);
110.6616 -					LDM_REG(1024, 10);
110.6617 -					LDM_REG(2048, 11);
110.6618 -					LDM_REG(4096, 12);
110.6619 -				}
110.6620 -
110.6621 -				if (armMode != 0x10 && armMode != 0x1f)
110.6622 -				{
110.6623 -					LDM_REG(8192, R13_USR);
110.6624 -					LDM_REG(16384, R14_USR);
110.6625 -				}
110.6626 -				else
110.6627 -				{
110.6628 -					LDM_REG(8192, 13);
110.6629 -					LDM_REG(16384, 14);
110.6630 -				}
110.6631 -
110.6632 -				if (!(opcode & (1 << base)))
110.6633 -					reg[base].I = temp;
110.6634 -			}
110.6635 -		}
110.6636 -		break;
110.6637 -
110.6638 -		CASE_16(0x890)
110.6639 -		{
110.6640 -			// LDMIA Rn, {Rlist}
110.6641 -			int base	= (opcode & 0x000F0000) >> 16;
110.6642 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.6643 -			clockTicks += 2;
110.6644 -			int offset = 0;
110.6645 -			LDM_REG(1, 0);
110.6646 -			LDM_REG(2, 1);
110.6647 -			LDM_REG(4, 2);
110.6648 -			LDM_REG(8, 3);
110.6649 -			LDM_REG(16, 4);
110.6650 -			LDM_REG(32, 5);
110.6651 -			LDM_REG(64, 6);
110.6652 -			LDM_REG(128, 7);
110.6653 -			LDM_REG(256, 8);
110.6654 -			LDM_REG(512, 9);
110.6655 -			LDM_REG(1024, 10);
110.6656 -			LDM_REG(2048, 11);
110.6657 -			LDM_REG(4096, 12);
110.6658 -			LDM_REG(8192, 13);
110.6659 -			LDM_REG(16384, 14);
110.6660 -			if (opcode & 32768)
110.6661 -			{
110.6662 -				reg[15].I = CPUReadMemory(address);
110.6663 -				if (!offset)
110.6664 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6665 -				else
110.6666 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6667 -				armNextPC  = reg[15].I;
110.6668 -				reg[15].I += 4;
110.6669 -			}
110.6670 -		}
110.6671 -		break;
110.6672 -		CASE_16(0x8b0)
110.6673 -		{
110.6674 -			// LDMIA Rn!, {Rlist}
110.6675 -			int base = (opcode & 0x000F0000) >> 16;
110.6676 -			u32 temp = reg[base].I +
110.6677 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6678 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.6679 -			clockTicks += 2;
110.6680 -			int offset = 0;
110.6681 -			LDM_REG(1, 0);
110.6682 -			LDM_REG(2, 1);
110.6683 -			LDM_REG(4, 2);
110.6684 -			LDM_REG(8, 3);
110.6685 -			LDM_REG(16, 4);
110.6686 -			LDM_REG(32, 5);
110.6687 -			LDM_REG(64, 6);
110.6688 -			LDM_REG(128, 7);
110.6689 -			LDM_REG(256, 8);
110.6690 -			LDM_REG(512, 9);
110.6691 -			LDM_REG(1024, 10);
110.6692 -			LDM_REG(2048, 11);
110.6693 -			LDM_REG(4096, 12);
110.6694 -			LDM_REG(8192, 13);
110.6695 -			LDM_REG(16384, 14);
110.6696 -			if (opcode & 32768)
110.6697 -			{
110.6698 -				reg[15].I = CPUReadMemory(address);
110.6699 -				if (!offset)
110.6700 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6701 -				else
110.6702 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6703 -				armNextPC  = reg[15].I;
110.6704 -				reg[15].I += 4;
110.6705 -			}
110.6706 -			if (!(opcode & (1 << base)))
110.6707 -				reg[base].I = temp;
110.6708 -		}
110.6709 -		break;
110.6710 -		CASE_16(0x8d0)
110.6711 -		{
110.6712 -			// LDMIA Rn, {Rlist}^
110.6713 -			int base	= (opcode & 0x000F0000) >> 16;
110.6714 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.6715 -			clockTicks += 2;
110.6716 -			int offset = 0;
110.6717 -			if (opcode & 0x8000)
110.6718 -			{
110.6719 -				LDM_REG(1, 0);
110.6720 -				LDM_REG(2, 1);
110.6721 -				LDM_REG(4, 2);
110.6722 -				LDM_REG(8, 3);
110.6723 -				LDM_REG(16, 4);
110.6724 -				LDM_REG(32, 5);
110.6725 -				LDM_REG(64, 6);
110.6726 -				LDM_REG(128, 7);
110.6727 -				LDM_REG(256, 8);
110.6728 -				LDM_REG(512, 9);
110.6729 -				LDM_REG(1024, 10);
110.6730 -				LDM_REG(2048, 11);
110.6731 -				LDM_REG(4096, 12);
110.6732 -				LDM_REG(8192, 13);
110.6733 -				LDM_REG(16384, 14);
110.6734 -
110.6735 -				reg[15].I = CPUReadMemory(address);
110.6736 -				if (!offset)
110.6737 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6738 -				else
110.6739 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6740 -
110.6741 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.6742 -				if (armState)
110.6743 -				{
110.6744 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.6745 -					reg[15].I = armNextPC + 4;
110.6746 -				}
110.6747 -				else
110.6748 -				{
110.6749 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.6750 -					reg[15].I = armNextPC + 2;
110.6751 -				}
110.6752 -			}
110.6753 -			else
110.6754 -			{
110.6755 -				LDM_REG(1, 0);
110.6756 -				LDM_REG(2, 1);
110.6757 -				LDM_REG(4, 2);
110.6758 -				LDM_REG(8, 3);
110.6759 -				LDM_REG(16, 4);
110.6760 -				LDM_REG(32, 5);
110.6761 -				LDM_REG(64, 6);
110.6762 -				LDM_REG(128, 7);
110.6763 -
110.6764 -				if (armMode == 0x11)
110.6765 -				{
110.6766 -					LDM_REG(256, R8_FIQ);
110.6767 -					LDM_REG(512, R9_FIQ);
110.6768 -					LDM_REG(1024, R10_FIQ);
110.6769 -					LDM_REG(2048, R11_FIQ);
110.6770 -					LDM_REG(4096, R12_FIQ);
110.6771 -				}
110.6772 -				else
110.6773 -				{
110.6774 -					LDM_REG(256, 8);
110.6775 -					LDM_REG(512, 9);
110.6776 -					LDM_REG(1024, 10);
110.6777 -					LDM_REG(2048, 11);
110.6778 -					LDM_REG(4096, 12);
110.6779 -				}
110.6780 -
110.6781 -				if (armMode != 0x10 && armMode != 0x1f)
110.6782 -				{
110.6783 -					LDM_REG(8192, R13_USR);
110.6784 -					LDM_REG(16384, R14_USR);
110.6785 -				}
110.6786 -				else
110.6787 -				{
110.6788 -					LDM_REG(8192, 13);
110.6789 -					LDM_REG(16384, 14);
110.6790 -				}
110.6791 -			}
110.6792 -		}
110.6793 -		break;
110.6794 -		CASE_16(0x8f0)
110.6795 -		{
110.6796 -			// LDMIA Rn!, {Rlist}^
110.6797 -			int base = (opcode & 0x000F0000) >> 16;
110.6798 -			u32 temp = reg[base].I +
110.6799 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6800 -			u32 address = reg[base].I & 0xFFFFFFFC;
110.6801 -			clockTicks += 2;
110.6802 -			int offset = 0;
110.6803 -			if (opcode & 0x8000)
110.6804 -			{
110.6805 -				LDM_REG(1, 0);
110.6806 -				LDM_REG(2, 1);
110.6807 -				LDM_REG(4, 2);
110.6808 -				LDM_REG(8, 3);
110.6809 -				LDM_REG(16, 4);
110.6810 -				LDM_REG(32, 5);
110.6811 -				LDM_REG(64, 6);
110.6812 -				LDM_REG(128, 7);
110.6813 -				LDM_REG(256, 8);
110.6814 -				LDM_REG(512, 9);
110.6815 -				LDM_REG(1024, 10);
110.6816 -				LDM_REG(2048, 11);
110.6817 -				LDM_REG(4096, 12);
110.6818 -				LDM_REG(8192, 13);
110.6819 -				LDM_REG(16384, 14);
110.6820 -
110.6821 -				reg[15].I = CPUReadMemory(address);
110.6822 -				if (!offset)
110.6823 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6824 -				else
110.6825 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6826 -
110.6827 -				if (!(opcode & (1 << base)))
110.6828 -					reg[base].I = temp;
110.6829 -
110.6830 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.6831 -				if (armState)
110.6832 -				{
110.6833 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.6834 -					reg[15].I = armNextPC + 4;
110.6835 -				}
110.6836 -				else
110.6837 -				{
110.6838 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.6839 -					reg[15].I = armNextPC + 2;
110.6840 -				}
110.6841 -			}
110.6842 -			else
110.6843 -			{
110.6844 -				LDM_REG(1, 0);
110.6845 -				LDM_REG(2, 1);
110.6846 -				LDM_REG(4, 2);
110.6847 -				LDM_REG(8, 3);
110.6848 -				LDM_REG(16, 4);
110.6849 -				LDM_REG(32, 5);
110.6850 -				LDM_REG(64, 6);
110.6851 -				LDM_REG(128, 7);
110.6852 -
110.6853 -				if (armMode == 0x11)
110.6854 -				{
110.6855 -					LDM_REG(256, R8_FIQ);
110.6856 -					LDM_REG(512, R9_FIQ);
110.6857 -					LDM_REG(1024, R10_FIQ);
110.6858 -					LDM_REG(2048, R11_FIQ);
110.6859 -					LDM_REG(4096, R12_FIQ);
110.6860 -				}
110.6861 -				else
110.6862 -				{
110.6863 -					LDM_REG(256, 8);
110.6864 -					LDM_REG(512, 9);
110.6865 -					LDM_REG(1024, 10);
110.6866 -					LDM_REG(2048, 11);
110.6867 -					LDM_REG(4096, 12);
110.6868 -				}
110.6869 -
110.6870 -				if (armMode != 0x10 && armMode != 0x1f)
110.6871 -				{
110.6872 -					LDM_REG(8192, R13_USR);
110.6873 -					LDM_REG(16384, R14_USR);
110.6874 -				}
110.6875 -				else
110.6876 -				{
110.6877 -					LDM_REG(8192, 13);
110.6878 -					LDM_REG(16384, 14);
110.6879 -				}
110.6880 -
110.6881 -				if (!(opcode & (1 << base)))
110.6882 -					reg[base].I = temp;
110.6883 -			}
110.6884 -		}
110.6885 -		break;
110.6886 -
110.6887 -		CASE_16(0x910)
110.6888 -		{
110.6889 -			// LDMDB Rn, {Rlist}
110.6890 -			int base = (opcode & 0x000F0000) >> 16;
110.6891 -			u32 temp = reg[base].I -
110.6892 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6893 -			u32 address = temp & 0xFFFFFFFC;
110.6894 -			clockTicks += 2;
110.6895 -			int offset = 0;
110.6896 -			LDM_REG(1, 0);
110.6897 -			LDM_REG(2, 1);
110.6898 -			LDM_REG(4, 2);
110.6899 -			LDM_REG(8, 3);
110.6900 -			LDM_REG(16, 4);
110.6901 -			LDM_REG(32, 5);
110.6902 -			LDM_REG(64, 6);
110.6903 -			LDM_REG(128, 7);
110.6904 -			LDM_REG(256, 8);
110.6905 -			LDM_REG(512, 9);
110.6906 -			LDM_REG(1024, 10);
110.6907 -			LDM_REG(2048, 11);
110.6908 -			LDM_REG(4096, 12);
110.6909 -			LDM_REG(8192, 13);
110.6910 -			LDM_REG(16384, 14);
110.6911 -			if (opcode & 32768)
110.6912 -			{
110.6913 -				reg[15].I = CPUReadMemory(address);
110.6914 -				if (!offset)
110.6915 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6916 -				else
110.6917 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6918 -				armNextPC  = reg[15].I;
110.6919 -				reg[15].I += 4;
110.6920 -			}
110.6921 -		}
110.6922 -		break;
110.6923 -		CASE_16(0x930)
110.6924 -		{
110.6925 -			// LDMDB Rn!, {Rlist}
110.6926 -			int base = (opcode & 0x000F0000) >> 16;
110.6927 -			u32 temp = reg[base].I -
110.6928 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6929 -			u32 address = temp & 0xFFFFFFFC;
110.6930 -			clockTicks += 2;
110.6931 -			int offset = 0;
110.6932 -			LDM_REG(1, 0);
110.6933 -			LDM_REG(2, 1);
110.6934 -			LDM_REG(4, 2);
110.6935 -			LDM_REG(8, 3);
110.6936 -			LDM_REG(16, 4);
110.6937 -			LDM_REG(32, 5);
110.6938 -			LDM_REG(64, 6);
110.6939 -			LDM_REG(128, 7);
110.6940 -			LDM_REG(256, 8);
110.6941 -			LDM_REG(512, 9);
110.6942 -			LDM_REG(1024, 10);
110.6943 -			LDM_REG(2048, 11);
110.6944 -			LDM_REG(4096, 12);
110.6945 -			LDM_REG(8192, 13);
110.6946 -			LDM_REG(16384, 14);
110.6947 -			if (opcode & 32768)
110.6948 -			{
110.6949 -				reg[15].I = CPUReadMemory(address);
110.6950 -				if (!offset)
110.6951 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6952 -				else
110.6953 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6954 -				armNextPC  = reg[15].I;
110.6955 -				reg[15].I += 4;
110.6956 -			}
110.6957 -			if (!(opcode & (1 << base)))
110.6958 -				reg[base].I = temp;
110.6959 -		}
110.6960 -		break;
110.6961 -		CASE_16(0x950)
110.6962 -		{
110.6963 -			// LDMDB Rn, {Rlist}^
110.6964 -			int base = (opcode & 0x000F0000) >> 16;
110.6965 -			u32 temp = reg[base].I -
110.6966 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.6967 -			u32 address = temp & 0xFFFFFFFC;
110.6968 -			clockTicks += 2;
110.6969 -			int offset = 0;
110.6970 -			if (opcode & 0x8000)
110.6971 -			{
110.6972 -				LDM_REG(1, 0);
110.6973 -				LDM_REG(2, 1);
110.6974 -				LDM_REG(4, 2);
110.6975 -				LDM_REG(8, 3);
110.6976 -				LDM_REG(16, 4);
110.6977 -				LDM_REG(32, 5);
110.6978 -				LDM_REG(64, 6);
110.6979 -				LDM_REG(128, 7);
110.6980 -				LDM_REG(256, 8);
110.6981 -				LDM_REG(512, 9);
110.6982 -				LDM_REG(1024, 10);
110.6983 -				LDM_REG(2048, 11);
110.6984 -				LDM_REG(4096, 12);
110.6985 -				LDM_REG(8192, 13);
110.6986 -				LDM_REG(16384, 14);
110.6987 -
110.6988 -				reg[15].I = CPUReadMemory(address);
110.6989 -				if (!offset)
110.6990 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.6991 -				else
110.6992 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.6993 -
110.6994 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.6995 -				if (armState)
110.6996 -				{
110.6997 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.6998 -					reg[15].I = armNextPC + 4;
110.6999 -				}
110.7000 -				else
110.7001 -				{
110.7002 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.7003 -					reg[15].I = armNextPC + 2;
110.7004 -				}
110.7005 -			}
110.7006 -			else
110.7007 -			{
110.7008 -				LDM_REG(1, 0);
110.7009 -				LDM_REG(2, 1);
110.7010 -				LDM_REG(4, 2);
110.7011 -				LDM_REG(8, 3);
110.7012 -				LDM_REG(16, 4);
110.7013 -				LDM_REG(32, 5);
110.7014 -				LDM_REG(64, 6);
110.7015 -				LDM_REG(128, 7);
110.7016 -
110.7017 -				if (armMode == 0x11)
110.7018 -				{
110.7019 -					LDM_REG(256, R8_FIQ);
110.7020 -					LDM_REG(512, R9_FIQ);
110.7021 -					LDM_REG(1024, R10_FIQ);
110.7022 -					LDM_REG(2048, R11_FIQ);
110.7023 -					LDM_REG(4096, R12_FIQ);
110.7024 -				}
110.7025 -				else
110.7026 -				{
110.7027 -					LDM_REG(256, 8);
110.7028 -					LDM_REG(512, 9);
110.7029 -					LDM_REG(1024, 10);
110.7030 -					LDM_REG(2048, 11);
110.7031 -					LDM_REG(4096, 12);
110.7032 -				}
110.7033 -
110.7034 -				if (armMode != 0x10 && armMode != 0x1f)
110.7035 -				{
110.7036 -					LDM_REG(8192, R13_USR);
110.7037 -					LDM_REG(16384, R14_USR);
110.7038 -				}
110.7039 -				else
110.7040 -				{
110.7041 -					LDM_REG(8192, 13);
110.7042 -					LDM_REG(16384, 14);
110.7043 -				}
110.7044 -			}
110.7045 -		}
110.7046 -		break;
110.7047 -		CASE_16(0x970)
110.7048 -		{
110.7049 -			// LDMDB Rn!, {Rlist}^
110.7050 -			int base = (opcode & 0x000F0000) >> 16;
110.7051 -			u32 temp = reg[base].I -
110.7052 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.7053 -			u32 address = temp & 0xFFFFFFFC;
110.7054 -			clockTicks += 2;
110.7055 -			int offset = 0;
110.7056 -			if (opcode & 0x8000)
110.7057 -			{
110.7058 -				LDM_REG(1, 0);
110.7059 -				LDM_REG(2, 1);
110.7060 -				LDM_REG(4, 2);
110.7061 -				LDM_REG(8, 3);
110.7062 -				LDM_REG(16, 4);
110.7063 -				LDM_REG(32, 5);
110.7064 -				LDM_REG(64, 6);
110.7065 -				LDM_REG(128, 7);
110.7066 -				LDM_REG(256, 8);
110.7067 -				LDM_REG(512, 9);
110.7068 -				LDM_REG(1024, 10);
110.7069 -				LDM_REG(2048, 11);
110.7070 -				LDM_REG(4096, 12);
110.7071 -				LDM_REG(8192, 13);
110.7072 -				LDM_REG(16384, 14);
110.7073 -
110.7074 -				reg[15].I = CPUReadMemory(address);
110.7075 -				if (!offset)
110.7076 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.7077 -				else
110.7078 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.7079 -
110.7080 -				if (!(opcode & (1 << base)))
110.7081 -					reg[base].I = temp;
110.7082 -
110.7083 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.7084 -				if (armState)
110.7085 -				{
110.7086 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.7087 -					reg[15].I = armNextPC + 4;
110.7088 -				}
110.7089 -				else
110.7090 -				{
110.7091 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.7092 -					reg[15].I = armNextPC + 2;
110.7093 -				}
110.7094 -			}
110.7095 -			else
110.7096 -			{
110.7097 -				LDM_REG(1, 0);
110.7098 -				LDM_REG(2, 1);
110.7099 -				LDM_REG(4, 2);
110.7100 -				LDM_REG(8, 3);
110.7101 -				LDM_REG(16, 4);
110.7102 -				LDM_REG(32, 5);
110.7103 -				LDM_REG(64, 6);
110.7104 -				LDM_REG(128, 7);
110.7105 -
110.7106 -				if (armMode == 0x11)
110.7107 -				{
110.7108 -					LDM_REG(256, R8_FIQ);
110.7109 -					LDM_REG(512, R9_FIQ);
110.7110 -					LDM_REG(1024, R10_FIQ);
110.7111 -					LDM_REG(2048, R11_FIQ);
110.7112 -					LDM_REG(4096, R12_FIQ);
110.7113 -				}
110.7114 -				else
110.7115 -				{
110.7116 -					LDM_REG(256, 8);
110.7117 -					LDM_REG(512, 9);
110.7118 -					LDM_REG(1024, 10);
110.7119 -					LDM_REG(2048, 11);
110.7120 -					LDM_REG(4096, 12);
110.7121 -				}
110.7122 -
110.7123 -				if (armMode != 0x10 && armMode != 0x1f)
110.7124 -				{
110.7125 -					LDM_REG(8192, R13_USR);
110.7126 -					LDM_REG(16384, R14_USR);
110.7127 -				}
110.7128 -				else
110.7129 -				{
110.7130 -					LDM_REG(8192, 13);
110.7131 -					LDM_REG(16384, 14);
110.7132 -				}
110.7133 -
110.7134 -				if (!(opcode & (1 << base)))
110.7135 -					reg[base].I = temp;
110.7136 -			}
110.7137 -		}
110.7138 -		break;
110.7139 -
110.7140 -		CASE_16(0x990)
110.7141 -		{
110.7142 -			// LDMIB Rn, {Rlist}
110.7143 -			int base	= (opcode & 0x000F0000) >> 16;
110.7144 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.7145 -			clockTicks += 2;
110.7146 -			int offset = 0;
110.7147 -			LDM_REG(1, 0);
110.7148 -			LDM_REG(2, 1);
110.7149 -			LDM_REG(4, 2);
110.7150 -			LDM_REG(8, 3);
110.7151 -			LDM_REG(16, 4);
110.7152 -			LDM_REG(32, 5);
110.7153 -			LDM_REG(64, 6);
110.7154 -			LDM_REG(128, 7);
110.7155 -			LDM_REG(256, 8);
110.7156 -			LDM_REG(512, 9);
110.7157 -			LDM_REG(1024, 10);
110.7158 -			LDM_REG(2048, 11);
110.7159 -			LDM_REG(4096, 12);
110.7160 -			LDM_REG(8192, 13);
110.7161 -			LDM_REG(16384, 14);
110.7162 -			if (opcode & 32768)
110.7163 -			{
110.7164 -				reg[15].I = CPUReadMemory(address);
110.7165 -				if (!offset)
110.7166 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.7167 -				else
110.7168 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.7169 -				armNextPC  = reg[15].I;
110.7170 -				reg[15].I += 4;
110.7171 -			}
110.7172 -		}
110.7173 -		break;
110.7174 -		CASE_16(0x9b0)
110.7175 -		{
110.7176 -			// LDMIB Rn!, {Rlist}
110.7177 -			int base = (opcode & 0x000F0000) >> 16;
110.7178 -			u32 temp = reg[base].I +
110.7179 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.7180 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.7181 -			clockTicks += 2;
110.7182 -			int offset = 0;
110.7183 -			LDM_REG(1, 0);
110.7184 -			LDM_REG(2, 1);
110.7185 -			LDM_REG(4, 2);
110.7186 -			LDM_REG(8, 3);
110.7187 -			LDM_REG(16, 4);
110.7188 -			LDM_REG(32, 5);
110.7189 -			LDM_REG(64, 6);
110.7190 -			LDM_REG(128, 7);
110.7191 -			LDM_REG(256, 8);
110.7192 -			LDM_REG(512, 9);
110.7193 -			LDM_REG(1024, 10);
110.7194 -			LDM_REG(2048, 11);
110.7195 -			LDM_REG(4096, 12);
110.7196 -			LDM_REG(8192, 13);
110.7197 -			LDM_REG(16384, 14);
110.7198 -			if (opcode & 32768)
110.7199 -			{
110.7200 -				reg[15].I = CPUReadMemory(address);
110.7201 -				if (!offset)
110.7202 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.7203 -				else
110.7204 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.7205 -				armNextPC  = reg[15].I;
110.7206 -				reg[15].I += 4;
110.7207 -			}
110.7208 -			if (!(opcode & (1 << base)))
110.7209 -				reg[base].I = temp;
110.7210 -		}
110.7211 -		break;
110.7212 -		CASE_16(0x9d0)
110.7213 -		{
110.7214 -			// LDMIB Rn, {Rlist}^
110.7215 -			int base	= (opcode & 0x000F0000) >> 16;
110.7216 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.7217 -			clockTicks += 2;
110.7218 -			int offset = 0;
110.7219 -			if (opcode & 0x8000)
110.7220 -			{
110.7221 -				LDM_REG(1, 0);
110.7222 -				LDM_REG(2, 1);
110.7223 -				LDM_REG(4, 2);
110.7224 -				LDM_REG(8, 3);
110.7225 -				LDM_REG(16, 4);
110.7226 -				LDM_REG(32, 5);
110.7227 -				LDM_REG(64, 6);
110.7228 -				LDM_REG(128, 7);
110.7229 -				LDM_REG(256, 8);
110.7230 -				LDM_REG(512, 9);
110.7231 -				LDM_REG(1024, 10);
110.7232 -				LDM_REG(2048, 11);
110.7233 -				LDM_REG(4096, 12);
110.7234 -				LDM_REG(8192, 13);
110.7235 -				LDM_REG(16384, 14);
110.7236 -
110.7237 -				reg[15].I = CPUReadMemory(address);
110.7238 -				if (!offset)
110.7239 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.7240 -				else
110.7241 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.7242 -
110.7243 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.7244 -				if (armState)
110.7245 -				{
110.7246 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.7247 -					reg[15].I = armNextPC + 4;
110.7248 -				}
110.7249 -				else
110.7250 -				{
110.7251 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.7252 -					reg[15].I = armNextPC + 2;
110.7253 -				}
110.7254 -			}
110.7255 -			else
110.7256 -			{
110.7257 -				LDM_REG(1, 0);
110.7258 -				LDM_REG(2, 1);
110.7259 -				LDM_REG(4, 2);
110.7260 -				LDM_REG(8, 3);
110.7261 -				LDM_REG(16, 4);
110.7262 -				LDM_REG(32, 5);
110.7263 -				LDM_REG(64, 6);
110.7264 -				LDM_REG(128, 7);
110.7265 -
110.7266 -				if (armMode == 0x11)
110.7267 -				{
110.7268 -					LDM_REG(256, R8_FIQ);
110.7269 -					LDM_REG(512, R9_FIQ);
110.7270 -					LDM_REG(1024, R10_FIQ);
110.7271 -					LDM_REG(2048, R11_FIQ);
110.7272 -					LDM_REG(4096, R12_FIQ);
110.7273 -				}
110.7274 -				else
110.7275 -				{
110.7276 -					LDM_REG(256, 8);
110.7277 -					LDM_REG(512, 9);
110.7278 -					LDM_REG(1024, 10);
110.7279 -					LDM_REG(2048, 11);
110.7280 -					LDM_REG(4096, 12);
110.7281 -				}
110.7282 -
110.7283 -				if (armMode != 0x10 && armMode != 0x1f)
110.7284 -				{
110.7285 -					LDM_REG(8192, R13_USR);
110.7286 -					LDM_REG(16384, R14_USR);
110.7287 -				}
110.7288 -				else
110.7289 -				{
110.7290 -					LDM_REG(8192, 13);
110.7291 -					LDM_REG(16384, 14);
110.7292 -				}
110.7293 -			}
110.7294 -		}
110.7295 -		break;
110.7296 -		CASE_16(0x9f0)
110.7297 -		{
110.7298 -			// LDMIB Rn!, {Rlist}^
110.7299 -			int base = (opcode & 0x000F0000) >> 16;
110.7300 -			u32 temp = reg[base].I +
110.7301 -			           4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
110.7302 -			u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
110.7303 -			clockTicks += 2;
110.7304 -			int offset = 0;
110.7305 -			if (opcode & 0x8000)
110.7306 -			{
110.7307 -				LDM_REG(1, 0);
110.7308 -				LDM_REG(2, 1);
110.7309 -				LDM_REG(4, 2);
110.7310 -				LDM_REG(8, 3);
110.7311 -				LDM_REG(16, 4);
110.7312 -				LDM_REG(32, 5);
110.7313 -				LDM_REG(64, 6);
110.7314 -				LDM_REG(128, 7);
110.7315 -				LDM_REG(256, 8);
110.7316 -				LDM_REG(512, 9);
110.7317 -				LDM_REG(1024, 10);
110.7318 -				LDM_REG(2048, 11);
110.7319 -				LDM_REG(4096, 12);
110.7320 -				LDM_REG(8192, 13);
110.7321 -				LDM_REG(16384, 14);
110.7322 -
110.7323 -				reg[15].I = CPUReadMemory(address);
110.7324 -				if (!offset)
110.7325 -					clockTicks += 2 + CPUUpdateTicksAccess32(address);
110.7326 -				else
110.7327 -					clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);
110.7328 -
110.7329 -				if (!(opcode & (1 << base)))
110.7330 -					reg[base].I = temp;
110.7331 -
110.7332 -				CPUSwitchMode(reg[17].I & 0x1f, false);
110.7333 -				if (armState)
110.7334 -				{
110.7335 -					armNextPC = reg[15].I & 0xFFFFFFFC;
110.7336 -					reg[15].I = armNextPC + 4;
110.7337 -				}
110.7338 -				else
110.7339 -				{
110.7340 -					armNextPC = reg[15].I & 0xFFFFFFFE;
110.7341 -					reg[15].I = armNextPC + 2;
110.7342 -				}
110.7343 -			}
110.7344 -			else
110.7345 -			{
110.7346 -				LDM_REG(1, 0);
110.7347 -				LDM_REG(2, 1);
110.7348 -				LDM_REG(4, 2);
110.7349 -				LDM_REG(8, 3);
110.7350 -				LDM_REG(16, 4);
110.7351 -				LDM_REG(32, 5);
110.7352 -				LDM_REG(64, 6);
110.7353 -				LDM_REG(128, 7);
110.7354 -
110.7355 -				if (armMode == 0x11)
110.7356 -				{
110.7357 -					LDM_REG(256, R8_FIQ);
110.7358 -					LDM_REG(512, R9_FIQ);
110.7359 -					LDM_REG(1024, R10_FIQ);
110.7360 -					LDM_REG(2048, R11_FIQ);
110.7361 -					LDM_REG(4096, R12_FIQ);
110.7362 -				}
110.7363 -				else
110.7364 -				{
110.7365 -					LDM_REG(256, 8);
110.7366 -					LDM_REG(512, 9);
110.7367 -					LDM_REG(1024, 10);
110.7368 -					LDM_REG(2048, 11);
110.7369 -					LDM_REG(4096, 12);
110.7370 -				}
110.7371 -
110.7372 -				if (armMode != 0x10 && armMode != 0x1f)
110.7373 -				{
110.7374 -					LDM_REG(8192, R13_USR);
110.7375 -					LDM_REG(16384, R14_USR);
110.7376 -				}
110.7377 -				else
110.7378 -				{
110.7379 -					LDM_REG(8192, 13);
110.7380 -					LDM_REG(16384, 14);
110.7381 -				}
110.7382 -
110.7383 -				if (!(opcode & (1 << base)))
110.7384 -					reg[base].I = temp;
110.7385 -			}
110.7386 -		}
110.7387 -		break;
110.7388 -		CASE_256(0xa00)
110.7389 -		{
110.7390 -			// B <offset>
110.7391 -			clockTicks += 3;
110.7392 -			int offset = opcode & 0x00FFFFFF;
110.7393 -			if (offset & 0x00800000)
110.7394 -			{
110.7395 -				offset |= 0xFF000000;
110.7396 -			}
110.7397 -			offset	 <<= 2;
110.7398 -			reg[15].I += offset;
110.7399 -			armNextPC  = reg[15].I;
110.7400 -			reg[15].I += 4;
110.7401 -		}
110.7402 -		break;
110.7403 -		CASE_256(0xb00)
110.7404 -		{
110.7405 -			// BL <offset>
110.7406 -			clockTicks += 3;
110.7407 -			int offset = opcode & 0x00FFFFFF;
110.7408 -			if (offset & 0x00800000)
110.7409 -			{
110.7410 -				offset |= 0xFF000000;
110.7411 -			}
110.7412 -			offset	 <<= 2;
110.7413 -			reg[14].I  = reg[15].I - 4;
110.7414 -			reg[15].I += offset;
110.7415 -			armNextPC  = reg[15].I;
110.7416 -			reg[15].I += 4;
110.7417 -		}
110.7418 -		break;
110.7419 -		CASE_256(0xf00)
110.7420 -		// SWI <comment>
110.7421 -		clockTicks += 3;
110.7422 -		CPUSoftwareInterrupt(opcode & 0x00FFFFFF);
110.7423 -		break;
110.7424 -#ifdef GP_SUPPORT
110.7425 -	case 0xe11:
110.7426 -	case 0xe13:
110.7427 -	case 0xe15:
110.7428 -	case 0xe17:
110.7429 -	case 0xe19:
110.7430 -	case 0xe1b:
110.7431 -	case 0xe1d:
110.7432 -	case 0xe1f:
110.7433 -		// MRC
110.7434 -		break;
110.7435 -	case 0xe01:
110.7436 -	case 0xe03:
110.7437 -	case 0xe05:
110.7438 -	case 0xe07:
110.7439 -	case 0xe09:
110.7440 -	case 0xe0b:
110.7441 -	case 0xe0d:
110.7442 -	case 0xe0f:
110.7443 -		// MRC
110.7444 -		break;
110.7445 -#endif
110.7446 -	default:
110.7447 -#ifdef GBA_LOGGING
110.7448 -		if (systemVerbose & VERBOSE_UNDEFINED)
110.7449 -			log("Undefined ARM instruction %08x at %08x\n", opcode,
110.7450 -			    armNextPC - 4);
110.7451 -#endif
110.7452 -		CPUUndefinedException();
110.7453 -		break;
110.7454 -		// END
110.7455 -	}
110.7456 -}
   111.1 --- a/src/gba/armdis.cpp	Sat Mar 03 10:54:39 2012 -0600
   111.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   111.3 @@ -1,774 +0,0 @@
   111.4 -/************************************************************************/
   111.5 -/* Arm/Thumb command set disassembler                                   */
   111.6 -/************************************************************************/
   111.7 -#include <cstdio>
   111.8 -
   111.9 -#include "GBAGlobals.h"
  111.10 -#include "armdis.h"
  111.11 -#include "elf.h"
  111.12 -
  111.13 -struct Opcodes
  111.14 -{
  111.15 -	u32 mask;
  111.16 -	u32 cval;
  111.17 -	const char *mnemonic;
  111.18 -};
  111.19 -
  111.20 -const char hdig[] = "0123456789abcdef";
  111.21 -
  111.22 -const char *decVals[16] = {
  111.23 -	"0", "1",  "2",	 "3",  "4",	 "5",  "6", "7", "8",
  111.24 -	"9", "10", "11", "12", "13", "14", "15"
  111.25 -};
  111.26 -
  111.27 -const char *regs[16] = {
  111.28 -	"r0", "r1", "r2",  "r3",  "r4",	 "r5", "r6", "r7",
  111.29 -	"r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc"
  111.30 -};
  111.31 -
  111.32 -const char *conditions[16] = {
  111.33 -	"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
  111.34 -	"hi", "ls", "ge", "lt", "gt", "le", "",	  "nv"
  111.35 -};
  111.36 -
  111.37 -const char *shifts[5] = {
  111.38 -	"lsl", "lsr", "asr", "ror", "rrx"
  111.39 -};
  111.40 -
  111.41 -const char *armMultLoadStore[12] = {
  111.42 -	// non-stack
  111.43 -	"da", "ia", "db", "ib",
  111.44 -	// stack store
  111.45 -	"ed", "ea", "fd", "fa",
  111.46 -	// stack load
  111.47 -	"fa", "fd", "ea", "ed"
  111.48 -};
  111.49 -
  111.50 -const Opcodes thumbOpcodes[] = {
  111.51 -	// Format 1
  111.52 -	{ 0xf800, 0x0000, "lsl %r0, %r3, %o"	  },
  111.53 -	{ 0xf800, 0x0800, "lsr %r0, %r3, %o"	  },
  111.54 -	{ 0xf800, 0x1000, "asr %r0, %r3, %o"	  },
  111.55 -	// Format 2
  111.56 -	{ 0xfe00, 0x1800, "add %r0, %r3, %r6"	  },
  111.57 -	{ 0xfe00, 0x1a00, "sub %r0, %r3, %r6"	  },
  111.58 -	{ 0xfe00, 0x1c00, "add %r0, %r3, %i"	  },
  111.59 -	{ 0xfe00, 0x1e00, "sub %r0, %r3, %i"	  },
  111.60 -	// Format 3
  111.61 -	{ 0xf800, 0x2000, "mov %r8, %O"			  },
  111.62 -	{ 0xf800, 0x2800, "cmp %r8, %O"			  },
  111.63 -	{ 0xf800, 0x3000, "add %r8, %O"			  },
  111.64 -	{ 0xf800, 0x3800, "sub %r8, %O"			  },
  111.65 -	// Format 4
  111.66 -	{ 0xffc0, 0x4000, "and %r0, %r3"		  },
  111.67 -	{ 0xffc0, 0x4040, "eor %r0, %r3"		  },
  111.68 -	{ 0xffc0, 0x4080, "lsl %r0, %r3"		  },
  111.69 -	{ 0xffc0, 0x40c0, "lsr %r0, %r3"		  },
  111.70 -	{ 0xffc0, 0x4100, "asr %r0, %r3"		  },
  111.71 -	{ 0xffc0, 0x4140, "adc %r0, %r3"		  },
  111.72 -	{ 0xffc0, 0x4180, "sbc %r0, %r3"		  },
  111.73 -	{ 0xffc0, 0x41c0, "ror %r0, %r3"		  },
  111.74 -	{ 0xffc0, 0x4200, "tst %r0, %r3"		  },
  111.75 -	{ 0xffc0, 0x4240, "neg %r0, %r3"		  },
  111.76 -	{ 0xffc0, 0x4280, "cmp %r0, %r3"		  },
  111.77 -	{ 0xffc0, 0x42c0, "cmn %r0, %r3"		  },
  111.78 -	{ 0xffc0, 0x4300, "orr %r0, %r3"		  },
  111.79 -	{ 0xffc0, 0x4340, "mul %r0, %r3"		  },
  111.80 -	{ 0xffc0, 0x4380, "bic %r0, %r3"		  },
  111.81 -	{ 0xffc0, 0x43c0, "mvn %r0, %r3"		  },
  111.82 -	// Format 5
  111.83 -	{ 0xff80, 0x4700, "bx %h36"				  },
  111.84 -	{ 0xfcc0, 0x4400, "[ ??? ]"				  },
  111.85 -	{ 0xff00, 0x4400, "add %h07, %h36"		  },
  111.86 -	{ 0xff00, 0x4500, "cmp %h07, %h36"		  },
  111.87 -	{ 0xff00, 0x4600, "mov %h07, %h36"		  },
  111.88 -	// Format 6
  111.89 -	{ 0xf800, 0x4800, "ldr %r8, [%I] (=%J)"	  },
  111.90 -	// Format 7
  111.91 -	{ 0xfa00, 0x5000, "str%b %r0, [%r3, %r6]" },
  111.92 -	{ 0xfa00, 0x5800, "ldr%b %r0, [%r3, %r6]" },
  111.93 -	// Format 8
  111.94 -	{ 0xfe00, 0x5200, "strh %r0, [%r3, %r6]"  },
  111.95 -	{ 0xfe00, 0x5600, "ldsb %r0, [%r3, %r6]"  },
  111.96 -	{ 0xfe00, 0x5a00, "ldrh %r0, [%r3, %r6]"  },
  111.97 -	{ 0xfe00, 0x5e00, "ldsh %r0, [%r3, %r6]"  },
  111.98 -	// Format 9
  111.99 -	{ 0xe800, 0x6000, "str%B %r0, [%r3, %p]"  },
 111.100 -	{ 0xe800, 0x6800, "ldr%B %r0, [%r3, %p]"  },
 111.101 -	// Format 10
 111.102 -	{ 0xf800, 0x8000, "strh %r0, [%r3, %e]"	  },
 111.103 -	{ 0xf800, 0x8800, "ldrh %r0, [%r3, %e]"	  },
 111.104 -	// Format 11
 111.105 -	{ 0xf800, 0x9000, "str %r8, [sp, %w]"	  },
 111.106 -	{ 0xf800, 0x9800, "ldr %r8, [sp, %w]"	  },
 111.107 -	// Format 12
 111.108 -	{ 0xf800, 0xa000, "add %r8, pc, %w (=%K)" },
 111.109 -	{ 0xf800, 0xa800, "add %r8, sp, %w"		  },
 111.110 -	// Format 13
 111.111 -	{ 0xff00, 0xb000, "add sp, %s"			  },
 111.112 -	// Format 14
 111.113 -	{ 0xffff, 0xb500, "push {lr}"			  },
 111.114 -	{ 0xff00, 0xb400, "push {%l}"			  },
 111.115 -	{ 0xff00, 0xb500, "push {%l,lr}"		  },
 111.116 -	{ 0xffff, 0xbd00, "pop {pc}"			  },
 111.117 -	{ 0xff00, 0xbd00, "pop {%l,pc}"			  },
 111.118 -	{ 0xff00, 0xbc00, "pop {%l}"			  },
 111.119 -	// Format 15
 111.120 -	{ 0xf800, 0xc000, "stmia %r8!, {%l}"	  },
 111.121 -	{ 0xf800, 0xc800, "ldmia %r8!, {%l}"	  },
 111.122 -	// Format 17
 111.123 -	{ 0xff00, 0xdf00, "swi %m"				  },
 111.124 -	// Format 16
 111.125 -	{ 0xf000, 0xd000, "b%c %W"				  },
 111.126 -	// Format 18
 111.127 -	{ 0xf800, 0xe000, "b %a"				  },
 111.128 -	// Format 19
 111.129 -	{ 0xf800, 0xf000, "bl %A"				  },
 111.130 -	{ 0xf800, 0xf800, "blh %Z"				  },
 111.131 -	{ 0xff00, 0xbe00, "bkpt %O"				  },
 111.132 -	// Unknown
 111.133 -	{ 0x0000, 0x0000, "[ ??? ]"				  }
 111.134 -};
 111.135 -
 111.136 -const Opcodes armOpcodes[] = {
 111.137 -	// Undefined
 111.138 -	{ 0x0e000010, 0x06000010, "[ undefined ]"				  },
 111.139 -	// Branch instructions
 111.140 -	{ 0x0ff000f0, 0x01200010, "bx%c %r0"					  },
 111.141 -	{ 0x0f000000, 0x0a000000, "b%c %o"						  },
 111.142 -	{ 0x0f000000, 0x0b000000, "bl%c %o"						  },
 111.143 -	{ 0x0f000000, 0x0f000000, "swi%c %q"					  },
 111.144 -	// PSR transfer
 111.145 -	{ 0x0fbf0fff, 0x010f0000, "mrs%c %r3, %p"				  },
 111.146 -	{ 0x0db0f000, 0x0120f000, "msr%c %p, %i"				  },
 111.147 -	// Multiply instructions
 111.148 -	{ 0x0fe000f0, 0x00000090, "mul%c%s %r4, %r0, %r2"		  },
 111.149 -	{ 0x0fe000f0, 0x00200090, "mla%c%s %r4, %r0, %r2, %r3"	  },
 111.150 -	{ 0x0fa000f0, 0x00800090, "%umull%c%s %r3, %r4, %r0, %r2" },
 111.151 -	{ 0x0fa000f0, 0x00a00090, "%umlal%c%s %r3, %r4, %r0, %r2" },
 111.152 -	// Load/Store instructions
 111.153 -	{ 0x0fb00ff0, 0x01000090, "swp%c%b %r3, %r0, [%r4]"		  },
 111.154 -	{ 0x0fb000f0, 0x01000090, "[ ??? ]"						  },
 111.155 -	{ 0x0c100000, 0x04000000, "str%c%b%t %r3, %a"			  },
 111.156 -	{ 0x0c100000, 0x04100000, "ldr%c%b%t %r3, %a"			  },
 111.157 -	{ 0x0e100090, 0x00000090, "str%c%h %r3, %a"				  },
 111.158 -	{ 0x0e100090, 0x00100090, "ldr%c%h %r3, %a"				  },
 111.159 -	{ 0x0e100000, 0x08000000, "stm%c%m %r4%l"				  },
 111.160 -	{ 0x0e100000, 0x08100000, "ldm%c%m %r4%l"				  },
 111.161 -	// Data processing
 111.162 -	{ 0x0de00000, 0x00000000, "and%c%s %r3, %r4, %i"		  },
 111.163 -	{ 0x0de00000, 0x00200000, "eor%c%s %r3, %r4, %i"		  },
 111.164 -	{ 0x0de00000, 0x00400000, "sub%c%s %r3, %r4, %i"		  },
 111.165 -	{ 0x0de00000, 0x00600000, "rsb%c%s %r3, %r4, %i"		  },
 111.166 -	{ 0x0de00000, 0x00800000, "add%c%s %r3, %r4, %i"		  },
 111.167 -	{ 0x0de00000, 0x00a00000, "adc%c%s %r3, %r4, %i"		  },
 111.168 -	{ 0x0de00000, 0x00c00000, "sbc%c%s %r3, %r4, %i"		  },
 111.169 -	{ 0x0de00000, 0x00e00000, "rsc%c%s %r3, %r4, %i"		  },
 111.170 -	{ 0x0de00000, 0x01000000, "tst%c%s %r4, %i"				  },
 111.171 -	{ 0x0de00000, 0x01200000, "teq%c%s %r4, %i"				  },
 111.172 -	{ 0x0de00000, 0x01400000, "cmp%c%s %r4, %i"				  },
 111.173 -	{ 0x0de00000, 0x01600000, "cmn%c%s %r4, %i"				  },
 111.174 -	{ 0x0de00000, 0x01800000, "orr%c%s %r3, %r4, %i"		  },
 111.175 -	{ 0x0de00000, 0x01a00000, "mov%c%s %r3, %i"				  },
 111.176 -	{ 0x0de00000, 0x01c00000, "bic%c%s %r3, %r4, %i"		  },
 111.177 -	{ 0x0de00000, 0x01e00000, "mvn%c%s %r3, %i"				  },
 111.178 -	// Coprocessor operations
 111.179 -	{ 0x0f000010, 0x0e000000, "cdp%c %P, %N, %r3, %R4, %R0%V" },
 111.180 -	{ 0x0e100000, 0x0c000000, "stc%c%L %P, %r3, %A"			  },
 111.181 -	{ 0x0f100010, 0x0e000010, "mcr%c %P, %N, %r3, %R4, %R0%V" },
 111.182 -	{ 0x0f100010, 0x0e100010, "mrc%c %P, %N, %r3, %R4, %R0%V" },
 111.183 -	// Unknown
 111.184 -	{ 0x00000000, 0x00000000, "[ ??? ]"						  }
 111.185 -};
 111.186 -
 111.187 -char *addStr(char *dest, const char *src)
 111.188 -{
 111.189 -	while (*src)
 111.190 -	{
 111.191 -		*dest++ = *src++;
 111.192 -	}
 111.193 -	return dest;
 111.194 -}
 111.195 -
 111.196 -char *addHex(char *dest, int siz, u32 val)
 111.197 -{
 111.198 -	if (siz == 0)
 111.199 -	{
 111.200 -		siz = 28;
 111.201 -		while ((((val >> siz) & 15) == 0) && (siz >= 4))
 111.202 -			siz -= 4;
 111.203 -		siz += 4;
 111.204 -	}
 111.205 -	while (siz > 0)
 111.206 -	{
 111.207 -		siz	   -= 4;
 111.208 -		*dest++ = hdig[(val >> siz) & 15];
 111.209 -	}
 111.210 -	return dest;
 111.211 -}
 111.212 -
 111.213 -int disArm(u32 offset, char *dest, int flags)
 111.214 -{
 111.215 -	u32 opcode = debuggerReadMemory(offset);
 111.216 -
 111.217 -	const Opcodes *sp = armOpcodes;
 111.218 -	while (sp->cval != (opcode & sp->mask))
 111.219 -		sp++;
 111.220 -
 111.221 -	if (flags & DIS_VIEW_ADDRESS)
 111.222 -	{
 111.223 -		dest	= addHex(dest, 32, offset);
 111.224 -		*dest++ = ' ';
 111.225 -	}
 111.226 -	if (flags & DIS_VIEW_CODE)
 111.227 -	{
 111.228 -		dest	= addHex(dest, 32, opcode);
 111.229 -		*dest++ = ' ';
 111.230 -	}
 111.231 -
 111.232 -	const char *src = sp->mnemonic;
 111.233 -	while (*src)
 111.234 -	{
 111.235 -		if (*src != '%')
 111.236 -			*dest++ = *src++;
 111.237 -		else
 111.238 -		{
 111.239 -			src++;
 111.240 -			switch (*src)
 111.241 -			{
 111.242 -			case 'c':
 111.243 -				dest = addStr(dest, conditions[opcode >> 28]);
 111.244 -				break;
 111.245 -			case 'r':
 111.246 -				dest = addStr(dest, regs[(opcode >> ((*(++src) - '0') * 4)) & 15]);
 111.247 -				break;
 111.248 -			case 'o':
 111.249 -			{
 111.250 -				*dest++ = '$';
 111.251 -				int off = opcode & 0xffffff;
 111.252 -				if (off & 0x800000)
 111.253 -					off |= 0xff000000;
 111.254 -				off <<= 2;
 111.255 -				dest  = addHex(dest, 32, offset + 8 + off);
 111.256 -			}
 111.257 -			break;
 111.258 -			case 'i':
 111.259 -				if (opcode & (1 << 25))
 111.260 -				{
 111.261 -					dest = addStr(dest, "#0x");
 111.262 -					int imm = opcode & 0xff;
 111.263 -					int rot = (opcode & 0xf00) >> 7;
 111.264 -					int val = (imm << (32 - rot)) | (imm >> rot);
 111.265 -					dest = addHex(dest, 0, val);
 111.266 -				}
 111.267 -				else
 111.268 -				{
 111.269 -					dest = addStr(dest, regs[opcode & 0x0f]);
 111.270 -					int shi = (opcode >> 5) & 3;
 111.271 -					int sdw = (opcode >> 7) & 0x1f;
 111.272 -					if ((sdw == 0) && (shi == 3))
 111.273 -						shi = 4;
 111.274 -					if ((sdw) || (opcode & 0x10) || (shi))
 111.275 -					{
 111.276 -						dest = addStr(dest, ", ");
 111.277 -						dest = addStr(dest, shifts[shi]);
 111.278 -						if (opcode & 0x10)
 111.279 -						{
 111.280 -							*dest++ = ' ';
 111.281 -							dest	= addStr(dest, regs[(opcode >> 8) & 15]);
 111.282 -						}
 111.283 -						else
 111.284 -						{
 111.285 -							if (sdw == 0 && ((shi == 1) || (shi == 2)))
 111.286 -								sdw = 32;
 111.287 -							if (shi != 4)
 111.288 -							{
 111.289 -								dest = addStr(dest, " #0x");
 111.290 -								dest = addHex(dest, 8, sdw);
 111.291 -							}
 111.292 -						}
 111.293 -					}
 111.294 -				}
 111.295 -				break;
 111.296 -			case 'p':
 111.297 -				if (opcode & (1 << 22))
 111.298 -					dest = addStr(dest, "spsr");
 111.299 -				else
 111.300 -					dest = addStr(dest, "cpsr");
 111.301 -				if (opcode & 0x00F00000)
 111.302 -				{
 111.303 -					*dest++ = '_';
 111.304 -					if (opcode & 0x00080000)
 111.305 -						*dest++ = 'f';
 111.306 -					if (opcode & 0x00040000)
 111.307 -						*dest++ = 's';
 111.308 -					if (opcode & 0x00020000)
 111.309 -						*dest++ = 'x';
 111.310 -					if (opcode & 0x00010000)
 111.311 -						*dest++ = 'c';
 111.312 -				}
 111.313 -				break;
 111.314 -			case 's':
 111.315 -				if (opcode & (1 << 20))
 111.316 -					*dest++ = 's';
 111.317 -				break;
 111.318 -			case 'S':
 111.319 -				if (opcode & (1 << 22))
 111.320 -					*dest++ = 's';
 111.321 -				break;
 111.322 -			case 'u':
 111.323 -				if (opcode & (1 << 22))
 111.324 -					*dest++ = 's';
 111.325 -				else
 111.326 -					*dest++ = 'u';
 111.327 -				break;
 111.328 -			case 'b':
 111.329 -				if (opcode & (1 << 22))
 111.330 -					*dest++ = 'b';
 111.331 -				break;
 111.332 -			case 'a':
 111.333 -				if ((opcode & 0x076f0000) == 0x004f0000)
 111.334 -				{
 111.335 -					*dest++ = '[';
 111.336 -					*dest++ = '$';
 111.337 -					int adr = offset + 8;
 111.338 -					int add = (opcode & 15) | ((opcode >> 8) & 0xf0);
 111.339 -					if (opcode & (1 << 23))
 111.340 -						adr += add;
 111.341 -					else
 111.342 -						adr -= add;
 111.343 -					dest	= addHex(dest, 32, adr);
 111.344 -					*dest++ = ']';
 111.345 -					dest	= addStr(dest, " (=");
 111.346 -					*dest++ = '$';
 111.347 -					dest	= addHex(dest, 32, debuggerReadMemory(adr));
 111.348 -					*dest++ = ')';
 111.349 -				}
 111.350 -				if ((opcode & 0x072f0000) == 0x050f0000)
 111.351 -				{
 111.352 -					*dest++ = '[';
 111.353 -					*dest++ = '$';
 111.354 -					int adr = offset + 8;
 111.355 -					if (opcode & (1 << 23))
 111.356 -						adr += opcode & 0xfff;
 111.357 -					else
 111.358 -						adr -= opcode & 0xfff;
 111.359 -					dest	= addHex(dest, 32, adr);
 111.360 -					*dest++ = ']';
 111.361 -					dest	= addStr(dest, " (=");
 111.362 -					*dest++ = '$';
 111.363 -					dest	= addHex(dest, 32, debuggerReadMemory(adr));
 111.364 -					*dest++ = ')';
 111.365 -				}
 111.366 -				else
 111.367 -				{
 111.368 -					int reg = (opcode >> 16) & 15;
 111.369 -					*dest++ = '[';
 111.370 -					dest	= addStr(dest, regs[reg]);
 111.371 -					if (!(opcode & (1 << 24)))
 111.372 -						*dest++ = ']';
 111.373 -					if (((opcode & (1 << 25)) && (opcode & (1 << 26))) || (!(opcode & (1 << 22)) && !(opcode & (1 << 26))))
 111.374 -					{
 111.375 -						dest = addStr(dest, ", ");
 111.376 -						if (!(opcode & (1 << 23)))
 111.377 -							*dest++ = '-';
 111.378 -						dest = addStr(dest, regs[opcode & 0x0f]);
 111.379 -						int shi = (opcode >> 5) & 3;
 111.380 -						if (opcode & (1 << 26))
 111.381 -						{
 111.382 -							if (((opcode >> 7) & 0x1f) || (opcode & 0x10) || (shi == 1) || (shi == 2))
 111.383 -							{
 111.384 -								dest = addStr(dest, ", ");
 111.385 -								dest = addStr(dest, shifts[shi]);
 111.386 -								if (opcode & 0x10)
 111.387 -								{
 111.388 -									*dest++ = ' ';
 111.389 -									dest	= addStr(dest, regs[(opcode >> 8) & 15]);
 111.390 -								}
 111.391 -								else
 111.392 -								{
 111.393 -									int sdw = (opcode >> 7) & 0x1f;
 111.394 -									if (sdw == 0 && ((shi == 1) || (shi == 2)))
 111.395 -										sdw = 32;
 111.396 -									dest = addStr(dest, " #0x");
 111.397 -									dest = addHex(dest, 8, sdw);
 111.398 -								}
 111.399 -							}
 111.400 -						}
 111.401 -					}
 111.402 -					else
 111.403 -					{
 111.404 -						int off;
 111.405 -						if (opcode & (1 << 26))
 111.406 -							off = opcode & 0xfff;
 111.407 -						else
 111.408 -							off = (opcode & 15) | ((opcode >> 4) & 0xf0);
 111.409 -						if (off)
 111.410 -						{
 111.411 -							dest = addStr(dest, ", ");
 111.412 -							if (!(opcode & (1 << 23)))
 111.413 -								*dest++ = '-';
 111.414 -							dest = addStr(dest, "#0x");
 111.415 -							dest = addHex(dest, 0, off);
 111.416 -						}
 111.417 -					}
 111.418 -					if (opcode & (1 << 24))
 111.419 -					{
 111.420 -						*dest++ = ']';
 111.421 -						if (opcode & (1 << 21))
 111.422 -							*dest++ = '!';
 111.423 -					}
 111.424 -				}
 111.425 -				break;
 111.426 -			case 't':
 111.427 -				if ((opcode & 0x01200000) == 0x01200000)
 111.428 -					*dest++ = 't';
 111.429 -				break;
 111.430 -			case 'h':
 111.431 -				if (opcode & (1 << 6))
 111.432 -					*dest++ = 's';
 111.433 -				if (opcode & (1 << 5))
 111.434 -					*dest++ = 'h';
 111.435 -				else
 111.436 -					*dest++ = 'b';
 111.437 -				break;
 111.438 -			case 'm':
 111.439 -				if (((opcode >> 16) & 15) == 13)
 111.440 -				{
 111.441 -					if (opcode & 0x00100000)
 111.442 -						dest = addStr(dest, armMultLoadStore[8 + ((opcode >> 23) & 3)]);
 111.443 -					else
 111.444 -						dest = addStr(dest, armMultLoadStore[4 + ((opcode >> 23) & 3)]);
 111.445 -				}
 111.446 -				else
 111.447 -					dest = addStr(dest, armMultLoadStore[(opcode >> 23) & 3]);
 111.448 -				break;
 111.449 -			case 'l':
 111.450 -				if (opcode & (1 << 21))
 111.451 -					*dest++ = '!';
 111.452 -				dest = addStr(dest, ", {");
 111.453 -				{
 111.454 -					int rlst	  = opcode & 0xffff;
 111.455 -					int msk		  = 0;
 111.456 -					int not_first = 0;
 111.457 -					while (msk < 16)
 111.458 -					{
 111.459 -						if (rlst & (1 << msk))
 111.460 -						{
 111.461 -							int fr = msk;
 111.462 -							while (rlst & (1 << msk))
 111.463 -								msk++;
 111.464 -							int to = msk - 1;
 111.465 -							if (not_first)
 111.466 -								//dest = addStr(dest, ", ");
 111.467 -								*dest++ = ',';
 111.468 -							dest = addStr(dest, regs[fr]);
 111.469 -							if (fr != to)
 111.470 -							{
 111.471 -								if (fr == to - 1)
 111.472 -									//dest = addStr(", ");
 111.473 -									*dest++ = ',';
 111.474 -								else
 111.475 -									*dest++ = '-';
 111.476 -								dest = addStr(dest, regs[to]);
 111.477 -							}
 111.478 -							not_first = 1;
 111.479 -						}
 111.480 -						else
 111.481 -							msk++;
 111.482 -					}
 111.483 -					*dest++ = '}';
 111.484 -					if (opcode & (1 << 22))
 111.485 -						*dest++ = '^';
 111.486 -				}
 111.487 -				break;
 111.488 -			case 'q':
 111.489 -				*dest++ = '$';
 111.490 -				dest	= addHex(dest, 24, opcode & 0xffffff);
 111.491 -				break;
 111.492 -			case 'P':
 111.493 -				*dest++ = 'p';
 111.494 -				dest	= addStr(dest, decVals[(opcode >> 8) & 15]);
 111.495 -				break;
 111.496 -			case 'N':
 111.497 -				if (opcode & 0x10)
 111.498 -					dest = addStr(dest, decVals[(opcode >> 21) & 7]);
 111.499 -				else
 111.500 -					dest = addStr(dest, decVals[(opcode >> 20) & 15]);
 111.501 -				break;
 111.502 -			case 'R':
 111.503 -			{
 111.504 -				src++;
 111.505 -				int reg = 4 * (*src - '0');
 111.506 -				*dest++ = 'c';
 111.507 -				dest	= addStr(dest, decVals[(opcode >> reg) & 15]);
 111.508 -			}
 111.509 -			break;
 111.510 -			case 'V':
 111.511 -			{
 111.512 -				int val = (opcode >> 5) & 7;
 111.513 -				if (val)
 111.514 -				{
 111.515 -					dest = addStr(dest, ", ");
 111.516 -					dest = addStr(dest, decVals[val]);
 111.517 -				}
 111.518 -			}
 111.519 -			break;
 111.520 -			case 'L':
 111.521 -				if (opcode & (1 << 22))
 111.522 -					*dest++ = 'l';
 111.523 -				break;
 111.524 -			case 'A':
 111.525 -				if ((opcode & 0x012f0000) == 0x010f0000)
 111.526 -				{
 111.527 -					int adr = offset + 8;
 111.528 -					int add = (opcode & 0xff) << 2;
 111.529 -					if (opcode & (1 << 23))
 111.530 -						adr += add;
 111.531 -					else
 111.532 -						adr -= add;
 111.533 -					*dest++ = '$';
 111.534 -					addHex(dest, 32, adr);
 111.535 -				}
 111.536 -				else
 111.537 -				{
 111.538 -					*dest++ = '[';
 111.539 -					dest	= addStr(dest, regs[(opcode >> 16) & 15]);
 111.540 -					if (!(opcode & (1 << 24)))
 111.541 -						*dest++ = ']';
 111.542 -					int off = (opcode & 0xff) << 2;
 111.543 -					if (off)
 111.544 -					{
 111.545 -						dest = addStr(dest, ", ");
 111.546 -						if (!(opcode & (1 << 23)))
 111.547 -							*dest++ = '-';
 111.548 -						dest = addStr(dest, "#0x");
 111.549 -						dest = addHex(dest, 0, off);
 111.550 -					}
 111.551 -					if (opcode & (1 << 24))
 111.552 -					{
 111.553 -						*dest++ = ']';
 111.554 -						if (opcode & (1 << 21))
 111.555 -							*dest++ = '!';
 111.556 -					}
 111.557 -				}
 111.558 -				break;
 111.559 -			}
 111.560 -			src++;
 111.561 -		}
 111.562 -	}
 111.563 -	*dest++ = 0;
 111.564 -
 111.565 -	return 4;
 111.566 -}
 111.567 -
 111.568 -int disThumb(u32 offset, char *dest, int flags)
 111.569 -{
 111.570 -	u32 opcode = debuggerReadHalfWord(offset);
 111.571 -
 111.572 -	const Opcodes *sp = thumbOpcodes;
 111.573 -	int ret = 2;
 111.574 -	while (sp->cval != (opcode & sp->mask))
 111.575 -		sp++;
 111.576 -
 111.577 -	if (flags & DIS_VIEW_ADDRESS)
 111.578 -	{
 111.579 -		dest	= addHex(dest, 32, offset);
 111.580 -		*dest++ = ' ';
 111.581 -	}
 111.582 -	if (flags & DIS_VIEW_CODE)
 111.583 -	{
 111.584 -		dest	= addHex(dest, 16, opcode);
 111.585 -		*dest++ = ' ';
 111.586 -	}
 111.587 -
 111.588 -	const char *src = sp->mnemonic;
 111.589 -	while (*src)
 111.590 -	{
 111.591 -		if (*src != '%')
 111.592 -			*dest++ = *src++;
 111.593 -		else
 111.594 -		{
 111.595 -			src++;
 111.596 -			switch (*src)
 111.597 -			{
 111.598 -			case 'r':
 111.599 -				src++;
 111.600 -				dest = addStr(dest, regs[(opcode >> (*src - '0')) & 7]);
 111.601 -				break;
 111.602 -			case 'o':
 111.603 -				dest = addStr(dest, "#0x");
 111.604 -				{
 111.605 -					int val = (opcode >> 6) & 0x1f;
 111.606 -					dest = addHex(dest, 8, val);
 111.607 -				}
 111.608 -				break;
 111.609 -			case 'p':
 111.610 -				dest = addStr(dest, "#0x");
 111.611 -				{
 111.612 -					int val = (opcode >> 6) & 0x1f;
 111.613 -					if (!(opcode & (1 << 12)))
 111.614 -						val <<= 2;
 111.615 -					dest = addHex(dest, 0, val);
 111.616 -				}
 111.617 -				break;
 111.618 -			case 'e':
 111.619 -				dest = addStr(dest, "#0x");
 111.620 -				dest = addHex(dest, 0, ((opcode >> 6) & 0x1f) << 1);
 111.621 -				break;
 111.622 -			case 'i':
 111.623 -				dest = addStr(dest, "#0x");
 111.624 -				dest = addHex(dest, 0, (opcode >> 6) & 7);
 111.625 -				break;
 111.626 -			case 'h':
 111.627 -			{
 111.628 -				src++;
 111.629 -				int reg = (opcode >> (*src - '0')) & 7;
 111.630 -				src++;
 111.631 -				if (opcode & (1 << (*src - '0')))
 111.632 -					reg += 8;
 111.633 -				dest = addStr(dest, regs[reg]);
 111.634 -			}
 111.635 -			break;
 111.636 -			case 'O':
 111.637 -				dest = addStr(dest, "#0x");
 111.638 -				dest = addHex(dest, 0, (opcode & 0xff));
 111.639 -				break;
 111.640 -			case 'I':
 111.641 -				*dest++ = '$';
 111.642 -				dest	= addHex(dest, 32, (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
 111.643 -				break;
 111.644 -			case 'J':
 111.645 -			{
 111.646 -				u32 value = debuggerReadMemory((offset & 0xfffffffc) + 4 +
 111.647 -				                               ((opcode & 0xff) << 2));
 111.648 -				*dest++ = '$';
 111.649 -				dest	= addHex(dest, 32, value);
 111.650 -				const char *s = elfGetAddressSymbol(value);
 111.651 -				if (*s)
 111.652 -				{
 111.653 -					*dest++ = ' ';
 111.654 -					dest	= addStr(dest, s);
 111.655 -				}
 111.656 -			}
 111.657 -			break;
 111.658 -			case 'K':
 111.659 -			{
 111.660 -				u32 value = (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2);
 111.661 -				*dest++ = '$';
 111.662 -				dest	= addHex(dest, 32, value);
 111.663 -				const char *s = elfGetAddressSymbol(value);
 111.664 -				if (*s)
 111.665 -				{
 111.666 -					*dest++ = ' ';
 111.667 -					dest	= addStr(dest, s);
 111.668 -				}
 111.669 -			}
 111.670 -			break;
 111.671 -			case 'b':
 111.672 -				if (opcode & (1 << 10))
 111.673 -					*dest++ = 'b';
 111.674 -				break;
 111.675 -			case 'B':
 111.676 -				if (opcode & (1 << 12))
 111.677 -					*dest++ = 'b';
 111.678 -				break;
 111.679 -			case 'w':
 111.680 -				dest = addStr(dest, "#0x");
 111.681 -				dest = addHex(dest, 0, (opcode & 0xff) << 2);
 111.682 -				break;
 111.683 -			case 'W':
 111.684 -				*dest++ = '$';
 111.685 -				{
 111.686 -					int add = opcode & 0xff;
 111.687 -					if (add & 0x80)
 111.688 -						add |= 0xffffff00;
 111.689 -					dest = addHex(dest, 32, (offset & 0xfffffffe) + 4 + (add << 1));
 111.690 -				}
 111.691 -				break;
 111.692 -			case 'c':
 111.693 -				dest = addStr(dest, conditions[(opcode >> 8) & 15]);
 111.694 -				break;
 111.695 -			case 's':
 111.696 -				if (opcode & (1 << 7))
 111.697 -					*dest++ = '-';
 111.698 -				dest = addStr(dest, "#0x");
 111.699 -				dest = addHex(dest, 0, (opcode & 0x7f) << 2);
 111.700 -				break;
 111.701 -			case 'l':
 111.702 -			{
 111.703 -				int rlst	  = opcode & 0xff;
 111.704 -				int msk		  = 0;
 111.705 -				int not_first = 0;
 111.706 -				while (msk < 8)
 111.707 -				{
 111.708 -					if (rlst & (1 << msk))
 111.709 -					{
 111.710 -						int fr = msk;
 111.711 -						while (rlst & (1 << msk))
 111.712 -							msk++;
 111.713 -						int to = msk - 1;
 111.714 -						if (not_first)
 111.715 -							*dest++ = ',';
 111.716 -						dest = addStr(dest, regs[fr]);
 111.717 -						if (fr != to)
 111.718 -						{
 111.719 -							if (fr == to - 1)
 111.720 -								*dest++ = ',';
 111.721 -							else
 111.722 -								*dest++ = '-';
 111.723 -							dest = addStr(dest, regs[to]);
 111.724 -						}
 111.725 -						not_first = 1;
 111.726 -					}
 111.727 -					else
 111.728 -						msk++;
 111.729 -				}
 111.730 -			}
 111.731 -			break;
 111.732 -			case 'm':
 111.733 -				*dest++ = '$';
 111.734 -				dest	= addHex(dest, 8, opcode & 0xff);
 111.735 -				break;
 111.736 -			case 'Z':
 111.737 -				*dest++ = '$';
 111.738 -				dest	= addHex(dest, 16, (opcode & 0x7ff) << 1);
 111.739 -				break;
 111.740 -			case 'a':
 111.741 -				*dest++ = '$';
 111.742 -				{
 111.743 -					int add = opcode & 0x07ff;
 111.744 -					if (add & 0x400)
 111.745 -						add |= 0xfffff800;
 111.746 -					add <<= 1;
 111.747 -					dest  = addHex(dest, 32, offset + 4 + add);
 111.748 -				}
 111.749 -				break;
 111.750 -			case 'A':
 111.751 -			{
 111.752 -				int nopcode = debuggerReadHalfWord(offset + 2);
 111.753 -				int add		= opcode & 0x7ff;
 111.754 -				if (add & 0x400)
 111.755 -					add |= 0xfff800;
 111.756 -				add		= (add << 12) | ((nopcode & 0x7ff) << 1);
 111.757 -				*dest++ = '$';
 111.758 -				dest	= addHex(dest, 32, offset + 4 + add);
 111.759 -				const char *s = elfGetAddressSymbol(offset + 4 + add);
 111.760 -				if (*s)
 111.761 -				{
 111.762 -					*dest++ = ' ';
 111.763 -					*dest++ = '(';
 111.764 -					dest	= addStr(dest, s);
 111.765 -					*dest++ = ')';
 111.766 -				}
 111.767 -				ret = 4;
 111.768 -			}
 111.769 -			break;
 111.770 -			}
 111.771 -			src++;
 111.772 -		}
 111.773 -	}
 111.774 -	*dest++ = 0;
 111.775 -	return ret;
 111.776 -}
 111.777 -
   112.1 --- a/src/gba/armdis.h	Sat Mar 03 10:54:39 2012 -0600
   112.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.3 @@ -1,14 +0,0 @@
   112.4 -#ifndef VBA_GBA_ARMDIS_H
   112.5 -#define VBA_GBA_ARMDIS_H
   112.6 -
   112.7 -#if _MSC_VER > 1000
   112.8 -#pragma once
   112.9 -#endif // _MSC_VER > 1000
  112.10 -
  112.11 -#define DIS_VIEW_ADDRESS 1
  112.12 -#define DIS_VIEW_CODE 2
  112.13 -
  112.14 -int disThumb(u32 offset, char *dest, int flags);
  112.15 -int disArm(u32 offset, char *dest, int flags);
  112.16 -
  112.17 -#endif // VBA_GBA_ARMDIS_H
   113.1 --- a/src/gba/bios.cpp	Sat Mar 03 10:54:39 2012 -0600
   113.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.3 @@ -1,1278 +0,0 @@
   113.4 -#include <cmath>
   113.5 -#include <cstdlib>
   113.6 -#include <cstring>
   113.7 -
   113.8 -#include "bios.h"
   113.9 -#include "../common/System.h"
  113.10 -#include "GBA.h"
  113.11 -#include "GBACheats.h" // FIXME: SDL build requires this
  113.12 -#include "GBAinline.h"
  113.13 -#include "GBAGlobals.h"
  113.14 -
  113.15 -s16 sineTable[256] = {
  113.16 -	(s16)0x0000, (s16)0x0192, (s16)0x0323, (s16)0x04B5, (s16)0x0645, (s16)0x07D5, (s16)0x0964, (s16)0x0AF1,
  113.17 -	(s16)0x0C7C, (s16)0x0E05, (s16)0x0F8C, (s16)0x1111, (s16)0x1294, (s16)0x1413, (s16)0x158F, (s16)0x1708,
  113.18 -	(s16)0x187D, (s16)0x19EF, (s16)0x1B5D, (s16)0x1CC6, (s16)0x1E2B, (s16)0x1F8B, (s16)0x20E7, (s16)0x223D,
  113.19 -	(s16)0x238E, (s16)0x24DA, (s16)0x261F, (s16)0x275F, (s16)0x2899, (s16)0x29CD, (s16)0x2AFA, (s16)0x2C21,
  113.20 -	(s16)0x2D41, (s16)0x2E5A, (s16)0x2F6B, (s16)0x3076, (s16)0x3179, (s16)0x3274, (s16)0x3367, (s16)0x3453,
  113.21 -	(s16)0x3536, (s16)0x3612, (s16)0x36E5, (s16)0x37AF, (s16)0x3871, (s16)0x392A, (s16)0x39DA, (s16)0x3A82,
  113.22 -	(s16)0x3B20, (s16)0x3BB6, (s16)0x3C42, (s16)0x3CC5, (s16)0x3D3E, (s16)0x3DAE, (s16)0x3E14, (s16)0x3E71,
  113.23 -	(s16)0x3EC5, (s16)0x3F0E, (s16)0x3F4E, (s16)0x3F84, (s16)0x3FB1, (s16)0x3FD3, (s16)0x3FEC, (s16)0x3FFB,
  113.24 -	(s16)0x4000, (s16)0x3FFB, (s16)0x3FEC, (s16)0x3FD3, (s16)0x3FB1, (s16)0x3F84, (s16)0x3F4E, (s16)0x3F0E,
  113.25 -	(s16)0x3EC5, (s16)0x3E71, (s16)0x3E14, (s16)0x3DAE, (s16)0x3D3E, (s16)0x3CC5, (s16)0x3C42, (s16)0x3BB6,
  113.26 -	(s16)0x3B20, (s16)0x3A82, (s16)0x39DA, (s16)0x392A, (s16)0x3871, (s16)0x37AF, (s16)0x36E5, (s16)0x3612,
  113.27 -	(s16)0x3536, (s16)0x3453, (s16)0x3367, (s16)0x3274, (s16)0x3179, (s16)0x3076, (s16)0x2F6B, (s16)0x2E5A,
  113.28 -	(s16)0x2D41, (s16)0x2C21, (s16)0x2AFA, (s16)0x29CD, (s16)0x2899, (s16)0x275F, (s16)0x261F, (s16)0x24DA,
  113.29 -	(s16)0x238E, (s16)0x223D, (s16)0x20E7, (s16)0x1F8B, (s16)0x1E2B, (s16)0x1CC6, (s16)0x1B5D, (s16)0x19EF,
  113.30 -	(s16)0x187D, (s16)0x1708, (s16)0x158F, (s16)0x1413, (s16)0x1294, (s16)0x1111, (s16)0x0F8C, (s16)0x0E05,
  113.31 -	(s16)0x0C7C, (s16)0x0AF1, (s16)0x0964, (s16)0x07D5, (s16)0x0645, (s16)0x04B5, (s16)0x0323, (s16)0x0192,
  113.32 -	(s16)0x0000, (s16)0xFE6E, (s16)0xFCDD, (s16)0xFB4B, (s16)0xF9BB, (s16)0xF82B, (s16)0xF69C, (s16)0xF50F,
  113.33 -	(s16)0xF384, (s16)0xF1FB, (s16)0xF074, (s16)0xEEEF, (s16)0xED6C, (s16)0xEBED, (s16)0xEA71, (s16)0xE8F8,
  113.34 -	(s16)0xE783, (s16)0xE611, (s16)0xE4A3, (s16)0xE33A, (s16)0xE1D5, (s16)0xE075, (s16)0xDF19, (s16)0xDDC3,
  113.35 -	(s16)0xDC72, (s16)0xDB26, (s16)0xD9E1, (s16)0xD8A1, (s16)0xD767, (s16)0xD633, (s16)0xD506, (s16)0xD3DF,
  113.36 -	(s16)0xD2BF, (s16)0xD1A6, (s16)0xD095, (s16)0xCF8A, (s16)0xCE87, (s16)0xCD8C, (s16)0xCC99, (s16)0xCBAD,
  113.37 -	(s16)0xCACA, (s16)0xC9EE, (s16)0xC91B, (s16)0xC851, (s16)0xC78F, (s16)0xC6D6, (s16)0xC626, (s16)0xC57E,
  113.38 -	(s16)0xC4E0, (s16)0xC44A, (s16)0xC3BE, (s16)0xC33B, (s16)0xC2C2, (s16)0xC252, (s16)0xC1EC, (s16)0xC18F,
  113.39 -	(s16)0xC13B, (s16)0xC0F2, (s16)0xC0B2, (s16)0xC07C, (s16)0xC04F, (s16)0xC02D, (s16)0xC014, (s16)0xC005,
  113.40 -	(s16)0xC000, (s16)0xC005, (s16)0xC014, (s16)0xC02D, (s16)0xC04F, (s16)0xC07C, (s16)0xC0B2, (s16)0xC0F2,
  113.41 -	(s16)0xC13B, (s16)0xC18F, (s16)0xC1EC, (s16)0xC252, (s16)0xC2C2, (s16)0xC33B, (s16)0xC3BE, (s16)0xC44A,
  113.42 -	(s16)0xC4E0, (s16)0xC57E, (s16)0xC626, (s16)0xC6D6, (s16)0xC78F, (s16)0xC851, (s16)0xC91B, (s16)0xC9EE,
  113.43 -	(s16)0xCACA, (s16)0xCBAD, (s16)0xCC99, (s16)0xCD8C, (s16)0xCE87, (s16)0xCF8A, (s16)0xD095, (s16)0xD1A6,
  113.44 -	(s16)0xD2BF, (s16)0xD3DF, (s16)0xD506, (s16)0xD633, (s16)0xD767, (s16)0xD8A1, (s16)0xD9E1, (s16)0xDB26,
  113.45 -	(s16)0xDC72, (s16)0xDDC3, (s16)0xDF19, (s16)0xE075, (s16)0xE1D5, (s16)0xE33A, (s16)0xE4A3, (s16)0xE611,
  113.46 -	(s16)0xE783, (s16)0xE8F8, (s16)0xEA71, (s16)0xEBED, (s16)0xED6C, (s16)0xEEEF, (s16)0xF074, (s16)0xF1FB,
  113.47 -	(s16)0xF384, (s16)0xF50F, (s16)0xF69C, (s16)0xF82B, (s16)0xF9BB, (s16)0xFB4B, (s16)0xFCDD, (s16)0xFE6E
  113.48 -};
  113.49 -
  113.50 -void BIOS_ArcTan()
  113.51 -{
  113.52 -#ifdef GBA_LOGGING
  113.53 -	if (systemVerbose & VERBOSE_SWI)
  113.54 -	{
  113.55 -		log("ArcTan: %08x (VCOUNT=%2d)\n",
  113.56 -		    reg[0].I,
  113.57 -		    VCOUNT);
  113.58 -	}
  113.59 -#endif
  113.60 -
  113.61 -	s32 a = -((s32)(reg[0].I * reg[0].I)) >> 14;
  113.62 -	s32 b = ((0xA9 * a) >> 14) + 0x390;
  113.63 -	b        = ((b * a) >> 14) + 0x91C;
  113.64 -	b        = ((b * a) >> 14) + 0xFB6;
  113.65 -	b        = ((b * a) >> 14) + 0x16AA;
  113.66 -	b        = ((b * a) >> 14) + 0x2081;
  113.67 -	b        = ((b * a) >> 14) + 0x3651;
  113.68 -	b        = ((b * a) >> 14) + 0xA2F9;
  113.69 -	reg[0].I = (reg[0].I * b) >> 16;
  113.70 -
  113.71 -#ifdef GBA_LOGGING
  113.72 -	if (systemVerbose & VERBOSE_SWI)
  113.73 -	{
  113.74 -		log("ArcTan: return=%08x\n",
  113.75 -		    reg[0].I);
  113.76 -	}
  113.77 -#endif
  113.78 -}
  113.79 -
  113.80 -void BIOS_ArcTan2()
  113.81 -{
  113.82 -#ifdef GBA_LOGGING
  113.83 -	if (systemVerbose & VERBOSE_SWI)
  113.84 -	{
  113.85 -		log("ArcTan2: %08x,%08x (VCOUNT=%2d)\n",
  113.86 -		    reg[0].I,
  113.87 -		    reg[1].I,
  113.88 -		    VCOUNT);
  113.89 -	}
  113.90 -#endif
  113.91 -
  113.92 -	s16 x = reg[0].I;
  113.93 -	s16 y = reg[1].I;
  113.94 -
  113.95 -	if (y == 0)
  113.96 -	{
  113.97 -		reg[0].I = 0x8000 & x;
  113.98 -		reg[3].I = 0x170;
  113.99 -	}
 113.100 -	else
 113.101 -	{
 113.102 -		if (x == 0)
 113.103 -		{
 113.104 -			reg[0].I = (0x8000 & y) + 0x4000;
 113.105 -			reg[3].I = 0x170;
 113.106 -		}
 113.107 -		else
 113.108 -		{
 113.109 -			if (abs(x) > abs(y))
 113.110 -			{
 113.111 -				reg[1].I = x;
 113.112 -				reg[0].I = y << 14;
 113.113 -				BIOS_Div();
 113.114 -				BIOS_ArcTan();
 113.115 -				if (x < 0)
 113.116 -					reg[0].I = 0x8000 + reg[0].I;
 113.117 -				else
 113.118 -					reg[0].I = ((y & 0x8000) << 1) + reg[0].I;
 113.119 -				reg[3].I = 0x170;
 113.120 -			}
 113.121 -			else
 113.122 -			{
 113.123 -				reg[0].I = x << 14;
 113.124 -				BIOS_Div();
 113.125 -				BIOS_ArcTan();
 113.126 -				reg[0].I = (0x4000 + (y & 0x8000)) - reg[0].I;
 113.127 -				reg[3].I = 0x170;
 113.128 -			}
 113.129 -		}
 113.130 -	}
 113.131 -
 113.132 -#ifdef GBA_LOGGING
 113.133 -	if (systemVerbose & VERBOSE_SWI)
 113.134 -	{
 113.135 -		log("ArcTan2: return=%08x\n",
 113.136 -		    reg[0].I);
 113.137 -	}
 113.138 -#endif
 113.139 -}
 113.140 -
 113.141 -void BIOS_BitUnPack()
 113.142 -{
 113.143 -#ifdef GBA_LOGGING
 113.144 -	if (systemVerbose & VERBOSE_SWI)
 113.145 -	{
 113.146 -		log("BitUnPack: %08x,%08x,%08x (VCOUNT=%2d)\n",
 113.147 -		    reg[0].I,
 113.148 -		    reg[1].I,
 113.149 -		    reg[2].I,
 113.150 -		    VCOUNT);
 113.151 -	}
 113.152 -#endif
 113.153 -
 113.154 -	u32 source = reg[0].I;
 113.155 -	u32 dest   = reg[1].I;
 113.156 -	u32 header = reg[2].I;
 113.157 -
 113.158 -	int len = CPUReadHalfWord(header);
 113.159 -	// check address
 113.160 -	int bits    = CPUReadByte(header+2);
 113.161 -	int revbits = 8 - bits;
 113.162 -	// u32 value = 0;
 113.163 -	u32  base    = CPUReadMemory(header+4);
 113.164 -	bool addBase = (base & 0x80000000) ? true : false;
 113.165 -	base &= 0x7fffffff;
 113.166 -	int dataSize = CPUReadByte(header+3);
 113.167 -
 113.168 -	int data = 0;
 113.169 -	int bitwritecount = 0;
 113.170 -	while (1)
 113.171 -	{
 113.172 -		len -= 1;
 113.173 -		if (len < 0)
 113.174 -			break;
 113.175 -		int mask = 0xff >> revbits;
 113.176 -		u8  b    = CPUReadByte(source);
 113.177 -		source++;
 113.178 -		int bitcount = 0;
 113.179 -		while (1)
 113.180 -		{
 113.181 -			if (bitcount >= 8)
 113.182 -				break;
 113.183 -			u32 d    = b & mask;
 113.184 -			u32 temp = d >> bitcount;
 113.185 -			if (!temp && addBase)
 113.186 -			{
 113.187 -				temp += base;
 113.188 -			}
 113.189 -			data |= temp << bitwritecount;
 113.190 -			bitwritecount += dataSize;
 113.191 -			if (bitwritecount >= 32)
 113.192 -			{
 113.193 -				CPUWriteMemory(dest, data);
 113.194 -				dest += 4;
 113.195 -				data  = 0;
 113.196 -				bitwritecount = 0;
 113.197 -			}
 113.198 -			mask    <<= bits;
 113.199 -			bitcount += bits;
 113.200 -		}
 113.201 -	}
 113.202 -}
 113.203 -
 113.204 -void BIOS_BgAffineSet()
 113.205 -{
 113.206 -#ifdef GBA_LOGGING
 113.207 -	if (systemVerbose & VERBOSE_SWI)
 113.208 -	{
 113.209 -		log("BgAffineSet: %08x,%08x,%08x (VCOUNT=%2d)\n",
 113.210 -		    reg[0].I,
 113.211 -		    reg[1].I,
 113.212 -		    reg[2].I,
 113.213 -		    VCOUNT);
 113.214 -	}
 113.215 -#endif
 113.216 -
 113.217 -	u32 src  = reg[0].I;
 113.218 -	u32 dest = reg[1].I;
 113.219 -	int num  = reg[2].I;
 113.220 -
 113.221 -	for (int i = 0; i < num; i++)
 113.222 -	{
 113.223 -		s32 cx = CPUReadMemory(src);
 113.224 -		src += 4;
 113.225 -		s32 cy = CPUReadMemory(src);
 113.226 -		src += 4;
 113.227 -		s16 dispx = CPUReadHalfWord(src);
 113.228 -		src += 2;
 113.229 -		s16 dispy = CPUReadHalfWord(src);
 113.230 -		src += 2;
 113.231 -		s16 rx = CPUReadHalfWord(src);
 113.232 -		src += 2;
 113.233 -		s16 ry = CPUReadHalfWord(src);
 113.234 -		src += 2;
 113.235 -		u16 theta = CPUReadHalfWord(src)>>8;
 113.236 -		src += 4; // keep structure alignment
 113.237 -		s32 a = (s32)sineTable[(theta+0x40)&255];
 113.238 -		s32 b = (s32)sineTable[theta];
 113.239 -
 113.240 -		s16 dx  =  (s16)((rx * a)>>14);
 113.241 -		s16 dmx = (s16)((rx * b)>>14);
 113.242 -		s16 dy  =  (s16)((ry * b)>>14);
 113.243 -		s16 dmy = (s16)((ry * a)>>14);
 113.244 -
 113.245 -		CPUWriteHalfWord(dest, dx);
 113.246 -		dest += 2;
 113.247 -		CPUWriteHalfWord(dest, -dmx);
 113.248 -		dest += 2;
 113.249 -		CPUWriteHalfWord(dest, dy);
 113.250 -		dest += 2;
 113.251 -		CPUWriteHalfWord(dest, dmy);
 113.252 -		dest += 2;
 113.253 -
 113.254 -		s32 startx = cx - dx * dispx + dmx * dispy;
 113.255 -		s32 starty = cy - dy * dispx - dmy * dispy;
 113.256 -
 113.257 -		CPUWriteMemory(dest, startx);
 113.258 -		dest += 4;
 113.259 -		CPUWriteMemory(dest, starty);
 113.260 -		dest += 4;
 113.261 -	}
 113.262 -}
 113.263 -
 113.264 -void BIOS_CpuSet()
 113.265 -{
 113.266 -#ifdef GBA_LOGGING
 113.267 -	if (systemVerbose & VERBOSE_SWI)
 113.268 -	{
 113.269 -		log("CpuSet: 0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I,
 113.270 -		    reg[2].I, VCOUNT);
 113.271 -	}
 113.272 -#endif
 113.273 -
 113.274 -	u32 source = reg[0].I;
 113.275 -	u32 dest   = reg[1].I;
 113.276 -	u32 cnt    = reg[2].I;
 113.277 -
 113.278 -	if (((source & 0xe000000) == 0) ||
 113.279 -	    ((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0)
 113.280 -		return;
 113.281 -
 113.282 -	int count = cnt & 0x1FFFFF;
 113.283 -
 113.284 -	// 32-bit ?
 113.285 -	if ((cnt >> 26) & 1)
 113.286 -	{
 113.287 -		// needed for 32-bit mode!
 113.288 -		source &= 0xFFFFFFFC;
 113.289 -		dest   &= 0xFFFFFFFC;
 113.290 -		// fill ?
 113.291 -		if ((cnt >> 24) & 1)
 113.292 -		{
 113.293 -			u32 value = CPUReadMemory(source);
 113.294 -			while (count)
 113.295 -			{
 113.296 -				CPUWriteMemory(dest, value);
 113.297 -				dest += 4;
 113.298 -				count--;
 113.299 -			}
 113.300 -		}
 113.301 -		else
 113.302 -		{
 113.303 -			// copy
 113.304 -			while (count)
 113.305 -			{
 113.306 -				CPUWriteMemory(dest, CPUReadMemory(source));
 113.307 -				source += 4;
 113.308 -				dest   += 4;
 113.309 -				count--;
 113.310 -			}
 113.311 -		}
 113.312 -	}
 113.313 -	else
 113.314 -	{
 113.315 -		// 16-bit fill?
 113.316 -		if ((cnt >> 24) & 1)
 113.317 -		{
 113.318 -			u16 value = CPUReadHalfWord(source);
 113.319 -			while (count)
 113.320 -			{
 113.321 -				CPUWriteHalfWord(dest, value);
 113.322 -				dest += 2;
 113.323 -				count--;
 113.324 -			}
 113.325 -		}
 113.326 -		else
 113.327 -		{
 113.328 -			// copy
 113.329 -			while (count)
 113.330 -			{
 113.331 -				CPUWriteHalfWord(dest, CPUReadHalfWord(source));
 113.332 -				source += 2;
 113.333 -				dest   += 2;
 113.334 -				count--;
 113.335 -			}
 113.336 -		}
 113.337 -	}
 113.338 -}
 113.339 -
 113.340 -void BIOS_CpuFastSet()
 113.341 -{
 113.342 -#ifdef GBA_LOGGING
 113.343 -	if (systemVerbose & VERBOSE_SWI)
 113.344 -	{
 113.345 -		log("CpuFastSet: 0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I,
 113.346 -		    reg[2].I, VCOUNT);
 113.347 -	}
 113.348 -#endif
 113.349 -
 113.350 -	u32 source = reg[0].I;
 113.351 -	u32 dest   = reg[1].I;
 113.352 -	u32 cnt    = reg[2].I;
 113.353 -
 113.354 -	if (((source & 0xe000000) == 0) ||
 113.355 -	    ((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0)
 113.356 -		return;
 113.357 -
 113.358 -	// needed for 32-bit mode!
 113.359 -	source &= 0xFFFFFFFC;
 113.360 -	dest   &= 0xFFFFFFFC;
 113.361 -
 113.362 -	int count = cnt & 0x1FFFFF;
 113.363 -
 113.364 -	// fill?
 113.365 -	if ((cnt >> 24) & 1)
 113.366 -	{
 113.367 -		while (count > 0)
 113.368 -		{
 113.369 -			// BIOS always transfers 32 bytes at a time
 113.370 -			u32 value = CPUReadMemory(source);
 113.371 -			for (int i = 0; i < 8; i++)
 113.372 -			{
 113.373 -				CPUWriteMemory(dest, value);
 113.374 -				dest += 4;
 113.375 -			}
 113.376 -			count -= 8;
 113.377 -		}
 113.378 -	}
 113.379 -	else
 113.380 -	{
 113.381 -		// copy
 113.382 -		while (count > 0)
 113.383 -		{
 113.384 -			// BIOS always transfers 32 bytes at a time
 113.385 -			for (int i = 0; i < 8; i++)
 113.386 -			{
 113.387 -				CPUWriteMemory(dest, CPUReadMemory(source));
 113.388 -				source += 4;
 113.389 -				dest   += 4;
 113.390 -			}
 113.391 -			count -= 8;
 113.392 -		}
 113.393 -	}
 113.394 -}
 113.395 -
 113.396 -void BIOS_Diff8bitUnFilterWram()
 113.397 -{
 113.398 -#ifdef GBA_LOGGING
 113.399 -	if (systemVerbose & VERBOSE_SWI)
 113.400 -	{
 113.401 -		log("Diff8bitUnFilterWram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I,
 113.402 -		    reg[1].I, VCOUNT);
 113.403 -	}
 113.404 -#endif
 113.405 -
 113.406 -	u32 source = reg[0].I;
 113.407 -	u32 dest   = reg[1].I;
 113.408 -
 113.409 -	u32 header = CPUReadMemory(source);
 113.410 -	source += 4;
 113.411 -
 113.412 -	if (((source & 0xe000000) == 0) ||
 113.413 -	    ((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0))
 113.414 -		return;
 113.415 -
 113.416 -	int len = header >> 8;
 113.417 -
 113.418 -	u8 data = CPUReadByte(source++);
 113.419 -	CPUWriteByte(dest++, data);
 113.420 -	len--;
 113.421 -
 113.422 -	while (len > 0)
 113.423 -	{
 113.424 -		u8 diff = CPUReadByte(source++);
 113.425 -		data += diff;
 113.426 -		CPUWriteByte(dest++, data);
 113.427 -		len--;
 113.428 -	}
 113.429 -}
 113.430 -
 113.431 -void BIOS_Diff8bitUnFilterVram()
 113.432 -{
 113.433 -#ifdef GBA_LOGGING
 113.434 -	if (systemVerbose & VERBOSE_SWI)
 113.435 -	{
 113.436 -		log("Diff8bitUnFilterVram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I,
 113.437 -		    reg[1].I, VCOUNT);
 113.438 -	}
 113.439 -#endif
 113.440 -
 113.441 -	u32 source = reg[0].I;
 113.442 -	u32 dest   = reg[1].I;
 113.443 -
 113.444 -	u32 header = CPUReadMemory(source);
 113.445 -	source += 4;
 113.446 -
 113.447 -	if (((source & 0xe000000) == 0) ||
 113.448 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
 113.449 -		return;
 113.450 -
 113.451 -	int len = header >> 8;
 113.452 -
 113.453 -	u8  data      = CPUReadByte(source++);
 113.454 -	u16 writeData = data;
 113.455 -	int shift     = 8;
 113.456 -	int bytes     = 1;
 113.457 -
 113.458 -	while (len >= 2)
 113.459 -	{
 113.460 -		u8 diff = CPUReadByte(source++);
 113.461 -		data      += diff;
 113.462 -		writeData |= (data << shift);
 113.463 -		bytes++;
 113.464 -		shift += 8;
 113.465 -		if (bytes == 2)
 113.466 -		{
 113.467 -			CPUWriteHalfWord(dest, writeData);
 113.468 -			dest     += 2;
 113.469 -			len      -= 2;
 113.470 -			bytes     = 0;
 113.471 -			writeData = 0;
 113.472 -			shift     = 0;
 113.473 -		}
 113.474 -	}
 113.475 -}
 113.476 -
 113.477 -void BIOS_Diff16bitUnFilter()
 113.478 -{
 113.479 -#ifdef GBA_LOGGING
 113.480 -	if (systemVerbose & VERBOSE_SWI)
 113.481 -	{
 113.482 -		log("Diff16bitUnFilter: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I,
 113.483 -		    reg[1].I, VCOUNT);
 113.484 -	}
 113.485 -#endif
 113.486 -
 113.487 -	u32 source = reg[0].I;
 113.488 -	u32 dest   = reg[1].I;
 113.489 -
 113.490 -	u32 header = CPUReadMemory(source);
 113.491 -	source += 4;
 113.492 -
 113.493 -	if (((source & 0xe000000) == 0) ||
 113.494 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
 113.495 -		return;
 113.496 -
 113.497 -	int len = header >> 8;
 113.498 -
 113.499 -	u16 data = CPUReadHalfWord(source);
 113.500 -	source += 2;
 113.501 -	CPUWriteHalfWord(dest, data);
 113.502 -	dest += 2;
 113.503 -	len  -= 2;
 113.504 -
 113.505 -	while (len >= 2)
 113.506 -	{
 113.507 -		u16 diff = CPUReadHalfWord(source);
 113.508 -		source += 2;
 113.509 -		data   += diff;
 113.510 -		CPUWriteHalfWord(dest, data);
 113.511 -		dest += 2;
 113.512 -		len  -= 2;
 113.513 -	}
 113.514 -}
 113.515 -
 113.516 -void BIOS_Div()
 113.517 -{
 113.518 -#ifdef GBA_LOGGING
 113.519 -	if (systemVerbose & VERBOSE_SWI)
 113.520 -	{
 113.521 -		log("Div: 0x%08x,0x%08x (VCOUNT=%d)\n",
 113.522 -		    reg[0].I,
 113.523 -		    reg[1].I,
 113.524 -		    VCOUNT);
 113.525 -	}
 113.526 -#endif
 113.527 -
 113.528 -	int number = reg[0].I;
 113.529 -	int denom  = reg[1].I;
 113.530 -
 113.531 -	if (denom != 0)
 113.532 -	{
 113.533 -		reg[0].I = number / denom;
 113.534 -		reg[1].I = number % denom;
 113.535 -		s32 temp = (s32)reg[0].I;
 113.536 -		reg[3].I = temp < 0 ? (u32)-temp : (u32)temp;
 113.537 -	}
 113.538 -#ifdef GBA_LOGGING
 113.539 -	if (systemVerbose & VERBOSE_SWI)
 113.540 -	{
 113.541 -		log("Div: return=0x%08x,0x%08x,0x%08x\n",
 113.542 -		    reg[0].I,
 113.543 -		    reg[1].I,
 113.544 -		    reg[3].I);
 113.545 -	}
 113.546 -#endif
 113.547 -}
 113.548 -
 113.549 -void BIOS_DivARM()
 113.550 -{
 113.551 -#ifdef GBA_LOGGING
 113.552 -	if (systemVerbose & VERBOSE_SWI)
 113.553 -	{
 113.554 -		log("DivARM: 0x%08x, (VCOUNT=%d)\n",
 113.555 -		    reg[0].I,
 113.556 -		    VCOUNT);
 113.557 -	}
 113.558 -#endif
 113.559 -
 113.560 -	u32 temp = reg[0].I;
 113.561 -	reg[0].I = reg[1].I;
 113.562 -	reg[1].I = temp;
 113.563 -	BIOS_Div();
 113.564 -}
 113.565 -
 113.566 -void BIOS_HuffUnComp()
 113.567 -{
 113.568 -#ifdef GBA_LOGGING
 113.569 -	if (systemVerbose & VERBOSE_SWI)
 113.570 -	{
 113.571 -		log("HuffUnComp: 0x%08x,0x%08x (VCOUNT=%d)\n",
 113.572 -		    reg[0].I,
 113.573 -		    reg[1].I,
 113.574 -		    VCOUNT);
 113.575 -	}
 113.576 -#endif
 113.577 -
 113.578 -	u32 source = reg[0].I;
 113.579 -	u32 dest   = reg[1].I;
 113.580 -
 113.581 -	u32 header = CPUReadMemory(source);
 113.582 -	source += 4;
 113.583 -
 113.584 -	if (((source & 0xe000000) == 0) ||
 113.585 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
 113.586 -		return;
 113.587 -
 113.588 -	u8 treeSize = CPUReadByte(source++);
 113.589 -
 113.590 -	u32 treeStart = source;
 113.591 -
 113.592 -	source += (treeSize<<1) + 1;
 113.593 -
 113.594 -	int len = header >> 8;
 113.595 -
 113.596 -	u32 mask = 0x80000000;
 113.597 -	u32 data = CPUReadMemory(source);
 113.598 -	source += 4;
 113.599 -
 113.600 -	int  pos         = 0;
 113.601 -	u8   rootNode    = CPUReadByte(treeStart);
 113.602 -	u8   currentNode = rootNode;
 113.603 -	bool writeData   = false;
 113.604 -	int  byteShift   = 0;
 113.605 -	int  byteCount   = 0;
 113.606 -	u32  writeValue  = 0;
 113.607 -
 113.608 -	if ((header & 0x0F) == 8)
 113.609 -	{
 113.610 -		while (len > 0)
 113.611 -		{
 113.612 -			// take left
 113.613 -			if (pos == 0)
 113.614 -				pos++;
 113.615 -			else
 113.616 -				pos += (((currentNode & 0x3F)+1)<<1);
 113.617 -
 113.618 -			if (data & mask)
 113.619 -			{
 113.620 -				// right
 113.621 -				if (currentNode & 0x40)
 113.622 -					writeData = true;
 113.623 -				currentNode = CPUReadByte(treeStart+pos+1);
 113.624 -			}
 113.625 -			else
 113.626 -			{
 113.627 -				// left
 113.628 -				if (currentNode & 0x80)
 113.629 -					writeData = true;
 113.630 -				currentNode = CPUReadByte(treeStart+pos);
 113.631 -			}
 113.632 -
 113.633 -			if (writeData)
 113.634 -			{
 113.635 -				writeValue |= (currentNode << byteShift);
 113.636 -				byteCount++;
 113.637 -				byteShift += 8;
 113.638 -
 113.639 -				pos         = 0;
 113.640 -				currentNode = rootNode;
 113.641 -				writeData   = false;
 113.642 -
 113.643 -				if (byteCount == 4)
 113.644 -				{
 113.645 -					byteCount = 0;
 113.646 -					byteShift = 0;
 113.647 -					CPUWriteMemory(dest, writeValue);
 113.648 -					writeValue = 0;
 113.649 -					dest      += 4;
 113.650 -					len       -= 4;
 113.651 -				}
 113.652 -			}
 113.653 -			mask >>= 1;
 113.654 -			if (mask == 0)
 113.655 -			{
 113.656 -				mask    = 0x80000000;
 113.657 -				data    = CPUReadMemory(source);
 113.658 -				source += 4;
 113.659 -			}
 113.660 -		}
 113.661 -	}
 113.662 -	else
 113.663 -	{
 113.664 -		int halfLen = 0;
 113.665 -		int value   = 0;
 113.666 -		while (len > 0)
 113.667 -		{
 113.668 -			// take left
 113.669 -			if (pos == 0)
 113.670 -				pos++;
 113.671 -			else
 113.672 -				pos += (((currentNode & 0x3F)+1)<<1);
 113.673 -
 113.674 -			if ((data & mask))
 113.675 -			{
 113.676 -				// right
 113.677 -				if (currentNode & 0x40)
 113.678 -					writeData = true;
 113.679 -				currentNode = CPUReadByte(treeStart+pos+1);
 113.680 -			}
 113.681 -			else
 113.682 -			{
 113.683 -				// left
 113.684 -				if (currentNode & 0x80)
 113.685 -					writeData = true;
 113.686 -				currentNode = CPUReadByte(treeStart+pos);
 113.687 -			}
 113.688 -
 113.689 -			if (writeData)
 113.690 -			{
 113.691 -				if (halfLen == 0)
 113.692 -					value |= currentNode;
 113.693 -				else
 113.694 -					value |= (currentNode<<4);
 113.695 -
 113.696 -				halfLen += 4;
 113.697 -				if (halfLen == 8)
 113.698 -				{
 113.699 -					writeValue |= (value << byteShift);
 113.700 -					byteCount++;
 113.701 -					byteShift += 8;
 113.702 -
 113.703 -					halfLen = 0;
 113.704 -					value   = 0;
 113.705 -
 113.706 -					if (byteCount == 4)
 113.707 -					{
 113.708 -						byteCount = 0;
 113.709 -						byteShift = 0;
 113.710 -						CPUWriteMemory(dest, writeValue);
 113.711 -						dest      += 4;
 113.712 -						writeValue = 0;
 113.713 -						len       -= 4;
 113.714 -					}
 113.715 -				}
 113.716 -				pos         = 0;
 113.717 -				currentNode = rootNode;
 113.718 -				writeData   = false;
 113.719 -			}
 113.720 -			mask >>= 1;
 113.721 -			if (mask == 0)
 113.722 -			{
 113.723 -				mask    = 0x80000000;
 113.724 -				data    = CPUReadMemory(source);
 113.725 -				source += 4;
 113.726 -			}
 113.727 -		}
 113.728 -	}
 113.729 -}
 113.730 -
 113.731 -void BIOS_LZ77UnCompVram()
 113.732 -{
 113.733 -#ifdef GBA_LOGGING
 113.734 -	if (systemVerbose & VERBOSE_SWI)
 113.735 -	{
 113.736 -		log("LZ77UnCompVram: 0x%08x,0x%08x (VCOUNT=%d)\n",
 113.737 -		    reg[0].I,
 113.738 -		    reg[1].I,
 113.739 -		    VCOUNT);
 113.740 -	}
 113.741 -#endif
 113.742 -
 113.743 -	u32 source = reg[0].I;
 113.744 -	u32 dest   = reg[1].I;
 113.745 -
 113.746 -	u32 header = CPUReadMemory(source);
 113.747 -	source += 4;
 113.748 -
 113.749 -	if (((source & 0xe000000) == 0) ||
 113.750 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
 113.751 -		return;
 113.752 -
 113.753 -	int byteCount  = 0;
 113.754 -	int byteShift  = 0;
 113.755 -	u32 writeValue = 0;
 113.756 -
 113.757 -	int len = header >> 8;
 113.758 -
 113.759 -	while (len > 0)
 113.760 -	{
 113.761 -		u8 d = CPUReadByte(source++);
 113.762 -
 113.763 -		if (d)
 113.764 -		{
 113.765 -			for (int i = 0; i < 8; i++)
 113.766 -			{
 113.767 -				if (d & 0x80)
 113.768 -				{
 113.769 -					u16 data = CPUReadByte(source++) << 8;
 113.770 -					data |= CPUReadByte(source++);
 113.771 -					int length       = (data >> 12) + 3;
 113.772 -					int offset       = (data & 0x0FFF);
 113.773 -					u32 windowOffset = dest + byteCount - offset - 1;
 113.774 -					for (int i = 0; i < length; i++)
 113.775 -					{
 113.776 -						writeValue |= (CPUReadByte(windowOffset++) << byteShift);
 113.777 -						byteShift  += 8;
 113.778 -						byteCount++;
 113.779 -
 113.780 -						if (byteCount == 2)
 113.781 -						{
 113.782 -							CPUWriteHalfWord(dest, writeValue);
 113.783 -							dest      += 2;
 113.784 -							byteCount  = 0;
 113.785 -							byteShift  = 0;
 113.786 -							writeValue = 0;
 113.787 -						}
 113.788 -						len--;
 113.789 -						if (len == 0)
 113.790 -							return;
 113.791 -					}
 113.792 -				}
 113.793 -				else
 113.794 -				{
 113.795 -					writeValue |= (CPUReadByte(source++) << byteShift);
 113.796 -					byteShift  += 8;
 113.797 -					byteCount++;
 113.798 -					if (byteCount == 2)
 113.799 -					{
 113.800 -						CPUWriteHalfWord(dest, writeValue);
 113.801 -						dest      += 2;
 113.802 -						byteCount  = 0;
 113.803 -						byteShift  = 0;
 113.804 -						writeValue = 0;
 113.805 -					}
 113.806 -					len--;
 113.807 -					if (len == 0)
 113.808 -						return;
 113.809 -				}
 113.810 -				d <<= 1;
 113.811 -			}
 113.812 -		}
 113.813 -		else
 113.814 -		{
 113.815 -			for (int i = 0; i < 8; i++)
 113.816 -			{
 113.817 -				writeValue |= (CPUReadByte(source++) << byteShift);
 113.818 -				byteShift  += 8;
 113.819 -				byteCount++;
 113.820 -				if (byteCount == 2)
 113.821 -				{
 113.822 -					CPUWriteHalfWord(dest, writeValue);
 113.823 -					dest      += 2;
 113.824 -					byteShift  = 0;
 113.825 -					byteCount  = 0;
 113.826 -					writeValue = 0;
 113.827 -				}
 113.828 -				len--;
 113.829 -				if (len == 0)
 113.830 -					return;
 113.831 -			}
 113.832 -		}
 113.833 -	}
 113.834 -}
 113.835 -
 113.836 -void BIOS_LZ77UnCompWram()
 113.837 -{
 113.838 -#ifdef GBA_LOGGING
 113.839 -	if (systemVerbose & VERBOSE_SWI)
 113.840 -	{
 113.841 -		log("LZ77UnCompWram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I,
 113.842 -		    VCOUNT);
 113.843 -	}
 113.844 -#endif
 113.845 -
 113.846 -	u32 source = reg[0].I;
 113.847 -	u32 dest   = reg[1].I;
 113.848 -
 113.849 -	u32 header = CPUReadMemory(source);
 113.850 -	source += 4;
 113.851 -
 113.852 -	if (((source & 0xe000000) == 0) ||
 113.853 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
 113.854 -		return;
 113.855 -
 113.856 -	int len = header >> 8;
 113.857 -
 113.858 -	while (len > 0)
 113.859 -	{
 113.860 -		u8 d = CPUReadByte(source++);
 113.861 -
 113.862 -		if (d)
 113.863 -		{
 113.864 -			for (int i = 0; i < 8; i++)
 113.865 -			{
 113.866 -				if (d & 0x80)
 113.867 -				{
 113.868 -					u16 data = CPUReadByte(source++) << 8;
 113.869 -					data |= CPUReadByte(source++);
 113.870 -					int length       = (data >> 12) + 3;
 113.871 -					int offset       = (data & 0x0FFF);
 113.872 -					u32 windowOffset = dest - offset - 1;
 113.873 -					for (int i = 0; i < length; i++)
 113.874 -					{
 113.875 -						CPUWriteByte(dest++, CPUReadByte(windowOffset++));
 113.876 -						len--;
 113.877 -						if (len == 0)
 113.878 -							return;
 113.879 -					}
 113.880 -				}
 113.881 -				else
 113.882 -				{
 113.883 -					CPUWriteByte(dest++, CPUReadByte(source++));
 113.884 -					len--;
 113.885 -					if (len == 0)
 113.886 -						return;
 113.887 -				}
 113.888 -				d <<= 1;
 113.889 -			}
 113.890 -		}
 113.891 -		else
 113.892 -		{
 113.893 -			for (int i = 0; i < 8; i++)
 113.894 -			{
 113.895 -				CPUWriteByte(dest++, CPUReadByte(source++));
 113.896 -				len--;
 113.897 -				if (len == 0)
 113.898 -					return;
 113.899 -			}
 113.900 -		}
 113.901 -	}
 113.902 -}
 113.903 -
 113.904 -void BIOS_ObjAffineSet()
 113.905 -{
 113.906 -#ifdef GBA_LOGGING
 113.907 -	if (systemVerbose & VERBOSE_SWI)
 113.908 -	{
 113.909 -		log("ObjAffineSet: 0x%08x,0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n",
 113.910 -		    reg[0].I,
 113.911 -		    reg[1].I,
 113.912 -		    reg[2].I,
 113.913 -		    reg[3].I,
 113.914 -		    VCOUNT);
 113.915 -	}
 113.916 -#endif
 113.917 -
 113.918 -	u32 src    = reg[0].I;
 113.919 -	u32 dest   = reg[1].I;
 113.920 -	int num    = reg[2].I;
 113.921 -	int offset = reg[3].I;
 113.922 -
 113.923 -	for (int i = 0; i < num; i++)
 113.924 -	{
 113.925 -		s16 rx = CPUReadHalfWord(src);
 113.926 -		src += 2;
 113.927 -		s16 ry = CPUReadHalfWord(src);
 113.928 -		src += 2;
 113.929 -		u16 theta = CPUReadHalfWord(src)>>8;
 113.930 -		src += 4; // keep structure alignment
 113.931 -
 113.932 -		s32 a = (s32)sineTable[(theta+0x40)&255];
 113.933 -		s32 b = (s32)sineTable[theta];
 113.934 -
 113.935 -		s16 dx  =  (s16)((rx * a)>>14);
 113.936 -		s16 dmx = (s16)((rx * b)>>14);
 113.937 -		s16 dy  =  (s16)((ry * b)>>14);
 113.938 -		s16 dmy = (s16)((ry * a)>>14);
 113.939 -
 113.940 -		CPUWriteHalfWord(dest, dx);
 113.941 -		dest += offset;
 113.942 -		CPUWriteHalfWord(dest, -dmx);
 113.943 -		dest += offset;
 113.944 -		CPUWriteHalfWord(dest, dy);
 113.945 -		dest += offset;
 113.946 -		CPUWriteHalfWord(dest, dmy);
 113.947 -		dest += offset;
 113.948 -	}
 113.949 -}
 113.950 -
 113.951 -void BIOS_RegisterRamReset(u32 flags)
 113.952 -{
 113.953 -	// no need to trace here. this is only called directly from GBA.cpp
 113.954 -	// to emulate bios initialization
 113.955 -
 113.956 -	if (flags)
 113.957 -	{
 113.958 -		if (flags & 0x01)
 113.959 -		{
 113.960 -			// clear work RAM
 113.961 -			memset(workRAM, 0, 0x40000);
 113.962 -		}
 113.963 -		if (flags & 0x02)
 113.964 -		{
 113.965 -			// clear internal RAM
 113.966 -			memset(internalRAM, 0, 0x7e00); // don't clear 0x7e00-0x7fff
 113.967 -		}
 113.968 -		if (flags & 0x04)
 113.969 -		{
 113.970 -			// clear palette RAM
 113.971 -			memset(paletteRAM, 0, 0x400);
 113.972 -		}
 113.973 -		if (flags & 0x08)
 113.974 -		{
 113.975 -			// clear VRAM
 113.976 -			memset(vram, 0, 0x18000);
 113.977 -		}
 113.978 -		if (flags & 0x10)
 113.979 -		{
 113.980 -			// clean OAM
 113.981 -			memset(oam, 0, 0x400);
 113.982 -		}
 113.983 -
 113.984 -		if (flags & 0x80)
 113.985 -		{
 113.986 -			int i;
 113.987 -			for (i = 0; i < 8; i++)
 113.988 -				CPUUpdateRegister(0x200+i*2, 0);
 113.989 -
 113.990 -			CPUUpdateRegister(0x202, 0xFFFF);
 113.991 -
 113.992 -			for (i = 0; i < 8; i++)
 113.993 -				CPUUpdateRegister(0x4+i*2, 0);
 113.994 -
 113.995 -			for (i = 0; i < 16; i++)
 113.996 -				CPUUpdateRegister(0x20+i*2, 0);
 113.997 -
 113.998 -			for (i = 0; i < 24; i++)
 113.999 -				CPUUpdateRegister(0xb0+i*2, 0);
113.1000 -
113.1001 -			CPUUpdateRegister(0x130, 0);
113.1002 -			CPUUpdateRegister(0x20, 0x100);
113.1003 -			CPUUpdateRegister(0x30, 0x100);
113.1004 -			CPUUpdateRegister(0x26, 0x100);
113.1005 -			CPUUpdateRegister(0x36, 0x100);
113.1006 -		}
113.1007 -
113.1008 -		if (flags & 0x20)
113.1009 -		{
113.1010 -			int i;
113.1011 -			for (i = 0; i < 8; i++)
113.1012 -				CPUUpdateRegister(0x110+i*2, 0);
113.1013 -			CPUUpdateRegister(0x134, 0x8000);
113.1014 -			for (i = 0; i < 7; i++)
113.1015 -				CPUUpdateRegister(0x140+i*2, 0);
113.1016 -		}
113.1017 -
113.1018 -		if (flags & 0x40)
113.1019 -		{
113.1020 -			int i;
113.1021 -			CPUWriteByte(0x4000084, 0);
113.1022 -			CPUWriteByte(0x4000084, 0x80);
113.1023 -			CPUWriteMemory(0x4000080, 0x880e0000);
113.1024 -			CPUUpdateRegister(0x88, CPUReadHalfWord(0x4000088)&0x3ff);
113.1025 -			CPUWriteByte(0x4000070, 0x70);
113.1026 -			for (i = 0; i < 8; i++)
113.1027 -				CPUUpdateRegister(0x90+i*2, 0);
113.1028 -			CPUWriteByte(0x4000070, 0);
113.1029 -			for (i = 0; i < 8; i++)
113.1030 -				CPUUpdateRegister(0x90+i*2, 0);
113.1031 -			CPUWriteByte(0x4000084, 0);
113.1032 -		}
113.1033 -	}
113.1034 -}
113.1035 -
113.1036 -void BIOS_RegisterRamReset()
113.1037 -{
113.1038 -#ifdef GBA_LOGGING
113.1039 -	if (systemVerbose & VERBOSE_SWI)
113.1040 -	{
113.1041 -		log("RegisterRamReset: 0x%08x (VCOUNT=%d)\n",
113.1042 -		    reg[0].I,
113.1043 -		    VCOUNT);
113.1044 -	}
113.1045 -#endif
113.1046 -
113.1047 -	BIOS_RegisterRamReset(reg[0].I);
113.1048 -}
113.1049 -
113.1050 -void BIOS_RLUnCompVram()
113.1051 -{
113.1052 -#ifdef GBA_LOGGING
113.1053 -	if (systemVerbose & VERBOSE_SWI)
113.1054 -	{
113.1055 -		log("RLUnCompVram: 0x%08x,0x%08x (VCOUNT=%d)\n",
113.1056 -		    reg[0].I,
113.1057 -		    reg[1].I,
113.1058 -		    VCOUNT);
113.1059 -	}
113.1060 -#endif
113.1061 -
113.1062 -	u32 source = reg[0].I;
113.1063 -	u32 dest   = reg[1].I;
113.1064 -
113.1065 -	u32 header = CPUReadMemory(source);
113.1066 -	source += 4;
113.1067 -
113.1068 -	if (((source & 0xe000000) == 0) ||
113.1069 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
113.1070 -		return;
113.1071 -
113.1072 -	int len        = header >> 8;
113.1073 -	int byteCount  = 0;
113.1074 -	int byteShift  = 0;
113.1075 -	u32 writeValue = 0;
113.1076 -
113.1077 -	while (len > 0)
113.1078 -	{
113.1079 -		u8  d = CPUReadByte(source++);
113.1080 -		int l = d & 0x7F;
113.1081 -		if (d & 0x80)
113.1082 -		{
113.1083 -			u8 data = CPUReadByte(source++);
113.1084 -			l += 3;
113.1085 -			for (int i = 0; i < l; i++)
113.1086 -			{
113.1087 -				writeValue |= (data << byteShift);
113.1088 -				byteShift  += 8;
113.1089 -				byteCount++;
113.1090 -
113.1091 -				if (byteCount == 2)
113.1092 -				{
113.1093 -					CPUWriteHalfWord(dest, writeValue);
113.1094 -					dest      += 2;
113.1095 -					byteCount  = 0;
113.1096 -					byteShift  = 0;
113.1097 -					writeValue = 0;
113.1098 -				}
113.1099 -				len--;
113.1100 -				if (len == 0)
113.1101 -					return;
113.1102 -			}
113.1103 -		}
113.1104 -		else
113.1105 -		{
113.1106 -			l++;
113.1107 -			for (int i = 0; i < l; i++)
113.1108 -			{
113.1109 -				writeValue |= (CPUReadByte(source++) << byteShift);
113.1110 -				byteShift  += 8;
113.1111 -				byteCount++;
113.1112 -				if (byteCount == 2)
113.1113 -				{
113.1114 -					CPUWriteHalfWord(dest, writeValue);
113.1115 -					dest      += 2;
113.1116 -					byteCount  = 0;
113.1117 -					byteShift  = 0;
113.1118 -					writeValue = 0;
113.1119 -				}
113.1120 -				len--;
113.1121 -				if (len == 0)
113.1122 -					return;
113.1123 -			}
113.1124 -		}
113.1125 -	}
113.1126 -}
113.1127 -
113.1128 -void BIOS_RLUnCompWram()
113.1129 -{
113.1130 -#ifdef GBA_LOGGING
113.1131 -	if (systemVerbose & VERBOSE_SWI)
113.1132 -	{
113.1133 -		log("RLUnCompWram: 0x%08x,0x%08x (VCOUNT=%d)\n",
113.1134 -		    reg[0].I,
113.1135 -		    reg[1].I,
113.1136 -		    VCOUNT);
113.1137 -	}
113.1138 -#endif
113.1139 -
113.1140 -	u32 source = reg[0].I;
113.1141 -	u32 dest   = reg[1].I;
113.1142 -
113.1143 -	u32 header = CPUReadMemory(source);
113.1144 -	source += 4;
113.1145 -
113.1146 -	if (((source & 0xe000000) == 0) ||
113.1147 -	    ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
113.1148 -		return;
113.1149 -
113.1150 -	int len = header >> 8;
113.1151 -
113.1152 -	while (len > 0)
113.1153 -	{
113.1154 -		u8  d = CPUReadByte(source++);
113.1155 -		int l = d & 0x7F;
113.1156 -		if (d & 0x80)
113.1157 -		{
113.1158 -			u8 data = CPUReadByte(source++);
113.1159 -			l += 3;
113.1160 -			for (int i = 0; i < l; i++)
113.1161 -			{
113.1162 -				CPUWriteByte(dest++, data);
113.1163 -				len--;
113.1164 -				if (len == 0)
113.1165 -					return;
113.1166 -			}
113.1167 -		}
113.1168 -		else
113.1169 -		{
113.1170 -			l++;
113.1171 -			for (int i = 0; i < l; i++)
113.1172 -			{
113.1173 -				CPUWriteByte(dest++,  CPUReadByte(source++));
113.1174 -				len--;
113.1175 -				if (len == 0)
113.1176 -					return;
113.1177 -			}
113.1178 -		}
113.1179 -	}
113.1180 -}
113.1181 -
113.1182 -void BIOS_SoftReset()
113.1183 -{
113.1184 -#ifdef GBA_LOGGING
113.1185 -	if (systemVerbose & VERBOSE_SWI)
113.1186 -	{
113.1187 -		log("SoftReset: (VCOUNT=%d)\n", VCOUNT);
113.1188 -	}
113.1189 -#endif
113.1190 -
113.1191 -	armState        = true;
113.1192 -	armMode         = 0x1F;
113.1193 -	armIrqEnable    = false;
113.1194 -	C_FLAG          = V_FLAG = N_FLAG = Z_FLAG = false;
113.1195 -	reg[13].I       = 0x03007F00;
113.1196 -	reg[14].I       = 0x00000000;
113.1197 -	reg[16].I       = 0x00000000;
113.1198 -	reg[R13_IRQ].I  = 0x03007FA0;
113.1199 -	reg[R14_IRQ].I  = 0x00000000;
113.1200 -	reg[SPSR_IRQ].I = 0x00000000;
113.1201 -	reg[R13_SVC].I  = 0x03007FE0;
113.1202 -	reg[R14_SVC].I  = 0x00000000;
113.1203 -	reg[SPSR_SVC].I = 0x00000000;
113.1204 -	u8 b = internalRAM[0x7ffa];
113.1205 -
113.1206 -	memset(&internalRAM[0x7e00], 0, 0x200);
113.1207 -
113.1208 -	if (b)
113.1209 -	{
113.1210 -		armNextPC = 0x02000000;
113.1211 -		reg[15].I = 0x02000004;
113.1212 -	}
113.1213 -	else
113.1214 -	{
113.1215 -		armNextPC = 0x08000000;
113.1216 -		reg[15].I = 0x08000004;
113.1217 -	}
113.1218 -}
113.1219 -
113.1220 -void BIOS_Sqrt()
113.1221 -{
113.1222 -#ifdef GBA_LOGGING
113.1223 -	if (systemVerbose & VERBOSE_SWI)
113.1224 -	{
113.1225 -		log("Sqrt: %08x (VCOUNT=%2d)\n",
113.1226 -		    reg[0].I,
113.1227 -		    VCOUNT);
113.1228 -	}
113.1229 -#endif
113.1230 -	reg[0].I = (u32)sqrt((double)reg[0].I);
113.1231 -#ifdef GBA_LOGGING
113.1232 -	if (systemVerbose & VERBOSE_SWI)
113.1233 -	{
113.1234 -		log("Sqrt: return=%08x\n",
113.1235 -		    reg[0].I);
113.1236 -	}
113.1237 -#endif
113.1238 -}
113.1239 -
113.1240 -void BIOS_MidiKey2Freq()
113.1241 -{
113.1242 -#ifdef GBA_LOGGING
113.1243 -	if (systemVerbose & VERBOSE_SWI)
113.1244 -	{
113.1245 -		log("MidiKey2Freq: WaveData=%08x mk=%08x fp=%08x\n",
113.1246 -		    reg[0].I,
113.1247 -		    reg[1].I,
113.1248 -		    reg[2].I);
113.1249 -	}
113.1250 -#endif
113.1251 -	int    freq = CPUReadMemory(reg[0].I+4);
113.1252 -	double tmp;
113.1253 -	tmp      = ((double)(180 - reg[1].I)) - ((double)reg[2].I / 256.f);
113.1254 -	tmp      = pow((double)2.f, tmp / 12.f);
113.1255 -	reg[0].I = (int)((double)freq / tmp);
113.1256 -
113.1257 -#ifdef GBA_LOGGING
113.1258 -	if (systemVerbose & VERBOSE_SWI)
113.1259 -	{
113.1260 -		log("MidiKey2Freq: return %08x\n",
113.1261 -		    reg[0].I);
113.1262 -	}
113.1263 -#endif
113.1264 -}
113.1265 -
113.1266 -void BIOS_SndDriverJmpTableCopy()
113.1267 -{
113.1268 -#ifdef GBA_LOGGING
113.1269 -	if (systemVerbose & VERBOSE_SWI)
113.1270 -	{
113.1271 -		log("SndDriverJmpTableCopy: dest=%08x\n",
113.1272 -		    reg[0].I);
113.1273 -	}
113.1274 -#endif
113.1275 -	for (int i = 0; i < 0x24; i++)
113.1276 -	{
113.1277 -		CPUWriteMemory(reg[0].I, 0x9c);
113.1278 -		reg[0].I += 4;
113.1279 -	}
113.1280 -}
113.1281 -
   114.1 --- a/src/gba/bios.h	Sat Mar 03 10:54:39 2012 -0600
   114.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.3 @@ -1,34 +0,0 @@
   114.4 -#ifndef VBA_BIOS_H
   114.5 -#define VBA_BIOS_H
   114.6 -
   114.7 -#if _MSC_VER > 1000
   114.8 -#pragma once
   114.9 -#endif // _MSC_VER > 1000
  114.10 -
  114.11 -#include "../Port.h"
  114.12 -
  114.13 -extern void BIOS_ArcTan();
  114.14 -extern void BIOS_ArcTan2();
  114.15 -extern void BIOS_BitUnPack();
  114.16 -extern void BIOS_BgAffineSet();
  114.17 -extern void BIOS_CpuSet();
  114.18 -extern void BIOS_CpuFastSet();
  114.19 -extern void BIOS_Diff8bitUnFilterWram();
  114.20 -extern void BIOS_Diff8bitUnFilterVram();
  114.21 -extern void BIOS_Diff16bitUnFilter();
  114.22 -extern void BIOS_Div();
  114.23 -extern void BIOS_DivARM();
  114.24 -extern void BIOS_HuffUnComp();
  114.25 -extern void BIOS_LZ77UnCompVram();
  114.26 -extern void BIOS_LZ77UnCompWram();
  114.27 -extern void BIOS_ObjAffineSet();
  114.28 -extern void BIOS_RegisterRamReset();
  114.29 -extern void BIOS_RegisterRamReset(u32);
  114.30 -extern void BIOS_RLUnCompVram();
  114.31 -extern void BIOS_RLUnCompWram();
  114.32 -extern void BIOS_SoftReset();
  114.33 -extern void BIOS_Sqrt();
  114.34 -extern void BIOS_MidiKey2Freq();
  114.35 -extern void BIOS_SndDriverJmpTableCopy();
  114.36 -
  114.37 -#endif // VBA_BIOS_H
   115.1 --- a/src/gba/elf.cpp	Sat Mar 03 10:54:39 2012 -0600
   115.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.3 @@ -1,3229 +0,0 @@
   115.4 -#include <cstdio>
   115.5 -#include <cstdlib>
   115.6 -#include <cstring>
   115.7 -
   115.8 -#include "../Port.h"
   115.9 -#include "../NLS.h"
  115.10 -#include "../common/System.h" // systemMessage
  115.11 -#include "GBAGlobals.h"
  115.12 -#include "elf.h"
  115.13 -
  115.14 -#define elfReadMemory(addr) \
  115.15 -    READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
  115.16 -
  115.17 -#define DW_TAG_array_type             0x01
  115.18 -#define DW_TAG_enumeration_type       0x04
  115.19 -#define DW_TAG_formal_parameter       0x05
  115.20 -#define DW_TAG_label                  0x0a
  115.21 -#define DW_TAG_lexical_block          0x0b
  115.22 -#define DW_TAG_member                 0x0d
  115.23 -#define DW_TAG_pointer_type           0x0f
  115.24 -#define DW_TAG_reference_type         0x10
  115.25 -#define DW_TAG_compile_unit           0x11
  115.26 -#define DW_TAG_structure_type         0x13
  115.27 -#define DW_TAG_subroutine_type        0x15
  115.28 -#define DW_TAG_typedef                0x16
  115.29 -#define DW_TAG_union_type             0x17
  115.30 -#define DW_TAG_unspecified_parameters 0x18
  115.31 -#define DW_TAG_inheritance            0x1c
  115.32 -#define DW_TAG_inlined_subroutine     0x1d
  115.33 -#define DW_TAG_subrange_type          0x21
  115.34 -#define DW_TAG_base_type              0x24
  115.35 -#define DW_TAG_const_type             0x26
  115.36 -#define DW_TAG_enumerator             0x28
  115.37 -#define DW_TAG_subprogram             0x2e
  115.38 -#define DW_TAG_variable               0x34
  115.39 -#define DW_TAG_volatile_type          0x35
  115.40 -
  115.41 -#define DW_AT_sibling              0x01
  115.42 -#define DW_AT_location             0x02
  115.43 -#define DW_AT_name                 0x03
  115.44 -#define DW_AT_byte_size            0x0b
  115.45 -#define DW_AT_bit_offset           0x0c
  115.46 -#define DW_AT_bit_size             0x0d
  115.47 -#define DW_AT_stmt_list            0x10
  115.48 -#define DW_AT_low_pc               0x11
  115.49 -#define DW_AT_high_pc              0x12
  115.50 -#define DW_AT_language             0x13
  115.51 -#define DW_AT_compdir              0x1b
  115.52 -#define DW_AT_const_value          0x1c
  115.53 -#define DW_AT_containing_type      0x1d
  115.54 -#define DW_AT_inline               0x20
  115.55 -#define DW_AT_producer             0x25
  115.56 -#define DW_AT_prototyped           0x27
  115.57 -#define DW_AT_upper_bound          0x2f
  115.58 -#define DW_AT_abstract_origin      0x31
  115.59 -#define DW_AT_accessibility        0x32
  115.60 -#define DW_AT_artificial           0x34
  115.61 -#define DW_AT_data_member_location 0x38
  115.62 -#define DW_AT_decl_file            0x3a
  115.63 -#define DW_AT_decl_line            0x3b
  115.64 -#define DW_AT_declaration          0x3c
  115.65 -#define DW_AT_encoding             0x3e
  115.66 -#define DW_AT_external             0x3f
  115.67 -#define DW_AT_frame_base           0x40
  115.68 -#define DW_AT_macro_info           0x43
  115.69 -#define DW_AT_specification        0x47
  115.70 -#define DW_AT_type                 0x49
  115.71 -#define DW_AT_virtuality           0x4c
  115.72 -#define DW_AT_vtable_elem_location 0x4d
  115.73 -// DWARF 2.1/3.0 extensions
  115.74 -#define DW_AT_entry_pc             0x52
  115.75 -#define DW_AT_ranges               0x55
  115.76 -// ARM Compiler extensions
  115.77 -#define DW_AT_proc_body            0x2000
  115.78 -#define DW_AT_save_offset          0x2001
  115.79 -#define DW_AT_user_2002            0x2002
  115.80 -// MIPS extensions
  115.81 -#define DW_AT_MIPS_linkage_name    0x2007
  115.82 -
  115.83 -#define DW_FORM_addr      0x01
  115.84 -#define DW_FORM_data2     0x05
  115.85 -#define DW_FORM_data4     0x06
  115.86 -#define DW_FORM_string    0x08
  115.87 -#define DW_FORM_block     0x09
  115.88 -#define DW_FORM_block1    0x0a
  115.89 -#define DW_FORM_data1     0x0b
  115.90 -#define DW_FORM_flag      0x0c
  115.91 -#define DW_FORM_sdata     0x0d
  115.92 -#define DW_FORM_strp      0x0e
  115.93 -#define DW_FORM_udata     0x0f
  115.94 -#define DW_FORM_ref_addr  0x10
  115.95 -#define DW_FORM_ref4      0x13
  115.96 -#define DW_FORM_ref_udata 0x15
  115.97 -#define DW_FORM_indirect  0x16
  115.98 -
  115.99 -#define DW_OP_addr        0x03
 115.100 -#define DW_OP_plus_uconst 0x23
 115.101 -#define DW_OP_reg0        0x50
 115.102 -#define DW_OP_reg1        0x51
 115.103 -#define DW_OP_reg2        0x52
 115.104 -#define DW_OP_reg3        0x53
 115.105 -#define DW_OP_reg4        0x54
 115.106 -#define DW_OP_reg5        0x55
 115.107 -#define DW_OP_reg6        0x56
 115.108 -#define DW_OP_reg7        0x57
 115.109 -#define DW_OP_reg8        0x58
 115.110 -#define DW_OP_reg9        0x59
 115.111 -#define DW_OP_reg10       0x5a
 115.112 -#define DW_OP_reg11       0x5b
 115.113 -#define DW_OP_reg12       0x5c
 115.114 -#define DW_OP_reg13       0x5d
 115.115 -#define DW_OP_reg14       0x5e
 115.116 -#define DW_OP_reg15       0x5f
 115.117 -#define DW_OP_fbreg       0x91
 115.118 -
 115.119 -#define DW_LNS_extended_op      0x00
 115.120 -#define DW_LNS_copy             0x01
 115.121 -#define DW_LNS_advance_pc       0x02
 115.122 -#define DW_LNS_advance_line     0x03
 115.123 -#define DW_LNS_set_file         0x04
 115.124 -#define DW_LNS_set_column       0x05
 115.125 -#define DW_LNS_negate_stmt      0x06
 115.126 -#define DW_LNS_set_basic_block  0x07
 115.127 -#define DW_LNS_const_add_pc     0x08
 115.128 -#define DW_LNS_fixed_advance_pc 0x09
 115.129 -
 115.130 -#define DW_LNE_end_sequence 0x01
 115.131 -#define DW_LNE_set_address  0x02
 115.132 -#define DW_LNE_define_file  0x03
 115.133 -
 115.134 -#define DW_CFA_advance_loc      0x01
 115.135 -#define DW_CFA_offset           0x02
 115.136 -#define DW_CFA_restore          0x03
 115.137 -#define DW_CFA_set_loc          0x01
 115.138 -#define DW_CFA_advance_loc1     0x02
 115.139 -#define DW_CFA_advance_loc2     0x03
 115.140 -#define DW_CFA_advance_loc4     0x04
 115.141 -#define DW_CFA_offset_extended  0x05
 115.142 -#define DW_CFA_restore_extended 0x06
 115.143 -#define DW_CFA_undefined        0x07
 115.144 -#define DW_CFA_same_value       0x08
 115.145 -#define DW_CFA_register         0x09
 115.146 -#define DW_CFA_remember_state   0x0a
 115.147 -#define DW_CFA_restore_state    0x0b
 115.148 -#define DW_CFA_def_cfa          0x0c
 115.149 -#define DW_CFA_def_cfa_register 0x0d
 115.150 -#define DW_CFA_def_cfa_offset   0x0e
 115.151 -#define DW_CFA_nop              0x00
 115.152 -
 115.153 -#define CASE_TYPE_TAG \
 115.154 -case DW_TAG_const_type: \
 115.155 -case DW_TAG_volatile_type: \
 115.156 -case DW_TAG_pointer_type: \
 115.157 -case DW_TAG_base_type: \
 115.158 -case DW_TAG_array_type: \
 115.159 -case DW_TAG_structure_type: \
 115.160 -case DW_TAG_union_type: \
 115.161 -case DW_TAG_typedef: \
 115.162 -case DW_TAG_subroutine_type: \
 115.163 -case DW_TAG_enumeration_type: \
 115.164 -case DW_TAG_enumerator: \
 115.165 -case DW_TAG_reference_type
 115.166 -
 115.167 -struct ELFcie
 115.168 -{
 115.169 -	ELFcie *next;
 115.170 -	u32     offset;
 115.171 -	u8 *    augmentation;
 115.172 -	u32     codeAlign;
 115.173 -	s32     dataAlign;
 115.174 -	int     returnAddress;
 115.175 -	u8 *    data;
 115.176 -	u32     dataLen;
 115.177 -};
 115.178 -
 115.179 -struct ELFfde
 115.180 -{
 115.181 -	ELFcie *cie;
 115.182 -	u32     address;
 115.183 -	u32     end;
 115.184 -	u8 *    data;
 115.185 -	u32     dataLen;
 115.186 -};
 115.187 -
 115.188 -enum ELFRegMode
 115.189 -{
 115.190 -	REG_NOT_SET,
 115.191 -	REG_OFFSET,
 115.192 -	REG_REGISTER
 115.193 -};
 115.194 -
 115.195 -struct ELFFrameStateRegister
 115.196 -{
 115.197 -	ELFRegMode mode;
 115.198 -	int        reg;
 115.199 -	s32        offset;
 115.200 -};
 115.201 -
 115.202 -struct ELFFrameStateRegisters
 115.203 -{
 115.204 -	ELFFrameStateRegister   regs[16];
 115.205 -	ELFFrameStateRegisters *previous;
 115.206 -};
 115.207 -
 115.208 -enum ELFCfaMode
 115.209 -{
 115.210 -	CFA_NOT_SET,
 115.211 -	CFA_REG_OFFSET
 115.212 -};
 115.213 -
 115.214 -struct ELFFrameState
 115.215 -{
 115.216 -	ELFFrameStateRegisters registers;
 115.217 -
 115.218 -	ELFCfaMode cfaMode;
 115.219 -	int        cfaRegister;
 115.220 -	s32        cfaOffset;
 115.221 -
 115.222 -	u32 pc;
 115.223 -
 115.224 -	int dataAlign;
 115.225 -	int codeAlign;
 115.226 -	int returnAddress;
 115.227 -};
 115.228 -
 115.229 -extern bool8 cpuIsMultiBoot;
 115.230 -
 115.231 -Symbol *elfSymbols       = NULL;
 115.232 -char *  elfSymbolsStrTab = NULL;
 115.233 -int     elfSymbolsCount  = 0;
 115.234 -
 115.235 -ELFSectionHeader **elfSectionHeaders = NULL;
 115.236 -char *elfSectionHeadersStringTable   = NULL;
 115.237 -int   elfSectionHeadersCount         = 0;
 115.238 -u8 *  elfFileData = NULL;
 115.239 -
 115.240 -CompileUnit *elfCompileUnits = NULL;
 115.241 -DebugInfo *  elfDebugInfo    = NULL;
 115.242 -char *       elfDebugStrings = NULL;
 115.243 -
 115.244 -ELFcie * elfCies     = NULL;
 115.245 -ELFfde **elfFdes     = NULL;
 115.246 -int      elfFdeCount = 0;
 115.247 -
 115.248 -CompileUnit *elfCurrentUnit = NULL;
 115.249 -
 115.250 -u32 elfRead4Bytes(u8 *);
 115.251 -u16 elfRead2Bytes(u8 *);
 115.252 -
 115.253 -CompileUnit *elfGetCompileUnit(u32 addr)
 115.254 -{
 115.255 -	if (elfCompileUnits)
 115.256 -	{
 115.257 -		CompileUnit *unit = elfCompileUnits;
 115.258 -		while (unit)
 115.259 -		{
 115.260 -			if (unit->lowPC)
 115.261 -			{
 115.262 -				if (addr >= unit->lowPC && addr < unit->highPC)
 115.263 -					return unit;
 115.264 -			}
 115.265 -			else
 115.266 -			{
 115.267 -				ARanges *r = unit->ranges;
 115.268 -				if (r)
 115.269 -				{
 115.270 -					int count = r->count;
 115.271 -					for (int j = 0; j < count; j++)
 115.272 -					{
 115.273 -						if (addr >= r->ranges[j].lowPC && addr < r->ranges[j].highPC)
 115.274 -							return unit;
 115.275 -					}
 115.276 -				}
 115.277 -			}
 115.278 -			unit = unit->next;
 115.279 -		}
 115.280 -	}
 115.281 -	return NULL;
 115.282 -}
 115.283 -
 115.284 -char *elfGetAddressSymbol(u32 addr)
 115.285 -{
 115.286 -	static char buffer[256];
 115.287 -
 115.288 -	CompileUnit *unit = elfGetCompileUnit(addr);
 115.289 -	// found unit, need to find function
 115.290 -	if (unit)
 115.291 -	{
 115.292 -		Function *func = unit->functions;
 115.293 -		while (func)
 115.294 -		{
 115.295 -			if (addr >= func->lowPC && addr < func->highPC)
 115.296 -			{
 115.297 -				int   offset = addr - func->lowPC;
 115.298 -				char *name   = func->name;
 115.299 -				if (!name)
 115.300 -					name = "";
 115.301 -				if (offset)
 115.302 -					sprintf(buffer, "%s+%d", name, offset);
 115.303 -				else
 115.304 -					strcpy(buffer, name);
 115.305 -				return buffer;
 115.306 -			}
 115.307 -			func = func->next;
 115.308 -		}
 115.309 -	}
 115.310 -
 115.311 -	if (elfSymbolsCount)
 115.312 -	{
 115.313 -		for (int i = 0; i < elfSymbolsCount; i++)
 115.314 -		{
 115.315 -			Symbol *s = &elfSymbols[i];
 115.316 -			if ((addr >= s->value)  && addr < (s->value+s->size))
 115.317 -			{
 115.318 -				int   offset = addr-s->value;
 115.319 -				char *name   = s->name;
 115.320 -				if (name == NULL)
 115.321 -					name = "";
 115.322 -				if (offset)
 115.323 -					sprintf(buffer, "%s+%d", name, addr-s->value);
 115.324 -				else
 115.325 -					strcpy(buffer, name);
 115.326 -				return buffer;
 115.327 -			}
 115.328 -			else if (addr == s->value)
 115.329 -			{
 115.330 -				if (s->name)
 115.331 -					strcpy(buffer, s->name);
 115.332 -				else
 115.333 -					strcpy(buffer, "");
 115.334 -				return buffer;
 115.335 -			}
 115.336 -		}
 115.337 -	}
 115.338 -
 115.339 -	return "";
 115.340 -}
 115.341 -
 115.342 -bool elfFindLineInModule(u32 *addr, char *name, int line)
 115.343 -{
 115.344 -	CompileUnit *unit = elfCompileUnits;
 115.345 -
 115.346 -	while (unit)
 115.347 -	{
 115.348 -		if (unit->lineInfoTable)
 115.349 -		{
 115.350 -			int   i;
 115.351 -			int   count = unit->lineInfoTable->fileCount;
 115.352 -			char *found = NULL;
 115.353 -			for (i = 0; i < count; i++)
 115.354 -			{
 115.355 -				if (strcmp(name, unit->lineInfoTable->files[i]) == 0)
 115.356 -				{
 115.357 -					found = unit->lineInfoTable->files[i];
 115.358 -					break;
 115.359 -				}
 115.360 -			}
 115.361 -			// found a matching filename... try to find line now
 115.362 -			if (found)
 115.363 -			{
 115.364 -				LineInfoItem *table = unit->lineInfoTable->lines;
 115.365 -				count = unit->lineInfoTable->number;
 115.366 -				for (i = 0; i < count; i++)
 115.367 -				{
 115.368 -					if (table[i].file == found && table[i].line == line)
 115.369 -					{
 115.370 -						*addr = table[i].address;
 115.371 -						return true;
 115.372 -					}
 115.373 -				}
 115.374 -				// we can only find a single match
 115.375 -				return false;
 115.376 -			}
 115.377 -		}
 115.378 -		unit = unit->next;
 115.379 -	}
 115.380 -	return false;
 115.381 -}
 115.382 -
 115.383 -int elfFindLine(CompileUnit *unit, Function * /* func */, u32 addr, char **f)
 115.384 -{
 115.385 -	int currentLine = -1;
 115.386 -	if (unit->hasLineInfo)
 115.387 -	{
 115.388 -		int count = unit->lineInfoTable->number;
 115.389 -		LineInfoItem *table = unit->lineInfoTable->lines;
 115.390 -		int i;
 115.391 -		for (i = 0; i < count; i++)
 115.392 -		{
 115.393 -			if (addr <= table[i].address)
 115.394 -				break;
 115.395 -		}
 115.396 -		if (i == count)
 115.397 -			i--;
 115.398 -		*f = table[i].file;
 115.399 -		currentLine = table[i].line;
 115.400 -	}
 115.401 -	return currentLine;
 115.402 -}
 115.403 -
 115.404 -bool elfFindLineInUnit(u32 *addr, CompileUnit *unit, int line)
 115.405 -{
 115.406 -	if (unit->hasLineInfo)
 115.407 -	{
 115.408 -		int count = unit->lineInfoTable->number;
 115.409 -		LineInfoItem *table = unit->lineInfoTable->lines;
 115.410 -		int i;
 115.411 -		for (i = 0; i < count; i++)
 115.412 -		{
 115.413 -			if (line == table[i].line)
 115.414 -			{
 115.415 -				*addr = table[i].address;
 115.416 -				return true;
 115.417 -			}
 115.418 -		}
 115.419 -	}
 115.420 -	return false;
 115.421 -}
 115.422 -
 115.423 -bool elfGetCurrentFunction(u32 addr, Function **f, CompileUnit **u)
 115.424 -{
 115.425 -	CompileUnit *unit = elfGetCompileUnit(addr);
 115.426 -	// found unit, need to find function
 115.427 -	if (unit)
 115.428 -	{
 115.429 -		Function *func = unit->functions;
 115.430 -		while (func)
 115.431 -		{
 115.432 -			if (addr >= func->lowPC && addr < func->highPC)
 115.433 -			{
 115.434 -				*f = func;
 115.435 -				*u = unit;
 115.436 -				return true;
 115.437 -			}
 115.438 -			func = func->next;
 115.439 -		}
 115.440 -	}
 115.441 -	return false;
 115.442 -}
 115.443 -
 115.444 -bool elfGetObject(char *name, Function *f, CompileUnit *u, Object **o)
 115.445 -{
 115.446 -	if (f && u)
 115.447 -	{
 115.448 -		Object *v = f->variables;
 115.449 -
 115.450 -		while (v)
 115.451 -		{
 115.452 -			if (strcmp(name, v->name) == 0)
 115.453 -			{
 115.454 -				*o = v;
 115.455 -				return true;
 115.456 -			}
 115.457 -			v = v->next;
 115.458 -		}
 115.459 -		v = f->parameters;
 115.460 -		while (v)
 115.461 -		{
 115.462 -			if (strcmp(name, v->name) == 0)
 115.463 -			{
 115.464 -				*o = v;
 115.465 -				return true;
 115.466 -			}
 115.467 -			v = v->next;
 115.468 -		}
 115.469 -		v = u->variables;
 115.470 -		while (v)
 115.471 -		{
 115.472 -			if (strcmp(name, v->name) == 0)
 115.473 -			{
 115.474 -				*o = v;
 115.475 -				return true;
 115.476 -			}
 115.477 -			v = v->next;
 115.478 -		}
 115.479 -	}
 115.480 -
 115.481 -	CompileUnit *c = elfCompileUnits;
 115.482 -
 115.483 -	while (c)
 115.484 -	{
 115.485 -		if (c != u)
 115.486 -		{
 115.487 -			Object *v = c->variables;
 115.488 -			while (v)
 115.489 -			{
 115.490 -				if (strcmp(name, v->name) == 0)
 115.491 -				{
 115.492 -					*o = v;
 115.493 -					return true;
 115.494 -				}
 115.495 -				v = v->next;
 115.496 -			}
 115.497 -		}
 115.498 -		c = c->next;
 115.499 -	}
 115.500 -
 115.501 -	return false;
 115.502 -}
 115.503 -
 115.504 -char *elfGetSymbol(int i, u32 *value, u32 *size, int *type)
 115.505 -{
 115.506 -	if (i < elfSymbolsCount)
 115.507 -	{
 115.508 -		Symbol *s = &elfSymbols[i];
 115.509 -		*value = s->value;
 115.510 -		*size  = s->size;
 115.511 -		*type  = s->type;
 115.512 -		return s->name;
 115.513 -	}
 115.514 -	return NULL;
 115.515 -}
 115.516 -
 115.517 -bool elfGetSymbolAddress(char *sym, u32 *addr, u32 *size, int *type)
 115.518 -{
 115.519 -	if (elfSymbolsCount)
 115.520 -	{
 115.521 -		for (int i = 0; i < elfSymbolsCount; i++)
 115.522 -		{
 115.523 -			Symbol *s = &elfSymbols[i];
 115.524 -			if (strcmp(sym, s->name) == 0)
 115.525 -			{
 115.526 -				*addr = s->value;
 115.527 -				*size = s->size;
 115.528 -				*type = s->type;
 115.529 -				return true;
 115.530 -			}
 115.531 -		}
 115.532 -	}
 115.533 -	return false;
 115.534 -}
 115.535 -
 115.536 -ELFfde *elfGetFde(u32 address)
 115.537 -{
 115.538 -	if (elfFdes)
 115.539 -	{
 115.540 -		int i;
 115.541 -		for (i = 0; i < elfFdeCount; i++)
 115.542 -		{
 115.543 -			if (address >= elfFdes[i]->address &&
 115.544 -			    address < elfFdes[i]->end)
 115.545 -			{
 115.546 -				return elfFdes[i];
 115.547 -			}
 115.548 -		}
 115.549 -	}
 115.550 -
 115.551 -	return NULL;
 115.552 -}
 115.553 -
 115.554 -void elfExecuteCFAInstructions(ELFFrameState *state, u8 *data, u32 len,
 115.555 -                               u32 pc)
 115.556 -{
 115.557 -	u8 *end = data + len;
 115.558 -	int bytes;
 115.559 -	int reg;
 115.560 -	ELFFrameStateRegisters *fs;
 115.561 -
 115.562 -	while (data < end && state->pc < pc)
 115.563 -	{
 115.564 -		u8 op = *data++;
 115.565 -
 115.566 -		switch (op >> 6)
 115.567 -		{
 115.568 -		case DW_CFA_advance_loc:
 115.569 -			state->pc += (op & 0x3f) * state->codeAlign;
 115.570 -			break;
 115.571 -		case DW_CFA_offset:
 115.572 -			reg = op & 0x3f;
 115.573 -			state->registers.regs[reg].mode   = REG_OFFSET;
 115.574 -			state->registers.regs[reg].offset = state->dataAlign *
 115.575 -			                                    (s32)elfReadLEB128(data, &bytes);
 115.576 -			data += bytes;
 115.577 -			break;
 115.578 -		case DW_CFA_restore:
 115.579 -			// we don't care much about the other possible settings,
 115.580 -			// so just setting to unset is enough for now
 115.581 -			state->registers.regs[op & 0x3f].mode = REG_NOT_SET;
 115.582 -			break;
 115.583 -		case 0:
 115.584 -			switch (op & 0x3f)
 115.585 -			{
 115.586 -			case DW_CFA_nop:
 115.587 -				break;
 115.588 -			case DW_CFA_advance_loc1:
 115.589 -				state->pc += state->codeAlign * (*data++);
 115.590 -				break;
 115.591 -			case DW_CFA_advance_loc2:
 115.592 -				state->pc += state->codeAlign * elfRead2Bytes(data);
 115.593 -				data      += 2;
 115.594 -				break;
 115.595 -			case DW_CFA_advance_loc4:
 115.596 -				state->pc += state->codeAlign * elfRead4Bytes(data);
 115.597 -				data      += 4;
 115.598 -				break;
 115.599 -			case DW_CFA_offset_extended:
 115.600 -				reg   = elfReadLEB128(data, &bytes);
 115.601 -				data += bytes;
 115.602 -				state->registers.regs[reg].mode   = REG_OFFSET;
 115.603 -				state->registers.regs[reg].offset = state->dataAlign *
 115.604 -				                                    (s32)elfReadLEB128(data, &bytes);
 115.605 -				data += bytes;
 115.606 -				break;
 115.607 -			case DW_CFA_restore_extended:
 115.608 -			case DW_CFA_undefined:
 115.609 -			case DW_CFA_same_value:
 115.610 -				reg   = elfReadLEB128(data, &bytes);
 115.611 -				data += bytes;
 115.612 -				state->registers.regs[reg].mode = REG_NOT_SET;
 115.613 -				break;
 115.614 -			case DW_CFA_register:
 115.615 -				reg   = elfReadLEB128(data, &bytes);
 115.616 -				data += bytes;
 115.617 -				state->registers.regs[reg].mode = REG_REGISTER;
 115.618 -				state->registers.regs[reg].reg  = elfReadLEB128(data, &bytes);
 115.619 -				data += bytes;
 115.620 -				break;
 115.621 -			case DW_CFA_remember_state:
 115.622 -				fs = (ELFFrameStateRegisters *)calloc(1,
 115.623 -				                                      sizeof(ELFFrameStateRegisters));
 115.624 -				memcpy(fs, &state->registers, sizeof(ELFFrameStateRegisters));
 115.625 -				state->registers.previous = fs;
 115.626 -				break;
 115.627 -			case DW_CFA_restore_state:
 115.628 -				if (state->registers.previous == NULL)
 115.629 -				{
 115.630 -					printf("Error: previous frame state is NULL.\n");
 115.631 -					return;
 115.632 -				}
 115.633 -				fs = state->registers.previous;
 115.634 -				memcpy(&state->registers, fs, sizeof(ELFFrameStateRegisters));
 115.635 -				free(fs);
 115.636 -				break;
 115.637 -			case DW_CFA_def_cfa:
 115.638 -				state->cfaRegister = elfReadLEB128(data, &bytes);
 115.639 -				data += bytes;
 115.640 -				state->cfaOffset = (s32)elfReadLEB128(data, &bytes);
 115.641 -				data += bytes;
 115.642 -				state->cfaMode = CFA_REG_OFFSET;
 115.643 -				break;
 115.644 -			case DW_CFA_def_cfa_register:
 115.645 -				state->cfaRegister = elfReadLEB128(data, &bytes);
 115.646 -				data += bytes;
 115.647 -				state->cfaMode = CFA_REG_OFFSET;
 115.648 -				break;
 115.649 -			case DW_CFA_def_cfa_offset:
 115.650 -				state->cfaOffset = (s32)elfReadLEB128(data, &bytes);
 115.651 -				data += bytes;
 115.652 -				state->cfaMode = CFA_REG_OFFSET;
 115.653 -				break;
 115.654 -			default:
 115.655 -				printf("Unknown CFA opcode %08x\n", op);
 115.656 -				return;
 115.657 -			}
 115.658 -			break;
 115.659 -		default:
 115.660 -			printf("Unknown CFA opcode %08x\n", op);
 115.661 -			return;
 115.662 -		}
 115.663 -	}
 115.664 -}
 115.665 -
 115.666 -ELFFrameState *elfGetFrameState(ELFfde *fde, u32 address)
 115.667 -{
 115.668 -	ELFFrameState *state = (ELFFrameState *)calloc(1, sizeof(ELFFrameState));
 115.669 -	state->pc            = fde->address;
 115.670 -	state->dataAlign     = fde->cie->dataAlign;
 115.671 -	state->codeAlign     = fde->cie->codeAlign;
 115.672 -	state->returnAddress = fde->cie->returnAddress;
 115.673 -
 115.674 -	elfExecuteCFAInstructions(state,
 115.675 -	                          fde->cie->data,
 115.676 -	                          fde->cie->dataLen,
 115.677 -	                          0xffffffff);
 115.678 -	elfExecuteCFAInstructions(state,
 115.679 -	                          fde->data,
 115.680 -	                          fde->dataLen,
 115.681 -	                          address);
 115.682 -
 115.683 -	return state;
 115.684 -}
 115.685 -
 115.686 -void elfPrintCallChain(u32 address)
 115.687 -{
 115.688 -	int count = 1;
 115.689 -
 115.690 -	reg_pair regs[15];
 115.691 -	reg_pair newRegs[15];
 115.692 -
 115.693 -	memcpy(&regs[0], &reg[0], sizeof(reg_pair) * 15);
 115.694 -
 115.695 -	while (count < 20)
 115.696 -	{
 115.697 -		char *addr = elfGetAddressSymbol(address);
 115.698 -		if (*addr == 0)
 115.699 -			addr = "???";
 115.700 -
 115.701 -		printf("%08x %s\n", address, addr);
 115.702 -
 115.703 -		ELFfde *fde = elfGetFde(address);
 115.704 -
 115.705 -		if (fde == NULL)
 115.706 -		{
 115.707 -			break;
 115.708 -		}
 115.709 -
 115.710 -		ELFFrameState *state = elfGetFrameState(fde, address);
 115.711 -
 115.712 -		if (!state)
 115.713 -		{
 115.714 -			break;
 115.715 -		}
 115.716 -
 115.717 -		if (state->cfaMode == CFA_REG_OFFSET)
 115.718 -		{
 115.719 -			memcpy(&newRegs[0], &regs[0], sizeof(reg_pair) * 15);
 115.720 -			u32 addr = 0;
 115.721 -			for (int i = 0; i < 15; i++)
 115.722 -			{
 115.723 -				ELFFrameStateRegister *r = &state->registers.
 115.724 -				                           regs[i];
 115.725 -
 115.726 -				switch (r->mode)
 115.727 -				{
 115.728 -				case REG_NOT_SET:
 115.729 -					newRegs[i].I = regs[i].I;
 115.730 -					break;
 115.731 -				case REG_OFFSET:
 115.732 -					newRegs[i].I = elfReadMemory(regs[state->cfaRegister].I +
 115.733 -					                             state->cfaOffset +
 115.734 -					                             r->offset);
 115.735 -					break;
 115.736 -				case REG_REGISTER:
 115.737 -					newRegs[i].I = regs[r->reg].I;
 115.738 -					break;
 115.739 -				default:
 115.740 -					printf("Unknown register mode: %d\n", r->mode);
 115.741 -					break;
 115.742 -				}
 115.743 -			}
 115.744 -			memcpy(regs, newRegs, sizeof(reg_pair)*15);
 115.745 -			addr    = newRegs[14].I;
 115.746 -			addr   &= 0xfffffffe;
 115.747 -			address = addr;
 115.748 -			count++;
 115.749 -		}
 115.750 -		else
 115.751 -		{
 115.752 -			printf("CFA not set\n");
 115.753 -			break;
 115.754 -		}
 115.755 -		if (state->registers.previous)
 115.756 -		{
 115.757 -			ELFFrameStateRegisters *prev = state->registers.previous;
 115.758 -
 115.759 -			while (prev)
 115.760 -			{
 115.761 -				ELFFrameStateRegisters *p = prev->previous;
 115.762 -				free(prev);
 115.763 -				prev = p;
 115.764 -			}
 115.765 -		}
 115.766 -		free(state);
 115.767 -	}
 115.768 -}
 115.769 -
 115.770 -u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base)
 115.771 -{
 115.772 -	u32 framebase = 0;
 115.773 -	if (f && f->frameBase)
 115.774 -	{
 115.775 -		ELFBlock *b = f->frameBase;
 115.776 -		switch (*b->data)
 115.777 -		{
 115.778 -		case DW_OP_reg0:
 115.779 -		case DW_OP_reg1:
 115.780 -		case DW_OP_reg2:
 115.781 -		case DW_OP_reg3:
 115.782 -		case DW_OP_reg4:
 115.783 -		case DW_OP_reg5:
 115.784 -		case DW_OP_reg6:
 115.785 -		case DW_OP_reg7:
 115.786 -		case DW_OP_reg8:
 115.787 -		case DW_OP_reg9:
 115.788 -		case DW_OP_reg10:
 115.789 -		case DW_OP_reg11:
 115.790 -		case DW_OP_reg12:
 115.791 -		case DW_OP_reg13:
 115.792 -		case DW_OP_reg14:
 115.793 -		case DW_OP_reg15:
 115.794 -			framebase = reg[*b->data-0x50].I;
 115.795 -			break;
 115.796 -		default:
 115.797 -			fprintf(stderr, "Unknown frameBase %02x\n", *b->data);
 115.798 -			break;
 115.799 -		}
 115.800 -	}
 115.801 -
 115.802 -	ELFBlock *loc      = o;
 115.803 -	u32       location = 0;
 115.804 -	int       bytes    = 0;
 115.805 -	if (loc)
 115.806 -	{
 115.807 -		switch (*loc->data)
 115.808 -		{
 115.809 -		case DW_OP_addr:
 115.810 -			location = elfRead4Bytes(loc->data+1);
 115.811 -			*type    = LOCATION_memory;
 115.812 -			break;
 115.813 -		case DW_OP_plus_uconst:
 115.814 -			location = base + elfReadLEB128(loc->data+1, &bytes);
 115.815 -			*type    = LOCATION_memory;
 115.816 -			break;
 115.817 -		case DW_OP_reg0:
 115.818 -		case DW_OP_reg1:
 115.819 -		case DW_OP_reg2:
 115.820 -		case DW_OP_reg3:
 115.821 -		case DW_OP_reg4:
 115.822 -		case DW_OP_reg5:
 115.823 -		case DW_OP_reg6:
 115.824 -		case DW_OP_reg7:
 115.825 -		case DW_OP_reg8:
 115.826 -		case DW_OP_reg9:
 115.827 -		case DW_OP_reg10:
 115.828 -		case DW_OP_reg11:
 115.829 -		case DW_OP_reg12:
 115.830 -		case DW_OP_reg13:
 115.831 -		case DW_OP_reg14:
 115.832 -		case DW_OP_reg15:
 115.833 -			location = *loc->data - 0x50;
 115.834 -			*type    = LOCATION_register;
 115.835 -			break;
 115.836 -		case DW_OP_fbreg:
 115.837 -		{
 115.838 -			int bytes;
 115.839 -			s32 off = elfReadSignedLEB128(loc->data+1, &bytes);
 115.840 -			location = framebase + off;
 115.841 -			*type    = LOCATION_memory;
 115.842 -			break;
 115.843 -		}
 115.844 -		default:
 115.845 -			fprintf(stderr, "Unknown location %02x\n", *loc->data);
 115.846 -			break;
 115.847 -		}
 115.848 -	}
 115.849 -	return location;
 115.850 -}
 115.851 -
 115.852 -u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type)
 115.853 -{
 115.854 -	return elfDecodeLocation(f, o, type, 0);
 115.855 -}
 115.856 -
 115.857 -// reading function
 115.858 -
 115.859 -u32 elfRead4Bytes(u8 *data)
 115.860 -{
 115.861 -	u32 value = *data++;
 115.862 -	value |= (*data++ << 8);
 115.863 -	value |= (*data++ << 16);
 115.864 -	value |= (*data << 24);
 115.865 -	return value;
 115.866 -}
 115.867 -
 115.868 -u16 elfRead2Bytes(u8 *data)
 115.869 -{
 115.870 -	u16 value = *data++;
 115.871 -	value |= (*data << 8);
 115.872 -	return value;
 115.873 -}
 115.874 -
 115.875 -char *elfReadString(u8 *data, int *bytesRead)
 115.876 -{
 115.877 -	if (*data == 0)
 115.878 -	{
 115.879 -		*bytesRead = 1;
 115.880 -		return NULL;
 115.881 -	}
 115.882 -	*bytesRead = strlen((char *)data) + 1;
 115.883 -	return (char *)data;
 115.884 -}
 115.885 -
 115.886 -s32 elfReadSignedLEB128(u8 *data, int *bytesRead)
 115.887 -{
 115.888 -	s32 result = 0;
 115.889 -	int shift  = 0;
 115.890 -	int count  = 0;
 115.891 -
 115.892 -	u8 byte;
 115.893 -	do
 115.894 -	{
 115.895 -		byte = *data++;
 115.896 -		count++;
 115.897 -		result |= (byte & 0x7f) << shift;
 115.898 -		shift  += 7;
 115.899 -	}
 115.900 -	while (byte & 0x80);
 115.901 -	if ((shift < 32) && (byte & 0x40))
 115.902 -		result |= -(1 << shift);
 115.903 -	*bytesRead = count;
 115.904 -	return result;
 115.905 -}
 115.906 -
 115.907 -u32 elfReadLEB128(u8 *data, int *bytesRead)
 115.908 -{
 115.909 -	u32 result = 0;
 115.910 -	int shift  = 0;
 115.911 -	int count  = 0;
 115.912 -	u8  byte;
 115.913 -	do
 115.914 -	{
 115.915 -		byte = *data++;
 115.916 -		count++;
 115.917 -		result |= (byte & 0x7f) << shift;
 115.918 -		shift  += 7;
 115.919 -	}
 115.920 -	while (byte & 0x80);
 115.921 -	*bytesRead = count;
 115.922 -	return result;
 115.923 -}
 115.924 -
 115.925 -u8 *elfReadSection(u8 *data, ELFSectionHeader *sh)
 115.926 -{
 115.927 -	return data + READ32LE(&sh->offset);
 115.928 -}
 115.929 -
 115.930 -ELFSectionHeader *elfGetSectionByName(char *name)
 115.931 -{
 115.932 -	for (int i = 0; i < elfSectionHeadersCount; i++)
 115.933 -	{
 115.934 -		if (strcmp(name,
 115.935 -		           &elfSectionHeadersStringTable[READ32LE(&elfSectionHeaders[i]->
 115.936 -		                                                  name)]) == 0)
 115.937 -		{
 115.938 -			return elfSectionHeaders[i];
 115.939 -		}
 115.940 -	}
 115.941 -	return NULL;
 115.942 -}
 115.943 -
 115.944 -ELFSectionHeader *elfGetSectionByNumber(int number)
 115.945 -{
 115.946 -	if (number < elfSectionHeadersCount)
 115.947 -	{
 115.948 -		return elfSectionHeaders[number];
 115.949 -	}
 115.950 -	return NULL;
 115.951 -}
 115.952 -
 115.953 -CompileUnit *elfGetCompileUnitForData(u8 *data)
 115.954 -{
 115.955 -	u8 *end = elfCurrentUnit->top + 4 + elfCurrentUnit->length;
 115.956 -
 115.957 -	if (data >= elfCurrentUnit->top && data < end)
 115.958 -		return elfCurrentUnit;
 115.959 -
 115.960 -	CompileUnit *unit = elfCompileUnits;
 115.961 -
 115.962 -	while (unit)
 115.963 -	{
 115.964 -		end = unit->top + 4 + unit->length;
 115.965 -
 115.966 -		if (data >= unit->top && data < end)
 115.967 -			return unit;
 115.968 -
 115.969 -		unit = unit->next;
 115.970 -	}
 115.971 -
 115.972 -	printf("Error: cannot find reference to compile unit at offset %08x\n",
 115.973 -	       (int)(data - elfDebugInfo->infodata));
 115.974 -	exit(-1);
 115.975 -}
 115.976 -
 115.977 -u8 *elfReadAttribute(u8 *data, ELFAttr *attr)
 115.978 -{
 115.979 -	int bytes;
 115.980 -	int form = attr->form;
 115.981 -start:
 115.982 -	switch (form)
 115.983 -	{
 115.984 -	case DW_FORM_addr:
 115.985 -		attr->value = elfRead4Bytes(data);
 115.986 -		data       += 4;
 115.987 -		break;
 115.988 -	case DW_FORM_data2:
 115.989 -		attr->value = elfRead2Bytes(data);
 115.990 -		data       += 2;
 115.991 -		break;
 115.992 -	case DW_FORM_data4:
 115.993 -		attr->value = elfRead4Bytes(data);
 115.994 -		data       += 4;
 115.995 -		break;
 115.996 -	case DW_FORM_string:
 115.997 -		attr->string = (char *)data;
 115.998 -		data        += strlen(attr->string)+1;
 115.999 -		break;
115.1000 -	case DW_FORM_strp:
115.1001 -		attr->string = elfDebugStrings + elfRead4Bytes(data);
115.1002 -		data        += 4;
115.1003 -		break;
115.1004 -	case DW_FORM_block:
115.1005 -		attr->block         = (ELFBlock *)malloc(sizeof(ELFBlock));
115.1006 -		attr->block->length = elfReadLEB128(data, &bytes);
115.1007 -		data += bytes;
115.1008 -		attr->block->data = data;
115.1009 -		data += attr->block->length;
115.1010 -		break;
115.1011 -	case DW_FORM_block1:
115.1012 -		attr->block         = (ELFBlock *)malloc(sizeof(ELFBlock));
115.1013 -		attr->block->length = *data++;
115.1014 -		attr->block->data   = data;
115.1015 -		data += attr->block->length;
115.1016 -		break;
115.1017 -	case DW_FORM_data1:
115.1018 -		attr->value = *data++;
115.1019 -		break;
115.1020 -	case DW_FORM_flag:
115.1021 -		attr->flag = (*data++) ? true : false;
115.1022 -		break;
115.1023 -	case DW_FORM_sdata:
115.1024 -		attr->value = elfReadSignedLEB128(data, &bytes);
115.1025 -		data       += bytes;
115.1026 -		break;
115.1027 -	case DW_FORM_udata:
115.1028 -		attr->value = elfReadLEB128(data, &bytes);
115.1029 -		data       += bytes;
115.1030 -		break;
115.1031 -	case DW_FORM_ref_addr:
115.1032 -		attr->value = (elfDebugInfo->infodata + elfRead4Bytes(data)) -
115.1033 -		              elfGetCompileUnitForData(data)->top;
115.1034 -		data += 4;
115.1035 -		break;
115.1036 -	case DW_FORM_ref4:
115.1037 -		attr->value = elfRead4Bytes(data);
115.1038 -		data       += 4;
115.1039 -		break;
115.1040 -	case DW_FORM_ref_udata:
115.1041 -		attr->value = (elfDebugInfo->infodata +
115.1042 -		               (elfGetCompileUnitForData(data)->top -
115.1043 -		                elfDebugInfo->infodata) +
115.1044 -		               elfReadLEB128(data, &bytes)) -
115.1045 -		              elfCurrentUnit->top;
115.1046 -		data += bytes;
115.1047 -		break;
115.1048 -	case DW_FORM_indirect:
115.1049 -		form  = elfReadLEB128(data, &bytes);
115.1050 -		data += bytes;
115.1051 -		goto start;
115.1052 -	default:
115.1053 -		fprintf(stderr, "Unsupported FORM %02x\n", form);
115.1054 -		exit(-1);
115.1055 -	}
115.1056 -	return data;
115.1057 -}
115.1058 -
115.1059 -ELFAbbrev *elfGetAbbrev(ELFAbbrev **table, u32 number)
115.1060 -{
115.1061 -	int hash = number % 121;
115.1062 -
115.1063 -	ELFAbbrev *abbrev = table[hash];
115.1064 -
115.1065 -	while (abbrev)
115.1066 -	{
115.1067 -		if (abbrev->number == number)
115.1068 -			return abbrev;
115.1069 -		abbrev = abbrev->next;
115.1070 -	}
115.1071 -	return NULL;
115.1072 -}
115.1073 -
115.1074 -ELFAbbrev * *elfReadAbbrevs(u8 *data, u32 offset)
115.1075 -{
115.1076 -	data += offset;
115.1077 -	ELFAbbrev **abbrevs = (ELFAbbrev * *)calloc(sizeof(ELFAbbrev *)*121, 1);
115.1078 -	int         bytes   = 0;
115.1079 -	u32         number  = elfReadLEB128(data, &bytes);
115.1080 -	data += bytes;
115.1081 -	while (number)
115.1082 -	{
115.1083 -		ELFAbbrev *abbrev = (ELFAbbrev *)calloc(sizeof(ELFAbbrev), 1);
115.1084 -
115.1085 -		// read tag information
115.1086 -		abbrev->number = number;
115.1087 -		abbrev->tag    = elfReadLEB128(data, &bytes);
115.1088 -		data += bytes;
115.1089 -		abbrev->hasChildren = *data++ ? true : false;
115.1090 -
115.1091 -		// read attributes
115.1092 -		int name = elfReadLEB128(data, &bytes);
115.1093 -		data += bytes;
115.1094 -		int form = elfReadLEB128(data, &bytes);
115.1095 -		data += bytes;
115.1096 -
115.1097 -		while (name)
115.1098 -		{
115.1099 -			if ((abbrev->numAttrs % 4) == 0)
115.1100 -			{
115.1101 -				abbrev->attrs = (ELFAttr *)realloc(abbrev->attrs,
115.1102 -				                                   (abbrev->numAttrs + 4) *
115.1103 -				                                   sizeof(ELFAttr));
115.1104 -			}
115.1105 -			abbrev->attrs[abbrev->numAttrs].name   = name;
115.1106 -			abbrev->attrs[abbrev->numAttrs++].form = form;
115.1107 -
115.1108 -			name  = elfReadLEB128(data, &bytes);
115.1109 -			data += bytes;
115.1110 -			form  = elfReadLEB128(data, &bytes);
115.1111 -			data += bytes;
115.1112 -		}
115.1113 -
115.1114 -		int hash = number % 121;
115.1115 -		abbrev->next  = abbrevs[hash];
115.1116 -		abbrevs[hash] = abbrev;
115.1117 -
115.1118 -		number = elfReadLEB128(data, &bytes);
115.1119 -		data  += bytes;
115.1120 -
115.1121 -		if (elfGetAbbrev(abbrevs, number) != NULL)
115.1122 -			break;
115.1123 -	}
115.1124 -
115.1125 -	return abbrevs;
115.1126 -}
115.1127 -
115.1128 -void elfParseCFA(u8 *top)
115.1129 -{
115.1130 -	ELFSectionHeader *h = elfGetSectionByName(".debug_frame");
115.1131 -
115.1132 -	if (h == NULL)
115.1133 -	{
115.1134 -		return;
115.1135 -	}
115.1136 -
115.1137 -	u8 *data = elfReadSection(top, h);
115.1138 -
115.1139 -	u8 *topOffset = data;
115.1140 -
115.1141 -	u8 *end = data + READ32LE(&h->size);
115.1142 -
115.1143 -	ELFcie *cies = NULL;
115.1144 -
115.1145 -	while (data < end)
115.1146 -	{
115.1147 -		u32 offset = data - topOffset;
115.1148 -		u32 len    = elfRead4Bytes(data);
115.1149 -		data += 4;
115.1150 -
115.1151 -		u8 *dataEnd = data + len;
115.1152 -
115.1153 -		u32 id = elfRead4Bytes(data);
115.1154 -		data += 4;
115.1155 -
115.1156 -		if (id == 0xffffffff)
115.1157 -		{
115.1158 -			// skip version
115.1159 -			*data++;
115.1160 -
115.1161 -			ELFcie *cie = (ELFcie *)calloc(1, sizeof(ELFcie));
115.1162 -
115.1163 -			cie->next = cies;
115.1164 -			cies      = cie;
115.1165 -
115.1166 -			cie->offset = offset;
115.1167 -
115.1168 -			cie->augmentation = data;
115.1169 -			while (*data)
115.1170 -				data++;
115.1171 -			data++;
115.1172 -
115.1173 -			if (*cie->augmentation)
115.1174 -			{
115.1175 -				fprintf(stderr, "Error: augmentation not supported\n");
115.1176 -				exit(-1);
115.1177 -			}
115.1178 -
115.1179 -			int bytes;
115.1180 -			cie->codeAlign = elfReadLEB128(data, &bytes);
115.1181 -			data += bytes;
115.1182 -
115.1183 -			cie->dataAlign = elfReadSignedLEB128(data, &bytes);
115.1184 -			data += bytes;
115.1185 -
115.1186 -			cie->returnAddress = *data++;
115.1187 -
115.1188 -			cie->data    = data;
115.1189 -			cie->dataLen = dataEnd - data;
115.1190 -		}
115.1191 -		else
115.1192 -		{
115.1193 -			ELFfde *fde = (ELFfde *)calloc(1, sizeof(ELFfde));
115.1194 -
115.1195 -			ELFcie *cie = cies;
115.1196 -
115.1197 -			while (cie != NULL)
115.1198 -			{
115.1199 -				if (cie->offset == id)
115.1200 -					break;
115.1201 -				cie = cie->next;
115.1202 -			}
115.1203 -
115.1204 -			if (!cie)
115.1205 -			{
115.1206 -				fprintf(stderr, "Cannot find CIE %08x\n", id);
115.1207 -				exit(-1);
115.1208 -			}
115.1209 -
115.1210 -			fde->cie = cie;
115.1211 -
115.1212 -			fde->address = elfRead4Bytes(data);
115.1213 -			data        += 4;
115.1214 -
115.1215 -			fde->end = fde->address + elfRead4Bytes(data);
115.1216 -			data    += 4;
115.1217 -
115.1218 -			fde->data    = data;
115.1219 -			fde->dataLen = dataEnd - data;
115.1220 -
115.1221 -			if ((elfFdeCount %10) == 0)
115.1222 -			{
115.1223 -				elfFdes = (ELFfde * *)realloc(elfFdes, (elfFdeCount+10) *
115.1224 -				                              sizeof(ELFfde *));
115.1225 -			}
115.1226 -			elfFdes[elfFdeCount++] = fde;
115.1227 -		}
115.1228 -		data = dataEnd;
115.1229 -	}
115.1230 -
115.1231 -	elfCies = cies;
115.1232 -}
115.1233 -
115.1234 -void elfAddLine(LineInfo *l, u32 a, int file, int line, int *max)
115.1235 -{
115.1236 -	if (l->number == *max)
115.1237 -	{
115.1238 -		*max    += 1000;
115.1239 -		l->lines = (LineInfoItem *)realloc(l->lines, *max*sizeof(LineInfoItem));
115.1240 -	}
115.1241 -	LineInfoItem *li = &l->lines[l->number];
115.1242 -	li->file    = l->files[file-1];
115.1243 -	li->address = a;
115.1244 -	li->line    = line;
115.1245 -	l->number++;
115.1246 -}
115.1247 -
115.1248 -void elfParseLineInfo(CompileUnit *unit, u8 *top)
115.1249 -{
115.1250 -	ELFSectionHeader *h = elfGetSectionByName(".debug_line");
115.1251 -	if (h == NULL)
115.1252 -	{
115.1253 -		fprintf(stderr, "No line information found\n");
115.1254 -		return;
115.1255 -	}
115.1256 -	LineInfo *l = unit->lineInfoTable = (LineInfo *)calloc(1, sizeof(LineInfo));
115.1257 -	l->number = 0;
115.1258 -	int max = 1000;
115.1259 -	l->lines = (LineInfoItem *)malloc(1000*sizeof(LineInfoItem));
115.1260 -
115.1261 -	u8 *data = elfReadSection(top, h);
115.1262 -	data += unit->lineInfo;
115.1263 -	u32 totalLen = elfRead4Bytes(data);
115.1264 -	data += 4;
115.1265 -	u8 *end = data + totalLen;
115.1266 -	//  u16 version = elfRead2Bytes(data);
115.1267 -	data += 2;
115.1268 -	//  u32 offset = elfRead4Bytes(data);
115.1269 -	data += 4;
115.1270 -	int minInstrSize  = *data++;
115.1271 -	int defaultIsStmt = *data++;
115.1272 -	int lineBase      = (s8)*data++;
115.1273 -	int lineRange     = *data++;
115.1274 -	int opcodeBase    = *data++;
115.1275 -	u8 *stdOpLen      = (u8 *)malloc(opcodeBase * sizeof(u8));
115.1276 -	stdOpLen[0] = 1;
115.1277 -	int i;
115.1278 -	for (i = 1; i < opcodeBase; i++)
115.1279 -		stdOpLen[i] = *data++;
115.1280 -
115.1281 -	free(stdOpLen); // todo
115.1282 -	int bytes = 0;
115.1283 -
115.1284 -	char *s;
115.1285 -	while ((s = elfReadString(data, &bytes)) != NULL)
115.1286 -	{
115.1287 -		data += bytes;
115.1288 -		//    fprintf(stderr, "Directory is %s\n", s);
115.1289 -	}
115.1290 -	data += bytes;
115.1291 -	int count = 4;
115.1292 -	int index = 0;
115.1293 -	l->files = (char * *)malloc(sizeof(char *)*count);
115.1294 -
115.1295 -	while ((s = elfReadString(data, &bytes)) != NULL)
115.1296 -	{
115.1297 -		l->files[index++] = s;
115.1298 -
115.1299 -		data += bytes;
115.1300 -		// directory
115.1301 -		elfReadLEB128(data, &bytes);
115.1302 -		data += bytes;
115.1303 -		// time
115.1304 -		elfReadLEB128(data, &bytes);
115.1305 -		data += bytes;
115.1306 -		// size
115.1307 -		elfReadLEB128(data, &bytes);
115.1308 -		data += bytes;
115.1309 -		//    fprintf(stderr, "File is %s\n", s);
115.1310 -		if (index == count)
115.1311 -		{
115.1312 -			count   += 4;
115.1313 -			l->files = (char * *)realloc(l->files, sizeof(char *)*count);
115.1314 -		}
115.1315 -	}
115.1316 -	l->fileCount = index;
115.1317 -	data        += bytes;
115.1318 -
115.1319 -	while (data < end)
115.1320 -	{
115.1321 -		u32 address    = 0;
115.1322 -		int file       = 1;
115.1323 -		int line       = 1;
115.1324 -		int col        = 0;
115.1325 -		int isStmt     = defaultIsStmt;
115.1326 -		int basicBlock = 0;
115.1327 -		int endSeq     = 0;
115.1328 -
115.1329 -		while (!endSeq)
115.1330 -		{
115.1331 -			int op = *data++;
115.1332 -			switch (op)
115.1333 -			{
115.1334 -			case DW_LNS_extended_op:
115.1335 -			{
115.1336 -				data++;
115.1337 -				op = *data++;
115.1338 -				switch (op)
115.1339 -				{
115.1340 -				case DW_LNE_end_sequence:
115.1341 -					endSeq = 1;
115.1342 -					break;
115.1343 -				case DW_LNE_set_address:
115.1344 -					address = elfRead4Bytes(data);
115.1345 -					data   += 4;
115.1346 -					break;
115.1347 -				default:
115.1348 -					fprintf(stderr, "Unknown extended LINE opcode %02x\n", op);
115.1349 -					exit(-1);
115.1350 -				}
115.1351 -				break;
115.1352 -			}
115.1353 -			case DW_LNS_copy:
115.1354 -				//      fprintf(stderr, "Address %08x line %d (%d)\n", address, line, file);
115.1355 -				elfAddLine(l, address, file, line, &max);
115.1356 -				basicBlock = 0;
115.1357 -				break;
115.1358 -			case DW_LNS_advance_pc:
115.1359 -				address += minInstrSize * elfReadLEB128(data, &bytes);
115.1360 -				data    += bytes;
115.1361 -				break;
115.1362 -			case DW_LNS_advance_line:
115.1363 -				line += elfReadSignedLEB128(data, &bytes);
115.1364 -				data += bytes;
115.1365 -				break;
115.1366 -			case DW_LNS_set_file:
115.1367 -				file  = elfReadLEB128(data, &bytes);
115.1368 -				data += bytes;
115.1369 -				break;
115.1370 -			case DW_LNS_set_column:
115.1371 -				col   = elfReadLEB128(data, &bytes);
115.1372 -				data += bytes;
115.1373 -				break;
115.1374 -			case DW_LNS_negate_stmt:
115.1375 -				isStmt = !isStmt;
115.1376 -				break;
115.1377 -			case DW_LNS_set_basic_block:
115.1378 -				basicBlock = 1;
115.1379 -				break;
115.1380 -			case DW_LNS_const_add_pc:
115.1381 -				address += (minInstrSize *((255 - opcodeBase)/lineRange));
115.1382 -				break;
115.1383 -			case DW_LNS_fixed_advance_pc:
115.1384 -				address += elfRead2Bytes(data);
115.1385 -				data    += 2;
115.1386 -				break;
115.1387 -			default:
115.1388 -				op       = op - opcodeBase;
115.1389 -				address += (op / lineRange) * minInstrSize;
115.1390 -				line    += lineBase + (op % lineRange);
115.1391 -				elfAddLine(l, address, file, line, &max);
115.1392 -				//        fprintf(stderr, "Address %08x line %d (%d)\n", address, line,file);
115.1393 -				basicBlock = 1;
115.1394 -				break;
115.1395 -			}
115.1396 -		}
115.1397 -	}
115.1398 -	l->lines = (LineInfoItem *)realloc(l->lines, l->number*sizeof(LineInfoItem));
115.1399 -}
115.1400 -
115.1401 -u8 *elfSkipData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
115.1402 -{
115.1403 -	int i;
115.1404 -	int bytes;
115.1405 -
115.1406 -	for (i = 0; i < abbrev->numAttrs; i++)
115.1407 -	{
115.1408 -		data = elfReadAttribute(data,  &abbrev->attrs[i]);
115.1409 -		if (abbrev->attrs[i].form == DW_FORM_block1)
115.1410 -			free(abbrev->attrs[i].block);
115.1411 -	}
115.1412 -
115.1413 -	if (abbrev->hasChildren)
115.1414 -	{
115.1415 -		int nesting = 1;
115.1416 -		while (nesting)
115.1417 -		{
115.1418 -			u32 abbrevNum = elfReadLEB128(data, &bytes);
115.1419 -			data += bytes;
115.1420 -
115.1421 -			if (!abbrevNum)
115.1422 -			{
115.1423 -				nesting--;
115.1424 -				continue;
115.1425 -			}
115.1426 -
115.1427 -			abbrev = elfGetAbbrev(abbrevs, abbrevNum);
115.1428 -
115.1429 -			for (i = 0; i < abbrev->numAttrs; i++)
115.1430 -			{
115.1431 -				data = elfReadAttribute(data,  &abbrev->attrs[i]);
115.1432 -				if (abbrev->attrs[i].form == DW_FORM_block1)
115.1433 -					free(abbrev->attrs[i].block);
115.1434 -			}
115.1435 -
115.1436 -			if (abbrev->hasChildren)
115.1437 -			{
115.1438 -				nesting++;
115.1439 -			}
115.1440 -		}
115.1441 -	}
115.1442 -	return data;
115.1443 -}
115.1444 -
115.1445 -Type *elfParseType(CompileUnit *unit, u32);
115.1446 -u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
115.1447 -                   Object **object);
115.1448 -u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
115.1449 -                     Function **function);
115.1450 -void elfCleanUp(Function *);
115.1451 -
115.1452 -void elfAddType(Type *type, CompileUnit *unit, u32 offset)
115.1453 -{
115.1454 -	if (type->next == NULL)
115.1455 -	{
115.1456 -		if (unit->types != type && type->offset == 0)
115.1457 -		{
115.1458 -			type->offset = offset;
115.1459 -			type->next   = unit->types;
115.1460 -			unit->types  = type;
115.1461 -		}
115.1462 -	}
115.1463 -}
115.1464 -
115.1465 -void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
115.1466 -                  Type **type)
115.1467 -{
115.1468 -	switch (abbrev->tag)
115.1469 -	{
115.1470 -	case DW_TAG_typedef:
115.1471 -	{
115.1472 -		u32   typeref = 0;
115.1473 -		char *name    = NULL;
115.1474 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1475 -		{
115.1476 -			ELFAttr *attr = &abbrev->attrs[i];
115.1477 -			data = elfReadAttribute(data, attr);
115.1478 -			switch (attr->name)
115.1479 -			{
115.1480 -			case DW_AT_name:
115.1481 -				name = attr->string;
115.1482 -				break;
115.1483 -			case DW_AT_type:
115.1484 -				typeref = attr->value;
115.1485 -				break;
115.1486 -			case DW_AT_decl_file:
115.1487 -			case DW_AT_decl_line:
115.1488 -				break;
115.1489 -			default:
115.1490 -				fprintf(stderr, "Unknown attribute for typedef %02x\n", attr->name);
115.1491 -				break;
115.1492 -			}
115.1493 -		}
115.1494 -		if (abbrev->hasChildren)
115.1495 -			fprintf(stderr, "Unexpected children for typedef\n");
115.1496 -		*type = elfParseType(unit, typeref);
115.1497 -		if (name)
115.1498 -			(*type)->name = name;
115.1499 -		return;
115.1500 -		break;
115.1501 -	}
115.1502 -	case DW_TAG_union_type:
115.1503 -	case DW_TAG_structure_type:
115.1504 -	{
115.1505 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1506 -		if (abbrev->tag == DW_TAG_structure_type)
115.1507 -			t->type = TYPE_struct;
115.1508 -		else
115.1509 -			t->type = TYPE_union;
115.1510 -
115.1511 -		Struct *s = (Struct *)calloc(sizeof(Struct), 1);
115.1512 -		t->structure = s;
115.1513 -		elfAddType(t, unit, offset);
115.1514 -
115.1515 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1516 -		{
115.1517 -			ELFAttr *attr = &abbrev->attrs[i];
115.1518 -			data = elfReadAttribute(data, attr);
115.1519 -			switch (attr->name)
115.1520 -			{
115.1521 -			case DW_AT_name:
115.1522 -				t->name = attr->string;
115.1523 -				break;
115.1524 -			case DW_AT_byte_size:
115.1525 -				t->size = attr->value;
115.1526 -				break;
115.1527 -			case DW_AT_decl_file:
115.1528 -			case DW_AT_decl_line:
115.1529 -			case DW_AT_sibling:
115.1530 -			case DW_AT_containing_type: // todo?
115.1531 -			case DW_AT_declaration:
115.1532 -			case DW_AT_specification: // TODO:
115.1533 -				break;
115.1534 -			default:
115.1535 -				fprintf(stderr, "Unknown attribute for struct %02x\n", attr->name);
115.1536 -				break;
115.1537 -			}
115.1538 -		}
115.1539 -		if (abbrev->hasChildren)
115.1540 -		{
115.1541 -			int bytes;
115.1542 -			u32 num = elfReadLEB128(data, &bytes);
115.1543 -			data += bytes;
115.1544 -			int index = 0;
115.1545 -			while (num)
115.1546 -			{
115.1547 -				ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
115.1548 -
115.1549 -				switch (abbr->tag)
115.1550 -				{
115.1551 -				case DW_TAG_member:
115.1552 -				{
115.1553 -					if ((index % 4) == 0)
115.1554 -						s->members = (Member *)realloc(s->members,
115.1555 -						                               sizeof(Member)*(index+4));
115.1556 -					Member *m = &s->members[index];
115.1557 -					m->location  = NULL;
115.1558 -					m->bitOffset = 0;
115.1559 -					m->bitSize   = 0;
115.1560 -					m->byteSize  = 0;
115.1561 -					for (int i = 0; i < abbr->numAttrs; i++)
115.1562 -					{
115.1563 -						ELFAttr *attr = &abbr->attrs[i];
115.1564 -						data = elfReadAttribute(data, attr);
115.1565 -						switch (attr->name)
115.1566 -						{
115.1567 -						case DW_AT_name:
115.1568 -							m->name = attr->string;
115.1569 -							break;
115.1570 -						case DW_AT_type:
115.1571 -							m->type = elfParseType(unit, attr->value);
115.1572 -							break;
115.1573 -						case DW_AT_data_member_location:
115.1574 -							m->location = attr->block;
115.1575 -							break;
115.1576 -						case DW_AT_byte_size:
115.1577 -							m->byteSize = attr->value;
115.1578 -							break;
115.1579 -						case DW_AT_bit_offset:
115.1580 -							m->bitOffset = attr->value;
115.1581 -							break;
115.1582 -						case DW_AT_bit_size:
115.1583 -							m->bitSize = attr->value;
115.1584 -							break;
115.1585 -						case DW_AT_decl_file:
115.1586 -						case DW_AT_decl_line:
115.1587 -						case DW_AT_accessibility:
115.1588 -						case DW_AT_artificial: // todo?
115.1589 -							break;
115.1590 -						default:
115.1591 -							fprintf(stderr, "Unknown member attribute %02x\n",
115.1592 -							        attr->name);
115.1593 -						}
115.1594 -					}
115.1595 -					index++;
115.1596 -					break;
115.1597 -				}
115.1598 -				case DW_TAG_subprogram:
115.1599 -				{
115.1600 -					Function *fnc = NULL;
115.1601 -					data = elfParseFunction(data, abbr, unit, &fnc);
115.1602 -					if (fnc != NULL)
115.1603 -					{
115.1604 -						if (unit->lastFunction)
115.1605 -							unit->lastFunction->next = fnc;
115.1606 -						else
115.1607 -							unit->functions = fnc;
115.1608 -						unit->lastFunction = fnc;
115.1609 -					}
115.1610 -					break;
115.1611 -				}
115.1612 -				case DW_TAG_inheritance:
115.1613 -					// TODO: add support
115.1614 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1615 -					break;
115.1616 -CASE_TYPE_TAG:
115.1617 -					// skip types... parsed only when used
115.1618 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1619 -					break;
115.1620 -				case DW_TAG_variable:
115.1621 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1622 -					break;
115.1623 -				default:
115.1624 -					fprintf(stderr, "Unknown struct tag %02x %s\n", abbr->tag, t->name);
115.1625 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1626 -					break;
115.1627 -				}
115.1628 -				num   = elfReadLEB128(data, &bytes);
115.1629 -				data += bytes;
115.1630 -			}
115.1631 -			s->memberCount = index;
115.1632 -		}
115.1633 -		*type = t;
115.1634 -		return;
115.1635 -		break;
115.1636 -	}
115.1637 -	case DW_TAG_base_type:
115.1638 -	{
115.1639 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1640 -
115.1641 -		t->type = TYPE_base;
115.1642 -		elfAddType(t, unit, offset);
115.1643 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1644 -		{
115.1645 -			ELFAttr *attr = &abbrev->attrs[i];
115.1646 -			data = elfReadAttribute(data, attr);
115.1647 -			switch (attr->name)
115.1648 -			{
115.1649 -			case DW_AT_name:
115.1650 -				t->name = attr->string;
115.1651 -				break;
115.1652 -			case DW_AT_encoding:
115.1653 -				t->encoding = attr->value;
115.1654 -				break;
115.1655 -			case DW_AT_byte_size:
115.1656 -				t->size = attr->value;
115.1657 -				break;
115.1658 -			case DW_AT_bit_size:
115.1659 -				t->bitSize = attr->value;
115.1660 -				break;
115.1661 -			default:
115.1662 -				fprintf(stderr, "Unknown attribute for base type %02x\n",
115.1663 -				        attr->name);
115.1664 -				break;
115.1665 -			}
115.1666 -		}
115.1667 -		if (abbrev->hasChildren)
115.1668 -			fprintf(stderr, "Unexpected children for base type\n");
115.1669 -		*type = t;
115.1670 -		return;
115.1671 -		break;
115.1672 -	}
115.1673 -	case DW_TAG_pointer_type:
115.1674 -	{
115.1675 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1676 -
115.1677 -		t->type = TYPE_pointer;
115.1678 -
115.1679 -		elfAddType(t, unit, offset);
115.1680 -
115.1681 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1682 -		{
115.1683 -			ELFAttr *attr = &abbrev->attrs[i];
115.1684 -			data = elfReadAttribute(data, attr);
115.1685 -			switch (attr->name)
115.1686 -			{
115.1687 -			case DW_AT_type:
115.1688 -				t->pointer = elfParseType(unit, attr->value);
115.1689 -				break;
115.1690 -			case DW_AT_byte_size:
115.1691 -				t->size = attr->value;
115.1692 -				break;
115.1693 -			default:
115.1694 -				fprintf(stderr, "Unknown pointer type attribute %02x\n", attr->name);
115.1695 -				break;
115.1696 -			}
115.1697 -		}
115.1698 -		if (abbrev->hasChildren)
115.1699 -			fprintf(stderr, "Unexpected children for pointer type\n");
115.1700 -		*type = t;
115.1701 -		return;
115.1702 -		break;
115.1703 -	}
115.1704 -	case DW_TAG_reference_type:
115.1705 -	{
115.1706 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1707 -
115.1708 -		t->type = TYPE_reference;
115.1709 -
115.1710 -		elfAddType(t, unit, offset);
115.1711 -
115.1712 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1713 -		{
115.1714 -			ELFAttr *attr = &abbrev->attrs[i];
115.1715 -			data = elfReadAttribute(data, attr);
115.1716 -			switch (attr->name)
115.1717 -			{
115.1718 -			case DW_AT_type:
115.1719 -				t->pointer = elfParseType(unit, attr->value);
115.1720 -				break;
115.1721 -			case DW_AT_byte_size:
115.1722 -				t->size = attr->value;
115.1723 -				break;
115.1724 -			default:
115.1725 -				fprintf(stderr, "Unknown ref type attribute %02x\n", attr->name);
115.1726 -				break;
115.1727 -			}
115.1728 -		}
115.1729 -		if (abbrev->hasChildren)
115.1730 -			fprintf(stderr, "Unexpected children for ref type\n");
115.1731 -		*type = t;
115.1732 -		return;
115.1733 -		break;
115.1734 -	}
115.1735 -	case DW_TAG_volatile_type:
115.1736 -	{
115.1737 -		u32 typeref = 0;
115.1738 -
115.1739 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1740 -		{
115.1741 -			ELFAttr *attr = &abbrev->attrs[i];
115.1742 -			data = elfReadAttribute(data, attr);
115.1743 -			switch (attr->name)
115.1744 -			{
115.1745 -			case DW_AT_type:
115.1746 -				typeref = attr->value;
115.1747 -				break;
115.1748 -			default:
115.1749 -				fprintf(stderr, "Unknown volatile attribute for type %02x\n",
115.1750 -				        attr->name);
115.1751 -				break;
115.1752 -			}
115.1753 -		}
115.1754 -		if (abbrev->hasChildren)
115.1755 -			fprintf(stderr, "Unexpected children for volatile type\n");
115.1756 -		*type = elfParseType(unit, typeref);
115.1757 -		return;
115.1758 -		break;
115.1759 -	}
115.1760 -	case DW_TAG_const_type:
115.1761 -	{
115.1762 -		u32 typeref = 0;
115.1763 -
115.1764 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1765 -		{
115.1766 -			ELFAttr *attr = &abbrev->attrs[i];
115.1767 -			data = elfReadAttribute(data, attr);
115.1768 -			switch (attr->name)
115.1769 -			{
115.1770 -			case DW_AT_type:
115.1771 -				typeref = attr->value;
115.1772 -				break;
115.1773 -			default:
115.1774 -				fprintf(stderr, "Unknown const attribute for type %02x\n",
115.1775 -				        attr->name);
115.1776 -				break;
115.1777 -			}
115.1778 -		}
115.1779 -		if (abbrev->hasChildren)
115.1780 -			fprintf(stderr, "Unexpected children for const type\n");
115.1781 -		*type = elfParseType(unit, typeref);
115.1782 -		return;
115.1783 -		break;
115.1784 -	}
115.1785 -	case DW_TAG_enumeration_type:
115.1786 -	{
115.1787 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1788 -		t->type = TYPE_enum;
115.1789 -		Enum *e = (Enum *)calloc(sizeof(Enum), 1);
115.1790 -		t->enumeration = e;
115.1791 -		elfAddType(t, unit, offset);
115.1792 -		int count = 0;
115.1793 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1794 -		{
115.1795 -			ELFAttr *attr = &abbrev->attrs[i];
115.1796 -			data = elfReadAttribute(data, attr);
115.1797 -			switch (attr->name)
115.1798 -			{
115.1799 -			case DW_AT_name:
115.1800 -				t->name = attr->string;
115.1801 -				break;
115.1802 -			case DW_AT_byte_size:
115.1803 -				t->size = attr->value;
115.1804 -				break;
115.1805 -			case DW_AT_sibling:
115.1806 -			case DW_AT_decl_file:
115.1807 -			case DW_AT_decl_line:
115.1808 -				break;
115.1809 -			default:
115.1810 -				fprintf(stderr, "Unknown enum attribute %02x\n", attr->name);
115.1811 -			}
115.1812 -		}
115.1813 -		if (abbrev->hasChildren)
115.1814 -		{
115.1815 -			int bytes;
115.1816 -			u32 num = elfReadLEB128(data, &bytes);
115.1817 -			data += bytes;
115.1818 -			while (num)
115.1819 -			{
115.1820 -				ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
115.1821 -
115.1822 -				switch (abbr->tag)
115.1823 -				{
115.1824 -				case DW_TAG_enumerator:
115.1825 -				{
115.1826 -					count++;
115.1827 -					e->members = (EnumMember *)realloc(e->members,
115.1828 -					                                   count*sizeof(EnumMember));
115.1829 -					EnumMember *m = &e->members[count-1];
115.1830 -					for (int i = 0; i < abbr->numAttrs; i++)
115.1831 -					{
115.1832 -						ELFAttr *attr = &abbr->attrs[i];
115.1833 -						data = elfReadAttribute(data, attr);
115.1834 -						switch (attr->name)
115.1835 -						{
115.1836 -						case DW_AT_name:
115.1837 -							m->name = attr->string;
115.1838 -							break;
115.1839 -						case DW_AT_const_value:
115.1840 -							m->value = attr->value;
115.1841 -							break;
115.1842 -						default:
115.1843 -							fprintf(stderr, "Unknown sub param attribute %02x\n",
115.1844 -							        attr->name);
115.1845 -						}
115.1846 -					}
115.1847 -					break;
115.1848 -				}
115.1849 -				default:
115.1850 -					fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag);
115.1851 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1852 -					break;
115.1853 -				}
115.1854 -				num   = elfReadLEB128(data, &bytes);
115.1855 -				data += bytes;
115.1856 -			}
115.1857 -		}
115.1858 -		e->count = count;
115.1859 -		*type    = t;
115.1860 -		return;
115.1861 -		break;
115.1862 -	}
115.1863 -	case DW_TAG_subroutine_type:
115.1864 -	{
115.1865 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.1866 -		t->type = TYPE_function;
115.1867 -		FunctionType *f = (FunctionType *)calloc(sizeof(FunctionType), 1);
115.1868 -		t->function = f;
115.1869 -		elfAddType(t, unit, offset);
115.1870 -		for (int i = 0; i < abbrev->numAttrs; i++)
115.1871 -		{
115.1872 -			ELFAttr *attr = &abbrev->attrs[i];
115.1873 -			data = elfReadAttribute(data, attr);
115.1874 -			switch (attr->name)
115.1875 -			{
115.1876 -			case DW_AT_prototyped:
115.1877 -			case DW_AT_sibling:
115.1878 -				break;
115.1879 -			case DW_AT_type:
115.1880 -				f->returnType = elfParseType(unit, attr->value);
115.1881 -				break;
115.1882 -			default:
115.1883 -				fprintf(stderr, "Unknown subroutine attribute %02x\n", attr->name);
115.1884 -			}
115.1885 -		}
115.1886 -		if (abbrev->hasChildren)
115.1887 -		{
115.1888 -			int bytes;
115.1889 -			u32 num = elfReadLEB128(data, &bytes);
115.1890 -			data += bytes;
115.1891 -			Object *lastVar = NULL;
115.1892 -			while (num)
115.1893 -			{
115.1894 -				ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
115.1895 -
115.1896 -				switch (abbr->tag)
115.1897 -				{
115.1898 -				case DW_TAG_formal_parameter:
115.1899 -				{
115.1900 -					Object *o;
115.1901 -					data = elfParseObject(data, abbr, unit, &o);
115.1902 -					if (f->args)
115.1903 -						lastVar->next = o;
115.1904 -					else
115.1905 -						f->args = o;
115.1906 -					lastVar = o;
115.1907 -					break;
115.1908 -				}
115.1909 -				case DW_TAG_unspecified_parameters:
115.1910 -					// no use in the debugger yet
115.1911 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1912 -					break;
115.1913 -CASE_TYPE_TAG:
115.1914 -					// skip types... parsed only when used
115.1915 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1916 -					break;
115.1917 -				default:
115.1918 -					fprintf(stderr, "Unknown subroutine tag %02x\n", abbr->tag);
115.1919 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1920 -					break;
115.1921 -				}
115.1922 -				num   = elfReadLEB128(data, &bytes);
115.1923 -				data += bytes;
115.1924 -			}
115.1925 -		}
115.1926 -		*type = t;
115.1927 -		return;
115.1928 -		break;
115.1929 -	}
115.1930 -	case DW_TAG_array_type:
115.1931 -	{
115.1932 -		u32    typeref = 0;
115.1933 -		int    i;
115.1934 -		Array *array = (Array *)calloc(sizeof(Array), 1);
115.1935 -		Type * t     = (Type *)calloc(sizeof(Type), 1);
115.1936 -		t->type = TYPE_array;
115.1937 -		elfAddType(t, unit, offset);
115.1938 -
115.1939 -		for (i = 0; i < abbrev->numAttrs; i++)
115.1940 -		{
115.1941 -			ELFAttr *attr = &abbrev->attrs[i];
115.1942 -			data = elfReadAttribute(data, attr);
115.1943 -			switch (attr->name)
115.1944 -			{
115.1945 -			case DW_AT_sibling:
115.1946 -				break;
115.1947 -			case DW_AT_type:
115.1948 -				typeref     = attr->value;
115.1949 -				array->type = elfParseType(unit, typeref);
115.1950 -				break;
115.1951 -			default:
115.1952 -				fprintf(stderr, "Unknown array attribute %02x\n", attr->name);
115.1953 -			}
115.1954 -		}
115.1955 -		if (abbrev->hasChildren)
115.1956 -		{
115.1957 -			int bytes;
115.1958 -			u32 num = elfReadLEB128(data, &bytes);
115.1959 -			data += bytes;
115.1960 -			int index     = 0;
115.1961 -			int maxBounds = 0;
115.1962 -			while (num)
115.1963 -			{
115.1964 -				ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
115.1965 -
115.1966 -				switch (abbr->tag)
115.1967 -				{
115.1968 -				case DW_TAG_subrange_type:
115.1969 -				{
115.1970 -					if (maxBounds == index)
115.1971 -					{
115.1972 -						maxBounds    += 4;
115.1973 -						array->bounds = (int *)realloc(array->bounds,
115.1974 -						                               sizeof(int)*maxBounds);
115.1975 -					}
115.1976 -					for (int i = 0; i < abbr->numAttrs; i++)
115.1977 -					{
115.1978 -						ELFAttr *attr = &abbr->attrs[i];
115.1979 -						data = elfReadAttribute(data, attr);
115.1980 -						switch (attr->name)
115.1981 -						{
115.1982 -						case DW_AT_upper_bound:
115.1983 -							array->bounds[index] = attr->value+1;
115.1984 -							break;
115.1985 -						case DW_AT_type: // ignore
115.1986 -							break;
115.1987 -						default:
115.1988 -							fprintf(stderr, "Unknown subrange attribute %02x\n",
115.1989 -							        attr->name);
115.1990 -						}
115.1991 -					}
115.1992 -					index++;
115.1993 -					break;
115.1994 -				}
115.1995 -				default:
115.1996 -					fprintf(stderr, "Unknown array tag %02x\n", abbr->tag);
115.1997 -					data = elfSkipData(data, abbr, unit->abbrevs);
115.1998 -					break;
115.1999 -				}
115.2000 -				num   = elfReadLEB128(data, &bytes);
115.2001 -				data += bytes;
115.2002 -			}
115.2003 -			array->maxBounds = index;
115.2004 -		}
115.2005 -		t->size = array->type->size;
115.2006 -		for (i = 0; i < array->maxBounds; i++)
115.2007 -			t->size *= array->bounds[i];
115.2008 -		t->array = array;
115.2009 -		*type    = t;
115.2010 -		return;
115.2011 -		break;
115.2012 -	}
115.2013 -	default:
115.2014 -		fprintf(stderr, "Unknown type TAG %02x\n", abbrev->tag);
115.2015 -		exit(-1);
115.2016 -	}
115.2017 -}
115.2018 -
115.2019 -Type *elfParseType(CompileUnit *unit, u32 offset)
115.2020 -{
115.2021 -	Type *t = unit->types;
115.2022 -
115.2023 -	while (t)
115.2024 -	{
115.2025 -		if (t->offset == offset)
115.2026 -			return t;
115.2027 -		t = t->next;
115.2028 -	}
115.2029 -	if (offset == 0)
115.2030 -	{
115.2031 -		Type *t = (Type *)calloc(sizeof(Type), 1);
115.2032 -		t->type   = TYPE_void;
115.2033 -		t->offset = 0;
115.2034 -		elfAddType(t, unit, 0);
115.2035 -		return t;
115.2036 -	}
115.2037 -	u8 *data = unit->top + offset;
115.2038 -	int bytes;
115.2039 -	int abbrevNum = elfReadLEB128(data, &bytes);
115.2040 -	data += bytes;
115.2041 -	Type *type = NULL;
115.2042 -
115.2043 -	ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2044 -
115.2045 -	elfParseType(data, offset, abbrev, unit, &type);
115.2046 -	return type;
115.2047 -}
115.2048 -
115.2049 -void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
115.2050 -{
115.2051 -	u8 *data = unit->top + offset;
115.2052 -	int bytes;
115.2053 -	u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2054 -	data += bytes;
115.2055 -
115.2056 -	if (!abbrevNum)
115.2057 -	{
115.2058 -		return;
115.2059 -	}
115.2060 -
115.2061 -	ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2062 -
115.2063 -	for (int i = 0; i < abbrev->numAttrs; i++)
115.2064 -	{
115.2065 -		ELFAttr *attr = &abbrev->attrs[i];
115.2066 -		data = elfReadAttribute(data, attr);
115.2067 -		switch (attr->name)
115.2068 -		{
115.2069 -		case DW_AT_location:
115.2070 -			o->location = attr->block;
115.2071 -			break;
115.2072 -		case DW_AT_name:
115.2073 -			if (o->name == NULL)
115.2074 -				o->name = attr->string;
115.2075 -			break;
115.2076 -		case DW_AT_MIPS_linkage_name:
115.2077 -			o->name = attr->string;
115.2078 -			break;
115.2079 -		case DW_AT_decl_file:
115.2080 -			o->file = attr->value;
115.2081 -			break;
115.2082 -		case DW_AT_decl_line:
115.2083 -			o->line = attr->value;
115.2084 -			break;
115.2085 -		case DW_AT_type:
115.2086 -			o->type = elfParseType(unit, attr->value);
115.2087 -			break;
115.2088 -		case DW_AT_external:
115.2089 -			o->external = attr->flag;
115.2090 -			break;
115.2091 -		case DW_AT_const_value:
115.2092 -		case DW_AT_abstract_origin:
115.2093 -		case DW_AT_declaration:
115.2094 -		case DW_AT_artificial:
115.2095 -			// todo
115.2096 -			break;
115.2097 -		case DW_AT_specification:
115.2098 -			// TODO:
115.2099 -			break;
115.2100 -		default:
115.2101 -			fprintf(stderr, "Unknown object attribute %02x\n", attr->name);
115.2102 -			break;
115.2103 -		}
115.2104 -	}
115.2105 -}
115.2106 -
115.2107 -u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
115.2108 -                   Object **object)
115.2109 -{
115.2110 -	Object *o = (Object *)calloc(sizeof(Object), 1);
115.2111 -
115.2112 -	o->next = NULL;
115.2113 -
115.2114 -	for (int i = 0; i < abbrev->numAttrs; i++)
115.2115 -	{
115.2116 -		ELFAttr *attr = &abbrev->attrs[i];
115.2117 -		data = elfReadAttribute(data, attr);
115.2118 -		switch (attr->name)
115.2119 -		{
115.2120 -		case DW_AT_location:
115.2121 -			o->location = attr->block;
115.2122 -			break;
115.2123 -		case DW_AT_name:
115.2124 -			if (o->name == NULL)
115.2125 -				o->name = attr->string;
115.2126 -			break;
115.2127 -		case DW_AT_MIPS_linkage_name:
115.2128 -			o->name = attr->string;
115.2129 -			break;
115.2130 -		case DW_AT_decl_file:
115.2131 -			o->file = attr->value;
115.2132 -			break;
115.2133 -		case DW_AT_decl_line:
115.2134 -			o->line = attr->value;
115.2135 -			break;
115.2136 -		case DW_AT_type:
115.2137 -			o->type = elfParseType(unit, attr->value);
115.2138 -			break;
115.2139 -		case DW_AT_external:
115.2140 -			o->external = attr->flag;
115.2141 -			break;
115.2142 -		case DW_AT_abstract_origin:
115.2143 -			elfGetObjectAttributes(unit, attr->value, o);
115.2144 -			break;
115.2145 -		case DW_AT_const_value:
115.2146 -		case DW_AT_declaration:
115.2147 -		case DW_AT_artificial:
115.2148 -			break;
115.2149 -		case DW_AT_specification:
115.2150 -			// TODO:
115.2151 -			break;
115.2152 -		default:
115.2153 -			fprintf(stderr, "Unknown object attribute %02x\n", attr->name);
115.2154 -			break;
115.2155 -		}
115.2156 -	}
115.2157 -	*object = o;
115.2158 -	return data;
115.2159 -}
115.2160 -
115.2161 -u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
115.2162 -                  Function *func, Object **lastVar)
115.2163 -{
115.2164 -	int bytes;
115.2165 -	u32 start = func->lowPC;
115.2166 -	u32 end   = func->highPC;
115.2167 -
115.2168 -	for (int i = 0; i < abbrev->numAttrs; i++)
115.2169 -	{
115.2170 -		ELFAttr *attr = &abbrev->attrs[i];
115.2171 -		data = elfReadAttribute(data, attr);
115.2172 -		switch (attr->name)
115.2173 -		{
115.2174 -		case DW_AT_sibling:
115.2175 -			break;
115.2176 -		case DW_AT_low_pc:
115.2177 -			start = attr->value;
115.2178 -			break;
115.2179 -		case DW_AT_high_pc:
115.2180 -			end = attr->value;
115.2181 -			break;
115.2182 -		case DW_AT_ranges: // ignore for now
115.2183 -			break;
115.2184 -		default:
115.2185 -			fprintf(stderr, "Unknown block attribute %02x\n", attr->name);
115.2186 -			break;
115.2187 -		}
115.2188 -	}
115.2189 -
115.2190 -	if (abbrev->hasChildren)
115.2191 -	{
115.2192 -		int nesting = 1;
115.2193 -
115.2194 -		while (nesting)
115.2195 -		{
115.2196 -			u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2197 -			data += bytes;
115.2198 -
115.2199 -			if (!abbrevNum)
115.2200 -			{
115.2201 -				nesting--;
115.2202 -				continue;
115.2203 -			}
115.2204 -
115.2205 -			abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2206 -
115.2207 -			switch (abbrev->tag)
115.2208 -			{
115.2209 -CASE_TYPE_TAG:       // types only parsed when used
115.2210 -			case DW_TAG_label: // not needed
115.2211 -				data = elfSkipData(data, abbrev, unit->abbrevs);
115.2212 -				break;
115.2213 -			case DW_TAG_lexical_block:
115.2214 -				data = elfParseBlock(data, abbrev, unit, func, lastVar);
115.2215 -				break;
115.2216 -			case DW_TAG_subprogram:
115.2217 -			{
115.2218 -				Function *f = NULL;
115.2219 -				data = elfParseFunction(data, abbrev, unit, &f);
115.2220 -				if (f != NULL)
115.2221 -				{
115.2222 -					if (unit->lastFunction)
115.2223 -						unit->lastFunction->next = f;
115.2224 -					else
115.2225 -						unit->functions = f;
115.2226 -					unit->lastFunction = f;
115.2227 -				}
115.2228 -				break;
115.2229 -			}
115.2230 -			case DW_TAG_variable:
115.2231 -			{
115.2232 -				Object *o;
115.2233 -				data = elfParseObject(data, abbrev, unit, &o);
115.2234 -				if (o->startScope == 0)
115.2235 -					o->startScope = start;
115.2236 -				if (o->endScope == 0)
115.2237 -					o->endScope = 0;
115.2238 -				if (func->variables)
115.2239 -					(*lastVar)->next = o;
115.2240 -				else
115.2241 -					func->variables = o;
115.2242 -				*lastVar = o;
115.2243 -				break;
115.2244 -			}
115.2245 -			case DW_TAG_inlined_subroutine:
115.2246 -				// TODO:
115.2247 -				data = elfSkipData(data, abbrev, unit->abbrevs);
115.2248 -				break;
115.2249 -			default:
115.2250 -			{
115.2251 -				fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag);
115.2252 -				data = elfSkipData(data, abbrev, unit->abbrevs);
115.2253 -				break;
115.2254 -			}
115.2255 -			}
115.2256 -		}
115.2257 -	}
115.2258 -	return data;
115.2259 -}
115.2260 -
115.2261 -void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
115.2262 -{
115.2263 -	u8 *data = unit->top + offset;
115.2264 -	int bytes;
115.2265 -	u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2266 -	data += bytes;
115.2267 -
115.2268 -	if (!abbrevNum)
115.2269 -	{
115.2270 -		return;
115.2271 -	}
115.2272 -
115.2273 -	ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2274 -
115.2275 -	for (int i = 0; i < abbrev->numAttrs; i++)
115.2276 -	{
115.2277 -		ELFAttr *attr = &abbrev->attrs[i];
115.2278 -		data = elfReadAttribute(data, attr);
115.2279 -
115.2280 -		switch (attr->name)
115.2281 -		{
115.2282 -		case DW_AT_sibling:
115.2283 -			break;
115.2284 -		case DW_AT_name:
115.2285 -			if (func->name == NULL)
115.2286 -				func->name = attr->string;
115.2287 -			break;
115.2288 -		case DW_AT_MIPS_linkage_name:
115.2289 -			func->name = attr->string;
115.2290 -			break;
115.2291 -		case DW_AT_low_pc:
115.2292 -			func->lowPC = attr->value;
115.2293 -			break;
115.2294 -		case DW_AT_high_pc:
115.2295 -			func->highPC = attr->value;
115.2296 -			break;
115.2297 -		case DW_AT_decl_file:
115.2298 -			func->file = attr->value;
115.2299 -			break;
115.2300 -		case DW_AT_decl_line:
115.2301 -			func->line = attr->value;
115.2302 -			break;
115.2303 -		case DW_AT_external:
115.2304 -			func->external = attr->flag;
115.2305 -			break;
115.2306 -		case DW_AT_frame_base:
115.2307 -			func->frameBase = attr->block;
115.2308 -			break;
115.2309 -		case DW_AT_type:
115.2310 -			func->returnType = elfParseType(unit, attr->value);
115.2311 -			break;
115.2312 -		case DW_AT_inline:
115.2313 -		case DW_AT_specification:
115.2314 -		case DW_AT_declaration:
115.2315 -		case DW_AT_artificial:
115.2316 -		case DW_AT_prototyped:
115.2317 -		case DW_AT_proc_body:
115.2318 -		case DW_AT_save_offset:
115.2319 -		case DW_AT_user_2002:
115.2320 -		case DW_AT_virtuality:
115.2321 -		case DW_AT_containing_type:
115.2322 -		case DW_AT_accessibility:
115.2323 -			// todo;
115.2324 -			break;
115.2325 -		case DW_AT_vtable_elem_location:
115.2326 -			free(attr->block);
115.2327 -			break;
115.2328 -		default:
115.2329 -			fprintf(stderr, "Unknown function attribute %02x\n", attr->name);
115.2330 -			break;
115.2331 -		}
115.2332 -	}
115.2333 -
115.2334 -	return;
115.2335 -}
115.2336 -
115.2337 -u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
115.2338 -                     Function **f)
115.2339 -{
115.2340 -	Function *func = (Function *)calloc(sizeof(Function), 1);
115.2341 -	*f = func;
115.2342 -
115.2343 -	int  bytes;
115.2344 -	bool mangled     = false;
115.2345 -	bool declaration = false;
115.2346 -	for (int i = 0; i < abbrev->numAttrs; i++)
115.2347 -	{
115.2348 -		ELFAttr *attr = &abbrev->attrs[i];
115.2349 -		data = elfReadAttribute(data, attr);
115.2350 -		switch (attr->name)
115.2351 -		{
115.2352 -		case DW_AT_sibling:
115.2353 -			break;
115.2354 -		case DW_AT_name:
115.2355 -			if (func->name == NULL)
115.2356 -				func->name = attr->string;
115.2357 -			break;
115.2358 -		case DW_AT_MIPS_linkage_name:
115.2359 -			func->name = attr->string;
115.2360 -			mangled    = true;
115.2361 -			break;
115.2362 -		case DW_AT_low_pc:
115.2363 -			func->lowPC = attr->value;
115.2364 -			break;
115.2365 -		case DW_AT_high_pc:
115.2366 -			func->highPC = attr->value;
115.2367 -			break;
115.2368 -		case DW_AT_prototyped:
115.2369 -			break;
115.2370 -		case DW_AT_decl_file:
115.2371 -			func->file = attr->value;
115.2372 -			break;
115.2373 -		case DW_AT_decl_line:
115.2374 -			func->line = attr->value;
115.2375 -			break;
115.2376 -		case DW_AT_external:
115.2377 -			func->external = attr->flag;
115.2378 -			break;
115.2379 -		case DW_AT_frame_base:
115.2380 -			func->frameBase = attr->block;
115.2381 -			break;
115.2382 -		case DW_AT_type:
115.2383 -			func->returnType = elfParseType(unit, attr->value);
115.2384 -			break;
115.2385 -		case DW_AT_abstract_origin:
115.2386 -			elfGetFunctionAttributes(unit, attr->value, func);
115.2387 -			break;
115.2388 -		case DW_AT_declaration:
115.2389 -			declaration = attr->flag;
115.2390 -			break;
115.2391 -		case DW_AT_inline:
115.2392 -		case DW_AT_specification:
115.2393 -		case DW_AT_artificial:
115.2394 -		case DW_AT_proc_body:
115.2395 -		case DW_AT_save_offset:
115.2396 -		case DW_AT_user_2002:
115.2397 -		case DW_AT_virtuality:
115.2398 -		case DW_AT_containing_type:
115.2399 -		case DW_AT_accessibility:
115.2400 -			// todo;
115.2401 -			break;
115.2402 -		case DW_AT_vtable_elem_location:
115.2403 -			free(attr->block);
115.2404 -			break;
115.2405 -		default:
115.2406 -			fprintf(stderr, "Unknown function attribute %02x\n", attr->name);
115.2407 -			break;
115.2408 -		}
115.2409 -	}
115.2410 -
115.2411 -	if (declaration)
115.2412 -	{
115.2413 -		elfCleanUp(func);
115.2414 -		free(func);
115.2415 -		*f = NULL;
115.2416 -
115.2417 -		while (1)
115.2418 -		{
115.2419 -			u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2420 -			data += bytes;
115.2421 -
115.2422 -			if (!abbrevNum)
115.2423 -			{
115.2424 -				return data;
115.2425 -			}
115.2426 -
115.2427 -			abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2428 -
115.2429 -			data = elfSkipData(data, abbrev, unit->abbrevs);
115.2430 -		}
115.2431 -	}
115.2432 -
115.2433 -	if (abbrev->hasChildren)
115.2434 -	{
115.2435 -		int     nesting   = 1;
115.2436 -		Object *lastParam = NULL;
115.2437 -		Object *lastVar   = NULL;
115.2438 -
115.2439 -		while (nesting)
115.2440 -		{
115.2441 -			u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2442 -			data += bytes;
115.2443 -
115.2444 -			if (!abbrevNum)
115.2445 -			{
115.2446 -				nesting--;
115.2447 -				continue;
115.2448 -			}
115.2449 -
115.2450 -			abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2451 -
115.2452 -			switch (abbrev->tag)
115.2453 -			{
115.2454 -CASE_TYPE_TAG:       // no need to parse types. only parsed when used
115.2455 -			case DW_TAG_label: // not needed
115.2456 -				data = elfSkipData(data, abbrev, unit->abbrevs);
115.2457 -				break;
115.2458 -			case DW_TAG_subprogram:
115.2459 -			{
115.2460 -				Function *fnc = NULL;
115.2461 -				data = elfParseFunction(data, abbrev, unit, &fnc);
115.2462 -				if (fnc != NULL)
115.2463 -				{
115.2464 -					if (unit->lastFunction == NULL)
115.2465 -						unit->functions = fnc;
115.2466 -					else
115.2467 -						unit->lastFunction->next = fnc;
115.2468 -					unit->lastFunction = fnc;
115.2469 -				}
115.2470 -				break;
115.2471 -			}
115.2472 -			case DW_TAG_lexical_block:
115.2473 -			{
115.2474 -				data = elfParseBlock(data, abbrev, unit, func, &lastVar);
115.2475 -				break;
115.2476 -			}
115.2477 -			case DW_TAG_formal_parameter:
115.2478 -			{
115.2479 -				Object *o;
115.2480 -				data = elfParseObject(data, abbrev, unit, &o);
115.2481 -				if (func->parameters)
115.2482 -					lastParam->next = o;
115.2483 -				else
115.2484 -					func->parameters = o;
115.2485 -				lastParam = o;
115.2486 -				break;
115.2487 -			}
115.2488 -			case DW_TAG_variable:
115.2489 -			{
115.2490 -				Object *o;
115.2491 -				data = elfParseObject(data, abbrev, unit, &o);
115.2492 -				if (func->variables)
115.2493 -					lastVar->next = o;
115.2494 -				else
115.2495 -					func->variables = o;
115.2496 -				lastVar = o;
115.2497 -				break;
115.2498 -			}
115.2499 -			case DW_TAG_unspecified_parameters:
115.2500 -			case DW_TAG_inlined_subroutine:
115.2501 -			{
115.2502 -				// todo
115.2503 -				for (int i = 0; i < abbrev->numAttrs; i++)
115.2504 -				{
115.2505 -					data = elfReadAttribute(data,  &abbrev->attrs[i]);
115.2506 -					if (abbrev->attrs[i].form == DW_FORM_block1)
115.2507 -						free(abbrev->attrs[i].block);
115.2508 -				}
115.2509 -
115.2510 -				if (abbrev->hasChildren)
115.2511 -					nesting++;
115.2512 -				break;
115.2513 -			}
115.2514 -			default:
115.2515 -			{
115.2516 -				fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag);
115.2517 -				data = elfSkipData(data, abbrev, unit->abbrevs);
115.2518 -				break;
115.2519 -			}
115.2520 -			}
115.2521 -		}
115.2522 -	}
115.2523 -	return data;
115.2524 -}
115.2525 -
115.2526 -u8 *elfParseUnknownData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
115.2527 -{
115.2528 -	int i;
115.2529 -	int bytes;
115.2530 -	//  switch(abbrev->tag) {
115.2531 -	//  default:
115.2532 -	fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
115.2533 -
115.2534 -	for (i = 0; i < abbrev->numAttrs; i++)
115.2535 -	{
115.2536 -		data = elfReadAttribute(data,  &abbrev->attrs[i]);
115.2537 -		if (abbrev->attrs[i].form == DW_FORM_block1)
115.2538 -			free(abbrev->attrs[i].block);
115.2539 -	}
115.2540 -
115.2541 -	if (abbrev->hasChildren)
115.2542 -	{
115.2543 -		int nesting = 1;
115.2544 -		while (nesting)
115.2545 -		{
115.2546 -			u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2547 -			data += bytes;
115.2548 -
115.2549 -			if (!abbrevNum)
115.2550 -			{
115.2551 -				nesting--;
115.2552 -				continue;
115.2553 -			}
115.2554 -
115.2555 -			abbrev = elfGetAbbrev(abbrevs, abbrevNum);
115.2556 -
115.2557 -			fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
115.2558 -
115.2559 -			for (i = 0; i < abbrev->numAttrs; i++)
115.2560 -			{
115.2561 -				data = elfReadAttribute(data,  &abbrev->attrs[i]);
115.2562 -				if (abbrev->attrs[i].form == DW_FORM_block1)
115.2563 -					free(abbrev->attrs[i].block);
115.2564 -			}
115.2565 -
115.2566 -			if (abbrev->hasChildren)
115.2567 -			{
115.2568 -				nesting++;
115.2569 -			}
115.2570 -		}
115.2571 -	}
115.2572 -	//  }
115.2573 -	return data;
115.2574 -}
115.2575 -
115.2576 -u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
115.2577 -{
115.2578 -	int bytes;
115.2579 -	u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2580 -	data += bytes;
115.2581 -	Object *lastObj = NULL;
115.2582 -	while (abbrevNum)
115.2583 -	{
115.2584 -		ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
115.2585 -		switch (abbrev->tag)
115.2586 -		{
115.2587 -		case DW_TAG_subprogram:
115.2588 -		{
115.2589 -			Function *func = NULL;
115.2590 -			data = elfParseFunction(data, abbrev, unit, &func);
115.2591 -			if (func != NULL)
115.2592 -			{
115.2593 -				if (unit->lastFunction)
115.2594 -					unit->lastFunction->next = func;
115.2595 -				else
115.2596 -					unit->functions = func;
115.2597 -				unit->lastFunction = func;
115.2598 -			}
115.2599 -			break;
115.2600 -		}
115.2601 -CASE_TYPE_TAG:
115.2602 -			data = elfSkipData(data, abbrev, unit->abbrevs);
115.2603 -			break;
115.2604 -		case DW_TAG_variable:
115.2605 -		{
115.2606 -			Object *var = NULL;
115.2607 -			data = elfParseObject(data, abbrev, unit, &var);
115.2608 -			if (lastObj)
115.2609 -				lastObj->next = var;
115.2610 -			else
115.2611 -				unit->variables = var;
115.2612 -			lastObj = var;
115.2613 -			break;
115.2614 -		}
115.2615 -		default:
115.2616 -			data = elfParseUnknownData(data, abbrev, unit->abbrevs);
115.2617 -			break;
115.2618 -		}
115.2619 -
115.2620 -		abbrevNum = elfReadLEB128(data, &bytes);
115.2621 -		data     += bytes;
115.2622 -	}
115.2623 -	return data;
115.2624 -}
115.2625 -
115.2626 -CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData)
115.2627 -{
115.2628 -	int bytes;
115.2629 -	u8 *top = data;
115.2630 -
115.2631 -	u32 length = elfRead4Bytes(data);
115.2632 -	data += 4;
115.2633 -
115.2634 -	u16 version = elfRead2Bytes(data);
115.2635 -	data += 2;
115.2636 -
115.2637 -	u32 offset = elfRead4Bytes(data);
115.2638 -	data += 4;
115.2639 -
115.2640 -	u8 addrSize = *data++;
115.2641 -
115.2642 -	if (version != 2)
115.2643 -	{
115.2644 -		fprintf(stderr, "Unsupported debugging information version %d\n", version);
115.2645 -		return NULL;
115.2646 -	}
115.2647 -
115.2648 -	if (addrSize != 4)
115.2649 -	{
115.2650 -		fprintf(stderr, "Unsupported address size %d\n", addrSize);
115.2651 -		return NULL;
115.2652 -	}
115.2653 -
115.2654 -	ELFAbbrev **abbrevs = elfReadAbbrevs(abbrevData, offset);
115.2655 -
115.2656 -	u32 abbrevNum = elfReadLEB128(data, &bytes);
115.2657 -	data += bytes;
115.2658 -
115.2659 -	ELFAbbrev *abbrev = elfGetAbbrev(abbrevs, abbrevNum);
115.2660 -
115.2661 -	CompileUnit *unit = (CompileUnit *)calloc(sizeof(CompileUnit), 1);
115.2662 -	unit->top     = top;
115.2663 -	unit->length  = length;
115.2664 -	unit->abbrevs = abbrevs;
115.2665 -	unit->next    = NULL;
115.2666 -
115.2667 -	elfCurrentUnit = unit;
115.2668 -
115.2669 -	int i;
115.2670 -
115.2671 -	for (i = 0; i < abbrev->numAttrs; i++)
115.2672 -	{
115.2673 -		ELFAttr *attr = &abbrev->attrs[i];
115.2674 -		data = elfReadAttribute(data, attr);
115.2675 -
115.2676 -		switch (attr->name)
115.2677 -		{
115.2678 -		case DW_AT_name:
115.2679 -			unit->name = attr->string;
115.2680 -			break;
115.2681 -		case DW_AT_stmt_list:
115.2682 -			unit->hasLineInfo = true;
115.2683 -			unit->lineInfo    = attr->value;
115.2684 -			break;
115.2685 -		case DW_AT_low_pc:
115.2686 -			unit->lowPC = attr->value;
115.2687 -			break;
115.2688 -		case DW_AT_high_pc:
115.2689 -			unit->highPC = attr->value;
115.2690 -			break;
115.2691 -		case DW_AT_compdir:
115.2692 -			unit->compdir = attr->string;
115.2693 -			break;
115.2694 -		// ignore
115.2695 -		case DW_AT_language:
115.2696 -		case DW_AT_producer:
115.2697 -		case DW_AT_macro_info:
115.2698 -		case DW_AT_entry_pc:
115.2699 -			break;
115.2700 -		default:
115.2701 -			fprintf(stderr, "Unknown attribute %02x\n", attr->name);
115.2702 -			break;
115.2703 -		}
115.2704 -	}
115.2705 -
115.2706 -	if (abbrev->hasChildren)
115.2707 -		elfParseCompileUnitChildren(data, unit);
115.2708 -
115.2709 -	return unit;
115.2710 -}
115.2711 -
115.2712 -void elfParseAranges(u8 *data)
115.2713 -{
115.2714 -	ELFSectionHeader *sh = elfGetSectionByName(".debug_aranges");
115.2715 -	if (sh == NULL)
115.2716 -	{
115.2717 -		fprintf(stderr, "No aranges found\n");
115.2718 -		return;
115.2719 -	}
115.2720 -
115.2721 -	data = elfReadSection(data, sh);
115.2722 -	u8 *end = data + READ32LE(&sh->size);
115.2723 -
115.2724 -	int      max    = 4;
115.2725 -	ARanges *ranges = (ARanges *)calloc(sizeof(ARanges), 4);
115.2726 -
115.2727 -	int index = 0;
115.2728 -
115.2729 -	while (data < end)
115.2730 -	{
115.2731 -		u32 len = elfRead4Bytes(data);
115.2732 -		data += 4;
115.2733 -		//    u16 version = elfRead2Bytes(data);
115.2734 -		data += 2;
115.2735 -		u32 offset = elfRead4Bytes(data);
115.2736 -		data += 4;
115.2737 -		//    u8 addrSize = *data++;
115.2738 -		//    u8 segSize = *data++;
115.2739 -		data += 2; // remove if uncommenting above
115.2740 -		data += 4;
115.2741 -		ranges[index].count  = (len-20)/8;
115.2742 -		ranges[index].offset = offset;
115.2743 -		ranges[index].ranges = (ARange *)calloc(sizeof(ARange), (len-20)/8);
115.2744 -		int i = 0;
115.2745 -		while (true)
115.2746 -		{
115.2747 -			u32 addr = elfRead4Bytes(data);
115.2748 -			data += 4;
115.2749 -			u32 len = elfRead4Bytes(data);
115.2750 -			data += 4;
115.2751 -			if (addr == 0 && len == 0)
115.2752 -				break;
115.2753 -			ranges[index].ranges[i].lowPC  = addr;
115.2754 -			ranges[index].ranges[i].highPC = addr+len;
115.2755 -			i++;
115.2756 -		}
115.2757 -		index++;
115.2758 -		if (index == max)
115.2759 -		{
115.2760 -			max   += 4;
115.2761 -			ranges = (ARanges *)realloc(ranges, max*sizeof(ARanges));
115.2762 -		}
115.2763 -	}
115.2764 -	elfDebugInfo->numRanges = index;
115.2765 -	elfDebugInfo->ranges    = ranges;
115.2766 -}
115.2767 -
115.2768 -void elfReadSymtab(u8 *data)
115.2769 -{
115.2770 -	ELFSectionHeader *sh = elfGetSectionByName(".symtab");
115.2771 -	int table = READ32LE(&sh->link);
115.2772 -
115.2773 -	char *strtable = (char *)elfReadSection(data, elfGetSectionByNumber(table));
115.2774 -
115.2775 -	ELFSymbol *symtab = (ELFSymbol *)elfReadSection(data, sh);
115.2776 -
115.2777 -	int count = READ32LE(&sh->size) / sizeof(ELFSymbol);
115.2778 -	elfSymbolsCount = 0;
115.2779 -
115.2780 -	elfSymbols = (Symbol *)malloc(sizeof(Symbol)*count);
115.2781 -
115.2782 -	int i;
115.2783 -
115.2784 -	for (i = 0; i < count; i++)
115.2785 -	{
115.2786 -		ELFSymbol *s       = &symtab[i];
115.2787 -		int        type    = s->info & 15;
115.2788 -		int        binding = s->info >> 4;
115.2789 -
115.2790 -		if (binding)
115.2791 -		{
115.2792 -			Symbol *sym = &elfSymbols[elfSymbolsCount];
115.2793 -			sym->name    = &strtable[READ32LE(&s->name)];
115.2794 -			sym->binding = binding;
115.2795 -			sym->type    = type;
115.2796 -			sym->value   = READ32LE(&s->value);
115.2797 -			sym->size    = READ32LE(&s->size);
115.2798 -			elfSymbolsCount++;
115.2799 -		}
115.2800 -	}
115.2801 -	for (i = 0; i < count; i++)
115.2802 -	{
115.2803 -		ELFSymbol *s    = &symtab[i];
115.2804 -		int        bind = s->info>>4;
115.2805 -		int        type = s->info & 15;
115.2806 -
115.2807 -		if (!bind)
115.2808 -		{
115.2809 -			Symbol *sym = &elfSymbols[elfSymbolsCount];
115.2810 -			sym->name    = &strtable[READ32LE(&s->name)];
115.2811 -			sym->binding = (s->info >> 4);
115.2812 -			sym->type    = type;
115.2813 -			sym->value   = READ32LE(&s->value);
115.2814 -			sym->size    = READ32LE(&s->size);
115.2815 -			elfSymbolsCount++;
115.2816 -		}
115.2817 -	}
115.2818 -	elfSymbolsStrTab = strtable;
115.2819 -	//  free(symtab);
115.2820 -}
115.2821 -
115.2822 -bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
115.2823 -{
115.2824 -	int count = READ16LE(&eh->e_phnum);
115.2825 -	int i;
115.2826 -
115.2827 -	if (READ32LE(&eh->e_entry) == 0x2000000)
115.2828 -		cpuIsMultiBoot = true;
115.2829 -
115.2830 -	// read program headers... should probably move this code down
115.2831 -	u8 *p = data + READ32LE(&eh->e_phoff);
115.2832 -	size = 0;
115.2833 -	for (i = 0; i < count; i++)
115.2834 -	{
115.2835 -		ELFProgramHeader *ph = (ELFProgramHeader *)p;
115.2836 -		p += sizeof(ELFProgramHeader);
115.2837 -		if (READ16LE(&eh->e_phentsize) != sizeof(ELFProgramHeader))
115.2838 -		{
115.2839 -			p += READ16LE(&eh->e_phentsize) - sizeof(ELFProgramHeader);
115.2840 -		}
115.2841 -
115.2842 -		//    printf("PH %d %08x %08x %08x %08x %08x %08x %08x %08x\n",
115.2843 -		//     i, ph->type, ph->offset, ph->vaddr, ph->paddr,
115.2844 -		//     ph->filesz, ph->memsz, ph->flags, ph->align);
115.2845 -		if (cpuIsMultiBoot)
115.2846 -		{
115.2847 -			if (READ32LE(&ph->paddr) >= 0x2000000 &&
115.2848 -			    READ32LE(&ph->paddr) <= 0x203ffff)
115.2849 -			{
115.2850 -				memcpy(&workRAM[READ32LE(&ph->paddr) & 0x3ffff],
115.2851 -				       data + READ32LE(&ph->offset),
115.2852 -				       READ32LE(&ph->filesz));
115.2853 -			}
115.2854 -		}
115.2855 -		else
115.2856 -		{
115.2857 -			if (READ32LE(&ph->paddr) >= 0x8000000 &&
115.2858 -			    READ32LE(&ph->paddr) <= 0x9ffffff)
115.2859 -			{
115.2860 -				memcpy(&rom[READ32LE(&ph->paddr) & 0x1ffffff],
115.2861 -				       data + READ32LE(&ph->offset),
115.2862 -				       READ32LE(&ph->filesz));
115.2863 -				size += READ32LE(&ph->filesz);
115.2864 -			}
115.2865 -		}
115.2866 -	}
115.2867 -
115.2868 -	char *stringTable = NULL;
115.2869 -
115.2870 -	// read section headers
115.2871 -	p     = data + READ32LE(&eh->e_shoff);
115.2872 -	count = READ16LE(&eh->e_shnum);
115.2873 -
115.2874 -	ELFSectionHeader **sh = (ELFSectionHeader * *)
115.2875 -	                        malloc(sizeof(ELFSectionHeader *) * count);
115.2876 -
115.2877 -	for (i = 0; i < count; i++)
115.2878 -	{
115.2879 -		sh[i] = (ELFSectionHeader *)p;
115.2880 -		p    += sizeof(ELFSectionHeader);
115.2881 -		if (READ16LE(&eh->e_shentsize) != sizeof(ELFSectionHeader))
115.2882 -			p += READ16LE(&eh->e_shentsize) - sizeof(ELFSectionHeader);
115.2883 -	}
115.2884 -
115.2885 -	if (READ16LE(&eh->e_shstrndx) != 0)
115.2886 -	{
115.2887 -		stringTable = (char *)elfReadSection(data,
115.2888 -		                                     sh[READ16LE(&eh->e_shstrndx)]);
115.2889 -	}
115.2890 -
115.2891 -	elfSectionHeaders = sh;
115.2892 -	elfSectionHeadersStringTable = stringTable;
115.2893 -	elfSectionHeadersCount       = count;
115.2894 -
115.2895 -	for (i = 0; i < count; i++)
115.2896 -	{
115.2897 -		//    printf("SH %d %-20s %08x %08x %08x %08x %08x %08x %08x %08x\n",
115.2898 -		//   i, &stringTable[sh[i]->name], sh[i]->name, sh[i]->type,
115.2899 -		//   sh[i]->flags, sh[i]->addr, sh[i]->offset, sh[i]->size,
115.2900 -		//   sh[i]->link, sh[i]->info);
115.2901 -		if (READ32LE(&sh[i]->flags) & 2) // load section
115.2902 -		{
115.2903 -			if (cpuIsMultiBoot)
115.2904 -			{
115.2905 -				if (READ32LE(&sh[i]->addr) >= 0x2000000 &&
115.2906 -				    READ32LE(&sh[i]->addr) <= 0x203ffff)
115.2907 -				{
115.2908 -					memcpy(&workRAM[READ32LE(&sh[i]->addr) & 0x3ffff], data +
115.2909 -					       READ32LE(&sh[i]->offset),
115.2910 -					       READ32LE(&sh[i]->size));
115.2911 -				}
115.2912 -			}
115.2913 -			else
115.2914 -			{
115.2915 -				if (READ32LE(&sh[i]->addr) >= 0x8000000 &&
115.2916 -				    READ32LE(&sh[i]->addr) <= 0x9ffffff)
115.2917 -				{
115.2918 -					memcpy(&rom[READ32LE(&sh[i]->addr) & 0x1ffffff],
115.2919 -					       data + READ32LE(&sh[i]->offset),
115.2920 -					       READ32LE(&sh[i]->size));
115.2921 -					size += READ32LE(&sh[i]->size);
115.2922 -				}
115.2923 -			}
115.2924 -		}
115.2925 -	}
115.2926 -
115.2927 -	if (parseDebug)
115.2928 -	{
115.2929 -		fprintf(stderr, "Parsing debug info\n");
115.2930 -
115.2931 -		ELFSectionHeader *dbgHeader = elfGetSectionByName(".debug_info");
115.2932 -		if (dbgHeader == NULL)
115.2933 -		{
115.2934 -			fprintf(stderr, "Cannot find debug information\n");
115.2935 -			goto end;
115.2936 -		}
115.2937 -
115.2938 -		ELFSectionHeader *h = elfGetSectionByName(".debug_abbrev");
115.2939 -		if (h == NULL)
115.2940 -		{
115.2941 -			fprintf(stderr, "Cannot find abbreviation table\n");
115.2942 -			goto end;
115.2943 -		}
115.2944 -
115.2945 -		elfDebugInfo = (DebugInfo *)calloc(sizeof(DebugInfo), 1);
115.2946 -		u8 *abbrevdata = elfReadSection(data, h);
115.2947 -
115.2948 -		h = elfGetSectionByName(".debug_str");
115.2949 -
115.2950 -		if (h == NULL)
115.2951 -			elfDebugStrings = NULL;
115.2952 -		else
115.2953 -			elfDebugStrings = (char *)elfReadSection(data, h);
115.2954 -
115.2955 -		u8 *debugdata = elfReadSection(data, dbgHeader);
115.2956 -
115.2957 -		elfDebugInfo->debugdata = data;
115.2958 -		elfDebugInfo->infodata  = debugdata;
115.2959 -
115.2960 -		u32 total = READ32LE(&dbgHeader->size);
115.2961 -		u8 *end   = debugdata + total;
115.2962 -		u8 *ddata = debugdata;
115.2963 -
115.2964 -		CompileUnit *last = NULL;
115.2965 -		CompileUnit *unit = NULL;
115.2966 -
115.2967 -		while (ddata < end)
115.2968 -		{
115.2969 -			unit         = elfParseCompUnit(ddata, abbrevdata);
115.2970 -			unit->offset = ddata-debugdata;
115.2971 -			elfParseLineInfo(unit, data);
115.2972 -			if (last == NULL)
115.2973 -				elfCompileUnits = unit;
115.2974 -			else
115.2975 -				last->next = unit;
115.2976 -			last   = unit;
115.2977 -			ddata += 4 + unit->length;
115.2978 -		}
115.2979 -		elfParseAranges(data);
115.2980 -		CompileUnit *comp = elfCompileUnits;
115.2981 -		while (comp)
115.2982 -		{
115.2983 -			ARanges *r = elfDebugInfo->ranges;
115.2984 -			for (int i = 0; i < elfDebugInfo->numRanges; i++)
115.2985 -				if (r[i].offset == comp->offset)
115.2986 -				{
115.2987 -					comp->ranges = &r[i];
115.2988 -					break;
115.2989 -				}
115.2990 -			comp = comp->next;
115.2991 -		}
115.2992 -		elfParseCFA(data);
115.2993 -		elfReadSymtab(data);
115.2994 -	}
115.2995 -end:
115.2996 -	if (sh)
115.2997 -	{
115.2998 -		free(sh);
115.2999 -	}
115.3000 -
115.3001 -	elfSectionHeaders = NULL;
115.3002 -	elfSectionHeadersStringTable = NULL;
115.3003 -	elfSectionHeadersCount       = 0;
115.3004 -
115.3005 -	return true;
115.3006 -}
115.3007 -
115.3008 -extern bool8 parseDebug;
115.3009 -
115.3010 -bool elfRead(const char *name, int& siz, FILE *f)
115.3011 -{
115.3012 -	fseek(f, 0, SEEK_END);
115.3013 -	long size = ftell(f);
115.3014 -	elfFileData = (u8 *)malloc(size);
115.3015 -	fseek(f, 0, SEEK_SET);
115.3016 -	fread(elfFileData, 1, size, f);
115.3017 -	fclose(f);
115.3018 -
115.3019 -	ELFHeader *header = (ELFHeader *)elfFileData;
115.3020 -
115.3021 -	if (READ32LE(&header->magic) != 0x464C457F ||
115.3022 -	    READ16LE(&header->e_machine) != 40 ||
115.3023 -	    header->clazz != 1)
115.3024 -	{
115.3025 -		systemMessage(0, N_("Not a valid ELF file %s"), name);
115.3026 -		free(elfFileData);
115.3027 -		elfFileData = NULL;
115.3028 -		return false;
115.3029 -	}
115.3030 -
115.3031 -	if (!elfReadProgram(header, elfFileData, siz, parseDebug))
115.3032 -	{
115.3033 -		free(elfFileData);
115.3034 -		elfFileData = NULL;
115.3035 -		return false;
115.3036 -	}
115.3037 -
115.3038 -	return true;
115.3039 -}
115.3040 -
115.3041 -void elfCleanUp(Object *o)
115.3042 -{
115.3043 -	free(o->location);
115.3044 -}
115.3045 -
115.3046 -void elfCleanUp(Function *func)
115.3047 -{
115.3048 -	Object *o = func->parameters;
115.3049 -	while (o)
115.3050 -	{
115.3051 -		elfCleanUp(o);
115.3052 -		Object *next = o->next;
115.3053 -		free(o);
115.3054 -		o = next;
115.3055 -	}
115.3056 -
115.3057 -	o = func->variables;
115.3058 -	while (o)
115.3059 -	{
115.3060 -		elfCleanUp(o);
115.3061 -		Object *next = o->next;
115.3062 -		free(o);
115.3063 -		o = next;
115.3064 -	}
115.3065 -	free(func->frameBase);
115.3066 -}
115.3067 -
115.3068 -void elfCleanUp(ELFAbbrev **abbrevs)
115.3069 -{
115.3070 -	for (int i = 0; i < 121; i++)
115.3071 -	{
115.3072 -		ELFAbbrev *abbrev = abbrevs[i];
115.3073 -
115.3074 -		while (abbrev)
115.3075 -		{
115.3076 -			free(abbrev->attrs);
115.3077 -			ELFAbbrev *next = abbrev->next;
115.3078 -			free(abbrev);
115.3079 -
115.3080 -			abbrev = next;
115.3081 -		}
115.3082 -	}
115.3083 -}
115.3084 -
115.3085 -void elfCleanUp(Type *t)
115.3086 -{
115.3087 -	switch (t->type)
115.3088 -	{
115.3089 -	case TYPE_function:
115.3090 -		if (t->function)
115.3091 -		{
115.3092 -			Object *o = t->function->args;
115.3093 -			while (o)
115.3094 -			{
115.3095 -				elfCleanUp(o);
115.3096 -				Object *next = o->next;
115.3097 -				free(o);
115.3098 -				o = next;
115.3099 -			}
115.3100 -			free(t->function);
115.3101 -		}
115.3102 -		break;
115.3103 -	case TYPE_array:
115.3104 -		if (t->array)
115.3105 -		{
115.3106 -			free(t->array->bounds);
115.3107 -			free(t->array);
115.3108 -		}
115.3109 -		break;
115.3110 -	case TYPE_struct:
115.3111 -	case TYPE_union:
115.3112 -		if (t->structure)
115.3113 -		{
115.3114 -			for (int i = 0; i < t->structure->memberCount; i++)
115.3115 -			{
115.3116 -				free(t->structure->members[i].location);
115.3117 -			}
115.3118 -			free(t->structure->members);
115.3119 -			free(t->structure);
115.3120 -		}
115.3121 -		break;
115.3122 -	case TYPE_enum:
115.3123 -		if (t->enumeration)
115.3124 -		{
115.3125 -			free(t->enumeration->members);
115.3126 -			free(t->enumeration);
115.3127 -		}
115.3128 -		break;
115.3129 -	case TYPE_base:
115.3130 -	case TYPE_pointer:
115.3131 -	case TYPE_void:
115.3132 -	case TYPE_reference:
115.3133 -		break; // nothing to do
115.3134 -	}
115.3135 -}
115.3136 -
115.3137 -void elfCleanUp(CompileUnit *comp)
115.3138 -{
115.3139 -	elfCleanUp(comp->abbrevs);
115.3140 -	free(comp->abbrevs);
115.3141 -	Function *func = comp->functions;
115.3142 -	while (func)
115.3143 -	{
115.3144 -		elfCleanUp(func);
115.3145 -		Function *next = func->next;
115.3146 -		free(func);
115.3147 -		func = next;
115.3148 -	}
115.3149 -	Type *t = comp->types;
115.3150 -	while (t)
115.3151 -	{
115.3152 -		elfCleanUp(t);
115.3153 -		Type *next = t->next;
115.3154 -		free(t);
115.3155 -		t = next;
115.3156 -	}
115.3157 -	Object *o = comp->variables;
115.3158 -	while (o)
115.3159 -	{
115.3160 -		elfCleanUp(o);
115.3161 -		Object *next = o->next;
115.3162 -		free(o);
115.3163 -		o = next;
115.3164 -	}
115.3165 -	if (comp->lineInfoTable)
115.3166 -	{
115.3167 -		free(comp->lineInfoTable->lines);
115.3168 -		free(comp->lineInfoTable->files);
115.3169 -		free(comp->lineInfoTable);
115.3170 -	}
115.3171 -}
115.3172 -
115.3173 -void elfCleanUp()
115.3174 -{
115.3175 -	CompileUnit *comp = elfCompileUnits;
115.3176 -
115.3177 -	while (comp)
115.3178 -	{
115.3179 -		elfCleanUp(comp);
115.3180 -		CompileUnit *next = comp->next;
115.3181 -		free(comp);
115.3182 -		comp = next;
115.3183 -	}
115.3184 -	elfCompileUnits = NULL;
115.3185 -	free(elfSymbols);
115.3186 -	elfSymbols = NULL;
115.3187 -	//  free(elfSymbolsStrTab);
115.3188 -	elfSymbolsStrTab = NULL;
115.3189 -
115.3190 -	elfDebugStrings = NULL;
115.3191 -	if (elfDebugInfo)
115.3192 -	{
115.3193 -		int num = elfDebugInfo->numRanges;
115.3194 -		int i;
115.3195 -		for (i = 0; i < num; i++)
115.3196 -		{
115.3197 -			free(elfDebugInfo->ranges[i].ranges);
115.3198 -		}
115.3199 -		free(elfDebugInfo->ranges);
115.3200 -		free(elfDebugInfo);
115.3201 -		elfDebugInfo = NULL;
115.3202 -	}
115.3203 -
115.3204 -	if (elfFdes)
115.3205 -	{
115.3206 -		if (elfFdeCount)
115.3207 -		{
115.3208 -			for (int i = 0; i < elfFdeCount; i++)
115.3209 -				free(elfFdes[i]);
115.3210 -		}
115.3211 -		free(elfFdes);
115.3212 -
115.3213 -		elfFdes     = NULL;
115.3214 -		elfFdeCount = 0;
115.3215 -	}
115.3216 -
115.3217 -	ELFcie *cie = elfCies;
115.3218 -	while (cie)
115.3219 -	{
115.3220 -		ELFcie *next = cie->next;
115.3221 -		free(cie);
115.3222 -		cie = next;
115.3223 -	}
115.3224 -	elfCies = NULL;
115.3225 -
115.3226 -	if (elfFileData)
115.3227 -	{
115.3228 -		free(elfFileData);
115.3229 -		elfFileData = NULL;
115.3230 -	}
115.3231 -}
115.3232 -
   116.1 --- a/src/gba/elf.h	Sat Mar 03 10:54:39 2012 -0600
   116.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.3 @@ -1,296 +0,0 @@
   116.4 -#ifndef VBA_ELF_H
   116.5 -#define VBA_ELF_H
   116.6 -
   116.7 -#if _MSC_VER > 1000
   116.8 -#pragma once
   116.9 -#endif // _MSC_VER > 1000
  116.10 -
  116.11 -enum LocationType
  116.12 -{
  116.13 -	LOCATION_register,
  116.14 -	LOCATION_memory,
  116.15 -	LOCATION_value
  116.16 -};
  116.17 -
  116.18 -#define DW_ATE_boolean       0x02
  116.19 -#define DW_ATE_signed        0x05
  116.20 -#define DW_ATE_unsigned      0x07
  116.21 -#define DW_ATE_unsigned_char 0x08
  116.22 -
  116.23 -struct ELFHeader
  116.24 -{
  116.25 -	u32 magic;
  116.26 -	u8  clazz;
  116.27 -	u8  data;
  116.28 -	u8  version;
  116.29 -	u8  pad[9];
  116.30 -	u16 e_type;
  116.31 -	u16 e_machine;
  116.32 -	u32 e_version;
  116.33 -	u32 e_entry;
  116.34 -	u32 e_phoff;
  116.35 -	u32 e_shoff;
  116.36 -	u32 e_flags;
  116.37 -	u16 e_ehsize;
  116.38 -	u16 e_phentsize;
  116.39 -	u16 e_phnum;
  116.40 -	u16 e_shentsize;
  116.41 -	u16 e_shnum;
  116.42 -	u16 e_shstrndx;
  116.43 -};
  116.44 -
  116.45 -struct ELFProgramHeader
  116.46 -{
  116.47 -	u32 type;
  116.48 -	u32 offset;
  116.49 -	u32 vaddr;
  116.50 -	u32 paddr;
  116.51 -	u32 filesz;
  116.52 -	u32 memsz;
  116.53 -	u32 flags;
  116.54 -	u32 align;
  116.55 -};
  116.56 -
  116.57 -struct ELFSectionHeader
  116.58 -{
  116.59 -	u32 name;
  116.60 -	u32 type;
  116.61 -	u32 flags;
  116.62 -	u32 addr;
  116.63 -	u32 offset;
  116.64 -	u32 size;
  116.65 -	u32 link;
  116.66 -	u32 info;
  116.67 -	u32 addralign;
  116.68 -	u32 entsize;
  116.69 -};
  116.70 -
  116.71 -struct ELFSymbol
  116.72 -{
  116.73 -	u32 name;
  116.74 -	u32 value;
  116.75 -	u32 size;
  116.76 -	u8  info;
  116.77 -	u8  other;
  116.78 -	u16 shndx;
  116.79 -};
  116.80 -
  116.81 -struct ELFBlock
  116.82 -{
  116.83 -	int length;
  116.84 -	u8 *data;
  116.85 -};
  116.86 -
  116.87 -struct ELFAttr
  116.88 -{
  116.89 -	u32 name;
  116.90 -	u32 form;
  116.91 -	union
  116.92 -	{
  116.93 -		u32       value;
  116.94 -		char *    string;
  116.95 -		u8 *      data;
  116.96 -		bool      flag;
  116.97 -		ELFBlock *block;
  116.98 -	};
  116.99 -};
 116.100 -
 116.101 -struct ELFAbbrev
 116.102 -{
 116.103 -	u32        number;
 116.104 -	u32        tag;
 116.105 -	bool       hasChildren;
 116.106 -	int        numAttrs;
 116.107 -	ELFAttr *  attrs;
 116.108 -	ELFAbbrev *next;
 116.109 -};
 116.110 -
 116.111 -enum TypeEnum
 116.112 -{
 116.113 -	TYPE_base,
 116.114 -	TYPE_pointer,
 116.115 -	TYPE_function,
 116.116 -	TYPE_void,
 116.117 -	TYPE_array,
 116.118 -	TYPE_struct,
 116.119 -	TYPE_reference,
 116.120 -	TYPE_enum,
 116.121 -	TYPE_union
 116.122 -};
 116.123 -
 116.124 -struct Type;
 116.125 -struct Object;
 116.126 -
 116.127 -struct FunctionType
 116.128 -{
 116.129 -	Type *  returnType;
 116.130 -	Object *args;
 116.131 -};
 116.132 -
 116.133 -struct Member
 116.134 -{
 116.135 -	char *    name;
 116.136 -	Type *    type;
 116.137 -	int       bitSize;
 116.138 -	int       bitOffset;
 116.139 -	int       byteSize;
 116.140 -	ELFBlock *location;
 116.141 -};
 116.142 -
 116.143 -struct Struct
 116.144 -{
 116.145 -	int     memberCount;
 116.146 -	Member *members;
 116.147 -};
 116.148 -
 116.149 -struct Array
 116.150 -{
 116.151 -	Type *type;
 116.152 -	int   maxBounds;
 116.153 -	int * bounds;
 116.154 -};
 116.155 -
 116.156 -struct EnumMember
 116.157 -{
 116.158 -	char *name;
 116.159 -	u32   value;
 116.160 -};
 116.161 -
 116.162 -struct Enum
 116.163 -{
 116.164 -	int         count;
 116.165 -	EnumMember *members;
 116.166 -};
 116.167 -
 116.168 -struct Type
 116.169 -{
 116.170 -	u32      offset;
 116.171 -	TypeEnum type;
 116.172 -	char *   name;
 116.173 -	int      encoding;
 116.174 -	int      size;
 116.175 -	int      bitSize;
 116.176 -	union
 116.177 -	{
 116.178 -		Type *        pointer;
 116.179 -		FunctionType *function;
 116.180 -		Array *       array;
 116.181 -		Struct *      structure;
 116.182 -		Enum *        enumeration;
 116.183 -	};
 116.184 -	Type *next;
 116.185 -};
 116.186 -
 116.187 -struct Object
 116.188 -{
 116.189 -	char *    name;
 116.190 -	int       file;
 116.191 -	int       line;
 116.192 -	bool      external;
 116.193 -	Type *    type;
 116.194 -	ELFBlock *location;
 116.195 -	u32       startScope;
 116.196 -	u32       endScope;
 116.197 -	Object *  next;
 116.198 -};
 116.199 -
 116.200 -struct Function
 116.201 -{
 116.202 -	char *    name;
 116.203 -	u32       lowPC;
 116.204 -	u32       highPC;
 116.205 -	int       file;
 116.206 -	int       line;
 116.207 -	bool      external;
 116.208 -	Type *    returnType;
 116.209 -	Object *  parameters;
 116.210 -	Object *  variables;
 116.211 -	ELFBlock *frameBase;
 116.212 -	Function *next;
 116.213 -};
 116.214 -
 116.215 -struct LineInfoItem
 116.216 -{
 116.217 -	u32   address;
 116.218 -	char *file;
 116.219 -	int   line;
 116.220 -};
 116.221 -
 116.222 -struct LineInfo
 116.223 -{
 116.224 -	int           fileCount;
 116.225 -	char **       files;
 116.226 -	int           number;
 116.227 -	LineInfoItem *lines;
 116.228 -};
 116.229 -
 116.230 -struct ARange
 116.231 -{
 116.232 -	u32 lowPC;
 116.233 -	u32 highPC;
 116.234 -};
 116.235 -
 116.236 -struct ARanges
 116.237 -{
 116.238 -	u32     offset;
 116.239 -	int     count;
 116.240 -	ARange *ranges;
 116.241 -};
 116.242 -
 116.243 -struct CompileUnit
 116.244 -{
 116.245 -	u32          length;
 116.246 -	u8 *         top;
 116.247 -	u32          offset;
 116.248 -	ELFAbbrev ** abbrevs;
 116.249 -	ARanges *    ranges;
 116.250 -	char *       name;
 116.251 -	char *       compdir;
 116.252 -	u32          lowPC;
 116.253 -	u32          highPC;
 116.254 -	bool         hasLineInfo;
 116.255 -	u32          lineInfo;
 116.256 -	LineInfo *   lineInfoTable;
 116.257 -	Function *   functions;
 116.258 -	Function *   lastFunction;
 116.259 -	Object *     variables;
 116.260 -	Type *       types;
 116.261 -	CompileUnit *next;
 116.262 -};
 116.263 -
 116.264 -struct DebugInfo
 116.265 -{
 116.266 -	u8 *     debugfile;
 116.267 -	u8 *     abbrevdata;
 116.268 -	u8 *     debugdata;
 116.269 -	u8 *     infodata;
 116.270 -	int      numRanges;
 116.271 -	ARanges *ranges;
 116.272 -};
 116.273 -
 116.274 -struct Symbol
 116.275 -{
 116.276 -	char *name;
 116.277 -	int   type;
 116.278 -	int   binding;
 116.279 -	u32   address;
 116.280 -	u32   value;
 116.281 -	u32   size;
 116.282 -};
 116.283 -
 116.284 -extern u32 elfReadLEB128(u8 *, int *);
 116.285 -extern s32 elfReadSignedLEB128(u8 *, int *);
 116.286 -extern bool elfRead(const char *, int &, FILE *f);
 116.287 -extern bool elfGetSymbolAddress(char *, u32 *, u32 *, int *);
 116.288 -extern char *elfGetAddressSymbol(u32);
 116.289 -extern char *elfGetSymbol(int, u32 *, u32 *, int *);
 116.290 -extern void elfCleanUp();
 116.291 -extern bool elfGetCurrentFunction(u32, Function **, CompileUnit **c);
 116.292 -extern bool elfGetObject(char *, Function *, CompileUnit *, Object * *);
 116.293 -extern bool elfFindLineInUnit(u32 *, CompileUnit *, int);
 116.294 -extern bool elfFindLineInModule(u32 *, char *, int);
 116.295 -u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *);
 116.296 -u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *, u32);
 116.297 -int elfFindLine(CompileUnit *unit, Function *func, u32 addr, char * *);
 116.298 -
 116.299 -#endif // VBA_ELF_H
   117.1 --- a/src/gba/remote.cpp	Sat Mar 03 10:54:39 2012 -0600
   117.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.3 @@ -1,712 +0,0 @@
   117.4 -#include <cstdlib>
   117.5 -#include <cstdio>
   117.6 -#include <cstring>
   117.7 -
   117.8 -#ifndef WIN32
   117.9 -# include <unistd.h>
  117.10 -# include <sys/socket.h>
  117.11 -# include <netdb.h>
  117.12 -# ifdef HAVE_NETINET_IN_H
  117.13 -#  include <netinet/in.h>
  117.14 -# endif // HAVE_NETINET_IN_H
  117.15 -# ifdef HAVE_ARPA_INET_H
  117.16 -#  include <arpa/inet.h>
  117.17 -# else // ! HAVE_ARPA_INET_H
  117.18 -#  define socklen_t int
  117.19 -# endif // ! HAVE_ARPA_INET_H
  117.20 -#else // WIN32
  117.21 -# include "../win32/stdafx.h"
  117.22 -# include <winsock.h>
  117.23 -# include <io.h>
  117.24 -# define socklen_t int
  117.25 -# define close closesocket
  117.26 -# define read _read
  117.27 -# define write _write
  117.28 -#endif // WIN32
  117.29 -
  117.30 -#include "GBA.h"
  117.31 -#include "GBAGlobals.h"
  117.32 -
  117.33 -extern bool debugger;
  117.34 -extern void CPUUpdateCPSR();
  117.35 -#ifdef SDL
  117.36 -extern void (*dbgMain)();
  117.37 -extern void (*dbgSignal)(int, int);
  117.38 -extern void debuggerMain();
  117.39 -extern void debuggerSignal(int, int);
  117.40 -#endif
  117.41 -
  117.42 -int  remotePort         = 55555;
  117.43 -int  remoteSignal       = 5;
  117.44 -int  remoteSocket       = -1;
  117.45 -int  remoteListenSocket = -1;
  117.46 -bool remoteConnected    = false;
  117.47 -bool remoteResumed      = false;
  117.48 -
  117.49 -int  (*remoteSendFnc)(char *, int) = NULL;
  117.50 -int  (*remoteRecvFnc)(char *, int) = NULL;
  117.51 -bool (*remoteInitFnc)()    = NULL;
  117.52 -void (*remoteCleanUpFnc)() = NULL;
  117.53 -
  117.54 -#if (defined WIN32 && !defined SDL)
  117.55 -void remoteSetSockets(SOCKET l, SOCKET r)
  117.56 -{
  117.57 -	remoteSocket       = r;
  117.58 -	remoteListenSocket = l;
  117.59 -}
  117.60 -
  117.61 -#endif
  117.62 -
  117.63 -int remoteTcpSend(char *data, int len)
  117.64 -{
  117.65 -	return send(remoteSocket, data, len, 0);
  117.66 -}
  117.67 -
  117.68 -int remoteTcpRecv(char *data, int len)
  117.69 -{
  117.70 -	return recv(remoteSocket, data, len, 0);
  117.71 -}
  117.72 -
  117.73 -bool remoteTcpInit()
  117.74 -{
  117.75 -	if (remoteSocket == -1)
  117.76 -	{
  117.77 -#ifdef WIN32
  117.78 -		WSADATA wsaData;
  117.79 -		int     error = WSAStartup(MAKEWORD(1, 1), &wsaData);
  117.80 -#endif // WIN32
  117.81 -		int s = socket(PF_INET, SOCK_STREAM, 0);
  117.82 -
  117.83 -		remoteListenSocket = s;
  117.84 -
  117.85 -		if (s < 0)
  117.86 -		{
  117.87 -			fprintf(stderr, "Error opening socket\n");
  117.88 -			exit(-1);
  117.89 -		}
  117.90 -		int tmp = 1;
  117.91 -		setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof(tmp));
  117.92 -
  117.93 -		//    char hostname[256];
  117.94 -		//    gethostname(hostname, 256);
  117.95 -
  117.96 -		//    hostent *ent = gethostbyname(hostname);
  117.97 -		//    unsigned long a = *((unsigned long *)ent->h_addr);
  117.98 -
  117.99 -		sockaddr_in addr;
 117.100 -		addr.sin_family      = AF_INET;
 117.101 -		addr.sin_port        = htons(remotePort);
 117.102 -		addr.sin_addr.s_addr = htonl(0);
 117.103 -		int count = 0;
 117.104 -		while (count < 3)
 117.105 -		{
 117.106 -			if (bind(s, (sockaddr *)&addr, sizeof(addr)))
 117.107 -			{
 117.108 -				addr.sin_port = htons(ntohs(addr.sin_port)+1);
 117.109 -			}
 117.110 -			else
 117.111 -				break;
 117.112 -		}
 117.113 -		if (count == 3)
 117.114 -		{
 117.115 -			fprintf(stderr, "Error binding \n");
 117.116 -			exit(-1);
 117.117 -		}
 117.118 -
 117.119 -		fprintf(stderr, "Listening for a connection at port %d\n",
 117.120 -		        ntohs(addr.sin_port));
 117.121 -
 117.122 -		if (listen(s, 1))
 117.123 -		{
 117.124 -			fprintf(stderr, "Error listening\n");
 117.125 -			exit(-1);
 117.126 -		}
 117.127 -		socklen_t len = sizeof(addr);
 117.128 -
 117.129 -#ifdef WIN32
 117.130 -		int flag = 0;
 117.131 -		ioctlsocket(s, FIONBIO, (unsigned long *)&flag);
 117.132 -#endif // WIN32
 117.133 -		int s2 = accept(s, (sockaddr *)&addr, &len);
 117.134 -		if (s2 > 0)
 117.135 -		{
 117.136 -			fprintf(stderr, "Got a connection from %s %d\n",
 117.137 -			        inet_ntoa((in_addr)addr.sin_addr),
 117.138 -			        ntohs(addr.sin_port));
 117.139 -		}
 117.140 -		else
 117.141 -		{
 117.142 -#ifdef WIN32
 117.143 -			int error = WSAGetLastError();
 117.144 -#endif // WIN32
 117.145 -		}
 117.146 -		char dummy;
 117.147 -		recv(s2, &dummy, 1, 0);
 117.148 -		if (dummy != '+')
 117.149 -		{
 117.150 -			fprintf(stderr, "ACK not received\n");
 117.151 -			exit(-1);
 117.152 -		}
 117.153 -		remoteSocket = s2;
 117.154 -		//    close(s);
 117.155 -	}
 117.156 -	return true;
 117.157 -}
 117.158 -
 117.159 -void remoteTcpCleanUp()
 117.160 -{
 117.161 -	if (remoteSocket > 0)
 117.162 -	{
 117.163 -		fprintf(stderr, "Closing remote socket\n");
 117.164 -		close(remoteSocket);
 117.165 -		remoteSocket = -1;
 117.166 -	}
 117.167 -	if (remoteListenSocket > 0)
 117.168 -	{
 117.169 -		fprintf(stderr, "Closing listen socket\n");
 117.170 -		close(remoteListenSocket);
 117.171 -		remoteListenSocket = -1;
 117.172 -	}
 117.173 -}
 117.174 -
 117.175 -int remotePipeSend(char *data, int len)
 117.176 -{
 117.177 -	int res = write(1, data, len);
 117.178 -	return res;
 117.179 -}
 117.180 -
 117.181 -int remotePipeRecv(char *data, int len)
 117.182 -{
 117.183 -	int res = read(0, data, len);
 117.184 -	return res;
 117.185 -}
 117.186 -
 117.187 -bool remotePipeInit()
 117.188 -{
 117.189 -	char dummy;
 117.190 -	read(0, &dummy, 1);
 117.191 -	if (dummy != '+')
 117.192 -	{
 117.193 -		fprintf(stderr, "ACK not received\n");
 117.194 -		exit(-1);
 117.195 -	}
 117.196 -
 117.197 -	return true;
 117.198 -}
 117.199 -
 117.200 -void remotePipeCleanUp()
 117.201 -{}
 117.202 -
 117.203 -void remoteSetPort(int port)
 117.204 -{
 117.205 -	remotePort = port;
 117.206 -}
 117.207 -
 117.208 -void remoteSetProtocol(int p)
 117.209 -{
 117.210 -	if (p == 0)
 117.211 -	{
 117.212 -		remoteSendFnc    = remoteTcpSend;
 117.213 -		remoteRecvFnc    = remoteTcpRecv;
 117.214 -		remoteInitFnc    = remoteTcpInit;
 117.215 -		remoteCleanUpFnc = remoteTcpCleanUp;
 117.216 -	}
 117.217 -	else
 117.218 -	{
 117.219 -		remoteSendFnc    = remotePipeSend;
 117.220 -		remoteRecvFnc    = remotePipeRecv;
 117.221 -		remoteInitFnc    = remotePipeInit;
 117.222 -		remoteCleanUpFnc = remotePipeCleanUp;
 117.223 -	}
 117.224 -}
 117.225 -
 117.226 -void remoteInit()
 117.227 -{
 117.228 -	if (remoteInitFnc)
 117.229 -		remoteInitFnc();
 117.230 -}
 117.231 -
 117.232 -void remotePutPacket(char *packet)
 117.233 -{
 117.234 -	char *hex = "0123456789abcdef";
 117.235 -	char  buffer[1024];
 117.236 -
 117.237 -	int count = strlen(packet);
 117.238 -
 117.239 -	unsigned char csum = 0;
 117.240 -
 117.241 -	char *p = buffer;
 117.242 -	*p++ = '$';
 117.243 -
 117.244 -	for (int i = 0; i < count; i++)
 117.245 -	{
 117.246 -		csum += packet[i];
 117.247 -		*p++  = packet[i];
 117.248 -	}
 117.249 -	*p++ = '#';
 117.250 -	*p++ = hex[csum>>4];
 117.251 -	*p++ = hex[csum & 15];
 117.252 -	*p++ = 0;
 117.253 -	//  printf("Sending %s\n", buffer);
 117.254 -	remoteSendFnc(buffer, count + 4);
 117.255 -
 117.256 -	char c = 0;
 117.257 -	remoteRecvFnc(&c, 1);
 117.258 -	/*
 117.259 -	   if(c == '+')
 117.260 -	   printf("ACK\n");
 117.261 -	   else if(c=='-')
 117.262 -	   printf("NACK\n");
 117.263 -	 */
 117.264 -}
 117.265 -
 117.266 -void remoteOutput(char *s, u32 addr)
 117.267 -{
 117.268 -	char buffer[16384];
 117.269 -
 117.270 -	char *d = buffer;
 117.271 -	*d++ = 'O';
 117.272 -
 117.273 -	if (s)
 117.274 -	{
 117.275 -		char c = *s++;
 117.276 -		while (c)
 117.277 -		{
 117.278 -			sprintf(d, "%02x", c);
 117.279 -			d += 2;
 117.280 -			c  = *s++;
 117.281 -		}
 117.282 -	}
 117.283 -	else
 117.284 -	{
 117.285 -		char c = debuggerReadByte(addr);
 117.286 -		addr++;
 117.287 -		while (c)
 117.288 -		{
 117.289 -			sprintf(d, "%02x", c);
 117.290 -			d += 2;
 117.291 -			c  = debuggerReadByte(addr);
 117.292 -			addr++;
 117.293 -		}
 117.294 -	}
 117.295 -	remotePutPacket(buffer);
 117.296 -	//  fprintf(stderr, "Output sent %s\n", buffer);
 117.297 -}
 117.298 -
 117.299 -void remoteSendSignal()
 117.300 -{
 117.301 -	char buffer[1024];
 117.302 -	sprintf(buffer, "S%02x", remoteSignal);
 117.303 -	remotePutPacket(buffer);
 117.304 -}
 117.305 -
 117.306 -void remoteSendStatus()
 117.307 -{
 117.308 -	char buffer[1024];
 117.309 -	sprintf(buffer, "T%02x", remoteSignal);
 117.310 -	char *s = buffer;
 117.311 -	s += 3;
 117.312 -	for (int i = 0; i < 15; i++)
 117.313 -	{
 117.314 -		u32 v = reg[i].I;
 117.315 -		sprintf(s, "%02x:%02x%02x%02x%02x;", i,
 117.316 -		        (v & 255),
 117.317 -		        (v >> 8) & 255,
 117.318 -		        (v >> 16) & 255,
 117.319 -		        (v >> 24) & 255);
 117.320 -		s += 12;
 117.321 -	}
 117.322 -	u32 v = armNextPC;
 117.323 -	sprintf(s, "0f:%02x%02x%02x%02x;", (v & 255),
 117.324 -	        (v >> 8) & 255,
 117.325 -	        (v >> 16) & 255,
 117.326 -	        (v >> 24) & 255);
 117.327 -	s += 12;
 117.328 -	CPUUpdateCPSR();
 117.329 -	v = reg[16].I;
 117.330 -	sprintf(s, "19:%02x%02x%02x%02x;", (v & 255),
 117.331 -	        (v >> 8) & 255,
 117.332 -	        (v >> 16) & 255,
 117.333 -	        (v >> 24) & 255);
 117.334 -	s += 12;
 117.335 -	*s = 0;
 117.336 -	//  printf("Sending %s\n", buffer);
 117.337 -	remotePutPacket(buffer);
 117.338 -}
 117.339 -
 117.340 -void remoteBinaryWrite(char *p)
 117.341 -{
 117.342 -	u32 address;
 117.343 -	int count;
 117.344 -	sscanf(p, "%x,%x:", &address, &count);
 117.345 -	//  printf("Binary write for %08x %d\n", address, count);
 117.346 -
 117.347 -	p = strchr(p, ':');
 117.348 -	p++;
 117.349 -	for (int i = 0; i < count; i++)
 117.350 -	{
 117.351 -		u8 b = *p++;
 117.352 -		switch (b)
 117.353 -		{
 117.354 -		case 0x7d:
 117.355 -			b = *p++;
 117.356 -			debuggerWriteByte(address, (b^0x20));
 117.357 -			address++;
 117.358 -			break;
 117.359 -		default:
 117.360 -			debuggerWriteByte(address, b);
 117.361 -			address++;
 117.362 -			break;
 117.363 -		}
 117.364 -	}
 117.365 -	//  printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
 117.366 -	remotePutPacket("OK");
 117.367 -}
 117.368 -
 117.369 -void remoteMemoryWrite(char *p)
 117.370 -{
 117.371 -	u32 address;
 117.372 -	int count;
 117.373 -	sscanf(p, "%x,%x:", &address, &count);
 117.374 -	//  printf("Memory write for %08x %d\n", address, count);
 117.375 -
 117.376 -	p = strchr(p, ':');
 117.377 -	p++;
 117.378 -	for (int i = 0; i < count; i++)
 117.379 -	{
 117.380 -		u8   v = 0;
 117.381 -		char c = *p++;
 117.382 -		if (c <= '9')
 117.383 -			v = (c - '0') << 4;
 117.384 -		else
 117.385 -			v = (c + 10 - 'a') << 4;
 117.386 -		c = *p++;
 117.387 -		if (c <= '9')
 117.388 -			v += (c - '0');
 117.389 -		else
 117.390 -			v += (c + 10 - 'a');
 117.391 -		debuggerWriteByte(address, v);
 117.392 -		address++;
 117.393 -	}
 117.394 -	//  printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
 117.395 -	remotePutPacket("OK");
 117.396 -}
 117.397 -
 117.398 -void remoteMemoryRead(char *p)
 117.399 -{
 117.400 -	u32 address;
 117.401 -	int count;
 117.402 -	sscanf(p, "%x,%x:", &address, &count);
 117.403 -	//  printf("Memory read for %08x %d\n", address, count);
 117.404 -
 117.405 -	char buffer[1024];
 117.406 -
 117.407 -	char *s = buffer;
 117.408 -	for (int i = 0; i < count; i++)
 117.409 -	{
 117.410 -		u8 b = debuggerReadByte(address);
 117.411 -		sprintf(s, "%02x", b);
 117.412 -		address++;
 117.413 -		s += 2;
 117.414 -	}
 117.415 -	*s = 0;
 117.416 -	remotePutPacket(buffer);
 117.417 -}
 117.418 -
 117.419 -void remoteStepOverRange(char *p)
 117.420 -{
 117.421 -	u32 address;
 117.422 -	u32 final;
 117.423 -	sscanf(p, "%x,%x", &address, &final);
 117.424 -
 117.425 -	remotePutPacket("OK");
 117.426 -
 117.427 -	remoteResumed = true;
 117.428 -	do
 117.429 -	{
 117.430 -		CPULoop(1);
 117.431 -		if (debugger)
 117.432 -			break;
 117.433 -	}
 117.434 -	while (armNextPC >= address && armNextPC < final);
 117.435 -
 117.436 -	remoteResumed = false;
 117.437 -
 117.438 -	remoteSendStatus();
 117.439 -}
 117.440 -
 117.441 -void remoteWriteWatch(char *p, bool active)
 117.442 -{
 117.443 -	u32 address;
 117.444 -	int count;
 117.445 -	sscanf(p, ",%x,%x#", &address, &count);
 117.446 -
 117.447 -	fprintf(stderr, "Write watch for %08x %d\n", address, count);
 117.448 -
 117.449 -	if (address < 0x2000000 || address > 0x3007fff)
 117.450 -	{
 117.451 -		remotePutPacket("E01");
 117.452 -		return;
 117.453 -	}
 117.454 -
 117.455 -	if (address > 0x203ffff && address < 0x3000000)
 117.456 -	{
 117.457 -		remotePutPacket("E01");
 117.458 -		return;
 117.459 -	}
 117.460 -
 117.461 -	u32 final = address + count;
 117.462 -
 117.463 -	if (address < 0x2040000 && final > 0x2040000)
 117.464 -	{
 117.465 -		remotePutPacket("E01");
 117.466 -		return;
 117.467 -	}
 117.468 -	else if (address < 0x3008000 && final > 0x3008000)
 117.469 -	{
 117.470 -		remotePutPacket("E01");
 117.471 -		return;
 117.472 -	}
 117.473 -
 117.474 -	for (int i = 0; i < count; i++)
 117.475 -	{
 117.476 -		if ((address >> 24) == 2)
 117.477 -			freezeWorkRAM[address & 0x3ffff] = active;
 117.478 -		else
 117.479 -			freezeInternalRAM[address & 0x7fff] = active;
 117.480 -		address++;
 117.481 -	}
 117.482 -
 117.483 -	remotePutPacket("OK");
 117.484 -}
 117.485 -
 117.486 -void remoteReadRegisters(char *p)
 117.487 -{
 117.488 -	char buffer[1024];
 117.489 -
 117.490 -	char *s = buffer;
 117.491 -	int   i;
 117.492 -	// regular registers
 117.493 -	for (i = 0; i < 15; i++)
 117.494 -	{
 117.495 -		u32 v = reg[i].I;
 117.496 -		sprintf(s, "%02x%02x%02x%02x",  v & 255, (v >> 8) & 255,
 117.497 -		        (v >> 16) & 255, (v >> 24) & 255);
 117.498 -		s += 8;
 117.499 -	}
 117.500 -	// PC
 117.501 -	u32 pc = armNextPC;
 117.502 -	sprintf(s, "%02x%02x%02x%02x", pc & 255, (pc >> 8) & 255,
 117.503 -	        (pc >> 16) & 255, (pc >> 24) & 255);
 117.504 -	s += 8;
 117.505 -
 117.506 -	// floating point registers (24-bit)
 117.507 -	for (i = 0; i < 8; i++)
 117.508 -	{
 117.509 -		sprintf(s, "000000000000000000000000");
 117.510 -		s += 24;
 117.511 -	}
 117.512 -
 117.513 -	// FP status register
 117.514 -	sprintf(s, "00000000");
 117.515 -	s += 8;
 117.516 -	// CPSR
 117.517 -	CPUUpdateCPSR();
 117.518 -	u32 v = reg[16].I;
 117.519 -	sprintf(s, "%02x%02x%02x%02x",  v & 255, (v >> 8) & 255,
 117.520 -	        (v >> 16) & 255, (v >> 24) & 255);
 117.521 -	s += 8;
 117.522 -	*s = 0;
 117.523 -	remotePutPacket(buffer);
 117.524 -}
 117.525 -
 117.526 -void remoteWriteRegister(char *p)
 117.527 -{
 117.528 -	int r;
 117.529 -
 117.530 -	sscanf(p, "%x=", &r);
 117.531 -
 117.532 -	p = strchr(p, '=');
 117.533 -	p++;
 117.534 -
 117.535 -	char c = *p++;
 117.536 -
 117.537 -	u32 v = 0;
 117.538 -
 117.539 -	u8 data[4] = {0, 0, 0, 0};
 117.540 -
 117.541 -	int i = 0;
 117.542 -
 117.543 -	while (c != '#')
 117.544 -	{
 117.545 -		u8 b = 0;
 117.546 -		if (c <= '9')
 117.547 -			b = (c - '0') << 4;
 117.548 -		else
 117.549 -			b = (c + 10 - 'a') << 4;
 117.550 -		c = *p++;
 117.551 -		if (c <= '9')
 117.552 -			b += (c - '0');
 117.553 -		else
 117.554 -			b += (c + 10 - 'a');
 117.555 -		data[i++] = b;
 117.556 -		c         = *p++;
 117.557 -	}
 117.558 -
 117.559 -	v = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
 117.560 -
 117.561 -	//  printf("Write register %d=%08x\n", r, v);
 117.562 -	reg[r].I = v;
 117.563 -	if (r == 15)
 117.564 -	{
 117.565 -		armNextPC = v;
 117.566 -		if (armState)
 117.567 -			reg[15].I = v + 4;
 117.568 -		else
 117.569 -			reg[15].I = v + 2;
 117.570 -	}
 117.571 -	remotePutPacket("OK");
 117.572 -}
 117.573 -
 117.574 -void remoteStubMain()
 117.575 -{
 117.576 -	if (!debugger)
 117.577 -		return;
 117.578 -
 117.579 -	if (remoteResumed)
 117.580 -	{
 117.581 -		remoteSendStatus();
 117.582 -		remoteResumed = false;
 117.583 -	}
 117.584 -
 117.585 -	while (true)
 117.586 -	{
 117.587 -		char buffer[1024];
 117.588 -		int  res = remoteRecvFnc(buffer, 1024);
 117.589 -
 117.590 -		if (res == -1)
 117.591 -		{
 117.592 -			fprintf(stderr, "GDB connection lost\n");
 117.593 -#ifdef SDL
 117.594 -			dbgMain   = debuggerMain;
 117.595 -			dbgSignal = debuggerSignal;
 117.596 -#endif
 117.597 -			debugger = false;
 117.598 -			break;
 117.599 -		}
 117.600 -
 117.601 -		//    fprintf(stderr, "Received %s\n", buffer);
 117.602 -		char *p  = buffer;
 117.603 -		char  c  = *p++;
 117.604 -		char  pp = '+';
 117.605 -		remoteSendFnc(&pp, 1);
 117.606 -
 117.607 -		if (c != '$')
 117.608 -			continue;
 117.609 -		c = *p++;
 117.610 -		switch (c)
 117.611 -		{
 117.612 -		case '?':
 117.613 -			remoteSendSignal();
 117.614 -			break;
 117.615 -		case 'D':
 117.616 -			remotePutPacket("OK");
 117.617 -#ifdef SDL
 117.618 -			dbgMain   = debuggerMain;
 117.619 -			dbgSignal = debuggerSignal;
 117.620 -#endif
 117.621 -			remoteResumed = true;
 117.622 -			debugger      = false;
 117.623 -			return;
 117.624 -		case 'e':
 117.625 -			remoteStepOverRange(p);
 117.626 -			break;
 117.627 -		case 'k':
 117.628 -			remotePutPacket("OK");
 117.629 -#ifdef SDL
 117.630 -			dbgMain   = debuggerMain;
 117.631 -			dbgSignal = debuggerSignal;
 117.632 -#endif
 117.633 -			debugger  = false;
 117.634 -			emulating = false;
 117.635 -			return;
 117.636 -		case 'C':
 117.637 -			remoteResumed = true;
 117.638 -			debugger      = false;
 117.639 -			return;
 117.640 -		case 'c':
 117.641 -			remoteResumed = true;
 117.642 -			debugger      = false;
 117.643 -			return;
 117.644 -		case 's':
 117.645 -			remoteResumed = true;
 117.646 -			remoteSignal  = 5;
 117.647 -			CPULoop(1);
 117.648 -			if (remoteResumed)
 117.649 -			{
 117.650 -				remoteResumed = false;
 117.651 -				remoteSendStatus();
 117.652 -			}
 117.653 -			break;
 117.654 -		case 'g':
 117.655 -			remoteReadRegisters(p);
 117.656 -			break;
 117.657 -		case 'P':
 117.658 -			remoteWriteRegister(p);
 117.659 -			break;
 117.660 -		case 'M':
 117.661 -			remoteMemoryWrite(p);
 117.662 -			break;
 117.663 -		case 'm':
 117.664 -			remoteMemoryRead(p);
 117.665 -			break;
 117.666 -		case 'X':
 117.667 -			remoteBinaryWrite(p);
 117.668 -			break;
 117.669 -		case 'H':
 117.670 -			remotePutPacket("OK");
 117.671 -			break;
 117.672 -		case 'q':
 117.673 -			remotePutPacket("");
 117.674 -			break;
 117.675 -		case 'Z':
 117.676 -			if (*p++ == '2')
 117.677 -			{
 117.678 -				remoteWriteWatch(p, true);
 117.679 -			}
 117.680 -			else
 117.681 -				remotePutPacket("");
 117.682 -			break;
 117.683 -		case 'z':
 117.684 -			if (*p++ == '2')
 117.685 -			{
 117.686 -				remoteWriteWatch(p, false);
 117.687 -			}
 117.688 -			else
 117.689 -				remotePutPacket("");
 117.690 -			break;
 117.691 -		default:
 117.692 -		{
 117.693 -			*(strchr(p, '#') + 3) = 0;
 117.694 -			fprintf(stderr, "Unknown packet %s\n", --p);
 117.695 -			remotePutPacket("");
 117.696 -			break;
 117.697 -		}
 117.698 -		}
 117.699 -	}
 117.700 -}
 117.701 -
 117.702 -void remoteStubSignal(int sig, int number)
 117.703 -{
 117.704 -	remoteSignal  = sig;
 117.705 -	remoteResumed = false;
 117.706 -	remoteSendStatus();
 117.707 -	debugger = true;
 117.708 -}
 117.709 -
 117.710 -void remoteCleanUp()
 117.711 -{
 117.712 -	if (remoteCleanUpFnc)
 117.713 -		remoteCleanUpFnc();
 117.714 -}
 117.715 -
   118.1 --- a/src/gba/thumb.h	Sat Mar 03 10:54:39 2012 -0600
   118.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   118.3 @@ -1,2524 +0,0 @@
   118.4 -#ifdef C_CORE
   118.5 -#define NEG(i) ((i) >> 31)
   118.6 -#define POS(i) ((~(i)) >> 31)
   118.7 -#define ADDCARRY(a, b, c) \
   118.8 -    C_FLAG = ((NEG(a) & NEG(b)) | \
   118.9 -              (NEG(a) & POS(c)) | \
  118.10 -              (NEG(b) & POS(c))) ? true : false;
  118.11 -#define ADDOVERFLOW(a, b, c) \
  118.12 -    V_FLAG = ((NEG(a) & NEG(b) & POS(c)) | \
  118.13 -              (POS(a) & POS(b) & NEG(c))) ? true : false;
  118.14 -#define SUBCARRY(a, b, c) \
  118.15 -    C_FLAG = ((NEG(a) & POS(b)) | \
  118.16 -              (NEG(a) & POS(c)) | \
  118.17 -              (POS(b) & POS(c))) ? true : false;
  118.18 -#define SUBOVERFLOW(a, b, c) \
  118.19 -    V_FLAG = ((NEG(a) & POS(b) & POS(c)) | \
  118.20 -              (POS(a) & NEG(b) & NEG(c))) ? true : false;
  118.21 -#define ADD_RD_RS_RN \
  118.22 -	{ \
  118.23 -		u32 lhs = reg[source].I; \
  118.24 -		u32 rhs = value; \
  118.25 -		u32 res = lhs + rhs; \
  118.26 -		reg[dest].I = res; \
  118.27 -		Z_FLAG		= (res == 0) ? true : false; \
  118.28 -		N_FLAG		= NEG(res) ? true : false; \
  118.29 -		ADDCARRY(lhs, rhs, res); \
  118.30 -		ADDOVERFLOW(lhs, rhs, res); \
  118.31 -	}
  118.32 -#define ADD_RD_RS_O3 \
  118.33 -	{ \
  118.34 -		u32 lhs = reg[source].I; \
  118.35 -		u32 rhs = value; \
  118.36 -		u32 res = lhs + rhs; \
  118.37 -		reg[dest].I = res; \
  118.38 -		Z_FLAG		= (res == 0) ? true : false; \
  118.39 -		N_FLAG		= NEG(res) ? true : false; \
  118.40 -		ADDCARRY(lhs, rhs, res); \
  118.41 -		ADDOVERFLOW(lhs, rhs, res); \
  118.42 -	}
  118.43 -#define ADD_RN_O8(d) \
  118.44 -	{ \
  118.45 -		u32 lhs = reg[(d)].I; \
  118.46 -		u32 rhs = (opcode & 255); \
  118.47 -		u32 res = lhs + rhs; \
  118.48 -		reg[(d)].I = res; \
  118.49 -		Z_FLAG	   = (res == 0) ? true : false; \
  118.50 -		N_FLAG	   = NEG(res) ? true : false; \
  118.51 -		ADDCARRY(lhs, rhs, res); \
  118.52 -		ADDOVERFLOW(lhs, rhs, res); \
  118.53 -	}
  118.54 -#define CMN_RD_RS \
  118.55 -	{ \
  118.56 -		u32 lhs = reg[dest].I; \
  118.57 -		u32 rhs = value; \
  118.58 -		u32 res = lhs + rhs; \
  118.59 -		Z_FLAG = (res == 0) ? true : false; \
  118.60 -		N_FLAG = NEG(res) ? true : false; \
  118.61 -		ADDCARRY(lhs, rhs, res); \
  118.62 -		ADDOVERFLOW(lhs, rhs, res); \
  118.63 -	}
  118.64 -#define ADC_RD_RS \
  118.65 -	{ \
  118.66 -		u32 lhs = reg[dest].I; \
  118.67 -		u32 rhs = value; \
  118.68 -		u32 res = lhs + rhs + (u32)C_FLAG; \
  118.69 -		reg[dest].I = res; \
  118.70 -		Z_FLAG		= (res == 0) ? true : false; \
  118.71 -		N_FLAG		= NEG(res) ? true : false; \
  118.72 -		ADDCARRY(lhs, rhs, res); \
  118.73 -		ADDOVERFLOW(lhs, rhs, res); \
  118.74 -	}
  118.75 -#define SUB_RD_RS_RN \
  118.76 -	{ \
  118.77 -		u32 lhs = reg[source].I; \
  118.78 -		u32 rhs = value; \
  118.79 -		u32 res = lhs - rhs; \
  118.80 -		reg[dest].I = res; \
  118.81 -		Z_FLAG		= (res == 0) ? true : false; \
  118.82 -		N_FLAG		= NEG(res) ? true : false; \
  118.83 -		SUBCARRY(lhs, rhs, res); \
  118.84 -		SUBOVERFLOW(lhs, rhs, res); \
  118.85 -	}
  118.86 -#define SUB_RD_RS_O3 \
  118.87 -	{ \
  118.88 -		u32 lhs = reg[source].I; \
  118.89 -		u32 rhs = value; \
  118.90 -		u32 res = lhs - rhs; \
  118.91 -		reg[dest].I = res; \
  118.92 -		Z_FLAG		= (res == 0) ? true : false; \
  118.93 -		N_FLAG		= NEG(res) ? true : false; \
  118.94 -		SUBCARRY(lhs, rhs, res); \
  118.95 -		SUBOVERFLOW(lhs, rhs, res); \
  118.96 -	}
  118.97 -#define SUB_RN_O8(d) \
  118.98 -	{ \
  118.99 -		u32 lhs = reg[(d)].I; \
 118.100 -		u32 rhs = (opcode & 255); \
 118.101 -		u32 res = lhs - rhs; \
 118.102 -		reg[(d)].I = res; \
 118.103 -		Z_FLAG	   = (res == 0) ? true : false; \
 118.104 -		N_FLAG	   = NEG(res) ? true : false; \
 118.105 -		SUBCARRY(lhs, rhs, res); \
 118.106 -		SUBOVERFLOW(lhs, rhs, res); \
 118.107 -	}
 118.108 -#define CMP_RN_O8(d) \
 118.109 -	{ \
 118.110 -		u32 lhs = reg[(d)].I; \
 118.111 -		u32 rhs = (opcode & 255); \
 118.112 -		u32 res = lhs - rhs; \
 118.113 -		Z_FLAG = (res == 0) ? true : false; \
 118.114 -		N_FLAG = NEG(res) ? true : false; \
 118.115 -		SUBCARRY(lhs, rhs, res); \
 118.116 -		SUBOVERFLOW(lhs, rhs, res); \
 118.117 -	}
 118.118 -#define SBC_RD_RS \
 118.119 -	{ \
 118.120 -		u32 lhs = reg[dest].I; \
 118.121 -		u32 rhs = value; \
 118.122 -		u32 res = lhs - rhs - !((u32)C_FLAG); \
 118.123 -		reg[dest].I = res; \
 118.124 -		Z_FLAG		= (res == 0) ? true : false; \
 118.125 -		N_FLAG		= NEG(res) ? true : false; \
 118.126 -		SUBCARRY(lhs, rhs, res); \
 118.127 -		SUBOVERFLOW(lhs, rhs, res); \
 118.128 -	}
 118.129 -#define LSL_RD_RM_I5 \
 118.130 -	{ \
 118.131 -		C_FLAG = (reg[source].I >> (32 - shift)) & 1 ? true : false; \
 118.132 -		value  = reg[source].I << shift; \
 118.133 -	}
 118.134 -#define LSL_RD_RS \
 118.135 -	{ \
 118.136 -		C_FLAG = (reg[dest].I >> (32 - value)) & 1 ? true : false; \
 118.137 -		value  = reg[dest].I << value; \
 118.138 -	}
 118.139 -#define LSR_RD_RM_I5 \
 118.140 -	{ \
 118.141 -		C_FLAG = (reg[source].I >> (shift - 1)) & 1 ? true : false; \
 118.142 -		value  = reg[source].I >> shift; \
 118.143 -	}
 118.144 -#define LSR_RD_RS \
 118.145 -	{ \
 118.146 -		C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
 118.147 -		value  = reg[dest].I >> value; \
 118.148 -	}
 118.149 -#define ASR_RD_RM_I5 \
 118.150 -	{ \
 118.151 -		C_FLAG = ((s32)reg[source].I >> (int)(shift - 1)) & 1 ? true : false; \
 118.152 -		value  = (s32)reg[source].I >> (int)shift; \
 118.153 -	}
 118.154 -#define ASR_RD_RS \
 118.155 -	{ \
 118.156 -		C_FLAG = ((s32)reg[dest].I >> (int)(value - 1)) & 1 ? true : false; \
 118.157 -		value  = (s32)reg[dest].I >> (int)value; \
 118.158 -	}
 118.159 -#define ROR_RD_RS \
 118.160 -	{ \
 118.161 -		C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
 118.162 -		value  = ((reg[dest].I << (32 - value)) | \
 118.163 -		          (reg[dest].I >> value)); \
 118.164 -	}
 118.165 -#define NEG_RD_RS \
 118.166 -	{ \
 118.167 -		u32 lhs = reg[source].I; \
 118.168 -		u32 rhs = 0; \
 118.169 -		u32 res = rhs - lhs; \
 118.170 -		reg[dest].I = res; \
 118.171 -		Z_FLAG		= (res == 0) ? true : false; \
 118.172 -		N_FLAG		= NEG(res) ? true : false; \
 118.173 -		SUBCARRY(rhs, lhs, res); \
 118.174 -		SUBOVERFLOW(rhs, lhs, res); \
 118.175 -	}
 118.176 -#define CMP_RD_RS \
 118.177 -	{ \
 118.178 -		u32 lhs = reg[dest].I; \
 118.179 -		u32 rhs = value; \
 118.180 -		u32 res = lhs - rhs; \
 118.181 -		Z_FLAG = (res == 0) ? true : false; \
 118.182 -		N_FLAG = NEG(res) ? true : false; \
 118.183 -		SUBCARRY(lhs, rhs, res); \
 118.184 -		SUBOVERFLOW(lhs, rhs, res); \
 118.185 -	}
 118.186 -#else
 118.187 -#ifdef __GNUC__
 118.188 -#ifdef __POWERPC__
 118.189 -			#define ADD_RD_RS_RN \
 118.190 -	{                                       \
 118.191 -		register int Flags;                 \
 118.192 -		register int Result;                \
 118.193 -		asm volatile ("addco. %0, %2, %3\n"  \
 118.194 -		              "mcrxr cr1\n"           \
 118.195 -		              "mfcr %1\n"             \
 118.196 -					  : "=r" (Result),        \
 118.197 -		              "=r" (Flags)          \
 118.198 -					  : "r" (reg[source].I),  \
 118.199 -		              "r" (value)           \
 118.200 -		              );                      \
 118.201 -		reg[dest].I = Result;               \
 118.202 -		Z_FLAG		= (Flags >> 29) & 1;         \
 118.203 -		N_FLAG		= (Flags >> 31) & 1;         \
 118.204 -		C_FLAG		= (Flags >> 25) & 1;         \
 118.205 -		V_FLAG		= (Flags >> 26) & 1;         \
 118.206 -	}
 118.207 -			#define ADD_RD_RS_O3 ADD_RD_RS_RN
 118.208 -			#define ADD_RN_O8(d) \
 118.209 -	{ \
 118.210 -		register int Flags;                 \
 118.211 -		register int Result;                \
 118.212 -		asm volatile ("addco. %0, %2, %3\n"  \
 118.213 -		              "mcrxr cr1\n"           \
 118.214 -		              "mfcr %1\n"             \
 118.215 -					  : "=r" (Result),        \
 118.216 -		              "=r" (Flags)          \
 118.217 -					  : "r" (reg[(d)].I),     \
 118.218 -		              "r" (opcode & 255)    \
 118.219 -		              );                      \
 118.220 -		reg[(d)].I = Result;                \
 118.221 -		Z_FLAG	   = (Flags >> 29) & 1;         \
 118.222 -		N_FLAG	   = (Flags >> 31) & 1;         \
 118.223 -		C_FLAG	   = (Flags >> 25) & 1;         \
 118.224 -		V_FLAG	   = (Flags >> 26) & 1;         \
 118.225 -	}
 118.226 -			#define CMN_RD_RS \
 118.227 -	{ \
 118.228 -		register int Flags;                 \
 118.229 -		register int Result;                \
 118.230 -		asm volatile ("addco. %0, %2, %3\n"  \
 118.231 -		              "mcrxr cr1\n"           \
 118.232 -		              "mfcr %1\n"             \
 118.233 -					  : "=r" (Result),        \
 118.234 -		              "=r" (Flags)          \
 118.235 -					  : "r" (reg[dest].I),    \
 118.236 -		              "r" (value)           \
 118.237 -		              );                      \
 118.238 -		Z_FLAG = (Flags >> 29) & 1;         \
 118.239 -		N_FLAG = (Flags >> 31) & 1;         \
 118.240 -		C_FLAG = (Flags >> 25) & 1;         \
 118.241 -		V_FLAG = (Flags >> 26) & 1;         \
 118.242 -	}
 118.243 -			#define ADC_RD_RS \
 118.244 -	{ \
 118.245 -		register int Flags;                 \
 118.246 -		register int Result;                \
 118.247 -		asm volatile ("mtspr xer, %4\n"      \
 118.248 -		              "addeo. %0, %2, %3\n"  \
 118.249 -		              "mcrxr cr1\n"          \
 118.250 -		              "mfcr	%1\n"            \
 118.251 -					  : "=r" (Result),       \
 118.252 -		              "=r" (Flags)         \
 118.253 -					  : "r" (reg[dest].I),   \
 118.254 -		              "r" (value),         \
 118.255 -		              "r" (C_FLAG << 29)   \
 118.256 -		              );                     \
 118.257 -		reg[dest].I = Result;               \
 118.258 -		Z_FLAG		= (Flags >> 29) & 1;         \
 118.259 -		N_FLAG		= (Flags >> 31) & 1;         \
 118.260 -		C_FLAG		= (Flags >> 25) & 1;         \
 118.261 -		V_FLAG		= (Flags >> 26) & 1;         \
 118.262 -	}
 118.263 -			#define SUB_RD_RS_RN \
 118.264 -	{ \
 118.265 -		register int Flags;                 \
 118.266 -		register int Result;                \
 118.267 -		asm volatile ("subco. %0, %2, %3\n"  \
 118.268 -		              "mcrxr cr1\n"           \
 118.269 -		              "mfcr %1\n"             \
 118.270 -					  : "=r" (Result),        \
 118.271 -		              "=r" (Flags)          \
 118.272 -					  : "r" (reg[source].I),  \
 118.273 -		              "r" (value)           \
 118.274 -		              );                      \
 118.275 -		reg[dest].I = Result;               \
 118.276 -		Z_FLAG		= (Flags >> 29) & 1;         \
 118.277 -		N_FLAG		= (Flags >> 31) & 1;         \
 118.278 -		C_FLAG		= (Flags >> 25) & 1;         \
 118.279 -		V_FLAG		= (Flags >> 26) & 1;         \
 118.280 -	}
 118.281 -			#define SUB_RD_RS_O3 SUB_RD_RS_RN
 118.282 -			#define SUB_RN_O8(d) \
 118.283 -	{ \
 118.284 -		register int Flags;                 \
 118.285 -		register int Result;                \
 118.286 -		asm volatile ("subco. %0, %2, %3\n"  \
 118.287 -		              "mcrxr cr1\n"           \
 118.288 -		              "mfcr %1\n"             \
 118.289 -					  : "=r" (Result),        \
 118.290 -		              "=r" (Flags)          \
 118.291 -					  : "r" (reg[(d)].I),     \
 118.292 -		              "r" (opcode & 255)    \
 118.293 -		              );                      \
 118.294 -		reg[(d)].I = Result;                \
 118.295 -		Z_FLAG	   = (Flags >> 29) & 1;         \
 118.296 -		N_FLAG	   = (Flags >> 31) & 1;         \
 118.297 -		C_FLAG	   = (Flags >> 25) & 1;         \
 118.298 -		V_FLAG	   = (Flags >> 26) & 1;         \
 118.299 -	}
 118.300 -			#define CMP_RN_O8(d) \
 118.301 -	{ \
 118.302 -		register int Flags;                 \
 118.303 -		register int Result;                \
 118.304 -		asm volatile ("subco. %0, %2, %3\n"  \
 118.305 -		              "mcrxr cr1\n"           \
 118.306 -		              "mfcr %1\n"             \
 118.307 -					  : "=r" (Result),        \
 118.308 -		              "=r" (Flags)          \
 118.309 -					  : "r" (reg[(d)].I),     \
 118.310 -		              "r" (opcode & 255)    \
 118.311 -		              );                      \
 118.312 -		Z_FLAG = (Flags >> 29) & 1;         \
 118.313 -		N_FLAG = (Flags >> 31) & 1;         \
 118.314 -		C_FLAG = (Flags >> 25) & 1;         \
 118.315 -		V_FLAG = (Flags >> 26) & 1;         \
 118.316 -	}
 118.317 -			#define SBC_RD_RS \
 118.318 -	{ \
 118.319 -		register int Flags;                 \
 118.320 -		register int Result;                \
 118.321 -		asm volatile ("mtspr xer, %4\n"      \
 118.322 -		              "subfeo. %0, %3, %2\n" \
 118.323 -		              "mcrxr cr1\n"          \
 118.324 -		              "mfcr	%1\n"            \
 118.325 -					  : "=r" (Result),       \
 118.326 -		              "=r" (Flags)         \
 118.327 -					  : "r" (reg[dest].I),   \
 118.328 -		              "r" (value),         \
 118.329 -		              "r" (C_FLAG << 29)   \
 118.330 -		              );                     \
 118.331 -		reg[dest].I = Result;               \
 118.332 -		Z_FLAG		= (Flags >> 29) & 1;         \
 118.333 -		N_FLAG		= (Flags >> 31) & 1;         \
 118.334 -		C_FLAG		= (Flags >> 25) & 1;         \
 118.335 -		V_FLAG		= (Flags >> 26) & 1;         \
 118.336 -	}
 118.337 -			#define LSL_RD_RM_I5 \
 118.338 -	{ \
 118.339 -		C_FLAG = (reg[source].I >> (32 - shift)) & 1 ? true : false; \
 118.340 -		value  = reg[source].I << shift; \
 118.341 -	}
 118.342 -			#define LSL_RD_RS \
 118.343 -	{ \
 118.344 -		C_FLAG = (reg[dest].I >> (32 - value)) & 1 ? true : false; \
 118.345 -		value  = reg[dest].I << value; \
 118.346 -	}
 118.347 -			#define LSR_RD_RM_I5 \
 118.348 -	{ \
 118.349 -		C_FLAG = (reg[source].I >> (shift - 1)) & 1 ? true : false; \
 118.350 -		value  = reg[source].I >> shift; \
 118.351 -	}
 118.352 -			#define LSR_RD_RS \
 118.353 -	{ \
 118.354 -		C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
 118.355 -		value  = reg[dest].I >> value; \
 118.356 -	}
 118.357 -			#define ASR_RD_RM_I5 \
 118.358 -	{ \
 118.359 -		C_FLAG = ((s32)reg[source].I >> (int)(shift - 1)) & 1 ? true : false; \
 118.360 -		value  = (s32)reg[source].I >> (int)shift; \
 118.361 -	}
 118.362 -			#define ASR_RD_RS \
 118.363 -	{ \
 118.364 -		C_FLAG = ((s32)reg[dest].I >> (int)(value - 1)) & 1 ? true : false; \
 118.365 -		value  = (s32)reg[dest].I >> (int)value; \
 118.366 -	}
 118.367 -			#define ROR_RD_RS \
 118.368 -	{ \
 118.369 -		C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
 118.370 -		value  = ((reg[dest].I << (32 - value)) | \
 118.371 -		          (reg[dest].I >> value)); \
 118.372 -	}
 118.373 -			#define NEG_RD_RS \
 118.374 -	{ \
 118.375 -		register int Flags;                 \
 118.376 -		register int Result;                \
 118.377 -		asm volatile ("subfco. %0, %2, %3\n" \
 118.378 -		              "mcrxr cr1\n"           \
 118.379 -		              "mfcr %1\n"             \
 118.380 -					  : "=r" (Result),        \
 118.381 -		              "=r" (Flags)          \
 118.382 -					  : "r" (reg[source].I),  \
 118.383 -		              "r" (0)               \
 118.384 -		              );                      \
 118.385 -		reg[dest].I = Result;               \
 118.386 -		Z_FLAG		= (Flags >> 29) & 1;         \
 118.387 -		N_FLAG		= (Flags >> 31) & 1;         \
 118.388 -		C_FLAG		= (Flags >> 25) & 1;         \
 118.389 -		V_FLAG		= (Flags >> 26) & 1;         \
 118.390 -	}
 118.391 -			#define CMP_RD_RS \
 118.392 -	{ \
 118.393 -		register int Flags;                 \
 118.394 -		register int Result;                \
 118.395 -		asm volatile ("subco. %0, %2, %3\n"  \
 118.396 -		              "mcrxr cr1\n"           \
 118.397 -		              "mfcr %1\n"             \
 118.398 -					  : "=r" (Result),        \
 118.399 -		              "=r" (Flags)          \
 118.400 -					  : "r" (reg[dest].I),    \
 118.401 -		              "r" (value)           \
 118.402 -		              );                      \
 118.403 -		Z_FLAG = (Flags >> 29) & 1;         \
 118.404 -		N_FLAG = (Flags >> 31) & 1;         \
 118.405 -		C_FLAG = (Flags >> 25) & 1;         \
 118.406 -		V_FLAG = (Flags >> 26) & 1;         \
 118.407 -	}
 118.408 -#else
 118.409 -#define ADD_RD_RS_RN \
 118.410 -    asm ("add %1, %%ebx;" \
 118.411 -         "setsb N_FLAG;" \
 118.412 -         "setzb Z_FLAG;" \
 118.413 -         "setcb C_FLAG;" \
 118.414 -         "setob V_FLAG;" \
 118.415 -		 : "=b" (reg[dest].I) \
 118.416 -		 : "r" (value), "b" (reg[source].I));
 118.417 -#define ADD_RD_RS_O3 \
 118.418 -    asm ("add %1, %%ebx;" \
 118.419 -         "setsb N_FLAG;" \
 118.420 -         "setzb Z_FLAG;" \
 118.421 -         "setcb C_FLAG;" \
 118.422 -         "setob V_FLAG;" \
 118.423 -		 : "=b" (reg[dest].I) \
 118.424 -		 : "r" (value), "b" (reg[source].I));
 118.425 -#define ADD_RN_O8(d) \
 118.426 -    asm ("add %1, %%ebx;" \
 118.427 -         "setsb N_FLAG;" \
 118.428 -         "setzb Z_FLAG;" \
 118.429 -         "setcb C_FLAG;" \
 118.430 -         "setob V_FLAG;" \
 118.431 -		 : "=b" (reg[(d)].I) \
 118.432 -		 : "r" (opcode & 255), "b" (reg[(d)].I));
 118.433 -#define CMN_RD_RS \
 118.434 -    asm ("add %0, %1;" \
 118.435 -         "setsb N_FLAG;" \
 118.436 -         "setzb Z_FLAG;" \
 118.437 -         "setcb C_FLAG;" \
 118.438 -         "setob V_FLAG;" \
 118.439 -		 : \
 118.440 -		 : "r" (value), "r" (reg[dest].I) : "1");
 118.441 -#define ADC_RD_RS \
 118.442 -    asm ("bt $0, C_FLAG;" \
 118.443 -         "adc %1, %%ebx;" \
 118.444 -         "setsb N_FLAG;" \
 118.445 -         "setzb Z_FLAG;" \
 118.446 -         "setcb C_FLAG;" \
 118.447 -         "setob V_FLAG;" \
 118.448 -		 : "=b" (reg[dest].I) \
 118.449 -		 : "r" (value), "b" (reg[dest].I));
 118.450 -#define SUB_RD_RS_RN \
 118.451 -    asm ("sub %1, %%ebx;" \
 118.452 -         "setsb N_FLAG;" \
 118.453 -         "setzb Z_FLAG;" \
 118.454 -         "setncb C_FLAG;" \
 118.455 -         "setob V_FLAG;" \
 118.456 -		 : "=b" (reg[dest].I) \
 118.457 -		 : "r" (value), "b" (reg[source].I));
 118.458 -#define SUB_RD_RS_O3 \
 118.459 -    asm ("sub %1, %%ebx;" \
 118.460 -         "setsb N_FLAG;" \
 118.461 -         "setzb Z_FLAG;" \
 118.462 -         "setncb C_FLAG;" \
 118.463 -         "setob V_FLAG;" \
 118.464 -		 : "=b" (reg[dest].I) \
 118.465 -		 : "r" (value), "b" (reg[source].I));
 118.466 -#define SUB_RN_O8(d) \
 118.467 -    asm ("sub %1, %%ebx;" \
 118.468 -         "setsb N_FLAG;" \
 118.469 -         "setzb Z_FLAG;" \
 118.470 -         "setncb C_FLAG;" \
 118.471 -         "setob V_FLAG;" \
 118.472 -		 : "=b" (reg[(d)].I) \
 118.473 -		 : "r" (opcode & 255), "b" (reg[(d)].I));
 118.474 -#define CMP_RN_O8(d) \
 118.475 -    asm ("sub %0, %1;" \
 118.476 -         "setsb N_FLAG;" \
 118.477 -         "setzb Z_FLAG;" \
 118.478 -         "setncb C_FLAG;" \
 118.479 -         "setob V_FLAG;" \
 118.480 -		 : \
 118.481 -		 : "r" (opcode & 255), "r" (reg[(d)].I) : "1");
 118.482 -#define SBC_RD_RS \
 118.483 -    asm volatile ("bt $0, C_FLAG;" \
 118.484 -                  "cmc;" \
 118.485 -                  "sbb %1, %%ebx;" \
 118.486 -                  "setsb N_FLAG;" \
 118.487 -                  "setzb Z_FLAG;" \
 118.488 -                  "setncb C_FLAG;" \
 118.489 -                  "setob V_FLAG;" \
 118.490 -				  : "=b" (reg[dest].I) \
 118.491 -				  : "r" (value), "b" (reg[dest].I) : "cc", "memory");
 118.492 -#define LSL_RD_RM_I5 \
 118.493 -    asm ("shl %%cl, %%eax;" \
 118.494 -         "setcb C_FLAG;" \
 118.495 -		 : "=a" (value) \
 118.496 -		 : "a" (reg[source].I), "c" (shift));
 118.497 -#define LSL_RD_RS \
 118.498 -    asm ("shl %%cl, %%eax;" \
 118.499 -         "setcb C_FLAG;" \
 118.500 -		 : "=a" (value) \
 118.501 -		 : "a" (reg[dest].I), "c" (value));
 118.502 -#define LSR_RD_RM_I5 \
 118.503 -    asm ("shr %%cl, %%eax;" \
 118.504 -         "setcb C_FLAG;" \
 118.505 -		 : "=a" (value) \
 118.506 -		 : "a" (reg[source].I), "c" (shift));
 118.507 -#define LSR_RD_RS \
 118.508 -    asm ("shr %%cl, %%eax;" \
 118.509 -         "setcb C_FLAG;" \
 118.510 -		 : "=a" (value) \
 118.511 -		 : "a" (reg[dest].I), "c" (value));
 118.512 -#define ASR_RD_RM_I5 \
 118.513 -    asm ("sar %%cl, %%eax;" \
 118.514 -         "setcb C_FLAG;" \
 118.515 -		 : "=a" (value) \
 118.516 -		 : "a" (reg[source].I), "c" (shift));
 118.517 -#define ASR_RD_RS \
 118.518 -    asm ("sar %%cl, %%eax;" \
 118.519 -         "setcb C_FLAG;" \
 118.520 -		 : "=a" (value) \
 118.521 -		 : "a" (reg[dest].I), "c" (value));
 118.522 -#define ROR_RD_RS \
 118.523 -    asm ("ror %%cl, %%eax;" \
 118.524 -         "setcb C_FLAG;" \
 118.525 -		 : "=a" (value) \
 118.526 -		 : "a" (reg[dest].I), "c" (value));
 118.527 -#define NEG_RD_RS \
 118.528 -    asm ("neg %%ebx;" \
 118.529 -         "setsb N_FLAG;" \
 118.530 -         "setzb Z_FLAG;" \
 118.531 -         "setncb C_FLAG;" \
 118.532 -         "setob V_FLAG;" \
 118.533 -		 : "=b" (reg[dest].I) \
 118.534 -		 : "b" (reg[source].I));
 118.535 -#define CMP_RD_RS \
 118.536 -    asm ("sub %0, %1;" \
 118.537 -         "setsb N_FLAG;" \
 118.538 -         "setzb Z_FLAG;" \
 118.539 -         "setncb C_FLAG;" \
 118.540 -         "setob V_FLAG;" \
 118.541 -		 : \
 118.542 -		 : "r" (value), "r" (reg[dest].I) : "1");
 118.543 -#endif
 118.544 -#else
 118.545 -#define ADD_RD_RS_RN \
 118.546 -	{ \
 118.547 -		__asm mov eax, source \
 118.548 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.549 -		__asm add ebx, value \
 118.550 -		__asm mov eax, dest \
 118.551 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.552 -		__asm sets byte ptr N_FLAG \
 118.553 -		__asm setz byte ptr Z_FLAG \
 118.554 -		__asm setc byte ptr C_FLAG \
 118.555 -		__asm seto byte ptr V_FLAG \
 118.556 -	}
 118.557 -#define ADD_RD_RS_O3 \
 118.558 -	{ \
 118.559 -		__asm mov eax, source \
 118.560 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.561 -		__asm add ebx, value \
 118.562 -		__asm mov eax, dest \
 118.563 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.564 -		__asm sets byte ptr N_FLAG \
 118.565 -		__asm setz byte ptr Z_FLAG \
 118.566 -		__asm setc byte ptr C_FLAG \
 118.567 -		__asm seto byte ptr V_FLAG \
 118.568 -	}
 118.569 -#define ADD_RN_O8(d) \
 118.570 -	{ \
 118.571 -		__asm mov ebx, opcode \
 118.572 -		          __asm and ebx, 255 \
 118.573 -		__asm add dword ptr [OFFSET reg + 4 * (d)], ebx \
 118.574 -		__asm sets byte ptr N_FLAG \
 118.575 -		__asm setz byte ptr Z_FLAG \
 118.576 -		__asm setc byte ptr C_FLAG \
 118.577 -		__asm seto byte ptr V_FLAG \
 118.578 -	}
 118.579 -#define CMN_RD_RS \
 118.580 -	{ \
 118.581 -		__asm mov eax, dest \
 118.582 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.583 -		__asm add ebx, value \
 118.584 -		__asm sets byte ptr N_FLAG \
 118.585 -		__asm setz byte ptr Z_FLAG \
 118.586 -		__asm setc byte ptr C_FLAG \
 118.587 -		__asm seto byte ptr V_FLAG \
 118.588 -	}
 118.589 -#define ADC_RD_RS \
 118.590 -	{ \
 118.591 -		__asm mov ebx, dest \
 118.592 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 118.593 -		__asm bt word ptr C_FLAG, 0 \
 118.594 -		__asm adc ebx, value \
 118.595 -		__asm mov eax, dest \
 118.596 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.597 -		__asm sets byte ptr N_FLAG \
 118.598 -		__asm setz byte ptr Z_FLAG \
 118.599 -		__asm setc byte ptr C_FLAG \
 118.600 -		__asm seto byte ptr V_FLAG \
 118.601 -	}
 118.602 -#define SUB_RD_RS_RN \
 118.603 -	{ \
 118.604 -		__asm mov eax, source \
 118.605 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.606 -		__asm sub ebx, value \
 118.607 -		__asm mov eax, dest \
 118.608 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.609 -		__asm sets byte ptr N_FLAG \
 118.610 -		__asm setz byte ptr Z_FLAG \
 118.611 -		__asm setnc byte ptr C_FLAG \
 118.612 -		__asm seto byte ptr V_FLAG \
 118.613 -	}
 118.614 -#define SUB_RD_RS_O3 \
 118.615 -	{ \
 118.616 -		__asm mov eax, source \
 118.617 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.618 -		__asm sub ebx, value \
 118.619 -		__asm mov eax, dest \
 118.620 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.621 -		__asm sets byte ptr N_FLAG \
 118.622 -		__asm setz byte ptr Z_FLAG \
 118.623 -		__asm setnc byte ptr C_FLAG \
 118.624 -		__asm seto byte ptr V_FLAG \
 118.625 -	}
 118.626 -#define SUB_RN_O8(d) \
 118.627 -	{ \
 118.628 -		__asm mov ebx, opcode \
 118.629 -		          __asm and ebx, 255 \
 118.630 -		__asm sub dword ptr [OFFSET reg + 4 * (d)], ebx \
 118.631 -		__asm sets byte ptr N_FLAG \
 118.632 -		__asm setz byte ptr Z_FLAG \
 118.633 -		__asm setnc byte ptr C_FLAG \
 118.634 -		__asm seto byte ptr V_FLAG \
 118.635 -	}
 118.636 -#define CMP_RN_O8(d) \
 118.637 -	{ \
 118.638 -		__asm mov eax, dword ptr [OFFSET reg + 4 * (d)] \
 118.639 -		__asm mov ebx, opcode \
 118.640 -		          __asm and ebx, 255 \
 118.641 -		__asm sub eax, ebx \
 118.642 -		__asm sets byte ptr N_FLAG \
 118.643 -		__asm setz byte ptr Z_FLAG \
 118.644 -		__asm setnc byte ptr C_FLAG \
 118.645 -		__asm seto byte ptr V_FLAG \
 118.646 -	}
 118.647 -#define SBC_RD_RS \
 118.648 -	{ \
 118.649 -		__asm mov ebx, dest \
 118.650 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 118.651 -		__asm mov eax, value \
 118.652 -		__asm bt word ptr C_FLAG, 0 \
 118.653 -		__asm cmc \
 118.654 -		__asm sbb ebx, eax \
 118.655 -		__asm mov eax, dest \
 118.656 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.657 -		__asm sets byte ptr N_FLAG \
 118.658 -		__asm setz byte ptr Z_FLAG \
 118.659 -		__asm setnc byte ptr C_FLAG \
 118.660 -		__asm seto byte ptr V_FLAG \
 118.661 -	}
 118.662 -#define LSL_RD_RM_I5 \
 118.663 -	{ \
 118.664 -		__asm mov eax, source \
 118.665 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.666 -		__asm mov cl, byte ptr shift \
 118.667 -		__asm shl eax, cl \
 118.668 -		__asm mov value, eax \
 118.669 -		__asm setc byte ptr C_FLAG \
 118.670 -	}
 118.671 -#define LSL_RD_RS \
 118.672 -	{ \
 118.673 -		__asm mov eax, dest \
 118.674 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.675 -		__asm mov cl, byte ptr value \
 118.676 -		__asm shl eax, cl \
 118.677 -		__asm mov value, eax \
 118.678 -		__asm setc byte ptr C_FLAG \
 118.679 -	}
 118.680 -#define LSR_RD_RM_I5 \
 118.681 -	{ \
 118.682 -		__asm mov eax, source \
 118.683 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.684 -		__asm mov cl, byte ptr shift \
 118.685 -		__asm shr eax, cl \
 118.686 -		__asm mov value, eax \
 118.687 -		__asm setc byte ptr C_FLAG \
 118.688 -	}
 118.689 -#define LSR_RD_RS \
 118.690 -	{ \
 118.691 -		__asm mov eax, dest \
 118.692 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.693 -		__asm mov cl, byte ptr value \
 118.694 -		__asm shr eax, cl \
 118.695 -		__asm mov value, eax \
 118.696 -		__asm setc byte ptr C_FLAG \
 118.697 -	}
 118.698 -#define ASR_RD_RM_I5 \
 118.699 -	{ \
 118.700 -		__asm mov eax, source \
 118.701 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.702 -		__asm mov cl, byte ptr shift \
 118.703 -		__asm sar eax, cl \
 118.704 -		__asm mov value, eax \
 118.705 -		__asm setc byte ptr C_FLAG \
 118.706 -	}
 118.707 -#define ASR_RD_RS \
 118.708 -	{ \
 118.709 -		__asm mov eax, dest \
 118.710 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.711 -		__asm mov cl, byte ptr value \
 118.712 -		__asm sar eax, cl \
 118.713 -		__asm mov value, eax \
 118.714 -		__asm setc byte ptr C_FLAG \
 118.715 -	}
 118.716 -#define ROR_RD_RS \
 118.717 -	{ \
 118.718 -		__asm mov eax, dest \
 118.719 -		__asm mov eax, dword ptr [OFFSET reg + 4 * eax] \
 118.720 -		__asm mov cl, byte ptr value \
 118.721 -		__asm ror eax, cl \
 118.722 -		__asm mov value, eax \
 118.723 -		__asm setc byte ptr C_FLAG \
 118.724 -	}
 118.725 -#define NEG_RD_RS \
 118.726 -	{ \
 118.727 -		__asm mov ebx, source \
 118.728 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * ebx] \
 118.729 -		__asm neg ebx \
 118.730 -		__asm mov eax, dest \
 118.731 -		__asm mov dword ptr [OFFSET reg + 4 * eax], ebx \
 118.732 -		__asm sets byte ptr N_FLAG \
 118.733 -		__asm setz byte ptr Z_FLAG \
 118.734 -		__asm setnc byte ptr C_FLAG \
 118.735 -		__asm seto byte ptr V_FLAG \
 118.736 -	}
 118.737 -#define CMP_RD_RS \
 118.738 -	{ \
 118.739 -		__asm mov eax, dest \
 118.740 -		__asm mov ebx, dword ptr [OFFSET reg + 4 * eax] \
 118.741 -		__asm sub ebx, value \
 118.742 -		__asm sets byte ptr N_FLAG \
 118.743 -		__asm setz byte ptr Z_FLAG \
 118.744 -		__asm setnc byte ptr C_FLAG \
 118.745 -		__asm seto byte ptr V_FLAG \
 118.746 -	}
 118.747 -#endif
 118.748 -#endif
 118.749 -
 118.750 -u32 opcode = CPUReadHalfWordQuick(armNextPC);
 118.751 -clockTicks = thumbCycles[opcode >> 8] + memoryWaitFetch[(armNextPC >> 24) & 15];
 118.752 -#ifndef FINAL_VERSION
 118.753 -if (armNextPC == stop)
 118.754 -{
 118.755 -	armNextPC = armNextPC++;
 118.756 -}
 118.757 -#endif
 118.758 -
 118.759 -armNextPC  = reg[15].I;
 118.760 -reg[15].I += 2;
 118.761 -
 118.762 -switch (opcode >> 8)
 118.763 -{
 118.764 -case 0x00:
 118.765 -case 0x01:
 118.766 -case 0x02:
 118.767 -case 0x03:
 118.768 -case 0x04:
 118.769 -case 0x05:
 118.770 -case 0x06:
 118.771 -case 0x07:
 118.772 -{
 118.773 -	// LSL Rd, Rm, #Imm 5
 118.774 -	int dest   = opcode & 0x07;
 118.775 -	int source = (opcode >> 3) & 0x07;
 118.776 -	int shift  = (opcode >> 6) & 0x1f;
 118.777 -	u32 value;
 118.778 -
 118.779 -	if (shift)
 118.780 -	{
 118.781 -		LSL_RD_RM_I5;
 118.782 -	}
 118.783 -	else
 118.784 -	{
 118.785 -		value = reg[source].I;
 118.786 -	}
 118.787 -	reg[dest].I = value;
 118.788 -	// C_FLAG set above
 118.789 -	N_FLAG = (value & 0x80000000 ? true : false);
 118.790 -	Z_FLAG = (value ? false : true);
 118.791 -}
 118.792 -break;
 118.793 -case 0x08:
 118.794 -case 0x09:
 118.795 -case 0x0a:
 118.796 -case 0x0b:
 118.797 -case 0x0c:
 118.798 -case 0x0d:
 118.799 -case 0x0e:
 118.800 -case 0x0f:
 118.801 -{
 118.802 -	// LSR Rd, Rm, #Imm 5
 118.803 -	int dest   = opcode & 0x07;
 118.804 -	int source = (opcode >> 3) & 0x07;
 118.805 -	int shift  = (opcode >> 6) & 0x1f;
 118.806 -	u32 value;
 118.807 -
 118.808 -	if (shift)
 118.809 -	{
 118.810 -		LSR_RD_RM_I5;
 118.811 -	}
 118.812 -	else
 118.813 -	{
 118.814 -		C_FLAG = reg[source].I & 0x80000000 ? true : false;
 118.815 -		value  = 0;
 118.816 -	}
 118.817 -	reg[dest].I = value;
 118.818 -	// C_FLAG set above
 118.819 -	N_FLAG = (value & 0x80000000 ? true : false);
 118.820 -	Z_FLAG = (value ? false : true);
 118.821 -}
 118.822 -break;
 118.823 -case 0x10:
 118.824 -case 0x11:
 118.825 -case 0x12:
 118.826 -case 0x13:
 118.827 -case 0x14:
 118.828 -case 0x15:
 118.829 -case 0x16:
 118.830 -case 0x17:
 118.831 -{
 118.832 -	// ASR Rd, Rm, #Imm 5
 118.833 -	int dest   = opcode & 0x07;
 118.834 -	int source = (opcode >> 3) & 0x07;
 118.835 -	int shift  = (opcode >> 6) & 0x1f;
 118.836 -	u32 value;
 118.837 -
 118.838 -	if (shift)
 118.839 -	{
 118.840 -		ASR_RD_RM_I5;
 118.841 -	}
 118.842 -	else
 118.843 -	{
 118.844 -		if (reg[source].I & 0x80000000)
 118.845 -		{
 118.846 -			value  = 0xFFFFFFFF;
 118.847 -			C_FLAG = true;
 118.848 -		}
 118.849 -		else
 118.850 -		{
 118.851 -			value  = 0;
 118.852 -			C_FLAG = false;
 118.853 -		}
 118.854 -	}
 118.855 -	reg[dest].I = value;
 118.856 -	// C_FLAG set above
 118.857 -	N_FLAG = (value & 0x80000000 ? true : false);
 118.858 -	Z_FLAG = (value ? false : true);
 118.859 -}
 118.860 -break;
 118.861 -case 0x18:
 118.862 -case 0x19:
 118.863 -{
 118.864 -	// ADD Rd, Rs, Rn
 118.865 -	int dest   = opcode & 0x07;
 118.866 -	int source = (opcode >> 3) & 0x07;
 118.867 -	u32 value  = reg[(opcode >> 6) & 0x07].I;
 118.868 -	ADD_RD_RS_RN;
 118.869 -}
 118.870 -break;
 118.871 -case 0x1a:
 118.872 -case 0x1b:
 118.873 -{
 118.874 -	// SUB Rd, Rs, Rn
 118.875 -	int dest   = opcode & 0x07;
 118.876 -	int source = (opcode >> 3) & 0x07;
 118.877 -	u32 value  = reg[(opcode >> 6) & 0x07].I;
 118.878 -	SUB_RD_RS_RN;
 118.879 -}
 118.880 -break;
 118.881 -case 0x1c:
 118.882 -case 0x1d:
 118.883 -{
 118.884 -	// ADD Rd, Rs, #Offset3
 118.885 -	int dest   = opcode & 0x07;
 118.886 -	int source = (opcode >> 3) & 0x07;
 118.887 -	u32 value  = (opcode >> 6) & 7;
 118.888 -	ADD_RD_RS_O3;
 118.889 -}
 118.890 -break;
 118.891 -case 0x1e:
 118.892 -case 0x1f:
 118.893 -{
 118.894 -	// SUB Rd, Rs, #Offset3
 118.895 -	int dest   = opcode & 0x07;
 118.896 -	int source = (opcode >> 3) & 0x07;
 118.897 -	u32 value  = (opcode >> 6) & 7;
 118.898 -	SUB_RD_RS_O3;
 118.899 -}
 118.900 -break;
 118.901 -case 0x20:
 118.902 -	// MOV R0, #Offset8
 118.903 -	reg[0].I = opcode & 255;
 118.904 -	N_FLAG	 = false;
 118.905 -	Z_FLAG	 = (reg[0].I ? false : true);
 118.906 -	break;
 118.907 -case 0x21:
 118.908 -	// MOV R1, #Offset8
 118.909 -	reg[1].I = opcode & 255;
 118.910 -	N_FLAG	 = false;
 118.911 -	Z_FLAG	 = (reg[1].I ? false : true);
 118.912 -	break;
 118.913 -case 0x22:
 118.914 -	// MOV R2, #Offset8
 118.915 -	reg[2].I = opcode & 255;
 118.916 -	N_FLAG	 = false;
 118.917 -	Z_FLAG	 = (reg[2].I ? false : true);
 118.918 -	break;
 118.919 -case 0x23:
 118.920 -	// MOV R3, #Offset8
 118.921 -	reg[3].I = opcode & 255;
 118.922 -	N_FLAG	 = false;
 118.923 -	Z_FLAG	 = (reg[3].I ? false : true);
 118.924 -	break;
 118.925 -case 0x24:
 118.926 -	// MOV R4, #Offset8
 118.927 -	reg[4].I = opcode & 255;
 118.928 -	N_FLAG	 = false;
 118.929 -	Z_FLAG	 = (reg[4].I ? false : true);
 118.930 -	break;
 118.931 -case 0x25:
 118.932 -	// MOV R5, #Offset8
 118.933 -	reg[5].I = opcode & 255;
 118.934 -	N_FLAG	 = false;
 118.935 -	Z_FLAG	 = (reg[5].I ? false : true);
 118.936 -	break;
 118.937 -case 0x26:
 118.938 -	// MOV R6, #Offset8
 118.939 -	reg[6].I = opcode & 255;
 118.940 -	N_FLAG	 = false;
 118.941 -	Z_FLAG	 = (reg[6].I ? false : true);
 118.942 -	break;
 118.943 -case 0x27:
 118.944 -	// MOV R7, #Offset8
 118.945 -	reg[7].I = opcode & 255;
 118.946 -	N_FLAG	 = false;
 118.947 -	Z_FLAG	 = (reg[7].I ? false : true);
 118.948 -	break;
 118.949 -case 0x28:
 118.950 -	// CMP R0, #Offset8
 118.951 -	CMP_RN_O8(0);
 118.952 -	break;
 118.953 -case 0x29:
 118.954 -	// CMP R1, #Offset8
 118.955 -	CMP_RN_O8(1);
 118.956 -	break;
 118.957 -case 0x2a:
 118.958 -	// CMP R2, #Offset8
 118.959 -	CMP_RN_O8(2);
 118.960 -	break;
 118.961 -case 0x2b:
 118.962 -	// CMP R3, #Offset8
 118.963 -	CMP_RN_O8(3);
 118.964 -	break;
 118.965 -case 0x2c:
 118.966 -	// CMP R4, #Offset8
 118.967 -	CMP_RN_O8(4);
 118.968 -	break;
 118.969 -case 0x2d:
 118.970 -	// CMP R5, #Offset8
 118.971 -	CMP_RN_O8(5);
 118.972 -	break;
 118.973 -case 0x2e:
 118.974 -	// CMP R6, #Offset8
 118.975 -	CMP_RN_O8(6);
 118.976 -	break;
 118.977 -case 0x2f:
 118.978 -	// CMP R7, #Offset8
 118.979 -	CMP_RN_O8(7);
 118.980 -	break;
 118.981 -case 0x30:
 118.982 -	// ADD R0,#Offset8
 118.983 -	ADD_RN_O8(0);
 118.984 -	break;
 118.985 -case 0x31:
 118.986 -	// ADD R1,#Offset8
 118.987 -	ADD_RN_O8(1);
 118.988 -	break;
 118.989 -case 0x32:
 118.990 -	// ADD R2,#Offset8
 118.991 -	ADD_RN_O8(2);
 118.992 -	break;
 118.993 -case 0x33:
 118.994 -	// ADD R3,#Offset8
 118.995 -	ADD_RN_O8(3);
 118.996 -	break;
 118.997 -case 0x34:
 118.998 -	// ADD R4,#Offset8
 118.999 -	ADD_RN_O8(4);
118.1000 -	break;
118.1001 -case 0x35:
118.1002 -	// ADD R5,#Offset8
118.1003 -	ADD_RN_O8(5);
118.1004 -	break;
118.1005 -case 0x36:
118.1006 -	// ADD R6,#Offset8
118.1007 -	ADD_RN_O8(6);
118.1008 -	break;
118.1009 -case 0x37:
118.1010 -	// ADD R7,#Offset8
118.1011 -	ADD_RN_O8(7);
118.1012 -	break;
118.1013 -case 0x38:
118.1014 -	// SUB R0,#Offset8
118.1015 -	SUB_RN_O8(0);
118.1016 -	break;
118.1017 -case 0x39:
118.1018 -	// SUB R1,#Offset8
118.1019 -	SUB_RN_O8(1);
118.1020 -	break;
118.1021 -case 0x3a:
118.1022 -	// SUB R2,#Offset8
118.1023 -	SUB_RN_O8(2);
118.1024 -	break;
118.1025 -case 0x3b:
118.1026 -	// SUB R3,#Offset8
118.1027 -	SUB_RN_O8(3);
118.1028 -	break;
118.1029 -case 0x3c:
118.1030 -	// SUB R4,#Offset8
118.1031 -	SUB_RN_O8(4);
118.1032 -	break;
118.1033 -case 0x3d:
118.1034 -	// SUB R5,#Offset8
118.1035 -	SUB_RN_O8(5);
118.1036 -	break;
118.1037 -case 0x3e:
118.1038 -	// SUB R6,#Offset8
118.1039 -	SUB_RN_O8(6);
118.1040 -	break;
118.1041 -case 0x3f:
118.1042 -	// SUB R7,#Offset8
118.1043 -	SUB_RN_O8(7);
118.1044 -	break;
118.1045 -case 0x40:
118.1046 -	switch ((opcode >> 6) & 3)
118.1047 -	{
118.1048 -	case 0x00:
118.1049 -	{
118.1050 -		// AND Rd, Rs
118.1051 -		int dest = opcode & 7;
118.1052 -		reg[dest].I &= reg[(opcode >> 3) & 7].I;
118.1053 -		N_FLAG		 = reg[dest].I & 0x80000000 ? true : false;
118.1054 -		Z_FLAG		 = reg[dest].I ? false : true;
118.1055 -#ifdef BKPT_SUPPORT
118.1056 -#define THUMB_CONSOLE_OUTPUT(a, b) \
118.1057 -	if ((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) { \
118.1058 -		extern void (*dbgOutput)(char *, u32); \
118.1059 -		dbgOutput((a), (b)); \
118.1060 -	}
118.1061 -#else
118.1062 -#define THUMB_CONSOLE_OUTPUT(a, b)
118.1063 -#endif
118.1064 -		THUMB_CONSOLE_OUTPUT(NULL, reg[2].I);
118.1065 -	}
118.1066 -	break;
118.1067 -	case 0x01:
118.1068 -		// EOR Rd, Rs
118.1069 -	{
118.1070 -		int dest = opcode & 7;
118.1071 -		reg[dest].I ^= reg[(opcode >> 3) & 7].I;
118.1072 -		N_FLAG		 = reg[dest].I & 0x80000000 ? true : false;
118.1073 -		Z_FLAG		 = reg[dest].I ? false : true;
118.1074 -	}
118.1075 -	break;
118.1076 -	case 0x02:
118.1077 -		// LSL Rd, Rs
118.1078 -	{
118.1079 -		int dest  = opcode & 7;
118.1080 -		u32 value = reg[(opcode >> 3) & 7].B.B0;
118.1081 -		if (value)
118.1082 -		{
118.1083 -			if (value == 32)
118.1084 -			{
118.1085 -				value  = 0;
118.1086 -				C_FLAG = (reg[dest].I & 1 ? true : false);
118.1087 -			}
118.1088 -			else if (value < 32)
118.1089 -			{
118.1090 -				LSL_RD_RS;
118.1091 -			}
118.1092 -			else
118.1093 -			{
118.1094 -				value  = 0;
118.1095 -				C_FLAG = false;
118.1096 -			}
118.1097 -			reg[dest].I = value;
118.1098 -		}
118.1099 -		N_FLAG = reg[dest].I & 0x80000000 ? true : false;
118.1100 -		Z_FLAG = reg[dest].I ? false : true;
118.1101 -		clockTicks++;
118.1102 -	}
118.1103 -	break;
118.1104 -	case 0x03:
118.1105 -	{
118.1106 -		// LSR Rd, Rs
118.1107 -		int dest  = opcode & 7;
118.1108 -		u32 value = reg[(opcode >> 3) & 7].B.B0;
118.1109 -		if (value)
118.1110 -		{
118.1111 -			if (value == 32)
118.1112 -			{
118.1113 -				value  = 0;
118.1114 -				C_FLAG = (reg[dest].I & 0x80000000 ? true : false);
118.1115 -			}
118.1116 -			else if (value < 32)
118.1117 -			{
118.1118 -				LSR_RD_RS;
118.1119 -			}
118.1120 -			else
118.1121 -			{
118.1122 -				value  = 0;
118.1123 -				C_FLAG = false;
118.1124 -			}
118.1125 -			reg[dest].I = value;
118.1126 -		}
118.1127 -		N_FLAG = reg[dest].I & 0x80000000 ? true : false;
118.1128 -		Z_FLAG = reg[dest].I ? false : true;
118.1129 -		clockTicks++;
118.1130 -	}
118.1131 -	break;
118.1132 -	}
118.1133 -	break;
118.1134 -case 0x41:
118.1135 -	switch ((opcode >> 6) & 3)
118.1136 -	{
118.1137 -	case 0x00:
118.1138 -	{
118.1139 -		// ASR Rd, Rs
118.1140 -		int dest  = opcode & 7;
118.1141 -		u32 value = reg[(opcode >> 3) & 7].B.B0;
118.1142 -		// ASR
118.1143 -		if (value)
118.1144 -		{
118.1145 -			if (value < 32)
118.1146 -			{
118.1147 -				ASR_RD_RS;
118.1148 -				reg[dest].I = value;
118.1149 -			}
118.1150 -			else
118.1151 -			{
118.1152 -				if (reg[dest].I & 0x80000000)
118.1153 -				{
118.1154 -					reg[dest].I = 0xFFFFFFFF;
118.1155 -					C_FLAG		= true;
118.1156 -				}
118.1157 -				else
118.1158 -				{
118.1159 -					reg[dest].I = 0x00000000;
118.1160 -					C_FLAG		= false;
118.1161 -				}
118.1162 -			}
118.1163 -		}
118.1164 -		N_FLAG = reg[dest].I & 0x80000000 ? true : false;
118.1165 -		Z_FLAG = reg[dest].I ? false : true;
118.1166 -		clockTicks++;
118.1167 -	}
118.1168 -	break;
118.1169 -	case 0x01:
118.1170 -	{
118.1171 -		// ADC Rd, Rs
118.1172 -		int dest  = opcode & 0x07;
118.1173 -		u32 value = reg[(opcode >> 3) & 7].I;
118.1174 -		// ADC
118.1175 -		ADC_RD_RS;
118.1176 -	}
118.1177 -	break;
118.1178 -	case 0x02:
118.1179 -	{
118.1180 -		// SBC Rd, Rs
118.1181 -		int dest  = opcode & 0x07;
118.1182 -		u32 value = reg[(opcode >> 3) & 7].I;
118.1183 -
118.1184 -		// SBC
118.1185 -		SBC_RD_RS;
118.1186 -	}
118.1187 -	break;
118.1188 -	case 0x03:
118.1189 -		// ROR Rd, Rs
118.1190 -	{
118.1191 -		int dest  = opcode & 7;
118.1192 -		u32 value = reg[(opcode >> 3) & 7].B.B0;
118.1193 -
118.1194 -		if (value)
118.1195 -		{
118.1196 -			value = value & 0x1f;
118.1197 -			if (value == 0)
118.1198 -			{
118.1199 -				C_FLAG = (reg[dest].I & 0x80000000 ? true : false);
118.1200 -			}
118.1201 -			else
118.1202 -			{
118.1203 -				ROR_RD_RS;
118.1204 -				reg[dest].I = value;
118.1205 -			}
118.1206 -		}
118.1207 -		clockTicks++;
118.1208 -		N_FLAG = reg[dest].I & 0x80000000 ? true : false;
118.1209 -		Z_FLAG = reg[dest].I ? false : true;
118.1210 -	}
118.1211 -	break;
118.1212 -	}
118.1213 -	break;
118.1214 -case 0x42:
118.1215 -	switch ((opcode >> 6) & 3)
118.1216 -	{
118.1217 -	case 0x00:
118.1218 -	{
118.1219 -		// TST Rd, Rs
118.1220 -		u32 value = reg[opcode & 7].I & reg[(opcode >> 3) & 7].I;
118.1221 -		N_FLAG = value & 0x80000000 ? true : false;
118.1222 -		Z_FLAG = value ? false : true;
118.1223 -	}
118.1224 -	break;
118.1225 -	case 0x01:
118.1226 -	{
118.1227 -		// NEG Rd, Rs
118.1228 -		int dest   = opcode & 7;
118.1229 -		int source = (opcode >> 3) & 7;
118.1230 -		NEG_RD_RS;
118.1231 -	}
118.1232 -	break;
118.1233 -	case 0x02:
118.1234 -	{
118.1235 -		// CMP Rd, Rs
118.1236 -		int dest  = opcode & 7;
118.1237 -		u32 value = reg[(opcode >> 3) & 7].I;
118.1238 -		CMP_RD_RS;
118.1239 -	}
118.1240 -	break;
118.1241 -	case 0x03:
118.1242 -	{
118.1243 -		// CMN Rd, Rs
118.1244 -		int dest  = opcode & 7;
118.1245 -		u32 value = reg[(opcode >> 3) & 7].I;
118.1246 -		// CMN
118.1247 -		CMN_RD_RS;
118.1248 -	}
118.1249 -	break;
118.1250 -	}
118.1251 -	break;
118.1252 -case 0x43:
118.1253 -	switch ((opcode >> 6) & 3)
118.1254 -	{
118.1255 -	case 0x00:
118.1256 -	{
118.1257 -		// ORR Rd, Rs
118.1258 -		int dest = opcode & 7;
118.1259 -		reg[dest].I |= reg[(opcode >> 3) & 7].I;
118.1260 -		Z_FLAG		 = reg[dest].I ? false : true;
118.1261 -		N_FLAG		 = reg[dest].I & 0x80000000 ? true : false;
118.1262 -	}
118.1263 -	break;
118.1264 -	case 0x01:
118.1265 -	{
118.1266 -		// MUL Rd, Rs
118.1267 -		int dest = opcode & 7;
118.1268 -		u32 rm	 = reg[(opcode >> 3) & 7].I;
118.1269 -		reg[dest].I = reg[dest].I * rm;
118.1270 -		if (((s32)rm) < 0)
118.1271 -			rm = ~rm;
118.1272 -		if ((rm & 0xFFFFFF00) == 0)
118.1273 -			clockTicks += 1;
118.1274 -		else if ((rm & 0xFFFF0000) == 0)
118.1275 -			clockTicks += 2;
118.1276 -		else if ((rm & 0xFF000000) == 0)
118.1277 -			clockTicks += 3;
118.1278 -		else
118.1279 -			clockTicks += 4;
118.1280 -		Z_FLAG = reg[dest].I ? false : true;
118.1281 -		N_FLAG = reg[dest].I & 0x80000000 ? true : false;
118.1282 -	}
118.1283 -	break;
118.1284 -	case 0x02:
118.1285 -	{
118.1286 -		// BIC Rd, Rs
118.1287 -		int dest = opcode & 7;
118.1288 -		reg[dest].I &= (~reg[(opcode >> 3) & 7].I);
118.1289 -		Z_FLAG		 = reg[dest].I ? false : true;
118.1290 -		N_FLAG		 = reg[dest].I & 0x80000000 ? true : false;
118.1291 -	}
118.1292 -	break;
118.1293 -	case 0x03:
118.1294 -	{
118.1295 -		// MVN Rd, Rs
118.1296 -		int dest = opcode & 7;
118.1297 -		reg[dest].I = ~reg[(opcode >> 3) & 7].I;
118.1298 -		Z_FLAG		= reg[dest].I ? false : true;
118.1299 -		N_FLAG		= reg[dest].I & 0x80000000 ? true : false;
118.1300 -	}
118.1301 -	break;
118.1302 -	}
118.1303 -	break;
118.1304 -case 0x44:
118.1305 -{
118.1306 -	int dest = opcode & 7;
118.1307 -	int base = (opcode >> 3) & 7;
118.1308 -	switch ((opcode >> 6) & 3)
118.1309 -	{
118.1310 -	default:
118.1311 -		goto unknown_thumb;
118.1312 -	case 1:
118.1313 -		// ADD Rd, Hs
118.1314 -		reg[dest].I += reg[base + 8].I;
118.1315 -		break;
118.1316 -	case 2:
118.1317 -		// ADD Hd, Rs
118.1318 -		reg[dest + 8].I += reg[base].I;
118.1319 -		if (dest == 7)
118.1320 -		{
118.1321 -			reg[15].I &= 0xFFFFFFFE;
118.1322 -			armNextPC  = reg[15].I;
118.1323 -			reg[15].I += 2;
118.1324 -			clockTicks++;
118.1325 -		}
118.1326 -		break;
118.1327 -	case 3:
118.1328 -		// ADD Hd, Hs
118.1329 -		reg[dest + 8].I += reg[base + 8].I;
118.1330 -		if (dest == 7)
118.1331 -		{
118.1332 -			reg[15].I &= 0xFFFFFFFE;
118.1333 -			armNextPC  = reg[15].I;
118.1334 -			reg[15].I += 2;
118.1335 -			clockTicks++;
118.1336 -		}
118.1337 -		break;
118.1338 -	}
118.1339 -}
118.1340 -break;
118.1341 -case 0x45:
118.1342 -{
118.1343 -	int dest = opcode & 7;
118.1344 -	int base = (opcode >> 3) & 7;
118.1345 -	u32 value;
118.1346 -	switch ((opcode >> 6) & 3)
118.1347 -	{
118.1348 -	case 0:
118.1349 -		// CMP Rd, Hs
118.1350 -		value = reg[base].I;
118.1351 -		CMP_RD_RS;
118.1352 -		break;
118.1353 -	case 1:
118.1354 -		// CMP Rd, Hs
118.1355 -		value = reg[base + 8].I;
118.1356 -		CMP_RD_RS;
118.1357 -		break;
118.1358 -	case 2:
118.1359 -		// CMP Hd, Rs
118.1360 -		value = reg[base].I;
118.1361 -		dest += 8;
118.1362 -		CMP_RD_RS;
118.1363 -		break;
118.1364 -	case 3:
118.1365 -		// CMP Hd, Hs
118.1366 -		value = reg[base + 8].I;
118.1367 -		dest += 8;
118.1368 -		CMP_RD_RS;
118.1369 -		break;
118.1370 -	}
118.1371 -}
118.1372 -break;
118.1373 -case 0x46:
118.1374 -{
118.1375 -	int dest = opcode & 7;
118.1376 -	int base = (opcode >> 3) & 7;
118.1377 -	switch ((opcode >> 6) & 3)
118.1378 -	{
118.1379 -	case 0:
118.1380 -		// this form should not be used...
118.1381 -		// MOV Rd, Rs
118.1382 -		reg[dest].I = reg[base].I;
118.1383 -		break;
118.1384 -	case 1:
118.1385 -		// MOV Rd, Hs
118.1386 -		reg[dest].I = reg[base + 8].I;
118.1387 -		break;
118.1388 -	case 2:
118.1389 -		// MOV Hd, Rs
118.1390 -		reg[dest + 8].I = reg[base].I;
118.1391 -		if (dest == 7)
118.1392 -		{
118.1393 -			reg[15].I &= 0xFFFFFFFE;
118.1394 -			armNextPC  = reg[15].I;
118.1395 -			reg[15].I += 2;
118.1396 -			clockTicks++;
118.1397 -		}
118.1398 -		break;
118.1399 -	case 3:
118.1400 -		// MOV Hd, Hs
118.1401 -		reg[dest + 8].I = reg[base + 8].I;
118.1402 -		if (dest == 7)
118.1403 -		{
118.1404 -			reg[15].I &= 0xFFFFFFFE;
118.1405 -			armNextPC  = reg[15].I;
118.1406 -			reg[15].I += 2;
118.1407 -			clockTicks++;
118.1408 -		}
118.1409 -		break;
118.1410 -	}
118.1411 -}
118.1412 -break;
118.1413 -case 0x47:
118.1414 -{
118.1415 -	int base = (opcode >> 3) & 7;
118.1416 -	switch ((opcode >> 6) & 3)
118.1417 -	{
118.1418 -	case 0:
118.1419 -		// BX Rs
118.1420 -		reg[15].I = (reg[base].I) & 0xFFFFFFFE;
118.1421 -		if (reg[base].I & 1)
118.1422 -		{
118.1423 -			armState   = false;
118.1424 -			armNextPC  = reg[15].I;
118.1425 -			reg[15].I += 2;
118.1426 -		}
118.1427 -		else
118.1428 -		{
118.1429 -			armState   = true;
118.1430 -			reg[15].I &= 0xFFFFFFFC;
118.1431 -			armNextPC  = reg[15].I;
118.1432 -			reg[15].I += 4;
118.1433 -		}
118.1434 -		break;
118.1435 -	case 1:
118.1436 -		// BX Hs
118.1437 -		reg[15].I = (reg[8 + base].I) & 0xFFFFFFFE;
118.1438 -		if (reg[8 + base].I & 1)
118.1439 -		{
118.1440 -			armState   = false;
118.1441 -			armNextPC  = reg[15].I;
118.1442 -			reg[15].I += 2;
118.1443 -		}
118.1444 -		else
118.1445 -		{
118.1446 -			armState   = true;
118.1447 -			reg[15].I &= 0xFFFFFFFC;
118.1448 -			armNextPC  = reg[15].I;
118.1449 -			reg[15].I += 4;
118.1450 -		}
118.1451 -		break;
118.1452 -	default:
118.1453 -		goto unknown_thumb;
118.1454 -	}
118.1455 -}
118.1456 -break;
118.1457 -case 0x48:
118.1458 -	// LDR R0,[PC, #Imm]
118.1459 -{
118.1460 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1461 -	reg[0].I	= CPUReadMemoryQuick(address);
118.1462 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1463 -}
118.1464 -break;
118.1465 -case 0x49:
118.1466 -	// LDR R1,[PC, #Imm]
118.1467 -{
118.1468 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1469 -	reg[1].I	= CPUReadMemoryQuick(address);
118.1470 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1471 -}
118.1472 -break;
118.1473 -case 0x4a:
118.1474 -	// LDR R2,[PC, #Imm]
118.1475 -{
118.1476 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1477 -	reg[2].I	= CPUReadMemoryQuick(address);
118.1478 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1479 -}
118.1480 -break;
118.1481 -case 0x4b:
118.1482 -	// LDR R3,[PC, #Imm]
118.1483 -{
118.1484 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1485 -	reg[3].I	= CPUReadMemoryQuick(address);
118.1486 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1487 -}
118.1488 -break;
118.1489 -case 0x4c:
118.1490 -	// LDR R4,[PC, #Imm]
118.1491 -{
118.1492 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1493 -	reg[4].I	= CPUReadMemoryQuick(address);
118.1494 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1495 -}
118.1496 -break;
118.1497 -case 0x4d:
118.1498 -	// LDR R5,[PC, #Imm]
118.1499 -{
118.1500 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1501 -	reg[5].I	= CPUReadMemoryQuick(address);
118.1502 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1503 -}
118.1504 -break;
118.1505 -case 0x4e:
118.1506 -	// LDR R6,[PC, #Imm]
118.1507 -{
118.1508 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1509 -	reg[6].I	= CPUReadMemoryQuick(address);
118.1510 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1511 -}
118.1512 -break;
118.1513 -case 0x4f:
118.1514 -	// LDR R7,[PC, #Imm]
118.1515 -{
118.1516 -	u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
118.1517 -	reg[7].I	= CPUReadMemoryQuick(address);
118.1518 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1519 -}
118.1520 -break;
118.1521 -case 0x50:
118.1522 -case 0x51:
118.1523 -	// STR Rd, [Rs, Rn]
118.1524 -{
118.1525 -	u32
118.1526 -	    address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1527 -	CPUWriteMemory(address,
118.1528 -	               reg[opcode & 7].I);
118.1529 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1530 -}
118.1531 -break;
118.1532 -case 0x52:
118.1533 -case 0x53:
118.1534 -	// STRH Rd, [Rs, Rn]
118.1535 -{
118.1536 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1537 -	CPUWriteHalfWord(address,
118.1538 -	                 reg[opcode & 7].W.W0);
118.1539 -	clockTicks += CPUUpdateTicksAccess16(address);
118.1540 -}
118.1541 -break;
118.1542 -case 0x54:
118.1543 -case 0x55:
118.1544 -	// STRB Rd, [Rs, Rn]
118.1545 -{
118.1546 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1547 -	CPUWriteByte(address,
118.1548 -	             reg[opcode & 7].B.B0);
118.1549 -	clockTicks += CPUUpdateTicksAccess16(address);
118.1550 -}
118.1551 -break;
118.1552 -case 0x56:
118.1553 -case 0x57:
118.1554 -	// LDSB Rd, [Rs, Rn]
118.1555 -{
118.1556 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1557 -	reg[opcode & 7].I = (s8)CPUReadByte(address);
118.1558 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1559 -}
118.1560 -break;
118.1561 -case 0x58:
118.1562 -case 0x59:
118.1563 -	// LDR Rd, [Rs, Rn]
118.1564 -{
118.1565 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1566 -	reg[opcode & 7].I = CPUReadMemory(address);
118.1567 -	clockTicks		 += CPUUpdateTicksAccess32(address);
118.1568 -}
118.1569 -break;
118.1570 -case 0x5a:
118.1571 -case 0x5b:
118.1572 -	// LDRH Rd, [Rs, Rn]
118.1573 -{
118.1574 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1575 -	reg[opcode & 7].I = CPUReadHalfWord(address);
118.1576 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1577 -}
118.1578 -break;
118.1579 -case 0x5c:
118.1580 -case 0x5d:
118.1581 -	// LDRB Rd, [Rs, Rn]
118.1582 -{
118.1583 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1584 -	reg[opcode & 7].I = CPUReadByte(address);
118.1585 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1586 -}
118.1587 -break;
118.1588 -case 0x5e:
118.1589 -case 0x5f:
118.1590 -	// LDSH Rd, [Rs, Rn]
118.1591 -{
118.1592 -	u32 address = reg[(opcode >> 3) & 7].I + reg[(opcode >> 6) & 7].I;
118.1593 -	reg[opcode & 7].I = (s16)CPUReadHalfWordSigned(address);
118.1594 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1595 -}
118.1596 -break;
118.1597 -case 0x60:
118.1598 -case 0x61:
118.1599 -case 0x62:
118.1600 -case 0x63:
118.1601 -case 0x64:
118.1602 -case 0x65:
118.1603 -case 0x66:
118.1604 -case 0x67:
118.1605 -	// STR Rd, [Rs, #Imm]
118.1606 -{
118.1607 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31) << 2);
118.1608 -	CPUWriteMemory(address,
118.1609 -	               reg[opcode & 7].I);
118.1610 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1611 -}
118.1612 -break;
118.1613 -case 0x68:
118.1614 -case 0x69:
118.1615 -case 0x6a:
118.1616 -case 0x6b:
118.1617 -case 0x6c:
118.1618 -case 0x6d:
118.1619 -case 0x6e:
118.1620 -case 0x6f:
118.1621 -	// LDR Rd, [Rs, #Imm]
118.1622 -{
118.1623 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31) << 2);
118.1624 -	reg[opcode & 7].I = CPUReadMemory(address);
118.1625 -	clockTicks		 += CPUUpdateTicksAccess32(address);
118.1626 -}
118.1627 -break;
118.1628 -case 0x70:
118.1629 -case 0x71:
118.1630 -case 0x72:
118.1631 -case 0x73:
118.1632 -case 0x74:
118.1633 -case 0x75:
118.1634 -case 0x76:
118.1635 -case 0x77:
118.1636 -	// STRB Rd, [Rs, #Imm]
118.1637 -{
118.1638 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31));
118.1639 -	CPUWriteByte(address,
118.1640 -	             reg[opcode & 7].B.B0);
118.1641 -	clockTicks += CPUUpdateTicksAccess16(address);
118.1642 -}
118.1643 -break;
118.1644 -case 0x78:
118.1645 -case 0x79:
118.1646 -case 0x7a:
118.1647 -case 0x7b:
118.1648 -case 0x7c:
118.1649 -case 0x7d:
118.1650 -case 0x7e:
118.1651 -case 0x7f:
118.1652 -	// LDRB Rd, [Rs, #Imm]
118.1653 -{
118.1654 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31));
118.1655 -	reg[opcode & 7].I = CPUReadByte(address);
118.1656 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1657 -}
118.1658 -break;
118.1659 -case 0x80:
118.1660 -case 0x81:
118.1661 -case 0x82:
118.1662 -case 0x83:
118.1663 -case 0x84:
118.1664 -case 0x85:
118.1665 -case 0x86:
118.1666 -case 0x87:
118.1667 -	// STRH Rd, [Rs, #Imm]
118.1668 -{
118.1669 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31) << 1);
118.1670 -	CPUWriteHalfWord(address,
118.1671 -	                 reg[opcode & 7].W.W0);
118.1672 -	clockTicks += CPUUpdateTicksAccess16(address);
118.1673 -}
118.1674 -break;
118.1675 -case 0x88:
118.1676 -case 0x89:
118.1677 -case 0x8a:
118.1678 -case 0x8b:
118.1679 -case 0x8c:
118.1680 -case 0x8d:
118.1681 -case 0x8e:
118.1682 -case 0x8f:
118.1683 -	// LDRH Rd, [Rs, #Imm]
118.1684 -{
118.1685 -	u32 address = reg[(opcode >> 3) & 7].I + (((opcode >> 6) & 31) << 1);
118.1686 -	reg[opcode & 7].I = CPUReadHalfWord(address);
118.1687 -	clockTicks		 += CPUUpdateTicksAccess16(address);
118.1688 -}
118.1689 -break;
118.1690 -case 0x90:
118.1691 -	// STR R0, [SP, #Imm]
118.1692 -{
118.1693 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1694 -	CPUWriteMemory(address, reg[0].I);
118.1695 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1696 -}
118.1697 -break;
118.1698 -case 0x91:
118.1699 -	// STR R1, [SP, #Imm]
118.1700 -{
118.1701 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1702 -	CPUWriteMemory(address, reg[1].I);
118.1703 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1704 -}
118.1705 -break;
118.1706 -case 0x92:
118.1707 -	// STR R2, [SP, #Imm]
118.1708 -{
118.1709 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1710 -	CPUWriteMemory(address, reg[2].I);
118.1711 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1712 -}
118.1713 -break;
118.1714 -case 0x93:
118.1715 -	// STR R3, [SP, #Imm]
118.1716 -{
118.1717 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1718 -	CPUWriteMemory(address, reg[3].I);
118.1719 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1720 -}
118.1721 -break;
118.1722 -case 0x94:
118.1723 -	// STR R4, [SP, #Imm]
118.1724 -{
118.1725 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1726 -	CPUWriteMemory(address, reg[4].I);
118.1727 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1728 -}
118.1729 -break;
118.1730 -case 0x95:
118.1731 -	// STR R5, [SP, #Imm]
118.1732 -{
118.1733 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1734 -	CPUWriteMemory(address, reg[5].I);
118.1735 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1736 -}
118.1737 -break;
118.1738 -case 0x96:
118.1739 -	// STR R6, [SP, #Imm]
118.1740 -{
118.1741 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1742 -	CPUWriteMemory(address, reg[6].I);
118.1743 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1744 -}
118.1745 -break;
118.1746 -case 0x97:
118.1747 -	// STR R7, [SP, #Imm]
118.1748 -{
118.1749 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1750 -	CPUWriteMemory(address, reg[7].I);
118.1751 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1752 -}
118.1753 -break;
118.1754 -case 0x98:
118.1755 -	// LDR R0, [SP, #Imm]
118.1756 -{
118.1757 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1758 -	reg[0].I	= CPUReadMemoryQuick(address);
118.1759 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1760 -}
118.1761 -break;
118.1762 -case 0x99:
118.1763 -	// LDR R1, [SP, #Imm]
118.1764 -{
118.1765 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1766 -	reg[1].I	= CPUReadMemoryQuick(address);
118.1767 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1768 -}
118.1769 -break;
118.1770 -case 0x9a:
118.1771 -	// LDR R2, [SP, #Imm]
118.1772 -{
118.1773 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1774 -	reg[2].I	= CPUReadMemoryQuick(address);
118.1775 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1776 -}
118.1777 -break;
118.1778 -case 0x9b:
118.1779 -	// LDR R3, [SP, #Imm]
118.1780 -{
118.1781 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1782 -	reg[3].I	= CPUReadMemoryQuick(address);
118.1783 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1784 -}
118.1785 -break;
118.1786 -case 0x9c:
118.1787 -	// LDR R4, [SP, #Imm]
118.1788 -{
118.1789 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1790 -	reg[4].I	= CPUReadMemoryQuick(address);
118.1791 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1792 -}
118.1793 -break;
118.1794 -case 0x9d:
118.1795 -	// LDR R5, [SP, #Imm]
118.1796 -{
118.1797 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1798 -	reg[5].I	= CPUReadMemoryQuick(address);
118.1799 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1800 -}
118.1801 -break;
118.1802 -case 0x9e:
118.1803 -	// LDR R6, [SP, #Imm]
118.1804 -{
118.1805 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1806 -	reg[6].I	= CPUReadMemoryQuick(address);
118.1807 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1808 -}
118.1809 -break;
118.1810 -case 0x9f:
118.1811 -	// LDR R7, [SP, #Imm]
118.1812 -{
118.1813 -	u32 address = reg[13].I + ((opcode & 255) << 2);
118.1814 -	reg[7].I	= CPUReadMemoryQuick(address);
118.1815 -	clockTicks += CPUUpdateTicksAccess32(address);
118.1816 -}
118.1817 -break;
118.1818 -case 0xa0:
118.1819 -	// ADD R0, PC, Imm
118.1820 -	reg[0].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1821 -	break;
118.1822 -case 0xa1:
118.1823 -	// ADD R1, PC, Imm
118.1824 -	reg[1].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1825 -	break;
118.1826 -case 0xa2:
118.1827 -	// ADD R2, PC, Imm
118.1828 -	reg[2].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1829 -	break;
118.1830 -case 0xa3:
118.1831 -	// ADD R3, PC, Imm
118.1832 -	reg[3].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1833 -	break;
118.1834 -case 0xa4:
118.1835 -	// ADD R4, PC, Imm
118.1836 -	reg[4].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1837 -	break;
118.1838 -case 0xa5:
118.1839 -	// ADD R5, PC, Imm
118.1840 -	reg[5].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1841 -	break;
118.1842 -case 0xa6:
118.1843 -	// ADD R6, PC, Imm
118.1844 -	reg[6].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1845 -	break;
118.1846 -case 0xa7:
118.1847 -	// ADD R7, PC, Imm
118.1848 -	reg[7].I = (reg[15].I & 0xFFFFFFFC) + ((opcode & 255) << 2);
118.1849 -	break;
118.1850 -case 0xa8:
118.1851 -	// ADD R0, SP, Imm
118.1852 -	reg[0].I = reg[13].I + ((opcode & 255) << 2);
118.1853 -	break;
118.1854 -case 0xa9:
118.1855 -	// ADD R1, SP, Imm
118.1856 -	reg[1].I = reg[13].I + ((opcode & 255) << 2);
118.1857 -	break;
118.1858 -case 0xaa:
118.1859 -	// ADD R2, SP, Imm
118.1860 -	reg[2].I = reg[13].I + ((opcode & 255) << 2);
118.1861 -	break;
118.1862 -case 0xab:
118.1863 -	// ADD R3, SP, Imm
118.1864 -	reg[3].I = reg[13].I + ((opcode & 255) << 2);
118.1865 -	break;
118.1866 -case 0xac:
118.1867 -	// ADD R4, SP, Imm
118.1868 -	reg[4].I = reg[13].I + ((opcode & 255) << 2);
118.1869 -	break;
118.1870 -case 0xad:
118.1871 -	// ADD R5, SP, Imm
118.1872 -	reg[5].I = reg[13].I + ((opcode & 255) << 2);
118.1873 -	break;
118.1874 -case 0xae:
118.1875 -	// ADD R6, SP, Imm
118.1876 -	reg[6].I = reg[13].I + ((opcode & 255) << 2);
118.1877 -	break;
118.1878 -case 0xaf:
118.1879 -	// ADD R7, SP, Imm
118.1880 -	reg[7].I = reg[13].I + ((opcode & 255) << 2);
118.1881 -	break;
118.1882 -case 0xb0:
118.1883 -{
118.1884 -	// ADD SP, Imm
118.1885 -	int offset = (opcode & 127) << 2;
118.1886 -	if (opcode & 0x80)
118.1887 -		offset = -offset;
118.1888 -	reg[13].I += offset;
118.1889 -}
118.1890 -break;
118.1891 -#define PUSH_REG(val, r) \
118.1892 -	if (opcode & (val)) { \
118.1893 -		CPUWriteMemory(address, reg[(r)].I); \
118.1894 -		if (offset) \
118.1895 -			clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); \
118.1896 -		else \
118.1897 -			clockTicks += 1 + CPUUpdateTicksAccess32(address); \
118.1898 -		offset	 = 1; \
118.1899 -		address += 4; \
118.1900 -	}
118.1901 -case 0xb4:
118.1902 -	// PUSH {Rlist}
118.1903 -{
118.1904 -	int offset	= 0;
118.1905 -	u32 temp	= reg[13].I - 4 * cpuBitsSet[opcode & 0xff];
118.1906 -	u32 address = temp & 0xFFFFFFFC;
118.1907 -	PUSH_REG(1, 0);
118.1908 -	PUSH_REG(2, 1);
118.1909 -	PUSH_REG(4, 2);
118.1910 -	PUSH_REG(8, 3);
118.1911 -	PUSH_REG(16, 4);
118.1912 -	PUSH_REG(32, 5);
118.1913 -	PUSH_REG(64, 6);
118.1914 -	PUSH_REG(128, 7);
118.1915 -	reg[13].I = temp;
118.1916 -}
118.1917 -break;
118.1918 -case 0xb5:
118.1919 -	// PUSH {Rlist, LR}
118.1920 -{
118.1921 -	int offset	= 0;
118.1922 -	u32 temp	= reg[13].I - 4 - 4 * cpuBitsSet[opcode & 0xff];
118.1923 -	u32 address = temp & 0xFFFFFFFC;
118.1924 -	PUSH_REG(1, 0);
118.1925 -	PUSH_REG(2, 1);
118.1926 -	PUSH_REG(4, 2);
118.1927 -	PUSH_REG(8, 3);
118.1928 -	PUSH_REG(16, 4);
118.1929 -	PUSH_REG(32, 5);
118.1930 -	PUSH_REG(64, 6);
118.1931 -	PUSH_REG(128, 7);
118.1932 -	PUSH_REG(256, 14);
118.1933 -	reg[13].I = temp;
118.1934 -}
118.1935 -break;
118.1936 -#define POP_REG(val, r) \
118.1937 -	if (opcode & (val)) { \
118.1938 -		reg[(r)].I = CPUReadMemory(address); \
118.1939 -		if (offset) \
118.1940 -			clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); \
118.1941 -		else \
118.1942 -			clockTicks += 2 + CPUUpdateTicksAccess32(address); \
118.1943 -		offset	 = 1; \
118.1944 -		address += 4; \
118.1945 -	}
118.1946 -case 0xbc:
118.1947 -	// POP {Rlist}
118.1948 -{
118.1949 -	int offset	= 0;
118.1950 -	u32 address = reg[13].I & 0xFFFFFFFC;
118.1951 -	u32 temp	= reg[13].I + 4 * cpuBitsSet[opcode & 0xFF];
118.1952 -	POP_REG(1, 0);
118.1953 -	POP_REG(2, 1);
118.1954 -	POP_REG(4, 2);
118.1955 -	POP_REG(8, 3);
118.1956 -	POP_REG(16, 4);
118.1957 -	POP_REG(32, 5);
118.1958 -	POP_REG(64, 6);
118.1959 -	POP_REG(128, 7);
118.1960 -	reg[13].I = temp;
118.1961 -}
118.1962 -break;
118.1963 -case 0xbd:
118.1964 -	// POP {Rlist, PC}
118.1965 -{
118.1966 -	int offset	= 0;
118.1967 -	u32 address = reg[13].I & 0xFFFFFFFC;
118.1968 -	u32 temp	= reg[13].I + 4 + 4 * cpuBitsSet[opcode & 0xFF];
118.1969 -	POP_REG(1, 0);
118.1970 -	POP_REG(2, 1);
118.1971 -	POP_REG(4, 2);
118.1972 -	POP_REG(8, 3);
118.1973 -	POP_REG(16, 4);
118.1974 -	POP_REG(32, 5);
118.1975 -	POP_REG(64, 6);
118.1976 -	POP_REG(128, 7);
118.1977 -	reg[15].I = (CPUReadMemory(address) & 0xFFFFFFFE);
118.1978 -	if (offset)
118.1979 -		clockTicks += CPUUpdateTicksAccessSeq32(address);
118.1980 -	else
118.1981 -		clockTicks += CPUUpdateTicksAccess32(address);
118.1982 -	armNextPC  = reg[15].I;
118.1983 -	reg[15].I += 2;
118.1984 -	reg[13].I  = temp;
118.1985 -}
118.1986 -break;
118.1987 -#define THUMB_STM_REG(val, r, b) \
118.1988 -	if (opcode & (val)) { \
118.1989 -		CPUWriteMemory(address, reg[(r)].I); \
118.1990 -		if (!offset) { \
118.1991 -			reg[(b)].I	= temp; \
118.1992 -			clockTicks += 1 + CPUUpdateTicksAccess32(address); \
118.1993 -		} else \
118.1994 -			clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); \
118.1995 -		offset	 = 1; \
118.1996 -		address += 4; \
118.1997 -	}
118.1998 -case 0xc0:
118.1999 -{
118.2000 -	// STM R0!, {Rlist}
118.2001 -	u32 address = reg[0].I & 0xFFFFFFFC;
118.2002 -	u32 temp	= reg[0].I + 4 * cpuBitsSet[opcode & 0xff];
118.2003 -	int offset	= 0;
118.2004 -	// store
118.2005 -	THUMB_STM_REG(1, 0, 0);
118.2006 -	THUMB_STM_REG(2, 1, 0);
118.2007 -	THUMB_STM_REG(4, 2, 0);
118.2008 -	THUMB_STM_REG(8, 3, 0);
118.2009 -	THUMB_STM_REG(16, 4, 0);
118.2010 -	THUMB_STM_REG(32, 5, 0);
118.2011 -	THUMB_STM_REG(64, 6, 0);
118.2012 -	THUMB_STM_REG(128, 7, 0);
118.2013 -}
118.2014 -break;
118.2015 -case 0xc1:
118.2016 -{
118.2017 -	// STM R1!, {Rlist}
118.2018 -	u32 address = reg[1].I & 0xFFFFFFFC;
118.2019 -	u32 temp	= reg[1].I + 4 * cpuBitsSet[opcode & 0xff];
118.2020 -	int offset	= 0;
118.2021 -	// store
118.2022 -	THUMB_STM_REG(1, 0, 1);
118.2023 -	THUMB_STM_REG(2, 1, 1);
118.2024 -	THUMB_STM_REG(4, 2, 1);
118.2025 -	THUMB_STM_REG(8, 3, 1);
118.2026 -	THUMB_STM_REG(16, 4, 1);
118.2027 -	THUMB_STM_REG(32, 5, 1);
118.2028 -	THUMB_STM_REG(64, 6, 1);
118.2029 -	THUMB_STM_REG(128, 7, 1);
118.2030 -}
118.2031 -break;
118.2032 -case 0xc2:
118.2033 -{
118.2034 -	// STM R2!, {Rlist}
118.2035 -	u32 address = reg[2].I & 0xFFFFFFFC;
118.2036 -	u32 temp	= reg[2].I + 4 * cpuBitsSet[opcode & 0xff];
118.2037 -	int offset	= 0;
118.2038 -	// store
118.2039 -	THUMB_STM_REG(1, 0, 2);
118.2040 -	THUMB_STM_REG(2, 1, 2);
118.2041 -	THUMB_STM_REG(4, 2, 2);
118.2042 -	THUMB_STM_REG(8, 3, 2);
118.2043 -	THUMB_STM_REG(16, 4, 2);
118.2044 -	THUMB_STM_REG(32, 5, 2);
118.2045 -	THUMB_STM_REG(64, 6, 2);
118.2046 -	THUMB_STM_REG(128, 7, 2);
118.2047 -}
118.2048 -break;
118.2049 -case 0xc3:
118.2050 -{
118.2051 -	// STM R3!, {Rlist}
118.2052 -	u32 address = reg[3].I & 0xFFFFFFFC;
118.2053 -	u32 temp	= reg[3].I + 4 * cpuBitsSet[opcode & 0xff];
118.2054 -	int offset	= 0;
118.2055 -	// store
118.2056 -	THUMB_STM_REG(1, 0, 3);
118.2057 -	THUMB_STM_REG(2, 1, 3);
118.2058 -	THUMB_STM_REG(4, 2, 3);
118.2059 -	THUMB_STM_REG(8, 3, 3);
118.2060 -	THUMB_STM_REG(16, 4, 3);
118.2061 -	THUMB_STM_REG(32, 5, 3);
118.2062 -	THUMB_STM_REG(64, 6, 3);
118.2063 -	THUMB_STM_REG(128, 7, 3);
118.2064 -}
118.2065 -break;
118.2066 -case 0xc4:
118.2067 -{
118.2068 -	// STM R4!, {Rlist}
118.2069 -	u32 address = reg[4].I & 0xFFFFFFFC;
118.2070 -	u32 temp	= reg[4].I + 4 * cpuBitsSet[opcode & 0xff];
118.2071 -	int offset	= 0;
118.2072 -	// store
118.2073 -	THUMB_STM_REG(1, 0, 4);
118.2074 -	THUMB_STM_REG(2, 1, 4);
118.2075 -	THUMB_STM_REG(4, 2, 4);
118.2076 -	THUMB_STM_REG(8, 3, 4);
118.2077 -	THUMB_STM_REG(16, 4, 4);
118.2078 -	THUMB_STM_REG(32, 5, 4);
118.2079 -	THUMB_STM_REG(64, 6, 4);
118.2080 -	THUMB_STM_REG(128, 7, 4);
118.2081 -}
118.2082 -break;
118.2083 -case 0xc5:
118.2084 -{
118.2085 -	// STM R5!, {Rlist}
118.2086 -	u32 address = reg[5].I & 0xFFFFFFFC;
118.2087 -	u32 temp	= reg[5].I + 4 * cpuBitsSet[opcode & 0xff];
118.2088 -	int offset	= 0;
118.2089 -	// store
118.2090 -	THUMB_STM_REG(1, 0, 5);
118.2091 -	THUMB_STM_REG(2, 1, 5);
118.2092 -	THUMB_STM_REG(4, 2, 5);
118.2093 -	THUMB_STM_REG(8, 3, 5);
118.2094 -	THUMB_STM_REG(16, 4, 5);
118.2095 -	THUMB_STM_REG(32, 5, 5);
118.2096 -	THUMB_STM_REG(64, 6, 5);
118.2097 -	THUMB_STM_REG(128, 7, 5);
118.2098 -}
118.2099 -break;
118.2100 -case 0xc6:
118.2101 -{
118.2102 -	// STM R6!, {Rlist}
118.2103 -	u32 address = reg[6].I & 0xFFFFFFFC;
118.2104 -	u32 temp	= reg[6].I + 4 * cpuBitsSet[opcode & 0xff];
118.2105 -	int offset	= 0;
118.2106 -	// store
118.2107 -	THUMB_STM_REG(1, 0, 6);
118.2108 -	THUMB_STM_REG(2, 1, 6);
118.2109 -	THUMB_STM_REG(4, 2, 6);
118.2110 -	THUMB_STM_REG(8, 3, 6);
118.2111 -	THUMB_STM_REG(16, 4, 6);
118.2112 -	THUMB_STM_REG(32, 5, 6);
118.2113 -	THUMB_STM_REG(64, 6, 6);
118.2114 -	THUMB_STM_REG(128, 7, 6);
118.2115 -}
118.2116 -break;
118.2117 -case 0xc7:
118.2118 -{
118.2119 -	// STM R7!, {Rlist}
118.2120 -	u32 address = reg[7].I & 0xFFFFFFFC;
118.2121 -	u32 temp	= reg[7].I + 4 * cpuBitsSet[opcode & 0xff];
118.2122 -	int offset	= 0;
118.2123 -	// store
118.2124 -	THUMB_STM_REG(1, 0, 7);
118.2125 -	THUMB_STM_REG(2, 1, 7);
118.2126 -	THUMB_STM_REG(4, 2, 7);
118.2127 -	THUMB_STM_REG(8, 3, 7);
118.2128 -	THUMB_STM_REG(16, 4, 7);
118.2129 -	THUMB_STM_REG(32, 5, 7);
118.2130 -	THUMB_STM_REG(64, 6, 7);
118.2131 -	THUMB_STM_REG(128, 7, 7);
118.2132 -}
118.2133 -break;
118.2134 -#define THUMB_LDM_REG(val, r) \
118.2135 -	if (opcode & (val)) { \
118.2136 -		reg[(r)].I = CPUReadMemory(address); \
118.2137 -		if (offset) \
118.2138 -			clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); \
118.2139 -		else \
118.2140 -			clockTicks += 2 + CPUUpdateTicksAccess32(address); \
118.2141 -		offset	 = 1; \
118.2142 -		address += 4; \
118.2143 -	}
118.2144 -case 0xc8:
118.2145 -{
118.2146 -	// LDM R0!, {Rlist}
118.2147 -	u32 address = reg[0].I & 0xFFFFFFFC;
118.2148 -	u32 temp	= reg[0].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2149 -	int offset	= 0;
118.2150 -	// load
118.2151 -	THUMB_LDM_REG(1, 0);
118.2152 -	THUMB_LDM_REG(2, 1);
118.2153 -	THUMB_LDM_REG(4, 2);
118.2154 -	THUMB_LDM_REG(8, 3);
118.2155 -	THUMB_LDM_REG(16, 4);
118.2156 -	THUMB_LDM_REG(32, 5);
118.2157 -	THUMB_LDM_REG(64, 6);
118.2158 -	THUMB_LDM_REG(128, 7);
118.2159 -	if (!(opcode & 1))
118.2160 -		reg[0].I = temp;
118.2161 -}
118.2162 -break;
118.2163 -case 0xc9:
118.2164 -{
118.2165 -	// LDM R1!, {Rlist}
118.2166 -	u32 address = reg[1].I & 0xFFFFFFFC;
118.2167 -	u32 temp	= reg[1].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2168 -	int offset	= 0;
118.2169 -	// load
118.2170 -	THUMB_LDM_REG(1, 0);
118.2171 -	THUMB_LDM_REG(2, 1);
118.2172 -	THUMB_LDM_REG(4, 2);
118.2173 -	THUMB_LDM_REG(8, 3);
118.2174 -	THUMB_LDM_REG(16, 4);
118.2175 -	THUMB_LDM_REG(32, 5);
118.2176 -	THUMB_LDM_REG(64, 6);
118.2177 -	THUMB_LDM_REG(128, 7);
118.2178 -	if (!(opcode & 2))
118.2179 -		reg[1].I = temp;
118.2180 -}
118.2181 -break;
118.2182 -case 0xca:
118.2183 -{
118.2184 -	// LDM R2!, {Rlist}
118.2185 -	u32 address = reg[2].I & 0xFFFFFFFC;
118.2186 -	u32 temp	= reg[2].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2187 -	int offset	= 0;
118.2188 -	// load
118.2189 -	THUMB_LDM_REG(1, 0);
118.2190 -	THUMB_LDM_REG(2, 1);
118.2191 -	THUMB_LDM_REG(4, 2);
118.2192 -	THUMB_LDM_REG(8, 3);
118.2193 -	THUMB_LDM_REG(16, 4);
118.2194 -	THUMB_LDM_REG(32, 5);
118.2195 -	THUMB_LDM_REG(64, 6);
118.2196 -	THUMB_LDM_REG(128, 7);
118.2197 -	if (!(opcode & 4))
118.2198 -		reg[2].I = temp;
118.2199 -}
118.2200 -break;
118.2201 -case 0xcb:
118.2202 -{
118.2203 -	// LDM R3!, {Rlist}
118.2204 -	u32 address = reg[3].I & 0xFFFFFFFC;
118.2205 -	u32 temp	= reg[3].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2206 -	int offset	= 0;
118.2207 -	// load
118.2208 -	THUMB_LDM_REG(1, 0);
118.2209 -	THUMB_LDM_REG(2, 1);
118.2210 -	THUMB_LDM_REG(4, 2);
118.2211 -	THUMB_LDM_REG(8, 3);
118.2212 -	THUMB_LDM_REG(16, 4);
118.2213 -	THUMB_LDM_REG(32, 5);
118.2214 -	THUMB_LDM_REG(64, 6);
118.2215 -	THUMB_LDM_REG(128, 7);
118.2216 -	if (!(opcode & 8))
118.2217 -		reg[3].I = temp;
118.2218 -}
118.2219 -break;
118.2220 -case 0xcc:
118.2221 -{
118.2222 -	// LDM R4!, {Rlist}
118.2223 -	u32 address = reg[4].I & 0xFFFFFFFC;
118.2224 -	u32 temp	= reg[4].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2225 -	int offset	= 0;
118.2226 -	// load
118.2227 -	THUMB_LDM_REG(1, 0);
118.2228 -	THUMB_LDM_REG(2, 1);
118.2229 -	THUMB_LDM_REG(4, 2);
118.2230 -	THUMB_LDM_REG(8, 3);
118.2231 -	THUMB_LDM_REG(16, 4);
118.2232 -	THUMB_LDM_REG(32, 5);
118.2233 -	THUMB_LDM_REG(64, 6);
118.2234 -	THUMB_LDM_REG(128, 7);
118.2235 -	if (!(opcode & 16))
118.2236 -		reg[4].I = temp;
118.2237 -}
118.2238 -break;
118.2239 -case 0xcd:
118.2240 -{
118.2241 -	// LDM R5!, {Rlist}
118.2242 -	u32 address = reg[5].I & 0xFFFFFFFC;
118.2243 -	u32 temp	= reg[5].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2244 -	int offset	= 0;
118.2245 -	// load
118.2246 -	THUMB_LDM_REG(1, 0);
118.2247 -	THUMB_LDM_REG(2, 1);
118.2248 -	THUMB_LDM_REG(4, 2);
118.2249 -	THUMB_LDM_REG(8, 3);
118.2250 -	THUMB_LDM_REG(16, 4);
118.2251 -	THUMB_LDM_REG(32, 5);
118.2252 -	THUMB_LDM_REG(64, 6);
118.2253 -	THUMB_LDM_REG(128, 7);
118.2254 -	if (!(opcode & 32))
118.2255 -		reg[5].I = temp;
118.2256 -}
118.2257 -break;
118.2258 -case 0xce:
118.2259 -{
118.2260 -	// LDM R6!, {Rlist}
118.2261 -	u32 address = reg[6].I & 0xFFFFFFFC;
118.2262 -	u32 temp	= reg[6].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2263 -	int offset	= 0;
118.2264 -	// load
118.2265 -	THUMB_LDM_REG(1, 0);
118.2266 -	THUMB_LDM_REG(2, 1);
118.2267 -	THUMB_LDM_REG(4, 2);
118.2268 -	THUMB_LDM_REG(8, 3);
118.2269 -	THUMB_LDM_REG(16, 4);
118.2270 -	THUMB_LDM_REG(32, 5);
118.2271 -	THUMB_LDM_REG(64, 6);
118.2272 -	THUMB_LDM_REG(128, 7);
118.2273 -	if (!(opcode & 64))
118.2274 -		reg[6].I = temp;
118.2275 -}
118.2276 -break;
118.2277 -case 0xcf:
118.2278 -{
118.2279 -	// LDM R7!, {Rlist}
118.2280 -	u32 address = reg[7].I & 0xFFFFFFFC;
118.2281 -	u32 temp	= reg[7].I + 4 * cpuBitsSet[opcode & 0xFF];
118.2282 -	int offset	= 0;
118.2283 -	// load
118.2284 -	THUMB_LDM_REG(1, 0);
118.2285 -	THUMB_LDM_REG(2, 1);
118.2286 -	THUMB_LDM_REG(4, 2);
118.2287 -	THUMB_LDM_REG(8, 3);
118.2288 -	THUMB_LDM_REG(16, 4);
118.2289 -	THUMB_LDM_REG(32, 5);
118.2290 -	THUMB_LDM_REG(64, 6);
118.2291 -	THUMB_LDM_REG(128, 7);
118.2292 -	if (!(opcode & 128))
118.2293 -		reg[7].I = temp;
118.2294 -}
118.2295 -break;
118.2296 -case 0xd0:
118.2297 -	// BEQ offset
118.2298 -	if (Z_FLAG)
118.2299 -	{
118.2300 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2301 -		armNextPC  = reg[15].I;
118.2302 -		reg[15].I += 2;
118.2303 -		clockTicks = 3;
118.2304 -	}
118.2305 -	break;
118.2306 -case 0xd1:
118.2307 -	// BNE offset
118.2308 -	if (!Z_FLAG)
118.2309 -	{
118.2310 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2311 -		armNextPC  = reg[15].I;
118.2312 -		reg[15].I += 2;
118.2313 -		clockTicks = 3;
118.2314 -	}
118.2315 -	break;
118.2316 -case 0xd2:
118.2317 -	// BCS offset
118.2318 -	if (C_FLAG)
118.2319 -	{
118.2320 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2321 -		armNextPC  = reg[15].I;
118.2322 -		reg[15].I += 2;
118.2323 -		clockTicks = 3;
118.2324 -	}
118.2325 -	break;
118.2326 -case 0xd3:
118.2327 -	// BCC offset
118.2328 -	if (!C_FLAG)
118.2329 -	{
118.2330 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2331 -		armNextPC  = reg[15].I;
118.2332 -		reg[15].I += 2;
118.2333 -		clockTicks = 3;
118.2334 -	}
118.2335 -	break;
118.2336 -case 0xd4:
118.2337 -	// BMI offset
118.2338 -	if (N_FLAG)
118.2339 -	{
118.2340 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2341 -		armNextPC  = reg[15].I;
118.2342 -		reg[15].I += 2;
118.2343 -		clockTicks = 3;
118.2344 -	}
118.2345 -	break;
118.2346 -case 0xd5:
118.2347 -	// BPL offset
118.2348 -	if (!N_FLAG)
118.2349 -	{
118.2350 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2351 -		armNextPC  = reg[15].I;
118.2352 -		reg[15].I += 2;
118.2353 -		clockTicks = 3;
118.2354 -	}
118.2355 -	break;
118.2356 -case 0xd6:
118.2357 -	// BVS offset
118.2358 -	if (V_FLAG)
118.2359 -	{
118.2360 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2361 -		armNextPC  = reg[15].I;
118.2362 -		reg[15].I += 2;
118.2363 -		clockTicks = 3;
118.2364 -	}
118.2365 -	break;
118.2366 -case 0xd7:
118.2367 -	// BVC offset
118.2368 -	if (!V_FLAG)
118.2369 -	{
118.2370 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2371 -		armNextPC  = reg[15].I;
118.2372 -		reg[15].I += 2;
118.2373 -		clockTicks = 3;
118.2374 -	}
118.2375 -	break;
118.2376 -case 0xd8:
118.2377 -	// BHI offset
118.2378 -	if (C_FLAG && !Z_FLAG)
118.2379 -	{
118.2380 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2381 -		armNextPC  = reg[15].I;
118.2382 -		reg[15].I += 2;
118.2383 -		clockTicks = 3;
118.2384 -	}
118.2385 -	break;
118.2386 -case 0xd9:
118.2387 -	// BLS offset
118.2388 -	if (!C_FLAG || Z_FLAG)
118.2389 -	{
118.2390 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2391 -		armNextPC  = reg[15].I;
118.2392 -		reg[15].I += 2;
118.2393 -		clockTicks = 3;
118.2394 -	}
118.2395 -	break;
118.2396 -case 0xda:
118.2397 -	// BGE offset
118.2398 -	if (N_FLAG == V_FLAG)
118.2399 -	{
118.2400 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2401 -		armNextPC  = reg[15].I;
118.2402 -		reg[15].I += 2;
118.2403 -		clockTicks = 3;
118.2404 -	}
118.2405 -	break;
118.2406 -case 0xdb:
118.2407 -	// BLT offset
118.2408 -	if (N_FLAG != V_FLAG)
118.2409 -	{
118.2410 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2411 -		armNextPC  = reg[15].I;
118.2412 -		reg[15].I += 2;
118.2413 -		clockTicks = 3;
118.2414 -	}
118.2415 -	break;
118.2416 -case 0xdc:
118.2417 -	// BGT offset
118.2418 -	if (!Z_FLAG && (N_FLAG == V_FLAG))
118.2419 -	{
118.2420 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2421 -		armNextPC  = reg[15].I;
118.2422 -		reg[15].I += 2;
118.2423 -		clockTicks = 3;
118.2424 -	}
118.2425 -	break;
118.2426 -case 0xdd:
118.2427 -	// BLE offset
118.2428 -	if (Z_FLAG || (N_FLAG != V_FLAG))
118.2429 -	{
118.2430 -		reg[15].I += ((s8)(opcode & 0xFF)) << 1;
118.2431 -		armNextPC  = reg[15].I;
118.2432 -		reg[15].I += 2;
118.2433 -		clockTicks = 3;
118.2434 -	}
118.2435 -	break;
118.2436 -case 0xdf:
118.2437 -	// SWI #comment
118.2438 -	CPUSoftwareInterrupt(opcode & 0xFF);
118.2439 -	break;
118.2440 -case 0xe0:
118.2441 -case 0xe1:
118.2442 -case 0xe2:
118.2443 -case 0xe3:
118.2444 -case 0xe4:
118.2445 -case 0xe5:
118.2446 -case 0xe6:
118.2447 -case 0xe7:
118.2448 -{
118.2449 -	// B offset
118.2450 -	int offset = (opcode & 0x3FF) << 1;
118.2451 -	if (opcode & 0x0400)
118.2452 -		offset |= 0xFFFFF800;
118.2453 -	reg[15].I += offset;
118.2454 -	armNextPC  = reg[15].I;
118.2455 -	reg[15].I += 2;
118.2456 -}
118.2457 -break;
118.2458 -case 0xf0:
118.2459 -case 0xf1:
118.2460 -case 0xf2:
118.2461 -case 0xf3:
118.2462 -{
118.2463 -	// BLL #offset
118.2464 -	int offset = (opcode & 0x7FF);
118.2465 -	reg[14].I = reg[15].I + (offset << 12);
118.2466 -}
118.2467 -break;
118.2468 -case 0xf4:
118.2469 -case 0xf5:
118.2470 -case 0xf6:
118.2471 -case 0xf7:
118.2472 -{
118.2473 -	// BLL #offset
118.2474 -	int offset = (opcode & 0x7FF);
118.2475 -	reg[14].I = reg[15].I + ((offset << 12) | 0xFF800000);
118.2476 -}
118.2477 -break;
118.2478 -case 0xf8:
118.2479 -case 0xf9:
118.2480 -case 0xfa:
118.2481 -case 0xfb:
118.2482 -case 0xfc:
118.2483 -case 0xfd:
118.2484 -case 0xfe:
118.2485 -case 0xff:
118.2486 -{
118.2487 -	// BLH #offset
118.2488 -	int offset = (opcode & 0x7FF);
118.2489 -	u32 temp   = reg[15].I - 2;
118.2490 -	reg[15].I  = (reg[14].I + (offset << 1)) & 0xFFFFFFFE;
118.2491 -	armNextPC  = reg[15].I;
118.2492 -	reg[15].I += 2;
118.2493 -	reg[14].I  = temp | 1;
118.2494 -}
118.2495 -break;
118.2496 -#ifdef BKPT_SUPPORT
118.2497 -case 0xbe:
118.2498 -	// BKPT #comment
118.2499 -	extern void (*dbgSignal)(int, int);
118.2500 -	reg[15].I -= 2;
118.2501 -	armNextPC -= 2;
118.2502 -	dbgSignal(5, opcode & 255);
118.2503 -	return;
118.2504 -#endif
118.2505 -case 0xb1:
118.2506 -case 0xb2:
118.2507 -case 0xb3:
118.2508 -case 0xb6:
118.2509 -case 0xb7:
118.2510 -case 0xb8:
118.2511 -case 0xb9:
118.2512 -case 0xba:
118.2513 -case 0xbb:
118.2514 -#ifndef BKPT_SUPPORT
118.2515 -case 0xbe:
118.2516 -#endif
118.2517 -case 0xbf:
118.2518 -case 0xde:
118.2519 -default:
118.2520 -unknown_thumb:
118.2521 -#ifdef GBA_LOGGING
118.2522 -	if (systemVerbose & VERBOSE_UNDEFINED)
118.2523 -		log("Undefined THUMB instruction %04x at %08x\n", opcode, armNextPC - 2);
118.2524 -#endif
118.2525 -	CPUUndefinedException();
118.2526 -	break;
118.2527 -}
   119.1 --- a/src/gtk/.deps/gvba-configfile.Po	Sat Mar 03 10:54:39 2012 -0600
   119.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.3 @@ -1,1 +0,0 @@
   119.4 -# dummy
   120.1 --- a/src/gtk/.deps/gvba-filters.Po	Sat Mar 03 10:54:39 2012 -0600
   120.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   120.3 @@ -1,1 +0,0 @@
   120.4 -# dummy
   121.1 --- a/src/gtk/.deps/gvba-input.Po	Sat Mar 03 10:54:39 2012 -0600
   121.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.3 @@ -1,1 +0,0 @@
   121.4 -# dummy
   122.1 --- a/src/gtk/.deps/gvba-joypadconfig.Po	Sat Mar 03 10:54:39 2012 -0600
   122.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.3 @@ -1,1 +0,0 @@
   122.4 -# dummy
   123.1 --- a/src/gtk/.deps/gvba-main.Po	Sat Mar 03 10:54:39 2012 -0600
   123.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.3 @@ -1,1 +0,0 @@
   123.4 -# dummy
   124.1 --- a/src/gtk/.deps/gvba-screenarea.Po	Sat Mar 03 10:54:39 2012 -0600
   124.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   124.3 @@ -1,1 +0,0 @@
   124.4 -# dummy
   125.1 --- a/src/gtk/.deps/gvba-system.Po	Sat Mar 03 10:54:39 2012 -0600
   125.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   125.3 @@ -1,1 +0,0 @@
   125.4 -# dummy
   126.1 --- a/src/gtk/.deps/gvba-tools.Po	Sat Mar 03 10:54:39 2012 -0600
   126.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.3 @@ -1,1 +0,0 @@
   126.4 -# dummy
   127.1 --- a/src/gtk/.deps/gvba-window.Po	Sat Mar 03 10:54:39 2012 -0600
   127.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.3 @@ -1,1 +0,0 @@
   127.4 -# dummy
   128.1 --- a/src/gtk/.deps/gvba-windowcallbacks.Po	Sat Mar 03 10:54:39 2012 -0600
   128.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   128.3 @@ -1,1 +0,0 @@
   128.4 -# dummy
   129.1 --- a/src/gtk/Makefile	Sat Mar 03 10:54:39 2012 -0600
   129.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.3 @@ -1,817 +0,0 @@
   129.4 -# Makefile.in generated by automake 1.10.1 from Makefile.am.
   129.5 -# src/gtk/Makefile.  Generated from Makefile.in by configure.
   129.6 -
   129.7 -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
   129.8 -# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
   129.9 -# This Makefile.in is free software; the Free Software Foundation
  129.10 -# gives unlimited permission to copy and/or distribute it,
  129.11 -# with or without modifications, as long as this notice is preserved.
  129.12 -
  129.13 -# This program is distributed in the hope that it will be useful,
  129.14 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  129.15 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  129.16 -# PARTICULAR PURPOSE.
  129.17 -
  129.18 -
  129.19 -
  129.20 -
  129.21 -
  129.22 -
  129.23 -pkgdatadir = $(datadir)/VisualBoyAdvance
  129.24 -pkglibdir = $(libdir)/VisualBoyAdvance
  129.25 -pkgincludedir = $(includedir)/VisualBoyAdvance
  129.26 -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
  129.27 -install_sh_DATA = $(install_sh) -c -m 644
  129.28 -install_sh_PROGRAM = $(install_sh) -c
  129.29 -install_sh_SCRIPT = $(install_sh) -c
  129.30 -INSTALL_HEADER = $(INSTALL_DATA)
  129.31 -transform = $(program_transform_name)
  129.32 -NORMAL_INSTALL = :
  129.33 -PRE_INSTALL = :
  129.34 -POST_INSTALL = :
  129.35 -NORMAL_UNINSTALL = :
  129.36 -PRE_UNINSTALL = :
  129.37 -POST_UNINSTALL = :
  129.38 -build_triplet = x86_64-unknown-linux-gnu
  129.39 -host_triplet = x86_64-unknown-linux-gnu
  129.40 -target_triplet = x86_64-unknown-linux-gnu
  129.41 -bin_PROGRAMS = gvba$(EXEEXT)
  129.42 -subdir = src/gtk
  129.43 -DIST_COMMON = $(dist_pkgdata_DATA) $(srcdir)/Makefile.am \
  129.44 -	$(srcdir)/Makefile.in
  129.45 -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
  129.46 -am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
  129.47 -	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
  129.48 -	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
  129.49 -	$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
  129.50 -	$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
  129.51 -	$(top_srcdir)/configure.in
  129.52 -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
  129.53 -	$(ACLOCAL_M4)
  129.54 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  129.55 -CONFIG_CLEAN_FILES =
  129.56 -LIBRARIES = $(noinst_LIBRARIES)
  129.57 -AR = ar
  129.58 -ARFLAGS = cru
  129.59 -libgvba_a_AR = $(AR) $(ARFLAGS)
  129.60 -libgvba_a_LIBADD =
  129.61 -am_libgvba_a_OBJECTS =
  129.62 -libgvba_a_OBJECTS = $(am_libgvba_a_OBJECTS)
  129.63 -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)"
  129.64 -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
  129.65 -PROGRAMS = $(bin_PROGRAMS)
  129.66 -am_gvba_OBJECTS = gvba-configfile.$(OBJEXT) gvba-filters.$(OBJEXT) \
  129.67 -	gvba-input.$(OBJEXT) gvba-joypadconfig.$(OBJEXT) \
  129.68 -	gvba-main.$(OBJEXT) gvba-screenarea.$(OBJEXT) \
  129.69 -	gvba-system.$(OBJEXT) gvba-tools.$(OBJEXT) \
  129.70 -	gvba-windowcallbacks.$(OBJEXT) gvba-window.$(OBJEXT)
  129.71 -gvba_OBJECTS = $(am_gvba_OBJECTS)
  129.72 -gvba_LINK = $(CXXLD) $(gvba_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
  129.73 -	$(LDFLAGS) -o $@
  129.74 -DEFAULT_INCLUDES = -I.
  129.75 -depcomp = $(SHELL) $(top_srcdir)/depcomp
  129.76 -am__depfiles_maybe = depfiles
  129.77 -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
  129.78 -	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
  129.79 -CXXLD = $(CXX)
  129.80 -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
  129.81 -	-o $@
  129.82 -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
  129.83 -	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  129.84 -CCLD = $(CC)
  129.85 -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
  129.86 -SOURCES = $(libgvba_a_SOURCES) $(gvba_SOURCES)
  129.87 -DIST_SOURCES = $(libgvba_a_SOURCES) $(gvba_SOURCES)
  129.88 -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
  129.89 -	html-recursive info-recursive install-data-recursive \
  129.90 -	install-dvi-recursive install-exec-recursive \
  129.91 -	install-html-recursive install-info-recursive \
  129.92 -	install-pdf-recursive install-ps-recursive install-recursive \
  129.93 -	installcheck-recursive installdirs-recursive pdf-recursive \
  129.94 -	ps-recursive uninstall-recursive
  129.95 -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
  129.96 -am__vpath_adj = case $$p in \
  129.97 -    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
  129.98 -    *) f=$$p;; \
  129.99 -  esac;
 129.100 -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 129.101 -dist_pkgdataDATA_INSTALL = $(INSTALL_DATA)
 129.102 -DATA = $(dist_pkgdata_DATA)
 129.103 -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
 129.104 -  distclean-recursive maintainer-clean-recursive
 129.105 -ETAGS = etags
 129.106 -CTAGS = ctags
 129.107 -DIST_SUBDIRS = $(SUBDIRS)
 129.108 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 129.109 -ACLOCAL = ${SHELL} /home/r/proj/vba/trunk/missing --run aclocal-1.10
 129.110 -AMTAR = ${SHELL} /home/r/proj/vba/trunk/missing --run tar
 129.111 -AUTOCONF = ${SHELL} /home/r/proj/vba/trunk/missing --run autoconf
 129.112 -AUTOHEADER = ${SHELL} /home/r/proj/vba/trunk/missing --run autoheader
 129.113 -AUTOMAKE = ${SHELL} /home/r/proj/vba/trunk/missing --run automake-1.10
 129.114 -AWK = gawk
 129.115 -CC = gcc
 129.116 -CCDEPMODE = depmode=gcc3
 129.117 -CFLAGS = -g -O2
 129.118 -CPP = gcc -E
 129.119 -CPPFLAGS = 
 129.120 -CXX = g++
 129.121 -CXXDEPMODE = depmode=gcc3
 129.122 -CXXFLAGS = -g -O2 -DC_CORE -DPROFILING -DDEV_VERSION
 129.123 -CYGPATH_W = echo
 129.124 -DEFS = -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"VisualBoyAdvance\" -DVERSION=\"1.7.2\" -DYYTEXT_POINTER=1 -DHAVE_LIBZ=1 -DHAVE_LIBPNG=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_NETINET_IN_H=1
 129.125 -DEPDIR = .deps
 129.126 -ECHO_C = 
 129.127 -ECHO_N = -n
 129.128 -ECHO_T = 
 129.129 -EGREP = /bin/grep -E
 129.130 -EXEEXT = 
 129.131 -GETTEXT_PACKAGE = 
 129.132 -GMSGFMT = 
 129.133 -GREP = /bin/grep
 129.134 -GTKMM_CFLAGS = 
 129.135 -GTKMM_CPPFLAGS = 
 129.136 -GTKMM_LIBS = 
 129.137 -INSTALL = /usr/bin/install -c
 129.138 -INSTALL_DATA = ${INSTALL} -m 644
 129.139 -INSTALL_PROGRAM = ${INSTALL}
 129.140 -INSTALL_SCRIPT = ${INSTALL}
 129.141 -INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 129.142 -INTLLIBS = 
 129.143 -LDFLAGS = 
 129.144 -LEX = flex
 129.145 -LEXLIB = -lfl
 129.146 -LEX_OUTPUT_ROOT = lex.yy
 129.147 -LIBICONV = 
 129.148 -LIBINTL = 
 129.149 -LIBOBJS = 
 129.150 -LIBS = -lpthread -lpng -lz 
 129.151 -LTLIBICONV = 
 129.152 -LTLIBINTL = 
 129.153 -LTLIBOBJS = 
 129.154 -MAKEINFO = ${SHELL} /home/r/proj/vba/trunk/missing --run makeinfo
 129.155 -MKDIR_P = /bin/mkdir -p
 129.156 -MKINSTALLDIRS = 
 129.157 -MSGFMT = 
 129.158 -MSGMERGE = 
 129.159 -NASM = /usr/bin/nasm
 129.160 -OBJEXT = o
 129.161 -PACKAGE = VisualBoyAdvance
 129.162 -PACKAGE_BUGREPORT = 
 129.163 -PACKAGE_NAME = 
 129.164 -PACKAGE_STRING = 
 129.165 -PACKAGE_TARNAME = 
 129.166 -PACKAGE_VERSION = 
 129.167 -PATH_SEPARATOR = :
 129.168 -PKG_CONFIG = 
 129.169 -POSUB = 
 129.170 -RANLIB = ranlib
 129.171 -SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
 129.172 -SDL_CONFIG = /usr/bin/sdl-config
 129.173 -SDL_LIBS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
 129.174 -SET_MAKE = 
 129.175 -SHELL = /bin/sh
 129.176 -STRIP = 
 129.177 -USE_NLS = 
 129.178 -VBA_EXTRA = 
 129.179 -VBA_LIBS = ../gba/libgba.a ../gb/libgb.a ../common/libgbcom.a ../filters/libfilter.a ../lua/libgblua.a ../prof/libprof.a
 129.180 -VBA_SRC_EXTRA =  lua prof sdl
 129.181 -VERSION = 1.7.2
 129.182 -XGETTEXT = 
 129.183 -XMKMF = 
 129.184 -YACC = bison -y
 129.185 -YFLAGS = 
 129.186 -abs_builddir = /home/r/proj/vba/trunk/src/gtk
 129.187 -abs_srcdir = /home/r/proj/vba/trunk/src/gtk
 129.188 -abs_top_builddir = /home/r/proj/vba/trunk
 129.189 -abs_top_srcdir = /home/r/proj/vba/trunk
 129.190 -ac_ct_CC = gcc
 129.191 -ac_ct_CXX = g++
 129.192 -am__include = include
 129.193 -am__leading_dot = .
 129.194 -am__quote = 
 129.195 -am__tar = ${AMTAR} chof - "$$tardir"
 129.196 -am__untar = ${AMTAR} xf -
 129.197 -bindir = ${exec_prefix}/bin
 129.198 -build = x86_64-unknown-linux-gnu
 129.199 -build_alias = 
 129.200 -build_cpu = x86_64
 129.201 -build_os = linux-gnu
 129.202 -build_vendor = unknown
 129.203 -builddir = .
 129.204 -datadir = ${datarootdir}
 129.205 -datarootdir = ${prefix}/share
 129.206 -docdir = ${datarootdir}/doc/${PACKAGE}
 129.207 -dvidir = ${docdir}
 129.208 -exec_prefix = ${prefix}
 129.209 -host = x86_64-unknown-linux-gnu
 129.210 -host_alias = 
 129.211 -host_cpu = x86_64
 129.212 -host_os = linux-gnu
 129.213 -host_vendor = unknown
 129.214 -htmldir = ${docdir}
 129.215 -includedir = ${prefix}/include
 129.216 -infodir = ${datarootdir}/info
 129.217 -install_sh = $(SHELL) /home/r/proj/vba/trunk/install-sh
 129.218 -libdir = ${exec_prefix}/lib
 129.219 -libexecdir = ${exec_prefix}/libexec
 129.220 -localedir = ${datarootdir}/locale
 129.221 -localstatedir = ${prefix}/var
 129.222 -mandir = ${datarootdir}/man
 129.223 -mkdir_p = /bin/mkdir -p
 129.224 -oldincludedir = /usr/include
 129.225 -pdfdir = ${docdir}
 129.226 -prefix = /usr/local
 129.227 -program_transform_name = s,x,x,
 129.228 -psdir = ${docdir}
 129.229 -sbindir = ${exec_prefix}/sbin
 129.230 -sharedstatedir = ${prefix}/com
 129.231 -srcdir = .
 129.232 -sysconfdir = ${prefix}/etc
 129.233 -target = x86_64-unknown-linux-gnu
 129.234 -target_alias = 
 129.235 -target_cpu = x86_64
 129.236 -target_os = linux-gnu
 129.237 -target_vendor = unknown
 129.238 -top_builddir = ../..
 129.239 -top_srcdir = ../..
 129.240 -SUBDIRS = images
 129.241 -noinst_LIBRARIES = libgvba.a
 129.242 -gvba_SOURCES = \
 129.243 -	configfile.cpp		\
 129.244 -	configfile.h		\
 129.245 -	filters.cpp		\
 129.246 -	filters.h		\
 129.247 -	input.cpp		\
 129.248 -	input.h			\
 129.249 -	intl.h			\
 129.250 -	joypadconfig.cpp	\
 129.251 -	joypadconfig.h		\
 129.252 -	main.cpp		\
 129.253 -	menuitem.h		\
 129.254 -	screenarea.cpp		\
 129.255 -	screenarea.h		\
 129.256 -	sigccompat.h		\
 129.257 -	system.cpp		\
 129.258 -	tools.cpp		\
 129.259 -	tools.h			\
 129.260 -	windowcallbacks.cpp	\
 129.261 -	window.cpp		\
 129.262 -	window.h
 129.263 -
 129.264 -gvba_LDADD = libgvba.a ../gba/libgba.a ../gb/libgb.a ../common/libgbcom.a ../filters/libfilter.a ../lua/libgblua.a ../prof/libprof.a   -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
 129.265 -gvba_DEPENDENCIES = libgvba.a ../gba/libgba.a ../gb/libgb.a ../common/libgbcom.a ../filters/libfilter.a ../lua/libgblua.a ../prof/libprof.a
 129.266 -gvba_CPPFLAGS = \
 129.267 -	-DPKGDATADIR=\"$(pkgdatadir)\"			\
 129.268 -	-DLOCALEDIR=\"$(datadir)/locale\"		\
 129.269 -	-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\"	\
 129.270 -	$(GTKMM_CPPFLAGS)
 129.271 -
 129.272 -gvba_CXXFLAGS =  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
 129.273 -libgvba_a_SOURCES = \
 129.274 -	../AutoBuild.h		\
 129.275 -	../NLS.h		\
 129.276 -	../Port.h
 129.277 -
 129.278 -libgvba_a_CPPFLAGS = -DSDL
 129.279 -libgvba_a_CXXFLAGS = -fno-exceptions
 129.280 -dist_pkgdata_DATA = vba.glade
 129.281 -all: all-recursive
 129.282 -
 129.283 -.SUFFIXES:
 129.284 -.SUFFIXES: .cpp .o .obj
 129.285 -$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 129.286 -	@for dep in $?; do \
 129.287 -	  case '$(am__configure_deps)' in \
 129.288 -	    *$$dep*) \
 129.289 -	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
 129.290 -		&& exit 0; \
 129.291 -	      exit 1;; \
 129.292 -	  esac; \
 129.293 -	done; \
 129.294 -	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gtk/Makefile'; \
 129.295 -	cd $(top_srcdir) && \
 129.296 -	  $(AUTOMAKE) --gnu  src/gtk/Makefile
 129.297 -.PRECIOUS: Makefile
 129.298 -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 129.299 -	@case '$?' in \
 129.300 -	  *config.status*) \
 129.301 -	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 129.302 -	  *) \
 129.303 -	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 129.304 -	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 129.305 -	esac;
 129.306 -
 129.307 -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 129.308 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 129.309 -
 129.310 -$(top_srcdir)/configure:  $(am__configure_deps)
 129.311 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 129.312 -$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 129.313 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 129.314 -
 129.315 -clean-noinstLIBRARIES:
 129.316 -	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
 129.317 -libgvba.a: $(libgvba_a_OBJECTS) $(libgvba_a_DEPENDENCIES) 
 129.318 -	-rm -f libgvba.a
 129.319 -	$(libgvba_a_AR) libgvba.a $(libgvba_a_OBJECTS) $(libgvba_a_LIBADD)
 129.320 -	$(RANLIB) libgvba.a
 129.321 -install-binPROGRAMS: $(bin_PROGRAMS)
 129.322 -	@$(NORMAL_INSTALL)
 129.323 -	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
 129.324 -	@list='$(bin_PROGRAMS)'; for p in $$list; do \
 129.325 -	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
 129.326 -	  if test -f $$p \
 129.327 -	  ; then \
 129.328 -	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
 129.329 -	   echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
 129.330 -	   $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 129.331 -	  else :; fi; \
 129.332 -	done
 129.333 -
 129.334 -uninstall-binPROGRAMS:
 129.335 -	@$(NORMAL_UNINSTALL)
 129.336 -	@list='$(bin_PROGRAMS)'; for p in $$list; do \
 129.337 -	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
 129.338 -	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
 129.339 -	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
 129.340 -	done
 129.341 -
 129.342 -clean-binPROGRAMS:
 129.343 -	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
 129.344 -gvba$(EXEEXT): $(gvba_OBJECTS) $(gvba_DEPENDENCIES) 
 129.345 -	@rm -f gvba$(EXEEXT)
 129.346 -	$(gvba_LINK) $(gvba_OBJECTS) $(gvba_LDADD) $(LIBS)
 129.347 -
 129.348 -mostlyclean-compile:
 129.349 -	-rm -f *.$(OBJEXT)
 129.350 -
 129.351 -distclean-compile:
 129.352 -	-rm -f *.tab.c
 129.353 -
 129.354 -include ./$(DEPDIR)/gvba-configfile.Po
 129.355 -include ./$(DEPDIR)/gvba-filters.Po
 129.356 -include ./$(DEPDIR)/gvba-input.Po
 129.357 -include ./$(DEPDIR)/gvba-joypadconfig.Po
 129.358 -include ./$(DEPDIR)/gvba-main.Po
 129.359 -include ./$(DEPDIR)/gvba-screenarea.Po
 129.360 -include ./$(DEPDIR)/gvba-system.Po
 129.361 -include ./$(DEPDIR)/gvba-tools.Po
 129.362 -include ./$(DEPDIR)/gvba-window.Po
 129.363 -include ./$(DEPDIR)/gvba-windowcallbacks.Po
 129.364 -
 129.365 -.cpp.o:
 129.366 -	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 129.367 -	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 129.368 -#	source='$<' object='$@' libtool=no \
 129.369 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.370 -#	$(CXXCOMPILE) -c -o $@ $<
 129.371 -
 129.372 -.cpp.obj:
 129.373 -	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 129.374 -	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 129.375 -#	source='$<' object='$@' libtool=no \
 129.376 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.377 -#	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 129.378 -
 129.379 -gvba-configfile.o: configfile.cpp
 129.380 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-configfile.o -MD -MP -MF $(DEPDIR)/gvba-configfile.Tpo -c -o gvba-configfile.o `test -f 'configfile.cpp' || echo '$(srcdir)/'`configfile.cpp
 129.381 -	mv -f $(DEPDIR)/gvba-configfile.Tpo $(DEPDIR)/gvba-configfile.Po
 129.382 -#	source='configfile.cpp' object='gvba-configfile.o' libtool=no \
 129.383 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.384 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-configfile.o `test -f 'configfile.cpp' || echo '$(srcdir)/'`configfile.cpp
 129.385 -
 129.386 -gvba-configfile.obj: configfile.cpp
 129.387 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-configfile.obj -MD -MP -MF $(DEPDIR)/gvba-configfile.Tpo -c -o gvba-configfile.obj `if test -f 'configfile.cpp'; then $(CYGPATH_W) 'configfile.cpp'; else $(CYGPATH_W) '$(srcdir)/configfile.cpp'; fi`
 129.388 -	mv -f $(DEPDIR)/gvba-configfile.Tpo $(DEPDIR)/gvba-configfile.Po
 129.389 -#	source='configfile.cpp' object='gvba-configfile.obj' libtool=no \
 129.390 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.391 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-configfile.obj `if test -f 'configfile.cpp'; then $(CYGPATH_W) 'configfile.cpp'; else $(CYGPATH_W) '$(srcdir)/configfile.cpp'; fi`
 129.392 -
 129.393 -gvba-filters.o: filters.cpp
 129.394 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-filters.o -MD -MP -MF $(DEPDIR)/gvba-filters.Tpo -c -o gvba-filters.o `test -f 'filters.cpp' || echo '$(srcdir)/'`filters.cpp
 129.395 -	mv -f $(DEPDIR)/gvba-filters.Tpo $(DEPDIR)/gvba-filters.Po
 129.396 -#	source='filters.cpp' object='gvba-filters.o' libtool=no \
 129.397 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.398 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-filters.o `test -f 'filters.cpp' || echo '$(srcdir)/'`filters.cpp
 129.399 -
 129.400 -gvba-filters.obj: filters.cpp
 129.401 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-filters.obj -MD -MP -MF $(DEPDIR)/gvba-filters.Tpo -c -o gvba-filters.obj `if test -f 'filters.cpp'; then $(CYGPATH_W) 'filters.cpp'; else $(CYGPATH_W) '$(srcdir)/filters.cpp'; fi`
 129.402 -	mv -f $(DEPDIR)/gvba-filters.Tpo $(DEPDIR)/gvba-filters.Po
 129.403 -#	source='filters.cpp' object='gvba-filters.obj' libtool=no \
 129.404 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.405 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-filters.obj `if test -f 'filters.cpp'; then $(CYGPATH_W) 'filters.cpp'; else $(CYGPATH_W) '$(srcdir)/filters.cpp'; fi`
 129.406 -
 129.407 -gvba-input.o: input.cpp
 129.408 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-input.o -MD -MP -MF $(DEPDIR)/gvba-input.Tpo -c -o gvba-input.o `test -f 'input.cpp' || echo '$(srcdir)/'`input.cpp
 129.409 -	mv -f $(DEPDIR)/gvba-input.Tpo $(DEPDIR)/gvba-input.Po
 129.410 -#	source='input.cpp' object='gvba-input.o' libtool=no \
 129.411 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.412 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-input.o `test -f 'input.cpp' || echo '$(srcdir)/'`input.cpp
 129.413 -
 129.414 -gvba-input.obj: input.cpp
 129.415 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-input.obj -MD -MP -MF $(DEPDIR)/gvba-input.Tpo -c -o gvba-input.obj `if test -f 'input.cpp'; then $(CYGPATH_W) 'input.cpp'; else $(CYGPATH_W) '$(srcdir)/input.cpp'; fi`
 129.416 -	mv -f $(DEPDIR)/gvba-input.Tpo $(DEPDIR)/gvba-input.Po
 129.417 -#	source='input.cpp' object='gvba-input.obj' libtool=no \
 129.418 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.419 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-input.obj `if test -f 'input.cpp'; then $(CYGPATH_W) 'input.cpp'; else $(CYGPATH_W) '$(srcdir)/input.cpp'; fi`
 129.420 -
 129.421 -gvba-joypadconfig.o: joypadconfig.cpp
 129.422 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-joypadconfig.o -MD -MP -MF $(DEPDIR)/gvba-joypadconfig.Tpo -c -o gvba-joypadconfig.o `test -f 'joypadconfig.cpp' || echo '$(srcdir)/'`joypadconfig.cpp
 129.423 -	mv -f $(DEPDIR)/gvba-joypadconfig.Tpo $(DEPDIR)/gvba-joypadconfig.Po
 129.424 -#	source='joypadconfig.cpp' object='gvba-joypadconfig.o' libtool=no \
 129.425 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.426 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-joypadconfig.o `test -f 'joypadconfig.cpp' || echo '$(srcdir)/'`joypadconfig.cpp
 129.427 -
 129.428 -gvba-joypadconfig.obj: joypadconfig.cpp
 129.429 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-joypadconfig.obj -MD -MP -MF $(DEPDIR)/gvba-joypadconfig.Tpo -c -o gvba-joypadconfig.obj `if test -f 'joypadconfig.cpp'; then $(CYGPATH_W) 'joypadconfig.cpp'; else $(CYGPATH_W) '$(srcdir)/joypadconfig.cpp'; fi`
 129.430 -	mv -f $(DEPDIR)/gvba-joypadconfig.Tpo $(DEPDIR)/gvba-joypadconfig.Po
 129.431 -#	source='joypadconfig.cpp' object='gvba-joypadconfig.obj' libtool=no \
 129.432 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.433 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-joypadconfig.obj `if test -f 'joypadconfig.cpp'; then $(CYGPATH_W) 'joypadconfig.cpp'; else $(CYGPATH_W) '$(srcdir)/joypadconfig.cpp'; fi`
 129.434 -
 129.435 -gvba-main.o: main.cpp
 129.436 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-main.o -MD -MP -MF $(DEPDIR)/gvba-main.Tpo -c -o gvba-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
 129.437 -	mv -f $(DEPDIR)/gvba-main.Tpo $(DEPDIR)/gvba-main.Po
 129.438 -#	source='main.cpp' object='gvba-main.o' libtool=no \
 129.439 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.440 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
 129.441 -
 129.442 -gvba-main.obj: main.cpp
 129.443 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-main.obj -MD -MP -MF $(DEPDIR)/gvba-main.Tpo -c -o gvba-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi`
 129.444 -	mv -f $(DEPDIR)/gvba-main.Tpo $(DEPDIR)/gvba-main.Po
 129.445 -#	source='main.cpp' object='gvba-main.obj' libtool=no \
 129.446 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.447 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi`
 129.448 -
 129.449 -gvba-screenarea.o: screenarea.cpp
 129.450 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-screenarea.o -MD -MP -MF $(DEPDIR)/gvba-screenarea.Tpo -c -o gvba-screenarea.o `test -f 'screenarea.cpp' || echo '$(srcdir)/'`screenarea.cpp
 129.451 -	mv -f $(DEPDIR)/gvba-screenarea.Tpo $(DEPDIR)/gvba-screenarea.Po
 129.452 -#	source='screenarea.cpp' object='gvba-screenarea.o' libtool=no \
 129.453 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.454 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-screenarea.o `test -f 'screenarea.cpp' || echo '$(srcdir)/'`screenarea.cpp
 129.455 -
 129.456 -gvba-screenarea.obj: screenarea.cpp
 129.457 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-screenarea.obj -MD -MP -MF $(DEPDIR)/gvba-screenarea.Tpo -c -o gvba-screenarea.obj `if test -f 'screenarea.cpp'; then $(CYGPATH_W) 'screenarea.cpp'; else $(CYGPATH_W) '$(srcdir)/screenarea.cpp'; fi`
 129.458 -	mv -f $(DEPDIR)/gvba-screenarea.Tpo $(DEPDIR)/gvba-screenarea.Po
 129.459 -#	source='screenarea.cpp' object='gvba-screenarea.obj' libtool=no \
 129.460 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.461 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-screenarea.obj `if test -f 'screenarea.cpp'; then $(CYGPATH_W) 'screenarea.cpp'; else $(CYGPATH_W) '$(srcdir)/screenarea.cpp'; fi`
 129.462 -
 129.463 -gvba-system.o: system.cpp
 129.464 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-system.o -MD -MP -MF $(DEPDIR)/gvba-system.Tpo -c -o gvba-system.o `test -f 'system.cpp' || echo '$(srcdir)/'`system.cpp
 129.465 -	mv -f $(DEPDIR)/gvba-system.Tpo $(DEPDIR)/gvba-system.Po
 129.466 -#	source='system.cpp' object='gvba-system.o' libtool=no \
 129.467 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.468 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-system.o `test -f 'system.cpp' || echo '$(srcdir)/'`system.cpp
 129.469 -
 129.470 -gvba-system.obj: system.cpp
 129.471 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-system.obj -MD -MP -MF $(DEPDIR)/gvba-system.Tpo -c -o gvba-system.obj `if test -f 'system.cpp'; then $(CYGPATH_W) 'system.cpp'; else $(CYGPATH_W) '$(srcdir)/system.cpp'; fi`
 129.472 -	mv -f $(DEPDIR)/gvba-system.Tpo $(DEPDIR)/gvba-system.Po
 129.473 -#	source='system.cpp' object='gvba-system.obj' libtool=no \
 129.474 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.475 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-system.obj `if test -f 'system.cpp'; then $(CYGPATH_W) 'system.cpp'; else $(CYGPATH_W) '$(srcdir)/system.cpp'; fi`
 129.476 -
 129.477 -gvba-tools.o: tools.cpp
 129.478 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-tools.o -MD -MP -MF $(DEPDIR)/gvba-tools.Tpo -c -o gvba-tools.o `test -f 'tools.cpp' || echo '$(srcdir)/'`tools.cpp
 129.479 -	mv -f $(DEPDIR)/gvba-tools.Tpo $(DEPDIR)/gvba-tools.Po
 129.480 -#	source='tools.cpp' object='gvba-tools.o' libtool=no \
 129.481 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.482 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-tools.o `test -f 'tools.cpp' || echo '$(srcdir)/'`tools.cpp
 129.483 -
 129.484 -gvba-tools.obj: tools.cpp
 129.485 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-tools.obj -MD -MP -MF $(DEPDIR)/gvba-tools.Tpo -c -o gvba-tools.obj `if test -f 'tools.cpp'; then $(CYGPATH_W) 'tools.cpp'; else $(CYGPATH_W) '$(srcdir)/tools.cpp'; fi`
 129.486 -	mv -f $(DEPDIR)/gvba-tools.Tpo $(DEPDIR)/gvba-tools.Po
 129.487 -#	source='tools.cpp' object='gvba-tools.obj' libtool=no \
 129.488 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.489 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-tools.obj `if test -f 'tools.cpp'; then $(CYGPATH_W) 'tools.cpp'; else $(CYGPATH_W) '$(srcdir)/tools.cpp'; fi`
 129.490 -
 129.491 -gvba-windowcallbacks.o: windowcallbacks.cpp
 129.492 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-windowcallbacks.o -MD -MP -MF $(DEPDIR)/gvba-windowcallbacks.Tpo -c -o gvba-windowcallbacks.o `test -f 'windowcallbacks.cpp' || echo '$(srcdir)/'`windowcallbacks.cpp
 129.493 -	mv -f $(DEPDIR)/gvba-windowcallbacks.Tpo $(DEPDIR)/gvba-windowcallbacks.Po
 129.494 -#	source='windowcallbacks.cpp' object='gvba-windowcallbacks.o' libtool=no \
 129.495 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.496 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-windowcallbacks.o `test -f 'windowcallbacks.cpp' || echo '$(srcdir)/'`windowcallbacks.cpp
 129.497 -
 129.498 -gvba-windowcallbacks.obj: windowcallbacks.cpp
 129.499 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-windowcallbacks.obj -MD -MP -MF $(DEPDIR)/gvba-windowcallbacks.Tpo -c -o gvba-windowcallbacks.obj `if test -f 'windowcallbacks.cpp'; then $(CYGPATH_W) 'windowcallbacks.cpp'; else $(CYGPATH_W) '$(srcdir)/windowcallbacks.cpp'; fi`
 129.500 -	mv -f $(DEPDIR)/gvba-windowcallbacks.Tpo $(DEPDIR)/gvba-windowcallbacks.Po
 129.501 -#	source='windowcallbacks.cpp' object='gvba-windowcallbacks.obj' libtool=no \
 129.502 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.503 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-windowcallbacks.obj `if test -f 'windowcallbacks.cpp'; then $(CYGPATH_W) 'windowcallbacks.cpp'; else $(CYGPATH_W) '$(srcdir)/windowcallbacks.cpp'; fi`
 129.504 -
 129.505 -gvba-window.o: window.cpp
 129.506 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-window.o -MD -MP -MF $(DEPDIR)/gvba-window.Tpo -c -o gvba-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp
 129.507 -	mv -f $(DEPDIR)/gvba-window.Tpo $(DEPDIR)/gvba-window.Po
 129.508 -#	source='window.cpp' object='gvba-window.o' libtool=no \
 129.509 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.510 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp
 129.511 -
 129.512 -gvba-window.obj: window.cpp
 129.513 -	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-window.obj -MD -MP -MF $(DEPDIR)/gvba-window.Tpo -c -o gvba-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi`
 129.514 -	mv -f $(DEPDIR)/gvba-window.Tpo $(DEPDIR)/gvba-window.Po
 129.515 -#	source='window.cpp' object='gvba-window.obj' libtool=no \
 129.516 -#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 129.517 -#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi`
 129.518 -install-dist_pkgdataDATA: $(dist_pkgdata_DATA)
 129.519 -	@$(NORMAL_INSTALL)
 129.520 -	test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
 129.521 -	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
 129.522 -	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 129.523 -	  f=$(am__strip_dir) \
 129.524 -	  echo " $(dist_pkgdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \
 129.525 -	  $(dist_pkgdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \
 129.526 -	done
 129.527 -
 129.528 -uninstall-dist_pkgdataDATA:
 129.529 -	@$(NORMAL_UNINSTALL)
 129.530 -	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
 129.531 -	  f=$(am__strip_dir) \
 129.532 -	  echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \
 129.533 -	  rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \
 129.534 -	done
 129.535 -
 129.536 -# This directory's subdirectories are mostly independent; you can cd
 129.537 -# into them and run `make' without going through this Makefile.
 129.538 -# To change the values of `make' variables: instead of editing Makefiles,
 129.539 -# (1) if the variable is set in `config.status', edit `config.status'
 129.540 -#     (which will cause the Makefiles to be regenerated when you run `make');
 129.541 -# (2) otherwise, pass the desired values on the `make' command line.
 129.542 -$(RECURSIVE_TARGETS):
 129.543 -	@failcom='exit 1'; \
 129.544 -	for f in x $$MAKEFLAGS; do \
 129.545 -	  case $$f in \
 129.546 -	    *=* | --[!k]*);; \
 129.547 -	    *k*) failcom='fail=yes';; \
 129.548 -	  esac; \
 129.549 -	done; \
 129.550 -	dot_seen=no; \
 129.551 -	target=`echo $@ | sed s/-recursive//`; \
 129.552 -	list='$(SUBDIRS)'; for subdir in $$list; do \
 129.553 -	  echo "Making $$target in $$subdir"; \
 129.554 -	  if test "$$subdir" = "."; then \
 129.555 -	    dot_seen=yes; \
 129.556 -	    local_target="$$target-am"; \
 129.557 -	  else \
 129.558 -	    local_target="$$target"; \
 129.559 -	  fi; \
 129.560 -	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 129.561 -	  || eval $$failcom; \
 129.562 -	done; \
 129.563 -	if test "$$dot_seen" = "no"; then \
 129.564 -	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 129.565 -	fi; test -z "$$fail"
 129.566 -
 129.567 -$(RECURSIVE_CLEAN_TARGETS):
 129.568 -	@failcom='exit 1'; \
 129.569 -	for f in x $$MAKEFLAGS; do \
 129.570 -	  case $$f in \
 129.571 -	    *=* | --[!k]*);; \
 129.572 -	    *k*) failcom='fail=yes';; \
 129.573 -	  esac; \
 129.574 -	done; \
 129.575 -	dot_seen=no; \
 129.576 -	case "$@" in \
 129.577 -	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
 129.578 -	  *) list='$(SUBDIRS)' ;; \
 129.579 -	esac; \
 129.580 -	rev=''; for subdir in $$list; do \
 129.581 -	  if test "$$subdir" = "."; then :; else \
 129.582 -	    rev="$$subdir $$rev"; \
 129.583 -	  fi; \
 129.584 -	done; \
 129.585 -	rev="$$rev ."; \
 129.586 -	target=`echo $@ | sed s/-recursive//`; \
 129.587 -	for subdir in $$rev; do \
 129.588 -	  echo "Making $$target in $$subdir"; \
 129.589 -	  if test "$$subdir" = "."; then \
 129.590 -	    local_target="$$target-am"; \
 129.591 -	  else \
 129.592 -	    local_target="$$target"; \
 129.593 -	  fi; \
 129.594 -	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 129.595 -	  || eval $$failcom; \
 129.596 -	done && test -z "$$fail"
 129.597 -tags-recursive:
 129.598 -	list='$(SUBDIRS)'; for subdir in $$list; do \
 129.599 -	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 129.600 -	done
 129.601 -ctags-recursive:
 129.602 -	list='$(SUBDIRS)'; for subdir in $$list; do \
 129.603 -	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 129.604 -	done
 129.605 -
 129.606 -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 129.607 -	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 129.608 -	unique=`for i in $$list; do \
 129.609 -	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 129.610 -	  done | \
 129.611 -	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
 129.612 -	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 129.613 -	mkid -fID $$unique
 129.614 -tags: TAGS
 129.615 -
 129.616 -TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 129.617 -		$(TAGS_FILES) $(LISP)
 129.618 -	tags=; \
 129.619 -	here=`pwd`; \
 129.620 -	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 129.621 -	  include_option=--etags-include; \
 129.622 -	  empty_fix=.; \
 129.623 -	else \
 129.624 -	  include_option=--include; \
 129.625 -	  empty_fix=; \
 129.626 -	fi; \
 129.627 -	list='$(SUBDIRS)'; for subdir in $$list; do \
 129.628 -	  if test "$$subdir" = .; then :; else \
 129.629 -	    test ! -f $$subdir/TAGS || \
 129.630 -	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
 129.631 -	  fi; \
 129.632 -	done; \
 129.633 -	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 129.634 -	unique=`for i in $$list; do \
 129.635 -	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 129.636 -	  done | \
 129.637 -	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 129.638 -	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 129.639 -	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 129.640 -	  test -n "$$unique" || unique=$$empty_fix; \
 129.641 -	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
 129.642 -	    $$tags $$unique; \
 129.643 -	fi
 129.644 -ctags: CTAGS
 129.645 -CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 129.646 -		$(TAGS_FILES) $(LISP)
 129.647 -	tags=; \
 129.648 -	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 129.649 -	unique=`for i in $$list; do \
 129.650 -	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 129.651 -	  done | \
 129.652 -	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 129.653 -	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 129.654 -	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 129.655 -	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 129.656 -	     $$tags $$unique
 129.657 -
 129.658 -GTAGS:
 129.659 -	here=`$(am__cd) $(top_builddir) && pwd` \
 129.660 -	  && cd $(top_srcdir) \
 129.661 -	  && gtags -i $(GTAGS_ARGS) $$here
 129.662 -
 129.663 -distclean-tags:
 129.664 -	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 129.665 -
 129.666 -distdir: $(DISTFILES)
 129.667 -	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 129.668 -	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 129.669 -	list='$(DISTFILES)'; \
 129.670 -	  dist_files=`for file in $$list; do echo $$file; done | \
 129.671 -	  sed -e "s|^$$srcdirstrip/||;t" \
 129.672 -	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
 129.673 -	case $$dist_files in \
 129.674 -	  */*) $(MKDIR_P) `echo "$$dist_files" | \
 129.675 -			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
 129.676 -			   sort -u` ;; \
 129.677 -	esac; \
 129.678 -	for file in $$dist_files; do \
 129.679 -	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 129.680 -	  if test -d $$d/$$file; then \
 129.681 -	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
 129.682 -	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
 129.683 -	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
 129.684 -	    fi; \
 129.685 -	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 129.686 -	  else \
 129.687 -	    test -f $(distdir)/$$file \
 129.688 -	    || cp -p $$d/$$file $(distdir)/$$file \
 129.689 -	    || exit 1; \
 129.690 -	  fi; \
 129.691 -	done
 129.692 -	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 129.693 -	  if test "$$subdir" = .; then :; else \
 129.694 -	    test -d "$(distdir)/$$subdir" \
 129.695 -	    || $(MKDIR_P) "$(distdir)/$$subdir" \
 129.696 -	    || exit 1; \
 129.697 -	    distdir=`$(am__cd) $(distdir) && pwd`; \
 129.698 -	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
 129.699 -	    (cd $$subdir && \
 129.700 -	      $(MAKE) $(AM_MAKEFLAGS) \
 129.701 -	        top_distdir="$$top_distdir" \
 129.702 -	        distdir="$$distdir/$$subdir" \
 129.703 -		am__remove_distdir=: \
 129.704 -		am__skip_length_check=: \
 129.705 -	        distdir) \
 129.706 -	      || exit 1; \
 129.707 -	  fi; \
 129.708 -	done
 129.709 -check-am: all-am
 129.710 -check: check-recursive
 129.711 -all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(DATA)
 129.712 -installdirs: installdirs-recursive
 129.713 -installdirs-am:
 129.714 -	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)"; do \
 129.715 -	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 129.716 -	done
 129.717 -install: install-recursive
 129.718 -install-exec: install-exec-recursive
 129.719 -install-data: install-data-recursive
 129.720 -uninstall: uninstall-recursive
 129.721 -
 129.722 -install-am: all-am
 129.723 -	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 129.724 -
 129.725 -installcheck: installcheck-recursive
 129.726 -install-strip:
 129.727 -	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 129.728 -	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
 129.729 -	  `test -z '$(STRIP)' || \
 129.730 -	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 129.731 -mostlyclean-generic:
 129.732 -
 129.733 -clean-generic:
 129.734 -
 129.735 -distclean-generic:
 129.736 -	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 129.737 -
 129.738 -maintainer-clean-generic:
 129.739 -	@echo "This command is intended for maintainers to use"
 129.740 -	@echo "it deletes files that may require special tools to rebuild."
 129.741 -clean: clean-recursive
 129.742 -
 129.743 -clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \
 129.744 -	mostlyclean-am
 129.745 -
 129.746 -distclean: distclean-recursive
 129.747 -	-rm -rf ./$(DEPDIR)
 129.748 -	-rm -f Makefile
 129.749 -distclean-am: clean-am distclean-compile distclean-generic \
 129.750 -	distclean-tags
 129.751 -
 129.752 -dvi: dvi-recursive
 129.753 -
 129.754 -dvi-am:
 129.755 -
 129.756 -html: html-recursive
 129.757 -
 129.758 -info: info-recursive
 129.759 -
 129.760 -info-am:
 129.761 -
 129.762 -install-data-am: install-dist_pkgdataDATA
 129.763 -
 129.764 -install-dvi: install-dvi-recursive
 129.765 -
 129.766 -install-exec-am: install-binPROGRAMS
 129.767 -
 129.768 -install-html: install-html-recursive
 129.769 -
 129.770 -install-info: install-info-recursive
 129.771 -
 129.772 -install-man:
 129.773 -
 129.774 -install-pdf: install-pdf-recursive
 129.775 -
 129.776 -install-ps: install-ps-recursive
 129.777 -
 129.778 -installcheck-am:
 129.779 -
 129.780 -maintainer-clean: maintainer-clean-recursive
 129.781 -	-rm -rf ./$(DEPDIR)
 129.782 -	-rm -f Makefile
 129.783 -maintainer-clean-am: distclean-am maintainer-clean-generic
 129.784 -
 129.785 -mostlyclean: mostlyclean-recursive
 129.786 -
 129.787 -mostlyclean-am: mostlyclean-compile mostlyclean-generic
 129.788 -
 129.789 -pdf: pdf-recursive
 129.790 -
 129.791 -pdf-am:
 129.792 -
 129.793 -ps: ps-recursive
 129.794 -
 129.795 -ps-am:
 129.796 -
 129.797 -uninstall-am: uninstall-binPROGRAMS uninstall-dist_pkgdataDATA
 129.798 -
 129.799 -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
 129.800 -	install-strip
 129.801 -
 129.802 -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 129.803 -	all all-am check check-am clean clean-binPROGRAMS \
 129.804 -	clean-generic clean-noinstLIBRARIES ctags ctags-recursive \
 129.805 -	distclean distclean-compile distclean-generic distclean-tags \
 129.806 -	distdir dvi dvi-am html html-am info info-am install \
 129.807 -	install-am install-binPROGRAMS install-data install-data-am \
 129.808 -	install-dist_pkgdataDATA install-dvi install-dvi-am \
 129.809 -	install-exec install-exec-am install-html install-html-am \
 129.810 -	install-info install-info-am install-man install-pdf \
 129.811 -	install-pdf-am install-ps install-ps-am install-strip \
 129.812 -	installcheck installcheck-am installdirs installdirs-am \
 129.813 -	maintainer-clean maintainer-clean-generic mostlyclean \
 129.814 -	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
 129.815 -	tags tags-recursive uninstall uninstall-am \
 129.816 -	uninstall-binPROGRAMS uninstall-dist_pkgdataDATA
 129.817 -
 129.818 -# Tell versions [3.59,3.63) of GNU make to not export all variables.
 129.819 -# Otherwise a system limit (for SysV at least) may be exceeded.
 129.820 -.NOEXPORT:
   130.1 --- a/src/gtk/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
   130.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.3 @@ -1,50 +0,0 @@
   130.4 -SUBDIRS = images
   130.5 -
   130.6 -bin_PROGRAMS = gvba
   130.7 -
   130.8 -noinst_LIBRARIES = libgvba.a
   130.9 -
  130.10 -gvba_SOURCES = \
  130.11 -	configfile.cpp		\
  130.12 -	configfile.h		\
  130.13 -	filters.cpp		\
  130.14 -	filters.h		\
  130.15 -	input.cpp		\
  130.16 -	input.h			\
  130.17 -	intl.h			\
  130.18 -	joypadconfig.cpp	\
  130.19 -	joypadconfig.h		\
  130.20 -	main.cpp		\
  130.21 -	menuitem.h		\
  130.22 -	screenarea.cpp		\
  130.23 -	screenarea.h		\
  130.24 -	sigccompat.h		\
  130.25 -	system.cpp		\
  130.26 -	tools.cpp		\
  130.27 -	tools.h			\
  130.28 -	windowcallbacks.cpp	\
  130.29 -	window.cpp		\
  130.30 -	window.h
  130.31 -
  130.32 -gvba_LDADD = libgvba.a @VBA_LIBS@ @GTKMM_LIBS@ @LIBINTL@ @SDL_LIBS@
  130.33 -
  130.34 -gvba_DEPENDENCIES = libgvba.a @VBA_LIBS@
  130.35 -
  130.36 -gvba_CPPFLAGS = \
  130.37 -	-DPKGDATADIR=\"$(pkgdatadir)\"			\
  130.38 -	-DLOCALEDIR=\"$(datadir)/locale\"		\
  130.39 -	-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\"	\
  130.40 -	$(GTKMM_CPPFLAGS)
  130.41 -
  130.42 -gvba_CXXFLAGS = @GTKMM_CFLAGS@ @SDL_CFLAGS@
  130.43 -
  130.44 -libgvba_a_SOURCES = \
  130.45 -	../AutoBuild.h		\
  130.46 -	../NLS.h		\
  130.47 -	../Port.h
  130.48 -
  130.49 -libgvba_a_CPPFLAGS = -DSDL
  130.50 -
  130.51 -libgvba_a_CXXFLAGS = -fno-exceptions
  130.52 -
  130.53 -dist_pkgdata_DATA = vba.glade
   131.1 --- a/src/gtk/configfile.cpp	Sat Mar 03 10:54:39 2012 -0600
   131.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.3 @@ -1,262 +0,0 @@
   131.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   131.5 -// Copyright (C) 1999-2003 Forgotten
   131.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   131.7 -
   131.8 -// This program is free software; you can redistribute it and/or modify
   131.9 -// it under the terms of the GNU General Public License as published by
  131.10 -// the Free Software Foundation; either version 2, or(at your option)
  131.11 -// any later version.
  131.12 -//
  131.13 -// This program is distributed in the hope that it will be useful,
  131.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  131.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  131.16 -// GNU General Public License for more details.
  131.17 -//
  131.18 -// You should have received a copy of the GNU General Public License
  131.19 -// along with this program; if not, write to the Free Software Foundation,
  131.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  131.21 -
  131.22 -#include "configfile.h"
  131.23 -
  131.24 -#include <string.h>
  131.25 -#include <glib.h>
  131.26 -
  131.27 -#include <glibmm/fileutils.h>
  131.28 -#include <glibmm/iochannel.h>
  131.29 -
  131.30 -namespace VBA
  131.31 -{
  131.32 -namespace Config
  131.33 -{
  131.34 -
  131.35 -using std::string;
  131.36 -using Glib::IOChannel;
  131.37 -
  131.38 -Line::Line(const string & _rsKey, const string & _rsValue) :
  131.39 -  m_sKey(_rsKey),
  131.40 -  m_sValue(_rsValue)
  131.41 -{
  131.42 -}
  131.43 -
  131.44 -Section::Section(const string & _rsName) :
  131.45 -  m_sName(_rsName)
  131.46 -{
  131.47 -}
  131.48 -
  131.49 -bool Section::bKeyExists(const string & _rsKey)
  131.50 -{
  131.51 -  for (iterator it = begin(); it != end(); it++)
  131.52 -  {
  131.53 -    if (it->m_sKey == _rsKey)
  131.54 -    {
  131.55 -      return true;
  131.56 -    }
  131.57 -  }
  131.58 -  return false;
  131.59 -}
  131.60 -
  131.61 -void Section::vSetKey(const string & _rsKey, const string & _rsValue)
  131.62 -{
  131.63 -  for (iterator it = begin(); it != end(); it++)
  131.64 -  {
  131.65 -    if (it->m_sKey == _rsKey)
  131.66 -    {
  131.67 -      it->m_sValue = _rsValue;
  131.68 -      return;
  131.69 -    }
  131.70 -  }
  131.71 -  push_back(Line(_rsKey, _rsValue));
  131.72 -}
  131.73 -
  131.74 -string Section::sGetKey(const string & _rsKey) const
  131.75 -{
  131.76 -  for (const_iterator it = begin(); it != end(); it++)
  131.77 -  {
  131.78 -    if (it->m_sKey == _rsKey)
  131.79 -    {
  131.80 -      return it->m_sValue;
  131.81 -    }
  131.82 -  }
  131.83 -  throw KeyNotFound(m_sName, _rsKey);
  131.84 -}
  131.85 -
  131.86 -void Section::vRemoveKey(const string & _rsKey)
  131.87 -{
  131.88 -  for (iterator it = begin(); it != end(); it++)
  131.89 -  {
  131.90 -    if (it->m_sKey == _rsKey)
  131.91 -    {
  131.92 -      erase(it);
  131.93 -      return;
  131.94 -    }
  131.95 -  }
  131.96 -}
  131.97 -
  131.98 -File::File()
  131.99 -{
 131.100 -}
 131.101 -
 131.102 -File::File(const string & _rsFile)
 131.103 -{
 131.104 -  vLoad(_rsFile);
 131.105 -}
 131.106 -
 131.107 -File::~File()
 131.108 -{
 131.109 -}
 131.110 -
 131.111 -bool File::bSectionExists(const string & _rsName)
 131.112 -{
 131.113 -  for (iterator it = begin(); it != end(); it++)
 131.114 -  {
 131.115 -    if (it->sGetName() == _rsName)
 131.116 -    {
 131.117 -      return true;
 131.118 -    }
 131.119 -  }
 131.120 -  return false;
 131.121 -}
 131.122 -
 131.123 -Section * File::poAddSection(const string & _rsName)
 131.124 -{
 131.125 -  Section * poSection = NULL;
 131.126 -  for (iterator it = begin(); it != end(); it++)
 131.127 -  {
 131.128 -    if (it->sGetName() == _rsName)
 131.129 -    {
 131.130 -      poSection = &(*it);
 131.131 -    }
 131.132 -  }
 131.133 -  if (poSection == NULL)
 131.134 -  {
 131.135 -    push_back(Section(_rsName));
 131.136 -    poSection = &back();
 131.137 -  }
 131.138 -  return poSection;
 131.139 -}
 131.140 -
 131.141 -Section * File::poGetSection(const string & _rsName)
 131.142 -{
 131.143 -  for (iterator it = begin(); it != end(); it++)
 131.144 -  {
 131.145 -    if (it->sGetName() == _rsName)
 131.146 -    {
 131.147 -      return &(*it);
 131.148 -    }
 131.149 -  }
 131.150 -  throw SectionNotFound(_rsName);
 131.151 -}
 131.152 -
 131.153 -void File::vRemoveSection(const string & _rsName)
 131.154 -{
 131.155 -  for (iterator it = begin(); it != end(); it++)
 131.156 -  {
 131.157 -    if (it->sGetName() == _rsName)
 131.158 -    {
 131.159 -      erase(it);
 131.160 -      return;
 131.161 -    }
 131.162 -  }
 131.163 -}
 131.164 -
 131.165 -void File::vLoad(const string & _rsFile,
 131.166 -                 bool _bAddSection,
 131.167 -                 bool _bAddKey)
 131.168 -{
 131.169 -  string sBuffer = Glib::file_get_contents(_rsFile);
 131.170 -  Section * poSection = NULL;
 131.171 -  char ** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
 131.172 -  char * tmp;
 131.173 -  int i = 0;
 131.174 -  while (lines[i])
 131.175 -  {
 131.176 -    if (lines[i][0] == '[')
 131.177 -    {
 131.178 -      if ((tmp = strchr(lines[i], ']')))
 131.179 -      {
 131.180 -        *tmp = '\0';
 131.181 -        if (_bAddSection)
 131.182 -        {
 131.183 -          poSection = poAddSection(&lines[i][1]);
 131.184 -        }
 131.185 -        else
 131.186 -        {
 131.187 -          try
 131.188 -          {
 131.189 -            poSection = poGetSection(&lines[i][1]);
 131.190 -          }
 131.191 -          catch (...)
 131.192 -          {
 131.193 -            poSection = NULL;
 131.194 -          }
 131.195 -        }
 131.196 -      }
 131.197 -    }
 131.198 -    else if (lines[i][0] != '#' && poSection != NULL)
 131.199 -    {
 131.200 -      if ((tmp = strchr(lines[i], '=')))
 131.201 -      {
 131.202 -        *tmp = '\0';
 131.203 -        tmp++;
 131.204 -        if (_bAddKey || poSection->bKeyExists(lines[i]))
 131.205 -        {
 131.206 -          poSection->vSetKey(lines[i], tmp);
 131.207 -        }
 131.208 -      }
 131.209 -    }
 131.210 -    i++;
 131.211 -  }
 131.212 -  g_strfreev(lines);
 131.213 -}
 131.214 -
 131.215 -void File::vSave(const string & _rsFile)
 131.216 -{
 131.217 -  Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
 131.218 -  poFile->set_encoding("");
 131.219 -
 131.220 -  for (const_iterator poSection = begin();
 131.221 -       poSection != end();
 131.222 -       poSection++)
 131.223 -  {
 131.224 -    string sName = "[" + poSection->sGetName() + "]\n";
 131.225 -    poFile->write(sName);
 131.226 -
 131.227 -    for (Section::const_iterator poLine = poSection->begin();
 131.228 -         poLine != poSection->end();
 131.229 -         poLine++)
 131.230 -    {
 131.231 -      string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
 131.232 -      poFile->write(sLine);
 131.233 -    }
 131.234 -    poFile->write("\n");
 131.235 -  }
 131.236 -}
 131.237 -
 131.238 -void File::vClear()
 131.239 -{
 131.240 -  clear();
 131.241 -}
 131.242 -
 131.243 -std::ostream & operator<<(std::ostream & _roOut, const File & _roFile)
 131.244 -{
 131.245 -  for (File::const_iterator poSection = _roFile.begin();
 131.246 -       poSection != _roFile.end();
 131.247 -       poSection++)
 131.248 -  {
 131.249 -    string sName = "[" + poSection->sGetName() + "]\n";
 131.250 -    _roOut << sName;
 131.251 -
 131.252 -    for (Section::const_iterator poLine = poSection->begin();
 131.253 -         poLine != poSection->end();
 131.254 -         poLine++)
 131.255 -    {
 131.256 -      string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
 131.257 -      _roOut << sLine;
 131.258 -    }
 131.259 -    _roOut << "\n";
 131.260 -  }
 131.261 -  return _roOut;
 131.262 -}
 131.263 -
 131.264 -} // namespace Config
 131.265 -} // namespace VBA
   132.1 --- a/src/gtk/configfile.h	Sat Mar 03 10:54:39 2012 -0600
   132.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   132.3 @@ -1,204 +0,0 @@
   132.4 -// -*- C++ -*-
   132.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   132.6 -// Copyright (C) 1999-2003 Forgotten
   132.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   132.8 -
   132.9 -// This program is free software; you can redistribute it and/or modify
  132.10 -// it under the terms of the GNU General Public License as published by
  132.11 -// the Free Software Foundation; either version 2, or(at your option)
  132.12 -// any later version.
  132.13 -//
  132.14 -// This program is distributed in the hope that it will be useful,
  132.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  132.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  132.17 -// GNU General Public License for more details.
  132.18 -//
  132.19 -// You should have received a copy of the GNU General Public License
  132.20 -// along with this program; if not, write to the Free Software Foundation,
  132.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  132.22 -
  132.23 -#ifndef __VBA_CONFIGFILE_H__
  132.24 -#define __VBA_CONFIGFILE_H__
  132.25 -
  132.26 -#include <list>
  132.27 -#include <string>
  132.28 -#include <sstream>
  132.29 -#include <ostream>
  132.30 -
  132.31 -namespace VBA
  132.32 -{
  132.33 -namespace Config
  132.34 -{
  132.35 -
  132.36 -class NotFound
  132.37 -{
  132.38 -public:
  132.39 -  virtual ~NotFound() {}
  132.40 -
  132.41 -protected:
  132.42 -  NotFound() {}
  132.43 -};
  132.44 -
  132.45 -class SectionNotFound : public NotFound
  132.46 -{
  132.47 -public:
  132.48 -  SectionNotFound(const std::string & _rsName) :
  132.49 -    m_sName(_rsName)
  132.50 -    {
  132.51 -    }
  132.52 -  virtual ~SectionNotFound() {}
  132.53 -
  132.54 -  inline std::string sGetName() const { return m_sName; }
  132.55 -
  132.56 -private:
  132.57 -  std::string m_sName;
  132.58 -};
  132.59 -
  132.60 -class KeyNotFound : public NotFound
  132.61 -{
  132.62 -public:
  132.63 -  KeyNotFound(const std::string & _rsSection, const std::string & _rsKey) :
  132.64 -    m_sSection(_rsSection),
  132.65 -    m_sKey(_rsKey)
  132.66 -    {
  132.67 -    }
  132.68 -  virtual ~KeyNotFound() {}
  132.69 -
  132.70 -  inline std::string sGetSection() const { return m_sSection; }
  132.71 -  inline std::string sGetKey() const { return m_sKey; }
  132.72 -
  132.73 -private:
  132.74 -  std::string m_sSection;
  132.75 -  std::string m_sKey;
  132.76 -};
  132.77 -
  132.78 -class Line
  132.79 -{
  132.80 -public:
  132.81 -  Line(const std::string & _rsKey, const std::string & _rsValue);
  132.82 -
  132.83 -  std::string m_sKey;
  132.84 -  std::string m_sValue;
  132.85 -};
  132.86 -
  132.87 -class Section : private std::list<Line>
  132.88 -{
  132.89 -public:
  132.90 -  explicit Section(const std::string & _rsName);
  132.91 -
  132.92 -  inline std::string sGetName() const { return m_sName; }
  132.93 -
  132.94 -  bool bKeyExists(const std::string & _rsKey);
  132.95 -  void vSetKey(const std::string & _rsKey, const std::string & _rsValue);
  132.96 -  std::string sGetKey(const std::string & _rsKey) const;
  132.97 -  void vRemoveKey(const std::string & _rsKey);
  132.98 -
  132.99 -  template<typename T>
 132.100 -  void vSetKey(const std::string & _rsKey, const T & _rValue);
 132.101 -
 132.102 -  template<typename T>
 132.103 -  T oGetKey(const std::string & _rsKey) const;
 132.104 -
 132.105 -  // read only
 132.106 -  typedef std::list<Line>::const_iterator const_iterator;
 132.107 -  inline const_iterator begin() const
 132.108 -    {
 132.109 -      return std::list<Line>::begin();
 132.110 -    }
 132.111 -  inline const_iterator end() const
 132.112 -    {
 132.113 -      return std::list<Line>::end();
 132.114 -    }
 132.115 -
 132.116 -private:
 132.117 -  inline iterator begin()
 132.118 -    {
 132.119 -      return std::list<Line>::begin();
 132.120 -    }
 132.121 -  inline iterator end()
 132.122 -    {
 132.123 -      return std::list<Line>::end();
 132.124 -    }
 132.125 -
 132.126 -  std::string m_sName;
 132.127 -};
 132.128 -
 132.129 -class File : private std::list<Section>
 132.130 -{
 132.131 -public:
 132.132 -  File();
 132.133 -  File(const std::string & _rsFile);
 132.134 -  virtual ~File();
 132.135 -
 132.136 -  bool bSectionExists(const std::string & _rsName);
 132.137 -  Section * poAddSection(const std::string & _rsName);
 132.138 -  Section * poGetSection(const std::string & _rsName);
 132.139 -  void vRemoveSection(const std::string & _rsName);
 132.140 -  void vLoad(const std::string & _rsFile,
 132.141 -             bool _bAddSection = true,
 132.142 -             bool _bAddKey = true);
 132.143 -  void vSave(const std::string & _rsFile);
 132.144 -  void vClear();
 132.145 -
 132.146 -  // read only
 132.147 -  typedef std::list<Section>::const_iterator const_iterator;
 132.148 -  inline const_iterator begin() const
 132.149 -    {
 132.150 -      return std::list<Section>::begin();
 132.151 -    }
 132.152 -  inline const_iterator end() const
 132.153 -    {
 132.154 -      return std::list<Section>::end();
 132.155 -    }
 132.156 -
 132.157 -private:
 132.158 -  inline iterator begin()
 132.159 -    {
 132.160 -      return std::list<Section>::begin();
 132.161 -    }
 132.162 -  inline iterator end()
 132.163 -    {
 132.164 -      return std::list<Section>::end();
 132.165 -    }
 132.166 -};
 132.167 -
 132.168 -// debug
 132.169 -std::ostream & operator<<(std::ostream & _roOut, const File & _roConfig);
 132.170 -
 132.171 -template<typename T>
 132.172 -void Section::vSetKey(const std::string & _rsKey, const T & _rValue)
 132.173 -{
 132.174 -  std::ostringstream oOut;
 132.175 -  oOut << _rValue;
 132.176 -  for (iterator it = begin(); it != end(); it++)
 132.177 -  {
 132.178 -    if (it->m_sKey == _rsKey)
 132.179 -    {
 132.180 -      it->m_sValue = oOut.str();
 132.181 -      return;
 132.182 -    }
 132.183 -  }
 132.184 -  push_back(Line(_rsKey, oOut.str()));
 132.185 -}
 132.186 -
 132.187 -template<typename T>
 132.188 -T Section::oGetKey(const std::string & _rsKey) const
 132.189 -{
 132.190 -  T oValue;
 132.191 -  for (const_iterator it = begin(); it != end(); it++)
 132.192 -  {
 132.193 -    if (it->m_sKey == _rsKey)
 132.194 -    {
 132.195 -      std::istringstream oIn(it->m_sValue);
 132.196 -      oIn >> oValue;
 132.197 -      return oValue;
 132.198 -    }
 132.199 -  }
 132.200 -  throw KeyNotFound(m_sName, _rsKey);
 132.201 -}
 132.202 -
 132.203 -} // namespace Config
 132.204 -} // namespace VBA
 132.205 -
 132.206 -
 132.207 -#endif // __VBA_CONFIGFILE_H__
   133.1 --- a/src/gtk/filters.cpp	Sat Mar 03 10:54:39 2012 -0600
   133.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   133.3 @@ -1,59 +0,0 @@
   133.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   133.5 -// Copyright (C) 1999-2003 Forgotten
   133.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   133.7 -
   133.8 -// This program is free software; you can redistribute it and/or modify
   133.9 -// it under the terms of the GNU General Public License as published by
  133.10 -// the Free Software Foundation; either version 2, or(at your option)
  133.11 -// any later version.
  133.12 -//
  133.13 -// This program is distributed in the hope that it will be useful,
  133.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  133.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  133.16 -// GNU General Public License for more details.
  133.17 -//
  133.18 -// You should have received a copy of the GNU General Public License
  133.19 -// along with this program; if not, write to the Free Software Foundation,
  133.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  133.21 -
  133.22 -#include "filters.h"
  133.23 -
  133.24 -namespace VBA
  133.25 -{
  133.26 -
  133.27 -static const Filter2x apvFilters2x[][2] =
  133.28 -{
  133.29 -  { NULL,         NULL           },
  133.30 -  { _2xSaI,       _2xSaI32       },
  133.31 -  { Super2xSaI,   Super2xSaI32   },
  133.32 -  { SuperEagle,   SuperEagle32   },
  133.33 -  { Pixelate2x16, Pixelate2x32   },
  133.34 -  { MotionBlur,   MotionBlur32   },
  133.35 -  { AdMame2x,     AdMame2x32     },
  133.36 -  { Simple2x16,   Simple2x32     },
  133.37 -  { Bilinear,     Bilinear32     },
  133.38 -  { BilinearPlus, BilinearPlus32 },
  133.39 -  { Scanlines,    Scanlines32    },
  133.40 -  { ScanlinesTV,  ScanlinesTV32  },
  133.41 -  { hq2x,         hq2x32         },
  133.42 -  { lq2x,         lq2x32         }
  133.43 -};
  133.44 -
  133.45 -static const FilterIB apvFiltersIB[][2] =
  133.46 -{
  133.47 -  { NULL,         NULL           },
  133.48 -  { SmartIB,      SmartIB32      },
  133.49 -  { MotionBlurIB, MotionBlurIB32 }
  133.50 -};
  133.51 -
  133.52 -Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth)
  133.53 -{
  133.54 -  return apvFilters2x[_eFilter2x][_eDepth];
  133.55 -}
  133.56 -
  133.57 -FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
  133.58 -{
  133.59 -  return apvFiltersIB[_eFilterIB][_eDepth];
  133.60 -}
  133.61 -
  133.62 -} // namespace VBA
   134.1 --- a/src/gtk/filters.h	Sat Mar 03 10:54:39 2012 -0600
   134.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   134.3 @@ -1,106 +0,0 @@
   134.4 -// -*- C++ -*-
   134.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   134.6 -// Copyright (C) 1999-2003 Forgotten
   134.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   134.8 -
   134.9 -// This program is free software; you can redistribute it and/or modify
  134.10 -// it under the terms of the GNU General Public License as published by
  134.11 -// the Free Software Foundation; either version 2, or(at your option)
  134.12 -// any later version.
  134.13 -//
  134.14 -// This program is distributed in the hope that it will be useful,
  134.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  134.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  134.17 -// GNU General Public License for more details.
  134.18 -//
  134.19 -// You should have received a copy of the GNU General Public License
  134.20 -// along with this program; if not, write to the Free Software Foundation,
  134.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  134.22 -
  134.23 -#ifndef __VBA_FILTERS_H__
  134.24 -#define __VBA_FILTERS_H__
  134.25 -
  134.26 -#include "../common/System.h"
  134.27 -
  134.28 -int Init_2xSaI(u32);
  134.29 -
  134.30 -void _2xSaI        (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.31 -void _2xSaI32      (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.32 -void Super2xSaI    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.33 -void Super2xSaI32  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.34 -void SuperEagle    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.35 -void SuperEagle32  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.36 -void Pixelate2x16  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.37 -void Pixelate2x32  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.38 -void MotionBlur    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.39 -void MotionBlur32  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.40 -void AdMame2x      (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.41 -void AdMame2x32    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.42 -void Simple2x16    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.43 -void Simple2x32    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.44 -void Bilinear      (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.45 -void Bilinear32    (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.46 -void BilinearPlus  (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.47 -void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int);
  134.48 -void Scanlines     (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.49 -void Scanlines32   (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.50 -void ScanlinesTV   (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.51 -void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.52 -void hq2x          (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.53 -void hq2x32        (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.54 -void lq2x          (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.55 -void lq2x32        (u8 *, u32, u8 *, u8 *, u32, int, int);
  134.56 -
  134.57 -void SmartIB       (u8 *, u32, int, int);
  134.58 -void SmartIB32     (u8 *, u32, int, int);
  134.59 -void MotionBlurIB  (u8 *, u32, int, int);
  134.60 -void MotionBlurIB32(u8 *, u32, int, int);
  134.61 -
  134.62 -namespace VBA
  134.63 -{
  134.64 -
  134.65 -typedef void (*Filter2x)(u8 *, u32, u8 *, u8 *, u32, int, int);
  134.66 -typedef void (*FilterIB)(u8 *, u32, int, int);
  134.67 -
  134.68 -enum EFilter2x
  134.69 -{
  134.70 -  FirstFilter,
  134.71 -  FilterNone = FirstFilter,
  134.72 -  Filter2xSaI,
  134.73 -  FilterSuper2xSaI,
  134.74 -  FilterSuperEagle,
  134.75 -  FilterPixelate,
  134.76 -  FilterMotionBlur,
  134.77 -  FilterAdMame2x,
  134.78 -  FilterSimple2x,
  134.79 -  FilterBilinear,
  134.80 -  FilterBilinearPlus,
  134.81 -  FilterScanlines,
  134.82 -  FilterScanlinesTV,
  134.83 -  FilterHq2x,
  134.84 -  FilterLq2x,
  134.85 -  LastFilter = FilterLq2x
  134.86 -};
  134.87 -
  134.88 -enum EFilterIB
  134.89 -{
  134.90 -  FirstFilterIB,
  134.91 -  FilterIBNone = FirstFilterIB,
  134.92 -  FilterIBSmart,
  134.93 -  FilterIBMotionBlur,
  134.94 -  LastFilterIB = FilterIBMotionBlur
  134.95 -};
  134.96 -
  134.97 -enum EFilterDepth
  134.98 -{
  134.99 -  FilterDepth16,
 134.100 -  FilterDepth32
 134.101 -};
 134.102 -
 134.103 -Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth);
 134.104 -FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
 134.105 -
 134.106 -} // namespace VBA
 134.107 -
 134.108 -
 134.109 -#endif // __VBA_FILTERS_H__
   135.1 --- a/src/gtk/images/Makefile	Sat Mar 03 10:54:39 2012 -0600
   135.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   135.3 @@ -1,396 +0,0 @@
   135.4 -# Makefile.in generated by automake 1.10.1 from Makefile.am.
   135.5 -# src/gtk/images/Makefile.  Generated from Makefile.in by configure.
   135.6 -
   135.7 -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
   135.8 -# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
   135.9 -# This Makefile.in is free software; the Free Software Foundation
  135.10 -# gives unlimited permission to copy and/or distribute it,
  135.11 -# with or without modifications, as long as this notice is preserved.
  135.12 -
  135.13 -# This program is distributed in the hope that it will be useful,
  135.14 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  135.15 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  135.16 -# PARTICULAR PURPOSE.
  135.17 -
  135.18 -
  135.19 -
  135.20 -
  135.21 -pkgdatadir = $(datadir)/VisualBoyAdvance
  135.22 -pkglibdir = $(libdir)/VisualBoyAdvance
  135.23 -pkgincludedir = $(includedir)/VisualBoyAdvance
  135.24 -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
  135.25 -install_sh_DATA = $(install_sh) -c -m 644
  135.26 -install_sh_PROGRAM = $(install_sh) -c
  135.27 -install_sh_SCRIPT = $(install_sh) -c
  135.28 -INSTALL_HEADER = $(INSTALL_DATA)
  135.29 -transform = $(program_transform_name)
  135.30 -NORMAL_INSTALL = :
  135.31 -PRE_INSTALL = :
  135.32 -POST_INSTALL = :
  135.33 -NORMAL_UNINSTALL = :
  135.34 -PRE_UNINSTALL = :
  135.35 -POST_UNINSTALL = :
  135.36 -build_triplet = x86_64-unknown-linux-gnu
  135.37 -host_triplet = x86_64-unknown-linux-gnu
  135.38 -target_triplet = x86_64-unknown-linux-gnu
  135.39 -subdir = src/gtk/images
  135.40 -DIST_COMMON = $(dist_pkgdata_DATA) $(srcdir)/Makefile.am \
  135.41 -	$(srcdir)/Makefile.in
  135.42 -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
  135.43 -am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
  135.44 -	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
  135.45 -	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
  135.46 -	$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
  135.47 -	$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
  135.48 -	$(top_srcdir)/configure.in
  135.49 -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
  135.50 -	$(ACLOCAL_M4)
  135.51 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  135.52 -CONFIG_CLEAN_FILES =
  135.53 -SOURCES =
  135.54 -DIST_SOURCES =
  135.55 -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
  135.56 -am__vpath_adj = case $$p in \
  135.57 -    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
  135.58 -    *) f=$$p;; \
  135.59 -  esac;
  135.60 -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
  135.61 -am__installdirs = "$(DESTDIR)$(pkgdatadir)"
  135.62 -dist_pkgdataDATA_INSTALL = $(INSTALL_DATA)
  135.63 -DATA = $(dist_pkgdata_DATA) $(noinst_DATA)
  135.64 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
  135.65 -ACLOCAL = ${SHELL} /home/r/proj/vba/trunk/missing --run aclocal-1.10
  135.66 -AMTAR = ${SHELL} /home/r/proj/vba/trunk/missing --run tar
  135.67 -AUTOCONF = ${SHELL} /home/r/proj/vba/trunk/missing --run autoconf
  135.68 -AUTOHEADER = ${SHELL} /home/r/proj/vba/trunk/missing --run autoheader
  135.69 -AUTOMAKE = ${SHELL} /home/r/proj/vba/trunk/missing --run automake-1.10
  135.70 -AWK = gawk
  135.71 -CC = gcc
  135.72 -CCDEPMODE = depmode=gcc3
  135.73 -CFLAGS = -g -O2
  135.74 -CPP = gcc -E
  135.75 -CPPFLAGS = 
  135.76 -CXX = g++
  135.77 -CXXDEPMODE = depmode=gcc3
  135.78 -CXXFLAGS = -g -O2 -DC_CORE -DPROFILING -DDEV_VERSION
  135.79 -CYGPATH_W = echo
  135.80 -DEFS = -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"VisualBoyAdvance\" -DVERSION=\"1.7.2\" -DYYTEXT_POINTER=1 -DHAVE_LIBZ=1 -DHAVE_LIBPNG=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_NETINET_IN_H=1
  135.81 -DEPDIR = .deps
  135.82 -ECHO_C = 
  135.83 -ECHO_N = -n
  135.84 -ECHO_T = 
  135.85 -EGREP = /bin/grep -E
  135.86 -EXEEXT = 
  135.87 -GETTEXT_PACKAGE = 
  135.88 -GMSGFMT = 
  135.89 -GREP = /bin/grep
  135.90 -GTKMM_CFLAGS = 
  135.91 -GTKMM_CPPFLAGS = 
  135.92 -GTKMM_LIBS = 
  135.93 -INSTALL = /usr/bin/install -c
  135.94 -INSTALL_DATA = ${INSTALL} -m 644
  135.95 -INSTALL_PROGRAM = ${INSTALL}
  135.96 -INSTALL_SCRIPT = ${INSTALL}
  135.97 -INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
  135.98 -INTLLIBS = 
  135.99 -LDFLAGS = 
 135.100 -LEX = flex
 135.101 -LEXLIB = -lfl
 135.102 -LEX_OUTPUT_ROOT = lex.yy
 135.103 -LIBICONV = 
 135.104 -LIBINTL = 
 135.105 -LIBOBJS = 
 135.106 -LIBS = -lpthread -lpng -lz 
 135.107 -LTLIBICONV = 
 135.108 -LTLIBINTL = 
 135.109 -LTLIBOBJS = 
 135.110 -MAKEINFO = ${SHELL} /home/r/proj/vba/trunk/missing --run makeinfo
 135.111 -MKDIR_P = /bin/mkdir -p
 135.112 -MKINSTALLDIRS = 
 135.113 -MSGFMT = 
 135.114 -MSGMERGE = 
 135.115 -NASM = /usr/bin/nasm
 135.116 -OBJEXT = o
 135.117 -PACKAGE = VisualBoyAdvance
 135.118 -PACKAGE_BUGREPORT = 
 135.119 -PACKAGE_NAME = 
 135.120 -PACKAGE_STRING = 
 135.121 -PACKAGE_TARNAME = 
 135.122 -PACKAGE_VERSION = 
 135.123 -PATH_SEPARATOR = :
 135.124 -PKG_CONFIG = 
 135.125 -POSUB = 
 135.126 -RANLIB = ranlib
 135.127 -SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
 135.128 -SDL_CONFIG = /usr/bin/sdl-config
 135.129 -SDL_LIBS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
 135.130 -SET_MAKE = 
 135.131 -SHELL = /bin/sh
 135.132 -STRIP = 
 135.133 -USE_NLS = 
 135.134 -VBA_EXTRA = 
 135.135 -VBA_LIBS = ../gba/libgba.a ../gb/libgb.a ../common/libgbcom.a ../filters/libfilter.a ../lua/libgblua.a ../prof/libprof.a
 135.136 -VBA_SRC_EXTRA =  lua prof sdl
 135.137 -VERSION = 1.7.2
 135.138 -XGETTEXT = 
 135.139 -XMKMF = 
 135.140 -YACC = bison -y
 135.141 -YFLAGS = 
 135.142 -abs_builddir = /home/r/proj/vba/trunk/src/gtk/images
 135.143 -abs_srcdir = /home/r/proj/vba/trunk/src/gtk/images
 135.144 -abs_top_builddir = /home/r/proj/vba/trunk
 135.145 -abs_top_srcdir = /home/r/proj/vba/trunk
 135.146 -ac_ct_CC = gcc
 135.147 -ac_ct_CXX = g++
 135.148 -am__include = include
 135.149 -am__leading_dot = .
 135.150 -am__quote = 
 135.151 -am__tar = ${AMTAR} chof - "$$tardir"
 135.152 -am__untar = ${AMTAR} xf -
 135.153 -bindir = ${exec_prefix}/bin
 135.154 -build = x86_64-unknown-linux-gnu
 135.155 -build_alias = 
 135.156 -build_cpu = x86_64
 135.157 -build_os = linux-gnu
 135.158 -build_vendor = unknown
 135.159 -builddir = .
 135.160 -datadir = ${datarootdir}
 135.161 -datarootdir = ${prefix}/share
 135.162 -docdir = ${datarootdir}/doc/${PACKAGE}
 135.163 -dvidir = ${docdir}
 135.164 -exec_prefix = ${prefix}
 135.165 -host = x86_64-unknown-linux-gnu
 135.166 -host_alias = 
 135.167 -host_cpu = x86_64
 135.168 -host_os = linux-gnu
 135.169 -host_vendor = unknown
 135.170 -htmldir = ${docdir}
 135.171 -includedir = ${prefix}/include
 135.172 -infodir = ${datarootdir}/info
 135.173 -install_sh = $(SHELL) /home/r/proj/vba/trunk/install-sh
 135.174 -libdir = ${exec_prefix}/lib
 135.175 -libexecdir = ${exec_prefix}/libexec
 135.176 -localedir = ${datarootdir}/locale
 135.177 -localstatedir = ${prefix}/var
 135.178 -mandir = ${datarootdir}/man
 135.179 -mkdir_p = /bin/mkdir -p
 135.180 -oldincludedir = /usr/include
 135.181 -pdfdir = ${docdir}
 135.182 -prefix = /usr/local
 135.183 -program_transform_name = s,x,x,
 135.184 -psdir = ${docdir}
 135.185 -sbindir = ${exec_prefix}/sbin
 135.186 -sharedstatedir = ${prefix}/com
 135.187 -srcdir = .
 135.188 -sysconfdir = ${prefix}/etc
 135.189 -target = x86_64-unknown-linux-gnu
 135.190 -target_alias = 
 135.191 -target_cpu = x86_64
 135.192 -target_os = linux-gnu
 135.193 -target_vendor = unknown
 135.194 -top_builddir = ../../..
 135.195 -top_srcdir = ../../..
 135.196 -VBA_WM_IMAGES = \
 135.197 -	stock-vba-wm-16.png	\
 135.198 -	stock-vba-wm-32.png	\
 135.199 -	stock-vba-wm-48.png	\
 135.200 -	stock-vba-wm-64.png
 135.201 -
 135.202 -VBA_WM_VARIABLES = \
 135.203 -	stock_vba_wm_16  $(srcdir)/stock-vba-wm-16.png	\
 135.204 -	stock_vba_wm_32  $(srcdir)/stock-vba-wm-32.png	\
 135.205 -	stock_vba_wm_48  $(srcdir)/stock-vba-wm-48.png	\
 135.206 -	stock_vba_wm_64  $(srcdir)/stock-vba-wm-64.png
 135.207 -
 135.208 -EXTRA_DIST = $(VBA_WM_IMAGES)
 135.209 -noinst_DATA = vba-wm-pixbufs.h
 135.210 -dist_pkgdata_DATA = vba-64.png
 135.211 -CLEANFILES = $(noinst_DATA)
 135.212 -all: all-am
 135.213 -
 135.214 -.SUFFIXES:
 135.215 -$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 135.216 -	@for dep in $?; do \
 135.217 -	  case '$(am__configure_deps)' in \
 135.218 -	    *$$dep*) \
 135.219 -	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
 135.220 -		&& exit 0; \
 135.221 -	      exit 1;; \
 135.222 -	  esac; \
 135.223 -	done; \
 135.224 -	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gtk/images/Makefile'; \
 135.225 -	cd $(top_srcdir) && \
 135.226 -	  $(AUTOMAKE) --gnu  src/gtk/images/Makefile
 135.227 -.PRECIOUS: Makefile
 135.228 -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 135.229 -	@case '$?' in \
 135.230 -	  *config.status*) \
 135.231 -	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 135.232 -	  *) \
 135.233 -	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 135.234 -	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 135.235 -	esac;
 135.236 -
 135.237 -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 135.238 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 135.239 -
 135.240 -$(top_srcdir)/configure:  $(am__configure_deps)
 135.241 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 135.242 -$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 135.243 -	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 135.244 -install-dist_pkgdataDATA: $(dist_pkgdata_DATA)
 135.245 -	@$(NORMAL_INSTALL)
 135.246 -	test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
 135.247 -	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
 135.248 -	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 135.249 -	  f=$(am__strip_dir) \
 135.250 -	  echo " $(dist_pkgdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \
 135.251 -	  $(dist_pkgdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \
 135.252 -	done
 135.253 -
 135.254 -uninstall-dist_pkgdataDATA:
 135.255 -	@$(NORMAL_UNINSTALL)
 135.256 -	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
 135.257 -	  f=$(am__strip_dir) \
 135.258 -	  echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \
 135.259 -	  rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \
 135.260 -	done
 135.261 -tags: TAGS
 135.262 -TAGS:
 135.263 -
 135.264 -ctags: CTAGS
 135.265 -CTAGS:
 135.266 -
 135.267 -
 135.268 -distdir: $(DISTFILES)
 135.269 -	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 135.270 -	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 135.271 -	list='$(DISTFILES)'; \
 135.272 -	  dist_files=`for file in $$list; do echo $$file; done | \
 135.273 -	  sed -e "s|^$$srcdirstrip/||;t" \
 135.274 -	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
 135.275 -	case $$dist_files in \
 135.276 -	  */*) $(MKDIR_P) `echo "$$dist_files" | \
 135.277 -			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
 135.278 -			   sort -u` ;; \
 135.279 -	esac; \
 135.280 -	for file in $$dist_files; do \
 135.281 -	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 135.282 -	  if test -d $$d/$$file; then \
 135.283 -	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
 135.284 -	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
 135.285 -	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
 135.286 -	    fi; \
 135.287 -	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 135.288 -	  else \
 135.289 -	    test -f $(distdir)/$$file \
 135.290 -	    || cp -p $$d/$$file $(distdir)/$$file \
 135.291 -	    || exit 1; \
 135.292 -	  fi; \
 135.293 -	done
 135.294 -check-am: all-am
 135.295 -check: check-am
 135.296 -all-am: Makefile $(DATA)
 135.297 -installdirs:
 135.298 -	for dir in "$(DESTDIR)$(pkgdatadir)"; do \
 135.299 -	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 135.300 -	done
 135.301 -install: install-am
 135.302 -install-exec: install-exec-am
 135.303 -install-data: install-data-am
 135.304 -uninstall: uninstall-am
 135.305 -
 135.306 -install-am: all-am
 135.307 -	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 135.308 -
 135.309 -installcheck: installcheck-am
 135.310 -install-strip:
 135.311 -	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 135.312 -	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
 135.313 -	  `test -z '$(STRIP)' || \
 135.314 -	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 135.315 -mostlyclean-generic:
 135.316 -
 135.317 -clean-generic:
 135.318 -	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 135.319 -
 135.320 -distclean-generic:
 135.321 -	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 135.322 -
 135.323 -maintainer-clean-generic:
 135.324 -	@echo "This command is intended for maintainers to use"
 135.325 -	@echo "it deletes files that may require special tools to rebuild."
 135.326 -clean: clean-am
 135.327 -
 135.328 -clean-am: clean-generic mostlyclean-am
 135.329 -
 135.330 -distclean: distclean-am
 135.331 -	-rm -f Makefile
 135.332 -distclean-am: clean-am distclean-generic
 135.333 -
 135.334 -dvi: dvi-am
 135.335 -
 135.336 -dvi-am:
 135.337 -
 135.338 -html: html-am
 135.339 -
 135.340 -info: info-am
 135.341 -
 135.342 -info-am:
 135.343 -
 135.344 -install-data-am: install-dist_pkgdataDATA
 135.345 -
 135.346 -install-dvi: install-dvi-am
 135.347 -
 135.348 -install-exec-am:
 135.349 -
 135.350 -install-html: install-html-am
 135.351 -
 135.352 -install-info: install-info-am
 135.353 -
 135.354 -install-man:
 135.355 -
 135.356 -install-pdf: install-pdf-am
 135.357 -
 135.358 -install-ps: install-ps-am
 135.359 -
 135.360 -installcheck-am:
 135.361 -
 135.362 -maintainer-clean: maintainer-clean-am
 135.363 -	-rm -f Makefile
 135.364 -maintainer-clean-am: distclean-am maintainer-clean-generic
 135.365 -
 135.366 -mostlyclean: mostlyclean-am
 135.367 -
 135.368 -mostlyclean-am: mostlyclean-generic
 135.369 -
 135.370 -pdf: pdf-am
 135.371 -
 135.372 -pdf-am:
 135.373 -
 135.374 -ps: ps-am
 135.375 -
 135.376 -ps-am:
 135.377 -
 135.378 -uninstall-am: uninstall-dist_pkgdataDATA
 135.379 -
 135.380 -.MAKE: install-am install-strip
 135.381 -
 135.382 -.PHONY: all all-am check check-am clean clean-generic distclean \
 135.383 -	distclean-generic distdir dvi dvi-am html html-am info info-am \
 135.384 -	install install-am install-data install-data-am \
 135.385 -	install-dist_pkgdataDATA install-dvi install-dvi-am \
 135.386 -	install-exec install-exec-am install-html install-html-am \
 135.387 -	install-info install-info-am install-man install-pdf \
 135.388 -	install-pdf-am install-ps install-ps-am install-strip \
 135.389 -	installcheck installcheck-am installdirs maintainer-clean \
 135.390 -	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
 135.391 -	pdf-am ps ps-am uninstall uninstall-am \
 135.392 -	uninstall-dist_pkgdataDATA
 135.393 -
 135.394 -
 135.395 -$(srcdir)/vba-wm-pixbufs.h: $(VBA_WM_IMAGES) Makefile.am
 135.396 -	gdk-pixbuf-csource --raw --build-list $(VBA_WM_VARIABLES) > $(@F)
 135.397 -# Tell versions [3.59,3.63) of GNU make to not export all variables.
 135.398 -# Otherwise a system limit (for SysV at least) may be exceeded.
 135.399 -.NOEXPORT:
   136.1 --- a/src/gtk/images/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
   136.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   136.3 @@ -1,22 +0,0 @@
   136.4 -VBA_WM_IMAGES = \
   136.5 -	stock-vba-wm-16.png	\
   136.6 -	stock-vba-wm-32.png	\
   136.7 -	stock-vba-wm-48.png	\
   136.8 -	stock-vba-wm-64.png
   136.9 -
  136.10 -VBA_WM_VARIABLES = \
  136.11 -	stock_vba_wm_16  $(srcdir)/stock-vba-wm-16.png	\
  136.12 -	stock_vba_wm_32  $(srcdir)/stock-vba-wm-32.png	\
  136.13 -	stock_vba_wm_48  $(srcdir)/stock-vba-wm-48.png	\
  136.14 -	stock_vba_wm_64  $(srcdir)/stock-vba-wm-64.png
  136.15 -
  136.16 -EXTRA_DIST = $(VBA_WM_IMAGES)
  136.17 -
  136.18 -noinst_DATA = vba-wm-pixbufs.h
  136.19 -
  136.20 -dist_pkgdata_DATA = vba-64.png
  136.21 -
  136.22 -CLEANFILES = $(noinst_DATA)
  136.23 -
  136.24 -$(srcdir)/vba-wm-pixbufs.h: $(VBA_WM_IMAGES) Makefile.am
  136.25 -	gdk-pixbuf-csource --raw --build-list $(VBA_WM_VARIABLES) > $(@F)
   137.1 Binary file src/gtk/images/stock-vba-wm-16.png has changed
   138.1 Binary file src/gtk/images/stock-vba-wm-32.png has changed
   139.1 Binary file src/gtk/images/stock-vba-wm-48.png has changed
   140.1 Binary file src/gtk/images/stock-vba-wm-64.png has changed
   141.1 Binary file src/gtk/images/vba-64.png has changed
   142.1 --- a/src/gtk/input.cpp	Sat Mar 03 10:54:39 2012 -0600
   142.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   142.3 @@ -1,53 +0,0 @@
   142.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   142.5 -// Copyright (C) 1999-2003 Forgotten
   142.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   142.7 -
   142.8 -// This program is free software; you can redistribute it and/or modify
   142.9 -// it under the terms of the GNU General Public License as published by
  142.10 -// the Free Software Foundation; either version 2, or(at your option)
  142.11 -// any later version.
  142.12 -//
  142.13 -// This program is distributed in the hope that it will be useful,
  142.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  142.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  142.16 -// GNU General Public License for more details.
  142.17 -//
  142.18 -// You should have received a copy of the GNU General Public License
  142.19 -// along with this program; if not, write to the Free Software Foundation,
  142.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  142.21 -
  142.22 -#include "input.h"
  142.23 -
  142.24 -#include <new>
  142.25 -
  142.26 -namespace VBA
  142.27 -{
  142.28 -
  142.29 -Keymap::Keymap()
  142.30 -{
  142.31 -  m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal);
  142.32 -  if (m_pstTable == NULL)
  142.33 -  {
  142.34 -    throw std::bad_alloc();
  142.35 -  }
  142.36 -}
  142.37 -
  142.38 -Keymap::~Keymap()
  142.39 -{
  142.40 -  g_hash_table_destroy(m_pstTable);
  142.41 -}
  142.42 -
  142.43 -void Keymap::vRegister(guint _uiVal, EKey _eKey)
  142.44 -{
  142.45 -  g_hash_table_insert(m_pstTable,
  142.46 -                      GUINT_TO_POINTER(_uiVal),
  142.47 -                      GUINT_TO_POINTER(_eKey));
  142.48 -}
  142.49 -
  142.50 -void Keymap::vClear()
  142.51 -{
  142.52 -  g_hash_table_destroy(m_pstTable);
  142.53 -  m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal);
  142.54 -}
  142.55 -
  142.56 -} // namespace VBA
   143.1 --- a/src/gtk/input.h	Sat Mar 03 10:54:39 2012 -0600
   143.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.3 @@ -1,92 +0,0 @@
   143.4 -// -*- C++ -*-
   143.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   143.6 -// Copyright (C) 1999-2003 Forgotten
   143.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   143.8 -
   143.9 -// This program is free software; you can redistribute it and/or modify
  143.10 -// it under the terms of the GNU General Public License as published by
  143.11 -// the Free Software Foundation; either version 2, or(at your option)
  143.12 -// any later version.
  143.13 -//
  143.14 -// This program is distributed in the hope that it will be useful,
  143.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  143.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  143.17 -// GNU General Public License for more details.
  143.18 -//
  143.19 -// You should have received a copy of the GNU General Public License
  143.20 -// along with this program; if not, write to the Free Software Foundation,
  143.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  143.22 -
  143.23 -#ifndef __VBA_INPUT_H__
  143.24 -#define __VBA_INPUT_H__
  143.25 -
  143.26 -#include <glib.h>
  143.27 -
  143.28 -namespace VBA
  143.29 -{
  143.30 -
  143.31 -enum EKey
  143.32 -{
  143.33 -  KeyNone,
  143.34 -  // GBA keys
  143.35 -  KeyA,
  143.36 -  KeyB,
  143.37 -  KeySelect,
  143.38 -  KeyStart,
  143.39 -  KeyRight,
  143.40 -  KeyLeft,
  143.41 -  KeyUp,
  143.42 -  KeyDown,
  143.43 -  KeyR,
  143.44 -  KeyL,
  143.45 -  // VBA extension
  143.46 -  KeySpeed,
  143.47 -  KeyCapture
  143.48 -};
  143.49 -
  143.50 -enum EKeyFlag
  143.51 -{
  143.52 -  // GBA keys
  143.53 -  KeyFlagA       = 1 << 0,
  143.54 -  KeyFlagB       = 1 << 1,
  143.55 -  KeyFlagSelect  = 1 << 2,
  143.56 -  KeyFlagStart   = 1 << 3,
  143.57 -  KeyFlagRight   = 1 << 4,
  143.58 -  KeyFlagLeft    = 1 << 5,
  143.59 -  KeyFlagUp      = 1 << 6,
  143.60 -  KeyFlagDown    = 1 << 7,
  143.61 -  KeyFlagR       = 1 << 8,
  143.62 -  KeyFlagL       = 1 << 9,
  143.63 -  // VBA extension
  143.64 -  KeyFlagSpeed   = 1 << 10,
  143.65 -  KeyFlagCapture = 1 << 11,
  143.66 -};
  143.67 -
  143.68 -class Keymap
  143.69 -{
  143.70 - public:
  143.71 -  Keymap();
  143.72 -  ~Keymap();
  143.73 -
  143.74 -  void vRegister(guint _uiVal, EKey _eKey);
  143.75 -  void vClear();
  143.76 -  inline EKey eGetKey(guint _uiVal);
  143.77 -
  143.78 - private:
  143.79 -  GHashTable * m_pstTable;
  143.80 -
  143.81 -  // noncopyable
  143.82 -  Keymap(const Keymap &);
  143.83 -  Keymap & operator=(const Keymap &);
  143.84 -};
  143.85 -
  143.86 -inline EKey Keymap::eGetKey(guint _uiVal)
  143.87 -{
  143.88 -  return (EKey)GPOINTER_TO_UINT(g_hash_table_lookup(m_pstTable,
  143.89 -                                                    GUINT_TO_POINTER(_uiVal)));
  143.90 -}
  143.91 -
  143.92 -} // namespace VBA
  143.93 -
  143.94 -
  143.95 -#endif // __VBA_INPUT_H__
   144.1 --- a/src/gtk/intl.h	Sat Mar 03 10:54:39 2012 -0600
   144.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.3 @@ -1,42 +0,0 @@
   144.4 -// -*- C++ -*-
   144.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   144.6 -// Copyright (C) 1999-2003 Forgotten
   144.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   144.8 -
   144.9 -// This program is free software; you can redistribute it and/or modify
  144.10 -// it under the terms of the GNU General Public License as published by
  144.11 -// the Free Software Foundation; either version 2, or(at your option)
  144.12 -// any later version.
  144.13 -//
  144.14 -// This program is distributed in the hope that it will be useful,
  144.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  144.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  144.17 -// GNU General Public License for more details.
  144.18 -//
  144.19 -// You should have received a copy of the GNU General Public License
  144.20 -// along with this program; if not, write to the Free Software Foundation,
  144.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  144.22 -
  144.23 -#ifndef __VBA_INTL_H__
  144.24 -#define __VBA_INTL_H__
  144.25 -
  144.26 -#ifndef GETTEXT_PACKAGE
  144.27 -# error "GETTEXT_PACKAGE must be defined"
  144.28 -#endif
  144.29 -
  144.30 -#ifdef ENABLE_NLS
  144.31 -# include <libintl.h>
  144.32 -# define _(String) gettext(String)
  144.33 -# define N_(String) (String)
  144.34 -#else
  144.35 -# define _(String) (String)
  144.36 -# define N_(String) (String)
  144.37 -# define textdomain(String) (String)
  144.38 -# define gettext(String) (String)
  144.39 -# define dgettext(Domain,String) (String)
  144.40 -# define dcgettext(Domain,String,Type) (String)
  144.41 -# define bindtextdomain(Domain,Directory) (Domain) 
  144.42 -#endif
  144.43 -
  144.44 -
  144.45 -#endif // __VBA_INTL_H__
   145.1 --- a/src/gtk/joypadconfig.cpp	Sat Mar 03 10:54:39 2012 -0600
   145.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.3 @@ -1,276 +0,0 @@
   145.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   145.5 -// Copyright (C) 1999-2003 Forgotten
   145.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   145.7 -
   145.8 -// This program is free software; you can redistribute it and/or modify
   145.9 -// it under the terms of the GNU General Public License as published by
  145.10 -// the Free Software Foundation; either version 2, or(at your option)
  145.11 -// any later version.
  145.12 -//
  145.13 -// This program is distributed in the hope that it will be useful,
  145.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  145.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  145.16 -// GNU General Public License for more details.
  145.17 -//
  145.18 -// You should have received a copy of the GNU General Public License
  145.19 -// along with this program; if not, write to the Free Software Foundation,
  145.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  145.21 -
  145.22 -#include "joypadconfig.h"
  145.23 -
  145.24 -#include <string.h>
  145.25 -
  145.26 -#include "intl.h"
  145.27 -
  145.28 -namespace VBA
  145.29 -{
  145.30 -
  145.31 -guint * JoypadConfig::puiAt(int _iIndex)
  145.32 -{
  145.33 -  guint * puiMember;
  145.34 -
  145.35 -  switch (_iIndex)
  145.36 -  {
  145.37 -  case 0:
  145.38 -    puiMember = &m_uiUp;
  145.39 -    break;
  145.40 -  case 1:
  145.41 -    puiMember = &m_uiDown;
  145.42 -    break;
  145.43 -  case 2:
  145.44 -    puiMember = &m_uiLeft;
  145.45 -    break;
  145.46 -  case 3:
  145.47 -    puiMember = &m_uiRight;
  145.48 -    break;
  145.49 -  case 4:
  145.50 -    puiMember = &m_uiA;
  145.51 -    break;
  145.52 -  case 5:
  145.53 -    puiMember = &m_uiB;
  145.54 -    break;
  145.55 -  case 6:
  145.56 -    puiMember = &m_uiL;
  145.57 -    break;
  145.58 -  case 7:
  145.59 -    puiMember = &m_uiR;
  145.60 -    break;
  145.61 -  case 8:
  145.62 -    puiMember = &m_uiSelect;
  145.63 -    break;
  145.64 -  case 9:
  145.65 -    puiMember = &m_uiStart;
  145.66 -    break;
  145.67 -  case 10:
  145.68 -    puiMember = &m_uiSpeed;
  145.69 -    break;
  145.70 -  case 11:
  145.71 -    puiMember = &m_uiCapture;
  145.72 -    break;
  145.73 -  default:
  145.74 -    puiMember = NULL;
  145.75 -  }
  145.76 -
  145.77 -  return puiMember;
  145.78 -}
  145.79 -
  145.80 -int JoypadConfig::iFind(guint _uiKeycode)
  145.81 -{
  145.82 -  for (guint i = 0; i < 12; i++)
  145.83 -  {
  145.84 -    if (*puiAt(i) == _uiKeycode)
  145.85 -    {
  145.86 -      return i;
  145.87 -    }
  145.88 -  }
  145.89 -
  145.90 -  return -1;
  145.91 -}
  145.92 -
  145.93 -void JoypadConfig::vSetDefault()
  145.94 -{
  145.95 -  guint auiKeyval[] =
  145.96 -  {
  145.97 -    GDK_Up, GDK_Down, GDK_Left, GDK_Right,
  145.98 -    GDK_z, GDK_x, GDK_a, GDK_s,
  145.99 -    GDK_BackSpace, GDK_Return,
 145.100 -    GDK_space, GDK_F12
 145.101 -  };
 145.102 -
 145.103 -  for (guint i = 0; i < G_N_ELEMENTS(auiKeyval); i++)
 145.104 -  {
 145.105 -    GdkKeymapKey * pstKeys;
 145.106 -    int iKeys;
 145.107 -
 145.108 -    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
 145.109 -                                          auiKeyval[i],
 145.110 -                                          &pstKeys,
 145.111 -                                          &iKeys))
 145.112 -    {
 145.113 -      *puiAt(i) = pstKeys[0].keycode;
 145.114 -      g_free(pstKeys);
 145.115 -    }
 145.116 -    else
 145.117 -    {
 145.118 -      *puiAt(i) = 0;
 145.119 -    }
 145.120 -  }
 145.121 -}
 145.122 -
 145.123 -Keymap * JoypadConfig::poCreateKeymap() const
 145.124 -{
 145.125 -  Keymap * poKeymap = new Keymap();
 145.126 -
 145.127 -  poKeymap->vRegister(m_uiUp,      KeyUp      );
 145.128 -  poKeymap->vRegister(m_uiDown,    KeyDown    );
 145.129 -  poKeymap->vRegister(m_uiLeft,    KeyLeft    );
 145.130 -  poKeymap->vRegister(m_uiRight,   KeyRight   );
 145.131 -  poKeymap->vRegister(m_uiA,       KeyA       );
 145.132 -  poKeymap->vRegister(m_uiB,       KeyB       );
 145.133 -  poKeymap->vRegister(m_uiL,       KeyL       );
 145.134 -  poKeymap->vRegister(m_uiR,       KeyR       );
 145.135 -  poKeymap->vRegister(m_uiSelect,  KeySelect  );
 145.136 -  poKeymap->vRegister(m_uiStart,   KeyStart   );
 145.137 -  poKeymap->vRegister(m_uiSpeed,   KeySpeed   );
 145.138 -  poKeymap->vRegister(m_uiCapture, KeyCapture );
 145.139 -
 145.140 -  return poKeymap;
 145.141 -}
 145.142 -
 145.143 -JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog,
 145.144 -                                       const Glib::RefPtr<Gnome::Glade::Xml> & _poXml) :
 145.145 -  Gtk::Dialog(_pstDialog)
 145.146 -{
 145.147 -  m_puiCurrentKeyCode = NULL;
 145.148 -
 145.149 -  memset(&m_oConfig, 0, sizeof(m_oConfig));
 145.150 -
 145.151 -  m_poOkButton = dynamic_cast<Gtk::Button *>(_poXml->get_widget("JoypadOkButton"));
 145.152 -
 145.153 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadUpEntry")));
 145.154 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadDownEntry")));
 145.155 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadLeftEntry")));
 145.156 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadRightEntry")));
 145.157 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadAEntry")));
 145.158 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadBEntry")));
 145.159 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadLEntry")));
 145.160 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadREntry")));
 145.161 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadSelectEntry")));
 145.162 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadStartEntry")));
 145.163 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadSpeedEntry")));
 145.164 -  m_oEntries.push_back(dynamic_cast<Gtk::Entry *>(_poXml->get_widget("JoypadCaptureEntry")));
 145.165 -
 145.166 -  for (guint i = 0; i < m_oEntries.size(); i++)
 145.167 -  {
 145.168 -    Gtk::Entry * poEntry = m_oEntries[i];
 145.169 -
 145.170 -    poEntry->signal_focus_in_event().connect(SigC::bind<guint>(
 145.171 -                                               SigC::slot(*this, &JoypadConfigDialog::bOnEntryFocusIn),
 145.172 -                                               i));
 145.173 -    poEntry->signal_focus_out_event().connect(SigC::slot(*this, &JoypadConfigDialog::bOnEntryFocusOut));
 145.174 -  }
 145.175 -
 145.176 -  vUpdateEntries();
 145.177 -}
 145.178 -
 145.179 -JoypadConfigDialog::~JoypadConfigDialog()
 145.180 -{
 145.181 -}
 145.182 -
 145.183 -void JoypadConfigDialog::vSetConfig(const JoypadConfig & _roConfig)
 145.184 -{
 145.185 -  m_oConfig = _roConfig;
 145.186 -  vUpdateEntries();
 145.187 -}
 145.188 -
 145.189 -void JoypadConfigDialog::vUpdateEntries()
 145.190 -{
 145.191 -  for (guint i = 0; i < m_oEntries.size(); i++)
 145.192 -  {
 145.193 -    guint uiKeyval = 0;
 145.194 -    gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
 145.195 -                                        *m_oConfig.puiAt(i),
 145.196 -                                        (GdkModifierType)0,
 145.197 -                                        0,
 145.198 -                                        &uiKeyval,
 145.199 -                                        NULL,
 145.200 -                                        NULL,
 145.201 -                                        NULL);
 145.202 -    const char * csName = gdk_keyval_name(uiKeyval);
 145.203 -    if (csName == NULL)
 145.204 -    {
 145.205 -      m_oEntries[i]->set_text(_("<Undefined>"));
 145.206 -    }
 145.207 -    else
 145.208 -    {
 145.209 -      m_oEntries[i]->set_text(csName);
 145.210 -    }
 145.211 -  }
 145.212 -}
 145.213 -
 145.214 -bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent,
 145.215 -                                         guint           _uiEntry)
 145.216 -{
 145.217 -  m_uiCurrentEntry    = _uiEntry;
 145.218 -  m_puiCurrentKeyCode = m_oConfig.puiAt(_uiEntry);
 145.219 -
 145.220 -  return false;
 145.221 -}
 145.222 -
 145.223 -bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus * _pstEvent)
 145.224 -{
 145.225 -  m_puiCurrentKeyCode = NULL;
 145.226 -
 145.227 -  return false;
 145.228 -}
 145.229 -
 145.230 -bool JoypadConfigDialog::on_key_press_event(GdkEventKey * _pstEvent)
 145.231 -{
 145.232 -  if (m_puiCurrentKeyCode == NULL)
 145.233 -  {
 145.234 -    return Gtk::Dialog::on_key_press_event(_pstEvent);
 145.235 -  }
 145.236 -
 145.237 -  *m_puiCurrentKeyCode = 0;
 145.238 -  int iFound = m_oConfig.iFind(_pstEvent->hardware_keycode);
 145.239 -  if (iFound >= 0)
 145.240 -  {
 145.241 -    *m_oConfig.puiAt(iFound) = 0;
 145.242 -    m_oEntries[iFound]->set_text(_("<Undefined>"));
 145.243 -  }
 145.244 -
 145.245 -  *m_puiCurrentKeyCode = _pstEvent->hardware_keycode;
 145.246 -
 145.247 -  guint uiKeyval = 0;
 145.248 -  gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
 145.249 -                                      _pstEvent->hardware_keycode,
 145.250 -                                      (GdkModifierType)0,
 145.251 -                                      0,
 145.252 -                                      &uiKeyval,
 145.253 -                                      NULL,
 145.254 -                                      NULL,
 145.255 -                                      NULL);
 145.256 -
 145.257 -  const char * csName = gdk_keyval_name(uiKeyval);
 145.258 -  if (csName == NULL)
 145.259 -  {
 145.260 -    m_oEntries[m_uiCurrentEntry]->set_text(_("<Undefined>"));
 145.261 -  }
 145.262 -  else
 145.263 -  {
 145.264 -    m_oEntries[m_uiCurrentEntry]->set_text(csName);
 145.265 -  }
 145.266 -
 145.267 -  if (m_uiCurrentEntry + 1 < m_oEntries.size())
 145.268 -  {
 145.269 -    m_oEntries[m_uiCurrentEntry + 1]->grab_focus();
 145.270 -  }
 145.271 -  else
 145.272 -  {
 145.273 -    m_poOkButton->grab_focus();
 145.274 -  }
 145.275 -
 145.276 -  return true;
 145.277 -}
 145.278 -
 145.279 -} // namespace VBA
   146.1 --- a/src/gtk/joypadconfig.h	Sat Mar 03 10:54:39 2012 -0600
   146.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.3 @@ -1,88 +0,0 @@
   146.4 -// -*- C++ -*-
   146.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   146.6 -// Copyright (C) 1999-2003 Forgotten
   146.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   146.8 -
   146.9 -// This program is free software; you can redistribute it and/or modify
  146.10 -// it under the terms of the GNU General Public License as published by
  146.11 -// the Free Software Foundation; either version 2, or(at your option)
  146.12 -// any later version.
  146.13 -//
  146.14 -// This program is distributed in the hope that it will be useful,
  146.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  146.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  146.17 -// GNU General Public License for more details.
  146.18 -//
  146.19 -// You should have received a copy of the GNU General Public License
  146.20 -// along with this program; if not, write to the Free Software Foundation,
  146.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  146.22 -
  146.23 -#ifndef __VBA_JOYPADCONFIG_H__
  146.24 -#define __VBA_JOYPADCONFIG_H__
  146.25 -
  146.26 -#include <vector>
  146.27 -
  146.28 -#include <libglademm.h>
  146.29 -#include <gtkmm.h>
  146.30 -
  146.31 -#ifndef GTKMM20
  146.32 -# include "sigccompat.h"
  146.33 -#endif // ! GTKMM20
  146.34 -
  146.35 -#include "input.h"
  146.36 -
  146.37 -namespace VBA
  146.38 -{
  146.39 -
  146.40 -class JoypadConfig
  146.41 -{
  146.42 -public:
  146.43 -  guint m_uiUp;
  146.44 -  guint m_uiDown;
  146.45 -  guint m_uiLeft;
  146.46 -  guint m_uiRight;
  146.47 -  guint m_uiA;
  146.48 -  guint m_uiB;
  146.49 -  guint m_uiL;
  146.50 -  guint m_uiR;
  146.51 -  guint m_uiSelect;
  146.52 -  guint m_uiStart;
  146.53 -  guint m_uiSpeed;
  146.54 -  guint m_uiCapture;
  146.55 -
  146.56 -  guint *  puiAt(int _iIndex);
  146.57 -  int      iFind(guint _uiKeycode);
  146.58 -  void     vSetDefault();
  146.59 -  Keymap * poCreateKeymap() const;
  146.60 -};
  146.61 -
  146.62 -class JoypadConfigDialog : public Gtk::Dialog
  146.63 -{
  146.64 -public:
  146.65 -  JoypadConfigDialog(GtkDialog * _pstDialog,
  146.66 -                     const Glib::RefPtr<Gnome::Glade::Xml> & _poXml);
  146.67 -  virtual ~JoypadConfigDialog();
  146.68 -
  146.69 -  void vSetConfig(const JoypadConfig & _roConfig);
  146.70 -  inline JoypadConfig stGetConfig() const { return m_oConfig; }
  146.71 -
  146.72 -protected:
  146.73 -  bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry);
  146.74 -  bool bOnEntryFocusOut(GdkEventFocus * _pstEvent);
  146.75 -
  146.76 -  bool on_key_press_event(GdkEventKey * _pstEvent);
  146.77 -
  146.78 -private:
  146.79 -  JoypadConfig              m_oConfig;
  146.80 -  Gtk::Button *             m_poOkButton;
  146.81 -  std::vector<Gtk::Entry *> m_oEntries;
  146.82 -  guint *                   m_puiCurrentKeyCode;
  146.83 -  guint                     m_uiCurrentEntry;
  146.84 -
  146.85 -  void vUpdateEntries();
  146.86 -};
  146.87 -
  146.88 -} // namespace VBA
  146.89 -
  146.90 -
  146.91 -#endif // __VBA_JOYPADCONFIG_H__
   147.1 --- a/src/gtk/main.cpp	Sat Mar 03 10:54:39 2012 -0600
   147.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   147.3 @@ -1,177 +0,0 @@
   147.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   147.5 -// Copyright (C) 1999-2003 Forgotten
   147.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   147.7 -
   147.8 -// This program is free software; you can redistribute it and/or modify
   147.9 -// it under the terms of the GNU General Public License as published by
  147.10 -// the Free Software Foundation; either version 2, or(at your option)
  147.11 -// any later version.
  147.12 -//
  147.13 -// This program is distributed in the hope that it will be useful,
  147.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  147.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  147.16 -// GNU General Public License for more details.
  147.17 -//
  147.18 -// You should have received a copy of the GNU General Public License
  147.19 -// along with this program; if not, write to the Free Software Foundation,
  147.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  147.21 -
  147.22 -#include <limits.h>
  147.23 -#include <stdlib.h>
  147.24 -#include "../getopt.h"
  147.25 -
  147.26 -#include <list>
  147.27 -
  147.28 -#include <libglademm.h>
  147.29 -#include <gtkmm/main.h>
  147.30 -#include <gtkmm/window.h>
  147.31 -#include <gtkmm/messagedialog.h>
  147.32 -
  147.33 -#include "images/vba-wm-pixbufs.h"
  147.34 -
  147.35 -#include "window.h"
  147.36 -#include "intl.h"
  147.37 -
  147.38 -using Gnome::Glade::Xml;
  147.39 -
  147.40 -static const char * csProgramName;
  147.41 -
  147.42 -static int iShowHelp;
  147.43 -static int iShowVersion;
  147.44 -
  147.45 -// Non-characters used for long options that have no equivalent short option
  147.46 -enum
  147.47 -{
  147.48 -  IGNORED_OPTION = CHAR_MAX + 1
  147.49 -};
  147.50 -
  147.51 -static const char csShortOptions[] = "V";
  147.52 -
  147.53 -static const struct option astLongOptions[] =
  147.54 -{
  147.55 -  { "help",    no_argument, &iShowHelp, IGNORED_OPTION },
  147.56 -  { "version", no_argument, NULL,       'V'            },
  147.57 -  { 0, 0, 0, 0 }
  147.58 -};
  147.59 -
  147.60 -static void vUsage(int iStatus)
  147.61 -{
  147.62 -  if (iStatus != 0)
  147.63 -  {
  147.64 -    g_printerr(_("Try `%s --help' for more information.\n"), csProgramName);
  147.65 -  }
  147.66 -  else
  147.67 -  {
  147.68 -    g_print(_("Usage: %s [option ...] [file]\n"), csProgramName);
  147.69 -    g_print(_("\
  147.70 -\n\
  147.71 -Options:\n\
  147.72 -      --help            Output this help.\n\
  147.73 -  -V, --version         Output version information.\n\
  147.74 -"));
  147.75 -  }
  147.76 -
  147.77 -  exit(iStatus);
  147.78 -}
  147.79 -
  147.80 -static void vSetDefaultWindowIcon()
  147.81 -{
  147.82 -  const guint8 * apuiInlinePixbuf[] =
  147.83 -  {
  147.84 -    stock_vba_wm_16,
  147.85 -    stock_vba_wm_32,
  147.86 -    stock_vba_wm_48,
  147.87 -    stock_vba_wm_64
  147.88 -  };
  147.89 -
  147.90 -  std::list<Glib::RefPtr<Gdk::Pixbuf> > listPixbuf;
  147.91 -  for (guint i = 0; i < G_N_ELEMENTS(apuiInlinePixbuf); i++)
  147.92 -  {
  147.93 -    listPixbuf.push_back(
  147.94 -      Gdk::Pixbuf::create_from_inline(-1, apuiInlinePixbuf[i]));
  147.95 -  }
  147.96 -
  147.97 -  Gtk::Window::set_default_icon_list(listPixbuf);
  147.98 -}
  147.99 -
 147.100 -int main(int argc, char * argv[])
 147.101 -{
 147.102 -  csProgramName = argv[0];
 147.103 -
 147.104 -#ifdef ENABLE_NLS
 147.105 -  setlocale(LC_ALL, "");
 147.106 -  bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
 147.107 -  textdomain(GETTEXT_PACKAGE);
 147.108 -  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
 147.109 -#endif // ENABLE_NLS
 147.110 -
 147.111 -  Gtk::Main oKit(argc, argv);
 147.112 -
 147.113 -  int iOpt;
 147.114 -  while ((iOpt = getopt_long(argc, argv, csShortOptions, astLongOptions, NULL))
 147.115 -         != -1)
 147.116 -  {
 147.117 -    switch (iOpt)
 147.118 -    {
 147.119 -    case 'V':
 147.120 -      iShowVersion = 1;
 147.121 -      break;
 147.122 -    case 0:
 147.123 -      // Long options
 147.124 -      break;
 147.125 -    default:
 147.126 -      vUsage(1);
 147.127 -      break;
 147.128 -    }
 147.129 -  }
 147.130 -
 147.131 -  if (iShowVersion)
 147.132 -  {
 147.133 -    g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
 147.134 -    exit(0);
 147.135 -  }
 147.136 -
 147.137 -  if (iShowHelp)
 147.138 -  {
 147.139 -    vUsage(0);
 147.140 -  }
 147.141 -
 147.142 -  vSetDefaultWindowIcon();
 147.143 -
 147.144 -  Glib::RefPtr<Xml> poXml;
 147.145 -  try
 147.146 -  {
 147.147 -    poXml = Xml::create(PKGDATADIR "/vba.glade", "MainWindow");
 147.148 -  }
 147.149 -  catch (const Xml::Error & e)
 147.150 -  {
 147.151 -    Gtk::MessageDialog oDialog(e.what(),
 147.152 -#ifndef GTKMM20
 147.153 -                               false,
 147.154 -#endif // ! GTKMM20
 147.155 -                               Gtk::MESSAGE_ERROR,
 147.156 -                               Gtk::BUTTONS_OK);
 147.157 -    oDialog.run();
 147.158 -    return 1;
 147.159 -  }
 147.160 -
 147.161 -  VBA::Window * poWindow = NULL;
 147.162 -  poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
 147.163 -
 147.164 -  if (optind < argc)
 147.165 -  {
 147.166 -    // Display the window before loading the file
 147.167 -    poWindow->show();
 147.168 -    while (Gtk::Main::events_pending())
 147.169 -    {
 147.170 -      Gtk::Main::iteration();
 147.171 -    }
 147.172 -
 147.173 -    poWindow->bLoadROM(argv[optind]);
 147.174 -  }
 147.175 -
 147.176 -  Gtk::Main::run(*poWindow);
 147.177 -  delete poWindow;
 147.178 -
 147.179 -  return 0;
 147.180 -}
   148.1 --- a/src/gtk/menuitem.h	Sat Mar 03 10:54:39 2012 -0600
   148.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.3 @@ -1,80 +0,0 @@
   148.4 -// -*- C++ -*-
   148.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   148.6 -// Copyright (C) 1999-2003 Forgotten
   148.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   148.8 -
   148.9 -// This program is free software; you can redistribute it and/or modify
  148.10 -// it under the terms of the GNU General Public License as published by
  148.11 -// the Free Software Foundation; either version 2, or(at your option)
  148.12 -// any later version.
  148.13 -//
  148.14 -// This program is distributed in the hope that it will be useful,
  148.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  148.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  148.17 -// GNU General Public License for more details.
  148.18 -//
  148.19 -// You should have received a copy of the GNU General Public License
  148.20 -// along with this program; if not, write to the Free Software Foundation,
  148.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  148.22 -
  148.23 -#ifndef __VBA_MENUITEM_H__
  148.24 -#define __VBA_MENUITEM_H__
  148.25 -
  148.26 -#include <gtkmm/menuitem.h>
  148.27 -#include <gtkmm/imagemenuitem.h>
  148.28 -
  148.29 -#ifdef GTKMM20
  148.30 -namespace Gtk { typedef Gtk::Menu_Helpers::AccelKey AccelKey; }
  148.31 -#endif // GTKMM20
  148.32 -
  148.33 -namespace VBA
  148.34 -{
  148.35 -
  148.36 -class MenuItem : public Gtk::MenuItem
  148.37 -{
  148.38 -public:
  148.39 -  MenuItem()
  148.40 -    {}
  148.41 -
  148.42 -  MenuItem(Gtk::Widget & _roWidget) :
  148.43 -    Gtk::MenuItem(_roWidget)
  148.44 -    {}
  148.45 -
  148.46 -  MenuItem(const Glib::ustring & _rsLabel, bool _bMnemonic = false) :
  148.47 -    Gtk::MenuItem(_rsLabel, _bMnemonic)
  148.48 -    {}
  148.49 -
  148.50 -  inline void set_accel_key(const Gtk::AccelKey & _roAccelKey)
  148.51 -    {
  148.52 -      Gtk::MenuItem::set_accel_key(_roAccelKey);
  148.53 -    }
  148.54 -};
  148.55 -
  148.56 -class ImageMenuItem : public Gtk::ImageMenuItem
  148.57 -{
  148.58 -public:
  148.59 -  ImageMenuItem()
  148.60 -    {}
  148.61 -
  148.62 -  ImageMenuItem(Widget & _roImage, const Glib::ustring & _rsLabel, bool _bMnemonic = false) :
  148.63 -    Gtk::ImageMenuItem(_roImage, _rsLabel, _bMnemonic)
  148.64 -    {}
  148.65 -
  148.66 -  ImageMenuItem(const Glib::ustring & _rsLabel, bool _bMnemonic = false) :
  148.67 -    Gtk::ImageMenuItem(_rsLabel, _bMnemonic)
  148.68 -    {}
  148.69 -
  148.70 -  ImageMenuItem(const Gtk::StockID & _roId) :
  148.71 -    Gtk::ImageMenuItem(_roId)
  148.72 -    {}
  148.73 -
  148.74 -  inline void set_accel_key(const Gtk::AccelKey & _roAccelKey)
  148.75 -    {
  148.76 -      Gtk::MenuItem::set_accel_key(_roAccelKey);
  148.77 -    }
  148.78 -};
  148.79 -
  148.80 -} // namespace VBA
  148.81 -
  148.82 -
  148.83 -#endif // __VBA_MENUITEM_H__
   149.1 --- a/src/gtk/screenarea.cpp	Sat Mar 03 10:54:39 2012 -0600
   149.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   149.3 @@ -1,293 +0,0 @@
   149.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   149.5 -// Copyright (C) 1999-2003 Forgotten
   149.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   149.7 -
   149.8 -// This program is free software; you can redistribute it and/or modify
   149.9 -// it under the terms of the GNU General Public License as published by
  149.10 -// the Free Software Foundation; either version 2, or(at your option)
  149.11 -// any later version.
  149.12 -//
  149.13 -// This program is distributed in the hope that it will be useful,
  149.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  149.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  149.16 -// GNU General Public License for more details.
  149.17 -//
  149.18 -// You should have received a copy of the GNU General Public License
  149.19 -// along with this program; if not, write to the Free Software Foundation,
  149.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  149.21 -
  149.22 -#include "screenarea.h"
  149.23 -
  149.24 -#include <string.h>
  149.25 -
  149.26 -namespace VBA
  149.27 -{
  149.28 -
  149.29 -ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) :
  149.30 -  m_puiPixels(NULL),
  149.31 -  m_puiDelta(NULL),
  149.32 -  m_vFilter2x(NULL),
  149.33 -  m_vFilterIB(NULL),
  149.34 -  m_bShowCursor(true)
  149.35 -{
  149.36 -  g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
  149.37 -
  149.38 -  m_iWidth  = _iWidth;
  149.39 -  m_iHeight = _iHeight;
  149.40 -  m_iScale  = _iScale;
  149.41 -  vUpdateSize();
  149.42 -
  149.43 -  set_events(Gdk::EXPOSURE_MASK
  149.44 -             | Gdk::POINTER_MOTION_MASK
  149.45 -             | Gdk::ENTER_NOTIFY_MASK
  149.46 -             | Gdk::LEAVE_NOTIFY_MASK);
  149.47 -
  149.48 -  char aiEmptyData[8];
  149.49 -  memset(aiEmptyData, 0, sizeof(aiEmptyData));
  149.50 -  Glib::RefPtr<Gdk::Bitmap> poSource = Gdk::Bitmap::create(aiEmptyData, 8, 8);
  149.51 -  Glib::RefPtr<Gdk::Bitmap> poMask = Gdk::Bitmap::create(aiEmptyData, 8, 8);
  149.52 -  Gdk::Color oFg;
  149.53 -  Gdk::Color oBg;
  149.54 -  oFg.set_rgb(0, 0, 0);
  149.55 -  oBg.set_rgb(0, 0, 0);
  149.56 -
  149.57 -  m_poEmptyCursor = new Gdk::Cursor(poSource, poMask, oFg, oBg, 0, 0);
  149.58 -}
  149.59 -
  149.60 -ScreenArea::~ScreenArea()
  149.61 -{
  149.62 -  if (m_puiPixels != NULL)
  149.63 -  {
  149.64 -    delete[] m_puiPixels;
  149.65 -  }
  149.66 -
  149.67 -  if (m_puiDelta != NULL)
  149.68 -  {
  149.69 -    delete[] m_puiDelta;
  149.70 -  }
  149.71 -
  149.72 -  if (m_poEmptyCursor != NULL)
  149.73 -  {
  149.74 -    delete m_poEmptyCursor;
  149.75 -  }
  149.76 -}
  149.77 -
  149.78 -void ScreenArea::vSetSize(int _iWidth, int _iHeight)
  149.79 -{
  149.80 -  g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
  149.81 -
  149.82 -  if (_iWidth != m_iWidth || _iHeight != m_iHeight)
  149.83 -  {
  149.84 -    m_iWidth  = _iWidth;
  149.85 -    m_iHeight = _iHeight;
  149.86 -    vUpdateSize();
  149.87 -  }
  149.88 -}
  149.89 -
  149.90 -void ScreenArea::vSetScale(int _iScale)
  149.91 -{
  149.92 -  g_return_if_fail(_iScale >= 1);
  149.93 -
  149.94 -  if (_iScale != m_iScale)
  149.95 -  {
  149.96 -    m_iScale = _iScale;
  149.97 -    vUpdateSize();
  149.98 -  }
  149.99 -}
 149.100 -
 149.101 -void ScreenArea::vSetFilter2x(EFilter2x _eFilter2x)
 149.102 -{
 149.103 -  m_vFilter2x = pvGetFilter2x(_eFilter2x, FilterDepth32);
 149.104 -}
 149.105 -
 149.106 -void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB)
 149.107 -{
 149.108 -  m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
 149.109 -}
 149.110 -
 149.111 -void ScreenArea::vDrawPixels(u8 * _puiData)
 149.112 -{
 149.113 -  if (m_vFilterIB != NULL)
 149.114 -  {
 149.115 -    m_vFilterIB(_puiData + m_iAreaWidth * 2 + 4,
 149.116 -                m_iAreaWidth * 2 + 4,
 149.117 -                m_iWidth,
 149.118 -                m_iHeight);
 149.119 -  }
 149.120 -
 149.121 -  if (m_iScale == 1)
 149.122 -  {
 149.123 -    u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1;
 149.124 -    u32 * puiPixel = m_puiPixels;
 149.125 -    for (int y = 0; y < m_iHeight; y++)
 149.126 -    {
 149.127 -      for (int x = 0; x < m_iWidth; x++)
 149.128 -      {
 149.129 -        *puiPixel++ = *puiSrc++;
 149.130 -      }
 149.131 -      puiSrc++;
 149.132 -    }
 149.133 -  }
 149.134 -  else if (m_iScale == 2 && m_vFilter2x != NULL)
 149.135 -  {
 149.136 -    m_vFilter2x(_puiData + m_iAreaWidth * 2 + 4,
 149.137 -                m_iAreaWidth * 2 + 4,
 149.138 -                m_puiDelta,
 149.139 -                (u8 *)m_puiPixels,
 149.140 -                m_iRowStride,
 149.141 -                m_iWidth,
 149.142 -                m_iHeight);
 149.143 -  }
 149.144 -  else
 149.145 -  {
 149.146 -    u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1;
 149.147 -    u32 * puiSrc2;
 149.148 -    u32 * puiPixel = m_puiPixels;
 149.149 -    for (int y = 0; y < m_iHeight; y++)
 149.150 -    {
 149.151 -      for (int j = 0; j < m_iScale; j++)
 149.152 -      {
 149.153 -        puiSrc2 = puiSrc;
 149.154 -        for (int x = 0; x < m_iWidth; x++)
 149.155 -        {
 149.156 -          for (int i = 0; i < m_iScale; i++)
 149.157 -          {
 149.158 -            *puiPixel++ = *puiSrc2;
 149.159 -          }
 149.160 -          puiSrc2++;
 149.161 -        }
 149.162 -      }
 149.163 -      puiSrc = puiSrc2 + 1;
 149.164 -    }
 149.165 -  }
 149.166 -
 149.167 -  queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight);
 149.168 -}
 149.169 -
 149.170 -void ScreenArea::vDrawColor(u32 _uiColor)
 149.171 -{
 149.172 -  _uiColor = GUINT32_TO_BE(_uiColor) << 8;
 149.173 -
 149.174 -  u32 * puiPixel = m_puiPixels;
 149.175 -  u32 * puiEnd   = m_puiPixels + m_iAreaWidth * m_iAreaHeight;
 149.176 -  while (puiPixel != puiEnd)
 149.177 -  {
 149.178 -    *puiPixel++ = _uiColor;
 149.179 -  }
 149.180 -
 149.181 -  queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight);
 149.182 -}
 149.183 -
 149.184 -void ScreenArea::vUpdateSize()
 149.185 -{
 149.186 -  if (m_puiPixels != NULL)
 149.187 -  {
 149.188 -    delete[] m_puiPixels;
 149.189 -  }
 149.190 -
 149.191 -  if (m_puiDelta != NULL)
 149.192 -  {
 149.193 -    delete[] m_puiDelta;
 149.194 -  }
 149.195 -
 149.196 -  m_iAreaWidth  = m_iScale * m_iWidth;
 149.197 -  m_iAreaHeight = m_iScale * m_iHeight;
 149.198 -  m_iRowStride  = m_iAreaWidth * 4;
 149.199 -
 149.200 -  m_puiPixels = new u32[m_iAreaWidth * m_iAreaHeight];
 149.201 -
 149.202 -  m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * 4];
 149.203 -  memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 4);
 149.204 -
 149.205 -  set_size_request(m_iAreaWidth, m_iAreaHeight);
 149.206 -}
 149.207 -
 149.208 -void ScreenArea::vStartCursorTimeout()
 149.209 -{
 149.210 -  m_oCursorSig.disconnect();
 149.211 -  m_oCursorSig = Glib::signal_timeout().connect(
 149.212 -    SigC::slot(*this, &ScreenArea::bOnCursorTimeout),
 149.213 -    2000);
 149.214 -}
 149.215 -
 149.216 -void ScreenArea::vStopCursorTimeout()
 149.217 -{
 149.218 -  m_oCursorSig.disconnect();
 149.219 -}
 149.220 -
 149.221 -void ScreenArea::vHideCursor()
 149.222 -{
 149.223 -  get_window()->set_cursor(*m_poEmptyCursor);
 149.224 -  m_bShowCursor = false;
 149.225 -}
 149.226 -
 149.227 -void ScreenArea::vShowCursor()
 149.228 -{
 149.229 -  get_window()->set_cursor();
 149.230 -  m_bShowCursor = true;
 149.231 -}
 149.232 -
 149.233 -bool ScreenArea::on_expose_event(GdkEventExpose * _pstEvent)
 149.234 -{
 149.235 -  if (_pstEvent->area.x + _pstEvent->area.width > m_iAreaWidth
 149.236 -      || _pstEvent->area.y + _pstEvent->area.height > m_iAreaHeight)
 149.237 -  {
 149.238 -    return false;
 149.239 -  }
 149.240 -
 149.241 -  guchar * puiAreaPixels = (guchar *)m_puiPixels;
 149.242 -
 149.243 -  if (_pstEvent->area.x != 0)
 149.244 -  {
 149.245 -    puiAreaPixels += _pstEvent->area.x << 2;
 149.246 -  }
 149.247 -
 149.248 -  if (_pstEvent->area.y != 0)
 149.249 -  {
 149.250 -    puiAreaPixels += _pstEvent->area.y * m_iRowStride;
 149.251 -  }
 149.252 -
 149.253 -  get_window()->draw_rgb_32_image(get_style()->get_fg_gc(get_state()),
 149.254 -                                  _pstEvent->area.x,
 149.255 -                                  _pstEvent->area.y,
 149.256 -                                  _pstEvent->area.width,
 149.257 -                                  _pstEvent->area.height,
 149.258 -                                  Gdk::RGB_DITHER_MAX,
 149.259 -                                  puiAreaPixels,
 149.260 -                                  m_iRowStride);
 149.261 -  return true;
 149.262 -}
 149.263 -
 149.264 -bool ScreenArea::on_motion_notify_event(GdkEventMotion * _pstEvent)
 149.265 -{
 149.266 -  if (! m_bShowCursor)
 149.267 -  {
 149.268 -    vShowCursor();
 149.269 -  }
 149.270 -  vStartCursorTimeout();
 149.271 -  return false;
 149.272 -}
 149.273 -
 149.274 -bool ScreenArea::on_enter_notify_event(GdkEventCrossing * _pstEvent)
 149.275 -{
 149.276 -  vStartCursorTimeout();
 149.277 -  return false;
 149.278 -}
 149.279 -
 149.280 -bool ScreenArea::on_leave_notify_event(GdkEventCrossing * _pstEvent)
 149.281 -{
 149.282 -  vStopCursorTimeout();
 149.283 -  if (! m_bShowCursor)
 149.284 -  {
 149.285 -    vShowCursor();
 149.286 -  }
 149.287 -  return false;
 149.288 -}
 149.289 -
 149.290 -bool ScreenArea::bOnCursorTimeout()
 149.291 -{
 149.292 -  vHideCursor();
 149.293 -  return false;
 149.294 -}
 149.295 -
 149.296 -} // namespace VBA
   150.1 --- a/src/gtk/screenarea.h	Sat Mar 03 10:54:39 2012 -0600
   150.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.3 @@ -1,81 +0,0 @@
   150.4 -// -*- C++ -*-
   150.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   150.6 -// Copyright (C) 1999-2003 Forgotten
   150.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   150.8 -
   150.9 -// This program is free software; you can redistribute it and/or modify
  150.10 -// it under the terms of the GNU General Public License as published by
  150.11 -// the Free Software Foundation; either version 2, or(at your option)
  150.12 -// any later version.
  150.13 -//
  150.14 -// This program is distributed in the hope that it will be useful,
  150.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  150.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  150.17 -// GNU General Public License for more details.
  150.18 -//
  150.19 -// You should have received a copy of the GNU General Public License
  150.20 -// along with this program; if not, write to the Free Software Foundation,
  150.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  150.22 -
  150.23 -#ifndef __VBA_SCREENAREA_H__
  150.24 -#define __VBA_SCREENAREA_H__
  150.25 -
  150.26 -#include <gtkmm/drawingarea.h>
  150.27 -#include <gdkmm/cursor.h>
  150.28 -
  150.29 -#ifndef GTKMM20
  150.30 -# include "sigccompat.h"
  150.31 -#endif // ! GTKMM20
  150.32 -
  150.33 -#include "filters.h"
  150.34 -
  150.35 -namespace VBA
  150.36 -{
  150.37 -
  150.38 -class ScreenArea : public Gtk::DrawingArea
  150.39 -{
  150.40 -public:
  150.41 -  ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
  150.42 -  virtual ~ScreenArea();
  150.43 -
  150.44 -  void vSetSize(int _iWidth, int _iHeight);
  150.45 -  void vSetScale(int _iScale);
  150.46 -  void vSetFilter2x(EFilter2x _eFilter2x);
  150.47 -  void vSetFilterIB(EFilterIB _eFilterIB);
  150.48 -  void vDrawPixels(u8 * _puiData);
  150.49 -  void vDrawColor(u32 _uiColor); // 0xRRGGBB
  150.50 -
  150.51 -protected:
  150.52 -  virtual bool on_expose_event(GdkEventExpose * _pstEvent);
  150.53 -  virtual bool on_motion_notify_event(GdkEventMotion * _pstEvent);
  150.54 -  virtual bool on_enter_notify_event(GdkEventCrossing * _pstEvent);
  150.55 -  virtual bool on_leave_notify_event(GdkEventCrossing * _pstEvent);
  150.56 -  virtual bool bOnCursorTimeout();
  150.57 -
  150.58 -private:
  150.59 -  int      m_iWidth;
  150.60 -  int      m_iHeight;
  150.61 -  int      m_iScale;
  150.62 -  int      m_iAreaWidth;
  150.63 -  int      m_iAreaHeight;
  150.64 -  int      m_iRowStride;
  150.65 -  u32 *    m_puiPixels;
  150.66 -  u8 *     m_puiDelta;
  150.67 -  Filter2x m_vFilter2x;
  150.68 -  FilterIB m_vFilterIB;
  150.69 -
  150.70 -  bool             m_bShowCursor;
  150.71 -  Gdk::Cursor *    m_poEmptyCursor;
  150.72 -  SigC::connection m_oCursorSig;
  150.73 -
  150.74 -  void vUpdateSize();
  150.75 -  void vStartCursorTimeout();
  150.76 -  void vStopCursorTimeout();
  150.77 -  void vHideCursor();
  150.78 -  void vShowCursor();
  150.79 -};
  150.80 -
  150.81 -} // namespace VBA
  150.82 -
  150.83 -
  150.84 -#endif // __VBA_SCREENAREA_H__
   151.1 --- a/src/gtk/sigccompat.h	Sat Mar 03 10:54:39 2012 -0600
   151.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   151.3 @@ -1,57 +0,0 @@
   151.4 -// -*- C++ -*-
   151.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   151.6 -// Copyright (C) 1999-2003 Forgotten
   151.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   151.8 -
   151.9 -// This program is free software; you can redistribute it and/or modify
  151.10 -// it under the terms of the GNU General Public License as published by
  151.11 -// the Free Software Foundation; either version 2, or(at your option)
  151.12 -// any later version.
  151.13 -//
  151.14 -// This program is distributed in the hope that it will be useful,
  151.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  151.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  151.17 -// GNU General Public License for more details.
  151.18 -//
  151.19 -// You should have received a copy of the GNU General Public License
  151.20 -// along with this program; if not, write to the Free Software Foundation,
  151.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  151.22 -
  151.23 -#ifndef __VBA_SIGCCOMPAT_H__
  151.24 -#define __VBA_SIGCCOMPAT_H__
  151.25 -
  151.26 -#undef LIBSIGC_DISABLE_DEPRECATED
  151.27 -#include <sigc++/bind.h>
  151.28 -#include <sigc++/connection.h>
  151.29 -
  151.30 -#include <sigc++/slot.h>
  151.31 -#include <sigc++/object.h>
  151.32 -#include <sigc++/functors/mem_fun.h>
  151.33 -
  151.34 -namespace SigC
  151.35 -{
  151.36 -
  151.37 -using namespace sigc;
  151.38 -
  151.39 -template <class T_return, class T_obj1, class T_obj2>
  151.40 -inline slot0<T_return>
  151.41 -slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)() )
  151.42 -{ return ::sigc::bound_mem_functor0<T_return, T_obj2>
  151.43 -             (dynamic_cast< T_obj1&>(_A_obj), _A_func); }
  151.44 -
  151.45 -template <class T_return, class T_arg1, class T_obj1, class T_obj2>
  151.46 -inline slot1<T_return, T_arg1>
  151.47 -slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)(T_arg1) )
  151.48 -{ return ::sigc::bound_mem_functor1<T_return, T_obj2, T_arg1>
  151.49 -             (dynamic_cast< T_obj1&>(_A_obj), _A_func); }
  151.50 -
  151.51 -template <class T_return, class T_arg1,class T_arg2, class T_obj1, class T_obj2>
  151.52 -inline slot2<T_return, T_arg1,T_arg2>
  151.53 -slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)(T_arg1,T_arg2) )
  151.54 -{ return ::sigc::bound_mem_functor2<T_return, T_obj2, T_arg1,T_arg2>
  151.55 -             (dynamic_cast< T_obj1&>(_A_obj), _A_func); }
  151.56 -
  151.57 -} // namespace SigC
  151.58 -
  151.59 -
  151.60 -#endif // __VBA_SIGCCOMPAT_H__
   152.1 --- a/src/gtk/system.cpp	Sat Mar 03 10:54:39 2012 -0600
   152.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   152.3 @@ -1,469 +0,0 @@
   152.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   152.5 -// Copyright (C) 1999-2003 Forgotten
   152.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   152.7 -
   152.8 -// This program is free software; you can redistribute it and/or modify
   152.9 -// it under the terms of the GNU General Public License as published by
  152.10 -// the Free Software Foundation; either version 2, or(at your option)
  152.11 -// any later version.
  152.12 -//
  152.13 -// This program is distributed in the hope that it will be useful,
  152.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  152.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  152.16 -// GNU General Public License for more details.
  152.17 -//
  152.18 -// You should have received a copy of the GNU General Public License
  152.19 -// along with this program; if not, write to the Free Software Foundation,
  152.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  152.21 -
  152.22 -#include <stdio.h>
  152.23 -#include <stdarg.h>
  152.24 -#include <string.h>
  152.25 -
  152.26 -#include <SDL.h>
  152.27 -#include <SDL_thread.h>
  152.28 -
  152.29 -#include "../common/System.h"
  152.30 -#include "../common/Util.h"
  152.31 -#include "../gba/GBAGlobals.h"
  152.32 -#include "../gb/gbGlobals.h"
  152.33 -#include "../gba/GBASound.h"
  152.34 -
  152.35 -#include "window.h"
  152.36 -#include "intl.h"
  152.37 -
  152.38 -// Required vars, used by the emulator core
  152.39 -//
  152.40 -int  systemRedShift;
  152.41 -int  systemGreenShift;
  152.42 -int  systemBlueShift;
  152.43 -int  systemColorDepth;
  152.44 -int  systemDebug;
  152.45 -int  systemVerbose;
  152.46 -int  systemSaveUpdateCounter;
  152.47 -int  systemFrameSkip;
  152.48 -u32  systemColorMap32[0x10000];
  152.49 -u16  systemColorMap16[0x10000];
  152.50 -u16  systemGbPalette[24];
  152.51 -bool systemSoundOn;
  152.52 -
  152.53 -char filename[2048];
  152.54 -char biosFileName[2048];
  152.55 -//char captureDir[2048];
  152.56 -char saveDir[2048];
  152.57 -char batteryDir[2048];
  152.58 -
  152.59 -int sensorX = 2047;
  152.60 -int sensorY = 2047;
  152.61 -bool sensorOn = false;
  152.62 -
  152.63 -int  emulating;
  152.64 -bool debugger;
  152.65 -int  RGB_LOW_BITS_MASK;
  152.66 -
  152.67 -int cartridgeType = 3;
  152.68 -int sizeOption = 0;
  152.69 -int captureFormat = 0;
  152.70 -int throttle = 0;
  152.71 -bool paused = false;
  152.72 -bool removeIntros = false;
  152.73 -int sdlFlashSize = 0;
  152.74 -int sdlRtcEnable = 0;
  152.75 -
  152.76 -int sdlDefaultJoypad = 0;
  152.77 -
  152.78 -SDL_Joystick **sdlDevices = NULL;
  152.79 -
  152.80 -u16 motion[4] = {
  152.81 -  SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
  152.82 -};
  152.83 -
  152.84 -struct EmulatedSystem emulator = {
  152.85 -  NULL,
  152.86 -  NULL,
  152.87 -  NULL,
  152.88 -  NULL,
  152.89 -  NULL,
  152.90 -  NULL,
  152.91 -  NULL,
  152.92 -  NULL,
  152.93 -  NULL,
  152.94 -  NULL,
  152.95 -  NULL,
  152.96 -  NULL,
  152.97 -  false,
  152.98 -  0
  152.99 -};
 152.100 -
 152.101 -// Extra vars, only used for the GUI
 152.102 -//
 152.103 -int systemRenderedFrames;
 152.104 -int systemFPS;
 152.105 -
 152.106 -// Sound stuff
 152.107 -//
 152.108 -const  int         iSoundSamples  = 2048;
 152.109 -const  int         iSoundTotalLen = iSoundSamples * 4;
 152.110 -static u8          auiSoundBuffer[iSoundTotalLen];
 152.111 -static int         iSoundLen;
 152.112 -static SDL_cond *  pstSoundCond;
 152.113 -static SDL_mutex * pstSoundMutex;
 152.114 -
 152.115 -inline VBA::Window * GUI()
 152.116 -{
 152.117 -  return VBA::Window::poGetInstance();
 152.118 -}
 152.119 -
 152.120 -void systemMessage(int _iId, const char * _csFormat, ...)
 152.121 -{
 152.122 -  va_list args;
 152.123 -  va_start(args, _csFormat);
 152.124 -
 152.125 -  GUI()->vPopupErrorV(_(_csFormat), args);
 152.126 -
 152.127 -  va_end(args);
 152.128 -}
 152.129 -
 152.130 -void systemDrawScreen()
 152.131 -{
 152.132 -  GUI()->vDrawScreen();
 152.133 -  systemRenderedFrames++;
 152.134 -}
 152.135 -
 152.136 -bool systemReadJoypads()
 152.137 -{
 152.138 -  return true;
 152.139 -}
 152.140 -
 152.141 -u32 systemReadJoypad(int,bool)
 152.142 -{
 152.143 -  return GUI()->uiReadJoypad();
 152.144 -}
 152.145 -
 152.146 -void systemShowSpeed(int _iSpeed)
 152.147 -{
 152.148 -  systemFPS = systemRenderedFrames;
 152.149 -  systemRenderedFrames = 0;
 152.150 -
 152.151 -  GUI()->vShowSpeed(_iSpeed);
 152.152 -}
 152.153 -
 152.154 -void system10Frames(int _iRate)
 152.155 -{
 152.156 -  GUI()->vComputeFrameskip(_iRate);
 152.157 -}
 152.158 -
 152.159 -void systemFrame(int)
 152.160 -{
 152.161 -}
 152.162 -
 152.163 -void systemSetTitle(const char * _csTitle)
 152.164 -{
 152.165 -  GUI()->set_title(_csTitle);
 152.166 -}
 152.167 -
 152.168 -int systemScreenCapture(int _iNum)
 152.169 -{
 152.170 -  GUI()->vCaptureScreen(_iNum);
 152.171 -}
 152.172 -
 152.173 -void systemSoundWriteToBuffer()
 152.174 -{
 152.175 -  if (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)
 152.176 -  {
 152.177 -    SDL_PauseAudio(0);
 152.178 -  }
 152.179 -
 152.180 -  bool bWait = true;
 152.181 -  while (bWait && ! speedup && GUI()->iGetThrottle() == 0)
 152.182 -  {
 152.183 -    SDL_mutexP(pstSoundMutex);
 152.184 -    if (iSoundLen < iSoundTotalLen)
 152.185 -    {
 152.186 -      bWait = false;
 152.187 -    }
 152.188 -    SDL_mutexV(pstSoundMutex);
 152.189 -  }
 152.190 -
 152.191 -  int iLen = soundBufferLen;
 152.192 -  int iCopied = 0;
 152.193 -  if (iSoundLen + iLen >= iSoundTotalLen)
 152.194 -  {
 152.195 -    iCopied = iSoundTotalLen - iSoundLen;
 152.196 -    memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, iCopied);
 152.197 -
 152.198 -    iSoundLen = iSoundTotalLen;
 152.199 -    SDL_CondSignal(pstSoundCond);
 152.200 -
 152.201 -    bWait = true;
 152.202 -    if (! speedup && GUI()->iGetThrottle() == 0)
 152.203 -    {
 152.204 -      while(bWait)
 152.205 -      {
 152.206 -        SDL_mutexP(pstSoundMutex);
 152.207 -        if (iSoundLen < iSoundTotalLen)
 152.208 -        {
 152.209 -          bWait = false;
 152.210 -        }
 152.211 -        SDL_mutexV(pstSoundMutex);
 152.212 -      }
 152.213 -
 152.214 -      memcpy(auiSoundBuffer, ((u8 *)soundFinalWave) + iCopied,
 152.215 -             soundBufferLen - iCopied);
 152.216 -
 152.217 -      iSoundLen = soundBufferLen - iCopied;
 152.218 -    }
 152.219 -    else
 152.220 -    {
 152.221 -      memcpy(auiSoundBuffer, ((u8 *)soundFinalWave) + iCopied,
 152.222 -             soundBufferLen);
 152.223 -    }
 152.224 -  }
 152.225 -  else
 152.226 -  {
 152.227 -    memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, soundBufferLen);
 152.228 -    iSoundLen += soundBufferLen;
 152.229 -  }
 152.230 -}
 152.231 -
 152.232 -static void vSoundCallback(void * _pvUserData, u8 * _puiStream, int _iLen)
 152.233 -{
 152.234 -  if (! emulating)
 152.235 -  {
 152.236 -    return;
 152.237 -  }
 152.238 -
 152.239 -  SDL_mutexP(pstSoundMutex);
 152.240 -  if (! speedup && GUI()->iGetThrottle() == 0)
 152.241 -  {
 152.242 -    while (iSoundLen < iSoundTotalLen && emulating)
 152.243 -    {
 152.244 -      SDL_CondWait(pstSoundCond, pstSoundMutex);
 152.245 -    }
 152.246 -  }
 152.247 -  if (emulating)
 152.248 -  {
 152.249 -    memcpy(_puiStream, auiSoundBuffer, _iLen);
 152.250 -  }
 152.251 -  iSoundLen = 0;
 152.252 -  SDL_mutexV(pstSoundMutex);
 152.253 -}
 152.254 -
 152.255 -bool systemSoundInit()
 152.256 -{
 152.257 -  SDL_AudioSpec stAudio;
 152.258 -
 152.259 -  switch (soundQuality)
 152.260 -  {
 152.261 -  case 1:
 152.262 -    stAudio.freq = 44100;
 152.263 -    soundBufferLen = 1470 * 2;
 152.264 -    break;
 152.265 -  case 2:
 152.266 -    stAudio.freq = 22050;
 152.267 -    soundBufferLen = 736 * 2;
 152.268 -    break;
 152.269 -  case 4:
 152.270 -    stAudio.freq = 11025;
 152.271 -    soundBufferLen = 368 * 2;
 152.272 -    break;
 152.273 -  }
 152.274 -
 152.275 -  stAudio.format   = AUDIO_S16SYS;
 152.276 -  stAudio.channels = 2;
 152.277 -  stAudio.samples  = iSoundSamples;
 152.278 -  stAudio.callback = vSoundCallback;
 152.279 -  stAudio.userdata = NULL;
 152.280 -
 152.281 -  if (SDL_OpenAudio(&stAudio, NULL) < 0)
 152.282 -  {
 152.283 -    fprintf(stderr, "Failed to open audio: %s\n", SDL_GetError());
 152.284 -    return false;
 152.285 -  }
 152.286 -
 152.287 -  pstSoundCond  = SDL_CreateCond();
 152.288 -  pstSoundMutex = SDL_CreateMutex();
 152.289 -
 152.290 -  soundBufferTotalLen = soundBufferLen * 10;
 152.291 -  iSoundLen = 0;
 152.292 -  systemSoundOn = true;
 152.293 -
 152.294 -  return true;
 152.295 -}
 152.296 -
 152.297 -void systemSoundShutdown()
 152.298 -{
 152.299 -  SDL_mutexP(pstSoundMutex);
 152.300 -  int iSave = emulating;
 152.301 -  emulating = 0;
 152.302 -  SDL_CondSignal(pstSoundCond);
 152.303 -  SDL_mutexV(pstSoundMutex);
 152.304 -
 152.305 -  SDL_DestroyCond(pstSoundCond);
 152.306 -  pstSoundCond = NULL;
 152.307 -
 152.308 -  SDL_DestroyMutex(pstSoundMutex);
 152.309 -  pstSoundMutex = NULL;
 152.310 -
 152.311 -  SDL_CloseAudio();
 152.312 -
 152.313 -  emulating = iSave;
 152.314 -  systemSoundOn = false;
 152.315 -}
 152.316 -
 152.317 -void systemSoundPause()
 152.318 -{
 152.319 -  SDL_PauseAudio(1);
 152.320 -}
 152.321 -
 152.322 -void systemSoundResume()
 152.323 -{
 152.324 -  SDL_PauseAudio(0);
 152.325 -}
 152.326 -
 152.327 -void systemSoundReset()
 152.328 -{
 152.329 -}
 152.330 -
 152.331 -u32 systemGetClock()
 152.332 -{
 152.333 -  return SDL_GetTicks();
 152.334 -}
 152.335 -
 152.336 -void systemUpdateMotionSensor()
 152.337 -{
 152.338 -}
 152.339 -
 152.340 -int systemGetSensorX()
 152.341 -{
 152.342 -  return 0;
 152.343 -}
 152.344 -
 152.345 -int systemGetSensorY()
 152.346 -{
 152.347 -  return 0;
 152.348 -}
 152.349 -
 152.350 -void systemGbPrint(u8 * _puiData,
 152.351 -                   int  _iPages,
 152.352 -                   int  _iFeed,
 152.353 -                   int  _iPalette,
 152.354 -                   int  _iContrast)
 152.355 -{
 152.356 -}
 152.357 -
 152.358 -void systemScreenMessage(const char * _csMsg, int slot, int duration, const char *colorList)
 152.359 -{
 152.360 -}
 152.361 -
 152.362 -bool systemCanChangeSoundQuality()
 152.363 -{
 152.364 -  return true;
 152.365 -}
 152.366 -
 152.367 -bool systemPauseOnFrame()
 152.368 -{
 152.369 -  return false;
 152.370 -}
 152.371 -
 152.372 -void systemGbBorderOn()
 152.373 -{
 152.374 -}
 152.375 -
 152.376 -void debuggerMain()
 152.377 -{
 152.378 -}
 152.379 -
 152.380 -void debuggerSignal(int, int)
 152.381 -{
 152.382 -}
 152.383 -
 152.384 -void debuggerOutput(char *, u32)
 152.385 -{
 152.386 -}
 152.387 -
 152.388 -char *sdlGetFilename(char *name)
 152.389 -{
 152.390 -  static char filebuffer[2048];
 152.391 -
 152.392 -  int len = strlen(name);
 152.393 -  
 152.394 -  char *p = name + len - 1;
 152.395 -  
 152.396 -  while(true) {
 152.397 -    if(*p == '/' ||
 152.398 -       *p == '\\') {
 152.399 -      p++;
 152.400 -      break;
 152.401 -    }
 152.402 -    len--;
 152.403 -    p--;
 152.404 -    if(len == 0)
 152.405 -      break;
 152.406 -  }
 152.407 -  
 152.408 -  if(len == 0)
 152.409 -    strcpy(filebuffer, name);
 152.410 -  else
 152.411 -    strcpy(filebuffer, p);
 152.412 -  return filebuffer;
 152.413 -}
 152.414 -
 152.415 -bool sdlCheckJoyKey(int key)
 152.416 -{
 152.417 -  int dev = (key >> 12) - 1;
 152.418 -  int what = key & 0xfff;
 152.419 -
 152.420 -  if(what >= 128) {
 152.421 -    // joystick button
 152.422 -    int button = what - 128;
 152.423 -
 152.424 -    if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
 152.425 -      return false;
 152.426 -  } else if (what < 0x20) {
 152.427 -    // joystick axis    
 152.428 -    what >>= 1;
 152.429 -    if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
 152.430 -      return false;
 152.431 -  } else if (what < 0x30) {
 152.432 -    // joystick hat
 152.433 -    what = (what & 15);
 152.434 -    what >>= 2;
 152.435 -    if(what >= SDL_JoystickNumHats(sdlDevices[dev]))
 152.436 -      return false;
 152.437 -  }
 152.438 -
 152.439 -  // no problem found
 152.440 -  return true;
 152.441 -}
 152.442 -
 152.443 -u16 checksumBIOS()
 152.444 -{
 152.445 -	bool hasBIOS = false;
 152.446 -	u8 * tempBIOS;
 152.447 -	if(useBios)
 152.448 -	{
 152.449 -		tempBIOS = (u8 *)malloc(0x4000);
 152.450 -		int size = 0x4000;
 152.451 -		if(utilLoad(biosFileName,
 152.452 -					utilIsGBABios,
 152.453 -					tempBIOS,
 152.454 -					size)) {
 152.455 -		if(size == 0x4000)
 152.456 -			hasBIOS = true;
 152.457 -		}
 152.458 -	}
 152.459 -
 152.460 -	u16 biosCheck = 0;
 152.461 -	if(hasBIOS) {
 152.462 -		for(int i = 0; i < 0x4000; i += 4)
 152.463 -			biosCheck += *((u32 *)&tempBIOS[i]);
 152.464 -		free(tempBIOS);
 152.465 -	}
 152.466 -
 152.467 -	return biosCheck;
 152.468 -}
 152.469 -
 152.470 -void (*dbgMain)() = debuggerMain;
 152.471 -void (*dbgSignal)(int, int) = debuggerSignal;
 152.472 -void (*dbgOutput)(char *, u32) = debuggerOutput;
   153.1 --- a/src/gtk/tools.cpp	Sat Mar 03 10:54:39 2012 -0600
   153.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   153.3 @@ -1,65 +0,0 @@
   153.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   153.5 -// Copyright (C) 1999-2003 Forgotten
   153.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   153.7 -
   153.8 -// This program is free software; you can redistribute it and/or modify
   153.9 -// it under the terms of the GNU General Public License as published by
  153.10 -// the Free Software Foundation; either version 2, or(at your option)
  153.11 -// any later version.
  153.12 -//
  153.13 -// This program is distributed in the hope that it will be useful,
  153.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  153.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  153.16 -// GNU General Public License for more details.
  153.17 -//
  153.18 -// You should have received a copy of the GNU General Public License
  153.19 -// along with this program; if not, write to the Free Software Foundation,
  153.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  153.21 -
  153.22 -#include "tools.h"
  153.23 -
  153.24 -namespace VBA
  153.25 -{
  153.26 -
  153.27 -std::string sCutSuffix(const std::string & _rsString,
  153.28 -                       const std::string & _rsSep)
  153.29 -{
  153.30 -  return _rsString.substr(0, _rsString.find_last_of(_rsSep));
  153.31 -}
  153.32 -
  153.33 -Glib::ustring sCutSuffix(const Glib::ustring & _rsString,
  153.34 -                         const Glib::ustring & _rsSep)
  153.35 -{
  153.36 -  return _rsString.substr(0, _rsString.find_last_of(_rsSep));
  153.37 -}
  153.38 -
  153.39 -bool bHasSuffix(const Glib::ustring & _rsString,
  153.40 -                const Glib::ustring & _rsSuffix,
  153.41 -                bool _bCaseSensitive)
  153.42 -{
  153.43 -  if (_rsSuffix.size() > _rsString.size())
  153.44 -  {
  153.45 -    return false;
  153.46 -  }
  153.47 -
  153.48 -  Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
  153.49 -
  153.50 -  if (_bCaseSensitive)
  153.51 -  {
  153.52 -    if (_rsSuffix == sEnd)
  153.53 -    {
  153.54 -      return true;
  153.55 -    }
  153.56 -  }
  153.57 -  else
  153.58 -  {
  153.59 -    if (_rsSuffix.lowercase() == sEnd.lowercase())
  153.60 -    {
  153.61 -      return true;
  153.62 -    }
  153.63 -  }
  153.64 -
  153.65 -  return false;
  153.66 -}
  153.67 -
  153.68 -} // namespace VBA
   154.1 --- a/src/gtk/tools.h	Sat Mar 03 10:54:39 2012 -0600
   154.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   154.3 @@ -1,42 +0,0 @@
   154.4 -// -*- C++ -*-
   154.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   154.6 -// Copyright (C) 1999-2003 Forgotten
   154.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   154.8 -
   154.9 -// This program is free software; you can redistribute it and/or modify
  154.10 -// it under the terms of the GNU General Public License as published by
  154.11 -// the Free Software Foundation; either version 2, or(at your option)
  154.12 -// any later version.
  154.13 -//
  154.14 -// This program is distributed in the hope that it will be useful,
  154.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  154.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  154.17 -// GNU General Public License for more details.
  154.18 -//
  154.19 -// You should have received a copy of the GNU General Public License
  154.20 -// along with this program; if not, write to the Free Software Foundation,
  154.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  154.22 -
  154.23 -#ifndef __VBA_TOOLS_H__
  154.24 -#define __VBA_TOOLS_H__
  154.25 -
  154.26 -#include <string>
  154.27 -#include <glibmm/ustring.h>
  154.28 -
  154.29 -namespace VBA
  154.30 -{
  154.31 -
  154.32 -std::string sCutSuffix(const std::string & _rsString,
  154.33 -                       const std::string & _rsSep = ".");
  154.34 -
  154.35 -Glib::ustring sCutSuffix(const Glib::ustring & _rsString,
  154.36 -                         const Glib::ustring & _rsSep = ".");
  154.37 -
  154.38 -bool bHasSuffix(const Glib::ustring & _rsString,
  154.39 -                const Glib::ustring & _rsSuffix,
  154.40 -                bool _bCaseSensitive = true);
  154.41 -
  154.42 -}
  154.43 -
  154.44 -
  154.45 -#endif // __VBA_TOOLS_H__
   155.1 --- a/src/gtk/vba.glade	Sat Mar 03 10:54:39 2012 -0600
   155.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   155.3 @@ -1,3597 +0,0 @@
   155.4 -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
   155.5 -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
   155.6 -
   155.7 -<glade-interface>
   155.8 -
   155.9 -<widget class="GtkWindow" id="MainWindow">
  155.10 -  <property name="title" translatable="yes">VBA</property>
  155.11 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  155.12 -  <property name="window_position">GTK_WIN_POS_NONE</property>
  155.13 -  <property name="modal">False</property>
  155.14 -  <property name="resizable">True</property>
  155.15 -  <property name="destroy_with_parent">False</property>
  155.16 -  <property name="skip_taskbar_hint">False</property>
  155.17 -  <property name="skip_pager_hint">False</property>
  155.18 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  155.19 -
  155.20 -  <child>
  155.21 -    <widget class="GtkVBox" id="vbox1">
  155.22 -      <property name="visible">True</property>
  155.23 -      <property name="homogeneous">False</property>
  155.24 -      <property name="spacing">0</property>
  155.25 -
  155.26 -      <child>
  155.27 -	<widget class="GtkHandleBox" id="handlebox1">
  155.28 -	  <property name="visible">True</property>
  155.29 -	  <property name="shadow_type">GTK_SHADOW_OUT</property>
  155.30 -	  <property name="handle_position">GTK_POS_LEFT</property>
  155.31 -	  <property name="snap_edge">GTK_POS_TOP</property>
  155.32 -
  155.33 -	  <child>
  155.34 -	    <widget class="GtkMenuBar" id="MenuBar">
  155.35 -	      <property name="visible">True</property>
  155.36 -
  155.37 -	      <child>
  155.38 -		<widget class="GtkMenuItem" id="FileMenu">
  155.39 -		  <property name="visible">True</property>
  155.40 -		  <property name="label" translatable="yes">_File</property>
  155.41 -		  <property name="use_underline">True</property>
  155.42 -
  155.43 -		  <child>
  155.44 -		    <widget class="GtkMenu" id="FileMenu_menu">
  155.45 -
  155.46 -		      <child>
  155.47 -			<widget class="GtkImageMenuItem" id="FileOpen">
  155.48 -			  <property name="visible">True</property>
  155.49 -			  <property name="label" translatable="yes">_Open...</property>
  155.50 -			  <property name="use_underline">True</property>
  155.51 -			  <accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
  155.52 -
  155.53 -			  <child internal-child="image">
  155.54 -			    <widget class="GtkImage" id="image128">
  155.55 -			      <property name="visible">True</property>
  155.56 -			      <property name="stock">gtk-open</property>
  155.57 -			      <property name="icon_size">1</property>
  155.58 -			      <property name="xalign">0.5</property>
  155.59 -			      <property name="yalign">0.5</property>
  155.60 -			      <property name="xpad">0</property>
  155.61 -			      <property name="ypad">0</property>
  155.62 -			    </widget>
  155.63 -			  </child>
  155.64 -			</widget>
  155.65 -		      </child>
  155.66 -
  155.67 -		      <child>
  155.68 -			<widget class="GtkSeparatorMenuItem" id="separator1">
  155.69 -			  <property name="visible">True</property>
  155.70 -			</widget>
  155.71 -		      </child>
  155.72 -
  155.73 -		      <child>
  155.74 -			<widget class="GtkMenuItem" id="FileLoad">
  155.75 -			  <property name="visible">True</property>
  155.76 -			  <property name="label" translatable="yes">_Load...</property>
  155.77 -			  <property name="use_underline">True</property>
  155.78 -			  <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
  155.79 -			</widget>
  155.80 -		      </child>
  155.81 -
  155.82 -		      <child>
  155.83 -			<widget class="GtkMenuItem" id="FileSave">
  155.84 -			  <property name="visible">True</property>
  155.85 -			  <property name="label" translatable="yes">_Save...</property>
  155.86 -			  <property name="use_underline">True</property>
  155.87 -			  <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
  155.88 -			</widget>
  155.89 -		      </child>
  155.90 -
  155.91 -		      <child>
  155.92 -			<widget class="GtkMenuItem" id="LoadGameMenu">
  155.93 -			  <property name="visible">True</property>
  155.94 -			  <property name="label" translatable="yes">Loa_d game</property>
  155.95 -			  <property name="use_underline">True</property>
  155.96 -
  155.97 -			  <child>
  155.98 -			    <widget class="GtkMenu" id="LoadGameMenu_menu">
  155.99 -
 155.100 -			      <child>
 155.101 -				<widget class="GtkMenuItem" id="LoadGameMostRecent">
 155.102 -				  <property name="visible">True</property>
 155.103 -				  <property name="label" translatable="yes">Most recent</property>
 155.104 -				  <property name="use_underline">True</property>
 155.105 -				</widget>
 155.106 -			      </child>
 155.107 -
 155.108 -			      <child>
 155.109 -				<widget class="GtkCheckMenuItem" id="LoadGameAuto">
 155.110 -				  <property name="visible">True</property>
 155.111 -				  <property name="label" translatable="yes">Auto load most recent</property>
 155.112 -				  <property name="use_underline">True</property>
 155.113 -				  <property name="active">False</property>
 155.114 -				</widget>
 155.115 -			      </child>
 155.116 -
 155.117 -			      <child>
 155.118 -				<widget class="GtkSeparatorMenuItem" id="separator28">
 155.119 -				  <property name="visible">True</property>
 155.120 -				</widget>
 155.121 -			      </child>
 155.122 -
 155.123 -			      <child>
 155.124 -				<widget class="GtkMenuItem" id="LoadGameSlot1">
 155.125 -				  <property name="visible">True</property>
 155.126 -				  <property name="label" translatable="yes">Slot1</property>
 155.127 -				  <property name="use_underline">True</property>
 155.128 -				  <accelerator key="F1" modifiers="0" signal="activate"/>
 155.129 -				</widget>
 155.130 -			      </child>
 155.131 -
 155.132 -			      <child>
 155.133 -				<widget class="GtkMenuItem" id="LoadGameSlot2">
 155.134 -				  <property name="visible">True</property>
 155.135 -				  <property name="label" translatable="yes">Slot2</property>
 155.136 -				  <property name="use_underline">True</property>
 155.137 -				  <accelerator key="F2" modifiers="0" signal="activate"/>
 155.138 -				</widget>
 155.139 -			      </child>
 155.140 -
 155.141 -			      <child>
 155.142 -				<widget class="GtkMenuItem" id="LoadGameSlot3">
 155.143 -				  <property name="visible">True</property>
 155.144 -				  <property name="label" translatable="yes">Slot3</property>
 155.145 -				  <property name="use_underline">True</property>
 155.146 -				  <accelerator key="F3" modifiers="0" signal="activate"/>
 155.147 -				</widget>
 155.148 -			      </child>
 155.149 -
 155.150 -			      <child>
 155.151 -				<widget class="GtkMenuItem" id="LoadGameSlot4">
 155.152 -				  <property name="visible">True</property>
 155.153 -				  <property name="label" translatable="yes">Slot4</property>
 155.154 -				  <property name="use_underline">True</property>
 155.155 -				  <accelerator key="F4" modifiers="0" signal="activate"/>
 155.156 -				</widget>
 155.157 -			      </child>
 155.158 -
 155.159 -			      <child>
 155.160 -				<widget class="GtkMenuItem" id="LoadGameSlot5">
 155.161 -				  <property name="visible">True</property>
 155.162 -				  <property name="label" translatable="yes">Slot5</property>
 155.163 -				  <property name="use_underline">True</property>
 155.164 -				  <accelerator key="F5" modifiers="0" signal="activate"/>
 155.165 -				</widget>
 155.166 -			      </child>
 155.167 -
 155.168 -			      <child>
 155.169 -				<widget class="GtkMenuItem" id="LoadGameSlot6">
 155.170 -				  <property name="visible">True</property>
 155.171 -				  <property name="label" translatable="yes">Slot6</property>
 155.172 -				  <property name="use_underline">True</property>
 155.173 -				  <accelerator key="F6" modifiers="0" signal="activate"/>
 155.174 -				</widget>
 155.175 -			      </child>
 155.176 -
 155.177 -			      <child>
 155.178 -				<widget class="GtkMenuItem" id="LoadGameSlot7">
 155.179 -				  <property name="visible">True</property>
 155.180 -				  <property name="label" translatable="yes">Slot7</property>
 155.181 -				  <property name="use_underline">True</property>
 155.182 -				  <accelerator key="F7" modifiers="0" signal="activate"/>
 155.183 -				</widget>
 155.184 -			      </child>
 155.185 -
 155.186 -			      <child>
 155.187 -				<widget class="GtkMenuItem" id="LoadGameSlot8">
 155.188 -				  <property name="visible">True</property>
 155.189 -				  <property name="label" translatable="yes">Slot8</property>
 155.190 -				  <property name="use_underline">True</property>
 155.191 -				  <accelerator key="F8" modifiers="0" signal="activate"/>
 155.192 -				</widget>
 155.193 -			      </child>
 155.194 -
 155.195 -			      <child>
 155.196 -				<widget class="GtkMenuItem" id="LoadGameSlot9">
 155.197 -				  <property name="visible">True</property>
 155.198 -				  <property name="label" translatable="yes">Slot9</property>
 155.199 -				  <property name="use_underline">True</property>
 155.200 -				  <accelerator key="F9" modifiers="0" signal="activate"/>
 155.201 -				</widget>
 155.202 -			      </child>
 155.203 -
 155.204 -			      <child>
 155.205 -				<widget class="GtkMenuItem" id="LoadGameSlot10">
 155.206 -				  <property name="visible">True</property>
 155.207 -				  <property name="label" translatable="yes">Slot10</property>
 155.208 -				  <property name="use_underline">True</property>
 155.209 -				  <accelerator key="F10" modifiers="0" signal="activate"/>
 155.210 -				</widget>
 155.211 -			      </child>
 155.212 -			    </widget>
 155.213 -			  </child>
 155.214 -			</widget>
 155.215 -		      </child>
 155.216 -
 155.217 -		      <child>
 155.218 -			<widget class="GtkMenuItem" id="SaveGameMenu">
 155.219 -			  <property name="visible">True</property>
 155.220 -			  <property name="label" translatable="yes">S_ave game</property>
 155.221 -			  <property name="use_underline">True</property>
 155.222 -
 155.223 -			  <child>
 155.224 -			    <widget class="GtkMenu" id="SaveGameMenu_menu">
 155.225 -
 155.226 -			      <child>
 155.227 -				<widget class="GtkMenuItem" id="SaveGameOldest">
 155.228 -				  <property name="visible">True</property>
 155.229 -				  <property name="label" translatable="yes">Oldest slot</property>
 155.230 -				  <property name="use_underline">True</property>
 155.231 -				</widget>
 155.232 -			      </child>
 155.233 -
 155.234 -			      <child>
 155.235 -				<widget class="GtkSeparatorMenuItem" id="separator27">
 155.236 -				  <property name="visible">True</property>
 155.237 -				</widget>
 155.238 -			      </child>
 155.239 -
 155.240 -			      <child>
 155.241 -				<widget class="GtkMenuItem" id="SaveGameSlot1">
 155.242 -				  <property name="visible">True</property>
 155.243 -				  <property name="label" translatable="yes">Slot1</property>
 155.244 -				  <property name="use_underline">True</property>
 155.245 -				  <accelerator key="F1" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.246 -				</widget>
 155.247 -			      </child>
 155.248 -
 155.249 -			      <child>
 155.250 -				<widget class="GtkMenuItem" id="SaveGameSlot2">
 155.251 -				  <property name="visible">True</property>
 155.252 -				  <property name="label" translatable="yes">Slot2</property>
 155.253 -				  <property name="use_underline">True</property>
 155.254 -				  <accelerator key="F2" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.255 -				</widget>
 155.256 -			      </child>
 155.257 -
 155.258 -			      <child>
 155.259 -				<widget class="GtkMenuItem" id="SaveGameSlot3">
 155.260 -				  <property name="visible">True</property>
 155.261 -				  <property name="label" translatable="yes">Slot3</property>
 155.262 -				  <property name="use_underline">True</property>
 155.263 -				  <accelerator key="F3" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.264 -				</widget>
 155.265 -			      </child>
 155.266 -
 155.267 -			      <child>
 155.268 -				<widget class="GtkMenuItem" id="SaveGameSlot4">
 155.269 -				  <property name="visible">True</property>
 155.270 -				  <property name="label" translatable="yes">Slot4</property>
 155.271 -				  <property name="use_underline">True</property>
 155.272 -				  <accelerator key="F4" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.273 -				</widget>
 155.274 -			      </child>
 155.275 -
 155.276 -			      <child>
 155.277 -				<widget class="GtkMenuItem" id="SaveGameSlot5">
 155.278 -				  <property name="visible">True</property>
 155.279 -				  <property name="label" translatable="yes">Slot5</property>
 155.280 -				  <property name="use_underline">True</property>
 155.281 -				  <accelerator key="F5" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.282 -				</widget>
 155.283 -			      </child>
 155.284 -
 155.285 -			      <child>
 155.286 -				<widget class="GtkMenuItem" id="SaveGameSlot6">
 155.287 -				  <property name="visible">True</property>
 155.288 -				  <property name="label" translatable="yes">Slot6</property>
 155.289 -				  <property name="use_underline">True</property>
 155.290 -				  <accelerator key="F6" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.291 -				</widget>
 155.292 -			      </child>
 155.293 -
 155.294 -			      <child>
 155.295 -				<widget class="GtkMenuItem" id="SaveGameSlot7">
 155.296 -				  <property name="visible">True</property>
 155.297 -				  <property name="label" translatable="yes">Slot7</property>
 155.298 -				  <property name="use_underline">True</property>
 155.299 -				  <accelerator key="F7" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.300 -				</widget>
 155.301 -			      </child>
 155.302 -
 155.303 -			      <child>
 155.304 -				<widget class="GtkMenuItem" id="SaveGameSlot8">
 155.305 -				  <property name="visible">True</property>
 155.306 -				  <property name="label" translatable="yes">Slot8</property>
 155.307 -				  <property name="use_underline">True</property>
 155.308 -				  <accelerator key="F8" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.309 -				</widget>
 155.310 -			      </child>
 155.311 -
 155.312 -			      <child>
 155.313 -				<widget class="GtkMenuItem" id="SaveGameSlot9">
 155.314 -				  <property name="visible">True</property>
 155.315 -				  <property name="label" translatable="yes">Slot9</property>
 155.316 -				  <property name="use_underline">True</property>
 155.317 -				  <accelerator key="F9" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.318 -				</widget>
 155.319 -			      </child>
 155.320 -
 155.321 -			      <child>
 155.322 -				<widget class="GtkMenuItem" id="SaveGameSlot10">
 155.323 -				  <property name="visible">True</property>
 155.324 -				  <property name="label" translatable="yes">Slot10</property>
 155.325 -				  <property name="use_underline">True</property>
 155.326 -				  <accelerator key="F10" modifiers="GDK_SHIFT_MASK" signal="activate"/>
 155.327 -				</widget>
 155.328 -			      </child>
 155.329 -			    </widget>
 155.330 -			  </child>
 155.331 -			</widget>
 155.332 -		      </child>
 155.333 -
 155.334 -		      <child>
 155.335 -			<widget class="GtkSeparatorMenuItem" id="separator2">
 155.336 -			  <property name="visible">True</property>
 155.337 -			</widget>
 155.338 -		      </child>
 155.339 -
 155.340 -		      <child>
 155.341 -			<widget class="GtkCheckMenuItem" id="FilePause">
 155.342 -			  <property name="visible">True</property>
 155.343 -			  <property name="label" translatable="yes">_Pause</property>
 155.344 -			  <property name="use_underline">True</property>
 155.345 -			  <property name="active">False</property>
 155.346 -			  <accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.347 -			</widget>
 155.348 -		      </child>
 155.349 -
 155.350 -		      <child>
 155.351 -			<widget class="GtkMenuItem" id="FileReset">
 155.352 -			  <property name="visible">True</property>
 155.353 -			  <property name="label" translatable="yes">_Reset</property>
 155.354 -			  <property name="use_underline">True</property>
 155.355 -			  <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.356 -			</widget>
 155.357 -		      </child>
 155.358 -
 155.359 -		      <child>
 155.360 -			<widget class="GtkSeparatorMenuItem" id="separator3">
 155.361 -			  <property name="visible">True</property>
 155.362 -			</widget>
 155.363 -		      </child>
 155.364 -
 155.365 -		      <child>
 155.366 -			<widget class="GtkMenuItem" id="RecentMenu">
 155.367 -			  <property name="visible">True</property>
 155.368 -			  <property name="label" translatable="yes">Rece_nt</property>
 155.369 -			  <property name="use_underline">True</property>
 155.370 -
 155.371 -			  <child>
 155.372 -			    <widget class="GtkMenu" id="RecentMenu_menu">
 155.373 -
 155.374 -			      <child>
 155.375 -				<widget class="GtkMenuItem" id="RecentReset">
 155.376 -				  <property name="visible">True</property>
 155.377 -				  <property name="label" translatable="yes">_Reset</property>
 155.378 -				  <property name="use_underline">True</property>
 155.379 -				</widget>
 155.380 -			      </child>
 155.381 -
 155.382 -			      <child>
 155.383 -				<widget class="GtkCheckMenuItem" id="RecentFreeze">
 155.384 -				  <property name="visible">True</property>
 155.385 -				  <property name="label" translatable="yes">_Freeze</property>
 155.386 -				  <property name="use_underline">True</property>
 155.387 -				  <property name="active">False</property>
 155.388 -				</widget>
 155.389 -			      </child>
 155.390 -
 155.391 -			      <child>
 155.392 -				<widget class="GtkSeparatorMenuItem" id="separator29">
 155.393 -				  <property name="visible">True</property>
 155.394 -				</widget>
 155.395 -			      </child>
 155.396 -			    </widget>
 155.397 -			  </child>
 155.398 -			</widget>
 155.399 -		      </child>
 155.400 -
 155.401 -		      <child>
 155.402 -			<widget class="GtkSeparatorMenuItem" id="separator4">
 155.403 -			  <property name="visible">True</property>
 155.404 -			</widget>
 155.405 -		      </child>
 155.406 -
 155.407 -		      <child>
 155.408 -			<widget class="GtkMenuItem" id="ImportMenu">
 155.409 -			  <property name="visible">True</property>
 155.410 -			  <property name="label" translatable="yes">_Import</property>
 155.411 -			  <property name="use_underline">True</property>
 155.412 -
 155.413 -			  <child>
 155.414 -			    <widget class="GtkMenu" id="ImportMenu_menu">
 155.415 -
 155.416 -			      <child>
 155.417 -				<widget class="GtkMenuItem" id="ImportBatteryFile">
 155.418 -				  <property name="visible">True</property>
 155.419 -				  <property name="label" translatable="yes">_Battery file...</property>
 155.420 -				  <property name="use_underline">True</property>
 155.421 -				</widget>
 155.422 -			      </child>
 155.423 -			    </widget>
 155.424 -			  </child>
 155.425 -			</widget>
 155.426 -		      </child>
 155.427 -
 155.428 -		      <child>
 155.429 -			<widget class="GtkMenuItem" id="ExportMenu">
 155.430 -			  <property name="visible">True</property>
 155.431 -			  <property name="label" translatable="yes">E_xport</property>
 155.432 -			  <property name="use_underline">True</property>
 155.433 -
 155.434 -			  <child>
 155.435 -			    <widget class="GtkMenu" id="ExportMenu_menu">
 155.436 -
 155.437 -			      <child>
 155.438 -				<widget class="GtkMenuItem" id="ExportBatteryFile">
 155.439 -				  <property name="visible">True</property>
 155.440 -				  <property name="label" translatable="yes">_Battery file...</property>
 155.441 -				  <property name="use_underline">True</property>
 155.442 -				</widget>
 155.443 -			      </child>
 155.444 -			    </widget>
 155.445 -			  </child>
 155.446 -			</widget>
 155.447 -		      </child>
 155.448 -
 155.449 -		      <child>
 155.450 -			<widget class="GtkSeparatorMenuItem" id="separator5">
 155.451 -			  <property name="visible">True</property>
 155.452 -			</widget>
 155.453 -		      </child>
 155.454 -
 155.455 -		      <child>
 155.456 -			<widget class="GtkMenuItem" id="FileScreenCapture">
 155.457 -			  <property name="visible">True</property>
 155.458 -			  <property name="label" translatable="yes">Screen capt_ure...</property>
 155.459 -			  <property name="use_underline">True</property>
 155.460 -			</widget>
 155.461 -		      </child>
 155.462 -
 155.463 -		      <child>
 155.464 -			<widget class="GtkSeparatorMenuItem" id="separator6">
 155.465 -			  <property name="visible">True</property>
 155.466 -			</widget>
 155.467 -		      </child>
 155.468 -
 155.469 -		      <child>
 155.470 -			<widget class="GtkImageMenuItem" id="FileClose">
 155.471 -			  <property name="visible">True</property>
 155.472 -			  <property name="label" translatable="yes">_Close</property>
 155.473 -			  <property name="use_underline">True</property>
 155.474 -
 155.475 -			  <child internal-child="image">
 155.476 -			    <widget class="GtkImage" id="image129">
 155.477 -			      <property name="visible">True</property>
 155.478 -			      <property name="stock">gtk-close</property>
 155.479 -			      <property name="icon_size">1</property>
 155.480 -			      <property name="xalign">0.5</property>
 155.481 -			      <property name="yalign">0.5</property>
 155.482 -			      <property name="xpad">0</property>
 155.483 -			      <property name="ypad">0</property>
 155.484 -			    </widget>
 155.485 -			  </child>
 155.486 -			</widget>
 155.487 -		      </child>
 155.488 -
 155.489 -		      <child>
 155.490 -			<widget class="GtkImageMenuItem" id="FileExit">
 155.491 -			  <property name="visible">True</property>
 155.492 -			  <property name="label" translatable="yes">_Exit</property>
 155.493 -			  <property name="use_underline">True</property>
 155.494 -			  <accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.495 -
 155.496 -			  <child internal-child="image">
 155.497 -			    <widget class="GtkImage" id="image130">
 155.498 -			      <property name="visible">True</property>
 155.499 -			      <property name="stock">gtk-quit</property>
 155.500 -			      <property name="icon_size">1</property>
 155.501 -			      <property name="xalign">0.5</property>
 155.502 -			      <property name="yalign">0.5</property>
 155.503 -			      <property name="xpad">0</property>
 155.504 -			      <property name="ypad">0</property>
 155.505 -			    </widget>
 155.506 -			  </child>
 155.507 -			</widget>
 155.508 -		      </child>
 155.509 -		    </widget>
 155.510 -		  </child>
 155.511 -		</widget>
 155.512 -	      </child>
 155.513 -
 155.514 -	      <child>
 155.515 -		<widget class="GtkMenuItem" id="OptionsMenu">
 155.516 -		  <property name="visible">True</property>
 155.517 -		  <property name="label" translatable="yes">_Options</property>
 155.518 -		  <property name="use_underline">True</property>
 155.519 -
 155.520 -		  <child>
 155.521 -		    <widget class="GtkMenu" id="OptionsMenu_menu">
 155.522 -
 155.523 -		      <child>
 155.524 -			<widget class="GtkMenuItem" id="FrameskipMenu">
 155.525 -			  <property name="visible">True</property>
 155.526 -			  <property name="label" translatable="yes">_Frameskip</property>
 155.527 -			  <property name="use_underline">True</property>
 155.528 -
 155.529 -			  <child>
 155.530 -			    <widget class="GtkMenu" id="FrameskipMenu_menu">
 155.531 -
 155.532 -			      <child>
 155.533 -				<widget class="GtkMenuItem" id="ThrottleMenu">
 155.534 -				  <property name="visible">True</property>
 155.535 -				  <property name="label" translatable="yes">_Throttle</property>
 155.536 -				  <property name="use_underline">True</property>
 155.537 -
 155.538 -				  <child>
 155.539 -				    <widget class="GtkMenu" id="ThrottleMenu_menu">
 155.540 -
 155.541 -				      <child>
 155.542 -					<widget class="GtkRadioMenuItem" id="ThrottleNoThrottle">
 155.543 -					  <property name="visible">True</property>
 155.544 -					  <property name="label" translatable="yes">_No throttle</property>
 155.545 -					  <property name="use_underline">True</property>
 155.546 -					  <property name="active">True</property>
 155.547 -					</widget>
 155.548 -				      </child>
 155.549 -
 155.550 -				      <child>
 155.551 -					<widget class="GtkRadioMenuItem" id="Throttle25">
 155.552 -					  <property name="visible">True</property>
 155.553 -					  <property name="label" translatable="yes">25%</property>
 155.554 -					  <property name="use_underline">True</property>
 155.555 -					  <property name="active">False</property>
 155.556 -					  <property name="group">ThrottleNoThrottle</property>
 155.557 -					</widget>
 155.558 -				      </child>
 155.559 -
 155.560 -				      <child>
 155.561 -					<widget class="GtkRadioMenuItem" id="Throttle50">
 155.562 -					  <property name="visible">True</property>
 155.563 -					  <property name="label" translatable="yes">50%</property>
 155.564 -					  <property name="use_underline">True</property>
 155.565 -					  <property name="active">False</property>
 155.566 -					  <property name="group">ThrottleNoThrottle</property>
 155.567 -					</widget>
 155.568 -				      </child>
 155.569 -
 155.570 -				      <child>
 155.571 -					<widget class="GtkRadioMenuItem" id="Throttle100">
 155.572 -					  <property name="visible">True</property>
 155.573 -					  <property name="label" translatable="yes">100%</property>
 155.574 -					  <property name="use_underline">True</property>
 155.575 -					  <property name="active">False</property>
 155.576 -					  <property name="group">ThrottleNoThrottle</property>
 155.577 -					</widget>
 155.578 -				      </child>
 155.579 -
 155.580 -				      <child>
 155.581 -					<widget class="GtkRadioMenuItem" id="Throttle150">
 155.582 -					  <property name="visible">True</property>
 155.583 -					  <property name="label" translatable="yes">150%</property>
 155.584 -					  <property name="use_underline">True</property>
 155.585 -					  <property name="active">False</property>
 155.586 -					  <property name="group">ThrottleNoThrottle</property>
 155.587 -					</widget>
 155.588 -				      </child>
 155.589 -
 155.590 -				      <child>
 155.591 -					<widget class="GtkRadioMenuItem" id="Throttle200">
 155.592 -					  <property name="visible">True</property>
 155.593 -					  <property name="label" translatable="yes">200%</property>
 155.594 -					  <property name="use_underline">True</property>
 155.595 -					  <property name="active">False</property>
 155.596 -					  <property name="group">ThrottleNoThrottle</property>
 155.597 -					</widget>
 155.598 -				      </child>
 155.599 -
 155.600 -				      <child>
 155.601 -					<widget class="GtkRadioMenuItem" id="ThrottleOther">
 155.602 -					  <property name="visible">True</property>
 155.603 -					  <property name="label" translatable="yes">_Other...</property>
 155.604 -					  <property name="use_underline">True</property>
 155.605 -					  <property name="active">False</property>
 155.606 -					  <property name="group">ThrottleNoThrottle</property>
 155.607 -					</widget>
 155.608 -				      </child>
 155.609 -				    </widget>
 155.610 -				  </child>
 155.611 -				</widget>
 155.612 -			      </child>
 155.613 -
 155.614 -			      <child>
 155.615 -				<widget class="GtkSeparatorMenuItem" id="separator19">
 155.616 -				  <property name="visible">True</property>
 155.617 -				</widget>
 155.618 -			      </child>
 155.619 -
 155.620 -			      <child>
 155.621 -				<widget class="GtkRadioMenuItem" id="FrameskipAutomatic">
 155.622 -				  <property name="visible">True</property>
 155.623 -				  <property name="label" translatable="yes">_Automatic</property>
 155.624 -				  <property name="use_underline">True</property>
 155.625 -				  <property name="active">True</property>
 155.626 -				</widget>
 155.627 -			      </child>
 155.628 -
 155.629 -			      <child>
 155.630 -				<widget class="GtkRadioMenuItem" id="Frameskip0">
 155.631 -				  <property name="visible">True</property>
 155.632 -				  <property name="label" translatable="yes">_0</property>
 155.633 -				  <property name="use_underline">True</property>
 155.634 -				  <property name="active">False</property>
 155.635 -				  <property name="group">FrameskipAutomatic</property>
 155.636 -				</widget>
 155.637 -			      </child>
 155.638 -
 155.639 -			      <child>
 155.640 -				<widget class="GtkRadioMenuItem" id="Frameskip1">
 155.641 -				  <property name="visible">True</property>
 155.642 -				  <property name="label" translatable="yes">_1</property>
 155.643 -				  <property name="use_underline">True</property>
 155.644 -				  <property name="active">False</property>
 155.645 -				  <property name="group">FrameskipAutomatic</property>
 155.646 -				</widget>
 155.647 -			      </child>
 155.648 -
 155.649 -			      <child>
 155.650 -				<widget class="GtkRadioMenuItem" id="Frameskip2">
 155.651 -				  <property name="visible">True</property>
 155.652 -				  <property name="label" translatable="yes">_2</property>
 155.653 -				  <property name="use_underline">True</property>
 155.654 -				  <property name="active">False</property>
 155.655 -				  <property name="group">FrameskipAutomatic</property>
 155.656 -				</widget>
 155.657 -			      </child>
 155.658 -
 155.659 -			      <child>
 155.660 -				<widget class="GtkRadioMenuItem" id="Frameskip3">
 155.661 -				  <property name="visible">True</property>
 155.662 -				  <property name="label" translatable="yes">_3</property>
 155.663 -				  <property name="use_underline">True</property>
 155.664 -				  <property name="active">False</property>
 155.665 -				  <property name="group">FrameskipAutomatic</property>
 155.666 -				</widget>
 155.667 -			      </child>
 155.668 -
 155.669 -			      <child>
 155.670 -				<widget class="GtkRadioMenuItem" id="Frameskip4">
 155.671 -				  <property name="visible">True</property>
 155.672 -				  <property name="label" translatable="yes">_4</property>
 155.673 -				  <property name="use_underline">True</property>
 155.674 -				  <property name="active">False</property>
 155.675 -				  <property name="group">FrameskipAutomatic</property>
 155.676 -				</widget>
 155.677 -			      </child>
 155.678 -
 155.679 -			      <child>
 155.680 -				<widget class="GtkRadioMenuItem" id="Frameskip5">
 155.681 -				  <property name="visible">True</property>
 155.682 -				  <property name="label" translatable="yes">_5</property>
 155.683 -				  <property name="use_underline">True</property>
 155.684 -				  <property name="active">False</property>
 155.685 -				  <property name="group">FrameskipAutomatic</property>
 155.686 -				</widget>
 155.687 -			      </child>
 155.688 -
 155.689 -			      <child>
 155.690 -				<widget class="GtkRadioMenuItem" id="Frameskip6">
 155.691 -				  <property name="visible">True</property>
 155.692 -				  <property name="label" translatable="yes">_6</property>
 155.693 -				  <property name="use_underline">True</property>
 155.694 -				  <property name="active">False</property>
 155.695 -				  <property name="group">FrameskipAutomatic</property>
 155.696 -				</widget>
 155.697 -			      </child>
 155.698 -
 155.699 -			      <child>
 155.700 -				<widget class="GtkRadioMenuItem" id="Frameskip7">
 155.701 -				  <property name="visible">True</property>
 155.702 -				  <property name="label" translatable="yes">_7</property>
 155.703 -				  <property name="use_underline">True</property>
 155.704 -				  <property name="active">False</property>
 155.705 -				  <property name="group">FrameskipAutomatic</property>
 155.706 -				</widget>
 155.707 -			      </child>
 155.708 -
 155.709 -			      <child>
 155.710 -				<widget class="GtkRadioMenuItem" id="Frameskip8">
 155.711 -				  <property name="visible">True</property>
 155.712 -				  <property name="label" translatable="yes">_8</property>
 155.713 -				  <property name="use_underline">True</property>
 155.714 -				  <property name="active">False</property>
 155.715 -				  <property name="group">FrameskipAutomatic</property>
 155.716 -				</widget>
 155.717 -			      </child>
 155.718 -
 155.719 -			      <child>
 155.720 -				<widget class="GtkRadioMenuItem" id="Frameskip9">
 155.721 -				  <property name="visible">True</property>
 155.722 -				  <property name="label" translatable="yes">_9</property>
 155.723 -				  <property name="use_underline">True</property>
 155.724 -				  <property name="active">False</property>
 155.725 -				  <property name="group">FrameskipAutomatic</property>
 155.726 -				</widget>
 155.727 -			      </child>
 155.728 -			    </widget>
 155.729 -			  </child>
 155.730 -			</widget>
 155.731 -		      </child>
 155.732 -
 155.733 -		      <child>
 155.734 -			<widget class="GtkMenuItem" id="VideoMenu">
 155.735 -			  <property name="visible">True</property>
 155.736 -			  <property name="label" translatable="yes">_Video</property>
 155.737 -			  <property name="use_underline">True</property>
 155.738 -
 155.739 -			  <child>
 155.740 -			    <widget class="GtkMenu" id="VideoMenu_menu">
 155.741 -
 155.742 -			      <child>
 155.743 -				<widget class="GtkRadioMenuItem" id="Video1x">
 155.744 -				  <property name="visible">True</property>
 155.745 -				  <property name="label" translatable="yes">_1x</property>
 155.746 -				  <property name="use_underline">True</property>
 155.747 -				  <property name="active">True</property>
 155.748 -				</widget>
 155.749 -			      </child>
 155.750 -
 155.751 -			      <child>
 155.752 -				<widget class="GtkRadioMenuItem" id="Video2x">
 155.753 -				  <property name="visible">True</property>
 155.754 -				  <property name="label" translatable="yes">_2x</property>
 155.755 -				  <property name="use_underline">True</property>
 155.756 -				  <property name="active">False</property>
 155.757 -				  <property name="group">Video1x</property>
 155.758 -				</widget>
 155.759 -			      </child>
 155.760 -
 155.761 -			      <child>
 155.762 -				<widget class="GtkRadioMenuItem" id="Video3x">
 155.763 -				  <property name="visible">True</property>
 155.764 -				  <property name="label" translatable="yes">_3x</property>
 155.765 -				  <property name="use_underline">True</property>
 155.766 -				  <property name="active">False</property>
 155.767 -				  <property name="group">Video1x</property>
 155.768 -				</widget>
 155.769 -			      </child>
 155.770 -
 155.771 -			      <child>
 155.772 -				<widget class="GtkRadioMenuItem" id="Video4x">
 155.773 -				  <property name="visible">True</property>
 155.774 -				  <property name="label" translatable="yes">_4x</property>
 155.775 -				  <property name="use_underline">True</property>
 155.776 -				  <property name="active">False</property>
 155.777 -				  <property name="group">Video1x</property>
 155.778 -				</widget>
 155.779 -			      </child>
 155.780 -
 155.781 -			      <child>
 155.782 -				<widget class="GtkRadioMenuItem" id="Video5x">
 155.783 -				  <property name="visible">True</property>
 155.784 -				  <property name="label" translatable="yes">_5x</property>
 155.785 -				  <property name="use_underline">True</property>
 155.786 -				  <property name="active">False</property>
 155.787 -				  <property name="group">Video1x</property>
 155.788 -				</widget>
 155.789 -			      </child>
 155.790 -
 155.791 -			      <child>
 155.792 -				<widget class="GtkRadioMenuItem" id="Video6x">
 155.793 -				  <property name="visible">True</property>
 155.794 -				  <property name="label" translatable="yes">_6x</property>
 155.795 -				  <property name="use_underline">True</property>
 155.796 -				  <property name="active">False</property>
 155.797 -				  <property name="group">Video1x</property>
 155.798 -				</widget>
 155.799 -			      </child>
 155.800 -
 155.801 -			      <child>
 155.802 -				<widget class="GtkSeparatorMenuItem" id="separator9">
 155.803 -				  <property name="visible">True</property>
 155.804 -				</widget>
 155.805 -			      </child>
 155.806 -
 155.807 -			      <child>
 155.808 -				<widget class="GtkMenuItem" id="LayersMenu">
 155.809 -				  <property name="visible">True</property>
 155.810 -				  <property name="label" translatable="yes">_Layers</property>
 155.811 -				  <property name="use_underline">True</property>
 155.812 -
 155.813 -				  <child>
 155.814 -				    <widget class="GtkMenu" id="LayersMenu_menu">
 155.815 -
 155.816 -				      <child>
 155.817 -					<widget class="GtkCheckMenuItem" id="LayersBg0">
 155.818 -					  <property name="visible">True</property>
 155.819 -					  <property name="label" translatable="yes">BG0</property>
 155.820 -					  <property name="use_underline">True</property>
 155.821 -					  <property name="active">False</property>
 155.822 -					  <accelerator key="1" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.823 -					</widget>
 155.824 -				      </child>
 155.825 -
 155.826 -				      <child>
 155.827 -					<widget class="GtkCheckMenuItem" id="LayersBg1">
 155.828 -					  <property name="visible">True</property>
 155.829 -					  <property name="label" translatable="yes">BG1</property>
 155.830 -					  <property name="use_underline">True</property>
 155.831 -					  <property name="active">False</property>
 155.832 -					  <accelerator key="2" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.833 -					</widget>
 155.834 -				      </child>
 155.835 -
 155.836 -				      <child>
 155.837 -					<widget class="GtkCheckMenuItem" id="LayersBg2">
 155.838 -					  <property name="visible">True</property>
 155.839 -					  <property name="label" translatable="yes">BG2</property>
 155.840 -					  <property name="use_underline">True</property>
 155.841 -					  <property name="active">False</property>
 155.842 -					  <accelerator key="3" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.843 -					</widget>
 155.844 -				      </child>
 155.845 -
 155.846 -				      <child>
 155.847 -					<widget class="GtkCheckMenuItem" id="LayersBg3">
 155.848 -					  <property name="visible">True</property>
 155.849 -					  <property name="label" translatable="yes">BG3</property>
 155.850 -					  <property name="use_underline">True</property>
 155.851 -					  <property name="active">False</property>
 155.852 -					  <accelerator key="4" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.853 -					</widget>
 155.854 -				      </child>
 155.855 -
 155.856 -				      <child>
 155.857 -					<widget class="GtkCheckMenuItem" id="LayersObj">
 155.858 -					  <property name="visible">True</property>
 155.859 -					  <property name="label" translatable="yes">OBJ</property>
 155.860 -					  <property name="use_underline">True</property>
 155.861 -					  <property name="active">False</property>
 155.862 -					  <accelerator key="5" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.863 -					</widget>
 155.864 -				      </child>
 155.865 -
 155.866 -				      <child>
 155.867 -					<widget class="GtkCheckMenuItem" id="LayersWin0">
 155.868 -					  <property name="visible">True</property>
 155.869 -					  <property name="label" translatable="yes">WIN0</property>
 155.870 -					  <property name="use_underline">True</property>
 155.871 -					  <property name="active">False</property>
 155.872 -					  <accelerator key="6" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.873 -					</widget>
 155.874 -				      </child>
 155.875 -
 155.876 -				      <child>
 155.877 -					<widget class="GtkCheckMenuItem" id="LayersWin1">
 155.878 -					  <property name="visible">True</property>
 155.879 -					  <property name="label" translatable="yes">WIN1</property>
 155.880 -					  <property name="use_underline">True</property>
 155.881 -					  <property name="active">False</property>
 155.882 -					  <accelerator key="7" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.883 -					</widget>
 155.884 -				      </child>
 155.885 -
 155.886 -				      <child>
 155.887 -					<widget class="GtkCheckMenuItem" id="LayersObjWin">
 155.888 -					  <property name="visible">True</property>
 155.889 -					  <property name="label" translatable="yes">OBJWIN</property>
 155.890 -					  <property name="use_underline">True</property>
 155.891 -					  <property name="active">False</property>
 155.892 -					  <accelerator key="8" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 155.893 -					</widget>
 155.894 -				      </child>
 155.895 -				    </widget>
 155.896 -				  </child>
 155.897 -				</widget>
 155.898 -			      </child>
 155.899 -			    </widget>
 155.900 -			  </child>
 155.901 -			</widget>
 155.902 -		      </child>
 155.903 -
 155.904 -		      <child>
 155.905 -			<widget class="GtkMenuItem" id="EmulatorMenu">
 155.906 -			  <property name="visible">True</property>
 155.907 -			  <property name="label" translatable="yes">_Emulator</property>
 155.908 -			  <property name="use_underline">True</property>
 155.909 -
 155.910 -			  <child>
 155.911 -			    <widget class="GtkMenu" id="EmulatorMenu_menu">
 155.912 -
 155.913 -			      <child>
 155.914 -				<widget class="GtkMenuItem" id="EmulatorDirectories">
 155.915 -				  <property name="visible">True</property>
 155.916 -				  <property name="label" translatable="yes">Directories...</property>
 155.917 -				  <property name="use_underline">True</property>
 155.918 -				</widget>
 155.919 -			      </child>
 155.920 -
 155.921 -			      <child>
 155.922 -				<widget class="GtkCheckMenuItem" id="EmulatorPauseWhenInactive">
 155.923 -				  <property name="visible">True</property>
 155.924 -				  <property name="label" translatable="yes">Pause when inactive window</property>
 155.925 -				  <property name="use_underline">True</property>
 155.926 -				  <property name="active">False</property>
 155.927 -				</widget>
 155.928 -			      </child>
 155.929 -
 155.930 -			      <child>
 155.931 -				<widget class="GtkMenuItem" id="ShowSpeedMenu">
 155.932 -				  <property name="visible">True</property>
 155.933 -				  <property name="label" translatable="yes">Show speed</property>
 155.934 -				  <property name="use_underline">True</property>
 155.935 -
 155.936 -				  <child>
 155.937 -				    <widget class="GtkMenu" id="ShowSpeedMenu_menu">
 155.938 -
 155.939 -				      <child>
 155.940 -					<widget class="GtkRadioMenuItem" id="ShowSpeedNone">
 155.941 -					  <property name="visible">True</property>
 155.942 -					  <property name="label" translatable="yes">None</property>
 155.943 -					  <property name="use_underline">True</property>
 155.944 -					  <property name="active">True</property>
 155.945 -					</widget>
 155.946 -				      </child>
 155.947 -
 155.948 -				      <child>
 155.949 -					<widget class="GtkRadioMenuItem" id="ShowSpeedPercentage">
 155.950 -					  <property name="visible">True</property>
 155.951 -					  <property name="label" translatable="yes">Percentage</property>
 155.952 -					  <property name="use_underline">True</property>
 155.953 -					  <property name="active">False</property>
 155.954 -					  <property name="group">ShowSpeedNone</property>
 155.955 -					</widget>
 155.956 -				      </child>
 155.957 -
 155.958 -				      <child>
 155.959 -					<widget class="GtkRadioMenuItem" id="ShowSpeedDetailed">
 155.960 -					  <property name="visible">True</property>
 155.961 -					  <property name="label" translatable="yes">Detailed</property>
 155.962 -					  <property name="use_underline">True</property>
 155.963 -					  <property name="active">False</property>
 155.964 -					  <property name="group">ShowSpeedNone</property>
 155.965 -					</widget>
 155.966 -				      </child>
 155.967 -				    </widget>
 155.968 -				  </child>
 155.969 -				</widget>
 155.970 -			      </child>
 155.971 -
 155.972 -			      <child>
 155.973 -				<widget class="GtkMenuItem" id="SaveTypeMenu">
 155.974 -				  <property name="visible">True</property>
 155.975 -				  <property name="label" translatable="yes">Save type</property>
 155.976 -				  <property name="use_underline">True</property>
 155.977 -
 155.978 -				  <child>
 155.979 -				    <widget class="GtkMenu" id="SaveTypeMenu_menu">
 155.980 -
 155.981 -				      <child>
 155.982 -					<widget class="GtkRadioMenuItem" id="SaveTypeAutomatic">
 155.983 -					  <property name="visible">True</property>
 155.984 -					  <property name="label" translatable="yes">_Automatic</property>
 155.985 -					  <property name="use_underline">True</property>
 155.986 -					  <property name="active">True</property>
 155.987 -					</widget>
 155.988 -				      </child>
 155.989 -
 155.990 -				      <child>
 155.991 -					<widget class="GtkRadioMenuItem" id="SaveTypeEeprom">
 155.992 -					  <property name="visible">True</property>
 155.993 -					  <property name="label" translatable="yes">EEPROM</property>
 155.994 -					  <property name="use_underline">True</property>
 155.995 -					  <property name="active">False</property>
 155.996 -					  <property name="group">SaveTypeAutomatic</property>
 155.997 -					</widget>
 155.998 -				      </child>
 155.999 -
155.1000 -				      <child>
155.1001 -					<widget class="GtkRadioMenuItem" id="SaveTypeSram">
155.1002 -					  <property name="visible">True</property>
155.1003 -					  <property name="label" translatable="yes">SRAM</property>
155.1004 -					  <property name="use_underline">True</property>
155.1005 -					  <property name="active">False</property>
155.1006 -					  <property name="group">SaveTypeAutomatic</property>
155.1007 -					</widget>
155.1008 -				      </child>
155.1009 -
155.1010 -				      <child>
155.1011 -					<widget class="GtkRadioMenuItem" id="SaveTypeFlash">
155.1012 -					  <property name="visible">True</property>
155.1013 -					  <property name="label" translatable="yes">Flash</property>
155.1014 -					  <property name="use_underline">True</property>
155.1015 -					  <property name="active">False</property>
155.1016 -					  <property name="group">SaveTypeAutomatic</property>
155.1017 -					</widget>
155.1018 -				      </child>
155.1019 -
155.1020 -				      <child>
155.1021 -					<widget class="GtkRadioMenuItem" id="SaveTypeEepromSensor">
155.1022 -					  <property name="visible">True</property>
155.1023 -					  <property name="label" translatable="yes">EEPROM+Sensor</property>
155.1024 -					  <property name="use_underline">True</property>
155.1025 -					  <property name="active">False</property>
155.1026 -					  <property name="group">SaveTypeAutomatic</property>
155.1027 -					</widget>
155.1028 -				      </child>
155.1029 -
155.1030 -				      <child>
155.1031 -					<widget class="GtkRadioMenuItem" id="SaveTypeNone">
155.1032 -					  <property name="visible">True</property>
155.1033 -					  <property name="label" translatable="yes">None</property>
155.1034 -					  <property name="use_underline">True</property>
155.1035 -					  <property name="active">False</property>
155.1036 -					  <property name="group">SaveTypeAutomatic</property>
155.1037 -					</widget>
155.1038 -				      </child>
155.1039 -
155.1040 -				      <child>
155.1041 -					<widget class="GtkSeparatorMenuItem" id="separator10">
155.1042 -					  <property name="visible">True</property>
155.1043 -					</widget>
155.1044 -				      </child>
155.1045 -
155.1046 -				      <child>
155.1047 -					<widget class="GtkRadioMenuItem" id="SaveTypeFlash64K">
155.1048 -					  <property name="visible">True</property>
155.1049 -					  <property name="label" translatable="yes">Flash 64K</property>
155.1050 -					  <property name="use_underline">True</property>
155.1051 -					  <property name="active">True</property>
155.1052 -					</widget>
155.1053 -				      </child>
155.1054 -
155.1055 -				      <child>
155.1056 -					<widget class="GtkRadioMenuItem" id="SaveTypeFlash128K">
155.1057 -					  <property name="visible">True</property>
155.1058 -					  <property name="label" translatable="yes">Flash 128K</property>
155.1059 -					  <property name="use_underline">True</property>
155.1060 -					  <property name="active">False</property>
155.1061 -					  <property name="group">SaveTypeFlash64K</property>
155.1062 -					</widget>
155.1063 -				      </child>
155.1064 -				    </widget>
155.1065 -				  </child>
155.1066 -				</widget>
155.1067 -			      </child>
155.1068 -
155.1069 -			      <child>
155.1070 -				<widget class="GtkSeparatorMenuItem" id="separator31">
155.1071 -				  <property name="visible">True</property>
155.1072 -				</widget>
155.1073 -			      </child>
155.1074 -
155.1075 -			      <child>
155.1076 -				<widget class="GtkMenuItem" id="EmulatorSelectBios">
155.1077 -				  <property name="visible">True</property>
155.1078 -				  <property name="label" translatable="yes">_Select BIOS file...</property>
155.1079 -				  <property name="use_underline">True</property>
155.1080 -				</widget>
155.1081 -			      </child>
155.1082 -
155.1083 -			      <child>
155.1084 -				<widget class="GtkCheckMenuItem" id="EmulatorUseBios">
155.1085 -				  <property name="visible">True</property>
155.1086 -				  <property name="label" translatable="yes">_Use BIOS file</property>
155.1087 -				  <property name="use_underline">True</property>
155.1088 -				  <property name="active">False</property>
155.1089 -				</widget>
155.1090 -			      </child>
155.1091 -
155.1092 -			      <child>
155.1093 -				<widget class="GtkSeparatorMenuItem" id="separator30">
155.1094 -				  <property name="visible">True</property>
155.1095 -				</widget>
155.1096 -			      </child>
155.1097 -
155.1098 -			      <child>
155.1099 -				<widget class="GtkMenuItem" id="ScreenshotFormatMenu">
155.1100 -				  <property name="visible">True</property>
155.1101 -				  <property name="label" translatable="yes">Screenshot format</property>
155.1102 -				  <property name="use_underline">True</property>
155.1103 -
155.1104 -				  <child>
155.1105 -				    <widget class="GtkMenu" id="ScreenshotFormatMenu_menu">
155.1106 -
155.1107 -				      <child>
155.1108 -					<widget class="GtkRadioMenuItem" id="ScreenshotFormatPNG">
155.1109 -					  <property name="visible">True</property>
155.1110 -					  <property name="label" translatable="yes">_PNG</property>
155.1111 -					  <property name="use_underline">True</property>
155.1112 -					  <property name="active">True</property>
155.1113 -					</widget>
155.1114 -				      </child>
155.1115 -
155.1116 -				      <child>
155.1117 -					<widget class="GtkRadioMenuItem" id="ScreenshotFormatBMP">
155.1118 -					  <property name="visible">True</property>
155.1119 -					  <property name="label" translatable="yes">_BMP</property>
155.1120 -					  <property name="use_underline">True</property>
155.1121 -					  <property name="active">False</property>
155.1122 -					  <property name="group">ScreenshotFormatPNG</property>
155.1123 -					</widget>
155.1124 -				      </child>
155.1125 -				    </widget>
155.1126 -				  </child>
155.1127 -				</widget>
155.1128 -			      </child>
155.1129 -			    </widget>
155.1130 -			  </child>
155.1131 -			</widget>
155.1132 -		      </child>
155.1133 -
155.1134 -		      <child>
155.1135 -			<widget class="GtkMenuItem" id="SoundMenu">
155.1136 -			  <property name="visible">True</property>
155.1137 -			  <property name="label" translatable="yes">_Sound</property>
155.1138 -			  <property name="use_underline">True</property>
155.1139 -
155.1140 -			  <child>
155.1141 -			    <widget class="GtkMenu" id="SoundMenu_menu">
155.1142 -
155.1143 -			      <child>
155.1144 -				<widget class="GtkRadioMenuItem" id="SoundOff">
155.1145 -				  <property name="visible">True</property>
155.1146 -				  <property name="label" translatable="yes">O_ff</property>
155.1147 -				  <property name="use_underline">True</property>
155.1148 -				  <property name="active">True</property>
155.1149 -				</widget>
155.1150 -			      </child>
155.1151 -
155.1152 -			      <child>
155.1153 -				<widget class="GtkRadioMenuItem" id="SoundMute">
155.1154 -				  <property name="visible">True</property>
155.1155 -				  <property name="label" translatable="yes">_Mute</property>
155.1156 -				  <property name="use_underline">True</property>
155.1157 -				  <property name="active">False</property>
155.1158 -				  <property name="group">SoundOff</property>
155.1159 -				</widget>
155.1160 -			      </child>
155.1161 -
155.1162 -			      <child>
155.1163 -				<widget class="GtkRadioMenuItem" id="SoundOn">
155.1164 -				  <property name="visible">True</property>
155.1165 -				  <property name="label" translatable="yes">_On</property>
155.1166 -				  <property name="use_underline">True</property>
155.1167 -				  <property name="active">False</property>
155.1168 -				  <property name="group">SoundOff</property>
155.1169 -				</widget>
155.1170 -			      </child>
155.1171 -
155.1172 -			      <child>
155.1173 -				<widget class="GtkSeparatorMenuItem" id="separator11">
155.1174 -				  <property name="visible">True</property>
155.1175 -				</widget>
155.1176 -			      </child>
155.1177 -
155.1178 -			      <child>
155.1179 -				<widget class="GtkCheckMenuItem" id="SoundEcho">
155.1180 -				  <property name="visible">True</property>
155.1181 -				  <property name="label" translatable="yes">Echo</property>
155.1182 -				  <property name="use_underline">True</property>
155.1183 -				  <property name="active">False</property>
155.1184 -				</widget>
155.1185 -			      </child>
155.1186 -
155.1187 -			      <child>
155.1188 -				<widget class="GtkCheckMenuItem" id="SoundLowPass">
155.1189 -				  <property name="visible">True</property>
155.1190 -				  <property name="label" translatable="yes">Low pass filter</property>
155.1191 -				  <property name="use_underline">True</property>
155.1192 -				  <property name="active">False</property>
155.1193 -				</widget>
155.1194 -			      </child>
155.1195 -
155.1196 -			      <child>
155.1197 -				<widget class="GtkCheckMenuItem" id="SoundReverseStereo">
155.1198 -				  <property name="visible">True</property>
155.1199 -				  <property name="label" translatable="yes">Reverse stereo</property>
155.1200 -				  <property name="use_underline">True</property>
155.1201 -				  <property name="active">False</property>
155.1202 -				</widget>
155.1203 -			      </child>
155.1204 -
155.1205 -			      <child>
155.1206 -				<widget class="GtkSeparatorMenuItem" id="separator13">
155.1207 -				  <property name="visible">True</property>
155.1208 -				</widget>
155.1209 -			      </child>
155.1210 -
155.1211 -			      <child>
155.1212 -				<widget class="GtkCheckMenuItem" id="SoundChannel1">
155.1213 -				  <property name="visible">True</property>
155.1214 -				  <property name="label" translatable="yes">Channel _1</property>
155.1215 -				  <property name="use_underline">True</property>
155.1216 -				  <property name="active">False</property>
155.1217 -				</widget>
155.1218 -			      </child>
155.1219 -
155.1220 -			      <child>
155.1221 -				<widget class="GtkCheckMenuItem" id="SoundChannel2">
155.1222 -				  <property name="visible">True</property>
155.1223 -				  <property name="label" translatable="yes">Channel _2</property>
155.1224 -				  <property name="use_underline">True</property>
155.1225 -				  <property name="active">False</property>
155.1226 -				</widget>
155.1227 -			      </child>
155.1228 -
155.1229 -			      <child>
155.1230 -				<widget class="GtkCheckMenuItem" id="SoundChannel3">
155.1231 -				  <property name="visible">True</property>
155.1232 -				  <property name="label" translatable="yes">Channel _3</property>
155.1233 -				  <property name="use_underline">True</property>
155.1234 -				  <property name="active">False</property>
155.1235 -				</widget>
155.1236 -			      </child>
155.1237 -
155.1238 -			      <child>
155.1239 -				<widget class="GtkCheckMenuItem" id="SoundChannel4">
155.1240 -				  <property name="visible">True</property>
155.1241 -				  <property name="label" translatable="yes">Channel _4</property>
155.1242 -				  <property name="use_underline">True</property>
155.1243 -				  <property name="active">False</property>
155.1244 -				</widget>
155.1245 -			      </child>
155.1246 -
155.1247 -			      <child>
155.1248 -				<widget class="GtkCheckMenuItem" id="SoundChannelA">
155.1249 -				  <property name="visible">True</property>
155.1250 -				  <property name="label" translatable="yes">Channel _A</property>
155.1251 -				  <property name="use_underline">True</property>
155.1252 -				  <property name="active">False</property>
155.1253 -				</widget>
155.1254 -			      </child>
155.1255 -
155.1256 -			      <child>
155.1257 -				<widget class="GtkCheckMenuItem" id="SoundChannelB">
155.1258 -				  <property name="visible">True</property>
155.1259 -				  <property name="label" translatable="yes">Channel _B</property>
155.1260 -				  <property name="use_underline">True</property>
155.1261 -				  <property name="active">False</property>
155.1262 -				</widget>
155.1263 -			      </child>
155.1264 -
155.1265 -			      <child>
155.1266 -				<widget class="GtkSeparatorMenuItem" id="separator14">
155.1267 -				  <property name="visible">True</property>
155.1268 -				</widget>
155.1269 -			      </child>
155.1270 -
155.1271 -			      <child>
155.1272 -				<widget class="GtkRadioMenuItem" id="Sound11Khz">
155.1273 -				  <property name="visible">True</property>
155.1274 -				  <property name="label" translatable="yes">11 _Khz</property>
155.1275 -				  <property name="use_underline">True</property>
155.1276 -				  <property name="active">True</property>
155.1277 -				</widget>
155.1278 -			      </child>
155.1279 -
155.1280 -			      <child>
155.1281 -				<widget class="GtkRadioMenuItem" id="Sound22Khz">
155.1282 -				  <property name="visible">True</property>
155.1283 -				  <property name="label" translatable="yes">22 K_hz</property>
155.1284 -				  <property name="use_underline">True</property>
155.1285 -				  <property name="active">False</property>
155.1286 -				  <property name="group">Sound11Khz</property>
155.1287 -				</widget>
155.1288 -			      </child>
155.1289 -
155.1290 -			      <child>
155.1291 -				<widget class="GtkRadioMenuItem" id="Sound44Khz">
155.1292 -				  <property name="visible">True</property>
155.1293 -				  <property name="label" translatable="yes">44 Kh_z</property>
155.1294 -				  <property name="use_underline">True</property>
155.1295 -				  <property name="active">False</property>
155.1296 -				  <property name="group">Sound11Khz</property>
155.1297 -				</widget>
155.1298 -			      </child>
155.1299 -
155.1300 -			      <child>
155.1301 -				<widget class="GtkSeparatorMenuItem" id="separator15">
155.1302 -				  <property name="visible">True</property>
155.1303 -				</widget>
155.1304 -			      </child>
155.1305 -
155.1306 -			      <child>
155.1307 -				<widget class="GtkMenuItem" id="VolumeMenu">
155.1308 -				  <property name="visible">True</property>
155.1309 -				  <property name="label" translatable="yes">_Volume</property>
155.1310 -				  <property name="use_underline">True</property>
155.1311 -
155.1312 -				  <child>
155.1313 -				    <widget class="GtkMenu" id="VolumeMenu_menu">
155.1314 -
155.1315 -				      <child>
155.1316 -					<widget class="GtkRadioMenuItem" id="Volume25">
155.1317 -					  <property name="visible">True</property>
155.1318 -					  <property name="label" translatable="yes">25%</property>
155.1319 -					  <property name="use_underline">True</property>
155.1320 -					  <property name="active">True</property>
155.1321 -					</widget>
155.1322 -				      </child>
155.1323 -
155.1324 -				      <child>
155.1325 -					<widget class="GtkRadioMenuItem" id="Volume50">
155.1326 -					  <property name="visible">True</property>
155.1327 -					  <property name="label" translatable="yes">50%</property>
155.1328 -					  <property name="use_underline">True</property>
155.1329 -					  <property name="active">False</property>
155.1330 -					  <property name="group">Volume25</property>
155.1331 -					</widget>
155.1332 -				      </child>
155.1333 -
155.1334 -				      <child>
155.1335 -					<widget class="GtkRadioMenuItem" id="Volume100">
155.1336 -					  <property name="visible">True</property>
155.1337 -					  <property name="label" translatable="yes">100%</property>
155.1338 -					  <property name="use_underline">True</property>
155.1339 -					  <property name="active">False</property>
155.1340 -					  <property name="group">Volume25</property>
155.1341 -					</widget>
155.1342 -				      </child>
155.1343 -
155.1344 -				      <child>
155.1345 -					<widget class="GtkRadioMenuItem" id="Volume200">
155.1346 -					  <property name="visible">True</property>
155.1347 -					  <property name="label" translatable="yes">200%</property>
155.1348 -					  <property name="use_underline">True</property>
155.1349 -					  <property name="active">False</property>
155.1350 -					  <property name="group">Volume25</property>
155.1351 -					</widget>
155.1352 -				      </child>
155.1353 -
155.1354 -				      <child>
155.1355 -					<widget class="GtkRadioMenuItem" id="Volume300">
155.1356 -					  <property name="visible">True</property>
155.1357 -					  <property name="label" translatable="yes">300%</property>
155.1358 -					  <property name="use_underline">True</property>
155.1359 -					  <property name="active">False</property>
155.1360 -					  <property name="group">Volume25</property>
155.1361 -					</widget>
155.1362 -				      </child>
155.1363 -
155.1364 -				      <child>
155.1365 -					<widget class="GtkRadioMenuItem" id="Volume400">
155.1366 -					  <property name="visible">True</property>
155.1367 -					  <property name="label" translatable="yes">400%</property>
155.1368 -					  <property name="use_underline">True</property>
155.1369 -					  <property name="active">False</property>
155.1370 -					  <property name="group">Volume25</property>
155.1371 -					</widget>
155.1372 -				      </child>
155.1373 -				    </widget>
155.1374 -				  </child>
155.1375 -				</widget>
155.1376 -			      </child>
155.1377 -			    </widget>
155.1378 -			  </child>
155.1379 -			</widget>
155.1380 -		      </child>
155.1381 -
155.1382 -		      <child>
155.1383 -			<widget class="GtkMenuItem" id="GameboyMenu">
155.1384 -			  <property name="visible">True</property>
155.1385 -			  <property name="label" translatable="yes">_Gameboy</property>
155.1386 -			  <property name="use_underline">True</property>
155.1387 -
155.1388 -			  <child>
155.1389 -			    <widget class="GtkMenu" id="GameboyMenu_menu">
155.1390 -
155.1391 -			      <child>
155.1392 -				<widget class="GtkCheckMenuItem" id="GameboyBorder">
155.1393 -				  <property name="visible">True</property>
155.1394 -				  <property name="label" translatable="yes">_Border</property>
155.1395 -				  <property name="use_underline">True</property>
155.1396 -				  <property name="active">False</property>
155.1397 -				</widget>
155.1398 -			      </child>
155.1399 -
155.1400 -			      <child>
155.1401 -				<widget class="GtkCheckMenuItem" id="GameboyPrinter">
155.1402 -				  <property name="visible">True</property>
155.1403 -				  <property name="label" translatable="yes">_Printer</property>
155.1404 -				  <property name="use_underline">True</property>
155.1405 -				  <property name="active">False</property>
155.1406 -				</widget>
155.1407 -			      </child>
155.1408 -
155.1409 -			      <child>
155.1410 -				<widget class="GtkSeparatorMenuItem" id="separator16">
155.1411 -				  <property name="visible">True</property>
155.1412 -				</widget>
155.1413 -			      </child>
155.1414 -
155.1415 -			      <child>
155.1416 -				<widget class="GtkRadioMenuItem" id="GameboyAutomatic">
155.1417 -				  <property name="visible">True</property>
155.1418 -				  <property name="label" translatable="yes">_Automatic</property>
155.1419 -				  <property name="use_underline">True</property>
155.1420 -				  <property name="active">True</property>
155.1421 -				</widget>
155.1422 -			      </child>
155.1423 -
155.1424 -			      <child>
155.1425 -				<widget class="GtkRadioMenuItem" id="GameboyGba">
155.1426 -				  <property name="visible">True</property>
155.1427 -				  <property name="label" translatable="yes">_GBA</property>
155.1428 -				  <property name="use_underline">True</property>
155.1429 -				  <property name="active">False</property>
155.1430 -				  <property name="group">GameboyAutomatic</property>
155.1431 -				</widget>
155.1432 -			      </child>
155.1433 -
155.1434 -			      <child>
155.1435 -				<widget class="GtkRadioMenuItem" id="GameboyCgb">
155.1436 -				  <property name="visible">True</property>
155.1437 -				  <property name="label" translatable="yes">_CGB/GBC</property>
155.1438 -				  <property name="use_underline">True</property>
155.1439 -				  <property name="active">False</property>
155.1440 -				  <property name="group">GameboyAutomatic</property>
155.1441 -				</widget>
155.1442 -			      </child>
155.1443 -
155.1444 -			      <child>
155.1445 -				<widget class="GtkRadioMenuItem" id="GameboySgb">
155.1446 -				  <property name="visible">True</property>
155.1447 -				  <property name="label" translatable="yes">_SGB</property>
155.1448 -				  <property name="use_underline">True</property>
155.1449 -				  <property name="active">False</property>
155.1450 -				  <property name="group">GameboyAutomatic</property>
155.1451 -				</widget>
155.1452 -			      </child>
155.1453 -
155.1454 -			      <child>
155.1455 -				<widget class="GtkRadioMenuItem" id="GameboySgb2">
155.1456 -				  <property name="visible">True</property>
155.1457 -				  <property name="label" translatable="yes">SGB_2</property>
155.1458 -				  <property name="use_underline">True</property>
155.1459 -				  <property name="active">False</property>
155.1460 -				  <property name="group">GameboyAutomatic</property>
155.1461 -				</widget>
155.1462 -			      </child>
155.1463 -
155.1464 -			      <child>
155.1465 -				<widget class="GtkRadioMenuItem" id="GameboyGb">
155.1466 -				  <property name="visible">True</property>
155.1467 -				  <property name="label" translatable="yes">G_B</property>
155.1468 -				  <property name="use_underline">True</property>
155.1469 -				  <property name="active">False</property>
155.1470 -				  <property name="group">GameboyAutomatic</property>
155.1471 -				</widget>
155.1472 -			      </child>
155.1473 -			    </widget>
155.1474 -			  </child>
155.1475 -			</widget>
155.1476 -		      </child>
155.1477 -
155.1478 -		      <child>
155.1479 -			<widget class="GtkMenuItem" id="FilterMenu">
155.1480 -			  <property name="visible">True</property>
155.1481 -			  <property name="label" translatable="yes">F_ilter</property>
155.1482 -			  <property name="use_underline">True</property>
155.1483 -
155.1484 -			  <child>
155.1485 -			    <widget class="GtkMenu" id="FilterMenu_menu">
155.1486 -
155.1487 -			      <child>
155.1488 -				<widget class="GtkMenuItem" id="InterframeBlendingMenu">
155.1489 -				  <property name="visible">True</property>
155.1490 -				  <property name="label" translatable="yes">Interframe _blending</property>
155.1491 -				  <property name="use_underline">True</property>
155.1492 -
155.1493 -				  <child>
155.1494 -				    <widget class="GtkMenu" id="InterframeBlendingMenu_menu">
155.1495 -
155.1496 -				      <child>
155.1497 -					<widget class="GtkRadioMenuItem" id="IFBNone">
155.1498 -					  <property name="visible">True</property>
155.1499 -					  <property name="label" translatable="yes">_None</property>
155.1500 -					  <property name="use_underline">True</property>
155.1501 -					  <property name="active">True</property>
155.1502 -					</widget>
155.1503 -				      </child>
155.1504 -
155.1505 -				      <child>
155.1506 -					<widget class="GtkRadioMenuItem" id="IFBSmart">
155.1507 -					  <property name="visible">True</property>
155.1508 -					  <property name="label" translatable="yes">_Smart</property>
155.1509 -					  <property name="use_underline">True</property>
155.1510 -					  <property name="active">False</property>
155.1511 -					  <property name="group">IFBNone</property>
155.1512 -					</widget>
155.1513 -				      </child>
155.1514 -
155.1515 -				      <child>
155.1516 -					<widget class="GtkRadioMenuItem" id="IFBMotionBlur">
155.1517 -					  <property name="visible">True</property>
155.1518 -					  <property name="label" translatable="yes">_Motion Blur</property>
155.1519 -					  <property name="use_underline">True</property>
155.1520 -					  <property name="active">False</property>
155.1521 -					  <property name="group">IFBNone</property>
155.1522 -					</widget>
155.1523 -				      </child>
155.1524 -				    </widget>
155.1525 -				  </child>
155.1526 -				</widget>
155.1527 -			      </child>
155.1528 -
155.1529 -			      <child>
155.1530 -				<widget class="GtkSeparatorMenuItem" id="separator20">
155.1531 -				  <property name="visible">True</property>
155.1532 -				</widget>
155.1533 -			      </child>
155.1534 -
155.1535 -			      <child>
155.1536 -				<widget class="GtkRadioMenuItem" id="FilterNone">
155.1537 -				  <property name="visible">True</property>
155.1538 -				  <property name="label" translatable="yes">_None</property>
155.1539 -				  <property name="use_underline">True</property>
155.1540 -				  <property name="active">True</property>
155.1541 -				</widget>
155.1542 -			      </child>
155.1543 -
155.1544 -			      <child>
155.1545 -				<widget class="GtkRadioMenuItem" id="FilterTVMode">
155.1546 -				  <property name="visible">True</property>
155.1547 -				  <property name="label" translatable="yes">_TV Mode</property>
155.1548 -				  <property name="use_underline">True</property>
155.1549 -				  <property name="active">False</property>
155.1550 -				  <property name="group">FilterNone</property>
155.1551 -				</widget>
155.1552 -			      </child>
155.1553 -
155.1554 -			      <child>
155.1555 -				<widget class="GtkRadioMenuItem" id="Filter2xSaI">
155.1556 -				  <property name="visible">True</property>
155.1557 -				  <property name="label" translatable="yes">_2xSaI</property>
155.1558 -				  <property name="use_underline">True</property>
155.1559 -				  <property name="active">False</property>
155.1560 -				  <property name="group">FilterNone</property>
155.1561 -				</widget>
155.1562 -			      </child>
155.1563 -
155.1564 -			      <child>
155.1565 -				<widget class="GtkRadioMenuItem" id="FilterSuper2xSaI">
155.1566 -				  <property name="visible">True</property>
155.1567 -				  <property name="label" translatable="yes">_Super 2xSaI</property>
155.1568 -				  <property name="use_underline">True</property>
155.1569 -				  <property name="active">False</property>
155.1570 -				  <property name="group">FilterNone</property>
155.1571 -				</widget>
155.1572 -			      </child>
155.1573 -
155.1574 -			      <child>
155.1575 -				<widget class="GtkRadioMenuItem" id="FilterSuperEagle">
155.1576 -				  <property name="visible">True</property>
155.1577 -				  <property name="label" translatable="yes">Super _Eagle</property>
155.1578 -				  <property name="use_underline">True</property>
155.1579 -				  <property name="active">False</property>
155.1580 -				  <property name="group">FilterNone</property>
155.1581 -				</widget>
155.1582 -			      </child>
155.1583 -
155.1584 -			      <child>
155.1585 -				<widget class="GtkRadioMenuItem" id="FilterPixelate">
155.1586 -				  <property name="visible">True</property>
155.1587 -				  <property name="label" translatable="yes">_Pixelate</property>
155.1588 -				  <property name="use_underline">True</property>
155.1589 -				  <property name="active">False</property>
155.1590 -				  <property name="group">FilterNone</property>
155.1591 -				</widget>
155.1592 -			      </child>
155.1593 -
155.1594 -			      <child>
155.1595 -				<widget class="GtkRadioMenuItem" id="FilterMotionBlur">
155.1596 -				  <property name="visible">True</property>
155.1597 -				  <property name="label" translatable="yes">_Motion Blur</property>
155.1598 -				  <property name="use_underline">True</property>
155.1599 -				  <property name="active">False</property>
155.1600 -				  <property name="group">FilterNone</property>
155.1601 -				</widget>
155.1602 -			      </child>
155.1603 -
155.1604 -			      <child>
155.1605 -				<widget class="GtkRadioMenuItem" id="FilterAdvanceMame2x">
155.1606 -				  <property name="visible">True</property>
155.1607 -				  <property name="label" translatable="yes">_AdvanceMAME 2x</property>
155.1608 -				  <property name="use_underline">True</property>
155.1609 -				  <property name="active">False</property>
155.1610 -				  <property name="group">FilterNone</property>
155.1611 -				</widget>
155.1612 -			      </child>
155.1613 -
155.1614 -			      <child>
155.1615 -				<widget class="GtkRadioMenuItem" id="FilterSimple2x">
155.1616 -				  <property name="visible">True</property>
155.1617 -				  <property name="label" translatable="yes">S_imple 2x</property>
155.1618 -				  <property name="use_underline">True</property>
155.1619 -				  <property name="active">False</property>
155.1620 -				  <property name="group">FilterNone</property>
155.1621 -				</widget>
155.1622 -			      </child>
155.1623 -
155.1624 -			      <child>
155.1625 -				<widget class="GtkRadioMenuItem" id="FilterBilinear">
155.1626 -				  <property name="visible">True</property>
155.1627 -				  <property name="label" translatable="yes">Bilinea_r</property>
155.1628 -				  <property name="use_underline">True</property>
155.1629 -				  <property name="active">False</property>
155.1630 -				  <property name="group">FilterNone</property>
155.1631 -				</widget>
155.1632 -			      </child>
155.1633 -
155.1634 -			      <child>
155.1635 -				<widget class="GtkRadioMenuItem" id="FilterBilinearPlus">
155.1636 -				  <property name="visible">True</property>
155.1637 -				  <property name="label" translatable="yes">Bilinear Pl_us</property>
155.1638 -				  <property name="use_underline">True</property>
155.1639 -				  <property name="active">False</property>
155.1640 -				  <property name="group">FilterNone</property>
155.1641 -				</widget>
155.1642 -			      </child>
155.1643 -
155.1644 -			      <child>
155.1645 -				<widget class="GtkRadioMenuItem" id="FilterScanlines">
155.1646 -				  <property name="visible">True</property>
155.1647 -				  <property name="label" translatable="yes">S_canlines</property>
155.1648 -				  <property name="use_underline">True</property>
155.1649 -				  <property name="active">False</property>
155.1650 -				  <property name="group">FilterNone</property>
155.1651 -				</widget>
155.1652 -			      </child>
155.1653 -
155.1654 -			      <child>
155.1655 -				<widget class="GtkRadioMenuItem" id="FilterHq2x">
155.1656 -				  <property name="visible">True</property>
155.1657 -				  <property name="label" translatable="yes">h_q2x</property>
155.1658 -				  <property name="use_underline">True</property>
155.1659 -				  <property name="active">False</property>
155.1660 -				  <property name="group">FilterNone</property>
155.1661 -				</widget>
155.1662 -			      </child>
155.1663 -
155.1664 -			      <child>
155.1665 -				<widget class="GtkRadioMenuItem" id="FilterLq2x">
155.1666 -				  <property name="visible">True</property>
155.1667 -				  <property name="label" translatable="yes">_lq2x</property>
155.1668 -				  <property name="use_underline">True</property>
155.1669 -				  <property name="active">False</property>
155.1670 -				  <property name="group">FilterNone</property>
155.1671 -				</widget>
155.1672 -			      </child>
155.1673 -
155.1674 -			      <child>
155.1675 -				<widget class="GtkSeparatorMenuItem" id="separator17">
155.1676 -				  <property name="visible">True</property>
155.1677 -				</widget>
155.1678 -			      </child>
155.1679 -
155.1680 -			      <child>
155.1681 -				<widget class="GtkCheckMenuItem" id="FilterDisableMmx">
155.1682 -				  <property name="visible">True</property>
155.1683 -				  <property name="label" translatable="yes">_Disable MMX</property>
155.1684 -				  <property name="use_underline">True</property>
155.1685 -				  <property name="active">False</property>
155.1686 -				</widget>
155.1687 -			      </child>
155.1688 -			    </widget>
155.1689 -			  </child>
155.1690 -			</widget>
155.1691 -		      </child>
155.1692 -
155.1693 -		      <child>
155.1694 -			<widget class="GtkMenuItem" id="JoypadMenu">
155.1695 -			  <property name="visible">True</property>
155.1696 -			  <property name="label" translatable="yes">_Joypad</property>
155.1697 -			  <property name="use_underline">True</property>
155.1698 -
155.1699 -			  <child>
155.1700 -			    <widget class="GtkMenu" id="JoypadMenu_menu">
155.1701 -
155.1702 -			      <child>
155.1703 -				<widget class="GtkMenuItem" id="JoypadConfigureMenu">
155.1704 -				  <property name="visible">True</property>
155.1705 -				  <property name="label" translatable="yes">_Configure</property>
155.1706 -				  <property name="use_underline">True</property>
155.1707 -
155.1708 -				  <child>
155.1709 -				    <widget class="GtkMenu" id="JoypadConfigureMenu_menu">
155.1710 -
155.1711 -				      <child>
155.1712 -					<widget class="GtkMenuItem" id="JoypadConfigure1">
155.1713 -					  <property name="visible">True</property>
155.1714 -					  <property name="label" translatable="yes">_1...</property>
155.1715 -					  <property name="use_underline">True</property>
155.1716 -					</widget>
155.1717 -				      </child>
155.1718 -
155.1719 -				      <child>
155.1720 -					<widget class="GtkMenuItem" id="JoypadConfigure2">
155.1721 -					  <property name="visible">True</property>
155.1722 -					  <property name="label" translatable="yes">_2...</property>
155.1723 -					  <property name="use_underline">True</property>
155.1724 -					</widget>
155.1725 -				      </child>
155.1726 -
155.1727 -				      <child>
155.1728 -					<widget class="GtkMenuItem" id="JoypadConfigure3">
155.1729 -					  <property name="visible">True</property>
155.1730 -					  <property name="label" translatable="yes">_3...</property>
155.1731 -					  <property name="use_underline">True</property>
155.1732 -					</widget>
155.1733 -				      </child>
155.1734 -
155.1735 -				      <child>
155.1736 -					<widget class="GtkMenuItem" id="JoypadConfigure4">
155.1737 -					  <property name="visible">True</property>
155.1738 -					  <property name="label" translatable="yes">_4...</property>
155.1739 -					  <property name="use_underline">True</property>
155.1740 -					</widget>
155.1741 -				      </child>
155.1742 -				    </widget>
155.1743 -				  </child>
155.1744 -				</widget>
155.1745 -			      </child>
155.1746 -
155.1747 -			      <child>
155.1748 -				<widget class="GtkSeparatorMenuItem" id="separator18">
155.1749 -				  <property name="visible">True</property>
155.1750 -				</widget>
155.1751 -			      </child>
155.1752 -
155.1753 -			      <child>
155.1754 -				<widget class="GtkRadioMenuItem" id="Joypad1">
155.1755 -				  <property name="visible">True</property>
155.1756 -				  <property name="label" translatable="yes">_1</property>
155.1757 -				  <property name="use_underline">True</property>
155.1758 -				  <property name="active">True</property>
155.1759 -				</widget>
155.1760 -			      </child>
155.1761 -
155.1762 -			      <child>
155.1763 -				<widget class="GtkRadioMenuItem" id="Joypad2">
155.1764 -				  <property name="visible">True</property>
155.1765 -				  <property name="label" translatable="yes">_2</property>
155.1766 -				  <property name="use_underline">True</property>
155.1767 -				  <property name="active">False</property>
155.1768 -				  <property name="group">Joypad1</property>
155.1769 -				</widget>
155.1770 -			      </child>
155.1771 -
155.1772 -			      <child>
155.1773 -				<widget class="GtkRadioMenuItem" id="Joypad3">
155.1774 -				  <property name="visible">True</property>
155.1775 -				  <property name="label" translatable="yes">_3</property>
155.1776 -				  <property name="use_underline">True</property>
155.1777 -				  <property name="active">False</property>
155.1778 -				  <property name="group">Joypad1</property>
155.1779 -				</widget>
155.1780 -			      </child>
155.1781 -
155.1782 -			      <child>
155.1783 -				<widget class="GtkRadioMenuItem" id="Joypad4">
155.1784 -				  <property name="visible">True</property>
155.1785 -				  <property name="label" translatable="yes">_4</property>
155.1786 -				  <property name="use_underline">True</property>
155.1787 -				  <property name="active">False</property>
155.1788 -				  <property name="group">Joypad1</property>
155.1789 -				</widget>
155.1790 -			      </child>
155.1791 -
155.1792 -			      <child>
155.1793 -				<widget class="GtkSeparatorMenuItem" id="separator24">
155.1794 -				  <property name="visible">True</property>
155.1795 -				</widget>
155.1796 -			      </child>
155.1797 -
155.1798 -			      <child>
155.1799 -				<widget class="GtkMenuItem" id="AutofireMenu">
155.1800 -				  <property name="visible">True</property>
155.1801 -				  <property name="label" translatable="yes">_Autofire</property>
155.1802 -				  <property name="use_underline">True</property>
155.1803 -
155.1804 -				  <child>
155.1805 -				    <widget class="GtkMenu" id="AutofireMenu_menu">
155.1806 -
155.1807 -				      <child>
155.1808 -					<widget class="GtkCheckMenuItem" id="AutofireA">
155.1809 -					  <property name="visible">True</property>
155.1810 -					  <property name="label" translatable="yes">_A</property>
155.1811 -					  <property name="use_underline">True</property>
155.1812 -					  <property name="active">False</property>
155.1813 -					  <accelerator key="1" modifiers="GDK_MOD1_MASK" signal="activate"/>
155.1814 -					</widget>
155.1815 -				      </child>
155.1816 -
155.1817 -				      <child>
155.1818 -					<widget class="GtkCheckMenuItem" id="AutofireB">
155.1819 -					  <property name="visible">True</property>
155.1820 -					  <property name="label" translatable="yes">_B</property>
155.1821 -					  <property name="use_underline">True</property>
155.1822 -					  <property name="active">False</property>
155.1823 -					  <accelerator key="2" modifiers="GDK_MOD1_MASK" signal="activate"/>
155.1824 -					</widget>
155.1825 -				      </child>
155.1826 -
155.1827 -				      <child>
155.1828 -					<widget class="GtkCheckMenuItem" id="AutofireL">
155.1829 -					  <property name="visible">True</property>
155.1830 -					  <property name="label" translatable="yes">_L</property>
155.1831 -					  <property name="use_underline">True</property>
155.1832 -					  <property name="active">False</property>
155.1833 -					  <accelerator key="3" modifiers="GDK_MOD1_MASK" signal="activate"/>
155.1834 -					</widget>
155.1835 -				      </child>
155.1836 -
155.1837 -				      <child>
155.1838 -					<widget class="GtkCheckMenuItem" id="AutofireR">
155.1839 -					  <property name="visible">True</property>
155.1840 -					  <property name="label" translatable="yes">_R</property>
155.1841 -					  <property name="use_underline">True</property>
155.1842 -					  <property name="active">False</property>
155.1843 -					  <accelerator key="4" modifiers="GDK_MOD1_MASK" signal="activate"/>
155.1844 -					</widget>
155.1845 -				      </child>
155.1846 -				    </widget>
155.1847 -				  </child>
155.1848 -				</widget>
155.1849 -			      </child>
155.1850 -			    </widget>
155.1851 -			  </child>
155.1852 -			</widget>
155.1853 -		      </child>
155.1854 -		    </widget>
155.1855 -		  </child>
155.1856 -		</widget>
155.1857 -	      </child>
155.1858 -
155.1859 -	      <child>
155.1860 -		<widget class="GtkMenuItem" id="ToolsMenu">
155.1861 -		  <property name="visible">True</property>
155.1862 -		  <property name="label" translatable="yes">_Tools</property>
155.1863 -		  <property name="use_underline">True</property>
155.1864 -
155.1865 -		  <child>
155.1866 -		    <widget class="GtkMenu" id="ToolsMenu_menu">
155.1867 -
155.1868 -		      <child>
155.1869 -			<widget class="GtkMenuItem" id="GdbMenu">
155.1870 -			  <property name="visible">True</property>
155.1871 -			  <property name="label" translatable="yes">_GDB</property>
155.1872 -			  <property name="use_underline">True</property>
155.1873 -
155.1874 -			  <child>
155.1875 -			    <widget class="GtkMenu" id="GdbMenu_menu">
155.1876 -
155.1877 -			      <child>
155.1878 -				<widget class="GtkMenuItem" id="GdbWait">
155.1879 -				  <property name="visible">True</property>
155.1880 -				  <property name="label" translatable="yes">_Wait connection...</property>
155.1881 -				  <property name="use_underline">True</property>
155.1882 -				</widget>
155.1883 -			      </child>
155.1884 -
155.1885 -			      <child>
155.1886 -				<widget class="GtkMenuItem" id="GdbLoadAndWait">
155.1887 -				  <property name="visible">True</property>
155.1888 -				  <property name="label" translatable="yes">_Load and wait...</property>
155.1889 -				  <property name="use_underline">True</property>
155.1890 -				</widget>
155.1891 -			      </child>
155.1892 -
155.1893 -			      <child>
155.1894 -				<widget class="GtkMenuItem" id="GdbBreak">
155.1895 -				  <property name="visible">True</property>
155.1896 -				  <property name="label" translatable="yes">_Break</property>
155.1897 -				  <property name="use_underline">True</property>
155.1898 -				</widget>
155.1899 -			      </child>
155.1900 -
155.1901 -			      <child>
155.1902 -				<widget class="GtkMenuItem" id="GdbDisconnect">
155.1903 -				  <property name="visible">True</property>
155.1904 -				  <property name="label" translatable="yes">_Disconnect</property>
155.1905 -				  <property name="use_underline">True</property>
155.1906 -				</widget>
155.1907 -			      </child>
155.1908 -			    </widget>
155.1909 -			  </child>
155.1910 -			</widget>
155.1911 -		      </child>
155.1912 -		    </widget>
155.1913 -		  </child>
155.1914 -		</widget>
155.1915 -	      </child>
155.1916 -
155.1917 -	      <child>
155.1918 -		<widget class="GtkMenuItem" id="HelpMenu">
155.1919 -		  <property name="visible">True</property>
155.1920 -		  <property name="label" translatable="yes">_Help</property>
155.1921 -		  <property name="use_underline">True</property>
155.1922 -
155.1923 -		  <child>
155.1924 -		    <widget class="GtkMenu" id="HelpMenu_menu">
155.1925 -
155.1926 -		      <child>
155.1927 -			<widget class="GtkMenuItem" id="HelpAbout">
155.1928 -			  <property name="visible">True</property>
155.1929 -			  <property name="label" translatable="yes">_About</property>
155.1930 -			  <property name="use_underline">True</property>
155.1931 -			</widget>
155.1932 -		      </child>
155.1933 -		    </widget>
155.1934 -		  </child>
155.1935 -		</widget>
155.1936 -	      </child>
155.1937 -	    </widget>
155.1938 -	  </child>
155.1939 -	</widget>
155.1940 -	<packing>
155.1941 -	  <property name="padding">0</property>
155.1942 -	  <property name="expand">False</property>
155.1943 -	  <property name="fill">True</property>
155.1944 -	</packing>
155.1945 -      </child>
155.1946 -
155.1947 -      <child>
155.1948 -	<widget class="GtkAlignment" id="ScreenContainer">
155.1949 -	  <property name="visible">True</property>
155.1950 -	  <property name="xalign">0.5</property>
155.1951 -	  <property name="yalign">0.5</property>
155.1952 -	  <property name="xscale">0</property>
155.1953 -	  <property name="yscale">0</property>
155.1954 -
155.1955 -	  <child>
155.1956 -	    <placeholder/>
155.1957 -	  </child>
155.1958 -	</widget>
155.1959 -	<packing>
155.1960 -	  <property name="padding">0</property>
155.1961 -	  <property name="expand">True</property>
155.1962 -	  <property name="fill">True</property>
155.1963 -	</packing>
155.1964 -      </child>
155.1965 -    </widget>
155.1966 -  </child>
155.1967 -</widget>
155.1968 -
155.1969 -<widget class="GtkDialog" id="AboutDialog">
155.1970 -  <property name="title" translatable="yes">About VBA</property>
155.1971 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
155.1972 -  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
155.1973 -  <property name="modal">False</property>
155.1974 -  <property name="resizable">True</property>
155.1975 -  <property name="destroy_with_parent">True</property>
155.1976 -  <property name="skip_taskbar_hint">False</property>
155.1977 -  <property name="skip_pager_hint">False</property>
155.1978 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
155.1979 -  <property name="has_separator">True</property>
155.1980 -
155.1981 -  <child internal-child="vbox">
155.1982 -    <widget class="GtkVBox" id="dialog-vbox1">
155.1983 -      <property name="visible">True</property>
155.1984 -      <property name="homogeneous">False</property>
155.1985 -      <property name="spacing">0</property>
155.1986 -
155.1987 -      <child internal-child="action_area">
155.1988 -	<widget class="GtkHButtonBox" id="dialog-action_area1">
155.1989 -	  <property name="visible">True</property>
155.1990 -	  <property name="layout_style">GTK_BUTTONBOX_END</property>
155.1991 -
155.1992 -	  <child>
155.1993 -	    <widget class="GtkButton" id="closebutton1">
155.1994 -	      <property name="visible">True</property>
155.1995 -	      <property name="can_default">True</property>
155.1996 -	      <property name="can_focus">True</property>
155.1997 -	      <property name="label">gtk-close</property>
155.1998 -	      <property name="use_stock">True</property>
155.1999 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2000 -	      <property name="response_id">-7</property>
155.2001 -	    </widget>
155.2002 -	  </child>
155.2003 -	</widget>
155.2004 -	<packing>
155.2005 -	  <property name="padding">0</property>
155.2006 -	  <property name="expand">False</property>
155.2007 -	  <property name="fill">True</property>
155.2008 -	  <property name="pack_type">GTK_PACK_END</property>
155.2009 -	</packing>
155.2010 -      </child>
155.2011 -
155.2012 -      <child>
155.2013 -	<widget class="GtkAlignment" id="AboutIconContainer">
155.2014 -	  <property name="visible">True</property>
155.2015 -	  <property name="xalign">0.5</property>
155.2016 -	  <property name="yalign">0.5</property>
155.2017 -	  <property name="xscale">0</property>
155.2018 -	  <property name="yscale">0</property>
155.2019 -
155.2020 -	  <child>
155.2021 -	    <placeholder/>
155.2022 -	  </child>
155.2023 -	</widget>
155.2024 -	<packing>
155.2025 -	  <property name="padding">0</property>
155.2026 -	  <property name="expand">True</property>
155.2027 -	  <property name="fill">True</property>
155.2028 -	</packing>
155.2029 -      </child>
155.2030 -
155.2031 -      <child>
155.2032 -	<widget class="GtkLabel" id="VersionLabel">
155.2033 -	  <property name="visible">True</property>
155.2034 -	  <property name="can_focus">True</property>
155.2035 -	  <property name="label" translatable="yes"></property>
155.2036 -	  <property name="use_underline">False</property>
155.2037 -	  <property name="use_markup">True</property>
155.2038 -	  <property name="justify">GTK_JUSTIFY_CENTER</property>
155.2039 -	  <property name="wrap">False</property>
155.2040 -	  <property name="selectable">True</property>
155.2041 -	  <property name="xalign">0.5</property>
155.2042 -	  <property name="yalign">0.5</property>
155.2043 -	  <property name="xpad">5</property>
155.2044 -	  <property name="ypad">5</property>
155.2045 -	</widget>
155.2046 -	<packing>
155.2047 -	  <property name="padding">0</property>
155.2048 -	  <property name="expand">True</property>
155.2049 -	  <property name="fill">False</property>
155.2050 -	</packing>
155.2051 -      </child>
155.2052 -
155.2053 -      <child>
155.2054 -	<widget class="GtkLabel" id="label2">
155.2055 -	  <property name="visible">True</property>
155.2056 -	  <property name="can_focus">True</property>
155.2057 -	  <property name="label" translatable="yes">An emulator for Gameboy(TM) and GameboyAdvance(TM).</property>
155.2058 -	  <property name="use_underline">False</property>
155.2059 -	  <property name="use_markup">False</property>
155.2060 -	  <property name="justify">GTK_JUSTIFY_CENTER</property>
155.2061 -	  <property name="wrap">True</property>
155.2062 -	  <property name="selectable">True</property>
155.2063 -	  <property name="xalign">0.5</property>
155.2064 -	  <property name="yalign">0.5</property>
155.2065 -	  <property name="xpad">5</property>
155.2066 -	  <property name="ypad">5</property>
155.2067 -	</widget>
155.2068 -	<packing>
155.2069 -	  <property name="padding">0</property>
155.2070 -	  <property name="expand">True</property>
155.2071 -	  <property name="fill">False</property>
155.2072 -	</packing>
155.2073 -      </child>
155.2074 -
155.2075 -      <child>
155.2076 -	<widget class="GtkLabel" id="label24">
155.2077 -	  <property name="visible">True</property>
155.2078 -	  <property name="can_focus">True</property>
155.2079 -	  <property name="label" translatable="yes">&lt;i&gt;Special thanks to Yann Parmentier aka &quot;kohai&quot; for the icons.&lt;/i&gt;</property>
155.2080 -	  <property name="use_underline">False</property>
155.2081 -	  <property name="use_markup">True</property>
155.2082 -	  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2083 -	  <property name="wrap">False</property>
155.2084 -	  <property name="selectable">True</property>
155.2085 -	  <property name="xalign">0.5</property>
155.2086 -	  <property name="yalign">0.5</property>
155.2087 -	  <property name="xpad">5</property>
155.2088 -	  <property name="ypad">5</property>
155.2089 -	</widget>
155.2090 -	<packing>
155.2091 -	  <property name="padding">0</property>
155.2092 -	  <property name="expand">True</property>
155.2093 -	  <property name="fill">False</property>
155.2094 -	</packing>
155.2095 -      </child>
155.2096 -
155.2097 -      <child>
155.2098 -	<widget class="GtkLabel" id="label3">
155.2099 -	  <property name="visible">True</property>
155.2100 -	  <property name="can_focus">True</property>
155.2101 -	  <property name="label" translatable="yes">&lt;small&gt;Copyright (C) 2004 Forgotten and the VBA development team&lt;/small&gt;</property>
155.2102 -	  <property name="use_underline">False</property>
155.2103 -	  <property name="use_markup">True</property>
155.2104 -	  <property name="justify">GTK_JUSTIFY_CENTER</property>
155.2105 -	  <property name="wrap">True</property>
155.2106 -	  <property name="selectable">True</property>
155.2107 -	  <property name="xalign">0.5</property>
155.2108 -	  <property name="yalign">0.5</property>
155.2109 -	  <property name="xpad">5</property>
155.2110 -	  <property name="ypad">5</property>
155.2111 -	</widget>
155.2112 -	<packing>
155.2113 -	  <property name="padding">0</property>
155.2114 -	  <property name="expand">True</property>
155.2115 -	  <property name="fill">False</property>
155.2116 -	</packing>
155.2117 -      </child>
155.2118 -    </widget>
155.2119 -  </child>
155.2120 -</widget>
155.2121 -
155.2122 -<widget class="GtkDialog" id="ThrottleDialog">
155.2123 -  <property name="title" translatable="yes">Throttle</property>
155.2124 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
155.2125 -  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
155.2126 -  <property name="modal">False</property>
155.2127 -  <property name="resizable">True</property>
155.2128 -  <property name="destroy_with_parent">True</property>
155.2129 -  <property name="skip_taskbar_hint">False</property>
155.2130 -  <property name="skip_pager_hint">False</property>
155.2131 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
155.2132 -  <property name="has_separator">True</property>
155.2133 -
155.2134 -  <child internal-child="vbox">
155.2135 -    <widget class="GtkVBox" id="dialog-vbox2">
155.2136 -      <property name="visible">True</property>
155.2137 -      <property name="homogeneous">False</property>
155.2138 -      <property name="spacing">0</property>
155.2139 -
155.2140 -      <child internal-child="action_area">
155.2141 -	<widget class="GtkHButtonBox" id="dialog-action_area2">
155.2142 -	  <property name="visible">True</property>
155.2143 -	  <property name="layout_style">GTK_BUTTONBOX_END</property>
155.2144 -
155.2145 -	  <child>
155.2146 -	    <widget class="GtkButton" id="cancelbutton1">
155.2147 -	      <property name="visible">True</property>
155.2148 -	      <property name="can_default">True</property>
155.2149 -	      <property name="can_focus">True</property>
155.2150 -	      <property name="label">gtk-cancel</property>
155.2151 -	      <property name="use_stock">True</property>
155.2152 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2153 -	      <property name="response_id">-6</property>
155.2154 -	    </widget>
155.2155 -	  </child>
155.2156 -
155.2157 -	  <child>
155.2158 -	    <widget class="GtkButton" id="okbutton1">
155.2159 -	      <property name="visible">True</property>
155.2160 -	      <property name="can_default">True</property>
155.2161 -	      <property name="can_focus">True</property>
155.2162 -	      <property name="label">gtk-ok</property>
155.2163 -	      <property name="use_stock">True</property>
155.2164 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2165 -	      <property name="response_id">-5</property>
155.2166 -	    </widget>
155.2167 -	  </child>
155.2168 -	</widget>
155.2169 -	<packing>
155.2170 -	  <property name="padding">0</property>
155.2171 -	  <property name="expand">False</property>
155.2172 -	  <property name="fill">True</property>
155.2173 -	  <property name="pack_type">GTK_PACK_END</property>
155.2174 -	</packing>
155.2175 -      </child>
155.2176 -
155.2177 -      <child>
155.2178 -	<widget class="GtkAlignment" id="alignment4">
155.2179 -	  <property name="visible">True</property>
155.2180 -	  <property name="xalign">0.5</property>
155.2181 -	  <property name="yalign">0.5</property>
155.2182 -	  <property name="xscale">0</property>
155.2183 -	  <property name="yscale">0</property>
155.2184 -
155.2185 -	  <child>
155.2186 -	    <widget class="GtkHBox" id="hbox1">
155.2187 -	      <property name="visible">True</property>
155.2188 -	      <property name="homogeneous">False</property>
155.2189 -	      <property name="spacing">0</property>
155.2190 -
155.2191 -	      <child>
155.2192 -		<widget class="GtkLabel" id="label4">
155.2193 -		  <property name="visible">True</property>
155.2194 -		  <property name="label" translatable="yes">Throttle : </property>
155.2195 -		  <property name="use_underline">False</property>
155.2196 -		  <property name="use_markup">False</property>
155.2197 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2198 -		  <property name="wrap">False</property>
155.2199 -		  <property name="selectable">False</property>
155.2200 -		  <property name="xalign">1</property>
155.2201 -		  <property name="yalign">0.5</property>
155.2202 -		  <property name="xpad">0</property>
155.2203 -		  <property name="ypad">0</property>
155.2204 -		</widget>
155.2205 -		<packing>
155.2206 -		  <property name="padding">0</property>
155.2207 -		  <property name="expand">True</property>
155.2208 -		  <property name="fill">True</property>
155.2209 -		</packing>
155.2210 -	      </child>
155.2211 -
155.2212 -	      <child>
155.2213 -		<widget class="GtkSpinButton" id="ThrottleSpin">
155.2214 -		  <property name="visible">True</property>
155.2215 -		  <property name="can_focus">True</property>
155.2216 -		  <property name="climb_rate">1</property>
155.2217 -		  <property name="digits">0</property>
155.2218 -		  <property name="numeric">True</property>
155.2219 -		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
155.2220 -		  <property name="snap_to_ticks">True</property>
155.2221 -		  <property name="wrap">True</property>
155.2222 -		  <property name="adjustment">100 5 1000 1 25 25</property>
155.2223 -		</widget>
155.2224 -		<packing>
155.2225 -		  <property name="padding">0</property>
155.2226 -		  <property name="expand">True</property>
155.2227 -		  <property name="fill">True</property>
155.2228 -		</packing>
155.2229 -	      </child>
155.2230 -
155.2231 -	      <child>
155.2232 -		<widget class="GtkLabel" id="label5">
155.2233 -		  <property name="visible">True</property>
155.2234 -		  <property name="label" translatable="yes"> %</property>
155.2235 -		  <property name="use_underline">False</property>
155.2236 -		  <property name="use_markup">False</property>
155.2237 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2238 -		  <property name="wrap">False</property>
155.2239 -		  <property name="selectable">False</property>
155.2240 -		  <property name="xalign">0</property>
155.2241 -		  <property name="yalign">0.5</property>
155.2242 -		  <property name="xpad">0</property>
155.2243 -		  <property name="ypad">0</property>
155.2244 -		</widget>
155.2245 -		<packing>
155.2246 -		  <property name="padding">0</property>
155.2247 -		  <property name="expand">True</property>
155.2248 -		  <property name="fill">True</property>
155.2249 -		</packing>
155.2250 -	      </child>
155.2251 -	    </widget>
155.2252 -	  </child>
155.2253 -	</widget>
155.2254 -	<packing>
155.2255 -	  <property name="padding">0</property>
155.2256 -	  <property name="expand">True</property>
155.2257 -	  <property name="fill">True</property>
155.2258 -	</packing>
155.2259 -      </child>
155.2260 -    </widget>
155.2261 -  </child>
155.2262 -</widget>
155.2263 -
155.2264 -<widget class="GtkDialog" id="DirectoriesDialog">
155.2265 -  <property name="title" translatable="yes">Directories</property>
155.2266 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
155.2267 -  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
155.2268 -  <property name="modal">False</property>
155.2269 -  <property name="resizable">True</property>
155.2270 -  <property name="destroy_with_parent">True</property>
155.2271 -  <property name="skip_taskbar_hint">False</property>
155.2272 -  <property name="skip_pager_hint">False</property>
155.2273 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
155.2274 -  <property name="has_separator">True</property>
155.2275 -
155.2276 -  <child internal-child="vbox">
155.2277 -    <widget class="GtkVBox" id="dialog-vbox3">
155.2278 -      <property name="visible">True</property>
155.2279 -      <property name="homogeneous">False</property>
155.2280 -      <property name="spacing">0</property>
155.2281 -
155.2282 -      <child internal-child="action_area">
155.2283 -	<widget class="GtkHButtonBox" id="dialog-action_area3">
155.2284 -	  <property name="visible">True</property>
155.2285 -	  <property name="layout_style">GTK_BUTTONBOX_END</property>
155.2286 -
155.2287 -	  <child>
155.2288 -	    <widget class="GtkButton" id="cancelbutton2">
155.2289 -	      <property name="visible">True</property>
155.2290 -	      <property name="can_default">True</property>
155.2291 -	      <property name="can_focus">True</property>
155.2292 -	      <property name="label">gtk-cancel</property>
155.2293 -	      <property name="use_stock">True</property>
155.2294 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2295 -	      <property name="response_id">-6</property>
155.2296 -	    </widget>
155.2297 -	  </child>
155.2298 -
155.2299 -	  <child>
155.2300 -	    <widget class="GtkButton" id="okbutton2">
155.2301 -	      <property name="visible">True</property>
155.2302 -	      <property name="can_default">True</property>
155.2303 -	      <property name="can_focus">True</property>
155.2304 -	      <property name="label">gtk-ok</property>
155.2305 -	      <property name="use_stock">True</property>
155.2306 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2307 -	      <property name="response_id">-5</property>
155.2308 -	    </widget>
155.2309 -	  </child>
155.2310 -	</widget>
155.2311 -	<packing>
155.2312 -	  <property name="padding">0</property>
155.2313 -	  <property name="expand">False</property>
155.2314 -	  <property name="fill">True</property>
155.2315 -	  <property name="pack_type">GTK_PACK_END</property>
155.2316 -	</packing>
155.2317 -      </child>
155.2318 -
155.2319 -      <child>
155.2320 -	<widget class="GtkTable" id="table1">
155.2321 -	  <property name="visible">True</property>
155.2322 -	  <property name="n_rows">5</property>
155.2323 -	  <property name="n_columns">4</property>
155.2324 -	  <property name="homogeneous">False</property>
155.2325 -	  <property name="row_spacing">0</property>
155.2326 -	  <property name="column_spacing">0</property>
155.2327 -
155.2328 -	  <child>
155.2329 -	    <widget class="GtkLabel" id="label6">
155.2330 -	      <property name="visible">True</property>
155.2331 -	      <property name="label" translatable="yes">GBA roms : </property>
155.2332 -	      <property name="use_underline">False</property>
155.2333 -	      <property name="use_markup">False</property>
155.2334 -	      <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2335 -	      <property name="wrap">False</property>
155.2336 -	      <property name="selectable">False</property>
155.2337 -	      <property name="xalign">1</property>
155.2338 -	      <property name="yalign">0.5</property>
155.2339 -	      <property name="xpad">0</property>
155.2340 -	      <property name="ypad">0</property>
155.2341 -	    </widget>
155.2342 -	    <packing>
155.2343 -	      <property name="left_attach">0</property>
155.2344 -	      <property name="right_attach">1</property>
155.2345 -	      <property name="top_attach">0</property>
155.2346 -	      <property name="bottom_attach">1</property>
155.2347 -	      <property name="x_options">fill</property>
155.2348 -	      <property name="y_options">expand</property>
155.2349 -	    </packing>
155.2350 -	  </child>
155.2351 -
155.2352 -	  <child>
155.2353 -	    <widget class="GtkEntry" id="GBARomsDirEntry">
155.2354 -	      <property name="visible">True</property>
155.2355 -	      <property name="can_focus">True</property>
155.2356 -	      <property name="editable">True</property>
155.2357 -	      <property name="visibility">True</property>
155.2358 -	      <property name="max_length">0</property>
155.2359 -	      <property name="text" translatable="yes"></property>
155.2360 -	      <property name="has_frame">True</property>
155.2361 -	      <property name="invisible_char" translatable="yes">*</property>
155.2362 -	      <property name="activates_default">False</property>
155.2363 -	    </widget>
155.2364 -	    <packing>
155.2365 -	      <property name="left_attach">1</property>
155.2366 -	      <property name="right_attach">2</property>
155.2367 -	      <property name="top_attach">0</property>
155.2368 -	      <property name="bottom_attach">1</property>
155.2369 -	      <property name="y_options">expand</property>
155.2370 -	    </packing>
155.2371 -	  </child>
155.2372 -
155.2373 -	  <child>
155.2374 -	    <widget class="GtkButton" id="GBARomsDirResetButton">
155.2375 -	      <property name="visible">True</property>
155.2376 -	      <property name="can_focus">True</property>
155.2377 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2378 -
155.2379 -	      <child>
155.2380 -		<widget class="GtkImage" id="image83">
155.2381 -		  <property name="visible">True</property>
155.2382 -		  <property name="stock">gtk-cancel</property>
155.2383 -		  <property name="icon_size">4</property>
155.2384 -		  <property name="xalign">0.5</property>
155.2385 -		  <property name="yalign">0.5</property>
155.2386 -		  <property name="xpad">0</property>
155.2387 -		  <property name="ypad">0</property>
155.2388 -		</widget>
155.2389 -	      </child>
155.2390 -	    </widget>
155.2391 -	    <packing>
155.2392 -	      <property name="left_attach">2</property>
155.2393 -	      <property name="right_attach">3</property>
155.2394 -	      <property name="top_attach">0</property>
155.2395 -	      <property name="bottom_attach">1</property>
155.2396 -	      <property name="x_options">fill</property>
155.2397 -	      <property name="y_options">expand</property>
155.2398 -	    </packing>
155.2399 -	  </child>
155.2400 -
155.2401 -	  <child>
155.2402 -	    <widget class="GtkButton" id="GBARomsDirSelectButton">
155.2403 -	      <property name="visible">True</property>
155.2404 -	      <property name="can_focus">True</property>
155.2405 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2406 -
155.2407 -	      <child>
155.2408 -		<widget class="GtkImage" id="image84">
155.2409 -		  <property name="visible">True</property>
155.2410 -		  <property name="stock">gtk-open</property>
155.2411 -		  <property name="icon_size">4</property>
155.2412 -		  <property name="xalign">0.5</property>
155.2413 -		  <property name="yalign">0.5</property>
155.2414 -		  <property name="xpad">0</property>
155.2415 -		  <property name="ypad">0</property>
155.2416 -		</widget>
155.2417 -	      </child>
155.2418 -	    </widget>
155.2419 -	    <packing>
155.2420 -	      <property name="left_attach">3</property>
155.2421 -	      <property name="right_attach">4</property>
155.2422 -	      <property name="top_attach">0</property>
155.2423 -	      <property name="bottom_attach">1</property>
155.2424 -	      <property name="x_options">fill</property>
155.2425 -	      <property name="y_options">expand</property>
155.2426 -	    </packing>
155.2427 -	  </child>
155.2428 -
155.2429 -	  <child>
155.2430 -	    <widget class="GtkLabel" id="label7">
155.2431 -	      <property name="visible">True</property>
155.2432 -	      <property name="label" translatable="yes">GB roms : </property>
155.2433 -	      <property name="use_underline">False</property>
155.2434 -	      <property name="use_markup">False</property>
155.2435 -	      <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2436 -	      <property name="wrap">False</property>
155.2437 -	      <property name="selectable">False</property>
155.2438 -	      <property name="xalign">1</property>
155.2439 -	      <property name="yalign">0.5</property>
155.2440 -	      <property name="xpad">0</property>
155.2441 -	      <property name="ypad">0</property>
155.2442 -	    </widget>
155.2443 -	    <packing>
155.2444 -	      <property name="left_attach">0</property>
155.2445 -	      <property name="right_attach">1</property>
155.2446 -	      <property name="top_attach">1</property>
155.2447 -	      <property name="bottom_attach">2</property>
155.2448 -	      <property name="x_options">fill</property>
155.2449 -	      <property name="y_options">expand</property>
155.2450 -	    </packing>
155.2451 -	  </child>
155.2452 -
155.2453 -	  <child>
155.2454 -	    <widget class="GtkButton" id="GBRomsDirSelectButton">
155.2455 -	      <property name="visible">True</property>
155.2456 -	      <property name="can_focus">True</property>
155.2457 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2458 -
155.2459 -	      <child>
155.2460 -		<widget class="GtkImage" id="image94">
155.2461 -		  <property name="visible">True</property>
155.2462 -		  <property name="stock">gtk-open</property>
155.2463 -		  <property name="icon_size">4</property>
155.2464 -		  <property name="xalign">0.5</property>
155.2465 -		  <property name="yalign">0.5</property>
155.2466 -		  <property name="xpad">0</property>
155.2467 -		  <property name="ypad">0</property>
155.2468 -		</widget>
155.2469 -	      </child>
155.2470 -	    </widget>
155.2471 -	    <packing>
155.2472 -	      <property name="left_attach">3</property>
155.2473 -	      <property name="right_attach">4</property>
155.2474 -	      <property name="top_attach">1</property>
155.2475 -	      <property name="bottom_attach">2</property>
155.2476 -	      <property name="x_options">fill</property>
155.2477 -	      <property name="y_options">expand</property>
155.2478 -	    </packing>
155.2479 -	  </child>
155.2480 -
155.2481 -	  <child>
155.2482 -	    <widget class="GtkLabel" id="label8">
155.2483 -	      <property name="visible">True</property>
155.2484 -	      <property name="label" translatable="yes">Batteries : </property>
155.2485 -	      <property name="use_underline">False</property>
155.2486 -	      <property name="use_markup">False</property>
155.2487 -	      <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2488 -	      <property name="wrap">False</property>
155.2489 -	      <property name="selectable">False</property>
155.2490 -	      <property name="xalign">1</property>
155.2491 -	      <property name="yalign">0.5</property>
155.2492 -	      <property name="xpad">0</property>
155.2493 -	      <property name="ypad">0</property>
155.2494 -	    </widget>
155.2495 -	    <packing>
155.2496 -	      <property name="left_attach">0</property>
155.2497 -	      <property name="right_attach">1</property>
155.2498 -	      <property name="top_attach">2</property>
155.2499 -	      <property name="bottom_attach">3</property>
155.2500 -	      <property name="x_options">fill</property>
155.2501 -	      <property name="y_options">expand</property>
155.2502 -	    </packing>
155.2503 -	  </child>
155.2504 -
155.2505 -	  <child>
155.2506 -	    <widget class="GtkEntry" id="BatteriesDirEntry">
155.2507 -	      <property name="visible">True</property>
155.2508 -	      <property name="can_focus">True</property>
155.2509 -	      <property name="editable">True</property>
155.2510 -	      <property name="visibility">True</property>
155.2511 -	      <property name="max_length">0</property>
155.2512 -	      <property name="text" translatable="yes"></property>
155.2513 -	      <property name="has_frame">True</property>
155.2514 -	      <property name="invisible_char" translatable="yes">*</property>
155.2515 -	      <property name="activates_default">False</property>
155.2516 -	    </widget>
155.2517 -	    <packing>
155.2518 -	      <property name="left_attach">1</property>
155.2519 -	      <property name="right_attach">2</property>
155.2520 -	      <property name="top_attach">2</property>
155.2521 -	      <property name="bottom_attach">3</property>
155.2522 -	      <property name="y_options">expand</property>
155.2523 -	    </packing>
155.2524 -	  </child>
155.2525 -
155.2526 -	  <child>
155.2527 -	    <widget class="GtkButton" id="BatteriesDirSelectButton">
155.2528 -	      <property name="visible">True</property>
155.2529 -	      <property name="can_focus">True</property>
155.2530 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2531 -
155.2532 -	      <child>
155.2533 -		<widget class="GtkImage" id="image98">
155.2534 -		  <property name="visible">True</property>
155.2535 -		  <property name="stock">gtk-open</property>
155.2536 -		  <property name="icon_size">4</property>
155.2537 -		  <property name="xalign">0.5</property>
155.2538 -		  <property name="yalign">0.5</property>
155.2539 -		  <property name="xpad">0</property>
155.2540 -		  <property name="ypad">0</property>
155.2541 -		</widget>
155.2542 -	      </child>
155.2543 -	    </widget>
155.2544 -	    <packing>
155.2545 -	      <property name="left_attach">3</property>
155.2546 -	      <property name="right_attach">4</property>
155.2547 -	      <property name="top_attach">2</property>
155.2548 -	      <property name="bottom_attach">3</property>
155.2549 -	      <property name="x_options">fill</property>
155.2550 -	      <property name="y_options">expand</property>
155.2551 -	    </packing>
155.2552 -	  </child>
155.2553 -
155.2554 -	  <child>
155.2555 -	    <widget class="GtkButton" id="BatteriesDirResetButton">
155.2556 -	      <property name="visible">True</property>
155.2557 -	      <property name="can_focus">True</property>
155.2558 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2559 -
155.2560 -	      <child>
155.2561 -		<widget class="GtkImage" id="image95">
155.2562 -		  <property name="visible">True</property>
155.2563 -		  <property name="stock">gtk-cancel</property>
155.2564 -		  <property name="icon_size">4</property>
155.2565 -		  <property name="xalign">0.5</property>
155.2566 -		  <property name="yalign">0.5</property>
155.2567 -		  <property name="xpad">0</property>
155.2568 -		  <property name="ypad">0</property>
155.2569 -		</widget>
155.2570 -	      </child>
155.2571 -	    </widget>
155.2572 -	    <packing>
155.2573 -	      <property name="left_attach">2</property>
155.2574 -	      <property name="right_attach">3</property>
155.2575 -	      <property name="top_attach">2</property>
155.2576 -	      <property name="bottom_attach">3</property>
155.2577 -	      <property name="x_options">fill</property>
155.2578 -	      <property name="y_options">expand</property>
155.2579 -	    </packing>
155.2580 -	  </child>
155.2581 -
155.2582 -	  <child>
155.2583 -	    <widget class="GtkLabel" id="label9">
155.2584 -	      <property name="visible">True</property>
155.2585 -	      <property name="label" translatable="yes">Saves : </property>
155.2586 -	      <property name="use_underline">False</property>
155.2587 -	      <property name="use_markup">False</property>
155.2588 -	      <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2589 -	      <property name="wrap">False</property>
155.2590 -	      <property name="selectable">False</property>
155.2591 -	      <property name="xalign">1</property>
155.2592 -	      <property name="yalign">0.5</property>
155.2593 -	      <property name="xpad">0</property>
155.2594 -	      <property name="ypad">0</property>
155.2595 -	    </widget>
155.2596 -	    <packing>
155.2597 -	      <property name="left_attach">0</property>
155.2598 -	      <property name="right_attach">1</property>
155.2599 -	      <property name="top_attach">3</property>
155.2600 -	      <property name="bottom_attach">4</property>
155.2601 -	      <property name="x_options">fill</property>
155.2602 -	      <property name="y_options">expand</property>
155.2603 -	    </packing>
155.2604 -	  </child>
155.2605 -
155.2606 -	  <child>
155.2607 -	    <widget class="GtkEntry" id="SavesDirEntry">
155.2608 -	      <property name="visible">True</property>
155.2609 -	      <property name="can_focus">True</property>
155.2610 -	      <property name="editable">True</property>
155.2611 -	      <property name="visibility">True</property>
155.2612 -	      <property name="max_length">0</property>
155.2613 -	      <property name="text" translatable="yes"></property>
155.2614 -	      <property name="has_frame">True</property>
155.2615 -	      <property name="invisible_char" translatable="yes">*</property>
155.2616 -	      <property name="activates_default">False</property>
155.2617 -	    </widget>
155.2618 -	    <packing>
155.2619 -	      <property name="left_attach">1</property>
155.2620 -	      <property name="right_attach">2</property>
155.2621 -	      <property name="top_attach">3</property>
155.2622 -	      <property name="bottom_attach">4</property>
155.2623 -	      <property name="y_options">expand</property>
155.2624 -	    </packing>
155.2625 -	  </child>
155.2626 -
155.2627 -	  <child>
155.2628 -	    <widget class="GtkButton" id="SavesDirResetButton">
155.2629 -	      <property name="visible">True</property>
155.2630 -	      <property name="can_focus">True</property>
155.2631 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2632 -
155.2633 -	      <child>
155.2634 -		<widget class="GtkImage" id="image96">
155.2635 -		  <property name="visible">True</property>
155.2636 -		  <property name="stock">gtk-cancel</property>
155.2637 -		  <property name="icon_size">4</property>
155.2638 -		  <property name="xalign">0.5</property>
155.2639 -		  <property name="yalign">0.5</property>
155.2640 -		  <property name="xpad">0</property>
155.2641 -		  <property name="ypad">0</property>
155.2642 -		</widget>
155.2643 -	      </child>
155.2644 -	    </widget>
155.2645 -	    <packing>
155.2646 -	      <property name="left_attach">2</property>
155.2647 -	      <property name="right_attach">3</property>
155.2648 -	      <property name="top_attach">3</property>
155.2649 -	      <property name="bottom_attach">4</property>
155.2650 -	      <property name="x_options">fill</property>
155.2651 -	      <property name="y_options">expand</property>
155.2652 -	    </packing>
155.2653 -	  </child>
155.2654 -
155.2655 -	  <child>
155.2656 -	    <widget class="GtkButton" id="SavesDirSelectButton">
155.2657 -	      <property name="visible">True</property>
155.2658 -	      <property name="can_focus">True</property>
155.2659 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2660 -
155.2661 -	      <child>
155.2662 -		<widget class="GtkImage" id="image99">
155.2663 -		  <property name="visible">True</property>
155.2664 -		  <property name="stock">gtk-open</property>
155.2665 -		  <property name="icon_size">4</property>
155.2666 -		  <property name="xalign">0.5</property>
155.2667 -		  <property name="yalign">0.5</property>
155.2668 -		  <property name="xpad">0</property>
155.2669 -		  <property name="ypad">0</property>
155.2670 -		</widget>
155.2671 -	      </child>
155.2672 -	    </widget>
155.2673 -	    <packing>
155.2674 -	      <property name="left_attach">3</property>
155.2675 -	      <property name="right_attach">4</property>
155.2676 -	      <property name="top_attach">3</property>
155.2677 -	      <property name="bottom_attach">4</property>
155.2678 -	      <property name="x_options">fill</property>
155.2679 -	      <property name="y_options">expand</property>
155.2680 -	    </packing>
155.2681 -	  </child>
155.2682 -
155.2683 -	  <child>
155.2684 -	    <widget class="GtkLabel" id="label10">
155.2685 -	      <property name="visible">True</property>
155.2686 -	      <property name="label" translatable="yes">Captures : </property>
155.2687 -	      <property name="use_underline">False</property>
155.2688 -	      <property name="use_markup">False</property>
155.2689 -	      <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2690 -	      <property name="wrap">False</property>
155.2691 -	      <property name="selectable">False</property>
155.2692 -	      <property name="xalign">1</property>
155.2693 -	      <property name="yalign">0.5</property>
155.2694 -	      <property name="xpad">0</property>
155.2695 -	      <property name="ypad">0</property>
155.2696 -	    </widget>
155.2697 -	    <packing>
155.2698 -	      <property name="left_attach">0</property>
155.2699 -	      <property name="right_attach">1</property>
155.2700 -	      <property name="top_attach">4</property>
155.2701 -	      <property name="bottom_attach">5</property>
155.2702 -	      <property name="x_options">fill</property>
155.2703 -	      <property name="y_options">expand</property>
155.2704 -	    </packing>
155.2705 -	  </child>
155.2706 -
155.2707 -	  <child>
155.2708 -	    <widget class="GtkEntry" id="CapturesDirEntry">
155.2709 -	      <property name="visible">True</property>
155.2710 -	      <property name="can_focus">True</property>
155.2711 -	      <property name="editable">True</property>
155.2712 -	      <property name="visibility">True</property>
155.2713 -	      <property name="max_length">0</property>
155.2714 -	      <property name="text" translatable="yes"></property>
155.2715 -	      <property name="has_frame">True</property>
155.2716 -	      <property name="invisible_char" translatable="yes">*</property>
155.2717 -	      <property name="activates_default">False</property>
155.2718 -	    </widget>
155.2719 -	    <packing>
155.2720 -	      <property name="left_attach">1</property>
155.2721 -	      <property name="right_attach">2</property>
155.2722 -	      <property name="top_attach">4</property>
155.2723 -	      <property name="bottom_attach">5</property>
155.2724 -	      <property name="y_options">expand</property>
155.2725 -	    </packing>
155.2726 -	  </child>
155.2727 -
155.2728 -	  <child>
155.2729 -	    <widget class="GtkButton" id="CapturesDirResetButton">
155.2730 -	      <property name="visible">True</property>
155.2731 -	      <property name="can_focus">True</property>
155.2732 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2733 -
155.2734 -	      <child>
155.2735 -		<widget class="GtkImage" id="image97">
155.2736 -		  <property name="visible">True</property>
155.2737 -		  <property name="stock">gtk-cancel</property>
155.2738 -		  <property name="icon_size">4</property>
155.2739 -		  <property name="xalign">0.5</property>
155.2740 -		  <property name="yalign">0.5</property>
155.2741 -		  <property name="xpad">0</property>
155.2742 -		  <property name="ypad">0</property>
155.2743 -		</widget>
155.2744 -	      </child>
155.2745 -	    </widget>
155.2746 -	    <packing>
155.2747 -	      <property name="left_attach">2</property>
155.2748 -	      <property name="right_attach">3</property>
155.2749 -	      <property name="top_attach">4</property>
155.2750 -	      <property name="bottom_attach">5</property>
155.2751 -	      <property name="x_options">fill</property>
155.2752 -	      <property name="y_options">expand</property>
155.2753 -	    </packing>
155.2754 -	  </child>
155.2755 -
155.2756 -	  <child>
155.2757 -	    <widget class="GtkButton" id="CapturesDirSelectButton">
155.2758 -	      <property name="visible">True</property>
155.2759 -	      <property name="can_focus">True</property>
155.2760 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2761 -
155.2762 -	      <child>
155.2763 -		<widget class="GtkImage" id="image100">
155.2764 -		  <property name="visible">True</property>
155.2765 -		  <property name="stock">gtk-open</property>
155.2766 -		  <property name="icon_size">4</property>
155.2767 -		  <property name="xalign">0.5</property>
155.2768 -		  <property name="yalign">0.5</property>
155.2769 -		  <property name="xpad">0</property>
155.2770 -		  <property name="ypad">0</property>
155.2771 -		</widget>
155.2772 -	      </child>
155.2773 -	    </widget>
155.2774 -	    <packing>
155.2775 -	      <property name="left_attach">3</property>
155.2776 -	      <property name="right_attach">4</property>
155.2777 -	      <property name="top_attach">4</property>
155.2778 -	      <property name="bottom_attach">5</property>
155.2779 -	      <property name="x_options">fill</property>
155.2780 -	      <property name="y_options">expand</property>
155.2781 -	    </packing>
155.2782 -	  </child>
155.2783 -
155.2784 -	  <child>
155.2785 -	    <widget class="GtkEntry" id="GBRomsDirEntry">
155.2786 -	      <property name="visible">True</property>
155.2787 -	      <property name="can_focus">True</property>
155.2788 -	      <property name="editable">True</property>
155.2789 -	      <property name="visibility">True</property>
155.2790 -	      <property name="max_length">0</property>
155.2791 -	      <property name="text" translatable="yes"></property>
155.2792 -	      <property name="has_frame">True</property>
155.2793 -	      <property name="invisible_char" translatable="yes">*</property>
155.2794 -	      <property name="activates_default">False</property>
155.2795 -	    </widget>
155.2796 -	    <packing>
155.2797 -	      <property name="left_attach">1</property>
155.2798 -	      <property name="right_attach">2</property>
155.2799 -	      <property name="top_attach">1</property>
155.2800 -	      <property name="bottom_attach">2</property>
155.2801 -	      <property name="y_options">expand</property>
155.2802 -	    </packing>
155.2803 -	  </child>
155.2804 -
155.2805 -	  <child>
155.2806 -	    <widget class="GtkButton" id="GBRomsDirResetButton">
155.2807 -	      <property name="visible">True</property>
155.2808 -	      <property name="can_focus">True</property>
155.2809 -	      <property name="relief">GTK_RELIEF_NONE</property>
155.2810 -
155.2811 -	      <child>
155.2812 -		<widget class="GtkImage" id="image101">
155.2813 -		  <property name="visible">True</property>
155.2814 -		  <property name="stock">gtk-cancel</property>
155.2815 -		  <property name="icon_size">4</property>
155.2816 -		  <property name="xalign">0.5</property>
155.2817 -		  <property name="yalign">0.5</property>
155.2818 -		  <property name="xpad">0</property>
155.2819 -		  <property name="ypad">0</property>
155.2820 -		</widget>
155.2821 -	      </child>
155.2822 -	    </widget>
155.2823 -	    <packing>
155.2824 -	      <property name="left_attach">2</property>
155.2825 -	      <property name="right_attach">3</property>
155.2826 -	      <property name="top_attach">1</property>
155.2827 -	      <property name="bottom_attach">2</property>
155.2828 -	      <property name="x_options">fill</property>
155.2829 -	      <property name="y_options">expand</property>
155.2830 -	    </packing>
155.2831 -	  </child>
155.2832 -	</widget>
155.2833 -	<packing>
155.2834 -	  <property name="padding">0</property>
155.2835 -	  <property name="expand">True</property>
155.2836 -	  <property name="fill">True</property>
155.2837 -	</packing>
155.2838 -      </child>
155.2839 -    </widget>
155.2840 -  </child>
155.2841 -</widget>
155.2842 -
155.2843 -<widget class="GtkDialog" id="JoypadConfigDialog">
155.2844 -  <property name="title" translatable="yes">Joypad config</property>
155.2845 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
155.2846 -  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
155.2847 -  <property name="modal">False</property>
155.2848 -  <property name="resizable">True</property>
155.2849 -  <property name="destroy_with_parent">True</property>
155.2850 -  <property name="skip_taskbar_hint">False</property>
155.2851 -  <property name="skip_pager_hint">False</property>
155.2852 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
155.2853 -  <property name="has_separator">True</property>
155.2854 -
155.2855 -  <child internal-child="vbox">
155.2856 -    <widget class="GtkVBox" id="dialog-vbox4">
155.2857 -      <property name="visible">True</property>
155.2858 -      <property name="homogeneous">False</property>
155.2859 -      <property name="spacing">0</property>
155.2860 -
155.2861 -      <child internal-child="action_area">
155.2862 -	<widget class="GtkHButtonBox" id="dialog-action_area4">
155.2863 -	  <property name="visible">True</property>
155.2864 -	  <property name="layout_style">GTK_BUTTONBOX_END</property>
155.2865 -
155.2866 -	  <child>
155.2867 -	    <widget class="GtkButton" id="cancelbutton3">
155.2868 -	      <property name="visible">True</property>
155.2869 -	      <property name="can_default">True</property>
155.2870 -	      <property name="can_focus">True</property>
155.2871 -	      <property name="label">gtk-cancel</property>
155.2872 -	      <property name="use_stock">True</property>
155.2873 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2874 -	      <property name="response_id">-6</property>
155.2875 -	    </widget>
155.2876 -	  </child>
155.2877 -
155.2878 -	  <child>
155.2879 -	    <widget class="GtkButton" id="JoypadOkButton">
155.2880 -	      <property name="visible">True</property>
155.2881 -	      <property name="can_default">True</property>
155.2882 -	      <property name="can_focus">True</property>
155.2883 -	      <property name="label">gtk-ok</property>
155.2884 -	      <property name="use_stock">True</property>
155.2885 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.2886 -	      <property name="response_id">-5</property>
155.2887 -	    </widget>
155.2888 -	  </child>
155.2889 -	</widget>
155.2890 -	<packing>
155.2891 -	  <property name="padding">0</property>
155.2892 -	  <property name="expand">False</property>
155.2893 -	  <property name="fill">True</property>
155.2894 -	  <property name="pack_type">GTK_PACK_END</property>
155.2895 -	</packing>
155.2896 -      </child>
155.2897 -
155.2898 -      <child>
155.2899 -	<widget class="GtkAlignment" id="alignment1">
155.2900 -	  <property name="visible">True</property>
155.2901 -	  <property name="xalign">0.5</property>
155.2902 -	  <property name="yalign">0.5</property>
155.2903 -	  <property name="xscale">0</property>
155.2904 -	  <property name="yscale">1</property>
155.2905 -
155.2906 -	  <child>
155.2907 -	    <widget class="GtkTable" id="table2">
155.2908 -	      <property name="visible">True</property>
155.2909 -	      <property name="n_rows">12</property>
155.2910 -	      <property name="n_columns">2</property>
155.2911 -	      <property name="homogeneous">False</property>
155.2912 -	      <property name="row_spacing">5</property>
155.2913 -	      <property name="column_spacing">0</property>
155.2914 -
155.2915 -	      <child>
155.2916 -		<widget class="GtkEntry" id="JoypadUpEntry">
155.2917 -		  <property name="visible">True</property>
155.2918 -		  <property name="can_focus">True</property>
155.2919 -		  <property name="editable">False</property>
155.2920 -		  <property name="visibility">True</property>
155.2921 -		  <property name="max_length">0</property>
155.2922 -		  <property name="text" translatable="yes"></property>
155.2923 -		  <property name="has_frame">True</property>
155.2924 -		  <property name="invisible_char" translatable="yes">*</property>
155.2925 -		  <property name="activates_default">False</property>
155.2926 -		</widget>
155.2927 -		<packing>
155.2928 -		  <property name="left_attach">1</property>
155.2929 -		  <property name="right_attach">2</property>
155.2930 -		  <property name="top_attach">0</property>
155.2931 -		  <property name="bottom_attach">1</property>
155.2932 -		  <property name="x_options">fill</property>
155.2933 -		  <property name="y_options">expand</property>
155.2934 -		</packing>
155.2935 -	      </child>
155.2936 -
155.2937 -	      <child>
155.2938 -		<widget class="GtkLabel" id="label12">
155.2939 -		  <property name="visible">True</property>
155.2940 -		  <property name="label" translatable="yes">Down : </property>
155.2941 -		  <property name="use_underline">False</property>
155.2942 -		  <property name="use_markup">False</property>
155.2943 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2944 -		  <property name="wrap">False</property>
155.2945 -		  <property name="selectable">False</property>
155.2946 -		  <property name="xalign">1</property>
155.2947 -		  <property name="yalign">0.5</property>
155.2948 -		  <property name="xpad">0</property>
155.2949 -		  <property name="ypad">0</property>
155.2950 -		</widget>
155.2951 -		<packing>
155.2952 -		  <property name="left_attach">0</property>
155.2953 -		  <property name="right_attach">1</property>
155.2954 -		  <property name="top_attach">1</property>
155.2955 -		  <property name="bottom_attach">2</property>
155.2956 -		  <property name="x_options">fill</property>
155.2957 -		  <property name="y_options">expand</property>
155.2958 -		</packing>
155.2959 -	      </child>
155.2960 -
155.2961 -	      <child>
155.2962 -		<widget class="GtkLabel" id="label13">
155.2963 -		  <property name="visible">True</property>
155.2964 -		  <property name="label" translatable="yes">Left : </property>
155.2965 -		  <property name="use_underline">False</property>
155.2966 -		  <property name="use_markup">False</property>
155.2967 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2968 -		  <property name="wrap">False</property>
155.2969 -		  <property name="selectable">False</property>
155.2970 -		  <property name="xalign">1</property>
155.2971 -		  <property name="yalign">0.5</property>
155.2972 -		  <property name="xpad">0</property>
155.2973 -		  <property name="ypad">0</property>
155.2974 -		</widget>
155.2975 -		<packing>
155.2976 -		  <property name="left_attach">0</property>
155.2977 -		  <property name="right_attach">1</property>
155.2978 -		  <property name="top_attach">2</property>
155.2979 -		  <property name="bottom_attach">3</property>
155.2980 -		  <property name="x_options">fill</property>
155.2981 -		  <property name="y_options">expand</property>
155.2982 -		</packing>
155.2983 -	      </child>
155.2984 -
155.2985 -	      <child>
155.2986 -		<widget class="GtkLabel" id="label14">
155.2987 -		  <property name="visible">True</property>
155.2988 -		  <property name="label" translatable="yes">Right : </property>
155.2989 -		  <property name="use_underline">False</property>
155.2990 -		  <property name="use_markup">False</property>
155.2991 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.2992 -		  <property name="wrap">False</property>
155.2993 -		  <property name="selectable">False</property>
155.2994 -		  <property name="xalign">1</property>
155.2995 -		  <property name="yalign">0.5</property>
155.2996 -		  <property name="xpad">0</property>
155.2997 -		  <property name="ypad">0</property>
155.2998 -		</widget>
155.2999 -		<packing>
155.3000 -		  <property name="left_attach">0</property>
155.3001 -		  <property name="right_attach">1</property>
155.3002 -		  <property name="top_attach">3</property>
155.3003 -		  <property name="bottom_attach">4</property>
155.3004 -		  <property name="x_options">fill</property>
155.3005 -		  <property name="y_options">expand</property>
155.3006 -		</packing>
155.3007 -	      </child>
155.3008 -
155.3009 -	      <child>
155.3010 -		<widget class="GtkLabel" id="label15">
155.3011 -		  <property name="visible">True</property>
155.3012 -		  <property name="label" translatable="yes">Button A : </property>
155.3013 -		  <property name="use_underline">False</property>
155.3014 -		  <property name="use_markup">False</property>
155.3015 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3016 -		  <property name="wrap">False</property>
155.3017 -		  <property name="selectable">False</property>
155.3018 -		  <property name="xalign">1</property>
155.3019 -		  <property name="yalign">0.5</property>
155.3020 -		  <property name="xpad">0</property>
155.3021 -		  <property name="ypad">0</property>
155.3022 -		</widget>
155.3023 -		<packing>
155.3024 -		  <property name="left_attach">0</property>
155.3025 -		  <property name="right_attach">1</property>
155.3026 -		  <property name="top_attach">4</property>
155.3027 -		  <property name="bottom_attach">5</property>
155.3028 -		  <property name="x_options">fill</property>
155.3029 -		  <property name="y_options">expand</property>
155.3030 -		</packing>
155.3031 -	      </child>
155.3032 -
155.3033 -	      <child>
155.3034 -		<widget class="GtkLabel" id="label16">
155.3035 -		  <property name="visible">True</property>
155.3036 -		  <property name="label" translatable="yes">Button B : </property>
155.3037 -		  <property name="use_underline">False</property>
155.3038 -		  <property name="use_markup">False</property>
155.3039 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3040 -		  <property name="wrap">False</property>
155.3041 -		  <property name="selectable">False</property>
155.3042 -		  <property name="xalign">1</property>
155.3043 -		  <property name="yalign">0.5</property>
155.3044 -		  <property name="xpad">0</property>
155.3045 -		  <property name="ypad">0</property>
155.3046 -		</widget>
155.3047 -		<packing>
155.3048 -		  <property name="left_attach">0</property>
155.3049 -		  <property name="right_attach">1</property>
155.3050 -		  <property name="top_attach">5</property>
155.3051 -		  <property name="bottom_attach">6</property>
155.3052 -		  <property name="x_options">fill</property>
155.3053 -		  <property name="y_options">expand</property>
155.3054 -		</packing>
155.3055 -	      </child>
155.3056 -
155.3057 -	      <child>
155.3058 -		<widget class="GtkLabel" id="label17">
155.3059 -		  <property name="visible">True</property>
155.3060 -		  <property name="label" translatable="yes">Button L : </property>
155.3061 -		  <property name="use_underline">False</property>
155.3062 -		  <property name="use_markup">False</property>
155.3063 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3064 -		  <property name="wrap">False</property>
155.3065 -		  <property name="selectable">False</property>
155.3066 -		  <property name="xalign">1</property>
155.3067 -		  <property name="yalign">0.5</property>
155.3068 -		  <property name="xpad">0</property>
155.3069 -		  <property name="ypad">0</property>
155.3070 -		</widget>
155.3071 -		<packing>
155.3072 -		  <property name="left_attach">0</property>
155.3073 -		  <property name="right_attach">1</property>
155.3074 -		  <property name="top_attach">6</property>
155.3075 -		  <property name="bottom_attach">7</property>
155.3076 -		  <property name="x_options">fill</property>
155.3077 -		  <property name="y_options">expand</property>
155.3078 -		</packing>
155.3079 -	      </child>
155.3080 -
155.3081 -	      <child>
155.3082 -		<widget class="GtkLabel" id="label18">
155.3083 -		  <property name="visible">True</property>
155.3084 -		  <property name="label" translatable="yes">Button R : </property>
155.3085 -		  <property name="use_underline">False</property>
155.3086 -		  <property name="use_markup">False</property>
155.3087 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3088 -		  <property name="wrap">False</property>
155.3089 -		  <property name="selectable">False</property>
155.3090 -		  <property name="xalign">1</property>
155.3091 -		  <property name="yalign">0.5</property>
155.3092 -		  <property name="xpad">0</property>
155.3093 -		  <property name="ypad">0</property>
155.3094 -		</widget>
155.3095 -		<packing>
155.3096 -		  <property name="left_attach">0</property>
155.3097 -		  <property name="right_attach">1</property>
155.3098 -		  <property name="top_attach">7</property>
155.3099 -		  <property name="bottom_attach">8</property>
155.3100 -		  <property name="x_options">fill</property>
155.3101 -		  <property name="y_options">expand</property>
155.3102 -		</packing>
155.3103 -	      </child>
155.3104 -
155.3105 -	      <child>
155.3106 -		<widget class="GtkLabel" id="label19">
155.3107 -		  <property name="visible">True</property>
155.3108 -		  <property name="label" translatable="yes">Select : </property>
155.3109 -		  <property name="use_underline">False</property>
155.3110 -		  <property name="use_markup">False</property>
155.3111 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3112 -		  <property name="wrap">False</property>
155.3113 -		  <property name="selectable">False</property>
155.3114 -		  <property name="xalign">1</property>
155.3115 -		  <property name="yalign">0.5</property>
155.3116 -		  <property name="xpad">0</property>
155.3117 -		  <property name="ypad">0</property>
155.3118 -		</widget>
155.3119 -		<packing>
155.3120 -		  <property name="left_attach">0</property>
155.3121 -		  <property name="right_attach">1</property>
155.3122 -		  <property name="top_attach">8</property>
155.3123 -		  <property name="bottom_attach">9</property>
155.3124 -		  <property name="x_options">fill</property>
155.3125 -		  <property name="y_options">expand</property>
155.3126 -		</packing>
155.3127 -	      </child>
155.3128 -
155.3129 -	      <child>
155.3130 -		<widget class="GtkLabel" id="label20">
155.3131 -		  <property name="visible">True</property>
155.3132 -		  <property name="label" translatable="yes">Start : </property>
155.3133 -		  <property name="use_underline">False</property>
155.3134 -		  <property name="use_markup">False</property>
155.3135 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3136 -		  <property name="wrap">False</property>
155.3137 -		  <property name="selectable">False</property>
155.3138 -		  <property name="xalign">1</property>
155.3139 -		  <property name="yalign">0.5</property>
155.3140 -		  <property name="xpad">0</property>
155.3141 -		  <property name="ypad">0</property>
155.3142 -		</widget>
155.3143 -		<packing>
155.3144 -		  <property name="left_attach">0</property>
155.3145 -		  <property name="right_attach">1</property>
155.3146 -		  <property name="top_attach">9</property>
155.3147 -		  <property name="bottom_attach">10</property>
155.3148 -		  <property name="x_options">fill</property>
155.3149 -		  <property name="y_options">expand</property>
155.3150 -		</packing>
155.3151 -	      </child>
155.3152 -
155.3153 -	      <child>
155.3154 -		<widget class="GtkLabel" id="label21">
155.3155 -		  <property name="visible">True</property>
155.3156 -		  <property name="label" translatable="yes">Speed : </property>
155.3157 -		  <property name="use_underline">False</property>
155.3158 -		  <property name="use_markup">False</property>
155.3159 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3160 -		  <property name="wrap">False</property>
155.3161 -		  <property name="selectable">False</property>
155.3162 -		  <property name="xalign">1</property>
155.3163 -		  <property name="yalign">0.5</property>
155.3164 -		  <property name="xpad">0</property>
155.3165 -		  <property name="ypad">0</property>
155.3166 -		</widget>
155.3167 -		<packing>
155.3168 -		  <property name="left_attach">0</property>
155.3169 -		  <property name="right_attach">1</property>
155.3170 -		  <property name="top_attach">10</property>
155.3171 -		  <property name="bottom_attach">11</property>
155.3172 -		  <property name="x_options">fill</property>
155.3173 -		  <property name="y_options">expand</property>
155.3174 -		</packing>
155.3175 -	      </child>
155.3176 -
155.3177 -	      <child>
155.3178 -		<widget class="GtkLabel" id="label22">
155.3179 -		  <property name="visible">True</property>
155.3180 -		  <property name="label" translatable="yes">Capture : </property>
155.3181 -		  <property name="use_underline">False</property>
155.3182 -		  <property name="use_markup">False</property>
155.3183 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3184 -		  <property name="wrap">False</property>
155.3185 -		  <property name="selectable">False</property>
155.3186 -		  <property name="xalign">1</property>
155.3187 -		  <property name="yalign">0.5</property>
155.3188 -		  <property name="xpad">0</property>
155.3189 -		  <property name="ypad">0</property>
155.3190 -		</widget>
155.3191 -		<packing>
155.3192 -		  <property name="left_attach">0</property>
155.3193 -		  <property name="right_attach">1</property>
155.3194 -		  <property name="top_attach">11</property>
155.3195 -		  <property name="bottom_attach">12</property>
155.3196 -		  <property name="x_options">fill</property>
155.3197 -		  <property name="y_options">expand</property>
155.3198 -		</packing>
155.3199 -	      </child>
155.3200 -
155.3201 -	      <child>
155.3202 -		<widget class="GtkEntry" id="JoypadDownEntry">
155.3203 -		  <property name="visible">True</property>
155.3204 -		  <property name="can_focus">True</property>
155.3205 -		  <property name="editable">False</property>
155.3206 -		  <property name="visibility">True</property>
155.3207 -		  <property name="max_length">0</property>
155.3208 -		  <property name="text" translatable="yes"></property>
155.3209 -		  <property name="has_frame">True</property>
155.3210 -		  <property name="invisible_char" translatable="yes">*</property>
155.3211 -		  <property name="activates_default">False</property>
155.3212 -		</widget>
155.3213 -		<packing>
155.3214 -		  <property name="left_attach">1</property>
155.3215 -		  <property name="right_attach">2</property>
155.3216 -		  <property name="top_attach">1</property>
155.3217 -		  <property name="bottom_attach">2</property>
155.3218 -		  <property name="x_options">fill</property>
155.3219 -		  <property name="y_options">expand</property>
155.3220 -		</packing>
155.3221 -	      </child>
155.3222 -
155.3223 -	      <child>
155.3224 -		<widget class="GtkEntry" id="JoypadLeftEntry">
155.3225 -		  <property name="visible">True</property>
155.3226 -		  <property name="can_focus">True</property>
155.3227 -		  <property name="editable">False</property>
155.3228 -		  <property name="visibility">True</property>
155.3229 -		  <property name="max_length">0</property>
155.3230 -		  <property name="text" translatable="yes"></property>
155.3231 -		  <property name="has_frame">True</property>
155.3232 -		  <property name="invisible_char" translatable="yes">*</property>
155.3233 -		  <property name="activates_default">False</property>
155.3234 -		</widget>
155.3235 -		<packing>
155.3236 -		  <property name="left_attach">1</property>
155.3237 -		  <property name="right_attach">2</property>
155.3238 -		  <property name="top_attach">2</property>
155.3239 -		  <property name="bottom_attach">3</property>
155.3240 -		  <property name="x_options">fill</property>
155.3241 -		  <property name="y_options">expand</property>
155.3242 -		</packing>
155.3243 -	      </child>
155.3244 -
155.3245 -	      <child>
155.3246 -		<widget class="GtkEntry" id="JoypadRightEntry">
155.3247 -		  <property name="visible">True</property>
155.3248 -		  <property name="can_focus">True</property>
155.3249 -		  <property name="editable">False</property>
155.3250 -		  <property name="visibility">True</property>
155.3251 -		  <property name="max_length">0</property>
155.3252 -		  <property name="text" translatable="yes"></property>
155.3253 -		  <property name="has_frame">True</property>
155.3254 -		  <property name="invisible_char" translatable="yes">*</property>
155.3255 -		  <property name="activates_default">False</property>
155.3256 -		</widget>
155.3257 -		<packing>
155.3258 -		  <property name="left_attach">1</property>
155.3259 -		  <property name="right_attach">2</property>
155.3260 -		  <property name="top_attach">3</property>
155.3261 -		  <property name="bottom_attach">4</property>
155.3262 -		  <property name="x_options">fill</property>
155.3263 -		  <property name="y_options">expand</property>
155.3264 -		</packing>
155.3265 -	      </child>
155.3266 -
155.3267 -	      <child>
155.3268 -		<widget class="GtkEntry" id="JoypadAEntry">
155.3269 -		  <property name="visible">True</property>
155.3270 -		  <property name="can_focus">True</property>
155.3271 -		  <property name="editable">False</property>
155.3272 -		  <property name="visibility">True</property>
155.3273 -		  <property name="max_length">0</property>
155.3274 -		  <property name="text" translatable="yes"></property>
155.3275 -		  <property name="has_frame">True</property>
155.3276 -		  <property name="invisible_char" translatable="yes">*</property>
155.3277 -		  <property name="activates_default">False</property>
155.3278 -		</widget>
155.3279 -		<packing>
155.3280 -		  <property name="left_attach">1</property>
155.3281 -		  <property name="right_attach">2</property>
155.3282 -		  <property name="top_attach">4</property>
155.3283 -		  <property name="bottom_attach">5</property>
155.3284 -		  <property name="x_options">fill</property>
155.3285 -		  <property name="y_options">expand</property>
155.3286 -		</packing>
155.3287 -	      </child>
155.3288 -
155.3289 -	      <child>
155.3290 -		<widget class="GtkEntry" id="JoypadBEntry">
155.3291 -		  <property name="visible">True</property>
155.3292 -		  <property name="can_focus">True</property>
155.3293 -		  <property name="editable">False</property>
155.3294 -		  <property name="visibility">True</property>
155.3295 -		  <property name="max_length">0</property>
155.3296 -		  <property name="text" translatable="yes"></property>
155.3297 -		  <property name="has_frame">True</property>
155.3298 -		  <property name="invisible_char" translatable="yes">*</property>
155.3299 -		  <property name="activates_default">False</property>
155.3300 -		</widget>
155.3301 -		<packing>
155.3302 -		  <property name="left_attach">1</property>
155.3303 -		  <property name="right_attach">2</property>
155.3304 -		  <property name="top_attach">5</property>
155.3305 -		  <property name="bottom_attach">6</property>
155.3306 -		  <property name="x_options">fill</property>
155.3307 -		  <property name="y_options">expand</property>
155.3308 -		</packing>
155.3309 -	      </child>
155.3310 -
155.3311 -	      <child>
155.3312 -		<widget class="GtkEntry" id="JoypadLEntry">
155.3313 -		  <property name="visible">True</property>
155.3314 -		  <property name="can_focus">True</property>
155.3315 -		  <property name="editable">False</property>
155.3316 -		  <property name="visibility">True</property>
155.3317 -		  <property name="max_length">0</property>
155.3318 -		  <property name="text" translatable="yes"></property>
155.3319 -		  <property name="has_frame">True</property>
155.3320 -		  <property name="invisible_char" translatable="yes">*</property>
155.3321 -		  <property name="activates_default">False</property>
155.3322 -		</widget>
155.3323 -		<packing>
155.3324 -		  <property name="left_attach">1</property>
155.3325 -		  <property name="right_attach">2</property>
155.3326 -		  <property name="top_attach">6</property>
155.3327 -		  <property name="bottom_attach">7</property>
155.3328 -		  <property name="x_options">fill</property>
155.3329 -		  <property name="y_options">expand</property>
155.3330 -		</packing>
155.3331 -	      </child>
155.3332 -
155.3333 -	      <child>
155.3334 -		<widget class="GtkEntry" id="JoypadREntry">
155.3335 -		  <property name="visible">True</property>
155.3336 -		  <property name="can_focus">True</property>
155.3337 -		  <property name="editable">False</property>
155.3338 -		  <property name="visibility">True</property>
155.3339 -		  <property name="max_length">0</property>
155.3340 -		  <property name="text" translatable="yes"></property>
155.3341 -		  <property name="has_frame">True</property>
155.3342 -		  <property name="invisible_char" translatable="yes">*</property>
155.3343 -		  <property name="activates_default">False</property>
155.3344 -		</widget>
155.3345 -		<packing>
155.3346 -		  <property name="left_attach">1</property>
155.3347 -		  <property name="right_attach">2</property>
155.3348 -		  <property name="top_attach">7</property>
155.3349 -		  <property name="bottom_attach">8</property>
155.3350 -		  <property name="x_options">fill</property>
155.3351 -		  <property name="y_options">expand</property>
155.3352 -		</packing>
155.3353 -	      </child>
155.3354 -
155.3355 -	      <child>
155.3356 -		<widget class="GtkEntry" id="JoypadSelectEntry">
155.3357 -		  <property name="visible">True</property>
155.3358 -		  <property name="can_focus">True</property>
155.3359 -		  <property name="editable">False</property>
155.3360 -		  <property name="visibility">True</property>
155.3361 -		  <property name="max_length">0</property>
155.3362 -		  <property name="text" translatable="yes"></property>
155.3363 -		  <property name="has_frame">True</property>
155.3364 -		  <property name="invisible_char" translatable="yes">*</property>
155.3365 -		  <property name="activates_default">False</property>
155.3366 -		</widget>
155.3367 -		<packing>
155.3368 -		  <property name="left_attach">1</property>
155.3369 -		  <property name="right_attach">2</property>
155.3370 -		  <property name="top_attach">8</property>
155.3371 -		  <property name="bottom_attach">9</property>
155.3372 -		  <property name="x_options">fill</property>
155.3373 -		  <property name="y_options">expand</property>
155.3374 -		</packing>
155.3375 -	      </child>
155.3376 -
155.3377 -	      <child>
155.3378 -		<widget class="GtkEntry" id="JoypadStartEntry">
155.3379 -		  <property name="visible">True</property>
155.3380 -		  <property name="can_focus">True</property>
155.3381 -		  <property name="editable">False</property>
155.3382 -		  <property name="visibility">True</property>
155.3383 -		  <property name="max_length">0</property>
155.3384 -		  <property name="text" translatable="yes"></property>
155.3385 -		  <property name="has_frame">True</property>
155.3386 -		  <property name="invisible_char" translatable="yes">*</property>
155.3387 -		  <property name="activates_default">False</property>
155.3388 -		</widget>
155.3389 -		<packing>
155.3390 -		  <property name="left_attach">1</property>
155.3391 -		  <property name="right_attach">2</property>
155.3392 -		  <property name="top_attach">9</property>
155.3393 -		  <property name="bottom_attach">10</property>
155.3394 -		  <property name="x_options">fill</property>
155.3395 -		  <property name="y_options">expand</property>
155.3396 -		</packing>
155.3397 -	      </child>
155.3398 -
155.3399 -	      <child>
155.3400 -		<widget class="GtkEntry" id="JoypadSpeedEntry">
155.3401 -		  <property name="visible">True</property>
155.3402 -		  <property name="can_focus">True</property>
155.3403 -		  <property name="editable">False</property>
155.3404 -		  <property name="visibility">True</property>
155.3405 -		  <property name="max_length">0</property>
155.3406 -		  <property name="text" translatable="yes"></property>
155.3407 -		  <property name="has_frame">True</property>
155.3408 -		  <property name="invisible_char" translatable="yes">*</property>
155.3409 -		  <property name="activates_default">False</property>
155.3410 -		</widget>
155.3411 -		<packing>
155.3412 -		  <property name="left_attach">1</property>
155.3413 -		  <property name="right_attach">2</property>
155.3414 -		  <property name="top_attach">10</property>
155.3415 -		  <property name="bottom_attach">11</property>
155.3416 -		  <property name="x_options">fill</property>
155.3417 -		  <property name="y_options">expand</property>
155.3418 -		</packing>
155.3419 -	      </child>
155.3420 -
155.3421 -	      <child>
155.3422 -		<widget class="GtkEntry" id="JoypadCaptureEntry">
155.3423 -		  <property name="visible">True</property>
155.3424 -		  <property name="can_focus">True</property>
155.3425 -		  <property name="editable">False</property>
155.3426 -		  <property name="visibility">True</property>
155.3427 -		  <property name="max_length">0</property>
155.3428 -		  <property name="text" translatable="yes"></property>
155.3429 -		  <property name="has_frame">True</property>
155.3430 -		  <property name="invisible_char" translatable="yes">*</property>
155.3431 -		  <property name="activates_default">False</property>
155.3432 -		</widget>
155.3433 -		<packing>
155.3434 -		  <property name="left_attach">1</property>
155.3435 -		  <property name="right_attach">2</property>
155.3436 -		  <property name="top_attach">11</property>
155.3437 -		  <property name="bottom_attach">12</property>
155.3438 -		  <property name="x_options">fill</property>
155.3439 -		  <property name="y_options">expand</property>
155.3440 -		</packing>
155.3441 -	      </child>
155.3442 -
155.3443 -	      <child>
155.3444 -		<widget class="GtkLabel" id="label11">
155.3445 -		  <property name="visible">True</property>
155.3446 -		  <property name="label" translatable="yes">Up : </property>
155.3447 -		  <property name="use_underline">False</property>
155.3448 -		  <property name="use_markup">False</property>
155.3449 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3450 -		  <property name="wrap">False</property>
155.3451 -		  <property name="selectable">False</property>
155.3452 -		  <property name="xalign">1</property>
155.3453 -		  <property name="yalign">0.5</property>
155.3454 -		  <property name="xpad">0</property>
155.3455 -		  <property name="ypad">0</property>
155.3456 -		</widget>
155.3457 -		<packing>
155.3458 -		  <property name="left_attach">0</property>
155.3459 -		  <property name="right_attach">1</property>
155.3460 -		  <property name="top_attach">0</property>
155.3461 -		  <property name="bottom_attach">1</property>
155.3462 -		  <property name="x_options">fill</property>
155.3463 -		  <property name="y_options">expand</property>
155.3464 -		</packing>
155.3465 -	      </child>
155.3466 -	    </widget>
155.3467 -	  </child>
155.3468 -	</widget>
155.3469 -	<packing>
155.3470 -	  <property name="padding">0</property>
155.3471 -	  <property name="expand">True</property>
155.3472 -	  <property name="fill">True</property>
155.3473 -	</packing>
155.3474 -      </child>
155.3475 -    </widget>
155.3476 -  </child>
155.3477 -</widget>
155.3478 -
155.3479 -<widget class="GtkDialog" id="TcpPortDialog">
155.3480 -  <property name="title" translatable="yes">TCP port</property>
155.3481 -  <property name="type">GTK_WINDOW_TOPLEVEL</property>
155.3482 -  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
155.3483 -  <property name="modal">False</property>
155.3484 -  <property name="resizable">True</property>
155.3485 -  <property name="destroy_with_parent">True</property>
155.3486 -  <property name="skip_taskbar_hint">False</property>
155.3487 -  <property name="skip_pager_hint">False</property>
155.3488 -  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
155.3489 -  <property name="has_separator">True</property>
155.3490 -
155.3491 -  <child internal-child="vbox">
155.3492 -    <widget class="GtkVBox" id="dialog-vbox5">
155.3493 -      <property name="visible">True</property>
155.3494 -      <property name="homogeneous">False</property>
155.3495 -      <property name="spacing">0</property>
155.3496 -
155.3497 -      <child internal-child="action_area">
155.3498 -	<widget class="GtkHButtonBox" id="dialog-action_area5">
155.3499 -	  <property name="visible">True</property>
155.3500 -	  <property name="layout_style">GTK_BUTTONBOX_END</property>
155.3501 -
155.3502 -	  <child>
155.3503 -	    <widget class="GtkButton" id="cancelbutton4">
155.3504 -	      <property name="visible">True</property>
155.3505 -	      <property name="can_default">True</property>
155.3506 -	      <property name="can_focus">True</property>
155.3507 -	      <property name="label">gtk-cancel</property>
155.3508 -	      <property name="use_stock">True</property>
155.3509 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.3510 -	      <property name="response_id">-6</property>
155.3511 -	    </widget>
155.3512 -	  </child>
155.3513 -
155.3514 -	  <child>
155.3515 -	    <widget class="GtkButton" id="okbutton4">
155.3516 -	      <property name="visible">True</property>
155.3517 -	      <property name="can_default">True</property>
155.3518 -	      <property name="can_focus">True</property>
155.3519 -	      <property name="label">gtk-ok</property>
155.3520 -	      <property name="use_stock">True</property>
155.3521 -	      <property name="relief">GTK_RELIEF_NORMAL</property>
155.3522 -	      <property name="response_id">-5</property>
155.3523 -	    </widget>
155.3524 -	  </child>
155.3525 -	</widget>
155.3526 -	<packing>
155.3527 -	  <property name="padding">0</property>
155.3528 -	  <property name="expand">False</property>
155.3529 -	  <property name="fill">True</property>
155.3530 -	  <property name="pack_type">GTK_PACK_END</property>
155.3531 -	</packing>
155.3532 -      </child>
155.3533 -
155.3534 -      <child>
155.3535 -	<widget class="GtkAlignment" id="alignment3">
155.3536 -	  <property name="visible">True</property>
155.3537 -	  <property name="xalign">0.5</property>
155.3538 -	  <property name="yalign">0.5</property>
155.3539 -	  <property name="xscale">0</property>
155.3540 -	  <property name="yscale">0</property>
155.3541 -
155.3542 -	  <child>
155.3543 -	    <widget class="GtkHBox" id="hbox2">
155.3544 -	      <property name="visible">True</property>
155.3545 -	      <property name="homogeneous">False</property>
155.3546 -	      <property name="spacing">0</property>
155.3547 -
155.3548 -	      <child>
155.3549 -		<widget class="GtkLabel" id="label23">
155.3550 -		  <property name="visible">True</property>
155.3551 -		  <property name="label" translatable="yes">Port : </property>
155.3552 -		  <property name="use_underline">False</property>
155.3553 -		  <property name="use_markup">False</property>
155.3554 -		  <property name="justify">GTK_JUSTIFY_LEFT</property>
155.3555 -		  <property name="wrap">False</property>
155.3556 -		  <property name="selectable">False</property>
155.3557 -		  <property name="xalign">1</property>
155.3558 -		  <property name="yalign">0.5</property>
155.3559 -		  <property name="xpad">0</property>
155.3560 -		  <property name="ypad">0</property>
155.3561 -		</widget>
155.3562 -		<packing>
155.3563 -		  <property name="padding">0</property>
155.3564 -		  <property name="expand">True</property>
155.3565 -		  <property name="fill">True</property>
155.3566 -		</packing>
155.3567 -	      </child>
155.3568 -
155.3569 -	      <child>
155.3570 -		<widget class="GtkSpinButton" id="TcpPortSpin">
155.3571 -		  <property name="visible">True</property>
155.3572 -		  <property name="can_focus">True</property>
155.3573 -		  <property name="climb_rate">1</property>
155.3574 -		  <property name="digits">0</property>
155.3575 -		  <property name="numeric">True</property>
155.3576 -		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
155.3577 -		  <property name="snap_to_ticks">True</property>
155.3578 -		  <property name="wrap">True</property>
155.3579 -		  <property name="adjustment">55555 1 65535 1 100 100</property>
155.3580 -		</widget>
155.3581 -		<packing>
155.3582 -		  <property name="padding">0</property>
155.3583 -		  <property name="expand">True</property>
155.3584 -		  <property name="fill">True</property>
155.3585 -		</packing>
155.3586 -	      </child>
155.3587 -	    </widget>
155.3588 -	  </child>
155.3589 -	</widget>
155.3590 -	<packing>
155.3591 -	  <property name="padding">0</property>
155.3592 -	  <property name="expand">True</property>
155.3593 -	  <property name="fill">True</property>
155.3594 -	</packing>
155.3595 -      </child>
155.3596 -    </widget>
155.3597 -  </child>
155.3598 -</widget>
155.3599 -
155.3600 -</glade-interface>
   156.1 --- a/src/gtk/window.cpp	Sat Mar 03 10:54:39 2012 -0600
   156.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   156.3 @@ -1,1944 +0,0 @@
   156.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   156.5 -// Copyright (C) 1999-2003 Forgotten
   156.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   156.7 -
   156.8 -// This program is free software; you can redistribute it and/or modify
   156.9 -// it under the terms of the GNU General Public License as published by
  156.10 -// the Free Software Foundation; either version 2, or(at your option)
  156.11 -// any later version.
  156.12 -//
  156.13 -// This program is distributed in the hope that it will be useful,
  156.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  156.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  156.16 -// GNU General Public License for more details.
  156.17 -//
  156.18 -// You should have received a copy of the GNU General Public License
  156.19 -// along with this program; if not, write to the Free Software Foundation,
  156.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  156.21 -
  156.22 -#include "window.h"
  156.23 -
  156.24 -#include <sys/stat.h>
  156.25 -
  156.26 -#include <stdio.h>
  156.27 -#include <time.h>
  156.28 -
  156.29 -#include <SDL.h>
  156.30 -
  156.31 -#include "../gba/GBA.h"
  156.32 -#include "../gba/GBAGlobals.h"
  156.33 -#include "../gba/GBASound.h"
  156.34 -#include "../gb/GB.h"
  156.35 -#include "../gb/gbGlobals.h"
  156.36 -#include "../gb/gbPrinter.h"
  156.37 -#include "../common/Util.h"
  156.38 -
  156.39 -#include "menuitem.h"
  156.40 -#include "tools.h"
  156.41 -#include "intl.h"
  156.42 -
  156.43 -extern int systemRenderedFrames;
  156.44 -extern int systemFPS;
  156.45 -extern bool debugger;
  156.46 -extern int RGB_LOW_BITS_MASK;
  156.47 -extern void (*dbgMain)();
  156.48 -extern void (*dbgSignal)(int, int);
  156.49 -extern void (*dbgOutput)(char *, u32);
  156.50 -extern void remoteInit();
  156.51 -extern void remoteCleanUp();
  156.52 -extern void remoteStubMain();
  156.53 -extern void remoteStubSignal(int, int);
  156.54 -extern void remoteOutput(char *, u32);
  156.55 -extern void remoteSetProtocol(int);
  156.56 -extern void remoteSetPort(int);
  156.57 -
  156.58 -#ifdef MMX
  156.59 -extern "C" bool cpu_mmx;
  156.60 -#endif // MMX
  156.61 -
  156.62 -namespace VBA
  156.63 -{
  156.64 -
  156.65 -using Gnome::Glade::Xml;
  156.66 -
  156.67 -Window * Window::m_poInstance = NULL;
  156.68 -
  156.69 -Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
  156.70 -  Gtk::Window       (_pstWindow),
  156.71 -  m_iGBScreenWidth  (160),
  156.72 -  m_iGBScreenHeight (144),
  156.73 -  m_iSGBScreenWidth (256),
  156.74 -  m_iSGBScreenHeight(224),
  156.75 -  m_iGBAScreenWidth (240),
  156.76 -  m_iGBAScreenHeight(160),
  156.77 -  m_iFrameskipMin   (0),
  156.78 -  m_iFrameskipMax   (9),
  156.79 -  m_iThrottleMin    (5),
  156.80 -  m_iThrottleMax    (1000),
  156.81 -  m_iScaleMin       (1),
  156.82 -  m_iScaleMax       (6),
  156.83 -  m_iShowSpeedMin   (ShowNone),
  156.84 -  m_iShowSpeedMax   (ShowDetailed),
  156.85 -  m_iSaveTypeMin    (SaveAuto),
  156.86 -  m_iSaveTypeMax    (SaveNone),
  156.87 -  m_iSoundQualityMin(Sound44K),
  156.88 -  m_iSoundQualityMax(Sound11K),
  156.89 -  m_iSoundVolumeMin (Sound100),
  156.90 -  m_iSoundVolumeMax (Sound50),
  156.91 -  m_iEmulatorTypeMin(EmulatorAuto),
  156.92 -  m_iEmulatorTypeMax(EmulatorSGB2),
  156.93 -  m_iFilter2xMin    (FirstFilter),
  156.94 -  m_iFilter2xMax    (LastFilter),
  156.95 -  m_iFilterIBMin    (FirstFilterIB),
  156.96 -  m_iFilterIBMax    (LastFilterIB),
  156.97 -  m_iJoypadMin      (1),
  156.98 -  m_iJoypadMax      (4)
  156.99 -{
 156.100 -  m_poXml            = _poXml;
 156.101 -  m_poFileOpenDialog = NULL;
 156.102 -  m_iScreenWidth     = m_iGBAScreenWidth;
 156.103 -  m_iScreenHeight    = m_iGBAScreenHeight;
 156.104 -  m_eCartridge       = CartridgeNone;
 156.105 -  m_uiJoypadState    = 0;
 156.106 -
 156.107 -  vInitSystem();
 156.108 -  vInitSDL();
 156.109 -
 156.110 -  Gtk::Container * poC;
 156.111 -  poC = dynamic_cast<Gtk::Container *>(_poXml->get_widget("ScreenContainer"));
 156.112 -  m_poScreenArea = Gtk::manage(new ScreenArea(m_iScreenWidth, m_iScreenHeight));
 156.113 -  poC->add(*m_poScreenArea);
 156.114 -  vDrawDefaultScreen();
 156.115 -  m_poScreenArea->show();
 156.116 -
 156.117 -  // Get config
 156.118 -  //
 156.119 -  vInitConfig();
 156.120 -
 156.121 -  m_sUserDataDir = Glib::get_home_dir() + "/.gvba";
 156.122 -  m_sConfigFile  = m_sUserDataDir + "/config";
 156.123 -
 156.124 -  if (! Glib::file_test(m_sUserDataDir, Glib::FILE_TEST_EXISTS))
 156.125 -  {
 156.126 -    mkdir(m_sUserDataDir.c_str(), 0777);
 156.127 -  }
 156.128 -  if (Glib::file_test(m_sConfigFile, Glib::FILE_TEST_EXISTS))
 156.129 -  {
 156.130 -    vLoadConfig(m_sConfigFile);
 156.131 -    vCheckConfig();
 156.132 -  }
 156.133 -  else
 156.134 -  {
 156.135 -    vSaveConfig(m_sConfigFile);
 156.136 -  }
 156.137 -
 156.138 -  vCreateFileOpenDialog();
 156.139 -  vLoadHistoryFromConfig();
 156.140 -  vLoadJoypadsFromConfig();
 156.141 -
 156.142 -  Gtk::MenuItem *      poMI;
 156.143 -  Gtk::CheckMenuItem * poCMI;
 156.144 -
 156.145 -  // File menu
 156.146 -  //
 156.147 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileOpen"));
 156.148 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileOpen));
 156.149 -
 156.150 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileLoad"));
 156.151 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileLoad));
 156.152 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.153 -
 156.154 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileSave"));
 156.155 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileSave));
 156.156 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.157 -
 156.158 -  for (int i = 0; i < 10; i++)
 156.159 -  {
 156.160 -    char csName[20];
 156.161 -    snprintf(csName, 20, "LoadGameSlot%d", i + 1);
 156.162 -    m_apoLoadGameItem[i] = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget(csName));
 156.163 -    snprintf(csName, 20, "SaveGameSlot%d", i + 1);
 156.164 -    m_apoSaveGameItem[i] = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget(csName));
 156.165 -
 156.166 -    m_apoLoadGameItem[i]->signal_activate().connect(SigC::bind<int>(
 156.167 -                                                      SigC::slot(*this, &Window::vOnLoadGame),
 156.168 -                                                      i + 1));
 156.169 -    m_apoSaveGameItem[i]->signal_activate().connect(SigC::bind<int>(
 156.170 -                                                      SigC::slot(*this, &Window::vOnSaveGame),
 156.171 -                                                      i + 1));
 156.172 -  }
 156.173 -  vUpdateGameSlots();
 156.174 -
 156.175 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("LoadGameMostRecent"));
 156.176 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnLoadGameMostRecent));
 156.177 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.178 -
 156.179 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("LoadGameAuto"));
 156.180 -  poCMI->set_active(m_poCoreConfig->oGetKey<bool>("load_game_auto"));
 156.181 -  vOnLoadGameAutoToggled(poCMI);
 156.182 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.183 -                                    SigC::slot(*this, &Window::vOnLoadGameAutoToggled),
 156.184 -                                    poCMI));
 156.185 -
 156.186 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("SaveGameOldest"));
 156.187 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnSaveGameOldest));
 156.188 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.189 -
 156.190 -  m_poFilePauseItem = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("FilePause"));
 156.191 -  m_poFilePauseItem->set_active(false);
 156.192 -  vOnFilePauseToggled(m_poFilePauseItem);
 156.193 -  m_poFilePauseItem->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.194 -                                                SigC::slot(*this, &Window::vOnFilePauseToggled),
 156.195 -                                                m_poFilePauseItem));
 156.196 -  m_listSensitiveWhenPlaying.push_back(m_poFilePauseItem);
 156.197 -
 156.198 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileReset"));
 156.199 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileReset));
 156.200 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.201 -
 156.202 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileScreenCapture"));
 156.203 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileScreenCapture));
 156.204 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.205 -
 156.206 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileClose"));
 156.207 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileClose));
 156.208 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.209 -
 156.210 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileExit"));
 156.211 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileExit));
 156.212 -
 156.213 -  // Recent menu
 156.214 -  //
 156.215 -  m_poRecentMenu = dynamic_cast<Gtk::Menu *>(_poXml->get_widget("RecentMenu_menu"));
 156.216 -  vUpdateHistoryMenu();
 156.217 -
 156.218 -  m_poRecentResetItem = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("RecentReset"));
 156.219 -  m_poRecentResetItem->signal_activate().connect(SigC::slot(*this, &Window::vOnRecentReset));
 156.220 -
 156.221 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("RecentFreeze"));
 156.222 -  poCMI->set_active(m_poHistoryConfig->oGetKey<bool>("freeze"));
 156.223 -  vOnRecentFreezeToggled(poCMI);
 156.224 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.225 -                                    SigC::slot(*this, &Window::vOnRecentFreezeToggled),
 156.226 -                                    poCMI));
 156.227 -
 156.228 -  // Import menu
 156.229 -  //
 156.230 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("ImportBatteryFile"));
 156.231 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnImportBatteryFile));
 156.232 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.233 -
 156.234 -  // Export menu
 156.235 -  //
 156.236 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("ExportBatteryFile"));
 156.237 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnExportBatteryFile));
 156.238 -  m_listSensitiveWhenPlaying.push_back(poMI);
 156.239 -
 156.240 -  // Frameskip menu
 156.241 -  //
 156.242 -  struct
 156.243 -  {
 156.244 -    const char * m_csName;
 156.245 -    const int    m_iFrameskip;
 156.246 -  }
 156.247 -  astFrameskip[] =
 156.248 -  {
 156.249 -    { "FrameskipAutomatic", -1 },
 156.250 -    { "Frameskip0",          0 },
 156.251 -    { "Frameskip1",          1 },
 156.252 -    { "Frameskip2",          2 },
 156.253 -    { "Frameskip3",          3 },
 156.254 -    { "Frameskip4",          4 },
 156.255 -    { "Frameskip5",          5 },
 156.256 -    { "Frameskip6",          6 },
 156.257 -    { "Frameskip7",          7 },
 156.258 -    { "Frameskip8",          8 },
 156.259 -    { "Frameskip9",          9 }
 156.260 -  };
 156.261 -  int iDefaultFrameskip;
 156.262 -  if (m_poCoreConfig->sGetKey("frameskip") == "auto")
 156.263 -  {
 156.264 -    iDefaultFrameskip = -1;
 156.265 -  }
 156.266 -  else
 156.267 -  {
 156.268 -    iDefaultFrameskip = m_poCoreConfig->oGetKey<int>("frameskip");
 156.269 -  }
 156.270 -  for (guint i = 0; i < G_N_ELEMENTS(astFrameskip); i++)
 156.271 -  {
 156.272 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astFrameskip[i].m_csName));
 156.273 -    if (astFrameskip[i].m_iFrameskip == iDefaultFrameskip)
 156.274 -    {
 156.275 -      poCMI->set_active();
 156.276 -      vOnFrameskipToggled(poCMI, iDefaultFrameskip);
 156.277 -    }
 156.278 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.279 -                                      SigC::slot(*this, &Window::vOnFrameskipToggled),
 156.280 -                                      poCMI, astFrameskip[i].m_iFrameskip));
 156.281 -  }
 156.282 -
 156.283 -  // Throttle menu
 156.284 -  //
 156.285 -  struct
 156.286 -  {
 156.287 -    const char * m_csName;
 156.288 -    const int    m_iThrottle;
 156.289 -  }
 156.290 -  astThrottle[] =
 156.291 -  {
 156.292 -    { "ThrottleNoThrottle",   0 },
 156.293 -    { "Throttle25",          25 },
 156.294 -    { "Throttle50",          50 },
 156.295 -    { "Throttle100",        100 },
 156.296 -    { "Throttle150",        150 },
 156.297 -    { "Throttle200",        200 }
 156.298 -  };
 156.299 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("ThrottleOther"));
 156.300 -  poCMI->set_active();
 156.301 -  poCMI->signal_activate().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.302 -                                     SigC::slot(*this, &Window::vOnThrottleOther),
 156.303 -                                     poCMI));
 156.304 -
 156.305 -  int iDefaultThrottle = m_poCoreConfig->oGetKey<int>("throttle");
 156.306 -  for (guint i = 0; i < G_N_ELEMENTS(astThrottle); i++)
 156.307 -  {
 156.308 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astThrottle[i].m_csName));
 156.309 -    if (astThrottle[i].m_iThrottle == iDefaultThrottle)
 156.310 -    {
 156.311 -      poCMI->set_active();
 156.312 -    }
 156.313 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.314 -                                      SigC::slot(*this, &Window::vOnThrottleToggled),
 156.315 -                                      poCMI, astThrottle[i].m_iThrottle));
 156.316 -  }
 156.317 -  vSetThrottle(iDefaultThrottle);
 156.318 -
 156.319 -  // Video menu
 156.320 -  //
 156.321 -  struct
 156.322 -  {
 156.323 -    const char * m_csName;
 156.324 -    const int    m_iScale;
 156.325 -  }
 156.326 -  astVideoScale[] =
 156.327 -  {
 156.328 -    { "Video1x", 1 },
 156.329 -    { "Video2x", 2 },
 156.330 -    { "Video3x", 3 },
 156.331 -    { "Video4x", 4 },
 156.332 -    { "Video5x", 5 },
 156.333 -    { "Video6x", 6 }
 156.334 -  };
 156.335 -  int iDefaultScale = m_poDisplayConfig->oGetKey<int>("scale");
 156.336 -  for (guint i = 0; i < G_N_ELEMENTS(astVideoScale); i++)
 156.337 -  {
 156.338 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astVideoScale[i].m_csName));
 156.339 -    if (astVideoScale[i].m_iScale == iDefaultScale)
 156.340 -    {
 156.341 -      poCMI->set_active();
 156.342 -      vOnVideoScaleToggled(poCMI, iDefaultScale);
 156.343 -    }
 156.344 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.345 -                                      SigC::slot(*this, &Window::vOnVideoScaleToggled),
 156.346 -                                      poCMI, astVideoScale[i].m_iScale));
 156.347 -  }
 156.348 -
 156.349 -  // Layers menu
 156.350 -  //
 156.351 -  struct
 156.352 -  {
 156.353 -    const char * m_csName;
 156.354 -    const char * m_csKey;
 156.355 -    const int    m_iLayer;
 156.356 -  }
 156.357 -  astLayer[] =
 156.358 -  {
 156.359 -    { "LayersBg0",    "layer_bg0",    0 },
 156.360 -    { "LayersBg1",    "layer_bg1",    1 },
 156.361 -    { "LayersBg2",    "layer_bg2",    2 },
 156.362 -    { "LayersBg3",    "layer_bg3",    3 },
 156.363 -    { "LayersObj",    "layer_obj",    4 },
 156.364 -    { "LayersWin0",   "layer_win0",   5 },
 156.365 -    { "LayersWin1",   "layer_win1",   6 },
 156.366 -    { "LayersObjWin", "layer_objwin", 7 }
 156.367 -  };
 156.368 -  for (guint i = 0; i < G_N_ELEMENTS(astLayer); i++)
 156.369 -  {
 156.370 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astLayer[i].m_csName));
 156.371 -    poCMI->set_active(m_poCoreConfig->oGetKey<bool>(astLayer[i].m_csKey));
 156.372 -    vOnLayerToggled(poCMI, astLayer[i].m_iLayer);
 156.373 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.374 -                                      SigC::slot(*this, &Window::vOnLayerToggled),
 156.375 -                                      poCMI, astLayer[i].m_iLayer));
 156.376 -  }
 156.377 -
 156.378 -  // Emulator menu
 156.379 -  //
 156.380 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("EmulatorDirectories"));
 156.381 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnDirectories));
 156.382 -
 156.383 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("EmulatorPauseWhenInactive"));
 156.384 -  poCMI->set_active(m_poDisplayConfig->oGetKey<bool>("pause_when_inactive"));
 156.385 -  vOnPauseWhenInactiveToggled(poCMI);
 156.386 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.387 -                                    SigC::slot(*this, &Window::vOnPauseWhenInactiveToggled),
 156.388 -                                    poCMI));
 156.389 -
 156.390 -  m_poUseBiosItem = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("EmulatorUseBios"));
 156.391 -  m_poUseBiosItem->set_active(m_poCoreConfig->oGetKey<bool>("use_bios_file"));
 156.392 -  if (m_poCoreConfig->sGetKey("bios_file") == "")
 156.393 -  {
 156.394 -    m_poUseBiosItem->set_sensitive(false);
 156.395 -  }
 156.396 -  m_poUseBiosItem->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.397 -                                              SigC::slot(*this, &Window::vOnUseBiosToggled),
 156.398 -                                              m_poUseBiosItem));
 156.399 -
 156.400 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("EmulatorSelectBios"));
 156.401 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnSelectBios));
 156.402 -
 156.403 -  // Show speed menu
 156.404 -  //
 156.405 -  struct
 156.406 -  {
 156.407 -    const char *     m_csName;
 156.408 -    const EShowSpeed m_eShowSpeed;
 156.409 -  }
 156.410 -  astShowSpeed[] =
 156.411 -  {
 156.412 -    { "ShowSpeedNone",       ShowNone       },
 156.413 -    { "ShowSpeedPercentage", ShowPercentage },
 156.414 -    { "ShowSpeedDetailed",   ShowDetailed   }
 156.415 -  };
 156.416 -  EShowSpeed eDefaultShowSpeed = (EShowSpeed)m_poDisplayConfig->oGetKey<int>("show_speed");
 156.417 -  for (guint i = 0; i < G_N_ELEMENTS(astShowSpeed); i++)
 156.418 -  {
 156.419 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astShowSpeed[i].m_csName));
 156.420 -    if (astShowSpeed[i].m_eShowSpeed == eDefaultShowSpeed)
 156.421 -    {
 156.422 -      poCMI->set_active();
 156.423 -      vOnShowSpeedToggled(poCMI, eDefaultShowSpeed);
 156.424 -    }
 156.425 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.426 -                                      SigC::slot(*this, &Window::vOnShowSpeedToggled),
 156.427 -                                      poCMI, astShowSpeed[i].m_eShowSpeed));
 156.428 -  }
 156.429 -
 156.430 -  // Save type menu
 156.431 -  //
 156.432 -  struct
 156.433 -  {
 156.434 -    const char *    m_csName;
 156.435 -    const ESaveType m_eSaveType;
 156.436 -  }
 156.437 -  astSaveType[] =
 156.438 -  {
 156.439 -    { "SaveTypeAutomatic",    SaveAuto         },
 156.440 -    { "SaveTypeEeprom",       SaveEEPROM       },
 156.441 -    { "SaveTypeSram",         SaveSRAM         },
 156.442 -    { "SaveTypeFlash",        SaveFlash        },
 156.443 -    { "SaveTypeEepromSensor", SaveEEPROMSensor },
 156.444 -    { "SaveTypeNone",         SaveNone         }
 156.445 -  };
 156.446 -  ESaveType eDefaultSaveType = (ESaveType)m_poCoreConfig->oGetKey<int>("save_type");
 156.447 -  for (guint i = 0; i < G_N_ELEMENTS(astSaveType); i++)
 156.448 -  {
 156.449 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astSaveType[i].m_csName));
 156.450 -    if (astSaveType[i].m_eSaveType == eDefaultSaveType)
 156.451 -    {
 156.452 -      poCMI->set_active();
 156.453 -      vOnSaveTypeToggled(poCMI, eDefaultSaveType);
 156.454 -    }
 156.455 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.456 -                                      SigC::slot(*this, &Window::vOnSaveTypeToggled),
 156.457 -                                      poCMI, astSaveType[i].m_eSaveType));
 156.458 -  }
 156.459 -
 156.460 -  // Flash size menu
 156.461 -  //
 156.462 -  struct
 156.463 -  {
 156.464 -    const char * m_csName;
 156.465 -    const int    m_iFlashSize;
 156.466 -  }
 156.467 -  astFlashSize[] =
 156.468 -  {
 156.469 -    { "SaveTypeFlash64K",   64 },
 156.470 -    { "SaveTypeFlash128K", 128 }
 156.471 -  };
 156.472 -  int iDefaultFlashSize = m_poCoreConfig->oGetKey<int>("flash_size");
 156.473 -  for (guint i = 0; i < G_N_ELEMENTS(astFlashSize); i++)
 156.474 -  {
 156.475 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astFlashSize[i].m_csName));
 156.476 -    if (astFlashSize[i].m_iFlashSize == iDefaultFlashSize)
 156.477 -    {
 156.478 -      poCMI->set_active();
 156.479 -      vOnFlashSizeToggled(poCMI, iDefaultFlashSize);
 156.480 -    }
 156.481 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.482 -                                      SigC::slot(*this, &Window::vOnFlashSizeToggled),
 156.483 -                                      poCMI, astFlashSize[i].m_iFlashSize));
 156.484 -  }
 156.485 -
 156.486 -  // Screenshot format menu
 156.487 -  //
 156.488 -  struct
 156.489 -  {
 156.490 -    const char * m_csName;
 156.491 -    const char * m_csScreenshotFormat;
 156.492 -  }
 156.493 -  astScreenshotFormat[] =
 156.494 -  {
 156.495 -    { "ScreenshotFormatPNG", "png" },
 156.496 -    { "ScreenshotFormatBMP", "bmp" }
 156.497 -  };
 156.498 -  std::string sDefaultScreenshotFormat = m_poCoreConfig->sGetKey("screenshot_format");
 156.499 -  for (guint i = 0; i < G_N_ELEMENTS(astScreenshotFormat); i++)
 156.500 -  {
 156.501 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astScreenshotFormat[i].m_csName));
 156.502 -    if (astScreenshotFormat[i].m_csScreenshotFormat == sDefaultScreenshotFormat)
 156.503 -    {
 156.504 -      poCMI->set_active();
 156.505 -      vOnScreenshotFormatToggled(poCMI, sDefaultScreenshotFormat);
 156.506 -    }
 156.507 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, std::string>(
 156.508 -                                      SigC::slot(*this, &Window::vOnScreenshotFormatToggled),
 156.509 -                                      poCMI, std::string(astScreenshotFormat[i].m_csScreenshotFormat)));
 156.510 -  }
 156.511 -
 156.512 -  // Sound menu
 156.513 -  //
 156.514 -  std::string sDefaultSoundStatus = m_poSoundConfig->sGetKey("status");
 156.515 -
 156.516 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundOff"));
 156.517 -  if (sDefaultSoundStatus == "off")
 156.518 -  {
 156.519 -    poCMI->set_active();
 156.520 -    vOnSoundStatusToggled(poCMI, SoundOff);
 156.521 -  }
 156.522 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.523 -                                    SigC::slot(*this, &Window::vOnSoundStatusToggled),
 156.524 -                                    poCMI, SoundOff));
 156.525 -  m_poSoundOffItem = poCMI;
 156.526 -
 156.527 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundMute"));
 156.528 -  if (sDefaultSoundStatus == "mute")
 156.529 -  {
 156.530 -    poCMI->set_active();
 156.531 -    vOnSoundStatusToggled(poCMI, SoundMute);
 156.532 -  }
 156.533 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.534 -                                    SigC::slot(*this, &Window::vOnSoundStatusToggled),
 156.535 -                                    poCMI, SoundMute));
 156.536 -
 156.537 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundOn"));
 156.538 -  if (sDefaultSoundStatus == "on")
 156.539 -  {
 156.540 -    poCMI->set_active();
 156.541 -    vOnSoundStatusToggled(poCMI, SoundOn);
 156.542 -  }
 156.543 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.544 -                                    SigC::slot(*this, &Window::vOnSoundStatusToggled),
 156.545 -                                    poCMI, SoundOn));
 156.546 -
 156.547 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundEcho"));
 156.548 -  poCMI->set_active(m_poSoundConfig->oGetKey<bool>("echo"));
 156.549 -  vOnSoundEchoToggled(poCMI);
 156.550 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.551 -                                    SigC::slot(*this, &Window::vOnSoundEchoToggled),
 156.552 -                                    poCMI));
 156.553 -
 156.554 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundLowPass"));
 156.555 -  poCMI->set_active(m_poSoundConfig->oGetKey<bool>("low_pass"));
 156.556 -  vOnSoundLowPassToggled(poCMI);
 156.557 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.558 -                                    SigC::slot(*this, &Window::vOnSoundLowPassToggled),
 156.559 -                                    poCMI));
 156.560 -
 156.561 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("SoundReverseStereo"));
 156.562 -  poCMI->set_active(m_poSoundConfig->oGetKey<bool>("reverse_stereo"));
 156.563 -  vOnSoundReverseToggled(poCMI);
 156.564 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.565 -                                    SigC::slot(*this, &Window::vOnSoundReverseToggled),
 156.566 -                                    poCMI));
 156.567 -
 156.568 -  struct
 156.569 -  {
 156.570 -    const char * m_csName;
 156.571 -    const char * m_csKey;
 156.572 -    const int    m_iSoundChannel;
 156.573 -  }
 156.574 -  astSoundChannel[] =
 156.575 -  {
 156.576 -    { "SoundChannel1", "channel_1", 0 },
 156.577 -    { "SoundChannel2", "channel_2", 1 },
 156.578 -    { "SoundChannel3", "channel_3", 2 },
 156.579 -    { "SoundChannel4", "channel_4", 3 },
 156.580 -    { "SoundChannelA", "channel_A", 4 },
 156.581 -    { "SoundChannelB", "channel_B", 5 }
 156.582 -  };
 156.583 -  for (guint i = 0; i < G_N_ELEMENTS(astSoundChannel); i++)
 156.584 -  {
 156.585 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astSoundChannel[i].m_csName));
 156.586 -    poCMI->set_active(m_poSoundConfig->oGetKey<bool>(astSoundChannel[i].m_csKey));
 156.587 -    vOnSoundChannelToggled(poCMI, astSoundChannel[i].m_iSoundChannel);
 156.588 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.589 -                                      SigC::slot(*this, &Window::vOnSoundChannelToggled),
 156.590 -                                      poCMI, astSoundChannel[i].m_iSoundChannel));
 156.591 -  }
 156.592 -
 156.593 -  struct
 156.594 -  {
 156.595 -    const char *        m_csName;
 156.596 -    const ESoundQuality m_eSoundQuality;
 156.597 -  }
 156.598 -  astSoundQuality[] =
 156.599 -  {
 156.600 -    { "Sound11Khz", Sound11K },
 156.601 -    { "Sound22Khz", Sound22K },
 156.602 -    { "Sound44Khz", Sound44K }
 156.603 -  };
 156.604 -  ESoundQuality eDefaultSoundQuality = (ESoundQuality)m_poSoundConfig->oGetKey<int>("quality");
 156.605 -  for (guint i = 0; i < G_N_ELEMENTS(astSoundQuality); i++)
 156.606 -  {
 156.607 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astSoundQuality[i].m_csName));
 156.608 -    if (astSoundQuality[i].m_eSoundQuality == eDefaultSoundQuality)
 156.609 -    {
 156.610 -      poCMI->set_active();
 156.611 -      vOnSoundQualityToggled(poCMI, eDefaultSoundQuality);
 156.612 -    }
 156.613 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.614 -                                      SigC::slot(*this, &Window::vOnSoundQualityToggled),
 156.615 -                                      poCMI, astSoundQuality[i].m_eSoundQuality));
 156.616 -  }
 156.617 -
 156.618 -  // Volume menu
 156.619 -  //
 156.620 -  struct
 156.621 -  {
 156.622 -    const char *       m_csName;
 156.623 -    const ESoundVolume m_eSoundVolume;
 156.624 -  }
 156.625 -  astSoundVolume[] =
 156.626 -  {
 156.627 -    { "Volume25",   Sound25  },
 156.628 -    { "Volume50",   Sound50  },
 156.629 -    { "Volume100",  Sound100 },
 156.630 -    { "Volume200",  Sound200 },
 156.631 -    { "Volume300",  Sound300 },
 156.632 -    { "Volume400",  Sound400 }
 156.633 -  };
 156.634 -  ESoundVolume eDefaultSoundVolume = (ESoundVolume)m_poSoundConfig->oGetKey<int>("volume");
 156.635 -  for (guint i = 0; i < G_N_ELEMENTS(astSoundVolume); i++)
 156.636 -  {
 156.637 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astSoundVolume[i].m_csName));
 156.638 -    if (astSoundVolume[i].m_eSoundVolume == eDefaultSoundVolume)
 156.639 -    {
 156.640 -      poCMI->set_active();
 156.641 -      vOnSoundVolumeToggled(poCMI, eDefaultSoundVolume);
 156.642 -    }
 156.643 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.644 -                                      SigC::slot(*this, &Window::vOnSoundVolumeToggled),
 156.645 -                                      poCMI, astSoundVolume[i].m_eSoundVolume));
 156.646 -  }
 156.647 -
 156.648 -  // Gameboy menu
 156.649 -  //
 156.650 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("GameboyBorder"));
 156.651 -  poCMI->set_active(m_poCoreConfig->oGetKey<bool>("gb_border"));
 156.652 -  vOnGBBorderToggled(poCMI);
 156.653 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.654 -                                    SigC::slot(*this, &Window::vOnGBBorderToggled),
 156.655 -                                    poCMI));
 156.656 -
 156.657 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("GameboyPrinter"));
 156.658 -  poCMI->set_active(m_poCoreConfig->oGetKey<bool>("gb_printer"));
 156.659 -  vOnGBPrinterToggled(poCMI);
 156.660 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.661 -                                    SigC::slot(*this, &Window::vOnGBPrinterToggled),
 156.662 -                                    poCMI));
 156.663 -
 156.664 -  struct
 156.665 -  {
 156.666 -    const char *        m_csName;
 156.667 -    const EEmulatorType m_eEmulatorType;
 156.668 -  }
 156.669 -  astEmulatorType[] =
 156.670 -  {
 156.671 -    { "GameboyAutomatic", EmulatorAuto },
 156.672 -    { "GameboyGba",       EmulatorGBA  },
 156.673 -    { "GameboyCgb",       EmulatorCGB  },
 156.674 -    { "GameboySgb",       EmulatorSGB  },
 156.675 -    { "GameboySgb2",      EmulatorSGB2 },
 156.676 -    { "GameboyGb",        EmulatorGB   }
 156.677 -  };
 156.678 -  EEmulatorType eDefaultEmulatorType = (EEmulatorType)m_poCoreConfig->oGetKey<int>("emulator_type");
 156.679 -  for (guint i = 0; i < G_N_ELEMENTS(astEmulatorType); i++)
 156.680 -  {
 156.681 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astEmulatorType[i].m_csName));
 156.682 -    if (astEmulatorType[i].m_eEmulatorType == eDefaultEmulatorType)
 156.683 -    {
 156.684 -      poCMI->set_active();
 156.685 -      vOnEmulatorTypeToggled(poCMI, eDefaultEmulatorType);
 156.686 -    }
 156.687 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.688 -                                      SigC::slot(*this, &Window::vOnEmulatorTypeToggled),
 156.689 -                                      poCMI, astEmulatorType[i].m_eEmulatorType));
 156.690 -  }
 156.691 -
 156.692 -  // Filter menu
 156.693 -  //
 156.694 -  struct
 156.695 -  {
 156.696 -    const char *    m_csName;
 156.697 -    const EFilter2x m_eFilter2x;
 156.698 -  }
 156.699 -  astFilter2x[] =
 156.700 -  {
 156.701 -    { "FilterNone",          FilterNone         },
 156.702 -    { "FilterTVMode",        FilterScanlinesTV  },
 156.703 -    { "Filter2xSaI",         Filter2xSaI        },
 156.704 -    { "FilterSuper2xSaI",    FilterSuper2xSaI   },
 156.705 -    { "FilterSuperEagle",    FilterSuperEagle   },
 156.706 -    { "FilterPixelate",      FilterPixelate     },
 156.707 -    { "FilterMotionBlur",    FilterMotionBlur   },
 156.708 -    { "FilterAdvanceMame2x", FilterAdMame2x     },
 156.709 -    { "FilterSimple2x",      FilterSimple2x     },
 156.710 -    { "FilterBilinear",      FilterBilinear     },
 156.711 -    { "FilterBilinearPlus",  FilterBilinearPlus },
 156.712 -    { "FilterScanlines",     FilterScanlines    },
 156.713 -    { "FilterHq2x",          FilterHq2x         },
 156.714 -    { "FilterLq2x",          FilterLq2x         }
 156.715 -  };
 156.716 -  EFilter2x eDefaultFilter2x = (EFilter2x)m_poDisplayConfig->oGetKey<int>("filter2x");
 156.717 -  for (guint i = 0; i < G_N_ELEMENTS(astFilter2x); i++)
 156.718 -  {
 156.719 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astFilter2x[i].m_csName));
 156.720 -    if (astFilter2x[i].m_eFilter2x == eDefaultFilter2x)
 156.721 -    {
 156.722 -      poCMI->set_active();
 156.723 -      vOnFilter2xToggled(poCMI, eDefaultFilter2x);
 156.724 -    }
 156.725 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.726 -                                      SigC::slot(*this, &Window::vOnFilter2xToggled),
 156.727 -                                      poCMI, astFilter2x[i].m_eFilter2x));
 156.728 -  }
 156.729 -
 156.730 -  poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("FilterDisableMmx"));
 156.731 -#ifdef MMX
 156.732 -  poCMI->set_active(m_poDisplayConfig->oGetKey<bool>("filter_disable_mmx"));
 156.733 -  vOnDisableMMXToggled(poCMI);
 156.734 -  poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *>(
 156.735 -                                    SigC::slot(*this, &Window::vOnDisableMMXToggled),
 156.736 -                                    poCMI));
 156.737 -#else // ! MMX
 156.738 -  poCMI->set_active();
 156.739 -  poCMI->set_sensitive(false);
 156.740 -#endif // ! MMX
 156.741 -
 156.742 -  // Interframe blending menu
 156.743 -  //
 156.744 -  struct
 156.745 -  {
 156.746 -    const char *    m_csName;
 156.747 -    const EFilterIB m_eFilterIB;
 156.748 -  }
 156.749 -  astFilterIB[] =
 156.750 -  {
 156.751 -    { "IFBNone",       FilterIBNone       },
 156.752 -    { "IFBSmart",      FilterIBSmart      },
 156.753 -    { "IFBMotionBlur", FilterIBMotionBlur }
 156.754 -  };
 156.755 -  EFilterIB eDefaultFilterIB = (EFilterIB)m_poDisplayConfig->oGetKey<int>("filterIB");
 156.756 -  for (guint i = 0; i < G_N_ELEMENTS(astFilterIB); i++)
 156.757 -  {
 156.758 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astFilterIB[i].m_csName));
 156.759 -    if (astFilterIB[i].m_eFilterIB == eDefaultFilterIB)
 156.760 -    {
 156.761 -      poCMI->set_active();
 156.762 -      vOnFilterIBToggled(poCMI, eDefaultFilterIB);
 156.763 -    }
 156.764 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.765 -                                      SigC::slot(*this, &Window::vOnFilterIBToggled),
 156.766 -                                      poCMI, astFilterIB[i].m_eFilterIB));
 156.767 -  }
 156.768 -
 156.769 -  // Joypad menu
 156.770 -  //
 156.771 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure1"));
 156.772 -  poMI->signal_activate().connect(SigC::bind<int>(
 156.773 -                                    SigC::slot(*this, &Window::vOnJoypadConfigure), 1));
 156.774 -
 156.775 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure2"));
 156.776 -  poMI->signal_activate().connect(SigC::bind<int>(
 156.777 -                                    SigC::slot(*this, &Window::vOnJoypadConfigure), 2));
 156.778 -
 156.779 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure3"));
 156.780 -  poMI->signal_activate().connect(SigC::bind<int>(
 156.781 -                                    SigC::slot(*this, &Window::vOnJoypadConfigure), 3));
 156.782 -
 156.783 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure4"));
 156.784 -  poMI->signal_activate().connect(SigC::bind<int>(
 156.785 -                                    SigC::slot(*this, &Window::vOnJoypadConfigure), 4));
 156.786 -
 156.787 -  int iDefaultJoypad = m_poInputConfig->oGetKey<int>("active_joypad");
 156.788 -  for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)
 156.789 -  {
 156.790 -    char csName[20];
 156.791 -    snprintf(csName, sizeof(csName), "Joypad%d", i);
 156.792 -
 156.793 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(csName));
 156.794 -    if (i == iDefaultJoypad)
 156.795 -    {
 156.796 -      poCMI->set_active();
 156.797 -      vOnJoypadToggled(poCMI, iDefaultJoypad);
 156.798 -    }
 156.799 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>(
 156.800 -                                      SigC::slot(*this, &Window::vOnJoypadToggled),
 156.801 -                                      poCMI, i));
 156.802 -  }
 156.803 -
 156.804 -  // Autofire menu
 156.805 -  //
 156.806 -  struct
 156.807 -  {
 156.808 -    const char *   m_csName;
 156.809 -    const char *   m_csKey;
 156.810 -    const EKeyFlag m_eKeyFlag;
 156.811 -  }
 156.812 -  astAutofire[] =
 156.813 -  {
 156.814 -    { "AutofireA", "autofire_A", KeyFlagA },
 156.815 -    { "AutofireB", "autofire_B", KeyFlagB },
 156.816 -    { "AutofireL", "autofire_L", KeyFlagL },
 156.817 -    { "AutofireR", "autofire_R", KeyFlagR }
 156.818 -  };
 156.819 -  for (guint i = 0; i < G_N_ELEMENTS(astAutofire); i++)
 156.820 -  {
 156.821 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astAutofire[i].m_csName));
 156.822 -    poCMI->set_active(m_poInputConfig->oGetKey<bool>(astAutofire[i].m_csKey));
 156.823 -    vOnAutofireToggled(poCMI, astAutofire[i].m_eKeyFlag);
 156.824 -    poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, u32>(
 156.825 -                                      SigC::slot(*this, &Window::vOnAutofireToggled),
 156.826 -                                      poCMI, astAutofire[i].m_eKeyFlag));
 156.827 -  }
 156.828 -
 156.829 -  // GDB menu
 156.830 -  //
 156.831 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbWait"));
 156.832 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBWait));
 156.833 -
 156.834 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbLoadAndWait"));
 156.835 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBLoadAndWait));
 156.836 -
 156.837 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbBreak"));
 156.838 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBBreak));
 156.839 -
 156.840 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbDisconnect"));
 156.841 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBDisconnect));
 156.842 -
 156.843 -  // Help menu
 156.844 -  //
 156.845 -  poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("HelpAbout"));
 156.846 -  poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnHelpAbout));
 156.847 -
 156.848 -  // Init widgets sensitivity
 156.849 -  for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
 156.850 -       it != m_listSensitiveWhenPlaying.end();
 156.851 -       it++)
 156.852 -  {
 156.853 -    (*it)->set_sensitive(false);
 156.854 -  }
 156.855 -
 156.856 -  if (m_poInstance == NULL)
 156.857 -  {
 156.858 -    m_poInstance = this;
 156.859 -  }
 156.860 -  else
 156.861 -  {
 156.862 -    abort();
 156.863 -  }
 156.864 -}
 156.865 -
 156.866 -Window::~Window()
 156.867 -{
 156.868 -  vOnFileClose();
 156.869 -  vSaveHistoryToConfig();
 156.870 -  vSaveJoypadsToConfig();
 156.871 -  vSaveConfig(m_sConfigFile);
 156.872 -
 156.873 -  if (m_poFileOpenDialog != NULL)
 156.874 -  {
 156.875 -    delete m_poFileOpenDialog;
 156.876 -  }
 156.877 -
 156.878 -  if (m_poKeymap != NULL)
 156.879 -  {
 156.880 -    delete m_poKeymap;
 156.881 -  }
 156.882 -
 156.883 -  m_poInstance = NULL;
 156.884 -}
 156.885 -
 156.886 -void Window::vInitSystem()
 156.887 -{
 156.888 -#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 156.889 -  systemRedShift    = 3;
 156.890 -  systemGreenShift  = 11;
 156.891 -  systemBlueShift   = 19;
 156.892 -  RGB_LOW_BITS_MASK = 0x00010101;
 156.893 -#else
 156.894 -  systemRedShift    = 27;
 156.895 -  systemGreenShift  = 19;
 156.896 -  systemBlueShift   = 11;
 156.897 -  RGB_LOW_BITS_MASK = 0x01010100;
 156.898 -#endif
 156.899 -
 156.900 -  systemColorDepth = 32;
 156.901 -  systemDebug = 0;
 156.902 -  systemVerbose = 0;
 156.903 -  systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 156.904 -  systemFrameSkip = 0;
 156.905 -  systemSoundOn = false;
 156.906 -  soundOffFlag = true;
 156.907 -
 156.908 -  systemRenderedFrames = 0;
 156.909 -  systemFPS = 0;
 156.910 -
 156.911 -  emulating = 0;
 156.912 -  debugger = false;
 156.913 -
 156.914 -  for (int i = 0; i < 0x10000; i++)
 156.915 -  {
 156.916 -#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 156.917 -    systemColorMap32[i] = (((i & 0x1f) << systemRedShift)
 156.918 -                           | (((i & 0x3e0) >> 5) << systemGreenShift)
 156.919 -                           | (((i & 0x7c00) >> 10) << systemBlueShift));
 156.920 -#else
 156.921 -    systemColorMap32[i] = (((i & 0x1f) << systemRedShift)
 156.922 -                           | (((i & 0x3e0) >> 5) << systemGreenShift)
 156.923 -                           | (((i & 0x7c00) >> 10) << systemBlueShift));
 156.924 -#endif
 156.925 -  }
 156.926 -
 156.927 -  gbFrameSkip = 0;
 156.928 -
 156.929 -  for (int i = 0; i < 24; )
 156.930 -  {
 156.931 -    systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
 156.932 -    systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
 156.933 -    systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
 156.934 -    systemGbPalette[i++] = 0;
 156.935 -  }
 156.936 -
 156.937 -  Init_2xSaI(32);
 156.938 -}
 156.939 -
 156.940 -void Window::vInitSDL()
 156.941 -{
 156.942 -  static bool bDone = false;
 156.943 -
 156.944 -  if (bDone)
 156.945 -    return;
 156.946 -
 156.947 -  int iFlags = (SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
 156.948 -
 156.949 -  if (SDL_Init(iFlags) < 0)
 156.950 -  {
 156.951 -    fprintf(stderr, "Failed to init SDL: %s", SDL_GetError());
 156.952 -    abort();
 156.953 -  }
 156.954 -
 156.955 -  bDone = true;
 156.956 -}
 156.957 -
 156.958 -void Window::vInitConfig()
 156.959 -{
 156.960 -  m_oConfig.vClear();
 156.961 -
 156.962 -  // History section
 156.963 -  //
 156.964 -  m_poHistoryConfig = m_oConfig.poAddSection("History");
 156.965 -  m_poHistoryConfig->vSetKey("freeze", false );
 156.966 -  m_poHistoryConfig->vSetKey("0",      ""    );
 156.967 -  m_poHistoryConfig->vSetKey("1",      ""    );
 156.968 -  m_poHistoryConfig->vSetKey("2",      ""    );
 156.969 -  m_poHistoryConfig->vSetKey("3",      ""    );
 156.970 -  m_poHistoryConfig->vSetKey("4",      ""    );
 156.971 -  m_poHistoryConfig->vSetKey("5",      ""    );
 156.972 -  m_poHistoryConfig->vSetKey("6",      ""    );
 156.973 -  m_poHistoryConfig->vSetKey("7",      ""    );
 156.974 -  m_poHistoryConfig->vSetKey("8",      ""    );
 156.975 -  m_poHistoryConfig->vSetKey("9",      ""    );
 156.976 -
 156.977 -  // Directories section
 156.978 -  //
 156.979 -  m_poDirConfig = m_oConfig.poAddSection("Directories");
 156.980 -  m_poDirConfig->vSetKey("gb_roms",   "" );
 156.981 -  m_poDirConfig->vSetKey("gba_roms",  "" );
 156.982 -  m_poDirConfig->vSetKey("batteries", "" );
 156.983 -  m_poDirConfig->vSetKey("saves",     "" );
 156.984 -  m_poDirConfig->vSetKey("captures",  "" );
 156.985 -
 156.986 -  // Core section
 156.987 -  //
 156.988 -  m_poCoreConfig = m_oConfig.poAddSection("Core");
 156.989 -  m_poCoreConfig->vSetKey("load_game_auto",    false        );
 156.990 -  m_poCoreConfig->vSetKey("frameskip",         "auto"       );
 156.991 -  m_poCoreConfig->vSetKey("throttle",          0            );
 156.992 -  m_poCoreConfig->vSetKey("layer_bg0",         true         );
 156.993 -  m_poCoreConfig->vSetKey("layer_bg1",         true         );
 156.994 -  m_poCoreConfig->vSetKey("layer_bg2",         true         );
 156.995 -  m_poCoreConfig->vSetKey("layer_bg3",         true         );
 156.996 -  m_poCoreConfig->vSetKey("layer_obj",         true         );
 156.997 -  m_poCoreConfig->vSetKey("layer_win0",        true         );
 156.998 -  m_poCoreConfig->vSetKey("layer_win1",        true         );
 156.999 -  m_poCoreConfig->vSetKey("layer_objwin",      true         );
156.1000 -  m_poCoreConfig->vSetKey("use_bios_file",     false        );
156.1001 -  m_poCoreConfig->vSetKey("bios_file",         ""           );
156.1002 -  m_poCoreConfig->vSetKey("save_type",         SaveAuto     );
156.1003 -  m_poCoreConfig->vSetKey("flash_size",        64           );
156.1004 -  m_poCoreConfig->vSetKey("gb_border",         true         );
156.1005 -  m_poCoreConfig->vSetKey("gb_printer",        false        );
156.1006 -  m_poCoreConfig->vSetKey("emulator_type",     EmulatorAuto );
156.1007 -  m_poCoreConfig->vSetKey("screenshot_format", "png"        );
156.1008 -
156.1009 -  // Display section
156.1010 -  //
156.1011 -  m_poDisplayConfig = m_oConfig.poAddSection("Display");
156.1012 -  m_poDisplayConfig->vSetKey("scale",               1              );
156.1013 -  m_poDisplayConfig->vSetKey("show_speed",          ShowPercentage );
156.1014 -  m_poDisplayConfig->vSetKey("pause_when_inactive", true           );
156.1015 -  m_poDisplayConfig->vSetKey("filter2x",            FilterNone     );
156.1016 -  m_poDisplayConfig->vSetKey("filterIB",            FilterIBNone   );
156.1017 -#ifdef MMX
156.1018 -  m_poDisplayConfig->vSetKey("filter_disable_mmx",  false          );
156.1019 -#endif // MMX
156.1020 -
156.1021 -  // Sound section
156.1022 -  //
156.1023 -  m_poSoundConfig = m_oConfig.poAddSection("Sound");
156.1024 -  m_poSoundConfig->vSetKey("status",         "on"     );
156.1025 -  m_poSoundConfig->vSetKey("echo",           false    );
156.1026 -  m_poSoundConfig->vSetKey("low_pass",       false    );
156.1027 -  m_poSoundConfig->vSetKey("reverse_stereo", false    );
156.1028 -  m_poSoundConfig->vSetKey("channel_1",      true     );
156.1029 -  m_poSoundConfig->vSetKey("channel_2",      true     );
156.1030 -  m_poSoundConfig->vSetKey("channel_3",      true     );
156.1031 -  m_poSoundConfig->vSetKey("channel_4",      true     );
156.1032 -  m_poSoundConfig->vSetKey("channel_A",      true     );
156.1033 -  m_poSoundConfig->vSetKey("channel_B",      true     );
156.1034 -  m_poSoundConfig->vSetKey("quality",        Sound22K );
156.1035 -  m_poSoundConfig->vSetKey("volume",         Sound100 );
156.1036 -
156.1037 -  // Input section
156.1038 -  //
156.1039 -  JoypadConfig oJoypadConfig;
156.1040 -  oJoypadConfig.vSetDefault();
156.1041 -  m_poInputConfig = m_oConfig.poAddSection("Input");
156.1042 -  m_poInputConfig->vSetKey("active_joypad", m_iJoypadMin );
156.1043 -  for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)
156.1044 -  {
156.1045 -    char csPrefix[20];
156.1046 -    snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i);
156.1047 -    std::string sPrefix(csPrefix);
156.1048 -    m_poInputConfig->vSetKey(sPrefix + "up",      oJoypadConfig.m_uiUp      );
156.1049 -    m_poInputConfig->vSetKey(sPrefix + "down",    oJoypadConfig.m_uiDown    );
156.1050 -    m_poInputConfig->vSetKey(sPrefix + "left",    oJoypadConfig.m_uiLeft    );
156.1051 -    m_poInputConfig->vSetKey(sPrefix + "right",   oJoypadConfig.m_uiRight   );
156.1052 -    m_poInputConfig->vSetKey(sPrefix + "A",       oJoypadConfig.m_uiA       );
156.1053 -    m_poInputConfig->vSetKey(sPrefix + "B",       oJoypadConfig.m_uiB       );
156.1054 -    m_poInputConfig->vSetKey(sPrefix + "L",       oJoypadConfig.m_uiL       );
156.1055 -    m_poInputConfig->vSetKey(sPrefix + "R",       oJoypadConfig.m_uiR       );
156.1056 -    m_poInputConfig->vSetKey(sPrefix + "select",  oJoypadConfig.m_uiSelect  );
156.1057 -    m_poInputConfig->vSetKey(sPrefix + "start",   oJoypadConfig.m_uiStart   );
156.1058 -    m_poInputConfig->vSetKey(sPrefix + "speed",   oJoypadConfig.m_uiSpeed   );
156.1059 -    m_poInputConfig->vSetKey(sPrefix + "capture", oJoypadConfig.m_uiCapture );
156.1060 -  }
156.1061 -  m_poInputConfig->vSetKey("autofire_A", false );
156.1062 -  m_poInputConfig->vSetKey("autofire_B", false );
156.1063 -  m_poInputConfig->vSetKey("autofire_L", false );
156.1064 -  m_poInputConfig->vSetKey("autofire_R", false );
156.1065 -}
156.1066 -
156.1067 -void Window::vCheckConfig()
156.1068 -{
156.1069 -  int iValue;
156.1070 -  int iAdjusted;
156.1071 -  std::string sValue;
156.1072 -
156.1073 -  // Directories section
156.1074 -  //
156.1075 -  sValue = m_poDirConfig->sGetKey("gb_roms");
156.1076 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
156.1077 -  {
156.1078 -    m_poDirConfig->vSetKey("gb_roms", "");
156.1079 -  }
156.1080 -  sValue = m_poDirConfig->sGetKey("gba_roms");
156.1081 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
156.1082 -  {
156.1083 -    m_poDirConfig->vSetKey("gba_roms", "");
156.1084 -  }
156.1085 -  sValue = m_poDirConfig->sGetKey("batteries");
156.1086 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
156.1087 -  {
156.1088 -    m_poDirConfig->vSetKey("batteries", "");
156.1089 -  }
156.1090 -  sValue = m_poDirConfig->sGetKey("saves");
156.1091 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
156.1092 -  {
156.1093 -    m_poDirConfig->vSetKey("saves", "");
156.1094 -  }
156.1095 -  sValue = m_poDirConfig->sGetKey("captures");
156.1096 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
156.1097 -  {
156.1098 -    m_poDirConfig->vSetKey("captures", "");
156.1099 -  }
156.1100 -
156.1101 -  // Core section
156.1102 -  //
156.1103 -  if (m_poCoreConfig->sGetKey("frameskip") != "auto")
156.1104 -  {
156.1105 -    iValue = m_poCoreConfig->oGetKey<int>("frameskip");
156.1106 -    iAdjusted = CLAMP(iValue, m_iFrameskipMin, m_iFrameskipMax);
156.1107 -    if (iValue != iAdjusted)
156.1108 -    {
156.1109 -      m_poCoreConfig->vSetKey("frameskip", iAdjusted);
156.1110 -    }
156.1111 -  }
156.1112 -
156.1113 -  iValue = m_poCoreConfig->oGetKey<int>("throttle");
156.1114 -  if (iValue != 0)
156.1115 -  {
156.1116 -    iAdjusted = CLAMP(iValue, m_iThrottleMin, m_iThrottleMax);
156.1117 -    if (iValue != iAdjusted)
156.1118 -    {
156.1119 -      m_poCoreConfig->vSetKey("throttle", iAdjusted);
156.1120 -    }
156.1121 -  }
156.1122 -
156.1123 -  sValue = m_poCoreConfig->sGetKey("bios_file");
156.1124 -  if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_REGULAR))
156.1125 -  {
156.1126 -    m_poCoreConfig->vSetKey("bios_file", "");
156.1127 -  }
156.1128 -  if (m_poCoreConfig->sGetKey("bios_file") == "")
156.1129 -  {
156.1130 -    m_poCoreConfig->vSetKey("use_bios_file", false);
156.1131 -  }
156.1132 -
156.1133 -  iValue = m_poCoreConfig->oGetKey<int>("save_type");
156.1134 -  if (iValue != 0)
156.1135 -  {
156.1136 -    iAdjusted = CLAMP(iValue, m_iSaveTypeMin, m_iSaveTypeMax);
156.1137 -    if (iValue != iAdjusted)
156.1138 -    {
156.1139 -      m_poCoreConfig->vSetKey("save_type", iAdjusted);
156.1140 -    }
156.1141 -  }
156.1142 -
156.1143 -  iValue = m_poCoreConfig->oGetKey<int>("flash_size");
156.1144 -  if (iValue != 64 && iValue != 128)
156.1145 -  {
156.1146 -    m_poCoreConfig->vSetKey("flash_size", 64);
156.1147 -  }
156.1148 -
156.1149 -  iValue = m_poCoreConfig->oGetKey<int>("emulator_type");
156.1150 -  iAdjusted = CLAMP(iValue, m_iEmulatorTypeMin, m_iEmulatorTypeMax);
156.1151 -  if (iValue != iAdjusted)
156.1152 -  {
156.1153 -    m_poCoreConfig->vSetKey("emulator_type", iAdjusted);
156.1154 -  }
156.1155 -
156.1156 -  sValue = m_poCoreConfig->sGetKey("screenshot_format");
156.1157 -  if (sValue != "png" && sValue != "bmp")
156.1158 -  {
156.1159 -    sValue = "png";
156.1160 -  }
156.1161 -
156.1162 -  // Display section
156.1163 -  //
156.1164 -  iValue = m_poDisplayConfig->oGetKey<int>("scale");
156.1165 -  iAdjusted = CLAMP(iValue, m_iScaleMin, m_iScaleMax);
156.1166 -  if (iValue != iAdjusted)
156.1167 -  {
156.1168 -    m_poDisplayConfig->vSetKey("scale", iAdjusted);
156.1169 -  }
156.1170 -
156.1171 -  iValue = m_poDisplayConfig->oGetKey<int>("show_speed");
156.1172 -  iAdjusted = CLAMP(iValue, m_iShowSpeedMin, m_iShowSpeedMax);
156.1173 -  if (iValue != iAdjusted)
156.1174 -  {
156.1175 -    m_poDisplayConfig->vSetKey("show_speed", iAdjusted);
156.1176 -  }
156.1177 -
156.1178 -  iValue = m_poDisplayConfig->oGetKey<int>("filter2x");
156.1179 -  iAdjusted = CLAMP(iValue, m_iFilter2xMin, m_iFilter2xMax);
156.1180 -  if (iValue != iAdjusted)
156.1181 -  {
156.1182 -    m_poDisplayConfig->vSetKey("filter2x", iAdjusted);
156.1183 -  }
156.1184 -
156.1185 -  iValue = m_poDisplayConfig->oGetKey<int>("filterIB");
156.1186 -  iAdjusted = CLAMP(iValue, m_iFilterIBMin, m_iFilterIBMax);
156.1187 -  if (iValue != iAdjusted)
156.1188 -  {
156.1189 -    m_poDisplayConfig->vSetKey("filterIB", iAdjusted);
156.1190 -  }
156.1191 -
156.1192 -  // Sound section
156.1193 -  //
156.1194 -  sValue = m_poSoundConfig->sGetKey("status");
156.1195 -  if (sValue != "off" && sValue != "on" && sValue != "mute")
156.1196 -  {
156.1197 -    m_poSoundConfig->vSetKey("status", "on");
156.1198 -  }
156.1199 -
156.1200 -  iValue = m_poSoundConfig->oGetKey<int>("quality");
156.1201 -  iAdjusted = CLAMP(iValue, m_iSoundQualityMin, m_iSoundQualityMax);
156.1202 -  if (iValue != iAdjusted)
156.1203 -  {
156.1204 -    m_poSoundConfig->vSetKey("quality", iAdjusted);
156.1205 -  }
156.1206 -
156.1207 -  iValue = m_poSoundConfig->oGetKey<int>("volume");
156.1208 -  iAdjusted = CLAMP(iValue, m_iSoundVolumeMin, m_iSoundVolumeMax);
156.1209 -  if (iValue != iAdjusted)
156.1210 -  {
156.1211 -    m_poSoundConfig->vSetKey("volume", iAdjusted);
156.1212 -  }
156.1213 -
156.1214 -  // Input section
156.1215 -  //
156.1216 -  iValue = m_poInputConfig->oGetKey<int>("active_joypad");
156.1217 -  iAdjusted = CLAMP(iValue, m_iJoypadMin, m_iJoypadMax);
156.1218 -  if (iValue != iAdjusted)
156.1219 -  {
156.1220 -    m_poInputConfig->vSetKey("active_joypad", iAdjusted);
156.1221 -  }
156.1222 -}
156.1223 -
156.1224 -void Window::vLoadConfig(const std::string & _rsFile)
156.1225 -{
156.1226 -  try
156.1227 -  {
156.1228 -    m_oConfig.vLoad(_rsFile, false, false);
156.1229 -  }
156.1230 -  catch (const Glib::Error & e)
156.1231 -  {
156.1232 -    vPopupError(e.what().c_str());
156.1233 -  }
156.1234 -}
156.1235 -
156.1236 -void Window::vSaveConfig(const std::string & _rsFile)
156.1237 -{
156.1238 -  try
156.1239 -  {
156.1240 -    m_oConfig.vSave(_rsFile);
156.1241 -  }
156.1242 -  catch (const Glib::Error & e)
156.1243 -  {
156.1244 -    vPopupError(e.what().c_str());
156.1245 -  }
156.1246 -}
156.1247 -
156.1248 -void Window::vLoadHistoryFromConfig()
156.1249 -{
156.1250 -  char csKey[] = "0";
156.1251 -  for (int i = 0; i < 10; i++, csKey[0]++)
156.1252 -  {
156.1253 -    std::string sFile = m_poHistoryConfig->sGetKey(csKey);
156.1254 -    if (sFile == "")
156.1255 -    {
156.1256 -      break;
156.1257 -    }
156.1258 -    m_listHistory.push_back(sFile);
156.1259 -  }
156.1260 -}
156.1261 -
156.1262 -void Window::vSaveHistoryToConfig()
156.1263 -{
156.1264 -  char csKey[] = "0";
156.1265 -  for (std::list<std::string>::const_iterator it = m_listHistory.begin();
156.1266 -       it != m_listHistory.end();
156.1267 -       it++, csKey[0]++)
156.1268 -  {
156.1269 -    m_poHistoryConfig->vSetKey(csKey, *it);
156.1270 -  }
156.1271 -}
156.1272 -
156.1273 -void Window::vHistoryAdd(const std::string & _rsFile)
156.1274 -{
156.1275 -  if (m_poHistoryConfig->oGetKey<bool>("freeze"))
156.1276 -  {
156.1277 -    return;
156.1278 -  }
156.1279 -
156.1280 -  m_listHistory.remove(_rsFile);
156.1281 -  m_listHistory.push_front(_rsFile);
156.1282 -  if (m_listHistory.size() > 10)
156.1283 -  {
156.1284 -    m_listHistory.pop_back();
156.1285 -  }
156.1286 -
156.1287 -  vUpdateHistoryMenu();
156.1288 -}
156.1289 -
156.1290 -void Window::vClearHistoryMenu()
156.1291 -{
156.1292 -  Gtk::Menu_Helpers::MenuList::iterator it = m_poRecentMenu->items().begin();
156.1293 -  for (int i = 0; i < 3; i++, it++)
156.1294 -    ;
156.1295 -
156.1296 -  m_poRecentMenu->items().erase(it, m_poRecentMenu->items().end());
156.1297 -}
156.1298 -
156.1299 -void Window::vUpdateHistoryMenu()
156.1300 -{
156.1301 -  vClearHistoryMenu();
156.1302 -
156.1303 -  guint uiAccelKey = GDK_F1;
156.1304 -  for (std::list<std::string>::const_iterator it = m_listHistory.begin();
156.1305 -       it != m_listHistory.end();
156.1306 -       it++, uiAccelKey++)
156.1307 -  {
156.1308 -    Gtk::Image * poImage = Gtk::manage(new Gtk::Image(Gtk::Stock::OPEN, Gtk::ICON_SIZE_MENU));
156.1309 -    Glib::ustring sLabel = Glib::path_get_basename(*it);
156.1310 -    VBA::ImageMenuItem * poIMI = Gtk::manage(new VBA::ImageMenuItem(*poImage, sLabel));
156.1311 -
156.1312 -    m_oTooltips.set_tip(*poIMI, *it);
156.1313 -
156.1314 -    poIMI->signal_activate().connect(SigC::bind<std::string>(
156.1315 -                                      SigC::slot(*this, &Window::vOnRecentFile),
156.1316 -                                      *it));
156.1317 -
156.1318 -    poIMI->set_accel_key(Gtk::AccelKey(uiAccelKey, Gdk::CONTROL_MASK));
156.1319 -    poIMI->accelerate(*this);
156.1320 -
156.1321 -    poIMI->show();
156.1322 -    m_poRecentMenu->items().push_back(*poIMI);
156.1323 -  }
156.1324 -}
156.1325 -
156.1326 -void Window::vLoadJoypadsFromConfig()
156.1327 -{
156.1328 -  m_oJoypads.clear();
156.1329 -
156.1330 -  for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)
156.1331 -  {
156.1332 -    char csPrefix[20];
156.1333 -    snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i);
156.1334 -    std::string sPrefix(csPrefix);
156.1335 -
156.1336 -    JoypadConfig oJoypadConfig;
156.1337 -    oJoypadConfig.m_uiUp      = m_poInputConfig->oGetKey<guint>(sPrefix + "up");
156.1338 -    oJoypadConfig.m_uiDown    = m_poInputConfig->oGetKey<guint>(sPrefix + "down");
156.1339 -    oJoypadConfig.m_uiLeft    = m_poInputConfig->oGetKey<guint>(sPrefix + "left");
156.1340 -    oJoypadConfig.m_uiRight   = m_poInputConfig->oGetKey<guint>(sPrefix + "right");
156.1341 -    oJoypadConfig.m_uiA       = m_poInputConfig->oGetKey<guint>(sPrefix + "A");
156.1342 -    oJoypadConfig.m_uiB       = m_poInputConfig->oGetKey<guint>(sPrefix + "B");
156.1343 -    oJoypadConfig.m_uiL       = m_poInputConfig->oGetKey<guint>(sPrefix + "L");
156.1344 -    oJoypadConfig.m_uiR       = m_poInputConfig->oGetKey<guint>(sPrefix + "R");
156.1345 -    oJoypadConfig.m_uiSelect  = m_poInputConfig->oGetKey<guint>(sPrefix + "select");
156.1346 -    oJoypadConfig.m_uiStart   = m_poInputConfig->oGetKey<guint>(sPrefix + "start");
156.1347 -    oJoypadConfig.m_uiSpeed   = m_poInputConfig->oGetKey<guint>(sPrefix + "speed");
156.1348 -    oJoypadConfig.m_uiCapture = m_poInputConfig->oGetKey<guint>(sPrefix + "capture");
156.1349 -
156.1350 -    m_oJoypads.push_back(oJoypadConfig);
156.1351 -  }
156.1352 -}
156.1353 -
156.1354 -void Window::vSaveJoypadsToConfig()
156.1355 -{
156.1356 -  for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)
156.1357 -  {
156.1358 -    char csPrefix[20];
156.1359 -    snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i);
156.1360 -    std::string sPrefix(csPrefix);
156.1361 -
156.1362 -    m_poInputConfig->vSetKey(sPrefix + "up",      m_oJoypads[i - 1].m_uiUp      );
156.1363 -    m_poInputConfig->vSetKey(sPrefix + "down",    m_oJoypads[i - 1].m_uiDown    );
156.1364 -    m_poInputConfig->vSetKey(sPrefix + "left",    m_oJoypads[i - 1].m_uiLeft    );
156.1365 -    m_poInputConfig->vSetKey(sPrefix + "right",   m_oJoypads[i - 1].m_uiRight   );
156.1366 -    m_poInputConfig->vSetKey(sPrefix + "A",       m_oJoypads[i - 1].m_uiA       );
156.1367 -    m_poInputConfig->vSetKey(sPrefix + "B",       m_oJoypads[i - 1].m_uiB       );
156.1368 -    m_poInputConfig->vSetKey(sPrefix + "L",       m_oJoypads[i - 1].m_uiL       );
156.1369 -    m_poInputConfig->vSetKey(sPrefix + "R",       m_oJoypads[i - 1].m_uiR       );
156.1370 -    m_poInputConfig->vSetKey(sPrefix + "select",  m_oJoypads[i - 1].m_uiSelect  );
156.1371 -    m_poInputConfig->vSetKey(sPrefix + "start",   m_oJoypads[i - 1].m_uiStart   );
156.1372 -    m_poInputConfig->vSetKey(sPrefix + "speed",   m_oJoypads[i - 1].m_uiSpeed   );
156.1373 -    m_poInputConfig->vSetKey(sPrefix + "capture", m_oJoypads[i - 1].m_uiCapture );
156.1374 -  }
156.1375 -}
156.1376 -
156.1377 -void Window::vUpdateScreen()
156.1378 -{
156.1379 -  if (m_eCartridge == CartridgeGB)
156.1380 -  {
156.1381 -    if (gbBorderOn)
156.1382 -    {
156.1383 -      m_iScreenWidth     = m_iSGBScreenWidth;
156.1384 -      m_iScreenHeight    = m_iSGBScreenHeight;
156.1385 -      gbBorderLineSkip   = m_iSGBScreenWidth;
156.1386 -      gbBorderColumnSkip = (m_iSGBScreenWidth - m_iGBScreenWidth) / 2;
156.1387 -      gbBorderRowSkip    = (m_iSGBScreenHeight - m_iGBScreenHeight) / 2;
156.1388 -    }
156.1389 -    else
156.1390 -    {
156.1391 -      m_iScreenWidth     = m_iGBScreenWidth;
156.1392 -      m_iScreenHeight    = m_iGBScreenHeight;
156.1393 -      gbBorderLineSkip   = m_iGBScreenWidth;
156.1394 -      gbBorderColumnSkip = 0;
156.1395 -      gbBorderRowSkip    = 0;
156.1396 -    }
156.1397 -  }
156.1398 -  else if (m_eCartridge == CartridgeGBA)
156.1399 -  {
156.1400 -    m_iScreenWidth  = m_iGBAScreenWidth;
156.1401 -    m_iScreenHeight = m_iGBAScreenHeight;
156.1402 -  }
156.1403 -
156.1404 -  g_return_if_fail(m_iScreenWidth >= 1 && m_iScreenHeight >= 1);
156.1405 -
156.1406 -  m_poScreenArea->vSetSize(m_iScreenWidth, m_iScreenHeight);
156.1407 -  m_poScreenArea->vSetScale(m_poDisplayConfig->oGetKey<int>("scale"));
156.1408 -
156.1409 -  resize(1, 1);
156.1410 -
156.1411 -  if (emulating)
156.1412 -  {
156.1413 -    vDrawScreen();
156.1414 -  }
156.1415 -  else
156.1416 -  {
156.1417 -    vDrawDefaultScreen();
156.1418 -  }
156.1419 -}
156.1420 -
156.1421 -bool Window::bLoadROM(const std::string & _rsFile)
156.1422 -{
156.1423 -  vOnFileClose();
156.1424 -
156.1425 -  m_sRomFile = _rsFile;
156.1426 -  const char * csFile = _rsFile.c_str();
156.1427 -
156.1428 -  IMAGE_TYPE eType = utilFindType(csFile);
156.1429 -  if (eType == IMAGE_UNKNOWN)
156.1430 -  {
156.1431 -    vPopupError(_("Unknown file type %s"), csFile);
156.1432 -    return false;
156.1433 -  }
156.1434 -
156.1435 -  bool bLoaded = false;
156.1436 -  if (eType == IMAGE_GB)
156.1437 -  {
156.1438 -    bLoaded = gbLoadRom(csFile);
156.1439 -    if (bLoaded)
156.1440 -    {
156.1441 -      m_eCartridge = CartridgeGB;
156.1442 -      m_stEmulator = GBSystem;
156.1443 -    }
156.1444 -  }
156.1445 -  else if (eType == IMAGE_GBA)
156.1446 -  {
156.1447 -    int iSize = CPULoadRom(csFile);
156.1448 -    bLoaded = (iSize > 0);
156.1449 -    if (bLoaded)
156.1450 -    {
156.1451 -      m_eCartridge = CartridgeGBA;
156.1452 -      m_stEmulator = GBASystem;
156.1453 -
156.1454 -      useBios = m_poCoreConfig->oGetKey<bool>("use_bios_file");
156.1455 -      //CPUInit(m_poCoreConfig->sGetKey("bios_file").c_str(), useBios);
156.1456 -      CPUInit();
156.1457 -      CPUReset();
156.1458 -
156.1459 -      // If the bios file was rejected by CPUInit
156.1460 -      if (m_poCoreConfig->oGetKey<bool>("use_bios_file") && ! useBios)
156.1461 -      {
156.1462 -        m_poUseBiosItem->set_active(false);
156.1463 -        m_poUseBiosItem->set_sensitive(false);
156.1464 -        m_poCoreConfig->vSetKey("bios_file", "");
156.1465 -      }
156.1466 -    }
156.1467 -  }
156.1468 -
156.1469 -  if (! bLoaded)
156.1470 -  {
156.1471 -    return false;
156.1472 -  }
156.1473 -
156.1474 -  vLoadBattery();
156.1475 -  vUpdateScreen();
156.1476 -
156.1477 -  debugger = false; // May cause conflicts
156.1478 -  emulating = 1;
156.1479 -  m_bWasEmulating = false;
156.1480 -  m_uiThrottleDelay = 0;
156.1481 -
156.1482 -  if (m_eCartridge == CartridgeGBA)
156.1483 -  {
156.1484 -    soundSetQuality(m_eSoundQuality);
156.1485 -  }
156.1486 -  else
156.1487 -  {
156.1488 -    gbSoundSetQuality(m_eSoundQuality);
156.1489 -  }
156.1490 -
156.1491 -  vUpdateGameSlots();
156.1492 -  vHistoryAdd(_rsFile);
156.1493 -
156.1494 -  for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
156.1495 -       it != m_listSensitiveWhenPlaying.end();
156.1496 -       it++)
156.1497 -  {
156.1498 -    (*it)->set_sensitive();
156.1499 -  }
156.1500 -
156.1501 -  if (m_poCoreConfig->oGetKey<bool>("load_game_auto"))
156.1502 -  {
156.1503 -    vOnLoadGameMostRecent();
156.1504 -  }
156.1505 -
156.1506 -  vStartEmu();
156.1507 -
156.1508 -  return true;
156.1509 -}
156.1510 -
156.1511 -void Window::vPopupError(const char * _csFormat, ...)
156.1512 -{
156.1513 -  va_list args;
156.1514 -  va_start(args, _csFormat);
156.1515 -  char * csMsg = g_strdup_vprintf(_csFormat, args);
156.1516 -  va_end(args);
156.1517 -
156.1518 -  Gtk::MessageDialog oDialog(*this,
156.1519 -                             csMsg,
156.1520 -#ifndef GTKMM20
156.1521 -                             false,
156.1522 -#endif // ! GTKMM20
156.1523 -                             Gtk::MESSAGE_ERROR,
156.1524 -                             Gtk::BUTTONS_OK);
156.1525 -  oDialog.run();
156.1526 -  g_free(csMsg);
156.1527 -}
156.1528 -
156.1529 -void Window::vPopupErrorV(const char * _csFormat, va_list _args)
156.1530 -{
156.1531 -  char * csMsg = g_strdup_vprintf(_csFormat, _args);
156.1532 -
156.1533 -  Gtk::MessageDialog oDialog(*this,
156.1534 -                             csMsg,
156.1535 -#ifndef GTKMM20
156.1536 -                             false,
156.1537 -#endif // ! GTKMM20
156.1538 -                             Gtk::MESSAGE_ERROR,
156.1539 -                             Gtk::BUTTONS_OK);
156.1540 -  oDialog.run();
156.1541 -  g_free(csMsg);
156.1542 -}
156.1543 -
156.1544 -void Window::vDrawScreen()
156.1545 -{
156.1546 -  m_poScreenArea->vDrawPixels(pix);
156.1547 -}
156.1548 -
156.1549 -void Window::vDrawDefaultScreen()
156.1550 -{
156.1551 -  m_poScreenArea->vDrawColor(0x000000); // Black
156.1552 -}
156.1553 -
156.1554 -void Window::vSetDefaultTitle()
156.1555 -{
156.1556 -  set_title("VBA");
156.1557 -}
156.1558 -
156.1559 -void Window::vShowSpeed(int _iSpeed)
156.1560 -{
156.1561 -  char csTitle[50];
156.1562 -
156.1563 -  if (m_eShowSpeed == ShowPercentage)
156.1564 -  {
156.1565 -    snprintf(csTitle, 50, "VBA - %d%%", _iSpeed);
156.1566 -    set_title(csTitle);
156.1567 -  }
156.1568 -  else if (m_eShowSpeed == ShowDetailed)
156.1569 -  {
156.1570 -    snprintf(csTitle, 50, "VBA - %d%% (%d, %d fps)",
156.1571 -             _iSpeed, systemFrameSkip, systemFPS);
156.1572 -    set_title(csTitle);
156.1573 -  }
156.1574 -}
156.1575 -
156.1576 -void Window::vComputeFrameskip(int _iRate)
156.1577 -{
156.1578 -  static u32 uiLastTime = 0;
156.1579 -  static int iFrameskipAdjust = 0;
156.1580 -
156.1581 -  u32 uiTime = SDL_GetTicks();
156.1582 -
156.1583 -  if (m_bWasEmulating)
156.1584 -  {
156.1585 -    int iWantedSpeed = 100;
156.1586 -
156.1587 -    if (m_iThrottle > 0)
156.1588 -    {
156.1589 -      if (! speedup)
156.1590 -      {
156.1591 -        u32 uiDiff  = uiTime - m_uiThrottleLastTime;
156.1592 -        int iTarget = 1000000 / (_iRate * m_iThrottle);
156.1593 -        int iDelay  = iTarget - uiDiff;
156.1594 -        if (iDelay > 0)
156.1595 -        {
156.1596 -          m_uiThrottleDelay = iDelay;
156.1597 -        }
156.1598 -      }
156.1599 -      iWantedSpeed = m_iThrottle;
156.1600 -    }
156.1601 -
156.1602 -    if (m_bAutoFrameskip)
156.1603 -    {
156.1604 -      u32 uiDiff = uiTime - uiLastTime;
156.1605 -      int iSpeed = iWantedSpeed;
156.1606 -
156.1607 -      if (uiDiff != 0)
156.1608 -      {
156.1609 -        iSpeed = (1000000 / _iRate) / uiDiff;
156.1610 -      }
156.1611 -
156.1612 -      if (iSpeed >= iWantedSpeed - 2)
156.1613 -      {
156.1614 -        iFrameskipAdjust++;
156.1615 -        if (iFrameskipAdjust >= 3)
156.1616 -        {
156.1617 -          iFrameskipAdjust = 0;
156.1618 -          if (systemFrameSkip > 0)
156.1619 -          {
156.1620 -            systemFrameSkip--;
156.1621 -          }
156.1622 -        }
156.1623 -      }
156.1624 -      else
156.1625 -      {
156.1626 -        if (iSpeed < iWantedSpeed - 20)
156.1627 -        {
156.1628 -          iFrameskipAdjust -= ((iWantedSpeed - 10) - iSpeed) / 5;
156.1629 -        }
156.1630 -        else if (systemFrameSkip < 9)
156.1631 -        {
156.1632 -          iFrameskipAdjust--;
156.1633 -        }
156.1634 -
156.1635 -        if (iFrameskipAdjust <= -2)
156.1636 -        {
156.1637 -          iFrameskipAdjust += 2;
156.1638 -          if (systemFrameSkip < 9)
156.1639 -          {
156.1640 -            systemFrameSkip++;
156.1641 -          }
156.1642 -        }
156.1643 -      }
156.1644 -    }
156.1645 -  }
156.1646 -  else
156.1647 -  {
156.1648 -    m_bWasEmulating = true;
156.1649 -  }
156.1650 -
156.1651 -  uiLastTime = uiTime;
156.1652 -  m_uiThrottleLastTime = uiTime;
156.1653 -}
156.1654 -
156.1655 -void Window::vCaptureScreen(int _iNum)
156.1656 -{
156.1657 -  std::string sBaseName;
156.1658 -  std::string sCaptureDir = m_poDirConfig->sGetKey("captures");
156.1659 -  if (sCaptureDir == "")
156.1660 -  {
156.1661 -    sBaseName = sCutSuffix(m_sRomFile);
156.1662 -  }
156.1663 -  else
156.1664 -  {
156.1665 -    sBaseName = sCaptureDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile));
156.1666 -  }
156.1667 -  std::string sFormat = m_poCoreConfig->sGetKey("screenshot_format");
156.1668 -
156.1669 -  char * csFile = g_strdup_printf("%s_%02d.%s",
156.1670 -                                  sBaseName.c_str(),
156.1671 -                                  _iNum,
156.1672 -                                  sFormat.c_str());
156.1673 -  if (sFormat == "png")
156.1674 -  {
156.1675 -    m_stEmulator.emuWritePNG(csFile);
156.1676 -  }
156.1677 -  else
156.1678 -  {
156.1679 -    m_stEmulator.emuWriteBMP(csFile);
156.1680 -  }
156.1681 -  g_free(csFile);
156.1682 -}
156.1683 -
156.1684 -u32 Window::uiReadJoypad()
156.1685 -{
156.1686 -  u32 uiJoypad = m_uiJoypadState;
156.1687 -
156.1688 -  if (m_uiAutofireState != 0)
156.1689 -  {
156.1690 -    uiJoypad &= ~m_uiAutofireState;
156.1691 -    if (m_bAutofireToggle)
156.1692 -    {
156.1693 -      uiJoypad |= m_uiAutofireState;
156.1694 -    }
156.1695 -    m_bAutofireToggle = ! m_bAutofireToggle;
156.1696 -  }
156.1697 -
156.1698 -  return uiJoypad;
156.1699 -}
156.1700 -
156.1701 -void Window::vCreateFileOpenDialog()
156.1702 -{
156.1703 -  if (m_poFileOpenDialog != NULL)
156.1704 -  {
156.1705 -    return;
156.1706 -  }
156.1707 -
156.1708 -  std::string sGBDir  = m_poDirConfig->sGetKey("gb_roms");
156.1709 -  std::string sGBADir = m_poDirConfig->sGetKey("gba_roms");
156.1710 -
156.1711 -#ifdef GTKMM20
156.1712 -
156.1713 -  Gtk::FileSelection * poDialog = new Gtk::FileSelection(_("Open"));
156.1714 -  poDialog->set_transient_for(*this);
156.1715 -
156.1716 -  if (sGBADir != "")
156.1717 -  {
156.1718 -    poDialog->set_filename(sGBADir + "/");
156.1719 -  }
156.1720 -  else if (sGBDir != "")
156.1721 -  {
156.1722 -    poDialog->set_filename(sGBDir + "/");
156.1723 -  }
156.1724 -
156.1725 -#else // ! GTKMM20
156.1726 -
156.1727 -  Gtk::FileChooserDialog * poDialog = new Gtk::FileChooserDialog(*this, _("Open"));
156.1728 -  poDialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
156.1729 -  poDialog->add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
156.1730 -
156.1731 -  if (sGBDir != "")
156.1732 -  {
156.1733 -    poDialog->add_shortcut_folder(sGBDir);
156.1734 -    poDialog->set_current_folder(sGBDir);
156.1735 -  }
156.1736 -
156.1737 -  if (sGBADir != "" && sGBADir != sGBDir)
156.1738 -  {
156.1739 -    poDialog->add_shortcut_folder(sGBADir);
156.1740 -    poDialog->set_current_folder(sGBADir);
156.1741 -  }
156.1742 -
156.1743 -  const char * acsPattern[] =
156.1744 -  {
156.1745 -    // GBA
156.1746 -    "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
156.1747 -    // GB
156.1748 -    "*.[gG][bB]", "*.[sS][gG][bB]", "*.[cC][gG][bB]", "*.[gG][bB][cC]",
156.1749 -    // Both
156.1750 -    "*.[mM][bB]", "*.[eE][lL][fF]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
156.1751 -  };
156.1752 -
156.1753 -  Gtk::FileFilter oAllGBAFilter;
156.1754 -  oAllGBAFilter.set_name(_("All Gameboy Advance files"));
156.1755 -  for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
156.1756 -  {
156.1757 -    oAllGBAFilter.add_pattern(acsPattern[i]);
156.1758 -  }
156.1759 -
156.1760 -  Gtk::FileFilter oGBAFilter;
156.1761 -  oGBAFilter.set_name(_("Gameboy Advance files"));
156.1762 -  for (int i = 0; i < 3; i++)
156.1763 -  {
156.1764 -    oGBAFilter.add_pattern(acsPattern[i]);
156.1765 -  }
156.1766 -
156.1767 -  Gtk::FileFilter oGBFilter;
156.1768 -  oGBFilter.set_name(_("Gameboy files"));
156.1769 -  for (int i = 3; i < 7; i++)
156.1770 -  {
156.1771 -    oGBFilter.add_pattern(acsPattern[i]);
156.1772 -  }
156.1773 -
156.1774 -  poDialog->add_filter(oAllGBAFilter);
156.1775 -  poDialog->add_filter(oGBAFilter);
156.1776 -  poDialog->add_filter(oGBFilter);
156.1777 -
156.1778 -#endif // ! GTKMM20
156.1779 -
156.1780 -  m_poFileOpenDialog = poDialog;
156.1781 -}
156.1782 -
156.1783 -void Window::vLoadBattery()
156.1784 -{
156.1785 -  std::string sBattery;
156.1786 -  std::string sDir = m_poDirConfig->sGetKey("batteries");
156.1787 -  if (sDir == "")
156.1788 -  {
156.1789 -    sBattery = sCutSuffix(m_sRomFile) + ".sav";
156.1790 -  }
156.1791 -  else
156.1792 -  {
156.1793 -    sBattery = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sav";
156.1794 -  }
156.1795 -
156.1796 -  if (m_stEmulator.emuReadBattery(sBattery.c_str()))
156.1797 -  {
156.1798 -    systemScreenMessage(_("Loaded battery"));
156.1799 -  }
156.1800 -}
156.1801 -
156.1802 -void Window::vSaveBattery()
156.1803 -{
156.1804 -  std::string sBattery;
156.1805 -  std::string sDir = m_poDirConfig->sGetKey("batteries");
156.1806 -  if (sDir == "")
156.1807 -  {
156.1808 -    sBattery = sCutSuffix(m_sRomFile) + ".sav";
156.1809 -  }
156.1810 -  else
156.1811 -  {
156.1812 -    sBattery = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sav";
156.1813 -  }
156.1814 -
156.1815 -  if (m_stEmulator.emuWriteBattery(sBattery.c_str()))
156.1816 -  {
156.1817 -    systemScreenMessage(_("Saved battery"));
156.1818 -  }
156.1819 -}
156.1820 -
156.1821 -void Window::vStartEmu()
156.1822 -{
156.1823 -  if (m_oEmuSig.connected())
156.1824 -  {
156.1825 -    return;
156.1826 -  }
156.1827 -
156.1828 -  m_oEmuSig = Glib::signal_idle().connect(SigC::slot(*this, &Window::bOnEmuIdle),
156.1829 -                                          Glib::PRIORITY_DEFAULT_IDLE);
156.1830 -}
156.1831 -
156.1832 -void Window::vStopEmu()
156.1833 -{
156.1834 -  m_oEmuSig.disconnect();
156.1835 -  m_bWasEmulating = false;
156.1836 -}
156.1837 -
156.1838 -void Window::vSetThrottle(int _iPercent)
156.1839 -{
156.1840 -  m_iThrottle = _iPercent;
156.1841 -  m_poCoreConfig->vSetKey("throttle", _iPercent);
156.1842 -}
156.1843 -
156.1844 -void Window::vSelectBestThrottleItem()
156.1845 -{
156.1846 -  struct
156.1847 -  {
156.1848 -    const char * m_csName;
156.1849 -    const int    m_iThrottle;
156.1850 -  }
156.1851 -  astThrottle[] =
156.1852 -  {
156.1853 -    { "ThrottleNoThrottle",   0 },
156.1854 -    { "Throttle25",          25 },
156.1855 -    { "Throttle50",          50 },
156.1856 -    { "Throttle100",        100 },
156.1857 -    { "Throttle150",        150 },
156.1858 -    { "Throttle200",        200 }
156.1859 -  };
156.1860 -  for (guint i = 0; i < G_N_ELEMENTS(astThrottle); i++)
156.1861 -  {
156.1862 -    Gtk::CheckMenuItem * poCMI;
156.1863 -    poCMI = dynamic_cast<Gtk::CheckMenuItem *>(m_poXml->get_widget(astThrottle[i].m_csName));
156.1864 -    if (astThrottle[i].m_iThrottle == m_iThrottle)
156.1865 -    {
156.1866 -      poCMI->set_active();
156.1867 -    }
156.1868 -  }
156.1869 -}
156.1870 -
156.1871 -void Window::vUpdateGameSlots()
156.1872 -{
156.1873 -  if (m_eCartridge == CartridgeNone)
156.1874 -  {
156.1875 -    std::string sDateTime = _("----/--/-- --:--:--");
156.1876 -
156.1877 -    for (int i = 0; i < 10; i++)
156.1878 -    {
156.1879 -      char csPrefix[10];
156.1880 -      snprintf(csPrefix, sizeof(csPrefix), "%2d ", i + 1);
156.1881 -
156.1882 -      Gtk::Label * poLabel;
156.1883 -      poLabel = dynamic_cast<Gtk::Label *>(m_apoLoadGameItem[i]->get_child());
156.1884 -      poLabel->set_text(csPrefix + sDateTime);
156.1885 -      m_apoLoadGameItem[i]->set_sensitive(false);
156.1886 -
156.1887 -      poLabel = dynamic_cast<Gtk::Label *>(m_apoSaveGameItem[i]->get_child());
156.1888 -      poLabel->set_text(csPrefix + sDateTime);
156.1889 -      m_apoSaveGameItem[i]->set_sensitive(false);
156.1890 -
156.1891 -      m_astGameSlot[i].m_bEmpty = true;
156.1892 -    }
156.1893 -  }
156.1894 -  else
156.1895 -  {
156.1896 -    std::string sFileBase;
156.1897 -    std::string sDir = m_poDirConfig->sGetKey("saves");
156.1898 -    if (sDir == "")
156.1899 -    {
156.1900 -      sFileBase = sCutSuffix(m_sRomFile);
156.1901 -    }
156.1902 -    else
156.1903 -    {
156.1904 -      sFileBase = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile));
156.1905 -    }
156.1906 -
156.1907 -    const char * csDateFormat = _("%Y/%m/%d %H:%M:%S");
156.1908 -
156.1909 -    for (int i = 0; i < 10; i++)
156.1910 -    {
156.1911 -      char csPrefix[10];
156.1912 -      snprintf(csPrefix, sizeof(csPrefix), "%2d ", i + 1);
156.1913 -
156.1914 -      char csSlot[10];
156.1915 -      snprintf(csSlot, sizeof(csSlot), "%d", i + 1);
156.1916 -      m_astGameSlot[i].m_sFile = sFileBase + csSlot + ".sgm";
156.1917 -
156.1918 -      std::string sDateTime;
156.1919 -      struct stat stStat;
156.1920 -      if (stat(m_astGameSlot[i].m_sFile.c_str(), &stStat) == -1)
156.1921 -      {
156.1922 -        sDateTime = _("----/--/-- --:--:--");
156.1923 -        m_astGameSlot[i].m_bEmpty = true;
156.1924 -      }
156.1925 -      else
156.1926 -      {
156.1927 -        char csDateTime[30];
156.1928 -        strftime(csDateTime, sizeof(csDateTime), csDateFormat,
156.1929 -                 localtime(&stStat.st_mtime));
156.1930 -        sDateTime = csDateTime;
156.1931 -        m_astGameSlot[i].m_bEmpty = false;
156.1932 -        m_astGameSlot[i].m_uiTime = stStat.st_mtime;
156.1933 -      }
156.1934 -
156.1935 -      Gtk::Label * poLabel;
156.1936 -      poLabel = dynamic_cast<Gtk::Label *>(m_apoLoadGameItem[i]->get_child());
156.1937 -      poLabel->set_text(csPrefix + sDateTime);
156.1938 -      m_apoLoadGameItem[i]->set_sensitive(! m_astGameSlot[i].m_bEmpty);
156.1939 -
156.1940 -      poLabel = dynamic_cast<Gtk::Label *>(m_apoSaveGameItem[i]->get_child());
156.1941 -      poLabel->set_text(csPrefix + sDateTime);
156.1942 -      m_apoSaveGameItem[i]->set_sensitive();
156.1943 -    }
156.1944 -  }
156.1945 -}
156.1946 -
156.1947 -} // VBA namespace
   157.1 --- a/src/gtk/window.h	Sat Mar 03 10:54:39 2012 -0600
   157.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   157.3 @@ -1,322 +0,0 @@
   157.4 -// -*- C++ -*-
   157.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   157.6 -// Copyright (C) 1999-2003 Forgotten
   157.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   157.8 -
   157.9 -// This program is free software; you can redistribute it and/or modify
  157.10 -// it under the terms of the GNU General Public License as published by
  157.11 -// the Free Software Foundation; either version 2, or(at your option)
  157.12 -// any later version.
  157.13 -//
  157.14 -// This program is distributed in the hope that it will be useful,
  157.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  157.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  157.17 -// GNU General Public License for more details.
  157.18 -//
  157.19 -// You should have received a copy of the GNU General Public License
  157.20 -// along with this program; if not, write to the Free Software Foundation,
  157.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  157.22 -
  157.23 -#ifndef __VBA_WINDOW_H__
  157.24 -#define __VBA_WINDOW_H__
  157.25 -
  157.26 -#include <sys/types.h>
  157.27 -#include <stdarg.h>
  157.28 -
  157.29 -#include <libglademm.h>
  157.30 -#include <gtkmm.h>
  157.31 -
  157.32 -#ifndef GTKMM20
  157.33 -# include "sigccompat.h"
  157.34 -#endif // ! GTKMM20
  157.35 -
  157.36 -#include <string>
  157.37 -#include <vector>
  157.38 -#include <list>
  157.39 -
  157.40 -#include "../common/System.h"
  157.41 -
  157.42 -#include "configfile.h"
  157.43 -#include "screenarea.h"
  157.44 -#include "filters.h"
  157.45 -#include "input.h"
  157.46 -#include "joypadconfig.h"
  157.47 -
  157.48 -namespace VBA
  157.49 -{
  157.50 -
  157.51 -class Window : public Gtk::Window
  157.52 -{
  157.53 -  friend class Gnome::Glade::Xml;
  157.54 -
  157.55 -public:
  157.56 -  virtual ~Window();
  157.57 -
  157.58 -  inline static Window * poGetInstance() { return m_poInstance; }
  157.59 -
  157.60 -  enum ECartridge
  157.61 -  {
  157.62 -    CartridgeNone,
  157.63 -    CartridgeGB,
  157.64 -    CartridgeGBA
  157.65 -  };
  157.66 -
  157.67 -  // GB/GBA screen sizes
  157.68 -  const int m_iGBScreenWidth;
  157.69 -  const int m_iGBScreenHeight;
  157.70 -  const int m_iSGBScreenWidth;
  157.71 -  const int m_iSGBScreenHeight;
  157.72 -  const int m_iGBAScreenWidth;
  157.73 -  const int m_iGBAScreenHeight;
  157.74 -
  157.75 -  bool bLoadROM(const std::string & _rsFile);
  157.76 -  void vPopupError(const char * _csFormat, ...);
  157.77 -  void vPopupErrorV(const char * _csFormat, va_list _args);
  157.78 -  void vDrawScreen();
  157.79 -  void vComputeFrameskip(int _iRate);
  157.80 -  void vShowSpeed(int _iSpeed);
  157.81 -  void vCaptureScreen(int _iNum);
  157.82 -  u32  uiReadJoypad();
  157.83 -
  157.84 -  inline ECartridge eGetCartridge() const { return m_eCartridge; }
  157.85 -  inline int        iGetThrottle()  const { return m_iThrottle; }
  157.86 -
  157.87 -protected:
  157.88 -  Window(GtkWindow * _pstWindow,
  157.89 -         const Glib::RefPtr<Gnome::Glade::Xml> & _poXml);
  157.90 -
  157.91 -  enum EShowSpeed
  157.92 -  {
  157.93 -    ShowNone,
  157.94 -    ShowPercentage,
  157.95 -    ShowDetailed
  157.96 -  };
  157.97 -
  157.98 -  enum ESaveType
  157.99 -  {
 157.100 -    SaveAuto,
 157.101 -    SaveEEPROM,
 157.102 -    SaveSRAM,
 157.103 -    SaveFlash,
 157.104 -    SaveEEPROMSensor,
 157.105 -    SaveNone
 157.106 -  };
 157.107 -
 157.108 -  enum ESoundStatus
 157.109 -  {
 157.110 -    SoundOff,
 157.111 -    SoundMute,
 157.112 -    SoundOn
 157.113 -  };
 157.114 -
 157.115 -  enum ESoundQuality
 157.116 -  {
 157.117 -    Sound44K = 1,
 157.118 -    Sound22K = 2,
 157.119 -    Sound11K = 4
 157.120 -  };
 157.121 -
 157.122 -  enum ESoundVolume
 157.123 -  {
 157.124 -    Sound100,
 157.125 -    Sound200,
 157.126 -    Sound300,
 157.127 -    Sound400,
 157.128 -    Sound25,
 157.129 -    Sound50
 157.130 -  };
 157.131 -
 157.132 -  enum EEmulatorType
 157.133 -  {
 157.134 -    EmulatorAuto,
 157.135 -    EmulatorCGB,
 157.136 -    EmulatorSGB,
 157.137 -    EmulatorGB,
 157.138 -    EmulatorGBA,
 157.139 -    EmulatorSGB2
 157.140 -  };
 157.141 -
 157.142 -  virtual void vOnFileOpen();
 157.143 -  virtual void vOnFileLoad();
 157.144 -  virtual void vOnFileSave();
 157.145 -  virtual void vOnLoadGameMostRecent();
 157.146 -  virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI);
 157.147 -  virtual void vOnLoadGame(int _iSlot);
 157.148 -  virtual void vOnSaveGameOldest();
 157.149 -  virtual void vOnSaveGame(int _iSlot);
 157.150 -  virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI);
 157.151 -  virtual void vOnFileReset();
 157.152 -  virtual void vOnRecentReset();
 157.153 -  virtual void vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI);
 157.154 -  virtual void vOnRecentFile(std::string _sFile);
 157.155 -  virtual void vOnImportBatteryFile();
 157.156 -  virtual void vOnExportBatteryFile();
 157.157 -  virtual void vOnFileScreenCapture();
 157.158 -  virtual void vOnFileClose();
 157.159 -  virtual void vOnFileExit();
 157.160 -  virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue);
 157.161 -  virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent);
 157.162 -  virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI);
 157.163 -  virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale);
 157.164 -  virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer);
 157.165 -  virtual void vOnDirectories();
 157.166 -  virtual void vOnDirectoryReset(Gtk::Entry * _poEntry);
 157.167 -  virtual void vOnDirectorySelect(Gtk::Entry * _poEntry);
 157.168 -  virtual void vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI);
 157.169 -  virtual void vOnSelectBios();
 157.170 -  virtual void vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI);
 157.171 -  virtual void vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed);
 157.172 -  virtual void vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType);
 157.173 -  virtual void vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize);
 157.174 -  virtual void vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat);
 157.175 -  virtual void vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus);
 157.176 -  virtual void vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI);
 157.177 -  virtual void vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI);
 157.178 -  virtual void vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI);
 157.179 -  virtual void vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel);
 157.180 -  virtual void vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality);
 157.181 -  virtual void vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume);
 157.182 -  virtual void vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI);
 157.183 -  virtual void vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI);
 157.184 -  virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType);
 157.185 -  virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
 157.186 -  virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
 157.187 -#ifdef MMX
 157.188 -  virtual void vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI);
 157.189 -#endif // MMX
 157.190 -  virtual void vOnJoypadConfigure(int _iJoypad);
 157.191 -  virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad);
 157.192 -  virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag);
 157.193 -  virtual void vOnGDBWait();
 157.194 -  virtual void vOnGDBLoadAndWait();
 157.195 -  virtual void vOnGDBBreak();
 157.196 -  virtual void vOnGDBDisconnect();
 157.197 -  virtual void vOnHelpAbout();
 157.198 -  virtual bool bOnEmuIdle();
 157.199 -
 157.200 -  virtual bool on_focus_in_event(GdkEventFocus * _pstEvent);
 157.201 -  virtual bool on_focus_out_event(GdkEventFocus * _pstEvent);
 157.202 -  virtual bool on_key_press_event(GdkEventKey * _pstEvent);
 157.203 -  virtual bool on_key_release_event(GdkEventKey * _pstEvent);
 157.204 -
 157.205 -private:
 157.206 -  // Config limits
 157.207 -  const int m_iFrameskipMin;
 157.208 -  const int m_iFrameskipMax;
 157.209 -  const int m_iThrottleMin;
 157.210 -  const int m_iThrottleMax;
 157.211 -  const int m_iScaleMin;
 157.212 -  const int m_iScaleMax;
 157.213 -  const int m_iShowSpeedMin;
 157.214 -  const int m_iShowSpeedMax;
 157.215 -  const int m_iSaveTypeMin;
 157.216 -  const int m_iSaveTypeMax;
 157.217 -  const int m_iSoundQualityMin;
 157.218 -  const int m_iSoundQualityMax;
 157.219 -  const int m_iSoundVolumeMin;
 157.220 -  const int m_iSoundVolumeMax;
 157.221 -  const int m_iEmulatorTypeMin;
 157.222 -  const int m_iEmulatorTypeMax;
 157.223 -  const int m_iFilter2xMin;
 157.224 -  const int m_iFilter2xMax;
 157.225 -  const int m_iFilterIBMin;
 157.226 -  const int m_iFilterIBMax;
 157.227 -  const int m_iJoypadMin;
 157.228 -  const int m_iJoypadMax;
 157.229 -
 157.230 -  static Window * m_poInstance;
 157.231 -
 157.232 -  Glib::RefPtr<Gnome::Glade::Xml> m_poXml;
 157.233 -
 157.234 -  std::string       m_sUserDataDir;
 157.235 -  std::string       m_sConfigFile;
 157.236 -  Config::File      m_oConfig;
 157.237 -  Config::Section * m_poHistoryConfig;
 157.238 -  Config::Section * m_poDirConfig;
 157.239 -  Config::Section * m_poCoreConfig;
 157.240 -  Config::Section * m_poDisplayConfig;
 157.241 -  Config::Section * m_poSoundConfig;
 157.242 -  Config::Section * m_poInputConfig;
 157.243 -
 157.244 -#ifdef GTKMM20
 157.245 -  Gtk::FileSelection * m_poFileOpenDialog;
 157.246 -#else // ! GTKMM20
 157.247 -  Gtk::FileChooserDialog * m_poFileOpenDialog;
 157.248 -#endif // ! GTKMM20
 157.249 -  ScreenArea *         m_poScreenArea;
 157.250 -  Gtk::Menu *          m_poRecentMenu;
 157.251 -  Gtk::MenuItem *      m_poRecentResetItem;
 157.252 -  Gtk::CheckMenuItem * m_poFilePauseItem;
 157.253 -  Gtk::CheckMenuItem * m_poUseBiosItem;
 157.254 -  Gtk::CheckMenuItem * m_poSoundOffItem;
 157.255 -
 157.256 -  struct SGameSlot
 157.257 -  {
 157.258 -    bool        m_bEmpty;
 157.259 -    std::string m_sFile;
 157.260 -    time_t      m_uiTime;
 157.261 -  };
 157.262 -
 157.263 -  Gtk::MenuItem * m_apoLoadGameItem[10];
 157.264 -  Gtk::MenuItem * m_apoSaveGameItem[10];
 157.265 -  SGameSlot       m_astGameSlot[10];
 157.266 -
 157.267 -  std::list<std::string> m_listHistory;
 157.268 -
 157.269 -  std::list<Gtk::Widget *> m_listSensitiveWhenPlaying;
 157.270 -
 157.271 -  Gtk::Tooltips m_oTooltips;
 157.272 -
 157.273 -  SigC::connection m_oEmuSig;
 157.274 -
 157.275 -  std::vector<JoypadConfig> m_oJoypads;
 157.276 -  Keymap * m_poKeymap;
 157.277 -
 157.278 -  int m_iScreenWidth;
 157.279 -  int m_iScreenHeight;
 157.280 -
 157.281 -  std::string    m_sRomFile;
 157.282 -  ECartridge     m_eCartridge;
 157.283 -  EmulatedSystem m_stEmulator;
 157.284 -  u32            m_uiJoypadState;
 157.285 -  u32            m_uiAutofireState;
 157.286 -  bool           m_bAutofireToggle;
 157.287 -  bool           m_bPaused;
 157.288 -  bool           m_bWasEmulating;
 157.289 -  bool           m_bAutoFrameskip;
 157.290 -  int            m_iThrottle;
 157.291 -  u32            m_uiThrottleLastTime;
 157.292 -  u32            m_uiThrottleDelay;
 157.293 -  EShowSpeed     m_eShowSpeed;
 157.294 -  ESoundQuality  m_eSoundQuality;
 157.295 -
 157.296 -  void vInitSystem();
 157.297 -  void vInitSDL();
 157.298 -  void vInitConfig();
 157.299 -  void vCheckConfig();
 157.300 -  void vLoadConfig(const std::string & _rsFile);
 157.301 -  void vSaveConfig(const std::string & _rsFile);
 157.302 -  void vLoadHistoryFromConfig();
 157.303 -  void vSaveHistoryToConfig();
 157.304 -  void vHistoryAdd(const std::string & _rsFile);
 157.305 -  void vClearHistoryMenu();
 157.306 -  void vUpdateHistoryMenu();
 157.307 -  void vLoadJoypadsFromConfig();
 157.308 -  void vSaveJoypadsToConfig();
 157.309 -  void vUpdateScreen();
 157.310 -  void vDrawDefaultScreen();
 157.311 -  void vSetDefaultTitle();
 157.312 -  void vCreateFileOpenDialog();
 157.313 -  void vLoadBattery();
 157.314 -  void vSaveBattery();
 157.315 -  void vStartEmu();
 157.316 -  void vStopEmu();
 157.317 -  void vSetThrottle(int _iPercent);
 157.318 -  void vSelectBestThrottleItem();
 157.319 -  void vUpdateGameSlots();
 157.320 -};
 157.321 -
 157.322 -} // namespace VBA
 157.323 -
 157.324 -
 157.325 -#endif // __VBA_WINDOW_H__
   158.1 --- a/src/gtk/windowcallbacks.cpp	Sat Mar 03 10:54:39 2012 -0600
   158.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   158.3 @@ -1,1582 +0,0 @@
   158.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   158.5 -// Copyright (C) 1999-2003 Forgotten
   158.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   158.7 -
   158.8 -// This program is free software; you can redistribute it and/or modify
   158.9 -// it under the terms of the GNU General Public License as published by
  158.10 -// the Free Software Foundation; either version 2, or(at your option)
  158.11 -// any later version.
  158.12 -//
  158.13 -// This program is distributed in the hope that it will be useful,
  158.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  158.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  158.16 -// GNU General Public License for more details.
  158.17 -//
  158.18 -// You should have received a copy of the GNU General Public License
  158.19 -// along with this program; if not, write to the Free Software Foundation,
  158.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  158.21 -
  158.22 -#include "window.h"
  158.23 -
  158.24 -#include <sys/stat.h>
  158.25 -
  158.26 -#include <stdio.h>
  158.27 -#include <time.h>
  158.28 -
  158.29 -#include <SDL.h>
  158.30 -
  158.31 -#include "../gba/GBA.h"
  158.32 -#include "../gba/GBAGlobals.h"
  158.33 -#include "../gba/Flash.h"
  158.34 -#include "../gba/GBASound.h"
  158.35 -#include "../gb/GB.h"
  158.36 -#include "../gb/gbGlobals.h"
  158.37 -#include "../gb/gbPrinter.h"
  158.38 -#include "../common/Util.h"
  158.39 -
  158.40 -#include "tools.h"
  158.41 -#include "intl.h"
  158.42 -
  158.43 -extern int systemRenderedFrames;
  158.44 -extern int systemFPS;
  158.45 -extern bool debugger;
  158.46 -extern int RGB_LOW_BITS_MASK;
  158.47 -extern void (*dbgMain)();
  158.48 -extern void (*dbgSignal)(int, int);
  158.49 -extern void (*dbgOutput)(char *, u32);
  158.50 -extern void remoteInit();
  158.51 -extern void remoteCleanUp();
  158.52 -extern void remoteStubMain();
  158.53 -extern void remoteStubSignal(int, int);
  158.54 -extern void remoteOutput(char *, u32);
  158.55 -extern void remoteSetProtocol(int);
  158.56 -extern void remoteSetPort(int);
  158.57 -
  158.58 -#ifdef MMX
  158.59 -extern "C" bool cpu_mmx;
  158.60 -#endif // MMX
  158.61 -
  158.62 -namespace VBA
  158.63 -{
  158.64 -
  158.65 -using Gnome::Glade::Xml;
  158.66 -
  158.67 -void Window::vOnFileOpen()
  158.68 -{
  158.69 -  while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK)
  158.70 -  {
  158.71 -    if (bLoadROM(m_poFileOpenDialog->get_filename()))
  158.72 -    {
  158.73 -      break;
  158.74 -    }
  158.75 -  }
  158.76 -  m_poFileOpenDialog->hide();
  158.77 -}
  158.78 -
  158.79 -void Window::vOnFileLoad()
  158.80 -{
  158.81 -  std::string sSaveDir = m_poDirConfig->sGetKey("saves");
  158.82 -
  158.83 -#ifdef GTKMM20
  158.84 -
  158.85 -  Gtk::FileSelection oDialog(_("Load game"));
  158.86 -  oDialog.set_transient_for(*this);
  158.87 -
  158.88 -  if (sSaveDir == "")
  158.89 -  {
  158.90 -    oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/");
  158.91 -  }
  158.92 -  else
  158.93 -  {
  158.94 -    oDialog.set_filename(sSaveDir + "/");
  158.95 -  }
  158.96 -
  158.97 -#else // ! GTKMM20
  158.98 -
  158.99 -  Gtk::FileChooserDialog oDialog(*this, _("Load game"));
 158.100 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.101 -  oDialog.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
 158.102 -
 158.103 -  if (sSaveDir == "")
 158.104 -  {
 158.105 -    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
 158.106 -  }
 158.107 -  else
 158.108 -  {
 158.109 -    oDialog.set_current_folder(sSaveDir);
 158.110 -    oDialog.add_shortcut_folder(sSaveDir);
 158.111 -  }
 158.112 -
 158.113 -  Gtk::FileFilter oSaveFilter;
 158.114 -  oSaveFilter.set_name(_("VisualBoyAdvance save game"));
 158.115 -  oSaveFilter.add_pattern("*.[sS][gG][mM]");
 158.116 -
 158.117 -  oDialog.add_filter(oSaveFilter);
 158.118 -
 158.119 -#endif // ! GTKMM20
 158.120 -
 158.121 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.122 -  {
 158.123 -    if (m_stEmulator.emuReadState(oDialog.get_filename().c_str()))
 158.124 -    {
 158.125 -      break;
 158.126 -    }
 158.127 -  }
 158.128 -}
 158.129 -
 158.130 -void Window::vOnFileSave()
 158.131 -{
 158.132 -  Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves");
 158.133 -
 158.134 -#ifdef GTKMM20
 158.135 -
 158.136 -  Gtk::FileSelection oDialog(_("Save game"));
 158.137 -  oDialog.set_transient_for(*this);
 158.138 -
 158.139 -  if (sSaveDir == "")
 158.140 -  {
 158.141 -    oDialog.set_filename(sCutSuffix(m_sRomFile));
 158.142 -  }
 158.143 -  else
 158.144 -  {
 158.145 -    oDialog.set_filename(sSaveDir + "/" +
 158.146 -                         sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.147 -  }
 158.148 -
 158.149 -#else // ! GTKMM20
 158.150 -
 158.151 -  Gtk::FileChooserDialog oDialog(*this, _("Save game"),
 158.152 -                                 Gtk::FILE_CHOOSER_ACTION_SAVE);
 158.153 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.154 -  oDialog.add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK);
 158.155 -
 158.156 -  if (sSaveDir == "")
 158.157 -  {
 158.158 -    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
 158.159 -  }
 158.160 -  else
 158.161 -  {
 158.162 -    oDialog.set_current_folder(sSaveDir);
 158.163 -    oDialog.add_shortcut_folder(sSaveDir);
 158.164 -  }
 158.165 -  oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.166 -
 158.167 -  Gtk::FileFilter oSaveFilter;
 158.168 -  oSaveFilter.set_name(_("VisualBoyAdvance save game"));
 158.169 -  oSaveFilter.add_pattern("*.[sS][gG][mM]");
 158.170 -
 158.171 -  oDialog.add_filter(oSaveFilter);
 158.172 -
 158.173 -#endif // ! GTKMM20
 158.174 -
 158.175 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.176 -  {
 158.177 -    Glib::ustring sFile = oDialog.get_filename();
 158.178 -    if (! bHasSuffix(sFile, ".sgm", false))
 158.179 -    {
 158.180 -      sFile += ".sgm";
 158.181 -    }
 158.182 -
 158.183 -    if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
 158.184 -    {
 158.185 -      Gtk::MessageDialog oConfirmDialog(*this,
 158.186 -                                        _("File already exists. Overwrite it?"),
 158.187 -#ifndef GTKMM20
 158.188 -                                        false,
 158.189 -#endif // ! GTKMM20
 158.190 -                                        Gtk::MESSAGE_QUESTION,
 158.191 -                                        Gtk::BUTTONS_YES_NO);
 158.192 -      if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
 158.193 -      {
 158.194 -        continue;
 158.195 -      }
 158.196 -    }
 158.197 -
 158.198 -    if (m_stEmulator.emuWriteState(sFile.c_str()))
 158.199 -    {
 158.200 -      break;
 158.201 -    }
 158.202 -  }
 158.203 -}
 158.204 -
 158.205 -void Window::vOnLoadGameMostRecent()
 158.206 -{
 158.207 -  int    iMostRecent = -1;
 158.208 -  time_t uiTimeMax;
 158.209 -
 158.210 -  for (int i = 0; i < 10; i++)
 158.211 -  {
 158.212 -    if (! m_astGameSlot[i].m_bEmpty
 158.213 -        && (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax))
 158.214 -    {
 158.215 -      iMostRecent = i;
 158.216 -      uiTimeMax = m_astGameSlot[i].m_uiTime;
 158.217 -    }
 158.218 -  }
 158.219 -
 158.220 -  if (iMostRecent >= 0)
 158.221 -  {
 158.222 -    vOnLoadGame(iMostRecent + 1);
 158.223 -  }
 158.224 -}
 158.225 -
 158.226 -void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI)
 158.227 -{
 158.228 -  m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active());
 158.229 -}
 158.230 -
 158.231 -void Window::vOnLoadGame(int _iSlot)
 158.232 -{
 158.233 -  int i = _iSlot - 1;
 158.234 -  if (! m_astGameSlot[i].m_bEmpty)
 158.235 -  {
 158.236 -    m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
 158.237 -    m_poFilePauseItem->set_active(false);
 158.238 -  }
 158.239 -}
 158.240 -
 158.241 -void Window::vOnSaveGameOldest()
 158.242 -{
 158.243 -  int    iOldest = -1;
 158.244 -  time_t uiTimeMin;
 158.245 -
 158.246 -  for (int i = 0; i < 10; i++)
 158.247 -  {
 158.248 -    if (! m_astGameSlot[i].m_bEmpty
 158.249 -        && (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin))
 158.250 -    {
 158.251 -      iOldest = i;
 158.252 -      uiTimeMin = m_astGameSlot[i].m_uiTime;
 158.253 -    }
 158.254 -  }
 158.255 -
 158.256 -  if (iOldest >= 0)
 158.257 -  {
 158.258 -    vOnSaveGame(iOldest + 1);
 158.259 -  }
 158.260 -  else
 158.261 -  {
 158.262 -    vOnSaveGame(1);
 158.263 -  }
 158.264 -}
 158.265 -
 158.266 -void Window::vOnSaveGame(int _iSlot)
 158.267 -{
 158.268 -  int i = _iSlot - 1;
 158.269 -  m_stEmulator.emuWriteState(m_astGameSlot[i].m_sFile.c_str());
 158.270 -  vUpdateGameSlots();
 158.271 -}
 158.272 -
 158.273 -void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI)
 158.274 -{
 158.275 -  m_bPaused = _poCMI->get_active();
 158.276 -  if (emulating)
 158.277 -  {
 158.278 -    if (m_bPaused)
 158.279 -    {
 158.280 -      vStopEmu();
 158.281 -      soundPause();
 158.282 -    }
 158.283 -    else
 158.284 -    {
 158.285 -      vStartEmu();
 158.286 -      soundResume();
 158.287 -    }
 158.288 -  }
 158.289 -}
 158.290 -
 158.291 -void Window::vOnFileReset()
 158.292 -{
 158.293 -  if (emulating)
 158.294 -  {
 158.295 -    m_stEmulator.emuReset(true);
 158.296 -    m_poFilePauseItem->set_active(false);
 158.297 -  }
 158.298 -}
 158.299 -
 158.300 -void Window::vOnRecentReset()
 158.301 -{
 158.302 -  m_listHistory.clear();
 158.303 -  vClearHistoryMenu();
 158.304 -}
 158.305 -
 158.306 -void Window::vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI)
 158.307 -{
 158.308 -  m_poRecentResetItem->set_sensitive(! _poCMI->get_active());
 158.309 -  m_poHistoryConfig->vSetKey("freeze", _poCMI->get_active());
 158.310 -}
 158.311 -
 158.312 -void Window::vOnRecentFile(std::string _sFile)
 158.313 -{
 158.314 -  bLoadROM(_sFile);
 158.315 -}
 158.316 -
 158.317 -void Window::vOnImportBatteryFile()
 158.318 -{
 158.319 -  std::string BatteryDir = m_poDirConfig->sGetKey("batteries");
 158.320 -
 158.321 -#ifdef GTKMM20
 158.322 -
 158.323 -  Gtk::FileSelection oDialog(_("Import battery file"));
 158.324 -  oDialog.set_transient_for(*this);
 158.325 -
 158.326 -  if (BatteryDir == "")
 158.327 -  {
 158.328 -    oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/");
 158.329 -  }
 158.330 -  else
 158.331 -  {
 158.332 -    oDialog.set_filename(BatteryDir + "/");
 158.333 -  }
 158.334 -
 158.335 -#else // ! GTKMM20
 158.336 -
 158.337 -  Gtk::FileChooserDialog oDialog(*this, _("Import battery file"));
 158.338 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.339 -  oDialog.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
 158.340 -
 158.341 -  if (BatteryDir == "")
 158.342 -  {
 158.343 -    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
 158.344 -  }
 158.345 -  else
 158.346 -  {
 158.347 -    oDialog.set_current_folder(BatteryDir);
 158.348 -    oDialog.add_shortcut_folder(BatteryDir);
 158.349 -  }
 158.350 -
 158.351 -  Gtk::FileFilter oBatteryFilter;
 158.352 -  oBatteryFilter.set_name(_("Battery file"));
 158.353 -  oBatteryFilter.add_pattern("*.[sS][aA][vV]");
 158.354 -
 158.355 -  Gtk::FileFilter oFlashFilter;
 158.356 -  oFlashFilter.set_name(_("Flash save"));
 158.357 -  oFlashFilter.add_pattern("*.[dD][aA][tT]");
 158.358 -
 158.359 -  oDialog.add_filter(oBatteryFilter);
 158.360 -  oDialog.add_filter(oFlashFilter);
 158.361 -
 158.362 -#endif // ! GTKMM20
 158.363 -
 158.364 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.365 -  {
 158.366 -    Gtk::MessageDialog oConfirmDialog(*this,
 158.367 -                                      _("Importing a battery file will erase any saved games and reset the emulator. Do you want to continue?"),
 158.368 -#ifndef GTKMM20
 158.369 -                                      false,
 158.370 -#endif // ! GTKMM20
 158.371 -                                      Gtk::MESSAGE_QUESTION,
 158.372 -                                      Gtk::BUTTONS_YES_NO);
 158.373 -    if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
 158.374 -    {
 158.375 -      continue;
 158.376 -    }
 158.377 -
 158.378 -    if (m_stEmulator.emuReadBattery(oDialog.get_filename().c_str()))
 158.379 -    {
 158.380 -      m_stEmulator.emuReset(false);
 158.381 -      break;
 158.382 -    }
 158.383 -    else
 158.384 -    {
 158.385 -      vPopupError(_("Failed to import battery file %s."),
 158.386 -                  oDialog.get_filename().c_str());
 158.387 -    }
 158.388 -  }
 158.389 -}
 158.390 -
 158.391 -void Window::vOnExportBatteryFile()
 158.392 -{
 158.393 -  std::string sBatteryDir = m_poDirConfig->sGetKey("batteries");
 158.394 -
 158.395 -#ifdef GTKMM20
 158.396 -
 158.397 -  Gtk::FileSelection oDialog(_("Export battery file"));
 158.398 -  oDialog.set_transient_for(*this);
 158.399 -
 158.400 -  if (sBatteryDir == "")
 158.401 -  {
 158.402 -    oDialog.set_filename(sCutSuffix(m_sRomFile));
 158.403 -  }
 158.404 -  else
 158.405 -  {
 158.406 -    oDialog.set_filename(sBatteryDir + "/" +
 158.407 -                         sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.408 -  }
 158.409 -
 158.410 -#else // ! GTKMM20
 158.411 -
 158.412 -  Gtk::FileChooserDialog oDialog(*this, _("Export battery file"),
 158.413 -                                 Gtk::FILE_CHOOSER_ACTION_SAVE);
 158.414 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.415 -  oDialog.add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK);
 158.416 -
 158.417 -  if (sBatteryDir == "")
 158.418 -  {
 158.419 -    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
 158.420 -  }
 158.421 -  else
 158.422 -  {
 158.423 -    oDialog.set_current_folder(sBatteryDir);
 158.424 -    oDialog.add_shortcut_folder(sBatteryDir);
 158.425 -  }
 158.426 -  oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.427 -
 158.428 -  Gtk::FileFilter oBatteryFilter;
 158.429 -  oBatteryFilter.set_name(_("Battery file"));
 158.430 -  oBatteryFilter.add_pattern("*.[sS][aA][vV]");
 158.431 -
 158.432 -  Gtk::FileFilter oFlashFilter;
 158.433 -  oFlashFilter.set_name(_("Flash save"));
 158.434 -  oFlashFilter.add_pattern("*.[dD][aA][tT]");
 158.435 -
 158.436 -  oDialog.add_filter(oBatteryFilter);
 158.437 -  oDialog.add_filter(oFlashFilter);
 158.438 -
 158.439 -#endif // ! GTKMM20
 158.440 -
 158.441 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.442 -  {
 158.443 -    Glib::ustring sFile = oDialog.get_filename();
 158.444 -    Glib::ustring sExt;
 158.445 -
 158.446 -#ifdef GTKMM20
 158.447 -
 158.448 -    sExt = ".sav";
 158.449 -
 158.450 -#else // ! GTKMM20
 158.451 -
 158.452 -    if (oDialog.get_filter() == &oBatteryFilter)
 158.453 -    {
 158.454 -      sExt = ".sav";
 158.455 -    }
 158.456 -    else
 158.457 -    {
 158.458 -      sExt = ".dat";
 158.459 -    }
 158.460 -
 158.461 -#endif // ! GTKMM20
 158.462 -
 158.463 -    if (! bHasSuffix(sFile, sExt, false))
 158.464 -    {
 158.465 -      sFile += sExt;
 158.466 -    }
 158.467 -
 158.468 -    if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
 158.469 -    {
 158.470 -      Gtk::MessageDialog oConfirmDialog(*this,
 158.471 -                                        _("File already exists. Overwrite it?"),
 158.472 -#ifndef GTKMM20
 158.473 -                                        false,
 158.474 -#endif // ! GTKMM20
 158.475 -                                        Gtk::MESSAGE_QUESTION,
 158.476 -                                        Gtk::BUTTONS_YES_NO);
 158.477 -      if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
 158.478 -      {
 158.479 -        continue;
 158.480 -      }
 158.481 -    }
 158.482 -
 158.483 -    bool bResult;
 158.484 -    if (m_eCartridge == CartridgeGB)
 158.485 -    {
 158.486 -      bResult = gbWriteBatteryFile(sFile.c_str(), false);
 158.487 -    }
 158.488 -    else
 158.489 -    {
 158.490 -      bResult = m_stEmulator.emuWriteBattery(sFile.c_str());
 158.491 -    }
 158.492 -
 158.493 -    if (bResult)
 158.494 -    {
 158.495 -      break;
 158.496 -    }
 158.497 -    else
 158.498 -    {
 158.499 -      vPopupError(_("Failed to export battery file %s."),
 158.500 -                  sFile.c_str());
 158.501 -    }
 158.502 -  }
 158.503 -}
 158.504 -
 158.505 -void Window::vOnFileScreenCapture()
 158.506 -{
 158.507 -  std::string sCaptureDir = m_poDirConfig->sGetKey("captures");
 158.508 -
 158.509 -#ifdef GTKMM20
 158.510 -
 158.511 -  Gtk::FileSelection oDialog(_("Save screenshot"));
 158.512 -  oDialog.set_transient_for(*this);
 158.513 -
 158.514 -  if (sCaptureDir == "")
 158.515 -  {
 158.516 -    oDialog.set_filename(sCutSuffix(m_sRomFile));
 158.517 -  }
 158.518 -  else
 158.519 -  {
 158.520 -    oDialog.set_filename(sCaptureDir + "/" +
 158.521 -                         sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.522 -  }
 158.523 -
 158.524 -#else // ! GTKMM20
 158.525 -
 158.526 -  Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"),
 158.527 -                                 Gtk::FILE_CHOOSER_ACTION_SAVE);
 158.528 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.529 -  oDialog.add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK);
 158.530 -
 158.531 -  if (sCaptureDir == "")
 158.532 -  {
 158.533 -    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
 158.534 -  }
 158.535 -  else
 158.536 -  {
 158.537 -    oDialog.set_current_folder(sCaptureDir);
 158.538 -    oDialog.add_shortcut_folder(sCaptureDir);
 158.539 -  }
 158.540 -  oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
 158.541 -
 158.542 -  Gtk::FileFilter oPngFilter;
 158.543 -  oPngFilter.set_name(_("PNG image"));
 158.544 -  oPngFilter.add_pattern("*.[pP][nN][gG]");
 158.545 -
 158.546 -  Gtk::FileFilter oBmpFilter;
 158.547 -  oBmpFilter.set_name(_("BMP image"));
 158.548 -  oBmpFilter.add_pattern("*.[bB][mM][pP]");
 158.549 -
 158.550 -  oDialog.add_filter(oPngFilter);
 158.551 -  oDialog.add_filter(oBmpFilter);
 158.552 -
 158.553 -  if (m_poCoreConfig->sGetKey("screenshot_format") == "bmp")
 158.554 -  {
 158.555 -    oDialog.set_filter(oBmpFilter);
 158.556 -  }
 158.557 -
 158.558 -#endif // ! GTKMM20
 158.559 -
 158.560 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.561 -  {
 158.562 -    Glib::ustring sFile = oDialog.get_filename();
 158.563 -    Glib::ustring sExt;
 158.564 -
 158.565 -#ifdef GTKMM20
 158.566 -
 158.567 -    sExt = "." + m_poCoreConfig->sGetKey("screenshot_format");
 158.568 -
 158.569 -#else // ! GTKMM20
 158.570 -
 158.571 -    if (oDialog.get_filter() == &oPngFilter)
 158.572 -    {
 158.573 -      sExt = ".png";
 158.574 -    }
 158.575 -    else
 158.576 -    {
 158.577 -      sExt = ".bmp";
 158.578 -    }
 158.579 -
 158.580 -#endif // ! GTKMM20
 158.581 -
 158.582 -    if (! bHasSuffix(sFile, sExt, false))
 158.583 -    {
 158.584 -      sFile += sExt;
 158.585 -    }
 158.586 -
 158.587 -    if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
 158.588 -    {
 158.589 -      Gtk::MessageDialog oConfirmDialog(*this,
 158.590 -                                        _("File already exists. Overwrite it?"),
 158.591 -#ifndef GTKMM20
 158.592 -                                        false,
 158.593 -#endif // ! GTKMM20
 158.594 -                                        Gtk::MESSAGE_QUESTION,
 158.595 -                                        Gtk::BUTTONS_YES_NO);
 158.596 -      if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
 158.597 -      {
 158.598 -        continue;
 158.599 -      }
 158.600 -    }
 158.601 -
 158.602 -    bool bResult;
 158.603 -    if (sExt == ".png")
 158.604 -    {
 158.605 -      bResult = m_stEmulator.emuWritePNG(sFile.c_str());
 158.606 -    }
 158.607 -    else
 158.608 -    {
 158.609 -      bResult = m_stEmulator.emuWriteBMP(sFile.c_str());
 158.610 -    }
 158.611 -
 158.612 -    if (bResult)
 158.613 -    {
 158.614 -      break;
 158.615 -    }
 158.616 -  }
 158.617 -}
 158.618 -
 158.619 -void Window::vOnFileClose()
 158.620 -{
 158.621 -  if (m_eCartridge != CartridgeNone)
 158.622 -  {
 158.623 -    soundPause();
 158.624 -    vStopEmu();
 158.625 -    vSetDefaultTitle();
 158.626 -    vDrawDefaultScreen();
 158.627 -    vSaveBattery();
 158.628 -    m_stEmulator.emuCleanUp();
 158.629 -    m_eCartridge = CartridgeNone;
 158.630 -    emulating = 0;
 158.631 -
 158.632 -    vUpdateGameSlots();
 158.633 -
 158.634 -    for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
 158.635 -         it != m_listSensitiveWhenPlaying.end();
 158.636 -         it++)
 158.637 -    {
 158.638 -      (*it)->set_sensitive(false);
 158.639 -    }
 158.640 -
 158.641 -    m_poFilePauseItem->set_active(false);
 158.642 -  }
 158.643 -}
 158.644 -
 158.645 -void Window::vOnFileExit()
 158.646 -{
 158.647 -  hide();
 158.648 -}
 158.649 -
 158.650 -void Window::vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue)
 158.651 -{
 158.652 -  if (! _poCMI->get_active())
 158.653 -  {
 158.654 -    return;
 158.655 -  }
 158.656 -
 158.657 -  if (_iValue >= 0 && _iValue <= 9)
 158.658 -  {
 158.659 -    m_poCoreConfig->vSetKey("frameskip", _iValue);
 158.660 -    gbFrameSkip      = _iValue;
 158.661 -    systemFrameSkip  = _iValue;
 158.662 -    m_bAutoFrameskip = false;
 158.663 -  }
 158.664 -  else
 158.665 -  {
 158.666 -    m_poCoreConfig->vSetKey("frameskip", "auto");
 158.667 -    gbFrameSkip      = 0;
 158.668 -    systemFrameSkip  = 0;
 158.669 -    m_bAutoFrameskip = true;
 158.670 -  }
 158.671 -}
 158.672 -
 158.673 -void Window::vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent)
 158.674 -{
 158.675 -  if (! _poCMI->get_active())
 158.676 -  {
 158.677 -    return;
 158.678 -  }
 158.679 -
 158.680 -  vSetThrottle(_iPercent);
 158.681 -
 158.682 -  // Initialize the frameskip adjustment each time throttle is changed
 158.683 -  if (m_bAutoFrameskip)
 158.684 -  {
 158.685 -    systemFrameSkip = 0;
 158.686 -  }
 158.687 -}
 158.688 -
 158.689 -void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI)
 158.690 -{
 158.691 -  if (! _poCMI->get_active())
 158.692 -  {
 158.693 -    return;
 158.694 -  }
 158.695 -
 158.696 -  Glib::RefPtr<Xml> poXml;
 158.697 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "ThrottleDialog");
 158.698 -
 158.699 -  Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("ThrottleDialog"));
 158.700 -  Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("ThrottleSpin"));
 158.701 -
 158.702 -  poDialog->set_transient_for(*this);
 158.703 -
 158.704 -  if (m_iThrottle != 0)
 158.705 -  {
 158.706 -    poSpin->set_value(m_iThrottle);
 158.707 -  }
 158.708 -  else
 158.709 -  {
 158.710 -    poSpin->set_value(100);
 158.711 -  }
 158.712 -
 158.713 -  if (poDialog->run() == Gtk::RESPONSE_OK)
 158.714 -  {
 158.715 -    vSetThrottle(poSpin->get_value_as_int());
 158.716 -  }
 158.717 -
 158.718 -  delete poDialog;
 158.719 -  vSelectBestThrottleItem();
 158.720 -}
 158.721 -
 158.722 -void Window::vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale)
 158.723 -{
 158.724 -  if (! _poCMI->get_active())
 158.725 -  {
 158.726 -    return;
 158.727 -  }
 158.728 -
 158.729 -  m_poDisplayConfig->vSetKey("scale", _iScale);
 158.730 -  vUpdateScreen();
 158.731 -}
 158.732 -
 158.733 -void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer)
 158.734 -{
 158.735 -  int iMask = (0x0100 << _iLayer);
 158.736 -  if (_poCMI->get_active())
 158.737 -  {
 158.738 -    layerSettings |= iMask;
 158.739 -  }
 158.740 -  else
 158.741 -  {
 158.742 -    layerSettings &= ~iMask;
 158.743 -  }
 158.744 -  layerEnable = DISPCNT & layerSettings;
 158.745 -
 158.746 -  const char * acsLayers[] =
 158.747 -  {
 158.748 -    "layer_bg0",
 158.749 -    "layer_bg1",
 158.750 -    "layer_bg2",
 158.751 -    "layer_bg3",
 158.752 -    "layer_obj",
 158.753 -    "layer_win0",
 158.754 -    "layer_win1",
 158.755 -    "layer_objwin"
 158.756 -  };
 158.757 -  m_poCoreConfig->vSetKey(acsLayers[_iLayer], _poCMI->get_active());
 158.758 -}
 158.759 -
 158.760 -void Window::vOnDirectories()
 158.761 -{
 158.762 -  Glib::RefPtr<Xml> poXml;
 158.763 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "DirectoriesDialog");
 158.764 -
 158.765 -  struct
 158.766 -  {
 158.767 -    const char * m_csKey;
 158.768 -    const char * m_csEntry;
 158.769 -    const char * m_csResetButton;
 158.770 -    const char * m_csSelectButton;
 158.771 -  }
 158.772 -  astRow[] =
 158.773 -  {
 158.774 -    { "gba_roms",  "GBARomsDirEntry",   "GBARomsDirResetButton",   "GBARomsDirSelectButton"   },
 158.775 -    { "gb_roms",   "GBRomsDirEntry",    "GBRomsDirResetButton",    "GBRomsDirSelectButton"    },
 158.776 -    { "batteries", "BatteriesDirEntry", "BatteriesDirResetButton", "BatteriesDirSelectButton" },
 158.777 -    { "saves",     "SavesDirEntry",     "SavesDirResetButton",     "SavesDirSelectButton"     },
 158.778 -    { "captures",  "CapturesDirEntry",  "CapturesDirResetButton",  "CapturesDirSelectButton"  }
 158.779 -  };
 158.780 -
 158.781 -  for (guint i = 0; i < G_N_ELEMENTS(astRow); i++)
 158.782 -  {
 158.783 -    Gtk::Entry *  poEntry  = dynamic_cast<Gtk::Entry *>(poXml->get_widget(astRow[i].m_csEntry));
 158.784 -    Gtk::Button * poReset  = dynamic_cast<Gtk::Button *>(poXml->get_widget(astRow[i].m_csResetButton));
 158.785 -    Gtk::Button * poSelect = dynamic_cast<Gtk::Button *>(poXml->get_widget(astRow[i].m_csSelectButton));
 158.786 -
 158.787 -    poEntry->set_text(m_poDirConfig->sGetKey(astRow[i].m_csKey));
 158.788 -
 158.789 -    poReset->signal_clicked().connect(SigC::bind<Gtk::Entry *>(
 158.790 -                                        SigC::slot(*this, &Window::vOnDirectoryReset),
 158.791 -                                        poEntry));
 158.792 -    poSelect->signal_clicked().connect(SigC::bind<Gtk::Entry *>(
 158.793 -                                         SigC::slot(*this, &Window::vOnDirectorySelect),
 158.794 -                                         poEntry));
 158.795 -  }
 158.796 -
 158.797 -  Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("DirectoriesDialog"));
 158.798 -  poDialog->set_transient_for(*this);
 158.799 -
 158.800 -  if (poDialog->run() == Gtk::RESPONSE_OK)
 158.801 -  {
 158.802 -    for (guint i = 0; i < G_N_ELEMENTS(astRow); i++)
 158.803 -    {
 158.804 -      Gtk::Entry * poEntry = dynamic_cast<Gtk::Entry *>(poXml->get_widget(astRow[i].m_csEntry));
 158.805 -      Glib::ustring sDir = poEntry->get_text();
 158.806 -      if (! Glib::file_test(sDir, Glib::FILE_TEST_IS_DIR))
 158.807 -      {
 158.808 -        sDir = "";
 158.809 -      }
 158.810 -      m_poDirConfig->vSetKey(astRow[i].m_csKey, sDir);
 158.811 -    }
 158.812 -
 158.813 -    // Needed if saves dir changed
 158.814 -    vUpdateGameSlots();
 158.815 -  }
 158.816 -
 158.817 -  delete poDialog;
 158.818 -}
 158.819 -
 158.820 -void Window::vOnDirectoryReset(Gtk::Entry * _poEntry)
 158.821 -{
 158.822 -  _poEntry->set_text("");
 158.823 -}
 158.824 -
 158.825 -void Window::vOnDirectorySelect(Gtk::Entry * _poEntry)
 158.826 -{
 158.827 -#ifdef GTKMM20
 158.828 -
 158.829 -  Gtk::FileSelection oDialog(_("Select directory"));
 158.830 -  oDialog.set_transient_for(*this);
 158.831 -
 158.832 -  if (_poEntry->get_text() != "")
 158.833 -  {
 158.834 -    oDialog.set_filename(_poEntry->get_text() + "/");
 158.835 -  }
 158.836 -
 158.837 -  if (oDialog.run() == Gtk::RESPONSE_OK)
 158.838 -  {
 158.839 -    std::string sFile = oDialog.get_filename();
 158.840 -    if (! Glib::file_test(sFile, Glib::FILE_TEST_IS_DIR))
 158.841 -    {
 158.842 -      sFile = Glib::path_get_dirname(sFile);
 158.843 -    }
 158.844 -    _poEntry->set_text(sFile);
 158.845 -  }
 158.846 -
 158.847 -#else // ! GTKMM20
 158.848 -
 158.849 -  Gtk::FileChooserDialog oDialog(*this, _("Select directory"),
 158.850 -                                 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
 158.851 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.852 -  oDialog.add_button(Gtk::Stock::OK,     Gtk::RESPONSE_OK);
 158.853 -
 158.854 -  if (_poEntry->get_text() != "")
 158.855 -  {
 158.856 -    oDialog.add_shortcut_folder(_poEntry->get_text());
 158.857 -    oDialog.set_current_folder(_poEntry->get_text());
 158.858 -  }
 158.859 -
 158.860 -  if (oDialog.run() == Gtk::RESPONSE_OK)
 158.861 -  {
 158.862 -    _poEntry->set_text(oDialog.get_filename());
 158.863 -  }
 158.864 -
 158.865 -#endif // ! GTKMM20
 158.866 -}
 158.867 -
 158.868 -void Window::vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI)
 158.869 -{
 158.870 -  m_poDisplayConfig->vSetKey("pause_when_inactive", _poCMI->get_active());
 158.871 -}
 158.872 -
 158.873 -void Window::vOnSelectBios()
 158.874 -{
 158.875 -#ifdef GTKMM20
 158.876 -
 158.877 -  Gtk::FileSelection oDialog(_("Select BIOS file"));
 158.878 -  oDialog.set_transient_for(*this);
 158.879 -
 158.880 -  if (m_poCoreConfig->sGetKey("bios_file") != "")
 158.881 -  {
 158.882 -    oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file"));
 158.883 -  }
 158.884 -
 158.885 -#else // ! GTKMM20
 158.886 -
 158.887 -  Gtk::FileChooserDialog oDialog(*this, _("Select BIOS file"));
 158.888 -  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 158.889 -  oDialog.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
 158.890 -
 158.891 -  if (m_poCoreConfig->sGetKey("bios_file") != "")
 158.892 -  {
 158.893 -    oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file"));
 158.894 -  }
 158.895 -
 158.896 -  const char * acsPattern[] =
 158.897 -  {
 158.898 -    "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
 158.899 -    "*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
 158.900 -  };
 158.901 -
 158.902 -  Gtk::FileFilter oAllFilter;
 158.903 -  oAllFilter.set_name(_("All files"));
 158.904 -  oAllFilter.add_pattern("*");
 158.905 -
 158.906 -  Gtk::FileFilter oBiosFilter;
 158.907 -  oBiosFilter.set_name(_("Gameboy Advance BIOS"));
 158.908 -  for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
 158.909 -  {
 158.910 -    oBiosFilter.add_pattern(acsPattern[i]);
 158.911 -  }
 158.912 -
 158.913 -  oDialog.add_filter(oAllFilter);
 158.914 -  oDialog.add_filter(oBiosFilter);
 158.915 -
 158.916 -  oDialog.set_filter(oBiosFilter);
 158.917 -
 158.918 -#endif // ! GTKMM20
 158.919 -
 158.920 -  while (oDialog.run() == Gtk::RESPONSE_OK)
 158.921 -  {
 158.922 -    if (Glib::file_test(oDialog.get_filename(), Glib::FILE_TEST_IS_REGULAR))
 158.923 -    {
 158.924 -      m_poCoreConfig->vSetKey("bios_file", oDialog.get_filename());
 158.925 -      m_poUseBiosItem->set_sensitive();
 158.926 -      break;
 158.927 -    }
 158.928 -  }
 158.929 -}
 158.930 -
 158.931 -void Window::vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI)
 158.932 -{
 158.933 -  m_poCoreConfig->vSetKey("use_bios_file", _poCMI->get_active());
 158.934 -}
 158.935 -
 158.936 -void Window::vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed)
 158.937 -{
 158.938 -  if (! _poCMI->get_active())
 158.939 -  {
 158.940 -    return;
 158.941 -  }
 158.942 -
 158.943 -  m_eShowSpeed = (EShowSpeed)_iShowSpeed;
 158.944 -  if (m_eShowSpeed == ShowNone)
 158.945 -  {
 158.946 -    vSetDefaultTitle();
 158.947 -  }
 158.948 -  m_poDisplayConfig->vSetKey("show_speed", _iShowSpeed);
 158.949 -}
 158.950 -
 158.951 -void Window::vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType)
 158.952 -{
 158.953 -  if (! _poCMI->get_active())
 158.954 -  {
 158.955 -    return;
 158.956 -  }
 158.957 -
 158.958 -  cpuSaveType = _iSaveType;
 158.959 -  m_poCoreConfig->vSetKey("save_type", _iSaveType);
 158.960 -}
 158.961 -
 158.962 -void Window::vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize)
 158.963 -{
 158.964 -  if (! _poCMI->get_active())
 158.965 -  {
 158.966 -    return;
 158.967 -  }
 158.968 -
 158.969 -  if (_iFlashSize == 64)
 158.970 -  {
 158.971 -    flashSetSize(0x10000);
 158.972 -  }
 158.973 -  else
 158.974 -  {
 158.975 -    flashSetSize(0x20000);
 158.976 -  }
 158.977 -  m_poCoreConfig->vSetKey("flash_size", _iFlashSize);
 158.978 -}
 158.979 -
 158.980 -void Window::vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat)
 158.981 -{
 158.982 -  if (! _poCMI->get_active())
 158.983 -  {
 158.984 -    return;
 158.985 -  }
 158.986 -
 158.987 -  m_poCoreConfig->vSetKey("screenshot_format", _sFormat);
 158.988 -}
 158.989 -
 158.990 -void Window::vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus)
 158.991 -{
 158.992 -  if (! _poCMI->get_active())
 158.993 -  {
 158.994 -    return;
 158.995 -  }
 158.996 -
 158.997 -  std::string sSoundStatus;
 158.998 -  switch (_iSoundStatus)
 158.999 -  {
158.1000 -  case SoundOff:
158.1001 -    soundOffFlag = true;
158.1002 -    if (systemSoundOn)
158.1003 -    {
158.1004 -      soundShutdown();
158.1005 -    }
158.1006 -    sSoundStatus = "off";
158.1007 -    break;
158.1008 -  case SoundMute:
158.1009 -    soundDisableChannels(0x30f);
158.1010 -    sSoundStatus = "mute";
158.1011 -    break;
158.1012 -  case SoundOn:
158.1013 -    if (soundOffFlag)
158.1014 -    {
158.1015 -      soundOffFlag = false;
158.1016 -      if (! soundInit())
158.1017 -      {
158.1018 -        m_poSoundOffItem->set_active();
158.1019 -        return;
158.1020 -      }
158.1021 -    }
158.1022 -    soundEnableChannels(0x30f);
158.1023 -    sSoundStatus = "on";
158.1024 -    break;
158.1025 -  }
158.1026 -  m_poSoundConfig->vSetKey("status", sSoundStatus);
158.1027 -}
158.1028 -
158.1029 -void Window::vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI)
158.1030 -{
158.1031 -  soundEcho = _poCMI->get_active();
158.1032 -  m_poSoundConfig->vSetKey("echo", soundEcho);
158.1033 -}
158.1034 -
158.1035 -void Window::vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI)
158.1036 -{
158.1037 -  soundLowPass = _poCMI->get_active();
158.1038 -  m_poSoundConfig->vSetKey("low_pass", soundLowPass);
158.1039 -}
158.1040 -
158.1041 -void Window::vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI)
158.1042 -{
158.1043 -  soundReverse = _poCMI->get_active();
158.1044 -  m_poSoundConfig->vSetKey("reverse_stereo", soundReverse);
158.1045 -}
158.1046 -
158.1047 -void Window::vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel)
158.1048 -{
158.1049 -  int iShift = _iSoundChannel;
158.1050 -  if (_iSoundChannel > 3)
158.1051 -  {
158.1052 -    iShift += 4;
158.1053 -  }
158.1054 -  int iFlag = 1 << iShift;
158.1055 -  int iActive = soundGetEnabledChannels() & 0x30f;
158.1056 -  if (_poCMI->get_active())
158.1057 -  {
158.1058 -    iActive |= iFlag;
158.1059 -  }
158.1060 -  else
158.1061 -  {
158.1062 -    iActive &= ~iFlag;
158.1063 -  }
158.1064 -  soundEnableChannels(iActive);
158.1065 -  soundDisableChannels(~iActive & 0x30f);
158.1066 -
158.1067 -  const char * acsChannels[] =
158.1068 -  {
158.1069 -    "channel_1",
158.1070 -    "channel_2",
158.1071 -    "channel_3",
158.1072 -    "channel_4",
158.1073 -    "channel_A",
158.1074 -    "channel_B"
158.1075 -  };
158.1076 -  m_poSoundConfig->vSetKey(acsChannels[_iSoundChannel], _poCMI->get_active());
158.1077 -}
158.1078 -
158.1079 -void Window::vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality)
158.1080 -{
158.1081 -  if (! _poCMI->get_active())
158.1082 -  {
158.1083 -    return;
158.1084 -  }
158.1085 -
158.1086 -  m_eSoundQuality = (ESoundQuality)_iSoundQuality;
158.1087 -  if (m_eCartridge == CartridgeGBA)
158.1088 -  {
158.1089 -    soundSetQuality(_iSoundQuality);
158.1090 -  }
158.1091 -  else if (m_eCartridge == CartridgeGB)
158.1092 -  {
158.1093 -    gbSoundSetQuality(_iSoundQuality);
158.1094 -  }
158.1095 -  m_poSoundConfig->vSetKey("quality", _iSoundQuality);
158.1096 -}
158.1097 -
158.1098 -void Window::vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume)
158.1099 -{
158.1100 -  if (! _poCMI->get_active())
158.1101 -  {
158.1102 -    return;
158.1103 -  }
158.1104 -
158.1105 -  soundVolume = _iSoundVolume;
158.1106 -  m_poSoundConfig->vSetKey("volume", _iSoundVolume);
158.1107 -}
158.1108 -
158.1109 -void Window::vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI)
158.1110 -{
158.1111 -  gbBorderOn = _poCMI->get_active();
158.1112 -  if (emulating && m_eCartridge == CartridgeGB && _poCMI->get_active())
158.1113 -  {
158.1114 -    gbSgbRenderBorder();
158.1115 -  }
158.1116 -  vUpdateScreen();
158.1117 -  m_poCoreConfig->vSetKey("gb_border", _poCMI->get_active());
158.1118 -}
158.1119 -
158.1120 -void Window::vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI)
158.1121 -{
158.1122 -  if (_poCMI->get_active())
158.1123 -  {
158.1124 -    gbSerialFunction = gbPrinterSend;
158.1125 -  }
158.1126 -  else
158.1127 -  {
158.1128 -    gbSerialFunction = NULL;
158.1129 -  }
158.1130 -  m_poCoreConfig->vSetKey("gb_printer", _poCMI->get_active());
158.1131 -}
158.1132 -
158.1133 -void Window::vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType)
158.1134 -{
158.1135 -  gbEmulatorType = _iEmulatorType;
158.1136 -  m_poCoreConfig->vSetKey("emulator_type", _iEmulatorType);
158.1137 -}
158.1138 -
158.1139 -void Window::vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x)
158.1140 -{
158.1141 -  if (! _poCMI->get_active())
158.1142 -  {
158.1143 -    return;
158.1144 -  }
158.1145 -
158.1146 -  m_poScreenArea->vSetFilter2x((EFilter2x)_iFilter2x);
158.1147 -  if (emulating)
158.1148 -  {
158.1149 -    vDrawScreen();
158.1150 -  }
158.1151 -  m_poDisplayConfig->vSetKey("filter2x", _iFilter2x);
158.1152 -}
158.1153 -
158.1154 -void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB)
158.1155 -{
158.1156 -  if (! _poCMI->get_active())
158.1157 -  {
158.1158 -    return;
158.1159 -  }
158.1160 -
158.1161 -  m_poScreenArea->vSetFilterIB((EFilterIB)_iFilterIB);
158.1162 -  if (emulating)
158.1163 -  {
158.1164 -    vDrawScreen();
158.1165 -  }
158.1166 -  m_poDisplayConfig->vSetKey("filterIB", _iFilterIB);
158.1167 -}
158.1168 -
158.1169 -#ifdef MMX
158.1170 -void Window::vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI)
158.1171 -{
158.1172 -  cpu_mmx = ! _poCMI->get_active();
158.1173 -  m_poDisplayConfig->vSetKey("filter_disable_mmx", _poCMI->get_active());
158.1174 -}
158.1175 -#endif // MMX
158.1176 -
158.1177 -void Window::vOnJoypadConfigure(int _iJoypad)
158.1178 -{
158.1179 -  Glib::RefPtr<Xml> poXml;
158.1180 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "JoypadConfigDialog");
158.1181 -
158.1182 -  JoypadConfigDialog * poDialog = NULL;
158.1183 -  poXml->get_widget_derived<JoypadConfigDialog>("JoypadConfigDialog", poDialog);
158.1184 -  poDialog->set_transient_for(*this);
158.1185 -  poDialog->vSetConfig(m_oJoypads[_iJoypad - 1]);
158.1186 -
158.1187 -  if (poDialog->run() == Gtk::RESPONSE_OK)
158.1188 -  {
158.1189 -    m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig();
158.1190 -    if (_iJoypad == m_poInputConfig->oGetKey<int>("active_joypad"))
158.1191 -    {
158.1192 -      if (m_poKeymap != NULL)
158.1193 -      {
158.1194 -        delete m_poKeymap;
158.1195 -      }
158.1196 -      m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
158.1197 -    }
158.1198 -  }
158.1199 -
158.1200 -  delete poDialog;
158.1201 -}
158.1202 -
158.1203 -void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad)
158.1204 -{
158.1205 -  if (! _poCMI->get_active())
158.1206 -  {
158.1207 -    return;
158.1208 -  }
158.1209 -
158.1210 -  if (m_poKeymap != NULL)
158.1211 -  {
158.1212 -    delete m_poKeymap;
158.1213 -  }
158.1214 -  m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
158.1215 -
158.1216 -  m_poInputConfig->vSetKey("active_joypad", _iJoypad);
158.1217 -}
158.1218 -
158.1219 -void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag)
158.1220 -{
158.1221 -  if (_poCMI->get_active())
158.1222 -  {
158.1223 -    m_uiAutofireState |= _uiKeyFlag;
158.1224 -  }
158.1225 -  else
158.1226 -  {
158.1227 -    m_uiAutofireState &= ~_uiKeyFlag;
158.1228 -  }
158.1229 -
158.1230 -  std::string sKey;
158.1231 -  if (_uiKeyFlag == KeyFlagA)
158.1232 -  {
158.1233 -    sKey = "autofire_A";
158.1234 -  }
158.1235 -  else if (_uiKeyFlag == KeyFlagB)
158.1236 -  {
158.1237 -    sKey = "autofire_B";
158.1238 -  }
158.1239 -  else if (_uiKeyFlag == KeyFlagL)
158.1240 -  {
158.1241 -    sKey = "autofire_L";
158.1242 -  }
158.1243 -  else if (_uiKeyFlag == KeyFlagR)
158.1244 -  {
158.1245 -    sKey = "autofire_R";
158.1246 -  }
158.1247 -  m_poInputConfig->vSetKey(sKey, _poCMI->get_active());
158.1248 -}
158.1249 -
158.1250 -void Window::vOnGDBWait()
158.1251 -{
158.1252 -  Glib::RefPtr<Xml> poXml;
158.1253 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog");
158.1254 -
158.1255 -  Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("TcpPortDialog"));
158.1256 -  Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("TcpPortSpin"));
158.1257 -
158.1258 -  poDialog->set_transient_for(*this);
158.1259 -
158.1260 -  int iPort = 55555;
158.1261 -  poSpin->set_value(iPort);  
158.1262 -
158.1263 -  bool bOk = false;
158.1264 -  if (poDialog->run() == Gtk::RESPONSE_OK)
158.1265 -  {
158.1266 -    bOk = true;
158.1267 -    iPort = poSpin->get_value_as_int();
158.1268 -  }
158.1269 -  delete poDialog;
158.1270 -
158.1271 -  if (! bOk)
158.1272 -  {
158.1273 -    return;
158.1274 -  }
158.1275 -
158.1276 -  m_eCartridge = CartridgeGBA;
158.1277 -  m_sRomFile   = "gnu_stub";
158.1278 -  m_stEmulator = GBASystem;
158.1279 -
158.1280 -  rom         = (u8 *) malloc(0x2000000);
158.1281 -  workRAM     = (u8 *) calloc(1, 0x40000);
158.1282 -  bios        = (u8 *) calloc(1, 0x4000);
158.1283 -  internalRAM = (u8 *) calloc(1, 0x8000);
158.1284 -  paletteRAM  = (u8 *) calloc(1, 0x400);
158.1285 -  vram        = (u8 *) calloc(1, 0x20000);
158.1286 -  oam         = (u8 *) calloc(1, 0x400);
158.1287 -  pix         = (u8 *) calloc(1, 4 * m_iGBAScreenWidth * m_iGBAScreenHeight);
158.1288 -  ioMem       = (u8 *) calloc(1, 0x400);
158.1289 -
158.1290 -  useBios = m_poCoreConfig->oGetKey<bool>("use_bios_file");
158.1291 -  //CPUInit(m_poCoreConfig->sGetKey("bios_file").c_str(), useBios);
158.1292 -  CPUInit();
158.1293 -  CPUReset();
158.1294 -
158.1295 -  for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
158.1296 -       it != m_listSensitiveWhenPlaying.end();
158.1297 -       it++)
158.1298 -  {
158.1299 -    (*it)->set_sensitive();
158.1300 -  }
158.1301 -
158.1302 -  if (m_poCoreConfig->oGetKey<bool>("load_game_auto"))
158.1303 -  {
158.1304 -    vOnLoadGameMostRecent();
158.1305 -  }
158.1306 -
158.1307 -  vStartEmu();
158.1308 -
158.1309 -  emulating = 1;
158.1310 -
158.1311 -  dbgMain   = remoteStubMain;
158.1312 -  dbgSignal = remoteStubSignal;
158.1313 -  dbgOutput = remoteOutput;
158.1314 -  debugger  = true;
158.1315 -
158.1316 -  remoteSetProtocol(0);
158.1317 -  remoteSetPort(iPort);
158.1318 -  remoteInit();
158.1319 -}
158.1320 -
158.1321 -void Window::vOnGDBLoadAndWait()
158.1322 -{
158.1323 -  bool bLoaded = false;
158.1324 -
158.1325 -  while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK)
158.1326 -  {
158.1327 -    if (bLoadROM(m_poFileOpenDialog->get_filename()))
158.1328 -    {
158.1329 -      bLoaded = true;
158.1330 -      break;
158.1331 -    }
158.1332 -  }
158.1333 -  m_poFileOpenDialog->hide();
158.1334 -
158.1335 -  if (! bLoaded)
158.1336 -  {
158.1337 -    return;
158.1338 -  }
158.1339 -
158.1340 -  if (m_eCartridge != CartridgeGBA)
158.1341 -  {
158.1342 -    vPopupError(_("Only GBA images are supported."));
158.1343 -    vOnFileClose();
158.1344 -    return;
158.1345 -  }
158.1346 -
158.1347 -  Glib::RefPtr<Xml> poXml;
158.1348 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog");
158.1349 -
158.1350 -  Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("TcpPortDialog"));
158.1351 -  Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("TcpPortSpin"));
158.1352 -
158.1353 -  poDialog->set_transient_for(*this);
158.1354 -
158.1355 -  int iPort = 55555;
158.1356 -  poSpin->set_value(iPort);  
158.1357 -
158.1358 -  bool bOk = false;
158.1359 -  if (poDialog->run() == Gtk::RESPONSE_OK)
158.1360 -  {
158.1361 -    bOk = true;
158.1362 -    iPort = poSpin->get_value_as_int();
158.1363 -  }
158.1364 -  delete poDialog;
158.1365 -
158.1366 -  if (! bOk)
158.1367 -  {
158.1368 -    return;
158.1369 -  }
158.1370 -
158.1371 -  dbgMain   = remoteStubMain;
158.1372 -  dbgSignal = remoteStubSignal;
158.1373 -  dbgOutput = remoteOutput;
158.1374 -  debugger  = true;
158.1375 -
158.1376 -  remoteSetProtocol(0);
158.1377 -  remoteSetPort(iPort);
158.1378 -  remoteInit();
158.1379 -}
158.1380 -
158.1381 -void Window::vOnGDBBreak()
158.1382 -{
158.1383 -  if (armState)
158.1384 -  {
158.1385 -    armNextPC -= 4;
158.1386 -    reg[15].I -= 4;
158.1387 -  }
158.1388 -  else
158.1389 -  {
158.1390 -    armNextPC -= 2;
158.1391 -    reg[15].I -= 2;
158.1392 -  }
158.1393 -
158.1394 -  debugger = true;
158.1395 -}
158.1396 -
158.1397 -void Window::vOnGDBDisconnect()
158.1398 -{
158.1399 -  remoteCleanUp();
158.1400 -  debugger = false;
158.1401 -}
158.1402 -
158.1403 -void Window::vOnHelpAbout()
158.1404 -{
158.1405 -  Glib::RefPtr<Xml> poXml;
158.1406 -  poXml = Xml::create(PKGDATADIR "/vba.glade", "AboutDialog");
158.1407 -
158.1408 -  Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("AboutDialog"));
158.1409 -  poDialog->set_transient_for(*this);
158.1410 -
158.1411 -  Gtk::Image oIcon(PKGDATADIR "/vba-64.png");
158.1412 -  oIcon.show();
158.1413 -  Gtk::Container * poIconContainer = dynamic_cast<Gtk::Container *>(poXml->get_widget("AboutIconContainer"));
158.1414 -  poIconContainer->add(oIcon);
158.1415 -
158.1416 -  Gtk::Label * poLabel  = dynamic_cast<Gtk::Label *>(poXml->get_widget("VersionLabel"));
158.1417 -  poLabel->set_markup("<b><big>" PACKAGE " " VERSION "</big></b>");
158.1418 -
158.1419 -  poDialog->run();
158.1420 -  delete poDialog;
158.1421 -}
158.1422 -
158.1423 -bool Window::bOnEmuIdle()
158.1424 -{
158.1425 -  if (debugger && m_stEmulator.emuHasDebugger)
158.1426 -  {
158.1427 -    dbgMain();
158.1428 -    return true;
158.1429 -  }
158.1430 -
158.1431 -  if (m_uiThrottleDelay != 0)
158.1432 -  {
158.1433 -    u32 uiTime = SDL_GetTicks();
158.1434 -    if (uiTime - m_uiThrottleLastTime >= m_uiThrottleDelay)
158.1435 -    {
158.1436 -      m_uiThrottleDelay = 0;
158.1437 -      m_uiThrottleLastTime = uiTime;
158.1438 -    }
158.1439 -    else
158.1440 -    {
158.1441 -      return true;
158.1442 -    }
158.1443 -  }
158.1444 -
158.1445 -  m_stEmulator.emuMain(m_stEmulator.emuCount);
158.1446 -  return true;
158.1447 -}
158.1448 -
158.1449 -bool Window::on_focus_in_event(GdkEventFocus * _pstEvent)
158.1450 -{
158.1451 -  if (emulating
158.1452 -      && ! m_bPaused
158.1453 -      && m_poDisplayConfig->oGetKey<bool>("pause_when_inactive"))
158.1454 -  {
158.1455 -    vStartEmu();
158.1456 -    soundResume();
158.1457 -  }
158.1458 -  return false;
158.1459 -}
158.1460 -
158.1461 -bool Window::on_focus_out_event(GdkEventFocus * _pstEvent)
158.1462 -{
158.1463 -  if (emulating
158.1464 -      && ! m_bPaused
158.1465 -      && m_poDisplayConfig->oGetKey<bool>("pause_when_inactive"))
158.1466 -  {
158.1467 -    vStopEmu();
158.1468 -    soundPause();
158.1469 -  }
158.1470 -  return false;
158.1471 -}
158.1472 -
158.1473 -bool Window::on_key_press_event(GdkEventKey * _pstEvent)
158.1474 -{
158.1475 -  EKey eKey;
158.1476 -
158.1477 -  if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
158.1478 -      || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
158.1479 -  {
158.1480 -    return Gtk::Window::on_key_press_event(_pstEvent);
158.1481 -  }
158.1482 -
158.1483 -  switch (eKey)
158.1484 -  {
158.1485 -  case KeyA:
158.1486 -    m_uiJoypadState |= KeyFlagA;
158.1487 -    break;
158.1488 -  case KeyB:
158.1489 -    m_uiJoypadState |= KeyFlagB;
158.1490 -    break;
158.1491 -  case KeySelect:
158.1492 -    m_uiJoypadState |= KeyFlagSelect;
158.1493 -    break;
158.1494 -  case KeyStart:
158.1495 -    m_uiJoypadState |= KeyFlagStart;
158.1496 -    break;
158.1497 -  case KeyRight:
158.1498 -    m_uiJoypadState |= KeyFlagRight;
158.1499 -    m_uiJoypadState &= ~KeyFlagLeft;
158.1500 -    break;
158.1501 -  case KeyLeft:
158.1502 -    m_uiJoypadState |= KeyFlagLeft;
158.1503 -    m_uiJoypadState &= ~KeyFlagRight;
158.1504 -    break;
158.1505 -  case KeyUp:
158.1506 -    m_uiJoypadState |= KeyFlagUp;
158.1507 -    m_uiJoypadState &= ~KeyFlagDown;
158.1508 -    break;
158.1509 -  case KeyDown:
158.1510 -    m_uiJoypadState |= KeyFlagDown;
158.1511 -    m_uiJoypadState &= ~KeyFlagUp;
158.1512 -    break;
158.1513 -  case KeyR:
158.1514 -    m_uiJoypadState |= KeyFlagR;
158.1515 -    break;
158.1516 -  case KeyL:
158.1517 -    m_uiJoypadState |= KeyFlagL;
158.1518 -    break;
158.1519 -  case KeySpeed:
158.1520 -    m_uiJoypadState |= KeyFlagSpeed;
158.1521 -    break;
158.1522 -  case KeyCapture:
158.1523 -    m_uiJoypadState |= KeyFlagCapture;
158.1524 -    break;
158.1525 -  case KeyNone:
158.1526 -    break;
158.1527 -  }
158.1528 -  return true;
158.1529 -}
158.1530 -
158.1531 -bool Window::on_key_release_event(GdkEventKey * _pstEvent)
158.1532 -{
158.1533 -  EKey eKey;
158.1534 -
158.1535 -  if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
158.1536 -      || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
158.1537 -  {
158.1538 -    return Gtk::Window::on_key_release_event(_pstEvent);
158.1539 -  }
158.1540 -
158.1541 -  switch (eKey)
158.1542 -  {
158.1543 -  case KeyA:
158.1544 -    m_uiJoypadState &= ~KeyFlagA;
158.1545 -    break;
158.1546 -  case KeyB:
158.1547 -    m_uiJoypadState &= ~KeyFlagB;
158.1548 -    break;
158.1549 -  case KeySelect:
158.1550 -    m_uiJoypadState &= ~KeyFlagSelect;
158.1551 -    break;
158.1552 -  case KeyStart:
158.1553 -    m_uiJoypadState &= ~KeyFlagStart;
158.1554 -    break;
158.1555 -  case KeyRight:
158.1556 -    m_uiJoypadState &= ~KeyFlagRight;
158.1557 -    break;
158.1558 -  case KeyLeft:
158.1559 -    m_uiJoypadState &= ~KeyFlagLeft;
158.1560 -    break;
158.1561 -  case KeyUp:
158.1562 -    m_uiJoypadState &= ~KeyFlagUp;
158.1563 -    break;
158.1564 -  case KeyDown:
158.1565 -    m_uiJoypadState &= ~KeyFlagDown;
158.1566 -    break;
158.1567 -  case KeyR:
158.1568 -    m_uiJoypadState &= ~KeyFlagR;
158.1569 -    break;
158.1570 -  case KeyL:
158.1571 -    m_uiJoypadState &= ~KeyFlagL;
158.1572 -    break;
158.1573 -  case KeySpeed:
158.1574 -    m_uiJoypadState &= ~KeyFlagSpeed;
158.1575 -    break;
158.1576 -  case KeyCapture:
158.1577 -    m_uiJoypadState &= ~KeyFlagCapture;
158.1578 -    break;
158.1579 -  case KeyNone:
158.1580 -    break;
158.1581 -  }
158.1582 -  return true;
158.1583 -}
158.1584 -
158.1585 -} // namespace VBA
   159.1 --- a/src/prof/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
   159.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   159.3 @@ -1,7 +0,0 @@
   159.4 -noinst_LIBRARIES = libprof.a
   159.5 -
   159.6 -libprof_a_SOURCES = \
   159.7 -	gmon.h		\
   159.8 -	gmon_out.h	\
   159.9 -	prof.cpp	\
  159.10 -	prof.h
   160.1 --- a/src/prof/gmon.h	Sat Mar 03 10:54:39 2012 -0600
   160.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   160.3 @@ -1,151 +0,0 @@
   160.4 -/*
   160.5 - * Copyright (c) 1983, 1991, 1993, 2001
   160.6 - *      The Regents of the University of California.  All rights reserved.
   160.7 - *
   160.8 - * Redistribution and use in source and binary forms, with or without
   160.9 - * modification, are permitted provided that the following conditions
  160.10 - * are met:
  160.11 - * 1. Redistributions of source code must retain the above copyright
  160.12 - *    notice, this list of conditions and the following disclaimer.
  160.13 - * 2. Redistributions in binary form must reproduce the above copyright
  160.14 - *    notice, this list of conditions and the following disclaimer in the
  160.15 - *    documentation and/or other materials provided with the distribution.
  160.16 - * 3. Neither the name of the University nor the names of its contributors
  160.17 - *    may be used to endorse or promote products derived from this software
  160.18 - *    without specific prior written permission.
  160.19 - *
  160.20 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  160.21 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  160.22 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  160.23 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  160.24 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  160.25 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  160.26 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  160.27 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  160.28 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  160.29 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  160.30 - * SUCH DAMAGE.
  160.31 - */
  160.32 -#ifndef gmon_h
  160.33 -#define gmon_h
  160.34 -
  160.35 -#include <stdint.h>
  160.36 -typedef uint32_t u32;
  160.37 -
  160.38 -/* Size of the 4.4BSD gmon header */
  160.39 -#define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4))
  160.40 -#define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4))
  160.41 -
  160.42 -#if 0 /* For documentation purposes only.  */
  160.43 -  struct raw_phdr
  160.44 -    {
  160.45 -      char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
  160.46 -      char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
  160.47 -      char ncnt[4];		   /* size of sample buffer (plus this
  160.48 -				      header) */
  160.49 -
  160.50 -      char version[4];		   /* version number */
  160.51 -      char profrate[4];		   /* profiling clock rate */
  160.52 -      char spare[3*4];		   /* reserved */
  160.53 -    };
  160.54 -#endif
  160.55 -
  160.56 -#define GMONVERSION     0x00051879
  160.57 -
  160.58 -/* Size of the old BSD gmon header */
  160.59 -#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) 
  160.60 -
  160.61 -/* FIXME: Checking host compiler defines here means that we can't
  160.62 -   use a cross gprof alpha OSF.  */
  160.63 -#if defined(__alpha__) && defined (__osf__) 
  160.64 -#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4)
  160.65 -#else
  160.66 -#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4)
  160.67 -#endif
  160.68 -
  160.69 -#if 0 /* For documentation purposes only.  */
  160.70 -  struct old_raw_phdr
  160.71 -    {
  160.72 -      char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
  160.73 -      char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
  160.74 -      char ncnt[4];		   /* size of sample buffer (plus this
  160.75 -				      header) */
  160.76 -#if defined (__alpha__) && defined (__osf__)
  160.77 -      /*
  160.78 -       * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to
  160.79 -       * a size that is a multiple of 8.
  160.80 -       */
  160.81 -      char pad[4];
  160.82 -#endif
  160.83 -    };
  160.84 -#endif
  160.85 -
  160.86 -/*
  160.87 - * Histogram counters are unsigned shorts:
  160.88 - */
  160.89 -#define	HISTCOUNTER unsigned short
  160.90 -
  160.91 -/*
  160.92 - * Fraction of text space to allocate for histogram counters here, 1/2:
  160.93 - */
  160.94 -#define	HISTFRACTION	2
  160.95 -
  160.96 -/*
  160.97 - * Fraction of text space to allocate for from hash buckets.  The
  160.98 - * value of HASHFRACTION is based on the minimum number of bytes of
  160.99 - * separation between two subroutine call points in the object code.
 160.100 - * Given MIN_SUBR_SEPARATION bytes of separation the value of
 160.101 - * HASHFRACTION is calculated as:
 160.102 - *
 160.103 - *      HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
 160.104 - *
 160.105 - * For the VAX, the shortest two call sequence is:
 160.106 - *
 160.107 - *      calls   $0,(r0)
 160.108 - *      calls   $0,(r0)
 160.109 - *
 160.110 - * which is separated by only three bytes, thus HASHFRACTION is
 160.111 - * calculated as:
 160.112 - *
 160.113 - *      HASHFRACTION = 3 / (2 * 2 - 1) = 1
 160.114 - *
 160.115 - * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
 160.116 - * is less than three, this algorithm will not work!
 160.117 - */
 160.118 -#define	HASHFRACTION 1
 160.119 -
 160.120 -/*
 160.121 - * Percent of text space to allocate for tostructs with a minimum:
 160.122 - */
 160.123 -#define ARCDENSITY	2
 160.124 -#define MINARCS		50
 160.125 -
 160.126 -struct tostruct
 160.127 -  {
 160.128 -    u32 selfpc;
 160.129 -    int count;
 160.130 -    unsigned short link;
 160.131 -  };
 160.132 -
 160.133 -/*
 160.134 - * A raw arc, with pointers to the calling site and the called site
 160.135 - * and a count.  Everything is defined in terms of characters so
 160.136 - * as to get a packed representation (otherwise, different compilers
 160.137 - * might introduce different padding):
 160.138 - */
 160.139 -#if 0 /* For documentation purposes only.  */
 160.140 -  struct raw_arc
 160.141 -    {
 160.142 -      char from_pc[sizeof(void *)];
 160.143 -      char self_pc[sizeof(void *)];
 160.144 -      char count[sizeof(long)];
 160.145 -    };
 160.146 -#endif
 160.147 -
 160.148 -/*
 160.149 - * General rounding functions:
 160.150 - */
 160.151 -#define ROUNDDOWN(x,y)	(((x)/(y))*(y))
 160.152 -#define ROUNDUP(x,y)	((((x)+(y)-1)/(y))*(y))
 160.153 -
 160.154 -#endif /* gmon_h */
   161.1 --- a/src/prof/gmon_out.h	Sat Mar 03 10:54:39 2012 -0600
   161.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   161.3 @@ -1,45 +0,0 @@
   161.4 -/* gmon_out.h
   161.5 -
   161.6 -   Copyright 2000, 2001 Free Software Foundation, Inc.
   161.7 -
   161.8 -This file is part of GNU Binutils.
   161.9 -
  161.10 -This program is free software; you can redistribute it and/or modify
  161.11 -it under the terms of the GNU General Public License as published by
  161.12 -the Free Software Foundation; either version 2 of the License, or
  161.13 -(at your option) any later version.
  161.14 -
  161.15 -This program is distributed in the hope that it will be useful,
  161.16 -but WITHOUT ANY WARRANTY; without even the implied warranty of
  161.17 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  161.18 -GNU General Public License for more details.
  161.19 -
  161.20 -You should have received a copy of the GNU General Public License
  161.21 -along with this program; if not, write to the Free Software
  161.22 -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  161.23 -
  161.24 -/* A gmon.out file consists of a header (defined by gmon_hdr) followed
  161.25 -   by a sequence of records.  Each record starts with a one-byte tag
  161.26 -   identifying the type of records, followed by records specific data.  */
  161.27 -#ifndef gmon_out_h
  161.28 -#define gmon_out_h
  161.29 -
  161.30 -#define	GMON_MAGIC	"gmon"	/* magic cookie */
  161.31 -#define GMON_VERSION	1	/* version number */
  161.32 -
  161.33 -/* Raw header as it appears on file (without padding).  */
  161.34 -struct gmon_hdr
  161.35 -  {
  161.36 -    char cookie[4];
  161.37 -    char version[4];
  161.38 -    char spare[3 * 4];
  161.39 -  };
  161.40 -
  161.41 -/* Types of records in this file.  */
  161.42 -typedef enum
  161.43 -  {
  161.44 -    GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2
  161.45 -  }
  161.46 -GMON_Record_Tag;
  161.47 -
  161.48 -#endif /* gmon_out_h */
   162.1 --- a/src/prof/prof.cpp	Sat Mar 03 10:54:39 2012 -0600
   162.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   162.3 @@ -1,405 +0,0 @@
   162.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   162.5 -// Copyright (C) 1999-2003 Forgotten
   162.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   162.7 -
   162.8 -// This program is free software; you can redistribute it and/or modify
   162.9 -// it under the terms of the GNU General Public License as published by
  162.10 -// the Free Software Foundation; either version 2, or(at your option)
  162.11 -// any later version.
  162.12 -//
  162.13 -// This program is distributed in the hope that it will be useful,
  162.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  162.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  162.16 -// GNU General Public License for more details.
  162.17 -//
  162.18 -// You should have received a copy of the GNU General Public License
  162.19 -// along with this program; if not, write to the Free Software Foundation,
  162.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  162.21 -
  162.22 -// adapted from gmon.c
  162.23 -/*-
  162.24 - * Copyright (c) 1991, 1998 The Regents of the University of California.
  162.25 - * All rights reserved.
  162.26 - *
  162.27 - * Redistribution and use in source and binary forms, with or without
  162.28 - * modification, are permitted provided that the following conditions
  162.29 - * are met:
  162.30 - * 1. Redistributions of source code must retain the above copyright
  162.31 - *    notice, this list of conditions and the following disclaimer.
  162.32 - * 2. Redistributions in binary form must reproduce the above copyright
  162.33 - *    notice, this list of conditions and the following disclaimer in the
  162.34 - *    documentation and/or other materials provided with the distribution.
  162.35 - * 3. [rescinded 22 July 1999]
  162.36 - * 4. Neither the name of the University nor the names of its contributors
  162.37 - *    may be used to endorse or promote products derived from this software
  162.38 - *    without specific prior written permission.
  162.39 - *
  162.40 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  162.41 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  162.42 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  162.43 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  162.44 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  162.45 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  162.46 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  162.47 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  162.48 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  162.49 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  162.50 - * SUCH DAMAGE.
  162.51 - */
  162.52 -
  162.53 -#include <stdlib.h>
  162.54 -#include <stdio.h>
  162.55 -#include <memory.h>
  162.56 -
  162.57 -#include "gmon.h"
  162.58 -#include "gmon_out.h"
  162.59 -
  162.60 -#include "../common/System.h"
  162.61 -#include "../gba/GBA.h"
  162.62 -#include "../gba/GBAGlobals.h"
  162.63 -#include "../NLS.h"
  162.64 -
  162.65 -/*
  162.66 - * froms is actually a bunch of unsigned shorts indexing tos
  162.67 - */
  162.68 -static int  profiling = 3;
  162.69 -static unsigned short *froms;
  162.70 -static struct tostruct *tos = 0;
  162.71 -static long  tolimit = 0;
  162.72 -static u32  s_lowpc = 0;
  162.73 -static u32  s_highpc = 0;
  162.74 -static unsigned long s_textsize = 0;
  162.75 -
  162.76 -static int ssiz;
  162.77 -static char *sbuf;
  162.78 -static int s_scale;
  162.79 -
  162.80 -static int hz = 0;
  162.81 -static int hist_num_bins = 0;
  162.82 -static char hist_dimension[16] = "seconds";
  162.83 -static char hist_dimension_abbrev = 's';
  162.84 -
  162.85 -/* see profil(2) where this is describe (incorrectly) */
  162.86 -#define  SCALE_1_TO_1 0x10000L
  162.87 -
  162.88 -void profPut32(char *b, u32 v)
  162.89 -{
  162.90 -  b[0] = v & 255;
  162.91 -  b[1] = (v >> 8) & 255;
  162.92 -  b[2] = (v >> 16) & 255;
  162.93 -  b[3] = (v >> 24) & 255;
  162.94 -}
  162.95 -
  162.96 -void profPut16(char *b, u16 v)
  162.97 -{
  162.98 -  b[0] = v & 255;
  162.99 -  b[1] = (v >> 8) & 255;
 162.100 -}
 162.101 -
 162.102 -int profWrite8(FILE *f, u8 b)
 162.103 -{
 162.104 -  if(fwrite(&b, 1, 1, f) != 1)
 162.105 -    return 1;
 162.106 -  return 0;
 162.107 -}
 162.108 -
 162.109 -int profWrite32(FILE *f, u32 v)
 162.110 -{
 162.111 -  char buf[4];
 162.112 -
 162.113 -  profPut32(buf, v);
 162.114 -  if(fwrite(buf, 1, 4, f) != 4)
 162.115 -    return 1;
 162.116 -  return 0;
 162.117 -}
 162.118 -
 162.119 -int profWrite(FILE *f, char *buf, unsigned int n)
 162.120 -{
 162.121 -  if(fwrite(buf, 1, n, f) != n)
 162.122 -    return 1;
 162.123 -  return 0;
 162.124 -}
 162.125 -
 162.126 -/* Control profiling;
 162.127 -   profiling is what mcount checks to see if
 162.128 -   all the data structures are ready.  */
 162.129 -
 162.130 -void profControl(int mode)
 162.131 -{
 162.132 -  if (mode) {
 162.133 -    /* start */
 162.134 -#ifdef PROFILING
 162.135 -    cpuProfil(sbuf, ssiz, (u32)s_lowpc, s_scale);
 162.136 -#endif
 162.137 -    profiling = 0;
 162.138 -  } else {
 162.139 -    /* stop */
 162.140 -#ifdef PROFILING
 162.141 -    cpuProfil(NULL, 0, 0, 0);
 162.142 -#endif
 162.143 -    profiling = 3;
 162.144 -  }
 162.145 -}
 162.146 -
 162.147 -
 162.148 -#define MSG N_("No space for profiling buffer(s)\n")
 162.149 -
 162.150 -void profStartup(u32 lowpc, u32 highpc)
 162.151 -{
 162.152 -  int monsize;
 162.153 -  char *buffer;
 162.154 -  int o;
 162.155 -  
 162.156 -  /*
 162.157 -   * round lowpc and highpc to multiples of the density we're using
 162.158 -   * so the rest of the scaling (here and in gprof) stays in ints.
 162.159 -   */
 162.160 -  lowpc = ROUNDDOWN(lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
 162.161 -  s_lowpc = lowpc;
 162.162 -  highpc = ROUNDUP(highpc, HISTFRACTION*sizeof(HISTCOUNTER));
 162.163 -  s_highpc = highpc;
 162.164 -  s_textsize = highpc - lowpc;
 162.165 -  monsize = (s_textsize / HISTFRACTION);
 162.166 -  buffer = (char *)calloc(1, 2*monsize );
 162.167 -  if ( buffer == NULL ) {
 162.168 -    systemMessage(0, MSG);
 162.169 -    return;
 162.170 -  }
 162.171 -  froms = (unsigned short *) calloc(1, 4*s_textsize / HASHFRACTION );
 162.172 -  if ( froms == NULL ) {
 162.173 -    systemMessage(0, MSG);
 162.174 -    free(buffer);
 162.175 -    buffer = NULL;
 162.176 -    return;
 162.177 -  }
 162.178 -  tolimit = s_textsize * ARCDENSITY / 100;
 162.179 -  if ( tolimit < MINARCS ) {
 162.180 -    tolimit = MINARCS;
 162.181 -  } else if ( tolimit > 65534 ) {
 162.182 -    tolimit = 65534;
 162.183 -  }
 162.184 -  tos = (struct tostruct *) calloc(1, tolimit * sizeof( struct tostruct ) );
 162.185 -  if ( tos == NULL ) {
 162.186 -    systemMessage(0, MSG);
 162.187 -    
 162.188 -    free(buffer);
 162.189 -    buffer = NULL;
 162.190 -    
 162.191 -    free(froms);
 162.192 -    froms = NULL;
 162.193 -    
 162.194 -    return;
 162.195 -  }
 162.196 -  tos[0].link = 0;
 162.197 -  sbuf = buffer;
 162.198 -  ssiz = monsize;
 162.199 -  if ( monsize <= 0 )
 162.200 -    return;
 162.201 -  o = highpc - lowpc;
 162.202 -  if( monsize < o )
 162.203 -    s_scale = (int)(( (float) monsize / o ) * SCALE_1_TO_1);
 162.204 -  else
 162.205 -    s_scale = SCALE_1_TO_1;
 162.206 -  profControl(1);
 162.207 -}
 162.208 -
 162.209 -void profCleanup()
 162.210 -{
 162.211 -  FILE *fd;
 162.212 -  int fromindex;
 162.213 -  int endfrom;
 162.214 -  u32 frompc;
 162.215 -  int toindex;
 162.216 -  struct gmon_hdr ghdr;
 162.217 -  
 162.218 -  profControl(0);
 162.219 -  fd = fopen( "gmon.out" , "wb" );
 162.220 -  if ( fd == NULL ) {
 162.221 -    systemMessage( 0, "mcount: gmon.out" );
 162.222 -    return;
 162.223 -  }
 162.224 -
 162.225 -  memcpy(&ghdr.cookie[0], GMON_MAGIC, 4);
 162.226 -  profPut32((char *)ghdr.version, GMON_VERSION);
 162.227 -
 162.228 -  if(fwrite(&ghdr, sizeof(ghdr), 1, fd) != 1) {
 162.229 -    systemMessage(0, "mcount: gmon.out header");
 162.230 -    fclose(fd);
 162.231 -    return;
 162.232 -  }
 162.233 -
 162.234 -  if(hz == 0)
 162.235 -    hz = 100;
 162.236 -
 162.237 -  hist_num_bins = ssiz;
 162.238 -  
 162.239 -  if(profWrite8(fd, GMON_TAG_TIME_HIST) ||
 162.240 -     profWrite32(fd, (u32)s_lowpc) ||
 162.241 -     profWrite32(fd, (u32)s_highpc) ||
 162.242 -     profWrite32(fd, hist_num_bins) ||
 162.243 -     profWrite32(fd, hz) ||
 162.244 -     profWrite(fd, hist_dimension, 15) ||
 162.245 -     profWrite(fd, &hist_dimension_abbrev, 1)) {
 162.246 -    systemMessage(0, "mcount: gmon.out hist");
 162.247 -    fclose(fd);
 162.248 -    return;
 162.249 -  }
 162.250 -  u16 *hist_sample = (u16 *)sbuf;
 162.251 -
 162.252 -  u16 count;
 162.253 -  int i;
 162.254 -  
 162.255 -  for(i = 0; i < hist_num_bins; ++i) {
 162.256 -    profPut16((char *)&count, hist_sample[i]);
 162.257 -
 162.258 -    if(fwrite(&count, sizeof(count), 1, fd) != 1) {
 162.259 -      systemMessage(0, "mcount: gmon.out sample");
 162.260 -      fclose(fd);
 162.261 -      return;
 162.262 -    }
 162.263 -  }
 162.264 -  
 162.265 -  endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
 162.266 -  for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
 162.267 -    if ( froms[fromindex] == 0 ) {
 162.268 -      continue;
 162.269 -    }
 162.270 -    frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
 162.271 -    for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
 162.272 -      if(profWrite8(fd, GMON_TAG_CG_ARC) ||
 162.273 -         profWrite32(fd, (u32)frompc) ||
 162.274 -         profWrite32(fd, (u32)tos[toindex].selfpc) ||
 162.275 -         profWrite32(fd, tos[toindex].count)) {
 162.276 -        systemMessage(0, "mcount: arc");
 162.277 -        fclose(fd);
 162.278 -        return;
 162.279 -      }
 162.280 -    }
 162.281 -  }
 162.282 -  fclose(fd);
 162.283 -}
 162.284 -
 162.285 -void profCount()
 162.286 -{
 162.287 -  register u32 selfpc;
 162.288 -  register unsigned short *frompcindex;
 162.289 -  register struct tostruct *top;
 162.290 -  register struct tostruct *prevtop;
 162.291 -  register long toindex;
 162.292 -
 162.293 -  /*
 162.294 -   * find the return address for mcount,
 162.295 -   * and the return address for mcount's caller.
 162.296 -   */
 162.297 -  
 162.298 -  /* selfpc = pc pushed by mcount call.
 162.299 -     This identifies the function that was just entered.  */
 162.300 -  selfpc = (u32) reg[14].I;
 162.301 -  /* frompcindex = pc in preceding frame.
 162.302 -     This identifies the caller of the function just entered.  */
 162.303 -  frompcindex = (unsigned short *) reg[12].I;
 162.304 -  /*
 162.305 -   * check that we are profiling
 162.306 -   * and that we aren't recursively invoked.
 162.307 -   */
 162.308 -  if (profiling) {
 162.309 -    goto out;
 162.310 -  }
 162.311 -  profiling++;
 162.312 -  /*
 162.313 -   * check that frompcindex is a reasonable pc value.
 162.314 -   * for example: signal catchers get called from the stack,
 162.315 -   *   not from text space.  too bad.
 162.316 -   */
 162.317 -  frompcindex = (unsigned short *) ((long) frompcindex - (long) s_lowpc);
 162.318 -  if ((unsigned long) frompcindex > s_textsize) {
 162.319 -    goto done;
 162.320 -  }
 162.321 -  frompcindex =
 162.322 -    &froms[((long) frompcindex) / (HASHFRACTION * sizeof(*froms))];
 162.323 -  toindex = *frompcindex;
 162.324 -  if (toindex == 0) {
 162.325 -    /*
 162.326 -     * first time traversing this arc
 162.327 -     */
 162.328 -    toindex = ++tos[0].link;
 162.329 -    if (toindex >= tolimit) {
 162.330 -      goto overflow;
 162.331 -    }
 162.332 -    *frompcindex = (unsigned short)toindex;
 162.333 -    top = &tos[toindex];
 162.334 -    top->selfpc = selfpc;
 162.335 -    top->count = 1;
 162.336 -    top->link = 0;
 162.337 -    goto done;
 162.338 -  }
 162.339 -  top = &tos[toindex];
 162.340 -  if (top->selfpc == selfpc) {
 162.341 -    /*
 162.342 -     * arc at front of chain; usual case.
 162.343 -     */
 162.344 -    top->count++;
 162.345 -    goto done;
 162.346 -  }
 162.347 -  /*
 162.348 -   * have to go looking down chain for it.
 162.349 -   * top points to what we are looking at,
 162.350 -   * prevtop points to previous top.
 162.351 -   * we know it is not at the head of the chain.
 162.352 -   */
 162.353 -  for (; /* goto done */; ) {
 162.354 -    if (top->link == 0) {
 162.355 -      /*
 162.356 -       * top is end of the chain and none of the chain
 162.357 -       * had top->selfpc == selfpc.
 162.358 -       * so we allocate a new tostruct
 162.359 -       * and link it to the head of the chain.
 162.360 -       */
 162.361 -      toindex = ++tos[0].link;
 162.362 -      if (toindex >= tolimit) {
 162.363 -        goto overflow;
 162.364 -      }
 162.365 -      top = &tos[toindex];
 162.366 -      top->selfpc = selfpc;
 162.367 -      top->count = 1;
 162.368 -      top->link = *frompcindex;
 162.369 -      *frompcindex = (unsigned short)toindex;
 162.370 -      goto done;
 162.371 -    }
 162.372 -    /*
 162.373 -     * otherwise, check the next arc on the chain.
 162.374 -     */
 162.375 -    prevtop = top;
 162.376 -    top = &tos[top->link];
 162.377 -    if (top->selfpc == selfpc) {
 162.378 -      /*
 162.379 -       * there it is.
 162.380 -       * increment its count
 162.381 -       * move it to the head of the chain.
 162.382 -       */
 162.383 -      top->count++;
 162.384 -      toindex = prevtop->link;
 162.385 -      prevtop->link = top->link;
 162.386 -      top->link = *frompcindex;
 162.387 -      *frompcindex = (unsigned short)toindex;
 162.388 -      goto done;
 162.389 -    }
 162.390 -    
 162.391 -  }
 162.392 - done:
 162.393 -  profiling--;
 162.394 -  /* and fall through */
 162.395 - out:
 162.396 -  return;  /* normal return restores saved registers */
 162.397 -  
 162.398 - overflow:
 162.399 -  profiling++; /* halt further profiling */
 162.400 -#define TOLIMIT "mcount: tos overflow\n"
 162.401 -  systemMessage(0, TOLIMIT);
 162.402 -  goto out;
 162.403 -}
 162.404 -
 162.405 -void profSetHertz(int h)
 162.406 -{
 162.407 -  hz = h;
 162.408 -}
   163.1 --- a/src/prof/prof.h	Sat Mar 03 10:54:39 2012 -0600
   163.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   163.3 @@ -1,34 +0,0 @@
   163.4 -// -*- C++ -*-
   163.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   163.6 -// Copyright (C) 1999-2003 Forgotten
   163.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   163.8 -
   163.9 -// This program is free software; you can redistribute it and/or modify
  163.10 -// it under the terms of the GNU General Public License as published by
  163.11 -// the Free Software Foundation; either version 2, or(at your option)
  163.12 -// any later version.
  163.13 -//
  163.14 -// This program is distributed in the hope that it will be useful,
  163.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  163.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  163.17 -// GNU General Public License for more details.
  163.18 -//
  163.19 -// You should have received a copy of the GNU General Public License
  163.20 -// along with this program; if not, write to the Free Software Foundation,
  163.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  163.22 -
  163.23 -#ifndef VBA_PROF_PROF_H
  163.24 -#define VBA_PROF_PROF_H
  163.25 -
  163.26 -/* Control profiling;
  163.27 -   profiling is what mcount checks to see if
  163.28 -   all the data structures are ready.  */
  163.29 -
  163.30 -extern void profControl(int mode);
  163.31 -extern void profStartup(u32 lowpc, u32 highpc);
  163.32 -extern void profCleanup();
  163.33 -extern void profCount();
  163.34 -
  163.35 -extern void profSetHertz(int hertz);
  163.36 -#endif
  163.37 -
   164.1 --- a/src/sdl/Array.h	Sat Mar 03 10:54:39 2012 -0600
   164.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   164.3 @@ -1,40 +0,0 @@
   164.4 -/***************************************************************************
   164.5 - *   Copyright (C) 2008 by Sindre Aam�s                                    *
   164.6 - *   aamas@stud.ntnu.no                                                    *
   164.7 - *                                                                         *
   164.8 - *   This program is free software; you can redistribute it and/or modify  *
   164.9 - *   it under the terms of the GNU General Public License version 2 as     *
  164.10 - *   published by the Free Software Foundation.                            *
  164.11 - *                                                                         *
  164.12 - *   This program is distributed in the hope that it will be useful,       *
  164.13 - *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  164.14 - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  164.15 - *   GNU General Public License version 2 for more details.                *
  164.16 - *                                                                         *
  164.17 - *   You should have received a copy of the GNU General Public License     *
  164.18 - *   version 2 along with this program; if not, write to the               *
  164.19 - *   Free Software Foundation, Inc.,                                       *
  164.20 - *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  164.21 - ***************************************************************************/
  164.22 -#ifndef ARRAY_H
  164.23 -#define ARRAY_H
  164.24 -
  164.25 -#include <cstddef>
  164.26 -
  164.27 -template<typename T>
  164.28 -class Array {
  164.29 -	T *a;
  164.30 -	std::size_t sz;
  164.31 -	
  164.32 -	Array(const Array &ar);
  164.33 -	
  164.34 -public:
  164.35 -	Array(const std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {}
  164.36 -	~Array() { delete []a; }
  164.37 -	void reset(const std::size_t size) { delete []a; a = size ? new T[size] : 0; sz = size; }
  164.38 -	std::size_t size() const { return sz; }
  164.39 -	operator T*() { return a; }
  164.40 -	operator const T*() const { return a; }
  164.41 -};
  164.42 -
  164.43 -#endif
   165.1 --- a/src/sdl/Makefile.am	Sat Mar 03 10:54:39 2012 -0600
   165.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   165.3 @@ -1,47 +0,0 @@
   165.4 -bin_PROGRAMS = VisualBoyAdvance
   165.5 -
   165.6 -noinst_PROGRAMS = TestEmu
   165.7 -
   165.8 -VisualBoyAdvance_SOURCES = \
   165.9 -	SDL.cpp			\
  165.10 -	debugger.cpp		\
  165.11 -	debugger.h		\
  165.12 -	expr-lex.cpp		\
  165.13 -	expr.cpp		\
  165.14 -	expr.cpp.h		\
  165.15 -	exprNode.cpp		\
  165.16 -	exprNode.h		\
  165.17 -	getopt.c		\
  165.18 -	getopt.h		\
  165.19 -	getopt1.c		\
  165.20 -	../AutoBuild.h		\
  165.21 -	../NLS.h		\
  165.22 -	../Port.h
  165.23 -
  165.24 -VisualBoyAdvance_LDADD = @VBA_LIBS@ @SDL_LIBS@
  165.25 -
  165.26 -VisualBoyAdvance_DEPENDENCIES = @VBA_LIBS@
  165.27 -
  165.28 -TestEmu_SOURCES = \
  165.29 -	TestEmu.cpp		\
  165.30 -	debugger.cpp		\
  165.31 -	debugger.h		\
  165.32 -	expr-lex.cpp		\
  165.33 -	expr.cpp		\
  165.34 -	expr.cpp.h		\
  165.35 -	exprNode.cpp		\
  165.36 -	exprNode.h		\
  165.37 -	../AutoBuild.h		\
  165.38 -	../NLS.h		\
  165.39 -	../Port.h
  165.40 -
  165.41 -TestEmu_LDADD = @VBA_LIBS@ @SDL_LIBS@
  165.42 -
  165.43 -TestEmu_DEPENDENCIES = @VBA_LIBS@
  165.44 -
  165.45 -AM_CPPFLAGS = \
  165.46 -	-I$(top_srcdir)/src		\
  165.47 -	-DSDL				\
  165.48 -	-DSYSCONFDIR=\"$(sysconfdir)\"
  165.49 -
  165.50 -AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@
   166.1 --- a/src/sdl/RingBuffer.h	Sat Mar 03 10:54:39 2012 -0600
   166.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   166.3 @@ -1,112 +0,0 @@
   166.4 -/***************************************************************************
   166.5 - *   Copyright (C) 2008 by Sindre Aamås                                    *
   166.6 - *   aamas@stud.ntnu.no                                                    *
   166.7 - *                                                                         *
   166.8 - *   This program is free software; you can redistribute it and/or modify  *
   166.9 - *   it under the terms of the GNU General Public License version 2 as     *
  166.10 - *   published by the Free Software Foundation.                            *
  166.11 - *                                                                         *
  166.12 - *   This program is distributed in the hope that it will be useful,       *
  166.13 - *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  166.14 - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  166.15 - *   GNU General Public License version 2 for more details.                *
  166.16 - *                                                                         *
  166.17 - *   You should have received a copy of the GNU General Public License     *
  166.18 - *   version 2 along with this program; if not, write to the               *
  166.19 - *   Free Software Foundation, Inc.,                                       *
  166.20 - *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  166.21 - ***************************************************************************/
  166.22 -#ifndef RINGBUFFER_H
  166.23 -#define RINGBUFFER_H
  166.24 -
  166.25 -#include "Array.h"
  166.26 -#include <cstddef>
  166.27 -#include <algorithm>
  166.28 -#include <cstring>
  166.29 -
  166.30 -template<typename T>
  166.31 -class RingBuffer {
  166.32 -	Array<T> buf;
  166.33 -	std::size_t sz;
  166.34 -	std::size_t rpos;
  166.35 -	std::size_t wpos;
  166.36 -
  166.37 -public:
  166.38 -	RingBuffer(const std::size_t sz_in = 0) : sz(0), rpos(0), wpos(0) { reset(sz_in); }
  166.39 -
  166.40 -	std::size_t avail() const {
  166.41 -		return (wpos < rpos ? 0 : sz) + rpos - wpos - 1;
  166.42 -	}
  166.43 -
  166.44 -	void clear() {
  166.45 -		wpos = rpos = 0;
  166.46 -	}
  166.47 -
  166.48 -	void fill(T value);
  166.49 -
  166.50 -	void read(T *out, std::size_t num);
  166.51 -
  166.52 -	void reset(std::size_t sz_in);
  166.53 -
  166.54 -	std::size_t size() const {
  166.55 -		return sz - 1;
  166.56 -	}
  166.57 -
  166.58 -	std::size_t used() const {
  166.59 -		return (wpos < rpos ? sz : 0) + wpos - rpos;
  166.60 -	}
  166.61 -
  166.62 -	void write(const T *in, std::size_t num);
  166.63 -};
  166.64 -
  166.65 -template<typename T>
  166.66 -void RingBuffer<T>::fill(const T value) {
  166.67 -	std::fill(buf + 0, buf + sz, value);
  166.68 -	rpos = 0;
  166.69 -	wpos = sz - 1;
  166.70 -}
  166.71 -
  166.72 -template<typename T>
  166.73 -void RingBuffer<T>::read(T *out, std::size_t num) {
  166.74 -	if (rpos + num > sz) {
  166.75 -		const std::size_t n = sz - rpos;
  166.76 -
  166.77 -		std::memcpy(out, buf + rpos, n * sizeof(T));
  166.78 -
  166.79 -		rpos = 0;
  166.80 -		num -= n;
  166.81 -		out += n;
  166.82 -	}
  166.83 -
  166.84 -	std::memcpy(out, buf + rpos, num * sizeof(T));
  166.85 -
  166.86 -	if ((rpos += num) == sz)
  166.87 -		rpos = 0;
  166.88 -}
  166.89 -
  166.90 -template<typename T>
  166.91 -void RingBuffer<T>::reset(const std::size_t sz_in) {
  166.92 -	sz = sz_in + 1;
  166.93 -	rpos = wpos = 0;
  166.94 -	buf.reset(sz_in ? sz : 0);
  166.95 -}
  166.96 -
  166.97 -template<typename T>
  166.98 -void RingBuffer<T>::write(const T *in, std::size_t num) {
  166.99 -	if (wpos + num > sz) {
 166.100 -		const std::size_t n = sz - wpos;
 166.101 -
 166.102 -		std::memcpy(buf + wpos, in, n * sizeof(T));
 166.103 -
 166.104 -		wpos = 0;
 166.105 -		num -= n;
 166.106 -		in += n;
 166.107 -	}
 166.108 -
 166.109 -	std::memcpy(buf + wpos, in, num * sizeof(T));
 166.110 -
 166.111 -	if ((wpos += num) == sz)
 166.112 -		wpos = 0;
 166.113 -}
 166.114 -
 166.115 -#endif
   167.1 --- a/src/sdl/SDL.cpp	Sat Mar 03 10:54:39 2012 -0600
   167.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   167.3 @@ -1,3623 +0,0 @@
   167.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   167.5 -// Copyright (C) 1999-2003 Forgotten
   167.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   167.7 -
   167.8 -// This program is free software; you can redistribute it and/or modify
   167.9 -// it under the terms of the GNU General Public License as published by
  167.10 -// the Free Software Foundation; either version 2, or(at your option)
  167.11 -// any later version.
  167.12 -//
  167.13 -// This program is distributed in the hope that it will be useful,
  167.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  167.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  167.16 -// GNU General Public License for more details.
  167.17 -//
  167.18 -// You should have received a copy of the GNU General Public License
  167.19 -// along with this program; if not, write to the Free Software Foundation,
  167.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  167.21 -
  167.22 -#include <stdarg.h>
  167.23 -#include <stdlib.h>
  167.24 -#include <stdio.h>
  167.25 -#include <string.h>
  167.26 -#include <sys/types.h>
  167.27 -#include <sys/stat.h>
  167.28 -
  167.29 -#include "AutoBuild.h"
  167.30 -
  167.31 -#include "Port.h"
  167.32 -#include "SDL.h"
  167.33 -#include "debugger.h"
  167.34 -#include "gba/GBA.h"
  167.35 -#include "gba/GBAGlobals.h"
  167.36 -#include "gba/agbprint.h"
  167.37 -#include "gba/Flash.h"
  167.38 -#include "gba/RTC.h"
  167.39 -#include "gba/GBASound.h"
  167.40 -#include "gb/GB.h"
  167.41 -#include "gb/gbGlobals.h"
  167.42 -#include "common/Text.h"
  167.43 -#include "common/unzip.h"
  167.44 -#include "common/Util.h"
  167.45 -#include "common/movie.h"
  167.46 -#include "common/System.h"
  167.47 -#include "common/inputGlobal.h"
  167.48 -#include "../common/vbalua.h"
  167.49 -#include "SoundSDL.h"
  167.50 -
  167.51 -
  167.52 -#define GBC_CAPABLE ((gbRom[0x143] & 0x80) != 0)
  167.53 -#define SGB_CAPABLE (gbRom[0x146] == 0x03)
  167.54 -
  167.55 -#ifndef WIN32
  167.56 -# include <unistd.h>
  167.57 -# define GETCWD getcwd
  167.58 -#else // WIN32
  167.59 -# include <direct.h>
  167.60 -# define GETCWD _getcwd
  167.61 -#endif // WIN32
  167.62 -
  167.63 -#ifndef __GNUC__
  167.64 -# define HAVE_DECL_GETOPT 0
  167.65 -# define __STDC__ 1
  167.66 -# include "getopt.h"
  167.67 -#else // ! __GNUC__
  167.68 -# define HAVE_DECL_GETOPT 1
  167.69 -# include "getopt.h"
  167.70 -#endif // ! __GNUC__
  167.71 -
  167.72 -#ifdef MMX
  167.73 -extern "C" bool cpu_mmx;
  167.74 -#endif
  167.75 -extern bool8 soundEcho;
  167.76 -extern bool8 soundLowPass;
  167.77 -extern bool8 soundReverse;
  167.78 -extern int Init_2xSaI(u32);
  167.79 -extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int);
  167.80 -extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int);  
  167.81 -extern void Super2xSaI(u8*,u32,u8*,u8*,u32,int,int);
  167.82 -extern void Super2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
  167.83 -extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int);
  167.84 -extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int);  
  167.85 -extern void Pixelate2x16(u8*,u32,u8*,u8*,u32,int,int);
  167.86 -extern void Pixelate2x32(u8*,u32,u8*,u8*,u32,int,int);
  167.87 -extern void MotionBlur(u8*,u32,u8*,u8*,u32,int,int);
  167.88 -extern void MotionBlur32(u8*,u32,u8*,u8*,u32,int,int);
  167.89 -extern void AdMame2x(u8*,u32,u8*,u8*,u32,int,int);
  167.90 -extern void AdMame2x32(u8*,u32,u8*,u8*,u32,int,int);
  167.91 -extern void Simple2x16(u8*,u32,u8*,u8*,u32,int,int);
  167.92 -extern void Simple2x32(u8*,u32,u8*,u8*,u32,int,int);
  167.93 -extern void Bilinear(u8*,u32,u8*,u8*,u32,int,int);
  167.94 -extern void Bilinear32(u8*,u32,u8*,u8*,u32,int,int);
  167.95 -extern void BilinearPlus(u8*,u32,u8*,u8*,u32,int,int);
  167.96 -extern void BilinearPlus32(u8*,u32,u8*,u8*,u32,int,int);
  167.97 -extern void Scanlines(u8*,u32,u8*,u8*,u32,int,int);
  167.98 -extern void Scanlines32(u8*,u32,u8*,u8*,u32,int,int);
  167.99 -extern void ScanlinesTV(u8*,u32,u8*,u8*,u32,int,int);
 167.100 -extern void ScanlinesTV32(u8*,u32,u8*,u8*,u32,int,int);
 167.101 -extern void hq2x(u8*,u32,u8*,u8*,u32,int,int);
 167.102 -extern void hq2x32(u8*,u32,u8*,u8*,u32,int,int);
 167.103 -extern void lq2x(u8*,u32,u8*,u8*,u32,int,int);
 167.104 -extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int);
 167.105 -
 167.106 -extern void SmartIB(u8*,u32,int,int);
 167.107 -extern void SmartIB32(u8*,u32,int,int);
 167.108 -extern void MotionBlurIB(u8*,u32,int,int);
 167.109 -extern void MotionBlurIB32(u8*,u32,int,int);
 167.110 -
 167.111 -void Init_Overlay(SDL_Surface *surface, int overlaytype);
 167.112 -void Quit_Overlay(void);
 167.113 -void Draw_Overlay(SDL_Surface *surface, int size);
 167.114 -
 167.115 -extern void remoteInit();
 167.116 -extern void remoteCleanUp();
 167.117 -extern void remoteStubMain();
 167.118 -extern void remoteStubSignal(int,int);
 167.119 -extern void remoteOutput(char *, u32);
 167.120 -extern void remoteSetProtocol(int);
 167.121 -extern void remoteSetPort(int);
 167.122 -extern void debuggerOutput(char *, u32);
 167.123 -
 167.124 -extern void CPUUpdateRenderBuffers(bool);
 167.125 -
 167.126 -struct EmulatedSystem theEmulator = {
 167.127 -  NULL,
 167.128 -  NULL,
 167.129 -  NULL,
 167.130 -  NULL,
 167.131 -  NULL,
 167.132 -  NULL,
 167.133 -  NULL,
 167.134 -  NULL,
 167.135 -  NULL,
 167.136 -  NULL,
 167.137 -  NULL,
 167.138 -  NULL,
 167.139 -  false,
 167.140 -  0
 167.141 -};
 167.142 -
 167.143 -SDL_Surface *surface = NULL;
 167.144 -SDL_Overlay *overlay = NULL;
 167.145 -SDL_Rect overlay_rect;
 167.146 -
 167.147 -int systemSpeed = 0;
 167.148 -int systemRedShift = 0;
 167.149 -int systemBlueShift = 0;
 167.150 -int systemGreenShift = 0;
 167.151 -int systemColorDepth = 0;
 167.152 -int systemDebug = 0;
 167.153 -int systemVerbose = 0;
 167.154 -int systemFrameSkip = 0;
 167.155 -int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 167.156 -
 167.157 -int srcPitch = 0;
 167.158 -int srcWidth = 0;
 167.159 -int srcHeight = 0;
 167.160 -int destWidth = 0;
 167.161 -int destHeight = 0;
 167.162 -
 167.163 -int sensorX = 2047;
 167.164 -int sensorY = 2047;
 167.165 -bool sensorOn = false;
 167.166 -
 167.167 -int filter = 0;
 167.168 -u8 *delta = NULL;
 167.169 -
 167.170 -int sdlPrintUsage = 0;
 167.171 -int disableMMX = 0;
 167.172 -
 167.173 -int systemCartridgeType = 3;
 167.174 -int sizeOption = 0;
 167.175 -int captureFormat = 0;
 167.176 -int useMovie = 0;
 167.177 -
 167.178 -int pauseWhenInactive = 0;
 167.179 -int active = 1;
 167.180 -int emulating = 0;
 167.181 -int RGB_LOW_BITS_MASK=0x821;
 167.182 -u32 systemColorMap32[0x10000];
 167.183 -u16 systemColorMap16[0x10000];
 167.184 -u16 systemGbPalette[24];
 167.185 -void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = NULL;
 167.186 -void (*ifbFunction)(u8*,u32,int,int) = NULL;
 167.187 -int ifbType = 0;
 167.188 -char filename[2048];
 167.189 -char ipsname[2048];
 167.190 -char biosFileName[2048];
 167.191 -char movieFileName[2048];
 167.192 -char captureDir[2048];
 167.193 -char saveDir[2048];
 167.194 -char batteryDir[2048];
 167.195 -
 167.196 -static char *rewindMemory = NULL;
 167.197 -static int rewindPos = 0;
 167.198 -static int rewindTopPos = 0;
 167.199 -static int rewindCounter = 0;
 167.200 -static int rewindCount = 0;
 167.201 -static bool rewindSaveNeeded = false;
 167.202 -static int rewindTimer = 0;
 167.203 -
 167.204 -#define REWIND_SIZE 400000
 167.205 -
 167.206 -#define _stricmp strcasecmp
 167.207 -
 167.208 -/*bool sdlButtons[4][12] = {
 167.209 -  { false, false, false, false, false, false, 
 167.210 -    false, false, false, false, false, false },
 167.211 -  { false, false, false, false, false, false,
 167.212 -    false, false, false, false, false, false },
 167.213 -  { false, false, false, false, false, false,
 167.214 -    false, false, false, false, false, false },
 167.215 -  { false, false, false, false, false, false,
 167.216 -    false, false, false, false, false, false }
 167.217 -};*/
 167.218 -/*
 167.219 -	I'm changing the way the SDL GUI handles the button
 167.220 -	input to match the one in win32, this is needed in
 167.221 -	order to be compatible with the format required by
 167.222 -	common/movie.cpp
 167.223 -	--Felipe
 167.224 -*/
 167.225 -
 167.226 -u16 currentButtons[4] = {0, 0, 0, 0};
 167.227 -
 167.228 -bool sdlMotionButtons[4] = { false, false, false, false };
 167.229 -const int32 INITIAL_SENSOR_VALUE = 2047;
 167.230 -
 167.231 -int sdlNumDevices = 0;
 167.232 -SDL_Joystick **sdlDevices = NULL;
 167.233 -
 167.234 -bool wasPaused = false;
 167.235 -int autoFrameSkip = 0;
 167.236 -int frameskipadjust = 0;
 167.237 -int showRenderedFrames = 0;
 167.238 -int renderedFrames = 0;
 167.239 -
 167.240 -int throttle = 0;
 167.241 -u32 throttleLastTime = 0;
 167.242 -u32 autoFrameSkipLastTime = 0;
 167.243 -
 167.244 -int showSpeed = 1;
 167.245 -int showSpeedTransparent = 1;
 167.246 -bool disableStatusMessages = false;
 167.247 -bool paused = false;
 167.248 -bool pauseNextFrame = false;
 167.249 -bool debugger = false;
 167.250 -bool debuggerStub = false;
 167.251 -int fullscreen = 0;
 167.252 -bool systemSoundOn = false;
 167.253 -bool yuv = false;
 167.254 -int yuvType = 0;
 167.255 -bool removeIntros = false;
 167.256 -int sdlFlashSize = 0;
 167.257 -int sdlAutoIPS = 1;
 167.258 -int sdlRtcEnable = 0;
 167.259 -int sdlAgbPrint = 0;
 167.260 -
 167.261 -int sdlDefaultJoypad = 0;
 167.262 -
 167.263 -extern void debuggerSignal(int,int);
 167.264 -
 167.265 -void (*dbgMain)() = debuggerMain;
 167.266 -void (*dbgSignal)(int,int) = debuggerSignal;
 167.267 -void (*dbgOutput)(char *, u32) = debuggerOutput;
 167.268 -
 167.269 -int  mouseCounter = 0;
 167.270 -int autoFire = 0;
 167.271 -bool autoFireToggle = false;
 167.272 -
 167.273 -bool screenMessage[8] = {false,false,false,false,false,false,false,false};
 167.274 -char screenMessageBuffer[8][21];
 167.275 -u32  screenMessageTime[8] = {0,0,0,0,0,0,0,0};
 167.276 -u32  screenMessageDuration[8] = {0,0,0,0,0,0,0,0};
 167.277 -
 167.278 -SDL_cond *cond = NULL;
 167.279 -SDL_mutex *mutex = NULL;
 167.280 -u8* sdlBuffer;
 167.281 -int sdlSoundLen = 0;
 167.282 -SoundSDL* soundDriver = NULL;
 167.283 -
 167.284 -char *arg0;
 167.285 -
 167.286 -#ifndef C_CORE
 167.287 -u8 sdlStretcher[16384];
 167.288 -int sdlStretcherPos;
 167.289 -#else
 167.290 -void (*sdlStretcher)(u8 *, u8*) = NULL;
 167.291 -#endif
 167.292 -
 167.293 -u16 joypad[4][12] = {
 167.294 -  { SDLK_LEFT,  SDLK_RIGHT,
 167.295 -    SDLK_UP,    SDLK_DOWN,
 167.296 -    SDLK_z,     SDLK_x,
 167.297 -    SDLK_RETURN,SDLK_BACKSPACE,
 167.298 -    SDLK_a,     SDLK_s,
 167.299 -    SDLK_SPACE, SDLK_F12
 167.300 -  },
 167.301 -  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 167.302 -  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 167.303 -  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 167.304 -};
 167.305 -
 167.306 -u16 defaultJoypad[12] = {
 167.307 -  SDLK_LEFT,  SDLK_RIGHT,
 167.308 -  SDLK_UP,    SDLK_DOWN,
 167.309 -  SDLK_z,     SDLK_x,
 167.310 -  SDLK_RETURN,SDLK_BACKSPACE,
 167.311 -  SDLK_a,     SDLK_s,
 167.312 -  SDLK_SPACE, SDLK_F12
 167.313 -};
 167.314 -
 167.315 -u16 motion[4] = {
 167.316 -  SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
 167.317 -};
 167.318 -
 167.319 -u16 defaultMotion[4] = {
 167.320 -  SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
 167.321 -};
 167.322 -
 167.323 -struct option sdlOptions[] = {
 167.324 -  { "agb-print", no_argument, &sdlAgbPrint, 1 },
 167.325 -  { "auto-frameskip", no_argument, &autoFrameSkip, 1 },  
 167.326 -  { "bios", required_argument, 0, 'b' },
 167.327 -  { "config", required_argument, 0, 'c' },
 167.328 -  { "debug", no_argument, 0, 'd' },
 167.329 -  { "filter", required_argument, 0, 'f' },
 167.330 -  { "filter-normal", no_argument, &filter, 0 },
 167.331 -  { "filter-tv-mode", no_argument, &filter, 1 },
 167.332 -  { "filter-2xsai", no_argument, &filter, 2 },
 167.333 -  { "filter-super-2xsai", no_argument, &filter, 3 },
 167.334 -  { "filter-super-eagle", no_argument, &filter, 4 },
 167.335 -  { "filter-pixelate", no_argument, &filter, 5 },
 167.336 -  { "filter-motion-blur", no_argument, &filter, 6 },
 167.337 -  { "filter-advmame", no_argument, &filter, 7 },
 167.338 -  { "filter-simple2x", no_argument, &filter, 8 },
 167.339 -  { "filter-bilinear", no_argument, &filter, 9 },
 167.340 -  { "filter-bilinear+", no_argument, &filter, 10 },
 167.341 -  { "filter-scanlines", no_argument, &filter, 11 },
 167.342 -  { "filter-hq2x", no_argument, &filter, 12 },
 167.343 -  { "filter-lq2x", no_argument, &filter, 13 },
 167.344 -  { "flash-size", required_argument, 0, 'S' },
 167.345 -  { "flash-64k", no_argument, &sdlFlashSize, 0 },
 167.346 -  { "flash-128k", no_argument, &sdlFlashSize, 1 },
 167.347 -  { "frameskip", required_argument, 0, 's' },
 167.348 -  { "fullscreen", no_argument, &fullscreen, 1 },
 167.349 -  { "gdb", required_argument, 0, 'G' },
 167.350 -  { "help", no_argument, &sdlPrintUsage, 1 },
 167.351 -  { "ifb-none", no_argument, &ifbType, 0 },
 167.352 -  { "ifb-motion-blur", no_argument, &ifbType, 1 },
 167.353 -  { "ifb-smart", no_argument, &ifbType, 2 },
 167.354 -  { "ips", required_argument, 0, 'i' },
 167.355 -  { "no-agb-print", no_argument, &sdlAgbPrint, 0 },
 167.356 -  { "no-auto-frameskip", no_argument, &autoFrameSkip, 0 },
 167.357 -  { "no-debug", no_argument, 0, 'N' },
 167.358 -  { "no-ips", no_argument, &sdlAutoIPS, 0 },
 167.359 -  { "no-mmx", no_argument, &disableMMX, 1 },
 167.360 -  { "no-pause-when-inactive", no_argument, &pauseWhenInactive, 0 },
 167.361 -  { "no-rtc", no_argument, &sdlRtcEnable, 0 },
 167.362 -  { "no-show-speed", no_argument, &showSpeed, 0 },
 167.363 -  { "no-throttle", no_argument, &throttle, 0 },
 167.364 -  { "pause-when-inactive", no_argument, &pauseWhenInactive, 1 },
 167.365 -  { "profile", optional_argument, 0, 'P' },
 167.366 -  { "rtc", no_argument, &sdlRtcEnable, 1 },
 167.367 -  { "save-type", required_argument, 0, 't' },
 167.368 -  { "save-auto", no_argument, &cpuSaveType, 0 },
 167.369 -  { "save-eeprom", no_argument, &cpuSaveType, 1 },
 167.370 -  { "save-sram", no_argument, &cpuSaveType, 2 },
 167.371 -  { "save-flash", no_argument, &cpuSaveType, 3 },
 167.372 -  { "save-sensor", no_argument, &cpuSaveType, 4 },
 167.373 -  { "save-none", no_argument, &cpuSaveType, 5 },
 167.374 -  { "show-speed-normal", no_argument, &showSpeed, 1 },
 167.375 -  { "show-speed-detailed", no_argument, &showSpeed, 2 },
 167.376 -  { "throttle", required_argument, 0, 'T' },
 167.377 -  { "verbose", required_argument, 0, 'v' },  
 167.378 -  { "video-1x", no_argument, &sizeOption, 0 },
 167.379 -  { "video-2x", no_argument, &sizeOption, 1 },
 167.380 -  { "video-3x", no_argument, &sizeOption, 2 },
 167.381 -  { "video-4x", no_argument, &sizeOption, 3 },
 167.382 -  { "yuv", required_argument, 0, 'Y' },
 167.383 -  { "recordmovie", required_argument, 0, 'r' },
 167.384 -  { "playmovie", required_argument, 0, 'p' },
 167.385 -  { "watchmovie", required_argument, 0, 'w' },
 167.386 -  { NULL, no_argument, NULL, 0 }
 167.387 -};
 167.388 -
 167.389 -#ifndef C_CORE
 167.390 -#define SDL_LONG(val) \
 167.391 -  *((u32 *)&sdlStretcher[sdlStretcherPos]) = val;\
 167.392 -  sdlStretcherPos+=4;
 167.393 -
 167.394 -#define SDL_AND_EAX(val) \
 167.395 -  sdlStretcher[sdlStretcherPos++] = 0x25;\
 167.396 -  SDL_LONG(val);
 167.397 -
 167.398 -#define SDL_AND_EBX(val) \
 167.399 -  sdlStretcher[sdlStretcherPos++] = 0x81;\
 167.400 -  sdlStretcher[sdlStretcherPos++] = 0xe3;\
 167.401 -  SDL_LONG(val);
 167.402 -
 167.403 -#define SDL_OR_EAX_EBX \
 167.404 -  sdlStretcher[sdlStretcherPos++] = 0x09;\
 167.405 -  sdlStretcher[sdlStretcherPos++] = 0xd8;
 167.406 -
 167.407 -#define SDL_LOADL_EBX \
 167.408 -  sdlStretcher[sdlStretcherPos++] = 0x8b;\
 167.409 -  sdlStretcher[sdlStretcherPos++] = 0x1f;
 167.410 -
 167.411 -#define SDL_LOADW \
 167.412 -  sdlStretcher[sdlStretcherPos++] = 0x66;\
 167.413 -  sdlStretcher[sdlStretcherPos++] = 0x8b;\
 167.414 -  sdlStretcher[sdlStretcherPos++] = 0x06;\
 167.415 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.416 -  sdlStretcher[sdlStretcherPos++] = 0xc6;\
 167.417 -  sdlStretcher[sdlStretcherPos++] = 0x02;  
 167.418 -
 167.419 -#define SDL_LOADL \
 167.420 -  sdlStretcher[sdlStretcherPos++] = 0x8b;\
 167.421 -  sdlStretcher[sdlStretcherPos++] = 0x06;\
 167.422 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.423 -  sdlStretcher[sdlStretcherPos++] = 0xc6;\
 167.424 -  sdlStretcher[sdlStretcherPos++] = 0x04;  
 167.425 -
 167.426 -#define SDL_LOADL2 \
 167.427 -  sdlStretcher[sdlStretcherPos++] = 0x8b;\
 167.428 -  sdlStretcher[sdlStretcherPos++] = 0x06;\
 167.429 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.430 -  sdlStretcher[sdlStretcherPos++] = 0xc6;\
 167.431 -  sdlStretcher[sdlStretcherPos++] = 0x03;  
 167.432 -
 167.433 -#define SDL_STOREW \
 167.434 -  sdlStretcher[sdlStretcherPos++] = 0x66;\
 167.435 -  sdlStretcher[sdlStretcherPos++] = 0x89;\
 167.436 -  sdlStretcher[sdlStretcherPos++] = 0x07;\
 167.437 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.438 -  sdlStretcher[sdlStretcherPos++] = 0xc7;\
 167.439 -  sdlStretcher[sdlStretcherPos++] = 0x02;  
 167.440 -
 167.441 -#define SDL_STOREL \
 167.442 -  sdlStretcher[sdlStretcherPos++] = 0x89;\
 167.443 -  sdlStretcher[sdlStretcherPos++] = 0x07;\
 167.444 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.445 -  sdlStretcher[sdlStretcherPos++] = 0xc7;\
 167.446 -  sdlStretcher[sdlStretcherPos++] = 0x04;  
 167.447 -
 167.448 -#define SDL_STOREL2 \
 167.449 -  sdlStretcher[sdlStretcherPos++] = 0x89;\
 167.450 -  sdlStretcher[sdlStretcherPos++] = 0x07;\
 167.451 -  sdlStretcher[sdlStretcherPos++] = 0x83;\
 167.452 -  sdlStretcher[sdlStretcherPos++] = 0xc7;\
 167.453 -  sdlStretcher[sdlStretcherPos++] = 0x03;  
 167.454 -
 167.455 -#define SDL_RET \
 167.456 -  sdlStretcher[sdlStretcherPos++] = 0xc3;
 167.457 -
 167.458 -#define SDL_PUSH_EAX \
 167.459 -  sdlStretcher[sdlStretcherPos++] = 0x50;
 167.460 -
 167.461 -#define SDL_PUSH_ECX \
 167.462 -  sdlStretcher[sdlStretcherPos++] = 0x51;
 167.463 -
 167.464 -#define SDL_PUSH_EBX \
 167.465 -  sdlStretcher[sdlStretcherPos++] = 0x53;
 167.466 -
 167.467 -#define SDL_PUSH_ESI \
 167.468 -  sdlStretcher[sdlStretcherPos++] = 0x56;
 167.469 -
 167.470 -#define SDL_PUSH_EDI \
 167.471 -  sdlStretcher[sdlStretcherPos++] = 0x57;
 167.472 -
 167.473 -#define SDL_POP_EAX \
 167.474 -  sdlStretcher[sdlStretcherPos++] = 0x58;
 167.475 -
 167.476 -#define SDL_POP_ECX \
 167.477 -  sdlStretcher[sdlStretcherPos++] = 0x59;
 167.478 -
 167.479 -#define SDL_POP_EBX \
 167.480 -  sdlStretcher[sdlStretcherPos++] = 0x5b;
 167.481 -
 167.482 -#define SDL_POP_ESI \
 167.483 -  sdlStretcher[sdlStretcherPos++] = 0x5e;
 167.484 -
 167.485 -#define SDL_POP_EDI \
 167.486 -  sdlStretcher[sdlStretcherPos++] = 0x5f;
 167.487 -
 167.488 -#define SDL_MOV_ECX(val) \
 167.489 -  sdlStretcher[sdlStretcherPos++] = 0xb9;\
 167.490 -  SDL_LONG(val);
 167.491 -
 167.492 -#define SDL_REP_MOVSB \
 167.493 -  sdlStretcher[sdlStretcherPos++] = 0xf3;\
 167.494 -  sdlStretcher[sdlStretcherPos++] = 0xa4;
 167.495 -
 167.496 -#define SDL_REP_MOVSW \
 167.497 -  sdlStretcher[sdlStretcherPos++] = 0xf3;\
 167.498 -  sdlStretcher[sdlStretcherPos++] = 0x66;\
 167.499 -  sdlStretcher[sdlStretcherPos++] = 0xa5;
 167.500 -
 167.501 -#define SDL_REP_MOVSL \
 167.502 -  sdlStretcher[sdlStretcherPos++] = 0xf3;\
 167.503 -  sdlStretcher[sdlStretcherPos++] = 0xa5;
 167.504 -
 167.505 -void sdlMakeStretcher(int width)
 167.506 -{
 167.507 -  sdlStretcherPos = 0;
 167.508 -  switch(systemColorDepth) {
 167.509 -  case 16:
 167.510 -    if(sizeOption) {
 167.511 -      SDL_PUSH_EAX;
 167.512 -      SDL_PUSH_ESI;
 167.513 -      SDL_PUSH_EDI;
 167.514 -      for(int i = 0; i < width; i++) {
 167.515 -        SDL_LOADW;
 167.516 -        SDL_STOREW;
 167.517 -        SDL_STOREW;
 167.518 -        if(sizeOption > 1) {
 167.519 -          SDL_STOREW;
 167.520 -        }
 167.521 -        if(sizeOption > 2) {
 167.522 -          SDL_STOREW;
 167.523 -        }
 167.524 -      }
 167.525 -      SDL_POP_EDI;
 167.526 -      SDL_POP_ESI;
 167.527 -      SDL_POP_EAX;
 167.528 -      SDL_RET;
 167.529 -    } else {
 167.530 -      SDL_PUSH_ESI;
 167.531 -      SDL_PUSH_EDI;
 167.532 -      SDL_PUSH_ECX;
 167.533 -      SDL_MOV_ECX(width);
 167.534 -      SDL_REP_MOVSW;
 167.535 -      SDL_POP_ECX;
 167.536 -      SDL_POP_EDI;
 167.537 -      SDL_POP_ESI;
 167.538 -      SDL_RET;
 167.539 -    }
 167.540 -    break;
 167.541 -  case 24:
 167.542 -    if(sizeOption) {
 167.543 -      SDL_PUSH_EAX;
 167.544 -      SDL_PUSH_ESI;
 167.545 -      SDL_PUSH_EDI;
 167.546 -      int w = width - 1;
 167.547 -      for(int i = 0; i < w; i++) {
 167.548 -        SDL_LOADL2;
 167.549 -        SDL_STOREL2;
 167.550 -        SDL_STOREL2;
 167.551 -        if(sizeOption > 1) {
 167.552 -          SDL_STOREL2;
 167.553 -        }
 167.554 -        if(sizeOption > 2) {
 167.555 -          SDL_STOREL2;
 167.556 -        }
 167.557 -      }
 167.558 -      // need to write the last one
 167.559 -      SDL_LOADL2;
 167.560 -      SDL_STOREL2;
 167.561 -      if(sizeOption > 1) {
 167.562 -        SDL_STOREL2;
 167.563 -      }
 167.564 -      if(sizeOption > 2) {
 167.565 -        SDL_STOREL2;
 167.566 -      }
 167.567 -      SDL_AND_EAX(0x00ffffff);
 167.568 -      SDL_PUSH_EBX;
 167.569 -      SDL_LOADL_EBX;
 167.570 -      SDL_AND_EBX(0xff000000);
 167.571 -      SDL_OR_EAX_EBX;
 167.572 -      SDL_POP_EBX;
 167.573 -      SDL_STOREL2;
 167.574 -      SDL_POP_EDI;
 167.575 -      SDL_POP_ESI;
 167.576 -      SDL_POP_EAX;
 167.577 -      SDL_RET;
 167.578 -    } else {
 167.579 -      SDL_PUSH_ESI;
 167.580 -      SDL_PUSH_EDI;
 167.581 -      SDL_PUSH_ECX;
 167.582 -      SDL_MOV_ECX(3*width);
 167.583 -      SDL_REP_MOVSB;
 167.584 -      SDL_POP_ECX;
 167.585 -      SDL_POP_EDI;
 167.586 -      SDL_POP_ESI;
 167.587 -      SDL_RET;
 167.588 -    }
 167.589 -    break;
 167.590 -  case 32:
 167.591 -    if(sizeOption) {
 167.592 -      SDL_PUSH_EAX;
 167.593 -      SDL_PUSH_ESI;
 167.594 -      SDL_PUSH_EDI;
 167.595 -      for(int i = 0; i < width; i++) {
 167.596 -        SDL_LOADL;
 167.597 -        SDL_STOREL;
 167.598 -        SDL_STOREL;
 167.599 -        if(sizeOption > 1) {
 167.600 -          SDL_STOREL;
 167.601 -        }
 167.602 -        if(sizeOption > 2) {
 167.603 -          SDL_STOREL;
 167.604 -        }
 167.605 -      }
 167.606 -      SDL_POP_EDI;
 167.607 -      SDL_POP_ESI;
 167.608 -      SDL_POP_EAX;
 167.609 -      SDL_RET;
 167.610 -    } else {
 167.611 -      SDL_PUSH_ESI;
 167.612 -      SDL_PUSH_EDI;
 167.613 -      SDL_PUSH_ECX;
 167.614 -      SDL_MOV_ECX(width);
 167.615 -      SDL_REP_MOVSL;
 167.616 -      SDL_POP_ECX;
 167.617 -      SDL_POP_EDI;
 167.618 -      SDL_POP_ESI;
 167.619 -      SDL_RET;
 167.620 -    }
 167.621 -    break;
 167.622 -  }
 167.623 -}
 167.624 -
 167.625 -#ifdef _MSC_VER
 167.626 -#define SDL_CALL_STRETCHER \
 167.627 -  {\
 167.628 -    __asm mov eax, stretcher\
 167.629 -    __asm mov edi, dest\
 167.630 -    __asm mov esi, src\
 167.631 -    __asm call eax\
 167.632 -  }
 167.633 -#else
 167.634 -#define SDL_CALL_STRETCHER \
 167.635 -        asm volatile("call *%%eax"::"a" (stretcher),"S" (src),"D" (dest))
 167.636 -#endif
 167.637 -#else
 167.638 -#define SDL_CALL_STRETCHER \
 167.639 -       sdlStretcher(src, dest)
 167.640 -
 167.641 -void sdlStretch16x1(u8 *src, u8 *dest)
 167.642 -{
 167.643 -  u16 *s = (u16 *)src;
 167.644 -  u16 *d = (u16 *)dest;
 167.645 -  for(int i = 0; i < srcWidth; i++)
 167.646 -    *d++ = *s++;
 167.647 -}
 167.648 -
 167.649 -void sdlStretch16x2(u8 *src, u8 *dest)
 167.650 -{
 167.651 -  u16 *s = (u16 *)src;
 167.652 -  u16 *d = (u16 *)dest;
 167.653 -  for(int i = 0; i < srcWidth; i++) {
 167.654 -    *d++ = *s;
 167.655 -    *d++ = *s++;
 167.656 -  }
 167.657 -}
 167.658 -
 167.659 -void sdlStretch16x3(u8 *src, u8 *dest)
 167.660 -{
 167.661 -  u16 *s = (u16 *)src;
 167.662 -  u16 *d = (u16 *)dest;
 167.663 -  for(int i = 0; i < srcWidth; i++) {
 167.664 -    *d++ = *s;
 167.665 -    *d++ = *s;
 167.666 -    *d++ = *s++;
 167.667 -  }
 167.668 -}
 167.669 -
 167.670 -void sdlStretch16x4(u8 *src, u8 *dest)
 167.671 -{
 167.672 -  u16 *s = (u16 *)src;
 167.673 -  u16 *d = (u16 *)dest;
 167.674 -  for(int i = 0; i < srcWidth; i++) {
 167.675 -    *d++ = *s;
 167.676 -    *d++ = *s;
 167.677 -    *d++ = *s;
 167.678 -    *d++ = *s++;
 167.679 -  }
 167.680 -}
 167.681 -
 167.682 -void (*sdlStretcher16[4])(u8 *, u8 *) = {
 167.683 -  sdlStretch16x1,
 167.684 -  sdlStretch16x2,
 167.685 -  sdlStretch16x3,
 167.686 -  sdlStretch16x4
 167.687 -};
 167.688 -
 167.689 -void sdlStretch32x1(u8 *src, u8 *dest)
 167.690 -{
 167.691 -  u32 *s = (u32 *)src;
 167.692 -  u32 *d = (u32 *)dest;
 167.693 -  for(int i = 0; i < srcWidth; i++)
 167.694 -    *d++ = *s++;
 167.695 -}
 167.696 -
 167.697 -void sdlStretch32x2(u8 *src, u8 *dest)
 167.698 -{
 167.699 -  u32 *s = (u32 *)src;
 167.700 -  u32 *d = (u32 *)dest;
 167.701 -  for(int i = 0; i < srcWidth; i++) {
 167.702 -    *d++ = *s;
 167.703 -    *d++ = *s++;
 167.704 -  }
 167.705 -}
 167.706 -
 167.707 -void sdlStretch32x3(u8 *src, u8 *dest)
 167.708 -{
 167.709 -  u32 *s = (u32 *)src;
 167.710 -  u32 *d = (u32 *)dest;
 167.711 -  for(int i = 0; i < srcWidth; i++) {
 167.712 -    *d++ = *s;
 167.713 -    *d++ = *s;
 167.714 -    *d++ = *s++;
 167.715 -  }
 167.716 -}
 167.717 -
 167.718 -void sdlStretch32x4(u8 *src, u8 *dest)
 167.719 -{
 167.720 -  u32 *s = (u32 *)src;
 167.721 -  u32 *d = (u32 *)dest;
 167.722 -  for(int i = 0; i < srcWidth; i++) {
 167.723 -    *d++ = *s;
 167.724 -    *d++ = *s;
 167.725 -    *d++ = *s;
 167.726 -    *d++ = *s++;
 167.727 -  }
 167.728 -}
 167.729 -
 167.730 -void (*sdlStretcher32[4])(u8 *, u8 *) = {
 167.731 -  sdlStretch32x1,
 167.732 -  sdlStretch32x2,
 167.733 -  sdlStretch32x3,
 167.734 -  sdlStretch32x4
 167.735 -};
 167.736 -
 167.737 -void sdlStretch24x1(u8 *src, u8 *dest)
 167.738 -{
 167.739 -  u8 *s = src;
 167.740 -  u8 *d = dest;
 167.741 -  for(int i = 0; i < srcWidth; i++) {
 167.742 -    *d++ = *s++;
 167.743 -    *d++ = *s++;
 167.744 -    *d++ = *s++;
 167.745 -  }
 167.746 -}
 167.747 -
 167.748 -void sdlStretch24x2(u8 *src, u8 *dest)
 167.749 -{
 167.750 -  u8 *s = (u8 *)src;
 167.751 -  u8 *d = (u8 *)dest;
 167.752 -  for(int i = 0; i < srcWidth; i++) {
 167.753 -    *d++ = *s;
 167.754 -    *d++ = *(s+1);
 167.755 -    *d++ = *(s+2);
 167.756 -    s += 3;
 167.757 -    *d++ = *s;
 167.758 -    *d++ = *(s+1);
 167.759 -    *d++ = *(s+2);
 167.760 -    s += 3;
 167.761 -  }
 167.762 -}
 167.763 -
 167.764 -void sdlStretch24x3(u8 *src, u8 *dest)
 167.765 -{
 167.766 -  u8 *s = (u8 *)src;
 167.767 -  u8 *d = (u8 *)dest;
 167.768 -  for(int i = 0; i < srcWidth; i++) {
 167.769 -    *d++ = *s;
 167.770 -    *d++ = *(s+1);
 167.771 -    *d++ = *(s+2);
 167.772 -    s += 3;
 167.773 -    *d++ = *s;
 167.774 -    *d++ = *(s+1);
 167.775 -    *d++ = *(s+2);
 167.776 -    s += 3;
 167.777 -    *d++ = *s;
 167.778 -    *d++ = *(s+1);
 167.779 -    *d++ = *(s+2);
 167.780 -    s += 3;
 167.781 -  }
 167.782 -}
 167.783 -
 167.784 -void sdlStretch24x4(u8 *src, u8 *dest)
 167.785 -{
 167.786 -  u8 *s = (u8 *)src;
 167.787 -  u8 *d = (u8 *)dest;
 167.788 -  for(int i = 0; i < srcWidth; i++) {
 167.789 -    *d++ = *s;
 167.790 -    *d++ = *(s+1);
 167.791 -    *d++ = *(s+2);
 167.792 -    s += 3;
 167.793 -    *d++ = *s;
 167.794 -    *d++ = *(s+1);
 167.795 -    *d++ = *(s+2);
 167.796 -    s += 3;
 167.797 -    *d++ = *s;
 167.798 -    *d++ = *(s+1);
 167.799 -    *d++ = *(s+2);
 167.800 -    s += 3;
 167.801 -    *d++ = *s;
 167.802 -    *d++ = *(s+1);
 167.803 -    *d++ = *(s+2);
 167.804 -    s += 3;
 167.805 -  }
 167.806 -}
 167.807 -
 167.808 -void (*sdlStretcher24[4])(u8 *, u8 *) = {
 167.809 -  sdlStretch24x1,
 167.810 -  sdlStretch24x2,
 167.811 -  sdlStretch24x3,
 167.812 -  sdlStretch24x4
 167.813 -};
 167.814 -
 167.815 -#endif
 167.816 -
 167.817 -u32 sdlFromHex(char *s)
 167.818 -{
 167.819 -  u32 value;
 167.820 -  sscanf(s, "%x", &value);
 167.821 -  return value;
 167.822 -}
 167.823 -
 167.824 -#ifdef __MSC__
 167.825 -#define stat _stat
 167.826 -#define S_IFDIR _S_IFDIR
 167.827 -#endif
 167.828 -
 167.829 -void sdlCheckDirectory(char *dir)
 167.830 -{
 167.831 -  struct stat buf;
 167.832 -
 167.833 -  int len = strlen(dir);
 167.834 -
 167.835 -  char *p = dir + len - 1;
 167.836 -
 167.837 -  if(*p == '/' ||
 167.838 -     *p == '\\')
 167.839 -    *p = 0;
 167.840 -  
 167.841 -  if(stat(dir, &buf) == 0) {
 167.842 -    if(!(buf.st_mode & S_IFDIR)) {
 167.843 -      fprintf(stderr, "Error: %s is not a directory\n", dir);
 167.844 -      dir[0] = 0;
 167.845 -    }
 167.846 -  } else {
 167.847 -    fprintf(stderr, "Error: %s does not exist\n", dir);
 167.848 -    dir[0] = 0;
 167.849 -  }
 167.850 -}
 167.851 -
 167.852 -char *sdlGetFilename(char *name)
 167.853 -{
 167.854 -  static char filebuffer[2048];
 167.855 -
 167.856 -  int len = strlen(name);
 167.857 -  
 167.858 -  char *p = name + len - 1;
 167.859 -  
 167.860 -  while(true) {
 167.861 -    if(*p == '/' ||
 167.862 -       *p == '\\') {
 167.863 -      p++;
 167.864 -      break;
 167.865 -    }
 167.866 -    len--;
 167.867 -    p--;
 167.868 -    if(len == 0)
 167.869 -      break;
 167.870 -  }
 167.871 -  
 167.872 -  if(len == 0)
 167.873 -    strcpy(filebuffer, name);
 167.874 -  else
 167.875 -    strcpy(filebuffer, p);
 167.876 -  return filebuffer;
 167.877 -}
 167.878 -
 167.879 -FILE *sdlFindFile(const char *name)
 167.880 -{
 167.881 -  char buffer[4096];
 167.882 -  char path[2048];
 167.883 -
 167.884 -#ifdef WIN32
 167.885 -#define PATH_SEP ";"
 167.886 -#define FILE_SEP '\\'
 167.887 -#define EXE_NAME "VisualBoyAdvance-SDL.exe"
 167.888 -#else // ! WIN32
 167.889 -#define PATH_SEP ":"
 167.890 -#define FILE_SEP '/'
 167.891 -#define EXE_NAME "VisualBoyAdvance"
 167.892 -#endif // ! WIN32
 167.893 -
 167.894 -  fprintf(stderr, "Searching for file %s\n", name);
 167.895 -  
 167.896 -  if(GETCWD(buffer, 2048)) {
 167.897 -    fprintf(stderr, "Searching current directory: %s\n", buffer);
 167.898 -  }
 167.899 -  
 167.900 -  FILE *f = fopen(name, "r");
 167.901 -  if(f != NULL) {
 167.902 -    return f;
 167.903 -  }
 167.904 -
 167.905 -  char *home = getenv("HOME");
 167.906 -
 167.907 -  if(home != NULL) {
 167.908 -    fprintf(stderr, "Searching home directory: %s\n", home);
 167.909 -    sprintf(path, "%s%c%s", home, FILE_SEP, name);
 167.910 -    f = fopen(path, "r");
 167.911 -    if(f != NULL)
 167.912 -      return f;
 167.913 -  }
 167.914 -
 167.915 -#ifdef WIN32
 167.916 -  home = getenv("USERPROFILE");
 167.917 -  if(home != NULL) {
 167.918 -    fprintf(stderr, "Searching user profile directory: %s\n", home);
 167.919 -    sprintf(path, "%s%c%s", home, FILE_SEP, name);
 167.920 -    f = fopen(path, "r");
 167.921 -    if(f != NULL)
 167.922 -      return f;
 167.923 -  }
 167.924 -#else // ! WIN32
 167.925 -    fprintf(stderr, "Searching system config directory: %s\n", SYSCONFDIR);
 167.926 -    sprintf(path, "%s%c%s", SYSCONFDIR, FILE_SEP, name);
 167.927 -    f = fopen(path, "r");
 167.928 -    if(f != NULL)
 167.929 -      return f;
 167.930 -#endif // ! WIN32
 167.931 -
 167.932 -  if(!strchr(arg0, '/') &&
 167.933 -     !strchr(arg0, '\\')) {
 167.934 -    char *path = getenv("PATH");
 167.935 -
 167.936 -    if(path != NULL) {
 167.937 -      fprintf(stderr, "Searching PATH\n");
 167.938 -      strncpy(buffer, path, 4096);
 167.939 -      buffer[4095] = 0;
 167.940 -      char *tok = strtok(buffer, PATH_SEP);
 167.941 -      
 167.942 -      while(tok) {
 167.943 -        sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME);
 167.944 -        f = fopen(path, "r");
 167.945 -        if(f != NULL) {
 167.946 -          char path2[2048];
 167.947 -          fclose(f);
 167.948 -          sprintf(path2, "%s%c%s", tok, FILE_SEP, name);
 167.949 -          f = fopen(path2, "r");
 167.950 -          if(f != NULL) {
 167.951 -            fprintf(stderr, "Found at %s\n", path2);
 167.952 -            return f;
 167.953 -          }
 167.954 -        }
 167.955 -        tok = strtok(NULL, PATH_SEP);
 167.956 -      }
 167.957 -    }
 167.958 -  } else {
 167.959 -    // executable is relative to some directory
 167.960 -    fprintf(stderr, "Searching executable directory\n");
 167.961 -    strcpy(buffer, arg0);
 167.962 -    char *p = strrchr(buffer, FILE_SEP);
 167.963 -    if(p) {
 167.964 -      *p = 0;
 167.965 -      sprintf(path, "%s%c%s", buffer, FILE_SEP, name);
 167.966 -      f = fopen(path, "r");
 167.967 -      if(f != NULL)
 167.968 -        return f;
 167.969 -    }
 167.970 -  }
 167.971 -  return NULL;
 167.972 -}
 167.973 -
 167.974 -void sdlReadPreferences(FILE *f)
 167.975 -{
 167.976 -  char buffer[2048];
 167.977 -  
 167.978 -  while(1) {
 167.979 -    char *s = fgets(buffer, 2048, f);
 167.980 -
 167.981 -    if(s == NULL)
 167.982 -      break;
 167.983 -
 167.984 -    char *p  = strchr(s, '#');
 167.985 -    
 167.986 -    if(p)
 167.987 -      *p = 0;
 167.988 -    
 167.989 -    char *token = strtok(s, " \t\n\r=");
 167.990 -
 167.991 -    if(!token)
 167.992 -      continue;
 167.993 -
 167.994 -    if(strlen(token) == 0)
 167.995 -      continue;
 167.996 -
 167.997 -    char *key = token;
 167.998 -    char *value = strtok(NULL, "\t\n\r");
 167.999 -
167.1000 -    if(value == NULL) {
167.1001 -      fprintf(stderr, "Empty value for key %s\n", key);
167.1002 -      continue;
167.1003 -    }
167.1004 -
167.1005 -    if(!strcmp(key,"Joy0_Left")) {
167.1006 -      joypad[0][KEY_LEFT] = sdlFromHex(value);
167.1007 -    } else if(!strcmp(key, "Joy0_Right")) {
167.1008 -      joypad[0][KEY_RIGHT] = sdlFromHex(value);
167.1009 -    } else if(!strcmp(key, "Joy0_Up")) {
167.1010 -      joypad[0][KEY_UP] = sdlFromHex(value);
167.1011 -    } else if(!strcmp(key, "Joy0_Down")) {
167.1012 -      joypad[0][KEY_DOWN] = sdlFromHex(value);
167.1013 -    } else if(!strcmp(key, "Joy0_A")) {
167.1014 -      joypad[0][KEY_BUTTON_A] = sdlFromHex(value);
167.1015 -    } else if(!strcmp(key, "Joy0_B")) {
167.1016 -      joypad[0][KEY_BUTTON_B] = sdlFromHex(value);
167.1017 -    } else if(!strcmp(key, "Joy0_L")) {
167.1018 -      joypad[0][KEY_BUTTON_L] = sdlFromHex(value);
167.1019 -    } else if(!strcmp(key, "Joy0_R")) {
167.1020 -      joypad[0][KEY_BUTTON_R] = sdlFromHex(value);
167.1021 -    } else if(!strcmp(key, "Joy0_Start")) {
167.1022 -      joypad[0][KEY_BUTTON_START] = sdlFromHex(value);
167.1023 -    } else if(!strcmp(key, "Joy0_Select")) {
167.1024 -      joypad[0][KEY_BUTTON_SELECT] = sdlFromHex(value);
167.1025 -    } else if(!strcmp(key, "Joy0_Speed")) {
167.1026 -      joypad[0][KEY_BUTTON_SPEED] = sdlFromHex(value);
167.1027 -    } else if(!strcmp(key, "Joy0_Capture")) {
167.1028 -      joypad[0][KEY_BUTTON_CAPTURE] = sdlFromHex(value);
167.1029 -    } else if(!strcmp(key,"Joy1_Left")) {
167.1030 -      joypad[1][KEY_LEFT] = sdlFromHex(value);
167.1031 -    } else if(!strcmp(key, "Joy1_Right")) {
167.1032 -      joypad[1][KEY_RIGHT] = sdlFromHex(value);
167.1033 -    } else if(!strcmp(key, "Joy1_Up")) {
167.1034 -      joypad[1][KEY_UP] = sdlFromHex(value);
167.1035 -    } else if(!strcmp(key, "Joy1_Down")) {
167.1036 -      joypad[1][KEY_DOWN] = sdlFromHex(value);
167.1037 -    } else if(!strcmp(key, "Joy1_A")) {
167.1038 -      joypad[1][KEY_BUTTON_A] = sdlFromHex(value);
167.1039 -    } else if(!strcmp(key, "Joy1_B")) {
167.1040 -      joypad[1][KEY_BUTTON_B] = sdlFromHex(value);
167.1041 -    } else if(!strcmp(key, "Joy1_L")) {
167.1042 -      joypad[1][KEY_BUTTON_L] = sdlFromHex(value);
167.1043 -    } else if(!strcmp(key, "Joy1_R")) {
167.1044 -      joypad[1][KEY_BUTTON_R] = sdlFromHex(value);
167.1045 -    } else if(!strcmp(key, "Joy1_Start")) {
167.1046 -      joypad[1][KEY_BUTTON_START] = sdlFromHex(value);
167.1047 -    } else if(!strcmp(key, "Joy1_Select")) {
167.1048 -      joypad[1][KEY_BUTTON_SELECT] = sdlFromHex(value);
167.1049 -    } else if(!strcmp(key, "Joy1_Speed")) {
167.1050 -      joypad[1][KEY_BUTTON_SPEED] = sdlFromHex(value);
167.1051 -    } else if(!strcmp(key, "Joy1_Capture")) {
167.1052 -      joypad[1][KEY_BUTTON_CAPTURE] = sdlFromHex(value);
167.1053 -    } else if(!strcmp(key,"Joy2_Left")) {
167.1054 -      joypad[2][KEY_LEFT] = sdlFromHex(value);
167.1055 -    } else if(!strcmp(key, "Joy2_Right")) {
167.1056 -      joypad[2][KEY_RIGHT] = sdlFromHex(value);
167.1057 -    } else if(!strcmp(key, "Joy2_Up")) {
167.1058 -      joypad[2][KEY_UP] = sdlFromHex(value);
167.1059 -    } else if(!strcmp(key, "Joy2_Down")) {
167.1060 -      joypad[2][KEY_DOWN] = sdlFromHex(value);
167.1061 -    } else if(!strcmp(key, "Joy2_A")) {
167.1062 -      joypad[2][KEY_BUTTON_A] = sdlFromHex(value);
167.1063 -    } else if(!strcmp(key, "Joy2_B")) {
167.1064 -      joypad[2][KEY_BUTTON_B] = sdlFromHex(value);
167.1065 -    } else if(!strcmp(key, "Joy2_L")) {
167.1066 -      joypad[2][KEY_BUTTON_L] = sdlFromHex(value);
167.1067 -    } else if(!strcmp(key, "Joy2_R")) {
167.1068 -      joypad[2][KEY_BUTTON_R] = sdlFromHex(value);
167.1069 -    } else if(!strcmp(key, "Joy2_Start")) {
167.1070 -      joypad[2][KEY_BUTTON_START] = sdlFromHex(value);
167.1071 -    } else if(!strcmp(key, "Joy2_Select")) {
167.1072 -      joypad[2][KEY_BUTTON_SELECT] = sdlFromHex(value);
167.1073 -    } else if(!strcmp(key, "Joy2_Speed")) {
167.1074 -      joypad[2][KEY_BUTTON_SPEED] = sdlFromHex(value);
167.1075 -    } else if(!strcmp(key, "Joy2_Capture")) {
167.1076 -      joypad[2][KEY_BUTTON_CAPTURE] = sdlFromHex(value);
167.1077 -    } else if(!strcmp(key,"Joy4_Left")) {
167.1078 -      joypad[4][KEY_LEFT] = sdlFromHex(value);
167.1079 -    } else if(!strcmp(key, "Joy4_Right")) {
167.1080 -      joypad[4][KEY_RIGHT] = sdlFromHex(value);
167.1081 -    } else if(!strcmp(key, "Joy4_Up")) {
167.1082 -      joypad[4][KEY_UP] = sdlFromHex(value);
167.1083 -    } else if(!strcmp(key, "Joy4_Down")) {
167.1084 -      joypad[4][KEY_DOWN] = sdlFromHex(value);
167.1085 -    } else if(!strcmp(key, "Joy4_A")) {
167.1086 -      joypad[4][KEY_BUTTON_A] = sdlFromHex(value);
167.1087 -    } else if(!strcmp(key, "Joy4_B")) {
167.1088 -      joypad[4][KEY_BUTTON_B] = sdlFromHex(value);
167.1089 -    } else if(!strcmp(key, "Joy4_L")) {
167.1090 -      joypad[4][KEY_BUTTON_L] = sdlFromHex(value);
167.1091 -    } else if(!strcmp(key, "Joy4_R")) {
167.1092 -      joypad[4][KEY_BUTTON_R] = sdlFromHex(value);
167.1093 -    } else if(!strcmp(key, "Joy4_Start")) {
167.1094 -      joypad[4][KEY_BUTTON_START] = sdlFromHex(value);
167.1095 -    } else if(!strcmp(key, "Joy4_Select")) {
167.1096 -      joypad[4][KEY_BUTTON_SELECT] = sdlFromHex(value);
167.1097 -    } else if(!strcmp(key, "Joy4_Speed")) {
167.1098 -      joypad[4][KEY_BUTTON_SPEED] = sdlFromHex(value);
167.1099 -    } else if(!strcmp(key, "Joy4_Capture")) {
167.1100 -      joypad[4][KEY_BUTTON_CAPTURE] = sdlFromHex(value);
167.1101 -    } else if(!strcmp(key, "Motion_Left")) {
167.1102 -      motion[KEY_LEFT] = sdlFromHex(value);
167.1103 -    } else if(!strcmp(key, "Motion_Right")) {
167.1104 -      motion[KEY_RIGHT] = sdlFromHex(value);
167.1105 -    } else if(!strcmp(key, "Motion_Up")) {
167.1106 -      motion[KEY_UP] = sdlFromHex(value);
167.1107 -    } else if(!strcmp(key, "Motion_Down")) {
167.1108 -      motion[KEY_DOWN] = sdlFromHex(value);
167.1109 -    } else if(!strcmp(key, "frameSkip")) {
167.1110 -      frameSkip = sdlFromHex(value);
167.1111 -      if(frameSkip < 0 || frameSkip > 9)
167.1112 -        frameSkip = 2;
167.1113 -    } else if(!strcmp(key, "gbFrameSkip")) {
167.1114 -      gbFrameSkip = sdlFromHex(value);
167.1115 -      if(gbFrameSkip < 0 || gbFrameSkip > 9)
167.1116 -        gbFrameSkip = 0;      
167.1117 -    } else if(!strcmp(key, "video")) {
167.1118 -      sizeOption = sdlFromHex(value);
167.1119 -      if(sizeOption < 0 || sizeOption > 3)
167.1120 -        sizeOption = 1;
167.1121 -    } else if(!strcmp(key, "fullScreen")) {
167.1122 -      fullscreen = sdlFromHex(value) ? 1 : 0;
167.1123 -    } else if(!strcmp(key, "useBios")) {
167.1124 -      useBios = sdlFromHex(value) ? true : false;
167.1125 -    } else if(!strcmp(key, "skipBios")) {
167.1126 -      skipBios = sdlFromHex(value) ? true : false;
167.1127 -    } else if(!strcmp(key, "biosFile")) {
167.1128 -      strcpy(biosFileName, value);
167.1129 -    } else if(!strcmp(key, "filter")) {
167.1130 -      filter = sdlFromHex(value);
167.1131 -      if(filter < 0 || filter > 13)
167.1132 -        filter = 0;
167.1133 -    } else if(!strcmp(key, "disableStatus")) {
167.1134 -      disableStatusMessages = sdlFromHex(value) ? true : false;
167.1135 -    } else if(!strcmp(key, "borderOn")) {
167.1136 -      gbBorderOn = sdlFromHex(value) ? true : false;
167.1137 -    } else if(!strcmp(key, "borderAutomatic")) {
167.1138 -      gbBorderAutomatic = sdlFromHex(value) ? true : false;
167.1139 -    } else if(!strcmp(key, "emulatorType")) {
167.1140 -      gbEmulatorType = sdlFromHex(value);
167.1141 -      if(gbEmulatorType < 0 || gbEmulatorType > 5)
167.1142 -        gbEmulatorType = 1;
167.1143 -    } else if(!strcmp(key, "colorOption")) {
167.1144 -      gbColorOption = sdlFromHex(value) ? true : false;
167.1145 -    } else if(!strcmp(key, "captureDir")) {
167.1146 -      sdlCheckDirectory(value);
167.1147 -      strcpy(captureDir, value);
167.1148 -    } else if(!strcmp(key, "saveDir")) {
167.1149 -      sdlCheckDirectory(value);
167.1150 -      strcpy(saveDir, value);
167.1151 -    } else if(!strcmp(key, "batteryDir")) {
167.1152 -      sdlCheckDirectory(value);
167.1153 -      strcpy(batteryDir, value);
167.1154 -    } else if(!strcmp(key, "captureFormat")) {
167.1155 -      captureFormat = sdlFromHex(value);
167.1156 -    } else if(!strcmp(key, "soundQuality")) {
167.1157 -      soundQuality = sdlFromHex(value);
167.1158 -      switch(soundQuality) {
167.1159 -      case 1: break;
167.1160 -      default:
167.1161 -        fprintf(stderr, "The rerecording version will run only sound at highest quality. Defaulting to 44.1 KHz\n");
167.1162 -        soundQuality = 1;
167.1163 -        break;
167.1164 -      }
167.1165 -    } else if(!strcmp(key, "soundOff")) {
167.1166 -      soundOffFlag = sdlFromHex(value) ? true : false;
167.1167 -    } else if(!strcmp(key, "soundEnable")) {
167.1168 -      int res = sdlFromHex(value) & 0x30f;
167.1169 -      soundEnableChannels(res);
167.1170 -      soundDisableChannels(~res);
167.1171 -    } else if(!strcmp(key, "soundEcho")) {
167.1172 -      soundEcho = sdlFromHex(value) ? true : false;
167.1173 -    } else if(!strcmp(key, "soundLowPass")) {
167.1174 -      soundLowPass = sdlFromHex(value) ? true : false;
167.1175 -    } else if(!strcmp(key, "soundReverse")) {
167.1176 -      soundReverse = sdlFromHex(value) ? true : false;
167.1177 -    } else if(!strcmp(key, "soundVolume")) {
167.1178 -      soundVolume = sdlFromHex(value);
167.1179 -      if(soundVolume < 0 || soundVolume > 3)
167.1180 -        soundVolume = 0;
167.1181 -    } else if(!strcmp(key, "removeIntros")) {
167.1182 -      removeIntros = sdlFromHex(value) ? true : false;
167.1183 -    } else if(!strcmp(key, "saveType")) {
167.1184 -      cpuSaveType = sdlFromHex(value);
167.1185 -      if(cpuSaveType < 0 || cpuSaveType > 5)
167.1186 -        cpuSaveType = 0;
167.1187 -    } else if(!strcmp(key, "flashSize")) {
167.1188 -      sdlFlashSize = sdlFromHex(value);
167.1189 -      if(sdlFlashSize != 0 && sdlFlashSize != 1)
167.1190 -        sdlFlashSize = 0;
167.1191 -    } else if(!strcmp(key, "ifbType")) {
167.1192 -      ifbType = sdlFromHex(value);
167.1193 -      if(ifbType < 0 || ifbType > 2)
167.1194 -        ifbType = 0;
167.1195 -    } else if(!strcmp(key, "showSpeed")) {
167.1196 -      showSpeed = sdlFromHex(value);
167.1197 -      if(showSpeed < 0 || showSpeed > 2)
167.1198 -        showSpeed = 1;
167.1199 -    } else if(!strcmp(key, "showSpeedTransparent")) {
167.1200 -      showSpeedTransparent = sdlFromHex(value);
167.1201 -    } else if(!strcmp(key, "autoFrameSkip")) {
167.1202 -      autoFrameSkip = sdlFromHex(value);
167.1203 -    } else if(!strcmp(key, "throttle")) {
167.1204 -      throttle = sdlFromHex(value);
167.1205 -      if(throttle != 0 && (throttle < 5 || throttle > 1000))
167.1206 -        throttle = 0;
167.1207 -    } else if(!strcmp(key, "disableMMX")) {
167.1208 -#ifdef MMX
167.1209 -      cpu_mmx = sdlFromHex(value) ? false : true;
167.1210 -#endif
167.1211 -    } else if(!strcmp(key, "pauseWhenInactive")) {
167.1212 -      pauseWhenInactive = sdlFromHex(value) ? true : false;
167.1213 -    } else if(!strcmp(key, "agbPrint")) {
167.1214 -      sdlAgbPrint = sdlFromHex(value);
167.1215 -    } else if(!strcmp(key, "rtcEnabled")) {
167.1216 -      sdlRtcEnable = sdlFromHex(value);
167.1217 -    } else if(!strcmp(key, "rewindTimer")) {
167.1218 -      rewindTimer = sdlFromHex(value);
167.1219 -      if(rewindTimer < 0 || rewindTimer > 600)
167.1220 -        rewindTimer = 0;
167.1221 -      rewindTimer *= 6;  // convert value to 10 frames multiple
167.1222 -    } else if(!strcmp(key, "enhancedDetection")) {
167.1223 -      cpuEnhancedDetection = sdlFromHex(value) ? true : false;
167.1224 -    } else {
167.1225 -      fprintf(stderr, "Unknown configuration key %s\n", key);
167.1226 -    }
167.1227 -  }
167.1228 -}
167.1229 -
167.1230 -void sdlReadPreferences()
167.1231 -{
167.1232 -  FILE *f = sdlFindFile("VisualBoyAdvance.cfg");
167.1233 -
167.1234 -  if(f == NULL) {
167.1235 -    fprintf(stderr, "Configuration file NOT FOUND (using defaults)\n");
167.1236 -    return;
167.1237 -  } else
167.1238 -    fprintf(stderr, "Reading configuration file.\n");
167.1239 -
167.1240 -  sdlReadPreferences(f);
167.1241 -
167.1242 -  fclose(f);
167.1243 -}
167.1244 -
167.1245 -static void sdlApplyPerImagePreferences()
167.1246 -{
167.1247 -  FILE *f = sdlFindFile("vba-over.ini");
167.1248 -  if(!f) {
167.1249 -    fprintf(stderr, "vba-over.ini NOT FOUND (using emulator settings)\n");
167.1250 -    return;
167.1251 -  } else
167.1252 -    fprintf(stderr, "Reading vba-over.ini\n");
167.1253 -
167.1254 -  char buffer[7];
167.1255 -  buffer[0] = '[';
167.1256 -  buffer[1] = rom[0xac];
167.1257 -  buffer[2] = rom[0xad];
167.1258 -  buffer[3] = rom[0xae];
167.1259 -  buffer[4] = rom[0xaf];
167.1260 -  buffer[5] = ']';
167.1261 -  buffer[6] = 0;
167.1262 -
167.1263 -  char readBuffer[2048];
167.1264 -
167.1265 -  bool found = false;
167.1266 -  
167.1267 -  while(1) {
167.1268 -    char *s = fgets(readBuffer, 2048, f);
167.1269 -
167.1270 -    if(s == NULL)
167.1271 -      break;
167.1272 -
167.1273 -    char *p  = strchr(s, ';');
167.1274 -    
167.1275 -    if(p)
167.1276 -      *p = 0;
167.1277 -    
167.1278 -    char *token = strtok(s, " \t\n\r=");
167.1279 -
167.1280 -    if(!token)
167.1281 -      continue;
167.1282 -    if(strlen(token) == 0)
167.1283 -      continue;
167.1284 -
167.1285 -    if(!strcmp(token, buffer)) {
167.1286 -      found = true;
167.1287 -      break;
167.1288 -    }
167.1289 -  }
167.1290 -
167.1291 -  if(found) {
167.1292 -    while(1) {
167.1293 -      char *s = fgets(readBuffer, 2048, f);
167.1294 -
167.1295 -      if(s == NULL)
167.1296 -        break;
167.1297 -
167.1298 -      char *p = strchr(s, ';');
167.1299 -      if(p)
167.1300 -        *p = 0;
167.1301 -
167.1302 -      char *token = strtok(s, " \t\n\r=");
167.1303 -      if(!token)
167.1304 -        continue;
167.1305 -      if(strlen(token) == 0)
167.1306 -        continue;
167.1307 -
167.1308 -      if(token[0] == '[') // starting another image settings
167.1309 -        break;
167.1310 -      char *value = strtok(NULL, "\t\n\r=");
167.1311 -      if(value == NULL)
167.1312 -        continue;
167.1313 -      
167.1314 -      if(!strcmp(token, "rtcEnabled"))
167.1315 -        rtcEnable(atoi(value) == 0 ? false : true);
167.1316 -      else if(!strcmp(token, "flashSize")) {
167.1317 -        int size = atoi(value);
167.1318 -        if(size == 0x10000 || size == 0x20000)
167.1319 -          flashSetSize(size);
167.1320 -      } else if(!strcmp(token, "saveType")) {
167.1321 -        int save = atoi(value);
167.1322 -        if(save >= 0 && save <= 5)
167.1323 -          cpuSaveType = save;
167.1324 -      }
167.1325 -    }
167.1326 -  }
167.1327 -  fclose(f);
167.1328 -}
167.1329 -
167.1330 -static int sdlCalculateShift(u32 mask)
167.1331 -{
167.1332 -  int m = 0;
167.1333 -  
167.1334 -  while(mask) {
167.1335 -    m++;
167.1336 -    mask >>= 1;
167.1337 -  }
167.1338 -
167.1339 -  return m-5;
167.1340 -}
167.1341 -
167.1342 -static int sdlCalculateMaskWidth(u32 mask)
167.1343 -{
167.1344 -  int m = 0;
167.1345 -  int mask2 = mask;
167.1346 -
167.1347 -  while(mask2) {
167.1348 -    m++;
167.1349 -    mask2 >>= 1;
167.1350 -  }
167.1351 -
167.1352 -  int m2 = 0;
167.1353 -  mask2 = mask;
167.1354 -  while(!(mask2 & 1)) {
167.1355 -    m2++;
167.1356 -    mask2 >>= 1;
167.1357 -  }
167.1358 -
167.1359 -  return m - m2;
167.1360 -}
167.1361 -
167.1362 -void sdlWriteState(int num)
167.1363 -{
167.1364 -  char stateName[2048];
167.1365 -
167.1366 -  if(saveDir[0])
167.1367 -    sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename),
167.1368 -            num+1);
167.1369 -  else
167.1370 -    sprintf(stateName,"%s%d.sgm", filename, num+1);
167.1371 -  if(theEmulator.emuWriteState)
167.1372 -    theEmulator.emuWriteState(stateName);
167.1373 -  sprintf(stateName, "Wrote state %d", num+1);
167.1374 -  systemScreenMessage(stateName);
167.1375 -}
167.1376 -
167.1377 -void sdlReadState(int num)
167.1378 -{
167.1379 -  char stateName[2048];
167.1380 -
167.1381 -  if(saveDir[0])
167.1382 -    sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename),
167.1383 -            num+1);
167.1384 -  else
167.1385 -    sprintf(stateName,"%s%d.sgm", filename, num+1);
167.1386 -
167.1387 -  if(theEmulator.emuReadState)
167.1388 -    theEmulator.emuReadState(stateName);
167.1389 -
167.1390 -  sprintf(stateName, "Loaded state %d", num+1);
167.1391 -  systemScreenMessage(stateName);
167.1392 -}
167.1393 -
167.1394 -void sdlWriteBattery()
167.1395 -{
167.1396 -  char buffer[1048];
167.1397 -
167.1398 -  if(batteryDir[0])
167.1399 -    sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
167.1400 -  else  
167.1401 -    sprintf(buffer, "%s.sav", filename);
167.1402 -
167.1403 -  theEmulator.emuWriteBattery(buffer);	
167.1404 -
167.1405 -  systemScreenMessage("Wrote battery");
167.1406 -}
167.1407 -
167.1408 -void sdlReadBattery()
167.1409 -{
167.1410 -  char buffer[1048];
167.1411 -  
167.1412 -  if(batteryDir[0])
167.1413 -    sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
167.1414 -  else 
167.1415 -    sprintf(buffer, "%s.sav", filename);
167.1416 -  
167.1417 -  bool res = false;
167.1418 -
167.1419 -  res = theEmulator.emuReadBattery(buffer);
167.1420 -
167.1421 -  if(res)
167.1422 -    systemScreenMessage("Loaded battery");
167.1423 -}
167.1424 -
167.1425 -#define MOD_KEYS    (KMOD_CTRL|KMOD_SHIFT|KMOD_ALT|KMOD_META)
167.1426 -#define MOD_NOCTRL  (KMOD_SHIFT|KMOD_ALT|KMOD_META)
167.1427 -#define MOD_NOALT   (KMOD_CTRL|KMOD_SHIFT|KMOD_META)
167.1428 -#define MOD_NOSHIFT (KMOD_CTRL|KMOD_ALT|KMOD_META)
167.1429 -
167.1430 -void sdlUpdateKey(int key, bool down)
167.1431 -{
167.1432 -  int i;
167.1433 -  for(int j = 0; j < 4; j++) {
167.1434 -    for(i = 0 ; i < 12; i++) {
167.1435 -      if((joypad[j][i] & 0xf000) == 0) {
167.1436 -        if(key == joypad[j][i])
167.1437 -          if (down) currentButtons[j] |= 1<<i;
167.1438 -          else currentButtons[j] ^= 1<<i;
167.1439 -      }
167.1440 -    }
167.1441 -  }
167.1442 -  for(i = 0 ; i < 4; i++) {
167.1443 -    if((motion[i] & 0xf000) == 0) {
167.1444 -      if(key == motion[i])
167.1445 -        sdlMotionButtons[i] = down;
167.1446 -    }
167.1447 -  }
167.1448 -}
167.1449 -
167.1450 -void sdlUpdateJoyButton(int which,
167.1451 -                        int button,
167.1452 -                        bool pressed)
167.1453 -{
167.1454 -  int i;
167.1455 -  for(int j = 0; j < 4; j++) {
167.1456 -    for(i = 0; i < 12; i++) {
167.1457 -      int dev = (joypad[j][i] >> 12);
167.1458 -      int b = joypad[j][i] & 0xfff;
167.1459 -      if(dev) {
167.1460 -        dev--;
167.1461 -        
167.1462 -        if((dev == which) && (b >= 128) && (b == (button+128))) {
167.1463 -          if (pressed) currentButtons[j] |= 1<<i;
167.1464 -          else currentButtons[j] ^= 1<<i;
167.1465 -        }
167.1466 -      }
167.1467 -    }
167.1468 -  }
167.1469 -  for(i = 0; i < 4; i++) {
167.1470 -    int dev = (motion[i] >> 12);
167.1471 -    int b = motion[i] & 0xfff;
167.1472 -    if(dev) {
167.1473 -      dev--;
167.1474 -
167.1475 -      if((dev == which) && (b >= 128) && (b == (button+128))) {
167.1476 -        sdlMotionButtons[i] = pressed;
167.1477 -      }
167.1478 -    }
167.1479 -  }  
167.1480 -}
167.1481 -
167.1482 -void sdlUpdateJoyHat(int which,
167.1483 -                     int hat,
167.1484 -                     int value)
167.1485 -{
167.1486 -  int i;
167.1487 -  for(int j = 0; j < 4; j++) {
167.1488 -    for(i = 0; i < 12; i++) {
167.1489 -      int dev = (joypad[j][i] >> 12);
167.1490 -      int a = joypad[j][i] & 0xfff;
167.1491 -      if(dev) {
167.1492 -        dev--;
167.1493 -        
167.1494 -        if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
167.1495 -          int dir = a & 3;
167.1496 -          int v = 0;
167.1497 -          switch(dir) {
167.1498 -          case 0:
167.1499 -            v = value & SDL_HAT_UP;
167.1500 -            break;
167.1501 -          case 1:
167.1502 -            v = value & SDL_HAT_DOWN;
167.1503 -            break;
167.1504 -          case 2:
167.1505 -            v = value & SDL_HAT_RIGHT;
167.1506 -            break;
167.1507 -          case 3:
167.1508 -            v = value & SDL_HAT_LEFT;
167.1509 -            break;
167.1510 -          }
167.1511 -          if (v) currentButtons[j] |= 1<<i;
167.1512 -          else currentButtons[j] ^= 1<<i;
167.1513 -        }
167.1514 -      }
167.1515 -    }
167.1516 -  }
167.1517 -  for(i = 0; i < 4; i++) {
167.1518 -    int dev = (motion[i] >> 12);
167.1519 -    int a = motion[i] & 0xfff;
167.1520 -    if(dev) {
167.1521 -      dev--;
167.1522 -
167.1523 -      if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
167.1524 -        int dir = a & 3;
167.1525 -        int v = 0;
167.1526 -        switch(dir) {
167.1527 -        case 0:
167.1528 -          v = value & SDL_HAT_UP;
167.1529 -          break;
167.1530 -        case 1:
167.1531 -          v = value & SDL_HAT_DOWN;
167.1532 -          break;
167.1533 -        case 2:
167.1534 -          v = value & SDL_HAT_RIGHT;
167.1535 -          break;
167.1536 -        case 3:
167.1537 -          v = value & SDL_HAT_LEFT;
167.1538 -          break;
167.1539 -        }
167.1540 -        sdlMotionButtons[i] = (v ? true : false);
167.1541 -      }
167.1542 -    }
167.1543 -  }      
167.1544 -}
167.1545 -
167.1546 -void sdlUpdateJoyAxis(int which,
167.1547 -                      int axis,
167.1548 -                      int value)
167.1549 -{
167.1550 -  int i;
167.1551 -  for(int j = 0; j < 4; j++) {
167.1552 -    for(i = 0; i < 12; i++) {
167.1553 -      int dev = (joypad[j][i] >> 12);
167.1554 -      int a = joypad[j][i] & 0xfff;
167.1555 -      if(dev) {
167.1556 -        dev--;
167.1557 -        
167.1558 -        if((dev == which) && (a < 32) && ((a>>1) == axis)) {
167.1559 -	  //I have no idea what this does, is this reimplementation correct? --Felipe
167.1560 -	  if (value>16384) {
167.1561 -	  	if (a&1) currentButtons[j] |= 1<<i;
167.1562 -	  	else currentButtons[j] ^= 1<<i;
167.1563 -	  }
167.1564 -          else if (value<16384){
167.1565 -          	if (a&1) currentButtons[j] ^= 1<<i;
167.1566 -          	else currentButtons[j] |= 1<<i;
167.1567 -          }
167.1568 -        }
167.1569 -      }
167.1570 -    }
167.1571 -  }
167.1572 -  for(i = 0; i < 4; i++) {
167.1573 -    int dev = (motion[i] >> 12);
167.1574 -    int a = motion[i] & 0xfff;
167.1575 -    if(dev) {
167.1576 -      dev--;
167.1577 -
167.1578 -      if((dev == which) && (a < 32) && ((a>>1) == axis)) {
167.1579 -        sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
167.1580 -      }
167.1581 -    }
167.1582 -  }  
167.1583 -}
167.1584 -
167.1585 -bool sdlCheckJoyKey(int key)
167.1586 -{
167.1587 -  int dev = (key >> 12) - 1;
167.1588 -  int what = key & 0xfff;
167.1589 -
167.1590 -  if(what >= 128) {
167.1591 -    // joystick button
167.1592 -    int button = what - 128;
167.1593 -
167.1594 -    if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
167.1595 -      return false;
167.1596 -  } else if (what < 0x20) {
167.1597 -    // joystick axis    
167.1598 -    what >>= 1;
167.1599 -    if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
167.1600 -      return false;
167.1601 -  } else if (what < 0x30) {
167.1602 -    // joystick hat
167.1603 -    what = (what & 15);
167.1604 -    what >>= 2;
167.1605 -    if(what >= SDL_JoystickNumHats(sdlDevices[dev]))
167.1606 -      return false;
167.1607 -  }
167.1608 -
167.1609 -  // no problem found
167.1610 -  return true;
167.1611 -}
167.1612 -
167.1613 -void sdlCheckKeys()
167.1614 -{
167.1615 -  sdlNumDevices = SDL_NumJoysticks();
167.1616 -
167.1617 -  if(sdlNumDevices)
167.1618 -    sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices *
167.1619 -                                         sizeof(SDL_Joystick **));
167.1620 -  int i;
167.1621 -
167.1622 -  bool usesJoy = false;
167.1623 -
167.1624 -  for(int j = 0; j < 4; j++) {
167.1625 -    for(i = 0; i < 12; i++) {
167.1626 -      int dev = joypad[j][i] >> 12;
167.1627 -      if(dev) {
167.1628 -        dev--;
167.1629 -        bool ok = false;
167.1630 -        
167.1631 -        if(sdlDevices) {
167.1632 -          if(dev < sdlNumDevices) {
167.1633 -            if(sdlDevices[dev] == NULL) {
167.1634 -              sdlDevices[dev] = SDL_JoystickOpen(dev);
167.1635 -            }
167.1636 -            
167.1637 -            ok = sdlCheckJoyKey(joypad[j][i]);
167.1638 -          } else
167.1639 -            ok = false;
167.1640 -        }
167.1641 -        
167.1642 -        if(!ok)
167.1643 -          joypad[j][i] = defaultJoypad[i];
167.1644 -        else
167.1645 -          usesJoy = true;
167.1646 -      }
167.1647 -    }
167.1648 -  }
167.1649 -
167.1650 -  for(i = 0; i < 4; i++) {
167.1651 -    int dev = motion[i] >> 12;
167.1652 -    if(dev) {
167.1653 -      dev--;
167.1654 -      bool ok = false;
167.1655 -      
167.1656 -      if(sdlDevices) {
167.1657 -        if(dev < sdlNumDevices) {
167.1658 -          if(sdlDevices[dev] == NULL) {
167.1659 -            sdlDevices[dev] = SDL_JoystickOpen(dev);
167.1660 -          }
167.1661 -          
167.1662 -          ok = sdlCheckJoyKey(motion[i]);
167.1663 -        } else
167.1664 -          ok = false;
167.1665 -      }
167.1666 -      
167.1667 -      if(!ok)
167.1668 -        motion[i] = defaultMotion[i];
167.1669 -      else
167.1670 -        usesJoy = true;
167.1671 -    }
167.1672 -  }
167.1673 -
167.1674 -  if(usesJoy)
167.1675 -    SDL_JoystickEventState(SDL_ENABLE);
167.1676 -}
167.1677 -
167.1678 -void sdlPollEvents()
167.1679 -{
167.1680 -  SDL_Event event;
167.1681 -  while(SDL_PollEvent(&event)) {
167.1682 -    switch(event.type) {
167.1683 -    case SDL_QUIT:
167.1684 -      emulating = 0;
167.1685 -      break;
167.1686 -    case SDL_ACTIVEEVENT:
167.1687 -      if(pauseWhenInactive && (event.active.state & SDL_APPINPUTFOCUS)) {
167.1688 -        active = event.active.gain;
167.1689 -        if(active) {
167.1690 -          if(!paused) {
167.1691 -            if(emulating)
167.1692 -              soundResume();
167.1693 -          }
167.1694 -        } else {
167.1695 -          wasPaused = true;
167.1696 -          if(pauseWhenInactive) {
167.1697 -            if(emulating)
167.1698 -              soundPause();
167.1699 -          }
167.1700 -          
167.1701 -          memset(delta,255,sizeof(delta));
167.1702 -        }
167.1703 -      }
167.1704 -      break;
167.1705 -    case SDL_MOUSEMOTION:
167.1706 -    case SDL_MOUSEBUTTONUP:
167.1707 -    case SDL_MOUSEBUTTONDOWN:
167.1708 -      if(fullscreen) {
167.1709 -        SDL_ShowCursor(SDL_ENABLE);
167.1710 -        mouseCounter = 120;
167.1711 -      }
167.1712 -      break;
167.1713 -    case SDL_JOYHATMOTION:
167.1714 -      sdlUpdateJoyHat(event.jhat.which,
167.1715 -                      event.jhat.hat,
167.1716 -                      event.jhat.value);
167.1717 -      break;
167.1718 -    case SDL_JOYBUTTONDOWN:
167.1719 -    case SDL_JOYBUTTONUP:
167.1720 -      sdlUpdateJoyButton(event.jbutton.which,
167.1721 -                         event.jbutton.button,
167.1722 -                         event.jbutton.state == SDL_PRESSED);
167.1723 -      break;
167.1724 -    case SDL_JOYAXISMOTION:
167.1725 -      sdlUpdateJoyAxis(event.jaxis.which,
167.1726 -                       event.jaxis.axis,
167.1727 -                       event.jaxis.value);
167.1728 -      break;
167.1729 -    case SDL_KEYDOWN:
167.1730 -      sdlUpdateKey(event.key.keysym.sym, true);
167.1731 -      break;
167.1732 -    case SDL_KEYUP:
167.1733 -      switch(event.key.keysym.sym) {
167.1734 -      case SDLK_r:
167.1735 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1736 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1737 -          if(emulating) {
167.1738 -            theEmulator.emuReset(true);
167.1739 -
167.1740 -            systemScreenMessage("Reset");
167.1741 -          }
167.1742 -        }
167.1743 -        break;
167.1744 -      case SDLK_b:
167.1745 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1746 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1747 -          if(emulating && theEmulator.emuReadMemState && rewindMemory 
167.1748 -             && rewindCount) {
167.1749 -            rewindPos = --rewindPos & 7;
167.1750 -            theEmulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos], 
167.1751 -                                     REWIND_SIZE);
167.1752 -            rewindCount--;
167.1753 -            rewindCounter = 0;
167.1754 -            systemScreenMessage("Rewind");
167.1755 -          }
167.1756 -        }
167.1757 -        break;
167.1758 -      case SDLK_p:
167.1759 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1760 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1761 -          paused = !paused;
167.1762 -          SDL_PauseAudio(paused);
167.1763 -          if(paused)
167.1764 -            wasPaused = true;
167.1765 -        }
167.1766 -        break;
167.1767 -      case SDLK_ESCAPE:
167.1768 -        emulating = 0;
167.1769 -        break;
167.1770 -      case SDLK_f:
167.1771 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1772 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1773 -          int flags = 0;
167.1774 -          fullscreen = !fullscreen;
167.1775 -          if(fullscreen)
167.1776 -            flags |= SDL_FULLSCREEN;
167.1777 -          SDL_SetVideoMode(destWidth, destHeight, systemColorDepth, flags);
167.1778 -          //          if(SDL_WM_ToggleFullScreen(surface))
167.1779 -          //            fullscreen = !fullscreen;
167.1780 -        }
167.1781 -        break;
167.1782 -      case SDLK_F11:
167.1783 -        if(dbgMain != debuggerMain) {
167.1784 -          if(armState) {
167.1785 -            armNextPC -= 4;
167.1786 -            reg[15].I -= 4;
167.1787 -          } else {
167.1788 -            armNextPC -= 2;
167.1789 -            reg[15].I -= 2;
167.1790 -          }
167.1791 -        }
167.1792 -        debugger = true;
167.1793 -        break;
167.1794 -      case SDLK_F1:
167.1795 -      case SDLK_F2:
167.1796 -      case SDLK_F3:
167.1797 -      case SDLK_F4:
167.1798 -      case SDLK_F5:
167.1799 -      case SDLK_F6:
167.1800 -      case SDLK_F7:
167.1801 -      case SDLK_F8:
167.1802 -      case SDLK_F9:
167.1803 -      case SDLK_F10:
167.1804 -        if(!(event.key.keysym.mod & MOD_NOSHIFT) &&
167.1805 -           (event.key.keysym.mod & KMOD_SHIFT)) {
167.1806 -          sdlWriteState(event.key.keysym.sym-SDLK_F1);
167.1807 -        } else if(!(event.key.keysym.mod & MOD_KEYS)) {
167.1808 -          sdlReadState(event.key.keysym.sym-SDLK_F1);
167.1809 -        }
167.1810 -        break;
167.1811 -      case SDLK_1:
167.1812 -      case SDLK_2:
167.1813 -      case SDLK_3:
167.1814 -      case SDLK_4:
167.1815 -        if(!(event.key.keysym.mod & MOD_NOALT) &&
167.1816 -           (event.key.keysym.mod & KMOD_ALT)) {
167.1817 -          char *disableMessages[4] = 
167.1818 -            { "autofire A disabled",
167.1819 -              "autofire B disabled",
167.1820 -              "autofire R disabled",
167.1821 -              "autofire L disabled"};
167.1822 -          char *enableMessages[4] = 
167.1823 -            { "autofire A",
167.1824 -              "autofire B",
167.1825 -              "autofire R",
167.1826 -              "autofire L"};
167.1827 -          int mask = 1 << (event.key.keysym.sym - SDLK_1);
167.1828 -    if(event.key.keysym.sym > SDLK_2)
167.1829 -      mask <<= 6;
167.1830 -          if(autoFire & mask) {
167.1831 -            autoFire &= ~mask;
167.1832 -            systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]);
167.1833 -          } else {
167.1834 -            autoFire |= mask;
167.1835 -            systemScreenMessage(enableMessages[event.key.keysym.sym - SDLK_1]);
167.1836 -          }
167.1837 -        } if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1838 -             (event.key.keysym.mod & KMOD_CTRL)) {
167.1839 -          int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
167.1840 -          layerSettings ^= mask;
167.1841 -          layerEnable = DISPCNT & layerSettings;
167.1842 -          CPUUpdateRenderBuffers(false);
167.1843 -        }
167.1844 -        break;
167.1845 -      case SDLK_5:
167.1846 -      case SDLK_6:
167.1847 -      case SDLK_7:
167.1848 -      case SDLK_8:
167.1849 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1850 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1851 -          int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
167.1852 -          layerSettings ^= mask;
167.1853 -          layerEnable = DISPCNT & layerSettings;
167.1854 -        }
167.1855 -        break;
167.1856 -      case SDLK_n:
167.1857 -        if(!(event.key.keysym.mod & MOD_NOCTRL) &&
167.1858 -           (event.key.keysym.mod & KMOD_CTRL)) {
167.1859 -          if(paused)
167.1860 -            paused = false;
167.1861 -          pauseNextFrame = true;
167.1862 -        }
167.1863 -        break;
167.1864 -      default:
167.1865 -        break;
167.1866 -      }
167.1867 -      sdlUpdateKey(event.key.keysym.sym, false);
167.1868 -      break;
167.1869 -    }
167.1870 -  }
167.1871 -}
167.1872 -
167.1873 -void usage(char *cmd)
167.1874 -{
167.1875 -  printf("%s [option ...] file\n", cmd);
167.1876 -  printf("\
167.1877 -\n\
167.1878 -Options:\n\
167.1879 -  -1, --video-1x               1x\n\
167.1880 -  -2, --video-2x               2x\n\
167.1881 -  -3, --video-3x               3x\n\
167.1882 -  -4, --video-4x               4x\n\
167.1883 -  -F, --fullscreen             Full screen\n\
167.1884 -  -G, --gdb=PROTOCOL           GNU Remote Stub mode:\n\
167.1885 -                                tcp      - use TCP at port 55555\n\
167.1886 -                                tcp:PORT - use TCP at port PORT\n\
167.1887 -                                pipe     - use pipe transport\n\
167.1888 -  -N, --no-debug               Don't parse debug information\n\
167.1889 -  -S, --flash-size=SIZE        Set the Flash size\n\
167.1890 -      --flash-64k               0 -  64K Flash\n\
167.1891 -      --flash-128k              1 - 128K Flash\n\
167.1892 -  -T, --throttle=THROTTLE      Set the desired throttle (5...1000)\n\
167.1893 -  -Y, --yuv=TYPE               Use YUV overlay for drawing:\n\
167.1894 -                                0 - YV12\n\
167.1895 -                                1 - UYVY\n\
167.1896 -                                2 - YVYU\n\
167.1897 -                                3 - YUY2\n\
167.1898 -                                4 - IYUV\n\
167.1899 -  -b, --bios=BIOS              Use given bios file\n\
167.1900 -  -c, --config=FILE            Read the given configuration file\n\
167.1901 -  -d, --debug                  Enter debugger\n\
167.1902 -  -f, --filter=FILTER          Select filter:\n\
167.1903 -      --filter-normal            0 - normal mode\n\
167.1904 -      --filter-tv-mode           1 - TV Mode\n\
167.1905 -      --filter-2xsai             2 - 2xSaI\n\
167.1906 -      --filter-super-2xsai       3 - Super 2xSaI\n\
167.1907 -      --filter-super-eagle       4 - Super Eagle\n\
167.1908 -      --filter-pixelate          5 - Pixelate\n\
167.1909 -      --filter-motion-blur       6 - Motion Blur\n\
167.1910 -      --filter-advmame           7 - AdvanceMAME Scale2x\n\
167.1911 -      --filter-simple2x          8 - Simple2x\n\
167.1912 -      --filter-bilinear          9 - Bilinear\n\
167.1913 -      --filter-bilinear+        10 - Bilinear Plus\n\
167.1914 -      --filter-scanlines        11 - Scanlines\n\
167.1915 -      --filter-hq2x             12 - hq2x\n\
167.1916 -      --filter-lq2x             13 - lq2x\n\
167.1917 -  -h, --help                   Print this help\n\
167.1918 -  -i, --ips=PATCH              Apply given IPS patch\n\
167.1919 -  -P, --profile=[HERTZ]        Enable profiling\n\
167.1920 -  -s, --frameskip=FRAMESKIP    Set frame skip (0...9)\n\
167.1921 -");
167.1922 -  printf("\
167.1923 -  -t, --save-type=TYPE         Set the available save type\n\
167.1924 -      --save-auto               0 - Automatic (EEPROM, SRAM, FLASH)\n\
167.1925 -      --save-eeprom             1 - EEPROM\n\
167.1926 -      --save-sram               2 - SRAM\n\
167.1927 -      --save-flash              3 - FLASH\n\
167.1928 -      --save-sensor             4 - EEPROM+Sensor\n\
167.1929 -      --save-none               5 - NONE\n\
167.1930 -  -v, --verbose=VERBOSE        Set verbose logging (trace.log)\n\
167.1931 -                                  1 - SWI\n\
167.1932 -                                  2 - Unaligned memory access\n\
167.1933 -                                  4 - Illegal memory write\n\
167.1934 -                                  8 - Illegal memory read\n\
167.1935 -                                 16 - DMA 0\n\
167.1936 -                                 32 - DMA 1\n\
167.1937 -                                 64 - DMA 2\n\
167.1938 -                                128 - DMA 3\n\
167.1939 -                                256 - Undefined instruction\n\
167.1940 -                                512 - AGBPrint messages\n\
167.1941 -\n\
167.1942 -Long options only:\n\
167.1943 -      --agb-print              Enable AGBPrint support\n\
167.1944 -      --auto-frameskip         Enable auto frameskipping\n\
167.1945 -      --ifb-none               No interframe blending\n\
167.1946 -      --ifb-motion-blur        Interframe motion blur\n\
167.1947 -      --ifb-smart              Smart interframe blending\n\
167.1948 -      --no-agb-print           Disable AGBPrint support\n\
167.1949 -      --no-auto-frameskip      Disable auto frameskipping\n\
167.1950 -      --no-ips                 Do not apply IPS patch\n\
167.1951 -      --no-mmx                 Disable MMX support\n\
167.1952 -      --no-pause-when-inactive Don't pause when inactive\n\
167.1953 -      --no-rtc                 Disable RTC support\n\
167.1954 -      --no-show-speed          Don't show emulation speed\n\
167.1955 -      --no-throttle            Disable thrrotle\n\
167.1956 -      --pause-when-inactive    Pause when inactive\n\
167.1957 -      --rtc                    Enable RTC support\n\
167.1958 -      --show-speed-normal      Show emulation speed\n\
167.1959 -      --show-speed-detailed    Show detailed speed data\n\
167.1960 -");
167.1961 -  printf("\
167.1962 -  -r, --recordmovie=filename   Start recording input movie\n\
167.1963 -  -p, --playmovie=filename   Play input movie non-read-only\n\
167.1964 -  -w, --watchmovie=filename   Play input movie in read-only mode\n\
167.1965 -");
167.1966 -}
167.1967 -
167.1968 -static char *szFile;
167.1969 -
167.1970 -void file_run()
167.1971 -{
167.1972 -    utilGetBaseName(szFile, filename);
167.1973 -    char *p = strrchr(filename, '.');
167.1974 -
167.1975 -    if(p)
167.1976 -      *p = 0;
167.1977 -
167.1978 -    if(ipsname[0] == 0)
167.1979 -      sprintf(ipsname, "%s.ips", filename);
167.1980 -    
167.1981 -    bool failed = false;
167.1982 -
167.1983 -    IMAGE_TYPE type = utilFindType(szFile);
167.1984 -
167.1985 -    if(type == IMAGE_UNKNOWN) {
167.1986 -      systemMessage(0, "Unknown file type %s", szFile);
167.1987 -      exit(-1);
167.1988 -    }
167.1989 -    systemCartridgeType = (int)type;
167.1990 -
167.1991 -    if(type == IMAGE_GB) {
167.1992 -      failed = !gbLoadRom(szFile);
167.1993 -      if(!failed) {
167.1994 -        systemCartridgeType = 1;
167.1995 -        theEmulator = GBSystem;
167.1996 -        if(sdlAutoIPS) {
167.1997 -          int size = gbRomSize;
167.1998 -          utilApplyIPS(ipsname, &gbRom, &size);
167.1999 -          if(size != gbRomSize) {
167.2000 -            extern bool gbUpdateSizes();
167.2001 -            gbUpdateSizes();
167.2002 -            gbReset();
167.2003 -          }
167.2004 -        }
167.2005 -      }
167.2006 -    } else if(type == IMAGE_GBA) {
167.2007 -      int size = CPULoadRom(szFile);
167.2008 -      failed = (size == 0);
167.2009 -      if(!failed) {
167.2010 -        //        if(cpuEnhancedDetection && cpuSaveType == 0) {
167.2011 -        //          utilGBAFindSave(rom, size);
167.2012 -        //        }
167.2013 -
167.2014 -        sdlApplyPerImagePreferences();
167.2015 -        
167.2016 -        systemCartridgeType = 0;
167.2017 -        theEmulator = GBASystem;
167.2018 -
167.2019 -        /* disabled due to problems
167.2020 -        if(removeIntros && rom != NULL) {
167.2021 -          WRITE32LE(&rom[0], 0xea00002e);
167.2022 -        }
167.2023 -        */
167.2024 -        
167.2025 -        //CPUInit(biosFileName, useBios);
167.2026 -	CPUInit();
167.2027 -        CPUReset();
167.2028 -        if(sdlAutoIPS) {
167.2029 -          int size = 0x2000000;
167.2030 -          utilApplyIPS(ipsname, &rom, &size);
167.2031 -          if(size != 0x2000000) {
167.2032 -            CPUReset();
167.2033 -          }
167.2034 -        }
167.2035 -      }
167.2036 -    }
167.2037 -    
167.2038 -    if(failed) {
167.2039 -      systemMessage(0, "Failed to load file %s", szFile);
167.2040 -      exit(-1);
167.2041 -    }
167.2042 -  
167.2043 -  emulating = 1;
167.2044 -  renderedFrames = 0;
167.2045 -  }
167.2046 -
167.2047 -int main(int argc, char **argv)
167.2048 -{
167.2049 -  fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION);
167.2050 -
167.2051 -  arg0 = argv[0];
167.2052 -  
167.2053 -  captureDir[0] = 0;
167.2054 -  saveDir[0] = 0;
167.2055 -  batteryDir[0] = 0;
167.2056 -  ipsname[0] = 0;
167.2057 -  
167.2058 -  int op = -1;
167.2059 -
167.2060 -  frameSkip = 2;
167.2061 -  gbBorderOn = 0;
167.2062 -
167.2063 -  parseDebug = true;
167.2064 -
167.2065 -  sdlReadPreferences();
167.2066 -
167.2067 -  sdlPrintUsage = 0;
167.2068 -  
167.2069 -  while((op = getopt_long(argc,
167.2070 -                          argv,
167.2071 -                          "FNT:Y:G:D:b:c:df:hi:p::s:t:v:1234",
167.2072 -                          sdlOptions,
167.2073 -                          NULL)) != -1) {
167.2074 -    switch(op) {
167.2075 -    case 0:
167.2076 -      // long option already processed by getopt_long
167.2077 -      break;
167.2078 -    case 'b':
167.2079 -      useBios = true;
167.2080 -      if(optarg == NULL) {
167.2081 -        fprintf(stderr, "Missing BIOS file name\n");
167.2082 -        exit(-1);
167.2083 -      }
167.2084 -      strcpy(biosFileName, optarg);
167.2085 -      break;
167.2086 -    case 'c':
167.2087 -      {
167.2088 -        if(optarg == NULL) {
167.2089 -          fprintf(stderr, "Missing config file name\n");
167.2090 -          exit(-1);
167.2091 -        }
167.2092 -        FILE *f = fopen(optarg, "r");
167.2093 -        if(f == NULL) {
167.2094 -          fprintf(stderr, "File not found %s\n", optarg);
167.2095 -          exit(-1);
167.2096 -        }
167.2097 -        sdlReadPreferences(f);
167.2098 -        fclose(f);
167.2099 -      }
167.2100 -      break;
167.2101 -    case 'd':
167.2102 -      debugger = true;
167.2103 -      break;
167.2104 -    case 'h':
167.2105 -      sdlPrintUsage = 1;
167.2106 -      break;
167.2107 -    case 'i':
167.2108 -      if(optarg == NULL) {
167.2109 -        fprintf(stderr, "Missing IPS name\n");
167.2110 -        exit(-1);
167.2111 -        strcpy(ipsname, optarg);
167.2112 -      }
167.2113 -      break;
167.2114 -    case 'Y':
167.2115 -      yuv = true;
167.2116 -      if(optarg) {
167.2117 -        yuvType = atoi(optarg);
167.2118 -        switch(yuvType) {
167.2119 -        case 0:
167.2120 -          yuvType = SDL_YV12_OVERLAY;
167.2121 -          break;
167.2122 -        case 1:
167.2123 -          yuvType = SDL_UYVY_OVERLAY;
167.2124 -          break;
167.2125 -        case 2:
167.2126 -          yuvType = SDL_YVYU_OVERLAY;
167.2127 -          break;
167.2128 -        case 3:
167.2129 -          yuvType = SDL_YUY2_OVERLAY;
167.2130 -          break;
167.2131 -        case 4:
167.2132 -          yuvType = SDL_IYUV_OVERLAY;
167.2133 -          break;
167.2134 -        default:
167.2135 -          yuvType = SDL_YV12_OVERLAY;
167.2136 -        }
167.2137 -      } else
167.2138 -        yuvType = SDL_YV12_OVERLAY;
167.2139 -      break;
167.2140 -    case 'G':
167.2141 -      dbgMain = remoteStubMain;
167.2142 -      dbgSignal = remoteStubSignal;
167.2143 -      dbgOutput = remoteOutput;
167.2144 -      debugger = true;
167.2145 -      debuggerStub = true;
167.2146 -      if(optarg) {
167.2147 -        char *s = optarg;
167.2148 -        if(strncmp(s,"tcp:", 4) == 0) {
167.2149 -          s+=4;
167.2150 -          int port = atoi(s);
167.2151 -          remoteSetProtocol(0);
167.2152 -          remoteSetPort(port);
167.2153 -        } else if(strcmp(s,"tcp") == 0) {
167.2154 -          remoteSetProtocol(0);
167.2155 -        } else if(strcmp(s, "pipe") == 0) {
167.2156 -          remoteSetProtocol(1);
167.2157 -        } else {
167.2158 -          fprintf(stderr, "Unknown protocol %s\n", s);
167.2159 -          exit(-1);
167.2160 -        }
167.2161 -      } else {
167.2162 -        remoteSetProtocol(0);
167.2163 -      }
167.2164 -      break;
167.2165 -    case 'N':
167.2166 -      parseDebug = false;
167.2167 -      break;
167.2168 -    case 'D':
167.2169 -      if(optarg) {
167.2170 -        systemDebug = atoi(optarg);
167.2171 -      } else {
167.2172 -        systemDebug = 1;
167.2173 -      }
167.2174 -      break;
167.2175 -    case 'F':
167.2176 -      fullscreen = 1;
167.2177 -      mouseCounter = 120;
167.2178 -      break;
167.2179 -    case 'f':
167.2180 -      if(optarg) {
167.2181 -        filter = atoi(optarg);
167.2182 -      } else {
167.2183 -        filter = 0;
167.2184 -      }
167.2185 -      break;
167.2186 -      
167.2187 -    case 'r':
167.2188 -      if(optarg == NULL) {
167.2189 -        fprintf(stderr, "ERROR: --recordMovie ('r') needs movie filename as option\n");
167.2190 -        exit(-1);
167.2191 -      }
167.2192 -        strcpy(movieFileName, optarg);
167.2193 -        useMovie = 1;
167.2194 -      break;
167.2195 -    case 'p': // play without read-only (editable)
167.2196 -      fprintf (stderr, "-p got called!\n");
167.2197 -      if(optarg == NULL) {
167.2198 -        fprintf(stderr, "ERROR: --playMovie ('p') needs movie filename as option\n");
167.2199 -        exit(-1);
167.2200 -      }
167.2201 -        strcpy(movieFileName, optarg);
167.2202 -        useMovie = 2;
167.2203 -      break;
167.2204 -    case 'w': // play with read-only
167.2205 -     fprintf (stderr, "-w got called!\n"); 
167.2206 -      if(optarg == NULL) {
167.2207 -        fprintf(stderr, "ERROR: --watchMovie ('w') needs movie filename as option\n");
167.2208 -        exit(-1);
167.2209 -      }
167.2210 -        strcpy(movieFileName, optarg);
167.2211 -        useMovie = 3;
167.2212 -      break;
167.2213 -                  
167.2214 -    case 'P':
167.2215 -#ifdef PROFILING
167.2216 -      if(optarg) {
167.2217 -        cpuEnableProfiling(atoi(optarg));
167.2218 -      } else
167.2219 -        cpuEnableProfiling(100);
167.2220 -#endif
167.2221 -      break;
167.2222 -    case 'S':
167.2223 -      sdlFlashSize = atoi(optarg);
167.2224 -      if(sdlFlashSize < 0 || sdlFlashSize > 1)
167.2225 -        sdlFlashSize = 0;
167.2226 -      break;
167.2227 -    case 's':
167.2228 -      if(optarg) {
167.2229 -        int a = atoi(optarg);
167.2230 -        if(a >= 0 && a <= 9) {
167.2231 -          gbFrameSkip = a;
167.2232 -          frameSkip = a;
167.2233 -        }
167.2234 -      } else {
167.2235 -        frameSkip = 2;
167.2236 -        gbFrameSkip = 0;
167.2237 -      }
167.2238 -      break;
167.2239 -    case 't':
167.2240 -      if(optarg) {
167.2241 -        int a = atoi(optarg);
167.2242 -        if(a < 0 || a > 5)
167.2243 -          a = 0;
167.2244 -        cpuSaveType = a;
167.2245 -      }
167.2246 -      break;
167.2247 -    case 'T':
167.2248 -      if(optarg) {
167.2249 -        int t = atoi(optarg);
167.2250 -        throttle = t;
167.2251 -      }
167.2252 -      break;
167.2253 -    case 'v':
167.2254 -      if(optarg) {
167.2255 -        systemVerbose = atoi(optarg);
167.2256 -      } else 
167.2257 -        systemVerbose = 0;
167.2258 -      break;
167.2259 -    case '1':
167.2260 -      sizeOption = 0;
167.2261 -      break;
167.2262 -    case '2':
167.2263 -      sizeOption = 1;
167.2264 -      break;
167.2265 -    case '3':
167.2266 -      sizeOption = 2;
167.2267 -      break;
167.2268 -    case '4':
167.2269 -      sizeOption = 3;
167.2270 -      break;
167.2271 -    case '?':
167.2272 -      sdlPrintUsage = 1;
167.2273 -      break;
167.2274 -    }
167.2275 -  }
167.2276 -
167.2277 -  if(sdlPrintUsage) {
167.2278 -    usage(argv[0]);
167.2279 -    exit(-1);
167.2280 -  }
167.2281 -
167.2282 -#ifdef MMX
167.2283 -  if(disableMMX)
167.2284 -    cpu_mmx = 0;
167.2285 -#endif
167.2286 -
167.2287 -  if(rewindTimer)
167.2288 -    rewindMemory = (char *)malloc(8*REWIND_SIZE);
167.2289 -
167.2290 -  if(sdlFlashSize == 0)
167.2291 -    flashSetSize(0x10000);
167.2292 -  else
167.2293 -    flashSetSize(0x20000);
167.2294 -
167.2295 -  rtcEnable(sdlRtcEnable ? true : false);
167.2296 -  agbPrintEnable(sdlAgbPrint ? true : false);
167.2297 -  
167.2298 -  if(!debuggerStub) {
167.2299 -    if(optind >= argc) {
167.2300 -      systemMessage(0,"Missing image name");
167.2301 -      usage(argv[0]);
167.2302 -      exit(-1);
167.2303 -    }
167.2304 -  }
167.2305 -
167.2306 -  if(filter) {
167.2307 -    sizeOption = 1;
167.2308 -  }
167.2309 -
167.2310 -  for(int i = 0; i < 24;) {
167.2311 -    systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
167.2312 -    systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
167.2313 -    systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
167.2314 -    systemGbPalette[i++] = 0;
167.2315 -  }
167.2316 -
167.2317 -  systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
167.2318 -
167.2319 -  if(optind < argc) 
167.2320 -  {
167.2321 -      szFile = argv[optind];
167.2322 -      file_run();
167.2323 -  }
167.2324 -   else 
167.2325 -  {
167.2326 -    systemCartridgeType = 0;
167.2327 -    strcpy(filename, "gnu_stub");
167.2328 -    rom = (u8 *)malloc(0x2000000);
167.2329 -    workRAM = (u8 *)calloc(1, 0x40000);
167.2330 -    bios = (u8 *)calloc(1,0x4000);
167.2331 -    internalRAM = (u8 *)calloc(1,0x8000);
167.2332 -    paletteRAM = (u8 *)calloc(1,0x400);
167.2333 -    vram = (u8 *)calloc(1, 0x20000);
167.2334 -    oam = (u8 *)calloc(1, 0x400);
167.2335 -    pix = (u8 *)calloc(1, 4 * 240 * 160);
167.2336 -    ioMem = (u8 *)calloc(1, 0x400);
167.2337 -
167.2338 -    theEmulator = GBASystem;
167.2339 -    
167.2340 -    //CPUInit(biosFileName, useBios);
167.2341 -    CPUInit();
167.2342 -    CPUReset();    
167.2343 -  }
167.2344 -  
167.2345 -  if(debuggerStub) 
167.2346 -    remoteInit();
167.2347 -  
167.2348 -  int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
167.2349 -    SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE;
167.2350 -
167.2351 -  if(soundOffFlag)
167.2352 -    flags ^= SDL_INIT_AUDIO;
167.2353 -  
167.2354 -  if(SDL_Init(flags)) {
167.2355 -    systemMessage(0, "Failed to init SDL: %s", SDL_GetError());
167.2356 -    exit(-1);
167.2357 -  }
167.2358 -
167.2359 -  if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
167.2360 -    systemMessage(0, "Failed to init joystick support: %s", SDL_GetError());
167.2361 -  }
167.2362 -  
167.2363 -  sdlCheckKeys();
167.2364 -  
167.2365 -  if(systemCartridgeType == 0) {
167.2366 -    srcWidth = 240;
167.2367 -    srcHeight = 160;
167.2368 -    systemFrameSkip = frameSkip;
167.2369 -  } else if (systemCartridgeType == 1) {
167.2370 -    if(gbBorderOn) {
167.2371 -      srcWidth = 256;
167.2372 -      srcHeight = 224;
167.2373 -      gbBorderLineSkip = 256;
167.2374 -      gbBorderColumnSkip = 48;
167.2375 -      gbBorderRowSkip = 40;
167.2376 -    } else {      
167.2377 -      srcWidth = 160;
167.2378 -      srcHeight = 144;
167.2379 -      gbBorderLineSkip = 160;
167.2380 -      gbBorderColumnSkip = 0;
167.2381 -      gbBorderRowSkip = 0;
167.2382 -    }
167.2383 -    systemFrameSkip = gbFrameSkip;
167.2384 -  } else {
167.2385 -    srcWidth = 320;
167.2386 -    srcHeight = 240;
167.2387 -  }
167.2388 -  
167.2389 -  destWidth = (sizeOption+1)*srcWidth;
167.2390 -  destHeight = (sizeOption+1)*srcHeight;
167.2391 -  
167.2392 -  surface = SDL_SetVideoMode(destWidth, destHeight, 16,
167.2393 -                             SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
167.2394 -                             (fullscreen ? SDL_FULLSCREEN : 0));
167.2395 -  
167.2396 -  if(surface == NULL) {
167.2397 -    systemMessage(0, "Failed to set video mode");
167.2398 -    SDL_Quit();
167.2399 -    exit(-1);
167.2400 -  }
167.2401 -  
167.2402 -  systemRedShift = sdlCalculateShift(surface->format->Rmask);
167.2403 -  systemGreenShift = sdlCalculateShift(surface->format->Gmask);
167.2404 -  systemBlueShift = sdlCalculateShift(surface->format->Bmask);
167.2405 -  
167.2406 -  systemColorDepth = surface->format->BitsPerPixel;
167.2407 -  if(systemColorDepth == 15)
167.2408 -    systemColorDepth = 16;
167.2409 -
167.2410 -  if(yuv) {
167.2411 -    Init_Overlay(surface, yuvType);
167.2412 -    systemColorDepth = 32;
167.2413 -    systemRedShift = 3;
167.2414 -    systemGreenShift = 11;
167.2415 -    systemBlueShift =  19;
167.2416 -  }
167.2417 -  
167.2418 -  if(systemColorDepth != 16 && systemColorDepth != 24 &&
167.2419 -     systemColorDepth != 32) {
167.2420 -    fprintf(stderr,"Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth);
167.2421 -    exit(-1);
167.2422 -  }
167.2423 -
167.2424 -#ifndef C_CORE
167.2425 -  sdlMakeStretcher(srcWidth);
167.2426 -#else
167.2427 -  switch(systemColorDepth) {
167.2428 -  case 16:
167.2429 -    sdlStretcher = sdlStretcher16[sizeOption];
167.2430 -    break;
167.2431 -  case 24:
167.2432 -    sdlStretcher = sdlStretcher24[sizeOption];
167.2433 -    break;
167.2434 -  case 32:
167.2435 -    sdlStretcher = sdlStretcher32[sizeOption];
167.2436 -    break;
167.2437 -  default:
167.2438 -    fprintf(stderr, "Unsupported resolution: %d\n", systemColorDepth);
167.2439 -    exit(-1);
167.2440 -  }
167.2441 -#endif
167.2442 -
167.2443 -  fprintf(stderr,"Color depth: %d\n", systemColorDepth);
167.2444 -  
167.2445 -  if(systemColorDepth == 16) {
167.2446 -    if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) {
167.2447 -      Init_2xSaI(565);
167.2448 -      RGB_LOW_BITS_MASK = 0x821;
167.2449 -    } else {
167.2450 -      Init_2xSaI(555);
167.2451 -      RGB_LOW_BITS_MASK = 0x421;      
167.2452 -    }
167.2453 -    if(systemCartridgeType == 2) {
167.2454 -      for(int i = 0; i < 0x10000; i++) {
167.2455 -        systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) |
167.2456 -          (((i & 0x7c0) >> 6) << systemGreenShift) |
167.2457 -          (((i & 0xf800) >> 11) << systemRedShift);  
167.2458 -      }      
167.2459 -    } else {
167.2460 -      for(int i = 0; i < 0x10000; i++) {
167.2461 -        systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
167.2462 -          (((i & 0x3e0) >> 5) << systemGreenShift) |
167.2463 -          (((i & 0x7c00) >> 10) << systemBlueShift);  
167.2464 -      }
167.2465 -    }
167.2466 -    srcPitch = srcWidth * 2+4;
167.2467 -  } else {
167.2468 -    if(systemColorDepth != 32)
167.2469 -      filterFunction = NULL;
167.2470 -    RGB_LOW_BITS_MASK = 0x010101;
167.2471 -    if(systemColorDepth == 32) {
167.2472 -      Init_2xSaI(32);
167.2473 -    }
167.2474 -    for(int i = 0; i < 0x10000; i++) {
167.2475 -      systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
167.2476 -        (((i & 0x3e0) >> 5) << systemGreenShift) |
167.2477 -        (((i & 0x7c00) >> 10) << systemBlueShift);  
167.2478 -    }
167.2479 -    if(systemColorDepth == 32)
167.2480 -      srcPitch = srcWidth*4 + 4;
167.2481 -    else
167.2482 -      srcPitch = srcWidth*3;
167.2483 -  }
167.2484 -
167.2485 -  if(systemColorDepth != 32) {
167.2486 -    switch(filter) {
167.2487 -    case 0:
167.2488 -      filterFunction = NULL;
167.2489 -      break;
167.2490 -    case 1:
167.2491 -      filterFunction = ScanlinesTV;
167.2492 -      break;
167.2493 -    case 2:
167.2494 -      filterFunction = _2xSaI;
167.2495 -      break;
167.2496 -    case 3:
167.2497 -      filterFunction = Super2xSaI;
167.2498 -      break;
167.2499 -    case 4:
167.2500 -      filterFunction = SuperEagle;
167.2501 -      break;
167.2502 -    case 5:
167.2503 -      filterFunction = Pixelate2x16;
167.2504 -      break;
167.2505 -    case 6:
167.2506 -      filterFunction = MotionBlur;
167.2507 -      break;
167.2508 -    case 7:
167.2509 -      filterFunction = AdMame2x;
167.2510 -      break;
167.2511 -    case 8:
167.2512 -      filterFunction = Simple2x16;
167.2513 -      break;
167.2514 -    case 9:
167.2515 -      filterFunction = Bilinear;
167.2516 -      break;
167.2517 -    case 10:
167.2518 -      filterFunction = BilinearPlus;
167.2519 -      break;
167.2520 -    case 11:
167.2521 -      filterFunction = Scanlines;
167.2522 -      break;
167.2523 -    case 12:
167.2524 -      filterFunction = hq2x;
167.2525 -      break;
167.2526 -    case 13:
167.2527 -      filterFunction = lq2x;
167.2528 -      break;
167.2529 -    default:
167.2530 -      filterFunction = NULL;
167.2531 -      break;
167.2532 -    }
167.2533 -  } else {
167.2534 -    switch(filter) {
167.2535 -    case 0:
167.2536 -      filterFunction = NULL;
167.2537 -      break;
167.2538 -    case 1:
167.2539 -      filterFunction = ScanlinesTV32;
167.2540 -      break;
167.2541 -    case 2:
167.2542 -      filterFunction = _2xSaI32;
167.2543 -      break;
167.2544 -    case 3:
167.2545 -      filterFunction = Super2xSaI32;
167.2546 -      break;
167.2547 -    case 4:
167.2548 -      filterFunction = SuperEagle32;
167.2549 -      break;
167.2550 -    case 5:
167.2551 -      filterFunction = Pixelate2x32;
167.2552 -      break;
167.2553 -    case 6:
167.2554 -      filterFunction = MotionBlur32;
167.2555 -      break;
167.2556 -    case 7:
167.2557 -      filterFunction = AdMame2x32;
167.2558 -      break;
167.2559 -    case 8:
167.2560 -      filterFunction = Simple2x32;
167.2561 -      break;
167.2562 -    case 9:
167.2563 -      filterFunction = Bilinear32;
167.2564 -      break;
167.2565 -    case 10:
167.2566 -      filterFunction = BilinearPlus32;
167.2567 -      break;
167.2568 -    case 11:
167.2569 -      filterFunction = Scanlines32;
167.2570 -      break;
167.2571 -    case 12:
167.2572 -      filterFunction = hq2x32;
167.2573 -      break;
167.2574 -    case 13:
167.2575 -      filterFunction = lq2x32;
167.2576 -      break;
167.2577 -    default:
167.2578 -      filterFunction = NULL;
167.2579 -      break;
167.2580 -    }
167.2581 -  }
167.2582 -  
167.2583 -  if(systemColorDepth == 16) {
167.2584 -    switch(ifbType) {
167.2585 -    case 0:
167.2586 -    default:
167.2587 -      ifbFunction = NULL;
167.2588 -      break;
167.2589 -    case 1:
167.2590 -      ifbFunction = MotionBlurIB;
167.2591 -      break;
167.2592 -    case 2:
167.2593 -      ifbFunction = SmartIB;
167.2594 -      break;
167.2595 -    }
167.2596 -  } else if(systemColorDepth == 32) {
167.2597 -    switch(ifbType) {
167.2598 -    case 0:
167.2599 -    default:
167.2600 -      ifbFunction = NULL;
167.2601 -      break;
167.2602 -    case 1:
167.2603 -      ifbFunction = MotionBlurIB32;
167.2604 -      break;
167.2605 -    case 2:
167.2606 -      ifbFunction = SmartIB32;
167.2607 -      break;
167.2608 -    }
167.2609 -  } else
167.2610 -    ifbFunction = NULL;
167.2611 -
167.2612 -  if(delta == NULL) {
167.2613 -    delta = (u8*)malloc(322*242*4);
167.2614 -    memset(delta, 255, 322*242*4);
167.2615 -  }
167.2616 -
167.2617 -  if(!soundOffFlag)
167.2618 -    soundInit();
167.2619 -
167.2620 -  autoFrameSkipLastTime = throttleLastTime = systemGetClock();
167.2621 -
167.2622 -  switch(useMovie)
167.2623 -  {
167.2624 -    case 1: // --recordMovie
167.2625 -      VBAMovieCreate(movieFileName,
167.2626 -        /*authorInfo*/"",
167.2627 -        /*startFlags*/0,
167.2628 -        /*controllerFlags*/MOVIE_CONTROLLER(0),
167.2629 -        /*typeFlags*/(systemCartridgeType==IMAGE_GBA)?(MOVIE_TYPE_GBA):(GBC_CAPABLE?MOVIE_TYPE_GBC:MOVIE_TYPE_SGB));
167.2630 -	  break;
167.2631 -    case 2: // --playMovie
167.2632 -      VBAMovieOpen(movieFileName, false);
167.2633 -  	  break;
167.2634 -    case 3: // --watchMovie
167.2635 -      VBAMovieOpen(movieFileName, true);
167.2636 -  	  break;
167.2637 -    default:
167.2638 -    	sdlReadBattery();
167.2639 -  	  break;
167.2640 -  }
167.2641 -  SDL_WM_SetCaption("VisualBoyAdvance", NULL);
167.2642 -  
167.2643 -  char *moviefile = getenv("AUTODEMO");
167.2644 -//  fprintf (stderr, "Checking for AUTODEMO...\n");
167.2645 -  if (moviefile)
167.2646 -  {
167.2647 -//    fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n");
167.2648 -    VBAMovieOpen(moviefile, true);
167.2649 -  }
167.2650 -
167.2651 -  while(emulating) {
167.2652 -    if(!paused && active) {
167.2653 -      if(debugger && theEmulator.emuHasDebugger)
167.2654 -        dbgMain();
167.2655 -      else {
167.2656 -        theEmulator.emuMain(theEmulator.emuCount);
167.2657 -        if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
167.2658 -          rewindCount++;
167.2659 -          if(rewindCount > 8)
167.2660 -            rewindCount = 8;
167.2661 -          if(theEmulator.emuWriteMemState &&
167.2662 -             theEmulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], 
167.2663 -                                       REWIND_SIZE)) {
167.2664 -            rewindPos = ++rewindPos & 7;
167.2665 -            if(rewindCount == 8)
167.2666 -              rewindTopPos = ++rewindTopPos & 7;
167.2667 -          }
167.2668 -        }
167.2669 -
167.2670 -        rewindSaveNeeded = false;
167.2671 -      }
167.2672 -    } else {
167.2673 -      SDL_Delay(500);
167.2674 -    }
167.2675 -    sdlPollEvents();
167.2676 -    if(mouseCounter) {
167.2677 -      mouseCounter--;
167.2678 -      if(mouseCounter == 0)
167.2679 -        SDL_ShowCursor(SDL_DISABLE);
167.2680 -    }
167.2681 -  }
167.2682 -  
167.2683 -  emulating = 0;
167.2684 -  fprintf(stderr,"Shutting down\n");
167.2685 -  remoteCleanUp();
167.2686 -  soundShutdown();
167.2687 -
167.2688 -  if(gbRom != NULL || rom != NULL) {
167.2689 -    sdlWriteBattery();
167.2690 -    theEmulator.emuCleanUp();
167.2691 -  }
167.2692 -
167.2693 -  if(delta) {
167.2694 -    free(delta);
167.2695 -    delta = NULL;
167.2696 -  }
167.2697 -  
167.2698 -  SDL_Quit();
167.2699 -  return 0;
167.2700 -}
167.2701 -
167.2702 -void systemMessage(int num, const char *msg, ...)
167.2703 -{
167.2704 -  char buffer[2048];
167.2705 -  va_list valist;
167.2706 -  
167.2707 -  va_start(valist, msg);
167.2708 -  vsprintf(buffer, msg, valist);
167.2709 -  
167.2710 -  fprintf(stderr, "%s\n", buffer);
167.2711 -  va_end(valist);
167.2712 -}
167.2713 -
167.2714 -//On WIN32, this function messages requesting
167.2715 -//the window to be redrawn. Can this be ignored here?
167.2716 -void systemRefreshScreen(){}
167.2717 -
167.2718 -void systemRenderFrame()
167.2719 -{
167.2720 -  renderedFrames++;
167.2721 -  VBAUpdateFrameCountDisplay();
167.2722 -  VBAUpdateButtonPressDisplay();
167.2723 -  
167.2724 -  if(yuv) {
167.2725 -    Draw_Overlay(surface, sizeOption+1);
167.2726 -    return;
167.2727 -  }
167.2728 -  
167.2729 -  SDL_LockSurface(surface);
167.2730 -
167.2731 -  for(int slot = 0 ; slot < 8 ; slot++)
167.2732 -  {
167.2733 -	if(screenMessage[slot]) {
167.2734 -		if(systemCartridgeType == 1 && gbBorderOn) {
167.2735 -			gbSgbRenderBorder();
167.2736 -		}
167.2737 -		if(((systemGetClock() - screenMessageTime[slot]) < screenMessageDuration[slot]) &&
167.2738 -			!disableStatusMessages) {
167.2739 -			drawText(pix, srcPitch, 10, srcHeight - 20*(slot+1),
167.2740 -					screenMessageBuffer[slot]); 
167.2741 -		} else {
167.2742 -			screenMessage[slot] = false;
167.2743 -		}
167.2744 -	}
167.2745 -  }
167.2746 -
167.2747 -  if(ifbFunction) {
167.2748 -    if(systemColorDepth == 16)
167.2749 -      ifbFunction(pix+destWidth+4, destWidth+4, srcWidth, srcHeight);
167.2750 -    else
167.2751 -      ifbFunction(pix+destWidth*2+4, destWidth*2+4, srcWidth, srcHeight);
167.2752 -  }
167.2753 -  
167.2754 -  if(filterFunction) {
167.2755 -    if(systemColorDepth == 16)
167.2756 -      filterFunction(pix+destWidth+4,destWidth+4, delta,
167.2757 -                     (u8*)surface->pixels,surface->pitch,
167.2758 -                     srcWidth,
167.2759 -                     srcHeight);
167.2760 -    else
167.2761 -      filterFunction(pix+destWidth*2+4,
167.2762 -                     destWidth*2+4,
167.2763 -                     delta,
167.2764 -                     (u8*)surface->pixels,
167.2765 -                     surface->pitch,
167.2766 -                     srcWidth,
167.2767 -                     srcHeight);
167.2768 -  } else {
167.2769 -    int destPitch = surface->pitch;
167.2770 -    u8 *src = pix;
167.2771 -    u8 *dest = (u8*)surface->pixels;
167.2772 -    int i;
167.2773 -    u32 *stretcher = (u32 *)sdlStretcher;
167.2774 -    if(systemColorDepth == 16)
167.2775 -      src += srcPitch;
167.2776 -    int option = sizeOption;
167.2777 -    if(yuv)
167.2778 -      option = 0;
167.2779 -    switch(sizeOption) {
167.2780 -    case 0:
167.2781 -      for(i = 0; i < srcHeight; i++) {
167.2782 -        SDL_CALL_STRETCHER;
167.2783 -        src += srcPitch;
167.2784 -        dest += destPitch;
167.2785 -      }
167.2786 -      break;
167.2787 -    case 1:
167.2788 -      for(i = 0; i < srcHeight; i++) {
167.2789 -        SDL_CALL_STRETCHER;     
167.2790 -        dest += destPitch;
167.2791 -        SDL_CALL_STRETCHER;
167.2792 -        src += srcPitch;
167.2793 -        dest += destPitch;
167.2794 -      }
167.2795 -      break;
167.2796 -    case 2:
167.2797 -      for(i = 0; i < srcHeight; i++) {
167.2798 -        SDL_CALL_STRETCHER;
167.2799 -        dest += destPitch;
167.2800 -        SDL_CALL_STRETCHER;
167.2801 -        dest += destPitch;
167.2802 -        SDL_CALL_STRETCHER;
167.2803 -        src += srcPitch;
167.2804 -        dest += destPitch;
167.2805 -      }
167.2806 -      break;
167.2807 -    case 3:
167.2808 -      for(i = 0; i < srcHeight; i++) {
167.2809 -        SDL_CALL_STRETCHER;
167.2810 -        dest += destPitch;
167.2811 -        SDL_CALL_STRETCHER;
167.2812 -        dest += destPitch;
167.2813 -        SDL_CALL_STRETCHER;
167.2814 -        dest += destPitch;
167.2815 -        SDL_CALL_STRETCHER;
167.2816 -        src += srcPitch;
167.2817 -        dest += destPitch;
167.2818 -      }
167.2819 -      break;
167.2820 -    }
167.2821 -  }
167.2822 -
167.2823 -  if(showSpeed && fullscreen) {
167.2824 -    char buffer[50];
167.2825 -    if(showSpeed == 1)
167.2826 -      sprintf(buffer, "%d%%", systemSpeed);
167.2827 -    else
167.2828 -      sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
167.2829 -              systemFrameSkip,
167.2830 -              showRenderedFrames);
167.2831 -    if(showSpeedTransparent)
167.2832 -      drawTextTransp((u8*)surface->pixels,
167.2833 -                     surface->pitch,
167.2834 -                     10,
167.2835 -                     surface->h-20,
167.2836 -                     buffer);
167.2837 -    else
167.2838 -      drawText((u8*)surface->pixels,
167.2839 -               surface->pitch,
167.2840 -               10,
167.2841 -               surface->h-20,
167.2842 -               buffer);        
167.2843 -  }  
167.2844 -
167.2845 -  SDL_UnlockSurface(surface);
167.2846 -  //  SDL_UpdateRect(surface, 0, 0, destWidth, destHeight);
167.2847 -  SDL_Flip(surface);
167.2848 -}
167.2849 -
167.2850 -bool systemReadJoypads()
167.2851 -{
167.2852 -  return true;
167.2853 -}
167.2854 -
167.2855 -// Kludge to make Lua call the right function.
167.2856 -u32 systemGetOriginalJoypad(int which, bool sensor){
167.2857 -	return systemGetJoypad(which,sensor);
167.2858 -}
167.2859 -
167.2860 -u32 systemGetJoypad(int which, bool sensor)
167.2861 -{
167.2862 -    sensorOn = sensor;
167.2863 -  if(which < 0 || which > 3)
167.2864 -    which = sdlDefaultJoypad;
167.2865 -  
167.2866 -  //VBAMovieUpdate(which);
167.2867 -  //VBAMovieUpdateState();
167.2868 -  u32 res = 0;
167.2869 -  
167.2870 -  //----------------------------//
167.2871 -  if (VBAMoviePlaying()){
167.2872 -	// VBAMovieRead() overwrites currentButtons[i]
167.2873 -	VBAMovieRead(which, sensor);
167.2874 -	res = currentButtons[which];
167.2875 -	return res;
167.2876 -  }  
167.2877 -  //---------------------------//
167.2878 -  //Temporary implementation, not sure if it's correct --Felipe
167.2879 -  
167.2880 -  /*
167.2881 -  if(sdlButtons[which][KEY_BUTTON_A])
167.2882 -    res |= BUTTON_MASK_A;
167.2883 -  if(sdlButtons[which][KEY_BUTTON_B])
167.2884 -    res |= BUTTON_MASK_B;
167.2885 -  if(sdlButtons[which][KEY_BUTTON_SELECT])
167.2886 -    res |= BUTTON_MASK_SELECT;
167.2887 -  if(sdlButtons[which][KEY_BUTTON_START])
167.2888 -    res |= BUTTON_MASK_START;
167.2889 -  if(sdlButtons[which][KEY_RIGHT])
167.2890 -    res |= BUTTON_MASK_RIGHT;
167.2891 -  if(sdlButtons[which][KEY_LEFT])
167.2892 -    res |= BUTTON_MASK_LEFT;
167.2893 -  if(sdlButtons[which][KEY_UP])
167.2894 -    res |= BUTTON_MASK_UP;
167.2895 -  if(sdlButtons[which][KEY_DOWN])
167.2896 -    res |= BUTTON_MASK_DOWN;
167.2897 -  if(sdlButtons[which][KEY_BUTTON_R])
167.2898 -    res |= BUTTON_MASK_R;
167.2899 -  if(sdlButtons[which][KEY_BUTTON_L])
167.2900 -    res |= BUTTON_MASK_L;
167.2901 -  */
167.2902 -/*
167.2903 -  // disallow L+R or U+D of being pressed at the same time
167.2904 -  if((res & 48) == 48)
167.2905 -    res &= ~16;
167.2906 -  if((res & 192) == 192)
167.2907 -    res &= ~128;
167.2908 -*/
167.2909 -/*  
167.2910 -  if(sdlbuttons[which][KEY_BUTTON_SPEED])
167.2911 -    res |= 1024;
167.2912 -  if(sdlButtons[which][KEY_BUTTON_CAPTURE])
167.2913 -    res |= 2048;
167.2914 -*/
167.2915 -	res = currentButtons[which];
167.2916 -
167.2917 -  if(autoFire) {
167.2918 -    res &= (~autoFire);
167.2919 -    if(autoFireToggle)
167.2920 -      res |= autoFire;
167.2921 -    autoFireToggle = !autoFireToggle;
167.2922 -  }
167.2923 -  
167.2924 -  //if (res) fprintf(stdout,"%x\n",res);
167.2925 -  
167.2926 -  return res;
167.2927 -}
167.2928 -
167.2929 -void systemSetJoypad(int which, u32 buttons)
167.2930 -{
167.2931 -  if(which < 0 || which > 3)
167.2932 -    which = sdlDefaultJoypad;
167.2933 -/*  
167.2934 -  sdlButtons[which][KEY_BUTTON_A] = (buttons & 1) != 0;
167.2935 -  sdlButtons[which][KEY_BUTTON_B] = (buttons & 2) != 0;
167.2936 -  sdlButtons[which][KEY_BUTTON_SELECT] = (buttons & 4) != 0;
167.2937 -  sdlButtons[which][KEY_BUTTON_START] = (buttons & 8) != 0;
167.2938 -  sdlButtons[which][KEY_RIGHT] = (buttons & 16) != 0;
167.2939 -  sdlButtons[which][KEY_LEFT] = (buttons & 32) != 0;
167.2940 -  sdlButtons[which][KEY_UP] = (buttons & 64) != 0;
167.2941 -  sdlButtons[which][KEY_DOWN] = (buttons & 128) != 0;
167.2942 -  sdlButtons[which][KEY_BUTTON_R] = (buttons & 256) != 0;
167.2943 -  sdlButtons[which][KEY_BUTTON_L] = (buttons & 512) != 0;
167.2944 -*/
167.2945 -	currentButtons[which]= buttons & 0x3ff;
167.2946 -}
167.2947 -
167.2948 -void systemClearJoypads()
167.2949 -{
167.2950 -	for (int i = 0; i < 4; ++i)
167.2951 -		currentButtons[i] = 0;
167.2952 -
167.2953 -	//lastKeys = 0;
167.2954 -}
167.2955 -
167.2956 -void systemSetTitle(const char *title)
167.2957 -{
167.2958 -  SDL_WM_SetCaption(title, NULL);
167.2959 -}
167.2960 -
167.2961 -void systemShowSpeed(int speed)
167.2962 -{
167.2963 -  systemSpeed = speed;
167.2964 -
167.2965 -  showRenderedFrames = renderedFrames;
167.2966 -  renderedFrames = 0;  
167.2967 -
167.2968 -  if(!fullscreen && showSpeed) {
167.2969 -    char buffer[80];
167.2970 -    if(showSpeed == 1)
167.2971 -      sprintf(buffer, "VisualBoyAdvance-%3d%%", systemSpeed);
167.2972 -    else
167.2973 -      sprintf(buffer, "VisualBoyAdvance-%3d%%(%d, %d fps)", systemSpeed,
167.2974 -              systemFrameSkip,
167.2975 -              showRenderedFrames);
167.2976 -
167.2977 -    systemSetTitle(buffer);
167.2978 -  }
167.2979 -}
167.2980 -
167.2981 -// FIXME: the timing
167.2982 -void systemFrame(/*int rate*/) //Looking at System.cpp, it looks like rate should be 600
167.2983 -{
167.2984 -  u32 time = systemGetClock();  
167.2985 -  if(!wasPaused && autoFrameSkip && !throttle) {
167.2986 -    u32 diff = time - autoFrameSkipLastTime;
167.2987 -    int speed = 100;
167.2988 -
167.2989 -    if(diff)
167.2990 -      speed = (1000000/600)/diff;
167.2991 -    
167.2992 -    if(speed >= 98) {
167.2993 -      frameskipadjust++;
167.2994 -
167.2995 -      if(frameskipadjust >= 3) {
167.2996 -        frameskipadjust=0;
167.2997 -        if(systemFrameSkip > 0)
167.2998 -          systemFrameSkip--;
167.2999 -      }
167.3000 -    } else {
167.3001 -      if(speed  < 80)
167.3002 -        frameskipadjust -= (90 - speed)/5;
167.3003 -      else if(systemFrameSkip < 9)
167.3004 -        frameskipadjust--;
167.3005 -
167.3006 -      if(frameskipadjust <= -2) {
167.3007 -        frameskipadjust += 2;
167.3008 -        if(systemFrameSkip < 9)
167.3009 -          systemFrameSkip++;
167.3010 -      }
167.3011 -    }    
167.3012 -  }
167.3013 -  if(!wasPaused && throttle) {
167.3014 -    /*if(!speedup) {
167.3015 -      u32 diff = time - throttleLastTime;
167.3016 -      
167.3017 -      int target = (1000000.0/(600*throttle));
167.3018 -      int d = (target - diff);
167.3019 -      
167.3020 -      if(d > 0) {
167.3021 -        SDL_Delay(d);
167.3022 -      }
167.3023 -    }
167.3024 -    throttleLastTime = systemGetClock();
167.3025 -    */
167.3026 -  }
167.3027 -  if(rewindMemory) {
167.3028 -    if(++rewindCounter >= rewindTimer) {
167.3029 -      rewindSaveNeeded = true;
167.3030 -      rewindCounter = 0;
167.3031 -    }
167.3032 -  }
167.3033 -
167.3034 -  if(systemSaveUpdateCounter) {
167.3035 -    if(--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED) {
167.3036 -      sdlWriteBattery();
167.3037 -      systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
167.3038 -    }
167.3039 -  }
167.3040 -
167.3041 -  wasPaused = false;
167.3042 -  autoFrameSkipLastTime = time;
167.3043 -}
167.3044 -
167.3045 -int systemFramesToSkip(){
167.3046 -	return systemFrameSkip;
167.3047 -}
167.3048 -
167.3049 -int systemScreenCapture(int a)
167.3050 -{
167.3051 -  char buffer[2048];
167.3052 -
167.3053 -  if(captureFormat) {
167.3054 -    if(captureDir[0])
167.3055 -      sprintf(buffer, "%s/%s%02d.bmp", captureDir, sdlGetFilename(filename), a);
167.3056 -    else
167.3057 -      sprintf(buffer, "%s%02d.bmp", filename, a);
167.3058 -
167.3059 -    theEmulator.emuWriteBMP(buffer);
167.3060 -  } else {
167.3061 -    if(captureDir[0])
167.3062 -      sprintf(buffer, "%s/%s%02d.png", captureDir, sdlGetFilename(filename), a);
167.3063 -    else
167.3064 -      sprintf(buffer, "%s%02d.png", filename, a);
167.3065 -    theEmulator.emuWritePNG(buffer);
167.3066 -  }
167.3067 -
167.3068 -  systemScreenMessage("Screen capture");
167.3069 -  return a;
167.3070 -}
167.3071 -
167.3072 -void soundCallback(void *,u8 *stream,int len){}
167.3073 -
167.3074 -void systemSoundWriteToBuffer(){
167.3075 -	soundDriver->write(soundFinalWave, soundBufferLen);  
167.3076 -}
167.3077 -
167.3078 -void systemSoundClearBuffer()
167.3079 -{
167.3080 -	SDL_mutexP(mutex);
167.3081 -	memset(sdlBuffer,0,soundBufferTotalLen);
167.3082 -	sdlSoundLen=0;
167.3083 -	printf("Hi\n");
167.3084 -	SDL_mutexV(mutex);
167.3085 -}
167.3086 -
167.3087 -bool systemSoundInit(){
167.3088 -	systemSoundShutdown();
167.3089 -	soundDriver = new SoundSDL();
167.3090 -	if ( !soundDriver )
167.3091 -		return false;
167.3092 -
167.3093 -	if (!soundDriver->init()) //<-- sound sample rate
167.3094 -		return false;
167.3095 -	
167.3096 -	if (!(soundDriver->setThrottle(throttle))){
167.3097 -        	fprintf(stderr,"Failed to set desired throttle, defaulting to 100 %%.\n");
167.3098 -        	if (!soundDriver->setThrottle(100)) return false;
167.3099 -        }
167.3100 -	soundPaused = true;
167.3101 -	systemSoundOn = true;
167.3102 -	return true;
167.3103 -}
167.3104 -
167.3105 -void systemSoundShutdown(){
167.3106 -	if (soundDriver)
167.3107 -	{
167.3108 -		delete soundDriver;
167.3109 -		soundDriver = 0;
167.3110 -	}
167.3111 -}
167.3112 -
167.3113 -void systemSoundPause()
167.3114 -{
167.3115 -  SDL_PauseAudio(1);
167.3116 -}
167.3117 -
167.3118 -void systemSoundResume()
167.3119 -{
167.3120 -  SDL_PauseAudio(0);
167.3121 -}
167.3122 -
167.3123 -void systemSoundReset()
167.3124 -{
167.3125 -}
167.3126 -
167.3127 -u32 systemGetClock()
167.3128 -{
167.3129 -  return SDL_GetTicks();
167.3130 -}
167.3131 -
167.3132 -void systemUpdateMotionSensor()
167.3133 -{
167.3134 -  if(sdlMotionButtons[KEY_LEFT]) {
167.3135 -    sensorX += 3;
167.3136 -    if(sensorX > 2197)
167.3137 -      sensorX = 2197;
167.3138 -    if(sensorX < 2047)
167.3139 -      sensorX = 2057;
167.3140 -  } else if(sdlMotionButtons[KEY_RIGHT]) {
167.3141 -    sensorX -= 3;
167.3142 -    if(sensorX < 1897)
167.3143 -      sensorX = 1897;
167.3144 -    if(sensorX > 2047)
167.3145 -      sensorX = 2037;
167.3146 -  } else if(sensorX > 2047) {
167.3147 -    sensorX -= 2;
167.3148 -    if(sensorX < 2047)
167.3149 -      sensorX = 2047;
167.3150 -  } else {
167.3151 -    sensorX += 2;
167.3152 -    if(sensorX > 2047)
167.3153 -      sensorX = 2047;
167.3154 -  }
167.3155 -
167.3156 -  if(sdlMotionButtons[KEY_UP]) {
167.3157 -    sensorY += 3;
167.3158 -    if(sensorY > 2197)
167.3159 -      sensorY = 2197;
167.3160 -    if(sensorY < 2047)
167.3161 -      sensorY = 2057;
167.3162 -  } else if(sdlMotionButtons[KEY_DOWN]) {
167.3163 -    sensorY -= 3;
167.3164 -    if(sensorY < 1897)
167.3165 -      sensorY = 1897;
167.3166 -    if(sensorY > 2047)
167.3167 -      sensorY = 2037;
167.3168 -  } else if(sensorY > 2047) {
167.3169 -    sensorY -= 2;
167.3170 -    if(sensorY < 2047)
167.3171 -      sensorY = 2047;
167.3172 -  } else {
167.3173 -    sensorY += 2;
167.3174 -    if(sensorY > 2047)
167.3175 -      sensorY = 2047;
167.3176 -  }    
167.3177 -}
167.3178 -
167.3179 -void systemResetSensor()
167.3180 -{
167.3181 -	sensorX = sensorY = INITIAL_SENSOR_VALUE;
167.3182 -}
167.3183 -
167.3184 -int systemGetSensorX()
167.3185 -{
167.3186 -  return sensorX;
167.3187 -}
167.3188 -
167.3189 -int systemGetSensorY()
167.3190 -{
167.3191 -  return sensorY;
167.3192 -}
167.3193 -
167.3194 -void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast)
167.3195 -{
167.3196 -}
167.3197 -
167.3198 -void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList)
167.3199 -{
167.3200 -  screenMessage[slot] = true;
167.3201 -  screenMessageTime[slot] = systemGetClock();
167.3202 -  screenMessageDuration[slot] = duration;
167.3203 -  if(strlen(msg) > 20) {
167.3204 -    strncpy(screenMessageBuffer[slot], msg, 20);
167.3205 -    screenMessageBuffer[slot][20] = 0;
167.3206 -  } else
167.3207 -    strcpy(screenMessageBuffer[slot], msg);  
167.3208 -}
167.3209 -
167.3210 -bool systemSoundCanChangeQuality()
167.3211 -{
167.3212 -  return false;
167.3213 -}
167.3214 -
167.3215 -bool systemSoundSetQuality(int quality)
167.3216 -{
167.3217 -	if (systemCartridgeType == 0)
167.3218 -		soundSetQuality(quality);
167.3219 -	else
167.3220 -		gbSoundSetQuality(quality);
167.3221 -
167.3222 -	return true;
167.3223 -}
167.3224 -
167.3225 -bool systemPauseOnFrame()
167.3226 -{
167.3227 -  if(pauseNextFrame) {
167.3228 -    paused = true;
167.3229 -    pauseNextFrame = false;
167.3230 -    return true;
167.3231 -  }
167.3232 -  return false;
167.3233 -}
167.3234 -
167.3235 -// Code donated by Niels Wagenaar (BoycottAdvance)
167.3236 -
167.3237 -// GBA screensize.
167.3238 -#define GBA_WIDTH   240
167.3239 -#define GBA_HEIGHT  160
167.3240 -
167.3241 -void Init_Overlay(SDL_Surface *gbascreen, int overlaytype)
167.3242 -{
167.3243 -  
167.3244 -  overlay = SDL_CreateYUVOverlay( GBA_WIDTH,
167.3245 -                                  GBA_HEIGHT,
167.3246 -                                  overlaytype, gbascreen);
167.3247 -  fprintf(stderr, "Created %dx%dx%d %s %s overlay\n",
167.3248 -          overlay->w,overlay->h,overlay->planes,
167.3249 -          overlay->hw_overlay?"hardware":"software",
167.3250 -          overlay->format==SDL_YV12_OVERLAY?"YV12":
167.3251 -          overlay->format==SDL_IYUV_OVERLAY?"IYUV":
167.3252 -          overlay->format==SDL_YUY2_OVERLAY?"YUY2":
167.3253 -          overlay->format==SDL_UYVY_OVERLAY?"UYVY":
167.3254 -          overlay->format==SDL_YVYU_OVERLAY?"YVYU":
167.3255 -          "Unknown");
167.3256 -}
167.3257 -
167.3258 -void Quit_Overlay(void)
167.3259 -{
167.3260 -  
167.3261 -  SDL_FreeYUVOverlay(overlay);
167.3262 -}
167.3263 -
167.3264 -/* NOTE: These RGB conversion functions are not intended for speed,
167.3265 -   only as examples.
167.3266 -*/
167.3267 -inline void RGBtoYUV(Uint8 *rgb, int *yuv)
167.3268 -{
167.3269 -  yuv[0] = (int)((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
167.3270 -  yuv[1] = (int)(128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]));
167.3271 -  yuv[2] = (int)(128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]));
167.3272 -}
167.3273 -
167.3274 -inline void ConvertRGBtoYV12(SDL_Overlay *o)
167.3275 -{
167.3276 -  int x,y;
167.3277 -  int yuv[3];
167.3278 -  Uint8 *p,*op[3];
167.3279 -  
167.3280 -  SDL_LockYUVOverlay(o);
167.3281 -  
167.3282 -  /* Black initialization */
167.3283 -  /*
167.3284 -    memset(o->pixels[0],0,o->pitches[0]*o->h);
167.3285 -    memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
167.3286 -    memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
167.3287 -  */
167.3288 -  
167.3289 -  /* Convert */
167.3290 -  for(y=0; y<160 && y<o->h; y++) {
167.3291 -    p=(Uint8 *)pix+srcPitch*y;
167.3292 -    op[0]=o->pixels[0]+o->pitches[0]*y;
167.3293 -    op[1]=o->pixels[1]+o->pitches[1]*(y/2);
167.3294 -    op[2]=o->pixels[2]+o->pitches[2]*(y/2);
167.3295 -    for(x=0; x<240 && x<o->w; x++) {
167.3296 -      RGBtoYUV(p,yuv);
167.3297 -      *(op[0]++)=yuv[0];
167.3298 -      if(x%2==0 && y%2==0) {
167.3299 -        *(op[1]++)=yuv[2];
167.3300 -        *(op[2]++)=yuv[1];
167.3301 -      }
167.3302 -      p+=4;//s->format->BytesPerPixel;
167.3303 -    }
167.3304 -  }
167.3305 -  
167.3306 -  SDL_UnlockYUVOverlay(o);
167.3307 -}
167.3308 -
167.3309 -inline void ConvertRGBtoIYUV(SDL_Overlay *o)
167.3310 -{
167.3311 -  int x,y;
167.3312 -  int yuv[3];
167.3313 -  Uint8 *p,*op[3];
167.3314 -  
167.3315 -  SDL_LockYUVOverlay(o);
167.3316 -  
167.3317 -  /* Black initialization */
167.3318 -  /*
167.3319 -    memset(o->pixels[0],0,o->pitches[0]*o->h);
167.3320 -    memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
167.3321 -    memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
167.3322 -  */
167.3323 -  
167.3324 -  /* Convert */
167.3325 -  for(y=0; y<160 && y<o->h; y++) {
167.3326 -    p=(Uint8 *)pix+srcPitch*y;
167.3327 -    op[0]=o->pixels[0]+o->pitches[0]*y;
167.3328 -    op[1]=o->pixels[1]+o->pitches[1]*(y/2);
167.3329 -    op[2]=o->pixels[2]+o->pitches[2]*(y/2);
167.3330 -    for(x=0; x<240 && x<o->w; x++) {
167.3331 -      RGBtoYUV(p,yuv);
167.3332 -      *(op[0]++)=yuv[0];
167.3333 -      if(x%2==0 && y%2==0) {
167.3334 -        *(op[1]++)=yuv[1];
167.3335 -        *(op[2]++)=yuv[2];
167.3336 -      }
167.3337 -      p+=4; //s->format->BytesPerPixel;
167.3338 -    }
167.3339 -  }
167.3340 -  
167.3341 -  SDL_UnlockYUVOverlay(o);
167.3342 -}
167.3343 -
167.3344 -inline void ConvertRGBtoUYVY(SDL_Overlay *o)
167.3345 -{
167.3346 -  int x,y;
167.3347 -  int yuv[3];
167.3348 -  Uint8 *p,*op;
167.3349 -  
167.3350 -  SDL_LockYUVOverlay(o);
167.3351 -  
167.3352 -  for(y=0; y<160 && y<o->h; y++) {
167.3353 -    p=(Uint8 *)pix+srcPitch*y;
167.3354 -    op=o->pixels[0]+o->pitches[0]*y;
167.3355 -    for(x=0; x<240 && x<o->w; x++) {
167.3356 -      RGBtoYUV(p,yuv);
167.3357 -      if(x%2==0) {
167.3358 -        *(op++)=yuv[1];
167.3359 -        *(op++)=yuv[0];
167.3360 -        *(op++)=yuv[2];
167.3361 -      } else
167.3362 -        *(op++)=yuv[0];
167.3363 -      
167.3364 -      p+=4; //s->format->BytesPerPixel;
167.3365 -    }
167.3366 -  }
167.3367 -  
167.3368 -  SDL_UnlockYUVOverlay(o);
167.3369 -}
167.3370 -
167.3371 -inline void ConvertRGBtoYVYU(SDL_Overlay *o)
167.3372 -{
167.3373 -  int x,y;
167.3374 -  int yuv[3];
167.3375 -  Uint8 *p,*op;
167.3376 -  
167.3377 -  SDL_LockYUVOverlay(o);
167.3378 -  
167.3379 -  for(y=0; y<160 && y<o->h; y++) {
167.3380 -    p=(Uint8 *)pix+srcPitch*y;
167.3381 -    op=o->pixels[0]+o->pitches[0]*y;
167.3382 -    for(x=0; x<240 && x<o->w; x++) {
167.3383 -      RGBtoYUV(p,yuv);
167.3384 -      if(x%2==0) {
167.3385 -        *(op++)=yuv[0];
167.3386 -        *(op++)=yuv[2];
167.3387 -        op[1]=yuv[1];
167.3388 -      } else {
167.3389 -        *op=yuv[0];
167.3390 -        op+=2;
167.3391 -      }
167.3392 -      
167.3393 -      p+=4; //s->format->BytesPerPixel;
167.3394 -    }
167.3395 -  }
167.3396 -  
167.3397 -  SDL_UnlockYUVOverlay(o);
167.3398 -}
167.3399 -
167.3400 -inline void ConvertRGBtoYUY2(SDL_Overlay *o)
167.3401 -{
167.3402 -  int x,y;
167.3403 -  int yuv[3];
167.3404 -  Uint8 *p,*op;
167.3405 -  
167.3406 -  SDL_LockYUVOverlay(o);
167.3407 -  
167.3408 -  for(y=0; y<160 && y<o->h; y++) {
167.3409 -    p=(Uint8 *)pix+srcPitch*y;
167.3410 -    op=o->pixels[0]+o->pitches[0]*y;
167.3411 -    for(x=0; x<240 && x<o->w; x++) {
167.3412 -      RGBtoYUV(p,yuv);
167.3413 -      if(x%2==0) {
167.3414 -        *(op++)=yuv[0];
167.3415 -        *(op++)=yuv[1];
167.3416 -        op[1]=yuv[2];
167.3417 -      } else {
167.3418 -        *op=yuv[0];
167.3419 -        op+=2;
167.3420 -      }
167.3421 -      
167.3422 -      p+=4; //s->format->BytesPerPixel;
167.3423 -    }
167.3424 -  }
167.3425 -  
167.3426 -  SDL_UnlockYUVOverlay(o);
167.3427 -}
167.3428 -
167.3429 -inline void Convert32bit(SDL_Surface *display)
167.3430 -{
167.3431 -  switch(overlay->format) {
167.3432 -  case SDL_YV12_OVERLAY:
167.3433 -    ConvertRGBtoYV12(overlay);
167.3434 -    break;
167.3435 -  case SDL_UYVY_OVERLAY:
167.3436 -    ConvertRGBtoUYVY(overlay);
167.3437 -    break;
167.3438 -  case SDL_YVYU_OVERLAY:
167.3439 -    ConvertRGBtoYVYU(overlay);
167.3440 -    break;
167.3441 -  case SDL_YUY2_OVERLAY:
167.3442 -    ConvertRGBtoYUY2(overlay);
167.3443 -    break;
167.3444 -  case SDL_IYUV_OVERLAY:
167.3445 -    ConvertRGBtoIYUV(overlay);
167.3446 -    break;
167.3447 -  default:
167.3448 -    fprintf(stderr, "cannot convert RGB picture to obtained YUV format!\n");
167.3449 -    exit(1);
167.3450 -    break;
167.3451 -  }
167.3452 -  
167.3453 -}
167.3454 -
167.3455 -
167.3456 -inline void Draw_Overlay(SDL_Surface *display, int size)
167.3457 -{
167.3458 -  SDL_LockYUVOverlay(overlay);
167.3459 -  
167.3460 -  Convert32bit(display);
167.3461 -  
167.3462 -  overlay_rect.x = 0;
167.3463 -  overlay_rect.y = 0;
167.3464 -  overlay_rect.w = GBA_WIDTH  * size;
167.3465 -  overlay_rect.h = GBA_HEIGHT * size;
167.3466 -
167.3467 -  SDL_DisplayYUVOverlay(overlay, &overlay_rect);
167.3468 -  SDL_UnlockYUVOverlay(overlay);
167.3469 -}
167.3470 -
167.3471 -bool systemIsEmulating()
167.3472 -{
167.3473 -	return emulating != 0;
167.3474 -}
167.3475 -
167.3476 -void systemGbBorderOn()
167.3477 -{
167.3478 -  srcWidth = 256;
167.3479 -  srcHeight = 224;
167.3480 -  gbBorderLineSkip = 256;
167.3481 -  gbBorderColumnSkip = 48;
167.3482 -  gbBorderRowSkip = 40;
167.3483 -
167.3484 -  destWidth = (sizeOption+1)*srcWidth;
167.3485 -  destHeight = (sizeOption+1)*srcHeight;
167.3486 -  
167.3487 -  surface = SDL_SetVideoMode(destWidth, destHeight, 16,
167.3488 -                             SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
167.3489 -                             (fullscreen ? SDL_FULLSCREEN : 0));  
167.3490 -#ifndef C_CORE
167.3491 -  sdlMakeStretcher(srcWidth);
167.3492 -#else
167.3493 -  switch(systemColorDepth) {
167.3494 -  case 16:
167.3495 -    sdlStretcher = sdlStretcher16[sizeOption];
167.3496 -    break;
167.3497 -  case 24:
167.3498 -    sdlStretcher = sdlStretcher24[sizeOption];
167.3499 -    break;
167.3500 -  case 32:
167.3501 -    sdlStretcher = sdlStretcher32[sizeOption];
167.3502 -    break;
167.3503 -  default:
167.3504 -    fprintf(stderr, "Unsupported resolution: %d\n", systemColorDepth);
167.3505 -    exit(-1);
167.3506 -  }
167.3507 -#endif
167.3508 -
167.3509 -  if(systemColorDepth == 16) {
167.3510 -    if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) {
167.3511 -      Init_2xSaI(565);
167.3512 -      RGB_LOW_BITS_MASK = 0x821;
167.3513 -    } else {
167.3514 -      Init_2xSaI(555);
167.3515 -      RGB_LOW_BITS_MASK = 0x421;      
167.3516 -    }
167.3517 -    if(systemCartridgeType == 2) {
167.3518 -      for(int i = 0; i < 0x10000; i++) {
167.3519 -        systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) |
167.3520 -          (((i & 0x7c0) >> 6) << systemGreenShift) |
167.3521 -          (((i & 0xf800) >> 11) << systemRedShift);  
167.3522 -      }      
167.3523 -    } else {
167.3524 -      for(int i = 0; i < 0x10000; i++) {
167.3525 -        systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
167.3526 -          (((i & 0x3e0) >> 5) << systemGreenShift) |
167.3527 -          (((i & 0x7c00) >> 10) << systemBlueShift);  
167.3528 -      }
167.3529 -    }
167.3530 -    srcPitch = srcWidth * 2+4;
167.3531 -  } else {
167.3532 -    if(systemColorDepth != 32)
167.3533 -      filterFunction = NULL;
167.3534 -    RGB_LOW_BITS_MASK = 0x010101;
167.3535 -    if(systemColorDepth == 32) {
167.3536 -      Init_2xSaI(32);
167.3537 -    }
167.3538 -    for(int i = 0; i < 0x10000; i++) {
167.3539 -      systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
167.3540 -        (((i & 0x3e0) >> 5) << systemGreenShift) |
167.3541 -        (((i & 0x7c00) >> 10) << systemBlueShift);  
167.3542 -    }
167.3543 -    if(systemColorDepth == 32)
167.3544 -      srcPitch = srcWidth*4 + 4;
167.3545 -    else
167.3546 -      srcPitch = srcWidth*3;
167.3547 -  }
167.3548 -}
167.3549 -
167.3550 -bool systemIsRunningGBA()
167.3551 -{
167.3552 -	return (rom != NULL);
167.3553 -}
167.3554 -
167.3555 -int systemGetDefaultJoypad()
167.3556 -{
167.3557 -	return sdlDefaultJoypad;
167.3558 -}
167.3559 -
167.3560 -bool systemIsPaused()
167.3561 -{
167.3562 -	return paused;
167.3563 -}
167.3564 -
167.3565 -void systemSetPause(bool pause)
167.3566 -{
167.3567 -	paused = pause;
167.3568 -	if (pause)
167.3569 -		systemSoundPause();
167.3570 -	else
167.3571 -		systemSoundResume();
167.3572 -}
167.3573 -
167.3574 -u16 checksumBIOS()
167.3575 -{
167.3576 -	bool hasBIOS = false;
167.3577 -	u8 * tempBIOS;
167.3578 -	if(useBios)
167.3579 -	{
167.3580 -		tempBIOS = (u8 *)malloc(0x4000);
167.3581 -		int size = 0x4000;
167.3582 -		if(utilLoad(biosFileName,
167.3583 -					utilIsGBABios,
167.3584 -					tempBIOS,
167.3585 -					size)) {
167.3586 -		if(size == 0x4000)
167.3587 -			hasBIOS = true;
167.3588 -		}
167.3589 -	}
167.3590 -
167.3591 -	u16 biosCheck = 0;
167.3592 -	if(hasBIOS) {
167.3593 -		for(int i = 0; i < 0x4000; i += 4)
167.3594 -			biosCheck += *((u32 *)&tempBIOS[i]);
167.3595 -		free(tempBIOS);
167.3596 -	}
167.3597 -
167.3598 -	return biosCheck;
167.3599 -}
167.3600 -
167.3601 -EmulatedSystemCounters systemCounters = {
167.3602 -	0,	//framecount
167.3603 -	0,	//lagcount
167.3604 -	0,	//extracount
167.3605 -	true,	//lagged
167.3606 -	true	//laggedLast
167.3607 -};
167.3608 -
167.3609 -void VBAOnEnteringFrameBoundary()
167.3610 -{
167.3611 -	CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
167.3612 -
167.3613 -	if (VBALuaRunning())
167.3614 -	{
167.3615 -		VBALuaFrameBoundary();
167.3616 -	}
167.3617 -
167.3618 -	VBAMovieUpdateState();
167.3619 -}
167.3620 -
167.3621 -void VBAOnExitingFrameBoundary()
167.3622 -{
167.3623 -	;
167.3624 -}
167.3625 -
167.3626 -
   168.1 --- a/src/sdl/SoundDriver.h	Sat Mar 03 10:54:39 2012 -0600
   168.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   168.3 @@ -1,65 +0,0 @@
   168.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   168.5 -// Copyright (C) 2008 VBA-M development team
   168.6 -
   168.7 -// This program is free software; you can redistribute it and/or modify
   168.8 -// it under the terms of the GNU General Public License as published by
   168.9 -// the Free Software Foundation; either version 2, or(at your option)
  168.10 -// any later version.
  168.11 -//
  168.12 -// This program is distributed in the hope that it will be useful,
  168.13 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  168.14 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  168.15 -// GNU General Public License for more details.
  168.16 -//
  168.17 -// You should have received a copy of the GNU General Public License
  168.18 -// along with this program; if not, write to the Free Software Foundation,
  168.19 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  168.20 -
  168.21 -#ifndef __VBA_SOUND_DRIVER_H__
  168.22 -#define __VBA_SOUND_DRIVER_H__
  168.23 -
  168.24 -#include "Types.h"
  168.25 -
  168.26 -/**
  168.27 - * Sound driver abstract interface for the core to use to output sound.
  168.28 - * Subclass this to implement a new sound driver.
  168.29 - */
  168.30 -class SoundDriver
  168.31 -{
  168.32 -public:
  168.33 -
  168.34 -	/**
  168.35 -	 * Destructor. Free the resources allocated by the sound driver.
  168.36 -	 */
  168.37 -	virtual ~SoundDriver() { };
  168.38 -
  168.39 -	/**
  168.40 -	 * Initialize the sound driver.
  168.41 -	 * @param sampleRate In Hertz
  168.42 -	 */
  168.43 -	virtual bool init() = 0;
  168.44 -
  168.45 -	/**
  168.46 -	 * Tell the driver that the sound stream has paused
  168.47 -	 */
  168.48 -	virtual void pause() = 0;
  168.49 -
  168.50 -	/**
  168.51 -	 * Reset the sound driver
  168.52 -	 */
  168.53 -	virtual void reset() = 0;
  168.54 -
  168.55 -	/**
  168.56 -	 * Tell the driver that the sound stream has resumed
  168.57 -	 */
  168.58 -	virtual void resume() = 0;
  168.59 -
  168.60 -	/**
  168.61 -	 * Write length bytes of data from the finalWave buffer to the driver output buffer.
  168.62 -	 */
  168.63 -	virtual void write(u16 * finalWave, int length) = 0;
  168.64 -
  168.65 -	virtual bool setThrottle(unsigned short throttle) = 0;
  168.66 -};
  168.67 -
  168.68 -#endif // __VBA_SOUND_DRIVER_H__
   169.1 --- a/src/sdl/SoundSDL.cpp	Sat Mar 03 10:54:39 2012 -0600
   169.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   169.3 @@ -1,178 +0,0 @@
   169.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   169.5 -// Copyright (C) 2008 VBA-M development team
   169.6 -
   169.7 -// This program is free software; you can redistribute it and/or modify
   169.8 -// it under the terms of the GNU General Public License as published by
   169.9 -// the Free Software Foundation; either version 2, or(at your option)
  169.10 -// any later version.
  169.11 -//
  169.12 -// This program is distributed in the hope that it will be useful,
  169.13 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  169.14 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  169.15 -// GNU General Public License for more details.
  169.16 -//
  169.17 -// You should have received a copy of the GNU General Public License
  169.18 -// along with this program; if not, write to the Free Software Foundation,
  169.19 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  169.20 -
  169.21 -#include "SoundSDL.h"
  169.22 -
  169.23 -extern int emulating;
  169.24 -extern bool speedup;
  169.25 -
  169.26 -// Hold up to 100 ms of data in the ring buffer
  169.27 -const float SoundSDL::_delay = 0.1f;
  169.28 -
  169.29 -SoundSDL::SoundSDL():
  169.30 -	_rbuf(0),
  169.31 -	_initialized(false)
  169.32 -{
  169.33 -
  169.34 -}
  169.35 -
  169.36 -void SoundSDL::soundCallback(void *data, u8 *stream, int len)
  169.37 -{
  169.38 -	reinterpret_cast<SoundSDL*>(data)->read(reinterpret_cast<u16 *>(stream), len);
  169.39 -}
  169.40 -
  169.41 -void SoundSDL::read(u16 * stream, int length)
  169.42 -{
  169.43 -	if (!_initialized || length <= 0 || !emulating)
  169.44 -		return;
  169.45 -
  169.46 -	SDL_mutexP(_mutex);
  169.47 -	_rbuf.read(stream, std::min(static_cast<std::size_t>(length) / 2, _rbuf.used()));
  169.48 -
  169.49 -	SDL_CondSignal(_cond);
  169.50 -	SDL_mutexV(_mutex);
  169.51 -}
  169.52 -
  169.53 -void SoundSDL::write(u16 * finalWave, int length)
  169.54 -{
  169.55 -	if (!_initialized)
  169.56 -		return;
  169.57 -
  169.58 -	if (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)
  169.59 -		SDL_PauseAudio(0);
  169.60 -
  169.61 -	SDL_mutexP(_mutex);
  169.62 -
  169.63 -	unsigned int samples = length / 4;
  169.64 -
  169.65 -	std::size_t avail;
  169.66 -	while ((avail = _rbuf.avail() / 2) < samples)
  169.67 -	{
  169.68 -		_rbuf.write(finalWave, avail * 2);
  169.69 -
  169.70 -		finalWave += avail * 2;
  169.71 -		samples -= avail;
  169.72 -
  169.73 -		// If emulating and not in speed up mode, synchronize to audio
  169.74 -		// by waiting till there is enough room in the buffer
  169.75 -		if (emulating && !speedup)
  169.76 -		{
  169.77 -			SDL_CondWait(_cond,_mutex);
  169.78 -		}
  169.79 -		else
  169.80 -		{
  169.81 -			// Drop the remaining of the audio data
  169.82 -			SDL_mutexV(_mutex);
  169.83 -			return;
  169.84 -		}
  169.85 -	}
  169.86 -
  169.87 -	_rbuf.write(finalWave, samples * 2);
  169.88 -
  169.89 -	SDL_mutexV(_mutex);
  169.90 -}
  169.91 -
  169.92 -
  169.93 -bool SoundSDL::init()
  169.94 -{
  169.95 -	SDL_AudioSpec audio;
  169.96 -	audio.freq = SDL_SAMPLE_RATE;
  169.97 -	audio.format = AUDIO_S16SYS;
  169.98 -	audio.channels = 2;
  169.99 -	audio.samples = 1024;
 169.100 -	audio.callback = soundCallback;
 169.101 -	audio.userdata = this;
 169.102 -
 169.103 -	if(SDL_OpenAudio(&audio, NULL))
 169.104 -	{
 169.105 -		fprintf(stderr,"Failed to open audio: %s\n", SDL_GetError());
 169.106 -		return false;
 169.107 -	}
 169.108 -
 169.109 -	_rbuf.reset(_delay * SDL_SAMPLE_RATE * 2);
 169.110 -
 169.111 -	_cond  = SDL_CreateCond();
 169.112 -	_mutex = SDL_CreateMutex();
 169.113 -	_initialized = true;
 169.114 -
 169.115 -	return true;
 169.116 -}
 169.117 -
 169.118 -SoundSDL::~SoundSDL()
 169.119 -{
 169.120 -	if (!_initialized)
 169.121 -		return;
 169.122 -
 169.123 -	SDL_mutexP(_mutex);
 169.124 -	int iSave = emulating;
 169.125 -	emulating = 0;
 169.126 -	SDL_CondSignal(_cond);
 169.127 -	SDL_mutexV(_mutex);
 169.128 -
 169.129 -	SDL_DestroyCond(_cond);
 169.130 -	_cond = NULL;
 169.131 -
 169.132 -	SDL_DestroyMutex(_mutex);
 169.133 -	_mutex = NULL;
 169.134 -
 169.135 -	SDL_CloseAudio();
 169.136 -
 169.137 -	emulating = iSave;
 169.138 -}
 169.139 -
 169.140 -void SoundSDL::pause()
 169.141 -{
 169.142 -	if (!_initialized)
 169.143 -		return;
 169.144 -
 169.145 -	SDL_PauseAudio(1);
 169.146 -}
 169.147 -
 169.148 -void SoundSDL::resume()
 169.149 -{
 169.150 -	if (!_initialized)
 169.151 -		return;
 169.152 -
 169.153 -	SDL_PauseAudio(0);
 169.154 -}
 169.155 -
 169.156 -void SoundSDL::reset()
 169.157 -{
 169.158 -}
 169.159 -
 169.160 -bool SoundSDL::setThrottle(unsigned short throttle){
 169.161 -	switch(throttle){
 169.162 -		case 25:
 169.163 -		case 50:
 169.164 -		case 100:
 169.165 -		case 200:
 169.166 -		case 400:
 169.167 -			break;
 169.168 -		default:
 169.169 -			return false;
 169.170 -	}
 169.171 -	SDL_CloseAudio();
 169.172 -	SDL_AudioSpec audio;
 169.173 -	audio.freq = SDL_SAMPLE_RATE*throttle/100;
 169.174 -	audio.format = AUDIO_S16SYS;
 169.175 -	audio.channels = 2;
 169.176 -	audio.samples = 1024;
 169.177 -	audio.callback = soundCallback;
 169.178 -	audio.userdata = this;
 169.179 -	_rbuf.reset((_delay * SDL_SAMPLE_RATE * throttle * 2)/100);
 169.180 -	return !SDL_OpenAudio(&audio,NULL);
 169.181 -}
   170.1 --- a/src/sdl/SoundSDL.h	Sat Mar 03 10:54:39 2012 -0600
   170.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   170.3 @@ -1,56 +0,0 @@
   170.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   170.5 -// Copyright (C) 2008 VBA-M development team
   170.6 -
   170.7 -// This program is free software; you can redistribute it and/or modify
   170.8 -// it under the terms of the GNU General Public License as published by
   170.9 -// the Free Software Foundation; either version 2, or(at your option)
  170.10 -// any later version.
  170.11 -//
  170.12 -// This program is distributed in the hope that it will be useful,
  170.13 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  170.14 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  170.15 -// GNU General Public License for more details.
  170.16 -//
  170.17 -// You should have received a copy of the GNU General Public License
  170.18 -// along with this program; if not, write to the Free Software Foundation,
  170.19 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  170.20 -
  170.21 -#ifndef __VBA_SOUND_SDL_H__
  170.22 -#define __VBA_SOUND_SDL_H__
  170.23 -
  170.24 -#include "SoundDriver.h"
  170.25 -#include "RingBuffer.h"
  170.26 -
  170.27 -#include <SDL.h>
  170.28 -
  170.29 -const int SDL_SAMPLE_RATE = 44100;
  170.30 -
  170.31 -class SoundSDL: public SoundDriver
  170.32 -{
  170.33 -public:
  170.34 -	SoundSDL();
  170.35 -	virtual ~SoundSDL();
  170.36 -
  170.37 -	virtual bool init();
  170.38 -	virtual void pause();
  170.39 -	virtual void reset();
  170.40 -	virtual void resume();
  170.41 -	virtual void write(u16 * finalWave, int length);
  170.42 -	virtual bool setThrottle(unsigned short throttle);
  170.43 -
  170.44 -//private:
  170.45 -	RingBuffer<u16> _rbuf;
  170.46 -
  170.47 -	SDL_cond  * _cond;
  170.48 -	SDL_mutex * _mutex;
  170.49 -
  170.50 -	bool _initialized;
  170.51 -
  170.52 -	// Defines what delay in seconds we keep in the sound buffer
  170.53 -	static const float _delay;
  170.54 -
  170.55 -	static void soundCallback(void *data, u8 *stream, int length);
  170.56 -	virtual void read(u16 * stream, int length);
  170.57 -};
  170.58 -
  170.59 -#endif // __VBA_SOUND_SDL_H__
   171.1 --- a/src/sdl/TestEmu.cpp	Sat Mar 03 10:54:39 2012 -0600
   171.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   171.3 @@ -1,501 +0,0 @@
   171.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   171.5 -// Copyright (C) 1999-2003 Forgotten
   171.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   171.7 -
   171.8 -// This program is free software; you can redistribute it and/or modify
   171.9 -// it under the terms of the GNU General Public License as published by
  171.10 -// the Free Software Foundation; either version 2, or(at your option)
  171.11 -// any later version.
  171.12 -//
  171.13 -// This program is distributed in the hope that it will be useful,
  171.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  171.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  171.16 -// GNU General Public License for more details.
  171.17 -//
  171.18 -// You should have received a copy of the GNU General Public License
  171.19 -// along with this program; if not, write to the Free Software Foundation,
  171.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  171.21 -
  171.22 -#include <stdarg.h>
  171.23 -#include <stdlib.h>
  171.24 -#include <stdio.h>
  171.25 -#include <string.h>
  171.26 -#include <sys/types.h>
  171.27 -#include <sys/stat.h>
  171.28 -
  171.29 -#include "AutoBuild.h"
  171.30 -
  171.31 -#include "SDL.h"
  171.32 -#include "debugger.h"
  171.33 -#include "common/System.h"
  171.34 -#include "common/unzip.h"
  171.35 -#include "common/Util.h"
  171.36 -#include "gba/GBA.h"
  171.37 -#include "gba/GBAGlobals.h"
  171.38 -#include "gba/GBASound.h"
  171.39 -#include "gb/GB.h"
  171.40 -#include "gb/gbGlobals.h"
  171.41 -
  171.42 -#ifndef WIN32
  171.43 -# include <unistd.h>
  171.44 -# define GETCWD getcwd
  171.45 -#else // WIN32
  171.46 -# include <direct.h>
  171.47 -# define GETCWD _getcwd
  171.48 -#endif // WIN32
  171.49 -
  171.50 -#ifdef MMX
  171.51 -extern "C" bool cpu_mmx;
  171.52 -#endif
  171.53 -extern bool8 soundEcho;
  171.54 -extern bool8 soundLowPass;
  171.55 -extern bool8 soundReverse;
  171.56 -
  171.57 -extern void remoteInit();
  171.58 -extern void remoteCleanUp();
  171.59 -extern void remoteStubMain();
  171.60 -extern void remoteStubSignal(int,int);
  171.61 -extern void remoteOutput(char *, u32);
  171.62 -extern void remoteSetProtocol(int);
  171.63 -extern void remoteSetPort(int);
  171.64 -extern void debuggerOutput(char *, u32);
  171.65 -
  171.66 -struct EmulatedSystem emulator;
  171.67 -
  171.68 -int systemRedShift = 0;
  171.69 -int systemBlueShift = 16;
  171.70 -int systemGreenShift = 8;
  171.71 -int systemColorDepth = 32;
  171.72 -int systemDebug = 0;
  171.73 -int systemVerbose = 0;
  171.74 -int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
  171.75 -
  171.76 -int sensorX = 2047;
  171.77 -int sensorY = 2047;
  171.78 -bool sensorOn = false;
  171.79 -
  171.80 -int cartridgeType = 3;
  171.81 -int captureFormat = 0;
  171.82 -
  171.83 -int emulating = 0;
  171.84 -int RGB_LOW_BITS_MASK=0x821;
  171.85 -int systemFrameSkip = 0;
  171.86 -u32 systemColorMap32[0x10000];
  171.87 -u16 systemColorMap16[0x10000];
  171.88 -u16 systemGbPalette[24];
  171.89 -char filename[2048];
  171.90 -char biosFileName[2048];
  171.91 -char captureDir[2048];
  171.92 -char saveDir[2048];
  171.93 -char batteryDir[2048];
  171.94 -
  171.95 -int throttle = 0;
  171.96 -
  171.97 -bool paused = false;
  171.98 -bool debugger = true;
  171.99 -bool debuggerStub = false;
 171.100 -bool systemSoundOn = false;
 171.101 -bool removeIntros = false;
 171.102 -int sdlFlashSize = 0;
 171.103 -int sdlAutoIPS = 1;
 171.104 -int sdlRtcEnable = 0;
 171.105 -int sdlAgbPrint = 0;
 171.106 -
 171.107 -int sdlDefaultJoypad = 0;
 171.108 -
 171.109 -u16 motion[4] = {
 171.110 -  SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
 171.111 -};
 171.112 -
 171.113 -extern void debuggerSignal(int,int);
 171.114 -
 171.115 -void (*dbgMain)() = debuggerMain;
 171.116 -void (*dbgSignal)(int,int) = debuggerSignal;
 171.117 -void (*dbgOutput)(char *, u32) = debuggerOutput;
 171.118 -
 171.119 -char *sdlGetFilename(char *name)
 171.120 -{
 171.121 -  static char filebuffer[2048];
 171.122 -
 171.123 -  int len = strlen(name);
 171.124 -  
 171.125 -  char *p = name + len - 1;
 171.126 -  
 171.127 -  while(true) {
 171.128 -    if(*p == '/' ||
 171.129 -       *p == '\\') {
 171.130 -      p++;
 171.131 -      break;
 171.132 -    }
 171.133 -    len--;
 171.134 -    p--;
 171.135 -    if(len == 0)
 171.136 -      break;
 171.137 -  }
 171.138 -  
 171.139 -  if(len == 0)
 171.140 -    strcpy(filebuffer, name);
 171.141 -  else
 171.142 -    strcpy(filebuffer, p);
 171.143 -  return filebuffer;
 171.144 -}
 171.145 -
 171.146 -void usage(char *cmd)
 171.147 -{
 171.148 -  printf("%s file-name\n",cmd);
 171.149 -}
 171.150 -
 171.151 -int main(int argc, char **argv)
 171.152 -{
 171.153 -  fprintf(stderr,"VisualBoyAdvance-Test version %s\n", VERSION);
 171.154 -
 171.155 -  captureDir[0] = 0;
 171.156 -  saveDir[0] = 0;
 171.157 -  batteryDir[0] = 0;
 171.158 -  
 171.159 -  char buffer[1024];
 171.160 -
 171.161 -  systemFrameSkip = frameSkip = 2;
 171.162 -  gbBorderOn = 0;
 171.163 -
 171.164 -  parseDebug = true;
 171.165 -
 171.166 -  if(!debuggerStub) {
 171.167 -    if(argc <= 1) {
 171.168 -      systemMessage(0,"Missing image name");
 171.169 -      usage(argv[0]);
 171.170 -      exit(-1);
 171.171 -    }
 171.172 -  }
 171.173 -
 171.174 -  for(int i = 0; i < 24;) {
 171.175 -    systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
 171.176 -    systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
 171.177 -    systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
 171.178 -    systemGbPalette[i++] = 0;
 171.179 -  }
 171.180 -
 171.181 -  if(argc == 2) {
 171.182 -    char *szFile = argv[optind];
 171.183 -    bool failed = false;
 171.184 -    if(utilIsZipFile(szFile)) {
 171.185 -      unzFile unz = unzOpen(szFile);
 171.186 -      
 171.187 -      if(unz == NULL) {
 171.188 -        systemMessage(0, "Cannot open file %s", szFile);
 171.189 -        exit(-1);
 171.190 -      }
 171.191 -      int r = unzGoToFirstFile(unz);
 171.192 -      
 171.193 -      if(r != UNZ_OK) {
 171.194 -        unzClose(unz);
 171.195 -        systemMessage(0, "Bad ZIP file %s", szFile);
 171.196 -        exit(-1);
 171.197 -      }
 171.198 -      
 171.199 -      bool found = false;
 171.200 -      
 171.201 -      unz_file_info info;
 171.202 -      
 171.203 -      while(true) {
 171.204 -        r = unzGetCurrentFileInfo(unz,
 171.205 -                                  &info,
 171.206 -                                  buffer,
 171.207 -                                  sizeof(buffer),
 171.208 -                                  NULL,
 171.209 -                                  0,
 171.210 -                                  NULL,
 171.211 -                                  0);
 171.212 -        
 171.213 -        if(r != UNZ_OK) {
 171.214 -          unzClose(unz);
 171.215 -          systemMessage(0,"Bad ZIP file %s", szFile);
 171.216 -          exit(-1);
 171.217 -        }
 171.218 -        
 171.219 -        if(utilIsGBImage(buffer)) {
 171.220 -          found = true;
 171.221 -          cartridgeType = 1;
 171.222 -          break;
 171.223 -        }
 171.224 -        if(utilIsGBAImage(buffer)) {
 171.225 -          found = true;
 171.226 -          cartridgeType = 0;
 171.227 -          break;
 171.228 -        }
 171.229 -        
 171.230 -        r = unzGoToNextFile(unz);
 171.231 -        
 171.232 -        if(r != UNZ_OK)
 171.233 -          break;
 171.234 -      }
 171.235 -      
 171.236 -      if(!found) {
 171.237 -        unzClose(unz);
 171.238 -        systemMessage(0, "No image found on ZIP file %s", szFile);
 171.239 -        exit(-1);
 171.240 -      }
 171.241 -      
 171.242 -      unzClose(unz);
 171.243 -    }
 171.244 -    
 171.245 -    if(utilIsGBImage(szFile) || cartridgeType == 1) {
 171.246 -      failed = !gbLoadRom(szFile);
 171.247 -      cartridgeType = 1;
 171.248 -      emulator = GBSystem;
 171.249 -    } else if(utilIsGBAImage(szFile) || cartridgeType == 0) {
 171.250 -      failed = !CPULoadRom(szFile);
 171.251 -      cartridgeType = 0;
 171.252 -      emulator = GBASystem;
 171.253 -
 171.254 -      //CPUInit(biosFileName, useBios);
 171.255 -      CPUInit();
 171.256 -      CPUReset();
 171.257 -    } else {
 171.258 -      systemMessage(0, "Unknown file type %s", szFile);
 171.259 -      exit(-1);
 171.260 -    }
 171.261 -    
 171.262 -    if(failed) {
 171.263 -      systemMessage(0, "Failed to load file %s", szFile);
 171.264 -      exit(-1);
 171.265 -    }
 171.266 -    strcpy(filename, szFile);
 171.267 -    char *p = strrchr(filename, '.');
 171.268 -    
 171.269 -    if(p)
 171.270 -      *p = 0;
 171.271 -  } else {
 171.272 -    cartridgeType = 0;
 171.273 -    strcpy(filename, "gnu_stub");
 171.274 -    rom = (u8 *)malloc(0x2000000);
 171.275 -    workRAM = (u8 *)calloc(1, 0x40000);
 171.276 -    bios = (u8 *)calloc(1,0x4000);
 171.277 -    internalRAM = (u8 *)calloc(1,0x8000);
 171.278 -    paletteRAM = (u8 *)calloc(1,0x400);
 171.279 -    vram = (u8 *)calloc(1, 0x20000);
 171.280 -    oam = (u8 *)calloc(1, 0x400);
 171.281 -    pix = (u8 *)calloc(1, 4 * 240 * 160);
 171.282 -    ioMem = (u8 *)calloc(1, 0x400);
 171.283 -
 171.284 -    emulator = GBASystem;
 171.285 -    
 171.286 -    //CPUInit(biosFileName, useBios);
 171.287 -    CPUInit();
 171.288 -    CPUReset();    
 171.289 -  }
 171.290 -  
 171.291 -  if(debuggerStub) 
 171.292 -    remoteInit();
 171.293 -  
 171.294 -  if(cartridgeType == 0) {
 171.295 -  } else if (cartridgeType == 1) {
 171.296 -    if(gbBorderOn) {
 171.297 -      gbBorderLineSkip = 256;
 171.298 -      gbBorderColumnSkip = 48;
 171.299 -      gbBorderRowSkip = 40;
 171.300 -    } else {      
 171.301 -      gbBorderLineSkip = 160;
 171.302 -      gbBorderColumnSkip = 0;
 171.303 -      gbBorderRowSkip = 0;
 171.304 -    }      
 171.305 -  } else {
 171.306 -  }
 171.307 -
 171.308 -  for(int i = 0; i < 0x10000; i++) {
 171.309 -    systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 171.310 -      (((i & 0x3e0) >> 5) << systemGreenShift) |
 171.311 -      (((i & 0x7c00) >> 10) << systemBlueShift);  
 171.312 -  }
 171.313 -
 171.314 -  emulating = 1;
 171.315 -  soundInit();
 171.316 -  
 171.317 -  while(emulating) {
 171.318 -    if(!paused) {
 171.319 -      if(debugger && emulator.emuHasDebugger)
 171.320 -        dbgMain();
 171.321 -      else
 171.322 -        emulator.emuMain(emulator.emuCount);
 171.323 -    }
 171.324 -  }
 171.325 -  emulating = 0;
 171.326 -  fprintf(stderr,"Shutting down\n");
 171.327 -  remoteCleanUp();
 171.328 -  soundShutdown();
 171.329 -
 171.330 -  if(gbRom != NULL || rom != NULL) {
 171.331 -    emulator.emuCleanUp();
 171.332 -  }
 171.333 -
 171.334 -  return 0;
 171.335 -}
 171.336 -
 171.337 -void systemMessage(int num, const char *msg, ...)
 171.338 -{
 171.339 -  char buffer[2048];
 171.340 -  va_list valist;
 171.341 -  
 171.342 -  va_start(valist, msg);
 171.343 -  vsprintf(buffer, msg, valist);
 171.344 -  
 171.345 -  fprintf(stderr, "%s\n", buffer);
 171.346 -  va_end(valist);
 171.347 -}
 171.348 -
 171.349 -void systemDrawScreen()
 171.350 -{
 171.351 -}
 171.352 -
 171.353 -bool systemReadJoypads()
 171.354 -{
 171.355 -  return true;
 171.356 -}
 171.357 -
 171.358 -u32 systemReadJoypad(int,bool)
 171.359 -{
 171.360 -  return 0;
 171.361 -}
 171.362 -
 171.363 -void systemShowSpeed(int speed)
 171.364 -{
 171.365 -}
 171.366 -
 171.367 -void system10Frames(int rate)
 171.368 -{
 171.369 -}
 171.370 -
 171.371 -void systemFrame(int)
 171.372 -{
 171.373 -}
 171.374 -
 171.375 -void systemSetTitle(const char *title)
 171.376 -{
 171.377 -}
 171.378 -
 171.379 -int systemScreenCapture(int a)
 171.380 -{
 171.381 -  char buffer[2048];
 171.382 -
 171.383 -  if(captureFormat) {
 171.384 -    if(captureDir[0])
 171.385 -      sprintf(buffer, "%s/%s%02d.bmp", captureDir, sdlGetFilename(filename), a);
 171.386 -    else
 171.387 -      sprintf(buffer, "%s%02d.bmp", filename, a);
 171.388 -
 171.389 -    emulator.emuWriteBMP(buffer);
 171.390 -  } else {
 171.391 -    if(captureDir[0])
 171.392 -      sprintf(buffer, "%s/%s%02d.png", captureDir, sdlGetFilename(filename), a);
 171.393 -    else
 171.394 -      sprintf(buffer, "%s%02d.png", filename, a);
 171.395 -    emulator.emuWritePNG(buffer);
 171.396 -  }
 171.397 -
 171.398 -  systemScreenMessage("Screen capture");
 171.399 -}
 171.400 -
 171.401 -u32 systemReadJoypadExtended()
 171.402 -{
 171.403 -  return 0;
 171.404 -}
 171.405 -
 171.406 -void systemWriteDataToSoundBuffer()
 171.407 -{
 171.408 -}
 171.409 -
 171.410 -bool systemSoundInit()
 171.411 -{
 171.412 -  return true;
 171.413 -}
 171.414 -
 171.415 -void systemSoundShutdown()
 171.416 -{
 171.417 -}
 171.418 -
 171.419 -void systemSoundPause()
 171.420 -{
 171.421 -}
 171.422 -
 171.423 -void systemSoundResume()
 171.424 -{
 171.425 -}
 171.426 -
 171.427 -void systemSoundReset()
 171.428 -{
 171.429 -}
 171.430 -
 171.431 -static int ticks = 0;
 171.432 -
 171.433 -u32 systemGetClock()
 171.434 -{
 171.435 -  return ticks++;
 171.436 -}
 171.437 -
 171.438 -void systemUpdateMotionSensor()
 171.439 -{
 171.440 -}
 171.441 -
 171.442 -int systemGetSensorX()
 171.443 -{
 171.444 -  return 0;
 171.445 -}
 171.446 -
 171.447 -int systemGetSensorY()
 171.448 -{
 171.449 -  return 0;
 171.450 -}
 171.451 -
 171.452 -void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast)
 171.453 -{
 171.454 -}
 171.455 -
 171.456 -void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList)
 171.457 -{
 171.458 -}
 171.459 -
 171.460 -bool systemCanChangeSoundQuality()
 171.461 -{
 171.462 -  return false;
 171.463 -}
 171.464 -
 171.465 -bool systemPauseOnFrame()
 171.466 -{
 171.467 -  return false;
 171.468 -}
 171.469 -
 171.470 -void systemGbBorderOn()
 171.471 -{
 171.472 -}
 171.473 -
 171.474 -bool sdlCheckJoyKey(int)
 171.475 -{
 171.476 -  return true;
 171.477 -}
 171.478 -
 171.479 -u16 checksumBIOS()
 171.480 -{
 171.481 -	bool hasBIOS = false;
 171.482 -	u8 * tempBIOS;
 171.483 -	if(useBios)
 171.484 -	{
 171.485 -		tempBIOS = (u8 *)malloc(0x4000);
 171.486 -		int size = 0x4000;
 171.487 -		if(utilLoad(biosFileName,
 171.488 -					utilIsGBABios,
 171.489 -					tempBIOS,
 171.490 -					size)) {
 171.491 -		if(size == 0x4000)
 171.492 -			hasBIOS = true;
 171.493 -		}
 171.494 -	}
 171.495 -
 171.496 -	u16 biosCheck = 0;
 171.497 -	if(hasBIOS) {
 171.498 -		for(int i = 0; i < 0x4000; i += 4)
 171.499 -			biosCheck += *((u32 *)&tempBIOS[i]);
 171.500 -		free(tempBIOS);
 171.501 -	}
 171.502 -
 171.503 -	return biosCheck;
 171.504 -}
   172.1 --- a/src/sdl/Types.h	Sat Mar 03 10:54:39 2012 -0600
   172.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   172.3 @@ -1,33 +0,0 @@
   172.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   172.5 -// Copyright (C) 2008 VBA-M development team
   172.6 -
   172.7 -// This program is free software; you can redistribute it and/or modify
   172.8 -// it under the terms of the GNU General Public License as published by
   172.9 -// the Free Software Foundation; either version 2, or(at your option)
  172.10 -// any later version.
  172.11 -//
  172.12 -// This program is distributed in the hope that it will be useful,
  172.13 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  172.14 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  172.15 -// GNU General Public License for more details.
  172.16 -//
  172.17 -// You should have received a copy of the GNU General Public License
  172.18 -// along with this program; if not, write to the Free Software Foundation,
  172.19 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  172.20 -
  172.21 -#ifndef __VBA_TYPES_H__
  172.22 -#define __VBA_TYPES_H__
  172.23 -
  172.24 -#include <stdint.h>
  172.25 -
  172.26 -typedef uint8_t u8;
  172.27 -typedef uint16_t u16;
  172.28 -typedef uint32_t u32;
  172.29 -typedef uint64_t u64;
  172.30 -
  172.31 -typedef int8_t s8;
  172.32 -typedef int16_t s16;
  172.33 -typedef int32_t s32;
  172.34 -typedef int64_t s64;
  172.35 -
  172.36 -#endif // __VBA_TYPES_H__
   173.1 --- a/src/sdl/debugger.cpp	Sat Mar 03 10:54:39 2012 -0600
   173.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   173.3 @@ -1,1460 +0,0 @@
   173.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   173.5 -// Copyright (C) 1999-2003 Forgotten
   173.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   173.7 -
   173.8 -// This program is free software; you can redistribute it and/or modify
   173.9 -// it under the terms of the GNU General Public License as published by
  173.10 -// the Free Software Foundation; either version 2, or(at your option)
  173.11 -// any later version.
  173.12 -//
  173.13 -// This program is distributed in the hope that it will be useful,
  173.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  173.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  173.16 -// GNU General Public License for more details.
  173.17 -//
  173.18 -// You should have received a copy of the GNU General Public License
  173.19 -// along with this program; if not, write to the Free Software Foundation,
  173.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  173.21 -
  173.22 -extern "C" {
  173.23 -#include <stdio.h>
  173.24 -#include <stdlib.h>
  173.25 -} // FIXME: should use c++ headers instead
  173.26 -
  173.27 -#include <string.h>
  173.28 -
  173.29 -#include "Port.h"
  173.30 -#include "gba/GBA.h"
  173.31 -#include "gba/GBAGlobals.h"
  173.32 -#include "gba/GBACheats.h"
  173.33 -#include "gba/armdis.h"
  173.34 -#include "gba/elf.h"
  173.35 -#include "common/System.h"
  173.36 -#include "exprNode.h"
  173.37 -
  173.38 -extern bool debugger;
  173.39 -extern int emulating;
  173.40 -
  173.41 -extern struct EmulatedSystem theEmulator;
  173.42 -
  173.43 -#define debuggerReadMemory(addr) \
  173.44 -  READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
  173.45 -
  173.46 -#define debuggerReadHalfWord(addr) \
  173.47 -  READ16LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
  173.48 -
  173.49 -#define debuggerReadByte(addr) \
  173.50 -  map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
  173.51 -
  173.52 -#define debuggerWriteMemory(addr, value) \
  173.53 -  WRITE32LE(&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], value)
  173.54 -
  173.55 -#define debuggerWriteHalfWord(addr, value) \
  173.56 -  WRITE16LE(&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], value)
  173.57 -
  173.58 -#define debuggerWriteByte(addr, value) \
  173.59 -  map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] = (value)
  173.60 -
  173.61 -struct breakpointInfo {
  173.62 -  u32 address;
  173.63 -  u32 value;
  173.64 -  int size;
  173.65 -};
  173.66 -
  173.67 -struct DebuggerCommand {
  173.68 -  const char *name;
  173.69 -  void (*function)(int,char **);
  173.70 -  const char *help;
  173.71 -  const char *syntax;
  173.72 -};
  173.73 -
  173.74 -void debuggerContinueAfterBreakpoint();
  173.75 -
  173.76 -void debuggerHelp(int,char **);
  173.77 -void debuggerNext(int,char **);
  173.78 -void debuggerContinue(int, char **);
  173.79 -void debuggerRegisters(int, char **);
  173.80 -void debuggerBreak(int, char **);
  173.81 -void debuggerBreakDelete(int, char **);
  173.82 -void debuggerBreakList(int, char **);
  173.83 -void debuggerBreakArm(int, char **);
  173.84 -void debuggerBreakWriteClear(int, char **);
  173.85 -void debuggerBreakThumb(int, char **);
  173.86 -void debuggerBreakWrite(int, char **);
  173.87 -void debuggerDebug(int, char **);
  173.88 -void debuggerDisassemble(int, char **);
  173.89 -void debuggerDisassembleArm(int, char **);
  173.90 -void debuggerDisassembleThumb(int, char **);
  173.91 -void debuggerEditByte(int, char **);
  173.92 -void debuggerEditHalfWord(int, char **);
  173.93 -void debuggerEdit(int, char **);
  173.94 -void debuggerIo(int, char **);
  173.95 -void debuggerLocals(int, char **);
  173.96 -void debuggerMemoryByte(int, char **);
  173.97 -void debuggerMemoryHalfWord(int, char **);
  173.98 -void debuggerMemory(int, char **);
  173.99 -void debuggerPrint(int, char **);
 173.100 -void debuggerQuit(int, char **);
 173.101 -void debuggerSetRadix(int, char **);
 173.102 -void debuggerSymbols(int, char **);
 173.103 -void debuggerVerbose(int, char **);
 173.104 -void debuggerWhere(int, char **);
 173.105 -
 173.106 -DebuggerCommand debuggerCommands[] = {
 173.107 -  { "?", debuggerHelp,        "Shows this help information. Type ? <command> for command help", "[<command>]" },
 173.108 -  { "ba", debuggerBreakArm,   "Adds an ARM breakpoint", "<address>" },
 173.109 -  { "bd", debuggerBreakDelete,"Deletes a breakpoint", "<number>" },
 173.110 -  { "bl", debuggerBreakList,  "Lists breakpoints" },
 173.111 -  { "bpw", debuggerBreakWrite, "Break on write", "<address> <size>" },
 173.112 -  { "bpwc", debuggerBreakWriteClear, "Clear break on write", NULL },
 173.113 -  { "break", debuggerBreak,    "Adds a breakpoint on the given function", "<function>|<line>|<file:line>" },
 173.114 -  { "bt", debuggerBreakThumb, "Adds a THUMB breakpoint", "<address>" },
 173.115 -  { "c", debuggerContinue,    "Continues execution" , NULL },
 173.116 -  { "d", debuggerDisassemble, "Disassembles instructions", "[<address> [<number>]]" },
 173.117 -  { "da", debuggerDisassembleArm, "Disassembles ARM instructions", "[<address> [<number>]]" },
 173.118 -  { "dt", debuggerDisassembleThumb, "Disassembles THUMB instructions", "[<address> [<number>]]" },
 173.119 -  { "eb", debuggerEditByte,   "Modify memory location (byte)", "<address> <hex value>" },
 173.120 -  { "eh", debuggerEditHalfWord,"Modify memory location (half-word)","<address> <hex value>" },
 173.121 -  { "ew", debuggerEdit,       "Modify memory location (word)", "<address> <hex value" },
 173.122 -  { "h", debuggerHelp,        "Shows this help information. Type h <command> for command help", "[<command>]" },
 173.123 -  { "io", debuggerIo,         "Show I/O registers status", "[video|video2|dma|timer|misc]" },
 173.124 -  { "locals", debuggerLocals, "Shows local variables", NULL },
 173.125 -  { "mb", debuggerMemoryByte, "Shows memory contents (bytes)", "<address>" },
 173.126 -  { "mh", debuggerMemoryHalfWord, "Shows memory contents (half-words)", "<address>"},
 173.127 -  { "mw", debuggerMemory,     "Shows memory contents (words)", "<address>" },
 173.128 -  { "n", debuggerNext,        "Executes the next instruction", "[<count>]" },
 173.129 -  { "print", debuggerPrint,   "Print the value of a expression (if known)", "[/x|/o|/d] <expression>" },
 173.130 -  { "q", debuggerQuit,        "Quits the emulator", NULL },
 173.131 -  { "r", debuggerRegisters,   "Shows ARM registers", NULL },
 173.132 -  { "radix", debuggerSetRadix,   "Sets the print radix", "<radix>" },
 173.133 -  { "symbols", debuggerSymbols, "List symbols", "[<symbol>]" },
 173.134 -#ifndef FINAL_VERSION
 173.135 -  { "trace", debuggerDebug,       "Sets the trace level", "<value>" },
 173.136 -#endif
 173.137 -#ifdef DEV_VERSION
 173.138 -  { "verbose", debuggerVerbose,     "Change verbose setting", "<value>" },
 173.139 -#endif
 173.140 -  { "where", debuggerWhere,   "Shows call chain", NULL },
 173.141 -  { NULL, NULL, NULL, NULL} // end marker
 173.142 -};
 173.143 -
 173.144 -breakpointInfo debuggerBreakpointList[100];
 173.145 -
 173.146 -int debuggerNumOfBreakpoints = 0;
 173.147 -bool debuggerAtBreakpoint = false;
 173.148 -int debuggerBreakpointNumber = 0;
 173.149 -int debuggerRadix = 0;
 173.150 -
 173.151 -void debuggerApplyBreakpoint(u32 address, int num, int size)
 173.152 -{
 173.153 -  if(size)
 173.154 -    debuggerWriteMemory(address, (u32)(0xe1200070 | 
 173.155 -                                       (num & 0xf) | 
 173.156 -                                       ((num<<4)&0xf0)));
 173.157 -  else
 173.158 -    debuggerWriteHalfWord(address, 
 173.159 -                          (u16)(0xbe00 | num));
 173.160 -}
 173.161 -
 173.162 -void debuggerDisableBreakpoints()
 173.163 -{
 173.164 -  for(int i = 0; i < debuggerNumOfBreakpoints; i++) {
 173.165 -    if(debuggerBreakpointList[i].size)
 173.166 -      debuggerWriteMemory(debuggerBreakpointList[i].address,
 173.167 -                          debuggerBreakpointList[i].value);
 173.168 -    else
 173.169 -      debuggerWriteHalfWord(debuggerBreakpointList[i].address,
 173.170 -                            debuggerBreakpointList[i].value);      
 173.171 -  }
 173.172 -}
 173.173 -
 173.174 -void debuggerEnableBreakpoints(bool skipPC)
 173.175 -{
 173.176 -  for(int i = 0; i < debuggerNumOfBreakpoints; i++) {
 173.177 -    if(debuggerBreakpointList[i].address == armNextPC && skipPC)
 173.178 -      continue;
 173.179 -
 173.180 -    debuggerApplyBreakpoint(debuggerBreakpointList[i].address,
 173.181 -                            i,
 173.182 -                            debuggerBreakpointList[i].size);
 173.183 -  }  
 173.184 -}
 173.185 -
 173.186 -void debuggerUsage(const char *cmd)
 173.187 -{
 173.188 -  for(int i = 0; ; i++) {
 173.189 -    if(debuggerCommands[i].name) {
 173.190 -      if(!strcmp(debuggerCommands[i].name, cmd)) {
 173.191 -        printf("%s %s\t%s\n", 
 173.192 -               debuggerCommands[i].name, 
 173.193 -               debuggerCommands[i].syntax ? debuggerCommands[i].syntax : "",
 173.194 -               debuggerCommands[i].help);
 173.195 -        break;
 173.196 -      }
 173.197 -    } else {
 173.198 -      printf("Unrecognized command '%s'.", cmd);
 173.199 -      break;
 173.200 -    }
 173.201 -  }  
 173.202 -}
 173.203 -
 173.204 -void debuggerPrintBaseType(Type *t, u32 value, u32 location,
 173.205 -                           LocationType type,
 173.206 -                           int bitSize, int bitOffset)
 173.207 -{
 173.208 -  if(bitSize) {
 173.209 -    if(bitOffset)
 173.210 -      value >>= ((t->size*8)-bitOffset-bitSize);
 173.211 -    value &= (1 << bitSize)-1;
 173.212 -  } else {
 173.213 -    if(t->size == 2)
 173.214 -      value &= 0xFFFF;
 173.215 -    else if(t->size == 1)
 173.216 -      value &= 0xFF;
 173.217 -  }
 173.218 -
 173.219 -  if(t->size == 8) {
 173.220 -    u64 value = 0;
 173.221 -    if(type == LOCATION_memory) {
 173.222 -      value = debuggerReadMemory(location) |
 173.223 -        ((u64)debuggerReadMemory(location+4)<<32);
 173.224 -    } else if(type == LOCATION_register) {
 173.225 -      value = reg[location].I | ((u64)reg[location+1].I << 32);
 173.226 -    }
 173.227 -    switch(t->encoding) {
 173.228 -    case DW_ATE_signed:
 173.229 -      switch(debuggerRadix) {
 173.230 -      case 0:
 173.231 -        printf("%lld", value);
 173.232 -        break;
 173.233 -      case 1:
 173.234 -        printf("0x%llx", value);
 173.235 -        break;
 173.236 -      case 2:
 173.237 -        printf("0%llo", value);
 173.238 -        break;
 173.239 -      }
 173.240 -      break;
 173.241 -    case DW_ATE_unsigned:
 173.242 -      switch(debuggerRadix) {
 173.243 -      case 0:
 173.244 -        printf("%llu", value);
 173.245 -        break;
 173.246 -      case 1:
 173.247 -        printf("0x%llx", value);
 173.248 -        break;
 173.249 -      case 2:
 173.250 -        printf("0%llo", value);
 173.251 -        break;
 173.252 -      }
 173.253 -      break;
 173.254 -    default:
 173.255 -      printf("Unknowing 64-bit encoding\n");
 173.256 -    }
 173.257 -    return;
 173.258 -  }
 173.259 -  
 173.260 -  switch(t->encoding) {
 173.261 -  case DW_ATE_boolean:
 173.262 -    if(value)
 173.263 -      printf("true");
 173.264 -    else
 173.265 -      printf("false");
 173.266 -    break;
 173.267 -  case DW_ATE_signed:
 173.268 -    switch(debuggerRadix) {
 173.269 -    case 0:
 173.270 -      printf("%d", value);
 173.271 -      break;
 173.272 -    case 1:
 173.273 -      printf("0x%x", value);
 173.274 -      break;
 173.275 -    case 2:
 173.276 -      printf("0%o", value);
 173.277 -      break;
 173.278 -    }
 173.279 -    break;
 173.280 -  case DW_ATE_unsigned:
 173.281 -  case DW_ATE_unsigned_char:
 173.282 -    switch(debuggerRadix) {
 173.283 -    case 0:
 173.284 -      printf("%u", value);
 173.285 -      break;
 173.286 -    case 1:
 173.287 -      printf("0x%x", value);
 173.288 -      break;
 173.289 -    case 2:
 173.290 -      printf("0%o", value);
 173.291 -      break;
 173.292 -    }
 173.293 -    break;
 173.294 -  default:
 173.295 -    printf("UNKNOWN BASE %d %08x", t->encoding, value);
 173.296 -  }
 173.297 -}
 173.298 -
 173.299 -char *debuggerPrintType(Type *t)
 173.300 -{
 173.301 -  char buffer[1024];  
 173.302 -  static char buffer2[1024];
 173.303 -  
 173.304 -  if(t->type == TYPE_pointer) {
 173.305 -    if(t->pointer)
 173.306 -      strcpy(buffer, debuggerPrintType(t->pointer));
 173.307 -    else
 173.308 -      strcpy(buffer, "void");
 173.309 -    sprintf(buffer2, "%s *", buffer);
 173.310 -    return buffer2;
 173.311 -  } else if(t->type == TYPE_reference) {
 173.312 -    strcpy(buffer, debuggerPrintType(t->pointer));
 173.313 -    sprintf(buffer2, "%s &", buffer);
 173.314 -    return buffer2;    
 173.315 -  }
 173.316 -  return t->name;
 173.317 -}
 173.318 -
 173.319 -void debuggerPrintValueInternal(Function *, Type *, ELFBlock *, int, int, u32);
 173.320 -void debuggerPrintValueInternal(Function *f, Type *t,
 173.321 -                                int bitSize, int bitOffset,
 173.322 -                                u32 objLocation, LocationType type);
 173.323 -
 173.324 -u32 debuggerGetValue(u32 location, LocationType type)
 173.325 -{
 173.326 -  switch(type) {
 173.327 -  case LOCATION_memory:
 173.328 -    return debuggerReadMemory(location);
 173.329 -  case LOCATION_register:
 173.330 -    return reg[location].I;
 173.331 -  case LOCATION_value:
 173.332 -    return location;
 173.333 -  }
 173.334 -  return 0;
 173.335 -}
 173.336 -
 173.337 -void debuggerPrintPointer(Type *t, u32 value)
 173.338 -{
 173.339 -  printf("(%s)0x%08x", debuggerPrintType(t), value);
 173.340 -}
 173.341 -
 173.342 -void debuggerPrintReference(Type *t, u32 value)
 173.343 -{
 173.344 -  printf("(%s)0x%08x", debuggerPrintType(t), value);
 173.345 -}
 173.346 -
 173.347 -void debuggerPrintFunction(Type *t, u32 value)
 173.348 -{
 173.349 -  printf("(%s)0x%08x", debuggerPrintType(t), value);
 173.350 -}
 173.351 -
 173.352 -void debuggerPrintArray(Type *t, u32 value)
 173.353 -{
 173.354 -  // todo
 173.355 -  printf("(%s[])0x%08x", debuggerPrintType(t->array->type), value);
 173.356 -}
 173.357 -
 173.358 -void debuggerPrintMember(Function *f,
 173.359 -                         Member *m,
 173.360 -                         u32 objLocation,
 173.361 -                         u32 location)
 173.362 -{
 173.363 -  int bitSize = m->bitSize;
 173.364 -  if(bitSize) {
 173.365 -    u32 value = 0;
 173.366 -    int off = m->bitOffset;
 173.367 -    int size = m->byteSize;
 173.368 -    u32 v = 0;
 173.369 -    if(size == 1)
 173.370 -      v = debuggerReadByte(location);
 173.371 -      else if(size == 2)
 173.372 -        v = debuggerReadHalfWord(location);
 173.373 -      else if(size == 4)
 173.374 -        v = debuggerReadMemory(location);
 173.375 -      
 173.376 -      while(bitSize) {
 173.377 -        int top = size*8 - off;
 173.378 -        int bot = top - bitSize;
 173.379 -        top--;
 173.380 -        if(bot >= 0) {
 173.381 -          value = (v >> (size*8 - bitSize - off)) & ((1 << bitSize)-1);
 173.382 -          bitSize = 0;
 173.383 -        } else {
 173.384 -          value |= (v & ((1 << top)-1)) << (bitSize - top);
 173.385 -          bitSize -= (top+1);
 173.386 -          location -= size;
 173.387 -          off = 0;
 173.388 -          if(size == 1)
 173.389 -            v = debuggerReadByte(location);
 173.390 -          else if(size == 2)
 173.391 -            v = debuggerReadHalfWord(location);
 173.392 -          else
 173.393 -            v = debuggerReadMemory(location);
 173.394 -        }
 173.395 -      }
 173.396 -      debuggerPrintBaseType(m->type, value, location, LOCATION_memory,
 173.397 -                            bitSize, 0);
 173.398 -    } else {
 173.399 -      debuggerPrintValueInternal(f, m->type, m->location, m->bitSize,
 173.400 -                                 m->bitOffset, objLocation);
 173.401 -    }  
 173.402 -}
 173.403 -
 173.404 -void debuggerPrintStructure(Function *f, Type *t, u32 objLocation)
 173.405 -{
 173.406 -  printf("{");
 173.407 -  int count = t->structure->memberCount;
 173.408 -  int i = 0;
 173.409 -  while(i < count) {
 173.410 -    Member *m = &t->structure->members[i];
 173.411 -    printf("%s=", m->name);
 173.412 -    LocationType type;
 173.413 -    u32 location = elfDecodeLocation(f, m->location, &type, objLocation);
 173.414 -    debuggerPrintMember(f, m, objLocation, location);
 173.415 -    i++;
 173.416 -    if(i < count)
 173.417 -      printf(",");
 173.418 -  }
 173.419 -  printf("}");
 173.420 -}
 173.421 -
 173.422 -void debuggerPrintUnion(Function *f, Type *t, u32 objLocation)
 173.423 -{
 173.424 -  // todo
 173.425 -  printf("{");
 173.426 -  int count = t->structure->memberCount;
 173.427 -  int i = 0;
 173.428 -  while(i < count) {
 173.429 -    Member *m = &t->structure->members[i];
 173.430 -    printf("%s=", m->name);
 173.431 -    debuggerPrintMember(f, m, objLocation, 0);
 173.432 -    i++;
 173.433 -    if(i < count)
 173.434 -      printf(",");
 173.435 -  }
 173.436 -  printf("}");
 173.437 -}
 173.438 -
 173.439 -void debuggerPrintEnum(Type *t, u32 value)
 173.440 -{
 173.441 -  int i;
 173.442 -  for(i = 0; i < t->enumeration->count; i++) {
 173.443 -    EnumMember *m = (EnumMember *)&t->enumeration->members[i];
 173.444 -    if(value == m->value) {
 173.445 -      puts(m->name);
 173.446 -      return;
 173.447 -    }
 173.448 -  }
 173.449 -  printf("(UNKNOWN VALUE) %d", value);
 173.450 -}
 173.451 -
 173.452 -void debuggerPrintValueInternal(Function *f, Type *t,
 173.453 -                                int bitSize, int bitOffset,
 173.454 -                                u32 objLocation, LocationType type)
 173.455 -{
 173.456 -  u32 value = debuggerGetValue(objLocation, type);
 173.457 -  if(!t) {
 173.458 -    printf("void");
 173.459 -    return;
 173.460 -  }
 173.461 -  switch(t->type) {
 173.462 -  case TYPE_base:
 173.463 -    debuggerPrintBaseType(t, value, objLocation, type, bitSize, bitOffset);
 173.464 -    break;
 173.465 -  case TYPE_pointer:
 173.466 -    debuggerPrintPointer(t, value);
 173.467 -    break;
 173.468 -  case TYPE_reference:
 173.469 -    debuggerPrintReference(t, value);
 173.470 -    break;
 173.471 -  case TYPE_function:
 173.472 -    debuggerPrintFunction(t, value);
 173.473 -    break;
 173.474 -  case TYPE_array:
 173.475 -    debuggerPrintArray(t, objLocation);
 173.476 -    break;
 173.477 -  case TYPE_struct:
 173.478 -    debuggerPrintStructure(f, t, objLocation);
 173.479 -    break;
 173.480 -  case TYPE_union:
 173.481 -    debuggerPrintUnion(f, t, objLocation);
 173.482 -    break;
 173.483 -  case TYPE_enum:
 173.484 -    debuggerPrintEnum(t, value);
 173.485 -    break;
 173.486 -  default:
 173.487 -    printf("%08x", value);
 173.488 -    break;
 173.489 -  }  
 173.490 -}
 173.491 -
 173.492 -void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc,
 173.493 -                                int bitSize, int bitOffset, u32 objLocation)
 173.494 -{
 173.495 -  LocationType type;  
 173.496 -  u32 location;
 173.497 -  if(loc) {
 173.498 -    if(objLocation)
 173.499 -      location = elfDecodeLocation(f, loc, &type, objLocation);
 173.500 -    else
 173.501 -      location = elfDecodeLocation(f, loc,&type);
 173.502 -  } else {
 173.503 -    location = objLocation;
 173.504 -    type = LOCATION_memory;
 173.505 -  }
 173.506 -
 173.507 -  debuggerPrintValueInternal(f, t, bitSize, bitOffset, location, type);
 173.508 -}
 173.509 -
 173.510 -void debuggerPrintValue(Function *f, Object *o)
 173.511 -{
 173.512 -  debuggerPrintValueInternal(f, o->type, o->location, 0, 0, 0);
 173.513 -  
 173.514 -  printf("\n");
 173.515 -}
 173.516 -
 173.517 -void debuggerSymbols(int argc, char **argv)
 173.518 -{
 173.519 -  int i = 0;
 173.520 -  u32 value;
 173.521 -  u32 size;
 173.522 -  int type;
 173.523 -  bool match = false;
 173.524 -  int matchSize = 0;
 173.525 -  char *matchStr = NULL;
 173.526 -  
 173.527 -  if(argc == 2) {
 173.528 -    match = true;
 173.529 -    matchSize = strlen(argv[1]);
 173.530 -    matchStr = argv[1];
 173.531 -  }
 173.532 -  printf("Symbol               Value    Size     Type   \n");
 173.533 -  printf("-------------------- -------  -------- -------\n");
 173.534 -  char *s = NULL;
 173.535 -  while((s = elfGetSymbol(i, &value, &size, &type))) {
 173.536 -    if(*s) {
 173.537 -      if(match) {
 173.538 -        if(strncmp(s, matchStr, matchSize) != 0) {
 173.539 -          i++;
 173.540 -          continue;
 173.541 -        }
 173.542 -      }
 173.543 -      const char *ts = "?";
 173.544 -      switch(type) {
 173.545 -      case 2:
 173.546 -        ts = "ARM";
 173.547 -        break;
 173.548 -      case 0x0d:
 173.549 -        ts = "THUMB";
 173.550 -        break;
 173.551 -      case 1:
 173.552 -        ts = "DATA";
 173.553 -        break;
 173.554 -      }
 173.555 -      printf("%-20s %08x %08x %-7s\n",
 173.556 -             s, value, size, ts);
 173.557 -    }
 173.558 -    i++;
 173.559 -  }
 173.560 -}
 173.561 -
 173.562 -void debuggerSetRadix(int argc, char **argv)
 173.563 -{
 173.564 -  if(argc != 2)
 173.565 -    debuggerUsage(argv[0]);
 173.566 -  else {
 173.567 -    int r = atoi(argv[1]);
 173.568 -
 173.569 -    bool error = false;
 173.570 -    switch(r) {
 173.571 -    case 10:
 173.572 -      debuggerRadix = 0;
 173.573 -      break;
 173.574 -    case 8:
 173.575 -      debuggerRadix = 2;
 173.576 -      break;
 173.577 -    case 16:
 173.578 -      debuggerRadix = 1;
 173.579 -      break;
 173.580 -    default:
 173.581 -      error = true;
 173.582 -      printf("Unknown radix %d. Valid values are 8, 10 and 16.\n", r);
 173.583 -      break;
 173.584 -    }
 173.585 -    if(!error)
 173.586 -      printf("Radix set to %d\n", r);
 173.587 -  }
 173.588 -}
 173.589 -
 173.590 -void debuggerPrint(int argc, char **argv)
 173.591 -{
 173.592 -  if(argc != 2 && argc != 3) {
 173.593 -    debuggerUsage(argv[0]);
 173.594 -  } else {
 173.595 -    u32 pc = armNextPC;
 173.596 -    Function *f = NULL;
 173.597 -    CompileUnit *u = NULL;
 173.598 -    
 173.599 -    elfGetCurrentFunction(pc,
 173.600 -                          &f, &u);
 173.601 -
 173.602 -    int oldRadix = debuggerRadix;
 173.603 -    if(argc == 3) {
 173.604 -      if(argv[1][0] == '/') {
 173.605 -        if(argv[1][1] == 'x')
 173.606 -          debuggerRadix = 1;
 173.607 -        else if(argv[1][1] == 'o')
 173.608 -          debuggerRadix = 2;
 173.609 -        else if(argv[1][1] == 'd')
 173.610 -          debuggerRadix = 0;
 173.611 -        else {
 173.612 -          printf("Unknown format %c\n", argv[1][1]);
 173.613 -          return;
 173.614 -        }
 173.615 -      } else {
 173.616 -        printf("Unknown option %s\n", argv[1]);
 173.617 -        return;
 173.618 -      }
 173.619 -    } 
 173.620 -    
 173.621 -    char *s = argc == 2 ? argv[1] : argv[2];
 173.622 -
 173.623 -    extern char *exprString;
 173.624 -    extern int exprCol;
 173.625 -    extern int yyparse();
 173.626 -    exprString = s;
 173.627 -    exprCol = 0;
 173.628 -    if(!yyparse()) {
 173.629 -      extern Node *result;
 173.630 -      if(result->resolve(result, f, u)) {
 173.631 -        if(result->member)
 173.632 -          debuggerPrintMember(f,
 173.633 -                              result->member,
 173.634 -                              result->objLocation,
 173.635 -                              result->location);
 173.636 -        else
 173.637 -          debuggerPrintValueInternal(f, result->type, 0, 0,
 173.638 -                                     result->location,
 173.639 -                                     result->locType);
 173.640 -        printf("\n");
 173.641 -      } else {
 173.642 -        printf("Error resolving expression\n");
 173.643 -      }
 173.644 -    } else {
 173.645 -      printf("Error parsing expression:\n");
 173.646 -      printf("%s\n", s);
 173.647 -      exprCol--;
 173.648 -      for(int i = 0; i < exprCol; i++)
 173.649 -        printf(" ");
 173.650 -      printf("^\n");
 173.651 -    }
 173.652 -    extern void exprCleanBuffer();
 173.653 -    exprCleanBuffer();
 173.654 -    exprNodeCleanUp();
 173.655 -    debuggerRadix = oldRadix;
 173.656 -  }
 173.657 -}
 173.658 -
 173.659 -void debuggerHelp(int n, char **args)
 173.660 -{
 173.661 -  if(n == 2) {
 173.662 -    debuggerUsage(args[1]);
 173.663 -  } else {
 173.664 -    for(int i = 0; ; i++) {
 173.665 -      if(debuggerCommands[i].name) {
 173.666 -        printf("%s\t%s\n", debuggerCommands[i].name, debuggerCommands[i].help);
 173.667 -      } else
 173.668 -        break;
 173.669 -    }
 173.670 -  }
 173.671 -}
 173.672 -
 173.673 -void debuggerDebug(int n, char **args)
 173.674 -{
 173.675 -  if(n == 2) {
 173.676 -    int v = 0;
 173.677 -    sscanf(args[1], "%d", &v);
 173.678 -    systemDebug = v;
 173.679 -    printf("Debug level set to %d\n", systemDebug);
 173.680 -  } else
 173.681 -    debuggerUsage("trace");      
 173.682 -}
 173.683 -
 173.684 -void debuggerVerbose(int n, char **args)
 173.685 -{
 173.686 -  if(n == 2) {
 173.687 -    int v = 0;
 173.688 -    sscanf(args[1], "%d", &v);
 173.689 -    systemVerbose = v;
 173.690 -    printf("Verbose level set to %d\n", systemVerbose);
 173.691 -  } else
 173.692 -    debuggerUsage("verbose");    
 173.693 -}
 173.694 -
 173.695 -void debuggerWhere(int n, char **args)
 173.696 -{
 173.697 -  void elfPrintCallChain(u32);
 173.698 -  elfPrintCallChain(armNextPC);
 173.699 -}
 173.700 -
 173.701 -void debuggerLocals(int n, char **args)
 173.702 -{
 173.703 -  Function *f = NULL;
 173.704 -  CompileUnit *u = NULL;
 173.705 -  u32 pc = armNextPC;
 173.706 -  if(elfGetCurrentFunction(pc,
 173.707 -                           &f, &u)) {
 173.708 -    Object *o = f->parameters;
 173.709 -    while(o) {
 173.710 -      printf("%s=", o->name);
 173.711 -      debuggerPrintValue(f, o);
 173.712 -      o = o->next;
 173.713 -    }
 173.714 -
 173.715 -    o = f->variables;
 173.716 -    while(o) {
 173.717 -      bool visible = o->startScope ? pc>=o->startScope : true;
 173.718 -      if(visible)
 173.719 -        visible = o->endScope ? pc < o->endScope : true;
 173.720 -      if(visible) {
 173.721 -        printf("%s=", o->name);
 173.722 -        debuggerPrintValue(f, o);
 173.723 -      }
 173.724 -      o = o->next;      
 173.725 -    }
 173.726 -  } else {
 173.727 -    printf("No information for current address\n");
 173.728 -  }  
 173.729 -}
 173.730 -
 173.731 -void debuggerNext(int n, char **args)
 173.732 -{
 173.733 -  int count = 1;
 173.734 -  if(n == 2) {
 173.735 -    sscanf(args[1], "%d", &count);
 173.736 -  }
 173.737 -  for(int i = 0; i < count; i++) {
 173.738 -    if(debuggerAtBreakpoint) {
 173.739 -      debuggerContinueAfterBreakpoint();
 173.740 -      debuggerEnableBreakpoints(false);
 173.741 -    } else 
 173.742 -      theEmulator.emuMain(1);
 173.743 -  }
 173.744 -  debuggerDisableBreakpoints();
 173.745 -  Function *f = NULL;
 173.746 -  CompileUnit *u = NULL;
 173.747 -  u32 a = armNextPC;
 173.748 -  if(elfGetCurrentFunction(a, &f, &u)) {
 173.749 -    char *file;
 173.750 -    int line = elfFindLine(u, f, a, &file);
 173.751 -    
 173.752 -    printf("File %s, function %s, line %d\n", file, f->name,
 173.753 -           line);
 173.754 -  }
 173.755 -  debuggerRegisters(0, NULL);
 173.756 -}
 173.757 -
 173.758 -void debuggerContinue(int n, char **args)
 173.759 -{
 173.760 -  if(debuggerAtBreakpoint)
 173.761 -    debuggerContinueAfterBreakpoint();
 173.762 -  debuggerEnableBreakpoints(false);
 173.763 -  debugger = false;
 173.764 -}
 173.765 -
 173.766 -void debuggerSignal(int sig,int number)
 173.767 -{
 173.768 -  switch(sig) {
 173.769 -  case 4:
 173.770 -    {
 173.771 -      printf("Illegal instruction at %08x\n", armNextPC);
 173.772 -      debugger = true;
 173.773 -    }
 173.774 -    break;
 173.775 -  case 5:
 173.776 -    {
 173.777 -      printf("Breakpoint %d reached\n", number);
 173.778 -      debugger = true;
 173.779 -      debuggerAtBreakpoint = true;
 173.780 -      debuggerBreakpointNumber = number;
 173.781 -      debuggerDisableBreakpoints();
 173.782 -      
 173.783 -      Function *f = NULL;
 173.784 -      CompileUnit *u = NULL;
 173.785 -      
 173.786 -      if(elfGetCurrentFunction(armNextPC, &f, &u)) {
 173.787 -        char *file;
 173.788 -        int line = elfFindLine(u,f,armNextPC,&file);
 173.789 -        printf("File %s, function %s, line %d\n", file, f->name,
 173.790 -               line);
 173.791 -      }
 173.792 -    }
 173.793 -    break;
 173.794 -  default:
 173.795 -    printf("Unknown signal %d\n", sig);
 173.796 -    break;
 173.797 -  }
 173.798 -}
 173.799 -
 173.800 -void debuggerBreakList(int, char **)
 173.801 -{
 173.802 -  printf("Num Address  Type  Symbol\n");
 173.803 -  printf("--- -------- ----- ------\n");
 173.804 -  for(int i = 0; i < debuggerNumOfBreakpoints; i++) {
 173.805 -    printf("%3d %08x %s %s\n",i, debuggerBreakpointList[i].address,
 173.806 -           debuggerBreakpointList[i].size ? "ARM" : "THUMB",
 173.807 -           elfGetAddressSymbol(debuggerBreakpointList[i].address));
 173.808 -  }
 173.809 -}
 173.810 -
 173.811 -void debuggerBreakDelete(int n, char **args)
 173.812 -{
 173.813 -  if(n == 2) {
 173.814 -    int n = 0;
 173.815 -    sscanf(args[1], "%d", &n);
 173.816 -    printf("Deleting breakpoint %d (%d)\n", n, debuggerNumOfBreakpoints);
 173.817 -    if(n >= 0 && n < debuggerNumOfBreakpoints) {
 173.818 -      n++;
 173.819 -      if(n < debuggerNumOfBreakpoints) {
 173.820 -        for(int i = n; i < debuggerNumOfBreakpoints; i++) {
 173.821 -          debuggerBreakpointList[i-1].address = 
 173.822 -            debuggerBreakpointList[i].address;
 173.823 -          debuggerBreakpointList[i-1].value = 
 173.824 -            debuggerBreakpointList[i].value;
 173.825 -          debuggerBreakpointList[i-1].size = 
 173.826 -            debuggerBreakpointList[i].size;
 173.827 -        }
 173.828 -      }
 173.829 -      debuggerNumOfBreakpoints--;
 173.830 -    }
 173.831 -  } else
 173.832 -    debuggerUsage("bd");    
 173.833 -}
 173.834 -
 173.835 -void debuggerBreak(int n, char **args)
 173.836 -{
 173.837 -  if(n == 2) {
 173.838 -    u32 address = 0;
 173.839 -    u32 value = 0;
 173.840 -    int type = 0;
 173.841 -    char *s = args[1];
 173.842 -    char c = *s;
 173.843 -    if(strchr(s, ':')) {
 173.844 -      char *name = s;
 173.845 -      char *l = strchr(s, ':');
 173.846 -      *l++ = 0;
 173.847 -      int line = atoi(l);
 173.848 -
 173.849 -      u32 addr;
 173.850 -      Function *f;
 173.851 -      CompileUnit *u;
 173.852 -      
 173.853 -      if(elfFindLineInModule(&addr, name, line)) {
 173.854 -        if(elfGetCurrentFunction(addr, &f, &u)) {
 173.855 -          u32 addr2;
 173.856 -          if(elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
 173.857 -            address = addr;
 173.858 -          } else {
 173.859 -            printf("Unable to get function symbol data\n");
 173.860 -            return;
 173.861 -          }
 173.862 -        } else {
 173.863 -          printf("Unable to find function for address\n");
 173.864 -          return;
 173.865 -        }
 173.866 -      } else {
 173.867 -        printf("Unable to find module or line\n");
 173.868 -        return;
 173.869 -      }
 173.870 -    } else if(c >= '0' && c <= '9') {
 173.871 -      int line = atoi(s);
 173.872 -      Function *f;
 173.873 -      CompileUnit *u;
 173.874 -      u32 addr;
 173.875 -      
 173.876 -      if(elfGetCurrentFunction(armNextPC, &f, &u)) {
 173.877 -        if(elfFindLineInUnit(&addr, u, line)) {
 173.878 -          if(elfGetCurrentFunction(addr, &f, &u)) {
 173.879 -            u32 addr2;
 173.880 -            if(elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
 173.881 -              address = addr;
 173.882 -            } else {
 173.883 -              printf("Unable to get function symbol data\n");
 173.884 -              return;
 173.885 -            }
 173.886 -          } else {
 173.887 -            printf("Unable to find function for address\n");
 173.888 -            return;
 173.889 -          }
 173.890 -        } else {
 173.891 -          printf("Unable to find line\n");
 173.892 -          return;
 173.893 -        }
 173.894 -      } else {
 173.895 -        printf("Cannot find current function\n");
 173.896 -        return;
 173.897 -      }
 173.898 -    } else {
 173.899 -      if(!elfGetSymbolAddress(s, &address, &value, &type)) {
 173.900 -        printf("Function %s not found\n", args[1]);
 173.901 -        return;
 173.902 -      }
 173.903 -    }
 173.904 -    if(type == 0x02 || type == 0x0d) {
 173.905 -      int i = debuggerNumOfBreakpoints;
 173.906 -      int size = 0;
 173.907 -      if(type == 2)
 173.908 -        size = 1;
 173.909 -      debuggerBreakpointList[i].address = address;
 173.910 -      debuggerBreakpointList[i].value = type == 0x02 ?
 173.911 -        debuggerReadMemory(address) : debuggerReadHalfWord(address);
 173.912 -      debuggerBreakpointList[i].size = size;
 173.913 -      //      debuggerApplyBreakpoint(address, i, size);
 173.914 -      debuggerNumOfBreakpoints++;
 173.915 -      if(size)
 173.916 -        printf("Added ARM breakpoint at %08x\n", address);        
 173.917 -      else
 173.918 -        printf("Added THUMB breakpoint at %08x\n", address);
 173.919 -    } else {
 173.920 -      printf("%s is not a function symbol\n", args[1]); 
 173.921 -    }
 173.922 -  } else
 173.923 -    debuggerUsage("break");  
 173.924 -}
 173.925 -
 173.926 -void debuggerBreakThumb(int n, char **args)
 173.927 -{
 173.928 -  if(n == 2) {
 173.929 -    u32 address = 0;
 173.930 -    sscanf(args[1],"%x", &address);
 173.931 -    int i = debuggerNumOfBreakpoints;
 173.932 -    debuggerBreakpointList[i].address = address;
 173.933 -    debuggerBreakpointList[i].value = debuggerReadHalfWord(address);
 173.934 -    debuggerBreakpointList[i].size = 0;
 173.935 -    //    debuggerApplyBreakpoint(address, i, 0);
 173.936 -    debuggerNumOfBreakpoints++;
 173.937 -    printf("Added THUMB breakpoint at %08x\n", address);
 173.938 -  } else
 173.939 -    debuggerUsage("bt");    
 173.940 -}
 173.941 -
 173.942 -void debuggerBreakArm(int n, char **args)
 173.943 -{
 173.944 -  if(n == 2) {
 173.945 -    u32 address = 0;
 173.946 -    sscanf(args[1],"%x", &address);
 173.947 -    int i = debuggerNumOfBreakpoints;
 173.948 -    debuggerBreakpointList[i].address = address;
 173.949 -    debuggerBreakpointList[i].value = debuggerReadMemory(address);
 173.950 -    debuggerBreakpointList[i].size = 1;
 173.951 -    //    debuggerApplyBreakpoint(address, i, 1);
 173.952 -    debuggerNumOfBreakpoints++;
 173.953 -    printf("Added ARM breakpoint at %08x\n", address);
 173.954 -  } else
 173.955 -    debuggerUsage("ba");
 173.956 -}
 173.957 -
 173.958 -void debuggerBreakOnWrite(u32 *mem, u32 oldvalue, u32 value, int size)
 173.959 -{
 173.960 -  u32 address = 0;
 173.961 -  if(mem >= (u32*)&workRAM[0] && mem <= (u32*)&workRAM[0x3ffff])
 173.962 -    address = 0x2000000 + ((u64)mem - (u64)&workRAM[0]);
 173.963 -  else
 173.964 -    address = 0x3000000 + ((u64)mem - (u64)&internalRAM[0]);
 173.965 -
 173.966 -  if(size == 2)
 173.967 -    printf("Breakpoint (on write) address %08x old:%08x new:%08x\n", 
 173.968 -           address, oldvalue, value);
 173.969 -  else if(size == 1)
 173.970 -    printf("Breakpoint (on write) address %08x old:%04x new:%04x\n", 
 173.971 -           address, (u16)oldvalue,(u16)value);
 173.972 -  else
 173.973 -    printf("Breakpoint (on write) address %08x old:%02x new:%02x\n", 
 173.974 -           address, (u8)oldvalue, (u8)value);
 173.975 -  debugger = true;
 173.976 -}
 173.977 -
 173.978 -void debuggerBreakWriteClear(int n, char **args)
 173.979 -{
 173.980 -  memset(freezeWorkRAM, false, 0x40000);
 173.981 -  memset(freezeInternalRAM, false, 0x8000);
 173.982 -  printf("Cleared all break on write\n");
 173.983 -}
 173.984 -
 173.985 -void debuggerBreakWrite(int n, char **args)
 173.986 -{
 173.987 -  if(n == 3) {
 173.988 -    if(cheatsNumber != 0) {
 173.989 -      printf("Cheats are enabled. Cannot continue.\n");
 173.990 -      return;
 173.991 -    }
 173.992 -    u32 address = 0;
 173.993 -    sscanf(args[1], "%x", &address);
 173.994 -    int n = 0;
 173.995 -    sscanf(args[2], "%d", &n);
 173.996 -    
 173.997 -    if(address < 0x2000000 || address > 0x3007fff) {
 173.998 -      printf("Invalid address: %08x\n", address);
 173.999 -      return;
173.1000 -    }
173.1001 -    
173.1002 -    if(address > 0x203ffff && address < 0x3000000) {
173.1003 -      printf("Invalid address: %08x\n", address);
173.1004 -      return;
173.1005 -    }
173.1006 -
173.1007 -    u32 final = address + n;
173.1008 -
173.1009 -    if(address < 0x2040000 && final > 0x2040000) {
173.1010 -      printf("Invalid byte count: %d\n", n);
173.1011 -      return;
173.1012 -    } else if(address < 0x3008000 && final > 0x3008000) {
173.1013 -      printf("Invalid byte count: %d\n", n);
173.1014 -      return;
173.1015 -    }
173.1016 -    printf("Added break on write at %08x for %d bytes\n", address, n);
173.1017 -    for(int i = 0; i < n; i++) {
173.1018 -      if((address >> 24) == 2)
173.1019 -        freezeWorkRAM[address & 0x3ffff] = true;
173.1020 -      else
173.1021 -        freezeInternalRAM[address & 0x7fff] = true;
173.1022 -      address++;
173.1023 -    }
173.1024 -  } else
173.1025 -    debuggerUsage("bpw");    
173.1026 -}
173.1027 -
173.1028 -void debuggerDisassembleArm(int n, char **args)
173.1029 -{
173.1030 -  char buffer[80];
173.1031 -  u32 pc = reg[15].I;
173.1032 -  pc -= 4;
173.1033 -  int count = 20;
173.1034 -  if(n >= 2) {
173.1035 -    sscanf(args[1], "%x", &pc);
173.1036 -  }
173.1037 -  if(pc & 3) {
173.1038 -    printf("Misaligned address %08x\n", pc);
173.1039 -    pc &= 0xfffffffc;
173.1040 -  }
173.1041 -  if(n >= 3) {
173.1042 -    sscanf(args[2], "%d", &count);
173.1043 -  }
173.1044 -  int i = 0;
173.1045 -  int len = 0;
173.1046 -  char format[30];
173.1047 -  for(i = 0; i < count; i++) {
173.1048 -    int l = strlen(elfGetAddressSymbol(pc+4*i));
173.1049 -    if(l > len)
173.1050 -      len = l;
173.1051 -  }
173.1052 -  sprintf(format, "%%08x %%-%ds %%s\n", len);
173.1053 -  for(i = 0; i < count; i++) {
173.1054 -    u32 addr = pc;
173.1055 -    pc += disArm(pc, buffer, 2);
173.1056 -    printf(format, addr, elfGetAddressSymbol(addr), buffer);
173.1057 -  }
173.1058 -}
173.1059 -
173.1060 -void debuggerDisassembleThumb(int n, char **args)
173.1061 -{
173.1062 -  char buffer[80];
173.1063 -  u32 pc = reg[15].I;
173.1064 -  pc -= 2;
173.1065 -  int count = 20;
173.1066 -  if(n >= 2) {
173.1067 -    sscanf(args[1], "%x", &pc);
173.1068 -  }
173.1069 -  if(pc & 1) {
173.1070 -    printf("Misaligned address %08x\n", pc);
173.1071 -    pc &= 0xfffffffe;
173.1072 -  }
173.1073 -  if(n >= 3) {
173.1074 -    sscanf(args[2], "%d", &count);
173.1075 -  }
173.1076 -
173.1077 -  int i = 0;
173.1078 -  int len = 0;
173.1079 -  char format[30];
173.1080 -  for(i = 0; i < count; i++) {
173.1081 -    int l = strlen(elfGetAddressSymbol(pc+2*i));
173.1082 -    if(l > len)
173.1083 -      len = l;
173.1084 -  }
173.1085 -  sprintf(format, "%%08x %%-%ds %%s\n", len);  
173.1086 -  
173.1087 -  for(i = 0; i < count; i++) {
173.1088 -    u32 addr = pc;
173.1089 -    pc += disThumb(pc, buffer, 2);
173.1090 -    printf(format, addr, elfGetAddressSymbol(addr), buffer);
173.1091 -  }
173.1092 -}
173.1093 -
173.1094 -void debuggerDisassemble(int n, char **args)
173.1095 -{
173.1096 -  if(armState)
173.1097 -    debuggerDisassembleArm(n, args);
173.1098 -  else
173.1099 -    debuggerDisassembleThumb(n, args);
173.1100 -}
173.1101 -
173.1102 -void debuggerContinueAfterBreakpoint()
173.1103 -{
173.1104 -  printf("Continuing after breakpoint\n");
173.1105 -  debuggerEnableBreakpoints(true);
173.1106 -  theEmulator.emuMain(1);
173.1107 -  debuggerAtBreakpoint = false;
173.1108 -}
173.1109 -
173.1110 -void debuggerRegisters(int, char **)
173.1111 -{
173.1112 -  char *command[3];
173.1113 -  char buffer[10];
173.1114 -
173.1115 -  printf("R00=%08x R04=%08x R08=%08x R12=%08x\n",
173.1116 -         reg[0].I, reg[4].I, reg[8].I, reg[12].I);
173.1117 -  printf("R01=%08x R05=%08x R09=%08x R13=%08x\n",
173.1118 -         reg[1].I, reg[5].I, reg[9].I, reg[13].I);
173.1119 -  printf("R02=%08x R06=%08x R10=%08x R14=%08x\n",
173.1120 -         reg[2].I, reg[6].I, reg[10].I, reg[14].I);
173.1121 -  printf("R03=%08x R07=%08x R11=%08x R15=%08x\n",
173.1122 -         reg[3].I, reg[7].I, reg[11].I, reg[15].I);
173.1123 -  printf("CPSR=%08x (%c%c%c%c%c%c%c Mode: %02x)\n",
173.1124 -         reg[16].I,
173.1125 -         (N_FLAG ? 'N' : '.'),
173.1126 -         (Z_FLAG ? 'Z' : '.'),
173.1127 -         (C_FLAG ? 'C' : '.'),
173.1128 -         (V_FLAG ? 'V' : '.'),
173.1129 -         (armIrqEnable ? '.' : 'I'),
173.1130 -         ((!(reg[16].I & 0x40)) ? '.' : 'F'),
173.1131 -         (armState ? '.' : 'T'),
173.1132 -         armMode);
173.1133 -  sprintf(buffer,"%08x", armState ? reg[15].I - 4 : reg[15].I - 2);
173.1134 -  command[0]=const_cast<char *>("m");
173.1135 -  command[1]=buffer;
173.1136 -  command[2]=const_cast<char *>("1");
173.1137 -  debuggerDisassemble(3, command);
173.1138 -}
173.1139 -
173.1140 -void debuggerIoVideo()
173.1141 -{
173.1142 -  printf("DISPCNT  = %04x\n", DISPCNT);
173.1143 -  printf("DISPSTAT = %04x\n", DISPSTAT);
173.1144 -  printf("VCOUNT   = %04x\n", VCOUNT);
173.1145 -  printf("BG0CNT   = %04x\n", BG0CNT);
173.1146 -  printf("BG1CNT   = %04x\n", BG1CNT);
173.1147 -  printf("BG2CNT   = %04x\n", BG2CNT);
173.1148 -  printf("BG3CNT   = %04x\n", BG3CNT);
173.1149 -  printf("WIN0H    = %04x\n", WIN0H);
173.1150 -  printf("WIN0V    = %04x\n", WIN0V);
173.1151 -  printf("WIN1H    = %04x\n", WIN1H);
173.1152 -  printf("WIN1V    = %04x\n", WIN1V);
173.1153 -  printf("WININ    = %04x\n", WININ);
173.1154 -  printf("WINOUT   = %04x\n", WINOUT);
173.1155 -  printf("MOSAIC   = %04x\n", MOSAIC);
173.1156 -  printf("BLDMOD   = %04x\n", BLDMOD);
173.1157 -  printf("COLEV    = %04x\n", COLEV);
173.1158 -  printf("COLY     = %04x\n", COLY);
173.1159 -}
173.1160 -
173.1161 -void debuggerIoVideo2()
173.1162 -{
173.1163 -  printf("BG0HOFS  = %04x\n", BG0HOFS);
173.1164 -  printf("BG0VOFS  = %04x\n", BG0VOFS);
173.1165 -  printf("BG1HOFS  = %04x\n", BG1HOFS);
173.1166 -  printf("BG1VOFS  = %04x\n", BG1VOFS);
173.1167 -  printf("BG2HOFS  = %04x\n", BG2HOFS);
173.1168 -  printf("BG2VOFS  = %04x\n", BG2VOFS);
173.1169 -  printf("BG3HOFS  = %04x\n", BG3HOFS);
173.1170 -  printf("BG3VOFS  = %04x\n", BG3VOFS);
173.1171 -  printf("BG2PA    = %04x\n", BG2PA);
173.1172 -  printf("BG2PB    = %04x\n", BG2PB);
173.1173 -  printf("BG2PC    = %04x\n", BG2PC);
173.1174 -  printf("BG2PD    = %04x\n", BG2PD);
173.1175 -  printf("BG2X     = %08x\n", (BG2X_H<<16)|BG2X_L);
173.1176 -  printf("BG2Y     = %08x\n", (BG2Y_H<<16)|BG2Y_L);
173.1177 -  printf("BG3PA    = %04x\n", BG3PA);
173.1178 -  printf("BG3PB    = %04x\n", BG3PB);
173.1179 -  printf("BG3PC    = %04x\n", BG3PC);
173.1180 -  printf("BG3PD    = %04x\n", BG3PD);
173.1181 -  printf("BG3X     = %08x\n", (BG3X_H<<16)|BG3X_L);
173.1182 -  printf("BG3Y     = %08x\n", (BG3Y_H<<16)|BG3Y_L);
173.1183 -}
173.1184 -
173.1185 -void debuggerIoDMA()
173.1186 -{
173.1187 -  printf("DM0SAD   = %08x\n", (DM0SAD_H<<16)|DM0SAD_L);
173.1188 -  printf("DM0DAD   = %08x\n", (DM0DAD_H<<16)|DM0DAD_L);
173.1189 -  printf("DM0CNT   = %08x\n", (DM0CNT_H<<16)|DM0CNT_L);  
173.1190 -  printf("DM1SAD   = %08x\n", (DM1SAD_H<<16)|DM1SAD_L);
173.1191 -  printf("DM1DAD   = %08x\n", (DM1DAD_H<<16)|DM1DAD_L);
173.1192 -  printf("DM1CNT   = %08x\n", (DM1CNT_H<<16)|DM1CNT_L);  
173.1193 -  printf("DM2SAD   = %08x\n", (DM2SAD_H<<16)|DM2SAD_L);
173.1194 -  printf("DM2DAD   = %08x\n", (DM2DAD_H<<16)|DM2DAD_L);
173.1195 -  printf("DM2CNT   = %08x\n", (DM2CNT_H<<16)|DM2CNT_L);  
173.1196 -  printf("DM3SAD   = %08x\n", (DM3SAD_H<<16)|DM3SAD_L);
173.1197 -  printf("DM3DAD   = %08x\n", (DM3DAD_H<<16)|DM3DAD_L);
173.1198 -  printf("DM3CNT   = %08x\n", (DM3CNT_H<<16)|DM3CNT_L);    
173.1199 -}
173.1200 -
173.1201 -void debuggerIoTimer()
173.1202 -{
173.1203 -  printf("TM0D     = %04x\n", TM0D);
173.1204 -  printf("TM0CNT   = %04x\n", TM0CNT);
173.1205 -  printf("TM1D     = %04x\n", TM1D);
173.1206 -  printf("TM1CNT   = %04x\n", TM1CNT);
173.1207 -  printf("TM2D     = %04x\n", TM2D);
173.1208 -  printf("TM2CNT   = %04x\n", TM2CNT);
173.1209 -  printf("TM3D     = %04x\n", TM3D);
173.1210 -  printf("TM3CNT   = %04x\n", TM3CNT);
173.1211 -}
173.1212 -
173.1213 -void debuggerIoMisc()
173.1214 -{
173.1215 -  printf("P1       = %04x\n", P1);  
173.1216 -  printf("IE       = %04x\n", IE);
173.1217 -  printf("IF       = %04x\n", IF);
173.1218 -  printf("IME      = %04x\n", IME);
173.1219 -}
173.1220 -
173.1221 -void debuggerIo(int n, char **args)
173.1222 -{
173.1223 -  if(n == 1) {
173.1224 -    debuggerIoVideo();
173.1225 -    return;
173.1226 -  }
173.1227 -  if(!strcmp(args[1], "video"))
173.1228 -    debuggerIoVideo();
173.1229 -  else if(!strcmp(args[1], "video2"))
173.1230 -    debuggerIoVideo2();
173.1231 -  else if(!strcmp(args[1], "dma"))
173.1232 -    debuggerIoDMA();
173.1233 -  else if(!strcmp(args[1], "timer"))
173.1234 -    debuggerIoTimer();
173.1235 -  else if(!strcmp(args[1], "misc"))
173.1236 -    debuggerIoMisc();
173.1237 -  else printf("Unrecognized option %s\n", args[1]);
173.1238 -}
173.1239 -
173.1240 -void debuggerEditByte(int n, char **args)
173.1241 -{
173.1242 -  if(n == 3) {
173.1243 -    u32 address;
173.1244 -    u32 byte;
173.1245 -    sscanf(args[1], "%x", &address);
173.1246 -    sscanf(args[2], "%x", &byte);
173.1247 -    debuggerWriteByte(address, (u8)byte);
173.1248 -  } else
173.1249 -    debuggerUsage("eb");    
173.1250 -}
173.1251 -
173.1252 -void debuggerEditHalfWord(int n, char **args)
173.1253 -{
173.1254 -  if(n == 3) {
173.1255 -    u32 address;
173.1256 -    u32 byte;
173.1257 -    sscanf(args[1], "%x", &address);
173.1258 -    if(address & 1) {
173.1259 -      printf("Error: address must be half-word aligned\n");
173.1260 -      return;
173.1261 -    }
173.1262 -    sscanf(args[2], "%x", &byte);
173.1263 -    debuggerWriteHalfWord(address, (u16)byte);
173.1264 -  } else
173.1265 -    debuggerUsage("eh");        
173.1266 -}
173.1267 -
173.1268 -void debuggerEdit(int n, char **args)
173.1269 -{
173.1270 -  if(n == 3) {
173.1271 -    u32 address;
173.1272 -    u32 byte;
173.1273 -    sscanf(args[1], "%x", &address);
173.1274 -    if(address & 3) {
173.1275 -      printf("Error: address must be word aligned\n");
173.1276 -      return;
173.1277 -    }
173.1278 -    sscanf(args[2], "%x", &byte);
173.1279 -    debuggerWriteMemory(address, (u32)byte);
173.1280 -  } else
173.1281 -    debuggerUsage("ew");    
173.1282 -}
173.1283 -
173.1284 -
173.1285 -#define ASCII(c) (c) < 32 ? '.' : (c) > 127 ? '.' : (c)
173.1286 -
173.1287 -void debuggerMemoryByte(int n, char **args)
173.1288 -{
173.1289 -  if(n == 2) {
173.1290 -    u32 addr = 0;
173.1291 -    sscanf(args[1], "%x", &addr);
173.1292 -    for(int ii = 0; ii < 16; ii++) {
173.1293 -      int a = debuggerReadByte(addr);
173.1294 -      int b = debuggerReadByte(addr+1);
173.1295 -      int c = debuggerReadByte(addr+2);
173.1296 -      int d = debuggerReadByte(addr+3);
173.1297 -      int e = debuggerReadByte(addr+4);
173.1298 -      int f = debuggerReadByte(addr+5);
173.1299 -      int g = debuggerReadByte(addr+6);
173.1300 -      int h = debuggerReadByte(addr+7);
173.1301 -      int i = debuggerReadByte(addr+8);
173.1302 -      int j = debuggerReadByte(addr+9);
173.1303 -      int k = debuggerReadByte(addr+10);
173.1304 -      int l = debuggerReadByte(addr+11);
173.1305 -      int m = debuggerReadByte(addr+12);
173.1306 -      int n = debuggerReadByte(addr+13);
173.1307 -      int o = debuggerReadByte(addr+14);
173.1308 -      int p = debuggerReadByte(addr+15);
173.1309 -      
173.1310 -      printf("%08x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
173.1311 -             addr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,
173.1312 -             ASCII(a),ASCII(b),ASCII(c),ASCII(d),
173.1313 -             ASCII(e),ASCII(f),ASCII(g),ASCII(h),
173.1314 -             ASCII(i),ASCII(j),ASCII(k),ASCII(l),
173.1315 -             ASCII(m),ASCII(n),ASCII(o),ASCII(p));
173.1316 -      addr += 16;
173.1317 -    }
173.1318 -  } else
173.1319 -    debuggerUsage("mb");    
173.1320 -}
173.1321 -
173.1322 -void debuggerMemoryHalfWord(int n, char **args)
173.1323 -{
173.1324 -  if(n == 2) {
173.1325 -    u32 addr = 0;
173.1326 -    sscanf(args[1], "%x", &addr);
173.1327 -    addr = addr & 0xfffffffe;
173.1328 -    for(int ii = 0; ii < 16; ii++) {
173.1329 -      int a = debuggerReadByte(addr);
173.1330 -      int b = debuggerReadByte(addr+1);
173.1331 -      int c = debuggerReadByte(addr+2);
173.1332 -      int d = debuggerReadByte(addr+3);
173.1333 -      int e = debuggerReadByte(addr+4);
173.1334 -      int f = debuggerReadByte(addr+5);
173.1335 -      int g = debuggerReadByte(addr+6);
173.1336 -      int h = debuggerReadByte(addr+7);
173.1337 -      int i = debuggerReadByte(addr+8);
173.1338 -      int j = debuggerReadByte(addr+9);
173.1339 -      int k = debuggerReadByte(addr+10);
173.1340 -      int l = debuggerReadByte(addr+11);
173.1341 -      int m = debuggerReadByte(addr+12);
173.1342 -      int n = debuggerReadByte(addr+13);
173.1343 -      int o = debuggerReadByte(addr+14);
173.1344 -      int p = debuggerReadByte(addr+15);
173.1345 -      
173.1346 -      printf("%08x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
173.1347 -             addr,b,a,d,c,f,e,h,g,j,i,l,k,n,m,p,o,
173.1348 -             ASCII(a),ASCII(b),ASCII(c),ASCII(d),
173.1349 -             ASCII(e),ASCII(f),ASCII(g),ASCII(h),
173.1350 -             ASCII(i),ASCII(j),ASCII(k),ASCII(l),
173.1351 -             ASCII(m),ASCII(n),ASCII(o),ASCII(p));
173.1352 -      addr += 16;
173.1353 -    }
173.1354 -  } else
173.1355 -    debuggerUsage("mh");    
173.1356 -}
173.1357 -
173.1358 -void debuggerMemory(int n, char **args)
173.1359 -{
173.1360 -  if(n == 2) {
173.1361 -    u32 addr = 0;
173.1362 -    sscanf(args[1], "%x", &addr);
173.1363 -    addr = addr & 0xfffffffc;
173.1364 -    for(int ii = 0; ii < 16; ii++) {
173.1365 -      int a = debuggerReadByte(addr);
173.1366 -      int b = debuggerReadByte(addr+1);
173.1367 -      int c = debuggerReadByte(addr+2);
173.1368 -      int d = debuggerReadByte(addr+3);
173.1369 -
173.1370 -      int e = debuggerReadByte(addr+4);
173.1371 -      int f = debuggerReadByte(addr+5);
173.1372 -      int g = debuggerReadByte(addr+6);
173.1373 -      int h = debuggerReadByte(addr+7);
173.1374 -
173.1375 -      int i = debuggerReadByte(addr+8);
173.1376 -      int j = debuggerReadByte(addr+9);
173.1377 -      int k = debuggerReadByte(addr+10);
173.1378 -      int l = debuggerReadByte(addr+11);
173.1379 -
173.1380 -      int m = debuggerReadByte(addr+12);
173.1381 -      int n = debuggerReadByte(addr+13);
173.1382 -      int o = debuggerReadByte(addr+14);
173.1383 -      int p = debuggerReadByte(addr+15);
173.1384 -      
173.1385 -      printf("%08x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
173.1386 -             addr,d,c,b,a,h,g,f,e,l,k,j,i,p,o,n,m,
173.1387 -             ASCII(a),ASCII(b),ASCII(c),ASCII(d),
173.1388 -             ASCII(e),ASCII(f),ASCII(g),ASCII(h),
173.1389 -             ASCII(i),ASCII(j),ASCII(k),ASCII(l),
173.1390 -             ASCII(m),ASCII(n),ASCII(o),ASCII(p));
173.1391 -      addr += 16;
173.1392 -    }
173.1393 -  } else
173.1394 -    debuggerUsage("mw");    
173.1395 -}
173.1396 -
173.1397 -void debuggerQuit(int, char **)
173.1398 -{
173.1399 -  char buffer[10];
173.1400 -  printf("Are you sure you want to quit (y/n)? ");
173.1401 -  fgets(buffer, 1024, stdin);
173.1402 -  
173.1403 -  if(buffer[0] == 'y' || buffer[0] == 'Y') {
173.1404 -    debugger = false;
173.1405 -    emulating = false;
173.1406 -  }
173.1407 -}
173.1408 -
173.1409 -void debuggerOutput(char *s, u32 addr)
173.1410 -{
173.1411 -  if(s)
173.1412 -    puts(s);
173.1413 -  else {
173.1414 -    char c;
173.1415 -
173.1416 -    c = debuggerReadByte(addr);
173.1417 -    addr++;
173.1418 -    while(c) {
173.1419 -      putchar(c);
173.1420 -      c = debuggerReadByte(addr);
173.1421 -      addr++;
173.1422 -    }
173.1423 -  }
173.1424 -}
173.1425 -
173.1426 -void debuggerMain()
173.1427 -{
173.1428 -  char buffer[1024];
173.1429 -  char *commands[10];
173.1430 -  int commandCount = 0;
173.1431 -  
173.1432 -  if(theEmulator.emuUpdateCPSR)
173.1433 -    theEmulator.emuUpdateCPSR();
173.1434 -  debuggerRegisters(0, NULL);
173.1435 -  
173.1436 -  while(debugger) {
173.1437 -    systemSoundPause();
173.1438 -    printf("debugger> ");
173.1439 -    commandCount = 0;
173.1440 -    char *s = fgets(buffer, 1024, stdin);
173.1441 -
173.1442 -    commands[0] = strtok(s, " \t\n");
173.1443 -    if(commands[0] == NULL)
173.1444 -      continue;
173.1445 -    commandCount++;
173.1446 -    while((s = strtok(NULL, " \t\n"))) {
173.1447 -      commands[commandCount++] = s;
173.1448 -      if(commandCount == 10)
173.1449 -        break;
173.1450 -    }
173.1451 -
173.1452 -    for(int j = 0; ; j++) {
173.1453 -      if(debuggerCommands[j].name == NULL) {
173.1454 -        printf("Unrecognized command %s. Type h for help.\n", commands[0]);
173.1455 -        break;
173.1456 -      }
173.1457 -      if(!strcmp(commands[0], debuggerCommands[j].name)) {
173.1458 -        debuggerCommands[j].function(commandCount, commands);
173.1459 -        break;
173.1460 -      }
173.1461 -    } 
173.1462 -  }
173.1463 -}
   174.1 --- a/src/sdl/debugger.h	Sat Mar 03 10:54:39 2012 -0600
   174.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   174.3 @@ -1,20 +0,0 @@
   174.4 -// -*- C++ -*-
   174.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   174.6 -// Copyright (C) 1999-2003 Forgotten
   174.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   174.8 -
   174.9 -// This program is free software; you can redistribute it and/or modify
  174.10 -// it under the terms of the GNU General Public License as published by
  174.11 -// the Free Software Foundation; either version 2, or(at your option)
  174.12 -// any later version.
  174.13 -//
  174.14 -// This program is distributed in the hope that it will be useful,
  174.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  174.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  174.17 -// GNU General Public License for more details.
  174.18 -//
  174.19 -// You should have received a copy of the GNU General Public License
  174.20 -// along with this program; if not, write to the Free Software Foundation,
  174.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  174.22 -
  174.23 -extern void debuggerMain();
   175.1 --- a/src/sdl/expr-lex.cpp	Sat Mar 03 10:54:39 2012 -0600
   175.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   175.3 @@ -1,1590 +0,0 @@
   175.4 -#line 2 "expr-lex.cpp"
   175.5 -/* A lexical scanner generated by flex */
   175.6 -
   175.7 -/* Scanner skeleton version:
   175.8 - * $Header: /cvsroot/vba/VisualBoyAdvance/src/expr-lex.cpp,v 1.2 2003/06/06 14:17:21 forgotten Exp $
   175.9 - */
  175.10 -
  175.11 -#define FLEX_SCANNER
  175.12 -#define YY_FLEX_MAJOR_VERSION 2
  175.13 -#define YY_FLEX_MINOR_VERSION 5
  175.14 -
  175.15 -#include <stdio.h>
  175.16 -#ifdef __GNUC__
  175.17 -#include <unistd.h>
  175.18 -#endif
  175.19 -
  175.20 -
  175.21 -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  175.22 -#ifdef c_plusplus
  175.23 -#ifndef __cplusplus
  175.24 -#define __cplusplus
  175.25 -#endif
  175.26 -#endif
  175.27 -
  175.28 -
  175.29 -#ifdef __cplusplus
  175.30 -
  175.31 -#include <stdlib.h>
  175.32 -
  175.33 -/* Use prototypes in function declarations. */
  175.34 -#define YY_USE_PROTOS
  175.35 -
  175.36 -/* The "const" storage-class-modifier is valid. */
  175.37 -#define YY_USE_CONST
  175.38 -
  175.39 -#else   /* ! __cplusplus */
  175.40 -
  175.41 -#if __STDC__
  175.42 -
  175.43 -#define YY_USE_PROTOS
  175.44 -#define YY_USE_CONST
  175.45 -
  175.46 -#endif  /* __STDC__ */
  175.47 -#endif  /* ! __cplusplus */
  175.48 -
  175.49 -#ifdef __TURBOC__
  175.50 - #pragma warn -rch
  175.51 - #pragma warn -use
  175.52 -#include <io.h>
  175.53 -#include <stdlib.h>
  175.54 -#define YY_USE_CONST
  175.55 -#define YY_USE_PROTOS
  175.56 -#endif
  175.57 -
  175.58 -#ifdef YY_USE_CONST
  175.59 -#define yyconst const
  175.60 -#else
  175.61 -#define yyconst
  175.62 -#endif
  175.63 -
  175.64 -
  175.65 -#ifdef YY_USE_PROTOS
  175.66 -#define YY_PROTO(proto) proto
  175.67 -#else
  175.68 -#define YY_PROTO(proto) ()
  175.69 -#endif
  175.70 -
  175.71 -/* Returned upon end-of-file. */
  175.72 -#define YY_NULL 0
  175.73 -
  175.74 -/* Promotes a possibly negative, possibly signed char to an unsigned
  175.75 - * integer for use as an array index.  If the signed char is negative,
  175.76 - * we want to instead treat it as an 8-bit unsigned char, hence the
  175.77 - * double cast.
  175.78 - */
  175.79 -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  175.80 -
  175.81 -/* Enter a start condition.  This macro really ought to take a parameter,
  175.82 - * but we do it the disgusting crufty way forced on us by the ()-less
  175.83 - * definition of BEGIN.
  175.84 - */
  175.85 -#define BEGIN yy_start = 1 + 2 *
  175.86 -
  175.87 -/* Translate the current start state into a value that can be later handed
  175.88 - * to BEGIN to return to the state.  The YYSTATE alias is for lex
  175.89 - * compatibility.
  175.90 - */
  175.91 -#define YY_START ((yy_start - 1) / 2)
  175.92 -#define YYSTATE YY_START
  175.93 -
  175.94 -/* Action number for EOF rule of a given start state. */
  175.95 -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  175.96 -
  175.97 -/* Special action meaning "start processing a new file". */
  175.98 -#define YY_NEW_FILE yyrestart( yyin )
  175.99 -
 175.100 -#define YY_END_OF_BUFFER_CHAR 0
 175.101 -
 175.102 -/* Size of default input buffer. */
 175.103 -#define YY_BUF_SIZE 16384
 175.104 -
 175.105 -typedef struct yy_buffer_state *YY_BUFFER_STATE;
 175.106 -
 175.107 -extern int yyleng;
 175.108 -extern FILE *yyin, *yyout;
 175.109 -
 175.110 -#define EOB_ACT_CONTINUE_SCAN 0
 175.111 -#define EOB_ACT_END_OF_FILE 1
 175.112 -#define EOB_ACT_LAST_MATCH 2
 175.113 -
 175.114 -/* The funky do-while in the following #define is used to turn the definition
 175.115 - * int a single C statement (which needs a semi-colon terminator).  This
 175.116 - * avoids problems with code like:
 175.117 - *
 175.118 - *      if ( condition_holds )
 175.119 - *              yyless( 5 );
 175.120 - *      else
 175.121 - *              do_something_else();
 175.122 - *
 175.123 - * Prior to using the do-while the compiler would get upset at the
 175.124 - * "else" because it interpreted the "if" statement as being all
 175.125 - * done when it reached the ';' after the yyless() call.
 175.126 - */
 175.127 -
 175.128 -/* Return all but the first 'n' matched characters back to the input stream. */
 175.129 -
 175.130 -#define yyless(n) \
 175.131 -        do \
 175.132 -                { \
 175.133 -                /* Undo effects of setting up yytext. */ \
 175.134 -                *yy_cp = yy_hold_char; \
 175.135 -                YY_RESTORE_YY_MORE_OFFSET \
 175.136 -                yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
 175.137 -                YY_DO_BEFORE_ACTION; /* set up yytext again */ \
 175.138 -                } \
 175.139 -        while ( 0 )
 175.140 -
 175.141 -#define unput(c) yyunput( c, yytext_ptr )
 175.142 -
 175.143 -/* The following is because we cannot portably get our hands on size_t
 175.144 - * (without autoconf's help, which isn't available because we want
 175.145 - * flex-generated scanners to compile on their own).
 175.146 - */
 175.147 -typedef unsigned int yy_size_t;
 175.148 -
 175.149 -
 175.150 -struct yy_buffer_state
 175.151 -        {
 175.152 -        FILE *yy_input_file;
 175.153 -
 175.154 -        char *yy_ch_buf;                /* input buffer */
 175.155 -        char *yy_buf_pos;               /* current position in input buffer */
 175.156 -
 175.157 -        /* Size of input buffer in bytes, not including room for EOB
 175.158 -         * characters.
 175.159 -         */
 175.160 -        yy_size_t yy_buf_size;
 175.161 -
 175.162 -        /* Number of characters read into yy_ch_buf, not including EOB
 175.163 -         * characters.
 175.164 -         */
 175.165 -        int yy_n_chars;
 175.166 -
 175.167 -        /* Whether we "own" the buffer - i.e., we know we created it,
 175.168 -         * and can realloc() it to grow it, and should free() it to
 175.169 -         * delete it.
 175.170 -         */
 175.171 -        int yy_is_our_buffer;
 175.172 -
 175.173 -        /* Whether this is an "interactive" input source; if so, and
 175.174 -         * if we're using stdio for input, then we want to use getc()
 175.175 -         * instead of fread(), to make sure we stop fetching input after
 175.176 -         * each newline.
 175.177 -         */
 175.178 -        int yy_is_interactive;
 175.179 -
 175.180 -        /* Whether we're considered to be at the beginning of a line.
 175.181 -         * If so, '^' rules will be active on the next match, otherwise
 175.182 -         * not.
 175.183 -         */
 175.184 -        int yy_at_bol;
 175.185 -
 175.186 -        /* Whether to try to fill the input buffer when we reach the
 175.187 -         * end of it.
 175.188 -         */
 175.189 -        int yy_fill_buffer;
 175.190 -
 175.191 -        int yy_buffer_status;
 175.192 -#define YY_BUFFER_NEW 0
 175.193 -#define YY_BUFFER_NORMAL 1
 175.194 -        /* When an EOF's been seen but there's still some text to process
 175.195 -         * then we mark the buffer as YY_EOF_PENDING, to indicate that we
 175.196 -         * shouldn't try reading from the input source any more.  We might
 175.197 -         * still have a bunch of tokens to match, though, because of
 175.198 -         * possible backing-up.
 175.199 -         *
 175.200 -         * When we actually see the EOF, we change the status to "new"
 175.201 -         * (via yyrestart()), so that the user can continue scanning by
 175.202 -         * just pointing yyin at a new input file.
 175.203 -         */
 175.204 -#define YY_BUFFER_EOF_PENDING 2
 175.205 -        };
 175.206 -
 175.207 -static YY_BUFFER_STATE yy_current_buffer = 0;
 175.208 -
 175.209 -/* We provide macros for accessing buffer states in case in the
 175.210 - * future we want to put the buffer states in a more general
 175.211 - * "scanner state".
 175.212 - */
 175.213 -#define YY_CURRENT_BUFFER yy_current_buffer
 175.214 -
 175.215 -
 175.216 -/* yy_hold_char holds the character lost when yytext is formed. */
 175.217 -static char yy_hold_char;
 175.218 -
 175.219 -static int yy_n_chars;          /* number of characters read into yy_ch_buf */
 175.220 -
 175.221 -
 175.222 -int yyleng;
 175.223 -
 175.224 -/* Points to current character in buffer. */
 175.225 -static char *yy_c_buf_p = (char *) 0;
 175.226 -static int yy_init = 1;         /* whether we need to initialize */
 175.227 -static int yy_start = 0;        /* start state number */
 175.228 -
 175.229 -/* Flag which is used to allow yywrap()'s to do buffer switches
 175.230 - * instead of setting up a fresh yyin.  A bit of a hack ...
 175.231 - */
 175.232 -static int yy_did_buffer_switch_on_eof;
 175.233 -
 175.234 -void yyrestart YY_PROTO(( FILE *input_file ));
 175.235 -
 175.236 -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
 175.237 -void yy_load_buffer_state YY_PROTO(( void ));
 175.238 -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
 175.239 -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
 175.240 -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
 175.241 -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
 175.242 -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
 175.243 -
 175.244 -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
 175.245 -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
 175.246 -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
 175.247 -
 175.248 -static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
 175.249 -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
 175.250 -static void yy_flex_free YY_PROTO(( void * ));
 175.251 -
 175.252 -#define yy_new_buffer yy_create_buffer
 175.253 -
 175.254 -#define yy_set_interactive(is_interactive) \
 175.255 -        { \
 175.256 -        if ( ! yy_current_buffer ) \
 175.257 -                yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
 175.258 -        yy_current_buffer->yy_is_interactive = is_interactive; \
 175.259 -        }
 175.260 -
 175.261 -#define yy_set_bol(at_bol) \
 175.262 -        { \
 175.263 -        if ( ! yy_current_buffer ) \
 175.264 -                yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
 175.265 -        yy_current_buffer->yy_at_bol = at_bol; \
 175.266 -        }
 175.267 -
 175.268 -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
 175.269 -
 175.270 -
 175.271 -#define yywrap() 1
 175.272 -#define YY_SKIP_YYWRAP
 175.273 -typedef unsigned char YY_CHAR;
 175.274 -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
 175.275 -typedef int yy_state_type;
 175.276 -extern char *yytext;
 175.277 -#define yytext_ptr yytext
 175.278 -
 175.279 -static yy_state_type yy_get_previous_state YY_PROTO(( void ));
 175.280 -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
 175.281 -static int yy_get_next_buffer YY_PROTO(( void ));
 175.282 -static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
 175.283 -
 175.284 -/* Done after the current pattern has been matched and before the
 175.285 - * corresponding action - sets up yytext.
 175.286 - */
 175.287 -#define YY_DO_BEFORE_ACTION \
 175.288 -        yytext_ptr = yy_bp; \
 175.289 -        yyleng = (int) (yy_cp - yy_bp); \
 175.290 -        yy_hold_char = *yy_cp; \
 175.291 -        *yy_cp = '\0'; \
 175.292 -        yy_c_buf_p = yy_cp;
 175.293 -
 175.294 -#define YY_NUM_RULES 10
 175.295 -#define YY_END_OF_BUFFER 11
 175.296 -static yyconst short int yy_accept[24] =
 175.297 -    {   0,
 175.298 -        0,    0,   11,    9,    8,    8,    6,    7,    9,    4,
 175.299 -        3,    2,    2,    8,    5,    3,    2,    2,    2,    2,
 175.300 -        2,    1,    0
 175.301 -    } ;
 175.302 -
 175.303 -static yyconst int yy_ec[256] =
 175.304 -    {   0,
 175.305 -        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
 175.306 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.307 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.308 -        1,    2,    1,    1,    1,    1,    1,    4,    1,    1,
 175.309 -        1,    5,    1,    1,    6,    7,    1,    8,    8,    8,
 175.310 -        8,    8,    8,    8,    8,    8,    8,    1,    1,    1,
 175.311 -        1,    9,    1,    1,   10,   10,   10,   10,   10,   10,
 175.312 -       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
 175.313 -       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
 175.314 -        1,    1,    1,    1,   10,    1,   10,   10,   10,   10,
 175.315 -
 175.316 -       11,   12,   10,   10,   13,   10,   10,   10,   10,   10,
 175.317 -       14,   10,   10,   10,   15,   10,   10,   10,   10,   10,
 175.318 -       10,   16,    1,    1,    1,    1,    1,    1,    1,    1,
 175.319 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.320 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.321 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.322 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.323 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.324 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.325 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.326 -
 175.327 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.328 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.329 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.330 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.331 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.332 -        1,    1,    1,    1,    1
 175.333 -    } ;
 175.334 -
 175.335 -static yyconst int yy_meta[17] =
 175.336 -    {   0,
 175.337 -        1,    1,    1,    1,    1,    1,    1,    2,    1,    2,
 175.338 -        2,    2,    2,    2,    2,    2
 175.339 -    } ;
 175.340 -
 175.341 -static yyconst short int yy_base[25] =
 175.342 -    {   0,
 175.343 -        0,    0,   32,   33,   15,   17,   33,   33,   22,   33,
 175.344 -       22,    0,   16,   19,   33,   20,    0,   11,   15,   11,
 175.345 -       12,    0,   33,   21
 175.346 -    } ;
 175.347 -
 175.348 -static yyconst short int yy_def[25] =
 175.349 -    {   0,
 175.350 -       23,    1,   23,   23,   23,   23,   23,   23,   23,   23,
 175.351 -       23,   24,   24,   23,   23,   23,   24,   24,   24,   24,
 175.352 -       24,   24,    0,   23
 175.353 -    } ;
 175.354 -
 175.355 -static yyconst short int yy_nxt[50] =
 175.356 -    {   0,
 175.357 -        4,    5,    6,    7,    8,    9,   10,   11,    4,   12,
 175.358 -       12,   12,   12,   12,   13,   12,   14,   14,   14,   14,
 175.359 -       14,   14,   17,   22,   21,   20,   19,   16,   18,   16,
 175.360 -       15,   23,    3,   23,   23,   23,   23,   23,   23,   23,
 175.361 -       23,   23,   23,   23,   23,   23,   23,   23,   23
 175.362 -    } ;
 175.363 -
 175.364 -static yyconst short int yy_chk[50] =
 175.365 -    {   0,
 175.366 -        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 175.367 -        1,    1,    1,    1,    1,    1,    5,    5,    6,    6,
 175.368 -       14,   14,   24,   21,   20,   19,   18,   16,   13,   11,
 175.369 -        9,    3,   23,   23,   23,   23,   23,   23,   23,   23,
 175.370 -       23,   23,   23,   23,   23,   23,   23,   23,   23
 175.371 -    } ;
 175.372 -
 175.373 -static yy_state_type yy_last_accepting_state;
 175.374 -static char *yy_last_accepting_cpos;
 175.375 -
 175.376 -/* The intent behind this definition is that it'll catch
 175.377 - * any uses of REJECT which flex missed.
 175.378 - */
 175.379 -#define REJECT reject_used_but_not_detected
 175.380 -#define yymore() yymore_used_but_not_detected
 175.381 -#define YY_MORE_ADJ 0
 175.382 -#define YY_RESTORE_YY_MORE_OFFSET
 175.383 -char *yytext;
 175.384 -#line 1 "expr.l"
 175.385 -#define INITIAL 0
 175.386 -#line 2 "expr.l"
 175.387 -#include "expr.cpp.h"
 175.388 -
 175.389 -#ifndef __GNUC__
 175.390 -#include <io.h>
 175.391 -#define isatty _isatty
 175.392 -#endif
 175.393 -
 175.394 -char *exprString;
 175.395 -int exprCol;
 175.396 -
 175.397 -#define YY_INPUT(buf,result,max_size) \
 175.398 -    { \
 175.399 -    int c = *exprString++; \
 175.400 -    exprCol++;\
 175.401 -    result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \
 175.402 -    }
 175.403 -#define YY_MAIN 0
 175.404 -#line 400 "expr-lex.cpp"
 175.405 -
 175.406 -/* Macros after this point can all be overridden by user definitions in
 175.407 - * section 1.
 175.408 - */
 175.409 -
 175.410 -#ifndef YY_SKIP_YYWRAP
 175.411 -#ifdef __cplusplus
 175.412 -extern "C" int yywrap YY_PROTO(( void ));
 175.413 -#else
 175.414 -extern int yywrap YY_PROTO(( void ));
 175.415 -#endif
 175.416 -#endif
 175.417 -
 175.418 -#ifndef YY_NO_UNPUT
 175.419 -static void yyunput YY_PROTO(( int c, char *buf_ptr ));
 175.420 -#endif
 175.421 -
 175.422 -#ifndef yytext_ptr
 175.423 -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
 175.424 -#endif
 175.425 -
 175.426 -#ifdef YY_NEED_STRLEN
 175.427 -static int yy_flex_strlen YY_PROTO(( yyconst char * ));
 175.428 -#endif
 175.429 -
 175.430 -#ifndef YY_NO_INPUT
 175.431 -#ifdef __cplusplus
 175.432 -static int yyinput YY_PROTO(( void ));
 175.433 -#else
 175.434 -static int input YY_PROTO(( void ));
 175.435 -#endif
 175.436 -#endif
 175.437 -
 175.438 -#if YY_STACK_USED
 175.439 -static int yy_start_stack_ptr = 0;
 175.440 -static int yy_start_stack_depth = 0;
 175.441 -static int *yy_start_stack = 0;
 175.442 -#ifndef YY_NO_PUSH_STATE
 175.443 -static void yy_push_state YY_PROTO(( int new_state ));
 175.444 -#endif
 175.445 -#ifndef YY_NO_POP_STATE
 175.446 -static void yy_pop_state YY_PROTO(( void ));
 175.447 -#endif
 175.448 -#ifndef YY_NO_TOP_STATE
 175.449 -static int yy_top_state YY_PROTO(( void ));
 175.450 -#endif
 175.451 -
 175.452 -#else
 175.453 -#define YY_NO_PUSH_STATE 1
 175.454 -#define YY_NO_POP_STATE 1
 175.455 -#define YY_NO_TOP_STATE 1
 175.456 -#endif
 175.457 -
 175.458 -#ifdef YY_MALLOC_DECL
 175.459 -YY_MALLOC_DECL
 175.460 -#else
 175.461 -#if __STDC__
 175.462 -#ifndef __cplusplus
 175.463 -#include <stdlib.h>
 175.464 -#endif
 175.465 -#else
 175.466 -/* Just try to get by without declaring the routines.  This will fail
 175.467 - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
 175.468 - * or sizeof(void*) != sizeof(int).
 175.469 - */
 175.470 -#endif
 175.471 -#endif
 175.472 -
 175.473 -/* Amount of stuff to slurp up with each read. */
 175.474 -#ifndef YY_READ_BUF_SIZE
 175.475 -#define YY_READ_BUF_SIZE 8192
 175.476 -#endif
 175.477 -
 175.478 -/* Copy whatever the last rule matched to the standard output. */
 175.479 -
 175.480 -#ifndef ECHO
 175.481 -/* This used to be an fputs(), but since the string might contain NUL's,
 175.482 - * we now use fwrite().
 175.483 - */
 175.484 -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 175.485 -#endif
 175.486 -
 175.487 -/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 175.488 - * is returned in "result".
 175.489 - */
 175.490 -#ifndef YY_INPUT
 175.491 -#define YY_INPUT(buf,result,max_size) \
 175.492 -        if ( yy_current_buffer->yy_is_interactive ) \
 175.493 -                { \
 175.494 -                int c = '*', n; \
 175.495 -                for ( n = 0; n < max_size && \
 175.496 -                             (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 175.497 -                        buf[n] = (char) c; \
 175.498 -                if ( c == '\n' ) \
 175.499 -                        buf[n++] = (char) c; \
 175.500 -                if ( c == EOF && ferror( yyin ) ) \
 175.501 -                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
 175.502 -                result = n; \
 175.503 -                } \
 175.504 -        else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
 175.505 -                  && ferror( yyin ) ) \
 175.506 -                YY_FATAL_ERROR( "input in flex scanner failed" );
 175.507 -#endif
 175.508 -
 175.509 -/* No semi-colon after return; correct usage is to write "yyterminate();" -
 175.510 - * we don't want an extra ';' after the "return" because that will cause
 175.511 - * some compilers to complain about unreachable statements.
 175.512 - */
 175.513 -#ifndef yyterminate
 175.514 -#define yyterminate() return YY_NULL
 175.515 -#endif
 175.516 -
 175.517 -/* Number of entries by which start-condition stack grows. */
 175.518 -#ifndef YY_START_STACK_INCR
 175.519 -#define YY_START_STACK_INCR 25
 175.520 -#endif
 175.521 -
 175.522 -/* Report a fatal error. */
 175.523 -#ifndef YY_FATAL_ERROR
 175.524 -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
 175.525 -#endif
 175.526 -
 175.527 -/* Default declaration of generated scanner - a define so the user can
 175.528 - * easily add parameters.
 175.529 - */
 175.530 -#ifndef YY_DECL
 175.531 -#define YY_DECL int yylex YY_PROTO(( void ))
 175.532 -#endif
 175.533 -
 175.534 -/* Code executed at the beginning of each rule, after yytext and yyleng
 175.535 - * have been set up.
 175.536 - */
 175.537 -#ifndef YY_USER_ACTION
 175.538 -#define YY_USER_ACTION
 175.539 -#endif
 175.540 -
 175.541 -/* Code executed at the end of each rule. */
 175.542 -#ifndef YY_BREAK
 175.543 -#define YY_BREAK break;
 175.544 -#endif
 175.545 -
 175.546 -#define YY_RULE_SETUP \
 175.547 -        YY_USER_ACTION
 175.548 -
 175.549 -YY_DECL
 175.550 -        {
 175.551 -        register yy_state_type yy_current_state;
 175.552 -        register char *yy_cp = NULL, *yy_bp = NULL;
 175.553 -        register int yy_act;
 175.554 -
 175.555 -#line 31 "expr.l"
 175.556 -
 175.557 -
 175.558 -#line 554 "expr-lex.cpp"
 175.559 -
 175.560 -        if ( yy_init )
 175.561 -                {
 175.562 -                yy_init = 0;
 175.563 -
 175.564 -#ifdef YY_USER_INIT
 175.565 -                YY_USER_INIT;
 175.566 -#endif
 175.567 -
 175.568 -                if ( ! yy_start )
 175.569 -                        yy_start = 1;   /* first start state */
 175.570 -
 175.571 -                if ( ! yyin )
 175.572 -                        yyin = stdin;
 175.573 -
 175.574 -                if ( ! yyout )
 175.575 -                        yyout = stdout;
 175.576 -
 175.577 -                if ( ! yy_current_buffer )
 175.578 -                        yy_current_buffer =
 175.579 -                                yy_create_buffer( yyin, YY_BUF_SIZE );
 175.580 -
 175.581 -                yy_load_buffer_state();
 175.582 -                }
 175.583 -
 175.584 -        while ( 1 )             /* loops until end-of-file is reached */
 175.585 -                {
 175.586 -                yy_cp = yy_c_buf_p;
 175.587 -
 175.588 -                /* Support of yytext. */
 175.589 -                *yy_cp = yy_hold_char;
 175.590 -
 175.591 -                /* yy_bp points to the position in yy_ch_buf of the start of
 175.592 -                 * the current run.
 175.593 -                 */
 175.594 -                yy_bp = yy_cp;
 175.595 -
 175.596 -                yy_current_state = yy_start;
 175.597 -yy_match:
 175.598 -                do
 175.599 -                        {
 175.600 -                        register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
 175.601 -                        if ( yy_accept[yy_current_state] )
 175.602 -                                {
 175.603 -                                yy_last_accepting_state = yy_current_state;
 175.604 -                                yy_last_accepting_cpos = yy_cp;
 175.605 -                                }
 175.606 -                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 175.607 -                                {
 175.608 -                                yy_current_state = (int) yy_def[yy_current_state];
 175.609 -                                if ( yy_current_state >= 24 )
 175.610 -                                        yy_c = yy_meta[(unsigned int) yy_c];
 175.611 -                                }
 175.612 -                        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 175.613 -                        ++yy_cp;
 175.614 -                        }
 175.615 -                while ( yy_base[yy_current_state] != 33 );
 175.616 -
 175.617 -yy_find_action:
 175.618 -                yy_act = yy_accept[yy_current_state];
 175.619 -                if ( yy_act == 0 )
 175.620 -                        { /* have to back up */
 175.621 -                        yy_cp = yy_last_accepting_cpos;
 175.622 -                        yy_current_state = yy_last_accepting_state;
 175.623 -                        yy_act = yy_accept[yy_current_state];
 175.624 -                        }
 175.625 -
 175.626 -                YY_DO_BEFORE_ACTION;
 175.627 -
 175.628 -
 175.629 -do_action:      /* This label is used only to access EOF actions. */
 175.630 -
 175.631 -
 175.632 -                switch ( yy_act )
 175.633 -        { /* beginning of action switch */
 175.634 -                        case 0: /* must back up */
 175.635 -                        /* undo the effects of YY_DO_BEFORE_ACTION */
 175.636 -                        *yy_cp = yy_hold_char;
 175.637 -                        yy_cp = yy_last_accepting_cpos;
 175.638 -                        yy_current_state = yy_last_accepting_state;
 175.639 -                        goto yy_find_action;
 175.640 -
 175.641 -case 1:
 175.642 -YY_RULE_SETUP
 175.643 -#line 33 "expr.l"
 175.644 -{
 175.645 -        return TOKEN_SIZEOF;
 175.646 -}
 175.647 -        YY_BREAK
 175.648 -case 2:
 175.649 -YY_RULE_SETUP
 175.650 -#line 37 "expr.l"
 175.651 -{
 175.652 -        return TOKEN_IDENTIFIER;
 175.653 -}
 175.654 -        YY_BREAK
 175.655 -case 3:
 175.656 -YY_RULE_SETUP
 175.657 -#line 41 "expr.l"
 175.658 -{
 175.659 -        return TOKEN_NUMBER;
 175.660 -}
 175.661 -        YY_BREAK
 175.662 -case 4:
 175.663 -YY_RULE_SETUP
 175.664 -#line 45 "expr.l"
 175.665 -{
 175.666 -        return TOKEN_DOT;
 175.667 -}       
 175.668 -        YY_BREAK
 175.669 -case 5:
 175.670 -YY_RULE_SETUP
 175.671 -#line 49 "expr.l"
 175.672 -{
 175.673 -        return TOKEN_ARROW;
 175.674 -}
 175.675 -        YY_BREAK
 175.676 -case 6:
 175.677 -YY_RULE_SETUP
 175.678 -#line 53 "expr.l"
 175.679 -{
 175.680 -        return TOKEN_ADDR;
 175.681 -}
 175.682 -        YY_BREAK
 175.683 -case 7:
 175.684 -YY_RULE_SETUP
 175.685 -#line 57 "expr.l"
 175.686 -{
 175.687 -        return TOKEN_STAR;
 175.688 -}
 175.689 -        YY_BREAK
 175.690 -case 8:
 175.691 -YY_RULE_SETUP
 175.692 -#line 61 "expr.l"
 175.693 -
 175.694 -        YY_BREAK
 175.695 -case 9:
 175.696 -YY_RULE_SETUP
 175.697 -#line 63 "expr.l"
 175.698 -return *yytext;
 175.699 -        YY_BREAK
 175.700 -case 10:
 175.701 -YY_RULE_SETUP
 175.702 -#line 65 "expr.l"
 175.703 -ECHO;
 175.704 -        YY_BREAK
 175.705 -#line 701 "expr-lex.cpp"
 175.706 -case YY_STATE_EOF(INITIAL):
 175.707 -        yyterminate();
 175.708 -
 175.709 -        case YY_END_OF_BUFFER:
 175.710 -                {
 175.711 -                /* Amount of text matched not including the EOB char. */
 175.712 -                int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
 175.713 -
 175.714 -                /* Undo the effects of YY_DO_BEFORE_ACTION. */
 175.715 -                *yy_cp = yy_hold_char;
 175.716 -                YY_RESTORE_YY_MORE_OFFSET
 175.717 -
 175.718 -                if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
 175.719 -                        {
 175.720 -                        /* We're scanning a new file or input source.  It's
 175.721 -                         * possible that this happened because the user
 175.722 -                         * just pointed yyin at a new source and called
 175.723 -                         * yylex().  If so, then we have to assure
 175.724 -                         * consistency between yy_current_buffer and our
 175.725 -                         * globals.  Here is the right place to do so, because
 175.726 -                         * this is the first action (other than possibly a
 175.727 -                         * back-up) that will match for the new input source.
 175.728 -                         */
 175.729 -                        yy_n_chars = yy_current_buffer->yy_n_chars;
 175.730 -                        yy_current_buffer->yy_input_file = yyin;
 175.731 -                        yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
 175.732 -                        }
 175.733 -
 175.734 -                /* Note that here we test for yy_c_buf_p "<=" to the position
 175.735 -                 * of the first EOB in the buffer, since yy_c_buf_p will
 175.736 -                 * already have been incremented past the NUL character
 175.737 -                 * (since all states make transitions on EOB to the
 175.738 -                 * end-of-buffer state).  Contrast this with the test
 175.739 -                 * in input().
 175.740 -                 */
 175.741 -                if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
 175.742 -                        { /* This was really a NUL. */
 175.743 -                        yy_state_type yy_next_state;
 175.744 -
 175.745 -                        yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
 175.746 -
 175.747 -                        yy_current_state = yy_get_previous_state();
 175.748 -
 175.749 -                        /* Okay, we're now positioned to make the NUL
 175.750 -                         * transition.  We couldn't have
 175.751 -                         * yy_get_previous_state() go ahead and do it
 175.752 -                         * for us because it doesn't know how to deal
 175.753 -                         * with the possibility of jamming (and we don't
 175.754 -                         * want to build jamming into it because then it
 175.755 -                         * will run more slowly).
 175.756 -                         */
 175.757 -
 175.758 -                        yy_next_state = yy_try_NUL_trans( yy_current_state );
 175.759 -
 175.760 -                        yy_bp = yytext_ptr + YY_MORE_ADJ;
 175.761 -
 175.762 -                        if ( yy_next_state )
 175.763 -                                {
 175.764 -                                /* Consume the NUL. */
 175.765 -                                yy_cp = ++yy_c_buf_p;
 175.766 -                                yy_current_state = yy_next_state;
 175.767 -                                goto yy_match;
 175.768 -                                }
 175.769 -
 175.770 -                        else
 175.771 -                                {
 175.772 -                                yy_cp = yy_c_buf_p;
 175.773 -                                goto yy_find_action;
 175.774 -                                }
 175.775 -                        }
 175.776 -
 175.777 -                else switch ( yy_get_next_buffer() )
 175.778 -                        {
 175.779 -                        case EOB_ACT_END_OF_FILE:
 175.780 -                                {
 175.781 -                                yy_did_buffer_switch_on_eof = 0;
 175.782 -
 175.783 -                                if ( yywrap() )
 175.784 -                                        {
 175.785 -                                        /* Note: because we've taken care in
 175.786 -                                         * yy_get_next_buffer() to have set up
 175.787 -                                         * yytext, we can now set up
 175.788 -                                         * yy_c_buf_p so that if some total
 175.789 -                                         * hoser (like flex itself) wants to
 175.790 -                                         * call the scanner after we return the
 175.791 -                                         * YY_NULL, it'll still work - another
 175.792 -                                         * YY_NULL will get returned.
 175.793 -                                         */
 175.794 -                                        yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
 175.795 -
 175.796 -                                        yy_act = YY_STATE_EOF(YY_START);
 175.797 -                                        goto do_action;
 175.798 -                                        }
 175.799 -
 175.800 -                                else
 175.801 -                                        {
 175.802 -                                        if ( ! yy_did_buffer_switch_on_eof )
 175.803 -                                                YY_NEW_FILE;
 175.804 -                                        }
 175.805 -                                break;
 175.806 -                                }
 175.807 -
 175.808 -                        case EOB_ACT_CONTINUE_SCAN:
 175.809 -                                yy_c_buf_p =
 175.810 -                                        yytext_ptr + yy_amount_of_matched_text;
 175.811 -
 175.812 -                                yy_current_state = yy_get_previous_state();
 175.813 -
 175.814 -                                yy_cp = yy_c_buf_p;
 175.815 -                                yy_bp = yytext_ptr + YY_MORE_ADJ;
 175.816 -                                goto yy_match;
 175.817 -
 175.818 -                        case EOB_ACT_LAST_MATCH:
 175.819 -                                yy_c_buf_p =
 175.820 -                                &yy_current_buffer->yy_ch_buf[yy_n_chars];
 175.821 -
 175.822 -                                yy_current_state = yy_get_previous_state();
 175.823 -
 175.824 -                                yy_cp = yy_c_buf_p;
 175.825 -                                yy_bp = yytext_ptr + YY_MORE_ADJ;
 175.826 -                                goto yy_find_action;
 175.827 -                        }
 175.828 -                break;
 175.829 -                }
 175.830 -
 175.831 -        default:
 175.832 -                YY_FATAL_ERROR(
 175.833 -                        "fatal flex scanner internal error--no action found" );
 175.834 -        } /* end of action switch */
 175.835 -                } /* end of scanning one token */
 175.836 -        } /* end of yylex */
 175.837 -
 175.838 -
 175.839 -/* yy_get_next_buffer - try to read in a new buffer
 175.840 - *
 175.841 - * Returns a code representing an action:
 175.842 - *      EOB_ACT_LAST_MATCH -
 175.843 - *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 175.844 - *      EOB_ACT_END_OF_FILE - end of file
 175.845 - */
 175.846 -
 175.847 -static int yy_get_next_buffer()
 175.848 -        {
 175.849 -        register char *dest = yy_current_buffer->yy_ch_buf;
 175.850 -        register char *source = yytext_ptr;
 175.851 -        register int number_to_move, i;
 175.852 -        int ret_val;
 175.853 -
 175.854 -        if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
 175.855 -                YY_FATAL_ERROR(
 175.856 -                "fatal flex scanner internal error--end of buffer missed" );
 175.857 -
 175.858 -        if ( yy_current_buffer->yy_fill_buffer == 0 )
 175.859 -                { /* Don't try to fill the buffer, so this is an EOF. */
 175.860 -                if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
 175.861 -                        {
 175.862 -                        /* We matched a single character, the EOB, so
 175.863 -                         * treat this as a final EOF.
 175.864 -                         */
 175.865 -                        return EOB_ACT_END_OF_FILE;
 175.866 -                        }
 175.867 -
 175.868 -                else
 175.869 -                        {
 175.870 -                        /* We matched some text prior to the EOB, first
 175.871 -                         * process it.
 175.872 -                         */
 175.873 -                        return EOB_ACT_LAST_MATCH;
 175.874 -                        }
 175.875 -                }
 175.876 -
 175.877 -        /* Try to read more data. */
 175.878 -
 175.879 -        /* First move last chars to start of buffer. */
 175.880 -        number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
 175.881 -
 175.882 -        for ( i = 0; i < number_to_move; ++i )
 175.883 -                *(dest++) = *(source++);
 175.884 -
 175.885 -        if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
 175.886 -                /* don't do the read, it's not guaranteed to return an EOF,
 175.887 -                 * just force an EOF
 175.888 -                 */
 175.889 -                yy_current_buffer->yy_n_chars = yy_n_chars = 0;
 175.890 -
 175.891 -        else
 175.892 -                {
 175.893 -                int num_to_read =
 175.894 -                        yy_current_buffer->yy_buf_size - number_to_move - 1;
 175.895 -
 175.896 -                while ( num_to_read <= 0 )
 175.897 -                        { /* Not enough room in the buffer - grow it. */
 175.898 -#ifdef YY_USES_REJECT
 175.899 -                        YY_FATAL_ERROR(
 175.900 -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
 175.901 -#else
 175.902 -
 175.903 -                        /* just a shorter name for the current buffer */
 175.904 -                        YY_BUFFER_STATE b = yy_current_buffer;
 175.905 -
 175.906 -                        int yy_c_buf_p_offset =
 175.907 -                                (int) (yy_c_buf_p - b->yy_ch_buf);
 175.908 -
 175.909 -                        if ( b->yy_is_our_buffer )
 175.910 -                                {
 175.911 -                                int new_size = b->yy_buf_size * 2;
 175.912 -
 175.913 -                                if ( new_size <= 0 )
 175.914 -                                        b->yy_buf_size += b->yy_buf_size / 8;
 175.915 -                                else
 175.916 -                                        b->yy_buf_size *= 2;
 175.917 -
 175.918 -                                b->yy_ch_buf = (char *)
 175.919 -                                        /* Include room in for 2 EOB chars. */
 175.920 -                                        yy_flex_realloc( (void *) b->yy_ch_buf,
 175.921 -                                                         b->yy_buf_size + 2 );
 175.922 -                                }
 175.923 -                        else
 175.924 -                                /* Can't grow it, we don't own it. */
 175.925 -                                b->yy_ch_buf = 0;
 175.926 -
 175.927 -                        if ( ! b->yy_ch_buf )
 175.928 -                                YY_FATAL_ERROR(
 175.929 -                                "fatal error - scanner input buffer overflow" );
 175.930 -
 175.931 -                        yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
 175.932 -
 175.933 -                        num_to_read = yy_current_buffer->yy_buf_size -
 175.934 -                                                number_to_move - 1;
 175.935 -#endif
 175.936 -                        }
 175.937 -
 175.938 -                if ( num_to_read > YY_READ_BUF_SIZE )
 175.939 -                        num_to_read = YY_READ_BUF_SIZE;
 175.940 -
 175.941 -                /* Read in more data. */
 175.942 -                YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
 175.943 -                        yy_n_chars, num_to_read );
 175.944 -
 175.945 -                yy_current_buffer->yy_n_chars = yy_n_chars;
 175.946 -                }
 175.947 -
 175.948 -        if ( yy_n_chars == 0 )
 175.949 -                {
 175.950 -                if ( number_to_move == YY_MORE_ADJ )
 175.951 -                        {
 175.952 -                        ret_val = EOB_ACT_END_OF_FILE;
 175.953 -                        yyrestart( yyin );
 175.954 -                        }
 175.955 -
 175.956 -                else
 175.957 -                        {
 175.958 -                        ret_val = EOB_ACT_LAST_MATCH;
 175.959 -                        yy_current_buffer->yy_buffer_status =
 175.960 -                                YY_BUFFER_EOF_PENDING;
 175.961 -                        }
 175.962 -                }
 175.963 -
 175.964 -        else
 175.965 -                ret_val = EOB_ACT_CONTINUE_SCAN;
 175.966 -
 175.967 -        yy_n_chars += number_to_move;
 175.968 -        yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
 175.969 -        yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
 175.970 -
 175.971 -        yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
 175.972 -
 175.973 -        return ret_val;
 175.974 -        }
 175.975 -
 175.976 -
 175.977 -/* yy_get_previous_state - get the state just before the EOB char was reached */
 175.978 -
 175.979 -static yy_state_type yy_get_previous_state()
 175.980 -        {
 175.981 -        register yy_state_type yy_current_state;
 175.982 -        register char *yy_cp;
 175.983 -
 175.984 -        yy_current_state = yy_start;
 175.985 -
 175.986 -        for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
 175.987 -                {
 175.988 -                register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
 175.989 -                if ( yy_accept[yy_current_state] )
 175.990 -                        {
 175.991 -                        yy_last_accepting_state = yy_current_state;
 175.992 -                        yy_last_accepting_cpos = yy_cp;
 175.993 -                        }
 175.994 -                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 175.995 -                        {
 175.996 -                        yy_current_state = (int) yy_def[yy_current_state];
 175.997 -                        if ( yy_current_state >= 24 )
 175.998 -                                yy_c = yy_meta[(unsigned int) yy_c];
 175.999 -                        }
175.1000 -                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
175.1001 -                }
175.1002 -
175.1003 -        return yy_current_state;
175.1004 -        }
175.1005 -
175.1006 -
175.1007 -/* yy_try_NUL_trans - try to make a transition on the NUL character
175.1008 - *
175.1009 - * synopsis
175.1010 - *      next_state = yy_try_NUL_trans( current_state );
175.1011 - */
175.1012 -
175.1013 -#ifdef YY_USE_PROTOS
175.1014 -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
175.1015 -#else
175.1016 -static yy_state_type yy_try_NUL_trans( yy_current_state )
175.1017 -yy_state_type yy_current_state;
175.1018 -#endif
175.1019 -        {
175.1020 -        register int yy_is_jam;
175.1021 -        register char *yy_cp = yy_c_buf_p;
175.1022 -
175.1023 -        register YY_CHAR yy_c = 1;
175.1024 -        if ( yy_accept[yy_current_state] )
175.1025 -                {
175.1026 -                yy_last_accepting_state = yy_current_state;
175.1027 -                yy_last_accepting_cpos = yy_cp;
175.1028 -                }
175.1029 -        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
175.1030 -                {
175.1031 -                yy_current_state = (int) yy_def[yy_current_state];
175.1032 -                if ( yy_current_state >= 24 )
175.1033 -                        yy_c = yy_meta[(unsigned int) yy_c];
175.1034 -                }
175.1035 -        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
175.1036 -        yy_is_jam = (yy_current_state == 23);
175.1037 -
175.1038 -        return yy_is_jam ? 0 : yy_current_state;
175.1039 -        }
175.1040 -
175.1041 -
175.1042 -#ifndef YY_NO_UNPUT
175.1043 -#ifdef YY_USE_PROTOS
175.1044 -static void yyunput( int c, register char *yy_bp )
175.1045 -#else
175.1046 -static void yyunput( c, yy_bp )
175.1047 -int c;
175.1048 -register char *yy_bp;
175.1049 -#endif
175.1050 -        {
175.1051 -        register char *yy_cp = yy_c_buf_p;
175.1052 -
175.1053 -        /* undo effects of setting up yytext */
175.1054 -        *yy_cp = yy_hold_char;
175.1055 -
175.1056 -        if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
175.1057 -                { /* need to shift things up to make room */
175.1058 -                /* +2 for EOB chars. */
175.1059 -                register int number_to_move = yy_n_chars + 2;
175.1060 -                register char *dest = &yy_current_buffer->yy_ch_buf[
175.1061 -                                        yy_current_buffer->yy_buf_size + 2];
175.1062 -                register char *source =
175.1063 -                                &yy_current_buffer->yy_ch_buf[number_to_move];
175.1064 -
175.1065 -                while ( source > yy_current_buffer->yy_ch_buf )
175.1066 -                        *--dest = *--source;
175.1067 -
175.1068 -                yy_cp += (int) (dest - source);
175.1069 -                yy_bp += (int) (dest - source);
175.1070 -                yy_current_buffer->yy_n_chars =
175.1071 -                        yy_n_chars = yy_current_buffer->yy_buf_size;
175.1072 -
175.1073 -                if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
175.1074 -                        YY_FATAL_ERROR( "flex scanner push-back overflow" );
175.1075 -                }
175.1076 -
175.1077 -        *--yy_cp = (char) c;
175.1078 -
175.1079 -
175.1080 -        yytext_ptr = yy_bp;
175.1081 -        yy_hold_char = *yy_cp;
175.1082 -        yy_c_buf_p = yy_cp;
175.1083 -        }
175.1084 -#endif  /* ifndef YY_NO_UNPUT */
175.1085 -
175.1086 -
175.1087 -#ifdef __cplusplus
175.1088 -static int yyinput()
175.1089 -#else
175.1090 -static int input()
175.1091 -#endif
175.1092 -        {
175.1093 -        int c;
175.1094 -
175.1095 -        *yy_c_buf_p = yy_hold_char;
175.1096 -
175.1097 -        if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
175.1098 -                {
175.1099 -                /* yy_c_buf_p now points to the character we want to return.
175.1100 -                 * If this occurs *before* the EOB characters, then it's a
175.1101 -                 * valid NUL; if not, then we've hit the end of the buffer.
175.1102 -                 */
175.1103 -                if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
175.1104 -                        /* This was really a NUL. */
175.1105 -                        *yy_c_buf_p = '\0';
175.1106 -
175.1107 -                else
175.1108 -                        { /* need more input */
175.1109 -                        int offset = yy_c_buf_p - yytext_ptr;
175.1110 -                        ++yy_c_buf_p;
175.1111 -
175.1112 -                        switch ( yy_get_next_buffer() )
175.1113 -                                {
175.1114 -                                case EOB_ACT_LAST_MATCH:
175.1115 -                                        /* This happens because yy_g_n_b()
175.1116 -                                         * sees that we've accumulated a
175.1117 -                                         * token and flags that we need to
175.1118 -                                         * try matching the token before
175.1119 -                                         * proceeding.  But for input(),
175.1120 -                                         * there's no matching to consider.
175.1121 -                                         * So convert the EOB_ACT_LAST_MATCH
175.1122 -                                         * to EOB_ACT_END_OF_FILE.
175.1123 -                                         */
175.1124 -
175.1125 -                                        /* Reset buffer status. */
175.1126 -                                        yyrestart( yyin );
175.1127 -
175.1128 -                                        /* fall through */
175.1129 -
175.1130 -                                case EOB_ACT_END_OF_FILE:
175.1131 -                                        {
175.1132 -                                        if ( yywrap() )
175.1133 -                                                return EOF;
175.1134 -
175.1135 -                                        if ( ! yy_did_buffer_switch_on_eof )
175.1136 -                                                YY_NEW_FILE;
175.1137 -#ifdef __cplusplus
175.1138 -                                        return yyinput();
175.1139 -#else
175.1140 -                                        return input();
175.1141 -#endif
175.1142 -                                        }
175.1143 -
175.1144 -                                case EOB_ACT_CONTINUE_SCAN:
175.1145 -                                        yy_c_buf_p = yytext_ptr + offset;
175.1146 -                                        break;
175.1147 -                                }
175.1148 -                        }
175.1149 -                }
175.1150 -
175.1151 -        c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
175.1152 -        *yy_c_buf_p = '\0';     /* preserve yytext */
175.1153 -        yy_hold_char = *++yy_c_buf_p;
175.1154 -
175.1155 -
175.1156 -        return c;
175.1157 -        }
175.1158 -
175.1159 -
175.1160 -#ifdef YY_USE_PROTOS
175.1161 -void yyrestart( FILE *input_file )
175.1162 -#else
175.1163 -void yyrestart( input_file )
175.1164 -FILE *input_file;
175.1165 -#endif
175.1166 -        {
175.1167 -        if ( ! yy_current_buffer )
175.1168 -                yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
175.1169 -
175.1170 -        yy_init_buffer( yy_current_buffer, input_file );
175.1171 -        yy_load_buffer_state();
175.1172 -        }
175.1173 -
175.1174 -
175.1175 -#ifdef YY_USE_PROTOS
175.1176 -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
175.1177 -#else
175.1178 -void yy_switch_to_buffer( new_buffer )
175.1179 -YY_BUFFER_STATE new_buffer;
175.1180 -#endif
175.1181 -        {
175.1182 -        if ( yy_current_buffer == new_buffer )
175.1183 -                return;
175.1184 -
175.1185 -        if ( yy_current_buffer )
175.1186 -                {
175.1187 -                /* Flush out information for old buffer. */
175.1188 -                *yy_c_buf_p = yy_hold_char;
175.1189 -                yy_current_buffer->yy_buf_pos = yy_c_buf_p;
175.1190 -                yy_current_buffer->yy_n_chars = yy_n_chars;
175.1191 -                }
175.1192 -
175.1193 -        yy_current_buffer = new_buffer;
175.1194 -        yy_load_buffer_state();
175.1195 -
175.1196 -        /* We don't actually know whether we did this switch during
175.1197 -         * EOF (yywrap()) processing, but the only time this flag
175.1198 -         * is looked at is after yywrap() is called, so it's safe
175.1199 -         * to go ahead and always set it.
175.1200 -         */
175.1201 -        yy_did_buffer_switch_on_eof = 1;
175.1202 -        }
175.1203 -
175.1204 -
175.1205 -#ifdef YY_USE_PROTOS
175.1206 -void yy_load_buffer_state( void )
175.1207 -#else
175.1208 -void yy_load_buffer_state()
175.1209 -#endif
175.1210 -        {
175.1211 -        yy_n_chars = yy_current_buffer->yy_n_chars;
175.1212 -        yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
175.1213 -        yyin = yy_current_buffer->yy_input_file;
175.1214 -        yy_hold_char = *yy_c_buf_p;
175.1215 -        }
175.1216 -
175.1217 -
175.1218 -#ifdef YY_USE_PROTOS
175.1219 -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
175.1220 -#else
175.1221 -YY_BUFFER_STATE yy_create_buffer( file, size )
175.1222 -FILE *file;
175.1223 -int size;
175.1224 -#endif
175.1225 -        {
175.1226 -        YY_BUFFER_STATE b;
175.1227 -
175.1228 -        b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
175.1229 -        if ( ! b )
175.1230 -                YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
175.1231 -
175.1232 -        b->yy_buf_size = size;
175.1233 -
175.1234 -        /* yy_ch_buf has to be 2 characters longer than the size given because
175.1235 -         * we need to put in 2 end-of-buffer characters.
175.1236 -         */
175.1237 -        b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
175.1238 -        if ( ! b->yy_ch_buf )
175.1239 -                YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
175.1240 -
175.1241 -        b->yy_is_our_buffer = 1;
175.1242 -
175.1243 -        yy_init_buffer( b, file );
175.1244 -
175.1245 -        return b;
175.1246 -        }
175.1247 -
175.1248 -
175.1249 -#ifdef YY_USE_PROTOS
175.1250 -void yy_delete_buffer( YY_BUFFER_STATE b )
175.1251 -#else
175.1252 -void yy_delete_buffer( b )
175.1253 -YY_BUFFER_STATE b;
175.1254 -#endif
175.1255 -        {
175.1256 -        if ( ! b )
175.1257 -                return;
175.1258 -
175.1259 -        if ( b == yy_current_buffer )
175.1260 -                yy_current_buffer = (YY_BUFFER_STATE) 0;
175.1261 -
175.1262 -        if ( b->yy_is_our_buffer )
175.1263 -                yy_flex_free( (void *) b->yy_ch_buf );
175.1264 -
175.1265 -        yy_flex_free( (void *) b );
175.1266 -        }
175.1267 -
175.1268 -
175.1269 -
175.1270 -#ifdef YY_USE_PROTOS
175.1271 -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
175.1272 -#else
175.1273 -void yy_init_buffer( b, file )
175.1274 -YY_BUFFER_STATE b;
175.1275 -FILE *file;
175.1276 -#endif
175.1277 -
175.1278 -
175.1279 -        {
175.1280 -        yy_flush_buffer( b );
175.1281 -
175.1282 -        b->yy_input_file = file;
175.1283 -        b->yy_fill_buffer = 1;
175.1284 -
175.1285 -#if YY_ALWAYS_INTERACTIVE
175.1286 -        b->yy_is_interactive = 1;
175.1287 -#else
175.1288 -#if YY_NEVER_INTERACTIVE
175.1289 -        b->yy_is_interactive = 0;
175.1290 -#else
175.1291 -        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
175.1292 -#endif
175.1293 -#endif
175.1294 -        }
175.1295 -
175.1296 -
175.1297 -#ifdef YY_USE_PROTOS
175.1298 -void yy_flush_buffer( YY_BUFFER_STATE b )
175.1299 -#else
175.1300 -void yy_flush_buffer( b )
175.1301 -YY_BUFFER_STATE b;
175.1302 -#endif
175.1303 -
175.1304 -        {
175.1305 -        if ( ! b )
175.1306 -                return;
175.1307 -
175.1308 -        b->yy_n_chars = 0;
175.1309 -
175.1310 -        /* We always need two end-of-buffer characters.  The first causes
175.1311 -         * a transition to the end-of-buffer state.  The second causes
175.1312 -         * a jam in that state.
175.1313 -         */
175.1314 -        b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
175.1315 -        b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
175.1316 -
175.1317 -        b->yy_buf_pos = &b->yy_ch_buf[0];
175.1318 -
175.1319 -        b->yy_at_bol = 1;
175.1320 -        b->yy_buffer_status = YY_BUFFER_NEW;
175.1321 -
175.1322 -        if ( b == yy_current_buffer )
175.1323 -                yy_load_buffer_state();
175.1324 -        }
175.1325 -
175.1326 -
175.1327 -#ifndef YY_NO_SCAN_BUFFER
175.1328 -#ifdef YY_USE_PROTOS
175.1329 -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
175.1330 -#else
175.1331 -YY_BUFFER_STATE yy_scan_buffer( base, size )
175.1332 -char *base;
175.1333 -yy_size_t size;
175.1334 -#endif
175.1335 -        {
175.1336 -        YY_BUFFER_STATE b;
175.1337 -
175.1338 -        if ( size < 2 ||
175.1339 -             base[size-2] != YY_END_OF_BUFFER_CHAR ||
175.1340 -             base[size-1] != YY_END_OF_BUFFER_CHAR )
175.1341 -                /* They forgot to leave room for the EOB's. */
175.1342 -                return 0;
175.1343 -
175.1344 -        b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
175.1345 -        if ( ! b )
175.1346 -                YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
175.1347 -
175.1348 -        b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
175.1349 -        b->yy_buf_pos = b->yy_ch_buf = base;
175.1350 -        b->yy_is_our_buffer = 0;
175.1351 -        b->yy_input_file = 0;
175.1352 -        b->yy_n_chars = b->yy_buf_size;
175.1353 -        b->yy_is_interactive = 0;
175.1354 -        b->yy_at_bol = 1;
175.1355 -        b->yy_fill_buffer = 0;
175.1356 -        b->yy_buffer_status = YY_BUFFER_NEW;
175.1357 -
175.1358 -        yy_switch_to_buffer( b );
175.1359 -
175.1360 -        return b;
175.1361 -        }
175.1362 -#endif
175.1363 -
175.1364 -
175.1365 -#ifndef YY_NO_SCAN_STRING
175.1366 -#ifdef YY_USE_PROTOS
175.1367 -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
175.1368 -#else
175.1369 -YY_BUFFER_STATE yy_scan_string( yy_str )
175.1370 -yyconst char *yy_str;
175.1371 -#endif
175.1372 -        {
175.1373 -        int len;
175.1374 -        for ( len = 0; yy_str[len]; ++len )
175.1375 -                ;
175.1376 -
175.1377 -        return yy_scan_bytes( yy_str, len );
175.1378 -        }
175.1379 -#endif
175.1380 -
175.1381 -
175.1382 -#ifndef YY_NO_SCAN_BYTES
175.1383 -#ifdef YY_USE_PROTOS
175.1384 -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
175.1385 -#else
175.1386 -YY_BUFFER_STATE yy_scan_bytes( bytes, len )
175.1387 -yyconst char *bytes;
175.1388 -int len;
175.1389 -#endif
175.1390 -        {
175.1391 -        YY_BUFFER_STATE b;
175.1392 -        char *buf;
175.1393 -        yy_size_t n;
175.1394 -        int i;
175.1395 -
175.1396 -        /* Get memory for full buffer, including space for trailing EOB's. */
175.1397 -        n = len + 2;
175.1398 -        buf = (char *) yy_flex_alloc( n );
175.1399 -        if ( ! buf )
175.1400 -                YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
175.1401 -
175.1402 -        for ( i = 0; i < len; ++i )
175.1403 -                buf[i] = bytes[i];
175.1404 -
175.1405 -        buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
175.1406 -
175.1407 -        b = yy_scan_buffer( buf, n );
175.1408 -        if ( ! b )
175.1409 -                YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
175.1410 -
175.1411 -        /* It's okay to grow etc. this buffer, and we should throw it
175.1412 -         * away when we're done.
175.1413 -         */
175.1414 -        b->yy_is_our_buffer = 1;
175.1415 -
175.1416 -        return b;
175.1417 -        }
175.1418 -#endif
175.1419 -
175.1420 -
175.1421 -#ifndef YY_NO_PUSH_STATE
175.1422 -#ifdef YY_USE_PROTOS
175.1423 -static void yy_push_state( int new_state )
175.1424 -#else
175.1425 -static void yy_push_state( new_state )
175.1426 -int new_state;
175.1427 -#endif
175.1428 -        {
175.1429 -        if ( yy_start_stack_ptr >= yy_start_stack_depth )
175.1430 -                {
175.1431 -                yy_size_t new_size;
175.1432 -
175.1433 -                yy_start_stack_depth += YY_START_STACK_INCR;
175.1434 -                new_size = yy_start_stack_depth * sizeof( int );
175.1435 -
175.1436 -                if ( ! yy_start_stack )
175.1437 -                        yy_start_stack = (int *) yy_flex_alloc( new_size );
175.1438 -
175.1439 -                else
175.1440 -                        yy_start_stack = (int *) yy_flex_realloc(
175.1441 -                                        (void *) yy_start_stack, new_size );
175.1442 -
175.1443 -                if ( ! yy_start_stack )
175.1444 -                        YY_FATAL_ERROR(
175.1445 -                        "out of memory expanding start-condition stack" );
175.1446 -                }
175.1447 -
175.1448 -        yy_start_stack[yy_start_stack_ptr++] = YY_START;
175.1449 -
175.1450 -        BEGIN(new_state);
175.1451 -        }
175.1452 -#endif
175.1453 -
175.1454 -
175.1455 -#ifndef YY_NO_POP_STATE
175.1456 -static void yy_pop_state()
175.1457 -        {
175.1458 -        if ( --yy_start_stack_ptr < 0 )
175.1459 -                YY_FATAL_ERROR( "start-condition stack underflow" );
175.1460 -
175.1461 -        BEGIN(yy_start_stack[yy_start_stack_ptr]);
175.1462 -        }
175.1463 -#endif
175.1464 -
175.1465 -
175.1466 -#ifndef YY_NO_TOP_STATE
175.1467 -static int yy_top_state()
175.1468 -        {
175.1469 -        return yy_start_stack[yy_start_stack_ptr - 1];
175.1470 -        }
175.1471 -#endif
175.1472 -
175.1473 -#ifndef YY_EXIT_FAILURE
175.1474 -#define YY_EXIT_FAILURE 2
175.1475 -#endif
175.1476 -
175.1477 -#ifdef YY_USE_PROTOS
175.1478 -static void yy_fatal_error( yyconst char msg[] )
175.1479 -#else
175.1480 -static void yy_fatal_error( msg )
175.1481 -char msg[];
175.1482 -#endif
175.1483 -        {
175.1484 -        (void) fprintf( stderr, "%s\n", msg );
175.1485 -        exit( YY_EXIT_FAILURE );
175.1486 -        }
175.1487 -
175.1488 -
175.1489 -
175.1490 -/* Redefine yyless() so it works in section 3 code. */
175.1491 -
175.1492 -#undef yyless
175.1493 -#define yyless(n) \
175.1494 -        do \
175.1495 -                { \
175.1496 -                /* Undo effects of setting up yytext. */ \
175.1497 -                yytext[yyleng] = yy_hold_char; \
175.1498 -                yy_c_buf_p = yytext + n; \
175.1499 -                yy_hold_char = *yy_c_buf_p; \
175.1500 -                *yy_c_buf_p = '\0'; \
175.1501 -                yyleng = n; \
175.1502 -                } \
175.1503 -        while ( 0 )
175.1504 -
175.1505 -
175.1506 -/* Internal utility routines. */
175.1507 -
175.1508 -#ifndef yytext_ptr
175.1509 -#ifdef YY_USE_PROTOS
175.1510 -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
175.1511 -#else
175.1512 -static void yy_flex_strncpy( s1, s2, n )
175.1513 -char *s1;
175.1514 -yyconst char *s2;
175.1515 -int n;
175.1516 -#endif
175.1517 -        {
175.1518 -        register int i;
175.1519 -        for ( i = 0; i < n; ++i )
175.1520 -                s1[i] = s2[i];
175.1521 -        }
175.1522 -#endif
175.1523 -
175.1524 -#ifdef YY_NEED_STRLEN
175.1525 -#ifdef YY_USE_PROTOS
175.1526 -static int yy_flex_strlen( yyconst char *s )
175.1527 -#else
175.1528 -static int yy_flex_strlen( s )
175.1529 -yyconst char *s;
175.1530 -#endif
175.1531 -        {
175.1532 -        register int n;
175.1533 -        for ( n = 0; s[n]; ++n )
175.1534 -                ;
175.1535 -
175.1536 -        return n;
175.1537 -        }
175.1538 -#endif
175.1539 -
175.1540 -
175.1541 -#ifdef YY_USE_PROTOS
175.1542 -static void *yy_flex_alloc( yy_size_t size )
175.1543 -#else
175.1544 -static void *yy_flex_alloc( size )
175.1545 -yy_size_t size;
175.1546 -#endif
175.1547 -        {
175.1548 -        return (void *) malloc( size );
175.1549 -        }
175.1550 -
175.1551 -#ifdef YY_USE_PROTOS
175.1552 -static void *yy_flex_realloc( void *ptr, yy_size_t size )
175.1553 -#else
175.1554 -static void *yy_flex_realloc( ptr, size )
175.1555 -void *ptr;
175.1556 -yy_size_t size;
175.1557 -#endif
175.1558 -        {
175.1559 -        /* The cast to (char *) in the following accommodates both
175.1560 -         * implementations that use char* generic pointers, and those
175.1561 -         * that use void* generic pointers.  It works with the latter
175.1562 -         * because both ANSI C and C++ allow castless assignment from
175.1563 -         * any pointer type to void*, and deal with argument conversions
175.1564 -         * as though doing an assignment.
175.1565 -         */
175.1566 -        return (void *) realloc( (char *) ptr, size );
175.1567 -        }
175.1568 -
175.1569 -#ifdef YY_USE_PROTOS
175.1570 -static void yy_flex_free( void *ptr )
175.1571 -#else
175.1572 -static void yy_flex_free( ptr )
175.1573 -void *ptr;
175.1574 -#endif
175.1575 -        {
175.1576 -        free( ptr );
175.1577 -        }
175.1578 -
175.1579 -#if YY_MAIN
175.1580 -int main()
175.1581 -        {
175.1582 -        yylex();
175.1583 -        return 0;
175.1584 -        }
175.1585 -#endif
175.1586 -#line 65 "expr.l"
175.1587 -
175.1588 -
175.1589 -void exprCleanBuffer()
175.1590 -{
175.1591 -  yy_delete_buffer(yy_current_buffer);
175.1592 -  yy_init = 1;
175.1593 -}
   176.1 --- a/src/sdl/expr.cpp	Sat Mar 03 10:54:39 2012 -0600
   176.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   176.3 @@ -1,998 +0,0 @@
   176.4 -
   176.5 -/*  A Bison parser, made from expr.y
   176.6 -    by GNU Bison version 1.28  */
   176.7 -
   176.8 -#define YYBISON 1  /* Identify Bison output.  */
   176.9 -
  176.10 -#define TOKEN_IDENTIFIER        257
  176.11 -#define TOKEN_DOT       258
  176.12 -#define TOKEN_STAR      259
  176.13 -#define TOKEN_ARROW     260
  176.14 -#define TOKEN_ADDR      261
  176.15 -#define TOKEN_SIZEOF    262
  176.16 -#define TOKEN_NUMBER    263
  176.17 -
  176.18 -#line 1 "expr.y"
  176.19 -
  176.20 -namespace std {  
  176.21 -#include <stdio.h>
  176.22 -#include <memory.h>
  176.23 -#include <stdlib.h>
  176.24 -#include <string.h>
  176.25 -}
  176.26 -
  176.27 -using namespace std;
  176.28 - 
  176.29 -#include "../common/System.h"
  176.30 -#include "../gba/elf.h"
  176.31 -#include "exprNode.h" 
  176.32 -
  176.33 -extern int yyerror(char *);
  176.34 -extern int yylex(); 
  176.35 -extern char *yytext;
  176.36 -
  176.37 -  
  176.38 -//#define YYERROR_VERBOSE 1
  176.39 -//#define YYDEBUG 1
  176.40 -
  176.41 - Node *result = NULL;
  176.42 -#ifndef YYSTYPE
  176.43 -#define YYSTYPE int
  176.44 -#endif
  176.45 -#include <stdio.h>
  176.46 -
  176.47 -#ifndef __cplusplus
  176.48 -#ifndef __STDC__
  176.49 -#define const
  176.50 -#endif
  176.51 -#endif
  176.52 -
  176.53 -
  176.54 -
  176.55 -#define YYFINAL         26
  176.56 -#define YYFLAG          -32768
  176.57 -#define YYNTBASE        14
  176.58 -
  176.59 -#define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19)
  176.60 -
  176.61 -static const char yytranslate[] = {     0,
  176.62 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.63 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.64 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.65 -     2,     2,     2,     2,     2,     2,     2,     2,     2,    11,
  176.66 -    12,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.67 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.68 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.69 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.70 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.71 -    10,     2,    13,     2,     2,     2,     2,     2,     2,     2,
  176.72 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.73 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.74 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.75 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.76 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.77 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.78 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.79 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.80 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.81 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.82 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.83 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.84 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.85 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.86 -     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.87 -     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
  176.88 -     7,     8,     9
  176.89 -};
  176.90 -
  176.91 -#if YYDEBUG != 0
  176.92 -static const short yyprhs[] = {     0,
  176.93 -     0,     2,     4,     8,    12,    16,    21,    23,    26,    29,
  176.94 -    34,    36
  176.95 -};
  176.96 -
  176.97 -static const short yyrhs[] = {    15,
  176.98 -     0,    16,     0,    11,    15,    12,     0,    15,     4,    18,
  176.99 -     0,    15,     6,    18,     0,    15,    10,    17,    13,     0,
 176.100 -    18,     0,     5,    15,     0,     7,    15,     0,     8,    11,
 176.101 -    15,    12,     0,     9,     0,     3,     0
 176.102 -};
 176.103 -
 176.104 -#endif
 176.105 -
 176.106 -#if YYDEBUG != 0
 176.107 -static const short yyrline[] = { 0,
 176.108 -    32,    35,    36,    37,    38,    39,    42,    43,    44,    45,
 176.109 -    49,    53
 176.110 -};
 176.111 -#endif
 176.112 -
 176.113 -
 176.114 -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
 176.115 -
 176.116 -static const char * const yytname[] = {   "$","error","$undefined.","TOKEN_IDENTIFIER",
 176.117 -"TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER",
 176.118 -"'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL
 176.119 -};
 176.120 -#endif
 176.121 -
 176.122 -static const short yyr1[] = {     0,
 176.123 -    14,    15,    15,    15,    15,    15,    16,    16,    16,    16,
 176.124 -    17,    18
 176.125 -};
 176.126 -
 176.127 -static const short yyr2[] = {     0,
 176.128 -     1,     1,     3,     3,     3,     4,     1,     2,     2,     4,
 176.129 -     1,     1
 176.130 -};
 176.131 -
 176.132 -static const short yydefact[] = {     0,
 176.133 -    12,     0,     0,     0,     0,     1,     2,     7,     8,     9,
 176.134 -     0,     0,     0,     0,     0,     0,     3,     4,     5,    11,
 176.135 -     0,    10,     6,     0,     0,     0
 176.136 -};
 176.137 -
 176.138 -static const short yydefgoto[] = {    24,
 176.139 -     6,     7,    21,     8
 176.140 -};
 176.141 -
 176.142 -static const short yypact[] = {    -1,
 176.143 --32768,    -1,    -1,    -6,    -1,    17,-32768,-32768,    17,    17,
 176.144 -    -1,     7,     5,     5,    13,     8,-32768,-32768,-32768,-32768,
 176.145 -    11,-32768,-32768,    25,    26,-32768
 176.146 -};
 176.147 -
 176.148 -static const short yypgoto[] = {-32768,
 176.149 -    -2,-32768,-32768,     2
 176.150 -};
 176.151 -
 176.152 -
 176.153 -#define YYLAST          27
 176.154 -
 176.155 -
 176.156 -static const short yytable[] = {     9,
 176.157 -    10,     1,    12,     2,    11,     3,     4,     1,    16,     5,
 176.158 -    13,    13,    14,    14,    18,    19,    15,    15,    17,    22,
 176.159 -    13,    20,    14,    23,    25,    26,    15
 176.160 -};
 176.161 -
 176.162 -static const short yycheck[] = {     2,
 176.163 -     3,     3,     5,     5,    11,     7,     8,     3,    11,    11,
 176.164 -     4,     4,     6,     6,    13,    14,    10,    10,    12,    12,
 176.165 -     4,     9,     6,    13,     0,     0,    10
 176.166 -};
 176.167 -/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
 176.168 -#line 3 "/usr/lib/bison.simple"
 176.169 -/* This file comes from bison-1.28.  */
 176.170 -
 176.171 -/* Skeleton output parser for bison,
 176.172 -   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
 176.173 -
 176.174 -   This program is free software; you can redistribute it and/or modify
 176.175 -   it under the terms of the GNU General Public License as published by
 176.176 -   the Free Software Foundation; either version 2, or (at your option)
 176.177 -   any later version.
 176.178 -
 176.179 -   This program is distributed in the hope that it will be useful,
 176.180 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
 176.181 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 176.182 -   GNU General Public License for more details.
 176.183 -
 176.184 -   You should have received a copy of the GNU General Public License
 176.185 -   along with this program; if not, write to the Free Software
 176.186 -   Foundation, Inc., 59 Temple Place - Suite 330,
 176.187 -   Boston, MA 02111-1307, USA.  */
 176.188 -
 176.189 -/* As a special exception, when this file is copied by Bison into a
 176.190 -   Bison output file, you may use that output file without restriction.
 176.191 -   This special exception was added by the Free Software Foundation
 176.192 -   in version 1.24 of Bison.  */
 176.193 -
 176.194 -/* This is the parser code that is written into each bison parser
 176.195 -  when the %semantic_parser declaration is not specified in the grammar.
 176.196 -  It was written by Richard Stallman by simplifying the hairy parser
 176.197 -  used when %semantic_parser is specified.  */
 176.198 -
 176.199 -#ifndef YYSTACK_USE_ALLOCA
 176.200 -#ifdef alloca
 176.201 -#define YYSTACK_USE_ALLOCA
 176.202 -#else /* alloca not defined */
 176.203 -#ifdef __GNUC__
 176.204 -#define YYSTACK_USE_ALLOCA
 176.205 -#define alloca __builtin_alloca
 176.206 -#else /* not GNU C.  */
 176.207 -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
 176.208 -#define YYSTACK_USE_ALLOCA
 176.209 -#include <alloca.h>
 176.210 -#else /* not sparc */
 176.211 -/* We think this test detects Watcom and Microsoft C.  */
 176.212 -/* This used to test MSDOS, but that is a bad idea
 176.213 -   since that symbol is in the user namespace.  */
 176.214 -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
 176.215 -#if 0 /* No need for malloc.h, which pollutes the namespace;
 176.216 -         instead, just don't use alloca.  */
 176.217 -#include <malloc.h>
 176.218 -#endif
 176.219 -#else /* not MSDOS, or __TURBOC__ */
 176.220 -#if defined(_AIX)
 176.221 -/* I don't know what this was needed for, but it pollutes the namespace.
 176.222 -   So I turned it off.   rms, 2 May 1997.  */
 176.223 -/* #include <malloc.h>  */
 176.224 - #pragma alloca
 176.225 -#define YYSTACK_USE_ALLOCA
 176.226 -#else /* not MSDOS, or __TURBOC__, or _AIX */
 176.227 -#if 0
 176.228 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
 176.229 -                 and on HPUX 10.  Eventually we can turn this on.  */
 176.230 -#define YYSTACK_USE_ALLOCA
 176.231 -#define alloca __builtin_alloca
 176.232 -#endif /* __hpux */
 176.233 -#endif
 176.234 -#endif /* not _AIX */
 176.235 -#endif /* not MSDOS, or __TURBOC__ */
 176.236 -#endif /* not sparc */
 176.237 -#endif /* not GNU C */
 176.238 -#endif /* alloca not defined */
 176.239 -#endif /* YYSTACK_USE_ALLOCA not defined */
 176.240 -
 176.241 -#ifdef YYSTACK_USE_ALLOCA
 176.242 -#define YYSTACK_ALLOC alloca
 176.243 -#else
 176.244 -#define YYSTACK_ALLOC malloc
 176.245 -#endif
 176.246 -
 176.247 -/* Note: there must be only one dollar sign in this file.
 176.248 -   It is replaced by the list of actions, each action
 176.249 -   as one case of the switch.  */
 176.250 -
 176.251 -#define yyerrok         (yyerrstatus = 0)
 176.252 -#define yyclearin       (yychar = YYEMPTY)
 176.253 -#define YYEMPTY         -2
 176.254 -#define YYEOF           0
 176.255 -#define YYACCEPT        goto yyacceptlab
 176.256 -#define YYABORT         goto yyabortlab
 176.257 -#define YYERROR         goto yyerrlab1
 176.258 -/* Like YYERROR except do call yyerror.
 176.259 -   This remains here temporarily to ease the
 176.260 -   transition to the new meaning of YYERROR, for GCC.
 176.261 -   Once GCC version 2 has supplanted version 1, this can go.  */
 176.262 -#define YYFAIL          goto yyerrlab
 176.263 -#define YYRECOVERING()  (!!yyerrstatus)
 176.264 -#define YYBACKUP(token, value) \
 176.265 -do                                                              \
 176.266 -  if (yychar == YYEMPTY && yylen == 1)                          \
 176.267 -    { yychar = (token), yylval = (value);                       \
 176.268 -      yychar1 = YYTRANSLATE (yychar);                           \
 176.269 -      YYPOPSTACK;                                               \
 176.270 -      goto yybackup;                                            \
 176.271 -    }                                                           \
 176.272 -  else                                                          \
 176.273 -    { yyerror ("syntax error: cannot back up"); YYERROR; }      \
 176.274 -while (0)
 176.275 -
 176.276 -#define YYTERROR        1
 176.277 -#define YYERRCODE       256
 176.278 -
 176.279 -#ifndef YYPURE
 176.280 -#define YYLEX           yylex()
 176.281 -#endif
 176.282 -
 176.283 -#ifdef YYPURE
 176.284 -#ifdef YYLSP_NEEDED
 176.285 -#ifdef YYLEX_PARAM
 176.286 -#define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
 176.287 -#else
 176.288 -#define YYLEX           yylex(&yylval, &yylloc)
 176.289 -#endif
 176.290 -#else /* not YYLSP_NEEDED */
 176.291 -#ifdef YYLEX_PARAM
 176.292 -#define YYLEX           yylex(&yylval, YYLEX_PARAM)
 176.293 -#else
 176.294 -#define YYLEX           yylex(&yylval)
 176.295 -#endif
 176.296 -#endif /* not YYLSP_NEEDED */
 176.297 -#endif
 176.298 -
 176.299 -/* If nonreentrant, generate the variables here */
 176.300 -
 176.301 -#ifndef YYPURE
 176.302 -
 176.303 -int     yychar;                 /*  the lookahead symbol                */
 176.304 -YYSTYPE yylval;                 /*  the semantic value of the           */
 176.305 -                                /*  lookahead symbol                    */
 176.306 -
 176.307 -#ifdef YYLSP_NEEDED
 176.308 -YYLTYPE yylloc;                 /*  location data for the lookahead     */
 176.309 -                                /*  symbol                              */
 176.310 -#endif
 176.311 -
 176.312 -int yynerrs;                    /*  number of parse errors so far       */
 176.313 -#endif  /* not YYPURE */
 176.314 -
 176.315 -#if YYDEBUG != 0
 176.316 -int yydebug;                    /*  nonzero means print parse trace     */
 176.317 -/* Since this is uninitialized, it does not stop multiple parsers
 176.318 -   from coexisting.  */
 176.319 -#endif
 176.320 -
 176.321 -/*  YYINITDEPTH indicates the initial size of the parser's stacks       */
 176.322 -
 176.323 -#ifndef YYINITDEPTH
 176.324 -#define YYINITDEPTH 200
 176.325 -#endif
 176.326 -
 176.327 -/*  YYMAXDEPTH is the maximum size the stacks can grow to
 176.328 -    (effective only if the built-in stack extension method is used).  */
 176.329 -
 176.330 -#if YYMAXDEPTH == 0
 176.331 -#undef YYMAXDEPTH
 176.332 -#endif
 176.333 -
 176.334 -#ifndef YYMAXDEPTH
 176.335 -#define YYMAXDEPTH 10000
 176.336 -#endif
 176.337 -
 176.338 -/* Define __yy_memcpy.  Note that the size argument
 176.339 -   should be passed with type unsigned int, because that is what the non-GCC
 176.340 -   definitions require.  With GCC, __builtin_memcpy takes an arg
 176.341 -   of type size_t, but it can handle unsigned int.  */
 176.342 -
 176.343 -#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
 176.344 -#define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
 176.345 -#else                           /* not GNU C or C++ */
 176.346 -#ifndef __cplusplus
 176.347 -
 176.348 -/* This is the most reliable way to avoid incompatibilities
 176.349 -   in available built-in functions on various systems.  */
 176.350 -static void
 176.351 -__yy_memcpy (to, from, count)
 176.352 -     char *to;
 176.353 -     char *from;
 176.354 -     unsigned int count;
 176.355 -{
 176.356 -  register char *f = from;
 176.357 -  register char *t = to;
 176.358 -  register int i = count;
 176.359 -
 176.360 -  while (i-- > 0)
 176.361 -    *t++ = *f++;
 176.362 -}
 176.363 -
 176.364 -#else /* __cplusplus */
 176.365 -
 176.366 -/* This is the most reliable way to avoid incompatibilities
 176.367 -   in available built-in functions on various systems.  */
 176.368 -static void
 176.369 -__yy_memcpy (char *to, char *from, unsigned int count)
 176.370 -{
 176.371 -  register char *t = to;
 176.372 -  register char *f = from;
 176.373 -  register int i = count;
 176.374 -
 176.375 -  while (i-- > 0)
 176.376 -    *t++ = *f++;
 176.377 -}
 176.378 -
 176.379 -#endif
 176.380 -#endif
 176.381 -
 176.382 -#line 217 "/usr/lib/bison.simple"
 176.383 -
 176.384 -/* The user can define YYPARSE_PARAM as the name of an argument to be passed
 176.385 -   into yyparse.  The argument should have type void *.
 176.386 -   It should actually point to an object.
 176.387 -   Grammar actions can access the variable by casting it
 176.388 -   to the proper pointer type.  */
 176.389 -
 176.390 -#ifdef YYPARSE_PARAM
 176.391 -#ifdef __cplusplus
 176.392 -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
 176.393 -#define YYPARSE_PARAM_DECL
 176.394 -#else /* not __cplusplus */
 176.395 -#define YYPARSE_PARAM_ARG YYPARSE_PARAM
 176.396 -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
 176.397 -#endif /* not __cplusplus */
 176.398 -#else /* not YYPARSE_PARAM */
 176.399 -#define YYPARSE_PARAM_ARG
 176.400 -#define YYPARSE_PARAM_DECL
 176.401 -#endif /* not YYPARSE_PARAM */
 176.402 -
 176.403 -/* Prevent warning if -Wstrict-prototypes.  */
 176.404 -#ifdef __GNUC__
 176.405 -#ifdef YYPARSE_PARAM
 176.406 -int yyparse (void *);
 176.407 -#else
 176.408 -int yyparse (void);
 176.409 -#endif
 176.410 -#endif
 176.411 -
 176.412 -int
 176.413 -yyparse(YYPARSE_PARAM_ARG)
 176.414 -     YYPARSE_PARAM_DECL
 176.415 -{
 176.416 -  register int yystate;
 176.417 -  register int yyn;
 176.418 -  register short *yyssp;
 176.419 -  register YYSTYPE *yyvsp;
 176.420 -  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
 176.421 -  int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
 176.422 -
 176.423 -  short yyssa[YYINITDEPTH];     /*  the state stack                     */
 176.424 -  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
 176.425 -
 176.426 -  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
 176.427 -  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
 176.428 -
 176.429 -#ifdef YYLSP_NEEDED
 176.430 -  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
 176.431 -  YYLTYPE *yyls = yylsa;
 176.432 -  YYLTYPE *yylsp;
 176.433 -
 176.434 -#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
 176.435 -#else
 176.436 -#define YYPOPSTACK   (yyvsp--, yyssp--)
 176.437 -#endif
 176.438 -
 176.439 -  int yystacksize = YYINITDEPTH;
 176.440 -  int yyfree_stacks = 0;
 176.441 -
 176.442 -#ifdef YYPURE
 176.443 -  int yychar;
 176.444 -  YYSTYPE yylval;
 176.445 -  int yynerrs;
 176.446 -#ifdef YYLSP_NEEDED
 176.447 -  YYLTYPE yylloc;
 176.448 -#endif
 176.449 -#endif
 176.450 -
 176.451 -  YYSTYPE yyval;                /*  the variable used to return         */
 176.452 -                                /*  semantic values from the action     */
 176.453 -                                /*  routines                            */
 176.454 -
 176.455 -  int yylen;
 176.456 -
 176.457 -#if YYDEBUG != 0
 176.458 -  if (yydebug)
 176.459 -    fprintf(stderr, "Starting parse\n");
 176.460 -#endif
 176.461 -
 176.462 -  yystate = 0;
 176.463 -  yyerrstatus = 0;
 176.464 -  yynerrs = 0;
 176.465 -  yychar = YYEMPTY;             /* Cause a token to be read.  */
 176.466 -
 176.467 -  /* Initialize stack pointers.
 176.468 -     Waste one element of value and location stack
 176.469 -     so that they stay on the same level as the state stack.
 176.470 -     The wasted elements are never initialized.  */
 176.471 -
 176.472 -  yyssp = yyss - 1;
 176.473 -  yyvsp = yyvs;
 176.474 -#ifdef YYLSP_NEEDED
 176.475 -  yylsp = yyls;
 176.476 -#endif
 176.477 -
 176.478 -/* Push a new state, which is found in  yystate  .  */
 176.479 -/* In all cases, when you get here, the value and location stacks
 176.480 -   have just been pushed. so pushing a state here evens the stacks.  */
 176.481 -yynewstate:
 176.482 -
 176.483 -  *++yyssp = yystate;
 176.484 -
 176.485 -  if (yyssp >= yyss + yystacksize - 1)
 176.486 -    {
 176.487 -      /* Give user a chance to reallocate the stack */
 176.488 -      /* Use copies of these so that the &'s don't force the real ones into memory. */
 176.489 -      YYSTYPE *yyvs1 = yyvs;
 176.490 -      short *yyss1 = yyss;
 176.491 -#ifdef YYLSP_NEEDED
 176.492 -      YYLTYPE *yyls1 = yyls;
 176.493 -#endif
 176.494 -
 176.495 -      /* Get the current used size of the three stacks, in elements.  */
 176.496 -      int size = yyssp - yyss + 1;
 176.497 -
 176.498 -#ifdef yyoverflow
 176.499 -      /* Each stack pointer address is followed by the size of
 176.500 -         the data in use in that stack, in bytes.  */
 176.501 -#ifdef YYLSP_NEEDED
 176.502 -      /* This used to be a conditional around just the two extra args,
 176.503 -         but that might be undefined if yyoverflow is a macro.  */
 176.504 -      yyoverflow("parser stack overflow",
 176.505 -                 &yyss1, size * sizeof (*yyssp),
 176.506 -                 &yyvs1, size * sizeof (*yyvsp),
 176.507 -                 &yyls1, size * sizeof (*yylsp),
 176.508 -                 &yystacksize);
 176.509 -#else
 176.510 -      yyoverflow("parser stack overflow",
 176.511 -                 &yyss1, size * sizeof (*yyssp),
 176.512 -                 &yyvs1, size * sizeof (*yyvsp),
 176.513 -                 &yystacksize);
 176.514 -#endif
 176.515 -
 176.516 -      yyss = yyss1; yyvs = yyvs1;
 176.517 -#ifdef YYLSP_NEEDED
 176.518 -      yyls = yyls1;
 176.519 -#endif
 176.520 -#else /* no yyoverflow */
 176.521 -      /* Extend the stack our own way.  */
 176.522 -      if (yystacksize >= YYMAXDEPTH)
 176.523 -        {
 176.524 -          yyerror("parser stack overflow");
 176.525 -          if (yyfree_stacks)
 176.526 -            {
 176.527 -              free (yyss);
 176.528 -              free (yyvs);
 176.529 -#ifdef YYLSP_NEEDED
 176.530 -              free (yyls);
 176.531 -#endif
 176.532 -            }
 176.533 -          return 2;
 176.534 -        }
 176.535 -      yystacksize *= 2;
 176.536 -      if (yystacksize > YYMAXDEPTH)
 176.537 -        yystacksize = YYMAXDEPTH;
 176.538 -#ifndef YYSTACK_USE_ALLOCA
 176.539 -      yyfree_stacks = 1;
 176.540 -#endif
 176.541 -      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
 176.542 -      __yy_memcpy ((char *)yyss, (char *)yyss1,
 176.543 -                   size * (unsigned int) sizeof (*yyssp));
 176.544 -      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
 176.545 -      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
 176.546 -                   size * (unsigned int) sizeof (*yyvsp));
 176.547 -#ifdef YYLSP_NEEDED
 176.548 -      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
 176.549 -      __yy_memcpy ((char *)yyls, (char *)yyls1,
 176.550 -                   size * (unsigned int) sizeof (*yylsp));
 176.551 -#endif
 176.552 -#endif /* no yyoverflow */
 176.553 -
 176.554 -      yyssp = yyss + size - 1;
 176.555 -      yyvsp = yyvs + size - 1;
 176.556 -#ifdef YYLSP_NEEDED
 176.557 -      yylsp = yyls + size - 1;
 176.558 -#endif
 176.559 -
 176.560 -#if YYDEBUG != 0
 176.561 -      if (yydebug)
 176.562 -        fprintf(stderr, "Stack size increased to %d\n", yystacksize);
 176.563 -#endif
 176.564 -
 176.565 -      if (yyssp >= yyss + yystacksize - 1)
 176.566 -        YYABORT;
 176.567 -    }
 176.568 -
 176.569 -#if YYDEBUG != 0
 176.570 -  if (yydebug)
 176.571 -    fprintf(stderr, "Entering state %d\n", yystate);
 176.572 -#endif
 176.573 -
 176.574 -  goto yybackup;
 176.575 - yybackup:
 176.576 -
 176.577 -/* Do appropriate processing given the current state.  */
 176.578 -/* Read a lookahead token if we need one and don't already have one.  */
 176.579 -/* yyresume: */
 176.580 -
 176.581 -  /* First try to decide what to do without reference to lookahead token.  */
 176.582 -
 176.583 -  yyn = yypact[yystate];
 176.584 -  if (yyn == YYFLAG)
 176.585 -    goto yydefault;
 176.586 -
 176.587 -  /* Not known => get a lookahead token if don't already have one.  */
 176.588 -
 176.589 -  /* yychar is either YYEMPTY or YYEOF
 176.590 -     or a valid token in external form.  */
 176.591 -
 176.592 -  if (yychar == YYEMPTY)
 176.593 -    {
 176.594 -#if YYDEBUG != 0
 176.595 -      if (yydebug)
 176.596 -        fprintf(stderr, "Reading a token: ");
 176.597 -#endif
 176.598 -      yychar = YYLEX;
 176.599 -    }
 176.600 -
 176.601 -  /* Convert token to internal form (in yychar1) for indexing tables with */
 176.602 -
 176.603 -  if (yychar <= 0)              /* This means end of input. */
 176.604 -    {
 176.605 -      yychar1 = 0;
 176.606 -      yychar = YYEOF;           /* Don't call YYLEX any more */
 176.607 -
 176.608 -#if YYDEBUG != 0
 176.609 -      if (yydebug)
 176.610 -        fprintf(stderr, "Now at end of input.\n");
 176.611 -#endif
 176.612 -    }
 176.613 -  else
 176.614 -    {
 176.615 -      yychar1 = YYTRANSLATE(yychar);
 176.616 -
 176.617 -#if YYDEBUG != 0
 176.618 -      if (yydebug)
 176.619 -        {
 176.620 -          fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
 176.621 -          /* Give the individual parser a way to print the precise meaning
 176.622 -             of a token, for further debugging info.  */
 176.623 -#ifdef YYPRINT
 176.624 -          YYPRINT (stderr, yychar, yylval);
 176.625 -#endif
 176.626 -          fprintf (stderr, ")\n");
 176.627 -        }
 176.628 -#endif
 176.629 -    }
 176.630 -
 176.631 -  yyn += yychar1;
 176.632 -  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
 176.633 -    goto yydefault;
 176.634 -
 176.635 -  yyn = yytable[yyn];
 176.636 -
 176.637 -  /* yyn is what to do for this token type in this state.
 176.638 -     Negative => reduce, -yyn is rule number.
 176.639 -     Positive => shift, yyn is new state.
 176.640 -       New state is final state => don't bother to shift,
 176.641 -       just return success.
 176.642 -     0, or most negative number => error.  */
 176.643 -
 176.644 -  if (yyn < 0)
 176.645 -    {
 176.646 -      if (yyn == YYFLAG)
 176.647 -        goto yyerrlab;
 176.648 -      yyn = -yyn;
 176.649 -      goto yyreduce;
 176.650 -    }
 176.651 -  else if (yyn == 0)
 176.652 -    goto yyerrlab;
 176.653 -
 176.654 -  if (yyn == YYFINAL)
 176.655 -    YYACCEPT;
 176.656 -
 176.657 -  /* Shift the lookahead token.  */
 176.658 -
 176.659 -#if YYDEBUG != 0
 176.660 -  if (yydebug)
 176.661 -    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
 176.662 -#endif
 176.663 -
 176.664 -  /* Discard the token being shifted unless it is eof.  */
 176.665 -  if (yychar != YYEOF)
 176.666 -    yychar = YYEMPTY;
 176.667 -
 176.668 -  *++yyvsp = yylval;
 176.669 -#ifdef YYLSP_NEEDED
 176.670 -  *++yylsp = yylloc;
 176.671 -#endif
 176.672 -
 176.673 -  /* count tokens shifted since error; after three, turn off error status.  */
 176.674 -  if (yyerrstatus) yyerrstatus--;
 176.675 -
 176.676 -  yystate = yyn;
 176.677 -  goto yynewstate;
 176.678 -
 176.679 -/* Do the default action for the current state.  */
 176.680 -yydefault:
 176.681 -
 176.682 -  yyn = yydefact[yystate];
 176.683 -  if (yyn == 0)
 176.684 -    goto yyerrlab;
 176.685 -
 176.686 -/* Do a reduction.  yyn is the number of a rule to reduce with.  */
 176.687 -yyreduce:
 176.688 -  yylen = yyr2[yyn];
 176.689 -  if (yylen > 0)
 176.690 -    yyval = yyvsp[1-yylen]; /* implement default value of the action */
 176.691 -
 176.692 -#if YYDEBUG != 0
 176.693 -  if (yydebug)
 176.694 -    {
 176.695 -      int i;
 176.696 -
 176.697 -      fprintf (stderr, "Reducing via rule %d (line %d), ",
 176.698 -               yyn, yyrline[yyn]);
 176.699 -
 176.700 -      /* Print the symbols being reduced, and their result.  */
 176.701 -      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
 176.702 -        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
 176.703 -      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
 176.704 -    }
 176.705 -#endif
 176.706 -
 176.707 -
 176.708 -  switch (yyn) {
 176.709 -
 176.710 -case 1:
 176.711 -#line 32 "expr.y"
 176.712 -{ result = yyvsp[0]; ;
 176.713 -    break;}
 176.714 -case 2:
 176.715 -#line 36 "expr.y"
 176.716 -{ yyval = yyvsp[0]; ;
 176.717 -    break;}
 176.718 -case 3:
 176.719 -#line 37 "expr.y"
 176.720 -{ yyval = yyvsp[-1]; ;
 176.721 -    break;}
 176.722 -case 4:
 176.723 -#line 38 "expr.y"
 176.724 -{ yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ;
 176.725 -    break;}
 176.726 -case 5:
 176.727 -#line 39 "expr.y"
 176.728 -{ yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ;
 176.729 -    break;}
 176.730 -case 6:
 176.731 -#line 40 "expr.y"
 176.732 -{ yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ;
 176.733 -    break;}
 176.734 -case 7:
 176.735 -#line 43 "expr.y"
 176.736 -{ yyval = yyvsp[0]; ;
 176.737 -    break;}
 176.738 -case 8:
 176.739 -#line 44 "expr.y"
 176.740 -{ yyval = exprNodeStar(yyvsp[0]); ;
 176.741 -    break;}
 176.742 -case 9:
 176.743 -#line 45 "expr.y"
 176.744 -{ yyval = exprNodeAddr(yyvsp[0]); ;
 176.745 -    break;}
 176.746 -case 10:
 176.747 -#line 46 "expr.y"
 176.748 -{ yyval = exprNodeSizeof(yyvsp[-1]); ;
 176.749 -    break;}
 176.750 -case 11:
 176.751 -#line 50 "expr.y"
 176.752 -{ yyval = exprNodeNumber(); ;
 176.753 -    break;}
 176.754 -case 12:
 176.755 -#line 54 "expr.y"
 176.756 -{yyval = exprNodeIdentifier(); ;
 176.757 -    break;}
 176.758 -}
 176.759 -   /* the action file gets copied in in place of this dollarsign */
 176.760 -#line 543 "/usr/lib/bison.simple"
 176.761 -
 176.762 -  yyvsp -= yylen;
 176.763 -  yyssp -= yylen;
 176.764 -#ifdef YYLSP_NEEDED
 176.765 -  yylsp -= yylen;
 176.766 -#endif
 176.767 -
 176.768 -#if YYDEBUG != 0
 176.769 -  if (yydebug)
 176.770 -    {
 176.771 -      short *ssp1 = yyss - 1;
 176.772 -      fprintf (stderr, "state stack now");
 176.773 -      while (ssp1 != yyssp)
 176.774 -        fprintf (stderr, " %d", *++ssp1);
 176.775 -      fprintf (stderr, "\n");
 176.776 -    }
 176.777 -#endif
 176.778 -
 176.779 -  *++yyvsp = yyval;
 176.780 -
 176.781 -#ifdef YYLSP_NEEDED
 176.782 -  yylsp++;
 176.783 -  if (yylen == 0)
 176.784 -    {
 176.785 -      yylsp->first_line = yylloc.first_line;
 176.786 -      yylsp->first_column = yylloc.first_column;
 176.787 -      yylsp->last_line = (yylsp-1)->last_line;
 176.788 -      yylsp->last_column = (yylsp-1)->last_column;
 176.789 -      yylsp->text = 0;
 176.790 -    }
 176.791 -  else
 176.792 -    {
 176.793 -      yylsp->last_line = (yylsp+yylen-1)->last_line;
 176.794 -      yylsp->last_column = (yylsp+yylen-1)->last_column;
 176.795 -    }
 176.796 -#endif
 176.797 -
 176.798 -  /* Now "shift" the result of the reduction.
 176.799 -     Determine what state that goes to,
 176.800 -     based on the state we popped back to
 176.801 -     and the rule number reduced by.  */
 176.802 -
 176.803 -  yyn = yyr1[yyn];
 176.804 -
 176.805 -  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
 176.806 -  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
 176.807 -    yystate = yytable[yystate];
 176.808 -  else
 176.809 -    yystate = yydefgoto[yyn - YYNTBASE];
 176.810 -
 176.811 -  goto yynewstate;
 176.812 -
 176.813 -yyerrlab:   /* here on detecting error */
 176.814 -
 176.815 -  if (! yyerrstatus)
 176.816 -    /* If not already recovering from an error, report this error.  */
 176.817 -    {
 176.818 -      ++yynerrs;
 176.819 -
 176.820 -#ifdef YYERROR_VERBOSE
 176.821 -      yyn = yypact[yystate];
 176.822 -
 176.823 -      if (yyn > YYFLAG && yyn < YYLAST)
 176.824 -        {
 176.825 -          int size = 0;
 176.826 -          char *msg;
 176.827 -          int x, count;
 176.828 -
 176.829 -          count = 0;
 176.830 -          /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
 176.831 -          for (x = (yyn < 0 ? -yyn : 0);
 176.832 -               x < (sizeof(yytname) / sizeof(char *)); x++)
 176.833 -            if (yycheck[x + yyn] == x)
 176.834 -              size += strlen(yytname[x]) + 15, count++;
 176.835 -          msg = (char *) malloc(size + 15);
 176.836 -          if (msg != 0)
 176.837 -            {
 176.838 -              strcpy(msg, "parse error");
 176.839 -
 176.840 -              if (count < 5)
 176.841 -                {
 176.842 -                  count = 0;
 176.843 -                  for (x = (yyn < 0 ? -yyn : 0);
 176.844 -                       x < (sizeof(yytname) / sizeof(char *)); x++)
 176.845 -                    if (yycheck[x + yyn] == x)
 176.846 -                      {
 176.847 -                        strcat(msg, count == 0 ? ", expecting `" : " or `");
 176.848 -                        strcat(msg, yytname[x]);
 176.849 -                        strcat(msg, "'");
 176.850 -                        count++;
 176.851 -                      }
 176.852 -                }
 176.853 -              yyerror(msg);
 176.854 -              free(msg);
 176.855 -            }
 176.856 -          else
 176.857 -            yyerror ("parse error; also virtual memory exceeded");
 176.858 -        }
 176.859 -      else
 176.860 -#endif /* YYERROR_VERBOSE */
 176.861 -        yyerror("parse error");
 176.862 -    }
 176.863 -
 176.864 -  goto yyerrlab1;
 176.865 -yyerrlab1:   /* here on error raised explicitly by an action */
 176.866 -
 176.867 -  if (yyerrstatus == 3)
 176.868 -    {
 176.869 -      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
 176.870 -
 176.871 -      /* return failure if at end of input */
 176.872 -      if (yychar == YYEOF)
 176.873 -        YYABORT;
 176.874 -
 176.875 -#if YYDEBUG != 0
 176.876 -      if (yydebug)
 176.877 -        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
 176.878 -#endif
 176.879 -
 176.880 -      yychar = YYEMPTY;
 176.881 -    }
 176.882 -
 176.883 -  /* Else will try to reuse lookahead token
 176.884 -     after shifting the error token.  */
 176.885 -
 176.886 -  yyerrstatus = 3;              /* Each real token shifted decrements this */
 176.887 -
 176.888 -  goto yyerrhandle;
 176.889 -
 176.890 -yyerrdefault:  /* current state does not do anything special for the error token. */
 176.891 -
 176.892 -#if 0
 176.893 -  /* This is wrong; only states that explicitly want error tokens
 176.894 -     should shift them.  */
 176.895 -  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
 176.896 -  if (yyn) goto yydefault;
 176.897 -#endif
 176.898 -
 176.899 -yyerrpop:   /* pop the current state because it cannot handle the error token */
 176.900 -
 176.901 -  if (yyssp == yyss) YYABORT;
 176.902 -  yyvsp--;
 176.903 -  yystate = *--yyssp;
 176.904 -#ifdef YYLSP_NEEDED
 176.905 -  yylsp--;
 176.906 -#endif
 176.907 -
 176.908 -#if YYDEBUG != 0
 176.909 -  if (yydebug)
 176.910 -    {
 176.911 -      short *ssp1 = yyss - 1;
 176.912 -      fprintf (stderr, "Error: state stack now");
 176.913 -      while (ssp1 != yyssp)
 176.914 -        fprintf (stderr, " %d", *++ssp1);
 176.915 -      fprintf (stderr, "\n");
 176.916 -    }
 176.917 -#endif
 176.918 -
 176.919 -yyerrhandle:
 176.920 -
 176.921 -  yyn = yypact[yystate];
 176.922 -  if (yyn == YYFLAG)
 176.923 -    goto yyerrdefault;
 176.924 -
 176.925 -  yyn += YYTERROR;
 176.926 -  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
 176.927 -    goto yyerrdefault;
 176.928 -
 176.929 -  yyn = yytable[yyn];
 176.930 -  if (yyn < 0)
 176.931 -    {
 176.932 -      if (yyn == YYFLAG)
 176.933 -        goto yyerrpop;
 176.934 -      yyn = -yyn;
 176.935 -      goto yyreduce;
 176.936 -    }
 176.937 -  else if (yyn == 0)
 176.938 -    goto yyerrpop;
 176.939 -
 176.940 -  if (yyn == YYFINAL)
 176.941 -    YYACCEPT;
 176.942 -
 176.943 -#if YYDEBUG != 0
 176.944 -  if (yydebug)
 176.945 -    fprintf(stderr, "Shifting error token, ");
 176.946 -#endif
 176.947 -
 176.948 -  *++yyvsp = yylval;
 176.949 -#ifdef YYLSP_NEEDED
 176.950 -  *++yylsp = yylloc;
 176.951 -#endif
 176.952 -
 176.953 -  yystate = yyn;
 176.954 -  goto yynewstate;
 176.955 -
 176.956 - yyacceptlab:
 176.957 -  /* YYACCEPT comes here.  */
 176.958 -  if (yyfree_stacks)
 176.959 -    {
 176.960 -      free (yyss);
 176.961 -      free (yyvs);
 176.962 -#ifdef YYLSP_NEEDED
 176.963 -      free (yyls);
 176.964 -#endif
 176.965 -    }
 176.966 -  return 0;
 176.967 -
 176.968 - yyabortlab:
 176.969 -  /* YYABORT comes here.  */
 176.970 -  if (yyfree_stacks)
 176.971 -    {
 176.972 -      free (yyss);
 176.973 -      free (yyvs);
 176.974 -#ifdef YYLSP_NEEDED
 176.975 -      free (yyls);
 176.976 -#endif
 176.977 -    }
 176.978 -  return 1;
 176.979 -}
 176.980 -#line 57 "expr.y"
 176.981 -
 176.982 -
 176.983 -int yyerror(char *s)
 176.984 -{
 176.985 -  return 0;
 176.986 -}
 176.987 -
 176.988 -#ifndef SDL
 176.989 -extern FILE *yyin;
 176.990 -int main(int argc, char **argv)
 176.991 -{
 176.992 -  //  yydebug = 1;
 176.993 -  ++argv, --argc;
 176.994 -  if(argc > 0)
 176.995 -    yyin = fopen(argv[0], "r");
 176.996 -  else
 176.997 -    yyin = stdin;
 176.998 -  if(!yyparse())
 176.999 -    result->print();
176.1000 -}
176.1001 -#endif
   177.1 --- a/src/sdl/expr.cpp.h	Sat Mar 03 10:54:39 2012 -0600
   177.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   177.3 @@ -1,13 +0,0 @@
   177.4 -#ifndef YYSTYPE
   177.5 -#define YYSTYPE int
   177.6 -#endif
   177.7 -#define TOKEN_IDENTIFIER        257
   177.8 -#define TOKEN_DOT       258
   177.9 -#define TOKEN_STAR      259
  177.10 -#define TOKEN_ARROW     260
  177.11 -#define TOKEN_ADDR      261
  177.12 -#define TOKEN_SIZEOF    262
  177.13 -#define TOKEN_NUMBER    263
  177.14 -
  177.15 -
  177.16 -extern YYSTYPE yylval;
   178.1 --- a/src/sdl/expr.l	Sat Mar 03 10:54:39 2012 -0600
   178.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   178.3 @@ -1,71 +0,0 @@
   178.4 -%{
   178.5 -#include "expr.cpp.h"
   178.6 -
   178.7 -#ifndef __GNUC__
   178.8 -#include <io.h>
   178.9 -#define isatty _isatty
  178.10 -#endif
  178.11 -
  178.12 -char *exprString;
  178.13 -int exprCol;
  178.14 -
  178.15 -#define YY_INPUT(buf,result,max_size) \
  178.16 -    { \
  178.17 -    int c = *exprString++; \
  178.18 -    exprCol++;\
  178.19 -    result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \
  178.20 -    }
  178.21 -%}
  178.22 -
  178.23 -%option nomain
  178.24 -%option noyywrap
  178.25 -
  178.26 -SIZEOF "sizeof"
  178.27 -ID [a-zA-Z_][a-zA-Z0-9_]*
  178.28 -NUM [0-9]+
  178.29 -DOT "."
  178.30 -ARROW "->"
  178.31 -STAR "*"
  178.32 -ADDR "&"
  178.33 -
  178.34 -%%
  178.35 -
  178.36 -{SIZEOF} {
  178.37 -        return TOKEN_SIZEOF;
  178.38 -}
  178.39 -
  178.40 -{ID} {
  178.41 -        return TOKEN_IDENTIFIER;
  178.42 -}
  178.43 -
  178.44 -{NUM} {
  178.45 -        return TOKEN_NUMBER;
  178.46 -}
  178.47 -
  178.48 -{DOT} {
  178.49 -        return TOKEN_DOT;
  178.50 -}       
  178.51 -
  178.52 -{ARROW} {
  178.53 -        return TOKEN_ARROW;
  178.54 -}
  178.55 -
  178.56 -{ADDR} {
  178.57 -        return TOKEN_ADDR;
  178.58 -}
  178.59 -
  178.60 -{STAR} {
  178.61 -        return TOKEN_STAR;
  178.62 -}
  178.63 -
  178.64 -[ \t\n]+
  178.65 -
  178.66 -. return *yytext;
  178.67 -
  178.68 -%%
  178.69 -
  178.70 -void exprCleanBuffer()
  178.71 -{
  178.72 -  yy_delete_buffer(yy_current_buffer);
  178.73 -  yy_init = 1;
  178.74 -}
   179.1 --- a/src/sdl/expr.y	Sat Mar 03 10:54:39 2012 -0600
   179.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   179.3 @@ -1,77 +0,0 @@
   179.4 -%{
   179.5 -namespace std {  
   179.6 -#include <stdio.h>
   179.7 -#include <memory.h>
   179.8 -#include <stdlib.h>
   179.9 -#include <string.h>
  179.10 -}
  179.11 -
  179.12 -using namespace std;
  179.13 - 
  179.14 -#include "System.h"
  179.15 -#include "elf.h"
  179.16 -#include "exprNode.h" 
  179.17 -
  179.18 -extern int yyerror(char *);
  179.19 -extern int yylex(); 
  179.20 -extern char *yytext;
  179.21 -
  179.22 -  
  179.23 -//#define YYERROR_VERBOSE 1
  179.24 -//#define YYDEBUG 1
  179.25 -
  179.26 - Node *result = NULL;
  179.27 -%}
  179.28 -
  179.29 -%token TOKEN_IDENTIFIER TOKEN_DOT TOKEN_STAR TOKEN_ARROW TOKEN_ADDR
  179.30 -%token TOKEN_SIZEOF TOKEN_NUMBER
  179.31 -%left TOKEN_DOT TOKEN_ARROW '['
  179.32 -%expect 6
  179.33 -%%
  179.34 -
  179.35 -final: expression { result = $1; }
  179.36 -;
  179.37 -
  179.38 -expression:
  179.39 -  simple_expression { $$ = $1; } |
  179.40 -  '(' expression ')' { $$ = $2; } |
  179.41 -  expression TOKEN_DOT ident { $$ = exprNodeDot($1, $3); } |
  179.42 -  expression TOKEN_ARROW ident { $$ = exprNodeArrow($1, $3); } |
  179.43 -  expression '[' number ']' { $$ = exprNodeArray($1, $3); }
  179.44 -;
  179.45 -simple_expression:
  179.46 -  ident  { $$ = $1; } |
  179.47 -  TOKEN_STAR expression { $$ = exprNodeStar($2); } |
  179.48 -  TOKEN_ADDR expression { $$ = exprNodeAddr($2); } |
  179.49 -  TOKEN_SIZEOF '(' expression ')' { $$ = exprNodeSizeof($3); }
  179.50 -;
  179.51 -
  179.52 -number:
  179.53 -  TOKEN_NUMBER { $$ = exprNodeNumber(); }
  179.54 -;
  179.55 -
  179.56 -ident:
  179.57 -  TOKEN_IDENTIFIER {$$ = exprNodeIdentifier(); }
  179.58 -;
  179.59 -
  179.60 -%%
  179.61 -
  179.62 -int yyerror(char *s)
  179.63 -{
  179.64 -  return 0;
  179.65 -}
  179.66 -
  179.67 -#ifndef SDL
  179.68 -extern FILE *yyin;
  179.69 -int main(int argc, char **argv)
  179.70 -{
  179.71 -  //  yydebug = 1;
  179.72 -  ++argv, --argc;
  179.73 -  if(argc > 0)
  179.74 -    yyin = fopen(argv[0], "r");
  179.75 -  else
  179.76 -    yyin = stdin;
  179.77 -  if(!yyparse())
  179.78 -    result->print();
  179.79 -}
  179.80 -#endif
   180.1 --- a/src/sdl/exprNode.cpp	Sat Mar 03 10:54:39 2012 -0600
   180.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   180.3 @@ -1,411 +0,0 @@
   180.4 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   180.5 -// Copyright (C) 1999-2003 Forgotten
   180.6 -// Copyright (C) 2004 Forgotten and the VBA development team
   180.7 -
   180.8 -// This program is free software; you can redistribute it and/or modify
   180.9 -// it under the terms of the GNU General Public License as published by
  180.10 -// the Free Software Foundation; either version 2, or(at your option)
  180.11 -// any later version.
  180.12 -//
  180.13 -// This program is distributed in the hope that it will be useful,
  180.14 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  180.15 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  180.16 -// GNU General Public License for more details.
  180.17 -//
  180.18 -// You should have received a copy of the GNU General Public License
  180.19 -// along with this program; if not, write to the Free Software Foundation,
  180.20 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  180.21 -
  180.22 -#include <string.h>
  180.23 -#include <stdio.h>
  180.24 -#include <stdlib.h>
  180.25 -
  180.26 -#include "Port.h"
  180.27 -#include "gba/GBAGlobals.h"
  180.28 -#include "gba/elf.h"
  180.29 -#include "exprNode.h"
  180.30 -
  180.31 -extern char *yytext;
  180.32 -
  180.33 -#define debuggerReadMemory(addr) \
  180.34 -  READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
  180.35 -
  180.36 -void *exprNodeCleanUpList[100];
  180.37 -int exprNodeCleanUpCount = 0;
  180.38 -Type exprNodeType = { 0, TYPE_base, "int", DW_ATE_signed, 4, 0, {0}, 0 };
  180.39 -
  180.40 -void exprNodeClean(void *m)
  180.41 -{
  180.42 -  exprNodeCleanUpList[exprNodeCleanUpCount++] = m;
  180.43 -}
  180.44 -
  180.45 -void exprNodeCleanUp()
  180.46 -{
  180.47 -  for(int i = 0; i < exprNodeCleanUpCount; i++) {
  180.48 -    free(exprNodeCleanUpList[i]);
  180.49 -  }
  180.50 -  exprNodeCleanUpCount = 0;
  180.51 -}
  180.52 -
  180.53 -Node *exprNodeIdentifier()
  180.54 -{
  180.55 -  Node *n = (Node *)calloc(1, sizeof(Node));
  180.56 -  n->name = strdup(yytext);
  180.57 -
  180.58 -  exprNodeClean(n->name);  
  180.59 -  exprNodeClean(n);
  180.60 -  
  180.61 -  n->print = exprNodeIdentifierPrint;
  180.62 -  n->resolve = exprNodeIdentifierResolve;
  180.63 -  return n;
  180.64 -}
  180.65 -
  180.66 -bool exprNodeIdentifierResolve(Node *n, Function *f, CompileUnit *u)
  180.67 -{
  180.68 -  Object *o;
  180.69 -  if(elfGetObject(n->name, f, u, &o)) {
  180.70 -    n->type = o->type;
  180.71 -    n->location = elfDecodeLocation(f, o->location, &n->locType);
  180.72 -    return true;
  180.73 -  } else {
  180.74 -    printf("Object %s not found\n", n->name);
  180.75 -  }
  180.76 -  return false;
  180.77 -}
  180.78 -
  180.79 -void exprNodeIdentifierPrint(Node *n)
  180.80 -{
  180.81 -  printf("%s", n->name);
  180.82 -}
  180.83 -
  180.84 -Node *exprNodeNumber()
  180.85 -{
  180.86 -  Node *n = (Node *)calloc(1, sizeof(Node));
  180.87 -
  180.88 -  exprNodeClean(n);
  180.89 -  n->location = atoi(yytext);
  180.90 -  n->type = &exprNodeType;
  180.91 -  n->locType = LOCATION_value;  
  180.92 -  n->print = exprNodeNumberPrint;
  180.93 -  n->resolve = exprNodeNumberResolve;
  180.94 -  return n;
  180.95 -}
  180.96 -
  180.97 -bool exprNodeNumberResolve(Node *n, Function *f, CompileUnit *u)
  180.98 -{
  180.99 -  return true;
 180.100 -}
 180.101 -
 180.102 -void exprNodeNumberPrint(Node *n)
 180.103 -{
 180.104 -  printf("%d", n->location);
 180.105 -}
 180.106 -
 180.107 -Node *exprNodeStar(Node *exp)
 180.108 -{
 180.109 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.110 -  exprNodeClean(n);
 180.111 -  
 180.112 -  n->expression = exp;
 180.113 -  
 180.114 -  n->print = exprNodeStarPrint;
 180.115 -  n->resolve = exprNodeStarResolve;
 180.116 -  return n;
 180.117 -}
 180.118 -
 180.119 -bool exprNodeStarResolve(Node *n, Function *f, CompileUnit *u)
 180.120 -{
 180.121 -  if(n->expression->resolve(n->expression, f, u)) {
 180.122 -    if(n->expression->type->type == TYPE_pointer) {
 180.123 -      n->location = n->expression->location;
 180.124 -      if(n->expression->locType == LOCATION_memory) {
 180.125 -        n->location = debuggerReadMemory(n->location);
 180.126 -      } else if(n->expression->locType == LOCATION_register) {
 180.127 -        n->location = reg[n->expression->location].I;
 180.128 -      } else {
 180.129 -        n->location = n->expression->location;
 180.130 -      }
 180.131 -      n->type = n->expression->type->pointer;
 180.132 -      n->locType = LOCATION_memory;
 180.133 -      return true;
 180.134 -    } else {
 180.135 -      printf("Object is not of pointer type\n");
 180.136 -    }
 180.137 -  }
 180.138 -  return false;
 180.139 -}
 180.140 -
 180.141 -void exprNodeStarPrint(Node *n)
 180.142 -{
 180.143 -  printf("*");
 180.144 -  n->expression->print(n->expression);
 180.145 -}
 180.146 -
 180.147 -Node *exprNodeDot(Node *exp, Node *ident)
 180.148 -{
 180.149 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.150 -  exprNodeClean(n);
 180.151 -  
 180.152 -  n->expression = exp;
 180.153 -  n->name = ident->name;
 180.154 -  
 180.155 -  n->print = exprNodeDotPrint;
 180.156 -  n->resolve = exprNodeDotResolve;
 180.157 -  return n;
 180.158 -}
 180.159 -
 180.160 -bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
 180.161 -{
 180.162 -  if(n->expression->resolve(n->expression, f, u)) {
 180.163 -    TypeEnum tt = n->expression->type->type;
 180.164 -    
 180.165 -    if(tt == TYPE_struct ||
 180.166 -       tt == TYPE_union) {
 180.167 -      u32 loc = n->expression->location;
 180.168 -      Type *t = n->expression->type;
 180.169 -      int count = t->structure->memberCount;
 180.170 -      int i = 0;
 180.171 -      while(i < count) {
 180.172 -        Member *m = &t->structure->members[i];
 180.173 -        if(strcmp(m->name, n->name) == 0) {
 180.174 -          // found member
 180.175 -          n->type = m->type;
 180.176 -          if(tt == TYPE_struct) {
 180.177 -            n->location = elfDecodeLocation(f, m->location, &n->locType,
 180.178 -                                            loc);
 180.179 -            n->objLocation = loc;
 180.180 -          } else {
 180.181 -            n->location = loc;
 180.182 -            n->locType = n->expression->locType;
 180.183 -            n->objLocation = loc;
 180.184 -          }
 180.185 -          n->member = m;
 180.186 -          return true;
 180.187 -        }
 180.188 -        i++;
 180.189 -      }
 180.190 -      printf("Member %s not found\n", n->name);
 180.191 -    } else {
 180.192 -      printf("Object is not of structure type\n");
 180.193 -    }
 180.194 -  }
 180.195 -  return false;
 180.196 -}
 180.197 -
 180.198 -void exprNodeDotPrint(Node *n)
 180.199 -{
 180.200 -  n->expression->print(n->expression);
 180.201 -  printf(".%s", n->name);
 180.202 -}
 180.203 -
 180.204 -Node *exprNodeArrow(Node *exp, Node *ident)
 180.205 -{
 180.206 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.207 -  exprNodeClean(n);
 180.208 -  
 180.209 -  n->expression = exp;
 180.210 -  n->name = ident->name;
 180.211 -  
 180.212 -  n->print = exprNodeArrowPrint;
 180.213 -  n->resolve = exprNodeArrowResolve;
 180.214 -  return n;
 180.215 -}
 180.216 -
 180.217 -bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
 180.218 -{
 180.219 -  if(n->expression->resolve(n->expression, f, u)) {
 180.220 -    TypeEnum tt = n->expression->type->type;
 180.221 -    if(tt != TYPE_pointer) {
 180.222 -      printf("Object not of pointer type\n");
 180.223 -      return false;
 180.224 -    }
 180.225 -    tt = n->expression->type->pointer->type;
 180.226 -    
 180.227 -    if(tt == TYPE_struct ||
 180.228 -       tt == TYPE_union) {
 180.229 -      u32 loc = debuggerReadMemory(n->expression->location);
 180.230 -      Type *t = n->expression->type->pointer;
 180.231 -      int count = t->structure->memberCount;
 180.232 -      int i = 0;
 180.233 -      while(i < count) {
 180.234 -        Member *m = &t->structure->members[i];
 180.235 -        if(strcmp(m->name, n->name) == 0) {
 180.236 -          // found member
 180.237 -          n->type = m->type;
 180.238 -          if(tt == TYPE_struct) {
 180.239 -            n->location = elfDecodeLocation(f, m->location, &n->locType,
 180.240 -                                            loc);
 180.241 -            n->objLocation = loc;
 180.242 -          } else {
 180.243 -            n->location = loc;
 180.244 -            n->objLocation = loc;
 180.245 -          }
 180.246 -          n->locType = LOCATION_memory;
 180.247 -          n->member = m;
 180.248 -          return true;
 180.249 -        }
 180.250 -        i++;
 180.251 -      }
 180.252 -      printf("Member %s not found\n", n->name);
 180.253 -    } else {
 180.254 -      printf("Object is not of structure type\n");
 180.255 -    }
 180.256 -  }
 180.257 -  return false;
 180.258 -}
 180.259 -
 180.260 -void exprNodeArrowPrint(Node *n)
 180.261 -{
 180.262 -  n->expression->print(n->expression);
 180.263 -  printf("->%s", n->name);
 180.264 -}
 180.265 -
 180.266 -Node *exprNodeAddr(Node *exp)
 180.267 -{
 180.268 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.269 -  exprNodeClean(n);
 180.270 -  
 180.271 -  n->expression = exp;
 180.272 -  
 180.273 -  n->print = exprNodeAddrPrint;
 180.274 -  n->resolve = exprNodeAddrResolve;
 180.275 -  return n;
 180.276 -}
 180.277 -
 180.278 -bool exprNodeAddrResolve(Node *n, Function *f, CompileUnit *u)
 180.279 -{
 180.280 -  if(n->expression->resolve(n->expression, f, u)) {
 180.281 -    if(n->expression->locType == LOCATION_memory) {
 180.282 -      n->location = n->expression->location;
 180.283 -      n->locType = LOCATION_value;
 180.284 -      n->type = &exprNodeType;
 180.285 -    } else if(n->expression->locType == LOCATION_register) {
 180.286 -      printf("Value is in register %d\n", n->expression->location);
 180.287 -    } else {
 180.288 -      printf("Direct value is %d\n", n->location);
 180.289 -    }
 180.290 -    return true;
 180.291 -  }
 180.292 -  return false;
 180.293 -}
 180.294 -
 180.295 -void exprNodeAddrPrint(Node *n)
 180.296 -{
 180.297 -  printf("*");
 180.298 -  n->expression->print(n->expression);
 180.299 -}
 180.300 -
 180.301 -Node *exprNodeSizeof(Node *exp)
 180.302 -{
 180.303 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.304 -  exprNodeClean(n);
 180.305 -  
 180.306 -  n->expression = exp;
 180.307 -  
 180.308 -  n->print = exprNodeSizeofPrint;
 180.309 -  n->resolve = exprNodeSizeofResolve;
 180.310 -  return n;
 180.311 -}
 180.312 -
 180.313 -bool exprNodeSizeofResolve(Node *n, Function *f, CompileUnit *u)
 180.314 -{
 180.315 -  if(n->expression->resolve(n->expression, f, u)) {
 180.316 -    n->location = n->expression->type->size;
 180.317 -    n->locType = LOCATION_value;
 180.318 -    n->type = &exprNodeType;
 180.319 -    return true;
 180.320 -  }
 180.321 -  return false;
 180.322 -}
 180.323 -
 180.324 -void exprNodeSizeofPrint(Node *n)
 180.325 -{
 180.326 -  printf("sizeof(");
 180.327 -  n->expression->print(n->expression);
 180.328 -  printf(")");
 180.329 -}
 180.330 -
 180.331 -Node *exprNodeArray(Node *exp, Node *number)
 180.332 -{
 180.333 -  Node *n = (Node *)calloc(1, sizeof(Node));
 180.334 -  exprNodeClean(n);
 180.335 -  
 180.336 -  n->expression = exp;
 180.337 -  n->value = number->location;
 180.338 -  
 180.339 -  n->print = exprNodeArrayPrint;
 180.340 -  n->resolve = exprNodeArrayResolve;
 180.341 -  return n;
 180.342 -}
 180.343 -
 180.344 -int exprNodeGetSize(Array *a, int index)
 180.345 -{
 180.346 -  index++;
 180.347 -  if(index == a->maxBounds) {
 180.348 -    return a->type->size;
 180.349 -  } else {
 180.350 -    int size = a->bounds[a->maxBounds-1] * a->type->size;
 180.351 -    
 180.352 -    for(int i = index; i < a->maxBounds-1; i++) {
 180.353 -      size *= a->bounds[i];
 180.354 -    }
 180.355 -    return size;
 180.356 -  }
 180.357 -}
 180.358 -
 180.359 -bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
 180.360 -{
 180.361 -  if(n->expression->resolve(n->expression, f, u)) {
 180.362 -    TypeEnum tt = n->expression->type->type;
 180.363 -    if(tt != TYPE_array &&
 180.364 -       tt != TYPE_pointer) {
 180.365 -      printf("Object not of array or pointer type\n");
 180.366 -      return false;
 180.367 -    }
 180.368 -
 180.369 -    if(tt == TYPE_array) {
 180.370 -      Array *a = n->expression->type->array;
 180.371 -      
 180.372 -      u32 loc = n->expression->location;
 180.373 -      Type *t = a->type;
 180.374 -      if(a->maxBounds > 1) {
 180.375 -        int index = n->expression->index;
 180.376 -
 180.377 -        if(index == a->maxBounds) {
 180.378 -          printf("Too many indices for array\n");
 180.379 -          return false;
 180.380 -        }
 180.381 -
 180.382 -        if((index+1) < a->maxBounds) {
 180.383 -          n->type = n->expression->type;
 180.384 -          n->index = index+1;
 180.385 -          n->locType = LOCATION_memory;
 180.386 -          n->location = n->expression->location +
 180.387 -            n->value * exprNodeGetSize(a, index);
 180.388 -          return true;
 180.389 -        }
 180.390 -      }
 180.391 -      n->type = t;
 180.392 -      n->location = loc + n->value * t->size;
 180.393 -      n->locType = LOCATION_memory;
 180.394 -    } else {
 180.395 -      Type *t = n->expression->type->pointer;
 180.396 -      u32 loc = n->expression->location;
 180.397 -      if(n->expression->locType == LOCATION_register)
 180.398 -        loc = reg[loc].I;
 180.399 -      else
 180.400 -        loc = debuggerReadMemory(loc);
 180.401 -      n->type = t;
 180.402 -      n->location = loc + n->value * t->size;
 180.403 -      n->locType = LOCATION_memory;
 180.404 -    }
 180.405 -    return true;
 180.406 -  }
 180.407 -  return false;
 180.408 -}
 180.409 -
 180.410 -void exprNodeArrayPrint(Node *n)
 180.411 -{
 180.412 -  n->expression->print(n->expression);
 180.413 -  printf("[%d]", n->value);
 180.414 -}
   181.1 --- a/src/sdl/exprNode.h	Sat Mar 03 10:54:39 2012 -0600
   181.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   181.3 @@ -1,68 +0,0 @@
   181.4 -// -*- C++ -*-
   181.5 -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
   181.6 -// Copyright (C) 1999-2003 Forgotten
   181.7 -// Copyright (C) 2004 Forgotten and the VBA development team
   181.8 -
   181.9 -// This program is free software; you can redistribute it and/or modify
  181.10 -// it under the terms of the GNU General Public License as published by
  181.11 -// the Free Software Foundation; either version 2, or(at your option)
  181.12 -// any later version.
  181.13 -//
  181.14 -// This program is distributed in the hope that it will be useful,
  181.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  181.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  181.17 -// GNU General Public License for more details.
  181.18 -//
  181.19 -// You should have received a copy of the GNU General Public License
  181.20 -// along with this program; if not, write to the Free Software Foundation,
  181.21 -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  181.22 -
  181.23 -struct Node {
  181.24 -  Type *type;
  181.25 -  u32 location;
  181.26 -  u32 objLocation;
  181.27 -  LocationType locType;
  181.28 -  int value;
  181.29 -  int index;
  181.30 -  char *name;
  181.31 -  Node *expression;
  181.32 -  Member *member;
  181.33 -  void (*print)(Node *);
  181.34 -  bool (*resolve)(Node *, Function *f, CompileUnit *u);
  181.35 -};
  181.36 -
  181.37 -extern void exprNodeCleanUp();
  181.38 -
  181.39 -extern Node *exprNodeIdentifier();
  181.40 -extern void exprNodeIdentifierPrint(Node *);
  181.41 -extern bool exprNodeIdentifierResolve(Node *, Function *, CompileUnit *);
  181.42 -
  181.43 -extern Node *exprNodeNumber();
  181.44 -extern void exprNodeNumberPrint(Node *);
  181.45 -extern bool exprNodeNumberResolve(Node *, Function *, CompileUnit *);
  181.46 -
  181.47 -extern Node *exprNodeStar(Node *);
  181.48 -extern void exprNodeStarPrint(Node *);
  181.49 -extern bool exprNodeStarResolve(Node *, Function *, CompileUnit *);
  181.50 -
  181.51 -extern Node *exprNodeDot(Node *, Node *);
  181.52 -extern void exprNodeDotPrint(Node *);
  181.53 -extern bool exprNodeDotResolve(Node *, Function *, CompileUnit *);
  181.54 -
  181.55 -extern Node *exprNodeArrow(Node *, Node *);
  181.56 -extern void exprNodeArrowPrint(Node *);
  181.57 -extern bool exprNodeArrowResolve(Node *, Function *, CompileUnit *);
  181.58 -
  181.59 -extern Node *exprNodeAddr(Node *);
  181.60 -extern void exprNodeAddrPrint(Node *);
  181.61 -extern bool exprNodeAddrResolve(Node *, Function *, CompileUnit *);
  181.62 -
  181.63 -extern Node *exprNodeSizeof(Node *);
  181.64 -extern void exprNodeSizeofPrint(Node *);
  181.65 -extern bool exprNodeSizeofResolve(Node *, Function *, CompileUnit *);
  181.66 -
  181.67 -extern Node *exprNodeArray(Node *, Node *);
  181.68 -extern void exprNodeArrayPrint(Node *);
  181.69 -extern bool exprNodeArrayResolve(Node *, Function *, CompileUnit *);
  181.70 -
  181.71 -#define YYSTYPE struct Node *
   182.1 --- a/src/sdl/getopt.c	Sat Mar 03 10:54:39 2012 -0600
   182.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   182.3 @@ -1,1060 +0,0 @@
   182.4 -/* Getopt for GNU.
   182.5 -   NOTE: getopt is now part of the C library, so if you don't know what
   182.6 -   "Keep this file name-space clean" means, talk to drepper@gnu.org
   182.7 -   before changing it!
   182.8 -
   182.9 -   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
  182.10 -   	Free Software Foundation, Inc.
  182.11 -
  182.12 -   NOTE: This source is derived from an old version taken from the GNU C
  182.13 -   Library (glibc).
  182.14 -
  182.15 -   This program is free software; you can redistribute it and/or modify it
  182.16 -   under the terms of the GNU General Public License as published by the
  182.17 -   Free Software Foundation; either version 2, or (at your option) any
  182.18 -   later version.
  182.19 -
  182.20 -   This program is distributed in the hope that it will be useful,
  182.21 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
  182.22 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  182.23 -   GNU General Public License for more details.
  182.24 -
  182.25 -   You should have received a copy of the GNU General Public License
  182.26 -   along with this program; if not, write to the Free Software
  182.27 -   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  182.28 -   USA.  */
  182.29 -
  182.30 -/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
  182.31 -   Ditto for AIX 3.2 and <stdlib.h>.  */
  182.32 -#ifndef _NO_PROTO
  182.33 -# define _NO_PROTO
  182.34 -#endif
  182.35 -
  182.36 -#ifdef HAVE_CONFIG_H
  182.37 -# include <config.h>
  182.38 -#endif
  182.39 -
  182.40 -#if !defined __STDC__ || !__STDC__
  182.41 -/* This is a separate conditional since some stdc systems
  182.42 -   reject `defined (const)'.  */
  182.43 -# ifndef const
  182.44 -#  define const
  182.45 -# endif
  182.46 -#endif
  182.47 -
  182.48 -#include <stdio.h>
  182.49 -
  182.50 -/* Comment out all this code if we are using the GNU C Library, and are not
  182.51 -   actually compiling the library itself.  This code is part of the GNU C
  182.52 -   Library, but also included in many other GNU distributions.  Compiling
  182.53 -   and linking in this code is a waste when using the GNU C library
  182.54 -   (especially if it is a shared library).  Rather than having every GNU
  182.55 -   program understand `configure --with-gnu-libc' and omit the object files,
  182.56 -   it is simpler to just do this in the source for each such file.  */
  182.57 -
  182.58 -#define GETOPT_INTERFACE_VERSION 2
  182.59 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
  182.60 -# include <gnu-versions.h>
  182.61 -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
  182.62 -#  define ELIDE_CODE
  182.63 -# endif
  182.64 -#endif
  182.65 -
  182.66 -#ifndef ELIDE_CODE
  182.67 -
  182.68 -
  182.69 -/* This needs to come after some library #include
  182.70 -   to get __GNU_LIBRARY__ defined.  */
  182.71 -#ifdef	__GNU_LIBRARY__
  182.72 -/* Don't include stdlib.h for non-GNU C libraries because some of them
  182.73 -   contain conflicting prototypes for getopt.  */
  182.74 -# include <stdlib.h>
  182.75 -# include <unistd.h>
  182.76 -#endif	/* GNU C library.  */
  182.77 -
  182.78 -#ifdef VMS
  182.79 -# include <unixlib.h>
  182.80 -# if HAVE_STRING_H - 0
  182.81 -#  include <string.h>
  182.82 -# endif
  182.83 -#endif
  182.84 -
  182.85 -#ifndef _
  182.86 -/* This is for other GNU distributions with internationalized messages.
  182.87 -   When compiling libc, the _ macro is predefined.  */
  182.88 -# ifdef HAVE_LIBINTL_H
  182.89 -#  include <libintl.h>
  182.90 -#  define _(msgid)	gettext (msgid)
  182.91 -# else
  182.92 -#  define _(msgid)	(msgid)
  182.93 -# endif
  182.94 -#endif
  182.95 -
  182.96 -#ifdef _MSC_VER
  182.97 -#include <string.h>
  182.98 -#endif
  182.99 -
 182.100 -/* This version of `getopt' appears to the caller like standard Unix `getopt'
 182.101 -   but it behaves differently for the user, since it allows the user
 182.102 -   to intersperse the options with the other arguments.
 182.103 -
 182.104 -   As `getopt' works, it permutes the elements of ARGV so that,
 182.105 -   when it is done, all the options precede everything else.  Thus
 182.106 -   all application programs are extended to handle flexible argument order.
 182.107 -
 182.108 -   Setting the environment variable POSIXLY_CORRECT disables permutation.
 182.109 -   Then the behavior is completely standard.
 182.110 -
 182.111 -   GNU application programs can use a third alternative mode in which
 182.112 -   they can distinguish the relative order of options and other arguments.  */
 182.113 -
 182.114 -#include "getopt.h"
 182.115 -
 182.116 -/* For communication from `getopt' to the caller.
 182.117 -   When `getopt' finds an option that takes an argument,
 182.118 -   the argument value is returned here.
 182.119 -   Also, when `ordering' is RETURN_IN_ORDER,
 182.120 -   each non-option ARGV-element is returned here.  */
 182.121 -
 182.122 -char *optarg = NULL;
 182.123 -
 182.124 -/* Index in ARGV of the next element to be scanned.
 182.125 -   This is used for communication to and from the caller
 182.126 -   and for communication between successive calls to `getopt'.
 182.127 -
 182.128 -   On entry to `getopt', zero means this is the first call; initialize.
 182.129 -
 182.130 -   When `getopt' returns -1, this is the index of the first of the
 182.131 -   non-option elements that the caller should itself scan.
 182.132 -
 182.133 -   Otherwise, `optind' communicates from one call to the next
 182.134 -   how much of ARGV has been scanned so far.  */
 182.135 -
 182.136 -/* 1003.2 says this must be 1 before any call.  */
 182.137 -int optind = 1;
 182.138 -
 182.139 -/* Formerly, initialization of getopt depended on optind==0, which
 182.140 -   causes problems with re-calling getopt as programs generally don't
 182.141 -   know that. */
 182.142 -
 182.143 -int __getopt_initialized = 0;
 182.144 -
 182.145 -/* The next char to be scanned in the option-element
 182.146 -   in which the last option character we returned was found.
 182.147 -   This allows us to pick up the scan where we left off.
 182.148 -
 182.149 -   If this is zero, or a null string, it means resume the scan
 182.150 -   by advancing to the next ARGV-element.  */
 182.151 -
 182.152 -static char *nextchar;
 182.153 -
 182.154 -/* Callers store zero here to inhibit the error message
 182.155 -   for unrecognized options.  */
 182.156 -
 182.157 -int opterr = 1;
 182.158 -
 182.159 -/* Set to an option character which was unrecognized.
 182.160 -   This must be initialized on some systems to avoid linking in the
 182.161 -   system's own getopt implementation.  */
 182.162 -
 182.163 -int optopt = '?';
 182.164 -
 182.165 -/* Describe how to deal with options that follow non-option ARGV-elements.
 182.166 -
 182.167 -   If the caller did not specify anything,
 182.168 -   the default is REQUIRE_ORDER if the environment variable
 182.169 -   POSIXLY_CORRECT is defined, PERMUTE otherwise.
 182.170 -
 182.171 -   REQUIRE_ORDER means don't recognize them as options;
 182.172 -   stop option processing when the first non-option is seen.
 182.173 -   This is what Unix does.
 182.174 -   This mode of operation is selected by either setting the environment
 182.175 -   variable POSIXLY_CORRECT, or using `+' as the first character
 182.176 -   of the list of option characters.
 182.177 -
 182.178 -   PERMUTE is the default.  We permute the contents of ARGV as we scan,
 182.179 -   so that eventually all the non-options are at the end.  This allows options
 182.180 -   to be given in any order, even with programs that were not written to
 182.181 -   expect this.
 182.182 -
 182.183 -   RETURN_IN_ORDER is an option available to programs that were written
 182.184 -   to expect options and other ARGV-elements in any order and that care about
 182.185 -   the ordering of the two.  We describe each non-option ARGV-element
 182.186 -   as if it were the argument of an option with character code 1.
 182.187 -   Using `-' as the first character of the list of option characters
 182.188 -   selects this mode of operation.
 182.189 -
 182.190 -   The special argument `--' forces an end of option-scanning regardless
 182.191 -   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
 182.192 -   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
 182.193 -
 182.194 -static enum
 182.195 -{
 182.196 -  REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
 182.197 -} ordering;
 182.198 -
 182.199 -/* Value of POSIXLY_CORRECT environment variable.  */
 182.200 -static char *posixly_correct;
 182.201 -
 182.202 -#ifdef	__GNU_LIBRARY__
 182.203 -/* We want to avoid inclusion of string.h with non-GNU libraries
 182.204 -   because there are many ways it can cause trouble.
 182.205 -   On some systems, it contains special magic macros that don't work
 182.206 -   in GCC.  */
 182.207 -# include <string.h>
 182.208 -# define my_index	strchr
 182.209 -#else
 182.210 -
 182.211 -# if HAVE_STRING_H
 182.212 -#  include <string.h>
 182.213 -# else
 182.214 -#  if HAVE_STRINGS_H
 182.215 -#   include <strings.h>
 182.216 -#  endif
 182.217 -# endif
 182.218 -
 182.219 -/* Avoid depending on library functions or files
 182.220 -   whose names are inconsistent.  */
 182.221 -
 182.222 -#ifndef getenv
 182.223 -extern char *getenv ();
 182.224 -#endif
 182.225 -
 182.226 -static char *
 182.227 -my_index (str, chr)
 182.228 -     const char *str;
 182.229 -     int chr;
 182.230 -{
 182.231 -  while (*str)
 182.232 -    {
 182.233 -      if (*str == chr)
 182.234 -	return (char *) str;
 182.235 -      str++;
 182.236 -    }
 182.237 -  return 0;
 182.238 -}
 182.239 -
 182.240 -/* If using GCC, we can safely declare strlen this way.
 182.241 -   If not using GCC, it is ok not to declare it.  */
 182.242 -#ifdef __GNUC__
 182.243 -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
 182.244 -   That was relevant to code that was here before.  */
 182.245 -# if (!defined __STDC__ || !__STDC__) && !defined strlen
 182.246 -/* gcc with -traditional declares the built-in strlen to return int,
 182.247 -   and has done so at least since version 2.4.5. -- rms.  */
 182.248 -extern int strlen (const char *);
 182.249 -# endif /* not __STDC__ */
 182.250 -#endif /* __GNUC__ */
 182.251 -
 182.252 -#endif /* not __GNU_LIBRARY__ */
 182.253 -
 182.254 -/* Handle permutation of arguments.  */
 182.255 -
 182.256 -/* Describe the part of ARGV that contains non-options that have
 182.257 -   been skipped.  `first_nonopt' is the index in ARGV of the first of them;
 182.258 -   `last_nonopt' is the index after the last of them.  */
 182.259 -
 182.260 -static int first_nonopt;
 182.261 -static int last_nonopt;
 182.262 -
 182.263 -#ifdef _LIBC
 182.264 -/* Bash 2.0 gives us an environment variable containing flags
 182.265 -   indicating ARGV elements that should not be considered arguments.  */
 182.266 -
 182.267 -/* Defined in getopt_init.c  */
 182.268 -extern char *__getopt_nonoption_flags;
 182.269 -
 182.270 -static int nonoption_flags_max_len;
 182.271 -static int nonoption_flags_len;
 182.272 -
 182.273 -static int original_argc;
 182.274 -static char *const *original_argv;
 182.275 -
 182.276 -/* Make sure the environment variable bash 2.0 puts in the environment
 182.277 -   is valid for the getopt call we must make sure that the ARGV passed
 182.278 -   to getopt is that one passed to the process.  */
 182.279 -static void
 182.280 -__attribute__ ((unused))
 182.281 -store_args_and_env (int argc, char *const *argv)
 182.282 -{
 182.283 -  /* XXX This is no good solution.  We should rather copy the args so
 182.284 -     that we can compare them later.  But we must not use malloc(3).  */
 182.285 -  original_argc = argc;
 182.286 -  original_argv = argv;
 182.287 -}
 182.288 -# ifdef text_set_element
 182.289 -text_set_element (__libc_subinit, store_args_and_env);
 182.290 -# endif /* text_set_element */
 182.291 -
 182.292 -# define SWAP_FLAGS(ch1, ch2) \
 182.293 -  if (nonoption_flags_len > 0)						      \
 182.294 -    {									      \
 182.295 -      char __tmp = __getopt_nonoption_flags[ch1];			      \
 182.296 -      __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];	      \
 182.297 -      __getopt_nonoption_flags[ch2] = __tmp;				      \
 182.298 -    }
 182.299 -#else	/* !_LIBC */
 182.300 -# define SWAP_FLAGS(ch1, ch2)
 182.301 -#endif	/* _LIBC */
 182.302 -
 182.303 -/* Exchange two adjacent subsequences of ARGV.
 182.304 -   One subsequence is elements [first_nonopt,last_nonopt)
 182.305 -   which contains all the non-options that have been skipped so far.
 182.306 -   The other is elements [last_nonopt,optind), which contains all
 182.307 -   the options processed since those non-options were skipped.
 182.308 -
 182.309 -   `first_nonopt' and `last_nonopt' are relocated so that they describe
 182.310 -   the new indices of the non-options in ARGV after they are moved.  */
 182.311 -
 182.312 -#if defined __STDC__ && __STDC__
 182.313 -static void exchange (char **);
 182.314 -#endif
 182.315 -
 182.316 -static void
 182.317 -exchange (argv)
 182.318 -     char **argv;
 182.319 -{
 182.320 -  int bottom = first_nonopt;
 182.321 -  int middle = last_nonopt;
 182.322 -  int top = optind;
 182.323 -  char *tem;
 182.324 -
 182.325 -  /* Exchange the shorter segment with the far end of the longer segment.
 182.326 -     That puts the shorter segment into the right place.
 182.327 -     It leaves the longer segment in the right place overall,
 182.328 -     but it consists of two parts that need to be swapped next.  */
 182.329 -
 182.330 -#ifdef _LIBC
 182.331 -  /* First make sure the handling of the `__getopt_nonoption_flags'
 182.332 -     string can work normally.  Our top argument must be in the range
 182.333 -     of the string.  */
 182.334 -  if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
 182.335 -    {
 182.336 -      /* We must extend the array.  The user plays games with us and
 182.337 -	 presents new arguments.  */
 182.338 -      char *new_str = malloc (top + 1);
 182.339 -      if (new_str == NULL)
 182.340 -	nonoption_flags_len = nonoption_flags_max_len = 0;
 182.341 -      else
 182.342 -	{
 182.343 -	  memset (__mempcpy (new_str, __getopt_nonoption_flags,
 182.344 -			     nonoption_flags_max_len),
 182.345 -		  '\0', top + 1 - nonoption_flags_max_len);
 182.346 -	  nonoption_flags_max_len = top + 1;
 182.347 -	  __getopt_nonoption_flags = new_str;
 182.348 -	}
 182.349 -    }
 182.350 -#endif
 182.351 -
 182.352 -  while (top > middle && middle > bottom)
 182.353 -    {
 182.354 -      if (top - middle > middle - bottom)
 182.355 -	{
 182.356 -	  /* Bottom segment is the short one.  */
 182.357 -	  int len = middle - bottom;
 182.358 -	  register int i;
 182.359 -
 182.360 -	  /* Swap it with the top part of the top segment.  */
 182.361 -	  for (i = 0; i < len; i++)
 182.362 -	    {
 182.363 -	      tem = argv[bottom + i];
 182.364 -	      argv[bottom + i] = argv[top - (middle - bottom) + i];
 182.365 -	      argv[top - (middle - bottom) + i] = tem;
 182.366 -	      SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
 182.367 -	    }
 182.368 -	  /* Exclude the moved bottom segment from further swapping.  */
 182.369 -	  top -= len;
 182.370 -	}
 182.371 -      else
 182.372 -	{
 182.373 -	  /* Top segment is the short one.  */
 182.374 -	  int len = top - middle;
 182.375 -	  register int i;
 182.376 -
 182.377 -	  /* Swap it with the bottom part of the bottom segment.  */
 182.378 -	  for (i = 0; i < len; i++)
 182.379 -	    {
 182.380 -	      tem = argv[bottom + i];
 182.381 -	      argv[bottom + i] = argv[middle + i];
 182.382 -	      argv[middle + i] = tem;
 182.383 -	      SWAP_FLAGS (bottom + i, middle + i);
 182.384 -	    }
 182.385 -	  /* Exclude the moved top segment from further swapping.  */
 182.386 -	  bottom += len;
 182.387 -	}
 182.388 -    }
 182.389 -
 182.390 -  /* Update records for the slots the non-options now occupy.  */
 182.391 -
 182.392 -  first_nonopt += (optind - last_nonopt);
 182.393 -  last_nonopt = optind;
 182.394 -}
 182.395 -
 182.396 -/* Initialize the internal data when the first call is made.  */
 182.397 -
 182.398 -#if defined __STDC__ && __STDC__
 182.399 -static const char *_getopt_initialize (int, char *const *, const char *);
 182.400 -#endif
 182.401 -static const char *
 182.402 -_getopt_initialize (argc, argv, optstring)
 182.403 -     int argc;
 182.404 -     char *const *argv;
 182.405 -     const char *optstring;
 182.406 -{
 182.407 -  /* Start processing options with ARGV-element 1 (since ARGV-element 0
 182.408 -     is the program name); the sequence of previously skipped
 182.409 -     non-option ARGV-elements is empty.  */
 182.410 -
 182.411 -  first_nonopt = last_nonopt = optind;
 182.412 -
 182.413 -  nextchar = NULL;
 182.414 -
 182.415 -  posixly_correct = getenv ("POSIXLY_CORRECT");
 182.416 -
 182.417 -  /* Determine how to handle the ordering of options and nonoptions.  */
 182.418 -
 182.419 -  if (optstring[0] == '-')
 182.420 -    {
 182.421 -      ordering = RETURN_IN_ORDER;
 182.422 -      ++optstring;
 182.423 -    }
 182.424 -  else if (optstring[0] == '+')
 182.425 -    {
 182.426 -      ordering = REQUIRE_ORDER;
 182.427 -      ++optstring;
 182.428 -    }
 182.429 -  else if (posixly_correct != NULL)
 182.430 -    ordering = REQUIRE_ORDER;
 182.431 -  else
 182.432 -    ordering = PERMUTE;
 182.433 -
 182.434 -#ifdef _LIBC
 182.435 -  if (posixly_correct == NULL
 182.436 -      && argc == original_argc && argv == original_argv)
 182.437 -    {
 182.438 -      if (nonoption_flags_max_len == 0)
 182.439 -	{
 182.440 -	  if (__getopt_nonoption_flags == NULL
 182.441 -	      || __getopt_nonoption_flags[0] == '\0')
 182.442 -	    nonoption_flags_max_len = -1;
 182.443 -	  else
 182.444 -	    {
 182.445 -	      const char *orig_str = __getopt_nonoption_flags;
 182.446 -	      int len = nonoption_flags_max_len = strlen (orig_str);
 182.447 -	      if (nonoption_flags_max_len < argc)
 182.448 -		nonoption_flags_max_len = argc;
 182.449 -	      __getopt_nonoption_flags =
 182.450 -		(char *) malloc (nonoption_flags_max_len);
 182.451 -	      if (__getopt_nonoption_flags == NULL)
 182.452 -		nonoption_flags_max_len = -1;
 182.453 -	      else
 182.454 -		memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
 182.455 -			'\0', nonoption_flags_max_len - len);
 182.456 -	    }
 182.457 -	}
 182.458 -      nonoption_flags_len = nonoption_flags_max_len;
 182.459 -    }
 182.460 -  else
 182.461 -    nonoption_flags_len = 0;
 182.462 -#endif
 182.463 -
 182.464 -  return optstring;
 182.465 -}
 182.466 -
 182.467 -/* Scan elements of ARGV (whose length is ARGC) for option characters
 182.468 -   given in OPTSTRING.
 182.469 -
 182.470 -   If an element of ARGV starts with '-', and is not exactly "-" or "--",
 182.471 -   then it is an option element.  The characters of this element
 182.472 -   (aside from the initial '-') are option characters.  If `getopt'
 182.473 -   is called repeatedly, it returns successively each of the option characters
 182.474 -   from each of the option elements.
 182.475 -
 182.476 -   If `getopt' finds another option character, it returns that character,
 182.477 -   updating `optind' and `nextchar' so that the next call to `getopt' can
 182.478 -   resume the scan with the following option character or ARGV-element.
 182.479 -
 182.480 -   If there are no more option characters, `getopt' returns -1.
 182.481 -   Then `optind' is the index in ARGV of the first ARGV-element
 182.482 -   that is not an option.  (The ARGV-elements have been permuted
 182.483 -   so that those that are not options now come last.)
 182.484 -
 182.485 -   OPTSTRING is a string containing the legitimate option characters.
 182.486 -   If an option character is seen that is not listed in OPTSTRING,
 182.487 -   return '?' after printing an error message.  If you set `opterr' to
 182.488 -   zero, the error message is suppressed but we still return '?'.
 182.489 -
 182.490 -   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
 182.491 -   so the following text in the same ARGV-element, or the text of the following
 182.492 -   ARGV-element, is returned in `optarg'.  Two colons mean an option that
 182.493 -   wants an optional arg; if there is text in the current ARGV-element,
 182.494 -   it is returned in `optarg', otherwise `optarg' is set to zero.
 182.495 -
 182.496 -   If OPTSTRING starts with `-' or `+', it requests different methods of
 182.497 -   handling the non-option ARGV-elements.
 182.498 -   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
 182.499 -
 182.500 -   Long-named options begin with `--' instead of `-'.
 182.501 -   Their names may be abbreviated as long as the abbreviation is unique
 182.502 -   or is an exact match for some defined option.  If they have an
 182.503 -   argument, it follows the option name in the same ARGV-element, separated
 182.504 -   from the option name by a `=', or else the in next ARGV-element.
 182.505 -   When `getopt' finds a long-named option, it returns 0 if that option's
 182.506 -   `flag' field is nonzero, the value of the option's `val' field
 182.507 -   if the `flag' field is zero.
 182.508 -
 182.509 -   The elements of ARGV aren't really const, because we permute them.
 182.510 -   But we pretend they're const in the prototype to be compatible
 182.511 -   with other systems.
 182.512 -
 182.513 -   LONGOPTS is a vector of `struct option' terminated by an
 182.514 -   element containing a name which is zero.
 182.515 -
 182.516 -   LONGIND returns the index in LONGOPT of the long-named option found.
 182.517 -   It is only valid when a long-named option has been found by the most
 182.518 -   recent call.
 182.519 -
 182.520 -   If LONG_ONLY is nonzero, '-' as well as '--' can introduce
 182.521 -   long-named options.  */
 182.522 -
 182.523 -int
 182.524 -_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
 182.525 -     int argc;
 182.526 -     char *const *argv;
 182.527 -     const char *optstring;
 182.528 -     const struct option *longopts;
 182.529 -     int *longind;
 182.530 -     int long_only;
 182.531 -{
 182.532 -  optarg = NULL;
 182.533 -
 182.534 -  if (optind == 0 || !__getopt_initialized)
 182.535 -    {
 182.536 -      if (optind == 0)
 182.537 -	optind = 1;	/* Don't scan ARGV[0], the program name.  */
 182.538 -      optstring = _getopt_initialize (argc, argv, optstring);
 182.539 -      __getopt_initialized = 1;
 182.540 -    }
 182.541 -
 182.542 -  /* Test whether ARGV[optind] points to a non-option argument.
 182.543 -     Either it does not have option syntax, or there is an environment flag
 182.544 -     from the shell indicating it is not an option.  The later information
 182.545 -     is only used when the used in the GNU libc.  */
 182.546 -#ifdef _LIBC
 182.547 -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
 182.548 -		      || (optind < nonoption_flags_len			      \
 182.549 -			  && __getopt_nonoption_flags[optind] == '1'))
 182.550 -#else
 182.551 -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
 182.552 -#endif
 182.553 -
 182.554 -  if (nextchar == NULL || *nextchar == '\0')
 182.555 -    {
 182.556 -      /* Advance to the next ARGV-element.  */
 182.557 -
 182.558 -      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
 182.559 -	 moved back by the user (who may also have changed the arguments).  */
 182.560 -      if (last_nonopt > optind)
 182.561 -	last_nonopt = optind;
 182.562 -      if (first_nonopt > optind)
 182.563 -	first_nonopt = optind;
 182.564 -
 182.565 -      if (ordering == PERMUTE)
 182.566 -	{
 182.567 -	  /* If we have just processed some options following some non-options,
 182.568 -	     exchange them so that the options come first.  */
 182.569 -
 182.570 -	  if (first_nonopt != last_nonopt && last_nonopt != optind)
 182.571 -	    exchange ((char **) argv);
 182.572 -	  else if (last_nonopt != optind)
 182.573 -	    first_nonopt = optind;
 182.574 -
 182.575 -	  /* Skip any additional non-options
 182.576 -	     and extend the range of non-options previously skipped.  */
 182.577 -
 182.578 -	  while (optind < argc && NONOPTION_P)
 182.579 -	    optind++;
 182.580 -	  last_nonopt = optind;
 182.581 -	}
 182.582 -
 182.583 -      /* The special ARGV-element `--' means premature end of options.
 182.584 -	 Skip it like a null option,
 182.585 -	 then exchange with previous non-options as if it were an option,
 182.586 -	 then skip everything else like a non-option.  */
 182.587 -
 182.588 -      if (optind != argc && !strcmp (argv[optind], "--"))
 182.589 -	{
 182.590 -	  optind++;
 182.591 -
 182.592 -	  if (first_nonopt != last_nonopt && last_nonopt != optind)
 182.593 -	    exchange ((char **) argv);
 182.594 -	  else if (first_nonopt == last_nonopt)
 182.595 -	    first_nonopt = optind;
 182.596 -	  last_nonopt = argc;
 182.597 -
 182.598 -	  optind = argc;
 182.599 -	}
 182.600 -
 182.601 -      /* If we have done all the ARGV-elements, stop the scan
 182.602 -	 and back over any non-options that we skipped and permuted.  */
 182.603 -
 182.604 -      if (optind == argc)
 182.605 -	{
 182.606 -	  /* Set the next-arg-index to point at the non-options
 182.607 -	     that we previously skipped, so the caller will digest them.  */
 182.608 -	  if (first_nonopt != last_nonopt)
 182.609 -	    optind = first_nonopt;
 182.610 -	  return -1;
 182.611 -	}
 182.612 -
 182.613 -      /* If we have come to a non-option and did not permute it,
 182.614 -	 either stop the scan or describe it to the caller and pass it by.  */
 182.615 -
 182.616 -      if (NONOPTION_P)
 182.617 -	{
 182.618 -	  if (ordering == REQUIRE_ORDER)
 182.619 -	    return -1;
 182.620 -	  optarg = argv[optind++];
 182.621 -	  return 1;
 182.622 -	}
 182.623 -
 182.624 -      /* We have found another option-ARGV-element.
 182.625 -	 Skip the initial punctuation.  */
 182.626 -
 182.627 -      nextchar = (argv[optind] + 1
 182.628 -		  + (longopts != NULL && argv[optind][1] == '-'));
 182.629 -    }
 182.630 -
 182.631 -  /* Decode the current option-ARGV-element.  */
 182.632 -
 182.633 -  /* Check whether the ARGV-element is a long option.
 182.634 -
 182.635 -     If long_only and the ARGV-element has the form "-f", where f is
 182.636 -     a valid short option, don't consider it an abbreviated form of
 182.637 -     a long option that starts with f.  Otherwise there would be no
 182.638 -     way to give the -f short option.
 182.639 -
 182.640 -     On the other hand, if there's a long option "fubar" and
 182.641 -     the ARGV-element is "-fu", do consider that an abbreviation of
 182.642 -     the long option, just like "--fu", and not "-f" with arg "u".
 182.643 -
 182.644 -     This distinction seems to be the most useful approach.  */
 182.645 -
 182.646 -  if (longopts != NULL
 182.647 -      && (argv[optind][1] == '-'
 182.648 -	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
 182.649 -    {
 182.650 -      char *nameend;
 182.651 -      const struct option *p;
 182.652 -      const struct option *pfound = NULL;
 182.653 -      int exact = 0;
 182.654 -      int ambig = 0;
 182.655 -      int indfound = -1;
 182.656 -      int option_index;
 182.657 -
 182.658 -      for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
 182.659 -	/* Do nothing.  */ ;
 182.660 -
 182.661 -      /* Test all long options for either exact match
 182.662 -	 or abbreviated matches.  */
 182.663 -      for (p = longopts, option_index = 0; p->name; p++, option_index++)
 182.664 -	if (!strncmp (p->name, nextchar, nameend - nextchar))
 182.665 -	  {
 182.666 -	    if ((unsigned int) (nameend - nextchar)
 182.667 -		== (unsigned int) strlen (p->name))
 182.668 -	      {
 182.669 -		/* Exact match found.  */
 182.670 -		pfound = p;
 182.671 -		indfound = option_index;
 182.672 -		exact = 1;
 182.673 -		break;
 182.674 -	      }
 182.675 -	    else if (pfound == NULL)
 182.676 -	      {
 182.677 -		/* First nonexact match found.  */
 182.678 -		pfound = p;
 182.679 -		indfound = option_index;
 182.680 -	      }
 182.681 -	    else
 182.682 -	      /* Second or later nonexact match found.  */
 182.683 -	      ambig = 1;
 182.684 -	  }
 182.685 -
 182.686 -      if (ambig && !exact)
 182.687 -	{
 182.688 -	  if (opterr)
 182.689 -	    fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
 182.690 -		     argv[0], argv[optind]);
 182.691 -	  nextchar += strlen (nextchar);
 182.692 -	  optind++;
 182.693 -	  optopt = 0;
 182.694 -	  return '?';
 182.695 -	}
 182.696 -
 182.697 -      if (pfound != NULL)
 182.698 -	{
 182.699 -	  option_index = indfound;
 182.700 -	  optind++;
 182.701 -	  if (*nameend)
 182.702 -	    {
 182.703 -	      /* Don't test has_arg with >, because some C compilers don't
 182.704 -		 allow it to be used on enums.  */
 182.705 -	      if (pfound->has_arg)
 182.706 -		optarg = nameend + 1;
 182.707 -	      else
 182.708 -		{
 182.709 -		  if (opterr)
 182.710 -		    {
 182.711 -		      if (argv[optind - 1][1] == '-')
 182.712 -			/* --option */
 182.713 -			fprintf (stderr,
 182.714 -				 _("%s: option `--%s' doesn't allow an argument\n"),
 182.715 -				 argv[0], pfound->name);
 182.716 -		      else
 182.717 -			/* +option or -option */
 182.718 -			fprintf (stderr,
 182.719 -				 _("%s: option `%c%s' doesn't allow an argument\n"),
 182.720 -				 argv[0], argv[optind - 1][0], pfound->name);
 182.721 -
 182.722 -		      nextchar += strlen (nextchar);
 182.723 -
 182.724 -		      optopt = pfound->val;
 182.725 -		      return '?';
 182.726 -		    }
 182.727 -		}
 182.728 -	    }
 182.729 -	  else if (pfound->has_arg == 1)
 182.730 -	    {
 182.731 -	      if (optind < argc)
 182.732 -		optarg = argv[optind++];
 182.733 -	      else
 182.734 -		{
 182.735 -		  if (opterr)
 182.736 -		    fprintf (stderr,
 182.737 -			   _("%s: option `%s' requires an argument\n"),
 182.738 -			   argv[0], argv[optind - 1]);
 182.739 -		  nextchar += strlen (nextchar);
 182.740 -		  optopt = pfound->val;
 182.741 -		  return optstring[0] == ':' ? ':' : '?';
 182.742 -		}
 182.743 -	    }
 182.744 -	  nextchar += strlen (nextchar);
 182.745 -	  if (longind != NULL)
 182.746 -	    *longind = option_index;
 182.747 -	  if (pfound->flag)
 182.748 -	    {
 182.749 -	      *(pfound->flag) = pfound->val;
 182.750 -	      return 0;
 182.751 -	    }
 182.752 -	  return pfound->val;
 182.753 -	}
 182.754 -
 182.755 -      /* Can't find it as a long option.  If this is not getopt_long_only,
 182.756 -	 or the option starts with '--' or is not a valid short
 182.757 -	 option, then it's an error.
 182.758 -	 Otherwise interpret it as a short option.  */
 182.759 -      if (!long_only || argv[optind][1] == '-'
 182.760 -	  || my_index (optstring, *nextchar) == NULL)
 182.761 -	{
 182.762 -	  if (opterr)
 182.763 -	    {
 182.764 -	      if (argv[optind][1] == '-')
 182.765 -		/* --option */
 182.766 -		fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
 182.767 -			 argv[0], nextchar);
 182.768 -	      else
 182.769 -		/* +option or -option */
 182.770 -		fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
 182.771 -			 argv[0], argv[optind][0], nextchar);
 182.772 -	    }
 182.773 -	  nextchar = (char *) "";
 182.774 -	  optind++;
 182.775 -	  optopt = 0;
 182.776 -	  return '?';
 182.777 -	}
 182.778 -    }
 182.779 -
 182.780 -  /* Look at and handle the next short option-character.  */
 182.781 -
 182.782 -  {
 182.783 -    char c = *nextchar++;
 182.784 -    char *temp = my_index (optstring, c);
 182.785 -
 182.786 -    /* Increment `optind' when we start to process its last character.  */
 182.787 -    if (*nextchar == '\0')
 182.788 -      ++optind;
 182.789 -
 182.790 -    if (temp == NULL || c == ':')
 182.791 -      {
 182.792 -	if (opterr)
 182.793 -	  {
 182.794 -	    if (posixly_correct)
 182.795 -	      /* 1003.2 specifies the format of this message.  */
 182.796 -	      fprintf (stderr, _("%s: illegal option -- %c\n"),
 182.797 -		       argv[0], c);
 182.798 -	    else
 182.799 -	      fprintf (stderr, _("%s: invalid option -- %c\n"),
 182.800 -		       argv[0], c);
 182.801 -	  }
 182.802 -	optopt = c;
 182.803 -	return '?';
 182.804 -      }
 182.805 -    /* Convenience. Treat POSIX -W foo same as long option --foo */
 182.806 -    if (temp[0] == 'W' && temp[1] == ';')
 182.807 -      {
 182.808 -	char *nameend;
 182.809 -	const struct option *p;
 182.810 -	const struct option *pfound = NULL;
 182.811 -	int exact = 0;
 182.812 -	int ambig = 0;
 182.813 -	int indfound = 0;
 182.814 -	int option_index;
 182.815 -
 182.816 -	/* This is an option that requires an argument.  */
 182.817 -	if (*nextchar != '\0')
 182.818 -	  {
 182.819 -	    optarg = nextchar;
 182.820 -	    /* If we end this ARGV-element by taking the rest as an arg,
 182.821 -	       we must advance to the next element now.  */
 182.822 -	    optind++;
 182.823 -	  }
 182.824 -	else if (optind == argc)
 182.825 -	  {
 182.826 -	    if (opterr)
 182.827 -	      {
 182.828 -		/* 1003.2 specifies the format of this message.  */
 182.829 -		fprintf (stderr, _("%s: option requires an argument -- %c\n"),
 182.830 -			 argv[0], c);
 182.831 -	      }
 182.832 -	    optopt = c;
 182.833 -	    if (optstring[0] == ':')
 182.834 -	      c = ':';
 182.835 -	    else
 182.836 -	      c = '?';
 182.837 -	    return c;
 182.838 -	  }
 182.839 -	else
 182.840 -	  /* We already incremented `optind' once;
 182.841 -	     increment it again when taking next ARGV-elt as argument.  */
 182.842 -	  optarg = argv[optind++];
 182.843 -
 182.844 -	/* optarg is now the argument, see if it's in the
 182.845 -	   table of longopts.  */
 182.846 -
 182.847 -	for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
 182.848 -	  /* Do nothing.  */ ;
 182.849 -
 182.850 -	/* Test all long options for either exact match
 182.851 -	   or abbreviated matches.  */
 182.852 -	for (p = longopts, option_index = 0; p->name; p++, option_index++)
 182.853 -	  if (!strncmp (p->name, nextchar, nameend - nextchar))
 182.854 -	    {
 182.855 -	      if ((unsigned int) (nameend - nextchar) == strlen (p->name))
 182.856 -		{
 182.857 -		  /* Exact match found.  */
 182.858 -		  pfound = p;
 182.859 -		  indfound = option_index;
 182.860 -		  exact = 1;
 182.861 -		  break;
 182.862 -		}
 182.863 -	      else if (pfound == NULL)
 182.864 -		{
 182.865 -		  /* First nonexact match found.  */
 182.866 -		  pfound = p;
 182.867 -		  indfound = option_index;
 182.868 -		}
 182.869 -	      else
 182.870 -		/* Second or later nonexact match found.  */
 182.871 -		ambig = 1;
 182.872 -	    }
 182.873 -	if (ambig && !exact)
 182.874 -	  {
 182.875 -	    if (opterr)
 182.876 -	      fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
 182.877 -		       argv[0], argv[optind]);
 182.878 -	    nextchar += strlen (nextchar);
 182.879 -	    optind++;
 182.880 -	    return '?';
 182.881 -	  }
 182.882 -	if (pfound != NULL)
 182.883 -	  {
 182.884 -	    option_index = indfound;
 182.885 -	    if (*nameend)
 182.886 -	      {
 182.887 -		/* Don't test has_arg with >, because some C compilers don't
 182.888 -		   allow it to be used on enums.  */
 182.889 -		if (pfound->has_arg)
 182.890 -		  optarg = nameend + 1;
 182.891 -		else
 182.892 -		  {
 182.893 -		    if (opterr)
 182.894 -		      fprintf (stderr, _("\
 182.895 -%s: option `-W %s' doesn't allow an argument\n"),
 182.896 -			       argv[0], pfound->name);
 182.897 -
 182.898 -		    nextchar += strlen (nextchar);
 182.899 -		    return '?';
 182.900 -		  }
 182.901 -	      }
 182.902 -	    else if (pfound->has_arg == 1)
 182.903 -	      {
 182.904 -		if (optind < argc)
 182.905 -		  optarg = argv[optind++];
 182.906 -		else
 182.907 -		  {
 182.908 -		    if (opterr)
 182.909 -		      fprintf (stderr,
 182.910 -			       _("%s: option `%s' requires an argument\n"),
 182.911 -			       argv[0], argv[optind - 1]);
 182.912 -		    nextchar += strlen (nextchar);
 182.913 -		    return optstring[0] == ':' ? ':' : '?';
 182.914 -		  }
 182.915 -	      }
 182.916 -	    nextchar += strlen (nextchar);
 182.917 -	    if (longind != NULL)
 182.918 -	      *longind = option_index;
 182.919 -	    if (pfound->flag)
 182.920 -	      {
 182.921 -		*(pfound->flag) = pfound->val;
 182.922 -		return 0;
 182.923 -	      }
 182.924 -	    return pfound->val;
 182.925 -	  }
 182.926 -	  nextchar = NULL;
 182.927 -	  return 'W';	/* Let the application handle it.   */
 182.928 -      }
 182.929 -    if (temp[1] == ':')
 182.930 -      {
 182.931 -	if (temp[2] == ':')
 182.932 -	  {
 182.933 -	    /* This is an option that accepts an argument optionally.  */
 182.934 -	    if (*nextchar != '\0')
 182.935 -	      {
 182.936 -		optarg = nextchar;
 182.937 -		optind++;
 182.938 -	      }
 182.939 -	    else
 182.940 -	      optarg = NULL;
 182.941 -	    nextchar = NULL;
 182.942 -	  }
 182.943 -	else
 182.944 -	  {
 182.945 -	    /* This is an option that requires an argument.  */
 182.946 -	    if (*nextchar != '\0')
 182.947 -	      {
 182.948 -		optarg = nextchar;
 182.949 -		/* If we end this ARGV-element by taking the rest as an arg,
 182.950 -		   we must advance to the next element now.  */
 182.951 -		optind++;
 182.952 -	      }
 182.953 -	    else if (optind == argc)
 182.954 -	      {
 182.955 -		if (opterr)
 182.956 -		  {
 182.957 -		    /* 1003.2 specifies the format of this message.  */
 182.958 -		    fprintf (stderr,
 182.959 -			   _("%s: option requires an argument -- %c\n"),
 182.960 -			   argv[0], c);
 182.961 -		  }
 182.962 -		optopt = c;
 182.963 -		if (optstring[0] == ':')
 182.964 -		  c = ':';
 182.965 -		else
 182.966 -		  c = '?';
 182.967 -	      }
 182.968 -	    else
 182.969 -	      /* We already incremented `optind' once;
 182.970 -		 increment it again when taking next ARGV-elt as argument.  */
 182.971 -	      optarg = argv[optind++];
 182.972 -	    nextchar = NULL;
 182.973 -	  }
 182.974 -      }
 182.975 -    return c;
 182.976 -  }
 182.977 -}
 182.978 -
 182.979 -int
 182.980 -getopt (argc, argv, optstring)
 182.981 -     int argc;
 182.982 -     char *const *argv;
 182.983 -     const char *optstring;
 182.984 -{
 182.985 -  return _getopt_internal (argc, argv, optstring,
 182.986 -			   (const struct option *) 0,
 182.987 -			   (int *) 0,
 182.988 -			   0);
 182.989 -}
 182.990 -
 182.991 -#endif	/* Not ELIDE_CODE.  */
 182.992 -
 182.993 -#ifdef TEST
 182.994 -
 182.995 -/* Compile with -DTEST to make an executable for use in testing
 182.996 -   the above definition of `getopt'.  */
 182.997 -
 182.998 -int
 182.999 -main (argc, argv)
182.1000 -     int argc;
182.1001 -     char **argv;
182.1002 -{
182.1003 -  int c;
182.1004 -  int digit_optind = 0;
182.1005 -
182.1006 -  while (1)
182.1007 -    {
182.1008 -      int this_option_optind = optind ? optind : 1;
182.1009 -
182.1010 -      c = getopt (argc, argv, "abc:d:0123456789");
182.1011 -      if (c == -1)
182.1012 -	break;
182.1013 -
182.1014 -      switch (c)
182.1015 -	{
182.1016 -	case '0':
182.1017 -	case '1':
182.1018 -	case '2':
182.1019 -	case '3':
182.1020 -	case '4':
182.1021 -	case '5':
182.1022 -	case '6':
182.1023 -	case '7':
182.1024 -	case '8':
182.1025 -	case '9':
182.1026 -	  if (digit_optind != 0 && digit_optind != this_option_optind)
182.1027 -	    printf ("digits occur in two different argv-elements.\n");
182.1028 -	  digit_optind = this_option_optind;
182.1029 -	  printf ("option %c\n", c);
182.1030 -	  break;
182.1031 -
182.1032 -	case 'a':
182.1033 -	  printf ("option a\n");
182.1034 -	  break;
182.1035 -
182.1036 -	case 'b':
182.1037 -	  printf ("option b\n");
182.1038 -	  break;
182.1039 -
182.1040 -	case 'c':
182.1041 -	  printf ("option c with value `%s'\n", optarg);
182.1042 -	  break;
182.1043 -
182.1044 -	case '?':
182.1045 -	  break;
182.1046 -
182.1047 -	default:
182.1048 -	  printf ("?? getopt returned character code 0%o ??\n", c);
182.1049 -	}
182.1050 -    }
182.1051 -
182.1052 -  if (optind < argc)
182.1053 -    {
182.1054 -      printf ("non-option ARGV-elements: ");
182.1055 -      while (optind < argc)
182.1056 -	printf ("%s ", argv[optind++]);
182.1057 -      printf ("\n");
182.1058 -    }
182.1059 -
182.1060 -  exit (0);
182.1061 -}
182.1062 -
182.1063 -#endif /* TEST */
   183.1 --- a/src/sdl/getopt.h	Sat Mar 03 10:54:39 2012 -0600
   183.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   183.3 @@ -1,141 +0,0 @@
   183.4 -/* Declarations for getopt.
   183.5 -   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000
   183.6 -   Free Software Foundation, Inc.
   183.7 -
   183.8 -   NOTE: The canonical source of this file is maintained with the GNU C Library.
   183.9 -   Bugs can be reported to bug-glibc@gnu.org.
  183.10 -
  183.11 -   This program is free software; you can redistribute it and/or modify it
  183.12 -   under the terms of the GNU General Public License as published by the
  183.13 -   Free Software Foundation; either version 2, or (at your option) any
  183.14 -   later version.
  183.15 -
  183.16 -   This program is distributed in the hope that it will be useful,
  183.17 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
  183.18 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  183.19 -   GNU General Public License for more details.
  183.20 -
  183.21 -   You should have received a copy of the GNU General Public License
  183.22 -   along with this program; if not, write to the Free Software
  183.23 -   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  183.24 -   USA.  */
  183.25 -
  183.26 -#ifndef _GETOPT_H
  183.27 -#define _GETOPT_H 1
  183.28 -
  183.29 -#ifdef	__cplusplus
  183.30 -extern "C" {
  183.31 -#endif
  183.32 -
  183.33 -/* For communication from `getopt' to the caller.
  183.34 -   When `getopt' finds an option that takes an argument,
  183.35 -   the argument value is returned here.
  183.36 -   Also, when `ordering' is RETURN_IN_ORDER,
  183.37 -   each non-option ARGV-element is returned here.  */
  183.38 -
  183.39 -extern char *optarg;
  183.40 -
  183.41 -/* Index in ARGV of the next element to be scanned.
  183.42 -   This is used for communication to and from the caller
  183.43 -   and for communication between successive calls to `getopt'.
  183.44 -
  183.45 -   On entry to `getopt', zero means this is the first call; initialize.
  183.46 -
  183.47 -   When `getopt' returns -1, this is the index of the first of the
  183.48 -   non-option elements that the caller should itself scan.
  183.49 -
  183.50 -   Otherwise, `optind' communicates from one call to the next
  183.51 -   how much of ARGV has been scanned so far.  */
  183.52 -
  183.53 -extern int optind;
  183.54 -
  183.55 -/* Callers store zero here to inhibit the error message `getopt' prints
  183.56 -   for unrecognized options.  */
  183.57 -
  183.58 -extern int opterr;
  183.59 -
  183.60 -/* Set to an option character which was unrecognized.  */
  183.61 -
  183.62 -extern int optopt;
  183.63 -
  183.64 -/* Describe the long-named options requested by the application.
  183.65 -   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
  183.66 -   of `struct option' terminated by an element containing a name which is
  183.67 -   zero.
  183.68 -
  183.69 -   The field `has_arg' is:
  183.70 -   no_argument		(or 0) if the option does not take an argument,
  183.71 -   required_argument	(or 1) if the option requires an argument,
  183.72 -   optional_argument 	(or 2) if the option takes an optional argument.
  183.73 -
  183.74 -   If the field `flag' is not NULL, it points to a variable that is set
  183.75 -   to the value given in the field `val' when the option is found, but
  183.76 -   left unchanged if the option is not found.
  183.77 -
  183.78 -   To have a long-named option do something other than set an `int' to
  183.79 -   a compiled-in constant, such as set a value from `optarg', set the
  183.80 -   option's `flag' field to zero and its `val' field to a nonzero
  183.81 -   value (the equivalent single-letter option character, if there is
  183.82 -   one).  For long options that have a zero `flag' field, `getopt'
  183.83 -   returns the contents of the `val' field.  */
  183.84 -
  183.85 -struct option
  183.86 -{
  183.87 -#if defined (__STDC__) && __STDC__
  183.88 -  const char *name;
  183.89 -#else
  183.90 -  char *name;
  183.91 -#endif
  183.92 -  /* has_arg can't be an enum because some compilers complain about
  183.93 -     type mismatches in all the code that assumes it is an int.  */
  183.94 -  int has_arg;
  183.95 -  int *flag;
  183.96 -  int val;
  183.97 -};
  183.98 -
  183.99 -/* Names for the values of the `has_arg' field of `struct option'.  */
 183.100 -
 183.101 -#define	no_argument		0
 183.102 -#define required_argument	1
 183.103 -#define optional_argument	2
 183.104 -
 183.105 -#if defined (__STDC__) && __STDC__
 183.106 -/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1.  If it is
 183.107 -   undefined, we haven't run the autoconf check so provide the
 183.108 -   declaration without arguments.  If it is 0, we checked and failed
 183.109 -   to find the declaration so provide a fully prototyped one.  If it
 183.110 -   is 1, we found it so don't provide any declaration at all.  */
 183.111 -#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
 183.112 -/* Many other libraries have conflicting prototypes for getopt, with
 183.113 -   differences in the consts, in stdlib.h.  To avoid compilation
 183.114 -   errors, only prototype getopt for the GNU C library.  */
 183.115 -extern int getopt (int argc, char *const *argv, const char *shortopts);
 183.116 -#else /* not __GNU_LIBRARY__ */
 183.117 -# if !defined (HAVE_DECL_GETOPT)
 183.118 -extern int getopt ();
 183.119 -# endif
 183.120 -#endif /* __GNU_LIBRARY__ */
 183.121 -extern int getopt_long (int argc, char *const *argv, const char *shortopts,
 183.122 -		        const struct option *longopts, int *longind);
 183.123 -extern int getopt_long_only (int argc, char *const *argv,
 183.124 -			     const char *shortopts,
 183.125 -		             const struct option *longopts, int *longind);
 183.126 -
 183.127 -/* Internal only.  Users should not call this directly.  */
 183.128 -extern int _getopt_internal (int argc, char *const *argv,
 183.129 -			     const char *shortopts,
 183.130 -		             const struct option *longopts, int *longind,
 183.131 -			     int long_only);
 183.132 -#else /* not __STDC__ */
 183.133 -extern int getopt ();
 183.134 -extern int getopt_long ();
 183.135 -extern int getopt_long_only ();
 183.136 -
 183.137 -extern int _getopt_internal ();
 183.138 -#endif /* __STDC__ */
 183.139 -
 183.140 -#ifdef	__cplusplus
 183.141 -}
 183.142 -#endif
 183.143 -
 183.144 -#endif /* getopt.h */
   184.1 --- a/src/sdl/getopt1.c	Sat Mar 03 10:54:39 2012 -0600
   184.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   184.3 @@ -1,190 +0,0 @@
   184.4 -/* getopt_long and getopt_long_only entry points for GNU getopt.
   184.5 -   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
   184.6 -     Free Software Foundation, Inc.
   184.7 -
   184.8 -   NOTE: This source is derived from an old version taken from the GNU C
   184.9 -   Library (glibc).
  184.10 -
  184.11 -   This program is free software; you can redistribute it and/or modify it
  184.12 -   under the terms of the GNU General Public License as published by the
  184.13 -   Free Software Foundation; either version 2, or (at your option) any
  184.14 -   later version.
  184.15 -
  184.16 -   This program is distributed in the hope that it will be useful,
  184.17 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
  184.18 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  184.19 -   GNU General Public License for more details.
  184.20 -
  184.21 -   You should have received a copy of the GNU General Public License
  184.22 -   along with this program; if not, write to the Free Software
  184.23 -   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  184.24 -   USA.  */
  184.25 -
  184.26 -#ifdef HAVE_CONFIG_H
  184.27 -#include <config.h>
  184.28 -#endif
  184.29 -
  184.30 -#include "getopt.h"
  184.31 -
  184.32 -#if !defined __STDC__ || !__STDC__
  184.33 -/* This is a separate conditional since some stdc systems
  184.34 -   reject `defined (const)'.  */
  184.35 -#ifndef const
  184.36 -#define const
  184.37 -#endif
  184.38 -#endif
  184.39 -
  184.40 -#include <stdio.h>
  184.41 -
  184.42 -/* Comment out all this code if we are using the GNU C Library, and are not
  184.43 -   actually compiling the library itself.  This code is part of the GNU C
  184.44 -   Library, but also included in many other GNU distributions.  Compiling
  184.45 -   and linking in this code is a waste when using the GNU C library
  184.46 -   (especially if it is a shared library).  Rather than having every GNU
  184.47 -   program understand `configure --with-gnu-libc' and omit the object files,
  184.48 -   it is simpler to just do this in the source for each such file.  */
  184.49 -
  184.50 -#define GETOPT_INTERFACE_VERSION 2
  184.51 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
  184.52 -#include <gnu-versions.h>
  184.53 -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
  184.54 -#define ELIDE_CODE
  184.55 -#endif
  184.56 -#endif
  184.57 -
  184.58 -#ifndef ELIDE_CODE
  184.59 -
  184.60 -
  184.61 -/* This needs to come after some library #include
  184.62 -   to get __GNU_LIBRARY__ defined.  */
  184.63 -#ifdef __GNU_LIBRARY__
  184.64 -#include <stdlib.h>
  184.65 -#endif
  184.66 -
  184.67 -#ifndef	NULL
  184.68 -#define NULL 0
  184.69 -#endif
  184.70 -
  184.71 -int
  184.72 -getopt_long (argc, argv, options, long_options, opt_index)
  184.73 -     int argc;
  184.74 -     char *const *argv;
  184.75 -     const char *options;
  184.76 -     const struct option *long_options;
  184.77 -     int *opt_index;
  184.78 -{
  184.79 -  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
  184.80 -}
  184.81 -
  184.82 -/* Like getopt_long, but '-' as well as '--' can indicate a long option.
  184.83 -   If an option that starts with '-' (not '--') doesn't match a long option,
  184.84 -   but does match a short option, it is parsed as a short option
  184.85 -   instead.  */
  184.86 -
  184.87 -int
  184.88 -getopt_long_only (argc, argv, options, long_options, opt_index)
  184.89 -     int argc;
  184.90 -     char *const *argv;
  184.91 -     const char *options;
  184.92 -     const struct option *long_options;
  184.93 -     int *opt_index;
  184.94 -{
  184.95 -  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
  184.96 -}
  184.97 -
  184.98 -
  184.99 -#endif	/* Not ELIDE_CODE.  */
 184.100 -
 184.101 -#ifdef TEST
 184.102 -
 184.103 -#include <stdio.h>
 184.104 -
 184.105 -int
 184.106 -main (argc, argv)
 184.107 -     int argc;
 184.108 -     char **argv;
 184.109 -{
 184.110 -  int c;
 184.111 -  int digit_optind = 0;
 184.112 -
 184.113 -  while (1)
 184.114 -    {
 184.115 -      int this_option_optind = optind ? optind : 1;
 184.116 -      int option_index = 0;
 184.117 -      static struct option long_options[] =
 184.118 -      {
 184.119 -	{"add", 1, 0, 0},
 184.120 -	{"append", 0, 0, 0},
 184.121 -	{"delete", 1, 0, 0},
 184.122 -	{"verbose", 0, 0, 0},
 184.123 -	{"create", 0, 0, 0},
 184.124 -	{"file", 1, 0, 0},
 184.125 -	{0, 0, 0, 0}
 184.126 -      };
 184.127 -
 184.128 -      c = getopt_long (argc, argv, "abc:d:0123456789",
 184.129 -		       long_options, &option_index);
 184.130 -      if (c == -1)
 184.131 -	break;
 184.132 -
 184.133 -      switch (c)
 184.134 -	{
 184.135 -	case 0:
 184.136 -	  printf ("option %s", long_options[option_index].name);
 184.137 -	  if (optarg)
 184.138 -	    printf (" with arg %s", optarg);
 184.139 -	  printf ("\n");
 184.140 -	  break;
 184.141 -
 184.142 -	case '0':
 184.143 -	case '1':
 184.144 -	case '2':
 184.145 -	case '3':
 184.146 -	case '4':
 184.147 -	case '5':
 184.148 -	case '6':
 184.149 -	case '7':
 184.150 -	case '8':
 184.151 -	case '9':
 184.152 -	  if (digit_optind != 0 && digit_optind != this_option_optind)
 184.153 -	    printf ("digits occur in two different argv-elements.\n");
 184.154 -	  digit_optind = this_option_optind;
 184.155 -	  printf ("option %c\n", c);
 184.156 -	  break;
 184.157 -
 184.158 -	case 'a':
 184.159 -	  printf ("option a\n");
 184.160 -	  break;
 184.161 -
 184.162 -	case 'b':
 184.163 -	  printf ("option b\n");
 184.164 -	  break;
 184.165 -
 184.166 -	case 'c':
 184.167 -	  printf ("option c with value `%s'\n", optarg);
 184.168 -	  break;
 184.169 -
 184.170 -	case 'd':
 184.171 -	  printf ("option d with value `%s'\n", optarg);
 184.172 -	  break;
 184.173 -
 184.174 -	case '?':
 184.175 -	  break;
 184.176 -
 184.177 -	default:
 184.178 -	  printf ("?? getopt returned character code 0%o ??\n", c);
 184.179 -	}
 184.180 -    }
 184.181 -
 184.182 -  if (optind < argc)
 184.183 -    {
 184.184 -      printf ("non-option ARGV-elements: ");
 184.185 -      while (optind < argc)
 184.186 -	printf ("%s ", argv[optind++]);
 184.187 -      printf ("\n");
 184.188 -    }
 184.189 -
 184.190 -  exit (0);
 184.191 -}
 184.192 -
 184.193 -#endif /* TEST */
   185.1 --- a/src/version.h	Sat Mar 03 10:54:39 2012 -0600
   185.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   185.3 @@ -1,66 +0,0 @@
   185.4 -#ifndef VBA_VERSION_H
   185.5 -#define VBA_VERSION_H
   185.6 -
   185.7 -#if _MSC_VER > 1000
   185.8 -#pragma once
   185.9 -#endif // _MSC_VER > 1000
  185.10 -
  185.11 -#define STRINGIZE_VALUE(X) _Py_STRINGIZE2(X)
  185.12 -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
  185.13 -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
  185.14 -#define _Py_STRINGIZE2(X) #X
  185.15 -//re: http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5
  185.16 -
  185.17 -#if defined(_MSC_VER)
  185.18 -#	define VBA_COMPILER ""
  185.19 -#	define VBA_COMPILER_DETAIL " msvc " _Py_STRINGIZE(_MSC_VER)
  185.20 -#else
  185.21 -// TODO: make for others compilers
  185.22 -#	define VBA_COMPILER ""
  185.23 -#	define VBA_COMPILER_DETAIL ""
  185.24 -#endif
  185.25 -
  185.26 -#define VBA_NAME "VBA-RR"
  185.27 -#define VBA_RR_MAJOR_VERSION_NO 23
  185.28 -#define VBA_RR_MINOR_VERSION_NO 5
  185.29 -
  185.30 -#if !defined(_DEBUG) && (defined(WIN32) || defined(RC_INVOKED))
  185.31 -#	include "../win32/userconfig/svnrev.h"
  185.32 -#endif
  185.33 -#
  185.34 -#ifndef SVN_REV
  185.35 -#	define SVN_REV 0
  185.36 -#endif
  185.37 -
  185.38 -#ifndef SVN_REV_STR
  185.39 -#	if SVN_REV > 0
  185.40 -#		define SVN_REV_STR STRINGIZE_VALUE(SVN_REV)
  185.41 -#	else
  185.42 -#		define define SVN_REV_STR ""
  185.43 -#	endif
  185.44 -#endif
  185.45 -
  185.46 -#ifdef _DEBUG
  185.47 -#	define VBA_SUBVERSION_STRING " DEBUG"
  185.48 -#	define VBA_BUILDTYPE_STRING  "Debug"
  185.49 -#elif defined(PUBLIC_RELEASE)
  185.50 -#	define VBA_SUBVERSION_STRING ""
  185.51 -#	define VBA_BUILDTYPE_STRING  "Release"
  185.52 -#else // interim
  185.53 -#	define VBA_SUBVERSION_STRING " svn" SVN_REV_STR
  185.54 -#	define VBA_BUILDTYPE_STRING  "Interim"
  185.55 -#endif
  185.56 -
  185.57 -#define VBA_FEATURE_STRING ""
  185.58 -
  185.59 -#if VBA_RR_MINOR_VERSION_NO > 0
  185.60 -#	define VBA_RR_VERSION_NO VBA_RR_MAJOR_VERSION_NO ## . ## VBA_RR_MINOR_VERSION_NO
  185.61 -#else
  185.62 -#	define VBA_RR_VERSION_NO VBA_RR_MAJOR_VERSION_NO
  185.63 -#endif
  185.64 -
  185.65 -#define VBA_VERSION_STRING "v" STRINGIZE_VALUE(VBA_RR_VERSION_NO) VBA_SUBVERSION_STRING VBA_FEATURE_STRING VBA_COMPILER
  185.66 -#define VBA_NAME_AND_VERSION VBA_NAME " " VBA_VERSION_STRING
  185.67 -#define VBA_RR_SITE "http://code.google.com/p/vba-rerecording/"
  185.68 -
  185.69 -#endif // !VBA_VERSION_H
   186.1 --- a/src/win32/.cvsignore	Sat Mar 03 10:54:39 2012 -0600
   186.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   186.3 @@ -1,1 +0,0 @@
   186.4 -vba.aps
   187.1 --- a/src/win32/7zip/7z/7zip_2005.vcproj	Sat Mar 03 10:54:39 2012 -0600
   187.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   187.3 @@ -1,4058 +0,0 @@
   187.4 -<?xml version="1.0" encoding="Windows-1252"?>
   187.5 -<VisualStudioProject
   187.6 -	ProjectType="Visual C++"
   187.7 -	Version="8.00"
   187.8 -	Name="wlib7zip"
   187.9 -	ProjectGUID="{5646C572-A578-49F8-9DA9-3E00A8CBFE3F}"
  187.10 -	RootNamespace="gens"
  187.11 -	>
  187.12 -	<Platforms>
  187.13 -		<Platform
  187.14 -			Name="Win32"
  187.15 -		/>
  187.16 -	</Platforms>
  187.17 -	<ToolFiles>
  187.18 -		<DefaultToolFile
  187.19 -			FileName="masm.rules"
  187.20 -		/>
  187.21 -	</ToolFiles>
  187.22 -	<Configurations>
  187.23 -		<Configuration
  187.24 -			Name="Release|Win32"
  187.25 -			OutputDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
  187.26 -			IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
  187.27 -			ConfigurationType="4"
  187.28 -			UseOfMFC="0"
  187.29 -			ATLMinimizesCRunTimeLibraryUsage="false"
  187.30 -			WholeProgramOptimization="1"
  187.31 -			>
  187.32 -			<Tool
  187.33 -				Name="VCPreBuildEventTool"
  187.34 -			/>
  187.35 -			<Tool
  187.36 -				Name="VCCustomBuildTool"
  187.37 -			/>
  187.38 -			<Tool
  187.39 -				Name="MASM"
  187.40 -			/>
  187.41 -			<Tool
  187.42 -				Name="VCXMLDataGeneratorTool"
  187.43 -			/>
  187.44 -			<Tool
  187.45 -				Name="VCWebServiceProxyGeneratorTool"
  187.46 -			/>
  187.47 -			<Tool
  187.48 -				Name="VCMIDLTool"
  187.49 -				PreprocessorDefinitions="NDEBUG"
  187.50 -				MkTypLibCompatible="true"
  187.51 -				SuppressStartupBanner="true"
  187.52 -				TargetEnvironment="1"
  187.53 -				TypeLibraryName=".\Release/gens.tlb"
  187.54 -				HeaderFileName=""
  187.55 -			/>
  187.56 -			<Tool
  187.57 -				Name="VCCLCompilerTool"
  187.58 -				Optimization="3"
  187.59 -				InlineFunctionExpansion="2"
  187.60 -				EnableIntrinsicFunctions="true"
  187.61 -				FavorSizeOrSpeed="1"
  187.62 -				OmitFramePointers="true"
  187.63 -				EnableFiberSafeOptimizations="true"
  187.64 -				WholeProgramOptimization="true"
  187.65 -				AdditionalIncludeDirectories="CPP"
  187.66 -				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO"
  187.67 -				StringPooling="true"
  187.68 -				ExceptionHandling="1"
  187.69 -				RuntimeLibrary="0"
  187.70 -				UsePrecompiledHeader="2"
  187.71 -				PrecompiledHeaderFile="$(IntDir)\7z.pch"
  187.72 -				AssemblerListingLocation="$(IntDir)\"
  187.73 -				ObjectFile="$(IntDir)\"
  187.74 -				ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
  187.75 -				WarningLevel="3"
  187.76 -				SuppressStartupBanner="true"
  187.77 -				DebugInformationFormat="3"
  187.78 -				OmitDefaultLibName="true"
  187.79 -			/>
  187.80 -			<Tool
  187.81 -				Name="VCManagedResourceCompilerTool"
  187.82 -			/>
  187.83 -			<Tool
  187.84 -				Name="VCResourceCompilerTool"
  187.85 -				PreprocessorDefinitions="NDEBUG"
  187.86 -			/>
  187.87 -			<Tool
  187.88 -				Name="VCPreLinkEventTool"
  187.89 -			/>
  187.90 -			<Tool
  187.91 -				Name="VCLibrarianTool"
  187.92 -				AdditionalOptions=" /LTCG"
  187.93 -			/>
  187.94 -			<Tool
  187.95 -				Name="VCALinkTool"
  187.96 -			/>
  187.97 -			<Tool
  187.98 -				Name="VCXDCMakeTool"
  187.99 -			/>
 187.100 -			<Tool
 187.101 -				Name="VCBscMakeTool"
 187.102 -			/>
 187.103 -			<Tool
 187.104 -				Name="VCFxCopTool"
 187.105 -			/>
 187.106 -			<Tool
 187.107 -				Name="VCPostBuildEventTool"
 187.108 -			/>
 187.109 -		</Configuration>
 187.110 -		<Configuration
 187.111 -			Name="Debug|Win32"
 187.112 -			OutputDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 187.113 -			IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 187.114 -			ConfigurationType="4"
 187.115 -			UseOfMFC="0"
 187.116 -			ATLMinimizesCRunTimeLibraryUsage="false"
 187.117 -			>
 187.118 -			<Tool
 187.119 -				Name="VCPreBuildEventTool"
 187.120 -				CommandLine=""
 187.121 -			/>
 187.122 -			<Tool
 187.123 -				Name="VCCustomBuildTool"
 187.124 -				CommandLine=""
 187.125 -			/>
 187.126 -			<Tool
 187.127 -				Name="MASM"
 187.128 -			/>
 187.129 -			<Tool
 187.130 -				Name="VCXMLDataGeneratorTool"
 187.131 -			/>
 187.132 -			<Tool
 187.133 -				Name="VCWebServiceProxyGeneratorTool"
 187.134 -			/>
 187.135 -			<Tool
 187.136 -				Name="VCMIDLTool"
 187.137 -				PreprocessorDefinitions="NDEBUG"
 187.138 -				MkTypLibCompatible="true"
 187.139 -				SuppressStartupBanner="true"
 187.140 -				TargetEnvironment="1"
 187.141 -				TypeLibraryName=".\Release/gens.tlb"
 187.142 -				HeaderFileName=""
 187.143 -			/>
 187.144 -			<Tool
 187.145 -				Name="VCCLCompilerTool"
 187.146 -				Optimization="0"
 187.147 -				InlineFunctionExpansion="0"
 187.148 -				EnableIntrinsicFunctions="false"
 187.149 -				AdditionalIncludeDirectories="CPP"
 187.150 -				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO"
 187.151 -				StringPooling="false"
 187.152 -				ExceptionHandling="1"
 187.153 -				BasicRuntimeChecks="3"
 187.154 -				SmallerTypeCheck="true"
 187.155 -				RuntimeLibrary="0"
 187.156 -				EnableFunctionLevelLinking="false"
 187.157 -				UsePrecompiledHeader="2"
 187.158 -				PrecompiledHeaderFile="$(IntDir)\7z.pch"
 187.159 -				AssemblerListingLocation="$(IntDir)\"
 187.160 -				ObjectFile="$(IntDir)\"
 187.161 -				ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
 187.162 -				WarningLevel="3"
 187.163 -				SuppressStartupBanner="true"
 187.164 -				DebugInformationFormat="3"
 187.165 -				OmitDefaultLibName="true"
 187.166 -			/>
 187.167 -			<Tool
 187.168 -				Name="VCManagedResourceCompilerTool"
 187.169 -			/>
 187.170 -			<Tool
 187.171 -				Name="VCResourceCompilerTool"
 187.172 -				PreprocessorDefinitions="NDEBUG"
 187.173 -			/>
 187.174 -			<Tool
 187.175 -				Name="VCPreLinkEventTool"
 187.176 -			/>
 187.177 -			<Tool
 187.178 -				Name="VCLibrarianTool"
 187.179 -			/>
 187.180 -			<Tool
 187.181 -				Name="VCALinkTool"
 187.182 -			/>
 187.183 -			<Tool
 187.184 -				Name="VCXDCMakeTool"
 187.185 -			/>
 187.186 -			<Tool
 187.187 -				Name="VCBscMakeTool"
 187.188 -			/>
 187.189 -			<Tool
 187.190 -				Name="VCFxCopTool"
 187.191 -			/>
 187.192 -			<Tool
 187.193 -				Name="VCPostBuildEventTool"
 187.194 -			/>
 187.195 -		</Configuration>
 187.196 -	</Configurations>
 187.197 -	<References>
 187.198 -	</References>
 187.199 -	<Files>
 187.200 -		<Filter
 187.201 -			Name="7zip"
 187.202 -			>
 187.203 -			<File
 187.204 -				RelativePath=".\CPP\7zip\Common\FilterCoder.cpp"
 187.205 -				>
 187.206 -				<FileConfiguration
 187.207 -					Name="Release|Win32"
 187.208 -					>
 187.209 -					<Tool
 187.210 -						Name="VCCLCompilerTool"
 187.211 -						UsePrecompiledHeader="2"
 187.212 -					/>
 187.213 -				</FileConfiguration>
 187.214 -				<FileConfiguration
 187.215 -					Name="Debug|Win32"
 187.216 -					>
 187.217 -					<Tool
 187.218 -						Name="VCCLCompilerTool"
 187.219 -						UsePrecompiledHeader="2"
 187.220 -					/>
 187.221 -				</FileConfiguration>
 187.222 -			</File>
 187.223 -			<File
 187.224 -				RelativePath=".\CPP\7zip\Common\InBuffer.cpp"
 187.225 -				>
 187.226 -				<FileConfiguration
 187.227 -					Name="Release|Win32"
 187.228 -					>
 187.229 -					<Tool
 187.230 -						Name="VCCLCompilerTool"
 187.231 -						UsePrecompiledHeader="2"
 187.232 -					/>
 187.233 -				</FileConfiguration>
 187.234 -				<FileConfiguration
 187.235 -					Name="Debug|Win32"
 187.236 -					>
 187.237 -					<Tool
 187.238 -						Name="VCCLCompilerTool"
 187.239 -						UsePrecompiledHeader="2"
 187.240 -					/>
 187.241 -				</FileConfiguration>
 187.242 -			</File>
 187.243 -			<File
 187.244 -				RelativePath=".\CPP\7zip\Common\InOutTempBuffer.cpp"
 187.245 -				>
 187.246 -				<FileConfiguration
 187.247 -					Name="Release|Win32"
 187.248 -					>
 187.249 -					<Tool
 187.250 -						Name="VCCLCompilerTool"
 187.251 -						UsePrecompiledHeader="2"
 187.252 -					/>
 187.253 -				</FileConfiguration>
 187.254 -				<FileConfiguration
 187.255 -					Name="Debug|Win32"
 187.256 -					>
 187.257 -					<Tool
 187.258 -						Name="VCCLCompilerTool"
 187.259 -						UsePrecompiledHeader="2"
 187.260 -					/>
 187.261 -				</FileConfiguration>
 187.262 -			</File>
 187.263 -			<File
 187.264 -				RelativePath=".\CPP\7zip\Common\LimitedStreams.cpp"
 187.265 -				>
 187.266 -				<FileConfiguration
 187.267 -					Name="Release|Win32"
 187.268 -					>
 187.269 -					<Tool
 187.270 -						Name="VCCLCompilerTool"
 187.271 -						UsePrecompiledHeader="2"
 187.272 -					/>
 187.273 -				</FileConfiguration>
 187.274 -				<FileConfiguration
 187.275 -					Name="Debug|Win32"
 187.276 -					>
 187.277 -					<Tool
 187.278 -						Name="VCCLCompilerTool"
 187.279 -						UsePrecompiledHeader="2"
 187.280 -					/>
 187.281 -				</FileConfiguration>
 187.282 -			</File>
 187.283 -			<File
 187.284 -				RelativePath=".\CPP\7zip\Common\LockedStream.cpp"
 187.285 -				>
 187.286 -				<FileConfiguration
 187.287 -					Name="Release|Win32"
 187.288 -					>
 187.289 -					<Tool
 187.290 -						Name="VCCLCompilerTool"
 187.291 -						UsePrecompiledHeader="2"
 187.292 -					/>
 187.293 -				</FileConfiguration>
 187.294 -				<FileConfiguration
 187.295 -					Name="Debug|Win32"
 187.296 -					>
 187.297 -					<Tool
 187.298 -						Name="VCCLCompilerTool"
 187.299 -						UsePrecompiledHeader="2"
 187.300 -					/>
 187.301 -				</FileConfiguration>
 187.302 -			</File>
 187.303 -			<File
 187.304 -				RelativePath=".\CPP\7zip\Common\MemBlocks.cpp"
 187.305 -				>
 187.306 -				<FileConfiguration
 187.307 -					Name="Release|Win32"
 187.308 -					>
 187.309 -					<Tool
 187.310 -						Name="VCCLCompilerTool"
 187.311 -						UsePrecompiledHeader="2"
 187.312 -					/>
 187.313 -				</FileConfiguration>
 187.314 -				<FileConfiguration
 187.315 -					Name="Debug|Win32"
 187.316 -					>
 187.317 -					<Tool
 187.318 -						Name="VCCLCompilerTool"
 187.319 -						UsePrecompiledHeader="2"
 187.320 -					/>
 187.321 -				</FileConfiguration>
 187.322 -			</File>
 187.323 -			<File
 187.324 -				RelativePath=".\CPP\7zip\Common\MethodId.cpp"
 187.325 -				>
 187.326 -				<FileConfiguration
 187.327 -					Name="Release|Win32"
 187.328 -					>
 187.329 -					<Tool
 187.330 -						Name="VCCLCompilerTool"
 187.331 -						UsePrecompiledHeader="2"
 187.332 -					/>
 187.333 -				</FileConfiguration>
 187.334 -				<FileConfiguration
 187.335 -					Name="Debug|Win32"
 187.336 -					>
 187.337 -					<Tool
 187.338 -						Name="VCCLCompilerTool"
 187.339 -						UsePrecompiledHeader="2"
 187.340 -					/>
 187.341 -				</FileConfiguration>
 187.342 -			</File>
 187.343 -			<File
 187.344 -				RelativePath=".\CPP\7zip\Common\MethodProps.cpp"
 187.345 -				>
 187.346 -				<FileConfiguration
 187.347 -					Name="Release|Win32"
 187.348 -					>
 187.349 -					<Tool
 187.350 -						Name="VCCLCompilerTool"
 187.351 -						UsePrecompiledHeader="2"
 187.352 -					/>
 187.353 -				</FileConfiguration>
 187.354 -				<FileConfiguration
 187.355 -					Name="Debug|Win32"
 187.356 -					>
 187.357 -					<Tool
 187.358 -						Name="VCCLCompilerTool"
 187.359 -						UsePrecompiledHeader="2"
 187.360 -					/>
 187.361 -				</FileConfiguration>
 187.362 -			</File>
 187.363 -			<File
 187.364 -				RelativePath=".\CPP\7zip\Common\OffsetStream.cpp"
 187.365 -				>
 187.366 -				<FileConfiguration
 187.367 -					Name="Release|Win32"
 187.368 -					>
 187.369 -					<Tool
 187.370 -						Name="VCCLCompilerTool"
 187.371 -						UsePrecompiledHeader="2"
 187.372 -					/>
 187.373 -				</FileConfiguration>
 187.374 -				<FileConfiguration
 187.375 -					Name="Debug|Win32"
 187.376 -					>
 187.377 -					<Tool
 187.378 -						Name="VCCLCompilerTool"
 187.379 -						UsePrecompiledHeader="2"
 187.380 -					/>
 187.381 -				</FileConfiguration>
 187.382 -			</File>
 187.383 -			<File
 187.384 -				RelativePath=".\CPP\7zip\Common\OutBuffer.cpp"
 187.385 -				>
 187.386 -				<FileConfiguration
 187.387 -					Name="Release|Win32"
 187.388 -					>
 187.389 -					<Tool
 187.390 -						Name="VCCLCompilerTool"
 187.391 -						UsePrecompiledHeader="2"
 187.392 -					/>
 187.393 -				</FileConfiguration>
 187.394 -				<FileConfiguration
 187.395 -					Name="Debug|Win32"
 187.396 -					>
 187.397 -					<Tool
 187.398 -						Name="VCCLCompilerTool"
 187.399 -						UsePrecompiledHeader="2"
 187.400 -					/>
 187.401 -				</FileConfiguration>
 187.402 -			</File>
 187.403 -			<File
 187.404 -				RelativePath=".\CPP\7zip\Common\OutMemStream.cpp"
 187.405 -				>
 187.406 -				<FileConfiguration
 187.407 -					Name="Release|Win32"
 187.408 -					>
 187.409 -					<Tool
 187.410 -						Name="VCCLCompilerTool"
 187.411 -						UsePrecompiledHeader="2"
 187.412 -					/>
 187.413 -				</FileConfiguration>
 187.414 -				<FileConfiguration
 187.415 -					Name="Debug|Win32"
 187.416 -					>
 187.417 -					<Tool
 187.418 -						Name="VCCLCompilerTool"
 187.419 -						UsePrecompiledHeader="2"
 187.420 -					/>
 187.421 -				</FileConfiguration>
 187.422 -			</File>
 187.423 -			<File
 187.424 -				RelativePath=".\CPP\7zip\Common\ProgressMt.cpp"
 187.425 -				>
 187.426 -				<FileConfiguration
 187.427 -					Name="Release|Win32"
 187.428 -					>
 187.429 -					<Tool
 187.430 -						Name="VCCLCompilerTool"
 187.431 -						UsePrecompiledHeader="2"
 187.432 -					/>
 187.433 -				</FileConfiguration>
 187.434 -				<FileConfiguration
 187.435 -					Name="Debug|Win32"
 187.436 -					>
 187.437 -					<Tool
 187.438 -						Name="VCCLCompilerTool"
 187.439 -						UsePrecompiledHeader="2"
 187.440 -					/>
 187.441 -				</FileConfiguration>
 187.442 -			</File>
 187.443 -			<File
 187.444 -				RelativePath=".\CPP\7zip\Common\ProgressUtils.cpp"
 187.445 -				>
 187.446 -				<FileConfiguration
 187.447 -					Name="Release|Win32"
 187.448 -					>
 187.449 -					<Tool
 187.450 -						Name="VCCLCompilerTool"
 187.451 -						UsePrecompiledHeader="2"
 187.452 -					/>
 187.453 -				</FileConfiguration>
 187.454 -				<FileConfiguration
 187.455 -					Name="Debug|Win32"
 187.456 -					>
 187.457 -					<Tool
 187.458 -						Name="VCCLCompilerTool"
 187.459 -						UsePrecompiledHeader="2"
 187.460 -					/>
 187.461 -				</FileConfiguration>
 187.462 -			</File>
 187.463 -			<File
 187.464 -				RelativePath=".\CPP\7zip\Common\StreamBinder.cpp"
 187.465 -				>
 187.466 -				<FileConfiguration
 187.467 -					Name="Release|Win32"
 187.468 -					>
 187.469 -					<Tool
 187.470 -						Name="VCCLCompilerTool"
 187.471 -						UsePrecompiledHeader="2"
 187.472 -					/>
 187.473 -				</FileConfiguration>
 187.474 -				<FileConfiguration
 187.475 -					Name="Debug|Win32"
 187.476 -					>
 187.477 -					<Tool
 187.478 -						Name="VCCLCompilerTool"
 187.479 -						UsePrecompiledHeader="2"
 187.480 -					/>
 187.481 -				</FileConfiguration>
 187.482 -			</File>
 187.483 -			<File
 187.484 -				RelativePath=".\CPP\7zip\Common\StreamObjects.cpp"
 187.485 -				>
 187.486 -				<FileConfiguration
 187.487 -					Name="Release|Win32"
 187.488 -					>
 187.489 -					<Tool
 187.490 -						Name="VCCLCompilerTool"
 187.491 -						UsePrecompiledHeader="2"
 187.492 -					/>
 187.493 -				</FileConfiguration>
 187.494 -				<FileConfiguration
 187.495 -					Name="Debug|Win32"
 187.496 -					>
 187.497 -					<Tool
 187.498 -						Name="VCCLCompilerTool"
 187.499 -						UsePrecompiledHeader="2"
 187.500 -					/>
 187.501 -				</FileConfiguration>
 187.502 -			</File>
 187.503 -			<File
 187.504 -				RelativePath=".\CPP\7zip\Common\StreamUtils.cpp"
 187.505 -				>
 187.506 -				<FileConfiguration
 187.507 -					Name="Release|Win32"
 187.508 -					>
 187.509 -					<Tool
 187.510 -						Name="VCCLCompilerTool"
 187.511 -						UsePrecompiledHeader="2"
 187.512 -					/>
 187.513 -				</FileConfiguration>
 187.514 -				<FileConfiguration
 187.515 -					Name="Debug|Win32"
 187.516 -					>
 187.517 -					<Tool
 187.518 -						Name="VCCLCompilerTool"
 187.519 -						UsePrecompiledHeader="2"
 187.520 -					/>
 187.521 -				</FileConfiguration>
 187.522 -			</File>
 187.523 -			<File
 187.524 -				RelativePath=".\CPP\7zip\Common\VirtThread.cpp"
 187.525 -				>
 187.526 -				<FileConfiguration
 187.527 -					Name="Release|Win32"
 187.528 -					>
 187.529 -					<Tool
 187.530 -						Name="VCCLCompilerTool"
 187.531 -						UsePrecompiledHeader="2"
 187.532 -					/>
 187.533 -				</FileConfiguration>
 187.534 -				<FileConfiguration
 187.535 -					Name="Debug|Win32"
 187.536 -					>
 187.537 -					<Tool
 187.538 -						Name="VCCLCompilerTool"
 187.539 -						UsePrecompiledHeader="2"
 187.540 -					/>
 187.541 -				</FileConfiguration>
 187.542 -			</File>
 187.543 -		</Filter>
 187.544 -		<Filter
 187.545 -			Name="Windows"
 187.546 -			>
 187.547 -			<File
 187.548 -				RelativePath=".\CPP\Windows\FileDir.cpp"
 187.549 -				>
 187.550 -				<FileConfiguration
 187.551 -					Name="Release|Win32"
 187.552 -					>
 187.553 -					<Tool
 187.554 -						Name="VCCLCompilerTool"
 187.555 -						UsePrecompiledHeader="2"
 187.556 -					/>
 187.557 -				</FileConfiguration>
 187.558 -				<FileConfiguration
 187.559 -					Name="Debug|Win32"
 187.560 -					>
 187.561 -					<Tool
 187.562 -						Name="VCCLCompilerTool"
 187.563 -						UsePrecompiledHeader="2"
 187.564 -					/>
 187.565 -				</FileConfiguration>
 187.566 -			</File>
 187.567 -			<File
 187.568 -				RelativePath=".\CPP\Windows\FileFind.cpp"
 187.569 -				>
 187.570 -				<FileConfiguration
 187.571 -					Name="Release|Win32"
 187.572 -					>
 187.573 -					<Tool
 187.574 -						Name="VCCLCompilerTool"
 187.575 -						UsePrecompiledHeader="2"
 187.576 -					/>
 187.577 -				</FileConfiguration>
 187.578 -				<FileConfiguration
 187.579 -					Name="Debug|Win32"
 187.580 -					>
 187.581 -					<Tool
 187.582 -						Name="VCCLCompilerTool"
 187.583 -						UsePrecompiledHeader="2"
 187.584 -					/>
 187.585 -				</FileConfiguration>
 187.586 -			</File>
 187.587 -			<File
 187.588 -				RelativePath=".\CPP\Windows\FileIO.cpp"
 187.589 -				>
 187.590 -				<FileConfiguration
 187.591 -					Name="Release|Win32"
 187.592 -					>
 187.593 -					<Tool
 187.594 -						Name="VCCLCompilerTool"
 187.595 -						UsePrecompiledHeader="2"
 187.596 -					/>
 187.597 -				</FileConfiguration>
 187.598 -				<FileConfiguration
 187.599 -					Name="Debug|Win32"
 187.600 -					>
 187.601 -					<Tool
 187.602 -						Name="VCCLCompilerTool"
 187.603 -						UsePrecompiledHeader="2"
 187.604 -					/>
 187.605 -				</FileConfiguration>
 187.606 -			</File>
 187.607 -			<File
 187.608 -				RelativePath=".\CPP\Windows\PropVariant.cpp"
 187.609 -				>
 187.610 -				<FileConfiguration
 187.611 -					Name="Release|Win32"
 187.612 -					>
 187.613 -					<Tool
 187.614 -						Name="VCCLCompilerTool"
 187.615 -						UsePrecompiledHeader="2"
 187.616 -					/>
 187.617 -				</FileConfiguration>
 187.618 -				<FileConfiguration
 187.619 -					Name="Debug|Win32"
 187.620 -					>
 187.621 -					<Tool
 187.622 -						Name="VCCLCompilerTool"
 187.623 -						UsePrecompiledHeader="2"
 187.624 -					/>
 187.625 -				</FileConfiguration>
 187.626 -			</File>
 187.627 -			<File
 187.628 -				RelativePath=".\CPP\Windows\Time.cpp"
 187.629 -				>
 187.630 -				<FileConfiguration
 187.631 -					Name="Release|Win32"
 187.632 -					>
 187.633 -					<Tool
 187.634 -						Name="VCCLCompilerTool"
 187.635 -						UsePrecompiledHeader="2"
 187.636 -					/>
 187.637 -				</FileConfiguration>
 187.638 -				<FileConfiguration
 187.639 -					Name="Debug|Win32"
 187.640 -					>
 187.641 -					<Tool
 187.642 -						Name="VCCLCompilerTool"
 187.643 -						UsePrecompiledHeader="2"
 187.644 -					/>
 187.645 -				</FileConfiguration>
 187.646 -			</File>
 187.647 -		</Filter>
 187.648 -		<Filter
 187.649 -			Name="Archive"
 187.650 -			>
 187.651 -			<Filter
 187.652 -				Name="7z"
 187.653 -				>
 187.654 -				<File
 187.655 -					RelativePath=".\CPP\7zip\Archive\7z\7zCompressionMode.cpp"
 187.656 -					>
 187.657 -					<FileConfiguration
 187.658 -						Name="Release|Win32"
 187.659 -						>
 187.660 -						<Tool
 187.661 -							Name="VCCLCompilerTool"
 187.662 -							UsePrecompiledHeader="2"
 187.663 -						/>
 187.664 -					</FileConfiguration>
 187.665 -					<FileConfiguration
 187.666 -						Name="Debug|Win32"
 187.667 -						>
 187.668 -						<Tool
 187.669 -							Name="VCCLCompilerTool"
 187.670 -							UsePrecompiledHeader="2"
 187.671 -						/>
 187.672 -					</FileConfiguration>
 187.673 -				</File>
 187.674 -				<File
 187.675 -					RelativePath=".\CPP\7zip\Archive\7z\7zDecode.cpp"
 187.676 -					>
 187.677 -					<FileConfiguration
 187.678 -						Name="Release|Win32"
 187.679 -						>
 187.680 -						<Tool
 187.681 -							Name="VCCLCompilerTool"
 187.682 -							UsePrecompiledHeader="2"
 187.683 -						/>
 187.684 -					</FileConfiguration>
 187.685 -					<FileConfiguration
 187.686 -						Name="Debug|Win32"
 187.687 -						>
 187.688 -						<Tool
 187.689 -							Name="VCCLCompilerTool"
 187.690 -							UsePrecompiledHeader="2"
 187.691 -						/>
 187.692 -					</FileConfiguration>
 187.693 -				</File>
 187.694 -				<File
 187.695 -					RelativePath=".\CPP\7zip\Archive\7z\7zExtract.cpp"
 187.696 -					>
 187.697 -					<FileConfiguration
 187.698 -						Name="Release|Win32"
 187.699 -						>
 187.700 -						<Tool
 187.701 -							Name="VCCLCompilerTool"
 187.702 -							UsePrecompiledHeader="2"
 187.703 -						/>
 187.704 -					</FileConfiguration>
 187.705 -					<FileConfiguration
 187.706 -						Name="Debug|Win32"
 187.707 -						>
 187.708 -						<Tool
 187.709 -							Name="VCCLCompilerTool"
 187.710 -							UsePrecompiledHeader="2"
 187.711 -						/>
 187.712 -					</FileConfiguration>
 187.713 -				</File>
 187.714 -				<File
 187.715 -					RelativePath=".\CPP\7zip\Archive\7z\7zFolderInStream.cpp"
 187.716 -					>
 187.717 -					<FileConfiguration
 187.718 -						Name="Release|Win32"
 187.719 -						>
 187.720 -						<Tool
 187.721 -							Name="VCCLCompilerTool"
 187.722 -							UsePrecompiledHeader="2"
 187.723 -						/>
 187.724 -					</FileConfiguration>
 187.725 -					<FileConfiguration
 187.726 -						Name="Debug|Win32"
 187.727 -						>
 187.728 -						<Tool
 187.729 -							Name="VCCLCompilerTool"
 187.730 -							UsePrecompiledHeader="2"
 187.731 -						/>
 187.732 -					</FileConfiguration>
 187.733 -				</File>
 187.734 -				<File
 187.735 -					RelativePath=".\CPP\7zip\Archive\7z\7zFolderOutStream.cpp"
 187.736 -					>
 187.737 -					<FileConfiguration
 187.738 -						Name="Release|Win32"
 187.739 -						>
 187.740 -						<Tool
 187.741 -							Name="VCCLCompilerTool"
 187.742 -							UsePrecompiledHeader="2"
 187.743 -						/>
 187.744 -					</FileConfiguration>
 187.745 -					<FileConfiguration
 187.746 -						Name="Debug|Win32"
 187.747 -						>
 187.748 -						<Tool
 187.749 -							Name="VCCLCompilerTool"
 187.750 -							UsePrecompiledHeader="2"
 187.751 -						/>
 187.752 -					</FileConfiguration>
 187.753 -				</File>
 187.754 -				<File
 187.755 -					RelativePath=".\CPP\7zip\Archive\7z\7zHandler.cpp"
 187.756 -					>
 187.757 -					<FileConfiguration
 187.758 -						Name="Release|Win32"
 187.759 -						>
 187.760 -						<Tool
 187.761 -							Name="VCCLCompilerTool"
 187.762 -							UsePrecompiledHeader="2"
 187.763 -						/>
 187.764 -					</FileConfiguration>
 187.765 -					<FileConfiguration
 187.766 -						Name="Debug|Win32"
 187.767 -						>
 187.768 -						<Tool
 187.769 -							Name="VCCLCompilerTool"
 187.770 -							UsePrecompiledHeader="2"
 187.771 -						/>
 187.772 -					</FileConfiguration>
 187.773 -				</File>
 187.774 -				<File
 187.775 -					RelativePath=".\CPP\7zip\Archive\7z\7zHeader.cpp"
 187.776 -					>
 187.777 -					<FileConfiguration
 187.778 -						Name="Release|Win32"
 187.779 -						>
 187.780 -						<Tool
 187.781 -							Name="VCCLCompilerTool"
 187.782 -							UsePrecompiledHeader="2"
 187.783 -						/>
 187.784 -					</FileConfiguration>
 187.785 -					<FileConfiguration
 187.786 -						Name="Debug|Win32"
 187.787 -						>
 187.788 -						<Tool
 187.789 -							Name="VCCLCompilerTool"
 187.790 -							UsePrecompiledHeader="2"
 187.791 -						/>
 187.792 -					</FileConfiguration>
 187.793 -				</File>
 187.794 -				<File
 187.795 -					RelativePath=".\CPP\7zip\Archive\7z\7zIn.cpp"
 187.796 -					>
 187.797 -					<FileConfiguration
 187.798 -						Name="Release|Win32"
 187.799 -						>
 187.800 -						<Tool
 187.801 -							Name="VCCLCompilerTool"
 187.802 -							UsePrecompiledHeader="2"
 187.803 -						/>
 187.804 -					</FileConfiguration>
 187.805 -					<FileConfiguration
 187.806 -						Name="Debug|Win32"
 187.807 -						>
 187.808 -						<Tool
 187.809 -							Name="VCCLCompilerTool"
 187.810 -							UsePrecompiledHeader="2"
 187.811 -						/>
 187.812 -					</FileConfiguration>
 187.813 -				</File>
 187.814 -				<File
 187.815 -					RelativePath=".\CPP\7zip\Archive\7z\7zProperties.cpp"
 187.816 -					>
 187.817 -					<FileConfiguration
 187.818 -						Name="Release|Win32"
 187.819 -						>
 187.820 -						<Tool
 187.821 -							Name="VCCLCompilerTool"
 187.822 -							UsePrecompiledHeader="2"
 187.823 -						/>
 187.824 -					</FileConfiguration>
 187.825 -					<FileConfiguration
 187.826 -						Name="Debug|Win32"
 187.827 -						>
 187.828 -						<Tool
 187.829 -							Name="VCCLCompilerTool"
 187.830 -							UsePrecompiledHeader="2"
 187.831 -						/>
 187.832 -					</FileConfiguration>
 187.833 -				</File>
 187.834 -				<File
 187.835 -					RelativePath=".\CPP\7zip\Archive\7z\7zSpecStream.cpp"
 187.836 -					>
 187.837 -					<FileConfiguration
 187.838 -						Name="Release|Win32"
 187.839 -						>
 187.840 -						<Tool
 187.841 -							Name="VCCLCompilerTool"
 187.842 -							UsePrecompiledHeader="2"
 187.843 -						/>
 187.844 -					</FileConfiguration>
 187.845 -					<FileConfiguration
 187.846 -						Name="Debug|Win32"
 187.847 -						>
 187.848 -						<Tool
 187.849 -							Name="VCCLCompilerTool"
 187.850 -							UsePrecompiledHeader="2"
 187.851 -						/>
 187.852 -					</FileConfiguration>
 187.853 -				</File>
 187.854 -			</Filter>
 187.855 -			<Filter
 187.856 -				Name="Rar"
 187.857 -				>
 187.858 -				<File
 187.859 -					RelativePath=".\CPP\7zip\Archive\Rar\RarHandler.cpp"
 187.860 -					>
 187.861 -					<FileConfiguration
 187.862 -						Name="Release|Win32"
 187.863 -						>
 187.864 -						<Tool
 187.865 -							Name="VCCLCompilerTool"
 187.866 -							UsePrecompiledHeader="2"
 187.867 -						/>
 187.868 -					</FileConfiguration>
 187.869 -					<FileConfiguration
 187.870 -						Name="Debug|Win32"
 187.871 -						>
 187.872 -						<Tool
 187.873 -							Name="VCCLCompilerTool"
 187.874 -							UsePrecompiledHeader="2"
 187.875 -						/>
 187.876 -					</FileConfiguration>
 187.877 -				</File>
 187.878 -				<File
 187.879 -					RelativePath=".\CPP\7zip\Archive\Rar\RarHeader.cpp"
 187.880 -					>
 187.881 -					<FileConfiguration
 187.882 -						Name="Release|Win32"
 187.883 -						>
 187.884 -						<Tool
 187.885 -							Name="VCCLCompilerTool"
 187.886 -							UsePrecompiledHeader="2"
 187.887 -						/>
 187.888 -					</FileConfiguration>
 187.889 -					<FileConfiguration
 187.890 -						Name="Debug|Win32"
 187.891 -						>
 187.892 -						<Tool
 187.893 -							Name="VCCLCompilerTool"
 187.894 -							UsePrecompiledHeader="2"
 187.895 -						/>
 187.896 -					</FileConfiguration>
 187.897 -				</File>
 187.898 -				<File
 187.899 -					RelativePath=".\CPP\7zip\Archive\Rar\RarIn.cpp"
 187.900 -					>
 187.901 -					<FileConfiguration
 187.902 -						Name="Release|Win32"
 187.903 -						>
 187.904 -						<Tool
 187.905 -							Name="VCCLCompilerTool"
 187.906 -							UsePrecompiledHeader="2"
 187.907 -						/>
 187.908 -					</FileConfiguration>
 187.909 -					<FileConfiguration
 187.910 -						Name="Debug|Win32"
 187.911 -						>
 187.912 -						<Tool
 187.913 -							Name="VCCLCompilerTool"
 187.914 -							UsePrecompiledHeader="2"
 187.915 -						/>
 187.916 -					</FileConfiguration>
 187.917 -				</File>
 187.918 -				<File
 187.919 -					RelativePath=".\CPP\7zip\Archive\Rar\RarItem.cpp"
 187.920 -					>
 187.921 -					<FileConfiguration
 187.922 -						Name="Release|Win32"
 187.923 -						>
 187.924 -						<Tool
 187.925 -							Name="VCCLCompilerTool"
 187.926 -							UsePrecompiledHeader="2"
 187.927 -						/>
 187.928 -					</FileConfiguration>
 187.929 -					<FileConfiguration
 187.930 -						Name="Debug|Win32"
 187.931 -						>
 187.932 -						<Tool
 187.933 -							Name="VCCLCompilerTool"
 187.934 -							UsePrecompiledHeader="2"
 187.935 -						/>
 187.936 -					</FileConfiguration>
 187.937 -				</File>
 187.938 -				<File
 187.939 -					RelativePath=".\CPP\7zip\Archive\Rar\RarVolumeInStream.cpp"
 187.940 -					>
 187.941 -					<FileConfiguration
 187.942 -						Name="Release|Win32"
 187.943 -						>
 187.944 -						<Tool
 187.945 -							Name="VCCLCompilerTool"
 187.946 -							UsePrecompiledHeader="2"
 187.947 -						/>
 187.948 -					</FileConfiguration>
 187.949 -					<FileConfiguration
 187.950 -						Name="Debug|Win32"
 187.951 -						>
 187.952 -						<Tool
 187.953 -							Name="VCCLCompilerTool"
 187.954 -							UsePrecompiledHeader="2"
 187.955 -						/>
 187.956 -					</FileConfiguration>
 187.957 -				</File>
 187.958 -			</Filter>
 187.959 -			<Filter
 187.960 -				Name="bz2"
 187.961 -				>
 187.962 -				<File
 187.963 -					RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Handler.cpp"
 187.964 -					>
 187.965 -					<FileConfiguration
 187.966 -						Name="Release|Win32"
 187.967 -						>
 187.968 -						<Tool
 187.969 -							Name="VCCLCompilerTool"
 187.970 -							UsePrecompiledHeader="2"
 187.971 -						/>
 187.972 -					</FileConfiguration>
 187.973 -					<FileConfiguration
 187.974 -						Name="Debug|Win32"
 187.975 -						>
 187.976 -						<Tool
 187.977 -							Name="VCCLCompilerTool"
 187.978 -							UsePrecompiledHeader="2"
 187.979 -						/>
 187.980 -					</FileConfiguration>
 187.981 -				</File>
 187.982 -			</Filter>
 187.983 -			<Filter
 187.984 -				Name="Archive common"
 187.985 -				>
 187.986 -				<File
 187.987 -					RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2.cpp"
 187.988 -					>
 187.989 -					<FileConfiguration
 187.990 -						Name="Release|Win32"
 187.991 -						>
 187.992 -						<Tool
 187.993 -							Name="VCCLCompilerTool"
 187.994 -							UsePrecompiledHeader="2"
 187.995 -						/>
 187.996 -					</FileConfiguration>
 187.997 -					<FileConfiguration
 187.998 -						Name="Debug|Win32"
 187.999 -						>
187.1000 -						<Tool
187.1001 -							Name="VCCLCompilerTool"
187.1002 -							UsePrecompiledHeader="2"
187.1003 -						/>
187.1004 -					</FileConfiguration>
187.1005 -				</File>
187.1006 -				<File
187.1007 -					RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2MT.cpp"
187.1008 -					>
187.1009 -					<FileConfiguration
187.1010 -						Name="Release|Win32"
187.1011 -						>
187.1012 -						<Tool
187.1013 -							Name="VCCLCompilerTool"
187.1014 -							UsePrecompiledHeader="2"
187.1015 -						/>
187.1016 -					</FileConfiguration>
187.1017 -					<FileConfiguration
187.1018 -						Name="Debug|Win32"
187.1019 -						>
187.1020 -						<Tool
187.1021 -							Name="VCCLCompilerTool"
187.1022 -							UsePrecompiledHeader="2"
187.1023 -						/>
187.1024 -					</FileConfiguration>
187.1025 -				</File>
187.1026 -				<File
187.1027 -					RelativePath=".\CPP\7zip\Archive\Common\DummyOutStream.cpp"
187.1028 -					>
187.1029 -					<FileConfiguration
187.1030 -						Name="Release|Win32"
187.1031 -						>
187.1032 -						<Tool
187.1033 -							Name="VCCLCompilerTool"
187.1034 -							UsePrecompiledHeader="2"
187.1035 -						/>
187.1036 -					</FileConfiguration>
187.1037 -					<FileConfiguration
187.1038 -						Name="Debug|Win32"
187.1039 -						>
187.1040 -						<Tool
187.1041 -							Name="VCCLCompilerTool"
187.1042 -							UsePrecompiledHeader="2"
187.1043 -						/>
187.1044 -					</FileConfiguration>
187.1045 -				</File>
187.1046 -				<File
187.1047 -					RelativePath=".\CPP\7zip\Archive\Common\FindSignature.cpp"
187.1048 -					>
187.1049 -					<FileConfiguration
187.1050 -						Name="Release|Win32"
187.1051 -						>
187.1052 -						<Tool
187.1053 -							Name="VCCLCompilerTool"
187.1054 -							UsePrecompiledHeader="2"
187.1055 -						/>
187.1056 -					</FileConfiguration>
187.1057 -					<FileConfiguration
187.1058 -						Name="Debug|Win32"
187.1059 -						>
187.1060 -						<Tool
187.1061 -							Name="VCCLCompilerTool"
187.1062 -							UsePrecompiledHeader="2"
187.1063 -						/>
187.1064 -					</FileConfiguration>
187.1065 -				</File>
187.1066 -				<File
187.1067 -					RelativePath=".\CPP\7zip\Archive\Common\InStreamWithCRC.cpp"
187.1068 -					>
187.1069 -					<FileConfiguration
187.1070 -						Name="Release|Win32"
187.1071 -						>
187.1072 -						<Tool
187.1073 -							Name="VCCLCompilerTool"
187.1074 -							UsePrecompiledHeader="2"
187.1075 -						/>
187.1076 -					</FileConfiguration>
187.1077 -					<FileConfiguration
187.1078 -						Name="Debug|Win32"
187.1079 -						>
187.1080 -						<Tool
187.1081 -							Name="VCCLCompilerTool"
187.1082 -							UsePrecompiledHeader="2"
187.1083 -						/>
187.1084 -					</FileConfiguration>
187.1085 -				</File>
187.1086 -				<File
187.1087 -					RelativePath=".\CPP\7zip\Archive\Common\ItemNameUtils.cpp"
187.1088 -					>
187.1089 -					<FileConfiguration
187.1090 -						Name="Release|Win32"
187.1091 -						>
187.1092 -						<Tool
187.1093 -							Name="VCCLCompilerTool"
187.1094 -							UsePrecompiledHeader="2"
187.1095 -						/>
187.1096 -					</FileConfiguration>
187.1097 -					<FileConfiguration
187.1098 -						Name="Debug|Win32"
187.1099 -						>
187.1100 -						<Tool
187.1101 -							Name="VCCLCompilerTool"
187.1102 -							UsePrecompiledHeader="2"
187.1103 -						/>
187.1104 -					</FileConfiguration>
187.1105 -				</File>
187.1106 -				<File
187.1107 -					RelativePath=".\CPP\7zip\Archive\Common\MultiStream.cpp"
187.1108 -					>
187.1109 -					<FileConfiguration
187.1110 -						Name="Release|Win32"
187.1111 -						>
187.1112 -						<Tool
187.1113 -							Name="VCCLCompilerTool"
187.1114 -							UsePrecompiledHeader="2"
187.1115 -						/>
187.1116 -					</FileConfiguration>
187.1117 -					<FileConfiguration
187.1118 -						Name="Debug|Win32"
187.1119 -						>
187.1120 -						<Tool
187.1121 -							Name="VCCLCompilerTool"
187.1122 -							UsePrecompiledHeader="2"
187.1123 -						/>
187.1124 -					</FileConfiguration>
187.1125 -				</File>
187.1126 -				<File
187.1127 -					RelativePath=".\CPP\7zip\Archive\Common\OutStreamWithCRC.cpp"
187.1128 -					>
187.1129 -					<FileConfiguration
187.1130 -						Name="Release|Win32"
187.1131 -						>
187.1132 -						<Tool
187.1133 -							Name="VCCLCompilerTool"
187.1134 -							UsePrecompiledHeader="2"
187.1135 -						/>
187.1136 -					</FileConfiguration>
187.1137 -					<FileConfiguration
187.1138 -						Name="Debug|Win32"
187.1139 -						>
187.1140 -						<Tool
187.1141 -							Name="VCCLCompilerTool"
187.1142 -							UsePrecompiledHeader="2"
187.1143 -						/>
187.1144 -					</FileConfiguration>
187.1145 -				</File>
187.1146 -				<File
187.1147 -					RelativePath=".\CPP\7zip\Archive\Common\ParseProperties.cpp"
187.1148 -					>
187.1149 -					<FileConfiguration
187.1150 -						Name="Release|Win32"
187.1151 -						>
187.1152 -						<Tool
187.1153 -							Name="VCCLCompilerTool"
187.1154 -							UsePrecompiledHeader="2"
187.1155 -						/>
187.1156 -					</FileConfiguration>
187.1157 -					<FileConfiguration
187.1158 -						Name="Debug|Win32"
187.1159 -						>
187.1160 -						<Tool
187.1161 -							Name="VCCLCompilerTool"
187.1162 -							UsePrecompiledHeader="2"
187.1163 -						/>
187.1164 -					</FileConfiguration>
187.1165 -				</File>
187.1166 -			</Filter>
187.1167 -			<Filter
187.1168 -				Name="GZip"
187.1169 -				>
187.1170 -				<File
187.1171 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipHandler.cpp"
187.1172 -					>
187.1173 -					<FileConfiguration
187.1174 -						Name="Release|Win32"
187.1175 -						>
187.1176 -						<Tool
187.1177 -							Name="VCCLCompilerTool"
187.1178 -							UsePrecompiledHeader="2"
187.1179 -						/>
187.1180 -					</FileConfiguration>
187.1181 -					<FileConfiguration
187.1182 -						Name="Debug|Win32"
187.1183 -						>
187.1184 -						<Tool
187.1185 -							Name="VCCLCompilerTool"
187.1186 -							UsePrecompiledHeader="2"
187.1187 -						/>
187.1188 -					</FileConfiguration>
187.1189 -				</File>
187.1190 -				<File
187.1191 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipHeader.cpp"
187.1192 -					>
187.1193 -					<FileConfiguration
187.1194 -						Name="Release|Win32"
187.1195 -						>
187.1196 -						<Tool
187.1197 -							Name="VCCLCompilerTool"
187.1198 -							UsePrecompiledHeader="2"
187.1199 -						/>
187.1200 -					</FileConfiguration>
187.1201 -					<FileConfiguration
187.1202 -						Name="Debug|Win32"
187.1203 -						>
187.1204 -						<Tool
187.1205 -							Name="VCCLCompilerTool"
187.1206 -							UsePrecompiledHeader="2"
187.1207 -						/>
187.1208 -					</FileConfiguration>
187.1209 -				</File>
187.1210 -				<File
187.1211 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipIn.cpp"
187.1212 -					>
187.1213 -					<FileConfiguration
187.1214 -						Name="Release|Win32"
187.1215 -						>
187.1216 -						<Tool
187.1217 -							Name="VCCLCompilerTool"
187.1218 -							UsePrecompiledHeader="2"
187.1219 -						/>
187.1220 -					</FileConfiguration>
187.1221 -					<FileConfiguration
187.1222 -						Name="Debug|Win32"
187.1223 -						>
187.1224 -						<Tool
187.1225 -							Name="VCCLCompilerTool"
187.1226 -							UsePrecompiledHeader="2"
187.1227 -						/>
187.1228 -					</FileConfiguration>
187.1229 -				</File>
187.1230 -			</Filter>
187.1231 -			<Filter
187.1232 -				Name="Lzh"
187.1233 -				>
187.1234 -				<File
187.1235 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhCRC.cpp"
187.1236 -					>
187.1237 -					<FileConfiguration
187.1238 -						Name="Release|Win32"
187.1239 -						>
187.1240 -						<Tool
187.1241 -							Name="VCCLCompilerTool"
187.1242 -							UsePrecompiledHeader="2"
187.1243 -						/>
187.1244 -					</FileConfiguration>
187.1245 -					<FileConfiguration
187.1246 -						Name="Debug|Win32"
187.1247 -						>
187.1248 -						<Tool
187.1249 -							Name="VCCLCompilerTool"
187.1250 -							UsePrecompiledHeader="2"
187.1251 -						/>
187.1252 -					</FileConfiguration>
187.1253 -				</File>
187.1254 -				<File
187.1255 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhHandler.cpp"
187.1256 -					>
187.1257 -					<FileConfiguration
187.1258 -						Name="Release|Win32"
187.1259 -						>
187.1260 -						<Tool
187.1261 -							Name="VCCLCompilerTool"
187.1262 -							UsePrecompiledHeader="2"
187.1263 -						/>
187.1264 -					</FileConfiguration>
187.1265 -					<FileConfiguration
187.1266 -						Name="Debug|Win32"
187.1267 -						>
187.1268 -						<Tool
187.1269 -							Name="VCCLCompilerTool"
187.1270 -							UsePrecompiledHeader="2"
187.1271 -						/>
187.1272 -					</FileConfiguration>
187.1273 -				</File>
187.1274 -				<File
187.1275 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhIn.cpp"
187.1276 -					>
187.1277 -					<FileConfiguration
187.1278 -						Name="Release|Win32"
187.1279 -						>
187.1280 -						<Tool
187.1281 -							Name="VCCLCompilerTool"
187.1282 -							UsePrecompiledHeader="2"
187.1283 -						/>
187.1284 -					</FileConfiguration>
187.1285 -					<FileConfiguration
187.1286 -						Name="Debug|Win32"
187.1287 -						>
187.1288 -						<Tool
187.1289 -							Name="VCCLCompilerTool"
187.1290 -							UsePrecompiledHeader="2"
187.1291 -						/>
187.1292 -					</FileConfiguration>
187.1293 -				</File>
187.1294 -				<File
187.1295 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.cpp"
187.1296 -					>
187.1297 -					<FileConfiguration
187.1298 -						Name="Release|Win32"
187.1299 -						>
187.1300 -						<Tool
187.1301 -							Name="VCCLCompilerTool"
187.1302 -							UsePrecompiledHeader="2"
187.1303 -						/>
187.1304 -					</FileConfiguration>
187.1305 -					<FileConfiguration
187.1306 -						Name="Debug|Win32"
187.1307 -						>
187.1308 -						<Tool
187.1309 -							Name="VCCLCompilerTool"
187.1310 -							UsePrecompiledHeader="2"
187.1311 -						/>
187.1312 -					</FileConfiguration>
187.1313 -				</File>
187.1314 -			</Filter>
187.1315 -			<Filter
187.1316 -				Name="Split"
187.1317 -				>
187.1318 -				<File
187.1319 -					RelativePath=".\CPP\7zip\Archive\Split\SplitHandler.cpp"
187.1320 -					>
187.1321 -					<FileConfiguration
187.1322 -						Name="Release|Win32"
187.1323 -						>
187.1324 -						<Tool
187.1325 -							Name="VCCLCompilerTool"
187.1326 -							UsePrecompiledHeader="2"
187.1327 -						/>
187.1328 -					</FileConfiguration>
187.1329 -					<FileConfiguration
187.1330 -						Name="Debug|Win32"
187.1331 -						>
187.1332 -						<Tool
187.1333 -							Name="VCCLCompilerTool"
187.1334 -							UsePrecompiledHeader="2"
187.1335 -						/>
187.1336 -					</FileConfiguration>
187.1337 -				</File>
187.1338 -			</Filter>
187.1339 -			<Filter
187.1340 -				Name="Tar"
187.1341 -				>
187.1342 -				<File
187.1343 -					RelativePath=".\CPP\7zip\Archive\Tar\TarHandler.cpp"
187.1344 -					>
187.1345 -					<FileConfiguration
187.1346 -						Name="Release|Win32"
187.1347 -						>
187.1348 -						<Tool
187.1349 -							Name="VCCLCompilerTool"
187.1350 -							UsePrecompiledHeader="2"
187.1351 -						/>
187.1352 -					</FileConfiguration>
187.1353 -					<FileConfiguration
187.1354 -						Name="Debug|Win32"
187.1355 -						>
187.1356 -						<Tool
187.1357 -							Name="VCCLCompilerTool"
187.1358 -							UsePrecompiledHeader="2"
187.1359 -						/>
187.1360 -					</FileConfiguration>
187.1361 -				</File>
187.1362 -				<File
187.1363 -					RelativePath=".\CPP\7zip\Archive\Tar\TarHeader.cpp"
187.1364 -					>
187.1365 -					<FileConfiguration
187.1366 -						Name="Release|Win32"
187.1367 -						>
187.1368 -						<Tool
187.1369 -							Name="VCCLCompilerTool"
187.1370 -							UsePrecompiledHeader="2"
187.1371 -						/>
187.1372 -					</FileConfiguration>
187.1373 -					<FileConfiguration
187.1374 -						Name="Debug|Win32"
187.1375 -						>
187.1376 -						<Tool
187.1377 -							Name="VCCLCompilerTool"
187.1378 -							UsePrecompiledHeader="2"
187.1379 -						/>
187.1380 -					</FileConfiguration>
187.1381 -				</File>
187.1382 -				<File
187.1383 -					RelativePath=".\CPP\7zip\Archive\Tar\TarIn.cpp"
187.1384 -					>
187.1385 -					<FileConfiguration
187.1386 -						Name="Release|Win32"
187.1387 -						>
187.1388 -						<Tool
187.1389 -							Name="VCCLCompilerTool"
187.1390 -							UsePrecompiledHeader="2"
187.1391 -						/>
187.1392 -					</FileConfiguration>
187.1393 -					<FileConfiguration
187.1394 -						Name="Debug|Win32"
187.1395 -						>
187.1396 -						<Tool
187.1397 -							Name="VCCLCompilerTool"
187.1398 -							UsePrecompiledHeader="2"
187.1399 -						/>
187.1400 -					</FileConfiguration>
187.1401 -				</File>
187.1402 -			</Filter>
187.1403 -			<Filter
187.1404 -				Name="Zip"
187.1405 -				>
187.1406 -				<File
187.1407 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipHandler.cpp"
187.1408 -					>
187.1409 -					<FileConfiguration
187.1410 -						Name="Release|Win32"
187.1411 -						>
187.1412 -						<Tool
187.1413 -							Name="VCCLCompilerTool"
187.1414 -							UsePrecompiledHeader="2"
187.1415 -						/>
187.1416 -					</FileConfiguration>
187.1417 -					<FileConfiguration
187.1418 -						Name="Debug|Win32"
187.1419 -						>
187.1420 -						<Tool
187.1421 -							Name="VCCLCompilerTool"
187.1422 -							UsePrecompiledHeader="2"
187.1423 -						/>
187.1424 -					</FileConfiguration>
187.1425 -				</File>
187.1426 -				<File
187.1427 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipHeader.cpp"
187.1428 -					>
187.1429 -					<FileConfiguration
187.1430 -						Name="Release|Win32"
187.1431 -						>
187.1432 -						<Tool
187.1433 -							Name="VCCLCompilerTool"
187.1434 -							UsePrecompiledHeader="2"
187.1435 -						/>
187.1436 -					</FileConfiguration>
187.1437 -					<FileConfiguration
187.1438 -						Name="Debug|Win32"
187.1439 -						>
187.1440 -						<Tool
187.1441 -							Name="VCCLCompilerTool"
187.1442 -							UsePrecompiledHeader="2"
187.1443 -						/>
187.1444 -					</FileConfiguration>
187.1445 -				</File>
187.1446 -				<File
187.1447 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipIn.cpp"
187.1448 -					>
187.1449 -					<FileConfiguration
187.1450 -						Name="Release|Win32"
187.1451 -						>
187.1452 -						<Tool
187.1453 -							Name="VCCLCompilerTool"
187.1454 -							UsePrecompiledHeader="2"
187.1455 -						/>
187.1456 -					</FileConfiguration>
187.1457 -					<FileConfiguration
187.1458 -						Name="Debug|Win32"
187.1459 -						>
187.1460 -						<Tool
187.1461 -							Name="VCCLCompilerTool"
187.1462 -							UsePrecompiledHeader="2"
187.1463 -						/>
187.1464 -					</FileConfiguration>
187.1465 -				</File>
187.1466 -				<File
187.1467 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipItem.cpp"
187.1468 -					>
187.1469 -					<FileConfiguration
187.1470 -						Name="Release|Win32"
187.1471 -						>
187.1472 -						<Tool
187.1473 -							Name="VCCLCompilerTool"
187.1474 -							UsePrecompiledHeader="2"
187.1475 -						/>
187.1476 -					</FileConfiguration>
187.1477 -					<FileConfiguration
187.1478 -						Name="Debug|Win32"
187.1479 -						>
187.1480 -						<Tool
187.1481 -							Name="VCCLCompilerTool"
187.1482 -							UsePrecompiledHeader="2"
187.1483 -						/>
187.1484 -					</FileConfiguration>
187.1485 -				</File>
187.1486 -			</Filter>
187.1487 -			<Filter
187.1488 -				Name="Lzma Ar"
187.1489 -				>
187.1490 -				<File
187.1491 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaFiltersDecode.cpp"
187.1492 -					>
187.1493 -					<FileConfiguration
187.1494 -						Name="Release|Win32"
187.1495 -						>
187.1496 -						<Tool
187.1497 -							Name="VCCLCompilerTool"
187.1498 -							UsePrecompiledHeader="2"
187.1499 -						/>
187.1500 -					</FileConfiguration>
187.1501 -					<FileConfiguration
187.1502 -						Name="Debug|Win32"
187.1503 -						>
187.1504 -						<Tool
187.1505 -							Name="VCCLCompilerTool"
187.1506 -							UsePrecompiledHeader="2"
187.1507 -						/>
187.1508 -					</FileConfiguration>
187.1509 -				</File>
187.1510 -				<File
187.1511 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaHandler.cpp"
187.1512 -					>
187.1513 -					<FileConfiguration
187.1514 -						Name="Release|Win32"
187.1515 -						>
187.1516 -						<Tool
187.1517 -							Name="VCCLCompilerTool"
187.1518 -							UsePrecompiledHeader="2"
187.1519 -						/>
187.1520 -					</FileConfiguration>
187.1521 -					<FileConfiguration
187.1522 -						Name="Debug|Win32"
187.1523 -						>
187.1524 -						<Tool
187.1525 -							Name="VCCLCompilerTool"
187.1526 -							UsePrecompiledHeader="2"
187.1527 -						/>
187.1528 -					</FileConfiguration>
187.1529 -				</File>
187.1530 -				<File
187.1531 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaIn.cpp"
187.1532 -					>
187.1533 -					<FileConfiguration
187.1534 -						Name="Release|Win32"
187.1535 -						>
187.1536 -						<Tool
187.1537 -							Name="VCCLCompilerTool"
187.1538 -							UsePrecompiledHeader="2"
187.1539 -						/>
187.1540 -					</FileConfiguration>
187.1541 -					<FileConfiguration
187.1542 -						Name="Debug|Win32"
187.1543 -						>
187.1544 -						<Tool
187.1545 -							Name="VCCLCompilerTool"
187.1546 -							UsePrecompiledHeader="2"
187.1547 -						/>
187.1548 -					</FileConfiguration>
187.1549 -				</File>
187.1550 -			</Filter>
187.1551 -		</Filter>
187.1552 -		<Filter
187.1553 -			Name="C"
187.1554 -			>
187.1555 -			<File
187.1556 -				RelativePath=".\C\7zCrc.c"
187.1557 -				>
187.1558 -				<FileConfiguration
187.1559 -					Name="Release|Win32"
187.1560 -					>
187.1561 -					<Tool
187.1562 -						Name="VCCLCompilerTool"
187.1563 -						UsePrecompiledHeader="0"
187.1564 -					/>
187.1565 -				</FileConfiguration>
187.1566 -				<FileConfiguration
187.1567 -					Name="Debug|Win32"
187.1568 -					>
187.1569 -					<Tool
187.1570 -						Name="VCCLCompilerTool"
187.1571 -						UsePrecompiledHeader="0"
187.1572 -					/>
187.1573 -				</FileConfiguration>
187.1574 -			</File>
187.1575 -			<File
187.1576 -				RelativePath=".\C\Aes.c"
187.1577 -				>
187.1578 -				<FileConfiguration
187.1579 -					Name="Release|Win32"
187.1580 -					>
187.1581 -					<Tool
187.1582 -						Name="VCCLCompilerTool"
187.1583 -						UsePrecompiledHeader="0"
187.1584 -					/>
187.1585 -				</FileConfiguration>
187.1586 -				<FileConfiguration
187.1587 -					Name="Debug|Win32"
187.1588 -					>
187.1589 -					<Tool
187.1590 -						Name="VCCLCompilerTool"
187.1591 -						UsePrecompiledHeader="0"
187.1592 -					/>
187.1593 -				</FileConfiguration>
187.1594 -			</File>
187.1595 -			<File
187.1596 -				RelativePath=".\C\Alloc.c"
187.1597 -				>
187.1598 -				<FileConfiguration
187.1599 -					Name="Release|Win32"
187.1600 -					>
187.1601 -					<Tool
187.1602 -						Name="VCCLCompilerTool"
187.1603 -						UsePrecompiledHeader="0"
187.1604 -					/>
187.1605 -				</FileConfiguration>
187.1606 -				<FileConfiguration
187.1607 -					Name="Debug|Win32"
187.1608 -					>
187.1609 -					<Tool
187.1610 -						Name="VCCLCompilerTool"
187.1611 -						UsePrecompiledHeader="0"
187.1612 -					/>
187.1613 -				</FileConfiguration>
187.1614 -			</File>
187.1615 -			<File
187.1616 -				RelativePath=".\C\Bra.c"
187.1617 -				>
187.1618 -				<FileConfiguration
187.1619 -					Name="Release|Win32"
187.1620 -					>
187.1621 -					<Tool
187.1622 -						Name="VCCLCompilerTool"
187.1623 -						UsePrecompiledHeader="0"
187.1624 -					/>
187.1625 -				</FileConfiguration>
187.1626 -				<FileConfiguration
187.1627 -					Name="Debug|Win32"
187.1628 -					>
187.1629 -					<Tool
187.1630 -						Name="VCCLCompilerTool"
187.1631 -						UsePrecompiledHeader="0"
187.1632 -					/>
187.1633 -				</FileConfiguration>
187.1634 -			</File>
187.1635 -			<File
187.1636 -				RelativePath=".\C\Bra86.c"
187.1637 -				>
187.1638 -				<FileConfiguration
187.1639 -					Name="Release|Win32"
187.1640 -					>
187.1641 -					<Tool
187.1642 -						Name="VCCLCompilerTool"
187.1643 -						UsePrecompiledHeader="0"
187.1644 -					/>
187.1645 -				</FileConfiguration>
187.1646 -				<FileConfiguration
187.1647 -					Name="Debug|Win32"
187.1648 -					>
187.1649 -					<Tool
187.1650 -						Name="VCCLCompilerTool"
187.1651 -						UsePrecompiledHeader="0"
187.1652 -					/>
187.1653 -				</FileConfiguration>
187.1654 -			</File>
187.1655 -			<File
187.1656 -				RelativePath=".\C\BraIA64.c"
187.1657 -				>
187.1658 -				<FileConfiguration
187.1659 -					Name="Release|Win32"
187.1660 -					>
187.1661 -					<Tool
187.1662 -						Name="VCCLCompilerTool"
187.1663 -						UsePrecompiledHeader="0"
187.1664 -					/>
187.1665 -				</FileConfiguration>
187.1666 -				<FileConfiguration
187.1667 -					Name="Debug|Win32"
187.1668 -					>
187.1669 -					<Tool
187.1670 -						Name="VCCLCompilerTool"
187.1671 -						UsePrecompiledHeader="0"
187.1672 -					/>
187.1673 -				</FileConfiguration>
187.1674 -			</File>
187.1675 -			<File
187.1676 -				RelativePath=".\C\BwtSort.c"
187.1677 -				>
187.1678 -				<FileConfiguration
187.1679 -					Name="Release|Win32"
187.1680 -					>
187.1681 -					<Tool
187.1682 -						Name="VCCLCompilerTool"
187.1683 -						UsePrecompiledHeader="0"
187.1684 -					/>
187.1685 -				</FileConfiguration>
187.1686 -				<FileConfiguration
187.1687 -					Name="Debug|Win32"
187.1688 -					>
187.1689 -					<Tool
187.1690 -						Name="VCCLCompilerTool"
187.1691 -						UsePrecompiledHeader="0"
187.1692 -					/>
187.1693 -				</FileConfiguration>
187.1694 -			</File>
187.1695 -			<File
187.1696 -				RelativePath=".\C\HuffEnc.c"
187.1697 -				>
187.1698 -				<FileConfiguration
187.1699 -					Name="Release|Win32"
187.1700 -					>
187.1701 -					<Tool
187.1702 -						Name="VCCLCompilerTool"
187.1703 -						UsePrecompiledHeader="0"
187.1704 -					/>
187.1705 -				</FileConfiguration>
187.1706 -				<FileConfiguration
187.1707 -					Name="Debug|Win32"
187.1708 -					>
187.1709 -					<Tool
187.1710 -						Name="VCCLCompilerTool"
187.1711 -						UsePrecompiledHeader="0"
187.1712 -					/>
187.1713 -				</FileConfiguration>
187.1714 -			</File>
187.1715 -			<File
187.1716 -				RelativePath=".\C\LzFind.c"
187.1717 -				>
187.1718 -				<FileConfiguration
187.1719 -					Name="Release|Win32"
187.1720 -					>
187.1721 -					<Tool
187.1722 -						Name="VCCLCompilerTool"
187.1723 -						UsePrecompiledHeader="0"
187.1724 -					/>
187.1725 -				</FileConfiguration>
187.1726 -				<FileConfiguration
187.1727 -					Name="Debug|Win32"
187.1728 -					>
187.1729 -					<Tool
187.1730 -						Name="VCCLCompilerTool"
187.1731 -						UsePrecompiledHeader="0"
187.1732 -					/>
187.1733 -				</FileConfiguration>
187.1734 -			</File>
187.1735 -			<File
187.1736 -				RelativePath=".\C\LzFindMt.c"
187.1737 -				>
187.1738 -				<FileConfiguration
187.1739 -					Name="Release|Win32"
187.1740 -					>
187.1741 -					<Tool
187.1742 -						Name="VCCLCompilerTool"
187.1743 -						UsePrecompiledHeader="0"
187.1744 -					/>
187.1745 -				</FileConfiguration>
187.1746 -				<FileConfiguration
187.1747 -					Name="Debug|Win32"
187.1748 -					>
187.1749 -					<Tool
187.1750 -						Name="VCCLCompilerTool"
187.1751 -						UsePrecompiledHeader="0"
187.1752 -					/>
187.1753 -				</FileConfiguration>
187.1754 -			</File>
187.1755 -			<File
187.1756 -				RelativePath=".\C\LzmaDec.c"
187.1757 -				>
187.1758 -				<FileConfiguration
187.1759 -					Name="Release|Win32"
187.1760 -					>
187.1761 -					<Tool
187.1762 -						Name="VCCLCompilerTool"
187.1763 -						UsePrecompiledHeader="0"
187.1764 -					/>
187.1765 -				</FileConfiguration>
187.1766 -				<FileConfiguration
187.1767 -					Name="Debug|Win32"
187.1768 -					>
187.1769 -					<Tool
187.1770 -						Name="VCCLCompilerTool"
187.1771 -						UsePrecompiledHeader="0"
187.1772 -					/>
187.1773 -				</FileConfiguration>
187.1774 -			</File>
187.1775 -			<File
187.1776 -				RelativePath=".\C\LzmaEnc.c"
187.1777 -				>
187.1778 -				<FileConfiguration
187.1779 -					Name="Release|Win32"
187.1780 -					>
187.1781 -					<Tool
187.1782 -						Name="VCCLCompilerTool"
187.1783 -						UsePrecompiledHeader="0"
187.1784 -					/>
187.1785 -				</FileConfiguration>
187.1786 -				<FileConfiguration
187.1787 -					Name="Debug|Win32"
187.1788 -					>
187.1789 -					<Tool
187.1790 -						Name="VCCLCompilerTool"
187.1791 -						UsePrecompiledHeader="0"
187.1792 -					/>
187.1793 -				</FileConfiguration>
187.1794 -			</File>
187.1795 -			<File
187.1796 -				RelativePath=".\C\Sha256.c"
187.1797 -				>
187.1798 -				<FileConfiguration
187.1799 -					Name="Release|Win32"
187.1800 -					>
187.1801 -					<Tool
187.1802 -						Name="VCCLCompilerTool"
187.1803 -						UsePrecompiledHeader="0"
187.1804 -					/>
187.1805 -				</FileConfiguration>
187.1806 -				<FileConfiguration
187.1807 -					Name="Debug|Win32"
187.1808 -					>
187.1809 -					<Tool
187.1810 -						Name="VCCLCompilerTool"
187.1811 -						UsePrecompiledHeader="0"
187.1812 -					/>
187.1813 -				</FileConfiguration>
187.1814 -			</File>
187.1815 -			<File
187.1816 -				RelativePath=".\C\Sort.c"
187.1817 -				>
187.1818 -				<FileConfiguration
187.1819 -					Name="Release|Win32"
187.1820 -					>
187.1821 -					<Tool
187.1822 -						Name="VCCLCompilerTool"
187.1823 -						UsePrecompiledHeader="0"
187.1824 -					/>
187.1825 -				</FileConfiguration>
187.1826 -				<FileConfiguration
187.1827 -					Name="Debug|Win32"
187.1828 -					>
187.1829 -					<Tool
187.1830 -						Name="VCCLCompilerTool"
187.1831 -						UsePrecompiledHeader="0"
187.1832 -					/>
187.1833 -				</FileConfiguration>
187.1834 -			</File>
187.1835 -			<File
187.1836 -				RelativePath=".\C\Threads.c"
187.1837 -				>
187.1838 -				<FileConfiguration
187.1839 -					Name="Release|Win32"
187.1840 -					>
187.1841 -					<Tool
187.1842 -						Name="VCCLCompilerTool"
187.1843 -						UsePrecompiledHeader="0"
187.1844 -					/>
187.1845 -				</FileConfiguration>
187.1846 -				<FileConfiguration
187.1847 -					Name="Debug|Win32"
187.1848 -					>
187.1849 -					<Tool
187.1850 -						Name="VCCLCompilerTool"
187.1851 -						UsePrecompiledHeader="0"
187.1852 -					/>
187.1853 -				</FileConfiguration>
187.1854 -			</File>
187.1855 -		</Filter>
187.1856 -		<Filter
187.1857 -			Name="Common"
187.1858 -			>
187.1859 -			<File
187.1860 -				RelativePath=".\CPP\Common\CRC.cpp"
187.1861 -				>
187.1862 -				<FileConfiguration
187.1863 -					Name="Release|Win32"
187.1864 -					>
187.1865 -					<Tool
187.1866 -						Name="VCCLCompilerTool"
187.1867 -						UsePrecompiledHeader="2"
187.1868 -					/>
187.1869 -				</FileConfiguration>
187.1870 -				<FileConfiguration
187.1871 -					Name="Debug|Win32"
187.1872 -					>
187.1873 -					<Tool
187.1874 -						Name="VCCLCompilerTool"
187.1875 -						UsePrecompiledHeader="2"
187.1876 -					/>
187.1877 -				</FileConfiguration>
187.1878 -			</File>
187.1879 -			<File
187.1880 -				RelativePath=".\CPP\Common\IntToString.cpp"
187.1881 -				>
187.1882 -				<FileConfiguration
187.1883 -					Name="Release|Win32"
187.1884 -					>
187.1885 -					<Tool
187.1886 -						Name="VCCLCompilerTool"
187.1887 -						UsePrecompiledHeader="2"
187.1888 -					/>
187.1889 -				</FileConfiguration>
187.1890 -				<FileConfiguration
187.1891 -					Name="Debug|Win32"
187.1892 -					>
187.1893 -					<Tool
187.1894 -						Name="VCCLCompilerTool"
187.1895 -						UsePrecompiledHeader="2"
187.1896 -					/>
187.1897 -				</FileConfiguration>
187.1898 -			</File>
187.1899 -			<File
187.1900 -				RelativePath=".\CPP\Common\MyMap.cpp"
187.1901 -				>
187.1902 -				<FileConfiguration
187.1903 -					Name="Release|Win32"
187.1904 -					>
187.1905 -					<Tool
187.1906 -						Name="VCCLCompilerTool"
187.1907 -						UsePrecompiledHeader="2"
187.1908 -					/>
187.1909 -				</FileConfiguration>
187.1910 -				<FileConfiguration
187.1911 -					Name="Debug|Win32"
187.1912 -					>
187.1913 -					<Tool
187.1914 -						Name="VCCLCompilerTool"
187.1915 -						UsePrecompiledHeader="2"
187.1916 -					/>
187.1917 -				</FileConfiguration>
187.1918 -			</File>
187.1919 -			<File
187.1920 -				RelativePath=".\CPP\Common\MyString.cpp"
187.1921 -				>
187.1922 -				<FileConfiguration
187.1923 -					Name="Release|Win32"
187.1924 -					>
187.1925 -					<Tool
187.1926 -						Name="VCCLCompilerTool"
187.1927 -						UsePrecompiledHeader="2"
187.1928 -					/>
187.1929 -				</FileConfiguration>
187.1930 -				<FileConfiguration
187.1931 -					Name="Debug|Win32"
187.1932 -					>
187.1933 -					<Tool
187.1934 -						Name="VCCLCompilerTool"
187.1935 -						UsePrecompiledHeader="2"
187.1936 -					/>
187.1937 -				</FileConfiguration>
187.1938 -			</File>
187.1939 -			<File
187.1940 -				RelativePath=".\CPP\Common\MyVector.cpp"
187.1941 -				>
187.1942 -				<FileConfiguration
187.1943 -					Name="Release|Win32"
187.1944 -					>
187.1945 -					<Tool
187.1946 -						Name="VCCLCompilerTool"
187.1947 -						UsePrecompiledHeader="2"
187.1948 -					/>
187.1949 -				</FileConfiguration>
187.1950 -				<FileConfiguration
187.1951 -					Name="Debug|Win32"
187.1952 -					>
187.1953 -					<Tool
187.1954 -						Name="VCCLCompilerTool"
187.1955 -						UsePrecompiledHeader="2"
187.1956 -					/>
187.1957 -				</FileConfiguration>
187.1958 -			</File>
187.1959 -			<File
187.1960 -				RelativePath=".\CPP\Common\MyXml.cpp"
187.1961 -				>
187.1962 -				<FileConfiguration
187.1963 -					Name="Release|Win32"
187.1964 -					>
187.1965 -					<Tool
187.1966 -						Name="VCCLCompilerTool"
187.1967 -						UsePrecompiledHeader="2"
187.1968 -					/>
187.1969 -				</FileConfiguration>
187.1970 -				<FileConfiguration
187.1971 -					Name="Debug|Win32"
187.1972 -					>
187.1973 -					<Tool
187.1974 -						Name="VCCLCompilerTool"
187.1975 -						UsePrecompiledHeader="2"
187.1976 -					/>
187.1977 -				</FileConfiguration>
187.1978 -			</File>
187.1979 -			<File
187.1980 -				RelativePath=".\CPP\Common\NewHandler.cpp"
187.1981 -				>
187.1982 -				<FileConfiguration
187.1983 -					Name="Release|Win32"
187.1984 -					ExcludedFromBuild="true"
187.1985 -					>
187.1986 -					<Tool
187.1987 -						Name="VCCLCompilerTool"
187.1988 -						UsePrecompiledHeader="2"
187.1989 -					/>
187.1990 -				</FileConfiguration>
187.1991 -				<FileConfiguration
187.1992 -					Name="Debug|Win32"
187.1993 -					ExcludedFromBuild="true"
187.1994 -					>
187.1995 -					<Tool
187.1996 -						Name="VCCLCompilerTool"
187.1997 -						UsePrecompiledHeader="2"
187.1998 -					/>
187.1999 -				</FileConfiguration>
187.2000 -			</File>
187.2001 -			<File
187.2002 -				RelativePath=".\CPP\Common\StringConvert.cpp"
187.2003 -				>
187.2004 -				<FileConfiguration
187.2005 -					Name="Release|Win32"
187.2006 -					>
187.2007 -					<Tool
187.2008 -						Name="VCCLCompilerTool"
187.2009 -						UsePrecompiledHeader="2"
187.2010 -					/>
187.2011 -				</FileConfiguration>
187.2012 -				<FileConfiguration
187.2013 -					Name="Debug|Win32"
187.2014 -					>
187.2015 -					<Tool
187.2016 -						Name="VCCLCompilerTool"
187.2017 -						UsePrecompiledHeader="2"
187.2018 -					/>
187.2019 -				</FileConfiguration>
187.2020 -			</File>
187.2021 -			<File
187.2022 -				RelativePath=".\CPP\Common\StringToInt.cpp"
187.2023 -				>
187.2024 -				<FileConfiguration
187.2025 -					Name="Release|Win32"
187.2026 -					>
187.2027 -					<Tool
187.2028 -						Name="VCCLCompilerTool"
187.2029 -						UsePrecompiledHeader="2"
187.2030 -					/>
187.2031 -				</FileConfiguration>
187.2032 -				<FileConfiguration
187.2033 -					Name="Debug|Win32"
187.2034 -					>
187.2035 -					<Tool
187.2036 -						Name="VCCLCompilerTool"
187.2037 -						UsePrecompiledHeader="2"
187.2038 -					/>
187.2039 -				</FileConfiguration>
187.2040 -			</File>
187.2041 -			<File
187.2042 -				RelativePath=".\CPP\Common\UTFConvert.cpp"
187.2043 -				>
187.2044 -				<FileConfiguration
187.2045 -					Name="Release|Win32"
187.2046 -					>
187.2047 -					<Tool
187.2048 -						Name="VCCLCompilerTool"
187.2049 -						UsePrecompiledHeader="2"
187.2050 -					/>
187.2051 -				</FileConfiguration>
187.2052 -				<FileConfiguration
187.2053 -					Name="Debug|Win32"
187.2054 -					>
187.2055 -					<Tool
187.2056 -						Name="VCCLCompilerTool"
187.2057 -						UsePrecompiledHeader="2"
187.2058 -					/>
187.2059 -				</FileConfiguration>
187.2060 -			</File>
187.2061 -			<File
187.2062 -				RelativePath=".\CPP\Common\Wildcard.cpp"
187.2063 -				>
187.2064 -				<FileConfiguration
187.2065 -					Name="Release|Win32"
187.2066 -					>
187.2067 -					<Tool
187.2068 -						Name="VCCLCompilerTool"
187.2069 -						UsePrecompiledHeader="2"
187.2070 -					/>
187.2071 -				</FileConfiguration>
187.2072 -				<FileConfiguration
187.2073 -					Name="Debug|Win32"
187.2074 -					>
187.2075 -					<Tool
187.2076 -						Name="VCCLCompilerTool"
187.2077 -						UsePrecompiledHeader="2"
187.2078 -					/>
187.2079 -				</FileConfiguration>
187.2080 -			</File>
187.2081 -		</Filter>
187.2082 -		<Filter
187.2083 -			Name="Compress"
187.2084 -			>
187.2085 -			<File
187.2086 -				RelativePath=".\CPP\7zip\Compress\LzhDecoder.cpp"
187.2087 -				>
187.2088 -				<FileConfiguration
187.2089 -					Name="Release|Win32"
187.2090 -					>
187.2091 -					<Tool
187.2092 -						Name="VCCLCompilerTool"
187.2093 -						UsePrecompiledHeader="2"
187.2094 -					/>
187.2095 -				</FileConfiguration>
187.2096 -				<FileConfiguration
187.2097 -					Name="Debug|Win32"
187.2098 -					>
187.2099 -					<Tool
187.2100 -						Name="VCCLCompilerTool"
187.2101 -						UsePrecompiledHeader="2"
187.2102 -					/>
187.2103 -				</FileConfiguration>
187.2104 -			</File>
187.2105 -			<File
187.2106 -				RelativePath=".\CPP\7zip\Compress\LzOutWindow.cpp"
187.2107 -				>
187.2108 -				<FileConfiguration
187.2109 -					Name="Release|Win32"
187.2110 -					>
187.2111 -					<Tool
187.2112 -						Name="VCCLCompilerTool"
187.2113 -						UsePrecompiledHeader="2"
187.2114 -					/>
187.2115 -				</FileConfiguration>
187.2116 -				<FileConfiguration
187.2117 -					Name="Debug|Win32"
187.2118 -					>
187.2119 -					<Tool
187.2120 -						Name="VCCLCompilerTool"
187.2121 -						UsePrecompiledHeader="2"
187.2122 -					/>
187.2123 -				</FileConfiguration>
187.2124 -			</File>
187.2125 -			<Filter
187.2126 -				Name="PPMD"
187.2127 -				>
187.2128 -				<File
187.2129 -					RelativePath=".\CPP\7zip\Compress\PpmdDecoder.cpp"
187.2130 -					>
187.2131 -					<FileConfiguration
187.2132 -						Name="Release|Win32"
187.2133 -						>
187.2134 -						<Tool
187.2135 -							Name="VCCLCompilerTool"
187.2136 -							UsePrecompiledHeader="2"
187.2137 -						/>
187.2138 -					</FileConfiguration>
187.2139 -					<FileConfiguration
187.2140 -						Name="Debug|Win32"
187.2141 -						>
187.2142 -						<Tool
187.2143 -							Name="VCCLCompilerTool"
187.2144 -							UsePrecompiledHeader="2"
187.2145 -						/>
187.2146 -					</FileConfiguration>
187.2147 -				</File>
187.2148 -			</Filter>
187.2149 -			<Filter
187.2150 -				Name="Bit Coder"
187.2151 -				>
187.2152 -				<File
187.2153 -					RelativePath=".\CPP\7zip\Compress\BitlDecoder.cpp"
187.2154 -					>
187.2155 -					<FileConfiguration
187.2156 -						Name="Release|Win32"
187.2157 -						>
187.2158 -						<Tool
187.2159 -							Name="VCCLCompilerTool"
187.2160 -							UsePrecompiledHeader="2"
187.2161 -						/>
187.2162 -					</FileConfiguration>
187.2163 -					<FileConfiguration
187.2164 -						Name="Debug|Win32"
187.2165 -						>
187.2166 -						<Tool
187.2167 -							Name="VCCLCompilerTool"
187.2168 -							UsePrecompiledHeader="2"
187.2169 -						/>
187.2170 -					</FileConfiguration>
187.2171 -				</File>
187.2172 -			</Filter>
187.2173 -			<Filter
187.2174 -				Name="Rar Compress"
187.2175 -				>
187.2176 -				<File
187.2177 -					RelativePath=".\CPP\7zip\Compress\Rar1Decoder.cpp"
187.2178 -					>
187.2179 -					<FileConfiguration
187.2180 -						Name="Release|Win32"
187.2181 -						>
187.2182 -						<Tool
187.2183 -							Name="VCCLCompilerTool"
187.2184 -							UsePrecompiledHeader="2"
187.2185 -						/>
187.2186 -					</FileConfiguration>
187.2187 -					<FileConfiguration
187.2188 -						Name="Debug|Win32"
187.2189 -						>
187.2190 -						<Tool
187.2191 -							Name="VCCLCompilerTool"
187.2192 -							UsePrecompiledHeader="2"
187.2193 -						/>
187.2194 -					</FileConfiguration>
187.2195 -				</File>
187.2196 -				<File
187.2197 -					RelativePath=".\CPP\7zip\Compress\Rar2Decoder.cpp"
187.2198 -					>
187.2199 -					<FileConfiguration
187.2200 -						Name="Release|Win32"
187.2201 -						>
187.2202 -						<Tool
187.2203 -							Name="VCCLCompilerTool"
187.2204 -							UsePrecompiledHeader="2"
187.2205 -						/>
187.2206 -					</FileConfiguration>
187.2207 -					<FileConfiguration
187.2208 -						Name="Debug|Win32"
187.2209 -						>
187.2210 -						<Tool
187.2211 -							Name="VCCLCompilerTool"
187.2212 -							UsePrecompiledHeader="2"
187.2213 -						/>
187.2214 -					</FileConfiguration>
187.2215 -				</File>
187.2216 -				<File
187.2217 -					RelativePath=".\CPP\7zip\Compress\Rar3Decoder.cpp"
187.2218 -					>
187.2219 -					<FileConfiguration
187.2220 -						Name="Release|Win32"
187.2221 -						>
187.2222 -						<Tool
187.2223 -							Name="VCCLCompilerTool"
187.2224 -							UsePrecompiledHeader="2"
187.2225 -						/>
187.2226 -					</FileConfiguration>
187.2227 -					<FileConfiguration
187.2228 -						Name="Debug|Win32"
187.2229 -						>
187.2230 -						<Tool
187.2231 -							Name="VCCLCompilerTool"
187.2232 -							UsePrecompiledHeader="2"
187.2233 -						/>
187.2234 -					</FileConfiguration>
187.2235 -				</File>
187.2236 -				<File
187.2237 -					RelativePath=".\CPP\7zip\Compress\Rar3Vm.cpp"
187.2238 -					>
187.2239 -					<FileConfiguration
187.2240 -						Name="Release|Win32"
187.2241 -						>
187.2242 -						<Tool
187.2243 -							Name="VCCLCompilerTool"
187.2244 -							UsePrecompiledHeader="2"
187.2245 -						/>
187.2246 -					</FileConfiguration>
187.2247 -					<FileConfiguration
187.2248 -						Name="Debug|Win32"
187.2249 -						>
187.2250 -						<Tool
187.2251 -							Name="VCCLCompilerTool"
187.2252 -							UsePrecompiledHeader="2"
187.2253 -						/>
187.2254 -					</FileConfiguration>
187.2255 -				</File>
187.2256 -			</Filter>
187.2257 -			<Filter
187.2258 -				Name="BZip2 Compress"
187.2259 -				>
187.2260 -				<File
187.2261 -					RelativePath=".\CPP\7zip\Compress\BZip2Crc.cpp"
187.2262 -					>
187.2263 -					<FileConfiguration
187.2264 -						Name="Release|Win32"
187.2265 -						>
187.2266 -						<Tool
187.2267 -							Name="VCCLCompilerTool"
187.2268 -							UsePrecompiledHeader="2"
187.2269 -						/>
187.2270 -					</FileConfiguration>
187.2271 -					<FileConfiguration
187.2272 -						Name="Debug|Win32"
187.2273 -						>
187.2274 -						<Tool
187.2275 -							Name="VCCLCompilerTool"
187.2276 -							UsePrecompiledHeader="2"
187.2277 -						/>
187.2278 -					</FileConfiguration>
187.2279 -				</File>
187.2280 -				<File
187.2281 -					RelativePath=".\CPP\7zip\Compress\BZip2Decoder.cpp"
187.2282 -					>
187.2283 -					<FileConfiguration
187.2284 -						Name="Release|Win32"
187.2285 -						>
187.2286 -						<Tool
187.2287 -							Name="VCCLCompilerTool"
187.2288 -							UsePrecompiledHeader="2"
187.2289 -						/>
187.2290 -					</FileConfiguration>
187.2291 -					<FileConfiguration
187.2292 -						Name="Debug|Win32"
187.2293 -						>
187.2294 -						<Tool
187.2295 -							Name="VCCLCompilerTool"
187.2296 -							UsePrecompiledHeader="2"
187.2297 -						/>
187.2298 -					</FileConfiguration>
187.2299 -				</File>
187.2300 -			</Filter>
187.2301 -			<Filter
187.2302 -				Name="Zip Compress"
187.2303 -				>
187.2304 -				<File
187.2305 -					RelativePath=".\CPP\7zip\Compress\DeflateDecoder.cpp"
187.2306 -					>
187.2307 -					<FileConfiguration
187.2308 -						Name="Release|Win32"
187.2309 -						>
187.2310 -						<Tool
187.2311 -							Name="VCCLCompilerTool"
187.2312 -							UsePrecompiledHeader="2"
187.2313 -						/>
187.2314 -					</FileConfiguration>
187.2315 -					<FileConfiguration
187.2316 -						Name="Debug|Win32"
187.2317 -						>
187.2318 -						<Tool
187.2319 -							Name="VCCLCompilerTool"
187.2320 -							UsePrecompiledHeader="2"
187.2321 -						/>
187.2322 -					</FileConfiguration>
187.2323 -				</File>
187.2324 -				<File
187.2325 -					RelativePath=".\CPP\7zip\Compress\ImplodeDecoder.cpp"
187.2326 -					>
187.2327 -					<FileConfiguration
187.2328 -						Name="Release|Win32"
187.2329 -						>
187.2330 -						<Tool
187.2331 -							Name="VCCLCompilerTool"
187.2332 -							UsePrecompiledHeader="2"
187.2333 -						/>
187.2334 -					</FileConfiguration>
187.2335 -					<FileConfiguration
187.2336 -						Name="Debug|Win32"
187.2337 -						>
187.2338 -						<Tool
187.2339 -							Name="VCCLCompilerTool"
187.2340 -							UsePrecompiledHeader="2"
187.2341 -						/>
187.2342 -					</FileConfiguration>
187.2343 -				</File>
187.2344 -				<File
187.2345 -					RelativePath=".\CPP\7zip\Compress\ImplodeHuffmanDecoder.cpp"
187.2346 -					>
187.2347 -					<FileConfiguration
187.2348 -						Name="Release|Win32"
187.2349 -						>
187.2350 -						<Tool
187.2351 -							Name="VCCLCompilerTool"
187.2352 -							UsePrecompiledHeader="2"
187.2353 -						/>
187.2354 -					</FileConfiguration>
187.2355 -					<FileConfiguration
187.2356 -						Name="Debug|Win32"
187.2357 -						>
187.2358 -						<Tool
187.2359 -							Name="VCCLCompilerTool"
187.2360 -							UsePrecompiledHeader="2"
187.2361 -						/>
187.2362 -					</FileConfiguration>
187.2363 -				</File>
187.2364 -				<File
187.2365 -					RelativePath=".\CPP\7zip\Compress\ShrinkDecoder.cpp"
187.2366 -					>
187.2367 -					<FileConfiguration
187.2368 -						Name="Release|Win32"
187.2369 -						>
187.2370 -						<Tool
187.2371 -							Name="VCCLCompilerTool"
187.2372 -							UsePrecompiledHeader="2"
187.2373 -						/>
187.2374 -					</FileConfiguration>
187.2375 -					<FileConfiguration
187.2376 -						Name="Debug|Win32"
187.2377 -						>
187.2378 -						<Tool
187.2379 -							Name="VCCLCompilerTool"
187.2380 -							UsePrecompiledHeader="2"
187.2381 -						/>
187.2382 -					</FileConfiguration>
187.2383 -				</File>
187.2384 -				<File
187.2385 -					RelativePath=".\CPP\7zip\Compress\ZlibDecoder.cpp"
187.2386 -					>
187.2387 -					<FileConfiguration
187.2388 -						Name="Release|Win32"
187.2389 -						>
187.2390 -						<Tool
187.2391 -							Name="VCCLCompilerTool"
187.2392 -							UsePrecompiledHeader="2"
187.2393 -						/>
187.2394 -					</FileConfiguration>
187.2395 -					<FileConfiguration
187.2396 -						Name="Debug|Win32"
187.2397 -						>
187.2398 -						<Tool
187.2399 -							Name="VCCLCompilerTool"
187.2400 -							UsePrecompiledHeader="2"
187.2401 -						/>
187.2402 -					</FileConfiguration>
187.2403 -				</File>
187.2404 -			</Filter>
187.2405 -			<Filter
187.2406 -				Name="7z Compress"
187.2407 -				>
187.2408 -				<File
187.2409 -					RelativePath=".\CPP\7zip\Compress\Bcj2Coder.cpp"
187.2410 -					>
187.2411 -					<FileConfiguration
187.2412 -						Name="Release|Win32"
187.2413 -						>
187.2414 -						<Tool
187.2415 -							Name="VCCLCompilerTool"
187.2416 -							UsePrecompiledHeader="2"
187.2417 -						/>
187.2418 -					</FileConfiguration>
187.2419 -					<FileConfiguration
187.2420 -						Name="Debug|Win32"
187.2421 -						>
187.2422 -						<Tool
187.2423 -							Name="VCCLCompilerTool"
187.2424 -							UsePrecompiledHeader="2"
187.2425 -						/>
187.2426 -					</FileConfiguration>
187.2427 -				</File>
187.2428 -				<File
187.2429 -					RelativePath=".\CPP\7zip\Compress\BcjCoder.cpp"
187.2430 -					>
187.2431 -					<FileConfiguration
187.2432 -						Name="Release|Win32"
187.2433 -						>
187.2434 -						<Tool
187.2435 -							Name="VCCLCompilerTool"
187.2436 -							UsePrecompiledHeader="2"
187.2437 -						/>
187.2438 -					</FileConfiguration>
187.2439 -					<FileConfiguration
187.2440 -						Name="Debug|Win32"
187.2441 -						>
187.2442 -						<Tool
187.2443 -							Name="VCCLCompilerTool"
187.2444 -							UsePrecompiledHeader="2"
187.2445 -						/>
187.2446 -					</FileConfiguration>
187.2447 -				</File>
187.2448 -				<File
187.2449 -					RelativePath=".\CPP\7zip\Compress\BranchCoder.cpp"
187.2450 -					>
187.2451 -					<FileConfiguration
187.2452 -						Name="Release|Win32"
187.2453 -						>
187.2454 -						<Tool
187.2455 -							Name="VCCLCompilerTool"
187.2456 -							UsePrecompiledHeader="2"
187.2457 -						/>
187.2458 -					</FileConfiguration>
187.2459 -					<FileConfiguration
187.2460 -						Name="Debug|Win32"
187.2461 -						>
187.2462 -						<Tool
187.2463 -							Name="VCCLCompilerTool"
187.2464 -							UsePrecompiledHeader="2"
187.2465 -						/>
187.2466 -					</FileConfiguration>
187.2467 -				</File>
187.2468 -				<File
187.2469 -					RelativePath=".\CPP\7zip\Compress\BranchMisc.cpp"
187.2470 -					>
187.2471 -					<FileConfiguration
187.2472 -						Name="Release|Win32"
187.2473 -						>
187.2474 -						<Tool
187.2475 -							Name="VCCLCompilerTool"
187.2476 -							UsePrecompiledHeader="2"
187.2477 -						/>
187.2478 -					</FileConfiguration>
187.2479 -					<FileConfiguration
187.2480 -						Name="Debug|Win32"
187.2481 -						>
187.2482 -						<Tool
187.2483 -							Name="VCCLCompilerTool"
187.2484 -							UsePrecompiledHeader="2"
187.2485 -						/>
187.2486 -					</FileConfiguration>
187.2487 -				</File>
187.2488 -				<File
187.2489 -					RelativePath=".\CPP\7zip\Compress\ByteSwap.cpp"
187.2490 -					>
187.2491 -					<FileConfiguration
187.2492 -						Name="Release|Win32"
187.2493 -						>
187.2494 -						<Tool
187.2495 -							Name="VCCLCompilerTool"
187.2496 -							UsePrecompiledHeader="2"
187.2497 -						/>
187.2498 -					</FileConfiguration>
187.2499 -					<FileConfiguration
187.2500 -						Name="Debug|Win32"
187.2501 -						>
187.2502 -						<Tool
187.2503 -							Name="VCCLCompilerTool"
187.2504 -							UsePrecompiledHeader="2"
187.2505 -						/>
187.2506 -					</FileConfiguration>
187.2507 -				</File>
187.2508 -				<File
187.2509 -					RelativePath=".\CPP\7zip\Compress\CopyCoder.cpp"
187.2510 -					>
187.2511 -					<FileConfiguration
187.2512 -						Name="Release|Win32"
187.2513 -						>
187.2514 -						<Tool
187.2515 -							Name="VCCLCompilerTool"
187.2516 -							UsePrecompiledHeader="2"
187.2517 -						/>
187.2518 -					</FileConfiguration>
187.2519 -					<FileConfiguration
187.2520 -						Name="Debug|Win32"
187.2521 -						>
187.2522 -						<Tool
187.2523 -							Name="VCCLCompilerTool"
187.2524 -							UsePrecompiledHeader="2"
187.2525 -						/>
187.2526 -					</FileConfiguration>
187.2527 -				</File>
187.2528 -				<File
187.2529 -					RelativePath=".\CPP\7zip\Compress\LzmaDecoder.cpp"
187.2530 -					>
187.2531 -					<FileConfiguration
187.2532 -						Name="Release|Win32"
187.2533 -						>
187.2534 -						<Tool
187.2535 -							Name="VCCLCompilerTool"
187.2536 -							UsePrecompiledHeader="2"
187.2537 -						/>
187.2538 -					</FileConfiguration>
187.2539 -					<FileConfiguration
187.2540 -						Name="Debug|Win32"
187.2541 -						>
187.2542 -						<Tool
187.2543 -							Name="VCCLCompilerTool"
187.2544 -							UsePrecompiledHeader="2"
187.2545 -						/>
187.2546 -					</FileConfiguration>
187.2547 -				</File>
187.2548 -			</Filter>
187.2549 -		</Filter>
187.2550 -		<Filter
187.2551 -			Name="Crypto"
187.2552 -			>
187.2553 -			<File
187.2554 -				RelativePath=".\CPP\7zip\Crypto\7zAes.cpp"
187.2555 -				>
187.2556 -				<FileConfiguration
187.2557 -					Name="Release|Win32"
187.2558 -					>
187.2559 -					<Tool
187.2560 -						Name="VCCLCompilerTool"
187.2561 -						UsePrecompiledHeader="2"
187.2562 -					/>
187.2563 -				</FileConfiguration>
187.2564 -				<FileConfiguration
187.2565 -					Name="Debug|Win32"
187.2566 -					>
187.2567 -					<Tool
187.2568 -						Name="VCCLCompilerTool"
187.2569 -						UsePrecompiledHeader="2"
187.2570 -					/>
187.2571 -				</FileConfiguration>
187.2572 -			</File>
187.2573 -			<File
187.2574 -				RelativePath=".\CPP\7zip\Crypto\HmacSha1.cpp"
187.2575 -				>
187.2576 -				<FileConfiguration
187.2577 -					Name="Release|Win32"
187.2578 -					>
187.2579 -					<Tool
187.2580 -						Name="VCCLCompilerTool"
187.2581 -						UsePrecompiledHeader="2"
187.2582 -					/>
187.2583 -				</FileConfiguration>
187.2584 -				<FileConfiguration
187.2585 -					Name="Debug|Win32"
187.2586 -					>
187.2587 -					<Tool
187.2588 -						Name="VCCLCompilerTool"
187.2589 -						UsePrecompiledHeader="2"
187.2590 -					/>
187.2591 -				</FileConfiguration>
187.2592 -			</File>
187.2593 -			<File
187.2594 -				RelativePath=".\CPP\7zip\Crypto\MyAes.cpp"
187.2595 -				>
187.2596 -				<FileConfiguration
187.2597 -					Name="Release|Win32"
187.2598 -					>
187.2599 -					<Tool
187.2600 -						Name="VCCLCompilerTool"
187.2601 -						UsePrecompiledHeader="2"
187.2602 -					/>
187.2603 -				</FileConfiguration>
187.2604 -				<FileConfiguration
187.2605 -					Name="Debug|Win32"
187.2606 -					>
187.2607 -					<Tool
187.2608 -						Name="VCCLCompilerTool"
187.2609 -						UsePrecompiledHeader="2"
187.2610 -					/>
187.2611 -				</FileConfiguration>
187.2612 -			</File>
187.2613 -			<File
187.2614 -				RelativePath=".\CPP\7zip\Crypto\Pbkdf2HmacSha1.cpp"
187.2615 -				>
187.2616 -				<FileConfiguration
187.2617 -					Name="Release|Win32"
187.2618 -					>
187.2619 -					<Tool
187.2620 -						Name="VCCLCompilerTool"
187.2621 -						UsePrecompiledHeader="2"
187.2622 -					/>
187.2623 -				</FileConfiguration>
187.2624 -				<FileConfiguration
187.2625 -					Name="Debug|Win32"
187.2626 -					>
187.2627 -					<Tool
187.2628 -						Name="VCCLCompilerTool"
187.2629 -						UsePrecompiledHeader="2"
187.2630 -					/>
187.2631 -				</FileConfiguration>
187.2632 -			</File>
187.2633 -			<File
187.2634 -				RelativePath=".\CPP\7zip\Crypto\RandGen.cpp"
187.2635 -				>
187.2636 -				<FileConfiguration
187.2637 -					Name="Release|Win32"
187.2638 -					>
187.2639 -					<Tool
187.2640 -						Name="VCCLCompilerTool"
187.2641 -						UsePrecompiledHeader="2"
187.2642 -					/>
187.2643 -				</FileConfiguration>
187.2644 -				<FileConfiguration
187.2645 -					Name="Debug|Win32"
187.2646 -					>
187.2647 -					<Tool
187.2648 -						Name="VCCLCompilerTool"
187.2649 -						UsePrecompiledHeader="2"
187.2650 -					/>
187.2651 -				</FileConfiguration>
187.2652 -			</File>
187.2653 -			<File
187.2654 -				RelativePath=".\CPP\7zip\Crypto\Rar20Crypto.cpp"
187.2655 -				>
187.2656 -				<FileConfiguration
187.2657 -					Name="Release|Win32"
187.2658 -					>
187.2659 -					<Tool
187.2660 -						Name="VCCLCompilerTool"
187.2661 -						UsePrecompiledHeader="2"
187.2662 -					/>
187.2663 -				</FileConfiguration>
187.2664 -				<FileConfiguration
187.2665 -					Name="Debug|Win32"
187.2666 -					>
187.2667 -					<Tool
187.2668 -						Name="VCCLCompilerTool"
187.2669 -						UsePrecompiledHeader="2"
187.2670 -					/>
187.2671 -				</FileConfiguration>
187.2672 -			</File>
187.2673 -			<File
187.2674 -				RelativePath=".\CPP\7zip\Crypto\RarAes.cpp"
187.2675 -				>
187.2676 -				<FileConfiguration
187.2677 -					Name="Release|Win32"
187.2678 -					>
187.2679 -					<Tool
187.2680 -						Name="VCCLCompilerTool"
187.2681 -						UsePrecompiledHeader="2"
187.2682 -					/>
187.2683 -				</FileConfiguration>
187.2684 -				<FileConfiguration
187.2685 -					Name="Debug|Win32"
187.2686 -					>
187.2687 -					<Tool
187.2688 -						Name="VCCLCompilerTool"
187.2689 -						UsePrecompiledHeader="2"
187.2690 -					/>
187.2691 -				</FileConfiguration>
187.2692 -			</File>
187.2693 -			<File
187.2694 -				RelativePath=".\CPP\7zip\Crypto\Sha1.cpp"
187.2695 -				>
187.2696 -				<FileConfiguration
187.2697 -					Name="Release|Win32"
187.2698 -					>
187.2699 -					<Tool
187.2700 -						Name="VCCLCompilerTool"
187.2701 -						UsePrecompiledHeader="2"
187.2702 -					/>
187.2703 -				</FileConfiguration>
187.2704 -				<FileConfiguration
187.2705 -					Name="Debug|Win32"
187.2706 -					>
187.2707 -					<Tool
187.2708 -						Name="VCCLCompilerTool"
187.2709 -						UsePrecompiledHeader="2"
187.2710 -					/>
187.2711 -				</FileConfiguration>
187.2712 -			</File>
187.2713 -			<File
187.2714 -				RelativePath=".\CPP\7zip\Crypto\WzAes.cpp"
187.2715 -				>
187.2716 -				<FileConfiguration
187.2717 -					Name="Release|Win32"
187.2718 -					>
187.2719 -					<Tool
187.2720 -						Name="VCCLCompilerTool"
187.2721 -						UsePrecompiledHeader="2"
187.2722 -					/>
187.2723 -				</FileConfiguration>
187.2724 -				<FileConfiguration
187.2725 -					Name="Debug|Win32"
187.2726 -					>
187.2727 -					<Tool
187.2728 -						Name="VCCLCompilerTool"
187.2729 -						UsePrecompiledHeader="2"
187.2730 -					/>
187.2731 -				</FileConfiguration>
187.2732 -			</File>
187.2733 -			<File
187.2734 -				RelativePath=".\CPP\7zip\Crypto\ZipCrypto.cpp"
187.2735 -				>
187.2736 -				<FileConfiguration
187.2737 -					Name="Release|Win32"
187.2738 -					>
187.2739 -					<Tool
187.2740 -						Name="VCCLCompilerTool"
187.2741 -						UsePrecompiledHeader="2"
187.2742 -					/>
187.2743 -				</FileConfiguration>
187.2744 -				<FileConfiguration
187.2745 -					Name="Debug|Win32"
187.2746 -					>
187.2747 -					<Tool
187.2748 -						Name="VCCLCompilerTool"
187.2749 -						UsePrecompiledHeader="2"
187.2750 -					/>
187.2751 -				</FileConfiguration>
187.2752 -			</File>
187.2753 -			<File
187.2754 -				RelativePath=".\CPP\7zip\Crypto\ZipStrong.cpp"
187.2755 -				>
187.2756 -				<FileConfiguration
187.2757 -					Name="Release|Win32"
187.2758 -					>
187.2759 -					<Tool
187.2760 -						Name="VCCLCompilerTool"
187.2761 -						UsePrecompiledHeader="2"
187.2762 -					/>
187.2763 -				</FileConfiguration>
187.2764 -				<FileConfiguration
187.2765 -					Name="Debug|Win32"
187.2766 -					>
187.2767 -					<Tool
187.2768 -						Name="VCCLCompilerTool"
187.2769 -						UsePrecompiledHeader="2"
187.2770 -					/>
187.2771 -				</FileConfiguration>
187.2772 -			</File>
187.2773 -		</Filter>
187.2774 -		<Filter
187.2775 -			Name="Headers"
187.2776 -			>
187.2777 -			<File
187.2778 -				RelativePath=".\CPP\7zip\Crypto\7zAes.h"
187.2779 -				>
187.2780 -			</File>
187.2781 -			<File
187.2782 -				RelativePath=".\CPP\7zip\Archive\7z\7zCompressionMode.h"
187.2783 -				>
187.2784 -			</File>
187.2785 -			<File
187.2786 -				RelativePath=".\C\7zCrc.h"
187.2787 -				>
187.2788 -			</File>
187.2789 -			<File
187.2790 -				RelativePath=".\CPP\7zip\Archive\7z\7zDecode.h"
187.2791 -				>
187.2792 -			</File>
187.2793 -			<File
187.2794 -				RelativePath=".\CPP\7zip\Archive\7z\7zFolderInStream.h"
187.2795 -				>
187.2796 -			</File>
187.2797 -			<File
187.2798 -				RelativePath=".\CPP\7zip\Archive\7z\7zFolderOutStream.h"
187.2799 -				>
187.2800 -			</File>
187.2801 -			<File
187.2802 -				RelativePath=".\CPP\7zip\Archive\7z\7zHandler.h"
187.2803 -				>
187.2804 -			</File>
187.2805 -			<File
187.2806 -				RelativePath=".\CPP\7zip\Archive\7z\7zHeader.h"
187.2807 -				>
187.2808 -			</File>
187.2809 -			<File
187.2810 -				RelativePath=".\CPP\7zip\Archive\7z\7zIn.h"
187.2811 -				>
187.2812 -			</File>
187.2813 -			<File
187.2814 -				RelativePath=".\CPP\7zip\Archive\7z\7zItem.h"
187.2815 -				>
187.2816 -			</File>
187.2817 -			<File
187.2818 -				RelativePath=".\CPP\7zip\Archive\7z\7zProperties.h"
187.2819 -				>
187.2820 -			</File>
187.2821 -			<File
187.2822 -				RelativePath=".\CPP\7zip\Archive\7z\7zSpecStream.h"
187.2823 -				>
187.2824 -			</File>
187.2825 -			<File
187.2826 -				RelativePath=".\C\Aes.h"
187.2827 -				>
187.2828 -			</File>
187.2829 -			<File
187.2830 -				RelativePath=".\C\Alloc.h"
187.2831 -				>
187.2832 -			</File>
187.2833 -			<File
187.2834 -				RelativePath=".\CPP\7zip\Compress\Bcj2Coder.h"
187.2835 -				>
187.2836 -			</File>
187.2837 -			<File
187.2838 -				RelativePath=".\CPP\7zip\Compress\BcjCoder.h"
187.2839 -				>
187.2840 -			</File>
187.2841 -			<File
187.2842 -				RelativePath=".\CPP\7zip\Compress\BitlDecoder.h"
187.2843 -				>
187.2844 -			</File>
187.2845 -			<File
187.2846 -				RelativePath=".\CPP\7zip\Compress\BitmDecoder.h"
187.2847 -				>
187.2848 -			</File>
187.2849 -			<File
187.2850 -				RelativePath=".\C\Bra.h"
187.2851 -				>
187.2852 -			</File>
187.2853 -			<File
187.2854 -				RelativePath=".\CPP\7zip\Compress\BranchCoder.h"
187.2855 -				>
187.2856 -			</File>
187.2857 -			<File
187.2858 -				RelativePath=".\CPP\7zip\Compress\BranchMisc.h"
187.2859 -				>
187.2860 -			</File>
187.2861 -			<File
187.2862 -				RelativePath=".\CPP\Common\Buffer.h"
187.2863 -				>
187.2864 -			</File>
187.2865 -			<File
187.2866 -				RelativePath=".\C\BwtSort.h"
187.2867 -				>
187.2868 -			</File>
187.2869 -			<File
187.2870 -				RelativePath=".\CPP\7zip\Compress\ByteSwap.h"
187.2871 -				>
187.2872 -			</File>
187.2873 -			<File
187.2874 -				RelativePath=".\CPP\7zip\Compress\BZip2Const.h"
187.2875 -				>
187.2876 -			</File>
187.2877 -			<File
187.2878 -				RelativePath=".\CPP\7zip\Compress\BZip2Crc.h"
187.2879 -				>
187.2880 -			</File>
187.2881 -			<File
187.2882 -				RelativePath=".\CPP\7zip\Compress\BZip2Decoder.h"
187.2883 -				>
187.2884 -			</File>
187.2885 -			<File
187.2886 -				RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Handler.h"
187.2887 -				>
187.2888 -			</File>
187.2889 -			<File
187.2890 -				RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Item.h"
187.2891 -				>
187.2892 -			</File>
187.2893 -			<File
187.2894 -				RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2.h"
187.2895 -				>
187.2896 -			</File>
187.2897 -			<File
187.2898 -				RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2MT.h"
187.2899 -				>
187.2900 -			</File>
187.2901 -			<File
187.2902 -				RelativePath=".\CPP\Common\ComTry.h"
187.2903 -				>
187.2904 -			</File>
187.2905 -			<File
187.2906 -				RelativePath=".\CPP\7zip\Compress\CopyCoder.h"
187.2907 -				>
187.2908 -			</File>
187.2909 -			<File
187.2910 -				RelativePath=".\C\CpuArch.h"
187.2911 -				>
187.2912 -			</File>
187.2913 -			<File
187.2914 -				RelativePath=".\CPP\7zip\Common\CreateCoder.h"
187.2915 -				>
187.2916 -			</File>
187.2917 -			<File
187.2918 -				RelativePath=".\CPP\7zip\Common\DeclareArcs.h"
187.2919 -				>
187.2920 -			</File>
187.2921 -			<File
187.2922 -				RelativePath=".\CPP\7zip\Common\DeclareCodecs.h"
187.2923 -				>
187.2924 -			</File>
187.2925 -			<File
187.2926 -				RelativePath=".\CPP\7zip\Compress\DeflateConst.h"
187.2927 -				>
187.2928 -			</File>
187.2929 -			<File
187.2930 -				RelativePath=".\CPP\7zip\Compress\DeflateDecoder.h"
187.2931 -				>
187.2932 -			</File>
187.2933 -			<File
187.2934 -				RelativePath=".\CPP\Windows\Defs.h"
187.2935 -				>
187.2936 -			</File>
187.2937 -			<File
187.2938 -				RelativePath=".\CPP\Common\Defs.h"
187.2939 -				>
187.2940 -			</File>
187.2941 -			<File
187.2942 -				RelativePath=".\CPP\7zip\Archive\Common\DummyOutStream.h"
187.2943 -				>
187.2944 -			</File>
187.2945 -			<File
187.2946 -				RelativePath=".\CPP\Common\DynamicBuffer.h"
187.2947 -				>
187.2948 -			</File>
187.2949 -			<File
187.2950 -				RelativePath=".\CPP\Windows\FileDir.h"
187.2951 -				>
187.2952 -			</File>
187.2953 -			<File
187.2954 -				RelativePath=".\CPP\Windows\FileFind.h"
187.2955 -				>
187.2956 -			</File>
187.2957 -			<File
187.2958 -				RelativePath=".\CPP\Windows\FileIO.h"
187.2959 -				>
187.2960 -			</File>
187.2961 -			<File
187.2962 -				RelativePath=".\CPP\Windows\FileName.h"
187.2963 -				>
187.2964 -			</File>
187.2965 -			<File
187.2966 -				RelativePath=".\CPP\7zip\Common\FilterCoder.h"
187.2967 -				>
187.2968 -			</File>
187.2969 -			<File
187.2970 -				RelativePath=".\CPP\7zip\Archive\Common\FindSignature.h"
187.2971 -				>
187.2972 -			</File>
187.2973 -			<File
187.2974 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipHandler.h"
187.2975 -				>
187.2976 -			</File>
187.2977 -			<File
187.2978 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipHeader.h"
187.2979 -				>
187.2980 -			</File>
187.2981 -			<File
187.2982 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipIn.h"
187.2983 -				>
187.2984 -			</File>
187.2985 -			<File
187.2986 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipItem.h"
187.2987 -				>
187.2988 -			</File>
187.2989 -			<File
187.2990 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipUpdate.h"
187.2991 -				>
187.2992 -			</File>
187.2993 -			<File
187.2994 -				RelativePath=".\CPP\Windows\Handle.h"
187.2995 -				>
187.2996 -			</File>
187.2997 -			<File
187.2998 -				RelativePath=".\CPP\7zip\Crypto\HmacSha1.h"
187.2999 -				>
187.3000 -			</File>
187.3001 -			<File
187.3002 -				RelativePath=".\C\HuffEnc.h"
187.3003 -				>
187.3004 -			</File>
187.3005 -			<File
187.3006 -				RelativePath=".\CPP\7zip\Compress\HuffmanDecoder.h"
187.3007 -				>
187.3008 -			</File>
187.3009 -			<File
187.3010 -				RelativePath=".\CPP\7zip\Archive\IArchive.h"
187.3011 -				>
187.3012 -			</File>
187.3013 -			<File
187.3014 -				RelativePath=".\CPP\7zip\ICoder.h"
187.3015 -				>
187.3016 -			</File>
187.3017 -			<File
187.3018 -				RelativePath=".\CPP\7zip\IDecl.h"
187.3019 -				>
187.3020 -			</File>
187.3021 -			<File
187.3022 -				RelativePath=".\CPP\7zip\Compress\ImplodeDecoder.h"
187.3023 -				>
187.3024 -			</File>
187.3025 -			<File
187.3026 -				RelativePath=".\CPP\7zip\Compress\ImplodeHuffmanDecoder.h"
187.3027 -				>
187.3028 -			</File>
187.3029 -			<File
187.3030 -				RelativePath=".\CPP\7zip\Common\InBuffer.h"
187.3031 -				>
187.3032 -			</File>
187.3033 -			<File
187.3034 -				RelativePath=".\CPP\Common\InitializeStaticLib.h"
187.3035 -				>
187.3036 -			</File>
187.3037 -			<File
187.3038 -				RelativePath=".\CPP\7zip\Common\InOutTempBuffer.h"
187.3039 -				>
187.3040 -			</File>
187.3041 -			<File
187.3042 -				RelativePath=".\CPP\7zip\Archive\Common\InStreamWithCRC.h"
187.3043 -				>
187.3044 -			</File>
187.3045 -			<File
187.3046 -				RelativePath=".\CPP\Common\IntToString.h"
187.3047 -				>
187.3048 -			</File>
187.3049 -			<File
187.3050 -				RelativePath=".\CPP\7zip\IPassword.h"
187.3051 -				>
187.3052 -			</File>
187.3053 -			<File
187.3054 -				RelativePath=".\CPP\7zip\IProgress.h"
187.3055 -				>
187.3056 -			</File>
187.3057 -			<File
187.3058 -				RelativePath=".\CPP\7zip\IStream.h"
187.3059 -				>
187.3060 -			</File>
187.3061 -			<File
187.3062 -				RelativePath=".\CPP\7zip\Archive\Common\ItemNameUtils.h"
187.3063 -				>
187.3064 -			</File>
187.3065 -			<File
187.3066 -				RelativePath=".\CPP\7zip\Common\LimitedStreams.h"
187.3067 -				>
187.3068 -			</File>
187.3069 -			<File
187.3070 -				RelativePath=".\CPP\7zip\Common\LockedStream.h"
187.3071 -				>
187.3072 -			</File>
187.3073 -			<File
187.3074 -				RelativePath=".\C\LzFind.h"
187.3075 -				>
187.3076 -			</File>
187.3077 -			<File
187.3078 -				RelativePath=".\C\LzFindMt.h"
187.3079 -				>
187.3080 -			</File>
187.3081 -			<File
187.3082 -				RelativePath=".\C\LzHash.h"
187.3083 -				>
187.3084 -			</File>
187.3085 -			<File
187.3086 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhCRC.h"
187.3087 -				>
187.3088 -			</File>
187.3089 -			<File
187.3090 -				RelativePath=".\CPP\7zip\Compress\LzhDecoder.h"
187.3091 -				>
187.3092 -			</File>
187.3093 -			<File
187.3094 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhHandler.h"
187.3095 -				>
187.3096 -			</File>
187.3097 -			<File
187.3098 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhHeader.h"
187.3099 -				>
187.3100 -			</File>
187.3101 -			<File
187.3102 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhIn.h"
187.3103 -				>
187.3104 -			</File>
187.3105 -			<File
187.3106 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhItem.h"
187.3107 -				>
187.3108 -			</File>
187.3109 -			<File
187.3110 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.h"
187.3111 -				>
187.3112 -			</File>
187.3113 -			<File
187.3114 -				RelativePath=".\C\LzmaDec.h"
187.3115 -				>
187.3116 -			</File>
187.3117 -			<File
187.3118 -				RelativePath=".\CPP\7zip\Compress\LzmaDecoder.h"
187.3119 -				>
187.3120 -			</File>
187.3121 -			<File
187.3122 -				RelativePath=".\C\LzmaEnc.h"
187.3123 -				>
187.3124 -			</File>
187.3125 -			<File
187.3126 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaFiltersDecode.h"
187.3127 -				>
187.3128 -			</File>
187.3129 -			<File
187.3130 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaHandler.h"
187.3131 -				>
187.3132 -			</File>
187.3133 -			<File
187.3134 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaIn.h"
187.3135 -				>
187.3136 -			</File>
187.3137 -			<File
187.3138 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaItem.h"
187.3139 -				>
187.3140 -			</File>
187.3141 -			<File
187.3142 -				RelativePath=".\CPP\7zip\Compress\LzOutWindow.h"
187.3143 -				>
187.3144 -			</File>
187.3145 -			<File
187.3146 -				RelativePath=".\CPP\7zip\Common\MemBlocks.h"
187.3147 -				>
187.3148 -			</File>
187.3149 -			<File
187.3150 -				RelativePath=".\CPP\7zip\Common\MethodId.h"
187.3151 -				>
187.3152 -			</File>
187.3153 -			<File
187.3154 -				RelativePath=".\CPP\7zip\Common\MethodProps.h"
187.3155 -				>
187.3156 -			</File>
187.3157 -			<File
187.3158 -				RelativePath=".\CPP\7zip\Compress\Mtf8.h"
187.3159 -				>
187.3160 -			</File>
187.3161 -			<File
187.3162 -				RelativePath=".\CPP\7zip\Archive\Common\MultiStream.h"
187.3163 -				>
187.3164 -			</File>
187.3165 -			<File
187.3166 -				RelativePath=".\CPP\7zip\Crypto\MyAes.h"
187.3167 -				>
187.3168 -			</File>
187.3169 -			<File
187.3170 -				RelativePath=".\CPP\Common\MyCom.h"
187.3171 -				>
187.3172 -			</File>
187.3173 -			<File
187.3174 -				RelativePath=".\CPP\Common\MyException.h"
187.3175 -				>
187.3176 -			</File>
187.3177 -			<File
187.3178 -				RelativePath=".\CPP\Common\MyInitGuid.h"
187.3179 -				>
187.3180 -			</File>
187.3181 -			<File
187.3182 -				RelativePath=".\CPP\Common\MyMap.h"
187.3183 -				>
187.3184 -			</File>
187.3185 -			<File
187.3186 -				RelativePath=".\CPP\Common\MyString.h"
187.3187 -				>
187.3188 -			</File>
187.3189 -			<File
187.3190 -				RelativePath=".\CPP\Common\MyUnknown.h"
187.3191 -				>
187.3192 -			</File>
187.3193 -			<File
187.3194 -				RelativePath=".\CPP\Common\MyVector.h"
187.3195 -				>
187.3196 -			</File>
187.3197 -			<File
187.3198 -				RelativePath=".\CPP\Common\MyWindows.h"
187.3199 -				>
187.3200 -			</File>
187.3201 -			<File
187.3202 -				RelativePath=".\CPP\Common\MyXml.h"
187.3203 -				>
187.3204 -			</File>
187.3205 -			<File
187.3206 -				RelativePath=".\CPP\Common\NewHandler.h"
187.3207 -				>
187.3208 -			</File>
187.3209 -			<File
187.3210 -				RelativePath=".\CPP\7zip\Common\OffsetStream.h"
187.3211 -				>
187.3212 -			</File>
187.3213 -			<File
187.3214 -				RelativePath=".\CPP\7zip\Common\OutBuffer.h"
187.3215 -				>
187.3216 -			</File>
187.3217 -			<File
187.3218 -				RelativePath=".\CPP\7zip\Common\OutMemStream.h"
187.3219 -				>
187.3220 -			</File>
187.3221 -			<File
187.3222 -				RelativePath=".\CPP\7zip\Archive\Common\OutStreamWithCRC.h"
187.3223 -				>
187.3224 -			</File>
187.3225 -			<File
187.3226 -				RelativePath=".\CPP\7zip\Archive\Common\ParseProperties.h"
187.3227 -				>
187.3228 -			</File>
187.3229 -			<File
187.3230 -				RelativePath=".\CPP\7zip\Crypto\Pbkdf2HmacSha1.h"
187.3231 -				>
187.3232 -			</File>
187.3233 -			<File
187.3234 -				RelativePath=".\CPP\7zip\Compress\PpmdContext.h"
187.3235 -				>
187.3236 -			</File>
187.3237 -			<File
187.3238 -				RelativePath=".\CPP\7zip\Compress\PpmdDecode.h"
187.3239 -				>
187.3240 -			</File>
187.3241 -			<File
187.3242 -				RelativePath=".\CPP\7zip\Compress\PpmdDecoder.h"
187.3243 -				>
187.3244 -			</File>
187.3245 -			<File
187.3246 -				RelativePath=".\CPP\7zip\Compress\PpmdSubAlloc.h"
187.3247 -				>
187.3248 -			</File>
187.3249 -			<File
187.3250 -				RelativePath=".\CPP\7zip\Compress\PpmdType.h"
187.3251 -				>
187.3252 -			</File>
187.3253 -			<File
187.3254 -				RelativePath=".\CPP\7zip\Common\ProgressMt.h"
187.3255 -				>
187.3256 -			</File>
187.3257 -			<File
187.3258 -				RelativePath=".\CPP\7zip\Common\ProgressUtils.h"
187.3259 -				>
187.3260 -			</File>
187.3261 -			<File
187.3262 -				RelativePath=".\CPP\7zip\PropID.h"
187.3263 -				>
187.3264 -			</File>
187.3265 -			<File
187.3266 -				RelativePath=".\CPP\Windows\PropVariant.h"
187.3267 -				>
187.3268 -			</File>
187.3269 -			<File
187.3270 -				RelativePath=".\CPP\7zip\Crypto\RandGen.h"
187.3271 -				>
187.3272 -			</File>
187.3273 -			<File
187.3274 -				RelativePath=".\CPP\7zip\Compress\RangeCoder.h"
187.3275 -				>
187.3276 -			</File>
187.3277 -			<File
187.3278 -				RelativePath=".\CPP\7zip\Compress\RangeCoderBit.h"
187.3279 -				>
187.3280 -			</File>
187.3281 -			<File
187.3282 -				RelativePath=".\CPP\7zip\Compress\Rar1Decoder.h"
187.3283 -				>
187.3284 -			</File>
187.3285 -			<File
187.3286 -				RelativePath=".\CPP\7zip\Crypto\Rar20Crypto.h"
187.3287 -				>
187.3288 -			</File>
187.3289 -			<File
187.3290 -				RelativePath=".\CPP\7zip\Compress\Rar2Decoder.h"
187.3291 -				>
187.3292 -			</File>
187.3293 -			<File
187.3294 -				RelativePath=".\CPP\7zip\Compress\Rar3Decoder.h"
187.3295 -				>
187.3296 -			</File>
187.3297 -			<File
187.3298 -				RelativePath=".\CPP\7zip\Compress\Rar3Vm.h"
187.3299 -				>
187.3300 -			</File>
187.3301 -			<File
187.3302 -				RelativePath=".\CPP\7zip\Crypto\RarAes.h"
187.3303 -				>
187.3304 -			</File>
187.3305 -			<File
187.3306 -				RelativePath=".\CPP\7zip\Archive\Rar\RarHandler.h"
187.3307 -				>
187.3308 -			</File>
187.3309 -			<File
187.3310 -				RelativePath=".\CPP\7zip\Archive\Rar\RarHeader.h"
187.3311 -				>
187.3312 -			</File>
187.3313 -			<File
187.3314 -				RelativePath=".\CPP\7zip\Archive\Rar\RarIn.h"
187.3315 -				>
187.3316 -			</File>
187.3317 -			<File
187.3318 -				RelativePath=".\CPP\7zip\Archive\Rar\RarItem.h"
187.3319 -				>
187.3320 -			</File>
187.3321 -			<File
187.3322 -				RelativePath=".\CPP\7zip\Archive\Rar\RarVolumeInStream.h"
187.3323 -				>
187.3324 -			</File>
187.3325 -			<File
187.3326 -				RelativePath=".\CPP\7zip\Common\RegisterArc.h"
187.3327 -				>
187.3328 -			</File>
187.3329 -			<File
187.3330 -				RelativePath=".\CPP\7zip\Common\RegisterCodec.h"
187.3331 -				>
187.3332 -			</File>
187.3333 -			<File
187.3334 -				RelativePath=".\C\RotateDefs.h"
187.3335 -				>
187.3336 -			</File>
187.3337 -			<File
187.3338 -				RelativePath=".\CPP\7zip\Crypto\Sha1.h"
187.3339 -				>
187.3340 -			</File>
187.3341 -			<File
187.3342 -				RelativePath=".\C\Sha256.h"
187.3343 -				>
187.3344 -			</File>
187.3345 -			<File
187.3346 -				RelativePath=".\CPP\7zip\Compress\ShrinkDecoder.h"
187.3347 -				>
187.3348 -			</File>
187.3349 -			<File
187.3350 -				RelativePath=".\C\Sort.h"
187.3351 -				>
187.3352 -			</File>
187.3353 -			<File
187.3354 -				RelativePath=".\CPP\7zip\Archive\Split\SplitHandler.h"
187.3355 -				>
187.3356 -			</File>
187.3357 -			<File
187.3358 -				RelativePath=".\CPP\7zip\Archive\Common\StdAfx.h"
187.3359 -				>
187.3360 -			</File>
187.3361 -			<File
187.3362 -				RelativePath=".\CPP\7zip\Archive\Rar\StdAfx.h"
187.3363 -				>
187.3364 -			</File>
187.3365 -			<File
187.3366 -				RelativePath=".\CPP\7zip\Archive\BZip2\StdAfx.h"
187.3367 -				>
187.3368 -			</File>
187.3369 -			<File
187.3370 -				RelativePath=".\CPP\Windows\StdAfx.h"
187.3371 -				>
187.3372 -			</File>
187.3373 -			<File
187.3374 -				RelativePath=".\CPP\7zip\Archive\7z\StdAfx.h"
187.3375 -				>
187.3376 -			</File>
187.3377 -			<File
187.3378 -				RelativePath=".\CPP\7zip\Archive\StdAfx.h"
187.3379 -				>
187.3380 -			</File>
187.3381 -			<File
187.3382 -				RelativePath=".\CPP\7zip\Compress\StdAfx.h"
187.3383 -				>
187.3384 -			</File>
187.3385 -			<File
187.3386 -				RelativePath=".\CPP\7zip\Bundles\Format7zF\StdAfx.h"
187.3387 -				>
187.3388 -			</File>
187.3389 -			<File
187.3390 -				RelativePath=".\CPP\7zip\Archive\GZip\StdAfx.h"
187.3391 -				>
187.3392 -			</File>
187.3393 -			<File
187.3394 -				RelativePath=".\CPP\7zip\Crypto\StdAfx.h"
187.3395 -				>
187.3396 -			</File>
187.3397 -			<File
187.3398 -				RelativePath=".\CPP\7zip\Archive\Tar\StdAfx.h"
187.3399 -				>
187.3400 -			</File>
187.3401 -			<File
187.3402 -				RelativePath=".\CPP\7zip\Archive\Zip\StdAfx.h"
187.3403 -				>
187.3404 -			</File>
187.3405 -			<File
187.3406 -				RelativePath=".\CPP\7zip\Archive\Lzh\StdAfx.h"
187.3407 -				>
187.3408 -			</File>
187.3409 -			<File
187.3410 -				RelativePath=".\CPP\7zip\Common\StdAfx.h"
187.3411 -				>
187.3412 -			</File>
187.3413 -			<File
187.3414 -				RelativePath=".\CPP\7zip\Archive\Split\StdAfx.h"
187.3415 -				>
187.3416 -			</File>
187.3417 -			<File
187.3418 -				RelativePath=".\CPP\7zip\Archive\Lzma\StdAfx.h"
187.3419 -				>
187.3420 -			</File>
187.3421 -			<File
187.3422 -				RelativePath=".\CPP\7zip\Common\StreamBinder.h"
187.3423 -				>
187.3424 -			</File>
187.3425 -			<File
187.3426 -				RelativePath=".\CPP\7zip\Common\StreamObjects.h"
187.3427 -				>
187.3428 -			</File>
187.3429 -			<File
187.3430 -				RelativePath=".\CPP\7zip\Common\StreamUtils.h"
187.3431 -				>
187.3432 -			</File>
187.3433 -			<File
187.3434 -				RelativePath=".\CPP\Common\StringConvert.h"
187.3435 -				>
187.3436 -			</File>
187.3437 -			<File
187.3438 -				RelativePath=".\CPP\Common\StringToInt.h"
187.3439 -				>
187.3440 -			</File>
187.3441 -			<File
187.3442 -				RelativePath=".\CPP\Windows\Synchronization.h"
187.3443 -				>
187.3444 -			</File>
187.3445 -			<File
187.3446 -				RelativePath=".\CPP\7zip\Archive\Tar\TarHandler.h"
187.3447 -				>
187.3448 -			</File>
187.3449 -			<File
187.3450 -				RelativePath=".\CPP\7zip\Archive\Tar\TarHeader.h"
187.3451 -				>
187.3452 -			</File>
187.3453 -			<File
187.3454 -				RelativePath=".\CPP\7zip\Archive\Tar\TarIn.h"
187.3455 -				>
187.3456 -			</File>
187.3457 -			<File
187.3458 -				RelativePath=".\CPP\7zip\Archive\Tar\TarItem.h"
187.3459 -				>
187.3460 -			</File>
187.3461 -			<File
187.3462 -				RelativePath=".\CPP\Windows\Thread.h"
187.3463 -				>
187.3464 -			</File>
187.3465 -			<File
187.3466 -				RelativePath=".\C\Threads.h"
187.3467 -				>
187.3468 -			</File>
187.3469 -			<File
187.3470 -				RelativePath=".\CPP\Windows\Time.h"
187.3471 -				>
187.3472 -			</File>
187.3473 -			<File
187.3474 -				RelativePath=".\CPP\Common\Types.h"
187.3475 -				>
187.3476 -			</File>
187.3477 -			<File
187.3478 -				RelativePath=".\C\Types.h"
187.3479 -				>
187.3480 -			</File>
187.3481 -			<File
187.3482 -				RelativePath=".\CPP\Common\UTFConvert.h"
187.3483 -				>
187.3484 -			</File>
187.3485 -			<File
187.3486 -				RelativePath=".\CPP\7zip\Common\VirtThread.h"
187.3487 -				>
187.3488 -			</File>
187.3489 -			<File
187.3490 -				RelativePath=".\CPP\Common\Wildcard.h"
187.3491 -				>
187.3492 -			</File>
187.3493 -			<File
187.3494 -				RelativePath=".\CPP\7zip\Crypto\WzAes.h"
187.3495 -				>
187.3496 -			</File>
187.3497 -			<File
187.3498 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipCompressionMode.h"
187.3499 -				>
187.3500 -			</File>
187.3501 -			<File
187.3502 -				RelativePath=".\CPP\7zip\Crypto\ZipCrypto.h"
187.3503 -				>
187.3504 -			</File>
187.3505 -			<File
187.3506 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipHandler.h"
187.3507 -				>
187.3508 -			</File>
187.3509 -			<File
187.3510 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipHeader.h"
187.3511 -				>
187.3512 -			</File>
187.3513 -			<File
187.3514 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipIn.h"
187.3515 -				>
187.3516 -			</File>
187.3517 -			<File
187.3518 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipItem.h"
187.3519 -				>
187.3520 -			</File>
187.3521 -			<File
187.3522 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipItemEx.h"
187.3523 -				>
187.3524 -			</File>
187.3525 -			<File
187.3526 -				RelativePath=".\CPP\7zip\Crypto\ZipStrong.h"
187.3527 -				>
187.3528 -			</File>
187.3529 -			<File
187.3530 -				RelativePath=".\CPP\7zip\Compress\ZlibDecoder.h"
187.3531 -				>
187.3532 -			</File>
187.3533 -		</Filter>
187.3534 -		<Filter
187.3535 -			Name="Register"
187.3536 -			>
187.3537 -			<File
187.3538 -				RelativePath=".\CPP\7zip\Crypto\7zAesRegister.cpp"
187.3539 -				>
187.3540 -				<FileConfiguration
187.3541 -					Name="Release|Win32"
187.3542 -					>
187.3543 -					<Tool
187.3544 -						Name="VCCLCompilerTool"
187.3545 -						UsePrecompiledHeader="2"
187.3546 -					/>
187.3547 -				</FileConfiguration>
187.3548 -				<FileConfiguration
187.3549 -					Name="Debug|Win32"
187.3550 -					>
187.3551 -					<Tool
187.3552 -						Name="VCCLCompilerTool"
187.3553 -						UsePrecompiledHeader="2"
187.3554 -					/>
187.3555 -				</FileConfiguration>
187.3556 -			</File>
187.3557 -			<File
187.3558 -				RelativePath=".\CPP\7zip\Archive\7z\7zRegister.cpp"
187.3559 -				>
187.3560 -				<FileConfiguration
187.3561 -					Name="Release|Win32"
187.3562 -					>
187.3563 -					<Tool
187.3564 -						Name="VCCLCompilerTool"
187.3565 -						UsePrecompiledHeader="2"
187.3566 -					/>
187.3567 -				</FileConfiguration>
187.3568 -				<FileConfiguration
187.3569 -					Name="Debug|Win32"
187.3570 -					>
187.3571 -					<Tool
187.3572 -						Name="VCCLCompilerTool"
187.3573 -						UsePrecompiledHeader="2"
187.3574 -					/>
187.3575 -				</FileConfiguration>
187.3576 -			</File>
187.3577 -			<File
187.3578 -				RelativePath=".\CPP\7zip\Archive\ArchiveExports.cpp"
187.3579 -				>
187.3580 -				<FileConfiguration
187.3581 -					Name="Release|Win32"
187.3582 -					>
187.3583 -					<Tool
187.3584 -						Name="VCCLCompilerTool"
187.3585 -						UsePrecompiledHeader="1"
187.3586 -					/>
187.3587 -				</FileConfiguration>
187.3588 -				<FileConfiguration
187.3589 -					Name="Debug|Win32"
187.3590 -					>
187.3591 -					<Tool
187.3592 -						Name="VCCLCompilerTool"
187.3593 -						UsePrecompiledHeader="1"
187.3594 -					/>
187.3595 -				</FileConfiguration>
187.3596 -			</File>
187.3597 -			<File
187.3598 -				RelativePath=".\CPP\7zip\Compress\Bcj2Register.cpp"
187.3599 -				>
187.3600 -				<FileConfiguration
187.3601 -					Name="Release|Win32"
187.3602 -					>
187.3603 -					<Tool
187.3604 -						Name="VCCLCompilerTool"
187.3605 -						UsePrecompiledHeader="2"
187.3606 -					/>
187.3607 -				</FileConfiguration>
187.3608 -				<FileConfiguration
187.3609 -					Name="Debug|Win32"
187.3610 -					>
187.3611 -					<Tool
187.3612 -						Name="VCCLCompilerTool"
187.3613 -						UsePrecompiledHeader="2"
187.3614 -					/>
187.3615 -				</FileConfiguration>
187.3616 -			</File>
187.3617 -			<File
187.3618 -				RelativePath=".\CPP\7zip\Compress\BcjRegister.cpp"
187.3619 -				>
187.3620 -				<FileConfiguration
187.3621 -					Name="Release|Win32"
187.3622 -					>
187.3623 -					<Tool
187.3624 -						Name="VCCLCompilerTool"
187.3625 -						UsePrecompiledHeader="2"
187.3626 -					/>
187.3627 -				</FileConfiguration>
187.3628 -				<FileConfiguration
187.3629 -					Name="Debug|Win32"
187.3630 -					>
187.3631 -					<Tool
187.3632 -						Name="VCCLCompilerTool"
187.3633 -						UsePrecompiledHeader="2"
187.3634 -					/>
187.3635 -				</FileConfiguration>
187.3636 -			</File>
187.3637 -			<File
187.3638 -				RelativePath=".\CPP\7zip\Compress\BranchRegister.cpp"
187.3639 -				>
187.3640 -				<FileConfiguration
187.3641 -					Name="Release|Win32"
187.3642 -					>
187.3643 -					<Tool
187.3644 -						Name="VCCLCompilerTool"
187.3645 -						UsePrecompiledHeader="2"
187.3646 -					/>
187.3647 -				</FileConfiguration>
187.3648 -				<FileConfiguration
187.3649 -					Name="Debug|Win32"
187.3650 -					>
187.3651 -					<Tool
187.3652 -						Name="VCCLCompilerTool"
187.3653 -						UsePrecompiledHeader="2"
187.3654 -					/>
187.3655 -				</FileConfiguration>
187.3656 -			</File>
187.3657 -			<File
187.3658 -				RelativePath=".\CPP\7zip\Compress\ByteSwapRegister.cpp"
187.3659 -				>
187.3660 -				<FileConfiguration
187.3661 -					Name="Release|Win32"
187.3662 -					>
187.3663 -					<Tool
187.3664 -						Name="VCCLCompilerTool"
187.3665 -						UsePrecompiledHeader="2"
187.3666 -					/>
187.3667 -				</FileConfiguration>
187.3668 -				<FileConfiguration
187.3669 -					Name="Debug|Win32"
187.3670 -					>
187.3671 -					<Tool
187.3672 -						Name="VCCLCompilerTool"
187.3673 -						UsePrecompiledHeader="2"
187.3674 -					/>
187.3675 -				</FileConfiguration>
187.3676 -			</File>
187.3677 -			<File
187.3678 -				RelativePath=".\CPP\7zip\Archive\BZip2\bz2Register.cpp"
187.3679 -				>
187.3680 -				<FileConfiguration
187.3681 -					Name="Release|Win32"
187.3682 -					>
187.3683 -					<Tool
187.3684 -						Name="VCCLCompilerTool"
187.3685 -						UsePrecompiledHeader="2"
187.3686 -					/>
187.3687 -				</FileConfiguration>
187.3688 -				<FileConfiguration
187.3689 -					Name="Debug|Win32"
187.3690 -					>
187.3691 -					<Tool
187.3692 -						Name="VCCLCompilerTool"
187.3693 -						UsePrecompiledHeader="2"
187.3694 -					/>
187.3695 -				</FileConfiguration>
187.3696 -			</File>
187.3697 -			<File
187.3698 -				RelativePath=".\CPP\7zip\Compress\BZip2Register.cpp"
187.3699 -				>
187.3700 -				<FileConfiguration
187.3701 -					Name="Release|Win32"
187.3702 -					>
187.3703 -					<Tool
187.3704 -						Name="VCCLCompilerTool"
187.3705 -						UsePrecompiledHeader="2"
187.3706 -					/>
187.3707 -				</FileConfiguration>
187.3708 -				<FileConfiguration
187.3709 -					Name="Debug|Win32"
187.3710 -					>
187.3711 -					<Tool
187.3712 -						Name="VCCLCompilerTool"
187.3713 -						UsePrecompiledHeader="2"
187.3714 -					/>
187.3715 -				</FileConfiguration>
187.3716 -			</File>
187.3717 -			<File
187.3718 -				RelativePath=".\CPP\7zip\Compress\CodecExports.cpp"
187.3719 -				>
187.3720 -				<FileConfiguration
187.3721 -					Name="Release|Win32"
187.3722 -					>
187.3723 -					<Tool
187.3724 -						Name="VCCLCompilerTool"
187.3725 -						UsePrecompiledHeader="2"
187.3726 -					/>
187.3727 -				</FileConfiguration>
187.3728 -				<FileConfiguration
187.3729 -					Name="Debug|Win32"
187.3730 -					>
187.3731 -					<Tool
187.3732 -						Name="VCCLCompilerTool"
187.3733 -						UsePrecompiledHeader="2"
187.3734 -					/>
187.3735 -				</FileConfiguration>
187.3736 -			</File>
187.3737 -			<File
187.3738 -				RelativePath=".\CPP\7zip\Compress\CopyRegister.cpp"
187.3739 -				>
187.3740 -				<FileConfiguration
187.3741 -					Name="Release|Win32"
187.3742 -					>
187.3743 -					<Tool
187.3744 -						Name="VCCLCompilerTool"
187.3745 -						UsePrecompiledHeader="2"
187.3746 -					/>
187.3747 -				</FileConfiguration>
187.3748 -				<FileConfiguration
187.3749 -					Name="Debug|Win32"
187.3750 -					>
187.3751 -					<Tool
187.3752 -						Name="VCCLCompilerTool"
187.3753 -						UsePrecompiledHeader="2"
187.3754 -					/>
187.3755 -				</FileConfiguration>
187.3756 -			</File>
187.3757 -			<File
187.3758 -				RelativePath=".\CPP\7zip\Common\CreateCoder.cpp"
187.3759 -				>
187.3760 -				<FileConfiguration
187.3761 -					Name="Release|Win32"
187.3762 -					>
187.3763 -					<Tool
187.3764 -						Name="VCCLCompilerTool"
187.3765 -						UsePrecompiledHeader="2"
187.3766 -					/>
187.3767 -				</FileConfiguration>
187.3768 -				<FileConfiguration
187.3769 -					Name="Debug|Win32"
187.3770 -					>
187.3771 -					<Tool
187.3772 -						Name="VCCLCompilerTool"
187.3773 -						UsePrecompiledHeader="2"
187.3774 -					/>
187.3775 -				</FileConfiguration>
187.3776 -			</File>
187.3777 -			<File
187.3778 -				RelativePath=".\CPP\7zip\Compress\Deflate64Register.cpp"
187.3779 -				>
187.3780 -				<FileConfiguration
187.3781 -					Name="Release|Win32"
187.3782 -					>
187.3783 -					<Tool
187.3784 -						Name="VCCLCompilerTool"
187.3785 -						UsePrecompiledHeader="2"
187.3786 -					/>
187.3787 -				</FileConfiguration>
187.3788 -				<FileConfiguration
187.3789 -					Name="Debug|Win32"
187.3790 -					>
187.3791 -					<Tool
187.3792 -						Name="VCCLCompilerTool"
187.3793 -						UsePrecompiledHeader="2"
187.3794 -					/>
187.3795 -				</FileConfiguration>
187.3796 -			</File>
187.3797 -			<File
187.3798 -				RelativePath=".\CPP\7zip\Compress\DeflateNsisRegister.cpp"
187.3799 -				>
187.3800 -				<FileConfiguration
187.3801 -					Name="Release|Win32"
187.3802 -					>
187.3803 -					<Tool
187.3804 -						Name="VCCLCompilerTool"
187.3805 -						UsePrecompiledHeader="2"
187.3806 -					/>
187.3807 -				</FileConfiguration>
187.3808 -				<FileConfiguration
187.3809 -					Name="Debug|Win32"
187.3810 -					>
187.3811 -					<Tool
187.3812 -						Name="VCCLCompilerTool"
187.3813 -						UsePrecompiledHeader="2"
187.3814 -					/>
187.3815 -				</FileConfiguration>
187.3816 -			</File>
187.3817 -			<File
187.3818 -				RelativePath=".\CPP\7zip\Compress\DeflateRegister.cpp"
187.3819 -				>
187.3820 -				<FileConfiguration
187.3821 -					Name="Release|Win32"
187.3822 -					>
187.3823 -					<Tool
187.3824 -						Name="VCCLCompilerTool"
187.3825 -						UsePrecompiledHeader="2"
187.3826 -					/>
187.3827 -				</FileConfiguration>
187.3828 -				<FileConfiguration
187.3829 -					Name="Debug|Win32"
187.3830 -					>
187.3831 -					<Tool
187.3832 -						Name="VCCLCompilerTool"
187.3833 -						UsePrecompiledHeader="2"
187.3834 -					/>
187.3835 -				</FileConfiguration>
187.3836 -			</File>
187.3837 -			<File
187.3838 -				RelativePath=".\CPP\7zip\Archive\DllExports2.cpp"
187.3839 -				>
187.3840 -				<FileConfiguration
187.3841 -					Name="Release|Win32"
187.3842 -					>
187.3843 -					<Tool
187.3844 -						Name="VCCLCompilerTool"
187.3845 -						UsePrecompiledHeader="2"
187.3846 -					/>
187.3847 -				</FileConfiguration>
187.3848 -				<FileConfiguration
187.3849 -					Name="Debug|Win32"
187.3850 -					>
187.3851 -					<Tool
187.3852 -						Name="VCCLCompilerTool"
187.3853 -						UsePrecompiledHeader="2"
187.3854 -					/>
187.3855 -				</FileConfiguration>
187.3856 -			</File>
187.3857 -			<File
187.3858 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipRegister.cpp"
187.3859 -				>
187.3860 -				<FileConfiguration
187.3861 -					Name="Release|Win32"
187.3862 -					>
187.3863 -					<Tool
187.3864 -						Name="VCCLCompilerTool"
187.3865 -						UsePrecompiledHeader="2"
187.3866 -					/>
187.3867 -				</FileConfiguration>
187.3868 -				<FileConfiguration
187.3869 -					Name="Debug|Win32"
187.3870 -					>
187.3871 -					<Tool
187.3872 -						Name="VCCLCompilerTool"
187.3873 -						UsePrecompiledHeader="2"
187.3874 -					/>
187.3875 -				</FileConfiguration>
187.3876 -			</File>
187.3877 -			<File
187.3878 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhRegister.cpp"
187.3879 -				>
187.3880 -				<FileConfiguration
187.3881 -					Name="Release|Win32"
187.3882 -					>
187.3883 -					<Tool
187.3884 -						Name="VCCLCompilerTool"
187.3885 -						UsePrecompiledHeader="2"
187.3886 -					/>
187.3887 -				</FileConfiguration>
187.3888 -				<FileConfiguration
187.3889 -					Name="Debug|Win32"
187.3890 -					>
187.3891 -					<Tool
187.3892 -						Name="VCCLCompilerTool"
187.3893 -						UsePrecompiledHeader="2"
187.3894 -					/>
187.3895 -				</FileConfiguration>
187.3896 -			</File>
187.3897 -			<File
187.3898 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaArcRegister.cpp"
187.3899 -				>
187.3900 -				<FileConfiguration
187.3901 -					Name="Release|Win32"
187.3902 -					>
187.3903 -					<Tool
187.3904 -						Name="VCCLCompilerTool"
187.3905 -						UsePrecompiledHeader="2"
187.3906 -					/>
187.3907 -				</FileConfiguration>
187.3908 -				<FileConfiguration
187.3909 -					Name="Debug|Win32"
187.3910 -					>
187.3911 -					<Tool
187.3912 -						Name="VCCLCompilerTool"
187.3913 -						UsePrecompiledHeader="2"
187.3914 -					/>
187.3915 -				</FileConfiguration>
187.3916 -			</File>
187.3917 -			<File
187.3918 -				RelativePath=".\CPP\7zip\Compress\LzmaRegister.cpp"
187.3919 -				>
187.3920 -				<FileConfiguration
187.3921 -					Name="Release|Win32"
187.3922 -					>
187.3923 -					<Tool
187.3924 -						Name="VCCLCompilerTool"
187.3925 -						UsePrecompiledHeader="2"
187.3926 -					/>
187.3927 -				</FileConfiguration>
187.3928 -				<FileConfiguration
187.3929 -					Name="Debug|Win32"
187.3930 -					>
187.3931 -					<Tool
187.3932 -						Name="VCCLCompilerTool"
187.3933 -						UsePrecompiledHeader="2"
187.3934 -					/>
187.3935 -				</FileConfiguration>
187.3936 -			</File>
187.3937 -			<File
187.3938 -				RelativePath=".\CPP\7zip\Compress\PpmdRegister.cpp"
187.3939 -				>
187.3940 -				<FileConfiguration
187.3941 -					Name="Release|Win32"
187.3942 -					>
187.3943 -					<Tool
187.3944 -						Name="VCCLCompilerTool"
187.3945 -						UsePrecompiledHeader="2"
187.3946 -					/>
187.3947 -				</FileConfiguration>
187.3948 -				<FileConfiguration
187.3949 -					Name="Debug|Win32"
187.3950 -					>
187.3951 -					<Tool
187.3952 -						Name="VCCLCompilerTool"
187.3953 -						UsePrecompiledHeader="2"
187.3954 -					/>
187.3955 -				</FileConfiguration>
187.3956 -			</File>
187.3957 -			<File
187.3958 -				RelativePath=".\CPP\7zip\Compress\RarCodecsRegister.cpp"
187.3959 -				>
187.3960 -				<FileConfiguration
187.3961 -					Name="Release|Win32"
187.3962 -					>
187.3963 -					<Tool
187.3964 -						Name="VCCLCompilerTool"
187.3965 -						UsePrecompiledHeader="2"
187.3966 -					/>
187.3967 -				</FileConfiguration>
187.3968 -				<FileConfiguration
187.3969 -					Name="Debug|Win32"
187.3970 -					>
187.3971 -					<Tool
187.3972 -						Name="VCCLCompilerTool"
187.3973 -						UsePrecompiledHeader="2"
187.3974 -					/>
187.3975 -				</FileConfiguration>
187.3976 -			</File>
187.3977 -			<File
187.3978 -				RelativePath=".\CPP\7zip\Archive\Rar\RarRegister.cpp"
187.3979 -				>
187.3980 -				<FileConfiguration
187.3981 -					Name="Release|Win32"
187.3982 -					>
187.3983 -					<Tool
187.3984 -						Name="VCCLCompilerTool"
187.3985 -						UsePrecompiledHeader="2"
187.3986 -					/>
187.3987 -				</FileConfiguration>
187.3988 -				<FileConfiguration
187.3989 -					Name="Debug|Win32"
187.3990 -					>
187.3991 -					<Tool
187.3992 -						Name="VCCLCompilerTool"
187.3993 -						UsePrecompiledHeader="2"
187.3994 -					/>
187.3995 -				</FileConfiguration>
187.3996 -			</File>
187.3997 -			<File
187.3998 -				RelativePath=".\CPP\7zip\Archive\Split\SplitRegister.cpp"
187.3999 -				>
187.4000 -				<FileConfiguration
187.4001 -					Name="Release|Win32"
187.4002 -					>
187.4003 -					<Tool
187.4004 -						Name="VCCLCompilerTool"
187.4005 -						UsePrecompiledHeader="2"
187.4006 -					/>
187.4007 -				</FileConfiguration>
187.4008 -				<FileConfiguration
187.4009 -					Name="Debug|Win32"
187.4010 -					>
187.4011 -					<Tool
187.4012 -						Name="VCCLCompilerTool"
187.4013 -						UsePrecompiledHeader="2"
187.4014 -					/>
187.4015 -				</FileConfiguration>
187.4016 -			</File>
187.4017 -			<File
187.4018 -				RelativePath=".\CPP\7zip\Archive\Tar\TarRegister.cpp"
187.4019 -				>
187.4020 -				<FileConfiguration
187.4021 -					Name="Release|Win32"
187.4022 -					>
187.4023 -					<Tool
187.4024 -						Name="VCCLCompilerTool"
187.4025 -						UsePrecompiledHeader="2"
187.4026 -					/>
187.4027 -				</FileConfiguration>
187.4028 -				<FileConfiguration
187.4029 -					Name="Debug|Win32"
187.4030 -					>
187.4031 -					<Tool
187.4032 -						Name="VCCLCompilerTool"
187.4033 -						UsePrecompiledHeader="2"
187.4034 -					/>
187.4035 -				</FileConfiguration>
187.4036 -			</File>
187.4037 -			<File
187.4038 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipRegister.cpp"
187.4039 -				>
187.4040 -				<FileConfiguration
187.4041 -					Name="Release|Win32"
187.4042 -					>
187.4043 -					<Tool
187.4044 -						Name="VCCLCompilerTool"
187.4045 -						UsePrecompiledHeader="2"
187.4046 -					/>
187.4047 -				</FileConfiguration>
187.4048 -				<FileConfiguration
187.4049 -					Name="Debug|Win32"
187.4050 -					>
187.4051 -					<Tool
187.4052 -						Name="VCCLCompilerTool"
187.4053 -						UsePrecompiledHeader="2"
187.4054 -					/>
187.4055 -				</FileConfiguration>
187.4056 -			</File>
187.4057 -		</Filter>
187.4058 -	</Files>
187.4059 -	<Globals>
187.4060 -	</Globals>
187.4061 -</VisualStudioProject>
   188.1 --- a/src/win32/7zip/7z/7zip_2008.vcproj	Sat Mar 03 10:54:39 2012 -0600
   188.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   188.3 @@ -1,5347 +0,0 @@
   188.4 -<?xml version="1.0" encoding="Windows-1252"?>
   188.5 -<VisualStudioProject
   188.6 -	ProjectType="Visual C++"
   188.7 -	Version="9.00"
   188.8 -	Name="wlib7zip"
   188.9 -	ProjectGUID="{5646C572-A578-49F8-9DA9-3E00A8CBFE3F}"
  188.10 -	RootNamespace="gens"
  188.11 -	TargetFrameworkVersion="131072"
  188.12 -	>
  188.13 -	<Platforms>
  188.14 -		<Platform
  188.15 -			Name="Win32"
  188.16 -		/>
  188.17 -	</Platforms>
  188.18 -	<ToolFiles>
  188.19 -		<DefaultToolFile
  188.20 -			FileName="masm.rules"
  188.21 -		/>
  188.22 -	</ToolFiles>
  188.23 -	<Configurations>
  188.24 -		<Configuration
  188.25 -			Name="Release|Win32"
  188.26 -			OutputDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
  188.27 -			IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
  188.28 -			ConfigurationType="4"
  188.29 -			UseOfMFC="0"
  188.30 -			ATLMinimizesCRunTimeLibraryUsage="false"
  188.31 -			WholeProgramOptimization="1"
  188.32 -			>
  188.33 -			<Tool
  188.34 -				Name="VCPreBuildEventTool"
  188.35 -			/>
  188.36 -			<Tool
  188.37 -				Name="VCCustomBuildTool"
  188.38 -			/>
  188.39 -			<Tool
  188.40 -				Name="MASM"
  188.41 -			/>
  188.42 -			<Tool
  188.43 -				Name="VCXMLDataGeneratorTool"
  188.44 -			/>
  188.45 -			<Tool
  188.46 -				Name="VCWebServiceProxyGeneratorTool"
  188.47 -			/>
  188.48 -			<Tool
  188.49 -				Name="VCMIDLTool"
  188.50 -				PreprocessorDefinitions="NDEBUG"
  188.51 -				MkTypLibCompatible="true"
  188.52 -				SuppressStartupBanner="true"
  188.53 -				TargetEnvironment="1"
  188.54 -				TypeLibraryName=".\Release/gens.tlb"
  188.55 -				HeaderFileName=""
  188.56 -			/>
  188.57 -			<Tool
  188.58 -				Name="VCCLCompilerTool"
  188.59 -				Optimization="3"
  188.60 -				InlineFunctionExpansion="2"
  188.61 -				EnableIntrinsicFunctions="true"
  188.62 -				FavorSizeOrSpeed="1"
  188.63 -				OmitFramePointers="true"
  188.64 -				EnableFiberSafeOptimizations="true"
  188.65 -				WholeProgramOptimization="true"
  188.66 -				AdditionalIncludeDirectories="CPP"
  188.67 -				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO"
  188.68 -				StringPooling="true"
  188.69 -				ExceptionHandling="1"
  188.70 -				RuntimeLibrary="0"
  188.71 -				UsePrecompiledHeader="2"
  188.72 -				PrecompiledHeaderFile="$(IntDir)\7z.pch"
  188.73 -				AssemblerListingLocation="$(IntDir)\"
  188.74 -				ObjectFile="$(IntDir)\"
  188.75 -				ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
  188.76 -				WarningLevel="3"
  188.77 -				SuppressStartupBanner="true"
  188.78 -				DebugInformationFormat="3"
  188.79 -				OmitDefaultLibName="true"
  188.80 -			/>
  188.81 -			<Tool
  188.82 -				Name="VCManagedResourceCompilerTool"
  188.83 -			/>
  188.84 -			<Tool
  188.85 -				Name="VCResourceCompilerTool"
  188.86 -				PreprocessorDefinitions="NDEBUG"
  188.87 -			/>
  188.88 -			<Tool
  188.89 -				Name="VCPreLinkEventTool"
  188.90 -			/>
  188.91 -			<Tool
  188.92 -				Name="VCLibrarianTool"
  188.93 -				AdditionalOptions=" /LTCG"
  188.94 -			/>
  188.95 -			<Tool
  188.96 -				Name="VCALinkTool"
  188.97 -			/>
  188.98 -			<Tool
  188.99 -				Name="VCXDCMakeTool"
 188.100 -			/>
 188.101 -			<Tool
 188.102 -				Name="VCBscMakeTool"
 188.103 -			/>
 188.104 -			<Tool
 188.105 -				Name="VCFxCopTool"
 188.106 -			/>
 188.107 -			<Tool
 188.108 -				Name="VCPostBuildEventTool"
 188.109 -			/>
 188.110 -		</Configuration>
 188.111 -		<Configuration
 188.112 -			Name="Debug|Win32"
 188.113 -			OutputDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 188.114 -			IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 188.115 -			ConfigurationType="4"
 188.116 -			UseOfMFC="0"
 188.117 -			ATLMinimizesCRunTimeLibraryUsage="false"
 188.118 -			>
 188.119 -			<Tool
 188.120 -				Name="VCPreBuildEventTool"
 188.121 -				CommandLine=""
 188.122 -			/>
 188.123 -			<Tool
 188.124 -				Name="VCCustomBuildTool"
 188.125 -				CommandLine=""
 188.126 -			/>
 188.127 -			<Tool
 188.128 -				Name="MASM"
 188.129 -			/>
 188.130 -			<Tool
 188.131 -				Name="VCXMLDataGeneratorTool"
 188.132 -			/>
 188.133 -			<Tool
 188.134 -				Name="VCWebServiceProxyGeneratorTool"
 188.135 -			/>
 188.136 -			<Tool
 188.137 -				Name="VCMIDLTool"
 188.138 -				PreprocessorDefinitions="NDEBUG"
 188.139 -				MkTypLibCompatible="true"
 188.140 -				SuppressStartupBanner="true"
 188.141 -				TargetEnvironment="1"
 188.142 -				TypeLibraryName=".\Release/gens.tlb"
 188.143 -				HeaderFileName=""
 188.144 -			/>
 188.145 -			<Tool
 188.146 -				Name="VCCLCompilerTool"
 188.147 -				Optimization="0"
 188.148 -				InlineFunctionExpansion="0"
 188.149 -				EnableIntrinsicFunctions="false"
 188.150 -				AdditionalIncludeDirectories="CPP"
 188.151 -				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO"
 188.152 -				StringPooling="false"
 188.153 -				ExceptionHandling="1"
 188.154 -				BasicRuntimeChecks="3"
 188.155 -				SmallerTypeCheck="true"
 188.156 -				RuntimeLibrary="0"
 188.157 -				EnableFunctionLevelLinking="false"
 188.158 -				UsePrecompiledHeader="2"
 188.159 -				PrecompiledHeaderFile="$(IntDir)\7z.pch"
 188.160 -				AssemblerListingLocation="$(IntDir)\"
 188.161 -				ObjectFile="$(IntDir)\"
 188.162 -				ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
 188.163 -				WarningLevel="3"
 188.164 -				SuppressStartupBanner="true"
 188.165 -				DebugInformationFormat="3"
 188.166 -				OmitDefaultLibName="true"
 188.167 -			/>
 188.168 -			<Tool
 188.169 -				Name="VCManagedResourceCompilerTool"
 188.170 -			/>
 188.171 -			<Tool
 188.172 -				Name="VCResourceCompilerTool"
 188.173 -				PreprocessorDefinitions="NDEBUG"
 188.174 -			/>
 188.175 -			<Tool
 188.176 -				Name="VCPreLinkEventTool"
 188.177 -			/>
 188.178 -			<Tool
 188.179 -				Name="VCLibrarianTool"
 188.180 -			/>
 188.181 -			<Tool
 188.182 -				Name="VCALinkTool"
 188.183 -			/>
 188.184 -			<Tool
 188.185 -				Name="VCXDCMakeTool"
 188.186 -			/>
 188.187 -			<Tool
 188.188 -				Name="VCBscMakeTool"
 188.189 -			/>
 188.190 -			<Tool
 188.191 -				Name="VCFxCopTool"
 188.192 -			/>
 188.193 -			<Tool
 188.194 -				Name="VCPostBuildEventTool"
 188.195 -			/>
 188.196 -		</Configuration>
 188.197 -		<Configuration
 188.198 -			Name="Release FastBuild|Win32"
 188.199 -			OutputDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 188.200 -			IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)\$(ProjectName)"
 188.201 -			ConfigurationType="4"
 188.202 -			UseOfMFC="0"
 188.203 -			ATLMinimizesCRunTimeLibraryUsage="false"
 188.204 -			WholeProgramOptimization="0"
 188.205 -			>
 188.206 -			<Tool
 188.207 -				Name="VCPreBuildEventTool"
 188.208 -			/>
 188.209 -			<Tool
 188.210 -				Name="VCCustomBuildTool"
 188.211 -			/>
 188.212 -			<Tool
 188.213 -				Name="MASM"
 188.214 -			/>
 188.215 -			<Tool
 188.216 -				Name="VCXMLDataGeneratorTool"
 188.217 -			/>
 188.218 -			<Tool
 188.219 -				Name="VCWebServiceProxyGeneratorTool"
 188.220 -			/>
 188.221 -			<Tool
 188.222 -				Name="VCMIDLTool"
 188.223 -				PreprocessorDefinitions="NDEBUG"
 188.224 -				MkTypLibCompatible="true"
 188.225 -				SuppressStartupBanner="true"
 188.226 -				TargetEnvironment="1"
 188.227 -				TypeLibraryName=".\Release/gens.tlb"
 188.228 -				HeaderFileName=""
 188.229 -			/>
 188.230 -			<Tool
 188.231 -				Name="VCCLCompilerTool"
 188.232 -				Optimization="3"
 188.233 -				InlineFunctionExpansion="2"
 188.234 -				EnableIntrinsicFunctions="true"
 188.235 -				FavorSizeOrSpeed="1"
 188.236 -				OmitFramePointers="true"
 188.237 -				EnableFiberSafeOptimizations="true"
 188.238 -				WholeProgramOptimization="false"
 188.239 -				AdditionalIncludeDirectories="CPP"
 188.240 -				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO"
 188.241 -				StringPooling="true"
 188.242 -				ExceptionHandling="1"
 188.243 -				RuntimeLibrary="0"
 188.244 -				UsePrecompiledHeader="2"
 188.245 -				PrecompiledHeaderFile="$(IntDir)\7z.pch"
 188.246 -				AssemblerListingLocation="$(IntDir)\"
 188.247 -				ObjectFile="$(IntDir)\"
 188.248 -				ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
 188.249 -				WarningLevel="3"
 188.250 -				SuppressStartupBanner="true"
 188.251 -				DebugInformationFormat="3"
 188.252 -				OmitDefaultLibName="true"
 188.253 -			/>
 188.254 -			<Tool
 188.255 -				Name="VCManagedResourceCompilerTool"
 188.256 -			/>
 188.257 -			<Tool
 188.258 -				Name="VCResourceCompilerTool"
 188.259 -				PreprocessorDefinitions="NDEBUG"
 188.260 -			/>
 188.261 -			<Tool
 188.262 -				Name="VCPreLinkEventTool"
 188.263 -			/>
 188.264 -			<Tool
 188.265 -				Name="VCLibrarianTool"
 188.266 -				AdditionalOptions=" /LTCG"
 188.267 -			/>
 188.268 -			<Tool
 188.269 -				Name="VCALinkTool"
 188.270 -			/>
 188.271 -			<Tool
 188.272 -				Name="VCXDCMakeTool"
 188.273 -			/>
 188.274 -			<Tool
 188.275 -				Name="VCBscMakeTool"
 188.276 -			/>
 188.277 -			<Tool
 188.278 -				Name="VCFxCopTool"
 188.279 -			/>
 188.280 -			<Tool
 188.281 -				Name="VCPostBuildEventTool"
 188.282 -			/>
 188.283 -		</Configuration>
 188.284 -	</Configurations>
 188.285 -	<References>
 188.286 -	</References>
 188.287 -	<Files>
 188.288 -		<Filter
 188.289 -			Name="7zip"
 188.290 -			>
 188.291 -			<File
 188.292 -				RelativePath=".\CPP\7zip\Common\FilterCoder.cpp"
 188.293 -				>
 188.294 -				<FileConfiguration
 188.295 -					Name="Release|Win32"
 188.296 -					>
 188.297 -					<Tool
 188.298 -						Name="VCCLCompilerTool"
 188.299 -						UsePrecompiledHeader="2"
 188.300 -					/>
 188.301 -				</FileConfiguration>
 188.302 -				<FileConfiguration
 188.303 -					Name="Debug|Win32"
 188.304 -					>
 188.305 -					<Tool
 188.306 -						Name="VCCLCompilerTool"
 188.307 -						UsePrecompiledHeader="2"
 188.308 -					/>
 188.309 -				</FileConfiguration>
 188.310 -				<FileConfiguration
 188.311 -					Name="Release FastBuild|Win32"
 188.312 -					>
 188.313 -					<Tool
 188.314 -						Name="VCCLCompilerTool"
 188.315 -						UsePrecompiledHeader="2"
 188.316 -					/>
 188.317 -				</FileConfiguration>
 188.318 -			</File>
 188.319 -			<File
 188.320 -				RelativePath=".\CPP\7zip\Common\InBuffer.cpp"
 188.321 -				>
 188.322 -				<FileConfiguration
 188.323 -					Name="Release|Win32"
 188.324 -					>
 188.325 -					<Tool
 188.326 -						Name="VCCLCompilerTool"
 188.327 -						UsePrecompiledHeader="2"
 188.328 -					/>
 188.329 -				</FileConfiguration>
 188.330 -				<FileConfiguration
 188.331 -					Name="Debug|Win32"
 188.332 -					>
 188.333 -					<Tool
 188.334 -						Name="VCCLCompilerTool"
 188.335 -						UsePrecompiledHeader="2"
 188.336 -					/>
 188.337 -				</FileConfiguration>
 188.338 -				<FileConfiguration
 188.339 -					Name="Release FastBuild|Win32"
 188.340 -					>
 188.341 -					<Tool
 188.342 -						Name="VCCLCompilerTool"
 188.343 -						UsePrecompiledHeader="2"
 188.344 -					/>
 188.345 -				</FileConfiguration>
 188.346 -			</File>
 188.347 -			<File
 188.348 -				RelativePath=".\CPP\7zip\Common\InOutTempBuffer.cpp"
 188.349 -				>
 188.350 -				<FileConfiguration
 188.351 -					Name="Release|Win32"
 188.352 -					>
 188.353 -					<Tool
 188.354 -						Name="VCCLCompilerTool"
 188.355 -						UsePrecompiledHeader="2"
 188.356 -					/>
 188.357 -				</FileConfiguration>
 188.358 -				<FileConfiguration
 188.359 -					Name="Debug|Win32"
 188.360 -					>
 188.361 -					<Tool
 188.362 -						Name="VCCLCompilerTool"
 188.363 -						UsePrecompiledHeader="2"
 188.364 -					/>
 188.365 -				</FileConfiguration>
 188.366 -				<FileConfiguration
 188.367 -					Name="Release FastBuild|Win32"
 188.368 -					>
 188.369 -					<Tool
 188.370 -						Name="VCCLCompilerTool"
 188.371 -						UsePrecompiledHeader="2"
 188.372 -					/>
 188.373 -				</FileConfiguration>
 188.374 -			</File>
 188.375 -			<File
 188.376 -				RelativePath=".\CPP\7zip\Common\LimitedStreams.cpp"
 188.377 -				>
 188.378 -				<FileConfiguration
 188.379 -					Name="Release|Win32"
 188.380 -					>
 188.381 -					<Tool
 188.382 -						Name="VCCLCompilerTool"
 188.383 -						UsePrecompiledHeader="2"
 188.384 -					/>
 188.385 -				</FileConfiguration>
 188.386 -				<FileConfiguration
 188.387 -					Name="Debug|Win32"
 188.388 -					>
 188.389 -					<Tool
 188.390 -						Name="VCCLCompilerTool"
 188.391 -						UsePrecompiledHeader="2"
 188.392 -					/>
 188.393 -				</FileConfiguration>
 188.394 -				<FileConfiguration
 188.395 -					Name="Release FastBuild|Win32"
 188.396 -					>
 188.397 -					<Tool
 188.398 -						Name="VCCLCompilerTool"
 188.399 -						UsePrecompiledHeader="2"
 188.400 -					/>
 188.401 -				</FileConfiguration>
 188.402 -			</File>
 188.403 -			<File
 188.404 -				RelativePath=".\CPP\7zip\Common\LockedStream.cpp"
 188.405 -				>
 188.406 -				<FileConfiguration
 188.407 -					Name="Release|Win32"
 188.408 -					>
 188.409 -					<Tool
 188.410 -						Name="VCCLCompilerTool"
 188.411 -						UsePrecompiledHeader="2"
 188.412 -					/>
 188.413 -				</FileConfiguration>
 188.414 -				<FileConfiguration
 188.415 -					Name="Debug|Win32"
 188.416 -					>
 188.417 -					<Tool
 188.418 -						Name="VCCLCompilerTool"
 188.419 -						UsePrecompiledHeader="2"
 188.420 -					/>
 188.421 -				</FileConfiguration>
 188.422 -				<FileConfiguration
 188.423 -					Name="Release FastBuild|Win32"
 188.424 -					>
 188.425 -					<Tool
 188.426 -						Name="VCCLCompilerTool"
 188.427 -						UsePrecompiledHeader="2"
 188.428 -					/>
 188.429 -				</FileConfiguration>
 188.430 -			</File>
 188.431 -			<File
 188.432 -				RelativePath=".\CPP\7zip\Common\MemBlocks.cpp"
 188.433 -				>
 188.434 -				<FileConfiguration
 188.435 -					Name="Release|Win32"
 188.436 -					>
 188.437 -					<Tool
 188.438 -						Name="VCCLCompilerTool"
 188.439 -						UsePrecompiledHeader="2"
 188.440 -					/>
 188.441 -				</FileConfiguration>
 188.442 -				<FileConfiguration
 188.443 -					Name="Debug|Win32"
 188.444 -					>
 188.445 -					<Tool
 188.446 -						Name="VCCLCompilerTool"
 188.447 -						UsePrecompiledHeader="2"
 188.448 -					/>
 188.449 -				</FileConfiguration>
 188.450 -				<FileConfiguration
 188.451 -					Name="Release FastBuild|Win32"
 188.452 -					>
 188.453 -					<Tool
 188.454 -						Name="VCCLCompilerTool"
 188.455 -						UsePrecompiledHeader="2"
 188.456 -					/>
 188.457 -				</FileConfiguration>
 188.458 -			</File>
 188.459 -			<File
 188.460 -				RelativePath=".\CPP\7zip\Common\MethodId.cpp"
 188.461 -				>
 188.462 -				<FileConfiguration
 188.463 -					Name="Release|Win32"
 188.464 -					>
 188.465 -					<Tool
 188.466 -						Name="VCCLCompilerTool"
 188.467 -						UsePrecompiledHeader="2"
 188.468 -					/>
 188.469 -				</FileConfiguration>
 188.470 -				<FileConfiguration
 188.471 -					Name="Debug|Win32"
 188.472 -					>
 188.473 -					<Tool
 188.474 -						Name="VCCLCompilerTool"
 188.475 -						UsePrecompiledHeader="2"
 188.476 -					/>
 188.477 -				</FileConfiguration>
 188.478 -				<FileConfiguration
 188.479 -					Name="Release FastBuild|Win32"
 188.480 -					>
 188.481 -					<Tool
 188.482 -						Name="VCCLCompilerTool"
 188.483 -						UsePrecompiledHeader="2"
 188.484 -					/>
 188.485 -				</FileConfiguration>
 188.486 -			</File>
 188.487 -			<File
 188.488 -				RelativePath=".\CPP\7zip\Common\MethodProps.cpp"
 188.489 -				>
 188.490 -				<FileConfiguration
 188.491 -					Name="Release|Win32"
 188.492 -					>
 188.493 -					<Tool
 188.494 -						Name="VCCLCompilerTool"
 188.495 -						UsePrecompiledHeader="2"
 188.496 -					/>
 188.497 -				</FileConfiguration>
 188.498 -				<FileConfiguration
 188.499 -					Name="Debug|Win32"
 188.500 -					>
 188.501 -					<Tool
 188.502 -						Name="VCCLCompilerTool"
 188.503 -						UsePrecompiledHeader="2"
 188.504 -					/>
 188.505 -				</FileConfiguration>
 188.506 -				<FileConfiguration
 188.507 -					Name="Release FastBuild|Win32"
 188.508 -					>
 188.509 -					<Tool
 188.510 -						Name="VCCLCompilerTool"
 188.511 -						UsePrecompiledHeader="2"
 188.512 -					/>
 188.513 -				</FileConfiguration>
 188.514 -			</File>
 188.515 -			<File
 188.516 -				RelativePath=".\CPP\7zip\Common\OffsetStream.cpp"
 188.517 -				>
 188.518 -				<FileConfiguration
 188.519 -					Name="Release|Win32"
 188.520 -					>
 188.521 -					<Tool
 188.522 -						Name="VCCLCompilerTool"
 188.523 -						UsePrecompiledHeader="2"
 188.524 -					/>
 188.525 -				</FileConfiguration>
 188.526 -				<FileConfiguration
 188.527 -					Name="Debug|Win32"
 188.528 -					>
 188.529 -					<Tool
 188.530 -						Name="VCCLCompilerTool"
 188.531 -						UsePrecompiledHeader="2"
 188.532 -					/>
 188.533 -				</FileConfiguration>
 188.534 -				<FileConfiguration
 188.535 -					Name="Release FastBuild|Win32"
 188.536 -					>
 188.537 -					<Tool
 188.538 -						Name="VCCLCompilerTool"
 188.539 -						UsePrecompiledHeader="2"
 188.540 -					/>
 188.541 -				</FileConfiguration>
 188.542 -			</File>
 188.543 -			<File
 188.544 -				RelativePath=".\CPP\7zip\Common\OutBuffer.cpp"
 188.545 -				>
 188.546 -				<FileConfiguration
 188.547 -					Name="Release|Win32"
 188.548 -					>
 188.549 -					<Tool
 188.550 -						Name="VCCLCompilerTool"
 188.551 -						UsePrecompiledHeader="2"
 188.552 -					/>
 188.553 -				</FileConfiguration>
 188.554 -				<FileConfiguration
 188.555 -					Name="Debug|Win32"
 188.556 -					>
 188.557 -					<Tool
 188.558 -						Name="VCCLCompilerTool"
 188.559 -						UsePrecompiledHeader="2"
 188.560 -					/>
 188.561 -				</FileConfiguration>
 188.562 -				<FileConfiguration
 188.563 -					Name="Release FastBuild|Win32"
 188.564 -					>
 188.565 -					<Tool
 188.566 -						Name="VCCLCompilerTool"
 188.567 -						UsePrecompiledHeader="2"
 188.568 -					/>
 188.569 -				</FileConfiguration>
 188.570 -			</File>
 188.571 -			<File
 188.572 -				RelativePath=".\CPP\7zip\Common\OutMemStream.cpp"
 188.573 -				>
 188.574 -				<FileConfiguration
 188.575 -					Name="Release|Win32"
 188.576 -					>
 188.577 -					<Tool
 188.578 -						Name="VCCLCompilerTool"
 188.579 -						UsePrecompiledHeader="2"
 188.580 -					/>
 188.581 -				</FileConfiguration>
 188.582 -				<FileConfiguration
 188.583 -					Name="Debug|Win32"
 188.584 -					>
 188.585 -					<Tool
 188.586 -						Name="VCCLCompilerTool"
 188.587 -						UsePrecompiledHeader="2"
 188.588 -					/>
 188.589 -				</FileConfiguration>
 188.590 -				<FileConfiguration
 188.591 -					Name="Release FastBuild|Win32"
 188.592 -					>
 188.593 -					<Tool
 188.594 -						Name="VCCLCompilerTool"
 188.595 -						UsePrecompiledHeader="2"
 188.596 -					/>
 188.597 -				</FileConfiguration>
 188.598 -			</File>
 188.599 -			<File
 188.600 -				RelativePath=".\CPP\7zip\Common\ProgressMt.cpp"
 188.601 -				>
 188.602 -				<FileConfiguration
 188.603 -					Name="Release|Win32"
 188.604 -					>
 188.605 -					<Tool
 188.606 -						Name="VCCLCompilerTool"
 188.607 -						UsePrecompiledHeader="2"
 188.608 -					/>
 188.609 -				</FileConfiguration>
 188.610 -				<FileConfiguration
 188.611 -					Name="Debug|Win32"
 188.612 -					>
 188.613 -					<Tool
 188.614 -						Name="VCCLCompilerTool"
 188.615 -						UsePrecompiledHeader="2"
 188.616 -					/>
 188.617 -				</FileConfiguration>
 188.618 -				<FileConfiguration
 188.619 -					Name="Release FastBuild|Win32"
 188.620 -					>
 188.621 -					<Tool
 188.622 -						Name="VCCLCompilerTool"
 188.623 -						UsePrecompiledHeader="2"
 188.624 -					/>
 188.625 -				</FileConfiguration>
 188.626 -			</File>
 188.627 -			<File
 188.628 -				RelativePath=".\CPP\7zip\Common\ProgressUtils.cpp"
 188.629 -				>
 188.630 -				<FileConfiguration
 188.631 -					Name="Release|Win32"
 188.632 -					>
 188.633 -					<Tool
 188.634 -						Name="VCCLCompilerTool"
 188.635 -						UsePrecompiledHeader="2"
 188.636 -					/>
 188.637 -				</FileConfiguration>
 188.638 -				<FileConfiguration
 188.639 -					Name="Debug|Win32"
 188.640 -					>
 188.641 -					<Tool
 188.642 -						Name="VCCLCompilerTool"
 188.643 -						UsePrecompiledHeader="2"
 188.644 -					/>
 188.645 -				</FileConfiguration>
 188.646 -				<FileConfiguration
 188.647 -					Name="Release FastBuild|Win32"
 188.648 -					>
 188.649 -					<Tool
 188.650 -						Name="VCCLCompilerTool"
 188.651 -						UsePrecompiledHeader="2"
 188.652 -					/>
 188.653 -				</FileConfiguration>
 188.654 -			</File>
 188.655 -			<File
 188.656 -				RelativePath=".\CPP\7zip\Common\StreamBinder.cpp"
 188.657 -				>
 188.658 -				<FileConfiguration
 188.659 -					Name="Release|Win32"
 188.660 -					>
 188.661 -					<Tool
 188.662 -						Name="VCCLCompilerTool"
 188.663 -						UsePrecompiledHeader="2"
 188.664 -					/>
 188.665 -				</FileConfiguration>
 188.666 -				<FileConfiguration
 188.667 -					Name="Debug|Win32"
 188.668 -					>
 188.669 -					<Tool
 188.670 -						Name="VCCLCompilerTool"
 188.671 -						UsePrecompiledHeader="2"
 188.672 -					/>
 188.673 -				</FileConfiguration>
 188.674 -				<FileConfiguration
 188.675 -					Name="Release FastBuild|Win32"
 188.676 -					>
 188.677 -					<Tool
 188.678 -						Name="VCCLCompilerTool"
 188.679 -						UsePrecompiledHeader="2"
 188.680 -					/>
 188.681 -				</FileConfiguration>
 188.682 -			</File>
 188.683 -			<File
 188.684 -				RelativePath=".\CPP\7zip\Common\StreamObjects.cpp"
 188.685 -				>
 188.686 -				<FileConfiguration
 188.687 -					Name="Release|Win32"
 188.688 -					>
 188.689 -					<Tool
 188.690 -						Name="VCCLCompilerTool"
 188.691 -						UsePrecompiledHeader="2"
 188.692 -					/>
 188.693 -				</FileConfiguration>
 188.694 -				<FileConfiguration
 188.695 -					Name="Debug|Win32"
 188.696 -					>
 188.697 -					<Tool
 188.698 -						Name="VCCLCompilerTool"
 188.699 -						UsePrecompiledHeader="2"
 188.700 -					/>
 188.701 -				</FileConfiguration>
 188.702 -				<FileConfiguration
 188.703 -					Name="Release FastBuild|Win32"
 188.704 -					>
 188.705 -					<Tool
 188.706 -						Name="VCCLCompilerTool"
 188.707 -						UsePrecompiledHeader="2"
 188.708 -					/>
 188.709 -				</FileConfiguration>
 188.710 -			</File>
 188.711 -			<File
 188.712 -				RelativePath=".\CPP\7zip\Common\StreamUtils.cpp"
 188.713 -				>
 188.714 -				<FileConfiguration
 188.715 -					Name="Release|Win32"
 188.716 -					>
 188.717 -					<Tool
 188.718 -						Name="VCCLCompilerTool"
 188.719 -						UsePrecompiledHeader="2"
 188.720 -					/>
 188.721 -				</FileConfiguration>
 188.722 -				<FileConfiguration
 188.723 -					Name="Debug|Win32"
 188.724 -					>
 188.725 -					<Tool
 188.726 -						Name="VCCLCompilerTool"
 188.727 -						UsePrecompiledHeader="2"
 188.728 -					/>
 188.729 -				</FileConfiguration>
 188.730 -				<FileConfiguration
 188.731 -					Name="Release FastBuild|Win32"
 188.732 -					>
 188.733 -					<Tool
 188.734 -						Name="VCCLCompilerTool"
 188.735 -						UsePrecompiledHeader="2"
 188.736 -					/>
 188.737 -				</FileConfiguration>
 188.738 -			</File>
 188.739 -			<File
 188.740 -				RelativePath=".\CPP\7zip\Common\VirtThread.cpp"
 188.741 -				>
 188.742 -				<FileConfiguration
 188.743 -					Name="Release|Win32"
 188.744 -					>
 188.745 -					<Tool
 188.746 -						Name="VCCLCompilerTool"
 188.747 -						UsePrecompiledHeader="2"
 188.748 -					/>
 188.749 -				</FileConfiguration>
 188.750 -				<FileConfiguration
 188.751 -					Name="Debug|Win32"
 188.752 -					>
 188.753 -					<Tool
 188.754 -						Name="VCCLCompilerTool"
 188.755 -						UsePrecompiledHeader="2"
 188.756 -					/>
 188.757 -				</FileConfiguration>
 188.758 -				<FileConfiguration
 188.759 -					Name="Release FastBuild|Win32"
 188.760 -					>
 188.761 -					<Tool
 188.762 -						Name="VCCLCompilerTool"
 188.763 -						UsePrecompiledHeader="2"
 188.764 -					/>
 188.765 -				</FileConfiguration>
 188.766 -			</File>
 188.767 -		</Filter>
 188.768 -		<Filter
 188.769 -			Name="Windows"
 188.770 -			>
 188.771 -			<File
 188.772 -				RelativePath=".\CPP\Windows\FileDir.cpp"
 188.773 -				>
 188.774 -				<FileConfiguration
 188.775 -					Name="Release|Win32"
 188.776 -					>
 188.777 -					<Tool
 188.778 -						Name="VCCLCompilerTool"
 188.779 -						UsePrecompiledHeader="2"
 188.780 -					/>
 188.781 -				</FileConfiguration>
 188.782 -				<FileConfiguration
 188.783 -					Name="Debug|Win32"
 188.784 -					>
 188.785 -					<Tool
 188.786 -						Name="VCCLCompilerTool"
 188.787 -						UsePrecompiledHeader="2"
 188.788 -					/>
 188.789 -				</FileConfiguration>
 188.790 -				<FileConfiguration
 188.791 -					Name="Release FastBuild|Win32"
 188.792 -					>
 188.793 -					<Tool
 188.794 -						Name="VCCLCompilerTool"
 188.795 -						UsePrecompiledHeader="2"
 188.796 -					/>
 188.797 -				</FileConfiguration>
 188.798 -			</File>
 188.799 -			<File
 188.800 -				RelativePath=".\CPP\Windows\FileFind.cpp"
 188.801 -				>
 188.802 -				<FileConfiguration
 188.803 -					Name="Release|Win32"
 188.804 -					>
 188.805 -					<Tool
 188.806 -						Name="VCCLCompilerTool"
 188.807 -						UsePrecompiledHeader="2"
 188.808 -					/>
 188.809 -				</FileConfiguration>
 188.810 -				<FileConfiguration
 188.811 -					Name="Debug|Win32"
 188.812 -					>
 188.813 -					<Tool
 188.814 -						Name="VCCLCompilerTool"
 188.815 -						UsePrecompiledHeader="2"
 188.816 -					/>
 188.817 -				</FileConfiguration>
 188.818 -				<FileConfiguration
 188.819 -					Name="Release FastBuild|Win32"
 188.820 -					>
 188.821 -					<Tool
 188.822 -						Name="VCCLCompilerTool"
 188.823 -						UsePrecompiledHeader="2"
 188.824 -					/>
 188.825 -				</FileConfiguration>
 188.826 -			</File>
 188.827 -			<File
 188.828 -				RelativePath=".\CPP\Windows\FileIO.cpp"
 188.829 -				>
 188.830 -				<FileConfiguration
 188.831 -					Name="Release|Win32"
 188.832 -					>
 188.833 -					<Tool
 188.834 -						Name="VCCLCompilerTool"
 188.835 -						UsePrecompiledHeader="2"
 188.836 -					/>
 188.837 -				</FileConfiguration>
 188.838 -				<FileConfiguration
 188.839 -					Name="Debug|Win32"
 188.840 -					>
 188.841 -					<Tool
 188.842 -						Name="VCCLCompilerTool"
 188.843 -						UsePrecompiledHeader="2"
 188.844 -					/>
 188.845 -				</FileConfiguration>
 188.846 -				<FileConfiguration
 188.847 -					Name="Release FastBuild|Win32"
 188.848 -					>
 188.849 -					<Tool
 188.850 -						Name="VCCLCompilerTool"
 188.851 -						UsePrecompiledHeader="2"
 188.852 -					/>
 188.853 -				</FileConfiguration>
 188.854 -			</File>
 188.855 -			<File
 188.856 -				RelativePath=".\CPP\Windows\PropVariant.cpp"
 188.857 -				>
 188.858 -				<FileConfiguration
 188.859 -					Name="Release|Win32"
 188.860 -					>
 188.861 -					<Tool
 188.862 -						Name="VCCLCompilerTool"
 188.863 -						UsePrecompiledHeader="2"
 188.864 -					/>
 188.865 -				</FileConfiguration>
 188.866 -				<FileConfiguration
 188.867 -					Name="Debug|Win32"
 188.868 -					>
 188.869 -					<Tool
 188.870 -						Name="VCCLCompilerTool"
 188.871 -						UsePrecompiledHeader="2"
 188.872 -					/>
 188.873 -				</FileConfiguration>
 188.874 -				<FileConfiguration
 188.875 -					Name="Release FastBuild|Win32"
 188.876 -					>
 188.877 -					<Tool
 188.878 -						Name="VCCLCompilerTool"
 188.879 -						UsePrecompiledHeader="2"
 188.880 -					/>
 188.881 -				</FileConfiguration>
 188.882 -			</File>
 188.883 -			<File
 188.884 -				RelativePath=".\CPP\Windows\Time.cpp"
 188.885 -				>
 188.886 -				<FileConfiguration
 188.887 -					Name="Release|Win32"
 188.888 -					>
 188.889 -					<Tool
 188.890 -						Name="VCCLCompilerTool"
 188.891 -						UsePrecompiledHeader="2"
 188.892 -					/>
 188.893 -				</FileConfiguration>
 188.894 -				<FileConfiguration
 188.895 -					Name="Debug|Win32"
 188.896 -					>
 188.897 -					<Tool
 188.898 -						Name="VCCLCompilerTool"
 188.899 -						UsePrecompiledHeader="2"
 188.900 -					/>
 188.901 -				</FileConfiguration>
 188.902 -				<FileConfiguration
 188.903 -					Name="Release FastBuild|Win32"
 188.904 -					>
 188.905 -					<Tool
 188.906 -						Name="VCCLCompilerTool"
 188.907 -						UsePrecompiledHeader="2"
 188.908 -					/>
 188.909 -				</FileConfiguration>
 188.910 -			</File>
 188.911 -		</Filter>
 188.912 -		<Filter
 188.913 -			Name="Archive"
 188.914 -			>
 188.915 -			<Filter
 188.916 -				Name="7z"
 188.917 -				>
 188.918 -				<File
 188.919 -					RelativePath=".\CPP\7zip\Archive\7z\7zCompressionMode.cpp"
 188.920 -					>
 188.921 -					<FileConfiguration
 188.922 -						Name="Release|Win32"
 188.923 -						>
 188.924 -						<Tool
 188.925 -							Name="VCCLCompilerTool"
 188.926 -							UsePrecompiledHeader="2"
 188.927 -						/>
 188.928 -					</FileConfiguration>
 188.929 -					<FileConfiguration
 188.930 -						Name="Debug|Win32"
 188.931 -						>
 188.932 -						<Tool
 188.933 -							Name="VCCLCompilerTool"
 188.934 -							UsePrecompiledHeader="2"
 188.935 -						/>
 188.936 -					</FileConfiguration>
 188.937 -					<FileConfiguration
 188.938 -						Name="Release FastBuild|Win32"
 188.939 -						>
 188.940 -						<Tool
 188.941 -							Name="VCCLCompilerTool"
 188.942 -							UsePrecompiledHeader="2"
 188.943 -						/>
 188.944 -					</FileConfiguration>
 188.945 -				</File>
 188.946 -				<File
 188.947 -					RelativePath=".\CPP\7zip\Archive\7z\7zDecode.cpp"
 188.948 -					>
 188.949 -					<FileConfiguration
 188.950 -						Name="Release|Win32"
 188.951 -						>
 188.952 -						<Tool
 188.953 -							Name="VCCLCompilerTool"
 188.954 -							UsePrecompiledHeader="2"
 188.955 -						/>
 188.956 -					</FileConfiguration>
 188.957 -					<FileConfiguration
 188.958 -						Name="Debug|Win32"
 188.959 -						>
 188.960 -						<Tool
 188.961 -							Name="VCCLCompilerTool"
 188.962 -							UsePrecompiledHeader="2"
 188.963 -						/>
 188.964 -					</FileConfiguration>
 188.965 -					<FileConfiguration
 188.966 -						Name="Release FastBuild|Win32"
 188.967 -						>
 188.968 -						<Tool
 188.969 -							Name="VCCLCompilerTool"
 188.970 -							UsePrecompiledHeader="2"
 188.971 -						/>
 188.972 -					</FileConfiguration>
 188.973 -				</File>
 188.974 -				<File
 188.975 -					RelativePath=".\CPP\7zip\Archive\7z\7zExtract.cpp"
 188.976 -					>
 188.977 -					<FileConfiguration
 188.978 -						Name="Release|Win32"
 188.979 -						>
 188.980 -						<Tool
 188.981 -							Name="VCCLCompilerTool"
 188.982 -							UsePrecompiledHeader="2"
 188.983 -						/>
 188.984 -					</FileConfiguration>
 188.985 -					<FileConfiguration
 188.986 -						Name="Debug|Win32"
 188.987 -						>
 188.988 -						<Tool
 188.989 -							Name="VCCLCompilerTool"
 188.990 -							UsePrecompiledHeader="2"
 188.991 -						/>
 188.992 -					</FileConfiguration>
 188.993 -					<FileConfiguration
 188.994 -						Name="Release FastBuild|Win32"
 188.995 -						>
 188.996 -						<Tool
 188.997 -							Name="VCCLCompilerTool"
 188.998 -							UsePrecompiledHeader="2"
 188.999 -						/>
188.1000 -					</FileConfiguration>
188.1001 -				</File>
188.1002 -				<File
188.1003 -					RelativePath=".\CPP\7zip\Archive\7z\7zFolderInStream.cpp"
188.1004 -					>
188.1005 -					<FileConfiguration
188.1006 -						Name="Release|Win32"
188.1007 -						>
188.1008 -						<Tool
188.1009 -							Name="VCCLCompilerTool"
188.1010 -							UsePrecompiledHeader="2"
188.1011 -						/>
188.1012 -					</FileConfiguration>
188.1013 -					<FileConfiguration
188.1014 -						Name="Debug|Win32"
188.1015 -						>
188.1016 -						<Tool
188.1017 -							Name="VCCLCompilerTool"
188.1018 -							UsePrecompiledHeader="2"
188.1019 -						/>
188.1020 -					</FileConfiguration>
188.1021 -					<FileConfiguration
188.1022 -						Name="Release FastBuild|Win32"
188.1023 -						>
188.1024 -						<Tool
188.1025 -							Name="VCCLCompilerTool"
188.1026 -							UsePrecompiledHeader="2"
188.1027 -						/>
188.1028 -					</FileConfiguration>
188.1029 -				</File>
188.1030 -				<File
188.1031 -					RelativePath=".\CPP\7zip\Archive\7z\7zFolderOutStream.cpp"
188.1032 -					>
188.1033 -					<FileConfiguration
188.1034 -						Name="Release|Win32"
188.1035 -						>
188.1036 -						<Tool
188.1037 -							Name="VCCLCompilerTool"
188.1038 -							UsePrecompiledHeader="2"
188.1039 -						/>
188.1040 -					</FileConfiguration>
188.1041 -					<FileConfiguration
188.1042 -						Name="Debug|Win32"
188.1043 -						>
188.1044 -						<Tool
188.1045 -							Name="VCCLCompilerTool"
188.1046 -							UsePrecompiledHeader="2"
188.1047 -						/>
188.1048 -					</FileConfiguration>
188.1049 -					<FileConfiguration
188.1050 -						Name="Release FastBuild|Win32"
188.1051 -						>
188.1052 -						<Tool
188.1053 -							Name="VCCLCompilerTool"
188.1054 -							UsePrecompiledHeader="2"
188.1055 -						/>
188.1056 -					</FileConfiguration>
188.1057 -				</File>
188.1058 -				<File
188.1059 -					RelativePath=".\CPP\7zip\Archive\7z\7zHandler.cpp"
188.1060 -					>
188.1061 -					<FileConfiguration
188.1062 -						Name="Release|Win32"
188.1063 -						>
188.1064 -						<Tool
188.1065 -							Name="VCCLCompilerTool"
188.1066 -							UsePrecompiledHeader="2"
188.1067 -						/>
188.1068 -					</FileConfiguration>
188.1069 -					<FileConfiguration
188.1070 -						Name="Debug|Win32"
188.1071 -						>
188.1072 -						<Tool
188.1073 -							Name="VCCLCompilerTool"
188.1074 -							UsePrecompiledHeader="2"
188.1075 -						/>
188.1076 -					</FileConfiguration>
188.1077 -					<FileConfiguration
188.1078 -						Name="Release FastBuild|Win32"
188.1079 -						>
188.1080 -						<Tool
188.1081 -							Name="VCCLCompilerTool"
188.1082 -							UsePrecompiledHeader="2"
188.1083 -						/>
188.1084 -					</FileConfiguration>
188.1085 -				</File>
188.1086 -				<File
188.1087 -					RelativePath=".\CPP\7zip\Archive\7z\7zHeader.cpp"
188.1088 -					>
188.1089 -					<FileConfiguration
188.1090 -						Name="Release|Win32"
188.1091 -						>
188.1092 -						<Tool
188.1093 -							Name="VCCLCompilerTool"
188.1094 -							UsePrecompiledHeader="2"
188.1095 -						/>
188.1096 -					</FileConfiguration>
188.1097 -					<FileConfiguration
188.1098 -						Name="Debug|Win32"
188.1099 -						>
188.1100 -						<Tool
188.1101 -							Name="VCCLCompilerTool"
188.1102 -							UsePrecompiledHeader="2"
188.1103 -						/>
188.1104 -					</FileConfiguration>
188.1105 -					<FileConfiguration
188.1106 -						Name="Release FastBuild|Win32"
188.1107 -						>
188.1108 -						<Tool
188.1109 -							Name="VCCLCompilerTool"
188.1110 -							UsePrecompiledHeader="2"
188.1111 -						/>
188.1112 -					</FileConfiguration>
188.1113 -				</File>
188.1114 -				<File
188.1115 -					RelativePath=".\CPP\7zip\Archive\7z\7zIn.cpp"
188.1116 -					>
188.1117 -					<FileConfiguration
188.1118 -						Name="Release|Win32"
188.1119 -						>
188.1120 -						<Tool
188.1121 -							Name="VCCLCompilerTool"
188.1122 -							UsePrecompiledHeader="2"
188.1123 -						/>
188.1124 -					</FileConfiguration>
188.1125 -					<FileConfiguration
188.1126 -						Name="Debug|Win32"
188.1127 -						>
188.1128 -						<Tool
188.1129 -							Name="VCCLCompilerTool"
188.1130 -							UsePrecompiledHeader="2"
188.1131 -						/>
188.1132 -					</FileConfiguration>
188.1133 -					<FileConfiguration
188.1134 -						Name="Release FastBuild|Win32"
188.1135 -						>
188.1136 -						<Tool
188.1137 -							Name="VCCLCompilerTool"
188.1138 -							UsePrecompiledHeader="2"
188.1139 -						/>
188.1140 -					</FileConfiguration>
188.1141 -				</File>
188.1142 -				<File
188.1143 -					RelativePath=".\CPP\7zip\Archive\7z\7zProperties.cpp"
188.1144 -					>
188.1145 -					<FileConfiguration
188.1146 -						Name="Release|Win32"
188.1147 -						>
188.1148 -						<Tool
188.1149 -							Name="VCCLCompilerTool"
188.1150 -							UsePrecompiledHeader="2"
188.1151 -						/>
188.1152 -					</FileConfiguration>
188.1153 -					<FileConfiguration
188.1154 -						Name="Debug|Win32"
188.1155 -						>
188.1156 -						<Tool
188.1157 -							Name="VCCLCompilerTool"
188.1158 -							UsePrecompiledHeader="2"
188.1159 -						/>
188.1160 -					</FileConfiguration>
188.1161 -					<FileConfiguration
188.1162 -						Name="Release FastBuild|Win32"
188.1163 -						>
188.1164 -						<Tool
188.1165 -							Name="VCCLCompilerTool"
188.1166 -							UsePrecompiledHeader="2"
188.1167 -						/>
188.1168 -					</FileConfiguration>
188.1169 -				</File>
188.1170 -				<File
188.1171 -					RelativePath=".\CPP\7zip\Archive\7z\7zSpecStream.cpp"
188.1172 -					>
188.1173 -					<FileConfiguration
188.1174 -						Name="Release|Win32"
188.1175 -						>
188.1176 -						<Tool
188.1177 -							Name="VCCLCompilerTool"
188.1178 -							UsePrecompiledHeader="2"
188.1179 -						/>
188.1180 -					</FileConfiguration>
188.1181 -					<FileConfiguration
188.1182 -						Name="Debug|Win32"
188.1183 -						>
188.1184 -						<Tool
188.1185 -							Name="VCCLCompilerTool"
188.1186 -							UsePrecompiledHeader="2"
188.1187 -						/>
188.1188 -					</FileConfiguration>
188.1189 -					<FileConfiguration
188.1190 -						Name="Release FastBuild|Win32"
188.1191 -						>
188.1192 -						<Tool
188.1193 -							Name="VCCLCompilerTool"
188.1194 -							UsePrecompiledHeader="2"
188.1195 -						/>
188.1196 -					</FileConfiguration>
188.1197 -				</File>
188.1198 -			</Filter>
188.1199 -			<Filter
188.1200 -				Name="Rar"
188.1201 -				>
188.1202 -				<File
188.1203 -					RelativePath=".\CPP\7zip\Archive\Rar\RarHandler.cpp"
188.1204 -					>
188.1205 -					<FileConfiguration
188.1206 -						Name="Release|Win32"
188.1207 -						>
188.1208 -						<Tool
188.1209 -							Name="VCCLCompilerTool"
188.1210 -							UsePrecompiledHeader="2"
188.1211 -						/>
188.1212 -					</FileConfiguration>
188.1213 -					<FileConfiguration
188.1214 -						Name="Debug|Win32"
188.1215 -						>
188.1216 -						<Tool
188.1217 -							Name="VCCLCompilerTool"
188.1218 -							UsePrecompiledHeader="2"
188.1219 -						/>
188.1220 -					</FileConfiguration>
188.1221 -					<FileConfiguration
188.1222 -						Name="Release FastBuild|Win32"
188.1223 -						>
188.1224 -						<Tool
188.1225 -							Name="VCCLCompilerTool"
188.1226 -							UsePrecompiledHeader="2"
188.1227 -						/>
188.1228 -					</FileConfiguration>
188.1229 -				</File>
188.1230 -				<File
188.1231 -					RelativePath=".\CPP\7zip\Archive\Rar\RarHeader.cpp"
188.1232 -					>
188.1233 -					<FileConfiguration
188.1234 -						Name="Release|Win32"
188.1235 -						>
188.1236 -						<Tool
188.1237 -							Name="VCCLCompilerTool"
188.1238 -							UsePrecompiledHeader="2"
188.1239 -						/>
188.1240 -					</FileConfiguration>
188.1241 -					<FileConfiguration
188.1242 -						Name="Debug|Win32"
188.1243 -						>
188.1244 -						<Tool
188.1245 -							Name="VCCLCompilerTool"
188.1246 -							UsePrecompiledHeader="2"
188.1247 -						/>
188.1248 -					</FileConfiguration>
188.1249 -					<FileConfiguration
188.1250 -						Name="Release FastBuild|Win32"
188.1251 -						>
188.1252 -						<Tool
188.1253 -							Name="VCCLCompilerTool"
188.1254 -							UsePrecompiledHeader="2"
188.1255 -						/>
188.1256 -					</FileConfiguration>
188.1257 -				</File>
188.1258 -				<File
188.1259 -					RelativePath=".\CPP\7zip\Archive\Rar\RarIn.cpp"
188.1260 -					>
188.1261 -					<FileConfiguration
188.1262 -						Name="Release|Win32"
188.1263 -						>
188.1264 -						<Tool
188.1265 -							Name="VCCLCompilerTool"
188.1266 -							UsePrecompiledHeader="2"
188.1267 -						/>
188.1268 -					</FileConfiguration>
188.1269 -					<FileConfiguration
188.1270 -						Name="Debug|Win32"
188.1271 -						>
188.1272 -						<Tool
188.1273 -							Name="VCCLCompilerTool"
188.1274 -							UsePrecompiledHeader="2"
188.1275 -						/>
188.1276 -					</FileConfiguration>
188.1277 -					<FileConfiguration
188.1278 -						Name="Release FastBuild|Win32"
188.1279 -						>
188.1280 -						<Tool
188.1281 -							Name="VCCLCompilerTool"
188.1282 -							UsePrecompiledHeader="2"
188.1283 -						/>
188.1284 -					</FileConfiguration>
188.1285 -				</File>
188.1286 -				<File
188.1287 -					RelativePath=".\CPP\7zip\Archive\Rar\RarItem.cpp"
188.1288 -					>
188.1289 -					<FileConfiguration
188.1290 -						Name="Release|Win32"
188.1291 -						>
188.1292 -						<Tool
188.1293 -							Name="VCCLCompilerTool"
188.1294 -							UsePrecompiledHeader="2"
188.1295 -						/>
188.1296 -					</FileConfiguration>
188.1297 -					<FileConfiguration
188.1298 -						Name="Debug|Win32"
188.1299 -						>
188.1300 -						<Tool
188.1301 -							Name="VCCLCompilerTool"
188.1302 -							UsePrecompiledHeader="2"
188.1303 -						/>
188.1304 -					</FileConfiguration>
188.1305 -					<FileConfiguration
188.1306 -						Name="Release FastBuild|Win32"
188.1307 -						>
188.1308 -						<Tool
188.1309 -							Name="VCCLCompilerTool"
188.1310 -							UsePrecompiledHeader="2"
188.1311 -						/>
188.1312 -					</FileConfiguration>
188.1313 -				</File>
188.1314 -				<File
188.1315 -					RelativePath=".\CPP\7zip\Archive\Rar\RarVolumeInStream.cpp"
188.1316 -					>
188.1317 -					<FileConfiguration
188.1318 -						Name="Release|Win32"
188.1319 -						>
188.1320 -						<Tool
188.1321 -							Name="VCCLCompilerTool"
188.1322 -							UsePrecompiledHeader="2"
188.1323 -						/>
188.1324 -					</FileConfiguration>
188.1325 -					<FileConfiguration
188.1326 -						Name="Debug|Win32"
188.1327 -						>
188.1328 -						<Tool
188.1329 -							Name="VCCLCompilerTool"
188.1330 -							UsePrecompiledHeader="2"
188.1331 -						/>
188.1332 -					</FileConfiguration>
188.1333 -					<FileConfiguration
188.1334 -						Name="Release FastBuild|Win32"
188.1335 -						>
188.1336 -						<Tool
188.1337 -							Name="VCCLCompilerTool"
188.1338 -							UsePrecompiledHeader="2"
188.1339 -						/>
188.1340 -					</FileConfiguration>
188.1341 -				</File>
188.1342 -			</Filter>
188.1343 -			<Filter
188.1344 -				Name="bz2"
188.1345 -				>
188.1346 -				<File
188.1347 -					RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Handler.cpp"
188.1348 -					>
188.1349 -					<FileConfiguration
188.1350 -						Name="Release|Win32"
188.1351 -						>
188.1352 -						<Tool
188.1353 -							Name="VCCLCompilerTool"
188.1354 -							UsePrecompiledHeader="2"
188.1355 -						/>
188.1356 -					</FileConfiguration>
188.1357 -					<FileConfiguration
188.1358 -						Name="Debug|Win32"
188.1359 -						>
188.1360 -						<Tool
188.1361 -							Name="VCCLCompilerTool"
188.1362 -							UsePrecompiledHeader="2"
188.1363 -						/>
188.1364 -					</FileConfiguration>
188.1365 -					<FileConfiguration
188.1366 -						Name="Release FastBuild|Win32"
188.1367 -						>
188.1368 -						<Tool
188.1369 -							Name="VCCLCompilerTool"
188.1370 -							UsePrecompiledHeader="2"
188.1371 -						/>
188.1372 -					</FileConfiguration>
188.1373 -				</File>
188.1374 -			</Filter>
188.1375 -			<Filter
188.1376 -				Name="Archive common"
188.1377 -				>
188.1378 -				<File
188.1379 -					RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2.cpp"
188.1380 -					>
188.1381 -					<FileConfiguration
188.1382 -						Name="Release|Win32"
188.1383 -						>
188.1384 -						<Tool
188.1385 -							Name="VCCLCompilerTool"
188.1386 -							UsePrecompiledHeader="2"
188.1387 -						/>
188.1388 -					</FileConfiguration>
188.1389 -					<FileConfiguration
188.1390 -						Name="Debug|Win32"
188.1391 -						>
188.1392 -						<Tool
188.1393 -							Name="VCCLCompilerTool"
188.1394 -							UsePrecompiledHeader="2"
188.1395 -						/>
188.1396 -					</FileConfiguration>
188.1397 -					<FileConfiguration
188.1398 -						Name="Release FastBuild|Win32"
188.1399 -						>
188.1400 -						<Tool
188.1401 -							Name="VCCLCompilerTool"
188.1402 -							UsePrecompiledHeader="2"
188.1403 -						/>
188.1404 -					</FileConfiguration>
188.1405 -				</File>
188.1406 -				<File
188.1407 -					RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2MT.cpp"
188.1408 -					>
188.1409 -					<FileConfiguration
188.1410 -						Name="Release|Win32"
188.1411 -						>
188.1412 -						<Tool
188.1413 -							Name="VCCLCompilerTool"
188.1414 -							UsePrecompiledHeader="2"
188.1415 -						/>
188.1416 -					</FileConfiguration>
188.1417 -					<FileConfiguration
188.1418 -						Name="Debug|Win32"
188.1419 -						>
188.1420 -						<Tool
188.1421 -							Name="VCCLCompilerTool"
188.1422 -							UsePrecompiledHeader="2"
188.1423 -						/>
188.1424 -					</FileConfiguration>
188.1425 -					<FileConfiguration
188.1426 -						Name="Release FastBuild|Win32"
188.1427 -						>
188.1428 -						<Tool
188.1429 -							Name="VCCLCompilerTool"
188.1430 -							UsePrecompiledHeader="2"
188.1431 -						/>
188.1432 -					</FileConfiguration>
188.1433 -				</File>
188.1434 -				<File
188.1435 -					RelativePath=".\CPP\7zip\Archive\Common\DummyOutStream.cpp"
188.1436 -					>
188.1437 -					<FileConfiguration
188.1438 -						Name="Release|Win32"
188.1439 -						>
188.1440 -						<Tool
188.1441 -							Name="VCCLCompilerTool"
188.1442 -							UsePrecompiledHeader="2"
188.1443 -						/>
188.1444 -					</FileConfiguration>
188.1445 -					<FileConfiguration
188.1446 -						Name="Debug|Win32"
188.1447 -						>
188.1448 -						<Tool
188.1449 -							Name="VCCLCompilerTool"
188.1450 -							UsePrecompiledHeader="2"
188.1451 -						/>
188.1452 -					</FileConfiguration>
188.1453 -					<FileConfiguration
188.1454 -						Name="Release FastBuild|Win32"
188.1455 -						>
188.1456 -						<Tool
188.1457 -							Name="VCCLCompilerTool"
188.1458 -							UsePrecompiledHeader="2"
188.1459 -						/>
188.1460 -					</FileConfiguration>
188.1461 -				</File>
188.1462 -				<File
188.1463 -					RelativePath=".\CPP\7zip\Archive\Common\FindSignature.cpp"
188.1464 -					>
188.1465 -					<FileConfiguration
188.1466 -						Name="Release|Win32"
188.1467 -						>
188.1468 -						<Tool
188.1469 -							Name="VCCLCompilerTool"
188.1470 -							UsePrecompiledHeader="2"
188.1471 -						/>
188.1472 -					</FileConfiguration>
188.1473 -					<FileConfiguration
188.1474 -						Name="Debug|Win32"
188.1475 -						>
188.1476 -						<Tool
188.1477 -							Name="VCCLCompilerTool"
188.1478 -							UsePrecompiledHeader="2"
188.1479 -						/>
188.1480 -					</FileConfiguration>
188.1481 -					<FileConfiguration
188.1482 -						Name="Release FastBuild|Win32"
188.1483 -						>
188.1484 -						<Tool
188.1485 -							Name="VCCLCompilerTool"
188.1486 -							UsePrecompiledHeader="2"
188.1487 -						/>
188.1488 -					</FileConfiguration>
188.1489 -				</File>
188.1490 -				<File
188.1491 -					RelativePath=".\CPP\7zip\Archive\Common\InStreamWithCRC.cpp"
188.1492 -					>
188.1493 -					<FileConfiguration
188.1494 -						Name="Release|Win32"
188.1495 -						>
188.1496 -						<Tool
188.1497 -							Name="VCCLCompilerTool"
188.1498 -							UsePrecompiledHeader="2"
188.1499 -						/>
188.1500 -					</FileConfiguration>
188.1501 -					<FileConfiguration
188.1502 -						Name="Debug|Win32"
188.1503 -						>
188.1504 -						<Tool
188.1505 -							Name="VCCLCompilerTool"
188.1506 -							UsePrecompiledHeader="2"
188.1507 -						/>
188.1508 -					</FileConfiguration>
188.1509 -					<FileConfiguration
188.1510 -						Name="Release FastBuild|Win32"
188.1511 -						>
188.1512 -						<Tool
188.1513 -							Name="VCCLCompilerTool"
188.1514 -							UsePrecompiledHeader="2"
188.1515 -						/>
188.1516 -					</FileConfiguration>
188.1517 -				</File>
188.1518 -				<File
188.1519 -					RelativePath=".\CPP\7zip\Archive\Common\ItemNameUtils.cpp"
188.1520 -					>
188.1521 -					<FileConfiguration
188.1522 -						Name="Release|Win32"
188.1523 -						>
188.1524 -						<Tool
188.1525 -							Name="VCCLCompilerTool"
188.1526 -							UsePrecompiledHeader="2"
188.1527 -						/>
188.1528 -					</FileConfiguration>
188.1529 -					<FileConfiguration
188.1530 -						Name="Debug|Win32"
188.1531 -						>
188.1532 -						<Tool
188.1533 -							Name="VCCLCompilerTool"
188.1534 -							UsePrecompiledHeader="2"
188.1535 -						/>
188.1536 -					</FileConfiguration>
188.1537 -					<FileConfiguration
188.1538 -						Name="Release FastBuild|Win32"
188.1539 -						>
188.1540 -						<Tool
188.1541 -							Name="VCCLCompilerTool"
188.1542 -							UsePrecompiledHeader="2"
188.1543 -						/>
188.1544 -					</FileConfiguration>
188.1545 -				</File>
188.1546 -				<File
188.1547 -					RelativePath=".\CPP\7zip\Archive\Common\MultiStream.cpp"
188.1548 -					>
188.1549 -					<FileConfiguration
188.1550 -						Name="Release|Win32"
188.1551 -						>
188.1552 -						<Tool
188.1553 -							Name="VCCLCompilerTool"
188.1554 -							UsePrecompiledHeader="2"
188.1555 -						/>
188.1556 -					</FileConfiguration>
188.1557 -					<FileConfiguration
188.1558 -						Name="Debug|Win32"
188.1559 -						>
188.1560 -						<Tool
188.1561 -							Name="VCCLCompilerTool"
188.1562 -							UsePrecompiledHeader="2"
188.1563 -						/>
188.1564 -					</FileConfiguration>
188.1565 -					<FileConfiguration
188.1566 -						Name="Release FastBuild|Win32"
188.1567 -						>
188.1568 -						<Tool
188.1569 -							Name="VCCLCompilerTool"
188.1570 -							UsePrecompiledHeader="2"
188.1571 -						/>
188.1572 -					</FileConfiguration>
188.1573 -				</File>
188.1574 -				<File
188.1575 -					RelativePath=".\CPP\7zip\Archive\Common\OutStreamWithCRC.cpp"
188.1576 -					>
188.1577 -					<FileConfiguration
188.1578 -						Name="Release|Win32"
188.1579 -						>
188.1580 -						<Tool
188.1581 -							Name="VCCLCompilerTool"
188.1582 -							UsePrecompiledHeader="2"
188.1583 -						/>
188.1584 -					</FileConfiguration>
188.1585 -					<FileConfiguration
188.1586 -						Name="Debug|Win32"
188.1587 -						>
188.1588 -						<Tool
188.1589 -							Name="VCCLCompilerTool"
188.1590 -							UsePrecompiledHeader="2"
188.1591 -						/>
188.1592 -					</FileConfiguration>
188.1593 -					<FileConfiguration
188.1594 -						Name="Release FastBuild|Win32"
188.1595 -						>
188.1596 -						<Tool
188.1597 -							Name="VCCLCompilerTool"
188.1598 -							UsePrecompiledHeader="2"
188.1599 -						/>
188.1600 -					</FileConfiguration>
188.1601 -				</File>
188.1602 -				<File
188.1603 -					RelativePath=".\CPP\7zip\Archive\Common\ParseProperties.cpp"
188.1604 -					>
188.1605 -					<FileConfiguration
188.1606 -						Name="Release|Win32"
188.1607 -						>
188.1608 -						<Tool
188.1609 -							Name="VCCLCompilerTool"
188.1610 -							UsePrecompiledHeader="2"
188.1611 -						/>
188.1612 -					</FileConfiguration>
188.1613 -					<FileConfiguration
188.1614 -						Name="Debug|Win32"
188.1615 -						>
188.1616 -						<Tool
188.1617 -							Name="VCCLCompilerTool"
188.1618 -							UsePrecompiledHeader="2"
188.1619 -						/>
188.1620 -					</FileConfiguration>
188.1621 -					<FileConfiguration
188.1622 -						Name="Release FastBuild|Win32"
188.1623 -						>
188.1624 -						<Tool
188.1625 -							Name="VCCLCompilerTool"
188.1626 -							UsePrecompiledHeader="2"
188.1627 -						/>
188.1628 -					</FileConfiguration>
188.1629 -				</File>
188.1630 -			</Filter>
188.1631 -			<Filter
188.1632 -				Name="GZip"
188.1633 -				>
188.1634 -				<File
188.1635 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipHandler.cpp"
188.1636 -					>
188.1637 -					<FileConfiguration
188.1638 -						Name="Release|Win32"
188.1639 -						>
188.1640 -						<Tool
188.1641 -							Name="VCCLCompilerTool"
188.1642 -							UsePrecompiledHeader="2"
188.1643 -						/>
188.1644 -					</FileConfiguration>
188.1645 -					<FileConfiguration
188.1646 -						Name="Debug|Win32"
188.1647 -						>
188.1648 -						<Tool
188.1649 -							Name="VCCLCompilerTool"
188.1650 -							UsePrecompiledHeader="2"
188.1651 -						/>
188.1652 -					</FileConfiguration>
188.1653 -					<FileConfiguration
188.1654 -						Name="Release FastBuild|Win32"
188.1655 -						>
188.1656 -						<Tool
188.1657 -							Name="VCCLCompilerTool"
188.1658 -							UsePrecompiledHeader="2"
188.1659 -						/>
188.1660 -					</FileConfiguration>
188.1661 -				</File>
188.1662 -				<File
188.1663 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipHeader.cpp"
188.1664 -					>
188.1665 -					<FileConfiguration
188.1666 -						Name="Release|Win32"
188.1667 -						>
188.1668 -						<Tool
188.1669 -							Name="VCCLCompilerTool"
188.1670 -							UsePrecompiledHeader="2"
188.1671 -						/>
188.1672 -					</FileConfiguration>
188.1673 -					<FileConfiguration
188.1674 -						Name="Debug|Win32"
188.1675 -						>
188.1676 -						<Tool
188.1677 -							Name="VCCLCompilerTool"
188.1678 -							UsePrecompiledHeader="2"
188.1679 -						/>
188.1680 -					</FileConfiguration>
188.1681 -					<FileConfiguration
188.1682 -						Name="Release FastBuild|Win32"
188.1683 -						>
188.1684 -						<Tool
188.1685 -							Name="VCCLCompilerTool"
188.1686 -							UsePrecompiledHeader="2"
188.1687 -						/>
188.1688 -					</FileConfiguration>
188.1689 -				</File>
188.1690 -				<File
188.1691 -					RelativePath=".\CPP\7zip\Archive\GZip\GZipIn.cpp"
188.1692 -					>
188.1693 -					<FileConfiguration
188.1694 -						Name="Release|Win32"
188.1695 -						>
188.1696 -						<Tool
188.1697 -							Name="VCCLCompilerTool"
188.1698 -							UsePrecompiledHeader="2"
188.1699 -						/>
188.1700 -					</FileConfiguration>
188.1701 -					<FileConfiguration
188.1702 -						Name="Debug|Win32"
188.1703 -						>
188.1704 -						<Tool
188.1705 -							Name="VCCLCompilerTool"
188.1706 -							UsePrecompiledHeader="2"
188.1707 -						/>
188.1708 -					</FileConfiguration>
188.1709 -					<FileConfiguration
188.1710 -						Name="Release FastBuild|Win32"
188.1711 -						>
188.1712 -						<Tool
188.1713 -							Name="VCCLCompilerTool"
188.1714 -							UsePrecompiledHeader="2"
188.1715 -						/>
188.1716 -					</FileConfiguration>
188.1717 -				</File>
188.1718 -			</Filter>
188.1719 -			<Filter
188.1720 -				Name="Lzh"
188.1721 -				>
188.1722 -				<File
188.1723 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhCRC.cpp"
188.1724 -					>
188.1725 -					<FileConfiguration
188.1726 -						Name="Release|Win32"
188.1727 -						>
188.1728 -						<Tool
188.1729 -							Name="VCCLCompilerTool"
188.1730 -							UsePrecompiledHeader="2"
188.1731 -						/>
188.1732 -					</FileConfiguration>
188.1733 -					<FileConfiguration
188.1734 -						Name="Debug|Win32"
188.1735 -						>
188.1736 -						<Tool
188.1737 -							Name="VCCLCompilerTool"
188.1738 -							UsePrecompiledHeader="2"
188.1739 -						/>
188.1740 -					</FileConfiguration>
188.1741 -					<FileConfiguration
188.1742 -						Name="Release FastBuild|Win32"
188.1743 -						>
188.1744 -						<Tool
188.1745 -							Name="VCCLCompilerTool"
188.1746 -							UsePrecompiledHeader="2"
188.1747 -						/>
188.1748 -					</FileConfiguration>
188.1749 -				</File>
188.1750 -				<File
188.1751 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhHandler.cpp"
188.1752 -					>
188.1753 -					<FileConfiguration
188.1754 -						Name="Release|Win32"
188.1755 -						>
188.1756 -						<Tool
188.1757 -							Name="VCCLCompilerTool"
188.1758 -							UsePrecompiledHeader="2"
188.1759 -						/>
188.1760 -					</FileConfiguration>
188.1761 -					<FileConfiguration
188.1762 -						Name="Debug|Win32"
188.1763 -						>
188.1764 -						<Tool
188.1765 -							Name="VCCLCompilerTool"
188.1766 -							UsePrecompiledHeader="2"
188.1767 -						/>
188.1768 -					</FileConfiguration>
188.1769 -					<FileConfiguration
188.1770 -						Name="Release FastBuild|Win32"
188.1771 -						>
188.1772 -						<Tool
188.1773 -							Name="VCCLCompilerTool"
188.1774 -							UsePrecompiledHeader="2"
188.1775 -						/>
188.1776 -					</FileConfiguration>
188.1777 -				</File>
188.1778 -				<File
188.1779 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhIn.cpp"
188.1780 -					>
188.1781 -					<FileConfiguration
188.1782 -						Name="Release|Win32"
188.1783 -						>
188.1784 -						<Tool
188.1785 -							Name="VCCLCompilerTool"
188.1786 -							UsePrecompiledHeader="2"
188.1787 -						/>
188.1788 -					</FileConfiguration>
188.1789 -					<FileConfiguration
188.1790 -						Name="Debug|Win32"
188.1791 -						>
188.1792 -						<Tool
188.1793 -							Name="VCCLCompilerTool"
188.1794 -							UsePrecompiledHeader="2"
188.1795 -						/>
188.1796 -					</FileConfiguration>
188.1797 -					<FileConfiguration
188.1798 -						Name="Release FastBuild|Win32"
188.1799 -						>
188.1800 -						<Tool
188.1801 -							Name="VCCLCompilerTool"
188.1802 -							UsePrecompiledHeader="2"
188.1803 -						/>
188.1804 -					</FileConfiguration>
188.1805 -				</File>
188.1806 -				<File
188.1807 -					RelativePath=".\CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.cpp"
188.1808 -					>
188.1809 -					<FileConfiguration
188.1810 -						Name="Release|Win32"
188.1811 -						>
188.1812 -						<Tool
188.1813 -							Name="VCCLCompilerTool"
188.1814 -							UsePrecompiledHeader="2"
188.1815 -						/>
188.1816 -					</FileConfiguration>
188.1817 -					<FileConfiguration
188.1818 -						Name="Debug|Win32"
188.1819 -						>
188.1820 -						<Tool
188.1821 -							Name="VCCLCompilerTool"
188.1822 -							UsePrecompiledHeader="2"
188.1823 -						/>
188.1824 -					</FileConfiguration>
188.1825 -					<FileConfiguration
188.1826 -						Name="Release FastBuild|Win32"
188.1827 -						>
188.1828 -						<Tool
188.1829 -							Name="VCCLCompilerTool"
188.1830 -							UsePrecompiledHeader="2"
188.1831 -						/>
188.1832 -					</FileConfiguration>
188.1833 -				</File>
188.1834 -			</Filter>
188.1835 -			<Filter
188.1836 -				Name="Split"
188.1837 -				>
188.1838 -				<File
188.1839 -					RelativePath=".\CPP\7zip\Archive\Split\SplitHandler.cpp"
188.1840 -					>
188.1841 -					<FileConfiguration
188.1842 -						Name="Release|Win32"
188.1843 -						>
188.1844 -						<Tool
188.1845 -							Name="VCCLCompilerTool"
188.1846 -							UsePrecompiledHeader="2"
188.1847 -						/>
188.1848 -					</FileConfiguration>
188.1849 -					<FileConfiguration
188.1850 -						Name="Debug|Win32"
188.1851 -						>
188.1852 -						<Tool
188.1853 -							Name="VCCLCompilerTool"
188.1854 -							UsePrecompiledHeader="2"
188.1855 -						/>
188.1856 -					</FileConfiguration>
188.1857 -					<FileConfiguration
188.1858 -						Name="Release FastBuild|Win32"
188.1859 -						>
188.1860 -						<Tool
188.1861 -							Name="VCCLCompilerTool"
188.1862 -							UsePrecompiledHeader="2"
188.1863 -						/>
188.1864 -					</FileConfiguration>
188.1865 -				</File>
188.1866 -			</Filter>
188.1867 -			<Filter
188.1868 -				Name="Tar"
188.1869 -				>
188.1870 -				<File
188.1871 -					RelativePath=".\CPP\7zip\Archive\Tar\TarHandler.cpp"
188.1872 -					>
188.1873 -					<FileConfiguration
188.1874 -						Name="Release|Win32"
188.1875 -						>
188.1876 -						<Tool
188.1877 -							Name="VCCLCompilerTool"
188.1878 -							UsePrecompiledHeader="2"
188.1879 -						/>
188.1880 -					</FileConfiguration>
188.1881 -					<FileConfiguration
188.1882 -						Name="Debug|Win32"
188.1883 -						>
188.1884 -						<Tool
188.1885 -							Name="VCCLCompilerTool"
188.1886 -							UsePrecompiledHeader="2"
188.1887 -						/>
188.1888 -					</FileConfiguration>
188.1889 -					<FileConfiguration
188.1890 -						Name="Release FastBuild|Win32"
188.1891 -						>
188.1892 -						<Tool
188.1893 -							Name="VCCLCompilerTool"
188.1894 -							UsePrecompiledHeader="2"
188.1895 -						/>
188.1896 -					</FileConfiguration>
188.1897 -				</File>
188.1898 -				<File
188.1899 -					RelativePath=".\CPP\7zip\Archive\Tar\TarHeader.cpp"
188.1900 -					>
188.1901 -					<FileConfiguration
188.1902 -						Name="Release|Win32"
188.1903 -						>
188.1904 -						<Tool
188.1905 -							Name="VCCLCompilerTool"
188.1906 -							UsePrecompiledHeader="2"
188.1907 -						/>
188.1908 -					</FileConfiguration>
188.1909 -					<FileConfiguration
188.1910 -						Name="Debug|Win32"
188.1911 -						>
188.1912 -						<Tool
188.1913 -							Name="VCCLCompilerTool"
188.1914 -							UsePrecompiledHeader="2"
188.1915 -						/>
188.1916 -					</FileConfiguration>
188.1917 -					<FileConfiguration
188.1918 -						Name="Release FastBuild|Win32"
188.1919 -						>
188.1920 -						<Tool
188.1921 -							Name="VCCLCompilerTool"
188.1922 -							UsePrecompiledHeader="2"
188.1923 -						/>
188.1924 -					</FileConfiguration>
188.1925 -				</File>
188.1926 -				<File
188.1927 -					RelativePath=".\CPP\7zip\Archive\Tar\TarIn.cpp"
188.1928 -					>
188.1929 -					<FileConfiguration
188.1930 -						Name="Release|Win32"
188.1931 -						>
188.1932 -						<Tool
188.1933 -							Name="VCCLCompilerTool"
188.1934 -							UsePrecompiledHeader="2"
188.1935 -						/>
188.1936 -					</FileConfiguration>
188.1937 -					<FileConfiguration
188.1938 -						Name="Debug|Win32"
188.1939 -						>
188.1940 -						<Tool
188.1941 -							Name="VCCLCompilerTool"
188.1942 -							UsePrecompiledHeader="2"
188.1943 -						/>
188.1944 -					</FileConfiguration>
188.1945 -					<FileConfiguration
188.1946 -						Name="Release FastBuild|Win32"
188.1947 -						>
188.1948 -						<Tool
188.1949 -							Name="VCCLCompilerTool"
188.1950 -							UsePrecompiledHeader="2"
188.1951 -						/>
188.1952 -					</FileConfiguration>
188.1953 -				</File>
188.1954 -			</Filter>
188.1955 -			<Filter
188.1956 -				Name="Zip"
188.1957 -				>
188.1958 -				<File
188.1959 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipHandler.cpp"
188.1960 -					>
188.1961 -					<FileConfiguration
188.1962 -						Name="Release|Win32"
188.1963 -						>
188.1964 -						<Tool
188.1965 -							Name="VCCLCompilerTool"
188.1966 -							UsePrecompiledHeader="2"
188.1967 -						/>
188.1968 -					</FileConfiguration>
188.1969 -					<FileConfiguration
188.1970 -						Name="Debug|Win32"
188.1971 -						>
188.1972 -						<Tool
188.1973 -							Name="VCCLCompilerTool"
188.1974 -							UsePrecompiledHeader="2"
188.1975 -						/>
188.1976 -					</FileConfiguration>
188.1977 -					<FileConfiguration
188.1978 -						Name="Release FastBuild|Win32"
188.1979 -						>
188.1980 -						<Tool
188.1981 -							Name="VCCLCompilerTool"
188.1982 -							UsePrecompiledHeader="2"
188.1983 -						/>
188.1984 -					</FileConfiguration>
188.1985 -				</File>
188.1986 -				<File
188.1987 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipHeader.cpp"
188.1988 -					>
188.1989 -					<FileConfiguration
188.1990 -						Name="Release|Win32"
188.1991 -						>
188.1992 -						<Tool
188.1993 -							Name="VCCLCompilerTool"
188.1994 -							UsePrecompiledHeader="2"
188.1995 -						/>
188.1996 -					</FileConfiguration>
188.1997 -					<FileConfiguration
188.1998 -						Name="Debug|Win32"
188.1999 -						>
188.2000 -						<Tool
188.2001 -							Name="VCCLCompilerTool"
188.2002 -							UsePrecompiledHeader="2"
188.2003 -						/>
188.2004 -					</FileConfiguration>
188.2005 -					<FileConfiguration
188.2006 -						Name="Release FastBuild|Win32"
188.2007 -						>
188.2008 -						<Tool
188.2009 -							Name="VCCLCompilerTool"
188.2010 -							UsePrecompiledHeader="2"
188.2011 -						/>
188.2012 -					</FileConfiguration>
188.2013 -				</File>
188.2014 -				<File
188.2015 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipIn.cpp"
188.2016 -					>
188.2017 -					<FileConfiguration
188.2018 -						Name="Release|Win32"
188.2019 -						>
188.2020 -						<Tool
188.2021 -							Name="VCCLCompilerTool"
188.2022 -							UsePrecompiledHeader="2"
188.2023 -						/>
188.2024 -					</FileConfiguration>
188.2025 -					<FileConfiguration
188.2026 -						Name="Debug|Win32"
188.2027 -						>
188.2028 -						<Tool
188.2029 -							Name="VCCLCompilerTool"
188.2030 -							UsePrecompiledHeader="2"
188.2031 -						/>
188.2032 -					</FileConfiguration>
188.2033 -					<FileConfiguration
188.2034 -						Name="Release FastBuild|Win32"
188.2035 -						>
188.2036 -						<Tool
188.2037 -							Name="VCCLCompilerTool"
188.2038 -							UsePrecompiledHeader="2"
188.2039 -						/>
188.2040 -					</FileConfiguration>
188.2041 -				</File>
188.2042 -				<File
188.2043 -					RelativePath=".\CPP\7zip\Archive\Zip\ZipItem.cpp"
188.2044 -					>
188.2045 -					<FileConfiguration
188.2046 -						Name="Release|Win32"
188.2047 -						>
188.2048 -						<Tool
188.2049 -							Name="VCCLCompilerTool"
188.2050 -							UsePrecompiledHeader="2"
188.2051 -						/>
188.2052 -					</FileConfiguration>
188.2053 -					<FileConfiguration
188.2054 -						Name="Debug|Win32"
188.2055 -						>
188.2056 -						<Tool
188.2057 -							Name="VCCLCompilerTool"
188.2058 -							UsePrecompiledHeader="2"
188.2059 -						/>
188.2060 -					</FileConfiguration>
188.2061 -					<FileConfiguration
188.2062 -						Name="Release FastBuild|Win32"
188.2063 -						>
188.2064 -						<Tool
188.2065 -							Name="VCCLCompilerTool"
188.2066 -							UsePrecompiledHeader="2"
188.2067 -						/>
188.2068 -					</FileConfiguration>
188.2069 -				</File>
188.2070 -			</Filter>
188.2071 -			<Filter
188.2072 -				Name="Lzma Ar"
188.2073 -				>
188.2074 -				<File
188.2075 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaFiltersDecode.cpp"
188.2076 -					>
188.2077 -					<FileConfiguration
188.2078 -						Name="Release|Win32"
188.2079 -						>
188.2080 -						<Tool
188.2081 -							Name="VCCLCompilerTool"
188.2082 -							UsePrecompiledHeader="2"
188.2083 -						/>
188.2084 -					</FileConfiguration>
188.2085 -					<FileConfiguration
188.2086 -						Name="Debug|Win32"
188.2087 -						>
188.2088 -						<Tool
188.2089 -							Name="VCCLCompilerTool"
188.2090 -							UsePrecompiledHeader="2"
188.2091 -						/>
188.2092 -					</FileConfiguration>
188.2093 -					<FileConfiguration
188.2094 -						Name="Release FastBuild|Win32"
188.2095 -						>
188.2096 -						<Tool
188.2097 -							Name="VCCLCompilerTool"
188.2098 -							UsePrecompiledHeader="2"
188.2099 -						/>
188.2100 -					</FileConfiguration>
188.2101 -				</File>
188.2102 -				<File
188.2103 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaHandler.cpp"
188.2104 -					>
188.2105 -					<FileConfiguration
188.2106 -						Name="Release|Win32"
188.2107 -						>
188.2108 -						<Tool
188.2109 -							Name="VCCLCompilerTool"
188.2110 -							UsePrecompiledHeader="2"
188.2111 -						/>
188.2112 -					</FileConfiguration>
188.2113 -					<FileConfiguration
188.2114 -						Name="Debug|Win32"
188.2115 -						>
188.2116 -						<Tool
188.2117 -							Name="VCCLCompilerTool"
188.2118 -							UsePrecompiledHeader="2"
188.2119 -						/>
188.2120 -					</FileConfiguration>
188.2121 -					<FileConfiguration
188.2122 -						Name="Release FastBuild|Win32"
188.2123 -						>
188.2124 -						<Tool
188.2125 -							Name="VCCLCompilerTool"
188.2126 -							UsePrecompiledHeader="2"
188.2127 -						/>
188.2128 -					</FileConfiguration>
188.2129 -				</File>
188.2130 -				<File
188.2131 -					RelativePath=".\CPP\7zip\Archive\Lzma\LzmaIn.cpp"
188.2132 -					>
188.2133 -					<FileConfiguration
188.2134 -						Name="Release|Win32"
188.2135 -						>
188.2136 -						<Tool
188.2137 -							Name="VCCLCompilerTool"
188.2138 -							UsePrecompiledHeader="2"
188.2139 -						/>
188.2140 -					</FileConfiguration>
188.2141 -					<FileConfiguration
188.2142 -						Name="Debug|Win32"
188.2143 -						>
188.2144 -						<Tool
188.2145 -							Name="VCCLCompilerTool"
188.2146 -							UsePrecompiledHeader="2"
188.2147 -						/>
188.2148 -					</FileConfiguration>
188.2149 -					<FileConfiguration
188.2150 -						Name="Release FastBuild|Win32"
188.2151 -						>
188.2152 -						<Tool
188.2153 -							Name="VCCLCompilerTool"
188.2154 -							UsePrecompiledHeader="2"
188.2155 -						/>
188.2156 -					</FileConfiguration>
188.2157 -				</File>
188.2158 -			</Filter>
188.2159 -		</Filter>
188.2160 -		<Filter
188.2161 -			Name="C"
188.2162 -			>
188.2163 -			<File
188.2164 -				RelativePath=".\C\7zCrc.c"
188.2165 -				>
188.2166 -				<FileConfiguration
188.2167 -					Name="Release|Win32"
188.2168 -					>
188.2169 -					<Tool
188.2170 -						Name="VCCLCompilerTool"
188.2171 -						UsePrecompiledHeader="0"
188.2172 -					/>
188.2173 -				</FileConfiguration>
188.2174 -				<FileConfiguration
188.2175 -					Name="Debug|Win32"
188.2176 -					>
188.2177 -					<Tool
188.2178 -						Name="VCCLCompilerTool"
188.2179 -						UsePrecompiledHeader="0"
188.2180 -					/>
188.2181 -				</FileConfiguration>
188.2182 -				<FileConfiguration
188.2183 -					Name="Release FastBuild|Win32"
188.2184 -					>
188.2185 -					<Tool
188.2186 -						Name="VCCLCompilerTool"
188.2187 -						UsePrecompiledHeader="0"
188.2188 -					/>
188.2189 -				</FileConfiguration>
188.2190 -			</File>
188.2191 -			<File
188.2192 -				RelativePath=".\C\Aes.c"
188.2193 -				>
188.2194 -				<FileConfiguration
188.2195 -					Name="Release|Win32"
188.2196 -					>
188.2197 -					<Tool
188.2198 -						Name="VCCLCompilerTool"
188.2199 -						UsePrecompiledHeader="0"
188.2200 -					/>
188.2201 -				</FileConfiguration>
188.2202 -				<FileConfiguration
188.2203 -					Name="Debug|Win32"
188.2204 -					>
188.2205 -					<Tool
188.2206 -						Name="VCCLCompilerTool"
188.2207 -						UsePrecompiledHeader="0"
188.2208 -					/>
188.2209 -				</FileConfiguration>
188.2210 -				<FileConfiguration
188.2211 -					Name="Release FastBuild|Win32"
188.2212 -					>
188.2213 -					<Tool
188.2214 -						Name="VCCLCompilerTool"
188.2215 -						UsePrecompiledHeader="0"
188.2216 -					/>
188.2217 -				</FileConfiguration>
188.2218 -			</File>
188.2219 -			<File
188.2220 -				RelativePath=".\C\Alloc.c"
188.2221 -				>
188.2222 -				<FileConfiguration
188.2223 -					Name="Release|Win32"
188.2224 -					>
188.2225 -					<Tool
188.2226 -						Name="VCCLCompilerTool"
188.2227 -						UsePrecompiledHeader="0"
188.2228 -					/>
188.2229 -				</FileConfiguration>
188.2230 -				<FileConfiguration
188.2231 -					Name="Debug|Win32"
188.2232 -					>
188.2233 -					<Tool
188.2234 -						Name="VCCLCompilerTool"
188.2235 -						UsePrecompiledHeader="0"
188.2236 -					/>
188.2237 -				</FileConfiguration>
188.2238 -				<FileConfiguration
188.2239 -					Name="Release FastBuild|Win32"
188.2240 -					>
188.2241 -					<Tool
188.2242 -						Name="VCCLCompilerTool"
188.2243 -						UsePrecompiledHeader="0"
188.2244 -					/>
188.2245 -				</FileConfiguration>
188.2246 -			</File>
188.2247 -			<File
188.2248 -				RelativePath=".\C\Bra.c"
188.2249 -				>
188.2250 -				<FileConfiguration
188.2251 -					Name="Release|Win32"
188.2252 -					>
188.2253 -					<Tool
188.2254 -						Name="VCCLCompilerTool"
188.2255 -						UsePrecompiledHeader="0"
188.2256 -					/>
188.2257 -				</FileConfiguration>
188.2258 -				<FileConfiguration
188.2259 -					Name="Debug|Win32"
188.2260 -					>
188.2261 -					<Tool
188.2262 -						Name="VCCLCompilerTool"
188.2263 -						UsePrecompiledHeader="0"
188.2264 -					/>
188.2265 -				</FileConfiguration>
188.2266 -				<FileConfiguration
188.2267 -					Name="Release FastBuild|Win32"
188.2268 -					>
188.2269 -					<Tool
188.2270 -						Name="VCCLCompilerTool"
188.2271 -						UsePrecompiledHeader="0"
188.2272 -					/>
188.2273 -				</FileConfiguration>
188.2274 -			</File>
188.2275 -			<File
188.2276 -				RelativePath=".\C\Bra86.c"
188.2277 -				>
188.2278 -				<FileConfiguration
188.2279 -					Name="Release|Win32"
188.2280 -					>
188.2281 -					<Tool
188.2282 -						Name="VCCLCompilerTool"
188.2283 -						UsePrecompiledHeader="0"
188.2284 -					/>
188.2285 -				</FileConfiguration>
188.2286 -				<FileConfiguration
188.2287 -					Name="Debug|Win32"
188.2288 -					>
188.2289 -					<Tool
188.2290 -						Name="VCCLCompilerTool"
188.2291 -						UsePrecompiledHeader="0"
188.2292 -					/>
188.2293 -				</FileConfiguration>
188.2294 -				<FileConfiguration
188.2295 -					Name="Release FastBuild|Win32"
188.2296 -					>
188.2297 -					<Tool
188.2298 -						Name="VCCLCompilerTool"
188.2299 -						UsePrecompiledHeader="0"
188.2300 -					/>
188.2301 -				</FileConfiguration>
188.2302 -			</File>
188.2303 -			<File
188.2304 -				RelativePath=".\C\BraIA64.c"
188.2305 -				>
188.2306 -				<FileConfiguration
188.2307 -					Name="Release|Win32"
188.2308 -					>
188.2309 -					<Tool
188.2310 -						Name="VCCLCompilerTool"
188.2311 -						UsePrecompiledHeader="0"
188.2312 -					/>
188.2313 -				</FileConfiguration>
188.2314 -				<FileConfiguration
188.2315 -					Name="Debug|Win32"
188.2316 -					>
188.2317 -					<Tool
188.2318 -						Name="VCCLCompilerTool"
188.2319 -						UsePrecompiledHeader="0"
188.2320 -					/>
188.2321 -				</FileConfiguration>
188.2322 -				<FileConfiguration
188.2323 -					Name="Release FastBuild|Win32"
188.2324 -					>
188.2325 -					<Tool
188.2326 -						Name="VCCLCompilerTool"
188.2327 -						UsePrecompiledHeader="0"
188.2328 -					/>
188.2329 -				</FileConfiguration>
188.2330 -			</File>
188.2331 -			<File
188.2332 -				RelativePath=".\C\BwtSort.c"
188.2333 -				>
188.2334 -				<FileConfiguration
188.2335 -					Name="Release|Win32"
188.2336 -					>
188.2337 -					<Tool
188.2338 -						Name="VCCLCompilerTool"
188.2339 -						UsePrecompiledHeader="0"
188.2340 -					/>
188.2341 -				</FileConfiguration>
188.2342 -				<FileConfiguration
188.2343 -					Name="Debug|Win32"
188.2344 -					>
188.2345 -					<Tool
188.2346 -						Name="VCCLCompilerTool"
188.2347 -						UsePrecompiledHeader="0"
188.2348 -					/>
188.2349 -				</FileConfiguration>
188.2350 -				<FileConfiguration
188.2351 -					Name="Release FastBuild|Win32"
188.2352 -					>
188.2353 -					<Tool
188.2354 -						Name="VCCLCompilerTool"
188.2355 -						UsePrecompiledHeader="0"
188.2356 -					/>
188.2357 -				</FileConfiguration>
188.2358 -			</File>
188.2359 -			<File
188.2360 -				RelativePath=".\C\HuffEnc.c"
188.2361 -				>
188.2362 -				<FileConfiguration
188.2363 -					Name="Release|Win32"
188.2364 -					>
188.2365 -					<Tool
188.2366 -						Name="VCCLCompilerTool"
188.2367 -						UsePrecompiledHeader="0"
188.2368 -					/>
188.2369 -				</FileConfiguration>
188.2370 -				<FileConfiguration
188.2371 -					Name="Debug|Win32"
188.2372 -					>
188.2373 -					<Tool
188.2374 -						Name="VCCLCompilerTool"
188.2375 -						UsePrecompiledHeader="0"
188.2376 -					/>
188.2377 -				</FileConfiguration>
188.2378 -				<FileConfiguration
188.2379 -					Name="Release FastBuild|Win32"
188.2380 -					>
188.2381 -					<Tool
188.2382 -						Name="VCCLCompilerTool"
188.2383 -						UsePrecompiledHeader="0"
188.2384 -					/>
188.2385 -				</FileConfiguration>
188.2386 -			</File>
188.2387 -			<File
188.2388 -				RelativePath=".\C\LzFind.c"
188.2389 -				>
188.2390 -				<FileConfiguration
188.2391 -					Name="Release|Win32"
188.2392 -					>
188.2393 -					<Tool
188.2394 -						Name="VCCLCompilerTool"
188.2395 -						UsePrecompiledHeader="0"
188.2396 -					/>
188.2397 -				</FileConfiguration>
188.2398 -				<FileConfiguration
188.2399 -					Name="Debug|Win32"
188.2400 -					>
188.2401 -					<Tool
188.2402 -						Name="VCCLCompilerTool"
188.2403 -						UsePrecompiledHeader="0"
188.2404 -					/>
188.2405 -				</FileConfiguration>
188.2406 -				<FileConfiguration
188.2407 -					Name="Release FastBuild|Win32"
188.2408 -					>
188.2409 -					<Tool
188.2410 -						Name="VCCLCompilerTool"
188.2411 -						UsePrecompiledHeader="0"
188.2412 -					/>
188.2413 -				</FileConfiguration>
188.2414 -			</File>
188.2415 -			<File
188.2416 -				RelativePath=".\C\LzFindMt.c"
188.2417 -				>
188.2418 -				<FileConfiguration
188.2419 -					Name="Release|Win32"
188.2420 -					>
188.2421 -					<Tool
188.2422 -						Name="VCCLCompilerTool"
188.2423 -						UsePrecompiledHeader="0"
188.2424 -					/>
188.2425 -				</FileConfiguration>
188.2426 -				<FileConfiguration
188.2427 -					Name="Debug|Win32"
188.2428 -					>
188.2429 -					<Tool
188.2430 -						Name="VCCLCompilerTool"
188.2431 -						UsePrecompiledHeader="0"
188.2432 -					/>
188.2433 -				</FileConfiguration>
188.2434 -				<FileConfiguration
188.2435 -					Name="Release FastBuild|Win32"
188.2436 -					>
188.2437 -					<Tool
188.2438 -						Name="VCCLCompilerTool"
188.2439 -						UsePrecompiledHeader="0"
188.2440 -					/>
188.2441 -				</FileConfiguration>
188.2442 -			</File>
188.2443 -			<File
188.2444 -				RelativePath=".\C\LzmaDec.c"
188.2445 -				>
188.2446 -				<FileConfiguration
188.2447 -					Name="Release|Win32"
188.2448 -					>
188.2449 -					<Tool
188.2450 -						Name="VCCLCompilerTool"
188.2451 -						UsePrecompiledHeader="0"
188.2452 -					/>
188.2453 -				</FileConfiguration>
188.2454 -				<FileConfiguration
188.2455 -					Name="Debug|Win32"
188.2456 -					>
188.2457 -					<Tool
188.2458 -						Name="VCCLCompilerTool"
188.2459 -						UsePrecompiledHeader="0"
188.2460 -					/>
188.2461 -				</FileConfiguration>
188.2462 -				<FileConfiguration
188.2463 -					Name="Release FastBuild|Win32"
188.2464 -					>
188.2465 -					<Tool
188.2466 -						Name="VCCLCompilerTool"
188.2467 -						UsePrecompiledHeader="0"
188.2468 -					/>
188.2469 -				</FileConfiguration>
188.2470 -			</File>
188.2471 -			<File
188.2472 -				RelativePath=".\C\LzmaEnc.c"
188.2473 -				>
188.2474 -				<FileConfiguration
188.2475 -					Name="Release|Win32"
188.2476 -					>
188.2477 -					<Tool
188.2478 -						Name="VCCLCompilerTool"
188.2479 -						UsePrecompiledHeader="0"
188.2480 -					/>
188.2481 -				</FileConfiguration>
188.2482 -				<FileConfiguration
188.2483 -					Name="Debug|Win32"
188.2484 -					>
188.2485 -					<Tool
188.2486 -						Name="VCCLCompilerTool"
188.2487 -						UsePrecompiledHeader="0"
188.2488 -					/>
188.2489 -				</FileConfiguration>
188.2490 -				<FileConfiguration
188.2491 -					Name="Release FastBuild|Win32"
188.2492 -					>
188.2493 -					<Tool
188.2494 -						Name="VCCLCompilerTool"
188.2495 -						UsePrecompiledHeader="0"
188.2496 -					/>
188.2497 -				</FileConfiguration>
188.2498 -			</File>
188.2499 -			<File
188.2500 -				RelativePath=".\C\Sha256.c"
188.2501 -				>
188.2502 -				<FileConfiguration
188.2503 -					Name="Release|Win32"
188.2504 -					>
188.2505 -					<Tool
188.2506 -						Name="VCCLCompilerTool"
188.2507 -						UsePrecompiledHeader="0"
188.2508 -					/>
188.2509 -				</FileConfiguration>
188.2510 -				<FileConfiguration
188.2511 -					Name="Debug|Win32"
188.2512 -					>
188.2513 -					<Tool
188.2514 -						Name="VCCLCompilerTool"
188.2515 -						UsePrecompiledHeader="0"
188.2516 -					/>
188.2517 -				</FileConfiguration>
188.2518 -				<FileConfiguration
188.2519 -					Name="Release FastBuild|Win32"
188.2520 -					>
188.2521 -					<Tool
188.2522 -						Name="VCCLCompilerTool"
188.2523 -						UsePrecompiledHeader="0"
188.2524 -					/>
188.2525 -				</FileConfiguration>
188.2526 -			</File>
188.2527 -			<File
188.2528 -				RelativePath=".\C\Sort.c"
188.2529 -				>
188.2530 -				<FileConfiguration
188.2531 -					Name="Release|Win32"
188.2532 -					>
188.2533 -					<Tool
188.2534 -						Name="VCCLCompilerTool"
188.2535 -						UsePrecompiledHeader="0"
188.2536 -					/>
188.2537 -				</FileConfiguration>
188.2538 -				<FileConfiguration
188.2539 -					Name="Debug|Win32"
188.2540 -					>
188.2541 -					<Tool
188.2542 -						Name="VCCLCompilerTool"
188.2543 -						UsePrecompiledHeader="0"
188.2544 -					/>
188.2545 -				</FileConfiguration>
188.2546 -				<FileConfiguration
188.2547 -					Name="Release FastBuild|Win32"
188.2548 -					>
188.2549 -					<Tool
188.2550 -						Name="VCCLCompilerTool"
188.2551 -						UsePrecompiledHeader="0"
188.2552 -					/>
188.2553 -				</FileConfiguration>
188.2554 -			</File>
188.2555 -			<File
188.2556 -				RelativePath=".\C\Threads.c"
188.2557 -				>
188.2558 -				<FileConfiguration
188.2559 -					Name="Release|Win32"
188.2560 -					>
188.2561 -					<Tool
188.2562 -						Name="VCCLCompilerTool"
188.2563 -						UsePrecompiledHeader="0"
188.2564 -					/>
188.2565 -				</FileConfiguration>
188.2566 -				<FileConfiguration
188.2567 -					Name="Debug|Win32"
188.2568 -					>
188.2569 -					<Tool
188.2570 -						Name="VCCLCompilerTool"
188.2571 -						UsePrecompiledHeader="0"
188.2572 -					/>
188.2573 -				</FileConfiguration>
188.2574 -				<FileConfiguration
188.2575 -					Name="Release FastBuild|Win32"
188.2576 -					>
188.2577 -					<Tool
188.2578 -						Name="VCCLCompilerTool"
188.2579 -						UsePrecompiledHeader="0"
188.2580 -					/>
188.2581 -				</FileConfiguration>
188.2582 -			</File>
188.2583 -		</Filter>
188.2584 -		<Filter
188.2585 -			Name="Common"
188.2586 -			>
188.2587 -			<File
188.2588 -				RelativePath=".\CPP\Common\CRC.cpp"
188.2589 -				>
188.2590 -				<FileConfiguration
188.2591 -					Name="Release|Win32"
188.2592 -					>
188.2593 -					<Tool
188.2594 -						Name="VCCLCompilerTool"
188.2595 -						UsePrecompiledHeader="2"
188.2596 -					/>
188.2597 -				</FileConfiguration>
188.2598 -				<FileConfiguration
188.2599 -					Name="Debug|Win32"
188.2600 -					>
188.2601 -					<Tool
188.2602 -						Name="VCCLCompilerTool"
188.2603 -						UsePrecompiledHeader="2"
188.2604 -					/>
188.2605 -				</FileConfiguration>
188.2606 -				<FileConfiguration
188.2607 -					Name="Release FastBuild|Win32"
188.2608 -					>
188.2609 -					<Tool
188.2610 -						Name="VCCLCompilerTool"
188.2611 -						UsePrecompiledHeader="2"
188.2612 -					/>
188.2613 -				</FileConfiguration>
188.2614 -			</File>
188.2615 -			<File
188.2616 -				RelativePath=".\CPP\Common\IntToString.cpp"
188.2617 -				>
188.2618 -				<FileConfiguration
188.2619 -					Name="Release|Win32"
188.2620 -					>
188.2621 -					<Tool
188.2622 -						Name="VCCLCompilerTool"
188.2623 -						UsePrecompiledHeader="2"
188.2624 -					/>
188.2625 -				</FileConfiguration>
188.2626 -				<FileConfiguration
188.2627 -					Name="Debug|Win32"
188.2628 -					>
188.2629 -					<Tool
188.2630 -						Name="VCCLCompilerTool"
188.2631 -						UsePrecompiledHeader="2"
188.2632 -					/>
188.2633 -				</FileConfiguration>
188.2634 -				<FileConfiguration
188.2635 -					Name="Release FastBuild|Win32"
188.2636 -					>
188.2637 -					<Tool
188.2638 -						Name="VCCLCompilerTool"
188.2639 -						UsePrecompiledHeader="2"
188.2640 -					/>
188.2641 -				</FileConfiguration>
188.2642 -			</File>
188.2643 -			<File
188.2644 -				RelativePath=".\CPP\Common\MyMap.cpp"
188.2645 -				>
188.2646 -				<FileConfiguration
188.2647 -					Name="Release|Win32"
188.2648 -					>
188.2649 -					<Tool
188.2650 -						Name="VCCLCompilerTool"
188.2651 -						UsePrecompiledHeader="2"
188.2652 -					/>
188.2653 -				</FileConfiguration>
188.2654 -				<FileConfiguration
188.2655 -					Name="Debug|Win32"
188.2656 -					>
188.2657 -					<Tool
188.2658 -						Name="VCCLCompilerTool"
188.2659 -						UsePrecompiledHeader="2"
188.2660 -					/>
188.2661 -				</FileConfiguration>
188.2662 -				<FileConfiguration
188.2663 -					Name="Release FastBuild|Win32"
188.2664 -					>
188.2665 -					<Tool
188.2666 -						Name="VCCLCompilerTool"
188.2667 -						UsePrecompiledHeader="2"
188.2668 -					/>
188.2669 -				</FileConfiguration>
188.2670 -			</File>
188.2671 -			<File
188.2672 -				RelativePath=".\CPP\Common\MyString.cpp"
188.2673 -				>
188.2674 -				<FileConfiguration
188.2675 -					Name="Release|Win32"
188.2676 -					>
188.2677 -					<Tool
188.2678 -						Name="VCCLCompilerTool"
188.2679 -						UsePrecompiledHeader="2"
188.2680 -					/>
188.2681 -				</FileConfiguration>
188.2682 -				<FileConfiguration
188.2683 -					Name="Debug|Win32"
188.2684 -					>
188.2685 -					<Tool
188.2686 -						Name="VCCLCompilerTool"
188.2687 -						UsePrecompiledHeader="2"
188.2688 -					/>
188.2689 -				</FileConfiguration>
188.2690 -				<FileConfiguration
188.2691 -					Name="Release FastBuild|Win32"
188.2692 -					>
188.2693 -					<Tool
188.2694 -						Name="VCCLCompilerTool"
188.2695 -						UsePrecompiledHeader="2"
188.2696 -					/>
188.2697 -				</FileConfiguration>
188.2698 -			</File>
188.2699 -			<File
188.2700 -				RelativePath=".\CPP\Common\MyVector.cpp"
188.2701 -				>
188.2702 -				<FileConfiguration
188.2703 -					Name="Release|Win32"
188.2704 -					>
188.2705 -					<Tool
188.2706 -						Name="VCCLCompilerTool"
188.2707 -						UsePrecompiledHeader="2"
188.2708 -					/>
188.2709 -				</FileConfiguration>
188.2710 -				<FileConfiguration
188.2711 -					Name="Debug|Win32"
188.2712 -					>
188.2713 -					<Tool
188.2714 -						Name="VCCLCompilerTool"
188.2715 -						UsePrecompiledHeader="2"
188.2716 -					/>
188.2717 -				</FileConfiguration>
188.2718 -				<FileConfiguration
188.2719 -					Name="Release FastBuild|Win32"
188.2720 -					>
188.2721 -					<Tool
188.2722 -						Name="VCCLCompilerTool"
188.2723 -						UsePrecompiledHeader="2"
188.2724 -					/>
188.2725 -				</FileConfiguration>
188.2726 -			</File>
188.2727 -			<File
188.2728 -				RelativePath=".\CPP\Common\MyXml.cpp"
188.2729 -				>
188.2730 -				<FileConfiguration
188.2731 -					Name="Release|Win32"
188.2732 -					>
188.2733 -					<Tool
188.2734 -						Name="VCCLCompilerTool"
188.2735 -						UsePrecompiledHeader="2"
188.2736 -					/>
188.2737 -				</FileConfiguration>
188.2738 -				<FileConfiguration
188.2739 -					Name="Debug|Win32"
188.2740 -					>
188.2741 -					<Tool
188.2742 -						Name="VCCLCompilerTool"
188.2743 -						UsePrecompiledHeader="2"
188.2744 -					/>
188.2745 -				</FileConfiguration>
188.2746 -				<FileConfiguration
188.2747 -					Name="Release FastBuild|Win32"
188.2748 -					>
188.2749 -					<Tool
188.2750 -						Name="VCCLCompilerTool"
188.2751 -						UsePrecompiledHeader="2"
188.2752 -					/>
188.2753 -				</FileConfiguration>
188.2754 -			</File>
188.2755 -			<File
188.2756 -				RelativePath=".\CPP\Common\NewHandler.cpp"
188.2757 -				>
188.2758 -				<FileConfiguration
188.2759 -					Name="Release|Win32"
188.2760 -					ExcludedFromBuild="true"
188.2761 -					>
188.2762 -					<Tool
188.2763 -						Name="VCCLCompilerTool"
188.2764 -						UsePrecompiledHeader="2"
188.2765 -					/>
188.2766 -				</FileConfiguration>
188.2767 -				<FileConfiguration
188.2768 -					Name="Debug|Win32"
188.2769 -					ExcludedFromBuild="true"
188.2770 -					>
188.2771 -					<Tool
188.2772 -						Name="VCCLCompilerTool"
188.2773 -						UsePrecompiledHeader="2"
188.2774 -					/>
188.2775 -				</FileConfiguration>
188.2776 -				<FileConfiguration
188.2777 -					Name="Release FastBuild|Win32"
188.2778 -					ExcludedFromBuild="true"
188.2779 -					>
188.2780 -					<Tool
188.2781 -						Name="VCCLCompilerTool"
188.2782 -						UsePrecompiledHeader="2"
188.2783 -					/>
188.2784 -				</FileConfiguration>
188.2785 -			</File>
188.2786 -			<File
188.2787 -				RelativePath=".\CPP\Common\StringConvert.cpp"
188.2788 -				>
188.2789 -				<FileConfiguration
188.2790 -					Name="Release|Win32"
188.2791 -					>
188.2792 -					<Tool
188.2793 -						Name="VCCLCompilerTool"
188.2794 -						UsePrecompiledHeader="2"
188.2795 -					/>
188.2796 -				</FileConfiguration>
188.2797 -				<FileConfiguration
188.2798 -					Name="Debug|Win32"
188.2799 -					>
188.2800 -					<Tool
188.2801 -						Name="VCCLCompilerTool"
188.2802 -						UsePrecompiledHeader="2"
188.2803 -					/>
188.2804 -				</FileConfiguration>
188.2805 -				<FileConfiguration
188.2806 -					Name="Release FastBuild|Win32"
188.2807 -					>
188.2808 -					<Tool
188.2809 -						Name="VCCLCompilerTool"
188.2810 -						UsePrecompiledHeader="2"
188.2811 -					/>
188.2812 -				</FileConfiguration>
188.2813 -			</File>
188.2814 -			<File
188.2815 -				RelativePath=".\CPP\Common\StringToInt.cpp"
188.2816 -				>
188.2817 -				<FileConfiguration
188.2818 -					Name="Release|Win32"
188.2819 -					>
188.2820 -					<Tool
188.2821 -						Name="VCCLCompilerTool"
188.2822 -						UsePrecompiledHeader="2"
188.2823 -					/>
188.2824 -				</FileConfiguration>
188.2825 -				<FileConfiguration
188.2826 -					Name="Debug|Win32"
188.2827 -					>
188.2828 -					<Tool
188.2829 -						Name="VCCLCompilerTool"
188.2830 -						UsePrecompiledHeader="2"
188.2831 -					/>
188.2832 -				</FileConfiguration>
188.2833 -				<FileConfiguration
188.2834 -					Name="Release FastBuild|Win32"
188.2835 -					>
188.2836 -					<Tool
188.2837 -						Name="VCCLCompilerTool"
188.2838 -						UsePrecompiledHeader="2"
188.2839 -					/>
188.2840 -				</FileConfiguration>
188.2841 -			</File>
188.2842 -			<File
188.2843 -				RelativePath=".\CPP\Common\UTFConvert.cpp"
188.2844 -				>
188.2845 -				<FileConfiguration
188.2846 -					Name="Release|Win32"
188.2847 -					>
188.2848 -					<Tool
188.2849 -						Name="VCCLCompilerTool"
188.2850 -						UsePrecompiledHeader="2"
188.2851 -					/>
188.2852 -				</FileConfiguration>
188.2853 -				<FileConfiguration
188.2854 -					Name="Debug|Win32"
188.2855 -					>
188.2856 -					<Tool
188.2857 -						Name="VCCLCompilerTool"
188.2858 -						UsePrecompiledHeader="2"
188.2859 -					/>
188.2860 -				</FileConfiguration>
188.2861 -				<FileConfiguration
188.2862 -					Name="Release FastBuild|Win32"
188.2863 -					>
188.2864 -					<Tool
188.2865 -						Name="VCCLCompilerTool"
188.2866 -						UsePrecompiledHeader="2"
188.2867 -					/>
188.2868 -				</FileConfiguration>
188.2869 -			</File>
188.2870 -			<File
188.2871 -				RelativePath=".\CPP\Common\Wildcard.cpp"
188.2872 -				>
188.2873 -				<FileConfiguration
188.2874 -					Name="Release|Win32"
188.2875 -					>
188.2876 -					<Tool
188.2877 -						Name="VCCLCompilerTool"
188.2878 -						UsePrecompiledHeader="2"
188.2879 -					/>
188.2880 -				</FileConfiguration>
188.2881 -				<FileConfiguration
188.2882 -					Name="Debug|Win32"
188.2883 -					>
188.2884 -					<Tool
188.2885 -						Name="VCCLCompilerTool"
188.2886 -						UsePrecompiledHeader="2"
188.2887 -					/>
188.2888 -				</FileConfiguration>
188.2889 -				<FileConfiguration
188.2890 -					Name="Release FastBuild|Win32"
188.2891 -					>
188.2892 -					<Tool
188.2893 -						Name="VCCLCompilerTool"
188.2894 -						UsePrecompiledHeader="2"
188.2895 -					/>
188.2896 -				</FileConfiguration>
188.2897 -			</File>
188.2898 -		</Filter>
188.2899 -		<Filter
188.2900 -			Name="Compress"
188.2901 -			>
188.2902 -			<File
188.2903 -				RelativePath=".\CPP\7zip\Compress\LzhDecoder.cpp"
188.2904 -				>
188.2905 -				<FileConfiguration
188.2906 -					Name="Release|Win32"
188.2907 -					>
188.2908 -					<Tool
188.2909 -						Name="VCCLCompilerTool"
188.2910 -						UsePrecompiledHeader="2"
188.2911 -					/>
188.2912 -				</FileConfiguration>
188.2913 -				<FileConfiguration
188.2914 -					Name="Debug|Win32"
188.2915 -					>
188.2916 -					<Tool
188.2917 -						Name="VCCLCompilerTool"
188.2918 -						UsePrecompiledHeader="2"
188.2919 -					/>
188.2920 -				</FileConfiguration>
188.2921 -				<FileConfiguration
188.2922 -					Name="Release FastBuild|Win32"
188.2923 -					>
188.2924 -					<Tool
188.2925 -						Name="VCCLCompilerTool"
188.2926 -						UsePrecompiledHeader="2"
188.2927 -					/>
188.2928 -				</FileConfiguration>
188.2929 -			</File>
188.2930 -			<File
188.2931 -				RelativePath=".\CPP\7zip\Compress\LzOutWindow.cpp"
188.2932 -				>
188.2933 -				<FileConfiguration
188.2934 -					Name="Release|Win32"
188.2935 -					>
188.2936 -					<Tool
188.2937 -						Name="VCCLCompilerTool"
188.2938 -						UsePrecompiledHeader="2"
188.2939 -					/>
188.2940 -				</FileConfiguration>
188.2941 -				<FileConfiguration
188.2942 -					Name="Debug|Win32"
188.2943 -					>
188.2944 -					<Tool
188.2945 -						Name="VCCLCompilerTool"
188.2946 -						UsePrecompiledHeader="2"
188.2947 -					/>
188.2948 -				</FileConfiguration>
188.2949 -				<FileConfiguration
188.2950 -					Name="Release FastBuild|Win32"
188.2951 -					>
188.2952 -					<Tool
188.2953 -						Name="VCCLCompilerTool"
188.2954 -						UsePrecompiledHeader="2"
188.2955 -					/>
188.2956 -				</FileConfiguration>
188.2957 -			</File>
188.2958 -			<Filter
188.2959 -				Name="PPMD"
188.2960 -				>
188.2961 -				<File
188.2962 -					RelativePath=".\CPP\7zip\Compress\PpmdDecoder.cpp"
188.2963 -					>
188.2964 -					<FileConfiguration
188.2965 -						Name="Release|Win32"
188.2966 -						>
188.2967 -						<Tool
188.2968 -							Name="VCCLCompilerTool"
188.2969 -							UsePrecompiledHeader="2"
188.2970 -						/>
188.2971 -					</FileConfiguration>
188.2972 -					<FileConfiguration
188.2973 -						Name="Debug|Win32"
188.2974 -						>
188.2975 -						<Tool
188.2976 -							Name="VCCLCompilerTool"
188.2977 -							UsePrecompiledHeader="2"
188.2978 -						/>
188.2979 -					</FileConfiguration>
188.2980 -					<FileConfiguration
188.2981 -						Name="Release FastBuild|Win32"
188.2982 -						>
188.2983 -						<Tool
188.2984 -							Name="VCCLCompilerTool"
188.2985 -							UsePrecompiledHeader="2"
188.2986 -						/>
188.2987 -					</FileConfiguration>
188.2988 -				</File>
188.2989 -			</Filter>
188.2990 -			<Filter
188.2991 -				Name="Bit Coder"
188.2992 -				>
188.2993 -				<File
188.2994 -					RelativePath=".\CPP\7zip\Compress\BitlDecoder.cpp"
188.2995 -					>
188.2996 -					<FileConfiguration
188.2997 -						Name="Release|Win32"
188.2998 -						>
188.2999 -						<Tool
188.3000 -							Name="VCCLCompilerTool"
188.3001 -							UsePrecompiledHeader="2"
188.3002 -						/>
188.3003 -					</FileConfiguration>
188.3004 -					<FileConfiguration
188.3005 -						Name="Debug|Win32"
188.3006 -						>
188.3007 -						<Tool
188.3008 -							Name="VCCLCompilerTool"
188.3009 -							UsePrecompiledHeader="2"
188.3010 -						/>
188.3011 -					</FileConfiguration>
188.3012 -					<FileConfiguration
188.3013 -						Name="Release FastBuild|Win32"
188.3014 -						>
188.3015 -						<Tool
188.3016 -							Name="VCCLCompilerTool"
188.3017 -							UsePrecompiledHeader="2"
188.3018 -						/>
188.3019 -					</FileConfiguration>
188.3020 -				</File>
188.3021 -			</Filter>
188.3022 -			<Filter
188.3023 -				Name="Rar Compress"
188.3024 -				>
188.3025 -				<File
188.3026 -					RelativePath=".\CPP\7zip\Compress\Rar1Decoder.cpp"
188.3027 -					>
188.3028 -					<FileConfiguration
188.3029 -						Name="Release|Win32"
188.3030 -						>
188.3031 -						<Tool
188.3032 -							Name="VCCLCompilerTool"
188.3033 -							UsePrecompiledHeader="2"
188.3034 -						/>
188.3035 -					</FileConfiguration>
188.3036 -					<FileConfiguration
188.3037 -						Name="Debug|Win32"
188.3038 -						>
188.3039 -						<Tool
188.3040 -							Name="VCCLCompilerTool"
188.3041 -							UsePrecompiledHeader="2"
188.3042 -						/>
188.3043 -					</FileConfiguration>
188.3044 -					<FileConfiguration
188.3045 -						Name="Release FastBuild|Win32"
188.3046 -						>
188.3047 -						<Tool
188.3048 -							Name="VCCLCompilerTool"
188.3049 -							UsePrecompiledHeader="2"
188.3050 -						/>
188.3051 -					</FileConfiguration>
188.3052 -				</File>
188.3053 -				<File
188.3054 -					RelativePath=".\CPP\7zip\Compress\Rar2Decoder.cpp"
188.3055 -					>
188.3056 -					<FileConfiguration
188.3057 -						Name="Release|Win32"
188.3058 -						>
188.3059 -						<Tool
188.3060 -							Name="VCCLCompilerTool"
188.3061 -							UsePrecompiledHeader="2"
188.3062 -						/>
188.3063 -					</FileConfiguration>
188.3064 -					<FileConfiguration
188.3065 -						Name="Debug|Win32"
188.3066 -						>
188.3067 -						<Tool
188.3068 -							Name="VCCLCompilerTool"
188.3069 -							UsePrecompiledHeader="2"
188.3070 -						/>
188.3071 -					</FileConfiguration>
188.3072 -					<FileConfiguration
188.3073 -						Name="Release FastBuild|Win32"
188.3074 -						>
188.3075 -						<Tool
188.3076 -							Name="VCCLCompilerTool"
188.3077 -							UsePrecompiledHeader="2"
188.3078 -						/>
188.3079 -					</FileConfiguration>
188.3080 -				</File>
188.3081 -				<File
188.3082 -					RelativePath=".\CPP\7zip\Compress\Rar3Decoder.cpp"
188.3083 -					>
188.3084 -					<FileConfiguration
188.3085 -						Name="Release|Win32"
188.3086 -						>
188.3087 -						<Tool
188.3088 -							Name="VCCLCompilerTool"
188.3089 -							UsePrecompiledHeader="2"
188.3090 -						/>
188.3091 -					</FileConfiguration>
188.3092 -					<FileConfiguration
188.3093 -						Name="Debug|Win32"
188.3094 -						>
188.3095 -						<Tool
188.3096 -							Name="VCCLCompilerTool"
188.3097 -							UsePrecompiledHeader="2"
188.3098 -						/>
188.3099 -					</FileConfiguration>
188.3100 -					<FileConfiguration
188.3101 -						Name="Release FastBuild|Win32"
188.3102 -						>
188.3103 -						<Tool
188.3104 -							Name="VCCLCompilerTool"
188.3105 -							UsePrecompiledHeader="2"
188.3106 -						/>
188.3107 -					</FileConfiguration>
188.3108 -				</File>
188.3109 -				<File
188.3110 -					RelativePath=".\CPP\7zip\Compress\Rar3Vm.cpp"
188.3111 -					>
188.3112 -					<FileConfiguration
188.3113 -						Name="Release|Win32"
188.3114 -						>
188.3115 -						<Tool
188.3116 -							Name="VCCLCompilerTool"
188.3117 -							UsePrecompiledHeader="2"
188.3118 -						/>
188.3119 -					</FileConfiguration>
188.3120 -					<FileConfiguration
188.3121 -						Name="Debug|Win32"
188.3122 -						>
188.3123 -						<Tool
188.3124 -							Name="VCCLCompilerTool"
188.3125 -							UsePrecompiledHeader="2"
188.3126 -						/>
188.3127 -					</FileConfiguration>
188.3128 -					<FileConfiguration
188.3129 -						Name="Release FastBuild|Win32"
188.3130 -						>
188.3131 -						<Tool
188.3132 -							Name="VCCLCompilerTool"
188.3133 -							UsePrecompiledHeader="2"
188.3134 -						/>
188.3135 -					</FileConfiguration>
188.3136 -				</File>
188.3137 -			</Filter>
188.3138 -			<Filter
188.3139 -				Name="BZip2 Compress"
188.3140 -				>
188.3141 -				<File
188.3142 -					RelativePath=".\CPP\7zip\Compress\BZip2Crc.cpp"
188.3143 -					>
188.3144 -					<FileConfiguration
188.3145 -						Name="Release|Win32"
188.3146 -						>
188.3147 -						<Tool
188.3148 -							Name="VCCLCompilerTool"
188.3149 -							UsePrecompiledHeader="2"
188.3150 -						/>
188.3151 -					</FileConfiguration>
188.3152 -					<FileConfiguration
188.3153 -						Name="Debug|Win32"
188.3154 -						>
188.3155 -						<Tool
188.3156 -							Name="VCCLCompilerTool"
188.3157 -							UsePrecompiledHeader="2"
188.3158 -						/>
188.3159 -					</FileConfiguration>
188.3160 -					<FileConfiguration
188.3161 -						Name="Release FastBuild|Win32"
188.3162 -						>
188.3163 -						<Tool
188.3164 -							Name="VCCLCompilerTool"
188.3165 -							UsePrecompiledHeader="2"
188.3166 -						/>
188.3167 -					</FileConfiguration>
188.3168 -				</File>
188.3169 -				<File
188.3170 -					RelativePath=".\CPP\7zip\Compress\BZip2Decoder.cpp"
188.3171 -					>
188.3172 -					<FileConfiguration
188.3173 -						Name="Release|Win32"
188.3174 -						>
188.3175 -						<Tool
188.3176 -							Name="VCCLCompilerTool"
188.3177 -							UsePrecompiledHeader="2"
188.3178 -						/>
188.3179 -					</FileConfiguration>
188.3180 -					<FileConfiguration
188.3181 -						Name="Debug|Win32"
188.3182 -						>
188.3183 -						<Tool
188.3184 -							Name="VCCLCompilerTool"
188.3185 -							UsePrecompiledHeader="2"
188.3186 -						/>
188.3187 -					</FileConfiguration>
188.3188 -					<FileConfiguration
188.3189 -						Name="Release FastBuild|Win32"
188.3190 -						>
188.3191 -						<Tool
188.3192 -							Name="VCCLCompilerTool"
188.3193 -							UsePrecompiledHeader="2"
188.3194 -						/>
188.3195 -					</FileConfiguration>
188.3196 -				</File>
188.3197 -			</Filter>
188.3198 -			<Filter
188.3199 -				Name="Zip Compress"
188.3200 -				>
188.3201 -				<File
188.3202 -					RelativePath=".\CPP\7zip\Compress\DeflateDecoder.cpp"
188.3203 -					>
188.3204 -					<FileConfiguration
188.3205 -						Name="Release|Win32"
188.3206 -						>
188.3207 -						<Tool
188.3208 -							Name="VCCLCompilerTool"
188.3209 -							UsePrecompiledHeader="2"
188.3210 -						/>
188.3211 -					</FileConfiguration>
188.3212 -					<FileConfiguration
188.3213 -						Name="Debug|Win32"
188.3214 -						>
188.3215 -						<Tool
188.3216 -							Name="VCCLCompilerTool"
188.3217 -							UsePrecompiledHeader="2"
188.3218 -						/>
188.3219 -					</FileConfiguration>
188.3220 -					<FileConfiguration
188.3221 -						Name="Release FastBuild|Win32"
188.3222 -						>
188.3223 -						<Tool
188.3224 -							Name="VCCLCompilerTool"
188.3225 -							UsePrecompiledHeader="2"
188.3226 -						/>
188.3227 -					</FileConfiguration>
188.3228 -				</File>
188.3229 -				<File
188.3230 -					RelativePath=".\CPP\7zip\Compress\ImplodeDecoder.cpp"
188.3231 -					>
188.3232 -					<FileConfiguration
188.3233 -						Name="Release|Win32"
188.3234 -						>
188.3235 -						<Tool
188.3236 -							Name="VCCLCompilerTool"
188.3237 -							UsePrecompiledHeader="2"
188.3238 -						/>
188.3239 -					</FileConfiguration>
188.3240 -					<FileConfiguration
188.3241 -						Name="Debug|Win32"
188.3242 -						>
188.3243 -						<Tool
188.3244 -							Name="VCCLCompilerTool"
188.3245 -							UsePrecompiledHeader="2"
188.3246 -						/>
188.3247 -					</FileConfiguration>
188.3248 -					<FileConfiguration
188.3249 -						Name="Release FastBuild|Win32"
188.3250 -						>
188.3251 -						<Tool
188.3252 -							Name="VCCLCompilerTool"
188.3253 -							UsePrecompiledHeader="2"
188.3254 -						/>
188.3255 -					</FileConfiguration>
188.3256 -				</File>
188.3257 -				<File
188.3258 -					RelativePath=".\CPP\7zip\Compress\ImplodeHuffmanDecoder.cpp"
188.3259 -					>
188.3260 -					<FileConfiguration
188.3261 -						Name="Release|Win32"
188.3262 -						>
188.3263 -						<Tool
188.3264 -							Name="VCCLCompilerTool"
188.3265 -							UsePrecompiledHeader="2"
188.3266 -						/>
188.3267 -					</FileConfiguration>
188.3268 -					<FileConfiguration
188.3269 -						Name="Debug|Win32"
188.3270 -						>
188.3271 -						<Tool
188.3272 -							Name="VCCLCompilerTool"
188.3273 -							UsePrecompiledHeader="2"
188.3274 -						/>
188.3275 -					</FileConfiguration>
188.3276 -					<FileConfiguration
188.3277 -						Name="Release FastBuild|Win32"
188.3278 -						>
188.3279 -						<Tool
188.3280 -							Name="VCCLCompilerTool"
188.3281 -							UsePrecompiledHeader="2"
188.3282 -						/>
188.3283 -					</FileConfiguration>
188.3284 -				</File>
188.3285 -				<File
188.3286 -					RelativePath=".\CPP\7zip\Compress\ShrinkDecoder.cpp"
188.3287 -					>
188.3288 -					<FileConfiguration
188.3289 -						Name="Release|Win32"
188.3290 -						>
188.3291 -						<Tool
188.3292 -							Name="VCCLCompilerTool"
188.3293 -							UsePrecompiledHeader="2"
188.3294 -						/>
188.3295 -					</FileConfiguration>
188.3296 -					<FileConfiguration
188.3297 -						Name="Debug|Win32"
188.3298 -						>
188.3299 -						<Tool
188.3300 -							Name="VCCLCompilerTool"
188.3301 -							UsePrecompiledHeader="2"
188.3302 -						/>
188.3303 -					</FileConfiguration>
188.3304 -					<FileConfiguration
188.3305 -						Name="Release FastBuild|Win32"
188.3306 -						>
188.3307 -						<Tool
188.3308 -							Name="VCCLCompilerTool"
188.3309 -							UsePrecompiledHeader="2"
188.3310 -						/>
188.3311 -					</FileConfiguration>
188.3312 -				</File>
188.3313 -				<File
188.3314 -					RelativePath=".\CPP\7zip\Compress\ZlibDecoder.cpp"
188.3315 -					>
188.3316 -					<FileConfiguration
188.3317 -						Name="Release|Win32"
188.3318 -						>
188.3319 -						<Tool
188.3320 -							Name="VCCLCompilerTool"
188.3321 -							UsePrecompiledHeader="2"
188.3322 -						/>
188.3323 -					</FileConfiguration>
188.3324 -					<FileConfiguration
188.3325 -						Name="Debug|Win32"
188.3326 -						>
188.3327 -						<Tool
188.3328 -							Name="VCCLCompilerTool"
188.3329 -							UsePrecompiledHeader="2"
188.3330 -						/>
188.3331 -					</FileConfiguration>
188.3332 -					<FileConfiguration
188.3333 -						Name="Release FastBuild|Win32"
188.3334 -						>
188.3335 -						<Tool
188.3336 -							Name="VCCLCompilerTool"
188.3337 -							UsePrecompiledHeader="2"
188.3338 -						/>
188.3339 -					</FileConfiguration>
188.3340 -				</File>
188.3341 -			</Filter>
188.3342 -			<Filter
188.3343 -				Name="7z Compress"
188.3344 -				>
188.3345 -				<File
188.3346 -					RelativePath=".\CPP\7zip\Compress\Bcj2Coder.cpp"
188.3347 -					>
188.3348 -					<FileConfiguration
188.3349 -						Name="Release|Win32"
188.3350 -						>
188.3351 -						<Tool
188.3352 -							Name="VCCLCompilerTool"
188.3353 -							UsePrecompiledHeader="2"
188.3354 -						/>
188.3355 -					</FileConfiguration>
188.3356 -					<FileConfiguration
188.3357 -						Name="Debug|Win32"
188.3358 -						>
188.3359 -						<Tool
188.3360 -							Name="VCCLCompilerTool"
188.3361 -							UsePrecompiledHeader="2"
188.3362 -						/>
188.3363 -					</FileConfiguration>
188.3364 -					<FileConfiguration
188.3365 -						Name="Release FastBuild|Win32"
188.3366 -						>
188.3367 -						<Tool
188.3368 -							Name="VCCLCompilerTool"
188.3369 -							UsePrecompiledHeader="2"
188.3370 -						/>
188.3371 -					</FileConfiguration>
188.3372 -				</File>
188.3373 -				<File
188.3374 -					RelativePath=".\CPP\7zip\Compress\BcjCoder.cpp"
188.3375 -					>
188.3376 -					<FileConfiguration
188.3377 -						Name="Release|Win32"
188.3378 -						>
188.3379 -						<Tool
188.3380 -							Name="VCCLCompilerTool"
188.3381 -							UsePrecompiledHeader="2"
188.3382 -						/>
188.3383 -					</FileConfiguration>
188.3384 -					<FileConfiguration
188.3385 -						Name="Debug|Win32"
188.3386 -						>
188.3387 -						<Tool
188.3388 -							Name="VCCLCompilerTool"
188.3389 -							UsePrecompiledHeader="2"
188.3390 -						/>
188.3391 -					</FileConfiguration>
188.3392 -					<FileConfiguration
188.3393 -						Name="Release FastBuild|Win32"
188.3394 -						>
188.3395 -						<Tool
188.3396 -							Name="VCCLCompilerTool"
188.3397 -							UsePrecompiledHeader="2"
188.3398 -						/>
188.3399 -					</FileConfiguration>
188.3400 -				</File>
188.3401 -				<File
188.3402 -					RelativePath=".\CPP\7zip\Compress\BranchCoder.cpp"
188.3403 -					>
188.3404 -					<FileConfiguration
188.3405 -						Name="Release|Win32"
188.3406 -						>
188.3407 -						<Tool
188.3408 -							Name="VCCLCompilerTool"
188.3409 -							UsePrecompiledHeader="2"
188.3410 -						/>
188.3411 -					</FileConfiguration>
188.3412 -					<FileConfiguration
188.3413 -						Name="Debug|Win32"
188.3414 -						>
188.3415 -						<Tool
188.3416 -							Name="VCCLCompilerTool"
188.3417 -							UsePrecompiledHeader="2"
188.3418 -						/>
188.3419 -					</FileConfiguration>
188.3420 -					<FileConfiguration
188.3421 -						Name="Release FastBuild|Win32"
188.3422 -						>
188.3423 -						<Tool
188.3424 -							Name="VCCLCompilerTool"
188.3425 -							UsePrecompiledHeader="2"
188.3426 -						/>
188.3427 -					</FileConfiguration>
188.3428 -				</File>
188.3429 -				<File
188.3430 -					RelativePath=".\CPP\7zip\Compress\BranchMisc.cpp"
188.3431 -					>
188.3432 -					<FileConfiguration
188.3433 -						Name="Release|Win32"
188.3434 -						>
188.3435 -						<Tool
188.3436 -							Name="VCCLCompilerTool"
188.3437 -							UsePrecompiledHeader="2"
188.3438 -						/>
188.3439 -					</FileConfiguration>
188.3440 -					<FileConfiguration
188.3441 -						Name="Debug|Win32"
188.3442 -						>
188.3443 -						<Tool
188.3444 -							Name="VCCLCompilerTool"
188.3445 -							UsePrecompiledHeader="2"
188.3446 -						/>
188.3447 -					</FileConfiguration>
188.3448 -					<FileConfiguration
188.3449 -						Name="Release FastBuild|Win32"
188.3450 -						>
188.3451 -						<Tool
188.3452 -							Name="VCCLCompilerTool"
188.3453 -							UsePrecompiledHeader="2"
188.3454 -						/>
188.3455 -					</FileConfiguration>
188.3456 -				</File>
188.3457 -				<File
188.3458 -					RelativePath=".\CPP\7zip\Compress\ByteSwap.cpp"
188.3459 -					>
188.3460 -					<FileConfiguration
188.3461 -						Name="Release|Win32"
188.3462 -						>
188.3463 -						<Tool
188.3464 -							Name="VCCLCompilerTool"
188.3465 -							UsePrecompiledHeader="2"
188.3466 -						/>
188.3467 -					</FileConfiguration>
188.3468 -					<FileConfiguration
188.3469 -						Name="Debug|Win32"
188.3470 -						>
188.3471 -						<Tool
188.3472 -							Name="VCCLCompilerTool"
188.3473 -							UsePrecompiledHeader="2"
188.3474 -						/>
188.3475 -					</FileConfiguration>
188.3476 -					<FileConfiguration
188.3477 -						Name="Release FastBuild|Win32"
188.3478 -						>
188.3479 -						<Tool
188.3480 -							Name="VCCLCompilerTool"
188.3481 -							UsePrecompiledHeader="2"
188.3482 -						/>
188.3483 -					</FileConfiguration>
188.3484 -				</File>
188.3485 -				<File
188.3486 -					RelativePath=".\CPP\7zip\Compress\CopyCoder.cpp"
188.3487 -					>
188.3488 -					<FileConfiguration
188.3489 -						Name="Release|Win32"
188.3490 -						>
188.3491 -						<Tool
188.3492 -							Name="VCCLCompilerTool"
188.3493 -							UsePrecompiledHeader="2"
188.3494 -						/>
188.3495 -					</FileConfiguration>
188.3496 -					<FileConfiguration
188.3497 -						Name="Debug|Win32"
188.3498 -						>
188.3499 -						<Tool
188.3500 -							Name="VCCLCompilerTool"
188.3501 -							UsePrecompiledHeader="2"
188.3502 -						/>
188.3503 -					</FileConfiguration>
188.3504 -					<FileConfiguration
188.3505 -						Name="Release FastBuild|Win32"
188.3506 -						>
188.3507 -						<Tool
188.3508 -							Name="VCCLCompilerTool"
188.3509 -							UsePrecompiledHeader="2"
188.3510 -						/>
188.3511 -					</FileConfiguration>
188.3512 -				</File>
188.3513 -				<File
188.3514 -					RelativePath=".\CPP\7zip\Compress\LzmaDecoder.cpp"
188.3515 -					>
188.3516 -					<FileConfiguration
188.3517 -						Name="Release|Win32"
188.3518 -						>
188.3519 -						<Tool
188.3520 -							Name="VCCLCompilerTool"
188.3521 -							UsePrecompiledHeader="2"
188.3522 -						/>
188.3523 -					</FileConfiguration>
188.3524 -					<FileConfiguration
188.3525 -						Name="Debug|Win32"
188.3526 -						>
188.3527 -						<Tool
188.3528 -							Name="VCCLCompilerTool"
188.3529 -							UsePrecompiledHeader="2"
188.3530 -						/>
188.3531 -					</FileConfiguration>
188.3532 -					<FileConfiguration
188.3533 -						Name="Release FastBuild|Win32"
188.3534 -						>
188.3535 -						<Tool
188.3536 -							Name="VCCLCompilerTool"
188.3537 -							UsePrecompiledHeader="2"
188.3538 -						/>
188.3539 -					</FileConfiguration>
188.3540 -				</File>
188.3541 -			</Filter>
188.3542 -		</Filter>
188.3543 -		<Filter
188.3544 -			Name="Crypto"
188.3545 -			>
188.3546 -			<File
188.3547 -				RelativePath=".\CPP\7zip\Crypto\7zAes.cpp"
188.3548 -				>
188.3549 -				<FileConfiguration
188.3550 -					Name="Release|Win32"
188.3551 -					>
188.3552 -					<Tool
188.3553 -						Name="VCCLCompilerTool"
188.3554 -						UsePrecompiledHeader="2"
188.3555 -					/>
188.3556 -				</FileConfiguration>
188.3557 -				<FileConfiguration
188.3558 -					Name="Debug|Win32"
188.3559 -					>
188.3560 -					<Tool
188.3561 -						Name="VCCLCompilerTool"
188.3562 -						UsePrecompiledHeader="2"
188.3563 -					/>
188.3564 -				</FileConfiguration>
188.3565 -				<FileConfiguration
188.3566 -					Name="Release FastBuild|Win32"
188.3567 -					>
188.3568 -					<Tool
188.3569 -						Name="VCCLCompilerTool"
188.3570 -						UsePrecompiledHeader="2"
188.3571 -					/>
188.3572 -				</FileConfiguration>
188.3573 -			</File>
188.3574 -			<File
188.3575 -				RelativePath=".\CPP\7zip\Crypto\HmacSha1.cpp"
188.3576 -				>
188.3577 -				<FileConfiguration
188.3578 -					Name="Release|Win32"
188.3579 -					>
188.3580 -					<Tool
188.3581 -						Name="VCCLCompilerTool"
188.3582 -						UsePrecompiledHeader="2"
188.3583 -					/>
188.3584 -				</FileConfiguration>
188.3585 -				<FileConfiguration
188.3586 -					Name="Debug|Win32"
188.3587 -					>
188.3588 -					<Tool
188.3589 -						Name="VCCLCompilerTool"
188.3590 -						UsePrecompiledHeader="2"
188.3591 -					/>
188.3592 -				</FileConfiguration>
188.3593 -				<FileConfiguration
188.3594 -					Name="Release FastBuild|Win32"
188.3595 -					>
188.3596 -					<Tool
188.3597 -						Name="VCCLCompilerTool"
188.3598 -						UsePrecompiledHeader="2"
188.3599 -					/>
188.3600 -				</FileConfiguration>
188.3601 -			</File>
188.3602 -			<File
188.3603 -				RelativePath=".\CPP\7zip\Crypto\MyAes.cpp"
188.3604 -				>
188.3605 -				<FileConfiguration
188.3606 -					Name="Release|Win32"
188.3607 -					>
188.3608 -					<Tool
188.3609 -						Name="VCCLCompilerTool"
188.3610 -						UsePrecompiledHeader="2"
188.3611 -					/>
188.3612 -				</FileConfiguration>
188.3613 -				<FileConfiguration
188.3614 -					Name="Debug|Win32"
188.3615 -					>
188.3616 -					<Tool
188.3617 -						Name="VCCLCompilerTool"
188.3618 -						UsePrecompiledHeader="2"
188.3619 -					/>
188.3620 -				</FileConfiguration>
188.3621 -				<FileConfiguration
188.3622 -					Name="Release FastBuild|Win32"
188.3623 -					>
188.3624 -					<Tool
188.3625 -						Name="VCCLCompilerTool"
188.3626 -						UsePrecompiledHeader="2"
188.3627 -					/>
188.3628 -				</FileConfiguration>
188.3629 -			</File>
188.3630 -			<File
188.3631 -				RelativePath=".\CPP\7zip\Crypto\Pbkdf2HmacSha1.cpp"
188.3632 -				>
188.3633 -				<FileConfiguration
188.3634 -					Name="Release|Win32"
188.3635 -					>
188.3636 -					<Tool
188.3637 -						Name="VCCLCompilerTool"
188.3638 -						UsePrecompiledHeader="2"
188.3639 -					/>
188.3640 -				</FileConfiguration>
188.3641 -				<FileConfiguration
188.3642 -					Name="Debug|Win32"
188.3643 -					>
188.3644 -					<Tool
188.3645 -						Name="VCCLCompilerTool"
188.3646 -						UsePrecompiledHeader="2"
188.3647 -					/>
188.3648 -				</FileConfiguration>
188.3649 -				<FileConfiguration
188.3650 -					Name="Release FastBuild|Win32"
188.3651 -					>
188.3652 -					<Tool
188.3653 -						Name="VCCLCompilerTool"
188.3654 -						UsePrecompiledHeader="2"
188.3655 -					/>
188.3656 -				</FileConfiguration>
188.3657 -			</File>
188.3658 -			<File
188.3659 -				RelativePath=".\CPP\7zip\Crypto\RandGen.cpp"
188.3660 -				>
188.3661 -				<FileConfiguration
188.3662 -					Name="Release|Win32"
188.3663 -					>
188.3664 -					<Tool
188.3665 -						Name="VCCLCompilerTool"
188.3666 -						UsePrecompiledHeader="2"
188.3667 -					/>
188.3668 -				</FileConfiguration>
188.3669 -				<FileConfiguration
188.3670 -					Name="Debug|Win32"
188.3671 -					>
188.3672 -					<Tool
188.3673 -						Name="VCCLCompilerTool"
188.3674 -						UsePrecompiledHeader="2"
188.3675 -					/>
188.3676 -				</FileConfiguration>
188.3677 -				<FileConfiguration
188.3678 -					Name="Release FastBuild|Win32"
188.3679 -					>
188.3680 -					<Tool
188.3681 -						Name="VCCLCompilerTool"
188.3682 -						UsePrecompiledHeader="2"
188.3683 -					/>
188.3684 -				</FileConfiguration>
188.3685 -			</File>
188.3686 -			<File
188.3687 -				RelativePath=".\CPP\7zip\Crypto\Rar20Crypto.cpp"
188.3688 -				>
188.3689 -				<FileConfiguration
188.3690 -					Name="Release|Win32"
188.3691 -					>
188.3692 -					<Tool
188.3693 -						Name="VCCLCompilerTool"
188.3694 -						UsePrecompiledHeader="2"
188.3695 -					/>
188.3696 -				</FileConfiguration>
188.3697 -				<FileConfiguration
188.3698 -					Name="Debug|Win32"
188.3699 -					>
188.3700 -					<Tool
188.3701 -						Name="VCCLCompilerTool"
188.3702 -						UsePrecompiledHeader="2"
188.3703 -					/>
188.3704 -				</FileConfiguration>
188.3705 -				<FileConfiguration
188.3706 -					Name="Release FastBuild|Win32"
188.3707 -					>
188.3708 -					<Tool
188.3709 -						Name="VCCLCompilerTool"
188.3710 -						UsePrecompiledHeader="2"
188.3711 -					/>
188.3712 -				</FileConfiguration>
188.3713 -			</File>
188.3714 -			<File
188.3715 -				RelativePath=".\CPP\7zip\Crypto\RarAes.cpp"
188.3716 -				>
188.3717 -				<FileConfiguration
188.3718 -					Name="Release|Win32"
188.3719 -					>
188.3720 -					<Tool
188.3721 -						Name="VCCLCompilerTool"
188.3722 -						UsePrecompiledHeader="2"
188.3723 -					/>
188.3724 -				</FileConfiguration>
188.3725 -				<FileConfiguration
188.3726 -					Name="Debug|Win32"
188.3727 -					>
188.3728 -					<Tool
188.3729 -						Name="VCCLCompilerTool"
188.3730 -						UsePrecompiledHeader="2"
188.3731 -					/>
188.3732 -				</FileConfiguration>
188.3733 -				<FileConfiguration
188.3734 -					Name="Release FastBuild|Win32"
188.3735 -					>
188.3736 -					<Tool
188.3737 -						Name="VCCLCompilerTool"
188.3738 -						UsePrecompiledHeader="2"
188.3739 -					/>
188.3740 -				</FileConfiguration>
188.3741 -			</File>
188.3742 -			<File
188.3743 -				RelativePath=".\CPP\7zip\Crypto\Sha1.cpp"
188.3744 -				>
188.3745 -				<FileConfiguration
188.3746 -					Name="Release|Win32"
188.3747 -					>
188.3748 -					<Tool
188.3749 -						Name="VCCLCompilerTool"
188.3750 -						UsePrecompiledHeader="2"
188.3751 -					/>
188.3752 -				</FileConfiguration>
188.3753 -				<FileConfiguration
188.3754 -					Name="Debug|Win32"
188.3755 -					>
188.3756 -					<Tool
188.3757 -						Name="VCCLCompilerTool"
188.3758 -						UsePrecompiledHeader="2"
188.3759 -					/>
188.3760 -				</FileConfiguration>
188.3761 -				<FileConfiguration
188.3762 -					Name="Release FastBuild|Win32"
188.3763 -					>
188.3764 -					<Tool
188.3765 -						Name="VCCLCompilerTool"
188.3766 -						UsePrecompiledHeader="2"
188.3767 -					/>
188.3768 -				</FileConfiguration>
188.3769 -			</File>
188.3770 -			<File
188.3771 -				RelativePath=".\CPP\7zip\Crypto\WzAes.cpp"
188.3772 -				>
188.3773 -				<FileConfiguration
188.3774 -					Name="Release|Win32"
188.3775 -					>
188.3776 -					<Tool
188.3777 -						Name="VCCLCompilerTool"
188.3778 -						UsePrecompiledHeader="2"
188.3779 -					/>
188.3780 -				</FileConfiguration>
188.3781 -				<FileConfiguration
188.3782 -					Name="Debug|Win32"
188.3783 -					>
188.3784 -					<Tool
188.3785 -						Name="VCCLCompilerTool"
188.3786 -						UsePrecompiledHeader="2"
188.3787 -					/>
188.3788 -				</FileConfiguration>
188.3789 -				<FileConfiguration
188.3790 -					Name="Release FastBuild|Win32"
188.3791 -					>
188.3792 -					<Tool
188.3793 -						Name="VCCLCompilerTool"
188.3794 -						UsePrecompiledHeader="2"
188.3795 -					/>
188.3796 -				</FileConfiguration>
188.3797 -			</File>
188.3798 -			<File
188.3799 -				RelativePath=".\CPP\7zip\Crypto\ZipCrypto.cpp"
188.3800 -				>
188.3801 -				<FileConfiguration
188.3802 -					Name="Release|Win32"
188.3803 -					>
188.3804 -					<Tool
188.3805 -						Name="VCCLCompilerTool"
188.3806 -						UsePrecompiledHeader="2"
188.3807 -					/>
188.3808 -				</FileConfiguration>
188.3809 -				<FileConfiguration
188.3810 -					Name="Debug|Win32"
188.3811 -					>
188.3812 -					<Tool
188.3813 -						Name="VCCLCompilerTool"
188.3814 -						UsePrecompiledHeader="2"
188.3815 -					/>
188.3816 -				</FileConfiguration>
188.3817 -				<FileConfiguration
188.3818 -					Name="Release FastBuild|Win32"
188.3819 -					>
188.3820 -					<Tool
188.3821 -						Name="VCCLCompilerTool"
188.3822 -						UsePrecompiledHeader="2"
188.3823 -					/>
188.3824 -				</FileConfiguration>
188.3825 -			</File>
188.3826 -			<File
188.3827 -				RelativePath=".\CPP\7zip\Crypto\ZipStrong.cpp"
188.3828 -				>
188.3829 -				<FileConfiguration
188.3830 -					Name="Release|Win32"
188.3831 -					>
188.3832 -					<Tool
188.3833 -						Name="VCCLCompilerTool"
188.3834 -						UsePrecompiledHeader="2"
188.3835 -					/>
188.3836 -				</FileConfiguration>
188.3837 -				<FileConfiguration
188.3838 -					Name="Debug|Win32"
188.3839 -					>
188.3840 -					<Tool
188.3841 -						Name="VCCLCompilerTool"
188.3842 -						UsePrecompiledHeader="2"
188.3843 -					/>
188.3844 -				</FileConfiguration>
188.3845 -				<FileConfiguration
188.3846 -					Name="Release FastBuild|Win32"
188.3847 -					>
188.3848 -					<Tool
188.3849 -						Name="VCCLCompilerTool"
188.3850 -						UsePrecompiledHeader="2"
188.3851 -					/>
188.3852 -				</FileConfiguration>
188.3853 -			</File>
188.3854 -		</Filter>
188.3855 -		<Filter
188.3856 -			Name="Headers"
188.3857 -			>
188.3858 -			<File
188.3859 -				RelativePath=".\CPP\7zip\Crypto\7zAes.h"
188.3860 -				>
188.3861 -			</File>
188.3862 -			<File
188.3863 -				RelativePath=".\CPP\7zip\Archive\7z\7zCompressionMode.h"
188.3864 -				>
188.3865 -			</File>
188.3866 -			<File
188.3867 -				RelativePath=".\C\7zCrc.h"
188.3868 -				>
188.3869 -			</File>
188.3870 -			<File
188.3871 -				RelativePath=".\CPP\7zip\Archive\7z\7zDecode.h"
188.3872 -				>
188.3873 -			</File>
188.3874 -			<File
188.3875 -				RelativePath=".\CPP\7zip\Archive\7z\7zFolderInStream.h"
188.3876 -				>
188.3877 -			</File>
188.3878 -			<File
188.3879 -				RelativePath=".\CPP\7zip\Archive\7z\7zFolderOutStream.h"
188.3880 -				>
188.3881 -			</File>
188.3882 -			<File
188.3883 -				RelativePath=".\CPP\7zip\Archive\7z\7zHandler.h"
188.3884 -				>
188.3885 -			</File>
188.3886 -			<File
188.3887 -				RelativePath=".\CPP\7zip\Archive\7z\7zHeader.h"
188.3888 -				>
188.3889 -			</File>
188.3890 -			<File
188.3891 -				RelativePath=".\CPP\7zip\Archive\7z\7zIn.h"
188.3892 -				>
188.3893 -			</File>
188.3894 -			<File
188.3895 -				RelativePath=".\CPP\7zip\Archive\7z\7zItem.h"
188.3896 -				>
188.3897 -			</File>
188.3898 -			<File
188.3899 -				RelativePath=".\CPP\7zip\Archive\7z\7zProperties.h"
188.3900 -				>
188.3901 -			</File>
188.3902 -			<File
188.3903 -				RelativePath=".\CPP\7zip\Archive\7z\7zSpecStream.h"
188.3904 -				>
188.3905 -			</File>
188.3906 -			<File
188.3907 -				RelativePath=".\C\Aes.h"
188.3908 -				>
188.3909 -			</File>
188.3910 -			<File
188.3911 -				RelativePath=".\C\Alloc.h"
188.3912 -				>
188.3913 -			</File>
188.3914 -			<File
188.3915 -				RelativePath=".\CPP\7zip\Compress\Bcj2Coder.h"
188.3916 -				>
188.3917 -			</File>
188.3918 -			<File
188.3919 -				RelativePath=".\CPP\7zip\Compress\BcjCoder.h"
188.3920 -				>
188.3921 -			</File>
188.3922 -			<File
188.3923 -				RelativePath=".\CPP\7zip\Compress\BitlDecoder.h"
188.3924 -				>
188.3925 -			</File>
188.3926 -			<File
188.3927 -				RelativePath=".\CPP\7zip\Compress\BitmDecoder.h"
188.3928 -				>
188.3929 -			</File>
188.3930 -			<File
188.3931 -				RelativePath=".\C\Bra.h"
188.3932 -				>
188.3933 -			</File>
188.3934 -			<File
188.3935 -				RelativePath=".\CPP\7zip\Compress\BranchCoder.h"
188.3936 -				>
188.3937 -			</File>
188.3938 -			<File
188.3939 -				RelativePath=".\CPP\7zip\Compress\BranchMisc.h"
188.3940 -				>
188.3941 -			</File>
188.3942 -			<File
188.3943 -				RelativePath=".\CPP\Common\Buffer.h"
188.3944 -				>
188.3945 -			</File>
188.3946 -			<File
188.3947 -				RelativePath=".\C\BwtSort.h"
188.3948 -				>
188.3949 -			</File>
188.3950 -			<File
188.3951 -				RelativePath=".\CPP\7zip\Compress\ByteSwap.h"
188.3952 -				>
188.3953 -			</File>
188.3954 -			<File
188.3955 -				RelativePath=".\CPP\7zip\Compress\BZip2Const.h"
188.3956 -				>
188.3957 -			</File>
188.3958 -			<File
188.3959 -				RelativePath=".\CPP\7zip\Compress\BZip2Crc.h"
188.3960 -				>
188.3961 -			</File>
188.3962 -			<File
188.3963 -				RelativePath=".\CPP\7zip\Compress\BZip2Decoder.h"
188.3964 -				>
188.3965 -			</File>
188.3966 -			<File
188.3967 -				RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Handler.h"
188.3968 -				>
188.3969 -			</File>
188.3970 -			<File
188.3971 -				RelativePath=".\CPP\7zip\Archive\BZip2\BZip2Item.h"
188.3972 -				>
188.3973 -			</File>
188.3974 -			<File
188.3975 -				RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2.h"
188.3976 -				>
188.3977 -			</File>
188.3978 -			<File
188.3979 -				RelativePath=".\CPP\7zip\Archive\Common\CoderMixer2MT.h"
188.3980 -				>
188.3981 -			</File>
188.3982 -			<File
188.3983 -				RelativePath=".\CPP\Common\ComTry.h"
188.3984 -				>
188.3985 -			</File>
188.3986 -			<File
188.3987 -				RelativePath=".\CPP\7zip\Compress\CopyCoder.h"
188.3988 -				>
188.3989 -			</File>
188.3990 -			<File
188.3991 -				RelativePath=".\C\CpuArch.h"
188.3992 -				>
188.3993 -			</File>
188.3994 -			<File
188.3995 -				RelativePath=".\CPP\7zip\Common\CreateCoder.h"
188.3996 -				>
188.3997 -			</File>
188.3998 -			<File
188.3999 -				RelativePath=".\CPP\7zip\Common\DeclareArcs.h"
188.4000 -				>
188.4001 -			</File>
188.4002 -			<File
188.4003 -				RelativePath=".\CPP\7zip\Common\DeclareCodecs.h"
188.4004 -				>
188.4005 -			</File>
188.4006 -			<File
188.4007 -				RelativePath=".\CPP\7zip\Compress\DeflateConst.h"
188.4008 -				>
188.4009 -			</File>
188.4010 -			<File
188.4011 -				RelativePath=".\CPP\7zip\Compress\DeflateDecoder.h"
188.4012 -				>
188.4013 -			</File>
188.4014 -			<File
188.4015 -				RelativePath=".\CPP\Windows\Defs.h"
188.4016 -				>
188.4017 -			</File>
188.4018 -			<File
188.4019 -				RelativePath=".\CPP\Common\Defs.h"
188.4020 -				>
188.4021 -			</File>
188.4022 -			<File
188.4023 -				RelativePath=".\CPP\7zip\Archive\Common\DummyOutStream.h"
188.4024 -				>
188.4025 -			</File>
188.4026 -			<File
188.4027 -				RelativePath=".\CPP\Common\DynamicBuffer.h"
188.4028 -				>
188.4029 -			</File>
188.4030 -			<File
188.4031 -				RelativePath=".\CPP\Windows\FileDir.h"
188.4032 -				>
188.4033 -			</File>
188.4034 -			<File
188.4035 -				RelativePath=".\CPP\Windows\FileFind.h"
188.4036 -				>
188.4037 -			</File>
188.4038 -			<File
188.4039 -				RelativePath=".\CPP\Windows\FileIO.h"
188.4040 -				>
188.4041 -			</File>
188.4042 -			<File
188.4043 -				RelativePath=".\CPP\Windows\FileName.h"
188.4044 -				>
188.4045 -			</File>
188.4046 -			<File
188.4047 -				RelativePath=".\CPP\7zip\Common\FilterCoder.h"
188.4048 -				>
188.4049 -			</File>
188.4050 -			<File
188.4051 -				RelativePath=".\CPP\7zip\Archive\Common\FindSignature.h"
188.4052 -				>
188.4053 -			</File>
188.4054 -			<File
188.4055 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipHandler.h"
188.4056 -				>
188.4057 -			</File>
188.4058 -			<File
188.4059 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipHeader.h"
188.4060 -				>
188.4061 -			</File>
188.4062 -			<File
188.4063 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipIn.h"
188.4064 -				>
188.4065 -			</File>
188.4066 -			<File
188.4067 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipItem.h"
188.4068 -				>
188.4069 -			</File>
188.4070 -			<File
188.4071 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipUpdate.h"
188.4072 -				>
188.4073 -			</File>
188.4074 -			<File
188.4075 -				RelativePath=".\CPP\Windows\Handle.h"
188.4076 -				>
188.4077 -			</File>
188.4078 -			<File
188.4079 -				RelativePath=".\CPP\7zip\Crypto\HmacSha1.h"
188.4080 -				>
188.4081 -			</File>
188.4082 -			<File
188.4083 -				RelativePath=".\C\HuffEnc.h"
188.4084 -				>
188.4085 -			</File>
188.4086 -			<File
188.4087 -				RelativePath=".\CPP\7zip\Compress\HuffmanDecoder.h"
188.4088 -				>
188.4089 -			</File>
188.4090 -			<File
188.4091 -				RelativePath=".\CPP\7zip\Archive\IArchive.h"
188.4092 -				>
188.4093 -			</File>
188.4094 -			<File
188.4095 -				RelativePath=".\CPP\7zip\ICoder.h"
188.4096 -				>
188.4097 -			</File>
188.4098 -			<File
188.4099 -				RelativePath=".\CPP\7zip\IDecl.h"
188.4100 -				>
188.4101 -			</File>
188.4102 -			<File
188.4103 -				RelativePath=".\CPP\7zip\Compress\ImplodeDecoder.h"
188.4104 -				>
188.4105 -			</File>
188.4106 -			<File
188.4107 -				RelativePath=".\CPP\7zip\Compress\ImplodeHuffmanDecoder.h"
188.4108 -				>
188.4109 -			</File>
188.4110 -			<File
188.4111 -				RelativePath=".\CPP\7zip\Common\InBuffer.h"
188.4112 -				>
188.4113 -			</File>
188.4114 -			<File
188.4115 -				RelativePath=".\CPP\Common\InitializeStaticLib.h"
188.4116 -				>
188.4117 -			</File>
188.4118 -			<File
188.4119 -				RelativePath=".\CPP\7zip\Common\InOutTempBuffer.h"
188.4120 -				>
188.4121 -			</File>
188.4122 -			<File
188.4123 -				RelativePath=".\CPP\7zip\Archive\Common\InStreamWithCRC.h"
188.4124 -				>
188.4125 -			</File>
188.4126 -			<File
188.4127 -				RelativePath=".\CPP\Common\IntToString.h"
188.4128 -				>
188.4129 -			</File>
188.4130 -			<File
188.4131 -				RelativePath=".\CPP\7zip\IPassword.h"
188.4132 -				>
188.4133 -			</File>
188.4134 -			<File
188.4135 -				RelativePath=".\CPP\7zip\IProgress.h"
188.4136 -				>
188.4137 -			</File>
188.4138 -			<File
188.4139 -				RelativePath=".\CPP\7zip\IStream.h"
188.4140 -				>
188.4141 -			</File>
188.4142 -			<File
188.4143 -				RelativePath=".\CPP\7zip\Archive\Common\ItemNameUtils.h"
188.4144 -				>
188.4145 -			</File>
188.4146 -			<File
188.4147 -				RelativePath=".\CPP\7zip\Common\LimitedStreams.h"
188.4148 -				>
188.4149 -			</File>
188.4150 -			<File
188.4151 -				RelativePath=".\CPP\7zip\Common\LockedStream.h"
188.4152 -				>
188.4153 -			</File>
188.4154 -			<File
188.4155 -				RelativePath=".\C\LzFind.h"
188.4156 -				>
188.4157 -			</File>
188.4158 -			<File
188.4159 -				RelativePath=".\C\LzFindMt.h"
188.4160 -				>
188.4161 -			</File>
188.4162 -			<File
188.4163 -				RelativePath=".\C\LzHash.h"
188.4164 -				>
188.4165 -			</File>
188.4166 -			<File
188.4167 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhCRC.h"
188.4168 -				>
188.4169 -			</File>
188.4170 -			<File
188.4171 -				RelativePath=".\CPP\7zip\Compress\LzhDecoder.h"
188.4172 -				>
188.4173 -			</File>
188.4174 -			<File
188.4175 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhHandler.h"
188.4176 -				>
188.4177 -			</File>
188.4178 -			<File
188.4179 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhHeader.h"
188.4180 -				>
188.4181 -			</File>
188.4182 -			<File
188.4183 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhIn.h"
188.4184 -				>
188.4185 -			</File>
188.4186 -			<File
188.4187 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhItem.h"
188.4188 -				>
188.4189 -			</File>
188.4190 -			<File
188.4191 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.h"
188.4192 -				>
188.4193 -			</File>
188.4194 -			<File
188.4195 -				RelativePath=".\C\LzmaDec.h"
188.4196 -				>
188.4197 -			</File>
188.4198 -			<File
188.4199 -				RelativePath=".\CPP\7zip\Compress\LzmaDecoder.h"
188.4200 -				>
188.4201 -			</File>
188.4202 -			<File
188.4203 -				RelativePath=".\C\LzmaEnc.h"
188.4204 -				>
188.4205 -			</File>
188.4206 -			<File
188.4207 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaFiltersDecode.h"
188.4208 -				>
188.4209 -			</File>
188.4210 -			<File
188.4211 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaHandler.h"
188.4212 -				>
188.4213 -			</File>
188.4214 -			<File
188.4215 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaIn.h"
188.4216 -				>
188.4217 -			</File>
188.4218 -			<File
188.4219 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaItem.h"
188.4220 -				>
188.4221 -			</File>
188.4222 -			<File
188.4223 -				RelativePath=".\CPP\7zip\Compress\LzOutWindow.h"
188.4224 -				>
188.4225 -			</File>
188.4226 -			<File
188.4227 -				RelativePath=".\CPP\7zip\Common\MemBlocks.h"
188.4228 -				>
188.4229 -			</File>
188.4230 -			<File
188.4231 -				RelativePath=".\CPP\7zip\Common\MethodId.h"
188.4232 -				>
188.4233 -			</File>
188.4234 -			<File
188.4235 -				RelativePath=".\CPP\7zip\Common\MethodProps.h"
188.4236 -				>
188.4237 -			</File>
188.4238 -			<File
188.4239 -				RelativePath=".\CPP\7zip\Compress\Mtf8.h"
188.4240 -				>
188.4241 -			</File>
188.4242 -			<File
188.4243 -				RelativePath=".\CPP\7zip\Archive\Common\MultiStream.h"
188.4244 -				>
188.4245 -			</File>
188.4246 -			<File
188.4247 -				RelativePath=".\CPP\7zip\Crypto\MyAes.h"
188.4248 -				>
188.4249 -			</File>
188.4250 -			<File
188.4251 -				RelativePath=".\CPP\Common\MyCom.h"
188.4252 -				>
188.4253 -			</File>
188.4254 -			<File
188.4255 -				RelativePath=".\CPP\Common\MyException.h"
188.4256 -				>
188.4257 -			</File>
188.4258 -			<File
188.4259 -				RelativePath=".\CPP\Common\MyInitGuid.h"
188.4260 -				>
188.4261 -			</File>
188.4262 -			<File
188.4263 -				RelativePath=".\CPP\Common\MyMap.h"
188.4264 -				>
188.4265 -			</File>
188.4266 -			<File
188.4267 -				RelativePath=".\CPP\Common\MyString.h"
188.4268 -				>
188.4269 -			</File>
188.4270 -			<File
188.4271 -				RelativePath=".\CPP\Common\MyUnknown.h"
188.4272 -				>
188.4273 -			</File>
188.4274 -			<File
188.4275 -				RelativePath=".\CPP\Common\MyVector.h"
188.4276 -				>
188.4277 -			</File>
188.4278 -			<File
188.4279 -				RelativePath=".\CPP\Common\MyWindows.h"
188.4280 -				>
188.4281 -			</File>
188.4282 -			<File
188.4283 -				RelativePath=".\CPP\Common\MyXml.h"
188.4284 -				>
188.4285 -			</File>
188.4286 -			<File
188.4287 -				RelativePath=".\CPP\Common\NewHandler.h"
188.4288 -				>
188.4289 -			</File>
188.4290 -			<File
188.4291 -				RelativePath=".\CPP\7zip\Common\OffsetStream.h"
188.4292 -				>
188.4293 -			</File>
188.4294 -			<File
188.4295 -				RelativePath=".\CPP\7zip\Common\OutBuffer.h"
188.4296 -				>
188.4297 -			</File>
188.4298 -			<File
188.4299 -				RelativePath=".\CPP\7zip\Common\OutMemStream.h"
188.4300 -				>
188.4301 -			</File>
188.4302 -			<File
188.4303 -				RelativePath=".\CPP\7zip\Archive\Common\OutStreamWithCRC.h"
188.4304 -				>
188.4305 -			</File>
188.4306 -			<File
188.4307 -				RelativePath=".\CPP\7zip\Archive\Common\ParseProperties.h"
188.4308 -				>
188.4309 -			</File>
188.4310 -			<File
188.4311 -				RelativePath=".\CPP\7zip\Crypto\Pbkdf2HmacSha1.h"
188.4312 -				>
188.4313 -			</File>
188.4314 -			<File
188.4315 -				RelativePath=".\CPP\7zip\Compress\PpmdContext.h"
188.4316 -				>
188.4317 -			</File>
188.4318 -			<File
188.4319 -				RelativePath=".\CPP\7zip\Compress\PpmdDecode.h"
188.4320 -				>
188.4321 -			</File>
188.4322 -			<File
188.4323 -				RelativePath=".\CPP\7zip\Compress\PpmdDecoder.h"
188.4324 -				>
188.4325 -			</File>
188.4326 -			<File
188.4327 -				RelativePath=".\CPP\7zip\Compress\PpmdSubAlloc.h"
188.4328 -				>
188.4329 -			</File>
188.4330 -			<File
188.4331 -				RelativePath=".\CPP\7zip\Compress\PpmdType.h"
188.4332 -				>
188.4333 -			</File>
188.4334 -			<File
188.4335 -				RelativePath=".\CPP\7zip\Common\ProgressMt.h"
188.4336 -				>
188.4337 -			</File>
188.4338 -			<File
188.4339 -				RelativePath=".\CPP\7zip\Common\ProgressUtils.h"
188.4340 -				>
188.4341 -			</File>
188.4342 -			<File
188.4343 -				RelativePath=".\CPP\7zip\PropID.h"
188.4344 -				>
188.4345 -			</File>
188.4346 -			<File
188.4347 -				RelativePath=".\CPP\Windows\PropVariant.h"
188.4348 -				>
188.4349 -			</File>
188.4350 -			<File
188.4351 -				RelativePath=".\CPP\7zip\Crypto\RandGen.h"
188.4352 -				>
188.4353 -			</File>
188.4354 -			<File
188.4355 -				RelativePath=".\CPP\7zip\Compress\RangeCoder.h"
188.4356 -				>
188.4357 -			</File>
188.4358 -			<File
188.4359 -				RelativePath=".\CPP\7zip\Compress\RangeCoderBit.h"
188.4360 -				>
188.4361 -			</File>
188.4362 -			<File
188.4363 -				RelativePath=".\CPP\7zip\Compress\Rar1Decoder.h"
188.4364 -				>
188.4365 -			</File>
188.4366 -			<File
188.4367 -				RelativePath=".\CPP\7zip\Crypto\Rar20Crypto.h"
188.4368 -				>
188.4369 -			</File>
188.4370 -			<File
188.4371 -				RelativePath=".\CPP\7zip\Compress\Rar2Decoder.h"
188.4372 -				>
188.4373 -			</File>
188.4374 -			<File
188.4375 -				RelativePath=".\CPP\7zip\Compress\Rar3Decoder.h"
188.4376 -				>
188.4377 -			</File>
188.4378 -			<File
188.4379 -				RelativePath=".\CPP\7zip\Compress\Rar3Vm.h"
188.4380 -				>
188.4381 -			</File>
188.4382 -			<File
188.4383 -				RelativePath=".\CPP\7zip\Crypto\RarAes.h"
188.4384 -				>
188.4385 -			</File>
188.4386 -			<File
188.4387 -				RelativePath=".\CPP\7zip\Archive\Rar\RarHandler.h"
188.4388 -				>
188.4389 -			</File>
188.4390 -			<File
188.4391 -				RelativePath=".\CPP\7zip\Archive\Rar\RarHeader.h"
188.4392 -				>
188.4393 -			</File>
188.4394 -			<File
188.4395 -				RelativePath=".\CPP\7zip\Archive\Rar\RarIn.h"
188.4396 -				>
188.4397 -			</File>
188.4398 -			<File
188.4399 -				RelativePath=".\CPP\7zip\Archive\Rar\RarItem.h"
188.4400 -				>
188.4401 -			</File>
188.4402 -			<File
188.4403 -				RelativePath=".\CPP\7zip\Archive\Rar\RarVolumeInStream.h"
188.4404 -				>
188.4405 -			</File>
188.4406 -			<File
188.4407 -				RelativePath=".\CPP\7zip\Common\RegisterArc.h"
188.4408 -				>
188.4409 -			</File>
188.4410 -			<File
188.4411 -				RelativePath=".\CPP\7zip\Common\RegisterCodec.h"
188.4412 -				>
188.4413 -			</File>
188.4414 -			<File
188.4415 -				RelativePath=".\C\RotateDefs.h"
188.4416 -				>
188.4417 -			</File>
188.4418 -			<File
188.4419 -				RelativePath=".\CPP\7zip\Crypto\Sha1.h"
188.4420 -				>
188.4421 -			</File>
188.4422 -			<File
188.4423 -				RelativePath=".\C\Sha256.h"
188.4424 -				>
188.4425 -			</File>
188.4426 -			<File
188.4427 -				RelativePath=".\CPP\7zip\Compress\ShrinkDecoder.h"
188.4428 -				>
188.4429 -			</File>
188.4430 -			<File
188.4431 -				RelativePath=".\C\Sort.h"
188.4432 -				>
188.4433 -			</File>
188.4434 -			<File
188.4435 -				RelativePath=".\CPP\7zip\Archive\Split\SplitHandler.h"
188.4436 -				>
188.4437 -			</File>
188.4438 -			<File
188.4439 -				RelativePath=".\CPP\7zip\Archive\Common\StdAfx.h"
188.4440 -				>
188.4441 -			</File>
188.4442 -			<File
188.4443 -				RelativePath=".\CPP\7zip\Archive\Rar\StdAfx.h"
188.4444 -				>
188.4445 -			</File>
188.4446 -			<File
188.4447 -				RelativePath=".\CPP\7zip\Archive\BZip2\StdAfx.h"
188.4448 -				>
188.4449 -			</File>
188.4450 -			<File
188.4451 -				RelativePath=".\CPP\Windows\StdAfx.h"
188.4452 -				>
188.4453 -			</File>
188.4454 -			<File
188.4455 -				RelativePath=".\CPP\7zip\Archive\7z\StdAfx.h"
188.4456 -				>
188.4457 -			</File>
188.4458 -			<File
188.4459 -				RelativePath=".\CPP\7zip\Archive\StdAfx.h"
188.4460 -				>
188.4461 -			</File>
188.4462 -			<File
188.4463 -				RelativePath=".\CPP\7zip\Compress\StdAfx.h"
188.4464 -				>
188.4465 -			</File>
188.4466 -			<File
188.4467 -				RelativePath=".\CPP\7zip\Bundles\Format7zF\StdAfx.h"
188.4468 -				>
188.4469 -			</File>
188.4470 -			<File
188.4471 -				RelativePath=".\CPP\7zip\Archive\GZip\StdAfx.h"
188.4472 -				>
188.4473 -			</File>
188.4474 -			<File
188.4475 -				RelativePath=".\CPP\7zip\Crypto\StdAfx.h"
188.4476 -				>
188.4477 -			</File>
188.4478 -			<File
188.4479 -				RelativePath=".\CPP\7zip\Archive\Tar\StdAfx.h"
188.4480 -				>
188.4481 -			</File>
188.4482 -			<File
188.4483 -				RelativePath=".\CPP\7zip\Archive\Zip\StdAfx.h"
188.4484 -				>
188.4485 -			</File>
188.4486 -			<File
188.4487 -				RelativePath=".\CPP\7zip\Archive\Lzh\StdAfx.h"
188.4488 -				>
188.4489 -			</File>
188.4490 -			<File
188.4491 -				RelativePath=".\CPP\7zip\Common\StdAfx.h"
188.4492 -				>
188.4493 -			</File>
188.4494 -			<File
188.4495 -				RelativePath=".\CPP\7zip\Archive\Split\StdAfx.h"
188.4496 -				>
188.4497 -			</File>
188.4498 -			<File
188.4499 -				RelativePath=".\CPP\7zip\Archive\Lzma\StdAfx.h"
188.4500 -				>
188.4501 -			</File>
188.4502 -			<File
188.4503 -				RelativePath=".\CPP\7zip\Common\StreamBinder.h"
188.4504 -				>
188.4505 -			</File>
188.4506 -			<File
188.4507 -				RelativePath=".\CPP\7zip\Common\StreamObjects.h"
188.4508 -				>
188.4509 -			</File>
188.4510 -			<File
188.4511 -				RelativePath=".\CPP\7zip\Common\StreamUtils.h"
188.4512 -				>
188.4513 -			</File>
188.4514 -			<File
188.4515 -				RelativePath=".\CPP\Common\StringConvert.h"
188.4516 -				>
188.4517 -			</File>
188.4518 -			<File
188.4519 -				RelativePath=".\CPP\Common\StringToInt.h"
188.4520 -				>
188.4521 -			</File>
188.4522 -			<File
188.4523 -				RelativePath=".\CPP\Windows\Synchronization.h"
188.4524 -				>
188.4525 -			</File>
188.4526 -			<File
188.4527 -				RelativePath=".\CPP\7zip\Archive\Tar\TarHandler.h"
188.4528 -				>
188.4529 -			</File>
188.4530 -			<File
188.4531 -				RelativePath=".\CPP\7zip\Archive\Tar\TarHeader.h"
188.4532 -				>
188.4533 -			</File>
188.4534 -			<File
188.4535 -				RelativePath=".\CPP\7zip\Archive\Tar\TarIn.h"
188.4536 -				>
188.4537 -			</File>
188.4538 -			<File
188.4539 -				RelativePath=".\CPP\7zip\Archive\Tar\TarItem.h"
188.4540 -				>
188.4541 -			</File>
188.4542 -			<File
188.4543 -				RelativePath=".\CPP\Windows\Thread.h"
188.4544 -				>
188.4545 -			</File>
188.4546 -			<File
188.4547 -				RelativePath=".\C\Threads.h"
188.4548 -				>
188.4549 -			</File>
188.4550 -			<File
188.4551 -				RelativePath=".\CPP\Windows\Time.h"
188.4552 -				>
188.4553 -			</File>
188.4554 -			<File
188.4555 -				RelativePath=".\CPP\Common\Types.h"
188.4556 -				>
188.4557 -			</File>
188.4558 -			<File
188.4559 -				RelativePath=".\C\Types.h"
188.4560 -				>
188.4561 -			</File>
188.4562 -			<File
188.4563 -				RelativePath=".\CPP\Common\UTFConvert.h"
188.4564 -				>
188.4565 -			</File>
188.4566 -			<File
188.4567 -				RelativePath=".\CPP\7zip\Common\VirtThread.h"
188.4568 -				>
188.4569 -			</File>
188.4570 -			<File
188.4571 -				RelativePath=".\CPP\Common\Wildcard.h"
188.4572 -				>
188.4573 -			</File>
188.4574 -			<File
188.4575 -				RelativePath=".\CPP\7zip\Crypto\WzAes.h"
188.4576 -				>
188.4577 -			</File>
188.4578 -			<File
188.4579 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipCompressionMode.h"
188.4580 -				>
188.4581 -			</File>
188.4582 -			<File
188.4583 -				RelativePath=".\CPP\7zip\Crypto\ZipCrypto.h"
188.4584 -				>
188.4585 -			</File>
188.4586 -			<File
188.4587 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipHandler.h"
188.4588 -				>
188.4589 -			</File>
188.4590 -			<File
188.4591 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipHeader.h"
188.4592 -				>
188.4593 -			</File>
188.4594 -			<File
188.4595 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipIn.h"
188.4596 -				>
188.4597 -			</File>
188.4598 -			<File
188.4599 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipItem.h"
188.4600 -				>
188.4601 -			</File>
188.4602 -			<File
188.4603 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipItemEx.h"
188.4604 -				>
188.4605 -			</File>
188.4606 -			<File
188.4607 -				RelativePath=".\CPP\7zip\Crypto\ZipStrong.h"
188.4608 -				>
188.4609 -			</File>
188.4610 -			<File
188.4611 -				RelativePath=".\CPP\7zip\Compress\ZlibDecoder.h"
188.4612 -				>
188.4613 -			</File>
188.4614 -		</Filter>
188.4615 -		<Filter
188.4616 -			Name="Register"
188.4617 -			>
188.4618 -			<File
188.4619 -				RelativePath=".\CPP\7zip\Crypto\7zAesRegister.cpp"
188.4620 -				>
188.4621 -				<FileConfiguration
188.4622 -					Name="Release|Win32"
188.4623 -					>
188.4624 -					<Tool
188.4625 -						Name="VCCLCompilerTool"
188.4626 -						UsePrecompiledHeader="2"
188.4627 -					/>
188.4628 -				</FileConfiguration>
188.4629 -				<FileConfiguration
188.4630 -					Name="Debug|Win32"
188.4631 -					>
188.4632 -					<Tool
188.4633 -						Name="VCCLCompilerTool"
188.4634 -						UsePrecompiledHeader="2"
188.4635 -					/>
188.4636 -				</FileConfiguration>
188.4637 -				<FileConfiguration
188.4638 -					Name="Release FastBuild|Win32"
188.4639 -					>
188.4640 -					<Tool
188.4641 -						Name="VCCLCompilerTool"
188.4642 -						UsePrecompiledHeader="2"
188.4643 -					/>
188.4644 -				</FileConfiguration>
188.4645 -			</File>
188.4646 -			<File
188.4647 -				RelativePath=".\CPP\7zip\Archive\7z\7zRegister.cpp"
188.4648 -				>
188.4649 -				<FileConfiguration
188.4650 -					Name="Release|Win32"
188.4651 -					>
188.4652 -					<Tool
188.4653 -						Name="VCCLCompilerTool"
188.4654 -						UsePrecompiledHeader="2"
188.4655 -					/>
188.4656 -				</FileConfiguration>
188.4657 -				<FileConfiguration
188.4658 -					Name="Debug|Win32"
188.4659 -					>
188.4660 -					<Tool
188.4661 -						Name="VCCLCompilerTool"
188.4662 -						UsePrecompiledHeader="2"
188.4663 -					/>
188.4664 -				</FileConfiguration>
188.4665 -				<FileConfiguration
188.4666 -					Name="Release FastBuild|Win32"
188.4667 -					>
188.4668 -					<Tool
188.4669 -						Name="VCCLCompilerTool"
188.4670 -						UsePrecompiledHeader="2"
188.4671 -					/>
188.4672 -				</FileConfiguration>
188.4673 -			</File>
188.4674 -			<File
188.4675 -				RelativePath=".\CPP\7zip\Archive\ArchiveExports.cpp"
188.4676 -				>
188.4677 -				<FileConfiguration
188.4678 -					Name="Release|Win32"
188.4679 -					>
188.4680 -					<Tool
188.4681 -						Name="VCCLCompilerTool"
188.4682 -						UsePrecompiledHeader="1"
188.4683 -					/>
188.4684 -				</FileConfiguration>
188.4685 -				<FileConfiguration
188.4686 -					Name="Debug|Win32"
188.4687 -					>
188.4688 -					<Tool
188.4689 -						Name="VCCLCompilerTool"
188.4690 -						UsePrecompiledHeader="1"
188.4691 -					/>
188.4692 -				</FileConfiguration>
188.4693 -				<FileConfiguration
188.4694 -					Name="Release FastBuild|Win32"
188.4695 -					>
188.4696 -					<Tool
188.4697 -						Name="VCCLCompilerTool"
188.4698 -						UsePrecompiledHeader="1"
188.4699 -					/>
188.4700 -				</FileConfiguration>
188.4701 -			</File>
188.4702 -			<File
188.4703 -				RelativePath=".\CPP\7zip\Compress\Bcj2Register.cpp"
188.4704 -				>
188.4705 -				<FileConfiguration
188.4706 -					Name="Release|Win32"
188.4707 -					>
188.4708 -					<Tool
188.4709 -						Name="VCCLCompilerTool"
188.4710 -						UsePrecompiledHeader="2"
188.4711 -					/>
188.4712 -				</FileConfiguration>
188.4713 -				<FileConfiguration
188.4714 -					Name="Debug|Win32"
188.4715 -					>
188.4716 -					<Tool
188.4717 -						Name="VCCLCompilerTool"
188.4718 -						UsePrecompiledHeader="2"
188.4719 -					/>
188.4720 -				</FileConfiguration>
188.4721 -				<FileConfiguration
188.4722 -					Name="Release FastBuild|Win32"
188.4723 -					>
188.4724 -					<Tool
188.4725 -						Name="VCCLCompilerTool"
188.4726 -						UsePrecompiledHeader="2"
188.4727 -					/>
188.4728 -				</FileConfiguration>
188.4729 -			</File>
188.4730 -			<File
188.4731 -				RelativePath=".\CPP\7zip\Compress\BcjRegister.cpp"
188.4732 -				>
188.4733 -				<FileConfiguration
188.4734 -					Name="Release|Win32"
188.4735 -					>
188.4736 -					<Tool
188.4737 -						Name="VCCLCompilerTool"
188.4738 -						UsePrecompiledHeader="2"
188.4739 -					/>
188.4740 -				</FileConfiguration>
188.4741 -				<FileConfiguration
188.4742 -					Name="Debug|Win32"
188.4743 -					>
188.4744 -					<Tool
188.4745 -						Name="VCCLCompilerTool"
188.4746 -						UsePrecompiledHeader="2"
188.4747 -					/>
188.4748 -				</FileConfiguration>
188.4749 -				<FileConfiguration
188.4750 -					Name="Release FastBuild|Win32"
188.4751 -					>
188.4752 -					<Tool
188.4753 -						Name="VCCLCompilerTool"
188.4754 -						UsePrecompiledHeader="2"
188.4755 -					/>
188.4756 -				</FileConfiguration>
188.4757 -			</File>
188.4758 -			<File
188.4759 -				RelativePath=".\CPP\7zip\Compress\BranchRegister.cpp"
188.4760 -				>
188.4761 -				<FileConfiguration
188.4762 -					Name="Release|Win32"
188.4763 -					>
188.4764 -					<Tool
188.4765 -						Name="VCCLCompilerTool"
188.4766 -						UsePrecompiledHeader="2"
188.4767 -					/>
188.4768 -				</FileConfiguration>
188.4769 -				<FileConfiguration
188.4770 -					Name="Debug|Win32"
188.4771 -					>
188.4772 -					<Tool
188.4773 -						Name="VCCLCompilerTool"
188.4774 -						UsePrecompiledHeader="2"
188.4775 -					/>
188.4776 -				</FileConfiguration>
188.4777 -				<FileConfiguration
188.4778 -					Name="Release FastBuild|Win32"
188.4779 -					>
188.4780 -					<Tool
188.4781 -						Name="VCCLCompilerTool"
188.4782 -						UsePrecompiledHeader="2"
188.4783 -					/>
188.4784 -				</FileConfiguration>
188.4785 -			</File>
188.4786 -			<File
188.4787 -				RelativePath=".\CPP\7zip\Compress\ByteSwapRegister.cpp"
188.4788 -				>
188.4789 -				<FileConfiguration
188.4790 -					Name="Release|Win32"
188.4791 -					>
188.4792 -					<Tool
188.4793 -						Name="VCCLCompilerTool"
188.4794 -						UsePrecompiledHeader="2"
188.4795 -					/>
188.4796 -				</FileConfiguration>
188.4797 -				<FileConfiguration
188.4798 -					Name="Debug|Win32"
188.4799 -					>
188.4800 -					<Tool
188.4801 -						Name="VCCLCompilerTool"
188.4802 -						UsePrecompiledHeader="2"
188.4803 -					/>
188.4804 -				</FileConfiguration>
188.4805 -				<FileConfiguration
188.4806 -					Name="Release FastBuild|Win32"
188.4807 -					>
188.4808 -					<Tool
188.4809 -						Name="VCCLCompilerTool"
188.4810 -						UsePrecompiledHeader="2"
188.4811 -					/>
188.4812 -				</FileConfiguration>
188.4813 -			</File>
188.4814 -			<File
188.4815 -				RelativePath=".\CPP\7zip\Archive\BZip2\bz2Register.cpp"
188.4816 -				>
188.4817 -				<FileConfiguration
188.4818 -					Name="Release|Win32"
188.4819 -					>
188.4820 -					<Tool
188.4821 -						Name="VCCLCompilerTool"
188.4822 -						UsePrecompiledHeader="2"
188.4823 -					/>
188.4824 -				</FileConfiguration>
188.4825 -				<FileConfiguration
188.4826 -					Name="Debug|Win32"
188.4827 -					>
188.4828 -					<Tool
188.4829 -						Name="VCCLCompilerTool"
188.4830 -						UsePrecompiledHeader="2"
188.4831 -					/>
188.4832 -				</FileConfiguration>
188.4833 -				<FileConfiguration
188.4834 -					Name="Release FastBuild|Win32"
188.4835 -					>
188.4836 -					<Tool
188.4837 -						Name="VCCLCompilerTool"
188.4838 -						UsePrecompiledHeader="2"
188.4839 -					/>
188.4840 -				</FileConfiguration>
188.4841 -			</File>
188.4842 -			<File
188.4843 -				RelativePath=".\CPP\7zip\Compress\BZip2Register.cpp"
188.4844 -				>
188.4845 -				<FileConfiguration
188.4846 -					Name="Release|Win32"
188.4847 -					>
188.4848 -					<Tool
188.4849 -						Name="VCCLCompilerTool"
188.4850 -						UsePrecompiledHeader="2"
188.4851 -					/>
188.4852 -				</FileConfiguration>
188.4853 -				<FileConfiguration
188.4854 -					Name="Debug|Win32"
188.4855 -					>
188.4856 -					<Tool
188.4857 -						Name="VCCLCompilerTool"
188.4858 -						UsePrecompiledHeader="2"
188.4859 -					/>
188.4860 -				</FileConfiguration>
188.4861 -				<FileConfiguration
188.4862 -					Name="Release FastBuild|Win32"
188.4863 -					>
188.4864 -					<Tool
188.4865 -						Name="VCCLCompilerTool"
188.4866 -						UsePrecompiledHeader="2"
188.4867 -					/>
188.4868 -				</FileConfiguration>
188.4869 -			</File>
188.4870 -			<File
188.4871 -				RelativePath=".\CPP\7zip\Compress\CodecExports.cpp"
188.4872 -				>
188.4873 -				<FileConfiguration
188.4874 -					Name="Release|Win32"
188.4875 -					>
188.4876 -					<Tool
188.4877 -						Name="VCCLCompilerTool"
188.4878 -						UsePrecompiledHeader="2"
188.4879 -					/>
188.4880 -				</FileConfiguration>
188.4881 -				<FileConfiguration
188.4882 -					Name="Debug|Win32"
188.4883 -					>
188.4884 -					<Tool
188.4885 -						Name="VCCLCompilerTool"
188.4886 -						UsePrecompiledHeader="2"
188.4887 -					/>
188.4888 -				</FileConfiguration>
188.4889 -				<FileConfiguration
188.4890 -					Name="Release FastBuild|Win32"
188.4891 -					>
188.4892 -					<Tool
188.4893 -						Name="VCCLCompilerTool"
188.4894 -						UsePrecompiledHeader="2"
188.4895 -					/>
188.4896 -				</FileConfiguration>
188.4897 -			</File>
188.4898 -			<File
188.4899 -				RelativePath=".\CPP\7zip\Compress\CopyRegister.cpp"
188.4900 -				>
188.4901 -				<FileConfiguration
188.4902 -					Name="Release|Win32"
188.4903 -					>
188.4904 -					<Tool
188.4905 -						Name="VCCLCompilerTool"
188.4906 -						UsePrecompiledHeader="2"
188.4907 -					/>
188.4908 -				</FileConfiguration>
188.4909 -				<FileConfiguration
188.4910 -					Name="Debug|Win32"
188.4911 -					>
188.4912 -					<Tool
188.4913 -						Name="VCCLCompilerTool"
188.4914 -						UsePrecompiledHeader="2"
188.4915 -					/>
188.4916 -				</FileConfiguration>
188.4917 -				<FileConfiguration
188.4918 -					Name="Release FastBuild|Win32"
188.4919 -					>
188.4920 -					<Tool
188.4921 -						Name="VCCLCompilerTool"
188.4922 -						UsePrecompiledHeader="2"
188.4923 -					/>
188.4924 -				</FileConfiguration>
188.4925 -			</File>
188.4926 -			<File
188.4927 -				RelativePath=".\CPP\7zip\Common\CreateCoder.cpp"
188.4928 -				>
188.4929 -				<FileConfiguration
188.4930 -					Name="Release|Win32"
188.4931 -					>
188.4932 -					<Tool
188.4933 -						Name="VCCLCompilerTool"
188.4934 -						UsePrecompiledHeader="2"
188.4935 -					/>
188.4936 -				</FileConfiguration>
188.4937 -				<FileConfiguration
188.4938 -					Name="Debug|Win32"
188.4939 -					>
188.4940 -					<Tool
188.4941 -						Name="VCCLCompilerTool"
188.4942 -						UsePrecompiledHeader="2"
188.4943 -					/>
188.4944 -				</FileConfiguration>
188.4945 -				<FileConfiguration
188.4946 -					Name="Release FastBuild|Win32"
188.4947 -					>
188.4948 -					<Tool
188.4949 -						Name="VCCLCompilerTool"
188.4950 -						UsePrecompiledHeader="2"
188.4951 -					/>
188.4952 -				</FileConfiguration>
188.4953 -			</File>
188.4954 -			<File
188.4955 -				RelativePath=".\CPP\7zip\Compress\Deflate64Register.cpp"
188.4956 -				>
188.4957 -				<FileConfiguration
188.4958 -					Name="Release|Win32"
188.4959 -					>
188.4960 -					<Tool
188.4961 -						Name="VCCLCompilerTool"
188.4962 -						UsePrecompiledHeader="2"
188.4963 -					/>
188.4964 -				</FileConfiguration>
188.4965 -				<FileConfiguration
188.4966 -					Name="Debug|Win32"
188.4967 -					>
188.4968 -					<Tool
188.4969 -						Name="VCCLCompilerTool"
188.4970 -						UsePrecompiledHeader="2"
188.4971 -					/>
188.4972 -				</FileConfiguration>
188.4973 -				<FileConfiguration
188.4974 -					Name="Release FastBuild|Win32"
188.4975 -					>
188.4976 -					<Tool
188.4977 -						Name="VCCLCompilerTool"
188.4978 -						UsePrecompiledHeader="2"
188.4979 -					/>
188.4980 -				</FileConfiguration>
188.4981 -			</File>
188.4982 -			<File
188.4983 -				RelativePath=".\CPP\7zip\Compress\DeflateNsisRegister.cpp"
188.4984 -				>
188.4985 -				<FileConfiguration
188.4986 -					Name="Release|Win32"
188.4987 -					>
188.4988 -					<Tool
188.4989 -						Name="VCCLCompilerTool"
188.4990 -						UsePrecompiledHeader="2"
188.4991 -					/>
188.4992 -				</FileConfiguration>
188.4993 -				<FileConfiguration
188.4994 -					Name="Debug|Win32"
188.4995 -					>
188.4996 -					<Tool
188.4997 -						Name="VCCLCompilerTool"
188.4998 -						UsePrecompiledHeader="2"
188.4999 -					/>
188.5000 -				</FileConfiguration>
188.5001 -				<FileConfiguration
188.5002 -					Name="Release FastBuild|Win32"
188.5003 -					>
188.5004 -					<Tool
188.5005 -						Name="VCCLCompilerTool"
188.5006 -						UsePrecompiledHeader="2"
188.5007 -					/>
188.5008 -				</FileConfiguration>
188.5009 -			</File>
188.5010 -			<File
188.5011 -				RelativePath=".\CPP\7zip\Compress\DeflateRegister.cpp"
188.5012 -				>
188.5013 -				<FileConfiguration
188.5014 -					Name="Release|Win32"
188.5015 -					>
188.5016 -					<Tool
188.5017 -						Name="VCCLCompilerTool"
188.5018 -						UsePrecompiledHeader="2"
188.5019 -					/>
188.5020 -				</FileConfiguration>
188.5021 -				<FileConfiguration
188.5022 -					Name="Debug|Win32"
188.5023 -					>
188.5024 -					<Tool
188.5025 -						Name="VCCLCompilerTool"
188.5026 -						UsePrecompiledHeader="2"
188.5027 -					/>
188.5028 -				</FileConfiguration>
188.5029 -				<FileConfiguration
188.5030 -					Name="Release FastBuild|Win32"
188.5031 -					>
188.5032 -					<Tool
188.5033 -						Name="VCCLCompilerTool"
188.5034 -						UsePrecompiledHeader="2"
188.5035 -					/>
188.5036 -				</FileConfiguration>
188.5037 -			</File>
188.5038 -			<File
188.5039 -				RelativePath=".\CPP\7zip\Archive\DllExports2.cpp"
188.5040 -				>
188.5041 -				<FileConfiguration
188.5042 -					Name="Release|Win32"
188.5043 -					>
188.5044 -					<Tool
188.5045 -						Name="VCCLCompilerTool"
188.5046 -						UsePrecompiledHeader="2"
188.5047 -					/>
188.5048 -				</FileConfiguration>
188.5049 -				<FileConfiguration
188.5050 -					Name="Debug|Win32"
188.5051 -					>
188.5052 -					<Tool
188.5053 -						Name="VCCLCompilerTool"
188.5054 -						UsePrecompiledHeader="2"
188.5055 -					/>
188.5056 -				</FileConfiguration>
188.5057 -				<FileConfiguration
188.5058 -					Name="Release FastBuild|Win32"
188.5059 -					>
188.5060 -					<Tool
188.5061 -						Name="VCCLCompilerTool"
188.5062 -						UsePrecompiledHeader="2"
188.5063 -					/>
188.5064 -				</FileConfiguration>
188.5065 -			</File>
188.5066 -			<File
188.5067 -				RelativePath=".\CPP\7zip\Archive\GZip\GZipRegister.cpp"
188.5068 -				>
188.5069 -				<FileConfiguration
188.5070 -					Name="Release|Win32"
188.5071 -					>
188.5072 -					<Tool
188.5073 -						Name="VCCLCompilerTool"
188.5074 -						UsePrecompiledHeader="2"
188.5075 -					/>
188.5076 -				</FileConfiguration>
188.5077 -				<FileConfiguration
188.5078 -					Name="Debug|Win32"
188.5079 -					>
188.5080 -					<Tool
188.5081 -						Name="VCCLCompilerTool"
188.5082 -						UsePrecompiledHeader="2"
188.5083 -					/>
188.5084 -				</FileConfiguration>
188.5085 -				<FileConfiguration
188.5086 -					Name="Release FastBuild|Win32"
188.5087 -					>
188.5088 -					<Tool
188.5089 -						Name="VCCLCompilerTool"
188.5090 -						UsePrecompiledHeader="2"
188.5091 -					/>
188.5092 -				</FileConfiguration>
188.5093 -			</File>
188.5094 -			<File
188.5095 -				RelativePath=".\CPP\7zip\Archive\Lzh\LzhRegister.cpp"
188.5096 -				>
188.5097 -				<FileConfiguration
188.5098 -					Name="Release|Win32"
188.5099 -					>
188.5100 -					<Tool
188.5101 -						Name="VCCLCompilerTool"
188.5102 -						UsePrecompiledHeader="2"
188.5103 -					/>
188.5104 -				</FileConfiguration>
188.5105 -				<FileConfiguration
188.5106 -					Name="Debug|Win32"
188.5107 -					>
188.5108 -					<Tool
188.5109 -						Name="VCCLCompilerTool"
188.5110 -						UsePrecompiledHeader="2"
188.5111 -					/>
188.5112 -				</FileConfiguration>
188.5113 -				<FileConfiguration
188.5114 -					Name="Release FastBuild|Win32"
188.5115 -					>
188.5116 -					<Tool
188.5117 -						Name="VCCLCompilerTool"
188.5118 -						UsePrecompiledHeader="2"
188.5119 -					/>
188.5120 -				</FileConfiguration>
188.5121 -			</File>
188.5122 -			<File
188.5123 -				RelativePath=".\CPP\7zip\Archive\Lzma\LzmaArcRegister.cpp"
188.5124 -				>
188.5125 -				<FileConfiguration
188.5126 -					Name="Release|Win32"
188.5127 -					>
188.5128 -					<Tool
188.5129 -						Name="VCCLCompilerTool"
188.5130 -						UsePrecompiledHeader="2"
188.5131 -					/>
188.5132 -				</FileConfiguration>
188.5133 -				<FileConfiguration
188.5134 -					Name="Debug|Win32"
188.5135 -					>
188.5136 -					<Tool
188.5137 -						Name="VCCLCompilerTool"
188.5138 -						UsePrecompiledHeader="2"
188.5139 -					/>
188.5140 -				</FileConfiguration>
188.5141 -				<FileConfiguration
188.5142 -					Name="Release FastBuild|Win32"
188.5143 -					>
188.5144 -					<Tool
188.5145 -						Name="VCCLCompilerTool"
188.5146 -						UsePrecompiledHeader="2"
188.5147 -					/>
188.5148 -				</FileConfiguration>
188.5149 -			</File>
188.5150 -			<File
188.5151 -				RelativePath=".\CPP\7zip\Compress\LzmaRegister.cpp"
188.5152 -				>
188.5153 -				<FileConfiguration
188.5154 -					Name="Release|Win32"
188.5155 -					>
188.5156 -					<Tool
188.5157 -						Name="VCCLCompilerTool"
188.5158 -						UsePrecompiledHeader="2"
188.5159 -					/>
188.5160 -				</FileConfiguration>
188.5161 -				<FileConfiguration
188.5162 -					Name="Debug|Win32"
188.5163 -					>
188.5164 -					<Tool
188.5165 -						Name="VCCLCompilerTool"
188.5166 -						UsePrecompiledHeader="2"
188.5167 -					/>
188.5168 -				</FileConfiguration>
188.5169 -				<FileConfiguration
188.5170 -					Name="Release FastBuild|Win32"
188.5171 -					>
188.5172 -					<Tool
188.5173 -						Name="VCCLCompilerTool"
188.5174 -						UsePrecompiledHeader="2"
188.5175 -					/>
188.5176 -				</FileConfiguration>
188.5177 -			</File>
188.5178 -			<File
188.5179 -				RelativePath=".\CPP\7zip\Compress\PpmdRegister.cpp"
188.5180 -				>
188.5181 -				<FileConfiguration
188.5182 -					Name="Release|Win32"
188.5183 -					>
188.5184 -					<Tool
188.5185 -						Name="VCCLCompilerTool"
188.5186 -						UsePrecompiledHeader="2"
188.5187 -					/>
188.5188 -				</FileConfiguration>
188.5189 -				<FileConfiguration
188.5190 -					Name="Debug|Win32"
188.5191 -					>
188.5192 -					<Tool
188.5193 -						Name="VCCLCompilerTool"
188.5194 -						UsePrecompiledHeader="2"
188.5195 -					/>
188.5196 -				</FileConfiguration>
188.5197 -				<FileConfiguration
188.5198 -					Name="Release FastBuild|Win32"
188.5199 -					>
188.5200 -					<Tool
188.5201 -						Name="VCCLCompilerTool"
188.5202 -						UsePrecompiledHeader="2"
188.5203 -					/>
188.5204 -				</FileConfiguration>
188.5205 -			</File>
188.5206 -			<File
188.5207 -				RelativePath=".\CPP\7zip\Compress\RarCodecsRegister.cpp"
188.5208 -				>
188.5209 -				<FileConfiguration
188.5210 -					Name="Release|Win32"
188.5211 -					>
188.5212 -					<Tool
188.5213 -						Name="VCCLCompilerTool"
188.5214 -						UsePrecompiledHeader="2"
188.5215 -					/>
188.5216 -				</FileConfiguration>
188.5217 -				<FileConfiguration
188.5218 -					Name="Debug|Win32"
188.5219 -					>
188.5220 -					<Tool
188.5221 -						Name="VCCLCompilerTool"
188.5222 -						UsePrecompiledHeader="2"
188.5223 -					/>
188.5224 -				</FileConfiguration>
188.5225 -				<FileConfiguration
188.5226 -					Name="Release FastBuild|Win32"
188.5227 -					>
188.5228 -					<Tool
188.5229 -						Name="VCCLCompilerTool"
188.5230 -						UsePrecompiledHeader="2"
188.5231 -					/>
188.5232 -				</FileConfiguration>
188.5233 -			</File>
188.5234 -			<File
188.5235 -				RelativePath=".\CPP\7zip\Archive\Rar\RarRegister.cpp"
188.5236 -				>
188.5237 -				<FileConfiguration
188.5238 -					Name="Release|Win32"
188.5239 -					>
188.5240 -					<Tool
188.5241 -						Name="VCCLCompilerTool"
188.5242 -						UsePrecompiledHeader="2"
188.5243 -					/>
188.5244 -				</FileConfiguration>
188.5245 -				<FileConfiguration
188.5246 -					Name="Debug|Win32"
188.5247 -					>
188.5248 -					<Tool
188.5249 -						Name="VCCLCompilerTool"
188.5250 -						UsePrecompiledHeader="2"
188.5251 -					/>
188.5252 -				</FileConfiguration>
188.5253 -				<FileConfiguration
188.5254 -					Name="Release FastBuild|Win32"
188.5255 -					>
188.5256 -					<Tool
188.5257 -						Name="VCCLCompilerTool"
188.5258 -						UsePrecompiledHeader="2"
188.5259 -					/>
188.5260 -				</FileConfiguration>
188.5261 -			</File>
188.5262 -			<File
188.5263 -				RelativePath=".\CPP\7zip\Archive\Split\SplitRegister.cpp"
188.5264 -				>
188.5265 -				<FileConfiguration
188.5266 -					Name="Release|Win32"
188.5267 -					>
188.5268 -					<Tool
188.5269 -						Name="VCCLCompilerTool"
188.5270 -						UsePrecompiledHeader="2"
188.5271 -					/>
188.5272 -				</FileConfiguration>
188.5273 -				<FileConfiguration
188.5274 -					Name="Debug|Win32"
188.5275 -					>
188.5276 -					<Tool
188.5277 -						Name="VCCLCompilerTool"
188.5278 -						UsePrecompiledHeader="2"
188.5279 -					/>
188.5280 -				</FileConfiguration>
188.5281 -				<FileConfiguration
188.5282 -					Name="Release FastBuild|Win32"
188.5283 -					>
188.5284 -					<Tool
188.5285 -						Name="VCCLCompilerTool"
188.5286 -						UsePrecompiledHeader="2"
188.5287 -					/>
188.5288 -				</FileConfiguration>
188.5289 -			</File>
188.5290 -			<File
188.5291 -				RelativePath=".\CPP\7zip\Archive\Tar\TarRegister.cpp"
188.5292 -				>
188.5293 -				<FileConfiguration
188.5294 -					Name="Release|Win32"
188.5295 -					>
188.5296 -					<Tool
188.5297 -						Name="VCCLCompilerTool"
188.5298 -						UsePrecompiledHeader="2"
188.5299 -					/>
188.5300 -				</FileConfiguration>
188.5301 -				<FileConfiguration
188.5302 -					Name="Debug|Win32"
188.5303 -					>
188.5304 -					<Tool
188.5305 -						Name="VCCLCompilerTool"
188.5306 -						UsePrecompiledHeader="2"
188.5307 -					/>
188.5308 -				</FileConfiguration>
188.5309 -				<FileConfiguration
188.5310 -					Name="Release FastBuild|Win32"
188.5311 -					>
188.5312 -					<Tool
188.5313 -						Name="VCCLCompilerTool"
188.5314 -						UsePrecompiledHeader="2"
188.5315 -					/>
188.5316 -				</FileConfiguration>
188.5317 -			</File>
188.5318 -			<File
188.5319 -				RelativePath=".\CPP\7zip\Archive\Zip\ZipRegister.cpp"
188.5320 -				>
188.5321 -				<FileConfiguration
188.5322 -					Name="Release|Win32"
188.5323 -					>
188.5324 -					<Tool
188.5325 -						Name="VCCLCompilerTool"
188.5326 -						UsePrecompiledHeader="2"
188.5327 -					/>
188.5328 -				</FileConfiguration>
188.5329 -				<FileConfiguration
188.5330 -					Name="Debug|Win32"
188.5331 -					>
188.5332 -					<Tool
188.5333 -						Name="VCCLCompilerTool"
188.5334 -						UsePrecompiledHeader="2"
188.5335 -					/>
188.5336 -				</FileConfiguration>
188.5337 -				<FileConfiguration
188.5338 -					Name="Release FastBuild|Win32"
188.5339 -					>
188.5340 -					<Tool
188.5341 -						Name="VCCLCompilerTool"
188.5342 -						UsePrecompiledHeader="2"
188.5343 -					/>
188.5344 -				</FileConfiguration>
188.5345 -			</File>
188.5346 -		</Filter>
188.5347 -	</Files>
188.5348 -	<Globals>
188.5349 -	</Globals>
188.5350 -</VisualStudioProject>
   189.1 --- a/src/win32/7zip/7z/7zip_2010.vcxproj	Sat Mar 03 10:54:39 2012 -0600
   189.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   189.3 @@ -1,1193 +0,0 @@
   189.4 -<?xml version="1.0" encoding="utf-8"?>
   189.5 -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   189.6 -  <ItemGroup Label="ProjectConfigurations">
   189.7 -    <ProjectConfiguration Include="Debug|Win32">
   189.8 -      <Configuration>Debug</Configuration>
   189.9 -      <Platform>Win32</Platform>
  189.10 -    </ProjectConfiguration>
  189.11 -    <ProjectConfiguration Include="Release FastBuild|Win32">
  189.12 -      <Configuration>Release FastBuild</Configuration>
  189.13 -      <Platform>Win32</Platform>
  189.14 -    </ProjectConfiguration>
  189.15 -    <ProjectConfiguration Include="Release|Win32">
  189.16 -      <Configuration>Release</Configuration>
  189.17 -      <Platform>Win32</Platform>
  189.18 -    </ProjectConfiguration>
  189.19 -  </ItemGroup>
  189.20 -  <PropertyGroup Label="Globals">
  189.21 -    <ProjectName>wlib7zip</ProjectName>
  189.22 -    <ProjectGuid>{5646C572-A578-49F8-9DA9-3E00A8CBFE3F}</ProjectGuid>
  189.23 -    <RootNamespace>gens</RootNamespace>
  189.24 -  </PropertyGroup>
  189.25 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  189.26 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'" Label="Configuration">
  189.27 -    <ConfigurationType>StaticLibrary</ConfigurationType>
  189.28 -    <UseOfMfc>false</UseOfMfc>
  189.29 -    <WholeProgramOptimization>false</WholeProgramOptimization>
  189.30 -    <CharacterSet>MultiByte</CharacterSet>
  189.31 -  </PropertyGroup>
  189.32 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
  189.33 -    <ConfigurationType>StaticLibrary</ConfigurationType>
  189.34 -    <UseOfMfc>false</UseOfMfc>
  189.35 -    <CharacterSet>MultiByte</CharacterSet>
  189.36 -  </PropertyGroup>
  189.37 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
  189.38 -    <ConfigurationType>StaticLibrary</ConfigurationType>
  189.39 -    <UseOfMfc>false</UseOfMfc>
  189.40 -    <WholeProgramOptimization>true</WholeProgramOptimization>
  189.41 -    <CharacterSet>MultiByte</CharacterSet>
  189.42 -  </PropertyGroup>
  189.43 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  189.44 -  <ImportGroup Label="ExtensionSettings">
  189.45 -    <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
  189.46 -  </ImportGroup>
  189.47 -  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'" Label="PropertySheets">
  189.48 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
  189.49 -  </ImportGroup>
  189.50 -  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
  189.51 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
  189.52 -  </ImportGroup>
  189.53 -  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
  189.54 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
  189.55 -  </ImportGroup>
  189.56 -  <PropertyGroup Label="UserMacros" />
  189.57 -  <PropertyGroup>
  189.58 -    <_ProjectFileVersion>10.0.21006.1</_ProjectFileVersion>
  189.59 -    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</OutDir>
  189.60 -    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
  189.61 -    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</OutDir>
  189.62 -    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
  189.63 -    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</OutDir>
  189.64 -    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">$(SolutionDir).VS2010\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
  189.65 -    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
  189.66 -    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
  189.67 -    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
  189.68 -    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
  189.69 -    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'" />
  189.70 -    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'" />
  189.71 -    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
  189.72 -    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
  189.73 -    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
  189.74 -  </PropertyGroup>
  189.75 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
  189.76 -    <Midl>
  189.77 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  189.78 -      <MkTypLibCompatible>true</MkTypLibCompatible>
  189.79 -      <SuppressStartupBanner>true</SuppressStartupBanner>
  189.80 -      <TargetEnvironment>Win32</TargetEnvironment>
  189.81 -      <TypeLibraryName>.\Release/gens.tlb</TypeLibraryName>
  189.82 -      <HeaderFileName>
  189.83 -      </HeaderFileName>
  189.84 -    </Midl>
  189.85 -    <ClCompile>
  189.86 -      <Optimization>Full</Optimization>
  189.87 -      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
  189.88 -      <IntrinsicFunctions>false</IntrinsicFunctions>
  189.89 -      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
  189.90 -      <OmitFramePointers>true</OmitFramePointers>
  189.91 -      <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
  189.92 -      <WholeProgramOptimization>true</WholeProgramOptimization>
  189.93 -      <AdditionalIncludeDirectories>CPP;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  189.94 -      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  189.95 -      <StringPooling>true</StringPooling>
  189.96 -      <ExceptionHandling>Sync</ExceptionHandling>
  189.97 -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  189.98 -      <PrecompiledHeader>Use</PrecompiledHeader>
  189.99 -      <PrecompiledHeaderOutputFile>$(IntDir)7z.pch</PrecompiledHeaderOutputFile>
 189.100 -      <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
 189.101 -      <ObjectFileName>$(IntDir)</ObjectFileName>
 189.102 -      <ProgramDataBaseFileName>$(IntDir)vc80.pdb</ProgramDataBaseFileName>
 189.103 -      <WarningLevel>Level3</WarningLevel>
 189.104 -      <SuppressStartupBanner>true</SuppressStartupBanner>
 189.105 -      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 189.106 -      <OmitDefaultLibName>true</OmitDefaultLibName>
 189.107 -      <BufferSecurityCheck>false</BufferSecurityCheck>
 189.108 -      <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
 189.109 -    </ClCompile>
 189.110 -    <ResourceCompile>
 189.111 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.112 -    </ResourceCompile>
 189.113 -    <Lib>
 189.114 -      <AdditionalOptions> /LTCG %(AdditionalOptions)</AdditionalOptions>
 189.115 -    </Lib>
 189.116 -  </ItemDefinitionGroup>
 189.117 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.118 -    <PreBuildEvent>
 189.119 -      <Command>
 189.120 -      </Command>
 189.121 -    </PreBuildEvent>
 189.122 -    <CustomBuildStep>
 189.123 -      <Command>
 189.124 -      </Command>
 189.125 -    </CustomBuildStep>
 189.126 -    <Midl>
 189.127 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.128 -      <MkTypLibCompatible>true</MkTypLibCompatible>
 189.129 -      <SuppressStartupBanner>true</SuppressStartupBanner>
 189.130 -      <TargetEnvironment>Win32</TargetEnvironment>
 189.131 -      <TypeLibraryName>.\Release/gens.tlb</TypeLibraryName>
 189.132 -      <HeaderFileName>
 189.133 -      </HeaderFileName>
 189.134 -    </Midl>
 189.135 -    <ClCompile>
 189.136 -      <Optimization>Disabled</Optimization>
 189.137 -      <InlineFunctionExpansion>Default</InlineFunctionExpansion>
 189.138 -      <IntrinsicFunctions>false</IntrinsicFunctions>
 189.139 -      <AdditionalIncludeDirectories>CPP;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 189.140 -      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.141 -      <StringPooling>false</StringPooling>
 189.142 -      <ExceptionHandling>Sync</ExceptionHandling>
 189.143 -      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
 189.144 -      <SmallerTypeCheck>true</SmallerTypeCheck>
 189.145 -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
 189.146 -      <FunctionLevelLinking>false</FunctionLevelLinking>
 189.147 -      <PrecompiledHeader>Use</PrecompiledHeader>
 189.148 -      <PrecompiledHeaderOutputFile>$(IntDir)7z.pch</PrecompiledHeaderOutputFile>
 189.149 -      <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
 189.150 -      <ObjectFileName>$(IntDir)</ObjectFileName>
 189.151 -      <ProgramDataBaseFileName>$(IntDir)vc80.pdb</ProgramDataBaseFileName>
 189.152 -      <WarningLevel>Level3</WarningLevel>
 189.153 -      <SuppressStartupBanner>true</SuppressStartupBanner>
 189.154 -      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 189.155 -      <OmitDefaultLibName>true</OmitDefaultLibName>
 189.156 -    </ClCompile>
 189.157 -    <ResourceCompile>
 189.158 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.159 -    </ResourceCompile>
 189.160 -  </ItemDefinitionGroup>
 189.161 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.162 -    <Midl>
 189.163 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.164 -      <MkTypLibCompatible>true</MkTypLibCompatible>
 189.165 -      <SuppressStartupBanner>true</SuppressStartupBanner>
 189.166 -      <TargetEnvironment>Win32</TargetEnvironment>
 189.167 -      <TypeLibraryName>.\Release/gens.tlb</TypeLibraryName>
 189.168 -      <HeaderFileName>
 189.169 -      </HeaderFileName>
 189.170 -    </Midl>
 189.171 -    <ClCompile>
 189.172 -      <Optimization>Full</Optimization>
 189.173 -      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
 189.174 -      <IntrinsicFunctions>true</IntrinsicFunctions>
 189.175 -      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
 189.176 -      <OmitFramePointers>true</OmitFramePointers>
 189.177 -      <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
 189.178 -      <WholeProgramOptimization>false</WholeProgramOptimization>
 189.179 -      <AdditionalIncludeDirectories>CPP;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 189.180 -      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;EXTRACT_ONLY;_NO_CRYPTO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.181 -      <StringPooling>true</StringPooling>
 189.182 -      <ExceptionHandling>Sync</ExceptionHandling>
 189.183 -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
 189.184 -      <PrecompiledHeader>Use</PrecompiledHeader>
 189.185 -      <PrecompiledHeaderOutputFile>$(IntDir)7z.pch</PrecompiledHeaderOutputFile>
 189.186 -      <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
 189.187 -      <ObjectFileName>$(IntDir)</ObjectFileName>
 189.188 -      <ProgramDataBaseFileName>$(IntDir)vc80.pdb</ProgramDataBaseFileName>
 189.189 -      <WarningLevel>Level3</WarningLevel>
 189.190 -      <SuppressStartupBanner>true</SuppressStartupBanner>
 189.191 -      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 189.192 -      <OmitDefaultLibName>true</OmitDefaultLibName>
 189.193 -    </ClCompile>
 189.194 -    <ResourceCompile>
 189.195 -      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 189.196 -    </ResourceCompile>
 189.197 -    <Lib>
 189.198 -      <AdditionalOptions> /LTCG %(AdditionalOptions)</AdditionalOptions>
 189.199 -    </Lib>
 189.200 -  </ItemDefinitionGroup>
 189.201 -  <ItemGroup>
 189.202 -    <ClCompile Include="CPP\7zip\Common\FilterCoder.cpp">
 189.203 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.204 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.205 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.206 -    </ClCompile>
 189.207 -    <ClCompile Include="CPP\7zip\Common\InBuffer.cpp">
 189.208 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.209 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.210 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.211 -    </ClCompile>
 189.212 -    <ClCompile Include="CPP\7zip\Common\InOutTempBuffer.cpp">
 189.213 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.214 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.215 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.216 -    </ClCompile>
 189.217 -    <ClCompile Include="CPP\7zip\Common\LimitedStreams.cpp">
 189.218 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.219 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.220 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.221 -    </ClCompile>
 189.222 -    <ClCompile Include="CPP\7zip\Common\LockedStream.cpp">
 189.223 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.224 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.225 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.226 -    </ClCompile>
 189.227 -    <ClCompile Include="CPP\7zip\Common\MemBlocks.cpp">
 189.228 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.229 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.230 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.231 -    </ClCompile>
 189.232 -    <ClCompile Include="CPP\7zip\Common\MethodId.cpp">
 189.233 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.234 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.235 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.236 -    </ClCompile>
 189.237 -    <ClCompile Include="CPP\7zip\Common\MethodProps.cpp">
 189.238 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.239 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.240 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.241 -    </ClCompile>
 189.242 -    <ClCompile Include="CPP\7zip\Common\OffsetStream.cpp">
 189.243 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.244 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.245 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.246 -    </ClCompile>
 189.247 -    <ClCompile Include="CPP\7zip\Common\OutBuffer.cpp">
 189.248 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.249 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.250 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.251 -    </ClCompile>
 189.252 -    <ClCompile Include="CPP\7zip\Common\OutMemStream.cpp">
 189.253 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.254 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.255 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.256 -    </ClCompile>
 189.257 -    <ClCompile Include="CPP\7zip\Common\ProgressMt.cpp">
 189.258 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.259 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.260 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.261 -    </ClCompile>
 189.262 -    <ClCompile Include="CPP\7zip\Common\ProgressUtils.cpp">
 189.263 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.264 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.265 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.266 -    </ClCompile>
 189.267 -    <ClCompile Include="CPP\7zip\Common\StreamBinder.cpp">
 189.268 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.269 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.270 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.271 -    </ClCompile>
 189.272 -    <ClCompile Include="CPP\7zip\Common\StreamObjects.cpp">
 189.273 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.274 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.275 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.276 -    </ClCompile>
 189.277 -    <ClCompile Include="CPP\7zip\Common\StreamUtils.cpp">
 189.278 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.279 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.280 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.281 -    </ClCompile>
 189.282 -    <ClCompile Include="CPP\7zip\Common\VirtThread.cpp">
 189.283 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.284 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.285 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.286 -    </ClCompile>
 189.287 -    <ClCompile Include="CPP\Windows\FileDir.cpp">
 189.288 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.289 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.290 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.291 -    </ClCompile>
 189.292 -    <ClCompile Include="CPP\Windows\FileFind.cpp">
 189.293 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.294 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.295 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.296 -    </ClCompile>
 189.297 -    <ClCompile Include="CPP\Windows\FileIO.cpp">
 189.298 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.299 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.300 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.301 -    </ClCompile>
 189.302 -    <ClCompile Include="CPP\Windows\PropVariant.cpp">
 189.303 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.304 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.305 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.306 -    </ClCompile>
 189.307 -    <ClCompile Include="CPP\Windows\Time.cpp">
 189.308 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.309 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.310 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.311 -    </ClCompile>
 189.312 -    <ClCompile Include="CPP\7zip\Archive\7z\7zCompressionMode.cpp">
 189.313 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.314 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.315 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.316 -    </ClCompile>
 189.317 -    <ClCompile Include="CPP\7zip\Archive\7z\7zDecode.cpp">
 189.318 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.319 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.320 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.321 -    </ClCompile>
 189.322 -    <ClCompile Include="CPP\7zip\Archive\7z\7zExtract.cpp">
 189.323 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.324 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.325 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.326 -    </ClCompile>
 189.327 -    <ClCompile Include="CPP\7zip\Archive\7z\7zFolderInStream.cpp">
 189.328 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.329 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.330 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.331 -    </ClCompile>
 189.332 -    <ClCompile Include="CPP\7zip\Archive\7z\7zFolderOutStream.cpp">
 189.333 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.334 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.335 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.336 -    </ClCompile>
 189.337 -    <ClCompile Include="CPP\7zip\Archive\7z\7zHandler.cpp">
 189.338 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.339 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.340 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.341 -    </ClCompile>
 189.342 -    <ClCompile Include="CPP\7zip\Archive\7z\7zHeader.cpp">
 189.343 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.344 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.345 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.346 -    </ClCompile>
 189.347 -    <ClCompile Include="CPP\7zip\Archive\7z\7zIn.cpp">
 189.348 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.349 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.350 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.351 -    </ClCompile>
 189.352 -    <ClCompile Include="CPP\7zip\Archive\7z\7zProperties.cpp">
 189.353 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.354 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.355 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.356 -    </ClCompile>
 189.357 -    <ClCompile Include="CPP\7zip\Archive\7z\7zSpecStream.cpp">
 189.358 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.359 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.360 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.361 -    </ClCompile>
 189.362 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarHandler.cpp">
 189.363 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.364 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.365 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.366 -    </ClCompile>
 189.367 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarHeader.cpp">
 189.368 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.369 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.370 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.371 -    </ClCompile>
 189.372 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarIn.cpp">
 189.373 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.374 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.375 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.376 -    </ClCompile>
 189.377 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarItem.cpp">
 189.378 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.379 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.380 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.381 -    </ClCompile>
 189.382 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarVolumeInStream.cpp">
 189.383 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.384 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.385 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.386 -    </ClCompile>
 189.387 -    <ClCompile Include="CPP\7zip\Archive\BZip2\BZip2Handler.cpp">
 189.388 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.389 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.390 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.391 -    </ClCompile>
 189.392 -    <ClCompile Include="CPP\7zip\Archive\Common\CoderMixer2.cpp">
 189.393 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.394 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.395 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.396 -    </ClCompile>
 189.397 -    <ClCompile Include="CPP\7zip\Archive\Common\CoderMixer2MT.cpp">
 189.398 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.399 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.400 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.401 -    </ClCompile>
 189.402 -    <ClCompile Include="CPP\7zip\Archive\Common\DummyOutStream.cpp">
 189.403 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.404 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.405 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.406 -    </ClCompile>
 189.407 -    <ClCompile Include="CPP\7zip\Archive\Common\FindSignature.cpp">
 189.408 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.409 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.410 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.411 -    </ClCompile>
 189.412 -    <ClCompile Include="CPP\7zip\Archive\Common\InStreamWithCRC.cpp">
 189.413 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.414 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.415 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.416 -    </ClCompile>
 189.417 -    <ClCompile Include="CPP\7zip\Archive\Common\ItemNameUtils.cpp">
 189.418 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.419 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.420 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.421 -    </ClCompile>
 189.422 -    <ClCompile Include="CPP\7zip\Archive\Common\MultiStream.cpp">
 189.423 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.424 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.425 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.426 -    </ClCompile>
 189.427 -    <ClCompile Include="CPP\7zip\Archive\Common\OutStreamWithCRC.cpp">
 189.428 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.429 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.430 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.431 -    </ClCompile>
 189.432 -    <ClCompile Include="CPP\7zip\Archive\Common\ParseProperties.cpp">
 189.433 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.434 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.435 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.436 -    </ClCompile>
 189.437 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipHandler.cpp">
 189.438 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.439 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.440 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.441 -    </ClCompile>
 189.442 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipHeader.cpp">
 189.443 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.444 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.445 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.446 -    </ClCompile>
 189.447 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipIn.cpp">
 189.448 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.449 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.450 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.451 -    </ClCompile>
 189.452 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhCRC.cpp">
 189.453 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.454 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.455 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.456 -    </ClCompile>
 189.457 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhHandler.cpp">
 189.458 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.459 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.460 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.461 -    </ClCompile>
 189.462 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhIn.cpp">
 189.463 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.464 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.465 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.466 -    </ClCompile>
 189.467 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.cpp">
 189.468 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.469 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.470 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.471 -    </ClCompile>
 189.472 -    <ClCompile Include="CPP\7zip\Archive\Split\SplitHandler.cpp">
 189.473 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.474 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.475 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.476 -    </ClCompile>
 189.477 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarHandler.cpp">
 189.478 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.479 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.480 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.481 -    </ClCompile>
 189.482 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarHeader.cpp">
 189.483 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.484 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.485 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.486 -    </ClCompile>
 189.487 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarIn.cpp">
 189.488 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.489 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.490 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.491 -    </ClCompile>
 189.492 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipHandler.cpp">
 189.493 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.494 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.495 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.496 -    </ClCompile>
 189.497 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipHeader.cpp">
 189.498 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.499 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.500 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.501 -    </ClCompile>
 189.502 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipIn.cpp">
 189.503 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.504 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.505 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.506 -    </ClCompile>
 189.507 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipItem.cpp">
 189.508 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.509 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.510 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.511 -    </ClCompile>
 189.512 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaFiltersDecode.cpp">
 189.513 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.514 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.515 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.516 -    </ClCompile>
 189.517 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaHandler.cpp">
 189.518 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.519 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.520 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.521 -    </ClCompile>
 189.522 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaIn.cpp">
 189.523 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.524 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.525 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.526 -    </ClCompile>
 189.527 -    <ClCompile Include="C\7zCrc.c">
 189.528 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.529 -      </PrecompiledHeader>
 189.530 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.531 -      </PrecompiledHeader>
 189.532 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.533 -      </PrecompiledHeader>
 189.534 -    </ClCompile>
 189.535 -    <ClCompile Include="C\Aes.c">
 189.536 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.537 -      </PrecompiledHeader>
 189.538 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.539 -      </PrecompiledHeader>
 189.540 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.541 -      </PrecompiledHeader>
 189.542 -    </ClCompile>
 189.543 -    <ClCompile Include="C\Alloc.c">
 189.544 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.545 -      </PrecompiledHeader>
 189.546 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.547 -      </PrecompiledHeader>
 189.548 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.549 -      </PrecompiledHeader>
 189.550 -    </ClCompile>
 189.551 -    <ClCompile Include="C\Bra.c">
 189.552 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.553 -      </PrecompiledHeader>
 189.554 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.555 -      </PrecompiledHeader>
 189.556 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.557 -      </PrecompiledHeader>
 189.558 -    </ClCompile>
 189.559 -    <ClCompile Include="C\Bra86.c">
 189.560 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.561 -      </PrecompiledHeader>
 189.562 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.563 -      </PrecompiledHeader>
 189.564 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.565 -      </PrecompiledHeader>
 189.566 -    </ClCompile>
 189.567 -    <ClCompile Include="C\BraIA64.c">
 189.568 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.569 -      </PrecompiledHeader>
 189.570 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.571 -      </PrecompiledHeader>
 189.572 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.573 -      </PrecompiledHeader>
 189.574 -    </ClCompile>
 189.575 -    <ClCompile Include="C\BwtSort.c">
 189.576 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.577 -      </PrecompiledHeader>
 189.578 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.579 -      </PrecompiledHeader>
 189.580 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.581 -      </PrecompiledHeader>
 189.582 -    </ClCompile>
 189.583 -    <ClCompile Include="C\HuffEnc.c">
 189.584 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.585 -      </PrecompiledHeader>
 189.586 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.587 -      </PrecompiledHeader>
 189.588 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.589 -      </PrecompiledHeader>
 189.590 -    </ClCompile>
 189.591 -    <ClCompile Include="C\LzFind.c">
 189.592 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.593 -      </PrecompiledHeader>
 189.594 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.595 -      </PrecompiledHeader>
 189.596 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.597 -      </PrecompiledHeader>
 189.598 -    </ClCompile>
 189.599 -    <ClCompile Include="C\LzFindMt.c">
 189.600 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.601 -      </PrecompiledHeader>
 189.602 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.603 -      </PrecompiledHeader>
 189.604 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.605 -      </PrecompiledHeader>
 189.606 -    </ClCompile>
 189.607 -    <ClCompile Include="C\LzmaDec.c">
 189.608 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.609 -      </PrecompiledHeader>
 189.610 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.611 -      </PrecompiledHeader>
 189.612 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.613 -      </PrecompiledHeader>
 189.614 -    </ClCompile>
 189.615 -    <ClCompile Include="C\LzmaEnc.c">
 189.616 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.617 -      </PrecompiledHeader>
 189.618 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.619 -      </PrecompiledHeader>
 189.620 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.621 -      </PrecompiledHeader>
 189.622 -    </ClCompile>
 189.623 -    <ClCompile Include="C\Sha256.c">
 189.624 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.625 -      </PrecompiledHeader>
 189.626 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.627 -      </PrecompiledHeader>
 189.628 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.629 -      </PrecompiledHeader>
 189.630 -    </ClCompile>
 189.631 -    <ClCompile Include="C\Sort.c">
 189.632 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.633 -      </PrecompiledHeader>
 189.634 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.635 -      </PrecompiledHeader>
 189.636 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.637 -      </PrecompiledHeader>
 189.638 -    </ClCompile>
 189.639 -    <ClCompile Include="C\Threads.c">
 189.640 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 189.641 -      </PrecompiledHeader>
 189.642 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">
 189.643 -      </PrecompiledHeader>
 189.644 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 189.645 -      </PrecompiledHeader>
 189.646 -    </ClCompile>
 189.647 -    <ClCompile Include="CPP\Common\CRC.cpp">
 189.648 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.649 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.650 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.651 -    </ClCompile>
 189.652 -    <ClCompile Include="CPP\Common\IntToString.cpp">
 189.653 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.654 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.655 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.656 -    </ClCompile>
 189.657 -    <ClCompile Include="CPP\Common\MyMap.cpp">
 189.658 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.659 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.660 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.661 -    </ClCompile>
 189.662 -    <ClCompile Include="CPP\Common\MyString.cpp">
 189.663 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.664 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.665 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.666 -    </ClCompile>
 189.667 -    <ClCompile Include="CPP\Common\MyVector.cpp">
 189.668 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.669 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.670 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.671 -    </ClCompile>
 189.672 -    <ClCompile Include="CPP\Common\MyXml.cpp">
 189.673 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.674 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.675 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.676 -    </ClCompile>
 189.677 -    <ClCompile Include="CPP\Common\NewHandler.cpp">
 189.678 -      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
 189.679 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.680 -      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">true</ExcludedFromBuild>
 189.681 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.682 -      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
 189.683 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.684 -    </ClCompile>
 189.685 -    <ClCompile Include="CPP\Common\StringConvert.cpp">
 189.686 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.687 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.688 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.689 -    </ClCompile>
 189.690 -    <ClCompile Include="CPP\Common\StringToInt.cpp">
 189.691 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.692 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.693 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.694 -    </ClCompile>
 189.695 -    <ClCompile Include="CPP\Common\UTFConvert.cpp">
 189.696 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.697 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.698 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.699 -    </ClCompile>
 189.700 -    <ClCompile Include="CPP\Common\Wildcard.cpp">
 189.701 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.702 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.703 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.704 -    </ClCompile>
 189.705 -    <ClCompile Include="CPP\7zip\Compress\LzhDecoder.cpp">
 189.706 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.707 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.708 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.709 -    </ClCompile>
 189.710 -    <ClCompile Include="CPP\7zip\Compress\LzOutWindow.cpp">
 189.711 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.712 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.713 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.714 -    </ClCompile>
 189.715 -    <ClCompile Include="CPP\7zip\Compress\PpmdDecoder.cpp">
 189.716 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.717 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.718 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.719 -    </ClCompile>
 189.720 -    <ClCompile Include="CPP\7zip\Compress\BitlDecoder.cpp">
 189.721 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.722 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.723 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.724 -    </ClCompile>
 189.725 -    <ClCompile Include="CPP\7zip\Compress\Rar1Decoder.cpp">
 189.726 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.727 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.728 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.729 -    </ClCompile>
 189.730 -    <ClCompile Include="CPP\7zip\Compress\Rar2Decoder.cpp">
 189.731 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.732 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.733 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.734 -    </ClCompile>
 189.735 -    <ClCompile Include="CPP\7zip\Compress\Rar3Decoder.cpp">
 189.736 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.737 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.738 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.739 -    </ClCompile>
 189.740 -    <ClCompile Include="CPP\7zip\Compress\Rar3Vm.cpp">
 189.741 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.742 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.743 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.744 -    </ClCompile>
 189.745 -    <ClCompile Include="CPP\7zip\Compress\BZip2Crc.cpp">
 189.746 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.747 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.748 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.749 -    </ClCompile>
 189.750 -    <ClCompile Include="CPP\7zip\Compress\BZip2Decoder.cpp">
 189.751 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.752 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.753 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.754 -    </ClCompile>
 189.755 -    <ClCompile Include="CPP\7zip\Compress\DeflateDecoder.cpp">
 189.756 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.757 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.758 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.759 -    </ClCompile>
 189.760 -    <ClCompile Include="CPP\7zip\Compress\ImplodeDecoder.cpp">
 189.761 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.762 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.763 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.764 -    </ClCompile>
 189.765 -    <ClCompile Include="CPP\7zip\Compress\ImplodeHuffmanDecoder.cpp">
 189.766 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.767 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.768 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.769 -    </ClCompile>
 189.770 -    <ClCompile Include="CPP\7zip\Compress\ShrinkDecoder.cpp">
 189.771 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.772 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.773 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.774 -    </ClCompile>
 189.775 -    <ClCompile Include="CPP\7zip\Compress\ZlibDecoder.cpp">
 189.776 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.777 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.778 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.779 -    </ClCompile>
 189.780 -    <ClCompile Include="CPP\7zip\Compress\Bcj2Coder.cpp">
 189.781 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.782 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.783 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.784 -    </ClCompile>
 189.785 -    <ClCompile Include="CPP\7zip\Compress\BcjCoder.cpp">
 189.786 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.787 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.788 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.789 -    </ClCompile>
 189.790 -    <ClCompile Include="CPP\7zip\Compress\BranchCoder.cpp">
 189.791 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.792 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.793 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.794 -    </ClCompile>
 189.795 -    <ClCompile Include="CPP\7zip\Compress\BranchMisc.cpp">
 189.796 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.797 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.798 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.799 -    </ClCompile>
 189.800 -    <ClCompile Include="CPP\7zip\Compress\ByteSwap.cpp">
 189.801 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.802 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.803 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.804 -    </ClCompile>
 189.805 -    <ClCompile Include="CPP\7zip\Compress\CopyCoder.cpp">
 189.806 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.807 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.808 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.809 -    </ClCompile>
 189.810 -    <ClCompile Include="CPP\7zip\Compress\LzmaDecoder.cpp">
 189.811 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.812 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.813 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.814 -    </ClCompile>
 189.815 -    <ClCompile Include="CPP\7zip\Crypto\7zAes.cpp">
 189.816 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.817 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.818 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.819 -    </ClCompile>
 189.820 -    <ClCompile Include="CPP\7zip\Crypto\HmacSha1.cpp">
 189.821 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.822 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.823 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.824 -    </ClCompile>
 189.825 -    <ClCompile Include="CPP\7zip\Crypto\MyAes.cpp">
 189.826 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.827 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.828 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.829 -    </ClCompile>
 189.830 -    <ClCompile Include="CPP\7zip\Crypto\Pbkdf2HmacSha1.cpp">
 189.831 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.832 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.833 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.834 -    </ClCompile>
 189.835 -    <ClCompile Include="CPP\7zip\Crypto\RandGen.cpp">
 189.836 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.837 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.838 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.839 -    </ClCompile>
 189.840 -    <ClCompile Include="CPP\7zip\Crypto\Rar20Crypto.cpp">
 189.841 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.842 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.843 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.844 -    </ClCompile>
 189.845 -    <ClCompile Include="CPP\7zip\Crypto\RarAes.cpp">
 189.846 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.847 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.848 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.849 -    </ClCompile>
 189.850 -    <ClCompile Include="CPP\7zip\Crypto\Sha1.cpp">
 189.851 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.852 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.853 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.854 -    </ClCompile>
 189.855 -    <ClCompile Include="CPP\7zip\Crypto\WzAes.cpp">
 189.856 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.857 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.858 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.859 -    </ClCompile>
 189.860 -    <ClCompile Include="CPP\7zip\Crypto\ZipCrypto.cpp">
 189.861 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.862 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.863 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.864 -    </ClCompile>
 189.865 -    <ClCompile Include="CPP\7zip\Crypto\ZipStrong.cpp">
 189.866 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.867 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.868 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.869 -    </ClCompile>
 189.870 -    <ClCompile Include="CPP\7zip\Crypto\7zAesRegister.cpp">
 189.871 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.872 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.873 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.874 -    </ClCompile>
 189.875 -    <ClCompile Include="CPP\7zip\Archive\7z\7zRegister.cpp">
 189.876 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.877 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.878 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.879 -    </ClCompile>
 189.880 -    <ClCompile Include="CPP\7zip\Archive\ArchiveExports.cpp">
 189.881 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
 189.882 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Create</PrecompiledHeader>
 189.883 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
 189.884 -    </ClCompile>
 189.885 -    <ClCompile Include="CPP\7zip\Compress\Bcj2Register.cpp">
 189.886 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.887 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.888 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.889 -    </ClCompile>
 189.890 -    <ClCompile Include="CPP\7zip\Compress\BcjRegister.cpp">
 189.891 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.892 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.893 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.894 -    </ClCompile>
 189.895 -    <ClCompile Include="CPP\7zip\Compress\BranchRegister.cpp">
 189.896 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.897 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.898 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.899 -    </ClCompile>
 189.900 -    <ClCompile Include="CPP\7zip\Compress\ByteSwapRegister.cpp">
 189.901 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.902 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.903 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.904 -    </ClCompile>
 189.905 -    <ClCompile Include="CPP\7zip\Archive\BZip2\bz2Register.cpp">
 189.906 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.907 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.908 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.909 -    </ClCompile>
 189.910 -    <ClCompile Include="CPP\7zip\Compress\BZip2Register.cpp">
 189.911 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.912 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.913 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.914 -    </ClCompile>
 189.915 -    <ClCompile Include="CPP\7zip\Compress\CodecExports.cpp">
 189.916 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.917 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.918 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.919 -    </ClCompile>
 189.920 -    <ClCompile Include="CPP\7zip\Compress\CopyRegister.cpp">
 189.921 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.922 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.923 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.924 -    </ClCompile>
 189.925 -    <ClCompile Include="CPP\7zip\Common\CreateCoder.cpp">
 189.926 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.927 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.928 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.929 -    </ClCompile>
 189.930 -    <ClCompile Include="CPP\7zip\Compress\Deflate64Register.cpp">
 189.931 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.932 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.933 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.934 -    </ClCompile>
 189.935 -    <ClCompile Include="CPP\7zip\Compress\DeflateNsisRegister.cpp">
 189.936 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.937 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.938 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.939 -    </ClCompile>
 189.940 -    <ClCompile Include="CPP\7zip\Compress\DeflateRegister.cpp">
 189.941 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.942 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.943 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.944 -    </ClCompile>
 189.945 -    <ClCompile Include="CPP\7zip\Archive\DllExports2.cpp">
 189.946 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.947 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.948 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.949 -    </ClCompile>
 189.950 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipRegister.cpp">
 189.951 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.952 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.953 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.954 -    </ClCompile>
 189.955 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhRegister.cpp">
 189.956 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.957 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.958 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.959 -    </ClCompile>
 189.960 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaArcRegister.cpp">
 189.961 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.962 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.963 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.964 -    </ClCompile>
 189.965 -    <ClCompile Include="CPP\7zip\Compress\LzmaRegister.cpp">
 189.966 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.967 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.968 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.969 -    </ClCompile>
 189.970 -    <ClCompile Include="CPP\7zip\Compress\PpmdRegister.cpp">
 189.971 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.972 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.973 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.974 -    </ClCompile>
 189.975 -    <ClCompile Include="CPP\7zip\Compress\RarCodecsRegister.cpp">
 189.976 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.977 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.978 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.979 -    </ClCompile>
 189.980 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarRegister.cpp">
 189.981 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.982 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.983 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.984 -    </ClCompile>
 189.985 -    <ClCompile Include="CPP\7zip\Archive\Split\SplitRegister.cpp">
 189.986 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.987 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.988 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.989 -    </ClCompile>
 189.990 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarRegister.cpp">
 189.991 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.992 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.993 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.994 -    </ClCompile>
 189.995 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipRegister.cpp">
 189.996 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
 189.997 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FastBuild|Win32'">Use</PrecompiledHeader>
 189.998 -      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
 189.999 -    </ClCompile>
189.1000 -  </ItemGroup>
189.1001 -  <ItemGroup>
189.1002 -    <ClInclude Include="CPP\7zip\Crypto\7zAes.h" />
189.1003 -    <ClInclude Include="CPP\7zip\Archive\7z\7zCompressionMode.h" />
189.1004 -    <ClInclude Include="C\7zCrc.h" />
189.1005 -    <ClInclude Include="CPP\7zip\Archive\7z\7zDecode.h" />
189.1006 -    <ClInclude Include="CPP\7zip\Archive\7z\7zFolderInStream.h" />
189.1007 -    <ClInclude Include="CPP\7zip\Archive\7z\7zFolderOutStream.h" />
189.1008 -    <ClInclude Include="CPP\7zip\Archive\7z\7zHandler.h" />
189.1009 -    <ClInclude Include="CPP\7zip\Archive\7z\7zHeader.h" />
189.1010 -    <ClInclude Include="CPP\7zip\Archive\7z\7zIn.h" />
189.1011 -    <ClInclude Include="CPP\7zip\Archive\7z\7zItem.h" />
189.1012 -    <ClInclude Include="CPP\7zip\Archive\7z\7zProperties.h" />
189.1013 -    <ClInclude Include="CPP\7zip\Archive\7z\7zSpecStream.h" />
189.1014 -    <ClInclude Include="C\Aes.h" />
189.1015 -    <ClInclude Include="C\Alloc.h" />
189.1016 -    <ClInclude Include="CPP\7zip\Compress\Bcj2Coder.h" />
189.1017 -    <ClInclude Include="CPP\7zip\Compress\BcjCoder.h" />
189.1018 -    <ClInclude Include="CPP\7zip\Compress\BitlDecoder.h" />
189.1019 -    <ClInclude Include="CPP\7zip\Compress\BitmDecoder.h" />
189.1020 -    <ClInclude Include="C\Bra.h" />
189.1021 -    <ClInclude Include="CPP\7zip\Compress\BranchCoder.h" />
189.1022 -    <ClInclude Include="CPP\7zip\Compress\BranchMisc.h" />
189.1023 -    <ClInclude Include="CPP\Common\Buffer.h" />
189.1024 -    <ClInclude Include="C\BwtSort.h" />
189.1025 -    <ClInclude Include="CPP\7zip\Compress\ByteSwap.h" />
189.1026 -    <ClInclude Include="CPP\7zip\Compress\BZip2Const.h" />
189.1027 -    <ClInclude Include="CPP\7zip\Compress\BZip2Crc.h" />
189.1028 -    <ClInclude Include="CPP\7zip\Compress\BZip2Decoder.h" />
189.1029 -    <ClInclude Include="CPP\7zip\Archive\BZip2\BZip2Handler.h" />
189.1030 -    <ClInclude Include="CPP\7zip\Archive\BZip2\BZip2Item.h" />
189.1031 -    <ClInclude Include="CPP\7zip\Archive\Common\CoderMixer2.h" />
189.1032 -    <ClInclude Include="CPP\7zip\Archive\Common\CoderMixer2MT.h" />
189.1033 -    <ClInclude Include="CPP\Common\ComTry.h" />
189.1034 -    <ClInclude Include="CPP\7zip\Compress\CopyCoder.h" />
189.1035 -    <ClInclude Include="C\CpuArch.h" />
189.1036 -    <ClInclude Include="CPP\7zip\Common\CreateCoder.h" />
189.1037 -    <ClInclude Include="CPP\7zip\Common\DeclareArcs.h" />
189.1038 -    <ClInclude Include="CPP\7zip\Common\DeclareCodecs.h" />
189.1039 -    <ClInclude Include="CPP\7zip\Compress\DeflateConst.h" />
189.1040 -    <ClInclude Include="CPP\7zip\Compress\DeflateDecoder.h" />
189.1041 -    <ClInclude Include="CPP\Windows\Defs.h" />
189.1042 -    <ClInclude Include="CPP\Common\Defs.h" />
189.1043 -    <ClInclude Include="CPP\7zip\Archive\Common\DummyOutStream.h" />
189.1044 -    <ClInclude Include="CPP\Common\DynamicBuffer.h" />
189.1045 -    <ClInclude Include="CPP\Windows\FileDir.h" />
189.1046 -    <ClInclude Include="CPP\Windows\FileFind.h" />
189.1047 -    <ClInclude Include="CPP\Windows\FileIO.h" />
189.1048 -    <ClInclude Include="CPP\Windows\FileName.h" />
189.1049 -    <ClInclude Include="CPP\7zip\Common\FilterCoder.h" />
189.1050 -    <ClInclude Include="CPP\7zip\Archive\Common\FindSignature.h" />
189.1051 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipHandler.h" />
189.1052 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipHeader.h" />
189.1053 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipIn.h" />
189.1054 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipItem.h" />
189.1055 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipUpdate.h" />
189.1056 -    <ClInclude Include="CPP\Windows\Handle.h" />
189.1057 -    <ClInclude Include="CPP\7zip\Crypto\HmacSha1.h" />
189.1058 -    <ClInclude Include="C\HuffEnc.h" />
189.1059 -    <ClInclude Include="CPP\7zip\Compress\HuffmanDecoder.h" />
189.1060 -    <ClInclude Include="CPP\7zip\Archive\IArchive.h" />
189.1061 -    <ClInclude Include="CPP\7zip\ICoder.h" />
189.1062 -    <ClInclude Include="CPP\7zip\IDecl.h" />
189.1063 -    <ClInclude Include="CPP\7zip\Compress\ImplodeDecoder.h" />
189.1064 -    <ClInclude Include="CPP\7zip\Compress\ImplodeHuffmanDecoder.h" />
189.1065 -    <ClInclude Include="CPP\7zip\Common\InBuffer.h" />
189.1066 -    <ClInclude Include="CPP\Common\InitializeStaticLib.h" />
189.1067 -    <ClInclude Include="CPP\7zip\Common\InOutTempBuffer.h" />
189.1068 -    <ClInclude Include="CPP\7zip\Archive\Common\InStreamWithCRC.h" />
189.1069 -    <ClInclude Include="CPP\Common\IntToString.h" />
189.1070 -    <ClInclude Include="CPP\7zip\IPassword.h" />
189.1071 -    <ClInclude Include="CPP\7zip\IProgress.h" />
189.1072 -    <ClInclude Include="CPP\7zip\IStream.h" />
189.1073 -    <ClInclude Include="CPP\7zip\Archive\Common\ItemNameUtils.h" />
189.1074 -    <ClInclude Include="CPP\7zip\Common\LimitedStreams.h" />
189.1075 -    <ClInclude Include="CPP\7zip\Common\LockedStream.h" />
189.1076 -    <ClInclude Include="C\LzFind.h" />
189.1077 -    <ClInclude Include="C\LzFindMt.h" />
189.1078 -    <ClInclude Include="C\LzHash.h" />
189.1079 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhCRC.h" />
189.1080 -    <ClInclude Include="CPP\7zip\Compress\LzhDecoder.h" />
189.1081 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhHandler.h" />
189.1082 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhHeader.h" />
189.1083 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhIn.h" />
189.1084 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhItem.h" />
189.1085 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.h" />
189.1086 -    <ClInclude Include="C\LzmaDec.h" />
189.1087 -    <ClInclude Include="CPP\7zip\Compress\LzmaDecoder.h" />
189.1088 -    <ClInclude Include="C\LzmaEnc.h" />
189.1089 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaFiltersDecode.h" />
189.1090 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaHandler.h" />
189.1091 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaIn.h" />
189.1092 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaItem.h" />
189.1093 -    <ClInclude Include="CPP\7zip\Compress\LzOutWindow.h" />
189.1094 -    <ClInclude Include="CPP\7zip\Common\MemBlocks.h" />
189.1095 -    <ClInclude Include="CPP\7zip\Common\MethodId.h" />
189.1096 -    <ClInclude Include="CPP\7zip\Common\MethodProps.h" />
189.1097 -    <ClInclude Include="CPP\7zip\Compress\Mtf8.h" />
189.1098 -    <ClInclude Include="CPP\7zip\Archive\Common\MultiStream.h" />
189.1099 -    <ClInclude Include="CPP\7zip\Crypto\MyAes.h" />
189.1100 -    <ClInclude Include="CPP\Common\MyCom.h" />
189.1101 -    <ClInclude Include="CPP\Common\MyException.h" />
189.1102 -    <ClInclude Include="CPP\Common\MyInitGuid.h" />
189.1103 -    <ClInclude Include="CPP\Common\MyMap.h" />
189.1104 -    <ClInclude Include="CPP\Common\MyString.h" />
189.1105 -    <ClInclude Include="CPP\Common\MyUnknown.h" />
189.1106 -    <ClInclude Include="CPP\Common\MyVector.h" />
189.1107 -    <ClInclude Include="CPP\Common\MyWindows.h" />
189.1108 -    <ClInclude Include="CPP\Common\MyXml.h" />
189.1109 -    <ClInclude Include="CPP\Common\NewHandler.h" />
189.1110 -    <ClInclude Include="CPP\7zip\Common\OffsetStream.h" />
189.1111 -    <ClInclude Include="CPP\7zip\Common\OutBuffer.h" />
189.1112 -    <ClInclude Include="CPP\7zip\Common\OutMemStream.h" />
189.1113 -    <ClInclude Include="CPP\7zip\Archive\Common\OutStreamWithCRC.h" />
189.1114 -    <ClInclude Include="CPP\7zip\Archive\Common\ParseProperties.h" />
189.1115 -    <ClInclude Include="CPP\7zip\Crypto\Pbkdf2HmacSha1.h" />
189.1116 -    <ClInclude Include="CPP\7zip\Compress\PpmdContext.h" />
189.1117 -    <ClInclude Include="CPP\7zip\Compress\PpmdDecode.h" />
189.1118 -    <ClInclude Include="CPP\7zip\Compress\PpmdDecoder.h" />
189.1119 -    <ClInclude Include="CPP\7zip\Compress\PpmdSubAlloc.h" />
189.1120 -    <ClInclude Include="CPP\7zip\Compress\PpmdType.h" />
189.1121 -    <ClInclude Include="CPP\7zip\Common\ProgressMt.h" />
189.1122 -    <ClInclude Include="CPP\7zip\Common\ProgressUtils.h" />
189.1123 -    <ClInclude Include="CPP\7zip\PropID.h" />
189.1124 -    <ClInclude Include="CPP\Windows\PropVariant.h" />
189.1125 -    <ClInclude Include="CPP\7zip\Crypto\RandGen.h" />
189.1126 -    <ClInclude Include="CPP\7zip\Compress\RangeCoder.h" />
189.1127 -    <ClInclude Include="CPP\7zip\Compress\RangeCoderBit.h" />
189.1128 -    <ClInclude Include="CPP\7zip\Compress\Rar1Decoder.h" />
189.1129 -    <ClInclude Include="CPP\7zip\Crypto\Rar20Crypto.h" />
189.1130 -    <ClInclude Include="CPP\7zip\Compress\Rar2Decoder.h" />
189.1131 -    <ClInclude Include="CPP\7zip\Compress\Rar3Decoder.h" />
189.1132 -    <ClInclude Include="CPP\7zip\Compress\Rar3Vm.h" />
189.1133 -    <ClInclude Include="CPP\7zip\Crypto\RarAes.h" />
189.1134 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarHandler.h" />
189.1135 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarHeader.h" />
189.1136 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarIn.h" />
189.1137 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarItem.h" />
189.1138 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarVolumeInStream.h" />
189.1139 -    <ClInclude Include="CPP\7zip\Common\RegisterArc.h" />
189.1140 -    <ClInclude Include="CPP\7zip\Common\RegisterCodec.h" />
189.1141 -    <ClInclude Include="C\RotateDefs.h" />
189.1142 -    <ClInclude Include="CPP\7zip\Crypto\Sha1.h" />
189.1143 -    <ClInclude Include="C\Sha256.h" />
189.1144 -    <ClInclude Include="CPP\7zip\Compress\ShrinkDecoder.h" />
189.1145 -    <ClInclude Include="C\Sort.h" />
189.1146 -    <ClInclude Include="CPP\7zip\Archive\Split\SplitHandler.h" />
189.1147 -    <ClInclude Include="CPP\7zip\Archive\Common\StdAfx.h" />
189.1148 -    <ClInclude Include="CPP\7zip\Archive\Rar\StdAfx.h" />
189.1149 -    <ClInclude Include="CPP\7zip\Archive\BZip2\StdAfx.h" />
189.1150 -    <ClInclude Include="CPP\Windows\StdAfx.h" />
189.1151 -    <ClInclude Include="CPP\7zip\Archive\7z\StdAfx.h" />
189.1152 -    <ClInclude Include="CPP\7zip\Archive\StdAfx.h" />
189.1153 -    <ClInclude Include="CPP\7zip\Compress\StdAfx.h" />
189.1154 -    <ClInclude Include="CPP\7zip\Bundles\Format7zF\StdAfx.h" />
189.1155 -    <ClInclude Include="CPP\7zip\Archive\GZip\StdAfx.h" />
189.1156 -    <ClInclude Include="CPP\7zip\Crypto\StdAfx.h" />
189.1157 -    <ClInclude Include="CPP\7zip\Archive\Tar\StdAfx.h" />
189.1158 -    <ClInclude Include="CPP\7zip\Archive\Zip\StdAfx.h" />
189.1159 -    <ClInclude Include="CPP\7zip\Archive\Lzh\StdAfx.h" />
189.1160 -    <ClInclude Include="CPP\7zip\Common\StdAfx.h" />
189.1161 -    <ClInclude Include="CPP\7zip\Archive\Split\StdAfx.h" />
189.1162 -    <ClInclude Include="CPP\7zip\Archive\Lzma\StdAfx.h" />
189.1163 -    <ClInclude Include="CPP\7zip\Common\StreamBinder.h" />
189.1164 -    <ClInclude Include="CPP\7zip\Common\StreamObjects.h" />
189.1165 -    <ClInclude Include="CPP\7zip\Common\StreamUtils.h" />
189.1166 -    <ClInclude Include="CPP\Common\StringConvert.h" />
189.1167 -    <ClInclude Include="CPP\Common\StringToInt.h" />
189.1168 -    <ClInclude Include="CPP\Windows\Synchronization.h" />
189.1169 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarHandler.h" />
189.1170 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarHeader.h" />
189.1171 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarIn.h" />
189.1172 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarItem.h" />
189.1173 -    <ClInclude Include="CPP\Windows\Thread.h" />
189.1174 -    <ClInclude Include="C\Threads.h" />
189.1175 -    <ClInclude Include="CPP\Windows\Time.h" />
189.1176 -    <ClInclude Include="CPP\Common\Types.h" />
189.1177 -    <ClInclude Include="C\Types.h" />
189.1178 -    <ClInclude Include="CPP\Common\UTFConvert.h" />
189.1179 -    <ClInclude Include="CPP\7zip\Common\VirtThread.h" />
189.1180 -    <ClInclude Include="CPP\Common\Wildcard.h" />
189.1181 -    <ClInclude Include="CPP\7zip\Crypto\WzAes.h" />
189.1182 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipCompressionMode.h" />
189.1183 -    <ClInclude Include="CPP\7zip\Crypto\ZipCrypto.h" />
189.1184 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipHandler.h" />
189.1185 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipHeader.h" />
189.1186 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipIn.h" />
189.1187 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipItem.h" />
189.1188 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipItemEx.h" />
189.1189 -    <ClInclude Include="CPP\7zip\Crypto\ZipStrong.h" />
189.1190 -    <ClInclude Include="CPP\7zip\Compress\ZlibDecoder.h" />
189.1191 -  </ItemGroup>
189.1192 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
189.1193 -  <ImportGroup Label="ExtensionTargets">
189.1194 -    <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
189.1195 -  </ImportGroup>
189.1196 -</Project>
189.1197 \ No newline at end of file
   190.1 --- a/src/win32/7zip/7z/7zip_2010.vcxproj.filters	Sat Mar 03 10:54:39 2012 -0600
   190.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   190.3 @@ -1,1101 +0,0 @@
   190.4 -<?xml version="1.0" encoding="utf-8"?>
   190.5 -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   190.6 -  <ItemGroup>
   190.7 -    <Filter Include="7zip">
   190.8 -      <UniqueIdentifier>{640011be-3f4f-4873-8d35-29603260353a}</UniqueIdentifier>
   190.9 -    </Filter>
  190.10 -    <Filter Include="Archive">
  190.11 -      <UniqueIdentifier>{ca6f9c4b-9f5f-48ad-a31c-af98fcd62e40}</UniqueIdentifier>
  190.12 -    </Filter>
  190.13 -    <Filter Include="Archive\7z">
  190.14 -      <UniqueIdentifier>{92298691-8079-41ab-97b4-ea8c5d57705d}</UniqueIdentifier>
  190.15 -    </Filter>
  190.16 -    <Filter Include="Archive\Archive common">
  190.17 -      <UniqueIdentifier>{07c1f99d-328c-4292-bcae-756aa615b6b8}</UniqueIdentifier>
  190.18 -    </Filter>
  190.19 -    <Filter Include="Archive\bz2">
  190.20 -      <UniqueIdentifier>{d4404f87-37f6-47c0-84ad-28f886e050f1}</UniqueIdentifier>
  190.21 -    </Filter>
  190.22 -    <Filter Include="Archive\GZip">
  190.23 -      <UniqueIdentifier>{2da83f5f-49e0-4bf4-94df-5f71548d513e}</UniqueIdentifier>
  190.24 -    </Filter>
  190.25 -    <Filter Include="Archive\Lzh">
  190.26 -      <UniqueIdentifier>{c294dbd6-e157-4b12-a25f-f86c6f33c0ac}</UniqueIdentifier>
  190.27 -    </Filter>
  190.28 -    <Filter Include="Archive\Lzma Ar">
  190.29 -      <UniqueIdentifier>{cf17b1b3-505a-4072-82c3-a558076da4c9}</UniqueIdentifier>
  190.30 -    </Filter>
  190.31 -    <Filter Include="Archive\Rar">
  190.32 -      <UniqueIdentifier>{2c848328-adab-4c70-8850-0cd99749a22a}</UniqueIdentifier>
  190.33 -    </Filter>
  190.34 -    <Filter Include="Archive\Split">
  190.35 -      <UniqueIdentifier>{681491fd-a85a-4c9d-979c-16310a4bc7d2}</UniqueIdentifier>
  190.36 -    </Filter>
  190.37 -    <Filter Include="Archive\Tar">
  190.38 -      <UniqueIdentifier>{f3894462-e945-41f6-8e24-095eb40a5366}</UniqueIdentifier>
  190.39 -    </Filter>
  190.40 -    <Filter Include="Archive\Zip">
  190.41 -      <UniqueIdentifier>{67371b0c-95dc-4dc8-8783-b64dff05d198}</UniqueIdentifier>
  190.42 -    </Filter>
  190.43 -    <Filter Include="C">
  190.44 -      <UniqueIdentifier>{5ea4ccf3-187c-4ab5-a59c-a7ad7eec0faa}</UniqueIdentifier>
  190.45 -    </Filter>
  190.46 -    <Filter Include="Common">
  190.47 -      <UniqueIdentifier>{f50e973f-7173-4cde-a755-fb5e8d91ab0e}</UniqueIdentifier>
  190.48 -    </Filter>
  190.49 -    <Filter Include="Compress">
  190.50 -      <UniqueIdentifier>{6af22ddd-1f4e-4843-a216-ec5e10c4fa28}</UniqueIdentifier>
  190.51 -    </Filter>
  190.52 -    <Filter Include="Compress\7z Compress">
  190.53 -      <UniqueIdentifier>{79334f59-b7f7-4c4f-86af-408256cd4abe}</UniqueIdentifier>
  190.54 -    </Filter>
  190.55 -    <Filter Include="Compress\Bit Coder">
  190.56 -      <UniqueIdentifier>{489a1d17-d337-4891-9071-61795accd837}</UniqueIdentifier>
  190.57 -    </Filter>
  190.58 -    <Filter Include="Compress\BZip2 Compress">
  190.59 -      <UniqueIdentifier>{97f1da29-65d5-42e9-9d87-6e25185e01c6}</UniqueIdentifier>
  190.60 -    </Filter>
  190.61 -    <Filter Include="Compress\PPMD">
  190.62 -      <UniqueIdentifier>{6ae17cf5-91d4-437c-84ea-e70b79c5f915}</UniqueIdentifier>
  190.63 -    </Filter>
  190.64 -    <Filter Include="Compress\Rar Compress">
  190.65 -      <UniqueIdentifier>{17dd5db8-6972-4bde-a450-a16aded15a07}</UniqueIdentifier>
  190.66 -    </Filter>
  190.67 -    <Filter Include="Compress\Zip Compress">
  190.68 -      <UniqueIdentifier>{3a7d5a57-f03c-4adb-8101-4dd3c84d9514}</UniqueIdentifier>
  190.69 -    </Filter>
  190.70 -    <Filter Include="Crypto">
  190.71 -      <UniqueIdentifier>{7164d745-e58e-44a4-bfe9-037f44bee447}</UniqueIdentifier>
  190.72 -    </Filter>
  190.73 -    <Filter Include="Headers">
  190.74 -      <UniqueIdentifier>{33eeb3f2-448c-4542-b150-472136c39410}</UniqueIdentifier>
  190.75 -    </Filter>
  190.76 -    <Filter Include="Register">
  190.77 -      <UniqueIdentifier>{6f4b2871-2e91-4697-a7f5-6596fae9ac6e}</UniqueIdentifier>
  190.78 -    </Filter>
  190.79 -    <Filter Include="Windows">
  190.80 -      <UniqueIdentifier>{c1dbfe74-7113-46fd-80cf-bb76de09bf98}</UniqueIdentifier>
  190.81 -    </Filter>
  190.82 -  </ItemGroup>
  190.83 -  <ItemGroup>
  190.84 -    <ClCompile Include="CPP\7zip\Archive\7z\7zCompressionMode.cpp">
  190.85 -      <Filter>Archive\7z</Filter>
  190.86 -    </ClCompile>
  190.87 -    <ClCompile Include="CPP\7zip\Archive\7z\7zDecode.cpp">
  190.88 -      <Filter>Archive\7z</Filter>
  190.89 -    </ClCompile>
  190.90 -    <ClCompile Include="CPP\7zip\Archive\7z\7zExtract.cpp">
  190.91 -      <Filter>Archive\7z</Filter>
  190.92 -    </ClCompile>
  190.93 -    <ClCompile Include="CPP\7zip\Archive\7z\7zFolderInStream.cpp">
  190.94 -      <Filter>Archive\7z</Filter>
  190.95 -    </ClCompile>
  190.96 -    <ClCompile Include="CPP\7zip\Archive\7z\7zFolderOutStream.cpp">
  190.97 -      <Filter>Archive\7z</Filter>
  190.98 -    </ClCompile>
  190.99 -    <ClCompile Include="CPP\7zip\Archive\7z\7zHandler.cpp">
 190.100 -      <Filter>Archive\7z</Filter>
 190.101 -    </ClCompile>
 190.102 -    <ClCompile Include="CPP\7zip\Archive\7z\7zHeader.cpp">
 190.103 -      <Filter>Archive\7z</Filter>
 190.104 -    </ClCompile>
 190.105 -    <ClCompile Include="CPP\7zip\Archive\7z\7zIn.cpp">
 190.106 -      <Filter>Archive\7z</Filter>
 190.107 -    </ClCompile>
 190.108 -    <ClCompile Include="CPP\7zip\Archive\7z\7zProperties.cpp">
 190.109 -      <Filter>Archive\7z</Filter>
 190.110 -    </ClCompile>
 190.111 -    <ClCompile Include="CPP\7zip\Archive\7z\7zRegister.cpp">
 190.112 -      <Filter>Register</Filter>
 190.113 -    </ClCompile>
 190.114 -    <ClCompile Include="CPP\7zip\Archive\7z\7zSpecStream.cpp">
 190.115 -      <Filter>Archive\7z</Filter>
 190.116 -    </ClCompile>
 190.117 -    <ClCompile Include="CPP\7zip\Archive\ArchiveExports.cpp">
 190.118 -      <Filter>Register</Filter>
 190.119 -    </ClCompile>
 190.120 -    <ClCompile Include="CPP\7zip\Archive\BZip2\bz2Register.cpp">
 190.121 -      <Filter>Register</Filter>
 190.122 -    </ClCompile>
 190.123 -    <ClCompile Include="CPP\7zip\Archive\BZip2\BZip2Handler.cpp">
 190.124 -      <Filter>Archive\bz2</Filter>
 190.125 -    </ClCompile>
 190.126 -    <ClCompile Include="CPP\7zip\Archive\Common\CoderMixer2.cpp">
 190.127 -      <Filter>Archive\Archive common</Filter>
 190.128 -    </ClCompile>
 190.129 -    <ClCompile Include="CPP\7zip\Archive\Common\CoderMixer2MT.cpp">
 190.130 -      <Filter>Archive\Archive common</Filter>
 190.131 -    </ClCompile>
 190.132 -    <ClCompile Include="CPP\7zip\Archive\Common\DummyOutStream.cpp">
 190.133 -      <Filter>Archive\Archive common</Filter>
 190.134 -    </ClCompile>
 190.135 -    <ClCompile Include="CPP\7zip\Archive\Common\FindSignature.cpp">
 190.136 -      <Filter>Archive\Archive common</Filter>
 190.137 -    </ClCompile>
 190.138 -    <ClCompile Include="CPP\7zip\Archive\Common\InStreamWithCRC.cpp">
 190.139 -      <Filter>Archive\Archive common</Filter>
 190.140 -    </ClCompile>
 190.141 -    <ClCompile Include="CPP\7zip\Archive\Common\ItemNameUtils.cpp">
 190.142 -      <Filter>Archive\Archive common</Filter>
 190.143 -    </ClCompile>
 190.144 -    <ClCompile Include="CPP\7zip\Archive\Common\MultiStream.cpp">
 190.145 -      <Filter>Archive\Archive common</Filter>
 190.146 -    </ClCompile>
 190.147 -    <ClCompile Include="CPP\7zip\Archive\Common\OutStreamWithCRC.cpp">
 190.148 -      <Filter>Archive\Archive common</Filter>
 190.149 -    </ClCompile>
 190.150 -    <ClCompile Include="CPP\7zip\Archive\Common\ParseProperties.cpp">
 190.151 -      <Filter>Archive\Archive common</Filter>
 190.152 -    </ClCompile>
 190.153 -    <ClCompile Include="CPP\7zip\Archive\DllExports2.cpp">
 190.154 -      <Filter>Register</Filter>
 190.155 -    </ClCompile>
 190.156 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipHandler.cpp">
 190.157 -      <Filter>Archive\GZip</Filter>
 190.158 -    </ClCompile>
 190.159 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipHeader.cpp">
 190.160 -      <Filter>Archive\GZip</Filter>
 190.161 -    </ClCompile>
 190.162 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipIn.cpp">
 190.163 -      <Filter>Archive\GZip</Filter>
 190.164 -    </ClCompile>
 190.165 -    <ClCompile Include="CPP\7zip\Archive\GZip\GZipRegister.cpp">
 190.166 -      <Filter>Register</Filter>
 190.167 -    </ClCompile>
 190.168 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhCRC.cpp">
 190.169 -      <Filter>Archive\Lzh</Filter>
 190.170 -    </ClCompile>
 190.171 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhHandler.cpp">
 190.172 -      <Filter>Archive\Lzh</Filter>
 190.173 -    </ClCompile>
 190.174 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhIn.cpp">
 190.175 -      <Filter>Archive\Lzh</Filter>
 190.176 -    </ClCompile>
 190.177 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.cpp">
 190.178 -      <Filter>Archive\Lzh</Filter>
 190.179 -    </ClCompile>
 190.180 -    <ClCompile Include="CPP\7zip\Archive\Lzh\LzhRegister.cpp">
 190.181 -      <Filter>Register</Filter>
 190.182 -    </ClCompile>
 190.183 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaArcRegister.cpp">
 190.184 -      <Filter>Register</Filter>
 190.185 -    </ClCompile>
 190.186 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaFiltersDecode.cpp">
 190.187 -      <Filter>Archive\Lzma Ar</Filter>
 190.188 -    </ClCompile>
 190.189 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaHandler.cpp">
 190.190 -      <Filter>Archive\Lzma Ar</Filter>
 190.191 -    </ClCompile>
 190.192 -    <ClCompile Include="CPP\7zip\Archive\Lzma\LzmaIn.cpp">
 190.193 -      <Filter>Archive\Lzma Ar</Filter>
 190.194 -    </ClCompile>
 190.195 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarHandler.cpp">
 190.196 -      <Filter>Archive\Rar</Filter>
 190.197 -    </ClCompile>
 190.198 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarHeader.cpp">
 190.199 -      <Filter>Archive\Rar</Filter>
 190.200 -    </ClCompile>
 190.201 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarIn.cpp">
 190.202 -      <Filter>Archive\Rar</Filter>
 190.203 -    </ClCompile>
 190.204 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarItem.cpp">
 190.205 -      <Filter>Archive\Rar</Filter>
 190.206 -    </ClCompile>
 190.207 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarRegister.cpp">
 190.208 -      <Filter>Register</Filter>
 190.209 -    </ClCompile>
 190.210 -    <ClCompile Include="CPP\7zip\Archive\Rar\RarVolumeInStream.cpp">
 190.211 -      <Filter>Archive\Rar</Filter>
 190.212 -    </ClCompile>
 190.213 -    <ClCompile Include="CPP\7zip\Archive\Split\SplitHandler.cpp">
 190.214 -      <Filter>Archive\Split</Filter>
 190.215 -    </ClCompile>
 190.216 -    <ClCompile Include="CPP\7zip\Archive\Split\SplitRegister.cpp">
 190.217 -      <Filter>Register</Filter>
 190.218 -    </ClCompile>
 190.219 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarHandler.cpp">
 190.220 -      <Filter>Archive\Tar</Filter>
 190.221 -    </ClCompile>
 190.222 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarHeader.cpp">
 190.223 -      <Filter>Archive\Tar</Filter>
 190.224 -    </ClCompile>
 190.225 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarIn.cpp">
 190.226 -      <Filter>Archive\Tar</Filter>
 190.227 -    </ClCompile>
 190.228 -    <ClCompile Include="CPP\7zip\Archive\Tar\TarRegister.cpp">
 190.229 -      <Filter>Register</Filter>
 190.230 -    </ClCompile>
 190.231 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipHandler.cpp">
 190.232 -      <Filter>Archive\Zip</Filter>
 190.233 -    </ClCompile>
 190.234 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipHeader.cpp">
 190.235 -      <Filter>Archive\Zip</Filter>
 190.236 -    </ClCompile>
 190.237 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipIn.cpp">
 190.238 -      <Filter>Archive\Zip</Filter>
 190.239 -    </ClCompile>
 190.240 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipItem.cpp">
 190.241 -      <Filter>Archive\Zip</Filter>
 190.242 -    </ClCompile>
 190.243 -    <ClCompile Include="CPP\7zip\Archive\Zip\ZipRegister.cpp">
 190.244 -      <Filter>Register</Filter>
 190.245 -    </ClCompile>
 190.246 -    <ClCompile Include="CPP\7zip\Common\CreateCoder.cpp">
 190.247 -      <Filter>Register</Filter>
 190.248 -    </ClCompile>
 190.249 -    <ClCompile Include="CPP\7zip\Common\FilterCoder.cpp">
 190.250 -      <Filter>7zip</Filter>
 190.251 -    </ClCompile>
 190.252 -    <ClCompile Include="CPP\7zip\Common\InBuffer.cpp">
 190.253 -      <Filter>7zip</Filter>
 190.254 -    </ClCompile>
 190.255 -    <ClCompile Include="CPP\7zip\Common\InOutTempBuffer.cpp">
 190.256 -      <Filter>7zip</Filter>
 190.257 -    </ClCompile>
 190.258 -    <ClCompile Include="CPP\7zip\Common\LimitedStreams.cpp">
 190.259 -      <Filter>7zip</Filter>
 190.260 -    </ClCompile>
 190.261 -    <ClCompile Include="CPP\7zip\Common\LockedStream.cpp">
 190.262 -      <Filter>7zip</Filter>
 190.263 -    </ClCompile>
 190.264 -    <ClCompile Include="CPP\7zip\Common\MemBlocks.cpp">
 190.265 -      <Filter>7zip</Filter>
 190.266 -    </ClCompile>
 190.267 -    <ClCompile Include="CPP\7zip\Common\MethodId.cpp">
 190.268 -      <Filter>7zip</Filter>
 190.269 -    </ClCompile>
 190.270 -    <ClCompile Include="CPP\7zip\Common\MethodProps.cpp">
 190.271 -      <Filter>7zip</Filter>
 190.272 -    </ClCompile>
 190.273 -    <ClCompile Include="CPP\7zip\Common\OffsetStream.cpp">
 190.274 -      <Filter>7zip</Filter>
 190.275 -    </ClCompile>
 190.276 -    <ClCompile Include="CPP\7zip\Common\OutBuffer.cpp">
 190.277 -      <Filter>7zip</Filter>
 190.278 -    </ClCompile>
 190.279 -    <ClCompile Include="CPP\7zip\Common\OutMemStream.cpp">
 190.280 -      <Filter>7zip</Filter>
 190.281 -    </ClCompile>
 190.282 -    <ClCompile Include="CPP\7zip\Common\ProgressMt.cpp">
 190.283 -      <Filter>7zip</Filter>
 190.284 -    </ClCompile>
 190.285 -    <ClCompile Include="CPP\7zip\Common\ProgressUtils.cpp">
 190.286 -      <Filter>7zip</Filter>
 190.287 -    </ClCompile>
 190.288 -    <ClCompile Include="CPP\7zip\Common\StreamBinder.cpp">
 190.289 -      <Filter>7zip</Filter>
 190.290 -    </ClCompile>
 190.291 -    <ClCompile Include="CPP\7zip\Common\StreamObjects.cpp">
 190.292 -      <Filter>7zip</Filter>
 190.293 -    </ClCompile>
 190.294 -    <ClCompile Include="CPP\7zip\Common\StreamUtils.cpp">
 190.295 -      <Filter>7zip</Filter>
 190.296 -    </ClCompile>
 190.297 -    <ClCompile Include="CPP\7zip\Common\VirtThread.cpp">
 190.298 -      <Filter>7zip</Filter>
 190.299 -    </ClCompile>
 190.300 -    <ClCompile Include="CPP\7zip\Compress\Bcj2Coder.cpp">
 190.301 -      <Filter>Compress\7z Compress</Filter>
 190.302 -    </ClCompile>
 190.303 -    <ClCompile Include="CPP\7zip\Compress\Bcj2Register.cpp">
 190.304 -      <Filter>Register</Filter>
 190.305 -    </ClCompile>
 190.306 -    <ClCompile Include="CPP\7zip\Compress\BcjCoder.cpp">
 190.307 -      <Filter>Compress\7z Compress</Filter>
 190.308 -    </ClCompile>
 190.309 -    <ClCompile Include="CPP\7zip\Compress\BcjRegister.cpp">
 190.310 -      <Filter>Register</Filter>
 190.311 -    </ClCompile>
 190.312 -    <ClCompile Include="CPP\7zip\Compress\BitlDecoder.cpp">
 190.313 -      <Filter>Compress\Bit Coder</Filter>
 190.314 -    </ClCompile>
 190.315 -    <ClCompile Include="CPP\7zip\Compress\BranchCoder.cpp">
 190.316 -      <Filter>Compress\7z Compress</Filter>
 190.317 -    </ClCompile>
 190.318 -    <ClCompile Include="CPP\7zip\Compress\BranchMisc.cpp">
 190.319 -      <Filter>Compress\7z Compress</Filter>
 190.320 -    </ClCompile>
 190.321 -    <ClCompile Include="CPP\7zip\Compress\BranchRegister.cpp">
 190.322 -      <Filter>Register</Filter>
 190.323 -    </ClCompile>
 190.324 -    <ClCompile Include="CPP\7zip\Compress\ByteSwap.cpp">
 190.325 -      <Filter>Compress\7z Compress</Filter>
 190.326 -    </ClCompile>
 190.327 -    <ClCompile Include="CPP\7zip\Compress\ByteSwapRegister.cpp">
 190.328 -      <Filter>Register</Filter>
 190.329 -    </ClCompile>
 190.330 -    <ClCompile Include="CPP\7zip\Compress\BZip2Crc.cpp">
 190.331 -      <Filter>Compress\BZip2 Compress</Filter>
 190.332 -    </ClCompile>
 190.333 -    <ClCompile Include="CPP\7zip\Compress\BZip2Decoder.cpp">
 190.334 -      <Filter>Compress\BZip2 Compress</Filter>
 190.335 -    </ClCompile>
 190.336 -    <ClCompile Include="CPP\7zip\Compress\BZip2Register.cpp">
 190.337 -      <Filter>Register</Filter>
 190.338 -    </ClCompile>
 190.339 -    <ClCompile Include="CPP\7zip\Compress\CodecExports.cpp">
 190.340 -      <Filter>Register</Filter>
 190.341 -    </ClCompile>
 190.342 -    <ClCompile Include="CPP\7zip\Compress\CopyCoder.cpp">
 190.343 -      <Filter>Compress\7z Compress</Filter>
 190.344 -    </ClCompile>
 190.345 -    <ClCompile Include="CPP\7zip\Compress\CopyRegister.cpp">
 190.346 -      <Filter>Register</Filter>
 190.347 -    </ClCompile>
 190.348 -    <ClCompile Include="CPP\7zip\Compress\Deflate64Register.cpp">
 190.349 -      <Filter>Register</Filter>
 190.350 -    </ClCompile>
 190.351 -    <ClCompile Include="CPP\7zip\Compress\DeflateDecoder.cpp">
 190.352 -      <Filter>Compress\Zip Compress</Filter>
 190.353 -    </ClCompile>
 190.354 -    <ClCompile Include="CPP\7zip\Compress\DeflateNsisRegister.cpp">
 190.355 -      <Filter>Register</Filter>
 190.356 -    </ClCompile>
 190.357 -    <ClCompile Include="CPP\7zip\Compress\DeflateRegister.cpp">
 190.358 -      <Filter>Register</Filter>
 190.359 -    </ClCompile>
 190.360 -    <ClCompile Include="CPP\7zip\Compress\ImplodeDecoder.cpp">
 190.361 -      <Filter>Compress\Zip Compress</Filter>
 190.362 -    </ClCompile>
 190.363 -    <ClCompile Include="CPP\7zip\Compress\ImplodeHuffmanDecoder.cpp">
 190.364 -      <Filter>Compress\Zip Compress</Filter>
 190.365 -    </ClCompile>
 190.366 -    <ClCompile Include="CPP\7zip\Compress\LzhDecoder.cpp">
 190.367 -      <Filter>Compress</Filter>
 190.368 -    </ClCompile>
 190.369 -    <ClCompile Include="CPP\7zip\Compress\LzmaDecoder.cpp">
 190.370 -      <Filter>Compress\7z Compress</Filter>
 190.371 -    </ClCompile>
 190.372 -    <ClCompile Include="CPP\7zip\Compress\LzmaRegister.cpp">
 190.373 -      <Filter>Register</Filter>
 190.374 -    </ClCompile>
 190.375 -    <ClCompile Include="CPP\7zip\Compress\LzOutWindow.cpp">
 190.376 -      <Filter>Compress</Filter>
 190.377 -    </ClCompile>
 190.378 -    <ClCompile Include="CPP\7zip\Compress\PpmdDecoder.cpp">
 190.379 -      <Filter>Compress\PPMD</Filter>
 190.380 -    </ClCompile>
 190.381 -    <ClCompile Include="CPP\7zip\Compress\PpmdRegister.cpp">
 190.382 -      <Filter>Register</Filter>
 190.383 -    </ClCompile>
 190.384 -    <ClCompile Include="CPP\7zip\Compress\Rar1Decoder.cpp">
 190.385 -      <Filter>Compress\Rar Compress</Filter>
 190.386 -    </ClCompile>
 190.387 -    <ClCompile Include="CPP\7zip\Compress\Rar2Decoder.cpp">
 190.388 -      <Filter>Compress\Rar Compress</Filter>
 190.389 -    </ClCompile>
 190.390 -    <ClCompile Include="CPP\7zip\Compress\Rar3Decoder.cpp">
 190.391 -      <Filter>Compress\Rar Compress</Filter>
 190.392 -    </ClCompile>
 190.393 -    <ClCompile Include="CPP\7zip\Compress\Rar3Vm.cpp">
 190.394 -      <Filter>Compress\Rar Compress</Filter>
 190.395 -    </ClCompile>
 190.396 -    <ClCompile Include="CPP\7zip\Compress\RarCodecsRegister.cpp">
 190.397 -      <Filter>Register</Filter>
 190.398 -    </ClCompile>
 190.399 -    <ClCompile Include="CPP\7zip\Compress\ShrinkDecoder.cpp">
 190.400 -      <Filter>Compress\Zip Compress</Filter>
 190.401 -    </ClCompile>
 190.402 -    <ClCompile Include="CPP\7zip\Compress\ZlibDecoder.cpp">
 190.403 -      <Filter>Compress\Zip Compress</Filter>
 190.404 -    </ClCompile>
 190.405 -    <ClCompile Include="CPP\7zip\Crypto\7zAes.cpp">
 190.406 -      <Filter>Crypto</Filter>
 190.407 -    </ClCompile>
 190.408 -    <ClCompile Include="CPP\7zip\Crypto\7zAesRegister.cpp">
 190.409 -      <Filter>Register</Filter>
 190.410 -    </ClCompile>
 190.411 -    <ClCompile Include="CPP\7zip\Crypto\HmacSha1.cpp">
 190.412 -      <Filter>Crypto</Filter>
 190.413 -    </ClCompile>
 190.414 -    <ClCompile Include="CPP\7zip\Crypto\MyAes.cpp">
 190.415 -      <Filter>Crypto</Filter>
 190.416 -    </ClCompile>
 190.417 -    <ClCompile Include="CPP\7zip\Crypto\Pbkdf2HmacSha1.cpp">
 190.418 -      <Filter>Crypto</Filter>
 190.419 -    </ClCompile>
 190.420 -    <ClCompile Include="CPP\7zip\Crypto\RandGen.cpp">
 190.421 -      <Filter>Crypto</Filter>
 190.422 -    </ClCompile>
 190.423 -    <ClCompile Include="CPP\7zip\Crypto\Rar20Crypto.cpp">
 190.424 -      <Filter>Crypto</Filter>
 190.425 -    </ClCompile>
 190.426 -    <ClCompile Include="CPP\7zip\Crypto\RarAes.cpp">
 190.427 -      <Filter>Crypto</Filter>
 190.428 -    </ClCompile>
 190.429 -    <ClCompile Include="CPP\7zip\Crypto\Sha1.cpp">
 190.430 -      <Filter>Crypto</Filter>
 190.431 -    </ClCompile>
 190.432 -    <ClCompile Include="CPP\7zip\Crypto\WzAes.cpp">
 190.433 -      <Filter>Crypto</Filter>
 190.434 -    </ClCompile>
 190.435 -    <ClCompile Include="CPP\7zip\Crypto\ZipCrypto.cpp">
 190.436 -      <Filter>Crypto</Filter>
 190.437 -    </ClCompile>
 190.438 -    <ClCompile Include="CPP\7zip\Crypto\ZipStrong.cpp">
 190.439 -      <Filter>Crypto</Filter>
 190.440 -    </ClCompile>
 190.441 -    <ClCompile Include="CPP\Common\CRC.cpp">
 190.442 -      <Filter>Common</Filter>
 190.443 -    </ClCompile>
 190.444 -    <ClCompile Include="CPP\Common\IntToString.cpp">
 190.445 -      <Filter>Common</Filter>
 190.446 -    </ClCompile>
 190.447 -    <ClCompile Include="CPP\Common\MyMap.cpp">
 190.448 -      <Filter>Common</Filter>
 190.449 -    </ClCompile>
 190.450 -    <ClCompile Include="CPP\Common\MyString.cpp">
 190.451 -      <Filter>Common</Filter>
 190.452 -    </ClCompile>
 190.453 -    <ClCompile Include="CPP\Common\MyVector.cpp">
 190.454 -      <Filter>Common</Filter>
 190.455 -    </ClCompile>
 190.456 -    <ClCompile Include="CPP\Common\MyXml.cpp">
 190.457 -      <Filter>Common</Filter>
 190.458 -    </ClCompile>
 190.459 -    <ClCompile Include="CPP\Common\NewHandler.cpp">
 190.460 -      <Filter>Common</Filter>
 190.461 -    </ClCompile>
 190.462 -    <ClCompile Include="CPP\Common\StringConvert.cpp">
 190.463 -      <Filter>Common</Filter>
 190.464 -    </ClCompile>
 190.465 -    <ClCompile Include="CPP\Common\StringToInt.cpp">
 190.466 -      <Filter>Common</Filter>
 190.467 -    </ClCompile>
 190.468 -    <ClCompile Include="CPP\Common\UTFConvert.cpp">
 190.469 -      <Filter>Common</Filter>
 190.470 -    </ClCompile>
 190.471 -    <ClCompile Include="CPP\Common\Wildcard.cpp">
 190.472 -      <Filter>Common</Filter>
 190.473 -    </ClCompile>
 190.474 -    <ClCompile Include="CPP\Windows\FileDir.cpp">
 190.475 -      <Filter>Windows</Filter>
 190.476 -    </ClCompile>
 190.477 -    <ClCompile Include="CPP\Windows\FileFind.cpp">
 190.478 -      <Filter>Windows</Filter>
 190.479 -    </ClCompile>
 190.480 -    <ClCompile Include="CPP\Windows\FileIO.cpp">
 190.481 -      <Filter>Windows</Filter>
 190.482 -    </ClCompile>
 190.483 -    <ClCompile Include="CPP\Windows\PropVariant.cpp">
 190.484 -      <Filter>Windows</Filter>
 190.485 -    </ClCompile>
 190.486 -    <ClCompile Include="CPP\Windows\Time.cpp">
 190.487 -      <Filter>Windows</Filter>
 190.488 -    </ClCompile>
 190.489 -    <ClCompile Include="C\7zCrc.c">
 190.490 -      <Filter>C</Filter>
 190.491 -    </ClCompile>
 190.492 -    <ClCompile Include="C\Aes.c">
 190.493 -      <Filter>C</Filter>
 190.494 -    </ClCompile>
 190.495 -    <ClCompile Include="C\Alloc.c">
 190.496 -      <Filter>C</Filter>
 190.497 -    </ClCompile>
 190.498 -    <ClCompile Include="C\Bra.c">
 190.499 -      <Filter>C</Filter>
 190.500 -    </ClCompile>
 190.501 -    <ClCompile Include="C\Bra86.c">
 190.502 -      <Filter>C</Filter>
 190.503 -    </ClCompile>
 190.504 -    <ClCompile Include="C\BraIA64.c">
 190.505 -      <Filter>C</Filter>
 190.506 -    </ClCompile>
 190.507 -    <ClCompile Include="C\BwtSort.c">
 190.508 -      <Filter>C</Filter>
 190.509 -    </ClCompile>
 190.510 -    <ClCompile Include="C\HuffEnc.c">
 190.511 -      <Filter>C</Filter>
 190.512 -    </ClCompile>
 190.513 -    <ClCompile Include="C\LzFind.c">
 190.514 -      <Filter>C</Filter>
 190.515 -    </ClCompile>
 190.516 -    <ClCompile Include="C\LzFindMt.c">
 190.517 -      <Filter>C</Filter>
 190.518 -    </ClCompile>
 190.519 -    <ClCompile Include="C\LzmaDec.c">
 190.520 -      <Filter>C</Filter>
 190.521 -    </ClCompile>
 190.522 -    <ClCompile Include="C\LzmaEnc.c">
 190.523 -      <Filter>C</Filter>
 190.524 -    </ClCompile>
 190.525 -    <ClCompile Include="C\Sha256.c">
 190.526 -      <Filter>C</Filter>
 190.527 -    </ClCompile>
 190.528 -    <ClCompile Include="C\Sort.c">
 190.529 -      <Filter>C</Filter>
 190.530 -    </ClCompile>
 190.531 -    <ClCompile Include="C\Threads.c">
 190.532 -      <Filter>C</Filter>
 190.533 -    </ClCompile>
 190.534 -  </ItemGroup>
 190.535 -  <ItemGroup>
 190.536 -    <ClInclude Include="CPP\7zip\Archive\7z\7zCompressionMode.h">
 190.537 -      <Filter>Headers</Filter>
 190.538 -    </ClInclude>
 190.539 -    <ClInclude Include="CPP\7zip\Archive\7z\7zDecode.h">
 190.540 -      <Filter>Headers</Filter>
 190.541 -    </ClInclude>
 190.542 -    <ClInclude Include="CPP\7zip\Archive\7z\7zFolderInStream.h">
 190.543 -      <Filter>Headers</Filter>
 190.544 -    </ClInclude>
 190.545 -    <ClInclude Include="CPP\7zip\Archive\7z\7zFolderOutStream.h">
 190.546 -      <Filter>Headers</Filter>
 190.547 -    </ClInclude>
 190.548 -    <ClInclude Include="CPP\7zip\Archive\7z\7zHandler.h">
 190.549 -      <Filter>Headers</Filter>
 190.550 -    </ClInclude>
 190.551 -    <ClInclude Include="CPP\7zip\Archive\7z\7zHeader.h">
 190.552 -      <Filter>Headers</Filter>
 190.553 -    </ClInclude>
 190.554 -    <ClInclude Include="CPP\7zip\Archive\7z\7zIn.h">
 190.555 -      <Filter>Headers</Filter>
 190.556 -    </ClInclude>
 190.557 -    <ClInclude Include="CPP\7zip\Archive\7z\7zItem.h">
 190.558 -      <Filter>Headers</Filter>
 190.559 -    </ClInclude>
 190.560 -    <ClInclude Include="CPP\7zip\Archive\7z\7zProperties.h">
 190.561 -      <Filter>Headers</Filter>
 190.562 -    </ClInclude>
 190.563 -    <ClInclude Include="CPP\7zip\Archive\7z\7zSpecStream.h">
 190.564 -      <Filter>Headers</Filter>
 190.565 -    </ClInclude>
 190.566 -    <ClInclude Include="CPP\7zip\Archive\7z\StdAfx.h">
 190.567 -      <Filter>Headers</Filter>
 190.568 -    </ClInclude>
 190.569 -    <ClInclude Include="CPP\7zip\Archive\BZip2\BZip2Handler.h">
 190.570 -      <Filter>Headers</Filter>
 190.571 -    </ClInclude>
 190.572 -    <ClInclude Include="CPP\7zip\Archive\BZip2\BZip2Item.h">
 190.573 -      <Filter>Headers</Filter>
 190.574 -    </ClInclude>
 190.575 -    <ClInclude Include="CPP\7zip\Archive\BZip2\StdAfx.h">
 190.576 -      <Filter>Headers</Filter>
 190.577 -    </ClInclude>
 190.578 -    <ClInclude Include="CPP\7zip\Archive\Common\CoderMixer2.h">
 190.579 -      <Filter>Headers</Filter>
 190.580 -    </ClInclude>
 190.581 -    <ClInclude Include="CPP\7zip\Archive\Common\CoderMixer2MT.h">
 190.582 -      <Filter>Headers</Filter>
 190.583 -    </ClInclude>
 190.584 -    <ClInclude Include="CPP\7zip\Archive\Common\DummyOutStream.h">
 190.585 -      <Filter>Headers</Filter>
 190.586 -    </ClInclude>
 190.587 -    <ClInclude Include="CPP\7zip\Archive\Common\FindSignature.h">
 190.588 -      <Filter>Headers</Filter>
 190.589 -    </ClInclude>
 190.590 -    <ClInclude Include="CPP\7zip\Archive\Common\InStreamWithCRC.h">
 190.591 -      <Filter>Headers</Filter>
 190.592 -    </ClInclude>
 190.593 -    <ClInclude Include="CPP\7zip\Archive\Common\ItemNameUtils.h">
 190.594 -      <Filter>Headers</Filter>
 190.595 -    </ClInclude>
 190.596 -    <ClInclude Include="CPP\7zip\Archive\Common\MultiStream.h">
 190.597 -      <Filter>Headers</Filter>
 190.598 -    </ClInclude>
 190.599 -    <ClInclude Include="CPP\7zip\Archive\Common\OutStreamWithCRC.h">
 190.600 -      <Filter>Headers</Filter>
 190.601 -    </ClInclude>
 190.602 -    <ClInclude Include="CPP\7zip\Archive\Common\ParseProperties.h">
 190.603 -      <Filter>Headers</Filter>
 190.604 -    </ClInclude>
 190.605 -    <ClInclude Include="CPP\7zip\Archive\Common\StdAfx.h">
 190.606 -      <Filter>Headers</Filter>
 190.607 -    </ClInclude>
 190.608 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipHandler.h">
 190.609 -      <Filter>Headers</Filter>
 190.610 -    </ClInclude>
 190.611 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipHeader.h">
 190.612 -      <Filter>Headers</Filter>
 190.613 -    </ClInclude>
 190.614 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipIn.h">
 190.615 -      <Filter>Headers</Filter>
 190.616 -    </ClInclude>
 190.617 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipItem.h">
 190.618 -      <Filter>Headers</Filter>
 190.619 -    </ClInclude>
 190.620 -    <ClInclude Include="CPP\7zip\Archive\GZip\GZipUpdate.h">
 190.621 -      <Filter>Headers</Filter>
 190.622 -    </ClInclude>
 190.623 -    <ClInclude Include="CPP\7zip\Archive\GZip\StdAfx.h">
 190.624 -      <Filter>Headers</Filter>
 190.625 -    </ClInclude>
 190.626 -    <ClInclude Include="CPP\7zip\Archive\IArchive.h">
 190.627 -      <Filter>Headers</Filter>
 190.628 -    </ClInclude>
 190.629 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhCRC.h">
 190.630 -      <Filter>Headers</Filter>
 190.631 -    </ClInclude>
 190.632 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhHandler.h">
 190.633 -      <Filter>Headers</Filter>
 190.634 -    </ClInclude>
 190.635 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhHeader.h">
 190.636 -      <Filter>Headers</Filter>
 190.637 -    </ClInclude>
 190.638 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhIn.h">
 190.639 -      <Filter>Headers</Filter>
 190.640 -    </ClInclude>
 190.641 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhItem.h">
 190.642 -      <Filter>Headers</Filter>
 190.643 -    </ClInclude>
 190.644 -    <ClInclude Include="CPP\7zip\Archive\Lzh\LzhOutStreamWithCRC.h">
 190.645 -      <Filter>Headers</Filter>
 190.646 -    </ClInclude>
 190.647 -    <ClInclude Include="CPP\7zip\Archive\Lzh\StdAfx.h">
 190.648 -      <Filter>Headers</Filter>
 190.649 -    </ClInclude>
 190.650 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaFiltersDecode.h">
 190.651 -      <Filter>Headers</Filter>
 190.652 -    </ClInclude>
 190.653 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaHandler.h">
 190.654 -      <Filter>Headers</Filter>
 190.655 -    </ClInclude>
 190.656 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaIn.h">
 190.657 -      <Filter>Headers</Filter>
 190.658 -    </ClInclude>
 190.659 -    <ClInclude Include="CPP\7zip\Archive\Lzma\LzmaItem.h">
 190.660 -      <Filter>Headers</Filter>
 190.661 -    </ClInclude>
 190.662 -    <ClInclude Include="CPP\7zip\Archive\Lzma\StdAfx.h">
 190.663 -      <Filter>Headers</Filter>
 190.664 -    </ClInclude>
 190.665 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarHandler.h">
 190.666 -      <Filter>Headers</Filter>
 190.667 -    </ClInclude>
 190.668 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarHeader.h">
 190.669 -      <Filter>Headers</Filter>
 190.670 -    </ClInclude>
 190.671 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarIn.h">
 190.672 -      <Filter>Headers</Filter>
 190.673 -    </ClInclude>
 190.674 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarItem.h">
 190.675 -      <Filter>Headers</Filter>
 190.676 -    </ClInclude>
 190.677 -    <ClInclude Include="CPP\7zip\Archive\Rar\RarVolumeInStream.h">
 190.678 -      <Filter>Headers</Filter>
 190.679 -    </ClInclude>
 190.680 -    <ClInclude Include="CPP\7zip\Archive\Rar\StdAfx.h">
 190.681 -      <Filter>Headers</Filter>
 190.682 -    </ClInclude>
 190.683 -    <ClInclude Include="CPP\7zip\Archive\Split\SplitHandler.h">
 190.684 -      <Filter>Headers</Filter>
 190.685 -    </ClInclude>
 190.686 -    <ClInclude Include="CPP\7zip\Archive\Split\StdAfx.h">
 190.687 -      <Filter>Headers</Filter>
 190.688 -    </ClInclude>
 190.689 -    <ClInclude Include="CPP\7zip\Archive\StdAfx.h">
 190.690 -      <Filter>Headers</Filter>
 190.691 -    </ClInclude>
 190.692 -    <ClInclude Include="CPP\7zip\Archive\Tar\StdAfx.h">
 190.693 -      <Filter>Headers</Filter>
 190.694 -    </ClInclude>
 190.695 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarHandler.h">
 190.696 -      <Filter>Headers</Filter>
 190.697 -    </ClInclude>
 190.698 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarHeader.h">
 190.699 -      <Filter>Headers</Filter>
 190.700 -    </ClInclude>
 190.701 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarIn.h">
 190.702 -      <Filter>Headers</Filter>
 190.703 -    </ClInclude>
 190.704 -    <ClInclude Include="CPP\7zip\Archive\Tar\TarItem.h">
 190.705 -      <Filter>Headers</Filter>
 190.706 -    </ClInclude>
 190.707 -    <ClInclude Include="CPP\7zip\Archive\Zip\StdAfx.h">
 190.708 -      <Filter>Headers</Filter>
 190.709 -    </ClInclude>
 190.710 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipCompressionMode.h">
 190.711 -      <Filter>Headers</Filter>
 190.712 -    </ClInclude>
 190.713 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipHandler.h">
 190.714 -      <Filter>Headers</Filter>
 190.715 -    </ClInclude>
 190.716 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipHeader.h">
 190.717 -      <Filter>Headers</Filter>
 190.718 -    </ClInclude>
 190.719 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipIn.h">
 190.720 -      <Filter>Headers</Filter>
 190.721 -    </ClInclude>
 190.722 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipItem.h">
 190.723 -      <Filter>Headers</Filter>
 190.724 -    </ClInclude>
 190.725 -    <ClInclude Include="CPP\7zip\Archive\Zip\ZipItemEx.h">
 190.726 -      <Filter>Headers</Filter>
 190.727 -    </ClInclude>
 190.728 -    <ClInclude Include="CPP\7zip\Bundles\Format7zF\StdAfx.h">
 190.729 -      <Filter>Headers</Filter>
 190.730 -    </ClInclude>
 190.731 -    <ClInclude Include="CPP\7zip\Common\CreateCoder.h">
 190.732 -      <Filter>Headers</Filter>
 190.733 -    </ClInclude>
 190.734 -    <ClInclude Include="CPP\7zip\Common\DeclareArcs.h">
 190.735 -      <Filter>Headers</Filter>
 190.736 -    </ClInclude>
 190.737 -    <ClInclude Include="CPP\7zip\Common\DeclareCodecs.h">
 190.738 -      <Filter>Headers</Filter>
 190.739 -    </ClInclude>
 190.740 -    <ClInclude Include="CPP\7zip\Common\FilterCoder.h">
 190.741 -      <Filter>Headers</Filter>
 190.742 -    </ClInclude>
 190.743 -    <ClInclude Include="CPP\7zip\Common\InBuffer.h">
 190.744 -      <Filter>Headers</Filter>
 190.745 -    </ClInclude>
 190.746 -    <ClInclude Include="CPP\7zip\Common\InOutTempBuffer.h">
 190.747 -      <Filter>Headers</Filter>
 190.748 -    </ClInclude>
 190.749 -    <ClInclude Include="CPP\7zip\Common\LimitedStreams.h">
 190.750 -      <Filter>Headers</Filter>
 190.751 -    </ClInclude>
 190.752 -    <ClInclude Include="CPP\7zip\Common\LockedStream.h">
 190.753 -      <Filter>Headers</Filter>
 190.754 -    </ClInclude>
 190.755 -    <ClInclude Include="CPP\7zip\Common\MemBlocks.h">
 190.756 -      <Filter>Headers</Filter>
 190.757 -    </ClInclude>
 190.758 -    <ClInclude Include="CPP\7zip\Common\MethodId.h">
 190.759 -      <Filter>Headers</Filter>
 190.760 -    </ClInclude>
 190.761 -    <ClInclude Include="CPP\7zip\Common\MethodProps.h">
 190.762 -      <Filter>Headers</Filter>
 190.763 -    </ClInclude>
 190.764 -    <ClInclude Include="CPP\7zip\Common\OffsetStream.h">
 190.765 -      <Filter>Headers</Filter>
 190.766 -    </ClInclude>
 190.767 -    <ClInclude Include="CPP\7zip\Common\OutBuffer.h">
 190.768 -      <Filter>Headers</Filter>
 190.769 -    </ClInclude>
 190.770 -    <ClInclude Include="CPP\7zip\Common\OutMemStream.h">
 190.771 -      <Filter>Headers</Filter>
 190.772 -    </ClInclude>
 190.773 -    <ClInclude Include="CPP\7zip\Common\ProgressMt.h">
 190.774 -      <Filter>Headers</Filter>
 190.775 -    </ClInclude>
 190.776 -    <ClInclude Include="CPP\7zip\Common\ProgressUtils.h">
 190.777 -      <Filter>Headers</Filter>
 190.778 -    </ClInclude>
 190.779 -    <ClInclude Include="CPP\7zip\Common\RegisterArc.h">
 190.780 -      <Filter>Headers</Filter>
 190.781 -    </ClInclude>
 190.782 -    <ClInclude Include="CPP\7zip\Common\RegisterCodec.h">
 190.783 -      <Filter>Headers</Filter>
 190.784 -    </ClInclude>
 190.785 -    <ClInclude Include="CPP\7zip\Common\StdAfx.h">
 190.786 -      <Filter>Headers</Filter>
 190.787 -    </ClInclude>
 190.788 -    <ClInclude Include="CPP\7zip\Common\StreamBinder.h">
 190.789 -      <Filter>Headers</Filter>
 190.790 -    </ClInclude>
 190.791 -    <ClInclude Include="CPP\7zip\Common\StreamObjects.h">
 190.792 -      <Filter>Headers</Filter>
 190.793 -    </ClInclude>
 190.794 -    <ClInclude Include="CPP\7zip\Common\StreamUtils.h">
 190.795 -      <Filter>Headers</Filter>
 190.796 -    </ClInclude>
 190.797 -    <ClInclude Include="CPP\7zip\Common\VirtThread.h">
 190.798 -      <Filter>Headers</Filter>
 190.799 -    </ClInclude>
 190.800 -    <ClInclude Include="CPP\7zip\Compress\Bcj2Coder.h">
 190.801 -      <Filter>Headers</Filter>
 190.802 -    </ClInclude>
 190.803 -    <ClInclude Include="CPP\7zip\Compress\BcjCoder.h">
 190.804 -      <Filter>Headers</Filter>
 190.805 -    </ClInclude>
 190.806 -    <ClInclude Include="CPP\7zip\Compress\BitlDecoder.h">
 190.807 -      <Filter>Headers</Filter>
 190.808 -    </ClInclude>
 190.809 -    <ClInclude Include="CPP\7zip\Compress\BitmDecoder.h">
 190.810 -      <Filter>Headers</Filter>
 190.811 -    </ClInclude>
 190.812 -    <ClInclude Include="CPP\7zip\Compress\BranchCoder.h">
 190.813 -      <Filter>Headers</Filter>
 190.814 -    </ClInclude>
 190.815 -    <ClInclude Include="CPP\7zip\Compress\BranchMisc.h">
 190.816 -      <Filter>Headers</Filter>
 190.817 -    </ClInclude>
 190.818 -    <ClInclude Include="CPP\7zip\Compress\ByteSwap.h">
 190.819 -      <Filter>Headers</Filter>
 190.820 -    </ClInclude>
 190.821 -    <ClInclude Include="CPP\7zip\Compress\BZip2Const.h">
 190.822 -      <Filter>Headers</Filter>
 190.823 -    </ClInclude>
 190.824 -    <ClInclude Include="CPP\7zip\Compress\BZip2Crc.h">
 190.825 -      <Filter>Headers</Filter>
 190.826 -    </ClInclude>
 190.827 -    <ClInclude Include="CPP\7zip\Compress\BZip2Decoder.h">
 190.828 -      <Filter>Headers</Filter>
 190.829 -    </ClInclude>
 190.830 -    <ClInclude Include="CPP\7zip\Compress\CopyCoder.h">
 190.831 -      <Filter>Headers</Filter>
 190.832 -    </ClInclude>
 190.833 -    <ClInclude Include="CPP\7zip\Compress\DeflateConst.h">
 190.834 -      <Filter>Headers</Filter>
 190.835 -    </ClInclude>
 190.836 -    <ClInclude Include="CPP\7zip\Compress\DeflateDecoder.h">
 190.837 -      <Filter>Headers</Filter>
 190.838 -    </ClInclude>
 190.839 -    <ClInclude Include="CPP\7zip\Compress\HuffmanDecoder.h">
 190.840 -      <Filter>Headers</Filter>
 190.841 -    </ClInclude>
 190.842 -    <ClInclude Include="CPP\7zip\Compress\ImplodeDecoder.h">
 190.843 -      <Filter>Headers</Filter>
 190.844 -    </ClInclude>
 190.845 -    <ClInclude Include="CPP\7zip\Compress\ImplodeHuffmanDecoder.h">
 190.846 -      <Filter>Headers</Filter>
 190.847 -    </ClInclude>
 190.848 -    <ClInclude Include="CPP\7zip\Compress\LzhDecoder.h">
 190.849 -      <Filter>Headers</Filter>
 190.850 -    </ClInclude>
 190.851 -    <ClInclude Include="CPP\7zip\Compress\LzmaDecoder.h">
 190.852 -      <Filter>Headers</Filter>
 190.853 -    </ClInclude>
 190.854 -    <ClInclude Include="CPP\7zip\Compress\LzOutWindow.h">
 190.855 -      <Filter>Headers</Filter>
 190.856 -    </ClInclude>
 190.857 -    <ClInclude Include="CPP\7zip\Compress\Mtf8.h">
 190.858 -      <Filter>Headers</Filter>
 190.859 -    </ClInclude>
 190.860 -    <ClInclude Include="CPP\7zip\Compress\PpmdContext.h">
 190.861 -      <Filter>Headers</Filter>
 190.862 -    </ClInclude>
 190.863 -    <ClInclude Include="CPP\7zip\Compress\PpmdDecode.h">
 190.864 -      <Filter>Headers</Filter>
 190.865 -    </ClInclude>
 190.866 -    <ClInclude Include="CPP\7zip\Compress\PpmdDecoder.h">
 190.867 -      <Filter>Headers</Filter>
 190.868 -    </ClInclude>
 190.869 -    <ClInclude Include="CPP\7zip\Compress\PpmdSubAlloc.h">
 190.870 -      <Filter>Headers</Filter>
 190.871 -    </ClInclude>
 190.872 -    <ClInclude Include="CPP\7zip\Compress\PpmdType.h">
 190.873 -      <Filter>Headers</Filter>
 190.874 -    </ClInclude>
 190.875 -    <ClInclude Include="CPP\7zip\Compress\RangeCoder.h">
 190.876 -      <Filter>Headers</Filter>
 190.877 -    </ClInclude>
 190.878 -    <ClInclude Include="CPP\7zip\Compress\RangeCoderBit.h">
 190.879 -      <Filter>Headers</Filter>
 190.880 -    </ClInclude>
 190.881 -    <ClInclude Include="CPP\7zip\Compress\Rar1Decoder.h">
 190.882 -      <Filter>Headers</Filter>
 190.883 -    </ClInclude>
 190.884 -    <ClInclude Include="CPP\7zip\Compress\Rar2Decoder.h">
 190.885 -      <Filter>Headers</Filter>
 190.886 -    </ClInclude>
 190.887 -    <ClInclude Include="CPP\7zip\Compress\Rar3Decoder.h">
 190.888 -      <Filter>Headers</Filter>
 190.889 -    </ClInclude>
 190.890 -    <ClInclude Include="CPP\7zip\Compress\Rar3Vm.h">
 190.891 -      <Filter>Headers</Filter>
 190.892 -    </ClInclude>
 190.893 -    <ClInclude Include="CPP\7zip\Compress\ShrinkDecoder.h">
 190.894 -      <Filter>Headers</Filter>
 190.895 -    </ClInclude>
 190.896 -    <ClInclude Include="CPP\7zip\Compress\StdAfx.h">
 190.897 -      <Filter>Headers</Filter>
 190.898 -    </ClInclude>
 190.899 -    <ClInclude Include="CPP\7zip\Compress\ZlibDecoder.h">
 190.900 -      <Filter>Headers</Filter>
 190.901 -    </ClInclude>
 190.902 -    <ClInclude Include="CPP\7zip\Crypto\7zAes.h">
 190.903 -      <Filter>Headers</Filter>
 190.904 -    </ClInclude>
 190.905 -    <ClInclude Include="CPP\7zip\Crypto\HmacSha1.h">
 190.906 -      <Filter>Headers</Filter>
 190.907 -    </ClInclude>
 190.908 -    <ClInclude Include="CPP\7zip\Crypto\MyAes.h">
 190.909 -      <Filter>Headers</Filter>
 190.910 -    </ClInclude>
 190.911 -    <ClInclude Include="CPP\7zip\Crypto\Pbkdf2HmacSha1.h">
 190.912 -      <Filter>Headers</Filter>
 190.913 -    </ClInclude>
 190.914 -    <ClInclude Include="CPP\7zip\Crypto\RandGen.h">
 190.915 -      <Filter>Headers</Filter>
 190.916 -    </ClInclude>
 190.917 -    <ClInclude Include="CPP\7zip\Crypto\Rar20Crypto.h">
 190.918 -      <Filter>Headers</Filter>
 190.919 -    </ClInclude>
 190.920 -    <ClInclude Include="CPP\7zip\Crypto\RarAes.h">
 190.921 -      <Filter>Headers</Filter>
 190.922 -    </ClInclude>
 190.923 -    <ClInclude Include="CPP\7zip\Crypto\Sha1.h">
 190.924 -      <Filter>Headers</Filter>
 190.925 -    </ClInclude>
 190.926 -    <ClInclude Include="CPP\7zip\Crypto\StdAfx.h">
 190.927 -      <Filter>Headers</Filter>
 190.928 -    </ClInclude>
 190.929 -    <ClInclude Include="CPP\7zip\Crypto\WzAes.h">
 190.930 -      <Filter>Headers</Filter>
 190.931 -    </ClInclude>
 190.932 -    <ClInclude Include="CPP\7zip\Crypto\ZipCrypto.h">
 190.933 -      <Filter>Headers</Filter>
 190.934 -    </ClInclude>
 190.935 -    <ClInclude Include="CPP\7zip\Crypto\ZipStrong.h">
 190.936 -      <Filter>Headers</Filter>
 190.937 -    </ClInclude>
 190.938 -    <ClInclude Include="CPP\7zip\ICoder.h">
 190.939 -      <Filter>Headers</Filter>
 190.940 -    </ClInclude>
 190.941 -    <ClInclude Include="CPP\7zip\IDecl.h">
 190.942 -      <Filter>Headers</Filter>
 190.943 -    </ClInclude>
 190.944 -    <ClInclude Include="CPP\7zip\IPassword.h">
 190.945 -      <Filter>Headers</Filter>
 190.946 -    </ClInclude>
 190.947 -    <ClInclude Include="CPP\7zip\IProgress.h">
 190.948 -      <Filter>Headers</Filter>
 190.949 -    </ClInclude>
 190.950 -    <ClInclude Include="CPP\7zip\IStream.h">
 190.951 -      <Filter>Headers</Filter>
 190.952 -    </ClInclude>
 190.953 -    <ClInclude Include="CPP\7zip\PropID.h">
 190.954 -      <Filter>Headers</Filter>
 190.955 -    </ClInclude>
 190.956 -    <ClInclude Include="CPP\Common\Buffer.h">
 190.957 -      <Filter>Headers</Filter>
 190.958 -    </ClInclude>
 190.959 -    <ClInclude Include="CPP\Common\ComTry.h">
 190.960 -      <Filter>Headers</Filter>
 190.961 -    </ClInclude>
 190.962 -    <ClInclude Include="CPP\Common\Defs.h">
 190.963 -      <Filter>Headers</Filter>
 190.964 -    </ClInclude>
 190.965 -    <ClInclude Include="CPP\Common\DynamicBuffer.h">
 190.966 -      <Filter>Headers</Filter>
 190.967 -    </ClInclude>
 190.968 -    <ClInclude Include="CPP\Common\InitializeStaticLib.h">
 190.969 -      <Filter>Headers</Filter>
 190.970 -    </ClInclude>
 190.971 -    <ClInclude Include="CPP\Common\IntToString.h">
 190.972 -      <Filter>Headers</Filter>
 190.973 -    </ClInclude>
 190.974 -    <ClInclude Include="CPP\Common\MyCom.h">
 190.975 -      <Filter>Headers</Filter>
 190.976 -    </ClInclude>
 190.977 -    <ClInclude Include="CPP\Common\MyException.h">
 190.978 -      <Filter>Headers</Filter>
 190.979 -    </ClInclude>
 190.980 -    <ClInclude Include="CPP\Common\MyInitGuid.h">
 190.981 -      <Filter>Headers</Filter>
 190.982 -    </ClInclude>
 190.983 -    <ClInclude Include="CPP\Common\MyMap.h">
 190.984 -      <Filter>Headers</Filter>
 190.985 -    </ClInclude>
 190.986 -    <ClInclude Include="CPP\Common\MyString.h">
 190.987 -      <Filter>Headers</Filter>
 190.988 -    </ClInclude>
 190.989 -    <ClInclude Include="CPP\Common\MyUnknown.h">
 190.990 -      <Filter>Headers</Filter>
 190.991 -    </ClInclude>
 190.992 -    <ClInclude Include="CPP\Common\MyVector.h">
 190.993 -      <Filter>Headers</Filter>
 190.994 -    </ClInclude>
 190.995 -    <ClInclude Include="CPP\Common\MyWindows.h">
 190.996 -      <Filter>Headers</Filter>
 190.997 -    </ClInclude>
 190.998 -    <ClInclude Include="CPP\Common\MyXml.h">
 190.999 -      <Filter>Headers</Filter>
190.1000 -    </ClInclude>
190.1001 -    <ClInclude Include="CPP\Common\NewHandler.h">
190.1002 -      <Filter>Headers</Filter>
190.1003 -    </ClInclude>
190.1004 -    <ClInclude Include="CPP\Common\StringConvert.h">
190.1005 -      <Filter>Headers</Filter>
190.1006 -    </ClInclude>
190.1007 -    <ClInclude Include="CPP\Common\StringToInt.h">
190.1008 -      <Filter>Headers</Filter>
190.1009 -    </ClInclude>
190.1010 -    <ClInclude Include="CPP\Common\Types.h">
190.1011 -      <Filter>Headers</Filter>
190.1012 -    </ClInclude>
190.1013 -    <ClInclude Include="CPP\Common\UTFConvert.h">
190.1014 -      <Filter>Headers</Filter>
190.1015 -    </ClInclude>
190.1016 -    <ClInclude Include="CPP\Common\Wildcard.h">
190.1017 -      <Filter>Headers</Filter>
190.1018 -    </ClInclude>
190.1019 -    <ClInclude Include="CPP\Windows\Defs.h">
190.1020 -      <Filter>Headers</Filter>
190.1021 -    </ClInclude>
190.1022 -    <ClInclude Include="CPP\Windows\FileDir.h">
190.1023 -      <Filter>Headers</Filter>
190.1024 -    </ClInclude>
190.1025 -    <ClInclude Include="CPP\Windows\FileFind.h">
190.1026 -      <Filter>Headers</Filter>
190.1027 -    </ClInclude>
190.1028 -    <ClInclude Include="CPP\Windows\FileIO.h">
190.1029 -      <Filter>Headers</Filter>
190.1030 -    </ClInclude>
190.1031 -    <ClInclude Include="CPP\Windows\FileName.h">
190.1032 -      <Filter>Headers</Filter>
190.1033 -    </ClInclude>
190.1034 -    <ClInclude Include="CPP\Windows\Handle.h">
190.1035 -      <Filter>Headers</Filter>
190.1036 -    </ClInclude>
190.1037 -    <ClInclude Include="CPP\Windows\PropVariant.h">
190.1038 -      <Filter>Headers</Filter>
190.1039 -    </ClInclude>
190.1040 -    <ClInclude Include="CPP\Windows\StdAfx.h">
190.1041 -      <Filter>Headers</Filter>
190.1042 -    </ClInclude>
190.1043 -    <ClInclude Include="CPP\Windows\Synchronization.h">
190.1044 -      <Filter>Headers</Filter>
190.1045 -    </ClInclude>
190.1046 -    <ClInclude Include="CPP\Windows\Thread.h">
190.1047 -      <Filter>Headers</Filter>
190.1048 -    </ClInclude>
190.1049 -    <ClInclude Include="CPP\Windows\Time.h">
190.1050 -      <Filter>Headers</Filter>
190.1051 -    </ClInclude>
190.1052 -    <ClInclude Include="C\7zCrc.h">
190.1053 -      <Filter>Headers</Filter>
190.1054 -    </ClInclude>
190.1055 -    <ClInclude Include="C\Aes.h">
190.1056 -      <Filter>Headers</Filter>
190.1057 -    </ClInclude>
190.1058 -    <ClInclude Include="C\Alloc.h">
190.1059 -      <Filter>Headers</Filter>
190.1060 -    </ClInclude>
190.1061 -    <ClInclude Include="C\Bra.h">
190.1062 -      <Filter>Headers</Filter>
190.1063 -    </ClInclude>
190.1064 -    <ClInclude Include="C\BwtSort.h">
190.1065 -      <Filter>Headers</Filter>
190.1066 -    </ClInclude>
190.1067 -    <ClInclude Include="C\CpuArch.h">
190.1068 -      <Filter>Headers</Filter>
190.1069 -    </ClInclude>
190.1070 -    <ClInclude Include="C\HuffEnc.h">
190.1071 -      <Filter>Headers</Filter>
190.1072 -    </ClInclude>
190.1073 -    <ClInclude Include="C\LzFind.h">
190.1074 -      <Filter>Headers</Filter>
190.1075 -    </ClInclude>
190.1076 -    <ClInclude Include="C\LzFindMt.h">
190.1077 -      <Filter>Headers</Filter>
190.1078 -    </ClInclude>
190.1079 -    <ClInclude Include="C\LzHash.h">
190.1080 -      <Filter>Headers</Filter>
190.1081 -    </ClInclude>
190.1082 -    <ClInclude Include="C\LzmaDec.h">
190.1083 -      <Filter>Headers</Filter>
190.1084 -    </ClInclude>
190.1085 -    <ClInclude Include="C\LzmaEnc.h">
190.1086 -      <Filter>Headers</Filter>
190.1087 -    </ClInclude>
190.1088 -    <ClInclude Include="C\RotateDefs.h">
190.1089 -      <Filter>Headers</Filter>
190.1090 -    </ClInclude>
190.1091 -    <ClInclude Include="C\Sha256.h">
190.1092 -      <Filter>Headers</Filter>
190.1093 -    </ClInclude>
190.1094 -    <ClInclude Include="C\Sort.h">
190.1095 -      <Filter>Headers</Filter>
190.1096 -    </ClInclude>
190.1097 -    <ClInclude Include="C\Threads.h">
190.1098 -      <Filter>Headers</Filter>
190.1099 -    </ClInclude>
190.1100 -    <ClInclude Include="C\Types.h">
190.1101 -      <Filter>Headers</Filter>
190.1102 -    </ClInclude>
190.1103 -  </ItemGroup>
190.1104 -</Project>
190.1105 \ No newline at end of file
   191.1 --- a/src/win32/7zip/7z/C/7zCrc.c	Sat Mar 03 10:54:39 2012 -0600
   191.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   191.3 @@ -1,35 +0,0 @@
   191.4 -/* 7zCrc.c -- CRC32 calculation
   191.5 -2008-08-05
   191.6 -Igor Pavlov
   191.7 -Public domain */
   191.8 -
   191.9 -#include "7zCrc.h"
  191.10 -
  191.11 -#define kCrcPoly 0xEDB88320
  191.12 -UInt32 g_CrcTable[256];
  191.13 -
  191.14 -void MY_FAST_CALL CrcGenerateTable(void)
  191.15 -{
  191.16 -  UInt32 i;
  191.17 -  for (i = 0; i < 256; i++)
  191.18 -  {
  191.19 -    UInt32 r = i;
  191.20 -    int j;
  191.21 -    for (j = 0; j < 8; j++)
  191.22 -      r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
  191.23 -    g_CrcTable[i] = r;
  191.24 -  }
  191.25 -}
  191.26 -
  191.27 -UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
  191.28 -{
  191.29 -  const Byte *p = (const Byte *)data;
  191.30 -  for (; size > 0 ; size--, p++)
  191.31 -    v = CRC_UPDATE_BYTE(v, *p);
  191.32 -  return v;
  191.33 -}
  191.34 -
  191.35 -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
  191.36 -{
  191.37 -  return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
  191.38 -}
   192.1 --- a/src/win32/7zip/7z/C/7zCrc.h	Sat Mar 03 10:54:39 2012 -0600
   192.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   192.3 @@ -1,24 +0,0 @@
   192.4 -/* 7zCrc.h -- CRC32 calculation
   192.5 -2008-03-13
   192.6 -Igor Pavlov
   192.7 -Public domain */
   192.8 -
   192.9 -#ifndef __7Z_CRC_H
  192.10 -#define __7Z_CRC_H
  192.11 -
  192.12 -#include <stddef.h>
  192.13 -
  192.14 -#include "Types.h"
  192.15 -
  192.16 -extern UInt32 g_CrcTable[];
  192.17 -
  192.18 -void MY_FAST_CALL CrcGenerateTable(void);
  192.19 -
  192.20 -#define CRC_INIT_VAL 0xFFFFFFFF
  192.21 -#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
  192.22 -#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
  192.23 -
  192.24 -UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
  192.25 -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
  192.26 -
  192.27 -#endif
   193.1 --- a/src/win32/7zip/7z/C/Aes.c	Sat Mar 03 10:54:39 2012 -0600
   193.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   193.3 @@ -1,262 +0,0 @@
   193.4 -/* Aes.c -- AES encryption / decryption
   193.5 -2008-08-05
   193.6 -Igor Pavlov
   193.7 -Public domain */
   193.8 -
   193.9 -#include "Aes.h"
  193.10 -#include "CpuArch.h"
  193.11 -
  193.12 -static UInt32 T[256 * 4];
  193.13 -static Byte Sbox[256] = {
  193.14 -  0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
  193.15 -  0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
  193.16 -  0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
  193.17 -  0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
  193.18 -  0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
  193.19 -  0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
  193.20 -  0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
  193.21 -  0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
  193.22 -  0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
  193.23 -  0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
  193.24 -  0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
  193.25 -  0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
  193.26 -  0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
  193.27 -  0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
  193.28 -  0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
  193.29 -  0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
  193.30 -
  193.31 -static UInt32 D[256 * 4];
  193.32 -static Byte InvS[256];
  193.33 -
  193.34 -static Byte Rcon[11] = { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
  193.35 -
  193.36 -#define xtime(x) ((((x) << 1) ^ (((x) & 0x80) != 0 ? 0x1B : 0)) & 0xFF)
  193.37 -
  193.38 -#define Ui32(a0, a1, a2, a3) ((UInt32)(a0) | ((UInt32)(a1) << 8) | ((UInt32)(a2) << 16) | ((UInt32)(a3) << 24))
  193.39 -
  193.40 -#define gb0(x) ( (x)          & 0xFF)
  193.41 -#define gb1(x) (((x) >> ( 8)) & 0xFF)
  193.42 -#define gb2(x) (((x) >> (16)) & 0xFF)
  193.43 -#define gb3(x) (((x) >> (24)) & 0xFF)
  193.44 -
  193.45 -void AesGenTables(void)
  193.46 -{
  193.47 -  unsigned i;
  193.48 -  for (i = 0; i < 256; i++)
  193.49 -    InvS[Sbox[i]] = (Byte)i;
  193.50 -  for (i = 0; i < 256; i++)
  193.51 -  {
  193.52 -    {
  193.53 -      UInt32 a1 = Sbox[i];
  193.54 -      UInt32 a2 = xtime(a1);
  193.55 -      UInt32 a3 = xtime(a1) ^ a1;
  193.56 -      T[        i] = Ui32(a2, a1, a1, a3);
  193.57 -      T[0x100 + i] = Ui32(a3, a2, a1, a1);
  193.58 -      T[0x200 + i] = Ui32(a1, a3, a2, a1);
  193.59 -      T[0x300 + i] = Ui32(a1, a1, a3, a2);
  193.60 -    }
  193.61 -    {
  193.62 -      UInt32 a1 = InvS[i];
  193.63 -      UInt32 a2 = xtime(a1);
  193.64 -      UInt32 a4 = xtime(a2);
  193.65 -      UInt32 a8 = xtime(a4);
  193.66 -      UInt32 a9 = a8 ^ a1;
  193.67 -      UInt32 aB = a8 ^ a2 ^ a1;
  193.68 -      UInt32 aD = a8 ^ a4 ^ a1;
  193.69 -      UInt32 aE = a8 ^ a4 ^ a2;
  193.70 -      D[        i] = Ui32(aE, a9, aD, aB);
  193.71 -      D[0x100 + i] = Ui32(aB, aE, a9, aD);
  193.72 -      D[0x200 + i] = Ui32(aD, aB, aE, a9);
  193.73 -      D[0x300 + i] = Ui32(a9, aD, aB, aE);
  193.74 -    }
  193.75 -  }
  193.76 -}
  193.77 -
  193.78 -#define HT(i, x, s) (T + (x << 8))[gb ## x(s[(i + x) & 3])]
  193.79 -#define HT4(m, i, s, p) m[i] = \
  193.80 -    HT(i, 0, s) ^ \
  193.81 -    HT(i, 1, s) ^ \
  193.82 -    HT(i, 2, s) ^ \
  193.83 -    HT(i, 3, s) ^ w[p + i]
  193.84 -/* such order (2031) in HT16 is for VC6/K8 speed optimization) */
  193.85 -#define HT16(m, s, p) \
  193.86 -    HT4(m, 2, s, p); \
  193.87 -    HT4(m, 0, s, p); \
  193.88 -    HT4(m, 3, s, p); \
  193.89 -    HT4(m, 1, s, p); \
  193.90 -
  193.91 -#define FT(i, x) Sbox[gb ## x(m[(i + x) & 3])]
  193.92 -#define FT4(i) dest[i] = Ui32(FT(i, 0), FT(i, 1), FT(i, 2), FT(i, 3)) ^ w[i];
  193.93 -
  193.94 -#define HD(i, x, s) (D + (x << 8))[gb ## x(s[(i - x) & 3])]
  193.95 -#define HD4(m, i, s, p) m[i] = \
  193.96 -    HD(i, 0, s) ^ \
  193.97 -    HD(i, 1, s) ^ \
  193.98 -    HD(i, 2, s) ^ \
  193.99 -    HD(i, 3, s) ^ w[p + i];
 193.100 -/* such order (0231) in HD16 is for VC6/K8 speed optimization) */
 193.101 -#define HD16(m, s, p) \
 193.102 -    HD4(m, 0, s, p); \
 193.103 -    HD4(m, 2, s, p); \
 193.104 -    HD4(m, 3, s, p); \
 193.105 -    HD4(m, 1, s, p); \
 193.106 -
 193.107 -#define FD(i, x) InvS[gb ## x(m[(i - x) & 3])]
 193.108 -#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i];
 193.109 -
 193.110 -void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize)
 193.111 -{
 193.112 -  unsigned i, wSize;
 193.113 -  UInt32 *w;
 193.114 -  keySize /= 4;
 193.115 -  p->numRounds2 = keySize / 2 + 3;
 193.116 -
 193.117 -  wSize = (p->numRounds2 * 2 + 1) * 4;
 193.118 -  w = p->rkey;
 193.119 -
 193.120 -  for (i = 0; i < keySize; i++, key += 4)
 193.121 -    w[i] = Ui32(key[0], key[1], key[2], key[3]);
 193.122 -
 193.123 -  for (; i < wSize; i++)
 193.124 -  {
 193.125 -    UInt32 t = w[i - 1];
 193.126 -    unsigned rem = i % keySize;
 193.127 -    if (rem == 0)
 193.128 -      t = Ui32(Sbox[gb1(t)] ^ Rcon[i / keySize], Sbox[gb2(t)], Sbox[gb3(t)], Sbox[gb0(t)]);
 193.129 -    else if (keySize > 6 && rem == 4)
 193.130 -      t = Ui32(Sbox[gb0(t)], Sbox[gb1(t)], Sbox[gb2(t)], Sbox[gb3(t)]);
 193.131 -    w[i] = w[i - keySize] ^ t;
 193.132 -  }
 193.133 -}
 193.134 -
 193.135 -void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize)
 193.136 -{
 193.137 -  unsigned i, num;
 193.138 -  UInt32 *w;
 193.139 -  Aes_SetKeyEncode(p, key, keySize);
 193.140 -  num = p->numRounds2 * 8 - 4;
 193.141 -  w = p->rkey + 4;
 193.142 -  for (i = 0; i < num; i++)
 193.143 -  {
 193.144 -    UInt32 r = w[i];
 193.145 -    w[i] =
 193.146 -      D[        Sbox[gb0(r)]] ^
 193.147 -      D[0x100 + Sbox[gb1(r)]] ^
 193.148 -      D[0x200 + Sbox[gb2(r)]] ^
 193.149 -      D[0x300 + Sbox[gb3(r)]];
 193.150 -  }
 193.151 -}
 193.152 -
 193.153 -static void AesEncode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
 193.154 -{
 193.155 -  UInt32 s[4];
 193.156 -  UInt32 m[4];
 193.157 -  s[0] = src[0] ^ w[0];
 193.158 -  s[1] = src[1] ^ w[1];
 193.159 -  s[2] = src[2] ^ w[2];
 193.160 -  s[3] = src[3] ^ w[3];
 193.161 -  w += 4;
 193.162 -  for (;;)
 193.163 -  {
 193.164 -    HT16(m, s, 0);
 193.165 -    if (--numRounds2 == 0)
 193.166 -      break;
 193.167 -    HT16(s, m, 4);
 193.168 -    w += 8;
 193.169 -  }
 193.170 -  w += 4;
 193.171 -  FT4(0); FT4(1); FT4(2); FT4(3);
 193.172 -}
 193.173 -
 193.174 -static void AesDecode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
 193.175 -{
 193.176 -  UInt32 s[4];
 193.177 -  UInt32 m[4];
 193.178 -  w += numRounds2 * 8;
 193.179 -  s[0] = src[0] ^ w[0];
 193.180 -  s[1] = src[1] ^ w[1];
 193.181 -  s[2] = src[2] ^ w[2];
 193.182 -  s[3] = src[3] ^ w[3];
 193.183 -  for (;;)
 193.184 -  {
 193.185 -    w -= 8;
 193.186 -    HD16(m, s, 4);
 193.187 -    if (--numRounds2 == 0)
 193.188 -      break;
 193.189 -    HD16(s, m, 0);
 193.190 -  }
 193.191 -  FD4(0); FD4(1); FD4(2); FD4(3);
 193.192 -}
 193.193 -
 193.194 -void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src)
 193.195 -{
 193.196 -  AesEncode32(dest, src, p->rkey, p->numRounds2);
 193.197 -}
 193.198 -
 193.199 -void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src)
 193.200 -{
 193.201 -  AesDecode32(dest, src, p->rkey, p->numRounds2);
 193.202 -}
 193.203 -
 193.204 -void AesCbc_Init(CAesCbc *p, const Byte *iv)
 193.205 -{
 193.206 -  unsigned i;
 193.207 -  for (i = 0; i < 4; i++)
 193.208 -    p->prev[i] = GetUi32(iv + i * 4);
 193.209 -}
 193.210 -
 193.211 -SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size)
 193.212 -{
 193.213 -  SizeT i;
 193.214 -  if (size == 0)
 193.215 -    return 0;
 193.216 -  if (size < AES_BLOCK_SIZE)
 193.217 -    return AES_BLOCK_SIZE;
 193.218 -  size -= AES_BLOCK_SIZE;
 193.219 -  for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
 193.220 -  {
 193.221 -    p->prev[0] ^= GetUi32(data);
 193.222 -    p->prev[1] ^= GetUi32(data + 4);
 193.223 -    p->prev[2] ^= GetUi32(data + 8);
 193.224 -    p->prev[3] ^= GetUi32(data + 12);
 193.225 -    
 193.226 -    AesEncode32(p->prev, p->prev, p->aes.rkey, p->aes.numRounds2);
 193.227 -    
 193.228 -    SetUi32(data,      p->prev[0]);
 193.229 -    SetUi32(data + 4,  p->prev[1]);
 193.230 -    SetUi32(data + 8,  p->prev[2]);
 193.231 -    SetUi32(data + 12, p->prev[3]);
 193.232 -  }
 193.233 -  return i;
 193.234 -}
 193.235 -
 193.236 -SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size)
 193.237 -{
 193.238 -  SizeT i;
 193.239 -  UInt32 in[4], out[4];
 193.240 -  if (size == 0)
 193.241 -    return 0;
 193.242 -  if (size < AES_BLOCK_SIZE)
 193.243 -    return AES_BLOCK_SIZE;
 193.244 -  size -= AES_BLOCK_SIZE;
 193.245 -  for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
 193.246 -  {
 193.247 -    in[0] = GetUi32(data);
 193.248 -    in[1] = GetUi32(data + 4);
 193.249 -    in[2] = GetUi32(data + 8);
 193.250 -    in[3] = GetUi32(data + 12);
 193.251 -    
 193.252 -    AesDecode32(out, in, p->aes.rkey, p->aes.numRounds2);
 193.253 -    
 193.254 -    SetUi32(data,      p->prev[0] ^ out[0]);
 193.255 -    SetUi32(data + 4,  p->prev[1] ^ out[1]);
 193.256 -    SetUi32(data + 8,  p->prev[2] ^ out[2]);
 193.257 -    SetUi32(data + 12, p->prev[3] ^ out[3]);
 193.258 -    
 193.259 -    p->prev[0] = in[0];
 193.260 -    p->prev[1] = in[1];
 193.261 -    p->prev[2] = in[2];
 193.262 -    p->prev[3] = in[3];
 193.263 -  }
 193.264 -  return i;
 193.265 -}
   194.1 --- a/src/win32/7zip/7z/C/Aes.h	Sat Mar 03 10:54:39 2012 -0600
   194.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   194.3 @@ -1,48 +0,0 @@
   194.4 -/* Aes.h -- AES encryption / decryption
   194.5 -2008-08-05
   194.6 -Igor Pavlov
   194.7 -Public domain */
   194.8 -
   194.9 -#ifndef __AES_H
  194.10 -#define __AES_H
  194.11 -
  194.12 -#include "Types.h"
  194.13 -
  194.14 -#define AES_BLOCK_SIZE 16
  194.15 -
  194.16 -typedef struct
  194.17 -{
  194.18 -  unsigned numRounds2; /* = numRounds / 2 */
  194.19 -  UInt32 rkey[(14 + 1) * 4];
  194.20 -} CAes;
  194.21 -
  194.22 -/* Call AesGenTables one time before other AES functions */
  194.23 -void AesGenTables(void);
  194.24 -
  194.25 -/* keySize = 16 or 24 or 32 (bytes) */
  194.26 -void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize);
  194.27 -void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize);
  194.28 -
  194.29 -/* Aes_Encode32 and Aes_Decode32 functions work with little-endian words.
  194.30 -  src and dest are pointers to 4 UInt32 words.
  194.31 -  arc and dest can point to same block */
  194.32 -void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src);
  194.33 -void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src);
  194.34 -
  194.35 -typedef struct
  194.36 -{
  194.37 -  UInt32 prev[4];
  194.38 -  CAes aes;
  194.39 -} CAesCbc;
  194.40 -
  194.41 -void AesCbc_Init(CAesCbc *p, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
  194.42 -
  194.43 -/* AesCbc_Encode and AesCbc_Decode:
  194.44 -  if (res <= size): Filter have converted res bytes
  194.45 -  if (res > size):  Filter have not converted anything. And it needs at
  194.46 -                    least res = AES_BLOCK_SIZE bytes to convert one block */
  194.47 -
  194.48 -SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size);
  194.49 -SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size);
  194.50 -
  194.51 -#endif
   195.1 --- a/src/win32/7zip/7z/C/Alloc.c	Sat Mar 03 10:54:39 2012 -0600
   195.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   195.3 @@ -1,127 +0,0 @@
   195.4 -/* Alloc.c -- Memory allocation functions
   195.5 -2008-09-24
   195.6 -Igor Pavlov
   195.7 -Public domain */
   195.8 -
   195.9 -#ifdef _WIN32
  195.10 -#include <windows.h>
  195.11 -#endif
  195.12 -#include <stdlib.h>
  195.13 -
  195.14 -#include "Alloc.h"
  195.15 -
  195.16 -/* #define _SZ_ALLOC_DEBUG */
  195.17 -
  195.18 -/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
  195.19 -#ifdef _SZ_ALLOC_DEBUG
  195.20 -#include <stdio.h>
  195.21 -int g_allocCount = 0;
  195.22 -int g_allocCountMid = 0;
  195.23 -int g_allocCountBig = 0;
  195.24 -#endif
  195.25 -
  195.26 -void *MyAlloc(size_t size)
  195.27 -{
  195.28 -  if (size == 0)
  195.29 -    return 0;
  195.30 -  #ifdef _SZ_ALLOC_DEBUG
  195.31 -  {
  195.32 -    void *p = malloc(size);
  195.33 -    fprintf(stderr, "\nAlloc %10d bytes, count = %10d,  addr = %8X", size, g_allocCount++, (unsigned)p);
  195.34 -    return p;
  195.35 -  }
  195.36 -  #else
  195.37 -  return malloc(size);
  195.38 -  #endif
  195.39 -}
  195.40 -
  195.41 -void MyFree(void *address)
  195.42 -{
  195.43 -  #ifdef _SZ_ALLOC_DEBUG
  195.44 -  if (address != 0)
  195.45 -    fprintf(stderr, "\nFree; count = %10d,  addr = %8X", --g_allocCount, (unsigned)address);
  195.46 -  #endif
  195.47 -  free(address);
  195.48 -}
  195.49 -
  195.50 -#ifdef _WIN32
  195.51 -
  195.52 -void *MidAlloc(size_t size)
  195.53 -{
  195.54 -  if (size == 0)
  195.55 -    return 0;
  195.56 -  #ifdef _SZ_ALLOC_DEBUG
  195.57 -  fprintf(stderr, "\nAlloc_Mid %10d bytes;  count = %10d", size, g_allocCountMid++);
  195.58 -  #endif
  195.59 -  return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
  195.60 -}
  195.61 -
  195.62 -void MidFree(void *address)
  195.63 -{
  195.64 -  #ifdef _SZ_ALLOC_DEBUG
  195.65 -  if (address != 0)
  195.66 -    fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
  195.67 -  #endif
  195.68 -  if (address == 0)
  195.69 -    return;
  195.70 -  VirtualFree(address, 0, MEM_RELEASE);
  195.71 -}
  195.72 -
  195.73 -#ifndef MEM_LARGE_PAGES
  195.74 -#undef _7ZIP_LARGE_PAGES
  195.75 -#endif
  195.76 -
  195.77 -#ifdef _7ZIP_LARGE_PAGES
  195.78 -SIZE_T g_LargePageSize = 0;
  195.79 -typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
  195.80 -#endif
  195.81 -
  195.82 -void SetLargePageSize()
  195.83 -{
  195.84 -  #ifdef _7ZIP_LARGE_PAGES
  195.85 -  SIZE_T size = 0;
  195.86 -  GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
  195.87 -        GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
  195.88 -  if (largePageMinimum == 0)
  195.89 -    return;
  195.90 -  size = largePageMinimum();
  195.91 -  if (size == 0 || (size & (size - 1)) != 0)
  195.92 -    return;
  195.93 -  g_LargePageSize = size;
  195.94 -  #endif
  195.95 -}
  195.96 -
  195.97 -
  195.98 -void *BigAlloc(size_t size)
  195.99 -{
 195.100 -  if (size == 0)
 195.101 -    return 0;
 195.102 -  #ifdef _SZ_ALLOC_DEBUG
 195.103 -  fprintf(stderr, "\nAlloc_Big %10d bytes;  count = %10d", size, g_allocCountBig++);
 195.104 -  #endif
 195.105 -  
 195.106 -  #ifdef _7ZIP_LARGE_PAGES
 195.107 -  if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
 195.108 -  {
 195.109 -    void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
 195.110 -        MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
 195.111 -    if (res != 0)
 195.112 -      return res;
 195.113 -  }
 195.114 -  #endif
 195.115 -  return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
 195.116 -}
 195.117 -
 195.118 -void BigFree(void *address)
 195.119 -{
 195.120 -  #ifdef _SZ_ALLOC_DEBUG
 195.121 -  if (address != 0)
 195.122 -    fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
 195.123 -  #endif
 195.124 -  
 195.125 -  if (address == 0)
 195.126 -    return;
 195.127 -  VirtualFree(address, 0, MEM_RELEASE);
 195.128 -}
 195.129 -
 195.130 -#endif
   196.1 --- a/src/win32/7zip/7z/C/Alloc.h	Sat Mar 03 10:54:39 2012 -0600
   196.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   196.3 @@ -1,32 +0,0 @@
   196.4 -/* Alloc.h -- Memory allocation functions
   196.5 -2008-03-13
   196.6 -Igor Pavlov
   196.7 -Public domain */
   196.8 -
   196.9 -#ifndef __COMMON_ALLOC_H
  196.10 -#define __COMMON_ALLOC_H
  196.11 -
  196.12 -#include <stddef.h>
  196.13 -
  196.14 -void *MyAlloc(size_t size);
  196.15 -void MyFree(void *address);
  196.16 -
  196.17 -#ifdef _WIN32
  196.18 -
  196.19 -void SetLargePageSize();
  196.20 -
  196.21 -void *MidAlloc(size_t size);
  196.22 -void MidFree(void *address);
  196.23 -void *BigAlloc(size_t size);
  196.24 -void BigFree(void *address);
  196.25 -
  196.26 -#else
  196.27 -
  196.28 -#define MidAlloc(size) MyAlloc(size)
  196.29 -#define MidFree(address) MyFree(address)
  196.30 -#define BigAlloc(size) MyAlloc(size)
  196.31 -#define BigFree(address) MyFree(address)
  196.32 -
  196.33 -#endif
  196.34 -
  196.35 -#endif
   197.1 --- a/src/win32/7zip/7z/C/Bra.c	Sat Mar 03 10:54:39 2012 -0600
   197.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   197.3 @@ -1,133 +0,0 @@
   197.4 -/* Bra.c -- Converters for RISC code
   197.5 -2008-10-04 : Igor Pavlov : Public domain */
   197.6 -
   197.7 -#include "Bra.h"
   197.8 -
   197.9 -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
  197.10 -{
  197.11 -  SizeT i;
  197.12 -  if (size < 4)
  197.13 -    return 0;
  197.14 -  size -= 4;
  197.15 -  ip += 8;
  197.16 -  for (i = 0; i <= size; i += 4)
  197.17 -  {
  197.18 -    if (data[i + 3] == 0xEB)
  197.19 -    {
  197.20 -      UInt32 dest;
  197.21 -      UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]);
  197.22 -      src <<= 2;
  197.23 -      if (encoding)
  197.24 -        dest = ip + (UInt32)i + src;
  197.25 -      else
  197.26 -        dest = src - (ip + (UInt32)i);
  197.27 -      dest >>= 2;
  197.28 -      data[i + 2] = (Byte)(dest >> 16);
  197.29 -      data[i + 1] = (Byte)(dest >> 8);
  197.30 -      data[i + 0] = (Byte)dest;
  197.31 -    }
  197.32 -  }
  197.33 -  return i;
  197.34 -}
  197.35 -
  197.36 -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
  197.37 -{
  197.38 -  SizeT i;
  197.39 -  if (size < 4)
  197.40 -    return 0;
  197.41 -  size -= 4;
  197.42 -  ip += 4;
  197.43 -  for (i = 0; i <= size; i += 2)
  197.44 -  {
  197.45 -    if ((data[i + 1] & 0xF8) == 0xF0 &&
  197.46 -        (data[i + 3] & 0xF8) == 0xF8)
  197.47 -    {
  197.48 -      UInt32 dest;
  197.49 -      UInt32 src =
  197.50 -        (((UInt32)data[i + 1] & 0x7) << 19) |
  197.51 -        ((UInt32)data[i + 0] << 11) |
  197.52 -        (((UInt32)data[i + 3] & 0x7) << 8) |
  197.53 -        (data[i + 2]);
  197.54 -      
  197.55 -      src <<= 1;
  197.56 -      if (encoding)
  197.57 -        dest = ip + (UInt32)i + src;
  197.58 -      else
  197.59 -        dest = src - (ip + (UInt32)i);
  197.60 -      dest >>= 1;
  197.61 -      
  197.62 -      data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
  197.63 -      data[i + 0] = (Byte)(dest >> 11);
  197.64 -      data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));
  197.65 -      data[i + 2] = (Byte)dest;
  197.66 -      i += 2;
  197.67 -    }
  197.68 -  }
  197.69 -  return i;
  197.70 -}
  197.71 -
  197.72 -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
  197.73 -{
  197.74 -  SizeT i;
  197.75 -  if (size < 4)
  197.76 -    return 0;
  197.77 -  size -= 4;
  197.78 -  for (i = 0; i <= size; i += 4)
  197.79 -  {
  197.80 -    if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1)
  197.81 -    {
  197.82 -      UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) |
  197.83 -        ((UInt32)data[i + 1] << 16) |
  197.84 -        ((UInt32)data[i + 2] << 8) |
  197.85 -        ((UInt32)data[i + 3] & (~3));
  197.86 -      
  197.87 -      UInt32 dest;
  197.88 -      if (encoding)
  197.89 -        dest = ip + (UInt32)i + src;
  197.90 -      else
  197.91 -        dest = src - (ip + (UInt32)i);
  197.92 -      data[i + 0] = (Byte)(0x48 | ((dest >> 24) &  0x3));
  197.93 -      data[i + 1] = (Byte)(dest >> 16);
  197.94 -      data[i + 2] = (Byte)(dest >> 8);
  197.95 -      data[i + 3] &= 0x3;
  197.96 -      data[i + 3] |= dest;
  197.97 -    }
  197.98 -  }
  197.99 -  return i;
 197.100 -}
 197.101 -
 197.102 -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
 197.103 -{
 197.104 -  UInt32 i;
 197.105 -  if (size < 4)
 197.106 -    return 0;
 197.107 -  size -= 4;
 197.108 -  for (i = 0; i <= size; i += 4)
 197.109 -  {
 197.110 -    if (data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 ||
 197.111 -        data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)
 197.112 -    {
 197.113 -      UInt32 src =
 197.114 -        ((UInt32)data[i + 0] << 24) |
 197.115 -        ((UInt32)data[i + 1] << 16) |
 197.116 -        ((UInt32)data[i + 2] << 8) |
 197.117 -        ((UInt32)data[i + 3]);
 197.118 -      UInt32 dest;
 197.119 -      
 197.120 -      src <<= 2;
 197.121 -      if (encoding)
 197.122 -        dest = ip + i + src;
 197.123 -      else
 197.124 -        dest = src - (ip + i);
 197.125 -      dest >>= 2;
 197.126 -      
 197.127 -      dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
 197.128 -
 197.129 -      data[i + 0] = (Byte)(dest >> 24);
 197.130 -      data[i + 1] = (Byte)(dest >> 16);
 197.131 -      data[i + 2] = (Byte)(dest >> 8);
 197.132 -      data[i + 3] = (Byte)dest;
 197.133 -    }
 197.134 -  }
 197.135 -  return i;
 197.136 -}
   198.1 --- a/src/win32/7zip/7z/C/Bra.h	Sat Mar 03 10:54:39 2012 -0600
   198.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   198.3 @@ -1,60 +0,0 @@
   198.4 -/* Bra.h -- Branch converters for executables
   198.5 -2008-10-04 : Igor Pavlov : Public domain */
   198.6 -
   198.7 -#ifndef __BRA_H
   198.8 -#define __BRA_H
   198.9 -
  198.10 -#include "Types.h"
  198.11 -
  198.12 -/*
  198.13 -These functions convert relative addresses to absolute addresses
  198.14 -in CALL instructions to increase the compression ratio.
  198.15 -  
  198.16 -  In:
  198.17 -    data     - data buffer
  198.18 -    size     - size of data
  198.19 -    ip       - current virtual Instruction Pinter (IP) value
  198.20 -    state    - state variable for x86 converter
  198.21 -    encoding - 0 (for decoding), 1 (for encoding)
  198.22 -  
  198.23 -  Out:
  198.24 -    state    - state variable for x86 converter
  198.25 -
  198.26 -  Returns:
  198.27 -    The number of processed bytes. If you call these functions with multiple calls,
  198.28 -    you must start next call with first byte after block of processed bytes.
  198.29 -  
  198.30 -  Type   Endian  Alignment  LookAhead
  198.31 -  
  198.32 -  x86    little      1          4
  198.33 -  ARMT   little      2          2
  198.34 -  ARM    little      4          0
  198.35 -  PPC     big        4          0
  198.36 -  SPARC   big        4          0
  198.37 -  IA64   little     16          0
  198.38 -
  198.39 -  size must be >= Alignment + LookAhead, if it's not last block.
  198.40 -  If (size < Alignment + LookAhead), converter returns 0.
  198.41 -
  198.42 -  Example:
  198.43 -
  198.44 -    UInt32 ip = 0;
  198.45 -    for ()
  198.46 -    {
  198.47 -      ; size must be >= Alignment + LookAhead, if it's not last block
  198.48 -      SizeT processed = Convert(data, size, ip, 1);
  198.49 -      data += processed;
  198.50 -      size -= processed;
  198.51 -      ip += processed;
  198.52 -    }
  198.53 -*/
  198.54 -
  198.55 -#define x86_Convert_Init(state) { state = 0; }
  198.56 -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
  198.57 -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
  198.58 -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
  198.59 -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
  198.60 -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
  198.61 -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
  198.62 -
  198.63 -#endif
   199.1 --- a/src/win32/7zip/7z/C/Bra86.c	Sat Mar 03 10:54:39 2012 -0600
   199.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   199.3 @@ -1,85 +0,0 @@
   199.4 -/* Bra86.c -- Converter for x86 code (BCJ)
   199.5 -2008-10-04 : Igor Pavlov : Public domain */
   199.6 -
   199.7 -#include "Bra.h"
   199.8 -
   199.9 -#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
  199.10 -
  199.11 -const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
  199.12 -const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
  199.13 -
  199.14 -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
  199.15 -{
  199.16 -  SizeT bufferPos = 0, prevPosT;
  199.17 -  UInt32 prevMask = *state & 0x7;
  199.18 -  if (size < 5)
  199.19 -    return 0;
  199.20 -  ip += 5;
  199.21 -  prevPosT = (SizeT)0 - 1;
  199.22 -
  199.23 -  for (;;)
  199.24 -  {
  199.25 -    Byte *p = data + bufferPos;
  199.26 -    Byte *limit = data + size - 4;
  199.27 -    for (; p < limit; p++)
  199.28 -      if ((*p & 0xFE) == 0xE8)
  199.29 -        break;
  199.30 -    bufferPos = (SizeT)(p - data);
  199.31 -    if (p >= limit)
  199.32 -      break;
  199.33 -    prevPosT = bufferPos - prevPosT;
  199.34 -    if (prevPosT > 3)
  199.35 -      prevMask = 0;
  199.36 -    else
  199.37 -    {
  199.38 -      prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
  199.39 -      if (prevMask != 0)
  199.40 -      {
  199.41 -        Byte b = p[4 - kMaskToBitNumber[prevMask]];
  199.42 -        if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b))
  199.43 -        {
  199.44 -          prevPosT = bufferPos;
  199.45 -          prevMask = ((prevMask << 1) & 0x7) | 1;
  199.46 -          bufferPos++;
  199.47 -          continue;
  199.48 -        }
  199.49 -      }
  199.50 -    }
  199.51 -    prevPosT = bufferPos;
  199.52 -
  199.53 -    if (Test86MSByte(p[4]))
  199.54 -    {
  199.55 -      UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
  199.56 -      UInt32 dest;
  199.57 -      for (;;)
  199.58 -      {
  199.59 -        Byte b;
  199.60 -        int index;
  199.61 -        if (encoding)
  199.62 -          dest = (ip + (UInt32)bufferPos) + src;
  199.63 -        else
  199.64 -          dest = src - (ip + (UInt32)bufferPos);
  199.65 -        if (prevMask == 0)
  199.66 -          break;
  199.67 -        index = kMaskToBitNumber[prevMask] * 8;
  199.68 -        b = (Byte)((dest >> (24 - index)) & 0xFF);
  199.69 -        if (!Test86MSByte(b))
  199.70 -          break;
  199.71 -        src = dest ^ ((1 << (32 - index)) - 1);
  199.72 -      }
  199.73 -      p[4] = (Byte)((~(((dest >> 24) & 1) - 1)) & 0xFF);
  199.74 -      p[3] = (Byte)((dest >> 16) & 0xFF);
  199.75 -      p[2] = (Byte)((dest >> 8) & 0xFF);
  199.76 -      p[1] = (Byte)(dest & 0xFF);
  199.77 -      bufferPos += 5;
  199.78 -    }
  199.79 -    else
  199.80 -    {
  199.81 -      prevMask = ((prevMask << 1) & 0x7) | 1;
  199.82 -      bufferPos++;
  199.83 -    }
  199.84 -  }
  199.85 -  prevPosT = bufferPos - prevPosT;
  199.86 -  *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7));
  199.87 -  return bufferPos;
  199.88 -}
   200.1 --- a/src/win32/7zip/7z/C/BraIA64.c	Sat Mar 03 10:54:39 2012 -0600
   200.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   200.3 @@ -1,67 +0,0 @@
   200.4 -/* BraIA64.c -- Converter for IA-64 code
   200.5 -2008-10-04 : Igor Pavlov : Public domain */
   200.6 -
   200.7 -#include "Bra.h"
   200.8 -
   200.9 -static const Byte kBranchTable[32] =
  200.10 -{
  200.11 -  0, 0, 0, 0, 0, 0, 0, 0,
  200.12 -  0, 0, 0, 0, 0, 0, 0, 0,
  200.13 -  4, 4, 6, 6, 0, 0, 7, 7,
  200.14 -  4, 4, 0, 0, 4, 4, 0, 0
  200.15 -};
  200.16 -
  200.17 -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
  200.18 -{
  200.19 -  SizeT i;
  200.20 -  if (size < 16)
  200.21 -    return 0;
  200.22 -  size -= 16;
  200.23 -  for (i = 0; i <= size; i += 16)
  200.24 -  {
  200.25 -    UInt32 instrTemplate = data[i] & 0x1F;
  200.26 -    UInt32 mask = kBranchTable[instrTemplate];
  200.27 -    UInt32 bitPos = 5;
  200.28 -    int slot;
  200.29 -    for (slot = 0; slot < 3; slot++, bitPos += 41)
  200.30 -    {
  200.31 -      UInt32 bytePos, bitRes;
  200.32 -      UInt64 instruction, instNorm;
  200.33 -      int j;
  200.34 -      if (((mask >> slot) & 1) == 0)
  200.35 -        continue;
  200.36 -      bytePos = (bitPos >> 3);
  200.37 -      bitRes = bitPos & 0x7;
  200.38 -      instruction = 0;
  200.39 -      for (j = 0; j < 6; j++)
  200.40 -        instruction += (UInt64)data[i + j + bytePos] << (8 * j);
  200.41 -
  200.42 -      instNorm = instruction >> bitRes;
  200.43 -      if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
  200.44 -      {
  200.45 -        UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
  200.46 -        UInt32 dest;
  200.47 -        src |= ((UInt32)(instNorm >> 36) & 1) << 20;
  200.48 -        
  200.49 -        src <<= 4;
  200.50 -        
  200.51 -        if (encoding)
  200.52 -          dest = ip + (UInt32)i + src;
  200.53 -        else
  200.54 -          dest = src - (ip + (UInt32)i);
  200.55 -        
  200.56 -        dest >>= 4;
  200.57 -        
  200.58 -        instNorm &= ~((UInt64)(0x8FFFFF) << 13);
  200.59 -        instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
  200.60 -        instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
  200.61 -        
  200.62 -        instruction &= (1 << bitRes) - 1;
  200.63 -        instruction |= (instNorm << bitRes);
  200.64 -        for (j = 0; j < 6; j++)
  200.65 -          data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
  200.66 -      }
  200.67 -    }
  200.68 -  }
  200.69 -  return i;
  200.70 -}
   201.1 --- a/src/win32/7zip/7z/C/BwtSort.c	Sat Mar 03 10:54:39 2012 -0600
   201.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   201.3 @@ -1,516 +0,0 @@
   201.4 -/* BwtSort.c -- BWT block sorting
   201.5 -2008-08-17
   201.6 -Igor Pavlov
   201.7 -Public domain */
   201.8 -
   201.9 -#include "BwtSort.h"
  201.10 -#include "Sort.h"
  201.11 -
  201.12 -/* #define BLOCK_SORT_USE_HEAP_SORT */
  201.13 -
  201.14 -#define NO_INLINE MY_FAST_CALL
  201.15 -
  201.16 -/* Don't change it !!! */
  201.17 -#define kNumHashBytes 2
  201.18 -#define kNumHashValues (1 << (kNumHashBytes * 8))
  201.19 -
  201.20 -/* kNumRefBitsMax must be < (kNumHashBytes * 8) = 16 */
  201.21 -#define kNumRefBitsMax 12
  201.22 -
  201.23 -#define BS_TEMP_SIZE kNumHashValues
  201.24 -
  201.25 -#ifdef BLOCK_SORT_EXTERNAL_FLAGS
  201.26 -
  201.27 -/* 32 Flags in UInt32 word */
  201.28 -#define kNumFlagsBits 5
  201.29 -#define kNumFlagsInWord (1 << kNumFlagsBits)
  201.30 -#define kFlagsMask (kNumFlagsInWord - 1)
  201.31 -#define kAllFlags 0xFFFFFFFF
  201.32 -
  201.33 -#else
  201.34 -
  201.35 -#define kNumBitsMax 20
  201.36 -#define kIndexMask ((1 << kNumBitsMax) - 1)
  201.37 -#define kNumExtraBits (32 - kNumBitsMax)
  201.38 -#define kNumExtra0Bits (kNumExtraBits - 2)
  201.39 -#define kNumExtra0Mask ((1 << kNumExtra0Bits) - 1)
  201.40 -
  201.41 -#define SetFinishedGroupSize(p, size) \
  201.42 -  {  *(p) |= ((((size) - 1) & kNumExtra0Mask) << kNumBitsMax); \
  201.43 -    if ((size) > (1 << kNumExtra0Bits)) { \
  201.44 -    *(p) |= 0x40000000;  *((p) + 1) |= ((((size) - 1)>> kNumExtra0Bits) << kNumBitsMax); } } \
  201.45 -
  201.46 -static void SetGroupSize(UInt32 *p, UInt32 size)
  201.47 -{
  201.48 -  if (--size == 0)
  201.49 -    return;
  201.50 -  *p |= 0x80000000 | ((size & kNumExtra0Mask) << kNumBitsMax);
  201.51 -  if (size >= (1 << kNumExtra0Bits))
  201.52 -  {
  201.53 -    *p |= 0x40000000;
  201.54 -    p[1] |= ((size >> kNumExtra0Bits) << kNumBitsMax);
  201.55 -  }
  201.56 -}
  201.57 -
  201.58 -#endif
  201.59 -
  201.60 -/*
  201.61 -SortGroup - is recursive Range-Sort function with HeapSort optimization for small blocks
  201.62 -  "range" is not real range. It's only for optimization.
  201.63 -returns: 1 - if there are groups, 0 - no more groups
  201.64 -*/
  201.65 -
  201.66 -UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 groupOffset, UInt32 groupSize, int NumRefBits, UInt32 *Indices
  201.67 -  #ifndef BLOCK_SORT_USE_HEAP_SORT
  201.68 -  , UInt32 left, UInt32 range
  201.69 -  #endif
  201.70 -  )
  201.71 -{
  201.72 -  UInt32 *ind2 = Indices + groupOffset;
  201.73 -  UInt32 *Groups;
  201.74 -  if (groupSize <= 1)
  201.75 -  {
  201.76 -    /*
  201.77 -    #ifndef BLOCK_SORT_EXTERNAL_FLAGS
  201.78 -    SetFinishedGroupSize(ind2, 1);
  201.79 -    #endif
  201.80 -    */
  201.81 -    return 0;
  201.82 -  }
  201.83 -  Groups = Indices + BlockSize + BS_TEMP_SIZE;
  201.84 -  if (groupSize <= ((UInt32)1 << NumRefBits)
  201.85 -      #ifndef BLOCK_SORT_USE_HEAP_SORT
  201.86 -      && groupSize <= range
  201.87 -      #endif
  201.88 -      )
  201.89 -  {
  201.90 -    UInt32 *temp = Indices + BlockSize;
  201.91 -    UInt32 j;
  201.92 -    UInt32 mask, thereAreGroups, group, cg;
  201.93 -    {
  201.94 -      UInt32 gPrev;
  201.95 -      UInt32 gRes = 0;
  201.96 -      {
  201.97 -        UInt32 sp = ind2[0] + NumSortedBytes;
  201.98 -        if (sp >= BlockSize) sp -= BlockSize;
  201.99 -        gPrev = Groups[sp];
 201.100 -        temp[0] = (gPrev << NumRefBits);
 201.101 -      }
 201.102 -      
 201.103 -      for (j = 1; j < groupSize; j++)
 201.104 -      {
 201.105 -        UInt32 sp = ind2[j] + NumSortedBytes;
 201.106 -        UInt32 g;
 201.107 -        if (sp >= BlockSize) sp -= BlockSize;
 201.108 -        g = Groups[sp];
 201.109 -        temp[j] = (g << NumRefBits) | j;
 201.110 -        gRes |= (gPrev ^ g);
 201.111 -      }
 201.112 -      if (gRes == 0)
 201.113 -      {
 201.114 -        #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.115 -        SetGroupSize(ind2, groupSize);
 201.116 -        #endif
 201.117 -        return 1;
 201.118 -      }
 201.119 -    }
 201.120 -    
 201.121 -    HeapSort(temp, groupSize);
 201.122 -    mask = ((1 << NumRefBits) - 1);
 201.123 -    thereAreGroups = 0;
 201.124 -    
 201.125 -    group = groupOffset;
 201.126 -    cg = (temp[0] >> NumRefBits);
 201.127 -    temp[0] = ind2[temp[0] & mask];
 201.128 -
 201.129 -    {
 201.130 -    #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.131 -    UInt32 *Flags = Groups + BlockSize;
 201.132 -    #else
 201.133 -    UInt32 prevGroupStart = 0;
 201.134 -    #endif
 201.135 -    
 201.136 -    for (j = 1; j < groupSize; j++)
 201.137 -    {
 201.138 -      UInt32 val = temp[j];
 201.139 -      UInt32 cgCur = (val >> NumRefBits);
 201.140 -      
 201.141 -      if (cgCur != cg)
 201.142 -      {
 201.143 -        cg = cgCur;
 201.144 -        group = groupOffset + j;
 201.145 -
 201.146 -        #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.147 -        {
 201.148 -        UInt32 t = group - 1;
 201.149 -        Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
 201.150 -        }
 201.151 -        #else
 201.152 -        SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
 201.153 -        prevGroupStart = j;
 201.154 -        #endif
 201.155 -      }
 201.156 -      else
 201.157 -        thereAreGroups = 1;
 201.158 -      {
 201.159 -      UInt32 ind = ind2[val & mask];
 201.160 -      temp[j] = ind;
 201.161 -      Groups[ind] = group;
 201.162 -      }
 201.163 -    }
 201.164 -
 201.165 -    #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.166 -    SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
 201.167 -    #endif
 201.168 -    }
 201.169 -
 201.170 -    for (j = 0; j < groupSize; j++)
 201.171 -      ind2[j] = temp[j];
 201.172 -    return thereAreGroups;
 201.173 -  }
 201.174 -
 201.175 -  /* Check that all strings are in one group (cannot sort) */
 201.176 -  {
 201.177 -    UInt32 group, j;
 201.178 -    UInt32 sp = ind2[0] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
 201.179 -    group = Groups[sp];
 201.180 -    for (j = 1; j < groupSize; j++)
 201.181 -    {
 201.182 -      sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
 201.183 -      if (Groups[sp] != group)
 201.184 -        break;
 201.185 -    }
 201.186 -    if (j == groupSize)
 201.187 -    {
 201.188 -      #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.189 -      SetGroupSize(ind2, groupSize);
 201.190 -      #endif
 201.191 -      return 1;
 201.192 -    }
 201.193 -  }
 201.194 -
 201.195 -  #ifndef BLOCK_SORT_USE_HEAP_SORT
 201.196 -  {
 201.197 -  /* ---------- Range Sort ---------- */
 201.198 -  UInt32 i;
 201.199 -  UInt32 mid;
 201.200 -  for (;;)
 201.201 -  {
 201.202 -    UInt32 j;
 201.203 -    if (range <= 1)
 201.204 -    {
 201.205 -      #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.206 -      SetGroupSize(ind2, groupSize);
 201.207 -      #endif
 201.208 -      return 1;
 201.209 -    }
 201.210 -    mid = left + ((range + 1) >> 1);
 201.211 -    j = groupSize;
 201.212 -    i = 0;
 201.213 -    do
 201.214 -    {
 201.215 -      UInt32 sp = ind2[i] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
 201.216 -      if (Groups[sp] >= mid)
 201.217 -      {
 201.218 -        for (j--; j > i; j--)
 201.219 -        {
 201.220 -          sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
 201.221 -          if (Groups[sp] < mid)
 201.222 -          {
 201.223 -            UInt32 temp = ind2[i]; ind2[i] = ind2[j]; ind2[j] = temp;
 201.224 -            break;
 201.225 -          }
 201.226 -        }
 201.227 -        if (i >= j)
 201.228 -          break;
 201.229 -      }
 201.230 -    }
 201.231 -    while (++i < j);
 201.232 -    if (i == 0)
 201.233 -    {
 201.234 -      range = range - (mid - left);
 201.235 -      left = mid;
 201.236 -    }
 201.237 -    else if (i == groupSize)
 201.238 -      range = (mid - left);
 201.239 -    else
 201.240 -      break;
 201.241 -  }
 201.242 -
 201.243 -  #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.244 -  {
 201.245 -    UInt32 t = (groupOffset + i - 1);
 201.246 -    UInt32 *Flags = Groups + BlockSize;
 201.247 -    Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
 201.248 -  }
 201.249 -  #endif
 201.250 -
 201.251 -  {
 201.252 -    UInt32 j;
 201.253 -    for (j = i; j < groupSize; j++)
 201.254 -      Groups[ind2[j]] = groupOffset + i;
 201.255 -  }
 201.256 -
 201.257 -  {
 201.258 -  UInt32 res = SortGroup(BlockSize, NumSortedBytes, groupOffset, i, NumRefBits, Indices, left, mid - left);
 201.259 -  return res | SortGroup(BlockSize, NumSortedBytes, groupOffset + i, groupSize - i, NumRefBits, Indices, mid, range - (mid - left));
 201.260 -  }
 201.261 -
 201.262 -  }
 201.263 -
 201.264 -  #else
 201.265 -
 201.266 -  /* ---------- Heap Sort ---------- */
 201.267 -
 201.268 -  {
 201.269 -    UInt32 j;
 201.270 -    for (j = 0; j < groupSize; j++)
 201.271 -    {
 201.272 -      UInt32 sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
 201.273 -      ind2[j] = sp;
 201.274 -    }
 201.275 -
 201.276 -    HeapSortRef(ind2, Groups, groupSize);
 201.277 -
 201.278 -    /* Write Flags */
 201.279 -    {
 201.280 -    UInt32 sp = ind2[0];
 201.281 -    UInt32 group = Groups[sp];
 201.282 -
 201.283 -    #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.284 -    UInt32 *Flags = Groups + BlockSize;
 201.285 -    #else
 201.286 -    UInt32 prevGroupStart = 0;
 201.287 -    #endif
 201.288 -
 201.289 -    for (j = 1; j < groupSize; j++)
 201.290 -    {
 201.291 -      sp = ind2[j];
 201.292 -      if (Groups[sp] != group)
 201.293 -      {
 201.294 -        group = Groups[sp];
 201.295 -        #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.296 -        {
 201.297 -        UInt32 t = groupOffset + j - 1;
 201.298 -        Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
 201.299 -        }
 201.300 -        #else
 201.301 -        SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
 201.302 -        prevGroupStart = j;
 201.303 -        #endif
 201.304 -      }
 201.305 -    }
 201.306 -
 201.307 -    #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.308 -    SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
 201.309 -    #endif
 201.310 -    }
 201.311 -    {
 201.312 -    /* Write new Groups values and Check that there are groups */
 201.313 -    UInt32 thereAreGroups = 0;
 201.314 -    for (j = 0; j < groupSize; j++)
 201.315 -    {
 201.316 -      UInt32 group = groupOffset + j;
 201.317 -      #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.318 -      UInt32 subGroupSize = ((ind2[j] & ~0xC0000000) >> kNumBitsMax);
 201.319 -      if ((ind2[j] & 0x40000000) != 0)
 201.320 -        subGroupSize += ((ind2[j + 1] >> kNumBitsMax) << kNumExtra0Bits);
 201.321 -      subGroupSize++;
 201.322 -      for (;;)
 201.323 -      {
 201.324 -        UInt32 original = ind2[j];
 201.325 -        UInt32 sp = original & kIndexMask;
 201.326 -        if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
 201.327 -        ind2[j] = sp | (original & ~kIndexMask);
 201.328 -        Groups[sp] = group;
 201.329 -        if (--subGroupSize == 0)
 201.330 -          break;
 201.331 -        j++;
 201.332 -        thereAreGroups = 1;
 201.333 -      }
 201.334 -      #else
 201.335 -      UInt32 *Flags = Groups + BlockSize;
 201.336 -      for (;;)
 201.337 -      {
 201.338 -        UInt32 sp = ind2[j]; if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
 201.339 -        ind2[j] = sp;
 201.340 -        Groups[sp] = group;
 201.341 -        if ((Flags[(groupOffset + j) >> kNumFlagsBits] & (1 << ((groupOffset + j) & kFlagsMask))) == 0)
 201.342 -          break;
 201.343 -        j++;
 201.344 -        thereAreGroups = 1;
 201.345 -      }
 201.346 -      #endif
 201.347 -    }
 201.348 -    return thereAreGroups;
 201.349 -    }
 201.350 -  }
 201.351 -  #endif
 201.352 -}
 201.353 -
 201.354 -/* conditions: blockSize > 0 */
 201.355 -UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
 201.356 -{
 201.357 -  UInt32 *counters = Indices + blockSize;
 201.358 -  UInt32 i;
 201.359 -  UInt32 *Groups;
 201.360 -  #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.361 -  UInt32 *Flags;
 201.362 -  #endif
 201.363 -
 201.364 -  /* Radix-Sort for 2 bytes */
 201.365 -  for (i = 0; i < kNumHashValues; i++)
 201.366 -    counters[i] = 0;
 201.367 -  for (i = 0; i < blockSize - 1; i++)
 201.368 -    counters[((UInt32)data[i] << 8) | data[i + 1]]++;
 201.369 -  counters[((UInt32)data[i] << 8) | data[0]]++;
 201.370 -
 201.371 -  Groups = counters + BS_TEMP_SIZE;
 201.372 -  #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.373 -  Flags = Groups + blockSize;
 201.374 -    {
 201.375 -      UInt32 numWords = (blockSize + kFlagsMask) >> kNumFlagsBits;
 201.376 -      for (i = 0; i < numWords; i++)
 201.377 -        Flags[i] = kAllFlags;
 201.378 -    }
 201.379 -  #endif
 201.380 -
 201.381 -  {
 201.382 -    UInt32 sum = 0;
 201.383 -    for (i = 0; i < kNumHashValues; i++)
 201.384 -    {
 201.385 -      UInt32 groupSize = counters[i];
 201.386 -      if (groupSize > 0)
 201.387 -      {
 201.388 -        #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.389 -        UInt32 t = sum + groupSize - 1;
 201.390 -        Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
 201.391 -        #endif
 201.392 -        sum += groupSize;
 201.393 -      }
 201.394 -      counters[i] = sum - groupSize;
 201.395 -    }
 201.396 -
 201.397 -    for (i = 0; i < blockSize - 1; i++)
 201.398 -      Groups[i] = counters[((UInt32)data[i] << 8) | data[i + 1]];
 201.399 -    Groups[i] = counters[((UInt32)data[i] << 8) | data[0]];
 201.400 -
 201.401 -    for (i = 0; i < blockSize - 1; i++)
 201.402 -      Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
 201.403 -    Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
 201.404 -    
 201.405 -    #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.406 -    {
 201.407 -    UInt32 prev = 0;
 201.408 -    for (i = 0; i < kNumHashValues; i++)
 201.409 -    {
 201.410 -      UInt32 prevGroupSize = counters[i] - prev;
 201.411 -      if (prevGroupSize == 0)
 201.412 -        continue;
 201.413 -      SetGroupSize(Indices + prev, prevGroupSize);
 201.414 -      prev = counters[i];
 201.415 -    }
 201.416 -    }
 201.417 -    #endif
 201.418 -  }
 201.419 -
 201.420 -  {
 201.421 -  int NumRefBits;
 201.422 -  UInt32 NumSortedBytes;
 201.423 -  for (NumRefBits = 0; ((blockSize - 1) >> NumRefBits) != 0; NumRefBits++);
 201.424 -  NumRefBits = 32 - NumRefBits;
 201.425 -  if (NumRefBits > kNumRefBitsMax)
 201.426 -    NumRefBits = kNumRefBitsMax;
 201.427 -
 201.428 -  for (NumSortedBytes = kNumHashBytes; ; NumSortedBytes <<= 1)
 201.429 -  {
 201.430 -    #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.431 -    UInt32 finishedGroupSize = 0;
 201.432 -    #endif
 201.433 -    UInt32 newLimit = 0;
 201.434 -    for (i = 0; i < blockSize;)
 201.435 -    {
 201.436 -      UInt32 groupSize;
 201.437 -      #ifdef BLOCK_SORT_EXTERNAL_FLAGS
 201.438 -
 201.439 -      if ((Flags[i >> kNumFlagsBits] & (1 << (i & kFlagsMask))) == 0)
 201.440 -      {
 201.441 -        i++;
 201.442 -        continue;
 201.443 -      }
 201.444 -      for (groupSize = 1;
 201.445 -        (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
 201.446 -        groupSize++);
 201.447 -      
 201.448 -      groupSize++;
 201.449 -
 201.450 -      #else
 201.451 -
 201.452 -      groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
 201.453 -      {
 201.454 -      Bool finishedGroup = ((Indices[i] & 0x80000000) == 0);
 201.455 -      if ((Indices[i] & 0x40000000) != 0)
 201.456 -      {
 201.457 -        groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
 201.458 -        Indices[i + 1] &= kIndexMask;
 201.459 -      }
 201.460 -      Indices[i] &= kIndexMask;
 201.461 -      groupSize++;
 201.462 -      if (finishedGroup || groupSize == 1)
 201.463 -      {
 201.464 -        Indices[i - finishedGroupSize] &= kIndexMask;
 201.465 -        if (finishedGroupSize > 1)
 201.466 -          Indices[i - finishedGroupSize + 1] &= kIndexMask;
 201.467 -        {
 201.468 -        UInt32 newGroupSize = groupSize + finishedGroupSize;
 201.469 -        SetFinishedGroupSize(Indices + i - finishedGroupSize, newGroupSize);
 201.470 -        finishedGroupSize = newGroupSize;
 201.471 -        }
 201.472 -        i += groupSize;
 201.473 -        continue;
 201.474 -      }
 201.475 -      finishedGroupSize = 0;
 201.476 -      }
 201.477 -
 201.478 -      #endif
 201.479 -      
 201.480 -      if (NumSortedBytes >= blockSize)
 201.481 -      {
 201.482 -        UInt32 j;
 201.483 -        for (j = 0; j < groupSize; j++)
 201.484 -        {
 201.485 -          UInt32 t = (i + j);
 201.486 -          /* Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask)); */
 201.487 -          Groups[Indices[t]] = t;
 201.488 -        }
 201.489 -      }
 201.490 -      else
 201.491 -        if (SortGroup(blockSize, NumSortedBytes, i, groupSize, NumRefBits, Indices
 201.492 -          #ifndef BLOCK_SORT_USE_HEAP_SORT
 201.493 -          , 0, blockSize
 201.494 -          #endif
 201.495 -          ) != 0)
 201.496 -          newLimit = i + groupSize;
 201.497 -      i += groupSize;
 201.498 -    }
 201.499 -    if (newLimit == 0)
 201.500 -      break;
 201.501 -  }
 201.502 -  }
 201.503 -  #ifndef BLOCK_SORT_EXTERNAL_FLAGS
 201.504 -  for (i = 0; i < blockSize;)
 201.505 -  {
 201.506 -    UInt32 groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
 201.507 -    if ((Indices[i] & 0x40000000) != 0)
 201.508 -    {
 201.509 -      groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
 201.510 -      Indices[i + 1] &= kIndexMask;
 201.511 -    }
 201.512 -    Indices[i] &= kIndexMask;
 201.513 -    groupSize++;
 201.514 -    i += groupSize;
 201.515 -  }
 201.516 -  #endif
 201.517 -  return Groups[0];
 201.518 -}
 201.519 -
   202.1 --- a/src/win32/7zip/7z/C/BwtSort.h	Sat Mar 03 10:54:39 2012 -0600
   202.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   202.3 @@ -1,24 +0,0 @@
   202.4 -/* BwtSort.h -- BWT block sorting
   202.5 -2008-03-26
   202.6 -Igor Pavlov
   202.7 -Public domain */
   202.8 -
   202.9 -#ifndef __BWTSORT_H
  202.10 -#define __BWTSORT_H
  202.11 -
  202.12 -#include "Types.h"
  202.13 -
  202.14 -/* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M */
  202.15 -/* #define BLOCK_SORT_EXTERNAL_FLAGS */
  202.16 -
  202.17 -#ifdef BLOCK_SORT_EXTERNAL_FLAGS
  202.18 -#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) ((((blockSize) + 31) >> 5))
  202.19 -#else
  202.20 -#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) 0
  202.21 -#endif
  202.22 -
  202.23 -#define BLOCK_SORT_BUF_SIZE(blockSize) ((blockSize) * 2 + BLOCK_SORT_EXTERNAL_SIZE(blockSize) + (1 << 16))
  202.24 -
  202.25 -UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize);
  202.26 -
  202.27 -#endif
   203.1 --- a/src/win32/7zip/7z/C/CpuArch.h	Sat Mar 03 10:54:39 2012 -0600
   203.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   203.3 @@ -1,69 +0,0 @@
   203.4 -/* CpuArch.h
   203.5 -2008-08-05
   203.6 -Igor Pavlov
   203.7 -Public domain */
   203.8 -
   203.9 -#ifndef __CPUARCH_H
  203.10 -#define __CPUARCH_H
  203.11 -
  203.12 -/*
  203.13 -LITTLE_ENDIAN_UNALIGN means:
  203.14 -  1) CPU is LITTLE_ENDIAN
  203.15 -  2) it's allowed to make unaligned memory accesses
  203.16 -if LITTLE_ENDIAN_UNALIGN is not defined, it means that we don't know
  203.17 -about these properties of platform.
  203.18 -*/
  203.19 -
  203.20 -#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__)
  203.21 -#define LITTLE_ENDIAN_UNALIGN
  203.22 -#endif
  203.23 -
  203.24 -#ifdef LITTLE_ENDIAN_UNALIGN
  203.25 -
  203.26 -#define GetUi16(p) (*(const UInt16 *)(p))
  203.27 -#define GetUi32(p) (*(const UInt32 *)(p))
  203.28 -#define GetUi64(p) (*(const UInt64 *)(p))
  203.29 -#define SetUi32(p, d) *(UInt32 *)(p) = (d);
  203.30 -
  203.31 -#else
  203.32 -
  203.33 -#define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8))
  203.34 -
  203.35 -#define GetUi32(p) ( \
  203.36 -             ((const Byte *)(p))[0]        | \
  203.37 -    ((UInt32)((const Byte *)(p))[1] <<  8) | \
  203.38 -    ((UInt32)((const Byte *)(p))[2] << 16) | \
  203.39 -    ((UInt32)((const Byte *)(p))[3] << 24))
  203.40 -
  203.41 -#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
  203.42 -
  203.43 -#define SetUi32(p, d) { UInt32 _x_ = (d); \
  203.44 -    ((Byte *)(p))[0] = (Byte)_x_; \
  203.45 -    ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \
  203.46 -    ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
  203.47 -    ((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
  203.48 -
  203.49 -#endif
  203.50 -
  203.51 -#if defined(LITTLE_ENDIAN_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
  203.52 -
  203.53 -#pragma intrinsic(_byteswap_ulong)
  203.54 -#pragma intrinsic(_byteswap_uint64)
  203.55 -#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
  203.56 -#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
  203.57 -
  203.58 -#else
  203.59 -
  203.60 -#define GetBe32(p) ( \
  203.61 -    ((UInt32)((const Byte *)(p))[0] << 24) | \
  203.62 -    ((UInt32)((const Byte *)(p))[1] << 16) | \
  203.63 -    ((UInt32)((const Byte *)(p))[2] <<  8) | \
  203.64 -             ((const Byte *)(p))[3] )
  203.65 -
  203.66 -#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
  203.67 -
  203.68 -#endif
  203.69 -
  203.70 -#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1])
  203.71 -
  203.72 -#endif
   204.1 --- a/src/win32/7zip/7z/C/HuffEnc.c	Sat Mar 03 10:54:39 2012 -0600
   204.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   204.3 @@ -1,148 +0,0 @@
   204.4 -/* HuffEnc.c -- functions for Huffman encoding
   204.5 -2008-08-05
   204.6 -Igor Pavlov
   204.7 -Public domain */
   204.8 -
   204.9 -#include "HuffEnc.h"
  204.10 -#include "Sort.h"
  204.11 -
  204.12 -#define kMaxLen 16
  204.13 -#define NUM_BITS 10
  204.14 -#define MASK ((1 << NUM_BITS) - 1)
  204.15 -
  204.16 -#define NUM_COUNTERS 64
  204.17 -
  204.18 -#define HUFFMAN_SPEED_OPT
  204.19 -
  204.20 -void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymbols, UInt32 maxLen)
  204.21 -{
  204.22 -  UInt32 num = 0;
  204.23 -  /* if (maxLen > 10) maxLen = 10; */
  204.24 -  {
  204.25 -    UInt32 i;
  204.26 -    
  204.27 -    #ifdef HUFFMAN_SPEED_OPT
  204.28 -    
  204.29 -    UInt32 counters[NUM_COUNTERS];
  204.30 -    for (i = 0; i < NUM_COUNTERS; i++)
  204.31 -      counters[i] = 0;
  204.32 -    for (i = 0; i < numSymbols; i++)
  204.33 -    {
  204.34 -      UInt32 freq = freqs[i];
  204.35 -      counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++;
  204.36 -    }
  204.37 - 
  204.38 -    for (i = 1; i < NUM_COUNTERS; i++)
  204.39 -    {
  204.40 -      UInt32 temp = counters[i];
  204.41 -      counters[i] = num;
  204.42 -      num += temp;
  204.43 -    }
  204.44 -
  204.45 -    for (i = 0; i < numSymbols; i++)
  204.46 -    {
  204.47 -      UInt32 freq = freqs[i];
  204.48 -      if (freq == 0)
  204.49 -        lens[i] = 0;
  204.50 -      else
  204.51 -        p[counters[((freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1)]++] = i | (freq << NUM_BITS);
  204.52 -    }
  204.53 -    counters[0] = 0;
  204.54 -    HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]);
  204.55 -    
  204.56 -    #else
  204.57 -
  204.58 -    for (i = 0; i < numSymbols; i++)
  204.59 -    {
  204.60 -      UInt32 freq = freqs[i];
  204.61 -      if (freq == 0)
  204.62 -        lens[i] = 0;
  204.63 -      else
  204.64 -        p[num++] = i | (freq << NUM_BITS);
  204.65 -    }
  204.66 -    HeapSort(p, num);
  204.67 -
  204.68 -    #endif
  204.69 -  }
  204.70 -
  204.71 -  if (num < 2)
  204.72 -  {
  204.73 -    int minCode = 0;
  204.74 -    int maxCode = 1;
  204.75 -    if (num == 1)
  204.76 -    {
  204.77 -      maxCode = (int)(p[0] & MASK);
  204.78 -      if (maxCode == 0)
  204.79 -        maxCode++;
  204.80 -    }
  204.81 -    p[minCode] = 0;
  204.82 -    p[maxCode] = 1;
  204.83 -    lens[minCode] = lens[maxCode] = 1;
  204.84 -    return;
  204.85 -  }
  204.86 -  
  204.87 -  {
  204.88 -    UInt32 b, e, i;
  204.89 -  
  204.90 -    i = b = e = 0;
  204.91 -    do
  204.92 -    {
  204.93 -      UInt32 n, m, freq;
  204.94 -      n = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
  204.95 -      freq = (p[n] & ~MASK);
  204.96 -      p[n] = (p[n] & MASK) | (e << NUM_BITS);
  204.97 -      m = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
  204.98 -      freq += (p[m] & ~MASK);
  204.99 -      p[m] = (p[m] & MASK) | (e << NUM_BITS);
 204.100 -      p[e] = (p[e] & MASK) | freq;
 204.101 -      e++;
 204.102 -    }
 204.103 -    while (num - e > 1);
 204.104 -    
 204.105 -    {
 204.106 -      UInt32 lenCounters[kMaxLen + 1];
 204.107 -      for (i = 0; i <= kMaxLen; i++)
 204.108 -        lenCounters[i] = 0;
 204.109 -      
 204.110 -      p[--e] &= MASK;
 204.111 -      lenCounters[1] = 2;
 204.112 -      while (e > 0)
 204.113 -      {
 204.114 -        UInt32 len = (p[p[--e] >> NUM_BITS] >> NUM_BITS) + 1;
 204.115 -        p[e] = (p[e] & MASK) | (len << NUM_BITS);
 204.116 -        if (len >= maxLen)
 204.117 -          for (len = maxLen - 1; lenCounters[len] == 0; len--);
 204.118 -        lenCounters[len]--;
 204.119 -        lenCounters[len + 1] += 2;
 204.120 -      }
 204.121 -      
 204.122 -      {
 204.123 -        UInt32 len;
 204.124 -        i = 0;
 204.125 -        for (len = maxLen; len != 0; len--)
 204.126 -        {
 204.127 -          UInt32 num;
 204.128 -          for (num = lenCounters[len]; num != 0; num--)
 204.129 -            lens[p[i++] & MASK] = (Byte)len;
 204.130 -        }
 204.131 -      }
 204.132 -      
 204.133 -      {
 204.134 -        UInt32 nextCodes[kMaxLen + 1];
 204.135 -        {
 204.136 -          UInt32 code = 0;
 204.137 -          UInt32 len;
 204.138 -          for (len = 1; len <= kMaxLen; len++)
 204.139 -            nextCodes[len] = code = (code + lenCounters[len - 1]) << 1;
 204.140 -        }
 204.141 -        /* if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; */
 204.142 -
 204.143 -        {
 204.144 -          UInt32 i;
 204.145 -          for (i = 0; i < numSymbols; i++)
 204.146 -            p[i] = nextCodes[lens[i]]++;
 204.147 -        }
 204.148 -      }
 204.149 -    }
 204.150 -  }
 204.151 -}
   205.1 --- a/src/win32/7zip/7z/C/HuffEnc.h	Sat Mar 03 10:54:39 2012 -0600
   205.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   205.3 @@ -1,21 +0,0 @@
   205.4 -/* HuffEnc.h -- functions for Huffman encoding
   205.5 -2008-03-26
   205.6 -Igor Pavlov
   205.7 -Public domain */
   205.8 -
   205.9 -#ifndef __HUFFENC_H
  205.10 -#define __HUFFENC_H
  205.11 -
  205.12 -#include "Types.h"
  205.13 -
  205.14 -/*
  205.15 -Conditions:
  205.16 -  num <= 1024 = 2 ^ NUM_BITS
  205.17 -  Sum(freqs) < 4M = 2 ^ (32 - NUM_BITS)
  205.18 -  maxLen <= 16 = kMaxLen
  205.19 -  Num_Items(p) >= HUFFMAN_TEMP_SIZE(num)
  205.20 -*/
  205.21 - 
  205.22 -void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
  205.23 -
  205.24 -#endif
   206.1 --- a/src/win32/7zip/7z/C/LzFind.c	Sat Mar 03 10:54:39 2012 -0600
   206.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   206.3 @@ -1,751 +0,0 @@
   206.4 -/* LzFind.c -- Match finder for LZ algorithms
   206.5 -2008-10-04 : Igor Pavlov : Public domain */
   206.6 -
   206.7 -#include <string.h>
   206.8 -
   206.9 -#include "LzFind.h"
  206.10 -#include "LzHash.h"
  206.11 -
  206.12 -#define kEmptyHashValue 0
  206.13 -#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
  206.14 -#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
  206.15 -#define kNormalizeMask (~(kNormalizeStepMin - 1))
  206.16 -#define kMaxHistorySize ((UInt32)3 << 30)
  206.17 -
  206.18 -#define kStartMaxLen 3
  206.19 -
  206.20 -static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
  206.21 -{
  206.22 -  if (!p->directInput)
  206.23 -  {
  206.24 -    alloc->Free(alloc, p->bufferBase);
  206.25 -    p->bufferBase = 0;
  206.26 -  }
  206.27 -}
  206.28 -
  206.29 -/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
  206.30 -
  206.31 -static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
  206.32 -{
  206.33 -  UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
  206.34 -  if (p->directInput)
  206.35 -  {
  206.36 -    p->blockSize = blockSize;
  206.37 -    return 1;
  206.38 -  }
  206.39 -  if (p->bufferBase == 0 || p->blockSize != blockSize)
  206.40 -  {
  206.41 -    LzInWindow_Free(p, alloc);
  206.42 -    p->blockSize = blockSize;
  206.43 -    p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
  206.44 -  }
  206.45 -  return (p->bufferBase != 0);
  206.46 -}
  206.47 -
  206.48 -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
  206.49 -Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
  206.50 -
  206.51 -UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
  206.52 -
  206.53 -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
  206.54 -{
  206.55 -  p->posLimit -= subValue;
  206.56 -  p->pos -= subValue;
  206.57 -  p->streamPos -= subValue;
  206.58 -}
  206.59 -
  206.60 -static void MatchFinder_ReadBlock(CMatchFinder *p)
  206.61 -{
  206.62 -  if (p->streamEndWasReached || p->result != SZ_OK)
  206.63 -    return;
  206.64 -  for (;;)
  206.65 -  {
  206.66 -    Byte *dest = p->buffer + (p->streamPos - p->pos);
  206.67 -    size_t size = (p->bufferBase + p->blockSize - dest);
  206.68 -    if (size == 0)
  206.69 -      return;
  206.70 -    p->result = p->stream->Read(p->stream, dest, &size);
  206.71 -    if (p->result != SZ_OK)
  206.72 -      return;
  206.73 -    if (size == 0)
  206.74 -    {
  206.75 -      p->streamEndWasReached = 1;
  206.76 -      return;
  206.77 -    }
  206.78 -    p->streamPos += (UInt32)size;
  206.79 -    if (p->streamPos - p->pos > p->keepSizeAfter)
  206.80 -      return;
  206.81 -  }
  206.82 -}
  206.83 -
  206.84 -void MatchFinder_MoveBlock(CMatchFinder *p)
  206.85 -{
  206.86 -  memmove(p->bufferBase,
  206.87 -    p->buffer - p->keepSizeBefore,
  206.88 -    (size_t)(p->streamPos - p->pos + p->keepSizeBefore));
  206.89 -  p->buffer = p->bufferBase + p->keepSizeBefore;
  206.90 -}
  206.91 -
  206.92 -int MatchFinder_NeedMove(CMatchFinder *p)
  206.93 -{
  206.94 -  /* if (p->streamEndWasReached) return 0; */
  206.95 -  return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
  206.96 -}
  206.97 -
  206.98 -void MatchFinder_ReadIfRequired(CMatchFinder *p)
  206.99 -{
 206.100 -  if (p->streamEndWasReached)
 206.101 -    return;
 206.102 -  if (p->keepSizeAfter >= p->streamPos - p->pos)
 206.103 -    MatchFinder_ReadBlock(p);
 206.104 -}
 206.105 -
 206.106 -static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
 206.107 -{
 206.108 -  if (MatchFinder_NeedMove(p))
 206.109 -    MatchFinder_MoveBlock(p);
 206.110 -  MatchFinder_ReadBlock(p);
 206.111 -}
 206.112 -
 206.113 -static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
 206.114 -{
 206.115 -  p->cutValue = 32;
 206.116 -  p->btMode = 1;
 206.117 -  p->numHashBytes = 4;
 206.118 -  /* p->skipModeBits = 0; */
 206.119 -  p->directInput = 0;
 206.120 -  p->bigHash = 0;
 206.121 -}
 206.122 -
 206.123 -#define kCrcPoly 0xEDB88320
 206.124 -
 206.125 -void MatchFinder_Construct(CMatchFinder *p)
 206.126 -{
 206.127 -  UInt32 i;
 206.128 -  p->bufferBase = 0;
 206.129 -  p->directInput = 0;
 206.130 -  p->hash = 0;
 206.131 -  MatchFinder_SetDefaultSettings(p);
 206.132 -
 206.133 -  for (i = 0; i < 256; i++)
 206.134 -  {
 206.135 -    UInt32 r = i;
 206.136 -    int j;
 206.137 -    for (j = 0; j < 8; j++)
 206.138 -      r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
 206.139 -    p->crc[i] = r;
 206.140 -  }
 206.141 -}
 206.142 -
 206.143 -static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
 206.144 -{
 206.145 -  alloc->Free(alloc, p->hash);
 206.146 -  p->hash = 0;
 206.147 -}
 206.148 -
 206.149 -void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
 206.150 -{
 206.151 -  MatchFinder_FreeThisClassMemory(p, alloc);
 206.152 -  LzInWindow_Free(p, alloc);
 206.153 -}
 206.154 -
 206.155 -static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
 206.156 -{
 206.157 -  size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
 206.158 -  if (sizeInBytes / sizeof(CLzRef) != num)
 206.159 -    return 0;
 206.160 -  return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
 206.161 -}
 206.162 -
 206.163 -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
 206.164 -    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
 206.165 -    ISzAlloc *alloc)
 206.166 -{
 206.167 -  UInt32 sizeReserv;
 206.168 -  if (historySize > kMaxHistorySize)
 206.169 -  {
 206.170 -    MatchFinder_Free(p, alloc);
 206.171 -    return 0;
 206.172 -  }
 206.173 -  sizeReserv = historySize >> 1;
 206.174 -  if (historySize > ((UInt32)2 << 30))
 206.175 -    sizeReserv = historySize >> 2;
 206.176 -  sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
 206.177 -
 206.178 -  p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
 206.179 -  p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
 206.180 -  /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
 206.181 -  if (LzInWindow_Create(p, sizeReserv, alloc))
 206.182 -  {
 206.183 -    UInt32 newCyclicBufferSize = (historySize /* >> p->skipModeBits */) + 1;
 206.184 -    UInt32 hs;
 206.185 -    p->matchMaxLen = matchMaxLen;
 206.186 -    {
 206.187 -      p->fixedHashSize = 0;
 206.188 -      if (p->numHashBytes == 2)
 206.189 -        hs = (1 << 16) - 1;
 206.190 -      else
 206.191 -      {
 206.192 -        hs = historySize - 1;
 206.193 -        hs |= (hs >> 1);
 206.194 -        hs |= (hs >> 2);
 206.195 -        hs |= (hs >> 4);
 206.196 -        hs |= (hs >> 8);
 206.197 -        hs >>= 1;
 206.198 -        /* hs >>= p->skipModeBits; */
 206.199 -        hs |= 0xFFFF; /* don't change it! It's required for Deflate */
 206.200 -        if (hs > (1 << 24))
 206.201 -        {
 206.202 -          if (p->numHashBytes == 3)
 206.203 -            hs = (1 << 24) - 1;
 206.204 -          else
 206.205 -            hs >>= 1;
 206.206 -        }
 206.207 -      }
 206.208 -      p->hashMask = hs;
 206.209 -      hs++;
 206.210 -      if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
 206.211 -      if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
 206.212 -      if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
 206.213 -      hs += p->fixedHashSize;
 206.214 -    }
 206.215 -
 206.216 -    {
 206.217 -      UInt32 prevSize = p->hashSizeSum + p->numSons;
 206.218 -      UInt32 newSize;
 206.219 -      p->historySize = historySize;
 206.220 -      p->hashSizeSum = hs;
 206.221 -      p->cyclicBufferSize = newCyclicBufferSize;
 206.222 -      p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
 206.223 -      newSize = p->hashSizeSum + p->numSons;
 206.224 -      if (p->hash != 0 && prevSize == newSize)
 206.225 -        return 1;
 206.226 -      MatchFinder_FreeThisClassMemory(p, alloc);
 206.227 -      p->hash = AllocRefs(newSize, alloc);
 206.228 -      if (p->hash != 0)
 206.229 -      {
 206.230 -        p->son = p->hash + p->hashSizeSum;
 206.231 -        return 1;
 206.232 -      }
 206.233 -    }
 206.234 -  }
 206.235 -  MatchFinder_Free(p, alloc);
 206.236 -  return 0;
 206.237 -}
 206.238 -
 206.239 -static void MatchFinder_SetLimits(CMatchFinder *p)
 206.240 -{
 206.241 -  UInt32 limit = kMaxValForNormalize - p->pos;
 206.242 -  UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
 206.243 -  if (limit2 < limit)
 206.244 -    limit = limit2;
 206.245 -  limit2 = p->streamPos - p->pos;
 206.246 -  if (limit2 <= p->keepSizeAfter)
 206.247 -  {
 206.248 -    if (limit2 > 0)
 206.249 -      limit2 = 1;
 206.250 -  }
 206.251 -  else
 206.252 -    limit2 -= p->keepSizeAfter;
 206.253 -  if (limit2 < limit)
 206.254 -    limit = limit2;
 206.255 -  {
 206.256 -    UInt32 lenLimit = p->streamPos - p->pos;
 206.257 -    if (lenLimit > p->matchMaxLen)
 206.258 -      lenLimit = p->matchMaxLen;
 206.259 -    p->lenLimit = lenLimit;
 206.260 -  }
 206.261 -  p->posLimit = p->pos + limit;
 206.262 -}
 206.263 -
 206.264 -void MatchFinder_Init(CMatchFinder *p)
 206.265 -{
 206.266 -  UInt32 i;
 206.267 -  for (i = 0; i < p->hashSizeSum; i++)
 206.268 -    p->hash[i] = kEmptyHashValue;
 206.269 -  p->cyclicBufferPos = 0;
 206.270 -  p->buffer = p->bufferBase;
 206.271 -  p->pos = p->streamPos = p->cyclicBufferSize;
 206.272 -  p->result = SZ_OK;
 206.273 -  p->streamEndWasReached = 0;
 206.274 -  MatchFinder_ReadBlock(p);
 206.275 -  MatchFinder_SetLimits(p);
 206.276 -}
 206.277 -
 206.278 -static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
 206.279 -{
 206.280 -  return (p->pos - p->historySize - 1) & kNormalizeMask;
 206.281 -}
 206.282 -
 206.283 -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
 206.284 -{
 206.285 -  UInt32 i;
 206.286 -  for (i = 0; i < numItems; i++)
 206.287 -  {
 206.288 -    UInt32 value = items[i];
 206.289 -    if (value <= subValue)
 206.290 -      value = kEmptyHashValue;
 206.291 -    else
 206.292 -      value -= subValue;
 206.293 -    items[i] = value;
 206.294 -  }
 206.295 -}
 206.296 -
 206.297 -static void MatchFinder_Normalize(CMatchFinder *p)
 206.298 -{
 206.299 -  UInt32 subValue = MatchFinder_GetSubValue(p);
 206.300 -  MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
 206.301 -  MatchFinder_ReduceOffsets(p, subValue);
 206.302 -}
 206.303 -
 206.304 -static void MatchFinder_CheckLimits(CMatchFinder *p)
 206.305 -{
 206.306 -  if (p->pos == kMaxValForNormalize)
 206.307 -    MatchFinder_Normalize(p);
 206.308 -  if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
 206.309 -    MatchFinder_CheckAndMoveAndRead(p);
 206.310 -  if (p->cyclicBufferPos == p->cyclicBufferSize)
 206.311 -    p->cyclicBufferPos = 0;
 206.312 -  MatchFinder_SetLimits(p);
 206.313 -}
 206.314 -
 206.315 -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
 206.316 -    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
 206.317 -    UInt32 *distances, UInt32 maxLen)
 206.318 -{
 206.319 -  son[_cyclicBufferPos] = curMatch;
 206.320 -  for (;;)
 206.321 -  {
 206.322 -    UInt32 delta = pos - curMatch;
 206.323 -    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
 206.324 -      return distances;
 206.325 -    {
 206.326 -      const Byte *pb = cur - delta;
 206.327 -      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
 206.328 -      if (pb[maxLen] == cur[maxLen] && *pb == *cur)
 206.329 -      {
 206.330 -        UInt32 len = 0;
 206.331 -        while (++len != lenLimit)
 206.332 -          if (pb[len] != cur[len])
 206.333 -            break;
 206.334 -        if (maxLen < len)
 206.335 -        {
 206.336 -          *distances++ = maxLen = len;
 206.337 -          *distances++ = delta - 1;
 206.338 -          if (len == lenLimit)
 206.339 -            return distances;
 206.340 -        }
 206.341 -      }
 206.342 -    }
 206.343 -  }
 206.344 -}
 206.345 -
 206.346 -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
 206.347 -    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
 206.348 -    UInt32 *distances, UInt32 maxLen)
 206.349 -{
 206.350 -  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
 206.351 -  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
 206.352 -  UInt32 len0 = 0, len1 = 0;
 206.353 -  for (;;)
 206.354 -  {
 206.355 -    UInt32 delta = pos - curMatch;
 206.356 -    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
 206.357 -    {
 206.358 -      *ptr0 = *ptr1 = kEmptyHashValue;
 206.359 -      return distances;
 206.360 -    }
 206.361 -    {
 206.362 -      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
 206.363 -      const Byte *pb = cur - delta;
 206.364 -      UInt32 len = (len0 < len1 ? len0 : len1);
 206.365 -      if (pb[len] == cur[len])
 206.366 -      {
 206.367 -        if (++len != lenLimit && pb[len] == cur[len])
 206.368 -          while (++len != lenLimit)
 206.369 -            if (pb[len] != cur[len])
 206.370 -              break;
 206.371 -        if (maxLen < len)
 206.372 -        {
 206.373 -          *distances++ = maxLen = len;
 206.374 -          *distances++ = delta - 1;
 206.375 -          if (len == lenLimit)
 206.376 -          {
 206.377 -            *ptr1 = pair[0];
 206.378 -            *ptr0 = pair[1];
 206.379 -            return distances;
 206.380 -          }
 206.381 -        }
 206.382 -      }
 206.383 -      if (pb[len] < cur[len])
 206.384 -      {
 206.385 -        *ptr1 = curMatch;
 206.386 -        ptr1 = pair + 1;
 206.387 -        curMatch = *ptr1;
 206.388 -        len1 = len;
 206.389 -      }
 206.390 -      else
 206.391 -      {
 206.392 -        *ptr0 = curMatch;
 206.393 -        ptr0 = pair;
 206.394 -        curMatch = *ptr0;
 206.395 -        len0 = len;
 206.396 -      }
 206.397 -    }
 206.398 -  }
 206.399 -}
 206.400 -
 206.401 -static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
 206.402 -    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
 206.403 -{
 206.404 -  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
 206.405 -  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
 206.406 -  UInt32 len0 = 0, len1 = 0;
 206.407 -  for (;;)
 206.408 -  {
 206.409 -    UInt32 delta = pos - curMatch;
 206.410 -    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
 206.411 -    {
 206.412 -      *ptr0 = *ptr1 = kEmptyHashValue;
 206.413 -      return;
 206.414 -    }
 206.415 -    {
 206.416 -      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
 206.417 -      const Byte *pb = cur - delta;
 206.418 -      UInt32 len = (len0 < len1 ? len0 : len1);
 206.419 -      if (pb[len] == cur[len])
 206.420 -      {
 206.421 -        while (++len != lenLimit)
 206.422 -          if (pb[len] != cur[len])
 206.423 -            break;
 206.424 -        {
 206.425 -          if (len == lenLimit)
 206.426 -          {
 206.427 -            *ptr1 = pair[0];
 206.428 -            *ptr0 = pair[1];
 206.429 -            return;
 206.430 -          }
 206.431 -        }
 206.432 -      }
 206.433 -      if (pb[len] < cur[len])
 206.434 -      {
 206.435 -        *ptr1 = curMatch;
 206.436 -        ptr1 = pair + 1;
 206.437 -        curMatch = *ptr1;
 206.438 -        len1 = len;
 206.439 -      }
 206.440 -      else
 206.441 -      {
 206.442 -        *ptr0 = curMatch;
 206.443 -        ptr0 = pair;
 206.444 -        curMatch = *ptr0;
 206.445 -        len0 = len;
 206.446 -      }
 206.447 -    }
 206.448 -  }
 206.449 -}
 206.450 -
 206.451 -#define MOVE_POS \
 206.452 -  ++p->cyclicBufferPos; \
 206.453 -  p->buffer++; \
 206.454 -  if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
 206.455 -
 206.456 -#define MOVE_POS_RET MOVE_POS return offset;
 206.457 -
 206.458 -static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
 206.459 -
 206.460 -#define GET_MATCHES_HEADER2(minLen, ret_op) \
 206.461 -  UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
 206.462 -  lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
 206.463 -  cur = p->buffer;
 206.464 -
 206.465 -#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
 206.466 -#define SKIP_HEADER(minLen)        GET_MATCHES_HEADER2(minLen, continue)
 206.467 -
 206.468 -#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
 206.469 -
 206.470 -#define GET_MATCHES_FOOTER(offset, maxLen) \
 206.471 -  offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
 206.472 -  distances + offset, maxLen) - distances); MOVE_POS_RET;
 206.473 -
 206.474 -#define SKIP_FOOTER \
 206.475 -  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
 206.476 -
 206.477 -static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.478 -{
 206.479 -  UInt32 offset;
 206.480 -  GET_MATCHES_HEADER(2)
 206.481 -  HASH2_CALC;
 206.482 -  curMatch = p->hash[hashValue];
 206.483 -  p->hash[hashValue] = p->pos;
 206.484 -  offset = 0;
 206.485 -  GET_MATCHES_FOOTER(offset, 1)
 206.486 -}
 206.487 -
 206.488 -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.489 -{
 206.490 -  UInt32 offset;
 206.491 -  GET_MATCHES_HEADER(3)
 206.492 -  HASH_ZIP_CALC;
 206.493 -  curMatch = p->hash[hashValue];
 206.494 -  p->hash[hashValue] = p->pos;
 206.495 -  offset = 0;
 206.496 -  GET_MATCHES_FOOTER(offset, 2)
 206.497 -}
 206.498 -
 206.499 -static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.500 -{
 206.501 -  UInt32 hash2Value, delta2, maxLen, offset;
 206.502 -  GET_MATCHES_HEADER(3)
 206.503 -
 206.504 -  HASH3_CALC;
 206.505 -
 206.506 -  delta2 = p->pos - p->hash[hash2Value];
 206.507 -  curMatch = p->hash[kFix3HashSize + hashValue];
 206.508 -  
 206.509 -  p->hash[hash2Value] =
 206.510 -  p->hash[kFix3HashSize + hashValue] = p->pos;
 206.511 -
 206.512 -
 206.513 -  maxLen = 2;
 206.514 -  offset = 0;
 206.515 -  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
 206.516 -  {
 206.517 -    for (; maxLen != lenLimit; maxLen++)
 206.518 -      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
 206.519 -        break;
 206.520 -    distances[0] = maxLen;
 206.521 -    distances[1] = delta2 - 1;
 206.522 -    offset = 2;
 206.523 -    if (maxLen == lenLimit)
 206.524 -    {
 206.525 -      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
 206.526 -      MOVE_POS_RET;
 206.527 -    }
 206.528 -  }
 206.529 -  GET_MATCHES_FOOTER(offset, maxLen)
 206.530 -}
 206.531 -
 206.532 -static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.533 -{
 206.534 -  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
 206.535 -  GET_MATCHES_HEADER(4)
 206.536 -
 206.537 -  HASH4_CALC;
 206.538 -
 206.539 -  delta2 = p->pos - p->hash[                hash2Value];
 206.540 -  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
 206.541 -  curMatch = p->hash[kFix4HashSize + hashValue];
 206.542 -  
 206.543 -  p->hash[                hash2Value] =
 206.544 -  p->hash[kFix3HashSize + hash3Value] =
 206.545 -  p->hash[kFix4HashSize + hashValue] = p->pos;
 206.546 -
 206.547 -  maxLen = 1;
 206.548 -  offset = 0;
 206.549 -  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
 206.550 -  {
 206.551 -    distances[0] = maxLen = 2;
 206.552 -    distances[1] = delta2 - 1;
 206.553 -    offset = 2;
 206.554 -  }
 206.555 -  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
 206.556 -  {
 206.557 -    maxLen = 3;
 206.558 -    distances[offset + 1] = delta3 - 1;
 206.559 -    offset += 2;
 206.560 -    delta2 = delta3;
 206.561 -  }
 206.562 -  if (offset != 0)
 206.563 -  {
 206.564 -    for (; maxLen != lenLimit; maxLen++)
 206.565 -      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
 206.566 -        break;
 206.567 -    distances[offset - 2] = maxLen;
 206.568 -    if (maxLen == lenLimit)
 206.569 -    {
 206.570 -      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
 206.571 -      MOVE_POS_RET;
 206.572 -    }
 206.573 -  }
 206.574 -  if (maxLen < 3)
 206.575 -    maxLen = 3;
 206.576 -  GET_MATCHES_FOOTER(offset, maxLen)
 206.577 -}
 206.578 -
 206.579 -static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.580 -{
 206.581 -  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
 206.582 -  GET_MATCHES_HEADER(4)
 206.583 -
 206.584 -  HASH4_CALC;
 206.585 -
 206.586 -  delta2 = p->pos - p->hash[                hash2Value];
 206.587 -  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
 206.588 -  curMatch = p->hash[kFix4HashSize + hashValue];
 206.589 -
 206.590 -  p->hash[                hash2Value] =
 206.591 -  p->hash[kFix3HashSize + hash3Value] =
 206.592 -  p->hash[kFix4HashSize + hashValue] = p->pos;
 206.593 -
 206.594 -  maxLen = 1;
 206.595 -  offset = 0;
 206.596 -  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
 206.597 -  {
 206.598 -    distances[0] = maxLen = 2;
 206.599 -    distances[1] = delta2 - 1;
 206.600 -    offset = 2;
 206.601 -  }
 206.602 -  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
 206.603 -  {
 206.604 -    maxLen = 3;
 206.605 -    distances[offset + 1] = delta3 - 1;
 206.606 -    offset += 2;
 206.607 -    delta2 = delta3;
 206.608 -  }
 206.609 -  if (offset != 0)
 206.610 -  {
 206.611 -    for (; maxLen != lenLimit; maxLen++)
 206.612 -      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
 206.613 -        break;
 206.614 -    distances[offset - 2] = maxLen;
 206.615 -    if (maxLen == lenLimit)
 206.616 -    {
 206.617 -      p->son[p->cyclicBufferPos] = curMatch;
 206.618 -      MOVE_POS_RET;
 206.619 -    }
 206.620 -  }
 206.621 -  if (maxLen < 3)
 206.622 -    maxLen = 3;
 206.623 -  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
 206.624 -    distances + offset, maxLen) - (distances));
 206.625 -  MOVE_POS_RET
 206.626 -}
 206.627 -
 206.628 -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 206.629 -{
 206.630 -  UInt32 offset;
 206.631 -  GET_MATCHES_HEADER(3)
 206.632 -  HASH_ZIP_CALC;
 206.633 -  curMatch = p->hash[hashValue];
 206.634 -  p->hash[hashValue] = p->pos;
 206.635 -  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
 206.636 -    distances, 2) - (distances));
 206.637 -  MOVE_POS_RET
 206.638 -}
 206.639 -
 206.640 -static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.641 -{
 206.642 -  do
 206.643 -  {
 206.644 -    SKIP_HEADER(2)
 206.645 -    HASH2_CALC;
 206.646 -    curMatch = p->hash[hashValue];
 206.647 -    p->hash[hashValue] = p->pos;
 206.648 -    SKIP_FOOTER
 206.649 -  }
 206.650 -  while (--num != 0);
 206.651 -}
 206.652 -
 206.653 -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.654 -{
 206.655 -  do
 206.656 -  {
 206.657 -    SKIP_HEADER(3)
 206.658 -    HASH_ZIP_CALC;
 206.659 -    curMatch = p->hash[hashValue];
 206.660 -    p->hash[hashValue] = p->pos;
 206.661 -    SKIP_FOOTER
 206.662 -  }
 206.663 -  while (--num != 0);
 206.664 -}
 206.665 -
 206.666 -static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.667 -{
 206.668 -  do
 206.669 -  {
 206.670 -    UInt32 hash2Value;
 206.671 -    SKIP_HEADER(3)
 206.672 -    HASH3_CALC;
 206.673 -    curMatch = p->hash[kFix3HashSize + hashValue];
 206.674 -    p->hash[hash2Value] =
 206.675 -    p->hash[kFix3HashSize + hashValue] = p->pos;
 206.676 -    SKIP_FOOTER
 206.677 -  }
 206.678 -  while (--num != 0);
 206.679 -}
 206.680 -
 206.681 -static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.682 -{
 206.683 -  do
 206.684 -  {
 206.685 -    UInt32 hash2Value, hash3Value;
 206.686 -    SKIP_HEADER(4)
 206.687 -    HASH4_CALC;
 206.688 -    curMatch = p->hash[kFix4HashSize + hashValue];
 206.689 -    p->hash[                hash2Value] =
 206.690 -    p->hash[kFix3HashSize + hash3Value] = p->pos;
 206.691 -    p->hash[kFix4HashSize + hashValue] = p->pos;
 206.692 -    SKIP_FOOTER
 206.693 -  }
 206.694 -  while (--num != 0);
 206.695 -}
 206.696 -
 206.697 -static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.698 -{
 206.699 -  do
 206.700 -  {
 206.701 -    UInt32 hash2Value, hash3Value;
 206.702 -    SKIP_HEADER(4)
 206.703 -    HASH4_CALC;
 206.704 -    curMatch = p->hash[kFix4HashSize + hashValue];
 206.705 -    p->hash[                hash2Value] =
 206.706 -    p->hash[kFix3HashSize + hash3Value] =
 206.707 -    p->hash[kFix4HashSize + hashValue] = p->pos;
 206.708 -    p->son[p->cyclicBufferPos] = curMatch;
 206.709 -    MOVE_POS
 206.710 -  }
 206.711 -  while (--num != 0);
 206.712 -}
 206.713 -
 206.714 -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
 206.715 -{
 206.716 -  do
 206.717 -  {
 206.718 -    SKIP_HEADER(3)
 206.719 -    HASH_ZIP_CALC;
 206.720 -    curMatch = p->hash[hashValue];
 206.721 -    p->hash[hashValue] = p->pos;
 206.722 -    p->son[p->cyclicBufferPos] = curMatch;
 206.723 -    MOVE_POS
 206.724 -  }
 206.725 -  while (--num != 0);
 206.726 -}
 206.727 -
 206.728 -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
 206.729 -{
 206.730 -  vTable->Init = (Mf_Init_Func)MatchFinder_Init;
 206.731 -  vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
 206.732 -  vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
 206.733 -  vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
 206.734 -  if (!p->btMode)
 206.735 -  {
 206.736 -    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
 206.737 -    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
 206.738 -  }
 206.739 -  else if (p->numHashBytes == 2)
 206.740 -  {
 206.741 -    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
 206.742 -    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
 206.743 -  }
 206.744 -  else if (p->numHashBytes == 3)
 206.745 -  {
 206.746 -    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
 206.747 -    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
 206.748 -  }
 206.749 -  else
 206.750 -  {
 206.751 -    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
 206.752 -    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
 206.753 -  }
 206.754 -}
   207.1 --- a/src/win32/7zip/7z/C/LzFind.h	Sat Mar 03 10:54:39 2012 -0600
   207.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   207.3 @@ -1,107 +0,0 @@
   207.4 -/* LzFind.h -- Match finder for LZ algorithms
   207.5 -2008-10-04 : Igor Pavlov : Public domain */
   207.6 -
   207.7 -#ifndef __LZFIND_H
   207.8 -#define __LZFIND_H
   207.9 -
  207.10 -#include "Types.h"
  207.11 -
  207.12 -typedef UInt32 CLzRef;
  207.13 -
  207.14 -typedef struct _CMatchFinder
  207.15 -{
  207.16 -  Byte *buffer;
  207.17 -  UInt32 pos;
  207.18 -  UInt32 posLimit;
  207.19 -  UInt32 streamPos;
  207.20 -  UInt32 lenLimit;
  207.21 -
  207.22 -  UInt32 cyclicBufferPos;
  207.23 -  UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
  207.24 -
  207.25 -  UInt32 matchMaxLen;
  207.26 -  CLzRef *hash;
  207.27 -  CLzRef *son;
  207.28 -  UInt32 hashMask;
  207.29 -  UInt32 cutValue;
  207.30 -
  207.31 -  Byte *bufferBase;
  207.32 -  ISeqInStream *stream;
  207.33 -  int streamEndWasReached;
  207.34 -
  207.35 -  UInt32 blockSize;
  207.36 -  UInt32 keepSizeBefore;
  207.37 -  UInt32 keepSizeAfter;
  207.38 -
  207.39 -  UInt32 numHashBytes;
  207.40 -  int directInput;
  207.41 -  int btMode;
  207.42 -  /* int skipModeBits; */
  207.43 -  int bigHash;
  207.44 -  UInt32 historySize;
  207.45 -  UInt32 fixedHashSize;
  207.46 -  UInt32 hashSizeSum;
  207.47 -  UInt32 numSons;
  207.48 -  SRes result;
  207.49 -  UInt32 crc[256];
  207.50 -} CMatchFinder;
  207.51 -
  207.52 -#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
  207.53 -#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
  207.54 -
  207.55 -#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
  207.56 -
  207.57 -int MatchFinder_NeedMove(CMatchFinder *p);
  207.58 -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
  207.59 -void MatchFinder_MoveBlock(CMatchFinder *p);
  207.60 -void MatchFinder_ReadIfRequired(CMatchFinder *p);
  207.61 -
  207.62 -void MatchFinder_Construct(CMatchFinder *p);
  207.63 -
  207.64 -/* Conditions:
  207.65 -     historySize <= 3 GB
  207.66 -     keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
  207.67 -*/
  207.68 -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
  207.69 -    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
  207.70 -    ISzAlloc *alloc);
  207.71 -void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
  207.72 -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
  207.73 -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
  207.74 -
  207.75 -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
  207.76 -    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
  207.77 -    UInt32 *distances, UInt32 maxLen);
  207.78 -
  207.79 -/*
  207.80 -Conditions:
  207.81 -  Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
  207.82 -  Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
  207.83 -*/
  207.84 -
  207.85 -typedef void (*Mf_Init_Func)(void *object);
  207.86 -typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
  207.87 -typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
  207.88 -typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
  207.89 -typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
  207.90 -typedef void (*Mf_Skip_Func)(void *object, UInt32);
  207.91 -
  207.92 -typedef struct _IMatchFinder
  207.93 -{
  207.94 -  Mf_Init_Func Init;
  207.95 -  Mf_GetIndexByte_Func GetIndexByte;
  207.96 -  Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
  207.97 -  Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
  207.98 -  Mf_GetMatches_Func GetMatches;
  207.99 -  Mf_Skip_Func Skip;
 207.100 -} IMatchFinder;
 207.101 -
 207.102 -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
 207.103 -
 207.104 -void MatchFinder_Init(CMatchFinder *p);
 207.105 -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
 207.106 -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
 207.107 -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
 207.108 -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
 207.109 -
 207.110 -#endif
   208.1 --- a/src/win32/7zip/7z/C/LzFindMt.c	Sat Mar 03 10:54:39 2012 -0600
   208.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   208.3 @@ -1,793 +0,0 @@
   208.4 -/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
   208.5 -2008-10-04 : Igor Pavlov : Public domain */
   208.6 -
   208.7 -#include "LzHash.h"
   208.8 -
   208.9 -#include "LzFindMt.h"
  208.10 -
  208.11 -void MtSync_Construct(CMtSync *p)
  208.12 -{
  208.13 -  p->wasCreated = False;
  208.14 -  p->csWasInitialized = False;
  208.15 -  p->csWasEntered = False;
  208.16 -  Thread_Construct(&p->thread);
  208.17 -  Event_Construct(&p->canStart);
  208.18 -  Event_Construct(&p->wasStarted);
  208.19 -  Event_Construct(&p->wasStopped);
  208.20 -  Semaphore_Construct(&p->freeSemaphore);
  208.21 -  Semaphore_Construct(&p->filledSemaphore);
  208.22 -}
  208.23 -
  208.24 -void MtSync_GetNextBlock(CMtSync *p)
  208.25 -{
  208.26 -  if (p->needStart)
  208.27 -  {
  208.28 -    p->numProcessedBlocks = 1;
  208.29 -    p->needStart = False;
  208.30 -    p->stopWriting = False;
  208.31 -    p->exit = False;
  208.32 -    Event_Reset(&p->wasStarted);
  208.33 -    Event_Reset(&p->wasStopped);
  208.34 -
  208.35 -    Event_Set(&p->canStart);
  208.36 -    Event_Wait(&p->wasStarted);
  208.37 -  }
  208.38 -  else
  208.39 -  {
  208.40 -    CriticalSection_Leave(&p->cs);
  208.41 -    p->csWasEntered = False;
  208.42 -    p->numProcessedBlocks++;
  208.43 -    Semaphore_Release1(&p->freeSemaphore);
  208.44 -  }
  208.45 -  Semaphore_Wait(&p->filledSemaphore);
  208.46 -  CriticalSection_Enter(&p->cs);
  208.47 -  p->csWasEntered = True;
  208.48 -}
  208.49 -
  208.50 -/* MtSync_StopWriting must be called if Writing was started */
  208.51 -
  208.52 -void MtSync_StopWriting(CMtSync *p)
  208.53 -{
  208.54 -  UInt32 myNumBlocks = p->numProcessedBlocks;
  208.55 -  if (!Thread_WasCreated(&p->thread) || p->needStart)
  208.56 -    return;
  208.57 -  p->stopWriting = True;
  208.58 -  if (p->csWasEntered)
  208.59 -  {
  208.60 -    CriticalSection_Leave(&p->cs);
  208.61 -    p->csWasEntered = False;
  208.62 -  }
  208.63 -  Semaphore_Release1(&p->freeSemaphore);
  208.64 - 
  208.65 -  Event_Wait(&p->wasStopped);
  208.66 -
  208.67 -  while (myNumBlocks++ != p->numProcessedBlocks)
  208.68 -  {
  208.69 -    Semaphore_Wait(&p->filledSemaphore);
  208.70 -    Semaphore_Release1(&p->freeSemaphore);
  208.71 -  }
  208.72 -  p->needStart = True;
  208.73 -}
  208.74 -
  208.75 -void MtSync_Destruct(CMtSync *p)
  208.76 -{
  208.77 -  if (Thread_WasCreated(&p->thread))
  208.78 -  {
  208.79 -    MtSync_StopWriting(p);
  208.80 -    p->exit = True;
  208.81 -    if (p->needStart)
  208.82 -      Event_Set(&p->canStart);
  208.83 -    Thread_Wait(&p->thread);
  208.84 -    Thread_Close(&p->thread);
  208.85 -  }
  208.86 -  if (p->csWasInitialized)
  208.87 -  {
  208.88 -    CriticalSection_Delete(&p->cs);
  208.89 -    p->csWasInitialized = False;
  208.90 -  }
  208.91 -
  208.92 -  Event_Close(&p->canStart);
  208.93 -  Event_Close(&p->wasStarted);
  208.94 -  Event_Close(&p->wasStopped);
  208.95 -  Semaphore_Close(&p->freeSemaphore);
  208.96 -  Semaphore_Close(&p->filledSemaphore);
  208.97 -
  208.98 -  p->wasCreated = False;
  208.99 -}
 208.100 -
 208.101 -#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
 208.102 -
 208.103 -static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
 208.104 -{
 208.105 -  if (p->wasCreated)
 208.106 -    return SZ_OK;
 208.107 -
 208.108 -  RINOK_THREAD(CriticalSection_Init(&p->cs));
 208.109 -  p->csWasInitialized = True;
 208.110 -
 208.111 -  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart));
 208.112 -  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted));
 208.113 -  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped));
 208.114 -  
 208.115 -  RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));
 208.116 -  RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));
 208.117 -
 208.118 -  p->needStart = True;
 208.119 -  
 208.120 -  RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj));
 208.121 -  p->wasCreated = True;
 208.122 -  return SZ_OK;
 208.123 -}
 208.124 -
 208.125 -static SRes MtSync_Create(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
 208.126 -{
 208.127 -  SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
 208.128 -  if (res != SZ_OK)
 208.129 -    MtSync_Destruct(p);
 208.130 -  return res;
 208.131 -}
 208.132 -
 208.133 -void MtSync_Init(CMtSync *p) { p->needStart = True; }
 208.134 -
 208.135 -#define kMtMaxValForNormalize 0xFFFFFFFF
 208.136 -
 208.137 -#define DEF_GetHeads2(name, v, action) \
 208.138 -static void GetHeads ## name(const Byte *p, UInt32 pos, \
 208.139 -UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) \
 208.140 -{ action; for (; numHeads != 0; numHeads--) { \
 208.141 -const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++;  } }
 208.142 -
 208.143 -#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;)
 208.144 -
 208.145 -DEF_GetHeads2(2,  (p[0] | ((UInt32)p[1] << 8)), hashMask = hashMask; crc = crc; )
 208.146 -DEF_GetHeads(3,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)
 208.147 -DEF_GetHeads(4,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5)) & hashMask)
 208.148 -DEF_GetHeads(4b, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ ((UInt32)p[3] << 16)) & hashMask)
 208.149 -DEF_GetHeads(5,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5) ^ (crc[p[4]] << 3)) & hashMask)
 208.150 -
 208.151 -void HashThreadFunc(CMatchFinderMt *mt)
 208.152 -{
 208.153 -  CMtSync *p = &mt->hashSync;
 208.154 -  for (;;)
 208.155 -  {
 208.156 -    UInt32 numProcessedBlocks = 0;
 208.157 -    Event_Wait(&p->canStart);
 208.158 -    Event_Set(&p->wasStarted);
 208.159 -    for (;;)
 208.160 -    {
 208.161 -      if (p->exit)
 208.162 -        return;
 208.163 -      if (p->stopWriting)
 208.164 -      {
 208.165 -        p->numProcessedBlocks = numProcessedBlocks;
 208.166 -        Event_Set(&p->wasStopped);
 208.167 -        break;
 208.168 -      }
 208.169 -
 208.170 -      {
 208.171 -        CMatchFinder *mf = mt->MatchFinder;
 208.172 -        if (MatchFinder_NeedMove(mf))
 208.173 -        {
 208.174 -          CriticalSection_Enter(&mt->btSync.cs);
 208.175 -          CriticalSection_Enter(&mt->hashSync.cs);
 208.176 -          {
 208.177 -            const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf);
 208.178 -            const Byte *afterPtr;
 208.179 -            MatchFinder_MoveBlock(mf);
 208.180 -            afterPtr = MatchFinder_GetPointerToCurrentPos(mf);
 208.181 -            mt->pointerToCurPos -= beforePtr - afterPtr;
 208.182 -            mt->buffer -= beforePtr - afterPtr;
 208.183 -          }
 208.184 -          CriticalSection_Leave(&mt->btSync.cs);
 208.185 -          CriticalSection_Leave(&mt->hashSync.cs);
 208.186 -          continue;
 208.187 -        }
 208.188 -
 208.189 -        Semaphore_Wait(&p->freeSemaphore);
 208.190 -
 208.191 -        MatchFinder_ReadIfRequired(mf);
 208.192 -        if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize))
 208.193 -        {
 208.194 -          UInt32 subValue = (mf->pos - mf->historySize - 1);
 208.195 -          MatchFinder_ReduceOffsets(mf, subValue);
 208.196 -          MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, mf->hashMask + 1);
 208.197 -        }
 208.198 -        {
 208.199 -          UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize;
 208.200 -          UInt32 num = mf->streamPos - mf->pos;
 208.201 -          heads[0] = 2;
 208.202 -          heads[1] = num;
 208.203 -          if (num >= mf->numHashBytes)
 208.204 -          {
 208.205 -            num = num - mf->numHashBytes + 1;
 208.206 -            if (num > kMtHashBlockSize - 2)
 208.207 -              num = kMtHashBlockSize - 2;
 208.208 -            mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc);
 208.209 -            heads[0] += num;
 208.210 -          }
 208.211 -          mf->pos += num;
 208.212 -          mf->buffer += num;
 208.213 -        }
 208.214 -      }
 208.215 -
 208.216 -      Semaphore_Release1(&p->filledSemaphore);
 208.217 -    }
 208.218 -  }
 208.219 -}
 208.220 -
 208.221 -void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
 208.222 -{
 208.223 -  MtSync_GetNextBlock(&p->hashSync);
 208.224 -  p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize;
 208.225 -  p->hashBufPosLimit += p->hashBuf[p->hashBufPos++];
 208.226 -  p->hashNumAvail = p->hashBuf[p->hashBufPos++];
 208.227 -}
 208.228 -
 208.229 -#define kEmptyHashValue 0
 208.230 -
 208.231 -/* #define MFMT_GM_INLINE */
 208.232 -
 208.233 -#ifdef MFMT_GM_INLINE
 208.234 -
 208.235 -#define NO_INLINE MY_FAST_CALL
 208.236 -
 208.237 -Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
 208.238 -    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
 208.239 -    UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)
 208.240 -{
 208.241 -  do
 208.242 -  {
 208.243 -  UInt32 *distances = _distances + 1;
 208.244 -  UInt32 curMatch = pos - *hash++;
 208.245 -
 208.246 -  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
 208.247 -  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
 208.248 -  UInt32 len0 = 0, len1 = 0;
 208.249 -  UInt32 cutValue = _cutValue;
 208.250 -  UInt32 maxLen = _maxLen;
 208.251 -  for (;;)
 208.252 -  {
 208.253 -    UInt32 delta = pos - curMatch;
 208.254 -    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
 208.255 -    {
 208.256 -      *ptr0 = *ptr1 = kEmptyHashValue;
 208.257 -      break;
 208.258 -    }
 208.259 -    {
 208.260 -      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
 208.261 -      const Byte *pb = cur - delta;
 208.262 -      UInt32 len = (len0 < len1 ? len0 : len1);
 208.263 -      if (pb[len] == cur[len])
 208.264 -      {
 208.265 -        if (++len != lenLimit && pb[len] == cur[len])
 208.266 -          while (++len != lenLimit)
 208.267 -            if (pb[len] != cur[len])
 208.268 -              break;
 208.269 -        if (maxLen < len)
 208.270 -        {
 208.271 -          *distances++ = maxLen = len;
 208.272 -          *distances++ = delta - 1;
 208.273 -          if (len == lenLimit)
 208.274 -          {
 208.275 -            *ptr1 = pair[0];
 208.276 -            *ptr0 = pair[1];
 208.277 -            break;
 208.278 -          }
 208.279 -        }
 208.280 -      }
 208.281 -      if (pb[len] < cur[len])
 208.282 -      {
 208.283 -        *ptr1 = curMatch;
 208.284 -        ptr1 = pair + 1;
 208.285 -        curMatch = *ptr1;
 208.286 -        len1 = len;
 208.287 -      }
 208.288 -      else
 208.289 -      {
 208.290 -        *ptr0 = curMatch;
 208.291 -        ptr0 = pair;
 208.292 -        curMatch = *ptr0;
 208.293 -        len0 = len;
 208.294 -      }
 208.295 -    }
 208.296 -  }
 208.297 -  pos++;
 208.298 -  _cyclicBufferPos++;
 208.299 -  cur++;
 208.300 -  {
 208.301 -    UInt32 num = (UInt32)(distances - _distances);
 208.302 -    *_distances = num - 1;
 208.303 -    _distances += num;
 208.304 -    limit -= num;
 208.305 -  }
 208.306 -  }
 208.307 -  while (limit > 0 && --size != 0);
 208.308 -  *posRes = pos;
 208.309 -  return limit;
 208.310 -}
 208.311 -
 208.312 -#endif
 208.313 -
 208.314 -void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
 208.315 -{
 208.316 -  UInt32 numProcessed = 0;
 208.317 -  UInt32 curPos = 2;
 208.318 -  UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);
 208.319 -  distances[1] = p->hashNumAvail;
 208.320 -  while (curPos < limit)
 208.321 -  {
 208.322 -    if (p->hashBufPos == p->hashBufPosLimit)
 208.323 -    {
 208.324 -      MatchFinderMt_GetNextBlock_Hash(p);
 208.325 -      distances[1] = numProcessed + p->hashNumAvail;
 208.326 -      if (p->hashNumAvail >= p->numHashBytes)
 208.327 -        continue;
 208.328 -      for (; p->hashNumAvail != 0; p->hashNumAvail--)
 208.329 -        distances[curPos++] = 0;
 208.330 -      break;
 208.331 -    }
 208.332 -    {
 208.333 -      UInt32 size = p->hashBufPosLimit - p->hashBufPos;
 208.334 -      UInt32 lenLimit = p->matchMaxLen;
 208.335 -      UInt32 pos = p->pos;
 208.336 -      UInt32 cyclicBufferPos = p->cyclicBufferPos;
 208.337 -      if (lenLimit >= p->hashNumAvail)
 208.338 -        lenLimit = p->hashNumAvail;
 208.339 -      {
 208.340 -        UInt32 size2 = p->hashNumAvail - lenLimit + 1;
 208.341 -        if (size2 < size)
 208.342 -          size = size2;
 208.343 -        size2 = p->cyclicBufferSize - cyclicBufferPos;
 208.344 -        if (size2 < size)
 208.345 -          size = size2;
 208.346 -      }
 208.347 -      #ifndef MFMT_GM_INLINE
 208.348 -      while (curPos < limit && size-- != 0)
 208.349 -      {
 208.350 -        UInt32 *startDistances = distances + curPos;
 208.351 -        UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++],
 208.352 -          pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
 208.353 -          startDistances + 1, p->numHashBytes - 1) - startDistances);
 208.354 -        *startDistances = num - 1;
 208.355 -        curPos += num;
 208.356 -        cyclicBufferPos++;
 208.357 -        pos++;
 208.358 -        p->buffer++;
 208.359 -      }
 208.360 -      #else
 208.361 -      {
 208.362 -        UInt32 posRes;
 208.363 -        curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
 208.364 -          distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos) , size, &posRes);
 208.365 -        p->hashBufPos += posRes - pos;
 208.366 -        cyclicBufferPos += posRes - pos;
 208.367 -        p->buffer += posRes - pos;
 208.368 -        pos = posRes;
 208.369 -      }
 208.370 -      #endif
 208.371 -
 208.372 -      numProcessed += pos - p->pos;
 208.373 -      p->hashNumAvail -= pos - p->pos;
 208.374 -      p->pos = pos;
 208.375 -      if (cyclicBufferPos == p->cyclicBufferSize)
 208.376 -        cyclicBufferPos = 0;
 208.377 -      p->cyclicBufferPos = cyclicBufferPos;
 208.378 -    }
 208.379 -  }
 208.380 -  distances[0] = curPos;
 208.381 -}
 208.382 -
 208.383 -void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)
 208.384 -{
 208.385 -  CMtSync *sync = &p->hashSync;
 208.386 -  if (!sync->needStart)
 208.387 -  {
 208.388 -    CriticalSection_Enter(&sync->cs);
 208.389 -    sync->csWasEntered = True;
 208.390 -  }
 208.391 -  
 208.392 -  BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);
 208.393 -
 208.394 -  if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)
 208.395 -  {
 208.396 -    UInt32 subValue = p->pos - p->cyclicBufferSize;
 208.397 -    MatchFinder_Normalize3(subValue, p->son, p->cyclicBufferSize * 2);
 208.398 -    p->pos -= subValue;
 208.399 -  }
 208.400 -
 208.401 -  if (!sync->needStart)
 208.402 -  {
 208.403 -    CriticalSection_Leave(&sync->cs);
 208.404 -    sync->csWasEntered = False;
 208.405 -  }
 208.406 -}
 208.407 -
 208.408 -void BtThreadFunc(CMatchFinderMt *mt)
 208.409 -{
 208.410 -  CMtSync *p = &mt->btSync;
 208.411 -  for (;;)
 208.412 -  {
 208.413 -    UInt32 blockIndex = 0;
 208.414 -    Event_Wait(&p->canStart);
 208.415 -    Event_Set(&p->wasStarted);
 208.416 -    for (;;)
 208.417 -    {
 208.418 -      if (p->exit)
 208.419 -        return;
 208.420 -      if (p->stopWriting)
 208.421 -      {
 208.422 -        p->numProcessedBlocks = blockIndex;
 208.423 -        MtSync_StopWriting(&mt->hashSync);
 208.424 -        Event_Set(&p->wasStopped);
 208.425 -        break;
 208.426 -      }
 208.427 -      Semaphore_Wait(&p->freeSemaphore);
 208.428 -      BtFillBlock(mt, blockIndex++);
 208.429 -      Semaphore_Release1(&p->filledSemaphore);
 208.430 -    }
 208.431 -  }
 208.432 -}
 208.433 -
 208.434 -void MatchFinderMt_Construct(CMatchFinderMt *p)
 208.435 -{
 208.436 -  p->hashBuf = 0;
 208.437 -  MtSync_Construct(&p->hashSync);
 208.438 -  MtSync_Construct(&p->btSync);
 208.439 -}
 208.440 -
 208.441 -void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAlloc *alloc)
 208.442 -{
 208.443 -  alloc->Free(alloc, p->hashBuf);
 208.444 -  p->hashBuf = 0;
 208.445 -}
 208.446 -
 208.447 -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
 208.448 -{
 208.449 -  MtSync_Destruct(&p->hashSync);
 208.450 -  MtSync_Destruct(&p->btSync);
 208.451 -  MatchFinderMt_FreeMem(p, alloc);
 208.452 -}
 208.453 -
 208.454 -#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
 208.455 -#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
 208.456 -
 208.457 -static unsigned MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p);  return 0; }
 208.458 -static unsigned MY_STD_CALL BtThreadFunc2(void *p)
 208.459 -{
 208.460 -  Byte allocaDummy[0x180];
 208.461 -  int i = 0;
 208.462 -  for (i = 0; i < 16; i++)
 208.463 -    allocaDummy[i] = (Byte)i;
 208.464 -  BtThreadFunc((CMatchFinderMt *)p);
 208.465 -  return 0;
 208.466 -}
 208.467 -
 208.468 -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
 208.469 -    UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
 208.470 -{
 208.471 -  CMatchFinder *mf = p->MatchFinder;
 208.472 -  p->historySize = historySize;
 208.473 -  if (kMtBtBlockSize <= matchMaxLen * 4)
 208.474 -    return SZ_ERROR_PARAM;
 208.475 -  if (p->hashBuf == 0)
 208.476 -  {
 208.477 -    p->hashBuf = (UInt32 *)alloc->Alloc(alloc, (kHashBufferSize + kBtBufferSize) * sizeof(UInt32));
 208.478 -    if (p->hashBuf == 0)
 208.479 -      return SZ_ERROR_MEM;
 208.480 -    p->btBuf = p->hashBuf + kHashBufferSize;
 208.481 -  }
 208.482 -  keepAddBufferBefore += (kHashBufferSize + kBtBufferSize);
 208.483 -  keepAddBufferAfter += kMtHashBlockSize;
 208.484 -  if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc))
 208.485 -    return SZ_ERROR_MEM;
 208.486 -
 208.487 -  RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks));
 208.488 -  RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks));
 208.489 -  return SZ_OK;
 208.490 -}
 208.491 -
 208.492 -/* Call it after ReleaseStream / SetStream */
 208.493 -void MatchFinderMt_Init(CMatchFinderMt *p)
 208.494 -{
 208.495 -  CMatchFinder *mf = p->MatchFinder;
 208.496 -  p->btBufPos = p->btBufPosLimit = 0;
 208.497 -  p->hashBufPos = p->hashBufPosLimit = 0;
 208.498 -  MatchFinder_Init(mf);
 208.499 -  p->pointerToCurPos = MatchFinder_GetPointerToCurrentPos(mf);
 208.500 -  p->btNumAvailBytes = 0;
 208.501 -  p->lzPos = p->historySize + 1;
 208.502 -
 208.503 -  p->hash = mf->hash;
 208.504 -  p->fixedHashSize = mf->fixedHashSize;
 208.505 -  p->crc = mf->crc;
 208.506 -
 208.507 -  p->son = mf->son;
 208.508 -  p->matchMaxLen = mf->matchMaxLen;
 208.509 -  p->numHashBytes = mf->numHashBytes;
 208.510 -  p->pos = mf->pos;
 208.511 -  p->buffer = mf->buffer;
 208.512 -  p->cyclicBufferPos = mf->cyclicBufferPos;
 208.513 -  p->cyclicBufferSize = mf->cyclicBufferSize;
 208.514 -  p->cutValue = mf->cutValue;
 208.515 -}
 208.516 -
 208.517 -/* ReleaseStream is required to finish multithreading */
 208.518 -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p)
 208.519 -{
 208.520 -  MtSync_StopWriting(&p->btSync);
 208.521 -  /* p->MatchFinder->ReleaseStream(); */
 208.522 -}
 208.523 -
 208.524 -void MatchFinderMt_Normalize(CMatchFinderMt *p)
 208.525 -{
 208.526 -  MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize);
 208.527 -  p->lzPos = p->historySize + 1;
 208.528 -}
 208.529 -
 208.530 -void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p)
 208.531 -{
 208.532 -  UInt32 blockIndex;
 208.533 -  MtSync_GetNextBlock(&p->btSync);
 208.534 -  blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask);
 208.535 -  p->btBufPosLimit = p->btBufPos = blockIndex * kMtBtBlockSize;
 208.536 -  p->btBufPosLimit += p->btBuf[p->btBufPos++];
 208.537 -  p->btNumAvailBytes = p->btBuf[p->btBufPos++];
 208.538 -  if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize)
 208.539 -    MatchFinderMt_Normalize(p);
 208.540 -}
 208.541 -
 208.542 -const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p)
 208.543 -{
 208.544 -  return p->pointerToCurPos;
 208.545 -}
 208.546 -
 208.547 -#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p);
 208.548 -
 208.549 -UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p)
 208.550 -{
 208.551 -  GET_NEXT_BLOCK_IF_REQUIRED;
 208.552 -  return p->btNumAvailBytes;
 208.553 -}
 208.554 -
 208.555 -Byte MatchFinderMt_GetIndexByte(CMatchFinderMt *p, Int32 index)
 208.556 -{
 208.557 -  return p->pointerToCurPos[index];
 208.558 -}
 208.559 -
 208.560 -UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
 208.561 -{
 208.562 -  UInt32 hash2Value, curMatch2;
 208.563 -  UInt32 *hash = p->hash;
 208.564 -  const Byte *cur = p->pointerToCurPos;
 208.565 -  UInt32 lzPos = p->lzPos;
 208.566 -  MT_HASH2_CALC
 208.567 -      
 208.568 -  curMatch2 = hash[hash2Value];
 208.569 -  hash[hash2Value] = lzPos;
 208.570 -
 208.571 -  if (curMatch2 >= matchMinPos)
 208.572 -    if (cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
 208.573 -    {
 208.574 -      *distances++ = 2;
 208.575 -      *distances++ = lzPos - curMatch2 - 1;
 208.576 -    }
 208.577 -  return distances;
 208.578 -}
 208.579 -
 208.580 -UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
 208.581 -{
 208.582 -  UInt32 hash2Value, hash3Value, curMatch2, curMatch3;
 208.583 -  UInt32 *hash = p->hash;
 208.584 -  const Byte *cur = p->pointerToCurPos;
 208.585 -  UInt32 lzPos = p->lzPos;
 208.586 -  MT_HASH3_CALC
 208.587 -
 208.588 -  curMatch2 = hash[                hash2Value];
 208.589 -  curMatch3 = hash[kFix3HashSize + hash3Value];
 208.590 -  
 208.591 -  hash[                hash2Value] =
 208.592 -  hash[kFix3HashSize + hash3Value] =
 208.593 -    lzPos;
 208.594 -
 208.595 -  if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
 208.596 -  {
 208.597 -    distances[1] = lzPos - curMatch2 - 1;
 208.598 -    if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
 208.599 -    {
 208.600 -      distances[0] = 3;
 208.601 -      return distances + 2;
 208.602 -    }
 208.603 -    distances[0] = 2;
 208.604 -    distances += 2;
 208.605 -  }
 208.606 -  if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
 208.607 -  {
 208.608 -    *distances++ = 3;
 208.609 -    *distances++ = lzPos - curMatch3 - 1;
 208.610 -  }
 208.611 -  return distances;
 208.612 -}
 208.613 -
 208.614 -/*
 208.615 -UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
 208.616 -{
 208.617 -  UInt32 hash2Value, hash3Value, hash4Value, curMatch2, curMatch3, curMatch4;
 208.618 -  UInt32 *hash = p->hash;
 208.619 -  const Byte *cur = p->pointerToCurPos;
 208.620 -  UInt32 lzPos = p->lzPos;
 208.621 -  MT_HASH4_CALC
 208.622 -      
 208.623 -  curMatch2 = hash[                hash2Value];
 208.624 -  curMatch3 = hash[kFix3HashSize + hash3Value];
 208.625 -  curMatch4 = hash[kFix4HashSize + hash4Value];
 208.626 -  
 208.627 -  hash[                hash2Value] =
 208.628 -  hash[kFix3HashSize + hash3Value] =
 208.629 -  hash[kFix4HashSize + hash4Value] =
 208.630 -    lzPos;
 208.631 -
 208.632 -  if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
 208.633 -  {
 208.634 -    distances[1] = lzPos - curMatch2 - 1;
 208.635 -    if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
 208.636 -    {
 208.637 -      distances[0] =  (cur[(ptrdiff_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;
 208.638 -      return distances + 2;
 208.639 -    }
 208.640 -    distances[0] = 2;
 208.641 -    distances += 2;
 208.642 -  }
 208.643 -  if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
 208.644 -  {
 208.645 -    distances[1] = lzPos - curMatch3 - 1;
 208.646 -    if (cur[(ptrdiff_t)curMatch3 - lzPos + 3] == cur[3])
 208.647 -    {
 208.648 -      distances[0] = 4;
 208.649 -      return distances + 2;
 208.650 -    }
 208.651 -    distances[0] = 3;
 208.652 -    distances += 2;
 208.653 -  }
 208.654 -
 208.655 -  if (curMatch4 >= matchMinPos)
 208.656 -    if (
 208.657 -      cur[(ptrdiff_t)curMatch4 - lzPos] == cur[0] &&
 208.658 -      cur[(ptrdiff_t)curMatch4 - lzPos + 3] == cur[3]
 208.659 -      )
 208.660 -    {
 208.661 -      *distances++ = 4;
 208.662 -      *distances++ = lzPos - curMatch4 - 1;
 208.663 -    }
 208.664 -  return distances;
 208.665 -}
 208.666 -*/
 208.667 -
 208.668 -#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++;
 208.669 -
 208.670 -UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances)
 208.671 -{
 208.672 -  const UInt32 *btBuf = p->btBuf + p->btBufPos;
 208.673 -  UInt32 len = *btBuf++;
 208.674 -  p->btBufPos += 1 + len;
 208.675 -  p->btNumAvailBytes--;
 208.676 -  {
 208.677 -    UInt32 i;
 208.678 -    for (i = 0; i < len; i += 2)
 208.679 -    {
 208.680 -      *distances++ = *btBuf++;
 208.681 -      *distances++ = *btBuf++;
 208.682 -    }
 208.683 -  }
 208.684 -  INCREASE_LZ_POS
 208.685 -  return len;
 208.686 -}
 208.687 -
 208.688 -UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
 208.689 -{
 208.690 -  const UInt32 *btBuf = p->btBuf + p->btBufPos;
 208.691 -  UInt32 len = *btBuf++;
 208.692 -  p->btBufPos += 1 + len;
 208.693 -
 208.694 -  if (len == 0)
 208.695 -  {
 208.696 -    if (p->btNumAvailBytes-- >= 4)
 208.697 -      len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, distances) - (distances));
 208.698 -  }
 208.699 -  else
 208.700 -  {
 208.701 -    /* Condition: there are matches in btBuf with length < p->numHashBytes */
 208.702 -    UInt32 *distances2;
 208.703 -    p->btNumAvailBytes--;
 208.704 -    distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);
 208.705 -    do
 208.706 -    {
 208.707 -      *distances2++ = *btBuf++;
 208.708 -      *distances2++ = *btBuf++;
 208.709 -    }
 208.710 -    while ((len -= 2) != 0);
 208.711 -    len  = (UInt32)(distances2 - (distances));
 208.712 -  }
 208.713 -  INCREASE_LZ_POS
 208.714 -  return len;
 208.715 -}
 208.716 -
 208.717 -#define SKIP_HEADER2  do { GET_NEXT_BLOCK_IF_REQUIRED
 208.718 -#define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
 208.719 -#define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);
 208.720 -
 208.721 -void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
 208.722 -{
 208.723 -  SKIP_HEADER2 { p->btNumAvailBytes--;
 208.724 -  SKIP_FOOTER
 208.725 -}
 208.726 -
 208.727 -void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)
 208.728 -{
 208.729 -  SKIP_HEADER(2)
 208.730 -      UInt32 hash2Value;
 208.731 -      MT_HASH2_CALC
 208.732 -      hash[hash2Value] = p->lzPos;
 208.733 -  SKIP_FOOTER
 208.734 -}
 208.735 -
 208.736 -void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)
 208.737 -{
 208.738 -  SKIP_HEADER(3)
 208.739 -      UInt32 hash2Value, hash3Value;
 208.740 -      MT_HASH3_CALC
 208.741 -      hash[kFix3HashSize + hash3Value] =
 208.742 -      hash[                hash2Value] =
 208.743 -        p->lzPos;
 208.744 -  SKIP_FOOTER
 208.745 -}
 208.746 -
 208.747 -/*
 208.748 -void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)
 208.749 -{
 208.750 -  SKIP_HEADER(4)
 208.751 -      UInt32 hash2Value, hash3Value, hash4Value;
 208.752 -      MT_HASH4_CALC
 208.753 -      hash[kFix4HashSize + hash4Value] =
 208.754 -      hash[kFix3HashSize + hash3Value] =
 208.755 -      hash[                hash2Value] =
 208.756 -        p->lzPos;
 208.757 -  SKIP_FOOTER
 208.758 -}
 208.759 -*/
 208.760 -
 208.761 -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable)
 208.762 -{
 208.763 -  vTable->Init = (Mf_Init_Func)MatchFinderMt_Init;
 208.764 -  vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinderMt_GetIndexByte;
 208.765 -  vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes;
 208.766 -  vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos;
 208.767 -  vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches;
 208.768 -  switch(p->MatchFinder->numHashBytes)
 208.769 -  {
 208.770 -    case 2:
 208.771 -      p->GetHeadsFunc = GetHeads2;
 208.772 -      p->MixMatchesFunc = (Mf_Mix_Matches)0;
 208.773 -      vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
 208.774 -      vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
 208.775 -      break;
 208.776 -    case 3:
 208.777 -      p->GetHeadsFunc = GetHeads3;
 208.778 -      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2;
 208.779 -      vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip;
 208.780 -      break;
 208.781 -    default:
 208.782 -    /* case 4: */
 208.783 -      p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4;
 208.784 -      /* p->GetHeadsFunc = GetHeads4; */
 208.785 -      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3;
 208.786 -      vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip;
 208.787 -      break;
 208.788 -    /*
 208.789 -    default:
 208.790 -      p->GetHeadsFunc = GetHeads5;
 208.791 -      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4;
 208.792 -      vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip;
 208.793 -      break;
 208.794 -    */
 208.795 -  }
 208.796 -}
   209.1 --- a/src/win32/7zip/7z/C/LzFindMt.h	Sat Mar 03 10:54:39 2012 -0600
   209.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   209.3 @@ -1,97 +0,0 @@
   209.4 -/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
   209.5 -2008-10-04 : Igor Pavlov : Public domain */
   209.6 -
   209.7 -#ifndef __LZFINDMT_H
   209.8 -#define __LZFINDMT_H
   209.9 -
  209.10 -#include "Threads.h"
  209.11 -#include "LzFind.h"
  209.12 -
  209.13 -#define kMtHashBlockSize (1 << 13)
  209.14 -#define kMtHashNumBlocks (1 << 3)
  209.15 -#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
  209.16 -
  209.17 -#define kMtBtBlockSize (1 << 14)
  209.18 -#define kMtBtNumBlocks (1 << 6)
  209.19 -#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
  209.20 -
  209.21 -typedef struct _CMtSync
  209.22 -{
  209.23 -  Bool wasCreated;
  209.24 -  Bool needStart;
  209.25 -  Bool exit;
  209.26 -  Bool stopWriting;
  209.27 -
  209.28 -  CThread thread;
  209.29 -  CAutoResetEvent canStart;
  209.30 -  CAutoResetEvent wasStarted;
  209.31 -  CAutoResetEvent wasStopped;
  209.32 -  CSemaphore freeSemaphore;
  209.33 -  CSemaphore filledSemaphore;
  209.34 -  Bool csWasInitialized;
  209.35 -  Bool csWasEntered;
  209.36 -  CCriticalSection cs;
  209.37 -  UInt32 numProcessedBlocks;
  209.38 -} CMtSync;
  209.39 -
  209.40 -typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
  209.41 -
  209.42 -/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
  209.43 -#define kMtCacheLineDummy 128
  209.44 -
  209.45 -typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
  209.46 -  UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
  209.47 -
  209.48 -typedef struct _CMatchFinderMt
  209.49 -{
  209.50 -  /* LZ */
  209.51 -  const Byte *pointerToCurPos;
  209.52 -  UInt32 *btBuf;
  209.53 -  UInt32 btBufPos;
  209.54 -  UInt32 btBufPosLimit;
  209.55 -  UInt32 lzPos;
  209.56 -  UInt32 btNumAvailBytes;
  209.57 -
  209.58 -  UInt32 *hash;
  209.59 -  UInt32 fixedHashSize;
  209.60 -  UInt32 historySize;
  209.61 -  const UInt32 *crc;
  209.62 -
  209.63 -  Mf_Mix_Matches MixMatchesFunc;
  209.64 -  
  209.65 -  /* LZ + BT */
  209.66 -  CMtSync btSync;
  209.67 -  Byte btDummy[kMtCacheLineDummy];
  209.68 -
  209.69 -  /* BT */
  209.70 -  UInt32 *hashBuf;
  209.71 -  UInt32 hashBufPos;
  209.72 -  UInt32 hashBufPosLimit;
  209.73 -  UInt32 hashNumAvail;
  209.74 -
  209.75 -  CLzRef *son;
  209.76 -  UInt32 matchMaxLen;
  209.77 -  UInt32 numHashBytes;
  209.78 -  UInt32 pos;
  209.79 -  Byte *buffer;
  209.80 -  UInt32 cyclicBufferPos;
  209.81 -  UInt32 cyclicBufferSize; /* it must be historySize + 1 */
  209.82 -  UInt32 cutValue;
  209.83 -
  209.84 -  /* BT + Hash */
  209.85 -  CMtSync hashSync;
  209.86 -  /* Byte hashDummy[kMtCacheLineDummy]; */
  209.87 -  
  209.88 -  /* Hash */
  209.89 -  Mf_GetHeads GetHeadsFunc;
  209.90 -  CMatchFinder *MatchFinder;
  209.91 -} CMatchFinderMt;
  209.92 -
  209.93 -void MatchFinderMt_Construct(CMatchFinderMt *p);
  209.94 -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
  209.95 -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
  209.96 -    UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
  209.97 -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
  209.98 -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
  209.99 -
 209.100 -#endif
   210.1 --- a/src/win32/7zip/7z/C/LzHash.h	Sat Mar 03 10:54:39 2012 -0600
   210.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   210.3 @@ -1,54 +0,0 @@
   210.4 -/* LzHash.h -- HASH functions for LZ algorithms
   210.5 -2008-10-04 : Igor Pavlov : Public domain */
   210.6 -
   210.7 -#ifndef __LZHASH_H
   210.8 -#define __LZHASH_H
   210.9 -
  210.10 -#define kHash2Size (1 << 10)
  210.11 -#define kHash3Size (1 << 16)
  210.12 -#define kHash4Size (1 << 20)
  210.13 -
  210.14 -#define kFix3HashSize (kHash2Size)
  210.15 -#define kFix4HashSize (kHash2Size + kHash3Size)
  210.16 -#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
  210.17 -
  210.18 -#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
  210.19 -
  210.20 -#define HASH3_CALC { \
  210.21 -  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
  210.22 -  hash2Value = temp & (kHash2Size - 1); \
  210.23 -  hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
  210.24 -
  210.25 -#define HASH4_CALC { \
  210.26 -  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
  210.27 -  hash2Value = temp & (kHash2Size - 1); \
  210.28 -  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
  210.29 -  hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
  210.30 -
  210.31 -#define HASH5_CALC { \
  210.32 -  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
  210.33 -  hash2Value = temp & (kHash2Size - 1); \
  210.34 -  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
  210.35 -  hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
  210.36 -  hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
  210.37 -  hash4Value &= (kHash4Size - 1); }
  210.38 -
  210.39 -/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
  210.40 -#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
  210.41 -
  210.42 -
  210.43 -#define MT_HASH2_CALC \
  210.44 -  hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
  210.45 -
  210.46 -#define MT_HASH3_CALC { \
  210.47 -  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
  210.48 -  hash2Value = temp & (kHash2Size - 1); \
  210.49 -  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
  210.50 -
  210.51 -#define MT_HASH4_CALC { \
  210.52 -  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
  210.53 -  hash2Value = temp & (kHash2Size - 1); \
  210.54 -  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
  210.55 -  hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
  210.56 -
  210.57 -#endif
   211.1 --- a/src/win32/7zip/7z/C/LzmaDec.c	Sat Mar 03 10:54:39 2012 -0600
   211.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   211.3 @@ -1,1007 +0,0 @@
   211.4 -/* LzmaDec.c -- LZMA Decoder
   211.5 -2008-11-06 : Igor Pavlov : Public domain */
   211.6 -
   211.7 -#include "LzmaDec.h"
   211.8 -
   211.9 -#include <string.h>
  211.10 -
  211.11 -#define kNumTopBits 24
  211.12 -#define kTopValue ((UInt32)1 << kNumTopBits)
  211.13 -
  211.14 -#define kNumBitModelTotalBits 11
  211.15 -#define kBitModelTotal (1 << kNumBitModelTotalBits)
  211.16 -#define kNumMoveBits 5
  211.17 -
  211.18 -#define RC_INIT_SIZE 5
  211.19 -
  211.20 -#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
  211.21 -
  211.22 -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
  211.23 -#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
  211.24 -#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
  211.25 -#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
  211.26 -  { UPDATE_0(p); i = (i + i); A0; } else \
  211.27 -  { UPDATE_1(p); i = (i + i) + 1; A1; }
  211.28 -#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
  211.29 -
  211.30 -#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
  211.31 -#define TREE_DECODE(probs, limit, i) \
  211.32 -  { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
  211.33 -
  211.34 -/* #define _LZMA_SIZE_OPT */
  211.35 -
  211.36 -#ifdef _LZMA_SIZE_OPT
  211.37 -#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
  211.38 -#else
  211.39 -#define TREE_6_DECODE(probs, i) \
  211.40 -  { i = 1; \
  211.41 -  TREE_GET_BIT(probs, i); \
  211.42 -  TREE_GET_BIT(probs, i); \
  211.43 -  TREE_GET_BIT(probs, i); \
  211.44 -  TREE_GET_BIT(probs, i); \
  211.45 -  TREE_GET_BIT(probs, i); \
  211.46 -  TREE_GET_BIT(probs, i); \
  211.47 -  i -= 0x40; }
  211.48 -#endif
  211.49 -
  211.50 -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
  211.51 -
  211.52 -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
  211.53 -#define UPDATE_0_CHECK range = bound;
  211.54 -#define UPDATE_1_CHECK range -= bound; code -= bound;
  211.55 -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
  211.56 -  { UPDATE_0_CHECK; i = (i + i); A0; } else \
  211.57 -  { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
  211.58 -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
  211.59 -#define TREE_DECODE_CHECK(probs, limit, i) \
  211.60 -  { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
  211.61 -
  211.62 -
  211.63 -#define kNumPosBitsMax 4
  211.64 -#define kNumPosStatesMax (1 << kNumPosBitsMax)
  211.65 -
  211.66 -#define kLenNumLowBits 3
  211.67 -#define kLenNumLowSymbols (1 << kLenNumLowBits)
  211.68 -#define kLenNumMidBits 3
  211.69 -#define kLenNumMidSymbols (1 << kLenNumMidBits)
  211.70 -#define kLenNumHighBits 8
  211.71 -#define kLenNumHighSymbols (1 << kLenNumHighBits)
  211.72 -
  211.73 -#define LenChoice 0
  211.74 -#define LenChoice2 (LenChoice + 1)
  211.75 -#define LenLow (LenChoice2 + 1)
  211.76 -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
  211.77 -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
  211.78 -#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
  211.79 -
  211.80 -
  211.81 -#define kNumStates 12
  211.82 -#define kNumLitStates 7
  211.83 -
  211.84 -#define kStartPosModelIndex 4
  211.85 -#define kEndPosModelIndex 14
  211.86 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
  211.87 -
  211.88 -#define kNumPosSlotBits 6
  211.89 -#define kNumLenToPosStates 4
  211.90 -
  211.91 -#define kNumAlignBits 4
  211.92 -#define kAlignTableSize (1 << kNumAlignBits)
  211.93 -
  211.94 -#define kMatchMinLen 2
  211.95 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
  211.96 -
  211.97 -#define IsMatch 0
  211.98 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
  211.99 -#define IsRepG0 (IsRep + kNumStates)
 211.100 -#define IsRepG1 (IsRepG0 + kNumStates)
 211.101 -#define IsRepG2 (IsRepG1 + kNumStates)
 211.102 -#define IsRep0Long (IsRepG2 + kNumStates)
 211.103 -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
 211.104 -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
 211.105 -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
 211.106 -#define LenCoder (Align + kAlignTableSize)
 211.107 -#define RepLenCoder (LenCoder + kNumLenProbs)
 211.108 -#define Literal (RepLenCoder + kNumLenProbs)
 211.109 -
 211.110 -#define LZMA_BASE_SIZE 1846
 211.111 -#define LZMA_LIT_SIZE 768
 211.112 -
 211.113 -#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
 211.114 -
 211.115 -#if Literal != LZMA_BASE_SIZE
 211.116 -StopCompilingDueBUG
 211.117 -#endif
 211.118 -
 211.119 -static const Byte kLiteralNextStates[kNumStates * 2] =
 211.120 -{
 211.121 -  0, 0, 0, 0, 1, 2, 3,  4,  5,  6,  4,  5,
 211.122 -  7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10
 211.123 -};
 211.124 -
 211.125 -#define LZMA_DIC_MIN (1 << 12)
 211.126 -
 211.127 -/* First LZMA-symbol is always decoded.
 211.128 -And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
 211.129 -Out:
 211.130 -  Result:
 211.131 -    SZ_OK - OK
 211.132 -    SZ_ERROR_DATA - Error
 211.133 -  p->remainLen:
 211.134 -    < kMatchSpecLenStart : normal remain
 211.135 -    = kMatchSpecLenStart : finished
 211.136 -    = kMatchSpecLenStart + 1 : Flush marker
 211.137 -    = kMatchSpecLenStart + 2 : State Init Marker
 211.138 -*/
 211.139 -
 211.140 -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
 211.141 -{
 211.142 -  CLzmaProb *probs = p->probs;
 211.143 -
 211.144 -  unsigned state = p->state;
 211.145 -  UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
 211.146 -  unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
 211.147 -  unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
 211.148 -  unsigned lc = p->prop.lc;
 211.149 -
 211.150 -  Byte *dic = p->dic;
 211.151 -  SizeT dicBufSize = p->dicBufSize;
 211.152 -  SizeT dicPos = p->dicPos;
 211.153 -  
 211.154 -  UInt32 processedPos = p->processedPos;
 211.155 -  UInt32 checkDicSize = p->checkDicSize;
 211.156 -  unsigned len = 0;
 211.157 -
 211.158 -  const Byte *buf = p->buf;
 211.159 -  UInt32 range = p->range;
 211.160 -  UInt32 code = p->code;
 211.161 -
 211.162 -  do
 211.163 -  {
 211.164 -    CLzmaProb *prob;
 211.165 -    UInt32 bound;
 211.166 -    unsigned ttt;
 211.167 -    unsigned posState = processedPos & pbMask;
 211.168 -
 211.169 -    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
 211.170 -    IF_BIT_0(prob)
 211.171 -    {
 211.172 -      unsigned symbol;
 211.173 -      UPDATE_0(prob);
 211.174 -      prob = probs + Literal;
 211.175 -      if (checkDicSize != 0 || processedPos != 0)
 211.176 -        prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
 211.177 -        (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
 211.178 -
 211.179 -      if (state < kNumLitStates)
 211.180 -      {
 211.181 -        symbol = 1;
 211.182 -        do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
 211.183 -      }
 211.184 -      else
 211.185 -      {
 211.186 -        unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
 211.187 -        unsigned offs = 0x100;
 211.188 -        symbol = 1;
 211.189 -        do
 211.190 -        {
 211.191 -          unsigned bit;
 211.192 -          CLzmaProb *probLit;
 211.193 -          matchByte <<= 1;
 211.194 -          bit = (matchByte & offs);
 211.195 -          probLit = prob + offs + bit + symbol;
 211.196 -          GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
 211.197 -        }
 211.198 -        while (symbol < 0x100);
 211.199 -      }
 211.200 -      dic[dicPos++] = (Byte)(symbol & 0xFF);
 211.201 -      processedPos++;
 211.202 -
 211.203 -      state = kLiteralNextStates[state];
 211.204 -      /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */
 211.205 -      continue;
 211.206 -    }
 211.207 -    else
 211.208 -    {
 211.209 -      UPDATE_1(prob);
 211.210 -      prob = probs + IsRep + state;
 211.211 -      IF_BIT_0(prob)
 211.212 -      {
 211.213 -        UPDATE_0(prob);
 211.214 -        state += kNumStates;
 211.215 -        prob = probs + LenCoder;
 211.216 -      }
 211.217 -      else
 211.218 -      {
 211.219 -        UPDATE_1(prob);
 211.220 -        if (checkDicSize == 0 && processedPos == 0)
 211.221 -          return SZ_ERROR_DATA;
 211.222 -        prob = probs + IsRepG0 + state;
 211.223 -        IF_BIT_0(prob)
 211.224 -        {
 211.225 -          UPDATE_0(prob);
 211.226 -          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
 211.227 -          IF_BIT_0(prob)
 211.228 -          {
 211.229 -            UPDATE_0(prob);
 211.230 -            dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
 211.231 -            dicPos++;
 211.232 -            processedPos++;
 211.233 -            state = state < kNumLitStates ? 9 : 11;
 211.234 -            continue;
 211.235 -          }
 211.236 -          UPDATE_1(prob);
 211.237 -        }
 211.238 -        else
 211.239 -        {
 211.240 -          UInt32 distance;
 211.241 -          UPDATE_1(prob);
 211.242 -          prob = probs + IsRepG1 + state;
 211.243 -          IF_BIT_0(prob)
 211.244 -          {
 211.245 -            UPDATE_0(prob);
 211.246 -            distance = rep1;
 211.247 -          }
 211.248 -          else
 211.249 -          {
 211.250 -            UPDATE_1(prob);
 211.251 -            prob = probs + IsRepG2 + state;
 211.252 -            IF_BIT_0(prob)
 211.253 -            {
 211.254 -              UPDATE_0(prob);
 211.255 -              distance = rep2;
 211.256 -            }
 211.257 -            else
 211.258 -            {
 211.259 -              UPDATE_1(prob);
 211.260 -              distance = rep3;
 211.261 -              rep3 = rep2;
 211.262 -            }
 211.263 -            rep2 = rep1;
 211.264 -          }
 211.265 -          rep1 = rep0;
 211.266 -          rep0 = distance;
 211.267 -        }
 211.268 -        state = state < kNumLitStates ? 8 : 11;
 211.269 -        prob = probs + RepLenCoder;
 211.270 -      }
 211.271 -      {
 211.272 -        unsigned limit, offset;
 211.273 -        CLzmaProb *probLen = prob + LenChoice;
 211.274 -        IF_BIT_0(probLen)
 211.275 -        {
 211.276 -          UPDATE_0(probLen);
 211.277 -          probLen = prob + LenLow + (posState << kLenNumLowBits);
 211.278 -          offset = 0;
 211.279 -          limit = (1 << kLenNumLowBits);
 211.280 -        }
 211.281 -        else
 211.282 -        {
 211.283 -          UPDATE_1(probLen);
 211.284 -          probLen = prob + LenChoice2;
 211.285 -          IF_BIT_0(probLen)
 211.286 -          {
 211.287 -            UPDATE_0(probLen);
 211.288 -            probLen = prob + LenMid + (posState << kLenNumMidBits);
 211.289 -            offset = kLenNumLowSymbols;
 211.290 -            limit = (1 << kLenNumMidBits);
 211.291 -          }
 211.292 -          else
 211.293 -          {
 211.294 -            UPDATE_1(probLen);
 211.295 -            probLen = prob + LenHigh;
 211.296 -            offset = kLenNumLowSymbols + kLenNumMidSymbols;
 211.297 -            limit = (1 << kLenNumHighBits);
 211.298 -          }
 211.299 -        }
 211.300 -        TREE_DECODE(probLen, limit, len);
 211.301 -        len += offset;
 211.302 -      }
 211.303 -
 211.304 -      if (state >= kNumStates)
 211.305 -      {
 211.306 -        UInt32 distance;
 211.307 -        prob = probs + PosSlot +
 211.308 -            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
 211.309 -        TREE_6_DECODE(prob, distance);
 211.310 -        if (distance >= kStartPosModelIndex)
 211.311 -        {
 211.312 -          unsigned posSlot = (unsigned)distance;
 211.313 -          int numDirectBits = (int)(((distance >> 1) - 1));
 211.314 -          distance = (2 | (distance & 1));
 211.315 -          if (posSlot < kEndPosModelIndex)
 211.316 -          {
 211.317 -            distance <<= numDirectBits;
 211.318 -            prob = probs + SpecPos + distance - posSlot - 1;
 211.319 -            {
 211.320 -              UInt32 mask = 1;
 211.321 -              unsigned i = 1;
 211.322 -              do
 211.323 -              {
 211.324 -                GET_BIT2(prob + i, i, ; , distance |= mask);
 211.325 -                mask <<= 1;
 211.326 -              }
 211.327 -              while (--numDirectBits != 0);
 211.328 -            }
 211.329 -          }
 211.330 -          else
 211.331 -          {
 211.332 -            numDirectBits -= kNumAlignBits;
 211.333 -            do
 211.334 -            {
 211.335 -              NORMALIZE
 211.336 -              range >>= 1;
 211.337 -              
 211.338 -              {
 211.339 -                UInt32 t;
 211.340 -                code -= range;
 211.341 -                t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
 211.342 -                distance = (distance << 1) + (t + 1);
 211.343 -                code += range & t;
 211.344 -              }
 211.345 -              /*
 211.346 -              distance <<= 1;
 211.347 -              if (code >= range)
 211.348 -              {
 211.349 -                code -= range;
 211.350 -                distance |= 1;
 211.351 -              }
 211.352 -              */
 211.353 -            }
 211.354 -            while (--numDirectBits != 0);
 211.355 -            prob = probs + Align;
 211.356 -            distance <<= kNumAlignBits;
 211.357 -            {
 211.358 -              unsigned i = 1;
 211.359 -              GET_BIT2(prob + i, i, ; , distance |= 1);
 211.360 -              GET_BIT2(prob + i, i, ; , distance |= 2);
 211.361 -              GET_BIT2(prob + i, i, ; , distance |= 4);
 211.362 -              GET_BIT2(prob + i, i, ; , distance |= 8);
 211.363 -            }
 211.364 -            if (distance == (UInt32)0xFFFFFFFF)
 211.365 -            {
 211.366 -              len += kMatchSpecLenStart;
 211.367 -              state -= kNumStates;
 211.368 -              break;
 211.369 -            }
 211.370 -          }
 211.371 -        }
 211.372 -        rep3 = rep2;
 211.373 -        rep2 = rep1;
 211.374 -        rep1 = rep0;
 211.375 -        rep0 = distance + 1;
 211.376 -        if (checkDicSize == 0)
 211.377 -        {
 211.378 -          if (distance >= processedPos)
 211.379 -            return SZ_ERROR_DATA;
 211.380 -        }
 211.381 -        else if (distance >= checkDicSize)
 211.382 -          return SZ_ERROR_DATA;
 211.383 -        state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
 211.384 -        /* state = kLiteralNextStates[state]; */
 211.385 -      }
 211.386 -
 211.387 -      len += kMatchMinLen;
 211.388 -
 211.389 -      if (limit == dicPos)
 211.390 -        return SZ_ERROR_DATA;
 211.391 -      {
 211.392 -        SizeT rem = limit - dicPos;
 211.393 -        unsigned curLen = ((rem < len) ? (unsigned)rem : len);
 211.394 -        SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
 211.395 -
 211.396 -        processedPos += curLen;
 211.397 -
 211.398 -        len -= curLen;
 211.399 -        if (pos + curLen <= dicBufSize)
 211.400 -        {
 211.401 -          Byte *dest = dic + dicPos;
 211.402 -          ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
 211.403 -          const Byte *lim = dest + curLen;
 211.404 -          dicPos += curLen;
 211.405 -          do
 211.406 -            *(dest) = (Byte)*(dest + src);
 211.407 -          while (++dest != lim);
 211.408 -        }
 211.409 -        else
 211.410 -        {
 211.411 -          do
 211.412 -          {
 211.413 -            dic[dicPos++] = dic[pos];
 211.414 -            if (++pos == dicBufSize)
 211.415 -              pos = 0;
 211.416 -          }
 211.417 -          while (--curLen != 0);
 211.418 -        }
 211.419 -      }
 211.420 -    }
 211.421 -  }
 211.422 -  while (dicPos < limit && buf < bufLimit);
 211.423 -  NORMALIZE;
 211.424 -  p->buf = buf;
 211.425 -  p->range = range;
 211.426 -  p->code = code;
 211.427 -  p->remainLen = len;
 211.428 -  p->dicPos = dicPos;
 211.429 -  p->processedPos = processedPos;
 211.430 -  p->reps[0] = rep0;
 211.431 -  p->reps[1] = rep1;
 211.432 -  p->reps[2] = rep2;
 211.433 -  p->reps[3] = rep3;
 211.434 -  p->state = state;
 211.435 -
 211.436 -  return SZ_OK;
 211.437 -}
 211.438 -
 211.439 -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
 211.440 -{
 211.441 -  if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
 211.442 -  {
 211.443 -    Byte *dic = p->dic;
 211.444 -    SizeT dicPos = p->dicPos;
 211.445 -    SizeT dicBufSize = p->dicBufSize;
 211.446 -    unsigned len = p->remainLen;
 211.447 -    UInt32 rep0 = p->reps[0];
 211.448 -    if (limit - dicPos < len)
 211.449 -      len = (unsigned)(limit - dicPos);
 211.450 -
 211.451 -    if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
 211.452 -      p->checkDicSize = p->prop.dicSize;
 211.453 -
 211.454 -    p->processedPos += len;
 211.455 -    p->remainLen -= len;
 211.456 -    while (len-- != 0)
 211.457 -    {
 211.458 -      dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
 211.459 -      dicPos++;
 211.460 -    }
 211.461 -    p->dicPos = dicPos;
 211.462 -  }
 211.463 -}
 211.464 -
 211.465 -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
 211.466 -{
 211.467 -  do
 211.468 -  {
 211.469 -    SizeT limit2 = limit;
 211.470 -    if (p->checkDicSize == 0)
 211.471 -    {
 211.472 -      UInt32 rem = p->prop.dicSize - p->processedPos;
 211.473 -      if (limit - p->dicPos > rem)
 211.474 -        limit2 = p->dicPos + rem;
 211.475 -    }
 211.476 -    RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
 211.477 -    if (p->processedPos >= p->prop.dicSize)
 211.478 -      p->checkDicSize = p->prop.dicSize;
 211.479 -    LzmaDec_WriteRem(p, limit);
 211.480 -  }
 211.481 -  while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
 211.482 -
 211.483 -  if (p->remainLen > kMatchSpecLenStart)
 211.484 -  {
 211.485 -    p->remainLen = kMatchSpecLenStart;
 211.486 -  }
 211.487 -  return 0;
 211.488 -}
 211.489 -
 211.490 -typedef enum
 211.491 -{
 211.492 -  DUMMY_ERROR, /* unexpected end of input stream */
 211.493 -  DUMMY_LIT,
 211.494 -  DUMMY_MATCH,
 211.495 -  DUMMY_REP
 211.496 -} ELzmaDummy;
 211.497 -
 211.498 -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
 211.499 -{
 211.500 -  UInt32 range = p->range;
 211.501 -  UInt32 code = p->code;
 211.502 -  const Byte *bufLimit = buf + inSize;
 211.503 -  CLzmaProb *probs = p->probs;
 211.504 -  unsigned state = p->state;
 211.505 -  ELzmaDummy res;
 211.506 -
 211.507 -  {
 211.508 -    CLzmaProb *prob;
 211.509 -    UInt32 bound;
 211.510 -    unsigned ttt;
 211.511 -    unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
 211.512 -
 211.513 -    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
 211.514 -    IF_BIT_0_CHECK(prob)
 211.515 -    {
 211.516 -      UPDATE_0_CHECK
 211.517 -
 211.518 -      /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
 211.519 -
 211.520 -      prob = probs + Literal;
 211.521 -      if (p->checkDicSize != 0 || p->processedPos != 0)
 211.522 -        prob += (LZMA_LIT_SIZE *
 211.523 -          ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
 211.524 -          (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
 211.525 -
 211.526 -      if (state < kNumLitStates)
 211.527 -      {
 211.528 -        unsigned symbol = 1;
 211.529 -        do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
 211.530 -      }
 211.531 -      else
 211.532 -      {
 211.533 -        unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
 211.534 -            ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
 211.535 -        unsigned offs = 0x100;
 211.536 -        unsigned symbol = 1;
 211.537 -        do
 211.538 -        {
 211.539 -          unsigned bit;
 211.540 -          CLzmaProb *probLit;
 211.541 -          matchByte <<= 1;
 211.542 -          bit = (matchByte & offs);
 211.543 -          probLit = prob + offs + bit + symbol;
 211.544 -          GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
 211.545 -        }
 211.546 -        while (symbol < 0x100);
 211.547 -      }
 211.548 -      res = DUMMY_LIT;
 211.549 -    }
 211.550 -    else
 211.551 -    {
 211.552 -      unsigned len;
 211.553 -      UPDATE_1_CHECK;
 211.554 -
 211.555 -      prob = probs + IsRep + state;
 211.556 -      IF_BIT_0_CHECK(prob)
 211.557 -      {
 211.558 -        UPDATE_0_CHECK;
 211.559 -        state = 0;
 211.560 -        prob = probs + LenCoder;
 211.561 -        res = DUMMY_MATCH;
 211.562 -      }
 211.563 -      else
 211.564 -      {
 211.565 -        UPDATE_1_CHECK;
 211.566 -        res = DUMMY_REP;
 211.567 -        prob = probs + IsRepG0 + state;
 211.568 -        IF_BIT_0_CHECK(prob)
 211.569 -        {
 211.570 -          UPDATE_0_CHECK;
 211.571 -          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
 211.572 -          IF_BIT_0_CHECK(prob)
 211.573 -          {
 211.574 -            UPDATE_0_CHECK;
 211.575 -            NORMALIZE_CHECK;
 211.576 -            return DUMMY_REP;
 211.577 -          }
 211.578 -          else
 211.579 -          {
 211.580 -            UPDATE_1_CHECK;
 211.581 -          }
 211.582 -        }
 211.583 -        else
 211.584 -        {
 211.585 -          UPDATE_1_CHECK;
 211.586 -          prob = probs + IsRepG1 + state;
 211.587 -          IF_BIT_0_CHECK(prob)
 211.588 -          {
 211.589 -            UPDATE_0_CHECK;
 211.590 -          }
 211.591 -          else
 211.592 -          {
 211.593 -            UPDATE_1_CHECK;
 211.594 -            prob = probs + IsRepG2 + state;
 211.595 -            IF_BIT_0_CHECK(prob)
 211.596 -            {
 211.597 -              UPDATE_0_CHECK;
 211.598 -            }
 211.599 -            else
 211.600 -            {
 211.601 -              UPDATE_1_CHECK;
 211.602 -            }
 211.603 -          }
 211.604 -        }
 211.605 -        state = kNumStates;
 211.606 -        prob = probs + RepLenCoder;
 211.607 -      }
 211.608 -      {
 211.609 -        unsigned limit, offset;
 211.610 -        CLzmaProb *probLen = prob + LenChoice;
 211.611 -        IF_BIT_0_CHECK(probLen)
 211.612 -        {
 211.613 -          UPDATE_0_CHECK;
 211.614 -          probLen = prob + LenLow + (posState << kLenNumLowBits);
 211.615 -          offset = 0;
 211.616 -          limit = 1 << kLenNumLowBits;
 211.617 -        }
 211.618 -        else
 211.619 -        {
 211.620 -          UPDATE_1_CHECK;
 211.621 -          probLen = prob + LenChoice2;
 211.622 -          IF_BIT_0_CHECK(probLen)
 211.623 -          {
 211.624 -            UPDATE_0_CHECK;
 211.625 -            probLen = prob + LenMid + (posState << kLenNumMidBits);
 211.626 -            offset = kLenNumLowSymbols;
 211.627 -            limit = 1 << kLenNumMidBits;
 211.628 -          }
 211.629 -          else
 211.630 -          {
 211.631 -            UPDATE_1_CHECK;
 211.632 -            probLen = prob + LenHigh;
 211.633 -            offset = kLenNumLowSymbols + kLenNumMidSymbols;
 211.634 -            limit = 1 << kLenNumHighBits;
 211.635 -          }
 211.636 -        }
 211.637 -        TREE_DECODE_CHECK(probLen, limit, len);
 211.638 -        len += offset;
 211.639 -      }
 211.640 -
 211.641 -      if (state < 4)
 211.642 -      {
 211.643 -        unsigned posSlot;
 211.644 -        prob = probs + PosSlot +
 211.645 -            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
 211.646 -            kNumPosSlotBits);
 211.647 -        TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
 211.648 -        if (posSlot >= kStartPosModelIndex)
 211.649 -        {
 211.650 -          int numDirectBits = ((posSlot >> 1) - 1);
 211.651 -
 211.652 -          /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
 211.653 -
 211.654 -          if (posSlot < kEndPosModelIndex)
 211.655 -          {
 211.656 -            prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
 211.657 -          }
 211.658 -          else
 211.659 -          {
 211.660 -            numDirectBits -= kNumAlignBits;
 211.661 -            do
 211.662 -            {
 211.663 -              NORMALIZE_CHECK
 211.664 -              range >>= 1;
 211.665 -              code -= range & (((code - range) >> 31) - 1);
 211.666 -              /* if (code >= range) code -= range; */
 211.667 -            }
 211.668 -            while (--numDirectBits != 0);
 211.669 -            prob = probs + Align;
 211.670 -            numDirectBits = kNumAlignBits;
 211.671 -          }
 211.672 -          {
 211.673 -            unsigned i = 1;
 211.674 -            do
 211.675 -            {
 211.676 -              GET_BIT_CHECK(prob + i, i);
 211.677 -            }
 211.678 -            while (--numDirectBits != 0);
 211.679 -          }
 211.680 -        }
 211.681 -      }
 211.682 -    }
 211.683 -  }
 211.684 -  NORMALIZE_CHECK;
 211.685 -  return res;
 211.686 -}
 211.687 -
 211.688 -
 211.689 -static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
 211.690 -{
 211.691 -  p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
 211.692 -  p->range = 0xFFFFFFFF;
 211.693 -  p->needFlush = 0;
 211.694 -}
 211.695 -
 211.696 -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
 211.697 -{
 211.698 -  p->needFlush = 1;
 211.699 -  p->remainLen = 0;
 211.700 -  p->tempBufSize = 0;
 211.701 -
 211.702 -  if (initDic)
 211.703 -  {
 211.704 -    p->processedPos = 0;
 211.705 -    p->checkDicSize = 0;
 211.706 -    p->needInitState = 1;
 211.707 -  }
 211.708 -  if (initState)
 211.709 -    p->needInitState = 1;
 211.710 -}
 211.711 -
 211.712 -void LzmaDec_Init(CLzmaDec *p)
 211.713 -{
 211.714 -  p->dicPos = 0;
 211.715 -  LzmaDec_InitDicAndState(p, True, True);
 211.716 -}
 211.717 -
 211.718 -static void LzmaDec_InitStateReal(CLzmaDec *p)
 211.719 -{
 211.720 -  UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
 211.721 -  UInt32 i;
 211.722 -  CLzmaProb *probs = p->probs;
 211.723 -  for (i = 0; i < numProbs; i++)
 211.724 -    probs[i] = kBitModelTotal >> 1;
 211.725 -  p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
 211.726 -  p->state = 0;
 211.727 -  p->needInitState = 0;
 211.728 -}
 211.729 -
 211.730 -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
 211.731 -    ELzmaFinishMode finishMode, ELzmaStatus *status)
 211.732 -{
 211.733 -  SizeT inSize = *srcLen;
 211.734 -  (*srcLen) = 0;
 211.735 -  LzmaDec_WriteRem(p, dicLimit);
 211.736 -  
 211.737 -  *status = LZMA_STATUS_NOT_SPECIFIED;
 211.738 -
 211.739 -  while (p->remainLen != kMatchSpecLenStart)
 211.740 -  {
 211.741 -      int checkEndMarkNow;
 211.742 -
 211.743 -      if (p->needFlush != 0)
 211.744 -      {
 211.745 -        for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
 211.746 -          p->tempBuf[p->tempBufSize++] = *src++;
 211.747 -        if (p->tempBufSize < RC_INIT_SIZE)
 211.748 -        {
 211.749 -          *status = LZMA_STATUS_NEEDS_MORE_INPUT;
 211.750 -          return SZ_OK;
 211.751 -        }
 211.752 -        if (p->tempBuf[0] != 0)
 211.753 -          return SZ_ERROR_DATA;
 211.754 -
 211.755 -        LzmaDec_InitRc(p, p->tempBuf);
 211.756 -        p->tempBufSize = 0;
 211.757 -      }
 211.758 -
 211.759 -      checkEndMarkNow = 0;
 211.760 -      if (p->dicPos >= dicLimit)
 211.761 -      {
 211.762 -        if (p->remainLen == 0 && p->code == 0)
 211.763 -        {
 211.764 -          *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
 211.765 -          return SZ_OK;
 211.766 -        }
 211.767 -        if (finishMode == LZMA_FINISH_ANY)
 211.768 -        {
 211.769 -          *status = LZMA_STATUS_NOT_FINISHED;
 211.770 -          return SZ_OK;
 211.771 -        }
 211.772 -        if (p->remainLen != 0)
 211.773 -        {
 211.774 -          *status = LZMA_STATUS_NOT_FINISHED;
 211.775 -          return SZ_ERROR_DATA;
 211.776 -        }
 211.777 -        checkEndMarkNow = 1;
 211.778 -      }
 211.779 -
 211.780 -      if (p->needInitState)
 211.781 -        LzmaDec_InitStateReal(p);
 211.782 -  
 211.783 -      if (p->tempBufSize == 0)
 211.784 -      {
 211.785 -        SizeT processed;
 211.786 -        const Byte *bufLimit;
 211.787 -        if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
 211.788 -        {
 211.789 -          int dummyRes = LzmaDec_TryDummy(p, src, inSize);
 211.790 -          if (dummyRes == DUMMY_ERROR)
 211.791 -          {
 211.792 -            memcpy(p->tempBuf, src, inSize);
 211.793 -            p->tempBufSize = (unsigned)inSize;
 211.794 -            (*srcLen) += inSize;
 211.795 -            *status = LZMA_STATUS_NEEDS_MORE_INPUT;
 211.796 -            return SZ_OK;
 211.797 -          }
 211.798 -          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
 211.799 -          {
 211.800 -            *status = LZMA_STATUS_NOT_FINISHED;
 211.801 -            return SZ_ERROR_DATA;
 211.802 -          }
 211.803 -          bufLimit = src;
 211.804 -        }
 211.805 -        else
 211.806 -          bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
 211.807 -        p->buf = src;
 211.808 -        if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
 211.809 -          return SZ_ERROR_DATA;
 211.810 -        processed = (SizeT)(p->buf - src);
 211.811 -        (*srcLen) += processed;
 211.812 -        src += processed;
 211.813 -        inSize -= processed;
 211.814 -      }
 211.815 -      else
 211.816 -      {
 211.817 -        unsigned rem = p->tempBufSize, lookAhead = 0;
 211.818 -        while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
 211.819 -          p->tempBuf[rem++] = src[lookAhead++];
 211.820 -        p->tempBufSize = rem;
 211.821 -        if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
 211.822 -        {
 211.823 -          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
 211.824 -          if (dummyRes == DUMMY_ERROR)
 211.825 -          {
 211.826 -            (*srcLen) += lookAhead;
 211.827 -            *status = LZMA_STATUS_NEEDS_MORE_INPUT;
 211.828 -            return SZ_OK;
 211.829 -          }
 211.830 -          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
 211.831 -          {
 211.832 -            *status = LZMA_STATUS_NOT_FINISHED;
 211.833 -            return SZ_ERROR_DATA;
 211.834 -          }
 211.835 -        }
 211.836 -        p->buf = p->tempBuf;
 211.837 -        if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
 211.838 -          return SZ_ERROR_DATA;
 211.839 -        lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
 211.840 -        (*srcLen) += lookAhead;
 211.841 -        src += lookAhead;
 211.842 -        inSize -= lookAhead;
 211.843 -        p->tempBufSize = 0;
 211.844 -      }
 211.845 -  }
 211.846 -  if (p->code == 0)
 211.847 -    *status = LZMA_STATUS_FINISHED_WITH_MARK;
 211.848 -  return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
 211.849 -}
 211.850 -
 211.851 -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
 211.852 -{
 211.853 -  SizeT outSize = *destLen;
 211.854 -  SizeT inSize = *srcLen;
 211.855 -  *srcLen = *destLen = 0;
 211.856 -  for (;;)
 211.857 -  {
 211.858 -    SizeT inSizeCur = inSize, outSizeCur, dicPos;
 211.859 -    ELzmaFinishMode curFinishMode;
 211.860 -    SRes res;
 211.861 -    if (p->dicPos == p->dicBufSize)
 211.862 -      p->dicPos = 0;
 211.863 -    dicPos = p->dicPos;
 211.864 -    if (outSize > p->dicBufSize - dicPos)
 211.865 -    {
 211.866 -      outSizeCur = p->dicBufSize;
 211.867 -      curFinishMode = LZMA_FINISH_ANY;
 211.868 -    }
 211.869 -    else
 211.870 -    {
 211.871 -      outSizeCur = dicPos + outSize;
 211.872 -      curFinishMode = finishMode;
 211.873 -    }
 211.874 -
 211.875 -    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
 211.876 -    src += inSizeCur;
 211.877 -    inSize -= inSizeCur;
 211.878 -    *srcLen += inSizeCur;
 211.879 -    outSizeCur = p->dicPos - dicPos;
 211.880 -    memcpy(dest, p->dic + dicPos, outSizeCur);
 211.881 -    dest += outSizeCur;
 211.882 -    outSize -= outSizeCur;
 211.883 -    *destLen += outSizeCur;
 211.884 -    if (res != 0)
 211.885 -      return res;
 211.886 -    if (outSizeCur == 0 || outSize == 0)
 211.887 -      return SZ_OK;
 211.888 -  }
 211.889 -}
 211.890 -
 211.891 -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
 211.892 -{
 211.893 -  alloc->Free(alloc, p->probs);
 211.894 -  p->probs = 0;
 211.895 -}
 211.896 -
 211.897 -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
 211.898 -{
 211.899 -  alloc->Free(alloc, p->dic);
 211.900 -  p->dic = 0;
 211.901 -}
 211.902 -
 211.903 -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
 211.904 -{
 211.905 -  LzmaDec_FreeProbs(p, alloc);
 211.906 -  LzmaDec_FreeDict(p, alloc);
 211.907 -}
 211.908 -
 211.909 -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
 211.910 -{
 211.911 -  UInt32 dicSize;
 211.912 -  Byte d;
 211.913 -  
 211.914 -  if (size < LZMA_PROPS_SIZE)
 211.915 -    return SZ_ERROR_UNSUPPORTED;
 211.916 -  else
 211.917 -    dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
 211.918 - 
 211.919 -  if (dicSize < LZMA_DIC_MIN)
 211.920 -    dicSize = LZMA_DIC_MIN;
 211.921 -  p->dicSize = dicSize;
 211.922 -
 211.923 -  d = data[0];
 211.924 -  if (d >= (9 * 5 * 5))
 211.925 -    return SZ_ERROR_UNSUPPORTED;
 211.926 -
 211.927 -  p->lc = d % 9;
 211.928 -  d /= 9;
 211.929 -  p->pb = d / 5;
 211.930 -  p->lp = d % 5;
 211.931 -
 211.932 -  return SZ_OK;
 211.933 -}
 211.934 -
 211.935 -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
 211.936 -{
 211.937 -  UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
 211.938 -  if (p->probs == 0 || numProbs != p->numProbs)
 211.939 -  {
 211.940 -    LzmaDec_FreeProbs(p, alloc);
 211.941 -    p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
 211.942 -    p->numProbs = numProbs;
 211.943 -    if (p->probs == 0)
 211.944 -      return SZ_ERROR_MEM;
 211.945 -  }
 211.946 -  return SZ_OK;
 211.947 -}
 211.948 -
 211.949 -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
 211.950 -{
 211.951 -  CLzmaProps propNew;
 211.952 -  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
 211.953 -  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
 211.954 -  p->prop = propNew;
 211.955 -  return SZ_OK;
 211.956 -}
 211.957 -
 211.958 -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
 211.959 -{
 211.960 -  CLzmaProps propNew;
 211.961 -  SizeT dicBufSize;
 211.962 -  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
 211.963 -  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
 211.964 -  dicBufSize = propNew.dicSize;
 211.965 -  if (p->dic == 0 || dicBufSize != p->dicBufSize)
 211.966 -  {
 211.967 -    LzmaDec_FreeDict(p, alloc);
 211.968 -    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
 211.969 -    if (p->dic == 0)
 211.970 -    {
 211.971 -      LzmaDec_FreeProbs(p, alloc);
 211.972 -      return SZ_ERROR_MEM;
 211.973 -    }
 211.974 -  }
 211.975 -  p->dicBufSize = dicBufSize;
 211.976 -  p->prop = propNew;
 211.977 -  return SZ_OK;
 211.978 -}
 211.979 -
 211.980 -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
 211.981 -    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
 211.982 -    ELzmaStatus *status, ISzAlloc *alloc)
 211.983 -{
 211.984 -  CLzmaDec p;
 211.985 -  SRes res;
 211.986 -  SizeT inSize = *srcLen;
 211.987 -  SizeT outSize = *destLen;
 211.988 -  *srcLen = *destLen = 0;
 211.989 -  if (inSize < RC_INIT_SIZE)
 211.990 -    return SZ_ERROR_INPUT_EOF;
 211.991 -
 211.992 -  LzmaDec_Construct(&p);
 211.993 -  res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
 211.994 -  if (res != 0)
 211.995 -    return res;
 211.996 -  p.dic = dest;
 211.997 -  p.dicBufSize = outSize;
 211.998 -
 211.999 -  LzmaDec_Init(&p);
211.1000 -  
211.1001 -  *srcLen = inSize;
211.1002 -  res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
211.1003 -
211.1004 -  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
211.1005 -    res = SZ_ERROR_INPUT_EOF;
211.1006 -
211.1007 -  (*destLen) = p.dicPos;
211.1008 -  LzmaDec_FreeProbs(&p, alloc);
211.1009 -  return res;
211.1010 -}
   212.1 --- a/src/win32/7zip/7z/C/LzmaDec.h	Sat Mar 03 10:54:39 2012 -0600
   212.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   212.3 @@ -1,223 +0,0 @@
   212.4 -/* LzmaDec.h -- LZMA Decoder
   212.5 -2008-10-04 : Igor Pavlov : Public domain */
   212.6 -
   212.7 -#ifndef __LZMADEC_H
   212.8 -#define __LZMADEC_H
   212.9 -
  212.10 -#include "Types.h"
  212.11 -
  212.12 -/* #define _LZMA_PROB32 */
  212.13 -/* _LZMA_PROB32 can increase the speed on some CPUs,
  212.14 -   but memory usage for CLzmaDec::probs will be doubled in that case */
  212.15 -
  212.16 -#ifdef _LZMA_PROB32
  212.17 -#define CLzmaProb UInt32
  212.18 -#else
  212.19 -#define CLzmaProb UInt16
  212.20 -#endif
  212.21 -
  212.22 -
  212.23 -/* ---------- LZMA Properties ---------- */
  212.24 -
  212.25 -#define LZMA_PROPS_SIZE 5
  212.26 -
  212.27 -typedef struct _CLzmaProps
  212.28 -{
  212.29 -  unsigned lc, lp, pb;
  212.30 -  UInt32 dicSize;
  212.31 -} CLzmaProps;
  212.32 -
  212.33 -/* LzmaProps_Decode - decodes properties
  212.34 -Returns:
  212.35 -  SZ_OK
  212.36 -  SZ_ERROR_UNSUPPORTED - Unsupported properties
  212.37 -*/
  212.38 -
  212.39 -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
  212.40 -
  212.41 -
  212.42 -/* ---------- LZMA Decoder state ---------- */
  212.43 -
  212.44 -/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
  212.45 -   Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
  212.46 -
  212.47 -#define LZMA_REQUIRED_INPUT_MAX 20
  212.48 -
  212.49 -typedef struct
  212.50 -{
  212.51 -  CLzmaProps prop;
  212.52 -  CLzmaProb *probs;
  212.53 -  Byte *dic;
  212.54 -  const Byte *buf;
  212.55 -  UInt32 range, code;
  212.56 -  SizeT dicPos;
  212.57 -  SizeT dicBufSize;
  212.58 -  UInt32 processedPos;
  212.59 -  UInt32 checkDicSize;
  212.60 -  unsigned state;
  212.61 -  UInt32 reps[4];
  212.62 -  unsigned remainLen;
  212.63 -  int needFlush;
  212.64 -  int needInitState;
  212.65 -  UInt32 numProbs;
  212.66 -  unsigned tempBufSize;
  212.67 -  Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
  212.68 -} CLzmaDec;
  212.69 -
  212.70 -#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
  212.71 -
  212.72 -void LzmaDec_Init(CLzmaDec *p);
  212.73 -
  212.74 -/* There are two types of LZMA streams:
  212.75 -     0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
  212.76 -     1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
  212.77 -
  212.78 -typedef enum
  212.79 -{
  212.80 -  LZMA_FINISH_ANY,   /* finish at any point */
  212.81 -  LZMA_FINISH_END    /* block must be finished at the end */
  212.82 -} ELzmaFinishMode;
  212.83 -
  212.84 -/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
  212.85 -
  212.86 -   You must use LZMA_FINISH_END, when you know that current output buffer
  212.87 -   covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
  212.88 -
  212.89 -   If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
  212.90 -   and output value of destLen will be less than output buffer size limit.
  212.91 -   You can check status result also.
  212.92 -
  212.93 -   You can use multiple checks to test data integrity after full decompression:
  212.94 -     1) Check Result and "status" variable.
  212.95 -     2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
  212.96 -     3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
  212.97 -        You must use correct finish mode in that case. */
  212.98 -
  212.99 -typedef enum
 212.100 -{
 212.101 -  LZMA_STATUS_NOT_SPECIFIED,               /* use main error code instead */
 212.102 -  LZMA_STATUS_FINISHED_WITH_MARK,          /* stream was finished with end mark. */
 212.103 -  LZMA_STATUS_NOT_FINISHED,                /* stream was not finished */
 212.104 -  LZMA_STATUS_NEEDS_MORE_INPUT,            /* you must provide more input bytes */
 212.105 -  LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK  /* there is probability that stream was finished without end mark */
 212.106 -} ELzmaStatus;
 212.107 -
 212.108 -/* ELzmaStatus is used only as output value for function call */
 212.109 -
 212.110 -
 212.111 -/* ---------- Interfaces ---------- */
 212.112 -
 212.113 -/* There are 3 levels of interfaces:
 212.114 -     1) Dictionary Interface
 212.115 -     2) Buffer Interface
 212.116 -     3) One Call Interface
 212.117 -   You can select any of these interfaces, but don't mix functions from different
 212.118 -   groups for same object. */
 212.119 -
 212.120 -
 212.121 -/* There are two variants to allocate state for Dictionary Interface:
 212.122 -     1) LzmaDec_Allocate / LzmaDec_Free
 212.123 -     2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
 212.124 -   You can use variant 2, if you set dictionary buffer manually.
 212.125 -   For Buffer Interface you must always use variant 1.
 212.126 -
 212.127 -LzmaDec_Allocate* can return:
 212.128 -  SZ_OK
 212.129 -  SZ_ERROR_MEM         - Memory allocation error
 212.130 -  SZ_ERROR_UNSUPPORTED - Unsupported properties
 212.131 -*/
 212.132 -   
 212.133 -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
 212.134 -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
 212.135 -
 212.136 -SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
 212.137 -void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
 212.138 -
 212.139 -/* ---------- Dictionary Interface ---------- */
 212.140 -
 212.141 -/* You can use it, if you want to eliminate the overhead for data copying from
 212.142 -   dictionary to some other external buffer.
 212.143 -   You must work with CLzmaDec variables directly in this interface.
 212.144 -
 212.145 -   STEPS:
 212.146 -     LzmaDec_Constr()
 212.147 -     LzmaDec_Allocate()
 212.148 -     for (each new stream)
 212.149 -     {
 212.150 -       LzmaDec_Init()
 212.151 -       while (it needs more decompression)
 212.152 -       {
 212.153 -         LzmaDec_DecodeToDic()
 212.154 -         use data from CLzmaDec::dic and update CLzmaDec::dicPos
 212.155 -       }
 212.156 -     }
 212.157 -     LzmaDec_Free()
 212.158 -*/
 212.159 -
 212.160 -/* LzmaDec_DecodeToDic
 212.161 -   
 212.162 -   The decoding to internal dictionary buffer (CLzmaDec::dic).
 212.163 -   You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
 212.164 -
 212.165 -finishMode:
 212.166 -  It has meaning only if the decoding reaches output limit (dicLimit).
 212.167 -  LZMA_FINISH_ANY - Decode just dicLimit bytes.
 212.168 -  LZMA_FINISH_END - Stream must be finished after dicLimit.
 212.169 -
 212.170 -Returns:
 212.171 -  SZ_OK
 212.172 -    status:
 212.173 -      LZMA_STATUS_FINISHED_WITH_MARK
 212.174 -      LZMA_STATUS_NOT_FINISHED
 212.175 -      LZMA_STATUS_NEEDS_MORE_INPUT
 212.176 -      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
 212.177 -  SZ_ERROR_DATA - Data error
 212.178 -*/
 212.179 -
 212.180 -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
 212.181 -    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
 212.182 -
 212.183 -
 212.184 -/* ---------- Buffer Interface ---------- */
 212.185 -
 212.186 -/* It's zlib-like interface.
 212.187 -   See LzmaDec_DecodeToDic description for information about STEPS and return results,
 212.188 -   but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
 212.189 -   to work with CLzmaDec variables manually.
 212.190 -
 212.191 -finishMode:
 212.192 -  It has meaning only if the decoding reaches output limit (*destLen).
 212.193 -  LZMA_FINISH_ANY - Decode just destLen bytes.
 212.194 -  LZMA_FINISH_END - Stream must be finished after (*destLen).
 212.195 -*/
 212.196 -
 212.197 -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
 212.198 -    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
 212.199 -
 212.200 -
 212.201 -/* ---------- One Call Interface ---------- */
 212.202 -
 212.203 -/* LzmaDecode
 212.204 -
 212.205 -finishMode:
 212.206 -  It has meaning only if the decoding reaches output limit (*destLen).
 212.207 -  LZMA_FINISH_ANY - Decode just destLen bytes.
 212.208 -  LZMA_FINISH_END - Stream must be finished after (*destLen).
 212.209 -
 212.210 -Returns:
 212.211 -  SZ_OK
 212.212 -    status:
 212.213 -      LZMA_STATUS_FINISHED_WITH_MARK
 212.214 -      LZMA_STATUS_NOT_FINISHED
 212.215 -      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
 212.216 -  SZ_ERROR_DATA - Data error
 212.217 -  SZ_ERROR_MEM  - Memory allocation error
 212.218 -  SZ_ERROR_UNSUPPORTED - Unsupported properties
 212.219 -  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
 212.220 -*/
 212.221 -
 212.222 -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
 212.223 -    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
 212.224 -    ELzmaStatus *status, ISzAlloc *alloc);
 212.225 -
 212.226 -#endif
   213.1 --- a/src/win32/7zip/7z/C/LzmaEnc.c	Sat Mar 03 10:54:39 2012 -0600
   213.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   213.3 @@ -1,2275 +0,0 @@
   213.4 -/* LzmaEnc.c -- LZMA Encoder
   213.5 -2008-10-04 : Igor Pavlov : Public domain */
   213.6 -
   213.7 -#include <string.h>
   213.8 -
   213.9 -/* #define SHOW_STAT */
  213.10 -/* #define SHOW_STAT2 */
  213.11 -
  213.12 -#if defined(SHOW_STAT) || defined(SHOW_STAT2)
  213.13 -#include <stdio.h>
  213.14 -#endif
  213.15 -
  213.16 -#include "LzmaEnc.h"
  213.17 -
  213.18 -#include "LzFind.h"
  213.19 -#ifdef COMPRESS_MF_MT
  213.20 -#include "LzFindMt.h"
  213.21 -#endif
  213.22 -
  213.23 -#ifdef SHOW_STAT
  213.24 -static int ttt = 0;
  213.25 -#endif
  213.26 -
  213.27 -#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)
  213.28 -
  213.29 -#define kBlockSize (9 << 10)
  213.30 -#define kUnpackBlockSize (1 << 18)
  213.31 -#define kMatchArraySize (1 << 21)
  213.32 -#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX)
  213.33 -
  213.34 -#define kNumMaxDirectBits (31)
  213.35 -
  213.36 -#define kNumTopBits 24
  213.37 -#define kTopValue ((UInt32)1 << kNumTopBits)
  213.38 -
  213.39 -#define kNumBitModelTotalBits 11
  213.40 -#define kBitModelTotal (1 << kNumBitModelTotalBits)
  213.41 -#define kNumMoveBits 5
  213.42 -#define kProbInitValue (kBitModelTotal >> 1)
  213.43 -
  213.44 -#define kNumMoveReducingBits 4
  213.45 -#define kNumBitPriceShiftBits 4
  213.46 -#define kBitPrice (1 << kNumBitPriceShiftBits)
  213.47 -
  213.48 -void LzmaEncProps_Init(CLzmaEncProps *p)
  213.49 -{
  213.50 -  p->level = 5;
  213.51 -  p->dictSize = p->mc = 0;
  213.52 -  p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
  213.53 -  p->writeEndMark = 0;
  213.54 -}
  213.55 -
  213.56 -void LzmaEncProps_Normalize(CLzmaEncProps *p)
  213.57 -{
  213.58 -  int level = p->level;
  213.59 -  if (level < 0) level = 5;
  213.60 -  p->level = level;
  213.61 -  if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
  213.62 -  if (p->lc < 0) p->lc = 3;
  213.63 -  if (p->lp < 0) p->lp = 0;
  213.64 -  if (p->pb < 0) p->pb = 2;
  213.65 -  if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);
  213.66 -  if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);
  213.67 -  if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
  213.68 -  if (p->numHashBytes < 0) p->numHashBytes = 4;
  213.69 -  if (p->mc == 0)  p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
  213.70 -  if (p->numThreads < 0) p->numThreads = ((p->btMode && p->algo) ? 2 : 1);
  213.71 -}
  213.72 -
  213.73 -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
  213.74 -{
  213.75 -  CLzmaEncProps props = *props2;
  213.76 -  LzmaEncProps_Normalize(&props);
  213.77 -  return props.dictSize;
  213.78 -}
  213.79 -
  213.80 -/* #define LZMA_LOG_BSR */
  213.81 -/* Define it for Intel's CPU */
  213.82 -
  213.83 -
  213.84 -#ifdef LZMA_LOG_BSR
  213.85 -
  213.86 -#define kDicLogSizeMaxCompress 30
  213.87 -
  213.88 -#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
  213.89 -
  213.90 -UInt32 GetPosSlot1(UInt32 pos)
  213.91 -{
  213.92 -  UInt32 res;
  213.93 -  BSR2_RET(pos, res);
  213.94 -  return res;
  213.95 -}
  213.96 -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
  213.97 -#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }
  213.98 -
  213.99 -#else
 213.100 -
 213.101 -#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
 213.102 -#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
 213.103 -
 213.104 -void LzmaEnc_FastPosInit(Byte *g_FastPos)
 213.105 -{
 213.106 -  int c = 2, slotFast;
 213.107 -  g_FastPos[0] = 0;
 213.108 -  g_FastPos[1] = 1;
 213.109 -  
 213.110 -  for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
 213.111 -  {
 213.112 -    UInt32 k = (1 << ((slotFast >> 1) - 1));
 213.113 -    UInt32 j;
 213.114 -    for (j = 0; j < k; j++, c++)
 213.115 -      g_FastPos[c] = (Byte)slotFast;
 213.116 -  }
 213.117 -}
 213.118 -
 213.119 -#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
 213.120 -  (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
 213.121 -  res = p->g_FastPos[pos >> i] + (i * 2); }
 213.122 -/*
 213.123 -#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
 213.124 -  p->g_FastPos[pos >> 6] + 12 : \
 213.125 -  p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; }
 213.126 -*/
 213.127 -
 213.128 -#define GetPosSlot1(pos) p->g_FastPos[pos]
 213.129 -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
 213.130 -#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); }
 213.131 -
 213.132 -#endif
 213.133 -
 213.134 -
 213.135 -#define LZMA_NUM_REPS 4
 213.136 -
 213.137 -typedef unsigned CState;
 213.138 -
 213.139 -typedef struct _COptimal
 213.140 -{
 213.141 -  UInt32 price;
 213.142 -
 213.143 -  CState state;
 213.144 -  int prev1IsChar;
 213.145 -  int prev2;
 213.146 -
 213.147 -  UInt32 posPrev2;
 213.148 -  UInt32 backPrev2;
 213.149 -
 213.150 -  UInt32 posPrev;
 213.151 -  UInt32 backPrev;
 213.152 -  UInt32 backs[LZMA_NUM_REPS];
 213.153 -} COptimal;
 213.154 -
 213.155 -#define kNumOpts (1 << 12)
 213.156 -
 213.157 -#define kNumLenToPosStates 4
 213.158 -#define kNumPosSlotBits 6
 213.159 -#define kDicLogSizeMin 0
 213.160 -#define kDicLogSizeMax 32
 213.161 -#define kDistTableSizeMax (kDicLogSizeMax * 2)
 213.162 -
 213.163 -
 213.164 -#define kNumAlignBits 4
 213.165 -#define kAlignTableSize (1 << kNumAlignBits)
 213.166 -#define kAlignMask (kAlignTableSize - 1)
 213.167 -
 213.168 -#define kStartPosModelIndex 4
 213.169 -#define kEndPosModelIndex 14
 213.170 -#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)
 213.171 -
 213.172 -#define kNumFullDistances (1 << (kEndPosModelIndex / 2))
 213.173 -
 213.174 -#ifdef _LZMA_PROB32
 213.175 -#define CLzmaProb UInt32
 213.176 -#else
 213.177 -#define CLzmaProb UInt16
 213.178 -#endif
 213.179 -
 213.180 -#define LZMA_PB_MAX 4
 213.181 -#define LZMA_LC_MAX 8
 213.182 -#define LZMA_LP_MAX 4
 213.183 -
 213.184 -#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)
 213.185 -
 213.186 -
 213.187 -#define kLenNumLowBits 3
 213.188 -#define kLenNumLowSymbols (1 << kLenNumLowBits)
 213.189 -#define kLenNumMidBits 3
 213.190 -#define kLenNumMidSymbols (1 << kLenNumMidBits)
 213.191 -#define kLenNumHighBits 8
 213.192 -#define kLenNumHighSymbols (1 << kLenNumHighBits)
 213.193 -
 213.194 -#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
 213.195 -
 213.196 -#define LZMA_MATCH_LEN_MIN 2
 213.197 -#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1)
 213.198 -
 213.199 -#define kNumStates 12
 213.200 -
 213.201 -typedef struct
 213.202 -{
 213.203 -  CLzmaProb choice;
 213.204 -  CLzmaProb choice2;
 213.205 -  CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];
 213.206 -  CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];
 213.207 -  CLzmaProb high[kLenNumHighSymbols];
 213.208 -} CLenEnc;
 213.209 -
 213.210 -typedef struct
 213.211 -{
 213.212 -  CLenEnc p;
 213.213 -  UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
 213.214 -  UInt32 tableSize;
 213.215 -  UInt32 counters[LZMA_NUM_PB_STATES_MAX];
 213.216 -} CLenPriceEnc;
 213.217 -
 213.218 -typedef struct _CRangeEnc
 213.219 -{
 213.220 -  UInt32 range;
 213.221 -  Byte cache;
 213.222 -  UInt64 low;
 213.223 -  UInt64 cacheSize;
 213.224 -  Byte *buf;
 213.225 -  Byte *bufLim;
 213.226 -  Byte *bufBase;
 213.227 -  ISeqOutStream *outStream;
 213.228 -  UInt64 processed;
 213.229 -  SRes res;
 213.230 -} CRangeEnc;
 213.231 -
 213.232 -typedef struct _CSeqInStreamBuf
 213.233 -{
 213.234 -  ISeqInStream funcTable;
 213.235 -  const Byte *data;
 213.236 -  SizeT rem;
 213.237 -} CSeqInStreamBuf;
 213.238 -
 213.239 -static SRes MyRead(void *pp, void *data, size_t *size)
 213.240 -{
 213.241 -  size_t curSize = *size;
 213.242 -  CSeqInStreamBuf *p = (CSeqInStreamBuf *)pp;
 213.243 -  if (p->rem < curSize)
 213.244 -    curSize = p->rem;
 213.245 -  memcpy(data, p->data, curSize);
 213.246 -  p->rem -= curSize;
 213.247 -  p->data += curSize;
 213.248 -  *size = curSize;
 213.249 -  return SZ_OK;
 213.250 -}
 213.251 -
 213.252 -typedef struct
 213.253 -{
 213.254 -  CLzmaProb *litProbs;
 213.255 -
 213.256 -  CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
 213.257 -  CLzmaProb isRep[kNumStates];
 213.258 -  CLzmaProb isRepG0[kNumStates];
 213.259 -  CLzmaProb isRepG1[kNumStates];
 213.260 -  CLzmaProb isRepG2[kNumStates];
 213.261 -  CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
 213.262 -
 213.263 -  CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
 213.264 -  CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
 213.265 -  CLzmaProb posAlignEncoder[1 << kNumAlignBits];
 213.266 -  
 213.267 -  CLenPriceEnc lenEnc;
 213.268 -  CLenPriceEnc repLenEnc;
 213.269 -
 213.270 -  UInt32 reps[LZMA_NUM_REPS];
 213.271 -  UInt32 state;
 213.272 -} CSaveState;
 213.273 -
 213.274 -typedef struct _CLzmaEnc
 213.275 -{
 213.276 -  IMatchFinder matchFinder;
 213.277 -  void *matchFinderObj;
 213.278 -
 213.279 -  #ifdef COMPRESS_MF_MT
 213.280 -  Bool mtMode;
 213.281 -  CMatchFinderMt matchFinderMt;
 213.282 -  #endif
 213.283 -
 213.284 -  CMatchFinder matchFinderBase;
 213.285 -
 213.286 -  #ifdef COMPRESS_MF_MT
 213.287 -  Byte pad[128];
 213.288 -  #endif
 213.289 -  
 213.290 -  UInt32 optimumEndIndex;
 213.291 -  UInt32 optimumCurrentIndex;
 213.292 -
 213.293 -  UInt32 longestMatchLength;
 213.294 -  UInt32 numPairs;
 213.295 -  UInt32 numAvail;
 213.296 -  COptimal opt[kNumOpts];
 213.297 -  
 213.298 -  #ifndef LZMA_LOG_BSR
 213.299 -  Byte g_FastPos[1 << kNumLogBits];
 213.300 -  #endif
 213.301 -
 213.302 -  UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
 213.303 -  UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
 213.304 -  UInt32 numFastBytes;
 213.305 -  UInt32 additionalOffset;
 213.306 -  UInt32 reps[LZMA_NUM_REPS];
 213.307 -  UInt32 state;
 213.308 -
 213.309 -  UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
 213.310 -  UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];
 213.311 -  UInt32 alignPrices[kAlignTableSize];
 213.312 -  UInt32 alignPriceCount;
 213.313 -
 213.314 -  UInt32 distTableSize;
 213.315 -
 213.316 -  unsigned lc, lp, pb;
 213.317 -  unsigned lpMask, pbMask;
 213.318 -
 213.319 -  CLzmaProb *litProbs;
 213.320 -
 213.321 -  CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
 213.322 -  CLzmaProb isRep[kNumStates];
 213.323 -  CLzmaProb isRepG0[kNumStates];
 213.324 -  CLzmaProb isRepG1[kNumStates];
 213.325 -  CLzmaProb isRepG2[kNumStates];
 213.326 -  CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
 213.327 -
 213.328 -  CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
 213.329 -  CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
 213.330 -  CLzmaProb posAlignEncoder[1 << kNumAlignBits];
 213.331 -  
 213.332 -  CLenPriceEnc lenEnc;
 213.333 -  CLenPriceEnc repLenEnc;
 213.334 -
 213.335 -  unsigned lclp;
 213.336 -
 213.337 -  Bool fastMode;
 213.338 -  
 213.339 -  CRangeEnc rc;
 213.340 -
 213.341 -  Bool writeEndMark;
 213.342 -  UInt64 nowPos64;
 213.343 -  UInt32 matchPriceCount;
 213.344 -  Bool finished;
 213.345 -  Bool multiThread;
 213.346 -
 213.347 -  SRes result;
 213.348 -  UInt32 dictSize;
 213.349 -  UInt32 matchFinderCycles;
 213.350 -
 213.351 -  ISeqInStream *inStream;
 213.352 -  CSeqInStreamBuf seqBufInStream;
 213.353 -
 213.354 -  CSaveState saveState;
 213.355 -} CLzmaEnc;
 213.356 -
 213.357 -void LzmaEnc_SaveState(CLzmaEncHandle pp)
 213.358 -{
 213.359 -  CLzmaEnc *p = (CLzmaEnc *)pp;
 213.360 -  CSaveState *dest = &p->saveState;
 213.361 -  int i;
 213.362 -  dest->lenEnc = p->lenEnc;
 213.363 -  dest->repLenEnc = p->repLenEnc;
 213.364 -  dest->state = p->state;
 213.365 -
 213.366 -  for (i = 0; i < kNumStates; i++)
 213.367 -  {
 213.368 -    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
 213.369 -    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
 213.370 -  }
 213.371 -  for (i = 0; i < kNumLenToPosStates; i++)
 213.372 -    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
 213.373 -  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
 213.374 -  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
 213.375 -  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
 213.376 -  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
 213.377 -  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
 213.378 -  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
 213.379 -  memcpy(dest->reps, p->reps, sizeof(p->reps));
 213.380 -  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
 213.381 -}
 213.382 -
 213.383 -void LzmaEnc_RestoreState(CLzmaEncHandle pp)
 213.384 -{
 213.385 -  CLzmaEnc *dest = (CLzmaEnc *)pp;
 213.386 -  const CSaveState *p = &dest->saveState;
 213.387 -  int i;
 213.388 -  dest->lenEnc = p->lenEnc;
 213.389 -  dest->repLenEnc = p->repLenEnc;
 213.390 -  dest->state = p->state;
 213.391 -
 213.392 -  for (i = 0; i < kNumStates; i++)
 213.393 -  {
 213.394 -    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
 213.395 -    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
 213.396 -  }
 213.397 -  for (i = 0; i < kNumLenToPosStates; i++)
 213.398 -    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
 213.399 -  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
 213.400 -  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
 213.401 -  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
 213.402 -  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
 213.403 -  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
 213.404 -  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
 213.405 -  memcpy(dest->reps, p->reps, sizeof(p->reps));
 213.406 -  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
 213.407 -}
 213.408 -
 213.409 -SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
 213.410 -{
 213.411 -  CLzmaEnc *p = (CLzmaEnc *)pp;
 213.412 -  CLzmaEncProps props = *props2;
 213.413 -  LzmaEncProps_Normalize(&props);
 213.414 -
 213.415 -  if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
 213.416 -      props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
 213.417 -    return SZ_ERROR_PARAM;
 213.418 -  p->dictSize = props.dictSize;
 213.419 -  p->matchFinderCycles = props.mc;
 213.420 -  {
 213.421 -    unsigned fb = props.fb;
 213.422 -    if (fb < 5)
 213.423 -      fb = 5;
 213.424 -    if (fb > LZMA_MATCH_LEN_MAX)
 213.425 -      fb = LZMA_MATCH_LEN_MAX;
 213.426 -    p->numFastBytes = fb;
 213.427 -  }
 213.428 -  p->lc = props.lc;
 213.429 -  p->lp = props.lp;
 213.430 -  p->pb = props.pb;
 213.431 -  p->fastMode = (props.algo == 0);
 213.432 -  p->matchFinderBase.btMode = props.btMode;
 213.433 -  {
 213.434 -    UInt32 numHashBytes = 4;
 213.435 -    if (props.btMode)
 213.436 -    {
 213.437 -      if (props.numHashBytes < 2)
 213.438 -        numHashBytes = 2;
 213.439 -      else if (props.numHashBytes < 4)
 213.440 -        numHashBytes = props.numHashBytes;
 213.441 -    }
 213.442 -    p->matchFinderBase.numHashBytes = numHashBytes;
 213.443 -  }
 213.444 -
 213.445 -  p->matchFinderBase.cutValue = props.mc;
 213.446 -
 213.447 -  p->writeEndMark = props.writeEndMark;
 213.448 -
 213.449 -  #ifdef COMPRESS_MF_MT
 213.450 -  /*
 213.451 -  if (newMultiThread != _multiThread)
 213.452 -  {
 213.453 -    ReleaseMatchFinder();
 213.454 -    _multiThread = newMultiThread;
 213.455 -  }
 213.456 -  */
 213.457 -  p->multiThread = (props.numThreads > 1);
 213.458 -  #endif
 213.459 -
 213.460 -  return SZ_OK;
 213.461 -}
 213.462 -
 213.463 -static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4,  5,  6,   4, 5};
 213.464 -static const int kMatchNextStates[kNumStates]   = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
 213.465 -static const int kRepNextStates[kNumStates]     = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
 213.466 -static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
 213.467 -
 213.468 -#define IsCharState(s) ((s) < 7)
 213.469 -
 213.470 -#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1)
 213.471 -
 213.472 -#define kInfinityPrice (1 << 30)
 213.473 -
 213.474 -static void RangeEnc_Construct(CRangeEnc *p)
 213.475 -{
 213.476 -  p->outStream = 0;
 213.477 -  p->bufBase = 0;
 213.478 -}
 213.479 -
 213.480 -#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
 213.481 -
 213.482 -#define RC_BUF_SIZE (1 << 16)
 213.483 -static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
 213.484 -{
 213.485 -  if (p->bufBase == 0)
 213.486 -  {
 213.487 -    p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
 213.488 -    if (p->bufBase == 0)
 213.489 -      return 0;
 213.490 -    p->bufLim = p->bufBase + RC_BUF_SIZE;
 213.491 -  }
 213.492 -  return 1;
 213.493 -}
 213.494 -
 213.495 -static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)
 213.496 -{
 213.497 -  alloc->Free(alloc, p->bufBase);
 213.498 -  p->bufBase = 0;
 213.499 -}
 213.500 -
 213.501 -static void RangeEnc_Init(CRangeEnc *p)
 213.502 -{
 213.503 -  /* Stream.Init(); */
 213.504 -  p->low = 0;
 213.505 -  p->range = 0xFFFFFFFF;
 213.506 -  p->cacheSize = 1;
 213.507 -  p->cache = 0;
 213.508 -
 213.509 -  p->buf = p->bufBase;
 213.510 -
 213.511 -  p->processed = 0;
 213.512 -  p->res = SZ_OK;
 213.513 -}
 213.514 -
 213.515 -static void RangeEnc_FlushStream(CRangeEnc *p)
 213.516 -{
 213.517 -  size_t num;
 213.518 -  if (p->res != SZ_OK)
 213.519 -    return;
 213.520 -  num = p->buf - p->bufBase;
 213.521 -  if (num != p->outStream->Write(p->outStream, p->bufBase, num))
 213.522 -    p->res = SZ_ERROR_WRITE;
 213.523 -  p->processed += num;
 213.524 -  p->buf = p->bufBase;
 213.525 -}
 213.526 -
 213.527 -static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
 213.528 -{
 213.529 -  if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
 213.530 -  {
 213.531 -    Byte temp = p->cache;
 213.532 -    do
 213.533 -    {
 213.534 -      Byte *buf = p->buf;
 213.535 -      *buf++ = (Byte)(temp + (Byte)(p->low >> 32));
 213.536 -      p->buf = buf;
 213.537 -      if (buf == p->bufLim)
 213.538 -        RangeEnc_FlushStream(p);
 213.539 -      temp = 0xFF;
 213.540 -    }
 213.541 -    while (--p->cacheSize != 0);
 213.542 -    p->cache = (Byte)((UInt32)p->low >> 24);
 213.543 -  }
 213.544 -  p->cacheSize++;
 213.545 -  p->low = (UInt32)p->low << 8;
 213.546 -}
 213.547 -
 213.548 -static void RangeEnc_FlushData(CRangeEnc *p)
 213.549 -{
 213.550 -  int i;
 213.551 -  for (i = 0; i < 5; i++)
 213.552 -    RangeEnc_ShiftLow(p);
 213.553 -}
 213.554 -
 213.555 -static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
 213.556 -{
 213.557 -  do
 213.558 -  {
 213.559 -    p->range >>= 1;
 213.560 -    p->low += p->range & (0 - ((value >> --numBits) & 1));
 213.561 -    if (p->range < kTopValue)
 213.562 -    {
 213.563 -      p->range <<= 8;
 213.564 -      RangeEnc_ShiftLow(p);
 213.565 -    }
 213.566 -  }
 213.567 -  while (numBits != 0);
 213.568 -}
 213.569 -
 213.570 -static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
 213.571 -{
 213.572 -  UInt32 ttt = *prob;
 213.573 -  UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;
 213.574 -  if (symbol == 0)
 213.575 -  {
 213.576 -    p->range = newBound;
 213.577 -    ttt += (kBitModelTotal - ttt) >> kNumMoveBits;
 213.578 -  }
 213.579 -  else
 213.580 -  {
 213.581 -    p->low += newBound;
 213.582 -    p->range -= newBound;
 213.583 -    ttt -= ttt >> kNumMoveBits;
 213.584 -  }
 213.585 -  *prob = (CLzmaProb)ttt;
 213.586 -  if (p->range < kTopValue)
 213.587 -  {
 213.588 -    p->range <<= 8;
 213.589 -    RangeEnc_ShiftLow(p);
 213.590 -  }
 213.591 -}
 213.592 -
 213.593 -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
 213.594 -{
 213.595 -  symbol |= 0x100;
 213.596 -  do
 213.597 -  {
 213.598 -    RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);
 213.599 -    symbol <<= 1;
 213.600 -  }
 213.601 -  while (symbol < 0x10000);
 213.602 -}
 213.603 -
 213.604 -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
 213.605 -{
 213.606 -  UInt32 offs = 0x100;
 213.607 -  symbol |= 0x100;
 213.608 -  do
 213.609 -  {
 213.610 -    matchByte <<= 1;
 213.611 -    RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
 213.612 -    symbol <<= 1;
 213.613 -    offs &= ~(matchByte ^ symbol);
 213.614 -  }
 213.615 -  while (symbol < 0x10000);
 213.616 -}
 213.617 -
 213.618 -void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
 213.619 -{
 213.620 -  UInt32 i;
 213.621 -  for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
 213.622 -  {
 213.623 -    const int kCyclesBits = kNumBitPriceShiftBits;
 213.624 -    UInt32 w = i;
 213.625 -    UInt32 bitCount = 0;
 213.626 -    int j;
 213.627 -    for (j = 0; j < kCyclesBits; j++)
 213.628 -    {
 213.629 -      w = w * w;
 213.630 -      bitCount <<= 1;
 213.631 -      while (w >= ((UInt32)1 << 16))
 213.632 -      {
 213.633 -        w >>= 1;
 213.634 -        bitCount++;
 213.635 -      }
 213.636 -    }
 213.637 -    ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount);
 213.638 -  }
 213.639 -}
 213.640 -
 213.641 -
 213.642 -#define GET_PRICE(prob, symbol) \
 213.643 -  p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
 213.644 -
 213.645 -#define GET_PRICEa(prob, symbol) \
 213.646 -  ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
 213.647 -
 213.648 -#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]
 213.649 -#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
 213.650 -
 213.651 -#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]
 213.652 -#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
 213.653 -
 213.654 -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices)
 213.655 -{
 213.656 -  UInt32 price = 0;
 213.657 -  symbol |= 0x100;
 213.658 -  do
 213.659 -  {
 213.660 -    price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);
 213.661 -    symbol <<= 1;
 213.662 -  }
 213.663 -  while (symbol < 0x10000);
 213.664 -  return price;
 213.665 -}
 213.666 -
 213.667 -static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices)
 213.668 -{
 213.669 -  UInt32 price = 0;
 213.670 -  UInt32 offs = 0x100;
 213.671 -  symbol |= 0x100;
 213.672 -  do
 213.673 -  {
 213.674 -    matchByte <<= 1;
 213.675 -    price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
 213.676 -    symbol <<= 1;
 213.677 -    offs &= ~(matchByte ^ symbol);
 213.678 -  }
 213.679 -  while (symbol < 0x10000);
 213.680 -  return price;
 213.681 -}
 213.682 -
 213.683 -
 213.684 -static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
 213.685 -{
 213.686 -  UInt32 m = 1;
 213.687 -  int i;
 213.688 -  for (i = numBitLevels; i != 0;)
 213.689 -  {
 213.690 -    UInt32 bit;
 213.691 -    i--;
 213.692 -    bit = (symbol >> i) & 1;
 213.693 -    RangeEnc_EncodeBit(rc, probs + m, bit);
 213.694 -    m = (m << 1) | bit;
 213.695 -  }
 213.696 -}
 213.697 -
 213.698 -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
 213.699 -{
 213.700 -  UInt32 m = 1;
 213.701 -  int i;
 213.702 -  for (i = 0; i < numBitLevels; i++)
 213.703 -  {
 213.704 -    UInt32 bit = symbol & 1;
 213.705 -    RangeEnc_EncodeBit(rc, probs + m, bit);
 213.706 -    m = (m << 1) | bit;
 213.707 -    symbol >>= 1;
 213.708 -  }
 213.709 -}
 213.710 -
 213.711 -static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
 213.712 -{
 213.713 -  UInt32 price = 0;
 213.714 -  symbol |= (1 << numBitLevels);
 213.715 -  while (symbol != 1)
 213.716 -  {
 213.717 -    price += GET_PRICEa(probs[symbol >> 1], symbol & 1);
 213.718 -    symbol >>= 1;
 213.719 -  }
 213.720 -  return price;
 213.721 -}
 213.722 -
 213.723 -static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
 213.724 -{
 213.725 -  UInt32 price = 0;
 213.726 -  UInt32 m = 1;
 213.727 -  int i;
 213.728 -  for (i = numBitLevels; i != 0; i--)
 213.729 -  {
 213.730 -    UInt32 bit = symbol & 1;
 213.731 -    symbol >>= 1;
 213.732 -    price += GET_PRICEa(probs[m], bit);
 213.733 -    m = (m << 1) | bit;
 213.734 -  }
 213.735 -  return price;
 213.736 -}
 213.737 -
 213.738 -
 213.739 -static void LenEnc_Init(CLenEnc *p)
 213.740 -{
 213.741 -  unsigned i;
 213.742 -  p->choice = p->choice2 = kProbInitValue;
 213.743 -  for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++)
 213.744 -    p->low[i] = kProbInitValue;
 213.745 -  for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++)
 213.746 -    p->mid[i] = kProbInitValue;
 213.747 -  for (i = 0; i < kLenNumHighSymbols; i++)
 213.748 -    p->high[i] = kProbInitValue;
 213.749 -}
 213.750 -
 213.751 -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)
 213.752 -{
 213.753 -  if (symbol < kLenNumLowSymbols)
 213.754 -  {
 213.755 -    RangeEnc_EncodeBit(rc, &p->choice, 0);
 213.756 -    RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol);
 213.757 -  }
 213.758 -  else
 213.759 -  {
 213.760 -    RangeEnc_EncodeBit(rc, &p->choice, 1);
 213.761 -    if (symbol < kLenNumLowSymbols + kLenNumMidSymbols)
 213.762 -    {
 213.763 -      RangeEnc_EncodeBit(rc, &p->choice2, 0);
 213.764 -      RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols);
 213.765 -    }
 213.766 -    else
 213.767 -    {
 213.768 -      RangeEnc_EncodeBit(rc, &p->choice2, 1);
 213.769 -      RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols);
 213.770 -    }
 213.771 -  }
 213.772 -}
 213.773 -
 213.774 -static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices)
 213.775 -{
 213.776 -  UInt32 a0 = GET_PRICE_0a(p->choice);
 213.777 -  UInt32 a1 = GET_PRICE_1a(p->choice);
 213.778 -  UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);
 213.779 -  UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);
 213.780 -  UInt32 i = 0;
 213.781 -  for (i = 0; i < kLenNumLowSymbols; i++)
 213.782 -  {
 213.783 -    if (i >= numSymbols)
 213.784 -      return;
 213.785 -    prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices);
 213.786 -  }
 213.787 -  for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++)
 213.788 -  {
 213.789 -    if (i >= numSymbols)
 213.790 -      return;
 213.791 -    prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices);
 213.792 -  }
 213.793 -  for (; i < numSymbols; i++)
 213.794 -    prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
 213.795 -}
 213.796 -
 213.797 -static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices)
 213.798 -{
 213.799 -  LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
 213.800 -  p->counters[posState] = p->tableSize;
 213.801 -}
 213.802 -
 213.803 -static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices)
 213.804 -{
 213.805 -  UInt32 posState;
 213.806 -  for (posState = 0; posState < numPosStates; posState++)
 213.807 -    LenPriceEnc_UpdateTable(p, posState, ProbPrices);
 213.808 -}
 213.809 -
 213.810 -static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
 213.811 -{
 213.812 -  LenEnc_Encode(&p->p, rc, symbol, posState);
 213.813 -  if (updatePrice)
 213.814 -    if (--p->counters[posState] == 0)
 213.815 -      LenPriceEnc_UpdateTable(p, posState, ProbPrices);
 213.816 -}
 213.817 -
 213.818 -
 213.819 -
 213.820 -
 213.821 -static void MovePos(CLzmaEnc *p, UInt32 num)
 213.822 -{
 213.823 -  #ifdef SHOW_STAT
 213.824 -  ttt += num;
 213.825 -  printf("\n MovePos %d", num);
 213.826 -  #endif
 213.827 -  if (num != 0)
 213.828 -  {
 213.829 -    p->additionalOffset += num;
 213.830 -    p->matchFinder.Skip(p->matchFinderObj, num);
 213.831 -  }
 213.832 -}
 213.833 -
 213.834 -static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
 213.835 -{
 213.836 -  UInt32 lenRes = 0, numPairs;
 213.837 -  p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
 213.838 -  numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
 213.839 -  #ifdef SHOW_STAT
 213.840 -  printf("\n i = %d numPairs = %d    ", ttt, numPairs / 2);
 213.841 -  ttt++;
 213.842 -  {
 213.843 -    UInt32 i;
 213.844 -    for (i = 0; i < numPairs; i += 2)
 213.845 -      printf("%2d %6d   | ", p->matches[i], p->matches[i + 1]);
 213.846 -  }
 213.847 -  #endif
 213.848 -  if (numPairs > 0)
 213.849 -  {
 213.850 -    lenRes = p->matches[numPairs - 2];
 213.851 -    if (lenRes == p->numFastBytes)
 213.852 -    {
 213.853 -      const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
 213.854 -      UInt32 distance = p->matches[numPairs - 1] + 1;
 213.855 -      UInt32 numAvail = p->numAvail;
 213.856 -      if (numAvail > LZMA_MATCH_LEN_MAX)
 213.857 -        numAvail = LZMA_MATCH_LEN_MAX;
 213.858 -      {
 213.859 -        const Byte *pby2 = pby - distance;
 213.860 -        for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
 213.861 -      }
 213.862 -    }
 213.863 -  }
 213.864 -  p->additionalOffset++;
 213.865 -  *numDistancePairsRes = numPairs;
 213.866 -  return lenRes;
 213.867 -}
 213.868 -
 213.869 -
 213.870 -#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
 213.871 -#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
 213.872 -#define IsShortRep(p) ((p)->backPrev == 0)
 213.873 -
 213.874 -static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)
 213.875 -{
 213.876 -  return
 213.877 -    GET_PRICE_0(p->isRepG0[state]) +
 213.878 -    GET_PRICE_0(p->isRep0Long[state][posState]);
 213.879 -}
 213.880 -
 213.881 -static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)
 213.882 -{
 213.883 -  UInt32 price;
 213.884 -  if (repIndex == 0)
 213.885 -  {
 213.886 -    price = GET_PRICE_0(p->isRepG0[state]);
 213.887 -    price += GET_PRICE_1(p->isRep0Long[state][posState]);
 213.888 -  }
 213.889 -  else
 213.890 -  {
 213.891 -    price = GET_PRICE_1(p->isRepG0[state]);
 213.892 -    if (repIndex == 1)
 213.893 -      price += GET_PRICE_0(p->isRepG1[state]);
 213.894 -    else
 213.895 -    {
 213.896 -      price += GET_PRICE_1(p->isRepG1[state]);
 213.897 -      price += GET_PRICE(p->isRepG2[state], repIndex - 2);
 213.898 -    }
 213.899 -  }
 213.900 -  return price;
 213.901 -}
 213.902 -
 213.903 -static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)
 213.904 -{
 213.905 -  return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
 213.906 -    GetPureRepPrice(p, repIndex, state, posState);
 213.907 -}
 213.908 -
 213.909 -static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
 213.910 -{
 213.911 -  UInt32 posMem = p->opt[cur].posPrev;
 213.912 -  UInt32 backMem = p->opt[cur].backPrev;
 213.913 -  p->optimumEndIndex = cur;
 213.914 -  do
 213.915 -  {
 213.916 -    if (p->opt[cur].prev1IsChar)
 213.917 -    {
 213.918 -      MakeAsChar(&p->opt[posMem])
 213.919 -      p->opt[posMem].posPrev = posMem - 1;
 213.920 -      if (p->opt[cur].prev2)
 213.921 -      {
 213.922 -        p->opt[posMem - 1].prev1IsChar = False;
 213.923 -        p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;
 213.924 -        p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;
 213.925 -      }
 213.926 -    }
 213.927 -    {
 213.928 -      UInt32 posPrev = posMem;
 213.929 -      UInt32 backCur = backMem;
 213.930 -      
 213.931 -      backMem = p->opt[posPrev].backPrev;
 213.932 -      posMem = p->opt[posPrev].posPrev;
 213.933 -      
 213.934 -      p->opt[posPrev].backPrev = backCur;
 213.935 -      p->opt[posPrev].posPrev = cur;
 213.936 -      cur = posPrev;
 213.937 -    }
 213.938 -  }
 213.939 -  while (cur != 0);
 213.940 -  *backRes = p->opt[0].backPrev;
 213.941 -  p->optimumCurrentIndex  = p->opt[0].posPrev;
 213.942 -  return p->optimumCurrentIndex;
 213.943 -}
 213.944 -
 213.945 -#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300)
 213.946 -
 213.947 -static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
 213.948 -{
 213.949 -  UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
 213.950 -  UInt32 matchPrice, repMatchPrice, normalMatchPrice;
 213.951 -  UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
 213.952 -  UInt32 *matches;
 213.953 -  const Byte *data;
 213.954 -  Byte curByte, matchByte;
 213.955 -  if (p->optimumEndIndex != p->optimumCurrentIndex)
 213.956 -  {
 213.957 -    const COptimal *opt = &p->opt[p->optimumCurrentIndex];
 213.958 -    UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;
 213.959 -    *backRes = opt->backPrev;
 213.960 -    p->optimumCurrentIndex = opt->posPrev;
 213.961 -    return lenRes;
 213.962 -  }
 213.963 -  p->optimumCurrentIndex = p->optimumEndIndex = 0;
 213.964 -  
 213.965 -  if (p->additionalOffset == 0)
 213.966 -    mainLen = ReadMatchDistances(p, &numPairs);
 213.967 -  else
 213.968 -  {
 213.969 -    mainLen = p->longestMatchLength;
 213.970 -    numPairs = p->numPairs;
 213.971 -  }
 213.972 -
 213.973 -  numAvail = p->numAvail;
 213.974 -  if (numAvail < 2)
 213.975 -  {
 213.976 -    *backRes = (UInt32)(-1);
 213.977 -    return 1;
 213.978 -  }
 213.979 -  if (numAvail > LZMA_MATCH_LEN_MAX)
 213.980 -    numAvail = LZMA_MATCH_LEN_MAX;
 213.981 -
 213.982 -  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
 213.983 -  repMaxIndex = 0;
 213.984 -  for (i = 0; i < LZMA_NUM_REPS; i++)
 213.985 -  {
 213.986 -    UInt32 lenTest;
 213.987 -    const Byte *data2;
 213.988 -    reps[i] = p->reps[i];
 213.989 -    data2 = data - (reps[i] + 1);
 213.990 -    if (data[0] != data2[0] || data[1] != data2[1])
 213.991 -    {
 213.992 -      repLens[i] = 0;
 213.993 -      continue;
 213.994 -    }
 213.995 -    for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
 213.996 -    repLens[i] = lenTest;
 213.997 -    if (lenTest > repLens[repMaxIndex])
 213.998 -      repMaxIndex = i;
 213.999 -  }
213.1000 -  if (repLens[repMaxIndex] >= p->numFastBytes)
213.1001 -  {
213.1002 -    UInt32 lenRes;
213.1003 -    *backRes = repMaxIndex;
213.1004 -    lenRes = repLens[repMaxIndex];
213.1005 -    MovePos(p, lenRes - 1);
213.1006 -    return lenRes;
213.1007 -  }
213.1008 -
213.1009 -  matches = p->matches;
213.1010 -  if (mainLen >= p->numFastBytes)
213.1011 -  {
213.1012 -    *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
213.1013 -    MovePos(p, mainLen - 1);
213.1014 -    return mainLen;
213.1015 -  }
213.1016 -  curByte = *data;
213.1017 -  matchByte = *(data - (reps[0] + 1));
213.1018 -
213.1019 -  if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)
213.1020 -  {
213.1021 -    *backRes = (UInt32)-1;
213.1022 -    return 1;
213.1023 -  }
213.1024 -
213.1025 -  p->opt[0].state = (CState)p->state;
213.1026 -
213.1027 -  posState = (position & p->pbMask);
213.1028 -
213.1029 -  {
213.1030 -    const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
213.1031 -    p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +
213.1032 -        (!IsCharState(p->state) ?
213.1033 -          LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
213.1034 -          LitEnc_GetPrice(probs, curByte, p->ProbPrices));
213.1035 -  }
213.1036 -
213.1037 -  MakeAsChar(&p->opt[1]);
213.1038 -
213.1039 -  matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);
213.1040 -  repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);
213.1041 -
213.1042 -  if (matchByte == curByte)
213.1043 -  {
213.1044 -    UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
213.1045 -    if (shortRepPrice < p->opt[1].price)
213.1046 -    {
213.1047 -      p->opt[1].price = shortRepPrice;
213.1048 -      MakeAsShortRep(&p->opt[1]);
213.1049 -    }
213.1050 -  }
213.1051 -  lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]);
213.1052 -
213.1053 -  if (lenEnd < 2)
213.1054 -  {
213.1055 -    *backRes = p->opt[1].backPrev;
213.1056 -    return 1;
213.1057 -  }
213.1058 -
213.1059 -  p->opt[1].posPrev = 0;
213.1060 -  for (i = 0; i < LZMA_NUM_REPS; i++)
213.1061 -    p->opt[0].backs[i] = reps[i];
213.1062 -
213.1063 -  len = lenEnd;
213.1064 -  do
213.1065 -    p->opt[len--].price = kInfinityPrice;
213.1066 -  while (len >= 2);
213.1067 -
213.1068 -  for (i = 0; i < LZMA_NUM_REPS; i++)
213.1069 -  {
213.1070 -    UInt32 repLen = repLens[i];
213.1071 -    UInt32 price;
213.1072 -    if (repLen < 2)
213.1073 -      continue;
213.1074 -    price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);
213.1075 -    do
213.1076 -    {
213.1077 -      UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
213.1078 -      COptimal *opt = &p->opt[repLen];
213.1079 -      if (curAndLenPrice < opt->price)
213.1080 -      {
213.1081 -        opt->price = curAndLenPrice;
213.1082 -        opt->posPrev = 0;
213.1083 -        opt->backPrev = i;
213.1084 -        opt->prev1IsChar = False;
213.1085 -      }
213.1086 -    }
213.1087 -    while (--repLen >= 2);
213.1088 -  }
213.1089 -
213.1090 -  normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);
213.1091 -
213.1092 -  len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
213.1093 -  if (len <= mainLen)
213.1094 -  {
213.1095 -    UInt32 offs = 0;
213.1096 -    while (len > matches[offs])
213.1097 -      offs += 2;
213.1098 -    for (; ; len++)
213.1099 -    {
213.1100 -      COptimal *opt;
213.1101 -      UInt32 distance = matches[offs + 1];
213.1102 -
213.1103 -      UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
213.1104 -      UInt32 lenToPosState = GetLenToPosState(len);
213.1105 -      if (distance < kNumFullDistances)
213.1106 -        curAndLenPrice += p->distancesPrices[lenToPosState][distance];
213.1107 -      else
213.1108 -      {
213.1109 -        UInt32 slot;
213.1110 -        GetPosSlot2(distance, slot);
213.1111 -        curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];
213.1112 -      }
213.1113 -      opt = &p->opt[len];
213.1114 -      if (curAndLenPrice < opt->price)
213.1115 -      {
213.1116 -        opt->price = curAndLenPrice;
213.1117 -        opt->posPrev = 0;
213.1118 -        opt->backPrev = distance + LZMA_NUM_REPS;
213.1119 -        opt->prev1IsChar = False;
213.1120 -      }
213.1121 -      if (len == matches[offs])
213.1122 -      {
213.1123 -        offs += 2;
213.1124 -        if (offs == numPairs)
213.1125 -          break;
213.1126 -      }
213.1127 -    }
213.1128 -  }
213.1129 -
213.1130 -  cur = 0;
213.1131 -
213.1132 -    #ifdef SHOW_STAT2
213.1133 -    if (position >= 0)
213.1134 -    {
213.1135 -      unsigned i;
213.1136 -      printf("\n pos = %4X", position);
213.1137 -      for (i = cur; i <= lenEnd; i++)
213.1138 -      printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
213.1139 -    }
213.1140 -    #endif
213.1141 -
213.1142 -  for (;;)
213.1143 -  {
213.1144 -    UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
213.1145 -    UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
213.1146 -    Bool nextIsChar;
213.1147 -    Byte curByte, matchByte;
213.1148 -    const Byte *data;
213.1149 -    COptimal *curOpt;
213.1150 -    COptimal *nextOpt;
213.1151 -
213.1152 -    cur++;
213.1153 -    if (cur == lenEnd)
213.1154 -      return Backward(p, backRes, cur);
213.1155 -
213.1156 -    newLen = ReadMatchDistances(p, &numPairs);
213.1157 -    if (newLen >= p->numFastBytes)
213.1158 -    {
213.1159 -      p->numPairs = numPairs;
213.1160 -      p->longestMatchLength = newLen;
213.1161 -      return Backward(p, backRes, cur);
213.1162 -    }
213.1163 -    position++;
213.1164 -    curOpt = &p->opt[cur];
213.1165 -    posPrev = curOpt->posPrev;
213.1166 -    if (curOpt->prev1IsChar)
213.1167 -    {
213.1168 -      posPrev--;
213.1169 -      if (curOpt->prev2)
213.1170 -      {
213.1171 -        state = p->opt[curOpt->posPrev2].state;
213.1172 -        if (curOpt->backPrev2 < LZMA_NUM_REPS)
213.1173 -          state = kRepNextStates[state];
213.1174 -        else
213.1175 -          state = kMatchNextStates[state];
213.1176 -      }
213.1177 -      else
213.1178 -        state = p->opt[posPrev].state;
213.1179 -      state = kLiteralNextStates[state];
213.1180 -    }
213.1181 -    else
213.1182 -      state = p->opt[posPrev].state;
213.1183 -    if (posPrev == cur - 1)
213.1184 -    {
213.1185 -      if (IsShortRep(curOpt))
213.1186 -        state = kShortRepNextStates[state];
213.1187 -      else
213.1188 -        state = kLiteralNextStates[state];
213.1189 -    }
213.1190 -    else
213.1191 -    {
213.1192 -      UInt32 pos;
213.1193 -      const COptimal *prevOpt;
213.1194 -      if (curOpt->prev1IsChar && curOpt->prev2)
213.1195 -      {
213.1196 -        posPrev = curOpt->posPrev2;
213.1197 -        pos = curOpt->backPrev2;
213.1198 -        state = kRepNextStates[state];
213.1199 -      }
213.1200 -      else
213.1201 -      {
213.1202 -        pos = curOpt->backPrev;
213.1203 -        if (pos < LZMA_NUM_REPS)
213.1204 -          state = kRepNextStates[state];
213.1205 -        else
213.1206 -          state = kMatchNextStates[state];
213.1207 -      }
213.1208 -      prevOpt = &p->opt[posPrev];
213.1209 -      if (pos < LZMA_NUM_REPS)
213.1210 -      {
213.1211 -        UInt32 i;
213.1212 -        reps[0] = prevOpt->backs[pos];
213.1213 -        for (i = 1; i <= pos; i++)
213.1214 -          reps[i] = prevOpt->backs[i - 1];
213.1215 -        for (; i < LZMA_NUM_REPS; i++)
213.1216 -          reps[i] = prevOpt->backs[i];
213.1217 -      }
213.1218 -      else
213.1219 -      {
213.1220 -        UInt32 i;
213.1221 -        reps[0] = (pos - LZMA_NUM_REPS);
213.1222 -        for (i = 1; i < LZMA_NUM_REPS; i++)
213.1223 -          reps[i] = prevOpt->backs[i - 1];
213.1224 -      }
213.1225 -    }
213.1226 -    curOpt->state = (CState)state;
213.1227 -
213.1228 -    curOpt->backs[0] = reps[0];
213.1229 -    curOpt->backs[1] = reps[1];
213.1230 -    curOpt->backs[2] = reps[2];
213.1231 -    curOpt->backs[3] = reps[3];
213.1232 -
213.1233 -    curPrice = curOpt->price;
213.1234 -    nextIsChar = False;
213.1235 -    data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
213.1236 -    curByte = *data;
213.1237 -    matchByte = *(data - (reps[0] + 1));
213.1238 -
213.1239 -    posState = (position & p->pbMask);
213.1240 -
213.1241 -    curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]);
213.1242 -    {
213.1243 -      const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
213.1244 -      curAnd1Price +=
213.1245 -        (!IsCharState(state) ?
213.1246 -          LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
213.1247 -          LitEnc_GetPrice(probs, curByte, p->ProbPrices));
213.1248 -    }
213.1249 -
213.1250 -    nextOpt = &p->opt[cur + 1];
213.1251 -
213.1252 -    if (curAnd1Price < nextOpt->price)
213.1253 -    {
213.1254 -      nextOpt->price = curAnd1Price;
213.1255 -      nextOpt->posPrev = cur;
213.1256 -      MakeAsChar(nextOpt);
213.1257 -      nextIsChar = True;
213.1258 -    }
213.1259 -
213.1260 -    matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
213.1261 -    repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
213.1262 -    
213.1263 -    if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
213.1264 -    {
213.1265 -      UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
213.1266 -      if (shortRepPrice <= nextOpt->price)
213.1267 -      {
213.1268 -        nextOpt->price = shortRepPrice;
213.1269 -        nextOpt->posPrev = cur;
213.1270 -        MakeAsShortRep(nextOpt);
213.1271 -        nextIsChar = True;
213.1272 -      }
213.1273 -    }
213.1274 -    numAvailFull = p->numAvail;
213.1275 -    {
213.1276 -      UInt32 temp = kNumOpts - 1 - cur;
213.1277 -      if (temp < numAvailFull)
213.1278 -        numAvailFull = temp;
213.1279 -    }
213.1280 -
213.1281 -    if (numAvailFull < 2)
213.1282 -      continue;
213.1283 -    numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes);
213.1284 -
213.1285 -    if (!nextIsChar && matchByte != curByte) /* speed optimization */
213.1286 -    {
213.1287 -      /* try Literal + rep0 */
213.1288 -      UInt32 temp;
213.1289 -      UInt32 lenTest2;
213.1290 -      const Byte *data2 = data - (reps[0] + 1);
213.1291 -      UInt32 limit = p->numFastBytes + 1;
213.1292 -      if (limit > numAvailFull)
213.1293 -        limit = numAvailFull;
213.1294 -
213.1295 -      for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
213.1296 -      lenTest2 = temp - 1;
213.1297 -      if (lenTest2 >= 2)
213.1298 -      {
213.1299 -        UInt32 state2 = kLiteralNextStates[state];
213.1300 -        UInt32 posStateNext = (position + 1) & p->pbMask;
213.1301 -        UInt32 nextRepMatchPrice = curAnd1Price +
213.1302 -            GET_PRICE_1(p->isMatch[state2][posStateNext]) +
213.1303 -            GET_PRICE_1(p->isRep[state2]);
213.1304 -        /* for (; lenTest2 >= 2; lenTest2--) */
213.1305 -        {
213.1306 -          UInt32 curAndLenPrice;
213.1307 -          COptimal *opt;
213.1308 -          UInt32 offset = cur + 1 + lenTest2;
213.1309 -          while (lenEnd < offset)
213.1310 -            p->opt[++lenEnd].price = kInfinityPrice;
213.1311 -          curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
213.1312 -          opt = &p->opt[offset];
213.1313 -          if (curAndLenPrice < opt->price)
213.1314 -          {
213.1315 -            opt->price = curAndLenPrice;
213.1316 -            opt->posPrev = cur + 1;
213.1317 -            opt->backPrev = 0;
213.1318 -            opt->prev1IsChar = True;
213.1319 -            opt->prev2 = False;
213.1320 -          }
213.1321 -        }
213.1322 -      }
213.1323 -    }
213.1324 -    
213.1325 -    startLen = 2; /* speed optimization */
213.1326 -    {
213.1327 -    UInt32 repIndex;
213.1328 -    for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)
213.1329 -    {
213.1330 -      UInt32 lenTest;
213.1331 -      UInt32 lenTestTemp;
213.1332 -      UInt32 price;
213.1333 -      const Byte *data2 = data - (reps[repIndex] + 1);
213.1334 -      if (data[0] != data2[0] || data[1] != data2[1])
213.1335 -        continue;
213.1336 -      for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
213.1337 -      while (lenEnd < cur + lenTest)
213.1338 -        p->opt[++lenEnd].price = kInfinityPrice;
213.1339 -      lenTestTemp = lenTest;
213.1340 -      price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);
213.1341 -      do
213.1342 -      {
213.1343 -        UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
213.1344 -        COptimal *opt = &p->opt[cur + lenTest];
213.1345 -        if (curAndLenPrice < opt->price)
213.1346 -        {
213.1347 -          opt->price = curAndLenPrice;
213.1348 -          opt->posPrev = cur;
213.1349 -          opt->backPrev = repIndex;
213.1350 -          opt->prev1IsChar = False;
213.1351 -        }
213.1352 -      }
213.1353 -      while (--lenTest >= 2);
213.1354 -      lenTest = lenTestTemp;
213.1355 -      
213.1356 -      if (repIndex == 0)
213.1357 -        startLen = lenTest + 1;
213.1358 -        
213.1359 -      /* if (_maxMode) */
213.1360 -        {
213.1361 -          UInt32 lenTest2 = lenTest + 1;
213.1362 -          UInt32 limit = lenTest2 + p->numFastBytes;
213.1363 -          UInt32 nextRepMatchPrice;
213.1364 -          if (limit > numAvailFull)
213.1365 -            limit = numAvailFull;
213.1366 -          for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
213.1367 -          lenTest2 -= lenTest + 1;
213.1368 -          if (lenTest2 >= 2)
213.1369 -          {
213.1370 -            UInt32 state2 = kRepNextStates[state];
213.1371 -            UInt32 posStateNext = (position + lenTest) & p->pbMask;
213.1372 -            UInt32 curAndLenCharPrice =
213.1373 -                price + p->repLenEnc.prices[posState][lenTest - 2] +
213.1374 -                GET_PRICE_0(p->isMatch[state2][posStateNext]) +
213.1375 -                LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
213.1376 -                    data[lenTest], data2[lenTest], p->ProbPrices);
213.1377 -            state2 = kLiteralNextStates[state2];
213.1378 -            posStateNext = (position + lenTest + 1) & p->pbMask;
213.1379 -            nextRepMatchPrice = curAndLenCharPrice +
213.1380 -                GET_PRICE_1(p->isMatch[state2][posStateNext]) +
213.1381 -                GET_PRICE_1(p->isRep[state2]);
213.1382 -            
213.1383 -            /* for (; lenTest2 >= 2; lenTest2--) */
213.1384 -            {
213.1385 -              UInt32 curAndLenPrice;
213.1386 -              COptimal *opt;
213.1387 -              UInt32 offset = cur + lenTest + 1 + lenTest2;
213.1388 -              while (lenEnd < offset)
213.1389 -                p->opt[++lenEnd].price = kInfinityPrice;
213.1390 -              curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
213.1391 -              opt = &p->opt[offset];
213.1392 -              if (curAndLenPrice < opt->price)
213.1393 -              {
213.1394 -                opt->price = curAndLenPrice;
213.1395 -                opt->posPrev = cur + lenTest + 1;
213.1396 -                opt->backPrev = 0;
213.1397 -                opt->prev1IsChar = True;
213.1398 -                opt->prev2 = True;
213.1399 -                opt->posPrev2 = cur;
213.1400 -                opt->backPrev2 = repIndex;
213.1401 -              }
213.1402 -            }
213.1403 -          }
213.1404 -        }
213.1405 -    }
213.1406 -    }
213.1407 -    /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
213.1408 -    if (newLen > numAvail)
213.1409 -    {
213.1410 -      newLen = numAvail;
213.1411 -      for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2);
213.1412 -      matches[numPairs] = newLen;
213.1413 -      numPairs += 2;
213.1414 -    }
213.1415 -    if (newLen >= startLen)
213.1416 -    {
213.1417 -      UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
213.1418 -      UInt32 offs, curBack, posSlot;
213.1419 -      UInt32 lenTest;
213.1420 -      while (lenEnd < cur + newLen)
213.1421 -        p->opt[++lenEnd].price = kInfinityPrice;
213.1422 -
213.1423 -      offs = 0;
213.1424 -      while (startLen > matches[offs])
213.1425 -        offs += 2;
213.1426 -      curBack = matches[offs + 1];
213.1427 -      GetPosSlot2(curBack, posSlot);
213.1428 -      for (lenTest = /*2*/ startLen; ; lenTest++)
213.1429 -      {
213.1430 -        UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
213.1431 -        UInt32 lenToPosState = GetLenToPosState(lenTest);
213.1432 -        COptimal *opt;
213.1433 -        if (curBack < kNumFullDistances)
213.1434 -          curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
213.1435 -        else
213.1436 -          curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
213.1437 -        
213.1438 -        opt = &p->opt[cur + lenTest];
213.1439 -        if (curAndLenPrice < opt->price)
213.1440 -        {
213.1441 -          opt->price = curAndLenPrice;
213.1442 -          opt->posPrev = cur;
213.1443 -          opt->backPrev = curBack + LZMA_NUM_REPS;
213.1444 -          opt->prev1IsChar = False;
213.1445 -        }
213.1446 -
213.1447 -        if (/*_maxMode && */lenTest == matches[offs])
213.1448 -        {
213.1449 -          /* Try Match + Literal + Rep0 */
213.1450 -          const Byte *data2 = data - (curBack + 1);
213.1451 -          UInt32 lenTest2 = lenTest + 1;
213.1452 -          UInt32 limit = lenTest2 + p->numFastBytes;
213.1453 -          UInt32 nextRepMatchPrice;
213.1454 -          if (limit > numAvailFull)
213.1455 -            limit = numAvailFull;
213.1456 -          for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
213.1457 -          lenTest2 -= lenTest + 1;
213.1458 -          if (lenTest2 >= 2)
213.1459 -          {
213.1460 -            UInt32 state2 = kMatchNextStates[state];
213.1461 -            UInt32 posStateNext = (position + lenTest) & p->pbMask;
213.1462 -            UInt32 curAndLenCharPrice = curAndLenPrice +
213.1463 -                GET_PRICE_0(p->isMatch[state2][posStateNext]) +
213.1464 -                LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
213.1465 -                    data[lenTest], data2[lenTest], p->ProbPrices);
213.1466 -            state2 = kLiteralNextStates[state2];
213.1467 -            posStateNext = (posStateNext + 1) & p->pbMask;
213.1468 -            nextRepMatchPrice = curAndLenCharPrice +
213.1469 -                GET_PRICE_1(p->isMatch[state2][posStateNext]) +
213.1470 -                GET_PRICE_1(p->isRep[state2]);
213.1471 -            
213.1472 -            /* for (; lenTest2 >= 2; lenTest2--) */
213.1473 -            {
213.1474 -              UInt32 offset = cur + lenTest + 1 + lenTest2;
213.1475 -              UInt32 curAndLenPrice;
213.1476 -              COptimal *opt;
213.1477 -              while (lenEnd < offset)
213.1478 -                p->opt[++lenEnd].price = kInfinityPrice;
213.1479 -              curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
213.1480 -              opt = &p->opt[offset];
213.1481 -              if (curAndLenPrice < opt->price)
213.1482 -              {
213.1483 -                opt->price = curAndLenPrice;
213.1484 -                opt->posPrev = cur + lenTest + 1;
213.1485 -                opt->backPrev = 0;
213.1486 -                opt->prev1IsChar = True;
213.1487 -                opt->prev2 = True;
213.1488 -                opt->posPrev2 = cur;
213.1489 -                opt->backPrev2 = curBack + LZMA_NUM_REPS;
213.1490 -              }
213.1491 -            }
213.1492 -          }
213.1493 -          offs += 2;
213.1494 -          if (offs == numPairs)
213.1495 -            break;
213.1496 -          curBack = matches[offs + 1];
213.1497 -          if (curBack >= kNumFullDistances)
213.1498 -            GetPosSlot2(curBack, posSlot);
213.1499 -        }
213.1500 -      }
213.1501 -    }
213.1502 -  }
213.1503 -}
213.1504 -
213.1505 -#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
213.1506 -
213.1507 -static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
213.1508 -{
213.1509 -  UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
213.1510 -  const Byte *data;
213.1511 -  const UInt32 *matches;
213.1512 -
213.1513 -  if (p->additionalOffset == 0)
213.1514 -    mainLen = ReadMatchDistances(p, &numPairs);
213.1515 -  else
213.1516 -  {
213.1517 -    mainLen = p->longestMatchLength;
213.1518 -    numPairs = p->numPairs;
213.1519 -  }
213.1520 -
213.1521 -  numAvail = p->numAvail;
213.1522 -  *backRes = (UInt32)-1;
213.1523 -  if (numAvail < 2)
213.1524 -    return 1;
213.1525 -  if (numAvail > LZMA_MATCH_LEN_MAX)
213.1526 -    numAvail = LZMA_MATCH_LEN_MAX;
213.1527 -  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
213.1528 -
213.1529 -  repLen = repIndex = 0;
213.1530 -  for (i = 0; i < LZMA_NUM_REPS; i++)
213.1531 -  {
213.1532 -    UInt32 len;
213.1533 -    const Byte *data2 = data - (p->reps[i] + 1);
213.1534 -    if (data[0] != data2[0] || data[1] != data2[1])
213.1535 -      continue;
213.1536 -    for (len = 2; len < numAvail && data[len] == data2[len]; len++);
213.1537 -    if (len >= p->numFastBytes)
213.1538 -    {
213.1539 -      *backRes = i;
213.1540 -      MovePos(p, len - 1);
213.1541 -      return len;
213.1542 -    }
213.1543 -    if (len > repLen)
213.1544 -    {
213.1545 -      repIndex = i;
213.1546 -      repLen = len;
213.1547 -    }
213.1548 -  }
213.1549 -
213.1550 -  matches = p->matches;
213.1551 -  if (mainLen >= p->numFastBytes)
213.1552 -  {
213.1553 -    *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
213.1554 -    MovePos(p, mainLen - 1);
213.1555 -    return mainLen;
213.1556 -  }
213.1557 -
213.1558 -  mainDist = 0; /* for GCC */
213.1559 -  if (mainLen >= 2)
213.1560 -  {
213.1561 -    mainDist = matches[numPairs - 1];
213.1562 -    while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1)
213.1563 -    {
213.1564 -      if (!ChangePair(matches[numPairs - 3], mainDist))
213.1565 -        break;
213.1566 -      numPairs -= 2;
213.1567 -      mainLen = matches[numPairs - 2];
213.1568 -      mainDist = matches[numPairs - 1];
213.1569 -    }
213.1570 -    if (mainLen == 2 && mainDist >= 0x80)
213.1571 -      mainLen = 1;
213.1572 -  }
213.1573 -
213.1574 -  if (repLen >= 2 && (
213.1575 -        (repLen + 1 >= mainLen) ||
213.1576 -        (repLen + 2 >= mainLen && mainDist >= (1 << 9)) ||
213.1577 -        (repLen + 3 >= mainLen && mainDist >= (1 << 15))))
213.1578 -  {
213.1579 -    *backRes = repIndex;
213.1580 -    MovePos(p, repLen - 1);
213.1581 -    return repLen;
213.1582 -  }
213.1583 -  
213.1584 -  if (mainLen < 2 || numAvail <= 2)
213.1585 -    return 1;
213.1586 -
213.1587 -  p->longestMatchLength = ReadMatchDistances(p, &p->numPairs);
213.1588 -  if (p->longestMatchLength >= 2)
213.1589 -  {
213.1590 -    UInt32 newDistance = matches[p->numPairs - 1];
213.1591 -    if ((p->longestMatchLength >= mainLen && newDistance < mainDist) ||
213.1592 -        (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) ||
213.1593 -        (p->longestMatchLength > mainLen + 1) ||
213.1594 -        (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))
213.1595 -      return 1;
213.1596 -  }
213.1597 -  
213.1598 -  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
213.1599 -  for (i = 0; i < LZMA_NUM_REPS; i++)
213.1600 -  {
213.1601 -    UInt32 len, limit;
213.1602 -    const Byte *data2 = data - (p->reps[i] + 1);
213.1603 -    if (data[0] != data2[0] || data[1] != data2[1])
213.1604 -      continue;
213.1605 -    limit = mainLen - 1;
213.1606 -    for (len = 2; len < limit && data[len] == data2[len]; len++);
213.1607 -    if (len >= limit)
213.1608 -      return 1;
213.1609 -  }
213.1610 -  *backRes = mainDist + LZMA_NUM_REPS;
213.1611 -  MovePos(p, mainLen - 2);
213.1612 -  return mainLen;
213.1613 -}
213.1614 -
213.1615 -static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)
213.1616 -{
213.1617 -  UInt32 len;
213.1618 -  RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
213.1619 -  RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
213.1620 -  p->state = kMatchNextStates[p->state];
213.1621 -  len = LZMA_MATCH_LEN_MIN;
213.1622 -  LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
213.1623 -  RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);
213.1624 -  RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
213.1625 -  RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
213.1626 -}
213.1627 -
213.1628 -static SRes CheckErrors(CLzmaEnc *p)
213.1629 -{
213.1630 -  if (p->result != SZ_OK)
213.1631 -    return p->result;
213.1632 -  if (p->rc.res != SZ_OK)
213.1633 -    p->result = SZ_ERROR_WRITE;
213.1634 -  if (p->matchFinderBase.result != SZ_OK)
213.1635 -    p->result = SZ_ERROR_READ;
213.1636 -  if (p->result != SZ_OK)
213.1637 -    p->finished = True;
213.1638 -  return p->result;
213.1639 -}
213.1640 -
213.1641 -static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
213.1642 -{
213.1643 -  /* ReleaseMFStream(); */
213.1644 -  p->finished = True;
213.1645 -  if (p->writeEndMark)
213.1646 -    WriteEndMarker(p, nowPos & p->pbMask);
213.1647 -  RangeEnc_FlushData(&p->rc);
213.1648 -  RangeEnc_FlushStream(&p->rc);
213.1649 -  return CheckErrors(p);
213.1650 -}
213.1651 -
213.1652 -static void FillAlignPrices(CLzmaEnc *p)
213.1653 -{
213.1654 -  UInt32 i;
213.1655 -  for (i = 0; i < kAlignTableSize; i++)
213.1656 -    p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);
213.1657 -  p->alignPriceCount = 0;
213.1658 -}
213.1659 -
213.1660 -static void FillDistancesPrices(CLzmaEnc *p)
213.1661 -{
213.1662 -  UInt32 tempPrices[kNumFullDistances];
213.1663 -  UInt32 i, lenToPosState;
213.1664 -  for (i = kStartPosModelIndex; i < kNumFullDistances; i++)
213.1665 -  {
213.1666 -    UInt32 posSlot = GetPosSlot1(i);
213.1667 -    UInt32 footerBits = ((posSlot >> 1) - 1);
213.1668 -    UInt32 base = ((2 | (posSlot & 1)) << footerBits);
213.1669 -    tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);
213.1670 -  }
213.1671 -
213.1672 -  for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
213.1673 -  {
213.1674 -    UInt32 posSlot;
213.1675 -    const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];
213.1676 -    UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];
213.1677 -    for (posSlot = 0; posSlot < p->distTableSize; posSlot++)
213.1678 -      posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);
213.1679 -    for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)
213.1680 -      posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);
213.1681 -
213.1682 -    {
213.1683 -      UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
213.1684 -      UInt32 i;
213.1685 -      for (i = 0; i < kStartPosModelIndex; i++)
213.1686 -        distancesPrices[i] = posSlotPrices[i];
213.1687 -      for (; i < kNumFullDistances; i++)
213.1688 -        distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i];
213.1689 -    }
213.1690 -  }
213.1691 -  p->matchPriceCount = 0;
213.1692 -}
213.1693 -
213.1694 -void LzmaEnc_Construct(CLzmaEnc *p)
213.1695 -{
213.1696 -  RangeEnc_Construct(&p->rc);
213.1697 -  MatchFinder_Construct(&p->matchFinderBase);
213.1698 -  #ifdef COMPRESS_MF_MT
213.1699 -  MatchFinderMt_Construct(&p->matchFinderMt);
213.1700 -  p->matchFinderMt.MatchFinder = &p->matchFinderBase;
213.1701 -  #endif
213.1702 -
213.1703 -  {
213.1704 -    CLzmaEncProps props;
213.1705 -    LzmaEncProps_Init(&props);
213.1706 -    LzmaEnc_SetProps(p, &props);
213.1707 -  }
213.1708 -
213.1709 -  #ifndef LZMA_LOG_BSR
213.1710 -  LzmaEnc_FastPosInit(p->g_FastPos);
213.1711 -  #endif
213.1712 -
213.1713 -  LzmaEnc_InitPriceTables(p->ProbPrices);
213.1714 -  p->litProbs = 0;
213.1715 -  p->saveState.litProbs = 0;
213.1716 -}
213.1717 -
213.1718 -CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
213.1719 -{
213.1720 -  void *p;
213.1721 -  p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
213.1722 -  if (p != 0)
213.1723 -    LzmaEnc_Construct((CLzmaEnc *)p);
213.1724 -  return p;
213.1725 -}
213.1726 -
213.1727 -void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
213.1728 -{
213.1729 -  alloc->Free(alloc, p->litProbs);
213.1730 -  alloc->Free(alloc, p->saveState.litProbs);
213.1731 -  p->litProbs = 0;
213.1732 -  p->saveState.litProbs = 0;
213.1733 -}
213.1734 -
213.1735 -void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
213.1736 -{
213.1737 -  #ifdef COMPRESS_MF_MT
213.1738 -  MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
213.1739 -  #endif
213.1740 -  MatchFinder_Free(&p->matchFinderBase, allocBig);
213.1741 -  LzmaEnc_FreeLits(p, alloc);
213.1742 -  RangeEnc_Free(&p->rc, alloc);
213.1743 -}
213.1744 -
213.1745 -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
213.1746 -{
213.1747 -  LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);
213.1748 -  alloc->Free(alloc, p);
213.1749 -}
213.1750 -
213.1751 -static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
213.1752 -{
213.1753 -  UInt32 nowPos32, startPos32;
213.1754 -  if (p->inStream != 0)
213.1755 -  {
213.1756 -    p->matchFinderBase.stream = p->inStream;
213.1757 -    p->matchFinder.Init(p->matchFinderObj);
213.1758 -    p->inStream = 0;
213.1759 -  }
213.1760 -
213.1761 -  if (p->finished)
213.1762 -    return p->result;
213.1763 -  RINOK(CheckErrors(p));
213.1764 -
213.1765 -  nowPos32 = (UInt32)p->nowPos64;
213.1766 -  startPos32 = nowPos32;
213.1767 -
213.1768 -  if (p->nowPos64 == 0)
213.1769 -  {
213.1770 -    UInt32 numPairs;
213.1771 -    Byte curByte;
213.1772 -    if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
213.1773 -      return Flush(p, nowPos32);
213.1774 -    ReadMatchDistances(p, &numPairs);
213.1775 -    RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);
213.1776 -    p->state = kLiteralNextStates[p->state];
213.1777 -    curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
213.1778 -    LitEnc_Encode(&p->rc, p->litProbs, curByte);
213.1779 -    p->additionalOffset--;
213.1780 -    nowPos32++;
213.1781 -  }
213.1782 -
213.1783 -  if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)
213.1784 -  for (;;)
213.1785 -  {
213.1786 -    UInt32 pos, len, posState;
213.1787 -
213.1788 -    if (p->fastMode)
213.1789 -      len = GetOptimumFast(p, &pos);
213.1790 -    else
213.1791 -      len = GetOptimum(p, nowPos32, &pos);
213.1792 -
213.1793 -    #ifdef SHOW_STAT2
213.1794 -    printf("\n pos = %4X,   len = %d   pos = %d", nowPos32, len, pos);
213.1795 -    #endif
213.1796 -
213.1797 -    posState = nowPos32 & p->pbMask;
213.1798 -    if (len == 1 && pos == (UInt32)-1)
213.1799 -    {
213.1800 -      Byte curByte;
213.1801 -      CLzmaProb *probs;
213.1802 -      const Byte *data;
213.1803 -
213.1804 -      RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);
213.1805 -      data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
213.1806 -      curByte = *data;
213.1807 -      probs = LIT_PROBS(nowPos32, *(data - 1));
213.1808 -      if (IsCharState(p->state))
213.1809 -        LitEnc_Encode(&p->rc, probs, curByte);
213.1810 -      else
213.1811 -        LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));
213.1812 -      p->state = kLiteralNextStates[p->state];
213.1813 -    }
213.1814 -    else
213.1815 -    {
213.1816 -      RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
213.1817 -      if (pos < LZMA_NUM_REPS)
213.1818 -      {
213.1819 -        RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1);
213.1820 -        if (pos == 0)
213.1821 -        {
213.1822 -          RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0);
213.1823 -          RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1));
213.1824 -        }
213.1825 -        else
213.1826 -        {
213.1827 -          UInt32 distance = p->reps[pos];
213.1828 -          RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);
213.1829 -          if (pos == 1)
213.1830 -            RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);
213.1831 -          else
213.1832 -          {
213.1833 -            RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1);
213.1834 -            RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2);
213.1835 -            if (pos == 3)
213.1836 -              p->reps[3] = p->reps[2];
213.1837 -            p->reps[2] = p->reps[1];
213.1838 -          }
213.1839 -          p->reps[1] = p->reps[0];
213.1840 -          p->reps[0] = distance;
213.1841 -        }
213.1842 -        if (len == 1)
213.1843 -          p->state = kShortRepNextStates[p->state];
213.1844 -        else
213.1845 -        {
213.1846 -          LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
213.1847 -          p->state = kRepNextStates[p->state];
213.1848 -        }
213.1849 -      }
213.1850 -      else
213.1851 -      {
213.1852 -        UInt32 posSlot;
213.1853 -        RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
213.1854 -        p->state = kMatchNextStates[p->state];
213.1855 -        LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
213.1856 -        pos -= LZMA_NUM_REPS;
213.1857 -        GetPosSlot(pos, posSlot);
213.1858 -        RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
213.1859 -        
213.1860 -        if (posSlot >= kStartPosModelIndex)
213.1861 -        {
213.1862 -          UInt32 footerBits = ((posSlot >> 1) - 1);
213.1863 -          UInt32 base = ((2 | (posSlot & 1)) << footerBits);
213.1864 -          UInt32 posReduced = pos - base;
213.1865 -
213.1866 -          if (posSlot < kEndPosModelIndex)
213.1867 -            RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);
213.1868 -          else
213.1869 -          {
213.1870 -            RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
213.1871 -            RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask);
213.1872 -            p->alignPriceCount++;
213.1873 -          }
213.1874 -        }
213.1875 -        p->reps[3] = p->reps[2];
213.1876 -        p->reps[2] = p->reps[1];
213.1877 -        p->reps[1] = p->reps[0];
213.1878 -        p->reps[0] = pos;
213.1879 -        p->matchPriceCount++;
213.1880 -      }
213.1881 -    }
213.1882 -    p->additionalOffset -= len;
213.1883 -    nowPos32 += len;
213.1884 -    if (p->additionalOffset == 0)
213.1885 -    {
213.1886 -      UInt32 processed;
213.1887 -      if (!p->fastMode)
213.1888 -      {
213.1889 -        if (p->matchPriceCount >= (1 << 7))
213.1890 -          FillDistancesPrices(p);
213.1891 -        if (p->alignPriceCount >= kAlignTableSize)
213.1892 -          FillAlignPrices(p);
213.1893 -      }
213.1894 -      if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
213.1895 -        break;
213.1896 -      processed = nowPos32 - startPos32;
213.1897 -      if (useLimits)
213.1898 -      {
213.1899 -        if (processed + kNumOpts + 300 >= maxUnpackSize ||
213.1900 -            RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize)
213.1901 -          break;
213.1902 -      }
213.1903 -      else if (processed >= (1 << 15))
213.1904 -      {
213.1905 -        p->nowPos64 += nowPos32 - startPos32;
213.1906 -        return CheckErrors(p);
213.1907 -      }
213.1908 -    }
213.1909 -  }
213.1910 -  p->nowPos64 += nowPos32 - startPos32;
213.1911 -  return Flush(p, nowPos32);
213.1912 -}
213.1913 -
213.1914 -#define kBigHashDicLimit ((UInt32)1 << 24)
213.1915 -
213.1916 -static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
213.1917 -{
213.1918 -  UInt32 beforeSize = kNumOpts;
213.1919 -  Bool btMode;
213.1920 -  if (!RangeEnc_Alloc(&p->rc, alloc))
213.1921 -    return SZ_ERROR_MEM;
213.1922 -  btMode = (p->matchFinderBase.btMode != 0);
213.1923 -  #ifdef COMPRESS_MF_MT
213.1924 -  p->mtMode = (p->multiThread && !p->fastMode && btMode);
213.1925 -  #endif
213.1926 -
213.1927 -  {
213.1928 -    unsigned lclp = p->lc + p->lp;
213.1929 -    if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp)
213.1930 -    {
213.1931 -      LzmaEnc_FreeLits(p, alloc);
213.1932 -      p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
213.1933 -      p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
213.1934 -      if (p->litProbs == 0 || p->saveState.litProbs == 0)
213.1935 -      {
213.1936 -        LzmaEnc_FreeLits(p, alloc);
213.1937 -        return SZ_ERROR_MEM;
213.1938 -      }
213.1939 -      p->lclp = lclp;
213.1940 -    }
213.1941 -  }
213.1942 -
213.1943 -  p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit);
213.1944 -
213.1945 -  if (beforeSize + p->dictSize < keepWindowSize)
213.1946 -    beforeSize = keepWindowSize - p->dictSize;
213.1947 -
213.1948 -  #ifdef COMPRESS_MF_MT
213.1949 -  if (p->mtMode)
213.1950 -  {
213.1951 -    RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
213.1952 -    p->matchFinderObj = &p->matchFinderMt;
213.1953 -    MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);
213.1954 -  }
213.1955 -  else
213.1956 -  #endif
213.1957 -  {
213.1958 -    if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))
213.1959 -      return SZ_ERROR_MEM;
213.1960 -    p->matchFinderObj = &p->matchFinderBase;
213.1961 -    MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);
213.1962 -  }
213.1963 -  return SZ_OK;
213.1964 -}
213.1965 -
213.1966 -void LzmaEnc_Init(CLzmaEnc *p)
213.1967 -{
213.1968 -  UInt32 i;
213.1969 -  p->state = 0;
213.1970 -  for (i = 0 ; i < LZMA_NUM_REPS; i++)
213.1971 -    p->reps[i] = 0;
213.1972 -
213.1973 -  RangeEnc_Init(&p->rc);
213.1974 -
213.1975 -
213.1976 -  for (i = 0; i < kNumStates; i++)
213.1977 -  {
213.1978 -    UInt32 j;
213.1979 -    for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)
213.1980 -    {
213.1981 -      p->isMatch[i][j] = kProbInitValue;
213.1982 -      p->isRep0Long[i][j] = kProbInitValue;
213.1983 -    }
213.1984 -    p->isRep[i] = kProbInitValue;
213.1985 -    p->isRepG0[i] = kProbInitValue;
213.1986 -    p->isRepG1[i] = kProbInitValue;
213.1987 -    p->isRepG2[i] = kProbInitValue;
213.1988 -  }
213.1989 -
213.1990 -  {
213.1991 -    UInt32 num = 0x300 << (p->lp + p->lc);
213.1992 -    for (i = 0; i < num; i++)
213.1993 -      p->litProbs[i] = kProbInitValue;
213.1994 -  }
213.1995 -
213.1996 -  {
213.1997 -    for (i = 0; i < kNumLenToPosStates; i++)
213.1998 -    {
213.1999 -      CLzmaProb *probs = p->posSlotEncoder[i];
213.2000 -      UInt32 j;
213.2001 -      for (j = 0; j < (1 << kNumPosSlotBits); j++)
213.2002 -        probs[j] = kProbInitValue;
213.2003 -    }
213.2004 -  }
213.2005 -  {
213.2006 -    for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
213.2007 -      p->posEncoders[i] = kProbInitValue;
213.2008 -  }
213.2009 -
213.2010 -  LenEnc_Init(&p->lenEnc.p);
213.2011 -  LenEnc_Init(&p->repLenEnc.p);
213.2012 -
213.2013 -  for (i = 0; i < (1 << kNumAlignBits); i++)
213.2014 -    p->posAlignEncoder[i] = kProbInitValue;
213.2015 -
213.2016 -  p->optimumEndIndex = 0;
213.2017 -  p->optimumCurrentIndex = 0;
213.2018 -  p->additionalOffset = 0;
213.2019 -
213.2020 -  p->pbMask = (1 << p->pb) - 1;
213.2021 -  p->lpMask = (1 << p->lp) - 1;
213.2022 -}
213.2023 -
213.2024 -void LzmaEnc_InitPrices(CLzmaEnc *p)
213.2025 -{
213.2026 -  if (!p->fastMode)
213.2027 -  {
213.2028 -    FillDistancesPrices(p);
213.2029 -    FillAlignPrices(p);
213.2030 -  }
213.2031 -
213.2032 -  p->lenEnc.tableSize =
213.2033 -  p->repLenEnc.tableSize =
213.2034 -      p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;
213.2035 -  LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);
213.2036 -  LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
213.2037 -}
213.2038 -
213.2039 -static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
213.2040 -{
213.2041 -  UInt32 i;
213.2042 -  for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)
213.2043 -    if (p->dictSize <= ((UInt32)1 << i))
213.2044 -      break;
213.2045 -  p->distTableSize = i * 2;
213.2046 -
213.2047 -  p->finished = False;
213.2048 -  p->result = SZ_OK;
213.2049 -  RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));
213.2050 -  LzmaEnc_Init(p);
213.2051 -  LzmaEnc_InitPrices(p);
213.2052 -  p->nowPos64 = 0;
213.2053 -  return SZ_OK;
213.2054 -}
213.2055 -
213.2056 -static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqInStream *inStream, ISeqOutStream *outStream,
213.2057 -    ISzAlloc *alloc, ISzAlloc *allocBig)
213.2058 -{
213.2059 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2060 -  p->inStream = inStream;
213.2061 -  p->rc.outStream = outStream;
213.2062 -  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
213.2063 -}
213.2064 -
213.2065 -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
213.2066 -    ISeqInStream *inStream, UInt32 keepWindowSize,
213.2067 -    ISzAlloc *alloc, ISzAlloc *allocBig)
213.2068 -{
213.2069 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2070 -  p->inStream = inStream;
213.2071 -  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
213.2072 -}
213.2073 -
213.2074 -static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
213.2075 -{
213.2076 -  p->seqBufInStream.funcTable.Read = MyRead;
213.2077 -  p->seqBufInStream.data = src;
213.2078 -  p->seqBufInStream.rem = srcLen;
213.2079 -}
213.2080 -
213.2081 -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
213.2082 -    UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
213.2083 -{
213.2084 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2085 -  LzmaEnc_SetInputBuf(p, src, srcLen);
213.2086 -  p->inStream = &p->seqBufInStream.funcTable;
213.2087 -  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
213.2088 -}
213.2089 -
213.2090 -void LzmaEnc_Finish(CLzmaEncHandle pp)
213.2091 -{
213.2092 -  #ifdef COMPRESS_MF_MT
213.2093 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2094 -  if (p->mtMode)
213.2095 -    MatchFinderMt_ReleaseStream(&p->matchFinderMt);
213.2096 -  #else
213.2097 -  pp = pp;
213.2098 -  #endif
213.2099 -}
213.2100 -
213.2101 -typedef struct _CSeqOutStreamBuf
213.2102 -{
213.2103 -  ISeqOutStream funcTable;
213.2104 -  Byte *data;
213.2105 -  SizeT rem;
213.2106 -  Bool overflow;
213.2107 -} CSeqOutStreamBuf;
213.2108 -
213.2109 -static size_t MyWrite(void *pp, const void *data, size_t size)
213.2110 -{
213.2111 -  CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;
213.2112 -  if (p->rem < size)
213.2113 -  {
213.2114 -    size = p->rem;
213.2115 -    p->overflow = True;
213.2116 -  }
213.2117 -  memcpy(p->data, data, size);
213.2118 -  p->rem -= size;
213.2119 -  p->data += size;
213.2120 -  return size;
213.2121 -}
213.2122 -
213.2123 -
213.2124 -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
213.2125 -{
213.2126 -  const CLzmaEnc *p = (CLzmaEnc *)pp;
213.2127 -  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
213.2128 -}
213.2129 -
213.2130 -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
213.2131 -{
213.2132 -  const CLzmaEnc *p = (CLzmaEnc *)pp;
213.2133 -  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
213.2134 -}
213.2135 -
213.2136 -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
213.2137 -    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
213.2138 -{
213.2139 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2140 -  UInt64 nowPos64;
213.2141 -  SRes res;
213.2142 -  CSeqOutStreamBuf outStream;
213.2143 -
213.2144 -  outStream.funcTable.Write = MyWrite;
213.2145 -  outStream.data = dest;
213.2146 -  outStream.rem = *destLen;
213.2147 -  outStream.overflow = False;
213.2148 -
213.2149 -  p->writeEndMark = False;
213.2150 -  p->finished = False;
213.2151 -  p->result = SZ_OK;
213.2152 -
213.2153 -  if (reInit)
213.2154 -    LzmaEnc_Init(p);
213.2155 -  LzmaEnc_InitPrices(p);
213.2156 -  nowPos64 = p->nowPos64;
213.2157 -  RangeEnc_Init(&p->rc);
213.2158 -  p->rc.outStream = &outStream.funcTable;
213.2159 -
213.2160 -  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
213.2161 -  
213.2162 -  *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
213.2163 -  *destLen -= outStream.rem;
213.2164 -  if (outStream.overflow)
213.2165 -    return SZ_ERROR_OUTPUT_EOF;
213.2166 -
213.2167 -  return res;
213.2168 -}
213.2169 -
213.2170 -SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
213.2171 -    ISzAlloc *alloc, ISzAlloc *allocBig)
213.2172 -{
213.2173 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2174 -  SRes res = SZ_OK;
213.2175 -
213.2176 -  #ifdef COMPRESS_MF_MT
213.2177 -  Byte allocaDummy[0x300];
213.2178 -  int i = 0;
213.2179 -  for (i = 0; i < 16; i++)
213.2180 -    allocaDummy[i] = (Byte)i;
213.2181 -  #endif
213.2182 -
213.2183 -  RINOK(LzmaEnc_Prepare(pp, inStream, outStream, alloc, allocBig));
213.2184 -
213.2185 -  for (;;)
213.2186 -  {
213.2187 -    res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
213.2188 -    if (res != SZ_OK || p->finished != 0)
213.2189 -      break;
213.2190 -    if (progress != 0)
213.2191 -    {
213.2192 -      res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
213.2193 -      if (res != SZ_OK)
213.2194 -      {
213.2195 -        res = SZ_ERROR_PROGRESS;
213.2196 -        break;
213.2197 -      }
213.2198 -    }
213.2199 -  }
213.2200 -  LzmaEnc_Finish(pp);
213.2201 -  return res;
213.2202 -}
213.2203 -
213.2204 -SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
213.2205 -{
213.2206 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2207 -  int i;
213.2208 -  UInt32 dictSize = p->dictSize;
213.2209 -  if (*size < LZMA_PROPS_SIZE)
213.2210 -    return SZ_ERROR_PARAM;
213.2211 -  *size = LZMA_PROPS_SIZE;
213.2212 -  props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);
213.2213 -
213.2214 -  for (i = 11; i <= 30; i++)
213.2215 -  {
213.2216 -    if (dictSize <= ((UInt32)2 << i))
213.2217 -    {
213.2218 -      dictSize = (2 << i);
213.2219 -      break;
213.2220 -    }
213.2221 -    if (dictSize <= ((UInt32)3 << i))
213.2222 -    {
213.2223 -      dictSize = (3 << i);
213.2224 -      break;
213.2225 -    }
213.2226 -  }
213.2227 -
213.2228 -  for (i = 0; i < 4; i++)
213.2229 -    props[1 + i] = (Byte)(dictSize >> (8 * i));
213.2230 -  return SZ_OK;
213.2231 -}
213.2232 -
213.2233 -SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
213.2234 -    int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
213.2235 -{
213.2236 -  SRes res;
213.2237 -  CLzmaEnc *p = (CLzmaEnc *)pp;
213.2238 -
213.2239 -  CSeqOutStreamBuf outStream;
213.2240 -
213.2241 -  LzmaEnc_SetInputBuf(p, src, srcLen);
213.2242 -
213.2243 -  outStream.funcTable.Write = MyWrite;
213.2244 -  outStream.data = dest;
213.2245 -  outStream.rem = *destLen;
213.2246 -  outStream.overflow = False;
213.2247 -
213.2248 -  p->writeEndMark = writeEndMark;
213.2249 -  res = LzmaEnc_Encode(pp, &outStream.funcTable, &p->seqBufInStream.funcTable,
213.2250 -      progress, alloc, allocBig);
213.2251 -
213.2252 -  *destLen -= outStream.rem;
213.2253 -  if (outStream.overflow)
213.2254 -    return SZ_ERROR_OUTPUT_EOF;
213.2255 -  return res;
213.2256 -}
213.2257 -
213.2258 -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
213.2259 -    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
213.2260 -    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
213.2261 -{
213.2262 -  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
213.2263 -  SRes res;
213.2264 -  if (p == 0)
213.2265 -    return SZ_ERROR_MEM;
213.2266 -
213.2267 -  res = LzmaEnc_SetProps(p, props);
213.2268 -  if (res == SZ_OK)
213.2269 -  {
213.2270 -    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
213.2271 -    if (res == SZ_OK)
213.2272 -      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
213.2273 -          writeEndMark, progress, alloc, allocBig);
213.2274 -  }
213.2275 -
213.2276 -  LzmaEnc_Destroy(p, alloc, allocBig);
213.2277 -  return res;
213.2278 -}
   214.1 --- a/src/win32/7zip/7z/C/LzmaEnc.h	Sat Mar 03 10:54:39 2012 -0600
   214.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   214.3 @@ -1,72 +0,0 @@
   214.4 -/*  LzmaEnc.h -- LZMA Encoder
   214.5 -2008-10-04 : Igor Pavlov : Public domain */
   214.6 -
   214.7 -#ifndef __LZMAENC_H
   214.8 -#define __LZMAENC_H
   214.9 -
  214.10 -#include "Types.h"
  214.11 -
  214.12 -#define LZMA_PROPS_SIZE 5
  214.13 -
  214.14 -typedef struct _CLzmaEncProps
  214.15 -{
  214.16 -  int level;       /*  0 <= level <= 9 */
  214.17 -  UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
  214.18 -                      (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
  214.19 -                       default = (1 << 24) */
  214.20 -  int lc;          /* 0 <= lc <= 8, default = 3 */
  214.21 -  int lp;          /* 0 <= lp <= 4, default = 0 */
  214.22 -  int pb;          /* 0 <= pb <= 4, default = 2 */
  214.23 -  int algo;        /* 0 - fast, 1 - normal, default = 1 */
  214.24 -  int fb;          /* 5 <= fb <= 273, default = 32 */
  214.25 -  int btMode;      /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
  214.26 -  int numHashBytes; /* 2, 3 or 4, default = 4 */
  214.27 -  UInt32 mc;        /* 1 <= mc <= (1 << 30), default = 32 */
  214.28 -  unsigned writeEndMark;  /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
  214.29 -  int numThreads;  /* 1 or 2, default = 2 */
  214.30 -} CLzmaEncProps;
  214.31 -
  214.32 -void LzmaEncProps_Init(CLzmaEncProps *p);
  214.33 -void LzmaEncProps_Normalize(CLzmaEncProps *p);
  214.34 -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
  214.35 -
  214.36 -
  214.37 -/* ---------- CLzmaEncHandle Interface ---------- */
  214.38 -
  214.39 -/* LzmaEnc_* functions can return the following exit codes:
  214.40 -Returns:
  214.41 -  SZ_OK           - OK
  214.42 -  SZ_ERROR_MEM    - Memory allocation error
  214.43 -  SZ_ERROR_PARAM  - Incorrect paramater in props
  214.44 -  SZ_ERROR_WRITE  - Write callback error.
  214.45 -  SZ_ERROR_PROGRESS - some break from progress callback
  214.46 -  SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
  214.47 -*/
  214.48 -
  214.49 -typedef void * CLzmaEncHandle;
  214.50 -
  214.51 -CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
  214.52 -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
  214.53 -SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
  214.54 -SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
  214.55 -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
  214.56 -    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  214.57 -SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  214.58 -    int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  214.59 -
  214.60 -/* ---------- One Call Interface ---------- */
  214.61 -
  214.62 -/* LzmaEncode
  214.63 -Return code:
  214.64 -  SZ_OK               - OK
  214.65 -  SZ_ERROR_MEM        - Memory allocation error
  214.66 -  SZ_ERROR_PARAM      - Incorrect paramater
  214.67 -  SZ_ERROR_OUTPUT_EOF - output buffer overflow
  214.68 -  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
  214.69 -*/
  214.70 -
  214.71 -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  214.72 -    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  214.73 -    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  214.74 -
  214.75 -#endif
   215.1 --- a/src/win32/7zip/7z/C/RotateDefs.h	Sat Mar 03 10:54:39 2012 -0600
   215.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   215.3 @@ -1,22 +0,0 @@
   215.4 -/* RotateDefs.h -- Rotate functions
   215.5 -2008-08-05
   215.6 -Igor Pavlov
   215.7 -Public domain */
   215.8 -
   215.9 -#ifndef __ROTATEDEFS_H
  215.10 -#define __ROTATEDEFS_H
  215.11 -
  215.12 -#ifdef _MSC_VER
  215.13 -
  215.14 -#include <stdlib.h>
  215.15 -#define rotlFixed(x, n) _rotl((x), (n))
  215.16 -#define rotrFixed(x, n) _rotr((x), (n))
  215.17 -
  215.18 -#else
  215.19 -
  215.20 -#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
  215.21 -#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
  215.22 -
  215.23 -#endif
  215.24 -
  215.25 -#endif
   216.1 --- a/src/win32/7zip/7z/C/Sha256.c	Sat Mar 03 10:54:39 2012 -0600
   216.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   216.3 @@ -1,204 +0,0 @@
   216.4 -/* Crypto/Sha256.c -- SHA-256 Hash function
   216.5 -2008-11-06 : Igor Pavlov : Public domain
   216.6 -This code is based on public domain code from Wei Dai's Crypto++ library. */
   216.7 -
   216.8 -#include "Sha256.h"
   216.9 -#include "RotateDefs.h"
  216.10 -
  216.11 -/* define it for speed optimization */
  216.12 -/* #define _SHA256_UNROLL */
  216.13 -/* #define _SHA256_UNROLL2 */
  216.14 -
  216.15 -void Sha256_Init(CSha256 *p)
  216.16 -{
  216.17 -  p->state[0] = 0x6a09e667;
  216.18 -  p->state[1] = 0xbb67ae85;
  216.19 -  p->state[2] = 0x3c6ef372;
  216.20 -  p->state[3] = 0xa54ff53a;
  216.21 -  p->state[4] = 0x510e527f;
  216.22 -  p->state[5] = 0x9b05688c;
  216.23 -  p->state[6] = 0x1f83d9ab;
  216.24 -  p->state[7] = 0x5be0cd19;
  216.25 -  p->count = 0;
  216.26 -}
  216.27 -
  216.28 -#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22))
  216.29 -#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25))
  216.30 -#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3))
  216.31 -#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10))
  216.32 -
  216.33 -#define blk0(i) (W[i] = data[i])
  216.34 -#define blk2(i) (W[i&15] += s1(W[(i-2)&15]) + W[(i-7)&15] + s0(W[(i-15)&15]))
  216.35 -
  216.36 -#define Ch(x,y,z) (z^(x&(y^z)))
  216.37 -#define Maj(x,y,z) ((x&y)|(z&(x|y)))
  216.38 -
  216.39 -#define a(i) T[(0-(i))&7]
  216.40 -#define b(i) T[(1-(i))&7]
  216.41 -#define c(i) T[(2-(i))&7]
  216.42 -#define d(i) T[(3-(i))&7]
  216.43 -#define e(i) T[(4-(i))&7]
  216.44 -#define f(i) T[(5-(i))&7]
  216.45 -#define g(i) T[(6-(i))&7]
  216.46 -#define h(i) T[(7-(i))&7]
  216.47 -
  216.48 -
  216.49 -#ifdef _SHA256_UNROLL2
  216.50 -
  216.51 -#define R(a,b,c,d,e,f,g,h, i) h += S1(e) + Ch(e,f,g) + K[i+j] + (j?blk2(i):blk0(i));\
  216.52 -  d += h; h += S0(a) + Maj(a, b, c)
  216.53 -
  216.54 -#define RX_8(i) \
  216.55 -  R(a,b,c,d,e,f,g,h, i); \
  216.56 -  R(h,a,b,c,d,e,f,g, i+1); \
  216.57 -  R(g,h,a,b,c,d,e,f, i+2); \
  216.58 -  R(f,g,h,a,b,c,d,e, i+3); \
  216.59 -  R(e,f,g,h,a,b,c,d, i+4); \
  216.60 -  R(d,e,f,g,h,a,b,c, i+5); \
  216.61 -  R(c,d,e,f,g,h,a,b, i+6); \
  216.62 -  R(b,c,d,e,f,g,h,a, i+7)
  216.63 -
  216.64 -#else
  216.65 -
  216.66 -#define R(i) h(i) += S1(e(i)) + Ch(e(i),f(i),g(i)) + K[i+j] + (j?blk2(i):blk0(i));\
  216.67 -  d(i) += h(i); h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))
  216.68 -
  216.69 -#ifdef _SHA256_UNROLL
  216.70 -
  216.71 -#define RX_8(i) R(i+0); R(i+1); R(i+2); R(i+3); R(i+4); R(i+5); R(i+6); R(i+7);
  216.72 -
  216.73 -#endif
  216.74 -
  216.75 -#endif
  216.76 -
  216.77 -const UInt32 K[64] = {
  216.78 -  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  216.79 -  0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  216.80 -  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  216.81 -  0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  216.82 -  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  216.83 -  0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  216.84 -  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  216.85 -  0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  216.86 -  0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  216.87 -  0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  216.88 -  0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  216.89 -  0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  216.90 -  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  216.91 -  0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  216.92 -  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  216.93 -  0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  216.94 -};
  216.95 -
  216.96 -static void Sha256_Transform(UInt32 *state, const UInt32 *data)
  216.97 -{
  216.98 -  UInt32 W[16];
  216.99 -  unsigned j;
 216.100 -  #ifdef _SHA256_UNROLL2
 216.101 -  UInt32 a,b,c,d,e,f,g,h;
 216.102 -  a = state[0];
 216.103 -  b = state[1];
 216.104 -  c = state[2];
 216.105 -  d = state[3];
 216.106 -  e = state[4];
 216.107 -  f = state[5];
 216.108 -  g = state[6];
 216.109 -  h = state[7];
 216.110 -  #else
 216.111 -  UInt32 T[8];
 216.112 -  for (j = 0; j < 8; j++)
 216.113 -    T[j] = state[j];
 216.114 -  #endif
 216.115 -
 216.116 -  for (j = 0; j < 64; j += 16)
 216.117 -  {
 216.118 -    #if defined(_SHA256_UNROLL) || defined(_SHA256_UNROLL2)
 216.119 -    RX_8(0); RX_8(8);
 216.120 -    #else
 216.121 -    unsigned i;
 216.122 -    for (i = 0; i < 16; i++) { R(i); }
 216.123 -    #endif
 216.124 -  }
 216.125 -
 216.126 -  #ifdef _SHA256_UNROLL2
 216.127 -  state[0] += a;
 216.128 -  state[1] += b;
 216.129 -  state[2] += c;
 216.130 -  state[3] += d;
 216.131 -  state[4] += e;
 216.132 -  state[5] += f;
 216.133 -  state[6] += g;
 216.134 -  state[7] += h;
 216.135 -  #else
 216.136 -  for (j = 0; j < 8; j++)
 216.137 -    state[j] += T[j];
 216.138 -  #endif
 216.139 -  
 216.140 -  /* Wipe variables */
 216.141 -  /* memset(W, 0, sizeof(W)); */
 216.142 -  /* memset(T, 0, sizeof(T)); */
 216.143 -}
 216.144 -
 216.145 -#undef S0
 216.146 -#undef S1
 216.147 -#undef s0
 216.148 -#undef s1
 216.149 -
 216.150 -static void Sha256_WriteByteBlock(CSha256 *p)
 216.151 -{
 216.152 -  UInt32 data32[16];
 216.153 -  unsigned i;
 216.154 -  for (i = 0; i < 16; i++)
 216.155 -    data32[i] =
 216.156 -      ((UInt32)(p->buffer[i * 4    ]) << 24) +
 216.157 -      ((UInt32)(p->buffer[i * 4 + 1]) << 16) +
 216.158 -      ((UInt32)(p->buffer[i * 4 + 2]) <<  8) +
 216.159 -      ((UInt32)(p->buffer[i * 4 + 3]));
 216.160 -  Sha256_Transform(p->state, data32);
 216.161 -}
 216.162 -
 216.163 -void Sha256_Update(CSha256 *p, const Byte *data, size_t size)
 216.164 -{
 216.165 -  UInt32 curBufferPos = (UInt32)p->count & 0x3F;
 216.166 -  while (size > 0)
 216.167 -  {
 216.168 -    p->buffer[curBufferPos++] = *data++;
 216.169 -    p->count++;
 216.170 -    size--;
 216.171 -    if (curBufferPos == 64)
 216.172 -    {
 216.173 -      curBufferPos = 0;
 216.174 -      Sha256_WriteByteBlock(p);
 216.175 -    }
 216.176 -  }
 216.177 -}
 216.178 -
 216.179 -void Sha256_Final(CSha256 *p, Byte *digest)
 216.180 -{
 216.181 -  UInt64 lenInBits = (p->count << 3);
 216.182 -  UInt32 curBufferPos = (UInt32)p->count & 0x3F;
 216.183 -  unsigned i;
 216.184 -  p->buffer[curBufferPos++] = 0x80;
 216.185 -  while (curBufferPos != (64 - 8))
 216.186 -  {
 216.187 -    curBufferPos &= 0x3F;
 216.188 -    if (curBufferPos == 0)
 216.189 -      Sha256_WriteByteBlock(p);
 216.190 -    p->buffer[curBufferPos++] = 0;
 216.191 -  }
 216.192 -  for (i = 0; i < 8; i++)
 216.193 -  {
 216.194 -    p->buffer[curBufferPos++] = (Byte)(lenInBits >> 56);
 216.195 -    lenInBits <<= 8;
 216.196 -  }
 216.197 -  Sha256_WriteByteBlock(p);
 216.198 -
 216.199 -  for (i = 0; i < 8; i++)
 216.200 -  {
 216.201 -    *digest++ = (Byte)((p->state[i] >> 24) & 0xFF);
 216.202 -    *digest++ = (Byte)((p->state[i] >> 16) & 0xFF);
 216.203 -    *digest++ = (Byte)((p->state[i] >> 8) & 0xFF);
 216.204 -    *digest++ = (Byte)((p->state[i]) & 0xFF);
 216.205 -  }
 216.206 -  Sha256_Init(p);
 216.207 -}
   217.1 --- a/src/win32/7zip/7z/C/Sha256.h	Sat Mar 03 10:54:39 2012 -0600
   217.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   217.3 @@ -1,22 +0,0 @@
   217.4 -/* Crypto/Sha256.h -- SHA-256 Hash function
   217.5 -2008-10-04 : Igor Pavlov : Public domain */
   217.6 -
   217.7 -#ifndef __CRYPTO_SHA256_H
   217.8 -#define __CRYPTO_SHA256_H
   217.9 -
  217.10 -#include "Types.h"
  217.11 -
  217.12 -#define SHA256_DIGEST_SIZE 32
  217.13 -
  217.14 -typedef struct
  217.15 -{
  217.16 -  UInt32 state[8];
  217.17 -  UInt64 count;
  217.18 -  Byte buffer[64];
  217.19 -} CSha256;
  217.20 -
  217.21 -void Sha256_Init(CSha256 *p);
  217.22 -void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
  217.23 -void Sha256_Final(CSha256 *p, Byte *digest);
  217.24 -
  217.25 -#endif
   218.1 --- a/src/win32/7zip/7z/C/Sort.c	Sat Mar 03 10:54:39 2012 -0600
   218.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   218.3 @@ -1,95 +0,0 @@
   218.4 -/* Sort.c -- Sort functions
   218.5 -2008-08-17
   218.6 -Igor Pavlov
   218.7 -Public domain */
   218.8 -
   218.9 -#include "Sort.h"
  218.10 -
  218.11 -#define HeapSortDown(p, k, size, temp) \
  218.12 -  { for (;;) { \
  218.13 -    UInt32 s = (k << 1); \
  218.14 -    if (s > size) break; \
  218.15 -    if (s < size && p[s + 1] > p[s]) s++; \
  218.16 -    if (temp >= p[s]) break; \
  218.17 -    p[k] = p[s]; k = s; \
  218.18 -  } p[k] = temp; }
  218.19 -
  218.20 -void HeapSort(UInt32 *p, UInt32 size)
  218.21 -{
  218.22 -  if (size <= 1)
  218.23 -    return;
  218.24 -  p--;
  218.25 -  {
  218.26 -    UInt32 i = size / 2;
  218.27 -    do
  218.28 -    {
  218.29 -      UInt32 temp = p[i];
  218.30 -      UInt32 k = i;
  218.31 -      HeapSortDown(p, k, size, temp)
  218.32 -    }
  218.33 -    while (--i != 0);
  218.34 -  }
  218.35 -  /*
  218.36 -  do
  218.37 -  {
  218.38 -    UInt32 k = 1;
  218.39 -    UInt32 temp = p[size];
  218.40 -    p[size--] = p[1];
  218.41 -    HeapSortDown(p, k, size, temp)
  218.42 -  }
  218.43 -  while (size > 1);
  218.44 -  */
  218.45 -  while (size > 3)
  218.46 -  {
  218.47 -    UInt32 temp = p[size];
  218.48 -    UInt32 k = (p[3] > p[2]) ? 3 : 2;
  218.49 -    p[size--] = p[1];
  218.50 -    p[1] = p[k];
  218.51 -    HeapSortDown(p, k, size, temp)
  218.52 -  }
  218.53 -  {
  218.54 -    UInt32 temp = p[size];
  218.55 -    p[size] = p[1];
  218.56 -    if (size > 2 && p[2] < temp)
  218.57 -    {
  218.58 -      p[1] = p[2];
  218.59 -      p[2] = temp;
  218.60 -    }
  218.61 -    else
  218.62 -      p[1] = temp;
  218.63 -  }
  218.64 -}
  218.65 -
  218.66 -/*
  218.67 -#define HeapSortRefDown(p, vals, n, size, temp) \
  218.68 -  { UInt32 k = n; UInt32 val = vals[temp]; for (;;) { \
  218.69 -    UInt32 s = (k << 1); \
  218.70 -    if (s > size) break; \
  218.71 -    if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
  218.72 -    if (val >= vals[p[s]]) break; \
  218.73 -    p[k] = p[s]; k = s; \
  218.74 -  } p[k] = temp; }
  218.75 -
  218.76 -void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size)
  218.77 -{
  218.78 -  if (size <= 1)
  218.79 -    return;
  218.80 -  p--;
  218.81 -  {
  218.82 -    UInt32 i = size / 2;
  218.83 -    do
  218.84 -    {
  218.85 -      UInt32 temp = p[i];
  218.86 -      HeapSortRefDown(p, vals, i, size, temp);
  218.87 -    }
  218.88 -    while (--i != 0);
  218.89 -  }
  218.90 -  do
  218.91 -  {
  218.92 -    UInt32 temp = p[size];
  218.93 -    p[size--] = p[1];
  218.94 -    HeapSortRefDown(p, vals, 1, size, temp);
  218.95 -  }
  218.96 -  while (size > 1);
  218.97 -}
  218.98 -*/
  218.99 \ No newline at end of file
   219.1 --- a/src/win32/7zip/7z/C/Sort.h	Sat Mar 03 10:54:39 2012 -0600
   219.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   219.3 @@ -1,14 +0,0 @@
   219.4 -/* Sort.h -- Sort functions
   219.5 -2008-03-19
   219.6 -Igor Pavlov
   219.7 -Public domain */
   219.8 -
   219.9 -#ifndef __7Z_SORT_H
  219.10 -#define __7Z_SORT_H
  219.11 -
  219.12 -#include "Types.h"
  219.13 -
  219.14 -void HeapSort(UInt32 *p, UInt32 size);
  219.15 -/* void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size); */
  219.16 -
  219.17 -#endif
   220.1 --- a/src/win32/7zip/7z/C/Threads.c	Sat Mar 03 10:54:39 2012 -0600
   220.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   220.3 @@ -1,109 +0,0 @@
   220.4 -/* Threads.c -- multithreading library
   220.5 -2008-08-05
   220.6 -Igor Pavlov
   220.7 -Public domain */
   220.8 -
   220.9 -#include "Threads.h"
  220.10 -#include <process.h>
  220.11 -
  220.12 -static WRes GetError()
  220.13 -{
  220.14 -  DWORD res = GetLastError();
  220.15 -  return (res) ? (WRes)(res) : 1;
  220.16 -}
  220.17 -
  220.18 -WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); }
  220.19 -WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); }
  220.20 -
  220.21 -static WRes MyCloseHandle(HANDLE *h)
  220.22 -{
  220.23 -  if (*h != NULL)
  220.24 -    if (!CloseHandle(*h))
  220.25 -      return GetError();
  220.26 -  *h = NULL;
  220.27 -  return 0;
  220.28 -}
  220.29 -
  220.30 -WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
  220.31 -{
  220.32 -  unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
  220.33 -  thread->handle =
  220.34 -    /* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */
  220.35 -    (HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, &threadId);
  220.36 -    /* maybe we must use errno here, but probably GetLastError() is also OK. */
  220.37 -  return HandleToWRes(thread->handle);
  220.38 -}
  220.39 -
  220.40 -WRes WaitObject(HANDLE h)
  220.41 -{
  220.42 -  return (WRes)WaitForSingleObject(h, INFINITE);
  220.43 -}
  220.44 -
  220.45 -WRes Thread_Wait(CThread *thread)
  220.46 -{
  220.47 -  if (thread->handle == NULL)
  220.48 -    return 1;
  220.49 -  return WaitObject(thread->handle);
  220.50 -}
  220.51 -
  220.52 -WRes Thread_Close(CThread *thread)
  220.53 -{
  220.54 -  return MyCloseHandle(&thread->handle);
  220.55 -}
  220.56 -
  220.57 -WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
  220.58 -{
  220.59 -  p->handle = CreateEvent(NULL, manualReset, (initialSignaled ? TRUE : FALSE), NULL);
  220.60 -  return HandleToWRes(p->handle);
  220.61 -}
  220.62 -
  220.63 -WRes ManualResetEvent_Create(CManualResetEvent *p, int initialSignaled)
  220.64 -  { return Event_Create(p, TRUE, initialSignaled); }
  220.65 -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
  220.66 -  { return ManualResetEvent_Create(p, 0); }
  220.67 -
  220.68 -WRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
  220.69 -  { return Event_Create(p, FALSE, initialSignaled); }
  220.70 -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
  220.71 -  { return AutoResetEvent_Create(p, 0); }
  220.72 -
  220.73 -WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(p->handle)); }
  220.74 -WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(p->handle)); }
  220.75 -WRes Event_Wait(CEvent *p) { return WaitObject(p->handle); }
  220.76 -WRes Event_Close(CEvent *p) { return MyCloseHandle(&p->handle); }
  220.77 -
  220.78 -
  220.79 -WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
  220.80 -{
  220.81 -  p->handle = CreateSemaphore(NULL, (LONG)initiallyCount, (LONG)maxCount, NULL);
  220.82 -  return HandleToWRes(p->handle);
  220.83 -}
  220.84 -
  220.85 -WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
  220.86 -{
  220.87 -  return BOOLToWRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
  220.88 -}
  220.89 -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
  220.90 -{
  220.91 -  return Semaphore_Release(p, (LONG)releaseCount, NULL);
  220.92 -}
  220.93 -WRes Semaphore_Release1(CSemaphore *p)
  220.94 -{
  220.95 -  return Semaphore_ReleaseN(p, 1);
  220.96 -}
  220.97 -
  220.98 -WRes Semaphore_Wait(CSemaphore *p) { return WaitObject(p->handle); }
  220.99 -WRes Semaphore_Close(CSemaphore *p) { return MyCloseHandle(&p->handle); }
 220.100 -
 220.101 -WRes CriticalSection_Init(CCriticalSection *p)
 220.102 -{
 220.103 -  /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
 220.104 -  __try
 220.105 -  {
 220.106 -    InitializeCriticalSection(p);
 220.107 -    /* InitializeCriticalSectionAndSpinCount(p, 0); */
 220.108 -  }
 220.109 -  __except (EXCEPTION_EXECUTE_HANDLER) { return 1; }
 220.110 -  return 0;
 220.111 -}
 220.112 -
   221.1 --- a/src/win32/7zip/7z/C/Threads.h	Sat Mar 03 10:54:39 2012 -0600
   221.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   221.3 @@ -1,68 +0,0 @@
   221.4 -/* Threads.h -- multithreading library
   221.5 -2008-11-22 : Igor Pavlov : Public domain */
   221.6 -
   221.7 -#ifndef __7Z_THRESDS_H
   221.8 -#define __7Z_THRESDS_H
   221.9 -
  221.10 -#include "Types.h"
  221.11 -
  221.12 -typedef struct _CThread
  221.13 -{
  221.14 -  HANDLE handle;
  221.15 -} CThread;
  221.16 -
  221.17 -#define Thread_Construct(thread) (thread)->handle = NULL
  221.18 -#define Thread_WasCreated(thread) ((thread)->handle != NULL)
  221.19 - 
  221.20 -typedef unsigned THREAD_FUNC_RET_TYPE;
  221.21 -#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
  221.22 -#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
  221.23 -
  221.24 -WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter);
  221.25 -WRes Thread_Wait(CThread *thread);
  221.26 -WRes Thread_Close(CThread *thread);
  221.27 -
  221.28 -typedef struct _CEvent
  221.29 -{
  221.30 -  HANDLE handle;
  221.31 -} CEvent;
  221.32 -
  221.33 -typedef CEvent CAutoResetEvent;
  221.34 -typedef CEvent CManualResetEvent;
  221.35 -
  221.36 -#define Event_Construct(event) (event)->handle = NULL
  221.37 -#define Event_IsCreated(event) ((event)->handle != NULL)
  221.38 -
  221.39 -WRes ManualResetEvent_Create(CManualResetEvent *event, int initialSignaled);
  221.40 -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *event);
  221.41 -WRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
  221.42 -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
  221.43 -WRes Event_Set(CEvent *event);
  221.44 -WRes Event_Reset(CEvent *event);
  221.45 -WRes Event_Wait(CEvent *event);
  221.46 -WRes Event_Close(CEvent *event);
  221.47 -
  221.48 -
  221.49 -typedef struct _CSemaphore
  221.50 -{
  221.51 -  HANDLE handle;
  221.52 -} CSemaphore;
  221.53 -
  221.54 -#define Semaphore_Construct(p) (p)->handle = NULL
  221.55 -
  221.56 -WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
  221.57 -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
  221.58 -WRes Semaphore_Release1(CSemaphore *p);
  221.59 -WRes Semaphore_Wait(CSemaphore *p);
  221.60 -WRes Semaphore_Close(CSemaphore *p);
  221.61 -
  221.62 -
  221.63 -typedef CRITICAL_SECTION CCriticalSection;
  221.64 -
  221.65 -WRes CriticalSection_Init(CCriticalSection *p);
  221.66 -#define CriticalSection_Delete(p) DeleteCriticalSection(p)
  221.67 -#define CriticalSection_Enter(p) EnterCriticalSection(p)
  221.68 -#define CriticalSection_Leave(p) LeaveCriticalSection(p)
  221.69 -
  221.70 -#endif
  221.71 -
   222.1 --- a/src/win32/7zip/7z/C/Types.h	Sat Mar 03 10:54:39 2012 -0600
   222.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   222.3 @@ -1,208 +0,0 @@
   222.4 -/* Types.h -- Basic types
   222.5 -2008-11-23 : Igor Pavlov : Public domain */
   222.6 -
   222.7 -#ifndef __7Z_TYPES_H
   222.8 -#define __7Z_TYPES_H
   222.9 -
  222.10 -#include <stddef.h>
  222.11 -
  222.12 -#ifdef _WIN32
  222.13 -#include <windows.h>
  222.14 -#endif
  222.15 -
  222.16 -#define SZ_OK 0
  222.17 -
  222.18 -#define SZ_ERROR_DATA 1
  222.19 -#define SZ_ERROR_MEM 2
  222.20 -#define SZ_ERROR_CRC 3
  222.21 -#define SZ_ERROR_UNSUPPORTED 4
  222.22 -#define SZ_ERROR_PARAM 5
  222.23 -#define SZ_ERROR_INPUT_EOF 6
  222.24 -#define SZ_ERROR_OUTPUT_EOF 7
  222.25 -#define SZ_ERROR_READ 8
  222.26 -#define SZ_ERROR_WRITE 9
  222.27 -#define SZ_ERROR_PROGRESS 10
  222.28 -#define SZ_ERROR_FAIL 11
  222.29 -#define SZ_ERROR_THREAD 12
  222.30 -
  222.31 -#define SZ_ERROR_ARCHIVE 16
  222.32 -#define SZ_ERROR_NO_ARCHIVE 17
  222.33 -
  222.34 -typedef int SRes;
  222.35 -
  222.36 -#ifdef _WIN32
  222.37 -typedef DWORD WRes;
  222.38 -#else
  222.39 -typedef int WRes;
  222.40 -#endif
  222.41 -
  222.42 -#ifndef RINOK
  222.43 -#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
  222.44 -#endif
  222.45 -
  222.46 -typedef unsigned char Byte;
  222.47 -typedef short Int16;
  222.48 -typedef unsigned short UInt16;
  222.49 -
  222.50 -#ifdef _LZMA_UINT32_IS_ULONG
  222.51 -typedef long Int32;
  222.52 -typedef unsigned long UInt32;
  222.53 -#else
  222.54 -typedef int Int32;
  222.55 -typedef unsigned int UInt32;
  222.56 -#endif
  222.57 -
  222.58 -#ifdef _SZ_NO_INT_64
  222.59 -
  222.60 -/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
  222.61 -   NOTES: Some code will work incorrectly in that case! */
  222.62 -
  222.63 -typedef long Int64;
  222.64 -typedef unsigned long UInt64;
  222.65 -
  222.66 -#else
  222.67 -
  222.68 -#if defined(_MSC_VER) || defined(__BORLANDC__)
  222.69 -typedef __int64 Int64;
  222.70 -typedef unsigned __int64 UInt64;
  222.71 -#else
  222.72 -typedef long long int Int64;
  222.73 -typedef unsigned long long int UInt64;
  222.74 -#endif
  222.75 -
  222.76 -#endif
  222.77 -
  222.78 -#ifdef _LZMA_NO_SYSTEM_SIZE_T
  222.79 -typedef UInt32 SizeT;
  222.80 -#else
  222.81 -typedef size_t SizeT;
  222.82 -#endif
  222.83 -
  222.84 -typedef int Bool;
  222.85 -#define True 1
  222.86 -#define False 0
  222.87 -
  222.88 -
  222.89 -#ifdef _MSC_VER
  222.90 -
  222.91 -#if _MSC_VER >= 1300
  222.92 -#define MY_NO_INLINE __declspec(noinline)
  222.93 -#else
  222.94 -#define MY_NO_INLINE
  222.95 -#endif
  222.96 -
  222.97 -#define MY_CDECL __cdecl
  222.98 -#define MY_STD_CALL __stdcall
  222.99 -#define MY_FAST_CALL MY_NO_INLINE __fastcall
 222.100 -
 222.101 -#else
 222.102 -
 222.103 -#define MY_CDECL
 222.104 -#define MY_STD_CALL
 222.105 -#define MY_FAST_CALL
 222.106 -
 222.107 -#endif
 222.108 -
 222.109 -
 222.110 -/* The following interfaces use first parameter as pointer to structure */
 222.111 -
 222.112 -typedef struct
 222.113 -{
 222.114 -  SRes (*Read)(void *p, void *buf, size_t *size);
 222.115 -    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
 222.116 -       (output(*size) < input(*size)) is allowed */
 222.117 -} ISeqInStream;
 222.118 -
 222.119 -/* it can return SZ_ERROR_INPUT_EOF */
 222.120 -SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
 222.121 -SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
 222.122 -SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
 222.123 -
 222.124 -typedef struct
 222.125 -{
 222.126 -  size_t (*Write)(void *p, const void *buf, size_t size);
 222.127 -    /* Returns: result - the number of actually written bytes.
 222.128 -       (result < size) means error */
 222.129 -} ISeqOutStream;
 222.130 -
 222.131 -typedef enum
 222.132 -{
 222.133 -  SZ_SEEK_SET = 0,
 222.134 -  SZ_SEEK_CUR = 1,
 222.135 -  SZ_SEEK_END = 2
 222.136 -} ESzSeek;
 222.137 -
 222.138 -typedef struct
 222.139 -{
 222.140 -  SRes (*Read)(void *p, void *buf, size_t *size);  /* same as ISeqInStream::Read */
 222.141 -  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
 222.142 -} ISeekInStream;
 222.143 -
 222.144 -typedef struct
 222.145 -{
 222.146 -  SRes (*Look)(void *p, void **buf, size_t *size);
 222.147 -    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
 222.148 -       (output(*size) > input(*size)) is not allowed
 222.149 -       (output(*size) < input(*size)) is allowed */
 222.150 -  SRes (*Skip)(void *p, size_t offset);
 222.151 -    /* offset must be <= output(*size) of Look */
 222.152 -
 222.153 -  SRes (*Read)(void *p, void *buf, size_t *size);
 222.154 -    /* reads directly (without buffer). It's same as ISeqInStream::Read */
 222.155 -  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
 222.156 -} ILookInStream;
 222.157 -
 222.158 -SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
 222.159 -SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
 222.160 -
 222.161 -/* reads via ILookInStream::Read */
 222.162 -SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
 222.163 -SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
 222.164 -
 222.165 -#define LookToRead_BUF_SIZE (1 << 14)
 222.166 -
 222.167 -typedef struct
 222.168 -{
 222.169 -  ILookInStream s;
 222.170 -  ISeekInStream *realStream;
 222.171 -  size_t pos;
 222.172 -  size_t size;
 222.173 -  Byte buf[LookToRead_BUF_SIZE];
 222.174 -} CLookToRead;
 222.175 -
 222.176 -void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
 222.177 -void LookToRead_Init(CLookToRead *p);
 222.178 -
 222.179 -typedef struct
 222.180 -{
 222.181 -  ISeqInStream s;
 222.182 -  ILookInStream *realStream;
 222.183 -} CSecToLook;
 222.184 -
 222.185 -void SecToLook_CreateVTable(CSecToLook *p);
 222.186 -
 222.187 -typedef struct
 222.188 -{
 222.189 -  ISeqInStream s;
 222.190 -  ILookInStream *realStream;
 222.191 -} CSecToRead;
 222.192 -
 222.193 -void SecToRead_CreateVTable(CSecToRead *p);
 222.194 -
 222.195 -typedef struct
 222.196 -{
 222.197 -  SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
 222.198 -    /* Returns: result. (result != SZ_OK) means break.
 222.199 -       Value (UInt64)(Int64)-1 for size means unknown value. */
 222.200 -} ICompressProgress;
 222.201 -
 222.202 -typedef struct
 222.203 -{
 222.204 -  void *(*Alloc)(void *p, size_t size);
 222.205 -  void (*Free)(void *p, void *address); /* address can be 0 */
 222.206 -} ISzAlloc;
 222.207 -
 222.208 -#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
 222.209 -#define IAlloc_Free(p, a) (p)->Free((p), a)
 222.210 -
 222.211 -#endif
   223.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp	Sat Mar 03 10:54:39 2012 -0600
   223.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   223.3 @@ -1,3 +0,0 @@
   223.4 -// CompressionMethod.cpp
   223.5 -
   223.6 -#include "StdAfx.h"
   224.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zCompressionMode.h	Sat Mar 03 10:54:39 2012 -0600
   224.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   224.3 @@ -1,50 +0,0 @@
   224.4 -// 7zCompressionMode.h
   224.5 -
   224.6 -#ifndef __7Z_COMPRESSION_MODE_H
   224.7 -#define __7Z_COMPRESSION_MODE_H
   224.8 -
   224.9 -#include "../../../Common/MyString.h"
  224.10 -
  224.11 -#include "../../../Windows/PropVariant.h"
  224.12 -
  224.13 -#include "../../Common/MethodProps.h"
  224.14 -
  224.15 -namespace NArchive {
  224.16 -namespace N7z {
  224.17 -
  224.18 -struct CMethodFull: public CMethod
  224.19 -{
  224.20 -  UInt32 NumInStreams;
  224.21 -  UInt32 NumOutStreams;
  224.22 -  bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
  224.23 -};
  224.24 -
  224.25 -struct CBind
  224.26 -{
  224.27 -  UInt32 InCoder;
  224.28 -  UInt32 InStream;
  224.29 -  UInt32 OutCoder;
  224.30 -  UInt32 OutStream;
  224.31 -};
  224.32 -
  224.33 -struct CCompressionMethodMode
  224.34 -{
  224.35 -  CObjectVector<CMethodFull> Methods;
  224.36 -  CRecordVector<CBind> Binds;
  224.37 -  #ifdef COMPRESS_MT
  224.38 -  UInt32 NumThreads;
  224.39 -  #endif
  224.40 -  bool PasswordIsDefined;
  224.41 -  UString Password;
  224.42 -
  224.43 -  bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
  224.44 -  CCompressionMethodMode(): PasswordIsDefined(false)
  224.45 -      #ifdef COMPRESS_MT
  224.46 -      , NumThreads(1)
  224.47 -      #endif
  224.48 -  {}
  224.49 -};
  224.50 -
  224.51 -}}
  224.52 -
  224.53 -#endif
   225.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zDecode.cpp	Sat Mar 03 10:54:39 2012 -0600
   225.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   225.3 @@ -1,332 +0,0 @@
   225.4 -// 7zDecode.cpp
   225.5 -
   225.6 -#include "StdAfx.h"
   225.7 -
   225.8 -#include "../../Common/LimitedStreams.h"
   225.9 -#include "../../Common/LockedStream.h"
  225.10 -#include "../../Common/ProgressUtils.h"
  225.11 -#include "../../Common/StreamObjects.h"
  225.12 -
  225.13 -#include "7zDecode.h"
  225.14 -
  225.15 -namespace NArchive {
  225.16 -namespace N7z {
  225.17 -
  225.18 -static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
  225.19 -    CBindInfoEx &bindInfo)
  225.20 -{
  225.21 -  bindInfo.Clear();
  225.22 -  int i;
  225.23 -  for (i = 0; i < folder.BindPairs.Size(); i++)
  225.24 -  {
  225.25 -    NCoderMixer::CBindPair bindPair;
  225.26 -    bindPair.InIndex = (UInt32)folder.BindPairs[i].InIndex;
  225.27 -    bindPair.OutIndex = (UInt32)folder.BindPairs[i].OutIndex;
  225.28 -    bindInfo.BindPairs.Add(bindPair);
  225.29 -  }
  225.30 -  UInt32 outStreamIndex = 0;
  225.31 -  for (i = 0; i < folder.Coders.Size(); i++)
  225.32 -  {
  225.33 -    NCoderMixer::CCoderStreamsInfo coderStreamsInfo;
  225.34 -    const CCoderInfo &coderInfo = folder.Coders[i];
  225.35 -    coderStreamsInfo.NumInStreams = (UInt32)coderInfo.NumInStreams;
  225.36 -    coderStreamsInfo.NumOutStreams = (UInt32)coderInfo.NumOutStreams;
  225.37 -    bindInfo.Coders.Add(coderStreamsInfo);
  225.38 -    bindInfo.CoderMethodIDs.Add(coderInfo.MethodID);
  225.39 -    for (UInt32 j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)
  225.40 -      if (folder.FindBindPairForOutStream(outStreamIndex) < 0)
  225.41 -        bindInfo.OutStreams.Add(outStreamIndex);
  225.42 -  }
  225.43 -  for (i = 0; i < folder.PackStreams.Size(); i++)
  225.44 -    bindInfo.InStreams.Add((UInt32)folder.PackStreams[i]);
  225.45 -}
  225.46 -
  225.47 -static bool AreCodersEqual(const NCoderMixer::CCoderStreamsInfo &a1,
  225.48 -    const NCoderMixer::CCoderStreamsInfo &a2)
  225.49 -{
  225.50 -  return (a1.NumInStreams == a2.NumInStreams) &&
  225.51 -    (a1.NumOutStreams == a2.NumOutStreams);
  225.52 -}
  225.53 -
  225.54 -static bool AreBindPairsEqual(const NCoderMixer::CBindPair &a1, const NCoderMixer::CBindPair &a2)
  225.55 -{
  225.56 -  return (a1.InIndex == a2.InIndex) &&
  225.57 -    (a1.OutIndex == a2.OutIndex);
  225.58 -}
  225.59 -
  225.60 -static bool AreBindInfoExEqual(const CBindInfoEx &a1, const CBindInfoEx &a2)
  225.61 -{
  225.62 -  if (a1.Coders.Size() != a2.Coders.Size())
  225.63 -    return false;
  225.64 -  int i;
  225.65 -  for (i = 0; i < a1.Coders.Size(); i++)
  225.66 -    if (!AreCodersEqual(a1.Coders[i], a2.Coders[i]))
  225.67 -      return false;
  225.68 -  if (a1.BindPairs.Size() != a2.BindPairs.Size())
  225.69 -    return false;
  225.70 -  for (i = 0; i < a1.BindPairs.Size(); i++)
  225.71 -    if (!AreBindPairsEqual(a1.BindPairs[i], a2.BindPairs[i]))
  225.72 -      return false;
  225.73 -  for (i = 0; i < a1.CoderMethodIDs.Size(); i++)
  225.74 -    if (a1.CoderMethodIDs[i] != a2.CoderMethodIDs[i])
  225.75 -      return false;
  225.76 -  if (a1.InStreams.Size() != a2.InStreams.Size())
  225.77 -    return false;
  225.78 -  if (a1.OutStreams.Size() != a2.OutStreams.Size())
  225.79 -    return false;
  225.80 -  return true;
  225.81 -}
  225.82 -
  225.83 -CDecoder::CDecoder(bool multiThread)
  225.84 -{
  225.85 -  #ifndef _ST_MODE
  225.86 -  multiThread = true;
  225.87 -  #endif
  225.88 -  _multiThread = multiThread;
  225.89 -  _bindInfoExPrevIsDefined = false;
  225.90 -}
  225.91 -
  225.92 -HRESULT CDecoder::Decode(
  225.93 -    DECL_EXTERNAL_CODECS_LOC_VARS
  225.94 -    IInStream *inStream,
  225.95 -    UInt64 startPos,
  225.96 -    const UInt64 *packSizes,
  225.97 -    const CFolder &folderInfo,
  225.98 -    ISequentialOutStream *outStream,
  225.99 -    ICompressProgressInfo *compressProgress
 225.100 -    #ifndef _NO_CRYPTO
 225.101 -    , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 225.102 -    #endif
 225.103 -    #ifdef COMPRESS_MT
 225.104 -    , bool mtMode, UInt32 numThreads
 225.105 -    #endif
 225.106 -    )
 225.107 -{
 225.108 -  if (!folderInfo.CheckStructure())
 225.109 -    return E_NOTIMPL;
 225.110 -  #ifndef _NO_CRYPTO
 225.111 -  passwordIsDefined = false;
 225.112 -  #endif
 225.113 -  CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
 225.114 -  
 225.115 -  CLockedInStream lockedInStream;
 225.116 -  lockedInStream.Init(inStream);
 225.117 -  
 225.118 -  for (int j = 0; j < folderInfo.PackStreams.Size(); j++)
 225.119 -  {
 225.120 -    CLockedSequentialInStreamImp *lockedStreamImpSpec = new
 225.121 -        CLockedSequentialInStreamImp;
 225.122 -    CMyComPtr<ISequentialInStream> lockedStreamImp = lockedStreamImpSpec;
 225.123 -    lockedStreamImpSpec->Init(&lockedInStream, startPos);
 225.124 -    startPos += packSizes[j];
 225.125 -    
 225.126 -    CLimitedSequentialInStream *streamSpec = new
 225.127 -        CLimitedSequentialInStream;
 225.128 -    CMyComPtr<ISequentialInStream> inStream = streamSpec;
 225.129 -    streamSpec->SetStream(lockedStreamImp);
 225.130 -    streamSpec->Init(packSizes[j]);
 225.131 -    inStreams.Add(inStream);
 225.132 -  }
 225.133 -  
 225.134 -  int numCoders = folderInfo.Coders.Size();
 225.135 -  
 225.136 -  CBindInfoEx bindInfo;
 225.137 -  ConvertFolderItemInfoToBindInfo(folderInfo, bindInfo);
 225.138 -  bool createNewCoders;
 225.139 -  if (!_bindInfoExPrevIsDefined)
 225.140 -    createNewCoders = true;
 225.141 -  else
 225.142 -    createNewCoders = !AreBindInfoExEqual(bindInfo, _bindInfoExPrev);
 225.143 -  if (createNewCoders)
 225.144 -  {
 225.145 -    int i;
 225.146 -    _decoders.Clear();
 225.147 -    // _decoders2.Clear();
 225.148 -    
 225.149 -    _mixerCoder.Release();
 225.150 -
 225.151 -    if (_multiThread)
 225.152 -    {
 225.153 -      _mixerCoderMTSpec = new NCoderMixer::CCoderMixer2MT;
 225.154 -      _mixerCoder = _mixerCoderMTSpec;
 225.155 -      _mixerCoderCommon = _mixerCoderMTSpec;
 225.156 -    }
 225.157 -    else
 225.158 -    {
 225.159 -      #ifdef _ST_MODE
 225.160 -      _mixerCoderSTSpec = new NCoderMixer::CCoderMixer2ST;
 225.161 -      _mixerCoder = _mixerCoderSTSpec;
 225.162 -      _mixerCoderCommon = _mixerCoderSTSpec;
 225.163 -      #endif
 225.164 -    }
 225.165 -    RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
 225.166 -    
 225.167 -    for (i = 0; i < numCoders; i++)
 225.168 -    {
 225.169 -      const CCoderInfo &coderInfo = folderInfo.Coders[i];
 225.170 -
 225.171 -  
 225.172 -      CMyComPtr<ICompressCoder> decoder;
 225.173 -      CMyComPtr<ICompressCoder2> decoder2;
 225.174 -      RINOK(CreateCoder(
 225.175 -          EXTERNAL_CODECS_LOC_VARS
 225.176 -          coderInfo.MethodID, decoder, decoder2, false));
 225.177 -      CMyComPtr<IUnknown> decoderUnknown;
 225.178 -      if (coderInfo.IsSimpleCoder())
 225.179 -      {
 225.180 -        if (decoder == 0)
 225.181 -          return E_NOTIMPL;
 225.182 -
 225.183 -        decoderUnknown = (IUnknown *)decoder;
 225.184 -        
 225.185 -        if (_multiThread)
 225.186 -          _mixerCoderMTSpec->AddCoder(decoder);
 225.187 -        #ifdef _ST_MODE
 225.188 -        else
 225.189 -          _mixerCoderSTSpec->AddCoder(decoder, false);
 225.190 -        #endif
 225.191 -      }
 225.192 -      else
 225.193 -      {
 225.194 -        if (decoder2 == 0)
 225.195 -          return E_NOTIMPL;
 225.196 -        decoderUnknown = (IUnknown *)decoder2;
 225.197 -        if (_multiThread)
 225.198 -          _mixerCoderMTSpec->AddCoder2(decoder2);
 225.199 -        #ifdef _ST_MODE
 225.200 -        else
 225.201 -          _mixerCoderSTSpec->AddCoder2(decoder2, false);
 225.202 -        #endif
 225.203 -      }
 225.204 -      _decoders.Add(decoderUnknown);
 225.205 -      #ifdef EXTERNAL_CODECS
 225.206 -      CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
 225.207 -      decoderUnknown.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
 225.208 -      if (setCompressCodecsInfo)
 225.209 -      {
 225.210 -        RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
 225.211 -      }
 225.212 -      #endif
 225.213 -    }
 225.214 -    _bindInfoExPrev = bindInfo;
 225.215 -    _bindInfoExPrevIsDefined = true;
 225.216 -  }
 225.217 -  int i;
 225.218 -  _mixerCoderCommon->ReInit();
 225.219 -  
 225.220 -  UInt32 packStreamIndex = 0, unpackStreamIndex = 0;
 225.221 -  UInt32 coderIndex = 0;
 225.222 -  // UInt32 coder2Index = 0;
 225.223 -  
 225.224 -  for (i = 0; i < numCoders; i++)
 225.225 -  {
 225.226 -    const CCoderInfo &coderInfo = folderInfo.Coders[i];
 225.227 -    CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
 225.228 -    
 225.229 -    {
 225.230 -      CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
 225.231 -      decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
 225.232 -      if (setDecoderProperties)
 225.233 -      {
 225.234 -        const CByteBuffer &props = coderInfo.Props;
 225.235 -        size_t size = props.GetCapacity();
 225.236 -        if (size > 0xFFFFFFFF)
 225.237 -          return E_NOTIMPL;
 225.238 -        if (size > 0)
 225.239 -        {
 225.240 -          RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)props, (UInt32)size));
 225.241 -        }
 225.242 -      }
 225.243 -    }
 225.244 -
 225.245 -    #ifdef COMPRESS_MT
 225.246 -    if (mtMode)
 225.247 -    {
 225.248 -      CMyComPtr<ICompressSetCoderMt> setCoderMt;
 225.249 -      decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
 225.250 -      if (setCoderMt)
 225.251 -      {
 225.252 -        RINOK(setCoderMt->SetNumberOfThreads(numThreads));
 225.253 -      }
 225.254 -    }
 225.255 -    #endif
 225.256 -
 225.257 -    #ifndef _NO_CRYPTO
 225.258 -    {
 225.259 -      CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
 225.260 -      decoder.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
 225.261 -      if (cryptoSetPassword)
 225.262 -      {
 225.263 -        if (getTextPassword == 0)
 225.264 -          return E_FAIL;
 225.265 -        CMyComBSTR passwordBSTR;
 225.266 -        RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR));
 225.267 -        CByteBuffer buffer;
 225.268 -        passwordIsDefined = true;
 225.269 -        const UString password(passwordBSTR);
 225.270 -        const UInt32 sizeInBytes = password.Length() * 2;
 225.271 -        buffer.SetCapacity(sizeInBytes);
 225.272 -        for (int i = 0; i < password.Length(); i++)
 225.273 -        {
 225.274 -          wchar_t c = password[i];
 225.275 -          ((Byte *)buffer)[i * 2] = (Byte)c;
 225.276 -          ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
 225.277 -        }
 225.278 -        RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
 225.279 -      }
 225.280 -    }
 225.281 -    #endif
 225.282 -
 225.283 -    coderIndex++;
 225.284 -    
 225.285 -    UInt32 numInStreams = (UInt32)coderInfo.NumInStreams;
 225.286 -    UInt32 numOutStreams = (UInt32)coderInfo.NumOutStreams;
 225.287 -    CRecordVector<const UInt64 *> packSizesPointers;
 225.288 -    CRecordVector<const UInt64 *> unpackSizesPointers;
 225.289 -    packSizesPointers.Reserve(numInStreams);
 225.290 -    unpackSizesPointers.Reserve(numOutStreams);
 225.291 -    UInt32 j;
 225.292 -    for (j = 0; j < numOutStreams; j++, unpackStreamIndex++)
 225.293 -      unpackSizesPointers.Add(&folderInfo.UnpackSizes[unpackStreamIndex]);
 225.294 -    
 225.295 -    for (j = 0; j < numInStreams; j++, packStreamIndex++)
 225.296 -    {
 225.297 -      int bindPairIndex = folderInfo.FindBindPairForInStream(packStreamIndex);
 225.298 -      if (bindPairIndex >= 0)
 225.299 -        packSizesPointers.Add(
 225.300 -        &folderInfo.UnpackSizes[(UInt32)folderInfo.BindPairs[bindPairIndex].OutIndex]);
 225.301 -      else
 225.302 -      {
 225.303 -        int index = folderInfo.FindPackStreamArrayIndex(packStreamIndex);
 225.304 -        if (index < 0)
 225.305 -          return E_FAIL;
 225.306 -        packSizesPointers.Add(&packSizes[index]);
 225.307 -      }
 225.308 -    }
 225.309 -    
 225.310 -    _mixerCoderCommon->SetCoderInfo(i,
 225.311 -        &packSizesPointers.Front(),
 225.312 -        &unpackSizesPointers.Front());
 225.313 -  }
 225.314 -  UInt32 mainCoder, temp;
 225.315 -  bindInfo.FindOutStream(bindInfo.OutStreams[0], mainCoder, temp);
 225.316 -
 225.317 -  if (_multiThread)
 225.318 -    _mixerCoderMTSpec->SetProgressCoderIndex(mainCoder);
 225.319 -  /*
 225.320 -  else
 225.321 -    _mixerCoderSTSpec->SetProgressCoderIndex(mainCoder);;
 225.322 -  */
 225.323 -  
 225.324 -  if (numCoders == 0)
 225.325 -    return 0;
 225.326 -  CRecordVector<ISequentialInStream *> inStreamPointers;
 225.327 -  inStreamPointers.Reserve(inStreams.Size());
 225.328 -  for (i = 0; i < inStreams.Size(); i++)
 225.329 -    inStreamPointers.Add(inStreams[i]);
 225.330 -  ISequentialOutStream *outStreamPointer = outStream;
 225.331 -  return _mixerCoder->Code(&inStreamPointers.Front(), NULL,
 225.332 -    inStreams.Size(), &outStreamPointer, NULL, 1, compressProgress);
 225.333 -}
 225.334 -
 225.335 -}}
   226.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zDecode.h	Sat Mar 03 10:54:39 2012 -0600
   226.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   226.3 @@ -1,68 +0,0 @@
   226.4 -// 7zDecode.h
   226.5 -
   226.6 -#ifndef __7Z_DECODE_H
   226.7 -#define __7Z_DECODE_H
   226.8 -
   226.9 -#include "../../IStream.h"
  226.10 -#include "../../IPassword.h"
  226.11 -
  226.12 -#include "../Common/CoderMixer2.h"
  226.13 -#include "../Common/CoderMixer2MT.h"
  226.14 -#ifdef _ST_MODE
  226.15 -#include "../Common/CoderMixer2ST.h"
  226.16 -#endif
  226.17 -
  226.18 -#include "../../Common/CreateCoder.h"
  226.19 -
  226.20 -#include "7zItem.h"
  226.21 -
  226.22 -namespace NArchive {
  226.23 -namespace N7z {
  226.24 -
  226.25 -struct CBindInfoEx: public NCoderMixer::CBindInfo
  226.26 -{
  226.27 -  CRecordVector<CMethodId> CoderMethodIDs;
  226.28 -  void Clear()
  226.29 -  {
  226.30 -    CBindInfo::Clear();
  226.31 -    CoderMethodIDs.Clear();
  226.32 -  }
  226.33 -};
  226.34 -
  226.35 -class CDecoder
  226.36 -{
  226.37 -  bool _bindInfoExPrevIsDefined;
  226.38 -  CBindInfoEx _bindInfoExPrev;
  226.39 -  
  226.40 -  bool _multiThread;
  226.41 -  #ifdef _ST_MODE
  226.42 -  NCoderMixer::CCoderMixer2ST *_mixerCoderSTSpec;
  226.43 -  #endif
  226.44 -  NCoderMixer::CCoderMixer2MT *_mixerCoderMTSpec;
  226.45 -  NCoderMixer::CCoderMixer2 *_mixerCoderCommon;
  226.46 -  
  226.47 -  CMyComPtr<ICompressCoder2> _mixerCoder;
  226.48 -  CObjectVector<CMyComPtr<IUnknown> > _decoders;
  226.49 -  // CObjectVector<CMyComPtr<ICompressCoder2> > _decoders2;
  226.50 -public:
  226.51 -  CDecoder(bool multiThread);
  226.52 -  HRESULT Decode(
  226.53 -      DECL_EXTERNAL_CODECS_LOC_VARS
  226.54 -      IInStream *inStream,
  226.55 -      UInt64 startPos,
  226.56 -      const UInt64 *packSizes,
  226.57 -      const CFolder &folder,
  226.58 -      ISequentialOutStream *outStream,
  226.59 -      ICompressProgressInfo *compressProgress
  226.60 -      #ifndef _NO_CRYPTO
  226.61 -      , ICryptoGetTextPassword *getTextPasswordSpec, bool &passwordIsDefined
  226.62 -      #endif
  226.63 -      #ifdef COMPRESS_MT
  226.64 -      , bool mtMode, UInt32 numThreads
  226.65 -      #endif
  226.66 -      );
  226.67 -};
  226.68 -
  226.69 -}}
  226.70 -
  226.71 -#endif
   227.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zExtract.cpp	Sat Mar 03 10:54:39 2012 -0600
   227.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   227.3 @@ -1,273 +0,0 @@
   227.4 -// 7zExtract.cpp
   227.5 -
   227.6 -#include "StdAfx.h"
   227.7 -
   227.8 -#include "7zHandler.h"
   227.9 -#include "7zFolderOutStream.h"
  227.10 -#include "7zDecode.h"
  227.11 -// #include "7z1Decode.h"
  227.12 -
  227.13 -#include "../../../Common/ComTry.h"
  227.14 -#include "../../Common/StreamObjects.h"
  227.15 -#include "../../Common/ProgressUtils.h"
  227.16 -#include "../../Common/LimitedStreams.h"
  227.17 -
  227.18 -namespace NArchive {
  227.19 -namespace N7z {
  227.20 -
  227.21 -struct CExtractFolderInfo
  227.22 -{
  227.23 -  #ifdef _7Z_VOL
  227.24 -  int VolumeIndex;
  227.25 -  #endif
  227.26 -  CNum FileIndex;
  227.27 -  CNum FolderIndex;
  227.28 -  CBoolVector ExtractStatuses;
  227.29 -  UInt64 UnpackSize;
  227.30 -  CExtractFolderInfo(
  227.31 -    #ifdef _7Z_VOL
  227.32 -    int volumeIndex,
  227.33 -    #endif
  227.34 -    CNum fileIndex, CNum folderIndex):
  227.35 -    #ifdef _7Z_VOL
  227.36 -    VolumeIndex(volumeIndex),
  227.37 -    #endif
  227.38 -    FileIndex(fileIndex),
  227.39 -    FolderIndex(folderIndex),
  227.40 -    UnpackSize(0)
  227.41 -  {
  227.42 -    if (fileIndex != kNumNoIndex)
  227.43 -    {
  227.44 -      ExtractStatuses.Reserve(1);
  227.45 -      ExtractStatuses.Add(true);
  227.46 -    }
  227.47 -  };
  227.48 -};
  227.49 -
  227.50 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
  227.51 -    Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec)
  227.52 -{
  227.53 -  COM_TRY_BEGIN
  227.54 -  bool testMode = (testModeSpec != 0);
  227.55 -  CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
  227.56 -  UInt64 importantTotalUnpacked = 0;
  227.57 -
  227.58 -  bool allFilesMode = (numItems == UInt32(-1));
  227.59 -  if (allFilesMode)
  227.60 -    numItems =
  227.61 -    #ifdef _7Z_VOL
  227.62 -    _refs.Size();
  227.63 -    #else
  227.64 -    _db.Files.Size();
  227.65 -    #endif
  227.66 -
  227.67 -  if(numItems == 0)
  227.68 -    return S_OK;
  227.69 -
  227.70 -  /*
  227.71 -  if(_volumes.Size() != 1)
  227.72 -    return E_FAIL;
  227.73 -  const CVolume &volume = _volumes.Front();
  227.74 -  const CArchiveDatabaseEx &_db = volume.Database;
  227.75 -  IInStream *_inStream = volume.Stream;
  227.76 -  */
  227.77 -  
  227.78 -  CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
  227.79 -  for(UInt32 ii = 0; ii < numItems; ii++)
  227.80 -  {
  227.81 -    // UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
  227.82 -    UInt32 ref2Index = allFilesMode ? ii : indices[ii];
  227.83 -    // const CRef2 &ref2 = _refs[ref2Index];
  227.84 -
  227.85 -    // for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
  227.86 -    {
  227.87 -      #ifdef _7Z_VOL
  227.88 -      // const CRef &ref = ref2.Refs[ri];
  227.89 -      const CRef &ref = _refs[ref2Index];
  227.90 -
  227.91 -      int volumeIndex = ref.VolumeIndex;
  227.92 -      const CVolume &volume = _volumes[volumeIndex];
  227.93 -      const CArchiveDatabaseEx &db = volume.Database;
  227.94 -      UInt32 fileIndex = ref.ItemIndex;
  227.95 -      #else
  227.96 -      const CArchiveDatabaseEx &db = _db;
  227.97 -      UInt32 fileIndex = ref2Index;
  227.98 -      #endif
  227.99 -
 227.100 -      CNum folderIndex = db.FileIndexToFolderIndexMap[fileIndex];
 227.101 -      if (folderIndex == kNumNoIndex)
 227.102 -      {
 227.103 -        extractFolderInfoVector.Add(CExtractFolderInfo(
 227.104 -            #ifdef _7Z_VOL
 227.105 -            volumeIndex,
 227.106 -            #endif
 227.107 -            fileIndex, kNumNoIndex));
 227.108 -        continue;
 227.109 -      }
 227.110 -      if (extractFolderInfoVector.IsEmpty() ||
 227.111 -        folderIndex != extractFolderInfoVector.Back().FolderIndex
 227.112 -        #ifdef _7Z_VOL
 227.113 -        || volumeIndex != extractFolderInfoVector.Back().VolumeIndex
 227.114 -        #endif
 227.115 -        )
 227.116 -      {
 227.117 -        extractFolderInfoVector.Add(CExtractFolderInfo(
 227.118 -            #ifdef _7Z_VOL
 227.119 -            volumeIndex,
 227.120 -            #endif
 227.121 -            kNumNoIndex, folderIndex));
 227.122 -        const CFolder &folderInfo = db.Folders[folderIndex];
 227.123 -        UInt64 unpackSize = folderInfo.GetUnpackSize();
 227.124 -        importantTotalUnpacked += unpackSize;
 227.125 -        extractFolderInfoVector.Back().UnpackSize = unpackSize;
 227.126 -      }
 227.127 -      
 227.128 -      CExtractFolderInfo &efi = extractFolderInfoVector.Back();
 227.129 -      
 227.130 -      // const CFolderInfo &folderInfo = m_dam_Folders[folderIndex];
 227.131 -      CNum startIndex = db.FolderStartFileIndex[folderIndex];
 227.132 -      for (CNum index = efi.ExtractStatuses.Size();
 227.133 -          index <= fileIndex - startIndex; index++)
 227.134 -      {
 227.135 -        // UInt64 unpackSize = _db.Files[startIndex + index].UnpackSize;
 227.136 -        // Count partial_folder_size
 227.137 -        // efi.UnpackSize += unpackSize;
 227.138 -        // importantTotalUnpacked += unpackSize;
 227.139 -        efi.ExtractStatuses.Add(index == fileIndex - startIndex);
 227.140 -      }
 227.141 -    }
 227.142 -  }
 227.143 -
 227.144 -  extractCallback->SetTotal(importantTotalUnpacked);
 227.145 -
 227.146 -  CDecoder decoder(
 227.147 -    #ifdef _ST_MODE
 227.148 -    false
 227.149 -    #else
 227.150 -    true
 227.151 -    #endif
 227.152 -    );
 227.153 -  // CDecoder1 decoder;
 227.154 -
 227.155 -  UInt64 currentTotalPacked = 0;
 227.156 -  UInt64 currentTotalUnpacked = 0;
 227.157 -  UInt64 totalFolderUnpacked;
 227.158 -  UInt64 totalFolderPacked;
 227.159 -
 227.160 -  CLocalProgress *lps = new CLocalProgress;
 227.161 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 227.162 -  lps->Init(extractCallback, false);
 227.163 -
 227.164 -  for(int i = 0; i < extractFolderInfoVector.Size(); i++,
 227.165 -      currentTotalUnpacked += totalFolderUnpacked,
 227.166 -      currentTotalPacked += totalFolderPacked)
 227.167 -  {
 227.168 -    lps->OutSize = currentTotalUnpacked;
 227.169 -    lps->InSize = currentTotalPacked;
 227.170 -    RINOK(lps->SetCur());
 227.171 -    
 227.172 -    const CExtractFolderInfo &efi = extractFolderInfoVector[i];
 227.173 -    totalFolderUnpacked = efi.UnpackSize;
 227.174 -
 227.175 -    totalFolderPacked = 0;
 227.176 -
 227.177 -    CFolderOutStream *folderOutStream = new CFolderOutStream;
 227.178 -    CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
 227.179 -
 227.180 -    #ifdef _7Z_VOL
 227.181 -    const CVolume &volume = _volumes[efi.VolumeIndex];
 227.182 -    const CArchiveDatabaseEx &db = volume.Database;
 227.183 -    #else
 227.184 -    const CArchiveDatabaseEx &db = _db;
 227.185 -    #endif
 227.186 -
 227.187 -    CNum startIndex;
 227.188 -    if (efi.FileIndex != kNumNoIndex)
 227.189 -      startIndex = efi.FileIndex;
 227.190 -    else
 227.191 -      startIndex = db.FolderStartFileIndex[efi.FolderIndex];
 227.192 -
 227.193 -
 227.194 -    HRESULT result = folderOutStream->Init(&db,
 227.195 -        #ifdef _7Z_VOL
 227.196 -        volume.StartRef2Index,
 227.197 -        #else
 227.198 -        0,
 227.199 -        #endif
 227.200 -        startIndex,
 227.201 -        &efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
 227.202 -
 227.203 -    RINOK(result);
 227.204 -
 227.205 -    if (efi.FileIndex != kNumNoIndex)
 227.206 -      continue;
 227.207 -
 227.208 -    CNum folderIndex = efi.FolderIndex;
 227.209 -    const CFolder &folderInfo = db.Folders[folderIndex];
 227.210 -
 227.211 -    totalFolderPacked = _db.GetFolderFullPackSize(folderIndex);
 227.212 -
 227.213 -    CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
 227.214 -    UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);
 227.215 -
 227.216 -    #ifndef _NO_CRYPTO
 227.217 -    CMyComPtr<ICryptoGetTextPassword> getTextPassword;
 227.218 -    if (extractCallback)
 227.219 -      extractCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
 227.220 -    #endif
 227.221 -
 227.222 -    try
 227.223 -    {
 227.224 -      #ifndef _NO_CRYPTO
 227.225 -      bool passwordIsDefined;
 227.226 -      #endif
 227.227 -
 227.228 -      HRESULT result = decoder.Decode(
 227.229 -          EXTERNAL_CODECS_VARS
 227.230 -          #ifdef _7Z_VOL
 227.231 -          volume.Stream,
 227.232 -          #else
 227.233 -          _inStream,
 227.234 -          #endif
 227.235 -          folderStartPackPos,
 227.236 -          &db.PackSizes[packStreamIndex],
 227.237 -          folderInfo,
 227.238 -          outStream,
 227.239 -          progress
 227.240 -          #ifndef _NO_CRYPTO
 227.241 -          , getTextPassword, passwordIsDefined
 227.242 -          #endif
 227.243 -          #ifdef COMPRESS_MT
 227.244 -          , true, _numThreads
 227.245 -          #endif
 227.246 -          );
 227.247 -
 227.248 -      if (result == S_FALSE)
 227.249 -      {
 227.250 -        RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
 227.251 -        continue;
 227.252 -      }
 227.253 -      if (result == E_NOTIMPL)
 227.254 -      {
 227.255 -        RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 227.256 -        continue;
 227.257 -      }
 227.258 -      if (result != S_OK)
 227.259 -        return result;
 227.260 -      if (folderOutStream->WasWritingFinished() != S_OK)
 227.261 -      {
 227.262 -        RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
 227.263 -        continue;
 227.264 -      }
 227.265 -    }
 227.266 -    catch(...)
 227.267 -    {
 227.268 -      RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
 227.269 -      continue;
 227.270 -    }
 227.271 -  }
 227.272 -  return S_OK;
 227.273 -  COM_TRY_END
 227.274 -}
 227.275 -
 227.276 -}}
   228.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   228.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   228.3 @@ -1,130 +0,0 @@
   228.4 -// 7zFolderInStream.cpp
   228.5 -
   228.6 -#include "StdAfx.h"
   228.7 -
   228.8 -#include "7zFolderInStream.h"
   228.9 -
  228.10 -namespace NArchive {
  228.11 -namespace N7z {
  228.12 -
  228.13 -CFolderInStream::CFolderInStream()
  228.14 -{
  228.15 -  _inStreamWithHashSpec = new CSequentialInStreamWithCRC;
  228.16 -  _inStreamWithHash = _inStreamWithHashSpec;
  228.17 -}
  228.18 -
  228.19 -void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
  228.20 -    const UInt32 *fileIndices, UInt32 numFiles)
  228.21 -{
  228.22 -  _updateCallback = updateCallback;
  228.23 -  _numFiles = numFiles;
  228.24 -  _fileIndex = 0;
  228.25 -  _fileIndices = fileIndices;
  228.26 -  Processed.Clear();
  228.27 -  CRCs.Clear();
  228.28 -  Sizes.Clear();
  228.29 -  _fileIsOpen = false;
  228.30 -  _currentSizeIsDefined = false;
  228.31 -}
  228.32 -
  228.33 -HRESULT CFolderInStream::OpenStream()
  228.34 -{
  228.35 -  _filePos = 0;
  228.36 -  while (_fileIndex < _numFiles)
  228.37 -  {
  228.38 -    _currentSizeIsDefined = false;
  228.39 -    CMyComPtr<ISequentialInStream> stream;
  228.40 -    HRESULT result = _updateCallback->GetStream(_fileIndices[_fileIndex], &stream);
  228.41 -    if (result != S_OK && result != S_FALSE)
  228.42 -      return result;
  228.43 -    _fileIndex++;
  228.44 -    _inStreamWithHashSpec->SetStream(stream);
  228.45 -    _inStreamWithHashSpec->Init();
  228.46 -    if (!stream)
  228.47 -    {
  228.48 -      RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
  228.49 -      Sizes.Add(0);
  228.50 -      Processed.Add(result == S_OK);
  228.51 -      AddDigest();
  228.52 -      continue;
  228.53 -    }
  228.54 -    CMyComPtr<IStreamGetSize> streamGetSize;
  228.55 -    if (stream.QueryInterface(IID_IStreamGetSize, &streamGetSize) == S_OK)
  228.56 -    {
  228.57 -      if(streamGetSize)
  228.58 -      {
  228.59 -        _currentSizeIsDefined = true;
  228.60 -        RINOK(streamGetSize->GetSize(&_currentSize));
  228.61 -      }
  228.62 -    }
  228.63 -
  228.64 -    _fileIsOpen = true;
  228.65 -    return S_OK;
  228.66 -  }
  228.67 -  return S_OK;
  228.68 -}
  228.69 -
  228.70 -void CFolderInStream::AddDigest()
  228.71 -{
  228.72 -  CRCs.Add(_inStreamWithHashSpec->GetCRC());
  228.73 -}
  228.74 -
  228.75 -HRESULT CFolderInStream::CloseStream()
  228.76 -{
  228.77 -  RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
  228.78 -  _inStreamWithHashSpec->ReleaseStream();
  228.79 -  _fileIsOpen = false;
  228.80 -  Processed.Add(true);
  228.81 -  Sizes.Add(_filePos);
  228.82 -  AddDigest();
  228.83 -  return S_OK;
  228.84 -}
  228.85 -
  228.86 -STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
  228.87 -{
  228.88 -  UInt32 realProcessedSize = 0;
  228.89 -  while ((_fileIndex < _numFiles || _fileIsOpen) && size > 0)
  228.90 -  {
  228.91 -    if (_fileIsOpen)
  228.92 -    {
  228.93 -      UInt32 localProcessedSize;
  228.94 -      RINOK(_inStreamWithHash->Read(
  228.95 -          ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
  228.96 -      if (localProcessedSize == 0)
  228.97 -      {
  228.98 -        RINOK(CloseStream());
  228.99 -        continue;
 228.100 -      }
 228.101 -      realProcessedSize += localProcessedSize;
 228.102 -      _filePos += localProcessedSize;
 228.103 -      size -= localProcessedSize;
 228.104 -      break;
 228.105 -    }
 228.106 -    else
 228.107 -    {
 228.108 -      RINOK(OpenStream());
 228.109 -    }
 228.110 -  }
 228.111 -  if (processedSize != 0)
 228.112 -    *processedSize = realProcessedSize;
 228.113 -  return S_OK;
 228.114 -}
 228.115 -
 228.116 -STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
 228.117 -{
 228.118 -  *value = 0;
 228.119 -  int subStreamIndex = (int)subStream;
 228.120 -  if (subStreamIndex < 0 || subStream > Sizes.Size())
 228.121 -    return E_FAIL;
 228.122 -  if (subStreamIndex < Sizes.Size())
 228.123 -  {
 228.124 -    *value= Sizes[subStreamIndex];
 228.125 -    return S_OK;
 228.126 -  }
 228.127 -  if (!_currentSizeIsDefined)
 228.128 -    return S_FALSE;
 228.129 -  *value = _currentSize;
 228.130 -  return S_OK;
 228.131 -}
 228.132 -
 228.133 -}}
   229.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderInStream.h	Sat Mar 03 10:54:39 2012 -0600
   229.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   229.3 @@ -1,66 +0,0 @@
   229.4 -// 7z/FolderInStream.h
   229.5 -
   229.6 -#ifndef __7Z_FOLDERINSTREAM_H
   229.7 -#define __7Z_FOLDERINSTREAM_H
   229.8 -
   229.9 -#include "7zItem.h"
  229.10 -#include "7zHeader.h"
  229.11 -
  229.12 -#include "../IArchive.h"
  229.13 -#include "../Common/InStreamWithCRC.h"
  229.14 -#include "../../IStream.h"
  229.15 -#include "../../ICoder.h"
  229.16 -
  229.17 -namespace NArchive {
  229.18 -namespace N7z {
  229.19 -
  229.20 -class CFolderInStream:
  229.21 -  public ISequentialInStream,
  229.22 -  public ICompressGetSubStreamSize,
  229.23 -  public CMyUnknownImp
  229.24 -{
  229.25 -public:
  229.26 -
  229.27 -  MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)
  229.28 -
  229.29 -  CFolderInStream();
  229.30 -
  229.31 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  229.32 -
  229.33 -  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
  229.34 -private:
  229.35 -  CSequentialInStreamWithCRC *_inStreamWithHashSpec;
  229.36 -  CMyComPtr<ISequentialInStream> _inStreamWithHash;
  229.37 -  CMyComPtr<IArchiveUpdateCallback> _updateCallback;
  229.38 -
  229.39 -  bool _currentSizeIsDefined;
  229.40 -  UInt64 _currentSize;
  229.41 -
  229.42 -  bool _fileIsOpen;
  229.43 -  UInt64 _filePos;
  229.44 -
  229.45 -  const UInt32 *_fileIndices;
  229.46 -  UInt32 _numFiles;
  229.47 -  UInt32 _fileIndex;
  229.48 -
  229.49 -  HRESULT OpenStream();
  229.50 -  HRESULT CloseStream();
  229.51 -  void AddDigest();
  229.52 -public:
  229.53 -  void Init(IArchiveUpdateCallback *updateCallback,
  229.54 -      const UInt32 *fileIndices, UInt32 numFiles);
  229.55 -  CRecordVector<bool> Processed;
  229.56 -  CRecordVector<UInt32> CRCs;
  229.57 -  CRecordVector<UInt64> Sizes;
  229.58 -  UInt64 GetFullSize() const
  229.59 -  {
  229.60 -    UInt64 size = 0;
  229.61 -    for (int i = 0; i < Sizes.Size(); i++)
  229.62 -      size += Sizes[i];
  229.63 -    return size;
  229.64 -  }
  229.65 -};
  229.66 -
  229.67 -}}
  229.68 -
  229.69 -#endif
   230.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   230.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   230.3 @@ -1,164 +0,0 @@
   230.4 -// 7zFolderOutStream.cpp
   230.5 -
   230.6 -#include "StdAfx.h"
   230.7 -
   230.8 -#include "7zFolderOutStream.h"
   230.9 -
  230.10 -namespace NArchive {
  230.11 -namespace N7z {
  230.12 -
  230.13 -CFolderOutStream::CFolderOutStream()
  230.14 -{
  230.15 -  _outStreamWithHashSpec = new COutStreamWithCRC;
  230.16 -  _outStreamWithHash = _outStreamWithHashSpec;
  230.17 -}
  230.18 -
  230.19 -HRESULT CFolderOutStream::Init(
  230.20 -    const CArchiveDatabaseEx *archiveDatabase,
  230.21 -    UInt32 ref2Offset,
  230.22 -    UInt32 startIndex,
  230.23 -    const CBoolVector *extractStatuses,
  230.24 -    IArchiveExtractCallback *extractCallback,
  230.25 -    bool testMode,
  230.26 -    bool checkCrc)
  230.27 -{
  230.28 -  _archiveDatabase = archiveDatabase;
  230.29 -  _ref2Offset = ref2Offset;
  230.30 -  _startIndex = startIndex;
  230.31 -
  230.32 -  _extractStatuses = extractStatuses;
  230.33 -  _extractCallback = extractCallback;
  230.34 -  _testMode = testMode;
  230.35 -
  230.36 -  _checkCrc = checkCrc;
  230.37 -
  230.38 -  _currentIndex = 0;
  230.39 -  _fileIsOpen = false;
  230.40 -  return WriteEmptyFiles();
  230.41 -}
  230.42 -
  230.43 -HRESULT CFolderOutStream::OpenFile()
  230.44 -{
  230.45 -  Int32 askMode;
  230.46 -  if((*_extractStatuses)[_currentIndex])
  230.47 -    askMode = _testMode ?
  230.48 -        NArchive::NExtract::NAskMode::kTest :
  230.49 -        NArchive::NExtract::NAskMode::kExtract;
  230.50 -  else
  230.51 -    askMode = NArchive::NExtract::NAskMode::kSkip;
  230.52 -  CMyComPtr<ISequentialOutStream> realOutStream;
  230.53 -
  230.54 -  UInt32 index = _startIndex + _currentIndex;
  230.55 -  RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
  230.56 -
  230.57 -  _outStreamWithHashSpec->SetStream(realOutStream);
  230.58 -  _outStreamWithHashSpec->Init(_checkCrc);
  230.59 -  if (askMode == NArchive::NExtract::NAskMode::kExtract &&
  230.60 -      (!realOutStream))
  230.61 -  {
  230.62 -    const CFileItem &fi = _archiveDatabase->Files[index];
  230.63 -    if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir)
  230.64 -      askMode = NArchive::NExtract::NAskMode::kSkip;
  230.65 -  }
  230.66 -  return _extractCallback->PrepareOperation(askMode);
  230.67 -}
  230.68 -
  230.69 -HRESULT CFolderOutStream::WriteEmptyFiles()
  230.70 -{
  230.71 -  for(;_currentIndex < _extractStatuses->Size(); _currentIndex++)
  230.72 -  {
  230.73 -    UInt32 index = _startIndex + _currentIndex;
  230.74 -    const CFileItem &fi = _archiveDatabase->Files[index];
  230.75 -    if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir && fi.Size != 0)
  230.76 -      return S_OK;
  230.77 -    RINOK(OpenFile());
  230.78 -    RINOK(_extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
  230.79 -    _outStreamWithHashSpec->ReleaseStream();
  230.80 -  }
  230.81 -  return S_OK;
  230.82 -}
  230.83 -
  230.84 -STDMETHODIMP CFolderOutStream::Write(const void *data,
  230.85 -    UInt32 size, UInt32 *processedSize)
  230.86 -{
  230.87 -  UInt32 realProcessedSize = 0;
  230.88 -  while(_currentIndex < _extractStatuses->Size())
  230.89 -  {
  230.90 -    if (_fileIsOpen)
  230.91 -    {
  230.92 -      UInt32 index = _startIndex + _currentIndex;
  230.93 -      const CFileItem &fi = _archiveDatabase->Files[index];
  230.94 -      UInt64 fileSize = fi.Size;
  230.95 -      
  230.96 -      UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos,
  230.97 -          UInt64(size - realProcessedSize));
  230.98 -      
  230.99 -      UInt32 processedSizeLocal;
 230.100 -      RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize,
 230.101 -            numBytesToWrite, &processedSizeLocal));
 230.102 -
 230.103 -      _filePos += processedSizeLocal;
 230.104 -      realProcessedSize += processedSizeLocal;
 230.105 -      if (_filePos == fileSize)
 230.106 -      {
 230.107 -        bool digestsAreEqual;
 230.108 -        if (fi.CrcDefined && _checkCrc)
 230.109 -          digestsAreEqual = fi.Crc == _outStreamWithHashSpec->GetCRC();
 230.110 -        else
 230.111 -          digestsAreEqual = true;
 230.112 -
 230.113 -        RINOK(_extractCallback->SetOperationResult(
 230.114 -            digestsAreEqual ?
 230.115 -            NArchive::NExtract::NOperationResult::kOK :
 230.116 -            NArchive::NExtract::NOperationResult::kCRCError));
 230.117 -        _outStreamWithHashSpec->ReleaseStream();
 230.118 -        _fileIsOpen = false;
 230.119 -        _currentIndex++;
 230.120 -      }
 230.121 -      if (realProcessedSize == size)
 230.122 -      {
 230.123 -        if (processedSize != NULL)
 230.124 -          *processedSize = realProcessedSize;
 230.125 -        return WriteEmptyFiles();
 230.126 -      }
 230.127 -    }
 230.128 -    else
 230.129 -    {
 230.130 -      RINOK(OpenFile());
 230.131 -      _fileIsOpen = true;
 230.132 -      _filePos = 0;
 230.133 -    }
 230.134 -  }
 230.135 -  if (processedSize != NULL)
 230.136 -    *processedSize = size;
 230.137 -  return S_OK;
 230.138 -}
 230.139 -
 230.140 -HRESULT CFolderOutStream::FlushCorrupted(Int32 resultEOperationResult)
 230.141 -{
 230.142 -  while(_currentIndex < _extractStatuses->Size())
 230.143 -  {
 230.144 -    if (_fileIsOpen)
 230.145 -    {
 230.146 -      RINOK(_extractCallback->SetOperationResult(resultEOperationResult));
 230.147 -      _outStreamWithHashSpec->ReleaseStream();
 230.148 -      _fileIsOpen = false;
 230.149 -      _currentIndex++;
 230.150 -    }
 230.151 -    else
 230.152 -    {
 230.153 -      RINOK(OpenFile());
 230.154 -      _fileIsOpen = true;
 230.155 -    }
 230.156 -  }
 230.157 -  return S_OK;
 230.158 -}
 230.159 -
 230.160 -HRESULT CFolderOutStream::WasWritingFinished()
 230.161 -{
 230.162 -  if (_currentIndex == _extractStatuses->Size())
 230.163 -    return S_OK;
 230.164 -  return E_FAIL;
 230.165 -}
 230.166 -
 230.167 -}}
   231.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h	Sat Mar 03 10:54:39 2012 -0600
   231.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   231.3 @@ -1,60 +0,0 @@
   231.4 -// 7zFolderOutStream.h
   231.5 -
   231.6 -#ifndef __7Z_FOLDEROUTSTREAM_H
   231.7 -#define __7Z_FOLDEROUTSTREAM_H
   231.8 -
   231.9 -#include "7zIn.h"
  231.10 -
  231.11 -#include "../../IStream.h"
  231.12 -#include "../IArchive.h"
  231.13 -#include "../Common/OutStreamWithCRC.h"
  231.14 -
  231.15 -namespace NArchive {
  231.16 -namespace N7z {
  231.17 -
  231.18 -class CFolderOutStream:
  231.19 -  public ISequentialOutStream,
  231.20 -  public CMyUnknownImp
  231.21 -{
  231.22 -public:
  231.23 -  MY_UNKNOWN_IMP
  231.24 -  
  231.25 -  CFolderOutStream();
  231.26 -
  231.27 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  231.28 -private:
  231.29 -
  231.30 -  COutStreamWithCRC *_outStreamWithHashSpec;
  231.31 -  CMyComPtr<ISequentialOutStream> _outStreamWithHash;
  231.32 -  const CArchiveDatabaseEx *_archiveDatabase;
  231.33 -  const CBoolVector *_extractStatuses;
  231.34 -  UInt32 _startIndex;
  231.35 -  UInt32 _ref2Offset;
  231.36 -  int _currentIndex;
  231.37 -  // UInt64 _currentDataPos;
  231.38 -  CMyComPtr<IArchiveExtractCallback> _extractCallback;
  231.39 -  bool _testMode;
  231.40 -
  231.41 -  bool _fileIsOpen;
  231.42 -
  231.43 -  bool _checkCrc;
  231.44 -  UInt64 _filePos;
  231.45 -
  231.46 -  HRESULT OpenFile();
  231.47 -  HRESULT WriteEmptyFiles();
  231.48 -public:
  231.49 -  HRESULT Init(
  231.50 -      const CArchiveDatabaseEx *archiveDatabase,
  231.51 -      UInt32 ref2Offset,
  231.52 -      UInt32 startIndex,
  231.53 -      const CBoolVector *extractStatuses,
  231.54 -      IArchiveExtractCallback *extractCallback,
  231.55 -      bool testMode,
  231.56 -      bool checkCrc);
  231.57 -  HRESULT FlushCorrupted(Int32 resultEOperationResult);
  231.58 -  HRESULT WasWritingFinished();
  231.59 -};
  231.60 -
  231.61 -}}
  231.62 -
  231.63 -#endif
   232.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   232.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   232.3 @@ -1,503 +0,0 @@
   232.4 -// 7zHandler.cpp
   232.5 -
   232.6 -#include "StdAfx.h"
   232.7 -
   232.8 -extern "C"
   232.9 -{
  232.10 -  #include "../../../../C/CpuArch.h"
  232.11 -}
  232.12 -
  232.13 -#include "../../../Common/ComTry.h"
  232.14 -#include "../../../Common/IntToString.h"
  232.15 -
  232.16 -#ifdef COMPRESS_MT
  232.17 -#include "../../../Windows/System.h"
  232.18 -#endif
  232.19 -
  232.20 -#include "../Common/ItemNameUtils.h"
  232.21 -
  232.22 -#include "7zHandler.h"
  232.23 -#include "7zProperties.h"
  232.24 -
  232.25 -#ifdef __7Z_SET_PROPERTIES
  232.26 -#ifdef EXTRACT_ONLY
  232.27 -#include "../Common/ParseProperties.h"
  232.28 -#endif
  232.29 -#endif
  232.30 -
  232.31 -using namespace NWindows;
  232.32 -
  232.33 -extern UString ConvertMethodIdToString(UInt64 id);
  232.34 -
  232.35 -namespace NArchive {
  232.36 -namespace N7z {
  232.37 -
  232.38 -CHandler::CHandler()
  232.39 -{
  232.40 -  _crcSize = 4;
  232.41 -
  232.42 -  #ifndef _NO_CRYPTO
  232.43 -  _passwordIsDefined = false;
  232.44 -  #endif
  232.45 -
  232.46 -  #ifdef EXTRACT_ONLY
  232.47 -  #ifdef COMPRESS_MT
  232.48 -  _numThreads = NSystem::GetNumberOfProcessors();
  232.49 -  #endif
  232.50 -  #else
  232.51 -  Init();
  232.52 -  #endif
  232.53 -}
  232.54 -
  232.55 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
  232.56 -{
  232.57 -  *numItems = _db.Files.Size();
  232.58 -  return S_OK;
  232.59 -}
  232.60 -
  232.61 -#ifdef _SFX
  232.62 -
  232.63 -IMP_IInArchive_ArcProps_NO
  232.64 -
  232.65 -STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 * /* numProperties */)
  232.66 -{
  232.67 -  return E_NOTIMPL;
  232.68 -}
  232.69 -
  232.70 -STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
  232.71 -      BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
  232.72 -{
  232.73 -  return E_NOTIMPL;
  232.74 -}
  232.75 -
  232.76 -
  232.77 -#else
  232.78 -
  232.79 -STATPROPSTG kArcProps[] =
  232.80 -{
  232.81 -  { NULL, kpidMethod, VT_BSTR},
  232.82 -  { NULL, kpidSolid, VT_BOOL},
  232.83 -  { NULL, kpidNumBlocks, VT_UI4},
  232.84 -  { NULL, kpidPhySize, VT_UI8},
  232.85 -  { NULL, kpidHeadersSize, VT_UI8},
  232.86 -  { NULL, kpidOffset, VT_UI8}
  232.87 -};
  232.88 -
  232.89 -STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
  232.90 -{
  232.91 -  COM_TRY_BEGIN
  232.92 -  NCOM::CPropVariant prop;
  232.93 -  switch(propID)
  232.94 -  {
  232.95 -    case kpidMethod:
  232.96 -    {
  232.97 -      UString resString;
  232.98 -      CRecordVector<UInt64> ids;
  232.99 -      int i;
 232.100 -      for (i = 0; i < _db.Folders.Size(); i++)
 232.101 -      {
 232.102 -        const CFolder &f = _db.Folders[i];
 232.103 -        for (int j = f.Coders.Size() - 1; j >= 0; j--)
 232.104 -          ids.AddToUniqueSorted(f.Coders[j].MethodID);
 232.105 -      }
 232.106 -
 232.107 -      for (i = 0; i < ids.Size(); i++)
 232.108 -      {
 232.109 -        UInt64 id = ids[i];
 232.110 -        UString methodName;
 232.111 -        /* bool methodIsKnown = */ FindMethod(EXTERNAL_CODECS_VARS id, methodName);
 232.112 -        if (methodName.IsEmpty())
 232.113 -          methodName = ConvertMethodIdToString(id);
 232.114 -        if (!resString.IsEmpty())
 232.115 -          resString += L' ';
 232.116 -        resString += methodName;
 232.117 -      }
 232.118 -      prop = resString;
 232.119 -      break;
 232.120 -    }
 232.121 -    case kpidSolid: prop = _db.IsSolid(); break;
 232.122 -    case kpidNumBlocks: prop = (UInt32)_db.Folders.Size(); break;
 232.123 -    case kpidHeadersSize:  prop = _db.HeadersSize; break;
 232.124 -    case kpidPhySize:  prop = _db.PhySize; break;
 232.125 -    case kpidOffset: if (_db.ArchiveInfo.StartPosition != 0) prop = _db.ArchiveInfo.StartPosition; break;
 232.126 -  }
 232.127 -  prop.Detach(value);
 232.128 -  return S_OK;
 232.129 -  COM_TRY_END
 232.130 -}
 232.131 -
 232.132 -IMP_IInArchive_ArcProps
 232.133 -
 232.134 -#endif
 232.135 -
 232.136 -static void SetPropFromUInt64Def(CUInt64DefVector &v, int index, NCOM::CPropVariant &prop)
 232.137 -{
 232.138 -  UInt64 value;
 232.139 -  if (v.GetItem(index, value))
 232.140 -  {
 232.141 -    FILETIME ft;
 232.142 -    ft.dwLowDateTime = (DWORD)value;
 232.143 -    ft.dwHighDateTime = (DWORD)(value >> 32);
 232.144 -    prop = ft;
 232.145 -  }
 232.146 -}
 232.147 -
 232.148 -#ifndef _SFX
 232.149 -
 232.150 -static UString ConvertUInt32ToString(UInt32 value)
 232.151 -{
 232.152 -  wchar_t buffer[32];
 232.153 -  ConvertUInt64ToString(value, buffer);
 232.154 -  return buffer;
 232.155 -}
 232.156 -
 232.157 -static UString GetStringForSizeValue(UInt32 value)
 232.158 -{
 232.159 -  for (int i = 31; i >= 0; i--)
 232.160 -    if ((UInt32(1) << i) == value)
 232.161 -      return ConvertUInt32ToString(i);
 232.162 -  UString result;
 232.163 -  if (value % (1 << 20) == 0)
 232.164 -  {
 232.165 -    result += ConvertUInt32ToString(value >> 20);
 232.166 -    result += L"m";
 232.167 -  }
 232.168 -  else if (value % (1 << 10) == 0)
 232.169 -  {
 232.170 -    result += ConvertUInt32ToString(value >> 10);
 232.171 -    result += L"k";
 232.172 -  }
 232.173 -  else
 232.174 -  {
 232.175 -    result += ConvertUInt32ToString(value);
 232.176 -    result += L"b";
 232.177 -  }
 232.178 -  return result;
 232.179 -}
 232.180 -
 232.181 -static const UInt64 k_Copy = 0x0;
 232.182 -static const UInt64 k_LZMA  = 0x030101;
 232.183 -static const UInt64 k_PPMD  = 0x030401;
 232.184 -
 232.185 -static wchar_t GetHex(Byte value)
 232.186 -{
 232.187 -  return (wchar_t)((value < 10) ? (L'0' + value) : (L'A' + (value - 10)));
 232.188 -}
 232.189 -static inline UString GetHex2(Byte value)
 232.190 -{
 232.191 -  UString result;
 232.192 -  result += GetHex((Byte)(value >> 4));
 232.193 -  result += GetHex((Byte)(value & 0xF));
 232.194 -  return result;
 232.195 -}
 232.196 -
 232.197 -#endif
 232.198 -
 232.199 -static const UInt64 k_AES  = 0x06F10701;
 232.200 -
 232.201 -bool CHandler::IsEncrypted(UInt32 index2) const
 232.202 -{
 232.203 -  CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
 232.204 -  if (folderIndex != kNumNoIndex)
 232.205 -  {
 232.206 -    const CFolder &folderInfo = _db.Folders[folderIndex];
 232.207 -    for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
 232.208 -      if (folderInfo.Coders[i].MethodID == k_AES)
 232.209 -        return true;
 232.210 -  }
 232.211 -  return false;
 232.212 -}
 232.213 -
 232.214 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
 232.215 -{
 232.216 -  COM_TRY_BEGIN
 232.217 -  NCOM::CPropVariant prop;
 232.218 -  
 232.219 -  /*
 232.220 -  const CRef2 &ref2 = _refs[index];
 232.221 -  if (ref2.Refs.IsEmpty())
 232.222 -    return E_FAIL;
 232.223 -  const CRef &ref = ref2.Refs.Front();
 232.224 -  */
 232.225 -  
 232.226 -  const CFileItem &item = _db.Files[index];
 232.227 -  UInt32 index2 = index;
 232.228 -
 232.229 -  switch(propID)
 232.230 -  {
 232.231 -    case kpidPath:
 232.232 -      if (!item.Name.IsEmpty())
 232.233 -        prop = NItemName::GetOSName(item.Name);
 232.234 -      break;
 232.235 -    case kpidIsDir:  prop = item.IsDir; break;
 232.236 -    case kpidSize:
 232.237 -    {
 232.238 -      prop = item.Size;
 232.239 -      // prop = ref2.Size;
 232.240 -      break;
 232.241 -    }
 232.242 -    case kpidPackSize:
 232.243 -    {
 232.244 -      // prop = ref2.PackSize;
 232.245 -      {
 232.246 -        CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
 232.247 -        if (folderIndex != kNumNoIndex)
 232.248 -        {
 232.249 -          if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2)
 232.250 -            prop = _db.GetFolderFullPackSize(folderIndex);
 232.251 -          /*
 232.252 -          else
 232.253 -            prop = (UInt64)0;
 232.254 -          */
 232.255 -        }
 232.256 -        else
 232.257 -          prop = (UInt64)0;
 232.258 -      }
 232.259 -      break;
 232.260 -    }
 232.261 -    case kpidPosition:  { UInt64 v; if (_db.StartPos.GetItem(index2, v)) prop = v; break; }
 232.262 -    case kpidCTime:  SetPropFromUInt64Def(_db.CTime, index2, prop); break;
 232.263 -    case kpidATime:  SetPropFromUInt64Def(_db.ATime, index2, prop); break;
 232.264 -    case kpidMTime:  SetPropFromUInt64Def(_db.MTime, index2, prop); break;
 232.265 -    case kpidAttrib:  if (item.AttribDefined) prop = item.Attrib; break;
 232.266 -    case kpidCRC:  if (item.CrcDefined) prop = item.Crc; break;
 232.267 -    case kpidEncrypted:  prop = IsEncrypted(index2); break;
 232.268 -    case kpidIsAnti:  prop = _db.IsItemAnti(index2); break;
 232.269 -    #ifndef _SFX
 232.270 -    case kpidMethod:
 232.271 -      {
 232.272 -        CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
 232.273 -        if (folderIndex != kNumNoIndex)
 232.274 -        {
 232.275 -          const CFolder &folderInfo = _db.Folders[folderIndex];
 232.276 -          UString methodsString;
 232.277 -          for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
 232.278 -          {
 232.279 -            const CCoderInfo &coderInfo = folderInfo.Coders[i];
 232.280 -            if (!methodsString.IsEmpty())
 232.281 -              methodsString += L' ';
 232.282 -
 232.283 -            {
 232.284 -              UString methodName;
 232.285 -              bool methodIsKnown = FindMethod(
 232.286 -                  EXTERNAL_CODECS_VARS
 232.287 -                  coderInfo.MethodID, methodName);
 232.288 -
 232.289 -              if (methodIsKnown)
 232.290 -              {
 232.291 -                methodsString += methodName;
 232.292 -                if (coderInfo.MethodID == k_LZMA)
 232.293 -                {
 232.294 -                  if (coderInfo.Props.GetCapacity() >= 5)
 232.295 -                  {
 232.296 -                    methodsString += L":";
 232.297 -                    UInt32 dicSize = GetUi32((const Byte *)coderInfo.Props + 1);
 232.298 -                    methodsString += GetStringForSizeValue(dicSize);
 232.299 -                  }
 232.300 -                }
 232.301 -                else if (coderInfo.MethodID == k_PPMD)
 232.302 -                {
 232.303 -                  if (coderInfo.Props.GetCapacity() >= 5)
 232.304 -                  {
 232.305 -                    Byte order = *(const Byte *)coderInfo.Props;
 232.306 -                    methodsString += L":o";
 232.307 -                    methodsString += ConvertUInt32ToString(order);
 232.308 -                    methodsString += L":mem";
 232.309 -                    UInt32 dicSize = GetUi32((const Byte *)coderInfo.Props + 1);
 232.310 -                    methodsString += GetStringForSizeValue(dicSize);
 232.311 -                  }
 232.312 -                }
 232.313 -                else if (coderInfo.MethodID == k_AES)
 232.314 -                {
 232.315 -                  if (coderInfo.Props.GetCapacity() >= 1)
 232.316 -                  {
 232.317 -                    methodsString += L":";
 232.318 -                    const Byte *data = (const Byte *)coderInfo.Props;
 232.319 -                    Byte firstByte = *data++;
 232.320 -                    UInt32 numCyclesPower = firstByte & 0x3F;
 232.321 -                    methodsString += ConvertUInt32ToString(numCyclesPower);
 232.322 -                    /*
 232.323 -                    if ((firstByte & 0xC0) != 0)
 232.324 -                    {
 232.325 -                      methodsString += L":";
 232.326 -                      return S_OK;
 232.327 -                      UInt32 saltSize = (firstByte >> 7) & 1;
 232.328 -                      UInt32 ivSize = (firstByte >> 6) & 1;
 232.329 -                      if (coderInfo.Props.GetCapacity() >= 2)
 232.330 -                      {
 232.331 -                        Byte secondByte = *data++;
 232.332 -                        saltSize += (secondByte >> 4);
 232.333 -                        ivSize += (secondByte & 0x0F);
 232.334 -                      }
 232.335 -                    }
 232.336 -                    */
 232.337 -                  }
 232.338 -                }
 232.339 -                else
 232.340 -                {
 232.341 -                  if (coderInfo.Props.GetCapacity() > 0)
 232.342 -                  {
 232.343 -                    methodsString += L":[";
 232.344 -                    for (size_t bi = 0; bi < coderInfo.Props.GetCapacity(); bi++)
 232.345 -                    {
 232.346 -                      if (bi > 5 && bi + 1 < coderInfo.Props.GetCapacity())
 232.347 -                      {
 232.348 -                        methodsString += L"..";
 232.349 -                        break;
 232.350 -                      }
 232.351 -                      else
 232.352 -                        methodsString += GetHex2(coderInfo.Props[bi]);
 232.353 -                    }
 232.354 -                    methodsString += L"]";
 232.355 -                  }
 232.356 -                }
 232.357 -              }
 232.358 -              else
 232.359 -              {
 232.360 -                methodsString += ConvertMethodIdToString(coderInfo.MethodID);
 232.361 -              }
 232.362 -            }
 232.363 -          }
 232.364 -          prop = methodsString;
 232.365 -        }
 232.366 -      }
 232.367 -      break;
 232.368 -    case kpidBlock:
 232.369 -      {
 232.370 -        CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
 232.371 -        if (folderIndex != kNumNoIndex)
 232.372 -          prop = (UInt32)folderIndex;
 232.373 -      }
 232.374 -      break;
 232.375 -    case kpidPackedSize0:
 232.376 -    case kpidPackedSize1:
 232.377 -    case kpidPackedSize2:
 232.378 -    case kpidPackedSize3:
 232.379 -    case kpidPackedSize4:
 232.380 -      {
 232.381 -        CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
 232.382 -        if (folderIndex != kNumNoIndex)
 232.383 -        {
 232.384 -          const CFolder &folderInfo = _db.Folders[folderIndex];
 232.385 -          if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
 232.386 -              folderInfo.PackStreams.Size() > (int)(propID - kpidPackedSize0))
 232.387 -          {
 232.388 -            prop = _db.GetFolderPackStreamSize(folderIndex, propID - kpidPackedSize0);
 232.389 -          }
 232.390 -          else
 232.391 -            prop = (UInt64)0;
 232.392 -        }
 232.393 -        else
 232.394 -          prop = (UInt64)0;
 232.395 -      }
 232.396 -      break;
 232.397 -    #endif
 232.398 -  }
 232.399 -  prop.Detach(value);
 232.400 -  return S_OK;
 232.401 -  COM_TRY_END
 232.402 -}
 232.403 -
 232.404 -STDMETHODIMP CHandler::Open(IInStream *stream,
 232.405 -    const UInt64 *maxCheckStartPosition,
 232.406 -    IArchiveOpenCallback *openArchiveCallback)
 232.407 -{
 232.408 -  COM_TRY_BEGIN
 232.409 -  Close();
 232.410 -  #ifndef _SFX
 232.411 -  _fileInfoPopIDs.Clear();
 232.412 -  #endif
 232.413 -  try
 232.414 -  {
 232.415 -    CMyComPtr<IArchiveOpenCallback> openArchiveCallbackTemp = openArchiveCallback;
 232.416 -
 232.417 -    #ifndef _NO_CRYPTO
 232.418 -    CMyComPtr<ICryptoGetTextPassword> getTextPassword;
 232.419 -    if (openArchiveCallback)
 232.420 -    {
 232.421 -      openArchiveCallbackTemp.QueryInterface(
 232.422 -          IID_ICryptoGetTextPassword, &getTextPassword);
 232.423 -    }
 232.424 -    #endif
 232.425 -    CInArchive archive;
 232.426 -    RINOK(archive.Open(stream, maxCheckStartPosition));
 232.427 -    #ifndef _NO_CRYPTO
 232.428 -    _passwordIsDefined = false;
 232.429 -    UString password;
 232.430 -    #endif
 232.431 -    HRESULT result = archive.ReadDatabase(
 232.432 -      EXTERNAL_CODECS_VARS
 232.433 -      _db
 232.434 -      #ifndef _NO_CRYPTO
 232.435 -      , getTextPassword, _passwordIsDefined
 232.436 -      #endif
 232.437 -      );
 232.438 -    RINOK(result);
 232.439 -    _db.Fill();
 232.440 -    _inStream = stream;
 232.441 -  }
 232.442 -  catch(...)
 232.443 -  {
 232.444 -    Close();
 232.445 -    return S_FALSE;
 232.446 -  }
 232.447 -  // _inStream = stream;
 232.448 -  #ifndef _SFX
 232.449 -  FillPopIDs();
 232.450 -  #endif
 232.451 -  return S_OK;
 232.452 -  COM_TRY_END
 232.453 -}
 232.454 -
 232.455 -STDMETHODIMP CHandler::Close()
 232.456 -{
 232.457 -  COM_TRY_BEGIN
 232.458 -  _inStream.Release();
 232.459 -  _db.Clear();
 232.460 -  return S_OK;
 232.461 -  COM_TRY_END
 232.462 -}
 232.463 -
 232.464 -#ifdef __7Z_SET_PROPERTIES
 232.465 -#ifdef EXTRACT_ONLY
 232.466 -
 232.467 -STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
 232.468 -{
 232.469 -  COM_TRY_BEGIN
 232.470 -  #ifdef COMPRESS_MT
 232.471 -  const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
 232.472 -  _numThreads = numProcessors;
 232.473 -  #endif
 232.474 -
 232.475 -  for (int i = 0; i < numProperties; i++)
 232.476 -  {
 232.477 -    UString name = names[i];
 232.478 -    name.MakeUpper();
 232.479 -    if (name.IsEmpty())
 232.480 -      return E_INVALIDARG;
 232.481 -    const PROPVARIANT &value = values[i];
 232.482 -    UInt32 number;
 232.483 -    int index = ParseStringToUInt32(name, number);
 232.484 -    if (index == 0)
 232.485 -    {
 232.486 -      if(name.Left(2).CompareNoCase(L"MT") == 0)
 232.487 -      {
 232.488 -        #ifdef COMPRESS_MT
 232.489 -        RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
 232.490 -        #endif
 232.491 -        continue;
 232.492 -      }
 232.493 -      else
 232.494 -        return E_INVALIDARG;
 232.495 -    }
 232.496 -  }
 232.497 -  return S_OK;
 232.498 -  COM_TRY_END
 232.499 -}
 232.500 -
 232.501 -#endif
 232.502 -#endif
 232.503 -
 232.504 -IMPL_ISetCompressCodecsInfo
 232.505 -
 232.506 -}}
   233.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHandler.h	Sat Mar 03 10:54:39 2012 -0600
   233.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   233.3 @@ -1,121 +0,0 @@
   233.4 -// 7z/Handler.h
   233.5 -
   233.6 -#ifndef __7Z_HANDLER_H
   233.7 -#define __7Z_HANDLER_H
   233.8 -
   233.9 -#include "../../ICoder.h"
  233.10 -#include "../IArchive.h"
  233.11 -#include "7zIn.h"
  233.12 -
  233.13 -#include "7zCompressionMode.h"
  233.14 -
  233.15 -#include "../../Common/CreateCoder.h"
  233.16 -
  233.17 -#ifndef EXTRACT_ONLY
  233.18 -#include "../Common/HandlerOut.h"
  233.19 -#endif
  233.20 -
  233.21 -namespace NArchive {
  233.22 -namespace N7z {
  233.23 -
  233.24 -#ifndef __7Z_SET_PROPERTIES
  233.25 -
  233.26 -#ifdef EXTRACT_ONLY
  233.27 -#ifdef COMPRESS_MT
  233.28 -#define __7Z_SET_PROPERTIES
  233.29 -#endif
  233.30 -#else
  233.31 -#define __7Z_SET_PROPERTIES
  233.32 -#endif
  233.33 -
  233.34 -#endif
  233.35 -
  233.36 -
  233.37 -class CHandler:
  233.38 -  #ifndef EXTRACT_ONLY
  233.39 -  public NArchive::COutHandler,
  233.40 -  #endif
  233.41 -  public IInArchive,
  233.42 -  #ifdef __7Z_SET_PROPERTIES
  233.43 -  public ISetProperties,
  233.44 -  #endif
  233.45 -  #ifndef EXTRACT_ONLY
  233.46 -  public IOutArchive,
  233.47 -  #endif
  233.48 -  PUBLIC_ISetCompressCodecsInfo
  233.49 -  public CMyUnknownImp
  233.50 -{
  233.51 -public:
  233.52 -  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  233.53 -  #ifdef __7Z_SET_PROPERTIES
  233.54 -  MY_QUERYINTERFACE_ENTRY(ISetProperties)
  233.55 -  #endif
  233.56 -  #ifndef EXTRACT_ONLY
  233.57 -  MY_QUERYINTERFACE_ENTRY(IOutArchive)
  233.58 -  #endif
  233.59 -  QUERY_ENTRY_ISetCompressCodecsInfo
  233.60 -  MY_QUERYINTERFACE_END
  233.61 -  MY_ADDREF_RELEASE
  233.62 -
  233.63 -  INTERFACE_IInArchive(;)
  233.64 -
  233.65 -  #ifdef __7Z_SET_PROPERTIES
  233.66 -  STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
  233.67 -  #endif
  233.68 -
  233.69 -  #ifndef EXTRACT_ONLY
  233.70 -  INTERFACE_IOutArchive(;)
  233.71 -  #endif
  233.72 -
  233.73 -  DECL_ISetCompressCodecsInfo
  233.74 -
  233.75 -  CHandler();
  233.76 -
  233.77 -private:
  233.78 -  CMyComPtr<IInStream> _inStream;
  233.79 -  NArchive::N7z::CArchiveDatabaseEx _db;
  233.80 -  #ifndef _NO_CRYPTO
  233.81 -  bool _passwordIsDefined;
  233.82 -  #endif
  233.83 -
  233.84 -  #ifdef EXTRACT_ONLY
  233.85 -  
  233.86 -  #ifdef COMPRESS_MT
  233.87 -  UInt32 _numThreads;
  233.88 -  #endif
  233.89 -
  233.90 -  UInt32 _crcSize;
  233.91 -
  233.92 -  #else
  233.93 -  
  233.94 -  CRecordVector<CBind> _binds;
  233.95 -
  233.96 -  HRESULT SetPassword(CCompressionMethodMode &methodMode, IArchiveUpdateCallback *updateCallback);
  233.97 -
  233.98 -  HRESULT SetCompressionMethod(CCompressionMethodMode &method,
  233.99 -      CObjectVector<COneMethodInfo> &methodsInfo
 233.100 -      #ifdef COMPRESS_MT
 233.101 -      , UInt32 numThreads
 233.102 -      #endif
 233.103 -      );
 233.104 -
 233.105 -  HRESULT SetCompressionMethod(
 233.106 -      CCompressionMethodMode &method,
 233.107 -      CCompressionMethodMode &headerMethod);
 233.108 -
 233.109 -  #endif
 233.110 -
 233.111 -  bool IsEncrypted(UInt32 index2) const;
 233.112 -  #ifndef _SFX
 233.113 -
 233.114 -  CRecordVector<UInt64> _fileInfoPopIDs;
 233.115 -  void FillPopIDs();
 233.116 -
 233.117 -  #endif
 233.118 -
 233.119 -  DECL_EXTERNAL_CODECS_VARS
 233.120 -};
 233.121 -
 233.122 -}}
 233.123 -
 233.124 -#endif
   234.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHeader.cpp	Sat Mar 03 10:54:39 2012 -0600
   234.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   234.3 @@ -1,27 +0,0 @@
   234.4 -// 7z/Header.cpp
   234.5 -
   234.6 -#include "StdAfx.h"
   234.7 -#include "7zHeader.h"
   234.8 -
   234.9 -namespace NArchive {
  234.10 -namespace N7z {
  234.11 -
  234.12 -Byte kSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C};
  234.13 -#ifdef _7Z_VOL
  234.14 -Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C + 1};
  234.15 -#endif
  234.16 -
  234.17 -class SignatureInitializer
  234.18 -{
  234.19 -public:
  234.20 -  SignatureInitializer()
  234.21 -  {
  234.22 -    kSignature[0]--;
  234.23 -    #ifdef _7Z_VOL
  234.24 -    kFinishSignature[0]--;
  234.25 -    #endif
  234.26 -  };
  234.27 -} g_SignatureInitializer;
  234.28 -
  234.29 -}}
  234.30 -
   235.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zHeader.h	Sat Mar 03 10:54:39 2012 -0600
   235.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   235.3 @@ -1,97 +0,0 @@
   235.4 -// 7z/7zHeader.h
   235.5 -
   235.6 -#ifndef __7Z_HEADER_H
   235.7 -#define __7Z_HEADER_H
   235.8 -
   235.9 -#include "../../../Common/Types.h"
  235.10 -
  235.11 -namespace NArchive {
  235.12 -namespace N7z {
  235.13 -
  235.14 -const int kSignatureSize = 6;
  235.15 -extern Byte kSignature[kSignatureSize];
  235.16 -
  235.17 -// #define _7Z_VOL
  235.18 -// 7z-MultiVolume is not finished yet.
  235.19 -// It can work already, but I still do not like some
  235.20 -// things of that new multivolume format.
  235.21 -// So please keep it commented.
  235.22 -
  235.23 -#ifdef _7Z_VOL
  235.24 -extern Byte kFinishSignature[kSignatureSize];
  235.25 -#endif
  235.26 -
  235.27 -struct CArchiveVersion
  235.28 -{
  235.29 -  Byte Major;
  235.30 -  Byte Minor;
  235.31 -};
  235.32 -
  235.33 -const Byte kMajorVersion = 0;
  235.34 -
  235.35 -struct CStartHeader
  235.36 -{
  235.37 -  UInt64 NextHeaderOffset;
  235.38 -  UInt64 NextHeaderSize;
  235.39 -  UInt32 NextHeaderCRC;
  235.40 -};
  235.41 -
  235.42 -const UInt32 kStartHeaderSize = 20;
  235.43 -
  235.44 -#ifdef _7Z_VOL
  235.45 -struct CFinishHeader: public CStartHeader
  235.46 -{
  235.47 -  UInt64 ArchiveStartOffset;  // data offset from end if that struct
  235.48 -  UInt64 AdditionalStartBlockSize; // start  signature & start header size
  235.49 -};
  235.50 -
  235.51 -const UInt32 kFinishHeaderSize = kStartHeaderSize + 16;
  235.52 -#endif
  235.53 -
  235.54 -namespace NID
  235.55 -{
  235.56 -  enum EEnum
  235.57 -  {
  235.58 -    kEnd,
  235.59 -
  235.60 -    kHeader,
  235.61 -
  235.62 -    kArchiveProperties,
  235.63 -    
  235.64 -    kAdditionalStreamsInfo,
  235.65 -    kMainStreamsInfo,
  235.66 -    kFilesInfo,
  235.67 -    
  235.68 -    kPackInfo,
  235.69 -    kUnpackInfo,
  235.70 -    kSubStreamsInfo,
  235.71 -
  235.72 -    kSize,
  235.73 -    kCRC,
  235.74 -
  235.75 -    kFolder,
  235.76 -
  235.77 -    kCodersUnpackSize,
  235.78 -    kNumUnpackStream,
  235.79 -
  235.80 -    kEmptyStream,
  235.81 -    kEmptyFile,
  235.82 -    kAnti,
  235.83 -
  235.84 -    kName,
  235.85 -    kCTime,
  235.86 -    kATime,
  235.87 -    kMTime,
  235.88 -    kWinAttributes,
  235.89 -    kComment,
  235.90 -
  235.91 -    kEncodedHeader,
  235.92 -
  235.93 -    kStartPos,
  235.94 -    kDummy
  235.95 -  };
  235.96 -}
  235.97 -
  235.98 -}}
  235.99 -
 235.100 -#endif
   236.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   236.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   236.3 @@ -1,1260 +0,0 @@
   236.4 -// 7zIn.cpp
   236.5 -
   236.6 -#include "StdAfx.h"
   236.7 -
   236.8 -extern "C"
   236.9 -{
  236.10 -  #include "../../../../C/7zCrc.h"
  236.11 -  #include "../../../../C/CpuArch.h"
  236.12 -}
  236.13 -
  236.14 -#include "../../Common/StreamObjects.h"
  236.15 -#include "../../Common/StreamUtils.h"
  236.16 -
  236.17 -#include "7zDecode.h"
  236.18 -#include "7zIn.h"
  236.19 -
  236.20 -#define Get16(p) GetUi16(p)
  236.21 -#define Get32(p) GetUi32(p)
  236.22 -#define Get64(p) GetUi64(p)
  236.23 -
  236.24 -// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
  236.25 -#ifndef _SFX
  236.26 -#define FORMAT_7Z_RECOVERY
  236.27 -#endif
  236.28 -
  236.29 -namespace NArchive {
  236.30 -namespace N7z {
  236.31 -
  236.32 -static void BoolVector_Fill_False(CBoolVector &v, int size)
  236.33 -{
  236.34 -  v.Clear();
  236.35 -  v.Reserve(size);
  236.36 -  for (int i = 0; i < size; i++)
  236.37 -    v.Add(false);
  236.38 -}
  236.39 -
  236.40 -static bool BoolVector_GetAndSet(CBoolVector &v, UInt32 index)
  236.41 -{
  236.42 -  if (index >= (UInt32)v.Size())
  236.43 -    return true;
  236.44 -  bool res = v[index];
  236.45 -  v[index] = true;
  236.46 -  return res;
  236.47 -}
  236.48 -
  236.49 -bool CFolder::CheckStructure() const
  236.50 -{
  236.51 -  const int kNumCodersMax = sizeof(UInt32) * 8; // don't change it
  236.52 -  const int kMaskSize = sizeof(UInt32) * 8; // it must be >= kNumCodersMax
  236.53 -  const int kNumBindsMax = 32;
  236.54 -
  236.55 -  if (Coders.Size() > kNumCodersMax || BindPairs.Size() > kNumBindsMax)
  236.56 -    return false;
  236.57 -
  236.58 -  {
  236.59 -    CBoolVector v;
  236.60 -    BoolVector_Fill_False(v, BindPairs.Size() + PackStreams.Size());
  236.61 -    
  236.62 -    int i;
  236.63 -    for (i = 0; i < BindPairs.Size(); i++)
  236.64 -      if (BoolVector_GetAndSet(v, BindPairs[i].InIndex))
  236.65 -        return false;
  236.66 -    for (i = 0; i < PackStreams.Size(); i++)
  236.67 -      if (BoolVector_GetAndSet(v, PackStreams[i]))
  236.68 -        return false;
  236.69 -    
  236.70 -    BoolVector_Fill_False(v, UnpackSizes.Size());
  236.71 -    for (i = 0; i < BindPairs.Size(); i++)
  236.72 -      if (BoolVector_GetAndSet(v, BindPairs[i].OutIndex))
  236.73 -        return false;
  236.74 -  }
  236.75 -  
  236.76 -  UInt32 mask[kMaskSize];
  236.77 -  int i;
  236.78 -  for (i = 0; i < kMaskSize; i++)
  236.79 -    mask[i] = 0;
  236.80 -
  236.81 -  {
  236.82 -    CIntVector inStreamToCoder, outStreamToCoder;
  236.83 -    for (i = 0; i < Coders.Size(); i++)
  236.84 -    {
  236.85 -      CNum j;
  236.86 -      const CCoderInfo &coder = Coders[i];
  236.87 -      for (j = 0; j < coder.NumInStreams; j++)
  236.88 -        inStreamToCoder.Add(i);
  236.89 -      for (j = 0; j < coder.NumOutStreams; j++)
  236.90 -        outStreamToCoder.Add(i);
  236.91 -    }
  236.92 -    
  236.93 -    for (i = 0; i < BindPairs.Size(); i++)
  236.94 -    {
  236.95 -      const CBindPair &bp = BindPairs[i];
  236.96 -      mask[inStreamToCoder[bp.InIndex]] |= (1 << outStreamToCoder[bp.OutIndex]);
  236.97 -    }
  236.98 -  }
  236.99 -  
 236.100 -  for (i = 0; i < kMaskSize; i++)
 236.101 -    for (int j = 0; j < kMaskSize; j++)
 236.102 -      if (((1 << j) & mask[i]) != 0)
 236.103 -        mask[i] |= mask[j];
 236.104 -
 236.105 -  for (i = 0; i < kMaskSize; i++)
 236.106 -    if (((1 << i) & mask[i]) != 0)
 236.107 -      return false;
 236.108 -
 236.109 -  return true;
 236.110 -}
 236.111 -
 236.112 -class CInArchiveException {};
 236.113 -
 236.114 -static void ThrowException() { throw CInArchiveException(); }
 236.115 -static inline void ThrowEndOfData()   { ThrowException(); }
 236.116 -static inline void ThrowUnsupported() { ThrowException(); }
 236.117 -static inline void ThrowIncorrect()   { ThrowException(); }
 236.118 -static inline void ThrowUnsupportedVersion() { ThrowException(); }
 236.119 -
 236.120 -/*
 236.121 -class CInArchiveException
 236.122 -{
 236.123 -public:
 236.124 -  enum CCauseType
 236.125 -  {
 236.126 -    kUnsupportedVersion = 0,
 236.127 -    kUnsupported,
 236.128 -    kIncorrect,
 236.129 -    kEndOfData,
 236.130 -  } Cause;
 236.131 -  CInArchiveException(CCauseType cause): Cause(cause) {};
 236.132 -};
 236.133 -
 236.134 -static void ThrowException(CInArchiveException::CCauseType c) { throw CInArchiveException(c); }
 236.135 -static void ThrowEndOfData()   { ThrowException(CInArchiveException::kEndOfData); }
 236.136 -static void ThrowUnsupported() { ThrowException(CInArchiveException::kUnsupported); }
 236.137 -static void ThrowIncorrect()   { ThrowException(CInArchiveException::kIncorrect); }
 236.138 -static void ThrowUnsupportedVersion() { ThrowException(CInArchiveException::kUnsupportedVersion); }
 236.139 -*/
 236.140 -
 236.141 -class CStreamSwitch
 236.142 -{
 236.143 -  CInArchive *_archive;
 236.144 -  bool _needRemove;
 236.145 -public:
 236.146 -  CStreamSwitch(): _needRemove(false) {}
 236.147 -  ~CStreamSwitch() { Remove(); }
 236.148 -  void Remove();
 236.149 -  void Set(CInArchive *archive, const Byte *data, size_t size);
 236.150 -  void Set(CInArchive *archive, const CByteBuffer &byteBuffer);
 236.151 -  void Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector);
 236.152 -};
 236.153 -
 236.154 -void CStreamSwitch::Remove()
 236.155 -{
 236.156 -  if (_needRemove)
 236.157 -  {
 236.158 -    _archive->DeleteByteStream();
 236.159 -    _needRemove = false;
 236.160 -  }
 236.161 -}
 236.162 -
 236.163 -void CStreamSwitch::Set(CInArchive *archive, const Byte *data, size_t size)
 236.164 -{
 236.165 -  Remove();
 236.166 -  _archive = archive;
 236.167 -  _archive->AddByteStream(data, size);
 236.168 -  _needRemove = true;
 236.169 -}
 236.170 -
 236.171 -void CStreamSwitch::Set(CInArchive *archive, const CByteBuffer &byteBuffer)
 236.172 -{
 236.173 -  Set(archive, byteBuffer, byteBuffer.GetCapacity());
 236.174 -}
 236.175 -
 236.176 -void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector)
 236.177 -{
 236.178 -  Remove();
 236.179 -  Byte external = archive->ReadByte();
 236.180 -  if (external != 0)
 236.181 -  {
 236.182 -    int dataIndex = (int)archive->ReadNum();
 236.183 -    if (dataIndex < 0 || dataIndex >= dataVector->Size())
 236.184 -      ThrowIncorrect();
 236.185 -    Set(archive, (*dataVector)[dataIndex]);
 236.186 -  }
 236.187 -}
 236.188 -
 236.189 -Byte CInByte2::ReadByte()
 236.190 -{
 236.191 -  if (_pos >= _size)
 236.192 -    ThrowEndOfData();
 236.193 -  return _buffer[_pos++];
 236.194 -}
 236.195 -
 236.196 -void CInByte2::ReadBytes(Byte *data, size_t size)
 236.197 -{
 236.198 -  if (size > _size - _pos)
 236.199 -    ThrowEndOfData();
 236.200 -  for (size_t i = 0; i < size; i++)
 236.201 -    data[i] = _buffer[_pos++];
 236.202 -}
 236.203 -
 236.204 -void CInByte2::SkeepData(UInt64 size)
 236.205 -{
 236.206 -  if (size > _size - _pos)
 236.207 -    ThrowEndOfData();
 236.208 -  _pos += (size_t)size;
 236.209 -}
 236.210 -
 236.211 -void CInByte2::SkeepData()
 236.212 -{
 236.213 -  SkeepData(ReadNumber());
 236.214 -}
 236.215 -
 236.216 -UInt64 CInByte2::ReadNumber()
 236.217 -{
 236.218 -  if (_pos >= _size)
 236.219 -    ThrowEndOfData();
 236.220 -  Byte firstByte = _buffer[_pos++];
 236.221 -  Byte mask = 0x80;
 236.222 -  UInt64 value = 0;
 236.223 -  for (int i = 0; i < 8; i++)
 236.224 -  {
 236.225 -    if ((firstByte & mask) == 0)
 236.226 -    {
 236.227 -      UInt64 highPart = firstByte & (mask - 1);
 236.228 -      value += (highPart << (i * 8));
 236.229 -      return value;
 236.230 -    }
 236.231 -    if (_pos >= _size)
 236.232 -      ThrowEndOfData();
 236.233 -    value |= ((UInt64)_buffer[_pos++] << (8 * i));
 236.234 -    mask >>= 1;
 236.235 -  }
 236.236 -  return value;
 236.237 -}
 236.238 -
 236.239 -CNum CInByte2::ReadNum()
 236.240 -{
 236.241 -  UInt64 value = ReadNumber();
 236.242 -  if (value > kNumMax)
 236.243 -    ThrowUnsupported();
 236.244 -  return (CNum)value;
 236.245 -}
 236.246 -
 236.247 -UInt32 CInByte2::ReadUInt32()
 236.248 -{
 236.249 -  if (_pos + 4 > _size)
 236.250 -    ThrowEndOfData();
 236.251 -  UInt32 res = Get32(_buffer + _pos);
 236.252 -  _pos += 4;
 236.253 -  return res;
 236.254 -}
 236.255 -
 236.256 -UInt64 CInByte2::ReadUInt64()
 236.257 -{
 236.258 -  if (_pos + 8 > _size)
 236.259 -    ThrowEndOfData();
 236.260 -  UInt64 res = Get64(_buffer + _pos);
 236.261 -  _pos += 8;
 236.262 -  return res;
 236.263 -}
 236.264 -
 236.265 -void CInByte2::ReadString(UString &s)
 236.266 -{
 236.267 -  const Byte *buf = _buffer + _pos;
 236.268 -  size_t rem = (_size - _pos) / 2 * 2;
 236.269 -  {
 236.270 -    size_t i;
 236.271 -    for (i = 0; i < rem; i += 2)
 236.272 -      if (buf[i] == 0 && buf[i + 1] == 0)
 236.273 -        break;
 236.274 -    if (i == rem)
 236.275 -      ThrowEndOfData();
 236.276 -    rem = i;
 236.277 -  }
 236.278 -  int len = (int)(rem / 2);
 236.279 -  if (len < 0 || (size_t)len * 2 != rem)
 236.280 -    ThrowUnsupported();
 236.281 -  wchar_t *p = s.GetBuffer(len);
 236.282 -  int i;
 236.283 -  for (i = 0; i < len; i++, buf += 2)
 236.284 -    p[i] = (wchar_t)Get16(buf);
 236.285 -  s.ReleaseBuffer(len);
 236.286 -  _pos += rem + 2;
 236.287 -}
 236.288 -
 236.289 -static inline bool TestSignatureCandidate(const Byte *p)
 236.290 -{
 236.291 -  for (int i = 0; i < kSignatureSize; i++)
 236.292 -    if (p[i] != kSignature[i])
 236.293 -      return false;
 236.294 -  return (p[0x1A] == 0 && p[0x1B] == 0);
 236.295 -}
 236.296 -
 236.297 -HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
 236.298 -{
 236.299 -  RINOK(ReadStream_FALSE(stream, _header, kHeaderSize));
 236.300 -
 236.301 -  if (TestSignatureCandidate(_header))
 236.302 -    return S_OK;
 236.303 -
 236.304 -  CByteBuffer byteBuffer;
 236.305 -  const UInt32 kBufferSize = (1 << 16);
 236.306 -  byteBuffer.SetCapacity(kBufferSize);
 236.307 -  Byte *buffer = byteBuffer;
 236.308 -  UInt32 numPrevBytes = kHeaderSize - 1;
 236.309 -  memcpy(buffer, _header + 1, numPrevBytes);
 236.310 -  UInt64 curTestPos = _arhiveBeginStreamPosition + 1;
 236.311 -  for (;;)
 236.312 -  {
 236.313 -    if (searchHeaderSizeLimit != NULL)
 236.314 -      if (curTestPos - _arhiveBeginStreamPosition > *searchHeaderSizeLimit)
 236.315 -        break;
 236.316 -    do
 236.317 -    {
 236.318 -      UInt32 numReadBytes = kBufferSize - numPrevBytes;
 236.319 -      UInt32 processedSize;
 236.320 -      RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
 236.321 -      numPrevBytes += processedSize;
 236.322 -      if (processedSize == 0)
 236.323 -        return S_FALSE;
 236.324 -    }
 236.325 -    while (numPrevBytes < kHeaderSize);
 236.326 -    UInt32 numTests = numPrevBytes - kHeaderSize + 1;
 236.327 -    for (UInt32 pos = 0; pos < numTests; pos++)
 236.328 -    {
 236.329 -      for (; buffer[pos] != '7' && pos < numTests; pos++);
 236.330 -      if (pos == numTests)
 236.331 -        break;
 236.332 -      if (TestSignatureCandidate(buffer + pos))
 236.333 -      {
 236.334 -        memcpy(_header, buffer + pos, kHeaderSize);
 236.335 -        curTestPos += pos;
 236.336 -        _arhiveBeginStreamPosition = curTestPos;
 236.337 -        return stream->Seek(curTestPos + kHeaderSize, STREAM_SEEK_SET, NULL);
 236.338 -      }
 236.339 -    }
 236.340 -    curTestPos += numTests;
 236.341 -    numPrevBytes -= numTests;
 236.342 -    memmove(buffer, buffer + numTests, numPrevBytes);
 236.343 -  }
 236.344 -  return S_FALSE;
 236.345 -}
 236.346 -
 236.347 -// S_FALSE means that file is not archive
 236.348 -HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
 236.349 -{
 236.350 -  HeadersSize = 0;
 236.351 -  Close();
 236.352 -  RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
 236.353 -  RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
 236.354 -  _stream = stream;
 236.355 -  return S_OK;
 236.356 -}
 236.357 -  
 236.358 -void CInArchive::Close()
 236.359 -{
 236.360 -  _stream.Release();
 236.361 -}
 236.362 -
 236.363 -void CInArchive::ReadArchiveProperties(CInArchiveInfo & /* archiveInfo */)
 236.364 -{
 236.365 -  for (;;)
 236.366 -  {
 236.367 -    if (ReadID() == NID::kEnd)
 236.368 -      break;
 236.369 -    SkeepData();
 236.370 -  }
 236.371 -}
 236.372 -
 236.373 -void CInArchive::GetNextFolderItem(CFolder &folder)
 236.374 -{
 236.375 -  CNum numCoders = ReadNum();
 236.376 -
 236.377 -  folder.Coders.Clear();
 236.378 -  folder.Coders.Reserve((int)numCoders);
 236.379 -  CNum numInStreams = 0;
 236.380 -  CNum numOutStreams = 0;
 236.381 -  CNum i;
 236.382 -  for (i = 0; i < numCoders; i++)
 236.383 -  {
 236.384 -    folder.Coders.Add(CCoderInfo());
 236.385 -    CCoderInfo &coder = folder.Coders.Back();
 236.386 -
 236.387 -    {
 236.388 -      Byte mainByte = ReadByte();
 236.389 -      int idSize = (mainByte & 0xF);
 236.390 -      Byte longID[15];
 236.391 -      ReadBytes(longID, idSize);
 236.392 -      if (idSize > 8)
 236.393 -        ThrowUnsupported();
 236.394 -      UInt64 id = 0;
 236.395 -      for (int j = 0; j < idSize; j++)
 236.396 -        id |= (UInt64)longID[idSize - 1 - j] << (8 * j);
 236.397 -      coder.MethodID = id;
 236.398 -
 236.399 -      if ((mainByte & 0x10) != 0)
 236.400 -      {
 236.401 -        coder.NumInStreams = ReadNum();
 236.402 -        coder.NumOutStreams = ReadNum();
 236.403 -      }
 236.404 -      else
 236.405 -      {
 236.406 -        coder.NumInStreams = 1;
 236.407 -        coder.NumOutStreams = 1;
 236.408 -      }
 236.409 -      if ((mainByte & 0x20) != 0)
 236.410 -      {
 236.411 -        CNum propsSize = ReadNum();
 236.412 -        coder.Props.SetCapacity((size_t)propsSize);
 236.413 -        ReadBytes((Byte *)coder.Props, (size_t)propsSize);
 236.414 -      }
 236.415 -      if ((mainByte & 0x80) != 0)
 236.416 -        ThrowUnsupported();
 236.417 -    }
 236.418 -    numInStreams += coder.NumInStreams;
 236.419 -    numOutStreams += coder.NumOutStreams;
 236.420 -  }
 236.421 -
 236.422 -  CNum numBindPairs = numOutStreams - 1;
 236.423 -  folder.BindPairs.Clear();
 236.424 -  folder.BindPairs.Reserve(numBindPairs);
 236.425 -  for (i = 0; i < numBindPairs; i++)
 236.426 -  {
 236.427 -    CBindPair bp;
 236.428 -    bp.InIndex = ReadNum();
 236.429 -    bp.OutIndex = ReadNum();
 236.430 -    folder.BindPairs.Add(bp);
 236.431 -  }
 236.432 -
 236.433 -  if (numInStreams < numBindPairs)
 236.434 -    ThrowUnsupported();
 236.435 -  CNum numPackStreams = numInStreams - numBindPairs;
 236.436 -  folder.PackStreams.Reserve(numPackStreams);
 236.437 -  if (numPackStreams == 1)
 236.438 -  {
 236.439 -    for (i = 0; i < numInStreams; i++)
 236.440 -      if (folder.FindBindPairForInStream(i) < 0)
 236.441 -      {
 236.442 -        folder.PackStreams.Add(i);
 236.443 -        break;
 236.444 -      }
 236.445 -    if (folder.PackStreams.Size() != 1)
 236.446 -      ThrowUnsupported();
 236.447 -  }
 236.448 -  else
 236.449 -    for (i = 0; i < numPackStreams; i++)
 236.450 -      folder.PackStreams.Add(ReadNum());
 236.451 -}
 236.452 -
 236.453 -void CInArchive::WaitAttribute(UInt64 attribute)
 236.454 -{
 236.455 -  for (;;)
 236.456 -  {
 236.457 -    UInt64 type = ReadID();
 236.458 -    if (type == attribute)
 236.459 -      return;
 236.460 -    if (type == NID::kEnd)
 236.461 -      ThrowIncorrect();
 236.462 -    SkeepData();
 236.463 -  }
 236.464 -}
 236.465 -
 236.466 -void CInArchive::ReadHashDigests(int numItems,
 236.467 -    CBoolVector &digestsDefined,
 236.468 -    CRecordVector<UInt32> &digests)
 236.469 -{
 236.470 -  ReadBoolVector2(numItems, digestsDefined);
 236.471 -  digests.Clear();
 236.472 -  digests.Reserve(numItems);
 236.473 -  for (int i = 0; i < numItems; i++)
 236.474 -  {
 236.475 -    UInt32 crc = 0;
 236.476 -    if (digestsDefined[i])
 236.477 -      crc = ReadUInt32();
 236.478 -    digests.Add(crc);
 236.479 -  }
 236.480 -}
 236.481 -
 236.482 -void CInArchive::ReadPackInfo(
 236.483 -    UInt64 &dataOffset,
 236.484 -    CRecordVector<UInt64> &packSizes,
 236.485 -    CBoolVector &packCRCsDefined,
 236.486 -    CRecordVector<UInt32> &packCRCs)
 236.487 -{
 236.488 -  dataOffset = ReadNumber();
 236.489 -  CNum numPackStreams = ReadNum();
 236.490 -
 236.491 -  WaitAttribute(NID::kSize);
 236.492 -  packSizes.Clear();
 236.493 -  packSizes.Reserve(numPackStreams);
 236.494 -  for (CNum i = 0; i < numPackStreams; i++)
 236.495 -    packSizes.Add(ReadNumber());
 236.496 -
 236.497 -  UInt64 type;
 236.498 -  for (;;)
 236.499 -  {
 236.500 -    type = ReadID();
 236.501 -    if (type == NID::kEnd)
 236.502 -      break;
 236.503 -    if (type == NID::kCRC)
 236.504 -    {
 236.505 -      ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs);
 236.506 -      continue;
 236.507 -    }
 236.508 -    SkeepData();
 236.509 -  }
 236.510 -  if (packCRCsDefined.IsEmpty())
 236.511 -  {
 236.512 -    BoolVector_Fill_False(packCRCsDefined, numPackStreams);
 236.513 -    packCRCs.Reserve(numPackStreams);
 236.514 -    packCRCs.Clear();
 236.515 -    for (CNum i = 0; i < numPackStreams; i++)
 236.516 -      packCRCs.Add(0);
 236.517 -  }
 236.518 -}
 236.519 -
 236.520 -void CInArchive::ReadUnpackInfo(
 236.521 -    const CObjectVector<CByteBuffer> *dataVector,
 236.522 -    CObjectVector<CFolder> &folders)
 236.523 -{
 236.524 -  WaitAttribute(NID::kFolder);
 236.525 -  CNum numFolders = ReadNum();
 236.526 -
 236.527 -  {
 236.528 -    CStreamSwitch streamSwitch;
 236.529 -    streamSwitch.Set(this, dataVector);
 236.530 -    folders.Clear();
 236.531 -    folders.Reserve(numFolders);
 236.532 -    for (CNum i = 0; i < numFolders; i++)
 236.533 -    {
 236.534 -      folders.Add(CFolder());
 236.535 -      GetNextFolderItem(folders.Back());
 236.536 -    }
 236.537 -  }
 236.538 -
 236.539 -  WaitAttribute(NID::kCodersUnpackSize);
 236.540 -
 236.541 -  CNum i;
 236.542 -  for (i = 0; i < numFolders; i++)
 236.543 -  {
 236.544 -    CFolder &folder = folders[i];
 236.545 -    CNum numOutStreams = folder.GetNumOutStreams();
 236.546 -    folder.UnpackSizes.Reserve(numOutStreams);
 236.547 -    for (CNum j = 0; j < numOutStreams; j++)
 236.548 -      folder.UnpackSizes.Add(ReadNumber());
 236.549 -  }
 236.550 -
 236.551 -  for (;;)
 236.552 -  {
 236.553 -    UInt64 type = ReadID();
 236.554 -    if (type == NID::kEnd)
 236.555 -      return;
 236.556 -    if (type == NID::kCRC)
 236.557 -    {
 236.558 -      CBoolVector crcsDefined;
 236.559 -      CRecordVector<UInt32> crcs;
 236.560 -      ReadHashDigests(numFolders, crcsDefined, crcs);
 236.561 -      for (i = 0; i < numFolders; i++)
 236.562 -      {
 236.563 -        CFolder &folder = folders[i];
 236.564 -        folder.UnpackCRCDefined = crcsDefined[i];
 236.565 -        folder.UnpackCRC = crcs[i];
 236.566 -      }
 236.567 -      continue;
 236.568 -    }
 236.569 -    SkeepData();
 236.570 -  }
 236.571 -}
 236.572 -
 236.573 -void CInArchive::ReadSubStreamsInfo(
 236.574 -    const CObjectVector<CFolder> &folders,
 236.575 -    CRecordVector<CNum> &numUnpackStreamsInFolders,
 236.576 -    CRecordVector<UInt64> &unpackSizes,
 236.577 -    CBoolVector &digestsDefined,
 236.578 -    CRecordVector<UInt32> &digests)
 236.579 -{
 236.580 -  numUnpackStreamsInFolders.Clear();
 236.581 -  numUnpackStreamsInFolders.Reserve(folders.Size());
 236.582 -  UInt64 type;
 236.583 -  for (;;)
 236.584 -  {
 236.585 -    type = ReadID();
 236.586 -    if (type == NID::kNumUnpackStream)
 236.587 -    {
 236.588 -      for (int i = 0; i < folders.Size(); i++)
 236.589 -        numUnpackStreamsInFolders.Add(ReadNum());
 236.590 -      continue;
 236.591 -    }
 236.592 -    if (type == NID::kCRC || type == NID::kSize)
 236.593 -      break;
 236.594 -    if (type == NID::kEnd)
 236.595 -      break;
 236.596 -    SkeepData();
 236.597 -  }
 236.598 -
 236.599 -  if (numUnpackStreamsInFolders.IsEmpty())
 236.600 -    for (int i = 0; i < folders.Size(); i++)
 236.601 -      numUnpackStreamsInFolders.Add(1);
 236.602 -
 236.603 -  int i;
 236.604 -  for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
 236.605 -  {
 236.606 -    // v3.13 incorrectly worked with empty folders
 236.607 -    // v4.07: we check that folder is empty
 236.608 -    CNum numSubstreams = numUnpackStreamsInFolders[i];
 236.609 -    if (numSubstreams == 0)
 236.610 -      continue;
 236.611 -    UInt64 sum = 0;
 236.612 -    for (CNum j = 1; j < numSubstreams; j++)
 236.613 -      if (type == NID::kSize)
 236.614 -      {
 236.615 -        UInt64 size = ReadNumber();
 236.616 -        unpackSizes.Add(size);
 236.617 -        sum += size;
 236.618 -      }
 236.619 -    unpackSizes.Add(folders[i].GetUnpackSize() - sum);
 236.620 -  }
 236.621 -  if (type == NID::kSize)
 236.622 -    type = ReadID();
 236.623 -
 236.624 -  int numDigests = 0;
 236.625 -  int numDigestsTotal = 0;
 236.626 -  for (i = 0; i < folders.Size(); i++)
 236.627 -  {
 236.628 -    CNum numSubstreams = numUnpackStreamsInFolders[i];
 236.629 -    if (numSubstreams != 1 || !folders[i].UnpackCRCDefined)
 236.630 -      numDigests += numSubstreams;
 236.631 -    numDigestsTotal += numSubstreams;
 236.632 -  }
 236.633 -
 236.634 -  for (;;)
 236.635 -  {
 236.636 -    if (type == NID::kCRC)
 236.637 -    {
 236.638 -      CBoolVector digestsDefined2;
 236.639 -      CRecordVector<UInt32> digests2;
 236.640 -      ReadHashDigests(numDigests, digestsDefined2, digests2);
 236.641 -      int digestIndex = 0;
 236.642 -      for (i = 0; i < folders.Size(); i++)
 236.643 -      {
 236.644 -        CNum numSubstreams = numUnpackStreamsInFolders[i];
 236.645 -        const CFolder &folder = folders[i];
 236.646 -        if (numSubstreams == 1 && folder.UnpackCRCDefined)
 236.647 -        {
 236.648 -          digestsDefined.Add(true);
 236.649 -          digests.Add(folder.UnpackCRC);
 236.650 -        }
 236.651 -        else
 236.652 -          for (CNum j = 0; j < numSubstreams; j++, digestIndex++)
 236.653 -          {
 236.654 -            digestsDefined.Add(digestsDefined2[digestIndex]);
 236.655 -            digests.Add(digests2[digestIndex]);
 236.656 -          }
 236.657 -      }
 236.658 -    }
 236.659 -    else if (type == NID::kEnd)
 236.660 -    {
 236.661 -      if (digestsDefined.IsEmpty())
 236.662 -      {
 236.663 -        BoolVector_Fill_False(digestsDefined, numDigestsTotal);
 236.664 -        digests.Clear();
 236.665 -        for (int i = 0; i < numDigestsTotal; i++)
 236.666 -          digests.Add(0);
 236.667 -      }
 236.668 -      return;
 236.669 -    }
 236.670 -    else
 236.671 -      SkeepData();
 236.672 -    type = ReadID();
 236.673 -  }
 236.674 -}
 236.675 -
 236.676 -void CInArchive::ReadStreamsInfo(
 236.677 -    const CObjectVector<CByteBuffer> *dataVector,
 236.678 -    UInt64 &dataOffset,
 236.679 -    CRecordVector<UInt64> &packSizes,
 236.680 -    CBoolVector &packCRCsDefined,
 236.681 -    CRecordVector<UInt32> &packCRCs,
 236.682 -    CObjectVector<CFolder> &folders,
 236.683 -    CRecordVector<CNum> &numUnpackStreamsInFolders,
 236.684 -    CRecordVector<UInt64> &unpackSizes,
 236.685 -    CBoolVector &digestsDefined,
 236.686 -    CRecordVector<UInt32> &digests)
 236.687 -{
 236.688 -  for (;;)
 236.689 -  {
 236.690 -    UInt64 type = ReadID();
 236.691 -    if (type > ((UInt32)1 << 30))
 236.692 -      ThrowIncorrect();
 236.693 -    switch((UInt32)type)
 236.694 -    {
 236.695 -      case NID::kEnd:
 236.696 -        return;
 236.697 -      case NID::kPackInfo:
 236.698 -      {
 236.699 -        ReadPackInfo(dataOffset, packSizes, packCRCsDefined, packCRCs);
 236.700 -        break;
 236.701 -      }
 236.702 -      case NID::kUnpackInfo:
 236.703 -      {
 236.704 -        ReadUnpackInfo(dataVector, folders);
 236.705 -        break;
 236.706 -      }
 236.707 -      case NID::kSubStreamsInfo:
 236.708 -      {
 236.709 -        ReadSubStreamsInfo(folders, numUnpackStreamsInFolders,
 236.710 -            unpackSizes, digestsDefined, digests);
 236.711 -        break;
 236.712 -      }
 236.713 -      default:
 236.714 -        ThrowIncorrect();
 236.715 -    }
 236.716 -  }
 236.717 -}
 236.718 -
 236.719 -void CInArchive::ReadBoolVector(int numItems, CBoolVector &v)
 236.720 -{
 236.721 -  v.Clear();
 236.722 -  v.Reserve(numItems);
 236.723 -  Byte b = 0;
 236.724 -  Byte mask = 0;
 236.725 -  for (int i = 0; i < numItems; i++)
 236.726 -  {
 236.727 -    if (mask == 0)
 236.728 -    {
 236.729 -      b = ReadByte();
 236.730 -      mask = 0x80;
 236.731 -    }
 236.732 -    v.Add((b & mask) != 0);
 236.733 -    mask >>= 1;
 236.734 -  }
 236.735 -}
 236.736 -
 236.737 -void CInArchive::ReadBoolVector2(int numItems, CBoolVector &v)
 236.738 -{
 236.739 -  Byte allAreDefined = ReadByte();
 236.740 -  if (allAreDefined == 0)
 236.741 -  {
 236.742 -    ReadBoolVector(numItems, v);
 236.743 -    return;
 236.744 -  }
 236.745 -  v.Clear();
 236.746 -  v.Reserve(numItems);
 236.747 -  for (int i = 0; i < numItems; i++)
 236.748 -    v.Add(true);
 236.749 -}
 236.750 -
 236.751 -void CInArchive::ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
 236.752 -    CUInt64DefVector &v, int numFiles)
 236.753 -{
 236.754 -  ReadBoolVector2(numFiles, v.Defined);
 236.755 -
 236.756 -  CStreamSwitch streamSwitch;
 236.757 -  streamSwitch.Set(this, &dataVector);
 236.758 -  v.Values.Reserve(numFiles);
 236.759 -
 236.760 -  for (int i = 0; i < numFiles; i++)
 236.761 -  {
 236.762 -    UInt64 t = 0;
 236.763 -    if (v.Defined[i])
 236.764 -      t = ReadUInt64();
 236.765 -    v.Values.Add(t);
 236.766 -  }
 236.767 -}
 236.768 -
 236.769 -HRESULT CInArchive::ReadAndDecodePackedStreams(
 236.770 -    DECL_EXTERNAL_CODECS_LOC_VARS
 236.771 -    UInt64 baseOffset,
 236.772 -    UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
 236.773 -    #ifndef _NO_CRYPTO
 236.774 -    , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 236.775 -    #endif
 236.776 -    )
 236.777 -{
 236.778 -  CRecordVector<UInt64> packSizes;
 236.779 -  CBoolVector packCRCsDefined;
 236.780 -  CRecordVector<UInt32> packCRCs;
 236.781 -  CObjectVector<CFolder> folders;
 236.782 -  
 236.783 -  CRecordVector<CNum> numUnpackStreamsInFolders;
 236.784 -  CRecordVector<UInt64> unpackSizes;
 236.785 -  CBoolVector digestsDefined;
 236.786 -  CRecordVector<UInt32> digests;
 236.787 -  
 236.788 -  ReadStreamsInfo(NULL,
 236.789 -    dataOffset,
 236.790 -    packSizes,
 236.791 -    packCRCsDefined,
 236.792 -    packCRCs,
 236.793 -    folders,
 236.794 -    numUnpackStreamsInFolders,
 236.795 -    unpackSizes,
 236.796 -    digestsDefined,
 236.797 -    digests);
 236.798 -  
 236.799 -  // db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
 236.800 -  
 236.801 -  CNum packIndex = 0;
 236.802 -  CDecoder decoder(
 236.803 -    #ifdef _ST_MODE
 236.804 -    false
 236.805 -    #else
 236.806 -    true
 236.807 -    #endif
 236.808 -    );
 236.809 -  UInt64 dataStartPos = baseOffset + dataOffset;
 236.810 -  for (int i = 0; i < folders.Size(); i++)
 236.811 -  {
 236.812 -    const CFolder &folder = folders[i];
 236.813 -    dataVector.Add(CByteBuffer());
 236.814 -    CByteBuffer &data = dataVector.Back();
 236.815 -    UInt64 unpackSize64 = folder.GetUnpackSize();
 236.816 -    size_t unpackSize = (size_t)unpackSize64;
 236.817 -    if (unpackSize != unpackSize64)
 236.818 -      ThrowUnsupported();
 236.819 -    data.SetCapacity(unpackSize);
 236.820 -    
 236.821 -    CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2;
 236.822 -    CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
 236.823 -    outStreamSpec->Init(data, unpackSize);
 236.824 -    
 236.825 -    HRESULT result = decoder.Decode(
 236.826 -      EXTERNAL_CODECS_LOC_VARS
 236.827 -      _stream, dataStartPos,
 236.828 -      &packSizes[packIndex], folder, outStream, NULL
 236.829 -      #ifndef _NO_CRYPTO
 236.830 -      , getTextPassword, passwordIsDefined
 236.831 -      #endif
 236.832 -      #ifdef COMPRESS_MT
 236.833 -      , false, 1
 236.834 -      #endif
 236.835 -      );
 236.836 -    RINOK(result);
 236.837 -    
 236.838 -    if (folder.UnpackCRCDefined)
 236.839 -      if (CrcCalc(data, unpackSize) != folder.UnpackCRC)
 236.840 -        ThrowIncorrect();
 236.841 -    for (int j = 0; j < folder.PackStreams.Size(); j++)
 236.842 -    {
 236.843 -      UInt64 packSize = packSizes[packIndex++];
 236.844 -      dataStartPos += packSize;
 236.845 -      HeadersSize += packSize;
 236.846 -    }
 236.847 -  }
 236.848 -  return S_OK;
 236.849 -}
 236.850 -
 236.851 -HRESULT CInArchive::ReadHeader(
 236.852 -    DECL_EXTERNAL_CODECS_LOC_VARS
 236.853 -    CArchiveDatabaseEx &db
 236.854 -    #ifndef _NO_CRYPTO
 236.855 -    , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 236.856 -    #endif
 236.857 -    )
 236.858 -{
 236.859 -  UInt64 type = ReadID();
 236.860 -
 236.861 -  if (type == NID::kArchiveProperties)
 236.862 -  {
 236.863 -    ReadArchiveProperties(db.ArchiveInfo);
 236.864 -    type = ReadID();
 236.865 -  }
 236.866 - 
 236.867 -  CObjectVector<CByteBuffer> dataVector;
 236.868 -  
 236.869 -  if (type == NID::kAdditionalStreamsInfo)
 236.870 -  {
 236.871 -    HRESULT result = ReadAndDecodePackedStreams(
 236.872 -        EXTERNAL_CODECS_LOC_VARS
 236.873 -        db.ArchiveInfo.StartPositionAfterHeader,
 236.874 -        db.ArchiveInfo.DataStartPosition2,
 236.875 -        dataVector
 236.876 -        #ifndef _NO_CRYPTO
 236.877 -        , getTextPassword, passwordIsDefined
 236.878 -        #endif
 236.879 -        );
 236.880 -    RINOK(result);
 236.881 -    db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
 236.882 -    type = ReadID();
 236.883 -  }
 236.884 -
 236.885 -  CRecordVector<UInt64> unpackSizes;
 236.886 -  CBoolVector digestsDefined;
 236.887 -  CRecordVector<UInt32> digests;
 236.888 -  
 236.889 -  if (type == NID::kMainStreamsInfo)
 236.890 -  {
 236.891 -    ReadStreamsInfo(&dataVector,
 236.892 -        db.ArchiveInfo.DataStartPosition,
 236.893 -        db.PackSizes,
 236.894 -        db.PackCRCsDefined,
 236.895 -        db.PackCRCs,
 236.896 -        db.Folders,
 236.897 -        db.NumUnpackStreamsVector,
 236.898 -        unpackSizes,
 236.899 -        digestsDefined,
 236.900 -        digests);
 236.901 -    db.ArchiveInfo.DataStartPosition += db.ArchiveInfo.StartPositionAfterHeader;
 236.902 -    type = ReadID();
 236.903 -  }
 236.904 -  else
 236.905 -  {
 236.906 -    for (int i = 0; i < db.Folders.Size(); i++)
 236.907 -    {
 236.908 -      db.NumUnpackStreamsVector.Add(1);
 236.909 -      CFolder &folder = db.Folders[i];
 236.910 -      unpackSizes.Add(folder.GetUnpackSize());
 236.911 -      digestsDefined.Add(folder.UnpackCRCDefined);
 236.912 -      digests.Add(folder.UnpackCRC);
 236.913 -    }
 236.914 -  }
 236.915 -
 236.916 -  db.Files.Clear();
 236.917 -
 236.918 -  if (type == NID::kEnd)
 236.919 -    return S_OK;
 236.920 -  if (type != NID::kFilesInfo)
 236.921 -    ThrowIncorrect();
 236.922 -  
 236.923 -  CNum numFiles = ReadNum();
 236.924 -  db.Files.Reserve(numFiles);
 236.925 -  CNum i;
 236.926 -  for (i = 0; i < numFiles; i++)
 236.927 -    db.Files.Add(CFileItem());
 236.928 -
 236.929 -  db.ArchiveInfo.FileInfoPopIDs.Add(NID::kSize);
 236.930 -  if (!db.PackSizes.IsEmpty())
 236.931 -    db.ArchiveInfo.FileInfoPopIDs.Add(NID::kPackInfo);
 236.932 -  if (numFiles > 0  && !digests.IsEmpty())
 236.933 -    db.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
 236.934 -
 236.935 -  CBoolVector emptyStreamVector;
 236.936 -  BoolVector_Fill_False(emptyStreamVector, (int)numFiles);
 236.937 -  CBoolVector emptyFileVector;
 236.938 -  CBoolVector antiFileVector;
 236.939 -  CNum numEmptyStreams = 0;
 236.940 -
 236.941 -  for (;;)
 236.942 -  {
 236.943 -    UInt64 type = ReadID();
 236.944 -    if (type == NID::kEnd)
 236.945 -      break;
 236.946 -    UInt64 size = ReadNumber();
 236.947 -    size_t ppp = _inByteBack->_pos;
 236.948 -    bool addPropIdToList = true;
 236.949 -    bool isKnownType = true;
 236.950 -    if (type > ((UInt32)1 << 30))
 236.951 -      isKnownType = false;
 236.952 -    else switch((UInt32)type)
 236.953 -    {
 236.954 -      case NID::kName:
 236.955 -      {
 236.956 -        CStreamSwitch streamSwitch;
 236.957 -        streamSwitch.Set(this, &dataVector);
 236.958 -        for (int i = 0; i < db.Files.Size(); i++)
 236.959 -          _inByteBack->ReadString(db.Files[i].Name);
 236.960 -        break;
 236.961 -      }
 236.962 -      case NID::kWinAttributes:
 236.963 -      {
 236.964 -        CBoolVector boolVector;
 236.965 -        ReadBoolVector2(db.Files.Size(), boolVector);
 236.966 -        CStreamSwitch streamSwitch;
 236.967 -        streamSwitch.Set(this, &dataVector);
 236.968 -        for (i = 0; i < numFiles; i++)
 236.969 -        {
 236.970 -          CFileItem &file = db.Files[i];
 236.971 -          file.AttribDefined = boolVector[i];
 236.972 -          if (file.AttribDefined)
 236.973 -            file.Attrib = ReadUInt32();
 236.974 -        }
 236.975 -        break;
 236.976 -      }
 236.977 -      case NID::kEmptyStream:
 236.978 -      {
 236.979 -        ReadBoolVector(numFiles, emptyStreamVector);
 236.980 -        for (i = 0; i < (CNum)emptyStreamVector.Size(); i++)
 236.981 -          if (emptyStreamVector[i])
 236.982 -            numEmptyStreams++;
 236.983 -
 236.984 -        BoolVector_Fill_False(emptyFileVector, numEmptyStreams);
 236.985 -        BoolVector_Fill_False(antiFileVector, numEmptyStreams);
 236.986 -
 236.987 -        break;
 236.988 -      }
 236.989 -      case NID::kEmptyFile:  ReadBoolVector(numEmptyStreams, emptyFileVector); break;
 236.990 -      case NID::kAnti:  ReadBoolVector(numEmptyStreams, antiFileVector); break;
 236.991 -      case NID::kStartPos:  ReadUInt64DefVector(dataVector, db.StartPos, (int)numFiles); break;
 236.992 -      case NID::kCTime:  ReadUInt64DefVector(dataVector, db.CTime, (int)numFiles); break;
 236.993 -      case NID::kATime:  ReadUInt64DefVector(dataVector, db.ATime, (int)numFiles); break;
 236.994 -      case NID::kMTime:  ReadUInt64DefVector(dataVector, db.MTime, (int)numFiles); break;
 236.995 -      case NID::kDummy:
 236.996 -      {
 236.997 -        for (UInt64 j = 0; j < size; j++)
 236.998 -          if (ReadByte() != 0)
 236.999 -            ThrowIncorrect();
236.1000 -        addPropIdToList = false;
236.1001 -        break;
236.1002 -      }
236.1003 -      default:
236.1004 -        addPropIdToList = isKnownType = false;
236.1005 -    }
236.1006 -    if (isKnownType)
236.1007 -    {
236.1008 -      if(addPropIdToList)
236.1009 -        db.ArchiveInfo.FileInfoPopIDs.Add(type);
236.1010 -    }
236.1011 -    else
236.1012 -      SkeepData(size);
236.1013 -    bool checkRecordsSize = (db.ArchiveInfo.Version.Major > 0 ||
236.1014 -        db.ArchiveInfo.Version.Minor > 2);
236.1015 -    if (checkRecordsSize && _inByteBack->_pos - ppp != size)
236.1016 -      ThrowIncorrect();
236.1017 -  }
236.1018 -
236.1019 -  CNum emptyFileIndex = 0;
236.1020 -  CNum sizeIndex = 0;
236.1021 -
236.1022 -  CNum numAntiItems = 0;
236.1023 -  for (i = 0; i < numEmptyStreams; i++)
236.1024 -    if (antiFileVector[i])
236.1025 -      numAntiItems++;
236.1026 -    
236.1027 -  for (i = 0; i < numFiles; i++)
236.1028 -  {
236.1029 -    CFileItem &file = db.Files[i];
236.1030 -    bool isAnti;
236.1031 -    file.HasStream = !emptyStreamVector[i];
236.1032 -    if (file.HasStream)
236.1033 -    {
236.1034 -      file.IsDir = false;
236.1035 -      isAnti = false;
236.1036 -      file.Size = unpackSizes[sizeIndex];
236.1037 -      file.Crc = digests[sizeIndex];
236.1038 -      file.CrcDefined = digestsDefined[sizeIndex];
236.1039 -      sizeIndex++;
236.1040 -    }
236.1041 -    else
236.1042 -    {
236.1043 -      file.IsDir = !emptyFileVector[emptyFileIndex];
236.1044 -      isAnti = antiFileVector[emptyFileIndex];
236.1045 -      emptyFileIndex++;
236.1046 -      file.Size = 0;
236.1047 -      file.CrcDefined = false;
236.1048 -    }
236.1049 -    if (numAntiItems != 0)
236.1050 -      db.IsAnti.Add(isAnti);
236.1051 -  }
236.1052 -  return S_OK;
236.1053 -}
236.1054 -
236.1055 -
236.1056 -void CArchiveDatabaseEx::FillFolderStartPackStream()
236.1057 -{
236.1058 -  FolderStartPackStreamIndex.Clear();
236.1059 -  FolderStartPackStreamIndex.Reserve(Folders.Size());
236.1060 -  CNum startPos = 0;
236.1061 -  for (int i = 0; i < Folders.Size(); i++)
236.1062 -  {
236.1063 -    FolderStartPackStreamIndex.Add(startPos);
236.1064 -    startPos += (CNum)Folders[i].PackStreams.Size();
236.1065 -  }
236.1066 -}
236.1067 -
236.1068 -void CArchiveDatabaseEx::FillStartPos()
236.1069 -{
236.1070 -  PackStreamStartPositions.Clear();
236.1071 -  PackStreamStartPositions.Reserve(PackSizes.Size());
236.1072 -  UInt64 startPos = 0;
236.1073 -  for (int i = 0; i < PackSizes.Size(); i++)
236.1074 -  {
236.1075 -    PackStreamStartPositions.Add(startPos);
236.1076 -    startPos += PackSizes[i];
236.1077 -  }
236.1078 -}
236.1079 -
236.1080 -void CArchiveDatabaseEx::FillFolderStartFileIndex()
236.1081 -{
236.1082 -  FolderStartFileIndex.Clear();
236.1083 -  FolderStartFileIndex.Reserve(Folders.Size());
236.1084 -  FileIndexToFolderIndexMap.Clear();
236.1085 -  FileIndexToFolderIndexMap.Reserve(Files.Size());
236.1086 -  
236.1087 -  int folderIndex = 0;
236.1088 -  CNum indexInFolder = 0;
236.1089 -  for (int i = 0; i < Files.Size(); i++)
236.1090 -  {
236.1091 -    const CFileItem &file = Files[i];
236.1092 -    bool emptyStream = !file.HasStream;
236.1093 -    if (emptyStream && indexInFolder == 0)
236.1094 -    {
236.1095 -      FileIndexToFolderIndexMap.Add(kNumNoIndex);
236.1096 -      continue;
236.1097 -    }
236.1098 -    if (indexInFolder == 0)
236.1099 -    {
236.1100 -      // v3.13 incorrectly worked with empty folders
236.1101 -      // v4.07: Loop for skipping empty folders
236.1102 -      for (;;)
236.1103 -      {
236.1104 -        if (folderIndex >= Folders.Size())
236.1105 -          ThrowIncorrect();
236.1106 -        FolderStartFileIndex.Add(i); // check it
236.1107 -        if (NumUnpackStreamsVector[folderIndex] != 0)
236.1108 -          break;
236.1109 -        folderIndex++;
236.1110 -      }
236.1111 -    }
236.1112 -    FileIndexToFolderIndexMap.Add(folderIndex);
236.1113 -    if (emptyStream)
236.1114 -      continue;
236.1115 -    indexInFolder++;
236.1116 -    if (indexInFolder >= NumUnpackStreamsVector[folderIndex])
236.1117 -    {
236.1118 -      folderIndex++;
236.1119 -      indexInFolder = 0;
236.1120 -    }
236.1121 -  }
236.1122 -}
236.1123 -
236.1124 -HRESULT CInArchive::ReadDatabase2(
236.1125 -    DECL_EXTERNAL_CODECS_LOC_VARS
236.1126 -    CArchiveDatabaseEx &db
236.1127 -    #ifndef _NO_CRYPTO
236.1128 -    , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
236.1129 -    #endif
236.1130 -    )
236.1131 -{
236.1132 -  db.Clear();
236.1133 -  db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
236.1134 -
236.1135 -  db.ArchiveInfo.Version.Major = _header[6];
236.1136 -  db.ArchiveInfo.Version.Minor = _header[7];
236.1137 -
236.1138 -  if (db.ArchiveInfo.Version.Major != kMajorVersion)
236.1139 -    ThrowUnsupportedVersion();
236.1140 -
236.1141 -  UInt32 crcFromArchive = Get32(_header + 8);
236.1142 -  UInt64 nextHeaderOffset = Get64(_header + 0xC);
236.1143 -  UInt64 nextHeaderSize = Get64(_header + 0x14);
236.1144 -  UInt32 nextHeaderCRC = Get32(_header + 0x1C);
236.1145 -  UInt32 crc = CrcCalc(_header + 0xC, 20);
236.1146 -
236.1147 -  #ifdef FORMAT_7Z_RECOVERY
236.1148 -  if (crcFromArchive == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
236.1149 -  {
236.1150 -    UInt64 cur, cur2;
236.1151 -    RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &cur));
236.1152 -    const int kCheckSize = 500;
236.1153 -    Byte buf[kCheckSize];
236.1154 -    RINOK(_stream->Seek(0, STREAM_SEEK_END, &cur2));
236.1155 -    int checkSize = kCheckSize;
236.1156 -    if (cur2 - cur < kCheckSize)
236.1157 -      checkSize = (int)(cur2 - cur);
236.1158 -    RINOK(_stream->Seek(-checkSize, STREAM_SEEK_END, &cur2));
236.1159 -    
236.1160 -    RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize));
236.1161 -
236.1162 -    int i;
236.1163 -    for (i = (int)checkSize - 2; i >= 0; i--)
236.1164 -      if (buf[i] == 0x17 && buf[i + 1] == 0x6 || buf[i] == 0x01 && buf[i + 1] == 0x04)
236.1165 -        break;
236.1166 -    if (i < 0)
236.1167 -      return S_FALSE;
236.1168 -    nextHeaderSize = checkSize - i;
236.1169 -    nextHeaderOffset = cur2 - cur + i;
236.1170 -    nextHeaderCRC = CrcCalc(buf + i, (size_t)nextHeaderSize);
236.1171 -    RINOK(_stream->Seek(cur, STREAM_SEEK_SET, NULL));
236.1172 -  }
236.1173 -  #endif
236.1174 -
236.1175 -  #ifdef FORMAT_7Z_RECOVERY
236.1176 -  crcFromArchive = crc;
236.1177 -  #endif
236.1178 -
236.1179 -  db.ArchiveInfo.StartPositionAfterHeader = _arhiveBeginStreamPosition + kHeaderSize;
236.1180 -
236.1181 -  if (crc != crcFromArchive)
236.1182 -    ThrowIncorrect();
236.1183 -
236.1184 -  if (nextHeaderSize == 0)
236.1185 -    return S_OK;
236.1186 -
236.1187 -  if (nextHeaderSize > (UInt64)0xFFFFFFFF)
236.1188 -    return S_FALSE;
236.1189 -
236.1190 -  RINOK(_stream->Seek(nextHeaderOffset, STREAM_SEEK_CUR, NULL));
236.1191 -
236.1192 -  CByteBuffer buffer2;
236.1193 -  buffer2.SetCapacity((size_t)nextHeaderSize);
236.1194 -
236.1195 -  RINOK(ReadStream_FALSE(_stream, buffer2, (size_t)nextHeaderSize));
236.1196 -  HeadersSize += kHeaderSize + nextHeaderSize;
236.1197 -  db.PhySize = kHeaderSize + nextHeaderOffset + nextHeaderSize;
236.1198 -
236.1199 -  if (CrcCalc(buffer2, (UInt32)nextHeaderSize) != nextHeaderCRC)
236.1200 -    ThrowIncorrect();
236.1201 -  
236.1202 -  CStreamSwitch streamSwitch;
236.1203 -  streamSwitch.Set(this, buffer2);
236.1204 -  
236.1205 -  CObjectVector<CByteBuffer> dataVector;
236.1206 -  
236.1207 -  UInt64 type = ReadID();
236.1208 -  if (type != NID::kHeader)
236.1209 -  {
236.1210 -    if (type != NID::kEncodedHeader)
236.1211 -      ThrowIncorrect();
236.1212 -    HRESULT result = ReadAndDecodePackedStreams(
236.1213 -        EXTERNAL_CODECS_LOC_VARS
236.1214 -        db.ArchiveInfo.StartPositionAfterHeader,
236.1215 -        db.ArchiveInfo.DataStartPosition2,
236.1216 -        dataVector
236.1217 -        #ifndef _NO_CRYPTO
236.1218 -        , getTextPassword, passwordIsDefined
236.1219 -        #endif
236.1220 -        );
236.1221 -    RINOK(result);
236.1222 -    if (dataVector.Size() == 0)
236.1223 -      return S_OK;
236.1224 -    if (dataVector.Size() > 1)
236.1225 -      ThrowIncorrect();
236.1226 -    streamSwitch.Remove();
236.1227 -    streamSwitch.Set(this, dataVector.Front());
236.1228 -    if (ReadID() != NID::kHeader)
236.1229 -      ThrowIncorrect();
236.1230 -  }
236.1231 -
236.1232 -  db.HeadersSize = HeadersSize;
236.1233 -
236.1234 -  return ReadHeader(
236.1235 -    EXTERNAL_CODECS_LOC_VARS
236.1236 -    db
236.1237 -    #ifndef _NO_CRYPTO
236.1238 -    , getTextPassword, passwordIsDefined
236.1239 -    #endif
236.1240 -    );
236.1241 -}
236.1242 -
236.1243 -HRESULT CInArchive::ReadDatabase(
236.1244 -    DECL_EXTERNAL_CODECS_LOC_VARS
236.1245 -    CArchiveDatabaseEx &db
236.1246 -    #ifndef _NO_CRYPTO
236.1247 -    , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
236.1248 -    #endif
236.1249 -    )
236.1250 -{
236.1251 -  try
236.1252 -  {
236.1253 -    return ReadDatabase2(
236.1254 -      EXTERNAL_CODECS_LOC_VARS db
236.1255 -      #ifndef _NO_CRYPTO
236.1256 -      , getTextPassword, passwordIsDefined
236.1257 -      #endif
236.1258 -      );
236.1259 -  }
236.1260 -  catch(CInArchiveException &) { return S_FALSE; }
236.1261 -}
236.1262 -
236.1263 -}}
   237.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zIn.h	Sat Mar 03 10:54:39 2012 -0600
   237.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   237.3 @@ -1,245 +0,0 @@
   237.4 -// 7zIn.h
   237.5 -
   237.6 -#ifndef __7Z_IN_H
   237.7 -#define __7Z_IN_H
   237.8 -
   237.9 -#include "../../../Common/MyCom.h"
  237.10 -
  237.11 -#include "../../IPassword.h"
  237.12 -#include "../../IStream.h"
  237.13 -
  237.14 -#include "../../Common/CreateCoder.h"
  237.15 -#include "../../Common/InBuffer.h"
  237.16 -
  237.17 -#include "7zItem.h"
  237.18 - 
  237.19 -namespace NArchive {
  237.20 -namespace N7z {
  237.21 -  
  237.22 -struct CInArchiveInfo
  237.23 -{
  237.24 -  CArchiveVersion Version;
  237.25 -  UInt64 StartPosition;
  237.26 -  UInt64 StartPositionAfterHeader;
  237.27 -  UInt64 DataStartPosition;
  237.28 -  UInt64 DataStartPosition2;
  237.29 -  CRecordVector<UInt64> FileInfoPopIDs;
  237.30 -  void Clear()
  237.31 -  {
  237.32 -    FileInfoPopIDs.Clear();
  237.33 -  }
  237.34 -};
  237.35 -
  237.36 -struct CArchiveDatabaseEx: public CArchiveDatabase
  237.37 -{
  237.38 -  CInArchiveInfo ArchiveInfo;
  237.39 -  CRecordVector<UInt64> PackStreamStartPositions;
  237.40 -  CRecordVector<CNum> FolderStartPackStreamIndex;
  237.41 -  CRecordVector<CNum> FolderStartFileIndex;
  237.42 -  CRecordVector<CNum> FileIndexToFolderIndexMap;
  237.43 -
  237.44 -  UInt64 HeadersSize;
  237.45 -  UInt64 PhySize;
  237.46 -
  237.47 -  void Clear()
  237.48 -  {
  237.49 -    CArchiveDatabase::Clear();
  237.50 -    ArchiveInfo.Clear();
  237.51 -    PackStreamStartPositions.Clear();
  237.52 -    FolderStartPackStreamIndex.Clear();
  237.53 -    FolderStartFileIndex.Clear();
  237.54 -    FileIndexToFolderIndexMap.Clear();
  237.55 -
  237.56 -    HeadersSize = 0;
  237.57 -    PhySize = 0;
  237.58 -  }
  237.59 -
  237.60 -  void FillFolderStartPackStream();
  237.61 -  void FillStartPos();
  237.62 -  void FillFolderStartFileIndex();
  237.63 -
  237.64 -  void Fill()
  237.65 -  {
  237.66 -    FillFolderStartPackStream();
  237.67 -    FillStartPos();
  237.68 -    FillFolderStartFileIndex();
  237.69 -  }
  237.70 -  
  237.71 -  UInt64 GetFolderStreamPos(int folderIndex, int indexInFolder) const
  237.72 -  {
  237.73 -    return ArchiveInfo.DataStartPosition +
  237.74 -        PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] + indexInFolder];
  237.75 -  }
  237.76 -  
  237.77 -  UInt64 GetFolderFullPackSize(int folderIndex) const
  237.78 -  {
  237.79 -    CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
  237.80 -    const CFolder &folder = Folders[folderIndex];
  237.81 -    UInt64 size = 0;
  237.82 -    for (int i = 0; i < folder.PackStreams.Size(); i++)
  237.83 -      size += PackSizes[packStreamIndex + i];
  237.84 -    return size;
  237.85 -  }
  237.86 -  
  237.87 -  UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
  237.88 -  {
  237.89 -    return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
  237.90 -  }
  237.91 -
  237.92 -  UInt64 GetFilePackSize(CNum fileIndex) const
  237.93 -  {
  237.94 -    CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
  237.95 -    if (folderIndex != kNumNoIndex)
  237.96 -      if (FolderStartFileIndex[folderIndex] == fileIndex)
  237.97 -        return GetFolderFullPackSize(folderIndex);
  237.98 -    return 0;
  237.99 -  }
 237.100 -};
 237.101 -
 237.102 -class CInByte2
 237.103 -{
 237.104 -  const Byte *_buffer;
 237.105 -  size_t _size;
 237.106 -public:
 237.107 -  size_t _pos;
 237.108 -  void Init(const Byte *buffer, size_t size)
 237.109 -  {
 237.110 -    _buffer = buffer;
 237.111 -    _size = size;
 237.112 -    _pos = 0;
 237.113 -  }
 237.114 -  Byte ReadByte();
 237.115 -  void ReadBytes(Byte *data, size_t size);
 237.116 -  void SkeepData(UInt64 size);
 237.117 -  void SkeepData();
 237.118 -  UInt64 ReadNumber();
 237.119 -  CNum ReadNum();
 237.120 -  UInt32 ReadUInt32();
 237.121 -  UInt64 ReadUInt64();
 237.122 -  void ReadString(UString &s);
 237.123 -};
 237.124 -
 237.125 -class CStreamSwitch;
 237.126 -
 237.127 -const UInt32 kHeaderSize = 32;
 237.128 -
 237.129 -class CInArchive
 237.130 -{
 237.131 -  friend class CStreamSwitch;
 237.132 -
 237.133 -  CMyComPtr<IInStream> _stream;
 237.134 -
 237.135 -  CObjectVector<CInByte2> _inByteVector;
 237.136 -  CInByte2 *_inByteBack;
 237.137 - 
 237.138 -  UInt64 _arhiveBeginStreamPosition;
 237.139 -
 237.140 -  Byte _header[kHeaderSize];
 237.141 -
 237.142 -  UInt64 HeadersSize;
 237.143 -
 237.144 -  void AddByteStream(const Byte *buffer, size_t size)
 237.145 -  {
 237.146 -    _inByteVector.Add(CInByte2());
 237.147 -    _inByteBack = &_inByteVector.Back();
 237.148 -    _inByteBack->Init(buffer, size);
 237.149 -  }
 237.150 -  
 237.151 -  void DeleteByteStream()
 237.152 -  {
 237.153 -    _inByteVector.DeleteBack();
 237.154 -    if (!_inByteVector.IsEmpty())
 237.155 -      _inByteBack = &_inByteVector.Back();
 237.156 -  }
 237.157 -
 237.158 -private:
 237.159 -  HRESULT FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
 237.160 -  
 237.161 -  void ReadBytes(Byte *data, size_t size) { _inByteBack->ReadBytes(data, size); }
 237.162 -  Byte ReadByte() { return _inByteBack->ReadByte(); }
 237.163 -  UInt64 ReadNumber() { return _inByteBack->ReadNumber(); }
 237.164 -  CNum ReadNum() { return _inByteBack->ReadNum(); }
 237.165 -  UInt64 ReadID() { return _inByteBack->ReadNumber(); }
 237.166 -  UInt32 ReadUInt32() { return _inByteBack->ReadUInt32(); }
 237.167 -  UInt64 ReadUInt64() { return _inByteBack->ReadUInt64(); }
 237.168 -  void SkeepData(UInt64 size) { _inByteBack->SkeepData(size); }
 237.169 -  void SkeepData() { _inByteBack->SkeepData(); }
 237.170 -  void WaitAttribute(UInt64 attribute);
 237.171 -
 237.172 -  void ReadArchiveProperties(CInArchiveInfo &archiveInfo);
 237.173 -  void GetNextFolderItem(CFolder &itemInfo);
 237.174 -  void ReadHashDigests(int numItems,
 237.175 -      CBoolVector &digestsDefined, CRecordVector<UInt32> &digests);
 237.176 -  
 237.177 -  void ReadPackInfo(
 237.178 -      UInt64 &dataOffset,
 237.179 -      CRecordVector<UInt64> &packSizes,
 237.180 -      CBoolVector &packCRCsDefined,
 237.181 -      CRecordVector<UInt32> &packCRCs);
 237.182 -  
 237.183 -  void ReadUnpackInfo(
 237.184 -      const CObjectVector<CByteBuffer> *dataVector,
 237.185 -      CObjectVector<CFolder> &folders);
 237.186 -  
 237.187 -  void ReadSubStreamsInfo(
 237.188 -      const CObjectVector<CFolder> &folders,
 237.189 -      CRecordVector<CNum> &numUnpackStreamsInFolders,
 237.190 -      CRecordVector<UInt64> &unpackSizes,
 237.191 -      CBoolVector &digestsDefined,
 237.192 -      CRecordVector<UInt32> &digests);
 237.193 -
 237.194 -  void ReadStreamsInfo(
 237.195 -      const CObjectVector<CByteBuffer> *dataVector,
 237.196 -      UInt64 &dataOffset,
 237.197 -      CRecordVector<UInt64> &packSizes,
 237.198 -      CBoolVector &packCRCsDefined,
 237.199 -      CRecordVector<UInt32> &packCRCs,
 237.200 -      CObjectVector<CFolder> &folders,
 237.201 -      CRecordVector<CNum> &numUnpackStreamsInFolders,
 237.202 -      CRecordVector<UInt64> &unpackSizes,
 237.203 -      CBoolVector &digestsDefined,
 237.204 -      CRecordVector<UInt32> &digests);
 237.205 -
 237.206 -
 237.207 -  void ReadBoolVector(int numItems, CBoolVector &v);
 237.208 -  void ReadBoolVector2(int numItems, CBoolVector &v);
 237.209 -  void ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
 237.210 -      CUInt64DefVector &v, int numFiles);
 237.211 -  HRESULT ReadAndDecodePackedStreams(
 237.212 -      DECL_EXTERNAL_CODECS_LOC_VARS
 237.213 -      UInt64 baseOffset, UInt64 &dataOffset,
 237.214 -      CObjectVector<CByteBuffer> &dataVector
 237.215 -      #ifndef _NO_CRYPTO
 237.216 -      , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 237.217 -      #endif
 237.218 -      );
 237.219 -  HRESULT ReadHeader(
 237.220 -      DECL_EXTERNAL_CODECS_LOC_VARS
 237.221 -      CArchiveDatabaseEx &db
 237.222 -      #ifndef _NO_CRYPTO
 237.223 -      ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 237.224 -      #endif
 237.225 -      );
 237.226 -  HRESULT ReadDatabase2(
 237.227 -      DECL_EXTERNAL_CODECS_LOC_VARS
 237.228 -      CArchiveDatabaseEx &db
 237.229 -      #ifndef _NO_CRYPTO
 237.230 -      ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 237.231 -      #endif
 237.232 -      );
 237.233 -public:
 237.234 -  HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
 237.235 -  void Close();
 237.236 -
 237.237 -  HRESULT ReadDatabase(
 237.238 -      DECL_EXTERNAL_CODECS_LOC_VARS
 237.239 -      CArchiveDatabaseEx &db
 237.240 -      #ifndef _NO_CRYPTO
 237.241 -      ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
 237.242 -      #endif
 237.243 -      );
 237.244 -};
 237.245 -  
 237.246 -}}
 237.247 -  
 237.248 -#endif
   238.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zItem.h	Sat Mar 03 10:54:39 2012 -0600
   238.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   238.3 @@ -1,258 +0,0 @@
   238.4 -// 7zItem.h
   238.5 -
   238.6 -#ifndef __7Z_ITEM_H
   238.7 -#define __7Z_ITEM_H
   238.8 -
   238.9 -#include "../../../Common/Buffer.h"
  238.10 -#include "../../../Common/MyString.h"
  238.11 -
  238.12 -#include "../../Common/MethodId.h"
  238.13 -
  238.14 -#include "7zHeader.h"
  238.15 -
  238.16 -namespace NArchive {
  238.17 -namespace N7z {
  238.18 -
  238.19 -typedef UInt32 CNum;
  238.20 -const CNum kNumMax     = 0x7FFFFFFF;
  238.21 -const CNum kNumNoIndex = 0xFFFFFFFF;
  238.22 -
  238.23 -struct CCoderInfo
  238.24 -{
  238.25 -  CMethodId MethodID;
  238.26 -  CByteBuffer Props;
  238.27 -  CNum NumInStreams;
  238.28 -  CNum NumOutStreams;
  238.29 -  bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
  238.30 -};
  238.31 -
  238.32 -struct CBindPair
  238.33 -{
  238.34 -  CNum InIndex;
  238.35 -  CNum OutIndex;
  238.36 -};
  238.37 -
  238.38 -struct CFolder
  238.39 -{
  238.40 -  CObjectVector<CCoderInfo> Coders;
  238.41 -  CRecordVector<CBindPair> BindPairs;
  238.42 -  CRecordVector<CNum> PackStreams;
  238.43 -  CRecordVector<UInt64> UnpackSizes;
  238.44 -  UInt32 UnpackCRC;
  238.45 -  bool UnpackCRCDefined;
  238.46 -
  238.47 -  CFolder(): UnpackCRCDefined(false) {}
  238.48 -
  238.49 -  UInt64 GetUnpackSize() const // test it
  238.50 -  {
  238.51 -    if (UnpackSizes.IsEmpty())
  238.52 -      return 0;
  238.53 -    for (int i = UnpackSizes.Size() - 1; i >= 0; i--)
  238.54 -      if (FindBindPairForOutStream(i) < 0)
  238.55 -        return UnpackSizes[i];
  238.56 -    throw 1;
  238.57 -  }
  238.58 -
  238.59 -  CNum GetNumOutStreams() const
  238.60 -  {
  238.61 -    CNum result = 0;
  238.62 -    for (int i = 0; i < Coders.Size(); i++)
  238.63 -      result += Coders[i].NumOutStreams;
  238.64 -    return result;
  238.65 -  }
  238.66 -
  238.67 -  int FindBindPairForInStream(CNum inStreamIndex) const
  238.68 -  {
  238.69 -    for(int i = 0; i < BindPairs.Size(); i++)
  238.70 -      if (BindPairs[i].InIndex == inStreamIndex)
  238.71 -        return i;
  238.72 -    return -1;
  238.73 -  }
  238.74 -  int FindBindPairForOutStream(CNum outStreamIndex) const
  238.75 -  {
  238.76 -    for(int i = 0; i < BindPairs.Size(); i++)
  238.77 -      if (BindPairs[i].OutIndex == outStreamIndex)
  238.78 -        return i;
  238.79 -    return -1;
  238.80 -  }
  238.81 -  int FindPackStreamArrayIndex(CNum inStreamIndex) const
  238.82 -  {
  238.83 -    for(int i = 0; i < PackStreams.Size(); i++)
  238.84 -      if (PackStreams[i] == inStreamIndex)
  238.85 -        return i;
  238.86 -    return -1;
  238.87 -  }
  238.88 -
  238.89 -  bool CheckStructure() const;
  238.90 -};
  238.91 -
  238.92 -struct CUInt64DefVector
  238.93 -{
  238.94 -  CRecordVector<UInt64> Values;
  238.95 -  CRecordVector<bool> Defined;
  238.96 -  
  238.97 -  void Clear()
  238.98 -  {
  238.99 -    Values.Clear();
 238.100 -    Defined.Clear();
 238.101 -  }
 238.102 -  
 238.103 -  void ReserveDown()
 238.104 -  {
 238.105 -    Values.ReserveDown();
 238.106 -    Values.ReserveDown();
 238.107 -  }
 238.108 -
 238.109 -  bool GetItem(int index, UInt64 &value) const
 238.110 -  {
 238.111 -    if (index < Defined.Size() && Defined[index])
 238.112 -    {
 238.113 -      value = Values[index];
 238.114 -      return true;
 238.115 -    }
 238.116 -    value = 0;
 238.117 -    return false;
 238.118 -  }
 238.119 -  
 238.120 -  void SetItem(int index, bool defined, UInt64 value)
 238.121 -  {
 238.122 -    while (index >= Defined.Size())
 238.123 -      Defined.Add(false);
 238.124 -    Defined[index] = defined;
 238.125 -    if (!defined)
 238.126 -      return;
 238.127 -    while (index >= Values.Size())
 238.128 -      Values.Add(0);
 238.129 -    Values[index] = value;
 238.130 -  }
 238.131 -
 238.132 -  bool CheckSize(int size) const { return Defined.Size() == size || Defined.Size() == 0; }
 238.133 -};
 238.134 -
 238.135 -struct CFileItem
 238.136 -{
 238.137 -  UInt64 Size;
 238.138 -  UInt32 Attrib;
 238.139 -  UInt32 Crc;
 238.140 -  UString Name;
 238.141 -
 238.142 -  bool HasStream; // Test it !!! it means that there is
 238.143 -                  // stream in some folder. It can be empty stream
 238.144 -  bool IsDir;
 238.145 -  bool CrcDefined;
 238.146 -  bool AttribDefined;
 238.147 -
 238.148 -  CFileItem():
 238.149 -    HasStream(true),
 238.150 -    IsDir(false),
 238.151 -    CrcDefined(false),
 238.152 -    AttribDefined(false)
 238.153 -      {}
 238.154 -  void SetAttrib(UInt32 attrib)
 238.155 -  {
 238.156 -    AttribDefined = true;
 238.157 -    Attrib = attrib;
 238.158 -  }
 238.159 -};
 238.160 -
 238.161 -struct CFileItem2
 238.162 -{
 238.163 -  UInt64 CTime;
 238.164 -  UInt64 ATime;
 238.165 -  UInt64 MTime;
 238.166 -  UInt64 StartPos;
 238.167 -  bool CTimeDefined;
 238.168 -  bool ATimeDefined;
 238.169 -  bool MTimeDefined;
 238.170 -  bool StartPosDefined;
 238.171 -  bool IsAnti;
 238.172 -};
 238.173 -
 238.174 -struct CArchiveDatabase
 238.175 -{
 238.176 -  CRecordVector<UInt64> PackSizes;
 238.177 -  CRecordVector<bool> PackCRCsDefined;
 238.178 -  CRecordVector<UInt32> PackCRCs;
 238.179 -  CObjectVector<CFolder> Folders;
 238.180 -  CRecordVector<CNum> NumUnpackStreamsVector;
 238.181 -  CObjectVector<CFileItem> Files;
 238.182 -
 238.183 -  CUInt64DefVector CTime;
 238.184 -  CUInt64DefVector ATime;
 238.185 -  CUInt64DefVector MTime;
 238.186 -  CUInt64DefVector StartPos;
 238.187 -  CRecordVector<bool> IsAnti;
 238.188 -
 238.189 -  void Clear()
 238.190 -  {
 238.191 -    PackSizes.Clear();
 238.192 -    PackCRCsDefined.Clear();
 238.193 -    PackCRCs.Clear();
 238.194 -    Folders.Clear();
 238.195 -    NumUnpackStreamsVector.Clear();
 238.196 -    Files.Clear();
 238.197 -    CTime.Clear();
 238.198 -    ATime.Clear();
 238.199 -    MTime.Clear();
 238.200 -    StartPos.Clear();
 238.201 -    IsAnti.Clear();
 238.202 -  }
 238.203 -
 238.204 -  void ReserveDown()
 238.205 -  {
 238.206 -    PackSizes.ReserveDown();
 238.207 -    PackCRCsDefined.ReserveDown();
 238.208 -    PackCRCs.ReserveDown();
 238.209 -    Folders.ReserveDown();
 238.210 -    NumUnpackStreamsVector.ReserveDown();
 238.211 -    Files.ReserveDown();
 238.212 -    CTime.ReserveDown();
 238.213 -    ATime.ReserveDown();
 238.214 -    MTime.ReserveDown();
 238.215 -    StartPos.ReserveDown();
 238.216 -    IsAnti.ReserveDown();
 238.217 -  }
 238.218 -
 238.219 -  bool IsEmpty() const
 238.220 -  {
 238.221 -    return (PackSizes.IsEmpty() &&
 238.222 -      PackCRCsDefined.IsEmpty() &&
 238.223 -      PackCRCs.IsEmpty() &&
 238.224 -      Folders.IsEmpty() &&
 238.225 -      NumUnpackStreamsVector.IsEmpty() &&
 238.226 -      Files.IsEmpty());
 238.227 -  }
 238.228 -
 238.229 -  bool CheckNumFiles() const
 238.230 -  {
 238.231 -    int size = Files.Size();
 238.232 -    return (
 238.233 -      CTime.CheckSize(size) &&
 238.234 -      ATime.CheckSize(size) &&
 238.235 -      MTime.CheckSize(size) &&
 238.236 -      StartPos.CheckSize(size) &&
 238.237 -      (size == IsAnti.Size() || IsAnti.Size() == 0));
 238.238 -  }
 238.239 -
 238.240 -  bool IsSolid() const
 238.241 -  {
 238.242 -    for (int i = 0; i < NumUnpackStreamsVector.Size(); i++)
 238.243 -      if (NumUnpackStreamsVector[i] > 1)
 238.244 -        return true;
 238.245 -    return false;
 238.246 -  }
 238.247 -  bool IsItemAnti(int index) const { return (index < IsAnti.Size() && IsAnti[index]); }
 238.248 -  void SetItemAnti(int index, bool isAnti)
 238.249 -  {
 238.250 -    while (index >= IsAnti.Size())
 238.251 -      IsAnti.Add(false);
 238.252 -    IsAnti[index] = isAnti;
 238.253 -  }
 238.254 -
 238.255 -  void GetFile(int index, CFileItem &file, CFileItem2 &file2) const;
 238.256 -  void AddFile(const CFileItem &file, const CFileItem2 &file2);
 238.257 -};
 238.258 -
 238.259 -}}
 238.260 -
 238.261 -#endif
   239.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zProperties.cpp	Sat Mar 03 10:54:39 2012 -0600
   239.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   239.3 @@ -1,163 +0,0 @@
   239.4 -// 7zProperties.cpp
   239.5 -
   239.6 -#include "StdAfx.h"
   239.7 -
   239.8 -#include "7zProperties.h"
   239.9 -#include "7zHeader.h"
  239.10 -#include "7zHandler.h"
  239.11 -
  239.12 -// #define _MULTI_PACK
  239.13 -
  239.14 -namespace NArchive {
  239.15 -namespace N7z {
  239.16 -
  239.17 -struct CPropMap
  239.18 -{
  239.19 -  UInt64 FilePropID;
  239.20 -  STATPROPSTG StatPROPSTG;
  239.21 -};
  239.22 -
  239.23 -CPropMap kPropMap[] =
  239.24 -{
  239.25 -  { NID::kName, NULL, kpidPath, VT_BSTR},
  239.26 -  { NID::kSize, NULL, kpidSize, VT_UI8},
  239.27 -  { NID::kPackInfo, NULL, kpidPackSize, VT_UI8},
  239.28 -  
  239.29 -  #ifdef _MULTI_PACK
  239.30 -  { 100, L"Pack0", kpidPackedSize0, VT_UI8},
  239.31 -  { 101, L"Pack1", kpidPackedSize1, VT_UI8},
  239.32 -  { 102, L"Pack2", kpidPackedSize2, VT_UI8},
  239.33 -  { 103, L"Pack3", kpidPackedSize3, VT_UI8},
  239.34 -  { 104, L"Pack4", kpidPackedSize4, VT_UI8},
  239.35 -  #endif
  239.36 -
  239.37 -  { NID::kCTime, NULL, kpidCTime, VT_FILETIME},
  239.38 -  { NID::kMTime, NULL, kpidMTime, VT_FILETIME},
  239.39 -  { NID::kATime, NULL, kpidATime, VT_FILETIME},
  239.40 -  { NID::kWinAttributes, NULL, kpidAttrib, VT_UI4},
  239.41 -  { NID::kStartPos, NULL, kpidPosition, VT_UI4},
  239.42 -
  239.43 -  { NID::kCRC, NULL, kpidCRC, VT_UI4},
  239.44 -  
  239.45 -  { NID::kAnti, NULL, kpidIsAnti, VT_BOOL},
  239.46 -
  239.47 -  #ifndef _SFX
  239.48 -  { 97, NULL, kpidEncrypted, VT_BOOL},
  239.49 -  { 98, NULL, kpidMethod, VT_BSTR},
  239.50 -  { 99, NULL, kpidBlock, VT_UI4}
  239.51 -  #endif
  239.52 -};
  239.53 -
  239.54 -static const int kPropMapSize = sizeof(kPropMap) / sizeof(kPropMap[0]);
  239.55 -
  239.56 -static int FindPropInMap(UInt64 filePropID)
  239.57 -{
  239.58 -  for (int i = 0; i < kPropMapSize; i++)
  239.59 -    if (kPropMap[i].FilePropID == filePropID)
  239.60 -      return i;
  239.61 -  return -1;
  239.62 -}
  239.63 -
  239.64 -static void CopyOneItem(CRecordVector<UInt64> &src,
  239.65 -    CRecordVector<UInt64> &dest, UInt32 item)
  239.66 -{
  239.67 -  for (int i = 0; i < src.Size(); i++)
  239.68 -    if (src[i] == item)
  239.69 -    {
  239.70 -      dest.Add(item);
  239.71 -      src.Delete(i);
  239.72 -      return;
  239.73 -    }
  239.74 -}
  239.75 -
  239.76 -static void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item)
  239.77 -{
  239.78 -  for (int i = 0; i < src.Size(); i++)
  239.79 -    if (src[i] == item)
  239.80 -    {
  239.81 -      src.Delete(i);
  239.82 -      return;
  239.83 -    }
  239.84 -}
  239.85 -
  239.86 -static void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item)
  239.87 -{
  239.88 -  for (int i = 0; i < dest.Size(); i++)
  239.89 -    if (dest[i] == item)
  239.90 -    {
  239.91 -      dest.Delete(i);
  239.92 -      break;
  239.93 -    }
  239.94 -  dest.Insert(0, item);
  239.95 -}
  239.96 -
  239.97 -void CHandler::FillPopIDs()
  239.98 -{
  239.99 -  _fileInfoPopIDs.Clear();
 239.100 -
 239.101 -  #ifdef _7Z_VOL
 239.102 -  if(_volumes.Size() < 1)
 239.103 -    return;
 239.104 -  const CVolume &volume = _volumes.Front();
 239.105 -  const CArchiveDatabaseEx &_db = volume.Database;
 239.106 -  #endif
 239.107 -
 239.108 -  CRecordVector<UInt64> fileInfoPopIDs = _db.ArchiveInfo.FileInfoPopIDs;
 239.109 -
 239.110 -  RemoveOneItem(fileInfoPopIDs, NID::kEmptyStream);
 239.111 -  RemoveOneItem(fileInfoPopIDs, NID::kEmptyFile);
 239.112 -
 239.113 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kName);
 239.114 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kAnti);
 239.115 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kSize);
 239.116 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kPackInfo);
 239.117 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCTime);
 239.118 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kMTime);
 239.119 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kATime);
 239.120 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kWinAttributes);
 239.121 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCRC);
 239.122 -  CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kComment);
 239.123 -  _fileInfoPopIDs += fileInfoPopIDs;
 239.124 - 
 239.125 -  #ifndef _SFX
 239.126 -  _fileInfoPopIDs.Add(97);
 239.127 -  _fileInfoPopIDs.Add(98);
 239.128 -  _fileInfoPopIDs.Add(99);
 239.129 -  #endif
 239.130 -  #ifdef _MULTI_PACK
 239.131 -  _fileInfoPopIDs.Add(100);
 239.132 -  _fileInfoPopIDs.Add(101);
 239.133 -  _fileInfoPopIDs.Add(102);
 239.134 -  _fileInfoPopIDs.Add(103);
 239.135 -  _fileInfoPopIDs.Add(104);
 239.136 -  #endif
 239.137 -
 239.138 -  #ifndef _SFX
 239.139 -  InsertToHead(_fileInfoPopIDs, NID::kMTime);
 239.140 -  InsertToHead(_fileInfoPopIDs, NID::kPackInfo);
 239.141 -  InsertToHead(_fileInfoPopIDs, NID::kSize);
 239.142 -  InsertToHead(_fileInfoPopIDs, NID::kName);
 239.143 -  #endif
 239.144 -}
 239.145 -
 239.146 -STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
 239.147 -{
 239.148 -  *numProperties = _fileInfoPopIDs.Size();
 239.149 -  return S_OK;
 239.150 -}
 239.151 -
 239.152 -STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
 239.153 -{
 239.154 -  if ((int)index >= _fileInfoPopIDs.Size())
 239.155 -    return E_INVALIDARG;
 239.156 -  int indexInMap = FindPropInMap(_fileInfoPopIDs[index]);
 239.157 -  if (indexInMap == -1)
 239.158 -    return E_INVALIDARG;
 239.159 -  const STATPROPSTG &srcItem = kPropMap[indexInMap].StatPROPSTG;
 239.160 -  *propID = srcItem.propid;
 239.161 -  *varType = srcItem.vt;
 239.162 -  *name = 0;
 239.163 -  return S_OK;
 239.164 -}
 239.165 -
 239.166 -}}
   240.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zProperties.h	Sat Mar 03 10:54:39 2012 -0600
   240.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   240.3 @@ -1,22 +0,0 @@
   240.4 -// 7zProperties.h
   240.5 -
   240.6 -#ifndef __7Z_PROPERTIES_H
   240.7 -#define __7Z_PROPERTIES_H
   240.8 -
   240.9 -#include "../../PropID.h"
  240.10 -
  240.11 -namespace NArchive {
  240.12 -namespace N7z {
  240.13 -
  240.14 -enum
  240.15 -{
  240.16 -  kpidPackedSize0 = kpidUserDefined,
  240.17 -  kpidPackedSize1,
  240.18 -  kpidPackedSize2,
  240.19 -  kpidPackedSize3,
  240.20 -  kpidPackedSize4
  240.21 -};
  240.22 -
  240.23 -}}
  240.24 -
  240.25 -#endif
   241.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   241.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   241.3 @@ -1,18 +0,0 @@
   241.4 -// 7zRegister.cpp
   241.5 -
   241.6 -#include "StdAfx.h"
   241.7 -
   241.8 -#include "../../Common/RegisterArc.h"
   241.9 -
  241.10 -#include "7zHandler.h"
  241.11 -static IInArchive *CreateArc() { return new NArchive::N7z::CHandler;  }
  241.12 -#ifndef EXTRACT_ONLY
  241.13 -static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler;  }
  241.14 -#else
  241.15 -#define CreateArcOut 0
  241.16 -#endif
  241.17 -
  241.18 -static CArcInfo g_ArcInfo =
  241.19 -  { L"7z", L"7z", 0, 7, {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut };
  241.20 -
  241.21 -REGISTER_ARC(7z)
   242.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   242.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   242.3 @@ -1,24 +0,0 @@
   242.4 -// 7zSpecStream.cpp
   242.5 -
   242.6 -#include "StdAfx.h"
   242.7 -
   242.8 -#include "7zSpecStream.h"
   242.9 -
  242.10 -STDMETHODIMP CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32 *processedSize)
  242.11 -{
  242.12 -  UInt32 realProcessedSize;
  242.13 -  HRESULT result = _stream->Read(data, size, &realProcessedSize);
  242.14 -  _size += realProcessedSize;
  242.15 -  if (processedSize != 0)
  242.16 -    *processedSize = realProcessedSize;
  242.17 -  return result;
  242.18 -}
  242.19 -
  242.20 -STDMETHODIMP CSequentialInStreamSizeCount2::GetSubStreamSize(
  242.21 -    UInt64 subStream, UInt64 *value)
  242.22 -{
  242.23 -  if (_getSubStreamSize == NULL)
  242.24 -    return E_NOTIMPL;
  242.25 -  return  _getSubStreamSize->GetSubStreamSize(subStream, value);
  242.26 -}
  242.27 -
   243.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/7zSpecStream.h	Sat Mar 03 10:54:39 2012 -0600
   243.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   243.3 @@ -1,35 +0,0 @@
   243.4 -// 7zSpecStream.h
   243.5 -
   243.6 -#ifndef __7Z_SPEC_STREAM_H
   243.7 -#define __7Z_SPEC_STREAM_H
   243.8 -
   243.9 -#include "../../IStream.h"
  243.10 -#include "../../ICoder.h"
  243.11 -#include "../../../Common/MyCom.h"
  243.12 -
  243.13 -class CSequentialInStreamSizeCount2:
  243.14 -  public ISequentialInStream,
  243.15 -  public ICompressGetSubStreamSize,
  243.16 -  public CMyUnknownImp
  243.17 -{
  243.18 -  CMyComPtr<ISequentialInStream> _stream;
  243.19 -  CMyComPtr<ICompressGetSubStreamSize> _getSubStreamSize;
  243.20 -  UInt64 _size;
  243.21 -public:
  243.22 -  void Init(ISequentialInStream *stream)
  243.23 -  {
  243.24 -    _stream = stream;
  243.25 -    _getSubStreamSize = 0;
  243.26 -    _stream.QueryInterface(IID_ICompressGetSubStreamSize, &_getSubStreamSize);
  243.27 -    _size = 0;
  243.28 -  }
  243.29 -  UInt64 GetSize() const { return _size; }
  243.30 -
  243.31 -  MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)
  243.32 -
  243.33 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  243.34 -
  243.35 -  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
  243.36 -};
  243.37 -
  243.38 -#endif
   244.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/7z/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   244.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   244.3 @@ -1,9 +0,0 @@
   244.4 -// StdAfx.h
   244.5 -
   244.6 -#ifndef __STDAFX_H
   244.7 -#define __STDAFX_H
   244.8 -
   244.9 -#include "../../../Common/MyWindows.h"
  244.10 -#include "../../../Common/NewHandler.h"
  244.11 -
  244.12 -#endif
   245.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/ArchiveExports.cpp	Sat Mar 03 10:54:39 2012 -0600
   245.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   245.3 @@ -1,130 +0,0 @@
   245.4 -// ArchiveExports.cpp
   245.5 -
   245.6 -#include "StdAfx.h"
   245.7 -
   245.8 -#include "../../Common/ComTry.h"
   245.9 -#include "../../Common/Types.h"
  245.10 -#include "../../Windows/PropVariant.h"
  245.11 -#include "../Common/RegisterArc.h"
  245.12 -
  245.13 -#include "IArchive.h"
  245.14 -#include "../ICoder.h"
  245.15 -#include "../IPassword.h"
  245.16 -
  245.17 -static const unsigned int kNumArcsMax = 32;
  245.18 -static unsigned int g_NumArcs = 0;
  245.19 -static const CArcInfo *g_Arcs[kNumArcsMax];
  245.20 -void RegisterArc(const CArcInfo *arcInfo)
  245.21 -{
  245.22 -  if (g_NumArcs < kNumArcsMax)
  245.23 -    g_Arcs[g_NumArcs++] = arcInfo;
  245.24 -}
  245.25 -
  245.26 -DEFINE_GUID(CLSID_CArchiveHandler,
  245.27 -0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
  245.28 -
  245.29 -#define CLS_ARC_ID_ITEM(cls) ((cls).Data4[5])
  245.30 -
  245.31 -static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
  245.32 -{
  245.33 -  if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
  245.34 -    value->vt = VT_BSTR;
  245.35 -  return S_OK;
  245.36 -}
  245.37 -
  245.38 -static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
  245.39 -{
  245.40 -  return SetPropString((const char *)&guid, sizeof(GUID), value);
  245.41 -}
  245.42 -
  245.43 -int FindFormatCalssId(const GUID *clsID)
  245.44 -{
  245.45 -  GUID cls = *clsID;
  245.46 -  CLS_ARC_ID_ITEM(cls) = 0;
  245.47 -  if (cls != CLSID_CArchiveHandler)
  245.48 -    return -1;
  245.49 -  Byte id = CLS_ARC_ID_ITEM(*clsID);
  245.50 -  for (unsigned i = 0; i < g_NumArcs; i++)
  245.51 -    if (g_Arcs[i]->ClassId == id)
  245.52 -      return (int)i;
  245.53 -  return -1;
  245.54 -}
  245.55 -
  245.56 -STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject)
  245.57 -{
  245.58 -  COM_TRY_BEGIN
  245.59 -  {
  245.60 -    int needIn = (*iid == IID_IInArchive);
  245.61 -    int needOut = (*iid == IID_IOutArchive);
  245.62 -    if (!needIn && !needOut)
  245.63 -      return E_NOINTERFACE;
  245.64 -    int formatIndex = FindFormatCalssId(clsid);
  245.65 -    if (formatIndex < 0)
  245.66 -      return CLASS_E_CLASSNOTAVAILABLE;
  245.67 -    
  245.68 -    const CArcInfo &arc = *g_Arcs[formatIndex];
  245.69 -    if (needIn)
  245.70 -    {
  245.71 -      *outObject = arc.CreateInArchive();
  245.72 -      ((IInArchive *)*outObject)->AddRef();
  245.73 -    }
  245.74 -    else
  245.75 -    {
  245.76 -      if (!arc.CreateOutArchive)
  245.77 -        return CLASS_E_CLASSNOTAVAILABLE;
  245.78 -      *outObject = arc.CreateOutArchive();
  245.79 -      ((IOutArchive *)*outObject)->AddRef();
  245.80 -    }
  245.81 -  }
  245.82 -  COM_TRY_END
  245.83 -  return S_OK;
  245.84 -}
  245.85 -
  245.86 -STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value)
  245.87 -{
  245.88 -  if (formatIndex >= g_NumArcs)
  245.89 -    return E_INVALIDARG;
  245.90 -  const CArcInfo &arc = *g_Arcs[formatIndex];
  245.91 -  NWindows::NCOM::CPropVariant prop;
  245.92 -  switch(propID)
  245.93 -  {
  245.94 -    case NArchive::kName:
  245.95 -      prop = arc.Name;
  245.96 -      break;
  245.97 -    case NArchive::kClassID:
  245.98 -    {
  245.99 -      GUID clsId = CLSID_CArchiveHandler;
 245.100 -      CLS_ARC_ID_ITEM(clsId) = arc.ClassId;
 245.101 -      return SetPropGUID(clsId, value);
 245.102 -    }
 245.103 -    case NArchive::kExtension:
 245.104 -      if (arc.Ext != 0)
 245.105 -        prop = arc.Ext;
 245.106 -      break;
 245.107 -    case NArchive::kAddExtension:
 245.108 -      if (arc.AddExt != 0)
 245.109 -        prop = arc.AddExt;
 245.110 -      break;
 245.111 -    case NArchive::kUpdate:
 245.112 -      prop = (bool)(arc.CreateOutArchive != 0);
 245.113 -      break;
 245.114 -    case NArchive::kKeepName:
 245.115 -      prop = arc.KeepName;
 245.116 -      break;
 245.117 -    case NArchive::kStartSignature:
 245.118 -      return SetPropString((const char *)arc.Signature, arc.SignatureSize, value);
 245.119 -  }
 245.120 -  prop.Detach(value);
 245.121 -  return S_OK;
 245.122 -}
 245.123 -
 245.124 -STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
 245.125 -{
 245.126 -  return GetHandlerProperty2(0, propID, value);
 245.127 -}
 245.128 -
 245.129 -STDAPI GetNumberOfFormats(UINT32 *numFormats)
 245.130 -{
 245.131 -  *numFormats = g_NumArcs;
 245.132 -  return S_OK;
 245.133 -}
   246.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp	Sat Mar 03 10:54:39 2012 -0600
   246.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   246.3 @@ -1,216 +0,0 @@
   246.4 -// BZip2Handler.cpp
   246.5 -
   246.6 -#include "StdAfx.h"
   246.7 -
   246.8 -#include "Common/ComTry.h"
   246.9 -
  246.10 -#include "Windows/PropVariant.h"
  246.11 -
  246.12 -#include "../../Common/CreateCoder.h"
  246.13 -#include "../../Common/ProgressUtils.h"
  246.14 -#include "../../Common/StreamUtils.h"
  246.15 -
  246.16 -#include "../Common/DummyOutStream.h"
  246.17 -
  246.18 -#include "BZip2Handler.h"
  246.19 -
  246.20 -using namespace NWindows;
  246.21 -
  246.22 -namespace NArchive {
  246.23 -namespace NBZip2 {
  246.24 -
  246.25 -static const CMethodId kMethodId_BZip2 = 0x040202;
  246.26 -
  246.27 -STATPROPSTG kProps[] =
  246.28 -{
  246.29 -  { NULL, kpidPackSize, VT_UI8}
  246.30 -};
  246.31 -
  246.32 -IMP_IInArchive_Props
  246.33 -IMP_IInArchive_ArcProps_NO
  246.34 -
  246.35 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
  246.36 -{
  246.37 -  *numItems = 1;
  246.38 -  return S_OK;
  246.39 -}
  246.40 -
  246.41 -STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID,  PROPVARIANT *value)
  246.42 -{
  246.43 -  NWindows::NCOM::CPropVariant prop;
  246.44 -  switch(propID)
  246.45 -  {
  246.46 -    case kpidPackSize: prop = _item.PackSize; break;
  246.47 -  }
  246.48 -  prop.Detach(value);
  246.49 -  return S_OK;
  246.50 -}
  246.51 -
  246.52 -STDMETHODIMP CHandler::Open(IInStream *stream,
  246.53 -    const UInt64 * /* maxCheckStartPosition */,
  246.54 -    IArchiveOpenCallback * /* openArchiveCallback */)
  246.55 -{
  246.56 -  COM_TRY_BEGIN
  246.57 -  try
  246.58 -  {
  246.59 -    RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
  246.60 -    const int kSignatureSize = 3;
  246.61 -    Byte buffer[kSignatureSize];
  246.62 -    RINOK(ReadStream_FALSE(stream, buffer, kSignatureSize));
  246.63 -    if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
  246.64 -      return S_FALSE;
  246.65 -
  246.66 -    UInt64 endPosition;
  246.67 -    RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
  246.68 -    _item.PackSize = endPosition - _streamStartPosition;
  246.69 -    
  246.70 -    _stream = stream;
  246.71 -  }
  246.72 -  catch(...)
  246.73 -  {
  246.74 -    return S_FALSE;
  246.75 -  }
  246.76 -  return S_OK;
  246.77 -  COM_TRY_END
  246.78 -}
  246.79 -
  246.80 -STDMETHODIMP CHandler::Close()
  246.81 -{
  246.82 -  _stream.Release();
  246.83 -  return S_OK;
  246.84 -}
  246.85 -
  246.86 -
  246.87 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
  246.88 -    Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
  246.89 -{
  246.90 -  COM_TRY_BEGIN
  246.91 -  bool allFilesMode = (numItems == UInt32(-1));
  246.92 -  if (!allFilesMode)
  246.93 -  {
  246.94 -    if (numItems == 0)
  246.95 -      return S_OK;
  246.96 -    if (numItems != 1)
  246.97 -      return E_INVALIDARG;
  246.98 -    if (indices[0] != 0)
  246.99 -      return E_INVALIDARG;
 246.100 -  }
 246.101 -
 246.102 -  bool testMode = (testModeSpec != 0);
 246.103 -
 246.104 -  extractCallback->SetTotal(_item.PackSize);
 246.105 -
 246.106 -  UInt64 currentTotalPacked = 0;
 246.107 -  
 246.108 -  RINOK(extractCallback->SetCompleted(&currentTotalPacked));
 246.109 -  
 246.110 -  CMyComPtr<ISequentialOutStream> realOutStream;
 246.111 -  Int32 askMode;
 246.112 -  askMode = testMode ? NExtract::NAskMode::kTest :
 246.113 -  NExtract::NAskMode::kExtract;
 246.114 -  
 246.115 -  RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
 246.116 -    
 246.117 -  if(!testMode && !realOutStream)
 246.118 -    return S_OK;
 246.119 -
 246.120 -
 246.121 -  extractCallback->PrepareOperation(askMode);
 246.122 -
 246.123 -  CMyComPtr<ICompressCoder> decoder;
 246.124 -  HRESULT loadResult = CreateCoder(
 246.125 -      EXTERNAL_CODECS_VARS
 246.126 -      kMethodId_BZip2, decoder, false);
 246.127 -  if (loadResult != S_OK || !decoder)
 246.128 -  {
 246.129 -    RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
 246.130 -    return S_OK;
 246.131 -  }
 246.132 -
 246.133 -  #ifdef COMPRESS_MT
 246.134 -  {
 246.135 -    CMyComPtr<ICompressSetCoderMt> setCoderMt;
 246.136 -    decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
 246.137 -    if (setCoderMt)
 246.138 -    {
 246.139 -      RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
 246.140 -    }
 246.141 -  }
 246.142 -  #endif
 246.143 -
 246.144 -  CDummyOutStream *outStreamSpec = new CDummyOutStream;
 246.145 -  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 246.146 -  outStreamSpec->SetStream(realOutStream);
 246.147 -  outStreamSpec->Init();
 246.148 -  
 246.149 -  realOutStream.Release();
 246.150 -
 246.151 -  CLocalProgress *lps = new CLocalProgress;
 246.152 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 246.153 -  lps->Init(extractCallback, true);
 246.154 -  
 246.155 -  RINOK(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL));
 246.156 -
 246.157 -  HRESULT result = S_OK;
 246.158 -
 246.159 -  bool firstItem = true;
 246.160 -  for (;;)
 246.161 -  {
 246.162 -    lps->InSize = currentTotalPacked;
 246.163 -    lps->OutSize = outStreamSpec->GetSize();
 246.164 -
 246.165 -    RINOK(lps->SetCur());
 246.166 -
 246.167 -    const int kSignatureSize = 3;
 246.168 -    Byte buffer[kSignatureSize];
 246.169 -    size_t processedSize = kSignatureSize;
 246.170 -    RINOK(ReadStream(_stream, buffer, &processedSize));
 246.171 -    if (processedSize != kSignatureSize)
 246.172 -    {
 246.173 -      if (firstItem)
 246.174 -        return E_FAIL;
 246.175 -      break;
 246.176 -    }
 246.177 -    if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
 246.178 -    {
 246.179 -      if (firstItem)
 246.180 -        return E_FAIL;
 246.181 -      break;
 246.182 -    }
 246.183 -    firstItem = false;
 246.184 -
 246.185 -    UInt64 dataStartPos;
 246.186 -    RINOK(_stream->Seek((UInt64)(Int64)(-3), STREAM_SEEK_CUR, &dataStartPos));
 246.187 -
 246.188 -    result = decoder->Code(_stream, outStream, NULL, NULL, progress);
 246.189 -
 246.190 -    if (result != S_OK)
 246.191 -      break;
 246.192 -
 246.193 -    CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
 246.194 -    decoder.QueryInterface(IID_ICompressGetInStreamProcessedSize, &getInStreamProcessedSize);
 246.195 -    if (!getInStreamProcessedSize)
 246.196 -      break;
 246.197 -    UInt64 packSize;
 246.198 -    RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
 246.199 -    UInt64 pos;
 246.200 -    RINOK(_stream->Seek(dataStartPos + packSize, STREAM_SEEK_SET, &pos));
 246.201 -    currentTotalPacked = pos - _streamStartPosition;
 246.202 -  }
 246.203 -  outStream.Release();
 246.204 -
 246.205 -  Int32 retResult;
 246.206 -  if (result == S_OK)
 246.207 -    retResult = NExtract::NOperationResult::kOK;
 246.208 -  else if (result == S_FALSE)
 246.209 -    retResult = NExtract::NOperationResult::kDataError;
 246.210 -  else
 246.211 -    return result;
 246.212 -  return extractCallback->SetOperationResult(retResult);
 246.213 -
 246.214 -  COM_TRY_END
 246.215 -}
 246.216 -
 246.217 -IMPL_ISetCompressCodecsInfo
 246.218 -
 246.219 -}}
   247.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h	Sat Mar 03 10:54:39 2012 -0600
   247.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   247.3 @@ -1,70 +0,0 @@
   247.4 -// BZip2/Handler.h
   247.5 -
   247.6 -#ifndef __BZIP2_HANDLER_H
   247.7 -#define __BZIP2_HANDLER_H
   247.8 -
   247.9 -#include "Common/MyCom.h"
  247.10 -#include "../IArchive.h"
  247.11 -#include "../../Common/CreateCoder.h"
  247.12 -#include "BZip2Item.h"
  247.13 -
  247.14 -#ifdef COMPRESS_MT
  247.15 -#include "../../../Windows/System.h"
  247.16 -#endif
  247.17 -
  247.18 -namespace NArchive {
  247.19 -namespace NBZip2 {
  247.20 -
  247.21 -class CHandler:
  247.22 -  public IInArchive,
  247.23 -  public IOutArchive,
  247.24 -  public ISetProperties,
  247.25 -  PUBLIC_ISetCompressCodecsInfo
  247.26 -  public CMyUnknownImp
  247.27 -{
  247.28 -  CMyComPtr<IInStream> _stream;
  247.29 -  NArchive::NBZip2::CItem _item;
  247.30 -  UInt64 _streamStartPosition;
  247.31 -
  247.32 -  UInt32 _level;
  247.33 -  UInt32 _dicSize;
  247.34 -  UInt32 _numPasses;
  247.35 -  #ifdef COMPRESS_MT
  247.36 -  UInt32 _numThreads;
  247.37 -  #endif
  247.38 -
  247.39 -  DECL_EXTERNAL_CODECS_VARS
  247.40 -
  247.41 -  void InitMethodProperties()
  247.42 -  {
  247.43 -    _level = 5;
  247.44 -    _dicSize =
  247.45 -    _numPasses = 0xFFFFFFFF;
  247.46 -    #ifdef COMPRESS_MT
  247.47 -    _numThreads = NWindows::NSystem::GetNumberOfProcessors();;
  247.48 -    #endif
  247.49 -  }
  247.50 -
  247.51 -public:
  247.52 -  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  247.53 -  MY_QUERYINTERFACE_ENTRY(IOutArchive)
  247.54 -  MY_QUERYINTERFACE_ENTRY(ISetProperties)
  247.55 -  QUERY_ENTRY_ISetCompressCodecsInfo
  247.56 -  MY_QUERYINTERFACE_END
  247.57 -  MY_ADDREF_RELEASE
  247.58 -
  247.59 -  INTERFACE_IInArchive(;)
  247.60 -#ifndef EXTRACT_ONLY
  247.61 -  INTERFACE_IOutArchive(;)
  247.62 -
  247.63 -  STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
  247.64 -#endif
  247.65 -
  247.66 -  DECL_ISetCompressCodecsInfo
  247.67 -
  247.68 -  CHandler() { InitMethodProperties(); }
  247.69 -};
  247.70 -
  247.71 -}}
  247.72 -
  247.73 -#endif
   248.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/BZip2/BZip2Item.h	Sat Mar 03 10:54:39 2012 -0600
   248.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   248.3 @@ -1,20 +0,0 @@
   248.4 -// Archive/BZip2Item.h
   248.5 -
   248.6 -#ifndef __ARCHIVE_BZIP2_ITEM_H
   248.7 -#define __ARCHIVE_BZIP2_ITEM_H
   248.8 -
   248.9 -namespace NArchive {
  248.10 -namespace NBZip2 {
  248.11 -  
  248.12 -struct CItem
  248.13 -{
  248.14 -  UInt64 PackSize;
  248.15 -  UInt64 UnPackSize;
  248.16 -};
  248.17 -
  248.18 -}}
  248.19 -
  248.20 -#endif
  248.21 -
  248.22 -
  248.23 -
   249.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/BZip2/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   249.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   249.3 @@ -1,8 +0,0 @@
   249.4 -// StdAfx.h
   249.5 -
   249.6 -#ifndef __STDAFX_H
   249.7 -#define __STDAFX_H
   249.8 -
   249.9 -#include "../../../Common/MyWindows.h"
  249.10 -
  249.11 -#endif
   250.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp	Sat Mar 03 10:54:39 2012 -0600
   250.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   250.3 @@ -1,18 +0,0 @@
   250.4 -// BZip2Register.cpp
   250.5 -
   250.6 -#include "StdAfx.h"
   250.7 -
   250.8 -#include "../../Common/RegisterArc.h"
   250.9 -
  250.10 -#include "BZip2Handler.h"
  250.11 -static IInArchive *CreateArc() { return new NArchive::NBZip2::CHandler;  }
  250.12 -#ifndef EXTRACT_ONLY
  250.13 -static IOutArchive *CreateArcOut() { return new NArchive::NBZip2::CHandler;  }
  250.14 -#else
  250.15 -#define CreateArcOut 0
  250.16 -#endif
  250.17 -
  250.18 -static CArcInfo g_ArcInfo =
  250.19 -  { L"BZip2", L"bz2 bzip2 tbz2 tbz", L"* * .tar .tar", 2, { 'B', 'Z', 'h' }, 3, true, CreateArc, CreateArcOut };
  250.20 -
  250.21 -REGISTER_ARC(BZip2)
   251.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp	Sat Mar 03 10:54:39 2012 -0600
   251.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   251.3 @@ -1,121 +0,0 @@
   251.4 -// CoderMixer2.cpp
   251.5 -
   251.6 -#include "StdAfx.h"
   251.7 -
   251.8 -#include "CoderMixer2.h"
   251.9 -
  251.10 -namespace NCoderMixer {
  251.11 -
  251.12 -CBindReverseConverter::CBindReverseConverter(const CBindInfo &srcBindInfo):
  251.13 -  _srcBindInfo(srcBindInfo)
  251.14 -{
  251.15 -  srcBindInfo.GetNumStreams(NumSrcInStreams, _numSrcOutStreams);
  251.16 -
  251.17 -  UInt32  j;
  251.18 -  for (j = 0; j < NumSrcInStreams; j++)
  251.19 -  {
  251.20 -    _srcInToDestOutMap.Add(0);
  251.21 -    DestOutToSrcInMap.Add(0);
  251.22 -  }
  251.23 -  for (j = 0; j < _numSrcOutStreams; j++)
  251.24 -  {
  251.25 -    _srcOutToDestInMap.Add(0);
  251.26 -    _destInToSrcOutMap.Add(0);
  251.27 -  }
  251.28 -
  251.29 -  UInt32 destInOffset = 0;
  251.30 -  UInt32 destOutOffset = 0;
  251.31 -  UInt32 srcInOffset = NumSrcInStreams;
  251.32 -  UInt32 srcOutOffset = _numSrcOutStreams;
  251.33 -
  251.34 -  for (int i = srcBindInfo.Coders.Size() - 1; i >= 0; i--)
  251.35 -  {
  251.36 -    const CCoderStreamsInfo &srcCoderInfo = srcBindInfo.Coders[i];
  251.37 -
  251.38 -    srcInOffset -= srcCoderInfo.NumInStreams;
  251.39 -    srcOutOffset -= srcCoderInfo.NumOutStreams;
  251.40 -    
  251.41 -    UInt32 j;
  251.42 -    for (j = 0; j < srcCoderInfo.NumInStreams; j++, destOutOffset++)
  251.43 -    {
  251.44 -      UInt32 index = srcInOffset + j;
  251.45 -      _srcInToDestOutMap[index] = destOutOffset;
  251.46 -      DestOutToSrcInMap[destOutOffset] = index;
  251.47 -    }
  251.48 -    for (j = 0; j < srcCoderInfo.NumOutStreams; j++, destInOffset++)
  251.49 -    {
  251.50 -      UInt32 index = srcOutOffset + j;
  251.51 -      _srcOutToDestInMap[index] = destInOffset;
  251.52 -      _destInToSrcOutMap[destInOffset] = index;
  251.53 -    }
  251.54 -  }
  251.55 -}
  251.56 -
  251.57 -void CBindReverseConverter::CreateReverseBindInfo(CBindInfo &destBindInfo)
  251.58 -{
  251.59 -  destBindInfo.Coders.Clear();
  251.60 -  destBindInfo.BindPairs.Clear();
  251.61 -  destBindInfo.InStreams.Clear();
  251.62 -  destBindInfo.OutStreams.Clear();
  251.63 -
  251.64 -  int i;
  251.65 -  for (i = _srcBindInfo.Coders.Size() - 1; i >= 0; i--)
  251.66 -  {
  251.67 -    const CCoderStreamsInfo &srcCoderInfo = _srcBindInfo.Coders[i];
  251.68 -    CCoderStreamsInfo destCoderInfo;
  251.69 -    destCoderInfo.NumInStreams = srcCoderInfo.NumOutStreams;
  251.70 -    destCoderInfo.NumOutStreams = srcCoderInfo.NumInStreams;
  251.71 -    destBindInfo.Coders.Add(destCoderInfo);
  251.72 -  }
  251.73 -  for (i = _srcBindInfo.BindPairs.Size() - 1; i >= 0; i--)
  251.74 -  {
  251.75 -    const CBindPair &srcBindPair = _srcBindInfo.BindPairs[i];
  251.76 -    CBindPair destBindPair;
  251.77 -    destBindPair.InIndex = _srcOutToDestInMap[srcBindPair.OutIndex];
  251.78 -    destBindPair.OutIndex = _srcInToDestOutMap[srcBindPair.InIndex];
  251.79 -    destBindInfo.BindPairs.Add(destBindPair);
  251.80 -  }
  251.81 -  for (i = 0; i < _srcBindInfo.InStreams.Size(); i++)
  251.82 -    destBindInfo.OutStreams.Add(_srcInToDestOutMap[_srcBindInfo.InStreams[i]]);
  251.83 -  for (i = 0; i < _srcBindInfo.OutStreams.Size(); i++)
  251.84 -    destBindInfo.InStreams.Add(_srcOutToDestInMap[_srcBindInfo.OutStreams[i]]);
  251.85 -}
  251.86 -
  251.87 -CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams):
  251.88 -    NumInStreams(numInStreams),
  251.89 -    NumOutStreams(numOutStreams)
  251.90 -{
  251.91 -  InSizes.Reserve(NumInStreams);
  251.92 -  InSizePointers.Reserve(NumInStreams);
  251.93 -  OutSizePointers.Reserve(NumOutStreams);
  251.94 -  OutSizePointers.Reserve(NumOutStreams);
  251.95 -}
  251.96 -
  251.97 -static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
  251.98 -    CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
  251.99 -{
 251.100 -  sizes.Clear();
 251.101 -  sizePointers.Clear();
 251.102 -  for(UInt32 i = 0; i < numItems; i++)
 251.103 -  {
 251.104 -    if (srcSizes == 0 || srcSizes[i] == NULL)
 251.105 -    {
 251.106 -      sizes.Add(0);
 251.107 -      sizePointers.Add(NULL);
 251.108 -    }
 251.109 -    else
 251.110 -    {
 251.111 -      sizes.Add(*srcSizes[i]);
 251.112 -      sizePointers.Add(&sizes.Back());
 251.113 -    }
 251.114 -  }
 251.115 -}
 251.116 -
 251.117 -void CCoderInfo2::SetCoderInfo(const UInt64 **inSizes,
 251.118 -      const UInt64 **outSizes)
 251.119 -{
 251.120 -  SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
 251.121 -  SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
 251.122 -}
 251.123 -
 251.124 -}
   252.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.h	Sat Mar 03 10:54:39 2012 -0600
   252.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   252.3 @@ -1,174 +0,0 @@
   252.4 -// CoderMixer2.h
   252.5 -
   252.6 -#ifndef __CODER_MIXER2_H
   252.7 -#define __CODER_MIXER2_H
   252.8 -
   252.9 -#include "../../../Common/MyVector.h"
  252.10 -#include "../../../Common/Types.h"
  252.11 -#include "../../../Common/MyCom.h"
  252.12 -#include "../../ICoder.h"
  252.13 -
  252.14 -namespace NCoderMixer {
  252.15 -
  252.16 -struct CBindPair
  252.17 -{
  252.18 -  UInt32 InIndex;
  252.19 -  UInt32 OutIndex;
  252.20 -};
  252.21 -
  252.22 -struct CCoderStreamsInfo
  252.23 -{
  252.24 -  UInt32 NumInStreams;
  252.25 -  UInt32 NumOutStreams;
  252.26 -};
  252.27 -
  252.28 -struct CBindInfo
  252.29 -{
  252.30 -  CRecordVector<CCoderStreamsInfo> Coders;
  252.31 -  CRecordVector<CBindPair> BindPairs;
  252.32 -  CRecordVector<UInt32> InStreams;
  252.33 -  CRecordVector<UInt32> OutStreams;
  252.34 -
  252.35 -  void Clear()
  252.36 -  {
  252.37 -    Coders.Clear();
  252.38 -    BindPairs.Clear();
  252.39 -    InStreams.Clear();
  252.40 -    OutStreams.Clear();
  252.41 -  }
  252.42 -
  252.43 -  /*
  252.44 -  UInt32 GetCoderStartOutStream(UInt32 coderIndex) const
  252.45 -  {
  252.46 -    UInt32 numOutStreams = 0;
  252.47 -    for (UInt32 i = 0; i < coderIndex; i++)
  252.48 -      numOutStreams += Coders[i].NumOutStreams;
  252.49 -    return numOutStreams;
  252.50 -  }
  252.51 -  */
  252.52 -
  252.53 -
  252.54 -  void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const
  252.55 -  {
  252.56 -    numInStreams = 0;
  252.57 -    numOutStreams = 0;
  252.58 -    for (int i = 0; i < Coders.Size(); i++)
  252.59 -    {
  252.60 -      const CCoderStreamsInfo &coderStreamsInfo = Coders[i];
  252.61 -      numInStreams += coderStreamsInfo.NumInStreams;
  252.62 -      numOutStreams += coderStreamsInfo.NumOutStreams;
  252.63 -    }
  252.64 -  }
  252.65 -
  252.66 -  int FindBinderForInStream(UInt32 inStream) const
  252.67 -  {
  252.68 -    for (int i = 0; i < BindPairs.Size(); i++)
  252.69 -      if (BindPairs[i].InIndex == inStream)
  252.70 -        return i;
  252.71 -    return -1;
  252.72 -  }
  252.73 -  int FindBinderForOutStream(UInt32 outStream) const
  252.74 -  {
  252.75 -    for (int i = 0; i < BindPairs.Size(); i++)
  252.76 -      if (BindPairs[i].OutIndex == outStream)
  252.77 -        return i;
  252.78 -    return -1;
  252.79 -  }
  252.80 -
  252.81 -  UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const
  252.82 -  {
  252.83 -    UInt32 streamIndex = 0;
  252.84 -    for (UInt32 i = 0; i < coderIndex; i++)
  252.85 -      streamIndex += Coders[i].NumInStreams;
  252.86 -    return streamIndex;
  252.87 -  }
  252.88 -
  252.89 -  UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const
  252.90 -  {
  252.91 -    UInt32 streamIndex = 0;
  252.92 -    for (UInt32 i = 0; i < coderIndex; i++)
  252.93 -      streamIndex += Coders[i].NumOutStreams;
  252.94 -    return streamIndex;
  252.95 -  }
  252.96 -
  252.97 -
  252.98 -  void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
  252.99 -      UInt32 &coderStreamIndex) const
 252.100 -  {
 252.101 -    for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
 252.102 -    {
 252.103 -      UInt32 curSize = Coders[coderIndex].NumInStreams;
 252.104 -      if (streamIndex < curSize)
 252.105 -      {
 252.106 -        coderStreamIndex = streamIndex;
 252.107 -        return;
 252.108 -      }
 252.109 -      streamIndex -= curSize;
 252.110 -    }
 252.111 -    throw 1;
 252.112 -  }
 252.113 -  void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
 252.114 -      UInt32 &coderStreamIndex) const
 252.115 -  {
 252.116 -    for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
 252.117 -    {
 252.118 -      UInt32 curSize = Coders[coderIndex].NumOutStreams;
 252.119 -      if (streamIndex < curSize)
 252.120 -      {
 252.121 -        coderStreamIndex = streamIndex;
 252.122 -        return;
 252.123 -      }
 252.124 -      streamIndex -= curSize;
 252.125 -    }
 252.126 -    throw 1;
 252.127 -  }
 252.128 -};
 252.129 -
 252.130 -class CBindReverseConverter
 252.131 -{
 252.132 -  UInt32 _numSrcOutStreams;
 252.133 -  NCoderMixer::CBindInfo _srcBindInfo;
 252.134 -  CRecordVector<UInt32> _srcInToDestOutMap;
 252.135 -  CRecordVector<UInt32> _srcOutToDestInMap;
 252.136 -  CRecordVector<UInt32> _destInToSrcOutMap;
 252.137 -public:
 252.138 -  UInt32 NumSrcInStreams;
 252.139 -  CRecordVector<UInt32> DestOutToSrcInMap;
 252.140 -
 252.141 -  CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo);
 252.142 -  void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo);
 252.143 -};
 252.144 -
 252.145 -struct CCoderInfo2
 252.146 -{
 252.147 -  CMyComPtr<ICompressCoder> Coder;
 252.148 -  CMyComPtr<ICompressCoder2> Coder2;
 252.149 -  UInt32 NumInStreams;
 252.150 -  UInt32 NumOutStreams;
 252.151 -
 252.152 -  CRecordVector<UInt64> InSizes;
 252.153 -  CRecordVector<UInt64> OutSizes;
 252.154 -  CRecordVector<const UInt64 *> InSizePointers;
 252.155 -  CRecordVector<const UInt64 *> OutSizePointers;
 252.156 -
 252.157 -  CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams);
 252.158 -  void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
 252.159 -
 252.160 -  HRESULT QueryInterface(REFGUID iid, void** pp) const
 252.161 -  {
 252.162 -    IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
 252.163 -    return p->QueryInterface(iid, pp);
 252.164 -  }
 252.165 -};
 252.166 -
 252.167 -class CCoderMixer2
 252.168 -{
 252.169 -public:
 252.170 -  virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
 252.171 -  virtual void ReInit() = 0;
 252.172 -  virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
 252.173 -};
 252.174 -
 252.175 -}
 252.176 -#endif
 252.177 -
   253.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp	Sat Mar 03 10:54:39 2012 -0600
   253.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   253.3 @@ -1,230 +0,0 @@
   253.4 -// CoderMixer2MT.cpp
   253.5 -
   253.6 -#include "StdAfx.h"
   253.7 -
   253.8 -#include "CoderMixer2MT.h"
   253.9 -
  253.10 -namespace NCoderMixer {
  253.11 -
  253.12 -CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams):
  253.13 -    CCoderInfo2(numInStreams, numOutStreams)
  253.14 -{
  253.15 -  InStreams.Reserve(NumInStreams);
  253.16 -  InStreamPointers.Reserve(NumInStreams);
  253.17 -  OutStreams.Reserve(NumOutStreams);
  253.18 -  OutStreamPointers.Reserve(NumOutStreams);
  253.19 -}
  253.20 -
  253.21 -void CCoder2::Execute() { Code(NULL); }
  253.22 -
  253.23 -void CCoder2::Code(ICompressProgressInfo *progress)
  253.24 -{
  253.25 -  InStreamPointers.Clear();
  253.26 -  OutStreamPointers.Clear();
  253.27 -  UInt32 i;
  253.28 -  for (i = 0; i < NumInStreams; i++)
  253.29 -  {
  253.30 -    if (InSizePointers[i] != NULL)
  253.31 -      InSizePointers[i] = &InSizes[i];
  253.32 -    InStreamPointers.Add((ISequentialInStream *)InStreams[i]);
  253.33 -  }
  253.34 -  for (i = 0; i < NumOutStreams; i++)
  253.35 -  {
  253.36 -    if (OutSizePointers[i] != NULL)
  253.37 -      OutSizePointers[i] = &OutSizes[i];
  253.38 -    OutStreamPointers.Add((ISequentialOutStream *)OutStreams[i]);
  253.39 -  }
  253.40 -  if (Coder)
  253.41 -    Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0],
  253.42 -        InSizePointers[0], OutSizePointers[0], progress);
  253.43 -  else
  253.44 -    Result = Coder2->Code(&InStreamPointers.Front(), &InSizePointers.Front(), NumInStreams,
  253.45 -      &OutStreamPointers.Front(), &OutSizePointers.Front(), NumOutStreams, progress);
  253.46 -  {
  253.47 -    int i;
  253.48 -    for (i = 0; i < InStreams.Size(); i++)
  253.49 -      InStreams[i].Release();
  253.50 -    for (i = 0; i < OutStreams.Size(); i++)
  253.51 -      OutStreams[i].Release();
  253.52 -  }
  253.53 -}
  253.54 -
  253.55 -static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
  253.56 -    CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
  253.57 -{
  253.58 -  sizes.Clear();
  253.59 -  sizePointers.Clear();
  253.60 -  for(UInt32 i = 0; i < numItems; i++)
  253.61 -  {
  253.62 -    if (srcSizes == 0 || srcSizes[i] == NULL)
  253.63 -    {
  253.64 -      sizes.Add(0);
  253.65 -      sizePointers.Add(NULL);
  253.66 -    }
  253.67 -    else
  253.68 -    {
  253.69 -      sizes.Add(*srcSizes[i]);
  253.70 -      sizePointers.Add(&sizes.Back());
  253.71 -    }
  253.72 -  }
  253.73 -}
  253.74 -
  253.75 -
  253.76 -void CCoder2::SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes)
  253.77 -{
  253.78 -  SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
  253.79 -  SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
  253.80 -}
  253.81 -
  253.82 -//////////////////////////////////////
  253.83 -// CCoderMixer2MT
  253.84 -
  253.85 -HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
  253.86 -{
  253.87 -  _bindInfo = bindInfo;
  253.88 -  _streamBinders.Clear();
  253.89 -  for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
  253.90 -  {
  253.91 -    _streamBinders.Add(CStreamBinder());
  253.92 -    RINOK(_streamBinders.Back().CreateEvents());
  253.93 -  }
  253.94 -  return S_OK;
  253.95 -}
  253.96 -
  253.97 -void CCoderMixer2MT::AddCoderCommon()
  253.98 -{
  253.99 -  const CCoderStreamsInfo &c = _bindInfo.Coders[_coders.Size()];
 253.100 -  CCoder2 threadCoderInfo(c.NumInStreams, c.NumOutStreams);
 253.101 -  _coders.Add(threadCoderInfo);
 253.102 -}
 253.103 -
 253.104 -void CCoderMixer2MT::AddCoder(ICompressCoder *coder)
 253.105 -{
 253.106 -  AddCoderCommon();
 253.107 -  _coders.Back().Coder = coder;
 253.108 -}
 253.109 -
 253.110 -void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder)
 253.111 -{
 253.112 -  AddCoderCommon();
 253.113 -  _coders.Back().Coder2 = coder;
 253.114 -}
 253.115 -
 253.116 -
 253.117 -void CCoderMixer2MT::ReInit()
 253.118 -{
 253.119 -  for(int i = 0; i < _streamBinders.Size(); i++)
 253.120 -    _streamBinders[i].ReInit();
 253.121 -}
 253.122 -
 253.123 -
 253.124 -HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams)
 253.125 -{
 253.126 -  /*
 253.127 -  if (_coders.Size() != _bindInfo.Coders.Size())
 253.128 -    throw 0;
 253.129 -  */
 253.130 -  int i;
 253.131 -  for(i = 0; i < _coders.Size(); i++)
 253.132 -  {
 253.133 -    CCoder2 &coderInfo = _coders[i];
 253.134 -    const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i];
 253.135 -    coderInfo.InStreams.Clear();
 253.136 -    UInt32 j;
 253.137 -    for(j = 0; j < coderStreamsInfo.NumInStreams; j++)
 253.138 -      coderInfo.InStreams.Add(NULL);
 253.139 -    coderInfo.OutStreams.Clear();
 253.140 -    for(j = 0; j < coderStreamsInfo.NumOutStreams; j++)
 253.141 -      coderInfo.OutStreams.Add(NULL);
 253.142 -  }
 253.143 -
 253.144 -  for(i = 0; i < _bindInfo.BindPairs.Size(); i++)
 253.145 -  {
 253.146 -    const CBindPair &bindPair = _bindInfo.BindPairs[i];
 253.147 -    UInt32 inCoderIndex, inCoderStreamIndex;
 253.148 -    UInt32 outCoderIndex, outCoderStreamIndex;
 253.149 -    _bindInfo.FindInStream(bindPair.InIndex, inCoderIndex, inCoderStreamIndex);
 253.150 -    _bindInfo.FindOutStream(bindPair.OutIndex, outCoderIndex, outCoderStreamIndex);
 253.151 -
 253.152 -    _streamBinders[i].CreateStreams(
 253.153 -        &_coders[inCoderIndex].InStreams[inCoderStreamIndex],
 253.154 -        &_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
 253.155 -  }
 253.156 -
 253.157 -  for(i = 0; i < _bindInfo.InStreams.Size(); i++)
 253.158 -  {
 253.159 -    UInt32 inCoderIndex, inCoderStreamIndex;
 253.160 -    _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex);
 253.161 -    _coders[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i];
 253.162 -  }
 253.163 -  
 253.164 -  for(i = 0; i < _bindInfo.OutStreams.Size(); i++)
 253.165 -  {
 253.166 -    UInt32 outCoderIndex, outCoderStreamIndex;
 253.167 -    _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex);
 253.168 -    _coders[outCoderIndex].OutStreams[outCoderStreamIndex] = outStreams[i];
 253.169 -  }
 253.170 -  return S_OK;
 253.171 -}
 253.172 -
 253.173 -HRESULT CCoderMixer2MT::ReturnIfError(HRESULT code)
 253.174 -{
 253.175 -  for (int i = 0; i < _coders.Size(); i++)
 253.176 -    if (_coders[i].Result == code)
 253.177 -      return code;
 253.178 -  return S_OK;
 253.179 -}
 253.180 -
 253.181 -STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
 253.182 -      const UInt64 ** /* inSizes */,
 253.183 -      UInt32 numInStreams,
 253.184 -      ISequentialOutStream **outStreams,
 253.185 -      const UInt64 ** /* outSizes */,
 253.186 -      UInt32 numOutStreams,
 253.187 -      ICompressProgressInfo *progress)
 253.188 -{
 253.189 -  if (numInStreams != (UInt32)_bindInfo.InStreams.Size() ||
 253.190 -      numOutStreams != (UInt32)_bindInfo.OutStreams.Size())
 253.191 -    return E_INVALIDARG;
 253.192 -
 253.193 -  Init(inStreams, outStreams);
 253.194 -
 253.195 -  int i;
 253.196 -  for (i = 0; i < _coders.Size(); i++)
 253.197 -    if (i != _progressCoderIndex)
 253.198 -    {
 253.199 -      RINOK(_coders[i].Create());
 253.200 -    }
 253.201 -
 253.202 -  for (i = 0; i < _coders.Size(); i++)
 253.203 -    if (i != _progressCoderIndex)
 253.204 -      _coders[i].Start();
 253.205 -
 253.206 -  _coders[_progressCoderIndex].Code(progress);
 253.207 -
 253.208 -  for (i = 0; i < _coders.Size(); i++)
 253.209 -    if (i != _progressCoderIndex)
 253.210 -      _coders[i].WaitFinish();
 253.211 -
 253.212 -  RINOK(ReturnIfError(E_ABORT));
 253.213 -  RINOK(ReturnIfError(E_OUTOFMEMORY));
 253.214 -
 253.215 -  for (i = 0; i < _coders.Size(); i++)
 253.216 -  {
 253.217 -    HRESULT result = _coders[i].Result;
 253.218 -    if (result != S_OK && result != E_FAIL && result != S_FALSE)
 253.219 -      return result;
 253.220 -  }
 253.221 -
 253.222 -  RINOK(ReturnIfError(S_FALSE));
 253.223 -
 253.224 -  for (i = 0; i < _coders.Size(); i++)
 253.225 -  {
 253.226 -    HRESULT result = _coders[i].Result;
 253.227 -    if (result != S_OK)
 253.228 -      return result;
 253.229 -  }
 253.230 -  return S_OK;
 253.231 -}
 253.232 -
 253.233 -}
   254.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h	Sat Mar 03 10:54:39 2012 -0600
   254.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   254.3 @@ -1,80 +0,0 @@
   254.4 -// CoderMixer2MT.h
   254.5 -
   254.6 -#ifndef __CODER_MIXER2_MT_H
   254.7 -#define __CODER_MIXER2_MT_H
   254.8 -
   254.9 -#include "CoderMixer2.h"
  254.10 -#include "../../../Common/MyCom.h"
  254.11 -#include "../../Common/StreamBinder.h"
  254.12 -#include "../../Common/VirtThread.h"
  254.13 -
  254.14 -namespace NCoderMixer {
  254.15 -
  254.16 -struct CCoder2: public CCoderInfo2, public CVirtThread
  254.17 -{
  254.18 -  HRESULT Result;
  254.19 -  CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
  254.20 -  CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
  254.21 -  CRecordVector<ISequentialInStream*> InStreamPointers;
  254.22 -  CRecordVector<ISequentialOutStream*> OutStreamPointers;
  254.23 -
  254.24 -  CCoder2(UInt32 numInStreams, UInt32 numOutStreams);
  254.25 -  void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
  254.26 -  virtual void Execute();
  254.27 -  void Code(ICompressProgressInfo *progress);
  254.28 -};
  254.29 -
  254.30 -
  254.31 -/*
  254.32 -  SetBindInfo()
  254.33 -  for each coder
  254.34 -    AddCoder[2]()
  254.35 -  SetProgressIndex(UInt32 coderIndex);
  254.36 - 
  254.37 -  for each file
  254.38 -  {
  254.39 -    ReInit()
  254.40 -    for each coder
  254.41 -      SetCoderInfo
  254.42 -    Code
  254.43 -  }
  254.44 -*/
  254.45 -
  254.46 -class CCoderMixer2MT:
  254.47 -  public ICompressCoder2,
  254.48 -  public CCoderMixer2,
  254.49 -  public CMyUnknownImp
  254.50 -{
  254.51 -  CBindInfo _bindInfo;
  254.52 -  CObjectVector<CStreamBinder> _streamBinders;
  254.53 -  int _progressCoderIndex;
  254.54 -
  254.55 -  void AddCoderCommon();
  254.56 -  HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams);
  254.57 -  HRESULT ReturnIfError(HRESULT code);
  254.58 -public:
  254.59 -  CObjectVector<CCoder2> _coders;
  254.60 -  MY_UNKNOWN_IMP
  254.61 -
  254.62 -  STDMETHOD(Code)(ISequentialInStream **inStreams,
  254.63 -      const UInt64 **inSizes,
  254.64 -      UInt32 numInStreams,
  254.65 -      ISequentialOutStream **outStreams,
  254.66 -      const UInt64 **outSizes,
  254.67 -      UInt32 numOutStreams,
  254.68 -      ICompressProgressInfo *progress);
  254.69 -
  254.70 -  HRESULT SetBindInfo(const CBindInfo &bindInfo);
  254.71 -  void AddCoder(ICompressCoder *coder);
  254.72 -  void AddCoder2(ICompressCoder2 *coder);
  254.73 -  void SetProgressCoderIndex(int coderIndex) {  _progressCoderIndex = coderIndex; }
  254.74 -
  254.75 -  void ReInit();
  254.76 -  void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
  254.77 -    {  _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
  254.78 -  UInt64 GetWriteProcessedSize(UInt32 binderIndex) const
  254.79 -    {  return _streamBinders[binderIndex].ProcessedSize; }
  254.80 -};
  254.81 -
  254.82 -}
  254.83 -#endif
   255.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   255.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   255.3 @@ -1,22 +0,0 @@
   255.4 -// DummyOutStream.cpp
   255.5 -
   255.6 -#include "StdAfx.h"
   255.7 -
   255.8 -#include "DummyOutStream.h"
   255.9 -
  255.10 -STDMETHODIMP CDummyOutStream::Write(const void *data,  UInt32 size, UInt32 *processedSize)
  255.11 -{
  255.12 -  UInt32 realProcessedSize;
  255.13 -  HRESULT result;
  255.14 -  if(!_stream)
  255.15 -  {
  255.16 -    realProcessedSize = size;
  255.17 -    result = S_OK;
  255.18 -  }
  255.19 -  else
  255.20 -    result = _stream->Write(data, size, &realProcessedSize);
  255.21 -  _size += realProcessedSize;
  255.22 -  if(processedSize != NULL)
  255.23 -    *processedSize = realProcessedSize;
  255.24 -  return result;
  255.25 -}
   256.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/DummyOutStream.h	Sat Mar 03 10:54:39 2012 -0600
   256.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   256.3 @@ -1,24 +0,0 @@
   256.4 -// DummyOutStream.h
   256.5 -
   256.6 -#ifndef __DUMMYOUTSTREAM_H
   256.7 -#define __DUMMYOUTSTREAM_H
   256.8 -
   256.9 -#include "../../IStream.h"
  256.10 -#include "Common/MyCom.h"
  256.11 -
  256.12 -class CDummyOutStream:
  256.13 -  public ISequentialOutStream,
  256.14 -  public CMyUnknownImp
  256.15 -{
  256.16 -  CMyComPtr<ISequentialOutStream> _stream;
  256.17 -  UInt64 _size;
  256.18 -public:
  256.19 -  void SetStream(ISequentialOutStream *outStream) { _stream = outStream; }
  256.20 -  void ReleaseStream() { _stream.Release(); }
  256.21 -  void Init() { _size = 0; }
  256.22 -  MY_UNKNOWN_IMP
  256.23 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  256.24 -  UInt64 GetSize() const { return _size; }
  256.25 -};
  256.26 -
  256.27 -#endif
   257.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/FindSignature.cpp	Sat Mar 03 10:54:39 2012 -0600
   257.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   257.3 @@ -1,62 +0,0 @@
   257.4 -// FindSignature.cpp
   257.5 -
   257.6 -#include "StdAfx.h"
   257.7 -
   257.8 -#include "Common/Buffer.h"
   257.9 -
  257.10 -#include "FindSignature.h"
  257.11 -
  257.12 -#include "../../Common/StreamUtils.h"
  257.13 -
  257.14 -HRESULT FindSignatureInStream(ISequentialInStream *stream,
  257.15 -    const Byte *signature, unsigned signatureSize,
  257.16 -    const UInt64 *limit, UInt64 &resPos)
  257.17 -{
  257.18 -  resPos = 0;
  257.19 -  CByteBuffer byteBuffer2;
  257.20 -  byteBuffer2.SetCapacity(signatureSize);
  257.21 -  RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize));
  257.22 -
  257.23 -  if (memcmp(byteBuffer2, signature, signatureSize) == 0)
  257.24 -    return S_OK;
  257.25 -
  257.26 -  const UInt32 kBufferSize = (1 << 16);
  257.27 -  CByteBuffer byteBuffer;
  257.28 -  byteBuffer.SetCapacity(kBufferSize);
  257.29 -  Byte *buffer = byteBuffer;
  257.30 -  UInt32 numPrevBytes = signatureSize - 1;
  257.31 -  memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes);
  257.32 -  resPos = 1;
  257.33 -  for (;;)
  257.34 -  {
  257.35 -    if (limit != NULL)
  257.36 -      if (resPos > *limit)
  257.37 -        return S_FALSE;
  257.38 -    do
  257.39 -    {
  257.40 -      UInt32 numReadBytes = kBufferSize - numPrevBytes;
  257.41 -      UInt32 processedSize;
  257.42 -      RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
  257.43 -      numPrevBytes += processedSize;
  257.44 -      if (processedSize == 0)
  257.45 -        return S_FALSE;
  257.46 -    }
  257.47 -    while (numPrevBytes < signatureSize);
  257.48 -    UInt32 numTests = numPrevBytes - signatureSize + 1;
  257.49 -    for (UInt32 pos = 0; pos < numTests; pos++)
  257.50 -    {
  257.51 -      Byte b = signature[0];
  257.52 -      for (; buffer[pos] != b && pos < numTests; pos++);
  257.53 -      if (pos == numTests)
  257.54 -        break;
  257.55 -      if (memcmp(buffer + pos, signature, signatureSize) == 0)
  257.56 -      {
  257.57 -        resPos += pos;
  257.58 -        return S_OK;
  257.59 -      }
  257.60 -    }
  257.61 -    resPos += numTests;
  257.62 -    numPrevBytes -= numTests;
  257.63 -    memmove(buffer, buffer + numTests, numPrevBytes);
  257.64 -  }
  257.65 -}
   258.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/FindSignature.h	Sat Mar 03 10:54:39 2012 -0600
   258.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   258.3 @@ -1,12 +0,0 @@
   258.4 -// FindSignature.h
   258.5 -
   258.6 -#ifndef __FINDSIGNATURE_H
   258.7 -#define __FINDSIGNATURE_H
   258.8 -
   258.9 -#include "../../IStream.h"
  258.10 -
  258.11 -HRESULT FindSignatureInStream(ISequentialInStream *stream,
  258.12 -    const Byte *signature, unsigned signatureSize,
  258.13 -    const UInt64 *limit, UInt64 &resPos);
  258.14 -
  258.15 -#endif
   259.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp	Sat Mar 03 10:54:39 2012 -0600
   259.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   259.3 @@ -1,40 +0,0 @@
   259.4 -// InStreamWithCRC.cpp
   259.5 -
   259.6 -#include "StdAfx.h"
   259.7 -
   259.8 -#include "InStreamWithCRC.h"
   259.9 -
  259.10 -STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
  259.11 -{
  259.12 -  UInt32 realProcessedSize;
  259.13 -  HRESULT result = _stream->Read(data, size, &realProcessedSize);
  259.14 -  _size += realProcessedSize;
  259.15 -  if (size > 0 && realProcessedSize == 0)
  259.16 -    _wasFinished = true;
  259.17 -  _crc = CrcUpdate(_crc, data, realProcessedSize);
  259.18 -  if(processedSize != NULL)
  259.19 -    *processedSize = realProcessedSize;
  259.20 -  return result;
  259.21 -}
  259.22 -
  259.23 -STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
  259.24 -{
  259.25 -  UInt32 realProcessedSize;
  259.26 -  HRESULT result = _stream->Read(data, size, &realProcessedSize);
  259.27 -  if (size > 0 && realProcessedSize == 0)
  259.28 -    _wasFinished = true;
  259.29 -  _size += realProcessedSize;
  259.30 -  _crc = CrcUpdate(_crc, data, realProcessedSize);
  259.31 -  if(processedSize != NULL)
  259.32 -    *processedSize = realProcessedSize;
  259.33 -  return result;
  259.34 -}
  259.35 -
  259.36 -STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
  259.37 -{
  259.38 -  if (seekOrigin != STREAM_SEEK_SET || offset != 0)
  259.39 -    return E_FAIL;
  259.40 -  _size = 0;
  259.41 -  _crc = CRC_INIT_VAL;
  259.42 -  return _stream->Seek(offset, seekOrigin, newPosition);
  259.43 -}
   260.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h	Sat Mar 03 10:54:39 2012 -0600
   260.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   260.3 @@ -1,69 +0,0 @@
   260.4 -// InStreamWithCRC.h
   260.5 -
   260.6 -#ifndef __INSTREAMWITHCRC_H
   260.7 -#define __INSTREAMWITHCRC_H
   260.8 -
   260.9 -#include "../../../Common/MyCom.h"
  260.10 -#include "../../IStream.h"
  260.11 -
  260.12 -extern "C"
  260.13 -{
  260.14 -#include "../../../../C/7zCrc.h"
  260.15 -}
  260.16 -
  260.17 -class CSequentialInStreamWithCRC:
  260.18 -  public ISequentialInStream,
  260.19 -  public CMyUnknownImp
  260.20 -{
  260.21 -public:
  260.22 -  MY_UNKNOWN_IMP
  260.23 -
  260.24 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  260.25 -private:
  260.26 -  CMyComPtr<ISequentialInStream> _stream;
  260.27 -  UInt64 _size;
  260.28 -  UInt32 _crc;
  260.29 -  bool _wasFinished;
  260.30 -public:
  260.31 -  void SetStream(ISequentialInStream *stream) { _stream = stream;  }
  260.32 -  void Init()
  260.33 -  {
  260.34 -    _size = 0;
  260.35 -    _wasFinished = false;
  260.36 -    _crc = CRC_INIT_VAL;
  260.37 -  }
  260.38 -  void ReleaseStream() { _stream.Release(); }
  260.39 -  UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
  260.40 -  UInt64 GetSize() const { return _size; }
  260.41 -  bool WasFinished() const { return _wasFinished; }
  260.42 -};
  260.43 -
  260.44 -class CInStreamWithCRC:
  260.45 -  public IInStream,
  260.46 -  public CMyUnknownImp
  260.47 -{
  260.48 -public:
  260.49 -  MY_UNKNOWN_IMP1(IInStream)
  260.50 -
  260.51 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  260.52 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  260.53 -private:
  260.54 -  CMyComPtr<IInStream> _stream;
  260.55 -  UInt64 _size;
  260.56 -  UInt32 _crc;
  260.57 -  bool _wasFinished;
  260.58 -public:
  260.59 -  void SetStream(IInStream *stream) { _stream = stream;  }
  260.60 -  void Init()
  260.61 -  {
  260.62 -    _size = 0;
  260.63 -    _wasFinished = false;
  260.64 -    _crc = CRC_INIT_VAL;
  260.65 -  }
  260.66 -  void ReleaseStream() { _stream.Release(); }
  260.67 -  UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
  260.68 -  UInt64 GetSize() const { return _size; }
  260.69 -  bool WasFinished() const { return _wasFinished; }
  260.70 -};
  260.71 -
  260.72 -#endif
   261.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp	Sat Mar 03 10:54:39 2012 -0600
   261.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   261.3 @@ -1,59 +0,0 @@
   261.4 -// Archive/Common/ItemNameUtils.cpp
   261.5 -
   261.6 -#include "StdAfx.h"
   261.7 -
   261.8 -#include "ItemNameUtils.h"
   261.9 -
  261.10 -namespace NArchive {
  261.11 -namespace NItemName {
  261.12 -
  261.13 -static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
  261.14 -static const wchar_t kDirDelimiter = L'/';
  261.15 -
  261.16 -UString MakeLegalName(const UString &name)
  261.17 -{
  261.18 -  UString zipName = name;
  261.19 -  zipName.Replace(kOSDirDelimiter, kDirDelimiter);
  261.20 -  return zipName;
  261.21 -}
  261.22 -
  261.23 -UString GetOSName(const UString &name)
  261.24 -{
  261.25 -  UString newName = name;
  261.26 -  newName.Replace(kDirDelimiter, kOSDirDelimiter);
  261.27 -  return newName;
  261.28 -}
  261.29 -
  261.30 -UString GetOSName2(const UString &name)
  261.31 -{
  261.32 -  if (name.IsEmpty())
  261.33 -    return UString();
  261.34 -  UString newName = GetOSName(name);
  261.35 -  if (newName[newName.Length() - 1] == kOSDirDelimiter)
  261.36 -    newName.Delete(newName.Length() - 1);
  261.37 -  return newName;
  261.38 -}
  261.39 -
  261.40 -bool HasTailSlash(const AString &name, UINT codePage)
  261.41 -{
  261.42 -  if (name.IsEmpty())
  261.43 -    return false;
  261.44 -  LPCSTR prev =
  261.45 -  #ifdef _WIN32
  261.46 -    CharPrevExA((WORD)codePage, name, &name[name.Length()], 0);
  261.47 -  #else
  261.48 -    (LPCSTR)(name) + (name.Length() - 1);
  261.49 -  #endif
  261.50 -  return (*prev == '/');
  261.51 -}
  261.52 -
  261.53 -#ifndef _WIN32
  261.54 -UString WinNameToOSName(const UString &name)
  261.55 -{
  261.56 -  UString newName = name;
  261.57 -  newName.Replace(L'\\', kOSDirDelimiter);
  261.58 -  return newName;
  261.59 -}
  261.60 -#endif
  261.61 -
  261.62 -}}
   262.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/ItemNameUtils.h	Sat Mar 03 10:54:39 2012 -0600
   262.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   262.3 @@ -1,24 +0,0 @@
   262.4 -// Archive/Common/ItemNameUtils.h
   262.5 -
   262.6 -#ifndef __ARCHIVE_ITEMNAMEUTILS_H
   262.7 -#define __ARCHIVE_ITEMNAMEUTILS_H
   262.8 -
   262.9 -#include "../../../Common/MyString.h"
  262.10 -
  262.11 -namespace NArchive {
  262.12 -namespace NItemName {
  262.13 -
  262.14 -  UString MakeLegalName(const UString &name);
  262.15 -  UString GetOSName(const UString &name);
  262.16 -  UString GetOSName2(const UString &name);
  262.17 -  bool HasTailSlash(const AString &name, UINT codePage);
  262.18 -
  262.19 -  #ifdef _WIN32
  262.20 -  inline UString WinNameToOSName(const UString &name)  { return name; }
  262.21 -  #else
  262.22 -  UString WinNameToOSName(const UString &name);
  262.23 -  #endif
  262.24 -
  262.25 -}}
  262.26 -
  262.27 -#endif
   263.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/MultiStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   263.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   263.3 @@ -1,201 +0,0 @@
   263.4 -// MultiStream.cpp
   263.5 -
   263.6 -#include "StdAfx.h"
   263.7 -
   263.8 -#include "MultiStream.h"
   263.9 -
  263.10 -STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
  263.11 -{
  263.12 -  if(processedSize != NULL)
  263.13 -    *processedSize = 0;
  263.14 -  while(_streamIndex < Streams.Size() && size > 0)
  263.15 -  {
  263.16 -    CSubStreamInfo &s = Streams[_streamIndex];
  263.17 -    if (_pos == s.Size)
  263.18 -    {
  263.19 -      _streamIndex++;
  263.20 -      _pos = 0;
  263.21 -      continue;
  263.22 -    }
  263.23 -    RINOK(s.Stream->Seek(s.Pos + _pos, STREAM_SEEK_SET, 0));
  263.24 -    UInt32 sizeToRead = UInt32(MyMin((UInt64)size, s.Size - _pos));
  263.25 -    UInt32 realProcessed;
  263.26 -    HRESULT result = s.Stream->Read(data, sizeToRead, &realProcessed);
  263.27 -    data = (void *)((Byte *)data + realProcessed);
  263.28 -    size -= realProcessed;
  263.29 -    if(processedSize != NULL)
  263.30 -      *processedSize += realProcessed;
  263.31 -    _pos += realProcessed;
  263.32 -    _seekPos += realProcessed;
  263.33 -    RINOK(result);
  263.34 -    break;
  263.35 -  }
  263.36 -  return S_OK;
  263.37 -}
  263.38 -  
  263.39 -STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin,
  263.40 -    UInt64 *newPosition)
  263.41 -{
  263.42 -  UInt64 newPos;
  263.43 -  switch(seekOrigin)
  263.44 -  {
  263.45 -    case STREAM_SEEK_SET:
  263.46 -      newPos = offset;
  263.47 -      break;
  263.48 -    case STREAM_SEEK_CUR:
  263.49 -      newPos = _seekPos + offset;
  263.50 -      break;
  263.51 -    case STREAM_SEEK_END:
  263.52 -      newPos = _totalLength + offset;
  263.53 -      break;
  263.54 -    default:
  263.55 -      return STG_E_INVALIDFUNCTION;
  263.56 -  }
  263.57 -  _seekPos = 0;
  263.58 -  for (_streamIndex = 0; _streamIndex < Streams.Size(); _streamIndex++)
  263.59 -  {
  263.60 -    UInt64 size = Streams[_streamIndex].Size;
  263.61 -    if (newPos < _seekPos + size)
  263.62 -    {
  263.63 -      _pos = newPos - _seekPos;
  263.64 -      _seekPos += _pos;
  263.65 -      if (newPosition != 0)
  263.66 -        *newPosition = newPos;
  263.67 -      return S_OK;
  263.68 -    }
  263.69 -    _seekPos += size;
  263.70 -  }
  263.71 -  if (newPos == _seekPos)
  263.72 -  {
  263.73 -    if (newPosition != 0)
  263.74 -      *newPosition = newPos;
  263.75 -    return S_OK;
  263.76 -  }
  263.77 -  return E_FAIL;
  263.78 -}
  263.79 -
  263.80 -
  263.81 -/*
  263.82 -class COutVolumeStream:
  263.83 -  public ISequentialOutStream,
  263.84 -  public CMyUnknownImp
  263.85 -{
  263.86 -  int _volIndex;
  263.87 -  UInt64 _volSize;
  263.88 -  UInt64 _curPos;
  263.89 -  CMyComPtr<ISequentialOutStream> _volumeStream;
  263.90 -  COutArchive _archive;
  263.91 -  CCRC _crc;
  263.92 -
  263.93 -public:
  263.94 -  MY_UNKNOWN_IMP
  263.95 -
  263.96 -  CFileItem _file;
  263.97 -  CUpdateOptions _options;
  263.98 -  CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
  263.99 -  void Init(IArchiveUpdateCallback2 *volumeCallback,
 263.100 -      const UString &name)
 263.101 -  {
 263.102 -    _file.Name = name;
 263.103 -    _file.IsStartPosDefined = true;
 263.104 -    _file.StartPos = 0;
 263.105 -    
 263.106 -    VolumeCallback = volumeCallback;
 263.107 -    _volIndex = 0;
 263.108 -    _volSize = 0;
 263.109 -  }
 263.110 -  
 263.111 -  HRESULT Flush();
 263.112 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
 263.113 -};
 263.114 -
 263.115 -HRESULT COutVolumeStream::Flush()
 263.116 -{
 263.117 -  if (_volumeStream)
 263.118 -  {
 263.119 -    _file.UnPackSize = _curPos;
 263.120 -    _file.FileCRC = _crc.GetDigest();
 263.121 -    RINOK(WriteVolumeHeader(_archive, _file, _options));
 263.122 -    _archive.Close();
 263.123 -    _volumeStream.Release();
 263.124 -    _file.StartPos += _file.UnPackSize;
 263.125 -  }
 263.126 -  return S_OK;
 263.127 -}
 263.128 -*/
 263.129 -
 263.130 -/*
 263.131 -STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
 263.132 -{
 263.133 -  if(processedSize != NULL)
 263.134 -    *processedSize = 0;
 263.135 -  while(size > 0)
 263.136 -  {
 263.137 -    if (_streamIndex >= Streams.Size())
 263.138 -    {
 263.139 -      CSubStreamInfo subStream;
 263.140 -      RINOK(VolumeCallback->GetVolumeSize(Streams.Size(), &subStream.Size));
 263.141 -      RINOK(VolumeCallback->GetVolumeStream(Streams.Size(), &subStream.Stream));
 263.142 -      subStream.Pos = 0;
 263.143 -      Streams.Add(subStream);
 263.144 -      continue;
 263.145 -    }
 263.146 -    CSubStreamInfo &subStream = Streams[_streamIndex];
 263.147 -    if (_offsetPos >= subStream.Size)
 263.148 -    {
 263.149 -      _offsetPos -= subStream.Size;
 263.150 -      _streamIndex++;
 263.151 -      continue;
 263.152 -    }
 263.153 -    if (_offsetPos != subStream.Pos)
 263.154 -    {
 263.155 -      CMyComPtr<IOutStream> outStream;
 263.156 -      RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream));
 263.157 -      RINOK(outStream->Seek(_offsetPos, STREAM_SEEK_SET, NULL));
 263.158 -      subStream.Pos = _offsetPos;
 263.159 -    }
 263.160 -
 263.161 -    UInt32 curSize = (UInt32)MyMin((UInt64)size, subStream.Size - subStream.Pos);
 263.162 -    UInt32 realProcessed;
 263.163 -    RINOK(subStream.Stream->Write(data, curSize, &realProcessed));
 263.164 -    data = (void *)((Byte *)data + realProcessed);
 263.165 -    size -= realProcessed;
 263.166 -    subStream.Pos += realProcessed;
 263.167 -    _offsetPos += realProcessed;
 263.168 -    _absPos += realProcessed;
 263.169 -    if (_absPos > _length)
 263.170 -      _length = _absPos;
 263.171 -    if(processedSize != NULL)
 263.172 -      *processedSize += realProcessed;
 263.173 -    if (subStream.Pos == subStream.Size)
 263.174 -    {
 263.175 -      _streamIndex++;
 263.176 -      _offsetPos = 0;
 263.177 -    }
 263.178 -    if (realProcessed != curSize && realProcessed == 0)
 263.179 -      return E_FAIL;
 263.180 -  }
 263.181 -  return S_OK;
 263.182 -}
 263.183 -
 263.184 -STDMETHODIMP COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
 263.185 -{
 263.186 -  if(seekOrigin >= 3)
 263.187 -    return STG_E_INVALIDFUNCTION;
 263.188 -  switch(seekOrigin)
 263.189 -  {
 263.190 -    case STREAM_SEEK_SET:
 263.191 -      _absPos = offset;
 263.192 -      break;
 263.193 -    case STREAM_SEEK_CUR:
 263.194 -      _absPos += offset;
 263.195 -      break;
 263.196 -    case STREAM_SEEK_END:
 263.197 -      _absPos = _length + offset;
 263.198 -      break;
 263.199 -  }
 263.200 -  _offsetPos = _absPos;
 263.201 -  _streamIndex = 0;
 263.202 -  return S_OK;
 263.203 -}
 263.204 -*/
   264.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/MultiStream.h	Sat Mar 03 10:54:39 2012 -0600
   264.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   264.3 @@ -1,76 +0,0 @@
   264.4 -// MultiStream.h
   264.5 -
   264.6 -#ifndef __MULTISTREAM_H
   264.7 -#define __MULTISTREAM_H
   264.8 -
   264.9 -#include "../../../Common/MyCom.h"
  264.10 -#include "../../../Common/MyVector.h"
  264.11 -#include "../../Archive/IArchive.h"
  264.12 -
  264.13 -class CMultiStream:
  264.14 -  public IInStream,
  264.15 -  public CMyUnknownImp
  264.16 -{
  264.17 -  int _streamIndex;
  264.18 -  UInt64 _pos;
  264.19 -  UInt64 _seekPos;
  264.20 -  UInt64 _totalLength;
  264.21 -public:
  264.22 -  struct CSubStreamInfo
  264.23 -  {
  264.24 -    CMyComPtr<IInStream> Stream;
  264.25 -    UInt64 Pos;
  264.26 -    UInt64 Size;
  264.27 -  };
  264.28 -  CObjectVector<CSubStreamInfo> Streams;
  264.29 -  void Init()
  264.30 -  {
  264.31 -    _streamIndex = 0;
  264.32 -    _pos = 0;
  264.33 -    _seekPos = 0;
  264.34 -    _totalLength = 0;
  264.35 -    for (int i = 0; i < Streams.Size(); i++)
  264.36 -      _totalLength += Streams[i].Size;
  264.37 -  }
  264.38 -
  264.39 -  MY_UNKNOWN_IMP1(IInStream)
  264.40 -
  264.41 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  264.42 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  264.43 -};
  264.44 -
  264.45 -/*
  264.46 -class COutMultiStream:
  264.47 -  public IOutStream,
  264.48 -  public CMyUnknownImp
  264.49 -{
  264.50 -  int _streamIndex; // required stream
  264.51 -  UInt64 _offsetPos; // offset from start of _streamIndex index
  264.52 -  UInt64 _absPos;
  264.53 -  UInt64 _length;
  264.54 -
  264.55 -  struct CSubStreamInfo
  264.56 -  {
  264.57 -    CMyComPtr<ISequentialOutStream> Stream;
  264.58 -    UInt64 Size;
  264.59 -    UInt64 Pos;
  264.60 - };
  264.61 -  CObjectVector<CSubStreamInfo> Streams;
  264.62 -public:
  264.63 -  CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
  264.64 -  void Init()
  264.65 -  {
  264.66 -    _streamIndex = 0;
  264.67 -    _offsetPos = 0;
  264.68 -    _absPos = 0;
  264.69 -    _length = 0;
  264.70 -  }
  264.71 -
  264.72 -  MY_UNKNOWN_IMP1(IOutStream)
  264.73 -
  264.74 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  264.75 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  264.76 -};
  264.77 -*/
  264.78 -
  264.79 -#endif
   265.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp	Sat Mar 03 10:54:39 2012 -0600
   265.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   265.3 @@ -1,24 +0,0 @@
   265.4 -// OutStreamWithCRC.cpp
   265.5 -
   265.6 -#include "StdAfx.h"
   265.7 -
   265.8 -#include "OutStreamWithCRC.h"
   265.9 -
  265.10 -STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
  265.11 -{
  265.12 -  UInt32 realProcessedSize;
  265.13 -  HRESULT result;
  265.14 -  if(!_stream)
  265.15 -  {
  265.16 -    realProcessedSize = size;
  265.17 -    result = S_OK;
  265.18 -  }
  265.19 -  else
  265.20 -    result = _stream->Write(data, size, &realProcessedSize);
  265.21 -  if (_calculate)
  265.22 -    _crc = CrcUpdate(_crc, data, realProcessedSize);
  265.23 -  _size += realProcessedSize;
  265.24 -  if(processedSize != NULL)
  265.25 -    *processedSize = realProcessedSize;
  265.26 -  return result;
  265.27 -}
   266.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h	Sat Mar 03 10:54:39 2012 -0600
   266.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   266.3 @@ -1,38 +0,0 @@
   266.4 -// OutStreamWithCRC.h
   266.5 -
   266.6 -#ifndef __OUT_STREAM_WITH_CRC_H
   266.7 -#define __OUT_STREAM_WITH_CRC_H
   266.8 -
   266.9 -#include "../../../Common/MyCom.h"
  266.10 -#include "../../IStream.h"
  266.11 -
  266.12 -extern "C"
  266.13 -{
  266.14 -#include "../../../../C/7zCrc.h"
  266.15 -}
  266.16 -
  266.17 -class COutStreamWithCRC:
  266.18 -  public ISequentialOutStream,
  266.19 -  public CMyUnknownImp
  266.20 -{
  266.21 -  CMyComPtr<ISequentialOutStream> _stream;
  266.22 -  UInt64 _size;
  266.23 -  UInt32 _crc;
  266.24 -  bool _calculate;
  266.25 -public:
  266.26 -  MY_UNKNOWN_IMP
  266.27 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  266.28 -  void SetStream(ISequentialOutStream *stream) { _stream = stream; }
  266.29 -  void ReleaseStream() { _stream.Release(); }
  266.30 -  void Init(bool calculate = true)
  266.31 -  {
  266.32 -    _size = 0;
  266.33 -    _calculate = calculate;
  266.34 -    _crc = CRC_INIT_VAL;
  266.35 -  }
  266.36 -  void InitCRC() { _crc = CRC_INIT_VAL; }
  266.37 -  UInt64 GetSize() const { return _size; }
  266.38 -  UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
  266.39 -};
  266.40 -
  266.41 -#endif
   267.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/ParseProperties.cpp	Sat Mar 03 10:54:39 2012 -0600
   267.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   267.3 @@ -1,177 +0,0 @@
   267.4 -// ParseProperties.cpp
   267.5 -
   267.6 -#include "StdAfx.h"
   267.7 -
   267.8 -#include "ParseProperties.h"
   267.9 -
  267.10 -#include "Common/StringToInt.h"
  267.11 -#include "Common/MyCom.h"
  267.12 -
  267.13 -HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
  267.14 -{
  267.15 -  if (prop.vt == VT_UI4)
  267.16 -  {
  267.17 -    if (!name.IsEmpty())
  267.18 -      return E_INVALIDARG;
  267.19 -    resValue = prop.ulVal;
  267.20 -  }
  267.21 -  else if (prop.vt == VT_EMPTY)
  267.22 -  {
  267.23 -    if(!name.IsEmpty())
  267.24 -    {
  267.25 -      const wchar_t *start = name;
  267.26 -      const wchar_t *end;
  267.27 -      UInt64 v = ConvertStringToUInt64(start, &end);
  267.28 -      if (end - start != name.Length())
  267.29 -        return E_INVALIDARG;
  267.30 -      resValue = (UInt32)v;
  267.31 -    }
  267.32 -  }
  267.33 -  else
  267.34 -    return E_INVALIDARG;
  267.35 -  return S_OK;
  267.36 -}
  267.37 -
  267.38 -static const int kLogarithmicSizeLimit = 32;
  267.39 -static const wchar_t kByteSymbol = L'B';
  267.40 -static const wchar_t kKiloByteSymbol = L'K';
  267.41 -static const wchar_t kMegaByteSymbol = L'M';
  267.42 -
  267.43 -HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize)
  267.44 -{
  267.45 -  UString srcString = srcStringSpec;
  267.46 -  srcString.MakeUpper();
  267.47 -
  267.48 -  const wchar_t *start = srcString;
  267.49 -  const wchar_t *end;
  267.50 -  UInt64 number = ConvertStringToUInt64(start, &end);
  267.51 -  int numDigits = (int)(end - start);
  267.52 -  if (numDigits == 0 || srcString.Length() > numDigits + 1)
  267.53 -    return E_INVALIDARG;
  267.54 -  if (srcString.Length() == numDigits)
  267.55 -  {
  267.56 -    if (number >= kLogarithmicSizeLimit)
  267.57 -      return E_INVALIDARG;
  267.58 -    dicSize = (UInt32)1 << (int)number;
  267.59 -    return S_OK;
  267.60 -  }
  267.61 -  switch (srcString[numDigits])
  267.62 -  {
  267.63 -    case kByteSymbol:
  267.64 -      if (number >= ((UInt64)1 << kLogarithmicSizeLimit))
  267.65 -        return E_INVALIDARG;
  267.66 -      dicSize = (UInt32)number;
  267.67 -      break;
  267.68 -    case kKiloByteSymbol:
  267.69 -      if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 10)))
  267.70 -        return E_INVALIDARG;
  267.71 -      dicSize = (UInt32)(number << 10);
  267.72 -      break;
  267.73 -    case kMegaByteSymbol:
  267.74 -      if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 20)))
  267.75 -        return E_INVALIDARG;
  267.76 -      dicSize = (UInt32)(number << 20);
  267.77 -      break;
  267.78 -    default:
  267.79 -      return E_INVALIDARG;
  267.80 -  }
  267.81 -  return S_OK;
  267.82 -}
  267.83 -
  267.84 -HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
  267.85 -{
  267.86 -  if (name.IsEmpty())
  267.87 -  {
  267.88 -    if (prop.vt == VT_UI4)
  267.89 -    {
  267.90 -      UInt32 logDicSize = prop.ulVal;
  267.91 -      if (logDicSize >= 32)
  267.92 -        return E_INVALIDARG;
  267.93 -      resValue = (UInt32)1 << logDicSize;
  267.94 -      return S_OK;
  267.95 -    }
  267.96 -    if (prop.vt == VT_BSTR)
  267.97 -      return ParsePropDictionaryValue(prop.bstrVal, resValue);
  267.98 -    return E_INVALIDARG;
  267.99 -  }
 267.100 -  return ParsePropDictionaryValue(name, resValue);
 267.101 -}
 267.102 -
 267.103 -bool StringToBool(const UString &s, bool &res)
 267.104 -{
 267.105 -  if (s.IsEmpty() || s.CompareNoCase(L"ON") == 0 || s.Compare(L"+") == 0)
 267.106 -  {
 267.107 -    res = true;
 267.108 -    return true;
 267.109 -  }
 267.110 -  if (s.CompareNoCase(L"OFF") == 0 || s.Compare(L"-") == 0)
 267.111 -  {
 267.112 -    res = false;
 267.113 -    return true;
 267.114 -  }
 267.115 -  return false;
 267.116 -}
 267.117 -
 267.118 -HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value)
 267.119 -{
 267.120 -  switch(value.vt)
 267.121 -  {
 267.122 -    case VT_EMPTY:
 267.123 -      dest = true;
 267.124 -      return S_OK;
 267.125 -    case VT_BOOL:
 267.126 -      dest = (value.boolVal != VARIANT_FALSE);
 267.127 -      return S_OK;
 267.128 -    /*
 267.129 -    case VT_UI4:
 267.130 -      dest = (value.ulVal != 0);
 267.131 -      break;
 267.132 -    */
 267.133 -    case VT_BSTR:
 267.134 -      return StringToBool(value.bstrVal, dest) ?  S_OK : E_INVALIDARG;
 267.135 -  }
 267.136 -  return E_INVALIDARG;
 267.137 -}
 267.138 -
 267.139 -int ParseStringToUInt32(const UString &srcString, UInt32 &number)
 267.140 -{
 267.141 -  const wchar_t *start = srcString;
 267.142 -  const wchar_t *end;
 267.143 -  UInt64 number64 = ConvertStringToUInt64(start, &end);
 267.144 -  if (number64 > 0xFFFFFFFF)
 267.145 -  {
 267.146 -    number = 0;
 267.147 -    return 0;
 267.148 -  }
 267.149 -  number = (UInt32)number64;
 267.150 -  return (int)(end - start);
 267.151 -}
 267.152 -
 267.153 -HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads)
 267.154 -{
 267.155 -  if (name.IsEmpty())
 267.156 -  {
 267.157 -    switch(prop.vt)
 267.158 -    {
 267.159 -      case VT_UI4:
 267.160 -        numThreads = prop.ulVal;
 267.161 -        break;
 267.162 -      default:
 267.163 -      {
 267.164 -        bool val;
 267.165 -        RINOK(SetBoolProperty(val, prop));
 267.166 -        numThreads = (val ? defaultNumThreads : 1);
 267.167 -        break;
 267.168 -      }
 267.169 -    }
 267.170 -  }
 267.171 -  else
 267.172 -  {
 267.173 -    UInt32 number;
 267.174 -    int index = ParseStringToUInt32(name, number);
 267.175 -    if (index != name.Length())
 267.176 -      return E_INVALIDARG;
 267.177 -    numThreads = number;
 267.178 -  }
 267.179 -  return S_OK;
 267.180 -}
   268.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/ParseProperties.h	Sat Mar 03 10:54:39 2012 -0600
   268.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   268.3 @@ -1,18 +0,0 @@
   268.4 -// ParseProperties.h
   268.5 -
   268.6 -#ifndef __PARSEPROPERTIES_H
   268.7 -#define __PARSEPROPERTIES_H
   268.8 -
   268.9 -#include "Common/MyString.h"
  268.10 -#include "Common/Types.h"
  268.11 -
  268.12 -HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
  268.13 -HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize);
  268.14 -HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
  268.15 -
  268.16 -bool StringToBool(const UString &s, bool &res);
  268.17 -HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value);
  268.18 -int ParseStringToUInt32(const UString &srcString, UInt32 &number);
  268.19 -HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads);
  268.20 -
  268.21 -#endif
   269.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Common/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   269.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   269.3 @@ -1,9 +0,0 @@
   269.4 -// StdAfx.h
   269.5 -
   269.6 -#ifndef __STDAFX_H
   269.7 -#define __STDAFX_H
   269.8 -
   269.9 -#include "../../../Common/MyWindows.h"
  269.10 -#include "../../../Common/NewHandler.h"
  269.11 -
  269.12 -#endif
   270.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/DllExports2.cpp	Sat Mar 03 10:54:39 2012 -0600
   270.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   270.3 @@ -1,82 +0,0 @@
   270.4 -// DLLExports.cpp
   270.5 -
   270.6 -#include "StdAfx.h"
   270.7 -
   270.8 -#include "../../Common/MyInitGuid.h"
   270.9 -#include "../../Common/ComTry.h"
  270.10 -#include "../../Common/Types.h"
  270.11 -#include "../../Windows/PropVariant.h"
  270.12 -#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
  270.13 -extern "C"
  270.14 -{
  270.15 -#include "../../../C/Alloc.h"
  270.16 -}
  270.17 -#endif
  270.18 -
  270.19 -#include "IArchive.h"
  270.20 -#include "../ICoder.h"
  270.21 -#include "../IPassword.h"
  270.22 -
  270.23 -HINSTANCE g_hInstance;
  270.24 -#ifndef _UNICODE
  270.25 -#ifdef _WIN32
  270.26 -bool g_IsNT = false;
  270.27 -static bool IsItWindowsNT()
  270.28 -{
  270.29 -  OSVERSIONINFO versionInfo;
  270.30 -  versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
  270.31 -  if (!::GetVersionEx(&versionInfo))
  270.32 -    return false;
  270.33 -  return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
  270.34 -}
  270.35 -#endif
  270.36 -#endif
  270.37 -
  270.38 -extern "C"
  270.39 -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  270.40 -{
  270.41 -  if (dwReason == DLL_PROCESS_ATTACH)
  270.42 -  {
  270.43 -    g_hInstance = hInstance;
  270.44 -    #ifndef _UNICODE
  270.45 -    #ifdef _WIN32
  270.46 -    g_IsNT = IsItWindowsNT();
  270.47 -    #endif
  270.48 -    #endif
  270.49 -  }
  270.50 -  return TRUE;
  270.51 -}
  270.52 -
  270.53 -DEFINE_GUID(CLSID_CArchiveHandler,
  270.54 -0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
  270.55 -
  270.56 -static const UInt16 kDecodeId = 0x2790;
  270.57 -
  270.58 -DEFINE_GUID(CLSID_CCodec,
  270.59 -0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
  270.60 -
  270.61 -STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
  270.62 -STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
  270.63 -
  270.64 -STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
  270.65 -{
  270.66 -  // COM_TRY_BEGIN
  270.67 -  *outObject = 0;
  270.68 -  if (*iid == IID_ICompressCoder || *iid == IID_ICompressCoder2 || *iid == IID_ICompressFilter)
  270.69 -  {
  270.70 -    return CreateCoder(clsid, iid, outObject);
  270.71 -  }
  270.72 -  else
  270.73 -  {
  270.74 -    return CreateArchiver(clsid, iid, outObject);
  270.75 -  }
  270.76 -  // COM_TRY_END
  270.77 -}
  270.78 -
  270.79 -STDAPI SetLargePageMode()
  270.80 -{
  270.81 -  #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
  270.82 -  SetLargePageSize();
  270.83 -  #endif
  270.84 -  return S_OK;
  270.85 -}
   271.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   271.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   271.3 @@ -1,284 +0,0 @@
   271.4 -// GZipHandler.cpp
   271.5 -
   271.6 -#include "StdAfx.h"
   271.7 -
   271.8 -#include "GZipHandler.h"
   271.9 -
  271.10 -#include "Common/Defs.h"
  271.11 -#include "Common/StringConvert.h"
  271.12 -#include "Common/ComTry.h"
  271.13 -#include "Windows/PropVariant.h"
  271.14 -#include "Windows/Time.h"
  271.15 -
  271.16 -#include "../../ICoder.h"
  271.17 -#include "../../Common/ProgressUtils.h"
  271.18 -#include "../../Common/CreateCoder.h"
  271.19 -#include "../Common/OutStreamWithCRC.h"
  271.20 -
  271.21 -using namespace NWindows;
  271.22 -
  271.23 -namespace NArchive {
  271.24 -namespace NGZip {
  271.25 -
  271.26 -static const CMethodId kMethodId_Deflate = 0x040108;
  271.27 -
  271.28 -const wchar_t *kHostOS[] =
  271.29 -{
  271.30 -  L"FAT",
  271.31 -  L"AMIGA",
  271.32 -  L"VMS",
  271.33 -  L"Unix",
  271.34 -  L"VM_CMS",
  271.35 -  L"Atari",  // what if it's a minix filesystem? [cjh]
  271.36 -  L"HPFS",  // filesystem used by OS/2 (and NT 3.x)
  271.37 -  L"Mac",
  271.38 -  L"Z_System",
  271.39 -  L"CPM",
  271.40 -  L"TOPS20", // pkzip 2.50 NTFS
  271.41 -  L"NTFS", // filesystem used by Windows NT
  271.42 -  L"QDOS ", // SMS/QDOS
  271.43 -  L"Acorn", // Archimedes Acorn RISC OS
  271.44 -  L"VFAT", // filesystem used by Windows 95, NT
  271.45 -  L"MVS",
  271.46 -  L"BeOS", // hybrid POSIX/database filesystem
  271.47 -                        // BeBOX or PowerMac
  271.48 -  L"Tandem",
  271.49 -  L"THEOS"
  271.50 -};
  271.51 -
  271.52 -static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
  271.53 -
  271.54 -static const wchar_t *kUnknownOS = L"Unknown";
  271.55 -
  271.56 -/*
  271.57 -enum // PropID
  271.58 -{
  271.59 -  kpidExtraIsPresent = kpidUserDefined,
  271.60 -  kpidExtraFlags,
  271.61 -  kpidIsText
  271.62 -};
  271.63 -*/
  271.64 -
  271.65 -STATPROPSTG kProps[] =
  271.66 -{
  271.67 -  { NULL, kpidPath, VT_BSTR},
  271.68 -  { NULL, kpidSize, VT_UI8},
  271.69 -  { NULL, kpidPackSize, VT_UI8},
  271.70 -  { NULL, kpidMTime, VT_FILETIME},
  271.71 -  // { NULL, kpidMethod, VT_UI1},
  271.72 -  { NULL, kpidHostOS, VT_BSTR},
  271.73 -  { NULL, kpidCRC, VT_UI4}
  271.74 -  // { L"Extra", kpidExtraIsPresent, VT_BOOL}
  271.75 -  // { L"Extra flags", kpidExtraFlags, VT_UI1},
  271.76 -  // { L"Is Text", kpidIsText, VT_BOOL},
  271.77 -};
  271.78 -
  271.79 -IMP_IInArchive_Props
  271.80 -IMP_IInArchive_ArcProps_NO
  271.81 -
  271.82 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
  271.83 -{
  271.84 -  *numItems = 1;
  271.85 -  return S_OK;
  271.86 -}
  271.87 -
  271.88 -STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID,  PROPVARIANT *value)
  271.89 -{
  271.90 -  COM_TRY_BEGIN
  271.91 -  NWindows::NCOM::CPropVariant prop;
  271.92 -  switch(propID)
  271.93 -  {
  271.94 -    case kpidPath:
  271.95 -      if (m_Item.NameIsPresent())
  271.96 -        prop = MultiByteToUnicodeString(m_Item.Name, CP_ACP);
  271.97 -      break;
  271.98 -    case kpidMTime:
  271.99 -    {
 271.100 -      FILETIME utcTime;
 271.101 -      if (m_Item.Time != 0)
 271.102 -      {
 271.103 -        NTime::UnixTimeToFileTime((UInt32)m_Item.Time, utcTime);
 271.104 -        prop = utcTime;
 271.105 -      }
 271.106 -      else
 271.107 -      {
 271.108 -        // utcTime.dwLowDateTime = utcTime.dwHighDateTime = 0;
 271.109 -        // prop = utcTime;
 271.110 -      }
 271.111 -      break;
 271.112 -    }
 271.113 -    case kpidSize:  prop = UInt64(m_Item.UnPackSize32); break;
 271.114 -    case kpidPackSize:  prop = m_PackSize; break;
 271.115 -    case kpidCommented:  prop = m_Item.CommentIsPresent(); break;
 271.116 -    case kpidHostOS:
 271.117 -      prop = (m_Item.HostOS < kNumHostOSes) ?
 271.118 -          kHostOS[m_Item.HostOS] : kUnknownOS;
 271.119 -      break;
 271.120 -    case kpidMethod:  prop = m_Item.CompressionMethod; break;
 271.121 -    case kpidCRC:  prop = m_Item.FileCRC; break;
 271.122 -    /*
 271.123 -    case kpidExtraFlags:  prop = m_Item.ExtraFlags; break;
 271.124 -    case kpidIsText:  prop = m_Item.IsText(); break;
 271.125 -    case kpidExtraIsPresent:  prop = m_Item.ExtraFieldIsPresent(); break;
 271.126 -    */
 271.127 -  }
 271.128 -  prop.Detach(value);
 271.129 -  return S_OK;
 271.130 -  COM_TRY_END
 271.131 -}
 271.132 -
 271.133 -STDMETHODIMP CHandler::Open(IInStream *inStream,
 271.134 -    const UInt64 * /* maxCheckStartPosition */,
 271.135 -    IArchiveOpenCallback * /* openArchiveCallback */)
 271.136 -{
 271.137 -  COM_TRY_BEGIN
 271.138 -  try
 271.139 -  {
 271.140 -    CInArchive archive;
 271.141 -    RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
 271.142 -    RINOK(archive.ReadHeader(inStream, m_Item));
 271.143 -    m_DataOffset = archive.GetOffset();
 271.144 -    UInt64 newPosition;
 271.145 -    RINOK(inStream->Seek(-8, STREAM_SEEK_END, &newPosition));
 271.146 -    m_PackSize = newPosition - (m_StreamStartPosition + m_DataOffset);
 271.147 -    if (archive.ReadPostHeader(inStream, m_Item) != S_OK)
 271.148 -      return S_FALSE;
 271.149 -    m_Stream = inStream;
 271.150 -  }
 271.151 -  catch(...)
 271.152 -  {
 271.153 -    return S_FALSE;
 271.154 -  }
 271.155 -  return S_OK;
 271.156 -  COM_TRY_END
 271.157 -}
 271.158 -
 271.159 -STDMETHODIMP CHandler::Close()
 271.160 -{
 271.161 -  m_Stream.Release();
 271.162 -  return S_OK;
 271.163 -}
 271.164 -
 271.165 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 271.166 -    Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
 271.167 -{
 271.168 -  COM_TRY_BEGIN
 271.169 -  bool allFilesMode = (numItems == UInt32(-1));
 271.170 -  if (!allFilesMode)
 271.171 -  {
 271.172 -    if (numItems == 0)
 271.173 -      return S_OK;
 271.174 -    if (numItems != 1)
 271.175 -      return E_INVALIDARG;
 271.176 -    if (indices[0] != 0)
 271.177 -      return E_INVALIDARG;
 271.178 -  }
 271.179 -
 271.180 -  bool testMode = (_aTestMode != 0);
 271.181 -
 271.182 -  extractCallback->SetTotal(m_PackSize);
 271.183 -
 271.184 -  UInt64 currentTotalPacked = 0;
 271.185 -  
 271.186 -  RINOK(extractCallback->SetCompleted(&currentTotalPacked));
 271.187 -  CMyComPtr<ISequentialOutStream> realOutStream;
 271.188 -  Int32 askMode;
 271.189 -  askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
 271.190 -      NArchive::NExtract::NAskMode::kExtract;
 271.191 -  
 271.192 -  RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
 271.193 -  
 271.194 -  if(!testMode && !realOutStream)
 271.195 -    return S_OK;
 271.196 -
 271.197 -  extractCallback->PrepareOperation(askMode);
 271.198 -
 271.199 -  COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
 271.200 -  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 271.201 -  outStreamSpec->SetStream(realOutStream);
 271.202 -  outStreamSpec->Init();
 271.203 -  realOutStream.Release();
 271.204 -
 271.205 -  CLocalProgress *lps = new CLocalProgress;
 271.206 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 271.207 -  lps->Init(extractCallback, true);
 271.208 -
 271.209 -  CMyComPtr<ICompressCoder> deflateDecoder;
 271.210 -  bool firstItem = true;
 271.211 -  RINOK(m_Stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL));
 271.212 -  Int32 opRes;
 271.213 -  for (;;)
 271.214 -  {
 271.215 -    lps->InSize = currentTotalPacked;
 271.216 -    lps->OutSize = outStreamSpec->GetSize();
 271.217 -
 271.218 -    CInArchive archive;
 271.219 -    CItem item;
 271.220 -    HRESULT result = archive.ReadHeader(m_Stream, item);
 271.221 -    if (result != S_OK)
 271.222 -    {
 271.223 -      if (firstItem)
 271.224 -        return E_FAIL;
 271.225 -      opRes = NArchive::NExtract::NOperationResult::kOK;
 271.226 -      break;
 271.227 -    }
 271.228 -    firstItem = false;
 271.229 -
 271.230 -    UInt64 dataStartPos;
 271.231 -    RINOK(m_Stream->Seek(0, STREAM_SEEK_CUR, &dataStartPos));
 271.232 -
 271.233 -    outStreamSpec->InitCRC();
 271.234 -
 271.235 -    if (item.CompressionMethod != NFileHeader::NCompressionMethod::kDeflate)
 271.236 -    {
 271.237 -      opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 271.238 -      break;
 271.239 -    }
 271.240 -
 271.241 -    if (!deflateDecoder)
 271.242 -    {
 271.243 -      RINOK(CreateCoder(
 271.244 -          EXTERNAL_CODECS_VARS
 271.245 -          kMethodId_Deflate, deflateDecoder, false));
 271.246 -      if (!deflateDecoder)
 271.247 -      {
 271.248 -        opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 271.249 -        break;
 271.250 -      }
 271.251 -    }
 271.252 -    result = deflateDecoder->Code(m_Stream, outStream, NULL, NULL, progress);
 271.253 -    if (result != S_OK)
 271.254 -    {
 271.255 -      if (result != S_FALSE)
 271.256 -        return result;
 271.257 -      opRes = NArchive::NExtract::NOperationResult::kDataError;
 271.258 -      break;
 271.259 -    }
 271.260 -
 271.261 -    CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
 271.262 -    RINOK(deflateDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
 271.263 -        &getInStreamProcessedSize));
 271.264 -    UInt64 packSize;
 271.265 -    RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
 271.266 -    UInt64 pos;
 271.267 -    RINOK(m_Stream->Seek(dataStartPos + packSize, STREAM_SEEK_SET, &pos));
 271.268 -
 271.269 -    currentTotalPacked = pos - m_StreamStartPosition;
 271.270 -    
 271.271 -    CItem postItem;
 271.272 -    if (archive.ReadPostHeader(m_Stream, postItem) != S_OK)
 271.273 -      return E_FAIL;
 271.274 -    if((outStreamSpec->GetCRC() != postItem.FileCRC))
 271.275 -    {
 271.276 -      opRes = NArchive::NExtract::NOperationResult::kCRCError;
 271.277 -      break;
 271.278 -    }
 271.279 -  }
 271.280 -  outStream.Release();
 271.281 -  return extractCallback->SetOperationResult(opRes);
 271.282 -  COM_TRY_END
 271.283 -}
 271.284 -
 271.285 -IMPL_ISetCompressCodecsInfo
 271.286 -
 271.287 -}}
   272.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHandler.h	Sat Mar 03 10:54:39 2012 -0600
   272.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   272.3 @@ -1,65 +0,0 @@
   272.4 -// GZip/Handler.h
   272.5 -
   272.6 -#ifndef __GZIP_HANDLER_H
   272.7 -#define __GZIP_HANDLER_H
   272.8 -
   272.9 -#include "Common/MyCom.h"
  272.10 -
  272.11 -#include "../IArchive.h"
  272.12 -
  272.13 -#include "../../Common/CreateCoder.h"
  272.14 -
  272.15 -#include "GZipIn.h"
  272.16 -#include "GZipUpdate.h"
  272.17 -
  272.18 -namespace NArchive {
  272.19 -namespace NGZip {
  272.20 -
  272.21 -class CHandler:
  272.22 -  public IInArchive,
  272.23 -  public IOutArchive,
  272.24 -  public ISetProperties,
  272.25 -  PUBLIC_ISetCompressCodecsInfo
  272.26 -  public CMyUnknownImp
  272.27 -{
  272.28 -public:
  272.29 -  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  272.30 -  MY_QUERYINTERFACE_ENTRY(IOutArchive)
  272.31 -  MY_QUERYINTERFACE_ENTRY(ISetProperties)
  272.32 -  QUERY_ENTRY_ISetCompressCodecsInfo
  272.33 -  MY_QUERYINTERFACE_END
  272.34 -  MY_ADDREF_RELEASE
  272.35 -
  272.36 -  INTERFACE_IInArchive(;)
  272.37 -#ifndef EXTRACT_ONLY
  272.38 -  INTERFACE_IOutArchive(;)
  272.39 -
  272.40 -  STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
  272.41 -#endif
  272.42 -
  272.43 -  DECL_ISetCompressCodecsInfo
  272.44 -
  272.45 -  CHandler() { InitMethodProperties(); }
  272.46 -
  272.47 -private:
  272.48 -  NArchive::NGZip::CItem m_Item;
  272.49 -  UInt64 m_StreamStartPosition;
  272.50 -  UInt64 m_DataOffset;
  272.51 -  UInt64 m_PackSize;
  272.52 -  CMyComPtr<IInStream> m_Stream;
  272.53 -  CCompressionMethodMode m_Method;
  272.54 -  UInt32 m_Level;
  272.55 -
  272.56 -  DECL_EXTERNAL_CODECS_VARS
  272.57 -
  272.58 -  void InitMethodProperties()
  272.59 -  {
  272.60 -    m_Method.NumMatchFinderCyclesDefined = false;
  272.61 -    m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
  272.62 -        m_Method.NumMatchFinderCycles = m_Method.Algo = 0xFFFFFFFF;
  272.63 -  }
  272.64 -};
  272.65 -
  272.66 -}}
  272.67 -
  272.68 -#endif
   273.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp	Sat Mar 03 10:54:39 2012 -0600
   273.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   273.3 @@ -1,20 +0,0 @@
   273.4 -// Archive/GZip/Header.h
   273.5 -
   273.6 -#include "StdAfx.h"
   273.7 -
   273.8 -#include "GZipHeader.h"
   273.9 -
  273.10 -namespace NArchive {
  273.11 -namespace NGZip {
  273.12 -
  273.13 -extern UInt16 kSignature = 0x8B1F + 1;
  273.14 -
  273.15 -class CMarkersInitializer
  273.16 -{
  273.17 -public:
  273.18 -  CMarkersInitializer()
  273.19 -    { kSignature--; }
  273.20 -} g_MarkerInitializer;
  273.21 -
  273.22 -}}
  273.23 -
   274.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipHeader.h	Sat Mar 03 10:54:39 2012 -0600
   274.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   274.3 @@ -1,85 +0,0 @@
   274.4 -// Archive/GZip/Header.h
   274.5 -
   274.6 -#ifndef __ARCHIVE_GZIP_HEADER_H
   274.7 -#define __ARCHIVE_GZIP_HEADER_H
   274.8 -
   274.9 -#include "Common/Types.h"
  274.10 -
  274.11 -namespace NArchive {
  274.12 -namespace NGZip {
  274.13 -
  274.14 -extern UInt16 kSignature;
  274.15 -static const UInt32 kSignatureSize = 2;
  274.16 -
  274.17 -namespace NFileHeader
  274.18 -{
  274.19 -  /*
  274.20 -  struct CBlock
  274.21 -  {
  274.22 -    UInt16 Id;
  274.23 -    Byte CompressionMethod;
  274.24 -    Byte Flags;
  274.25 -    UInt32 Time;
  274.26 -    Byte ExtraFlags;
  274.27 -    Byte HostOS;
  274.28 -  };
  274.29 -  */
  274.30 -  
  274.31 -  namespace NFlags
  274.32 -  {
  274.33 -    const int kDataIsText = 1 << 0;
  274.34 -    const int kHeaderCRCIsPresent = 1 << 1;
  274.35 -    const int kExtraIsPresent = 1 << 2;
  274.36 -    const int kNameIsPresent = 1 << 3;
  274.37 -    const int kComentIsPresent = 1 << 4;
  274.38 -  }
  274.39 -  
  274.40 -  namespace NExtraFlags
  274.41 -  {
  274.42 -    enum EEnum
  274.43 -    {
  274.44 -      kMaximum = 2,
  274.45 -      kFastest = 4
  274.46 -    };
  274.47 -  }
  274.48 -  
  274.49 -  namespace NCompressionMethod
  274.50 -  {
  274.51 -    const Byte kDeflate = 8;
  274.52 -  }
  274.53 -
  274.54 -  namespace NHostOS
  274.55 -  {
  274.56 -    enum EEnum
  274.57 -    {
  274.58 -      kFAT      = 0,  // filesystem used by MS-DOS, OS/2, Win32
  274.59 -        // pkzip 2.50 (FAT / VFAT / FAT32 file systems)
  274.60 -        kAMIGA    = 1,
  274.61 -        kVMS      = 2,  // VAX/VMS
  274.62 -        kUnix     = 3,
  274.63 -        kVM_CMS   = 4,
  274.64 -        kAtari    = 5,  // what if it's a minix filesystem? [cjh]
  274.65 -        kHPFS     = 6,  // filesystem used by OS/2 (and NT 3.x)
  274.66 -        kMac      = 7,
  274.67 -        kZ_System = 8,
  274.68 -        kCPM      = 9,
  274.69 -        kTOPS20   = 10, // pkzip 2.50 NTFS
  274.70 -        kNTFS     = 11, // filesystem used by Windows NT
  274.71 -        kQDOS     = 12, // SMS/QDOS
  274.72 -        kAcorn    = 13, // Archimedes Acorn RISC OS
  274.73 -        kVFAT     = 14, // filesystem used by Windows 95, NT
  274.74 -        kMVS      = 15,
  274.75 -        kBeOS     = 16, // hybrid POSIX/database filesystem
  274.76 -                        // BeBOX or PowerMac
  274.77 -        kTandem   = 17,
  274.78 -        kTHEOS    = 18,
  274.79 -
  274.80 -        kUnknown = 255
  274.81 -    };
  274.82 -    const int kNumHostSystems = 19;
  274.83 -  }
  274.84 -}
  274.85 -
  274.86 -}}
  274.87 -
  274.88 -#endif
   275.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   275.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   275.3 @@ -1,119 +0,0 @@
   275.4 -// Archive/GZipIn.cpp
   275.5 -
   275.6 -#include "StdAfx.h"
   275.7 -
   275.8 -#include "GZipIn.h"
   275.9 -
  275.10 -#include "Common/Defs.h"
  275.11 -#include "Common/MyCom.h"
  275.12 -#include "Windows/Defs.h"
  275.13 -
  275.14 -#include "../../Common/StreamUtils.h"
  275.15 -
  275.16 -extern "C"
  275.17 -{
  275.18 -  #include "../../../../C/7zCrc.h"
  275.19 -}
  275.20 -
  275.21 -namespace NArchive {
  275.22 -namespace NGZip {
  275.23 - 
  275.24 -HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size)
  275.25 -{
  275.26 -  RINOK(ReadStream_FALSE(inStream, data, size));
  275.27 -  m_Position += size;
  275.28 -  return S_OK;
  275.29 -}
  275.30 -
  275.31 -HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc)
  275.32 -{
  275.33 -  RINOK(ReadBytes(inStream, &value, 1));
  275.34 -  crc = CRC_UPDATE_BYTE(crc, value);
  275.35 -  return S_OK;
  275.36 -}
  275.37 -
  275.38 -HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc)
  275.39 -{
  275.40 -  value = 0;
  275.41 -  for (int i = 0; i < 2; i++)
  275.42 -  {
  275.43 -    Byte b;
  275.44 -    RINOK(ReadByte(inStream, b, crc));
  275.45 -    value |= (UInt16(b) << (8 * i));
  275.46 -  }
  275.47 -  return S_OK;
  275.48 -}
  275.49 -
  275.50 -HRESULT CInArchive::ReadUInt32(ISequentialInStream *inStream, UInt32 &value, UInt32 &crc)
  275.51 -{
  275.52 -  value = 0;
  275.53 -  for (int i = 0; i < 4; i++)
  275.54 -  {
  275.55 -    Byte b;
  275.56 -    RINOK(ReadByte(inStream, b, crc));
  275.57 -    value |= (UInt32(b) << (8 * i));
  275.58 -  }
  275.59 -  return S_OK;
  275.60 -}
  275.61 -
  275.62 -HRESULT CInArchive::ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, UInt32 &crc)
  275.63 -{
  275.64 -  resString.Empty();
  275.65 -  for (;;)
  275.66 -  {
  275.67 -    Byte c;
  275.68 -    RINOK(ReadByte(inStream, c, crc));
  275.69 -    if (c == 0)
  275.70 -      return S_OK;
  275.71 -    resString += char(c);
  275.72 -  }
  275.73 -}
  275.74 -
  275.75 -HRESULT CInArchive::ReadHeader(ISequentialInStream *inStream, CItem &item)
  275.76 -{
  275.77 -  item.Clear();
  275.78 -  m_Position = 0;
  275.79 -
  275.80 -  UInt16 signature;
  275.81 -  UInt32 crc = CRC_INIT_VAL;;
  275.82 -  RINOK(ReadUInt16(inStream, signature, crc));
  275.83 -  if (signature != kSignature)
  275.84 -    return S_FALSE;
  275.85 -  
  275.86 -  RINOK(ReadByte(inStream, item.CompressionMethod, crc));
  275.87 -  RINOK(ReadByte(inStream, item.Flags, crc));
  275.88 -  RINOK(ReadUInt32(inStream, item.Time, crc));
  275.89 -  RINOK(ReadByte(inStream, item.ExtraFlags, crc));
  275.90 -  RINOK(ReadByte(inStream, item.HostOS, crc));
  275.91 -  
  275.92 -  if (item.ExtraFieldIsPresent())
  275.93 -  {
  275.94 -    UInt16 extraSize;
  275.95 -    RINOK(ReadUInt16(inStream, extraSize, crc));
  275.96 -    item.Extra.SetCapacity(extraSize);
  275.97 -    RINOK(ReadBytes(inStream, item.Extra, extraSize));
  275.98 -    crc = CrcUpdate(crc, item.Extra, extraSize);
  275.99 -  }
 275.100 -  if (item.NameIsPresent())
 275.101 -    RINOK(ReadZeroTerminatedString(inStream, item.Name, crc));
 275.102 -  if (item.CommentIsPresent())
 275.103 -    RINOK(ReadZeroTerminatedString(inStream, item.Comment, crc));
 275.104 -  if (item.HeaderCRCIsPresent())
 275.105 -  {
 275.106 -    UInt16 headerCRC;
 275.107 -    UInt32 dummy = 0;
 275.108 -    RINOK(ReadUInt16(inStream, headerCRC, dummy));
 275.109 -    if ((UInt16)CRC_GET_DIGEST(crc) != headerCRC)
 275.110 -      return S_FALSE;
 275.111 -  }
 275.112 -  return S_OK;
 275.113 -}
 275.114 -
 275.115 -HRESULT CInArchive::ReadPostHeader(ISequentialInStream *inStream, CItem &item)
 275.116 -{
 275.117 -  UInt32 dummy = 0;
 275.118 -  RINOK(ReadUInt32(inStream, item.FileCRC, dummy));
 275.119 -  return ReadUInt32(inStream, item.UnPackSize32, dummy);
 275.120 -}
 275.121 -
 275.122 -}}
   276.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipIn.h	Sat Mar 03 10:54:39 2012 -0600
   276.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   276.3 @@ -1,30 +0,0 @@
   276.4 -// Archive/GZipIn.h
   276.5 -
   276.6 -#ifndef __ARCHIVE_GZIP_IN_H
   276.7 -#define __ARCHIVE_GZIP_IN_H
   276.8 -
   276.9 -#include "GZipHeader.h"
  276.10 -#include "GZipItem.h"
  276.11 -#include "../../IStream.h"
  276.12 -
  276.13 -namespace NArchive {
  276.14 -namespace NGZip {
  276.15 -  
  276.16 -class CInArchive
  276.17 -{
  276.18 -  UInt64 m_Position;
  276.19 -  
  276.20 -  HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size);
  276.21 -  HRESULT ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, UInt32 &crc);
  276.22 -  HRESULT ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc);
  276.23 -  HRESULT ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc);
  276.24 -  HRESULT ReadUInt32(ISequentialInStream *inStream, UInt32 &value, UInt32 &crc);
  276.25 -public:
  276.26 -  HRESULT ReadHeader(ISequentialInStream *inStream, CItem &item);
  276.27 -  HRESULT ReadPostHeader(ISequentialInStream *inStream, CItem &item);
  276.28 -  UInt64 GetOffset() const { return m_Position; }
  276.29 -};
  276.30 -  
  276.31 -}}
  276.32 -  
  276.33 -#endif
   277.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipItem.h	Sat Mar 03 10:54:39 2012 -0600
   277.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   277.3 @@ -1,59 +0,0 @@
   277.4 -// Archive/GZipItem.h
   277.5 -
   277.6 -#ifndef __ARCHIVE_GZIP_ITEM_H
   277.7 -#define __ARCHIVE_GZIP_ITEM_H
   277.8 -
   277.9 -#include "Common/Types.h"
  277.10 -#include "Common/MyString.h"
  277.11 -#include "Common/Buffer.h"
  277.12 -
  277.13 -namespace NArchive {
  277.14 -namespace NGZip {
  277.15 -
  277.16 -class CItem
  277.17 -{
  277.18 -private:
  277.19 -  bool TestFlag(Byte flag) const { return ((Flags & flag) != 0); }
  277.20 -public:
  277.21 -  Byte CompressionMethod;
  277.22 -  Byte Flags;
  277.23 -  UInt32 Time;
  277.24 -  Byte ExtraFlags;
  277.25 -  Byte HostOS;
  277.26 -  UInt32 FileCRC;
  277.27 -  UInt32 UnPackSize32;
  277.28 -
  277.29 -  AString Name;
  277.30 -  AString Comment;
  277.31 -  CByteBuffer Extra;
  277.32 -
  277.33 -  bool IsText() const
  277.34 -    {  return TestFlag(NFileHeader::NFlags::kDataIsText); }
  277.35 -  bool HeaderCRCIsPresent() const
  277.36 -    {  return TestFlag(NFileHeader::NFlags::kHeaderCRCIsPresent); }
  277.37 -  bool ExtraFieldIsPresent() const
  277.38 -    {  return TestFlag(NFileHeader::NFlags::kExtraIsPresent); }
  277.39 -  bool NameIsPresent() const
  277.40 -    {  return TestFlag(NFileHeader::NFlags::kNameIsPresent); }
  277.41 -  bool CommentIsPresent() const
  277.42 -    {  return TestFlag(NFileHeader::NFlags::kComentIsPresent); }
  277.43 -
  277.44 -  void SetNameIsPresentFlag(bool nameIsPresent)
  277.45 -  {
  277.46 -    if (nameIsPresent)
  277.47 -      Flags |= NFileHeader::NFlags::kNameIsPresent;
  277.48 -    else
  277.49 -      Flags &= (~NFileHeader::NFlags::kNameIsPresent);
  277.50 -  }
  277.51 -
  277.52 -  void Clear()
  277.53 -  {
  277.54 -    Name.Empty();
  277.55 -    Comment.Empty();;
  277.56 -    Extra.SetCapacity(0);
  277.57 -  }
  277.58 -};
  277.59 -
  277.60 -}}
  277.61 -
  277.62 -#endif
   278.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   278.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   278.3 @@ -1,18 +0,0 @@
   278.4 -// GZipRegister.cpp
   278.5 -
   278.6 -#include "StdAfx.h"
   278.7 -
   278.8 -#include "../../Common/RegisterArc.h"
   278.9 -
  278.10 -#include "GZipHandler.h"
  278.11 -static IInArchive *CreateArc() { return new NArchive::NGZip::CHandler;  }
  278.12 -#ifndef EXTRACT_ONLY
  278.13 -static IOutArchive *CreateArcOut() { return new NArchive::NGZip::CHandler;  }
  278.14 -#else
  278.15 -#define CreateArcOut 0
  278.16 -#endif
  278.17 -
  278.18 -static CArcInfo g_ArcInfo =
  278.19 -  { L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B, 8 }, 3, true, CreateArc, CreateArcOut };
  278.20 -
  278.21 -REGISTER_ARC(GZip)
   279.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/GZipUpdate.h	Sat Mar 03 10:54:39 2012 -0600
   279.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   279.3 @@ -1,39 +0,0 @@
   279.4 -// GZip/Update.h
   279.5 -
   279.6 -#ifndef __GZIP_UPDATE_H
   279.7 -#define __GZIP_UPDATE_H
   279.8 -
   279.9 -#include "../IArchive.h"
  279.10 -
  279.11 -#include "../../Common/CreateCoder.h"
  279.12 -
  279.13 -#ifndef EXTRACT_ONLY
  279.14 -#include "GZipOut.h"
  279.15 -#endif
  279.16 -#include "GZipItem.h"
  279.17 -
  279.18 -namespace NArchive {
  279.19 -namespace NGZip {
  279.20 -
  279.21 -struct CCompressionMethodMode
  279.22 -{
  279.23 -  UInt32 NumPasses;
  279.24 -  UInt32 NumFastBytes;
  279.25 -  UInt32 Algo;
  279.26 -  bool NumMatchFinderCyclesDefined;
  279.27 -  UInt32 NumMatchFinderCycles;
  279.28 -};
  279.29 -
  279.30 -HRESULT UpdateArchive(
  279.31 -    DECL_EXTERNAL_CODECS_LOC_VARS
  279.32 -    IInStream *inStream,
  279.33 -    UInt64 unpackSize,
  279.34 -    ISequentialOutStream *outStream,
  279.35 -    const CItem &newItem,
  279.36 -    const CCompressionMethodMode &compressionMethod,
  279.37 -    int indexInClient,
  279.38 -    IArchiveUpdateCallback *updateCallback);
  279.39 -
  279.40 -}}
  279.41 -
  279.42 -#endif
   280.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/GZip/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   280.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   280.3 @@ -1,8 +0,0 @@
   280.4 -// StdAfx.h
   280.5 -
   280.6 -#ifndef __STDAFX_H
   280.7 -#define __STDAFX_H
   280.8 -
   280.9 -#include "../../../Common/MyWindows.h"
  280.10 -
  280.11 -#endif
   281.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/IArchive.h	Sat Mar 03 10:54:39 2012 -0600
   281.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   281.3 @@ -1,237 +0,0 @@
   281.4 -// IArchive.h
   281.5 -
   281.6 -#ifndef __IARCHIVE_H
   281.7 -#define __IARCHIVE_H
   281.8 -
   281.9 -#include "../IStream.h"
  281.10 -#include "../IProgress.h"
  281.11 -#include "../PropID.h"
  281.12 -
  281.13 -#define ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 6, x)
  281.14 -#define ARCHIVE_INTERFACE(i, x) ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
  281.15 -
  281.16 -namespace NFileTimeType
  281.17 -{
  281.18 -  enum EEnum
  281.19 -  {
  281.20 -    kWindows,
  281.21 -    kUnix,
  281.22 -    kDOS
  281.23 -  };
  281.24 -}
  281.25 -
  281.26 -namespace NArchive
  281.27 -{
  281.28 -  enum
  281.29 -  {
  281.30 -    kName = 0,
  281.31 -    kClassID,
  281.32 -    kExtension,
  281.33 -    kAddExtension,
  281.34 -    kUpdate,
  281.35 -    kKeepName,
  281.36 -    kStartSignature,
  281.37 -    kFinishSignature,
  281.38 -    kAssociate
  281.39 -  };
  281.40 -
  281.41 -  namespace NExtract
  281.42 -  {
  281.43 -    namespace NAskMode
  281.44 -    {
  281.45 -      enum
  281.46 -      {
  281.47 -        kExtract = 0,
  281.48 -        kTest,
  281.49 -        kSkip
  281.50 -      };
  281.51 -    }
  281.52 -    namespace NOperationResult
  281.53 -    {
  281.54 -      enum
  281.55 -      {
  281.56 -        kOK = 0,
  281.57 -        kUnSupportedMethod,
  281.58 -        kDataError,
  281.59 -        kCRCError
  281.60 -      };
  281.61 -    }
  281.62 -  }
  281.63 -  namespace NUpdate
  281.64 -  {
  281.65 -    namespace NOperationResult
  281.66 -    {
  281.67 -      enum
  281.68 -      {
  281.69 -        kOK = 0,
  281.70 -        kError
  281.71 -      };
  281.72 -    }
  281.73 -  }
  281.74 -}
  281.75 -
  281.76 -#define INTERFACE_IArchiveOpenCallback(x) \
  281.77 -  STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) x; \
  281.78 -  STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) x; \
  281.79 -
  281.80 -ARCHIVE_INTERFACE(IArchiveOpenCallback, 0x10)
  281.81 -{
  281.82 -  INTERFACE_IArchiveOpenCallback(PURE);
  281.83 -};
  281.84 -
  281.85 -
  281.86 -#define INTERFACE_IArchiveExtractCallback(x) \
  281.87 -  INTERFACE_IProgress(x) \
  281.88 -  /* GetStream OUT: S_OK - OK, S_FALSE - skeep this file */ \
  281.89 -  STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream,  Int32 askExtractMode) x; \
  281.90 -  STDMETHOD(PrepareOperation)(Int32 askExtractMode) x; \
  281.91 -  STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) x; \
  281.92 -
  281.93 -ARCHIVE_INTERFACE_SUB(IArchiveExtractCallback, IProgress, 0x20)
  281.94 -{
  281.95 -  INTERFACE_IArchiveExtractCallback(PURE)
  281.96 -};
  281.97 -
  281.98 -
  281.99 -#define INTERFACE_IArchiveOpenVolumeCallback(x) \
 281.100 -  STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) x; \
 281.101 -  STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) x; \
 281.102 -
 281.103 -ARCHIVE_INTERFACE(IArchiveOpenVolumeCallback, 0x30)
 281.104 -{
 281.105 -  INTERFACE_IArchiveOpenVolumeCallback(PURE);
 281.106 -};
 281.107 -
 281.108 -
 281.109 -ARCHIVE_INTERFACE(IInArchiveGetStream, 0x40)
 281.110 -{
 281.111 -  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE;
 281.112 -};
 281.113 -
 281.114 -
 281.115 -ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50)
 281.116 -{
 281.117 -  STDMETHOD(SetSubArchiveName)(const wchar_t *name) PURE;
 281.118 -};
 281.119 -
 281.120 -
 281.121 -/*
 281.122 -IInArchive::Extract:
 281.123 -  indices must be sorted
 281.124 -  numItems = 0xFFFFFFFF means "all files"
 281.125 -  testMode != 0 means "test files without writing to outStream"
 281.126 -*/
 281.127 -
 281.128 -#define INTERFACE_IInArchive(x) \
 281.129 -  STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback) x; \
 281.130 -  STDMETHOD(Close)() x; \
 281.131 -  STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
 281.132 -  STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
 281.133 -  STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) x; \
 281.134 -  STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
 281.135 -  STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
 281.136 -  STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
 281.137 -  STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
 281.138 -  STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
 281.139 -
 281.140 -ARCHIVE_INTERFACE(IInArchive, 0x60)
 281.141 -{
 281.142 -  INTERFACE_IInArchive(PURE)
 281.143 -  virtual ~IInArchive() {}
 281.144 -};
 281.145 -
 281.146 -
 281.147 -#define INTERFACE_IArchiveUpdateCallback(x) \
 281.148 -  INTERFACE_IProgress(x); \
 281.149 -  STDMETHOD(GetUpdateItemInfo)(UInt32 index,  \
 281.150 -      Int32 *newData, /*1 - new data, 0 - old data */ \
 281.151 -      Int32 *newProperties, /* 1 - new properties, 0 - old properties */ \
 281.152 -      UInt32 *indexInArchive /* -1 if there is no in archive, or if doesn't matter */ \
 281.153 -      )  x; \
 281.154 -  STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
 281.155 -  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) x; \
 281.156 -  STDMETHOD(SetOperationResult)(Int32 operationResult) x; \
 281.157 -
 281.158 -ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback, IProgress, 0x80)
 281.159 -{
 281.160 -  INTERFACE_IArchiveUpdateCallback(PURE);
 281.161 -};
 281.162 -
 281.163 -#define INTERFACE_IArchiveUpdateCallback2(x) \
 281.164 -  INTERFACE_IArchiveUpdateCallback(x) \
 281.165 -  STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) x; \
 281.166 -  STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) x; \
 281.167 -
 281.168 -ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82)
 281.169 -{
 281.170 -  INTERFACE_IArchiveUpdateCallback2(PURE);
 281.171 -};
 281.172 -
 281.173 -
 281.174 -#ifndef EXTRACT_ONLY
 281.175 -#define INTERFACE_IOutArchive(x) \
 281.176 -  STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, IArchiveUpdateCallback *updateCallback) x; \
 281.177 -  STDMETHOD(GetFileTimeType)(UInt32 *type) x;
 281.178 -#else
 281.179 -#define INTERFACE_IOutArchive(x)
 281.180 -#endif
 281.181 -
 281.182 -ARCHIVE_INTERFACE(IOutArchive, 0xA0)
 281.183 -{
 281.184 -#ifndef EXTRACT_ONLY
 281.185 -  INTERFACE_IOutArchive(PURE)
 281.186 -#endif
 281.187 -};
 281.188 -
 281.189 -
 281.190 -ARCHIVE_INTERFACE(ISetProperties, 0x03)
 281.191 -{
 281.192 -#ifndef EXTRACT_ONLY
 281.193 -  STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties) PURE;
 281.194 -#endif
 281.195 -};
 281.196 -
 281.197 -
 281.198 -#define IMP_IInArchive_GetProp(k) \
 281.199 -  (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
 281.200 -    { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
 281.201 -    const STATPROPSTG &srcItem = k[index]; \
 281.202 -    *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
 281.203 -
 281.204 -#define IMP_IInArchive_GetProp_WITH_NAME(k) \
 281.205 -  (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
 281.206 -    { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
 281.207 -    const STATPROPSTG &srcItem = k[index]; \
 281.208 -    *propID = srcItem.propid; *varType = srcItem.vt; \
 281.209 -    if (srcItem.lpwstrName == 0) *name = 0; else *name = ::SysAllocString(srcItem.lpwstrName); return S_OK; } \
 281.210 -
 281.211 -#define IMP_IInArchive_Props \
 281.212 -  STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
 281.213 -    { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
 281.214 -  STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp(kProps)
 281.215 -
 281.216 -#define IMP_IInArchive_Props_WITH_NAME \
 281.217 -  STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
 281.218 -    { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
 281.219 -  STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kProps)
 281.220 -
 281.221 -
 281.222 -#define IMP_IInArchive_ArcProps \
 281.223 -  STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
 281.224 -    { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
 281.225 -  STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp(kArcProps)
 281.226 -
 281.227 -#define IMP_IInArchive_ArcProps_WITH_NAME \
 281.228 -  STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
 281.229 -    { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
 281.230 -  STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kArcProps)
 281.231 -
 281.232 -#define IMP_IInArchive_ArcProps_NO \
 281.233 -  STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
 281.234 -    { *numProperties = 0; return S_OK; } \
 281.235 -  STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32, BSTR *, PROPID *, VARTYPE *) \
 281.236 -    { return E_NOTIMPL; } \
 281.237 -  STDMETHODIMP CHandler::GetArchiveProperty(PROPID, PROPVARIANT *value) \
 281.238 -    { value->vt = VT_EMPTY; return S_OK; }
 281.239 -
 281.240 -#endif
   282.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp	Sat Mar 03 10:54:39 2012 -0600
   282.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   282.3 @@ -1,43 +0,0 @@
   282.4 -// LzhCRC.cpp
   282.5 -
   282.6 -#include "StdAfx.h"
   282.7 -
   282.8 -#include "LzhCRC.h"
   282.9 -
  282.10 -namespace NArchive {
  282.11 -namespace NLzh {
  282.12 -
  282.13 -static const UInt16 kCRCPoly = 0xA001;
  282.14 -
  282.15 -UInt16 CCRC::Table[256];
  282.16 -
  282.17 -void CCRC::InitTable()
  282.18 -{
  282.19 -  for (UInt32 i = 0; i < 256; i++)
  282.20 -  {
  282.21 -    UInt32 r = i;
  282.22 -    for (int j = 0; j < 8; j++)
  282.23 -      if (r & 1)
  282.24 -        r = (r >> 1) ^ kCRCPoly;
  282.25 -      else
  282.26 -        r >>= 1;
  282.27 -    CCRC::Table[i] = (UInt16)r;
  282.28 -  }
  282.29 -}
  282.30 -
  282.31 -class CCRCTableInit
  282.32 -{
  282.33 -public:
  282.34 -  CCRCTableInit() { CCRC::InitTable(); }
  282.35 -} g_CRCTableInit;
  282.36 -
  282.37 -void CCRC::Update(const void *data, size_t size)
  282.38 -{
  282.39 -  UInt16 v = _value;
  282.40 -  const Byte *p = (const Byte *)data;
  282.41 -  for (; size > 0; size--, p++)
  282.42 -    v = (UInt16)(Table[((Byte)(v)) ^ *p] ^ (v >> 8));
  282.43 -  _value = v;
  282.44 -}
  282.45 -
  282.46 -}}
   283.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhCRC.h	Sat Mar 03 10:54:39 2012 -0600
   283.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   283.3 @@ -1,27 +0,0 @@
   283.4 -// LzhCRC.h
   283.5 -
   283.6 -#ifndef __LZH_CRC_H
   283.7 -#define __LZH_CRC_H
   283.8 -
   283.9 -#include <stddef.h>
  283.10 -#include "Common/Types.h"
  283.11 -
  283.12 -namespace NArchive {
  283.13 -namespace NLzh {
  283.14 -
  283.15 -class CCRC
  283.16 -{
  283.17 -  UInt16 _value;
  283.18 -public:
  283.19 -  static UInt16 Table[256];
  283.20 -  static void InitTable();
  283.21 -  
  283.22 -  CCRC():  _value(0){};
  283.23 -  void Init() { _value = 0; }
  283.24 -  void Update(const void *data, size_t size);
  283.25 -  UInt16 GetDigest() const { return _value; }
  283.26 -};
  283.27 -
  283.28 -}}
  283.29 -
  283.30 -#endif
   284.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   284.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   284.3 @@ -1,387 +0,0 @@
   284.4 -// LzhHandler.cpp
   284.5 -
   284.6 -#include "StdAfx.h"
   284.7 -
   284.8 -#include "Common/ComTry.h"
   284.9 -#include "Common/Defs.h"
  284.10 -#include "Common/StringConvert.h"
  284.11 -
  284.12 -#include "Windows/PropVariant.h"
  284.13 -#include "Windows/Time.h"
  284.14 -
  284.15 -#include "LzhHandler.h"
  284.16 -#include "LzhOutStreamWithCRC.h"
  284.17 -
  284.18 -#include "../../ICoder.h"
  284.19 -
  284.20 -#include "../../Common/LimitedStreams.h"
  284.21 -#include "../../Common/ProgressUtils.h"
  284.22 -
  284.23 -#include "../../Compress/CopyCoder.h"
  284.24 -#include "../../Compress/LzhDecoder.h"
  284.25 -
  284.26 -#include "../Common/ItemNameUtils.h"
  284.27 -
  284.28 -using namespace NWindows;
  284.29 -using namespace NTime;
  284.30 -
  284.31 -namespace NArchive {
  284.32 -namespace NLzh{
  284.33 -
  284.34 -struct COsPair
  284.35 -{
  284.36 -  Byte Id;
  284.37 -  const wchar_t *Name;
  284.38 -};
  284.39 -
  284.40 -COsPair g_OsPairs[] =
  284.41 -{
  284.42 -  { 'M', L"MS-DOS" },
  284.43 -  { '2', L"OS/2" },
  284.44 -  { '9', L"OS9" },
  284.45 -  { 'K', L"OS/68K" },
  284.46 -  { '3', L"OS/386" },
  284.47 -  { 'H', L"HUMAN" },
  284.48 -  { 'U', L"UNIX" },
  284.49 -  { 'C', L"CP/M" },
  284.50 -  { 'F', L"FLEX" },
  284.51 -  { 'm', L"Mac" },
  284.52 -  { 'R', L"Runser" },
  284.53 -  { 'T', L"TownsOS" },
  284.54 -  { 'X', L"XOSK" },
  284.55 -  { 'w', L"Windows95" },
  284.56 -  { 'W', L"WindowsNT" },
  284.57 -  {  0,  L"MS-DOS" },
  284.58 -  { 'J', L"Java VM" }
  284.59 -};
  284.60 -
  284.61 -const wchar_t *kUnknownOS = L"Unknown";
  284.62 -
  284.63 -const int kNumHostOSes = sizeof(g_OsPairs) / sizeof(g_OsPairs[0]);
  284.64 -
  284.65 -static const wchar_t *GetOS(Byte osId)
  284.66 -{
  284.67 -  for (int i = 0; i < kNumHostOSes; i++)
  284.68 -    if (g_OsPairs[i].Id == osId)
  284.69 -      return g_OsPairs[i].Name;
  284.70 -  return kUnknownOS;
  284.71 -};
  284.72 -
  284.73 -STATPROPSTG kProps[] =
  284.74 -{
  284.75 -  { NULL, kpidPath, VT_BSTR},
  284.76 -  { NULL, kpidIsDir, VT_BOOL},
  284.77 -  { NULL, kpidSize, VT_UI8},
  284.78 -  { NULL, kpidPackSize, VT_UI8},
  284.79 -  { NULL, kpidMTime, VT_FILETIME},
  284.80 -  { NULL, kpidAttrib, VT_UI4},
  284.81 -
  284.82 -  // { NULL, kpidCommented, VT_BOOL},
  284.83 -    
  284.84 -  { NULL, kpidCRC, VT_UI4},
  284.85 -
  284.86 -  { NULL, kpidMethod, VT_UI1},
  284.87 -  { NULL, kpidHostOS, VT_BSTR}
  284.88 -
  284.89 -};
  284.90 -
  284.91 -IMP_IInArchive_Props
  284.92 -IMP_IInArchive_ArcProps_NO
  284.93 -
  284.94 -CHandler::CHandler() {}
  284.95 -
  284.96 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
  284.97 -{
  284.98 -  *numItems = _items.Size();
  284.99 -  return S_OK;
 284.100 -}
 284.101 -
 284.102 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
 284.103 -{
 284.104 -  COM_TRY_BEGIN
 284.105 -  NWindows::NCOM::CPropVariant prop;
 284.106 -  const CItemEx &item = _items[index];
 284.107 -  switch(propID)
 284.108 -  {
 284.109 -    case kpidPath:
 284.110 -    {
 284.111 -      UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
 284.112 -      if (!s.IsEmpty())
 284.113 -      {
 284.114 -        if (s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
 284.115 -           s.Delete(s.Length() - 1);
 284.116 -        prop = s;
 284.117 -      }
 284.118 -      break;
 284.119 -    }
 284.120 -    case kpidIsDir:  prop = item.IsDir(); break;
 284.121 -    case kpidSize:   prop = item.Size; break;
 284.122 -    case kpidPackSize:  prop = item.PackSize; break;
 284.123 -    case kpidCRC:  prop = (UInt32)item.CRC; break;
 284.124 -    case kpidHostOS:  prop = GetOS(item.OsId); break;
 284.125 -    case kpidMTime:
 284.126 -    {
 284.127 -      FILETIME utcFileTime;
 284.128 -      UInt32 unixTime;
 284.129 -      if (item.GetUnixTime(unixTime))
 284.130 -        NTime::UnixTimeToFileTime(unixTime, utcFileTime);
 284.131 -      else
 284.132 -      {
 284.133 -        FILETIME localFileTime;
 284.134 -        if (DosTimeToFileTime(item.ModifiedTime, localFileTime))
 284.135 -        {
 284.136 -          if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
 284.137 -            utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 284.138 -        }
 284.139 -        else
 284.140 -          utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 284.141 -      }
 284.142 -      prop = utcFileTime;
 284.143 -      break;
 284.144 -    }
 284.145 -    /*
 284.146 -    case kpidAttrib:  prop = (UInt32)item.Attributes; break;
 284.147 -    case kpidCommented:  prop = item.IsCommented(); break;
 284.148 -    */
 284.149 -    case kpidMethod:
 284.150 -    {
 284.151 -      wchar_t method2[kMethodIdSize + 1];
 284.152 -      method2[kMethodIdSize] = 0;
 284.153 -      for (int i = 0; i < kMethodIdSize; i++)
 284.154 -        method2[i] = item.Method[i];
 284.155 -      prop = method2;
 284.156 -      break;
 284.157 -    }
 284.158 -  }
 284.159 -  prop.Detach(value);
 284.160 -  return S_OK;
 284.161 -  COM_TRY_END
 284.162 -}
 284.163 -
 284.164 -/*
 284.165 -class CProgressImp: public CProgressVirt
 284.166 -{
 284.167 -public:
 284.168 -  CMyComPtr<IArchiveOpenCallback> Callback;
 284.169 -  STDMETHOD(SetCompleted)(const UInt64 *numFiles);
 284.170 -};
 284.171 -
 284.172 -STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
 284.173 -{
 284.174 -  if (Callback)
 284.175 -    return Callback->SetCompleted(numFiles, NULL);
 284.176 -  return S_OK;
 284.177 -}
 284.178 -*/
 284.179 -
 284.180 -STDMETHODIMP CHandler::Open(IInStream *stream,
 284.181 -    const UInt64 * /* maxCheckStartPosition */, IArchiveOpenCallback *callback)
 284.182 -{
 284.183 -  COM_TRY_BEGIN
 284.184 -  try
 284.185 -  {
 284.186 -    _items.Clear();
 284.187 -    CInArchive archive;
 284.188 -
 284.189 -    UInt64 endPos = 0;
 284.190 -    bool needSetTotal = true;
 284.191 -
 284.192 -    if (callback != NULL)
 284.193 -    {
 284.194 -      RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
 284.195 -      RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
 284.196 -    }
 284.197 -
 284.198 -    RINOK(archive.Open(stream));
 284.199 -    for (;;)
 284.200 -    {
 284.201 -      CItemEx item;
 284.202 -      bool filled;
 284.203 -      HRESULT result = archive.GetNextItem(filled, item);
 284.204 -      if (result == S_FALSE)
 284.205 -        return S_FALSE;
 284.206 -      if (result != S_OK)
 284.207 -        return S_FALSE;
 284.208 -      if (!filled)
 284.209 -        break;
 284.210 -      _items.Add(item);
 284.211 -      archive.Skeep(item.PackSize);
 284.212 -      if (callback != NULL)
 284.213 -      {
 284.214 -        if (needSetTotal)
 284.215 -        {
 284.216 -          RINOK(callback->SetTotal(NULL, &endPos));
 284.217 -          needSetTotal = false;
 284.218 -        }
 284.219 -        if (_items.Size() % 100 == 0)
 284.220 -        {
 284.221 -          UInt64 numFiles = _items.Size();
 284.222 -          UInt64 numBytes = item.DataPosition;
 284.223 -          RINOK(callback->SetCompleted(&numFiles, &numBytes));
 284.224 -        }
 284.225 -      }
 284.226 -    }
 284.227 -    if (_items.IsEmpty())
 284.228 -      return S_FALSE;
 284.229 -
 284.230 -    _stream = stream;
 284.231 -  }
 284.232 -  catch(...)
 284.233 -  {
 284.234 -    return S_FALSE;
 284.235 -  }
 284.236 -  COM_TRY_END
 284.237 -  return S_OK;
 284.238 -}
 284.239 -
 284.240 -STDMETHODIMP CHandler::Close()
 284.241 -{
 284.242 -  _items.Clear();
 284.243 -  _stream.Release();
 284.244 -  return S_OK;
 284.245 -}
 284.246 -
 284.247 -
 284.248 -
 284.249 -//////////////////////////////////////
 284.250 -// CHandler::DecompressItems
 284.251 -
 284.252 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 284.253 -    Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
 284.254 -{
 284.255 -  COM_TRY_BEGIN
 284.256 -  bool testMode = (testModeSpec != 0);
 284.257 -  UInt64 totalUnPacked = 0, totalPacked = 0;
 284.258 -  bool allFilesMode = (numItems == UInt32(-1));
 284.259 -  if (allFilesMode)
 284.260 -    numItems = _items.Size();
 284.261 -  if(numItems == 0)
 284.262 -    return S_OK;
 284.263 -  UInt32 i;
 284.264 -  for(i = 0; i < numItems; i++)
 284.265 -  {
 284.266 -    const CItemEx &item = _items[allFilesMode ? i : indices[i]];
 284.267 -    totalUnPacked += item.Size;
 284.268 -    totalPacked += item.PackSize;
 284.269 -  }
 284.270 -  extractCallback->SetTotal(totalUnPacked);
 284.271 -
 284.272 -  UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
 284.273 -  UInt64 currentItemUnPacked, currentItemPacked;
 284.274 -  
 284.275 -  NCompress::NLzh::NDecoder::CCoder *lzhDecoderSpec = 0;
 284.276 -  CMyComPtr<ICompressCoder> lzhDecoder;
 284.277 -  CMyComPtr<ICompressCoder> lzh1Decoder;
 284.278 -  CMyComPtr<ICompressCoder> arj2Decoder;
 284.279 -
 284.280 -  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
 284.281 -  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
 284.282 -
 284.283 -  CLocalProgress *lps = new CLocalProgress;
 284.284 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 284.285 -  lps->Init(extractCallback, false);
 284.286 -
 284.287 -  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
 284.288 -  CMyComPtr<ISequentialInStream> inStream(streamSpec);
 284.289 -  streamSpec->SetStream(_stream);
 284.290 -
 284.291 -  for(i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked,
 284.292 -      currentTotalPacked += currentItemPacked)
 284.293 -  {
 284.294 -    currentItemUnPacked = 0;
 284.295 -    currentItemPacked = 0;
 284.296 -
 284.297 -    lps->InSize = currentTotalPacked;
 284.298 -    lps->OutSize = currentTotalUnPacked;
 284.299 -    RINOK(lps->SetCur());
 284.300 -
 284.301 -    CMyComPtr<ISequentialOutStream> realOutStream;
 284.302 -    Int32 askMode;
 284.303 -    askMode = testMode ? NExtract::NAskMode::kTest :
 284.304 -        NExtract::NAskMode::kExtract;
 284.305 -    Int32 index = allFilesMode ? i : indices[i];
 284.306 -    const CItemEx &item = _items[index];
 284.307 -    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
 284.308 -
 284.309 -    if (item.IsDir())
 284.310 -    {
 284.311 -      // if (!testMode)
 284.312 -      {
 284.313 -        RINOK(extractCallback->PrepareOperation(askMode));
 284.314 -        RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
 284.315 -      }
 284.316 -      continue;
 284.317 -    }
 284.318 -
 284.319 -    if (!testMode && (!realOutStream))
 284.320 -      continue;
 284.321 -
 284.322 -    RINOK(extractCallback->PrepareOperation(askMode));
 284.323 -    currentItemUnPacked = item.Size;
 284.324 -    currentItemPacked = item.PackSize;
 284.325 -
 284.326 -    {
 284.327 -      COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
 284.328 -      CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 284.329 -      outStreamSpec->Init(realOutStream);
 284.330 -      realOutStream.Release();
 284.331 -      
 284.332 -      UInt64 pos;
 284.333 -      _stream->Seek(item.DataPosition, STREAM_SEEK_SET, &pos);
 284.334 -
 284.335 -      streamSpec->Init(item.PackSize);
 284.336 -
 284.337 -      HRESULT result = S_OK;
 284.338 -      Int32 opRes = NExtract::NOperationResult::kOK;
 284.339 -
 284.340 -      if (item.IsCopyMethod())
 284.341 -      {
 284.342 -        result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
 284.343 -        if (result == S_OK && copyCoderSpec->TotalSize != item.PackSize)
 284.344 -          result = S_FALSE;
 284.345 -      }
 284.346 -      else if (item.IsLh4GroupMethod())
 284.347 -      {
 284.348 -        if (!lzhDecoder)
 284.349 -        {
 284.350 -          lzhDecoderSpec = new NCompress::NLzh::NDecoder::CCoder;
 284.351 -          lzhDecoder = lzhDecoderSpec;
 284.352 -        }
 284.353 -        lzhDecoderSpec->SetDictionary(item.GetNumDictBits());
 284.354 -        result = lzhDecoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
 284.355 -      }
 284.356 -      /*
 284.357 -      else if (item.IsLh1GroupMethod())
 284.358 -      {
 284.359 -        if (!lzh1Decoder)
 284.360 -        {
 284.361 -          lzh1DecoderSpec = new NCompress::NLzh1::NDecoder::CCoder;
 284.362 -          lzh1Decoder = lzh1DecoderSpec;
 284.363 -        }
 284.364 -        lzh1DecoderSpec->SetDictionary(item.GetNumDictBits());
 284.365 -        result = lzh1Decoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
 284.366 -      }
 284.367 -      */
 284.368 -      else
 284.369 -        opRes = NExtract::NOperationResult::kUnSupportedMethod;
 284.370 -
 284.371 -      if (opRes == NExtract::NOperationResult::kOK)
 284.372 -      {
 284.373 -        if (result == S_FALSE)
 284.374 -          opRes = NExtract::NOperationResult::kDataError;
 284.375 -        else
 284.376 -        {
 284.377 -          RINOK(result);
 284.378 -          if (outStreamSpec->GetCRC() != item.CRC)
 284.379 -            opRes = NExtract::NOperationResult::kCRCError;
 284.380 -        }
 284.381 -      }
 284.382 -      outStream.Release();
 284.383 -      RINOK(extractCallback->SetOperationResult(opRes));
 284.384 -    }
 284.385 -  }
 284.386 -  return S_OK;
 284.387 -  COM_TRY_END
 284.388 -}
 284.389 -
 284.390 -}}
   285.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHandler.h	Sat Mar 03 10:54:39 2012 -0600
   285.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   285.3 @@ -1,30 +0,0 @@
   285.4 -// LzhHandler.h
   285.5 -
   285.6 -#ifndef __LZH_HANDLER_H
   285.7 -#define __LZH_HANDLER_H
   285.8 -
   285.9 -#include "Common/MyCom.h"
  285.10 -#include "../IArchive.h"
  285.11 -#include "LzhIn.h"
  285.12 -
  285.13 -namespace NArchive {
  285.14 -namespace NLzh {
  285.15 -
  285.16 -class CHandler:
  285.17 -  public IInArchive,
  285.18 -  public CMyUnknownImp
  285.19 -{
  285.20 -public:
  285.21 -  MY_UNKNOWN_IMP1(IInArchive)
  285.22 -
  285.23 -  INTERFACE_IInArchive(;)
  285.24 -
  285.25 -  CHandler();
  285.26 -private:
  285.27 -  CObjectVector<CItemEx> _items;
  285.28 -  CMyComPtr<IInStream> _stream;
  285.29 -};
  285.30 -
  285.31 -}}
  285.32 -
  285.33 -#endif
   286.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhHeader.h	Sat Mar 03 10:54:39 2012 -0600
   286.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   286.3 @@ -1,19 +0,0 @@
   286.4 -// Archive/Lzh/Header.h
   286.5 -
   286.6 -#ifndef __ARCHIVE_LZH_HEADER_H
   286.7 -#define __ARCHIVE_LZH_HEADER_H
   286.8 -
   286.9 -#include "Common/Types.h"
  286.10 -
  286.11 -namespace NArchive {
  286.12 -namespace NLzh {
  286.13 -
  286.14 -const int kMethodIdSize = 5;
  286.15 -
  286.16 -const Byte kExtIdFileName = 0x01;
  286.17 -const Byte kExtIdDirName  = 0x02;
  286.18 -const Byte kExtIdUnixTime = 0x54;
  286.19 -
  286.20 -}}
  286.21 -
  286.22 -#endif
   287.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   287.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   287.3 @@ -1,172 +0,0 @@
   287.4 -// Archive/LzhIn.cpp
   287.5 -
   287.6 -#include "StdAfx.h"
   287.7 -
   287.8 -#include "Common/StringConvert.h"
   287.9 -#include "Common/Buffer.h"
  287.10 -
  287.11 -#include "../../Common/StreamUtils.h"
  287.12 -
  287.13 -#include "LzhIn.h"
  287.14 -
  287.15 -namespace NArchive {
  287.16 -namespace NLzh {
  287.17 - 
  287.18 -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
  287.19 -{
  287.20 -  size_t realProcessedSize = size;
  287.21 -  RINOK(ReadStream(m_Stream, data, &realProcessedSize));
  287.22 -  processedSize = (UInt32)realProcessedSize;
  287.23 -  m_Position += processedSize;
  287.24 -  return S_OK;
  287.25 -}
  287.26 -
  287.27 -HRESULT CInArchive::CheckReadBytes(void *data, UInt32 size)
  287.28 -{
  287.29 -  UInt32 processedSize;
  287.30 -  RINOK(ReadBytes(data, size, processedSize));
  287.31 -  return (processedSize == size) ? S_OK: S_FALSE;
  287.32 -}
  287.33 -
  287.34 -HRESULT CInArchive::Open(IInStream *inStream)
  287.35 -{
  287.36 -  RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
  287.37 -  m_Stream = inStream;
  287.38 -  return S_OK;
  287.39 -}
  287.40 -
  287.41 -static const Byte *ReadUInt32(const Byte *p, UInt32 &v)
  287.42 -{
  287.43 -  v = 0;
  287.44 -  for (int i = 0; i < 4; i++)
  287.45 -    v |= ((UInt32)(*p++) << (i * 8));
  287.46 -  return p;
  287.47 -}
  287.48 -
  287.49 -static const Byte *ReadUInt16(const Byte *p, UInt16 &v)
  287.50 -{
  287.51 -  v = 0;
  287.52 -  for (int i = 0; i < 2; i++)
  287.53 -    v |= ((UInt16)(*p++) << (i * 8));
  287.54 -  return p;
  287.55 -}
  287.56 -
  287.57 -static const Byte *ReadString(const Byte *p, size_t size, AString &s)
  287.58 -{
  287.59 -  s.Empty();
  287.60 -  for (size_t i = 0; i < size; i++)
  287.61 -  {
  287.62 -    char c = p[i];
  287.63 -    if (c == 0)
  287.64 -      break;
  287.65 -    s += c;
  287.66 -  }
  287.67 -  return p + size;
  287.68 -}
  287.69 -
  287.70 -static Byte CalcSum(const Byte *data, size_t size)
  287.71 -{
  287.72 -  Byte sum = 0;
  287.73 -  for (size_t i = 0; i < size; i++)
  287.74 -    sum = (Byte)(sum + data[i]);
  287.75 -  return sum;
  287.76 -}
  287.77 -
  287.78 -HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
  287.79 -{
  287.80 -  filled = false;
  287.81 -
  287.82 -  UInt32 processedSize;
  287.83 -  Byte startHeader[2];
  287.84 -  RINOK(ReadBytes(startHeader, 2, processedSize))
  287.85 -  if (processedSize == 0)
  287.86 -    return S_OK;
  287.87 -  if (processedSize == 1)
  287.88 -    return (startHeader[0] == 0) ? S_OK: S_FALSE;
  287.89 -  if (startHeader[0] == 0 && startHeader[1] == 0)
  287.90 -    return S_OK;
  287.91 -
  287.92 -  Byte header[256];
  287.93 -  const UInt32 kBasicPartSize = 22;
  287.94 -  RINOK(ReadBytes(header, kBasicPartSize, processedSize));
  287.95 -  if (processedSize != kBasicPartSize)
  287.96 -    return (startHeader[0] == 0) ? S_OK: S_FALSE;
  287.97 -
  287.98 -  const Byte *p = header;
  287.99 -  memmove(item.Method, p, kMethodIdSize);
 287.100 -  if (!item.IsValidMethod())
 287.101 -    return S_OK;
 287.102 -  p += kMethodIdSize;
 287.103 -  p = ReadUInt32(p, item.PackSize);
 287.104 -  p = ReadUInt32(p, item.Size);
 287.105 -  p = ReadUInt32(p, item.ModifiedTime);
 287.106 -  item.Attributes = *p++;
 287.107 -  item.Level = *p++;
 287.108 -  if (item.Level > 2)
 287.109 -    return S_FALSE;
 287.110 -  UInt32 headerSize;
 287.111 -  if (item.Level < 2)
 287.112 -  {
 287.113 -    headerSize = startHeader[0];
 287.114 -    if (headerSize < kBasicPartSize)
 287.115 -      return S_FALSE;
 287.116 -    UInt32 remain = headerSize - kBasicPartSize;
 287.117 -    RINOK(CheckReadBytes(header + kBasicPartSize, remain));
 287.118 -    if (startHeader[1] != CalcSum(header, headerSize))
 287.119 -      return S_FALSE;
 287.120 -    size_t nameLength = *p++;
 287.121 -    if ((p - header) + nameLength + 2 > headerSize)
 287.122 -      return S_FALSE;
 287.123 -    p = ReadString(p, nameLength, item.Name);
 287.124 -  }
 287.125 -  else
 287.126 -   headerSize = startHeader[0] | ((UInt32)startHeader[1] << 8);
 287.127 -  p = ReadUInt16(p, item.CRC);
 287.128 -  if (item.Level != 0)
 287.129 -  {
 287.130 -    if (item.Level == 2)
 287.131 -    {
 287.132 -      RINOK(CheckReadBytes(header + kBasicPartSize, 2));
 287.133 -    }
 287.134 -    if ((size_t)(p - header) + 3 > headerSize)
 287.135 -      return S_FALSE;
 287.136 -    item.OsId = *p++;
 287.137 -    UInt16 nextSize;
 287.138 -    p = ReadUInt16(p, nextSize);
 287.139 -    while (nextSize != 0)
 287.140 -    {
 287.141 -      if (nextSize < 3)
 287.142 -        return S_FALSE;
 287.143 -      if (item.Level == 1)
 287.144 -      {
 287.145 -        if (item.PackSize < nextSize)
 287.146 -          return S_FALSE;
 287.147 -        item.PackSize -= nextSize;
 287.148 -      }
 287.149 -      CExtension ext;
 287.150 -      RINOK(CheckReadBytes(&ext.Type, 1))
 287.151 -      nextSize -= 3;
 287.152 -      ext.Data.SetCapacity(nextSize);
 287.153 -      RINOK(CheckReadBytes((Byte *)ext.Data, nextSize))
 287.154 -      item.Extensions.Add(ext);
 287.155 -      Byte hdr2[2];
 287.156 -      RINOK(CheckReadBytes(hdr2, 2));
 287.157 -      ReadUInt16(hdr2, nextSize);
 287.158 -    }
 287.159 -  }
 287.160 -  item.DataPosition = m_Position;
 287.161 -  filled = true;
 287.162 -  return S_OK;
 287.163 -}
 287.164 -
 287.165 -HRESULT CInArchive::Skeep(UInt64 numBytes)
 287.166 -{
 287.167 -  UInt64 newPostion;
 287.168 -  RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
 287.169 -  m_Position += numBytes;
 287.170 -  if (m_Position != newPostion)
 287.171 -    return E_FAIL;
 287.172 -  return S_OK;
 287.173 -}
 287.174 -
 287.175 -}}
   288.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhIn.h	Sat Mar 03 10:54:39 2012 -0600
   288.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   288.3 @@ -1,29 +0,0 @@
   288.4 -// Archive/LzhIn.h
   288.5 -
   288.6 -#ifndef __ARCHIVE_LZHIN_H
   288.7 -#define __ARCHIVE_LZHIN_H
   288.8 -
   288.9 -#include "Common/MyCom.h"
  288.10 -#include "../../IStream.h"
  288.11 -
  288.12 -#include "LzhItem.h"
  288.13 -
  288.14 -namespace NArchive {
  288.15 -namespace NLzh {
  288.16 -  
  288.17 -class CInArchive
  288.18 -{
  288.19 -  CMyComPtr<IInStream> m_Stream;
  288.20 -  UInt64 m_Position;
  288.21 -  
  288.22 -  HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
  288.23 -  HRESULT CheckReadBytes(void *data, UInt32 size);
  288.24 -public:
  288.25 -  HRESULT Open(IInStream *inStream);
  288.26 -  HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
  288.27 -  HRESULT Skeep(UInt64 numBytes);
  288.28 -};
  288.29 -  
  288.30 -}}
  288.31 -  
  288.32 -#endif
   289.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhItem.h	Sat Mar 03 10:54:39 2012 -0600
   289.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   289.3 @@ -1,172 +0,0 @@
   289.4 -// Archive/LzhItem.h
   289.5 -
   289.6 -#ifndef __ARCHIVE_LZH_ITEM_H
   289.7 -#define __ARCHIVE_LZH_ITEM_H
   289.8 -
   289.9 -#include "Common/Types.h"
  289.10 -#include "Common/MyString.h"
  289.11 -#include "Common/Buffer.h"
  289.12 -#include "LzhHeader.h"
  289.13 -
  289.14 -namespace NArchive {
  289.15 -namespace NLzh {
  289.16 -
  289.17 -struct CExtension
  289.18 -{
  289.19 -  Byte Type;
  289.20 -  CByteBuffer Data;
  289.21 -  AString GetString() const
  289.22 -  {
  289.23 -    AString s;
  289.24 -    for (size_t i = 0; i < Data.GetCapacity(); i++)
  289.25 -    {
  289.26 -      char c = (char)Data[i];
  289.27 -      if (c == 0)
  289.28 -        break;
  289.29 -      s += c;
  289.30 -    }
  289.31 -    return s;
  289.32 -  }
  289.33 -};
  289.34 -
  289.35 -struct CItem
  289.36 -{
  289.37 -public:
  289.38 -  AString Name;
  289.39 -  Byte Method[kMethodIdSize];
  289.40 -  UInt32 PackSize;
  289.41 -  UInt32 Size;
  289.42 -  UInt32 ModifiedTime;
  289.43 -  Byte Attributes;
  289.44 -  Byte Level;
  289.45 -  UInt16 CRC;
  289.46 -  Byte OsId;
  289.47 -  CObjectVector<CExtension> Extensions;
  289.48 -
  289.49 -  bool IsValidMethod() const  { return (Method[0] == '-' && Method[1] == 'l' && Method[4] == '-'); }
  289.50 -  bool IsLhMethod() const  {return (IsValidMethod() && Method[2] == 'h'); }
  289.51 -  bool IsDir() const {return (IsLhMethod() && Method[3] == 'd'); }
  289.52 -
  289.53 -  bool IsCopyMethod() const
  289.54 -  {
  289.55 -    return (IsLhMethod() && Method[3] == '0') ||
  289.56 -      (IsValidMethod() && Method[2] == 'z' && Method[3] == '4');
  289.57 -  }
  289.58 -  
  289.59 -  bool IsLh1GroupMethod() const
  289.60 -  {
  289.61 -    if (!IsLhMethod())
  289.62 -      return false;
  289.63 -    switch(Method[3])
  289.64 -    {
  289.65 -      case '1':
  289.66 -        return true;
  289.67 -    }
  289.68 -    return false;
  289.69 -  }
  289.70 -  
  289.71 -  bool IsLh4GroupMethod() const
  289.72 -  {
  289.73 -    if (!IsLhMethod())
  289.74 -      return false;
  289.75 -    switch(Method[3])
  289.76 -    {
  289.77 -      case '4':
  289.78 -      case '5':
  289.79 -      case '6':
  289.80 -      case '7':
  289.81 -        return true;
  289.82 -    }
  289.83 -    return false;
  289.84 -  }
  289.85 -  
  289.86 -  int GetNumDictBits() const
  289.87 -  {
  289.88 -    if (!IsLhMethod())
  289.89 -      return 0;
  289.90 -    switch(Method[3])
  289.91 -    {
  289.92 -      case '1':
  289.93 -        return 12;
  289.94 -      case '2':
  289.95 -        return 13;
  289.96 -      case '3':
  289.97 -        return 13;
  289.98 -      case '4':
  289.99 -        return 12;
 289.100 -      case '5':
 289.101 -        return 13;
 289.102 -      case '6':
 289.103 -        return 15;
 289.104 -      case '7':
 289.105 -        return 16;
 289.106 -    }
 289.107 -    return 0;
 289.108 -  }
 289.109 -
 289.110 -  int FindExt(Byte type) const
 289.111 -  {
 289.112 -    for (int i = 0; i < Extensions.Size(); i++)
 289.113 -      if (Extensions[i].Type == type)
 289.114 -        return i;
 289.115 -    return -1;
 289.116 -  }
 289.117 -  bool GetUnixTime(UInt32 &value) const
 289.118 -  {
 289.119 -    int index = FindExt(kExtIdUnixTime);
 289.120 -    if (index < 0)
 289.121 -    {
 289.122 -      if (Level == 2)
 289.123 -      {
 289.124 -        value = ModifiedTime;
 289.125 -        return true;
 289.126 -      }
 289.127 -      return false;
 289.128 -    }
 289.129 -    const Byte *data = (const Byte *)(Extensions[index].Data);
 289.130 -    value = data[0] |
 289.131 -        ((UInt32)data[1] << 8) |
 289.132 -        ((UInt32)data[2] << 16) |
 289.133 -        ((UInt32)data[3] << 24);
 289.134 -    return true;
 289.135 -  }
 289.136 -
 289.137 -  AString GetDirName() const
 289.138 -  {
 289.139 -    int index = FindExt(kExtIdDirName);
 289.140 -    if (index < 0)
 289.141 -      return AString();
 289.142 -    return Extensions[index].GetString();
 289.143 -  }
 289.144 -
 289.145 -  AString GetFileName() const
 289.146 -  {
 289.147 -    int index = FindExt(kExtIdFileName);
 289.148 -    if (index < 0)
 289.149 -      return Name;
 289.150 -    return Extensions[index].GetString();
 289.151 -  }
 289.152 -
 289.153 -  AString GetName() const
 289.154 -  {
 289.155 -    AString dirName = GetDirName();
 289.156 -    dirName.Replace((char)(unsigned char)0xFF, '\\');
 289.157 -    if (!dirName.IsEmpty())
 289.158 -    {
 289.159 -      char c = dirName[dirName.Length() - 1];
 289.160 -      if (c != '\\')
 289.161 -        dirName += '\\';
 289.162 -    }
 289.163 -    return dirName + GetFileName();
 289.164 -  }
 289.165 -};
 289.166 -
 289.167 -class CItemEx: public CItem
 289.168 -{
 289.169 -public:
 289.170 -  UInt64 DataPosition;
 289.171 -};
 289.172 -
 289.173 -}}
 289.174 -
 289.175 -#endif
   290.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp	Sat Mar 03 10:54:39 2012 -0600
   290.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   290.3 @@ -1,27 +0,0 @@
   290.4 -// LzhOutStreamWithCRC.cpp
   290.5 -
   290.6 -#include "StdAfx.h"
   290.7 -
   290.8 -#include "LzhOutStreamWithCRC.h"
   290.9 -
  290.10 -namespace NArchive {
  290.11 -namespace NLzh {
  290.12 -
  290.13 -STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
  290.14 -{
  290.15 -  UInt32 realProcessedSize;
  290.16 -  HRESULT result;
  290.17 -  if(!_stream)
  290.18 -  {
  290.19 -    realProcessedSize = size;
  290.20 -    result = S_OK;
  290.21 -  }
  290.22 -  else
  290.23 -    result = _stream->Write(data, size, &realProcessedSize);
  290.24 -  _crc.Update(data, realProcessedSize);
  290.25 -  if(processedSize != NULL)
  290.26 -    *processedSize = realProcessedSize;
  290.27 -  return result;
  290.28 -}
  290.29 -
  290.30 -}}
   291.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h	Sat Mar 03 10:54:39 2012 -0600
   291.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   291.3 @@ -1,38 +0,0 @@
   291.4 -// LzhOutStreamWithCRC.h
   291.5 -
   291.6 -#ifndef __LZHOUTSTREAMWITHCRC_H
   291.7 -#define __LZHOUTSTREAMWITHCRC_H
   291.8 -
   291.9 -#include "LzhCRC.h"
  291.10 -#include "../../../Common/MyCom.h"
  291.11 -#include "../../IStream.h"
  291.12 -
  291.13 -namespace NArchive {
  291.14 -namespace NLzh {
  291.15 -
  291.16 -class COutStreamWithCRC:
  291.17 -  public ISequentialOutStream,
  291.18 -  public CMyUnknownImp
  291.19 -{
  291.20 -public:
  291.21 -  MY_UNKNOWN_IMP
  291.22 -
  291.23 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  291.24 -private:
  291.25 -  CCRC _crc;
  291.26 -  CMyComPtr<ISequentialOutStream> _stream;
  291.27 -public:
  291.28 -  void Init(ISequentialOutStream *stream)
  291.29 -  {
  291.30 -    _stream = stream;
  291.31 -    _crc.Init();
  291.32 -  }
  291.33 -  void ReleaseStream() { _stream.Release(); }
  291.34 -  UInt32 GetCRC() const { return _crc.GetDigest(); }
  291.35 -  void InitCRC() { _crc.Init(); }
  291.36 -
  291.37 -};
  291.38 -
  291.39 -}}
  291.40 -
  291.41 -#endif
   292.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   292.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   292.3 @@ -1,13 +0,0 @@
   292.4 -// LzhRegister.cpp
   292.5 -
   292.6 -#include "StdAfx.h"
   292.7 -
   292.8 -#include "../../Common/RegisterArc.h"
   292.9 -
  292.10 -#include "LzhHandler.h"
  292.11 -static IInArchive *CreateArc() { return new NArchive::NLzh::CHandler;  }
  292.12 -
  292.13 -static CArcInfo g_ArcInfo =
  292.14 -  { L"Lzh", L"lzh lha", 0, 6, { '-', 'l' }, 2, false, CreateArc, 0 };
  292.15 -
  292.16 -REGISTER_ARC(Lzh)
   293.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzh/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   293.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   293.3 @@ -1,8 +0,0 @@
   293.4 -// StdAfx.h
   293.5 -
   293.6 -#ifndef __STDAFX_H
   293.7 -#define __STDAFX_H
   293.8 -
   293.9 -#include "../../../Common/MyWindows.h"
  293.10 -
  293.11 -#endif
   294.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   294.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   294.3 @@ -1,14 +0,0 @@
   294.4 -// LzmaArcRegister.cpp
   294.5 -
   294.6 -#include "StdAfx.h"
   294.7 -
   294.8 -#include "../../Common/RegisterArc.h"
   294.9 -
  294.10 -#include "LzmaHandler.h"
  294.11 -
  294.12 -static IInArchive *CreateArc() { return new NArchive::NLzma::CHandler;  }
  294.13 -
  294.14 -static CArcInfo g_ArcInfo =
  294.15 -  { L"Lzma", L"lzma lzma86", 0, 0xA, {0 }, 0, true, CreateArc, NULL };
  294.16 -
  294.17 -REGISTER_ARC(Lzma)
   295.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp	Sat Mar 03 10:54:39 2012 -0600
   295.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   295.3 @@ -1,86 +0,0 @@
   295.4 -// LzmaFiltersDecode.cpp
   295.5 -
   295.6 -#include "StdAfx.h"
   295.7 -
   295.8 -#include "LzmaFiltersDecode.h"
   295.9 -
  295.10 -namespace NArchive {
  295.11 -namespace NLzma {
  295.12 -
  295.13 -static const UInt64 k_LZMA = 0x030101;
  295.14 -static const UInt64 k_BCJ = 0x03030103;
  295.15 -  
  295.16 -HRESULT CDecoder::Code(
  295.17 -    DECL_EXTERNAL_CODECS_LOC_VARS
  295.18 -    const CHeader &block,
  295.19 -    ISequentialInStream *inStream, ISequentialOutStream *outStream,
  295.20 -    UInt64 *inProcessedSize, ICompressProgressInfo *progress)
  295.21 -{
  295.22 -  *inProcessedSize = (UInt64)(Int64)-1;
  295.23 -
  295.24 -  if (block.FilterMethod > 1)
  295.25 -    return E_NOTIMPL;
  295.26 -
  295.27 -  if (!_lzmaDecoder)
  295.28 -  {
  295.29 -    RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_LZMA, _lzmaDecoder, false));
  295.30 -    if (_lzmaDecoder == 0)
  295.31 -      return E_NOTIMPL;
  295.32 -  }
  295.33 -
  295.34 -  {
  295.35 -    CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
  295.36 -    _lzmaDecoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
  295.37 -    if (!setDecoderProperties)
  295.38 -      return E_NOTIMPL;
  295.39 -    RINOK(setDecoderProperties->SetDecoderProperties2(block.LzmaProps, 5));
  295.40 -  }
  295.41 -
  295.42 -  bool filteredMode = (block.FilterMethod == 1);
  295.43 -
  295.44 -  CMyComPtr<ICompressSetOutStream> setOutStream;
  295.45 -
  295.46 -  if (filteredMode)
  295.47 -  {
  295.48 -    if (!_bcjStream)
  295.49 -    {
  295.50 -      CMyComPtr<ICompressCoder> coder;
  295.51 -      RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_BCJ, coder, false));
  295.52 -      if (!coder)
  295.53 -        return E_NOTIMPL;
  295.54 -      coder.QueryInterface(IID_ISequentialOutStream, &_bcjStream);
  295.55 -      if (!_bcjStream)
  295.56 -        return E_NOTIMPL;
  295.57 -    }
  295.58 -
  295.59 -    _bcjStream.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
  295.60 -    if (!setOutStream)
  295.61 -      return E_NOTIMPL;
  295.62 -    RINOK(setOutStream->SetOutStream(outStream));
  295.63 -    outStream = _bcjStream;
  295.64 -  }
  295.65 -
  295.66 -  const UInt64 *unpackSize = block.HasUnpackSize() ? &block.UnpackSize : NULL;
  295.67 -  RINOK(_lzmaDecoder->Code(inStream, outStream, NULL, unpackSize, progress));
  295.68 -
  295.69 -  if (filteredMode)
  295.70 -  {
  295.71 -    CMyComPtr<IOutStreamFlush> flush;
  295.72 -    _bcjStream.QueryInterface(IID_IOutStreamFlush, &flush);
  295.73 -    if (flush)
  295.74 -    {
  295.75 -      RINOK(flush->Flush());
  295.76 -    }
  295.77 -    RINOK(setOutStream->ReleaseOutStream());
  295.78 -  }
  295.79 -
  295.80 -  CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
  295.81 -  _lzmaDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize, &getInStreamProcessedSize);
  295.82 -  if (getInStreamProcessedSize)
  295.83 -  {
  295.84 -    RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(inProcessedSize));
  295.85 -  }
  295.86 -  return S_OK;
  295.87 -}
  295.88 -
  295.89 -}}
   296.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h	Sat Mar 03 10:54:39 2012 -0600
   296.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   296.3 @@ -1,26 +0,0 @@
   296.4 -// LzmaFiltersDecode.h
   296.5 -
   296.6 -#ifndef __LZMA_FILTERS_DECODE_H
   296.7 -#define __LZMA_FILTERS_DECODE_H
   296.8 -
   296.9 -#include "../../Common/CreateCoder.h"
  296.10 -
  296.11 -#include "LzmaItem.h"
  296.12 -
  296.13 -namespace NArchive {
  296.14 -namespace NLzma {
  296.15 -
  296.16 -class CDecoder
  296.17 -{
  296.18 -  CMyComPtr<ICompressCoder> _lzmaDecoder;
  296.19 -  CMyComPtr<ISequentialOutStream> _bcjStream;
  296.20 -public:
  296.21 -  HRESULT Code(DECL_EXTERNAL_CODECS_LOC_VARS
  296.22 -      const CHeader &block,
  296.23 -      ISequentialInStream *inStream, ISequentialOutStream *outStream,
  296.24 -      UInt64 *inProcessedSize, ICompressProgressInfo *progress);
  296.25 -};
  296.26 -
  296.27 -}}
  296.28 -
  296.29 -#endif
   297.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   297.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   297.3 @@ -1,243 +0,0 @@
   297.4 -// LzmaHandler.cpp
   297.5 -
   297.6 -#include "StdAfx.h"
   297.7 -
   297.8 -#include "LzmaHandler.h"
   297.9 -
  297.10 -#include "Common/Defs.h"
  297.11 -#include "Common/StringConvert.h"
  297.12 -#include "Common/ComTry.h"
  297.13 -#include "Common/IntToString.h"
  297.14 -
  297.15 -#include "Windows/PropVariant.h"
  297.16 -
  297.17 -#include "../../Common/ProgressUtils.h"
  297.18 -#include "../../Common/StreamUtils.h"
  297.19 -#include "../Common/DummyOutStream.h"
  297.20 -
  297.21 -#include "LzmaFiltersDecode.h"
  297.22 -
  297.23 -namespace NArchive {
  297.24 -namespace NLzma {
  297.25 -
  297.26 -STATPROPSTG kProps[] =
  297.27 -{
  297.28 -  { NULL, kpidSize, VT_UI8},
  297.29 -  { NULL, kpidPackSize, VT_UI8},
  297.30 -  { NULL, kpidMethod, VT_UI1}
  297.31 -};
  297.32 -
  297.33 -IMP_IInArchive_Props
  297.34 -IMP_IInArchive_ArcProps_NO
  297.35 -
  297.36 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
  297.37 -{
  297.38 -  *numItems = 1;
  297.39 -  return S_OK;
  297.40 -}
  297.41 -
  297.42 -static void ConvertUInt32ToString(UInt32 value, wchar_t *s)
  297.43 -{
  297.44 -  ConvertUInt64ToString(value, s + MyStringLen(s));
  297.45 -}
  297.46 -
  297.47 -static void DictSizeToString(UInt32 value, wchar_t *s)
  297.48 -{
  297.49 -  for (int i = 0; i <= 31; i++)
  297.50 -    if ((UInt32(1) << i) == value)
  297.51 -    {
  297.52 -      ConvertUInt32ToString(i, s);
  297.53 -      return;
  297.54 -    }
  297.55 -  wchar_t c = L'b';
  297.56 -  if ((value & ((1 << 20) - 1)) == 0)
  297.57 -  {
  297.58 -    value >>= 20;
  297.59 -    c = L'm';
  297.60 -  }
  297.61 -  else if ((value & ((1 << 10) - 1)) == 0)
  297.62 -  {
  297.63 -    value >>= 10;
  297.64 -    c = L'k';
  297.65 -  }
  297.66 -  ConvertUInt32ToString(value, s);
  297.67 -  int p = MyStringLen(s);
  297.68 -  s[p++] = c;
  297.69 -  s[p++] = L'\0';
  297.70 -}
  297.71 -
  297.72 -static void MyStrCat(wchar_t *d, const wchar_t *s)
  297.73 -{
  297.74 -  MyStringCopy(d + MyStringLen(d), s);
  297.75 -}
  297.76 -
  297.77 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
  297.78 -{
  297.79 -  if (index != 0)
  297.80 -    return E_INVALIDARG;
  297.81 -  NWindows::NCOM::CPropVariant propVariant;
  297.82 -  switch(propID)
  297.83 -  {
  297.84 -    case kpidSize:
  297.85 -      if (m_StreamInfo.HasUnpackSize())
  297.86 -        propVariant = (UInt64)m_StreamInfo.UnpackSize;
  297.87 -      break;
  297.88 -    case kpidPackSize:
  297.89 -      propVariant = (UInt64)m_PackSize;
  297.90 -      break;
  297.91 -    case kpidMethod:
  297.92 -    {
  297.93 -      wchar_t s[64];
  297.94 -      s[0] = '\0';
  297.95 -      if (m_StreamInfo.IsThereFilter)
  297.96 -      {
  297.97 -        const wchar_t *f;
  297.98 -        if (m_StreamInfo.FilterMethod == 0)
  297.99 -          f = L"Copy";
 297.100 -        else if (m_StreamInfo.FilterMethod == 1)
 297.101 -          f = L"BCJ";
 297.102 -        else
 297.103 -          f = L"Unknown";
 297.104 -        MyStrCat(s, f);
 297.105 -        MyStrCat(s, L" ");
 297.106 -      }
 297.107 -      MyStrCat(s, L"LZMA:");
 297.108 -      DictSizeToString(m_StreamInfo.GetDicSize(), s);
 297.109 -      propVariant = s;
 297.110 -      break;
 297.111 -    }
 297.112 -  }
 297.113 -  propVariant.Detach(value);
 297.114 -  return S_OK;
 297.115 -}
 297.116 -
 297.117 -STDMETHODIMP CHandler::Open(IInStream *inStream,
 297.118 -    const UInt64 * /* maxCheckStartPosition */,
 297.119 -    IArchiveOpenCallback * /* openArchiveCallback */)
 297.120 -{
 297.121 -  {
 297.122 -    RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
 297.123 -
 297.124 -    HRESULT res = ReadStreamHeader(inStream, m_StreamInfo);
 297.125 -    if (res != S_OK)
 297.126 -      return S_FALSE;
 297.127 -    
 297.128 -    Byte b;
 297.129 -    RINOK(ReadStream_FALSE(inStream, &b, 1));
 297.130 -    if (b != 0)
 297.131 -      return S_FALSE;
 297.132 -
 297.133 -    UInt64 endPos;
 297.134 -    RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
 297.135 -    m_PackSize = endPos - m_StreamStartPosition - m_StreamInfo.GetHeaderSize();
 297.136 -
 297.137 -    m_Stream = inStream;
 297.138 -  }
 297.139 -  return S_OK;
 297.140 -}
 297.141 -
 297.142 -STDMETHODIMP CHandler::Close()
 297.143 -{
 297.144 -  m_Stream.Release();
 297.145 -  return S_OK;
 297.146 -}
 297.147 -
 297.148 -
 297.149 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 297.150 -    Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
 297.151 -{
 297.152 -  COM_TRY_BEGIN
 297.153 -  bool allFilesMode = (numItems == UInt32(-1));
 297.154 -  if (!allFilesMode)
 297.155 -  {
 297.156 -    if (numItems == 0)
 297.157 -      return S_OK;
 297.158 -    if (numItems != 1)
 297.159 -      return E_INVALIDARG;
 297.160 -    if (indices[0] != 0)
 297.161 -      return E_INVALIDARG;
 297.162 -  }
 297.163 -
 297.164 -  bool testMode = (_aTestMode != 0);
 297.165 -
 297.166 -  RINOK(extractCallback->SetTotal(m_PackSize));
 297.167 -    
 297.168 -  UInt64 currentTotalPacked = 0;
 297.169 -
 297.170 -  CDummyOutStream *outStreamSpec = new CDummyOutStream;
 297.171 -  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 297.172 -
 297.173 -  {
 297.174 -    CMyComPtr<ISequentialOutStream> realOutStream;
 297.175 -    Int32 askMode = testMode ?
 297.176 -        NArchive::NExtract::NAskMode::kTest :
 297.177 -        NArchive::NExtract::NAskMode::kExtract;
 297.178 -    
 297.179 -    RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
 297.180 -
 297.181 -    outStreamSpec->SetStream(realOutStream);
 297.182 -    outStreamSpec->Init();
 297.183 -    if(!testMode && !realOutStream)
 297.184 -      return S_OK;
 297.185 -    extractCallback->PrepareOperation(askMode);
 297.186 -  }
 297.187 -  
 297.188 -  CLocalProgress *lps = new CLocalProgress;
 297.189 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 297.190 -  lps->Init(extractCallback, true);
 297.191 -
 297.192 -  CDecoder decoder;
 297.193 -  RINOK(m_Stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL));
 297.194 -  UInt64 streamPos = m_StreamStartPosition;
 297.195 -  Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
 297.196 -  bool firstItem = true;
 297.197 -  for (;;)
 297.198 -  {
 297.199 -    CHeader st;
 297.200 -    HRESULT result = ReadStreamHeader(m_Stream, st);
 297.201 -    if (result != S_OK)
 297.202 -    {
 297.203 -      if (firstItem)
 297.204 -        return E_FAIL;
 297.205 -      break;
 297.206 -    }
 297.207 -    firstItem = false;
 297.208 -
 297.209 -    lps->OutSize = outStreamSpec->GetSize();
 297.210 -    lps->InSize = currentTotalPacked;
 297.211 -    RINOK(lps->SetCur());
 297.212 -    
 297.213 -    streamPos += st.GetHeaderSize();
 297.214 -    UInt64 packProcessed;
 297.215 -
 297.216 -    {
 297.217 -      result = decoder.Code(
 297.218 -          EXTERNAL_CODECS_VARS
 297.219 -          st, m_Stream, outStream, &packProcessed, progress);
 297.220 -      if (result == E_NOTIMPL)
 297.221 -      {
 297.222 -        opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 297.223 -        break;
 297.224 -      }
 297.225 -      if (result == S_FALSE)
 297.226 -      {
 297.227 -        opRes = NArchive::NExtract::NOperationResult::kDataError;
 297.228 -        break;
 297.229 -      }
 297.230 -      RINOK(result);
 297.231 -    }
 297.232 -
 297.233 -    if (packProcessed == (UInt64)(Int64)-1)
 297.234 -      break;
 297.235 -    RINOK(m_Stream->Seek(streamPos + packProcessed, STREAM_SEEK_SET, NULL));
 297.236 -    currentTotalPacked += packProcessed;
 297.237 -    streamPos += packProcessed;
 297.238 -  }
 297.239 -  outStream.Release();
 297.240 -  return extractCallback->SetOperationResult(opRes);
 297.241 -  COM_TRY_END
 297.242 -}
 297.243 -
 297.244 -IMPL_ISetCompressCodecsInfo
 297.245 -
 297.246 -}}
   298.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h	Sat Mar 03 10:54:39 2012 -0600
   298.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   298.3 @@ -1,69 +0,0 @@
   298.4 -// Lzma/Handler.h
   298.5 -
   298.6 -#ifndef __GZIP_HANDLER_H
   298.7 -#define __GZIP_HANDLER_H
   298.8 -
   298.9 -#include "Common/MyCom.h"
  298.10 -
  298.11 -#include "../IArchive.h"
  298.12 -#include "../../Common/CreateCoder.h"
  298.13 -
  298.14 -#include "LzmaIn.h"
  298.15 -
  298.16 -namespace NArchive {
  298.17 -namespace NLzma {
  298.18 -
  298.19 -// const UInt64 k_LZMA = 0x030101;
  298.20 -
  298.21 -class CHandler:
  298.22 -  public IInArchive,
  298.23 -  PUBLIC_ISetCompressCodecsInfo
  298.24 -  public CMyUnknownImp
  298.25 -{
  298.26 -public:
  298.27 -  MY_QUERYINTERFACE_BEGIN
  298.28 -  MY_QUERYINTERFACE_ENTRY(IInArchive)
  298.29 -  QUERY_ENTRY_ISetCompressCodecsInfo
  298.30 -  MY_QUERYINTERFACE_END
  298.31 -  MY_ADDREF_RELEASE
  298.32 -
  298.33 -  STDMETHOD(Open)(IInStream *inStream,
  298.34 -      const UInt64 *maxCheckStartPosition,
  298.35 -      IArchiveOpenCallback *openArchiveCallback);
  298.36 -  STDMETHOD(Close)();
  298.37 -  
  298.38 -  STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
  298.39 -  STDMETHOD(GetProperty)(UInt32 index, PROPID propID,  PROPVARIANT *value);
  298.40 -  STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
  298.41 -      Int32 testMode, IArchiveExtractCallback *extractCallback);
  298.42 -
  298.43 -  STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
  298.44 -
  298.45 -  STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
  298.46 -  STDMETHOD(GetPropertyInfo)(UInt32 index,
  298.47 -      BSTR *name, PROPID *propID, VARTYPE *varType);
  298.48 -
  298.49 -  STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
  298.50 -  STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
  298.51 -      BSTR *name, PROPID *propID, VARTYPE *varType);
  298.52 -
  298.53 -  UString GetMethodString();
  298.54 -public:
  298.55 -  CHandler() {  }
  298.56 -
  298.57 -private:
  298.58 -  CHeader m_StreamInfo;
  298.59 -  UInt64 m_StreamStartPosition;
  298.60 -  UInt64 m_PackSize;
  298.61 -
  298.62 -  CMyComPtr<IInStream> m_Stream;
  298.63 -
  298.64 -  DECL_EXTERNAL_CODECS_VARS
  298.65 -
  298.66 -  DECL_ISetCompressCodecsInfo
  298.67 -
  298.68 -};
  298.69 -
  298.70 -}}
  298.71 -
  298.72 -#endif
   299.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   299.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   299.3 @@ -1,56 +0,0 @@
   299.4 -// Archive/LzmaIn.cpp
   299.5 -
   299.6 -#include "StdAfx.h"
   299.7 -
   299.8 -#include "LzmaIn.h"
   299.9 -
  299.10 -#include "../../Common/StreamUtils.h"
  299.11 -
  299.12 -namespace NArchive {
  299.13 -namespace NLzma {
  299.14 - 
  299.15 -static bool CheckDictSize(const Byte *p)
  299.16 -{
  299.17 -  UInt32 dicSize = GetUi32(p);
  299.18 -  int i;
  299.19 -  for (i = 1; i <= 30; i++)
  299.20 -    if (dicSize == ((UInt32)2 << i) || dicSize == ((UInt32)3 << i))
  299.21 -      return true;
  299.22 -  return false;
  299.23 -}
  299.24 -
  299.25 -HRESULT ReadStreamHeader(ISequentialInStream *inStream, CHeader &block)
  299.26 -{
  299.27 -  Byte sig[5 + 9];
  299.28 -  RINOK(ReadStream_FALSE(inStream, sig, 5 + 8));
  299.29 -
  299.30 -  const Byte kMaxProp0Val = 5 * 5 * 9 - 1;
  299.31 -  if (sig[0] > kMaxProp0Val)
  299.32 -    return S_FALSE;
  299.33 -
  299.34 -  for (int i = 0; i < 5; i++)
  299.35 -    block.LzmaProps[i] = sig[i];
  299.36 -  
  299.37 -  block.IsThereFilter = false;
  299.38 -  block.FilterMethod = 0;
  299.39 -
  299.40 -  if (!CheckDictSize(sig + 1))
  299.41 -  {
  299.42 -    if (sig[0] > 1 || sig[1] > kMaxProp0Val)
  299.43 -      return S_FALSE;
  299.44 -    block.IsThereFilter = true;
  299.45 -    block.FilterMethod = sig[0];
  299.46 -    for (int i = 0; i < 5; i++)
  299.47 -      block.LzmaProps[i] = sig[i + 1];
  299.48 -    if (!CheckDictSize(block.LzmaProps + 1))
  299.49 -      return S_FALSE;
  299.50 -    RINOK(ReadStream_FALSE(inStream, sig + 5 + 8, 1));
  299.51 -  }
  299.52 -  UInt32 unpOffset = 5 + (block.IsThereFilter ? 1 : 0);
  299.53 -  block.UnpackSize = GetUi64(sig + unpOffset);
  299.54 -  if (block.HasUnpackSize() && block.UnpackSize >= ((UInt64)1 << 56))
  299.55 -    return S_FALSE;
  299.56 -  return S_OK;
  299.57 -}
  299.58 -
  299.59 -}}
   300.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaIn.h	Sat Mar 03 10:54:39 2012 -0600
   300.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   300.3 @@ -1,16 +0,0 @@
   300.4 -// Archive/LzmaIn.h
   300.5 -
   300.6 -#ifndef __ARCHIVE_LZMA_IN_H
   300.7 -#define __ARCHIVE_LZMA_IN_H
   300.8 -
   300.9 -#include "LzmaItem.h"
  300.10 -#include "../../IStream.h"
  300.11 -
  300.12 -namespace NArchive {
  300.13 -namespace NLzma {
  300.14 -
  300.15 -HRESULT ReadStreamHeader(ISequentialInStream *inStream, CHeader &st);
  300.16 -
  300.17 -}}
  300.18 -  
  300.19 -#endif
   301.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaItem.h	Sat Mar 03 10:54:39 2012 -0600
   301.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   301.3 @@ -1,27 +0,0 @@
   301.4 -// Archive/LzmaItem.h
   301.5 -
   301.6 -#ifndef __ARCHIVE_LZMA_ITEM_H
   301.7 -#define __ARCHIVE_LZMA_ITEM_H
   301.8 -
   301.9 -#include "Common/Types.h"
  301.10 -
  301.11 -#include "../../../../C/CpuArch.h"
  301.12 -
  301.13 -namespace NArchive {
  301.14 -namespace NLzma {
  301.15 -
  301.16 -struct CHeader
  301.17 -{
  301.18 -  UInt64 UnpackSize;
  301.19 -  bool IsThereFilter;
  301.20 -  Byte FilterMethod;
  301.21 -  Byte LzmaProps[5];
  301.22 -
  301.23 -  UInt32 GetDicSize() const { return GetUi32(LzmaProps + 1); }
  301.24 -  bool HasUnpackSize() const { return (UnpackSize != (UInt64)(Int64)-1);  }
  301.25 -  unsigned GetHeaderSize() const { return 5 + 8 + (IsThereFilter ? 1 : 0); }
  301.26 -};
  301.27 -
  301.28 -}}
  301.29 -
  301.30 -#endif
   302.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Lzma/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   302.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   302.3 @@ -1,8 +0,0 @@
   302.4 -// StdAfx.h
   302.5 -
   302.6 -#ifndef __STDAFX_H
   302.7 -#define __STDAFX_H
   302.8 -
   302.9 -#include "../../../Common/MyWindows.h"
  302.10 -
  302.11 -#endif
   303.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   303.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   303.3 @@ -1,835 +0,0 @@
   303.4 -// RarHandler.cpp
   303.5 -
   303.6 -#include "StdAfx.h"
   303.7 -
   303.8 -#include "Common/ComTry.h"
   303.9 -#include "Common/IntToString.h"
  303.10 -#include "Common/StringConvert.h"
  303.11 -
  303.12 -#include "Windows/PropVariant.h"
  303.13 -#include "Windows/Time.h"
  303.14 -
  303.15 -#include "../../IPassword.h"
  303.16 -
  303.17 -#include "../../Common/CreateCoder.h"
  303.18 -#include "../../Common/FilterCoder.h"
  303.19 -#include "../../Common/MethodId.h"
  303.20 -#include "../../Common/ProgressUtils.h"
  303.21 -
  303.22 -#include "../../Compress/CopyCoder.h"
  303.23 -
  303.24 -#include "../../Crypto/Rar20Crypto.h"
  303.25 -#include "../../Crypto/RarAes.h"
  303.26 -
  303.27 -#include "../Common/ItemNameUtils.h"
  303.28 -#include "../Common/OutStreamWithCRC.h"
  303.29 -
  303.30 -#include "RarHandler.h"
  303.31 -
  303.32 -using namespace NWindows;
  303.33 -using namespace NTime;
  303.34 -
  303.35 -namespace NArchive {
  303.36 -namespace NRar {
  303.37 -
  303.38 -static const wchar_t *kHostOS[] =
  303.39 -{
  303.40 -  L"MS DOS",
  303.41 -  L"OS/2",
  303.42 -  L"Win32",
  303.43 -  L"Unix",
  303.44 -  L"Mac OS",
  303.45 -  L"BeOS"
  303.46 -};
  303.47 -
  303.48 -static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
  303.49 -
  303.50 -static const wchar_t *kUnknownOS = L"Unknown";
  303.51 -
  303.52 -STATPROPSTG kProps[] =
  303.53 -{
  303.54 -  { NULL, kpidPath, VT_BSTR},
  303.55 -  { NULL, kpidIsDir, VT_BOOL},
  303.56 -  { NULL, kpidSize, VT_UI8},
  303.57 -  { NULL, kpidPackSize, VT_UI8},
  303.58 -  { NULL, kpidMTime, VT_FILETIME},
  303.59 -  { NULL, kpidCTime, VT_FILETIME},
  303.60 -  { NULL, kpidATime, VT_FILETIME},
  303.61 -  { NULL, kpidAttrib, VT_UI4},
  303.62 -
  303.63 -  { NULL, kpidEncrypted, VT_BOOL},
  303.64 -  { NULL, kpidSolid, VT_BOOL},
  303.65 -  { NULL, kpidCommented, VT_BOOL},
  303.66 -  { NULL, kpidSplitBefore, VT_BOOL},
  303.67 -  { NULL, kpidSplitAfter, VT_BOOL},
  303.68 -  { NULL, kpidCRC, VT_UI4},
  303.69 -  { NULL, kpidHostOS, VT_BSTR},
  303.70 -  { NULL, kpidMethod, VT_BSTR},
  303.71 -  { NULL, kpidUnpackVer, VT_UI1}
  303.72 -};
  303.73 -
  303.74 -STATPROPSTG kArcProps[] =
  303.75 -{
  303.76 -  { NULL, kpidSolid, VT_BOOL},
  303.77 -  { NULL, kpidNumBlocks, VT_UI4},
  303.78 -  // { NULL, kpidEncrypted, VT_BOOL},
  303.79 -  { NULL, kpidIsVolume, VT_BOOL},
  303.80 -  { NULL, kpidNumVolumes, VT_UI4},
  303.81 -  { NULL, kpidPhySize, VT_UI8}
  303.82 -  // { NULL, kpidCommented, VT_BOOL}
  303.83 -};
  303.84 -
  303.85 -IMP_IInArchive_Props
  303.86 -IMP_IInArchive_ArcProps
  303.87 -
  303.88 -UInt64 CHandler::GetPackSize(int refIndex) const
  303.89 -{
  303.90 -  const CRefItem &refItem = _refItems[refIndex];
  303.91 -  UInt64 totalPackSize = 0;
  303.92 -  for (int i = 0; i < refItem.NumItems; i++)
  303.93 -    totalPackSize += _items[refItem.ItemIndex + i].PackSize;
  303.94 -  return totalPackSize;
  303.95 -}
  303.96 -
  303.97 -STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
  303.98 -{
  303.99 -  // COM_TRY_BEGIN
 303.100 -  NWindows::NCOM::CPropVariant prop;
 303.101 -  switch(propID)
 303.102 -  {
 303.103 -    case kpidSolid: prop = _archiveInfo.IsSolid(); break;
 303.104 -    // case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break; // it's for encrypted names.
 303.105 -    case kpidIsVolume: prop = _archiveInfo.IsVolume(); break;
 303.106 -    case kpidNumVolumes: prop = (UInt32)_archives.Size(); break;
 303.107 -    case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break;
 303.108 -    // case kpidCommented: prop = _archiveInfo.IsCommented(); break;
 303.109 -    case kpidNumBlocks:
 303.110 -    {
 303.111 -      UInt32 numBlocks = 0;
 303.112 -      for (int i = 0; i < _refItems.Size(); i++)
 303.113 -        if (!IsSolid(i))
 303.114 -          numBlocks++;
 303.115 -      prop = (UInt32)numBlocks;
 303.116 -      break;
 303.117 -    }
 303.118 -  }
 303.119 -  prop.Detach(value);
 303.120 -  return S_OK;
 303.121 -  // COM_TRY_END
 303.122 -}
 303.123 -
 303.124 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
 303.125 -{
 303.126 -  *numItems = _refItems.Size();
 303.127 -  return S_OK;
 303.128 -}
 303.129 -
 303.130 -static bool RarTimeToFileTime(const CRarTime &rarTime, FILETIME &result)
 303.131 -{
 303.132 -  if (!DosTimeToFileTime(rarTime.DosTime, result))
 303.133 -    return false;
 303.134 -  UInt64 value =  (((UInt64)result.dwHighDateTime) << 32) + result.dwLowDateTime;
 303.135 -  value += (UInt64)rarTime.LowSecond * 10000000;
 303.136 -  value += ((UInt64)rarTime.SubTime[2] << 16) +
 303.137 -    ((UInt64)rarTime.SubTime[1] << 8) +
 303.138 -    ((UInt64)rarTime.SubTime[0]);
 303.139 -  result.dwLowDateTime = (DWORD)value;
 303.140 -  result.dwHighDateTime = DWORD(value >> 32);
 303.141 -  return true;
 303.142 -}
 303.143 -
 303.144 -static void RarTimeToProp(const CRarTime &rarTime, NWindows::NCOM::CPropVariant &prop)
 303.145 -{
 303.146 -  FILETIME localFileTime, utcFileTime;
 303.147 -  if (RarTimeToFileTime(rarTime, localFileTime))
 303.148 -  {
 303.149 -    if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
 303.150 -      utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 303.151 -  }
 303.152 -  else
 303.153 -    utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 303.154 -  prop = utcFileTime;
 303.155 -}
 303.156 -
 303.157 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
 303.158 -{
 303.159 -  COM_TRY_BEGIN
 303.160 -  NWindows::NCOM::CPropVariant prop;
 303.161 -  const CRefItem &refItem = _refItems[index];
 303.162 -  const CItemEx &item = _items[refItem.ItemIndex];
 303.163 -  switch(propID)
 303.164 -  {
 303.165 -    case kpidPath:
 303.166 -    {
 303.167 -      UString u;
 303.168 -      if (item.HasUnicodeName() && !item.UnicodeName.IsEmpty())
 303.169 -        u = item.UnicodeName;
 303.170 -      else
 303.171 -        u = MultiByteToUnicodeString(item.Name, CP_OEMCP);
 303.172 -      prop = (const wchar_t *)NItemName::WinNameToOSName(u);
 303.173 -      break;
 303.174 -    }
 303.175 -    case kpidIsDir: prop = item.IsDir(); break;
 303.176 -    case kpidSize: prop = item.Size; break;
 303.177 -    case kpidPackSize: prop = GetPackSize(index); break;
 303.178 -    case kpidMTime: RarTimeToProp(item.MTime, prop); break;
 303.179 -    case kpidCTime: if (item.CTimeDefined) RarTimeToProp(item.CTime, prop); break;
 303.180 -    case kpidATime: if (item.ATimeDefined) RarTimeToProp(item.ATime, prop); break;
 303.181 -    case kpidAttrib: prop = item.GetWinAttributes(); break;
 303.182 -    case kpidEncrypted: prop = item.IsEncrypted(); break;
 303.183 -    case kpidSolid: prop = IsSolid(index); break;
 303.184 -    case kpidCommented: prop = item.IsCommented(); break;
 303.185 -    case kpidSplitBefore: prop = item.IsSplitBefore(); break;
 303.186 -    case kpidSplitAfter: prop = _items[refItem.ItemIndex + refItem.NumItems - 1].IsSplitAfter(); break;
 303.187 -    case kpidCRC:
 303.188 -    {
 303.189 -      const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
 303.190 -      prop = ((lastItem.IsSplitAfter()) ? item.FileCRC : lastItem.FileCRC);
 303.191 -      break;
 303.192 -    }
 303.193 -    case kpidUnpackVer: prop = item.UnPackVersion; break;
 303.194 -    case kpidMethod:
 303.195 -    {
 303.196 -      UString method;
 303.197 -      if (item.Method >= Byte('0') && item.Method <= Byte('5'))
 303.198 -      {
 303.199 -        method = L"m";
 303.200 -        wchar_t temp[32];
 303.201 -        ConvertUInt64ToString(item.Method - Byte('0'), temp);
 303.202 -        method += temp;
 303.203 -        if (!item.IsDir())
 303.204 -        {
 303.205 -          method += L":";
 303.206 -          ConvertUInt64ToString(16 + item.GetDictSize(), temp);
 303.207 -          method += temp;
 303.208 -        }
 303.209 -      }
 303.210 -      else
 303.211 -      {
 303.212 -        wchar_t temp[32];
 303.213 -        ConvertUInt64ToString(item.Method, temp);
 303.214 -        method += temp;
 303.215 -      }
 303.216 -      prop = method;
 303.217 -      break;
 303.218 -    }
 303.219 -    case kpidHostOS: prop = (item.HostOS < kNumHostOSes) ? (kHostOS[item.HostOS]) : kUnknownOS; break;
 303.220 -  }
 303.221 -  prop.Detach(value);
 303.222 -  return S_OK;
 303.223 -  COM_TRY_END
 303.224 -}
 303.225 -
 303.226 -class CVolumeName
 303.227 -{
 303.228 -  bool _first;
 303.229 -  bool _newStyle;
 303.230 -  UString _unchangedPart;
 303.231 -  UString _changedPart;
 303.232 -  UString _afterPart;
 303.233 -public:
 303.234 -  CVolumeName(): _newStyle(true) {};
 303.235 -
 303.236 -  bool InitName(const UString &name, bool newStyle)
 303.237 -  {
 303.238 -    _first = true;
 303.239 -    _newStyle = newStyle;
 303.240 -    int dotPos = name.ReverseFind('.');
 303.241 -    UString basePart = name;
 303.242 -    if (dotPos >= 0)
 303.243 -    {
 303.244 -      UString ext = name.Mid(dotPos + 1);
 303.245 -      if (ext.CompareNoCase(L"rar") == 0)
 303.246 -      {
 303.247 -        _afterPart = name.Mid(dotPos);
 303.248 -        basePart = name.Left(dotPos);
 303.249 -      }
 303.250 -      else if (ext.CompareNoCase(L"exe") == 0)
 303.251 -      {
 303.252 -        _afterPart = L".rar";
 303.253 -        basePart = name.Left(dotPos);
 303.254 -      }
 303.255 -      else if (!_newStyle)
 303.256 -      {
 303.257 -        if (ext.CompareNoCase(L"000") == 0 || ext.CompareNoCase(L"001") == 0)
 303.258 -        {
 303.259 -          _afterPart.Empty();
 303.260 -          _first = false;
 303.261 -          _changedPart = ext;
 303.262 -          _unchangedPart = name.Left(dotPos + 1);
 303.263 -          return true;
 303.264 -        }
 303.265 -      }
 303.266 -    }
 303.267 -
 303.268 -    if (!_newStyle)
 303.269 -    {
 303.270 -      _afterPart.Empty();
 303.271 -      _unchangedPart = basePart + UString(L".");
 303.272 -      _changedPart = L"r00";
 303.273 -      return true;
 303.274 -    }
 303.275 -
 303.276 -    int numLetters = 1;
 303.277 -    if (basePart.Right(numLetters) == L"1" || basePart.Right(numLetters) == L"0")
 303.278 -    {
 303.279 -      while (numLetters < basePart.Length())
 303.280 -      {
 303.281 -        if (basePart[basePart.Length() - numLetters - 1] != '0')
 303.282 -          break;
 303.283 -        numLetters++;
 303.284 -      }
 303.285 -    }
 303.286 -    else
 303.287 -      return false;
 303.288 -    _unchangedPart = basePart.Left(basePart.Length() - numLetters);
 303.289 -    _changedPart = basePart.Right(numLetters);
 303.290 -    return true;
 303.291 -  }
 303.292 -
 303.293 -  UString GetNextName()
 303.294 -  {
 303.295 -    UString newName;
 303.296 -    if (_newStyle || !_first)
 303.297 -    {
 303.298 -      int i;
 303.299 -      int numLetters = _changedPart.Length();
 303.300 -      for (i = numLetters - 1; i >= 0; i--)
 303.301 -      {
 303.302 -        wchar_t c = _changedPart[i];
 303.303 -        if (c == L'9')
 303.304 -        {
 303.305 -          c = L'0';
 303.306 -          newName = c + newName;
 303.307 -          if (i == 0)
 303.308 -            newName = UString(L'1') + newName;
 303.309 -          continue;
 303.310 -        }
 303.311 -        c++;
 303.312 -        newName = UString(c) + newName;
 303.313 -        i--;
 303.314 -        for (; i >= 0; i--)
 303.315 -          newName = _changedPart[i] + newName;
 303.316 -        break;
 303.317 -      }
 303.318 -      _changedPart = newName;
 303.319 -    }
 303.320 -    _first = false;
 303.321 -    return _unchangedPart + _changedPart + _afterPart;
 303.322 -  }
 303.323 -};
 303.324 -
 303.325 -HRESULT CHandler::Open2(IInStream *stream,
 303.326 -    const UInt64 *maxCheckStartPosition,
 303.327 -    IArchiveOpenCallback *openArchiveCallback)
 303.328 -{
 303.329 -  {
 303.330 -    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
 303.331 -    CMyComPtr<ICryptoGetTextPassword> getTextPassword;
 303.332 -    CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
 303.333 -    
 303.334 -    CVolumeName seqName;
 303.335 -
 303.336 -    UInt64 totalBytes = 0;
 303.337 -    UInt64 curBytes = 0;
 303.338 -
 303.339 -    if (openArchiveCallback != NULL)
 303.340 -    {
 303.341 -      openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
 303.342 -      openArchiveCallbackWrap.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
 303.343 -    }
 303.344 -
 303.345 -    for (;;)
 303.346 -    {
 303.347 -      CMyComPtr<IInStream> inStream;
 303.348 -      if (!_archives.IsEmpty())
 303.349 -      {
 303.350 -        if (!openVolumeCallback)
 303.351 -          break;
 303.352 -        
 303.353 -        if(_archives.Size() == 1)
 303.354 -        {
 303.355 -          if (!_archiveInfo.IsVolume())
 303.356 -            break;
 303.357 -          UString baseName;
 303.358 -          {
 303.359 -            NCOM::CPropVariant prop;
 303.360 -            RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
 303.361 -            if (prop.vt != VT_BSTR)
 303.362 -              break;
 303.363 -            baseName = prop.bstrVal;
 303.364 -          }
 303.365 -          seqName.InitName(baseName, _archiveInfo.HaveNewVolumeName());
 303.366 -        }
 303.367 -
 303.368 -        UString fullName = seqName.GetNextName();
 303.369 -        HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
 303.370 -        if (result == S_FALSE)
 303.371 -          break;
 303.372 -        if (result != S_OK)
 303.373 -          return result;
 303.374 -        if (!stream)
 303.375 -          break;
 303.376 -      }
 303.377 -      else
 303.378 -        inStream = stream;
 303.379 -
 303.380 -      UInt64 endPos = 0;
 303.381 -      if (openArchiveCallback != NULL)
 303.382 -      {
 303.383 -        RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
 303.384 -        RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
 303.385 -        totalBytes += endPos;
 303.386 -        RINOK(openArchiveCallback->SetTotal(NULL, &totalBytes));
 303.387 -      }
 303.388 -      
 303.389 -      NArchive::NRar::CInArchive archive;
 303.390 -      RINOK(archive.Open(inStream, maxCheckStartPosition));
 303.391 -
 303.392 -      if (_archives.IsEmpty())
 303.393 -        archive.GetArchiveInfo(_archiveInfo);
 303.394 -     
 303.395 -      CItemEx item;
 303.396 -      for (;;)
 303.397 -      {
 303.398 -        HRESULT result = archive.GetNextItem(item, getTextPassword);
 303.399 -        if (result == S_FALSE)
 303.400 -          break;
 303.401 -        RINOK(result);
 303.402 -        if (item.IgnoreItem())
 303.403 -          continue;
 303.404 -
 303.405 -        bool needAdd = true;
 303.406 -        if (item.IsSplitBefore())
 303.407 -        {
 303.408 -          if (!_refItems.IsEmpty())
 303.409 -          {
 303.410 -            CRefItem &refItem = _refItems.Back();
 303.411 -            refItem.NumItems++;
 303.412 -            needAdd = false;
 303.413 -          }
 303.414 -        }
 303.415 -        if (needAdd)
 303.416 -        {
 303.417 -          CRefItem refItem;
 303.418 -          refItem.ItemIndex = _items.Size();
 303.419 -          refItem.NumItems = 1;
 303.420 -          refItem.VolumeIndex = _archives.Size();
 303.421 -          _refItems.Add(refItem);
 303.422 -        }
 303.423 -        _items.Add(item);
 303.424 -        if (openArchiveCallback != NULL && _items.Size() % 100 == 0)
 303.425 -        {
 303.426 -          UInt64 numFiles = _items.Size();
 303.427 -          UInt64 numBytes = curBytes + item.Position;
 303.428 -          RINOK(openArchiveCallback->SetCompleted(&numFiles, &numBytes));
 303.429 -        }
 303.430 -      }
 303.431 -      curBytes += endPos;
 303.432 -      _archives.Add(archive);
 303.433 -    }
 303.434 -  }
 303.435 -  return S_OK;
 303.436 -}
 303.437 -
 303.438 -STDMETHODIMP CHandler::Open(IInStream *stream,
 303.439 -    const UInt64 *maxCheckStartPosition,
 303.440 -    IArchiveOpenCallback *openArchiveCallback)
 303.441 -{
 303.442 -  COM_TRY_BEGIN
 303.443 -  Close();
 303.444 -  try
 303.445 -  {
 303.446 -    HRESULT res = Open2(stream, maxCheckStartPosition, openArchiveCallback);
 303.447 -    if (res != S_OK)
 303.448 -      Close();
 303.449 -    return res;
 303.450 -  }
 303.451 -  catch(const CInArchiveException &) { Close(); return S_FALSE; }
 303.452 -  catch(...) { Close(); throw; }
 303.453 -  COM_TRY_END
 303.454 -}
 303.455 -
 303.456 -STDMETHODIMP CHandler::Close()
 303.457 -{
 303.458 -  COM_TRY_BEGIN
 303.459 -  _refItems.Clear();
 303.460 -  _items.Clear();
 303.461 -  _archives.Clear();
 303.462 -  return S_OK;
 303.463 -  COM_TRY_END
 303.464 -}
 303.465 -
 303.466 -struct CMethodItem
 303.467 -{
 303.468 -  Byte RarUnPackVersion;
 303.469 -  CMyComPtr<ICompressCoder> Coder;
 303.470 -};
 303.471 -
 303.472 -
 303.473 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 303.474 -    Int32 _aTestMode, IArchiveExtractCallback *_anExtractCallback)
 303.475 -{
 303.476 -  COM_TRY_BEGIN
 303.477 -  CMyComPtr<ICryptoGetTextPassword> getTextPassword;
 303.478 -  bool testMode = (_aTestMode != 0);
 303.479 -  CMyComPtr<IArchiveExtractCallback> extractCallback = _anExtractCallback;
 303.480 -  UInt64 censoredTotalUnPacked = 0,
 303.481 -        // censoredTotalPacked = 0,
 303.482 -        importantTotalUnPacked = 0;
 303.483 -        // importantTotalPacked = 0;
 303.484 -  bool allFilesMode = (numItems == UInt32(-1));
 303.485 -  if (allFilesMode)
 303.486 -    numItems = _refItems.Size();
 303.487 -  if(numItems == 0)
 303.488 -    return S_OK;
 303.489 -  int lastIndex = 0;
 303.490 -  CRecordVector<int> importantIndexes;
 303.491 -  CRecordVector<bool> extractStatuses;
 303.492 -
 303.493 -  for(UInt32 t = 0; t < numItems; t++)
 303.494 -  {
 303.495 -    int index = allFilesMode ? t : indices[t];
 303.496 -    const CRefItem &refItem = _refItems[index];
 303.497 -    const CItemEx &item = _items[refItem.ItemIndex];
 303.498 -    censoredTotalUnPacked += item.Size;
 303.499 -    // censoredTotalPacked += item.PackSize;
 303.500 -    int j;
 303.501 -    for(j = lastIndex; j <= index; j++)
 303.502 -      // if(!_items[_refItems[j].ItemIndex].IsSolid())
 303.503 -      if(!IsSolid(j))
 303.504 -        lastIndex = j;
 303.505 -    for(j = lastIndex; j <= index; j++)
 303.506 -    {
 303.507 -      const CRefItem &refItem = _refItems[j];
 303.508 -      const CItemEx &item = _items[refItem.ItemIndex];
 303.509 -
 303.510 -      // const CItemEx &item = _items[j];
 303.511 -
 303.512 -      importantTotalUnPacked += item.Size;
 303.513 -      // importantTotalPacked += item.PackSize;
 303.514 -      importantIndexes.Add(j);
 303.515 -      extractStatuses.Add(j == index);
 303.516 -    }
 303.517 -    lastIndex = index + 1;
 303.518 -  }
 303.519 -
 303.520 -  extractCallback->SetTotal(importantTotalUnPacked);
 303.521 -  UInt64 currentImportantTotalUnPacked = 0;
 303.522 -  UInt64 currentImportantTotalPacked = 0;
 303.523 -  UInt64 currentUnPackSize, currentPackSize;
 303.524 -
 303.525 -  CObjectVector<CMethodItem> methodItems;
 303.526 -
 303.527 -  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
 303.528 -  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
 303.529 -
 303.530 -  CFilterCoder *filterStreamSpec = new CFilterCoder;
 303.531 -  CMyComPtr<ISequentialInStream> filterStream = filterStreamSpec;
 303.532 -
 303.533 -  NCrypto::NRar20::CDecoder *rar20CryptoDecoderSpec = NULL;
 303.534 -  CMyComPtr<ICompressFilter> rar20CryptoDecoder;
 303.535 -  NCrypto::NRar29::CDecoder *rar29CryptoDecoderSpec = NULL;
 303.536 -  CMyComPtr<ICompressFilter> rar29CryptoDecoder;
 303.537 -
 303.538 -  CFolderInStream *folderInStreamSpec = NULL;
 303.539 -  CMyComPtr<ISequentialInStream> folderInStream;
 303.540 -
 303.541 -  CLocalProgress *lps = new CLocalProgress;
 303.542 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 303.543 -  lps->Init(extractCallback, false);
 303.544 -
 303.545 -  bool solidStart = true;
 303.546 -  for(int i = 0; i < importantIndexes.Size(); i++,
 303.547 -      currentImportantTotalUnPacked += currentUnPackSize,
 303.548 -      currentImportantTotalPacked += currentPackSize)
 303.549 -  {
 303.550 -    lps->InSize = currentImportantTotalPacked;
 303.551 -    lps->OutSize = currentImportantTotalUnPacked;
 303.552 -    RINOK(lps->SetCur());
 303.553 -    CMyComPtr<ISequentialOutStream> realOutStream;
 303.554 -
 303.555 -    Int32 askMode;
 303.556 -    if(extractStatuses[i])
 303.557 -      askMode = testMode ?
 303.558 -          NArchive::NExtract::NAskMode::kTest :
 303.559 -          NArchive::NExtract::NAskMode::kExtract;
 303.560 -    else
 303.561 -      askMode = NArchive::NExtract::NAskMode::kSkip;
 303.562 -
 303.563 -    UInt32 index = importantIndexes[i];
 303.564 -
 303.565 -    const CRefItem &refItem = _refItems[index];
 303.566 -    const CItemEx &item = _items[refItem.ItemIndex];
 303.567 -
 303.568 -    currentUnPackSize = item.Size;
 303.569 -
 303.570 -    currentPackSize = GetPackSize(index);
 303.571 -
 303.572 -    if(item.IgnoreItem())
 303.573 -      continue;
 303.574 -
 303.575 -    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
 303.576 -
 303.577 -    if (!IsSolid(index))
 303.578 -      solidStart = true;
 303.579 -    if(item.IsDir())
 303.580 -    {
 303.581 -      RINOK(extractCallback->PrepareOperation(askMode));
 303.582 -      RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
 303.583 -      continue;
 303.584 -    }
 303.585 -
 303.586 -    bool mustBeProcessedAnywhere = false;
 303.587 -    if(i < importantIndexes.Size() - 1)
 303.588 -    {
 303.589 -      // const CRefItem &nextRefItem = _refItems[importantIndexes[i + 1]];
 303.590 -      // const CItemEx &nextItemInfo = _items[nextRefItem.ItemIndex];
 303.591 -      // mustBeProcessedAnywhere = nextItemInfo.IsSolid();
 303.592 -      mustBeProcessedAnywhere = IsSolid(importantIndexes[i + 1]);
 303.593 -    }
 303.594 -    
 303.595 -    if (!mustBeProcessedAnywhere && !testMode && !realOutStream)
 303.596 -      continue;
 303.597 -    
 303.598 -    if (!realOutStream && !testMode)
 303.599 -      askMode = NArchive::NExtract::NAskMode::kSkip;
 303.600 -
 303.601 -    RINOK(extractCallback->PrepareOperation(askMode));
 303.602 -
 303.603 -    COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
 303.604 -    CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 303.605 -    outStreamSpec->SetStream(realOutStream);
 303.606 -    outStreamSpec->Init();
 303.607 -    realOutStream.Release();
 303.608 -    
 303.609 -    /*
 303.610 -    for (int partIndex = 0; partIndex < 1; partIndex++)
 303.611 -    {
 303.612 -    CMyComPtr<ISequentialInStream> inStream;
 303.613 -
 303.614 -    // item redefinition
 303.615 -    const CItemEx &item = _items[refItem.ItemIndex + partIndex];
 303.616 -
 303.617 -    NArchive::NRar::CInArchive &archive = _archives[refItem.VolumeIndex + partIndex];
 303.618 -
 303.619 -    inStream.Attach(archive.CreateLimitedStream(item.GetDataPosition(),
 303.620 -      item.PackSize));
 303.621 -    */
 303.622 -    if (!folderInStream)
 303.623 -    {
 303.624 -      folderInStreamSpec = new CFolderInStream;
 303.625 -      folderInStream = folderInStreamSpec;
 303.626 -    }
 303.627 -
 303.628 -    folderInStreamSpec->Init(&_archives, &_items, refItem);
 303.629 -
 303.630 -    UInt64 packSize = currentPackSize;
 303.631 -
 303.632 -    // packedPos += item.PackSize;
 303.633 -    // unpackedPos += 0;
 303.634 -    
 303.635 -    CMyComPtr<ISequentialInStream> inStream;
 303.636 -    if (item.IsEncrypted())
 303.637 -    {
 303.638 -      CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
 303.639 -      if (item.UnPackVersion >= 29)
 303.640 -      {
 303.641 -        if (!rar29CryptoDecoder)
 303.642 -        {
 303.643 -          rar29CryptoDecoderSpec = new NCrypto::NRar29::CDecoder;
 303.644 -          rar29CryptoDecoder = rar29CryptoDecoderSpec;
 303.645 -          // RINOK(rar29CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar29Decoder));
 303.646 -        }
 303.647 -        rar29CryptoDecoderSpec->SetRar350Mode(item.UnPackVersion < 36);
 303.648 -        CMyComPtr<ICompressSetDecoderProperties2> cryptoProperties;
 303.649 -        RINOK(rar29CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
 303.650 -            &cryptoProperties));
 303.651 -        RINOK(cryptoProperties->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0));
 303.652 -        filterStreamSpec->Filter = rar29CryptoDecoder;
 303.653 -      }
 303.654 -      else if (item.UnPackVersion >= 20)
 303.655 -      {
 303.656 -        if (!rar20CryptoDecoder)
 303.657 -        {
 303.658 -          rar20CryptoDecoderSpec = new NCrypto::NRar20::CDecoder;
 303.659 -          rar20CryptoDecoder = rar20CryptoDecoderSpec;
 303.660 -          // RINOK(rar20CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar20Decoder));
 303.661 -        }
 303.662 -        filterStreamSpec->Filter = rar20CryptoDecoder;
 303.663 -      }
 303.664 -      else
 303.665 -      {
 303.666 -        outStream.Release();
 303.667 -        RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 303.668 -        continue;
 303.669 -      }
 303.670 -      RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword,
 303.671 -          &cryptoSetPassword));
 303.672 -
 303.673 -      if (!getTextPassword)
 303.674 -        extractCallback.QueryInterface(IID_ICryptoGetTextPassword,
 303.675 -          &getTextPassword);
 303.676 -      if (getTextPassword)
 303.677 -      {
 303.678 -        CMyComBSTR password;
 303.679 -        RINOK(getTextPassword->CryptoGetTextPassword(&password));
 303.680 -        if (item.UnPackVersion >= 29)
 303.681 -        {
 303.682 -          CByteBuffer buffer;
 303.683 -          UString unicodePassword(password);
 303.684 -          const UInt32 sizeInBytes = unicodePassword.Length() * 2;
 303.685 -          buffer.SetCapacity(sizeInBytes);
 303.686 -          for (int i = 0; i < unicodePassword.Length(); i++)
 303.687 -          {
 303.688 -            wchar_t c = unicodePassword[i];
 303.689 -            ((Byte *)buffer)[i * 2] = (Byte)c;
 303.690 -            ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
 303.691 -          }
 303.692 -          RINOK(cryptoSetPassword->CryptoSetPassword(
 303.693 -            (const Byte *)buffer, sizeInBytes));
 303.694 -        }
 303.695 -        else
 303.696 -        {
 303.697 -          AString oemPassword = UnicodeStringToMultiByte(
 303.698 -            (const wchar_t *)password, CP_OEMCP);
 303.699 -          RINOK(cryptoSetPassword->CryptoSetPassword(
 303.700 -            (const Byte *)(const char *)oemPassword, oemPassword.Length()));
 303.701 -        }
 303.702 -      }
 303.703 -      else
 303.704 -      {
 303.705 -        RINOK(cryptoSetPassword->CryptoSetPassword(0, 0));
 303.706 -      }
 303.707 -      filterStreamSpec->SetInStream(folderInStream);
 303.708 -      inStream = filterStream;
 303.709 -    }
 303.710 -    else
 303.711 -    {
 303.712 -      inStream = folderInStream;
 303.713 -    }
 303.714 -    CMyComPtr<ICompressCoder> commonCoder;
 303.715 -    switch(item.Method)
 303.716 -    {
 303.717 -      case '0':
 303.718 -      {
 303.719 -        commonCoder = copyCoder;
 303.720 -        break;
 303.721 -      }
 303.722 -      case '1':
 303.723 -      case '2':
 303.724 -      case '3':
 303.725 -      case '4':
 303.726 -      case '5':
 303.727 -      {
 303.728 -        /*
 303.729 -        if (item.UnPackVersion >= 29)
 303.730 -        {
 303.731 -          outStream.Release();
 303.732 -          RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 303.733 -          continue;
 303.734 -        }
 303.735 -        */
 303.736 -        int m;
 303.737 -        for (m = 0; m < methodItems.Size(); m++)
 303.738 -          if (methodItems[m].RarUnPackVersion == item.UnPackVersion)
 303.739 -            break;
 303.740 -        if (m == methodItems.Size())
 303.741 -        {
 303.742 -          CMethodItem mi;
 303.743 -          mi.RarUnPackVersion = item.UnPackVersion;
 303.744 -
 303.745 -          mi.Coder.Release();
 303.746 -          if (item.UnPackVersion <= 30)
 303.747 -          {
 303.748 -            UInt32 methodID = 0x040300;
 303.749 -            if (item.UnPackVersion < 20)
 303.750 -              methodID += 1;
 303.751 -            else if (item.UnPackVersion < 29)
 303.752 -              methodID += 2;
 303.753 -            else
 303.754 -              methodID += 3;
 303.755 -            RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, mi.Coder, false));
 303.756 -          }
 303.757 -         
 303.758 -          if (mi.Coder == 0)
 303.759 -          {
 303.760 -            outStream.Release();
 303.761 -            RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 303.762 -            continue;
 303.763 -          }
 303.764 -
 303.765 -          m = methodItems.Add(mi);
 303.766 -        }
 303.767 -        CMyComPtr<ICompressCoder> decoder = methodItems[m].Coder;
 303.768 -
 303.769 -        CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
 303.770 -        RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
 303.771 -            &compressSetDecoderProperties));
 303.772 -        
 303.773 -        Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0);
 303.774 -        if (solidStart)
 303.775 -        {
 303.776 -          isSolid = false;
 303.777 -          solidStart = false;
 303.778 -        }
 303.779 -
 303.780 -
 303.781 -        RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1));
 303.782 -          
 303.783 -        commonCoder = decoder;
 303.784 -        break;
 303.785 -      }
 303.786 -      default:
 303.787 -        outStream.Release();
 303.788 -        RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 303.789 -        continue;
 303.790 -    }
 303.791 -    HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.Size, progress);
 303.792 -    if (item.IsEncrypted())
 303.793 -      filterStreamSpec->ReleaseInStream();
 303.794 -    if (result == S_FALSE)
 303.795 -    {
 303.796 -      outStream.Release();
 303.797 -      RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError));
 303.798 -      continue;
 303.799 -    }
 303.800 -    if (result != S_OK)
 303.801 -      return result;
 303.802 -
 303.803 -    /*
 303.804 -    if (refItem.NumItems == 1 &&
 303.805 -        !item.IsSplitBefore() && !item.IsSplitAfter())
 303.806 -    */
 303.807 -    {
 303.808 -      const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
 303.809 -      bool crcOK = outStreamSpec->GetCRC() == lastItem.FileCRC;
 303.810 -      outStream.Release();
 303.811 -      RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK:
 303.812 -          NArchive::NExtract::NOperationResult::kCRCError));
 303.813 -    }
 303.814 -    /*
 303.815 -    else
 303.816 -    {
 303.817 -      bool crcOK = true;
 303.818 -      for (int partIndex = 0; partIndex < refItem.NumItems; partIndex++)
 303.819 -      {
 303.820 -        const CItemEx &item = _items[refItem.ItemIndex + partIndex];
 303.821 -        if (item.FileCRC != folderInStreamSpec->CRCs[partIndex])
 303.822 -        {
 303.823 -          crcOK = false;
 303.824 -          break;
 303.825 -        }
 303.826 -      }
 303.827 -      RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK:
 303.828 -          NArchive::NExtract::NOperationResult::kCRCError));
 303.829 -    }
 303.830 -    */
 303.831 -  }
 303.832 -  return S_OK;
 303.833 -  COM_TRY_END
 303.834 -}
 303.835 -
 303.836 -IMPL_ISetCompressCodecsInfo
 303.837 -
 303.838 -}}
   304.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHandler.h	Sat Mar 03 10:54:39 2012 -0600
   304.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   304.3 @@ -1,60 +0,0 @@
   304.4 -// Rar/Handler.h
   304.5 -
   304.6 -#ifndef __RAR_HANDLER_H
   304.7 -#define __RAR_HANDLER_H
   304.8 -
   304.9 -#include "../IArchive.h"
  304.10 -#include "RarIn.h"
  304.11 -#include "RarVolumeInStream.h"
  304.12 -
  304.13 -#include "../../Common/CreateCoder.h"
  304.14 -
  304.15 -namespace NArchive {
  304.16 -namespace NRar {
  304.17 -
  304.18 -class CHandler:
  304.19 -  public IInArchive,
  304.20 -  PUBLIC_ISetCompressCodecsInfo
  304.21 -  public CMyUnknownImp
  304.22 -{
  304.23 -public:
  304.24 -  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  304.25 -  QUERY_ENTRY_ISetCompressCodecsInfo
  304.26 -  MY_QUERYINTERFACE_END
  304.27 -  MY_ADDREF_RELEASE
  304.28 -  
  304.29 -  INTERFACE_IInArchive(;)
  304.30 -
  304.31 -  DECL_ISetCompressCodecsInfo
  304.32 -
  304.33 -private:
  304.34 -  CRecordVector<CRefItem> _refItems;
  304.35 -  CObjectVector<CItemEx> _items;
  304.36 -  CObjectVector<CInArchive> _archives;
  304.37 -  NArchive::NRar::CInArchiveInfo _archiveInfo;
  304.38 -
  304.39 -  DECL_EXTERNAL_CODECS_VARS
  304.40 -
  304.41 -  UInt64 GetPackSize(int refIndex) const;
  304.42 -  // NArchive::NRar::CInArchive _archive;
  304.43 -
  304.44 -  bool IsSolid(int refIndex)
  304.45 -  {
  304.46 -    const CItemEx &item = _items[_refItems[refIndex].ItemIndex];
  304.47 -    if (item.UnPackVersion < 20)
  304.48 -    {
  304.49 -      if (_archiveInfo.IsSolid())
  304.50 -        return (refIndex > 0);
  304.51 -      return false;
  304.52 -    }
  304.53 -    return item.IsSolid();
  304.54 -  }
  304.55 -
  304.56 -  HRESULT Open2(IInStream *stream,
  304.57 -      const UInt64 *maxCheckStartPosition,
  304.58 -      IArchiveOpenCallback *openArchiveCallback);
  304.59 -};
  304.60 -
  304.61 -}}
  304.62 -
  304.63 -#endif
   305.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.cpp	Sat Mar 03 10:54:39 2012 -0600
   305.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   305.3 @@ -1,19 +0,0 @@
   305.4 -// Archive/Rar/Headers.cpp
   305.5 -
   305.6 -#include "StdAfx.h"
   305.7 -
   305.8 -#include "RarHeader.h"
   305.9 -
  305.10 -namespace NArchive{
  305.11 -namespace NRar{
  305.12 -namespace NHeader{
  305.13 -
  305.14 -Byte kMarker[kMarkerSize] = {0x52 + 1, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00};
  305.15 -  
  305.16 -class CMarkerInitializer
  305.17 -{
  305.18 -public:
  305.19 -  CMarkerInitializer() { kMarker[0]--; };
  305.20 -} g_MarkerInitializer;
  305.21 -
  305.22 -}}}
   306.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.h	Sat Mar 03 10:54:39 2012 -0600
   306.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   306.3 @@ -1,224 +0,0 @@
   306.4 -// Archive/RarHeader.h
   306.5 -
   306.6 -#ifndef __ARCHIVE_RAR_HEADER_H
   306.7 -#define __ARCHIVE_RAR_HEADER_H
   306.8 -
   306.9 -#include "Common/Types.h"
  306.10 -
  306.11 -namespace NArchive{
  306.12 -namespace NRar{
  306.13 -namespace NHeader{
  306.14 -
  306.15 -const int kMarkerSize = 7;
  306.16 -extern Byte kMarker[kMarkerSize];
  306.17 -  
  306.18 -const int kArchiveSolid = 0x1;
  306.19 -
  306.20 -namespace NBlockType
  306.21 -{
  306.22 -  enum EBlockType
  306.23 -  {
  306.24 -    kMarker        = 0x72,
  306.25 -    kArchiveHeader = 0x73,
  306.26 -    kFileHeader    = 0x74,
  306.27 -    kCommentHeader = 0x75,
  306.28 -    kOldAuthenticity = 0x76,
  306.29 -    kSubBlock       = 0x77,
  306.30 -    kRecoveryRecord = 0x78,
  306.31 -    kAuthenticity   = 0x79,
  306.32 -
  306.33 -    kEndOfArchive   = 0x7B // Is not safe
  306.34 -  };
  306.35 -}
  306.36 -
  306.37 -namespace NArchive
  306.38 -{
  306.39 -  const UInt16 kVolume  = 1;
  306.40 -  const UInt16 kComment = 2;
  306.41 -  const UInt16 kLock    = 4;
  306.42 -  const UInt16 kSolid   = 8;
  306.43 -  const UInt16 kNewVolName = 0x10; // ('volname.partN.rar')
  306.44 -  const UInt16 kAuthenticity  = 0x20;
  306.45 -  const UInt16 kRecovery = 0x40;
  306.46 -  const UInt16 kBlockEncryption  = 0x80;
  306.47 -  const UInt16 kFirstVolume = 0x100; // (set only by RAR 3.0 and later)
  306.48 -  const UInt16 kEncryptVer = 0x200; // RAR 3.6 there is EncryptVer Byte in End of MainHeader
  306.49 -  
  306.50 -  const int kHeaderSizeMin = 7;
  306.51 -
  306.52 -  struct CBlock
  306.53 -  {
  306.54 -    UInt16 CRC;
  306.55 -    Byte Type;
  306.56 -    UInt16 Flags;
  306.57 -    UInt16 Size;
  306.58 -    UInt16 Reserved1;
  306.59 -    UInt32 Reserved2;
  306.60 -    // UInt16 GetRealCRC() const;
  306.61 -  };
  306.62 -  
  306.63 -  const int kArchiveHeaderSize = 13;
  306.64 -
  306.65 -  const int kBlockHeadersAreEncrypted = 0x80;
  306.66 -
  306.67 -  struct CHeader360: public CBlock
  306.68 -  {
  306.69 -    Byte EncryptVersion;
  306.70 -    bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
  306.71 -    bool IsThereEncryptVer() const { return (Flags & NHeader::NArchive::kEncryptVer) != 0; }
  306.72 -    bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
  306.73 -    UInt32 GetBaseSize() const { return kArchiveHeaderSize + (IsEncryptOld() ? 0 : 1); }
  306.74 -  };
  306.75 -}
  306.76 -
  306.77 -namespace NFile
  306.78 -{
  306.79 -  const int kSplitBefore = 1 << 0;
  306.80 -  const int kSplitAfter  = 1 << 1;
  306.81 -  const int kEncrypted   = 1 << 2;
  306.82 -  const int kComment     = 1 << 3;
  306.83 -  const int kSolid       = 1 << 4;
  306.84 -  
  306.85 -  const int kDictBitStart     = 5;
  306.86 -  const int kNumDictBits  = 3;
  306.87 -  const int kDictMask         = (1 << kNumDictBits) - 1;
  306.88 -  const int kDictDirectoryValue  = 0x7;
  306.89 -  
  306.90 -  const int kSize64Bits    = 1 << 8;
  306.91 -  const int kUnicodeName   = 1 << 9;
  306.92 -  const int kSalt          = 1 << 10;
  306.93 -  const int kOldVersion    = 1 << 11;
  306.94 -  const int kExtTime       = 1 << 12;
  306.95 -  // const int kExtFlags      = 1 << 13;
  306.96 -  // const int kSkipIfUnknown = 1 << 14;
  306.97 -
  306.98 -  const int kLongBlock    = 1 << 15;
  306.99 -  
 306.100 -  /*
 306.101 -  struct CBlock
 306.102 -  {
 306.103 -    // UInt16 HeadCRC;
 306.104 -    // Byte Type;
 306.105 -    // UInt16 Flags;
 306.106 -    // UInt16 HeadSize;
 306.107 -    UInt32 PackSize;
 306.108 -    UInt32 UnPackSize;
 306.109 -    Byte HostOS;
 306.110 -    UInt32 FileCRC;
 306.111 -    UInt32 Time;
 306.112 -    Byte UnPackVersion;
 306.113 -    Byte Method;
 306.114 -    UInt16 NameSize;
 306.115 -    UInt32 Attributes;
 306.116 -  };
 306.117 -  */
 306.118 -
 306.119 -  /*
 306.120 -  struct CBlock32
 306.121 -  {
 306.122 -    UInt16 HeadCRC;
 306.123 -    Byte Type;
 306.124 -    UInt16 Flags;
 306.125 -    UInt16 HeadSize;
 306.126 -    UInt32 PackSize;
 306.127 -    UInt32 UnPackSize;
 306.128 -    Byte HostOS;
 306.129 -    UInt32 FileCRC;
 306.130 -    UInt32 Time;
 306.131 -    Byte UnPackVersion;
 306.132 -    Byte Method;
 306.133 -    UInt16 NameSize;
 306.134 -    UInt32 Attributes;
 306.135 -    UInt16 GetRealCRC(const void *aName, UInt32 aNameSize,
 306.136 -        bool anExtraDataDefined = false, Byte *anExtraData = 0) const;
 306.137 -  };
 306.138 -  struct CBlock64
 306.139 -  {
 306.140 -    UInt16 HeadCRC;
 306.141 -    Byte Type;
 306.142 -    UInt16 Flags;
 306.143 -    UInt16 HeadSize;
 306.144 -    UInt32 PackSizeLow;
 306.145 -    UInt32 UnPackSizeLow;
 306.146 -    Byte HostOS;
 306.147 -    UInt32 FileCRC;
 306.148 -    UInt32 Time;
 306.149 -    Byte UnPackVersion;
 306.150 -    Byte Method;
 306.151 -    UInt16 NameSize;
 306.152 -    UInt32 Attributes;
 306.153 -    UInt32 PackSizeHigh;
 306.154 -    UInt32 UnPackSizeHigh;
 306.155 -    UInt16 GetRealCRC(const void *aName, UInt32 aNameSize) const;
 306.156 -  };
 306.157 -  */
 306.158 -  
 306.159 -  const int kLabelFileAttribute            = 0x08;
 306.160 -  const int kWinFileDirectoryAttributeMask = 0x10;
 306.161 -  
 306.162 -  enum CHostOS
 306.163 -  {
 306.164 -    kHostMSDOS = 0,
 306.165 -      kHostOS2   = 1,
 306.166 -      kHostWin32 = 2,
 306.167 -      kHostUnix  = 3,
 306.168 -      kHostMacOS = 4,
 306.169 -      kHostBeOS = 5
 306.170 -  };
 306.171 -}
 306.172 -
 306.173 -namespace NBlock
 306.174 -{
 306.175 -  const UInt16 kLongBlock = 1 << 15;
 306.176 -  struct CBlock
 306.177 -  {
 306.178 -    UInt16 CRC;
 306.179 -    Byte Type;
 306.180 -    UInt16 Flags;
 306.181 -    UInt16 HeadSize;
 306.182 -    //  UInt32 DataSize;
 306.183 -  };
 306.184 -}
 306.185 -
 306.186 -/*
 306.187 -struct CSubBlock
 306.188 -{
 306.189 -  UInt16 HeadCRC;
 306.190 -  Byte HeadType;
 306.191 -  UInt16 Flags;
 306.192 -  UInt16 HeadSize;
 306.193 -  UInt32 DataSize;
 306.194 -  UInt16 SubType;
 306.195 -  Byte Level; // Reserved : Must be 0
 306.196 -};
 306.197 -
 306.198 -struct CCommentBlock
 306.199 -{
 306.200 -  UInt16 HeadCRC;
 306.201 -  Byte HeadType;
 306.202 -  UInt16 Flags;
 306.203 -  UInt16 HeadSize;
 306.204 -  UInt16 UnpSize;
 306.205 -  Byte UnpVer;
 306.206 -  Byte Method;
 306.207 -  UInt16 CommCRC;
 306.208 -};
 306.209 -
 306.210 -
 306.211 -struct CProtectHeader
 306.212 -{
 306.213 -  UInt16 HeadCRC;
 306.214 -  Byte HeadType;
 306.215 -  UInt16 Flags;
 306.216 -  UInt16 HeadSize;
 306.217 -  UInt32 DataSize;
 306.218 -  Byte Version;
 306.219 -  UInt16 RecSectors;
 306.220 -  UInt32 TotalBlocks;
 306.221 -  Byte Mark[8];
 306.222 -};
 306.223 -*/
 306.224 -
 306.225 -}}}
 306.226 -
 306.227 -#endif
   307.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   307.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   307.3 @@ -1,513 +0,0 @@
   307.4 -// Archive/RarIn.cpp
   307.5 -
   307.6 -#include "StdAfx.h"
   307.7 -
   307.8 -#include "Common/StringConvert.h"
   307.9 -#include "Common/UTFConvert.h"
  307.10 -
  307.11 -#include "RarIn.h"
  307.12 -#include "../../Common/LimitedStreams.h"
  307.13 -#include "../../Common/StreamUtils.h"
  307.14 -
  307.15 -#include "../Common/FindSignature.h"
  307.16 -
  307.17 -extern "C"
  307.18 -{
  307.19 -  #include "../../../../C/7zCrc.h"
  307.20 -}
  307.21 -
  307.22 -namespace NArchive {
  307.23 -namespace NRar {
  307.24 - 
  307.25 -void CInArchive::ThrowExceptionWithCode(
  307.26 -    CInArchiveException::CCauseType cause)
  307.27 -{
  307.28 -  throw CInArchiveException(cause);
  307.29 -}
  307.30 -
  307.31 -HRESULT CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
  307.32 -{
  307.33 -  try
  307.34 -  {
  307.35 -    Close();
  307.36 -    HRESULT res = Open2(inStream, searchHeaderSizeLimit);
  307.37 -    if (res == S_OK)
  307.38 -      return res;
  307.39 -    Close();
  307.40 -    return res;
  307.41 -  }
  307.42 -  catch(...) { Close(); throw; }
  307.43 -}
  307.44 -
  307.45 -void CInArchive::Close()
  307.46 -{
  307.47 -  m_Stream.Release();
  307.48 -}
  307.49 -
  307.50 -
  307.51 -static inline bool TestMarkerCandidate(const void *aTestBytes)
  307.52 -{
  307.53 -  for (UInt32 i = 0; i < NHeader::kMarkerSize; i++)
  307.54 -    if (((const Byte *)aTestBytes)[i] != NHeader::kMarker[i])
  307.55 -      return false;
  307.56 -  return true;
  307.57 -}
  307.58 -
  307.59 -HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
  307.60 -{
  307.61 -  RINOK(FindSignatureInStream(stream,
  307.62 -      NHeader::kMarker, NHeader::kMarkerSize,
  307.63 -      searchHeaderSizeLimit, m_ArchiveStartPosition));
  307.64 -  m_Stream = stream;
  307.65 -  m_Position = m_ArchiveStartPosition + NHeader::kMarkerSize;
  307.66 -  return m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
  307.67 -}
  307.68 -
  307.69 -void CInArchive::ThrowUnexpectedEndOfArchiveException()
  307.70 -{
  307.71 -  ThrowExceptionWithCode(CInArchiveException::kUnexpectedEndOfArchive);
  307.72 -}
  307.73 -
  307.74 -bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
  307.75 -{
  307.76 -  if (m_CryptoMode)
  307.77 -  {
  307.78 -    const Byte *bufData = (const Byte *)m_DecryptedData;
  307.79 -    UInt32 bufSize = m_DecryptedDataSize;
  307.80 -    UInt32 i;
  307.81 -    for (i = 0; i < size && m_CryptoPos < bufSize; i++)
  307.82 -      ((Byte *)data)[i] = bufData[m_CryptoPos++];
  307.83 -    return (i == size);
  307.84 -  }
  307.85 -  return (ReadStream_FALSE(m_Stream, data, size) == S_OK);
  307.86 -}
  307.87 -
  307.88 -void CInArchive::ReadBytesAndTestResult(void *data, UInt32 size)
  307.89 -{
  307.90 -  if(!ReadBytesAndTestSize(data,size))
  307.91 -    ThrowUnexpectedEndOfArchiveException();
  307.92 -}
  307.93 -
  307.94 -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
  307.95 -{
  307.96 -  size_t realProcessedSize = size;
  307.97 -  HRESULT result = ReadStream(m_Stream, data, &realProcessedSize);
  307.98 -  if (processedSize != NULL)
  307.99 -    *processedSize = (UInt32)realProcessedSize;
 307.100 -  AddToSeekValue(realProcessedSize);
 307.101 -  return result;
 307.102 -}
 307.103 -
 307.104 -static UInt32 CrcUpdateUInt16(UInt32 crc, UInt16 v)
 307.105 -{
 307.106 -  crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
 307.107 -  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
 307.108 -  return crc;
 307.109 -}
 307.110 -
 307.111 -static UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 v)
 307.112 -{
 307.113 -  crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
 307.114 -  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
 307.115 -  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 16) & 0xFF));
 307.116 -  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 24) & 0xFF));
 307.117 -  return crc;
 307.118 -}
 307.119 -
 307.120 -
 307.121 -HRESULT CInArchive::Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
 307.122 -{
 307.123 -  m_CryptoMode = false;
 307.124 -  RINOK(stream->Seek(0, STREAM_SEEK_SET, &m_StreamStartPosition));
 307.125 -  m_Position = m_StreamStartPosition;
 307.126 -
 307.127 -  RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
 307.128 -
 307.129 -  Byte buf[NHeader::NArchive::kArchiveHeaderSize];
 307.130 -  UInt32 processedSize;
 307.131 -  ReadBytes(buf, sizeof(buf), &processedSize);
 307.132 -  if (processedSize != sizeof(buf))
 307.133 -    return S_FALSE;
 307.134 -  m_CurData = buf;
 307.135 -  m_CurPos = 0;
 307.136 -  m_PosLimit = sizeof(buf);
 307.137 -
 307.138 -  m_ArchiveHeader.CRC = ReadUInt16();
 307.139 -  m_ArchiveHeader.Type = ReadByte();
 307.140 -  m_ArchiveHeader.Flags = ReadUInt16();
 307.141 -  m_ArchiveHeader.Size = ReadUInt16();
 307.142 -  m_ArchiveHeader.Reserved1 = ReadUInt16();
 307.143 -  m_ArchiveHeader.Reserved2 = ReadUInt32();
 307.144 -  m_ArchiveHeader.EncryptVersion = 0;
 307.145 -
 307.146 -  UInt32 crc = CRC_INIT_VAL;
 307.147 -  crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.Type);
 307.148 -  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Flags);
 307.149 -  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Size);
 307.150 -  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Reserved1);
 307.151 -  crc = CrcUpdateUInt32(crc, m_ArchiveHeader.Reserved2);
 307.152 -
 307.153 -  if (m_ArchiveHeader.IsThereEncryptVer() && m_ArchiveHeader.Size > NHeader::NArchive::kArchiveHeaderSize)
 307.154 -  {
 307.155 -    ReadBytes(&m_ArchiveHeader.EncryptVersion, 1, &processedSize);
 307.156 -    if (processedSize != 1)
 307.157 -      return S_FALSE;
 307.158 -    crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.EncryptVersion);
 307.159 -  }
 307.160 -
 307.161 -  if(m_ArchiveHeader.CRC != (CRC_GET_DIGEST(crc) & 0xFFFF))
 307.162 -    ThrowExceptionWithCode(CInArchiveException::kArchiveHeaderCRCError);
 307.163 -  if (m_ArchiveHeader.Type != NHeader::NBlockType::kArchiveHeader)
 307.164 -    return S_FALSE;
 307.165 -  m_ArchiveCommentPosition = m_Position;
 307.166 -  m_SeekOnArchiveComment = true;
 307.167 -  return S_OK;
 307.168 -}
 307.169 -
 307.170 -void CInArchive::SkipArchiveComment()
 307.171 -{
 307.172 -  if (!m_SeekOnArchiveComment)
 307.173 -    return;
 307.174 -  AddToSeekValue(m_ArchiveHeader.Size - m_ArchiveHeader.GetBaseSize());
 307.175 -  m_SeekOnArchiveComment = false;
 307.176 -}
 307.177 -
 307.178 -void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
 307.179 -{
 307.180 -  archiveInfo.StartPosition = m_ArchiveStartPosition;
 307.181 -  archiveInfo.Flags = m_ArchiveHeader.Flags;
 307.182 -  archiveInfo.CommentPosition = m_ArchiveCommentPosition;
 307.183 -  archiveInfo.CommentSize = (UInt16)(m_ArchiveHeader.Size - NHeader::NArchive::kArchiveHeaderSize);
 307.184 -}
 307.185 -
 307.186 -static void DecodeUnicodeFileName(const char *name, const Byte *encName,
 307.187 -    int encSize, wchar_t *unicodeName, int maxDecSize)
 307.188 -{
 307.189 -  int encPos = 0;
 307.190 -  int decPos = 0;
 307.191 -  int flagBits = 0;
 307.192 -  Byte flags = 0;
 307.193 -  Byte highByte = encName[encPos++];
 307.194 -  while (encPos < encSize && decPos < maxDecSize)
 307.195 -  {
 307.196 -    if (flagBits == 0)
 307.197 -    {
 307.198 -      flags = encName[encPos++];
 307.199 -      flagBits = 8;
 307.200 -    }
 307.201 -    switch(flags >> 6)
 307.202 -    {
 307.203 -      case 0:
 307.204 -        unicodeName[decPos++] = encName[encPos++];
 307.205 -        break;
 307.206 -      case 1:
 307.207 -        unicodeName[decPos++] = (wchar_t)(encName[encPos++] + (highByte << 8));
 307.208 -        break;
 307.209 -      case 2:
 307.210 -        unicodeName[decPos++] = (wchar_t)(encName[encPos] + (encName[encPos + 1] << 8));
 307.211 -        encPos += 2;
 307.212 -        break;
 307.213 -      case 3:
 307.214 -        {
 307.215 -          int length = encName[encPos++];
 307.216 -          if (length & 0x80)
 307.217 -          {
 307.218 -            Byte correction = encName[encPos++];
 307.219 -            for (length = (length & 0x7f) + 2;
 307.220 -                length > 0 && decPos < maxDecSize; length--, decPos++)
 307.221 -              unicodeName[decPos] = (wchar_t)(((name[decPos] + correction) & 0xff) + (highByte << 8));
 307.222 -          }
 307.223 -          else
 307.224 -            for (length += 2; length > 0 && decPos < maxDecSize; length--, decPos++)
 307.225 -              unicodeName[decPos] = name[decPos];
 307.226 -        }
 307.227 -        break;
 307.228 -    }
 307.229 -    flags <<= 2;
 307.230 -    flagBits -= 2;
 307.231 -  }
 307.232 -  unicodeName[decPos < maxDecSize ? decPos : maxDecSize - 1] = 0;
 307.233 -}
 307.234 -
 307.235 -void CInArchive::ReadName(CItemEx &item, int nameSize)
 307.236 -{
 307.237 -  item.UnicodeName.Empty();
 307.238 -  if (nameSize > 0)
 307.239 -  {
 307.240 -    m_NameBuffer.EnsureCapacity(nameSize + 1);
 307.241 -    char *buffer = (char *)m_NameBuffer;
 307.242 -
 307.243 -    for (int i = 0; i < nameSize; i++)
 307.244 -      buffer[i] = ReadByte();
 307.245 -
 307.246 -    int mainLen;
 307.247 -    for (mainLen = 0; mainLen < nameSize; mainLen++)
 307.248 -      if (buffer[mainLen] == '\0')
 307.249 -        break;
 307.250 -    buffer[mainLen] = '\0';
 307.251 -    item.Name = buffer;
 307.252 -
 307.253 -    if(item.HasUnicodeName())
 307.254 -    {
 307.255 -      if(mainLen < nameSize)
 307.256 -      {
 307.257 -        int unicodeNameSizeMax = MyMin(nameSize, (0x400));
 307.258 -        _unicodeNameBuffer.EnsureCapacity(unicodeNameSizeMax + 1);
 307.259 -        DecodeUnicodeFileName(buffer, (const Byte *)buffer + mainLen + 1,
 307.260 -            nameSize - (mainLen + 1), _unicodeNameBuffer, unicodeNameSizeMax);
 307.261 -        item.UnicodeName = _unicodeNameBuffer;
 307.262 -      }
 307.263 -      else if (!ConvertUTF8ToUnicode(item.Name, item.UnicodeName))
 307.264 -        item.UnicodeName.Empty();
 307.265 -    }
 307.266 -  }
 307.267 -  else
 307.268 -    item.Name.Empty();
 307.269 -}
 307.270 -
 307.271 -Byte CInArchive::ReadByte()
 307.272 -{
 307.273 -  if (m_CurPos >= m_PosLimit)
 307.274 -    throw CInArchiveException(CInArchiveException::kIncorrectArchive);
 307.275 -  return m_CurData[m_CurPos++];
 307.276 -}
 307.277 -
 307.278 -UInt16 CInArchive::ReadUInt16()
 307.279 -{
 307.280 -  UInt16 value = 0;
 307.281 -  for (int i = 0; i < 2; i++)
 307.282 -  {
 307.283 -    Byte b = ReadByte();
 307.284 -    value |= (UInt16(b) << (8 * i));
 307.285 -  }
 307.286 -  return value;
 307.287 -}
 307.288 -
 307.289 -UInt32 CInArchive::ReadUInt32()
 307.290 -{
 307.291 -  UInt32 value = 0;
 307.292 -  for (int i = 0; i < 4; i++)
 307.293 -  {
 307.294 -    Byte b = ReadByte();
 307.295 -    value |= (UInt32(b) << (8 * i));
 307.296 -  }
 307.297 -  return value;
 307.298 -}
 307.299 -
 307.300 -void CInArchive::ReadTime(Byte mask, CRarTime &rarTime)
 307.301 -{
 307.302 -  rarTime.LowSecond = (Byte)(((mask & 4) != 0) ? 1 : 0);
 307.303 -  int numDigits = (mask & 3);
 307.304 -  rarTime.SubTime[0] = rarTime.SubTime[1] = rarTime.SubTime[2] = 0;
 307.305 -  for (int i = 0; i < numDigits; i++)
 307.306 -    rarTime.SubTime[3 - numDigits + i] = ReadByte();
 307.307 -}
 307.308 -
 307.309 -void CInArchive::ReadHeaderReal(CItemEx &item)
 307.310 -{
 307.311 -  item.Flags = m_BlockHeader.Flags;
 307.312 -  item.PackSize = ReadUInt32();
 307.313 -  item.Size = ReadUInt32();
 307.314 -  item.HostOS = ReadByte();
 307.315 -  item.FileCRC = ReadUInt32();
 307.316 -  item.MTime.DosTime = ReadUInt32();
 307.317 -  item.UnPackVersion = ReadByte();
 307.318 -  item.Method = ReadByte();
 307.319 -  int nameSize = ReadUInt16();
 307.320 -  item.Attrib = ReadUInt32();
 307.321 -
 307.322 -  item.MTime.LowSecond = 0;
 307.323 -  item.MTime.SubTime[0] =
 307.324 -      item.MTime.SubTime[1] =
 307.325 -      item.MTime.SubTime[2] = 0;
 307.326 -
 307.327 -  if((item.Flags & NHeader::NFile::kSize64Bits) != 0)
 307.328 -  {
 307.329 -    item.PackSize |= ((UInt64)ReadUInt32() << 32);
 307.330 -    item.Size |= ((UInt64)ReadUInt32() << 32);
 307.331 -  }
 307.332 -
 307.333 -  ReadName(item, nameSize);
 307.334 -
 307.335 -  if (item.HasSalt())
 307.336 -    for (int i = 0; i < sizeof(item.Salt); i++)
 307.337 -      item.Salt[i] = ReadByte();
 307.338 -
 307.339 -  // some rar archives have HasExtTime flag without field.
 307.340 -  if (m_CurPos < m_PosLimit && item.HasExtTime())
 307.341 -  {
 307.342 -    Byte accessMask = (Byte)(ReadByte() >> 4);
 307.343 -    Byte b = ReadByte();
 307.344 -    Byte modifMask = (Byte)(b >> 4);
 307.345 -    Byte createMask = (Byte)(b & 0xF);
 307.346 -    if ((modifMask & 8) != 0)
 307.347 -      ReadTime(modifMask, item.MTime);
 307.348 -    item.CTimeDefined = ((createMask & 8) != 0);
 307.349 -    if (item.CTimeDefined)
 307.350 -    {
 307.351 -      item.CTime.DosTime = ReadUInt32();
 307.352 -      ReadTime(createMask, item.CTime);
 307.353 -    }
 307.354 -    item.ATimeDefined = ((accessMask & 8) != 0);
 307.355 -    if (item.ATimeDefined)
 307.356 -    {
 307.357 -      item.ATime.DosTime = ReadUInt32();
 307.358 -      ReadTime(accessMask, item.ATime);
 307.359 -    }
 307.360 -  }
 307.361 -
 307.362 -  UInt16 fileHeaderWithNameSize = (UInt16)m_CurPos;
 307.363 -  
 307.364 -  item.Position = m_Position;
 307.365 -  item.MainPartSize = fileHeaderWithNameSize;
 307.366 -  item.CommentSize = (UInt16)(m_BlockHeader.HeadSize - fileHeaderWithNameSize);
 307.367 -
 307.368 -  if (m_CryptoMode)
 307.369 -    item.AlignSize = (UInt16)((16 - ((m_BlockHeader.HeadSize) & 0xF)) & 0xF);
 307.370 -  else
 307.371 -    item.AlignSize = 0;
 307.372 -  AddToSeekValue(m_BlockHeader.HeadSize);
 307.373 -}
 307.374 -
 307.375 -void CInArchive::AddToSeekValue(UInt64 addValue)
 307.376 -{
 307.377 -  m_Position += addValue;
 307.378 -}
 307.379 -
 307.380 -HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword)
 307.381 -{
 307.382 -  if (m_SeekOnArchiveComment)
 307.383 -    SkipArchiveComment();
 307.384 -  for (;;)
 307.385 -  {
 307.386 -    if(!SeekInArchive(m_Position))
 307.387 -      return S_FALSE;
 307.388 -    if (!m_CryptoMode && (m_ArchiveHeader.Flags &
 307.389 -        NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
 307.390 -    {
 307.391 -      m_CryptoMode = false;
 307.392 -      if (getTextPassword == 0)
 307.393 -        return S_FALSE;
 307.394 -      if(!SeekInArchive(m_Position))
 307.395 -        return S_FALSE;
 307.396 -      if (!m_RarAES)
 307.397 -      {
 307.398 -        m_RarAESSpec = new NCrypto::NRar29::CDecoder;
 307.399 -        m_RarAES = m_RarAESSpec;
 307.400 -      }
 307.401 -      m_RarAESSpec->SetRar350Mode(m_ArchiveHeader.IsEncryptOld());
 307.402 -
 307.403 -      // Salt
 307.404 -      const UInt32 kSaltSize = 8;
 307.405 -      Byte salt[kSaltSize];
 307.406 -      if(!ReadBytesAndTestSize(salt, kSaltSize))
 307.407 -        return S_FALSE;
 307.408 -      m_Position += kSaltSize;
 307.409 -      RINOK(m_RarAESSpec->SetDecoderProperties2(salt, kSaltSize))
 307.410 -      // Password
 307.411 -      CMyComBSTR password;
 307.412 -      RINOK(getTextPassword->CryptoGetTextPassword(&password))
 307.413 -      UString unicodePassword(password);
 307.414 -
 307.415 -      CByteBuffer buffer;
 307.416 -      const UInt32 sizeInBytes = unicodePassword.Length() * 2;
 307.417 -      buffer.SetCapacity(sizeInBytes);
 307.418 -      for (int i = 0; i < unicodePassword.Length(); i++)
 307.419 -      {
 307.420 -        wchar_t c = unicodePassword[i];
 307.421 -        ((Byte *)buffer)[i * 2] = (Byte)c;
 307.422 -        ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
 307.423 -      }
 307.424 -
 307.425 -      RINOK(m_RarAESSpec->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
 307.426 -
 307.427 -      const UInt32 kDecryptedBufferSize = (1 << 12);
 307.428 -      if (m_DecryptedData.GetCapacity() == 0)
 307.429 -      {
 307.430 -        m_DecryptedData.SetCapacity(kDecryptedBufferSize);
 307.431 -      }
 307.432 -      RINOK(m_RarAES->Init());
 307.433 -      size_t decryptedDataSizeT = kDecryptedBufferSize;
 307.434 -      RINOK(ReadStream(m_Stream, (Byte *)m_DecryptedData, &decryptedDataSizeT));
 307.435 -      m_DecryptedDataSize = (UInt32)decryptedDataSizeT;
 307.436 -      m_DecryptedDataSize = m_RarAES->Filter((Byte *)m_DecryptedData, m_DecryptedDataSize);
 307.437 -
 307.438 -      m_CryptoMode = true;
 307.439 -      m_CryptoPos = 0;
 307.440 -    }
 307.441 -
 307.442 -    m_FileHeaderData.EnsureCapacity(7);
 307.443 -    if(!ReadBytesAndTestSize((Byte *)m_FileHeaderData, 7))
 307.444 -      return S_FALSE;
 307.445 -
 307.446 -    m_CurData = (Byte *)m_FileHeaderData;
 307.447 -    m_CurPos = 0;
 307.448 -    m_PosLimit = 7;
 307.449 -    m_BlockHeader.CRC = ReadUInt16();
 307.450 -    m_BlockHeader.Type = ReadByte();
 307.451 -    m_BlockHeader.Flags = ReadUInt16();
 307.452 -    m_BlockHeader.HeadSize = ReadUInt16();
 307.453 -
 307.454 -    if (m_BlockHeader.HeadSize < 7)
 307.455 -      ThrowExceptionWithCode(CInArchiveException::kIncorrectArchive);
 307.456 -
 307.457 -    if (m_BlockHeader.Type == NHeader::NBlockType::kEndOfArchive)
 307.458 -      return S_FALSE;
 307.459 -
 307.460 -    if (m_BlockHeader.Type == NHeader::NBlockType::kFileHeader)
 307.461 -    {
 307.462 -      m_FileHeaderData.EnsureCapacity(m_BlockHeader.HeadSize);
 307.463 -      m_CurData = (Byte *)m_FileHeaderData;
 307.464 -      m_PosLimit = m_BlockHeader.HeadSize;
 307.465 -      ReadBytesAndTestResult(m_CurData + m_CurPos, m_BlockHeader.HeadSize - 7);
 307.466 -      ReadHeaderReal(item);
 307.467 -      if ((CrcCalc(m_CurData + 2,
 307.468 -          m_BlockHeader.HeadSize - item.CommentSize - 2) & 0xFFFF) != m_BlockHeader.CRC)
 307.469 -        ThrowExceptionWithCode(CInArchiveException::kFileHeaderCRCError);
 307.470 -
 307.471 -      FinishCryptoBlock();
 307.472 -      m_CryptoMode = false;
 307.473 -      SeekInArchive(m_Position); // Move Position to compressed Data;
 307.474 -      AddToSeekValue(item.PackSize);  // m_Position points to next header;
 307.475 -      return S_OK;
 307.476 -    }
 307.477 -    if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 12))
 307.478 -      return E_FAIL; // it's for bad passwords
 307.479 -    if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
 307.480 -    {
 307.481 -      m_FileHeaderData.EnsureCapacity(7 + 4);
 307.482 -      m_CurData = (Byte *)m_FileHeaderData;
 307.483 -      ReadBytesAndTestResult(m_CurData + m_CurPos, 4); // test it
 307.484 -      m_PosLimit = 7 + 4;
 307.485 -      UInt32 dataSize = ReadUInt32();
 307.486 -      AddToSeekValue(dataSize);
 307.487 -      if (m_CryptoMode && dataSize > (1 << 27))
 307.488 -        return E_FAIL; // it's for bad passwords
 307.489 -      m_CryptoPos = m_BlockHeader.HeadSize;
 307.490 -    }
 307.491 -    else
 307.492 -      m_CryptoPos = 0;
 307.493 -    AddToSeekValue(m_BlockHeader.HeadSize);
 307.494 -    FinishCryptoBlock();
 307.495 -    m_CryptoMode = false;
 307.496 -  }
 307.497 -}
 307.498 -
 307.499 -bool CInArchive::SeekInArchive(UInt64 position)
 307.500 -{
 307.501 -  UInt64 newPosition;
 307.502 -  m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition);
 307.503 -  return newPosition == position;
 307.504 -}
 307.505 -
 307.506 -ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
 307.507 -{
 307.508 -  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
 307.509 -  CMyComPtr<ISequentialInStream> inStream(streamSpec);
 307.510 -  SeekInArchive(position);
 307.511 -  streamSpec->SetStream(m_Stream);
 307.512 -  streamSpec->Init(size);
 307.513 -  return inStream.Detach();
 307.514 -}
 307.515 -
 307.516 -}}
   308.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.h	Sat Mar 03 10:54:39 2012 -0600
   308.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   308.3 @@ -1,126 +0,0 @@
   308.4 -// RarIn.h
   308.5 -
   308.6 -#ifndef __ARCHIVE_RAR_IN_H
   308.7 -#define __ARCHIVE_RAR_IN_H
   308.8 -
   308.9 -#include "Common/DynamicBuffer.h"
  308.10 -#include "Common/MyCom.h"
  308.11 -
  308.12 -#include "../../ICoder.h"
  308.13 -#include "../../IStream.h"
  308.14 -
  308.15 -#include "../../Common/StreamObjects.h"
  308.16 -
  308.17 -#include "../../Crypto/RarAes.h"
  308.18 -
  308.19 -#include "RarHeader.h"
  308.20 -#include "RarItem.h"
  308.21 -
  308.22 -namespace NArchive {
  308.23 -namespace NRar {
  308.24 -
  308.25 -class CInArchiveException
  308.26 -{
  308.27 -public:
  308.28 -  enum CCauseType
  308.29 -  {
  308.30 -    kUnexpectedEndOfArchive = 0,
  308.31 -    kArchiveHeaderCRCError,
  308.32 -    kFileHeaderCRCError,
  308.33 -    kIncorrectArchive
  308.34 -  }
  308.35 -  Cause;
  308.36 -  CInArchiveException(CCauseType cause) :   Cause(cause) {}
  308.37 -};
  308.38 -
  308.39 -class CInArchiveInfo
  308.40 -{
  308.41 -public:
  308.42 -  UInt64 StartPosition;
  308.43 -  UInt16 Flags;
  308.44 -  UInt64 CommentPosition;
  308.45 -  UInt16 CommentSize;
  308.46 -  bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; }
  308.47 -  bool IsCommented() const {  return (Flags & NHeader::NArchive::kComment) != 0; }
  308.48 -  bool IsVolume() const {  return (Flags & NHeader::NArchive::kVolume) != 0; }
  308.49 -  bool HaveNewVolumeName() const {  return (Flags & NHeader::NArchive::kNewVolName) != 0; }
  308.50 -  bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
  308.51 -};
  308.52 -
  308.53 -class CInArchive
  308.54 -{
  308.55 -  CMyComPtr<IInStream> m_Stream;
  308.56 -  
  308.57 -  UInt64 m_StreamStartPosition;
  308.58 -  UInt64 m_Position;
  308.59 -  UInt64 m_ArchiveStartPosition;
  308.60 -  
  308.61 -  NHeader::NArchive::CHeader360 m_ArchiveHeader;
  308.62 -  CDynamicBuffer<char> m_NameBuffer;
  308.63 -  CDynamicBuffer<wchar_t> _unicodeNameBuffer;
  308.64 -  bool m_SeekOnArchiveComment;
  308.65 -  UInt64 m_ArchiveCommentPosition;
  308.66 -  
  308.67 -  void ReadName(CItemEx &item, int nameSize);
  308.68 -  void ReadHeaderReal(CItemEx &item);
  308.69 -  
  308.70 -  HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize);
  308.71 -  bool ReadBytesAndTestSize(void *data, UInt32 size);
  308.72 -  void ReadBytesAndTestResult(void *data, UInt32 size);
  308.73 -  
  308.74 -  HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  308.75 -  HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  308.76 -
  308.77 -  void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);
  308.78 -  void ThrowUnexpectedEndOfArchiveException();
  308.79 -  
  308.80 -  void AddToSeekValue(UInt64 addValue);
  308.81 -  
  308.82 -protected:
  308.83 -
  308.84 -  CDynamicBuffer<Byte> m_FileHeaderData;
  308.85 -  
  308.86 -  NHeader::NBlock::CBlock m_BlockHeader;
  308.87 -
  308.88 -  NCrypto::NRar29::CDecoder *m_RarAESSpec;
  308.89 -  CMyComPtr<ICompressFilter> m_RarAES;
  308.90 -  
  308.91 -  Byte *m_CurData; // it must point to start of Rar::Block
  308.92 -  UInt32 m_CurPos;
  308.93 -  UInt32 m_PosLimit;
  308.94 -  Byte ReadByte();
  308.95 -  UInt16 ReadUInt16();
  308.96 -  UInt32 ReadUInt32();
  308.97 -  void ReadTime(Byte mask, CRarTime &rarTime);
  308.98 -
  308.99 -  CBuffer<Byte> m_DecryptedData;
 308.100 -  UInt32 m_DecryptedDataSize;
 308.101 -
 308.102 -  bool m_CryptoMode;
 308.103 -  UInt32 m_CryptoPos;
 308.104 -  void FinishCryptoBlock()
 308.105 -  {
 308.106 -    if (m_CryptoMode)
 308.107 -      while ((m_CryptoPos & 0xF) != 0)
 308.108 -      {
 308.109 -        m_CryptoPos++;
 308.110 -        m_Position++;
 308.111 -      }
 308.112 -  }
 308.113 -
 308.114 -public:
 308.115 -  HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
 308.116 -  void Close();
 308.117 -  HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword);
 308.118 -  
 308.119 -  void SkipArchiveComment();
 308.120 -  
 308.121 -  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
 308.122 -  
 308.123 -  bool SeekInArchive(UInt64 position);
 308.124 -  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
 308.125 -};
 308.126 -  
 308.127 -}}
 308.128 -  
 308.129 -#endif
   309.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarItem.cpp	Sat Mar 03 10:54:39 2012 -0600
   309.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   309.3 @@ -1,55 +0,0 @@
   309.4 -// RarItem.cpp
   309.5 -
   309.6 -#include "StdAfx.h"
   309.7 -
   309.8 -#include "RarItem.h"
   309.9 -
  309.10 -namespace NArchive{
  309.11 -namespace NRar{
  309.12 -
  309.13 -bool CItem::IgnoreItem() const
  309.14 -{
  309.15 -  switch(HostOS)
  309.16 -  {
  309.17 -    case NHeader::NFile::kHostMSDOS:
  309.18 -    case NHeader::NFile::kHostOS2:
  309.19 -    case NHeader::NFile::kHostWin32:
  309.20 -      return ((Attrib & NHeader::NFile::kLabelFileAttribute) != 0);
  309.21 -  }
  309.22 -  return false;
  309.23 -}
  309.24 -
  309.25 -bool CItem::IsDir() const
  309.26 -{
  309.27 -  if (GetDictSize() == NHeader::NFile::kDictDirectoryValue)
  309.28 -    return true;
  309.29 -  switch(HostOS)
  309.30 -  {
  309.31 -    case NHeader::NFile::kHostMSDOS:
  309.32 -    case NHeader::NFile::kHostOS2:
  309.33 -    case NHeader::NFile::kHostWin32:
  309.34 -      if ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
  309.35 -        return true;
  309.36 -  }
  309.37 -  return false;
  309.38 -}
  309.39 -
  309.40 -UInt32 CItem::GetWinAttributes() const
  309.41 -{
  309.42 -  UInt32 winAttributes;
  309.43 -  switch(HostOS)
  309.44 -  {
  309.45 -    case NHeader::NFile::kHostMSDOS:
  309.46 -    case NHeader::NFile::kHostOS2:
  309.47 -    case NHeader::NFile::kHostWin32:
  309.48 -      winAttributes = Attrib;
  309.49 -      break;
  309.50 -    default:
  309.51 -      winAttributes = 0; // must be converted from unix value;
  309.52 -  }
  309.53 -  if (IsDir())
  309.54 -    winAttributes |= NHeader::NFile::kWinFileDirectoryAttributeMask;
  309.55 -  return winAttributes;
  309.56 -}
  309.57 -
  309.58 -}}
   310.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarItem.h	Sat Mar 03 10:54:39 2012 -0600
   310.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   310.3 @@ -1,79 +0,0 @@
   310.4 -// RarItem.h
   310.5 -
   310.6 -#ifndef __ARCHIVE_RAR_ITEM_H
   310.7 -#define __ARCHIVE_RAR_ITEM_H
   310.8 -
   310.9 -#include "Common/Types.h"
  310.10 -#include "Common/MyString.h"
  310.11 -
  310.12 -#include "RarHeader.h"
  310.13 -
  310.14 -namespace NArchive{
  310.15 -namespace NRar{
  310.16 -
  310.17 -struct CRarTime
  310.18 -{
  310.19 -  UInt32 DosTime;
  310.20 -  Byte LowSecond;
  310.21 -  Byte SubTime[3];
  310.22 -};
  310.23 -
  310.24 -struct CItem
  310.25 -{
  310.26 -  UInt64 Size;
  310.27 -  UInt64 PackSize;
  310.28 -  
  310.29 -  CRarTime CTime;
  310.30 -  CRarTime ATime;
  310.31 -  CRarTime MTime;
  310.32 -
  310.33 -  UInt32 FileCRC;
  310.34 -  UInt32 Attrib;
  310.35 -
  310.36 -  UInt16 Flags;
  310.37 -  Byte HostOS;
  310.38 -  Byte UnPackVersion;
  310.39 -  Byte Method;
  310.40 -
  310.41 -  bool CTimeDefined;
  310.42 -  bool ATimeDefined;
  310.43 -
  310.44 -  AString Name;
  310.45 -  UString UnicodeName;
  310.46 -
  310.47 -  Byte Salt[8];
  310.48 -  
  310.49 -  bool IsEncrypted()   const { return (Flags & NHeader::NFile::kEncrypted) != 0; }
  310.50 -  bool IsSolid()       const { return (Flags & NHeader::NFile::kSolid) != 0; }
  310.51 -  bool IsCommented()   const { return (Flags & NHeader::NFile::kComment) != 0; }
  310.52 -  bool IsSplitBefore() const { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
  310.53 -  bool IsSplitAfter()  const { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
  310.54 -  bool HasSalt()       const { return (Flags & NHeader::NFile::kSalt) != 0; }
  310.55 -  bool HasExtTime()    const { return (Flags & NHeader::NFile::kExtTime) != 0; }
  310.56 -  bool HasUnicodeName()const { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
  310.57 -  bool IsOldVersion()  const { return (Flags & NHeader::NFile::kOldVersion) != 0; }
  310.58 -  
  310.59 -  UInt32 GetDictSize() const { return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
  310.60 -  bool IsDir() const;
  310.61 -  bool IgnoreItem() const;
  310.62 -  UInt32 GetWinAttributes() const;
  310.63 -  
  310.64 -  CItem(): CTimeDefined(false), ATimeDefined(false) {}
  310.65 -};
  310.66 -
  310.67 -class CItemEx: public CItem
  310.68 -{
  310.69 -public:
  310.70 -  UInt64 Position;
  310.71 -  UInt16 MainPartSize;
  310.72 -  UInt16 CommentSize;
  310.73 -  UInt16 AlignSize;
  310.74 -  UInt64 GetFullSize()  const { return MainPartSize + CommentSize + AlignSize + PackSize; };
  310.75 -  //  DWORD GetHeaderWithCommentSize()  const { return MainPartSize + CommentSize; };
  310.76 -  UInt64 GetCommentPosition() const { return Position + MainPartSize; };
  310.77 -  UInt64 GetDataPosition()    const { return GetCommentPosition() + CommentSize + AlignSize; };
  310.78 -};
  310.79 -
  310.80 -}}
  310.81 -
  310.82 -#endif
   311.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   311.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   311.3 @@ -1,13 +0,0 @@
   311.4 -// RarRegister.cpp
   311.5 -
   311.6 -#include "StdAfx.h"
   311.7 -
   311.8 -#include "../../Common/RegisterArc.h"
   311.9 -
  311.10 -#include "RarHandler.h"
  311.11 -static IInArchive *CreateArc() { return new NArchive::NRar::CHandler;  }
  311.12 -
  311.13 -static CArcInfo g_ArcInfo =
  311.14 -  { L"Rar", L"rar r00", 0, 3, {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, 7, false, CreateArc, 0,  };
  311.15 -
  311.16 -REGISTER_ARC(Rar)
   312.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   312.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   312.3 @@ -1,84 +0,0 @@
   312.4 -// RarVolumeInStream.cpp
   312.5 -
   312.6 -#include "StdAfx.h"
   312.7 -
   312.8 -#include "RarVolumeInStream.h"
   312.9 -
  312.10 -#include "Windows/Defs.h"
  312.11 -#include "Common/Defs.h"
  312.12 -
  312.13 -extern "C"
  312.14 -{
  312.15 -  #include "../../../../C/7zCrc.h"
  312.16 -}
  312.17 -
  312.18 -namespace NArchive {
  312.19 -namespace NRar {
  312.20 -
  312.21 -void CFolderInStream::Init(
  312.22 -    CObjectVector<CInArchive> *archives,
  312.23 -    const CObjectVector<CItemEx> *items,
  312.24 -    const CRefItem &refItem)
  312.25 -{
  312.26 -  _archives = archives;
  312.27 -  _items = items;
  312.28 -  _refItem = refItem;
  312.29 -  _curIndex = 0;
  312.30 -  CRCs.Clear();
  312.31 -  _fileIsOpen = false;
  312.32 -}
  312.33 -
  312.34 -HRESULT CFolderInStream::OpenStream()
  312.35 -{
  312.36 -  while (_curIndex < _refItem.NumItems)
  312.37 -  {
  312.38 -    const CItemEx &item = (*_items)[_refItem.ItemIndex + _curIndex];
  312.39 -    _stream.Attach((*_archives)[_refItem.VolumeIndex + _curIndex].
  312.40 -        CreateLimitedStream(item.GetDataPosition(), item.PackSize));
  312.41 -    _curIndex++;
  312.42 -    _fileIsOpen = true;
  312.43 -    _crc = CRC_INIT_VAL;
  312.44 -    return S_OK;
  312.45 -  }
  312.46 -  return S_OK;
  312.47 -}
  312.48 -
  312.49 -HRESULT CFolderInStream::CloseStream()
  312.50 -{
  312.51 -  CRCs.Add(CRC_GET_DIGEST(_crc));
  312.52 -  _stream.Release();
  312.53 -  _fileIsOpen = false;
  312.54 -  return S_OK;
  312.55 -}
  312.56 -
  312.57 -STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
  312.58 -{
  312.59 -  UInt32 realProcessedSize = 0;
  312.60 -  while ((_curIndex < _refItem.NumItems || _fileIsOpen) && size > 0)
  312.61 -  {
  312.62 -    if (_fileIsOpen)
  312.63 -    {
  312.64 -      UInt32 localProcessedSize;
  312.65 -      RINOK(_stream->Read(
  312.66 -          ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
  312.67 -      _crc = CrcUpdate(_crc, ((Byte *)data) + realProcessedSize, localProcessedSize);
  312.68 -      if (localProcessedSize == 0)
  312.69 -      {
  312.70 -        RINOK(CloseStream());
  312.71 -        continue;
  312.72 -      }
  312.73 -      realProcessedSize += localProcessedSize;
  312.74 -      size -= localProcessedSize;
  312.75 -      break;
  312.76 -    }
  312.77 -    else
  312.78 -    {
  312.79 -      RINOK(OpenStream());
  312.80 -    }
  312.81 -  }
  312.82 -  if (processedSize != 0)
  312.83 -    *processedSize = realProcessedSize;
  312.84 -  return S_OK;
  312.85 -}
  312.86 -
  312.87 -}}
   313.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h	Sat Mar 03 10:54:39 2012 -0600
   313.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   313.3 @@ -1,49 +0,0 @@
   313.4 -// RarVolumeInStream.h
   313.5 -
   313.6 -#ifndef __RAR_VOLUME_IN_STREAM_H
   313.7 -#define __RAR_VOLUME_IN_STREAM_H
   313.8 -
   313.9 -#include "../../IStream.h"
  313.10 -#include "RarIn.h"
  313.11 -
  313.12 -namespace NArchive {
  313.13 -namespace NRar {
  313.14 -
  313.15 -struct CRefItem
  313.16 -{
  313.17 -  int VolumeIndex;
  313.18 -  int ItemIndex;
  313.19 -  int NumItems;
  313.20 -};
  313.21 -
  313.22 -class CFolderInStream:
  313.23 -  public ISequentialInStream,
  313.24 -  public CMyUnknownImp
  313.25 -{
  313.26 -public:
  313.27 -  MY_UNKNOWN_IMP
  313.28 -
  313.29 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  313.30 -
  313.31 -private:
  313.32 -  CObjectVector<CInArchive> *_archives;
  313.33 -  const CObjectVector<CItemEx> *_items;
  313.34 -  CRefItem _refItem;
  313.35 -  int _curIndex;
  313.36 -  UInt32 _crc;
  313.37 -  bool _fileIsOpen;
  313.38 -  CMyComPtr<ISequentialInStream> _stream;
  313.39 -
  313.40 -  HRESULT OpenStream();
  313.41 -  HRESULT CloseStream();
  313.42 -public:
  313.43 -  void Init(CObjectVector<CInArchive> *archives,
  313.44 -      const CObjectVector<CItemEx> *items,
  313.45 -      const CRefItem &refItem);
  313.46 -
  313.47 -  CRecordVector<UInt32> CRCs;
  313.48 -};
  313.49 -  
  313.50 -}}
  313.51 -
  313.52 -#endif
   314.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Rar/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   314.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   314.3 @@ -1,8 +0,0 @@
   314.4 -// StdAfx.h
   314.5 -
   314.6 -#ifndef __STDAFX_H
   314.7 -#define __STDAFX_H
   314.8 -
   314.9 -#include "../../../Common/MyWindows.h"
  314.10 -
  314.11 -#endif
   315.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   315.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   315.3 @@ -1,357 +0,0 @@
   315.4 -// SplitHandler.cpp
   315.5 -
   315.6 -#include "StdAfx.h"
   315.7 -
   315.8 -#include "Common/ComTry.h"
   315.9 -#include "Common/Defs.h"
  315.10 -#include "Common/NewHandler.h"
  315.11 -#include "Common/StringConvert.h"
  315.12 -
  315.13 -#include "Windows/PropVariant.h"
  315.14 -#include "Windows/Time.h"
  315.15 -
  315.16 -#include "../../Common/ProgressUtils.h"
  315.17 -
  315.18 -#include "../../Compress/CopyCoder.h"
  315.19 -
  315.20 -#include "../Common/ItemNameUtils.h"
  315.21 -#include "../Common/MultiStream.h"
  315.22 -
  315.23 -#include "SplitHandler.h"
  315.24 -
  315.25 -using namespace NWindows;
  315.26 -using namespace NTime;
  315.27 -
  315.28 -namespace NArchive {
  315.29 -namespace NSplit {
  315.30 -
  315.31 -STATPROPSTG kProps[] =
  315.32 -{
  315.33 -  { NULL, kpidPath, VT_BSTR},
  315.34 -  { NULL, kpidSize, VT_UI8},
  315.35 -  { NULL, kpidPackSize, VT_UI8},
  315.36 -};
  315.37 -
  315.38 -IMP_IInArchive_Props
  315.39 -IMP_IInArchive_ArcProps_NO
  315.40 -
  315.41 -class CSeqName
  315.42 -{
  315.43 -public:
  315.44 -  UString _unchangedPart;
  315.45 -  UString _changedPart;
  315.46 -  bool _splitStyle;
  315.47 -  UString GetNextName()
  315.48 -  {
  315.49 -    UString newName;
  315.50 -    if (_splitStyle)
  315.51 -    {
  315.52 -      int i;
  315.53 -      int numLetters = _changedPart.Length();
  315.54 -      for (i = numLetters - 1; i >= 0; i--)
  315.55 -      {
  315.56 -        wchar_t c = _changedPart[i];
  315.57 -        if (c == 'z')
  315.58 -        {
  315.59 -          c = 'a';
  315.60 -          newName = c + newName;
  315.61 -          continue;
  315.62 -        }
  315.63 -        else if (c == 'Z')
  315.64 -        {
  315.65 -          c = 'A';
  315.66 -          newName = c + newName;
  315.67 -          continue;
  315.68 -        }
  315.69 -        c++;
  315.70 -        if ((c == 'z' || c == 'Z') && i == 0)
  315.71 -        {
  315.72 -          _unchangedPart += c;
  315.73 -          wchar_t newChar = (c == 'z') ? L'a' : L'A';
  315.74 -          newName.Empty();
  315.75 -          numLetters++;
  315.76 -          for (int k = 0; k < numLetters; k++)
  315.77 -            newName += newChar;
  315.78 -          break;
  315.79 -        }
  315.80 -        newName = c + newName;
  315.81 -        i--;
  315.82 -        for (; i >= 0; i--)
  315.83 -          newName = _changedPart[i] + newName;
  315.84 -        break;
  315.85 -      }
  315.86 -    }
  315.87 -    else
  315.88 -    {
  315.89 -      int i;
  315.90 -      int numLetters = _changedPart.Length();
  315.91 -      for (i = numLetters - 1; i >= 0; i--)
  315.92 -      {
  315.93 -        wchar_t c = _changedPart[i];
  315.94 -        if (c == L'9')
  315.95 -        {
  315.96 -          c = L'0';
  315.97 -          newName = c + newName;
  315.98 -          if (i == 0)
  315.99 -            newName = UString(L'1') + newName;
 315.100 -          continue;
 315.101 -        }
 315.102 -        c++;
 315.103 -        newName = c + newName;
 315.104 -        i--;
 315.105 -        for (; i >= 0; i--)
 315.106 -          newName = _changedPart[i] + newName;
 315.107 -        break;
 315.108 -      }
 315.109 -    }
 315.110 -    _changedPart = newName;
 315.111 -    return _unchangedPart + _changedPart;
 315.112 -  }
 315.113 -};
 315.114 -
 315.115 -STDMETHODIMP CHandler::Open(IInStream *stream,
 315.116 -    const UInt64 * /* maxCheckStartPosition */,
 315.117 -    IArchiveOpenCallback *openArchiveCallback)
 315.118 -{
 315.119 -  COM_TRY_BEGIN
 315.120 -  Close();
 315.121 -  if (openArchiveCallback == 0)
 315.122 -    return S_FALSE;
 315.123 -  // try
 315.124 -  {
 315.125 -    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
 315.126 -    CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
 315.127 -    if (openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback,
 315.128 -        &openVolumeCallback) != S_OK)
 315.129 -      return S_FALSE;
 315.130 -    
 315.131 -    {
 315.132 -      NCOM::CPropVariant prop;
 315.133 -      RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
 315.134 -      if (prop.vt != VT_BSTR)
 315.135 -        return S_FALSE;
 315.136 -      _name = prop.bstrVal;
 315.137 -    }
 315.138 -    
 315.139 -    int dotPos = _name.ReverseFind('.');
 315.140 -    UString prefix, ext;
 315.141 -    if (dotPos >= 0)
 315.142 -    {
 315.143 -      prefix = _name.Left(dotPos + 1);
 315.144 -      ext = _name.Mid(dotPos + 1);
 315.145 -    }
 315.146 -    else
 315.147 -      ext = _name;
 315.148 -    UString extBig = ext;
 315.149 -    extBig.MakeUpper();
 315.150 -
 315.151 -    CSeqName seqName;
 315.152 -
 315.153 -    int numLetters = 2;
 315.154 -    bool splitStyle = false;
 315.155 -    if (extBig.Right(2) == L"AA")
 315.156 -    {
 315.157 -      splitStyle = true;
 315.158 -      while (numLetters < extBig.Length())
 315.159 -      {
 315.160 -        if (extBig[extBig.Length() - numLetters - 1] != 'A')
 315.161 -          break;
 315.162 -        numLetters++;
 315.163 -      }
 315.164 -    }
 315.165 -    else if (ext.Right(2) == L"01")
 315.166 -    {
 315.167 -      while (numLetters < extBig.Length())
 315.168 -      {
 315.169 -        if (extBig[extBig.Length() - numLetters - 1] != '0')
 315.170 -          break;
 315.171 -        numLetters++;
 315.172 -      }
 315.173 -      if (numLetters != ext.Length())
 315.174 -        return S_FALSE;
 315.175 -    }
 315.176 -    else
 315.177 -      return S_FALSE;
 315.178 -
 315.179 -    _streams.Add(stream);
 315.180 -
 315.181 -    seqName._unchangedPart = prefix + ext.Left(extBig.Length() - numLetters);
 315.182 -    seqName._changedPart = ext.Right(numLetters);
 315.183 -    seqName._splitStyle = splitStyle;
 315.184 -
 315.185 -    if (prefix.Length() < 1)
 315.186 -      _subName = L"file";
 315.187 -    else
 315.188 -      _subName = prefix.Left(prefix.Length() - 1);
 315.189 -
 315.190 -    _totalSize = 0;
 315.191 -    UInt64 size;
 315.192 -    {
 315.193 -      NCOM::CPropVariant prop;
 315.194 -      RINOK(openVolumeCallback->GetProperty(kpidSize, &prop));
 315.195 -      if (prop.vt != VT_UI8)
 315.196 -        return E_INVALIDARG;
 315.197 -      size = prop.uhVal.QuadPart;
 315.198 -    }
 315.199 -    _totalSize += size;
 315.200 -    _sizes.Add(size);
 315.201 -    
 315.202 -    if (openArchiveCallback != NULL)
 315.203 -    {
 315.204 -      UInt64 numFiles = _streams.Size();
 315.205 -      RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
 315.206 -    }
 315.207 -
 315.208 -    for (;;)
 315.209 -    {
 315.210 -      UString fullName = seqName.GetNextName();
 315.211 -      CMyComPtr<IInStream> nextStream;
 315.212 -      HRESULT result = openVolumeCallback->GetStream(fullName, &nextStream);
 315.213 -      if (result == S_FALSE)
 315.214 -        break;
 315.215 -      if (result != S_OK)
 315.216 -        return result;
 315.217 -      if (!stream)
 315.218 -        break;
 315.219 -      {
 315.220 -        NCOM::CPropVariant prop;
 315.221 -        RINOK(openVolumeCallback->GetProperty(kpidSize, &prop));
 315.222 -        if (prop.vt != VT_UI8)
 315.223 -          return E_INVALIDARG;
 315.224 -        size = prop.uhVal.QuadPart;
 315.225 -      }
 315.226 -      _totalSize += size;
 315.227 -      _sizes.Add(size);
 315.228 -      _streams.Add(nextStream);
 315.229 -      if (openArchiveCallback != NULL)
 315.230 -      {
 315.231 -        UInt64 numFiles = _streams.Size();
 315.232 -        RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
 315.233 -      }
 315.234 -    }
 315.235 -  }
 315.236 -  /*
 315.237 -  catch(...)
 315.238 -  {
 315.239 -    return S_FALSE;
 315.240 -  }
 315.241 -  */
 315.242 -  return S_OK;
 315.243 -  COM_TRY_END
 315.244 -}
 315.245 -
 315.246 -STDMETHODIMP CHandler::Close()
 315.247 -{
 315.248 -  _sizes.Clear();
 315.249 -  _streams.Clear();
 315.250 -  return S_OK;
 315.251 -}
 315.252 -
 315.253 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
 315.254 -{
 315.255 -  *numItems = _streams.IsEmpty() ? 0 : 1;
 315.256 -  return S_OK;
 315.257 -}
 315.258 -
 315.259 -STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
 315.260 -{
 315.261 -  NWindows::NCOM::CPropVariant prop;
 315.262 -  switch(propID)
 315.263 -  {
 315.264 -    case kpidPath:
 315.265 -      prop = _subName;
 315.266 -      break;
 315.267 -    case kpidSize:
 315.268 -    case kpidPackSize:
 315.269 -      prop = _totalSize;
 315.270 -      break;
 315.271 -  }
 315.272 -  prop.Detach(value);
 315.273 -  return S_OK;
 315.274 -}
 315.275 -
 315.276 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 315.277 -    Int32 _aTestMode, IArchiveExtractCallback *_anExtractCallback)
 315.278 -{
 315.279 -  COM_TRY_BEGIN
 315.280 -
 315.281 -  if (numItems != UInt32(-1))
 315.282 -  {
 315.283 -    if (numItems != 1)
 315.284 -      return E_INVALIDARG;
 315.285 -    if (indices[0] != 0)
 315.286 -      return E_INVALIDARG;
 315.287 -  }
 315.288 -  bool testMode = (_aTestMode != 0);
 315.289 -  CMyComPtr<IArchiveExtractCallback> extractCallback = _anExtractCallback;
 315.290 -  extractCallback->SetTotal(_totalSize);
 315.291 -  
 315.292 -  /*
 315.293 -  CMyComPtr<IArchiveVolumeExtractCallback> volumeExtractCallback;
 315.294 -  if (extractCallback.QueryInterface(&volumeExtractCallback) != S_OK)
 315.295 -    return E_FAIL;
 315.296 -  */
 315.297 -
 315.298 -  UInt64 currentTotalSize = 0;
 315.299 -  UInt64 currentItemSize;
 315.300 -
 315.301 -  RINOK(extractCallback->SetCompleted(&currentTotalSize));
 315.302 -  CMyComPtr<ISequentialOutStream> realOutStream;
 315.303 -  Int32 askMode;
 315.304 -  askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
 315.305 -  NArchive::NExtract::NAskMode::kExtract;
 315.306 -  Int32 index = 0;
 315.307 -  RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
 315.308 -  
 315.309 -  RINOK(extractCallback->PrepareOperation(askMode));
 315.310 -  if (testMode)
 315.311 -  {
 315.312 -    RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
 315.313 -    return S_OK;
 315.314 -  }
 315.315 -  
 315.316 -  if (!testMode && (!realOutStream))
 315.317 -    return S_OK;
 315.318 -
 315.319 -  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
 315.320 -  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
 315.321 -
 315.322 -  CLocalProgress *lps = new CLocalProgress;
 315.323 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 315.324 -  lps->Init(extractCallback, false);
 315.325 -
 315.326 -  for (int i = 0; i < _streams.Size(); i++, currentTotalSize += currentItemSize)
 315.327 -  {
 315.328 -    lps->InSize = lps->OutSize = currentTotalSize;
 315.329 -    RINOK(lps->SetCur());
 315.330 -    IInStream *inStream = _streams[i];
 315.331 -    RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
 315.332 -    RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
 315.333 -    currentItemSize = copyCoderSpec->TotalSize;
 315.334 -  }
 315.335 -  realOutStream.Release();
 315.336 -  return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK);
 315.337 -  COM_TRY_END
 315.338 -}
 315.339 -
 315.340 -STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
 315.341 -{
 315.342 -  if (index != 0)
 315.343 -    return E_INVALIDARG;
 315.344 -  *stream = 0;
 315.345 -  CMultiStream *streamSpec = new CMultiStream;
 315.346 -  CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
 315.347 -  for (int i = 0; i < _streams.Size(); i++)
 315.348 -  {
 315.349 -    CMultiStream::CSubStreamInfo subStreamInfo;
 315.350 -    subStreamInfo.Stream = _streams[i];
 315.351 -    subStreamInfo.Pos = 0;
 315.352 -    subStreamInfo.Size = _sizes[i];
 315.353 -    streamSpec->Streams.Add(subStreamInfo);
 315.354 -  }
 315.355 -  streamSpec->Init();
 315.356 -  *stream = streamTemp.Detach();
 315.357 -  return S_OK;
 315.358 -}
 315.359 -
 315.360 -}}
   316.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitHandler.h	Sat Mar 03 10:54:39 2012 -0600
   316.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   316.3 @@ -1,37 +0,0 @@
   316.4 -// Split/Handler.h
   316.5 -
   316.6 -#ifndef __SPLIT_HANDLER_H
   316.7 -#define __SPLIT_HANDLER_H
   316.8 -
   316.9 -#include "Common/MyCom.h"
  316.10 -#include "Common/MyString.h"
  316.11 -#include "../IArchive.h"
  316.12 -
  316.13 -namespace NArchive {
  316.14 -namespace NSplit {
  316.15 -
  316.16 -class CHandler:
  316.17 -  public IInArchive,
  316.18 -  public IInArchiveGetStream,
  316.19 -  // public IOutArchive,
  316.20 -  public CMyUnknownImp
  316.21 -{
  316.22 -public:
  316.23 -  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  316.24 -
  316.25 -  INTERFACE_IInArchive(;)
  316.26 -
  316.27 -  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
  316.28 -
  316.29 -private:
  316.30 -  UString _subName;
  316.31 -  UString _name;
  316.32 -  CObjectVector<CMyComPtr<IInStream> > _streams;
  316.33 -  CRecordVector<UInt64> _sizes;
  316.34 -
  316.35 -  UInt64 _totalSize;
  316.36 -};
  316.37 -
  316.38 -}}
  316.39 -
  316.40 -#endif
   317.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Split/SplitRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   317.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   317.3 @@ -1,20 +0,0 @@
   317.4 -// SplitRegister.cpp
   317.5 -
   317.6 -#include "StdAfx.h"
   317.7 -
   317.8 -#include "../../Common/RegisterArc.h"
   317.9 -
  317.10 -#include "SplitHandler.h"
  317.11 -static IInArchive *CreateArc() { return new NArchive::NSplit::CHandler;  }
  317.12 -/*
  317.13 -#ifndef EXTRACT_ONLY
  317.14 -static IOutArchive *CreateArcOut() { return new NArchive::NSplit::CHandler;  }
  317.15 -#else
  317.16 -#define CreateArcOut 0
  317.17 -#endif
  317.18 -*/
  317.19 -
  317.20 -static CArcInfo g_ArcInfo =
  317.21 -{ L"Split", L"001", 0, 0xEA, { 0 }, 0, false, CreateArc, 0 };
  317.22 -
  317.23 -REGISTER_ARC(Split)
   318.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Split/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   318.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   318.3 @@ -1,8 +0,0 @@
   318.4 -// StdAfx.h
   318.5 -
   318.6 -#ifndef __STDAFX_H
   318.7 -#define __STDAFX_H
   318.8 -
   318.9 -#include "../../../Common/MyWindows.h"
  318.10 -
  318.11 -#endif
   319.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   319.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   319.3 @@ -1,9 +0,0 @@
   319.4 -// StdAfx.h
   319.5 -
   319.6 -#ifndef __STDAFX_H
   319.7 -#define __STDAFX_H
   319.8 -
   319.9 -#include "../../Common/MyWindows.h"
  319.10 -#include "../../Common/NewHandler.h"
  319.11 -
  319.12 -#endif
   320.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   320.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   320.3 @@ -1,9 +0,0 @@
   320.4 -// StdAfx.h
   320.5 -
   320.6 -#ifndef __STDAFX_H
   320.7 -#define __STDAFX_H
   320.8 -
   320.9 -#include "../../../Common/MyWindows.h"
  320.10 -#include "../../../Common/NewHandler.h"
  320.11 -
  320.12 -#endif
   321.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   321.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   321.3 @@ -1,229 +0,0 @@
   321.4 -// TarHandler.cpp
   321.5 -
   321.6 -#include "StdAfx.h"
   321.7 -
   321.8 -#include "Common/ComTry.h"
   321.9 -#include "Common/Defs.h"
  321.10 -#include "Common/NewHandler.h"
  321.11 -#include "Common/StringConvert.h"
  321.12 -
  321.13 -#include "Windows/PropVariant.h"
  321.14 -#include "Windows/Time.h"
  321.15 -
  321.16 -#include "../../Common/LimitedStreams.h"
  321.17 -#include "../../Common/ProgressUtils.h"
  321.18 -
  321.19 -#include "../../Compress/CopyCoder.h"
  321.20 -
  321.21 -#include "../Common/DummyOutStream.h"
  321.22 -#include "../Common/ItemNameUtils.h"
  321.23 -
  321.24 -#include "TarHandler.h"
  321.25 -#include "TarIn.h"
  321.26 -
  321.27 -using namespace NWindows;
  321.28 -
  321.29 -namespace NArchive {
  321.30 -namespace NTar {
  321.31 -
  321.32 -STATPROPSTG kProps[] =
  321.33 -{
  321.34 -  { NULL, kpidPath, VT_BSTR},
  321.35 -  { NULL, kpidIsDir, VT_BOOL},
  321.36 -  { NULL, kpidSize, VT_UI8},
  321.37 -  { NULL, kpidPackSize, VT_UI8},
  321.38 -  { NULL, kpidMTime, VT_FILETIME},
  321.39 -  { NULL, kpidUser, VT_BSTR},
  321.40 -  { NULL, kpidGroup, VT_BSTR}
  321.41 -};
  321.42 -
  321.43 -IMP_IInArchive_Props
  321.44 -IMP_IInArchive_ArcProps_NO
  321.45 -
  321.46 -HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
  321.47 -{
  321.48 -  UInt64 endPos = 0;
  321.49 -  if (callback != NULL)
  321.50 -  {
  321.51 -    RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
  321.52 -    RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
  321.53 -  }
  321.54 -  
  321.55 -  UInt64 pos = 0;
  321.56 -  for (;;)
  321.57 -  {
  321.58 -    CItemEx item;
  321.59 -    bool filled;
  321.60 -    item.HeaderPosition = pos;
  321.61 -    RINOK(ReadItem(stream, filled, item));
  321.62 -    if (!filled)
  321.63 -      break;
  321.64 -    _items.Add(item);
  321.65 -    
  321.66 -    RINOK(stream->Seek(item.GetPackSize(), STREAM_SEEK_CUR, &pos));
  321.67 -    if (pos >= endPos)
  321.68 -      return S_FALSE;
  321.69 -    if (callback != NULL)
  321.70 -    {
  321.71 -      if (_items.Size() == 1)
  321.72 -      {
  321.73 -        RINOK(callback->SetTotal(NULL, &endPos));
  321.74 -      }
  321.75 -      if (_items.Size() % 100 == 0)
  321.76 -      {
  321.77 -        UInt64 numFiles = _items.Size();
  321.78 -        RINOK(callback->SetCompleted(&numFiles, &pos));
  321.79 -      }
  321.80 -    }
  321.81 -  }
  321.82 -
  321.83 -  if (_items.Size() == 0)
  321.84 -  {
  321.85 -    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
  321.86 -    if (!callback)
  321.87 -      return S_FALSE;
  321.88 -    callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
  321.89 -    if (!openVolumeCallback)
  321.90 -      return S_FALSE;
  321.91 -    NCOM::CPropVariant prop;
  321.92 -    if (openVolumeCallback->GetProperty(kpidName, &prop) != S_OK)
  321.93 -      return S_FALSE;
  321.94 -    if (prop.vt != VT_BSTR)
  321.95 -      return S_FALSE;
  321.96 -    UString baseName = prop.bstrVal;
  321.97 -    baseName = baseName.Right(4);
  321.98 -    if (baseName.CompareNoCase(L".tar") != 0)
  321.99 -      return S_FALSE;
 321.100 -  }
 321.101 -  return S_OK;
 321.102 -}
 321.103 -
 321.104 -STDMETHODIMP CHandler::Open(IInStream *stream,
 321.105 -    const UInt64 * /* maxCheckStartPosition */,
 321.106 -    IArchiveOpenCallback *openArchiveCallback)
 321.107 -{
 321.108 -  COM_TRY_BEGIN
 321.109 -  {
 321.110 -    Close();
 321.111 -    RINOK(Open2(stream, openArchiveCallback));
 321.112 -    _inStream = stream;
 321.113 -  }
 321.114 -  return S_OK;
 321.115 -  COM_TRY_END
 321.116 -}
 321.117 -
 321.118 -STDMETHODIMP CHandler::Close()
 321.119 -{
 321.120 -  _items.Clear();
 321.121 -  _inStream.Release();
 321.122 -  return S_OK;
 321.123 -}
 321.124 -
 321.125 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
 321.126 -{
 321.127 -  *numItems = _items.Size();
 321.128 -  return S_OK;
 321.129 -}
 321.130 -
 321.131 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
 321.132 -{
 321.133 -  COM_TRY_BEGIN
 321.134 -  NWindows::NCOM::CPropVariant prop;
 321.135 -  const CItemEx &item = _items[index];
 321.136 -
 321.137 -  switch(propID)
 321.138 -  {
 321.139 -    case kpidPath:  prop = NItemName::GetOSName2(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
 321.140 -    case kpidIsDir:  prop = item.IsDir(); break;
 321.141 -    case kpidSize:  prop = item.Size; break;
 321.142 -    case kpidPackSize:  prop = item.GetPackSize(); break;
 321.143 -    case kpidMTime:
 321.144 -      if (item.MTime != 0)
 321.145 -      {
 321.146 -        FILETIME ft;
 321.147 -        NTime::UnixTimeToFileTime(item.MTime, ft);
 321.148 -        prop = ft;
 321.149 -      }
 321.150 -      break;
 321.151 -    case kpidUser:  prop = MultiByteToUnicodeString(item.UserName, CP_OEMCP); break;
 321.152 -    case kpidGroup:  prop = MultiByteToUnicodeString(item.GroupName, CP_OEMCP); break;
 321.153 -  }
 321.154 -  prop.Detach(value);
 321.155 -  return S_OK;
 321.156 -  COM_TRY_END
 321.157 -}
 321.158 -
 321.159 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 321.160 -    Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
 321.161 -{
 321.162 -  COM_TRY_BEGIN
 321.163 -  bool testMode = (_aTestMode != 0);
 321.164 -  bool allFilesMode = (numItems == UInt32(-1));
 321.165 -  if (allFilesMode)
 321.166 -    numItems = _items.Size();
 321.167 -  if (numItems == 0)
 321.168 -    return S_OK;
 321.169 -  UInt64 totalSize = 0;
 321.170 -  UInt32 i;
 321.171 -  for (i = 0; i < numItems; i++)
 321.172 -    totalSize += _items[allFilesMode ? i : indices[i]].Size;
 321.173 -  extractCallback->SetTotal(totalSize);
 321.174 -
 321.175 -  UInt64 totalPackSize, curPackSize, curSize;
 321.176 -  totalSize = totalPackSize = 0;
 321.177 -  
 321.178 -  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
 321.179 -  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
 321.180 -
 321.181 -  CLocalProgress *lps = new CLocalProgress;
 321.182 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 321.183 -  lps->Init(extractCallback, false);
 321.184 -
 321.185 -  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
 321.186 -  CMyComPtr<ISequentialInStream> inStream(streamSpec);
 321.187 -  streamSpec->SetStream(_inStream);
 321.188 -
 321.189 -  CDummyOutStream *outStreamSpec = new CDummyOutStream;
 321.190 -  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
 321.191 -
 321.192 -  for (i = 0; i < numItems; i++, totalSize += curSize, totalPackSize += curPackSize)
 321.193 -  {
 321.194 -    lps->InSize = totalPackSize;
 321.195 -    lps->OutSize = totalSize;
 321.196 -    RINOK(lps->SetCur());
 321.197 -    CMyComPtr<ISequentialOutStream> realOutStream;
 321.198 -    Int32 askMode = testMode ?
 321.199 -        NArchive::NExtract::NAskMode::kTest :
 321.200 -        NArchive::NExtract::NAskMode::kExtract;
 321.201 -    Int32 index = allFilesMode ? i : indices[i];
 321.202 -    const CItemEx &item = _items[index];
 321.203 -    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
 321.204 -    curSize = item.Size;
 321.205 -    curPackSize = item.GetPackSize();
 321.206 -    if (item.IsDir())
 321.207 -    {
 321.208 -      RINOK(extractCallback->PrepareOperation(askMode));
 321.209 -      RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
 321.210 -      continue;
 321.211 -    }
 321.212 -    if (!testMode && (!realOutStream))
 321.213 -      continue;
 321.214 -    RINOK(extractCallback->PrepareOperation(askMode));
 321.215 -
 321.216 -    outStreamSpec->SetStream(realOutStream);
 321.217 -    realOutStream.Release();
 321.218 -    outStreamSpec->Init();
 321.219 -
 321.220 -    RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
 321.221 -    streamSpec->Init(item.Size);
 321.222 -    RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
 321.223 -    outStreamSpec->ReleaseStream();
 321.224 -    RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == item.Size ?
 321.225 -        NArchive::NExtract::NOperationResult::kOK:
 321.226 -        NArchive::NExtract::NOperationResult::kDataError));
 321.227 -  }
 321.228 -  return S_OK;
 321.229 -  COM_TRY_END
 321.230 -}
 321.231 -
 321.232 -}}
   322.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHandler.h	Sat Mar 03 10:54:39 2012 -0600
   322.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   322.3 @@ -1,37 +0,0 @@
   322.4 -// Tar/Handler.h
   322.5 -
   322.6 -#ifndef __TAR_HANDLER_H
   322.7 -#define __TAR_HANDLER_H
   322.8 -
   322.9 -#include "Common/MyCom.h"
  322.10 -#include "../IArchive.h"
  322.11 -
  322.12 -#include "TarItem.h"
  322.13 -
  322.14 -namespace NArchive {
  322.15 -namespace NTar {
  322.16 -
  322.17 -class CHandler:
  322.18 -  public IInArchive,
  322.19 -  public IOutArchive,
  322.20 -  public CMyUnknownImp
  322.21 -{
  322.22 -public:
  322.23 -  MY_UNKNOWN_IMP2(
  322.24 -    IInArchive,
  322.25 -    IOutArchive
  322.26 -  )
  322.27 -
  322.28 -  INTERFACE_IInArchive(;)
  322.29 -  INTERFACE_IOutArchive(;)
  322.30 -
  322.31 -  HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback);
  322.32 -
  322.33 -private:
  322.34 -  CObjectVector<CItemEx> _items;
  322.35 -  CMyComPtr<IInStream> _inStream;
  322.36 -};
  322.37 -
  322.38 -}}
  322.39 -
  322.40 -#endif
   323.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHeader.cpp	Sat Mar 03 10:54:39 2012 -0600
   323.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   323.3 @@ -1,25 +0,0 @@
   323.4 -// Archive/Tar/Header.h
   323.5 -
   323.6 -#include "StdAfx.h"
   323.7 -
   323.8 -#include "TarHeader.h"
   323.9 -
  323.10 -namespace NArchive {
  323.11 -namespace NTar {
  323.12 -namespace NFileHeader {
  323.13 -
  323.14 -  // The checksum field is filled with this while the checksum is computed.
  323.15 -  const char *kCheckSumBlanks = "        ";   // 8 blanks, no null
  323.16 -
  323.17 -  const char *kLongLink = "././@LongLink";
  323.18 -  const char *kLongLink2 = "@LongLink";
  323.19 -
  323.20 -  // The magic field is filled with this if uname and gname are valid.
  323.21 -  namespace NMagic
  323.22 -  {
  323.23 -    const char *kUsTar  = "ustar"; // 5 chars
  323.24 -    const char *kGNUTar = "GNUtar "; // 7 chars and a null
  323.25 -    const char *kEmpty = "\0\0\0\0\0\0\0\0"; // 7 chars and a null
  323.26 -  }
  323.27 -
  323.28 -}}}
   324.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarHeader.h	Sat Mar 03 10:54:39 2012 -0600
   324.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   324.3 @@ -1,108 +0,0 @@
   324.4 -// Archive/Tar/Header.h
   324.5 -
   324.6 -#ifndef __ARCHIVE_TAR_HEADER_H
   324.7 -#define __ARCHIVE_TAR_HEADER_H
   324.8 -
   324.9 -#include "Common/Types.h"
  324.10 -
  324.11 -namespace NArchive {
  324.12 -namespace NTar {
  324.13 -
  324.14 -namespace NFileHeader
  324.15 -{
  324.16 -  const int kRecordSize = 512;
  324.17 -  const int kNameSize = 100;
  324.18 -  const int kUserNameSize = 32;
  324.19 -  const int kGroupNameSize = 32;
  324.20 -  const int kPrefixSize = 155;
  324.21 -
  324.22 -  /*
  324.23 -  struct CHeader
  324.24 -  {
  324.25 -    char Name[kNameSize];
  324.26 -    char Mode[8];
  324.27 -    char UID[8];
  324.28 -    char GID[8];
  324.29 -    char Size[12];
  324.30 -    char ModificationTime[12];
  324.31 -    char CheckSum[8];
  324.32 -    char LinkFlag;
  324.33 -    char LinkName[kNameSize];
  324.34 -    char Magic[8];
  324.35 -    char UserName[kUserNameSize];
  324.36 -    char GroupName[kGroupNameSize];
  324.37 -    char DeviceMajor[8];
  324.38 -    char DeviceMinor[8];
  324.39 -    char Prefix[155];
  324.40 -  };
  324.41 -  union CRecord
  324.42 -  {
  324.43 -    CHeader Header;
  324.44 -    Byte Padding[kRecordSize];
  324.45 -  };
  324.46 -  */
  324.47 -
  324.48 -  namespace NMode
  324.49 -  {
  324.50 -    const int kSetUID   = 04000;  // Set UID on execution
  324.51 -    const int kSetGID   = 02000;  // Set GID on execution
  324.52 -    const int kSaveText = 01000;  // Save text (sticky bit)
  324.53 -  }
  324.54 -
  324.55 -  namespace NFilePermissions
  324.56 -  {
  324.57 -    const int kUserRead     = 00400;  // read by owner
  324.58 -    const int kUserWrite    = 00200;  // write by owner
  324.59 -    const int kUserExecute  = 00100;  // execute/search by owner
  324.60 -    const int kGroupRead    = 00040;  // read by group
  324.61 -    const int kGroupWrite   = 00020;  // write by group
  324.62 -    const int kGroupExecute = 00010;  // execute/search by group
  324.63 -    const int kOtherRead    = 00004;  // read by other
  324.64 -    const int kOtherWrite   = 00002;  // write by other
  324.65 -    const int kOtherExecute = 00001;  // execute/search by other
  324.66 -  }
  324.67 -
  324.68 -
  324.69 -  // The linkflag defines the type of file
  324.70 -  namespace NLinkFlag
  324.71 -  {
  324.72 -    const char kOldNormal    = '\0'; // Normal disk file, Unix compatible
  324.73 -    const char kNormal       = '0'; // Normal disk file
  324.74 -    const char kLink         = '1'; // Link to previously dumped file
  324.75 -    const char kSymbolicLink = '2'; // Symbolic link
  324.76 -    const char kCharacter    = '3'; // Character special file
  324.77 -    const char kBlock        = '4'; // Block special file
  324.78 -    const char kDirectory    = '5'; // Directory
  324.79 -    const char kFIFO         = '6'; // FIFO special file
  324.80 -    const char kContiguous   = '7'; // Contiguous file
  324.81 -
  324.82 -    const char kDumpDir       = 'D'; /* GNUTYPE_DUMPDIR.
  324.83 -      data: list of files created by the --incremental (-G) option
  324.84 -      Each file name is preceded by either
  324.85 -        - 'Y' (file should be in this archive)
  324.86 -        - 'N' (file is a directory, or is not stored in the archive.)
  324.87 -        Each file name is terminated by a null + an additional null after
  324.88 -        the last file name. */
  324.89 -
  324.90 -  }
  324.91 -  // Further link types may be defined later.
  324.92 -
  324.93 -  // The checksum field is filled with this while the checksum is computed.
  324.94 -  extern const char *kCheckSumBlanks;//   = "        ";   // 8 blanks, no null
  324.95 -
  324.96 -  extern const char *kLongLink;  //   = "././@LongLink";
  324.97 -  extern const char *kLongLink2; //   = "@LongLink";
  324.98 -
  324.99 -  // The magic field is filled with this if uname and gname are valid.
 324.100 -  namespace NMagic
 324.101 -  {
 324.102 -    extern const char *kUsTar; //   = "ustar"; // 5 chars
 324.103 -    extern const char *kGNUTar; //  = "GNUtar "; // 7 chars and a null
 324.104 -    extern const char *kEmpty; //  = "GNUtar "; // 7 chars and a null
 324.105 -  }
 324.106 -
 324.107 -}
 324.108 -
 324.109 -}}
 324.110 -
 324.111 -#endif
   325.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   325.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   325.3 @@ -1,176 +0,0 @@
   325.4 -// Archive/TarIn.cpp
   325.5 -
   325.6 -#include "StdAfx.h"
   325.7 -
   325.8 -#include "TarIn.h"
   325.9 -#include "TarHeader.h"
  325.10 -
  325.11 -#include "Common/StringToInt.h"
  325.12 -#include "Windows/Defs.h"
  325.13 -
  325.14 -#include "../../Common/StreamUtils.h"
  325.15 -
  325.16 -namespace NArchive {
  325.17 -namespace NTar {
  325.18 - 
  325.19 -static void MyStrNCpy(char *dest, const char *src, int size)
  325.20 -{
  325.21 -  for (int i = 0; i < size; i++)
  325.22 -  {
  325.23 -    char c = src[i];
  325.24 -    dest[i] = c;
  325.25 -    if (c == 0)
  325.26 -      break;
  325.27 -  }
  325.28 -}
  325.29 -
  325.30 -static bool OctalToNumber(const char *srcString, int size, UInt64 &res)
  325.31 -{
  325.32 -  char sz[32];
  325.33 -  MyStrNCpy(sz, srcString, size);
  325.34 -  sz[size] = 0;
  325.35 -  const char *end;
  325.36 -  int i;
  325.37 -  for (i = 0; sz[i] == ' '; i++);
  325.38 -  res = ConvertOctStringToUInt64(sz + i, &end);
  325.39 -  return (*end == ' ' || *end == 0);
  325.40 -}
  325.41 -
  325.42 -static bool OctalToNumber32(const char *srcString, int size, UInt32 &res)
  325.43 -{
  325.44 -  UInt64 res64;
  325.45 -  if (!OctalToNumber(srcString, size, res64))
  325.46 -    return false;
  325.47 -  res = (UInt32)res64;
  325.48 -  return (res64 <= 0xFFFFFFFF);
  325.49 -}
  325.50 -
  325.51 -#define RIF(x) { if (!(x)) return S_FALSE; }
  325.52 -
  325.53 -static bool IsRecordLast(const char *buf)
  325.54 -{
  325.55 -  for (int i = 0; i < NFileHeader::kRecordSize; i++)
  325.56 -    if (buf[i] != 0)
  325.57 -      return false;
  325.58 -  return true;
  325.59 -}
  325.60 -
  325.61 -static void ReadString(const char *s, int size, AString &result)
  325.62 -{
  325.63 -  char temp[NFileHeader::kRecordSize + 1];
  325.64 -  MyStrNCpy(temp, s, size);
  325.65 -  temp[size] = '\0';
  325.66 -  result = temp;
  325.67 -}
  325.68 -
  325.69 -static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemEx &item, size_t &processedSize)
  325.70 -{
  325.71 -  item.LongLinkSize = 0;
  325.72 -  char buf[NFileHeader::kRecordSize];
  325.73 -  char *p = buf;
  325.74 -
  325.75 -  filled = false;
  325.76 -
  325.77 -  processedSize = NFileHeader::kRecordSize;
  325.78 -  RINOK(ReadStream(stream, buf, &processedSize));
  325.79 -  if (processedSize == 0 || (processedSize == NFileHeader::kRecordSize && IsRecordLast(buf)))
  325.80 -    return S_OK;
  325.81 -  if (processedSize < NFileHeader::kRecordSize)
  325.82 -    return S_FALSE;
  325.83 -  
  325.84 -  ReadString(p, NFileHeader::kNameSize, item.Name); p += NFileHeader::kNameSize;
  325.85 -
  325.86 -  RIF(OctalToNumber32(p, 8, item.Mode)); p += 8;
  325.87 -
  325.88 -  if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
  325.89 -  if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;
  325.90 -
  325.91 -  RIF(OctalToNumber(p, 12, item.Size)); p += 12;
  325.92 -  RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
  325.93 -  
  325.94 -  UInt32 checkSum;
  325.95 -  RIF(OctalToNumber32(p, 8, checkSum));
  325.96 -  memcpy(p, NFileHeader::kCheckSumBlanks, 8); p += 8;
  325.97 -
  325.98 -  item.LinkFlag = *p++;
  325.99 -
 325.100 -  ReadString(p, NFileHeader::kNameSize, item.LinkName); p += NFileHeader::kNameSize;
 325.101 -
 325.102 -  memcpy(item.Magic, p, 8); p += 8;
 325.103 -
 325.104 -  ReadString(p, NFileHeader::kUserNameSize, item.UserName);  p += NFileHeader::kUserNameSize;
 325.105 -  ReadString(p, NFileHeader::kUserNameSize, item.GroupName); p += NFileHeader::kUserNameSize;
 325.106 -
 325.107 -  item.DeviceMajorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMajor)); p += 8;
 325.108 -  item.DeviceMinorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMinor)); p += 8;
 325.109 -
 325.110 -  AString prefix;
 325.111 -  ReadString(p, NFileHeader::kPrefixSize, prefix);
 325.112 -  p += NFileHeader::kPrefixSize;
 325.113 -  if (!prefix.IsEmpty() && item.IsMagic() &&
 325.114 -      (item.LinkFlag != 'L' /* || prefix != "00000000000" */ ))
 325.115 -    item.Name = prefix + AString('/') + item.Name;
 325.116 -
 325.117 -  if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
 325.118 -    item.Size = 0;
 325.119 - 
 325.120 -  UInt32 checkSumReal = 0;
 325.121 -  for (int i = 0; i < NFileHeader::kRecordSize; i++)
 325.122 -    checkSumReal += (Byte)buf[i];
 325.123 -  
 325.124 -  if (checkSumReal != checkSum)
 325.125 -    return S_FALSE;
 325.126 -
 325.127 -  filled = true;
 325.128 -  return S_OK;
 325.129 -}
 325.130 -
 325.131 -HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item)
 325.132 -{
 325.133 -  size_t processedSize;
 325.134 -  RINOK(GetNextItemReal(stream, filled, item, processedSize));
 325.135 -  if (!filled)
 325.136 -    return S_OK;
 325.137 -  // GNUtar extension
 325.138 -  if (item.LinkFlag == 'L')
 325.139 -  {
 325.140 -    if (item.Name.Compare(NFileHeader::kLongLink) != 0)
 325.141 -      if (item.Name.Compare(NFileHeader::kLongLink2) != 0)
 325.142 -        return S_FALSE;
 325.143 -
 325.144 -    AString fullName;
 325.145 -    if (item.Size > (1 << 15))
 325.146 -      return S_FALSE;
 325.147 -    int packSize = (int)item.GetPackSize();
 325.148 -    char *buffer = fullName.GetBuffer(packSize + 1);
 325.149 -
 325.150 -    RINOK(ReadStream_FALSE(stream, buffer, packSize));
 325.151 -    processedSize += packSize;
 325.152 -    buffer[item.Size] = '\0';
 325.153 -    fullName.ReleaseBuffer();
 325.154 -
 325.155 -    UInt64 headerPosition = item.HeaderPosition;
 325.156 -    {
 325.157 -      size_t processedSize2;
 325.158 -      RINOK(GetNextItemReal(stream, filled, item, processedSize2));
 325.159 -    }
 325.160 -    item.LongLinkSize = (unsigned)processedSize;
 325.161 -    item.Name = fullName;
 325.162 -    item.HeaderPosition = headerPosition;
 325.163 -  }
 325.164 -  else if (item.LinkFlag == 'g' || item.LinkFlag == 'x' || item.LinkFlag == 'X')
 325.165 -  {
 325.166 -    // pax Extended Header
 325.167 -    return S_OK;
 325.168 -  }
 325.169 -  else if (item.LinkFlag == NFileHeader::NLinkFlag::kDumpDir)
 325.170 -  {
 325.171 -    // GNU Extensions to the Archive Format
 325.172 -    return S_OK;
 325.173 -  }
 325.174 -  else if (item.LinkFlag > '7' || (item.LinkFlag < '0' && item.LinkFlag != 0))
 325.175 -    return S_FALSE;
 325.176 -  return S_OK;
 325.177 -}
 325.178 -
 325.179 -}}
   326.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarIn.h	Sat Mar 03 10:54:39 2012 -0600
   326.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   326.3 @@ -1,18 +0,0 @@
   326.4 -// Archive/TarIn.h
   326.5 -
   326.6 -#ifndef __ARCHIVE_TAR_IN_H
   326.7 -#define __ARCHIVE_TAR_IN_H
   326.8 -
   326.9 -#include "Common/MyCom.h"
  326.10 -#include "../../IStream.h"
  326.11 -
  326.12 -#include "TarItem.h"
  326.13 -
  326.14 -namespace NArchive {
  326.15 -namespace NTar {
  326.16 -  
  326.17 -HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo);
  326.18 -
  326.19 -}}
  326.20 -  
  326.21 -#endif
   327.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarItem.h	Sat Mar 03 10:54:39 2012 -0600
   327.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   327.3 @@ -1,71 +0,0 @@
   327.4 -// Archive/Tar/Item.h
   327.5 -
   327.6 -#ifndef __ARCHIVE_TAR_ITEM_H
   327.7 -#define __ARCHIVE_TAR_ITEM_H
   327.8 -
   327.9 -#include "Common/Types.h"
  327.10 -#include "Common/MyString.h"
  327.11 -
  327.12 -#include "../Common/ItemNameUtils.h"
  327.13 -#include "TarHeader.h"
  327.14 -
  327.15 -namespace NArchive {
  327.16 -namespace NTar {
  327.17 -
  327.18 -struct CItem
  327.19 -{
  327.20 -  AString Name;
  327.21 -  UInt64 Size;
  327.22 -
  327.23 -  UInt32 Mode;
  327.24 -  UInt32 UID;
  327.25 -  UInt32 GID;
  327.26 -  UInt32 MTime;
  327.27 -  UInt32 DeviceMajor;
  327.28 -  UInt32 DeviceMinor;
  327.29 -
  327.30 -  AString LinkName;
  327.31 -  AString UserName;
  327.32 -  AString GroupName;
  327.33 -
  327.34 -  char Magic[8];
  327.35 -  char LinkFlag;
  327.36 -  bool DeviceMajorDefined;
  327.37 -  bool DeviceMinorDefined;
  327.38 -
  327.39 -  bool IsDir() const
  327.40 -  {
  327.41 -    switch(LinkFlag)
  327.42 -    {
  327.43 -      case NFileHeader::NLinkFlag::kDirectory:
  327.44 -      case NFileHeader::NLinkFlag::kDumpDir:
  327.45 -        return true;
  327.46 -      case NFileHeader::NLinkFlag::kOldNormal:
  327.47 -      case NFileHeader::NLinkFlag::kNormal:
  327.48 -        return NItemName::HasTailSlash(Name, CP_OEMCP);
  327.49 -    }
  327.50 -    return false;
  327.51 -  }
  327.52 -
  327.53 -  bool IsMagic() const
  327.54 -  {
  327.55 -    for (int i = 0; i < 5; i++)
  327.56 -      if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
  327.57 -        return false;
  327.58 -    return true;
  327.59 -  }
  327.60 -
  327.61 -  UInt64 GetPackSize() const { return (Size + 0x1FF) & (~((UInt64)0x1FF)); }
  327.62 -};
  327.63 -
  327.64 -struct CItemEx: public CItem
  327.65 -{
  327.66 -  UInt64 HeaderPosition;
  327.67 -  unsigned LongLinkSize;
  327.68 -  UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; }
  327.69 -  UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; }
  327.70 -};
  327.71 -
  327.72 -}}
  327.73 -
  327.74 -#endif
   328.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Tar/TarRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   328.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   328.3 @@ -1,18 +0,0 @@
   328.4 -// TarRegister.cpp
   328.5 -
   328.6 -#include "StdAfx.h"
   328.7 -
   328.8 -#include "../../Common/RegisterArc.h"
   328.9 -
  328.10 -#include "TarHandler.h"
  328.11 -static IInArchive *CreateArc() { return new NArchive::NTar::CHandler;  }
  328.12 -#ifndef EXTRACT_ONLY
  328.13 -static IOutArchive *CreateArcOut() { return new NArchive::NTar::CHandler;  }
  328.14 -#else
  328.15 -#define CreateArcOut 0
  328.16 -#endif
  328.17 -
  328.18 -static CArcInfo g_ArcInfo =
  328.19 -{ L"Tar", L"tar", 0, 0xEE, { 'u', 's', 't', 'a', 'r' }, 5, false, CreateArc, CreateArcOut };
  328.20 -
  328.21 -REGISTER_ARC(Tar)
   329.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   329.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   329.3 @@ -1,8 +0,0 @@
   329.4 -// StdAfx.h
   329.5 -
   329.6 -#ifndef __STDAFX_H
   329.7 -#define __STDAFX_H
   329.8 -
   329.9 -#include "../../../Common/MyWindows.h"
  329.10 -
  329.11 -#endif
   330.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h	Sat Mar 03 10:54:39 2012 -0600
   330.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   330.3 @@ -1,39 +0,0 @@
   330.4 -// CompressionMode.h
   330.5 -
   330.6 -#ifndef __ZIP_COMPRESSIONMETHOD_H
   330.7 -#define __ZIP_COMPRESSIONMETHOD_H
   330.8 -
   330.9 -#include "../../../Common/MyString.h"
  330.10 -
  330.11 -namespace NArchive {
  330.12 -namespace NZip {
  330.13 -
  330.14 -struct CCompressionMethodMode
  330.15 -{
  330.16 -  CRecordVector<Byte> MethodSequence;
  330.17 -  UString MatchFinder;
  330.18 -  UInt32 Algo;
  330.19 -  UInt32 NumPasses;
  330.20 -  UInt32 NumFastBytes;
  330.21 -  bool NumMatchFinderCyclesDefined;
  330.22 -  UInt32 NumMatchFinderCycles;
  330.23 -  UInt32 DicSize;
  330.24 -  #ifdef COMPRESS_MT
  330.25 -  UInt32 NumThreads;
  330.26 -  #endif
  330.27 -  bool PasswordIsDefined;
  330.28 -  AString Password;
  330.29 -  bool IsAesMode;
  330.30 -  Byte AesKeyMode;
  330.31 -  
  330.32 -  CCompressionMethodMode():
  330.33 -      NumMatchFinderCyclesDefined(false),
  330.34 -      PasswordIsDefined(false),
  330.35 -      IsAesMode(false),
  330.36 -      AesKeyMode(3)
  330.37 -      {}
  330.38 -};
  330.39 -
  330.40 -}}
  330.41 -
  330.42 -#endif
   331.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   331.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   331.3 @@ -1,831 +0,0 @@
   331.4 -// ZipHandler.cpp
   331.5 -
   331.6 -#include "StdAfx.h"
   331.7 -
   331.8 -#include "Common/ComTry.h"
   331.9 -#include "Common/Defs.h"
  331.10 -#include "Common/IntToString.h"
  331.11 -#include "Common/StringConvert.h"
  331.12 -
  331.13 -#include "Windows/PropVariant.h"
  331.14 -#include "Windows/Time.h"
  331.15 -
  331.16 -#include "../../IPassword.h"
  331.17 -
  331.18 -#include "../../Common/CreateCoder.h"
  331.19 -#include "../../Common/FilterCoder.h"
  331.20 -#include "../../Common/ProgressUtils.h"
  331.21 -#include "../../Common/StreamObjects.h"
  331.22 -#include "../../Common/StreamUtils.h"
  331.23 -
  331.24 -#include "../../Compress/CopyCoder.h"
  331.25 -#include "../../Compress/LzmaDecoder.h"
  331.26 -#include "../../Compress/ImplodeDecoder.h"
  331.27 -#include "../../Compress/ShrinkDecoder.h"
  331.28 -
  331.29 -#include "../../Crypto/WzAes.h"
  331.30 -#include "../../Crypto/ZipCrypto.h"
  331.31 -#include "../../Crypto/ZipStrong.h"
  331.32 -
  331.33 -#include "../Common/ItemNameUtils.h"
  331.34 -#include "../Common/OutStreamWithCRC.h"
  331.35 -
  331.36 -#include "ZipHandler.h"
  331.37 -
  331.38 -using namespace NWindows;
  331.39 -
  331.40 -namespace NArchive {
  331.41 -namespace NZip {
  331.42 -
  331.43 -// static const CMethodId kMethodId_Store = 0;
  331.44 -static const CMethodId kMethodId_ZipBase = 0x040100;
  331.45 -static const CMethodId kMethodId_BZip2 = 0x040202;
  331.46 -
  331.47 -const wchar_t *kHostOS[] =
  331.48 -{
  331.49 -  L"FAT",
  331.50 -  L"AMIGA",
  331.51 -  L"VMS",
  331.52 -  L"Unix",
  331.53 -  L"VM/CMS",
  331.54 -  L"Atari",
  331.55 -  L"HPFS",
  331.56 -  L"Macintosh",
  331.57 -  L"Z-System",
  331.58 -  L"CP/M",
  331.59 -  L"TOPS-20",
  331.60 -  L"NTFS",
  331.61 -  L"SMS/QDOS",
  331.62 -  L"Acorn",
  331.63 -  L"VFAT",
  331.64 -  L"MVS",
  331.65 -  L"BeOS",
  331.66 -  L"Tandem",
  331.67 -  L"OS/400",
  331.68 -  L"OS/X"
  331.69 -};
  331.70 -
  331.71 -
  331.72 -static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
  331.73 -
  331.74 -static const wchar_t *kUnknownOS = L"Unknown";
  331.75 -
  331.76 -STATPROPSTG kProps[] =
  331.77 -{
  331.78 -  { NULL, kpidPath, VT_BSTR},
  331.79 -  { NULL, kpidIsDir, VT_BOOL},
  331.80 -  { NULL, kpidSize, VT_UI8},
  331.81 -  { NULL, kpidPackSize, VT_UI8},
  331.82 -  { NULL, kpidMTime, VT_FILETIME},
  331.83 -  { NULL, kpidCTime, VT_FILETIME},
  331.84 -  { NULL, kpidATime, VT_FILETIME},
  331.85 -  
  331.86 -  { NULL, kpidAttrib, VT_UI4},
  331.87 -
  331.88 -  { NULL, kpidEncrypted, VT_BOOL},
  331.89 -  { NULL, kpidComment, VT_BSTR},
  331.90 -    
  331.91 -  { NULL, kpidCRC, VT_UI4},
  331.92 -
  331.93 -  { NULL, kpidMethod, VT_BSTR},
  331.94 -  { NULL, kpidHostOS, VT_BSTR}
  331.95 -
  331.96 -  // { NULL, kpidUnpackVer, VT_UI1},
  331.97 -};
  331.98 -
  331.99 -const wchar_t *kMethods[] =
 331.100 -{
 331.101 -  L"Store",
 331.102 -  L"Shrink",
 331.103 -  L"Reduced1",
 331.104 -  L"Reduced2",
 331.105 -  L"Reduced2",
 331.106 -  L"Reduced3",
 331.107 -  L"Implode",
 331.108 -  L"Tokenizing",
 331.109 -  L"Deflate",
 331.110 -  L"Deflate64",
 331.111 -  L"PKImploding"
 331.112 -};
 331.113 -
 331.114 -const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
 331.115 -const wchar_t *kBZip2Method = L"BZip2";
 331.116 -const wchar_t *kLZMAMethod = L"LZMA";
 331.117 -const wchar_t *kJpegMethod = L"Jpeg";
 331.118 -const wchar_t *kWavPackMethod = L"WavPack";
 331.119 -const wchar_t *kPPMdMethod = L"PPMd";
 331.120 -const wchar_t *kAESMethod = L"AES";
 331.121 -const wchar_t *kZipCryptoMethod = L"ZipCrypto";
 331.122 -const wchar_t *kStrongCryptoMethod = L"StrongCrypto";
 331.123 -
 331.124 -struct CStrongCryptoPair
 331.125 -{
 331.126 -  UInt16 Id;
 331.127 -  const wchar_t *Name;
 331.128 -};
 331.129 -
 331.130 -CStrongCryptoPair g_StrongCryptoPairs[] =
 331.131 -{
 331.132 -  { NStrongCryptoFlags::kDES, L"DES" },
 331.133 -  { NStrongCryptoFlags::kRC2old, L"RC2a" },
 331.134 -  { NStrongCryptoFlags::k3DES168, L"3DES-168" },
 331.135 -  { NStrongCryptoFlags::k3DES112, L"3DES-112" },
 331.136 -  { NStrongCryptoFlags::kAES128, L"pkAES-128" },
 331.137 -  { NStrongCryptoFlags::kAES192, L"pkAES-192" },
 331.138 -  { NStrongCryptoFlags::kAES256, L"pkAES-256" },
 331.139 -  { NStrongCryptoFlags::kRC2, L"RC2" },
 331.140 -  { NStrongCryptoFlags::kBlowfish, L"Blowfish" },
 331.141 -  { NStrongCryptoFlags::kTwofish, L"Twofish" },
 331.142 -  { NStrongCryptoFlags::kRC4, L"RC4" }
 331.143 -};
 331.144 -
 331.145 -STATPROPSTG kArcProps[] =
 331.146 -{
 331.147 -  { NULL, kpidBit64, VT_BOOL},
 331.148 -  { NULL, kpidComment, VT_BSTR}
 331.149 -};
 331.150 -
 331.151 -CHandler::CHandler()
 331.152 -{
 331.153 -  InitMethodProperties();
 331.154 -}
 331.155 -
 331.156 -static AString BytesToString(const CByteBuffer &data)
 331.157 -{
 331.158 -  AString s;
 331.159 -  int size = (int)data.GetCapacity();
 331.160 -  if (size > 0)
 331.161 -  {
 331.162 -    char *p = s.GetBuffer(size + 1);
 331.163 -    memcpy(p, (const Byte *)data, size);
 331.164 -    p[size] = '\0';
 331.165 -    s.ReleaseBuffer();
 331.166 -  }
 331.167 -  return s;
 331.168 -}
 331.169 -
 331.170 -IMP_IInArchive_Props
 331.171 -IMP_IInArchive_ArcProps
 331.172 -
 331.173 -STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
 331.174 -{
 331.175 -  COM_TRY_BEGIN
 331.176 -  NWindows::NCOM::CPropVariant prop;
 331.177 -  switch(propID)
 331.178 -  {
 331.179 -    case kpidBit64:  if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break;
 331.180 -    case kpidComment:
 331.181 -      prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP);
 331.182 -      break;
 331.183 -  }
 331.184 -  prop.Detach(value);
 331.185 -  COM_TRY_END
 331.186 -  return S_OK;
 331.187 -}
 331.188 -
 331.189 -STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
 331.190 -{
 331.191 -  *numItems = m_Items.Size();
 331.192 -  return S_OK;
 331.193 -}
 331.194 -
 331.195 -STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
 331.196 -{
 331.197 -  COM_TRY_BEGIN
 331.198 -  NWindows::NCOM::CPropVariant prop;
 331.199 -  const CItemEx &item = m_Items[index];
 331.200 -  switch(propID)
 331.201 -  {
 331.202 -    case kpidPath:  prop = NItemName::GetOSName2(item.GetUnicodeString(item.Name)); break;
 331.203 -    case kpidIsDir:  prop = item.IsDir(); break;
 331.204 -    case kpidSize:  prop = item.UnPackSize; break;
 331.205 -    case kpidPackSize:  prop = item.PackSize; break;
 331.206 -    case kpidTimeType:
 331.207 -    {
 331.208 -      FILETIME utcFileTime;
 331.209 -      if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kTagTime, utcFileTime))
 331.210 -        prop = (UInt32)NFileTimeType::kWindows;
 331.211 -      break;
 331.212 -    }
 331.213 -    case kpidCTime:
 331.214 -    {
 331.215 -      FILETIME ft;
 331.216 -      if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kCTime, ft))
 331.217 -        prop = ft;
 331.218 -      break;
 331.219 -    }
 331.220 -    case kpidATime:
 331.221 -    {
 331.222 -      FILETIME ft;
 331.223 -      if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kATime, ft))
 331.224 -        prop = ft;
 331.225 -      break;
 331.226 -    }
 331.227 -    case kpidMTime:
 331.228 -    {
 331.229 -      FILETIME utcFileTime;
 331.230 -      if (!item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kMTime, utcFileTime))
 331.231 -      {
 331.232 -        FILETIME localFileTime;
 331.233 -        if (NTime::DosTimeToFileTime(item.Time, localFileTime))
 331.234 -        {
 331.235 -          if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
 331.236 -            utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 331.237 -        }
 331.238 -        else
 331.239 -          utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
 331.240 -      }
 331.241 -      prop = utcFileTime;
 331.242 -      break;
 331.243 -    }
 331.244 -    case kpidAttrib:  prop = item.GetWinAttributes(); break;
 331.245 -    case kpidEncrypted:  prop = item.IsEncrypted(); break;
 331.246 -    case kpidComment:  prop = item.GetUnicodeString(BytesToString(item.Comment)); break;
 331.247 -    case kpidCRC:  if (item.IsThereCrc()) prop = item.FileCRC; break;
 331.248 -    case kpidMethod:
 331.249 -    {
 331.250 -      UInt16 methodId = item.CompressionMethod;
 331.251 -      UString method;
 331.252 -      if (item.IsEncrypted())
 331.253 -      {
 331.254 -        if (methodId == NFileHeader::NCompressionMethod::kWzAES)
 331.255 -        {
 331.256 -          method = kAESMethod;
 331.257 -          CWzAesExtraField aesField;
 331.258 -          if (item.CentralExtra.GetWzAesField(aesField))
 331.259 -          {
 331.260 -            method += L"-";
 331.261 -            wchar_t s[32];
 331.262 -            ConvertUInt64ToString((aesField.Strength + 1) * 64 , s);
 331.263 -            method += s;
 331.264 -            method += L" ";
 331.265 -            methodId = aesField.Method;
 331.266 -          }
 331.267 -        }
 331.268 -        else
 331.269 -        {
 331.270 -          if (item.IsStrongEncrypted())
 331.271 -          {
 331.272 -            CStrongCryptoField f;
 331.273 -            bool finded = false;
 331.274 -            if (item.CentralExtra.GetStrongCryptoField(f))
 331.275 -            {
 331.276 -              for (int i = 0; i < sizeof(g_StrongCryptoPairs) / sizeof(g_StrongCryptoPairs[0]); i++)
 331.277 -              {
 331.278 -                const CStrongCryptoPair &pair = g_StrongCryptoPairs[i];
 331.279 -                if (f.AlgId == pair.Id)
 331.280 -                {
 331.281 -                  method += pair.Name;
 331.282 -                  finded = true;
 331.283 -                  break;
 331.284 -                }
 331.285 -              }
 331.286 -            }
 331.287 -            if (!finded)
 331.288 -              method += kStrongCryptoMethod;
 331.289 -          }
 331.290 -          else
 331.291 -            method += kZipCryptoMethod;
 331.292 -          method += L" ";
 331.293 -        }
 331.294 -      }
 331.295 -      if (methodId < kNumMethods)
 331.296 -        method += kMethods[methodId];
 331.297 -      else switch (methodId)
 331.298 -      {
 331.299 -        case NFileHeader::NCompressionMethod::kLZMA:
 331.300 -          method += kLZMAMethod;
 331.301 -          if (item.IsLzmaEOS())
 331.302 -            method += L":EOS";
 331.303 -          break;
 331.304 -        case NFileHeader::NCompressionMethod::kBZip2: method += kBZip2Method; break;
 331.305 -        case NFileHeader::NCompressionMethod::kJpeg: method += kJpegMethod; break;
 331.306 -        case NFileHeader::NCompressionMethod::kWavPack: method += kWavPackMethod; break;
 331.307 -        case NFileHeader::NCompressionMethod::kPPMd: method += kPPMdMethod; break;
 331.308 -        default:
 331.309 -        {
 331.310 -          wchar_t s[32];
 331.311 -          ConvertUInt64ToString(methodId, s);
 331.312 -          method += s;
 331.313 -        }
 331.314 -      }
 331.315 -      prop = method;
 331.316 -      break;
 331.317 -    }
 331.318 -    case kpidHostOS:
 331.319 -      prop = (item.MadeByVersion.HostOS < kNumHostOSes) ?
 331.320 -        (kHostOS[item.MadeByVersion.HostOS]) : kUnknownOS;
 331.321 -      break;
 331.322 -  }
 331.323 -  prop.Detach(value);
 331.324 -  return S_OK;
 331.325 -  COM_TRY_END
 331.326 -}
 331.327 -
 331.328 -class CProgressImp: public CProgressVirt
 331.329 -{
 331.330 -  CMyComPtr<IArchiveOpenCallback> _callback;
 331.331 -public:
 331.332 -  STDMETHOD(SetTotal)(UInt64 numFiles);
 331.333 -  STDMETHOD(SetCompleted)(UInt64 numFiles);
 331.334 -  CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {}
 331.335 -};
 331.336 -
 331.337 -STDMETHODIMP CProgressImp::SetTotal(UInt64 numFiles)
 331.338 -{
 331.339 -  if (_callback)
 331.340 -    return _callback->SetTotal(&numFiles, NULL);
 331.341 -  return S_OK;
 331.342 -}
 331.343 -
 331.344 -STDMETHODIMP CProgressImp::SetCompleted(UInt64 numFiles)
 331.345 -{
 331.346 -  if (_callback)
 331.347 -    return _callback->SetCompleted(&numFiles, NULL);
 331.348 -  return S_OK;
 331.349 -}
 331.350 -
 331.351 -STDMETHODIMP CHandler::Open(IInStream *inStream,
 331.352 -    const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
 331.353 -{
 331.354 -  COM_TRY_BEGIN
 331.355 -  try
 331.356 -  {
 331.357 -    Close();
 331.358 -    RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
 331.359 -    RINOK(m_Archive.Open(inStream, maxCheckStartPosition));
 331.360 -    CProgressImp progressImp(callback);
 331.361 -    return m_Archive.ReadHeaders(m_Items, &progressImp);
 331.362 -  }
 331.363 -  catch(const CInArchiveException &) { Close(); return S_FALSE; }
 331.364 -  catch(...) { Close(); throw; }
 331.365 -  COM_TRY_END
 331.366 -}
 331.367 -
 331.368 -STDMETHODIMP CHandler::Close()
 331.369 -{
 331.370 -  m_Items.Clear();
 331.371 -  m_Archive.Close();
 331.372 -  return S_OK;
 331.373 -}
 331.374 -
 331.375 -//////////////////////////////////////
 331.376 -// CHandler::DecompressItems
 331.377 -
 331.378 -class CLzmaDecoder:
 331.379 -  public ICompressCoder,
 331.380 -  public CMyUnknownImp
 331.381 -{
 331.382 -  NCompress::NLzma::CDecoder *DecoderSpec;
 331.383 -  CMyComPtr<ICompressCoder> Decoder;
 331.384 -public:
 331.385 -  CLzmaDecoder();
 331.386 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 331.387 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 331.388 -
 331.389 -  MY_UNKNOWN_IMP
 331.390 -};
 331.391 -
 331.392 -CLzmaDecoder::CLzmaDecoder()
 331.393 -{
 331.394 -  DecoderSpec = new NCompress::NLzma::CDecoder;
 331.395 -  Decoder = DecoderSpec;
 331.396 -}
 331.397 -
 331.398 -HRESULT CLzmaDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 331.399 -    const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
 331.400 -{
 331.401 -  Byte buf[9];
 331.402 -  RINOK(ReadStream_FALSE(inStream, buf, 9));
 331.403 -  if (buf[2] != 5 || buf[3] != 0)
 331.404 -    return E_NOTIMPL;
 331.405 -  RINOK(DecoderSpec->SetDecoderProperties2(buf + 4, 5));
 331.406 -  return Decoder->Code(inStream, outStream, NULL, outSize, progress);
 331.407 -}
 331.408 -
 331.409 -struct CMethodItem
 331.410 -{
 331.411 -  UInt16 ZipMethod;
 331.412 -  CMyComPtr<ICompressCoder> Coder;
 331.413 -};
 331.414 -
 331.415 -class CZipDecoder
 331.416 -{
 331.417 -  NCrypto::NZip::CDecoder *_zipCryptoDecoderSpec;
 331.418 -  NCrypto::NZipStrong::CDecoder *_pkAesDecoderSpec;
 331.419 -  NCrypto::NWzAes::CDecoder *_wzAesDecoderSpec;
 331.420 -
 331.421 -  CMyComPtr<ICompressFilter> _zipCryptoDecoder;
 331.422 -  CMyComPtr<ICompressFilter> _pkAesDecoder;
 331.423 -  CMyComPtr<ICompressFilter> _wzAesDecoder;
 331.424 -
 331.425 -  CFilterCoder *filterStreamSpec;
 331.426 -  CMyComPtr<ISequentialInStream> filterStream;
 331.427 -  CMyComPtr<ICryptoGetTextPassword> getTextPassword;
 331.428 -  CObjectVector<CMethodItem> methodItems;
 331.429 -
 331.430 -public:
 331.431 -  CZipDecoder():
 331.432 -      _zipCryptoDecoderSpec(0),
 331.433 -      _pkAesDecoderSpec(0),
 331.434 -      _wzAesDecoderSpec(0),
 331.435 -      filterStreamSpec(0) {}
 331.436 -
 331.437 -  HRESULT Decode(
 331.438 -    DECL_EXTERNAL_CODECS_LOC_VARS
 331.439 -    CInArchive &archive, const CItemEx &item,
 331.440 -    ISequentialOutStream *realOutStream,
 331.441 -    IArchiveExtractCallback *extractCallback,
 331.442 -    ICompressProgressInfo *compressProgress,
 331.443 -    UInt32 numThreads, Int32 &res);
 331.444 -};
 331.445 -
 331.446 -HRESULT CZipDecoder::Decode(
 331.447 -    DECL_EXTERNAL_CODECS_LOC_VARS
 331.448 -    CInArchive &archive, const CItemEx &item,
 331.449 -    ISequentialOutStream *realOutStream,
 331.450 -    IArchiveExtractCallback *extractCallback,
 331.451 -    ICompressProgressInfo *compressProgress,
 331.452 -    UInt32 numThreads, Int32 &res)
 331.453 -{
 331.454 -  res = NArchive::NExtract::NOperationResult::kDataError;
 331.455 -  CInStreamReleaser inStreamReleaser;
 331.456 -
 331.457 -  bool needCRC = true;
 331.458 -  bool wzAesMode = false;
 331.459 -  bool pkAesMode = false;
 331.460 -  UInt16 methodId = item.CompressionMethod;
 331.461 -  if (item.IsEncrypted())
 331.462 -  {
 331.463 -    if (item.IsStrongEncrypted())
 331.464 -    {
 331.465 -      CStrongCryptoField f;
 331.466 -      if (item.CentralExtra.GetStrongCryptoField(f))
 331.467 -      {
 331.468 -        pkAesMode = true;
 331.469 -      }
 331.470 -      if (!pkAesMode)
 331.471 -      {
 331.472 -        res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 331.473 -        return S_OK;
 331.474 -      }
 331.475 -    }
 331.476 -    if (methodId == NFileHeader::NCompressionMethod::kWzAES)
 331.477 -    {
 331.478 -      CWzAesExtraField aesField;
 331.479 -      if (item.CentralExtra.GetWzAesField(aesField))
 331.480 -      {
 331.481 -        wzAesMode = true;
 331.482 -        needCRC = aesField.NeedCrc();
 331.483 -      }
 331.484 -    }
 331.485 -  }
 331.486 -    
 331.487 -  COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
 331.488 -  CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
 331.489 -  outStreamSpec->SetStream(realOutStream);
 331.490 -  outStreamSpec->Init(needCRC);
 331.491 -  
 331.492 -  UInt64 authenticationPos;
 331.493 -  
 331.494 -  CMyComPtr<ISequentialInStream> inStream;
 331.495 -  {
 331.496 -    UInt64 packSize = item.PackSize;
 331.497 -    if (wzAesMode)
 331.498 -    {
 331.499 -      if (packSize < NCrypto::NWzAes::kMacSize)
 331.500 -        return S_OK;
 331.501 -      packSize -= NCrypto::NWzAes::kMacSize;
 331.502 -    }
 331.503 -    UInt64 dataPos = item.GetDataPosition();
 331.504 -    inStream.Attach(archive.CreateLimitedStream(dataPos, packSize));
 331.505 -    authenticationPos = dataPos + packSize;
 331.506 -  }
 331.507 -  
 331.508 -  CMyComPtr<ICompressFilter> cryptoFilter;
 331.509 -  if (item.IsEncrypted())
 331.510 -  {
 331.511 -    if (wzAesMode)
 331.512 -    {
 331.513 -      CWzAesExtraField aesField;
 331.514 -      if (!item.CentralExtra.GetWzAesField(aesField))
 331.515 -        return S_OK;
 331.516 -      methodId = aesField.Method;
 331.517 -      if (!_wzAesDecoder)
 331.518 -      {
 331.519 -        _wzAesDecoderSpec = new NCrypto::NWzAes::CDecoder;
 331.520 -        _wzAesDecoder = _wzAesDecoderSpec;
 331.521 -      }
 331.522 -      cryptoFilter = _wzAesDecoder;
 331.523 -      Byte properties = aesField.Strength;
 331.524 -      RINOK(_wzAesDecoderSpec->SetDecoderProperties2(&properties, 1));
 331.525 -    }
 331.526 -    else if (pkAesMode)
 331.527 -    {
 331.528 -      if (!_pkAesDecoder)
 331.529 -      {
 331.530 -        _pkAesDecoderSpec = new NCrypto::NZipStrong::CDecoder;
 331.531 -        _pkAesDecoder = _pkAesDecoderSpec;
 331.532 -      }
 331.533 -      cryptoFilter = _pkAesDecoder;
 331.534 -    }
 331.535 -    else
 331.536 -    {
 331.537 -      if (!_zipCryptoDecoder)
 331.538 -      {
 331.539 -        _zipCryptoDecoderSpec = new NCrypto::NZip::CDecoder;
 331.540 -        _zipCryptoDecoder = _zipCryptoDecoderSpec;
 331.541 -      }
 331.542 -      cryptoFilter = _zipCryptoDecoder;
 331.543 -    }
 331.544 -    CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
 331.545 -    RINOK(cryptoFilter.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword));
 331.546 -    
 331.547 -    if (!getTextPassword)
 331.548 -      extractCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
 331.549 -    
 331.550 -    if (getTextPassword)
 331.551 -    {
 331.552 -      CMyComBSTR password;
 331.553 -      RINOK(getTextPassword->CryptoGetTextPassword(&password));
 331.554 -      AString charPassword;
 331.555 -      if (wzAesMode || pkAesMode)
 331.556 -      {
 331.557 -        charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_ACP);
 331.558 -        /*
 331.559 -        for (int i = 0;; i++)
 331.560 -        {
 331.561 -          wchar_t c = password[i];
 331.562 -          if (c == 0)
 331.563 -            break;
 331.564 -          if (c >= 0x80)
 331.565 -          {
 331.566 -            res = NArchive::NExtract::NOperationResult::kDataError;
 331.567 -            return S_OK;
 331.568 -          }
 331.569 -          charPassword += (char)c;
 331.570 -        }
 331.571 -        */
 331.572 -      }
 331.573 -      else
 331.574 -      {
 331.575 -        // we use OEM. WinZip/Windows probably use ANSI for some files
 331.576 -        charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
 331.577 -      }
 331.578 -      HRESULT result = cryptoSetPassword->CryptoSetPassword(
 331.579 -        (const Byte *)(const char *)charPassword, charPassword.Length());
 331.580 -      if (result != S_OK)
 331.581 -        return S_OK;
 331.582 -    }
 331.583 -    else
 331.584 -    {
 331.585 -      RINOK(cryptoSetPassword->CryptoSetPassword(0, 0));
 331.586 -    }
 331.587 -  }
 331.588 -  
 331.589 -  int m;
 331.590 -  for (m = 0; m < methodItems.Size(); m++)
 331.591 -    if (methodItems[m].ZipMethod == methodId)
 331.592 -      break;
 331.593 -
 331.594 -  if (m == methodItems.Size())
 331.595 -  {
 331.596 -    CMethodItem mi;
 331.597 -    mi.ZipMethod = methodId;
 331.598 -    if (methodId == NFileHeader::NCompressionMethod::kStored)
 331.599 -      mi.Coder = new NCompress::CCopyCoder;
 331.600 -    else if (methodId == NFileHeader::NCompressionMethod::kShrunk)
 331.601 -      mi.Coder = new NCompress::NShrink::CDecoder;
 331.602 -    else if (methodId == NFileHeader::NCompressionMethod::kImploded)
 331.603 -      mi.Coder = new NCompress::NImplode::NDecoder::CCoder;
 331.604 -    else if (methodId == NFileHeader::NCompressionMethod::kLZMA)
 331.605 -      mi.Coder = new CLzmaDecoder;
 331.606 -    else
 331.607 -    {
 331.608 -      CMethodId szMethodID;
 331.609 -      if (methodId == NFileHeader::NCompressionMethod::kBZip2)
 331.610 -        szMethodID = kMethodId_BZip2;
 331.611 -      else
 331.612 -      {
 331.613 -        if (methodId > 0xFF)
 331.614 -        {
 331.615 -          res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 331.616 -          return S_OK;
 331.617 -        }
 331.618 -        szMethodID = kMethodId_ZipBase + (Byte)methodId;
 331.619 -      }
 331.620 -
 331.621 -      RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS szMethodID, mi.Coder, false));
 331.622 -
 331.623 -      if (mi.Coder == 0)
 331.624 -      {
 331.625 -        res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 331.626 -        return S_OK;
 331.627 -      }
 331.628 -    }
 331.629 -    m = methodItems.Add(mi);
 331.630 -  }
 331.631 -  ICompressCoder *coder = methodItems[m].Coder;
 331.632 -  
 331.633 -  {
 331.634 -    CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
 331.635 -    coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
 331.636 -    if (setDecoderProperties)
 331.637 -    {
 331.638 -      Byte properties = (Byte)item.Flags;
 331.639 -      RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
 331.640 -    }
 331.641 -  }
 331.642 -  
 331.643 -  #ifdef COMPRESS_MT
 331.644 -  {
 331.645 -    CMyComPtr<ICompressSetCoderMt> setCoderMt;
 331.646 -    coder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
 331.647 -    if (setCoderMt)
 331.648 -    {
 331.649 -      RINOK(setCoderMt->SetNumberOfThreads(numThreads));
 331.650 -    }
 331.651 -  }
 331.652 -  #endif
 331.653 -  
 331.654 -  {
 331.655 -    HRESULT result = S_OK;
 331.656 -    CMyComPtr<ISequentialInStream> inStreamNew;
 331.657 -    if (item.IsEncrypted())
 331.658 -    {
 331.659 -      if (!filterStream)
 331.660 -      {
 331.661 -        filterStreamSpec = new CFilterCoder;
 331.662 -        filterStream = filterStreamSpec;
 331.663 -      }
 331.664 -      filterStreamSpec->Filter = cryptoFilter;
 331.665 -      if (wzAesMode)
 331.666 -      {
 331.667 -        result = _wzAesDecoderSpec->ReadHeader(inStream);
 331.668 -      }
 331.669 -      else if (pkAesMode)
 331.670 -      {
 331.671 -        result =_pkAesDecoderSpec->ReadHeader(inStream, item.FileCRC, item.UnPackSize);
 331.672 -        if (result == S_OK)
 331.673 -        {
 331.674 -          bool passwOK;
 331.675 -          result = _pkAesDecoderSpec->CheckPassword(passwOK);
 331.676 -          if (result == S_OK && !passwOK)
 331.677 -            result = S_FALSE;
 331.678 -        }
 331.679 -      }
 331.680 -      else
 331.681 -      {
 331.682 -        result = _zipCryptoDecoderSpec->ReadHeader(inStream);
 331.683 -      }
 331.684 -
 331.685 -      if (result == S_OK)
 331.686 -      {
 331.687 -        RINOK(filterStreamSpec->SetInStream(inStream));
 331.688 -        inStreamReleaser.FilterCoder = filterStreamSpec;
 331.689 -        inStreamNew = filterStream;
 331.690 -        if (wzAesMode)
 331.691 -        {
 331.692 -          if (!_wzAesDecoderSpec->CheckPasswordVerifyCode())
 331.693 -            result = S_FALSE;
 331.694 -        }
 331.695 -      }
 331.696 -    }
 331.697 -    else
 331.698 -      inStreamNew = inStream;
 331.699 -    if (result == S_OK)
 331.700 -      result = coder->Code(inStreamNew, outStream, NULL, &item.UnPackSize, compressProgress);
 331.701 -    if (result == S_FALSE)
 331.702 -      return S_OK;
 331.703 -    if (result == E_NOTIMPL)
 331.704 -    {
 331.705 -      res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
 331.706 -      return S_OK;
 331.707 -    }
 331.708 -
 331.709 -    RINOK(result);
 331.710 -  }
 331.711 -  bool crcOK = true;
 331.712 -  bool authOk = true;
 331.713 -  if (needCRC)
 331.714 -    crcOK = (outStreamSpec->GetCRC() == item.FileCRC);
 331.715 -  if (wzAesMode)
 331.716 -  {
 331.717 -    inStream.Attach(archive.CreateLimitedStream(authenticationPos, NCrypto::NWzAes::kMacSize));
 331.718 -    if (_wzAesDecoderSpec->CheckMac(inStream, authOk) != S_OK)
 331.719 -      authOk = false;
 331.720 -  }
 331.721 -  
 331.722 -  res = ((crcOK && authOk) ?
 331.723 -    NArchive::NExtract::NOperationResult::kOK :
 331.724 -    NArchive::NExtract::NOperationResult::kCRCError);
 331.725 -  return S_OK;
 331.726 -}
 331.727 -
 331.728 -
 331.729 -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
 331.730 -    Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
 331.731 -{
 331.732 -  COM_TRY_BEGIN
 331.733 -  CZipDecoder myDecoder;
 331.734 -  bool testMode = (_aTestMode != 0);
 331.735 -  UInt64 totalUnPacked = 0, totalPacked = 0;
 331.736 -  bool allFilesMode = (numItems == UInt32(-1));
 331.737 -  if (allFilesMode)
 331.738 -    numItems = m_Items.Size();
 331.739 -  if(numItems == 0)
 331.740 -    return S_OK;
 331.741 -  UInt32 i;
 331.742 -  for(i = 0; i < numItems; i++)
 331.743 -  {
 331.744 -    const CItemEx &item = m_Items[allFilesMode ? i : indices[i]];
 331.745 -    totalUnPacked += item.UnPackSize;
 331.746 -    totalPacked += item.PackSize;
 331.747 -  }
 331.748 -  RINOK(extractCallback->SetTotal(totalUnPacked));
 331.749 -
 331.750 -  UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
 331.751 -  UInt64 currentItemUnPacked, currentItemPacked;
 331.752 -  
 331.753 -  CLocalProgress *lps = new CLocalProgress;
 331.754 -  CMyComPtr<ICompressProgressInfo> progress = lps;
 331.755 -  lps->Init(extractCallback, false);
 331.756 -
 331.757 -  for (i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked,
 331.758 -      currentTotalPacked += currentItemPacked)
 331.759 -  {
 331.760 -    currentItemUnPacked = 0;
 331.761 -    currentItemPacked = 0;
 331.762 -
 331.763 -    lps->InSize = currentTotalPacked;
 331.764 -    lps->OutSize = currentTotalUnPacked;
 331.765 -    RINOK(lps->SetCur());
 331.766 -
 331.767 -    CMyComPtr<ISequentialOutStream> realOutStream;
 331.768 -    Int32 askMode = testMode ?
 331.769 -        NArchive::NExtract::NAskMode::kTest :
 331.770 -        NArchive::NExtract::NAskMode::kExtract;
 331.771 -    Int32 index = allFilesMode ? i : indices[i];
 331.772 -
 331.773 -    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
 331.774 -
 331.775 -    CItemEx item = m_Items[index];
 331.776 -    if (!item.FromLocal)
 331.777 -    {
 331.778 -      HRESULT res = m_Archive.ReadLocalItemAfterCdItem(item);
 331.779 -      if (res == S_FALSE)
 331.780 -      {
 331.781 -        if (item.IsDir() || realOutStream || testMode)
 331.782 -        {
 331.783 -          RINOK(extractCallback->PrepareOperation(askMode));
 331.784 -          realOutStream.Release();
 331.785 -          RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
 331.786 -        }
 331.787 -        continue;
 331.788 -      }
 331.789 -      RINOK(res);
 331.790 -    }
 331.791 -
 331.792 -    if (item.IsDir() || item.IgnoreItem())
 331.793 -    {
 331.794 -      // if (!testMode)
 331.795 -      {
 331.796 -        RINOK(extractCallback->PrepareOperation(askMode));
 331.797 -        realOutStream.Release();
 331.798 -        RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
 331.799 -      }
 331.800 -      continue;
 331.801 -    }
 331.802 -
 331.803 -    currentItemUnPacked = item.UnPackSize;
 331.804 -    currentItemPacked = item.PackSize;
 331.805 -
 331.806 -    if (!testMode && (!realOutStream))
 331.807 -      continue;
 331.808 -
 331.809 -    RINOK(extractCallback->PrepareOperation(askMode));
 331.810 -
 331.811 -#ifndef COMPRESS_MT
 331.812 -#define _numThreads 1
 331.813 -#endif
 331.814 -
 331.815 -    Int32 res;
 331.816 -    RINOK(myDecoder.Decode(
 331.817 -        EXTERNAL_CODECS_VARS
 331.818 -        m_Archive, item, realOutStream, extractCallback,
 331.819 -        progress, 
 331.820 -		_numThreads, 
 331.821 -		res));
 331.822 -    realOutStream.Release();
 331.823 -    
 331.824 -    RINOK(extractCallback->SetOperationResult(res))
 331.825 -  }
 331.826 -  return S_OK;
 331.827 -  COM_TRY_END
 331.828 -}
 331.829 -
 331.830 -#ifndef EXTRACT_ONLY
 331.831 -IMPL_ISetCompressCodecsInfo
 331.832 -#endif
 331.833 -
 331.834 -}}
   332.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHandler.h	Sat Mar 03 10:54:39 2012 -0600
   332.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   332.3 @@ -1,100 +0,0 @@
   332.4 -// Zip/Handler.h
   332.5 -
   332.6 -#ifndef __ZIP_HANDLER_H
   332.7 -#define __ZIP_HANDLER_H
   332.8 -
   332.9 -#include "../../../Common/DynamicBuffer.h"
  332.10 -#include "../../ICoder.h"
  332.11 -#include "../IArchive.h"
  332.12 -
  332.13 -#include "../../Common/CreateCoder.h"
  332.14 -
  332.15 -#include "ZipIn.h"
  332.16 -#include "ZipCompressionMode.h"
  332.17 -
  332.18 -#ifdef COMPRESS_MT
  332.19 -#include "../../../Windows/System.h"
  332.20 -#endif
  332.21 -
  332.22 -namespace NArchive {
  332.23 -namespace NZip {
  332.24 -
  332.25 -class CHandler:
  332.26 -  public IInArchive,
  332.27 -#ifndef EXTRACT_ONLY
  332.28 -  public IOutArchive,
  332.29 -  public ISetProperties,
  332.30 -  PUBLIC_ISetCompressCodecsInfo
  332.31 -#endif
  332.32 -  public CMyUnknownImp
  332.33 -{
  332.34 -public:
  332.35 -  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  332.36 -#ifndef EXTRACT_ONLY
  332.37 -  MY_QUERYINTERFACE_ENTRY(IOutArchive)
  332.38 -  MY_QUERYINTERFACE_ENTRY(ISetProperties)
  332.39 -  QUERY_ENTRY_ISetCompressCodecsInfo
  332.40 -#endif
  332.41 -  MY_QUERYINTERFACE_END
  332.42 -  MY_ADDREF_RELEASE
  332.43 -
  332.44 -  INTERFACE_IInArchive(;)
  332.45 -#ifndef EXTRACT_ONLY
  332.46 -  INTERFACE_IOutArchive(;)
  332.47 -
  332.48 -  STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
  332.49 -
  332.50 -  DECL_ISetCompressCodecsInfo
  332.51 -#endif
  332.52 -
  332.53 -  CHandler();
  332.54 -private:
  332.55 -  CObjectVector<CItemEx> m_Items;
  332.56 -  CInArchive m_Archive;
  332.57 -
  332.58 -  int m_Level;
  332.59 -  int m_MainMethod;
  332.60 -  UInt32 m_DicSize;
  332.61 -  UInt32 m_Algo;
  332.62 -  UInt32 m_NumPasses;
  332.63 -  UInt32 m_NumFastBytes;
  332.64 -  UInt32 m_NumMatchFinderCycles;
  332.65 -  bool m_NumMatchFinderCyclesDefined;
  332.66 -
  332.67 -  bool m_IsAesMode;
  332.68 -  Byte m_AesKeyMode;
  332.69 -
  332.70 -  bool m_WriteNtfsTimeExtra;
  332.71 -  bool m_ForseLocal;
  332.72 -  bool m_ForseUtf8;
  332.73 -
  332.74 -  #ifdef COMPRESS_MT
  332.75 -  UInt32 _numThreads;
  332.76 -  #endif
  332.77 -
  332.78 -  DECL_EXTERNAL_CODECS_VARS
  332.79 -
  332.80 -  void InitMethodProperties()
  332.81 -  {
  332.82 -    m_Level = -1;
  332.83 -    m_MainMethod = -1;
  332.84 -    m_Algo =
  332.85 -    m_DicSize =
  332.86 -    m_NumPasses =
  332.87 -    m_NumFastBytes =
  332.88 -    m_NumMatchFinderCycles = 0xFFFFFFFF;
  332.89 -    m_NumMatchFinderCyclesDefined = false;
  332.90 -    m_IsAesMode = false;
  332.91 -    m_AesKeyMode = 3; // aes-256
  332.92 -    m_WriteNtfsTimeExtra = false;
  332.93 -    m_ForseLocal = false;
  332.94 -    m_ForseUtf8 = false;
  332.95 -    #ifdef COMPRESS_MT
  332.96 -    _numThreads = NWindows::NSystem::GetNumberOfProcessors();;
  332.97 -    #endif
  332.98 -  }
  332.99 -};
 332.100 -
 332.101 -}}
 332.102 -
 332.103 -#endif
   333.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp	Sat Mar 03 10:54:39 2012 -0600
   333.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   333.3 @@ -1,35 +0,0 @@
   333.4 -// Archive/Zip/Header.h
   333.5 -
   333.6 -#include "StdAfx.h"
   333.7 -
   333.8 -#include "ZipHeader.h"
   333.9 -
  333.10 -namespace NArchive {
  333.11 -namespace NZip {
  333.12 -
  333.13 -namespace NSignature
  333.14 -{
  333.15 -  UInt32 kLocalFileHeader   = 0x04034B50 + 1;
  333.16 -  UInt32 kDataDescriptor    = 0x08074B50 + 1;
  333.17 -  UInt32 kCentralFileHeader = 0x02014B50 + 1;
  333.18 -  UInt32 kEndOfCentralDir   = 0x06054B50 + 1;
  333.19 -  UInt32 kZip64EndOfCentralDir   = 0x06064B50 + 1;
  333.20 -  UInt32 kZip64EndOfCentralDirLocator   = 0x07064B50 + 1;
  333.21 -  
  333.22 -  class CMarkersInitializer
  333.23 -  {
  333.24 -  public:
  333.25 -    CMarkersInitializer()
  333.26 -    {
  333.27 -      kLocalFileHeader--;
  333.28 -      kDataDescriptor--;
  333.29 -      kCentralFileHeader--;
  333.30 -      kEndOfCentralDir--;
  333.31 -      kZip64EndOfCentralDir--;
  333.32 -      kZip64EndOfCentralDirLocator--;
  333.33 -    }
  333.34 -  } g_MarkerInitializer;
  333.35 -}
  333.36 -
  333.37 -}}
  333.38 -
   334.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipHeader.h	Sat Mar 03 10:54:39 2012 -0600
   334.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   334.3 @@ -1,265 +0,0 @@
   334.4 -// Archive/Zip/Header.h
   334.5 -
   334.6 -#ifndef __ARCHIVE_ZIP_HEADER_H
   334.7 -#define __ARCHIVE_ZIP_HEADER_H
   334.8 -
   334.9 -#include "../../../Common/Types.h"
  334.10 -
  334.11 -namespace NArchive {
  334.12 -namespace NZip {
  334.13 -
  334.14 -namespace NSignature
  334.15 -{
  334.16 -  extern UInt32 kLocalFileHeader;
  334.17 -  extern UInt32 kDataDescriptor;
  334.18 -  extern UInt32 kCentralFileHeader;
  334.19 -  extern UInt32 kEndOfCentralDir;
  334.20 -  extern UInt32 kZip64EndOfCentralDir;
  334.21 -  extern UInt32 kZip64EndOfCentralDirLocator;
  334.22 -  
  334.23 -  static const UInt32 kMarkerSize = 4;
  334.24 -}
  334.25 -
  334.26 -const UInt32 kEcdSize = 22;
  334.27 -const UInt32 kZip64EcdSize = 44;
  334.28 -const UInt32 kZip64EcdLocatorSize = 20;
  334.29 -/*
  334.30 -struct CEndOfCentralDirectoryRecord
  334.31 -{
  334.32 -  UInt16 ThisDiskNumber;
  334.33 -  UInt16 StartCentralDirectoryDiskNumber;
  334.34 -  UInt16 NumEntriesInCentaralDirectoryOnThisDisk;
  334.35 -  UInt16 NumEntriesInCentaralDirectory;
  334.36 -  UInt32 CentralDirectorySize;
  334.37 -  UInt32 CentralDirectoryStartOffset;
  334.38 -  UInt16 CommentSize;
  334.39 -};
  334.40 -
  334.41 -struct CEndOfCentralDirectoryRecordFull
  334.42 -{
  334.43 -  UInt32 Signature;
  334.44 -  CEndOfCentralDirectoryRecord Header;
  334.45 -};
  334.46 -*/
  334.47 -
  334.48 -namespace NFileHeader
  334.49 -{
  334.50 -  /*
  334.51 -  struct CVersion
  334.52 -  {
  334.53 -    Byte Version;
  334.54 -    Byte HostOS;
  334.55 -  };
  334.56 -  */
  334.57 -  
  334.58 -  namespace NCompressionMethod
  334.59 -  {
  334.60 -    enum EType
  334.61 -    {
  334.62 -      kStored = 0,
  334.63 -      kShrunk = 1,
  334.64 -      kReduced1 = 2,
  334.65 -      kReduced2 = 3,
  334.66 -      kReduced3 = 4,
  334.67 -      kReduced4 = 5,
  334.68 -      kImploded = 6,
  334.69 -      kReservedTokenizing = 7, // reserved for tokenizing
  334.70 -      kDeflated = 8,
  334.71 -      kDeflated64 = 9,
  334.72 -      kPKImploding = 10,
  334.73 -      
  334.74 -      kBZip2 = 12,
  334.75 -      kLZMA = 14,
  334.76 -      kTerse = 18,
  334.77 -      kLz77 = 19,
  334.78 -      kJpeg = 0x60,
  334.79 -      kWavPack = 0x61,
  334.80 -      kPPMd = 0x62,
  334.81 -      kWzAES = 0x63
  334.82 -    };
  334.83 -    const int kNumCompressionMethods = 11;
  334.84 -    const Byte kMadeByProgramVersion = 20;
  334.85 -    
  334.86 -    const Byte kDeflateExtractVersion = 20;
  334.87 -    const Byte kStoreExtractVersion = 10;
  334.88 -    
  334.89 -    const Byte kSupportedVersion   = 20;
  334.90 -  }
  334.91 -
  334.92 -  namespace NExtraID
  334.93 -  {
  334.94 -    enum
  334.95 -    {
  334.96 -      kZip64 = 0x01,
  334.97 -      kNTFS = 0x0A,
  334.98 -      kStrongEncrypt = 0x17,
  334.99 -      kWzAES = 0x9901
 334.100 -    };
 334.101 -  }
 334.102 -
 334.103 -  namespace NNtfsExtra
 334.104 -  {
 334.105 -    const UInt16 kTagTime = 1;
 334.106 -    enum
 334.107 -    {
 334.108 -      kMTime = 0,
 334.109 -      kATime = 1,
 334.110 -      kCTime = 2
 334.111 -    };
 334.112 -  }
 334.113 -
 334.114 -  const UInt32 kLocalBlockSize = 26;
 334.115 -  /*
 334.116 -  struct CLocalBlock
 334.117 -  {
 334.118 -    CVersion ExtractVersion;
 334.119 -    
 334.120 -    UInt16 Flags;
 334.121 -    UInt16 CompressionMethod;
 334.122 -    UInt32 Time;
 334.123 -    UInt32 FileCRC;
 334.124 -    UInt32 PackSize;
 334.125 -    UInt32 UnPackSize;
 334.126 -    UInt16 NameSize;
 334.127 -    UInt16 ExtraSize;
 334.128 -  };
 334.129 -  */
 334.130 -
 334.131 -  const UInt32 kDataDescriptorSize = 16;
 334.132 -  // const UInt32 kDataDescriptor64Size = 16 + 8;
 334.133 -  /*
 334.134 -  struct CDataDescriptor
 334.135 -  {
 334.136 -    UInt32 Signature;
 334.137 -    UInt32 FileCRC;
 334.138 -    UInt32 PackSize;
 334.139 -    UInt32 UnPackSize;
 334.140 -  };
 334.141 -
 334.142 -  struct CLocalBlockFull
 334.143 -  {
 334.144 -    UInt32 Signature;
 334.145 -    CLocalBlock Header;
 334.146 -  };
 334.147 -  */
 334.148 -  
 334.149 -  const UInt32 kCentralBlockSize = 42;
 334.150 -  /*
 334.151 -  struct CBlock
 334.152 -  {
 334.153 -    CVersion MadeByVersion;
 334.154 -    CVersion ExtractVersion;
 334.155 -    UInt16 Flags;
 334.156 -    UInt16 CompressionMethod;
 334.157 -    UInt32 Time;
 334.158 -    UInt32 FileCRC;
 334.159 -    UInt32 PackSize;
 334.160 -    UInt32 UnPackSize;
 334.161 -    UInt16 NameSize;
 334.162 -    UInt16 ExtraSize;
 334.163 -    UInt16 CommentSize;
 334.164 -    UInt16 DiskNumberStart;
 334.165 -    UInt16 InternalAttributes;
 334.166 -    UInt32 ExternalAttributes;
 334.167 -    UInt32 LocalHeaderOffset;
 334.168 -  };
 334.169 -  
 334.170 -  struct CBlockFull
 334.171 -  {
 334.172 -    UInt32 Signature;
 334.173 -    CBlock Header;
 334.174 -  };
 334.175 -  */
 334.176 -
 334.177 -  namespace NFlags
 334.178 -  {
 334.179 -    const int kEncrypted = 1 << 0;
 334.180 -    const int kLzmaEOS = 1 << 1;
 334.181 -    const int kDescriptorUsedMask = 1 << 3;
 334.182 -    const int kStrongEncrypted = 1 << 6;
 334.183 -    const int kUtf8 = 1 << 11;
 334.184 -
 334.185 -    const int kImplodeDictionarySizeMask = 1 << 1;
 334.186 -    const int kImplodeLiteralsOnMask     = 1 << 2;
 334.187 -    
 334.188 -    const int kDeflateTypeBitStart = 1;
 334.189 -    const int kNumDeflateTypeBits = 2;
 334.190 -    const int kNumDeflateTypes = (1 << kNumDeflateTypeBits);
 334.191 -    const int kDeflateTypeMask = (1 << kNumDeflateTypeBits) - 1;
 334.192 -  }
 334.193 -  
 334.194 -  namespace NHostOS
 334.195 -  {
 334.196 -    enum EEnum
 334.197 -    {
 334.198 -        kFAT      = 0,
 334.199 -        kAMIGA    = 1,
 334.200 -        kVMS      = 2,  // VAX/VMS
 334.201 -        kUnix     = 3,
 334.202 -        kVM_CMS   = 4,
 334.203 -        kAtari    = 5,  // what if it's a minix filesystem? [cjh]
 334.204 -        kHPFS     = 6,  // filesystem used by OS/2 (and NT 3.x)
 334.205 -        kMac      = 7,
 334.206 -        kZ_System = 8,
 334.207 -        kCPM      = 9,
 334.208 -        kTOPS20   = 10, // pkzip 2.50 NTFS
 334.209 -        kNTFS     = 11, // filesystem used by Windows NT
 334.210 -        kQDOS     = 12, // SMS/QDOS
 334.211 -        kAcorn    = 13, // Archimedes Acorn RISC OS
 334.212 -        kVFAT     = 14, // filesystem used by Windows 95, NT
 334.213 -        kMVS      = 15,
 334.214 -        kBeOS     = 16, // hybrid POSIX/database filesystem
 334.215 -        kTandem   = 17,
 334.216 -        kOS400    = 18,
 334.217 -        kOSX      = 19
 334.218 -    };
 334.219 -  }
 334.220 -  namespace NUnixAttribute
 334.221 -  {
 334.222 -    const UInt32 kIFMT   =   0170000;     /* Unix file type mask */
 334.223 -    
 334.224 -    const UInt32 kIFDIR  =   0040000;     /* Unix directory */
 334.225 -    const UInt32 kIFREG  =   0100000;     /* Unix regular file */
 334.226 -    const UInt32 kIFSOCK =   0140000;     /* Unix socket (BSD, not SysV or Amiga) */
 334.227 -    const UInt32 kIFLNK  =   0120000;     /* Unix symbolic link (not SysV, Amiga) */
 334.228 -    const UInt32 kIFBLK  =   0060000;     /* Unix block special       (not Amiga) */
 334.229 -    const UInt32 kIFCHR  =   0020000;     /* Unix character special   (not Amiga) */
 334.230 -    const UInt32 kIFIFO  =   0010000;     /* Unix fifo    (BCC, not MSC or Amiga) */
 334.231 -    
 334.232 -    const UInt32 kISUID  =   04000;       /* Unix set user id on execution */
 334.233 -    const UInt32 kISGID  =   02000;       /* Unix set group id on execution */
 334.234 -    const UInt32 kISVTX  =   01000;       /* Unix directory permissions control */
 334.235 -    const UInt32 kENFMT  =   kISGID;   /* Unix record locking enforcement flag */
 334.236 -    const UInt32 kIRWXU  =   00700;       /* Unix read, write, execute: owner */
 334.237 -    const UInt32 kIRUSR  =   00400;       /* Unix read permission: owner */
 334.238 -    const UInt32 kIWUSR  =   00200;       /* Unix write permission: owner */
 334.239 -    const UInt32 kIXUSR  =   00100;       /* Unix execute permission: owner */
 334.240 -    const UInt32 kIRWXG  =   00070;       /* Unix read, write, execute: group */
 334.241 -    const UInt32 kIRGRP  =   00040;       /* Unix read permission: group */
 334.242 -    const UInt32 kIWGRP  =   00020;       /* Unix write permission: group */
 334.243 -    const UInt32 kIXGRP  =   00010;       /* Unix execute permission: group */
 334.244 -    const UInt32 kIRWXO  =   00007;       /* Unix read, write, execute: other */
 334.245 -    const UInt32 kIROTH  =   00004;       /* Unix read permission: other */
 334.246 -    const UInt32 kIWOTH  =   00002;       /* Unix write permission: other */
 334.247 -    const UInt32 kIXOTH  =   00001;       /* Unix execute permission: other */
 334.248 -  }
 334.249 -  
 334.250 -  namespace NAmigaAttribute
 334.251 -  {
 334.252 -    const UInt32 kIFMT     = 06000;       /* Amiga file type mask */
 334.253 -    const UInt32 kIFDIR    = 04000;       /* Amiga directory */
 334.254 -    const UInt32 kIFREG    = 02000;       /* Amiga regular file */
 334.255 -    const UInt32 kIHIDDEN  = 00200;       /* to be supported in AmigaDOS 3.x */
 334.256 -    const UInt32 kISCRIPT  = 00100;       /* executable script (text command file) */
 334.257 -    const UInt32 kIPURE    = 00040;       /* allow loading into resident memory */
 334.258 -    const UInt32 kIARCHIVE = 00020;       /* not modified since bit was last set */
 334.259 -    const UInt32 kIREAD    = 00010;       /* can be opened for reading */
 334.260 -    const UInt32 kIWRITE   = 00004;       /* can be opened for writing */
 334.261 -    const UInt32 kIEXECUTE = 00002;       /* executable image, a loadable runfile */
 334.262 -    const UInt32 kIDELETE  = 00001;      /* can be deleted */
 334.263 -  }
 334.264 -}
 334.265 -
 334.266 -}}
 334.267 -
 334.268 -#endif
   335.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.cpp	Sat Mar 03 10:54:39 2012 -0600
   335.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   335.3 @@ -1,868 +0,0 @@
   335.4 -// Archive/ZipIn.cpp
   335.5 -
   335.6 -#include "StdAfx.h"
   335.7 -
   335.8 -#include "ZipIn.h"
   335.9 -#include "Windows/Defs.h"
  335.10 -#include "Common/StringConvert.h"
  335.11 -#include "Common/DynamicBuffer.h"
  335.12 -#include "../../Common/LimitedStreams.h"
  335.13 -#include "../../Common/StreamUtils.h"
  335.14 -
  335.15 -extern "C"
  335.16 -{
  335.17 -  #include "../../../../C/CpuArch.h"
  335.18 -}
  335.19 -
  335.20 -#define Get16(p) GetUi16(p)
  335.21 -#define Get32(p) GetUi32(p)
  335.22 -#define Get64(p) GetUi64(p)
  335.23 -
  335.24 -namespace NArchive {
  335.25 -namespace NZip {
  335.26 - 
  335.27 -// static const char kEndOfString = '\0';
  335.28 -
  335.29 -HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
  335.30 -{
  335.31 -  Close();
  335.32 -  RINOK(stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
  335.33 -  m_Position = m_StreamStartPosition;
  335.34 -  RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
  335.35 -  RINOK(stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
  335.36 -  m_Stream = stream;
  335.37 -  return S_OK;
  335.38 -}
  335.39 -
  335.40 -void CInArchive::Close()
  335.41 -{
  335.42 -  m_Stream.Release();
  335.43 -}
  335.44 -
  335.45 -HRESULT CInArchive::Seek(UInt64 offset)
  335.46 -{
  335.47 -  return m_Stream->Seek(offset, STREAM_SEEK_SET, NULL);
  335.48 -}
  335.49 -
  335.50 -//////////////////////////////////////
  335.51 -// Markers
  335.52 -
  335.53 -static inline bool TestMarkerCandidate(const Byte *p, UInt32 &value)
  335.54 -{
  335.55 -  value = Get32(p);
  335.56 -  return
  335.57 -    (value == NSignature::kLocalFileHeader) ||
  335.58 -    (value == NSignature::kEndOfCentralDir);
  335.59 -}
  335.60 -
  335.61 -static const UInt32 kNumMarkerAddtionalBytes = 2;
  335.62 -static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
  335.63 -{
  335.64 -  value = Get32(p);
  335.65 -  if (value == NSignature::kEndOfCentralDir)
  335.66 -    return (Get16(p + 4) == 0);
  335.67 -  return (value == NSignature::kLocalFileHeader && p[4] < 128);
  335.68 -}
  335.69 -
  335.70 -HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
  335.71 -{
  335.72 -  m_ArchiveInfo.Clear();
  335.73 -  m_Position = m_StreamStartPosition;
  335.74 -
  335.75 -  Byte marker[NSignature::kMarkerSize];
  335.76 -  RINOK(ReadStream_FALSE(stream, marker, NSignature::kMarkerSize));
  335.77 -  m_Position += NSignature::kMarkerSize;
  335.78 -  if (TestMarkerCandidate(marker, m_Signature))
  335.79 -    return S_OK;
  335.80 -
  335.81 -  CByteDynamicBuffer dynamicBuffer;
  335.82 -  const UInt32 kSearchMarkerBufferSize = 0x10000;
  335.83 -  dynamicBuffer.EnsureCapacity(kSearchMarkerBufferSize);
  335.84 -  Byte *buffer = dynamicBuffer;
  335.85 -  UInt32 numBytesPrev = NSignature::kMarkerSize - 1;
  335.86 -  memcpy(buffer, marker + 1, numBytesPrev);
  335.87 -  UInt64 curTestPos = m_StreamStartPosition + 1;
  335.88 -  for (;;)
  335.89 -  {
  335.90 -    if (searchHeaderSizeLimit != NULL)
  335.91 -      if (curTestPos - m_StreamStartPosition > *searchHeaderSizeLimit)
  335.92 -        break;
  335.93 -    size_t numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
  335.94 -    RINOK(ReadStream(stream, buffer + numBytesPrev, &numReadBytes));
  335.95 -    m_Position += numReadBytes;
  335.96 -    UInt32 numBytesInBuffer = numBytesPrev + (UInt32)numReadBytes;
  335.97 -    const UInt32 kMarker2Size = NSignature::kMarkerSize + kNumMarkerAddtionalBytes;
  335.98 -    if (numBytesInBuffer < kMarker2Size)
  335.99 -      break;
 335.100 -    UInt32 numTests = numBytesInBuffer - kMarker2Size + 1;
 335.101 -    for (UInt32 pos = 0; pos < numTests; pos++)
 335.102 -    {
 335.103 -      if (buffer[pos] != 0x50)
 335.104 -        continue;
 335.105 -      if (TestMarkerCandidate2(buffer + pos, m_Signature))
 335.106 -      {
 335.107 -        curTestPos += pos;
 335.108 -        m_ArchiveInfo.StartPosition = curTestPos;
 335.109 -        m_Position = curTestPos + NSignature::kMarkerSize;
 335.110 -        return S_OK;
 335.111 -      }
 335.112 -    }
 335.113 -    curTestPos += numTests;
 335.114 -    numBytesPrev = numBytesInBuffer - numTests;
 335.115 -    memmove(buffer, buffer + numTests, numBytesPrev);
 335.116 -  }
 335.117 -  return S_FALSE;
 335.118 -}
 335.119 -
 335.120 -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
 335.121 -{
 335.122 -  size_t realProcessedSize = size;
 335.123 -  HRESULT result = ReadStream(m_Stream, data, &realProcessedSize);
 335.124 -  if (processedSize != NULL)
 335.125 -    *processedSize = (UInt32)realProcessedSize;
 335.126 -  m_Position += realProcessedSize;
 335.127 -  return result;
 335.128 -}
 335.129 -
 335.130 -void CInArchive::IncreaseRealPosition(UInt64 addValue)
 335.131 -{
 335.132 -  if (m_Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position) != S_OK)
 335.133 -    throw CInArchiveException(CInArchiveException::kSeekStreamError);
 335.134 -}
 335.135 -
 335.136 -bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
 335.137 -{
 335.138 -  UInt32 realProcessedSize;
 335.139 -  if (ReadBytes(data, size, &realProcessedSize) != S_OK)
 335.140 -    throw CInArchiveException(CInArchiveException::kReadStreamError);
 335.141 -  return (realProcessedSize == size);
 335.142 -}
 335.143 -
 335.144 -void CInArchive::SafeReadBytes(void *data, UInt32 size)
 335.145 -{
 335.146 -  if (!ReadBytesAndTestSize(data, size))
 335.147 -    throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
 335.148 -}
 335.149 -
 335.150 -void CInArchive::ReadBuffer(CByteBuffer &buffer, UInt32 size)
 335.151 -{
 335.152 -  buffer.SetCapacity(size);
 335.153 -  if (size > 0)
 335.154 -    SafeReadBytes(buffer, size);
 335.155 -}
 335.156 -
 335.157 -Byte CInArchive::ReadByte()
 335.158 -{
 335.159 -  Byte b;
 335.160 -  SafeReadBytes(&b, 1);
 335.161 -  return b;
 335.162 -}
 335.163 -
 335.164 -UInt16 CInArchive::ReadUInt16()
 335.165 -{
 335.166 -  UInt16 value = 0;
 335.167 -  for (int i = 0; i < 2; i++)
 335.168 -    value |= (((UInt16)ReadByte()) << (8 * i));
 335.169 -  return value;
 335.170 -}
 335.171 -
 335.172 -UInt32 CInArchive::ReadUInt32()
 335.173 -{
 335.174 -  UInt32 value = 0;
 335.175 -  for (int i = 0; i < 4; i++)
 335.176 -    value |= (((UInt32)ReadByte()) << (8 * i));
 335.177 -  return value;
 335.178 -}
 335.179 -
 335.180 -UInt64 CInArchive::ReadUInt64()
 335.181 -{
 335.182 -  UInt64 value = 0;
 335.183 -  for (int i = 0; i < 8; i++)
 335.184 -    value |= (((UInt64)ReadByte()) << (8 * i));
 335.185 -  return value;
 335.186 -}
 335.187 -
 335.188 -bool CInArchive::ReadUInt32(UInt32 &value)
 335.189 -{
 335.190 -  value = 0;
 335.191 -  for (int i = 0; i < 4; i++)
 335.192 -  {
 335.193 -    Byte b;
 335.194 -    if (!ReadBytesAndTestSize(&b, 1))
 335.195 -      return false;
 335.196 -    value |= (UInt32(b) << (8 * i));
 335.197 -  }
 335.198 -  return true;
 335.199 -}
 335.200 -
 335.201 -
 335.202 -AString CInArchive::ReadFileName(UInt32 nameSize)
 335.203 -{
 335.204 -  if (nameSize == 0)
 335.205 -    return AString();
 335.206 -  char *p = m_NameBuffer.GetBuffer(nameSize);
 335.207 -  SafeReadBytes(p, nameSize);
 335.208 -  p[nameSize] = 0;
 335.209 -  m_NameBuffer.ReleaseBuffer();
 335.210 -  return m_NameBuffer;
 335.211 -}
 335.212 -
 335.213 -void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
 335.214 -{
 335.215 -  archiveInfo = m_ArchiveInfo;
 335.216 -}
 335.217 -
 335.218 -/*
 335.219 -void CInArchive::ThrowIncorrectArchiveException()
 335.220 -{
 335.221 -  throw CInArchiveException(CInArchiveException::kIncorrectArchive);
 335.222 -}
 335.223 -*/
 335.224 -
 335.225 -static UInt32 GetUInt32(const Byte *data)
 335.226 -{
 335.227 -  return
 335.228 -      ((UInt32)(Byte)data[0]) |
 335.229 -      (((UInt32)(Byte)data[1]) << 8) |
 335.230 -      (((UInt32)(Byte)data[2]) << 16) |
 335.231 -      (((UInt32)(Byte)data[3]) << 24);
 335.232 -}
 335.233 -
 335.234 -/*
 335.235 -static UInt16 GetUInt16(const Byte *data)
 335.236 -{
 335.237 -  return
 335.238 -      ((UInt16)(Byte)data[0]) |
 335.239 -      (((UInt16)(Byte)data[1]) << 8);
 335.240 -}
 335.241 -*/
 335.242 -
 335.243 -static UInt64 GetUInt64(const Byte *data)
 335.244 -{
 335.245 -  return GetUInt32(data) | ((UInt64)GetUInt32(data + 4) << 32);
 335.246 -}
 335.247 -
 335.248 -
 335.249 -
 335.250 -void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
 335.251 -    UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
 335.252 -{
 335.253 -  extraBlock.Clear();
 335.254 -  UInt32 remain = extraSize;
 335.255 -  while(remain >= 4)
 335.256 -  {
 335.257 -    CExtraSubBlock subBlock;
 335.258 -    subBlock.ID = ReadUInt16();
 335.259 -    UInt32 dataSize = ReadUInt16();
 335.260 -    remain -= 4;
 335.261 -    if (dataSize > remain) // it's bug
 335.262 -      dataSize = remain;
 335.263 -    if (subBlock.ID == NFileHeader::NExtraID::kZip64)
 335.264 -    {
 335.265 -      if (unpackSize == 0xFFFFFFFF)
 335.266 -      {
 335.267 -        if (dataSize < 8)
 335.268 -          break;
 335.269 -        unpackSize = ReadUInt64();
 335.270 -        remain -= 8;
 335.271 -        dataSize -= 8;
 335.272 -      }
 335.273 -      if (packSize == 0xFFFFFFFF)
 335.274 -      {
 335.275 -        if (dataSize < 8)
 335.276 -          break;
 335.277 -        packSize = ReadUInt64();
 335.278 -        remain -= 8;
 335.279 -        dataSize -= 8;
 335.280 -      }
 335.281 -      if (localHeaderOffset == 0xFFFFFFFF)
 335.282 -      {
 335.283 -        if (dataSize < 8)
 335.284 -          break;
 335.285 -        localHeaderOffset = ReadUInt64();
 335.286 -        remain -= 8;
 335.287 -        dataSize -= 8;
 335.288 -      }
 335.289 -      if (diskStartNumber == 0xFFFF)
 335.290 -      {
 335.291 -        if (dataSize < 4)
 335.292 -          break;
 335.293 -        diskStartNumber = ReadUInt32();
 335.294 -        remain -= 4;
 335.295 -        dataSize -= 4;
 335.296 -      }
 335.297 -      for (UInt32 i = 0; i < dataSize; i++)
 335.298 -        ReadByte();
 335.299 -    }
 335.300 -    else
 335.301 -    {
 335.302 -      ReadBuffer(subBlock.Data, dataSize);
 335.303 -      extraBlock.SubBlocks.Add(subBlock);
 335.304 -    }
 335.305 -    remain -= dataSize;
 335.306 -  }
 335.307 -  IncreaseRealPosition(remain);
 335.308 -}
 335.309 -
 335.310 -HRESULT CInArchive::ReadLocalItem(CItemEx &item)
 335.311 -{
 335.312 -  item.ExtractVersion.Version = ReadByte();
 335.313 -  item.ExtractVersion.HostOS = ReadByte();
 335.314 -  item.Flags = ReadUInt16();
 335.315 -  item.CompressionMethod = ReadUInt16();
 335.316 -  item.Time =  ReadUInt32();
 335.317 -  item.FileCRC = ReadUInt32();
 335.318 -  item.PackSize = ReadUInt32();
 335.319 -  item.UnPackSize = ReadUInt32();
 335.320 -  UInt32 fileNameSize = ReadUInt16();
 335.321 -  item.LocalExtraSize = ReadUInt16();
 335.322 -  item.Name = ReadFileName(fileNameSize);
 335.323 -  item.FileHeaderWithNameSize = 4 + NFileHeader::kLocalBlockSize + fileNameSize;
 335.324 -  if (item.LocalExtraSize > 0)
 335.325 -  {
 335.326 -    UInt64 localHeaderOffset = 0;
 335.327 -    UInt32 diskStartNumber = 0;
 335.328 -    ReadExtra(item.LocalExtraSize, item.LocalExtra, item.UnPackSize, item.PackSize,
 335.329 -      localHeaderOffset, diskStartNumber);
 335.330 -  }
 335.331 -  /*
 335.332 -  if (item.IsDir())
 335.333 -    item.UnPackSize = 0;       // check It
 335.334 -  */
 335.335 -  return S_OK;
 335.336 -}
 335.337 -
 335.338 -HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
 335.339 -{
 335.340 -  if (item.FromLocal)
 335.341 -    return S_OK;
 335.342 -  try
 335.343 -  {
 335.344 -    RINOK(Seek(m_ArchiveInfo.Base + item.LocalHeaderPosition));
 335.345 -    CItemEx localItem;
 335.346 -    if (ReadUInt32() != NSignature::kLocalFileHeader)
 335.347 -      return S_FALSE;
 335.348 -    RINOK(ReadLocalItem(localItem));
 335.349 -    if (item.Flags != localItem.Flags)
 335.350 -    {
 335.351 -      if (
 335.352 -          (item.CompressionMethod != NFileHeader::NCompressionMethod::kDeflated ||
 335.353 -            (item.Flags & 0x7FF9) != (localItem.Flags & 0x7FF9)) &&
 335.354 -          (item.CompressionMethod != NFileHeader::NCompressionMethod::kStored ||
 335.355 -            (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF)) &&
 335.356 -          (item.CompressionMethod != NFileHeader::NCompressionMethod::kImploded ||
 335.357 -            (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF))
 335.358 -        )
 335.359 -        return S_FALSE;
 335.360 -    }
 335.361 -
 335.362 -    if (item.CompressionMethod != localItem.CompressionMethod ||
 335.363 -        // item.Time != localItem.Time ||
 335.364 -        (!localItem.HasDescriptor() &&
 335.365 -          (
 335.366 -            item.FileCRC != localItem.FileCRC ||
 335.367 -            item.PackSize != localItem.PackSize ||
 335.368 -            item.UnPackSize != localItem.UnPackSize
 335.369 -          )
 335.370 -        ) ||
 335.371 -        item.Name.Length() != localItem.Name.Length()
 335.372 -        )
 335.373 -      return S_FALSE;
 335.374 -    item.FileHeaderWithNameSize = localItem.FileHeaderWithNameSize;
 335.375 -    item.LocalExtraSize = localItem.LocalExtraSize;
 335.376 -    item.LocalExtra = localItem.LocalExtra;
 335.377 -    item.FromLocal = true;
 335.378 -  }
 335.379 -  catch(...) { return S_FALSE; }
 335.380 -  return S_OK;
 335.381 -}
 335.382 -
 335.383 -HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
 335.384 -{
 335.385 -  if (item.HasDescriptor())
 335.386 -  {
 335.387 -    const int kBufferSize = (1 << 12);
 335.388 -    Byte buffer[kBufferSize];
 335.389 -    
 335.390 -    UInt32 numBytesInBuffer = 0;
 335.391 -    UInt32 packedSize = 0;
 335.392 -    
 335.393 -    bool descriptorWasFound = false;
 335.394 -    for (;;)
 335.395 -    {
 335.396 -      UInt32 processedSize;
 335.397 -      RINOK(ReadBytes(buffer + numBytesInBuffer, kBufferSize - numBytesInBuffer, &processedSize));
 335.398 -      numBytesInBuffer += processedSize;
 335.399 -      if (numBytesInBuffer < NFileHeader::kDataDescriptorSize)
 335.400 -        return S_FALSE;
 335.401 -      UInt32 i;
 335.402 -      for (i = 0; i <= numBytesInBuffer - NFileHeader::kDataDescriptorSize; i++)
 335.403 -      {
 335.404 -        // descriptorSignature field is Info-ZIP's extension
 335.405 -        // to Zip specification.
 335.406 -        UInt32 descriptorSignature = GetUInt32(buffer + i);
 335.407 -        
 335.408 -        // !!!! It must be fixed for Zip64 archives
 335.409 -        UInt32 descriptorPackSize = GetUInt32(buffer + i + 8);
 335.410 -        if (descriptorSignature== NSignature::kDataDescriptor && descriptorPackSize == packedSize + i)
 335.411 -        {
 335.412 -          descriptorWasFound = true;
 335.413 -          item.FileCRC = GetUInt32(buffer + i + 4);
 335.414 -          item.PackSize = descriptorPackSize;
 335.415 -          item.UnPackSize = GetUInt32(buffer + i + 12);
 335.416 -          IncreaseRealPosition(Int64(Int32(0 - (numBytesInBuffer - i - NFileHeader::kDataDescriptorSize))));
 335.417 -          break;
 335.418 -        }
 335.419 -      }
 335.420 -      if (descriptorWasFound)
 335.421 -        break;
 335.422 -      packedSize += i;
 335.423 -      int j;
 335.424 -      for (j = 0; i < numBytesInBuffer; i++, j++)
 335.425 -        buffer[j] = buffer[i];
 335.426 -      numBytesInBuffer = j;
 335.427 -    }
 335.428 -  }
 335.429 -  else
 335.430 -    IncreaseRealPosition(item.PackSize);
 335.431 -  return S_OK;
 335.432 -}
 335.433 -
 335.434 -HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
 335.435 -{
 335.436 -  if (item.FromLocal)
 335.437 -    return S_OK;
 335.438 -  try
 335.439 -  {
 335.440 -    RINOK(ReadLocalItemAfterCdItem(item));
 335.441 -    if (item.HasDescriptor())
 335.442 -    {
 335.443 -      RINOK(Seek(m_ArchiveInfo.Base + item.GetDataPosition() + item.PackSize));
 335.444 -      if (ReadUInt32() != NSignature::kDataDescriptor)
 335.445 -        return S_FALSE;
 335.446 -      UInt32 crc = ReadUInt32();
 335.447 -      UInt64 packSize, unpackSize;
 335.448 -
 335.449 -      /*
 335.450 -      if (IsZip64)
 335.451 -      {
 335.452 -        packSize = ReadUInt64();
 335.453 -        unpackSize = ReadUInt64();
 335.454 -      }
 335.455 -      else
 335.456 -      */
 335.457 -      {
 335.458 -        packSize = ReadUInt32();
 335.459 -        unpackSize = ReadUInt32();
 335.460 -      }
 335.461 -
 335.462 -      if (crc != item.FileCRC || item.PackSize != packSize || item.UnPackSize != unpackSize)
 335.463 -        return S_FALSE;
 335.464 -    }
 335.465 -  }
 335.466 -  catch(...) { return S_FALSE; }
 335.467 -  return S_OK;
 335.468 -}
 335.469 -  
 335.470 -HRESULT CInArchive::ReadCdItem(CItemEx &item)
 335.471 -{
 335.472 -  item.FromCentral = true;
 335.473 -  const int kBufSize = 42;
 335.474 -  Byte p[kBufSize];
 335.475 -  SafeReadBytes(p, kBufSize);
 335.476 -  item.MadeByVersion.Version = p[0];
 335.477 -  item.MadeByVersion.HostOS = p[1];
 335.478 -  item.ExtractVersion.Version = p[2];
 335.479 -  item.ExtractVersion.HostOS = p[3];
 335.480 -  item.Flags = Get16(p + 4);
 335.481 -  item.CompressionMethod = Get16(p + 6);
 335.482 -  item.Time = Get32(p + 8);
 335.483 -  item.FileCRC = Get32(p + 12);
 335.484 -  item.PackSize = Get32(p + 16);
 335.485 -  item.UnPackSize = Get32(p + 20);
 335.486 -  UInt16 headerNameSize = Get16(p + 24);
 335.487 -  UInt16 headerExtraSize = Get16(p + 26);
 335.488 -  UInt16 headerCommentSize = Get16(p + 28);
 335.489 -  UInt32 headerDiskNumberStart = Get16(p + 30);
 335.490 -  item.InternalAttributes = Get16(p + 32);
 335.491 -  item.ExternalAttributes = Get32(p + 34);
 335.492 -  item.LocalHeaderPosition = Get32(p + 38);
 335.493 -  item.Name = ReadFileName(headerNameSize);
 335.494 -  
 335.495 -  if (headerExtraSize > 0)
 335.496 -  {
 335.497 -    ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
 335.498 -        item.LocalHeaderPosition, headerDiskNumberStart);
 335.499 -  }
 335.500 -
 335.501 -  if (headerDiskNumberStart != 0)
 335.502 -    throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
 335.503 -  
 335.504 -  // May be these strings must be deleted
 335.505 -  /*
 335.506 -  if (item.IsDir())
 335.507 -    item.UnPackSize = 0;
 335.508 -  */
 335.509 -  
 335.510 -  ReadBuffer(item.Comment, headerCommentSize);
 335.511 -  return S_OK;
 335.512 -}
 335.513 -
 335.514 -HRESULT CInArchive::TryEcd64(UInt64 offset, CCdInfo &cdInfo)
 335.515 -{
 335.516 -  RINOK(Seek(offset));
 335.517 -  const UInt32 kEcd64Size = 56;
 335.518 -  Byte buf[kEcd64Size];
 335.519 -  if (!ReadBytesAndTestSize(buf, kEcd64Size))
 335.520 -    return S_FALSE;
 335.521 -  if (GetUInt32(buf) != NSignature::kZip64EndOfCentralDir)
 335.522 -    return S_FALSE;
 335.523 -  // cdInfo.NumEntries = GetUInt64(buf + 24);
 335.524 -  cdInfo.Size = GetUInt64(buf + 40);
 335.525 -  cdInfo.Offset = GetUInt64(buf + 48);
 335.526 -  return S_OK;
 335.527 -}
 335.528 -
 335.529 -HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
 335.530 -{
 335.531 -  UInt64 endPosition;
 335.532 -  RINOK(m_Stream->Seek(0, STREAM_SEEK_END, &endPosition));
 335.533 -  const UInt32 kBufSizeMax = (1 << 16) + kEcdSize + kZip64EcdLocatorSize;
 335.534 -  Byte buf[kBufSizeMax];
 335.535 -  UInt32 bufSize = (endPosition < kBufSizeMax) ? (UInt32)endPosition : kBufSizeMax;
 335.536 -  if (bufSize < kEcdSize)
 335.537 -    return S_FALSE;
 335.538 -  UInt64 startPosition = endPosition - bufSize;
 335.539 -  RINOK(m_Stream->Seek(startPosition, STREAM_SEEK_SET, &m_Position));
 335.540 -  if (m_Position != startPosition)
 335.541 -    return S_FALSE;
 335.542 -  if (!ReadBytesAndTestSize(buf, bufSize))
 335.543 -    return S_FALSE;
 335.544 -  for (int i = (int)(bufSize - kEcdSize); i >= 0; i--)
 335.545 -  {
 335.546 -    if (GetUInt32(buf + i) == NSignature::kEndOfCentralDir)
 335.547 -    {
 335.548 -      if (i >= kZip64EcdLocatorSize)
 335.549 -      {
 335.550 -        const Byte *locator = buf + i - kZip64EcdLocatorSize;
 335.551 -        if (GetUInt32(locator) == NSignature::kZip64EndOfCentralDirLocator)
 335.552 -        {
 335.553 -          UInt64 ecd64Offset = GetUInt64(locator + 8);
 335.554 -          if (TryEcd64(ecd64Offset, cdInfo) == S_OK)
 335.555 -            return S_OK;
 335.556 -          if (TryEcd64(m_ArchiveInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
 335.557 -          {
 335.558 -            m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
 335.559 -            return S_OK;
 335.560 -          }
 335.561 -        }
 335.562 -      }
 335.563 -      if (GetUInt32(buf + i + 4) == 0)
 335.564 -      {
 335.565 -        // cdInfo.NumEntries = GetUInt16(buf + i + 10);
 335.566 -        cdInfo.Size = GetUInt32(buf + i + 12);
 335.567 -        cdInfo.Offset = GetUInt32(buf + i + 16);
 335.568 -        UInt64 curPos = endPosition - bufSize + i;
 335.569 -        UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
 335.570 -        if (curPos > cdEnd)
 335.571 -          m_ArchiveInfo.Base = curPos - cdEnd;
 335.572 -        return S_OK;
 335.573 -      }
 335.574 -    }
 335.575 -  }
 335.576 -  return S_FALSE;
 335.577 -}
 335.578 -
 335.579 -HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress)
 335.580 -{
 335.581 -  items.Clear();
 335.582 -  RINOK(m_Stream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
 335.583 -  if (m_Position != cdOffset)
 335.584 -    return S_FALSE;
 335.585 -  while(m_Position - cdOffset < cdSize)
 335.586 -  {
 335.587 -    if (ReadUInt32() != NSignature::kCentralFileHeader)
 335.588 -      return S_FALSE;
 335.589 -    CItemEx cdItem;
 335.590 -    RINOK(ReadCdItem(cdItem));
 335.591 -    items.Add(cdItem);
 335.592 -    if (progress && items.Size() % 1000 == 0)
 335.593 -      RINOK(progress->SetCompleted(items.Size()));
 335.594 -  }
 335.595 -  return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
 335.596 -}
 335.597 -
 335.598 -HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
 335.599 -{
 335.600 -  m_ArchiveInfo.Base = 0;
 335.601 -  CCdInfo cdInfo;
 335.602 -  RINOK(FindCd(cdInfo));
 335.603 -  HRESULT res = S_FALSE;
 335.604 -  cdSize = cdInfo.Size;
 335.605 -  cdOffset = cdInfo.Offset;
 335.606 -  res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress);
 335.607 -  if (res == S_FALSE && m_ArchiveInfo.Base == 0)
 335.608 -  {
 335.609 -    res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress);
 335.610 -    if (res == S_OK)
 335.611 -      m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
 335.612 -  }
 335.613 -  if (!ReadUInt32(m_Signature))
 335.614 -    return S_FALSE;
 335.615 -  return res;
 335.616 -}
 335.617 -
 335.618 -HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset)
 335.619 -{
 335.620 -  items.Clear();
 335.621 -  while (m_Signature == NSignature::kLocalFileHeader)
 335.622 -  {
 335.623 -    // FSeek points to next byte after signature
 335.624 -    // NFileHeader::CLocalBlock localHeader;
 335.625 -    CItemEx item;
 335.626 -    item.LocalHeaderPosition = m_Position - m_StreamStartPosition - 4; // points to signature;
 335.627 -    RINOK(ReadLocalItem(item));
 335.628 -    item.FromLocal = true;
 335.629 -    ReadLocalItemDescriptor(item);
 335.630 -    items.Add(item);
 335.631 -    if (progress && items.Size() % 100 == 0)
 335.632 -      RINOK(progress->SetCompleted(items.Size()));
 335.633 -    if (!ReadUInt32(m_Signature))
 335.634 -      break;
 335.635 -  }
 335.636 -  cdOffset = m_Position - 4;
 335.637 -  for (int i = 0; i < items.Size(); i++)
 335.638 -  {
 335.639 -    if (progress && i % 1000 == 0)
 335.640 -      RINOK(progress->SetCompleted(items.Size()));
 335.641 -    if (m_Signature != NSignature::kCentralFileHeader)
 335.642 -      return S_FALSE;
 335.643 -
 335.644 -    CItemEx cdItem;
 335.645 -    RINOK(ReadCdItem(cdItem));
 335.646 -
 335.647 -    if (i == 0)
 335.648 -    {
 335.649 -      if (cdItem.LocalHeaderPosition == 0)
 335.650 -        m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
 335.651 -    }
 335.652 -
 335.653 -    int index;
 335.654 -    int left = 0, right = items.Size();
 335.655 -    for (;;)
 335.656 -    {
 335.657 -      if (left >= right)
 335.658 -        return S_FALSE;
 335.659 -      index = (left + right) / 2;
 335.660 -      UInt64 position = items[index].LocalHeaderPosition - m_ArchiveInfo.Base;
 335.661 -      if (cdItem.LocalHeaderPosition == position)
 335.662 -        break;
 335.663 -      if (cdItem.LocalHeaderPosition < position)
 335.664 -        right = index;
 335.665 -      else
 335.666 -        left = index + 1;
 335.667 -    }
 335.668 -    CItemEx &item = items[index];
 335.669 -    item.LocalHeaderPosition = cdItem.LocalHeaderPosition;
 335.670 -    item.MadeByVersion = cdItem.MadeByVersion;
 335.671 -    item.CentralExtra = cdItem.CentralExtra;
 335.672 -
 335.673 -    if (
 335.674 -        // item.ExtractVersion != cdItem.ExtractVersion ||
 335.675 -        item.Flags != cdItem.Flags ||
 335.676 -        item.CompressionMethod != cdItem.CompressionMethod ||
 335.677 -        // item.Time != cdItem.Time ||
 335.678 -        item.FileCRC != cdItem.FileCRC)
 335.679 -      return S_FALSE;
 335.680 -
 335.681 -    if (item.Name.Length() != cdItem.Name.Length() ||
 335.682 -        item.PackSize != cdItem.PackSize ||
 335.683 -        item.UnPackSize != cdItem.UnPackSize
 335.684 -      )
 335.685 -      return S_FALSE;
 335.686 -    item.Name = cdItem.Name;
 335.687 -    item.InternalAttributes = cdItem.InternalAttributes;
 335.688 -    item.ExternalAttributes = cdItem.ExternalAttributes;
 335.689 -    item.Comment = cdItem.Comment;
 335.690 -    item.FromCentral = cdItem.FromCentral;
 335.691 -    if (!ReadUInt32(m_Signature))
 335.692 -      return S_FALSE;
 335.693 -  }
 335.694 -  return S_OK;
 335.695 -}
 335.696 -
 335.697 -struct CEcd
 335.698 -{
 335.699 -  UInt16 thisDiskNumber;
 335.700 -  UInt16 startCDDiskNumber;
 335.701 -  UInt16 numEntriesInCDOnThisDisk;
 335.702 -  UInt16 numEntriesInCD;
 335.703 -  UInt32 cdSize;
 335.704 -  UInt32 cdStartOffset;
 335.705 -  UInt16 commentSize;
 335.706 -  void Parse(const Byte *p);
 335.707 -};
 335.708 -
 335.709 -void CEcd::Parse(const Byte *p)
 335.710 -{
 335.711 -  thisDiskNumber = Get16(p);
 335.712 -  startCDDiskNumber = Get16(p + 2);
 335.713 -  numEntriesInCDOnThisDisk = Get16(p + 4);
 335.714 -  numEntriesInCD = Get16(p + 6);
 335.715 -  cdSize = Get32(p + 8);
 335.716 -  cdStartOffset = Get32(p + 12);
 335.717 -  commentSize = Get16(p + 16);
 335.718 -}
 335.719 -
 335.720 -struct CEcd64
 335.721 -{
 335.722 -  UInt16 versionMade;
 335.723 -  UInt16 versionNeedExtract;
 335.724 -  UInt32 thisDiskNumber;
 335.725 -  UInt32 startCDDiskNumber;
 335.726 -  UInt64 numEntriesInCDOnThisDisk;
 335.727 -  UInt64 numEntriesInCD;
 335.728 -  UInt64 cdSize;
 335.729 -  UInt64 cdStartOffset;
 335.730 -  void Parse(const Byte *p);
 335.731 -  CEcd64() { memset(this, 0, sizeof(*this)); }
 335.732 -};
 335.733 -
 335.734 -void CEcd64::Parse(const Byte *p)
 335.735 -{
 335.736 -  versionMade = Get16(p);
 335.737 -  versionNeedExtract = Get16(p + 2);
 335.738 -  thisDiskNumber = Get32(p + 4);
 335.739 -  startCDDiskNumber = Get32(p + 8);
 335.740 -  numEntriesInCDOnThisDisk = Get64(p + 12);
 335.741 -  numEntriesInCD = Get64(p + 20);
 335.742 -  cdSize = Get64(p + 28);
 335.743 -  cdStartOffset = Get64(p + 36);
 335.744 -}
 335.745 -
 335.746 -#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. n != 0xFFFF)     ecd64. n = ecd. n;
 335.747 -#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. n != 0xFFFFFFFF) ecd64. n = ecd. n;
 335.748 -
 335.749 -HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
 335.750 -{
 335.751 -  // m_Signature must be kLocalFileHeaderSignature or
 335.752 -  // kEndOfCentralDirSignature
 335.753 -  // m_Position points to next byte after signature
 335.754 -
 335.755 -  IsZip64 = false;
 335.756 -  items.Clear();
 335.757 -
 335.758 -  UInt64 cdSize, cdStartOffset;
 335.759 -  HRESULT res = ReadCd(items, cdStartOffset, cdSize, progress);
 335.760 -  if (res != S_FALSE && res != S_OK)
 335.761 -    return res;
 335.762 -
 335.763 -  /*
 335.764 -  if (res != S_OK)
 335.765 -    return res;
 335.766 -  res = S_FALSE;
 335.767 -  */
 335.768 -
 335.769 -  if (res == S_FALSE)
 335.770 -  {
 335.771 -    m_ArchiveInfo.Base = 0;
 335.772 -    RINOK(m_Stream->Seek(m_ArchiveInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
 335.773 -    if (m_Position != m_ArchiveInfo.StartPosition)
 335.774 -      return S_FALSE;
 335.775 -    if (!ReadUInt32(m_Signature))
 335.776 -      return S_FALSE;
 335.777 -    RINOK(ReadLocalsAndCd(items, progress, cdStartOffset));
 335.778 -    cdSize = (m_Position - 4) - cdStartOffset;
 335.779 -    cdStartOffset -= m_ArchiveInfo.Base;
 335.780 -  }
 335.781 -
 335.782 -  CEcd64 ecd64;
 335.783 -  bool isZip64 = false;
 335.784 -  UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
 335.785 -  if (m_Signature == NSignature::kZip64EndOfCentralDir)
 335.786 -  {
 335.787 -    IsZip64 = isZip64 = true;
 335.788 -    UInt64 recordSize = ReadUInt64();
 335.789 -
 335.790 -    const int kBufSize = kZip64EcdSize;
 335.791 -    Byte buf[kBufSize];
 335.792 -    SafeReadBytes(buf, kBufSize);
 335.793 -    ecd64.Parse(buf);
 335.794 -
 335.795 -    IncreaseRealPosition(recordSize - kZip64EcdSize);
 335.796 -    if (!ReadUInt32(m_Signature))
 335.797 -      return S_FALSE;
 335.798 -    if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
 335.799 -      throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
 335.800 -    if (ecd64.numEntriesInCDOnThisDisk != items.Size() ||
 335.801 -        ecd64.numEntriesInCD != items.Size() ||
 335.802 -        ecd64.cdSize != cdSize ||
 335.803 -        (ecd64.cdStartOffset != cdStartOffset &&
 335.804 -        (!items.IsEmpty())))
 335.805 -      return S_FALSE;
 335.806 -  }
 335.807 -  if (m_Signature == NSignature::kZip64EndOfCentralDirLocator)
 335.808 -  {
 335.809 -    /* UInt32 startEndCDDiskNumber = */ ReadUInt32();
 335.810 -    UInt64 endCDStartOffset = ReadUInt64();
 335.811 -    /* UInt32 numberOfDisks = */ ReadUInt32();
 335.812 -    if (zip64EcdStartOffset != endCDStartOffset)
 335.813 -      return S_FALSE;
 335.814 -    if (!ReadUInt32(m_Signature))
 335.815 -      return S_FALSE;
 335.816 -  }
 335.817 -  if (m_Signature != NSignature::kEndOfCentralDir)
 335.818 -      return S_FALSE;
 335.819 -
 335.820 -  const int kBufSize = kEcdSize - 4;
 335.821 -  Byte buf[kBufSize];
 335.822 -  SafeReadBytes(buf, kBufSize);
 335.823 -  CEcd ecd;
 335.824 -  ecd.Parse(buf);
 335.825 -
 335.826 -  COPY_ECD_ITEM_16(thisDiskNumber);
 335.827 -  COPY_ECD_ITEM_16(startCDDiskNumber);
 335.828 -  COPY_ECD_ITEM_16(numEntriesInCDOnThisDisk);
 335.829 -  COPY_ECD_ITEM_16(numEntriesInCD);
 335.830 -  COPY_ECD_ITEM_32(cdSize);
 335.831 -  COPY_ECD_ITEM_32(cdStartOffset);
 335.832 -
 335.833 -  ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize);
 335.834 -
 335.835 -  if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
 335.836 -    throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
 335.837 -  if ((UInt16)ecd64.numEntriesInCDOnThisDisk != ((UInt16)items.Size()) ||
 335.838 -      (UInt16)ecd64.numEntriesInCD != ((UInt16)items.Size()) ||
 335.839 -      (UInt32)ecd64.cdSize != (UInt32)cdSize ||
 335.840 -      ((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset &&
 335.841 -        (!items.IsEmpty())))
 335.842 -      return S_FALSE;
 335.843 -  
 335.844 -  return S_OK;
 335.845 -}
 335.846 -
 335.847 -ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
 335.848 -{
 335.849 -  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
 335.850 -  CMyComPtr<ISequentialInStream> stream(streamSpec);
 335.851 -  SeekInArchive(m_ArchiveInfo.Base + position);
 335.852 -  streamSpec->SetStream(m_Stream);
 335.853 -  streamSpec->Init(size);
 335.854 -  return stream.Detach();
 335.855 -}
 335.856 -
 335.857 -IInStream* CInArchive::CreateStream()
 335.858 -{
 335.859 -  CMyComPtr<IInStream> stream = m_Stream;
 335.860 -  return stream.Detach();
 335.861 -}
 335.862 -
 335.863 -bool CInArchive::SeekInArchive(UInt64 position)
 335.864 -{
 335.865 -  UInt64 newPosition;
 335.866 -  if (m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition) != S_OK)
 335.867 -    return false;
 335.868 -  return (newPosition == position);
 335.869 -}
 335.870 -
 335.871 -}}
   336.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.h	Sat Mar 03 10:54:39 2012 -0600
   336.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   336.3 @@ -1,116 +0,0 @@
   336.4 -// Archive/ZipIn.h
   336.5 -
   336.6 -#ifndef __ZIP_IN_H
   336.7 -#define __ZIP_IN_H
   336.8 -
   336.9 -#include "../../../Common/MyCom.h"
  336.10 -#include "../../IStream.h"
  336.11 -
  336.12 -#include "ZipHeader.h"
  336.13 -#include "ZipItemEx.h"
  336.14 -
  336.15 -namespace NArchive {
  336.16 -namespace NZip {
  336.17 -  
  336.18 -class CInArchiveException
  336.19 -{
  336.20 -public:
  336.21 -  enum ECauseType
  336.22 -  {
  336.23 -    kUnexpectedEndOfArchive = 0,
  336.24 -    kArchiceHeaderCRCError,
  336.25 -    kFileHeaderCRCError,
  336.26 -    kIncorrectArchive,
  336.27 -    kDataDescroptorsAreNotSupported,
  336.28 -    kMultiVolumeArchiveAreNotSupported,
  336.29 -    kReadStreamError,
  336.30 -    kSeekStreamError
  336.31 -  }
  336.32 -  Cause;
  336.33 -  CInArchiveException(ECauseType cause): Cause(cause) {}
  336.34 -};
  336.35 -
  336.36 -class CInArchiveInfo
  336.37 -{
  336.38 -public:
  336.39 -  UInt64 Base;
  336.40 -  UInt64 StartPosition;
  336.41 -  CByteBuffer Comment;
  336.42 -  CInArchiveInfo(): Base(0), StartPosition(0) {}
  336.43 -  void Clear()
  336.44 -  {
  336.45 -    Base = 0;
  336.46 -    StartPosition = 0;
  336.47 -    Comment.SetCapacity(0);
  336.48 -  }
  336.49 -};
  336.50 -
  336.51 -class CProgressVirt
  336.52 -{
  336.53 -public:
  336.54 -  STDMETHOD(SetTotal)(UInt64 numFiles) PURE;
  336.55 -  STDMETHOD(SetCompleted)(UInt64 numFiles) PURE;
  336.56 -};
  336.57 -
  336.58 -struct CCdInfo
  336.59 -{
  336.60 -  // UInt64 NumEntries;
  336.61 -  UInt64 Size;
  336.62 -  UInt64 Offset;
  336.63 -};
  336.64 -
  336.65 -class CInArchive
  336.66 -{
  336.67 -  CMyComPtr<IInStream> m_Stream;
  336.68 -  UInt32 m_Signature;
  336.69 -  UInt64 m_StreamStartPosition;
  336.70 -  UInt64 m_Position;
  336.71 -  AString m_NameBuffer;
  336.72 -  
  336.73 -  HRESULT Seek(UInt64 offset);
  336.74 -
  336.75 -  HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  336.76 -  bool ReadUInt32(UInt32 &signature);
  336.77 -  AString ReadFileName(UInt32 nameSize);
  336.78 -  
  336.79 -  HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
  336.80 -  bool ReadBytesAndTestSize(void *data, UInt32 size);
  336.81 -  void SafeReadBytes(void *data, UInt32 size);
  336.82 -  void ReadBuffer(CByteBuffer &buffer, UInt32 size);
  336.83 -  Byte ReadByte();
  336.84 -  UInt16 ReadUInt16();
  336.85 -  UInt32 ReadUInt32();
  336.86 -  UInt64 ReadUInt64();
  336.87 -  
  336.88 -  void IncreaseRealPosition(UInt64 addValue);
  336.89 - 
  336.90 -  void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
  336.91 -      UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber);
  336.92 -  HRESULT ReadLocalItem(CItemEx &item);
  336.93 -  HRESULT ReadLocalItemDescriptor(CItemEx &item);
  336.94 -  HRESULT ReadCdItem(CItemEx &item);
  336.95 -  HRESULT TryEcd64(UInt64 offset, CCdInfo &cdInfo);
  336.96 -  HRESULT FindCd(CCdInfo &cdInfo);
  336.97 -  HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress);
  336.98 -  HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
  336.99 -  HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
 336.100 -public:
 336.101 -  CInArchiveInfo m_ArchiveInfo;
 336.102 -  bool IsZip64;
 336.103 -
 336.104 -  HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
 336.105 -  HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
 336.106 -  HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
 336.107 -  HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
 336.108 -  void Close();
 336.109 -  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
 336.110 -  bool SeekInArchive(UInt64 position);
 336.111 -  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
 336.112 -  IInStream* CreateStream();
 336.113 -
 336.114 -  bool IsOpen() const { return m_Stream != NULL; }
 336.115 -};
 336.116 -  
 336.117 -}}
 336.118 -  
 336.119 -#endif
   337.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItem.cpp	Sat Mar 03 10:54:39 2012 -0600
   337.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   337.3 @@ -1,147 +0,0 @@
   337.4 -// Archive/ZipItem.cpp
   337.5 -
   337.6 -#include "StdAfx.h"
   337.7 -
   337.8 -#include "ZipHeader.h"
   337.9 -#include "ZipItem.h"
  337.10 -#include "../Common/ItemNameUtils.h"
  337.11 -#include "../../../../C/CpuArch.h"
  337.12 -
  337.13 -namespace NArchive {
  337.14 -namespace NZip {
  337.15 -
  337.16 -bool operator==(const CVersion &v1, const CVersion &v2)
  337.17 -{
  337.18 -  return (v1.Version == v2.Version) && (v1.HostOS == v2.HostOS);
  337.19 -}
  337.20 -
  337.21 -bool operator!=(const CVersion &v1, const CVersion &v2)
  337.22 -{
  337.23 -  return !(v1 == v2);
  337.24 -}
  337.25 -
  337.26 -bool CExtraSubBlock::ExtractNtfsTime(int index, FILETIME &ft) const
  337.27 -{
  337.28 -  ft.dwHighDateTime = ft.dwLowDateTime = 0;
  337.29 -  UInt32 size = (UInt32)Data.GetCapacity();
  337.30 -  if (ID != NFileHeader::NExtraID::kNTFS || size < 32)
  337.31 -    return false;
  337.32 -  const Byte *p = (const Byte *)Data;
  337.33 -  p += 4; // for reserved
  337.34 -  size -= 4;
  337.35 -  while (size > 4)
  337.36 -  {
  337.37 -    UInt16 tag = GetUi16(p);
  337.38 -    UInt32 attrSize = GetUi16(p + 2);
  337.39 -    p += 4;
  337.40 -    size -= 4;
  337.41 -    if (attrSize > size)
  337.42 -      attrSize = size;
  337.43 -    
  337.44 -    if (tag == NFileHeader::NNtfsExtra::kTagTime && attrSize >= 24)
  337.45 -    {
  337.46 -      p += 8 * index;
  337.47 -      ft.dwLowDateTime = GetUi32(p);
  337.48 -      ft.dwHighDateTime = GetUi32(p + 4);
  337.49 -      return true;
  337.50 -    }
  337.51 -    p += attrSize;
  337.52 -    size -= attrSize;
  337.53 -  }
  337.54 -  return false;
  337.55 -}
  337.56 -
  337.57 -bool CLocalItem::IsDir() const
  337.58 -{
  337.59 -  return NItemName::HasTailSlash(Name, GetCodePage());
  337.60 -}
  337.61 -
  337.62 -bool CItem::IsDir() const
  337.63 -{
  337.64 -  if (NItemName::HasTailSlash(Name, GetCodePage()))
  337.65 -    return true;
  337.66 -  if (!FromCentral)
  337.67 -    return false;
  337.68 -  WORD highAttributes = WORD((ExternalAttributes >> 16 ) & 0xFFFF);
  337.69 -  switch(MadeByVersion.HostOS)
  337.70 -  {
  337.71 -    case NFileHeader::NHostOS::kAMIGA:
  337.72 -      switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
  337.73 -      {
  337.74 -        case NFileHeader::NAmigaAttribute::kIFDIR: return true;
  337.75 -        case NFileHeader::NAmigaAttribute::kIFREG: return false;
  337.76 -        default: return false; // change it throw kUnknownAttributes;
  337.77 -      }
  337.78 -    case NFileHeader::NHostOS::kFAT:
  337.79 -    case NFileHeader::NHostOS::kNTFS:
  337.80 -    case NFileHeader::NHostOS::kHPFS:
  337.81 -    case NFileHeader::NHostOS::kVFAT:
  337.82 -      return ((ExternalAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
  337.83 -    case NFileHeader::NHostOS::kAtari:
  337.84 -    case NFileHeader::NHostOS::kMac:
  337.85 -    case NFileHeader::NHostOS::kVMS:
  337.86 -    case NFileHeader::NHostOS::kVM_CMS:
  337.87 -    case NFileHeader::NHostOS::kAcorn:
  337.88 -    case NFileHeader::NHostOS::kMVS:
  337.89 -      return false; // change it throw kUnknownAttributes;
  337.90 -    default:
  337.91 -      /*
  337.92 -      switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
  337.93 -      {
  337.94 -        case NFileHeader::NUnixAttribute::kIFDIR:
  337.95 -          return true;
  337.96 -        default:
  337.97 -          return false;
  337.98 -      }
  337.99 -      */
 337.100 -      return false;
 337.101 -  }
 337.102 -}
 337.103 -
 337.104 -UInt32 CLocalItem::GetWinAttributes() const
 337.105 -{
 337.106 -  DWORD winAttributes = 0;
 337.107 -  if (IsDir())
 337.108 -    winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
 337.109 -  return winAttributes;
 337.110 -}
 337.111 -
 337.112 -UInt32 CItem::GetWinAttributes() const
 337.113 -{
 337.114 -  DWORD winAttributes = 0;
 337.115 -  switch(MadeByVersion.HostOS)
 337.116 -  {
 337.117 -    case NFileHeader::NHostOS::kFAT:
 337.118 -    case NFileHeader::NHostOS::kNTFS:
 337.119 -      if (FromCentral)
 337.120 -        winAttributes = ExternalAttributes;
 337.121 -      break;
 337.122 -    default:
 337.123 -      winAttributes = 0; // must be converted from unix value;
 337.124 -  }
 337.125 -  if (IsDir())       // test it;
 337.126 -    winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
 337.127 -  return winAttributes;
 337.128 -}
 337.129 -
 337.130 -void CLocalItem::SetFlagBits(int startBitNumber, int numBits, int value)
 337.131 -{
 337.132 -  UInt16 mask = (UInt16)(((1 << numBits) - 1) << startBitNumber);
 337.133 -  Flags &= ~mask;
 337.134 -  Flags |= value << startBitNumber;
 337.135 -}
 337.136 -
 337.137 -void CLocalItem::SetBitMask(int bitMask, bool enable)
 337.138 -{
 337.139 -  if(enable)
 337.140 -    Flags |= bitMask;
 337.141 -  else
 337.142 -    Flags &= ~bitMask;
 337.143 -}
 337.144 -
 337.145 -void CLocalItem::SetEncrypted(bool encrypted)
 337.146 -  { SetBitMask(NFileHeader::NFlags::kEncrypted, encrypted); }
 337.147 -void CLocalItem::SetUtf8(bool isUtf8)
 337.148 -  { SetBitMask(NFileHeader::NFlags::kUtf8, isUtf8); }
 337.149 -
 337.150 -}}
   338.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItem.h	Sat Mar 03 10:54:39 2012 -0600
   338.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   338.3 @@ -1,268 +0,0 @@
   338.4 -// Archive/ZipItem.h
   338.5 -
   338.6 -#ifndef __ARCHIVE_ZIP_ITEM_H
   338.7 -#define __ARCHIVE_ZIP_ITEM_H
   338.8 -
   338.9 -#include "../../../Common/Types.h"
  338.10 -#include "../../../Common/MyString.h"
  338.11 -#include "../../../Common/Buffer.h"
  338.12 -#include "../../../Common/UTFConvert.h"
  338.13 -#include "../../../Common/StringConvert.h"
  338.14 -
  338.15 -#include "ZipHeader.h"
  338.16 -
  338.17 -namespace NArchive {
  338.18 -namespace NZip {
  338.19 -
  338.20 -struct CVersion
  338.21 -{
  338.22 -  Byte Version;
  338.23 -  Byte HostOS;
  338.24 -};
  338.25 -
  338.26 -bool operator==(const CVersion &v1, const CVersion &v2);
  338.27 -bool operator!=(const CVersion &v1, const CVersion &v2);
  338.28 -
  338.29 -struct CExtraSubBlock
  338.30 -{
  338.31 -  UInt16 ID;
  338.32 -  CByteBuffer Data;
  338.33 -  bool ExtractNtfsTime(int index, FILETIME &ft) const;
  338.34 -};
  338.35 -
  338.36 -struct CWzAesExtraField
  338.37 -{
  338.38 -  UInt16 VendorVersion; // 0x0001 - AE-1, 0x0002 - AE-2,
  338.39 -  // UInt16 VendorId; // "AE"
  338.40 -  Byte Strength; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
  338.41 -  UInt16 Method;
  338.42 -
  338.43 -  CWzAesExtraField(): VendorVersion(2), Strength(3), Method(0) {}
  338.44 -
  338.45 -  bool NeedCrc() const { return (VendorVersion == 1); }
  338.46 -
  338.47 -  bool ParseFromSubBlock(const CExtraSubBlock &sb)
  338.48 -  {
  338.49 -    if (sb.ID != NFileHeader::NExtraID::kWzAES)
  338.50 -      return false;
  338.51 -    if (sb.Data.GetCapacity() < 7)
  338.52 -      return false;
  338.53 -    const Byte *p = (const Byte *)sb.Data;
  338.54 -    VendorVersion = (((UInt16)p[1]) << 8) | p[0];
  338.55 -    if (p[2] != 'A' || p[3] != 'E')
  338.56 -      return false;
  338.57 -    Strength = p[4];
  338.58 -    Method = (((UInt16)p[6]) << 16) | p[5];
  338.59 -    return true;
  338.60 -  }
  338.61 -  void SetSubBlock(CExtraSubBlock &sb) const
  338.62 -  {
  338.63 -    sb.Data.SetCapacity(7);
  338.64 -    sb.ID = NFileHeader::NExtraID::kWzAES;
  338.65 -    Byte *p = (Byte *)sb.Data;
  338.66 -    p[0] = (Byte)VendorVersion;
  338.67 -    p[1] = (Byte)(VendorVersion >> 8);
  338.68 -    p[2] = 'A';
  338.69 -    p[3] = 'E';
  338.70 -    p[4] = Strength;
  338.71 -    p[5] = (Byte)Method;
  338.72 -    p[6] = (Byte)(Method >> 8);
  338.73 -  }
  338.74 -};
  338.75 -
  338.76 -namespace NStrongCryptoFlags
  338.77 -{
  338.78 -  const UInt16 kDES = 0x6601;
  338.79 -  const UInt16 kRC2old = 0x6602;
  338.80 -  const UInt16 k3DES168 = 0x6603;
  338.81 -  const UInt16 k3DES112 = 0x6609;
  338.82 -  const UInt16 kAES128 = 0x660E;
  338.83 -  const UInt16 kAES192 = 0x660F;
  338.84 -  const UInt16 kAES256 = 0x6610;
  338.85 -  const UInt16 kRC2 = 0x6702;
  338.86 -  const UInt16 kBlowfish = 0x6720;
  338.87 -  const UInt16 kTwofish = 0x6721;
  338.88 -  const UInt16 kRC4 = 0x6801;
  338.89 -}
  338.90 -
  338.91 -struct CStrongCryptoField
  338.92 -{
  338.93 -  UInt16 Format;
  338.94 -  UInt16 AlgId;
  338.95 -  UInt16 BitLen;
  338.96 -  UInt16 Flags;
  338.97 -
  338.98 -  bool ParseFromSubBlock(const CExtraSubBlock &sb)
  338.99 -  {
 338.100 -    if (sb.ID != NFileHeader::NExtraID::kStrongEncrypt)
 338.101 -      return false;
 338.102 -    const Byte *p = (const Byte *)sb.Data;
 338.103 -    if (sb.Data.GetCapacity() < 8)
 338.104 -      return false;
 338.105 -    Format = (((UInt16)p[1]) << 8) | p[0];
 338.106 -    AlgId  = (((UInt16)p[3]) << 8) | p[2];
 338.107 -    BitLen = (((UInt16)p[5]) << 8) | p[4];
 338.108 -    Flags  = (((UInt16)p[7]) << 8) | p[6];
 338.109 -    return (Format == 2);
 338.110 -  }
 338.111 -};
 338.112 -
 338.113 -struct CExtraBlock
 338.114 -{
 338.115 -  CObjectVector<CExtraSubBlock> SubBlocks;
 338.116 -  void Clear() { SubBlocks.Clear(); }
 338.117 -  size_t GetSize() const
 338.118 -  {
 338.119 -    size_t res = 0;
 338.120 -    for (int i = 0; i < SubBlocks.Size(); i++)
 338.121 -      res += SubBlocks[i].Data.GetCapacity() + 2 + 2;
 338.122 -    return res;
 338.123 -  }
 338.124 -  bool GetWzAesField(CWzAesExtraField &aesField) const
 338.125 -  {
 338.126 -    for (int i = 0; i < SubBlocks.Size(); i++)
 338.127 -      if (aesField.ParseFromSubBlock(SubBlocks[i]))
 338.128 -        return true;
 338.129 -    return false;
 338.130 -  }
 338.131 -
 338.132 -  bool GetStrongCryptoField(CStrongCryptoField &f) const
 338.133 -  {
 338.134 -    for (int i = 0; i < SubBlocks.Size(); i++)
 338.135 -      if (f.ParseFromSubBlock(SubBlocks[i]))
 338.136 -        return true;
 338.137 -    return false;
 338.138 -  }
 338.139 -
 338.140 -  bool HasWzAesField() const
 338.141 -  {
 338.142 -    CWzAesExtraField aesField;
 338.143 -    return GetWzAesField(aesField);
 338.144 -  }
 338.145 -
 338.146 -  bool GetNtfsTime(int index, FILETIME &ft) const
 338.147 -  {
 338.148 -    for (int i = 0; i < SubBlocks.Size(); i++)
 338.149 -    {
 338.150 -      const CExtraSubBlock &sb = SubBlocks[i];
 338.151 -      if (sb.ID == NFileHeader::NExtraID::kNTFS)
 338.152 -        return sb.ExtractNtfsTime(index, ft);
 338.153 -    }
 338.154 -    return false;
 338.155 -  }
 338.156 -
 338.157 -  /*
 338.158 -  bool HasStrongCryptoField() const
 338.159 -  {
 338.160 -    CStrongCryptoField f;
 338.161 -    return GetStrongCryptoField(f);
 338.162 -  }
 338.163 -  */
 338.164 -
 338.165 -  void RemoveUnknownSubBlocks()
 338.166 -  {
 338.167 -    for (int i = SubBlocks.Size() - 1; i >= 0; i--)
 338.168 -      if (SubBlocks[i].ID != NFileHeader::NExtraID::kWzAES)
 338.169 -        SubBlocks.Delete(i);
 338.170 -  }
 338.171 -};
 338.172 -
 338.173 -
 338.174 -class CLocalItem
 338.175 -{
 338.176 -public:
 338.177 -  CVersion ExtractVersion;
 338.178 -  UInt16 Flags;
 338.179 -  UInt16 CompressionMethod;
 338.180 -  UInt32 Time;
 338.181 -  UInt32 FileCRC;
 338.182 -  UInt64 PackSize;
 338.183 -  UInt64 UnPackSize;
 338.184 -  
 338.185 -  AString Name;
 338.186 -
 338.187 -  CExtraBlock LocalExtra;
 338.188 -
 338.189 -  bool IsUtf8() const { return (Flags & NFileHeader::NFlags::kUtf8) != 0; }
 338.190 -  
 338.191 -  bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; }
 338.192 -  bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; };
 338.193 -  
 338.194 -  bool IsLzmaEOS() const { return (Flags & NFileHeader::NFlags::kLzmaEOS) != 0; }
 338.195 -  
 338.196 -  bool IsDir() const;
 338.197 -  bool IgnoreItem() const { return false; }
 338.198 -  UInt32 GetWinAttributes() const;
 338.199 -  
 338.200 -  bool HasDescriptor() const  { return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
 338.201 -
 338.202 -  UString GetUnicodeString(const AString &s) const
 338.203 -  {
 338.204 -    UString res;
 338.205 -    if (IsUtf8())
 338.206 -      if (!ConvertUTF8ToUnicode(s, res))
 338.207 -        res.Empty();
 338.208 -    if (res.IsEmpty())
 338.209 -      res = MultiByteToUnicodeString(s, GetCodePage());
 338.210 -    return res;
 338.211 -  }
 338.212 -  
 338.213 -private:
 338.214 -  void SetFlagBits(int startBitNumber, int numBits, int value);
 338.215 -  void SetBitMask(int bitMask, bool enable);
 338.216 -public:
 338.217 -  void ClearFlags() { Flags = 0; }
 338.218 -  void SetEncrypted(bool encrypted);
 338.219 -  void SetUtf8(bool isUtf8);
 338.220 -
 338.221 -  WORD GetCodePage() const { return  CP_OEMCP; }
 338.222 -};
 338.223 -
 338.224 -class CItem: public CLocalItem
 338.225 -{
 338.226 -public:
 338.227 -  CVersion MadeByVersion;
 338.228 -  UInt16 InternalAttributes;
 338.229 -  UInt32 ExternalAttributes;
 338.230 -  
 338.231 -  UInt64 LocalHeaderPosition;
 338.232 -  
 338.233 -  FILETIME NtfsMTime;
 338.234 -  FILETIME NtfsATime;
 338.235 -  FILETIME NtfsCTime;
 338.236 -
 338.237 -  CExtraBlock CentralExtra;
 338.238 -  CByteBuffer Comment;
 338.239 -
 338.240 -  bool FromLocal;
 338.241 -  bool FromCentral;
 338.242 -  bool NtfsTimeIsDefined;
 338.243 -  
 338.244 -  bool IsDir() const;
 338.245 -  UInt32 GetWinAttributes() const;
 338.246 -
 338.247 -  bool IsThereCrc() const
 338.248 -  {
 338.249 -    if (CompressionMethod == NFileHeader::NCompressionMethod::kWzAES)
 338.250 -    {
 338.251 -      CWzAesExtraField aesField;
 338.252 -      if (CentralExtra.GetWzAesField(aesField))
 338.253 -        return aesField.NeedCrc();
 338.254 -    }
 338.255 -    return (FileCRC != 0 || !IsDir());
 338.256 -  }
 338.257 -  
 338.258 -  WORD GetCodePage() const
 338.259 -  {
 338.260 -    return (WORD)((MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT
 338.261 -        || MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS
 338.262 -        ) ? CP_OEMCP : CP_ACP);
 338.263 -  }
 338.264 -  CItem() : FromLocal(false), FromCentral(false), NtfsTimeIsDefined(false) {}
 338.265 -};
 338.266 -
 338.267 -}}
 338.268 -
 338.269 -#endif
 338.270 -
 338.271 -
   339.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipItemEx.h	Sat Mar 03 10:54:39 2012 -0600
   339.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   339.3 @@ -1,34 +0,0 @@
   339.4 -// Archive/ZipItemEx.h
   339.5 -
   339.6 -#ifndef __ARCHIVE_ZIP_ITEMEX_H
   339.7 -#define __ARCHIVE_ZIP_ITEMEX_H
   339.8 -
   339.9 -#include "ZipHeader.h"
  339.10 -#include "ZipItem.h"
  339.11 -
  339.12 -namespace NArchive {
  339.13 -namespace NZip {
  339.14 -  
  339.15 -class CItemEx: public CItem
  339.16 -{
  339.17 -public:
  339.18 -  UInt32 FileHeaderWithNameSize;
  339.19 -  UInt16 LocalExtraSize;
  339.20 -  
  339.21 -  UInt64 GetLocalFullSize() const
  339.22 -    { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
  339.23 -      (HasDescriptor() ? NFileHeader::kDataDescriptorSize : 0); };
  339.24 -  /*
  339.25 -  UInt64 GetLocalFullSize(bool isZip64) const
  339.26 -    { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
  339.27 -    (HasDescriptor() ? (isZip64 ? NFileHeader::kDataDescriptor64Size : NFileHeader::kDataDescriptorSize) : 0); };
  339.28 -  */
  339.29 -  UInt64 GetLocalExtraPosition() const
  339.30 -    { return LocalHeaderPosition + FileHeaderWithNameSize; };
  339.31 -  UInt64 GetDataPosition() const
  339.32 -    { return GetLocalExtraPosition() + LocalExtraSize; };
  339.33 -};
  339.34 -
  339.35 -}}
  339.36 -
  339.37 -#endif
   340.1 --- a/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   340.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   340.3 @@ -1,21 +0,0 @@
   340.4 -// ZipRegister.cpp
   340.5 -
   340.6 -#include "StdAfx.h"
   340.7 -
   340.8 -#include "../../Common/RegisterArc.h"
   340.9 -
  340.10 -#include "ZipHandler.h"
  340.11 -static IInArchive *CreateArc() { return new NArchive::NZip::CHandler;  }
  340.12 -#ifndef EXTRACT_ONLY
  340.13 -static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler;  }
  340.14 -#else
  340.15 -#define CreateArcOut 0
  340.16 -#endif
  340.17 -
  340.18 -static CArcInfo g_ArcInfo  = { L"Zip", L"zip jar xpi zsg", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut };
  340.19 -static CArcInfo g_ArcInfo2 = { L"Zip", L"zip jar xpi zsg", 0, 1, { 0x50, 0x4B, 0x01, 0x02 }, 4, false, CreateArc, CreateArcOut };
  340.20 -static CArcInfo g_ArcInfo3 = { L"Zip", L"zip jar xpi zsg", 0, 1, { 0x50, 0x4B, 0x05, 0x06 }, 4, false, CreateArc, CreateArcOut };
  340.21 -
  340.22 -REGISTER_ARC(Zip)
  340.23 -REGISTER_ARCN(Zip,2)
  340.24 -REGISTER_ARCN(Zip,3)
   341.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/CreateCoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   341.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   341.3 @@ -1,292 +0,0 @@
   341.4 -// CreateCoder.cpp
   341.5 -
   341.6 -#include "StdAfx.h"
   341.7 -
   341.8 -#include "CreateCoder.h"
   341.9 -
  341.10 -#include "../../Windows/PropVariant.h"
  341.11 -#include "../../Windows/Defs.h"
  341.12 -#include "FilterCoder.h"
  341.13 -#include "RegisterCodec.h"
  341.14 -
  341.15 -static const unsigned int kNumCodecsMax = 64;
  341.16 -unsigned int g_NumCodecs = 0;
  341.17 -const CCodecInfo *g_Codecs[kNumCodecsMax];
  341.18 -void RegisterCodec(const CCodecInfo *codecInfo)
  341.19 -{
  341.20 -  if (g_NumCodecs < kNumCodecsMax)
  341.21 -    g_Codecs[g_NumCodecs++] = codecInfo;
  341.22 -}
  341.23 -
  341.24 -#ifdef EXTERNAL_CODECS
  341.25 -static HRESULT ReadNumberOfStreams(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, UInt32 &res)
  341.26 -{
  341.27 -  NWindows::NCOM::CPropVariant prop;
  341.28 -  RINOK(codecsInfo->GetProperty(index, propID, &prop));
  341.29 -  if (prop.vt == VT_EMPTY)
  341.30 -    res = 1;
  341.31 -  else if (prop.vt == VT_UI4)
  341.32 -    res = prop.ulVal;
  341.33 -  else
  341.34 -    return E_INVALIDARG;
  341.35 -  return S_OK;
  341.36 -}
  341.37 -
  341.38 -static HRESULT ReadIsAssignedProp(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, bool &res)
  341.39 -{
  341.40 -  NWindows::NCOM::CPropVariant prop;
  341.41 -  RINOK(codecsInfo->GetProperty(index, propID, &prop));
  341.42 -  if (prop.vt == VT_EMPTY)
  341.43 -    res = true;
  341.44 -  else if (prop.vt == VT_BOOL)
  341.45 -    res = VARIANT_BOOLToBool(prop.boolVal);
  341.46 -  else
  341.47 -    return E_INVALIDARG;
  341.48 -  return S_OK;
  341.49 -}
  341.50 -
  341.51 -HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs)
  341.52 -{
  341.53 -  UInt32 num;
  341.54 -  RINOK(codecsInfo->GetNumberOfMethods(&num));
  341.55 -  for (UInt32 i = 0; i < num; i++)
  341.56 -  {
  341.57 -    CCodecInfoEx info;
  341.58 -    NWindows::NCOM::CPropVariant prop;
  341.59 -    RINOK(codecsInfo->GetProperty(i, NMethodPropID::kID, &prop));
  341.60 -    // if (prop.vt != VT_BSTR)
  341.61 -    // info.Id.IDSize = (Byte)SysStringByteLen(prop.bstrVal);
  341.62 -    // memmove(info.Id.ID, prop.bstrVal, info.Id.IDSize);
  341.63 -    if (prop.vt != VT_UI8)
  341.64 -    {
  341.65 -      continue; // old Interface
  341.66 -      // return E_INVALIDARG;
  341.67 -    }
  341.68 -    info.Id = prop.uhVal.QuadPart;
  341.69 -    prop.Clear();
  341.70 -    
  341.71 -    RINOK(codecsInfo->GetProperty(i, NMethodPropID::kName, &prop));
  341.72 -    if (prop.vt == VT_BSTR)
  341.73 -      info.Name = prop.bstrVal;
  341.74 -    else if (prop.vt != VT_EMPTY)
  341.75 -      return E_INVALIDARG;;
  341.76 -    
  341.77 -    RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kInStreams, info.NumInStreams));
  341.78 -    RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kOutStreams, info.NumOutStreams));
  341.79 -    RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned));
  341.80 -    RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned));
  341.81 -    
  341.82 -    externalCodecs.Add(info);
  341.83 -  }
  341.84 -  return S_OK;
  341.85 -}
  341.86 -
  341.87 -#endif
  341.88 -
  341.89 -bool FindMethod(
  341.90 -  #ifdef EXTERNAL_CODECS
  341.91 -  ICompressCodecsInfo * /* codecsInfo */, const CObjectVector<CCodecInfoEx> *externalCodecs,
  341.92 -  #endif
  341.93 -  const UString &name,
  341.94 -  CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams)
  341.95 -{
  341.96 -  UInt32 i;
  341.97 -  for (i = 0; i < g_NumCodecs; i++)
  341.98 -  {
  341.99 -    const CCodecInfo &codec = *g_Codecs[i];
 341.100 -    if (name.CompareNoCase(codec.Name) == 0)
 341.101 -    {
 341.102 -      methodId = codec.Id;
 341.103 -      numInStreams = codec.NumInStreams;
 341.104 -      numOutStreams = 1;
 341.105 -      return true;
 341.106 -    }
 341.107 -  }
 341.108 -  #ifdef EXTERNAL_CODECS
 341.109 -  if (externalCodecs)
 341.110 -    for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
 341.111 -    {
 341.112 -      const CCodecInfoEx &codec = (*externalCodecs)[i];
 341.113 -      if (codec.Name.CompareNoCase(name) == 0)
 341.114 -      {
 341.115 -        methodId = codec.Id;
 341.116 -        numInStreams = codec.NumInStreams;
 341.117 -        numOutStreams = codec.NumOutStreams;
 341.118 -        return true;
 341.119 -      }
 341.120 -    }
 341.121 -  #endif
 341.122 -  return false;
 341.123 -}
 341.124 -
 341.125 -bool FindMethod(
 341.126 -  #ifdef EXTERNAL_CODECS
 341.127 -  ICompressCodecsInfo * /* codecsInfo */, const CObjectVector<CCodecInfoEx> *externalCodecs,
 341.128 -  #endif
 341.129 -  CMethodId methodId, UString &name)
 341.130 -{
 341.131 -  UInt32 i;
 341.132 -  for (i = 0; i < g_NumCodecs; i++)
 341.133 -  {
 341.134 -    const CCodecInfo &codec = *g_Codecs[i];
 341.135 -    if (methodId == codec.Id)
 341.136 -    {
 341.137 -      name = codec.Name;
 341.138 -      return true;
 341.139 -    }
 341.140 -  }
 341.141 -  #ifdef EXTERNAL_CODECS
 341.142 -  if (externalCodecs)
 341.143 -    for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
 341.144 -    {
 341.145 -      const CCodecInfoEx &codec = (*externalCodecs)[i];
 341.146 -      if (methodId == codec.Id)
 341.147 -      {
 341.148 -        name = codec.Name;
 341.149 -        return true;
 341.150 -      }
 341.151 -    }
 341.152 -  #endif
 341.153 -  return false;
 341.154 -}
 341.155 -
 341.156 -HRESULT CreateCoder(
 341.157 -  DECL_EXTERNAL_CODECS_LOC_VARS
 341.158 -  CMethodId methodId,
 341.159 -  CMyComPtr<ICompressFilter> &filter,
 341.160 -  CMyComPtr<ICompressCoder> &coder,
 341.161 -  CMyComPtr<ICompressCoder2> &coder2,
 341.162 -  bool encode, bool onlyCoder)
 341.163 -{
 341.164 -  bool created = false;
 341.165 -  UInt32 i;
 341.166 -  for (i = 0; i < g_NumCodecs; i++)
 341.167 -  {
 341.168 -    const CCodecInfo &codec = *g_Codecs[i];
 341.169 -    if (codec.Id == methodId)
 341.170 -    {
 341.171 -      if (encode)
 341.172 -      {
 341.173 -        if (codec.CreateEncoder)
 341.174 -        {
 341.175 -          void *p = codec.CreateEncoder();
 341.176 -          if (codec.IsFilter) filter = (ICompressFilter *)p;
 341.177 -          else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
 341.178 -          else coder2 = (ICompressCoder2 *)p;
 341.179 -          created = (p != 0);
 341.180 -          break;
 341.181 -        }
 341.182 -      }
 341.183 -      else
 341.184 -        if (codec.CreateDecoder)
 341.185 -        {
 341.186 -          void *p = codec.CreateDecoder();
 341.187 -          if (codec.IsFilter) filter = (ICompressFilter *)p;
 341.188 -          else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
 341.189 -          else coder2 = (ICompressCoder2 *)p;
 341.190 -          created = (p != 0);
 341.191 -          break;
 341.192 -        }
 341.193 -    }
 341.194 -  }
 341.195 -
 341.196 -  #ifdef EXTERNAL_CODECS
 341.197 -  if (!created && externalCodecs)
 341.198 -    for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
 341.199 -    {
 341.200 -      const CCodecInfoEx &codec = (*externalCodecs)[i];
 341.201 -      if (codec.Id == methodId)
 341.202 -      {
 341.203 -        if (encode)
 341.204 -        {
 341.205 -          if (codec.EncoderIsAssigned)
 341.206 -          {
 341.207 -            if (codec.IsSimpleCodec())
 341.208 -            {
 341.209 -              HRESULT result = codecsInfo->CreateEncoder(i, &IID_ICompressCoder, (void **)&coder);
 341.210 -              if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
 341.211 -                return result;
 341.212 -              if (!coder)
 341.213 -              {
 341.214 -                RINOK(codecsInfo->CreateEncoder(i, &IID_ICompressFilter, (void **)&filter));
 341.215 -              }
 341.216 -            }
 341.217 -            else
 341.218 -            {
 341.219 -              RINOK(codecsInfo->CreateEncoder(i, &IID_ICompressCoder2, (void **)&coder2));
 341.220 -            }
 341.221 -            break;
 341.222 -          }
 341.223 -        }
 341.224 -        else
 341.225 -          if (codec.DecoderIsAssigned)
 341.226 -          {
 341.227 -            if (codec.IsSimpleCodec())
 341.228 -            {
 341.229 -              HRESULT result = codecsInfo->CreateDecoder(i, &IID_ICompressCoder, (void **)&coder);
 341.230 -              if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
 341.231 -                return result;
 341.232 -              if (!coder)
 341.233 -              {
 341.234 -                RINOK(codecsInfo->CreateDecoder(i, &IID_ICompressFilter, (void **)&filter));
 341.235 -              }
 341.236 -            }
 341.237 -            else
 341.238 -            {
 341.239 -              RINOK(codecsInfo->CreateDecoder(i, &IID_ICompressCoder2, (void **)&coder2));
 341.240 -            }
 341.241 -            break;
 341.242 -          }
 341.243 -      }
 341.244 -    }
 341.245 -  #endif
 341.246 -
 341.247 -  if (onlyCoder && filter)
 341.248 -  {
 341.249 -    CFilterCoder *coderSpec = new CFilterCoder;
 341.250 -    coder = coderSpec;
 341.251 -    coderSpec->Filter = filter;
 341.252 -  }
 341.253 -  return S_OK;
 341.254 -}
 341.255 -
 341.256 -HRESULT CreateCoder(
 341.257 -  DECL_EXTERNAL_CODECS_LOC_VARS
 341.258 -  CMethodId methodId,
 341.259 -  CMyComPtr<ICompressCoder> &coder,
 341.260 -  CMyComPtr<ICompressCoder2> &coder2,
 341.261 -  bool encode)
 341.262 -{
 341.263 -  CMyComPtr<ICompressFilter> filter;
 341.264 -  return CreateCoder(
 341.265 -    EXTERNAL_CODECS_LOC_VARS
 341.266 -    methodId,
 341.267 -    filter, coder, coder2, encode, true);
 341.268 -}
 341.269 -
 341.270 -HRESULT CreateCoder(
 341.271 -  DECL_EXTERNAL_CODECS_LOC_VARS
 341.272 -  CMethodId methodId,
 341.273 -  CMyComPtr<ICompressCoder> &coder, bool encode)
 341.274 -{
 341.275 -  CMyComPtr<ICompressFilter> filter;
 341.276 -  CMyComPtr<ICompressCoder2> coder2;
 341.277 -  return CreateCoder(
 341.278 -    EXTERNAL_CODECS_LOC_VARS
 341.279 -    methodId,
 341.280 -    coder, coder2, encode);
 341.281 -}
 341.282 -
 341.283 -HRESULT CreateFilter(
 341.284 -  DECL_EXTERNAL_CODECS_LOC_VARS
 341.285 -  CMethodId methodId,
 341.286 -  CMyComPtr<ICompressFilter> &filter,
 341.287 -  bool encode)
 341.288 -{
 341.289 -  CMyComPtr<ICompressCoder> coder;
 341.290 -  CMyComPtr<ICompressCoder2> coder2;
 341.291 -  return CreateCoder(
 341.292 -    EXTERNAL_CODECS_LOC_VARS
 341.293 -    methodId,
 341.294 -    filter, coder, coder2, encode, false);
 341.295 -}
   342.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/CreateCoder.h	Sat Mar 03 10:54:39 2012 -0600
   342.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   342.3 @@ -1,98 +0,0 @@
   342.4 -// CreateCoder.h
   342.5 -
   342.6 -#ifndef __CREATECODER_H
   342.7 -#define __CREATECODER_H
   342.8 -
   342.9 -#include "../../Common/MyCom.h"
  342.10 -#include "../../Common/MyString.h"
  342.11 -#include "../ICoder.h"
  342.12 -
  342.13 -#include "MethodId.h"
  342.14 -
  342.15 -#ifdef EXTERNAL_CODECS
  342.16 -
  342.17 -struct CCodecInfoEx
  342.18 -{
  342.19 -  UString Name;
  342.20 -  CMethodId Id;
  342.21 -  UInt32 NumInStreams;
  342.22 -  UInt32 NumOutStreams;
  342.23 -  bool EncoderIsAssigned;
  342.24 -  bool DecoderIsAssigned;
  342.25 -  bool IsSimpleCodec() const { return NumOutStreams == 1 && NumInStreams == 1; }
  342.26 -  CCodecInfoEx(): EncoderIsAssigned(false), DecoderIsAssigned(false) {}
  342.27 -};
  342.28 -
  342.29 -HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs);
  342.30 -
  342.31 -#define PUBLIC_ISetCompressCodecsInfo public ISetCompressCodecsInfo,
  342.32 -#define QUERY_ENTRY_ISetCompressCodecsInfo MY_QUERYINTERFACE_ENTRY(ISetCompressCodecsInfo)
  342.33 -#define DECL_ISetCompressCodecsInfo STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo);
  342.34 -#define IMPL_ISetCompressCodecsInfo2(x) \
  342.35 -STDMETHODIMP x::SetCompressCodecsInfo(ICompressCodecsInfo *compressCodecsInfo) { \
  342.36 -  COM_TRY_BEGIN _codecsInfo = compressCodecsInfo;  return LoadExternalCodecs(_codecsInfo, _externalCodecs); COM_TRY_END }
  342.37 -#define IMPL_ISetCompressCodecsInfo IMPL_ISetCompressCodecsInfo2(CHandler)
  342.38 -
  342.39 -#define EXTERNAL_CODECS_VARS2 _codecsInfo, &_externalCodecs
  342.40 -
  342.41 -#define DECL_EXTERNAL_CODECS_VARS CMyComPtr<ICompressCodecsInfo> _codecsInfo; CObjectVector<CCodecInfoEx> _externalCodecs;
  342.42 -#define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2,
  342.43 -
  342.44 -#define DECL_EXTERNAL_CODECS_LOC_VARS2 ICompressCodecsInfo *codecsInfo, const CObjectVector<CCodecInfoEx> *externalCodecs
  342.45 -#define EXTERNAL_CODECS_LOC_VARS2 codecsInfo, externalCodecs
  342.46 -
  342.47 -#define DECL_EXTERNAL_CODECS_LOC_VARS DECL_EXTERNAL_CODECS_LOC_VARS2,
  342.48 -#define EXTERNAL_CODECS_LOC_VARS EXTERNAL_CODECS_LOC_VARS2,
  342.49 -
  342.50 -#else
  342.51 -
  342.52 -#define PUBLIC_ISetCompressCodecsInfo
  342.53 -#define QUERY_ENTRY_ISetCompressCodecsInfo
  342.54 -#define DECL_ISetCompressCodecsInfo
  342.55 -#define IMPL_ISetCompressCodecsInfo
  342.56 -#define EXTERNAL_CODECS_VARS2
  342.57 -#define DECL_EXTERNAL_CODECS_VARS
  342.58 -#define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2
  342.59 -#define DECL_EXTERNAL_CODECS_LOC_VARS2
  342.60 -#define EXTERNAL_CODECS_LOC_VARS2
  342.61 -#define DECL_EXTERNAL_CODECS_LOC_VARS
  342.62 -#define EXTERNAL_CODECS_LOC_VARS
  342.63 -
  342.64 -#endif
  342.65 -
  342.66 -bool FindMethod(
  342.67 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.68 -  const UString &name, CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams);
  342.69 -
  342.70 -bool FindMethod(
  342.71 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.72 -  CMethodId methodId, UString &name);
  342.73 -
  342.74 -
  342.75 -HRESULT CreateCoder(
  342.76 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.77 -  CMethodId methodId,
  342.78 -  CMyComPtr<ICompressFilter> &filter,
  342.79 -  CMyComPtr<ICompressCoder> &coder,
  342.80 -  CMyComPtr<ICompressCoder2> &coder2,
  342.81 -  bool encode, bool onlyCoder);
  342.82 -
  342.83 -HRESULT CreateCoder(
  342.84 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.85 -  CMethodId methodId,
  342.86 -  CMyComPtr<ICompressCoder> &coder,
  342.87 -  CMyComPtr<ICompressCoder2> &coder2,
  342.88 -  bool encode);
  342.89 -
  342.90 -HRESULT CreateCoder(
  342.91 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.92 -  CMethodId methodId,
  342.93 -  CMyComPtr<ICompressCoder> &coder, bool encode);
  342.94 -
  342.95 -HRESULT CreateFilter(
  342.96 -  DECL_EXTERNAL_CODECS_LOC_VARS
  342.97 -  CMethodId methodId,
  342.98 -  CMyComPtr<ICompressFilter> &filter,
  342.99 -  bool encode);
 342.100 -
 342.101 -#endif
   343.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/DeclareArcs.h	Sat Mar 03 10:54:39 2012 -0600
   343.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   343.3 @@ -1,28 +0,0 @@
   343.4 -// DeclareArcs.h
   343.5 -
   343.6 -#ifndef __DECLAREARCS_H
   343.7 -#define __DECLAREARCS_H
   343.8 -
   343.9 -#define DECLARE_ARC(x) struct CRegister##x { CRegister##x(); }; \
  343.10 -	FORCE_REF(CRegister##x, g_RegisterArc##x)
  343.11 -
  343.12 -#define DECLARE_ARCN(x,n) struct CRegister##x##n { CRegister##x##n(); }; \
  343.13 -	FORCE_REF(CRegister##x##n, g_RegisterArc##n##x)
  343.14 -
  343.15 -#ifndef FORCE_REF
  343.16 -	#define FORCE_REF(x,y)
  343.17 -#endif
  343.18 -
  343.19 -DECLARE_ARC(7z)
  343.20 -DECLARE_ARC(BZip2)
  343.21 -DECLARE_ARC(GZip)
  343.22 -DECLARE_ARC(Lzh)
  343.23 -DECLARE_ARC(Lzma)
  343.24 -DECLARE_ARC(Rar)
  343.25 -DECLARE_ARC(Split)
  343.26 -DECLARE_ARC(Tar)
  343.27 -DECLARE_ARC(Zip)
  343.28 -DECLARE_ARCN(Zip,2)
  343.29 -DECLARE_ARCN(Zip,3)
  343.30 -
  343.31 -#endif
   344.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/DeclareCodecs.h	Sat Mar 03 10:54:39 2012 -0600
   344.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   344.3 @@ -1,31 +0,0 @@
   344.4 -// DeclareCodecs.h
   344.5 -
   344.6 -#ifndef __DECLARECODECS_H
   344.7 -#define __DECLARECODECS_H
   344.8 -
   344.9 -#define DECLARE_CODEC(x) struct CRegisterCodec##x { CRegisterCodec##x(); }; \
  344.10 -	FORCE_REF(CRegisterCodec##x, g_RegisterCodec##x)
  344.11 -
  344.12 -#define DECLARE_CODECS(x) struct CRegisterCodecs##x { CRegisterCodecs##x(); }; \
  344.13 -	FORCE_REF(CRegisterCodecs##x, g_RegisterCodecs##x)
  344.14 -
  344.15 -#ifndef FORCE_REF
  344.16 -	#define FORCE_REF(x,y)
  344.17 -#endif
  344.18 -
  344.19 -DECLARE_CODEC(7zAES)
  344.20 -DECLARE_CODEC(BCJ2)
  344.21 -DECLARE_CODEC(BCJ)
  344.22 -DECLARE_CODEC(BZip2)
  344.23 -DECLARE_CODEC(Copy)
  344.24 -DECLARE_CODEC(Deflate64)
  344.25 -DECLARE_CODEC(DeflateNsis)
  344.26 -DECLARE_CODEC(Deflate)
  344.27 -DECLARE_CODEC(LZMA)
  344.28 -DECLARE_CODEC(PPMD)
  344.29 -
  344.30 -DECLARE_CODECS(Branch)
  344.31 -DECLARE_CODECS(ByteSwap)
  344.32 -DECLARE_CODECS(Rar)
  344.33 -
  344.34 -#endif
   345.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   345.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   345.3 @@ -1,262 +0,0 @@
   345.4 -// FilterCoder.cpp
   345.5 -
   345.6 -#include "StdAfx.h"
   345.7 -
   345.8 -#include "FilterCoder.h"
   345.9 -extern "C"
  345.10 -{
  345.11 -#include "../../../C/Alloc.h"
  345.12 -}
  345.13 -#include "../../Common/Defs.h"
  345.14 -#include "StreamUtils.h"
  345.15 -
  345.16 -static const UInt32 kBufferSize = 1 << 17;
  345.17 -
  345.18 -CFilterCoder::CFilterCoder()
  345.19 -{
  345.20 -  _buffer = (Byte *)::MidAlloc(kBufferSize);
  345.21 -}
  345.22 -
  345.23 -CFilterCoder::~CFilterCoder()
  345.24 -{
  345.25 -  ::MidFree(_buffer);
  345.26 -}
  345.27 -
  345.28 -HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
  345.29 -{
  345.30 -  if (_outSizeIsDefined)
  345.31 -  {
  345.32 -    UInt64 remSize = _outSize - _nowPos64;
  345.33 -    if (size > remSize)
  345.34 -      size = (UInt32)remSize;
  345.35 -  }
  345.36 -  RINOK(WriteStream(outStream, _buffer, size));
  345.37 -  _nowPos64 += size;
  345.38 -  return S_OK;
  345.39 -}
  345.40 -
  345.41 -
  345.42 -STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
  345.43 -      ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
  345.44 -      ICompressProgressInfo *progress)
  345.45 -{
  345.46 -  RINOK(Init());
  345.47 -  UInt32 bufferPos = 0;
  345.48 -  _outSizeIsDefined = (outSize != 0);
  345.49 -  if (_outSizeIsDefined)
  345.50 -    _outSize = *outSize;
  345.51 -
  345.52 -  while(NeedMore())
  345.53 -  {
  345.54 -    size_t processedSize = kBufferSize - bufferPos;
  345.55 -    
  345.56 -    // Change it: It can be optimized using ReadPart
  345.57 -    RINOK(ReadStream(inStream, _buffer + bufferPos, &processedSize));
  345.58 -    
  345.59 -    UInt32 endPos = bufferPos + (UInt32)processedSize;
  345.60 -
  345.61 -    bufferPos = Filter->Filter(_buffer, endPos);
  345.62 -    if (bufferPos > endPos)
  345.63 -    {
  345.64 -      for (; endPos< bufferPos; endPos++)
  345.65 -        _buffer[endPos] = 0;
  345.66 -      bufferPos = Filter->Filter(_buffer, endPos);
  345.67 -    }
  345.68 -
  345.69 -    if (bufferPos == 0)
  345.70 -    {
  345.71 -      if (endPos > 0)
  345.72 -        return WriteWithLimit(outStream, endPos);
  345.73 -      return S_OK;
  345.74 -    }
  345.75 -    RINOK(WriteWithLimit(outStream, bufferPos));
  345.76 -    if (progress != NULL)
  345.77 -    {
  345.78 -      RINOK(progress->SetRatioInfo(&_nowPos64, &_nowPos64));
  345.79 -    }
  345.80 -    UInt32 i = 0;
  345.81 -    while(bufferPos < endPos)
  345.82 -      _buffer[i++] = _buffer[bufferPos++];
  345.83 -    bufferPos = i;
  345.84 -  }
  345.85 -  return S_OK;
  345.86 -}
  345.87 -
  345.88 -// #ifdef _ST_MODE
  345.89 -STDMETHODIMP CFilterCoder::SetOutStream(ISequentialOutStream *outStream)
  345.90 -{
  345.91 -  _bufferPos = 0;
  345.92 -  _outStream = outStream;
  345.93 -  return Init();
  345.94 -}
  345.95 -
  345.96 -STDMETHODIMP CFilterCoder::ReleaseOutStream()
  345.97 -{
  345.98 -  _outStream.Release();
  345.99 -  return S_OK;
 345.100 -};
 345.101 -
 345.102 -
 345.103 -STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
 345.104 -{
 345.105 -  UInt32 processedSizeTotal = 0;
 345.106 -  while(size > 0)
 345.107 -  {
 345.108 -    UInt32 sizeMax = kBufferSize - _bufferPos;
 345.109 -    UInt32 sizeTemp = size;
 345.110 -    if (sizeTemp > sizeMax)
 345.111 -      sizeTemp = sizeMax;
 345.112 -    memmove(_buffer + _bufferPos, data, sizeTemp);
 345.113 -    size -= sizeTemp;
 345.114 -    processedSizeTotal += sizeTemp;
 345.115 -    data = (const Byte *)data + sizeTemp;
 345.116 -    UInt32 endPos = _bufferPos + sizeTemp;
 345.117 -    _bufferPos = Filter->Filter(_buffer, endPos);
 345.118 -    if (_bufferPos == 0)
 345.119 -    {
 345.120 -      _bufferPos = endPos;
 345.121 -      break;
 345.122 -    }
 345.123 -    if (_bufferPos > endPos)
 345.124 -    {
 345.125 -      if (size != 0)
 345.126 -        return E_FAIL;
 345.127 -      break;
 345.128 -    }
 345.129 -    RINOK(WriteWithLimit(_outStream, _bufferPos));
 345.130 -    UInt32 i = 0;
 345.131 -    while(_bufferPos < endPos)
 345.132 -      _buffer[i++] = _buffer[_bufferPos++];
 345.133 -    _bufferPos = i;
 345.134 -  }
 345.135 -  if (processedSize != NULL)
 345.136 -    *processedSize = processedSizeTotal;
 345.137 -  return S_OK;
 345.138 -}
 345.139 -
 345.140 -STDMETHODIMP CFilterCoder::Flush()
 345.141 -{
 345.142 -  if (_bufferPos != 0)
 345.143 -  {
 345.144 -    UInt32 endPos = Filter->Filter(_buffer, _bufferPos);
 345.145 -    if (endPos > _bufferPos)
 345.146 -    {
 345.147 -      for (; _bufferPos < endPos; _bufferPos++)
 345.148 -        _buffer[_bufferPos] = 0;
 345.149 -      if (Filter->Filter(_buffer, endPos) != endPos)
 345.150 -        return E_FAIL;
 345.151 -    }
 345.152 -    RINOK(WriteStream(_outStream, _buffer, _bufferPos));
 345.153 -    _bufferPos = 0;
 345.154 -  }
 345.155 -  CMyComPtr<IOutStreamFlush> flush;
 345.156 -  _outStream.QueryInterface(IID_IOutStreamFlush, &flush);
 345.157 -  if (flush)
 345.158 -    return  flush->Flush();
 345.159 -  return S_OK;
 345.160 -}
 345.161 -
 345.162 -
 345.163 -STDMETHODIMP CFilterCoder::SetInStream(ISequentialInStream *inStream)
 345.164 -{
 345.165 -  _convertedPosBegin = _convertedPosEnd = _bufferPos = 0;
 345.166 -  _inStream = inStream;
 345.167 -  return Init();
 345.168 -}
 345.169 -
 345.170 -STDMETHODIMP CFilterCoder::ReleaseInStream()
 345.171 -{
 345.172 -  _inStream.Release();
 345.173 -  return S_OK;
 345.174 -};
 345.175 -
 345.176 -STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
 345.177 -{
 345.178 -  UInt32 processedSizeTotal = 0;
 345.179 -  while(size > 0)
 345.180 -  {
 345.181 -    if (_convertedPosBegin != _convertedPosEnd)
 345.182 -    {
 345.183 -      UInt32 sizeTemp = MyMin(size, _convertedPosEnd - _convertedPosBegin);
 345.184 -      memmove(data, _buffer + _convertedPosBegin, sizeTemp);
 345.185 -      _convertedPosBegin += sizeTemp;
 345.186 -      data = (void *)((Byte *)data + sizeTemp);
 345.187 -      size -= sizeTemp;
 345.188 -      processedSizeTotal += sizeTemp;
 345.189 -      break;
 345.190 -    }
 345.191 -    int i;
 345.192 -    for (i = 0; _convertedPosEnd + i < _bufferPos; i++)
 345.193 -      _buffer[i] = _buffer[i + _convertedPosEnd];
 345.194 -    _bufferPos = i;
 345.195 -    _convertedPosBegin = _convertedPosEnd = 0;
 345.196 -    size_t processedSizeTemp = kBufferSize - _bufferPos;
 345.197 -    RINOK(ReadStream(_inStream, _buffer + _bufferPos, &processedSizeTemp));
 345.198 -    _bufferPos = _bufferPos + (UInt32)processedSizeTemp;
 345.199 -    _convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
 345.200 -    if (_convertedPosEnd == 0)
 345.201 -    {
 345.202 -      if (_bufferPos == 0)
 345.203 -        break;
 345.204 -      else
 345.205 -      {
 345.206 -        _convertedPosEnd = _bufferPos; // check it
 345.207 -        continue;
 345.208 -      }
 345.209 -    }
 345.210 -    if (_convertedPosEnd > _bufferPos)
 345.211 -    {
 345.212 -      for (; _bufferPos < _convertedPosEnd; _bufferPos++)
 345.213 -        _buffer[_bufferPos] = 0;
 345.214 -      _convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
 345.215 -    }
 345.216 -  }
 345.217 -  if (processedSize != NULL)
 345.218 -    *processedSize = processedSizeTotal;
 345.219 -  return S_OK;
 345.220 -}
 345.221 -
 345.222 -// #endif // _ST_MODE
 345.223 -
 345.224 -#ifndef _NO_CRYPTO
 345.225 -STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size)
 345.226 -{
 345.227 -  return _setPassword->CryptoSetPassword(data, size);
 345.228 -}
 345.229 -#endif
 345.230 -
 345.231 -#ifndef EXTRACT_ONLY
 345.232 -STDMETHODIMP CFilterCoder::SetCoderProperties(const PROPID *propIDs,
 345.233 -      const PROPVARIANT *properties, UInt32 numProperties)
 345.234 -{
 345.235 -  return _SetCoderProperties->SetCoderProperties(propIDs, properties, numProperties);
 345.236 -}
 345.237 -
 345.238 -STDMETHODIMP CFilterCoder::WriteCoderProperties(ISequentialOutStream *outStream)
 345.239 -{
 345.240 -  return _writeCoderProperties->WriteCoderProperties(outStream);
 345.241 -}
 345.242 -
 345.243 -/*
 345.244 -STDMETHODIMP CFilterCoder::ResetSalt()
 345.245 -{
 345.246 -  return _CryptoResetSalt->ResetSalt();
 345.247 -}
 345.248 -*/
 345.249 -
 345.250 -STDMETHODIMP CFilterCoder::ResetInitVector()
 345.251 -{
 345.252 -  return _CryptoResetInitVector->ResetInitVector();
 345.253 -}
 345.254 -#endif
 345.255 -
 345.256 -STDMETHODIMP CFilterCoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 345.257 -{
 345.258 -  return _setDecoderProperties->SetDecoderProperties2(data, size);
 345.259 -}
 345.260 -
 345.261 -
 345.262 -
 345.263 -void foo()
 345.264 -{
 345.265 -}
   346.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.h	Sat Mar 03 10:54:39 2012 -0600
   346.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   346.3 @@ -1,143 +0,0 @@
   346.4 -// FilterCoder.h
   346.5 -
   346.6 -#ifndef __FILTERCODER_H
   346.7 -#define __FILTERCODER_H
   346.8 -
   346.9 -#include "../../Common/MyCom.h"
  346.10 -#include "../ICoder.h"
  346.11 -#include "../IPassword.h"
  346.12 -
  346.13 -#define MY_QUERYINTERFACE_ENTRY_AG(i, sub0, sub) if (iid == IID_ ## i) \
  346.14 -{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \
  346.15 -*outObject = (void *)(i *)this; AddRef(); return S_OK; }
  346.16 -
  346.17 -class CFilterCoder:
  346.18 -  public ICompressCoder,
  346.19 -  // #ifdef _ST_MODE
  346.20 -  public ICompressSetInStream,
  346.21 -  public ISequentialInStream,
  346.22 -  public ICompressSetOutStream,
  346.23 -  public ISequentialOutStream,
  346.24 -  public IOutStreamFlush,
  346.25 -  // #endif
  346.26 -
  346.27 -  #ifndef _NO_CRYPTO
  346.28 -  public ICryptoSetPassword,
  346.29 -  #endif
  346.30 -  #ifndef EXTRACT_ONLY
  346.31 -  public ICompressSetCoderProperties,
  346.32 -  public ICompressWriteCoderProperties,
  346.33 -  // public ICryptoResetSalt,
  346.34 -  public ICryptoResetInitVector,
  346.35 -  #endif
  346.36 -  public ICompressSetDecoderProperties2,
  346.37 -  public CMyUnknownImp
  346.38 -{
  346.39 -protected:
  346.40 -  Byte *_buffer;
  346.41 -  // #ifdef _ST_MODE
  346.42 -  CMyComPtr<ISequentialInStream> _inStream;
  346.43 -  CMyComPtr<ISequentialOutStream> _outStream;
  346.44 -  UInt32 _bufferPos;
  346.45 -  UInt32 _convertedPosBegin;
  346.46 -  UInt32 _convertedPosEnd;
  346.47 -  // #endif
  346.48 -  bool _outSizeIsDefined;
  346.49 -  UInt64 _outSize;
  346.50 -  UInt64 _nowPos64;
  346.51 -
  346.52 -  HRESULT Init()
  346.53 -  {
  346.54 -    _nowPos64 = 0;
  346.55 -    _outSizeIsDefined = false;
  346.56 -    return Filter->Init();
  346.57 -  }
  346.58 -
  346.59 -  CMyComPtr<ICryptoSetPassword> _setPassword;
  346.60 -  #ifndef EXTRACT_ONLY
  346.61 -  CMyComPtr<ICompressSetCoderProperties> _SetCoderProperties;
  346.62 -  CMyComPtr<ICompressWriteCoderProperties> _writeCoderProperties;
  346.63 -  // CMyComPtr<ICryptoResetSalt> _CryptoResetSalt;
  346.64 -  CMyComPtr<ICryptoResetInitVector> _CryptoResetInitVector;
  346.65 -  #endif
  346.66 -  CMyComPtr<ICompressSetDecoderProperties2> _setDecoderProperties;
  346.67 -public:
  346.68 -  CMyComPtr<ICompressFilter> Filter;
  346.69 -
  346.70 -  CFilterCoder();
  346.71 -  ~CFilterCoder();
  346.72 -  HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size);
  346.73 -  bool NeedMore() const
  346.74 -    { return (!_outSizeIsDefined || (_nowPos64 < _outSize)); }
  346.75 -
  346.76 -public:
  346.77 -  MY_QUERYINTERFACE_BEGIN
  346.78 -    MY_QUERYINTERFACE_ENTRY(ICompressCoder)
  346.79 -    // #ifdef _ST_MODE
  346.80 -    MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
  346.81 -    MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
  346.82 -
  346.83 -    MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream)
  346.84 -    MY_QUERYINTERFACE_ENTRY(ISequentialOutStream)
  346.85 -    MY_QUERYINTERFACE_ENTRY(IOutStreamFlush)
  346.86 -    // #endif
  346.87 -
  346.88 -    #ifndef _NO_CRYPTO
  346.89 -    MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword)
  346.90 -    #endif
  346.91 -
  346.92 -    #ifndef EXTRACT_ONLY
  346.93 -    MY_QUERYINTERFACE_ENTRY_AG(ICompressSetCoderProperties, Filter, _SetCoderProperties)
  346.94 -    MY_QUERYINTERFACE_ENTRY_AG(ICompressWriteCoderProperties, Filter, _writeCoderProperties)
  346.95 -    // MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetSalt, Filter, _CryptoResetSalt)
  346.96 -    MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetInitVector, Filter, _CryptoResetInitVector)
  346.97 -    #endif
  346.98 -
  346.99 -    MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties)
 346.100 -  MY_QUERYINTERFACE_END
 346.101 -  MY_ADDREF_RELEASE
 346.102 -  STDMETHOD(Code)(ISequentialInStream *inStream,
 346.103 -      ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
 346.104 -      ICompressProgressInfo *progress);
 346.105 -  // #ifdef _ST_MODE
 346.106 -  STDMETHOD(ReleaseInStream)();
 346.107 -  STDMETHOD(SetInStream)(ISequentialInStream *inStream);
 346.108 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \
 346.109 -  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
 346.110 -  STDMETHOD(ReleaseOutStream)();
 346.111 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
 346.112 -  STDMETHOD(Flush)();
 346.113 -  // #endif
 346.114 -
 346.115 -  #ifndef _NO_CRYPTO
 346.116 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
 346.117 -  #endif
 346.118 -  #ifndef EXTRACT_ONLY
 346.119 -  STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
 346.120 -      const PROPVARIANT *properties, UInt32 numProperties);
 346.121 -  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
 346.122 -  // STDMETHOD(ResetSalt)();
 346.123 -  STDMETHOD(ResetInitVector)();
 346.124 -  #endif
 346.125 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
 346.126 -};
 346.127 -
 346.128 -// #ifdef _ST_MODE
 346.129 -class CInStreamReleaser
 346.130 -{
 346.131 -public:
 346.132 -  CFilterCoder *FilterCoder;
 346.133 -  CInStreamReleaser(): FilterCoder(0) {}
 346.134 -  ~CInStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseInStream(); }
 346.135 -};
 346.136 -
 346.137 -class COutStreamReleaser
 346.138 -{
 346.139 -public:
 346.140 -  CFilterCoder *FilterCoder;
 346.141 -  COutStreamReleaser(): FilterCoder(0) {}
 346.142 -  ~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); }
 346.143 -};
 346.144 -// #endif
 346.145 -
 346.146 -#endif
   347.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/InBuffer.cpp	Sat Mar 03 10:54:39 2012 -0600
   347.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   347.3 @@ -1,83 +0,0 @@
   347.4 -// InBuffer.cpp
   347.5 -
   347.6 -#include "StdAfx.h"
   347.7 -
   347.8 -#include "InBuffer.h"
   347.9 -
  347.10 -extern "C"
  347.11 -{
  347.12 -  #include "../../../C/Alloc.h"
  347.13 -}
  347.14 -
  347.15 -CInBuffer::CInBuffer():
  347.16 -  _buffer(0),
  347.17 -  _bufferLimit(0),
  347.18 -  _bufferBase(0),
  347.19 -  _stream(0),
  347.20 -  _bufferSize(0)
  347.21 -{}
  347.22 -
  347.23 -bool CInBuffer::Create(UInt32 bufferSize)
  347.24 -{
  347.25 -  const UInt32 kMinBlockSize = 1;
  347.26 -  if (bufferSize < kMinBlockSize)
  347.27 -    bufferSize = kMinBlockSize;
  347.28 -  if (_bufferBase != 0 && _bufferSize == bufferSize)
  347.29 -    return true;
  347.30 -  Free();
  347.31 -  _bufferSize = bufferSize;
  347.32 -  _bufferBase = (Byte *)::MidAlloc(bufferSize);
  347.33 -  return (_bufferBase != 0);
  347.34 -}
  347.35 -
  347.36 -void CInBuffer::Free()
  347.37 -{
  347.38 -  ::MidFree(_bufferBase);
  347.39 -  _bufferBase = 0;
  347.40 -}
  347.41 -
  347.42 -void CInBuffer::SetStream(ISequentialInStream *stream)
  347.43 -{
  347.44 -  _stream = stream;
  347.45 -}
  347.46 -
  347.47 -void CInBuffer::Init()
  347.48 -{
  347.49 -  _processedSize = 0;
  347.50 -  _buffer = _bufferBase;
  347.51 -  _bufferLimit = _buffer;
  347.52 -  _wasFinished = false;
  347.53 -  #ifdef _NO_EXCEPTIONS
  347.54 -  ErrorCode = S_OK;
  347.55 -  #endif
  347.56 -}
  347.57 -
  347.58 -bool CInBuffer::ReadBlock()
  347.59 -{
  347.60 -  #ifdef _NO_EXCEPTIONS
  347.61 -  if (ErrorCode != S_OK)
  347.62 -    return false;
  347.63 -  #endif
  347.64 -  if (_wasFinished)
  347.65 -    return false;
  347.66 -  _processedSize += (_buffer - _bufferBase);
  347.67 -  UInt32 numProcessedBytes;
  347.68 -  HRESULT result = _stream->Read(_bufferBase, _bufferSize, &numProcessedBytes);
  347.69 -  #ifdef _NO_EXCEPTIONS
  347.70 -  ErrorCode = result;
  347.71 -  #else
  347.72 -  if (result != S_OK)
  347.73 -    throw CInBufferException(result);
  347.74 -  #endif
  347.75 -  _buffer = _bufferBase;
  347.76 -  _bufferLimit = _buffer + numProcessedBytes;
  347.77 -  _wasFinished = (numProcessedBytes == 0);
  347.78 -  return (!_wasFinished);
  347.79 -}
  347.80 -
  347.81 -Byte CInBuffer::ReadBlock2()
  347.82 -{
  347.83 -  if(!ReadBlock())
  347.84 -    return 0xFF;
  347.85 -  return *_buffer++;
  347.86 -}
   348.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/InBuffer.h	Sat Mar 03 10:54:39 2012 -0600
   348.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   348.3 @@ -1,81 +0,0 @@
   348.4 -// InBuffer.h
   348.5 -
   348.6 -#ifndef __INBUFFER_H
   348.7 -#define __INBUFFER_H
   348.8 -
   348.9 -#include "../IStream.h"
  348.10 -#include "../../Common/MyCom.h"
  348.11 -#include "../../Common/MyException.h"
  348.12 -
  348.13 -#ifndef _NO_EXCEPTIONS
  348.14 -struct CInBufferException: public CSystemException
  348.15 -{
  348.16 -  CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
  348.17 -};
  348.18 -#endif
  348.19 -
  348.20 -class CInBuffer
  348.21 -{
  348.22 -  Byte *_buffer;
  348.23 -  Byte *_bufferLimit;
  348.24 -  Byte *_bufferBase;
  348.25 -  CMyComPtr<ISequentialInStream> _stream;
  348.26 -  UInt64 _processedSize;
  348.27 -  UInt32 _bufferSize;
  348.28 -  bool _wasFinished;
  348.29 -
  348.30 -  bool ReadBlock();
  348.31 -  Byte ReadBlock2();
  348.32 -
  348.33 -public:
  348.34 -  #ifdef _NO_EXCEPTIONS
  348.35 -  HRESULT ErrorCode;
  348.36 -  #endif
  348.37 -
  348.38 -  CInBuffer();
  348.39 -  ~CInBuffer() { Free(); }
  348.40 -
  348.41 -  bool Create(UInt32 bufferSize);
  348.42 -  void Free();
  348.43 -  
  348.44 -  void SetStream(ISequentialInStream *stream);
  348.45 -  void Init();
  348.46 -  void ReleaseStream() { _stream.Release(); }
  348.47 -
  348.48 -  bool ReadByte(Byte &b)
  348.49 -  {
  348.50 -    if (_buffer >= _bufferLimit)
  348.51 -      if (!ReadBlock())
  348.52 -        return false;
  348.53 -    b = *_buffer++;
  348.54 -    return true;
  348.55 -  }
  348.56 -  Byte ReadByte()
  348.57 -  {
  348.58 -    if (_buffer >= _bufferLimit)
  348.59 -      return ReadBlock2();
  348.60 -    return *_buffer++;
  348.61 -  }
  348.62 -  UInt32 ReadBytes(Byte *buf, UInt32 size)
  348.63 -  {
  348.64 -    if ((UInt32)(_bufferLimit - _buffer) >= size)
  348.65 -    {
  348.66 -      for (UInt32 i = 0; i < size; i++)
  348.67 -        buf[i] = _buffer[i];
  348.68 -      _buffer += size;
  348.69 -      return size;
  348.70 -    }
  348.71 -    for (UInt32 i = 0; i < size; i++)
  348.72 -    {
  348.73 -      if (_buffer >= _bufferLimit)
  348.74 -        if (!ReadBlock())
  348.75 -          return i;
  348.76 -      buf[i] = *_buffer++;
  348.77 -    }
  348.78 -    return size;
  348.79 -  }
  348.80 -  UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
  348.81 -  bool WasFinished() const { return _wasFinished; }
  348.82 -};
  348.83 -
  348.84 -#endif
   349.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/InOutTempBuffer.cpp	Sat Mar 03 10:54:39 2012 -0600
   349.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   349.3 @@ -1,122 +0,0 @@
   349.4 -// InOutTempBuffer.cpp
   349.5 -
   349.6 -#include "StdAfx.h"
   349.7 -
   349.8 -#include "InOutTempBuffer.h"
   349.9 -#include "../../Common/Defs.h"
  349.10 -// #include "Windows/Defs.h"
  349.11 -
  349.12 -#include "StreamUtils.h"
  349.13 -
  349.14 -using namespace NWindows;
  349.15 -using namespace NFile;
  349.16 -using namespace NDirectory;
  349.17 -
  349.18 -static UInt32 kTmpBufferMemorySize = (1 << 20);
  349.19 -
  349.20 -static LPCTSTR kTempFilePrefixString = TEXT("iot");
  349.21 -
  349.22 -CInOutTempBuffer::CInOutTempBuffer():
  349.23 -  _buffer(NULL)
  349.24 -{
  349.25 -}
  349.26 -
  349.27 -void CInOutTempBuffer::Create()
  349.28 -{
  349.29 -  _buffer = new Byte[kTmpBufferMemorySize];
  349.30 -}
  349.31 -
  349.32 -CInOutTempBuffer::~CInOutTempBuffer()
  349.33 -{
  349.34 -  delete []_buffer;
  349.35 -}
  349.36 -void CInOutTempBuffer::InitWriting()
  349.37 -{
  349.38 -  _bufferPosition = 0;
  349.39 -  _tmpFileCreated = false;
  349.40 -  _fileSize = 0;
  349.41 -}
  349.42 -
  349.43 -bool CInOutTempBuffer::WriteToFile(const void *data, UInt32 size)
  349.44 -{
  349.45 -  if (size == 0)
  349.46 -    return true;
  349.47 -  if(!_tmpFileCreated)
  349.48 -  {
  349.49 -    CSysString tempDirPath;
  349.50 -    if(!MyGetTempPath(tempDirPath))
  349.51 -      return false;
  349.52 -    if (_tempFile.Create(tempDirPath, kTempFilePrefixString, _tmpFileName) == 0)
  349.53 -      return false;
  349.54 -    // _outFile.SetOpenCreationDispositionCreateAlways();
  349.55 -    if(!_outFile.Create(_tmpFileName, true))
  349.56 -      return false;
  349.57 -    _tmpFileCreated = true;
  349.58 -  }
  349.59 -  UInt32 processedSize;
  349.60 -  if(!_outFile.Write(data, size, processedSize))
  349.61 -    return false;
  349.62 -  _fileSize += processedSize;
  349.63 -  return (processedSize == size);
  349.64 -}
  349.65 -
  349.66 -bool CInOutTempBuffer::FlushWrite()
  349.67 -{
  349.68 -  return _outFile.Close();
  349.69 -}
  349.70 -
  349.71 -bool CInOutTempBuffer::Write(const void *data, UInt32 size)
  349.72 -{
  349.73 -  if(_bufferPosition < kTmpBufferMemorySize)
  349.74 -  {
  349.75 -    UInt32 curSize = MyMin(kTmpBufferMemorySize - _bufferPosition, size);
  349.76 -    memmove(_buffer + _bufferPosition, (const Byte *)data, curSize);
  349.77 -    _bufferPosition += curSize;
  349.78 -    size -= curSize;
  349.79 -    data = ((const Byte *)data) + curSize;
  349.80 -    _fileSize += curSize;
  349.81 -  }
  349.82 -  return WriteToFile(data, size);
  349.83 -}
  349.84 -
  349.85 -bool CInOutTempBuffer::InitReading()
  349.86 -{
  349.87 -  _currentPositionInBuffer = 0;
  349.88 -  if(_tmpFileCreated)
  349.89 -    return _inFile.Open(_tmpFileName);
  349.90 -  return true;
  349.91 -}
  349.92 -
  349.93 -HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream)
  349.94 -{
  349.95 -  if (_currentPositionInBuffer < _bufferPosition)
  349.96 -  {
  349.97 -    UInt32 sizeToWrite = _bufferPosition - _currentPositionInBuffer;
  349.98 -    RINOK(WriteStream(stream, _buffer + _currentPositionInBuffer, sizeToWrite));
  349.99 -    _currentPositionInBuffer += sizeToWrite;
 349.100 -  }
 349.101 -  if (!_tmpFileCreated)
 349.102 -    return true;
 349.103 -  for (;;)
 349.104 -  {
 349.105 -    UInt32 localProcessedSize;
 349.106 -    if (!_inFile.ReadPart(_buffer, kTmpBufferMemorySize, localProcessedSize))
 349.107 -      return E_FAIL;
 349.108 -    if (localProcessedSize == 0)
 349.109 -      return S_OK;
 349.110 -    RINOK(WriteStream(stream, _buffer, localProcessedSize));
 349.111 -  }
 349.112 -}
 349.113 -
 349.114 -STDMETHODIMP CSequentialOutTempBufferImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
 349.115 -{
 349.116 -  if (!_buffer->Write(data, size))
 349.117 -  {
 349.118 -    if (processedSize != NULL)
 349.119 -      *processedSize = 0;
 349.120 -    return E_FAIL;
 349.121 -  }
 349.122 -  if (processedSize != NULL)
 349.123 -    *processedSize = size;
 349.124 -  return S_OK;
 349.125 -}
   350.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/InOutTempBuffer.h	Sat Mar 03 10:54:39 2012 -0600
   350.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   350.3 @@ -1,55 +0,0 @@
   350.4 -// Util/InOutTempBuffer.h
   350.5 -
   350.6 -#ifndef __IN_OUT_TEMP_BUFFER_H
   350.7 -#define __IN_OUT_TEMP_BUFFER_H
   350.8 -
   350.9 -#include "../../Windows/FileIO.h"
  350.10 -#include "../../Windows/FileDir.h"
  350.11 -#include "../../Common/MyCom.h"
  350.12 -
  350.13 -#include "../IStream.h"
  350.14 -
  350.15 -class CInOutTempBuffer
  350.16 -{
  350.17 -  NWindows::NFile::NDirectory::CTempFile _tempFile;
  350.18 -  NWindows::NFile::NIO::COutFile _outFile;
  350.19 -  NWindows::NFile::NIO::CInFile _inFile;
  350.20 -  Byte *_buffer;
  350.21 -  UInt32 _bufferPosition;
  350.22 -  UInt32 _currentPositionInBuffer;
  350.23 -  CSysString _tmpFileName;
  350.24 -  bool _tmpFileCreated;
  350.25 -
  350.26 -  UInt64 _fileSize;
  350.27 -
  350.28 -  bool WriteToFile(const void *data, UInt32 size);
  350.29 -public:
  350.30 -  CInOutTempBuffer();
  350.31 -  ~CInOutTempBuffer();
  350.32 -  void Create();
  350.33 -
  350.34 -  void InitWriting();
  350.35 -  bool Write(const void *data, UInt32 size);
  350.36 -  UInt64 GetDataSize() const { return _fileSize; }
  350.37 -  bool FlushWrite();
  350.38 -  bool InitReading();
  350.39 -  HRESULT WriteToStream(ISequentialOutStream *stream);
  350.40 -};
  350.41 -
  350.42 -class CSequentialOutTempBufferImp:
  350.43 -  public ISequentialOutStream,
  350.44 -  public CMyUnknownImp
  350.45 -{
  350.46 -  CInOutTempBuffer *_buffer;
  350.47 -public:
  350.48 -  // CSequentialOutStreamImp(): _size(0) {}
  350.49 -  // UInt32 _size;
  350.50 -  void Init(CInOutTempBuffer *buffer)  { _buffer = buffer; }
  350.51 -  // UInt32 GetSize() const { return _size; }
  350.52 -
  350.53 -  MY_UNKNOWN_IMP
  350.54 -
  350.55 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  350.56 -};
  350.57 -
  350.58 -#endif
   351.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.cpp	Sat Mar 03 10:54:39 2012 -0600
   351.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   351.3 @@ -1,45 +0,0 @@
   351.4 -// LimitedStreams.cpp
   351.5 -
   351.6 -#include "StdAfx.h"
   351.7 -
   351.8 -#include "LimitedStreams.h"
   351.9 -#include "../../Common/Defs.h"
  351.10 -
  351.11 -STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
  351.12 -{
  351.13 -  UInt32 realProcessedSize = 0;
  351.14 -  UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);
  351.15 -  HRESULT result = S_OK;
  351.16 -  if (sizeToRead > 0)
  351.17 -  {
  351.18 -    result = _stream->Read(data, sizeToRead, &realProcessedSize);
  351.19 -    _pos += realProcessedSize;
  351.20 -    if (realProcessedSize == 0)
  351.21 -      _wasFinished = true;
  351.22 -  }
  351.23 -  if(processedSize != NULL)
  351.24 -    *processedSize = realProcessedSize;
  351.25 -  return result;
  351.26 -}
  351.27 -
  351.28 -STDMETHODIMP CLimitedSequentialOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
  351.29 -{
  351.30 -  HRESULT result = S_OK;
  351.31 -  if (processedSize != NULL)
  351.32 -    *processedSize = 0;
  351.33 -  if (size > _size)
  351.34 -  {
  351.35 -    size = (UInt32)_size;
  351.36 -    if (size == 0)
  351.37 -    {
  351.38 -      _overflow = true;
  351.39 -      return E_FAIL;
  351.40 -    }
  351.41 -  }
  351.42 -  if (_stream)
  351.43 -    result = _stream->Write(data, size, &size);
  351.44 -  _size -= size;
  351.45 -  if (processedSize != NULL)
  351.46 -    *processedSize = size;
  351.47 -  return result;
  351.48 -}
   352.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.h	Sat Mar 03 10:54:39 2012 -0600
   352.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   352.3 @@ -1,54 +0,0 @@
   352.4 -// LimitedStreams.h
   352.5 -
   352.6 -#ifndef __LIMITEDSTREAMS_H
   352.7 -#define __LIMITEDSTREAMS_H
   352.8 -
   352.9 -#include "../../Common/MyCom.h"
  352.10 -#include "../IStream.h"
  352.11 -
  352.12 -class CLimitedSequentialInStream:
  352.13 -  public ISequentialInStream,
  352.14 -  public CMyUnknownImp
  352.15 -{
  352.16 -  CMyComPtr<ISequentialInStream> _stream;
  352.17 -  UInt64 _size;
  352.18 -  UInt64 _pos;
  352.19 -  bool _wasFinished;
  352.20 -public:
  352.21 -  void SetStream(ISequentialInStream *stream) { _stream = stream; }
  352.22 -  void Init(UInt64 streamSize)
  352.23 -  {
  352.24 -    _size = streamSize;
  352.25 -    _pos = 0;
  352.26 -    _wasFinished = false;
  352.27 -  }
  352.28 - 
  352.29 -  MY_UNKNOWN_IMP
  352.30 -
  352.31 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  352.32 -  UInt64 GetSize() const { return _pos; }
  352.33 -  bool WasFinished() const { return _wasFinished; }
  352.34 -};
  352.35 -
  352.36 -class CLimitedSequentialOutStream:
  352.37 -  public ISequentialOutStream,
  352.38 -  public CMyUnknownImp
  352.39 -{
  352.40 -  CMyComPtr<ISequentialOutStream> _stream;
  352.41 -  UInt64 _size;
  352.42 -  bool _overflow;
  352.43 -public:
  352.44 -  MY_UNKNOWN_IMP
  352.45 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  352.46 -  void SetStream(ISequentialOutStream *stream) { _stream = stream; }
  352.47 -  void ReleaseStream() { _stream.Release(); }
  352.48 -  void Init(UInt64 size)
  352.49 -  {
  352.50 -    _size = size;
  352.51 -    _overflow = false;
  352.52 -  }
  352.53 -  bool IsFinishedOK() const { return (_size == 0 && !_overflow); }
  352.54 -  UInt64 GetRem() const { return _size; }
  352.55 -};
  352.56 -
  352.57 -#endif
   353.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/LockedStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   353.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   353.3 @@ -1,23 +0,0 @@
   353.4 -// LockedStream.cpp
   353.5 -
   353.6 -#include "StdAfx.h"
   353.7 -
   353.8 -#include "LockedStream.h"
   353.9 -
  353.10 -HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size,
  353.11 -  UInt32 *processedSize)
  353.12 -{
  353.13 -  NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
  353.14 -  RINOK(_stream->Seek(startPos, STREAM_SEEK_SET, NULL));
  353.15 -  return _stream->Read(data, size, processedSize);
  353.16 -}
  353.17 -
  353.18 -STDMETHODIMP CLockedSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
  353.19 -{
  353.20 -  UInt32 realProcessedSize = 0;
  353.21 -  HRESULT result = _lockedInStream->Read(_pos, data, size, &realProcessedSize);
  353.22 -  _pos += realProcessedSize;
  353.23 -  if (processedSize != NULL)
  353.24 -    *processedSize = realProcessedSize;
  353.25 -  return result;
  353.26 -}
   354.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/LockedStream.h	Sat Mar 03 10:54:39 2012 -0600
   354.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   354.3 @@ -1,38 +0,0 @@
   354.4 -// LockedStream.h
   354.5 -
   354.6 -#ifndef __LOCKEDSTREAM_H
   354.7 -#define __LOCKEDSTREAM_H
   354.8 -
   354.9 -#include "../../Windows/Synchronization.h"
  354.10 -#include "../../Common/MyCom.h"
  354.11 -#include "../IStream.h"
  354.12 -
  354.13 -class CLockedInStream
  354.14 -{
  354.15 -  CMyComPtr<IInStream> _stream;
  354.16 -  NWindows::NSynchronization::CCriticalSection _criticalSection;
  354.17 -public:
  354.18 -  void Init(IInStream *stream)
  354.19 -    { _stream = stream; }
  354.20 -  HRESULT Read(UInt64 startPos, void *data, UInt32 size, UInt32 *processedSize);
  354.21 -};
  354.22 -
  354.23 -class CLockedSequentialInStreamImp:
  354.24 -  public ISequentialInStream,
  354.25 -  public CMyUnknownImp
  354.26 -{
  354.27 -  CLockedInStream *_lockedInStream;
  354.28 -  UInt64 _pos;
  354.29 -public:
  354.30 -  void Init(CLockedInStream *lockedInStream, UInt64 startPos)
  354.31 -  {
  354.32 -    _lockedInStream = lockedInStream;
  354.33 -    _pos = startPos;
  354.34 -  }
  354.35 -
  354.36 -  MY_UNKNOWN_IMP
  354.37 -
  354.38 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  354.39 -};
  354.40 -
  354.41 -#endif
   355.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MemBlocks.cpp	Sat Mar 03 10:54:39 2012 -0600
   355.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   355.3 @@ -1,183 +0,0 @@
   355.4 -// MemBlocks.cpp
   355.5 -
   355.6 -#include "StdAfx.h"
   355.7 -
   355.8 -#include "Common/MyCom.h"
   355.9 -
  355.10 -#include "StreamUtils.h"
  355.11 -#include "MemBlocks.h"
  355.12 -
  355.13 -bool CMemBlockManager::AllocateSpace(size_t numBlocks)
  355.14 -{
  355.15 -  FreeSpace();
  355.16 -  if (_blockSize < sizeof(void *) || numBlocks < 1)
  355.17 -    return false;
  355.18 -  size_t totalSize = numBlocks * _blockSize;
  355.19 -  if (totalSize / _blockSize != numBlocks)
  355.20 -    return false;
  355.21 -  _data = ::MidAlloc(totalSize);
  355.22 -  if (_data == 0)
  355.23 -    return false;
  355.24 -  Byte *p = (Byte *)_data;
  355.25 -  for (size_t i = 0; i + 1 < numBlocks; i++, p += _blockSize)
  355.26 -    *(Byte **)p = (p + _blockSize);
  355.27 -  *(Byte **)p = 0;
  355.28 -  _headFree = _data;
  355.29 -  return true;
  355.30 -}
  355.31 -
  355.32 -void CMemBlockManager::FreeSpace()
  355.33 -{
  355.34 -  ::MidFree(_data);
  355.35 -  _data = 0;
  355.36 -  _headFree= 0;
  355.37 -}
  355.38 -
  355.39 -void *CMemBlockManager::AllocateBlock()
  355.40 -{
  355.41 -  if (_headFree == 0)
  355.42 -    return 0;
  355.43 -  void *p = _headFree;
  355.44 -  _headFree = *(void **)_headFree;
  355.45 -  return p;
  355.46 -}
  355.47 -
  355.48 -void CMemBlockManager::FreeBlock(void *p)
  355.49 -{
  355.50 -  if (p == 0)
  355.51 -    return;
  355.52 -  *(void **)p = _headFree;
  355.53 -  _headFree = p;
  355.54 -}
  355.55 -
  355.56 -
  355.57 -HRes CMemBlockManagerMt::AllocateSpace(size_t numBlocks, size_t numNoLockBlocks)
  355.58 -{
  355.59 -  if (numNoLockBlocks > numBlocks)
  355.60 -    return E_INVALIDARG;
  355.61 -  if (!CMemBlockManager::AllocateSpace(numBlocks))
  355.62 -    return E_OUTOFMEMORY;
  355.63 -  size_t numLockBlocks = numBlocks - numNoLockBlocks;
  355.64 -  Semaphore.Close();
  355.65 -  return Semaphore.Create((LONG)numLockBlocks, (LONG)numLockBlocks);
  355.66 -}
  355.67 -
  355.68 -HRes CMemBlockManagerMt::AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks)
  355.69 -{
  355.70 -  if (numNoLockBlocks > desiredNumberOfBlocks)
  355.71 -    return E_INVALIDARG;
  355.72 -  for (;;)
  355.73 -  {
  355.74 -    if (AllocateSpace(desiredNumberOfBlocks, numNoLockBlocks) == 0)
  355.75 -      return 0;
  355.76 -    if (desiredNumberOfBlocks == numNoLockBlocks)
  355.77 -      return E_OUTOFMEMORY;
  355.78 -    desiredNumberOfBlocks = numNoLockBlocks + ((desiredNumberOfBlocks - numNoLockBlocks) >> 1);
  355.79 -  }
  355.80 -}
  355.81 -
  355.82 -void CMemBlockManagerMt::FreeSpace()
  355.83 -{
  355.84 -  Semaphore.Close();
  355.85 -  CMemBlockManager::FreeSpace();
  355.86 -}
  355.87 -
  355.88 -void *CMemBlockManagerMt::AllocateBlock()
  355.89 -{
  355.90 -  // Semaphore.Lock();
  355.91 -  NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
  355.92 -  return CMemBlockManager::AllocateBlock();
  355.93 -}
  355.94 -
  355.95 -void CMemBlockManagerMt::FreeBlock(void *p, bool lockMode)
  355.96 -{
  355.97 -  if (p == 0)
  355.98 -    return;
  355.99 -  {
 355.100 -    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
 355.101 -    CMemBlockManager::FreeBlock(p);
 355.102 -  }
 355.103 -  if (lockMode)
 355.104 -    Semaphore.Release();
 355.105 -}
 355.106 -
 355.107 -void CMemBlocks::Free(CMemBlockManagerMt *manager)
 355.108 -{
 355.109 -  while(Blocks.Size() > 0)
 355.110 -  {
 355.111 -    manager->FreeBlock(Blocks.Back());
 355.112 -    Blocks.DeleteBack();
 355.113 -  }
 355.114 -  TotalSize = 0;
 355.115 -}
 355.116 -
 355.117 -void CMemBlocks::FreeOpt(CMemBlockManagerMt *manager)
 355.118 -{
 355.119 -  Free(manager);
 355.120 -  Blocks.ClearAndFree();
 355.121 -}
 355.122 -
 355.123 -HRESULT CMemBlocks::WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const
 355.124 -{
 355.125 -  UInt64 totalSize = TotalSize;
 355.126 -  for (int blockIndex = 0; totalSize > 0; blockIndex++)
 355.127 -  {
 355.128 -    UInt32 curSize = (UInt32)blockSize;
 355.129 -    if (totalSize < curSize)
 355.130 -      curSize = (UInt32)totalSize;
 355.131 -    if (blockIndex >= Blocks.Size())
 355.132 -      return E_FAIL;
 355.133 -    RINOK(WriteStream(outStream, Blocks[blockIndex], curSize));
 355.134 -    totalSize -= curSize;
 355.135 -  }
 355.136 -  return S_OK;
 355.137 -}
 355.138 -
 355.139 -
 355.140 -void CMemLockBlocks::FreeBlock(int index, CMemBlockManagerMt *memManager)
 355.141 -{
 355.142 -  memManager->FreeBlock(Blocks[index], LockMode);
 355.143 -  Blocks[index] = 0;
 355.144 -}
 355.145 -
 355.146 -void CMemLockBlocks::Free(CMemBlockManagerMt *memManager)
 355.147 -{
 355.148 -  while (Blocks.Size() > 0)
 355.149 -  {
 355.150 -    FreeBlock(Blocks.Size() - 1, memManager);
 355.151 -    Blocks.DeleteBack();
 355.152 -  }
 355.153 -  TotalSize = 0;
 355.154 -}
 355.155 -
 355.156 -HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
 355.157 -{
 355.158 -  if (LockMode)
 355.159 -  {
 355.160 -    if (Blocks.Size() > 0)
 355.161 -    {
 355.162 -      RINOK(memManager->ReleaseLockedBlocks(Blocks.Size()));
 355.163 -    }
 355.164 -    LockMode = false;
 355.165 -  }
 355.166 -  return 0;
 355.167 -}
 355.168 -
 355.169 -void CMemLockBlocks::Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager)
 355.170 -{
 355.171 -  blocks.Free(memManager);
 355.172 -  blocks.LockMode = LockMode;
 355.173 -  UInt64 totalSize = 0;
 355.174 -  size_t blockSize = memManager->GetBlockSize();
 355.175 -  for (int i = 0; i < Blocks.Size(); i++)
 355.176 -  {
 355.177 -    if (totalSize < TotalSize)
 355.178 -      blocks.Blocks.Add(Blocks[i]);
 355.179 -    else
 355.180 -      FreeBlock(i, memManager);
 355.181 -    Blocks[i] = 0;
 355.182 -    totalSize += blockSize;
 355.183 -  }
 355.184 -  blocks.TotalSize = TotalSize;
 355.185 -  Free(memManager);
 355.186 -}
   356.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MemBlocks.h	Sat Mar 03 10:54:39 2012 -0600
   356.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   356.3 @@ -1,77 +0,0 @@
   356.4 -// MemBlocks.h
   356.5 -
   356.6 -#ifndef __MEMBLOCKS_H
   356.7 -#define __MEMBLOCKS_H
   356.8 -
   356.9 -extern "C"
  356.10 -{
  356.11 -#include "../../../C/Alloc.h"
  356.12 -}
  356.13 -
  356.14 -#include "Common/Types.h"
  356.15 -#include "Common/MyVector.h"
  356.16 -
  356.17 -#include "Windows/Synchronization.h"
  356.18 -
  356.19 -#include "../IStream.h"
  356.20 -
  356.21 -class CMemBlockManager
  356.22 -{
  356.23 -  void *_data;
  356.24 -  size_t _blockSize;
  356.25 -  void *_headFree;
  356.26 -public:
  356.27 -  CMemBlockManager(size_t blockSize = (1 << 20)): _data(0), _blockSize(blockSize), _headFree(0) {}
  356.28 -  ~CMemBlockManager() { FreeSpace(); }
  356.29 -
  356.30 -  bool AllocateSpace(size_t numBlocks);
  356.31 -  void FreeSpace();
  356.32 -  size_t GetBlockSize() const { return _blockSize; }
  356.33 -  void *AllocateBlock();
  356.34 -  void FreeBlock(void *p);
  356.35 -};
  356.36 -
  356.37 -
  356.38 -class CMemBlockManagerMt: public CMemBlockManager
  356.39 -{
  356.40 -  NWindows::NSynchronization::CCriticalSection _criticalSection;
  356.41 -public:
  356.42 -  NWindows::NSynchronization::CSemaphore Semaphore;
  356.43 -
  356.44 -  CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {}
  356.45 -  ~CMemBlockManagerMt() { FreeSpace(); }
  356.46 -
  356.47 -  HRes AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0);
  356.48 -  HRes AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
  356.49 -  void FreeSpace();
  356.50 -  void *AllocateBlock();
  356.51 -  void FreeBlock(void *p, bool lockMode = true);
  356.52 -  HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
  356.53 -};
  356.54 -
  356.55 -
  356.56 -class CMemBlocks
  356.57 -{
  356.58 -  void Free(CMemBlockManagerMt *manager);
  356.59 -public:
  356.60 -  CRecordVector<void *> Blocks;
  356.61 -  UInt64 TotalSize;
  356.62 -  
  356.63 -  CMemBlocks(): TotalSize(0) {}
  356.64 -
  356.65 -  void FreeOpt(CMemBlockManagerMt *manager);
  356.66 -  HRESULT WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const;
  356.67 -};
  356.68 -
  356.69 -struct CMemLockBlocks: public CMemBlocks
  356.70 -{
  356.71 -  bool LockMode;
  356.72 -
  356.73 -  CMemLockBlocks(): LockMode(true) {};
  356.74 -  void Free(CMemBlockManagerMt *memManager);
  356.75 -  void FreeBlock(int index, CMemBlockManagerMt *memManager);
  356.76 -  HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
  356.77 -  void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
  356.78 -};
  356.79 -
  356.80 -#endif
   357.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MethodId.cpp	Sat Mar 03 10:54:39 2012 -0600
   357.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   357.3 @@ -1,27 +0,0 @@
   357.4 -// MethodId.cpp
   357.5 -
   357.6 -#include "StdAfx.h"
   357.7 -
   357.8 -#include "MethodId.h"
   357.9 -#include "../../Common/MyString.h"
  357.10 -
  357.11 -static inline wchar_t GetHex(Byte value)
  357.12 -{
  357.13 -  return (wchar_t)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
  357.14 -}
  357.15 -
  357.16 -UString ConvertMethodIdToString(UInt64 id)
  357.17 -{
  357.18 -  wchar_t s[32];
  357.19 -  int len = 32;
  357.20 -  s[--len] = 0;
  357.21 -  do
  357.22 -  {
  357.23 -    s[--len] = GetHex((Byte)id & 0xF);
  357.24 -    id >>= 4;
  357.25 -    s[--len] = GetHex((Byte)id & 0xF);
  357.26 -    id >>= 4;
  357.27 -  }
  357.28 -  while (id != 0);
  357.29 -  return s + len;
  357.30 -}
   358.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MethodId.h	Sat Mar 03 10:54:39 2012 -0600
   358.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   358.3 @@ -1,10 +0,0 @@
   358.4 -// MethodId.h
   358.5 -
   358.6 -#ifndef __7Z_METHOD_ID_H
   358.7 -#define __7Z_METHOD_ID_H
   358.8 -
   358.9 -#include "../../Common/Types.h"
  358.10 -
  358.11 -typedef UInt64 CMethodId;
  358.12 -
  358.13 -#endif
   359.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MethodProps.cpp	Sat Mar 03 10:54:39 2012 -0600
   359.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   359.3 @@ -1,99 +0,0 @@
   359.4 -// MethodProps.cpp
   359.5 -
   359.6 -#include "StdAfx.h"
   359.7 -
   359.8 -#include "../../Common/MyCom.h"
   359.9 -
  359.10 -#include "../ICoder.h"
  359.11 -
  359.12 -#include "MethodProps.h"
  359.13 -
  359.14 -static UInt64 k_LZMA = 0x030101;
  359.15 -// static UInt64 k_LZMA2 = 0x030102;
  359.16 -
  359.17 -HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder)
  359.18 -{
  359.19 -  bool tryReduce = false;
  359.20 -  UInt32 reducedDictionarySize = 1 << 10;
  359.21 -  if (inSizeForReduce != 0 && (method.Id == k_LZMA /* || methodFull.MethodID == k_LZMA2 */))
  359.22 -  {
  359.23 -    for (;;)
  359.24 -    {
  359.25 -      const UInt32 step = (reducedDictionarySize >> 1);
  359.26 -      if (reducedDictionarySize >= *inSizeForReduce)
  359.27 -      {
  359.28 -        tryReduce = true;
  359.29 -        break;
  359.30 -      }
  359.31 -      reducedDictionarySize += step;
  359.32 -      if (reducedDictionarySize >= *inSizeForReduce)
  359.33 -      {
  359.34 -        tryReduce = true;
  359.35 -        break;
  359.36 -      }
  359.37 -      if (reducedDictionarySize >= ((UInt32)3 << 30))
  359.38 -        break;
  359.39 -      reducedDictionarySize += step;
  359.40 -    }
  359.41 -  }
  359.42 -
  359.43 -  {
  359.44 -    int numProps = method.Props.Size();
  359.45 -    CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
  359.46 -    coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
  359.47 -    if (setCoderProperties == NULL)
  359.48 -    {
  359.49 -      if (numProps != 0)
  359.50 -        return E_INVALIDARG;
  359.51 -    }
  359.52 -    else
  359.53 -    {
  359.54 -      CRecordVector<PROPID> propIDs;
  359.55 -      NWindows::NCOM::CPropVariant *values = new NWindows::NCOM::CPropVariant[numProps];
  359.56 -      HRESULT res = S_OK;
  359.57 -      try
  359.58 -      {
  359.59 -        for (int i = 0; i < numProps; i++)
  359.60 -        {
  359.61 -          const CProp &prop = method.Props[i];
  359.62 -          propIDs.Add(prop.Id);
  359.63 -          NWindows::NCOM::CPropVariant &value = values[i];
  359.64 -          value = prop.Value;
  359.65 -          // if (tryReduce && prop.Id == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
  359.66 -          if (tryReduce)
  359.67 -            if (prop.Id == NCoderPropID::kDictionarySize)
  359.68 -              if (value.vt == VT_UI4)
  359.69 -                if (reducedDictionarySize < value.ulVal)
  359.70 -            value.ulVal = reducedDictionarySize;
  359.71 -        }
  359.72 -        CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
  359.73 -        coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
  359.74 -        res = setCoderProperties->SetCoderProperties(&propIDs.Front(), values, numProps);
  359.75 -      }
  359.76 -      catch(...)
  359.77 -      {
  359.78 -        delete []values;
  359.79 -        throw;
  359.80 -      }
  359.81 -      delete []values;
  359.82 -      RINOK(res);
  359.83 -    }
  359.84 -  }
  359.85 - 
  359.86 -  /*
  359.87 -  CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
  359.88 -  coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
  359.89 -  if (writeCoderProperties != NULL)
  359.90 -  {
  359.91 -    CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
  359.92 -    CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
  359.93 -    outStreamSpec->Init();
  359.94 -    RINOK(writeCoderProperties->WriteCoderProperties(outStream));
  359.95 -    size_t size = outStreamSpec->GetSize();
  359.96 -    filterProps.SetCapacity(size);
  359.97 -    memmove(filterProps, outStreamSpec->GetBuffer(), size);
  359.98 -  }
  359.99 -  */
 359.100 -  return S_OK;
 359.101 -}
 359.102 -
   360.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/MethodProps.h	Sat Mar 03 10:54:39 2012 -0600
   360.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   360.3 @@ -1,41 +0,0 @@
   360.4 -// MethodProps.h
   360.5 -
   360.6 -#ifndef __7Z_METHOD_PROPS_H
   360.7 -#define __7Z_METHOD_PROPS_H
   360.8 -
   360.9 -#include "../../Common/MyVector.h"
  360.10 -
  360.11 -#include "../../Windows/PropVariant.h"
  360.12 -
  360.13 -#include "MethodId.h"
  360.14 -
  360.15 -struct CProp
  360.16 -{
  360.17 -  PROPID Id;
  360.18 -  NWindows::NCOM::CPropVariant Value;
  360.19 -};
  360.20 -
  360.21 -struct CMethod
  360.22 -{
  360.23 -  CMethodId Id;
  360.24 -  CObjectVector<CProp> Props;
  360.25 -};
  360.26 -
  360.27 -struct CMethodsMode
  360.28 -{
  360.29 -  CObjectVector<CMethod> Methods;
  360.30 -  #ifdef COMPRESS_MT
  360.31 -  UInt32 NumThreads;
  360.32 -  #endif
  360.33 -
  360.34 -  CMethodsMode()
  360.35 -      #ifdef COMPRESS_MT
  360.36 -      : NumThreads(1)
  360.37 -      #endif
  360.38 -  {}
  360.39 -  bool IsEmpty() const { return Methods.IsEmpty() ; }
  360.40 -};
  360.41 -
  360.42 -HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder);
  360.43 -
  360.44 -#endif
   361.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   361.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   361.3 @@ -1,35 +0,0 @@
   361.4 -// OffsetStream.cpp
   361.5 -
   361.6 -#include "StdAfx.h"
   361.7 -
   361.8 -#include "Common/Defs.h"
   361.9 -#include "OffsetStream.h"
  361.10 -
  361.11 -HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset)
  361.12 -{
  361.13 -  _offset = offset;
  361.14 -  _stream = stream;
  361.15 -  return _stream->Seek(offset, STREAM_SEEK_SET, NULL);
  361.16 -}
  361.17 -
  361.18 -STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
  361.19 -{
  361.20 -  return _stream->Write(data, size, processedSize);
  361.21 -}
  361.22 -
  361.23 -STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
  361.24 -    UInt64 *newPosition)
  361.25 -{
  361.26 -  UInt64 absoluteNewPosition;
  361.27 -  if (seekOrigin == STREAM_SEEK_SET)
  361.28 -    offset += _offset;
  361.29 -  HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition);
  361.30 -  if (newPosition != NULL)
  361.31 -    *newPosition = absoluteNewPosition - _offset;
  361.32 -  return result;
  361.33 -}
  361.34 -
  361.35 -STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize)
  361.36 -{
  361.37 -  return _stream->SetSize(_offset + newSize);
  361.38 -}
   362.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.h	Sat Mar 03 10:54:39 2012 -0600
   362.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   362.3 @@ -1,25 +0,0 @@
   362.4 -// OffsetStream.h
   362.5 -
   362.6 -#ifndef __OFFSETSTREAM_H
   362.7 -#define __OFFSETSTREAM_H
   362.8 -
   362.9 -#include "Common/MyCom.h"
  362.10 -#include "../IStream.h"
  362.11 -
  362.12 -class COffsetOutStream:
  362.13 -  public IOutStream,
  362.14 -  public CMyUnknownImp
  362.15 -{
  362.16 -  UInt64 _offset;
  362.17 -  CMyComPtr<IOutStream> _stream;
  362.18 -public:
  362.19 -  HRESULT Init(IOutStream *stream, UInt64 offset);
  362.20 -  
  362.21 -  MY_UNKNOWN_IMP
  362.22 -
  362.23 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  362.24 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  362.25 -  STDMETHOD(SetSize)(Int64 newSize);
  362.26 -};
  362.27 -
  362.28 -#endif
   363.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OutBuffer.cpp	Sat Mar 03 10:54:39 2012 -0600
   363.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   363.3 @@ -1,119 +0,0 @@
   363.4 -// OutByte.cpp
   363.5 -
   363.6 -#include "StdAfx.h"
   363.7 -
   363.8 -#include "OutBuffer.h"
   363.9 -
  363.10 -extern "C"
  363.11 -{
  363.12 -  #include "../../../C/Alloc.h"
  363.13 -}
  363.14 -
  363.15 -bool COutBuffer::Create(UInt32 bufferSize)
  363.16 -{
  363.17 -  const UInt32 kMinBlockSize = 1;
  363.18 -  if (bufferSize < kMinBlockSize)
  363.19 -    bufferSize = kMinBlockSize;
  363.20 -  if (_buffer != 0 && _bufferSize == bufferSize)
  363.21 -    return true;
  363.22 -  Free();
  363.23 -  _bufferSize = bufferSize;
  363.24 -  _buffer = (Byte *)::MidAlloc(bufferSize);
  363.25 -  return (_buffer != 0);
  363.26 -}
  363.27 -
  363.28 -void COutBuffer::Free()
  363.29 -{
  363.30 -  ::MidFree(_buffer);
  363.31 -  _buffer = 0;
  363.32 -}
  363.33 -
  363.34 -void COutBuffer::SetStream(ISequentialOutStream *stream)
  363.35 -{
  363.36 -  _stream = stream;
  363.37 -}
  363.38 -
  363.39 -void COutBuffer::Init()
  363.40 -{
  363.41 -  _streamPos = 0;
  363.42 -  _limitPos = _bufferSize;
  363.43 -  _pos = 0;
  363.44 -  _processedSize = 0;
  363.45 -  _overDict = false;
  363.46 -  #ifdef _NO_EXCEPTIONS
  363.47 -  ErrorCode = S_OK;
  363.48 -  #endif
  363.49 -}
  363.50 -
  363.51 -UInt64 COutBuffer::GetProcessedSize() const
  363.52 -{
  363.53 -  UInt64 res = _processedSize + _pos - _streamPos;
  363.54 -  if (_streamPos > _pos)
  363.55 -    res += _bufferSize;
  363.56 -  return res;
  363.57 -}
  363.58 -
  363.59 -
  363.60 -HRESULT COutBuffer::FlushPart()
  363.61 -{
  363.62 -  // _streamPos < _bufferSize
  363.63 -  UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);
  363.64 -  HRESULT result = S_OK;
  363.65 -  #ifdef _NO_EXCEPTIONS
  363.66 -  result = ErrorCode;
  363.67 -  #endif
  363.68 -  if (_buffer2 != 0)
  363.69 -  {
  363.70 -    memmove(_buffer2, _buffer + _streamPos, size);
  363.71 -    _buffer2 += size;
  363.72 -  }
  363.73 -
  363.74 -  if (_stream != 0
  363.75 -      #ifdef _NO_EXCEPTIONS
  363.76 -      && (ErrorCode == S_OK)
  363.77 -      #endif
  363.78 -     )
  363.79 -  {
  363.80 -    UInt32 processedSize = 0;
  363.81 -    result = _stream->Write(_buffer + _streamPos, size, &processedSize);
  363.82 -    size = processedSize;
  363.83 -  }
  363.84 -  _streamPos += size;
  363.85 -  if (_streamPos == _bufferSize)
  363.86 -    _streamPos = 0;
  363.87 -  if (_pos == _bufferSize)
  363.88 -  {
  363.89 -    _overDict = true;
  363.90 -    _pos = 0;
  363.91 -  }
  363.92 -  _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;
  363.93 -  _processedSize += size;
  363.94 -  return result;
  363.95 -}
  363.96 -
  363.97 -HRESULT COutBuffer::Flush()
  363.98 -{
  363.99 -  #ifdef _NO_EXCEPTIONS
 363.100 -  if (ErrorCode != S_OK)
 363.101 -    return ErrorCode;
 363.102 -  #endif
 363.103 -
 363.104 -  while(_streamPos != _pos)
 363.105 -  {
 363.106 -    HRESULT result = FlushPart();
 363.107 -    if (result != S_OK)
 363.108 -      return result;
 363.109 -  }
 363.110 -  return S_OK;
 363.111 -}
 363.112 -
 363.113 -void COutBuffer::FlushWithCheck()
 363.114 -{
 363.115 -  HRESULT result = Flush();
 363.116 -  #ifdef _NO_EXCEPTIONS
 363.117 -  ErrorCode = result;
 363.118 -  #else
 363.119 -  if (result != S_OK)
 363.120 -    throw COutBufferException(result);
 363.121 -  #endif
 363.122 -}
   364.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OutBuffer.h	Sat Mar 03 10:54:39 2012 -0600
   364.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   364.3 @@ -1,64 +0,0 @@
   364.4 -// OutBuffer.h
   364.5 -
   364.6 -#ifndef __OUTBUFFER_H
   364.7 -#define __OUTBUFFER_H
   364.8 -
   364.9 -#include "../IStream.h"
  364.10 -#include "../../Common/MyCom.h"
  364.11 -#include "../../Common/MyException.h"
  364.12 -
  364.13 -#ifndef _NO_EXCEPTIONS
  364.14 -struct COutBufferException: public CSystemException
  364.15 -{
  364.16 -  COutBufferException(HRESULT errorCode): CSystemException(errorCode) {}
  364.17 -};
  364.18 -#endif
  364.19 -
  364.20 -class COutBuffer
  364.21 -{
  364.22 -protected:
  364.23 -  Byte *_buffer;
  364.24 -  UInt32 _pos;
  364.25 -  UInt32 _limitPos;
  364.26 -  UInt32 _streamPos;
  364.27 -  UInt32 _bufferSize;
  364.28 -  CMyComPtr<ISequentialOutStream> _stream;
  364.29 -  UInt64 _processedSize;
  364.30 -  Byte  *_buffer2;
  364.31 -  bool _overDict;
  364.32 -
  364.33 -  HRESULT FlushPart();
  364.34 -public:
  364.35 -  #ifdef _NO_EXCEPTIONS
  364.36 -  HRESULT ErrorCode;
  364.37 -  #endif
  364.38 -
  364.39 -  COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}
  364.40 -  ~COutBuffer() { Free(); }
  364.41 -  
  364.42 -  bool Create(UInt32 bufferSize);
  364.43 -  void Free();
  364.44 -
  364.45 -  void SetMemStream(Byte *buffer) { _buffer2 = buffer; }
  364.46 -  void SetStream(ISequentialOutStream *stream);
  364.47 -  void Init();
  364.48 -  HRESULT Flush();
  364.49 -  void FlushWithCheck();
  364.50 -  void ReleaseStream() {  _stream.Release(); }
  364.51 -
  364.52 -  void WriteByte(Byte b)
  364.53 -  {
  364.54 -    _buffer[_pos++] = b;
  364.55 -    if(_pos == _limitPos)
  364.56 -      FlushWithCheck();
  364.57 -  }
  364.58 -  void WriteBytes(const void *data, size_t size)
  364.59 -  {
  364.60 -    for (size_t i = 0; i < size; i++)
  364.61 -      WriteByte(((const Byte *)data)[i]);
  364.62 -  }
  364.63 -
  364.64 -  UInt64 GetProcessedSize() const;
  364.65 -};
  364.66 -
  364.67 -#endif
   365.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.cpp	Sat Mar 03 10:54:39 2012 -0600
   365.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   365.3 @@ -1,142 +0,0 @@
   365.4 -// OutMemStream.cpp
   365.5 -
   365.6 -#include "StdAfx.h"
   365.7 -
   365.8 -#include "OutMemStream.h"
   365.9 -
  365.10 -void COutMemStream::Free()
  365.11 -{
  365.12 -  Blocks.Free(_memManager);
  365.13 -  Blocks.LockMode = true;
  365.14 -}
  365.15 -
  365.16 -void COutMemStream::Init()
  365.17 -{
  365.18 -  WriteToRealStreamEvent.Reset();
  365.19 -  _unlockEventWasSent = false;
  365.20 -  _realStreamMode = false;
  365.21 -  Free();
  365.22 -  _curBlockPos = 0;
  365.23 -  _curBlockIndex = 0;
  365.24 -}
  365.25 -
  365.26 -void COutMemStream::DetachData(CMemLockBlocks &blocks)
  365.27 -{
  365.28 -  Blocks.Detach(blocks, _memManager);
  365.29 -  Free();
  365.30 -}
  365.31 -
  365.32 -
  365.33 -HRESULT COutMemStream::WriteToRealStream()
  365.34 -{
  365.35 -  RINOK(Blocks.WriteToStream(_memManager->GetBlockSize(), OutSeqStream));
  365.36 -  Blocks.Free(_memManager);
  365.37 -  return S_OK;
  365.38 -}
  365.39 -
  365.40 -STDMETHODIMP COutMemStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
  365.41 -{
  365.42 -  if (_realStreamMode)
  365.43 -    return OutSeqStream->Write(data, size, processedSize);
  365.44 -  if (processedSize != 0)
  365.45 -    *processedSize = 0;
  365.46 -  while(size != 0)
  365.47 -  {
  365.48 -    if ((int)_curBlockIndex < Blocks.Blocks.Size())
  365.49 -    {
  365.50 -      Byte *p = (Byte *)Blocks.Blocks[(int)_curBlockIndex] + _curBlockPos;
  365.51 -      size_t curSize = _memManager->GetBlockSize() - _curBlockPos;
  365.52 -      if (size < curSize)
  365.53 -        curSize = size;
  365.54 -      memmove(p, data, curSize);
  365.55 -      if (processedSize != 0)
  365.56 -        *processedSize += (UInt32)curSize;
  365.57 -      data = (const void *)((const Byte *)data + curSize);
  365.58 -      size -= (UInt32)curSize;
  365.59 -      _curBlockPos += curSize;
  365.60 -
  365.61 -      UInt64 pos64 = GetPos();
  365.62 -      if (pos64 > Blocks.TotalSize)
  365.63 -        Blocks.TotalSize = pos64;
  365.64 -      if (_curBlockPos == _memManager->GetBlockSize())
  365.65 -      {
  365.66 -        _curBlockIndex++;
  365.67 -        _curBlockPos = 0;
  365.68 -      }
  365.69 -      continue;
  365.70 -    }
  365.71 -    HANDLE events[3] = { StopWritingEvent, WriteToRealStreamEvent, /* NoLockEvent, */ _memManager->Semaphore };
  365.72 -    DWORD waitResult = ::WaitForMultipleObjects((Blocks.LockMode ? 3 : 2), events, FALSE, INFINITE);
  365.73 -    switch (waitResult)
  365.74 -    {
  365.75 -      case (WAIT_OBJECT_0 + 0):
  365.76 -        return StopWriteResult;
  365.77 -      case (WAIT_OBJECT_0 + 1):
  365.78 -      {
  365.79 -        _realStreamMode = true;
  365.80 -        RINOK(WriteToRealStream());
  365.81 -        UInt32 processedSize2;
  365.82 -        HRESULT res = OutSeqStream->Write(data, size, &processedSize2);
  365.83 -        if (processedSize != 0)
  365.84 -          *processedSize += processedSize2;
  365.85 -        return res;
  365.86 -      }
  365.87 -      /*
  365.88 -      case (WAIT_OBJECT_0 + 2):
  365.89 -      {
  365.90 -        // it has bug: no write.
  365.91 -        if (!Blocks.SwitchToNoLockMode(_memManager))
  365.92 -          return E_FAIL;
  365.93 -        break;
  365.94 -      }
  365.95 -      */
  365.96 -      case (WAIT_OBJECT_0 + 2):
  365.97 -        break;
  365.98 -      default:
  365.99 -        return E_FAIL;
 365.100 -    }
 365.101 -    Blocks.Blocks.Add(_memManager->AllocateBlock());
 365.102 -    if (Blocks.Blocks.Back() == 0)
 365.103 -      return E_FAIL;
 365.104 -  }
 365.105 -  return S_OK;
 365.106 -}
 365.107 -
 365.108 -STDMETHODIMP COutMemStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
 365.109 -{
 365.110 -  if (_realStreamMode)
 365.111 -  {
 365.112 -    if (!OutStream)
 365.113 -      return E_FAIL;
 365.114 -    return OutStream->Seek(offset, seekOrigin, newPosition);
 365.115 -  }
 365.116 -  if (seekOrigin == STREAM_SEEK_CUR)
 365.117 -  {
 365.118 -    if (offset != 0)
 365.119 -      return E_NOTIMPL;
 365.120 -  }
 365.121 -  else if (seekOrigin == STREAM_SEEK_SET)
 365.122 -  {
 365.123 -    if (offset != 0)
 365.124 -      return E_NOTIMPL;
 365.125 -    _curBlockIndex = 0;
 365.126 -    _curBlockPos = 0;
 365.127 -  }
 365.128 -  else
 365.129 -    return E_NOTIMPL;
 365.130 -  if (newPosition != 0)
 365.131 -    *newPosition = GetPos();
 365.132 -  return S_OK;
 365.133 -}
 365.134 -
 365.135 -STDMETHODIMP COutMemStream::SetSize(Int64 newSize)
 365.136 -{
 365.137 -  if (_realStreamMode)
 365.138 -  {
 365.139 -    if (!OutStream)
 365.140 -      return E_FAIL;
 365.141 -    return OutStream->SetSize(newSize);
 365.142 -  }
 365.143 -  Blocks.TotalSize = newSize;
 365.144 -  return S_OK;
 365.145 -}
   366.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.h	Sat Mar 03 10:54:39 2012 -0600
   366.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   366.3 @@ -1,96 +0,0 @@
   366.4 -// OutMemStream.h
   366.5 -
   366.6 -#ifndef __OUTMEMSTREAM_H
   366.7 -#define __OUTMEMSTREAM_H
   366.8 -
   366.9 -#include "Common/MyCom.h"
  366.10 -#include "MemBlocks.h"
  366.11 -
  366.12 -class COutMemStream:
  366.13 -  public IOutStream,
  366.14 -  public CMyUnknownImp
  366.15 -{
  366.16 -  CMemBlockManagerMt *_memManager;
  366.17 -  size_t _curBlockIndex;
  366.18 -  size_t _curBlockPos;
  366.19 -  bool _realStreamMode;
  366.20 -
  366.21 -  bool _unlockEventWasSent;
  366.22 -  NWindows::NSynchronization::CAutoResetEvent StopWritingEvent;
  366.23 -  NWindows::NSynchronization::CAutoResetEvent WriteToRealStreamEvent;
  366.24 -  // NWindows::NSynchronization::CAutoResetEvent NoLockEvent;
  366.25 -
  366.26 -  HRESULT StopWriteResult;
  366.27 -  CMemLockBlocks Blocks;
  366.28 -
  366.29 -  UInt64 GetPos() const { return (UInt64)_curBlockIndex * _memManager->GetBlockSize() + _curBlockPos; }
  366.30 -
  366.31 -  CMyComPtr<ISequentialOutStream> OutSeqStream;
  366.32 -  CMyComPtr<IOutStream> OutStream;
  366.33 -
  366.34 -public:
  366.35 -
  366.36 -  HRes CreateEvents()
  366.37 -  {
  366.38 -    RINOK(StopWritingEvent.CreateIfNotCreated());
  366.39 -    return WriteToRealStreamEvent.CreateIfNotCreated();
  366.40 -  }
  366.41 -
  366.42 -  void SetOutStream(IOutStream *outStream)
  366.43 -  {
  366.44 -    OutStream = outStream;
  366.45 -    OutSeqStream = outStream;
  366.46 -  }
  366.47 -
  366.48 -  void SetSeqOutStream(ISequentialOutStream *outStream)
  366.49 -  {
  366.50 -    OutStream = NULL;
  366.51 -    OutSeqStream = outStream;
  366.52 -  }
  366.53 -
  366.54 -  void ReleaseOutStream()
  366.55 -  {
  366.56 -    OutStream.Release();
  366.57 -    OutSeqStream.Release();
  366.58 -  }
  366.59 -
  366.60 -  COutMemStream(CMemBlockManagerMt *memManager): _memManager(memManager)  { }
  366.61 -
  366.62 -  ~COutMemStream() { Free(); }
  366.63 -  void Free();
  366.64 -
  366.65 -  void Init();
  366.66 -  HRESULT WriteToRealStream();
  366.67 -
  366.68 -  void DetachData(CMemLockBlocks &blocks);
  366.69 -
  366.70 -  bool WasUnlockEventSent() const { return _unlockEventWasSent; }
  366.71 -
  366.72 -  void SetRealStreamMode()
  366.73 -  {
  366.74 -    _unlockEventWasSent = true;
  366.75 -    WriteToRealStreamEvent.Set();
  366.76 -  }
  366.77 -
  366.78 -  /*
  366.79 -  void SetNoLockMode()
  366.80 -  {
  366.81 -    _unlockEventWasSent = true;
  366.82 -    NoLockEvent.Set();
  366.83 -  }
  366.84 -  */
  366.85 -
  366.86 -  void StopWriting(HRESULT res)
  366.87 -  {
  366.88 -    StopWriteResult = res;
  366.89 -    StopWritingEvent.Set();
  366.90 -  }
  366.91 -
  366.92 -  MY_UNKNOWN_IMP
  366.93 -
  366.94 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  366.95 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  366.96 -  STDMETHOD(SetSize)(Int64 newSize);
  366.97 -};
  366.98 -
  366.99 -#endif
   367.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/ProgressMt.cpp	Sat Mar 03 10:54:39 2012 -0600
   367.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   367.3 @@ -1,53 +0,0 @@
   367.4 -// ProgressMt.h
   367.5 -
   367.6 -#include "StdAfx.h"
   367.7 -
   367.8 -#include "ProgressMt.h"
   367.9 -
  367.10 -void CMtCompressProgressMixer::Init(int numItems, ICompressProgressInfo *progress)
  367.11 -{
  367.12 -  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
  367.13 -  InSizes.Clear();
  367.14 -  OutSizes.Clear();
  367.15 -  for (int i = 0; i < numItems; i++)
  367.16 -  {
  367.17 -    InSizes.Add(0);
  367.18 -    OutSizes.Add(0);
  367.19 -  }
  367.20 -  TotalInSize = 0;
  367.21 -  TotalOutSize = 0;
  367.22 -  _progress = progress;
  367.23 -}
  367.24 -
  367.25 -void CMtCompressProgressMixer::Reinit(int index)
  367.26 -{
  367.27 -  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
  367.28 -  InSizes[index] = 0;
  367.29 -  OutSizes[index] = 0;
  367.30 -}
  367.31 -
  367.32 -HRESULT CMtCompressProgressMixer::SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize)
  367.33 -{
  367.34 -  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
  367.35 -  if (inSize != 0)
  367.36 -  {
  367.37 -    UInt64 diff = *inSize - InSizes[index];
  367.38 -    InSizes[index] = *inSize;
  367.39 -    TotalInSize += diff;
  367.40 -  }
  367.41 -  if (outSize != 0)
  367.42 -  {
  367.43 -    UInt64 diff = *outSize - OutSizes[index];
  367.44 -    OutSizes[index] = *outSize;
  367.45 -    TotalOutSize += diff;
  367.46 -  }
  367.47 -  if (_progress)
  367.48 -    return _progress->SetRatioInfo(&TotalInSize, &TotalOutSize);
  367.49 -  return S_OK;
  367.50 -}
  367.51 -
  367.52 -
  367.53 -STDMETHODIMP CMtCompressProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
  367.54 -{
  367.55 -  return _progress->SetRatioInfo(_index, inSize, outSize);
  367.56 -}
   368.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/ProgressMt.h	Sat Mar 03 10:54:39 2012 -0600
   368.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   368.3 @@ -1,46 +0,0 @@
   368.4 -// ProgressMt.h
   368.5 -
   368.6 -#ifndef __PROGRESSMT_H
   368.7 -#define __PROGRESSMT_H
   368.8 -
   368.9 -#include "../../Common/MyCom.h"
  368.10 -#include "../../Common/MyVector.h"
  368.11 -#include "../../Windows/Synchronization.h"
  368.12 -
  368.13 -#include "../ICoder.h"
  368.14 -#include "../IProgress.h"
  368.15 -
  368.16 -class CMtCompressProgressMixer
  368.17 -{
  368.18 -  CMyComPtr<ICompressProgressInfo> _progress;
  368.19 -  CRecordVector<UInt64> InSizes;
  368.20 -  CRecordVector<UInt64> OutSizes;
  368.21 -  UInt64 TotalInSize;
  368.22 -  UInt64 TotalOutSize;
  368.23 -public:
  368.24 -  NWindows::NSynchronization::CCriticalSection CriticalSection;
  368.25 -  void Init(int numItems, ICompressProgressInfo *progress);
  368.26 -  void Reinit(int index);
  368.27 -  HRESULT SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize);
  368.28 -};
  368.29 -
  368.30 -class CMtCompressProgress:
  368.31 -  public ICompressProgressInfo,
  368.32 -  public CMyUnknownImp
  368.33 -{
  368.34 -  CMtCompressProgressMixer *_progress;
  368.35 -  int _index;
  368.36 -public:
  368.37 -  void Init(CMtCompressProgressMixer *progress, int index)
  368.38 -  {
  368.39 -    _progress = progress;
  368.40 -    _index = index;
  368.41 -  }
  368.42 -  void Reinit() { _progress->Reinit(_index); }
  368.43 -
  368.44 -  MY_UNKNOWN_IMP
  368.45 -
  368.46 -  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
  368.47 -};
  368.48 -
  368.49 -#endif
   369.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.cpp	Sat Mar 03 10:54:39 2012 -0600
   369.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   369.3 @@ -1,42 +0,0 @@
   369.4 -// ProgressUtils.h
   369.5 -
   369.6 -#include "StdAfx.h"
   369.7 -
   369.8 -#include "ProgressUtils.h"
   369.9 -
  369.10 -CLocalProgress::CLocalProgress()
  369.11 -{
  369.12 -  ProgressOffset = InSize = OutSize = 0;
  369.13 -  SendRatio = SendProgress = true;
  369.14 -}
  369.15 -
  369.16 -void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
  369.17 -{
  369.18 -  _ratioProgress.Release();
  369.19 -  _progress = progress;
  369.20 -  _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
  369.21 -  _inSizeIsMain = inSizeIsMain;
  369.22 -}
  369.23 -
  369.24 -STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
  369.25 -{
  369.26 -  UInt64 inSizeNew = InSize, outSizeNew = OutSize;
  369.27 -  if (inSize)
  369.28 -    inSizeNew += (*inSize);
  369.29 -  if (outSize)
  369.30 -    outSizeNew += (*outSize);
  369.31 -  if (SendRatio && _ratioProgress)
  369.32 -  {
  369.33 -    RINOK(_ratioProgress->SetRatioInfo(&inSizeNew, &outSizeNew));
  369.34 -  }
  369.35 -  inSizeNew += ProgressOffset;
  369.36 -  outSizeNew += ProgressOffset;
  369.37 -  if (SendProgress)
  369.38 -    return _progress->SetCompleted(_inSizeIsMain ? &inSizeNew : &outSizeNew);
  369.39 -  return S_OK;
  369.40 -}
  369.41 -
  369.42 -HRESULT CLocalProgress::SetCur()
  369.43 -{
  369.44 -  return SetRatioInfo(NULL, NULL);
  369.45 -}
   370.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.h	Sat Mar 03 10:54:39 2012 -0600
   370.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   370.3 @@ -1,34 +0,0 @@
   370.4 -// ProgressUtils.h
   370.5 -
   370.6 -#ifndef __PROGRESSUTILS_H
   370.7 -#define __PROGRESSUTILS_H
   370.8 -
   370.9 -#include "../../Common/MyCom.h"
  370.10 -
  370.11 -#include "../ICoder.h"
  370.12 -#include "../IProgress.h"
  370.13 -
  370.14 -class CLocalProgress:
  370.15 -  public ICompressProgressInfo,
  370.16 -  public CMyUnknownImp
  370.17 -{
  370.18 -  CMyComPtr<IProgress> _progress;
  370.19 -  CMyComPtr<ICompressProgressInfo> _ratioProgress;
  370.20 -  bool _inSizeIsMain;
  370.21 -public:
  370.22 -  UInt64 ProgressOffset;
  370.23 -  UInt64 InSize;
  370.24 -  UInt64 OutSize;
  370.25 -  bool SendRatio;
  370.26 -  bool SendProgress;
  370.27 -
  370.28 -  CLocalProgress();
  370.29 -  void Init(IProgress *progress, bool inSizeIsMain);
  370.30 -  HRESULT SetCur();
  370.31 -
  370.32 -  MY_UNKNOWN_IMP
  370.33 -
  370.34 -  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
  370.35 -};
  370.36 -
  370.37 -#endif
   371.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/RegisterArc.h	Sat Mar 03 10:54:39 2012 -0600
   371.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   371.3 @@ -1,33 +0,0 @@
   371.4 -// RegisterArc.h
   371.5 -
   371.6 -#ifndef __REGISTERARC_H
   371.7 -#define __REGISTERARC_H
   371.8 -
   371.9 -#include "../Archive/IArchive.h"
  371.10 -#include "DeclareArcs.h"
  371.11 -
  371.12 -typedef IInArchive * (*CreateInArchiveP)();
  371.13 -typedef IOutArchive * (*CreateOutArchiveP)();
  371.14 -
  371.15 -struct CArcInfo
  371.16 -{
  371.17 -  const wchar_t *Name;
  371.18 -  const wchar_t *Ext;
  371.19 -  const wchar_t *AddExt;
  371.20 -  Byte ClassId;
  371.21 -  Byte Signature[16];
  371.22 -  int SignatureSize;
  371.23 -  bool KeepName;
  371.24 -  CreateInArchiveP CreateInArchive;
  371.25 -  CreateOutArchiveP CreateOutArchive;
  371.26 -};
  371.27 -
  371.28 -void RegisterArc(const CArcInfo *arcInfo);
  371.29 -
  371.30 -#define REGISTER_ARC(x) CRegister##x::CRegister##x() { RegisterArc(&g_ArcInfo); } \
  371.31 -    CRegister##x g_RegisterArc##x;
  371.32 -
  371.33 -#define REGISTER_ARCN(x,n) CRegister##x##n::CRegister##x##n() { RegisterArc(&g_ArcInfo##n); } \
  371.34 -	CRegister##x##n g_RegisterArc##n##x;
  371.35 -
  371.36 -#endif
   372.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/RegisterCodec.h	Sat Mar 03 10:54:39 2012 -0600
   372.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   372.3 @@ -1,30 +0,0 @@
   372.4 -// RegisterCodec.h
   372.5 -
   372.6 -#ifndef __REGISTERCODEC_H
   372.7 -#define __REGISTERCODEC_H
   372.8 -
   372.9 -#include "../Common/MethodId.h"
  372.10 -#include "DeclareCodecs.h"
  372.11 -
  372.12 -typedef void * (*CreateCodecP)();
  372.13 -struct CCodecInfo
  372.14 -{
  372.15 -  CreateCodecP CreateDecoder;
  372.16 -  CreateCodecP CreateEncoder;
  372.17 -  CMethodId Id;
  372.18 -  const wchar_t *Name;
  372.19 -  UInt32 NumInStreams;
  372.20 -  bool IsFilter;
  372.21 -};
  372.22 -
  372.23 -void RegisterCodec(const CCodecInfo *codecInfo);
  372.24 -
  372.25 -#define REGISTER_CODEC(x) CRegisterCodec##x::CRegisterCodec##x() { RegisterCodec(&g_CodecInfo); } \
  372.26 -    CRegisterCodec##x g_RegisterCodec##x;
  372.27 -
  372.28 -#define REGISTER_CODECS(x) CRegisterCodecs##x::CRegisterCodecs##x() { \
  372.29 -	for(int i=0;i<sizeof(g_CodecsInfo)/sizeof(*g_CodecsInfo);i++) \
  372.30 -		RegisterCodec(&g_CodecsInfo[i]); } \
  372.31 -	CRegisterCodecs##x g_RegisterCodecs##x;
  372.32 -
  372.33 -#endif
   373.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   373.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   373.3 @@ -1,9 +0,0 @@
   373.4 -// StdAfx.h
   373.5 -
   373.6 -#ifndef __STDAFX_H
   373.7 -#define __STDAFX_H
   373.8 -
   373.9 -#include "../../Common/MyWindows.h"
  373.10 -#include "../../Common/NewHandler.h"
  373.11 -
  373.12 -#endif
   374.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamBinder.cpp	Sat Mar 03 10:54:39 2012 -0600
   374.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   374.3 @@ -1,150 +0,0 @@
   374.4 -// StreamBinder.cpp
   374.5 -
   374.6 -#include "StdAfx.h"
   374.7 -
   374.8 -#include "StreamBinder.h"
   374.9 -#include "../../Common/Defs.h"
  374.10 -#include "../../Common/MyCom.h"
  374.11 -
  374.12 -using namespace NWindows;
  374.13 -using namespace NSynchronization;
  374.14 -
  374.15 -class CSequentialInStreamForBinder:
  374.16 -  public ISequentialInStream,
  374.17 -  public CMyUnknownImp
  374.18 -{
  374.19 -public:
  374.20 -  MY_UNKNOWN_IMP
  374.21 -
  374.22 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  374.23 -private:
  374.24 -  CStreamBinder *m_StreamBinder;
  374.25 -public:
  374.26 -  ~CSequentialInStreamForBinder() { m_StreamBinder->CloseRead(); }
  374.27 -  void SetBinder(CStreamBinder *streamBinder) { m_StreamBinder = streamBinder; }
  374.28 -};
  374.29 -
  374.30 -STDMETHODIMP CSequentialInStreamForBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
  374.31 -  { return m_StreamBinder->Read(data, size, processedSize); }
  374.32 -
  374.33 -class CSequentialOutStreamForBinder:
  374.34 -  public ISequentialOutStream,
  374.35 -  public CMyUnknownImp
  374.36 -{
  374.37 -public:
  374.38 -  MY_UNKNOWN_IMP
  374.39 -
  374.40 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  374.41 -
  374.42 -private:
  374.43 -  CStreamBinder *m_StreamBinder;
  374.44 -public:
  374.45 -  ~CSequentialOutStreamForBinder() {  m_StreamBinder->CloseWrite(); }
  374.46 -  void SetBinder(CStreamBinder *streamBinder) { m_StreamBinder = streamBinder; }
  374.47 -};
  374.48 -
  374.49 -STDMETHODIMP CSequentialOutStreamForBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
  374.50 -  { return m_StreamBinder->Write(data, size, processedSize); }
  374.51 -
  374.52 -
  374.53 -//////////////////////////
  374.54 -// CStreamBinder
  374.55 -// (_thereAreBytesToReadEvent && _bufferSize == 0) means that stream is finished.
  374.56 -
  374.57 -HRes CStreamBinder::CreateEvents()
  374.58 -{
  374.59 -  RINOK(_allBytesAreWritenEvent.Create(true));
  374.60 -  RINOK(_thereAreBytesToReadEvent.Create());
  374.61 -  return _readStreamIsClosedEvent.Create();
  374.62 -}
  374.63 -
  374.64 -void CStreamBinder::ReInit()
  374.65 -{
  374.66 -  _thereAreBytesToReadEvent.Reset();
  374.67 -  _readStreamIsClosedEvent.Reset();
  374.68 -  ProcessedSize = 0;
  374.69 -}
  374.70 -
  374.71 -
  374.72 -  
  374.73 -void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
  374.74 -      ISequentialOutStream **outStream)
  374.75 -{
  374.76 -  CSequentialInStreamForBinder *inStreamSpec = new
  374.77 -      CSequentialInStreamForBinder;
  374.78 -  CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
  374.79 -  inStreamSpec->SetBinder(this);
  374.80 -  *inStream = inStreamLoc.Detach();
  374.81 -
  374.82 -  CSequentialOutStreamForBinder *outStreamSpec = new
  374.83 -      CSequentialOutStreamForBinder;
  374.84 -  CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec);
  374.85 -  outStreamSpec->SetBinder(this);
  374.86 -  *outStream = outStreamLoc.Detach();
  374.87 -
  374.88 -  _buffer = NULL;
  374.89 -  _bufferSize= 0;
  374.90 -  ProcessedSize = 0;
  374.91 -}
  374.92 -
  374.93 -HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
  374.94 -{
  374.95 -  UInt32 sizeToRead = size;
  374.96 -  if (size > 0)
  374.97 -  {
  374.98 -    RINOK(_thereAreBytesToReadEvent.Lock());
  374.99 -    sizeToRead = MyMin(_bufferSize, size);
 374.100 -    if (_bufferSize > 0)
 374.101 -    {
 374.102 -      memcpy(data, _buffer, sizeToRead);
 374.103 -      _buffer = ((const Byte *)_buffer) + sizeToRead;
 374.104 -      _bufferSize -= sizeToRead;
 374.105 -      if (_bufferSize == 0)
 374.106 -      {
 374.107 -        _thereAreBytesToReadEvent.Reset();
 374.108 -        _allBytesAreWritenEvent.Set();
 374.109 -      }
 374.110 -    }
 374.111 -  }
 374.112 -  if (processedSize != NULL)
 374.113 -    *processedSize = sizeToRead;
 374.114 -  ProcessedSize += sizeToRead;
 374.115 -  return S_OK;
 374.116 -}
 374.117 -
 374.118 -void CStreamBinder::CloseRead()
 374.119 -{
 374.120 -  _readStreamIsClosedEvent.Set();
 374.121 -}
 374.122 -
 374.123 -HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
 374.124 -{
 374.125 -  if (size > 0)
 374.126 -  {
 374.127 -    _buffer = data;
 374.128 -    _bufferSize = size;
 374.129 -    _allBytesAreWritenEvent.Reset();
 374.130 -    _thereAreBytesToReadEvent.Set();
 374.131 -
 374.132 -    HANDLE events[2];
 374.133 -    events[0] = _allBytesAreWritenEvent;
 374.134 -    events[1] = _readStreamIsClosedEvent;
 374.135 -    DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
 374.136 -    if (waitResult != WAIT_OBJECT_0 + 0)
 374.137 -    {
 374.138 -      // ReadingWasClosed = true;
 374.139 -      return S_FALSE;
 374.140 -    }
 374.141 -    // if(!_allBytesAreWritenEvent.Lock())
 374.142 -    //   return E_FAIL;
 374.143 -  }
 374.144 -  if (processedSize != NULL)
 374.145 -    *processedSize = size;
 374.146 -  return S_OK;
 374.147 -}
 374.148 -
 374.149 -void CStreamBinder::CloseWrite()
 374.150 -{
 374.151 -  // _bufferSize must be = 0
 374.152 -  _thereAreBytesToReadEvent.Set();
 374.153 -}
   375.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamBinder.h	Sat Mar 03 10:54:39 2012 -0600
   375.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   375.3 @@ -1,32 +0,0 @@
   375.4 -// StreamBinder.h
   375.5 -
   375.6 -#ifndef __STREAMBINDER_H
   375.7 -#define __STREAMBINDER_H
   375.8 -
   375.9 -#include "../IStream.h"
  375.10 -#include "../../Windows/Synchronization.h"
  375.11 -
  375.12 -class CStreamBinder
  375.13 -{
  375.14 -  NWindows::NSynchronization::CManualResetEvent _allBytesAreWritenEvent;
  375.15 -  NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent;
  375.16 -  NWindows::NSynchronization::CManualResetEvent _readStreamIsClosedEvent;
  375.17 -  UInt32 _bufferSize;
  375.18 -  const void *_buffer;
  375.19 -public:
  375.20 -  // bool ReadingWasClosed;
  375.21 -  UInt64 ProcessedSize;
  375.22 -  CStreamBinder() {}
  375.23 -  HRes CreateEvents();
  375.24 -
  375.25 -  void CreateStreams(ISequentialInStream **inStream,
  375.26 -      ISequentialOutStream **outStream);
  375.27 -  HRESULT Read(void *data, UInt32 size, UInt32 *processedSize);
  375.28 -  void CloseRead();
  375.29 -
  375.30 -  HRESULT Write(const void *data, UInt32 size, UInt32 *processedSize);
  375.31 -  void CloseWrite();
  375.32 -  void ReInit();
  375.33 -};
  375.34 -
  375.35 -#endif
   376.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.cpp	Sat Mar 03 10:54:39 2012 -0600
   376.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   376.3 @@ -1,68 +0,0 @@
   376.4 -// StreamObjects.cpp
   376.5 -
   376.6 -#include "StdAfx.h"
   376.7 -
   376.8 -#include "StreamObjects.h"
   376.9 -#include "../../Common/Defs.h"
  376.10 -
  376.11 -
  376.12 -STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
  376.13 -{
  376.14 -  size_t rem = _size - _pos;
  376.15 -  if (size < rem)
  376.16 -    rem = (size_t)size;
  376.17 -  memcpy(data, _dataPointer + _pos, rem);
  376.18 -  _pos += rem;
  376.19 -  if (processedSize != NULL)
  376.20 -    *processedSize = (UInt32)rem;
  376.21 -  return S_OK;
  376.22 -}
  376.23 -
  376.24 -
  376.25 -void CWriteBuffer::Write(const void *data, size_t size)
  376.26 -{
  376.27 -  size_t newCapacity = _size + size;
  376.28 -  _buffer.EnsureCapacity(newCapacity);
  376.29 -  memcpy(_buffer + _size, data, size);
  376.30 -  _size += size;
  376.31 -}
  376.32 -
  376.33 -STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
  376.34 -{
  376.35 -  _writeBuffer.Write(data, (size_t)size);
  376.36 -  if(processedSize != NULL)
  376.37 -    *processedSize = size;
  376.38 -  return S_OK;
  376.39 -}
  376.40 -
  376.41 -STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)
  376.42 -{
  376.43 -  size_t rem = _size - _pos;
  376.44 -  if (size < rem)
  376.45 -    rem = (size_t)size;
  376.46 -  memcpy(_buffer + _pos, data, rem);
  376.47 -  _pos += rem;
  376.48 -  if (processedSize != NULL)
  376.49 -    *processedSize = (UInt32)rem;
  376.50 -  return (rem == size ? S_OK : E_FAIL);
  376.51 -}
  376.52 -
  376.53 -STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize)
  376.54 -{
  376.55 -  UInt32 realProcessedSize;
  376.56 -  HRESULT result = _stream->Read(data, size, &realProcessedSize);
  376.57 -  _size += realProcessedSize;
  376.58 -  if (processedSize != 0)
  376.59 -    *processedSize = realProcessedSize;
  376.60 -  return result;
  376.61 -}
  376.62 -
  376.63 -STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)
  376.64 -{
  376.65 -  UInt32 realProcessedSize;
  376.66 -  HRESULT result = _stream->Write(data, size, &realProcessedSize);
  376.67 -  _size += realProcessedSize;
  376.68 -  if (processedSize != 0)
  376.69 -    *processedSize = realProcessedSize;
  376.70 -  return result;
  376.71 -}
   377.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.h	Sat Mar 03 10:54:39 2012 -0600
   377.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   377.3 @@ -1,117 +0,0 @@
   377.4 -// StreamObjects.h
   377.5 -
   377.6 -#ifndef __STREAMOBJECTS_H
   377.7 -#define __STREAMOBJECTS_H
   377.8 -
   377.9 -#include "../../Common/DynamicBuffer.h"
  377.10 -#include "../../Common/MyCom.h"
  377.11 -#include "../IStream.h"
  377.12 -
  377.13 -class CSequentialInStreamImp:
  377.14 -  public ISequentialInStream,
  377.15 -  public CMyUnknownImp
  377.16 -{
  377.17 -  const Byte *_dataPointer;
  377.18 -  size_t _size;
  377.19 -  size_t _pos;
  377.20 -
  377.21 -public:
  377.22 -  void Init(const Byte *dataPointer, size_t size)
  377.23 -  {
  377.24 -    _dataPointer = dataPointer;
  377.25 -    _size = size;
  377.26 -    _pos = 0;
  377.27 -  }
  377.28 -
  377.29 -  MY_UNKNOWN_IMP
  377.30 -
  377.31 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  377.32 -};
  377.33 -
  377.34 -
  377.35 -class CWriteBuffer
  377.36 -{
  377.37 -  CByteDynamicBuffer _buffer;
  377.38 -  size_t _size;
  377.39 -public:
  377.40 -  CWriteBuffer(): _size(0) {}
  377.41 -  void Init() { _size = 0;  }
  377.42 -  void Write(const void *data, size_t size);
  377.43 -  size_t GetSize() const { return _size; }
  377.44 -  const CByteDynamicBuffer& GetBuffer() const { return _buffer; }
  377.45 -};
  377.46 -
  377.47 -class CSequentialOutStreamImp:
  377.48 -  public ISequentialOutStream,
  377.49 -  public CMyUnknownImp
  377.50 -{
  377.51 -  CWriteBuffer _writeBuffer;
  377.52 -public:
  377.53 -  void Init() { _writeBuffer.Init(); }
  377.54 -  size_t GetSize() const { return _writeBuffer.GetSize(); }
  377.55 -  const CByteDynamicBuffer& GetBuffer() const { return _writeBuffer.GetBuffer(); }
  377.56 -
  377.57 -  MY_UNKNOWN_IMP
  377.58 -
  377.59 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  377.60 -};
  377.61 -
  377.62 -class CSequentialOutStreamImp2:
  377.63 -  public ISequentialOutStream,
  377.64 -  public CMyUnknownImp
  377.65 -{
  377.66 -  Byte *_buffer;
  377.67 -  size_t _size;
  377.68 -  size_t _pos;
  377.69 -public:
  377.70 -
  377.71 -  void Init(Byte *buffer, size_t size)
  377.72 -  {
  377.73 -    _buffer = buffer;
  377.74 -    _pos = 0;
  377.75 -    _size = size;
  377.76 -  }
  377.77 -
  377.78 -  size_t GetPos() const { return _pos; }
  377.79 -
  377.80 -  MY_UNKNOWN_IMP
  377.81 -
  377.82 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  377.83 -};
  377.84 -
  377.85 -class CSequentialInStreamSizeCount:
  377.86 -  public ISequentialInStream,
  377.87 -  public CMyUnknownImp
  377.88 -{
  377.89 -  CMyComPtr<ISequentialInStream> _stream;
  377.90 -  UInt64 _size;
  377.91 -public:
  377.92 -  void Init(ISequentialInStream *stream)
  377.93 -  {
  377.94 -    _stream = stream;
  377.95 -    _size = 0;
  377.96 -  }
  377.97 -  UInt64 GetSize() const { return _size; }
  377.98 -
  377.99 -  MY_UNKNOWN_IMP
 377.100 -
 377.101 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
 377.102 -};
 377.103 -
 377.104 -class CSequentialOutStreamSizeCount:
 377.105 -  public ISequentialOutStream,
 377.106 -  public CMyUnknownImp
 377.107 -{
 377.108 -  CMyComPtr<ISequentialOutStream> _stream;
 377.109 -  UInt64 _size;
 377.110 -public:
 377.111 -  void SetStream(ISequentialOutStream *stream) { _stream = stream; }
 377.112 -  void Init() { _size = 0; }
 377.113 -  UInt64 GetSize() const { return _size; }
 377.114 -
 377.115 -  MY_UNKNOWN_IMP
 377.116 -
 377.117 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
 377.118 -};
 377.119 -
 377.120 -#endif
   378.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamUtils.cpp	Sat Mar 03 10:54:39 2012 -0600
   378.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   378.3 @@ -1,56 +0,0 @@
   378.4 -// StreamUtils.cpp
   378.5 -
   378.6 -#include "StdAfx.h"
   378.7 -
   378.8 -#include "StreamUtils.h"
   378.9 -
  378.10 -static const UInt32 kBlockSize = ((UInt32)1 << 31);
  378.11 -
  378.12 -HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize)
  378.13 -{
  378.14 -  size_t size = *processedSize;
  378.15 -  *processedSize = 0;
  378.16 -  while (size != 0)
  378.17 -  {
  378.18 -    UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
  378.19 -    UInt32 processedSizeLoc;
  378.20 -    HRESULT res = stream->Read(data, curSize, &processedSizeLoc);
  378.21 -    *processedSize += processedSizeLoc;
  378.22 -    data = (void *)((Byte *)data + processedSizeLoc);
  378.23 -    size -= processedSizeLoc;
  378.24 -    RINOK(res);
  378.25 -    if (processedSizeLoc == 0)
  378.26 -      return S_OK;
  378.27 -  }
  378.28 -  return S_OK;
  378.29 -}
  378.30 -
  378.31 -HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size)
  378.32 -{
  378.33 -  size_t processedSize = size;
  378.34 -  RINOK(ReadStream(stream, data, &processedSize));
  378.35 -  return (size == processedSize) ? S_OK : S_FALSE;
  378.36 -}
  378.37 -
  378.38 -HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size)
  378.39 -{
  378.40 -  size_t processedSize = size;
  378.41 -  RINOK(ReadStream(stream, data, &processedSize));
  378.42 -  return (size == processedSize) ? S_OK : E_FAIL;
  378.43 -}
  378.44 -
  378.45 -HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
  378.46 -{
  378.47 -  while (size != 0)
  378.48 -  {
  378.49 -    UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
  378.50 -    UInt32 processedSizeLoc;
  378.51 -    HRESULT res = stream->Write(data, curSize, &processedSizeLoc);
  378.52 -    data = (const void *)((const Byte *)data + processedSizeLoc);
  378.53 -    size -= processedSizeLoc;
  378.54 -    RINOK(res);
  378.55 -    if (processedSizeLoc == 0)
  378.56 -      return E_FAIL;
  378.57 -  }
  378.58 -  return S_OK;
  378.59 -}
   379.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/StreamUtils.h	Sat Mar 03 10:54:39 2012 -0600
   379.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   379.3 @@ -1,13 +0,0 @@
   379.4 -// StreamUtils.h
   379.5 -
   379.6 -#ifndef __STREAMUTILS_H
   379.7 -#define __STREAMUTILS_H
   379.8 -
   379.9 -#include "../IStream.h"
  379.10 -
  379.11 -HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *size);
  379.12 -HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size);
  379.13 -HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size);
  379.14 -HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size);
  379.15 -
  379.16 -#endif
   380.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/VirtThread.cpp	Sat Mar 03 10:54:39 2012 -0600
   380.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   380.3 @@ -1,45 +0,0 @@
   380.4 -// VirtThread.cpp
   380.5 -
   380.6 -#include "StdAfx.h"
   380.7 -
   380.8 -#include "VirtThread.h"
   380.9 -
  380.10 -static THREAD_FUNC_DECL CoderThread(void *p)
  380.11 -{
  380.12 -  for (;;)
  380.13 -  {
  380.14 -    CVirtThread *t = (CVirtThread *)p;
  380.15 -    t->StartEvent.Lock();
  380.16 -    if (t->ExitEvent)
  380.17 -      return 0;
  380.18 -    t->Execute();
  380.19 -    t->FinishedEvent.Set();
  380.20 -  }
  380.21 -}
  380.22 -
  380.23 -WRes CVirtThread::Create()
  380.24 -{
  380.25 -  RINOK(StartEvent.CreateIfNotCreated());
  380.26 -  RINOK(FinishedEvent.CreateIfNotCreated());
  380.27 -  StartEvent.Reset();
  380.28 -  FinishedEvent.Reset();
  380.29 -  ExitEvent = false;
  380.30 -  if (Thread.IsCreated())
  380.31 -    return S_OK;
  380.32 -  return Thread.Create(CoderThread, this);
  380.33 -}
  380.34 -
  380.35 -void CVirtThread::Start()
  380.36 -{
  380.37 -  ExitEvent = false;
  380.38 -  StartEvent.Set();
  380.39 -}
  380.40 -
  380.41 -CVirtThread::~CVirtThread()
  380.42 -{
  380.43 -  ExitEvent = true;
  380.44 -  if (StartEvent.IsCreated())
  380.45 -    StartEvent.Set();
  380.46 -  Thread.Wait();
  380.47 -}
  380.48 -
   381.1 --- a/src/win32/7zip/7z/CPP/7zip/Common/VirtThread.h	Sat Mar 03 10:54:39 2012 -0600
   381.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   381.3 @@ -1,23 +0,0 @@
   381.4 -// VirtThread.h
   381.5 -
   381.6 -#ifndef __VIRTTHREAD_H
   381.7 -#define __VIRTTHREAD_H
   381.8 -
   381.9 -#include "../../Windows/Synchronization.h"
  381.10 -#include "../../Windows/Thread.h"
  381.11 -
  381.12 -struct CVirtThread
  381.13 -{
  381.14 -  NWindows::NSynchronization::CAutoResetEvent StartEvent;
  381.15 -  NWindows::NSynchronization::CAutoResetEvent FinishedEvent;
  381.16 -  NWindows::CThread Thread;
  381.17 -  bool ExitEvent;
  381.18 -
  381.19 -  ~CVirtThread();
  381.20 -  WRes Create();
  381.21 -  void Start();
  381.22 -  void WaitFinish() { FinishedEvent.Lock(); }
  381.23 -  virtual void Execute() = 0;
  381.24 -};
  381.25 -
  381.26 -#endif
   382.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Const.h	Sat Mar 03 10:54:39 2012 -0600
   382.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   382.3 @@ -1,54 +0,0 @@
   382.4 -// Compress/BZip2Const.h
   382.5 -
   382.6 -#ifndef __COMPRESS_BZIP2_CONST_H
   382.7 -#define __COMPRESS_BZIP2_CONST_H
   382.8 -
   382.9 -namespace NCompress {
  382.10 -namespace NBZip2 {
  382.11 -
  382.12 -const Byte kArSig0 = 'B';
  382.13 -const Byte kArSig1 = 'Z';
  382.14 -const Byte kArSig2 = 'h';
  382.15 -const Byte kArSig3 = '0';
  382.16 -
  382.17 -const Byte kFinSig0 = 0x17;
  382.18 -const Byte kFinSig1 = 0x72;
  382.19 -const Byte kFinSig2 = 0x45;
  382.20 -const Byte kFinSig3 = 0x38;
  382.21 -const Byte kFinSig4 = 0x50;
  382.22 -const Byte kFinSig5 = 0x90;
  382.23 -
  382.24 -const Byte kBlockSig0 = 0x31;
  382.25 -const Byte kBlockSig1 = 0x41;
  382.26 -const Byte kBlockSig2 = 0x59;
  382.27 -const Byte kBlockSig3 = 0x26;
  382.28 -const Byte kBlockSig4 = 0x53;
  382.29 -const Byte kBlockSig5 = 0x59;
  382.30 -
  382.31 -const int kNumOrigBits = 24;
  382.32 -
  382.33 -const int kNumTablesBits = 3;
  382.34 -const int kNumTablesMin = 2;
  382.35 -const int kNumTablesMax = 6;
  382.36 -
  382.37 -const int kNumLevelsBits = 5;
  382.38 -
  382.39 -const int kMaxHuffmanLen = 20; // Check it
  382.40 -
  382.41 -const int kMaxAlphaSize = 258;
  382.42 -
  382.43 -const int kGroupSize = 50;
  382.44 -
  382.45 -const int kBlockSizeMultMin = 1;
  382.46 -const int kBlockSizeMultMax = 9;
  382.47 -const UInt32 kBlockSizeStep = 100000;
  382.48 -const UInt32 kBlockSizeMax = kBlockSizeMultMax * kBlockSizeStep;
  382.49 -
  382.50 -const int kNumSelectorsBits = 15;
  382.51 -const UInt32 kNumSelectorsMax = (2 + (kBlockSizeMax / kGroupSize));
  382.52 -
  382.53 -const int kRleModeRepSize = 4;
  382.54 -
  382.55 -}}
  382.56 -
  382.57 -#endif
   383.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.cpp	Sat Mar 03 10:54:39 2012 -0600
   383.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   383.3 @@ -1,26 +0,0 @@
   383.4 -// BZip2Crc.cpp
   383.5 -
   383.6 -#include "StdAfx.h"
   383.7 -
   383.8 -#include "BZip2Crc.h"
   383.9 -
  383.10 -UInt32 CBZip2Crc::Table[256];
  383.11 -
  383.12 -static const UInt32 kBZip2CrcPoly = 0x04c11db7;  /* AUTODIN II, Ethernet, & FDDI */
  383.13 -
  383.14 -void CBZip2Crc::InitTable()
  383.15 -{
  383.16 -  for (UInt32 i = 0; i < 256; i++)
  383.17 -  {
  383.18 -    UInt32 r = (i << 24);
  383.19 -    for (int j = 8; j > 0; j--)
  383.20 -      r = (r & 0x80000000) ? ((r << 1) ^ kBZip2CrcPoly) : (r << 1);
  383.21 -    Table[i] = r;
  383.22 -  }
  383.23 -}
  383.24 -
  383.25 -class CBZip2CrcTableInit
  383.26 -{
  383.27 -public:
  383.28 -  CBZip2CrcTableInit() { CBZip2Crc::InitTable(); }
  383.29 -} g_BZip2CrcTableInit;
   384.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.h	Sat Mar 03 10:54:39 2012 -0600
   384.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   384.3 @@ -1,31 +0,0 @@
   384.4 -// BZip2Crc.h
   384.5 -
   384.6 -#ifndef __BZIP2_CRC_H
   384.7 -#define __BZIP2_CRC_H
   384.8 -
   384.9 -#include "Common/Types.h"
  384.10 -
  384.11 -class CBZip2Crc
  384.12 -{
  384.13 -  UInt32 _value;
  384.14 -  static UInt32 Table[256];
  384.15 -public:
  384.16 -  static void InitTable();
  384.17 -  CBZip2Crc(): _value(0xFFFFFFFF) {};
  384.18 -  void Init() { _value = 0xFFFFFFFF; }
  384.19 -  void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
  384.20 -  void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
  384.21 -  UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
  384.22 -};
  384.23 -
  384.24 -class CBZip2CombinedCrc
  384.25 -{
  384.26 -  UInt32 _value;
  384.27 -public:
  384.28 -  CBZip2CombinedCrc():  _value(0){};
  384.29 -  void Init() { _value = 0; }
  384.30 -  void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
  384.31 -  UInt32 GetDigest() const { return _value ; }
  384.32 -};
  384.33 -
  384.34 -#endif
   385.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Decoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   385.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   385.3 @@ -1,791 +0,0 @@
   385.4 -// BZip2Decoder.cpp
   385.5 -
   385.6 -#include "StdAfx.h"
   385.7 -
   385.8 -extern "C"
   385.9 -{
  385.10 -#include "../../../C/Alloc.h"
  385.11 -}
  385.12 -
  385.13 -#include "../../Common/Defs.h"
  385.14 -
  385.15 -#include "BZip2Crc.h"
  385.16 -#include "BZip2Decoder.h"
  385.17 -#include "Mtf8.h"
  385.18 -
  385.19 -namespace NCompress {
  385.20 -namespace NBZip2 {
  385.21 -
  385.22 -#define NO_INLINE MY_FAST_CALL
  385.23 -
  385.24 -const UInt32 kNumThreadsMax = 4;
  385.25 -
  385.26 -static const UInt32 kBufferSize = (1 << 17);
  385.27 -
  385.28 -static Int16 kRandNums[512] = {
  385.29 -   619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
  385.30 -   985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
  385.31 -   733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
  385.32 -   419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
  385.33 -   878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
  385.34 -   862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
  385.35 -   150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
  385.36 -   170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
  385.37 -   73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
  385.38 -   909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
  385.39 -   641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
  385.40 -   161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
  385.41 -   382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
  385.42 -   98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
  385.43 -   227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
  385.44 -   469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
  385.45 -   184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
  385.46 -   715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
  385.47 -   951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
  385.48 -   652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
  385.49 -   645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
  385.50 -   609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
  385.51 -   653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
  385.52 -   411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
  385.53 -   170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
  385.54 -   857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
  385.55 -   669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
  385.56 -   944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
  385.57 -   344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
  385.58 -   897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
  385.59 -   433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
  385.60 -   686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
  385.61 -   946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
  385.62 -   978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
  385.63 -   680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
  385.64 -   707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
  385.65 -   297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
  385.66 -   134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
  385.67 -   343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
  385.68 -   140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
  385.69 -   170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
  385.70 -   369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
  385.71 -   804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
  385.72 -   896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
  385.73 -   661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
  385.74 -   768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
  385.75 -   61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
  385.76 -   372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
  385.77 -   780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
  385.78 -   920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
  385.79 -   645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
  385.80 -   936, 638
  385.81 -};
  385.82 -
  385.83 -bool CState::Alloc()
  385.84 -{
  385.85 -  if (Counters == 0)
  385.86 -    Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
  385.87 -  return (Counters != 0);
  385.88 -}
  385.89 -
  385.90 -void CState::Free()
  385.91 -{
  385.92 -  ::BigFree(Counters);
  385.93 -  Counters = 0;
  385.94 -}
  385.95 -
  385.96 -UInt32 CDecoder::ReadBits(int numBits) {  return m_InStream.ReadBits(numBits); }
  385.97 -Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
  385.98 -bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
  385.99 -
 385.100 -UInt32 CDecoder::ReadCrc()
 385.101 -{
 385.102 -  UInt32 crc = 0;
 385.103 -  for (int i = 0; i < 4; i++)
 385.104 -  {
 385.105 -    crc <<= 8;
 385.106 -    crc |= ReadByte();
 385.107 -  }
 385.108 -  return crc;
 385.109 -}
 385.110 -
 385.111 -UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num)
 385.112 -{
 385.113 -  return m_InStream->ReadBits(num);
 385.114 -}
 385.115 -
 385.116 -UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
 385.117 -{
 385.118 -  return m_InStream->ReadBits(1);
 385.119 -}
 385.120 -
 385.121 -static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
 385.122 -  UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
 385.123 -  UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
 385.124 -{
 385.125 -  *randRes = ReadBit(m_InStream) ? true : false;
 385.126 -  *origPtrRes = ReadBits(m_InStream, kNumOrigBits);
 385.127 -  
 385.128 -  // in original code it compares OrigPtr to (UInt32)(10 + blockSizeMax)) : why ?
 385.129 -  if (*origPtrRes >= blockSizeMax)
 385.130 -    return S_FALSE;
 385.131 -
 385.132 -  CMtf8Decoder mtf;
 385.133 -  mtf.StartInit();
 385.134 -  
 385.135 -  int numInUse = 0;
 385.136 -  {
 385.137 -    Byte inUse16[16];
 385.138 -    int i;
 385.139 -    for (i = 0; i < 16; i++)
 385.140 -      inUse16[i] = (Byte)ReadBit(m_InStream);
 385.141 -    for (i = 0; i < 256; i++)
 385.142 -      if (inUse16[i >> 4])
 385.143 -      {
 385.144 -        if (ReadBit(m_InStream))
 385.145 -          mtf.Add(numInUse++, (Byte)i);
 385.146 -      }
 385.147 -    if (numInUse == 0)
 385.148 -      return S_FALSE;
 385.149 -    // mtf.Init(numInUse);
 385.150 -  }
 385.151 -  int alphaSize = numInUse + 2;
 385.152 -
 385.153 -  int numTables = ReadBits(m_InStream, kNumTablesBits);
 385.154 -  if (numTables < kNumTablesMin || numTables > kNumTablesMax)
 385.155 -    return S_FALSE;
 385.156 -  
 385.157 -  UInt32 numSelectors = ReadBits(m_InStream, kNumSelectorsBits);
 385.158 -  if (numSelectors < 1 || numSelectors > kNumSelectorsMax)
 385.159 -    return S_FALSE;
 385.160 -
 385.161 -  {
 385.162 -    Byte mtfPos[kNumTablesMax];
 385.163 -    int t = 0;
 385.164 -    do
 385.165 -      mtfPos[t] = (Byte)t;
 385.166 -    while(++t < numTables);
 385.167 -    UInt32 i = 0;
 385.168 -    do
 385.169 -    {
 385.170 -      int j = 0;
 385.171 -      while (ReadBit(m_InStream))
 385.172 -        if (++j >= numTables)
 385.173 -          return S_FALSE;
 385.174 -      Byte tmp = mtfPos[j];
 385.175 -      for (;j > 0; j--)
 385.176 -        mtfPos[j] = mtfPos[j - 1];
 385.177 -      m_Selectors[i] = mtfPos[0] = tmp;
 385.178 -    }
 385.179 -    while(++i < numSelectors);
 385.180 -  }
 385.181 -
 385.182 -  int t = 0;
 385.183 -  do
 385.184 -  {
 385.185 -    Byte lens[kMaxAlphaSize];
 385.186 -    int len = (int)ReadBits(m_InStream, kNumLevelsBits);
 385.187 -    int i;
 385.188 -    for (i = 0; i < alphaSize; i++)
 385.189 -    {
 385.190 -      for (;;)
 385.191 -      {
 385.192 -        if (len < 1 || len > kMaxHuffmanLen)
 385.193 -          return S_FALSE;
 385.194 -        if (!ReadBit(m_InStream))
 385.195 -          break;
 385.196 -        len += 1 - (int)(ReadBit(m_InStream) << 1);
 385.197 -      }
 385.198 -      lens[i] = (Byte)len;
 385.199 -    }
 385.200 -    for (; i < kMaxAlphaSize; i++)
 385.201 -      lens[i] = 0;
 385.202 -    if(!m_HuffmanDecoders[t].SetCodeLengths(lens))
 385.203 -      return S_FALSE;
 385.204 -  }
 385.205 -  while(++t < numTables);
 385.206 -
 385.207 -  {
 385.208 -    for (int i = 0; i < 256; i++)
 385.209 -      CharCounters[i] = 0;
 385.210 -  }
 385.211 -  
 385.212 -  UInt32 blockSize = 0;
 385.213 -  {
 385.214 -    UInt32 groupIndex = 0;
 385.215 -    UInt32 groupSize = 0;
 385.216 -    CHuffmanDecoder *huffmanDecoder = 0;
 385.217 -    int runPower = 0;
 385.218 -    UInt32 runCounter = 0;
 385.219 -    
 385.220 -    for (;;)
 385.221 -    {
 385.222 -      if (groupSize == 0)
 385.223 -      {
 385.224 -        if (groupIndex >= numSelectors)
 385.225 -          return S_FALSE;
 385.226 -        groupSize = kGroupSize;
 385.227 -        huffmanDecoder = &m_HuffmanDecoders[m_Selectors[groupIndex++]];
 385.228 -      }
 385.229 -      groupSize--;
 385.230 -        
 385.231 -      UInt32 nextSym = huffmanDecoder->DecodeSymbol(m_InStream);
 385.232 -      
 385.233 -      if (nextSym < 2)
 385.234 -      {
 385.235 -        runCounter += ((UInt32)(nextSym + 1) << runPower++);
 385.236 -        if (blockSizeMax - blockSize < runCounter)
 385.237 -          return S_FALSE;
 385.238 -        continue;
 385.239 -      }
 385.240 -      if (runCounter != 0)
 385.241 -      {
 385.242 -        UInt32 b = (UInt32)mtf.GetHead();
 385.243 -        CharCounters[b] += runCounter;
 385.244 -        do
 385.245 -          CharCounters[256 + blockSize++] = b;
 385.246 -        while(--runCounter != 0);
 385.247 -        runPower = 0;
 385.248 -      }
 385.249 -      if (nextSym <= (UInt32)numInUse)
 385.250 -      {
 385.251 -        UInt32 b = (UInt32)mtf.GetAndMove((int)nextSym - 1);
 385.252 -        if (blockSize >= blockSizeMax)
 385.253 -          return S_FALSE;
 385.254 -        CharCounters[b]++;
 385.255 -        CharCounters[256 + blockSize++] = b;
 385.256 -      }
 385.257 -      else if (nextSym == (UInt32)numInUse + 1)
 385.258 -        break;
 385.259 -      else
 385.260 -        return S_FALSE;
 385.261 -    }
 385.262 -  }
 385.263 -  *blockSizeRes = blockSize;
 385.264 -  return (*origPtrRes < blockSize) ? S_OK : S_FALSE;
 385.265 -}
 385.266 -
 385.267 -void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
 385.268 -{
 385.269 -  {
 385.270 -    UInt32 sum = 0;
 385.271 -    for (UInt32 i = 0; i < 256; i++)
 385.272 -    {
 385.273 -      sum += charCounters[i];
 385.274 -      charCounters[i] = sum - charCounters[i];
 385.275 -    }
 385.276 -  }
 385.277 -  
 385.278 -  UInt32 *tt = charCounters + 256;
 385.279 -  // Compute the T^(-1) vector
 385.280 -  UInt32 i = 0;
 385.281 -  do
 385.282 -    tt[charCounters[tt[i] & 0xFF]++] |= (i << 8);
 385.283 -  while(++i < blockSize);
 385.284 -}
 385.285 -
 385.286 -static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
 385.287 -{
 385.288 -  CBZip2Crc crc;
 385.289 -
 385.290 -  // it's for speed optimization: prefetch & prevByte_init;
 385.291 -  UInt32 tPos = tt[tt[OrigPtr] >> 8];
 385.292 -  unsigned int prevByte = (unsigned int)(tPos & 0xFF);
 385.293 -  
 385.294 -  int numReps = 0;
 385.295 -
 385.296 -  do
 385.297 -  {
 385.298 -    unsigned int b = (unsigned int)(tPos & 0xFF);
 385.299 -    tPos = tt[tPos >> 8];
 385.300 -    
 385.301 -    if (numReps == kRleModeRepSize)
 385.302 -    {
 385.303 -      for (; b > 0; b--)
 385.304 -      {
 385.305 -        crc.UpdateByte(prevByte);
 385.306 -        m_OutStream.WriteByte((Byte)prevByte);
 385.307 -      }
 385.308 -      numReps = 0;
 385.309 -      continue;
 385.310 -    }
 385.311 -    if (b != prevByte)
 385.312 -      numReps = 0;
 385.313 -    numReps++;
 385.314 -    prevByte = b;
 385.315 -    crc.UpdateByte(b);
 385.316 -    m_OutStream.WriteByte((Byte)b);
 385.317 -
 385.318 -    /*
 385.319 -    prevByte = b;
 385.320 -    crc.UpdateByte(b);
 385.321 -    m_OutStream.WriteByte((Byte)b);
 385.322 -    for (; --blockSize != 0;)
 385.323 -    {
 385.324 -      b = (unsigned int)(tPos & 0xFF);
 385.325 -      tPos = tt[tPos >> 8];
 385.326 -      crc.UpdateByte(b);
 385.327 -      m_OutStream.WriteByte((Byte)b);
 385.328 -      if (b != prevByte)
 385.329 -      {
 385.330 -        prevByte = b;
 385.331 -        continue;
 385.332 -      }
 385.333 -      if (--blockSize == 0)
 385.334 -        break;
 385.335 -      
 385.336 -      b = (unsigned int)(tPos & 0xFF);
 385.337 -      tPos = tt[tPos >> 8];
 385.338 -      crc.UpdateByte(b);
 385.339 -      m_OutStream.WriteByte((Byte)b);
 385.340 -      if (b != prevByte)
 385.341 -      {
 385.342 -        prevByte = b;
 385.343 -        continue;
 385.344 -      }
 385.345 -      if (--blockSize == 0)
 385.346 -        break;
 385.347 -      
 385.348 -      b = (unsigned int)(tPos & 0xFF);
 385.349 -      tPos = tt[tPos >> 8];
 385.350 -      crc.UpdateByte(b);
 385.351 -      m_OutStream.WriteByte((Byte)b);
 385.352 -      if (b != prevByte)
 385.353 -      {
 385.354 -        prevByte = b;
 385.355 -        continue;
 385.356 -      }
 385.357 -      --blockSize;
 385.358 -      break;
 385.359 -    }
 385.360 -    if (blockSize == 0)
 385.361 -      break;
 385.362 -
 385.363 -    b = (unsigned int)(tPos & 0xFF);
 385.364 -    tPos = tt[tPos >> 8];
 385.365 -    
 385.366 -    for (; b > 0; b--)
 385.367 -    {
 385.368 -      crc.UpdateByte(prevByte);
 385.369 -      m_OutStream.WriteByte((Byte)prevByte);
 385.370 -    }
 385.371 -    */
 385.372 -  }
 385.373 -  while(--blockSize != 0);
 385.374 -  return crc.GetDigest();
 385.375 -}
 385.376 -
 385.377 -static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
 385.378 -{
 385.379 -  CBZip2Crc crc;
 385.380 -  
 385.381 -  UInt32 randIndex = 1;
 385.382 -  UInt32 randToGo = kRandNums[0] - 2;
 385.383 -  
 385.384 -  int numReps = 0;
 385.385 -
 385.386 -  // it's for speed optimization: prefetch & prevByte_init;
 385.387 -  UInt32 tPos = tt[tt[OrigPtr] >> 8];
 385.388 -  unsigned int prevByte = (unsigned int)(tPos & 0xFF);
 385.389 -  
 385.390 -  do
 385.391 -  {
 385.392 -    unsigned int b = (unsigned int)(tPos & 0xFF);
 385.393 -    tPos = tt[tPos >> 8];
 385.394 -    
 385.395 -    {
 385.396 -      if (randToGo == 0)
 385.397 -      {
 385.398 -        b ^= 1;
 385.399 -        randToGo = kRandNums[randIndex++];
 385.400 -        randIndex &= 0x1FF;
 385.401 -      }
 385.402 -      randToGo--;
 385.403 -    }
 385.404 -    
 385.405 -    if (numReps == kRleModeRepSize)
 385.406 -    {
 385.407 -      for (; b > 0; b--)
 385.408 -      {
 385.409 -        crc.UpdateByte(prevByte);
 385.410 -        m_OutStream.WriteByte((Byte)prevByte);
 385.411 -      }
 385.412 -      numReps = 0;
 385.413 -      continue;
 385.414 -    }
 385.415 -    if (b != prevByte)
 385.416 -      numReps = 0;
 385.417 -    numReps++;
 385.418 -    prevByte = b;
 385.419 -    crc.UpdateByte(b);
 385.420 -    m_OutStream.WriteByte((Byte)b);
 385.421 -  }
 385.422 -  while(--blockSize != 0);
 385.423 -  return crc.GetDigest();
 385.424 -}
 385.425 -
 385.426 -#ifdef COMPRESS_BZIP2_MT
 385.427 -
 385.428 -CDecoder::CDecoder():
 385.429 -  m_States(0)
 385.430 -{
 385.431 -  m_NumThreadsPrev = 0;
 385.432 -  NumThreads = 1;
 385.433 -}
 385.434 -
 385.435 -CDecoder::~CDecoder()
 385.436 -{
 385.437 -  Free();
 385.438 -}
 385.439 -
 385.440 -#define RINOK_THREAD(x) { WRes __result_ = (x); if(__result_ != 0) return __result_; }
 385.441 -
 385.442 -HRESULT CDecoder::Create()
 385.443 -{
 385.444 -  RINOK_THREAD(CanProcessEvent.CreateIfNotCreated());
 385.445 -  RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated());
 385.446 -  if (m_States != 0 && m_NumThreadsPrev == NumThreads)
 385.447 -    return S_OK;
 385.448 -  Free();
 385.449 -  MtMode = (NumThreads > 1);
 385.450 -  m_NumThreadsPrev = NumThreads;
 385.451 -  try
 385.452 -  {
 385.453 -    m_States = new CState[NumThreads];
 385.454 -    if (m_States == 0)
 385.455 -      return E_OUTOFMEMORY;
 385.456 -  }
 385.457 -  catch(...) { return E_OUTOFMEMORY; }
 385.458 -  for (UInt32 t = 0; t < NumThreads; t++)
 385.459 -  {
 385.460 -    CState &ti = m_States[t];
 385.461 -    ti.Decoder = this;
 385.462 -    if (MtMode)
 385.463 -    {
 385.464 -      HRESULT res = ti.Create();
 385.465 -      if (res != S_OK)
 385.466 -      {
 385.467 -        NumThreads = t;
 385.468 -        Free();
 385.469 -        return res;
 385.470 -      }
 385.471 -    }
 385.472 -  }
 385.473 -  return S_OK;
 385.474 -}
 385.475 -
 385.476 -void CDecoder::Free()
 385.477 -{
 385.478 -  if (!m_States)
 385.479 -    return;
 385.480 -  CloseThreads = true;
 385.481 -  CanProcessEvent.Set();
 385.482 -  for (UInt32 t = 0; t < NumThreads; t++)
 385.483 -  {
 385.484 -    CState &s = m_States[t];
 385.485 -    if (MtMode)
 385.486 -      s.Thread.Wait();
 385.487 -    s.Free();
 385.488 -  }
 385.489 -  delete []m_States;
 385.490 -  m_States = 0;
 385.491 -}
 385.492 -#endif
 385.493 -
 385.494 -HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
 385.495 -{
 385.496 -  wasFinished = false;
 385.497 -  Byte s[6];
 385.498 -  for (int i = 0; i < 6; i++)
 385.499 -    s[i] = ReadByte();
 385.500 -  crc = ReadCrc();
 385.501 -  if (s[0] == kFinSig0)
 385.502 -  {
 385.503 -    if (s[1] != kFinSig1 ||
 385.504 -        s[2] != kFinSig2 ||
 385.505 -        s[3] != kFinSig3 ||
 385.506 -        s[4] != kFinSig4 ||
 385.507 -        s[5] != kFinSig5)
 385.508 -      return S_FALSE;
 385.509 -    
 385.510 -    wasFinished = true;
 385.511 -    return (crc == CombinedCrc.GetDigest()) ? S_OK : S_FALSE;
 385.512 -  }
 385.513 -  if (s[0] != kBlockSig0 ||
 385.514 -      s[1] != kBlockSig1 ||
 385.515 -      s[2] != kBlockSig2 ||
 385.516 -      s[3] != kBlockSig3 ||
 385.517 -      s[4] != kBlockSig4 ||
 385.518 -      s[5] != kBlockSig5)
 385.519 -    return S_FALSE;
 385.520 -  CombinedCrc.Update(crc);
 385.521 -  return S_OK;
 385.522 -}
 385.523 -
 385.524 -HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
 385.525 -{
 385.526 -  #ifdef COMPRESS_BZIP2_MT
 385.527 -  Progress = progress;
 385.528 -  RINOK(Create());
 385.529 -  for (UInt32 t = 0; t < NumThreads; t++)
 385.530 -  {
 385.531 -    CState &s = m_States[t];
 385.532 -    if (!s.Alloc())
 385.533 -      return E_OUTOFMEMORY;
 385.534 -    if (MtMode)
 385.535 -    {
 385.536 -      RINOK(s.StreamWasFinishedEvent.Reset());
 385.537 -      RINOK(s.WaitingWasStartedEvent.Reset());
 385.538 -      RINOK(s.CanWriteEvent.Reset());
 385.539 -    }
 385.540 -  }
 385.541 -  #else
 385.542 -  if (!m_States[0].Alloc())
 385.543 -    return E_OUTOFMEMORY;
 385.544 -  #endif
 385.545 -
 385.546 -  isBZ = false;
 385.547 -  Byte s[6];
 385.548 -  int i;
 385.549 -  for (i = 0; i < 4; i++)
 385.550 -    s[i] = ReadByte();
 385.551 -  if (s[0] != kArSig0 ||
 385.552 -      s[1] != kArSig1 ||
 385.553 -      s[2] != kArSig2 ||
 385.554 -      s[3] <= kArSig3 ||
 385.555 -      s[3] > kArSig3 + kBlockSizeMultMax)
 385.556 -    return S_OK;
 385.557 -  isBZ = true;
 385.558 -  UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
 385.559 -
 385.560 -  CombinedCrc.Init();
 385.561 -  #ifdef COMPRESS_BZIP2_MT
 385.562 -  if (MtMode)
 385.563 -  {
 385.564 -    NextBlockIndex = 0;
 385.565 -    StreamWasFinished1 = StreamWasFinished2 = false;
 385.566 -    CloseThreads = false;
 385.567 -    CanStartWaitingEvent.Reset();
 385.568 -    m_States[0].CanWriteEvent.Set();
 385.569 -    BlockSizeMax = dicSize;
 385.570 -    Result1 = Result2 = S_OK;
 385.571 -    CanProcessEvent.Set();
 385.572 -    UInt32 t;
 385.573 -    for (t = 0; t < NumThreads; t++)
 385.574 -      m_States[t].StreamWasFinishedEvent.Lock();
 385.575 -    CanProcessEvent.Reset();
 385.576 -    CanStartWaitingEvent.Set();
 385.577 -    for (t = 0; t < NumThreads; t++)
 385.578 -      m_States[t].WaitingWasStartedEvent.Lock();
 385.579 -    CanStartWaitingEvent.Reset();
 385.580 -    RINOK(Result2);
 385.581 -    RINOK(Result1);
 385.582 -  }
 385.583 -  else
 385.584 -  #endif
 385.585 -  {
 385.586 -    CState &state = m_States[0];
 385.587 -    for (;;)
 385.588 -    {
 385.589 -      if (progress)
 385.590 -      {
 385.591 -        UInt64 packSize = m_InStream.GetProcessedSize();
 385.592 -        UInt64 unpackSize = m_OutStream.GetProcessedSize();
 385.593 -        RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
 385.594 -      }
 385.595 -      bool wasFinished;
 385.596 -      UInt32 crc;
 385.597 -      RINOK(ReadSignatures(wasFinished, crc));
 385.598 -      if (wasFinished)
 385.599 -        return S_OK;
 385.600 -
 385.601 -      UInt32 blockSize, origPtr;
 385.602 -      bool randMode;
 385.603 -      RINOK(ReadBlock(&m_InStream, state.Counters, dicSize,
 385.604 -        m_Selectors, m_HuffmanDecoders,
 385.605 -        &blockSize, &origPtr, &randMode));
 385.606 -      DecodeBlock1(state.Counters, blockSize);
 385.607 -      if ((randMode ?
 385.608 -          DecodeBlock2Rand(state.Counters + 256, blockSize, origPtr, m_OutStream) :
 385.609 -          DecodeBlock2(state.Counters + 256, blockSize, origPtr, m_OutStream)) != crc)
 385.610 -        return S_FALSE;
 385.611 -    }
 385.612 -  }
 385.613 -  return S_OK;
 385.614 -}
 385.615 -
 385.616 -HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 385.617 -    const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
 385.618 -{
 385.619 -  if (!m_InStream.Create(kBufferSize))
 385.620 -    return E_OUTOFMEMORY;
 385.621 -  if (!m_OutStream.Create(kBufferSize))
 385.622 -    return E_OUTOFMEMORY;
 385.623 -
 385.624 -  m_InStream.SetStream(inStream);
 385.625 -  m_InStream.Init();
 385.626 -
 385.627 -  m_OutStream.SetStream(outStream);
 385.628 -  m_OutStream.Init();
 385.629 -
 385.630 -  CDecoderFlusher flusher(this);
 385.631 -
 385.632 -  bool isBZ;
 385.633 -  RINOK(DecodeFile(isBZ, progress));
 385.634 -  return isBZ ? S_OK: S_FALSE;
 385.635 -}
 385.636 -
 385.637 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 385.638 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 385.639 -{
 385.640 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
 385.641 -  catch(const CInBufferException &e)  { return e.ErrorCode; }
 385.642 -  catch(const COutBufferException &e) { return e.ErrorCode; }
 385.643 -  catch(...) { return E_FAIL; }
 385.644 -}
 385.645 -
 385.646 -STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
 385.647 -{
 385.648 -  if (value == NULL)
 385.649 -    return E_INVALIDARG;
 385.650 -  *value = m_InStream.GetProcessedSize();
 385.651 -  return S_OK;
 385.652 -}
 385.653 -
 385.654 -#ifdef COMPRESS_BZIP2_MT
 385.655 -
 385.656 -static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
 385.657 -
 385.658 -HRESULT CState::Create()
 385.659 -{
 385.660 -  RINOK_THREAD(StreamWasFinishedEvent.CreateIfNotCreated());
 385.661 -  RINOK_THREAD(WaitingWasStartedEvent.CreateIfNotCreated());
 385.662 -  RINOK_THREAD(CanWriteEvent.CreateIfNotCreated());
 385.663 -  RINOK_THREAD(Thread.Create(MFThread, this));
 385.664 -  return S_OK;
 385.665 -}
 385.666 -
 385.667 -void CState::FinishStream()
 385.668 -{
 385.669 -  Decoder->StreamWasFinished1 = true;
 385.670 -  StreamWasFinishedEvent.Set();
 385.671 -  Decoder->CS.Leave();
 385.672 -  Decoder->CanStartWaitingEvent.Lock();
 385.673 -  WaitingWasStartedEvent.Set();
 385.674 -}
 385.675 -
 385.676 -void CState::ThreadFunc()
 385.677 -{
 385.678 -  for (;;)
 385.679 -  {
 385.680 -    Decoder->CanProcessEvent.Lock();
 385.681 -    Decoder->CS.Enter();
 385.682 -    if (Decoder->CloseThreads)
 385.683 -    {
 385.684 -      Decoder->CS.Leave();
 385.685 -      return;
 385.686 -    }
 385.687 -    if (Decoder->StreamWasFinished1)
 385.688 -    {
 385.689 -      FinishStream();
 385.690 -      continue;
 385.691 -    }
 385.692 -    HRESULT res = S_OK;
 385.693 -
 385.694 -    UInt32 blockIndex = Decoder->NextBlockIndex;
 385.695 -    UInt32 nextBlockIndex = blockIndex + 1;
 385.696 -    if (nextBlockIndex == Decoder->NumThreads)
 385.697 -      nextBlockIndex = 0;
 385.698 -    Decoder->NextBlockIndex = nextBlockIndex;
 385.699 -    UInt32 crc;
 385.700 -    UInt64 packSize;
 385.701 -    UInt32 blockSize = 0, origPtr = 0;
 385.702 -    bool randMode = false;
 385.703 -
 385.704 -    try
 385.705 -    {
 385.706 -      bool wasFinished;
 385.707 -      res = Decoder->ReadSignatures(wasFinished, crc);
 385.708 -      if (res != S_OK)
 385.709 -      {
 385.710 -        Decoder->Result1 = res;
 385.711 -        FinishStream();
 385.712 -        continue;
 385.713 -      }
 385.714 -      if (wasFinished)
 385.715 -      {
 385.716 -        Decoder->Result1 = res;
 385.717 -        FinishStream();
 385.718 -        continue;
 385.719 -      }
 385.720 -
 385.721 -      res = ReadBlock(&Decoder->m_InStream, Counters, Decoder->BlockSizeMax,
 385.722 -          Decoder->m_Selectors, Decoder->m_HuffmanDecoders,
 385.723 -          &blockSize, &origPtr, &randMode);
 385.724 -      if (res != S_OK)
 385.725 -      {
 385.726 -        Decoder->Result1 = res;
 385.727 -        FinishStream();
 385.728 -        continue;
 385.729 -      }
 385.730 -      packSize = Decoder->m_InStream.GetProcessedSize();
 385.731 -    }
 385.732 -    catch(const CInBufferException &e) { res = e.ErrorCode;  if (res != S_OK) res = E_FAIL; }
 385.733 -    catch(...) { res = E_FAIL; }
 385.734 -    if (res != S_OK)
 385.735 -    {
 385.736 -      Decoder->Result1 = res;
 385.737 -      FinishStream();
 385.738 -      continue;
 385.739 -    }
 385.740 -
 385.741 -    Decoder->CS.Leave();
 385.742 -
 385.743 -    DecodeBlock1(Counters, blockSize);
 385.744 -
 385.745 -    bool needFinish = true;
 385.746 -    try
 385.747 -    {
 385.748 -      Decoder->m_States[blockIndex].CanWriteEvent.Lock();
 385.749 -      needFinish = Decoder->StreamWasFinished2;
 385.750 -      if (!needFinish)
 385.751 -      {
 385.752 -        if ((randMode ?
 385.753 -          DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) :
 385.754 -          DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc)
 385.755 -        {
 385.756 -          if (Decoder->Progress)
 385.757 -          {
 385.758 -            UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize();
 385.759 -            res = Decoder->Progress->SetRatioInfo(&packSize, &unpackSize);
 385.760 -          }
 385.761 -        }
 385.762 -        else
 385.763 -          res = S_FALSE;
 385.764 -      }
 385.765 -    }
 385.766 -    catch(const COutBufferException &e) { res = e.ErrorCode; if (res != S_OK) res = E_FAIL; }
 385.767 -    catch(...) { res = E_FAIL; }
 385.768 -    if (res != S_OK)
 385.769 -    {
 385.770 -      Decoder->Result2 = res;
 385.771 -      Decoder->StreamWasFinished2 = true;
 385.772 -    }
 385.773 -    Decoder->m_States[nextBlockIndex].CanWriteEvent.Set();
 385.774 -    if (res != S_OK || needFinish)
 385.775 -    {
 385.776 -      StreamWasFinishedEvent.Set();
 385.777 -      Decoder->CanStartWaitingEvent.Lock();
 385.778 -      WaitingWasStartedEvent.Set();
 385.779 -    }
 385.780 -  }
 385.781 -}
 385.782 -
 385.783 -STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
 385.784 -{
 385.785 -  NumThreads = numThreads;
 385.786 -  if (NumThreads < 1)
 385.787 -    NumThreads = 1;
 385.788 -  if (NumThreads > kNumThreadsMax)
 385.789 -    NumThreads = kNumThreadsMax;
 385.790 -  return S_OK;
 385.791 -}
 385.792 -#endif
 385.793 -
 385.794 -}}
   386.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Decoder.h	Sat Mar 03 10:54:39 2012 -0600
   386.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   386.3 @@ -1,159 +0,0 @@
   386.4 -// Compress/BZip2Decoder.h
   386.5 -
   386.6 -#ifndef __COMPRESS_BZIP2_DECODER_H
   386.7 -#define __COMPRESS_BZIP2_DECODER_H
   386.8 -
   386.9 -#include "../../Common/MyCom.h"
  386.10 -
  386.11 -#ifdef COMPRESS_BZIP2_MT
  386.12 -#include "../../Windows/Synchronization.h"
  386.13 -#include "../../Windows/Thread.h"
  386.14 -#endif
  386.15 -
  386.16 -#include "../ICoder.h"
  386.17 -
  386.18 -#include "../Common/InBuffer.h"
  386.19 -#include "../Common/OutBuffer.h"
  386.20 -
  386.21 -#include "BitmDecoder.h"
  386.22 -#include "BZip2Const.h"
  386.23 -#include "BZip2Crc.h"
  386.24 -#include "HuffmanDecoder.h"
  386.25 -
  386.26 -namespace NCompress {
  386.27 -namespace NBZip2 {
  386.28 -
  386.29 -typedef NCompress::NHuffman::CDecoder<kMaxHuffmanLen, kMaxAlphaSize> CHuffmanDecoder;
  386.30 -
  386.31 -class CDecoder;
  386.32 -
  386.33 -struct CState
  386.34 -{
  386.35 -  UInt32 *Counters;
  386.36 -
  386.37 -  #ifdef COMPRESS_BZIP2_MT
  386.38 -
  386.39 -  CDecoder *Decoder;
  386.40 -  NWindows::CThread Thread;
  386.41 -  bool m_OptimizeNumTables;
  386.42 -
  386.43 -  NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
  386.44 -  NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
  386.45 -
  386.46 -  // it's not member of this thread. We just need one event per thread
  386.47 -  NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
  386.48 -
  386.49 -  Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
  386.50 -
  386.51 -  HRESULT Create();
  386.52 -  void FinishStream();
  386.53 -  void ThreadFunc();
  386.54 -
  386.55 -  #endif
  386.56 -
  386.57 -  CState(): Counters(0) {}
  386.58 -  ~CState() { Free(); }
  386.59 -  bool Alloc();
  386.60 -  void Free();
  386.61 -};
  386.62 -
  386.63 -class CDecoder :
  386.64 -  public ICompressCoder,
  386.65 -  #ifdef COMPRESS_BZIP2_MT
  386.66 -  public ICompressSetCoderMt,
  386.67 -  #endif
  386.68 -  public ICompressGetInStreamProcessedSize,
  386.69 -  public CMyUnknownImp
  386.70 -{
  386.71 -public:
  386.72 -  COutBuffer m_OutStream;
  386.73 -  Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
  386.74 -  NBitm::CDecoder<CInBuffer> m_InStream;
  386.75 -  Byte m_Selectors[kNumSelectorsMax];
  386.76 -  CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
  386.77 -private:
  386.78 -
  386.79 -  UInt32 m_NumThreadsPrev;
  386.80 -
  386.81 -  UInt32 ReadBits(int numBits);
  386.82 -  Byte ReadByte();
  386.83 -  bool ReadBit();
  386.84 -  UInt32 ReadCrc();
  386.85 -  HRESULT PrepareBlock(CState &state);
  386.86 -  HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
  386.87 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  386.88 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  386.89 -  class CDecoderFlusher
  386.90 -  {
  386.91 -    CDecoder *_decoder;
  386.92 -  public:
  386.93 -    bool NeedFlush;
  386.94 -    CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
  386.95 -    ~CDecoderFlusher()
  386.96 -    {
  386.97 -      if (NeedFlush)
  386.98 -        _decoder->Flush();
  386.99 -      _decoder->ReleaseStreams();
 386.100 -    }
 386.101 -  };
 386.102 -
 386.103 -public:
 386.104 -  CBZip2CombinedCrc CombinedCrc;
 386.105 -
 386.106 -  #ifdef COMPRESS_BZIP2_MT
 386.107 -  ICompressProgressInfo *Progress;
 386.108 -  CState *m_States;
 386.109 -
 386.110 -  NWindows::NSynchronization::CManualResetEvent CanProcessEvent;
 386.111 -  NWindows::NSynchronization::CCriticalSection CS;
 386.112 -  UInt32 NumThreads;
 386.113 -  bool MtMode;
 386.114 -  UInt32 NextBlockIndex;
 386.115 -  bool CloseThreads;
 386.116 -  bool StreamWasFinished1;
 386.117 -  bool StreamWasFinished2;
 386.118 -  NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
 386.119 -
 386.120 -  HRESULT Result1;
 386.121 -  HRESULT Result2;
 386.122 -
 386.123 -  UInt32 BlockSizeMax;
 386.124 -  CDecoder();
 386.125 -  ~CDecoder();
 386.126 -  HRESULT Create();
 386.127 -  void Free();
 386.128 -
 386.129 -  #else
 386.130 -  CState m_States[1];
 386.131 -  #endif
 386.132 -
 386.133 -  HRESULT ReadSignatures(bool &wasFinished, UInt32 &crc);
 386.134 -
 386.135 -
 386.136 -  HRESULT Flush() { return m_OutStream.Flush(); }
 386.137 -  void ReleaseStreams()
 386.138 -  {
 386.139 -    m_InStream.ReleaseStream();
 386.140 -    m_OutStream.ReleaseStream();
 386.141 -  }
 386.142 -
 386.143 -  #ifdef COMPRESS_BZIP2_MT
 386.144 -  MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressGetInStreamProcessedSize)
 386.145 -  #else
 386.146 -  MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
 386.147 -  #endif
 386.148 -
 386.149 -  
 386.150 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 386.151 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 386.152 -
 386.153 -  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
 386.154 -
 386.155 -  #ifdef COMPRESS_BZIP2_MT
 386.156 -  STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
 386.157 -  #endif
 386.158 -};
 386.159 -
 386.160 -}}
 386.161 -
 386.162 -#endif
   387.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Register.cpp	Sat Mar 03 10:54:39 2012 -0600
   387.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   387.3 @@ -1,20 +0,0 @@
   387.4 -// BZip2Register.cpp
   387.5 -
   387.6 -#include "StdAfx.h"
   387.7 -
   387.8 -#include "../Common/RegisterCodec.h"
   387.9 -
  387.10 -#include "BZip2Decoder.h"
  387.11 -
  387.12 -static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NBZip2::CDecoder); }
  387.13 -#if !defined(EXTRACT_ONLY) && !defined(BZIP2_EXTRACT_ONLY)
  387.14 -#include "BZip2Encoder.h"
  387.15 -static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NBZip2::CEncoder);  }
  387.16 -#else
  387.17 -#define CreateCodecOut 0
  387.18 -#endif
  387.19 -
  387.20 -static CCodecInfo g_CodecInfo =
  387.21 -  { CreateCodec, CreateCodecOut, 0x040202, L"BZip2", 1, false };
  387.22 -
  387.23 -REGISTER_CODEC(BZip2)
   388.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.cpp	Sat Mar 03 10:54:39 2012 -0600
   388.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   388.3 @@ -1,393 +0,0 @@
   388.4 -// Bcj2Coder.cpp
   388.5 -
   388.6 -#include "StdAfx.h"
   388.7 -
   388.8 -extern "C"
   388.9 -{
  388.10 -#include "../../../C/Alloc.h"
  388.11 -}
  388.12 -
  388.13 -#include "Bcj2Coder.h"
  388.14 -
  388.15 -namespace NCompress {
  388.16 -namespace NBcj2 {
  388.17 -
  388.18 -inline bool IsJcc(Byte b0, Byte b1) { return (b0 == 0x0F && (b1 & 0xF0) == 0x80); }
  388.19 -inline bool IsJ(Byte b0, Byte b1) { return ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)); }
  388.20 -inline unsigned GetIndex(Byte b0, Byte b1) { return ((b1 == 0xE8) ? b0 : ((b1 == 0xE9) ? 256 : 257)); }
  388.21 -
  388.22 -#ifndef EXTRACT_ONLY
  388.23 -
  388.24 -static const int kBufferSize = 1 << 17;
  388.25 -
  388.26 -static bool inline Test86MSByte(Byte b)
  388.27 -{
  388.28 -  return (b == 0 || b == 0xFF);
  388.29 -}
  388.30 -
  388.31 -bool CEncoder::Create()
  388.32 -{
  388.33 -  if (!_mainStream.Create(1 << 16))
  388.34 -    return false;
  388.35 -  if (!_callStream.Create(1 << 20))
  388.36 -    return false;
  388.37 -  if (!_jumpStream.Create(1 << 20))
  388.38 -    return false;
  388.39 -  if (!_rangeEncoder.Create(1 << 20))
  388.40 -    return false;
  388.41 -  if (_buffer == 0)
  388.42 -  {
  388.43 -    _buffer = (Byte *)MidAlloc(kBufferSize);
  388.44 -    if (_buffer == 0)
  388.45 -      return false;
  388.46 -  }
  388.47 -  return true;
  388.48 -}
  388.49 -
  388.50 -CEncoder::~CEncoder()
  388.51 -{
  388.52 -  ::MidFree(_buffer);
  388.53 -}
  388.54 -
  388.55 -HRESULT CEncoder::Flush()
  388.56 -{
  388.57 -  RINOK(_mainStream.Flush());
  388.58 -  RINOK(_callStream.Flush());
  388.59 -  RINOK(_jumpStream.Flush());
  388.60 -  _rangeEncoder.FlushData();
  388.61 -  return _rangeEncoder.FlushStream();
  388.62 -}
  388.63 -
  388.64 -const UInt32 kDefaultLimit = (1 << 24);
  388.65 -
  388.66 -HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
  388.67 -      const UInt64 **inSizes,
  388.68 -      UInt32 numInStreams,
  388.69 -      ISequentialOutStream **outStreams,
  388.70 -      const UInt64 ** /* outSizes */,
  388.71 -      UInt32 numOutStreams,
  388.72 -      ICompressProgressInfo *progress)
  388.73 -{
  388.74 -  if (numInStreams != 1 || numOutStreams != 4)
  388.75 -    return E_INVALIDARG;
  388.76 -
  388.77 -  if (!Create())
  388.78 -    return E_OUTOFMEMORY;
  388.79 -
  388.80 -  bool sizeIsDefined = false;
  388.81 -  UInt64 inSize = 0;
  388.82 -  if (inSizes != NULL)
  388.83 -    if (inSizes[0] != NULL)
  388.84 -    {
  388.85 -      inSize = *inSizes[0];
  388.86 -      if (inSize <= kDefaultLimit)
  388.87 -        sizeIsDefined = true;
  388.88 -    }
  388.89 -
  388.90 -  ISequentialInStream *inStream = inStreams[0];
  388.91 -
  388.92 -  _mainStream.SetStream(outStreams[0]);
  388.93 -  _mainStream.Init();
  388.94 -  _callStream.SetStream(outStreams[1]);
  388.95 -  _callStream.Init();
  388.96 -  _jumpStream.SetStream(outStreams[2]);
  388.97 -  _jumpStream.Init();
  388.98 -  _rangeEncoder.SetStream(outStreams[3]);
  388.99 -  _rangeEncoder.Init();
 388.100 -  for (int i = 0; i < 256 + 2; i++)
 388.101 -    _statusEncoder[i].Init();
 388.102 -  CCoderReleaser releaser(this);
 388.103 -
 388.104 -  CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
 388.105 -  {
 388.106 -    inStream->QueryInterface(IID_ICompressGetSubStreamSize, (void **)&getSubStreamSize);
 388.107 -  }
 388.108 -
 388.109 -  UInt32 nowPos = 0;
 388.110 -  UInt64 nowPos64 = 0;
 388.111 -  UInt32 bufferPos = 0;
 388.112 -
 388.113 -  Byte prevByte = 0;
 388.114 -
 388.115 -  UInt64 subStreamIndex = 0;
 388.116 -  UInt64 subStreamStartPos  = 0;
 388.117 -  UInt64 subStreamEndPos = 0;
 388.118 -
 388.119 -  for (;;)
 388.120 -  {
 388.121 -    UInt32 processedSize = 0;
 388.122 -    for (;;)
 388.123 -    {
 388.124 -      UInt32 size = kBufferSize - (bufferPos + processedSize);
 388.125 -      UInt32 processedSizeLoc;
 388.126 -      if (size == 0)
 388.127 -        break;
 388.128 -      RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
 388.129 -      if (processedSizeLoc == 0)
 388.130 -        break;
 388.131 -      processedSize += processedSizeLoc;
 388.132 -    }
 388.133 -    UInt32 endPos = bufferPos + processedSize;
 388.134 -    
 388.135 -    if (endPos < 5)
 388.136 -    {
 388.137 -      // change it
 388.138 -      for (bufferPos = 0; bufferPos < endPos; bufferPos++)
 388.139 -      {
 388.140 -        Byte b = _buffer[bufferPos];
 388.141 -        _mainStream.WriteByte(b);
 388.142 -        UInt32 index;
 388.143 -        if (b == 0xE8)
 388.144 -          index = prevByte;
 388.145 -        else if (b == 0xE9)
 388.146 -          index = 256;
 388.147 -        else if (IsJcc(prevByte, b))
 388.148 -          index = 257;
 388.149 -        else
 388.150 -        {
 388.151 -          prevByte = b;
 388.152 -          continue;
 388.153 -        }
 388.154 -        _statusEncoder[index].Encode(&_rangeEncoder, 0);
 388.155 -        prevByte = b;
 388.156 -      }
 388.157 -      return Flush();
 388.158 -    }
 388.159 -
 388.160 -    bufferPos = 0;
 388.161 -
 388.162 -    UInt32 limit = endPos - 5;
 388.163 -    while(bufferPos <= limit)
 388.164 -    {
 388.165 -      Byte b = _buffer[bufferPos];
 388.166 -      _mainStream.WriteByte(b);
 388.167 -      if (!IsJ(prevByte, b))
 388.168 -      {
 388.169 -        bufferPos++;
 388.170 -        prevByte = b;
 388.171 -        continue;
 388.172 -      }
 388.173 -      Byte nextByte = _buffer[bufferPos + 4];
 388.174 -      UInt32 src =
 388.175 -        (UInt32(nextByte) << 24) |
 388.176 -        (UInt32(_buffer[bufferPos + 3]) << 16) |
 388.177 -        (UInt32(_buffer[bufferPos + 2]) << 8) |
 388.178 -        (_buffer[bufferPos + 1]);
 388.179 -      UInt32 dest = (nowPos + bufferPos + 5) + src;
 388.180 -      // if (Test86MSByte(nextByte))
 388.181 -      bool convert;
 388.182 -      if (getSubStreamSize != NULL)
 388.183 -      {
 388.184 -        UInt64 currentPos = (nowPos64 + bufferPos);
 388.185 -        while (subStreamEndPos < currentPos)
 388.186 -        {
 388.187 -          UInt64 subStreamSize;
 388.188 -          HRESULT result = getSubStreamSize->GetSubStreamSize(subStreamIndex, &subStreamSize);
 388.189 -          if (result == S_OK)
 388.190 -          {
 388.191 -            subStreamStartPos = subStreamEndPos;
 388.192 -            subStreamEndPos += subStreamSize;
 388.193 -            subStreamIndex++;
 388.194 -          }
 388.195 -          else if (result == S_FALSE || result == E_NOTIMPL)
 388.196 -          {
 388.197 -            getSubStreamSize.Release();
 388.198 -            subStreamStartPos = 0;
 388.199 -            subStreamEndPos = subStreamStartPos - 1;
 388.200 -          }
 388.201 -          else
 388.202 -            return result;
 388.203 -        }
 388.204 -        if (getSubStreamSize == NULL)
 388.205 -        {
 388.206 -          if (sizeIsDefined)
 388.207 -            convert = (dest < inSize);
 388.208 -          else
 388.209 -            convert = Test86MSByte(nextByte);
 388.210 -        }
 388.211 -        else if (subStreamEndPos - subStreamStartPos > kDefaultLimit)
 388.212 -          convert = Test86MSByte(nextByte);
 388.213 -        else
 388.214 -        {
 388.215 -          UInt64 dest64 = (currentPos + 5) + Int64(Int32(src));
 388.216 -          convert = (dest64 >= subStreamStartPos && dest64 < subStreamEndPos);
 388.217 -        }
 388.218 -      }
 388.219 -      else if (sizeIsDefined)
 388.220 -        convert = (dest < inSize);
 388.221 -      else
 388.222 -        convert = Test86MSByte(nextByte);
 388.223 -      unsigned index = GetIndex(prevByte, b);
 388.224 -      if (convert)
 388.225 -      {
 388.226 -        _statusEncoder[index].Encode(&_rangeEncoder, 1);
 388.227 -        bufferPos += 5;
 388.228 -        COutBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
 388.229 -        for (int i = 24; i >= 0; i -= 8)
 388.230 -          s.WriteByte((Byte)(dest >> i));
 388.231 -        prevByte = nextByte;
 388.232 -      }
 388.233 -      else
 388.234 -      {
 388.235 -        _statusEncoder[index].Encode(&_rangeEncoder, 0);
 388.236 -        bufferPos++;
 388.237 -        prevByte = b;
 388.238 -      }
 388.239 -    }
 388.240 -    nowPos += bufferPos;
 388.241 -    nowPos64 += bufferPos;
 388.242 -
 388.243 -    if (progress != NULL)
 388.244 -    {
 388.245 -      /*
 388.246 -      const UInt64 compressedSize =
 388.247 -        _mainStream.GetProcessedSize() +
 388.248 -        _callStream.GetProcessedSize() +
 388.249 -        _jumpStream.GetProcessedSize() +
 388.250 -        _rangeEncoder.GetProcessedSize();
 388.251 -      */
 388.252 -      RINOK(progress->SetRatioInfo(&nowPos64, NULL));
 388.253 -    }
 388.254 - 
 388.255 -    UInt32 i = 0;
 388.256 -    while(bufferPos < endPos)
 388.257 -      _buffer[i++] = _buffer[bufferPos++];
 388.258 -    bufferPos = i;
 388.259 -  }
 388.260 -}
 388.261 -
 388.262 -STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams,
 388.263 -      const UInt64 **inSizes,
 388.264 -      UInt32 numInStreams,
 388.265 -      ISequentialOutStream **outStreams,
 388.266 -      const UInt64 **outSizes,
 388.267 -      UInt32 numOutStreams,
 388.268 -      ICompressProgressInfo *progress)
 388.269 -{
 388.270 -  try
 388.271 -  {
 388.272 -    return CodeReal(inStreams, inSizes, numInStreams,
 388.273 -      outStreams, outSizes,numOutStreams, progress);
 388.274 -  }
 388.275 -  catch(const COutBufferException &e) { return e.ErrorCode; }
 388.276 -  catch(...) { return S_FALSE; }
 388.277 -}
 388.278 -
 388.279 -#endif
 388.280 -
 388.281 -HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
 388.282 -      const UInt64 ** /* inSizes */,
 388.283 -      UInt32 numInStreams,
 388.284 -      ISequentialOutStream **outStreams,
 388.285 -      const UInt64 ** /* outSizes */,
 388.286 -      UInt32 numOutStreams,
 388.287 -      ICompressProgressInfo *progress)
 388.288 -{
 388.289 -  if (numInStreams != 4 || numOutStreams != 1)
 388.290 -    return E_INVALIDARG;
 388.291 -
 388.292 -  if (!_mainInStream.Create(1 << 16))
 388.293 -    return E_OUTOFMEMORY;
 388.294 -  if (!_callStream.Create(1 << 20))
 388.295 -    return E_OUTOFMEMORY;
 388.296 -  if (!_jumpStream.Create(1 << 16))
 388.297 -    return E_OUTOFMEMORY;
 388.298 -  if (!_rangeDecoder.Create(1 << 20))
 388.299 -    return E_OUTOFMEMORY;
 388.300 -  if (!_outStream.Create(1 << 16))
 388.301 -    return E_OUTOFMEMORY;
 388.302 -
 388.303 -  _mainInStream.SetStream(inStreams[0]);
 388.304 -  _callStream.SetStream(inStreams[1]);
 388.305 -  _jumpStream.SetStream(inStreams[2]);
 388.306 -  _rangeDecoder.SetStream(inStreams[3]);
 388.307 -  _outStream.SetStream(outStreams[0]);
 388.308 -
 388.309 -  _mainInStream.Init();
 388.310 -  _callStream.Init();
 388.311 -  _jumpStream.Init();
 388.312 -  _rangeDecoder.Init();
 388.313 -  _outStream.Init();
 388.314 -
 388.315 -  for (int i = 0; i < 256 + 2; i++)
 388.316 -    _statusDecoder[i].Init();
 388.317 -
 388.318 -  CCoderReleaser releaser(this);
 388.319 -
 388.320 -  Byte prevByte = 0;
 388.321 -  UInt32 processedBytes = 0;
 388.322 -  for (;;)
 388.323 -  {
 388.324 -    if (processedBytes >= (1 << 20) && progress != NULL)
 388.325 -    {
 388.326 -      /*
 388.327 -      const UInt64 compressedSize =
 388.328 -        _mainInStream.GetProcessedSize() +
 388.329 -        _callStream.GetProcessedSize() +
 388.330 -        _jumpStream.GetProcessedSize() +
 388.331 -        _rangeDecoder.GetProcessedSize();
 388.332 -      */
 388.333 -      const UInt64 nowPos64 = _outStream.GetProcessedSize();
 388.334 -      RINOK(progress->SetRatioInfo(NULL, &nowPos64));
 388.335 -      processedBytes = 0;
 388.336 -    }
 388.337 -    UInt32 i;
 388.338 -    Byte b = 0;
 388.339 -    const UInt32 kBurstSize = (1 << 18);
 388.340 -    for (i = 0; i < kBurstSize; i++)
 388.341 -    {
 388.342 -      if (!_mainInStream.ReadByte(b))
 388.343 -        return Flush();
 388.344 -      _outStream.WriteByte(b);
 388.345 -      if (IsJ(prevByte, b))
 388.346 -        break;
 388.347 -      prevByte = b;
 388.348 -    }
 388.349 -    processedBytes += i;
 388.350 -    if (i == kBurstSize)
 388.351 -      continue;
 388.352 -    unsigned index = GetIndex(prevByte, b);
 388.353 -    if (_statusDecoder[index].Decode(&_rangeDecoder) == 1)
 388.354 -    {
 388.355 -      UInt32 src = 0;
 388.356 -      CInBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
 388.357 -      for (int i = 0; i < 4; i++)
 388.358 -      {
 388.359 -        Byte b0;
 388.360 -        if(!s.ReadByte(b0))
 388.361 -          return S_FALSE;
 388.362 -        src <<= 8;
 388.363 -        src |= ((UInt32)b0);
 388.364 -      }
 388.365 -      UInt32 dest = src - (UInt32(_outStream.GetProcessedSize()) + 4) ;
 388.366 -      _outStream.WriteByte((Byte)(dest));
 388.367 -      _outStream.WriteByte((Byte)(dest >> 8));
 388.368 -      _outStream.WriteByte((Byte)(dest >> 16));
 388.369 -      _outStream.WriteByte((Byte)(dest >> 24));
 388.370 -      prevByte = (Byte)(dest >> 24);
 388.371 -      processedBytes += 4;
 388.372 -    }
 388.373 -    else
 388.374 -      prevByte = b;
 388.375 -  }
 388.376 -}
 388.377 -
 388.378 -STDMETHODIMP CDecoder::Code(ISequentialInStream **inStreams,
 388.379 -      const UInt64 **inSizes,
 388.380 -      UInt32 numInStreams,
 388.381 -      ISequentialOutStream **outStreams,
 388.382 -      const UInt64 **outSizes,
 388.383 -      UInt32 numOutStreams,
 388.384 -      ICompressProgressInfo *progress)
 388.385 -{
 388.386 -  try
 388.387 -  {
 388.388 -    return CodeReal(inStreams, inSizes, numInStreams,
 388.389 -        outStreams, outSizes,numOutStreams, progress);
 388.390 -  }
 388.391 -  catch(const CInBufferException &e) { return e.ErrorCode; }
 388.392 -  catch(const COutBufferException &e) { return e.ErrorCode; }
 388.393 -  catch(...) { return S_FALSE; }
 388.394 -}
 388.395 -
 388.396 -}}
   389.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.h	Sat Mar 03 10:54:39 2012 -0600
   389.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   389.3 @@ -1,125 +0,0 @@
   389.4 -// Bcj2Coder.h
   389.5 -
   389.6 -#ifndef __COMPRESS_BCJ2_CODER_H
   389.7 -#define __COMPRESS_BCJ2_CODER_H
   389.8 -
   389.9 -#include "../../Common/MyCom.h"
  389.10 -
  389.11 -#include "../ICoder.h"
  389.12 -
  389.13 -#include "RangeCoderBit.h"
  389.14 -
  389.15 -namespace NCompress {
  389.16 -namespace NBcj2 {
  389.17 -
  389.18 -const int kNumMoveBits = 5;
  389.19 -
  389.20 -#ifndef EXTRACT_ONLY
  389.21 -
  389.22 -class CEncoder:
  389.23 -  public ICompressCoder2,
  389.24 -  public CMyUnknownImp
  389.25 -{
  389.26 -  Byte *_buffer;
  389.27 -public:
  389.28 -  CEncoder(): _buffer(0) {};
  389.29 -  ~CEncoder();
  389.30 -  bool Create();
  389.31 -
  389.32 -  COutBuffer _mainStream;
  389.33 -  COutBuffer _callStream;
  389.34 -  COutBuffer _jumpStream;
  389.35 -  NCompress::NRangeCoder::CEncoder _rangeEncoder;
  389.36 -  NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
  389.37 -
  389.38 -  HRESULT Flush();
  389.39 -  void ReleaseStreams()
  389.40 -  {
  389.41 -    _mainStream.ReleaseStream();
  389.42 -    _callStream.ReleaseStream();
  389.43 -    _jumpStream.ReleaseStream();
  389.44 -    _rangeEncoder.ReleaseStream();
  389.45 -  }
  389.46 -
  389.47 -  class CCoderReleaser
  389.48 -  {
  389.49 -    CEncoder *_coder;
  389.50 -  public:
  389.51 -    CCoderReleaser(CEncoder *coder): _coder(coder) {}
  389.52 -    ~CCoderReleaser() {  _coder->ReleaseStreams(); }
  389.53 -  };
  389.54 -
  389.55 -public:
  389.56 -
  389.57 -  MY_UNKNOWN_IMP
  389.58 -
  389.59 -  HRESULT CodeReal(ISequentialInStream **inStreams,
  389.60 -      const UInt64 **inSizes,
  389.61 -      UInt32 numInStreams,
  389.62 -      ISequentialOutStream **outStreams,
  389.63 -      const UInt64 **outSizes,
  389.64 -      UInt32 numOutStreams,
  389.65 -      ICompressProgressInfo *progress);
  389.66 -  STDMETHOD(Code)(ISequentialInStream **inStreams,
  389.67 -      const UInt64 **inSizes,
  389.68 -      UInt32 numInStreams,
  389.69 -      ISequentialOutStream **outStreams,
  389.70 -      const UInt64 **outSizes,
  389.71 -      UInt32 numOutStreams,
  389.72 -      ICompressProgressInfo *progress);
  389.73 -};
  389.74 -
  389.75 -#endif
  389.76 -
  389.77 -class CDecoder:
  389.78 -  public ICompressCoder2,
  389.79 -  public CMyUnknownImp
  389.80 -{
  389.81 -public:
  389.82 -  CInBuffer _mainInStream;
  389.83 -  CInBuffer _callStream;
  389.84 -  CInBuffer _jumpStream;
  389.85 -  NCompress::NRangeCoder::CDecoder _rangeDecoder;
  389.86 -  NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
  389.87 -
  389.88 -  COutBuffer _outStream;
  389.89 -
  389.90 -  void ReleaseStreams()
  389.91 -  {
  389.92 -    _mainInStream.ReleaseStream();
  389.93 -    _callStream.ReleaseStream();
  389.94 -    _jumpStream.ReleaseStream();
  389.95 -    _rangeDecoder.ReleaseStream();
  389.96 -    _outStream.ReleaseStream();
  389.97 -  }
  389.98 -
  389.99 -  HRESULT Flush() { return _outStream.Flush(); }
 389.100 -  class CCoderReleaser
 389.101 -  {
 389.102 -    CDecoder *_coder;
 389.103 -  public:
 389.104 -    CCoderReleaser(CDecoder *coder): _coder(coder) {}
 389.105 -    ~CCoderReleaser()  { _coder->ReleaseStreams(); }
 389.106 -  };
 389.107 -
 389.108 -public:
 389.109 -  MY_UNKNOWN_IMP
 389.110 -  HRESULT CodeReal(ISequentialInStream **inStreams,
 389.111 -      const UInt64 **inSizes,
 389.112 -      UInt32 numInStreams,
 389.113 -      ISequentialOutStream **outStreams,
 389.114 -      const UInt64 **outSizes,
 389.115 -      UInt32 numOutStreams,
 389.116 -      ICompressProgressInfo *progress);
 389.117 -  STDMETHOD(Code)(ISequentialInStream **inStreams,
 389.118 -      const UInt64 **inSizes,
 389.119 -      UInt32 numInStreams,
 389.120 -      ISequentialOutStream **outStreams,
 389.121 -      const UInt64 **outSizes,
 389.122 -      UInt32 numOutStreams,
 389.123 -      ICompressProgressInfo *progress);
 389.124 -};
 389.125 -
 389.126 -}}
 389.127 -
 389.128 -#endif
   390.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Register.cpp	Sat Mar 03 10:54:39 2012 -0600
   390.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   390.3 @@ -1,19 +0,0 @@
   390.4 -// Bcj2Register.cpp
   390.5 -
   390.6 -#include "StdAfx.h"
   390.7 -
   390.8 -#include "../Common/RegisterCodec.h"
   390.9 -
  390.10 -#include "Bcj2Coder.h"
  390.11 -
  390.12 -static void *CreateCodec() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CDecoder()); }
  390.13 -#ifndef EXTRACT_ONLY
  390.14 -static void *CreateCodecOut() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CEncoder());  }
  390.15 -#else
  390.16 -#define CreateCodecOut 0
  390.17 -#endif
  390.18 -
  390.19 -static CCodecInfo g_CodecInfo =
  390.20 -  { CreateCodec, CreateCodecOut, 0x0303011B, L"BCJ2", 4, false };
  390.21 -
  390.22 -REGISTER_CODEC(BCJ2)
   391.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BcjCoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   391.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   391.3 @@ -1,15 +0,0 @@
   391.4 -// BcjCoder.cpp
   391.5 -
   391.6 -#include "StdAfx.h"
   391.7 -
   391.8 -#include "BcjCoder.h"
   391.9 -
  391.10 -UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
  391.11 -{
  391.12 -  return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 1);
  391.13 -}
  391.14 -
  391.15 -UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
  391.16 -{
  391.17 -  return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 0);
  391.18 -}
   392.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BcjCoder.h	Sat Mar 03 10:54:39 2012 -0600
   392.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   392.3 @@ -1,22 +0,0 @@
   392.4 -// BcjCoder.h
   392.5 -
   392.6 -#ifndef __COMPRESS_BCJ_CODER_H
   392.7 -#define __COMPRESS_BCJ_CODER_H
   392.8 -
   392.9 -extern "C"
  392.10 -{
  392.11 -#include "../../../C/Bra.h"
  392.12 -}
  392.13 -
  392.14 -#include "BranchCoder.h"
  392.15 -
  392.16 -struct CBranch86
  392.17 -{
  392.18 -  UInt32 _prevMask;
  392.19 -  void x86Init() { x86_Convert_Init(_prevMask); }
  392.20 -};
  392.21 -
  392.22 -MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
  392.23 -    virtual void SubInit() { x86Init(); })
  392.24 -
  392.25 -#endif
   393.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BcjRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   393.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   393.3 @@ -1,19 +0,0 @@
   393.4 -// BcjRegister.cpp
   393.5 -
   393.6 -#include "StdAfx.h"
   393.7 -
   393.8 -#include "../Common/RegisterCodec.h"
   393.9 -
  393.10 -#include "BcjCoder.h"
  393.11 -
  393.12 -static void *CreateCodec() { return (void *)(ICompressFilter *)(new CBCJ_x86_Decoder()); }
  393.13 -#ifndef EXTRACT_ONLY
  393.14 -static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new CBCJ_x86_Encoder());  }
  393.15 -#else
  393.16 -#define CreateCodecOut 0
  393.17 -#endif
  393.18 -
  393.19 -static CCodecInfo g_CodecInfo =
  393.20 -  { CreateCodec, CreateCodecOut, 0x03030103, L"BCJ", 1, true };
  393.21 -
  393.22 -REGISTER_CODEC(BCJ)
   394.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BitlDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   394.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   394.3 @@ -1,24 +0,0 @@
   394.4 -// BitlDecoder.cpp
   394.5 -
   394.6 -#include "StdAfx.h"
   394.7 -
   394.8 -#include "BitlDecoder.h"
   394.9 -
  394.10 -namespace NBitl {
  394.11 -
  394.12 -Byte kInvertTable[256];
  394.13 -
  394.14 -struct CInverterTableInitializer
  394.15 -{
  394.16 -  CInverterTableInitializer()
  394.17 -  {
  394.18 -    for (int i = 0; i < 256; i++)
  394.19 -    {
  394.20 -      int x = ((i & 0x55) << 1) | ((i & 0xAA) >> 1);
  394.21 -      x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2);
  394.22 -      kInvertTable[i] = (Byte)(((x & 0x0F) << 4) | ((x & 0xF0) >> 4));
  394.23 -    }
  394.24 -  }
  394.25 -} g_InverterTableInitializer;
  394.26 -
  394.27 -}
   395.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BitlDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   395.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   395.3 @@ -1,125 +0,0 @@
   395.4 -// BitlDecoder.h -- the Least Significant Bit of byte is First
   395.5 -
   395.6 -#ifndef __BITL_DECODER_H
   395.7 -#define __BITL_DECODER_H
   395.8 -
   395.9 -#include "../IStream.h"
  395.10 -
  395.11 -namespace NBitl {
  395.12 -
  395.13 -const int kNumBigValueBits = 8 * 4;
  395.14 -
  395.15 -const int kNumValueBytes = 3;
  395.16 -const int kNumValueBits = 8  * kNumValueBytes;
  395.17 -
  395.18 -const UInt32 kMask = (1 << kNumValueBits) - 1;
  395.19 -
  395.20 -extern Byte kInvertTable[256];
  395.21 -
  395.22 -template<class TInByte>
  395.23 -class CBaseDecoder
  395.24 -{
  395.25 -protected:
  395.26 -  int m_BitPos;
  395.27 -  UInt32 m_Value;
  395.28 -  TInByte m_Stream;
  395.29 -public:
  395.30 -  UInt32 NumExtraBytes;
  395.31 -  bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
  395.32 -  void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream); }
  395.33 -  void ReleaseStream() { m_Stream.ReleaseStream(); }
  395.34 -  void Init()
  395.35 -  {
  395.36 -    m_Stream.Init();
  395.37 -    m_BitPos = kNumBigValueBits;
  395.38 -    m_Value = 0;
  395.39 -    NumExtraBytes = 0;
  395.40 -  }
  395.41 -  UInt64 GetProcessedSize() const
  395.42 -    { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
  395.43 -  UInt64 GetProcessedBitsSize() const
  395.44 -    { return (m_Stream.GetProcessedSize() << 3) - (kNumBigValueBits - m_BitPos); }
  395.45 -  int GetBitPosition() const { return (m_BitPos & 7); }
  395.46 -
  395.47 -  void Normalize()
  395.48 -  {
  395.49 -    for (;m_BitPos >= 8; m_BitPos -= 8)
  395.50 -    {
  395.51 -      Byte b = 0;
  395.52 -      if (!m_Stream.ReadByte(b))
  395.53 -      {
  395.54 -        b = 0xFF; // check it
  395.55 -        NumExtraBytes++;
  395.56 -      }
  395.57 -      m_Value = (b << (kNumBigValueBits - m_BitPos)) | m_Value;
  395.58 -    }
  395.59 -  }
  395.60 -  
  395.61 -  UInt32 ReadBits(int numBits)
  395.62 -  {
  395.63 -    Normalize();
  395.64 -    UInt32 res = m_Value & ((1 << numBits) - 1);
  395.65 -    m_BitPos += numBits;
  395.66 -    m_Value >>= numBits;
  395.67 -    return res;
  395.68 -  }
  395.69 -
  395.70 -  bool ExtraBitsWereRead() const
  395.71 -  {
  395.72 -    if (NumExtraBytes == 0)
  395.73 -      return false;
  395.74 -    return ((UInt32)(kNumBigValueBits - m_BitPos) < (NumExtraBytes << 3));
  395.75 -  }
  395.76 -};
  395.77 -
  395.78 -template<class TInByte>
  395.79 -class CDecoder: public CBaseDecoder<TInByte>
  395.80 -{
  395.81 -  UInt32 m_NormalValue;
  395.82 -
  395.83 -public:
  395.84 -  void Init()
  395.85 -  {
  395.86 -    CBaseDecoder<TInByte>::Init();
  395.87 -    m_NormalValue = 0;
  395.88 -  }
  395.89 -
  395.90 -  void Normalize()
  395.91 -  {
  395.92 -    for (; this->m_BitPos >= 8; this->m_BitPos -= 8)
  395.93 -    {
  395.94 -      Byte b = 0;
  395.95 -      if (!this->m_Stream.ReadByte(b))
  395.96 -      {
  395.97 -        b = 0xFF; // check it
  395.98 -        this->NumExtraBytes++;
  395.99 -      }
 395.100 -      m_NormalValue = (b << (kNumBigValueBits - this->m_BitPos)) | m_NormalValue;
 395.101 -      this->m_Value = (this->m_Value << 8) | kInvertTable[b];
 395.102 -    }
 395.103 -  }
 395.104 -  
 395.105 -  UInt32 GetValue(int numBits)
 395.106 -  {
 395.107 -    Normalize();
 395.108 -    return ((this->m_Value >> (8 - this->m_BitPos)) & kMask) >> (kNumValueBits - numBits);
 395.109 -  }
 395.110 -
 395.111 -  void MovePos(int numBits)
 395.112 -  {
 395.113 -    this->m_BitPos += numBits;
 395.114 -    m_NormalValue >>= numBits;
 395.115 -  }
 395.116 -  
 395.117 -  UInt32 ReadBits(int numBits)
 395.118 -  {
 395.119 -    Normalize();
 395.120 -    UInt32 res = m_NormalValue & ( (1 << numBits) - 1);
 395.121 -    MovePos(numBits);
 395.122 -    return res;
 395.123 -  }
 395.124 -};
 395.125 -
 395.126 -}
 395.127 -
 395.128 -#endif
   396.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BitmDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   396.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   396.3 @@ -1,66 +0,0 @@
   396.4 -// BitmDecoder.h -- the Most Significant Bit of byte is First
   396.5 -
   396.6 -#ifndef __BITM_DECODER_H
   396.7 -#define __BITM_DECODER_H
   396.8 -
   396.9 -#include "../IStream.h"
  396.10 -
  396.11 -namespace NBitm {
  396.12 -
  396.13 -const int kNumBigValueBits = 8 * 4;
  396.14 -const int kNumValueBytes = 3;
  396.15 -const int kNumValueBits = 8  * kNumValueBytes;
  396.16 -
  396.17 -const UInt32 kMask = (1 << kNumValueBits) - 1;
  396.18 -
  396.19 -template<class TInByte>
  396.20 -class CDecoder
  396.21 -{
  396.22 -  UInt32 m_BitPos;
  396.23 -  UInt32 m_Value;
  396.24 -public:
  396.25 -  TInByte m_Stream;
  396.26 -  bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
  396.27 -  void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
  396.28 -  void ReleaseStream() { m_Stream.ReleaseStream();}
  396.29 -
  396.30 -  void Init()
  396.31 -  {
  396.32 -    m_Stream.Init();
  396.33 -    m_BitPos = kNumBigValueBits;
  396.34 -    Normalize();
  396.35 -  }
  396.36 -  
  396.37 -  UInt64 GetProcessedSize() const
  396.38 -    { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
  396.39 -  UInt32 GetBitPosition() const { return (m_BitPos & 7); }
  396.40 -  
  396.41 -  void Normalize()
  396.42 -  {
  396.43 -    for (;m_BitPos >= 8; m_BitPos -= 8)
  396.44 -      m_Value = (m_Value << 8) | m_Stream.ReadByte();
  396.45 -  }
  396.46 -
  396.47 -  UInt32 GetValue(UInt32 numBits) const
  396.48 -  {
  396.49 -    // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
  396.50 -    return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
  396.51 -  }
  396.52 -  
  396.53 -  void MovePos(UInt32 numBits)
  396.54 -  {
  396.55 -    m_BitPos += numBits;
  396.56 -    Normalize();
  396.57 -  }
  396.58 -  
  396.59 -  UInt32 ReadBits(UInt32 numBits)
  396.60 -  {
  396.61 -    UInt32 res = GetValue(numBits);
  396.62 -    MovePos(numBits);
  396.63 -    return res;
  396.64 -  }
  396.65 -};
  396.66 -
  396.67 -}
  396.68 -
  396.69 -#endif
   397.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BranchCoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   397.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   397.3 @@ -1,19 +0,0 @@
   397.4 -// BranchCoder.cpp
   397.5 -
   397.6 -#include "StdAfx.h"
   397.7 -
   397.8 -#include "BranchCoder.h"
   397.9 -
  397.10 -STDMETHODIMP CBranchConverter::Init()
  397.11 -{
  397.12 -  _bufferPos = 0;
  397.13 -  SubInit();
  397.14 -  return S_OK;
  397.15 -}
  397.16 -
  397.17 -STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size)
  397.18 -{
  397.19 -  UInt32 processedSize = SubFilter(data, size);
  397.20 -  _bufferPos += processedSize;
  397.21 -  return processedSize;
  397.22 -}
   398.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BranchCoder.h	Sat Mar 03 10:54:39 2012 -0600
   398.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   398.3 @@ -1,44 +0,0 @@
   398.4 -// BranchCoder.h
   398.5 -
   398.6 -#ifndef __COMPRESS_BRANCH_CODER_H
   398.7 -#define __COMPRESS_BRANCH_CODER_H
   398.8 -
   398.9 -#include "../../Common/MyCom.h"
  398.10 -
  398.11 -#include "../ICoder.h"
  398.12 -
  398.13 -class CBranchConverter:
  398.14 -  public ICompressFilter,
  398.15 -  public CMyUnknownImp
  398.16 -{
  398.17 -protected:
  398.18 -  UInt32 _bufferPos;
  398.19 -  virtual void SubInit() {}
  398.20 -  virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
  398.21 -public:
  398.22 -  MY_UNKNOWN_IMP;
  398.23 -  STDMETHOD(Init)();
  398.24 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  398.25 -};
  398.26 -
  398.27 -#define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
  398.28 -  { public: UInt32 SubFilter(Byte *data, UInt32 size); };
  398.29 -
  398.30 -#define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
  398.31 -  { public: UInt32 SubFilter(Byte *data, UInt32 size); };
  398.32 -
  398.33 -#define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
  398.34 -  { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
  398.35 -
  398.36 -#define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
  398.37 -  { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
  398.38 -
  398.39 -#define MyClassA(Name, id, subId)  \
  398.40 -MyClassEncoderA(Name ## _Encoder) \
  398.41 -MyClassDecoderA(Name ## _Decoder)
  398.42 -
  398.43 -#define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT)  \
  398.44 -MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
  398.45 -MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
  398.46 -
  398.47 -#endif
   399.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BranchMisc.cpp	Sat Mar 03 10:54:39 2012 -0600
   399.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   399.3 @@ -1,40 +0,0 @@
   399.4 -// BranchMisc.cpp
   399.5 -
   399.6 -#include "StdAfx.h"
   399.7 -
   399.8 -extern "C"
   399.9 -{
  399.10 -#include "../../../C/Bra.h"
  399.11 -}
  399.12 -
  399.13 -#include "BranchMisc.h"
  399.14 -
  399.15 -UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
  399.16 -  { return (UInt32)::ARM_Convert(data, size, _bufferPos, 1); }
  399.17 -
  399.18 -UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
  399.19 -  { return (UInt32)::ARM_Convert(data, size, _bufferPos, 0); }
  399.20 -
  399.21 -UInt32 CBC_ARMT_Encoder::SubFilter(Byte *data, UInt32 size)
  399.22 -  { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 1); }
  399.23 -
  399.24 -UInt32 CBC_ARMT_Decoder::SubFilter(Byte *data, UInt32 size)
  399.25 -  { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 0); }
  399.26 -
  399.27 -UInt32 CBC_PPC_Encoder::SubFilter(Byte *data, UInt32 size)
  399.28 -  { return (UInt32)::PPC_Convert(data, size, _bufferPos, 1); }
  399.29 -
  399.30 -UInt32 CBC_PPC_Decoder::SubFilter(Byte *data, UInt32 size)
  399.31 -  { return (UInt32)::PPC_Convert(data, size, _bufferPos, 0); }
  399.32 -
  399.33 -UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
  399.34 -  { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 1); }
  399.35 -
  399.36 -UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
  399.37 -  { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 0); }
  399.38 -
  399.39 -UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
  399.40 -  { return (UInt32)::IA64_Convert(data, size, _bufferPos, 1); }
  399.41 -
  399.42 -UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
  399.43 -  {  return (UInt32)::IA64_Convert(data, size, _bufferPos, 0); }
   400.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BranchMisc.h	Sat Mar 03 10:54:39 2012 -0600
   400.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   400.3 @@ -1,14 +0,0 @@
   400.4 -// BranchMisc.h
   400.5 -
   400.6 -#ifndef __COMPRESS_BRANCH_MISC_H
   400.7 -#define __COMPRESS_BRANCH_MISC_H
   400.8 -
   400.9 -#include "BranchCoder.h"
  400.10 -
  400.11 -MyClassA(BC_ARM,   0x05, 1)
  400.12 -MyClassA(BC_ARMT,  0x07, 1)
  400.13 -MyClassA(BC_PPC,   0x02, 5)
  400.14 -MyClassA(BC_SPARC, 0x08, 5)
  400.15 -MyClassA(BC_IA64,  0x04, 1)
  400.16 -
  400.17 -#endif
   401.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/BranchRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   401.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   401.3 @@ -1,30 +0,0 @@
   401.4 -// BranchRegister.cpp
   401.5 -
   401.6 -#include "StdAfx.h"
   401.7 -
   401.8 -#include "../Common/RegisterCodec.h"
   401.9 -
  401.10 -#include "BranchMisc.h"
  401.11 -
  401.12 -#define CREATE_CODEC(x) \
  401.13 -  static void *CreateCodec ## x() { return (void *)(ICompressFilter *)(new C ## x ## _Decoder); } \
  401.14 -  static void *CreateCodec ## x ## Out() { return (void *)(ICompressFilter *)(new C ## x ## _Encoder); }
  401.15 -
  401.16 -CREATE_CODEC(BC_PPC)
  401.17 -CREATE_CODEC(BC_IA64)
  401.18 -CREATE_CODEC(BC_ARM)
  401.19 -CREATE_CODEC(BC_ARMT)
  401.20 -CREATE_CODEC(BC_SPARC)
  401.21 -
  401.22 -#define METHOD_ITEM(x, id1, id2, name) { CreateCodec ## x, CreateCodec ## x ## Out, 0x03030000 + (id1 * 256) + id2, name, 1, true  }
  401.23 -
  401.24 -static CCodecInfo g_CodecsInfo[] =
  401.25 -{
  401.26 -  METHOD_ITEM(BC_PPC,   0x02, 0x05, L"PPC"),
  401.27 -  METHOD_ITEM(BC_IA64,  0x04, 1, L"IA64"),
  401.28 -  METHOD_ITEM(BC_ARM,   0x05, 1, L"ARM"),
  401.29 -  METHOD_ITEM(BC_ARMT,  0x07, 1, L"ARMT"),
  401.30 -  METHOD_ITEM(BC_SPARC, 0x08, 0x05, L"SPARC")
  401.31 -};
  401.32 -
  401.33 -REGISTER_CODECS(Branch)
   402.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ByteSwap.cpp	Sat Mar 03 10:54:39 2012 -0600
   402.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   402.3 @@ -1,38 +0,0 @@
   402.4 -// ByteSwap.cpp
   402.5 -
   402.6 -#include "StdAfx.h"
   402.7 -
   402.8 -#include "ByteSwap.h"
   402.9 -
  402.10 -STDMETHODIMP CByteSwap2::Init() { return S_OK; }
  402.11 -
  402.12 -STDMETHODIMP_(UInt32) CByteSwap2::Filter(Byte *data, UInt32 size)
  402.13 -{
  402.14 -  const UInt32 kStep = 2;
  402.15 -  UInt32 i;
  402.16 -  for (i = 0; i + kStep <= size; i += kStep)
  402.17 -  {
  402.18 -    Byte b = data[i];
  402.19 -    data[i] = data[i + 1];
  402.20 -    data[i + 1] = b;
  402.21 -  }
  402.22 -  return i;
  402.23 -}
  402.24 -
  402.25 -STDMETHODIMP CByteSwap4::Init() { return S_OK; }
  402.26 -
  402.27 -STDMETHODIMP_(UInt32) CByteSwap4::Filter(Byte *data, UInt32 size)
  402.28 -{
  402.29 -  const UInt32 kStep = 4;
  402.30 -  UInt32 i;
  402.31 -  for (i = 0; i + kStep <= size; i += kStep)
  402.32 -  {
  402.33 -    Byte b0 = data[i];
  402.34 -    Byte b1 = data[i + 1];
  402.35 -    data[i] = data[i + 3];
  402.36 -    data[i + 1] = data[i + 2];
  402.37 -    data[i + 2] = b1;
  402.38 -    data[i + 3] = b0;
  402.39 -  }
  402.40 -  return i;
  402.41 -}
   403.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ByteSwap.h	Sat Mar 03 10:54:39 2012 -0600
   403.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   403.3 @@ -1,30 +0,0 @@
   403.4 -// ByteSwap.h
   403.5 -
   403.6 -#ifndef __COMPRESS_BYTE_SWAP_H
   403.7 -#define __COMPRESS_BYTE_SWAP_H
   403.8 -
   403.9 -#include "../../Common/MyCom.h"
  403.10 -
  403.11 -#include "../ICoder.h"
  403.12 -
  403.13 -class CByteSwap2:
  403.14 -  public ICompressFilter,
  403.15 -  public CMyUnknownImp
  403.16 -{
  403.17 -public:
  403.18 -  MY_UNKNOWN_IMP
  403.19 -  STDMETHOD(Init)();
  403.20 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  403.21 -};
  403.22 -
  403.23 -class CByteSwap4:
  403.24 -  public ICompressFilter,
  403.25 -  public CMyUnknownImp
  403.26 -{
  403.27 -public:
  403.28 -  MY_UNKNOWN_IMP
  403.29 -  STDMETHOD(Init)();
  403.30 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  403.31 -};
  403.32 -
  403.33 -#endif
   404.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ByteSwapRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   404.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   404.3 @@ -1,18 +0,0 @@
   404.4 -// ByteSwapRegister.cpp
   404.5 -
   404.6 -#include "StdAfx.h"
   404.7 -
   404.8 -#include "../Common/RegisterCodec.h"
   404.9 -
  404.10 -#include "ByteSwap.h"
  404.11 -
  404.12 -static void *CreateCodec2() { return (void *)(ICompressFilter *)(new CByteSwap2); }
  404.13 -static void *CreateCodec4() { return (void *)(ICompressFilter *)(new CByteSwap4); }
  404.14 -
  404.15 -static CCodecInfo g_CodecsInfo[] =
  404.16 -{
  404.17 -  { CreateCodec2, CreateCodec4, 0x020302, L"Swap2", 1, true },
  404.18 -  { CreateCodec4, CreateCodec4, 0x020304, L"Swap4", 1, true }
  404.19 -};
  404.20 -
  404.21 -REGISTER_CODECS(ByteSwap)
   405.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Codec.def	Sat Mar 03 10:54:39 2012 -0600
   405.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   405.3 @@ -1,4 +0,0 @@
   405.4 -EXPORTS
   405.5 -  CreateObject PRIVATE
   405.6 -  GetNumberOfMethods PRIVATE
   405.7 -  GetMethodProperty PRIVATE
   406.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/CodecExports.cpp	Sat Mar 03 10:54:39 2012 -0600
   406.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   406.3 @@ -1,157 +0,0 @@
   406.4 -// CodecExports.cpp
   406.5 -
   406.6 -#include "StdAfx.h"
   406.7 -
   406.8 -#include "../../Common/ComTry.h"
   406.9 -#include "../../Windows/PropVariant.h"
  406.10 -#include "../Common/RegisterCodec.h"
  406.11 -#include "../ICoder.h"
  406.12 -
  406.13 -extern unsigned int g_NumCodecs;
  406.14 -extern const CCodecInfo *g_Codecs[];
  406.15 -
  406.16 -static const UInt16 kDecodeId = 0x2790;
  406.17 -
  406.18 -DEFINE_GUID(CLSID_CCodec,
  406.19 -0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
  406.20 -
  406.21 -static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
  406.22 -{
  406.23 -  if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
  406.24 -    value->vt = VT_BSTR;
  406.25 -  return S_OK;
  406.26 -}
  406.27 -
  406.28 -static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
  406.29 -{
  406.30 -  return SetPropString((const char *)&guid, sizeof(GUID), value);
  406.31 -}
  406.32 -
  406.33 -static HRESULT SetClassID(CMethodId id, bool encode, PROPVARIANT *value)
  406.34 -{
  406.35 -  GUID clsId = CLSID_CCodec;
  406.36 -  for (int i = 0; i < sizeof(id); i++, id >>= 8)
  406.37 -    clsId.Data4[i] = (Byte)(id & 0xFF);
  406.38 -  if (encode)
  406.39 -    clsId.Data3++;
  406.40 -  return SetPropGUID(clsId, value);
  406.41 -}
  406.42 -
  406.43 -static HRESULT FindCodecClassId(const GUID *clsID, UInt32 isCoder2, bool isFilter, bool &encode, int &index)
  406.44 -{
  406.45 -  index = -1;
  406.46 -  if (clsID->Data1 != CLSID_CCodec.Data1 ||
  406.47 -      clsID->Data2 != CLSID_CCodec.Data2 ||
  406.48 -      (clsID->Data3 & ~1) != kDecodeId)
  406.49 -    return S_OK;
  406.50 -  encode = (clsID->Data3 != kDecodeId);
  406.51 -  UInt64 id = 0;
  406.52 -  for (int j = 0; j < 8; j++)
  406.53 -    id |= ((UInt64)clsID->Data4[j]) << (8 * j);
  406.54 -  for (unsigned i = 0; i < g_NumCodecs; i++)
  406.55 -  {
  406.56 -    const CCodecInfo &codec = *g_Codecs[i];
  406.57 -    if (id != codec.Id || encode && !codec.CreateEncoder || !encode && !codec.CreateDecoder)
  406.58 -      continue;
  406.59 -    if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
  406.60 -        codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
  406.61 -      return E_NOINTERFACE;
  406.62 -    index = i;
  406.63 -    return S_OK;
  406.64 -  }
  406.65 -  return S_OK;
  406.66 -}
  406.67 -
  406.68 -STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject)
  406.69 -{
  406.70 -  COM_TRY_BEGIN
  406.71 -  *outObject = 0;
  406.72 -  bool isCoder = (*iid == IID_ICompressCoder) != 0;
  406.73 -  bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
  406.74 -  bool isFilter = (*iid == IID_ICompressFilter) != 0;
  406.75 -  const CCodecInfo &codec = *g_Codecs[index];
  406.76 -  if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
  406.77 -      codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
  406.78 -    return E_NOINTERFACE;
  406.79 -  if (encode)
  406.80 -  {
  406.81 -    if (!codec.CreateEncoder)
  406.82 -      return CLASS_E_CLASSNOTAVAILABLE;
  406.83 -    *outObject = codec.CreateEncoder();
  406.84 -  }
  406.85 -  else
  406.86 -  {
  406.87 -    if (!codec.CreateDecoder)
  406.88 -      return CLASS_E_CLASSNOTAVAILABLE;
  406.89 -    *outObject = codec.CreateDecoder();
  406.90 -  }
  406.91 -  if (isCoder)
  406.92 -    ((ICompressCoder *)*outObject)->AddRef();
  406.93 -  else if (isCoder2)
  406.94 -    ((ICompressCoder2 *)*outObject)->AddRef();
  406.95 -  else
  406.96 -    ((ICompressFilter *)*outObject)->AddRef();
  406.97 -  return S_OK;
  406.98 -  COM_TRY_END
  406.99 -}
 406.100 -
 406.101 -STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
 406.102 -{
 406.103 -  *outObject = 0;
 406.104 -  bool isCoder = (*iid == IID_ICompressCoder) != 0;
 406.105 -  bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
 406.106 -  bool isFilter = (*iid == IID_ICompressFilter) != 0;
 406.107 -  if (!isCoder && !isCoder2 && !isFilter)
 406.108 -    return E_NOINTERFACE;
 406.109 -  bool encode;
 406.110 -  int codecIndex;
 406.111 -  HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
 406.112 -  if (res != S_OK)
 406.113 -    return res;
 406.114 -  if (codecIndex < 0)
 406.115 -    return CLASS_E_CLASSNOTAVAILABLE;
 406.116 -  return CreateCoder2(encode, codecIndex, iid, outObject);
 406.117 -}
 406.118 -
 406.119 -STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
 406.120 -{
 406.121 -  ::VariantClear((VARIANTARG *)value);
 406.122 -  const CCodecInfo &codec = *g_Codecs[codecIndex];
 406.123 -  switch(propID)
 406.124 -  {
 406.125 -    case NMethodPropID::kID:
 406.126 -    {
 406.127 -      value->uhVal.QuadPart = (UInt64)codec.Id;
 406.128 -      value->vt = VT_UI8;
 406.129 -      break;
 406.130 -    }
 406.131 -    case NMethodPropID::kName:
 406.132 -      if ((value->bstrVal = ::SysAllocString(codec.Name)) != 0)
 406.133 -        value->vt = VT_BSTR;
 406.134 -      break;
 406.135 -    case NMethodPropID::kDecoder:
 406.136 -      if (codec.CreateDecoder)
 406.137 -        return SetClassID(codec.Id, false, value);
 406.138 -      break;
 406.139 -    case NMethodPropID::kEncoder:
 406.140 -      if (codec.CreateEncoder)
 406.141 -        return SetClassID(codec.Id, true, value);
 406.142 -      break;
 406.143 -    case NMethodPropID::kInStreams:
 406.144 -    {
 406.145 -      if (codec.NumInStreams != 1)
 406.146 -      {
 406.147 -        value->vt = VT_UI4;
 406.148 -        value->ulVal = (ULONG)codec.NumInStreams;
 406.149 -      }
 406.150 -      break;
 406.151 -    }
 406.152 -  }
 406.153 -  return S_OK;
 406.154 -}
 406.155 -
 406.156 -STDAPI GetNumberOfMethods(UINT32 *numCodecs)
 406.157 -{
 406.158 -  *numCodecs = g_NumCodecs;
 406.159 -  return S_OK;
 406.160 -}
   407.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/CopyCoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   407.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   407.3 @@ -1,62 +0,0 @@
   407.4 -// Compress/CopyCoder.cpp
   407.5 -
   407.6 -#include "StdAfx.h"
   407.7 -
   407.8 -extern "C"
   407.9 -{
  407.10 -#include "../../../C/Alloc.h"
  407.11 -}
  407.12 -
  407.13 -#include "../Common/StreamUtils.h"
  407.14 -
  407.15 -#include "CopyCoder.h"
  407.16 -
  407.17 -namespace NCompress {
  407.18 -
  407.19 -static const UInt32 kBufferSize = 1 << 17;
  407.20 -
  407.21 -CCopyCoder::~CCopyCoder()
  407.22 -{
  407.23 -  ::MidFree(_buffer);
  407.24 -}
  407.25 -
  407.26 -STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
  407.27 -    ISequentialOutStream *outStream,
  407.28 -    const UInt64 * /* inSize */, const UInt64 *outSize,
  407.29 -    ICompressProgressInfo *progress)
  407.30 -{
  407.31 -  if (_buffer == 0)
  407.32 -  {
  407.33 -    _buffer = (Byte *)::MidAlloc(kBufferSize);
  407.34 -    if (_buffer == 0)
  407.35 -      return E_OUTOFMEMORY;
  407.36 -  }
  407.37 -
  407.38 -  TotalSize = 0;
  407.39 -  for (;;)
  407.40 -  {
  407.41 -    UInt32 realProcessedSize;
  407.42 -    UInt32 size = kBufferSize;
  407.43 -    if (outSize != 0)
  407.44 -      if (size > *outSize - TotalSize)
  407.45 -        size = (UInt32)(*outSize - TotalSize);
  407.46 -    RINOK(inStream->Read(_buffer, size, &realProcessedSize));
  407.47 -    if (realProcessedSize == 0)
  407.48 -      break;
  407.49 -    RINOK(WriteStream(outStream, _buffer, realProcessedSize));
  407.50 -    TotalSize += realProcessedSize;
  407.51 -    if (progress != NULL)
  407.52 -    {
  407.53 -      RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
  407.54 -    }
  407.55 -  }
  407.56 -  return S_OK;
  407.57 -}
  407.58 -
  407.59 -STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
  407.60 -{
  407.61 -  *value = TotalSize;
  407.62 -  return S_OK;
  407.63 -}
  407.64 -
  407.65 -}
   408.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/CopyCoder.h	Sat Mar 03 10:54:39 2012 -0600
   408.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   408.3 @@ -1,32 +0,0 @@
   408.4 -// Compress/CopyCoder.h
   408.5 -
   408.6 -#ifndef __COMPRESS_COPY_CODER_H
   408.7 -#define __COMPRESS_COPY_CODER_H
   408.8 -
   408.9 -#include "../../Common/MyCom.h"
  408.10 -
  408.11 -#include "../ICoder.h"
  408.12 -
  408.13 -namespace NCompress {
  408.14 -
  408.15 -class CCopyCoder:
  408.16 -  public ICompressCoder,
  408.17 -  public ICompressGetInStreamProcessedSize,
  408.18 -  public CMyUnknownImp
  408.19 -{
  408.20 -  Byte *_buffer;
  408.21 -public:
  408.22 -  UInt64 TotalSize;
  408.23 -  CCopyCoder(): TotalSize(0) , _buffer(0) {};
  408.24 -  ~CCopyCoder();
  408.25 -
  408.26 -  MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
  408.27 -
  408.28 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  408.29 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  408.30 -  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
  408.31 -};
  408.32 -
  408.33 -}
  408.34 -
  408.35 -#endif
   409.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/CopyRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   409.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   409.3 @@ -1,14 +0,0 @@
   409.4 -// CopyRegister.cpp
   409.5 -
   409.6 -#include "StdAfx.h"
   409.7 -
   409.8 -#include "../Common/RegisterCodec.h"
   409.9 -
  409.10 -#include "CopyCoder.h"
  409.11 -
  409.12 -static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::CCopyCoder); }
  409.13 -
  409.14 -static CCodecInfo g_CodecInfo =
  409.15 -{ CreateCodec, CreateCodec, 0x00, L"Copy", 1, false };
  409.16 -
  409.17 -REGISTER_CODEC(Copy)
   410.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Deflate64Register.cpp	Sat Mar 03 10:54:39 2012 -0600
   410.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   410.3 @@ -1,20 +0,0 @@
   410.4 -// Deflate64Register.cpp
   410.5 -
   410.6 -#include "StdAfx.h"
   410.7 -
   410.8 -#include "../Common/RegisterCodec.h"
   410.9 -
  410.10 -#include "DeflateDecoder.h"
  410.11 -
  410.12 -static void *CreateCodecDeflate64() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder64); }
  410.13 -#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
  410.14 -#include "DeflateEncoder.h"
  410.15 -static void *CreateCodecOutDeflate64() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NEncoder::CCOMCoder64);  }
  410.16 -#else
  410.17 -#define CreateCodecOutDeflate64 0
  410.18 -#endif
  410.19 -
  410.20 -static CCodecInfo g_CodecInfo =
  410.21 -  { CreateCodecDeflate64, CreateCodecOutDeflate64, 0x040109, L"Deflate64", 1, false };
  410.22 -
  410.23 -REGISTER_CODEC(Deflate64)
   411.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/DeflateConst.h	Sat Mar 03 10:54:39 2012 -0600
   411.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   411.3 @@ -1,134 +0,0 @@
   411.4 -// DeflateConst.h
   411.5 -
   411.6 -#ifndef __DEFLATE_CONST_H
   411.7 -#define __DEFLATE_CONST_H
   411.8 -
   411.9 -namespace NCompress {
  411.10 -namespace NDeflate {
  411.11 -
  411.12 -const int kNumHuffmanBits = 15;
  411.13 -
  411.14 -const UInt32 kHistorySize32 = (1 << 15);
  411.15 -const UInt32 kHistorySize64 = (1 << 16);
  411.16 -
  411.17 -const UInt32 kDistTableSize32 = 30;
  411.18 -const UInt32 kDistTableSize64 = 32;
  411.19 -  
  411.20 -const UInt32 kNumLenSymbols32 = 256;
  411.21 -const UInt32 kNumLenSymbols64 = 255; // don't change it. It must be <= 255.
  411.22 -const UInt32 kNumLenSymbolsMax = kNumLenSymbols32;
  411.23 -  
  411.24 -const UInt32 kNumLenSlots = 29;
  411.25 -
  411.26 -const UInt32 kFixedDistTableSize = 32;
  411.27 -const UInt32 kFixedLenTableSize = 31;
  411.28 -
  411.29 -const UInt32 kSymbolEndOfBlock = 0x100;
  411.30 -const UInt32 kSymbolMatch = kSymbolEndOfBlock + 1;
  411.31 -
  411.32 -const UInt32 kMainTableSize = kSymbolMatch + kNumLenSlots;
  411.33 -const UInt32 kFixedMainTableSize = kSymbolMatch + kFixedLenTableSize;
  411.34 -
  411.35 -const UInt32 kLevelTableSize = 19;
  411.36 -
  411.37 -const UInt32 kTableDirectLevels = 16;
  411.38 -const UInt32 kTableLevelRepNumber = kTableDirectLevels;
  411.39 -const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
  411.40 -const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
  411.41 -
  411.42 -const UInt32 kLevelMask = 0xF;
  411.43 -
  411.44 -const Byte kLenStart32[kFixedLenTableSize] =
  411.45 -  {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 255, 0, 0};
  411.46 -const Byte kLenStart64[kFixedLenTableSize] =
  411.47 -  {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 0, 0, 0};
  411.48 -
  411.49 -const Byte kLenDirectBits32[kFixedLenTableSize] =
  411.50 -  {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5, 0, 0, 0};
  411.51 -const Byte kLenDirectBits64[kFixedLenTableSize] =
  411.52 -  {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5, 16, 0, 0};
  411.53 -
  411.54 -const UInt32 kDistStart[kDistTableSize64]  =
  411.55 -  {0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,
  411.56 -  1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768,49152};
  411.57 -const Byte kDistDirectBits[kDistTableSize64] =
  411.58 -  {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14};
  411.59 -
  411.60 -const Byte kLevelDirectBits[3] = {2, 3, 7};
  411.61 -
  411.62 -const Byte kCodeLengthAlphabetOrder[kLevelTableSize] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  411.63 -
  411.64 -const UInt32 kMatchMinLen = 3;
  411.65 -const UInt32 kMatchMaxLen32 = kNumLenSymbols32 + kMatchMinLen - 1; //256 + 2
  411.66 -const UInt32 kMatchMaxLen64 = kNumLenSymbols64 + kMatchMinLen - 1; //255 + 2
  411.67 -const UInt32 kMatchMaxLen = kMatchMaxLen32;
  411.68 -
  411.69 -const int kFinalBlockFieldSize = 1;
  411.70 -
  411.71 -namespace NFinalBlockField
  411.72 -{
  411.73 -  enum
  411.74 -  {
  411.75 -    kNotFinalBlock = 0,
  411.76 -    kFinalBlock = 1
  411.77 -  };
  411.78 -}
  411.79 -
  411.80 -const int kBlockTypeFieldSize = 2;
  411.81 -
  411.82 -namespace NBlockType
  411.83 -{
  411.84 -  enum
  411.85 -  {
  411.86 -    kStored = 0,
  411.87 -    kFixedHuffman = 1,
  411.88 -    kDynamicHuffman = 2
  411.89 -  };
  411.90 -}
  411.91 -
  411.92 -const int kNumLenCodesFieldSize = 5;
  411.93 -const int kNumDistCodesFieldSize = 5;
  411.94 -const int kNumLevelCodesFieldSize = 4;
  411.95 -
  411.96 -const UInt32 kNumLitLenCodesMin = 257;
  411.97 -const UInt32 kNumDistCodesMin = 1;
  411.98 -const UInt32 kNumLevelCodesMin = 4;
  411.99 -
 411.100 -const int kLevelFieldSize = 3;
 411.101 -
 411.102 -const int kStoredBlockLengthFieldSize = 16;
 411.103 -
 411.104 -struct CLevels
 411.105 -{
 411.106 -  Byte litLenLevels[kFixedMainTableSize];
 411.107 -  Byte distLevels[kFixedDistTableSize];
 411.108 -
 411.109 -  void SubClear()
 411.110 -  {
 411.111 -    UInt32 i;
 411.112 -    for(i = kNumLitLenCodesMin; i < kFixedMainTableSize; i++)
 411.113 -      litLenLevels[i] = 0;
 411.114 -    for(i = 0; i < kFixedDistTableSize; i++)
 411.115 -      distLevels[i] = 0;
 411.116 -  }
 411.117 -
 411.118 -  void SetFixedLevels()
 411.119 -  {
 411.120 -    int i;
 411.121 -    
 411.122 -    for (i = 0; i < 144; i++)
 411.123 -      litLenLevels[i] = 8;
 411.124 -    for (; i < 256; i++)
 411.125 -      litLenLevels[i] = 9;
 411.126 -    for (; i < 280; i++)
 411.127 -      litLenLevels[i] = 7;
 411.128 -    for (; i < 288; i++)
 411.129 -      litLenLevels[i] = 8;
 411.130 -    for (i = 0; i < kFixedDistTableSize; i++)  // test it: InfoZip only uses kDistTableSize
 411.131 -      distLevels[i] = 5;
 411.132 -  }
 411.133 -};
 411.134 -
 411.135 -}}
 411.136 -
 411.137 -#endif
   412.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/DeflateDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   412.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   412.3 @@ -1,345 +0,0 @@
   412.4 -// DeflateDecoder.cpp
   412.5 -
   412.6 -#include "StdAfx.h"
   412.7 -
   412.8 -#include "DeflateDecoder.h"
   412.9 -
  412.10 -namespace NCompress {
  412.11 -namespace NDeflate {
  412.12 -namespace NDecoder {
  412.13 -
  412.14 -static const int kLenIdFinished = -1;
  412.15 -static const int kLenIdNeedInit = -2;
  412.16 -
  412.17 -CCoder::CCoder(bool deflate64Mode, bool deflateNSIS):
  412.18 -    _deflate64Mode(deflate64Mode),
  412.19 -    _deflateNSIS(deflateNSIS),
  412.20 -    _keepHistory(false),
  412.21 -    ZlibMode(false) {}
  412.22 -
  412.23 -UInt32 CCoder::ReadBits(int numBits)
  412.24 -{
  412.25 -  return m_InBitStream.ReadBits(numBits);
  412.26 -}
  412.27 -
  412.28 -bool CCoder::DeCodeLevelTable(Byte *values, int numSymbols)
  412.29 -{
  412.30 -  int i = 0;
  412.31 -  do
  412.32 -  {
  412.33 -    UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
  412.34 -    if (number < kTableDirectLevels)
  412.35 -      values[i++] = (Byte)number;
  412.36 -    else if (number < kLevelTableSize)
  412.37 -    {
  412.38 -      if (number == kTableLevelRepNumber)
  412.39 -      {
  412.40 -        if (i == 0)
  412.41 -          return false;
  412.42 -        int num = ReadBits(2) + 3;
  412.43 -        for (; num > 0 && i < numSymbols; num--, i++)
  412.44 -          values[i] = values[i - 1];
  412.45 -      }
  412.46 -      else
  412.47 -      {
  412.48 -        int num;
  412.49 -        if (number == kTableLevel0Number)
  412.50 -          num = ReadBits(3) + 3;
  412.51 -        else
  412.52 -          num = ReadBits(7) + 11;
  412.53 -        for (;num > 0 && i < numSymbols; num--)
  412.54 -          values[i++] = 0;
  412.55 -      }
  412.56 -    }
  412.57 -    else
  412.58 -      return false;
  412.59 -  }
  412.60 -  while(i < numSymbols);
  412.61 -  return true;
  412.62 -}
  412.63 -
  412.64 -#define RIF(x) { if (!(x)) return false; }
  412.65 -
  412.66 -bool CCoder::ReadTables(void)
  412.67 -{
  412.68 -  m_FinalBlock = (ReadBits(kFinalBlockFieldSize) == NFinalBlockField::kFinalBlock);
  412.69 -  UInt32 blockType = ReadBits(kBlockTypeFieldSize);
  412.70 -  if (blockType > NBlockType::kDynamicHuffman)
  412.71 -    return false;
  412.72 -
  412.73 -  if (blockType == NBlockType::kStored)
  412.74 -  {
  412.75 -    m_StoredMode = true;
  412.76 -    UInt32 currentBitPosition = m_InBitStream.GetBitPosition();
  412.77 -    int numBitsForAlign = (int)(currentBitPosition > 0 ? (8 - currentBitPosition): 0);
  412.78 -    ReadBits(numBitsForAlign);
  412.79 -    m_StoredBlockSize = ReadBits(kStoredBlockLengthFieldSize);
  412.80 -    if (_deflateNSIS)
  412.81 -      return true;
  412.82 -    return (m_StoredBlockSize == (UInt16)~ReadBits(kStoredBlockLengthFieldSize));
  412.83 -  }
  412.84 -
  412.85 -  m_StoredMode = false;
  412.86 -
  412.87 -  CLevels levels;
  412.88 -  if (blockType == NBlockType::kFixedHuffman)
  412.89 -  {
  412.90 -    levels.SetFixedLevels();
  412.91 -    _numDistLevels = _deflate64Mode ? kDistTableSize64 : kDistTableSize32;
  412.92 -  }
  412.93 -  else
  412.94 -  {
  412.95 -    int numLitLenLevels = ReadBits(kNumLenCodesFieldSize) + kNumLitLenCodesMin;
  412.96 -    _numDistLevels = ReadBits(kNumDistCodesFieldSize) + kNumDistCodesMin;
  412.97 -    int numLevelCodes = ReadBits(kNumLevelCodesFieldSize) + kNumLevelCodesMin;
  412.98 -
  412.99 -    if (!_deflate64Mode)
 412.100 -      if (_numDistLevels > kDistTableSize32)
 412.101 -        return false;
 412.102 -    
 412.103 -    Byte levelLevels[kLevelTableSize];
 412.104 -    for (int i = 0; i < kLevelTableSize; i++)
 412.105 -    {
 412.106 -      int position = kCodeLengthAlphabetOrder[i];
 412.107 -      if(i < numLevelCodes)
 412.108 -        levelLevels[position] = (Byte)ReadBits(kLevelFieldSize);
 412.109 -      else
 412.110 -        levelLevels[position] = 0;
 412.111 -    }
 412.112 -    
 412.113 -    RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
 412.114 -    
 412.115 -    Byte tmpLevels[kFixedMainTableSize + kFixedDistTableSize];
 412.116 -    if (!DeCodeLevelTable(tmpLevels, numLitLenLevels + _numDistLevels))
 412.117 -      return false;
 412.118 -
 412.119 -    levels.SubClear();
 412.120 -    memcpy(levels.litLenLevels, tmpLevels, numLitLenLevels);
 412.121 -    memcpy(levels.distLevels, tmpLevels + numLitLenLevels, _numDistLevels);
 412.122 -  }
 412.123 -  RIF(m_MainDecoder.SetCodeLengths(levels.litLenLevels));
 412.124 -  return m_DistDecoder.SetCodeLengths(levels.distLevels);
 412.125 -}
 412.126 -
 412.127 -HRESULT CCoder::CodeSpec(UInt32 curSize)
 412.128 -{
 412.129 -  if (_remainLen == kLenIdFinished)
 412.130 -    return S_OK;
 412.131 -  if (_remainLen == kLenIdNeedInit)
 412.132 -  {
 412.133 -    if (!_keepHistory)
 412.134 -      if (!m_OutWindowStream.Create(_deflate64Mode ? kHistorySize64: kHistorySize32))
 412.135 -        return E_OUTOFMEMORY;
 412.136 -    if (!m_InBitStream.Create(1 << 17))
 412.137 -      return E_OUTOFMEMORY;
 412.138 -    m_OutWindowStream.Init(_keepHistory);
 412.139 -    m_InBitStream.Init();
 412.140 -    m_FinalBlock = false;
 412.141 -    _remainLen = 0;
 412.142 -    _needReadTable = true;
 412.143 -  }
 412.144 -
 412.145 -  if (curSize == 0)
 412.146 -    return S_OK;
 412.147 -
 412.148 -  while(_remainLen > 0 && curSize > 0)
 412.149 -  {
 412.150 -    _remainLen--;
 412.151 -    Byte b = m_OutWindowStream.GetByte(_rep0);
 412.152 -    m_OutWindowStream.PutByte(b);
 412.153 -    curSize--;
 412.154 -  }
 412.155 -
 412.156 -  while(curSize > 0)
 412.157 -  {
 412.158 -    if (_needReadTable)
 412.159 -    {
 412.160 -      if (m_FinalBlock)
 412.161 -      {
 412.162 -        _remainLen = kLenIdFinished;
 412.163 -        break;
 412.164 -      }
 412.165 -      if (!ReadTables())
 412.166 -        return S_FALSE;
 412.167 -      _needReadTable = false;
 412.168 -    }
 412.169 -
 412.170 -    if(m_StoredMode)
 412.171 -    {
 412.172 -      for (; m_StoredBlockSize > 0 && curSize > 0; m_StoredBlockSize--, curSize--)
 412.173 -        m_OutWindowStream.PutByte((Byte)m_InBitStream.ReadBits(8));
 412.174 -      _needReadTable = (m_StoredBlockSize == 0);
 412.175 -      continue;
 412.176 -    }
 412.177 -    while(curSize > 0)
 412.178 -    {
 412.179 -      if (m_InBitStream.NumExtraBytes > 4)
 412.180 -        return S_FALSE;
 412.181 -
 412.182 -      UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
 412.183 -      if (number < 0x100)
 412.184 -      {
 412.185 -        m_OutWindowStream.PutByte((Byte)number);
 412.186 -        curSize--;
 412.187 -        continue;
 412.188 -      }
 412.189 -      else if (number == kSymbolEndOfBlock)
 412.190 -      {
 412.191 -        _needReadTable = true;
 412.192 -        break;
 412.193 -      }
 412.194 -      else if (number < kMainTableSize)
 412.195 -      {
 412.196 -        number -= kSymbolMatch;
 412.197 -        UInt32 len;
 412.198 -        {
 412.199 -          int numBits;
 412.200 -          if (_deflate64Mode)
 412.201 -          {
 412.202 -            len = kLenStart64[number];
 412.203 -            numBits = kLenDirectBits64[number];
 412.204 -          }
 412.205 -          else
 412.206 -          {
 412.207 -            len = kLenStart32[number];
 412.208 -            numBits = kLenDirectBits32[number];
 412.209 -          }
 412.210 -          len += kMatchMinLen + m_InBitStream.ReadBits(numBits);
 412.211 -        }
 412.212 -        UInt32 locLen = len;
 412.213 -        if (locLen > curSize)
 412.214 -          locLen = (UInt32)curSize;
 412.215 -        number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
 412.216 -        if (number >= _numDistLevels)
 412.217 -          return S_FALSE;
 412.218 -        UInt32 distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
 412.219 -        if (!m_OutWindowStream.CopyBlock(distance, locLen))
 412.220 -          return S_FALSE;
 412.221 -        curSize -= locLen;
 412.222 -        len -= locLen;
 412.223 -        if (len != 0)
 412.224 -        {
 412.225 -          _remainLen = (Int32)len;
 412.226 -          _rep0 = distance;
 412.227 -          break;
 412.228 -        }
 412.229 -      }
 412.230 -      else
 412.231 -        return S_FALSE;
 412.232 -    }
 412.233 -  }
 412.234 -  return S_OK;
 412.235 -}
 412.236 -
 412.237 -HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 412.238 -    const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
 412.239 -{
 412.240 -  SetInStream(inStream);
 412.241 -  m_OutWindowStream.SetStream(outStream);
 412.242 -  SetOutStreamSize(outSize);
 412.243 -  CCoderReleaser flusher(this);
 412.244 -
 412.245 -  const UInt64 start = m_OutWindowStream.GetProcessedSize();
 412.246 -  for (;;)
 412.247 -  {
 412.248 -    UInt32 curSize = 1 << 18;
 412.249 -    if (outSize != 0)
 412.250 -    {
 412.251 -      const UInt64 rem = *outSize - (m_OutWindowStream.GetProcessedSize() - start);
 412.252 -      if (curSize > rem)
 412.253 -        curSize = (UInt32)rem;
 412.254 -    }
 412.255 -    if (curSize == 0)
 412.256 -      break;
 412.257 -    RINOK(CodeSpec(curSize));
 412.258 -    if (_remainLen == kLenIdFinished)
 412.259 -      break;
 412.260 -    if (progress != NULL)
 412.261 -    {
 412.262 -      const UInt64 inSize = m_InBitStream.GetProcessedSize();
 412.263 -      const UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
 412.264 -      RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
 412.265 -    }
 412.266 -  }
 412.267 -  if (_remainLen == kLenIdFinished && ZlibMode)
 412.268 -  {
 412.269 -    UInt32 currentBitPosition = m_InBitStream.GetBitPosition();
 412.270 -    int numBitsForAlign = (int)(currentBitPosition > 0 ? (8 - currentBitPosition): 0);
 412.271 -    ReadBits(numBitsForAlign);
 412.272 -    for (int i = 0; i < 4; i++)
 412.273 -      ZlibFooter[i] = (Byte)m_InBitStream.ReadBits(8);
 412.274 -  }
 412.275 -  flusher.NeedFlush = false;
 412.276 -  return Flush();
 412.277 -}
 412.278 -
 412.279 -
 412.280 -#ifdef _NO_EXCEPTIONS
 412.281 -
 412.282 -#define DEFLATE_TRY_BEGIN
 412.283 -#define DEFLATE_TRY_END
 412.284 -
 412.285 -#else
 412.286 -
 412.287 -#define DEFLATE_TRY_BEGIN try {
 412.288 -#define DEFLATE_TRY_END } \
 412.289 -  catch(const CInBufferException &e)  { return e.ErrorCode; } \
 412.290 -  catch(const CLzOutWindowException &e)  { return e.ErrorCode; } \
 412.291 -  catch(...) { return S_FALSE; }
 412.292 -
 412.293 -#endif
 412.294 -
 412.295 -HRESULT CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 412.296 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 412.297 -{
 412.298 -  DEFLATE_TRY_BEGIN
 412.299 -  return CodeReal(inStream, outStream, inSize, outSize, progress);
 412.300 -  DEFLATE_TRY_END
 412.301 -}
 412.302 -
 412.303 -STDMETHODIMP CCoder::GetInStreamProcessedSize(UInt64 *value)
 412.304 -{
 412.305 -  if (value == NULL)
 412.306 -    return E_INVALIDARG;
 412.307 -  *value = m_InBitStream.GetProcessedSize();
 412.308 -  return S_OK;
 412.309 -}
 412.310 -
 412.311 -STDMETHODIMP CCoder::SetInStream(ISequentialInStream *inStream)
 412.312 -{
 412.313 -  m_InBitStream.SetStream(inStream);
 412.314 -  return S_OK;
 412.315 -}
 412.316 -
 412.317 -STDMETHODIMP CCoder::ReleaseInStream()
 412.318 -{
 412.319 -  m_InBitStream.ReleaseStream();
 412.320 -  return S_OK;
 412.321 -}
 412.322 -
 412.323 -STDMETHODIMP CCoder::SetOutStreamSize(const UInt64 * /* outSize */)
 412.324 -{
 412.325 -  _remainLen = kLenIdNeedInit;
 412.326 -  m_OutWindowStream.Init(_keepHistory);
 412.327 -  return S_OK;
 412.328 -}
 412.329 -
 412.330 -#ifndef NO_READ_FROM_CODER
 412.331 -
 412.332 -STDMETHODIMP CCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
 412.333 -{
 412.334 -  DEFLATE_TRY_BEGIN
 412.335 -  if (processedSize)
 412.336 -    *processedSize = 0;
 412.337 -  const UInt64 startPos = m_OutWindowStream.GetProcessedSize();
 412.338 -  m_OutWindowStream.SetMemStream((Byte *)data);
 412.339 -  RINOK(CodeSpec(size));
 412.340 -  if (processedSize)
 412.341 -    *processedSize = (UInt32)(m_OutWindowStream.GetProcessedSize() - startPos);
 412.342 -  return Flush();
 412.343 -  DEFLATE_TRY_END
 412.344 -}
 412.345 -
 412.346 -#endif
 412.347 -
 412.348 -}}}
   413.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/DeflateDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   413.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   413.3 @@ -1,136 +0,0 @@
   413.4 -// DeflateDecoder.h
   413.5 -
   413.6 -#ifndef __DEFLATE_DECODER_H
   413.7 -#define __DEFLATE_DECODER_H
   413.8 -
   413.9 -#include "../../Common/MyCom.h"
  413.10 -
  413.11 -#include "../ICoder.h"
  413.12 -
  413.13 -#include "../Common/InBuffer.h"
  413.14 -
  413.15 -#include "BitlDecoder.h"
  413.16 -#include "DeflateConst.h"
  413.17 -#include "HuffmanDecoder.h"
  413.18 -#include "LzOutWindow.h"
  413.19 -
  413.20 -namespace NCompress {
  413.21 -namespace NDeflate {
  413.22 -namespace NDecoder {
  413.23 -
  413.24 -class CCoder:
  413.25 -  public ICompressCoder,
  413.26 -  public ICompressGetInStreamProcessedSize,
  413.27 -  #ifndef NO_READ_FROM_CODER
  413.28 -  public ICompressSetInStream,
  413.29 -  public ICompressSetOutStreamSize,
  413.30 -  public ISequentialInStream,
  413.31 -  #endif
  413.32 -  public CMyUnknownImp
  413.33 -{
  413.34 -  CLzOutWindow m_OutWindowStream;
  413.35 -  NBitl::CDecoder<CInBuffer> m_InBitStream;
  413.36 -  NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedMainTableSize> m_MainDecoder;
  413.37 -  NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedDistTableSize> m_DistDecoder;
  413.38 -  NCompress::NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
  413.39 -
  413.40 -  UInt32 m_StoredBlockSize;
  413.41 -
  413.42 -  bool m_FinalBlock;
  413.43 -  bool m_StoredMode;
  413.44 -  UInt32 _numDistLevels;
  413.45 -
  413.46 -
  413.47 -  bool _deflateNSIS;
  413.48 -  bool _deflate64Mode;
  413.49 -  bool _keepHistory;
  413.50 -  Int32 _remainLen;
  413.51 -  UInt32 _rep0;
  413.52 -  bool _needReadTable;
  413.53 -
  413.54 -  UInt32 ReadBits(int numBits);
  413.55 -
  413.56 -  bool DeCodeLevelTable(Byte *values, int numSymbols);
  413.57 -  bool ReadTables();
  413.58 -  
  413.59 -  void ReleaseStreams()
  413.60 -  {
  413.61 -    m_OutWindowStream.ReleaseStream();
  413.62 -    ReleaseInStream();
  413.63 -  }
  413.64 -
  413.65 -  HRESULT Flush() { return m_OutWindowStream.Flush(); }
  413.66 -  class CCoderReleaser
  413.67 -  {
  413.68 -    CCoder *m_Coder;
  413.69 -  public:
  413.70 -    bool NeedFlush;
  413.71 -    CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
  413.72 -    ~CCoderReleaser()
  413.73 -    {
  413.74 -      if (NeedFlush)
  413.75 -        m_Coder->Flush();
  413.76 -      m_Coder->ReleaseStreams();
  413.77 -    }
  413.78 -  };
  413.79 -  friend class CCoderReleaser;
  413.80 -
  413.81 -  HRESULT CodeSpec(UInt32 curSize);
  413.82 -public:
  413.83 -  bool ZlibMode;
  413.84 -  Byte ZlibFooter[4];
  413.85 -
  413.86 -  CCoder(bool deflate64Mode, bool deflateNSIS = false);
  413.87 -  void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
  413.88 -
  413.89 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  413.90 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  413.91 -
  413.92 -  #ifndef NO_READ_FROM_CODER
  413.93 -  MY_UNKNOWN_IMP4(
  413.94 -      ICompressGetInStreamProcessedSize,
  413.95 -      ICompressSetInStream,
  413.96 -      ICompressSetOutStreamSize,
  413.97 -      ISequentialInStream
  413.98 -      )
  413.99 -  #else
 413.100 -  MY_UNKNOWN_IMP1(
 413.101 -      ICompressGetInStreamProcessedSize)
 413.102 -  #endif
 413.103 -
 413.104 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 413.105 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 413.106 -
 413.107 -  STDMETHOD(SetInStream)(ISequentialInStream *inStream);
 413.108 -  STDMETHOD(ReleaseInStream)();
 413.109 -  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
 413.110 -  
 413.111 -  #ifndef NO_READ_FROM_CODER
 413.112 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
 413.113 -  #endif
 413.114 -
 413.115 -  // IGetInStreamProcessedSize
 413.116 -  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
 413.117 -};
 413.118 -
 413.119 -class CCOMCoder : public CCoder
 413.120 -{
 413.121 -public:
 413.122 -  CCOMCoder(): CCoder(false) {}
 413.123 -};
 413.124 -
 413.125 -class CNsisCOMCoder : public CCoder
 413.126 -{
 413.127 -public:
 413.128 -  CNsisCOMCoder(): CCoder(false, true) {}
 413.129 -};
 413.130 -
 413.131 -class CCOMCoder64 : public CCoder
 413.132 -{
 413.133 -public:
 413.134 -  CCOMCoder64(): CCoder(true) {}
 413.135 -};
 413.136 -
 413.137 -}}}
 413.138 -
 413.139 -#endif
   414.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   414.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   414.3 @@ -1,14 +0,0 @@
   414.4 -// DeflateNsisRegister.cpp
   414.5 -
   414.6 -#include "StdAfx.h"
   414.7 -
   414.8 -#include "../Common/RegisterCodec.h"
   414.9 -
  414.10 -#include "DeflateDecoder.h"
  414.11 -
  414.12 -static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); }
  414.13 -
  414.14 -static CCodecInfo g_CodecInfo =
  414.15 -  { CreateCodecDeflateNsis, 0,   0x040901, L"DeflateNSIS", 1, false };
  414.16 -
  414.17 -REGISTER_CODEC(DeflateNsis)
   415.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/DeflateRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   415.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   415.3 @@ -1,21 +0,0 @@
   415.4 -// DeflateRegister.cpp
   415.5 -
   415.6 -#include "StdAfx.h"
   415.7 -
   415.8 -#include "../Common/RegisterCodec.h"
   415.9 -
  415.10 -#include "DeflateDecoder.h"
  415.11 -
  415.12 -static void *CreateCodecDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder); }
  415.13 -
  415.14 -#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
  415.15 -#include "DeflateEncoder.h"
  415.16 -static void *CreateCodecOutDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NEncoder::CCOMCoder);  }
  415.17 -#else
  415.18 -#define CreateCodecOutDeflate 0
  415.19 -#endif
  415.20 -
  415.21 -static CCodecInfo g_CodecInfo =
  415.22 -  { CreateCodecDeflate,   CreateCodecOutDeflate,   0x040108, L"Deflate", 1, false };
  415.23 -
  415.24 -REGISTER_CODEC(Deflate)
   416.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/HuffmanDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   416.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   416.3 @@ -1,89 +0,0 @@
   416.4 -// Compress/HuffmanDecoder.h
   416.5 -
   416.6 -#ifndef __COMPRESS_HUFFMAN_DECODER_H
   416.7 -#define __COMPRESS_HUFFMAN_DECODER_H
   416.8 -
   416.9 -#include "../../Common/Types.h"
  416.10 -
  416.11 -namespace NCompress {
  416.12 -namespace NHuffman {
  416.13 -
  416.14 -const int kNumTableBits = 9;
  416.15 -
  416.16 -template <int kNumBitsMax, UInt32 m_NumSymbols>
  416.17 -class CDecoder
  416.18 -{
  416.19 -  UInt32 m_Limits[kNumBitsMax + 1];     // m_Limits[i] = value limit for symbols with length = i
  416.20 -  UInt32 m_Positions[kNumBitsMax + 1];  // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
  416.21 -  UInt32 m_Symbols[m_NumSymbols];
  416.22 -  Byte m_Lengths[1 << kNumTableBits];   // Table oh length for short codes.
  416.23 -
  416.24 -public:
  416.25 -  
  416.26 -  bool SetCodeLengths(const Byte *codeLengths)
  416.27 -  {
  416.28 -    int lenCounts[kNumBitsMax + 1];
  416.29 -    UInt32 tmpPositions[kNumBitsMax + 1];
  416.30 -    int i;
  416.31 -    for(i = 1; i <= kNumBitsMax; i++)
  416.32 -      lenCounts[i] = 0;
  416.33 -    UInt32 symbol;
  416.34 -    for (symbol = 0; symbol < m_NumSymbols; symbol++)
  416.35 -    {
  416.36 -      int len = codeLengths[symbol];
  416.37 -      if (len > kNumBitsMax)
  416.38 -        return false;
  416.39 -      lenCounts[len]++;
  416.40 -      m_Symbols[symbol] = 0xFFFFFFFF;
  416.41 -    }
  416.42 -    lenCounts[0] = 0;
  416.43 -    m_Positions[0] = m_Limits[0] = 0;
  416.44 -    UInt32 startPos = 0;
  416.45 -    UInt32 index = 0;
  416.46 -    const UInt32 kMaxValue = (1 << kNumBitsMax);
  416.47 -    for (i = 1; i <= kNumBitsMax; i++)
  416.48 -    {
  416.49 -      startPos += lenCounts[i] << (kNumBitsMax - i);
  416.50 -      if (startPos > kMaxValue)
  416.51 -        return false;
  416.52 -      m_Limits[i] = (i == kNumBitsMax) ? kMaxValue : startPos;
  416.53 -      m_Positions[i] = m_Positions[i - 1] + lenCounts[i - 1];
  416.54 -      tmpPositions[i] = m_Positions[i];
  416.55 -      if(i <= kNumTableBits)
  416.56 -      {
  416.57 -        UInt32 limit = (m_Limits[i] >> (kNumBitsMax - kNumTableBits));
  416.58 -        for (; index < limit; index++)
  416.59 -          m_Lengths[index] = (Byte)i;
  416.60 -      }
  416.61 -    }
  416.62 -    for (symbol = 0; symbol < m_NumSymbols; symbol++)
  416.63 -    {
  416.64 -      int len = codeLengths[symbol];
  416.65 -      if (len != 0)
  416.66 -        m_Symbols[tmpPositions[len]++] = symbol;
  416.67 -    }
  416.68 -    return true;
  416.69 -  }
  416.70 -
  416.71 -  template <class TBitDecoder>
  416.72 -  UInt32 DecodeSymbol(TBitDecoder *bitStream)
  416.73 -  {
  416.74 -    int numBits;
  416.75 -    UInt32 value = bitStream->GetValue(kNumBitsMax);
  416.76 -    if (value < m_Limits[kNumTableBits])
  416.77 -      numBits = m_Lengths[value >> (kNumBitsMax - kNumTableBits)];
  416.78 -    else
  416.79 -      for (numBits = kNumTableBits + 1; value >= m_Limits[numBits]; numBits++);
  416.80 -    bitStream->MovePos(numBits);
  416.81 -    UInt32 index = m_Positions[numBits] +
  416.82 -      ((value - m_Limits[numBits - 1]) >> (kNumBitsMax - numBits));
  416.83 -    if (index >= m_NumSymbols)
  416.84 -      // throw CDecoderException(); // test it
  416.85 -      return 0xFFFFFFFF;
  416.86 -    return m_Symbols[index];
  416.87 -  }
  416.88 -};
  416.89 -
  416.90 -}}
  416.91 -
  416.92 -#endif
   417.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ImplodeDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   417.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   417.3 @@ -1,219 +0,0 @@
   417.4 -// Implode/Decoder.cpp
   417.5 -
   417.6 -#include "StdAfx.h"
   417.7 -
   417.8 -#include "ImplodeDecoder.h"
   417.9 -#include "Common/Defs.h"
  417.10 -
  417.11 -namespace NCompress {
  417.12 -namespace NImplode {
  417.13 -namespace NDecoder {
  417.14 -
  417.15 -class CException
  417.16 -{
  417.17 -public:
  417.18 -  enum ECauseType
  417.19 -  {
  417.20 -    kData
  417.21 -  } m_Cause;
  417.22 -  CException(ECauseType cause): m_Cause(cause) {}
  417.23 -};
  417.24 -
  417.25 -static const int kNumDistanceLowDirectBitsForBigDict = 7;
  417.26 -static const int kNumDistanceLowDirectBitsForSmallDict = 6;
  417.27 -
  417.28 -static const int kNumBitsInByte = 8;
  417.29 -
  417.30 -// static const int kLevelStructuresNumberFieldSize = kNumBitsInByte;
  417.31 -static const int kLevelStructuresNumberAdditionalValue = 1;
  417.32 -
  417.33 -static const int kNumLevelStructureLevelBits = 4;
  417.34 -static const int kLevelStructureLevelAdditionalValue = 1;
  417.35 -
  417.36 -static const int kNumLevelStructureRepNumberBits = 4;
  417.37 -static const int kLevelStructureRepNumberAdditionalValue = 1;
  417.38 -
  417.39 -
  417.40 -static const int kLiteralTableSize = (1 << kNumBitsInByte);
  417.41 -static const int kDistanceTableSize = 64;
  417.42 -static const int kLengthTableSize = 64;
  417.43 -
  417.44 -static const UInt32 kHistorySize =
  417.45 -    (1 << MyMax(kNumDistanceLowDirectBitsForBigDict,
  417.46 -                kNumDistanceLowDirectBitsForSmallDict)) *
  417.47 -    kDistanceTableSize; // = 8 KB;
  417.48 -
  417.49 -static const int kNumAdditionalLengthBits = 8;
  417.50 -
  417.51 -static const UInt32 kMatchMinLenWhenLiteralsOn = 3;
  417.52 -static const UInt32 kMatchMinLenWhenLiteralsOff = 2;
  417.53 -
  417.54 -static const UInt32 kMatchMinLenMax = MyMax(kMatchMinLenWhenLiteralsOn,
  417.55 -    kMatchMinLenWhenLiteralsOff);  // 3
  417.56 -
  417.57 -// static const UInt32 kMatchMaxLenMax = kMatchMinLenMax + (kLengthTableSize - 1) + (1 << kNumAdditionalLengthBits) - 1;  // or 2
  417.58 -
  417.59 -enum
  417.60 -{
  417.61 -  kMatchId = 0,
  417.62 -  kLiteralId = 1
  417.63 -};
  417.64 -
  417.65 -
  417.66 -CCoder::CCoder():
  417.67 -  m_LiteralDecoder(kLiteralTableSize),
  417.68 -  m_LengthDecoder(kLengthTableSize),
  417.69 -  m_DistanceDecoder(kDistanceTableSize)
  417.70 -{
  417.71 -}
  417.72 -
  417.73 -void CCoder::ReleaseStreams()
  417.74 -{
  417.75 -  m_OutWindowStream.ReleaseStream();
  417.76 -  m_InBitStream.ReleaseStream();
  417.77 -}
  417.78 -
  417.79 -bool CCoder::ReadLevelItems(NImplode::NHuffman::CDecoder &decoder,
  417.80 -    Byte *levels, int numLevelItems)
  417.81 -{
  417.82 -  int numCodedStructures = m_InBitStream.ReadBits(kNumBitsInByte) +
  417.83 -      kLevelStructuresNumberAdditionalValue;
  417.84 -  int currentIndex = 0;
  417.85 -  for(int i = 0; i < numCodedStructures; i++)
  417.86 -  {
  417.87 -    int level = m_InBitStream.ReadBits(kNumLevelStructureLevelBits) +
  417.88 -      kLevelStructureLevelAdditionalValue;
  417.89 -    int rep = m_InBitStream.ReadBits(kNumLevelStructureRepNumberBits) +
  417.90 -      kLevelStructureRepNumberAdditionalValue;
  417.91 -    if (currentIndex + rep > numLevelItems)
  417.92 -      throw CException(CException::kData);
  417.93 -    for(int j = 0; j < rep; j++)
  417.94 -      levels[currentIndex++] = (Byte)level;
  417.95 -  }
  417.96 -  if (currentIndex != numLevelItems)
  417.97 -    return false;
  417.98 -  return decoder.SetCodeLengths(levels);
  417.99 -}
 417.100 -
 417.101 -
 417.102 -bool CCoder::ReadTables(void)
 417.103 -{
 417.104 -  if (m_LiteralsOn)
 417.105 -  {
 417.106 -    Byte literalLevels[kLiteralTableSize];
 417.107 -    if (!ReadLevelItems(m_LiteralDecoder, literalLevels, kLiteralTableSize))
 417.108 -      return false;
 417.109 -  }
 417.110 -
 417.111 -  Byte lengthLevels[kLengthTableSize];
 417.112 -  if (!ReadLevelItems(m_LengthDecoder, lengthLevels, kLengthTableSize))
 417.113 -    return false;
 417.114 -
 417.115 -  Byte distanceLevels[kDistanceTableSize];
 417.116 -  return ReadLevelItems(m_DistanceDecoder, distanceLevels, kDistanceTableSize);
 417.117 -}
 417.118 -
 417.119 -class CCoderReleaser
 417.120 -{
 417.121 -  CCoder *m_Coder;
 417.122 -public:
 417.123 -  CCoderReleaser(CCoder *coder): m_Coder(coder) {}
 417.124 -  ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
 417.125 -};
 417.126 -
 417.127 -HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 417.128 -    const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
 417.129 -{
 417.130 -  if (!m_InBitStream.Create(1 << 20))
 417.131 -    return E_OUTOFMEMORY;
 417.132 -  if (!m_OutWindowStream.Create(kHistorySize))
 417.133 -    return E_OUTOFMEMORY;
 417.134 -  if (outSize == NULL)
 417.135 -    return E_INVALIDARG;
 417.136 -  UInt64 pos = 0, unPackSize = *outSize;
 417.137 -
 417.138 -  m_OutWindowStream.SetStream(outStream);
 417.139 -  m_OutWindowStream.Init(false);
 417.140 -  m_InBitStream.SetStream(inStream);
 417.141 -  m_InBitStream.Init();
 417.142 -  CCoderReleaser coderReleaser(this);
 417.143 -
 417.144 -  if (!ReadTables())
 417.145 -    return S_FALSE;
 417.146 -  
 417.147 -  while(pos < unPackSize)
 417.148 -  {
 417.149 -    if (progress != NULL && pos % (1 << 16) == 0)
 417.150 -    {
 417.151 -      UInt64 packSize = m_InBitStream.GetProcessedSize();
 417.152 -      RINOK(progress->SetRatioInfo(&packSize, &pos));
 417.153 -    }
 417.154 -    if(m_InBitStream.ReadBits(1) == kMatchId) // match
 417.155 -    {
 417.156 -      UInt32 lowDistBits = m_InBitStream.ReadBits(m_NumDistanceLowDirectBits);
 417.157 -      UInt32 distance = m_DistanceDecoder.DecodeSymbol(&m_InBitStream);
 417.158 -      if (distance >= kDistanceTableSize)
 417.159 -        return S_FALSE;
 417.160 -      distance = (distance << m_NumDistanceLowDirectBits) + lowDistBits;
 417.161 -      UInt32 lengthSymbol = m_LengthDecoder.DecodeSymbol(&m_InBitStream);
 417.162 -      if (lengthSymbol >= kLengthTableSize)
 417.163 -        return S_FALSE;
 417.164 -      UInt32 length = lengthSymbol + m_MinMatchLength;
 417.165 -      if (lengthSymbol == kLengthTableSize - 1) // special symbol  = 63
 417.166 -        length += m_InBitStream.ReadBits(kNumAdditionalLengthBits);
 417.167 -      while(distance >= pos && length > 0)
 417.168 -      {
 417.169 -        m_OutWindowStream.PutByte(0);
 417.170 -        pos++;
 417.171 -        length--;
 417.172 -      }
 417.173 -      if (length > 0)
 417.174 -        m_OutWindowStream.CopyBlock(distance, length);
 417.175 -      pos += length;
 417.176 -    }
 417.177 -    else
 417.178 -    {
 417.179 -      Byte b;
 417.180 -      if (m_LiteralsOn)
 417.181 -      {
 417.182 -        UInt32 temp = m_LiteralDecoder.DecodeSymbol(&m_InBitStream);
 417.183 -        if (temp >= kLiteralTableSize)
 417.184 -          return S_FALSE;
 417.185 -        b = (Byte)temp;
 417.186 -      }
 417.187 -      else
 417.188 -        b = (Byte)m_InBitStream.ReadBits(kNumBitsInByte);
 417.189 -      m_OutWindowStream.PutByte(b);
 417.190 -      pos++;
 417.191 -    }
 417.192 -  }
 417.193 -  if (pos > unPackSize)
 417.194 -    return S_FALSE;
 417.195 -  return m_OutWindowStream.Flush();
 417.196 -}
 417.197 -
 417.198 -STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 417.199 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 417.200 -{
 417.201 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress);  }
 417.202 -  catch(const CLzOutWindowException &e) { return e.ErrorCode; }
 417.203 -  catch(...) { return S_FALSE; }
 417.204 -}
 417.205 -
 417.206 -STDMETHODIMP CCoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 417.207 -{
 417.208 -  if (size < 1)
 417.209 -    return E_INVALIDARG;
 417.210 -  Byte flag = data[0];
 417.211 -  m_BigDictionaryOn = ((flag & 2) != 0);
 417.212 -  m_NumDistanceLowDirectBits = m_BigDictionaryOn ?
 417.213 -      kNumDistanceLowDirectBitsForBigDict:
 417.214 -      kNumDistanceLowDirectBitsForSmallDict;
 417.215 -  m_LiteralsOn = ((flag & 4) != 0);
 417.216 -  m_MinMatchLength = m_LiteralsOn ?
 417.217 -      kMatchMinLenWhenLiteralsOn :
 417.218 -      kMatchMinLenWhenLiteralsOff;
 417.219 -  return S_OK;
 417.220 -}
 417.221 -
 417.222 -}}}
   418.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ImplodeDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   418.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   418.3 @@ -1,57 +0,0 @@
   418.4 -// ImplodeDecoder.h
   418.5 -
   418.6 -#ifndef __COMPRESS_IMPLODE_DECODER_H
   418.7 -#define __COMPRESS_IMPLODE_DECODER_H
   418.8 -
   418.9 -#include "../../Common/MyCom.h"
  418.10 -
  418.11 -#include "../ICoder.h"
  418.12 -
  418.13 -#include "ImplodeHuffmanDecoder.h"
  418.14 -#include "LzOutWindow.h"
  418.15 -
  418.16 -namespace NCompress {
  418.17 -namespace NImplode {
  418.18 -namespace NDecoder {
  418.19 -
  418.20 -class CCoder:
  418.21 -  public ICompressCoder,
  418.22 -  public ICompressSetDecoderProperties2,
  418.23 -  public CMyUnknownImp
  418.24 -{
  418.25 -  CLzOutWindow m_OutWindowStream;
  418.26 -  NBitl::CDecoder<CInBuffer> m_InBitStream;
  418.27 -  
  418.28 -  NImplode::NHuffman::CDecoder m_LiteralDecoder;
  418.29 -  NImplode::NHuffman::CDecoder m_LengthDecoder;
  418.30 -  NImplode::NHuffman::CDecoder m_DistanceDecoder;
  418.31 -
  418.32 -  bool m_BigDictionaryOn;
  418.33 -  bool m_LiteralsOn;
  418.34 -
  418.35 -  int m_NumDistanceLowDirectBits;
  418.36 -  UInt32 m_MinMatchLength;
  418.37 -
  418.38 -  bool ReadLevelItems(NImplode::NHuffman::CDecoder &table, Byte *levels, int numLevelItems);
  418.39 -  bool ReadTables();
  418.40 -  void DeCodeLevelTable(Byte *newLevels, int numLevels);
  418.41 -public:
  418.42 -  CCoder();
  418.43 -
  418.44 -  MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
  418.45 -
  418.46 -  void ReleaseStreams();
  418.47 -  HRESULT Flush() { return m_OutWindowStream.Flush(); }
  418.48 -
  418.49 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  418.50 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  418.51 -
  418.52 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  418.53 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  418.54 -
  418.55 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
  418.56 -};
  418.57 -
  418.58 -}}}
  418.59 -
  418.60 -#endif
   419.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   419.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   419.3 @@ -1,89 +0,0 @@
   419.4 -// ImplodeHuffmanDecoder.cpp
   419.5 -
   419.6 -#include "StdAfx.h"
   419.7 -
   419.8 -#include "ImplodeHuffmanDecoder.h"
   419.9 -
  419.10 -namespace NCompress {
  419.11 -namespace NImplode {
  419.12 -namespace NHuffman {
  419.13 -
  419.14 -CDecoder::CDecoder(UInt32 numSymbols):
  419.15 -  m_NumSymbols(numSymbols)
  419.16 -{
  419.17 -  m_Symbols = new UInt32[m_NumSymbols];
  419.18 -}
  419.19 -
  419.20 -CDecoder::~CDecoder()
  419.21 -{
  419.22 -  delete []m_Symbols;
  419.23 -}
  419.24 -
  419.25 -bool CDecoder::SetCodeLengths(const Byte *codeLengths)
  419.26 -{
  419.27 -  // int lenCounts[kNumBitsInLongestCode + 1], tmpPositions[kNumBitsInLongestCode + 1];
  419.28 -  int lenCounts[kNumBitsInLongestCode + 2], tmpPositions[kNumBitsInLongestCode + 1];
  419.29 -  int i;
  419.30 -  for(i = 0; i <= kNumBitsInLongestCode; i++)
  419.31 -    lenCounts[i] = 0;
  419.32 -  UInt32 symbolIndex;
  419.33 -  for (symbolIndex = 0; symbolIndex < m_NumSymbols; symbolIndex++)
  419.34 -    lenCounts[codeLengths[symbolIndex]]++;
  419.35 -  // lenCounts[0] = 0;
  419.36 -  
  419.37 -  // tmpPositions[0] = m_Positions[0] = m_Limitits[0] = 0;
  419.38 -  m_Limitits[kNumBitsInLongestCode + 1] = 0;
  419.39 -  m_Positions[kNumBitsInLongestCode + 1] = 0;
  419.40 -  lenCounts[kNumBitsInLongestCode + 1] = 0;
  419.41 -
  419.42 -
  419.43 -  UInt32 startPos = 0;
  419.44 -  static const UInt32 kMaxValue = (1 << kNumBitsInLongestCode);
  419.45 -
  419.46 -  for (i = kNumBitsInLongestCode; i > 0; i--)
  419.47 -  {
  419.48 -    startPos += lenCounts[i] << (kNumBitsInLongestCode - i);
  419.49 -    if (startPos > kMaxValue)
  419.50 -      return false;
  419.51 -    m_Limitits[i] = startPos;
  419.52 -    m_Positions[i] = m_Positions[i + 1] + lenCounts[i + 1];
  419.53 -    tmpPositions[i] = m_Positions[i] + lenCounts[i];
  419.54 -
  419.55 -  }
  419.56 -
  419.57 -  // if _ZIP_MODE do not throw exception for trees containing only one node
  419.58 -  // #ifndef _ZIP_MODE
  419.59 -  if (startPos != kMaxValue)
  419.60 -    return false;
  419.61 -  // #endif
  419.62 -
  419.63 -  for (symbolIndex = 0; symbolIndex < m_NumSymbols; symbolIndex++)
  419.64 -    if (codeLengths[symbolIndex] != 0)
  419.65 -      m_Symbols[--tmpPositions[codeLengths[symbolIndex]]] = symbolIndex;
  419.66 -  return true;
  419.67 -}
  419.68 -
  419.69 -UInt32 CDecoder::DecodeSymbol(CInBit *inStream)
  419.70 -{
  419.71 -  UInt32 numBits = 0;
  419.72 -  UInt32 value = inStream->GetValue(kNumBitsInLongestCode);
  419.73 -  int i;
  419.74 -  for(i = kNumBitsInLongestCode; i > 0; i--)
  419.75 -  {
  419.76 -    if (value < m_Limitits[i])
  419.77 -    {
  419.78 -      numBits = i;
  419.79 -      break;
  419.80 -    }
  419.81 -  }
  419.82 -  if (i == 0)
  419.83 -    return 0xFFFFFFFF;
  419.84 -  inStream->MovePos(numBits);
  419.85 -  UInt32 index = m_Positions[numBits] +
  419.86 -      ((value - m_Limitits[numBits + 1]) >> (kNumBitsInLongestCode - numBits));
  419.87 -  if (index >= m_NumSymbols)
  419.88 -    return 0xFFFFFFFF;
  419.89 -  return m_Symbols[index];
  419.90 -}
  419.91 -
  419.92 -}}}
   420.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   420.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   420.3 @@ -1,34 +0,0 @@
   420.4 -// ImplodeHuffmanDecoder.h
   420.5 -
   420.6 -#ifndef __IMPLODE_HUFFMAN_DECODER_H
   420.7 -#define __IMPLODE_HUFFMAN_DECODER_H
   420.8 -
   420.9 -#include "../Common/InBuffer.h"
  420.10 -
  420.11 -#include "BitlDecoder.h"
  420.12 -
  420.13 -namespace NCompress {
  420.14 -namespace NImplode {
  420.15 -namespace NHuffman {
  420.16 -
  420.17 -const int kNumBitsInLongestCode = 16;
  420.18 -
  420.19 -typedef NBitl::CDecoder<CInBuffer> CInBit;
  420.20 -
  420.21 -class CDecoder
  420.22 -{
  420.23 -  UInt32 m_Limitits[kNumBitsInLongestCode + 2]; // m_Limitits[i] = value limit for symbols with length = i
  420.24 -  UInt32 m_Positions[kNumBitsInLongestCode + 2];   // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
  420.25 -  UInt32 m_NumSymbols; // number of symbols in m_Symbols
  420.26 -  UInt32 *m_Symbols; // symbols: at first with len=1 then 2, ... 15.
  420.27 -public:
  420.28 -  CDecoder(UInt32 numSymbols);
  420.29 -  ~CDecoder();
  420.30 -  
  420.31 -  bool SetCodeLengths(const Byte *codeLengths);
  420.32 -  UInt32 DecodeSymbol(CInBit *inStream);
  420.33 -};
  420.34 -
  420.35 -}}}
  420.36 -
  420.37 -#endif
   421.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.cpp	Sat Mar 03 10:54:39 2012 -0600
   421.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   421.3 @@ -1,14 +0,0 @@
   421.4 -// LzOutWindow.cpp
   421.5 -
   421.6 -#include "StdAfx.h"
   421.7 -
   421.8 -#include "LzOutWindow.h"
   421.9 -
  421.10 -void CLzOutWindow::Init(bool solid)
  421.11 -{
  421.12 -  if (!solid)
  421.13 -    COutBuffer::Init();
  421.14 -  #ifdef _NO_EXCEPTIONS
  421.15 -  ErrorCode = S_OK;
  421.16 -  #endif
  421.17 -}
   422.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.h	Sat Mar 03 10:54:39 2012 -0600
   422.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   422.3 @@ -1,66 +0,0 @@
   422.4 -// LzOutWindow.h
   422.5 -
   422.6 -#ifndef __LZ_OUT_WINDOW_H
   422.7 -#define __LZ_OUT_WINDOW_H
   422.8 -
   422.9 -#include "../IStream.h"
  422.10 -
  422.11 -#include "../Common/OutBuffer.h"
  422.12 -
  422.13 -#ifndef _NO_EXCEPTIONS
  422.14 -typedef COutBufferException CLzOutWindowException;
  422.15 -#endif
  422.16 -
  422.17 -class CLzOutWindow: public COutBuffer
  422.18 -{
  422.19 -public:
  422.20 -  void Init(bool solid = false);
  422.21 -  
  422.22 -  // distance >= 0, len > 0,
  422.23 -  bool CopyBlock(UInt32 distance, UInt32 len)
  422.24 -  {
  422.25 -    UInt32 pos = _pos - distance - 1;
  422.26 -    if (distance >= _pos)
  422.27 -    {
  422.28 -      if (!_overDict || distance >= _bufferSize)
  422.29 -        return false;
  422.30 -      pos += _bufferSize;
  422.31 -    }
  422.32 -    if (_limitPos - _pos > len && _bufferSize - pos > len)
  422.33 -    {
  422.34 -      const Byte *src = _buffer + pos;
  422.35 -      Byte *dest = _buffer + _pos;
  422.36 -      _pos += len;
  422.37 -      do
  422.38 -        *dest++ = *src++;
  422.39 -      while(--len != 0);
  422.40 -    }
  422.41 -    else do
  422.42 -    {
  422.43 -      if (pos == _bufferSize)
  422.44 -        pos = 0;
  422.45 -      _buffer[_pos++] = _buffer[pos++];
  422.46 -      if (_pos == _limitPos)
  422.47 -        FlushWithCheck();
  422.48 -    }
  422.49 -    while(--len != 0);
  422.50 -    return true;
  422.51 -  }
  422.52 -  
  422.53 -  void PutByte(Byte b)
  422.54 -  {
  422.55 -    _buffer[_pos++] = b;
  422.56 -    if (_pos == _limitPos)
  422.57 -      FlushWithCheck();
  422.58 -  }
  422.59 -  
  422.60 -  Byte GetByte(UInt32 distance) const
  422.61 -  {
  422.62 -    UInt32 pos = _pos - distance - 1;
  422.63 -    if (pos >= _bufferSize)
  422.64 -      pos += _bufferSize;
  422.65 -    return _buffer[pos];
  422.66 -  }
  422.67 -};
  422.68 -
  422.69 -#endif
   423.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzhDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   423.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   423.3 @@ -1,220 +0,0 @@
   423.4 -// LzhDecoder.cpp
   423.5 -
   423.6 -#include "StdAfx.h"
   423.7 -
   423.8 -#include "LzhDecoder.h"
   423.9 -
  423.10 -#include "Windows/Defs.h"
  423.11 -
  423.12 -namespace NCompress{
  423.13 -namespace NLzh {
  423.14 -namespace NDecoder {
  423.15 -
  423.16 -static const UInt32 kHistorySize = (1 << 16);
  423.17 -
  423.18 -static const int kBlockSizeBits = 16;
  423.19 -static const int kNumCBits = 9;
  423.20 -static const int kNumLevelBits = 5; // smallest integer such that (1 << kNumLevelBits) > kNumLevelSymbols/
  423.21 -
  423.22 -UInt32 CCoder::ReadBits(int numBits) {  return m_InBitStream.ReadBits(numBits); }
  423.23 -
  423.24 -HRESULT CCoder::ReadLevelTable()
  423.25 -{
  423.26 -  int n = ReadBits(kNumLevelBits);
  423.27 -  if (n == 0)
  423.28 -  {
  423.29 -    m_LevelHuffman.Symbol = ReadBits(kNumLevelBits);
  423.30 -    if (m_LevelHuffman.Symbol >= kNumLevelSymbols)
  423.31 -      return S_FALSE;
  423.32 -  }
  423.33 -  else
  423.34 -  {
  423.35 -    if (n > kNumLevelSymbols)
  423.36 -      return S_FALSE;
  423.37 -    m_LevelHuffman.Symbol = -1;
  423.38 -    Byte lens[kNumLevelSymbols];
  423.39 -    int i = 0;
  423.40 -    while (i < n)
  423.41 -    {
  423.42 -      int c = m_InBitStream.ReadBits(3);
  423.43 -      if (c == 7)
  423.44 -        while (ReadBits(1))
  423.45 -          if (c++ > kMaxHuffmanLen)
  423.46 -            return S_FALSE;
  423.47 -      lens[i++] = (Byte)c;
  423.48 -      if (i == kNumSpecLevelSymbols)
  423.49 -      {
  423.50 -        c = ReadBits(2);
  423.51 -        while (--c >= 0)
  423.52 -          lens[i++] = 0;
  423.53 -      }
  423.54 -    }
  423.55 -    while (i < kNumLevelSymbols)
  423.56 -      lens[i++] = 0;
  423.57 -    m_LevelHuffman.SetCodeLengths(lens);
  423.58 -  }
  423.59 -  return S_OK;
  423.60 -}
  423.61 -
  423.62 -HRESULT CCoder::ReadPTable(int numBits)
  423.63 -{
  423.64 -  int n = ReadBits(numBits);
  423.65 -  if (n == 0)
  423.66 -  {
  423.67 -    m_PHuffmanDecoder.Symbol = ReadBits(numBits);
  423.68 -    if (m_PHuffmanDecoder.Symbol >= kNumDistanceSymbols)
  423.69 -      return S_FALSE;
  423.70 -  }
  423.71 -  else
  423.72 -  {
  423.73 -    if (n > kNumDistanceSymbols)
  423.74 -      return S_FALSE;
  423.75 -    m_PHuffmanDecoder.Symbol = -1;
  423.76 -    Byte lens[kNumDistanceSymbols];
  423.77 -    int i = 0;
  423.78 -    while (i < n)
  423.79 -    {
  423.80 -      int c = m_InBitStream.ReadBits(3);
  423.81 -      if (c == 7)
  423.82 -        while (ReadBits(1))
  423.83 -        {
  423.84 -          if (c > kMaxHuffmanLen)
  423.85 -            return S_FALSE;
  423.86 -          c++;
  423.87 -        }
  423.88 -      lens[i++] = (Byte)c;
  423.89 -    }
  423.90 -    while (i < kNumDistanceSymbols)
  423.91 -      lens[i++] = 0;
  423.92 -    m_PHuffmanDecoder.SetCodeLengths(lens);
  423.93 -  }
  423.94 -  return S_OK;
  423.95 -}
  423.96 -
  423.97 -HRESULT CCoder::ReadCTable()
  423.98 -{
  423.99 -  int n = ReadBits(kNumCBits);
 423.100 -  if (n == 0)
 423.101 -  {
 423.102 -    m_CHuffmanDecoder.Symbol = ReadBits(kNumCBits);
 423.103 -    if (m_CHuffmanDecoder.Symbol >= kNumCSymbols)
 423.104 -      return S_FALSE;
 423.105 -  }
 423.106 -  else
 423.107 -  {
 423.108 -    if (n > kNumCSymbols)
 423.109 -      return S_FALSE;
 423.110 -    m_CHuffmanDecoder.Symbol = -1;
 423.111 -    Byte lens[kNumCSymbols];
 423.112 -    int i = 0;
 423.113 -    while (i < n)
 423.114 -    {
 423.115 -      int c = m_LevelHuffman.Decode(&m_InBitStream);
 423.116 -      if (c < kNumSpecLevelSymbols)
 423.117 -      {
 423.118 -        if (c == 0)
 423.119 -          c = 1;
 423.120 -        else if (c == 1)
 423.121 -          c = ReadBits(4) + 3;
 423.122 -        else
 423.123 -          c = ReadBits(kNumCBits) + 20;
 423.124 -        while (--c >= 0)
 423.125 -        {
 423.126 -          if (i > kNumCSymbols)
 423.127 -            return S_FALSE;
 423.128 -          lens[i++] = 0;
 423.129 -        }
 423.130 -      }
 423.131 -      else
 423.132 -        lens[i++] = (Byte)(c - 2);
 423.133 -    }
 423.134 -    while (i < kNumCSymbols)
 423.135 -      lens[i++] = 0;
 423.136 -    m_CHuffmanDecoder.SetCodeLengths(lens);
 423.137 -  }
 423.138 -  return S_OK;
 423.139 -}
 423.140 -
 423.141 -STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
 423.142 -    ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
 423.143 -    ICompressProgressInfo *progress)
 423.144 -{
 423.145 -  if (outSize == NULL)
 423.146 -    return E_INVALIDARG;
 423.147 -
 423.148 -  if (!m_OutWindowStream.Create(kHistorySize))
 423.149 -    return E_OUTOFMEMORY;
 423.150 -  if (!m_InBitStream.Create(1 << 20))
 423.151 -    return E_OUTOFMEMORY;
 423.152 -
 423.153 -  UInt64 pos = 0;
 423.154 -  m_OutWindowStream.SetStream(outStream);
 423.155 -  m_OutWindowStream.Init(false);
 423.156 -  m_InBitStream.SetStream(inStream);
 423.157 -  m_InBitStream.Init();
 423.158 -  
 423.159 -  CCoderReleaser coderReleaser(this);
 423.160 -
 423.161 -  int pbit;
 423.162 -  if (m_NumDictBits <= 13)
 423.163 -    pbit = 4;
 423.164 -  else
 423.165 -    pbit = 5;
 423.166 -
 423.167 -  UInt32 blockSize = 0;
 423.168 -
 423.169 -  while(pos < *outSize)
 423.170 -  {
 423.171 -    // for (i = 0; i < dictSize; i++) dtext[i] = 0x20;
 423.172 -    
 423.173 -    if (blockSize == 0)
 423.174 -    {
 423.175 -      if (progress != NULL)
 423.176 -      {
 423.177 -        UInt64 packSize = m_InBitStream.GetProcessedSize();
 423.178 -        RINOK(progress->SetRatioInfo(&packSize, &pos));
 423.179 -      }
 423.180 -      blockSize = ReadBits(kBlockSizeBits);
 423.181 -      ReadLevelTable();
 423.182 -      ReadCTable();
 423.183 -      RINOK(ReadPTable(pbit));
 423.184 -    }
 423.185 -    blockSize--;
 423.186 -    UInt32 c = m_CHuffmanDecoder.Decode(&m_InBitStream);
 423.187 -    if (c < 256)
 423.188 -    {
 423.189 -      m_OutWindowStream.PutByte((Byte)c);
 423.190 -      pos++;
 423.191 -    }
 423.192 -    else if (c >= kNumCSymbols)
 423.193 -      return S_FALSE;
 423.194 -    else
 423.195 -    {
 423.196 -      // offset = (interface->method == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3;
 423.197 -      UInt32 len  = c - 256 + kMinMatch;
 423.198 -      UInt32 distance = m_PHuffmanDecoder.Decode(&m_InBitStream);
 423.199 -      if (distance != 0)
 423.200 -        distance = (1 << (distance - 1)) + ReadBits(distance - 1);
 423.201 -      if (distance >= pos)
 423.202 -        return S_FALSE;
 423.203 -      if (pos + len > *outSize)
 423.204 -        len = (UInt32)(*outSize - pos);
 423.205 -      pos += len;
 423.206 -      m_OutWindowStream.CopyBlock(distance, len);
 423.207 -    }
 423.208 -  }
 423.209 -  coderReleaser.NeedFlush = false;
 423.210 -  return m_OutWindowStream.Flush();
 423.211 -}
 423.212 -
 423.213 -STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
 423.214 -    ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
 423.215 -    ICompressProgressInfo *progress)
 423.216 -{
 423.217 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
 423.218 -  catch(const CInBufferException &e) { return e.ErrorCode; }
 423.219 -  catch(const CLzOutWindowException &e) { return e.ErrorCode; }
 423.220 -  catch(...) { return S_FALSE; }
 423.221 -}
 423.222 -
 423.223 -}}}
   424.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzhDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   424.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   424.3 @@ -1,106 +0,0 @@
   424.4 -// LzhDecoder.h
   424.5 -
   424.6 -#ifndef __COMPRESS_LZH_DECODER_H
   424.7 -#define __COMPRESS_LZH_DECODER_H
   424.8 -
   424.9 -#include "../../Common/MyCom.h"
  424.10 -
  424.11 -#include "../ICoder.h"
  424.12 -
  424.13 -#include "../Common/InBuffer.h"
  424.14 -
  424.15 -#include "BitmDecoder.h"
  424.16 -#include "HuffmanDecoder.h"
  424.17 -#include "LzOutWindow.h"
  424.18 -
  424.19 -namespace NCompress {
  424.20 -namespace NLzh {
  424.21 -namespace NDecoder {
  424.22 -
  424.23 -const int kMaxHuffmanLen = 16; // Check it
  424.24 -
  424.25 -const int kNumSpecLevelSymbols = 3;
  424.26 -const int kNumLevelSymbols = kNumSpecLevelSymbols + kMaxHuffmanLen;
  424.27 -
  424.28 -const int kDictBitsMax = 16;
  424.29 -const int kNumDistanceSymbols = kDictBitsMax + 1;
  424.30 -
  424.31 -const int kMaxMatch = 256;
  424.32 -const int kMinMatch = 3;
  424.33 -const int kNumCSymbols = 256 + kMaxMatch + 2 - kMinMatch;
  424.34 -
  424.35 -template <UInt32 m_NumSymbols>
  424.36 -class CHuffmanDecoder:public NCompress::NHuffman::CDecoder<kMaxHuffmanLen, m_NumSymbols>
  424.37 -{
  424.38 -public:
  424.39 -  int Symbol;
  424.40 -  template <class TBitDecoder>
  424.41 -  UInt32 Decode(TBitDecoder *bitStream)
  424.42 -  {
  424.43 -    if (Symbol >= 0)
  424.44 -      return (UInt32)Symbol;
  424.45 -    return DecodeSymbol(bitStream);
  424.46 -  }
  424.47 -};
  424.48 -
  424.49 -class CCoder :
  424.50 -  public ICompressCoder,
  424.51 -  public CMyUnknownImp
  424.52 -{
  424.53 -  CLzOutWindow m_OutWindowStream;
  424.54 -  NBitm::CDecoder<CInBuffer> m_InBitStream;
  424.55 -
  424.56 -  int m_NumDictBits;
  424.57 -
  424.58 -  CHuffmanDecoder<kNumLevelSymbols> m_LevelHuffman;
  424.59 -  CHuffmanDecoder<kNumDistanceSymbols> m_PHuffmanDecoder;
  424.60 -  CHuffmanDecoder<kNumCSymbols> m_CHuffmanDecoder;
  424.61 -
  424.62 -  void ReleaseStreams()
  424.63 -  {
  424.64 -    m_OutWindowStream.ReleaseStream();
  424.65 -    m_InBitStream.ReleaseStream();
  424.66 -  }
  424.67 -
  424.68 -  class CCoderReleaser
  424.69 -  {
  424.70 -    CCoder *m_Coder;
  424.71 -  public:
  424.72 -    bool NeedFlush;
  424.73 -    CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
  424.74 -    ~CCoderReleaser()
  424.75 -    {
  424.76 -      if (NeedFlush)
  424.77 -        m_Coder->m_OutWindowStream.Flush();
  424.78 -      m_Coder->ReleaseStreams();
  424.79 -    }
  424.80 -  };
  424.81 -  friend class CCoderReleaser;
  424.82 -
  424.83 -  void MakeTable(int nchar, Byte *bitlen, int tablebits,
  424.84 -      UInt32 *table, int tablesize);
  424.85 -  
  424.86 -  UInt32 ReadBits(int numBits);
  424.87 -  HRESULT ReadLevelTable();
  424.88 -  HRESULT ReadPTable(int numBits);
  424.89 -  HRESULT ReadCTable();
  424.90 -
  424.91 -public:
  424.92 -  
  424.93 -  MY_UNKNOWN_IMP
  424.94 -
  424.95 -  STDMETHOD(CodeReal)(ISequentialInStream *inStream,
  424.96 -      ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
  424.97 -      ICompressProgressInfo *progress);
  424.98 -
  424.99 -  STDMETHOD(Code)(ISequentialInStream *inStream,
 424.100 -      ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
 424.101 -      ICompressProgressInfo *progress);
 424.102 -
 424.103 -  void SetDictionary(int numDictBits) { m_NumDictBits = numDictBits; }
 424.104 -  CCoder(): m_NumDictBits(0) {}
 424.105 -};
 424.106 -
 424.107 -}}}
 424.108 -
 424.109 -#endif
   425.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzmaDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   425.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   425.3 @@ -1,190 +0,0 @@
   425.4 -// LzmaDecoder.cpp
   425.5 -
   425.6 -#include "StdAfx.h"
   425.7 -
   425.8 -extern "C"
   425.9 -{
  425.10 -#include "../../../C/Alloc.h"
  425.11 -}
  425.12 -
  425.13 -#include "../Common/StreamUtils.h"
  425.14 -
  425.15 -#include "LzmaDecoder.h"
  425.16 -
  425.17 -static HRESULT SResToHRESULT(SRes res)
  425.18 -{
  425.19 -  switch(res)
  425.20 -  {
  425.21 -    case SZ_OK: return S_OK;
  425.22 -    case SZ_ERROR_MEM: return E_OUTOFMEMORY;
  425.23 -    case SZ_ERROR_PARAM: return E_INVALIDARG;
  425.24 -    case SZ_ERROR_UNSUPPORTED: return E_NOTIMPL;
  425.25 -    // case SZ_ERROR_PROGRESS: return E_ABORT;
  425.26 -    case SZ_ERROR_DATA: return S_FALSE;
  425.27 -  }
  425.28 -  return E_FAIL;
  425.29 -}
  425.30 -
  425.31 -namespace NCompress {
  425.32 -namespace NLzma {
  425.33 -
  425.34 -static const UInt32 kInBufSize = 1 << 20;
  425.35 -
  425.36 -CDecoder::CDecoder(): _inBuf(0), _outSizeDefined(false), FinishStream(false)
  425.37 -{
  425.38 -  LzmaDec_Construct(&_state);
  425.39 -}
  425.40 -
  425.41 -static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
  425.42 -static void SzFree(void *p, void *address) { p = p; MyFree(address); }
  425.43 -static ISzAlloc g_Alloc = { SzAlloc, SzFree };
  425.44 -
  425.45 -CDecoder::~CDecoder()
  425.46 -{
  425.47 -  LzmaDec_Free(&_state, &g_Alloc);
  425.48 -  MyFree(_inBuf);
  425.49 -}
  425.50 -
  425.51 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
  425.52 -{
  425.53 -  RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_Alloc)));
  425.54 -
  425.55 -  if (_inBuf == 0)
  425.56 -  {
  425.57 -    _inBuf = (Byte *)MyAlloc(kInBufSize);
  425.58 -    if (_inBuf == 0)
  425.59 -      return E_OUTOFMEMORY;
  425.60 -  }
  425.61 -
  425.62 -  return S_OK;
  425.63 -}
  425.64 -
  425.65 -STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value) { *value = _inSizeProcessed; return S_OK; }
  425.66 -STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; }
  425.67 -STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; }
  425.68 -
  425.69 -STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
  425.70 -{
  425.71 -  _outSizeDefined = (outSize != NULL);
  425.72 -  if (_outSizeDefined)
  425.73 -    _outSize = *outSize;
  425.74 -
  425.75 -  LzmaDec_Init(&_state);
  425.76 -  
  425.77 -  _inPos = _inSize = 0;
  425.78 -  _inSizeProcessed = _outSizeProcessed = 0;
  425.79 -  return S_OK;
  425.80 -}
  425.81 -
  425.82 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  425.83 -    const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
  425.84 -{
  425.85 -  if (_inBuf == 0)
  425.86 -    return S_FALSE;
  425.87 -  SetOutStreamSize(outSize);
  425.88 -
  425.89 -  for (;;)
  425.90 -  {
  425.91 -    if (_inPos == _inSize)
  425.92 -    {
  425.93 -      _inPos = _inSize = 0;
  425.94 -      RINOK(inStream->Read(_inBuf, kInBufSize, &_inSize));
  425.95 -    }
  425.96 -
  425.97 -    SizeT dicPos = _state.dicPos;
  425.98 -    SizeT curSize = _state.dicBufSize - dicPos;
  425.99 -    const UInt32 kStepSize = ((UInt32)1 << 22);
 425.100 -    if (curSize > kStepSize)
 425.101 -      curSize = (SizeT)kStepSize;
 425.102 -    
 425.103 -    ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
 425.104 -    if (_outSizeDefined)
 425.105 -    {
 425.106 -      const UInt64 rem = _outSize - _outSizeProcessed;
 425.107 -      if (rem < curSize)
 425.108 -      {
 425.109 -        curSize = (SizeT)rem;
 425.110 -        if (FinishStream)
 425.111 -          finishMode = LZMA_FINISH_END;
 425.112 -      }
 425.113 -    }
 425.114 -
 425.115 -    SizeT inSizeProcessed = _inSize - _inPos;
 425.116 -    ELzmaStatus status;
 425.117 -    SRes res = LzmaDec_DecodeToDic(&_state, dicPos + curSize, _inBuf + _inPos, &inSizeProcessed, finishMode, &status);
 425.118 -
 425.119 -    _inPos += (UInt32)inSizeProcessed;
 425.120 -    _inSizeProcessed += inSizeProcessed;
 425.121 -    SizeT outSizeProcessed = _state.dicPos - dicPos;
 425.122 -    _outSizeProcessed += outSizeProcessed;
 425.123 -
 425.124 -    bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0);
 425.125 -    bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize);
 425.126 -
 425.127 -    if (res != 0 || _state.dicPos == _state.dicBufSize || finished || stopDecoding)
 425.128 -    {
 425.129 -      HRESULT res2 = WriteStream(outStream, _state.dic, _state.dicPos);
 425.130 -      if (res != 0)
 425.131 -        return S_FALSE;
 425.132 -      RINOK(res2);
 425.133 -      if (stopDecoding)
 425.134 -        return S_OK;
 425.135 -      if (finished)
 425.136 -        return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE);
 425.137 -    }
 425.138 -    if (_state.dicPos == _state.dicBufSize)
 425.139 -      _state.dicPos = 0;
 425.140 -
 425.141 -    if (progress != NULL)
 425.142 -    {
 425.143 -      RINOK(progress->SetRatioInfo(&_inSizeProcessed, &_outSizeProcessed));
 425.144 -    }
 425.145 -  }
 425.146 -}
 425.147 -
 425.148 -#ifndef NO_READ_FROM_CODER
 425.149 -
 425.150 -STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
 425.151 -{
 425.152 -  if (processedSize)
 425.153 -    *processedSize = 0;
 425.154 -  do
 425.155 -  {
 425.156 -    if (_inPos == _inSize)
 425.157 -    {
 425.158 -      _inPos = _inSize = 0;
 425.159 -      RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize));
 425.160 -    }
 425.161 -    {
 425.162 -      SizeT inProcessed = _inSize - _inPos;
 425.163 -
 425.164 -      if (_outSizeDefined)
 425.165 -      {
 425.166 -        const UInt64 rem = _outSize - _outSizeProcessed;
 425.167 -        if (rem < size)
 425.168 -          size = (UInt32)rem;
 425.169 -      }
 425.170 -
 425.171 -      SizeT outProcessed = size;
 425.172 -      ELzmaStatus status;
 425.173 -      SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
 425.174 -          _inBuf + _inPos, &inProcessed, LZMA_FINISH_ANY, &status);
 425.175 -      _inPos += (UInt32)inProcessed;
 425.176 -      _inSizeProcessed += inProcessed;
 425.177 -      _outSizeProcessed += outProcessed;
 425.178 -      size -= (UInt32)outProcessed;
 425.179 -      data = (Byte *)data + outProcessed;
 425.180 -      if (processedSize)
 425.181 -        *processedSize += (UInt32)outProcessed;
 425.182 -      RINOK(SResToHRESULT(res));
 425.183 -      if (inProcessed == 0 && outProcessed == 0)
 425.184 -        return S_OK;
 425.185 -    }
 425.186 -  }
 425.187 -  while (size != 0);
 425.188 -  return S_OK;
 425.189 -}
 425.190 -
 425.191 -#endif
 425.192 -
 425.193 -}}
   426.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzmaDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   426.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   426.3 @@ -1,73 +0,0 @@
   426.4 -// LzmaDecoder.h
   426.5 -
   426.6 -#ifndef __LZMA_DECODER_H
   426.7 -#define __LZMA_DECODER_H
   426.8 -
   426.9 -extern "C"
  426.10 -{
  426.11 -#include "../../../C/LzmaDec.h"
  426.12 -}
  426.13 -
  426.14 -#include "../../Common/MyCom.h"
  426.15 -#include "../ICoder.h"
  426.16 -
  426.17 -namespace NCompress {
  426.18 -namespace NLzma {
  426.19 -
  426.20 -class CDecoder:
  426.21 -  public ICompressCoder,
  426.22 -  public ICompressSetDecoderProperties2,
  426.23 -  public ICompressGetInStreamProcessedSize,
  426.24 -  #ifndef NO_READ_FROM_CODER
  426.25 -  public ICompressSetInStream,
  426.26 -  public ICompressSetOutStreamSize,
  426.27 -  public ISequentialInStream,
  426.28 -  #endif
  426.29 -  public CMyUnknownImp
  426.30 -{
  426.31 -  CMyComPtr<ISequentialInStream> _inStream;
  426.32 -  Byte *_inBuf;
  426.33 -  UInt32 _inPos;
  426.34 -  UInt32 _inSize;
  426.35 -  CLzmaDec _state;
  426.36 -  bool _outSizeDefined;
  426.37 -  UInt64 _outSize;
  426.38 -  UInt64 _inSizeProcessed;
  426.39 -  UInt64 _outSizeProcessed;
  426.40 -public:
  426.41 -
  426.42 -  #ifndef NO_READ_FROM_CODER
  426.43 -  MY_UNKNOWN_IMP5(
  426.44 -      ICompressSetDecoderProperties2,
  426.45 -      ICompressGetInStreamProcessedSize,
  426.46 -      ICompressSetInStream,
  426.47 -      ICompressSetOutStreamSize,
  426.48 -      ISequentialInStream)
  426.49 -  #else
  426.50 -  MY_UNKNOWN_IMP2(
  426.51 -      ICompressSetDecoderProperties2,
  426.52 -      ICompressGetInStreamProcessedSize)
  426.53 -  #endif
  426.54 -
  426.55 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  426.56 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  426.57 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
  426.58 -  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
  426.59 -  STDMETHOD(SetInStream)(ISequentialInStream *inStream);
  426.60 -  STDMETHOD(ReleaseInStream)();
  426.61 -  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
  426.62 -
  426.63 -  #ifndef NO_READ_FROM_CODER
  426.64 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  426.65 -  #endif
  426.66 -
  426.67 -  bool FinishStream;
  426.68 -
  426.69 -  CDecoder();
  426.70 -  virtual ~CDecoder();
  426.71 -
  426.72 -};
  426.73 -
  426.74 -}}
  426.75 -
  426.76 -#endif
   427.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/LzmaRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   427.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   427.3 @@ -1,20 +0,0 @@
   427.4 -// LzmaRegister.cpp
   427.5 -
   427.6 -#include "StdAfx.h"
   427.7 -
   427.8 -#include "../Common/RegisterCodec.h"
   427.9 -
  427.10 -#include "LzmaDecoder.h"
  427.11 -
  427.12 -static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NLzma::CDecoder); }
  427.13 -#ifndef EXTRACT_ONLY
  427.14 -#include "LzmaEncoder.h"
  427.15 -static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NLzma::CEncoder);  }
  427.16 -#else
  427.17 -#define CreateCodecOut 0
  427.18 -#endif
  427.19 -
  427.20 -static CCodecInfo g_CodecInfo =
  427.21 -  { CreateCodec, CreateCodecOut, 0x030101, L"LZMA", 1, false };
  427.22 -
  427.23 -REGISTER_CODEC(LZMA)
   428.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Mtf8.h	Sat Mar 03 10:54:39 2012 -0600
   428.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   428.3 @@ -1,196 +0,0 @@
   428.4 -// Mtf8.h
   428.5 -
   428.6 -#ifndef __COMPRESS_MTF8_H
   428.7 -#define __COMPRESS_MTF8_H
   428.8 -
   428.9 -#include "../../Common/Types.h"
  428.10 -
  428.11 -namespace NCompress {
  428.12 -
  428.13 -struct CMtf8Encoder
  428.14 -{
  428.15 -  Byte Buf[256];
  428.16 -
  428.17 -  int FindAndMove(Byte v)
  428.18 -  {
  428.19 -    int pos;
  428.20 -    for (pos = 0; Buf[pos] != v; pos++);
  428.21 -    int resPos = pos;
  428.22 -    for (; pos >= 8; pos -= 8)
  428.23 -    {
  428.24 -      Buf[pos] = Buf[pos - 1];
  428.25 -      Buf[pos - 1] = Buf[pos - 2];
  428.26 -      Buf[pos - 2] = Buf[pos - 3];
  428.27 -      Buf[pos - 3] = Buf[pos - 4];
  428.28 -      Buf[pos - 4] = Buf[pos - 5];
  428.29 -      Buf[pos - 5] = Buf[pos - 6];
  428.30 -      Buf[pos - 6] = Buf[pos - 7];
  428.31 -      Buf[pos - 7] = Buf[pos - 8];
  428.32 -    }
  428.33 -    for (; pos > 0; pos--)
  428.34 -      Buf[pos] = Buf[pos - 1];
  428.35 -    Buf[0] = v;
  428.36 -    return resPos;
  428.37 -  }
  428.38 -};
  428.39 -
  428.40 -/*
  428.41 -struct CMtf8Decoder
  428.42 -{
  428.43 -  Byte Buf[256];
  428.44 -
  428.45 -  void Init(int) {};
  428.46 -  Byte GetHead() const { return Buf[0]; }
  428.47 -  Byte GetAndMove(int pos)
  428.48 -  {
  428.49 -    Byte res = Buf[pos];
  428.50 -    for (; pos >= 8; pos -= 8)
  428.51 -    {
  428.52 -      Buf[pos] = Buf[pos - 1];
  428.53 -      Buf[pos - 1] = Buf[pos - 2];
  428.54 -      Buf[pos - 2] = Buf[pos - 3];
  428.55 -      Buf[pos - 3] = Buf[pos - 4];
  428.56 -      Buf[pos - 4] = Buf[pos - 5];
  428.57 -      Buf[pos - 5] = Buf[pos - 6];
  428.58 -      Buf[pos - 6] = Buf[pos - 7];
  428.59 -      Buf[pos - 7] = Buf[pos - 8];
  428.60 -    }
  428.61 -    for (; pos > 0; pos--)
  428.62 -      Buf[pos] = Buf[pos - 1];
  428.63 -    Buf[0] = res;
  428.64 -    return res;
  428.65 -  }
  428.66 -};
  428.67 -*/
  428.68 -
  428.69 -#ifdef _WIN64
  428.70 -#define MODE_64BIT
  428.71 -#endif
  428.72 -
  428.73 -#ifdef MODE_64BIT
  428.74 -typedef UInt64 CMtfVar;
  428.75 -#define MTF_MOVS 3
  428.76 -#else
  428.77 -typedef UInt32 CMtfVar;
  428.78 -#define MTF_MOVS 2
  428.79 -#endif
  428.80 -
  428.81 -#define MTF_MASK ((1 << MTF_MOVS) - 1)
  428.82 -
  428.83 -
  428.84 -struct CMtf8Decoder
  428.85 -{
  428.86 -  CMtfVar Buf[256 >> MTF_MOVS];
  428.87 -
  428.88 -  void StartInit() { memset(Buf, 0, sizeof(Buf)); }
  428.89 -  void Add(unsigned int pos, Byte val) { Buf[pos >> MTF_MOVS] |= ((CMtfVar)val << ((pos & MTF_MASK) << 3));  }
  428.90 -  Byte GetHead() const { return (Byte)Buf[0]; }
  428.91 -  Byte GetAndMove(unsigned int pos)
  428.92 -  {
  428.93 -    UInt32 lim = ((UInt32)pos >> MTF_MOVS);
  428.94 -    pos = (pos & MTF_MASK) << 3;
  428.95 -    CMtfVar prev = (Buf[lim] >> pos) & 0xFF;
  428.96 -
  428.97 -    UInt32 i = 0;
  428.98 -    if ((lim & 1) != 0)
  428.99 -    {
 428.100 -      CMtfVar next = Buf[0];
 428.101 -      Buf[0] = (next << 8) | prev;
 428.102 -      prev = (next >> (MTF_MASK << 3));
 428.103 -      i = 1;
 428.104 -      lim -= 1;
 428.105 -    }
 428.106 -    for (; i < lim; i += 2)
 428.107 -    {
 428.108 -      CMtfVar next = Buf[i];
 428.109 -      Buf[i] = (next << 8) | prev;
 428.110 -      prev = (next >> (MTF_MASK << 3));
 428.111 -      next = Buf[i + 1];
 428.112 -      Buf[i + 1] = (next << 8) | prev;
 428.113 -      prev = (next >> (MTF_MASK << 3));
 428.114 -    }
 428.115 -    CMtfVar next = Buf[i];
 428.116 -    CMtfVar mask = (((CMtfVar)0x100 << pos) - 1);
 428.117 -    Buf[i] = (next & ~mask) | (((next << 8) | prev) & mask);
 428.118 -    return (Byte)Buf[0];
 428.119 -  }
 428.120 -};
 428.121 -
 428.122 -/*
 428.123 -const int kSmallSize = 64;
 428.124 -class CMtf8Decoder
 428.125 -{
 428.126 -  Byte SmallBuffer[kSmallSize];
 428.127 -  int SmallSize;
 428.128 -  Byte Counts[16];
 428.129 -  int Size;
 428.130 -public:
 428.131 -  Byte Buf[256];
 428.132 -
 428.133 -  Byte GetHead() const
 428.134 -  {
 428.135 -    if (SmallSize > 0)
 428.136 -      return SmallBuffer[kSmallSize - SmallSize];
 428.137 -    return Buf[0];
 428.138 -  }
 428.139 -
 428.140 -  void Init(int size)
 428.141 -  {
 428.142 -    Size = size;
 428.143 -    SmallSize = 0;
 428.144 -    for (int i = 0; i < 16; i++)
 428.145 -    {
 428.146 -      Counts[i] = ((size >= 16) ? 16 : size);
 428.147 -      size -= Counts[i];
 428.148 -    }
 428.149 -  }
 428.150 -
 428.151 -  Byte GetAndMove(int pos)
 428.152 -  {
 428.153 -    if (pos < SmallSize)
 428.154 -    {
 428.155 -      Byte *p = SmallBuffer + kSmallSize - SmallSize;
 428.156 -      Byte res = p[pos];
 428.157 -      for (; pos > 0; pos--)
 428.158 -        p[pos] = p[pos - 1];
 428.159 -      SmallBuffer[kSmallSize - SmallSize] = res;
 428.160 -      return res;
 428.161 -    }
 428.162 -    if (SmallSize == kSmallSize)
 428.163 -    {
 428.164 -      int i = Size - 1;
 428.165 -      int g = 16;
 428.166 -      do
 428.167 -      {
 428.168 -        g--;
 428.169 -        int offset = (g << 4);
 428.170 -        for (int t = Counts[g] - 1; t >= 0; t--, i--)
 428.171 -          Buf[i] = Buf[offset + t];
 428.172 -      }
 428.173 -      while(g != 0);
 428.174 -      
 428.175 -      for (i = kSmallSize - 1; i >= 0; i--)
 428.176 -        Buf[i] = SmallBuffer[i];
 428.177 -      Init(Size);
 428.178 -    }
 428.179 -    pos -= SmallSize;
 428.180 -    int g;
 428.181 -    for (g = 0; pos >= Counts[g]; g++)
 428.182 -      pos -= Counts[g];
 428.183 -    int offset = (g << 4);
 428.184 -    Byte res = Buf[offset + pos];
 428.185 -    for (pos; pos < 16 - 1; pos++)
 428.186 -      Buf[offset + pos] = Buf[offset + pos + 1];
 428.187 -    
 428.188 -    SmallSize++;
 428.189 -    SmallBuffer[kSmallSize - SmallSize] = res;
 428.190 -
 428.191 -    Counts[g]--;
 428.192 -    return res;
 428.193 -  }
 428.194 -};
 428.195 -*/
 428.196 -
 428.197 -}
 428.198 -
 428.199 -#endif
   429.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdContext.h	Sat Mar 03 10:54:39 2012 -0600
   429.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   429.3 @@ -1,489 +0,0 @@
   429.4 -// PpmdContext.h
   429.5 -// This code is based on Dmitry Shkarin's PPMdH code
   429.6 -
   429.7 -#ifndef __COMPRESS_PPMD_CONTEXT_H
   429.8 -#define __COMPRESS_PPMD_CONTEXT_H
   429.9 -
  429.10 -#include "../../Common/Types.h"
  429.11 -
  429.12 -#include "PpmdSubAlloc.h"
  429.13 -#include "RangeCoder.h"
  429.14 -
  429.15 -namespace NCompress {
  429.16 -namespace NPpmd {
  429.17 -
  429.18 -const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
  429.19 -        INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
  429.20 -
  429.21 -struct SEE2_CONTEXT
  429.22 -{
  429.23 -  // SEE-contexts for PPM-contexts with masked symbols
  429.24 -  UInt16 Summ;
  429.25 -  Byte Shift, Count;
  429.26 -  void init(int InitVal) { Summ = (UInt16)(InitVal << (Shift=PERIOD_BITS-4)); Count=4; }
  429.27 -  unsigned int getMean()
  429.28 -  {
  429.29 -    unsigned int RetVal=(Summ >> Shift);
  429.30 -    Summ = (UInt16)(Summ - RetVal);
  429.31 -    return RetVal+(RetVal == 0);
  429.32 -  }
  429.33 -  void update()
  429.34 -  {
  429.35 -    if (Shift < PERIOD_BITS && --Count == 0)
  429.36 -    {
  429.37 -      Summ <<= 1;
  429.38 -      Count = (Byte)(3 << Shift++);
  429.39 -    }
  429.40 -  }
  429.41 -};
  429.42 -
  429.43 -struct PPM_CONTEXT
  429.44 -{
  429.45 -  UInt16 NumStats; // sizeof(UInt16) > sizeof(Byte)
  429.46 -  UInt16 SummFreq;
  429.47 -  
  429.48 -  struct STATE
  429.49 -  {
  429.50 -    Byte Symbol, Freq;
  429.51 -    UInt16 SuccessorLow;
  429.52 -    UInt16 SuccessorHigh;
  429.53 -
  429.54 -    UInt32 GetSuccessor() const { return SuccessorLow | ((UInt32)SuccessorHigh << 16); }
  429.55 -    void SetSuccessor(UInt32 v)
  429.56 -    {
  429.57 -      SuccessorLow = (UInt16)(v & 0xFFFF);
  429.58 -      SuccessorHigh = (UInt16)((v >> 16) & 0xFFFF);
  429.59 -    }
  429.60 -  };
  429.61 -  
  429.62 -  UInt32 Stats;
  429.63 -  UInt32 Suffix;
  429.64 -  
  429.65 -  PPM_CONTEXT* createChild(CSubAllocator &subAllocator, STATE* pStats, STATE& FirstState)
  429.66 -  {
  429.67 -    PPM_CONTEXT* pc = (PPM_CONTEXT*) subAllocator.AllocContext();
  429.68 -    if (pc)
  429.69 -    {
  429.70 -      pc->NumStats = 1;
  429.71 -      pc->oneState() = FirstState;
  429.72 -      pc->Suffix = subAllocator.GetOffset(this);
  429.73 -      pStats->SetSuccessor(subAllocator.GetOffsetNoCheck(pc));
  429.74 -    }
  429.75 -    return pc;
  429.76 -  }
  429.77 -
  429.78 -  STATE& oneState() const { return (STATE&) SummFreq; }
  429.79 -};
  429.80 -
  429.81 -/////////////////////////////////
  429.82 -
  429.83 -const UInt16 InitBinEsc[] =
  429.84 -  {0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051};
  429.85 -
  429.86 -struct CInfo
  429.87 -{
  429.88 -  CSubAllocator SubAllocator;
  429.89 -  SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
  429.90 -  PPM_CONTEXT * MinContext, * MaxContext;
  429.91 -
  429.92 -  PPM_CONTEXT::STATE* FoundState;      // found next state transition
  429.93 -  int NumMasked, InitEsc, OrderFall, RunLength, InitRL, MaxOrder;
  429.94 -  Byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
  429.95 -  Byte EscCount, PrintCount, PrevSuccess, HiBitsFlag;
  429.96 -  UInt16 BinSumm[128][64];               // binary SEE-contexts
  429.97 -
  429.98 -  UInt16 &GetBinSumm(const PPM_CONTEXT::STATE &rs, int numStates)
  429.99 -  {
 429.100 -    HiBitsFlag = HB2Flag[FoundState->Symbol];
 429.101 -    return BinSumm[rs.Freq - 1][
 429.102 -         PrevSuccess + NS2BSIndx[numStates - 1] +
 429.103 -         HiBitsFlag + 2 * HB2Flag[rs.Symbol] +
 429.104 -         ((RunLength >> 26) & 0x20)];
 429.105 -  }
 429.106 -
 429.107 -  PPM_CONTEXT *GetContext(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtr(offset); }
 429.108 -  PPM_CONTEXT *GetContextNoCheck(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtrNoCheck(offset); }
 429.109 -  PPM_CONTEXT::STATE *GetState(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }
 429.110 -  PPM_CONTEXT::STATE *GetStateNoCheck(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }
 429.111 -
 429.112 -  void RestartModelRare()
 429.113 -  {
 429.114 -    int i, k, m;
 429.115 -    memset(CharMask,0,sizeof(CharMask));
 429.116 -    SubAllocator.InitSubAllocator();
 429.117 -    InitRL = -((MaxOrder < 12) ? MaxOrder : 12) - 1;
 429.118 -    MinContext = MaxContext = (PPM_CONTEXT*) SubAllocator.AllocContext();
 429.119 -    MinContext->Suffix = 0;
 429.120 -    OrderFall = MaxOrder;
 429.121 -    MinContext->SummFreq = (UInt16)((MinContext->NumStats = 256) + 1);
 429.122 -    FoundState = (PPM_CONTEXT::STATE*)SubAllocator.AllocUnits(256 / 2);
 429.123 -    MinContext->Stats = SubAllocator.GetOffsetNoCheck(FoundState);
 429.124 -    PrevSuccess = 0;
 429.125 -    for (RunLength = InitRL, i = 0; i < 256; i++)
 429.126 -    {
 429.127 -      PPM_CONTEXT::STATE &state = FoundState[i];
 429.128 -      state.Symbol = (Byte)i;
 429.129 -      state.Freq = 1;
 429.130 -      state.SetSuccessor(0);
 429.131 -    }
 429.132 -    for (i = 0; i < 128; i++)
 429.133 -        for (k = 0; k < 8; k++)
 429.134 -            for ( m=0; m < 64; m += 8)
 429.135 -                BinSumm[i][k + m] = (UInt16)(BIN_SCALE - InitBinEsc[k] / (i + 2));
 429.136 -    for (i = 0; i < 25; i++)
 429.137 -        for (k = 0; k < 16; k++)
 429.138 -            SEE2Cont[i][k].init(5*i+10);
 429.139 -  }
 429.140 -
 429.141 -  void StartModelRare(int maxOrder)
 429.142 -  {
 429.143 -    int i, k, m ,Step;
 429.144 -    EscCount=PrintCount=1;
 429.145 -    if (maxOrder < 2)
 429.146 -    {
 429.147 -        memset(CharMask,0,sizeof(CharMask));
 429.148 -        OrderFall = MaxOrder;
 429.149 -        MinContext = MaxContext;
 429.150 -        while (MinContext->Suffix != 0)
 429.151 -        {
 429.152 -          MinContext = GetContextNoCheck(MinContext->Suffix);
 429.153 -          OrderFall--;
 429.154 -        }
 429.155 -        FoundState = GetState(MinContext->Stats);
 429.156 -        MinContext = MaxContext;
 429.157 -    }
 429.158 -    else
 429.159 -    {
 429.160 -        MaxOrder = maxOrder;
 429.161 -        RestartModelRare();
 429.162 -        NS2BSIndx[0] = 2 * 0;
 429.163 -        NS2BSIndx[1] = 2 * 1;
 429.164 -        memset(NS2BSIndx + 2, 2 * 2, 9);
 429.165 -        memset(NS2BSIndx + 11, 2 * 3, 256 - 11);
 429.166 -        for (i = 0; i < 3; i++)
 429.167 -          NS2Indx[i] = (Byte)i;
 429.168 -        for (m = i, k = Step = 1; i < 256; i++)
 429.169 -        {
 429.170 -            NS2Indx[i] = (Byte)m;
 429.171 -            if ( !--k )
 429.172 -            {
 429.173 -              k = ++Step;
 429.174 -              m++;
 429.175 -            }
 429.176 -        }
 429.177 -        memset(HB2Flag, 0, 0x40);
 429.178 -        memset(HB2Flag + 0x40, 0x08, 0x100 - 0x40);
 429.179 -        DummySEE2Cont.Shift = PERIOD_BITS;
 429.180 -    }
 429.181 -  }
 429.182 -
 429.183 -  PPM_CONTEXT* CreateSuccessors(bool skip, PPM_CONTEXT::STATE* p1)
 429.184 -  {
 429.185 -    // static UpState declaration bypasses IntelC bug
 429.186 -    // static PPM_CONTEXT::STATE UpState;
 429.187 -    PPM_CONTEXT::STATE UpState;
 429.188 -
 429.189 -    PPM_CONTEXT *pc = MinContext;
 429.190 -    PPM_CONTEXT *UpBranch = GetContext(FoundState->GetSuccessor());
 429.191 -    PPM_CONTEXT::STATE * p, * ps[MAX_O], ** pps = ps;
 429.192 -    if ( !skip )
 429.193 -    {
 429.194 -        *pps++ = FoundState;
 429.195 -        if ( !pc->Suffix )
 429.196 -          goto NO_LOOP;
 429.197 -    }
 429.198 -    if ( p1 )
 429.199 -    {
 429.200 -        p = p1;
 429.201 -        pc = GetContext(pc->Suffix);
 429.202 -        goto LOOP_ENTRY;
 429.203 -    }
 429.204 -    do
 429.205 -    {
 429.206 -        pc = GetContext(pc->Suffix);
 429.207 -        if (pc->NumStats != 1)
 429.208 -        {
 429.209 -            if ((p = GetStateNoCheck(pc->Stats))->Symbol != FoundState->Symbol)
 429.210 -                do { p++; } while (p->Symbol != FoundState->Symbol);
 429.211 -        }
 429.212 -        else
 429.213 -          p = &(pc->oneState());
 429.214 -LOOP_ENTRY:
 429.215 -        if (GetContext(p->GetSuccessor()) != UpBranch)
 429.216 -        {
 429.217 -            pc = GetContext(p->GetSuccessor());
 429.218 -            break;
 429.219 -        }
 429.220 -        *pps++ = p;
 429.221 -    }
 429.222 -    while ( pc->Suffix );
 429.223 -NO_LOOP:
 429.224 -    if (pps == ps)
 429.225 -      return pc;
 429.226 -    UpState.Symbol = *(Byte*) UpBranch;
 429.227 -    UpState.SetSuccessor(SubAllocator.GetOffset(UpBranch) + 1);
 429.228 -    if (pc->NumStats != 1)
 429.229 -    {
 429.230 -        if ((p = GetStateNoCheck(pc->Stats))->Symbol != UpState.Symbol)
 429.231 -                do { p++; } while (p->Symbol != UpState.Symbol);
 429.232 -        unsigned int cf = p->Freq-1;
 429.233 -        unsigned int s0 = pc->SummFreq - pc->NumStats - cf;
 429.234 -        UpState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) :
 429.235 -            ((2 * cf + 3 * s0 - 1) / (2 * s0))));
 429.236 -    }
 429.237 -    else
 429.238 -      UpState.Freq = pc->oneState().Freq;
 429.239 -    do
 429.240 -    {
 429.241 -        pc = pc->createChild(SubAllocator, *--pps, UpState);
 429.242 -        if ( !pc )
 429.243 -          return NULL;
 429.244 -    }
 429.245 -    while (pps != ps);
 429.246 -    return pc;
 429.247 -  }
 429.248 -
 429.249 -  void UpdateModel()
 429.250 -  {
 429.251 -    PPM_CONTEXT::STATE fs = *FoundState, * p = NULL;
 429.252 -    PPM_CONTEXT* pc, * Successor;
 429.253 -    unsigned int ns1, ns, cf, sf, s0;
 429.254 -    if (fs.Freq < MAX_FREQ / 4 && MinContext->Suffix != 0)
 429.255 -    {
 429.256 -        pc = GetContextNoCheck(MinContext->Suffix);
 429.257 -      
 429.258 -        if (pc->NumStats != 1)
 429.259 -        {
 429.260 -            if ((p = GetStateNoCheck(pc->Stats))->Symbol != fs.Symbol)
 429.261 -            {
 429.262 -                do { p++; } while (p->Symbol != fs.Symbol);
 429.263 -                if (p[0].Freq >= p[-1].Freq)
 429.264 -                {
 429.265 -                    _PPMD_SWAP(p[0],p[-1]);
 429.266 -                    p--;
 429.267 -                }
 429.268 -            }
 429.269 -            if (p->Freq < MAX_FREQ-9)
 429.270 -            {
 429.271 -                p->Freq += 2;
 429.272 -                pc->SummFreq += 2;
 429.273 -            }
 429.274 -        }
 429.275 -        else
 429.276 -        {
 429.277 -            p = &(pc->oneState());
 429.278 -            p->Freq = (Byte)(p->Freq + ((p->Freq < 32) ? 1 : 0));
 429.279 -        }
 429.280 -    }
 429.281 -    if ( !OrderFall )
 429.282 -    {
 429.283 -        MinContext = MaxContext = CreateSuccessors(true, p);
 429.284 -        FoundState->SetSuccessor(SubAllocator.GetOffset(MinContext));
 429.285 -        if (MinContext == 0)
 429.286 -          goto RESTART_MODEL;
 429.287 -        return;
 429.288 -    }
 429.289 -    *SubAllocator.pText++ = fs.Symbol;
 429.290 -    Successor = (PPM_CONTEXT*) SubAllocator.pText;
 429.291 -    if (SubAllocator.pText >= SubAllocator.UnitsStart)
 429.292 -      goto RESTART_MODEL;
 429.293 -    if (fs.GetSuccessor() != 0)
 429.294 -    {
 429.295 -        if ((Byte *)GetContext(fs.GetSuccessor()) <= SubAllocator.pText)
 429.296 -        {
 429.297 -          PPM_CONTEXT* cs = CreateSuccessors(false, p);
 429.298 -          fs.SetSuccessor(SubAllocator.GetOffset(cs));
 429.299 -          if (cs == NULL)
 429.300 -            goto RESTART_MODEL;
 429.301 -        }
 429.302 -        if ( !--OrderFall )
 429.303 -        {
 429.304 -            Successor = GetContext(fs.GetSuccessor());
 429.305 -            SubAllocator.pText -= (MaxContext != MinContext);
 429.306 -        }
 429.307 -    }
 429.308 -    else
 429.309 -    {
 429.310 -        FoundState->SetSuccessor(SubAllocator.GetOffsetNoCheck(Successor));
 429.311 -        fs.SetSuccessor(SubAllocator.GetOffsetNoCheck(MinContext));
 429.312 -    }
 429.313 -    s0 = MinContext->SummFreq - (ns = MinContext->NumStats) - (fs.Freq - 1);
 429.314 -    for (pc = MaxContext; pc != MinContext; pc = GetContext(pc->Suffix))
 429.315 -    {
 429.316 -        if ((ns1 = pc->NumStats) != 1)
 429.317 -        {
 429.318 -            if ((ns1 & 1) == 0)
 429.319 -            {
 429.320 -                void *ppp = SubAllocator.ExpandUnits(GetState(pc->Stats), ns1 >> 1);
 429.321 -                pc->Stats = SubAllocator.GetOffset(ppp);
 429.322 -                if (!ppp)
 429.323 -                  goto RESTART_MODEL;
 429.324 -            }
 429.325 -            pc->SummFreq = (UInt16)(pc->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) &
 429.326 -                    (pc->SummFreq <= 8 * ns1)));
 429.327 -        }
 429.328 -        else
 429.329 -        {
 429.330 -            p = (PPM_CONTEXT::STATE*) SubAllocator.AllocUnits(1);
 429.331 -            if ( !p )
 429.332 -              goto RESTART_MODEL;
 429.333 -            *p = pc->oneState();
 429.334 -            pc->Stats = SubAllocator.GetOffsetNoCheck(p);
 429.335 -            if (p->Freq < MAX_FREQ / 4 - 1)
 429.336 -              p->Freq <<= 1;
 429.337 -            else
 429.338 -              p->Freq  = MAX_FREQ - 4;
 429.339 -            pc->SummFreq = (UInt16)(p->Freq + InitEsc + (ns > 3));
 429.340 -        }
 429.341 -        cf = 2 * fs.Freq * (pc->SummFreq+6);
 429.342 -        sf = s0 + pc->SummFreq;
 429.343 -        if (cf < 6 * sf)
 429.344 -        {
 429.345 -            cf = 1 + (cf > sf)+(cf >= 4 * sf);
 429.346 -            pc->SummFreq += 3;
 429.347 -        }
 429.348 -        else
 429.349 -        {
 429.350 -            cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
 429.351 -            pc->SummFreq = (UInt16)(pc->SummFreq + cf);
 429.352 -        }
 429.353 -        p = GetState(pc->Stats) + ns1;
 429.354 -        p->SetSuccessor(SubAllocator.GetOffset(Successor));
 429.355 -        p->Symbol = fs.Symbol;
 429.356 -        p->Freq = (Byte)cf;
 429.357 -        pc->NumStats = (UInt16)++ns1;
 429.358 -    }
 429.359 -    MaxContext = MinContext = GetContext(fs.GetSuccessor());
 429.360 -    return;
 429.361 -RESTART_MODEL:
 429.362 -    RestartModelRare();
 429.363 -    EscCount = 0;
 429.364 -    PrintCount = 0xFF;
 429.365 -  }
 429.366 -
 429.367 -  void ClearMask()
 429.368 -  {
 429.369 -    EscCount = 1;
 429.370 -    memset(CharMask, 0, sizeof(CharMask));
 429.371 -    // if (++PrintCount == 0)
 429.372 -    //   PrintInfo(DecodedFile,EncodedFile);
 429.373 -  }
 429.374 -
 429.375 -  void update1(PPM_CONTEXT::STATE* p)
 429.376 -  {
 429.377 -    (FoundState = p)->Freq += 4;
 429.378 -    MinContext->SummFreq += 4;
 429.379 -    if (p[0].Freq > p[-1].Freq)
 429.380 -    {
 429.381 -        _PPMD_SWAP(p[0],p[-1]);
 429.382 -        FoundState = --p;
 429.383 -        if (p->Freq > MAX_FREQ)
 429.384 -          rescale();
 429.385 -    }
 429.386 -  }
 429.387 -
 429.388 -
 429.389 -  void update2(PPM_CONTEXT::STATE* p)
 429.390 -  {
 429.391 -    (FoundState = p)->Freq += 4;
 429.392 -    MinContext->SummFreq += 4;
 429.393 -    if (p->Freq > MAX_FREQ)
 429.394 -      rescale();
 429.395 -    EscCount++;
 429.396 -    RunLength = InitRL;
 429.397 -  }
 429.398 -  
 429.399 -  SEE2_CONTEXT* makeEscFreq2(int Diff, UInt32 &scale)
 429.400 -  {
 429.401 -    SEE2_CONTEXT* psee2c;
 429.402 -    if (MinContext->NumStats != 256)
 429.403 -    {
 429.404 -      psee2c = SEE2Cont[NS2Indx[Diff-1]] +
 429.405 -        (Diff < (GetContext(MinContext->Suffix))->NumStats - MinContext->NumStats) +
 429.406 -        2 * (MinContext->SummFreq < 11 * MinContext->NumStats) +
 429.407 -        4 * (NumMasked > Diff) +
 429.408 -        HiBitsFlag;
 429.409 -      scale = psee2c->getMean();
 429.410 -    }
 429.411 -    else
 429.412 -    {
 429.413 -      psee2c = &DummySEE2Cont;
 429.414 -      scale = 1;
 429.415 -    }
 429.416 -    return psee2c;
 429.417 -  }
 429.418 -
 429.419 -
 429.420 -
 429.421 -  void rescale()
 429.422 -  {
 429.423 -    int OldNS = MinContext->NumStats, i = MinContext->NumStats - 1, Adder, EscFreq;
 429.424 -    PPM_CONTEXT::STATE* p1, * p;
 429.425 -    PPM_CONTEXT::STATE *stats = GetStateNoCheck(MinContext->Stats);
 429.426 -    for (p = FoundState; p != stats; p--)
 429.427 -      _PPMD_SWAP(p[0], p[-1]);
 429.428 -    stats->Freq += 4;
 429.429 -    MinContext->SummFreq += 4;
 429.430 -    EscFreq = MinContext->SummFreq - p->Freq;
 429.431 -    Adder = (OrderFall != 0);
 429.432 -    p->Freq = (Byte)((p->Freq + Adder) >> 1);
 429.433 -    MinContext->SummFreq = p->Freq;
 429.434 -    do
 429.435 -    {
 429.436 -        EscFreq -= (++p)->Freq;
 429.437 -        p->Freq = (Byte)((p->Freq + Adder) >> 1);
 429.438 -        MinContext->SummFreq = (UInt16)(MinContext->SummFreq + p->Freq);
 429.439 -        if (p[0].Freq > p[-1].Freq)
 429.440 -        {
 429.441 -            PPM_CONTEXT::STATE tmp = *(p1 = p);
 429.442 -            do
 429.443 -            {
 429.444 -              p1[0] = p1[-1];
 429.445 -            }
 429.446 -            while (--p1 != stats && tmp.Freq > p1[-1].Freq);
 429.447 -            *p1 = tmp;
 429.448 -        }
 429.449 -    }
 429.450 -    while ( --i );
 429.451 -    if (p->Freq == 0)
 429.452 -    {
 429.453 -        do { i++; } while ((--p)->Freq == 0);
 429.454 -        EscFreq += i;
 429.455 -        MinContext->NumStats = (UInt16)(MinContext->NumStats - i);
 429.456 -        if (MinContext->NumStats == 1)
 429.457 -        {
 429.458 -            PPM_CONTEXT::STATE tmp = *stats;
 429.459 -            do { tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); EscFreq >>= 1; } while (EscFreq > 1);
 429.460 -            SubAllocator.FreeUnits(stats, (OldNS+1) >> 1);
 429.461 -            *(FoundState = &MinContext->oneState()) = tmp;  return;
 429.462 -        }
 429.463 -    }
 429.464 -    EscFreq -= (EscFreq >> 1);
 429.465 -    MinContext->SummFreq = (UInt16)(MinContext->SummFreq + EscFreq);
 429.466 -    int n0 = (OldNS+1) >> 1, n1 = (MinContext->NumStats + 1) >> 1;
 429.467 -    if (n0 != n1)
 429.468 -      MinContext->Stats = SubAllocator.GetOffset(SubAllocator.ShrinkUnits(stats, n0, n1));
 429.469 -    FoundState = GetState(MinContext->Stats);
 429.470 -  }
 429.471 -
 429.472 -  void NextContext()
 429.473 -  {
 429.474 -    PPM_CONTEXT *c = GetContext(FoundState->GetSuccessor());
 429.475 -    if (!OrderFall && (Byte *)c > SubAllocator.pText)
 429.476 -      MinContext = MaxContext = c;
 429.477 -    else
 429.478 -    {
 429.479 -      UpdateModel();
 429.480 -      if (EscCount == 0)
 429.481 -        ClearMask();
 429.482 -    }
 429.483 -  }
 429.484 -};
 429.485 -
 429.486 -// Tabulated escapes for exponential symbol distribution
 429.487 -const Byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
 429.488 -#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
 429.489 -
 429.490 -}}
 429.491 -
 429.492 -#endif
   430.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecode.h	Sat Mar 03 10:54:39 2012 -0600
   430.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   430.3 @@ -1,154 +0,0 @@
   430.4 -// PpmdDecode.h
   430.5 -// This code is based on Dmitry Shkarin's PPMdH code
   430.6 -
   430.7 -#ifndef __COMPRESS_PPMD_DECODE_H
   430.8 -#define __COMPRESS_PPMD_DECODE_H
   430.9 -
  430.10 -#include "PpmdContext.h"
  430.11 -
  430.12 -namespace NCompress {
  430.13 -namespace NPpmd {
  430.14 -
  430.15 -class CRangeDecoderVirt
  430.16 -{
  430.17 -public:
  430.18 -  virtual UInt32 GetThreshold(UInt32 total) = 0;
  430.19 -  virtual void Decode(UInt32 start, UInt32 size) = 0;
  430.20 -  virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) = 0;
  430.21 -};
  430.22 -
  430.23 -typedef NRangeCoder::CDecoder CRangeDecoderMy;
  430.24 -
  430.25 -class CRangeDecoder:public CRangeDecoderVirt, public CRangeDecoderMy
  430.26 -{
  430.27 -  UInt32 GetThreshold(UInt32 total) { return CRangeDecoderMy::GetThreshold(total); }
  430.28 -  void Decode(UInt32 start, UInt32 size) { CRangeDecoderMy::Decode(start, size); }
  430.29 -  UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) { return CRangeDecoderMy::DecodeBit(size0, numTotalBits); }
  430.30 -};
  430.31 -
  430.32 -struct CDecodeInfo: public CInfo
  430.33 -{
  430.34 -  void DecodeBinSymbol(CRangeDecoderVirt *rangeDecoder)
  430.35 -  {
  430.36 -    PPM_CONTEXT::STATE& rs = MinContext->oneState();
  430.37 -    UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
  430.38 -    if (rangeDecoder->DecodeBit(bs, TOT_BITS) == 0)
  430.39 -    {
  430.40 -      FoundState = &rs;
  430.41 -      rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
  430.42 -      bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
  430.43 -      PrevSuccess = 1;
  430.44 -      RunLength++;
  430.45 -    }
  430.46 -    else
  430.47 -    {
  430.48 -      bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
  430.49 -      InitEsc = ExpEscape[bs >> 10];
  430.50 -      NumMasked = 1;
  430.51 -      CharMask[rs.Symbol] = EscCount;
  430.52 -      PrevSuccess = 0;
  430.53 -      FoundState = NULL;
  430.54 -    }
  430.55 -  }
  430.56 -
  430.57 -  void DecodeSymbol1(CRangeDecoderVirt *rangeDecoder)
  430.58 -  {
  430.59 -    PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
  430.60 -    int i, count, hiCnt;
  430.61 -    if ((count = rangeDecoder->GetThreshold(MinContext->SummFreq)) < (hiCnt = p->Freq))
  430.62 -    {
  430.63 -      PrevSuccess = (2 * hiCnt > MinContext->SummFreq);
  430.64 -      RunLength += PrevSuccess;
  430.65 -      rangeDecoder->Decode(0, p->Freq); // MinContext->SummFreq);
  430.66 -      (FoundState = p)->Freq = (Byte)(hiCnt += 4);
  430.67 -      MinContext->SummFreq += 4;
  430.68 -      if (hiCnt > MAX_FREQ)
  430.69 -        rescale();
  430.70 -      return;
  430.71 -    }
  430.72 -    PrevSuccess = 0;
  430.73 -    i = MinContext->NumStats - 1;
  430.74 -    while ((hiCnt += (++p)->Freq) <= count)
  430.75 -      if (--i == 0)
  430.76 -      {
  430.77 -        HiBitsFlag = HB2Flag[FoundState->Symbol];
  430.78 -        rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
  430.79 -        CharMask[p->Symbol] = EscCount;
  430.80 -        i = (NumMasked = MinContext->NumStats)-1;
  430.81 -        FoundState = NULL;
  430.82 -        do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
  430.83 -        return;
  430.84 -      }
  430.85 -    rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , MinContext->SummFreq);
  430.86 -    update1(p);
  430.87 -  }
  430.88 -
  430.89 -
  430.90 -  void DecodeSymbol2(CRangeDecoderVirt *rangeDecoder)
  430.91 -  {
  430.92 -    int count, hiCnt, i = MinContext->NumStats - NumMasked;
  430.93 -    UInt32 freqSum;
  430.94 -    SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
  430.95 -    PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
  430.96 -    hiCnt = 0;
  430.97 -    do
  430.98 -    {
  430.99 -      do { p++; } while (CharMask[p->Symbol] == EscCount);
 430.100 -      hiCnt += p->Freq;
 430.101 -      *pps++ = p;
 430.102 -    }
 430.103 -    while ( --i );
 430.104 -    
 430.105 -    freqSum += hiCnt;
 430.106 -    count = rangeDecoder->GetThreshold(freqSum);
 430.107 -    
 430.108 -    p = *(pps = ps);
 430.109 -    if (count < hiCnt)
 430.110 -    {
 430.111 -      hiCnt = 0;
 430.112 -      while ((hiCnt += p->Freq) <= count)
 430.113 -        p=*++pps;
 430.114 -      rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
 430.115 -      
 430.116 -      psee2c->update();
 430.117 -      update2(p);
 430.118 -    }
 430.119 -    else
 430.120 -    {
 430.121 -      rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
 430.122 -      
 430.123 -      i = MinContext->NumStats - NumMasked;
 430.124 -      pps--;
 430.125 -      do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
 430.126 -      psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
 430.127 -      NumMasked = MinContext->NumStats;
 430.128 -    }
 430.129 -  }
 430.130 -
 430.131 -  int DecodeSymbol(CRangeDecoderVirt *rangeDecoder)
 430.132 -  {
 430.133 -    if (MinContext->NumStats != 1)
 430.134 -      DecodeSymbol1(rangeDecoder);
 430.135 -    else
 430.136 -      DecodeBinSymbol(rangeDecoder);
 430.137 -    while ( !FoundState )
 430.138 -    {
 430.139 -      do
 430.140 -      {
 430.141 -        OrderFall++;
 430.142 -        MinContext = GetContext(MinContext->Suffix);
 430.143 -        if (MinContext == 0)
 430.144 -          return -1;
 430.145 -      }
 430.146 -      while (MinContext->NumStats == NumMasked);
 430.147 -      DecodeSymbol2(rangeDecoder);
 430.148 -    }
 430.149 -    Byte symbol = FoundState->Symbol;
 430.150 -    NextContext();
 430.151 -    return symbol;
 430.152 -  }
 430.153 -};
 430.154 -
 430.155 -}}
 430.156 -
 430.157 -#endif
   431.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   431.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   431.3 @@ -1,182 +0,0 @@
   431.4 -// PpmdDecoder.cpp
   431.5 -
   431.6 -#include "StdAfx.h"
   431.7 -
   431.8 -#include "Common/Defs.h"
   431.9 -#include "Windows/Defs.h"
  431.10 -
  431.11 -#include "PpmdDecoder.h"
  431.12 -
  431.13 -namespace NCompress {
  431.14 -namespace NPpmd {
  431.15 -
  431.16 -const int kLenIdFinished = -1;
  431.17 -const int kLenIdNeedInit = -2;
  431.18 -
  431.19 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
  431.20 -{
  431.21 -  if (size < 5)
  431.22 -    return E_INVALIDARG;
  431.23 -  _order = properties[0];
  431.24 -  _usedMemorySize = 0;
  431.25 -  for (int i = 0; i < 4; i++)
  431.26 -    _usedMemorySize += ((UInt32)(properties[1 + i])) << (i * 8);
  431.27 -
  431.28 -  if (_usedMemorySize > kMaxMemBlockSize)
  431.29 -    return E_NOTIMPL;
  431.30 -
  431.31 -  if (!_rangeDecoder.Create(1 << 20))
  431.32 -    return E_OUTOFMEMORY;
  431.33 -  if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
  431.34 -    return E_OUTOFMEMORY;
  431.35 -
  431.36 -  return S_OK;
  431.37 -}
  431.38 -
  431.39 -class CDecoderFlusher
  431.40 -{
  431.41 -  CDecoder *_coder;
  431.42 -public:
  431.43 -  bool NeedFlush;
  431.44 -  CDecoderFlusher(CDecoder *coder): _coder(coder), NeedFlush(true) {}
  431.45 -  ~CDecoderFlusher()
  431.46 -  {
  431.47 -    if (NeedFlush)
  431.48 -      _coder->Flush();
  431.49 -    _coder->ReleaseStreams();
  431.50 -  }
  431.51 -};
  431.52 -
  431.53 -HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
  431.54 -{
  431.55 -  if (_outSizeDefined)
  431.56 -  {
  431.57 -    const UInt64 rem = _outSize - _processedSize;
  431.58 -    if (size > rem)
  431.59 -      size = (UInt32)rem;
  431.60 -  }
  431.61 -  const UInt32 startSize = size;
  431.62 -
  431.63 -  if (_remainLen == kLenIdFinished)
  431.64 -    return S_OK;
  431.65 -  if (_remainLen == kLenIdNeedInit)
  431.66 -  {
  431.67 -    _rangeDecoder.Init();
  431.68 -    _remainLen = 0;
  431.69 -    _info.MaxOrder = 0;
  431.70 -    _info.StartModelRare(_order);
  431.71 -  }
  431.72 -  while (size != 0)
  431.73 -  {
  431.74 -    int symbol = _info.DecodeSymbol(&_rangeDecoder);
  431.75 -    if (symbol < 0)
  431.76 -    {
  431.77 -      _remainLen = kLenIdFinished;
  431.78 -      break;
  431.79 -    }
  431.80 -    if (memStream != 0)
  431.81 -      *memStream++ = (Byte)symbol;
  431.82 -    else
  431.83 -      _outStream.WriteByte((Byte)symbol);
  431.84 -    size--;
  431.85 -  }
  431.86 -  _processedSize += startSize - size;
  431.87 -  return S_OK;
  431.88 -}
  431.89 -
  431.90 -STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  431.91 -    const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
  431.92 -{
  431.93 -  if (!_outStream.Create(1 << 20))
  431.94 -    return E_OUTOFMEMORY;
  431.95 -  
  431.96 -  SetInStream(inStream);
  431.97 -  _outStream.SetStream(outStream);
  431.98 -  SetOutStreamSize(outSize);
  431.99 -  CDecoderFlusher flusher(this);
 431.100 -
 431.101 -  for (;;)
 431.102 -  {
 431.103 -    _processedSize = _outStream.GetProcessedSize();
 431.104 -    UInt32 curSize = (1 << 18);
 431.105 -    RINOK(CodeSpec(curSize, NULL));
 431.106 -    if (_remainLen == kLenIdFinished)
 431.107 -      break;
 431.108 -    if (progress != NULL)
 431.109 -    {
 431.110 -      UInt64 inSize = _rangeDecoder.GetProcessedSize();
 431.111 -      RINOK(progress->SetRatioInfo(&inSize, &_processedSize));
 431.112 -    }
 431.113 -    if (_outSizeDefined)
 431.114 -      if (_outStream.GetProcessedSize() >= _outSize)
 431.115 -        break;
 431.116 -  }
 431.117 -  flusher.NeedFlush = false;
 431.118 -  return Flush();
 431.119 -}
 431.120 -
 431.121 -#ifdef _NO_EXCEPTIONS
 431.122 -
 431.123 -#define PPMD_TRY_BEGIN
 431.124 -#define PPMD_TRY_END
 431.125 -
 431.126 -#else
 431.127 -
 431.128 -#define PPMD_TRY_BEGIN try {
 431.129 -#define PPMD_TRY_END } \
 431.130 -  catch(const CInBufferException &e)  { return e.ErrorCode; } \
 431.131 -  catch(const COutBufferException &e)  { return e.ErrorCode; } \
 431.132 -  catch(...) { return S_FALSE; }
 431.133 -
 431.134 -#endif
 431.135 -
 431.136 -
 431.137 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 431.138 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 431.139 -{
 431.140 -  PPMD_TRY_BEGIN
 431.141 -  return CodeReal(inStream, outStream, inSize, outSize, progress);
 431.142 -  PPMD_TRY_END
 431.143 -}
 431.144 -
 431.145 -STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
 431.146 -{
 431.147 -  _rangeDecoder.SetStream(inStream);
 431.148 -  return S_OK;
 431.149 -}
 431.150 -
 431.151 -STDMETHODIMP CDecoder::ReleaseInStream()
 431.152 -{
 431.153 -  _rangeDecoder.ReleaseStream();
 431.154 -  return S_OK;
 431.155 -}
 431.156 -
 431.157 -STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
 431.158 -{
 431.159 -  _outSizeDefined = (outSize != NULL);
 431.160 -  if (_outSizeDefined)
 431.161 -    _outSize = *outSize;
 431.162 -  _processedSize = 0;
 431.163 -  _remainLen = kLenIdNeedInit;
 431.164 -  _outStream.Init();
 431.165 -  return S_OK;
 431.166 -}
 431.167 -
 431.168 -#ifndef NO_READ_FROM_CODER
 431.169 -
 431.170 -STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
 431.171 -{
 431.172 -  PPMD_TRY_BEGIN
 431.173 -  if (processedSize)
 431.174 -    *processedSize = 0;
 431.175 -  const UInt64 startPos = _processedSize;
 431.176 -  RINOK(CodeSpec(size, (Byte *)data));
 431.177 -  if (processedSize)
 431.178 -    *processedSize = (UInt32)(_processedSize - startPos);
 431.179 -  return Flush();
 431.180 -  PPMD_TRY_END
 431.181 -}
 431.182 -
 431.183 -#endif
 431.184 -
 431.185 -}}
   432.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   432.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   432.3 @@ -1,86 +0,0 @@
   432.4 -// PpmdDecoder.h
   432.5 -
   432.6 -#ifndef __COMPRESS_PPMD_DECODER_H
   432.7 -#define __COMPRESS_PPMD_DECODER_H
   432.8 -
   432.9 -#include "../../Common/MyCom.h"
  432.10 -
  432.11 -#include "../ICoder.h"
  432.12 -
  432.13 -#include "../Common/OutBuffer.h"
  432.14 -
  432.15 -#include "PpmdDecode.h"
  432.16 -#include "RangeCoder.h"
  432.17 -
  432.18 -namespace NCompress {
  432.19 -namespace NPpmd {
  432.20 -
  432.21 -class CDecoder :
  432.22 -  public ICompressCoder,
  432.23 -  public ICompressSetDecoderProperties2,
  432.24 -  #ifndef NO_READ_FROM_CODER
  432.25 -  public ICompressSetInStream,
  432.26 -  public ICompressSetOutStreamSize,
  432.27 -  public ISequentialInStream,
  432.28 -  #endif
  432.29 -  public CMyUnknownImp
  432.30 -{
  432.31 -  CRangeDecoder _rangeDecoder;
  432.32 -
  432.33 -  COutBuffer _outStream;
  432.34 -
  432.35 -  CDecodeInfo _info;
  432.36 -
  432.37 -  Byte _order;
  432.38 -  UInt32 _usedMemorySize;
  432.39 -
  432.40 -  int _remainLen;
  432.41 -  UInt64 _outSize;
  432.42 -  bool _outSizeDefined;
  432.43 -  UInt64 _processedSize;
  432.44 -
  432.45 -  HRESULT CodeSpec(UInt32 num, Byte *memStream);
  432.46 -
  432.47 -public:
  432.48 -
  432.49 -  #ifndef NO_READ_FROM_CODER
  432.50 -  MY_UNKNOWN_IMP4(
  432.51 -      ICompressSetDecoderProperties2,
  432.52 -      ICompressSetInStream,
  432.53 -      ICompressSetOutStreamSize,
  432.54 -      ISequentialInStream)
  432.55 -  #else
  432.56 -  MY_UNKNOWN_IMP1(
  432.57 -      ICompressSetDecoderProperties2)
  432.58 -  #endif
  432.59 -
  432.60 -  void ReleaseStreams()
  432.61 -  {
  432.62 -    ReleaseInStream();
  432.63 -    _outStream.ReleaseStream();
  432.64 -  }
  432.65 -
  432.66 -  HRESULT Flush() { return _outStream.Flush(); }
  432.67 -
  432.68 -  STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  432.69 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  432.70 -
  432.71 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  432.72 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  432.73 -
  432.74 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
  432.75 -
  432.76 -  STDMETHOD(SetInStream)(ISequentialInStream *inStream);
  432.77 -  STDMETHOD(ReleaseInStream)();
  432.78 -  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
  432.79 -
  432.80 -  #ifndef NO_READ_FROM_CODER
  432.81 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  432.82 -  #endif
  432.83 -
  432.84 -  CDecoder(): _outSizeDefined(false) {}
  432.85 -};
  432.86 -
  432.87 -}}
  432.88 -
  432.89 -#endif
   433.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   433.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   433.3 @@ -1,20 +0,0 @@
   433.4 -// PpmdRegister.cpp
   433.5 -
   433.6 -#include "StdAfx.h"
   433.7 -
   433.8 -#include "../Common/RegisterCodec.h"
   433.9 -
  433.10 -#include "PpmdDecoder.h"
  433.11 -
  433.12 -static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CDecoder); }
  433.13 -#ifndef EXTRACT_ONLY
  433.14 -#include "PpmdEncoder.h"
  433.15 -static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CEncoder);  }
  433.16 -#else
  433.17 -#define CreateCodecOut 0
  433.18 -#endif
  433.19 -
  433.20 -static CCodecInfo g_CodecInfo =
  433.21 -  { CreateCodec, CreateCodecOut, 0x030401, L"PPMD", 1, false };
  433.22 -
  433.23 -REGISTER_CODEC(PPMD)
   434.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdSubAlloc.h	Sat Mar 03 10:54:39 2012 -0600
   434.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   434.3 @@ -1,295 +0,0 @@
   434.4 -// PpmdSubAlloc.h
   434.5 -// This code is based on Dmitry Shkarin's PPMdH code
   434.6 -
   434.7 -#ifndef __COMPRESS_PPMD_SUB_ALLOC_H
   434.8 -#define __COMPRESS_PPMD_SUB_ALLOC_H
   434.9 -
  434.10 -extern "C"
  434.11 -{
  434.12 -#include "../../../C/Alloc.h"
  434.13 -}
  434.14 -
  434.15 -#include "PpmdType.h"
  434.16 -
  434.17 -const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
  434.18 -const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;
  434.19 -
  434.20 -// Extra 1 * UNIT_SIZE for NULL support
  434.21 -// Extra 2 * UNIT_SIZE for s0 in GlueFreeBlocks()
  434.22 -const UInt32 kExtraSize = (UNIT_SIZE * 3);
  434.23 -const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;
  434.24 -
  434.25 -struct MEM_BLK
  434.26 -{
  434.27 -  UInt16 Stamp, NU;
  434.28 -  UInt32 Next, Prev;
  434.29 -  void InsertAt(Byte *Base, UInt32 p)
  434.30 -  {
  434.31 -    Prev = p;
  434.32 -    MEM_BLK *pp = (MEM_BLK *)(Base + p);
  434.33 -    Next = pp->Next;
  434.34 -    pp->Next = ((MEM_BLK *)(Base + Next))->Prev = (UInt32)((Byte *)this - Base);
  434.35 -  }
  434.36 -  void Remove(Byte *Base)
  434.37 -  {
  434.38 -    ((MEM_BLK *)(Base + Prev))->Next = Next;
  434.39 -    ((MEM_BLK *)(Base + Next))->Prev = Prev;
  434.40 -  }
  434.41 -};
  434.42 -
  434.43 -
  434.44 -class CSubAllocator
  434.45 -{
  434.46 -  UInt32 SubAllocatorSize;
  434.47 -  Byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
  434.48 -  UInt32 FreeList[N_INDEXES];
  434.49 -
  434.50 -  Byte *Base;
  434.51 -  Byte *HeapStart, *LoUnit, *HiUnit;
  434.52 -public:
  434.53 -  Byte *pText, *UnitsStart;
  434.54 -  CSubAllocator():
  434.55 -    SubAllocatorSize(0),
  434.56 -    GlueCount(0),
  434.57 -    LoUnit(0),
  434.58 -    HiUnit(0),
  434.59 -    pText(0),
  434.60 -    UnitsStart(0)
  434.61 -  {
  434.62 -    memset(Indx2Units, 0, sizeof(Indx2Units));
  434.63 -    memset(FreeList, 0, sizeof(FreeList));
  434.64 -  }
  434.65 -  ~CSubAllocator()
  434.66 -  {
  434.67 -    StopSubAllocator();
  434.68 -  };
  434.69 -
  434.70 -  void *GetPtr(UInt32 offset) const { return (offset == 0) ? 0 : (void *)(Base + offset); }
  434.71 -  void *GetPtrNoCheck(UInt32 offset) const { return (void *)(Base + offset); }
  434.72 -  UInt32 GetOffset(void *ptr) const { return (ptr == 0) ? 0 : (UInt32)((Byte *)ptr - Base); }
  434.73 -  UInt32 GetOffsetNoCheck(void *ptr) const { return (UInt32)((Byte *)ptr - Base); }
  434.74 -  MEM_BLK *GetBlk(UInt32 offset) const { return (MEM_BLK *)(Base + offset); }
  434.75 -  UInt32 *GetNode(UInt32 offset) const { return (UInt32 *)(Base + offset); }
  434.76 -
  434.77 -  void InsertNode(void* p, int indx)
  434.78 -  {
  434.79 -    *(UInt32 *)p = FreeList[indx];
  434.80 -    FreeList[indx] = GetOffsetNoCheck(p);
  434.81 -  }
  434.82 -
  434.83 -  void* RemoveNode(int indx)
  434.84 -  {
  434.85 -    UInt32 offset = FreeList[indx];
  434.86 -    UInt32 *p = GetNode(offset);
  434.87 -    FreeList[indx] = *p;
  434.88 -    return (void *)p;
  434.89 -  }
  434.90 -  
  434.91 -  UINT U2B(int NU) const { return (UINT)(NU) * UNIT_SIZE; }
  434.92 -  
  434.93 -  void SplitBlock(void* pv, int oldIndx, int newIndx)
  434.94 -  {
  434.95 -    int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
  434.96 -    Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
  434.97 -    if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
  434.98 -    {
  434.99 -      InsertNode(p, --i);
 434.100 -      p += U2B(i = Indx2Units[i]);
 434.101 -      UDiff -= i;
 434.102 -    }
 434.103 -    InsertNode(p, Units2Indx[UDiff - 1]);
 434.104 -  }
 434.105 -  
 434.106 -  UInt32 GetUsedMemory() const
 434.107 -  {
 434.108 -    UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
 434.109 -    for (UInt32 i = 0; i < N_INDEXES; i++)
 434.110 -      for (UInt32 pn = FreeList[i]; pn != 0; RetVal -= (UInt32)Indx2Units[i] * UNIT_SIZE)
 434.111 -        pn = *GetNode(pn);
 434.112 -    return (RetVal >> 2);
 434.113 -  }
 434.114 -  
 434.115 -  UInt32 GetSubAllocatorSize() const { return SubAllocatorSize; }
 434.116 -
 434.117 -  void StopSubAllocator()
 434.118 -  {
 434.119 -    if (SubAllocatorSize != 0)
 434.120 -    {
 434.121 -      BigFree(Base);
 434.122 -      SubAllocatorSize = 0;
 434.123 -      Base = 0;
 434.124 -    }
 434.125 -  }
 434.126 -
 434.127 -  bool StartSubAllocator(UInt32 size)
 434.128 -  {
 434.129 -    if (SubAllocatorSize == size)
 434.130 -      return true;
 434.131 -    StopSubAllocator();
 434.132 -    if (size == 0)
 434.133 -      Base = 0;
 434.134 -    else
 434.135 -    {
 434.136 -      if ((Base = (Byte *)::BigAlloc(size + kExtraSize)) == 0)
 434.137 -        return false;
 434.138 -      HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
 434.139 -    }
 434.140 -    SubAllocatorSize = size;
 434.141 -    return true;
 434.142 -  }
 434.143 -
 434.144 -  void InitSubAllocator()
 434.145 -  {
 434.146 -    int i, k;
 434.147 -    memset(FreeList, 0, sizeof(FreeList));
 434.148 -    HiUnit = (pText = HeapStart) + SubAllocatorSize;
 434.149 -    UINT Diff = UNIT_SIZE * (SubAllocatorSize / 8 / UNIT_SIZE * 7);
 434.150 -    LoUnit = UnitsStart = HiUnit - Diff;
 434.151 -    for (i = 0, k=1; i < N1 ; i++, k += 1)        Indx2Units[i] = (Byte)k;
 434.152 -    for (k++; i < N1 + N2      ;i++, k += 2)      Indx2Units[i] = (Byte)k;
 434.153 -    for (k++; i < N1 + N2 + N3   ;i++,k += 3)     Indx2Units[i] = (Byte)k;
 434.154 -    for (k++; i < N1 + N2 + N3 + N4; i++, k += 4) Indx2Units[i] = (Byte)k;
 434.155 -    GlueCount = 0;
 434.156 -    for (k = i = 0; k < 128; k++)
 434.157 -    {
 434.158 -      i += (Indx2Units[i] < k+1);
 434.159 -        Units2Indx[k] = (Byte)i;
 434.160 -    }
 434.161 -  }
 434.162 -  
 434.163 -  void GlueFreeBlocks()
 434.164 -  {
 434.165 -    UInt32 s0 = (UInt32)(HeapStart + SubAllocatorSize - Base);
 434.166 -
 434.167 -    // We need add exta MEM_BLK with Stamp=0
 434.168 -    GetBlk(s0)->Stamp = 0;
 434.169 -    s0 += UNIT_SIZE;
 434.170 -    MEM_BLK *ps0 = GetBlk(s0);
 434.171 -
 434.172 -    UInt32 p;
 434.173 -    int i;
 434.174 -    if (LoUnit != HiUnit)
 434.175 -      *LoUnit=0;
 434.176 -    ps0->Next = ps0->Prev = s0;
 434.177 -
 434.178 -    for (i = 0; i < N_INDEXES; i++)
 434.179 -      while (FreeList[i] != 0)
 434.180 -      {
 434.181 -        MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
 434.182 -        pp->InsertAt(Base, s0);
 434.183 -        pp->Stamp = 0xFFFF;
 434.184 -        pp->NU = Indx2Units[i];
 434.185 -      }
 434.186 -    for (p = ps0->Next; p != s0; p = GetBlk(p)->Next)
 434.187 -    {
 434.188 -      for (;;)
 434.189 -      {
 434.190 -        MEM_BLK *pp = GetBlk(p);
 434.191 -        MEM_BLK *pp1 = GetBlk(p + pp->NU * UNIT_SIZE);
 434.192 -        if (pp1->Stamp != 0xFFFF || int(pp->NU) + pp1->NU >= 0x10000)
 434.193 -          break;
 434.194 -        pp1->Remove(Base);
 434.195 -        pp->NU = (UInt16)(pp->NU + pp1->NU);
 434.196 -      }
 434.197 -    }
 434.198 -    while ((p = ps0->Next) != s0)
 434.199 -    {
 434.200 -      MEM_BLK *pp = GetBlk(p);
 434.201 -      pp->Remove(Base);
 434.202 -      int sz;
 434.203 -      for (sz = pp->NU; sz > 128; sz -= 128, p += 128 * UNIT_SIZE)
 434.204 -        InsertNode(Base + p, N_INDEXES - 1);
 434.205 -      if (Indx2Units[i = Units2Indx[sz-1]] != sz)
 434.206 -      {
 434.207 -        int k = sz - Indx2Units[--i];
 434.208 -        InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
 434.209 -      }
 434.210 -      InsertNode(Base + p, i);
 434.211 -    }
 434.212 -  }
 434.213 -  void* AllocUnitsRare(int indx)
 434.214 -  {
 434.215 -    if ( !GlueCount )
 434.216 -    {
 434.217 -      GlueCount = 255;
 434.218 -      GlueFreeBlocks();
 434.219 -      if (FreeList[indx] != 0)
 434.220 -        return RemoveNode(indx);
 434.221 -    }
 434.222 -    int i = indx;
 434.223 -    do
 434.224 -    {
 434.225 -      if (++i == N_INDEXES)
 434.226 -      {
 434.227 -        GlueCount--;
 434.228 -        i = U2B(Indx2Units[indx]);
 434.229 -        return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
 434.230 -      }
 434.231 -    } while (FreeList[i] == 0);
 434.232 -    void* RetVal = RemoveNode(i);
 434.233 -    SplitBlock(RetVal, i, indx);
 434.234 -    return RetVal;
 434.235 -  }
 434.236 -  
 434.237 -  void* AllocUnits(int NU)
 434.238 -  {
 434.239 -    int indx = Units2Indx[NU - 1];
 434.240 -    if (FreeList[indx] != 0)
 434.241 -      return RemoveNode(indx);
 434.242 -    void* RetVal = LoUnit;
 434.243 -    LoUnit += U2B(Indx2Units[indx]);
 434.244 -    if (LoUnit <= HiUnit)
 434.245 -      return RetVal;
 434.246 -    LoUnit -= U2B(Indx2Units[indx]);
 434.247 -    return AllocUnitsRare(indx);
 434.248 -  }
 434.249 -  
 434.250 -  void* AllocContext()
 434.251 -  {
 434.252 -    if (HiUnit != LoUnit)
 434.253 -      return (HiUnit -= UNIT_SIZE);
 434.254 -    if (FreeList[0] != 0)
 434.255 -      return RemoveNode(0);
 434.256 -    return AllocUnitsRare(0);
 434.257 -  }
 434.258 -  
 434.259 -  void* ExpandUnits(void* oldPtr, int oldNU)
 434.260 -  {
 434.261 -    int i0=Units2Indx[oldNU - 1], i1=Units2Indx[oldNU - 1 + 1];
 434.262 -    if (i0 == i1)
 434.263 -      return oldPtr;
 434.264 -    void* ptr = AllocUnits(oldNU + 1);
 434.265 -    if (ptr)
 434.266 -    {
 434.267 -      memcpy(ptr, oldPtr, U2B(oldNU));
 434.268 -      InsertNode(oldPtr, i0);
 434.269 -    }
 434.270 -    return ptr;
 434.271 -  }
 434.272 -  
 434.273 -  void* ShrinkUnits(void* oldPtr, int oldNU, int newNU)
 434.274 -  {
 434.275 -    int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
 434.276 -    if (i0 == i1)
 434.277 -      return oldPtr;
 434.278 -    if (FreeList[i1] != 0)
 434.279 -    {
 434.280 -      void* ptr = RemoveNode(i1);
 434.281 -      memcpy(ptr, oldPtr, U2B(newNU));
 434.282 -      InsertNode(oldPtr,i0);
 434.283 -      return ptr;
 434.284 -    }
 434.285 -    else
 434.286 -    {
 434.287 -      SplitBlock(oldPtr, i0, i1);
 434.288 -      return oldPtr;
 434.289 -    }
 434.290 -  }
 434.291 -  
 434.292 -  void FreeUnits(void* ptr, int oldNU)
 434.293 -  {
 434.294 -    InsertNode(ptr, Units2Indx[oldNU - 1]);
 434.295 -  }
 434.296 -};
 434.297 -
 434.298 -#endif
   435.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/PpmdType.h	Sat Mar 03 10:54:39 2012 -0600
   435.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   435.3 @@ -1,20 +0,0 @@
   435.4 -/****************************************************************************
   435.5 - *  This file is part of PPMd project                                       *
   435.6 - *  Written and distributed to public domain by Dmitry Shkarin 1997,        *
   435.7 - *  1999-2001                                                               *
   435.8 - *  Contents: compilation parameters and miscelaneous definitions           *
   435.9 - *  Comments: system & compiler dependent file
  435.10 - 
  435.11 - *  modified by Igor Pavlov (2004-08-29).
  435.12 - ****************************************************************************/
  435.13 -
  435.14 -#ifndef __COMPRESS_PPMD_TYPE_H
  435.15 -#define __COMPRESS_PPMD_TYPE_H
  435.16 -
  435.17 -const int kMaxOrderCompress = 32;
  435.18 -const int MAX_O = 255; /* maximum allowed model order */
  435.19 -
  435.20 -template <class T>
  435.21 -inline void _PPMD_SWAP(T& t1,T& t2) { T tmp = t1; t1 = t2; t2 = tmp; }
  435.22 -
  435.23 -#endif
   436.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/RangeCoder.h	Sat Mar 03 10:54:39 2012 -0600
   436.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   436.3 @@ -1,204 +0,0 @@
   436.4 -// Compress/RangeCoder.h
   436.5 -
   436.6 -#ifndef __COMPRESS_RANGE_CODER_H
   436.7 -#define __COMPRESS_RANGE_CODER_H
   436.8 -
   436.9 -#include "../Common/InBuffer.h"
  436.10 -#include "../Common/OutBuffer.h"
  436.11 -
  436.12 -namespace NCompress {
  436.13 -namespace NRangeCoder {
  436.14 -
  436.15 -const int kNumTopBits = 24;
  436.16 -const UInt32 kTopValue = (1 << kNumTopBits);
  436.17 -
  436.18 -class CEncoder
  436.19 -{
  436.20 -  UInt32 _cacheSize;
  436.21 -  Byte _cache;
  436.22 -public:
  436.23 -  UInt64 Low;
  436.24 -  UInt32 Range;
  436.25 -  COutBuffer Stream;
  436.26 -  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
  436.27 -
  436.28 -  void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
  436.29 -  void Init()
  436.30 -  {
  436.31 -    Stream.Init();
  436.32 -    Low = 0;
  436.33 -    Range = 0xFFFFFFFF;
  436.34 -    _cacheSize = 1;
  436.35 -    _cache = 0;
  436.36 -  }
  436.37 -
  436.38 -  void FlushData()
  436.39 -  {
  436.40 -    // Low += 1;
  436.41 -    for(int i = 0; i < 5; i++)
  436.42 -      ShiftLow();
  436.43 -  }
  436.44 -
  436.45 -  HRESULT FlushStream() { return Stream.Flush();  }
  436.46 -
  436.47 -  void ReleaseStream() { Stream.ReleaseStream(); }
  436.48 -
  436.49 -  void Encode(UInt32 start, UInt32 size, UInt32 total)
  436.50 -  {
  436.51 -    Low += start * (Range /= total);
  436.52 -    Range *= size;
  436.53 -    while (Range < kTopValue)
  436.54 -    {
  436.55 -      Range <<= 8;
  436.56 -      ShiftLow();
  436.57 -    }
  436.58 -  }
  436.59 -
  436.60 -  void ShiftLow()
  436.61 -  {
  436.62 -    if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
  436.63 -    {
  436.64 -      Byte temp = _cache;
  436.65 -      do
  436.66 -      {
  436.67 -        Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
  436.68 -        temp = 0xFF;
  436.69 -      }
  436.70 -      while(--_cacheSize != 0);
  436.71 -      _cache = (Byte)((UInt32)Low >> 24);
  436.72 -    }
  436.73 -    _cacheSize++;
  436.74 -    Low = (UInt32)Low << 8;
  436.75 -  }
  436.76 -  
  436.77 -  void EncodeDirectBits(UInt32 value, int numBits)
  436.78 -  {
  436.79 -    for (numBits--; numBits >= 0; numBits--)
  436.80 -    {
  436.81 -      Range >>= 1;
  436.82 -      Low += Range & (0 - ((value >> numBits) & 1));
  436.83 -      if (Range < kTopValue)
  436.84 -      {
  436.85 -        Range <<= 8;
  436.86 -        ShiftLow();
  436.87 -      }
  436.88 -    }
  436.89 -  }
  436.90 -
  436.91 -  void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)
  436.92 -  {
  436.93 -    UInt32 newBound = (Range >> numTotalBits) * size0;
  436.94 -    if (symbol == 0)
  436.95 -      Range = newBound;
  436.96 -    else
  436.97 -    {
  436.98 -      Low += newBound;
  436.99 -      Range -= newBound;
 436.100 -    }
 436.101 -    while (Range < kTopValue)
 436.102 -    {
 436.103 -      Range <<= 8;
 436.104 -      ShiftLow();
 436.105 -    }
 436.106 -  }
 436.107 -
 436.108 -  UInt64 GetProcessedSize() {  return Stream.GetProcessedSize() + _cacheSize + 4; }
 436.109 -};
 436.110 -
 436.111 -class CDecoder
 436.112 -{
 436.113 -public:
 436.114 -  CInBuffer Stream;
 436.115 -  UInt32 Range;
 436.116 -  UInt32 Code;
 436.117 -  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
 436.118 -
 436.119 -  void Normalize()
 436.120 -  {
 436.121 -    while (Range < kTopValue)
 436.122 -    {
 436.123 -      Code = (Code << 8) | Stream.ReadByte();
 436.124 -      Range <<= 8;
 436.125 -    }
 436.126 -  }
 436.127 -  
 436.128 -  void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
 436.129 -  void Init()
 436.130 -  {
 436.131 -    Stream.Init();
 436.132 -    Code = 0;
 436.133 -    Range = 0xFFFFFFFF;
 436.134 -    for(int i = 0; i < 5; i++)
 436.135 -      Code = (Code << 8) | Stream.ReadByte();
 436.136 -  }
 436.137 -
 436.138 -  void ReleaseStream() { Stream.ReleaseStream(); }
 436.139 -
 436.140 -  UInt32 GetThreshold(UInt32 total)
 436.141 -  {
 436.142 -    return (Code) / ( Range /= total);
 436.143 -  }
 436.144 -
 436.145 -  void Decode(UInt32 start, UInt32 size)
 436.146 -  {
 436.147 -    Code -= start * Range;
 436.148 -    Range *= size;
 436.149 -    Normalize();
 436.150 -  }
 436.151 -
 436.152 -  UInt32 DecodeDirectBits(int numTotalBits)
 436.153 -  {
 436.154 -    UInt32 range = Range;
 436.155 -    UInt32 code = Code;
 436.156 -    UInt32 result = 0;
 436.157 -    for (int i = numTotalBits; i != 0; i--)
 436.158 -    {
 436.159 -      range >>= 1;
 436.160 -      /*
 436.161 -      result <<= 1;
 436.162 -      if (code >= range)
 436.163 -      {
 436.164 -        code -= range;
 436.165 -        result |= 1;
 436.166 -      }
 436.167 -      */
 436.168 -      UInt32 t = (code - range) >> 31;
 436.169 -      code -= range & (t - 1);
 436.170 -      result = (result << 1) | (1 - t);
 436.171 -
 436.172 -      if (range < kTopValue)
 436.173 -      {
 436.174 -        code = (code << 8) | Stream.ReadByte();
 436.175 -        range <<= 8;
 436.176 -      }
 436.177 -    }
 436.178 -    Range = range;
 436.179 -    Code = code;
 436.180 -    return result;
 436.181 -  }
 436.182 -
 436.183 -  UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
 436.184 -  {
 436.185 -    UInt32 newBound = (Range >> numTotalBits) * size0;
 436.186 -    UInt32 symbol;
 436.187 -    if (Code < newBound)
 436.188 -    {
 436.189 -      symbol = 0;
 436.190 -      Range = newBound;
 436.191 -    }
 436.192 -    else
 436.193 -    {
 436.194 -      symbol = 1;
 436.195 -      Code -= newBound;
 436.196 -      Range -= newBound;
 436.197 -    }
 436.198 -    Normalize();
 436.199 -    return symbol;
 436.200 -  }
 436.201 -
 436.202 -  UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
 436.203 -};
 436.204 -
 436.205 -}}
 436.206 -
 436.207 -#endif
   437.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/RangeCoderBit.h	Sat Mar 03 10:54:39 2012 -0600
   437.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   437.3 @@ -1,113 +0,0 @@
   437.4 -// Compress/RangeCoderBit.h
   437.5 -
   437.6 -#ifndef __COMPRESS_RANGE_CODER_BIT_H
   437.7 -#define __COMPRESS_RANGE_CODER_BIT_H
   437.8 -
   437.9 -#include "RangeCoder.h"
  437.10 -
  437.11 -namespace NCompress {
  437.12 -namespace NRangeCoder {
  437.13 -
  437.14 -const int kNumBitModelTotalBits  = 11;
  437.15 -const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
  437.16 -
  437.17 -const int kNumMoveReducingBits = 4;
  437.18 -
  437.19 -const int kNumBitPriceShiftBits = 4;
  437.20 -const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
  437.21 -
  437.22 -extern UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
  437.23 -
  437.24 -template <int numMoveBits>
  437.25 -class CBitModel
  437.26 -{
  437.27 -public:
  437.28 -  UInt32 Prob;
  437.29 -  void UpdateModel(UInt32 symbol)
  437.30 -  {
  437.31 -    /*
  437.32 -    Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
  437.33 -    Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
  437.34 -    */
  437.35 -    if (symbol == 0)
  437.36 -      Prob += (kBitModelTotal - Prob) >> numMoveBits;
  437.37 -    else
  437.38 -      Prob -= (Prob) >> numMoveBits;
  437.39 -  }
  437.40 -public:
  437.41 -  void Init() { Prob = kBitModelTotal / 2; }
  437.42 -};
  437.43 -
  437.44 -template <int numMoveBits>
  437.45 -class CBitEncoder: public CBitModel<numMoveBits>
  437.46 -{
  437.47 -public:
  437.48 -  void Encode(CEncoder *encoder, UInt32 symbol)
  437.49 -  {
  437.50 -    /*
  437.51 -    encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
  437.52 -    this->UpdateModel(symbol);
  437.53 -    */
  437.54 -    UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
  437.55 -    if (symbol == 0)
  437.56 -    {
  437.57 -      encoder->Range = newBound;
  437.58 -      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
  437.59 -    }
  437.60 -    else
  437.61 -    {
  437.62 -      encoder->Low += newBound;
  437.63 -      encoder->Range -= newBound;
  437.64 -      this->Prob -= (this->Prob) >> numMoveBits;
  437.65 -    }
  437.66 -    if (encoder->Range < kTopValue)
  437.67 -    {
  437.68 -      encoder->Range <<= 8;
  437.69 -      encoder->ShiftLow();
  437.70 -    }
  437.71 -  }
  437.72 -  UInt32 GetPrice(UInt32 symbol) const
  437.73 -  {
  437.74 -    return ProbPrices[(this->Prob ^ ((-(int)symbol)) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
  437.75 -  }
  437.76 -  UInt32 GetPrice0() const { return ProbPrices[this->Prob >> kNumMoveReducingBits]; }
  437.77 -  UInt32 GetPrice1() const { return ProbPrices[(this->Prob ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]; }
  437.78 -};
  437.79 -
  437.80 -
  437.81 -template <int numMoveBits>
  437.82 -class CBitDecoder: public CBitModel<numMoveBits>
  437.83 -{
  437.84 -public:
  437.85 -  UInt32 Decode(CDecoder *decoder)
  437.86 -  {
  437.87 -    UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
  437.88 -    if (decoder->Code < newBound)
  437.89 -    {
  437.90 -      decoder->Range = newBound;
  437.91 -      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
  437.92 -      if (decoder->Range < kTopValue)
  437.93 -      {
  437.94 -        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
  437.95 -        decoder->Range <<= 8;
  437.96 -      }
  437.97 -      return 0;
  437.98 -    }
  437.99 -    else
 437.100 -    {
 437.101 -      decoder->Range -= newBound;
 437.102 -      decoder->Code -= newBound;
 437.103 -      this->Prob -= (this->Prob) >> numMoveBits;
 437.104 -      if (decoder->Range < kTopValue)
 437.105 -      {
 437.106 -        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
 437.107 -        decoder->Range <<= 8;
 437.108 -      }
 437.109 -      return 1;
 437.110 -    }
 437.111 -  }
 437.112 -};
 437.113 -
 437.114 -}}
 437.115 -
 437.116 -#endif
   438.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar1Decoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   438.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   438.3 @@ -1,478 +0,0 @@
   438.4 -// Rar1Decoder.cpp
   438.5 -// According to unRAR license, this code may not be used to develop
   438.6 -// a program that creates RAR archives
   438.7 - 
   438.8 -#include "StdAfx.h"
   438.9 -
  438.10 -#include "Rar1Decoder.h"
  438.11 -
  438.12 -namespace NCompress {
  438.13 -namespace NRar1 {
  438.14 -
  438.15 -static UInt32 PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32, 256};
  438.16 -static UInt32 PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36, 256};
  438.17 -static UInt32 PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33, 257};
  438.18 -static UInt32 PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127, 257};
  438.19 -static UInt32 PosHf2[]={0,0,0,0,0,0,2,7,53,117,233, 257,0};
  438.20 -static UInt32 PosHf3[]={0,0,0,0,0,0,0,2,16,218,251, 257,0};
  438.21 -static UInt32 PosHf4[]={0,0,0,0,0,0,0,0,0,255, 257,0,0};
  438.22 -
  438.23 -static const UInt32 kHistorySize = (1 << 16);
  438.24 -
  438.25 -class CCoderReleaser
  438.26 -{
  438.27 -  CDecoder *m_Coder;
  438.28 -public:
  438.29 -  CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
  438.30 -  ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
  438.31 -};
  438.32 -
  438.33 -CDecoder::CDecoder(): m_IsSolid(false) { }
  438.34 -
  438.35 -void CDecoder::InitStructures()
  438.36 -{
  438.37 -  for(int i = 0; i < kNumRepDists; i++)
  438.38 -    m_RepDists[i] = 0;
  438.39 -  m_RepDistPtr = 0;
  438.40 -  LastLength = 0;
  438.41 -  LastDist = 0;
  438.42 -}
  438.43 -
  438.44 -UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
  438.45 -
  438.46 -HRESULT CDecoder::CopyBlock(UInt32 distance, UInt32 len)
  438.47 -{
  438.48 -  m_UnpackSize -= len;
  438.49 -  return m_OutWindowStream.CopyBlock(distance, len) ? S_OK : S_FALSE;
  438.50 -}
  438.51 -
  438.52 -
  438.53 -UInt32 CDecoder::DecodeNum(const UInt32 *posTab)
  438.54 -{
  438.55 -  UInt32 startPos = 2;
  438.56 -  UInt32 num = m_InBitStream.GetValue(12);
  438.57 -  for (;;)
  438.58 -  {
  438.59 -    UInt32 cur = (posTab[startPos + 1] - posTab[startPos]) << (12 - startPos);
  438.60 -    if (num < cur)
  438.61 -      break;
  438.62 -    startPos++;
  438.63 -    num -= cur;
  438.64 -  }
  438.65 -  m_InBitStream.MovePos(startPos);
  438.66 -  return((num >> (12 - startPos)) + posTab[startPos]);
  438.67 -}
  438.68 -
  438.69 -static Byte kShortLen1[]  = {1,3,4,4,5,6,7,8,8,4,4,5,6,6 };
  438.70 -static Byte kShortLen1a[] = {1,4,4,4,5,6,7,8,8,4,4,5,6,6,4 };
  438.71 -static Byte kShortLen2[]  = {2,3,3,3,4,4,5,6,6,4,4,5,6,6 };
  438.72 -static Byte kShortLen2a[] = {2,3,3,4,4,4,5,6,6,4,4,5,6,6,4 };
  438.73 -static UInt32 kShortXor1[] = {0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
  438.74 -static UInt32 kShortXor2[] = {0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
  438.75 -
  438.76 -HRESULT CDecoder::ShortLZ()
  438.77 -{
  438.78 -  UInt32 len, saveLen, dist;
  438.79 -  int distancePlace;
  438.80 -  Byte *kShortLen;
  438.81 -  const UInt32 *kShortXor;
  438.82 -  NumHuf = 0;
  438.83 -
  438.84 -  if (LCount == 2)
  438.85 -  {
  438.86 -    if (ReadBits(1))
  438.87 -      return CopyBlock(LastDist, LastLength);
  438.88 -    LCount = 0;
  438.89 -  }
  438.90 -
  438.91 -  UInt32 bitField = m_InBitStream.GetValue(8);
  438.92 -
  438.93 -  if (AvrLn1 < 37)
  438.94 -  {
  438.95 -    kShortLen = Buf60 ? kShortLen1a : kShortLen1;
  438.96 -    kShortXor = kShortXor1;
  438.97 -  }
  438.98 -  else
  438.99 -  {
 438.100 -    kShortLen = Buf60 ? kShortLen2a : kShortLen2;
 438.101 -    kShortXor = kShortXor2;
 438.102 -  }
 438.103 -
 438.104 -  for (len = 0; ((bitField ^ kShortXor[len]) & (~(0xff >> kShortLen[len]))) != 0; len++);
 438.105 -  m_InBitStream.MovePos(kShortLen[len]);
 438.106 -
 438.107 -  if (len >= 9)
 438.108 -  {
 438.109 -    if (len == 9)
 438.110 -    {
 438.111 -      LCount++;
 438.112 -      return CopyBlock(LastDist, LastLength);
 438.113 -    }
 438.114 -    if (len == 14)
 438.115 -    {
 438.116 -      LCount = 0;
 438.117 -      len = DecodeNum(PosL2) + 5;
 438.118 -      dist = 0x8000 + ReadBits(15) - 1;
 438.119 -      LastLength = len;
 438.120 -      LastDist = dist;
 438.121 -      return CopyBlock(dist, len);
 438.122 -    }
 438.123 -
 438.124 -    LCount = 0;
 438.125 -    saveLen = len;
 438.126 -    dist = m_RepDists[(m_RepDistPtr - (len - 9)) & 3];
 438.127 -    len = DecodeNum(PosL1) + 2;
 438.128 -    if (len == 0x101 && saveLen == 10)
 438.129 -    {
 438.130 -      Buf60 ^= 1;
 438.131 -      return S_OK;
 438.132 -    }
 438.133 -    if (dist >= 256)
 438.134 -      len++;
 438.135 -    if (dist >= MaxDist3 - 1)
 438.136 -      len++;
 438.137 -  }
 438.138 -  else
 438.139 -  {
 438.140 -    LCount = 0;
 438.141 -    AvrLn1 += len;
 438.142 -    AvrLn1 -= AvrLn1 >> 4;
 438.143 -    
 438.144 -    distancePlace = DecodeNum(PosHf2) & 0xff;
 438.145 -    dist = ChSetA[distancePlace];
 438.146 -    if (--distancePlace != -1)
 438.147 -    {
 438.148 -      PlaceA[dist]--;
 438.149 -      UInt32 lastDistance = ChSetA[distancePlace];
 438.150 -      PlaceA[lastDistance]++;
 438.151 -      ChSetA[distancePlace + 1] = lastDistance;
 438.152 -      ChSetA[distancePlace] = dist;
 438.153 -    }
 438.154 -    len += 2;
 438.155 -  }
 438.156 -  m_RepDists[m_RepDistPtr++] = dist;
 438.157 -  m_RepDistPtr &= 3;
 438.158 -  LastLength = len;
 438.159 -  LastDist = dist;
 438.160 -  return CopyBlock(dist, len);
 438.161 -}
 438.162 -
 438.163 -
 438.164 -HRESULT CDecoder::LongLZ()
 438.165 -{
 438.166 -  UInt32 len;
 438.167 -  UInt32 dist;
 438.168 -  UInt32 distancePlace, newDistancePlace;
 438.169 -  UInt32 oldAvr2, oldAvr3;
 438.170 -
 438.171 -  NumHuf = 0;
 438.172 -  Nlzb += 16;
 438.173 -  if (Nlzb > 0xff)
 438.174 -  {
 438.175 -    Nlzb = 0x90;
 438.176 -    Nhfb >>= 1;
 438.177 -  }
 438.178 -  oldAvr2=AvrLn2;
 438.179 -
 438.180 -  if (AvrLn2 >= 122)
 438.181 -    len = DecodeNum(PosL2);
 438.182 -  else if (AvrLn2 >= 64)
 438.183 -    len = DecodeNum(PosL1);
 438.184 -  else
 438.185 -  {
 438.186 -    UInt32 bitField = m_InBitStream.GetValue(16);
 438.187 -    if (bitField < 0x100)
 438.188 -    {
 438.189 -      len = bitField;
 438.190 -      m_InBitStream.MovePos(16);
 438.191 -    }
 438.192 -    else
 438.193 -    {
 438.194 -      for (len = 0; ((bitField << len) & 0x8000) == 0; len++)
 438.195 -        ;
 438.196 -      m_InBitStream.MovePos(len + 1);
 438.197 -    }
 438.198 -  }
 438.199 -
 438.200 -  AvrLn2 += len;
 438.201 -  AvrLn2 -= AvrLn2 >> 5;
 438.202 -
 438.203 -  if (AvrPlcB > 0x28ff)
 438.204 -    distancePlace = DecodeNum(PosHf2);
 438.205 -  else if (AvrPlcB > 0x6ff)
 438.206 -    distancePlace = DecodeNum(PosHf1);
 438.207 -  else
 438.208 -    distancePlace = DecodeNum(PosHf0);
 438.209 -
 438.210 -  AvrPlcB += distancePlace;
 438.211 -  AvrPlcB -= AvrPlcB >> 8;
 438.212 -  for (;;)
 438.213 -  {
 438.214 -    dist = ChSetB[distancePlace & 0xff];
 438.215 -    newDistancePlace = NToPlB[dist++ & 0xff]++;
 438.216 -    if (!(dist & 0xff))
 438.217 -      CorrHuff(ChSetB,NToPlB);
 438.218 -    else
 438.219 -      break;
 438.220 -  }
 438.221 -
 438.222 -  ChSetB[distancePlace] = ChSetB[newDistancePlace];
 438.223 -  ChSetB[newDistancePlace] = dist;
 438.224 -
 438.225 -  dist = ((dist & 0xff00) >> 1) | ReadBits(7);
 438.226 -
 438.227 -  oldAvr3 = AvrLn3;
 438.228 -  if (len != 1 && len != 4)
 438.229 -    if (len == 0 && dist <= MaxDist3)
 438.230 -    {
 438.231 -      AvrLn3++;
 438.232 -      AvrLn3 -= AvrLn3 >> 8;
 438.233 -    }
 438.234 -    else
 438.235 -      if (AvrLn3 > 0)
 438.236 -        AvrLn3--;
 438.237 -  len += 3;
 438.238 -  if (dist >= MaxDist3)
 438.239 -    len++;
 438.240 -  if (dist <= 256)
 438.241 -    len += 8;
 438.242 -  if (oldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && oldAvr2 < 0x40)
 438.243 -    MaxDist3 = 0x7f00;
 438.244 -  else
 438.245 -    MaxDist3 = 0x2001;
 438.246 -  m_RepDists[m_RepDistPtr++] = --dist;
 438.247 -  m_RepDistPtr &= 3;
 438.248 -  LastLength = len;
 438.249 -  LastDist = dist;
 438.250 -  return CopyBlock(dist, len);
 438.251 -}
 438.252 -
 438.253 -
 438.254 -HRESULT CDecoder::HuffDecode()
 438.255 -{
 438.256 -  UInt32 curByte, newBytePlace;
 438.257 -  UInt32 len;
 438.258 -  UInt32 dist;
 438.259 -  int bytePlace;
 438.260 -
 438.261 -  if      (AvrPlc > 0x75ff)  bytePlace = DecodeNum(PosHf4);
 438.262 -  else if (AvrPlc > 0x5dff)  bytePlace = DecodeNum(PosHf3);
 438.263 -  else if (AvrPlc > 0x35ff)  bytePlace = DecodeNum(PosHf2);
 438.264 -  else if (AvrPlc > 0x0dff)  bytePlace = DecodeNum(PosHf1);
 438.265 -  else                       bytePlace = DecodeNum(PosHf0);
 438.266 -  if (StMode)
 438.267 -  {
 438.268 -    if (--bytePlace == -1)
 438.269 -    {
 438.270 -      if (ReadBits(1))
 438.271 -      {
 438.272 -        NumHuf = StMode = 0;
 438.273 -        return S_OK;
 438.274 -      }
 438.275 -      else
 438.276 -      {
 438.277 -        len = (ReadBits(1)) ? 4 : 3;
 438.278 -        dist = DecodeNum(PosHf2);
 438.279 -        dist = (dist << 5) | ReadBits(5);
 438.280 -        return CopyBlock(dist - 1, len);
 438.281 -      }
 438.282 -    }
 438.283 -  }
 438.284 -  else if (NumHuf++ >= 16 && FlagsCnt == 0)
 438.285 -    StMode = 1;
 438.286 -  bytePlace &= 0xff;
 438.287 -  AvrPlc += bytePlace;
 438.288 -  AvrPlc -= AvrPlc >> 8;
 438.289 -  Nhfb+=16;
 438.290 -  if (Nhfb > 0xff)
 438.291 -  {
 438.292 -    Nhfb=0x90;
 438.293 -    Nlzb >>= 1;
 438.294 -  }
 438.295 -
 438.296 -  m_UnpackSize --;
 438.297 -  m_OutWindowStream.PutByte((Byte)(ChSet[bytePlace] >> 8));
 438.298 -
 438.299 -  for (;;)
 438.300 -  {
 438.301 -    curByte = ChSet[bytePlace];
 438.302 -    newBytePlace = NToPl[curByte++ & 0xff]++;
 438.303 -    if ((curByte & 0xff) > 0xa1)
 438.304 -      CorrHuff(ChSet, NToPl);
 438.305 -    else
 438.306 -      break;
 438.307 -  }
 438.308 -
 438.309 -  ChSet[bytePlace] = ChSet[newBytePlace];
 438.310 -  ChSet[newBytePlace] = curByte;
 438.311 -  return S_OK;
 438.312 -}
 438.313 -
 438.314 -
 438.315 -void CDecoder::GetFlagsBuf()
 438.316 -{
 438.317 -  UInt32 flags, newFlagsPlace;
 438.318 -  UInt32 flagsPlace = DecodeNum(PosHf2);
 438.319 -
 438.320 -  for (;;)
 438.321 -  {
 438.322 -    flags = ChSetC[flagsPlace];
 438.323 -    FlagBuf = flags >> 8;
 438.324 -    newFlagsPlace = NToPlC[flags++ & 0xff]++;
 438.325 -    if ((flags & 0xff) != 0)
 438.326 -      break;
 438.327 -    CorrHuff(ChSetC, NToPlC);
 438.328 -  }
 438.329 -
 438.330 -  ChSetC[flagsPlace] = ChSetC[newFlagsPlace];
 438.331 -  ChSetC[newFlagsPlace] = flags;
 438.332 -}
 438.333 -
 438.334 -void CDecoder::InitData()
 438.335 -{
 438.336 -  if (!m_IsSolid)
 438.337 -  {
 438.338 -    AvrPlcB = AvrLn1 = AvrLn2 = AvrLn3 = NumHuf = Buf60 = 0;
 438.339 -    AvrPlc = 0x3500;
 438.340 -    MaxDist3 = 0x2001;
 438.341 -    Nhfb = Nlzb = 0x80;
 438.342 -  }
 438.343 -  FlagsCnt = 0;
 438.344 -  FlagBuf = 0;
 438.345 -  StMode = 0;
 438.346 -  LCount = 0;
 438.347 -}
 438.348 -
 438.349 -void CDecoder::CorrHuff(UInt32 *CharSet,UInt32 *NumToPlace)
 438.350 -{
 438.351 -  int i;
 438.352 -  for (i = 7; i >= 0; i--)
 438.353 -    for (int j = 0; j < 32; j++, CharSet++)
 438.354 -      *CharSet = (*CharSet & ~0xff) | i;
 438.355 -  memset(NumToPlace, 0, sizeof(NToPl));
 438.356 -  for (i = 6; i >= 0; i--)
 438.357 -    NumToPlace[i] = (7 - i) * 32;
 438.358 -}
 438.359 -
 438.360 -void CDecoder::InitHuff()
 438.361 -{
 438.362 -  for (UInt32 i = 0; i < 256; i++)
 438.363 -  {
 438.364 -    Place[i] = PlaceA[i] = PlaceB[i] = i;
 438.365 -    PlaceC[i] = (~i + 1) & 0xff;
 438.366 -    ChSet[i] = ChSetB[i] = i << 8;
 438.367 -    ChSetA[i] = i;
 438.368 -    ChSetC[i] = ((~i + 1) & 0xff) << 8;
 438.369 -  }
 438.370 -  memset(NToPl, 0, sizeof(NToPl));
 438.371 -  memset(NToPlB, 0, sizeof(NToPlB));
 438.372 -  memset(NToPlC, 0, sizeof(NToPlC));
 438.373 -  CorrHuff(ChSetB, NToPlB);
 438.374 -}
 438.375 -
 438.376 -HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 438.377 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo * /* progress */)
 438.378 -{
 438.379 -  if (inSize == NULL || outSize == NULL)
 438.380 -    return E_INVALIDARG;
 438.381 -
 438.382 -  if (!m_OutWindowStream.Create(kHistorySize))
 438.383 -    return E_OUTOFMEMORY;
 438.384 -  if (!m_InBitStream.Create(1 << 20))
 438.385 -    return E_OUTOFMEMORY;
 438.386 -
 438.387 -  m_UnpackSize = (Int64)*outSize;
 438.388 -  m_OutWindowStream.SetStream(outStream);
 438.389 -  m_OutWindowStream.Init(m_IsSolid);
 438.390 -  m_InBitStream.SetStream(inStream);
 438.391 -  m_InBitStream.Init();
 438.392 -
 438.393 -  CCoderReleaser coderReleaser(this);
 438.394 -  InitData();
 438.395 -  if (!m_IsSolid)
 438.396 -  {
 438.397 -    InitStructures();
 438.398 -    InitHuff();
 438.399 -  }
 438.400 -  if (m_UnpackSize > 0)
 438.401 -  {
 438.402 -    GetFlagsBuf();
 438.403 -    FlagsCnt = 8;
 438.404 -  }
 438.405 -
 438.406 -  while (m_UnpackSize > 0)
 438.407 -  {
 438.408 -    if (StMode)
 438.409 -    {
 438.410 -      RINOK(HuffDecode());
 438.411 -      continue;
 438.412 -    }
 438.413 -
 438.414 -    if (--FlagsCnt < 0)
 438.415 -    {
 438.416 -      GetFlagsBuf();
 438.417 -      FlagsCnt=7;
 438.418 -    }
 438.419 -
 438.420 -    if (FlagBuf & 0x80)
 438.421 -    {
 438.422 -      FlagBuf <<= 1;
 438.423 -      if (Nlzb > Nhfb)
 438.424 -      {
 438.425 -        RINOK(LongLZ());
 438.426 -      }
 438.427 -      else
 438.428 -      {
 438.429 -        RINOK(HuffDecode());
 438.430 -      }
 438.431 -    }
 438.432 -    else
 438.433 -    {
 438.434 -      FlagBuf <<= 1;
 438.435 -      if (--FlagsCnt < 0)
 438.436 -      {
 438.437 -        GetFlagsBuf();
 438.438 -        FlagsCnt = 7;
 438.439 -      }
 438.440 -      if (FlagBuf & 0x80)
 438.441 -      {
 438.442 -        FlagBuf <<= 1;
 438.443 -        if (Nlzb > Nhfb)
 438.444 -        {
 438.445 -          RINOK(HuffDecode());
 438.446 -        }
 438.447 -        else
 438.448 -        {
 438.449 -          RINOK(LongLZ());
 438.450 -        }
 438.451 -      }
 438.452 -      else
 438.453 -      {
 438.454 -        FlagBuf <<= 1;
 438.455 -        RINOK(ShortLZ());
 438.456 -      }
 438.457 -    }
 438.458 -  }
 438.459 -  if (m_UnpackSize < 0)
 438.460 -    return S_FALSE;
 438.461 -  return m_OutWindowStream.Flush();
 438.462 -}
 438.463 -
 438.464 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 438.465 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 438.466 -{
 438.467 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
 438.468 -  catch(const CInBufferException &e) { return e.ErrorCode; }
 438.469 -  catch(const CLzOutWindowException &e) { return e.ErrorCode; }
 438.470 -  catch(...) { return S_FALSE; }
 438.471 -}
 438.472 -
 438.473 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 438.474 -{
 438.475 -  if (size < 1)
 438.476 -    return E_INVALIDARG;
 438.477 -  m_IsSolid = (data[0] != 0);
 438.478 -  return S_OK;
 438.479 -}
 438.480 -
 438.481 -}}
   439.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar1Decoder.h	Sat Mar 03 10:54:39 2012 -0600
   439.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   439.3 @@ -1,88 +0,0 @@
   439.4 -// Rar1Decoder.h
   439.5 -// According to unRAR license, this code may not be used to develop
   439.6 -// a program that creates RAR archives
   439.7 -
   439.8 -#ifndef __COMPRESS_RAR1_DECODER_H
   439.9 -#define __COMPRESS_RAR1_DECODER_H
  439.10 -
  439.11 -#include "../../Common/MyCom.h"
  439.12 -
  439.13 -#include "../ICoder.h"
  439.14 -
  439.15 -#include "../Common/InBuffer.h"
  439.16 -
  439.17 -#include "BitmDecoder.h"
  439.18 -#include "HuffmanDecoder.h"
  439.19 -#include "LzOutWindow.h"
  439.20 -
  439.21 -namespace NCompress {
  439.22 -namespace NRar1 {
  439.23 -
  439.24 -const UInt32 kNumRepDists = 4;
  439.25 -
  439.26 -typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
  439.27 -
  439.28 -class CDecoder :
  439.29 -  public ICompressCoder,
  439.30 -  public ICompressSetDecoderProperties2,
  439.31 -  public CMyUnknownImp
  439.32 -{
  439.33 -public:
  439.34 -  CLzOutWindow m_OutWindowStream;
  439.35 -  CBitDecoder m_InBitStream;
  439.36 -
  439.37 -  UInt32 m_RepDists[kNumRepDists];
  439.38 -  UInt32 m_RepDistPtr;
  439.39 -
  439.40 -  UInt32 LastDist;
  439.41 -  UInt32 LastLength;
  439.42 -
  439.43 -  Int64 m_UnpackSize;
  439.44 -  bool m_IsSolid;
  439.45 -
  439.46 -  UInt32 ReadBits(int numBits);
  439.47 -  HRESULT CopyBlock(UInt32 distance, UInt32 len);
  439.48 -
  439.49 -  UInt32 DecodeNum(const UInt32 *posTab);
  439.50 -  HRESULT ShortLZ();
  439.51 -  HRESULT LongLZ();
  439.52 -  HRESULT HuffDecode();
  439.53 -  void GetFlagsBuf();
  439.54 -  void InitData();
  439.55 -  void InitHuff();
  439.56 -  void CorrHuff(UInt32 *CharSet, UInt32 *NumToPlace);
  439.57 -  void OldUnpWriteBuf();
  439.58 -  
  439.59 -  UInt32 ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
  439.60 -  UInt32 Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
  439.61 -  UInt32 NToPl[256],NToPlB[256],NToPlC[256];
  439.62 -  UInt32 FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
  439.63 -  int Buf60,NumHuf,StMode,LCount,FlagsCnt;
  439.64 -  UInt32 Nhfb,Nlzb,MaxDist3;
  439.65 -
  439.66 -  void InitStructures();
  439.67 -
  439.68 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  439.69 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  439.70 -
  439.71 -public:
  439.72 -  CDecoder();
  439.73 -
  439.74 -  MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
  439.75 -
  439.76 -  void ReleaseStreams()
  439.77 -  {
  439.78 -    m_OutWindowStream.ReleaseStream();
  439.79 -    m_InBitStream.ReleaseStream();
  439.80 -  }
  439.81 -
  439.82 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  439.83 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  439.84 -
  439.85 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
  439.86 -
  439.87 -};
  439.88 -
  439.89 -}}
  439.90 -
  439.91 -#endif
   440.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar2Decoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   440.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   440.3 @@ -1,389 +0,0 @@
   440.4 -// Rar2Decoder.cpp
   440.5 -// According to unRAR license, this code may not be used to develop
   440.6 -// a program that creates RAR archives
   440.7 - 
   440.8 -#include "StdAfx.h"
   440.9 -
  440.10 -#include "Rar2Decoder.h"
  440.11 -
  440.12 -namespace NCompress {
  440.13 -namespace NRar2 {
  440.14 -
  440.15 -namespace NMultimedia {
  440.16 -
  440.17 -Byte CFilter::Decode(int &channelDelta, Byte deltaByte)
  440.18 -{
  440.19 -  D4 = D3;
  440.20 -  D3 = D2;
  440.21 -  D2 = LastDelta - D1;
  440.22 -  D1 = LastDelta;
  440.23 -  int predictedValue = ((8 * LastChar + K1 * D1 + K2 * D2 + K3 * D3 + K4 * D4 + K5 * channelDelta) >> 3);
  440.24 -
  440.25 -  Byte realValue = (Byte)(predictedValue - deltaByte);
  440.26 -  int i = ((int)(signed char)deltaByte) << 3;
  440.27 -
  440.28 -  Dif[0] += abs(i);
  440.29 -  Dif[1] += abs(i - D1);
  440.30 -  Dif[2] += abs(i + D1);
  440.31 -  Dif[3] += abs(i - D2);
  440.32 -  Dif[4] += abs(i + D2);
  440.33 -  Dif[5] += abs(i - D3);
  440.34 -  Dif[6] += abs(i + D3);
  440.35 -  Dif[7] += abs(i - D4);
  440.36 -  Dif[8] += abs(i + D4);
  440.37 -  Dif[9] += abs(i - channelDelta);
  440.38 -  Dif[10] += abs(i + channelDelta);
  440.39 -
  440.40 -  channelDelta = LastDelta = (signed char)(realValue - LastChar);
  440.41 -  LastChar = realValue;
  440.42 -
  440.43 -  if (((++ByteCount) & 0x1F) == 0)
  440.44 -  {
  440.45 -    UInt32 minDif = Dif[0];
  440.46 -    UInt32 numMinDif = 0;
  440.47 -    Dif[0] = 0;
  440.48 -    for (i = 1; i < sizeof(Dif) / sizeof(Dif[0]); i++)
  440.49 -    {
  440.50 -      if (Dif[i] < minDif)
  440.51 -      {
  440.52 -        minDif = Dif[i];
  440.53 -        numMinDif = i;
  440.54 -      }
  440.55 -      Dif[i] = 0;
  440.56 -    }
  440.57 -    switch(numMinDif)
  440.58 -    {
  440.59 -      case 1: if (K1 >= -16) K1--; break;
  440.60 -      case 2: if (K1 <   16) K1++; break;
  440.61 -      case 3: if (K2 >= -16) K2--; break;
  440.62 -      case 4: if (K2 <   16) K2++; break;
  440.63 -      case 5: if (K3 >= -16) K3--; break;
  440.64 -      case 6: if (K3 <   16) K3++; break;
  440.65 -      case 7: if (K4 >= -16) K4--; break;
  440.66 -      case 8: if (K4 <   16) K4++; break;
  440.67 -      case 9: if (K5 >= -16) K5--; break;
  440.68 -      case 10:if (K5 <   16) K5++; break;
  440.69 -    }
  440.70 -  }
  440.71 -  return realValue;
  440.72 -}
  440.73 -}
  440.74 -
  440.75 -static const char *kNumberErrorMessage = "Number error";
  440.76 -
  440.77 -static const UInt32 kHistorySize = 1 << 20;
  440.78 -
  440.79 -static const int kNumStats = 11;
  440.80 -
  440.81 -static const UInt32 kWindowReservSize = (1 << 22) + 256;
  440.82 -
  440.83 -CDecoder::CDecoder():
  440.84 -  m_IsSolid(false)
  440.85 -{
  440.86 -}
  440.87 -
  440.88 -void CDecoder::InitStructures()
  440.89 -{
  440.90 -  m_MmFilter.Init();
  440.91 -  for(int i = 0; i < kNumRepDists; i++)
  440.92 -    m_RepDists[i] = 0;
  440.93 -  m_RepDistPtr = 0;
  440.94 -  m_LastLength = 0;
  440.95 -  memset(m_LastLevels, 0, kMaxTableSize);
  440.96 -}
  440.97 -
  440.98 -UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
  440.99 -
 440.100 -#define RIF(x) { if (!(x)) return false; }
 440.101 -
 440.102 -bool CDecoder::ReadTables(void)
 440.103 -{
 440.104 -  Byte levelLevels[kLevelTableSize];
 440.105 -  Byte newLevels[kMaxTableSize];
 440.106 -  m_AudioMode = (ReadBits(1) == 1);
 440.107 -
 440.108 -  if (ReadBits(1) == 0)
 440.109 -    memset(m_LastLevels, 0, kMaxTableSize);
 440.110 -  int numLevels;
 440.111 -  if (m_AudioMode)
 440.112 -  {
 440.113 -    m_NumChannels = ReadBits(2) + 1;
 440.114 -    if (m_MmFilter.CurrentChannel >= m_NumChannels)
 440.115 -      m_MmFilter.CurrentChannel = 0;
 440.116 -    numLevels = m_NumChannels * kMMTableSize;
 440.117 -  }
 440.118 -  else
 440.119 -    numLevels = kHeapTablesSizesSum;
 440.120 - 
 440.121 -  int i;
 440.122 -  for (i = 0; i < kLevelTableSize; i++)
 440.123 -    levelLevels[i] = (Byte)ReadBits(4);
 440.124 -  RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
 440.125 -  i = 0;
 440.126 -  while (i < numLevels)
 440.127 -  {
 440.128 -    UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
 440.129 -    if (number < kTableDirectLevels)
 440.130 -    {
 440.131 -      newLevels[i] = (Byte)((number + m_LastLevels[i]) & kLevelMask);
 440.132 -      i++;
 440.133 -    }
 440.134 -    else
 440.135 -    {
 440.136 -      if (number == kTableLevelRepNumber)
 440.137 -      {
 440.138 -        int t = ReadBits(2) + 3;
 440.139 -        for (int reps = t; reps > 0 && i < numLevels ; reps--, i++)
 440.140 -          newLevels[i] = newLevels[i - 1];
 440.141 -      }
 440.142 -      else
 440.143 -      {
 440.144 -        int num;
 440.145 -        if (number == kTableLevel0Number)
 440.146 -          num = ReadBits(3) + 3;
 440.147 -        else if (number == kTableLevel0Number2)
 440.148 -          num = ReadBits(7) + 11;
 440.149 -        else
 440.150 -          return false;
 440.151 -        for (;num > 0 && i < numLevels; num--)
 440.152 -          newLevels[i++] = 0;
 440.153 -      }
 440.154 -    }
 440.155 -  }
 440.156 -  if (m_AudioMode)
 440.157 -    for (i = 0; i < m_NumChannels; i++)
 440.158 -    {
 440.159 -      RIF(m_MMDecoders[i].SetCodeLengths(&newLevels[i * kMMTableSize]));
 440.160 -    }
 440.161 -  else
 440.162 -  {
 440.163 -    RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
 440.164 -    RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
 440.165 -    RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
 440.166 -  }
 440.167 -  memcpy(m_LastLevels, newLevels, kMaxTableSize);
 440.168 -  return true;
 440.169 -}
 440.170 -
 440.171 -bool CDecoder::ReadLastTables()
 440.172 -{
 440.173 -  // it differs a little from pure RAR sources;
 440.174 -  // UInt64 ttt = m_InBitStream.GetProcessedSize() + 2;
 440.175 -  // + 2 works for: return 0xFF; in CInBuffer::ReadByte.
 440.176 -  if (m_InBitStream.GetProcessedSize() + 7 <= m_PackSize) // test it: probably incorrect;
 440.177 -  // if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
 440.178 -    if (m_AudioMode)
 440.179 -    {
 440.180 -      UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
 440.181 -      if (symbol == 256)
 440.182 -        return ReadTables();
 440.183 -      if (symbol >= kMMTableSize)
 440.184 -        return false;
 440.185 -    }
 440.186 -    else
 440.187 -    {
 440.188 -      UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
 440.189 -      if (number == kReadTableNumber)
 440.190 -        return ReadTables();
 440.191 -      if (number >= kMainTableSize)
 440.192 -        return false;
 440.193 -    }
 440.194 -  return true;
 440.195 -}
 440.196 -
 440.197 -class CCoderReleaser
 440.198 -{
 440.199 -  CDecoder *m_Coder;
 440.200 -public:
 440.201 -  CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
 440.202 -  ~CCoderReleaser()
 440.203 -  {
 440.204 -    m_Coder->ReleaseStreams();
 440.205 -  }
 440.206 -};
 440.207 -
 440.208 -bool CDecoder::DecodeMm(UInt32 pos)
 440.209 -{
 440.210 -  while (pos-- > 0)
 440.211 -  {
 440.212 -    UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
 440.213 -    if (symbol == 256)
 440.214 -      return true;
 440.215 -    if (symbol >= kMMTableSize)
 440.216 -      return false;
 440.217 -    /*
 440.218 -    Byte byPredict = m_Predictor.Predict();
 440.219 -    Byte byReal = (Byte)(byPredict - (Byte)symbol);
 440.220 -    m_Predictor.Update(byReal, byPredict);
 440.221 -    */
 440.222 -    Byte byReal = m_MmFilter.Decode((Byte)symbol);
 440.223 -    m_OutWindowStream.PutByte(byReal);
 440.224 -    if (++m_MmFilter.CurrentChannel == m_NumChannels)
 440.225 -      m_MmFilter.CurrentChannel = 0;
 440.226 -  }
 440.227 -  return true;
 440.228 -}
 440.229 -
 440.230 -bool CDecoder::DecodeLz(Int32 pos)
 440.231 -{
 440.232 -  while (pos > 0)
 440.233 -  {
 440.234 -    UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
 440.235 -    UInt32 length, distance;
 440.236 -    if (number < 256)
 440.237 -    {
 440.238 -      m_OutWindowStream.PutByte(Byte(number));
 440.239 -      pos--;
 440.240 -      continue;
 440.241 -    }
 440.242 -    else if (number >= kMatchNumber)
 440.243 -    {
 440.244 -      number -= kMatchNumber;
 440.245 -      length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
 440.246 -        m_InBitStream.ReadBits(kLenDirectBits[number]);
 440.247 -      number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
 440.248 -      if (number >= kDistTableSize)
 440.249 -        return false;
 440.250 -      distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
 440.251 -      if (distance >= kDistLimit3)
 440.252 -      {
 440.253 -        length += 2 - ((distance - kDistLimit4) >> 31);
 440.254 -        // length++;
 440.255 -        // if (distance >= kDistLimit4)
 440.256 -        //  length++;
 440.257 -      }
 440.258 -    }
 440.259 -    else if (number == kRepBothNumber)
 440.260 -    {
 440.261 -      length = m_LastLength;
 440.262 -      distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
 440.263 -    }
 440.264 -    else if (number < kLen2Number)
 440.265 -    {
 440.266 -      distance = m_RepDists[(m_RepDistPtr - (number - kRepNumber + 1)) & 3];
 440.267 -      number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
 440.268 -      if (number >= kLenTableSize)
 440.269 -        return false;
 440.270 -      length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
 440.271 -      if (distance >= kDistLimit2)
 440.272 -      {
 440.273 -        length++;
 440.274 -        if (distance >= kDistLimit3)
 440.275 -        {
 440.276 -          length += 2 - ((distance - kDistLimit4) >> 31);
 440.277 -          // length++;
 440.278 -          // if (distance >= kDistLimit4)
 440.279 -          //   length++;
 440.280 -        }
 440.281 -      }
 440.282 -    }
 440.283 -    else if (number < kReadTableNumber)
 440.284 -    {
 440.285 -      number -= kLen2Number;
 440.286 -      distance = kLen2DistStarts[number] +
 440.287 -        m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
 440.288 -      length = 2;
 440.289 -    }
 440.290 -    else if (number == kReadTableNumber)
 440.291 -      return true;
 440.292 -    else
 440.293 -      return false;
 440.294 -    m_RepDists[m_RepDistPtr++ & 3] = distance;
 440.295 -    m_LastLength = length;
 440.296 -    if (!m_OutWindowStream.CopyBlock(distance, length))
 440.297 -      return false;
 440.298 -    pos -= length;
 440.299 -  }
 440.300 -  return true;
 440.301 -}
 440.302 -
 440.303 -HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 440.304 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 440.305 -{
 440.306 -  if (inSize == NULL || outSize == NULL)
 440.307 -    return E_INVALIDARG;
 440.308 -
 440.309 -  if (!m_OutWindowStream.Create(kHistorySize))
 440.310 -    return E_OUTOFMEMORY;
 440.311 -  if (!m_InBitStream.Create(1 << 20))
 440.312 -    return E_OUTOFMEMORY;
 440.313 -
 440.314 -  m_PackSize = *inSize;
 440.315 -
 440.316 -  UInt64 pos = 0, unPackSize = *outSize;
 440.317 -  
 440.318 -  m_OutWindowStream.SetStream(outStream);
 440.319 -  m_OutWindowStream.Init(m_IsSolid);
 440.320 -  m_InBitStream.SetStream(inStream);
 440.321 -  m_InBitStream.Init();
 440.322 -
 440.323 -  CCoderReleaser coderReleaser(this);
 440.324 -  if (!m_IsSolid)
 440.325 -  {
 440.326 -    InitStructures();
 440.327 -    if (unPackSize == 0)
 440.328 -    {
 440.329 -      if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
 440.330 -        if (!ReadTables())
 440.331 -          return S_FALSE;
 440.332 -      return S_OK;
 440.333 -    }
 440.334 -    if (!ReadTables())
 440.335 -      return S_FALSE;
 440.336 -  }
 440.337 -
 440.338 -  UInt64 startPos = m_OutWindowStream.GetProcessedSize();
 440.339 -  while(pos < unPackSize)
 440.340 -  {
 440.341 -    UInt32 blockSize = 1 << 20;
 440.342 -    if (blockSize > unPackSize - pos)
 440.343 -      blockSize = (UInt32)(unPackSize - pos);
 440.344 -    UInt64 blockStartPos = m_OutWindowStream.GetProcessedSize();
 440.345 -    if (m_AudioMode)
 440.346 -    {
 440.347 -      if (!DecodeMm(blockSize))
 440.348 -        return S_FALSE;
 440.349 -    }
 440.350 -    else
 440.351 -    {
 440.352 -      if (!DecodeLz((Int32)blockSize))
 440.353 -        return S_FALSE;
 440.354 -    }
 440.355 -    UInt64 globalPos = m_OutWindowStream.GetProcessedSize();
 440.356 -    pos = globalPos - blockStartPos;
 440.357 -    if (pos < blockSize)
 440.358 -      if (!ReadTables())
 440.359 -        return S_FALSE;
 440.360 -    pos = globalPos - startPos;
 440.361 -    if (progress != 0)
 440.362 -    {
 440.363 -      UInt64 packSize = m_InBitStream.GetProcessedSize();
 440.364 -      RINOK(progress->SetRatioInfo(&packSize, &pos));
 440.365 -    }
 440.366 -  }
 440.367 -  if (pos > unPackSize)
 440.368 -    return S_FALSE;
 440.369 -
 440.370 -  if (!ReadLastTables())
 440.371 -    return S_FALSE;
 440.372 -  return m_OutWindowStream.Flush();
 440.373 -}
 440.374 -
 440.375 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 440.376 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 440.377 -{
 440.378 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
 440.379 -  catch(const CInBufferException &e) { return e.ErrorCode; }
 440.380 -  catch(const CLzOutWindowException &e) { return e.ErrorCode; }
 440.381 -  catch(...) { return S_FALSE; }
 440.382 -}
 440.383 -
 440.384 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 440.385 -{
 440.386 -  if (size < 1)
 440.387 -    return E_INVALIDARG;
 440.388 -  m_IsSolid = (data[0] != 0);
 440.389 -  return S_OK;
 440.390 -}
 440.391 -
 440.392 -}}
   441.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar2Decoder.h	Sat Mar 03 10:54:39 2012 -0600
   441.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   441.3 @@ -1,174 +0,0 @@
   441.4 -// Rar2Decoder.h
   441.5 -// According to unRAR license, this code may not be used to develop
   441.6 -// a program that creates RAR archives
   441.7 -
   441.8 -#ifndef __COMPRESS_RAR2_DECODER_H
   441.9 -#define __COMPRESS_RAR2_DECODER_H
  441.10 -
  441.11 -#include "../../Common/MyCom.h"
  441.12 -
  441.13 -#include "../ICoder.h"
  441.14 -
  441.15 -#include "../Common/InBuffer.h"
  441.16 -
  441.17 -#include "BitmDecoder.h"
  441.18 -#include "HuffmanDecoder.h"
  441.19 -#include "LzOutWindow.h"
  441.20 -
  441.21 -namespace NCompress {
  441.22 -namespace NRar2 {
  441.23 -
  441.24 -const UInt32 kNumRepDists = 4;
  441.25 -const UInt32 kDistTableSize = 48;
  441.26 -
  441.27 -const int kMMTableSize = 256 + 1;
  441.28 -
  441.29 -const UInt32 kMainTableSize = 298;
  441.30 -const UInt32 kLenTableSize = 28;
  441.31 -
  441.32 -const UInt32 kDistTableStart = kMainTableSize;
  441.33 -const UInt32 kLenTableStart = kDistTableStart + kDistTableSize;
  441.34 -
  441.35 -const UInt32 kHeapTablesSizesSum = kMainTableSize + kDistTableSize + kLenTableSize;
  441.36 -
  441.37 -const UInt32 kLevelTableSize = 19;
  441.38 -
  441.39 -const UInt32 kMMTablesSizesSum = kMMTableSize * 4;
  441.40 -
  441.41 -const UInt32 kMaxTableSize = kMMTablesSizesSum;
  441.42 -
  441.43 -const UInt32 kTableDirectLevels = 16;
  441.44 -const UInt32 kTableLevelRepNumber = kTableDirectLevels;
  441.45 -const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
  441.46 -const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
  441.47 -
  441.48 -const UInt32 kLevelMask = 0xF;
  441.49 -
  441.50 -
  441.51 -const UInt32 kRepBothNumber = 256;
  441.52 -const UInt32 kRepNumber = kRepBothNumber + 1;
  441.53 -const UInt32 kLen2Number = kRepNumber + 4;
  441.54 -
  441.55 -const UInt32 kLen2NumNumbers = 8;
  441.56 -const UInt32 kReadTableNumber = kLen2Number + kLen2NumNumbers;
  441.57 -const UInt32 kMatchNumber = kReadTableNumber + 1;
  441.58 -
  441.59 -const Byte kLenStart[kLenTableSize]      = {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
  441.60 -const Byte kLenDirectBits[kLenTableSize] = {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5};
  441.61 -
  441.62 -const UInt32 kDistStart[kDistTableSize]     = {0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768U,49152U,65536,98304,131072,196608,262144,327680,393216,458752,524288,589824,655360,720896,786432,851968,917504,983040};
  441.63 -const Byte kDistDirectBits[kDistTableSize] = {0,0,0,0,1,1,2, 2, 3, 3, 4, 4, 5, 5,  6,  6,  7,  7,  8,  8,   9,   9,  10,  10,  11,  11,  12,   12,   13,   13,    14,    14,   15,   15,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16};
  441.64 -
  441.65 -const Byte kLevelDirectBits[kLevelTableSize] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
  441.66 -
  441.67 -const Byte kLen2DistStarts[kLen2NumNumbers]={0,4,8,16,32,64,128,192};
  441.68 -const Byte kLen2DistDirectBits[kLen2NumNumbers]={2,2,3, 4, 5, 6,  6,  6};
  441.69 -
  441.70 -const UInt32 kDistLimit2 = 0x101 - 1;
  441.71 -const UInt32 kDistLimit3 = 0x2000 - 1;
  441.72 -const UInt32 kDistLimit4 = 0x40000 - 1;
  441.73 -
  441.74 -const UInt32 kMatchMaxLen = 255 + 2;
  441.75 -const UInt32 kMatchMaxLenMax = 255 + 5;
  441.76 -const UInt32 kNormalMatchMinLen = 3;
  441.77 -
  441.78 -namespace NMultimedia {
  441.79 -
  441.80 -struct CFilter
  441.81 -{
  441.82 -  int K1,K2,K3,K4,K5;
  441.83 -  int D1,D2,D3,D4;
  441.84 -  int LastDelta;
  441.85 -  UInt32 Dif[11];
  441.86 -  UInt32 ByteCount;
  441.87 -  int LastChar;
  441.88 -
  441.89 -  Byte Decode(int &channelDelta, Byte delta);
  441.90 -
  441.91 -  void Init() { memset(this, 0, sizeof(*this)); }
  441.92 -
  441.93 -};
  441.94 -
  441.95 -const int kNumChanelsMax = 4;
  441.96 -
  441.97 -class CFilter2
  441.98 -{
  441.99 -public:
 441.100 -  CFilter  m_Filters[kNumChanelsMax];
 441.101 -  int m_ChannelDelta;
 441.102 -  int CurrentChannel;
 441.103 -
 441.104 -  void Init() { memset(this, 0, sizeof(*this)); }
 441.105 -  Byte Decode(Byte delta)
 441.106 -  {
 441.107 -    return m_Filters[CurrentChannel].Decode(m_ChannelDelta, delta);
 441.108 -  }
 441.109 -
 441.110 -};
 441.111 -
 441.112 -}
 441.113 -
 441.114 -typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
 441.115 -
 441.116 -const int kNumHuffmanBits = 15;
 441.117 -
 441.118 -class CDecoder :
 441.119 -  public ICompressCoder,
 441.120 -  public ICompressSetDecoderProperties2,
 441.121 -  public CMyUnknownImp
 441.122 -{
 441.123 -  CLzOutWindow m_OutWindowStream;
 441.124 -  CBitDecoder m_InBitStream;
 441.125 -  NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
 441.126 -  NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
 441.127 -  NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
 441.128 -  NHuffman::CDecoder<kNumHuffmanBits, kMMTableSize> m_MMDecoders[NMultimedia::kNumChanelsMax];
 441.129 -  NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
 441.130 -
 441.131 -  bool m_AudioMode;
 441.132 -
 441.133 -  NMultimedia::CFilter2 m_MmFilter;
 441.134 -  int m_NumChannels;
 441.135 -
 441.136 -  UInt32 m_RepDists[kNumRepDists];
 441.137 -  UInt32 m_RepDistPtr;
 441.138 -
 441.139 -  UInt32 m_LastLength;
 441.140 -  
 441.141 -  Byte m_LastLevels[kMaxTableSize];
 441.142 -
 441.143 -  UInt64 m_PackSize;
 441.144 -  bool m_IsSolid;
 441.145 -
 441.146 -  void InitStructures();
 441.147 -  UInt32 ReadBits(int numBits);
 441.148 -  bool ReadTables();
 441.149 -  bool ReadLastTables();
 441.150 -
 441.151 -  bool DecodeMm(UInt32 pos);
 441.152 -  bool DecodeLz(Int32 pos);
 441.153 -
 441.154 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 441.155 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 441.156 -
 441.157 -public:
 441.158 -  CDecoder();
 441.159 -
 441.160 -  MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
 441.161 -
 441.162 -  void ReleaseStreams()
 441.163 -  {
 441.164 -    m_OutWindowStream.ReleaseStream();
 441.165 -    m_InBitStream.ReleaseStream();
 441.166 -  }
 441.167 -
 441.168 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 441.169 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 441.170 -
 441.171 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
 441.172 -
 441.173 -};
 441.174 -
 441.175 -}}
 441.176 -
 441.177 -#endif
   442.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar3Decoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   442.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   442.3 @@ -1,834 +0,0 @@
   442.4 -// Rar3Decoder.cpp
   442.5 -// According to unRAR license, this code may not be used to develop
   442.6 -// a program that creates RAR archives
   442.7 - 
   442.8 -#include "StdAfx.h"
   442.9 -
  442.10 -#include "../Common/StreamUtils.h"
  442.11 -
  442.12 -#include "Rar3Decoder.h"
  442.13 -
  442.14 -namespace NCompress {
  442.15 -namespace NRar3 {
  442.16 -
  442.17 -static const UInt32 kNumAlignReps = 15;
  442.18 -
  442.19 -static const UInt32 kSymbolReadTable = 256;
  442.20 -static const UInt32 kSymbolRep = 259;
  442.21 -static const UInt32 kSymbolLen2 = kSymbolRep + kNumReps;
  442.22 -
  442.23 -static const Byte kLenStart[kLenTableSize]      = {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
  442.24 -static const Byte kLenDirectBits[kLenTableSize] = {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5};
  442.25 -
  442.26 -static const Byte kDistDirectBits[kDistTableSize] =
  442.27 -  {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,
  442.28 -  16,16,16,16,16,16,16,16,16,16,16,16,16,16,
  442.29 -  18,18,18,18,18,18,18,18,18,18,18,18};
  442.30 -
  442.31 -static const Byte kLevelDirectBits[kLevelTableSize] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
  442.32 -
  442.33 -static const Byte kLen2DistStarts[kNumLen2Symbols]={0,4,8,16,32,64,128,192};
  442.34 -static const Byte kLen2DistDirectBits[kNumLen2Symbols]={2,2,3, 4, 5, 6,  6,  6};
  442.35 -
  442.36 -static const UInt32 kDistLimit3 = 0x2000 - 2;
  442.37 -static const UInt32 kDistLimit4 = 0x40000 - 2;
  442.38 -
  442.39 -static const UInt32 kNormalMatchMinLen = 3;
  442.40 -
  442.41 -static const UInt32 kVmDataSizeMax = 1 << 16;
  442.42 -static const UInt32 kVmCodeSizeMax = 1 << 16;
  442.43 -
  442.44 -CDecoder::CDecoder():
  442.45 -  _window(0),
  442.46 -  _winPos(0),
  442.47 -  _wrPtr(0),
  442.48 -  _lzSize(0),
  442.49 -  _writtenFileSize(0),
  442.50 -  _vmData(0),
  442.51 -  _vmCode(0),
  442.52 -  m_IsSolid(false)
  442.53 -{
  442.54 -}
  442.55 -
  442.56 -CDecoder::~CDecoder()
  442.57 -{
  442.58 -  InitFilters();
  442.59 -  ::MidFree(_vmData);
  442.60 -  ::MidFree(_window);
  442.61 -}
  442.62 -
  442.63 -HRESULT CDecoder::WriteDataToStream(const Byte *data, UInt32 size)
  442.64 -{
  442.65 -  return WriteStream(_outStream, data, size);
  442.66 -}
  442.67 -
  442.68 -HRESULT CDecoder::WriteData(const Byte *data, UInt32 size)
  442.69 -{
  442.70 -  HRESULT res = S_OK;
  442.71 -  if (_writtenFileSize < _unpackSize)
  442.72 -  {
  442.73 -    UInt32 curSize = size;
  442.74 -    UInt64 remain = _unpackSize - _writtenFileSize;
  442.75 -    if (remain < curSize)
  442.76 -      curSize = (UInt32)remain;
  442.77 -    res = WriteDataToStream(data, curSize);
  442.78 -  }
  442.79 -  _writtenFileSize += size;
  442.80 -  return res;
  442.81 -}
  442.82 -
  442.83 -HRESULT CDecoder::WriteArea(UInt32 startPtr, UInt32 endPtr)
  442.84 -{
  442.85 -  if (startPtr <= endPtr)
  442.86 -    return WriteData(_window + startPtr, endPtr - startPtr);
  442.87 -  RINOK(WriteData(_window + startPtr, kWindowSize - startPtr));
  442.88 -  return WriteData(_window, endPtr);
  442.89 -}
  442.90 -
  442.91 -void CDecoder::ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef)
  442.92 -{
  442.93 -  CTempFilter *tempFilter = _tempFilters[tempFilterIndex];
  442.94 -  tempFilter->InitR[6] = (UInt32)_writtenFileSize;
  442.95 -  NVm::SetValue32(&tempFilter->GlobalData[0x24], (UInt32)_writtenFileSize);
  442.96 -  NVm::SetValue32(&tempFilter->GlobalData[0x28], (UInt32)(_writtenFileSize >> 32));
  442.97 -  CFilter *filter = _filters[tempFilter->FilterIndex];
  442.98 -  _vm.Execute(filter, tempFilter, outBlockRef, filter->GlobalData);
  442.99 -  delete tempFilter;
 442.100 -  _tempFilters[tempFilterIndex] = 0;
 442.101 -}
 442.102 -
 442.103 -HRESULT CDecoder::WriteBuf()
 442.104 -{
 442.105 -  UInt32 writtenBorder = _wrPtr;
 442.106 -  UInt32 writeSize = (_winPos - writtenBorder) & kWindowMask;
 442.107 -  for (int i = 0; i < _tempFilters.Size(); i++)
 442.108 -  {
 442.109 -    CTempFilter *filter = _tempFilters[i];
 442.110 -    if (filter == NULL)
 442.111 -      continue;
 442.112 -    if (filter->NextWindow)
 442.113 -    {
 442.114 -      filter->NextWindow = false;
 442.115 -      continue;
 442.116 -    }
 442.117 -    UInt32 blockStart = filter->BlockStart;
 442.118 -    UInt32 blockSize = filter->BlockSize;
 442.119 -    if (((blockStart - writtenBorder) & kWindowMask) < writeSize)
 442.120 -    {
 442.121 -      if (writtenBorder != blockStart)
 442.122 -      {
 442.123 -        RINOK(WriteArea(writtenBorder, blockStart));
 442.124 -        writtenBorder = blockStart;
 442.125 -        writeSize = (_winPos - writtenBorder) & kWindowMask;
 442.126 -      }
 442.127 -      if (blockSize <= writeSize)
 442.128 -      {
 442.129 -        UInt32 blockEnd = (blockStart + blockSize) & kWindowMask;
 442.130 -        if (blockStart < blockEnd || blockEnd == 0)
 442.131 -          _vm.SetMemory(0, _window + blockStart, blockSize);
 442.132 -        else
 442.133 -        {
 442.134 -          UInt32 tailSize = kWindowSize - blockStart;
 442.135 -          _vm.SetMemory(0, _window + blockStart, tailSize);
 442.136 -          _vm.SetMemory(tailSize, _window, blockEnd);
 442.137 -        }
 442.138 -        NVm::CBlockRef outBlockRef;
 442.139 -        ExecuteFilter(i, outBlockRef);
 442.140 -        while (i + 1 < _tempFilters.Size())
 442.141 -        {
 442.142 -          CTempFilter *nextFilter = _tempFilters[i + 1];
 442.143 -          if (nextFilter == NULL || nextFilter->BlockStart != blockStart ||
 442.144 -              nextFilter->BlockSize != outBlockRef.Size || nextFilter->NextWindow)
 442.145 -            break;
 442.146 -          _vm.SetMemory(0, _vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
 442.147 -          ExecuteFilter(++i, outBlockRef);
 442.148 -        }
 442.149 -        WriteDataToStream(_vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
 442.150 -        _writtenFileSize += outBlockRef.Size;
 442.151 -        writtenBorder = blockEnd;
 442.152 -        writeSize = (_winPos - writtenBorder) & kWindowMask;
 442.153 -      }
 442.154 -      else
 442.155 -      {
 442.156 -        for (int j = i; j < _tempFilters.Size(); j++)
 442.157 -        {
 442.158 -          CTempFilter *filter = _tempFilters[j];
 442.159 -          if (filter != NULL && filter->NextWindow)
 442.160 -            filter->NextWindow = false;
 442.161 -        }
 442.162 -        _wrPtr = writtenBorder;
 442.163 -        return S_OK; // check it
 442.164 -      }
 442.165 -    }
 442.166 -  }
 442.167 -      
 442.168 -  _wrPtr = _winPos;
 442.169 -  return WriteArea(writtenBorder, _winPos);
 442.170 -}
 442.171 -
 442.172 -void CDecoder::InitFilters()
 442.173 -{
 442.174 -  _lastFilter = 0;
 442.175 -  int i;
 442.176 -  for (i = 0; i < _tempFilters.Size(); i++)
 442.177 -    delete _tempFilters[i];
 442.178 -  _tempFilters.Clear();
 442.179 -  for (i = 0; i < _filters.Size(); i++)
 442.180 -    delete _filters[i];
 442.181 -  _filters.Clear();
 442.182 -}
 442.183 -
 442.184 -bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
 442.185 -{
 442.186 -  CMemBitDecoder inp;
 442.187 -  inp.Init(_vmData, codeSize);
 442.188 -
 442.189 -  UInt32 filterIndex;
 442.190 -  if (firstByte & 0x80)
 442.191 -  {
 442.192 -    filterIndex = NVm::ReadEncodedUInt32(inp);
 442.193 -    if (filterIndex == 0)
 442.194 -      InitFilters();
 442.195 -    else
 442.196 -      filterIndex--;
 442.197 -  }
 442.198 -  else
 442.199 -    filterIndex = _lastFilter;
 442.200 -  if (filterIndex > (UInt32)_filters.Size())
 442.201 -    return false;
 442.202 -  _lastFilter = filterIndex;
 442.203 -  bool newFilter = (filterIndex == (UInt32)_filters.Size());
 442.204 -
 442.205 -  CFilter *filter;
 442.206 -  if (newFilter)
 442.207 -  {
 442.208 -    // check if too many filters
 442.209 -    if (filterIndex > 1024)
 442.210 -      return false;
 442.211 -    filter = new CFilter;
 442.212 -    _filters.Add(filter);
 442.213 -  }
 442.214 -  else
 442.215 -  {
 442.216 -    filter = _filters[filterIndex];
 442.217 -    filter->ExecCount++;
 442.218 -  }
 442.219 -
 442.220 -  int numEmptyItems = 0;
 442.221 -  int i;
 442.222 -  for (i = 0; i < _tempFilters.Size(); i++)
 442.223 -  {
 442.224 -    _tempFilters[i - numEmptyItems] = _tempFilters[i];
 442.225 -    if (_tempFilters[i] == NULL)
 442.226 -      numEmptyItems++;
 442.227 -    if (numEmptyItems > 0)
 442.228 -      _tempFilters[i] = NULL;
 442.229 -  }
 442.230 -  if (numEmptyItems == 0)
 442.231 -  {
 442.232 -    _tempFilters.Add(NULL);
 442.233 -    numEmptyItems = 1;
 442.234 -  }
 442.235 -  CTempFilter *tempFilter = new CTempFilter;
 442.236 -  _tempFilters[_tempFilters.Size() - numEmptyItems] = tempFilter;
 442.237 -  tempFilter->FilterIndex = filterIndex;
 442.238 -  tempFilter->ExecCount = filter->ExecCount;
 442.239 - 
 442.240 -  UInt32 blockStart = NVm::ReadEncodedUInt32(inp);
 442.241 -  if (firstByte & 0x40)
 442.242 -    blockStart += 258;
 442.243 -  tempFilter->BlockStart = (blockStart + _winPos) & kWindowMask;
 442.244 -  if (firstByte & 0x20)
 442.245 -    filter->BlockSize = NVm::ReadEncodedUInt32(inp);
 442.246 -  tempFilter->BlockSize = filter->BlockSize;
 442.247 -  tempFilter->NextWindow = _wrPtr != _winPos && ((_wrPtr - _winPos) & kWindowMask) <= blockStart;
 442.248 -
 442.249 -  memset(tempFilter->InitR, 0, sizeof(tempFilter->InitR));
 442.250 -  tempFilter->InitR[3] = NVm::kGlobalOffset;
 442.251 -  tempFilter->InitR[4] = tempFilter->BlockSize;
 442.252 -  tempFilter->InitR[5] = tempFilter->ExecCount;
 442.253 -  if (firstByte & 0x10)
 442.254 -  {
 442.255 -    UInt32 initMask = inp.ReadBits(NVm::kNumGpRegs);
 442.256 -    for (int i = 0; i < NVm::kNumGpRegs; i++)
 442.257 -      if (initMask & (1 << i))
 442.258 -        tempFilter->InitR[i] = NVm::ReadEncodedUInt32(inp);
 442.259 -  }
 442.260 -  if (newFilter)
 442.261 -  {
 442.262 -    UInt32 vmCodeSize = NVm::ReadEncodedUInt32(inp);
 442.263 -    if (vmCodeSize >= kVmCodeSizeMax || vmCodeSize == 0)
 442.264 -      return false;
 442.265 -    for (UInt32 i = 0; i < vmCodeSize; i++)
 442.266 -      _vmCode[i] = (Byte)inp.ReadBits(8);
 442.267 -    _vm.PrepareProgram(_vmCode, vmCodeSize, filter);
 442.268 -  }
 442.269 -
 442.270 -  tempFilter->AllocateEmptyFixedGlobal();
 442.271 -
 442.272 -  Byte *globalData = &tempFilter->GlobalData[0];
 442.273 -  for (i = 0; i < NVm::kNumGpRegs; i++)
 442.274 -    NVm::SetValue32(&globalData[i * 4], tempFilter->InitR[i]);
 442.275 -  NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockSize], tempFilter->BlockSize);
 442.276 -  NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockPos], 0); // It was commented. why?
 442.277 -  NVm::SetValue32(&globalData[NVm::NGlobalOffset::kExecCount], tempFilter->ExecCount);
 442.278 -
 442.279 -  if (firstByte & 8)
 442.280 -  {
 442.281 -    UInt32 dataSize = NVm::ReadEncodedUInt32(inp);
 442.282 -    if (dataSize > NVm::kGlobalSize - NVm::kFixedGlobalSize)
 442.283 -      return false;
 442.284 -    CRecordVector<Byte> &globalData = tempFilter->GlobalData;
 442.285 -    int requredSize = (int)(dataSize + NVm::kFixedGlobalSize);
 442.286 -    if (globalData.Size() < requredSize)
 442.287 -    {
 442.288 -      globalData.Reserve(requredSize);
 442.289 -      for (; globalData.Size() < requredSize; i++)
 442.290 -        globalData.Add(0);
 442.291 -    }
 442.292 -    for (UInt32 i = 0; i < dataSize; i++)
 442.293 -      globalData[NVm::kFixedGlobalSize + i] = (Byte)inp.ReadBits(8);
 442.294 -  }
 442.295 -  return true;
 442.296 -}
 442.297 -
 442.298 -bool CDecoder::ReadVmCodeLZ()
 442.299 -{
 442.300 -  UInt32 firstByte = m_InBitStream.ReadBits(8);
 442.301 -  UInt32 length = (firstByte & 7) + 1;
 442.302 -  if (length == 7)
 442.303 -    length = m_InBitStream.ReadBits(8) + 7;
 442.304 -  else if (length == 8)
 442.305 -    length = m_InBitStream.ReadBits(16);
 442.306 -  if (length > kVmDataSizeMax)
 442.307 -    return false;
 442.308 -  for (UInt32 i = 0; i < length; i++)
 442.309 -    _vmData[i] = (Byte)m_InBitStream.ReadBits(8);
 442.310 -  return AddVmCode(firstByte, length);
 442.311 -}
 442.312 -
 442.313 -bool CDecoder::ReadVmCodePPM()
 442.314 -{
 442.315 -  int firstByte = DecodePpmSymbol();
 442.316 -  if (firstByte == -1)
 442.317 -    return false;
 442.318 -  UInt32 length = (firstByte & 7) + 1;
 442.319 -  if (length == 7)
 442.320 -  {
 442.321 -    int b1 = DecodePpmSymbol();
 442.322 -    if (b1 == -1)
 442.323 -      return false;
 442.324 -    length = b1 + 7;
 442.325 -  }
 442.326 -  else if (length == 8)
 442.327 -  {
 442.328 -    int b1 = DecodePpmSymbol();
 442.329 -    if (b1 == -1)
 442.330 -      return false;
 442.331 -    int b2 = DecodePpmSymbol();
 442.332 -    if (b2 == -1)
 442.333 -      return false;
 442.334 -    length = b1 * 256 + b2;
 442.335 -  }
 442.336 -  if (length > kVmDataSizeMax)
 442.337 -    return false;
 442.338 -  for (UInt32 i = 0; i < length; i++)
 442.339 -  {
 442.340 -    int b = DecodePpmSymbol();
 442.341 -    if (b == -1)
 442.342 -      return false;
 442.343 -    _vmData[i] = (Byte)b;
 442.344 -  }
 442.345 -  return AddVmCode(firstByte, length);
 442.346 -}
 442.347 -
 442.348 -#define RIF(x) { if (!(x)) return S_FALSE; }
 442.349 -
 442.350 -UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
 442.351 -
 442.352 -/////////////////////////////////////////////////
 442.353 -// PPM
 442.354 -
 442.355 -HRESULT CDecoder::InitPPM()
 442.356 -{
 442.357 -  Byte maxOrder = (Byte)ReadBits(7);
 442.358 -
 442.359 -  bool reset = ((maxOrder & 0x20) != 0);
 442.360 -  int maxMB = 0;
 442.361 -  if (reset)
 442.362 -    maxMB = (Byte)ReadBits(8);
 442.363 -  else
 442.364 -  {
 442.365 -    if (_ppm.SubAllocator.GetSubAllocatorSize()== 0)
 442.366 -      return S_FALSE;
 442.367 -  }
 442.368 -  if (maxOrder & 0x40)
 442.369 -    PpmEscChar = (Byte)ReadBits(8);
 442.370 -  m_InBitStream.InitRangeCoder();
 442.371 -  /*
 442.372 -  if (m_InBitStream.m_BitPos != 0)
 442.373 -    return S_FALSE;
 442.374 -  */
 442.375 -  if (reset)
 442.376 -  {
 442.377 -    maxOrder = (maxOrder & 0x1F) + 1;
 442.378 -    if (maxOrder > 16)
 442.379 -      maxOrder = 16 + (maxOrder - 16) * 3;
 442.380 -    if (maxOrder == 1)
 442.381 -    {
 442.382 -      // SubAlloc.StopSubAllocator();
 442.383 -      _ppm.SubAllocator.StopSubAllocator();
 442.384 -      return S_FALSE;
 442.385 -    }
 442.386 -    // SubAlloc.StartSubAllocator(MaxMB+1);
 442.387 -    // StartModelRare(maxOrder);
 442.388 -
 442.389 -    if (!_ppm.SubAllocator.StartSubAllocator((maxMB + 1) << 20))
 442.390 -      return E_OUTOFMEMORY;
 442.391 -    _ppm.MaxOrder = 0;
 442.392 -    _ppm.StartModelRare(maxOrder);
 442.393 -
 442.394 -  }
 442.395 -  // return (minContext != NULL);
 442.396 -
 442.397 -  return S_OK;
 442.398 -}
 442.399 -
 442.400 -int CDecoder::DecodePpmSymbol() { return _ppm.DecodeSymbol(&m_InBitStream); }
 442.401 -
 442.402 -HRESULT CDecoder::DecodePPM(Int32 num, bool &keepDecompressing)
 442.403 -{
 442.404 -  keepDecompressing = false;
 442.405 -  do
 442.406 -  {
 442.407 -    if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
 442.408 -    {
 442.409 -      RINOK(WriteBuf());
 442.410 -      if (_writtenFileSize > _unpackSize)
 442.411 -      {
 442.412 -        keepDecompressing = false;
 442.413 -        return S_OK;
 442.414 -      }
 442.415 -    }
 442.416 -    int c = DecodePpmSymbol();
 442.417 -    if (c == -1)
 442.418 -    {
 442.419 -      // Original code sets PPMError=true here and then it returns S_OK. Why ???
 442.420 -      // return S_OK;
 442.421 -      return S_FALSE;
 442.422 -    }
 442.423 -    if (c == PpmEscChar)
 442.424 -    {
 442.425 -      int nextCh = DecodePpmSymbol();
 442.426 -      if (nextCh == 0)
 442.427 -        return ReadTables(keepDecompressing);
 442.428 -      if (nextCh == 2 || nextCh == -1)
 442.429 -        return S_OK;
 442.430 -      if (nextCh == 3)
 442.431 -      {
 442.432 -        if (!ReadVmCodePPM())
 442.433 -          return S_FALSE;
 442.434 -        continue;
 442.435 -      }
 442.436 -      if (nextCh == 4 || nextCh == 5)
 442.437 -      {
 442.438 -        UInt32 distance = 0;
 442.439 -        UInt32 length = 4;
 442.440 -        if (nextCh == 4)
 442.441 -        {
 442.442 -          for (int i = 0; i < 3; i++)
 442.443 -          {
 442.444 -            int c = DecodePpmSymbol();
 442.445 -            if (c == -1)
 442.446 -              return S_OK;
 442.447 -            distance = (distance << 8) + (Byte)c;
 442.448 -          }
 442.449 -          distance++;
 442.450 -          length += 28;
 442.451 -        }
 442.452 -        int c = DecodePpmSymbol();
 442.453 -        if (c == -1)
 442.454 -          return S_OK;
 442.455 -        length += c;
 442.456 -        if (distance >= _lzSize)
 442.457 -          return S_FALSE;
 442.458 -        CopyBlock(distance, length);
 442.459 -        num -= (Int32)length;
 442.460 -        continue;
 442.461 -      }
 442.462 -    }
 442.463 -    PutByte((Byte)c);
 442.464 -    num--;
 442.465 -  }
 442.466 -  while (num >= 0);
 442.467 -  keepDecompressing = true;
 442.468 -  return S_OK;
 442.469 -}
 442.470 -
 442.471 -/////////////////////////////////////////////////
 442.472 -// LZ
 442.473 -
 442.474 -HRESULT CDecoder::ReadTables(bool &keepDecompressing)
 442.475 -{
 442.476 -  keepDecompressing = true;
 442.477 -  ReadBits((8 - m_InBitStream.GetBitPosition()) & 7);
 442.478 -  if (ReadBits(1) != 0)
 442.479 -  {
 442.480 -    _lzMode = false;
 442.481 -    return InitPPM();
 442.482 -  }
 442.483 -
 442.484 -  _lzMode = true;
 442.485 -  PrevAlignBits = 0;
 442.486 -  PrevAlignCount = 0;
 442.487 -
 442.488 -  Byte levelLevels[kLevelTableSize];
 442.489 -  Byte newLevels[kTablesSizesSum];
 442.490 -
 442.491 -  if (ReadBits(1) == 0)
 442.492 -    memset(m_LastLevels, 0, kTablesSizesSum);
 442.493 -
 442.494 -  int i;
 442.495 -  for (i = 0; i < kLevelTableSize; i++)
 442.496 -  {
 442.497 -    UInt32 length = ReadBits(4);
 442.498 -    if (length == 15)
 442.499 -    {
 442.500 -      UInt32 zeroCount = ReadBits(4);
 442.501 -      if (zeroCount != 0)
 442.502 -      {
 442.503 -        zeroCount += 2;
 442.504 -        while (zeroCount-- > 0 && i < kLevelTableSize)
 442.505 -          levelLevels[i++]=0;
 442.506 -        i--;
 442.507 -        continue;
 442.508 -      }
 442.509 -    }
 442.510 -    levelLevels[i] = (Byte)length;
 442.511 -  }
 442.512 -  RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
 442.513 -  i = 0;
 442.514 -  while (i < kTablesSizesSum)
 442.515 -  {
 442.516 -    UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
 442.517 -    if (number < 16)
 442.518 -    {
 442.519 -      newLevels[i] = Byte((number + m_LastLevels[i]) & 15);
 442.520 -      i++;
 442.521 -    }
 442.522 -    else if (number > kLevelTableSize)
 442.523 -      return S_FALSE;
 442.524 -    else
 442.525 -    {
 442.526 -      int num;
 442.527 -      if (((number - 16) & 1) == 0)
 442.528 -        num = ReadBits(3) + 3;
 442.529 -      else
 442.530 -        num = ReadBits(7) + 11;
 442.531 -      if (number < 18)
 442.532 -      {
 442.533 -        if (i == 0)
 442.534 -          return S_FALSE;
 442.535 -        for (; num > 0 && i < kTablesSizesSum; num--, i++)
 442.536 -          newLevels[i] = newLevels[i - 1];
 442.537 -      }
 442.538 -      else
 442.539 -      {
 442.540 -        for (; num > 0 && i < kTablesSizesSum; num--)
 442.541 -          newLevels[i++] = 0;
 442.542 -      }
 442.543 -    }
 442.544 -  }
 442.545 -  TablesRead = true;
 442.546 -
 442.547 -  // original code has check here:
 442.548 -  /*
 442.549 -  if (InAddr > ReadTop)
 442.550 -  {
 442.551 -    keepDecompressing = false;
 442.552 -    return true;
 442.553 -  }
 442.554 -  */
 442.555 -
 442.556 -  RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
 442.557 -  RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
 442.558 -  RIF(m_AlignDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
 442.559 -  RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize + kAlignTableSize]));
 442.560 -
 442.561 -  memcpy(m_LastLevels, newLevels, kTablesSizesSum);
 442.562 -  return S_OK;
 442.563 -}
 442.564 -
 442.565 -class CCoderReleaser
 442.566 -{
 442.567 -  CDecoder *m_Coder;
 442.568 -public:
 442.569 -  CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
 442.570 -  ~CCoderReleaser()
 442.571 -  {
 442.572 -    // m_Coder->m_OutWindowStream.Flush();
 442.573 -    m_Coder->ReleaseStreams();
 442.574 -  }
 442.575 -};
 442.576 -
 442.577 -HRESULT CDecoder::ReadEndOfBlock(bool &keepDecompressing)
 442.578 -{
 442.579 -  if (ReadBits(1) != 0)
 442.580 -  {
 442.581 -    // old file
 442.582 -    TablesRead = false;
 442.583 -    return ReadTables(keepDecompressing);
 442.584 -  }
 442.585 -  // new file
 442.586 -  keepDecompressing = false;
 442.587 -  TablesRead = (ReadBits(1) == 0);
 442.588 -  return S_OK;
 442.589 -}
 442.590 -
 442.591 -UInt32 kDistStart[kDistTableSize];
 442.592 -
 442.593 -class CDistInit
 442.594 -{
 442.595 -public:
 442.596 -  CDistInit() { Init(); }
 442.597 -  void Init()
 442.598 -  {
 442.599 -    UInt32 start = 0;
 442.600 -    for (UInt32 i = 0; i < kDistTableSize; i++)
 442.601 -    {
 442.602 -      kDistStart[i] = start;
 442.603 -      start += (1 << kDistDirectBits[i]);
 442.604 -    }
 442.605 -  }
 442.606 -} g_DistInit;
 442.607 -
 442.608 -HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
 442.609 -{
 442.610 -  UInt32 rep0 = _reps[0];
 442.611 -  UInt32 rep1 = _reps[1];
 442.612 -  UInt32 rep2 = _reps[2];
 442.613 -  UInt32 rep3 = _reps[3];
 442.614 -  UInt32 length = _lastLength;
 442.615 -  for (;;)
 442.616 -  {
 442.617 -    if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
 442.618 -    {
 442.619 -      RINOK(WriteBuf());
 442.620 -      if (_writtenFileSize > _unpackSize)
 442.621 -      {
 442.622 -        keepDecompressing = false;
 442.623 -        return S_OK;
 442.624 -      }
 442.625 -    }
 442.626 -    UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
 442.627 -    if (number < 256)
 442.628 -    {
 442.629 -      PutByte(Byte(number));
 442.630 -
 442.631 -      continue;
 442.632 -    }
 442.633 -    else if (number == kSymbolReadTable)
 442.634 -    {
 442.635 -      RINOK(ReadEndOfBlock(keepDecompressing));
 442.636 -      break;
 442.637 -    }
 442.638 -    else if (number == 257)
 442.639 -    {
 442.640 -      if (!ReadVmCodeLZ())
 442.641 -        return S_FALSE;
 442.642 -      continue;
 442.643 -    }
 442.644 -    else if (number == 258)
 442.645 -    {
 442.646 -    }
 442.647 -    else if (number < kSymbolRep + 4)
 442.648 -    {
 442.649 -      if (number != kSymbolRep)
 442.650 -      {
 442.651 -        UInt32 distance;
 442.652 -        if (number == kSymbolRep + 1)
 442.653 -          distance = rep1;
 442.654 -        else
 442.655 -        {
 442.656 -          if (number == kSymbolRep + 2)
 442.657 -            distance = rep2;
 442.658 -          else
 442.659 -          {
 442.660 -            distance = rep3;
 442.661 -            rep3 = rep2;
 442.662 -          }
 442.663 -          rep2 = rep1;
 442.664 -        }
 442.665 -        rep1 = rep0;
 442.666 -        rep0 = distance;
 442.667 -      }
 442.668 -
 442.669 -      UInt32 number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
 442.670 -      if (number >= kLenTableSize)
 442.671 -        return S_FALSE;
 442.672 -      length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
 442.673 -    }
 442.674 -    else
 442.675 -    {
 442.676 -      rep3 = rep2;
 442.677 -      rep2 = rep1;
 442.678 -      rep1 = rep0;
 442.679 -      if (number < 271)
 442.680 -      {
 442.681 -        number -= 263;
 442.682 -        rep0 = kLen2DistStarts[number] + m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
 442.683 -        length = 2;
 442.684 -      }
 442.685 -      else if (number < 299)
 442.686 -      {
 442.687 -        number -= 271;
 442.688 -        length = kNormalMatchMinLen + (UInt32)kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
 442.689 -        UInt32 number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
 442.690 -        if (number >= kDistTableSize)
 442.691 -          return S_FALSE;
 442.692 -        rep0 = kDistStart[number];
 442.693 -        int numBits = kDistDirectBits[number];
 442.694 -        if (number >= (kNumAlignBits * 2) + 2)
 442.695 -        {
 442.696 -          if (numBits > kNumAlignBits)
 442.697 -            rep0 += (m_InBitStream.ReadBits(numBits - kNumAlignBits) << kNumAlignBits);
 442.698 -          if (PrevAlignCount > 0)
 442.699 -          {
 442.700 -            PrevAlignCount--;
 442.701 -            rep0 += PrevAlignBits;
 442.702 -          }
 442.703 -          else
 442.704 -          {
 442.705 -            UInt32 number = m_AlignDecoder.DecodeSymbol(&m_InBitStream);
 442.706 -            if (number < (1 << kNumAlignBits))
 442.707 -            {
 442.708 -              rep0 += number;
 442.709 -              PrevAlignBits = number;
 442.710 -            }
 442.711 -            else if (number  == (1 << kNumAlignBits))
 442.712 -            {
 442.713 -              PrevAlignCount = kNumAlignReps;
 442.714 -              rep0 += PrevAlignBits;
 442.715 -            }
 442.716 -            else
 442.717 -              return S_FALSE;
 442.718 -          }
 442.719 -        }
 442.720 -        else
 442.721 -          rep0 += m_InBitStream.ReadBits(numBits);
 442.722 -        length += ((kDistLimit4 - rep0) >> 31) + ((kDistLimit3 - rep0) >> 31);
 442.723 -      }
 442.724 -      else
 442.725 -        return S_FALSE;
 442.726 -    }
 442.727 -    if (rep0 >= _lzSize)
 442.728 -      return S_FALSE;
 442.729 -    CopyBlock(rep0, length);
 442.730 -  }
 442.731 -  _reps[0] = rep0;
 442.732 -  _reps[1] = rep1;
 442.733 -  _reps[2] = rep2;
 442.734 -  _reps[3] = rep3;
 442.735 -  _lastLength = length;
 442.736 -
 442.737 -  return S_OK;
 442.738 -}
 442.739 -
 442.740 -HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
 442.741 -{
 442.742 -  _writtenFileSize = 0;
 442.743 -  if (!m_IsSolid)
 442.744 -  {
 442.745 -    _lzSize = 0;
 442.746 -    _winPos = 0;
 442.747 -    _wrPtr = 0;
 442.748 -    for (int i = 0; i < kNumReps; i++)
 442.749 -      _reps[i] = 0;
 442.750 -    _lastLength = 0;
 442.751 -    memset(m_LastLevels, 0, kTablesSizesSum);
 442.752 -    TablesRead = false;
 442.753 -    PpmEscChar = 2;
 442.754 -    InitFilters();
 442.755 -  }
 442.756 -  if (!m_IsSolid || !TablesRead)
 442.757 -  {
 442.758 -    bool keepDecompressing;
 442.759 -    RINOK(ReadTables(keepDecompressing));
 442.760 -    if (!keepDecompressing)
 442.761 -      return S_OK;
 442.762 -  }
 442.763 -
 442.764 -  for(;;)
 442.765 -  {
 442.766 -    bool keepDecompressing;
 442.767 -    if (_lzMode)
 442.768 -    {
 442.769 -      RINOK(DecodeLZ(keepDecompressing))
 442.770 -    }
 442.771 -    else
 442.772 -    {
 442.773 -      RINOK(DecodePPM(1 << 18, keepDecompressing))
 442.774 -    }
 442.775 -    UInt64 packSize = m_InBitStream.GetProcessedSize();
 442.776 -    RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
 442.777 -    if (!keepDecompressing)
 442.778 -      break;
 442.779 -  }
 442.780 -  RINOK(WriteBuf());
 442.781 -  if (_writtenFileSize < _unpackSize)
 442.782 -    return S_FALSE;
 442.783 -  // return m_OutWindowStream.Flush();
 442.784 -  return S_OK;
 442.785 -}
 442.786 -
 442.787 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 442.788 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
 442.789 -{
 442.790 -  try
 442.791 -  {
 442.792 -    if (inSize == NULL || outSize == NULL)
 442.793 -      return E_INVALIDARG;
 442.794 -
 442.795 -    if (_vmData == 0)
 442.796 -    {
 442.797 -      _vmData = (Byte *)::MidAlloc(kVmDataSizeMax + kVmCodeSizeMax);
 442.798 -      if (_vmData == 0)
 442.799 -        return E_OUTOFMEMORY;
 442.800 -      _vmCode = _vmData + kVmDataSizeMax;
 442.801 -    }
 442.802 -    
 442.803 -    if (_window == 0)
 442.804 -    {
 442.805 -      _window = (Byte *)::MidAlloc(kWindowSize);
 442.806 -      if (_window == 0)
 442.807 -        return E_OUTOFMEMORY;
 442.808 -    }
 442.809 -    if (!m_InBitStream.Create(1 << 20))
 442.810 -      return E_OUTOFMEMORY;
 442.811 -    if (!_vm.Create())
 442.812 -      return E_OUTOFMEMORY;
 442.813 -
 442.814 -    
 442.815 -    m_InBitStream.SetStream(inStream);
 442.816 -    m_InBitStream.Init();
 442.817 -    _outStream = outStream;
 442.818 -   
 442.819 -    CCoderReleaser coderReleaser(this);
 442.820 -    _unpackSize = *outSize;
 442.821 -    return CodeReal(progress);
 442.822 -  }
 442.823 -  catch(const CInBufferException &e)  { return e.ErrorCode; }
 442.824 -  catch(...) { return S_FALSE; }
 442.825 -  // CNewException is possible here. But probably CNewException is caused
 442.826 -  // by error in data stream.
 442.827 -}
 442.828 -
 442.829 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 442.830 -{
 442.831 -  if (size < 1)
 442.832 -    return E_INVALIDARG;
 442.833 -  m_IsSolid = (data[0] != 0);
 442.834 -  return S_OK;
 442.835 -}
 442.836 -
 442.837 -}}
   443.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar3Decoder.h	Sat Mar 03 10:54:39 2012 -0600
   443.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   443.3 @@ -1,301 +0,0 @@
   443.4 -// Rar3Decoder.h
   443.5 -// According to unRAR license, this code may not be used to develop
   443.6 -// a program that creates RAR archives
   443.7 -
   443.8 -#ifndef __COMPRESS_RAR3_DECODER_H
   443.9 -#define __COMPRESS_RAR3_DECODER_H
  443.10 -
  443.11 -#include "../../Common/MyCom.h"
  443.12 -
  443.13 -#include "../ICoder.h"
  443.14 -
  443.15 -#include "../Common/InBuffer.h"
  443.16 -
  443.17 -#include "BitmDecoder.h"
  443.18 -#include "HuffmanDecoder.h"
  443.19 -#include "PpmdDecode.h"
  443.20 -#include "Rar3Vm.h"
  443.21 -
  443.22 -namespace NCompress {
  443.23 -namespace NRar3 {
  443.24 -
  443.25 -const UInt32 kWindowSize = 1 << 22;
  443.26 -const UInt32 kWindowMask = (kWindowSize - 1);
  443.27 -
  443.28 -const UInt32 kNumReps = 4;
  443.29 -const UInt32 kNumLen2Symbols = 8;
  443.30 -const UInt32 kLenTableSize = 28;
  443.31 -const UInt32 kMainTableSize = 256 + 1 + 1 + 1 + kNumReps + kNumLen2Symbols + kLenTableSize;
  443.32 -const UInt32 kDistTableSize = 60;
  443.33 -
  443.34 -const int kNumAlignBits = 4;
  443.35 -const UInt32 kAlignTableSize = (1 << kNumAlignBits) + 1;
  443.36 -
  443.37 -const UInt32 kLevelTableSize = 20;
  443.38 -
  443.39 -const UInt32 kTablesSizesSum = kMainTableSize + kDistTableSize + kAlignTableSize + kLenTableSize;
  443.40 -
  443.41 -class CBitDecoder
  443.42 -{
  443.43 -  UInt32 m_Value;
  443.44 -public:
  443.45 -  UInt32 m_BitPos;
  443.46 -  CInBuffer m_Stream;
  443.47 -  bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
  443.48 -  void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
  443.49 -  void ReleaseStream() { m_Stream.ReleaseStream();}
  443.50 -
  443.51 -  void Init()
  443.52 -  {
  443.53 -    m_Stream.Init();
  443.54 -    m_BitPos = 0;
  443.55 -    m_Value = 0;
  443.56 -    // m_BitPos = kNumBigValueBits;
  443.57 -    // Normalize();
  443.58 -  }
  443.59 -  
  443.60 -  UInt64 GetProcessedSize() const
  443.61 -    { return m_Stream.GetProcessedSize() - (m_BitPos) / 8; }
  443.62 -  UInt32 GetBitPosition() const { return ((8 - m_BitPos) & 7); }
  443.63 -  
  443.64 -  /*
  443.65 -  void Normalize()
  443.66 -  {
  443.67 -    for (;m_BitPos >= 8; m_BitPos -= 8)
  443.68 -      m_Value = (m_Value << 8) | m_Stream.ReadByte();
  443.69 -  }
  443.70 -  */
  443.71 -
  443.72 -  UInt32 GetValue(UInt32 numBits)
  443.73 -  {
  443.74 -    // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
  443.75 -    // return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
  443.76 -    if (m_BitPos < numBits)
  443.77 -    {
  443.78 -      m_BitPos += 8;
  443.79 -      m_Value = (m_Value << 8) | m_Stream.ReadByte();
  443.80 -      if (m_BitPos < numBits)
  443.81 -      {
  443.82 -        m_BitPos += 8;
  443.83 -        m_Value = (m_Value << 8) | m_Stream.ReadByte();
  443.84 -      }
  443.85 -    }
  443.86 -    return m_Value >> (m_BitPos - numBits);
  443.87 -  }
  443.88 -  
  443.89 -  void MovePos(UInt32 numBits)
  443.90 -  {
  443.91 -    m_BitPos -= numBits;
  443.92 -    m_Value = m_Value & ((1 << m_BitPos) - 1);
  443.93 -  }
  443.94 -  
  443.95 -  UInt32 ReadBits(UInt32 numBits)
  443.96 -  {
  443.97 -    UInt32 res = GetValue(numBits);
  443.98 -    MovePos(numBits);
  443.99 -    return res;
 443.100 -  }
 443.101 -};
 443.102 -
 443.103 -const int kNumTopBits = 24;
 443.104 -const UInt32 kTopValue = (1 << kNumTopBits);
 443.105 -const UInt32 kBot = (1 << 15);
 443.106 -
 443.107 -class CRangeDecoder:public NPpmd::CRangeDecoderVirt, public CBitDecoder
 443.108 -{
 443.109 -public:
 443.110 -  UInt32 Range;
 443.111 -  UInt32 Low;
 443.112 -  UInt32 Code;
 443.113 -
 443.114 -  void Normalize()
 443.115 -  {
 443.116 -    while ((Low ^ (Low + Range)) < kTopValue ||
 443.117 -       Range < kBot && ((Range = (0 - Low) & (kBot - 1)), 1))
 443.118 -    {
 443.119 -      Code = (Code << 8) | m_Stream.ReadByte();
 443.120 -      Range <<= 8;
 443.121 -      Low <<= 8;
 443.122 -    }
 443.123 -  }
 443.124 -  
 443.125 -  void InitRangeCoder()
 443.126 -  {
 443.127 -    Code = 0;
 443.128 -    Low = 0;
 443.129 -    Range = 0xFFFFFFFF;
 443.130 -    for(int i = 0; i < 4; i++)
 443.131 -      Code = (Code << 8) | ReadBits(8);
 443.132 -  }
 443.133 -
 443.134 -  virtual UInt32 GetThreshold(UInt32 total)
 443.135 -  {
 443.136 -    return (Code - Low) / ( Range /= total);
 443.137 -  }
 443.138 -
 443.139 -  virtual void Decode(UInt32 start, UInt32 size)
 443.140 -  {
 443.141 -    Low += start * Range;
 443.142 -    Range *= size;
 443.143 -    Normalize();
 443.144 -  }
 443.145 -
 443.146 -  virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
 443.147 -  {
 443.148 -    if (((Code - Low) / (Range >>= numTotalBits)) < size0)
 443.149 -    {
 443.150 -      Decode(0, size0);
 443.151 -      return 0;
 443.152 -    }
 443.153 -    else
 443.154 -    {
 443.155 -      Decode(size0, (1 << numTotalBits) - size0);
 443.156 -      return 1;
 443.157 -    }
 443.158 -  }
 443.159 -
 443.160 -  // UInt64 GetProcessedSizeRangeCoder() {return Stream.GetProcessedSize(); }
 443.161 -};
 443.162 -
 443.163 -
 443.164 -struct CFilter: public NVm::CProgram
 443.165 -{
 443.166 -  CRecordVector<Byte> GlobalData;
 443.167 -  UInt32 BlockStart;
 443.168 -  UInt32 BlockSize;
 443.169 -  UInt32 ExecCount;
 443.170 -  CFilter(): BlockStart(0), BlockSize(0), ExecCount(0) {}
 443.171 -};
 443.172 -
 443.173 -struct CTempFilter: public NVm::CProgramInitState
 443.174 -{
 443.175 -  UInt32 BlockStart;
 443.176 -  UInt32 BlockSize;
 443.177 -  UInt32 ExecCount;
 443.178 -  bool NextWindow;
 443.179 -  
 443.180 -  UInt32 FilterIndex;
 443.181 -};
 443.182 -
 443.183 -const int kNumHuffmanBits = 15;
 443.184 -
 443.185 -class CDecoder:
 443.186 -  public ICompressCoder,
 443.187 -  public ICompressSetDecoderProperties2,
 443.188 -  public CMyUnknownImp
 443.189 -{
 443.190 -  CRangeDecoder m_InBitStream;
 443.191 -  Byte *_window;
 443.192 -  UInt32 _winPos;
 443.193 -  UInt32 _wrPtr;
 443.194 -  UInt64 _lzSize;
 443.195 -  UInt64 _unpackSize;
 443.196 -  UInt64 _writtenFileSize; // if it's > _unpackSize, then _unpackSize only written
 443.197 -  CMyComPtr<ISequentialOutStream> _outStream;
 443.198 -  NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
 443.199 -  NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
 443.200 -  NHuffman::CDecoder<kNumHuffmanBits, kAlignTableSize> m_AlignDecoder;
 443.201 -  NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
 443.202 -  NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
 443.203 -
 443.204 -  UInt32 _reps[kNumReps];
 443.205 -  UInt32 _lastLength;
 443.206 -  
 443.207 -  Byte m_LastLevels[kTablesSizesSum];
 443.208 -
 443.209 -  Byte *_vmData;
 443.210 -  Byte *_vmCode;
 443.211 -  NVm::CVm _vm;
 443.212 -  CRecordVector<CFilter *> _filters;
 443.213 -  CRecordVector<CTempFilter *>  _tempFilters;
 443.214 -  UInt32 _lastFilter;
 443.215 -
 443.216 -  bool m_IsSolid;
 443.217 -
 443.218 -  bool _lzMode;
 443.219 -
 443.220 -  UInt32 PrevAlignBits;
 443.221 -  UInt32 PrevAlignCount;
 443.222 -
 443.223 -  bool TablesRead;
 443.224 -
 443.225 -  NPpmd::CDecodeInfo _ppm;
 443.226 -  int PpmEscChar;
 443.227 -  
 443.228 -  HRESULT WriteDataToStream(const Byte *data, UInt32 size);
 443.229 -  HRESULT WriteData(const Byte *data, UInt32 size);
 443.230 -  HRESULT WriteArea(UInt32 startPtr, UInt32 endPtr);
 443.231 -  void ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef);
 443.232 -  HRESULT WriteBuf();
 443.233 -
 443.234 -  void InitFilters();
 443.235 -  bool AddVmCode(UInt32 firstByte, UInt32 codeSize);
 443.236 -  bool ReadVmCodeLZ();
 443.237 -  bool ReadVmCodePPM();
 443.238 -  
 443.239 -  UInt32 ReadBits(int numBits);
 443.240 -
 443.241 -  HRESULT InitPPM();
 443.242 -  int DecodePpmSymbol();
 443.243 -  HRESULT DecodePPM(Int32 num, bool &keepDecompressing);
 443.244 -
 443.245 -  HRESULT ReadTables(bool &keepDecompressing);
 443.246 -  HRESULT ReadEndOfBlock(bool &keepDecompressing);
 443.247 -  HRESULT DecodeLZ(bool &keepDecompressing);
 443.248 -  HRESULT CodeReal(ICompressProgressInfo *progress);
 443.249 -public:
 443.250 -  CDecoder();
 443.251 -  ~CDecoder();
 443.252 -
 443.253 -  MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
 443.254 -
 443.255 -  void ReleaseStreams()
 443.256 -  {
 443.257 -    _outStream.Release();
 443.258 -    m_InBitStream.ReleaseStream();
 443.259 -  }
 443.260 -
 443.261 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 443.262 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
 443.263 -
 443.264 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
 443.265 -
 443.266 -  void CopyBlock(UInt32 distance, UInt32 len)
 443.267 -  {
 443.268 -    _lzSize += len;
 443.269 -    UInt32 pos = (_winPos - distance - 1) & kWindowMask;
 443.270 -    Byte *window = _window;
 443.271 -    UInt32 winPos = _winPos;
 443.272 -    if (kWindowSize - winPos > len && kWindowSize - pos > len)
 443.273 -    {
 443.274 -      const Byte *src = window + pos;
 443.275 -      Byte *dest = window + winPos;
 443.276 -      _winPos += len;
 443.277 -      do
 443.278 -        *dest++ = *src++;
 443.279 -      while(--len != 0);
 443.280 -      return;
 443.281 -    }
 443.282 -    do
 443.283 -    {
 443.284 -      window[winPos] = window[pos];
 443.285 -      winPos = (winPos + 1) & kWindowMask;
 443.286 -      pos = (pos + 1) & kWindowMask;
 443.287 -    }
 443.288 -    while(--len != 0);
 443.289 -    _winPos = winPos;
 443.290 -  }
 443.291 -  
 443.292 -  void PutByte(Byte b)
 443.293 -  {
 443.294 -    _window[_winPos] = b;
 443.295 -    _winPos = (_winPos + 1) & kWindowMask;
 443.296 -    _lzSize++;
 443.297 -  }
 443.298 -
 443.299 -
 443.300 -};
 443.301 -
 443.302 -}}
 443.303 -
 443.304 -#endif
   444.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar3Vm.cpp	Sat Mar 03 10:54:39 2012 -0600
   444.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   444.3 @@ -1,1094 +0,0 @@
   444.4 -// Rar3Vm.cpp
   444.5 -// According to unRAR license, this code may not be used to develop
   444.6 -// a program that creates RAR archives
   444.7 -
   444.8 -/*
   444.9 -Note:
  444.10 -  Due to performance considerations Rar VM may set Flags C incorrectly
  444.11 -  for some operands (SHL x, 0, ... ).
  444.12 -  Check implementation of concrete VM command
  444.13 -  to see if it sets flags right.
  444.14 -*/
  444.15 -
  444.16 -#include "StdAfx.h"
  444.17 -
  444.18 -extern "C"
  444.19 -{
  444.20 -#include "../../../C/7zCrc.h"
  444.21 -#include "../../../C/Alloc.h"
  444.22 -}
  444.23 -
  444.24 -#include "Rar3Vm.h"
  444.25 -
  444.26 -namespace NCompress {
  444.27 -namespace NRar3 {
  444.28 -
  444.29 -UInt32 CMemBitDecoder::ReadBits(int numBits)
  444.30 -{
  444.31 -  UInt32 res = 0;
  444.32 -  for (;;)
  444.33 -  {
  444.34 -    Byte b = _bitPos < _bitSize ? _data[_bitPos >> 3] : 0;
  444.35 -    int avail = (int)(8 - (_bitPos & 7));
  444.36 -    if (numBits <= avail)
  444.37 -    {
  444.38 -      _bitPos += numBits;
  444.39 -      return res | (b >> (avail - numBits)) & ((1 << numBits) - 1);
  444.40 -    }
  444.41 -    numBits -= avail;
  444.42 -    res |= (UInt32)(b & ((1 << avail) - 1)) << numBits;
  444.43 -    _bitPos += avail;
  444.44 -  }
  444.45 -}
  444.46 -
  444.47 -UInt32 CMemBitDecoder::ReadBit() { return ReadBits(1); }
  444.48 -
  444.49 -namespace NVm {
  444.50 -
  444.51 -static const UInt32 kStackRegIndex = kNumRegs - 1;
  444.52 -
  444.53 -static const UInt32 FLAG_C = 1;
  444.54 -static const UInt32 FLAG_Z = 2;
  444.55 -static const UInt32 FLAG_S = 0x80000000;
  444.56 -
  444.57 -static const Byte CF_OP0 = 0;
  444.58 -static const Byte CF_OP1 = 1;
  444.59 -static const Byte CF_OP2 = 2;
  444.60 -static const Byte CF_OPMASK = 3;
  444.61 -static const Byte CF_BYTEMODE = 4;
  444.62 -static const Byte CF_JUMP = 8;
  444.63 -static const Byte CF_PROC = 16;
  444.64 -static const Byte CF_USEFLAGS = 32;
  444.65 -static const Byte CF_CHFLAGS = 64;
  444.66 -
  444.67 -static Byte kCmdFlags[]=
  444.68 -{
  444.69 -  /* CMD_MOV   */ CF_OP2 | CF_BYTEMODE,
  444.70 -  /* CMD_CMP   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.71 -  /* CMD_ADD   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.72 -  /* CMD_SUB   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.73 -  /* CMD_JZ    */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.74 -  /* CMD_JNZ   */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.75 -  /* CMD_INC   */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
  444.76 -  /* CMD_DEC   */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
  444.77 -  /* CMD_JMP   */ CF_OP1 | CF_JUMP,
  444.78 -  /* CMD_XOR   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.79 -  /* CMD_AND   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.80 -  /* CMD_OR    */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.81 -  /* CMD_TEST  */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.82 -  /* CMD_JS    */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.83 -  /* CMD_JNS   */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.84 -  /* CMD_JB    */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.85 -  /* CMD_JBE   */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.86 -  /* CMD_JA    */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.87 -  /* CMD_JAE   */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
  444.88 -  /* CMD_PUSH  */ CF_OP1,
  444.89 -  /* CMD_POP   */ CF_OP1,
  444.90 -  /* CMD_CALL  */ CF_OP1 | CF_PROC,
  444.91 -  /* CMD_RET   */ CF_OP0 | CF_PROC,
  444.92 -  /* CMD_NOT   */ CF_OP1 | CF_BYTEMODE,
  444.93 -  /* CMD_SHL   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.94 -  /* CMD_SHR   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.95 -  /* CMD_SAR   */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
  444.96 -  /* CMD_NEG   */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
  444.97 -  /* CMD_PUSHA */ CF_OP0,
  444.98 -  /* CMD_POPA  */ CF_OP0,
  444.99 -  /* CMD_PUSHF */ CF_OP0 | CF_USEFLAGS,
 444.100 -  /* CMD_POPF  */ CF_OP0 | CF_CHFLAGS,
 444.101 -  /* CMD_MOVZX */ CF_OP2,
 444.102 -  /* CMD_MOVSX */ CF_OP2,
 444.103 -  /* CMD_XCHG  */ CF_OP2 | CF_BYTEMODE,
 444.104 -  /* CMD_MUL   */ CF_OP2 | CF_BYTEMODE,
 444.105 -  /* CMD_DIV   */ CF_OP2 | CF_BYTEMODE,
 444.106 -  /* CMD_ADC   */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
 444.107 -  /* CMD_SBB   */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
 444.108 -  /* CMD_PRINT */ CF_OP0
 444.109 -};
 444.110 -
 444.111 -CVm::CVm(): Mem(NULL) {}
 444.112 -
 444.113 -bool CVm::Create()
 444.114 -{
 444.115 -  if (Mem == NULL)
 444.116 -    Mem = (Byte *)::MyAlloc(kSpaceSize + 4);
 444.117 -  return (Mem != NULL);
 444.118 -}
 444.119 -
 444.120 -CVm::~CVm()
 444.121 -{
 444.122 -  ::MyFree(Mem);
 444.123 -}
 444.124 -
 444.125 -// CVm::Execute can change CProgram object: it clears progarm if VM returns error.
 444.126 -
 444.127 -bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
 444.128 -    CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData)
 444.129 -{
 444.130 -  memcpy(R, initState->InitR, sizeof(initState->InitR));
 444.131 -  R[kStackRegIndex] = kSpaceSize;
 444.132 -  R[kNumRegs] = 0;
 444.133 -  Flags = 0;
 444.134 -
 444.135 -  UInt32 globalSize = MyMin((UInt32)initState->GlobalData.Size(), kGlobalSize);
 444.136 -  if (globalSize != 0)
 444.137 -    memcpy(Mem + kGlobalOffset, &initState->GlobalData[0], globalSize);
 444.138 -  UInt32 staticSize = MyMin((UInt32)prg->StaticData.Size(), kGlobalSize - globalSize);
 444.139 -  if (staticSize != 0)
 444.140 -    memcpy(Mem + kGlobalOffset + globalSize, &prg->StaticData[0], staticSize);
 444.141 -
 444.142 -  bool res = true;
 444.143 -  #ifdef RARVM_STANDARD_FILTERS
 444.144 -  if (prg->StandardFilterIndex >= 0)
 444.145 -    ExecuteStandardFilter(prg->StandardFilterIndex);
 444.146 -  else
 444.147 -  #endif
 444.148 -  {
 444.149 -    res = ExecuteCode(prg);
 444.150 -    if (!res)
 444.151 -      prg->Commands[0].OpCode = CMD_RET;
 444.152 -  }
 444.153 -  UInt32 newBlockPos = GetFixedGlobalValue32(NGlobalOffset::kBlockPos) & kSpaceMask;
 444.154 -  UInt32 newBlockSize = GetFixedGlobalValue32(NGlobalOffset::kBlockSize) & kSpaceMask;
 444.155 -  if (newBlockPos + newBlockSize >= kSpaceSize)
 444.156 -    newBlockPos = newBlockSize = 0;
 444.157 -  outBlockRef.Offset = newBlockPos;
 444.158 -  outBlockRef.Size = newBlockSize;
 444.159 -
 444.160 -  outGlobalData.Clear();
 444.161 -  UInt32 dataSize = GetFixedGlobalValue32(NGlobalOffset::kGlobalMemOutSize);
 444.162 -  dataSize = MyMin(dataSize, kGlobalSize - kFixedGlobalSize);
 444.163 -  if (dataSize != 0)
 444.164 -  {
 444.165 -    dataSize += kFixedGlobalSize;
 444.166 -    outGlobalData.Reserve(dataSize);
 444.167 -    for (UInt32 i = 0; i < dataSize; i++)
 444.168 -      outGlobalData.Add(Mem[kGlobalOffset + i]);
 444.169 -  }
 444.170 -  return res;
 444.171 -}
 444.172 -
 444.173 -
 444.174 -#define SET_IP(IP) \
 444.175 -  if ((IP) >= numCommands) return true; \
 444.176 -  if (--maxOpCount <= 0) return false; \
 444.177 -  cmd = commands + (IP);
 444.178 -
 444.179 -#define GET_FLAG_S_B(res) (((res) & 0x80) ? FLAG_S : 0)
 444.180 -#define SET_IP_OP1 { UInt32 val = GetOperand32(&cmd->Op1); SET_IP(val); }
 444.181 -#define FLAGS_UPDATE_SZ Flags = res == 0 ? FLAG_Z : res & FLAG_S
 444.182 -#define FLAGS_UPDATE_SZ_B Flags = (res & 0xFF) == 0 ? FLAG_Z : GET_FLAG_S_B(res)
 444.183 -
 444.184 -UInt32 CVm::GetOperand32(const COperand *op) const
 444.185 -{
 444.186 -  switch(op->Type)
 444.187 -  {
 444.188 -    case OP_TYPE_REG: return R[op->Data];
 444.189 -    case OP_TYPE_REGMEM: return GetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask]);
 444.190 -    default: return op->Data;
 444.191 -  }
 444.192 -}
 444.193 -
 444.194 -void CVm::SetOperand32(const COperand *op, UInt32 val)
 444.195 -{
 444.196 -  switch(op->Type)
 444.197 -  {
 444.198 -    case OP_TYPE_REG: R[op->Data] = val; return;
 444.199 -    case OP_TYPE_REGMEM: SetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask], val); return;
 444.200 -  }
 444.201 -}
 444.202 -
 444.203 -Byte CVm::GetOperand8(const COperand *op) const
 444.204 -{
 444.205 -  switch(op->Type)
 444.206 -  {
 444.207 -    case OP_TYPE_REG: return (Byte)R[op->Data];
 444.208 -    case OP_TYPE_REGMEM: return Mem[(op->Base + R[op->Data]) & kSpaceMask];;
 444.209 -    default: return (Byte)op->Data;
 444.210 -  }
 444.211 -}
 444.212 -
 444.213 -void CVm::SetOperand8(const COperand *op, Byte val)
 444.214 -{
 444.215 -  switch(op->Type)
 444.216 -  {
 444.217 -    case OP_TYPE_REG: R[op->Data] = (R[op->Data] & 0xFFFFFF00) | val; return;
 444.218 -    case OP_TYPE_REGMEM: Mem[(op->Base + R[op->Data]) & kSpaceMask] = val; return;
 444.219 -  }
 444.220 -}
 444.221 -
 444.222 -UInt32 CVm::GetOperand(bool byteMode, const COperand *op) const
 444.223 -{
 444.224 -  if (byteMode)
 444.225 -    return GetOperand8(op);
 444.226 -  return GetOperand32(op);
 444.227 -}
 444.228 -
 444.229 -void CVm::SetOperand(bool byteMode, const COperand *op, UInt32 val)
 444.230 -{
 444.231 -  if (byteMode)
 444.232 -    SetOperand8(op, (Byte)(val & 0xFF));
 444.233 -  else
 444.234 -    SetOperand32(op, val);
 444.235 -}
 444.236 -
 444.237 -bool CVm::ExecuteCode(const CProgram *prg)
 444.238 -{
 444.239 -  Int32 maxOpCount = 25000000;
 444.240 -  const CCommand *commands = &prg->Commands[0];
 444.241 -  const CCommand *cmd = commands;
 444.242 -  UInt32 numCommands = prg->Commands.Size();
 444.243 -  for (;;)
 444.244 -  {
 444.245 -    switch(cmd->OpCode)
 444.246 -    {
 444.247 -      #ifndef RARVM_NO_VM
 444.248 -      
 444.249 -      case CMD_MOV:
 444.250 -        SetOperand32(&cmd->Op1, GetOperand32(&cmd->Op2));
 444.251 -        break;
 444.252 -      case CMD_MOVB:
 444.253 -        SetOperand8(&cmd->Op1, GetOperand8(&cmd->Op2));
 444.254 -        break;
 444.255 -      case CMD_CMP:
 444.256 -        {
 444.257 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.258 -          UInt32 res = v1 - GetOperand32(&cmd->Op2);
 444.259 -          Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
 444.260 -        }
 444.261 -        break;
 444.262 -      case CMD_CMPB:
 444.263 -        {
 444.264 -          Byte v1 = GetOperand8(&cmd->Op1);
 444.265 -          Byte res = v1 - GetOperand8(&cmd->Op2);
 444.266 -          res &= 0xFF;
 444.267 -          Flags = res == 0 ? FLAG_Z : (res > v1) | GET_FLAG_S_B(res);
 444.268 -        }
 444.269 -        break;
 444.270 -      case CMD_ADD:
 444.271 -        {
 444.272 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.273 -          UInt32 res = v1 + GetOperand32(&cmd->Op2);
 444.274 -          SetOperand32(&cmd->Op1, res);
 444.275 -          Flags = (res < v1) | (res == 0 ? FLAG_Z : (res & FLAG_S));
 444.276 -        }
 444.277 -        break;
 444.278 -      case CMD_ADDB:
 444.279 -        {
 444.280 -          Byte v1 = GetOperand8(&cmd->Op1);
 444.281 -          Byte res = v1 + GetOperand8(&cmd->Op2);
 444.282 -          res &= 0xFF;
 444.283 -          SetOperand8(&cmd->Op1, (Byte)res);
 444.284 -          Flags = (res < v1) | (res == 0 ? FLAG_Z : GET_FLAG_S_B(res));
 444.285 -        }
 444.286 -        break;
 444.287 -      case CMD_ADC:
 444.288 -        {
 444.289 -          UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
 444.290 -          UInt32 FC = (Flags & FLAG_C);
 444.291 -          UInt32 res = v1 + GetOperand(cmd->ByteMode, &cmd->Op2) + FC;
 444.292 -          if (cmd->ByteMode)
 444.293 -            res &= 0xFF;
 444.294 -          SetOperand(cmd->ByteMode, &cmd->Op1, res);
 444.295 -          Flags = (res < v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
 444.296 -        }
 444.297 -        break;
 444.298 -      case CMD_SUB:
 444.299 -        {
 444.300 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.301 -          UInt32 res = v1 - GetOperand32(&cmd->Op2);
 444.302 -          SetOperand32(&cmd->Op1, res);
 444.303 -          Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
 444.304 -        }
 444.305 -        break;
 444.306 -      case CMD_SUBB:
 444.307 -        {
 444.308 -          UInt32 v1 = GetOperand8(&cmd->Op1);
 444.309 -          UInt32 res = v1 - GetOperand8(&cmd->Op2);
 444.310 -          SetOperand8(&cmd->Op1, (Byte)res);
 444.311 -          Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
 444.312 -        }
 444.313 -        break;
 444.314 -      case CMD_SBB:
 444.315 -        {
 444.316 -          UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
 444.317 -          UInt32 FC = (Flags & FLAG_C);
 444.318 -          UInt32 res = v1 - GetOperand(cmd->ByteMode, &cmd->Op2) - FC;
 444.319 -          // Flags = res == 0 ? FLAG_Z : (res > v1 || res == v1 && FC) | (res & FLAG_S);
 444.320 -          if (cmd->ByteMode)
 444.321 -            res &= 0xFF;
 444.322 -          SetOperand(cmd->ByteMode, &cmd->Op1, res);
 444.323 -          Flags = (res > v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
 444.324 -        }
 444.325 -        break;
 444.326 -      case CMD_INC:
 444.327 -        {
 444.328 -          UInt32 res = GetOperand32(&cmd->Op1) + 1;
 444.329 -          SetOperand32(&cmd->Op1, res);
 444.330 -          FLAGS_UPDATE_SZ;
 444.331 -        }
 444.332 -        break;
 444.333 -      case CMD_INCB:
 444.334 -        {
 444.335 -          Byte res = GetOperand8(&cmd->Op1) + 1;
 444.336 -          SetOperand8(&cmd->Op1, res);;
 444.337 -          FLAGS_UPDATE_SZ_B;
 444.338 -        }
 444.339 -        break;
 444.340 -      case CMD_DEC:
 444.341 -        {
 444.342 -          UInt32 res = GetOperand32(&cmd->Op1) - 1;
 444.343 -          SetOperand32(&cmd->Op1, res);
 444.344 -          FLAGS_UPDATE_SZ;
 444.345 -        }
 444.346 -        break;
 444.347 -      case CMD_DECB:
 444.348 -        {
 444.349 -          Byte res = GetOperand8(&cmd->Op1) - 1;
 444.350 -          SetOperand8(&cmd->Op1, res);;
 444.351 -          FLAGS_UPDATE_SZ_B;
 444.352 -        }
 444.353 -        break;
 444.354 -      case CMD_XOR:
 444.355 -        {
 444.356 -          UInt32 res = GetOperand32(&cmd->Op1) ^ GetOperand32(&cmd->Op2);
 444.357 -          SetOperand32(&cmd->Op1, res);
 444.358 -          FLAGS_UPDATE_SZ;
 444.359 -        }
 444.360 -        break;
 444.361 -      case CMD_XORB:
 444.362 -        {
 444.363 -          Byte res = GetOperand8(&cmd->Op1) ^ GetOperand8(&cmd->Op2);
 444.364 -          SetOperand8(&cmd->Op1, res);
 444.365 -          FLAGS_UPDATE_SZ_B;
 444.366 -        }
 444.367 -        break;
 444.368 -      case CMD_AND:
 444.369 -        {
 444.370 -          UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
 444.371 -          SetOperand32(&cmd->Op1, res);
 444.372 -          FLAGS_UPDATE_SZ;
 444.373 -        }
 444.374 -        break;
 444.375 -      case CMD_ANDB:
 444.376 -        {
 444.377 -          Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
 444.378 -          SetOperand8(&cmd->Op1, res);
 444.379 -          FLAGS_UPDATE_SZ_B;
 444.380 -        }
 444.381 -        break;
 444.382 -      case CMD_OR:
 444.383 -        {
 444.384 -          UInt32 res = GetOperand32(&cmd->Op1) | GetOperand32(&cmd->Op2);
 444.385 -          SetOperand32(&cmd->Op1, res);
 444.386 -          FLAGS_UPDATE_SZ;
 444.387 -        }
 444.388 -        break;
 444.389 -      case CMD_ORB:
 444.390 -        {
 444.391 -          Byte res = GetOperand8(&cmd->Op1) | GetOperand8(&cmd->Op2);
 444.392 -          SetOperand8(&cmd->Op1, res);
 444.393 -          FLAGS_UPDATE_SZ_B;
 444.394 -        }
 444.395 -        break;
 444.396 -      case CMD_TEST:
 444.397 -        {
 444.398 -          UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
 444.399 -          FLAGS_UPDATE_SZ;
 444.400 -        }
 444.401 -        break;
 444.402 -      case CMD_TESTB:
 444.403 -        {
 444.404 -          Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
 444.405 -          FLAGS_UPDATE_SZ_B;
 444.406 -        }
 444.407 -        break;
 444.408 -      case CMD_NOT:
 444.409 -        SetOperand(cmd->ByteMode, &cmd->Op1, ~GetOperand(cmd->ByteMode, &cmd->Op1));
 444.410 -        break;
 444.411 -      case CMD_NEG:
 444.412 -        {
 444.413 -          UInt32 res = 0 - GetOperand32(&cmd->Op1);
 444.414 -          SetOperand32(&cmd->Op1, res);
 444.415 -          Flags = res == 0 ? FLAG_Z : FLAG_C | (res & FLAG_S);
 444.416 -        }
 444.417 -        break;
 444.418 -      case CMD_NEGB:
 444.419 -        {
 444.420 -          Byte res = (Byte)(0 - GetOperand8(&cmd->Op1));
 444.421 -          SetOperand8(&cmd->Op1, res);
 444.422 -          Flags = res == 0 ? FLAG_Z : FLAG_C | GET_FLAG_S_B(res);
 444.423 -        }
 444.424 -        break;
 444.425 -
 444.426 -      case CMD_SHL:
 444.427 -        {
 444.428 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.429 -          int v2 = (int)GetOperand32(&cmd->Op2);
 444.430 -          UInt32 res = v1 << v2;
 444.431 -          SetOperand32(&cmd->Op1, res);
 444.432 -          Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 << (v2 - 1)) & 0x80000000 ? FLAG_C : 0);
 444.433 -        }
 444.434 -        break;
 444.435 -      case CMD_SHLB:
 444.436 -        {
 444.437 -          Byte v1 = GetOperand8(&cmd->Op1);
 444.438 -          int v2 = (int)GetOperand8(&cmd->Op2);
 444.439 -          Byte res = (Byte)(v1 << v2);
 444.440 -          SetOperand8(&cmd->Op1, res);
 444.441 -          Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 << (v2 - 1)) & 0x80 ? FLAG_C : 0);
 444.442 -        }
 444.443 -        break;
 444.444 -      case CMD_SHR:
 444.445 -        {
 444.446 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.447 -          int v2 = (int)GetOperand32(&cmd->Op2);
 444.448 -          UInt32 res = v1 >> v2;
 444.449 -          SetOperand32(&cmd->Op1, res);
 444.450 -          Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
 444.451 -        }
 444.452 -        break;
 444.453 -      case CMD_SHRB:
 444.454 -        {
 444.455 -          Byte v1 = GetOperand8(&cmd->Op1);
 444.456 -          int v2 = (int)GetOperand8(&cmd->Op2);
 444.457 -          Byte res = (Byte)(v1 >> v2);
 444.458 -          SetOperand8(&cmd->Op1, res);
 444.459 -          Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
 444.460 -        }
 444.461 -        break;
 444.462 -      case CMD_SAR:
 444.463 -        {
 444.464 -          UInt32 v1 = GetOperand32(&cmd->Op1);
 444.465 -          int v2 = (int)GetOperand32(&cmd->Op2);
 444.466 -          UInt32 res = UInt32(((Int32)v1) >> v2);
 444.467 -          SetOperand32(&cmd->Op1, res);
 444.468 -          Flags= (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
 444.469 -        }
 444.470 -        break;
 444.471 -      case CMD_SARB:
 444.472 -        {
 444.473 -          Byte v1 = GetOperand8(&cmd->Op1);
 444.474 -          int v2 = (int)GetOperand8(&cmd->Op2);
 444.475 -          Byte res = (Byte)(((signed char)v1) >> v2);
 444.476 -          SetOperand8(&cmd->Op1, res);
 444.477 -          Flags= (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
 444.478 -        }
 444.479 -        break;
 444.480 -
 444.481 -      case CMD_JMP:
 444.482 -        SET_IP_OP1;
 444.483 -        continue;
 444.484 -      case CMD_JZ:
 444.485 -        if ((Flags & FLAG_Z) != 0)
 444.486 -        {
 444.487 -          SET_IP_OP1;
 444.488 -          continue;
 444.489 -        }
 444.490 -        break;
 444.491 -      case CMD_JNZ:
 444.492 -        if ((Flags & FLAG_Z) == 0)
 444.493 -        {
 444.494 -          SET_IP_OP1;
 444.495 -          continue;
 444.496 -        }
 444.497 -        break;
 444.498 -      case CMD_JS:
 444.499 -        if ((Flags & FLAG_S) != 0)
 444.500 -        {
 444.501 -          SET_IP_OP1;
 444.502 -          continue;
 444.503 -        }
 444.504 -        break;
 444.505 -      case CMD_JNS:
 444.506 -        if ((Flags & FLAG_S) == 0)
 444.507 -        {
 444.508 -          SET_IP_OP1;
 444.509 -          continue;
 444.510 -        }
 444.511 -        break;
 444.512 -      case CMD_JB:
 444.513 -        if ((Flags & FLAG_C) != 0)
 444.514 -        {
 444.515 -          SET_IP_OP1;
 444.516 -          continue;
 444.517 -        }
 444.518 -        break;
 444.519 -      case CMD_JBE:
 444.520 -        if ((Flags & (FLAG_C | FLAG_Z)) != 0)
 444.521 -        {
 444.522 -          SET_IP_OP1;
 444.523 -          continue;
 444.524 -        }
 444.525 -        break;
 444.526 -      case CMD_JA:
 444.527 -        if ((Flags & (FLAG_C | FLAG_Z)) == 0)
 444.528 -        {
 444.529 -          SET_IP_OP1;
 444.530 -          continue;
 444.531 -        }
 444.532 -        break;
 444.533 -      case CMD_JAE:
 444.534 -        if ((Flags & FLAG_C) == 0)
 444.535 -        {
 444.536 -          SET_IP_OP1;
 444.537 -          continue;
 444.538 -        }
 444.539 -        break;
 444.540 -      
 444.541 -      case CMD_PUSH:
 444.542 -        R[kStackRegIndex] -= 4;
 444.543 -        SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], GetOperand32(&cmd->Op1));
 444.544 -        break;
 444.545 -      case CMD_POP:
 444.546 -        SetOperand32(&cmd->Op1, GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]));
 444.547 -        R[kStackRegIndex] += 4;
 444.548 -        break;
 444.549 -      case CMD_CALL:
 444.550 -        R[kStackRegIndex] -= 4;
 444.551 -        SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], (UInt32)(cmd - commands + 1));
 444.552 -        SET_IP_OP1;
 444.553 -        continue;
 444.554 -
 444.555 -      case CMD_PUSHA:
 444.556 -        {
 444.557 -          for (UInt32 i = 0, SP = R[kStackRegIndex] - 4; i < kNumRegs; i++, SP -= 4)
 444.558 -            SetValue32(&Mem[SP & kSpaceMask], R[i]);
 444.559 -          R[kStackRegIndex] -= kNumRegs * 4;
 444.560 -        }
 444.561 -        break;
 444.562 -      case CMD_POPA:
 444.563 -        {
 444.564 -          for (UInt32 i = 0, SP = R[kStackRegIndex]; i < kNumRegs; i++, SP += 4)
 444.565 -            R[kStackRegIndex - i] = GetValue32(&Mem[SP & kSpaceMask]);
 444.566 -        }
 444.567 -        break;
 444.568 -      case CMD_PUSHF:
 444.569 -        R[kStackRegIndex] -= 4;
 444.570 -        SetValue32(&Mem[R[kStackRegIndex]&kSpaceMask], Flags);
 444.571 -        break;
 444.572 -      case CMD_POPF:
 444.573 -        Flags = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
 444.574 -        R[kStackRegIndex] += 4;
 444.575 -        break;
 444.576 -      
 444.577 -      case CMD_MOVZX:
 444.578 -        SetOperand32(&cmd->Op1, GetOperand8(&cmd->Op2));
 444.579 -        break;
 444.580 -      case CMD_MOVSX:
 444.581 -        SetOperand32(&cmd->Op1, (UInt32)(Int32)(signed char)GetOperand8(&cmd->Op2));
 444.582 -        break;
 444.583 -      case CMD_XCHG:
 444.584 -        {
 444.585 -          UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
 444.586 -          SetOperand(cmd->ByteMode, &cmd->Op1, GetOperand(cmd->ByteMode, &cmd->Op2));
 444.587 -          SetOperand(cmd->ByteMode, &cmd->Op2, v1);
 444.588 -        }
 444.589 -        break;
 444.590 -      case CMD_MUL:
 444.591 -        {
 444.592 -          UInt32 res = GetOperand32(&cmd->Op1) * GetOperand32(&cmd->Op2);
 444.593 -          SetOperand32(&cmd->Op1, res);
 444.594 -        }
 444.595 -        break;
 444.596 -      case CMD_MULB:
 444.597 -        {
 444.598 -          Byte res = GetOperand8(&cmd->Op1) * GetOperand8(&cmd->Op2);
 444.599 -          SetOperand8(&cmd->Op1, res);
 444.600 -        }
 444.601 -        break;
 444.602 -      case CMD_DIV:
 444.603 -        {
 444.604 -          UInt32 divider = GetOperand(cmd->ByteMode, &cmd->Op2);
 444.605 -          if (divider != 0)
 444.606 -          {
 444.607 -            UInt32 res = GetOperand(cmd->ByteMode, &cmd->Op1) / divider;
 444.608 -            SetOperand(cmd->ByteMode, &cmd->Op1, res);
 444.609 -          }
 444.610 -        }
 444.611 -        break;
 444.612 -      
 444.613 -      #endif
 444.614 -      
 444.615 -      case CMD_RET:
 444.616 -        {
 444.617 -          if (R[kStackRegIndex] >= kSpaceSize)
 444.618 -            return true;
 444.619 -          UInt32 ip = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
 444.620 -          SET_IP(ip);
 444.621 -          R[kStackRegIndex] += 4;
 444.622 -          continue;
 444.623 -        }
 444.624 -      case CMD_PRINT:
 444.625 -        break;
 444.626 -    }
 444.627 -    cmd++;
 444.628 -    --maxOpCount;
 444.629 -  }
 444.630 -}
 444.631 -
 444.632 -
 444.633 -//////////////////////////////////////////////////////
 444.634 -// Read program
 444.635 -
 444.636 -UInt32 ReadEncodedUInt32(CMemBitDecoder &inp)
 444.637 -{
 444.638 -  switch(inp.ReadBits(2))
 444.639 -  {
 444.640 -    case 0:
 444.641 -      return inp.ReadBits(4);
 444.642 -    case 1:
 444.643 -    {
 444.644 -      UInt32 v = inp.ReadBits(4);
 444.645 -      if (v == 0)
 444.646 -        return 0xFFFFFF00 | inp.ReadBits(8);
 444.647 -      else
 444.648 -        return (v << 4) | inp.ReadBits(4);
 444.649 -    }
 444.650 -    case 2:
 444.651 -      return inp.ReadBits(16);
 444.652 -    default:
 444.653 -      return inp.ReadBits(32);
 444.654 -  }
 444.655 -}
 444.656 -
 444.657 -void CVm::DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode)
 444.658 -{
 444.659 -  if (inp.ReadBit())
 444.660 -  {
 444.661 -    op.Type = OP_TYPE_REG;
 444.662 -    op.Data = inp.ReadBits(kNumRegBits);
 444.663 -  }
 444.664 -  else if (inp.ReadBit() == 0)
 444.665 -  {
 444.666 -    op.Type = OP_TYPE_INT;
 444.667 -    if (byteMode)
 444.668 -      op.Data = inp.ReadBits(8);
 444.669 -    else
 444.670 -      op.Data = ReadEncodedUInt32(inp);
 444.671 -  }
 444.672 -  else
 444.673 -  {
 444.674 -    op.Type = OP_TYPE_REGMEM;
 444.675 -    if (inp.ReadBit() == 0)
 444.676 -    {
 444.677 -      op.Data = inp.ReadBits(kNumRegBits);
 444.678 -      op.Base = 0;
 444.679 -    }
 444.680 -    else
 444.681 -    {
 444.682 -      if (inp.ReadBit() == 0)
 444.683 -        op.Data = inp.ReadBits(kNumRegBits);
 444.684 -      else
 444.685 -        op.Data = kNumRegs;
 444.686 -      op.Base = ReadEncodedUInt32(inp);
 444.687 -    }
 444.688 -  }
 444.689 -}
 444.690 -
 444.691 -void CVm::ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
 444.692 -{
 444.693 -  CMemBitDecoder inp;
 444.694 -  inp.Init(code, codeSize);
 444.695 -
 444.696 -  prg->StaticData.Clear();
 444.697 -  if (inp.ReadBit())
 444.698 -  {
 444.699 -    UInt32 dataSize = ReadEncodedUInt32(inp) + 1;
 444.700 -    for (UInt32 i = 0; inp.Avail() && i < dataSize; i++)
 444.701 -      prg->StaticData.Add((Byte)inp.ReadBits(8));
 444.702 -  }
 444.703 -  while (inp.Avail())
 444.704 -  {
 444.705 -    prg->Commands.Add(CCommand());
 444.706 -    CCommand *cmd = &prg->Commands.Back();
 444.707 -    if (inp.ReadBit() == 0)
 444.708 -      cmd->OpCode = (ECommand)inp.ReadBits(3);
 444.709 -    else
 444.710 -      cmd->OpCode = (ECommand)(8 + inp.ReadBits(5));
 444.711 -    if (kCmdFlags[cmd->OpCode] & CF_BYTEMODE)
 444.712 -      cmd->ByteMode = (inp.ReadBit()) ? true : false;
 444.713 -    else
 444.714 -      cmd->ByteMode = 0;
 444.715 -    int opNum = (kCmdFlags[cmd->OpCode] & CF_OPMASK);
 444.716 -    if (opNum > 0)
 444.717 -    {
 444.718 -      DecodeArg(inp, cmd->Op1, cmd->ByteMode);
 444.719 -      if (opNum == 2)
 444.720 -        DecodeArg(inp, cmd->Op2, cmd->ByteMode);
 444.721 -      else
 444.722 -      {
 444.723 -        if (cmd->Op1.Type == OP_TYPE_INT && (kCmdFlags[cmd->OpCode] & (CF_JUMP | CF_PROC)))
 444.724 -        {
 444.725 -          int Distance = cmd->Op1.Data;
 444.726 -          if (Distance >= 256)
 444.727 -            Distance -= 256;
 444.728 -          else
 444.729 -          {
 444.730 -            if (Distance >= 136)
 444.731 -              Distance -= 264;
 444.732 -            else if (Distance >= 16)
 444.733 -              Distance -= 8;
 444.734 -            else if (Distance >= 8)
 444.735 -              Distance -= 16;
 444.736 -            Distance += prg->Commands.Size() - 1;
 444.737 -          }
 444.738 -          cmd->Op1.Data = Distance;
 444.739 -        }
 444.740 -      }
 444.741 -    }
 444.742 -    if (cmd->ByteMode)
 444.743 -    {
 444.744 -      switch (cmd->OpCode)
 444.745 -      {
 444.746 -        case CMD_MOV: cmd->OpCode = CMD_MOVB; break;
 444.747 -        case CMD_CMP: cmd->OpCode = CMD_CMPB; break;
 444.748 -        case CMD_ADD: cmd->OpCode = CMD_ADDB; break;
 444.749 -        case CMD_SUB: cmd->OpCode = CMD_SUBB; break;
 444.750 -        case CMD_INC: cmd->OpCode = CMD_INCB; break;
 444.751 -        case CMD_DEC: cmd->OpCode = CMD_DECB; break;
 444.752 -        case CMD_XOR: cmd->OpCode = CMD_XORB; break;
 444.753 -        case CMD_AND: cmd->OpCode = CMD_ANDB; break;
 444.754 -        case CMD_OR: cmd->OpCode = CMD_ORB; break;
 444.755 -        case CMD_TEST: cmd->OpCode = CMD_TESTB; break;
 444.756 -        case CMD_NEG: cmd->OpCode = CMD_NEGB; break;
 444.757 -        case CMD_SHL: cmd->OpCode = CMD_SHLB; break;
 444.758 -        case CMD_SHR: cmd->OpCode = CMD_SHRB; break;
 444.759 -        case CMD_SAR: cmd->OpCode = CMD_SARB; break;
 444.760 -        case CMD_MUL: cmd->OpCode = CMD_MULB; break;
 444.761 -      }
 444.762 -    }
 444.763 -  }
 444.764 -}
 444.765 -
 444.766 -#ifdef RARVM_STANDARD_FILTERS
 444.767 -
 444.768 -enum EStandardFilter
 444.769 -{
 444.770 -  SF_E8,
 444.771 -  SF_E8E9,
 444.772 -  SF_ITANIUM,
 444.773 -  SF_RGB,
 444.774 -  SF_AUDIO,
 444.775 -  SF_DELTA,
 444.776 -  SF_UPCASE
 444.777 -};
 444.778 -
 444.779 -struct StandardFilterSignature
 444.780 -{
 444.781 -  UInt32 Length;
 444.782 -  UInt32 CRC;
 444.783 -  EStandardFilter Type;
 444.784 -}
 444.785 -kStdFilters[]=
 444.786 -{
 444.787 -   53, 0xad576887, SF_E8,
 444.788 -   57, 0x3cd7e57e, SF_E8E9,
 444.789 -  120, 0x3769893f, SF_ITANIUM,
 444.790 -   29, 0x0e06077d, SF_DELTA,
 444.791 -  149, 0x1c2c5dc8, SF_RGB,
 444.792 -  216, 0xbc85e701, SF_AUDIO,
 444.793 -   40, 0x46b9c560, SF_UPCASE
 444.794 -};
 444.795 -
 444.796 -static int FindStandardFilter(const Byte *code, UInt32 codeSize)
 444.797 -{
 444.798 -  UInt32 crc = CrcCalc(code, codeSize);
 444.799 -  for (int i = 0; i < sizeof(kStdFilters) / sizeof(kStdFilters[0]); i++)
 444.800 -  {
 444.801 -    StandardFilterSignature &sfs = kStdFilters[i];
 444.802 -    if (sfs.CRC == crc && sfs.Length == codeSize)
 444.803 -      return i;
 444.804 -  }
 444.805 -  return -1;
 444.806 -}
 444.807 -
 444.808 -#endif
 444.809 -
 444.810 -void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
 444.811 -{
 444.812 -  Byte xorSum = 0;
 444.813 -  for (UInt32 i = 1; i < codeSize; i++)
 444.814 -    xorSum ^= code[i];
 444.815 -
 444.816 -  prg->Commands.Clear();
 444.817 -  #ifdef RARVM_STANDARD_FILTERS
 444.818 -  prg->StandardFilterIndex = -1;
 444.819 -  #endif
 444.820 -
 444.821 -  if (xorSum == code[0] && codeSize > 0)
 444.822 -  {
 444.823 -    #ifdef RARVM_STANDARD_FILTERS
 444.824 -    prg->StandardFilterIndex = FindStandardFilter(code, codeSize);
 444.825 -    if (prg->StandardFilterIndex >= 0)
 444.826 -      return;
 444.827 -    #endif
 444.828 -    // 1 byte for checksum
 444.829 -    ReadVmProgram(code + 1, codeSize - 1, prg);
 444.830 -  }
 444.831 -  prg->Commands.Add(CCommand());
 444.832 -  CCommand *cmd = &prg->Commands.Back();
 444.833 -  cmd->OpCode = CMD_RET;
 444.834 -}
 444.835 -
 444.836 -void CVm::SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize)
 444.837 -{
 444.838 -  if (pos < kSpaceSize && data != Mem + pos)
 444.839 -    memmove(Mem + pos, data, MyMin(dataSize, kSpaceSize - pos));
 444.840 -}
 444.841 -
 444.842 -#ifdef RARVM_STANDARD_FILTERS
 444.843 -
 444.844 -static void E8E9Decode(Byte *data, UInt32 dataSize, UInt32 fileOffset, bool e9)
 444.845 -{
 444.846 -  if (dataSize <= 4)
 444.847 -    return;
 444.848 -  dataSize -= 4;
 444.849 -  const UInt32 kFileSize = 0x1000000;
 444.850 -  Byte cmpByte2 = (e9 ? 0xE9 : 0xE8);
 444.851 -  for (UInt32 curPos = 0; curPos < dataSize;)
 444.852 -  {
 444.853 -    Byte curByte = *(data++);
 444.854 -    curPos++;
 444.855 -    if (curByte == 0xE8 || curByte == cmpByte2)
 444.856 -    {
 444.857 -      UInt32 offset = curPos + fileOffset;
 444.858 -      UInt32 addr = (Int32)GetValue32(data);
 444.859 -      if (addr < kFileSize)
 444.860 -        SetValue32(data, addr - offset);
 444.861 -      else if ((Int32)addr < 0 && (Int32)(addr + offset) >= 0)
 444.862 -        SetValue32(data, addr + kFileSize);
 444.863 -      data += 4;
 444.864 -      curPos += 4;
 444.865 -    }
 444.866 -  }
 444.867 -}
 444.868 -
 444.869 -static inline UInt32 ItaniumGetOpType(const Byte *data, int bitPos)
 444.870 -{
 444.871 -  return (data[(unsigned int)bitPos >> 3] >> (bitPos & 7)) & 0xF;
 444.872 -}
 444.873 -
 444.874 -
 444.875 -static void ItaniumDecode(Byte *data, UInt32 dataSize, UInt32 fileOffset)
 444.876 -{
 444.877 -  UInt32 curPos = 0;
 444.878 -  fileOffset >>= 4;
 444.879 -  while (curPos < dataSize - 21)
 444.880 -  {
 444.881 -    int b = (data[0] & 0x1F) - 0x10;
 444.882 -    if (b >= 0)
 444.883 -    {
 444.884 -      static Byte kCmdMasks[16] = {4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0};
 444.885 -      Byte cmdMask = kCmdMasks[b];
 444.886 -      if (cmdMask != 0)
 444.887 -        for (int i = 0; i < 3; i++)
 444.888 -          if (cmdMask & (1 << i))
 444.889 -          {
 444.890 -            int startPos = i * 41 + 18;
 444.891 -            if (ItaniumGetOpType(data, startPos + 24) == 5)
 444.892 -            {
 444.893 -              const UInt32 kMask = 0xFFFFF;
 444.894 -              Byte *p = data + ((unsigned int)startPos >> 3);
 444.895 -              UInt32 bitField =  ((UInt32)p[0]) | ((UInt32)p[1] <<  8) | ((UInt32)p[2] << 16);
 444.896 -              int inBit = (startPos & 7);
 444.897 -              UInt32 offset = (bitField >> inBit) & kMask;
 444.898 -              UInt32 andMask = ~(kMask << inBit);
 444.899 -              bitField = ((offset - fileOffset) & kMask) << inBit;
 444.900 -              for (int j = 0; j < 3; j++)
 444.901 -              {
 444.902 -                p[j] &= andMask;
 444.903 -                p[j] |= bitField;
 444.904 -                andMask >>= 8;
 444.905 -                bitField >>= 8;
 444.906 -              }
 444.907 -            }
 444.908 -          }
 444.909 -    }
 444.910 -    data += 16;
 444.911 -    curPos += 16;
 444.912 -    fileOffset++;
 444.913 -  }
 444.914 -}
 444.915 -
 444.916 -static void DeltaDecode(Byte *data, UInt32 dataSize, UInt32 numChannels)
 444.917 -{
 444.918 -  UInt32 srcPos = 0;
 444.919 -  UInt32 border = dataSize * 2;
 444.920 -  for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
 444.921 -  {
 444.922 -    Byte prevByte = 0;
 444.923 -    for (UInt32 destPos = dataSize + curChannel; destPos < border; destPos += numChannels)
 444.924 -      data[destPos] = (prevByte = prevByte - data[srcPos++]);
 444.925 -  }
 444.926 -}
 444.927 -
 444.928 -static void RgbDecode(Byte *srcData, UInt32 dataSize, UInt32 width, UInt32 posR)
 444.929 -{
 444.930 -  Byte *destData = srcData + dataSize;
 444.931 -  const UInt32 numChannels = 3;
 444.932 -  for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
 444.933 -  {
 444.934 -    Byte prevByte = 0;
 444.935 -    
 444.936 -    for (UInt32 i = curChannel; i < dataSize; i+= numChannels)
 444.937 -    {
 444.938 -      unsigned int predicted;
 444.939 -      if (i < width)
 444.940 -        predicted = prevByte;
 444.941 -      else
 444.942 -      {
 444.943 -        unsigned int upperLeftByte = destData[i - width];
 444.944 -        unsigned int upperByte = destData[i - width + 3];
 444.945 -        predicted = prevByte + upperByte - upperLeftByte;
 444.946 -        int pa = abs((int)(predicted - prevByte));
 444.947 -        int pb = abs((int)(predicted - upperByte));
 444.948 -        int pc = abs((int)(predicted - upperLeftByte));
 444.949 -        if (pa <= pb && pa <= pc)
 444.950 -          predicted = prevByte;
 444.951 -        else
 444.952 -          if (pb <= pc)
 444.953 -            predicted = upperByte;
 444.954 -          else
 444.955 -            predicted = upperLeftByte;
 444.956 -      }
 444.957 -      destData[i] = prevByte = (Byte)(predicted - *(srcData++));
 444.958 -    }
 444.959 -  }
 444.960 -  if (dataSize < 3)
 444.961 -    return;
 444.962 -  for (UInt32 i = posR, border = dataSize - 2; i < border; i += 3)
 444.963 -  {
 444.964 -    Byte g = destData[i + 1];
 444.965 -    destData[i] = destData[i] + g;
 444.966 -    destData[i + 2] = destData[i + 2] + g;
 444.967 -  }
 444.968 -}
 444.969 -
 444.970 -static void AudioDecode(Byte *srcData, UInt32 dataSize, UInt32 numChannels)
 444.971 -{
 444.972 -  Byte *destData = srcData + dataSize;
 444.973 -  for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
 444.974 -  {
 444.975 -    UInt32 prevByte = 0, prevDelta = 0, dif[7];
 444.976 -    Int32 D1 = 0, D2 = 0, D3;
 444.977 -    Int32 K1 = 0, K2 = 0, K3 = 0;
 444.978 -    memset(dif, 0, sizeof(dif));
 444.979 -    
 444.980 -    for (UInt32 i = curChannel, byteCount = 0; i < dataSize; i += numChannels, byteCount++)
 444.981 -    {
 444.982 -      D3 = D2;
 444.983 -      D2 = prevDelta - D1;
 444.984 -      D1 = prevDelta;
 444.985 -      
 444.986 -      UInt32 predicted = 8 * prevByte + K1 * D1 + K2 * D2 + K3 * D3;
 444.987 -      predicted = (predicted >> 3) & 0xFF;
 444.988 -      
 444.989 -      UInt32 curByte = *(srcData++);
 444.990 -      
 444.991 -      predicted -= curByte;
 444.992 -      destData[i] = (Byte)predicted;
 444.993 -      prevDelta = (UInt32)(Int32)(signed char)(predicted - prevByte);
 444.994 -      prevByte = predicted;
 444.995 -      
 444.996 -      Int32 D = ((Int32)(signed char)curByte) << 3;
 444.997 -      
 444.998 -      dif[0] += abs(D);
 444.999 -      dif[1] += abs(D - D1);
444.1000 -      dif[2] += abs(D + D1);
444.1001 -      dif[3] += abs(D - D2);
444.1002 -      dif[4] += abs(D + D2);
444.1003 -      dif[5] += abs(D - D3);
444.1004 -      dif[6] += abs(D + D3);
444.1005 -      
444.1006 -      if ((byteCount & 0x1F) == 0)
444.1007 -      {
444.1008 -        UInt32 minDif = dif[0], numMinDif = 0;
444.1009 -        dif[0] = 0;
444.1010 -        for (int j = 1; j < sizeof(dif) / sizeof(dif[0]); j++)
444.1011 -        {
444.1012 -          if (dif[j] < minDif)
444.1013 -          {
444.1014 -            minDif = dif[j];
444.1015 -            numMinDif = j;
444.1016 -          }
444.1017 -          dif[j] = 0;
444.1018 -        }
444.1019 -        switch (numMinDif)
444.1020 -        {
444.1021 -          case 1: if (K1 >= -16) K1--; break;
444.1022 -          case 2: if (K1 <   16) K1++; break;
444.1023 -          case 3: if (K2 >= -16) K2--; break;
444.1024 -          case 4: if (K2 <   16) K2++; break;
444.1025 -          case 5: if (K3 >= -16) K3--; break;
444.1026 -          case 6: if (K3 <   16) K3++; break;
444.1027 -        }
444.1028 -      }
444.1029 -    }
444.1030 -  }
444.1031 -}
444.1032 -
444.1033 -static UInt32 UpCaseDecode(Byte *data, UInt32 dataSize)
444.1034 -{
444.1035 -  UInt32 srcPos = 0, destPos = dataSize;
444.1036 -  while (srcPos < dataSize)
444.1037 -  {
444.1038 -    Byte curByte = data[srcPos++];
444.1039 -    if (curByte == 2 && (curByte = data[srcPos++]) != 2)
444.1040 -      curByte -= 32;
444.1041 -    data[destPos++] = curByte;
444.1042 -  }
444.1043 -  return destPos - dataSize;
444.1044 -}
444.1045 -
444.1046 -void CVm::ExecuteStandardFilter(int filterIndex)
444.1047 -{
444.1048 -  UInt32 dataSize = R[4];
444.1049 -  if (dataSize >= kGlobalOffset)
444.1050 -    return;
444.1051 -  EStandardFilter filterType = kStdFilters[filterIndex].Type;
444.1052 -
444.1053 -  switch (filterType)
444.1054 -  {
444.1055 -    case SF_E8:
444.1056 -    case SF_E8E9:
444.1057 -      E8E9Decode(Mem, dataSize, R[6], (filterType == SF_E8E9));
444.1058 -      break;
444.1059 -    case SF_ITANIUM:
444.1060 -      ItaniumDecode(Mem, dataSize, R[6]);
444.1061 -      break;
444.1062 -    case SF_DELTA:
444.1063 -      if (dataSize >= kGlobalOffset / 2)
444.1064 -        break;
444.1065 -      SetBlockPos(dataSize);
444.1066 -      DeltaDecode(Mem, dataSize, R[0]);
444.1067 -      break;
444.1068 -    case SF_RGB:
444.1069 -      if (dataSize >= kGlobalOffset / 2)
444.1070 -        break;
444.1071 -      {
444.1072 -        UInt32 width = R[0];
444.1073 -        if (width <= 3)
444.1074 -          break;
444.1075 -        SetBlockPos(dataSize);
444.1076 -        RgbDecode(Mem, dataSize, width, R[1]);
444.1077 -      }
444.1078 -      break;
444.1079 -    case SF_AUDIO:
444.1080 -      if (dataSize >= kGlobalOffset / 2)
444.1081 -        break;
444.1082 -      SetBlockPos(dataSize);
444.1083 -      AudioDecode(Mem, dataSize, R[0]);
444.1084 -      break;
444.1085 -    case SF_UPCASE:
444.1086 -      if (dataSize >= kGlobalOffset / 2)
444.1087 -        break;
444.1088 -      UInt32 destSize = UpCaseDecode(Mem, dataSize);
444.1089 -      SetBlockSize(destSize);
444.1090 -      SetBlockPos(dataSize);
444.1091 -      break;
444.1092 -  }
444.1093 -}
444.1094 -
444.1095 -#endif
444.1096 -
444.1097 -}}}
   445.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/Rar3Vm.h	Sat Mar 03 10:54:39 2012 -0600
   445.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   445.3 @@ -1,179 +0,0 @@
   445.4 -// Rar3Vm.h
   445.5 -// According to unRAR license, this code may not be used to develop
   445.6 -// a program that creates RAR archives
   445.7 -
   445.8 -#ifndef __COMPRESS_RAR3_VM_H
   445.9 -#define __COMPRESS_RAR3_VM_H
  445.10 -
  445.11 -#include "../../../C/CpuArch.h"
  445.12 -
  445.13 -#include "Common/MyVector.h"
  445.14 -#include "Common/Types.h"
  445.15 -
  445.16 -#define RARVM_STANDARD_FILTERS
  445.17 -
  445.18 -namespace NCompress {
  445.19 -namespace NRar3 {
  445.20 -
  445.21 -class CMemBitDecoder
  445.22 -{
  445.23 -  const Byte *_data;
  445.24 -  UInt32 _bitSize;
  445.25 -  UInt32 _bitPos;
  445.26 -public:
  445.27 -  void Init(const Byte *data, UInt32 byteSize)
  445.28 -  {
  445.29 -    _data = data;
  445.30 -    _bitSize = (byteSize << 3);
  445.31 -    _bitPos = 0;
  445.32 -  }
  445.33 -  UInt32 ReadBits(int numBits);
  445.34 -  UInt32 ReadBit();
  445.35 -  bool Avail() const { return (_bitPos < _bitSize); }
  445.36 -};
  445.37 -
  445.38 -namespace NVm {
  445.39 -
  445.40 -inline UInt32 GetValue32(const void *addr) { return GetUi32(addr); }
  445.41 -inline void SetValue32(void *addr, UInt32 value) { SetUi32(addr, value); }
  445.42 -
  445.43 -UInt32 ReadEncodedUInt32(CMemBitDecoder &inp);
  445.44 -
  445.45 -const int kNumRegBits = 3;
  445.46 -const UInt32 kNumRegs = 1 << kNumRegBits;
  445.47 -const UInt32 kNumGpRegs = kNumRegs - 1;
  445.48 -
  445.49 -const UInt32 kSpaceSize = 0x40000;
  445.50 -const UInt32 kSpaceMask = kSpaceSize -1;
  445.51 -const UInt32 kGlobalOffset = 0x3C000;
  445.52 -const UInt32 kGlobalSize = 0x2000;
  445.53 -const UInt32 kFixedGlobalSize = 64;
  445.54 -
  445.55 -namespace NGlobalOffset
  445.56 -{
  445.57 -  const UInt32 kBlockSize = 0x1C;
  445.58 -  const UInt32 kBlockPos  = 0x20;
  445.59 -  const UInt32 kExecCount = 0x2C;
  445.60 -  const UInt32 kGlobalMemOutSize = 0x30;
  445.61 -}
  445.62 -
  445.63 -enum ECommand
  445.64 -{
  445.65 -  CMD_MOV,  CMD_CMP,  CMD_ADD,  CMD_SUB,  CMD_JZ,   CMD_JNZ,  CMD_INC,  CMD_DEC,
  445.66 -  CMD_JMP,  CMD_XOR,  CMD_AND,  CMD_OR,   CMD_TEST, CMD_JS,   CMD_JNS,  CMD_JB,
  445.67 -  CMD_JBE,  CMD_JA,   CMD_JAE,  CMD_PUSH, CMD_POP,  CMD_CALL, CMD_RET,  CMD_NOT,
  445.68 -  CMD_SHL,  CMD_SHR,  CMD_SAR,  CMD_NEG,  CMD_PUSHA,CMD_POPA, CMD_PUSHF,CMD_POPF,
  445.69 -  CMD_MOVZX,CMD_MOVSX,CMD_XCHG, CMD_MUL,  CMD_DIV,  CMD_ADC,  CMD_SBB,  CMD_PRINT,
  445.70 -
  445.71 -  CMD_MOVB, CMD_CMPB, CMD_ADDB, CMD_SUBB, CMD_INCB, CMD_DECB,
  445.72 -  CMD_XORB, CMD_ANDB, CMD_ORB,  CMD_TESTB,CMD_NEGB,
  445.73 -  CMD_SHLB, CMD_SHRB, CMD_SARB, CMD_MULB
  445.74 -};
  445.75 -
  445.76 -enum EOpType {OP_TYPE_REG, OP_TYPE_INT, OP_TYPE_REGMEM, OP_TYPE_NONE};
  445.77 -
  445.78 -// Addr in COperand object can link (point) to CVm object!!!
  445.79 -
  445.80 -struct COperand
  445.81 -{
  445.82 -  EOpType Type;
  445.83 -  UInt32 Data;
  445.84 -  UInt32 Base;
  445.85 -  COperand(): Type(OP_TYPE_NONE), Data(0), Base(0) {}
  445.86 -};
  445.87 -
  445.88 -struct CCommand
  445.89 -{
  445.90 -  ECommand OpCode;
  445.91 -  bool ByteMode;
  445.92 -  COperand Op1, Op2;
  445.93 -};
  445.94 -
  445.95 -struct CBlockRef
  445.96 -{
  445.97 -  UInt32 Offset;
  445.98 -  UInt32 Size;
  445.99 -};
 445.100 -
 445.101 -struct CProgram
 445.102 -{
 445.103 -  CRecordVector<CCommand> Commands;
 445.104 -  #ifdef RARVM_STANDARD_FILTERS
 445.105 -  int StandardFilterIndex;
 445.106 -  #endif
 445.107 -  CRecordVector<Byte> StaticData;
 445.108 -};
 445.109 -
 445.110 -struct CProgramInitState
 445.111 -{
 445.112 -  UInt32 InitR[kNumGpRegs];
 445.113 -  CRecordVector<Byte> GlobalData;
 445.114 -
 445.115 -  void AllocateEmptyFixedGlobal()
 445.116 -  {
 445.117 -    GlobalData.Clear();
 445.118 -    GlobalData.Reserve(NVm::kFixedGlobalSize);
 445.119 -    for (UInt32 i = 0; i < NVm::kFixedGlobalSize; i++)
 445.120 -      GlobalData.Add(0);
 445.121 -  }
 445.122 -};
 445.123 -
 445.124 -class CVm
 445.125 -{
 445.126 -  static UInt32 GetValue(bool byteMode, const void *addr)
 445.127 -  {
 445.128 -    if (byteMode)
 445.129 -      return(*(const Byte *)addr);
 445.130 -    else
 445.131 -      return GetUi32(addr);
 445.132 -  }
 445.133 -
 445.134 -  static void SetValue(bool byteMode, void *addr, UInt32 value)
 445.135 -  {
 445.136 -    if (byteMode)
 445.137 -      *(Byte *)addr = (Byte)value;
 445.138 -    else
 445.139 -      SetUi32(addr, value);
 445.140 -  }
 445.141 -
 445.142 -  UInt32 GetFixedGlobalValue32(UInt32 globalOffset) { return GetValue(false, &Mem[kGlobalOffset + globalOffset]); }
 445.143 -
 445.144 -  void SetBlockSize(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockSize], v); }
 445.145 -  void SetBlockPos(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockPos], v); }
 445.146 -public:
 445.147 -  static void SetValue(void *addr, UInt32 value) { SetValue(false, addr, value); }
 445.148 -private:
 445.149 -  UInt32 GetOperand32(const COperand *op) const;
 445.150 -  void SetOperand32(const COperand *op, UInt32 val);
 445.151 -  Byte GetOperand8(const COperand *op) const;
 445.152 -  void SetOperand8(const COperand *op, Byte val);
 445.153 -  UInt32 GetOperand(bool byteMode, const COperand *op) const;
 445.154 -  void SetOperand(bool byteMode, const COperand *op, UInt32 val);
 445.155 -
 445.156 -  void DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode);
 445.157 -  
 445.158 -  bool ExecuteCode(const CProgram *prg);
 445.159 -  
 445.160 -  #ifdef RARVM_STANDARD_FILTERS
 445.161 -  void ExecuteStandardFilter(int filterIndex);
 445.162 -  #endif
 445.163 -  
 445.164 -  Byte *Mem;
 445.165 -  UInt32 R[kNumRegs + 1]; // R[kNumRegs] = 0 always (speed optimization)
 445.166 -  UInt32 Flags;
 445.167 -  void ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
 445.168 -public:
 445.169 -  CVm();
 445.170 -  ~CVm();
 445.171 -  bool Create();
 445.172 -  void PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
 445.173 -  void SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize);
 445.174 -  bool Execute(CProgram *prg, const CProgramInitState *initState,
 445.175 -      CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData);
 445.176 -  const Byte *GetDataPointer(UInt32 offset) const { return Mem + offset; }
 445.177 -
 445.178 -};
 445.179 -
 445.180 -#endif
 445.181 -
 445.182 -}}}
   446.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/RarCodecsRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   446.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   446.3 @@ -1,26 +0,0 @@
   446.4 -// RarCodecsRegister.cpp
   446.5 -
   446.6 -#include "StdAfx.h"
   446.7 -
   446.8 -#include "../Common/RegisterCodec.h"
   446.9 -
  446.10 -#include "Rar1Decoder.h"
  446.11 -#include "Rar2Decoder.h"
  446.12 -#include "Rar3Decoder.h"
  446.13 -
  446.14 -#define CREATE_CODEC(x) static void *CreateCodec ## x() { return (void *)(ICompressCoder *)(new NCompress::NRar ## x::CDecoder); }
  446.15 -
  446.16 -CREATE_CODEC(1)
  446.17 -CREATE_CODEC(2)
  446.18 -CREATE_CODEC(3)
  446.19 -
  446.20 -#define RAR_CODEC(x, name) { CreateCodec ## x, 0, 0x040300 + x, L"Rar" name, 1, false }
  446.21 -
  446.22 -static CCodecInfo g_CodecsInfo[] =
  446.23 -{
  446.24 -  RAR_CODEC(1, L"1"),
  446.25 -  RAR_CODEC(2, L"2"),
  446.26 -  RAR_CODEC(3, L"3"),
  446.27 -};
  446.28 -
  446.29 -REGISTER_CODECS(Rar)
   447.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ShrinkDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   447.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   447.3 @@ -1,148 +0,0 @@
   447.4 -// ShrinkDecoder.cpp
   447.5 -
   447.6 -#include "StdAfx.h"
   447.7 -
   447.8 -extern "C"
   447.9 -{
  447.10 -#include "../../../C/Alloc.h"
  447.11 -}
  447.12 -
  447.13 -#include "../Common/InBuffer.h"
  447.14 -#include "../Common/OutBuffer.h"
  447.15 -
  447.16 -#include "BitlDecoder.h"
  447.17 -#include "ShrinkDecoder.h"
  447.18 -
  447.19 -namespace NCompress {
  447.20 -namespace NShrink {
  447.21 -
  447.22 -static const UInt32 kBufferSize = (1 << 20);
  447.23 -static const int kNumMinBits = 9;
  447.24 -
  447.25 -HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  447.26 -    const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
  447.27 -{
  447.28 -  NBitl::CBaseDecoder<CInBuffer> inBuffer;
  447.29 -  COutBuffer outBuffer;
  447.30 -
  447.31 -  if (!inBuffer.Create(kBufferSize))
  447.32 -    return E_OUTOFMEMORY;
  447.33 -  inBuffer.SetStream(inStream);
  447.34 -  inBuffer.Init();
  447.35 -
  447.36 -  if (!outBuffer.Create(kBufferSize))
  447.37 -    return E_OUTOFMEMORY;
  447.38 -  outBuffer.SetStream(outStream);
  447.39 -  outBuffer.Init();
  447.40 -
  447.41 -  UInt64 prevPos = 0;
  447.42 -  int numBits = kNumMinBits;
  447.43 -  UInt32 head = 257;
  447.44 -  bool needPrev = false;
  447.45 -  UInt32 lastSymbol = 0;
  447.46 -
  447.47 -  int i;
  447.48 -  for (i = 0; i < kNumItems; i++)
  447.49 -    _parents[i] = 0;
  447.50 -  for (i = 0; i < kNumItems; i++)
  447.51 -    _suffixes[i] = 0;
  447.52 -  for (i = 0; i < 257; i++)
  447.53 -    _isFree[i] = false;
  447.54 -  for (; i < kNumItems; i++)
  447.55 -    _isFree[i] = true;
  447.56 -
  447.57 -  for (;;)
  447.58 -  {
  447.59 -    UInt32 symbol = inBuffer.ReadBits(numBits);
  447.60 -    if (inBuffer.ExtraBitsWereRead())
  447.61 -      break;
  447.62 -    if (_isFree[symbol])
  447.63 -      return S_FALSE;
  447.64 -    if (symbol == 256)
  447.65 -    {
  447.66 -      UInt32 symbol = inBuffer.ReadBits(numBits);
  447.67 -      if (symbol == 1)
  447.68 -      {
  447.69 -        if (numBits < kNumMaxBits)
  447.70 -          numBits++;
  447.71 -      }
  447.72 -      else if (symbol == 2)
  447.73 -      {
  447.74 -        if (needPrev)
  447.75 -          _isFree[head - 1] = true;
  447.76 -        for (i = 257; i < kNumItems; i++)
  447.77 -          _isParent[i] = false;
  447.78 -        for (i = 257; i < kNumItems; i++)
  447.79 -          if (!_isFree[i])
  447.80 -            _isParent[_parents[i]] = true;
  447.81 -        for (i = 257; i < kNumItems; i++)
  447.82 -          if (!_isParent[i])
  447.83 -            _isFree[i] = true;
  447.84 -        head = 257;
  447.85 -        while (head < kNumItems && !_isFree[head])
  447.86 -          head++;
  447.87 -        if (head < kNumItems)
  447.88 -        {
  447.89 -          needPrev = true;
  447.90 -          _isFree[head] = false;
  447.91 -          _parents[head] = (UInt16)lastSymbol;
  447.92 -          head++;
  447.93 -        }
  447.94 -      }
  447.95 -      else
  447.96 -        return S_FALSE;
  447.97 -      continue;
  447.98 -    }
  447.99 -    UInt32 cur = symbol;
 447.100 -    i = 0;
 447.101 -    int corectionIndex = -1;
 447.102 -    while (cur >= 256)
 447.103 -    {
 447.104 -      if (cur == head - 1)
 447.105 -        corectionIndex = i;
 447.106 -      _stack[i++] = _suffixes[cur];
 447.107 -      cur = _parents[cur];
 447.108 -    }
 447.109 -    _stack[i++] = (Byte)cur;
 447.110 -    if (needPrev)
 447.111 -    {
 447.112 -      _suffixes[head - 1] = (Byte)cur;
 447.113 -      if (corectionIndex >= 0)
 447.114 -        _stack[corectionIndex] = (Byte)cur;
 447.115 -    }
 447.116 -    while (i > 0)
 447.117 -      outBuffer.WriteByte((_stack[--i]));
 447.118 -    while (head < kNumItems && !_isFree[head])
 447.119 -      head++;
 447.120 -    if (head < kNumItems)
 447.121 -    {
 447.122 -      needPrev = true;
 447.123 -      _isFree[head] = false;
 447.124 -      _parents[head] = (UInt16)symbol;
 447.125 -      head++;
 447.126 -    }
 447.127 -    else
 447.128 -      needPrev = false;
 447.129 -    lastSymbol = symbol;
 447.130 -
 447.131 -    UInt64 nowPos = outBuffer.GetProcessedSize();
 447.132 -    if (progress != NULL && nowPos - prevPos > (1 << 18))
 447.133 -    {
 447.134 -      prevPos = nowPos;
 447.135 -      UInt64 packSize = inBuffer.GetProcessedSize();
 447.136 -      RINOK(progress->SetRatioInfo(&packSize, &nowPos));
 447.137 -    }
 447.138 -  }
 447.139 -  return outBuffer.Flush();
 447.140 -}
 447.141 -
 447.142 -STDMETHODIMP CDecoder ::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
 447.143 -    const UInt64 *inSize, const UInt64 *outSize,    ICompressProgressInfo *progress)
 447.144 -{
 447.145 -  try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
 447.146 -  catch(const CInBufferException &e) { return e.ErrorCode; }
 447.147 -  catch(const COutBufferException &e) { return e.ErrorCode; }
 447.148 -  catch(...) { return S_FALSE; }
 447.149 -}
 447.150 -
 447.151 -}}
   448.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ShrinkDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   448.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   448.3 @@ -1,38 +0,0 @@
   448.4 -// ShrinkDecoder.h
   448.5 -
   448.6 -#ifndef __COMPRESS_SHRINK_DECODER_H
   448.7 -#define __COMPRESS_SHRINK_DECODER_H
   448.8 -
   448.9 -#include "../../Common/MyCom.h"
  448.10 -
  448.11 -#include "../ICoder.h"
  448.12 -
  448.13 -namespace NCompress {
  448.14 -namespace NShrink {
  448.15 -
  448.16 -const int kNumMaxBits = 13;
  448.17 -const UInt32 kNumItems = 1 << kNumMaxBits;
  448.18 -
  448.19 -class CDecoder :
  448.20 -  public ICompressCoder,
  448.21 -  public CMyUnknownImp
  448.22 -{
  448.23 -  UInt16 _parents[kNumItems];
  448.24 -  Byte _suffixes[kNumItems];
  448.25 -  Byte _stack[kNumItems];
  448.26 -  bool _isFree[kNumItems];
  448.27 -  bool _isParent[kNumItems];
  448.28 -
  448.29 -public:
  448.30 -  MY_UNKNOWN_IMP
  448.31 -
  448.32 -  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  448.33 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  448.34 -  
  448.35 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  448.36 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  448.37 -};
  448.38 -
  448.39 -}}
  448.40 -
  448.41 -#endif
   449.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   449.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   449.3 @@ -1,8 +0,0 @@
   449.4 -// StdAfx.h
   449.5 -
   449.6 -#ifndef __STDAFX_H
   449.7 -#define __STDAFX_H
   449.8 -
   449.9 -#include "../../Common/MyWindows.h"
  449.10 -
  449.11 -#endif
   450.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ZlibDecoder.cpp	Sat Mar 03 10:54:39 2012 -0600
   450.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   450.3 @@ -1,94 +0,0 @@
   450.4 -// ZlibDecoder.cpp
   450.5 -
   450.6 -#include "StdAfx.h"
   450.7 -
   450.8 -#include "../Common/StreamUtils.h"
   450.9 -
  450.10 -#include "DeflateDecoder.h"
  450.11 -#include "ZlibDecoder.h"
  450.12 -
  450.13 -namespace NCompress {
  450.14 -namespace NZlib {
  450.15 -
  450.16 -#define DEFLATE_TRY_BEGIN try {
  450.17 -#define DEFLATE_TRY_END } \
  450.18 -  catch(...) { return S_FALSE; }
  450.19 -
  450.20 -#define ADLER_MOD 65521
  450.21 -#define ADLER_LOOP_MAX 5550
  450.22 -
  450.23 -static UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size)
  450.24 -{
  450.25 -  UInt32 a = adler & 0xFFFF;
  450.26 -  UInt32 b = (adler >> 16) & 0xFFFF;
  450.27 -  while (size > 0)
  450.28 -  {
  450.29 -    unsigned curSize = (size > ADLER_LOOP_MAX) ? ADLER_LOOP_MAX : (unsigned )size;
  450.30 -    unsigned i;
  450.31 -    for (i = 0; i < curSize; i++)
  450.32 -    {
  450.33 -      a += buf[i];
  450.34 -      b += a;
  450.35 -    }
  450.36 -    buf += curSize;
  450.37 -    size -= curSize;
  450.38 -    a %= ADLER_MOD;
  450.39 -    b %= ADLER_MOD;
  450.40 -  }
  450.41 -  return (b << 16) + a;
  450.42 -}
  450.43 -
  450.44 -STDMETHODIMP COutStreamWithAdler::Write(const void *data, UInt32 size, UInt32 *processedSize)
  450.45 -{
  450.46 -  HRESULT result = _stream->Write(data, size, &size);
  450.47 -  _adler = Adler32_Update(_adler, (const Byte *)data, size);
  450.48 -  if (processedSize != NULL)
  450.49 -    *processedSize = size;
  450.50 -  return result;
  450.51 -}
  450.52 -
  450.53 -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  450.54 -    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
  450.55 -{
  450.56 -  DEFLATE_TRY_BEGIN
  450.57 -  if (!AdlerStream)
  450.58 -  {
  450.59 -    AdlerSpec = new COutStreamWithAdler;
  450.60 -    AdlerStream = AdlerSpec;
  450.61 -  }
  450.62 -  if (!DeflateDecoder)
  450.63 -  {
  450.64 -    DeflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
  450.65 -    DeflateDecoderSpec->ZlibMode = true;
  450.66 -    DeflateDecoder = DeflateDecoderSpec;
  450.67 -  }
  450.68 -
  450.69 -  Byte buf[2];
  450.70 -  RINOK(ReadStream_FALSE(inStream, buf, 2));
  450.71 -  int method = buf[0] & 0xF;
  450.72 -  if (method != 8)
  450.73 -    return S_FALSE;
  450.74 -  // int dicSize = buf[0] >> 4;
  450.75 -  if ((((UInt32)buf[0] << 8) + buf[1]) % 31 != 0)
  450.76 -    return S_FALSE;
  450.77 -  if ((buf[1] & 0x20) != 0) // dictPresent
  450.78 -    return S_FALSE;
  450.79 -  // int level = (buf[1] >> 6);
  450.80 -
  450.81 -  AdlerSpec->SetStream(outStream);
  450.82 -  AdlerSpec->Init();
  450.83 -  HRESULT res = DeflateDecoder->Code(inStream, AdlerStream, inSize, outSize, progress);
  450.84 -  AdlerSpec->ReleaseStream();
  450.85 -
  450.86 -  if (res == S_OK)
  450.87 -  {
  450.88 -    const Byte *p = DeflateDecoderSpec->ZlibFooter;
  450.89 -    UInt32 adler = ((UInt32)p[0] << 24) | ((UInt32)p[1] << 16) | ((UInt32)p[2] << 8) | p[3];
  450.90 -    if (adler != AdlerSpec->GetAdler())
  450.91 -      return S_FALSE;
  450.92 -  }
  450.93 -  return res;
  450.94 -  DEFLATE_TRY_END
  450.95 -}
  450.96 -
  450.97 -}}
   451.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/ZlibDecoder.h	Sat Mar 03 10:54:39 2012 -0600
   451.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   451.3 @@ -1,46 +0,0 @@
   451.4 -// ZlibDecoder.h
   451.5 -
   451.6 -#ifndef __ZLIB_DECODER_H
   451.7 -#define __ZLIB_DECODER_H
   451.8 -
   451.9 -#include "DeflateDecoder.h"
  451.10 -
  451.11 -namespace NCompress {
  451.12 -namespace NZlib {
  451.13 -
  451.14 -const UInt32 ADLER_INIT_VAL = 1;
  451.15 -
  451.16 -class COutStreamWithAdler:
  451.17 -  public ISequentialOutStream,
  451.18 -  public CMyUnknownImp
  451.19 -{
  451.20 -  CMyComPtr<ISequentialOutStream> _stream;
  451.21 -  UInt32 _adler;
  451.22 -public:
  451.23 -  MY_UNKNOWN_IMP
  451.24 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  451.25 -  void SetStream(ISequentialOutStream *stream) { _stream = stream; }
  451.26 -  void ReleaseStream() { _stream.Release(); }
  451.27 -  void Init() { _adler = ADLER_INIT_VAL; }
  451.28 -  UInt32 GetAdler() const { return _adler; }
  451.29 -};
  451.30 -
  451.31 -class CDecoder:
  451.32 -  public ICompressCoder,
  451.33 -  public CMyUnknownImp
  451.34 -{
  451.35 -  COutStreamWithAdler *AdlerSpec;
  451.36 -  CMyComPtr<ISequentialOutStream> AdlerStream;
  451.37 -  
  451.38 -  NCompress::NDeflate::NDecoder::CCOMCoder *DeflateDecoderSpec;
  451.39 -  CMyComPtr<ICompressCoder> DeflateDecoder;
  451.40 -public:
  451.41 -  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
  451.42 -      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
  451.43 -
  451.44 -  MY_UNKNOWN_IMP
  451.45 -};
  451.46 -
  451.47 -}}
  451.48 -
  451.49 -#endif
   452.1 --- a/src/win32/7zip/7z/CPP/7zip/Compress/makefile	Sat Mar 03 10:54:39 2012 -0600
   452.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   452.3 @@ -1,14 +0,0 @@
   452.4 -DIRS = \
   452.5 -  Branch\~ \
   452.6 -  ByteSwap\~ \
   452.7 -  BZip2\~ \
   452.8 -  Copy\~ \
   452.9 -  Deflate\~ \
  452.10 -  LZMA\~ \
  452.11 -  PPMD\~ \
  452.12 -  Rar\~ \
  452.13 -  
  452.14 -all: $(DIRS)
  452.15 -
  452.16 -$(DIRS):
  452.17 -!include "../SubBuild.mak"
   453.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/7zAes.cpp	Sat Mar 03 10:54:39 2012 -0600
   453.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   453.3 @@ -1,245 +0,0 @@
   453.4 -// 7zAes.cpp
   453.5 -
   453.6 -#include "StdAfx.h"
   453.7 -
   453.8 -extern "C"
   453.9 -{
  453.10 -#include "../../../C/Sha256.h"
  453.11 -}
  453.12 -
  453.13 -#include "Windows/Synchronization.h"
  453.14 -#include "../Common/StreamObjects.h"
  453.15 -#include "../Common/StreamUtils.h"
  453.16 -#include "7zAes.h"
  453.17 -#include "MyAes.h"
  453.18 -
  453.19 -#ifndef EXTRACT_ONLY
  453.20 -#include "RandGen.h"
  453.21 -#endif
  453.22 -
  453.23 -using namespace NWindows;
  453.24 -
  453.25 -namespace NCrypto {
  453.26 -namespace NSevenZ {
  453.27 -
  453.28 -bool CKeyInfo::IsEqualTo(const CKeyInfo &a) const
  453.29 -{
  453.30 -  if (SaltSize != a.SaltSize || NumCyclesPower != a.NumCyclesPower)
  453.31 -    return false;
  453.32 -  for (UInt32 i = 0; i < SaltSize; i++)
  453.33 -    if (Salt[i] != a.Salt[i])
  453.34 -      return false;
  453.35 -  return (Password == a.Password);
  453.36 -}
  453.37 -
  453.38 -void CKeyInfo::CalculateDigest()
  453.39 -{
  453.40 -  if (NumCyclesPower == 0x3F)
  453.41 -  {
  453.42 -    UInt32 pos;
  453.43 -    for (pos = 0; pos < SaltSize; pos++)
  453.44 -      Key[pos] = Salt[pos];
  453.45 -    for (UInt32 i = 0; i < Password.GetCapacity() && pos < kKeySize; i++)
  453.46 -      Key[pos++] = Password[i];
  453.47 -    for (; pos < kKeySize; pos++)
  453.48 -      Key[pos] = 0;
  453.49 -  }
  453.50 -  else
  453.51 -  {
  453.52 -    CSha256 sha;
  453.53 -    Sha256_Init(&sha);
  453.54 -    const UInt64 numRounds = UInt64(1) << (NumCyclesPower);
  453.55 -    Byte temp[8] = { 0,0,0,0,0,0,0,0 };
  453.56 -    for (UInt64 round = 0; round < numRounds; round++)
  453.57 -    {
  453.58 -      Sha256_Update(&sha, Salt, (size_t)SaltSize);
  453.59 -      Sha256_Update(&sha, Password, Password.GetCapacity());
  453.60 -      Sha256_Update(&sha, temp, 8);
  453.61 -      for (int i = 0; i < 8; i++)
  453.62 -        if (++(temp[i]) != 0)
  453.63 -          break;
  453.64 -    }
  453.65 -    Sha256_Final(&sha, Key);
  453.66 -  }
  453.67 -}
  453.68 -
  453.69 -bool CKeyInfoCache::Find(CKeyInfo &key)
  453.70 -{
  453.71 -  for (int i = 0; i < Keys.Size(); i++)
  453.72 -  {
  453.73 -    const CKeyInfo &cached = Keys[i];
  453.74 -    if (key.IsEqualTo(cached))
  453.75 -    {
  453.76 -      for (int j = 0; j < kKeySize; j++)
  453.77 -        key.Key[j] = cached.Key[j];
  453.78 -      if (i != 0)
  453.79 -      {
  453.80 -        Keys.Insert(0, cached);
  453.81 -        Keys.Delete(i+1);
  453.82 -      }
  453.83 -      return true;
  453.84 -    }
  453.85 -  }
  453.86 -  return false;
  453.87 -}
  453.88 -
  453.89 -void CKeyInfoCache::Add(CKeyInfo &key)
  453.90 -{
  453.91 -  if (Find(key))
  453.92 -    return;
  453.93 -  if (Keys.Size() >= Size)
  453.94 -    Keys.DeleteBack();
  453.95 -  Keys.Insert(0, key);
  453.96 -}
  453.97 -
  453.98 -static CKeyInfoCache g_GlobalKeyCache(32);
  453.99 -static NSynchronization::CCriticalSection g_GlobalKeyCacheCriticalSection;
 453.100 -
 453.101 -CBase::CBase():
 453.102 -  _cachedKeys(16),
 453.103 -  _ivSize(0)
 453.104 -{
 453.105 -  for (int i = 0; i < sizeof(_iv); i++)
 453.106 -    _iv[i] = 0;
 453.107 -}
 453.108 -
 453.109 -void CBase::CalculateDigest()
 453.110 -{
 453.111 -  NSynchronization::CCriticalSectionLock lock(g_GlobalKeyCacheCriticalSection);
 453.112 -  if (_cachedKeys.Find(_key))
 453.113 -    g_GlobalKeyCache.Add(_key);
 453.114 -  else
 453.115 -  {
 453.116 -    if (!g_GlobalKeyCache.Find(_key))
 453.117 -    {
 453.118 -      _key.CalculateDigest();
 453.119 -      g_GlobalKeyCache.Add(_key);
 453.120 -    }
 453.121 -    _cachedKeys.Add(_key);
 453.122 -  }
 453.123 -}
 453.124 -
 453.125 -#ifndef EXTRACT_ONLY
 453.126 -
 453.127 -/*
 453.128 -STDMETHODIMP CEncoder::ResetSalt()
 453.129 -{
 453.130 -  _key.SaltSize = 4;
 453.131 -  g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
 453.132 -  return S_OK;
 453.133 -}
 453.134 -*/
 453.135 -
 453.136 -STDMETHODIMP CEncoder::ResetInitVector()
 453.137 -{
 453.138 -  _ivSize = 8;
 453.139 -  g_RandomGenerator.Generate(_iv, (unsigned)_ivSize);
 453.140 -  return S_OK;
 453.141 -}
 453.142 -
 453.143 -STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
 453.144 -{
 453.145 -   // _key.Init();
 453.146 -   for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
 453.147 -    _iv[i] = 0;
 453.148 -
 453.149 -  UInt32 ivSize = _ivSize;
 453.150 -  
 453.151 -  // _key.NumCyclesPower = 0x3F;
 453.152 -  _key.NumCyclesPower = 19;
 453.153 -
 453.154 -  Byte firstByte = (Byte)(_key.NumCyclesPower |
 453.155 -    (((_key.SaltSize == 0) ? 0 : 1) << 7) |
 453.156 -    (((ivSize == 0) ? 0 : 1) << 6));
 453.157 -  RINOK(outStream->Write(&firstByte, 1, NULL));
 453.158 -  if (_key.SaltSize == 0 && ivSize == 0)
 453.159 -    return S_OK;
 453.160 -  Byte saltSizeSpec = (Byte)((_key.SaltSize == 0) ? 0 : (_key.SaltSize - 1));
 453.161 -  Byte ivSizeSpec = (Byte)((ivSize == 0) ? 0 : (ivSize - 1));
 453.162 -  Byte secondByte = (Byte)(((saltSizeSpec) << 4) | ivSizeSpec);
 453.163 -  RINOK(outStream->Write(&secondByte, 1, NULL));
 453.164 -  if (_key.SaltSize > 0)
 453.165 -  {
 453.166 -    RINOK(WriteStream(outStream, _key.Salt, _key.SaltSize));
 453.167 -  }
 453.168 -  if (ivSize > 0)
 453.169 -  {
 453.170 -    RINOK(WriteStream(outStream, _iv, ivSize));
 453.171 -  }
 453.172 -  return S_OK;
 453.173 -}
 453.174 -
 453.175 -HRESULT CEncoder::CreateFilter()
 453.176 -{
 453.177 -  _aesFilter = new CAesCbcEncoder;
 453.178 -  return S_OK;
 453.179 -}
 453.180 -
 453.181 -#endif
 453.182 -
 453.183 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 453.184 -{
 453.185 -  _key.Init();
 453.186 -  UInt32 i;
 453.187 -  for (i = 0; i < sizeof(_iv); i++)
 453.188 -    _iv[i] = 0;
 453.189 -  if (size == 0)
 453.190 -    return S_OK;
 453.191 -  UInt32 pos = 0;
 453.192 -  Byte firstByte = data[pos++];
 453.193 -
 453.194 -  _key.NumCyclesPower = firstByte & 0x3F;
 453.195 -  if ((firstByte & 0xC0) == 0)
 453.196 -    return S_OK;
 453.197 -  _key.SaltSize = (firstByte >> 7) & 1;
 453.198 -  UInt32 ivSize = (firstByte >> 6) & 1;
 453.199 -
 453.200 -  if (pos >= size)
 453.201 -    return E_INVALIDARG;
 453.202 -  Byte secondByte = data[pos++];
 453.203 -  
 453.204 -  _key.SaltSize += (secondByte >> 4);
 453.205 -  ivSize += (secondByte & 0x0F);
 453.206 -  
 453.207 -  if (pos + _key.SaltSize + ivSize > size)
 453.208 -    return E_INVALIDARG;
 453.209 -  for (i = 0; i < _key.SaltSize; i++)
 453.210 -    _key.Salt[i] = data[pos++];
 453.211 -  for (i = 0; i < ivSize; i++)
 453.212 -    _iv[i] = data[pos++];
 453.213 -  return S_OK;
 453.214 -}
 453.215 -
 453.216 -STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
 453.217 -{
 453.218 -  _key.Password.SetCapacity((size_t)size);
 453.219 -  memcpy(_key.Password, data, (size_t)size);
 453.220 -  return S_OK;
 453.221 -}
 453.222 -
 453.223 -STDMETHODIMP CBaseCoder::Init()
 453.224 -{
 453.225 -  CalculateDigest();
 453.226 -  if (_aesFilter == 0)
 453.227 -  {
 453.228 -    RINOK(CreateFilter());
 453.229 -  }
 453.230 -  CMyComPtr<ICryptoProperties> cp;
 453.231 -  RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
 453.232 -  RINOK(cp->SetKey(_key.Key, sizeof(_key.Key)));
 453.233 -  RINOK(cp->SetInitVector(_iv, sizeof(_iv)));
 453.234 -  return S_OK;
 453.235 -}
 453.236 -
 453.237 -STDMETHODIMP_(UInt32) CBaseCoder::Filter(Byte *data, UInt32 size)
 453.238 -{
 453.239 -  return _aesFilter->Filter(data, size);
 453.240 -}
 453.241 -
 453.242 -HRESULT CDecoder::CreateFilter()
 453.243 -{
 453.244 -  _aesFilter = new CAesCbcDecoder;
 453.245 -  return S_OK;
 453.246 -}
 453.247 -
 453.248 -}}
   454.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/7zAes.h	Sat Mar 03 10:54:39 2012 -0600
   454.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   454.3 @@ -1,117 +0,0 @@
   454.4 -// 7zAes.h
   454.5 -
   454.6 -#ifndef __CRYPTO_7Z_AES_H
   454.7 -#define __CRYPTO_7Z_AES_H
   454.8 -
   454.9 -#include "Common/Buffer.h"
  454.10 -#include "Common/MyCom.h"
  454.11 -#include "Common/MyVector.h"
  454.12 -
  454.13 -#include "../ICoder.h"
  454.14 -#include "../IPassword.h"
  454.15 -
  454.16 -namespace NCrypto {
  454.17 -namespace NSevenZ {
  454.18 -
  454.19 -const int kKeySize = 32;
  454.20 -
  454.21 -class CKeyInfo
  454.22 -{
  454.23 -public:
  454.24 -  int NumCyclesPower;
  454.25 -  UInt32 SaltSize;
  454.26 -  Byte Salt[16];
  454.27 -  CByteBuffer Password;
  454.28 -  Byte Key[kKeySize];
  454.29 -
  454.30 -  bool IsEqualTo(const CKeyInfo &a) const;
  454.31 -  void CalculateDigest();
  454.32 -
  454.33 -  CKeyInfo() { Init(); }
  454.34 -  void Init()
  454.35 -  {
  454.36 -    NumCyclesPower = 0;
  454.37 -    SaltSize = 0;
  454.38 -    for (int i = 0; i < sizeof(Salt); i++)
  454.39 -      Salt[i] = 0;
  454.40 -  }
  454.41 -};
  454.42 -
  454.43 -class CKeyInfoCache
  454.44 -{
  454.45 -  int Size;
  454.46 -  CObjectVector<CKeyInfo> Keys;
  454.47 -public:
  454.48 -  CKeyInfoCache(int size): Size(size) {}
  454.49 -  bool Find(CKeyInfo &key);
  454.50 -  // HRESULT Calculate(CKeyInfo &key);
  454.51 -  void Add(CKeyInfo &key);
  454.52 -};
  454.53 -
  454.54 -class CBase
  454.55 -{
  454.56 -  CKeyInfoCache _cachedKeys;
  454.57 -protected:
  454.58 -  CKeyInfo _key;
  454.59 -  Byte _iv[16];
  454.60 -  UInt32 _ivSize;
  454.61 -  void CalculateDigest();
  454.62 -  CBase();
  454.63 -};
  454.64 -
  454.65 -class CBaseCoder:
  454.66 -  public ICompressFilter,
  454.67 -  public ICryptoSetPassword,
  454.68 -  public CMyUnknownImp,
  454.69 -  public CBase
  454.70 -{
  454.71 -protected:
  454.72 -  CMyComPtr<ICompressFilter> _aesFilter;
  454.73 -
  454.74 -  virtual HRESULT CreateFilter() = 0;
  454.75 -  #ifndef CRYPTO_AES
  454.76 -  HRESULT CreateFilterFromDLL(REFCLSID clsID);
  454.77 -  #endif
  454.78 -public:
  454.79 -  STDMETHOD(Init)();
  454.80 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  454.81 -  
  454.82 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  454.83 -};
  454.84 -
  454.85 -#ifndef EXTRACT_ONLY
  454.86 -
  454.87 -class CEncoder:
  454.88 -  public CBaseCoder,
  454.89 -  public ICompressWriteCoderProperties,
  454.90 -  // public ICryptoResetSalt,
  454.91 -  public ICryptoResetInitVector
  454.92 -{
  454.93 -  virtual HRESULT CreateFilter();
  454.94 -public:
  454.95 -  MY_UNKNOWN_IMP3(
  454.96 -      ICryptoSetPassword,
  454.97 -      ICompressWriteCoderProperties,
  454.98 -      // ICryptoResetSalt,
  454.99 -      ICryptoResetInitVector)
 454.100 -  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
 454.101 -  // STDMETHOD(ResetSalt)();
 454.102 -  STDMETHOD(ResetInitVector)();
 454.103 -};
 454.104 -#endif
 454.105 -
 454.106 -class CDecoder:
 454.107 -  public CBaseCoder,
 454.108 -  public ICompressSetDecoderProperties2
 454.109 -{
 454.110 -  virtual HRESULT CreateFilter();
 454.111 -public:
 454.112 -  MY_UNKNOWN_IMP2(
 454.113 -      ICryptoSetPassword,
 454.114 -      ICompressSetDecoderProperties2)
 454.115 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
 454.116 -};
 454.117 -
 454.118 -}}
 454.119 -
 454.120 -#endif
   455.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/7zAesRegister.cpp	Sat Mar 03 10:54:39 2012 -0600
   455.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   455.3 @@ -1,18 +0,0 @@
   455.4 -// 7zAesRegister.cpp
   455.5 -
   455.6 -#include "StdAfx.h"
   455.7 -
   455.8 -#include "../Common/RegisterCodec.h"
   455.9 -#include "7zAes.h"
  455.10 -
  455.11 -static void *CreateCodec() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CDecoder()); }
  455.12 -#ifndef EXTRACT_ONLY
  455.13 -static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CEncoder()); }
  455.14 -#else
  455.15 -#define CreateCodecOut 0
  455.16 -#endif
  455.17 -
  455.18 -static CCodecInfo g_CodecInfo =
  455.19 -  { CreateCodec, CreateCodecOut, 0x06F10701, L"7zAES", 1, true };
  455.20 -
  455.21 -REGISTER_CODEC(7zAES)
   456.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/HmacSha1.cpp	Sat Mar 03 10:54:39 2012 -0600
   456.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   456.3 @@ -1,109 +0,0 @@
   456.4 -// HmacSha1.cpp
   456.5 -
   456.6 -#include "StdAfx.h"
   456.7 -
   456.8 -#include "HmacSha1.h"
   456.9 -
  456.10 -namespace NCrypto {
  456.11 -namespace NSha1 {
  456.12 -
  456.13 -void CHmac::SetKey(const Byte *key, size_t keySize)
  456.14 -{
  456.15 -  Byte keyTemp[kBlockSize];
  456.16 -  size_t i;
  456.17 -  for (i = 0; i < kBlockSize; i++)
  456.18 -    keyTemp[i] = 0;
  456.19 -  if(keySize > kBlockSize)
  456.20 -  {
  456.21 -    _sha.Init();
  456.22 -    _sha.Update(key, keySize);
  456.23 -    _sha.Final(keyTemp);
  456.24 -    keySize = kDigestSize;
  456.25 -  }
  456.26 -  else
  456.27 -    for (i = 0; i < keySize; i++)
  456.28 -      keyTemp[i] = key[i];
  456.29 -  for (i = 0; i < kBlockSize; i++)
  456.30 -    keyTemp[i] ^= 0x36;
  456.31 -  _sha.Init();
  456.32 -  _sha.Update(keyTemp, kBlockSize);
  456.33 -  for (i = 0; i < kBlockSize; i++)
  456.34 -    keyTemp[i] ^= 0x36 ^ 0x5C;
  456.35 -  _sha2.Init();
  456.36 -  _sha2.Update(keyTemp, kBlockSize);
  456.37 -}
  456.38 -
  456.39 -void CHmac::Final(Byte *mac, size_t macSize)
  456.40 -{
  456.41 -  Byte digest[kDigestSize];
  456.42 -  _sha.Final(digest);
  456.43 -  _sha2.Update(digest, kDigestSize);
  456.44 -  _sha2.Final(digest);
  456.45 -  for(size_t i = 0; i < macSize; i++)
  456.46 -    mac[i] = digest[i];
  456.47 -}
  456.48 -
  456.49 -
  456.50 -void CHmac32::SetKey(const Byte *key, size_t keySize)
  456.51 -{
  456.52 -  UInt32 keyTemp[kBlockSizeInWords];
  456.53 -  size_t i;
  456.54 -  for (i = 0; i < kBlockSizeInWords; i++)
  456.55 -    keyTemp[i] = 0;
  456.56 -  if(keySize > kBlockSize)
  456.57 -  {
  456.58 -    CContext sha;
  456.59 -    sha.Init();
  456.60 -    sha.Update(key, keySize);
  456.61 -    Byte digest[kDigestSize];
  456.62 -    sha.Final(digest);
  456.63 -    
  456.64 -    for (int i = 0 ; i < kDigestSizeInWords; i++)
  456.65 -      keyTemp[i] =
  456.66 -          ((UInt32)(digest[i * 4 + 0]) << 24) |
  456.67 -          ((UInt32)(digest[i * 4 + 1]) << 16) |
  456.68 -          ((UInt32)(digest[i * 4 + 2]) <<  8) |
  456.69 -          ((UInt32)(digest[i * 4 + 3]));
  456.70 -    keySize = kDigestSizeInWords;
  456.71 -  }
  456.72 -  else
  456.73 -    for (size_t i = 0; i < keySize; i++)
  456.74 -      keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
  456.75 -  for (i = 0; i < kBlockSizeInWords; i++)
  456.76 -    keyTemp[i] ^= 0x36363636;
  456.77 -  _sha.Init();
  456.78 -  _sha.Update(keyTemp, kBlockSizeInWords);
  456.79 -  for (i = 0; i < kBlockSizeInWords; i++)
  456.80 -    keyTemp[i] ^= 0x36363636 ^ 0x5C5C5C5C;
  456.81 -  _sha2.Init();
  456.82 -  _sha2.Update(keyTemp, kBlockSizeInWords);
  456.83 -}
  456.84 -
  456.85 -void CHmac32::Final(UInt32 *mac, size_t macSize)
  456.86 -{
  456.87 -  UInt32 digest[kDigestSizeInWords];
  456.88 -  _sha.Final(digest);
  456.89 -  _sha2.Update(digest, kDigestSizeInWords);
  456.90 -  _sha2.Final(digest);
  456.91 -  for(size_t i = 0; i < macSize; i++)
  456.92 -    mac[i] = digest[i];
  456.93 -}
  456.94 -
  456.95 -void CHmac32::GetLoopXorDigest(UInt32 *mac, UInt32 numIteration)
  456.96 -{
  456.97 -  UInt32 block[kBlockSizeInWords];
  456.98 -  UInt32 block2[kBlockSizeInWords];
  456.99 -  _sha.PrepareBlock(block, kDigestSizeInWords);
 456.100 -  _sha2.PrepareBlock(block2, kDigestSizeInWords);
 456.101 -  for(unsigned int s = 0; s < kDigestSizeInWords; s++)
 456.102 -    block[s] = mac[s];
 456.103 -  for(UInt32 i = 0; i < numIteration; i++)
 456.104 -  {
 456.105 -    _sha.GetBlockDigest(block, block2);
 456.106 -    _sha2.GetBlockDigest(block2, block);
 456.107 -    for (unsigned int s = 0; s < kDigestSizeInWords; s++)
 456.108 -      mac[s] ^= block[s];
 456.109 -  }
 456.110 -}
 456.111 -
 456.112 -}}
   457.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/HmacSha1.h	Sat Mar 03 10:54:39 2012 -0600
   457.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   457.3 @@ -1,39 +0,0 @@
   457.4 -// HmacSha1.h
   457.5 -// Implements HMAC-SHA-1 (RFC2104, FIPS-198)
   457.6 -
   457.7 -#ifndef __CRYPTO_HMAC_SHA1_H
   457.8 -#define __CRYPTO_HMAC_SHA1_H
   457.9 -
  457.10 -#include "Sha1.h"
  457.11 -
  457.12 -namespace NCrypto {
  457.13 -namespace NSha1 {
  457.14 -
  457.15 -// Use:  SetKey(key, keySize); for () Update(data, size); Final(mac, macSize);
  457.16 -
  457.17 -class CHmac
  457.18 -{
  457.19 -  CContext _sha;
  457.20 -  CContext _sha2;
  457.21 -public:
  457.22 -  void SetKey(const Byte *key, size_t keySize);
  457.23 -  void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); }
  457.24 -  void Final(Byte *mac, size_t macSize = kDigestSize);
  457.25 -};
  457.26 -
  457.27 -class CHmac32
  457.28 -{
  457.29 -  CContext32 _sha;
  457.30 -  CContext32 _sha2;
  457.31 -public:
  457.32 -  void SetKey(const Byte *key, size_t keySize);
  457.33 -  void Update(const UInt32 *data, size_t dataSize) { _sha.Update(data, dataSize); }
  457.34 -  void Final(UInt32 *mac, size_t macSize = kDigestSizeInWords);
  457.35 -  
  457.36 -  // It'sa for hmac function. in,out: mac[kDigestSizeInWords].
  457.37 -  void GetLoopXorDigest(UInt32 *mac, UInt32 numIteration);
  457.38 -};
  457.39 -
  457.40 -}}
  457.41 -
  457.42 -#endif
   458.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/MyAes.cpp	Sat Mar 03 10:54:39 2012 -0600
   458.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   458.3 @@ -1,57 +0,0 @@
   458.4 -// Crypto/MyAes.cpp
   458.5 -
   458.6 -#include "StdAfx.h"
   458.7 -
   458.8 -#include "MyAes.h"
   458.9 -
  458.10 -namespace NCrypto {
  458.11 -
  458.12 -struct CAesTabInit { CAesTabInit() { AesGenTables();} } g_AesTabInit;
  458.13 -
  458.14 -STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; }
  458.15 -
  458.16 -STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
  458.17 -{
  458.18 -  return (UInt32)AesCbc_Encode(&Aes, data, size);
  458.19 -}
  458.20 -
  458.21 -STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size)
  458.22 -{
  458.23 -  if ((size & 0x7) != 0 || size < 16 || size > 32)
  458.24 -    return E_INVALIDARG;
  458.25 -  Aes_SetKeyEncode(&Aes.aes, data, size);
  458.26 -  return S_OK;
  458.27 -}
  458.28 -
  458.29 -STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size)
  458.30 -{
  458.31 -  if (size != AES_BLOCK_SIZE)
  458.32 -    return E_INVALIDARG;
  458.33 -  AesCbc_Init(&Aes, data);
  458.34 -  return S_OK;
  458.35 -}
  458.36 -
  458.37 -STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; }
  458.38 -
  458.39 -STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
  458.40 -{
  458.41 -  return (UInt32)AesCbc_Decode(&Aes, data, size);
  458.42 -}
  458.43 -
  458.44 -STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size)
  458.45 -{
  458.46 -  if ((size & 0x7) != 0 || size < 16 || size > 32)
  458.47 -    return E_INVALIDARG;
  458.48 -  Aes_SetKeyDecode(&Aes.aes, data, size);
  458.49 -  return S_OK;
  458.50 -}
  458.51 -
  458.52 -STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size)
  458.53 -{
  458.54 -  if (size != AES_BLOCK_SIZE)
  458.55 -    return E_INVALIDARG;
  458.56 -  AesCbc_Init(&Aes, data);
  458.57 -  return S_OK;
  458.58 -}
  458.59 -
  458.60 -}
   459.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/MyAes.h	Sat Mar 03 10:54:39 2012 -0600
   459.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   459.3 @@ -1,48 +0,0 @@
   459.4 -// Crypto/MyAes.h
   459.5 -
   459.6 -#ifndef __CRYPTO_MY_AES_H
   459.7 -#define __CRYPTO_MY_AES_H
   459.8 -
   459.9 -extern "C"
  459.10 -{
  459.11 -#include "../../../C/Aes.h"
  459.12 -}
  459.13 -
  459.14 -#include "../../Common/MyCom.h"
  459.15 -#include "../../Common/Types.h"
  459.16 -
  459.17 -#include "../ICoder.h"
  459.18 -
  459.19 -namespace NCrypto {
  459.20 -
  459.21 -class CAesCbcEncoder:
  459.22 -  public ICompressFilter,
  459.23 -  public ICryptoProperties,
  459.24 -  public CMyUnknownImp
  459.25 -{
  459.26 -  CAesCbc Aes;
  459.27 -public:
  459.28 -  MY_UNKNOWN_IMP1(ICryptoProperties)
  459.29 -  STDMETHOD(Init)();
  459.30 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  459.31 -  STDMETHOD(SetKey)(const Byte *data, UInt32 size);
  459.32 -  STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
  459.33 -};
  459.34 -
  459.35 -class CAesCbcDecoder:
  459.36 -  public ICompressFilter,
  459.37 -  public ICryptoProperties,
  459.38 -  public CMyUnknownImp
  459.39 -{
  459.40 -  CAesCbc Aes;
  459.41 -public:
  459.42 -  MY_UNKNOWN_IMP1(ICryptoProperties)
  459.43 -  STDMETHOD(Init)();
  459.44 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  459.45 -  STDMETHOD(SetKey)(const Byte *data, UInt32 size);
  459.46 -  STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
  459.47 -};
  459.48 -
  459.49 -}
  459.50 -
  459.51 -#endif
   460.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp	Sat Mar 03 10:54:39 2012 -0600
   460.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   460.3 @@ -1,83 +0,0 @@
   460.4 -// Pbkdf2HmacSha1.cpp
   460.5 -
   460.6 -#include "StdAfx.h"
   460.7 -
   460.8 -#include "HmacSha1.h"
   460.9 -
  460.10 -namespace NCrypto {
  460.11 -namespace NSha1 {
  460.12 -
  460.13 -void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
  460.14 -    UInt32 numIterations, Byte *key, size_t keySize)
  460.15 -{
  460.16 -  CHmac baseCtx;
  460.17 -  baseCtx.SetKey(pwd, pwdSize);
  460.18 -  for (UInt32 i = 1; keySize > 0; i++)
  460.19 -  {
  460.20 -    CHmac ctx = baseCtx;
  460.21 -    ctx.Update(salt, saltSize);
  460.22 -    Byte u[kDigestSize] = { (Byte)(i >> 24), (Byte)(i >> 16), (Byte)(i >> 8), (Byte)(i) };
  460.23 -    const unsigned int curSize = (keySize < kDigestSize) ? (unsigned int)keySize : kDigestSize;
  460.24 -    ctx.Update(u, 4);
  460.25 -    ctx.Final(u, kDigestSize);
  460.26 -
  460.27 -    unsigned int s;
  460.28 -    for (s = 0; s < curSize; s++)
  460.29 -      key[s] = u[s];
  460.30 -    
  460.31 -    for (UInt32 j = numIterations; j > 1; j--)
  460.32 -    {
  460.33 -      ctx = baseCtx;
  460.34 -      ctx.Update(u, kDigestSize);
  460.35 -      ctx.Final(u, kDigestSize);
  460.36 -      for (s = 0; s < curSize; s++)
  460.37 -        key[s] ^= u[s];
  460.38 -    }
  460.39 -
  460.40 -    key += curSize;
  460.41 -    keySize -= curSize;
  460.42 -  }
  460.43 -}
  460.44 -
  460.45 -void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
  460.46 -    UInt32 numIterations, UInt32 *key, size_t keySize)
  460.47 -{
  460.48 -  CHmac32 baseCtx;
  460.49 -  baseCtx.SetKey(pwd, pwdSize);
  460.50 -  for (UInt32 i = 1; keySize > 0; i++)
  460.51 -  {
  460.52 -    CHmac32 ctx = baseCtx;
  460.53 -    ctx.Update(salt, saltSize);
  460.54 -    UInt32 u[kDigestSizeInWords] = { i };
  460.55 -    const unsigned int curSize = (keySize < kDigestSizeInWords) ? (unsigned int)keySize : kDigestSizeInWords;
  460.56 -    ctx.Update(u, 1);
  460.57 -    ctx.Final(u, kDigestSizeInWords);
  460.58 -
  460.59 -    // Speed-optimized code start
  460.60 -    ctx = baseCtx;
  460.61 -    ctx.GetLoopXorDigest(u, numIterations - 1);
  460.62 -    // Speed-optimized code end
  460.63 -    
  460.64 -    unsigned int s;
  460.65 -    for (s = 0; s < curSize; s++)
  460.66 -      key[s] = u[s];
  460.67 -    
  460.68 -    /*
  460.69 -    // Default code start
  460.70 -    for (UInt32 j = numIterations; j > 1; j--)
  460.71 -    {
  460.72 -      ctx = baseCtx;
  460.73 -      ctx.Update(u, kDigestSizeInWords);
  460.74 -      ctx.Final(u, kDigestSizeInWords);
  460.75 -      for (s = 0; s < curSize; s++)
  460.76 -        key[s] ^= u[s];
  460.77 -    }
  460.78 -    // Default code end
  460.79 -    */
  460.80 -
  460.81 -    key += curSize;
  460.82 -    keySize -= curSize;
  460.83 -  }
  460.84 -}
  460.85 -
  460.86 -}}
   461.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h	Sat Mar 03 10:54:39 2012 -0600
   461.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   461.3 @@ -1,21 +0,0 @@
   461.4 -// Pbkdf2HmacSha1.h
   461.5 -// Password-Based Key Derivation Function (RFC 2898, PKCS #5) based on HMAC-SHA-1
   461.6 -
   461.7 -#ifndef __CRYPTO_PBKDF2_HMAC_SHA1_H
   461.8 -#define __CRYPTO_PBKDF2_HMAC_SHA1_H
   461.9 -
  461.10 -#include <stddef.h>
  461.11 -#include "../../Common/Types.h"
  461.12 -
  461.13 -namespace NCrypto {
  461.14 -namespace NSha1 {
  461.15 -
  461.16 -void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
  461.17 -    UInt32 numIterations, Byte *key, size_t keySize);
  461.18 -
  461.19 -void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
  461.20 -    UInt32 numIterations, UInt32 *key, size_t keySize);
  461.21 -
  461.22 -}}
  461.23 -
  461.24 -#endif
   462.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/RandGen.cpp	Sat Mar 03 10:54:39 2012 -0600
   462.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   462.3 @@ -1,107 +0,0 @@
   462.4 -// RandGen.cpp
   462.5 -
   462.6 -#include "StdAfx.h"
   462.7 -
   462.8 -#include <stdio.h>
   462.9 -#include "Windows/Synchronization.h"
  462.10 -#include "RandGen.h"
  462.11 -
  462.12 -#ifndef _WIN32
  462.13 -#include <unistd.h>
  462.14 -#define USE_POSIX_TIME
  462.15 -#define USE_POSIX_TIME2
  462.16 -#endif
  462.17 -
  462.18 -#ifdef USE_POSIX_TIME
  462.19 -#include <time.h>
  462.20 -#ifdef USE_POSIX_TIME2
  462.21 -#include <sys/time.h>
  462.22 -#endif
  462.23 -#endif
  462.24 -
  462.25 -// This is not very good random number generator.
  462.26 -// Please use it only for salt.
  462.27 -// First generated data block depends from timer and processID.
  462.28 -// Other generated data blocks depend from previous state
  462.29 -// Maybe it's possible to restore original timer value from generated value.
  462.30 -
  462.31 -void CRandomGenerator::Init()
  462.32 -{
  462.33 -  NCrypto::NSha1::CContext hash;
  462.34 -  hash.Init();
  462.35 -
  462.36 -  #ifdef _WIN32
  462.37 -  DWORD w = ::GetCurrentProcessId();
  462.38 -  hash.Update((const Byte *)&w, sizeof(w));
  462.39 -  w = ::GetCurrentThreadId();
  462.40 -  hash.Update((const Byte *)&w, sizeof(w));
  462.41 -  #else
  462.42 -  pid_t pid = getpid();
  462.43 -  hash.Update((const Byte *)&pid, sizeof(pid));
  462.44 -  pid = getppid();
  462.45 -  hash.Update((const Byte *)&pid, sizeof(pid));
  462.46 -  #endif
  462.47 -
  462.48 -  for (int i = 0; i < 1000; i++)
  462.49 -  {
  462.50 -    #ifdef _WIN32
  462.51 -    LARGE_INTEGER v;
  462.52 -    if (::QueryPerformanceCounter(&v))
  462.53 -      hash.Update((const Byte *)&v.QuadPart, sizeof(v.QuadPart));
  462.54 -    #endif
  462.55 -
  462.56 -    #ifdef USE_POSIX_TIME
  462.57 -    #ifdef USE_POSIX_TIME2
  462.58 -    timeval v;
  462.59 -    if (gettimeofday(&v, 0) == 0)
  462.60 -    {
  462.61 -      hash.Update((const Byte *)&v.tv_sec, sizeof(v.tv_sec));
  462.62 -      hash.Update((const Byte *)&v.tv_usec, sizeof(v.tv_usec));
  462.63 -    }
  462.64 -    #endif
  462.65 -    time_t v2 = time(NULL);
  462.66 -    hash.Update((const Byte *)&v2, sizeof(v2));
  462.67 -    #endif
  462.68 -
  462.69 -    DWORD tickCount = ::GetTickCount();
  462.70 -    hash.Update((const Byte *)&tickCount, sizeof(tickCount));
  462.71 -    
  462.72 -    for (int j = 0; j < 100; j++)
  462.73 -    {
  462.74 -      hash.Final(_buff);
  462.75 -      hash.Init();
  462.76 -      hash.Update(_buff, NCrypto::NSha1::kDigestSize);
  462.77 -    }
  462.78 -  }
  462.79 -  hash.Final(_buff);
  462.80 -  _needInit = false;
  462.81 -}
  462.82 -
  462.83 -static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
  462.84 -
  462.85 -void CRandomGenerator::Generate(Byte *data, unsigned int size)
  462.86 -{
  462.87 -  g_CriticalSection.Enter();
  462.88 -  if (_needInit)
  462.89 -    Init();
  462.90 -  while (size > 0)
  462.91 -  {
  462.92 -    NCrypto::NSha1::CContext hash;
  462.93 -    
  462.94 -    hash.Init();
  462.95 -    hash.Update(_buff, NCrypto::NSha1::kDigestSize);
  462.96 -    hash.Final(_buff);
  462.97 -    
  462.98 -    hash.Init();
  462.99 -    UInt32 salt = 0xF672ABD1;
 462.100 -    hash.Update((const Byte *)&salt, sizeof(salt));
 462.101 -    hash.Update(_buff, NCrypto::NSha1::kDigestSize);
 462.102 -    Byte buff[NCrypto::NSha1::kDigestSize];
 462.103 -    hash.Final(buff);
 462.104 -    for (unsigned int i = 0; i < NCrypto::NSha1::kDigestSize && size > 0; i++, size--)
 462.105 -      *data++ = buff[i];
 462.106 -  }
 462.107 -  g_CriticalSection.Leave();
 462.108 -}
 462.109 -
 462.110 -CRandomGenerator g_RandomGenerator;
   463.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/RandGen.h	Sat Mar 03 10:54:39 2012 -0600
   463.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   463.3 @@ -1,21 +0,0 @@
   463.4 -// RandGen.h
   463.5 -
   463.6 -#ifndef __CRYPTO_RAND_GEN_H
   463.7 -#define __CRYPTO_RAND_GEN_H
   463.8 -
   463.9 -#include "Sha1.h"
  463.10 -
  463.11 -class CRandomGenerator
  463.12 -{
  463.13 -  Byte _buff[NCrypto::NSha1::kDigestSize];
  463.14 -  bool _needInit;
  463.15 -
  463.16 -  void Init();
  463.17 -public:
  463.18 -  CRandomGenerator(): _needInit(true) {};
  463.19 -  void Generate(Byte *data, unsigned size);
  463.20 -};
  463.21 -
  463.22 -extern CRandomGenerator g_RandomGenerator;
  463.23 -
  463.24 -#endif
   464.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.cpp	Sat Mar 03 10:54:39 2012 -0600
   464.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   464.3 @@ -1,136 +0,0 @@
   464.4 -// Crypto/Rar20Crypto.cpp
   464.5 -
   464.6 -#include "StdAfx.h"
   464.7 -
   464.8 -extern "C"
   464.9 -{
  464.10 -  #include "../../../C/7zCrc.h"
  464.11 -  #include "../../../C/CpuArch.h"
  464.12 -  #include "../../../C/RotateDefs.h"
  464.13 -}
  464.14 -
  464.15 -#include "Rar20Crypto.h"
  464.16 -
  464.17 -namespace NCrypto {
  464.18 -namespace NRar20 {
  464.19 -
  464.20 -static const int kNumRounds = 32;
  464.21 -
  464.22 -static const Byte InitSubstTable[256] = {
  464.23 -  215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221,  2, 42,
  464.24 -  232,  1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137,
  464.25 -  255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86,  6,
  464.26 -   71, 24,171,196,101,113,218,123, 93, 91,163,178,202, 67, 44,235,
  464.27 -  107,250, 75,234, 49,167,125,211, 83,114,157,144, 32,193,143, 36,
  464.28 -  158,124,247,187, 89,214,141, 47,121,228, 61,130,213,194,174,251,
  464.29 -   97,110, 54,229,115, 57,152, 94,105,243,212, 55,209,245, 63, 11,
  464.30 -  164,200, 31,156, 81,176,227, 21, 76, 99,139,188,127, 17,248, 51,
  464.31 -  207,120,189,210,  8,226, 41, 72,183,203,135,165,166, 60, 98,  7,
  464.32 -  122, 38,155,170, 69,172,252,238, 39,134, 59,128,236, 27,240, 80,
  464.33 -  131,  3, 85,206,145, 79,154,142,159,220,201,133, 74, 64, 20,129,
  464.34 -  224,185,138,103,173,182, 43, 34,254, 82,198,151,231,180, 58, 10,
  464.35 -  118, 26,102, 12, 50,132, 22,191,136,111,162,179, 45,  4,148,108,
  464.36 -  161, 56, 78,126,242,222, 15,175,146, 23, 33,241,181,190, 77,225,
  464.37 -    0, 46,169,186, 68, 95,237, 65, 53,208,253,168,  9, 18,100, 52,
  464.38 -  116,184,160, 96,109, 37, 30,106,140,104,150,  5,204,117,112, 84
  464.39 -};
  464.40 -
  464.41 -void CData::UpdateKeys(const Byte *data)
  464.42 -{
  464.43 -  for (int i = 0; i < 16; i += 4)
  464.44 -    for (int j = 0; j < 4; j++)
  464.45 -      Keys[j] ^= g_CrcTable[data[i + j]];
  464.46 -}
  464.47 -
  464.48 -static void Swap(Byte *b1, Byte *b2)
  464.49 -{
  464.50 -  Byte b = *b1;
  464.51 -  *b1 = *b2;
  464.52 -  *b2 = b;
  464.53 -}
  464.54 -
  464.55 -void CData::SetPassword(const Byte *password, UInt32 passwordLen)
  464.56 -{
  464.57 -  Keys[0] = 0xD3A3B879L;
  464.58 -  Keys[1] = 0x3F6D12F7L;
  464.59 -  Keys[2] = 0x7515A235L;
  464.60 -  Keys[3] = 0xA4E7F123L;
  464.61 -  
  464.62 -  Byte psw[256];
  464.63 -  memset(psw, 0, sizeof(psw));
  464.64 -  memcpy(psw, password, passwordLen);
  464.65 -  memcpy(SubstTable, InitSubstTable, sizeof(SubstTable));
  464.66 -
  464.67 -  for (UInt32 j = 0; j < 256; j++)
  464.68 -    for (UInt32 i = 0; i < passwordLen; i += 2)
  464.69 -    {
  464.70 -      UInt32 n2 = (Byte)g_CrcTable[(psw[i + 1] + j) & 0xFF];
  464.71 -      UInt32 n1 = (Byte)g_CrcTable[(psw[i] - j) & 0xFF];
  464.72 -      for (UInt32 k = 1; (n1 & 0xFF) != n2; n1++, k++)
  464.73 -        Swap(&SubstTable[n1 & 0xFF], &SubstTable[(n1 + i + k) & 0xFF]);
  464.74 -    }
  464.75 -  for (UInt32 i = 0; i < passwordLen; i+= 16)
  464.76 -    EncryptBlock(&psw[i]);
  464.77 -}
  464.78 -
  464.79 -void CData::CryptBlock(Byte *buf, bool encrypt)
  464.80 -{
  464.81 -  Byte inBuf[16];
  464.82 -  UInt32 A, B, C, D, T, TA, TB;
  464.83 -
  464.84 -  A = GetUi32(buf +  0) ^ Keys[0];
  464.85 -  B = GetUi32(buf +  4) ^ Keys[1];
  464.86 -  C = GetUi32(buf +  8) ^ Keys[2];
  464.87 -  D = GetUi32(buf + 12) ^ Keys[3];
  464.88 -
  464.89 -  if (!encrypt)
  464.90 -    memcpy(inBuf, buf, sizeof(inBuf));
  464.91 -  
  464.92 -  for (int i = 0; i < kNumRounds; i++)
  464.93 -  {
  464.94 -    UInt32 key = Keys[(encrypt ? i : (kNumRounds - 1 - i)) & 3];
  464.95 -    T = ((C + rotlFixed(D, 11)) ^ key);
  464.96 -    TA = A ^ SubstLong(T);
  464.97 -    T = ((D ^ rotlFixed(C, 17)) + key);
  464.98 -    TB = B ^ SubstLong(T);
  464.99 -    A = C;
 464.100 -    B = D;
 464.101 -    C = TA;
 464.102 -    D = TB;
 464.103 -  }
 464.104 -
 464.105 -  SetUi32(buf +  0, C ^ Keys[0]);
 464.106 -  SetUi32(buf +  4, D ^ Keys[1]);
 464.107 -  SetUi32(buf +  8, A ^ Keys[2]);
 464.108 -  SetUi32(buf + 12, B ^ Keys[3]);
 464.109 -
 464.110 -  UpdateKeys(encrypt ? buf : inBuf);
 464.111 -}
 464.112 -
 464.113 -STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
 464.114 -{
 464.115 -  _cipher.SetPassword(data, size);
 464.116 -  return S_OK;
 464.117 -}
 464.118 -
 464.119 -STDMETHODIMP CDecoder::Init()
 464.120 -{
 464.121 -  return S_OK;
 464.122 -}
 464.123 -
 464.124 -static const UInt32 kBlockSize = 16;
 464.125 -
 464.126 -STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
 464.127 -{
 464.128 -  if (size == 0)
 464.129 -    return 0;
 464.130 -  if (size < kBlockSize)
 464.131 -    return kBlockSize;
 464.132 -  UInt32 i;
 464.133 -  size -= kBlockSize;
 464.134 -  for (i = 0; i <= size; i += kBlockSize)
 464.135 -    _cipher.DecryptBlock(data + i);
 464.136 -  return i;
 464.137 -}
 464.138 -
 464.139 -}}
   465.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.h	Sat Mar 03 10:54:39 2012 -0600
   465.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   465.3 @@ -1,50 +0,0 @@
   465.4 -// Crypto/Rar20Crypto.h
   465.5 -
   465.6 -#ifndef __CRYPTO_RAR20_CRYPTO_H
   465.7 -#define __CRYPTO_RAR20_CRYPTO_H
   465.8 -
   465.9 -#include "Common/MyCom.h"
  465.10 -
  465.11 -#include "../ICoder.h"
  465.12 -#include "../IPassword.h"
  465.13 -
  465.14 -namespace NCrypto {
  465.15 -namespace NRar20 {
  465.16 -
  465.17 -class CData
  465.18 -{
  465.19 -  Byte SubstTable[256];
  465.20 -  UInt32 Keys[4];
  465.21 -  
  465.22 -  UInt32 SubstLong(UInt32 t)
  465.23 -  {
  465.24 -    return (UInt32)SubstTable[(int)t & 255] |
  465.25 -           ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
  465.26 -           ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
  465.27 -           ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
  465.28 -  }
  465.29 -  void UpdateKeys(const Byte *data);
  465.30 -  void CryptBlock(Byte *buf, bool encrypt);
  465.31 -public:
  465.32 -  void EncryptBlock(Byte *buf) { CryptBlock(buf, true); }
  465.33 -  void DecryptBlock(Byte *buf) { CryptBlock(buf, false); }
  465.34 -  void SetPassword(const Byte *password, UInt32 passwordLen);
  465.35 -};
  465.36 -
  465.37 -class CDecoder:
  465.38 -  public ICompressFilter,
  465.39 -  public ICryptoSetPassword,
  465.40 -  public CMyUnknownImp
  465.41 -{
  465.42 -  CData _cipher;
  465.43 -public:
  465.44 -  MY_UNKNOWN_IMP1(ICryptoSetPassword)
  465.45 -
  465.46 -  STDMETHOD(Init)();
  465.47 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  465.48 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  465.49 -};
  465.50 -
  465.51 -}}
  465.52 -
  465.53 -#endif
   466.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/RarAes.cpp	Sat Mar 03 10:54:39 2012 -0600
   466.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   466.3 @@ -1,139 +0,0 @@
   466.4 -// Crypto/RarAes.cpp
   466.5 -// Note: you must include MyAes.cpp to project to initialize AES tables
   466.6 -
   466.7 -#include "StdAfx.h"
   466.8 -
   466.9 -#include "RarAes.h"
  466.10 -#include "Sha1.h"
  466.11 -
  466.12 -namespace NCrypto {
  466.13 -namespace NRar29 {
  466.14 -
  466.15 -CDecoder::CDecoder():
  466.16 -  _thereIsSalt(false),
  466.17 -  _needCalculate(true),
  466.18 -  _rar350Mode(false)
  466.19 -{
  466.20 -  for (int i = 0; i < sizeof(_salt); i++)
  466.21 -    _salt[i] = 0;
  466.22 -}
  466.23 -
  466.24 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
  466.25 -{
  466.26 -  bool thereIsSaltPrev = _thereIsSalt;
  466.27 -  _thereIsSalt = false;
  466.28 -  if (size == 0)
  466.29 -    return S_OK;
  466.30 -  if (size < 8)
  466.31 -    return E_INVALIDARG;
  466.32 -  _thereIsSalt = true;
  466.33 -  bool same = false;
  466.34 -  if (_thereIsSalt == thereIsSaltPrev)
  466.35 -  {
  466.36 -    same = true;
  466.37 -    if (_thereIsSalt)
  466.38 -    {
  466.39 -      for (int i = 0; i < sizeof(_salt); i++)
  466.40 -        if (_salt[i] != data[i])
  466.41 -        {
  466.42 -          same = false;
  466.43 -          break;
  466.44 -        }
  466.45 -    }
  466.46 -  }
  466.47 -  for (int i = 0; i < sizeof(_salt); i++)
  466.48 -    _salt[i] = data[i];
  466.49 -  if (!_needCalculate && !same)
  466.50 -    _needCalculate = true;
  466.51 -  return S_OK;
  466.52 -}
  466.53 -
  466.54 -static const int kMaxPasswordLength = 127 * 2;
  466.55 -
  466.56 -STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
  466.57 -{
  466.58 -  if (size > kMaxPasswordLength)
  466.59 -    size = kMaxPasswordLength;
  466.60 -  bool same = false;
  466.61 -  if (size == buffer.GetCapacity())
  466.62 -  {
  466.63 -    same = true;
  466.64 -    for (UInt32 i = 0; i < size; i++)
  466.65 -      if (data[i] != buffer[i])
  466.66 -      {
  466.67 -        same = false;
  466.68 -        break;
  466.69 -      }
  466.70 -  }
  466.71 -  if (!_needCalculate && !same)
  466.72 -    _needCalculate = true;
  466.73 -  buffer.SetCapacity(size);
  466.74 -  memcpy(buffer, data, size);
  466.75 -  return S_OK;
  466.76 -}
  466.77 -
  466.78 -STDMETHODIMP CDecoder::Init()
  466.79 -{
  466.80 -  Calculate();
  466.81 -  Aes_SetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize);
  466.82 -  AesCbc_Init(&Aes, aesInit);
  466.83 -  return S_OK;
  466.84 -}
  466.85 -
  466.86 -STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
  466.87 -{
  466.88 -  return (UInt32)AesCbc_Decode(&Aes, data, size);
  466.89 -}
  466.90 -
  466.91 -void CDecoder::Calculate()
  466.92 -{
  466.93 -  if (_needCalculate)
  466.94 -  {
  466.95 -    const int kSaltSize = 8;
  466.96 -    
  466.97 -    Byte rawPassword[kMaxPasswordLength + kSaltSize];
  466.98 -    
  466.99 -    memcpy(rawPassword, buffer, buffer.GetCapacity());
 466.100 -    
 466.101 -    size_t rawLength = buffer.GetCapacity();
 466.102 -    
 466.103 -    if (_thereIsSalt)
 466.104 -    {
 466.105 -      memcpy(rawPassword + rawLength, _salt, kSaltSize);
 466.106 -      rawLength += kSaltSize;
 466.107 -    }
 466.108 -    
 466.109 -    NSha1::CContext sha;
 466.110 -    sha.Init();
 466.111 -
 466.112 -    // seems rar reverts hash for sha.
 466.113 -    const int hashRounds = 0x40000;
 466.114 -    int i;
 466.115 -    for (i = 0; i < hashRounds; i++)
 466.116 -    {
 466.117 -      sha.Update(rawPassword, rawLength, _rar350Mode);
 466.118 -      Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
 466.119 -      sha.Update(pswNum, 3, _rar350Mode);
 466.120 -      if (i % (hashRounds / 16) == 0)
 466.121 -      {
 466.122 -        NSha1::CContext shaTemp = sha;
 466.123 -        Byte digest[NSha1::kDigestSize];
 466.124 -        shaTemp.Final(digest);
 466.125 -        aesInit[i / (hashRounds / 16)] = (Byte)digest[4 * 4 + 3];
 466.126 -      }
 466.127 -    }
 466.128 -    /*
 466.129 -    // it's test message for sha
 466.130 -    const char *message = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
 466.131 -    sha.Update((const Byte *)message, strlen(message));
 466.132 -    */
 466.133 -    Byte digest[20];
 466.134 -    sha.Final(digest);
 466.135 -    for (i = 0; i < 4; i++)
 466.136 -      for (int j = 0; j < 4; j++)
 466.137 -        aesKey[i * 4 + j] = (digest[i * 4 + 3 - j]);
 466.138 -  }
 466.139 -  _needCalculate = false;
 466.140 -}
 466.141 -
 466.142 -}}
   467.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/RarAes.h	Sat Mar 03 10:54:39 2012 -0600
   467.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   467.3 @@ -1,62 +0,0 @@
   467.4 -// Crypto/RarAes.h
   467.5 -
   467.6 -#ifndef __CRYPTO_RAR_AES_H
   467.7 -#define __CRYPTO_RAR_AES_H
   467.8 -
   467.9 -extern "C"
  467.10 -{
  467.11 -#include "../../../C/Aes.h"
  467.12 -}
  467.13 -
  467.14 -#include "Common/Buffer.h"
  467.15 -#include "Common/MyCom.h"
  467.16 -
  467.17 -#include "../ICoder.h"
  467.18 -#include "../IPassword.h"
  467.19 -
  467.20 -namespace NCrypto {
  467.21 -namespace NRar29 {
  467.22 -
  467.23 -const UInt32 kRarAesKeySize = 16;
  467.24 -
  467.25 -class CDecoder:
  467.26 -  public ICompressFilter,
  467.27 -  public ICompressSetDecoderProperties2,
  467.28 -  public ICryptoSetPassword,
  467.29 -  public CMyUnknownImp
  467.30 -{
  467.31 -  Byte _salt[8];
  467.32 -  bool _thereIsSalt;
  467.33 -  CByteBuffer buffer;
  467.34 -  Byte aesKey[kRarAesKeySize];
  467.35 -  Byte aesInit[AES_BLOCK_SIZE];
  467.36 -  bool _needCalculate;
  467.37 -
  467.38 -  CAesCbc Aes;
  467.39 -
  467.40 -  bool _rar350Mode;
  467.41 -
  467.42 -  void Calculate();
  467.43 -
  467.44 -public:
  467.45 -
  467.46 -  MY_UNKNOWN_IMP2(
  467.47 -    ICryptoSetPassword,
  467.48 -    ICompressSetDecoderProperties2)
  467.49 -
  467.50 -  STDMETHOD(Init)();
  467.51 -
  467.52 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  467.53 -
  467.54 -  STDMETHOD(CryptoSetPassword)(const Byte *aData, UInt32 aSize);
  467.55 -
  467.56 -  // ICompressSetDecoderProperties
  467.57 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
  467.58 -
  467.59 -  CDecoder();
  467.60 -  void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; }
  467.61 -};
  467.62 -
  467.63 -}}
  467.64 -
  467.65 -#endif
   468.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Sha1.cpp	Sat Mar 03 10:54:39 2012 -0600
   468.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   468.3 @@ -1,213 +0,0 @@
   468.4 -// Crypto/Sha1.cpp
   468.5 -// This file is based on public domain
   468.6 -// Steve Reid and Wei Dai's code from Crypto++
   468.7 -
   468.8 -#include "StdAfx.h"
   468.9 -
  468.10 -#include "Sha1.h"
  468.11 -extern "C"
  468.12 -{
  468.13 -#include "../../../C/RotateDefs.h"
  468.14 -}
  468.15 -
  468.16 -namespace NCrypto {
  468.17 -namespace NSha1 {
  468.18 -
  468.19 -// define it for speed optimization
  468.20 -// #define _SHA1_UNROLL
  468.21 -
  468.22 -static const unsigned kNumW =
  468.23 -  #ifdef _SHA1_UNROLL
  468.24 -  16;
  468.25 -  #else
  468.26 -  80;
  468.27 -  #endif
  468.28 -  
  468.29 -
  468.30 -#define w0(i) (W[(i)] = data[(i)])
  468.31 -
  468.32 -#ifdef _SHA1_UNROLL
  468.33 -#define w1(i) (W[(i)&15] = rotlFixed(W[((i)-3)&15] ^ W[((i)-8)&15] ^ W[((i)-14)&15] ^ W[((i)-16)&15], 1))
  468.34 -#else
  468.35 -#define w1(i) (W[(i)] = rotlFixed(W[(i)-3] ^ W[(i)-8] ^ W[(i)-14] ^ W[(i)-16], 1))
  468.36 -#endif
  468.37 -
  468.38 -#define f1(x,y,z) (z^(x&(y^z)))
  468.39 -#define f2(x,y,z) (x^y^z)
  468.40 -#define f3(x,y,z) ((x&y)|(z&(x|y)))
  468.41 -#define f4(x,y,z) (x^y^z)
  468.42 -
  468.43 -#define RK1(a,b,c,d,e,i, f, w, k) e += f(b,c,d) + w(i) + k + rotlFixed(a,5); b = rotlFixed(b,30);
  468.44 -
  468.45 -#define R0(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w0, 0x5A827999)
  468.46 -#define R1(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w1, 0x5A827999)
  468.47 -#define R2(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f2, w1, 0x6ED9EBA1)
  468.48 -#define R3(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f3, w1, 0x8F1BBCDC)
  468.49 -#define R4(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f4, w1, 0xCA62C1D6)
  468.50 -
  468.51 -#define RX_1_4(rx1, rx4, i) rx1(a,b,c,d,e,i); rx4(e,a,b,c,d,i+1); rx4(d,e,a,b,c,i+2); rx4(c,d,e,a,b,i+3); rx4(b,c,d,e,a,i+4);
  468.52 -#define RX_5(rx, i) RX_1_4(rx, rx, i);
  468.53 -
  468.54 -void CContextBase::Init()
  468.55 -{
  468.56 -  _state[0] = 0x67452301;
  468.57 -  _state[1] = 0xEFCDAB89;
  468.58 -  _state[2] = 0x98BADCFE;
  468.59 -  _state[3] = 0x10325476;
  468.60 -  _state[4] = 0xC3D2E1F0;
  468.61 -  _count = 0;
  468.62 -}
  468.63 -
  468.64 -void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnRes)
  468.65 -{
  468.66 -  UInt32 a, b, c, d, e;
  468.67 -  UInt32 W[kNumW];
  468.68 -
  468.69 -  a = _state[0];
  468.70 -  b = _state[1];
  468.71 -  c = _state[2];
  468.72 -  d = _state[3];
  468.73 -  e = _state[4];
  468.74 -  #ifdef _SHA1_UNROLL
  468.75 -  RX_5(R0, 0); RX_5(R0, 5); RX_5(R0, 10);
  468.76 -  #else
  468.77 -  int i;
  468.78 -  for (i = 0; i < 15; i += 5) { RX_5(R0, i); }
  468.79 -  #endif
  468.80 -
  468.81 -  RX_1_4(R0, R1, 15);
  468.82 -
  468.83 -
  468.84 -  #ifdef _SHA1_UNROLL
  468.85 -  RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
  468.86 -  RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
  468.87 -  RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
  468.88 -  #else
  468.89 -  i = 20;
  468.90 -  for (; i < 40; i += 5) { RX_5(R2, i); }
  468.91 -  for (; i < 60; i += 5) { RX_5(R3, i); }
  468.92 -  for (; i < 80; i += 5) { RX_5(R4, i); }
  468.93 -  #endif
  468.94 -
  468.95 -  destDigest[0] = _state[0] + a;
  468.96 -  destDigest[1] = _state[1] + b;
  468.97 -  destDigest[2] = _state[2] + c;
  468.98 -  destDigest[3] = _state[3] + d;
  468.99 -  destDigest[4] = _state[4] + e;
 468.100 -
 468.101 -  if (returnRes)
 468.102 -    for (int i = 0 ; i < 16; i++)
 468.103 -      data[i] = W[kNumW - 16 + i];
 468.104 -  
 468.105 -  // Wipe variables
 468.106 -  // a = b = c = d = e = 0;
 468.107 -}
 468.108 -
 468.109 -void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
 468.110 -{
 468.111 -  unsigned curBufferPos = size & 0xF;
 468.112 -  block[curBufferPos++] = 0x80000000;
 468.113 -  while (curBufferPos != (16 - 2))
 468.114 -    block[curBufferPos++] = 0;
 468.115 -  const UInt64 lenInBits = (_count << 9) + ((UInt64)size << 5);
 468.116 -  block[curBufferPos++] = (UInt32)(lenInBits >> 32);
 468.117 -  block[curBufferPos++] = (UInt32)(lenInBits);
 468.118 -}
 468.119 -
 468.120 -void CContext::Update(Byte *data, size_t size, bool rar350Mode)
 468.121 -{
 468.122 -  bool returnRes = false;
 468.123 -  unsigned curBufferPos = _count2;
 468.124 -  while (size-- > 0)
 468.125 -  {
 468.126 -    int pos = (int)(curBufferPos & 3);
 468.127 -    if (pos == 0)
 468.128 -      _buffer[curBufferPos >> 2] = 0;
 468.129 -    _buffer[curBufferPos >> 2] |= ((UInt32)*data++) << (8 * (3 - pos));
 468.130 -    if (++curBufferPos == kBlockSize)
 468.131 -    {
 468.132 -      curBufferPos = 0;
 468.133 -      CContextBase::UpdateBlock(_buffer, returnRes);
 468.134 -      if (returnRes)
 468.135 -        for (int i = 0; i < kBlockSizeInWords; i++)
 468.136 -        {
 468.137 -          UInt32 d = _buffer[i];
 468.138 -          data[i * 4 + 0 - kBlockSize] = (Byte)(d);
 468.139 -          data[i * 4 + 1 - kBlockSize] = (Byte)(d >>  8);
 468.140 -          data[i * 4 + 2 - kBlockSize] = (Byte)(d >> 16);
 468.141 -          data[i * 4 + 3 - kBlockSize] = (Byte)(d >> 24);
 468.142 -        }
 468.143 -      returnRes = rar350Mode;
 468.144 -    }
 468.145 -  }
 468.146 -  _count2 = curBufferPos;
 468.147 -}
 468.148 -
 468.149 -void CContext::Final(Byte *digest)
 468.150 -{
 468.151 -  const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 3);
 468.152 -  unsigned curBufferPos = _count2;
 468.153 -  int pos = (int)(curBufferPos & 3);
 468.154 -  curBufferPos >>= 2;
 468.155 -  if (pos == 0)
 468.156 -    _buffer[curBufferPos] = 0;
 468.157 -  _buffer[curBufferPos++] |= ((UInt32)0x80) << (8 * (3 - pos));
 468.158 -
 468.159 -  while (curBufferPos != (16 - 2))
 468.160 -  {
 468.161 -    curBufferPos &= 0xF;
 468.162 -    if (curBufferPos == 0)
 468.163 -      UpdateBlock();
 468.164 -    _buffer[curBufferPos++] = 0;
 468.165 -  }
 468.166 -  _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
 468.167 -  _buffer[curBufferPos++] = (UInt32)(lenInBits);
 468.168 -  UpdateBlock();
 468.169 -
 468.170 -  int i;
 468.171 -  for (i = 0; i < kDigestSizeInWords; i++)
 468.172 -  {
 468.173 -    UInt32 state = _state[i] & 0xFFFFFFFF;
 468.174 -    *digest++ = (Byte)(state >> 24);
 468.175 -    *digest++ = (Byte)(state >> 16);
 468.176 -    *digest++ = (Byte)(state >> 8);
 468.177 -    *digest++ = (Byte)(state);
 468.178 -  }
 468.179 -  Init();
 468.180 -}
 468.181 -
 468.182 -///////////////////////////
 468.183 -// Words version
 468.184 -
 468.185 -void CContext32::Update(const UInt32 *data, size_t size)
 468.186 -{
 468.187 -  while (size-- > 0)
 468.188 -  {
 468.189 -    _buffer[_count2++] = *data++;
 468.190 -    if (_count2 == kBlockSizeInWords)
 468.191 -    {
 468.192 -      _count2 = 0;
 468.193 -      UpdateBlock();
 468.194 -    }
 468.195 -  }
 468.196 -}
 468.197 -
 468.198 -void CContext32::Final(UInt32 *digest)
 468.199 -{
 468.200 -  const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 5);
 468.201 -  unsigned curBufferPos = _count2;
 468.202 -  _buffer[curBufferPos++] = 0x80000000;
 468.203 -  while (curBufferPos != (16 - 2))
 468.204 -  {
 468.205 -    curBufferPos &= 0xF;
 468.206 -    if (curBufferPos == 0)
 468.207 -      UpdateBlock();
 468.208 -    _buffer[curBufferPos++] = 0;
 468.209 -  }
 468.210 -  _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
 468.211 -  _buffer[curBufferPos++] = (UInt32)(lenInBits);
 468.212 -  GetBlockDigest(_buffer, digest);
 468.213 -  Init();
 468.214 -}
 468.215 -
 468.216 -}}
   469.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/Sha1.h	Sat Mar 03 10:54:39 2012 -0600
   469.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   469.3 @@ -1,68 +0,0 @@
   469.4 -// Crypto/Sha1.h
   469.5 -// This file is based on public domain
   469.6 -// Steve Reid and Wei Dai's code from Crypto++
   469.7 -
   469.8 -#ifndef __CRYPTO_SHA1_H
   469.9 -#define __CRYPTO_SHA1_H
  469.10 -
  469.11 -#include <stddef.h>
  469.12 -#include "../../Common/Types.h"
  469.13 -
  469.14 -// Sha1 implementation in RAR before version 3.60 has bug:
  469.15 -// it changes data bytes in some cases.
  469.16 -// So this class supports both versions: normal_SHA and rar3Mode
  469.17 -
  469.18 -namespace NCrypto {
  469.19 -namespace NSha1 {
  469.20 -
  469.21 -const unsigned kBlockSize = 64;
  469.22 -const unsigned kDigestSize = 20;
  469.23 -
  469.24 -const unsigned kBlockSizeInWords = (kBlockSize >> 2);
  469.25 -const unsigned kDigestSizeInWords = (kDigestSize >> 2);
  469.26 -
  469.27 -class CContextBase
  469.28 -{
  469.29 -protected:
  469.30 -  UInt32 _state[5];
  469.31 -  UInt64 _count;
  469.32 -  void UpdateBlock(UInt32 *data, bool returnRes = false)
  469.33 -  {
  469.34 -    GetBlockDigest(data, _state, returnRes);
  469.35 -    _count++;
  469.36 -  }
  469.37 -public:
  469.38 -  void Init();
  469.39 -  void GetBlockDigest(UInt32 *blockData, UInt32 *destDigest, bool returnRes = false);
  469.40 -  // PrepareBlock can be used only when size <= 13. size in Words
  469.41 -  void PrepareBlock(UInt32 *block, unsigned int size) const;
  469.42 -};
  469.43 -
  469.44 -class CContextBase2: public CContextBase
  469.45 -{
  469.46 -protected:
  469.47 -  unsigned _count2;
  469.48 -  UInt32 _buffer[kBlockSizeInWords];
  469.49 -  void UpdateBlock() { CContextBase::UpdateBlock(_buffer); }
  469.50 -public:
  469.51 -  void Init() { CContextBase::Init(); _count2 = 0; }
  469.52 -};
  469.53 -
  469.54 -class CContext: public CContextBase2
  469.55 -{
  469.56 -public:
  469.57 -  void Update(Byte *data, size_t size, bool rar350Mode = false);
  469.58 -  void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); }
  469.59 -  void Final(Byte *digest);
  469.60 -};
  469.61 -
  469.62 -class CContext32: public CContextBase2
  469.63 -{
  469.64 -public:
  469.65 -  void Update(const UInt32 *data, size_t size);
  469.66 -  void Final(UInt32 *digest);
  469.67 -};
  469.68 -
  469.69 -}}
  469.70 -
  469.71 -#endif
   470.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   470.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   470.3 @@ -1,8 +0,0 @@
   470.4 -// StdAfx.h
   470.5 -
   470.6 -#ifndef __STDAFX_H
   470.7 -#define __STDAFX_H
   470.8 -
   470.9 -#include "../../Common/MyWindows.h"
  470.10 -
  470.11 -#endif
   471.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/WzAes.cpp	Sat Mar 03 10:54:39 2012 -0600
   471.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   471.3 @@ -1,209 +0,0 @@
   471.4 -// Crypto/WzAes.cpp
   471.5 -/*
   471.6 -This code implements Brian Gladman's scheme
   471.7 -specified in password Based File Encryption Utility.
   471.8 -
   471.9 -Note: you must include MyAes.cpp to project to initialize AES tables
  471.10 -*/
  471.11 -
  471.12 -#include "StdAfx.h"
  471.13 -
  471.14 -#include "../Common/StreamObjects.h"
  471.15 -#include "../Common/StreamUtils.h"
  471.16 -
  471.17 -#include "Pbkdf2HmacSha1.h"
  471.18 -#include "RandGen.h"
  471.19 -#include "WzAes.h"
  471.20 -
  471.21 -// define it if you don't want to use speed-optimized version of Pbkdf2HmacSha1
  471.22 -// #define _NO_WZAES_OPTIMIZATIONS
  471.23 -
  471.24 -namespace NCrypto {
  471.25 -namespace NWzAes {
  471.26 -
  471.27 -const unsigned int kAesKeySizeMax = 32;
  471.28 -
  471.29 -static const UInt32 kNumKeyGenIterations = 1000;
  471.30 -
  471.31 -STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
  471.32 -{
  471.33 -  if(size > kPasswordSizeMax)
  471.34 -    return E_INVALIDARG;
  471.35 -  _key.Password.SetCapacity(size);
  471.36 -  memcpy(_key.Password, data, size);
  471.37 -  return S_OK;
  471.38 -}
  471.39 -
  471.40 -#define SetUi32(p, d) { UInt32 x = (d); (p)[0] = (Byte)x; (p)[1] = (Byte)(x >> 8); \
  471.41 -    (p)[2] = (Byte)(x >> 16); (p)[3] = (Byte)(x >> 24); }
  471.42 -
  471.43 -void CBaseCoder::EncryptData(Byte *data, UInt32 size)
  471.44 -{
  471.45 -  unsigned int pos = _blockPos;
  471.46 -  for (; size > 0; size--)
  471.47 -  {
  471.48 -    if (pos == AES_BLOCK_SIZE)
  471.49 -    {
  471.50 -      if (++_counter[0] == 0)
  471.51 -        _counter[1]++;
  471.52 -      UInt32 temp[4];
  471.53 -      Aes_Encode32(&Aes, temp, _counter);
  471.54 -      SetUi32(_buffer,      temp[0]);
  471.55 -      SetUi32(_buffer + 4,  temp[1]);
  471.56 -      SetUi32(_buffer + 8,  temp[2]);
  471.57 -      SetUi32(_buffer + 12, temp[3]);
  471.58 -      pos = 0;
  471.59 -    }
  471.60 -    *data++ ^= _buffer[pos++];
  471.61 -  }
  471.62 -  _blockPos = pos;
  471.63 -}
  471.64 -
  471.65 -#ifndef _NO_WZAES_OPTIMIZATIONS
  471.66 -
  471.67 -static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize)
  471.68 -{
  471.69 -  for (int i = 0 ; i < destSize; i++)
  471.70 -      dest[i] =
  471.71 -          ((UInt32)(src[i * 4 + 0]) << 24) |
  471.72 -          ((UInt32)(src[i * 4 + 1]) << 16) |
  471.73 -          ((UInt32)(src[i * 4 + 2]) <<  8) |
  471.74 -          ((UInt32)(src[i * 4 + 3]));
  471.75 -}
  471.76 -
  471.77 -#endif
  471.78 -
  471.79 -STDMETHODIMP CBaseCoder::Init()
  471.80 -{
  471.81 -  UInt32 keySize = _key.GetKeySize();
  471.82 -  UInt32 keysTotalSize = 2 * keySize + kPwdVerifCodeSize;
  471.83 -  Byte buf[2 * kAesKeySizeMax + kPwdVerifCodeSize];
  471.84 -  
  471.85 -  // for (int ii = 0; ii < 1000; ii++)
  471.86 -  {
  471.87 -    #ifdef _NO_WZAES_OPTIMIZATIONS
  471.88 -
  471.89 -    NSha1::Pbkdf2Hmac(
  471.90 -      _key.Password, _key.Password.GetCapacity(),
  471.91 -      _key.Salt, _key.GetSaltSize(),
  471.92 -      kNumKeyGenIterations,
  471.93 -      buf, keysTotalSize);
  471.94 -
  471.95 -    #else
  471.96 -
  471.97 -    UInt32 buf32[(2 * kAesKeySizeMax + kPwdVerifCodeSize + 3) / 4];
  471.98 -    UInt32 key32SizeTotal = (keysTotalSize + 3) / 4;
  471.99 -    UInt32 salt[kSaltSizeMax * 4];
 471.100 -    UInt32 saltSizeInWords = _key.GetSaltSize() / 4;
 471.101 -    BytesToBeUInt32s(_key.Salt, salt, saltSizeInWords);
 471.102 -    NSha1::Pbkdf2Hmac32(
 471.103 -      _key.Password, _key.Password.GetCapacity(),
 471.104 -      salt, saltSizeInWords,
 471.105 -      kNumKeyGenIterations,
 471.106 -      buf32, key32SizeTotal);
 471.107 -    for (UInt32 j = 0; j < keysTotalSize; j++)
 471.108 -      buf[j] = (Byte)(buf32[j / 4] >> (24 - 8 * (j & 3)));
 471.109 -    
 471.110 -    #endif
 471.111 -  }
 471.112 -
 471.113 -  _hmac.SetKey(buf + keySize, keySize);
 471.114 -  memcpy(_key.PwdVerifComputed, buf + 2 * keySize, kPwdVerifCodeSize);
 471.115 -  
 471.116 -  _blockPos = AES_BLOCK_SIZE;
 471.117 -  for (int i = 0; i < 4; i++)
 471.118 -    _counter[i] = 0;
 471.119 -
 471.120 -  Aes_SetKeyEncode(&Aes, buf, keySize);
 471.121 -  return S_OK;
 471.122 -}
 471.123 -
 471.124 -/*
 471.125 -STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
 471.126 -{
 471.127 -  Byte keySizeMode = 3;
 471.128 -  return outStream->Write(&keySizeMode, 1, NULL);
 471.129 -}
 471.130 -*/
 471.131 -
 471.132 -HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
 471.133 -{
 471.134 -  UInt32 saltSize = _key.GetSaltSize();
 471.135 -  g_RandomGenerator.Generate(_key.Salt, saltSize);
 471.136 -  Init();
 471.137 -  RINOK(WriteStream(outStream, _key.Salt, saltSize));
 471.138 -  return WriteStream(outStream, _key.PwdVerifComputed, kPwdVerifCodeSize);
 471.139 -}
 471.140 -
 471.141 -HRESULT CEncoder::WriteFooter(ISequentialOutStream *outStream)
 471.142 -{
 471.143 -  Byte mac[kMacSize];
 471.144 -  _hmac.Final(mac, kMacSize);
 471.145 -  return WriteStream(outStream, mac, kMacSize);
 471.146 -}
 471.147 -
 471.148 -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
 471.149 -{
 471.150 -  if (size != 1)
 471.151 -    return E_INVALIDARG;
 471.152 -  _key.Init();
 471.153 -  Byte keySizeMode = data[0];
 471.154 -  if (keySizeMode < 1 || keySizeMode > 3)
 471.155 -    return E_INVALIDARG;
 471.156 -  _key.KeySizeMode = keySizeMode;
 471.157 -  return S_OK;
 471.158 -}
 471.159 -
 471.160 -HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
 471.161 -{
 471.162 -  UInt32 saltSize = _key.GetSaltSize();
 471.163 -  UInt32 extraSize = saltSize + kPwdVerifCodeSize;
 471.164 -  Byte temp[kSaltSizeMax + kPwdVerifCodeSize];
 471.165 -  RINOK(ReadStream_FAIL(inStream, temp, extraSize));
 471.166 -  UInt32 i;
 471.167 -  for (i = 0; i < saltSize; i++)
 471.168 -    _key.Salt[i] = temp[i];
 471.169 -  for (i = 0; i < kPwdVerifCodeSize; i++)
 471.170 -    _pwdVerifFromArchive[i] = temp[saltSize + i];
 471.171 -  return S_OK;
 471.172 -}
 471.173 -
 471.174 -static bool CompareArrays(const Byte *p1, const Byte *p2, UInt32 size)
 471.175 -{
 471.176 -  for (UInt32 i = 0; i < size; i++)
 471.177 -    if (p1[i] != p2[i])
 471.178 -      return false;
 471.179 -  return true;
 471.180 -}
 471.181 -
 471.182 -bool CDecoder::CheckPasswordVerifyCode()
 471.183 -{
 471.184 -  return CompareArrays(_key.PwdVerifComputed, _pwdVerifFromArchive, kPwdVerifCodeSize);
 471.185 -}
 471.186 -
 471.187 -HRESULT CDecoder::CheckMac(ISequentialInStream *inStream, bool &isOK)
 471.188 -{
 471.189 -  isOK = false;
 471.190 -  Byte mac1[kMacSize];
 471.191 -  RINOK(ReadStream_FAIL(inStream, mac1, kMacSize));
 471.192 -  Byte mac2[kMacSize];
 471.193 -  _hmac.Final(mac2, kMacSize);
 471.194 -  isOK = CompareArrays(mac1, mac2, kMacSize);
 471.195 -  return S_OK;
 471.196 -}
 471.197 -
 471.198 -STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
 471.199 -{
 471.200 -  EncryptData(data, size);
 471.201 -  _hmac.Update(data, size);
 471.202 -  return size;
 471.203 -}
 471.204 -
 471.205 -STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
 471.206 -{
 471.207 -  _hmac.Update(data, size);
 471.208 -  EncryptData(data, size);
 471.209 -  return size;
 471.210 -}
 471.211 -
 471.212 -}}
   472.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/WzAes.h	Sat Mar 03 10:54:39 2012 -0600
   472.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   472.3 @@ -1,119 +0,0 @@
   472.4 -// Crypto/WzAes.h
   472.5 -/*
   472.6 -This code implements Brian Gladman's scheme
   472.7 -specified in password Based File Encryption Utility:
   472.8 -  - AES encryption (128,192,256-bit) in Counter (CTR) mode.
   472.9 -  - HMAC-SHA1 authentication for encrypted data (10 bytes)
  472.10 -  - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and
  472.11 -    Salt (saltSize = aesKeySize / 2).
  472.12 -  - 2 bytes contain Password Verifier's Code
  472.13 -*/
  472.14 -
  472.15 -#ifndef __CRYPTO_WZ_AES_H
  472.16 -#define __CRYPTO_WZ_AES_H
  472.17 -
  472.18 -extern "C"
  472.19 -{
  472.20 -#include "../../../C/Aes.h"
  472.21 -}
  472.22 -
  472.23 -#include "Common/Buffer.h"
  472.24 -#include "Common/MyCom.h"
  472.25 -#include "Common/MyVector.h"
  472.26 -
  472.27 -#include "../ICoder.h"
  472.28 -#include "../IPassword.h"
  472.29 -
  472.30 -#include "HmacSha1.h"
  472.31 -
  472.32 -namespace NCrypto {
  472.33 -namespace NWzAes {
  472.34 -
  472.35 -const unsigned int kSaltSizeMax = 16;
  472.36 -const unsigned int kMacSize = 10;
  472.37 -
  472.38 -const UInt32 kPasswordSizeMax = 99; // 128;
  472.39 -
  472.40 -// Password Verification Code Size
  472.41 -const unsigned int kPwdVerifCodeSize = 2;
  472.42 -
  472.43 -class CKeyInfo
  472.44 -{
  472.45 -public:
  472.46 -  Byte KeySizeMode; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
  472.47 -  Byte Salt[kSaltSizeMax];
  472.48 -  Byte PwdVerifComputed[kPwdVerifCodeSize];
  472.49 -
  472.50 -  CByteBuffer Password;
  472.51 -
  472.52 -  UInt32 GetKeySize() const  { return (8 * (KeySizeMode & 3) + 8); }
  472.53 -  UInt32 GetSaltSize() const { return (4 * (KeySizeMode & 3) + 4); }
  472.54 -
  472.55 -  CKeyInfo() { Init(); }
  472.56 -  void Init() { KeySizeMode = 3; }
  472.57 -};
  472.58 -
  472.59 -class CBaseCoder:
  472.60 -  public ICompressFilter,
  472.61 -  public ICryptoSetPassword,
  472.62 -  public CMyUnknownImp
  472.63 -{
  472.64 -protected:
  472.65 -  CKeyInfo _key;
  472.66 -  UInt32 _counter[AES_BLOCK_SIZE / 4];
  472.67 -  Byte _buffer[AES_BLOCK_SIZE];
  472.68 -  NSha1::CHmac _hmac;
  472.69 -  unsigned int _blockPos;
  472.70 -  Byte _pwdVerifFromArchive[kPwdVerifCodeSize];
  472.71 -
  472.72 -  void EncryptData(Byte *data, UInt32 size);
  472.73 -
  472.74 -  CAes Aes;
  472.75 -
  472.76 -public:
  472.77 -  STDMETHOD(Init)();
  472.78 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
  472.79 -  
  472.80 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  472.81 -
  472.82 -  UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; }
  472.83 -};
  472.84 -
  472.85 -class CEncoder:
  472.86 -  public CBaseCoder
  472.87 -  // public ICompressWriteCoderProperties
  472.88 -{
  472.89 -public:
  472.90 -  MY_UNKNOWN_IMP1(ICryptoSetPassword)
  472.91 -  //  ICompressWriteCoderProperties
  472.92 -  // STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
  472.93 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  472.94 -  HRESULT WriteHeader(ISequentialOutStream *outStream);
  472.95 -  HRESULT WriteFooter(ISequentialOutStream *outStream);
  472.96 -  bool SetKeyMode(Byte mode)
  472.97 -  {
  472.98 -    if (mode < 1 || mode > 3)
  472.99 -      return false;
 472.100 -    _key.KeySizeMode = mode;
 472.101 -    return true;
 472.102 -  }
 472.103 -};
 472.104 -
 472.105 -class CDecoder:
 472.106 -  public CBaseCoder,
 472.107 -  public ICompressSetDecoderProperties2
 472.108 -{
 472.109 -public:
 472.110 -  MY_UNKNOWN_IMP2(
 472.111 -      ICryptoSetPassword,
 472.112 -      ICompressSetDecoderProperties2)
 472.113 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
 472.114 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
 472.115 -  HRESULT ReadHeader(ISequentialInStream *inStream);
 472.116 -  bool CheckPasswordVerifyCode();
 472.117 -  HRESULT CheckMac(ISequentialInStream *inStream, bool &isOK);
 472.118 -};
 472.119 -
 472.120 -}}
 472.121 -
 472.122 -#endif
   473.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/ZipCrypto.cpp	Sat Mar 03 10:54:39 2012 -0600
   473.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   473.3 @@ -1,131 +0,0 @@
   473.4 -// Crypto/ZipCrypto.cpp
   473.5 -
   473.6 -#include "StdAfx.h"
   473.7 -
   473.8 -extern "C"
   473.9 -{
  473.10 -#include "../../../C/7zCrc.h"
  473.11 -}
  473.12 -
  473.13 -#include "../Common/StreamUtils.h"
  473.14 -
  473.15 -#include "RandGen.h"
  473.16 -#include "ZipCrypto.h"
  473.17 -
  473.18 -namespace NCrypto {
  473.19 -namespace NZip {
  473.20 -
  473.21 -void CCipher::UpdateKeys(Byte b)
  473.22 -{
  473.23 -  Keys[0] = CRC_UPDATE_BYTE(Keys[0], b);
  473.24 -  Keys[1] += Keys[0] & 0xff;
  473.25 -  Keys[1] = Keys[1] * 134775813L + 1;
  473.26 -  Keys[2] = CRC_UPDATE_BYTE(Keys[2], (Byte)(Keys[1] >> 24));
  473.27 -}
  473.28 -
  473.29 -void CCipher::SetPassword(const Byte *password, UInt32 passwordLen)
  473.30 -{
  473.31 -  Keys[0] = 305419896L;
  473.32 -  Keys[1] = 591751049L;
  473.33 -  Keys[2] = 878082192L;
  473.34 -  for (UInt32 i = 0; i < passwordLen; i++)
  473.35 -    UpdateKeys(password[i]);
  473.36 -}
  473.37 -
  473.38 -Byte CCipher::DecryptByteSpec()
  473.39 -{
  473.40 -  UInt32 temp = Keys[2] | 2;
  473.41 -  return (Byte)((temp * (temp ^ 1)) >> 8);
  473.42 -}
  473.43 -
  473.44 -Byte CCipher::DecryptByte(Byte b)
  473.45 -{
  473.46 -  Byte c = (Byte)(b ^ DecryptByteSpec());
  473.47 -  UpdateKeys(c);
  473.48 -  return c;
  473.49 -}
  473.50 -
  473.51 -Byte CCipher::EncryptByte(Byte b)
  473.52 -{
  473.53 -  Byte c = (Byte)(b ^ DecryptByteSpec());
  473.54 -  UpdateKeys(b);
  473.55 -  return c;
  473.56 -}
  473.57 -
  473.58 -void CCipher::DecryptHeader(Byte *buf)
  473.59 -{
  473.60 -  for (unsigned i = 0; i < kHeaderSize; i++)
  473.61 -    buf[i] = DecryptByte(buf[i]);
  473.62 -}
  473.63 -
  473.64 -void CCipher::EncryptHeader(Byte *buf)
  473.65 -{
  473.66 -  for (unsigned i = 0; i < kHeaderSize; i++)
  473.67 -    buf[i] = EncryptByte(buf[i]);
  473.68 -}
  473.69 -
  473.70 -STDMETHODIMP CEncoder::CryptoSetPassword(const Byte *data, UInt32 size)
  473.71 -{
  473.72 -  _cipher.SetPassword(data, size);
  473.73 -  return S_OK;
  473.74 -}
  473.75 -
  473.76 -STDMETHODIMP CEncoder::CryptoSetCRC(UInt32 crc)
  473.77 -{
  473.78 -  _crc = crc;
  473.79 -  return S_OK;
  473.80 -}
  473.81 -
  473.82 -STDMETHODIMP CEncoder::Init()
  473.83 -{
  473.84 -  return S_OK;
  473.85 -}
  473.86 -
  473.87 -HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
  473.88 -{
  473.89 -  Byte header[kHeaderSize];
  473.90 -  g_RandomGenerator.Generate(header, kHeaderSize - 2);
  473.91 -
  473.92 -  header[kHeaderSize - 1] = Byte(_crc >> 24);
  473.93 -  header[kHeaderSize - 2] = Byte(_crc >> 16);
  473.94 -
  473.95 -  _cipher.EncryptHeader(header);
  473.96 -  return WriteStream(outStream, header, kHeaderSize);
  473.97 -}
  473.98 -
  473.99 -STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
 473.100 -{
 473.101 -  UInt32 i;
 473.102 -  for (i = 0; i < size; i++)
 473.103 -    data[i] = _cipher.EncryptByte(data[i]);
 473.104 -  return i;
 473.105 -}
 473.106 -
 473.107 -STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
 473.108 -{
 473.109 -  _cipher.SetPassword(data, size);
 473.110 -  return S_OK;
 473.111 -}
 473.112 -
 473.113 -HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
 473.114 -{
 473.115 -  Byte header[kHeaderSize];
 473.116 -  RINOK(ReadStream_FAIL(inStream, header, kHeaderSize));
 473.117 -  _cipher.DecryptHeader(header);
 473.118 -  return S_OK;
 473.119 -}
 473.120 -
 473.121 -STDMETHODIMP CDecoder::Init()
 473.122 -{
 473.123 -  return S_OK;
 473.124 -}
 473.125 -
 473.126 -STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
 473.127 -{
 473.128 -  UInt32 i;
 473.129 -  for (i = 0; i < size; i++)
 473.130 -    data[i] = _cipher.DecryptByte(data[i]);
 473.131 -  return i;
 473.132 -}
 473.133 -
 473.134 -}}
   474.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/ZipCrypto.h	Sat Mar 03 10:54:39 2012 -0600
   474.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   474.3 @@ -1,71 +0,0 @@
   474.4 -// Crypto/ZipCrypto.h
   474.5 -
   474.6 -#ifndef __CRYPTO_ZIP_CRYPTO_H
   474.7 -#define __CRYPTO_ZIP_CRYPTO_H
   474.8 -
   474.9 -#include "Common/MyCom.h"
  474.10 -
  474.11 -#include "../ICoder.h"
  474.12 -#include "../IPassword.h"
  474.13 -
  474.14 -namespace NCrypto {
  474.15 -namespace NZip {
  474.16 -
  474.17 -const unsigned kHeaderSize = 12;
  474.18 -
  474.19 -class CCipher
  474.20 -{
  474.21 -  UInt32 Keys[3];
  474.22 -
  474.23 -  void UpdateKeys(Byte b);
  474.24 -  Byte DecryptByteSpec();
  474.25 -public:
  474.26 -  void SetPassword(const Byte *password, UInt32 passwordLen);
  474.27 -  Byte DecryptByte(Byte b);
  474.28 -  Byte EncryptByte(Byte b);
  474.29 -  void DecryptHeader(Byte *buf);
  474.30 -  void EncryptHeader(Byte *buf);
  474.31 -};
  474.32 -
  474.33 -class CEncoder :
  474.34 -  public ICompressFilter,
  474.35 -  public ICryptoSetPassword,
  474.36 -  public ICryptoSetCRC,
  474.37 -  public CMyUnknownImp
  474.38 -{
  474.39 -  CCipher _cipher;
  474.40 -  UInt32 _crc;
  474.41 -public:
  474.42 -  MY_UNKNOWN_IMP2(
  474.43 -      ICryptoSetPassword,
  474.44 -      ICryptoSetCRC
  474.45 -  )
  474.46 -  STDMETHOD(Init)();
  474.47 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  474.48 -
  474.49 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  474.50 -  STDMETHOD(CryptoSetCRC)(UInt32 crc);
  474.51 -  HRESULT WriteHeader(ISequentialOutStream *outStream);
  474.52 -};
  474.53 -
  474.54 -
  474.55 -class CDecoder:
  474.56 -  public ICompressFilter,
  474.57 -  public ICryptoSetPassword,
  474.58 -  public CMyUnknownImp
  474.59 -{
  474.60 -  CCipher _cipher;
  474.61 -public:
  474.62 -  MY_UNKNOWN_IMP1(ICryptoSetPassword)
  474.63 -
  474.64 -  STDMETHOD(Init)();
  474.65 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  474.66 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  474.67 -
  474.68 -  HRESULT ReadHeader(ISequentialInStream *inStream);
  474.69 -};
  474.70 -
  474.71 -
  474.72 -}}
  474.73 -
  474.74 -#endif
   475.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/ZipStrong.cpp	Sat Mar 03 10:54:39 2012 -0600
   475.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   475.3 @@ -1,180 +0,0 @@
   475.4 -// Crypto/ZipStrong.cpp
   475.5 -
   475.6 -#include "StdAfx.h"
   475.7 -
   475.8 -extern "C"
   475.9 -{
  475.10 -#include "../../../C/7zCrc.h"
  475.11 -#include "../../../C/CpuArch.h"
  475.12 -}
  475.13 -
  475.14 -#include "../Common/StreamUtils.h"
  475.15 -
  475.16 -#include "MyAES.h"
  475.17 -#include "Sha1.h"
  475.18 -#include "ZipStrong.h"
  475.19 -
  475.20 -namespace NCrypto {
  475.21 -namespace NZipStrong {
  475.22 -
  475.23 -static const UInt16 kAES128 = 0x660E;
  475.24 -
  475.25 -// DeriveKey* function is similar to CryptDeriveKey() from Windows.
  475.26 -// But MSDN tells that we need such scheme only if
  475.27 -// "the required key length is longer than the hash value"
  475.28 -// but ZipStrong uses it always.
  475.29 -
  475.30 -static void DeriveKey2(const Byte *digest, Byte c, Byte *dest)
  475.31 -{
  475.32 -  Byte buf[64];
  475.33 -  memset(buf, c, 64);
  475.34 -  for (unsigned i = 0; i < NSha1::kDigestSize; i++)
  475.35 -    buf[i] ^= digest[i];
  475.36 -  NSha1::CContext sha;
  475.37 -  sha.Init();
  475.38 -  sha.Update(buf, 64);
  475.39 -  sha.Final(dest);
  475.40 -}
  475.41 - 
  475.42 -static void DeriveKey(NSha1::CContext &sha, Byte *key)
  475.43 -{
  475.44 -  Byte digest[NSha1::kDigestSize];
  475.45 -  sha.Final(digest);
  475.46 -  Byte temp[NSha1::kDigestSize * 2];
  475.47 -  DeriveKey2(digest, 0x36, temp);
  475.48 -  DeriveKey2(digest, 0x5C, temp + NSha1::kDigestSize);
  475.49 -  memcpy(key, temp, 32);
  475.50 -}
  475.51 -
  475.52 -void CKeyInfo::SetPassword(const Byte *data, UInt32 size)
  475.53 -{
  475.54 -  NSha1::CContext sha;
  475.55 -  sha.Init();
  475.56 -  sha.Update(data, size);
  475.57 -  DeriveKey(sha, MasterKey);
  475.58 -}
  475.59 -
  475.60 -STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
  475.61 -{
  475.62 -  _key.SetPassword(data, size);
  475.63 -  return S_OK;
  475.64 -}
  475.65 -
  475.66 -STDMETHODIMP CBaseCoder::Init()
  475.67 -{
  475.68 -  return S_OK;
  475.69 -}
  475.70 -
  475.71 -HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream, UInt32 /* crc */, UInt64 /* unpackSize */)
  475.72 -{
  475.73 -  Byte temp[4];
  475.74 -  RINOK(ReadStream_FALSE(inStream, temp, 2));
  475.75 -  _ivSize = GetUi16(temp);
  475.76 -  if (_ivSize == 0)
  475.77 -  {
  475.78 -    return E_NOTIMPL;
  475.79 -    /*
  475.80 -    SetUi32(_iv, crc);
  475.81 -    for (int i = 0; i < 8; i++)
  475.82 -     _iv[4 + i] = (Byte)(unpackSize >> (8 * i));
  475.83 -    SetUi32(_iv + 12, 0);
  475.84 -    */
  475.85 -  }
  475.86 -  else if (_ivSize == 16)
  475.87 -  {
  475.88 -    RINOK(ReadStream_FALSE(inStream, _iv, _ivSize));
  475.89 -  }
  475.90 -  else
  475.91 -    return E_NOTIMPL;
  475.92 -  RINOK(ReadStream_FALSE(inStream, temp, 4));
  475.93 -  _remSize = GetUi32(temp);
  475.94 -  if (_remSize > _buf.GetCapacity())
  475.95 -  {
  475.96 -    _buf.Free();
  475.97 -    _buf.SetCapacity(_remSize);
  475.98 -  }
  475.99 -  return ReadStream_FALSE(inStream, _buf, _remSize);
 475.100 -}
 475.101 -
 475.102 -HRESULT CDecoder::CheckPassword(bool &passwOK)
 475.103 -{
 475.104 -  passwOK = false;
 475.105 -  if (_remSize < 10)
 475.106 -    return E_NOTIMPL;
 475.107 -  Byte *p = _buf;
 475.108 -  UInt16 format = GetUi16(p);
 475.109 -  if (format != 3)
 475.110 -    return E_NOTIMPL;
 475.111 -  UInt16 algId  = GetUi16(p + 2);
 475.112 -  if (algId < kAES128)
 475.113 -    return E_NOTIMPL;
 475.114 -  algId -= kAES128;
 475.115 -  if (algId > 2)
 475.116 -    return E_NOTIMPL;
 475.117 -  UInt16 bitLen = GetUi16(p + 4);
 475.118 -  UInt16 flags  = GetUi16(p + 6);
 475.119 -  if (algId * 64 + 128 != bitLen)
 475.120 -    return E_NOTIMPL;
 475.121 -  _key.KeySize = 16 + algId * 8;
 475.122 -  if ((flags & 1) == 0)
 475.123 -    return E_NOTIMPL;
 475.124 -  UInt32 rdSize = GetUi16(p + 8);
 475.125 -  UInt32 pos = 10;
 475.126 -  Byte *rd = p + pos;
 475.127 -  pos += rdSize;
 475.128 -  if (pos + 4 > _remSize)
 475.129 -    return E_NOTIMPL;
 475.130 -  UInt32 reserved = GetUi32(p + pos);
 475.131 -  pos += 4;
 475.132 -  if (reserved != 0)
 475.133 -    return E_NOTIMPL;
 475.134 -  if (pos + 2 > _remSize)
 475.135 -    return E_NOTIMPL;
 475.136 -  UInt32 validSize = GetUi16(p + pos);
 475.137 -  pos += 2;
 475.138 -  Byte *validData = p + pos;
 475.139 -  if (pos + validSize != _remSize)
 475.140 -    return E_NOTIMPL;
 475.141 -
 475.142 -  if (!_aesFilter)
 475.143 -    _aesFilter = new CAesCbcDecoder;
 475.144 -
 475.145 -  CMyComPtr<ICryptoProperties> cp;
 475.146 -  RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
 475.147 -  {
 475.148 -    RINOK(cp->SetKey(_key.MasterKey, _key.KeySize));
 475.149 -    RINOK(cp->SetInitVector(_iv, 16));
 475.150 -    _aesFilter->Init();
 475.151 -    if (_aesFilter->Filter(rd, rdSize) != rdSize)
 475.152 -      return E_NOTIMPL;
 475.153 -  }
 475.154 -
 475.155 -  Byte fileKey[32];
 475.156 -  NSha1::CContext sha;
 475.157 -  sha.Init();
 475.158 -  sha.Update(_iv, 16);
 475.159 -  sha.Update(rd, rdSize - 16); // we don't use last 16 bytes (PAD bytes)
 475.160 -  DeriveKey(sha, fileKey);
 475.161 -  
 475.162 -  RINOK(cp->SetKey(fileKey, _key.KeySize));
 475.163 -  RINOK(cp->SetInitVector(_iv, 16));
 475.164 -  _aesFilter->Init();
 475.165 -  if (_aesFilter->Filter(validData, validSize) != validSize)
 475.166 -    return E_NOTIMPL;
 475.167 -
 475.168 -  if (validSize < 4)
 475.169 -    return E_NOTIMPL;
 475.170 -  validSize -= 4;
 475.171 -  if (GetUi32(validData + validSize) != CrcCalc(validData, validSize))
 475.172 -    return S_OK;
 475.173 -  passwOK = true;
 475.174 -  _aesFilter->Init();
 475.175 -  return S_OK;
 475.176 -}
 475.177 -
 475.178 -STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
 475.179 -{
 475.180 -  return _aesFilter->Filter(data, size);
 475.181 -}
 475.182 -
 475.183 -}}
   476.1 --- a/src/win32/7zip/7z/CPP/7zip/Crypto/ZipStrong.h	Sat Mar 03 10:54:39 2012 -0600
   476.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   476.3 @@ -1,53 +0,0 @@
   476.4 -// Crypto/ZipStrong.h
   476.5 -
   476.6 -#ifndef __CRYPTO_ZIP_STRONG_H
   476.7 -#define __CRYPTO_ZIP_STRONG_H
   476.8 -
   476.9 -#include "Common/MyCom.h"
  476.10 -#include "Common/Buffer.h"
  476.11 -
  476.12 -#include "../ICoder.h"
  476.13 -#include "../IPassword.h"
  476.14 -
  476.15 -namespace NCrypto {
  476.16 -namespace NZipStrong {
  476.17 -
  476.18 -struct CKeyInfo
  476.19 -{
  476.20 -  Byte MasterKey[32];
  476.21 -  UInt32 KeySize;
  476.22 -  void SetPassword(const Byte *data, UInt32 size);
  476.23 -};
  476.24 -
  476.25 -class CBaseCoder:
  476.26 -  public ICompressFilter,
  476.27 -  public ICryptoSetPassword,
  476.28 -  public CMyUnknownImp
  476.29 -{
  476.30 -protected:
  476.31 -  CKeyInfo _key;
  476.32 -  CMyComPtr<ICompressFilter> _aesFilter;
  476.33 -  CByteBuffer _buf;
  476.34 -public:
  476.35 -  STDMETHOD(Init)();
  476.36 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
  476.37 -  
  476.38 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
  476.39 -};
  476.40 -
  476.41 -class CDecoder:
  476.42 -  public CBaseCoder
  476.43 -{
  476.44 -  UInt32 _ivSize;
  476.45 -  Byte _iv[16];
  476.46 -  UInt32 _remSize;
  476.47 -public:
  476.48 -  MY_UNKNOWN_IMP1(ICryptoSetPassword)
  476.49 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
  476.50 -  HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize);
  476.51 -  HRESULT CheckPassword(bool &passwOK);
  476.52 -};
  476.53 -
  476.54 -}}
  476.55 -
  476.56 -#endif
   477.1 --- a/src/win32/7zip/7z/CPP/7zip/ICoder.h	Sat Mar 03 10:54:39 2012 -0600
   477.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   477.3 @@ -1,186 +0,0 @@
   477.4 -// ICoder.h
   477.5 -
   477.6 -#ifndef __ICODER_H
   477.7 -#define __ICODER_H
   477.8 -
   477.9 -#include "IStream.h"
  477.10 -
  477.11 -#define CODER_INTERFACE(i, x) DECL_INTERFACE(i, 4, x)
  477.12 -
  477.13 -CODER_INTERFACE(ICompressProgressInfo, 0x04)
  477.14 -{
  477.15 -  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;
  477.16 -};
  477.17 -
  477.18 -CODER_INTERFACE(ICompressCoder, 0x05)
  477.19 -{
  477.20 -  STDMETHOD(Code)(ISequentialInStream *inStream,
  477.21 -      ISequentialOutStream *outStream,
  477.22 -      const UInt64 *inSize,
  477.23 -      const UInt64 *outSize,
  477.24 -      ICompressProgressInfo *progress) PURE;
  477.25 -};
  477.26 -
  477.27 -CODER_INTERFACE(ICompressCoder2, 0x18)
  477.28 -{
  477.29 -  STDMETHOD(Code)(ISequentialInStream **inStreams,
  477.30 -      const UInt64 **inSizes,
  477.31 -      UInt32 numInStreams,
  477.32 -      ISequentialOutStream **outStreams,
  477.33 -      const UInt64 **outSizes,
  477.34 -      UInt32 numOutStreams,
  477.35 -      ICompressProgressInfo *progress) PURE;
  477.36 -};
  477.37 -
  477.38 -namespace NCoderPropID
  477.39 -{
  477.40 -  enum EEnum
  477.41 -  {
  477.42 -    kDictionarySize = 0x400,
  477.43 -    kUsedMemorySize,
  477.44 -    kOrder,
  477.45 -    kBlockSize,
  477.46 -    kPosStateBits = 0x440,
  477.47 -    kLitContextBits,
  477.48 -    kLitPosBits,
  477.49 -    kNumFastBytes = 0x450,
  477.50 -    kMatchFinder,
  477.51 -    kMatchFinderCycles,
  477.52 -    kNumPasses = 0x460,
  477.53 -    kAlgorithm = 0x470,
  477.54 -    kMultiThread = 0x480,
  477.55 -    kNumThreads,
  477.56 -    kEndMarker = 0x490
  477.57 -  };
  477.58 -}
  477.59 -
  477.60 -CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
  477.61 -{
  477.62 -  STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
  477.63 -      const PROPVARIANT *properties, UInt32 numProperties) PURE;
  477.64 -};
  477.65 -
  477.66 -/*
  477.67 -CODER_INTERFACE(ICompressSetCoderProperties, 0x21)
  477.68 -{
  477.69 -  STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
  477.70 -};
  477.71 -*/
  477.72 -
  477.73 -CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)
  477.74 -{
  477.75 -  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;
  477.76 -};
  477.77 -
  477.78 -CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)
  477.79 -{
  477.80 -  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStreams) PURE;
  477.81 -};
  477.82 -
  477.83 -CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)
  477.84 -{
  477.85 -  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;
  477.86 -};
  477.87 -
  477.88 -CODER_INTERFACE(ICompressSetCoderMt, 0x25)
  477.89 -{
  477.90 -  STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;
  477.91 -};
  477.92 -
  477.93 -CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
  477.94 -{
  477.95 -  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;
  477.96 -};
  477.97 -
  477.98 -CODER_INTERFACE(ICompressSetInStream, 0x31)
  477.99 -{
 477.100 -  STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
 477.101 -  STDMETHOD(ReleaseInStream)() PURE;
 477.102 -};
 477.103 -
 477.104 -CODER_INTERFACE(ICompressSetOutStream, 0x32)
 477.105 -{
 477.106 -  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
 477.107 -  STDMETHOD(ReleaseOutStream)() PURE;
 477.108 -};
 477.109 -
 477.110 -CODER_INTERFACE(ICompressSetInStreamSize, 0x33)
 477.111 -{
 477.112 -  STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;
 477.113 -};
 477.114 -
 477.115 -CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
 477.116 -{
 477.117 -  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
 477.118 -};
 477.119 -
 477.120 -CODER_INTERFACE(ICompressFilter, 0x40)
 477.121 -{
 477.122 -  STDMETHOD(Init)() PURE;
 477.123 -  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
 477.124 -  // Filter return outSize (UInt32)
 477.125 -  // if (outSize <= size): Filter have converted outSize bytes
 477.126 -  // if (outSize > size): Filter have not converted anything.
 477.127 -  //      and it needs at least outSize bytes to convert one block
 477.128 -  //      (it's for crypto block algorithms).
 477.129 -};
 477.130 -
 477.131 -CODER_INTERFACE(ICompressCodecsInfo, 0x60)
 477.132 -{
 477.133 -  STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods) PURE;
 477.134 -  STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
 477.135 -  STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder) PURE;
 477.136 -  STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder) PURE;
 477.137 -};
 477.138 -CODER_INTERFACE(ISetCompressCodecsInfo, 0x61)
 477.139 -{
 477.140 -  STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo) PURE;
 477.141 -};
 477.142 -
 477.143 -CODER_INTERFACE(ICryptoProperties, 0x80)
 477.144 -{
 477.145 -  STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;
 477.146 -  STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;
 477.147 -};
 477.148 -
 477.149 -/*
 477.150 -CODER_INTERFACE(ICryptoResetSalt, 0x88)
 477.151 -{
 477.152 -  STDMETHOD(ResetSalt)() PURE;
 477.153 -};
 477.154 -*/
 477.155 -
 477.156 -CODER_INTERFACE(ICryptoResetInitVector, 0x8C)
 477.157 -{
 477.158 -  STDMETHOD(ResetInitVector)() PURE;
 477.159 -};
 477.160 -
 477.161 -CODER_INTERFACE(ICryptoSetPassword, 0x90)
 477.162 -{
 477.163 -  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;
 477.164 -};
 477.165 -
 477.166 -CODER_INTERFACE(ICryptoSetCRC, 0xA0)
 477.167 -{
 477.168 -  STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;
 477.169 -};
 477.170 -
 477.171 -//////////////////////
 477.172 -// It's for DLL file
 477.173 -namespace NMethodPropID
 477.174 -{
 477.175 -  enum EEnum
 477.176 -  {
 477.177 -    kID,
 477.178 -    kName,
 477.179 -    kDecoder,
 477.180 -    kEncoder,
 477.181 -    kInStreams,
 477.182 -    kOutStreams,
 477.183 -    kDescription,
 477.184 -    kDecoderIsAssigned,
 477.185 -    kEncoderIsAssigned
 477.186 -  };
 477.187 -}
 477.188 -
 477.189 -#endif
   478.1 --- a/src/win32/7zip/7z/CPP/7zip/IDecl.h	Sat Mar 03 10:54:39 2012 -0600
   478.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   478.3 @@ -1,15 +0,0 @@
   478.4 -// IDecl.h
   478.5 -
   478.6 -#ifndef __IDECL_H
   478.7 -#define __IDECL_H
   478.8 -
   478.9 -#include "../Common/MyUnknown.h"
  478.10 -
  478.11 -#define DECL_INTERFACE_SUB(i, base, groupId, subId) \
  478.12 -DEFINE_GUID(IID_ ## i, \
  478.13 -0x23170F69, 0x40C1, 0x278A, 0, 0, 0, (groupId), 0, (subId), 0, 0); \
  478.14 -struct i: public base
  478.15 -
  478.16 -#define DECL_INTERFACE(i, groupId, subId) DECL_INTERFACE_SUB(i, IUnknown, groupId, subId)
  478.17 -
  478.18 -#endif
   479.1 --- a/src/win32/7zip/7z/CPP/7zip/IPassword.h	Sat Mar 03 10:54:39 2012 -0600
   479.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   479.3 @@ -1,24 +0,0 @@
   479.4 -// IPassword.h
   479.5 -
   479.6 -#ifndef __IPASSWORD_H
   479.7 -#define __IPASSWORD_H
   479.8 -
   479.9 -#include "../Common/MyUnknown.h"
  479.10 -#include "../Common/Types.h"
  479.11 -
  479.12 -#include "IDecl.h"
  479.13 -
  479.14 -#define PASSWORD_INTERFACE(i, x) DECL_INTERFACE(i, 5, x)
  479.15 -
  479.16 -PASSWORD_INTERFACE(ICryptoGetTextPassword, 0x10)
  479.17 -{
  479.18 -  STDMETHOD(CryptoGetTextPassword)(BSTR *password) PURE;
  479.19 -};
  479.20 -
  479.21 -PASSWORD_INTERFACE(ICryptoGetTextPassword2, 0x11)
  479.22 -{
  479.23 -  STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password) PURE;
  479.24 -};
  479.25 -
  479.26 -#endif
  479.27 -
   480.1 --- a/src/win32/7zip/7z/CPP/7zip/IProgress.h	Sat Mar 03 10:54:39 2012 -0600
   480.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   480.3 @@ -1,33 +0,0 @@
   480.4 -// Interface/IProgress.h
   480.5 -
   480.6 -#ifndef __IPROGRESS_H
   480.7 -#define __IPROGRESS_H
   480.8 -
   480.9 -#include "../Common/MyUnknown.h"
  480.10 -#include "../Common/Types.h"
  480.11 -
  480.12 -#include "IDecl.h"
  480.13 -
  480.14 -#define INTERFACE_IProgress(x) \
  480.15 -  STDMETHOD(SetTotal)(UInt64 total) x; \
  480.16 -  STDMETHOD(SetCompleted)(const UInt64 *completeValue) x; \
  480.17 -
  480.18 -DECL_INTERFACE(IProgress, 0, 5)
  480.19 -{
  480.20 -  INTERFACE_IProgress(PURE)
  480.21 -};
  480.22 -
  480.23 -/*
  480.24 -// {23170F69-40C1-278A-0000-000000050002}
  480.25 -DEFINE_GUID(IID_IProgress2,
  480.26 -0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02);
  480.27 -MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050002")
  480.28 -IProgress2: public IUnknown
  480.29 -{
  480.30 -public:
  480.31 -  STDMETHOD(SetTotal)(const UInt64 *total) PURE;
  480.32 -  STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE;
  480.33 -};
  480.34 -*/
  480.35 -
  480.36 -#endif
   481.1 --- a/src/win32/7zip/7z/CPP/7zip/IStream.h	Sat Mar 03 10:54:39 2012 -0600
   481.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   481.3 @@ -1,58 +0,0 @@
   481.4 -// IStream.h
   481.5 -
   481.6 -#ifndef __ISTREAM_H
   481.7 -#define __ISTREAM_H
   481.8 -
   481.9 -#include "../Common/MyUnknown.h"
  481.10 -#include "../Common/Types.h"
  481.11 -
  481.12 -#include "IDecl.h"
  481.13 -
  481.14 -#define STREAM_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 3, x)
  481.15 -#define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)
  481.16 -
  481.17 -STREAM_INTERFACE(ISequentialInStream, 0x01)
  481.18 -{
  481.19 -  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;
  481.20 -  /*
  481.21 -  Out: if size != 0, return_value = S_OK and (*processedSize == 0),
  481.22 -    then there are no more bytes in stream.
  481.23 -  if (size > 0) && there are bytes in stream,
  481.24 -  this function must read at least 1 byte.
  481.25 -  This function is allowed to read less than number of remaining bytes in stream.
  481.26 -  You must call Read function in loop, if you need exact amount of data
  481.27 -  */
  481.28 -};
  481.29 -
  481.30 -STREAM_INTERFACE(ISequentialOutStream, 0x02)
  481.31 -{
  481.32 -  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;
  481.33 -  /*
  481.34 -  if (size > 0) this function must write at least 1 byte.
  481.35 -  This function is allowed to write less than "size".
  481.36 -  You must call Write function in loop, if you need to write exact amount of data
  481.37 -  */
  481.38 -};
  481.39 -
  481.40 -STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
  481.41 -{
  481.42 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
  481.43 -};
  481.44 -
  481.45 -STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
  481.46 -{
  481.47 -  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
  481.48 -  STDMETHOD(SetSize)(Int64 newSize) PURE;
  481.49 -};
  481.50 -
  481.51 -STREAM_INTERFACE(IStreamGetSize, 0x06)
  481.52 -{
  481.53 -  STDMETHOD(GetSize)(UInt64 *size) PURE;
  481.54 -};
  481.55 -
  481.56 -STREAM_INTERFACE(IOutStreamFlush, 0x07)
  481.57 -{
  481.58 -  STDMETHOD(Flush)() PURE;
  481.59 -};
  481.60 -
  481.61 -#endif
   482.1 --- a/src/win32/7zip/7z/CPP/7zip/PropID.h	Sat Mar 03 10:54:39 2012 -0600
   482.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   482.3 @@ -1,69 +0,0 @@
   482.4 -// PropID.h
   482.5 -
   482.6 -#ifndef __7ZIP_PROPID_H
   482.7 -#define __7ZIP_PROPID_H
   482.8 -
   482.9 -enum
  482.10 -{
  482.11 -  kpidNoProperty = 0,
  482.12 -  
  482.13 -  kpidHandlerItemIndex = 2,
  482.14 -  kpidPath,
  482.15 -  kpidName,
  482.16 -  kpidExtension,
  482.17 -  kpidIsDir,
  482.18 -  kpidSize,
  482.19 -  kpidPackSize,
  482.20 -  kpidAttrib,
  482.21 -  kpidCTime,
  482.22 -  kpidATime,
  482.23 -  kpidMTime,
  482.24 -  kpidSolid,
  482.25 -  kpidCommented,
  482.26 -  kpidEncrypted,
  482.27 -  kpidSplitBefore,
  482.28 -  kpidSplitAfter,
  482.29 -  kpidDictionarySize,
  482.30 -  kpidCRC,
  482.31 -  kpidType,
  482.32 -  kpidIsAnti,
  482.33 -  kpidMethod,
  482.34 -  kpidHostOS,
  482.35 -  kpidFileSystem,
  482.36 -  kpidUser,
  482.37 -  kpidGroup,
  482.38 -  kpidBlock,
  482.39 -  kpidComment,
  482.40 -  kpidPosition,
  482.41 -  kpidPrefix,
  482.42 -  kpidNumSubDirs,
  482.43 -  kpidNumSubFiles,
  482.44 -  kpidUnpackVer,
  482.45 -  kpidVolume,
  482.46 -  kpidIsVolume,
  482.47 -  kpidOffset,
  482.48 -  kpidLinks,
  482.49 -  kpidNumBlocks,
  482.50 -  kpidNumVolumes,
  482.51 -  kpidTimeType,
  482.52 -  kpidBit64,
  482.53 -  kpidBigEndian,
  482.54 -  kpidCpu,
  482.55 -  kpidPhySize,
  482.56 -  kpidHeadersSize,
  482.57 -  kpidChecksum,
  482.58 -  kpidCharacts,
  482.59 -  kpidVa,
  482.60 -
  482.61 -  kpidTotalSize = 0x1100,
  482.62 -  kpidFreeSpace,
  482.63 -  kpidClusterSize,
  482.64 -  kpidVolumeName,
  482.65 -
  482.66 -  kpidLocalName = 0x1200,
  482.67 -  kpidProvider,
  482.68 -
  482.69 -  kpidUserDefined = 0x10000
  482.70 -};
  482.71 -
  482.72 -#endif
   483.1 --- a/src/win32/7zip/7z/CPP/Common/Buffer.h	Sat Mar 03 10:54:39 2012 -0600
   483.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   483.3 @@ -1,77 +0,0 @@
   483.4 -// Common/Buffer.h
   483.5 -
   483.6 -#ifndef __COMMON_BUFFER_H
   483.7 -#define __COMMON_BUFFER_H
   483.8 -
   483.9 -#include "Defs.h"
  483.10 -
  483.11 -template <class T> class CBuffer
  483.12 -{
  483.13 -protected:
  483.14 -  size_t _capacity;
  483.15 -  T *_items;
  483.16 -public:
  483.17 -  void Free()
  483.18 -  {
  483.19 -    delete []_items;
  483.20 -    _items = 0;
  483.21 -    _capacity = 0;
  483.22 -  }
  483.23 -  CBuffer(): _capacity(0), _items(0) {};
  483.24 -  CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; }
  483.25 -  CBuffer(size_t size): _items(0),  _capacity(0) {  SetCapacity(size); }
  483.26 -  virtual ~CBuffer() { delete []_items; }
  483.27 -  operator T *() { return _items; };
  483.28 -  operator const T *() const { return _items; };
  483.29 -  size_t GetCapacity() const { return  _capacity; }
  483.30 -  void SetCapacity(size_t newCapacity)
  483.31 -  {
  483.32 -    if (newCapacity == _capacity)
  483.33 -      return;
  483.34 -    T *newBuffer;
  483.35 -    if (newCapacity > 0)
  483.36 -    {
  483.37 -      newBuffer = new T[newCapacity];
  483.38 -      if (_capacity > 0)
  483.39 -        memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
  483.40 -    }
  483.41 -    else
  483.42 -      newBuffer = 0;
  483.43 -    delete []_items;
  483.44 -    _items = newBuffer;
  483.45 -    _capacity = newCapacity;
  483.46 -  }
  483.47 -  CBuffer& operator=(const CBuffer &buffer)
  483.48 -  {
  483.49 -    Free();
  483.50 -    if (buffer._capacity > 0)
  483.51 -    {
  483.52 -      SetCapacity(buffer._capacity);
  483.53 -      memmove(_items, buffer._items, buffer._capacity * sizeof(T));
  483.54 -    }
  483.55 -    return *this;
  483.56 -  }
  483.57 -};
  483.58 -
  483.59 -template <class T>
  483.60 -bool operator==(const CBuffer<T>& b1, const CBuffer<T>& b2)
  483.61 -{
  483.62 -  if (b1.GetCapacity() != b2.GetCapacity())
  483.63 -    return false;
  483.64 -  for (size_t i = 0; i < b1.GetCapacity(); i++)
  483.65 -    if (b1[i] != b2[i])
  483.66 -      return false;
  483.67 -  return true;
  483.68 -}
  483.69 -
  483.70 -template <class T>
  483.71 -bool operator!=(const CBuffer<T>& b1, const CBuffer<T>& b2)
  483.72 -{
  483.73 -  return !(b1 == b2);
  483.74 -}
  483.75 -
  483.76 -typedef CBuffer<char> CCharBuffer;
  483.77 -typedef CBuffer<wchar_t> CWCharBuffer;
  483.78 -typedef CBuffer<unsigned char> CByteBuffer;
  483.79 -
  483.80 -#endif
   484.1 --- a/src/win32/7zip/7z/CPP/Common/CRC.cpp	Sat Mar 03 10:54:39 2012 -0600
   484.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   484.3 @@ -1,10 +0,0 @@
   484.4 -// Common/CRC.cpp
   484.5 -
   484.6 -#include "StdAfx.h"
   484.7 -
   484.8 -extern "C"
   484.9 -{
  484.10 -#include "../../C/7zCrc.h"
  484.11 -}
  484.12 -
  484.13 -struct CCRCTableInit { CCRCTableInit() { CrcGenerateTable(); } } g_CRCTableInit;
   485.1 --- a/src/win32/7zip/7z/CPP/Common/ComTry.h	Sat Mar 03 10:54:39 2012 -0600
   485.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   485.3 @@ -1,17 +0,0 @@
   485.4 -// ComTry.h
   485.5 -
   485.6 -#ifndef __COM_TRY_H
   485.7 -#define __COM_TRY_H
   485.8 -
   485.9 -#include "MyWindows.h"
  485.10 -// #include "Exception.h"
  485.11 -// #include "NewHandler.h"
  485.12 -
  485.13 -#define COM_TRY_BEGIN try {
  485.14 -#define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; }
  485.15 -  
  485.16 -  // catch(const CNewException &) { return E_OUTOFMEMORY; }\
  485.17 -  // catch(const CSystemException &e) { return e.ErrorCode; }\
  485.18 -  // catch(...) { return E_FAIL; }
  485.19 -
  485.20 -#endif
   486.1 --- a/src/win32/7zip/7z/CPP/Common/Defs.h	Sat Mar 03 10:54:39 2012 -0600
   486.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   486.3 @@ -1,20 +0,0 @@
   486.4 -// Common/Defs.h
   486.5 -
   486.6 -#ifndef __COMMON_DEFS_H
   486.7 -#define __COMMON_DEFS_H
   486.8 -
   486.9 -template <class T> inline T MyMin(T a, T b)
  486.10 -  {  return a < b ? a : b; }
  486.11 -template <class T> inline T MyMax(T a, T b)
  486.12 -  {  return a > b ? a : b; }
  486.13 -
  486.14 -template <class T> inline int MyCompare(T a, T b)
  486.15 -  {  return a < b ? -1 : (a == b ? 0 : 1); }
  486.16 -
  486.17 -inline int BoolToInt(bool value)
  486.18 -  { return (value ? 1: 0); }
  486.19 -
  486.20 -inline bool IntToBool(int value)
  486.21 -  { return (value != 0); }
  486.22 -
  486.23 -#endif
   487.1 --- a/src/win32/7zip/7z/CPP/Common/DynamicBuffer.h	Sat Mar 03 10:54:39 2012 -0600
   487.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   487.3 @@ -1,47 +0,0 @@
   487.4 -// Common/DynamicBuffer.h
   487.5 -
   487.6 -#ifndef __COMMON_DYNAMICBUFFER_H
   487.7 -#define __COMMON_DYNAMICBUFFER_H
   487.8 -
   487.9 -#include "Buffer.h"
  487.10 -
  487.11 -template <class T> class CDynamicBuffer: public CBuffer<T>
  487.12 -{
  487.13 -  void GrowLength(size_t size)
  487.14 -  {
  487.15 -    size_t delta;
  487.16 -    if (this->_capacity > 64)
  487.17 -      delta = this->_capacity / 4;
  487.18 -    else if (this->_capacity > 8)
  487.19 -      delta = 16;
  487.20 -    else
  487.21 -      delta = 4;
  487.22 -    delta = MyMax(delta, size);
  487.23 -    SetCapacity(this->_capacity + delta);
  487.24 -  }
  487.25 -public:
  487.26 -  CDynamicBuffer(): CBuffer<T>() {};
  487.27 -  CDynamicBuffer(const CDynamicBuffer &buffer): CBuffer<T>(buffer) {};
  487.28 -  CDynamicBuffer(size_t size): CBuffer<T>(size) {};
  487.29 -  CDynamicBuffer& operator=(const CDynamicBuffer &buffer)
  487.30 -  {
  487.31 -    this->Free();
  487.32 -    if (buffer._capacity > 0)
  487.33 -    {
  487.34 -      SetCapacity(buffer._capacity);
  487.35 -      memmove(this->_items, buffer._items, buffer._capacity * sizeof(T));
  487.36 -    }
  487.37 -    return *this;
  487.38 -  }
  487.39 -  void EnsureCapacity(size_t capacity)
  487.40 -  {
  487.41 -    if (this->_capacity < capacity)
  487.42 -      GrowLength(capacity - this->_capacity);
  487.43 -  }
  487.44 -};
  487.45 -
  487.46 -typedef CDynamicBuffer<char> CCharDynamicBuffer;
  487.47 -typedef CDynamicBuffer<wchar_t> CWCharDynamicBuffer;
  487.48 -typedef CDynamicBuffer<unsigned char> CByteDynamicBuffer;
  487.49 -
  487.50 -#endif
   488.1 --- a/src/win32/7zip/7z/CPP/Common/InitializeStaticLib.h	Sat Mar 03 10:54:39 2012 -0600
   488.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   488.3 @@ -1,29 +0,0 @@
   488.4 -// Common/InitializeStaticLib.h
   488.5 -//
   488.6 -// it's necessary to include this from one cpp file in order to use 7zip as a static library,
   488.7 -// otherwise the linker will optimize away some important internals of 7zip.
   488.8 -
   488.9 -#ifndef __COMMON_INITIALIZESTATICLIB_H
  488.10 -#define __COMMON_INITIALIZESTATICLIB_H
  488.11 -
  488.12 -#define FORCE_REF(dec, var) extern dec var; void* var##ref = (void*)&var;
  488.13 -
  488.14 -#include "../7zip/Common/DeclareCodecs.h"
  488.15 -#include "../7zip/Common/DeclareArcs.h"
  488.16 -
  488.17 -FORCE_REF(struct CCRCTableInit, g_CRCTableInit)
  488.18 -
  488.19 -
  488.20 -// these don't seem to be necessary with my compiler,
  488.21 -// but they're here in case a different compiler more aggressively strips out unreferenced code
  488.22 -FORCE_REF(class CBZip2CrcTableInit, g_BZip2CrcTableInit)
  488.23 -namespace NCrypto { struct CAesTabInit; FORCE_REF(CAesTabInit, g_AesTabInit) }
  488.24 -namespace NBitl { struct CInverterTableInitializer; FORCE_REF(CInverterTableInitializer, g_InverterTableInitializer) }
  488.25 -namespace NCompress { namespace NRar3 { class CDistInit; FORCE_REF(CDistInit, g_DistInit) }}
  488.26 -namespace NArchive { namespace NLzh { class CCRCTableInit; FORCE_REF(CCRCTableInit, g_CRCTableInit) }}
  488.27 -namespace NArchive { namespace N7z { class SignatureInitializer; FORCE_REF(SignatureInitializer, g_SignatureInitializer) }}
  488.28 -namespace NArchive{ namespace NRar{ namespace NHeader{ class CMarkerInitializer; FORCE_REF(CMarkerInitializer, g_MarkerInitializer) }}}
  488.29 -namespace NArchive { namespace NZip { namespace NSignature{ class CMarkersInitializer; FORCE_REF(CMarkersInitializer, g_MarkerInitializer) }}}
  488.30 -
  488.31 -
  488.32 -#endif
   489.1 --- a/src/win32/7zip/7z/CPP/Common/IntToString.cpp	Sat Mar 03 10:54:39 2012 -0600
   489.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   489.3 @@ -1,63 +0,0 @@
   489.4 -// Common/IntToString.cpp
   489.5 -
   489.6 -#include "StdAfx.h"
   489.7 -
   489.8 -#include "IntToString.h"
   489.9 -
  489.10 -void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base)
  489.11 -{
  489.12 -  if (base < 2 || base > 36)
  489.13 -  {
  489.14 -    *s = '\0';
  489.15 -    return;
  489.16 -  }
  489.17 -  char temp[72];
  489.18 -  int pos = 0;
  489.19 -  do
  489.20 -  {
  489.21 -    int delta = (int)(value % base);
  489.22 -    temp[pos++] = (char)((delta < 10) ? ('0' + delta) : ('a' + (delta - 10)));
  489.23 -    value /= base;
  489.24 -  }
  489.25 -  while (value != 0);
  489.26 -  do
  489.27 -    *s++ = temp[--pos];
  489.28 -  while (pos > 0);
  489.29 -  *s = '\0';
  489.30 -}
  489.31 -
  489.32 -void ConvertUInt64ToString(UInt64 value, wchar_t *s)
  489.33 -{
  489.34 -  wchar_t temp[32];
  489.35 -  int pos = 0;
  489.36 -  do
  489.37 -  {
  489.38 -    temp[pos++] = (wchar_t)(L'0' + (int)(value % 10));
  489.39 -    value /= 10;
  489.40 -  }
  489.41 -  while (value != 0);
  489.42 -  do
  489.43 -    *s++ = temp[--pos];
  489.44 -  while (pos > 0);
  489.45 -  *s = L'\0';
  489.46 -}
  489.47 -
  489.48 -void ConvertInt64ToString(Int64 value, char *s)
  489.49 -{
  489.50 -  if (value < 0)
  489.51 -  {
  489.52 -    *s++ = '-';
  489.53 -    value = -value;
  489.54 -  }
  489.55 -  ConvertUInt64ToString(value, s);
  489.56 -}
  489.57 -
  489.58 -void ConvertInt64ToString(Int64 value, wchar_t *s)
  489.59 -{
  489.60 -  if (value < 0)
  489.61 -  {
  489.62 -    *s++ = L'-';
  489.63 -    value = -value;
  489.64 -  }
  489.65 -  ConvertUInt64ToString(value, s);
  489.66 -}
   490.1 --- a/src/win32/7zip/7z/CPP/Common/IntToString.h	Sat Mar 03 10:54:39 2012 -0600
   490.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   490.3 @@ -1,15 +0,0 @@
   490.4 -// Common/IntToString.h
   490.5 -
   490.6 -#ifndef __COMMON_INTTOSTRING_H
   490.7 -#define __COMMON_INTTOSTRING_H
   490.8 -
   490.9 -#include <stddef.h>
  490.10 -#include "Types.h"
  490.11 -
  490.12 -void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base = 10);
  490.13 -void ConvertUInt64ToString(UInt64 value, wchar_t *s);
  490.14 -
  490.15 -void ConvertInt64ToString(Int64 value, char *s);
  490.16 -void ConvertInt64ToString(Int64 value, wchar_t *s);
  490.17 -
  490.18 -#endif
   491.1 --- a/src/win32/7zip/7z/CPP/Common/MyCom.h	Sat Mar 03 10:54:39 2012 -0600
   491.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   491.3 @@ -1,225 +0,0 @@
   491.4 -// MyCom.h
   491.5 -
   491.6 -#ifndef __MYCOM_H
   491.7 -#define __MYCOM_H
   491.8 -
   491.9 -#include "MyWindows.h"
  491.10 -
  491.11 -#ifndef RINOK
  491.12 -#define RINOK(x) { HRESULT __result_ = (x); if (__result_ != S_OK) return __result_; }
  491.13 -#endif
  491.14 -
  491.15 -template <class T>
  491.16 -class CMyComPtr
  491.17 -{
  491.18 -  T* _p;
  491.19 -public:
  491.20 -  // typedef T _PtrClass;
  491.21 -  CMyComPtr() { _p = NULL;}
  491.22 -  CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }
  491.23 -  CMyComPtr(const CMyComPtr<T>& lp)
  491.24 -  {
  491.25 -    if ((_p = lp._p) != NULL)
  491.26 -      _p->AddRef();
  491.27 -  }
  491.28 -  ~CMyComPtr() { if (_p) _p->Release(); }
  491.29 -  void Release() { if (_p) { _p->Release(); _p = NULL; } }
  491.30 -  operator T*() const {  return (T*)_p;  }
  491.31 -  // T& operator*() const {  return *_p; }
  491.32 -  T** operator&() { return &_p; }
  491.33 -  T* operator->() const { return _p; }
  491.34 -  T* operator=(T* p)
  491.35 -  {
  491.36 -    if (p != 0)
  491.37 -      p->AddRef();
  491.38 -    if (_p)
  491.39 -      _p->Release();
  491.40 -    _p = p;
  491.41 -    return p;
  491.42 -  }
  491.43 -  T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
  491.44 -  bool operator!() const { return (_p == NULL); }
  491.45 -  // bool operator==(T* pT) const {  return _p == pT; }
  491.46 -  // Compare two objects for equivalence
  491.47 -  void Attach(T* p2)
  491.48 -  {
  491.49 -    Release();
  491.50 -    _p = p2;
  491.51 -  }
  491.52 -  T* Detach()
  491.53 -  {
  491.54 -    T* pt = _p;
  491.55 -    _p = NULL;
  491.56 -    return pt;
  491.57 -  }
  491.58 -  #ifdef _WIN32
  491.59 -  HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  491.60 -  {
  491.61 -    return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
  491.62 -  }
  491.63 -  #endif
  491.64 -  /*
  491.65 -  HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  491.66 -  {
  491.67 -    CLSID clsid;
  491.68 -    HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
  491.69 -    ATLASSERT(_p == NULL);
  491.70 -    if (SUCCEEDED(hr))
  491.71 -      hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
  491.72 -    return hr;
  491.73 -  }
  491.74 -  */
  491.75 -  template <class Q>
  491.76 -  HRESULT QueryInterface(REFGUID iid, Q** pp) const
  491.77 -  {
  491.78 -    return _p->QueryInterface(iid, (void**)pp);
  491.79 -  }
  491.80 -};
  491.81 -
  491.82 -//////////////////////////////////////////////////////////
  491.83 -
  491.84 -inline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr)
  491.85 -{
  491.86 -  *bstr = ::SysAllocString(src);
  491.87 -  return (*bstr != 0) ? S_OK : E_OUTOFMEMORY;
  491.88 -}
  491.89 -
  491.90 -class CMyComBSTR
  491.91 -{
  491.92 -public:
  491.93 -  BSTR m_str;
  491.94 -  CMyComBSTR(): m_str(NULL) {}
  491.95 -  CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }
  491.96 -  // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
  491.97 -  // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize);  }
  491.98 -  CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
  491.99 -  /*
 491.100 -  CMyComBSTR(REFGUID src)
 491.101 -  {
 491.102 -    LPOLESTR szGuid;
 491.103 -    StringFromCLSID(src, &szGuid);
 491.104 -    m_str = ::SysAllocString(szGuid);
 491.105 -    CoTaskMemFree(szGuid);
 491.106 -  }
 491.107 -  */
 491.108 -  ~CMyComBSTR() { ::SysFreeString(m_str); }
 491.109 -  CMyComBSTR& operator=(const CMyComBSTR& src)
 491.110 -  {
 491.111 -    if (m_str != src.m_str)
 491.112 -    {
 491.113 -      if (m_str)
 491.114 -        ::SysFreeString(m_str);
 491.115 -      m_str = src.MyCopy();
 491.116 -    }
 491.117 -    return *this;
 491.118 -  }
 491.119 -  CMyComBSTR& operator=(LPCOLESTR src)
 491.120 -  {
 491.121 -    ::SysFreeString(m_str);
 491.122 -    m_str = ::SysAllocString(src);
 491.123 -    return *this;
 491.124 -  }
 491.125 -  unsigned int Length() const { return ::SysStringLen(m_str); }
 491.126 -  operator BSTR() const { return m_str; }
 491.127 -  BSTR* operator&() { return &m_str; }
 491.128 -  BSTR MyCopy() const
 491.129 -  {
 491.130 -    int byteLen = ::SysStringByteLen(m_str);
 491.131 -    BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
 491.132 -    memcpy(res, m_str, byteLen);
 491.133 -    return res;
 491.134 -  }
 491.135 -  /*
 491.136 -  void Attach(BSTR src) { m_str = src; }
 491.137 -  BSTR Detach()
 491.138 -  {
 491.139 -    BSTR s = m_str;
 491.140 -    m_str = NULL;
 491.141 -    return s;
 491.142 -  }
 491.143 -  */
 491.144 -  void Empty()
 491.145 -  {
 491.146 -    ::SysFreeString(m_str);
 491.147 -    m_str = NULL;
 491.148 -  }
 491.149 -  bool operator!() const {  return (m_str == NULL); }
 491.150 -};
 491.151 -
 491.152 -//////////////////////////////////////////////////////////
 491.153 -
 491.154 -class CMyUnknownImp
 491.155 -{
 491.156 -public:
 491.157 -  ULONG __m_RefCount;
 491.158 -  CMyUnknownImp(): __m_RefCount(0) {}
 491.159 -};
 491.160 -
 491.161 -#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
 491.162 -    (REFGUID iid, void **outObject) {
 491.163 -
 491.164 -#define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \
 491.165 -    { *outObject = (void *)(i *)this; AddRef(); return S_OK; }
 491.166 -
 491.167 -#define MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) if (iid == IID_IUnknown) \
 491.168 -    { *outObject = (void *)(IUnknown *)(i *)this; AddRef(); return S_OK; }
 491.169 -
 491.170 -#define MY_QUERYINTERFACE_BEGIN2(i) MY_QUERYINTERFACE_BEGIN \
 491.171 -    MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) \
 491.172 -    MY_QUERYINTERFACE_ENTRY(i)
 491.173 -
 491.174 -#define MY_QUERYINTERFACE_END return E_NOINTERFACE; }
 491.175 -
 491.176 -#define MY_ADDREF_RELEASE \
 491.177 -STDMETHOD_(ULONG, AddRef)() { return ++__m_RefCount; } \
 491.178 -STDMETHOD_(ULONG, Release)() { if (--__m_RefCount != 0)  \
 491.179 -  return __m_RefCount; delete this; return 0; }
 491.180 -
 491.181 -#define MY_UNKNOWN_IMP_SPEC(i) \
 491.182 -  MY_QUERYINTERFACE_BEGIN \
 491.183 -  i \
 491.184 -  MY_QUERYINTERFACE_END \
 491.185 -  MY_ADDREF_RELEASE
 491.186 -
 491.187 -
 491.188 -#define MY_UNKNOWN_IMP MY_QUERYINTERFACE_BEGIN \
 491.189 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(IUnknown) \
 491.190 -  MY_QUERYINTERFACE_END \
 491.191 -  MY_ADDREF_RELEASE
 491.192 -
 491.193 -#define MY_UNKNOWN_IMP1(i) MY_UNKNOWN_IMP_SPEC( \
 491.194 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) \
 491.195 -  MY_QUERYINTERFACE_ENTRY(i) \
 491.196 -  )
 491.197 -
 491.198 -#define MY_UNKNOWN_IMP2(i1, i2) MY_UNKNOWN_IMP_SPEC( \
 491.199 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
 491.200 -  MY_QUERYINTERFACE_ENTRY(i1) \
 491.201 -  MY_QUERYINTERFACE_ENTRY(i2) \
 491.202 -  )
 491.203 -
 491.204 -#define MY_UNKNOWN_IMP3(i1, i2, i3) MY_UNKNOWN_IMP_SPEC( \
 491.205 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
 491.206 -  MY_QUERYINTERFACE_ENTRY(i1) \
 491.207 -  MY_QUERYINTERFACE_ENTRY(i2) \
 491.208 -  MY_QUERYINTERFACE_ENTRY(i3) \
 491.209 -  )
 491.210 -
 491.211 -#define MY_UNKNOWN_IMP4(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC( \
 491.212 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
 491.213 -  MY_QUERYINTERFACE_ENTRY(i1) \
 491.214 -  MY_QUERYINTERFACE_ENTRY(i2) \
 491.215 -  MY_QUERYINTERFACE_ENTRY(i3) \
 491.216 -  MY_QUERYINTERFACE_ENTRY(i4) \
 491.217 -  )
 491.218 -
 491.219 -#define MY_UNKNOWN_IMP5(i1, i2, i3, i4, i5) MY_UNKNOWN_IMP_SPEC( \
 491.220 -  MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
 491.221 -  MY_QUERYINTERFACE_ENTRY(i1) \
 491.222 -  MY_QUERYINTERFACE_ENTRY(i2) \
 491.223 -  MY_QUERYINTERFACE_ENTRY(i3) \
 491.224 -  MY_QUERYINTERFACE_ENTRY(i4) \
 491.225 -  MY_QUERYINTERFACE_ENTRY(i5) \
 491.226 -  )
 491.227 -
 491.228 -#endif
   492.1 --- a/src/win32/7zip/7z/CPP/Common/MyException.h	Sat Mar 03 10:54:39 2012 -0600
   492.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   492.3 @@ -1,14 +0,0 @@
   492.4 -// Common/Exception.h
   492.5 -
   492.6 -#ifndef __COMMON_EXCEPTION_H
   492.7 -#define __COMMON_EXCEPTION_H
   492.8 -
   492.9 -#include "MyWindows.h"
  492.10 -
  492.11 -struct CSystemException
  492.12 -{
  492.13 -  HRESULT ErrorCode;
  492.14 -  CSystemException(HRESULT errorCode): ErrorCode(errorCode) {}
  492.15 -};
  492.16 -
  492.17 -#endif
   493.1 --- a/src/win32/7zip/7z/CPP/Common/MyInitGuid.h	Sat Mar 03 10:54:39 2012 -0600
   493.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   493.3 @@ -1,15 +0,0 @@
   493.4 -// Common/MyInitGuid.h
   493.5 -
   493.6 -#ifndef __COMMON_MYINITGUID_H
   493.7 -#define __COMMON_MYINITGUID_H
   493.8 -
   493.9 -#ifdef _WIN32
  493.10 -#include <initguid.h>
  493.11 -#else
  493.12 -#define INITGUID
  493.13 -#include "MyGuidDef.h"
  493.14 -DEFINE_GUID(IID_IUnknown,
  493.15 -0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
  493.16 -#endif
  493.17 -
  493.18 -#endif
   494.1 --- a/src/win32/7zip/7z/CPP/Common/MyMap.cpp	Sat Mar 03 10:54:39 2012 -0600
   494.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   494.3 @@ -1,140 +0,0 @@
   494.4 -// MyMap.cpp
   494.5 -
   494.6 -#include "StdAfx.h"
   494.7 -
   494.8 -#include "MyMap.h"
   494.9 -
  494.10 -static const unsigned kNumBitsMax = sizeof(UInt32) * 8;
  494.11 -
  494.12 -static UInt32 GetSubBits(UInt32 value, unsigned startPos, unsigned numBits)
  494.13 -{
  494.14 -  if (startPos == sizeof(value) * 8)
  494.15 -    return 0;
  494.16 -  value >>= startPos;
  494.17 -  if (numBits == sizeof(value) * 8)
  494.18 -    return value;
  494.19 -  return value & (((UInt32)1 << numBits) - 1);
  494.20 -}
  494.21 -
  494.22 -static inline unsigned GetSubBit(UInt32 v, unsigned n) { return (unsigned)(v >> n) & 1; }
  494.23 -
  494.24 -bool CMap32::Find(UInt32 key, UInt32 &valueRes) const
  494.25 -{
  494.26 -  valueRes = (UInt32)(Int32)-1;
  494.27 -  if (Nodes.Size() == 0)
  494.28 -    return false;
  494.29 -  if (Nodes.Size() == 1)
  494.30 -  {
  494.31 -    const CNode &n = Nodes[0];
  494.32 -    if (n.Len == kNumBitsMax)
  494.33 -    {
  494.34 -      valueRes = n.Values[0];
  494.35 -      return (key == n.Key);
  494.36 -    }
  494.37 -  }
  494.38 -
  494.39 -  int cur = 0;
  494.40 -  unsigned bitPos = kNumBitsMax;
  494.41 -  for (;;)
  494.42 -  {
  494.43 -    const CNode &n = Nodes[cur];
  494.44 -    bitPos -= n.Len;
  494.45 -    if (GetSubBits(key, bitPos, n.Len) != GetSubBits(n.Key, bitPos, n.Len))
  494.46 -      return false;
  494.47 -    unsigned bit = GetSubBit(key, --bitPos);
  494.48 -    if (n.IsLeaf[bit])
  494.49 -    {
  494.50 -      valueRes = n.Values[bit];
  494.51 -      return (key == n.Keys[bit]);
  494.52 -    }
  494.53 -    cur = (int)n.Keys[bit];
  494.54 -  }
  494.55 -}
  494.56 -
  494.57 -bool CMap32::Set(UInt32 key, UInt32 value)
  494.58 -{
  494.59 -  if (Nodes.Size() == 0)
  494.60 -  {
  494.61 -    CNode n;
  494.62 -    n.Key = n.Keys[0] = n.Keys[1] = key;
  494.63 -    n.Values[0] = n.Values[1] = value;
  494.64 -    n.IsLeaf[0] = n.IsLeaf[1] = 1;
  494.65 -    n.Len = kNumBitsMax;
  494.66 -    Nodes.Add(n);
  494.67 -    return false;
  494.68 -  }
  494.69 -  if (Nodes.Size() == 1)
  494.70 -  {
  494.71 -    CNode &n = Nodes[0];
  494.72 -    if (n.Len == kNumBitsMax)
  494.73 -    {
  494.74 -      if (key == n.Key)
  494.75 -      {
  494.76 -        n.Values[0] = n.Values[1] = value;
  494.77 -        return true;
  494.78 -      }
  494.79 -      unsigned i = kNumBitsMax - 1;
  494.80 -      for (;GetSubBit(key, i) == GetSubBit(n.Key, i); i--);
  494.81 -      n.Len = (UInt16)(kNumBitsMax - (1 + i));
  494.82 -      unsigned newBit = GetSubBit(key, i);
  494.83 -      n.Values[newBit] = value;
  494.84 -      n.Keys[newBit] = key;
  494.85 -      return false;
  494.86 -    }
  494.87 -  }
  494.88 -
  494.89 -  int cur = 0;
  494.90 -  unsigned bitPos = kNumBitsMax;
  494.91 -  for (;;)
  494.92 -  {
  494.93 -    CNode &n = Nodes[cur];
  494.94 -    bitPos -= n.Len;
  494.95 -    if (GetSubBits(key, bitPos, n.Len) != GetSubBits(n.Key, bitPos, n.Len))
  494.96 -    {
  494.97 -      unsigned i = n.Len - 1;
  494.98 -      for (; GetSubBit(key, bitPos + i) == GetSubBit(n.Key, bitPos + i); i--);
  494.99 -      
 494.100 -      CNode e2(n);
 494.101 -      e2.Len = (UInt16)i;
 494.102 -
 494.103 -      n.Len = (UInt16)(n.Len - (1 + i));
 494.104 -      unsigned newBit = GetSubBit(key, bitPos + i);
 494.105 -      n.Values[newBit] = value;
 494.106 -      n.IsLeaf[newBit] = 1;
 494.107 -      n.IsLeaf[1 - newBit] = 0;
 494.108 -      n.Keys[newBit] = key;
 494.109 -      n.Keys[1 - newBit] = Nodes.Size();
 494.110 -      Nodes.Add(e2);
 494.111 -      return false;
 494.112 -    }
 494.113 -    unsigned bit = GetSubBit(key, --bitPos);
 494.114 -
 494.115 -    if (n.IsLeaf[bit])
 494.116 -    {
 494.117 -      if (key == n.Keys[bit])
 494.118 -      {
 494.119 -        n.Values[bit] = value;
 494.120 -        return true;
 494.121 -      }
 494.122 -      unsigned i = bitPos - 1;
 494.123 -      for (;GetSubBit(key, i) == GetSubBit(n.Keys[bit], i); i--);
 494.124 -     
 494.125 -      CNode e2;
 494.126 -      
 494.127 -      unsigned newBit = GetSubBit(key, i);
 494.128 -      e2.Values[newBit] = value;
 494.129 -      e2.Values[1 - newBit] = n.Values[bit];
 494.130 -      e2.IsLeaf[newBit] = e2.IsLeaf[1 - newBit] = 1;
 494.131 -      e2.Keys[newBit] = key;
 494.132 -      e2.Keys[1 - newBit] = e2.Key = n.Keys[bit];
 494.133 -      e2.Len = (UInt16)(bitPos - (1 + i));
 494.134 -
 494.135 -      n.IsLeaf[bit] = 0;
 494.136 -      n.Keys[bit] = Nodes.Size();
 494.137 -
 494.138 -      Nodes.Add(e2);
 494.139 -      return false;
 494.140 -    }
 494.141 -    cur = (int)n.Keys[bit];
 494.142 -  }
 494.143 -}
   495.1 --- a/src/win32/7zip/7z/CPP/Common/MyMap.h	Sat Mar 03 10:54:39 2012 -0600
   495.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   495.3 @@ -1,28 +0,0 @@
   495.4 -// MyMap.h
   495.5 -
   495.6 -#ifndef __COMMON_MYMAP_H
   495.7 -#define __COMMON_MYMAP_H
   495.8 -
   495.9 -#include "MyVector.h"
  495.10 -#include "Types.h"
  495.11 -
  495.12 -class CMap32
  495.13 -{
  495.14 -  struct CNode
  495.15 -  {
  495.16 -    UInt32 Key;
  495.17 -    UInt32 Keys[2];
  495.18 -    UInt32 Values[2];
  495.19 -    UInt16 Len;
  495.20 -    Byte IsLeaf[2];
  495.21 -  };
  495.22 -  CRecordVector<CNode> Nodes;
  495.23 -
  495.24 -public:
  495.25 -
  495.26 -  void Clear() { Nodes.Clear(); }
  495.27 -  bool Find(UInt32 key, UInt32 &valueRes) const;
  495.28 -  bool Set(UInt32 key, UInt32 value); // returns true, if there is such key already
  495.29 -};
  495.30 -
  495.31 -#endif
   496.1 --- a/src/win32/7zip/7z/CPP/Common/MyString.cpp	Sat Mar 03 10:54:39 2012 -0600
   496.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   496.3 @@ -1,198 +0,0 @@
   496.4 -// Common/MyString.cpp
   496.5 -
   496.6 -#include "StdAfx.h"
   496.7 -
   496.8 -#ifdef _WIN32
   496.9 -#include "StringConvert.h"
  496.10 -#else
  496.11 -#include <ctype.h>
  496.12 -#endif
  496.13 -
  496.14 -#include "MyString.h"
  496.15 -
  496.16 -
  496.17 -#ifdef _WIN32
  496.18 -
  496.19 -#ifndef _UNICODE
  496.20 -
  496.21 -wchar_t MyCharUpper(wchar_t c)
  496.22 -{
  496.23 -  if (c == 0)
  496.24 -    return 0;
  496.25 -  wchar_t *res = CharUpperW((LPWSTR)(UINT_PTR)(unsigned int)c);
  496.26 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
  496.27 -    return (wchar_t)(unsigned int)(UINT_PTR)res;
  496.28 -  const int kBufferSize = 4;
  496.29 -  char s[kBufferSize + 1];
  496.30 -  int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
  496.31 -  if (numChars == 0 || numChars > kBufferSize)
  496.32 -    return c;
  496.33 -  s[numChars] = 0;
  496.34 -  ::CharUpperA(s);
  496.35 -  ::MultiByteToWideChar(CP_ACP, 0, s, numChars, &c, 1);
  496.36 -  return c;
  496.37 -}
  496.38 -
  496.39 -wchar_t MyCharLower(wchar_t c)
  496.40 -{
  496.41 -  if (c == 0)
  496.42 -    return 0;
  496.43 -  wchar_t *res = CharLowerW((LPWSTR)(UINT_PTR)(unsigned int)c);
  496.44 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
  496.45 -    return (wchar_t)(unsigned int)(UINT_PTR)res;
  496.46 -  const int kBufferSize = 4;
  496.47 -  char s[kBufferSize + 1];
  496.48 -  int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
  496.49 -  if (numChars == 0 || numChars > kBufferSize)
  496.50 -    return c;
  496.51 -  s[numChars] = 0;
  496.52 -  ::CharLowerA(s);
  496.53 -  ::MultiByteToWideChar(CP_ACP, 0, s, numChars, &c, 1);
  496.54 -  return c;
  496.55 -}
  496.56 -
  496.57 -wchar_t * MyStringUpper(wchar_t *s)
  496.58 -{
  496.59 -  if (s == 0)
  496.60 -    return 0;
  496.61 -  wchar_t *res = CharUpperW(s);
  496.62 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
  496.63 -    return res;
  496.64 -  AString a = UnicodeStringToMultiByte(s);
  496.65 -  a.MakeUpper();
  496.66 -  return MyStringCopy(s, (const wchar_t *)MultiByteToUnicodeString(a));
  496.67 -}
  496.68 -
  496.69 -wchar_t * MyStringLower(wchar_t *s)
  496.70 -{
  496.71 -  if (s == 0)
  496.72 -    return 0;
  496.73 -  wchar_t *res = CharLowerW(s);
  496.74 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
  496.75 -    return res;
  496.76 -  AString a = UnicodeStringToMultiByte(s);
  496.77 -  a.MakeLower();
  496.78 -  return MyStringCopy(s, (const wchar_t *)MultiByteToUnicodeString(a));
  496.79 -}
  496.80 -
  496.81 -#endif
  496.82 -
  496.83 -/*
  496.84 -inline int ConvertCompareResult(int r) { return r - 2; }
  496.85 -
  496.86 -int MyStringCollate(const wchar_t *s1, const wchar_t *s2)
  496.87 -{
  496.88 -  int res = CompareStringW(
  496.89 -        LOCALE_USER_DEFAULT, SORT_STRINGSORT, s1, -1, s2, -1);
  496.90 -  #ifdef _UNICODE
  496.91 -  return ConvertCompareResult(res);
  496.92 -  #else
  496.93 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
  496.94 -    return ConvertCompareResult(res);
  496.95 -  return MyStringCollate(UnicodeStringToMultiByte(s1),
  496.96 -        UnicodeStringToMultiByte(s2));
  496.97 -  #endif
  496.98 -}
  496.99 -
 496.100 -#ifndef _WIN32_WCE
 496.101 -int MyStringCollate(const char *s1, const char *s2)
 496.102 -{
 496.103 -  return ConvertCompareResult(CompareStringA(
 496.104 -    LOCALE_USER_DEFAULT, SORT_STRINGSORT, s1, -1, s2, -1));
 496.105 -}
 496.106 -
 496.107 -int MyStringCollateNoCase(const char *s1, const char *s2)
 496.108 -{
 496.109 -  return ConvertCompareResult(CompareStringA(
 496.110 -    LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, s1, -1, s2, -1));
 496.111 -}
 496.112 -#endif
 496.113 -
 496.114 -int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
 496.115 -{
 496.116 -  int res = CompareStringW(
 496.117 -        LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, s1, -1, s2, -1);
 496.118 -  #ifdef _UNICODE
 496.119 -  return ConvertCompareResult(res);
 496.120 -  #else
 496.121 -  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
 496.122 -    return ConvertCompareResult(res);
 496.123 -  return MyStringCollateNoCase(UnicodeStringToMultiByte(s1),
 496.124 -      UnicodeStringToMultiByte(s2));
 496.125 -  #endif
 496.126 -}
 496.127 -*/
 496.128 -
 496.129 -#else
 496.130 -
 496.131 -wchar_t MyCharUpper(wchar_t c)
 496.132 -{
 496.133 -  return toupper(c);
 496.134 -}
 496.135 -
 496.136 -/*
 496.137 -int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
 496.138 -{
 496.139 -  for (;;)
 496.140 -  {
 496.141 -    wchar_t c1 = *s1++;
 496.142 -    wchar_t c2 = *s2++;
 496.143 -    wchar_t u1 = MyCharUpper(c1);
 496.144 -    wchar_t u2 = MyCharUpper(c2);
 496.145 -
 496.146 -    if (u1 < u2) return -1;
 496.147 -    if (u1 > u2) return 1;
 496.148 -    if (u1 == 0) return 0;
 496.149 -  }
 496.150 -}
 496.151 -*/
 496.152 -
 496.153 -#endif
 496.154 -
 496.155 -int MyStringCompare(const char *s1, const char *s2)
 496.156 -{
 496.157 -  for (;;)
 496.158 -  {
 496.159 -    unsigned char c1 = (unsigned char)*s1++;
 496.160 -    unsigned char c2 = (unsigned char)*s2++;
 496.161 -    if (c1 < c2) return -1;
 496.162 -    if (c1 > c2) return 1;
 496.163 -    if (c1 == 0) return 0;
 496.164 -  }
 496.165 -}
 496.166 -
 496.167 -int MyStringCompare(const wchar_t *s1, const wchar_t *s2)
 496.168 -{
 496.169 -  for (;;)
 496.170 -  {
 496.171 -    wchar_t c1 = *s1++;
 496.172 -    wchar_t c2 = *s2++;
 496.173 -    if (c1 < c2) return -1;
 496.174 -    if (c1 > c2) return 1;
 496.175 -    if (c1 == 0) return 0;
 496.176 -  }
 496.177 -}
 496.178 -
 496.179 -int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
 496.180 -{
 496.181 -  for (;;)
 496.182 -  {
 496.183 -    wchar_t c1 = *s1++;
 496.184 -    wchar_t c2 = *s2++;
 496.185 -    if (c1 != c2)
 496.186 -    {
 496.187 -      wchar_t u1 = MyCharUpper(c1);
 496.188 -      wchar_t u2 = MyCharUpper(c2);
 496.189 -      if (u1 < u2) return -1;
 496.190 -      if (u1 > u2) return 1;
 496.191 -    }
 496.192 -    if (c1 == 0) return 0;
 496.193 -  }
 496.194 -}
 496.195 -
 496.196 -#ifdef _WIN32
 496.197 -int MyStringCompareNoCase(const char *s1, const char *s2)
 496.198 -{
 496.199 -  return MyStringCompareNoCase(MultiByteToUnicodeString(s1), MultiByteToUnicodeString(s2));
 496.200 -}
 496.201 -#endif
   497.1 --- a/src/win32/7zip/7z/CPP/Common/MyString.h	Sat Mar 03 10:54:39 2012 -0600
   497.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   497.3 @@ -1,631 +0,0 @@
   497.4 -// Common/String.h
   497.5 -
   497.6 -#ifndef __COMMON_STRING_H
   497.7 -#define __COMMON_STRING_H
   497.8 -
   497.9 -#include <string.h>
  497.10 -// #include <wchar.h>
  497.11 -
  497.12 -#include "MyVector.h"
  497.13 -
  497.14 -#ifdef _WIN32
  497.15 -#include "MyWindows.h"
  497.16 -#endif
  497.17 -
  497.18 -template <class T>
  497.19 -inline int MyStringLen(const T *s)
  497.20 -{
  497.21 -  int i;
  497.22 -  for (i = 0; s[i] != '\0'; i++);
  497.23 -  return i;
  497.24 -}
  497.25 -
  497.26 -template <class T>
  497.27 -inline T * MyStringCopy(T *dest, const T *src)
  497.28 -{
  497.29 -  T *destStart = dest;
  497.30 -  while ((*dest++ = *src++) != 0);
  497.31 -  return destStart;
  497.32 -}
  497.33 -
  497.34 -inline wchar_t* MyStringGetNextCharPointer(wchar_t *p)
  497.35 -  { return (p + 1); }
  497.36 -inline const wchar_t* MyStringGetNextCharPointer(const wchar_t *p)
  497.37 -  { return (p + 1); }
  497.38 -inline wchar_t* MyStringGetPrevCharPointer(const wchar_t *, wchar_t *p)
  497.39 -  { return (p - 1); }
  497.40 -inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t *p)
  497.41 -  { return (p - 1); }
  497.42 -
  497.43 -#ifdef _WIN32
  497.44 -
  497.45 -inline char* MyStringGetNextCharPointer(char *p)
  497.46 -  { return CharNextA(p); }
  497.47 -inline const char* MyStringGetNextCharPointer(const char *p)
  497.48 -  { return CharNextA(p); }
  497.49 -
  497.50 -inline char* MyStringGetPrevCharPointer(char *base, char *p)
  497.51 -  { return CharPrevA(base, p); }
  497.52 -inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
  497.53 -  { return CharPrevA(base, p); }
  497.54 -
  497.55 -inline char MyCharUpper(char c)
  497.56 -  { return (char)(unsigned int)(UINT_PTR)CharUpperA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
  497.57 -#ifdef _UNICODE
  497.58 -inline wchar_t MyCharUpper(wchar_t c)
  497.59 -  { return (wchar_t)(unsigned int)(UINT_PTR)CharUpperW((LPWSTR)(UINT_PTR)(unsigned int)c); }
  497.60 -#else
  497.61 -wchar_t MyCharUpper(wchar_t c);
  497.62 -#endif
  497.63 -
  497.64 -inline char MyCharLower(char c)
  497.65 -  { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
  497.66 -#ifdef _UNICODE
  497.67 -inline wchar_t MyCharLower(wchar_t c)
  497.68 -  { return (wchar_t)(unsigned int)(UINT_PTR)CharLowerW((LPWSTR)(UINT_PTR)(unsigned int)c); }
  497.69 -#else
  497.70 -wchar_t MyCharLower(wchar_t c);
  497.71 -#endif
  497.72 -
  497.73 -inline char * MyStringUpper(char *s) { return CharUpperA(s); }
  497.74 -#ifdef _UNICODE
  497.75 -inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); }
  497.76 -#else
  497.77 -wchar_t * MyStringUpper(wchar_t *s);
  497.78 -#endif
  497.79 -
  497.80 -inline char * MyStringLower(char *s) { return CharLowerA(s); }
  497.81 -#ifdef _UNICODE
  497.82 -inline wchar_t * MyStringLower(wchar_t *s) { return CharLowerW(s); }
  497.83 -#else
  497.84 -wchar_t * MyStringLower(wchar_t *s);
  497.85 -#endif
  497.86 -
  497.87 -#else // Standard-C
  497.88 -wchar_t MyCharUpper(wchar_t c);
  497.89 -#endif
  497.90 -
  497.91 -//////////////////////////////////////
  497.92 -// Compare
  497.93 -
  497.94 -/*
  497.95 -#ifndef _WIN32_WCE
  497.96 -int MyStringCollate(const char *s1, const char *s2);
  497.97 -int MyStringCollateNoCase(const char *s1, const char *s2);
  497.98 -#endif
  497.99 -int MyStringCollate(const wchar_t *s1, const wchar_t *s2);
 497.100 -int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
 497.101 -*/
 497.102 -
 497.103 -int MyStringCompare(const char *s1, const char  *s2);
 497.104 -int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
 497.105 -
 497.106 -#ifdef _WIN32
 497.107 -int MyStringCompareNoCase(const char *s1, const char  *s2);
 497.108 -#endif
 497.109 -
 497.110 -int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
 497.111 -
 497.112 -template <class T>
 497.113 -class CStringBase
 497.114 -{
 497.115 -  void TrimLeftWithCharSet(const CStringBase &charSet)
 497.116 -  {
 497.117 -    const T *p = _chars;
 497.118 -    while (charSet.Find(*p) >= 0 && (*p != 0))
 497.119 -      p = GetNextCharPointer(p);
 497.120 -    Delete(0, (int)(p - _chars));
 497.121 -  }
 497.122 -  void TrimRightWithCharSet(const CStringBase &charSet)
 497.123 -  {
 497.124 -    const T *p = _chars;
 497.125 -    const T *pLast = NULL;
 497.126 -    while (*p != 0)
 497.127 -    {
 497.128 -      if (charSet.Find(*p) >= 0)
 497.129 -      {
 497.130 -        if (pLast == NULL)
 497.131 -          pLast = p;
 497.132 -      }
 497.133 -      else
 497.134 -        pLast = NULL;
 497.135 -      p = GetNextCharPointer(p);
 497.136 -    }
 497.137 -    if (pLast != NULL)
 497.138 -    {
 497.139 -      int i = (int)(pLast - _chars);
 497.140 -      Delete(i, _length - i);
 497.141 -    }
 497.142 -
 497.143 -  }
 497.144 -  void MoveItems(int destIndex, int srcIndex)
 497.145 -  {
 497.146 -    memmove(_chars + destIndex, _chars + srcIndex,
 497.147 -        sizeof(T) * (_length - srcIndex + 1));
 497.148 -  }
 497.149 -  
 497.150 -  void InsertSpace(int &index, int size)
 497.151 -  {
 497.152 -    CorrectIndex(index);
 497.153 -    GrowLength(size);
 497.154 -    MoveItems(index + size, index);
 497.155 -  }
 497.156 -
 497.157 -  static T *GetNextCharPointer(T *p)
 497.158 -    { return MyStringGetNextCharPointer(p); }
 497.159 -  static const T *GetNextCharPointer(const T *p)
 497.160 -    { return MyStringGetNextCharPointer(p); }
 497.161 -  static T *GetPrevCharPointer(T *base, T *p)
 497.162 -    { return MyStringGetPrevCharPointer(base, p); }
 497.163 -  static const T *GetPrevCharPointer(const T *base, const T *p)
 497.164 -    { return MyStringGetPrevCharPointer(base, p); }
 497.165 -protected:
 497.166 -  T *_chars;
 497.167 -  int _length;
 497.168 -  int _capacity;
 497.169 -  
 497.170 -  void SetCapacity(int newCapacity)
 497.171 -  {
 497.172 -    int realCapacity = newCapacity + 1;
 497.173 -    if (realCapacity == _capacity)
 497.174 -      return;
 497.175 -    /*
 497.176 -    const int kMaxStringSize = 0x20000000;
 497.177 -    #ifndef _WIN32_WCE
 497.178 -    if (newCapacity > kMaxStringSize || newCapacity < _length)
 497.179 -      throw 1052337;
 497.180 -    #endif
 497.181 -    */
 497.182 -    T *newBuffer = new T[realCapacity];
 497.183 -    if (_capacity > 0)
 497.184 -    {
 497.185 -      for (int i = 0; i < _length; i++)
 497.186 -        newBuffer[i] = _chars[i];
 497.187 -      delete []_chars;
 497.188 -    }
 497.189 -    _chars = newBuffer;
 497.190 -    _chars[_length] = 0;
 497.191 -    _capacity = realCapacity;
 497.192 -  }
 497.193 -
 497.194 -  void GrowLength(int n)
 497.195 -  {
 497.196 -    int freeSize = _capacity - _length - 1;
 497.197 -    if (n <= freeSize)
 497.198 -      return;
 497.199 -    int delta;
 497.200 -    if (_capacity > 64)
 497.201 -      delta = _capacity / 2;
 497.202 -    else if (_capacity > 8)
 497.203 -      delta = 16;
 497.204 -    else
 497.205 -      delta = 4;
 497.206 -    if (freeSize + delta < n)
 497.207 -      delta = n - freeSize;
 497.208 -    SetCapacity(_capacity + delta);
 497.209 -  }
 497.210 -
 497.211 -  void CorrectIndex(int &index) const
 497.212 -  {
 497.213 -    if (index > _length)
 497.214 -      index = _length;
 497.215 -  }
 497.216 -
 497.217 -public:
 497.218 -  CStringBase(): _chars(0), _length(0), _capacity(0) { SetCapacity(3); }
 497.219 -  CStringBase(T c):  _chars(0), _length(0), _capacity(0)
 497.220 -  {
 497.221 -    SetCapacity(1);
 497.222 -    _chars[0] = c;
 497.223 -    _chars[1] = 0;
 497.224 -    _length = 1;
 497.225 -  }
 497.226 -  CStringBase(const T *chars): _chars(0), _length(0), _capacity(0)
 497.227 -  {
 497.228 -    int length = MyStringLen(chars);
 497.229 -    SetCapacity(length);
 497.230 -    MyStringCopy(_chars, chars); // can be optimized by memove()
 497.231 -    _length = length;
 497.232 -  }
 497.233 -  CStringBase(const CStringBase &s):  _chars(0), _length(0), _capacity(0)
 497.234 -  {
 497.235 -    SetCapacity(s._length);
 497.236 -    MyStringCopy(_chars, s._chars);
 497.237 -    _length = s._length;
 497.238 -  }
 497.239 -  ~CStringBase() {  delete []_chars; }
 497.240 -
 497.241 -  operator const T*() const { return _chars;}
 497.242 -
 497.243 -  // The minimum size of the character buffer in characters.
 497.244 -  // This value does not include space for a null terminator.
 497.245 -  T* GetBuffer(int minBufLength)
 497.246 -  {
 497.247 -    if (minBufLength >= _capacity)
 497.248 -      SetCapacity(minBufLength);
 497.249 -    return _chars;
 497.250 -  }
 497.251 -  void ReleaseBuffer() { ReleaseBuffer(MyStringLen(_chars)); }
 497.252 -  void ReleaseBuffer(int newLength)
 497.253 -  {
 497.254 -    /*
 497.255 -    #ifndef _WIN32_WCE
 497.256 -    if (newLength >= _capacity)
 497.257 -      throw 282217;
 497.258 -    #endif
 497.259 -    */
 497.260 -    _chars[newLength] = 0;
 497.261 -    _length = newLength;
 497.262 -  }
 497.263 -
 497.264 -  CStringBase& operator=(T c)
 497.265 -  {
 497.266 -    Empty();
 497.267 -    SetCapacity(1);
 497.268 -    _chars[0] = c;
 497.269 -    _chars[1] = 0;
 497.270 -    _length = 1;
 497.271 -    return *this;
 497.272 -  }
 497.273 -  CStringBase& operator=(const T *chars)
 497.274 -  {
 497.275 -    Empty();
 497.276 -    int length = MyStringLen(chars);
 497.277 -    SetCapacity(length);
 497.278 -    MyStringCopy(_chars, chars);
 497.279 -    _length = length;
 497.280 -    return *this;
 497.281 -  }
 497.282 -  CStringBase& operator=(const CStringBase& s)
 497.283 -  {
 497.284 -    if (&s == this)
 497.285 -      return *this;
 497.286 -    Empty();
 497.287 -    SetCapacity(s._length);
 497.288 -    MyStringCopy(_chars, s._chars);
 497.289 -    _length = s._length;
 497.290 -    return *this;
 497.291 -  }
 497.292 -  
 497.293 -  CStringBase& operator+=(T c)
 497.294 -  {
 497.295 -    GrowLength(1);
 497.296 -    _chars[_length] = c;
 497.297 -    _chars[++_length] = 0;
 497.298 -    return *this;
 497.299 -  }
 497.300 -  CStringBase& operator+=(const T *s)
 497.301 -  {
 497.302 -    int len = MyStringLen(s);
 497.303 -    GrowLength(len);
 497.304 -    MyStringCopy(_chars + _length, s);
 497.305 -    _length += len;
 497.306 -    return *this;
 497.307 -  }
 497.308 -  CStringBase& operator+=(const CStringBase &s)
 497.309 -  {
 497.310 -    GrowLength(s._length);
 497.311 -    MyStringCopy(_chars + _length, s._chars);
 497.312 -    _length += s._length;
 497.313 -    return *this;
 497.314 -  }
 497.315 -  void Empty()
 497.316 -  {
 497.317 -    _length = 0;
 497.318 -    _chars[0] = 0;
 497.319 -  }
 497.320 -  int Length() const { return _length; }
 497.321 -  bool IsEmpty() const { return (_length == 0); }
 497.322 -
 497.323 -  CStringBase Mid(int startIndex) const
 497.324 -    { return Mid(startIndex, _length - startIndex); }
 497.325 -  CStringBase Mid(int startIndex, int count ) const
 497.326 -  {
 497.327 -    if (startIndex + count > _length)
 497.328 -      count = _length - startIndex;
 497.329 -    
 497.330 -    if (startIndex == 0 && startIndex + count == _length)
 497.331 -      return *this;
 497.332 -    
 497.333 -    CStringBase<T> result;
 497.334 -    result.SetCapacity(count);
 497.335 -    // MyStringNCopy(result._chars, _chars + startIndex, count);
 497.336 -    for (int i = 0; i < count; i++)
 497.337 -      result._chars[i] = _chars[startIndex + i];
 497.338 -    result._chars[count] = 0;
 497.339 -    result._length = count;
 497.340 -    return result;
 497.341 -  }
 497.342 -  CStringBase Left(int count) const
 497.343 -    { return Mid(0, count); }
 497.344 -  CStringBase Right(int count) const
 497.345 -  {
 497.346 -    if (count > _length)
 497.347 -      count = _length;
 497.348 -    return Mid(_length - count, count);
 497.349 -  }
 497.350 -
 497.351 -  void MakeUpper()
 497.352 -    { MyStringUpper(_chars); }
 497.353 -  void MakeLower()
 497.354 -    { MyStringLower(_chars); }
 497.355 -
 497.356 -  int Compare(const CStringBase& s) const
 497.357 -    { return MyStringCompare(_chars, s._chars); }
 497.358 -
 497.359 -  int Compare(const T *s) const
 497.360 -    { return MyStringCompare(_chars, s); }
 497.361 -
 497.362 -  int CompareNoCase(const CStringBase& s) const
 497.363 -    { return MyStringCompareNoCase(_chars, s._chars); }
 497.364 -
 497.365 -  int CompareNoCase(const T *s) const
 497.366 -    { return MyStringCompareNoCase(_chars, s); }
 497.367 -
 497.368 -  /*
 497.369 -  int Collate(const CStringBase& s) const
 497.370 -    { return MyStringCollate(_chars, s._chars); }
 497.371 -  int CollateNoCase(const CStringBase& s) const
 497.372 -    { return MyStringCollateNoCase(_chars, s._chars); }
 497.373 -  */
 497.374 -
 497.375 -  int Find(T c) const { return Find(c, 0); }
 497.376 -  int Find(T c, int startIndex) const
 497.377 -  {
 497.378 -    T *p = _chars + startIndex;
 497.379 -    for (;;)
 497.380 -    {
 497.381 -      if (*p == c)
 497.382 -        return (int)(p - _chars);
 497.383 -      if (*p == 0)
 497.384 -        return -1;
 497.385 -      p = GetNextCharPointer(p);
 497.386 -    }
 497.387 -  }
 497.388 -  int Find(const CStringBase &s) const { return Find(s, 0); }
 497.389 -  int Find(const CStringBase &s, int startIndex) const
 497.390 -  {
 497.391 -    if (s.IsEmpty())
 497.392 -      return startIndex;
 497.393 -    for (; startIndex < _length; startIndex++)
 497.394 -    {
 497.395 -      int j;
 497.396 -      for (j = 0; j < s._length && startIndex + j < _length; j++)
 497.397 -        if (_chars[startIndex+j] != s._chars[j])
 497.398 -          break;
 497.399 -      if (j == s._length)
 497.400 -        return startIndex;
 497.401 -    }
 497.402 -    return -1;
 497.403 -  }
 497.404 -  int ReverseFind(T c) const
 497.405 -  {
 497.406 -    if (_length == 0)
 497.407 -      return -1;
 497.408 -    T *p = _chars + _length - 1;
 497.409 -    for (;;)
 497.410 -    {
 497.411 -      if (*p == c)
 497.412 -        return (int)(p - _chars);
 497.413 -      if (p == _chars)
 497.414 -        return -1;
 497.415 -      p = GetPrevCharPointer(_chars, p);
 497.416 -    }
 497.417 -  }
 497.418 -  int FindOneOf(const CStringBase &s) const
 497.419 -  {
 497.420 -    for (int i = 0; i < _length; i++)
 497.421 -      if (s.Find(_chars[i]) >= 0)
 497.422 -        return i;
 497.423 -      return -1;
 497.424 -  }
 497.425 -
 497.426 -  void TrimLeft(T c)
 497.427 -  {
 497.428 -    const T *p = _chars;
 497.429 -    while (c == *p)
 497.430 -      p = GetNextCharPointer(p);
 497.431 -    Delete(0, p - _chars);
 497.432 -  }
 497.433 -  private:
 497.434 -  CStringBase GetTrimDefaultCharSet()
 497.435 -  {
 497.436 -    CStringBase<T> charSet;
 497.437 -    charSet += (T)' ';
 497.438 -    charSet += (T)'\n';
 497.439 -    charSet += (T)'\t';
 497.440 -    return charSet;
 497.441 -  }
 497.442 -  public:
 497.443 -
 497.444 -  void TrimLeft()
 497.445 -  {
 497.446 -    TrimLeftWithCharSet(GetTrimDefaultCharSet());
 497.447 -  }
 497.448 -  void TrimRight()
 497.449 -  {
 497.450 -    TrimRightWithCharSet(GetTrimDefaultCharSet());
 497.451 -  }
 497.452 -  void TrimRight(T c)
 497.453 -  {
 497.454 -    const T *p = _chars;
 497.455 -    const T *pLast = NULL;
 497.456 -    while (*p != 0)
 497.457 -    {
 497.458 -      if (*p == c)
 497.459 -      {
 497.460 -        if (pLast == NULL)
 497.461 -          pLast = p;
 497.462 -      }
 497.463 -      else
 497.464 -        pLast = NULL;
 497.465 -      p = GetNextCharPointer(p);
 497.466 -    }
 497.467 -    if (pLast != NULL)
 497.468 -    {
 497.469 -      int i = pLast - _chars;
 497.470 -      Delete(i, _length - i);
 497.471 -    }
 497.472 -  }
 497.473 -  void Trim()
 497.474 -  {
 497.475 -    TrimRight();
 497.476 -    TrimLeft();
 497.477 -  }
 497.478 -
 497.479 -  int Insert(int index, T c)
 497.480 -  {
 497.481 -    InsertSpace(index, 1);
 497.482 -    _chars[index] = c;
 497.483 -    _length++;
 497.484 -    return _length;
 497.485 -  }
 497.486 -  int Insert(int index, const CStringBase &s)
 497.487 -  {
 497.488 -    CorrectIndex(index);
 497.489 -    if (s.IsEmpty())
 497.490 -      return _length;
 497.491 -    int numInsertChars = s.Length();
 497.492 -    InsertSpace(index, numInsertChars);
 497.493 -    for (int i = 0; i < numInsertChars; i++)
 497.494 -      _chars[index + i] = s[i];
 497.495 -    _length += numInsertChars;
 497.496 -    return _length;
 497.497 -  }
 497.498 -
 497.499 -  // !!!!!!!!!!!!!!! test it if newChar = '\0'
 497.500 -  int Replace(T oldChar, T newChar)
 497.501 -  {
 497.502 -    if (oldChar == newChar)
 497.503 -      return 0;
 497.504 -    int number  = 0;
 497.505 -    int pos  = 0;
 497.506 -    while (pos < Length())
 497.507 -    {
 497.508 -      pos = Find(oldChar, pos);
 497.509 -      if (pos < 0)
 497.510 -        break;
 497.511 -      _chars[pos] = newChar;
 497.512 -      pos++;
 497.513 -      number++;
 497.514 -    }
 497.515 -    return number;
 497.516 -  }
 497.517 -  int Replace(const CStringBase &oldString, const CStringBase &newString)
 497.518 -  {
 497.519 -    if (oldString.IsEmpty())
 497.520 -      return 0;
 497.521 -    if (oldString == newString)
 497.522 -      return 0;
 497.523 -    int oldStringLength = oldString.Length();
 497.524 -    int newStringLength = newString.Length();
 497.525 -    int number  = 0;
 497.526 -    int pos  = 0;
 497.527 -    while (pos < _length)
 497.528 -    {
 497.529 -      pos = Find(oldString, pos);
 497.530 -      if (pos < 0)
 497.531 -        break;
 497.532 -      Delete(pos, oldStringLength);
 497.533 -      Insert(pos, newString);
 497.534 -      pos += newStringLength;
 497.535 -      number++;
 497.536 -    }
 497.537 -    return number;
 497.538 -  }
 497.539 -  int Delete(int index, int count = 1 )
 497.540 -  {
 497.541 -    if (index + count > _length)
 497.542 -      count = _length - index;
 497.543 -    if (count > 0)
 497.544 -    {
 497.545 -      MoveItems(index, index + count);
 497.546 -      _length -= count;
 497.547 -    }
 497.548 -    return _length;
 497.549 -  }
 497.550 -};
 497.551 -
 497.552 -template <class T>
 497.553 -CStringBase<T> operator+(const CStringBase<T>& s1, const CStringBase<T>& s2)
 497.554 -{
 497.555 -  CStringBase<T> result(s1);
 497.556 -  result += s2;
 497.557 -  return result;
 497.558 -}
 497.559 -
 497.560 -template <class T>
 497.561 -CStringBase<T> operator+(const CStringBase<T>& s, T c)
 497.562 -{
 497.563 -  CStringBase<T> result(s);
 497.564 -  result += c;
 497.565 -  return result;
 497.566 -}
 497.567 -
 497.568 -template <class T>
 497.569 -CStringBase<T> operator+(T c, const CStringBase<T>& s)
 497.570 -{
 497.571 -  CStringBase<T> result(c);
 497.572 -  result += s;
 497.573 -  return result;
 497.574 -}
 497.575 -
 497.576 -template <class T>
 497.577 -CStringBase<T> operator+(const CStringBase<T>& s, const T * chars)
 497.578 -{
 497.579 -  CStringBase<T> result(s);
 497.580 -  result += chars;
 497.581 -  return result;
 497.582 -}
 497.583 -
 497.584 -template <class T>
 497.585 -CStringBase<T> operator+(const T * chars, const CStringBase<T>& s)
 497.586 -{
 497.587 -  CStringBase<T> result(chars);
 497.588 -  result += s;
 497.589 -  return result;
 497.590 -}
 497.591 -
 497.592 -template <class T>
 497.593 -bool operator==(const CStringBase<T>& s1, const CStringBase<T>& s2)
 497.594 -  { return (s1.Compare(s2) == 0); }
 497.595 -
 497.596 -template <class T>
 497.597 -bool operator<(const CStringBase<T>& s1, const CStringBase<T>& s2)
 497.598 -  { return (s1.Compare(s2) < 0); }
 497.599 -
 497.600 -template <class T>
 497.601 -bool operator==(const T *s1, const CStringBase<T>& s2)
 497.602 -  { return (s2.Compare(s1) == 0); }
 497.603 -
 497.604 -template <class T>
 497.605 -bool operator==(const CStringBase<T>& s1, const T *s2)
 497.606 -  { return (s1.Compare(s2) == 0); }
 497.607 -
 497.608 -template <class T>
 497.609 -bool operator!=(const CStringBase<T>& s1, const CStringBase<T>& s2)
 497.610 -  { return (s1.Compare(s2) != 0); }
 497.611 -
 497.612 -template <class T>
 497.613 -bool operator!=(const T *s1, const CStringBase<T>& s2)
 497.614 -  { return (s2.Compare(s1) != 0); }
 497.615 -
 497.616 -template <class T>
 497.617 -bool operator!=(const CStringBase<T>& s1, const T *s2)
 497.618 -  { return (s1.Compare(s2) != 0); }
 497.619 -
 497.620 -typedef CStringBase<char> AString;
 497.621 -typedef CStringBase<wchar_t> UString;
 497.622 -
 497.623 -typedef CObjectVector<AString> AStringVector;
 497.624 -typedef CObjectVector<UString> UStringVector;
 497.625 -
 497.626 -#ifdef _UNICODE
 497.627 -  typedef UString CSysString;
 497.628 -#else
 497.629 -  typedef AString CSysString;
 497.630 -#endif
 497.631 -
 497.632 -typedef CObjectVector<CSysString> CSysStringVector;
 497.633 -
 497.634 -#endif
   498.1 --- a/src/win32/7zip/7z/CPP/Common/MyUnknown.h	Sat Mar 03 10:54:39 2012 -0600
   498.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   498.3 @@ -1,24 +0,0 @@
   498.4 -// MyUnknown.h
   498.5 -
   498.6 -#ifndef __MYUNKNOWN_H
   498.7 -#define __MYUNKNOWN_H
   498.8 -
   498.9 -#ifdef _WIN32
  498.10 -
  498.11 -#ifdef _WIN32_WCE
  498.12 -#if (_WIN32_WCE > 300)
  498.13 -#include <basetyps.h>
  498.14 -#else
  498.15 -#define MIDL_INTERFACE(x) struct
  498.16 -#endif
  498.17 -#else
  498.18 -#include <basetyps.h>
  498.19 -#endif
  498.20 -
  498.21 -#include <unknwn.h>
  498.22 -
  498.23 -#else
  498.24 -#include "MyWindows.h"
  498.25 -#endif
  498.26 -  
  498.27 -#endif
   499.1 --- a/src/win32/7zip/7z/CPP/Common/MyVector.cpp	Sat Mar 03 10:54:39 2012 -0600
   499.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   499.3 @@ -1,90 +0,0 @@
   499.4 -// Common/MyVector.cpp
   499.5 -
   499.6 -#include "StdAfx.h"
   499.7 -
   499.8 -#include <string.h>
   499.9 -
  499.10 -#include "MyVector.h"
  499.11 -
  499.12 -CBaseRecordVector::~CBaseRecordVector() { ClearAndFree(); }
  499.13 -
  499.14 -void CBaseRecordVector::ClearAndFree()
  499.15 -{
  499.16 -  Clear();
  499.17 -  delete []((unsigned char *)_items);
  499.18 -  _capacity = 0;
  499.19 -  _size = 0;
  499.20 -  _items = 0;
  499.21 -}
  499.22 -
  499.23 -void CBaseRecordVector::Clear() { DeleteFrom(0); }
  499.24 -void CBaseRecordVector::DeleteBack() { Delete(_size - 1); }
  499.25 -void CBaseRecordVector::DeleteFrom(int index)
  499.26 -{
  499.27 -	Delete(index, _size - index);
  499.28 -}
  499.29 -
  499.30 -void CBaseRecordVector::ReserveOnePosition()
  499.31 -{
  499.32 -  if (_size != _capacity)
  499.33 -    return;
  499.34 -  int delta = 1;
  499.35 -  if (_capacity >= 64)
  499.36 -    delta = _capacity / 4;
  499.37 -  else if (_capacity >= 8)
  499.38 -    delta = 8;
  499.39 -  Reserve(_capacity + delta);
  499.40 -}
  499.41 -
  499.42 -void CBaseRecordVector::Reserve(int newCapacity)
  499.43 -{
  499.44 -  // if (newCapacity <= _capacity)
  499.45 -  if (newCapacity == _capacity)
  499.46 -    return;
  499.47 -  if ((unsigned)newCapacity >= ((unsigned)1 << (sizeof(unsigned) * 8 - 1)))
  499.48 -    throw 1052353;
  499.49 -  size_t newSize = (size_t)(unsigned)newCapacity * _itemSize;
  499.50 -  if (newSize / _itemSize != (size_t)(unsigned)newCapacity)
  499.51 -    throw 1052354;
  499.52 -  unsigned char *p = NULL;
  499.53 -  if (newSize > 0)
  499.54 -  {
  499.55 -    p = new unsigned char[newSize];
  499.56 -    if (p == 0)
  499.57 -      throw 1052355;
  499.58 -    int numRecordsToMove = (_size < newCapacity ? _size : newCapacity);
  499.59 -    memcpy(p, _items, _itemSize * numRecordsToMove);
  499.60 -  }
  499.61 -  delete [](unsigned char *)_items;
  499.62 -  _items = p;
  499.63 -  _capacity = newCapacity;
  499.64 -}
  499.65 -
  499.66 -void CBaseRecordVector::ReserveDown()
  499.67 -{
  499.68 -  Reserve(_size);
  499.69 -}
  499.70 -
  499.71 -void CBaseRecordVector::MoveItems(int destIndex, int srcIndex)
  499.72 -{
  499.73 -  memmove(((unsigned char *)_items) + destIndex * _itemSize,
  499.74 -    ((unsigned char  *)_items) + srcIndex * _itemSize,
  499.75 -    _itemSize * (_size - srcIndex));
  499.76 -}
  499.77 -
  499.78 -void CBaseRecordVector::InsertOneItem(int index)
  499.79 -{
  499.80 -  ReserveOnePosition();
  499.81 -  MoveItems(index + 1, index);
  499.82 -  _size++;
  499.83 -}
  499.84 -
  499.85 -void CBaseRecordVector::Delete(int index, int num)
  499.86 -{
  499.87 -  TestIndexAndCorrectNum(index, num);
  499.88 -  if (num > 0)
  499.89 -  {
  499.90 -    MoveItems(index, index + num);
  499.91 -    _size -= num;
  499.92 -  }
  499.93 -}
   500.1 --- a/src/win32/7zip/7z/CPP/Common/MyVector.h	Sat Mar 03 10:54:39 2012 -0600
   500.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   500.3 @@ -1,256 +0,0 @@
   500.4 -// Common/Vector.h
   500.5 -
   500.6 -#ifndef __COMMON_VECTOR_H
   500.7 -#define __COMMON_VECTOR_H
   500.8 -
   500.9 -#include "Defs.h"
  500.10 -
  500.11 -class CBaseRecordVector
  500.12 -{
  500.13 -  void MoveItems(int destIndex, int srcIndex);
  500.14 -protected:
  500.15 -  int _capacity;
  500.16 -  int _size;
  500.17 -  void *_items;
  500.18 -  size_t _itemSize;
  500.19 -  
  500.20 -  void ReserveOnePosition();
  500.21 -  void InsertOneItem(int index);
  500.22 -  void TestIndexAndCorrectNum(int index, int &num) const
  500.23 -    { if (index + num > _size) num = _size - index; }
  500.24 -public:
  500.25 -  CBaseRecordVector(size_t itemSize): _capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
  500.26 -  virtual ~CBaseRecordVector();
  500.27 -  void ClearAndFree();
  500.28 -  int Size() const { return _size; }
  500.29 -  bool IsEmpty() const { return (_size == 0); }
  500.30 -  void Reserve(int newCapacity);
  500.31 -  void ReserveDown();
  500.32 -  virtual void Delete(int index, int num = 1);
  500.33 -  void Clear();
  500.34 -  void DeleteFrom(int index);
  500.35 -  void DeleteBack();
  500.36 -};
  500.37 -
  500.38 -template <class T>
  500.39 -class CRecordVector: public CBaseRecordVector
  500.40 -{
  500.41 -public:
  500.42 -  CRecordVector(): CBaseRecordVector(sizeof(T)){};
  500.43 -  CRecordVector(const CRecordVector &v): CBaseRecordVector(sizeof(T)) { *this = v; }
  500.44 -  CRecordVector& operator=(const CRecordVector &v)
  500.45 -  {
  500.46 -    Clear();
  500.47 -    return (*this += v);
  500.48 -  }
  500.49 -  CRecordVector& operator+=(const CRecordVector &v)
  500.50 -  {
  500.51 -    int size = v.Size();
  500.52 -    Reserve(Size() + size);
  500.53 -    for (int i = 0; i < size; i++)
  500.54 -      Add(v[i]);
  500.55 -    return *this;
  500.56 -  }
  500.57 -  int Add(T item)
  500.58 -  {
  500.59 -    ReserveOnePosition();
  500.60 -    ((T *)_items)[_size] = item;
  500.61 -    return _size++;
  500.62 -  }
  500.63 -  void Insert(int index, T item)
  500.64 -  {
  500.65 -    InsertOneItem(index);
  500.66 -    ((T *)_items)[index] = item;
  500.67 -  }
  500.68 -  // T* GetPointer() const { return (T*)_items; }
  500.69 -  // operator const T *() const { return _items; };
  500.70 -  const T& operator[](int index) const { return ((T *)_items)[index]; }
  500.71 -  T& operator[](int index) { return ((T *)_items)[index]; }
  500.72 -  const T& Front() const { return operator[](0); }
  500.73 -  T& Front() { return operator[](0); }
  500.74 -  const T& Back() const { return operator[](_size - 1); }
  500.75 -  T& Back() { return operator[](_size - 1); }
  500.76 -
  500.77 -  void Swap(int i, int j)
  500.78 -  {
  500.79 -    T temp = operator[](i);
  500.80 -    operator[](i) = operator[](j);
  500.81 -    operator[](j) = temp;
  500.82 -  }
  500.83 -
  500.84 -  int FindInSorted(const T& item) const
  500.85 -  {
  500.86 -    int left = 0, right = Size();
  500.87 -    while (left != right)
  500.88 -    {
  500.89 -      int mid = (left + right) / 2;
  500.90 -      const T& midValue = (*this)[mid];
  500.91 -      if (item == midValue)
  500.92 -        return mid;
  500.93 -      if (item < midValue)
  500.94 -        right = mid;
  500.95 -      else
  500.96 -        left = mid + 1;
  500.97 -    }
  500.98 -    return -1;
  500.99 -  }
 500.100 -
 500.101 -  int AddToUniqueSorted(const T& item)
 500.102 -  {
 500.103 -    int left = 0, right = Size();
 500.104 -    while (left != right)
 500.105 -    {
 500.106 -      int mid = (left + right) / 2;
 500.107 -      const T& midValue = (*this)[mid];
 500.108 -      if (item == midValue)
 500.109 -        return mid;
 500.110 -      if (item < midValue)
 500.111 -        right = mid;
 500.112 -      else
 500.113 -        left = mid + 1;
 500.114 -    }
 500.115 -    Insert(right, item);
 500.116 -    return right;
 500.117 -  }
 500.118 -
 500.119 -  static void SortRefDown(T* p, int k, int size, int (*compare)(const T*, const T*, void *), void *param)
 500.120 -  {
 500.121 -    T temp = p[k];
 500.122 -    for (;;)
 500.123 -    {
 500.124 -      int s = (k << 1);
 500.125 -      if (s > size)
 500.126 -        break;
 500.127 -      if (s < size && compare(p + s + 1, p + s, param) > 0)
 500.128 -        s++;
 500.129 -      if (compare(&temp, p + s, param) >= 0)
 500.130 -        break;
 500.131 -      p[k] = p[s];
 500.132 -      k = s;
 500.133 -    }
 500.134 -    p[k] = temp;
 500.135 -  }
 500.136 -
 500.137 -  void Sort(int (*compare)(const T*, const T*, void *), void *param)
 500.138 -  {
 500.139 -    int size = _size;
 500.140 -    if (size <= 1)
 500.141 -      return;
 500.142 -    T* p = (&Front()) - 1;
 500.143 -    {
 500.144 -      int i = size / 2;
 500.145 -      do
 500.146 -        SortRefDown(p, i, size, compare, param);
 500.147 -      while (--i != 0);
 500.148 -    }
 500.149 -    do
 500.150 -    {
 500.151 -      T temp = p[size];
 500.152 -      p[size--] = p[1];
 500.153 -      p[1] = temp;
 500.154 -      SortRefDown(p, 1, size, compare, param);
 500.155 -    }
 500.156 -    while (size > 1);
 500.157 -  }
 500.158 -};
 500.159 -
 500.160 -typedef CRecordVector<int> CIntVector;
 500.161 -typedef CRecordVector<unsigned int> CUIntVector;
 500.162 -typedef CRecordVector<bool> CBoolVector;
 500.163 -typedef CRecordVector<unsigned char> CByteVector;
 500.164 -typedef CRecordVector<void *> CPointerVector;
 500.165 -
 500.166 -template <class T>
 500.167 -class CObjectVector: public CPointerVector
 500.168 -{
 500.169 -public:
 500.170 -  CObjectVector() {};
 500.171 -  ~CObjectVector() { Clear(); };
 500.172 -  CObjectVector(const CObjectVector &v) { *this = v; }
 500.173 -  CObjectVector& operator=(const CObjectVector &v)
 500.174 -  {
 500.175 -    Clear();
 500.176 -    return (*this += v);
 500.177 -  }
 500.178 -  CObjectVector& operator+=(const CObjectVector &v)
 500.179 -  {
 500.180 -    int size = v.Size();
 500.181 -    Reserve(Size() + size);
 500.182 -    for (int i = 0; i < size; i++)
 500.183 -      Add(v[i]);
 500.184 -    return *this;
 500.185 -  }
 500.186 -  const T& operator[](int index) const
 500.187 -  {
 500.188 -	  return *((T *)CPointerVector::operator[](index));
 500.189 -  }
 500.190 -  T& operator[](int index)
 500.191 -  {
 500.192 -	  return *((T *)CPointerVector::operator[](index));
 500.193 -  }
 500.194 -  T& Front() { return operator[](0); }
 500.195 -  const T& Front() const { return operator[](0); }
 500.196 -  T& Back() { return operator[](_size - 1); }
 500.197 -  const T& Back() const { return operator[](_size - 1); }
 500.198 -  int Add(const T& item) { return CPointerVector::Add(new T(item)); }
 500.199 -  void Insert(int index, const T& item) { CPointerVector::Insert(index, new T(item)); }
 500.200 -  virtual void Delete(int index, int num = 1)
 500.201 -  {
 500.202 -    TestIndexAndCorrectNum(index, num);
 500.203 -    for (int i = 0; i < num; i++)
 500.204 -      delete (T *)(((void **)_items)[index + i]);
 500.205 -    CPointerVector::Delete(index, num);
 500.206 -  }
 500.207 -  int Find(const T& item) const
 500.208 -  {
 500.209 -    for (int i = 0; i < Size(); i++)
 500.210 -      if (item == (*this)[i])
 500.211 -        return i;
 500.212 -    return -1;
 500.213 -  }
 500.214 -  int FindInSorted(const T& item) const
 500.215 -  {
 500.216 -    int left = 0, right = Size();
 500.217 -    while (left != right)
 500.218 -    {
 500.219 -      int mid = (left + right) / 2;
 500.220 -      const T& midValue = (*this)[mid];
 500.221 -      if (item == midValue)
 500.222 -        return mid;
 500.223 -      if (item < midValue)
 500.224 -        right = mid;
 500.225 -      else
 500.226 -        left = mid + 1;
 500.227 -    }
 500.228 -    return -1;
 500.229 -  }
 500.230 -  int AddToSorted(const T& item)
 500.231 -  {
 500.232 -    int left = 0, right = Size();
 500.233 -    while (left != right)
 500.234 -    {
 500.235 -      int mid = (left + right) / 2;
 500.236 -      const T& midValue = (*this)[mid];
 500.237 -      if (item == midValue)
 500.238 -      {
 500.239 -        right = mid + 1;
 500.240 -        break;
 500.241 -      }
 500.242 -      if (item < midValue)
 500.243 -        right = mid;
 500.244 -      else
 500.245 -        left = mid + 1;
 500.246 -    }
 500.247 -    Insert(right, item);
 500.248 -    return right;
 500.249 -  }
 500.250 -
 500.251 -  void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
 500.252 -    { CPointerVector::Sort(compare, param); }
 500.253 -
 500.254 -  static int CompareObjectItems(void *const *a1, void *const *a2, void * /* param */)
 500.255 -    { return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
 500.256 -  void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
 500.257 -};
 500.258 -
 500.259 -#endif
   501.1 --- a/src/win32/7zip/7z/CPP/Common/MyWindows.h	Sat Mar 03 10:54:39 2012 -0600
   501.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   501.3 @@ -1,214 +0,0 @@
   501.4 -// MyWindows.h
   501.5 -
   501.6 -#ifndef __MYWINDOWS_H
   501.7 -#define __MYWINDOWS_H
   501.8 -
   501.9 -#ifdef _WIN32
  501.10 -
  501.11 -#include <windows.h>
  501.12 -
  501.13 -#define CHAR_PATH_SEPARATOR '\\'
  501.14 -#define WCHAR_PATH_SEPARATOR L'\\'
  501.15 -#define STRING_PATH_SEPARATOR "\\"
  501.16 -#define WSTRING_PATH_SEPARATOR L"\\"
  501.17 -
  501.18 -#else
  501.19 -
  501.20 -#define CHAR_PATH_SEPARATOR '/'
  501.21 -#define WCHAR_PATH_SEPARATOR L'/'
  501.22 -#define STRING_PATH_SEPARATOR "/"
  501.23 -#define WSTRING_PATH_SEPARATOR L"/"
  501.24 -
  501.25 -#include <stddef.h> // for wchar_t
  501.26 -#include <string.h>
  501.27 -
  501.28 -#include "MyGuidDef.h"
  501.29 -
  501.30 -typedef char CHAR;
  501.31 -typedef unsigned char UCHAR;
  501.32 -
  501.33 -#undef BYTE
  501.34 -typedef unsigned char BYTE;
  501.35 -
  501.36 -typedef short SHORT;
  501.37 -typedef unsigned short USHORT;
  501.38 -
  501.39 -#undef WORD
  501.40 -typedef unsigned short WORD;
  501.41 -typedef short VARIANT_BOOL;
  501.42 -
  501.43 -typedef int INT;
  501.44 -typedef Int32 INT32;
  501.45 -typedef unsigned int UINT;
  501.46 -typedef UInt32 UINT32;
  501.47 -typedef INT32 LONG;   // LONG, ULONG and DWORD must be 32-bit
  501.48 -typedef UINT32 ULONG;
  501.49 -
  501.50 -#undef DWORD
  501.51 -typedef UINT32 DWORD;
  501.52 -
  501.53 -typedef Int64 LONGLONG;
  501.54 -typedef UInt64 ULONGLONG;
  501.55 -
  501.56 -typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
  501.57 -typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
  501.58 -
  501.59 -typedef const CHAR *LPCSTR;
  501.60 -typedef CHAR TCHAR;
  501.61 -typedef const TCHAR *LPCTSTR;
  501.62 -typedef wchar_t WCHAR;
  501.63 -typedef WCHAR OLECHAR;
  501.64 -typedef const WCHAR *LPCWSTR;
  501.65 -typedef OLECHAR *BSTR;
  501.66 -typedef const OLECHAR *LPCOLESTR;
  501.67 -typedef OLECHAR *LPOLESTR;
  501.68 -
  501.69 -typedef struct _FILETIME
  501.70 -{
  501.71 -  DWORD dwLowDateTime;
  501.72 -  DWORD dwHighDateTime;
  501.73 -}FILETIME;
  501.74 -
  501.75 -#define HRESULT LONG
  501.76 -#define FAILED(Status) ((HRESULT)(Status)<0)
  501.77 -typedef ULONG PROPID;
  501.78 -typedef LONG SCODE;
  501.79 -
  501.80 -#define S_OK    ((HRESULT)0x00000000L)
  501.81 -#define S_FALSE ((HRESULT)0x00000001L)
  501.82 -#define E_NOTIMPL ((HRESULT)0x80004001L)
  501.83 -#define E_NOINTERFACE ((HRESULT)0x80004002L)
  501.84 -#define E_ABORT ((HRESULT)0x80004004L)
  501.85 -#define E_FAIL ((HRESULT)0x80004005L)
  501.86 -#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
  501.87 -#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
  501.88 -#define E_INVALIDARG ((HRESULT)0x80070057L)
  501.89 -
  501.90 -#ifdef _MSC_VER
  501.91 -#define STDMETHODCALLTYPE __stdcall
  501.92 -#else
  501.93 -#define STDMETHODCALLTYPE
  501.94 -#endif
  501.95 -
  501.96 -#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
  501.97 -#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
  501.98 -#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  501.99 -#define STDMETHODIMP STDMETHODIMP_(HRESULT)
 501.100 -
 501.101 -#define PURE = 0
 501.102 -
 501.103 -#define MIDL_INTERFACE(x) struct
 501.104 -
 501.105 -#ifdef __cplusplus
 501.106 -
 501.107 -DEFINE_GUID(IID_IUnknown,
 501.108 -0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
 501.109 -struct IUnknown
 501.110 -{
 501.111 -  STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
 501.112 -  STDMETHOD_(ULONG, AddRef)() PURE;
 501.113 -  STDMETHOD_(ULONG, Release)() PURE;
 501.114 -  #ifndef _WIN32
 501.115 -  virtual ~IUnknown() {}
 501.116 -  #endif
 501.117 -};
 501.118 -
 501.119 -typedef IUnknown *LPUNKNOWN;
 501.120 -
 501.121 -#endif
 501.122 -
 501.123 -#define VARIANT_TRUE ((VARIANT_BOOL)-1)
 501.124 -#define VARIANT_FALSE ((VARIANT_BOOL)0)
 501.125 -
 501.126 -enum VARENUM
 501.127 -{
 501.128 -  VT_EMPTY = 0,
 501.129 -  VT_NULL = 1,
 501.130 -  VT_I2 = 2,
 501.131 -  VT_I4 = 3,
 501.132 -  VT_R4 = 4,
 501.133 -  VT_R8 = 5,
 501.134 -  VT_CY = 6,
 501.135 -  VT_DATE = 7,
 501.136 -  VT_BSTR = 8,
 501.137 -  VT_DISPATCH = 9,
 501.138 -  VT_ERROR = 10,
 501.139 -  VT_BOOL = 11,
 501.140 -  VT_VARIANT = 12,
 501.141 -  VT_UNKNOWN = 13,
 501.142 -  VT_DECIMAL = 14,
 501.143 -  VT_I1 = 16,
 501.144 -  VT_UI1 = 17,
 501.145 -  VT_UI2 = 18,
 501.146 -  VT_UI4 = 19,
 501.147 -  VT_I8 = 20,
 501.148 -  VT_UI8 = 21,
 501.149 -  VT_INT = 22,
 501.150 -  VT_UINT = 23,
 501.151 -  VT_VOID = 24,
 501.152 -  VT_HRESULT = 25,
 501.153 -  VT_FILETIME = 64
 501.154 -};
 501.155 -
 501.156 -typedef unsigned short VARTYPE;
 501.157 -typedef WORD PROPVAR_PAD1;
 501.158 -typedef WORD PROPVAR_PAD2;
 501.159 -typedef WORD PROPVAR_PAD3;
 501.160 -
 501.161 -#ifdef __cplusplus
 501.162 -
 501.163 -typedef struct tagPROPVARIANT
 501.164 -{
 501.165 -  VARTYPE vt;
 501.166 -  PROPVAR_PAD1 wReserved1;
 501.167 -  PROPVAR_PAD2 wReserved2;
 501.168 -  PROPVAR_PAD3 wReserved3;
 501.169 -  union
 501.170 -  {
 501.171 -    CHAR cVal;
 501.172 -    UCHAR bVal;
 501.173 -    SHORT iVal;
 501.174 -    USHORT uiVal;
 501.175 -    LONG lVal;
 501.176 -    ULONG ulVal;
 501.177 -    INT intVal;
 501.178 -    UINT uintVal;
 501.179 -    LARGE_INTEGER hVal;
 501.180 -    ULARGE_INTEGER uhVal;
 501.181 -    VARIANT_BOOL boolVal;
 501.182 -    SCODE scode;
 501.183 -    FILETIME filetime;
 501.184 -    BSTR bstrVal;
 501.185 -  };
 501.186 -} PROPVARIANT;
 501.187 -
 501.188 -typedef PROPVARIANT tagVARIANT;
 501.189 -typedef tagVARIANT VARIANT;
 501.190 -typedef VARIANT VARIANTARG;
 501.191 -
 501.192 -MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
 501.193 -MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
 501.194 -
 501.195 -#endif
 501.196 -
 501.197 -MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
 501.198 -MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
 501.199 -MY_EXTERN_C void SysFreeString(BSTR bstr);
 501.200 -MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
 501.201 -MY_EXTERN_C UINT SysStringLen(BSTR bstr);
 501.202 -
 501.203 -MY_EXTERN_C DWORD GetLastError();
 501.204 -MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
 501.205 -
 501.206 -#define CP_ACP    0
 501.207 -#define CP_OEMCP  1
 501.208 -
 501.209 -typedef enum tagSTREAM_SEEK
 501.210 -{
 501.211 -  STREAM_SEEK_SET = 0,
 501.212 -  STREAM_SEEK_CUR = 1,
 501.213 -  STREAM_SEEK_END = 2
 501.214 -} STREAM_SEEK;
 501.215 -
 501.216 -#endif
 501.217 -#endif
   502.1 --- a/src/win32/7zip/7z/CPP/Common/MyXml.cpp	Sat Mar 03 10:54:39 2012 -0600
   502.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   502.3 @@ -1,209 +0,0 @@
   502.4 -// MyXml.cpp
   502.5 -
   502.6 -#include "StdAfx.h"
   502.7 -
   502.8 -#include "MyXml.h"
   502.9 -
  502.10 -static bool IsValidChar(char c)
  502.11 -{
  502.12 -  return
  502.13 -    c >= 'a' && c <= 'z' ||
  502.14 -    c >= 'A' && c <= 'Z' ||
  502.15 -    c >= '0' && c <= '9' ||
  502.16 -    c == '-';
  502.17 -}
  502.18 -
  502.19 -static bool IsSpaceChar(char c)
  502.20 -{
  502.21 -  return (c == ' ' || c == '\t' || c == 0x0D || c == 0x0A);
  502.22 -}
  502.23 -
  502.24 -#define SKEEP_SPACES(s, pos) while (IsSpaceChar(s[pos])) pos++;
  502.25 -
  502.26 -static bool ReadProperty(const AString &s, int &pos, CXmlProp &prop)
  502.27 -{
  502.28 -  prop.Name.Empty();
  502.29 -  prop.Value.Empty();
  502.30 -  for (; pos < s.Length(); pos++)
  502.31 -  {
  502.32 -    char c = s[pos];
  502.33 -    if (!IsValidChar(c))
  502.34 -      break;
  502.35 -    prop.Name += c;
  502.36 -  }
  502.37 -  
  502.38 -  if (prop.Name.IsEmpty())
  502.39 -    return false;
  502.40 -
  502.41 -  SKEEP_SPACES(s, pos);
  502.42 -  if (s[pos++] != '=')
  502.43 -    return false;
  502.44 -
  502.45 -  SKEEP_SPACES(s, pos);
  502.46 -  if (s[pos++] != '\"')
  502.47 -    return false;
  502.48 -  
  502.49 -  while (pos < s.Length())
  502.50 -  {
  502.51 -    char c = s[pos++];
  502.52 -    if (c == '\"')
  502.53 -      return true;
  502.54 -    prop.Value += c;
  502.55 -  }
  502.56 -  return false;
  502.57 -}
  502.58 -
  502.59 -int CXmlItem::FindProperty(const AString &propName) const
  502.60 -{
  502.61 -  for (int i = 0; i < Props.Size(); i++)
  502.62 -    if (Props[i].Name == propName)
  502.63 -      return i;
  502.64 -  return -1;
  502.65 -}
  502.66 -
  502.67 -AString CXmlItem::GetPropertyValue(const AString &propName) const
  502.68 -{
  502.69 -  int index = FindProperty(propName);
  502.70 -  if (index >= 0)
  502.71 -    return Props[index].Value;
  502.72 -  return AString();
  502.73 -}
  502.74 -
  502.75 -bool CXmlItem::IsTagged(const AString &tag) const
  502.76 -{
  502.77 -  return (IsTag && Name == tag);
  502.78 -}
  502.79 -
  502.80 -int CXmlItem::FindSubTag(const AString &tag) const
  502.81 -{
  502.82 -  for (int i = 0; i < SubItems.Size(); i++)
  502.83 -    if (SubItems[i].IsTagged(tag))
  502.84 -      return i;
  502.85 -  return -1;
  502.86 -}
  502.87 -
  502.88 -AString CXmlItem::GetSubString() const
  502.89 -{
  502.90 -  if (SubItems.Size() == 1)
  502.91 -  {
  502.92 -    const CXmlItem &item = SubItems[0];
  502.93 -    if (!item.IsTag)
  502.94 -      return item.Name;
  502.95 -  }
  502.96 -  return AString();
  502.97 -}
  502.98 -
  502.99 -AString CXmlItem::GetSubStringForTag(const AString &tag) const
 502.100 -{
 502.101 -  int index = FindSubTag(tag);
 502.102 -  if (index >= 0)
 502.103 -    return SubItems[index].GetSubString();
 502.104 -  return AString();
 502.105 -}
 502.106 -
 502.107 -bool CXmlItem::ParseItems(const AString &s, int &pos, int numAllowedLevels)
 502.108 -{
 502.109 -  if (numAllowedLevels == 0)
 502.110 -    return false;
 502.111 -  SubItems.Clear();
 502.112 -  AString finishString = "</";
 502.113 -  for (;;)
 502.114 -  {
 502.115 -    SKEEP_SPACES(s, pos);
 502.116 -
 502.117 -    if (s.Mid(pos, finishString.Length()) == finishString)
 502.118 -      return true;
 502.119 -      
 502.120 -    CXmlItem item;
 502.121 -    if (!item.ParseItem(s, pos, numAllowedLevels - 1))
 502.122 -      return false;
 502.123 -    SubItems.Add(item);
 502.124 -  }
 502.125 -}
 502.126 -
 502.127 -bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
 502.128 -{
 502.129 -  SKEEP_SPACES(s, pos);
 502.130 -
 502.131 -  int pos2 = s.Find('<', pos);
 502.132 -  if (pos2 < 0)
 502.133 -    return false;
 502.134 -  if (pos2 != pos)
 502.135 -  {
 502.136 -    IsTag = false;
 502.137 -    Name += s.Mid(pos, pos2 - pos);
 502.138 -    pos = pos2;
 502.139 -    return true;
 502.140 -  }
 502.141 -  IsTag = true;
 502.142 -
 502.143 -  pos++;
 502.144 -  SKEEP_SPACES(s, pos);
 502.145 -
 502.146 -  for (; pos < s.Length(); pos++)
 502.147 -  {
 502.148 -    char c = s[pos];
 502.149 -    if (!IsValidChar(c))
 502.150 -      break;
 502.151 -    Name += c;
 502.152 -  }
 502.153 -  if (Name.IsEmpty() || pos == s.Length())
 502.154 -    return false;
 502.155 -
 502.156 -  int posTemp = pos;
 502.157 -  for (;;)
 502.158 -  {
 502.159 -    SKEEP_SPACES(s, pos);
 502.160 -    if (s[pos] == '/')
 502.161 -    {
 502.162 -      pos++;
 502.163 -      // SKEEP_SPACES(s, pos);
 502.164 -      return (s[pos++] == '>');
 502.165 -    }
 502.166 -    if (s[pos] == '>')
 502.167 -    {
 502.168 -      if (!ParseItems(s, ++pos, numAllowedLevels))
 502.169 -        return false;
 502.170 -      AString finishString = AString("</") + Name + AString(">");
 502.171 -      if (s.Mid(pos, finishString.Length()) != finishString)
 502.172 -        return false;
 502.173 -      pos += finishString.Length();
 502.174 -      return true;
 502.175 -    }
 502.176 -    if (posTemp == pos)
 502.177 -      return false;
 502.178 -
 502.179 -    CXmlProp prop;
 502.180 -    if (!ReadProperty(s, pos, prop))
 502.181 -      return false;
 502.182 -    Props.Add(prop);
 502.183 -    posTemp = pos;
 502.184 -  }
 502.185 -}
 502.186 -
 502.187 -bool SkeepHeader(const AString &s, int &pos, const AString &startString, const AString &endString)
 502.188 -{
 502.189 -  SKEEP_SPACES(s, pos);
 502.190 -  if (s.Mid(pos, startString.Length()) == startString)
 502.191 -  {
 502.192 -    pos = s.Find(endString, pos);
 502.193 -    if (pos < 0)
 502.194 -      return false;
 502.195 -    pos += endString.Length();
 502.196 -    SKEEP_SPACES(s, pos);
 502.197 -  }
 502.198 -  return true;
 502.199 -}
 502.200 -
 502.201 -bool CXml::Parse(const AString &s)
 502.202 -{
 502.203 -  int pos = 0;
 502.204 -  if (!SkeepHeader(s, pos, "<?xml", "?>"))
 502.205 -    return false;
 502.206 -  if (!SkeepHeader(s, pos, "<!DOCTYPE", ">"))
 502.207 -    return false;
 502.208 -  if (!Root.ParseItem(s, pos, 1000))
 502.209 -    return false;
 502.210 -  SKEEP_SPACES(s, pos);
 502.211 -  return (pos == s.Length() && Root.IsTag);
 502.212 -}
   503.1 --- a/src/win32/7zip/7z/CPP/Common/MyXml.h	Sat Mar 03 10:54:39 2012 -0600
   503.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   503.3 @@ -1,40 +0,0 @@
   503.4 -// MyXml.h
   503.5 -
   503.6 -#ifndef __MYXML_H
   503.7 -#define __MYXML_H
   503.8 -
   503.9 -#include "MyString.h"
  503.10 -
  503.11 -struct CXmlProp
  503.12 -{
  503.13 -  AString Name;
  503.14 -  AString Value;
  503.15 -};
  503.16 -
  503.17 -class CXmlItem
  503.18 -{
  503.19 -  bool ParseItems(const AString &s, int &pos, int numAllowedLevels);
  503.20 -
  503.21 -public:
  503.22 -  AString Name;
  503.23 -  bool IsTag;
  503.24 -  CObjectVector<CXmlProp> Props;
  503.25 -  CObjectVector<CXmlItem> SubItems;
  503.26 -
  503.27 -  bool ParseItem(const AString &s, int &pos, int numAllowedLevels);
  503.28 -  
  503.29 -  bool IsTagged(const AString &tag) const;
  503.30 -  int FindProperty(const AString &propName) const;
  503.31 -  AString GetPropertyValue(const AString &propName) const;
  503.32 -  AString GetSubString() const;
  503.33 -  int FindSubTag(const AString &tag) const;
  503.34 -  AString GetSubStringForTag(const AString &tag) const;
  503.35 -};
  503.36 -
  503.37 -struct CXml
  503.38 -{
  503.39 -  CXmlItem Root;
  503.40 -  bool Parse(const AString &s);
  503.41 -};
  503.42 -
  503.43 -#endif
   504.1 --- a/src/win32/7zip/7z/CPP/Common/NewHandler.cpp	Sat Mar 03 10:54:39 2012 -0600
   504.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   504.3 @@ -1,116 +0,0 @@
   504.4 -// NewHandler.cpp
   504.5 - 
   504.6 -#include "StdAfx.h"
   504.7 -
   504.8 -#include <stdlib.h>
   504.9 -
  504.10 -#include "NewHandler.h"
  504.11 -
  504.12 -// #define DEBUG_MEMORY_LEAK
  504.13 -
  504.14 -#ifndef DEBUG_MEMORY_LEAK
  504.15 -
  504.16 -#ifdef _WIN32
  504.17 -void *
  504.18 -#ifdef _MSC_VER
  504.19 -__cdecl
  504.20 -#endif
  504.21 -operator new(size_t size)
  504.22 -{
  504.23 -  // void *p = ::HeapAlloc(::GetProcessHeap(), 0, size);
  504.24 -  void *p = ::malloc(size);
  504.25 -  if (p == 0)
  504.26 -    throw CNewException();
  504.27 -  return p;
  504.28 -}
  504.29 -
  504.30 -void
  504.31 -#ifdef _MSC_VER
  504.32 -__cdecl
  504.33 -#endif
  504.34 -operator delete(void *p) throw()
  504.35 -{
  504.36 -  /*
  504.37 -  if (p == 0)
  504.38 -    return;
  504.39 -  ::HeapFree(::GetProcessHeap(), 0, p);
  504.40 -  */
  504.41 -  ::free(p);
  504.42 -}
  504.43 -#endif
  504.44 -
  504.45 -#else
  504.46 -
  504.47 -#pragma init_seg(lib)
  504.48 -const int kDebugSize = 1000000;
  504.49 -static void *a[kDebugSize];
  504.50 -static int index = 0;
  504.51 -
  504.52 -static int numAllocs = 0;
  504.53 -void * __cdecl operator new(size_t size)
  504.54 -{
  504.55 -  numAllocs++;
  504.56 -  void *p = HeapAlloc(GetProcessHeap(), 0, size);
  504.57 -  if (index == 40)
  504.58 -  {
  504.59 -    int t = 1;
  504.60 -  }
  504.61 -  if (index < kDebugSize)
  504.62 -  {
  504.63 -    a[index] = p;
  504.64 -    index++;
  504.65 -  }
  504.66 -  if (p == 0)
  504.67 -    throw CNewException();
  504.68 -  printf("Alloc %6d, size = %8d\n", numAllocs, size);
  504.69 -  return p;
  504.70 -}
  504.71 -
  504.72 -class CC
  504.73 -{
  504.74 -public:
  504.75 -  CC()
  504.76 -  {
  504.77 -    for (int i = 0; i < kDebugSize; i++)
  504.78 -      a[i] = 0;
  504.79 -  }
  504.80 -  ~CC()
  504.81 -  {
  504.82 -    for (int i = 0; i < kDebugSize; i++)
  504.83 -      if (a[i] != 0)
  504.84 -        return;
  504.85 -  }
  504.86 -} g_CC;
  504.87 -
  504.88 -
  504.89 -void __cdecl operator delete(void *p)
  504.90 -{
  504.91 -  if (p == 0)
  504.92 -    return;
  504.93 -  /*
  504.94 -  for (int i = 0; i < index; i++)
  504.95 -    if (a[i] == p)
  504.96 -      a[i] = 0;
  504.97 -  */
  504.98 -  HeapFree(GetProcessHeap(), 0, p);
  504.99 -  numAllocs--;
 504.100 -  printf("Free %d\n", numAllocs);
 504.101 -}
 504.102 -
 504.103 -#endif
 504.104 -
 504.105 -/*
 504.106 -int MemErrorVC(size_t)
 504.107 -{
 504.108 -  throw CNewException();
 504.109 -  // return 1;
 504.110 -}
 504.111 -CNewHandlerSetter::CNewHandlerSetter()
 504.112 -{
 504.113 -  // MemErrorOldVCFunction = _set_new_handler(MemErrorVC);
 504.114 -}
 504.115 -CNewHandlerSetter::~CNewHandlerSetter()
 504.116 -{
 504.117 -  // _set_new_handler(MemErrorOldVCFunction);
 504.118 -}
 504.119 -*/
   505.1 --- a/src/win32/7zip/7z/CPP/Common/NewHandler.h	Sat Mar 03 10:54:39 2012 -0600
   505.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   505.3 @@ -1,16 +0,0 @@
   505.4 -// Common/NewHandler.h
   505.5 -
   505.6 -#ifndef __COMMON_NEWHANDLER_H
   505.7 -#define __COMMON_NEWHANDLER_H
   505.8 -
   505.9 -class CNewException {};
  505.10 -
  505.11 -#ifdef _WIN32
  505.12 -void
  505.13 -#ifdef _MSC_VER
  505.14 -__cdecl
  505.15 -#endif
  505.16 -operator delete(void *p) throw();
  505.17 -#endif
  505.18 -
  505.19 -#endif
   506.1 --- a/src/win32/7zip/7z/CPP/Common/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   506.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   506.3 @@ -1,9 +0,0 @@
   506.4 -// StdAfx.h
   506.5 -
   506.6 -#ifndef __STDAFX_H
   506.7 -#define __STDAFX_H
   506.8 -
   506.9 -#include "MyWindows.h"
  506.10 -#include "NewHandler.h"
  506.11 -
  506.12 -#endif
   507.1 --- a/src/win32/7zip/7z/CPP/Common/StringConvert.cpp	Sat Mar 03 10:54:39 2012 -0600
   507.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   507.3 @@ -1,102 +0,0 @@
   507.4 -// Common/StringConvert.cpp
   507.5 -
   507.6 -#include "StdAfx.h"
   507.7 -
   507.8 -#include "StringConvert.h"
   507.9 -
  507.10 -#ifndef _WIN32
  507.11 -#include <stdlib.h>
  507.12 -#endif
  507.13 -
  507.14 -#ifdef _WIN32
  507.15 -UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
  507.16 -{
  507.17 -  UString resultString;
  507.18 -  if (!srcString.IsEmpty())
  507.19 -  {
  507.20 -    int numChars = MultiByteToWideChar(codePage, 0, srcString,
  507.21 -      srcString.Length(), resultString.GetBuffer(srcString.Length()),
  507.22 -      srcString.Length() + 1);
  507.23 -    #ifndef _WIN32_WCE
  507.24 -    if (numChars == 0)
  507.25 -      throw 282228;
  507.26 -    #endif
  507.27 -    resultString.ReleaseBuffer(numChars);
  507.28 -  }
  507.29 -  return resultString;
  507.30 -}
  507.31 -
  507.32 -AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultChar, bool &defaultCharWasUsed)
  507.33 -{
  507.34 -  AString dest;
  507.35 -  defaultCharWasUsed = false;
  507.36 -  if (!s.IsEmpty())
  507.37 -  {
  507.38 -    int numRequiredBytes = s.Length() * 2;
  507.39 -    BOOL defUsed;
  507.40 -    int numChars = WideCharToMultiByte(codePage, 0, s, s.Length(),
  507.41 -        dest.GetBuffer(numRequiredBytes), numRequiredBytes + 1,
  507.42 -        &defaultChar, &defUsed);
  507.43 -    defaultCharWasUsed = (defUsed != FALSE);
  507.44 -    #ifndef _WIN32_WCE
  507.45 -    if (numChars == 0)
  507.46 -      throw 282229;
  507.47 -    #endif
  507.48 -    dest.ReleaseBuffer(numChars);
  507.49 -  }
  507.50 -  return dest;
  507.51 -}
  507.52 -
  507.53 -AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
  507.54 -{
  507.55 -  bool defaultCharWasUsed;
  507.56 -  return UnicodeStringToMultiByte(srcString, codePage, '_', defaultCharWasUsed);
  507.57 -}
  507.58 -
  507.59 -#ifndef _WIN32_WCE
  507.60 -AString SystemStringToOemString(const CSysString &srcString)
  507.61 -{
  507.62 -  AString result;
  507.63 -  CharToOem(srcString, result.GetBuffer(srcString.Length() * 2));
  507.64 -  result.ReleaseBuffer();
  507.65 -  return result;
  507.66 -}
  507.67 -#endif
  507.68 -
  507.69 -#else
  507.70 -
  507.71 -UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
  507.72 -{
  507.73 -  UString resultString;
  507.74 -  for (int i = 0; i < srcString.Length(); i++)
  507.75 -    resultString += wchar_t(srcString[i]);
  507.76 -  /*
  507.77 -  if (!srcString.IsEmpty())
  507.78 -  {
  507.79 -    int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1);
  507.80 -    if (numChars < 0) throw "Your environment does not support UNICODE";
  507.81 -    resultString.ReleaseBuffer(numChars);
  507.82 -  }
  507.83 -  */
  507.84 -  return resultString;
  507.85 -}
  507.86 -
  507.87 -AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
  507.88 -{
  507.89 -  AString resultString;
  507.90 -  for (int i = 0; i < srcString.Length(); i++)
  507.91 -    resultString += char(srcString[i]);
  507.92 -  /*
  507.93 -  if (!srcString.IsEmpty())
  507.94 -  {
  507.95 -    int numRequiredBytes = srcString.Length() * 6 + 1;
  507.96 -    int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes);
  507.97 -    if (numChars < 0) throw "Your environment does not support UNICODE";
  507.98 -    resultString.ReleaseBuffer(numChars);
  507.99 -  }
 507.100 -  */
 507.101 -  return resultString;
 507.102 -}
 507.103 -
 507.104 -#endif
 507.105 -
   508.1 --- a/src/win32/7zip/7z/CPP/Common/StringConvert.h	Sat Mar 03 10:54:39 2012 -0600
   508.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   508.3 @@ -1,73 +0,0 @@
   508.4 -// Common/StringConvert.h
   508.5 -
   508.6 -#ifndef __COMMON_STRINGCONVERT_H
   508.7 -#define __COMMON_STRINGCONVERT_H
   508.8 -
   508.9 -#include "MyWindows.h"
  508.10 -#include "MyString.h"
  508.11 -#include "Types.h"
  508.12 -
  508.13 -UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
  508.14 -AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
  508.15 -AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP);
  508.16 -
  508.17 -
  508.18 -inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
  508.19 -  { return unicodeString; }
  508.20 -inline const UString& GetUnicodeString(const UString &unicodeString)
  508.21 -  { return unicodeString; }
  508.22 -inline UString GetUnicodeString(const AString &ansiString)
  508.23 -  { return MultiByteToUnicodeString(ansiString); }
  508.24 -inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
  508.25 -  { return MultiByteToUnicodeString(multiByteString, codePage); }
  508.26 -inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
  508.27 -  { return unicodeString; }
  508.28 -inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
  508.29 -  { return unicodeString; }
  508.30 -
  508.31 -inline const char* GetAnsiString(const char* ansiString)
  508.32 -  { return ansiString; }
  508.33 -inline const AString& GetAnsiString(const AString &ansiString)
  508.34 -  { return ansiString; }
  508.35 -inline AString GetAnsiString(const UString &unicodeString)
  508.36 -  { return UnicodeStringToMultiByte(unicodeString); }
  508.37 -
  508.38 -inline const char* GetOemString(const char* oemString)
  508.39 -  { return oemString; }
  508.40 -inline const AString& GetOemString(const AString &oemString)
  508.41 -  { return oemString; }
  508.42 -inline AString GetOemString(const UString &unicodeString)
  508.43 -  { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
  508.44 -
  508.45 -
  508.46 -#ifdef _UNICODE
  508.47 -  inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
  508.48 -    { return unicodeString;}
  508.49 -  inline const UString& GetSystemString(const UString &unicodeString)
  508.50 -    { return unicodeString;}
  508.51 -  inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
  508.52 -    { return unicodeString;}
  508.53 -  inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
  508.54 -    { return unicodeString;}
  508.55 -  inline UString GetSystemString(const AString &multiByteString, UINT codePage)
  508.56 -    { return MultiByteToUnicodeString(multiByteString, codePage);}
  508.57 -  inline UString GetSystemString(const AString &multiByteString)
  508.58 -    { return MultiByteToUnicodeString(multiByteString);}
  508.59 -#else
  508.60 -  inline const char* GetSystemString(const char *ansiString)
  508.61 -    { return ansiString; }
  508.62 -  inline const AString& GetSystemString(const AString &multiByteString, UINT)
  508.63 -    { return multiByteString; }
  508.64 -  inline const char * GetSystemString(const char *multiByteString, UINT)
  508.65 -    { return multiByteString; }
  508.66 -  inline AString GetSystemString(const UString &unicodeString)
  508.67 -    { return UnicodeStringToMultiByte(unicodeString); }
  508.68 -  inline AString GetSystemString(const UString &unicodeString, UINT codePage)
  508.69 -    { return UnicodeStringToMultiByte(unicodeString, codePage); }
  508.70 -#endif
  508.71 -
  508.72 -#ifndef _WIN32_WCE
  508.73 -AString SystemStringToOemString(const CSysString &srcString);
  508.74 -#endif
  508.75 -
  508.76 -#endif
   509.1 --- a/src/win32/7zip/7z/CPP/Common/StringToInt.cpp	Sat Mar 03 10:54:39 2012 -0600
   509.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   509.3 @@ -1,90 +0,0 @@
   509.4 -// Common/StringToInt.cpp
   509.5 -
   509.6 -#include "StdAfx.h"
   509.7 -
   509.8 -#include "StringToInt.h"
   509.9 -
  509.10 -UInt64 ConvertStringToUInt64(const char *s, const char **end)
  509.11 -{
  509.12 -  UInt64 result = 0;
  509.13 -  for (;;)
  509.14 -  {
  509.15 -    char c = *s;
  509.16 -    if (c < '0' || c > '9')
  509.17 -    {
  509.18 -      if (end != NULL)
  509.19 -        *end = s;
  509.20 -      return result;
  509.21 -    }
  509.22 -    result *= 10;
  509.23 -    result += (c - '0');
  509.24 -    s++;
  509.25 -  }
  509.26 -}
  509.27 -
  509.28 -UInt64 ConvertOctStringToUInt64(const char *s, const char **end)
  509.29 -{
  509.30 -  UInt64 result = 0;
  509.31 -  for (;;)
  509.32 -  {
  509.33 -    char c = *s;
  509.34 -    if (c < '0' || c > '7')
  509.35 -    {
  509.36 -      if (end != NULL)
  509.37 -        *end = s;
  509.38 -      return result;
  509.39 -    }
  509.40 -    result <<= 3;
  509.41 -    result += (c - '0');
  509.42 -    s++;
  509.43 -  }
  509.44 -}
  509.45 -
  509.46 -UInt64 ConvertHexStringToUInt64(const char *s, const char **end)
  509.47 -{
  509.48 -  UInt64 result = 0;
  509.49 -  for (;;)
  509.50 -  {
  509.51 -    char c = *s;
  509.52 -    UInt32 v;
  509.53 -    if (c >= '0' && c <= '9') v = (c - '0');
  509.54 -    else if (c >= 'A' && c <= 'F') v = 10 + (c - 'A');
  509.55 -    else if (c >= 'a' && c <= 'f') v = 10 + (c - 'a');
  509.56 -    else
  509.57 -    {
  509.58 -      if (end != NULL)
  509.59 -        *end = s;
  509.60 -      return result;
  509.61 -    }
  509.62 -    result <<= 4;
  509.63 -    result |= v;
  509.64 -    s++;
  509.65 -  }
  509.66 -}
  509.67 -
  509.68 -
  509.69 -UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end)
  509.70 -{
  509.71 -  UInt64 result = 0;
  509.72 -  for (;;)
  509.73 -  {
  509.74 -    wchar_t c = *s;
  509.75 -    if (c < '0' || c > '9')
  509.76 -    {
  509.77 -      if (end != NULL)
  509.78 -        *end = s;
  509.79 -      return result;
  509.80 -    }
  509.81 -    result *= 10;
  509.82 -    result += (c - '0');
  509.83 -    s++;
  509.84 -  }
  509.85 -}
  509.86 -
  509.87 -
  509.88 -Int64 ConvertStringToInt64(const char *s, const char **end)
  509.89 -{
  509.90 -  if (*s == '-')
  509.91 -    return -(Int64)ConvertStringToUInt64(s + 1, end);
  509.92 -  return ConvertStringToUInt64(s, end);
  509.93 -}
   510.1 --- a/src/win32/7zip/7z/CPP/Common/StringToInt.h	Sat Mar 03 10:54:39 2012 -0600
   510.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   510.3 @@ -1,18 +0,0 @@
   510.4 -// Common/StringToInt.h
   510.5 -
   510.6 -#ifndef __COMMON_STRINGTOINT_H
   510.7 -#define __COMMON_STRINGTOINT_H
   510.8 -
   510.9 -#include <string.h>
  510.10 -#include "Types.h"
  510.11 -
  510.12 -UInt64 ConvertStringToUInt64(const char *s, const char **end);
  510.13 -UInt64 ConvertOctStringToUInt64(const char *s, const char **end);
  510.14 -UInt64 ConvertHexStringToUInt64(const char *s, const char **end);
  510.15 -UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end);
  510.16 -
  510.17 -Int64 ConvertStringToInt64(const char *s, const char **end);
  510.18 -
  510.19 -#endif
  510.20 -
  510.21 -
   511.1 --- a/src/win32/7zip/7z/CPP/Common/Types.h	Sat Mar 03 10:54:39 2012 -0600
   511.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   511.3 @@ -1,14 +0,0 @@
   511.4 -// Common/Types.h
   511.5 -
   511.6 -#ifndef __COMMON_TYPES_H
   511.7 -#define __COMMON_TYPES_H
   511.8 -
   511.9 -extern "C"
  511.10 -{
  511.11 -#include "../../C/Types.h"
  511.12 -}
  511.13 -
  511.14 -typedef int HRes;
  511.15 -
  511.16 -#endif
  511.17 -
   512.1 --- a/src/win32/7zip/7z/CPP/Common/UTFConvert.cpp	Sat Mar 03 10:54:39 2012 -0600
   512.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   512.3 @@ -1,145 +0,0 @@
   512.4 -// UTFConvert.cpp
   512.5 -
   512.6 -#include "StdAfx.h"
   512.7 -
   512.8 -#include "UTFConvert.h"
   512.9 -#include "Types.h"
  512.10 -
  512.11 -static const Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
  512.12 -
  512.13 -static Bool Utf8_To_Utf16(wchar_t *dest, size_t *destLen, const char *src, size_t srcLen)
  512.14 -{
  512.15 -  size_t destPos = 0, srcPos = 0;
  512.16 -  for (;;)
  512.17 -  {
  512.18 -    Byte c;
  512.19 -    int numAdds;
  512.20 -    if (srcPos == srcLen)
  512.21 -    {
  512.22 -      *destLen = destPos;
  512.23 -      return True;
  512.24 -    }
  512.25 -    c = (Byte)src[srcPos++];
  512.26 -
  512.27 -    if (c < 0x80)
  512.28 -    {
  512.29 -      if (dest)
  512.30 -        dest[destPos] = (wchar_t)c;
  512.31 -      destPos++;
  512.32 -      continue;
  512.33 -    }
  512.34 -    if (c < 0xC0)
  512.35 -      break;
  512.36 -    for (numAdds = 1; numAdds < 5; numAdds++)
  512.37 -      if (c < kUtf8Limits[numAdds])
  512.38 -        break;
  512.39 -    UInt32 value = (c - kUtf8Limits[numAdds - 1]);
  512.40 -
  512.41 -    do
  512.42 -    {
  512.43 -      Byte c2;
  512.44 -      if (srcPos == srcLen)
  512.45 -        break;
  512.46 -      c2 = (Byte)src[srcPos++];
  512.47 -      if (c2 < 0x80 || c2 >= 0xC0)
  512.48 -        break;
  512.49 -      value <<= 6;
  512.50 -      value |= (c2 - 0x80);
  512.51 -    }
  512.52 -    while (--numAdds != 0);
  512.53 -    
  512.54 -    if (value < 0x10000)
  512.55 -    {
  512.56 -      if (dest)
  512.57 -        dest[destPos] = (wchar_t)value;
  512.58 -      destPos++;
  512.59 -    }
  512.60 -    else
  512.61 -    {
  512.62 -      value -= 0x10000;
  512.63 -      if (value >= 0x100000)
  512.64 -        break;
  512.65 -      if (dest)
  512.66 -      {
  512.67 -        dest[destPos + 0] = (wchar_t)(0xD800 + (value >> 10));
  512.68 -        dest[destPos + 1] = (wchar_t)(0xDC00 + (value & 0x3FF));
  512.69 -      }
  512.70 -      destPos += 2;
  512.71 -    }
  512.72 -  }
  512.73 -  *destLen = destPos;
  512.74 -  return False;
  512.75 -}
  512.76 -
  512.77 -static Bool Utf16_To_Utf8(char *dest, size_t *destLen, const wchar_t *src, size_t srcLen)
  512.78 -{
  512.79 -  size_t destPos = 0, srcPos = 0;
  512.80 -  for (;;)
  512.81 -  {
  512.82 -    unsigned numAdds;
  512.83 -    UInt32 value;
  512.84 -    if (srcPos == srcLen)
  512.85 -    {
  512.86 -      *destLen = destPos;
  512.87 -      return True;
  512.88 -    }
  512.89 -    value = src[srcPos++];
  512.90 -    if (value < 0x80)
  512.91 -    {
  512.92 -      if (dest)
  512.93 -        dest[destPos] = (char)value;
  512.94 -      destPos++;
  512.95 -      continue;
  512.96 -    }
  512.97 -    if (value >= 0xD800 && value < 0xE000)
  512.98 -    {
  512.99 -      UInt32 c2;
 512.100 -      if (value >= 0xDC00 || srcPos == srcLen)
 512.101 -        break;
 512.102 -      c2 = src[srcPos++];
 512.103 -      if (c2 < 0xDC00 || c2 >= 0xE000)
 512.104 -        break;
 512.105 -      value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
 512.106 -    }
 512.107 -    for (numAdds = 1; numAdds < 5; numAdds++)
 512.108 -      if (value < (((UInt32)1) << (numAdds * 5 + 6)))
 512.109 -        break;
 512.110 -    if (dest)
 512.111 -      dest[destPos] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
 512.112 -    destPos++;
 512.113 -    do
 512.114 -    {
 512.115 -      numAdds--;
 512.116 -      if (dest)
 512.117 -        dest[destPos] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
 512.118 -      destPos++;
 512.119 -    }
 512.120 -    while (numAdds != 0);
 512.121 -  }
 512.122 -  *destLen = destPos;
 512.123 -  return False;
 512.124 -}
 512.125 -
 512.126 -bool ConvertUTF8ToUnicode(const AString &src, UString &dest)
 512.127 -{
 512.128 -  dest.Empty();
 512.129 -  size_t destLen = 0;
 512.130 -  Utf8_To_Utf16(NULL, &destLen, src, src.Length());
 512.131 -  wchar_t *p = dest.GetBuffer((int)destLen);
 512.132 -  Bool res = Utf8_To_Utf16(p, &destLen, src, src.Length());
 512.133 -  p[destLen] = 0;
 512.134 -  dest.ReleaseBuffer();
 512.135 -  return res ? true : false;
 512.136 -}
 512.137 -
 512.138 -bool ConvertUnicodeToUTF8(const UString &src, AString &dest)
 512.139 -{
 512.140 -  dest.Empty();
 512.141 -  size_t destLen = 0;
 512.142 -  Utf16_To_Utf8(NULL, &destLen, src, src.Length());
 512.143 -  char *p = dest.GetBuffer((int)destLen);
 512.144 -  Bool res = Utf16_To_Utf8(p, &destLen, src, src.Length());
 512.145 -  p[destLen] = 0;
 512.146 -  dest.ReleaseBuffer();
 512.147 -  return res ? true : false;
 512.148 -}
   513.1 --- a/src/win32/7zip/7z/CPP/Common/UTFConvert.h	Sat Mar 03 10:54:39 2012 -0600
   513.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   513.3 @@ -1,11 +0,0 @@
   513.4 -// Common/UTFConvert.h
   513.5 -
   513.6 -#ifndef __COMMON_UTFCONVERT_H
   513.7 -#define __COMMON_UTFCONVERT_H
   513.8 -
   513.9 -#include "MyString.h"
  513.10 -
  513.11 -bool ConvertUTF8ToUnicode(const AString &utfString, UString &resultString);
  513.12 -bool ConvertUnicodeToUTF8(const UString &unicodeString, AString &resultString);
  513.13 -
  513.14 -#endif
   514.1 --- a/src/win32/7zip/7z/CPP/Common/Wildcard.cpp	Sat Mar 03 10:54:39 2012 -0600
   514.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   514.3 @@ -1,458 +0,0 @@
   514.4 -// Common/Wildcard.cpp
   514.5 -
   514.6 -#include "StdAfx.h"
   514.7 -
   514.8 -#include "Wildcard.h"
   514.9 -
  514.10 -bool g_CaseSensitive =
  514.11 -  #ifdef _WIN32
  514.12 -    false;
  514.13 -  #else
  514.14 -    true;
  514.15 -  #endif
  514.16 -
  514.17 -static const wchar_t kAnyCharsChar = L'*';
  514.18 -static const wchar_t kAnyCharChar = L'?';
  514.19 -
  514.20 -#ifdef _WIN32
  514.21 -static const wchar_t kDirDelimiter1 = L'\\';
  514.22 -#endif
  514.23 -static const wchar_t kDirDelimiter2 = L'/';
  514.24 -
  514.25 -static const UString kWildCardCharSet = L"?*";
  514.26 -
  514.27 -static const UString kIllegalWildCardFileNameChars=
  514.28 -  L"\x1\x2\x3\x4\x5\x6\x7\x8\x9\xA\xB\xC\xD\xE\xF"
  514.29 -  L"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
  514.30 -  L"\"/:<>\\|";
  514.31 -
  514.32 -
  514.33 -static inline bool IsCharDirLimiter(wchar_t c)
  514.34 -{
  514.35 -  return (
  514.36 -    #ifdef _WIN32
  514.37 -    c == kDirDelimiter1 ||
  514.38 -    #endif
  514.39 -    c == kDirDelimiter2);
  514.40 -}
  514.41 -
  514.42 -int CompareFileNames(const UString &s1, const UString &s2)
  514.43 -{
  514.44 -  if (g_CaseSensitive)
  514.45 -    return s1.Compare(s2);
  514.46 -  return s1.CompareNoCase(s2);
  514.47 -}
  514.48 -
  514.49 -// -----------------------------------------
  514.50 -// this function compares name with mask
  514.51 -// ? - any char
  514.52 -// * - any char or empty
  514.53 -
  514.54 -static bool EnhancedMaskTest(const wchar_t *mask, const wchar_t *name)
  514.55 -{
  514.56 -  for (;;)
  514.57 -  {
  514.58 -    wchar_t m = *mask;
  514.59 -    wchar_t c = *name;
  514.60 -    if (m == 0)
  514.61 -      return (c == 0);
  514.62 -    if (m == kAnyCharsChar)
  514.63 -    {
  514.64 -      if (EnhancedMaskTest(mask + 1, name))
  514.65 -        return true;
  514.66 -      if (c == 0)
  514.67 -        return false;
  514.68 -    }
  514.69 -    else
  514.70 -    {
  514.71 -      if (m == kAnyCharChar)
  514.72 -      {
  514.73 -        if (c == 0)
  514.74 -          return false;
  514.75 -      }
  514.76 -      else if (m != c)
  514.77 -        if (g_CaseSensitive || MyCharUpper(m) != MyCharUpper(c))
  514.78 -          return false;
  514.79 -      mask++;
  514.80 -    }
  514.81 -    name++;
  514.82 -  }
  514.83 -}
  514.84 -
  514.85 -// --------------------------------------------------
  514.86 -// Splits path to strings
  514.87 -
  514.88 -void SplitPathToParts(const UString &path, UStringVector &pathParts)
  514.89 -{
  514.90 -  pathParts.Clear();
  514.91 -  UString name;
  514.92 -  int len = path.Length();
  514.93 -  if (len == 0)
  514.94 -    return;
  514.95 -  for (int i = 0; i < len; i++)
  514.96 -  {
  514.97 -    wchar_t c = path[i];
  514.98 -    if (IsCharDirLimiter(c))
  514.99 -    {
 514.100 -      pathParts.Add(name);
 514.101 -      name.Empty();
 514.102 -    }
 514.103 -    else
 514.104 -      name += c;
 514.105 -  }
 514.106 -  pathParts.Add(name);
 514.107 -}
 514.108 -
 514.109 -void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name)
 514.110 -{
 514.111 -  int i;
 514.112 -  for (i = path.Length() - 1; i >= 0; i--)
 514.113 -    if (IsCharDirLimiter(path[i]))
 514.114 -      break;
 514.115 -  dirPrefix = path.Left(i + 1);
 514.116 -  name = path.Mid(i + 1);
 514.117 -}
 514.118 -
 514.119 -UString ExtractDirPrefixFromPath(const UString &path)
 514.120 -{
 514.121 -  int i;
 514.122 -  for (i = path.Length() - 1; i >= 0; i--)
 514.123 -    if (IsCharDirLimiter(path[i]))
 514.124 -      break;
 514.125 -  return path.Left(i + 1);
 514.126 -}
 514.127 -
 514.128 -UString ExtractFileNameFromPath(const UString &path)
 514.129 -{
 514.130 -  int i;
 514.131 -  for (i = path.Length() - 1; i >= 0; i--)
 514.132 -    if (IsCharDirLimiter(path[i]))
 514.133 -      break;
 514.134 -  return path.Mid(i + 1);
 514.135 -}
 514.136 -
 514.137 -
 514.138 -bool CompareWildCardWithName(const UString &mask, const UString &name)
 514.139 -{
 514.140 -  return EnhancedMaskTest(mask, name);
 514.141 -}
 514.142 -
 514.143 -bool DoesNameContainWildCard(const UString &path)
 514.144 -{
 514.145 -  return (path.FindOneOf(kWildCardCharSet) >= 0);
 514.146 -}
 514.147 -
 514.148 -
 514.149 -// ----------------------------------------------------------'
 514.150 -// NWildcard
 514.151 -
 514.152 -namespace NWildcard {
 514.153 -
 514.154 -
 514.155 -/*
 514.156 -M = MaskParts.Size();
 514.157 -N = TestNameParts.Size();
 514.158 -
 514.159 -                           File                          Dir
 514.160 -ForFile     req   M<=N  [N-M, N)                          -
 514.161 -         nonreq   M=N   [0, M)                            -
 514.162 - 
 514.163 -ForDir      req   M<N   [0, M) ... [N-M-1, N-1)  same as ForBoth-File
 514.164 -         nonreq         [0, M)                   same as ForBoth-File
 514.165 -
 514.166 -ForBoth     req   m<=N  [0, M) ... [N-M, N)      same as ForBoth-File
 514.167 -         nonreq         [0, M)                   same as ForBoth-File
 514.168 -
 514.169 -*/
 514.170 -
 514.171 -bool CItem::CheckPath(const UStringVector &pathParts, bool isFile) const
 514.172 -{
 514.173 -  if (!isFile && !ForDir)
 514.174 -    return false;
 514.175 -  int delta = (int)pathParts.Size() - (int)PathParts.Size();
 514.176 -  if (delta < 0)
 514.177 -    return false;
 514.178 -  int start = 0;
 514.179 -  int finish = 0;
 514.180 -  if (isFile)
 514.181 -  {
 514.182 -    if (!ForDir && !Recursive && delta !=0)
 514.183 -      return false;
 514.184 -    if (!ForFile && delta == 0)
 514.185 -      return false;
 514.186 -    if (!ForDir && Recursive)
 514.187 -      start = delta;
 514.188 -  }
 514.189 -  if (Recursive)
 514.190 -  {
 514.191 -    finish = delta;
 514.192 -    if (isFile && !ForFile)
 514.193 -      finish = delta - 1;
 514.194 -  }
 514.195 -  for (int d = start; d <= finish; d++)
 514.196 -  {
 514.197 -    int i;
 514.198 -    for (i = 0; i < PathParts.Size(); i++)
 514.199 -      if (!CompareWildCardWithName(PathParts[i], pathParts[i + d]))
 514.200 -        break;
 514.201 -    if (i == PathParts.Size())
 514.202 -      return true;
 514.203 -  }
 514.204 -  return false;
 514.205 -}
 514.206 -
 514.207 -int CCensorNode::FindSubNode(const UString &name) const
 514.208 -{
 514.209 -  for (int i = 0; i < SubNodes.Size(); i++)
 514.210 -    if (CompareFileNames(SubNodes[i].Name, name) == 0)
 514.211 -      return i;
 514.212 -  return -1;
 514.213 -}
 514.214 -
 514.215 -void CCensorNode::AddItemSimple(bool include, CItem &item)
 514.216 -{
 514.217 -  if (include)
 514.218 -    IncludeItems.Add(item);
 514.219 -  else
 514.220 -    ExcludeItems.Add(item);
 514.221 -}
 514.222 -
 514.223 -void CCensorNode::AddItem(bool include, CItem &item)
 514.224 -{
 514.225 -  if (item.PathParts.Size() <= 1)
 514.226 -  {
 514.227 -    AddItemSimple(include, item);
 514.228 -    return;
 514.229 -  }
 514.230 -  const UString &front = item.PathParts.Front();
 514.231 -  if (DoesNameContainWildCard(front))
 514.232 -  {
 514.233 -    AddItemSimple(include, item);
 514.234 -    return;
 514.235 -  }
 514.236 -  int index = FindSubNode(front);
 514.237 -  if (index < 0)
 514.238 -    index = SubNodes.Add(CCensorNode(front, this));
 514.239 -  item.PathParts.Delete(0);
 514.240 -  SubNodes[index].AddItem(include, item);
 514.241 -}
 514.242 -
 514.243 -void CCensorNode::AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir)
 514.244 -{
 514.245 -  CItem item;
 514.246 -  SplitPathToParts(path, item.PathParts);
 514.247 -  item.Recursive = recursive;
 514.248 -  item.ForFile = forFile;
 514.249 -  item.ForDir = forDir;
 514.250 -  AddItem(include, item);
 514.251 -}
 514.252 -
 514.253 -bool CCensorNode::NeedCheckSubDirs() const
 514.254 -{
 514.255 -  for (int i = 0; i < IncludeItems.Size(); i++)
 514.256 -  {
 514.257 -    const CItem &item = IncludeItems[i];
 514.258 -    if (item.Recursive || item.PathParts.Size() > 1)
 514.259 -      return true;
 514.260 -  }
 514.261 -  return false;
 514.262 -}
 514.263 -
 514.264 -bool CCensorNode::AreThereIncludeItems() const
 514.265 -{
 514.266 -  if (IncludeItems.Size() > 0)
 514.267 -    return true;
 514.268 -  for (int i = 0; i < SubNodes.Size(); i++)
 514.269 -    if (SubNodes[i].AreThereIncludeItems())
 514.270 -      return true;
 514.271 -  return false;
 514.272 -}
 514.273 -
 514.274 -bool CCensorNode::CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const
 514.275 -{
 514.276 -  const CObjectVector<CItem> &items = include ? IncludeItems : ExcludeItems;
 514.277 -  for (int i = 0; i < items.Size(); i++)
 514.278 -    if (items[i].CheckPath(pathParts, isFile))
 514.279 -      return true;
 514.280 -  return false;
 514.281 -}
 514.282 -
 514.283 -bool CCensorNode::CheckPath(UStringVector &pathParts, bool isFile, bool &include) const
 514.284 -{
 514.285 -  if (CheckPathCurrent(false, pathParts, isFile))
 514.286 -  {
 514.287 -    include = false;
 514.288 -    return true;
 514.289 -  }
 514.290 -  include = true;
 514.291 -  bool finded = CheckPathCurrent(true, pathParts, isFile);
 514.292 -  if (pathParts.Size() == 1)
 514.293 -    return finded;
 514.294 -  int index = FindSubNode(pathParts.Front());
 514.295 -  if (index >= 0)
 514.296 -  {
 514.297 -    UStringVector pathParts2 = pathParts;
 514.298 -    pathParts2.Delete(0);
 514.299 -    if (SubNodes[index].CheckPath(pathParts2, isFile, include))
 514.300 -      return true;
 514.301 -  }
 514.302 -  return finded;
 514.303 -}
 514.304 -
 514.305 -bool CCensorNode::CheckPath(const UString &path, bool isFile, bool &include) const
 514.306 -{
 514.307 -  UStringVector pathParts;
 514.308 -  SplitPathToParts(path, pathParts);
 514.309 -  return CheckPath(pathParts, isFile, include);
 514.310 -}
 514.311 -
 514.312 -bool CCensorNode::CheckPath(const UString &path, bool isFile) const
 514.313 -{
 514.314 -  bool include;
 514.315 -  if (CheckPath(path, isFile, include))
 514.316 -    return include;
 514.317 -  return false;
 514.318 -}
 514.319 -
 514.320 -bool CCensorNode::CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const
 514.321 -{
 514.322 -  if (CheckPathCurrent(include, pathParts, isFile))
 514.323 -    return true;
 514.324 -  if (Parent == 0)
 514.325 -    return false;
 514.326 -  pathParts.Insert(0, Name);
 514.327 -  return Parent->CheckPathToRoot(include, pathParts, isFile);
 514.328 -}
 514.329 -
 514.330 -/*
 514.331 -bool CCensorNode::CheckPathToRoot(bool include, const UString &path, bool isFile) const
 514.332 -{
 514.333 -  UStringVector pathParts;
 514.334 -  SplitPathToParts(path, pathParts);
 514.335 -  return CheckPathToRoot(include, pathParts, isFile);
 514.336 -}
 514.337 -*/
 514.338 -
 514.339 -void CCensorNode::AddItem2(bool include, const UString &path, bool recursive)
 514.340 -{
 514.341 -  if (path.IsEmpty())
 514.342 -    return;
 514.343 -  bool forFile = true;
 514.344 -  bool forFolder = true;
 514.345 -  UString path2 = path;
 514.346 -  if (IsCharDirLimiter(path[path.Length() - 1]))
 514.347 -  {
 514.348 -    path2.Delete(path.Length() - 1);
 514.349 -    forFile = false;
 514.350 -  }
 514.351 -  AddItem(include, path2, recursive, forFile, forFolder);
 514.352 -}
 514.353 -
 514.354 -void CCensorNode::ExtendExclude(const CCensorNode &fromNodes)
 514.355 -{
 514.356 -  ExcludeItems += fromNodes.ExcludeItems;
 514.357 -  for (int i = 0; i < fromNodes.SubNodes.Size(); i++)
 514.358 -  {
 514.359 -    const CCensorNode &node = fromNodes.SubNodes[i];
 514.360 -    int subNodeIndex = FindSubNode(node.Name);
 514.361 -    if (subNodeIndex < 0)
 514.362 -      subNodeIndex = SubNodes.Add(CCensorNode(node.Name, this));
 514.363 -    SubNodes[subNodeIndex].ExtendExclude(node);
 514.364 -  }
 514.365 -}
 514.366 -
 514.367 -int CCensor::FindPrefix(const UString &prefix) const
 514.368 -{
 514.369 -  for (int i = 0; i < Pairs.Size(); i++)
 514.370 -    if (CompareFileNames(Pairs[i].Prefix, prefix) == 0)
 514.371 -      return i;
 514.372 -  return -1;
 514.373 -}
 514.374 -
 514.375 -void CCensor::AddItem(bool include, const UString &path, bool recursive)
 514.376 -{
 514.377 -  UStringVector pathParts;
 514.378 -  SplitPathToParts(path, pathParts);
 514.379 -  bool forFile = true;
 514.380 -  if (pathParts.Back().IsEmpty())
 514.381 -  {
 514.382 -    forFile = false;
 514.383 -    pathParts.DeleteBack();
 514.384 -  }
 514.385 -  const UString &front = pathParts.Front();
 514.386 -  bool isAbs = false;
 514.387 -  if (front.IsEmpty())
 514.388 -    isAbs = true;
 514.389 -  else if (front.Length() == 2 && front[1] == L':')
 514.390 -    isAbs = true;
 514.391 -  else
 514.392 -  {
 514.393 -    for (int i = 0; i < pathParts.Size(); i++)
 514.394 -    {
 514.395 -      const UString &part = pathParts[i];
 514.396 -      if (part == L".." || part == L".")
 514.397 -      {
 514.398 -        isAbs = true;
 514.399 -        break;
 514.400 -      }
 514.401 -    }
 514.402 -  }
 514.403 -  int numAbsParts = 0;
 514.404 -  if (isAbs)
 514.405 -    if (pathParts.Size() > 1)
 514.406 -      numAbsParts = pathParts.Size() - 1;
 514.407 -    else
 514.408 -      numAbsParts = 1;
 514.409 -  UString prefix;
 514.410 -  for (int i = 0; i < numAbsParts; i++)
 514.411 -  {
 514.412 -    const UString &front = pathParts.Front();
 514.413 -    if (DoesNameContainWildCard(front))
 514.414 -      break;
 514.415 -    prefix += front;
 514.416 -    prefix += WCHAR_PATH_SEPARATOR;
 514.417 -    pathParts.Delete(0);
 514.418 -  }
 514.419 -  int index = FindPrefix(prefix);
 514.420 -  if (index < 0)
 514.421 -    index = Pairs.Add(CPair(prefix));
 514.422 -
 514.423 -  CItem item;
 514.424 -  item.PathParts = pathParts;
 514.425 -  item.ForDir = true;
 514.426 -  item.ForFile = forFile;
 514.427 -  item.Recursive = recursive;
 514.428 -  Pairs[index].Head.AddItem(include, item);
 514.429 -}
 514.430 -
 514.431 -bool CCensor::CheckPath(const UString &path, bool isFile) const
 514.432 -{
 514.433 -  bool finded = false;
 514.434 -  for (int i = 0; i < Pairs.Size(); i++)
 514.435 -  {
 514.436 -    bool include;
 514.437 -    if (Pairs[i].Head.CheckPath(path, isFile, include))
 514.438 -    {
 514.439 -      if (!include)
 514.440 -        return false;
 514.441 -      finded = true;
 514.442 -    }
 514.443 -  }
 514.444 -  return finded;
 514.445 -}
 514.446 -
 514.447 -void CCensor::ExtendExclude()
 514.448 -{
 514.449 -  int i;
 514.450 -  for (i = 0; i < Pairs.Size(); i++)
 514.451 -    if (Pairs[i].Prefix.IsEmpty())
 514.452 -      break;
 514.453 -  if (i == Pairs.Size())
 514.454 -    return;
 514.455 -  int index = i;
 514.456 -  for (i = 0; i < Pairs.Size(); i++)
 514.457 -    if (index != i)
 514.458 -      Pairs[i].Head.ExtendExclude(Pairs[index].Head);
 514.459 -}
 514.460 -
 514.461 -}
   515.1 --- a/src/win32/7zip/7z/CPP/Common/Wildcard.h	Sat Mar 03 10:54:39 2012 -0600
   515.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   515.3 @@ -1,80 +0,0 @@
   515.4 -// Common/Wildcard.h
   515.5 -
   515.6 -#ifndef __COMMON_WILDCARD_H
   515.7 -#define __COMMON_WILDCARD_H
   515.8 -
   515.9 -#include "MyString.h"
  515.10 -
  515.11 -int CompareFileNames(const UString &s1, const UString &s2);
  515.12 -
  515.13 -void SplitPathToParts(const UString &path, UStringVector &pathParts);
  515.14 -void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name);
  515.15 -UString ExtractDirPrefixFromPath(const UString &path);
  515.16 -UString ExtractFileNameFromPath(const UString &path);
  515.17 -bool DoesNameContainWildCard(const UString &path);
  515.18 -bool CompareWildCardWithName(const UString &mask, const UString &name);
  515.19 -
  515.20 -namespace NWildcard {
  515.21 -
  515.22 -struct CItem
  515.23 -{
  515.24 -  UStringVector PathParts;
  515.25 -  bool Recursive;
  515.26 -  bool ForFile;
  515.27 -  bool ForDir;
  515.28 -  bool CheckPath(const UStringVector &pathParts, bool isFile) const;
  515.29 -};
  515.30 -
  515.31 -class CCensorNode
  515.32 -{
  515.33 -  CCensorNode *Parent;
  515.34 -  bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const;
  515.35 -  void AddItemSimple(bool include, CItem &item);
  515.36 -  bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const;
  515.37 -public:
  515.38 -  CCensorNode(): Parent(0) { };
  515.39 -  CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { };
  515.40 -  UString Name;
  515.41 -  CObjectVector<CCensorNode> SubNodes;
  515.42 -  CObjectVector<CItem> IncludeItems;
  515.43 -  CObjectVector<CItem> ExcludeItems;
  515.44 -
  515.45 -  int FindSubNode(const UString &path) const;
  515.46 -
  515.47 -  void AddItem(bool include, CItem &item);
  515.48 -  void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir);
  515.49 -  void AddItem2(bool include, const UString &path, bool recursive);
  515.50 -
  515.51 -  bool NeedCheckSubDirs() const;
  515.52 -  bool AreThereIncludeItems() const;
  515.53 -
  515.54 -  bool CheckPath(const UString &path, bool isFile, bool &include) const;
  515.55 -  bool CheckPath(const UString &path, bool isFile) const;
  515.56 -
  515.57 -  bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const;
  515.58 -  // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const;
  515.59 -  void ExtendExclude(const CCensorNode &fromNodes);
  515.60 -};
  515.61 -
  515.62 -struct CPair
  515.63 -{
  515.64 -  UString Prefix;
  515.65 -  CCensorNode Head;
  515.66 -  CPair(const UString &prefix): Prefix(prefix) { };
  515.67 -};
  515.68 -
  515.69 -class CCensor
  515.70 -{
  515.71 -  int FindPrefix(const UString &prefix) const;
  515.72 -public:
  515.73 -  CObjectVector<CPair> Pairs;
  515.74 -  bool AllAreRelative() const
  515.75 -    { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); }
  515.76 -  void AddItem(bool include, const UString &path, bool recursive);
  515.77 -  bool CheckPath(const UString &path, bool isFile) const;
  515.78 -  void ExtendExclude();
  515.79 -};
  515.80 -
  515.81 -}
  515.82 -
  515.83 -#endif
   516.1 --- a/src/win32/7zip/7z/CPP/Windows/Defs.h	Sat Mar 03 10:54:39 2012 -0600
   516.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   516.3 @@ -1,23 +0,0 @@
   516.4 -// Windows/Defs.h
   516.5 -
   516.6 -#ifndef __WINDOWS_DEFS_H
   516.7 -#define __WINDOWS_DEFS_H
   516.8 -
   516.9 -inline bool BOOLToBool(BOOL value)
  516.10 -  { return (value != FALSE); }
  516.11 -
  516.12 -#ifdef _WIN32
  516.13 -inline bool LRESULTToBool(LRESULT value)
  516.14 -  { return (value != FALSE); }
  516.15 -#endif
  516.16 -
  516.17 -inline BOOL BoolToBOOL(bool value)
  516.18 -  { return (value ? TRUE: FALSE); }
  516.19 -
  516.20 -inline VARIANT_BOOL BoolToVARIANT_BOOL(bool value)
  516.21 -  { return (value ? VARIANT_TRUE: VARIANT_FALSE); }
  516.22 -
  516.23 -inline bool VARIANT_BOOLToBool(VARIANT_BOOL value)
  516.24 -  { return (value != VARIANT_FALSE); }
  516.25 -
  516.26 -#endif
   517.1 --- a/src/win32/7zip/7z/CPP/Windows/FileDir.cpp	Sat Mar 03 10:54:39 2012 -0600
   517.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   517.3 @@ -1,841 +0,0 @@
   517.4 -// Windows/FileDir.cpp
   517.5 -
   517.6 -#include "StdAfx.h"
   517.7 -
   517.8 -#include "FileDir.h"
   517.9 -#include "FileName.h"
  517.10 -#include "FileFind.h"
  517.11 -#include "Defs.h"
  517.12 -#ifndef _UNICODE
  517.13 -#include "../Common/StringConvert.h"
  517.14 -#endif
  517.15 -
  517.16 -#ifndef _UNICODE
  517.17 -extern bool g_IsNT;
  517.18 -#endif
  517.19 -
  517.20 -namespace NWindows {
  517.21 -namespace NFile {
  517.22 -
  517.23 -#if defined(WIN_LONG_PATH) && defined(_UNICODE)
  517.24 -#define WIN_LONG_PATH2
  517.25 -#endif
  517.26 -
  517.27 -// SetCurrentDirectory doesn't support \\?\ prefix
  517.28 -
  517.29 -#ifdef WIN_LONG_PATH
  517.30 -bool GetLongPathBase(LPCWSTR fileName, UString &res);
  517.31 -bool GetLongPath(LPCWSTR fileName, UString &res);
  517.32 -#endif
  517.33 -
  517.34 -namespace NDirectory {
  517.35 -
  517.36 -#ifndef _UNICODE
  517.37 -static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
  517.38 -static UString GetUnicodePath(const CSysString &sysPath)
  517.39 -  { return MultiByteToUnicodeString(sysPath, GetCurrentCodePage()); }
  517.40 -static CSysString GetSysPath(LPCWSTR sysPath)
  517.41 -  { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
  517.42 -#endif
  517.43 -
  517.44 -bool MyGetWindowsDirectory(CSysString &path)
  517.45 -{
  517.46 -  UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
  517.47 -  path.ReleaseBuffer();
  517.48 -  return (needLength > 0 && needLength <= MAX_PATH);
  517.49 -}
  517.50 -
  517.51 -bool MyGetSystemDirectory(CSysString &path)
  517.52 -{
  517.53 -  UINT needLength = ::GetSystemDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
  517.54 -  path.ReleaseBuffer();
  517.55 -  return (needLength > 0 && needLength <= MAX_PATH);
  517.56 -}
  517.57 -
  517.58 -#ifndef _UNICODE
  517.59 -bool MyGetWindowsDirectory(UString &path)
  517.60 -{
  517.61 -  if (g_IsNT)
  517.62 -  {
  517.63 -    UINT needLength = ::GetWindowsDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
  517.64 -    path.ReleaseBuffer();
  517.65 -    return (needLength > 0 && needLength <= MAX_PATH);
  517.66 -  }
  517.67 -  CSysString sysPath;
  517.68 -  if (!MyGetWindowsDirectory(sysPath))
  517.69 -    return false;
  517.70 -  path = GetUnicodePath(sysPath);
  517.71 -  return true;
  517.72 -}
  517.73 -
  517.74 -bool MyGetSystemDirectory(UString &path)
  517.75 -{
  517.76 -  if (g_IsNT)
  517.77 -  {
  517.78 -    UINT needLength = ::GetSystemDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
  517.79 -    path.ReleaseBuffer();
  517.80 -    return (needLength > 0 && needLength <= MAX_PATH);
  517.81 -  }
  517.82 -  CSysString sysPath;
  517.83 -  if (!MyGetSystemDirectory(sysPath))
  517.84 -    return false;
  517.85 -  path = GetUnicodePath(sysPath);
  517.86 -  return true;
  517.87 -}
  517.88 -#endif
  517.89 -
  517.90 -bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
  517.91 -{
  517.92 -  #ifndef _UNICODE
  517.93 -  if (!g_IsNT)
  517.94 -  {
  517.95 -    ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  517.96 -    return false;
  517.97 -  }
  517.98 -  #endif
  517.99 -  HANDLE hDir = ::CreateFileW(fileName, GENERIC_WRITE,
 517.100 -      FILE_SHARE_READ | FILE_SHARE_WRITE,
 517.101 -      NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 517.102 -  #ifdef WIN_LONG_PATH
 517.103 -  if (hDir == INVALID_HANDLE_VALUE)
 517.104 -  {
 517.105 -    UString longPath;
 517.106 -    if (GetLongPath(fileName, longPath))
 517.107 -      hDir = ::CreateFileW(longPath, GENERIC_WRITE,
 517.108 -        FILE_SHARE_READ | FILE_SHARE_WRITE,
 517.109 -        NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 517.110 -  }
 517.111 -  #endif
 517.112 -
 517.113 -  bool res = false;
 517.114 -  if (hDir != INVALID_HANDLE_VALUE)
 517.115 -  {
 517.116 -    res = BOOLToBool(::SetFileTime(hDir, cTime, aTime, mTime));
 517.117 -    ::CloseHandle(hDir);
 517.118 -  }
 517.119 -  return res;
 517.120 -}
 517.121 -
 517.122 -bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
 517.123 -{
 517.124 -  if (::SetFileAttributes(fileName, fileAttributes))
 517.125 -    return true;
 517.126 -  #ifdef WIN_LONG_PATH2
 517.127 -  UString longPath;
 517.128 -  if (GetLongPath(fileName, longPath))
 517.129 -    return BOOLToBool(::SetFileAttributesW(longPath, fileAttributes));
 517.130 -  #endif
 517.131 -  return false;
 517.132 -}
 517.133 -
 517.134 -bool MyRemoveDirectory(LPCTSTR pathName)
 517.135 -{
 517.136 -  if (::RemoveDirectory(pathName))
 517.137 -    return true;
 517.138 -  #ifdef WIN_LONG_PATH2
 517.139 -  UString longPath;
 517.140 -  if (GetLongPath(pathName, longPath))
 517.141 -    return BOOLToBool(::RemoveDirectoryW(longPath));
 517.142 -  #endif
 517.143 -  return false;
 517.144 -}
 517.145 -
 517.146 -#ifdef WIN_LONG_PATH
 517.147 -bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2)
 517.148 -{
 517.149 -  if (!GetLongPathBase(s1, d1) || !GetLongPathBase(s2, d2))
 517.150 -    return false;
 517.151 -  if (d1.IsEmpty() && d2.IsEmpty()) return false;
 517.152 -  if (d1.IsEmpty()) d1 = s1;
 517.153 -  if (d2.IsEmpty()) d2 = s2;
 517.154 -  return true;
 517.155 -}
 517.156 -#endif
 517.157 -
 517.158 -bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
 517.159 -{
 517.160 -  if (::MoveFile(existFileName, newFileName))
 517.161 -    return true;
 517.162 -  #ifdef WIN_LONG_PATH2
 517.163 -  UString d1, d2;
 517.164 -  if (GetLongPaths(existFileName, newFileName, d1, d2))
 517.165 -    return BOOLToBool(::MoveFileW(d1, d2));
 517.166 -  #endif
 517.167 -  return false;
 517.168 -}
 517.169 -
 517.170 -#ifndef _UNICODE
 517.171 -bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
 517.172 -{
 517.173 -  if (!g_IsNT)
 517.174 -    return MySetFileAttributes(GetSysPath(fileName), fileAttributes);
 517.175 -  if (::SetFileAttributesW(fileName, fileAttributes))
 517.176 -    return true;
 517.177 -  #ifdef WIN_LONG_PATH
 517.178 -  UString longPath;
 517.179 -  if (GetLongPath(fileName, longPath))
 517.180 -    return BOOLToBool(::SetFileAttributesW(longPath, fileAttributes));
 517.181 -  #endif
 517.182 -  return false;
 517.183 -}
 517.184 -
 517.185 -
 517.186 -bool MyRemoveDirectory(LPCWSTR pathName)
 517.187 -{
 517.188 -  if (!g_IsNT)
 517.189 -    return MyRemoveDirectory(GetSysPath(pathName));
 517.190 -  if (::RemoveDirectoryW(pathName))
 517.191 -    return true;
 517.192 -  #ifdef WIN_LONG_PATH
 517.193 -  UString longPath;
 517.194 -  if (GetLongPath(pathName, longPath))
 517.195 -    return BOOLToBool(::RemoveDirectoryW(longPath));
 517.196 -  #endif
 517.197 -  return false;
 517.198 -}
 517.199 -
 517.200 -bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
 517.201 -{
 517.202 -  if (!g_IsNT)
 517.203 -    return MyMoveFile(GetSysPath(existFileName), GetSysPath(newFileName));
 517.204 -  if (::MoveFileW(existFileName, newFileName))
 517.205 -    return true;
 517.206 -  #ifdef WIN_LONG_PATH
 517.207 -  UString d1, d2;
 517.208 -  if (GetLongPaths(existFileName, newFileName, d1, d2))
 517.209 -    return BOOLToBool(::MoveFileW(d1, d2));
 517.210 -  #endif
 517.211 -  return false;
 517.212 -}
 517.213 -#endif
 517.214 -
 517.215 -bool MyCreateDirectory(LPCTSTR pathName)
 517.216 -{
 517.217 -  if (::CreateDirectory(pathName, NULL))
 517.218 -    return true;
 517.219 -  #ifdef WIN_LONG_PATH2
 517.220 -  if (::GetLastError() != ERROR_ALREADY_EXISTS)
 517.221 -  {
 517.222 -    UString longPath;
 517.223 -    if (GetLongPath(pathName, longPath))
 517.224 -      return BOOLToBool(::CreateDirectoryW(longPath, NULL));
 517.225 -  }
 517.226 -  #endif
 517.227 -  return false;
 517.228 -}
 517.229 -
 517.230 -#ifndef _UNICODE
 517.231 -bool MyCreateDirectory(LPCWSTR pathName)
 517.232 -{
 517.233 -  if (!g_IsNT)
 517.234 -    return MyCreateDirectory(GetSysPath(pathName));
 517.235 -  if (::CreateDirectoryW(pathName, NULL))
 517.236 -    return true;
 517.237 -  #ifdef WIN_LONG_PATH
 517.238 -  if (::GetLastError() != ERROR_ALREADY_EXISTS)
 517.239 -  {
 517.240 -    UString longPath;
 517.241 -    if (GetLongPath(pathName, longPath))
 517.242 -      return BOOLToBool(::CreateDirectoryW(longPath, NULL));
 517.243 -  }
 517.244 -  #endif
 517.245 -  return false;
 517.246 -}
 517.247 -#endif
 517.248 -
 517.249 -/*
 517.250 -bool CreateComplexDirectory(LPCTSTR pathName)
 517.251 -{
 517.252 -  NName::CParsedPath path;
 517.253 -  path.ParsePath(pathName);
 517.254 -  CSysString fullPath = path.Prefix;
 517.255 -  DWORD errorCode = ERROR_SUCCESS;
 517.256 -  for (int i = 0; i < path.PathParts.Size(); i++)
 517.257 -  {
 517.258 -    const CSysString &string = path.PathParts[i];
 517.259 -    if (string.IsEmpty())
 517.260 -    {
 517.261 -      if (i != path.PathParts.Size() - 1)
 517.262 -        return false;
 517.263 -      return true;
 517.264 -    }
 517.265 -    fullPath += path.PathParts[i];
 517.266 -    if (!MyCreateDirectory(fullPath))
 517.267 -    {
 517.268 -      DWORD errorCode = GetLastError();
 517.269 -      if (errorCode != ERROR_ALREADY_EXISTS)
 517.270 -        return false;
 517.271 -    }
 517.272 -    fullPath += NName::kDirDelimiter;
 517.273 -  }
 517.274 -  return true;
 517.275 -}
 517.276 -*/
 517.277 -
 517.278 -bool CreateComplexDirectory(LPCTSTR _aPathName)
 517.279 -{
 517.280 -  CSysString pathName = _aPathName;
 517.281 -  int pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
 517.282 -  if (pos > 0 && pos == pathName.Length() - 1)
 517.283 -  {
 517.284 -    if (pathName.Length() == 3 && pathName[1] == ':')
 517.285 -      return true; // Disk folder;
 517.286 -    pathName.Delete(pos);
 517.287 -  }
 517.288 -  CSysString pathName2 = pathName;
 517.289 -  pos = pathName.Length();
 517.290 -  for (;;)
 517.291 -  {
 517.292 -    if (MyCreateDirectory(pathName))
 517.293 -      break;
 517.294 -    if (::GetLastError() == ERROR_ALREADY_EXISTS)
 517.295 -    {
 517.296 -      NFind::CFileInfo fileInfo;
 517.297 -      if (!NFind::FindFile(pathName, fileInfo)) // For network folders
 517.298 -        return true;
 517.299 -      if (!fileInfo.IsDir())
 517.300 -        return false;
 517.301 -      break;
 517.302 -    }
 517.303 -    pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
 517.304 -    if (pos < 0 || pos == 0)
 517.305 -      return false;
 517.306 -    if (pathName[pos - 1] == ':')
 517.307 -      return false;
 517.308 -    pathName = pathName.Left(pos);
 517.309 -  }
 517.310 -  pathName = pathName2;
 517.311 -  while (pos < pathName.Length())
 517.312 -  {
 517.313 -    pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1);
 517.314 -    if (pos < 0)
 517.315 -      pos = pathName.Length();
 517.316 -    if (!MyCreateDirectory(pathName.Left(pos)))
 517.317 -      return false;
 517.318 -  }
 517.319 -  return true;
 517.320 -}
 517.321 -
 517.322 -#ifndef _UNICODE
 517.323 -
 517.324 -bool CreateComplexDirectory(LPCWSTR _aPathName)
 517.325 -{
 517.326 -  UString pathName = _aPathName;
 517.327 -  int pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
 517.328 -  if (pos > 0 && pos == pathName.Length() - 1)
 517.329 -  {
 517.330 -    if (pathName.Length() == 3 && pathName[1] == L':')
 517.331 -      return true; // Disk folder;
 517.332 -    pathName.Delete(pos);
 517.333 -  }
 517.334 -  UString pathName2 = pathName;
 517.335 -  pos = pathName.Length();
 517.336 -  for (;;)
 517.337 -  {
 517.338 -    if (MyCreateDirectory(pathName))
 517.339 -      break;
 517.340 -    if (::GetLastError() == ERROR_ALREADY_EXISTS)
 517.341 -    {
 517.342 -      NFind::CFileInfoW fileInfo;
 517.343 -      if (!NFind::FindFile(pathName, fileInfo)) // For network folders
 517.344 -        return true;
 517.345 -      if (!fileInfo.IsDir())
 517.346 -        return false;
 517.347 -      break;
 517.348 -    }
 517.349 -    pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
 517.350 -    if (pos < 0 || pos == 0)
 517.351 -      return false;
 517.352 -    if (pathName[pos - 1] == L':')
 517.353 -      return false;
 517.354 -    pathName = pathName.Left(pos);
 517.355 -  }
 517.356 -  pathName = pathName2;
 517.357 -  while (pos < pathName.Length())
 517.358 -  {
 517.359 -    pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1);
 517.360 -    if (pos < 0)
 517.361 -      pos = pathName.Length();
 517.362 -    if (!MyCreateDirectory(pathName.Left(pos)))
 517.363 -      return false;
 517.364 -  }
 517.365 -  return true;
 517.366 -}
 517.367 -
 517.368 -#endif
 517.369 -
 517.370 -bool DeleteFileAlways(LPCTSTR name)
 517.371 -{
 517.372 -  if (!MySetFileAttributes(name, 0))
 517.373 -    return false;
 517.374 -  if (::DeleteFile(name))
 517.375 -    return true;
 517.376 -  #ifdef WIN_LONG_PATH2
 517.377 -  UString longPath;
 517.378 -  if (GetLongPath(name, longPath))
 517.379 -    return BOOLToBool(::DeleteFileW(longPath));
 517.380 -  #endif
 517.381 -  return false;
 517.382 -}
 517.383 -
 517.384 -#ifndef _UNICODE
 517.385 -bool DeleteFileAlways(LPCWSTR name)
 517.386 -{
 517.387 -  if (!g_IsNT)
 517.388 -    return DeleteFileAlways(GetSysPath(name));
 517.389 -  if (!MySetFileAttributes(name, 0))
 517.390 -    return false;
 517.391 -  if (::DeleteFileW(name))
 517.392 -    return true;
 517.393 -  #ifdef WIN_LONG_PATH
 517.394 -  UString longPath;
 517.395 -  if (GetLongPath(name, longPath))
 517.396 -    return BOOLToBool(::DeleteFileW(longPath));
 517.397 -  #endif
 517.398 -  return false;
 517.399 -}
 517.400 -#endif
 517.401 -
 517.402 -static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
 517.403 -{
 517.404 -  if (fileInfo.IsDir())
 517.405 -    return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
 517.406 -  return DeleteFileAlways(pathPrefix + fileInfo.Name);
 517.407 -}
 517.408 -
 517.409 -bool RemoveDirectoryWithSubItems(const CSysString &path)
 517.410 -{
 517.411 -  NFind::CFileInfo fileInfo;
 517.412 -  CSysString pathPrefix = path + NName::kDirDelimiter;
 517.413 -  {
 517.414 -    NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard));
 517.415 -    while (enumerator.Next(fileInfo))
 517.416 -      if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
 517.417 -        return false;
 517.418 -  }
 517.419 -  if (!MySetFileAttributes(path, 0))
 517.420 -    return false;
 517.421 -  return MyRemoveDirectory(path);
 517.422 -}
 517.423 -
 517.424 -#ifndef _UNICODE
 517.425 -static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
 517.426 -{
 517.427 -  if (fileInfo.IsDir())
 517.428 -    return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
 517.429 -  return DeleteFileAlways(pathPrefix + fileInfo.Name);
 517.430 -}
 517.431 -bool RemoveDirectoryWithSubItems(const UString &path)
 517.432 -{
 517.433 -  NFind::CFileInfoW fileInfo;
 517.434 -  UString pathPrefix = path + UString(NName::kDirDelimiter);
 517.435 -  {
 517.436 -    NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard));
 517.437 -    while (enumerator.Next(fileInfo))
 517.438 -      if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
 517.439 -        return false;
 517.440 -  }
 517.441 -  if (!MySetFileAttributes(path, 0))
 517.442 -    return false;
 517.443 -  return MyRemoveDirectory(path);
 517.444 -}
 517.445 -#endif
 517.446 -
 517.447 -#ifndef _WIN32_WCE
 517.448 -
 517.449 -bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
 517.450 -{
 517.451 -  DWORD needLength = ::GetShortPathName(longPath, shortPath.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
 517.452 -  shortPath.ReleaseBuffer();
 517.453 -  return (needLength > 0 && needLength < MAX_PATH);
 517.454 -}
 517.455 -
 517.456 -bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex)
 517.457 -{
 517.458 -  resultPath.Empty();
 517.459 -  LPTSTR fileNamePointer = 0;
 517.460 -  LPTSTR buffer = resultPath.GetBuffer(MAX_PATH);
 517.461 -  DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
 517.462 -  resultPath.ReleaseBuffer();
 517.463 -  if (needLength == 0)
 517.464 -    return false;
 517.465 -  if (needLength >= MAX_PATH)
 517.466 -  {
 517.467 -    #ifdef WIN_LONG_PATH2
 517.468 -    needLength++;
 517.469 -    buffer = resultPath.GetBuffer(needLength + 1);
 517.470 -    DWORD needLength2 = ::GetFullPathNameW(fileName, needLength, buffer, &fileNamePointer);
 517.471 -    resultPath.ReleaseBuffer();
 517.472 -    if (needLength2 == 0 || needLength2 > needLength)
 517.473 -    #endif
 517.474 -      return false;
 517.475 -  }
 517.476 -  if (fileNamePointer == 0)
 517.477 -    fileNamePartStartIndex = lstrlen(fileName);
 517.478 -  else
 517.479 -    fileNamePartStartIndex = (int)(fileNamePointer - buffer);
 517.480 -  return true;
 517.481 -}
 517.482 -
 517.483 -#ifndef _UNICODE
 517.484 -bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex)
 517.485 -{
 517.486 -  resultPath.Empty();
 517.487 -  if (g_IsNT)
 517.488 -  {
 517.489 -    LPWSTR fileNamePointer = 0;
 517.490 -    LPWSTR buffer = resultPath.GetBuffer(MAX_PATH);
 517.491 -    DWORD needLength = ::GetFullPathNameW(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
 517.492 -    resultPath.ReleaseBuffer();
 517.493 -    if (needLength == 0)
 517.494 -      return false;
 517.495 -    if (needLength >= MAX_PATH)
 517.496 -    {
 517.497 -      #ifdef WIN_LONG_PATH
 517.498 -      needLength++;
 517.499 -      buffer = resultPath.GetBuffer(needLength + 1);
 517.500 -      DWORD needLength2 = ::GetFullPathNameW(fileName, needLength, buffer, &fileNamePointer);
 517.501 -      resultPath.ReleaseBuffer();
 517.502 -      if (needLength2 == 0 || needLength2 > needLength)
 517.503 -      #endif
 517.504 -        return false;
 517.505 -    }
 517.506 -    if (fileNamePointer == 0)
 517.507 -      fileNamePartStartIndex = MyStringLen(fileName);
 517.508 -    else
 517.509 -      fileNamePartStartIndex = (int)(fileNamePointer - buffer);
 517.510 -  }
 517.511 -  else
 517.512 -  {
 517.513 -    CSysString sysPath;
 517.514 -    if (!MyGetFullPathName(GetSysPath(fileName), sysPath, fileNamePartStartIndex))
 517.515 -      return false;
 517.516 -    UString resultPath1 = GetUnicodePath(sysPath.Left(fileNamePartStartIndex));
 517.517 -    UString resultPath2 = GetUnicodePath(sysPath.Mid(fileNamePartStartIndex));
 517.518 -    fileNamePartStartIndex = resultPath1.Length();
 517.519 -    resultPath = resultPath1 + resultPath2;
 517.520 -  }
 517.521 -  return true;
 517.522 -}
 517.523 -#endif
 517.524 -
 517.525 -
 517.526 -bool MyGetFullPathName(LPCTSTR fileName, CSysString &path)
 517.527 -{
 517.528 -  int index;
 517.529 -  return MyGetFullPathName(fileName, path, index);
 517.530 -}
 517.531 -
 517.532 -#ifndef _UNICODE
 517.533 -bool MyGetFullPathName(LPCWSTR fileName, UString &path)
 517.534 -{
 517.535 -  int index;
 517.536 -  return MyGetFullPathName(fileName, path, index);
 517.537 -}
 517.538 -#endif
 517.539 -
 517.540 -bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
 517.541 -{
 517.542 -  int index;
 517.543 -  if (!MyGetFullPathName(fileName, resultName, index))
 517.544 -    return false;
 517.545 -  resultName = resultName.Mid(index);
 517.546 -  return true;
 517.547 -}
 517.548 -
 517.549 -#ifndef _UNICODE
 517.550 -bool GetOnlyName(LPCWSTR fileName, UString &resultName)
 517.551 -{
 517.552 -  int index;
 517.553 -  if (!MyGetFullPathName(fileName, resultName, index))
 517.554 -    return false;
 517.555 -  resultName = resultName.Mid(index);
 517.556 -  return true;
 517.557 -}
 517.558 -#endif
 517.559 -
 517.560 -bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
 517.561 -{
 517.562 -  int index;
 517.563 -  if (!MyGetFullPathName(fileName, resultName, index))
 517.564 -    return false;
 517.565 -  resultName = resultName.Left(index);
 517.566 -  return true;
 517.567 -}
 517.568 -
 517.569 -#ifndef _UNICODE
 517.570 -bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName)
 517.571 -{
 517.572 -  int index;
 517.573 -  if (!MyGetFullPathName(fileName, resultName, index))
 517.574 -    return false;
 517.575 -  resultName = resultName.Left(index);
 517.576 -  return true;
 517.577 -}
 517.578 -#endif
 517.579 -
 517.580 -bool MyGetCurrentDirectory(CSysString &path)
 517.581 -{
 517.582 -  DWORD needLength = ::GetCurrentDirectory(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
 517.583 -  path.ReleaseBuffer();
 517.584 -  return (needLength > 0 && needLength <= MAX_PATH);
 517.585 -}
 517.586 -
 517.587 -#ifndef _UNICODE
 517.588 -bool MySetCurrentDirectory(LPCWSTR path)
 517.589 -{
 517.590 -  if (g_IsNT)
 517.591 -    return BOOLToBool(::SetCurrentDirectoryW(path));
 517.592 -  return MySetCurrentDirectory(GetSysPath(path));
 517.593 -}
 517.594 -bool MyGetCurrentDirectory(UString &path)
 517.595 -{
 517.596 -  if (g_IsNT)
 517.597 -  {
 517.598 -    DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
 517.599 -    path.ReleaseBuffer();
 517.600 -    return (needLength > 0 && needLength <= MAX_PATH);
 517.601 -  }
 517.602 -  CSysString sysPath;
 517.603 -  if (!MyGetCurrentDirectory(sysPath))
 517.604 -    return false;
 517.605 -  path = GetUnicodePath(sysPath);
 517.606 -  return true;
 517.607 -}
 517.608 -#endif
 517.609 -#endif
 517.610 -
 517.611 -bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
 517.612 -  CSysString &resultPath, UINT32 &filePart)
 517.613 -{
 517.614 -  LPTSTR filePartPointer;
 517.615 -  DWORD value = ::SearchPath(path, fileName, extension,
 517.616 -    MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
 517.617 -  filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath);
 517.618 -  resultPath.ReleaseBuffer();
 517.619 -  return (value > 0 && value <= MAX_PATH);
 517.620 -}
 517.621 -
 517.622 -#ifndef _UNICODE
 517.623 -bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
 517.624 -  UString &resultPath, UINT32 &filePart)
 517.625 -{
 517.626 -  if (g_IsNT)
 517.627 -  {
 517.628 -    LPWSTR filePartPointer = 0;
 517.629 -    DWORD value = ::SearchPathW(path, fileName, extension,
 517.630 -        MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
 517.631 -    filePart = (UINT32)(filePartPointer - (LPCWSTR)resultPath);
 517.632 -    resultPath.ReleaseBuffer();
 517.633 -    return (value > 0 && value <= MAX_PATH);
 517.634 -  }
 517.635 -  
 517.636 -  CSysString sysPath;
 517.637 -  if (!MySearchPath(
 517.638 -      path != 0 ? (LPCTSTR)GetSysPath(path): 0,
 517.639 -      fileName != 0 ? (LPCTSTR)GetSysPath(fileName): 0,
 517.640 -      extension != 0 ? (LPCTSTR)GetSysPath(extension): 0,
 517.641 -      sysPath, filePart))
 517.642 -    return false;
 517.643 -  UString resultPath1 = GetUnicodePath(sysPath.Left(filePart));
 517.644 -  UString resultPath2 = GetUnicodePath(sysPath.Mid(filePart));
 517.645 -  filePart = resultPath1.Length();
 517.646 -  resultPath = resultPath1 + resultPath2;
 517.647 -  return true;
 517.648 -}
 517.649 -#endif
 517.650 -
 517.651 -bool MyGetTempPath(CSysString &path)
 517.652 -{
 517.653 -  DWORD needLength = ::GetTempPath(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
 517.654 -  path.ReleaseBuffer();
 517.655 -  return (needLength > 0 && needLength <= MAX_PATH);
 517.656 -}
 517.657 -
 517.658 -#ifndef _UNICODE
 517.659 -bool MyGetTempPath(UString &path)
 517.660 -{
 517.661 -  path.Empty();
 517.662 -  if (g_IsNT)
 517.663 -  {
 517.664 -    DWORD needLength = ::GetTempPathW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
 517.665 -    path.ReleaseBuffer();
 517.666 -    return (needLength > 0 && needLength <= MAX_PATH);
 517.667 -  }
 517.668 -  CSysString sysPath;
 517.669 -  if (!MyGetTempPath(sysPath))
 517.670 -    return false;
 517.671 -  path = GetUnicodePath(sysPath);
 517.672 -  return true;
 517.673 -}
 517.674 -#endif
 517.675 -
 517.676 -UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &path)
 517.677 -{
 517.678 -  UINT number = ::GetTempFileName(dirPath, prefix, 0, path.GetBuffer(MAX_PATH + 1));
 517.679 -  path.ReleaseBuffer();
 517.680 -  return number;
 517.681 -}
 517.682 -
 517.683 -#ifndef _UNICODE
 517.684 -UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &path)
 517.685 -{
 517.686 -  if (g_IsNT)
 517.687 -  {
 517.688 -    UINT number = ::GetTempFileNameW(dirPath, prefix, 0, path.GetBuffer(MAX_PATH));
 517.689 -    path.ReleaseBuffer();
 517.690 -    return number;
 517.691 -  }
 517.692 -  CSysString sysPath;
 517.693 -  UINT number = MyGetTempFileName(
 517.694 -      dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
 517.695 -      prefix ? (LPCTSTR)GetSysPath(prefix): 0,
 517.696 -      sysPath);
 517.697 -  path = GetUnicodePath(sysPath);
 517.698 -  return number;
 517.699 -}
 517.700 -#endif
 517.701 -
 517.702 -UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath)
 517.703 -{
 517.704 -  Remove();
 517.705 -  UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
 517.706 -  if (number != 0)
 517.707 -  {
 517.708 -    _fileName = resultPath;
 517.709 -    _mustBeDeleted = true;
 517.710 -  }
 517.711 -  return number;
 517.712 -}
 517.713 -
 517.714 -bool CTempFile::Create(LPCTSTR prefix, CSysString &resultPath)
 517.715 -{
 517.716 -  CSysString tempPath;
 517.717 -  if (!MyGetTempPath(tempPath))
 517.718 -    return false;
 517.719 -  if (Create(tempPath, prefix, resultPath) != 0)
 517.720 -    return true;
 517.721 -  if (!MyGetWindowsDirectory(tempPath))
 517.722 -    return false;
 517.723 -  return (Create(tempPath, prefix, resultPath) != 0);
 517.724 -}
 517.725 -
 517.726 -bool CTempFile::Remove()
 517.727 -{
 517.728 -  if (!_mustBeDeleted)
 517.729 -    return true;
 517.730 -  _mustBeDeleted = !DeleteFileAlways(_fileName);
 517.731 -  return !_mustBeDeleted;
 517.732 -}
 517.733 -
 517.734 -#ifndef _UNICODE
 517.735 -
 517.736 -UINT CTempFileW::Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath)
 517.737 -{
 517.738 -  Remove();
 517.739 -  UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
 517.740 -  if (number != 0)
 517.741 -  {
 517.742 -    _fileName = resultPath;
 517.743 -    _mustBeDeleted = true;
 517.744 -  }
 517.745 -  return number;
 517.746 -}
 517.747 -
 517.748 -bool CTempFileW::Create(LPCWSTR prefix, UString &resultPath)
 517.749 -{
 517.750 -  UString tempPath;
 517.751 -  if (!MyGetTempPath(tempPath))
 517.752 -    return false;
 517.753 -  if (Create(tempPath, prefix, resultPath) != 0)
 517.754 -    return true;
 517.755 -  if (!MyGetWindowsDirectory(tempPath))
 517.756 -    return false;
 517.757 -  return (Create(tempPath, prefix, resultPath) != 0);
 517.758 -}
 517.759 -
 517.760 -bool CTempFileW::Remove()
 517.761 -{
 517.762 -  if (!_mustBeDeleted)
 517.763 -    return true;
 517.764 -  _mustBeDeleted = !DeleteFileAlways(_fileName);
 517.765 -  return !_mustBeDeleted;
 517.766 -}
 517.767 -
 517.768 -#endif
 517.769 -
 517.770 -bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName)
 517.771 -{
 517.772 -  /*
 517.773 -  CSysString prefix = tempPath + prefixChars;
 517.774 -  CRandom random;
 517.775 -  random.Init();
 517.776 -  */
 517.777 -  for (;;)
 517.778 -  {
 517.779 -    CTempFile tempFile;
 517.780 -    if (!tempFile.Create(prefix, dirName))
 517.781 -      return false;
 517.782 -    if (!::DeleteFile(dirName))
 517.783 -      return false;
 517.784 -    /*
 517.785 -    UINT32 randomNumber = random.Generate();
 517.786 -    TCHAR randomNumberString[32];
 517.787 -    _stprintf(randomNumberString, _T("%04X"), randomNumber);
 517.788 -    dirName = prefix + randomNumberString;
 517.789 -    */
 517.790 -    if (NFind::DoesFileExist(dirName))
 517.791 -      continue;
 517.792 -    if (MyCreateDirectory(dirName))
 517.793 -      return true;
 517.794 -    if (::GetLastError() != ERROR_ALREADY_EXISTS)
 517.795 -      return false;
 517.796 -  }
 517.797 -}
 517.798 -
 517.799 -bool CTempDirectory::Create(LPCTSTR prefix)
 517.800 -{
 517.801 -  Remove();
 517.802 -  return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
 517.803 -}
 517.804 -
 517.805 -#ifndef _UNICODE
 517.806 -
 517.807 -bool CreateTempDirectory(LPCWSTR prefix, UString &dirName)
 517.808 -{
 517.809 -  /*
 517.810 -  CSysString prefix = tempPath + prefixChars;
 517.811 -  CRandom random;
 517.812 -  random.Init();
 517.813 -  */
 517.814 -  for (;;)
 517.815 -  {
 517.816 -    CTempFileW tempFile;
 517.817 -    if (!tempFile.Create(prefix, dirName))
 517.818 -      return false;
 517.819 -    if (!DeleteFileAlways(dirName))
 517.820 -      return false;
 517.821 -    /*
 517.822 -    UINT32 randomNumber = random.Generate();
 517.823 -    TCHAR randomNumberString[32];
 517.824 -    _stprintf(randomNumberString, _T("%04X"), randomNumber);
 517.825 -    dirName = prefix + randomNumberString;
 517.826 -    */
 517.827 -    if (NFind::DoesFileExist(dirName))
 517.828 -      continue;
 517.829 -    if (MyCreateDirectory(dirName))
 517.830 -      return true;
 517.831 -    if (::GetLastError() != ERROR_ALREADY_EXISTS)
 517.832 -      return false;
 517.833 -  }
 517.834 -}
 517.835 -
 517.836 -bool CTempDirectoryW::Create(LPCWSTR prefix)
 517.837 -{
 517.838 -  Remove();
 517.839 -  return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
 517.840 -}
 517.841 -
 517.842 -#endif
 517.843 -
 517.844 -}}}
   518.1 --- a/src/win32/7zip/7z/CPP/Windows/FileDir.h	Sat Mar 03 10:54:39 2012 -0600
   518.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   518.3 @@ -1,178 +0,0 @@
   518.4 -// Windows/FileDir.h
   518.5 -
   518.6 -#ifndef __WINDOWS_FILEDIR_H
   518.7 -#define __WINDOWS_FILEDIR_H
   518.8 -
   518.9 -#include "../Common/MyString.h"
  518.10 -#include "Defs.h"
  518.11 -
  518.12 -namespace NWindows {
  518.13 -namespace NFile {
  518.14 -namespace NDirectory {
  518.15 -
  518.16 -#ifdef WIN_LONG_PATH
  518.17 -bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2);
  518.18 -#endif
  518.19 -
  518.20 -bool MyGetWindowsDirectory(CSysString &path);
  518.21 -bool MyGetSystemDirectory(CSysString &path);
  518.22 -#ifndef _UNICODE
  518.23 -bool MyGetWindowsDirectory(UString &path);
  518.24 -bool MyGetSystemDirectory(UString &path);
  518.25 -#endif
  518.26 -
  518.27 -bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
  518.28 -
  518.29 -bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes);
  518.30 -bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName);
  518.31 -bool MyRemoveDirectory(LPCTSTR pathName);
  518.32 -bool MyCreateDirectory(LPCTSTR pathName);
  518.33 -bool CreateComplexDirectory(LPCTSTR pathName);
  518.34 -bool DeleteFileAlways(LPCTSTR name);
  518.35 -bool RemoveDirectoryWithSubItems(const CSysString &path);
  518.36 -
  518.37 -#ifndef _UNICODE
  518.38 -bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
  518.39 -bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
  518.40 -bool MyRemoveDirectory(LPCWSTR pathName);
  518.41 -bool MyCreateDirectory(LPCWSTR pathName);
  518.42 -bool CreateComplexDirectory(LPCWSTR pathName);
  518.43 -bool DeleteFileAlways(LPCWSTR name);
  518.44 -bool RemoveDirectoryWithSubItems(const UString &path);
  518.45 -#endif
  518.46 -
  518.47 -#ifndef _WIN32_WCE
  518.48 -bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
  518.49 -
  518.50 -bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
  518.51 -    int &fileNamePartStartIndex);
  518.52 -bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
  518.53 -bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
  518.54 -bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
  518.55 -#ifndef _UNICODE
  518.56 -bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
  518.57 -    int &fileNamePartStartIndex);
  518.58 -bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
  518.59 -bool GetOnlyName(LPCWSTR fileName, UString &resultName);
  518.60 -bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
  518.61 -#endif
  518.62 -
  518.63 -inline bool MySetCurrentDirectory(LPCTSTR path)
  518.64 -  { return BOOLToBool(::SetCurrentDirectory(path)); }
  518.65 -bool MyGetCurrentDirectory(CSysString &resultPath);
  518.66 -#ifndef _UNICODE
  518.67 -bool MySetCurrentDirectory(LPCWSTR path);
  518.68 -bool MyGetCurrentDirectory(UString &resultPath);
  518.69 -#endif
  518.70 -#endif
  518.71 -
  518.72 -bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
  518.73 -  CSysString &resultPath, UINT32 &filePart);
  518.74 -#ifndef _UNICODE
  518.75 -bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
  518.76 -  UString &resultPath, UINT32 &filePart);
  518.77 -#endif
  518.78 -
  518.79 -inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
  518.80 -  CSysString &resultPath)
  518.81 -{
  518.82 -  UINT32 value;
  518.83 -  return MySearchPath(path, fileName, extension, resultPath, value);
  518.84 -}
  518.85 -
  518.86 -#ifndef _UNICODE
  518.87 -inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
  518.88 -  UString &resultPath)
  518.89 -{
  518.90 -  UINT32 value;
  518.91 -  return MySearchPath(path, fileName, extension, resultPath, value);
  518.92 -}
  518.93 -#endif
  518.94 -
  518.95 -bool MyGetTempPath(CSysString &resultPath);
  518.96 -#ifndef _UNICODE
  518.97 -bool MyGetTempPath(UString &resultPath);
  518.98 -#endif
  518.99 -
 518.100 -UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
 518.101 -#ifndef _UNICODE
 518.102 -UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
 518.103 -#endif
 518.104 -
 518.105 -class CTempFile
 518.106 -{
 518.107 -  bool _mustBeDeleted;
 518.108 -  CSysString _fileName;
 518.109 -public:
 518.110 -  CTempFile(): _mustBeDeleted(false) {}
 518.111 -  ~CTempFile() { Remove(); }
 518.112 -  void DisableDeleting() { _mustBeDeleted = false; }
 518.113 -  UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
 518.114 -  bool Create(LPCTSTR prefix, CSysString &resultPath);
 518.115 -  bool Remove();
 518.116 -};
 518.117 -
 518.118 -#ifdef _UNICODE
 518.119 -typedef CTempFile CTempFileW;
 518.120 -#else
 518.121 -class CTempFileW
 518.122 -{
 518.123 -  bool _mustBeDeleted;
 518.124 -  UString _fileName;
 518.125 -public:
 518.126 -  CTempFileW(): _mustBeDeleted(false) {}
 518.127 -  ~CTempFileW() { Remove(); }
 518.128 -  void DisableDeleting() { _mustBeDeleted = false; }
 518.129 -  UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
 518.130 -  bool Create(LPCWSTR prefix, UString &resultPath);
 518.131 -  bool Remove();
 518.132 -};
 518.133 -#endif
 518.134 -
 518.135 -bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
 518.136 -
 518.137 -class CTempDirectory
 518.138 -{
 518.139 -  bool _mustBeDeleted;
 518.140 -  CSysString _tempDir;
 518.141 -public:
 518.142 -  const CSysString &GetPath() const { return _tempDir; }
 518.143 -  CTempDirectory(): _mustBeDeleted(false) {}
 518.144 -  ~CTempDirectory() { Remove();  }
 518.145 -  bool Create(LPCTSTR prefix) ;
 518.146 -  bool Remove()
 518.147 -  {
 518.148 -    if (!_mustBeDeleted)
 518.149 -      return true;
 518.150 -    _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
 518.151 -    return (!_mustBeDeleted);
 518.152 -  }
 518.153 -  void DisableDeleting() { _mustBeDeleted = false; }
 518.154 -};
 518.155 -
 518.156 -#ifdef _UNICODE
 518.157 -typedef CTempDirectory CTempDirectoryW;
 518.158 -#else
 518.159 -class CTempDirectoryW
 518.160 -{
 518.161 -  bool _mustBeDeleted;
 518.162 -  UString _tempDir;
 518.163 -public:
 518.164 -  const UString &GetPath() const { return _tempDir; }
 518.165 -  CTempDirectoryW(): _mustBeDeleted(false) {}
 518.166 -  ~CTempDirectoryW() { Remove();  }
 518.167 -  bool Create(LPCWSTR prefix) ;
 518.168 -  bool Remove()
 518.169 -  {
 518.170 -    if (!_mustBeDeleted)
 518.171 -      return true;
 518.172 -    _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
 518.173 -    return (!_mustBeDeleted);
 518.174 -  }
 518.175 -  void DisableDeleting() { _mustBeDeleted = false; }
 518.176 -};
 518.177 -#endif
 518.178 -
 518.179 -}}}
 518.180 -
 518.181 -#endif
   519.1 --- a/src/win32/7zip/7z/CPP/Windows/FileFind.cpp	Sat Mar 03 10:54:39 2012 -0600
   519.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   519.3 @@ -1,402 +0,0 @@
   519.4 -// Windows/FileFind.cpp
   519.5 -
   519.6 -#include "StdAfx.h"
   519.7 -
   519.8 -#include "FileFind.h"
   519.9 -#ifndef _UNICODE
  519.10 -#include "../Common/StringConvert.h"
  519.11 -#endif
  519.12 -
  519.13 -#ifndef _UNICODE
  519.14 -extern bool g_IsNT;
  519.15 -#endif
  519.16 -
  519.17 -namespace NWindows {
  519.18 -namespace NFile {
  519.19 -
  519.20 -#if defined(WIN_LONG_PATH) && defined(_UNICODE)
  519.21 -#define WIN_LONG_PATH2
  519.22 -#endif
  519.23 -
  519.24 -bool GetLongPath(LPCWSTR fileName, UString &res);
  519.25 -
  519.26 -namespace NFind {
  519.27 -
  519.28 -static const TCHAR kDot = TEXT('.');
  519.29 -
  519.30 -bool CFileInfo::IsDots() const
  519.31 -{
  519.32 -  if (!IsDir() || Name.IsEmpty())
  519.33 -    return false;
  519.34 -  if (Name[0] != kDot)
  519.35 -    return false;
  519.36 -  return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
  519.37 -}
  519.38 -
  519.39 -#ifndef _UNICODE
  519.40 -bool CFileInfoW::IsDots() const
  519.41 -{
  519.42 -  if (!IsDir() || Name.IsEmpty())
  519.43 -    return false;
  519.44 -  if (Name[0] != kDot)
  519.45 -    return false;
  519.46 -  return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
  519.47 -}
  519.48 -#endif
  519.49 -
  519.50 -static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi)
  519.51 -{
  519.52 -  fi.Attrib = fd.dwFileAttributes;
  519.53 -  fi.CTime = fd.ftCreationTime;
  519.54 -  fi.ATime = fd.ftLastAccessTime;
  519.55 -  fi.MTime = fd.ftLastWriteTime;
  519.56 -  fi.Size  = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
  519.57 -  fi.Name = fd.cFileName;
  519.58 -  #ifndef _WIN32_WCE
  519.59 -  fi.ReparseTag = fd.dwReserved0;
  519.60 -  #else
  519.61 -  fi.ObjectID = fd.dwOID;
  519.62 -  #endif
  519.63 -}
  519.64 -
  519.65 -#ifndef _UNICODE
  519.66 -
  519.67 -static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
  519.68 -
  519.69 -static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfoW &fi)
  519.70 -{
  519.71 -  fi.Attrib = fd.dwFileAttributes;
  519.72 -  fi.CTime = fd.ftCreationTime;
  519.73 -  fi.ATime = fd.ftLastAccessTime;
  519.74 -  fi.MTime = fd.ftLastWriteTime;
  519.75 -  fi.Size  = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
  519.76 -  fi.Name = fd.cFileName;
  519.77 -  #ifndef _WIN32_WCE
  519.78 -  fi.ReparseTag = fd.dwReserved0;
  519.79 -  #else
  519.80 -  fi.ObjectID = fd.dwOID;
  519.81 -  #endif
  519.82 -}
  519.83 -
  519.84 -static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATA &fd, CFileInfoW &fi)
  519.85 -{
  519.86 -  fi.Attrib = fd.dwFileAttributes;
  519.87 -  fi.CTime = fd.ftCreationTime;
  519.88 -  fi.ATime = fd.ftLastAccessTime;
  519.89 -  fi.MTime = fd.ftLastWriteTime;
  519.90 -  fi.Size  = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
  519.91 -  fi.Name = GetUnicodeString(fd.cFileName, GetCurrentCodePage());
  519.92 -  #ifndef _WIN32_WCE
  519.93 -  fi.ReparseTag = fd.dwReserved0;
  519.94 -  #else
  519.95 -  fi.ObjectID = fd.dwOID;
  519.96 -  #endif
  519.97 -}
  519.98 -#endif
  519.99 -  
 519.100 -////////////////////////////////
 519.101 -// CFindFile
 519.102 -
 519.103 -bool CFindFile::Close()
 519.104 -{
 519.105 -  if (_handle == INVALID_HANDLE_VALUE)
 519.106 -    return true;
 519.107 -  if (!::FindClose(_handle))
 519.108 -    return false;
 519.109 -  _handle = INVALID_HANDLE_VALUE;
 519.110 -  return true;
 519.111 -}
 519.112 -
 519.113 -          
 519.114 -bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
 519.115 -{
 519.116 -  if (!Close())
 519.117 -    return false;
 519.118 -  WIN32_FIND_DATA fd;
 519.119 -  _handle = ::FindFirstFile(wildcard, &fd);
 519.120 -  #ifdef WIN_LONG_PATH2
 519.121 -  if (_handle == INVALID_HANDLE_VALUE)
 519.122 -  {
 519.123 -    UString longPath;
 519.124 -    if (GetLongPath(wildcard, longPath))
 519.125 -      _handle = ::FindFirstFileW(longPath, &fd);
 519.126 -  }
 519.127 -  #endif
 519.128 -  if (_handle == INVALID_HANDLE_VALUE)
 519.129 -    return false;
 519.130 -  ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.131 -  return true;
 519.132 -}
 519.133 -
 519.134 -#ifndef _UNICODE
 519.135 -bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
 519.136 -{
 519.137 -  if (!Close())
 519.138 -    return false;
 519.139 -  if (g_IsNT)
 519.140 -  {
 519.141 -    WIN32_FIND_DATAW fd;
 519.142 -    _handle = ::FindFirstFileW(wildcard, &fd);
 519.143 -    #ifdef WIN_LONG_PATH
 519.144 -    if (_handle == INVALID_HANDLE_VALUE)
 519.145 -    {
 519.146 -      UString longPath;
 519.147 -      if (GetLongPath(wildcard, longPath))
 519.148 -        _handle = ::FindFirstFileW(longPath, &fd);
 519.149 -    }
 519.150 -    #endif
 519.151 -    if (_handle != INVALID_HANDLE_VALUE)
 519.152 -      ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.153 -  }
 519.154 -  else
 519.155 -  {
 519.156 -    WIN32_FIND_DATAA fd;
 519.157 -    _handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
 519.158 -        GetCurrentCodePage()), &fd);
 519.159 -    if (_handle != INVALID_HANDLE_VALUE)
 519.160 -      ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.161 -  }
 519.162 -  return (_handle != INVALID_HANDLE_VALUE);
 519.163 -}
 519.164 -#endif
 519.165 -
 519.166 -bool CFindFile::FindNext(CFileInfo &fileInfo)
 519.167 -{
 519.168 -  WIN32_FIND_DATA fd;
 519.169 -  bool result = BOOLToBool(::FindNextFile(_handle, &fd));
 519.170 -  if (result)
 519.171 -    ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.172 -  return result;
 519.173 -}
 519.174 -
 519.175 -#ifndef _UNICODE
 519.176 -bool CFindFile::FindNext(CFileInfoW &fileInfo)
 519.177 -{
 519.178 -  if (g_IsNT)
 519.179 -  {
 519.180 -    WIN32_FIND_DATAW fd;
 519.181 -    if (!::FindNextFileW(_handle, &fd))
 519.182 -      return false;
 519.183 -    ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.184 -  }
 519.185 -  else
 519.186 -  {
 519.187 -    WIN32_FIND_DATAA fd;
 519.188 -    if (!::FindNextFileA(_handle, &fd))
 519.189 -      return false;
 519.190 -    ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
 519.191 -  }
 519.192 -  return true;
 519.193 -}
 519.194 -#endif
 519.195 -
 519.196 -bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo)
 519.197 -{
 519.198 -  CFindFile finder;
 519.199 -  return finder.FindFirst(wildcard, fileInfo);
 519.200 -}
 519.201 -
 519.202 -#ifndef _UNICODE
 519.203 -bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo)
 519.204 -{
 519.205 -  CFindFile finder;
 519.206 -  return finder.FindFirst(wildcard, fileInfo);
 519.207 -}
 519.208 -#endif
 519.209 -
 519.210 -bool DoesFileExist(LPCTSTR name)
 519.211 -{
 519.212 -  CFileInfo fileInfo;
 519.213 -  return FindFile(name, fileInfo);
 519.214 -}
 519.215 -
 519.216 -#ifndef _UNICODE
 519.217 -bool DoesFileExist(LPCWSTR name)
 519.218 -{
 519.219 -  CFileInfoW fileInfo;
 519.220 -  return FindFile(name, fileInfo);
 519.221 -}
 519.222 -#endif
 519.223 -
 519.224 -/////////////////////////////////////
 519.225 -// CEnumerator
 519.226 -
 519.227 -bool CEnumerator::NextAny(CFileInfo &fileInfo)
 519.228 -{
 519.229 -  if (_findFile.IsHandleAllocated())
 519.230 -    return _findFile.FindNext(fileInfo);
 519.231 -  else
 519.232 -    return _findFile.FindFirst(_wildcard, fileInfo);
 519.233 -}
 519.234 -
 519.235 -bool CEnumerator::Next(CFileInfo &fileInfo)
 519.236 -{
 519.237 -  for (;;)
 519.238 -  {
 519.239 -    if (!NextAny(fileInfo))
 519.240 -      return false;
 519.241 -    if (!fileInfo.IsDots())
 519.242 -      return true;
 519.243 -  }
 519.244 -}
 519.245 -
 519.246 -bool CEnumerator::Next(CFileInfo &fileInfo, bool &found)
 519.247 -{
 519.248 -  if (Next(fileInfo))
 519.249 -  {
 519.250 -    found = true;
 519.251 -    return true;
 519.252 -  }
 519.253 -  found = false;
 519.254 -  return (::GetLastError() == ERROR_NO_MORE_FILES);
 519.255 -}
 519.256 -
 519.257 -#ifndef _UNICODE
 519.258 -bool CEnumeratorW::NextAny(CFileInfoW &fileInfo)
 519.259 -{
 519.260 -  if (_findFile.IsHandleAllocated())
 519.261 -    return _findFile.FindNext(fileInfo);
 519.262 -  else
 519.263 -    return _findFile.FindFirst(_wildcard, fileInfo);
 519.264 -}
 519.265 -
 519.266 -bool CEnumeratorW::Next(CFileInfoW &fileInfo)
 519.267 -{
 519.268 -  for (;;)
 519.269 -  {
 519.270 -    if (!NextAny(fileInfo))
 519.271 -      return false;
 519.272 -    if (!fileInfo.IsDots())
 519.273 -      return true;
 519.274 -  }
 519.275 -}
 519.276 -
 519.277 -bool CEnumeratorW::Next(CFileInfoW &fileInfo, bool &found)
 519.278 -{
 519.279 -  if (Next(fileInfo))
 519.280 -  {
 519.281 -    found = true;
 519.282 -    return true;
 519.283 -  }
 519.284 -  found = false;
 519.285 -  return (::GetLastError() == ERROR_NO_MORE_FILES);
 519.286 -}
 519.287 -
 519.288 -#endif
 519.289 -
 519.290 -////////////////////////////////
 519.291 -// CFindChangeNotification
 519.292 -// FindFirstChangeNotification can return 0. MSDN doesn't tell about it.
 519.293 -
 519.294 -bool CFindChangeNotification::Close()
 519.295 -{
 519.296 -  if (!IsHandleAllocated())
 519.297 -    return true;
 519.298 -  if (!::FindCloseChangeNotification(_handle))
 519.299 -    return false;
 519.300 -  _handle = INVALID_HANDLE_VALUE;
 519.301 -  return true;
 519.302 -}
 519.303 -           
 519.304 -HANDLE CFindChangeNotification::FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter)
 519.305 -{
 519.306 -  _handle = ::FindFirstChangeNotification(pathName, BoolToBOOL(watchSubtree), notifyFilter);
 519.307 -  #ifdef WIN_LONG_PATH2
 519.308 -  if (!IsHandleAllocated())
 519.309 -  {
 519.310 -    UString longPath;
 519.311 -    if (GetLongPath(pathName, longPath))
 519.312 -      _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter);
 519.313 -  }
 519.314 -  #endif
 519.315 -  return _handle;
 519.316 -}
 519.317 -
 519.318 -#ifndef _UNICODE
 519.319 -HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter)
 519.320 -{
 519.321 -  if (!g_IsNT)
 519.322 -    return FindFirst(UnicodeStringToMultiByte(pathName, GetCurrentCodePage()), watchSubtree, notifyFilter);
 519.323 -  _handle = ::FindFirstChangeNotificationW(pathName, BoolToBOOL(watchSubtree), notifyFilter);
 519.324 -  #ifdef WIN_LONG_PATH
 519.325 -  if (!IsHandleAllocated())
 519.326 -  {
 519.327 -    UString longPath;
 519.328 -    if (GetLongPath(pathName, longPath))
 519.329 -      _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter);
 519.330 -  }
 519.331 -  #endif
 519.332 -  return _handle;
 519.333 -}
 519.334 -#endif
 519.335 -
 519.336 -#ifndef _WIN32_WCE
 519.337 -bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
 519.338 -{
 519.339 -  driveStrings.Clear();
 519.340 -  UINT32 size = GetLogicalDriveStrings(0, NULL);
 519.341 -  if (size == 0)
 519.342 -    return false;
 519.343 -  CSysString buffer;
 519.344 -  UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
 519.345 -  if (newSize == 0)
 519.346 -    return false;
 519.347 -  if (newSize > size)
 519.348 -    return false;
 519.349 -  CSysString string;
 519.350 -  for (UINT32 i = 0; i < newSize; i++)
 519.351 -  {
 519.352 -    TCHAR c = buffer[i];
 519.353 -    if (c == TEXT('\0'))
 519.354 -    {
 519.355 -      driveStrings.Add(string);
 519.356 -      string.Empty();
 519.357 -    }
 519.358 -    else
 519.359 -      string += c;
 519.360 -  }
 519.361 -  if (!string.IsEmpty())
 519.362 -    return false;
 519.363 -  return true;
 519.364 -}
 519.365 -
 519.366 -#ifndef _UNICODE
 519.367 -bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
 519.368 -{
 519.369 -  driveStrings.Clear();
 519.370 -  if (g_IsNT)
 519.371 -  {
 519.372 -    UINT32 size = GetLogicalDriveStringsW(0, NULL);
 519.373 -    if (size == 0)
 519.374 -      return false;
 519.375 -    UString buffer;
 519.376 -    UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
 519.377 -    if (newSize == 0)
 519.378 -      return false;
 519.379 -    if (newSize > size)
 519.380 -      return false;
 519.381 -    UString string;
 519.382 -    for (UINT32 i = 0; i < newSize; i++)
 519.383 -    {
 519.384 -      WCHAR c = buffer[i];
 519.385 -      if (c == L'\0')
 519.386 -      {
 519.387 -        driveStrings.Add(string);
 519.388 -        string.Empty();
 519.389 -      }
 519.390 -      else
 519.391 -        string += c;
 519.392 -    }
 519.393 -    return string.IsEmpty();
 519.394 -  }
 519.395 -  CSysStringVector driveStringsA;
 519.396 -  bool res = MyGetLogicalDriveStrings(driveStringsA);
 519.397 -  for (int i = 0; i < driveStringsA.Size(); i++)
 519.398 -    driveStrings.Add(GetUnicodeString(driveStringsA[i]));
 519.399 -  return res;
 519.400 -}
 519.401 -#endif
 519.402 -
 519.403 -#endif
 519.404 -
 519.405 -}}}
   520.1 --- a/src/win32/7zip/7z/CPP/Windows/FileFind.h	Sat Mar 03 10:54:39 2012 -0600
   520.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   520.3 @@ -1,153 +0,0 @@
   520.4 -// Windows/FileFind.h
   520.5 -
   520.6 -#ifndef __WINDOWS_FILEFIND_H
   520.7 -#define __WINDOWS_FILEFIND_H
   520.8 -
   520.9 -#include "../Common/MyString.h"
  520.10 -#include "../Common/Types.h"
  520.11 -#include "FileName.h"
  520.12 -#include "Defs.h"
  520.13 -
  520.14 -namespace NWindows {
  520.15 -namespace NFile {
  520.16 -namespace NFind {
  520.17 -
  520.18 -namespace NAttributes
  520.19 -{
  520.20 -  inline bool IsReadOnly(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_READONLY) != 0; }
  520.21 -  inline bool IsHidden(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; }
  520.22 -  inline bool IsSystem(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; }
  520.23 -  inline bool IsDir(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0; }
  520.24 -  inline bool IsArchived(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ARCHIVE) != 0; }
  520.25 -  inline bool IsCompressed(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_COMPRESSED) != 0; }
  520.26 -  inline bool IsEncrypted(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
  520.27 -}
  520.28 -
  520.29 -class CFileInfoBase
  520.30 -{
  520.31 -  bool MatchesMask(UINT32 mask) const { return ((Attrib & mask) != 0); }
  520.32 -public:
  520.33 -  UInt64 Size;
  520.34 -  FILETIME CTime;
  520.35 -  FILETIME ATime;
  520.36 -  FILETIME MTime;
  520.37 -  DWORD Attrib;
  520.38 -  
  520.39 -  #ifndef _WIN32_WCE
  520.40 -  UINT32 ReparseTag;
  520.41 -  #else
  520.42 -  DWORD ObjectID;
  520.43 -  #endif
  520.44 -
  520.45 -  bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); }
  520.46 -  bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); }
  520.47 -  bool IsDir() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
  520.48 -  bool IsEncrypted() const { return MatchesMask(FILE_ATTRIBUTE_ENCRYPTED); }
  520.49 -  bool IsHidden() const { return MatchesMask(FILE_ATTRIBUTE_HIDDEN); }
  520.50 -  bool IsNormal() const { return MatchesMask(FILE_ATTRIBUTE_NORMAL); }
  520.51 -  bool IsOffline() const { return MatchesMask(FILE_ATTRIBUTE_OFFLINE); }
  520.52 -  bool IsReadOnly() const { return MatchesMask(FILE_ATTRIBUTE_READONLY); }
  520.53 -  bool HasReparsePoint() const { return MatchesMask(FILE_ATTRIBUTE_REPARSE_POINT); }
  520.54 -  bool IsSparse() const { return MatchesMask(FILE_ATTRIBUTE_SPARSE_FILE); }
  520.55 -  bool IsSystem() const { return MatchesMask(FILE_ATTRIBUTE_SYSTEM); }
  520.56 -  bool IsTemporary() const { return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); }
  520.57 -};
  520.58 -
  520.59 -class CFileInfo: public CFileInfoBase
  520.60 -{
  520.61 -public:
  520.62 -  CSysString Name;
  520.63 -  bool IsDots() const;
  520.64 -};
  520.65 -
  520.66 -#ifdef _UNICODE
  520.67 -typedef CFileInfo CFileInfoW;
  520.68 -#else
  520.69 -class CFileInfoW: public CFileInfoBase
  520.70 -{
  520.71 -public:
  520.72 -  UString Name;
  520.73 -  bool IsDots() const;
  520.74 -};
  520.75 -#endif
  520.76 -
  520.77 -class CFindFile
  520.78 -{
  520.79 -  friend class CEnumerator;
  520.80 -  HANDLE _handle;
  520.81 -public:
  520.82 -  bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE; }
  520.83 -  CFindFile(): _handle(INVALID_HANDLE_VALUE) {}
  520.84 -  ~CFindFile() {  Close(); }
  520.85 -  bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo);
  520.86 -  bool FindNext(CFileInfo &fileInfo);
  520.87 -  #ifndef _UNICODE
  520.88 -  bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo);
  520.89 -  bool FindNext(CFileInfoW &fileInfo);
  520.90 -  #endif
  520.91 -  bool Close();
  520.92 -};
  520.93 -
  520.94 -bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo);
  520.95 -
  520.96 -bool DoesFileExist(LPCTSTR name);
  520.97 -#ifndef _UNICODE
  520.98 -bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo);
  520.99 -bool DoesFileExist(LPCWSTR name);
 520.100 -#endif
 520.101 -
 520.102 -class CEnumerator
 520.103 -{
 520.104 -  CFindFile _findFile;
 520.105 -  CSysString _wildcard;
 520.106 -  bool NextAny(CFileInfo &fileInfo);
 520.107 -public:
 520.108 -  CEnumerator(): _wildcard(NName::kAnyStringWildcard) {}
 520.109 -  CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {}
 520.110 -  bool Next(CFileInfo &fileInfo);
 520.111 -  bool Next(CFileInfo &fileInfo, bool &found);
 520.112 -};
 520.113 -
 520.114 -#ifdef _UNICODE
 520.115 -typedef CEnumerator CEnumeratorW;
 520.116 -#else
 520.117 -class CEnumeratorW
 520.118 -{
 520.119 -  CFindFile _findFile;
 520.120 -  UString _wildcard;
 520.121 -  bool NextAny(CFileInfoW &fileInfo);
 520.122 -public:
 520.123 -  CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {}
 520.124 -  CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {}
 520.125 -  bool Next(CFileInfoW &fileInfo);
 520.126 -  bool Next(CFileInfoW &fileInfo, bool &found);
 520.127 -};
 520.128 -#endif
 520.129 -
 520.130 -class CFindChangeNotification
 520.131 -{
 520.132 -  HANDLE _handle;
 520.133 -public:
 520.134 -  operator HANDLE () { return _handle; }
 520.135 -  bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE && _handle != 0; }
 520.136 -  CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {}
 520.137 -  ~CFindChangeNotification() { Close(); }
 520.138 -  bool Close();
 520.139 -  HANDLE FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter);
 520.140 -  #ifndef _UNICODE
 520.141 -  HANDLE FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter);
 520.142 -  #endif
 520.143 -  bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); }
 520.144 -};
 520.145 -
 520.146 -#ifndef _WIN32_WCE
 520.147 -bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings);
 520.148 -#ifndef _UNICODE
 520.149 -bool MyGetLogicalDriveStrings(UStringVector &driveStrings);
 520.150 -#endif
 520.151 -#endif
 520.152 -
 520.153 -}}}
 520.154 -
 520.155 -#endif
 520.156 -
   521.1 --- a/src/win32/7zip/7z/CPP/Windows/FileIO.cpp	Sat Mar 03 10:54:39 2012 -0600
   521.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   521.3 @@ -1,317 +0,0 @@
   521.4 -// Windows/FileIO.cpp
   521.5 -
   521.6 -#include "StdAfx.h"
   521.7 -
   521.8 -#include "FileIO.h"
   521.9 -#include "Defs.h"
  521.10 -#ifdef WIN_LONG_PATH
  521.11 -#include "../Common/MyString.h"
  521.12 -#endif
  521.13 -#ifndef _UNICODE
  521.14 -#include "../Common/StringConvert.h"
  521.15 -#endif
  521.16 -
  521.17 -#ifndef _UNICODE
  521.18 -extern bool g_IsNT;
  521.19 -#endif
  521.20 -
  521.21 -namespace NWindows {
  521.22 -namespace NFile {
  521.23 -
  521.24 -#if defined(WIN_LONG_PATH) && defined(_UNICODE)
  521.25 -#define WIN_LONG_PATH2
  521.26 -#endif
  521.27 -
  521.28 -#ifdef WIN_LONG_PATH
  521.29 -bool GetLongPathBase(LPCWSTR s, UString &res)
  521.30 -{
  521.31 -  res.Empty();
  521.32 -  int len = MyStringLen(s);
  521.33 -  wchar_t c = s[0];
  521.34 -  if (len < 1 || c == L'\\' || c == L'.' && (len == 1 || len == 2 && s[1] == L'.'))
  521.35 -    return true;
  521.36 -  UString curDir;
  521.37 -  bool isAbs = false;
  521.38 -  if (len > 3)
  521.39 -    isAbs = (s[1] == L':' && s[2] == L'\\' && (c >= L'a' && c <= L'z' || c >= L'A' && c <= L'Z'));
  521.40 -
  521.41 -  if (!isAbs)
  521.42 -    {
  521.43 -      DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, curDir.GetBuffer(MAX_PATH + 1));
  521.44 -      curDir.ReleaseBuffer();
  521.45 -      if (needLength == 0 || needLength > MAX_PATH)
  521.46 -        return false;
  521.47 -      if (curDir[curDir.Length() - 1] != L'\\')
  521.48 -        curDir += L'\\';
  521.49 -    }
  521.50 -  res = UString(L"\\\\?\\") + curDir + s;
  521.51 -  return true;
  521.52 -}
  521.53 -
  521.54 -bool GetLongPath(LPCWSTR path, UString &longPath)
  521.55 -{
  521.56 -  if (GetLongPathBase(path, longPath))
  521.57 -    return !longPath.IsEmpty();
  521.58 -  return false;
  521.59 -}
  521.60 -#endif
  521.61 -
  521.62 -namespace NIO {
  521.63 -
  521.64 -CFileBase::~CFileBase() { Close(); }
  521.65 -
  521.66 -bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
  521.67 -    DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
  521.68 -{
  521.69 -  if (!Close())
  521.70 -    return false;
  521.71 -  _handle = ::CreateFile(fileName, desiredAccess, shareMode,
  521.72 -      (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
  521.73 -      flagsAndAttributes, (HANDLE)NULL);
  521.74 -  #ifdef WIN_LONG_PATH2
  521.75 -  if (_handle == INVALID_HANDLE_VALUE)
  521.76 -  {
  521.77 -    UString longPath;
  521.78 -    if (GetLongPath(fileName, longPath))
  521.79 -      _handle = ::CreateFileW(longPath, desiredAccess, shareMode,
  521.80 -        (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
  521.81 -        flagsAndAttributes, (HANDLE)NULL);
  521.82 -  }
  521.83 -  #endif
  521.84 -  return (_handle != INVALID_HANDLE_VALUE);
  521.85 -}
  521.86 -
  521.87 -#ifndef _UNICODE
  521.88 -bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
  521.89 -    DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
  521.90 -{
  521.91 -  if (!g_IsNT)
  521.92 -    return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
  521.93 -      desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
  521.94 -  if (!Close())
  521.95 -    return false;
  521.96 -  _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
  521.97 -    (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
  521.98 -    flagsAndAttributes, (HANDLE)NULL);
  521.99 -  #ifdef WIN_LONG_PATH
 521.100 -  if (_handle == INVALID_HANDLE_VALUE)
 521.101 -  {
 521.102 -    UString longPath;
 521.103 -    if (GetLongPath(fileName, longPath))
 521.104 -      _handle = ::CreateFileW(longPath, desiredAccess, shareMode,
 521.105 -        (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
 521.106 -        flagsAndAttributes, (HANDLE)NULL);
 521.107 -  }
 521.108 -  #endif
 521.109 -  return (_handle != INVALID_HANDLE_VALUE);
 521.110 -}
 521.111 -#endif
 521.112 -
 521.113 -bool CFileBase::Close()
 521.114 -{
 521.115 -  if (_handle == INVALID_HANDLE_VALUE)
 521.116 -    return true;
 521.117 -  if (!::CloseHandle(_handle))
 521.118 -    return false;
 521.119 -  _handle = INVALID_HANDLE_VALUE;
 521.120 -  return true;
 521.121 -}
 521.122 -
 521.123 -bool CFileBase::GetPosition(UInt64 &position) const
 521.124 -{
 521.125 -  return Seek(0, FILE_CURRENT, position);
 521.126 -}
 521.127 -
 521.128 -bool CFileBase::GetLength(UInt64 &length) const
 521.129 -{
 521.130 -  DWORD sizeHigh;
 521.131 -  DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
 521.132 -  if (sizeLow == 0xFFFFFFFF)
 521.133 -    if (::GetLastError() != NO_ERROR)
 521.134 -      return false;
 521.135 -  length = (((UInt64)sizeHigh) << 32) + sizeLow;
 521.136 -  return true;
 521.137 -}
 521.138 -
 521.139 -bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const
 521.140 -{
 521.141 -  LARGE_INTEGER value;
 521.142 -  value.QuadPart = distanceToMove;
 521.143 -  value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
 521.144 -  if (value.LowPart == 0xFFFFFFFF)
 521.145 -    if (::GetLastError() != NO_ERROR)
 521.146 -      return false;
 521.147 -  newPosition = value.QuadPart;
 521.148 -  return true;
 521.149 -}
 521.150 -
 521.151 -bool CFileBase::Seek(UInt64 position, UInt64 &newPosition)
 521.152 -{
 521.153 -  return Seek(position, FILE_BEGIN, newPosition);
 521.154 -}
 521.155 -
 521.156 -bool CFileBase::SeekToBegin()
 521.157 -{
 521.158 -  UInt64 newPosition;
 521.159 -  return Seek(0, newPosition);
 521.160 -}
 521.161 -
 521.162 -bool CFileBase::SeekToEnd(UInt64 &newPosition)
 521.163 -{
 521.164 -  return Seek(0, FILE_END, newPosition);
 521.165 -}
 521.166 -
 521.167 -bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
 521.168 -{
 521.169 -  BY_HANDLE_FILE_INFORMATION winFileInfo;
 521.170 -  if (!::GetFileInformationByHandle(_handle, &winFileInfo))
 521.171 -    return false;
 521.172 -  fileInfo.Attributes = winFileInfo.dwFileAttributes;
 521.173 -  fileInfo.CTime = winFileInfo.ftCreationTime;
 521.174 -  fileInfo.ATime = winFileInfo.ftLastAccessTime;
 521.175 -  fileInfo.MTime = winFileInfo.ftLastWriteTime;
 521.176 -  fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
 521.177 -  fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) +  winFileInfo.nFileSizeLow;
 521.178 -  fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
 521.179 -  fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
 521.180 -  return true;
 521.181 -}
 521.182 -
 521.183 -/////////////////////////
 521.184 -// CInFile
 521.185 -
 521.186 -bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
 521.187 -  { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
 521.188 -
 521.189 -bool CInFile::OpenShared(LPCTSTR fileName, bool shareForWrite)
 521.190 -{ return Open(fileName, FILE_SHARE_READ | (shareForWrite ? FILE_SHARE_WRITE : 0), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
 521.191 -
 521.192 -bool CInFile::Open(LPCTSTR fileName)
 521.193 -  { return OpenShared(fileName, false); }
 521.194 -
 521.195 -#ifndef _UNICODE
 521.196 -bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
 521.197 -  { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
 521.198 -
 521.199 -bool CInFile::OpenShared(LPCWSTR fileName, bool shareForWrite)
 521.200 -{ return Open(fileName, FILE_SHARE_READ | (shareForWrite ? FILE_SHARE_WRITE : 0), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
 521.201 -
 521.202 -bool CInFile::Open(LPCWSTR fileName)
 521.203 -  { return OpenShared(fileName, false); }
 521.204 -#endif
 521.205 -
 521.206 -// ReadFile and WriteFile functions in Windows have BUG:
 521.207 -// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
 521.208 -// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
 521.209 -// (Insufficient system resources exist to complete the requested service).
 521.210 -
 521.211 -// Probably in some version of Windows there are problems with other sizes:
 521.212 -// for 32 MB (maybe also for 16 MB).
 521.213 -// And message can be "Network connection was lost"
 521.214 -
 521.215 -static UInt32 kChunkSizeMax = (1 << 22);
 521.216 -
 521.217 -bool CInFile::ReadPart(void *data, UInt32 size, UInt32 &processedSize)
 521.218 -{
 521.219 -  if (size > kChunkSizeMax)
 521.220 -    size = kChunkSizeMax;
 521.221 -  DWORD processedLoc = 0;
 521.222 -  bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
 521.223 -  processedSize = (UInt32)processedLoc;
 521.224 -  return res;
 521.225 -}
 521.226 -
 521.227 -bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
 521.228 -{
 521.229 -  processedSize = 0;
 521.230 -  do
 521.231 -  {
 521.232 -    UInt32 processedLoc = 0;
 521.233 -    bool res = ReadPart(data, size, processedLoc);
 521.234 -    processedSize += processedLoc;
 521.235 -    if (!res)
 521.236 -      return false;
 521.237 -    if (processedLoc == 0)
 521.238 -      return true;
 521.239 -    data = (void *)((unsigned char *)data + processedLoc);
 521.240 -    size -= processedLoc;
 521.241 -  }
 521.242 -  while (size > 0);
 521.243 -  return true;
 521.244 -}
 521.245 -
 521.246 -/////////////////////////
 521.247 -// COutFile
 521.248 -
 521.249 -bool COutFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
 521.250 -  { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
 521.251 -
 521.252 -static inline DWORD GetCreationDisposition(bool createAlways)
 521.253 -  { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
 521.254 -
 521.255 -bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
 521.256 -  { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
 521.257 -
 521.258 -bool COutFile::Create(LPCTSTR fileName, bool createAlways)
 521.259 -  { return Open(fileName, GetCreationDisposition(createAlways)); }
 521.260 -
 521.261 -#ifndef _UNICODE
 521.262 -
 521.263 -bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
 521.264 -  { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode,      creationDisposition, flagsAndAttributes); }
 521.265 -
 521.266 -bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
 521.267 -  { return Open(fileName, FILE_SHARE_READ,  creationDisposition, FILE_ATTRIBUTE_NORMAL); }
 521.268 -
 521.269 -bool COutFile::Create(LPCWSTR fileName, bool createAlways)
 521.270 -  { return Open(fileName, GetCreationDisposition(createAlways)); }
 521.271 -
 521.272 -#endif
 521.273 -
 521.274 -bool COutFile::SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
 521.275 -  { return BOOLToBool(::SetFileTime(_handle, cTime, aTime, mTime)); }
 521.276 -
 521.277 -bool COutFile::SetMTime(const FILETIME *mTime) {  return SetTime(NULL, NULL, mTime); }
 521.278 -
 521.279 -bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
 521.280 -{
 521.281 -  if (size > kChunkSizeMax)
 521.282 -    size = kChunkSizeMax;
 521.283 -  DWORD processedLoc = 0;
 521.284 -  bool res = BOOLToBool(::WriteFile(_handle, data, size, &processedLoc, NULL));
 521.285 -  processedSize = (UInt32)processedLoc;
 521.286 -  return res;
 521.287 -}
 521.288 -
 521.289 -bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize)
 521.290 -{
 521.291 -  processedSize = 0;
 521.292 -  do
 521.293 -  {
 521.294 -    UInt32 processedLoc = 0;
 521.295 -    bool res = WritePart(data, size, processedLoc);
 521.296 -    processedSize += processedLoc;
 521.297 -    if (!res)
 521.298 -      return false;
 521.299 -    if (processedLoc == 0)
 521.300 -      return true;
 521.301 -    data = (const void *)((const unsigned char *)data + processedLoc);
 521.302 -    size -= processedLoc;
 521.303 -  }
 521.304 -  while (size > 0);
 521.305 -  return true;
 521.306 -}
 521.307 -
 521.308 -bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
 521.309 -
 521.310 -bool COutFile::SetLength(UInt64 length)
 521.311 -{
 521.312 -  UInt64 newPosition;
 521.313 -  if (!Seek(length, newPosition))
 521.314 -    return false;
 521.315 -  if (newPosition != length)
 521.316 -    return false;
 521.317 -  return SetEndOfFile();
 521.318 -}
 521.319 -
 521.320 -}}}
   522.1 --- a/src/win32/7zip/7z/CPP/Windows/FileIO.h	Sat Mar 03 10:54:39 2012 -0600
   522.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   522.3 @@ -1,99 +0,0 @@
   522.4 -// Windows/FileIO.h
   522.5 -
   522.6 -#ifndef __WINDOWS_FILEIO_H
   522.7 -#define __WINDOWS_FILEIO_H
   522.8 -
   522.9 -#include "../Common/Types.h"
  522.10 -
  522.11 -namespace NWindows {
  522.12 -namespace NFile {
  522.13 -namespace NIO {
  522.14 -
  522.15 -struct CByHandleFileInfo
  522.16 -{
  522.17 -  DWORD    Attributes;
  522.18 -  FILETIME CTime;
  522.19 -  FILETIME ATime;
  522.20 -  FILETIME MTime;
  522.21 -  DWORD    VolumeSerialNumber;
  522.22 -  UInt64   Size;
  522.23 -  DWORD    NumberOfLinks;
  522.24 -  UInt64   FileIndex;
  522.25 -};
  522.26 -
  522.27 -class CFileBase
  522.28 -{
  522.29 -protected:
  522.30 -  HANDLE _handle;
  522.31 -  bool Create(LPCTSTR fileName, DWORD desiredAccess,
  522.32 -      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
  522.33 -  #ifndef _UNICODE
  522.34 -  bool Create(LPCWSTR fileName, DWORD desiredAccess,
  522.35 -      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
  522.36 -  #endif
  522.37 -
  522.38 -public:
  522.39 -  CFileBase(): _handle(INVALID_HANDLE_VALUE){};
  522.40 -  ~CFileBase();
  522.41 -
  522.42 -  bool Close();
  522.43 -
  522.44 -  bool GetPosition(UInt64 &position) const;
  522.45 -  bool GetLength(UInt64 &length) const;
  522.46 -
  522.47 -  bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
  522.48 -  bool Seek(UInt64 position, UInt64 &newPosition);
  522.49 -  bool SeekToBegin();
  522.50 -  bool SeekToEnd(UInt64 &newPosition);
  522.51 -  
  522.52 -  bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
  522.53 -};
  522.54 -
  522.55 -class CInFile: public CFileBase
  522.56 -{
  522.57 -public:
  522.58 -  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
  522.59 -  bool OpenShared(LPCTSTR fileName, bool shareForWrite);
  522.60 -  bool Open(LPCTSTR fileName);
  522.61 -  #ifndef _UNICODE
  522.62 -  bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
  522.63 -  bool OpenShared(LPCWSTR fileName, bool shareForWrite);
  522.64 -  bool Open(LPCWSTR fileName);
  522.65 -  #endif
  522.66 -  bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
  522.67 -  bool Read(void *data, UInt32 size, UInt32 &processedSize);
  522.68 -};
  522.69 -
  522.70 -class COutFile: public CFileBase
  522.71 -{
  522.72 -  // DWORD m_CreationDisposition;
  522.73 -public:
  522.74 -  // COutFile(): m_CreationDisposition(CREATE_NEW){};
  522.75 -  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
  522.76 -  bool Open(LPCTSTR fileName, DWORD creationDisposition);
  522.77 -  bool Create(LPCTSTR fileName, bool createAlways);
  522.78 -
  522.79 -  #ifndef _UNICODE
  522.80 -  bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
  522.81 -  bool Open(LPCWSTR fileName, DWORD creationDisposition);
  522.82 -  bool Create(LPCWSTR fileName, bool createAlways);
  522.83 -  #endif
  522.84 -
  522.85 -  /*
  522.86 -  void SetOpenCreationDisposition(DWORD creationDisposition)
  522.87 -    { m_CreationDisposition = creationDisposition; }
  522.88 -  void SetOpenCreationDispositionCreateAlways()
  522.89 -    { m_CreationDisposition = CREATE_ALWAYS; }
  522.90 -  */
  522.91 -
  522.92 -  bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
  522.93 -  bool SetMTime(const FILETIME *mTime);
  522.94 -  bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
  522.95 -  bool Write(const void *data, UInt32 size, UInt32 &processedSize);
  522.96 -  bool SetEndOfFile();
  522.97 -  bool SetLength(UInt64 length);
  522.98 -};
  522.99 -
 522.100 -}}}
 522.101 -
 522.102 -#endif
   523.1 --- a/src/win32/7zip/7z/CPP/Windows/FileName.h	Sat Mar 03 10:54:39 2012 -0600
   523.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   523.3 @@ -1,25 +0,0 @@
   523.4 -// Windows/FileName.h
   523.5 -
   523.6 -#ifndef __WINDOWS_FILENAME_H
   523.7 -#define __WINDOWS_FILENAME_H
   523.8 -
   523.9 -#include "../Common/MyString.h"
  523.10 -
  523.11 -namespace NWindows {
  523.12 -namespace NFile {
  523.13 -namespace NName {
  523.14 -
  523.15 -const TCHAR kDirDelimiter = CHAR_PATH_SEPARATOR;
  523.16 -const TCHAR kAnyStringWildcard = '*';
  523.17 -
  523.18 -void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with '\\'
  523.19 -#ifndef _UNICODE
  523.20 -void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\'
  523.21 -#endif
  523.22 -
  523.23 -void SplitNameToPureNameAndExtension(const UString &fullName,
  523.24 -    UString &pureName, UString &extensionDelimiter, UString &extension);
  523.25 -
  523.26 -}}}
  523.27 -
  523.28 -#endif
   524.1 --- a/src/win32/7zip/7z/CPP/Windows/Handle.h	Sat Mar 03 10:54:39 2012 -0600
   524.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   524.3 @@ -1,37 +0,0 @@
   524.4 -// Windows/Handle.h
   524.5 -
   524.6 -#ifndef __WINDOWS_HANDLE_H
   524.7 -#define __WINDOWS_HANDLE_H
   524.8 -
   524.9 -namespace NWindows {
  524.10 -
  524.11 -class CHandle
  524.12 -{
  524.13 -protected:
  524.14 -  HANDLE _handle;
  524.15 -public:
  524.16 -  operator HANDLE() { return _handle; }
  524.17 -  CHandle(): _handle(NULL) {}
  524.18 -  ~CHandle() { Close(); }
  524.19 -  bool Close()
  524.20 -  {
  524.21 -    if (_handle == NULL)
  524.22 -      return true;
  524.23 -    if (!::CloseHandle(_handle))
  524.24 -      return false;
  524.25 -    _handle = NULL;
  524.26 -    return true;
  524.27 -  }
  524.28 -  void Attach(HANDLE handle)
  524.29 -    { _handle = handle; }
  524.30 -  HANDLE Detach()
  524.31 -  {
  524.32 -    HANDLE handle = _handle;
  524.33 -    _handle = NULL;
  524.34 -    return handle;
  524.35 -  }
  524.36 -};
  524.37 -
  524.38 -}
  524.39 -
  524.40 -#endif
   525.1 --- a/src/win32/7zip/7z/CPP/Windows/PropVariant.cpp	Sat Mar 03 10:54:39 2012 -0600
   525.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   525.3 @@ -1,312 +0,0 @@
   525.4 -// Windows/PropVariant.cpp
   525.5 -
   525.6 -#include "StdAfx.h"
   525.7 -
   525.8 -#include "PropVariant.h"
   525.9 -
  525.10 -#include "../Common/Defs.h"
  525.11 -
  525.12 -namespace NWindows {
  525.13 -namespace NCOM {
  525.14 -
  525.15 -CPropVariant::CPropVariant(const PROPVARIANT& varSrc)
  525.16 -{
  525.17 -  vt = VT_EMPTY;
  525.18 -  InternalCopy(&varSrc);
  525.19 -}
  525.20 -
  525.21 -CPropVariant::CPropVariant(const CPropVariant& varSrc)
  525.22 -{
  525.23 -  vt = VT_EMPTY;
  525.24 -  InternalCopy(&varSrc);
  525.25 -}
  525.26 -
  525.27 -CPropVariant::CPropVariant(BSTR bstrSrc)
  525.28 -{
  525.29 -  vt = VT_EMPTY;
  525.30 -  *this = bstrSrc;
  525.31 -}
  525.32 -
  525.33 -CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
  525.34 -{
  525.35 -  vt = VT_EMPTY;
  525.36 -  *this = lpszSrc;
  525.37 -}
  525.38 -
  525.39 -CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc)
  525.40 -{
  525.41 -  InternalCopy(&varSrc);
  525.42 -  return *this;
  525.43 -}
  525.44 -CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc)
  525.45 -{
  525.46 -  InternalCopy(&varSrc);
  525.47 -  return *this;
  525.48 -}
  525.49 -
  525.50 -CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
  525.51 -{
  525.52 -  *this = (LPCOLESTR)bstrSrc;
  525.53 -  return *this;
  525.54 -}
  525.55 -
  525.56 -CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
  525.57 -{
  525.58 -  InternalClear();
  525.59 -  vt = VT_BSTR;
  525.60 -  wReserved1 = 0;
  525.61 -  bstrVal = ::SysAllocString(lpszSrc);
  525.62 -  if (bstrVal == NULL && lpszSrc != NULL)
  525.63 -  {
  525.64 -    vt = VT_ERROR;
  525.65 -    scode = E_OUTOFMEMORY;
  525.66 -  }
  525.67 -  return *this;
  525.68 -}
  525.69 -
  525.70 -
  525.71 -CPropVariant& CPropVariant::operator=(bool bSrc)
  525.72 -{
  525.73 -  if (vt != VT_BOOL)
  525.74 -  {
  525.75 -    InternalClear();
  525.76 -    vt = VT_BOOL;
  525.77 -  }
  525.78 -  boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
  525.79 -  return *this;
  525.80 -}
  525.81 -
  525.82 -CPropVariant& CPropVariant::operator=(UInt32 value)
  525.83 -{
  525.84 -  if (vt != VT_UI4)
  525.85 -  {
  525.86 -    InternalClear();
  525.87 -    vt = VT_UI4;
  525.88 -  }
  525.89 -  ulVal = value;
  525.90 -  return *this;
  525.91 -}
  525.92 -
  525.93 -CPropVariant& CPropVariant::operator=(UInt64 value)
  525.94 -{
  525.95 -  if (vt != VT_UI8)
  525.96 -  {
  525.97 -    InternalClear();
  525.98 -    vt = VT_UI8;
  525.99 -  }
 525.100 -  uhVal.QuadPart = value;
 525.101 -  return *this;
 525.102 -}
 525.103 -
 525.104 -CPropVariant& CPropVariant::operator=(const FILETIME &value)
 525.105 -{
 525.106 -  if (vt != VT_FILETIME)
 525.107 -  {
 525.108 -    InternalClear();
 525.109 -    vt = VT_FILETIME;
 525.110 -  }
 525.111 -  filetime = value;
 525.112 -  return *this;
 525.113 -}
 525.114 -
 525.115 -CPropVariant& CPropVariant::operator=(Int32 value)
 525.116 -{
 525.117 -  if (vt != VT_I4)
 525.118 -  {
 525.119 -    InternalClear();
 525.120 -    vt = VT_I4;
 525.121 -  }
 525.122 -  lVal = value;
 525.123 -  
 525.124 -  return *this;
 525.125 -}
 525.126 -
 525.127 -CPropVariant& CPropVariant::operator=(Byte value)
 525.128 -{
 525.129 -  if (vt != VT_UI1)
 525.130 -  {
 525.131 -    InternalClear();
 525.132 -    vt = VT_UI1;
 525.133 -  }
 525.134 -  bVal = value;
 525.135 -  return *this;
 525.136 -}
 525.137 -
 525.138 -CPropVariant& CPropVariant::operator=(Int16 value)
 525.139 -{
 525.140 -  if (vt != VT_I2)
 525.141 -  {
 525.142 -    InternalClear();
 525.143 -    vt = VT_I2;
 525.144 -  }
 525.145 -  iVal = value;
 525.146 -  return *this;
 525.147 -}
 525.148 -
 525.149 -/*
 525.150 -CPropVariant& CPropVariant::operator=(LONG value)
 525.151 -{
 525.152 -  if (vt != VT_I4)
 525.153 -  {
 525.154 -    InternalClear();
 525.155 -    vt = VT_I4;
 525.156 -  }
 525.157 -  lVal = value;
 525.158 -  return *this;
 525.159 -}
 525.160 -*/
 525.161 -
 525.162 -static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
 525.163 -{
 525.164 -  switch(propVariant->vt)
 525.165 -  {
 525.166 -    case VT_UI1:
 525.167 -    case VT_I1:
 525.168 -    case VT_I2:
 525.169 -    case VT_UI2:
 525.170 -    case VT_BOOL:
 525.171 -    case VT_I4:
 525.172 -    case VT_UI4:
 525.173 -    case VT_R4:
 525.174 -    case VT_INT:
 525.175 -    case VT_UINT:
 525.176 -    case VT_ERROR:
 525.177 -    case VT_FILETIME:
 525.178 -    case VT_UI8:
 525.179 -    case VT_R8:
 525.180 -    case VT_CY:
 525.181 -    case VT_DATE:
 525.182 -      propVariant->vt = VT_EMPTY;
 525.183 -      propVariant->wReserved1 = 0;
 525.184 -      return S_OK;
 525.185 -  }
 525.186 -  return ::VariantClear((VARIANTARG *)propVariant);
 525.187 -}
 525.188 -
 525.189 -HRESULT CPropVariant::Clear()
 525.190 -{
 525.191 -  return MyPropVariantClear(this);
 525.192 -}
 525.193 -
 525.194 -HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
 525.195 -{
 525.196 -  ::VariantClear((tagVARIANT *)this);
 525.197 -  switch(pSrc->vt)
 525.198 -  {
 525.199 -    case VT_UI1:
 525.200 -    case VT_I1:
 525.201 -    case VT_I2:
 525.202 -    case VT_UI2:
 525.203 -    case VT_BOOL:
 525.204 -    case VT_I4:
 525.205 -    case VT_UI4:
 525.206 -    case VT_R4:
 525.207 -    case VT_INT:
 525.208 -    case VT_UINT:
 525.209 -    case VT_ERROR:
 525.210 -    case VT_FILETIME:
 525.211 -    case VT_UI8:
 525.212 -    case VT_R8:
 525.213 -    case VT_CY:
 525.214 -    case VT_DATE:
 525.215 -      memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
 525.216 -      return S_OK;
 525.217 -  }
 525.218 -  return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
 525.219 -}
 525.220 -
 525.221 -
 525.222 -HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
 525.223 -{
 525.224 -  HRESULT hr = Clear();
 525.225 -  if (FAILED(hr))
 525.226 -    return hr;
 525.227 -  memcpy(this, pSrc, sizeof(PROPVARIANT));
 525.228 -  pSrc->vt = VT_EMPTY;
 525.229 -  return S_OK;
 525.230 -}
 525.231 -
 525.232 -HRESULT CPropVariant::Detach(PROPVARIANT* pDest)
 525.233 -{
 525.234 -  HRESULT hr = MyPropVariantClear(pDest);
 525.235 -  if (FAILED(hr))
 525.236 -    return hr;
 525.237 -  memcpy(pDest, this, sizeof(PROPVARIANT));
 525.238 -  vt = VT_EMPTY;
 525.239 -  return S_OK;
 525.240 -}
 525.241 -
 525.242 -HRESULT CPropVariant::InternalClear()
 525.243 -{
 525.244 -  HRESULT hr = Clear();
 525.245 -  if (FAILED(hr))
 525.246 -  {
 525.247 -    vt = VT_ERROR;
 525.248 -    scode = hr;
 525.249 -  }
 525.250 -  return hr;
 525.251 -}
 525.252 -
 525.253 -void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
 525.254 -{
 525.255 -  HRESULT hr = Copy(pSrc);
 525.256 -  if (FAILED(hr))
 525.257 -  {
 525.258 -    vt = VT_ERROR;
 525.259 -    scode = hr;
 525.260 -  }
 525.261 -}
 525.262 -
 525.263 -int CPropVariant::Compare(const CPropVariant &a)
 525.264 -{
 525.265 -  if (vt != a.vt)
 525.266 -    return 0; // it's mean some bug
 525.267 -  switch (vt)
 525.268 -  {
 525.269 -    case VT_EMPTY:
 525.270 -      return 0;
 525.271 -    
 525.272 -    /*
 525.273 -    case VT_I1:
 525.274 -      return MyCompare(cVal, a.cVal);
 525.275 -    */
 525.276 -    case VT_UI1:
 525.277 -      return MyCompare(bVal, a.bVal);
 525.278 -
 525.279 -    case VT_I2:
 525.280 -      return MyCompare(iVal, a.iVal);
 525.281 -    case VT_UI2:
 525.282 -      return MyCompare(uiVal, a.uiVal);
 525.283 -    
 525.284 -    case VT_I4:
 525.285 -      return MyCompare(lVal, a.lVal);
 525.286 -    /*
 525.287 -    case VT_INT:
 525.288 -      return MyCompare(intVal, a.intVal);
 525.289 -    */
 525.290 -    case VT_UI4:
 525.291 -      return MyCompare(ulVal, a.ulVal);
 525.292 -    /*
 525.293 -    case VT_UINT:
 525.294 -      return MyCompare(uintVal, a.uintVal);
 525.295 -    */
 525.296 -    case VT_I8:
 525.297 -      return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
 525.298 -    case VT_UI8:
 525.299 -      return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
 525.300 -
 525.301 -    case VT_BOOL:
 525.302 -      return -MyCompare(boolVal, a.boolVal);
 525.303 -
 525.304 -    case VT_FILETIME:
 525.305 -      return ::CompareFileTime(&filetime, &a.filetime);
 525.306 -    case VT_BSTR:
 525.307 -      return 0; // Not implemented
 525.308 -      // return MyCompare(aPropVarint.cVal);
 525.309 -
 525.310 -    default:
 525.311 -      return 0;
 525.312 -  }
 525.313 -}
 525.314 -
 525.315 -}}
   526.1 --- a/src/win32/7zip/7z/CPP/Windows/PropVariant.h	Sat Mar 03 10:54:39 2012 -0600
   526.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   526.3 @@ -1,57 +0,0 @@
   526.4 -// Windows/PropVariant.h
   526.5 -
   526.6 -#ifndef __WINDOWS_PROPVARIANT_H
   526.7 -#define __WINDOWS_PROPVARIANT_H
   526.8 -
   526.9 -#include "../Common/MyWindows.h"
  526.10 -#include "../Common/Types.h"
  526.11 -
  526.12 -namespace NWindows {
  526.13 -namespace NCOM {
  526.14 -
  526.15 -class CPropVariant : public tagPROPVARIANT
  526.16 -{
  526.17 -public:
  526.18 -  CPropVariant() { vt = VT_EMPTY; wReserved1 = 0; }
  526.19 -  ~CPropVariant() { Clear(); }
  526.20 -  CPropVariant(const PROPVARIANT& varSrc);
  526.21 -  CPropVariant(const CPropVariant& varSrc);
  526.22 -  CPropVariant(BSTR bstrSrc);
  526.23 -  CPropVariant(LPCOLESTR lpszSrc);
  526.24 -  CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); };
  526.25 -  CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; }
  526.26 -  CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal = *(ULARGE_INTEGER*)&value; }
  526.27 -  CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; }
  526.28 -  CPropVariant(Int32 value) { vt = VT_I4; wReserved1 = 0; lVal = value; }
  526.29 -  CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; }
  526.30 -  CPropVariant(Int16 value) { vt = VT_I2; wReserved1 = 0; iVal = value; }
  526.31 -  // CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; }
  526.32 -
  526.33 -  CPropVariant& operator=(const CPropVariant& varSrc);
  526.34 -  CPropVariant& operator=(const PROPVARIANT& varSrc);
  526.35 -  CPropVariant& operator=(BSTR bstrSrc);
  526.36 -  CPropVariant& operator=(LPCOLESTR lpszSrc);
  526.37 -  CPropVariant& operator=(bool bSrc);
  526.38 -  CPropVariant& operator=(UInt32 value);
  526.39 -  CPropVariant& operator=(UInt64 value);
  526.40 -  CPropVariant& operator=(const FILETIME &value);
  526.41 -
  526.42 -  CPropVariant& operator=(Int32 value);
  526.43 -  CPropVariant& operator=(Byte value);
  526.44 -  CPropVariant& operator=(Int16 value);
  526.45 -  // CPropVariant& operator=(LONG  value);
  526.46 -
  526.47 -  HRESULT Clear();
  526.48 -  HRESULT Copy(const PROPVARIANT* pSrc);
  526.49 -  HRESULT Attach(PROPVARIANT* pSrc);
  526.50 -  HRESULT Detach(PROPVARIANT* pDest);
  526.51 -
  526.52 -  HRESULT InternalClear();
  526.53 -  void InternalCopy(const PROPVARIANT* pSrc);
  526.54 -
  526.55 -  int Compare(const CPropVariant &a1);
  526.56 -};
  526.57 -
  526.58 -}}
  526.59 -
  526.60 -#endif
   527.1 --- a/src/win32/7zip/7z/CPP/Windows/StdAfx.h	Sat Mar 03 10:54:39 2012 -0600
   527.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   527.3 @@ -1,9 +0,0 @@
   527.4 -// StdAfx.h
   527.5 -
   527.6 -#ifndef __STDAFX_H
   527.7 -#define __STDAFX_H
   527.8 -
   527.9 -#include "../Common/MyWindows.h"
  527.10 -#include "../Common/NewHandler.h"
  527.11 -
  527.12 -#endif
   528.1 --- a/src/win32/7zip/7z/CPP/Windows/Synchronization.h	Sat Mar 03 10:54:39 2012 -0600
   528.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   528.3 @@ -1,168 +0,0 @@
   528.4 -// Windows/Synchronization.h
   528.5 -
   528.6 -#ifndef __WINDOWS_SYNCHRONIZATION_H
   528.7 -#define __WINDOWS_SYNCHRONIZATION_H
   528.8 -
   528.9 -#include "Defs.h"
  528.10 -
  528.11 -extern "C"
  528.12 -{
  528.13 -#include "../../C/Threads.h"
  528.14 -}
  528.15 -
  528.16 -#ifdef _WIN32
  528.17 -#include "Handle.h"
  528.18 -#endif
  528.19 -
  528.20 -namespace NWindows {
  528.21 -namespace NSynchronization {
  528.22 -
  528.23 -class CBaseEvent
  528.24 -{
  528.25 -protected:
  528.26 -  ::CEvent _object;
  528.27 -public:
  528.28 -  bool IsCreated() { return Event_IsCreated(&_object) != 0; }
  528.29 -  operator HANDLE() { return _object.handle; }
  528.30 -  CBaseEvent() { Event_Construct(&_object); }
  528.31 -  ~CBaseEvent() { Close(); }
  528.32 -  WRes Close() { return Event_Close(&_object); }
  528.33 -  #ifdef _WIN32
  528.34 -  WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL,
  528.35 -      LPSECURITY_ATTRIBUTES securityAttributes = NULL)
  528.36 -  {
  528.37 -    _object.handle = ::CreateEvent(securityAttributes, BoolToBOOL(manualReset),
  528.38 -        BoolToBOOL(initiallyOwn), name);
  528.39 -    if (_object.handle != 0)
  528.40 -      return 0;
  528.41 -    return ::GetLastError();
  528.42 -  }
  528.43 -  WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
  528.44 -  {
  528.45 -    _object.handle = ::OpenEvent(desiredAccess, BoolToBOOL(inheritHandle), name);
  528.46 -    if (_object.handle != 0)
  528.47 -      return 0;
  528.48 -    return ::GetLastError();
  528.49 -  }
  528.50 -  #endif
  528.51 -
  528.52 -  WRes Set() { return Event_Set(&_object); }
  528.53 -  // bool Pulse() { return BOOLToBool(::PulseEvent(_handle)); }
  528.54 -  WRes Reset() { return Event_Reset(&_object); }
  528.55 -  WRes Lock() { return Event_Wait(&_object); }
  528.56 -};
  528.57 -
  528.58 -class CManualResetEvent: public CBaseEvent
  528.59 -{
  528.60 -public:
  528.61 -  WRes Create(bool initiallyOwn = false)
  528.62 -  {
  528.63 -    return ManualResetEvent_Create(&_object, initiallyOwn ? 1: 0);
  528.64 -  }
  528.65 -  WRes CreateIfNotCreated()
  528.66 -  {
  528.67 -    if (IsCreated())
  528.68 -      return 0;
  528.69 -    return ManualResetEvent_CreateNotSignaled(&_object);
  528.70 -  }
  528.71 -  #ifdef _WIN32
  528.72 -  WRes CreateWithName(bool initiallyOwn, LPCTSTR name)
  528.73 -  {
  528.74 -    return CBaseEvent::Create(true, initiallyOwn, name);
  528.75 -  }
  528.76 -  #endif
  528.77 -};
  528.78 -
  528.79 -class CAutoResetEvent: public CBaseEvent
  528.80 -{
  528.81 -public:
  528.82 -  WRes Create()
  528.83 -  {
  528.84 -    return AutoResetEvent_CreateNotSignaled(&_object);
  528.85 -  }
  528.86 -  WRes CreateIfNotCreated()
  528.87 -  {
  528.88 -    if (IsCreated())
  528.89 -      return 0;
  528.90 -    return AutoResetEvent_CreateNotSignaled(&_object);
  528.91 -  }
  528.92 -};
  528.93 -
  528.94 -#ifdef _WIN32
  528.95 -class CObject: public CHandle
  528.96 -{
  528.97 -public:
  528.98 -  WRes Lock(DWORD timeoutInterval = INFINITE)
  528.99 -    { return (::WaitForSingleObject(_handle, timeoutInterval) == WAIT_OBJECT_0 ? 0 : ::GetLastError()); }
 528.100 -};
 528.101 -class CMutex: public CObject
 528.102 -{
 528.103 -public:
 528.104 -  WRes Create(bool initiallyOwn, LPCTSTR name = NULL,
 528.105 -      LPSECURITY_ATTRIBUTES securityAttributes = NULL)
 528.106 -  {
 528.107 -    _handle = ::CreateMutex(securityAttributes, BoolToBOOL(initiallyOwn), name);
 528.108 -    if (_handle != 0)
 528.109 -      return 0;
 528.110 -    return ::GetLastError();
 528.111 -  }
 528.112 -  WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
 528.113 -  {
 528.114 -    _handle = ::OpenMutex(desiredAccess, BoolToBOOL(inheritHandle), name);
 528.115 -    if (_handle != 0)
 528.116 -      return 0;
 528.117 -    return ::GetLastError();
 528.118 -  }
 528.119 -  WRes Release()
 528.120 -  {
 528.121 -    return ::ReleaseMutex(_handle) ? 0 : ::GetLastError();
 528.122 -  }
 528.123 -};
 528.124 -class CMutexLock
 528.125 -{
 528.126 -  CMutex *_object;
 528.127 -public:
 528.128 -  CMutexLock(CMutex &object): _object(&object) { _object->Lock(); }
 528.129 -  ~CMutexLock() { _object->Release(); }
 528.130 -};
 528.131 -#endif
 528.132 -
 528.133 -class CSemaphore
 528.134 -{
 528.135 -  ::CSemaphore _object;
 528.136 -public:
 528.137 -  CSemaphore() { Semaphore_Construct(&_object); }
 528.138 -  ~CSemaphore() { Close(); }
 528.139 -  WRes Close() {  return Semaphore_Close(&_object); }
 528.140 -  operator HANDLE() { return _object.handle; }
 528.141 -  WRes Create(UInt32 initiallyCount, UInt32 maxCount)
 528.142 -  {
 528.143 -    return Semaphore_Create(&_object, initiallyCount, maxCount);
 528.144 -  }
 528.145 -  WRes Release() { return Semaphore_Release1(&_object); }
 528.146 -  WRes Release(UInt32 releaseCount) { return Semaphore_ReleaseN(&_object, releaseCount); }
 528.147 -  WRes Lock() { return Semaphore_Wait(&_object); }
 528.148 -};
 528.149 -
 528.150 -class CCriticalSection
 528.151 -{
 528.152 -  ::CCriticalSection _object;
 528.153 -public:
 528.154 -  CCriticalSection() { CriticalSection_Init(&_object); }
 528.155 -  ~CCriticalSection() { CriticalSection_Delete(&_object); }
 528.156 -  void Enter() { CriticalSection_Enter(&_object); }
 528.157 -  void Leave() { CriticalSection_Leave(&_object); }
 528.158 -};
 528.159 -
 528.160 -class CCriticalSectionLock
 528.161 -{
 528.162 -  CCriticalSection *_object;
 528.163 -  void Unlock()  { _object->Leave(); }
 528.164 -public:
 528.165 -  CCriticalSectionLock(CCriticalSection &object): _object(&object) {_object->Enter(); }
 528.166 -  ~CCriticalSectionLock() { Unlock(); }
 528.167 -};
 528.168 -
 528.169 -}}
 528.170 -
 528.171 -#endif
   529.1 --- a/src/win32/7zip/7z/CPP/Windows/Thread.h	Sat Mar 03 10:54:39 2012 -0600
   529.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   529.3 @@ -1,38 +0,0 @@
   529.4 -// Windows/Thread.h
   529.5 -
   529.6 -#ifndef __WINDOWS_THREAD_H
   529.7 -#define __WINDOWS_THREAD_H
   529.8 -
   529.9 -#include "Defs.h"
  529.10 -
  529.11 -extern "C"
  529.12 -{
  529.13 -#include "../../C/Threads.h"
  529.14 -}
  529.15 -
  529.16 -namespace NWindows {
  529.17 -
  529.18 -class CThread
  529.19 -{
  529.20 -  ::CThread thread;
  529.21 -public:
  529.22 -  CThread() { Thread_Construct(&thread); }
  529.23 -  ~CThread() { Close(); }
  529.24 -  bool IsCreated() { return Thread_WasCreated(&thread) != 0; }
  529.25 -  WRes Close()  { return Thread_Close(&thread); }
  529.26 -  WRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
  529.27 -    { return Thread_Create(&thread, startAddress, parameter); }
  529.28 -  WRes Wait() { return Thread_Wait(&thread); }
  529.29 -  
  529.30 -  #ifdef _WIN32
  529.31 -  DWORD Resume() { return ::ResumeThread(thread.handle); }
  529.32 -  DWORD Suspend() { return ::SuspendThread(thread.handle); }
  529.33 -  bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); }
  529.34 -  int GetPriority() { return ::GetThreadPriority(thread.handle); }
  529.35 -  bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(thread.handle, priority)); }
  529.36 -  #endif
  529.37 -};
  529.38 -
  529.39 -}
  529.40 -
  529.41 -#endif
   530.1 --- a/src/win32/7zip/7z/CPP/Windows/Time.cpp	Sat Mar 03 10:54:39 2012 -0600
   530.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   530.3 @@ -1,86 +0,0 @@
   530.4 -// Windows/Time.cpp
   530.5 -
   530.6 -#include "StdAfx.h"
   530.7 -
   530.8 -#include "Time.h"
   530.9 -#include "Windows/Defs.h"
  530.10 -
  530.11 -namespace NWindows {
  530.12 -namespace NTime {
  530.13 -
  530.14 -bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime)
  530.15 -{
  530.16 -  return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &fileTime));
  530.17 -}
  530.18 -
  530.19 -static const UInt32 kHighDosTime = 0xFF9FBF7D;
  530.20 -static const UInt32 kLowDosTime = 0x210000;
  530.21 -
  530.22 -bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime)
  530.23 -{
  530.24 -  WORD datePart, timePart;
  530.25 -  if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart))
  530.26 -  {
  530.27 -    dosTime = (fileTime.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime;
  530.28 -    return false;
  530.29 -  }
  530.30 -  dosTime = (((UInt32)datePart) << 16) + timePart;
  530.31 -  return true;
  530.32 -}
  530.33 -
  530.34 -static const UInt32 kNumTimeQuantumsInSecond = 10000000;
  530.35 -static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774;
  530.36 -
  530.37 -void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime)
  530.38 -{
  530.39 -  UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond;
  530.40 -  fileTime.dwLowDateTime = (DWORD)v;
  530.41 -  fileTime.dwHighDateTime = (DWORD)(v >> 32);
  530.42 -}
  530.43 -
  530.44 -bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime)
  530.45 -{
  530.46 -  UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
  530.47 -  if (winTime < kUnixTimeStartValue)
  530.48 -  {
  530.49 -    unixTime = 0;
  530.50 -    return false;
  530.51 -  }
  530.52 -  winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond;
  530.53 -  if (winTime > 0xFFFFFFFF)
  530.54 -  {
  530.55 -    unixTime = 0xFFFFFFFF;
  530.56 -    return false;
  530.57 -  }
  530.58 -  unixTime = (UInt32)winTime;
  530.59 -  return true;
  530.60 -}
  530.61 -
  530.62 -bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
  530.63 -  unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds)
  530.64 -{
  530.65 -  resSeconds = 0;
  530.66 -  if (year < 1601 || year >= 10000 || month < 1 || month > 12 ||
  530.67 -      day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59)
  530.68 -    return false;
  530.69 -  UInt32 numYears = year - 1601;
  530.70 -  UInt32 numDays = numYears * 365 + numYears / 4 - numYears / 100 + numYears / 400;
  530.71 -  Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  530.72 -  if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
  530.73 -    ms[1] = 29;
  530.74 -  month--;
  530.75 -  for (unsigned i = 0; i < month; i++)
  530.76 -    numDays += ms[i];
  530.77 -  numDays += day - 1;
  530.78 -  resSeconds = ((UInt64)(numDays * 24 + hour) * 60 + min) * 60 + sec;
  530.79 -  return true;
  530.80 -}
  530.81 -
  530.82 -void GetCurUtcFileTime(FILETIME &ft)
  530.83 -{
  530.84 -  SYSTEMTIME st;
  530.85 -  GetSystemTime(&st);
  530.86 -  SystemTimeToFileTime(&st, &ft);
  530.87 -}
  530.88 -
  530.89 -}}
   531.1 --- a/src/win32/7zip/7z/CPP/Windows/Time.h	Sat Mar 03 10:54:39 2012 -0600
   531.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   531.3 @@ -1,21 +0,0 @@
   531.4 -// Windows/Time.h
   531.5 -
   531.6 -#ifndef __WINDOWS_TIME_H
   531.7 -#define __WINDOWS_TIME_H
   531.8 -
   531.9 -#include "Common/Types.h"
  531.10 -
  531.11 -namespace NWindows {
  531.12 -namespace NTime {
  531.13 -
  531.14 -bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime);
  531.15 -bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime);
  531.16 -void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime);
  531.17 -bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime);
  531.18 -bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
  531.19 -  unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds);
  531.20 -void GetCurUtcFileTime(FILETIME &ft);
  531.21 -
  531.22 -}}
  531.23 -
  531.24 -#endif
   532.1 --- a/src/win32/7zip/7z/DOC/License.txt	Sat Mar 03 10:54:39 2012 -0600
   532.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   532.3 @@ -1,57 +0,0 @@
   532.4 -NOTE: The 7-zip library source is available under the LGPL,
   532.5 -however, this copy of it is distributed under the GPL 2.0.
   532.6 -This license has been modified accordingly.
   532.7 -
   532.8 -
   532.9 -  7-Zip source code
  532.10 -  ~~~~~~~~~~~~~~~~~
  532.11 -  License for use and distribution
  532.12 -  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  532.13 -
  532.14 -  7-Zip Copyright (C) 1999-2009 Igor Pavlov.
  532.15 -
  532.16 -  Licenses for files are:
  532.17 -
  532.18 -    1) The 8 files in CPP/7zip/Compress/Rar*:  GNU GPL 2.0 + unRAR restriction
  532.19 -    2) All other files:  GNU GPL 2.0
  532.20 -
  532.21 -  The GNU GPL + unRAR restriction means that you must follow both 
  532.22 -  GNU GPL rules and unRAR restriction rules.
  532.23 -
  532.24 -
  532.25 -  GNU GPL information
  532.26 -  --------------------
  532.27 -
  532.28 -    This program is free software; you can redistribute it and/or
  532.29 -    modify it under the terms of the GNU General Public License
  532.30 -    as published by the Free Software Foundation; either version 2
  532.31 -    of the License, or (at your option) any later version.
  532.32 -
  532.33 -    This program is distributed in the hope that it will be useful,
  532.34 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
  532.35 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  532.36 -    GNU General Public License for more details.
  532.37 -
  532.38 -    You should have received a copy of the GNU General Public License
  532.39 -    along with this program; if not, write to the Free Software
  532.40 -    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  532.41 -
  532.42 -
  532.43 -  unRAR restriction
  532.44 -  -----------------
  532.45 -
  532.46 -    The decompression engine for RAR archives was developed using source 
  532.47 -    code of unRAR program.
  532.48 -    All copyrights to original unRAR code are owned by Alexander Roshal.
  532.49 -
  532.50 -    The license for original unRAR code has the following restriction:
  532.51 -
  532.52 -    The unRAR sources cannot be used to re-create the RAR compression algorithm, 
  532.53 -    which is proprietary. Distribution of modified unRAR sources in separate form 
  532.54 -    or as a part of other software is permitted, provided that it is clearly
  532.55 -    stated in the documentation and source comments that the code may
  532.56 -    not be used to develop a RAR (WinRAR) compatible archiver.
  532.57 -
  532.58 -
  532.59 -  --
  532.60 -  Igor Pavlov
   533.1 --- a/src/win32/7zip/7z/DOC/gpl.txt	Sat Mar 03 10:54:39 2012 -0600
   533.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   533.3 @@ -1,339 +0,0 @@
   533.4 -		    GNU GENERAL PUBLIC LICENSE
   533.5 -		       Version 2, June 1991
   533.6 -
   533.7 - Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
   533.8 - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   533.9 - Everyone is permitted to copy and distribute verbatim copies
  533.10 - of this license document, but changing it is not allowed.
  533.11 -
  533.12 -			    Preamble
  533.13 -
  533.14 -  The licenses for most software are designed to take away your
  533.15 -freedom to share and change it.  By contrast, the GNU General Public
  533.16 -License is intended to guarantee your freedom to share and change free
  533.17 -software--to make sure the software is free for all its users.  This
  533.18 -General Public License applies to most of the Free Software
  533.19 -Foundation's software and to any other program whose authors commit to
  533.20 -using it.  (Some other Free Software Foundation software is covered by
  533.21 -the GNU Lesser General Public License instead.)  You can apply it to
  533.22 -your programs, too.
  533.23 -
  533.24 -  When we speak of free software, we are referring to freedom, not
  533.25 -price.  Our General Public Licenses are designed to make sure that you
  533.26 -have the freedom to distribute copies of free software (and charge for
  533.27 -this service if you wish), that you receive source code or can get it
  533.28 -if you want it, that you can change the software or use pieces of it
  533.29 -in new free programs; and that you know you can do these things.
  533.30 -
  533.31 -  To protect your rights, we need to make restrictions that forbid
  533.32 -anyone to deny you these rights or to ask you to surrender the rights.
  533.33 -These restrictions translate to certain responsibilities for you if you
  533.34 -distribute copies of the software, or if you modify it.
  533.35 -
  533.36 -  For example, if you distribute copies of such a program, whether
  533.37 -gratis or for a fee, you must give the recipients all the rights that
  533.38 -you have.  You must make sure that they, too, receive or can get the
  533.39 -source code.  And you must show them these terms so they know their
  533.40 -rights.
  533.41 -
  533.42 -  We protect your rights with two steps: (1) copyright the software, and
  533.43 -(2) offer you this license which gives you legal permission to copy,
  533.44 -distribute and/or modify the software.
  533.45 -
  533.46 -  Also, for each author's protection and ours, we want to make certain
  533.47 -that everyone understands that there is no warranty for this free
  533.48 -software.  If the software is modified by someone else and passed on, we
  533.49 -want its recipients to know that what they have is not the original, so
  533.50 -that any problems introduced by others will not reflect on the original
  533.51 -authors' reputations.
  533.52 -
  533.53 -  Finally, any free program is threatened constantly by software
  533.54 -patents.  We wish to avoid the danger that redistributors of a free
  533.55 -program will individually obtain patent licenses, in effect making the
  533.56 -program proprietary.  To prevent this, we have made it clear that any
  533.57 -patent must be licensed for everyone's free use or not licensed at all.
  533.58 -
  533.59 -  The precise terms and conditions for copying, distribution and
  533.60 -modification follow.
  533.61 -
  533.62 -		    GNU GENERAL PUBLIC LICENSE
  533.63 -   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  533.64 -
  533.65 -  0. This License applies to any program or other work which contains
  533.66 -a notice placed by the copyright holder saying it may be distributed
  533.67 -under the terms of this General Public License.  The "Program", below,
  533.68 -refers to any such program or work, and a "work based on the Program"
  533.69 -means either the Program or any derivative work under copyright law:
  533.70 -that is to say, a work containing the Program or a portion of it,
  533.71 -either verbatim or with modifications and/or translated into another
  533.72 -language.  (Hereinafter, translation is included without limitation in
  533.73 -the term "modification".)  Each licensee is addressed as "you".
  533.74 -
  533.75 -Activities other than copying, distribution and modification are not
  533.76 -covered by this License; they are outside its scope.  The act of
  533.77 -running the Program is not restricted, and the output from the Program
  533.78 -is covered only if its contents constitute a work based on the
  533.79 -Program (independent of having been made by running the Program).
  533.80 -Whether that is true depends on what the Program does.
  533.81 -
  533.82 -  1. You may copy and distribute verbatim copies of the Program's
  533.83 -source code as you receive it, in any medium, provided that you
  533.84 -conspicuously and appropriately publish on each copy an appropriate
  533.85 -copyright notice and disclaimer of warranty; keep intact all the
  533.86 -notices that refer to this License and to the absence of any warranty;
  533.87 -and give any other recipients of the Program a copy of this License
  533.88 -along with the Program.
  533.89 -
  533.90 -You may charge a fee for the physical act of transferring a copy, and
  533.91 -you may at your option offer warranty protection in exchange for a fee.
  533.92 -
  533.93 -  2. You may modify your copy or copies of the Program or any portion
  533.94 -of it, thus forming a work based on the Program, and copy and
  533.95 -distribute such modifications or work under the terms of Section 1
  533.96 -above, provided that you also meet all of these conditions:
  533.97 -
  533.98 -    a) You must cause the modified files to carry prominent notices
  533.99 -    stating that you changed the files and the date of any change.
 533.100 -
 533.101 -    b) You must cause any work that you distribute or publish, that in
 533.102 -    whole or in part contains or is derived from the Program or any
 533.103 -    part thereof, to be licensed as a whole at no charge to all third
 533.104 -    parties under the terms of this License.
 533.105 -
 533.106 -    c) If the modified program normally reads commands interactively
 533.107 -    when run, you must cause it, when started running for such
 533.108 -    interactive use in the most ordinary way, to print or display an
 533.109 -    announcement including an appropriate copyright notice and a
 533.110 -    notice that there is no warranty (or else, saying that you provide
 533.111 -    a warranty) and that users may redistribute the program under
 533.112 -    these conditions, and telling the user how to view a copy of this
 533.113 -    License.  (Exception: if the Program itself is interactive but
 533.114 -    does not normally print such an announcement, your work based on
 533.115 -    the Program is not required to print an announcement.)
 533.116 -
 533.117 -These requirements apply to the modified work as a whole.  If
 533.118 -identifiable sections of that work are not derived from the Program,
 533.119 -and can be reasonably considered independent and separate works in
 533.120 -themselves, then this License, and its terms, do not apply to those
 533.121 -sections when you distribute them as separate works.  But when you
 533.122 -distribute the same sections as part of a whole which is a work based
 533.123 -on the Program, the distribution of the whole must be on the terms of
 533.124 -this License, whose permissions for other licensees extend to the
 533.125 -entire whole, and thus to each and every part regardless of who wrote it.
 533.126 -
 533.127 -Thus, it is not the intent of this section to claim rights or contest
 533.128 -your rights to work written entirely by you; rather, the intent is to
 533.129 -exercise the right to control the distribution of derivative or
 533.130 -collective works based on the Program.
 533.131 -
 533.132 -In addition, mere aggregation of another work not based on the Program
 533.133 -with the Program (or with a work based on the Program) on a volume of
 533.134 -a storage or distribution medium does not bring the other work under
 533.135 -the scope of this License.
 533.136 -
 533.137 -  3. You may copy and distribute the Program (or a work based on it,
 533.138 -under Section 2) in object code or executable form under the terms of
 533.139 -Sections 1 and 2 above provided that you also do one of the following:
 533.140 -
 533.141 -    a) Accompany it with the complete corresponding machine-readable
 533.142 -    source code, which must be distributed under the terms of Sections
 533.143 -    1 and 2 above on a medium customarily used for software interchange; or,
 533.144 -
 533.145 -    b) Accompany it with a written offer, valid for at least three
 533.146 -    years, to give any third party, for a charge no more than your
 533.147 -    cost of physically performing source distribution, a complete
 533.148 -    machine-readable copy of the corresponding source code, to be
 533.149 -    distributed under the terms of Sections 1 and 2 above on a medium
 533.150 -    customarily used for software interchange; or,
 533.151 -
 533.152 -    c) Accompany it with the information you received as to the offer
 533.153 -    to distribute corresponding source code.  (This alternative is
 533.154 -    allowed only for noncommercial distribution and only if you
 533.155 -    received the program in object code or executable form with such
 533.156 -    an offer, in accord with Subsection b above.)
 533.157 -
 533.158 -The source code for a work means the preferred form of the work for
 533.159 -making modifications to it.  For an executable work, complete source
 533.160 -code means all the source code for all modules it contains, plus any
 533.161 -associated interface definition files, plus the scripts used to
 533.162 -control compilation and installation of the executable.  However, as a
 533.163 -special exception, the source code distributed need not include
 533.164 -anything that is normally distributed (in either source or binary
 533.165 -form) with the major components (compiler, kernel, and so on) of the
 533.166 -operating system on which the executable runs, unless that component
 533.167 -itself accompanies the executable.
 533.168 -
 533.169 -If distribution of executable or object code is made by offering
 533.170 -access to copy from a designated place, then offering equivalent
 533.171 -access to copy the source code from the same place counts as
 533.172 -distribution of the source code, even though third parties are not
 533.173 -compelled to copy the source along with the object code.
 533.174 -
 533.175 -  4. You may not copy, modify, sublicense, or distribute the Program
 533.176 -except as expressly provided under this License.  Any attempt
 533.177 -otherwise to copy, modify, sublicense or distribute the Program is
 533.178 -void, and will automatically terminate your rights under this License.
 533.179 -However, parties who have received copies, or rights, from you under
 533.180 -this License will not have their licenses terminated so long as such
 533.181 -parties remain in full compliance.
 533.182 -
 533.183 -  5. You are not required to accept this License, since you have not
 533.184 -signed it.  However, nothing else grants you permission to modify or
 533.185 -distribute the Program or its derivative works.  These actions are
 533.186 -prohibited by law if you do not accept this License.  Therefore, by
 533.187 -modifying or distributing the Program (or any work based on the
 533.188 -Program), you indicate your acceptance of this License to do so, and
 533.189 -all its terms and conditions for copying, distributing or modifying
 533.190 -the Program or works based on it.
 533.191 -
 533.192 -  6. Each time you redistribute the Program (or any work based on the
 533.193 -Program), the recipient automatically receives a license from the
 533.194 -original licensor to copy, distribute or modify the Program subject to
 533.195 -these terms and conditions.  You may not impose any further
 533.196 -restrictions on the recipients' exercise of the rights granted herein.
 533.197 -You are not responsible for enforcing compliance by third parties to
 533.198 -this License.
 533.199 -
 533.200 -  7. If, as a consequence of a court judgment or allegation of patent
 533.201 -infringement or for any other reason (not limited to patent issues),
 533.202 -conditions are imposed on you (whether by court order, agreement or
 533.203 -otherwise) that contradict the conditions of this License, they do not
 533.204 -excuse you from the conditions of this License.  If you cannot
 533.205 -distribute so as to satisfy simultaneously your obligations under this
 533.206 -License and any other pertinent obligations, then as a consequence you
 533.207 -may not distribute the Program at all.  For example, if a patent
 533.208 -license would not permit royalty-free redistribution of the Program by
 533.209 -all those who receive copies directly or indirectly through you, then
 533.210 -the only way you could satisfy both it and this License would be to
 533.211 -refrain entirely from distribution of the Program.
 533.212 -
 533.213 -If any portion of this section is held invalid or unenforceable under
 533.214 -any particular circumstance, the balance of the section is intended to
 533.215 -apply and the section as a whole is intended to apply in other
 533.216 -circumstances.
 533.217 -
 533.218 -It is not the purpose of this section to induce you to infringe any
 533.219 -patents or other property right claims or to contest validity of any
 533.220 -such claims; this section has the sole purpose of protecting the
 533.221 -integrity of the free software distribution system, which is
 533.222 -implemented by public license practices.  Many people have made
 533.223 -generous contributions to the wide range of software distributed
 533.224 -through that system in reliance on consistent application of that
 533.225 -system; it is up to the author/donor to decide if he or she is willing
 533.226 -to distribute software through any other system and a licensee cannot
 533.227 -impose that choice.
 533.228 -
 533.229 -This section is intended to make thoroughly clear what is believed to
 533.230 -be a consequence of the rest of this License.
 533.231 -
 533.232 -  8. If the distribution and/or use of the Program is restricted in
 533.233 -certain countries either by patents or by copyrighted interfaces, the
 533.234 -original copyright holder who places the Program under this License
 533.235 -may add an explicit geographical distribution limitation excluding
 533.236 -those countries, so that distribution is permitted only in or among
 533.237 -countries not thus excluded.  In such case, this License incorporates
 533.238 -the limitation as if written in the body of this License.
 533.239 -
 533.240 -  9. The Free Software Foundation may publish revised and/or new versions
 533.241 -of the General Public License from time to time.  Such new versions will
 533.242 -be similar in spirit to the present version, but may differ in detail to
 533.243 -address new problems or concerns.
 533.244 -
 533.245 -Each version is given a distinguishing version number.  If the Program
 533.246 -specifies a version number of this License which applies to it and "any
 533.247 -later version", you have the option of following the terms and conditions
 533.248 -either of that version or of any later version published by the Free
 533.249 -Software Foundation.  If the Program does not specify a version number of
 533.250 -this License, you may choose any version ever published by the Free Software
 533.251 -Foundation.
 533.252 -
 533.253 -  10. If you wish to incorporate parts of the Program into other free
 533.254 -programs whose distribution conditions are different, write to the author
 533.255 -to ask for permission.  For software which is copyrighted by the Free
 533.256 -Software Foundation, write to the Free Software Foundation; we sometimes
 533.257 -make exceptions for this.  Our decision will be guided by the two goals
 533.258 -of preserving the free status of all derivatives of our free software and
 533.259 -of promoting the sharing and reuse of software generally.
 533.260 -
 533.261 -			    NO WARRANTY
 533.262 -
 533.263 -  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 533.264 -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
 533.265 -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
 533.266 -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
 533.267 -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 533.268 -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
 533.269 -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
 533.270 -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
 533.271 -REPAIR OR CORRECTION.
 533.272 -
 533.273 -  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
 533.274 -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
 533.275 -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
 533.276 -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
 533.277 -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
 533.278 -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
 533.279 -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 533.280 -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 533.281 -POSSIBILITY OF SUCH DAMAGES.
 533.282 -
 533.283 -		     END OF TERMS AND CONDITIONS
 533.284 -
 533.285 -	    How to Apply These Terms to Your New Programs
 533.286 -
 533.287 -  If you develop a new program, and you want it to be of the greatest
 533.288 -possible use to the public, the best way to achieve this is to make it
 533.289 -free software which everyone can redistribute and change under these terms.
 533.290 -
 533.291 -  To do so, attach the following notices to the program.  It is safest
 533.292 -to attach them to the start of each source file to most effectively
 533.293 -convey the exclusion of warranty; and each file should have at least
 533.294 -the "copyright" line and a pointer to where the full notice is found.
 533.295 -
 533.296 -    <one line to give the program's name and a brief idea of what it does.>
 533.297 -    Copyright (C) <year>  <name of author>
 533.298 -
 533.299 -    This program is free software; you can redistribute it and/or modify
 533.300 -    it under the terms of the GNU General Public License as published by
 533.301 -    the Free Software Foundation; either version 2 of the License, or
 533.302 -    (at your option) any later version.
 533.303 -
 533.304 -    This program is distributed in the hope that it will be useful,
 533.305 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
 533.306 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 533.307 -    GNU General Public License for more details.
 533.308 -
 533.309 -    You should have received a copy of the GNU General Public License along
 533.310 -    with this program; if not, write to the Free Software Foundation, Inc.,
 533.311 -    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 533.312 -
 533.313 -Also add information on how to contact you by electronic and paper mail.
 533.314 -
 533.315 -If the program is interactive, make it output a short notice like this
 533.316 -when it starts in an interactive mode:
 533.317 -
 533.318 -    Gnomovision version 69, Copyright (C) year name of author
 533.319 -    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
 533.320 -    This is free software, and you are welcome to redistribute it
 533.321 -    under certain conditions; type `show c' for details.
 533.322 -
 533.323 -The hypothetical commands `show w' and `show c' should show the appropriate
 533.324 -parts of the General Public License.  Of course, the commands you use may
 533.325 -be called something other than `show w' and `show c'; they could even be
 533.326 -mouse-clicks or menu items--whatever suits your program.
 533.327 -
 533.328 -You should also get your employer (if you work as a programmer) or your
 533.329 -school, if any, to sign a "copyright disclaimer" for the program, if
 533.330 -necessary.  Here is a sample; alter the names:
 533.331 -
 533.332 -  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
 533.333 -  `Gnomovision' (which makes passes at compilers) written by James Hacker.
 533.334 -
 533.335 -  <signature of Ty Coon>, 1 April 1989
 533.336 -  Ty Coon, President of Vice
 533.337 -
 533.338 -This General Public License does not permit incorporating your program into
 533.339 -proprietary programs.  If your program is a subroutine library, you may
 533.340 -consider it more useful to permit linking proprietary applications with the
 533.341 -library.  If this is what you want to do, use the GNU Lesser General
 533.342 -Public License instead of this License.
   534.1 --- a/src/win32/7zip/7z/DOC/readme.txt	Sat Mar 03 10:54:39 2012 -0600
   534.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   534.3 @@ -1,49 +0,0 @@
   534.4 -This copy of the 7-zip source code has been modified as follows:
   534.5 -- Encoding support has been disabled, so only archive extraction is supported.
   534.6 -- Some archive formats have been removed, so only 7z, bzip2, gzip, lzh, lzma, rar, split, tar, and zip are supported.
   534.7 -- Support for using it as a static library has been added. (specifically, a file called InitializeStaticLib.h)
   534.8 -- Occasional minor fixes/customization not really worth describing in detail.
   534.9 -- The LGPL part of the 7-zip library source license has been upgraded to GPL 2.0 (as per condition 3 of the LGPL 2.1)
  534.10 -
  534.11 -You can find most of the files in this library in the "7-Zip Source code" download at http://www.7-zip.org/ distributed under the LGPL 2.1.
  534.12 -A small subset of them are in the LZMA SDK which is public domain and can be found at http://www.7-zip.org/sdk.html
  534.13 -
  534.14 -
  534.15 -
  534.16 -7-Zip 4.64 Sources
  534.17 -------------------
  534.18 -
  534.19 -7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP/Vista. 
  534.20 -
  534.21 -7-Zip Copyright (C) 1999-2009 Igor Pavlov.
  534.22 -
  534.23 -
  534.24 -License Info
  534.25 -------------
  534.26 -
  534.27 -This copy of 7-Zip is free software distributed under the GNU GPL 2.0
  534.28 -(with an additional restriction that has always applied to the unRar code).
  534.29 -read License.txt for more infomation about license.
  534.30 -
  534.31 -Notes about unRAR license:
  534.32 -
  534.33 -Please check main restriction from unRar license:
  534.34 -
  534.35 -   2. The unRAR sources may be used in any software to handle RAR
  534.36 -      archives without limitations free of charge, but cannot be used
  534.37 -      to re-create the RAR compression algorithm, which is proprietary.
  534.38 -      Distribution of modified unRAR sources in separate form or as a
  534.39 -      part of other software is permitted, provided that it is clearly
  534.40 -      stated in the documentation and source comments that the code may
  534.41 -      not be used to develop a RAR (WinRAR) compatible archiver.
  534.42 -
  534.43 -In brief it means:
  534.44 -1) You can compile and use compiled files under GNU GPL rules, since 
  534.45 -   unRAR license almost has no restrictions for compiled files.
  534.46 -   You can link these compiled files to GPL programs.
  534.47 -2) You can fix bugs in source code and use compiled fixed version.
  534.48 -3) You can not use unRAR sources to re-create the RAR compression algorithm.
  534.49 -
  534.50 ----
  534.51 -Igor Pavlov
  534.52 -http://www.7-zip.org
   535.1 --- a/src/win32/7zip/7z/DOC/unRarLicense.txt	Sat Mar 03 10:54:39 2012 -0600
   535.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   535.3 @@ -1,41 +0,0 @@
   535.4 - ******    *****   ******   unRAR - free utility for RAR archives
   535.5 - **   **  **   **  **   **  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   535.6 - ******   *******  ******    License for use and distribution of
   535.7 - **   **  **   **  **   **   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   535.8 - **   **  **   **  **   **         FREE portable version
   535.9 -                                   ~~~~~~~~~~~~~~~~~~~~~
  535.10 -
  535.11 -      The source code of unRAR utility is freeware. This means:
  535.12 -
  535.13 -   1. All copyrights to RAR and the utility unRAR are exclusively
  535.14 -      owned by the author - Alexander Roshal.
  535.15 -
  535.16 -   2. The unRAR sources may be used in any software to handle RAR
  535.17 -      archives without limitations free of charge, but cannot be used
  535.18 -      to re-create the RAR compression algorithm, which is proprietary.
  535.19 -      Distribution of modified unRAR sources in separate form or as a
  535.20 -      part of other software is permitted, provided that it is clearly
  535.21 -      stated in the documentation and source comments that the code may
  535.22 -      not be used to develop a RAR (WinRAR) compatible archiver.
  535.23 -
  535.24 -   3. The unRAR utility may be freely distributed. No person or company 
  535.25 -      may charge a fee for the distribution of unRAR without written
  535.26 -      permission from the copyright holder.
  535.27 -
  535.28 -   4. THE RAR ARCHIVER AND THE UNRAR UTILITY ARE DISTRIBUTED "AS IS".
  535.29 -      NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.  YOU USE AT 
  535.30 -      YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, 
  535.31 -      DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING
  535.32 -      OR MISUSING THIS SOFTWARE.
  535.33 -
  535.34 -   5. Installing and using the unRAR utility signifies acceptance of
  535.35 -      these terms and conditions of the license.
  535.36 -
  535.37 -   6. If you don't agree with terms of the license you must remove
  535.38 -      unRAR files from your storage devices and cease to use the
  535.39 -      utility.
  535.40 -
  535.41 -      Thank you for your interest in RAR and unRAR.
  535.42 -
  535.43 -
  535.44 -                                            Alexander L. Roshal
  535.45 \ No newline at end of file
   536.1 --- a/src/win32/7zip/7zip.cpp	Sat Mar 03 10:54:39 2012 -0600
   536.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   536.3 @@ -1,392 +0,0 @@
   536.4 -#include "7zip.h"
   536.5 -
   536.6 -#include "7z/C/Types.h"
   536.7 -#include "7z/CPP/7zip/Archive/IArchive.h"
   536.8 -#include "7z/CPP/Common/InitializeStaticLib.h" // important! (if using a static lib)
   536.9 -
  536.10 -#include <string>
  536.11 -#include <vector>
  536.12 -#include <cassert>
  536.13 -#include <malloc.h>
  536.14 -
  536.15 -#include "7zipstreams.h" // defines OutStream and InFileStream
  536.16 -
  536.17 -STDAPI GetNumberOfFormats(UINT32 *numFormats);
  536.18 -STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value);
  536.19 -STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject);
  536.20 -
  536.21 -struct ArchiveFormatInfo
  536.22 -{
  536.23 -	std::string name;
  536.24 -	std::vector<std::string> extensions;
  536.25 -	std::string signature;
  536.26 -	GUID guid;
  536.27 -};
  536.28 -
  536.29 -static std::vector<ArchiveFormatInfo> s_formatInfos;
  536.30 -
  536.31 -static std::string wstrToStr(const wchar_t* wstr)
  536.32 -{
  536.33 -/*
  536.34 -	// This thing wouldn't work
  536.35 -	char* str = (char*)_alloca((wcslen(wstr)+1));
  536.36 -    sprintf(str, "%S", wstr);
  536.37 -	return std::string(str);
  536.38 -*/
  536.39 -//	setlocale(LC_CTYPE, ".ACP");
  536.40 -	size_t n = wcstombs(NULL, wstr, 0);
  536.41 -	if (n == (size_t)-1)	// failed
  536.42 -	{
  536.43 -//		setlocale(LC_CTYPE, "C");
  536.44 -		return std::string();
  536.45 -	}
  536.46 -	char* str = (char*)_alloca(n + 1);
  536.47 -	wcstombs(str, wstr, n);
  536.48 -	str[n] = '\0';
  536.49 -//	setlocale(LC_CTYPE, "C");
  536.50 -	return std::string(str);
  536.51 -}
  536.52 -
  536.53 -static std::vector<std::string> tokenize(const std::string & str, const std::string & delim)
  536.54 -{
  536.55 -	std::vector<std::string> tokens;
  536.56 -	size_t p0 = 0, p1 = std::string::npos;
  536.57 -	while(p0 != std::string::npos)
  536.58 -	{
  536.59 -		p1 = str.find_first_of(delim, p0);
  536.60 -		if(p1 != p0)
  536.61 -		{
  536.62 -			std::string token = str.substr(p0, p1 - p0);
  536.63 -			tokens.push_back(token);
  536.64 -		}
  536.65 -		p0 = str.find_first_not_of(delim, p1);
  536.66 -	}
  536.67 -	return tokens;
  536.68 -}
  536.69 -
  536.70 -static std::string s_supportedFormatsFilter;
  536.71 -const char* GetSupportedFormatsFilter()
  536.72 -{
  536.73 -	assert(!s_formatInfos.empty());
  536.74 -	if(s_supportedFormatsFilter.empty())
  536.75 -	{
  536.76 -		s_supportedFormatsFilter = "";
  536.77 -		for(size_t i = 0; i < s_formatInfos.size(); i++)
  536.78 -		{
  536.79 -			for(size_t j = 0; j < s_formatInfos[i].extensions.size(); j++)
  536.80 -			{
  536.81 -				s_supportedFormatsFilter += ";*.";
  536.82 -				s_supportedFormatsFilter += s_formatInfos[i].extensions[j];
  536.83 -			}
  536.84 -		}
  536.85 -	}
  536.86 -	return s_supportedFormatsFilter.c_str();
  536.87 -}
  536.88 -
  536.89 -void InitDecoder()
  536.90 -{
  536.91 -	CleanupDecoder();
  536.92 -
  536.93 -	UINT32 numFormats = 0;
  536.94 -	GetNumberOfFormats(&numFormats);
  536.95 -
  536.96 -	for(unsigned int i = 0; i < numFormats; i++)
  536.97 -	{
  536.98 -		PROPVARIANT var = {VT_EMPTY};
  536.99 -		ArchiveFormatInfo info;
 536.100 -
 536.101 -		GetHandlerProperty2(i, NArchive::kName, &var);
 536.102 -		if(var.vt == VT_BSTR)
 536.103 -			info.name = wstrToStr(var.bstrVal);
 536.104 -
 536.105 -		GetHandlerProperty2(i, NArchive::kExtension, &var);
 536.106 -		if(var.vt == VT_BSTR)
 536.107 -			info.extensions = tokenize(wstrToStr(var.bstrVal), " ");
 536.108 -
 536.109 -		GetHandlerProperty2(i, NArchive::kStartSignature, &var);
 536.110 -		if(var.vt == VT_BSTR)
 536.111 -			info.signature = (const char*)var.bstrVal; // note: there's no 100% correct way of doing this with the existing 7-zip interface, but this is much better than using SysStringLen() in any way (it would return 1 for the signature "BZh", for example)
 536.112 -
 536.113 -		GetHandlerProperty2(i,NArchive::kClassID,&var);
 536.114 -		if(var.vt == VT_BSTR)
 536.115 -			memcpy(&info.guid, var.bstrVal, 16);
 536.116 -		else
 536.117 -			memset(&info.guid, 0, 16);
 536.118 -
 536.119 -		s_formatInfos.push_back(info);
 536.120 -
 536.121 -		VariantClear((VARIANTARG*)&var);
 536.122 -	}
 536.123 -}
 536.124 -
 536.125 -void CleanupDecoder()
 536.126 -{
 536.127 -	s_formatInfos.clear();
 536.128 -	s_supportedFormatsFilter.clear();
 536.129 -}
 536.130 -
 536.131 -#include "7z/CPP/7zip/Archive/Zip/ZipHandler.h"
 536.132 -
 536.133 -
 536.134 -ArchiveFile::ArchiveFile(const char* filename, const char* displayFilename)
 536.135 -{
 536.136 -	assert(!s_formatInfos.empty());
 536.137 -
 536.138 -	m_typeIndex = -1;
 536.139 -	m_numItems = 0;
 536.140 -	m_items = NULL;
 536.141 -	m_filename = NULL;
 536.142 -	m_displayFilename = NULL;
 536.143 -	m_userMadeSelection = false;
 536.144 -
 536.145 -	FILE* file = fopen(filename, "rb");
 536.146 -	if(!file)
 536.147 -		return;
 536.148 -
 536.149 -	m_filename = new char[strlen(filename)+1];
 536.150 -	strcpy(m_filename, filename);
 536.151 -
 536.152 -	if(displayFilename)
 536.153 -	{
 536.154 -		m_displayFilename = new char[strlen(displayFilename)+1];
 536.155 -		strcpy(m_displayFilename, displayFilename);
 536.156 -	}
 536.157 -
 536.158 -	// detect archive type using format signature in file
 536.159 -	for(size_t i = 0; i < s_formatInfos.size() && m_typeIndex < 0; i++)
 536.160 -	{
 536.161 -		fseek(file, 0, SEEK_SET);
 536.162 -		
 536.163 -		std::string& formatSig = s_formatInfos[i].signature;
 536.164 -		int len = formatSig.size();
 536.165 -
 536.166 -		if(len == 0)
 536.167 -			continue; // because some formats have no signature
 536.168 -
 536.169 -		char* fileSig = (char*)_alloca(len);
 536.170 -		fread(fileSig, 1, len, file);
 536.171 -
 536.172 -		if(!memcmp(formatSig.c_str(), fileSig, len))
 536.173 -			m_typeIndex = i;
 536.174 -	}
 536.175 -
 536.176 -	// if no signature match has been found, detect archive type using filename.
 536.177 -	// this is only for signature-less formats
 536.178 -	const char* fileExt = strrchr(filename, '.');
 536.179 -	if(fileExt++)
 536.180 -	{
 536.181 -		for(size_t i = 0; i < s_formatInfos.size() && m_typeIndex < 0; i++)
 536.182 -		{
 536.183 -			if(s_formatInfos[i].signature.empty())
 536.184 -			{
 536.185 -				std::vector<std::string>& formatExts = s_formatInfos[i].extensions;
 536.186 -				for(size_t j = 0; j < formatExts.size(); j++)
 536.187 -				{
 536.188 -					if(!_stricmp(formatExts[j].c_str(), fileExt))
 536.189 -					{
 536.190 -						m_typeIndex = i;
 536.191 -						break;
 536.192 -					}
 536.193 -				}
 536.194 -			}
 536.195 -		}
 536.196 -	}
 536.197 -
 536.198 -	if(m_typeIndex < 0)
 536.199 -	{
 536.200 -		// uncompressed
 536.201 -
 536.202 -		m_numItems = 1;
 536.203 -		m_items = new ArchiveItem[m_numItems];
 536.204 -
 536.205 -		fseek(file, 0, SEEK_END);
 536.206 -		m_items[0].size = ftell(file);
 536.207 -
 536.208 -		m_items[0].name = new char[strlen(filename)+1];
 536.209 -		strcpy(m_items[0].name, filename);
 536.210 -	}
 536.211 -	else
 536.212 -	{
 536.213 -		IInArchive* object = NULL;
 536.214 -		if(SUCCEEDED(CreateObject(&s_formatInfos[m_typeIndex].guid, &IID_IInArchive, (void**)&object)))
 536.215 -		{
 536.216 -			InFileStream* ifs = new InFileStream(filename);
 536.217 -			if(SUCCEEDED(object->Open(ifs,0,0)))
 536.218 -			{
 536.219 -				UInt32 numItems = 0;
 536.220 -				object->GetNumberOfItems(&numItems);
 536.221 -				m_numItems = numItems;
 536.222 -				m_items = new ArchiveItem[m_numItems];
 536.223 -
 536.224 -				for(int i = 0; i < m_numItems; i++)
 536.225 -				{
 536.226 -					PROPVARIANT var = {VT_EMPTY};
 536.227 -					ArchiveItem& item = m_items[i];
 536.228 -
 536.229 -					object->GetProperty(i, kpidSize, &var);
 536.230 -					item.size = var.uhVal.LowPart;
 536.231 -
 536.232 -					object->GetProperty(i, kpidPath, &var);
 536.233 -					std::string& path = wstrToStr(var.bstrVal);
 536.234 -					item.name = new char[path.size()+1];
 536.235 -					strcpy(item.name, path.c_str());
 536.236 -
 536.237 -					//object->GetProperty(i, kpidMethod, &var);
 536.238 -					//std::string& method = wstrToStr(var.bstrVal);
 536.239 -					//item.method = new char[method.size()+1];
 536.240 -					//strcpy(item.method, method.c_str());
 536.241 -
 536.242 -					object->GetProperty(i, kpidEncrypted, &var);
 536.243 -#ifdef _NO_CRYPTO
 536.244 -					if(var.boolVal)
 536.245 -						item.size = 0; // don't support decompressing it, pretend size zero
 536.246 -#else
 536.247 -					#error password support NYI... see client7z.cpp
 536.248 -					item.encrypted = !!var.boolVal;
 536.249 -#endif
 536.250 -
 536.251 -					VariantClear((VARIANTARG*)&var);
 536.252 -				}
 536.253 -
 536.254 -				object->Close();
 536.255 -			}
 536.256 -
 536.257 -			object->Release();
 536.258 -		}
 536.259 -	}
 536.260 -
 536.261 -	fclose(file);
 536.262 -}
 536.263 -
 536.264 -ArchiveFile::~ArchiveFile()
 536.265 -{
 536.266 -	for(int i = 0; i < m_numItems; i++)
 536.267 -	{
 536.268 -		delete[] m_items[i].name;
 536.269 -	}
 536.270 -	delete[] m_items;
 536.271 -	delete[] m_filename;
 536.272 -	delete[] m_displayFilename;
 536.273 -}
 536.274 -
 536.275 -const char* ArchiveFile::GetArchiveTypeName()
 536.276 -{
 536.277 -	assert(!s_formatInfos.empty());
 536.278 -
 536.279 -	if((size_t)m_typeIndex >= s_formatInfos.size())
 536.280 -		return "";
 536.281 -
 536.282 -	return s_formatInfos[m_typeIndex].name.c_str();
 536.283 -}
 536.284 -
 536.285 -int ArchiveFile::GetNumItems()
 536.286 -{
 536.287 -	return m_numItems;
 536.288 -}
 536.289 -
 536.290 -int ArchiveFile::GetItemSize(int item)
 536.291 -{
 536.292 -	assert(item >= 0 && item < m_numItems);
 536.293 -	if(!(item >= 0 && item < m_numItems)) return 0;
 536.294 -	return m_items[item].size;
 536.295 -}
 536.296 -
 536.297 -const char* ArchiveFile::GetItemName(int item)
 536.298 -{
 536.299 -	//assert(item >= 0 && item < m_numItems);
 536.300 -	if(!(item >= 0 && item < m_numItems)) return "";
 536.301 -	return m_items[item].name;
 536.302 -}
 536.303 -
 536.304 -bool ArchiveFile::IsCompressed()
 536.305 -{
 536.306 -	return (m_typeIndex >= 0);
 536.307 -}
 536.308 -
 536.309 -int ArchiveFile::ExtractItem(int index, unsigned char* outBuffer, int bufSize) const
 536.310 -{
 536.311 -	assert(!s_formatInfos.empty());
 536.312 -	//assert(index >= 0 && index < m_numItems);
 536.313 -	if(!(index >= 0 && index < m_numItems)) return 0;
 536.314 -
 536.315 -	ArchiveItem& item = m_items[index];
 536.316 -
 536.317 -	if(bufSize < item.size)
 536.318 -		return 0;
 536.319 -
 536.320 -	if(m_typeIndex < 0)
 536.321 -	{
 536.322 -		// uncompressed
 536.323 -		FILE* file = fopen(m_filename, "rb");
 536.324 -		fread(outBuffer, 1, item.size, file);
 536.325 -		fclose(file);
 536.326 -	}
 536.327 -	else
 536.328 -	{
 536.329 -		IInArchive* object = NULL;
 536.330 -		HRESULT hr = E_FAIL;
 536.331 -		if(SUCCEEDED(CreateObject(&s_formatInfos[m_typeIndex].guid, &IID_IInArchive, (void**)&object)))
 536.332 -		{
 536.333 -			InFileStream* ifs = new InFileStream(m_filename);
 536.334 -			if(SUCCEEDED(object->Open(ifs,0,0)))
 536.335 -			{
 536.336 -				OutStream* os = new OutStream(index, outBuffer, item.size);
 536.337 -				const UInt32 indices [1] = {index};
 536.338 -				hr = object->Extract(indices, 1, 0, os);
 536.339 -				object->Close();
 536.340 -			}
 536.341 -			object->Release();
 536.342 -		}
 536.343 -		if(FAILED(hr))
 536.344 -			return 0;
 536.345 -	}
 536.346 -
 536.347 -	return item.size;
 536.348 -}
 536.349 -
 536.350 -
 536.351 -
 536.352 -int ArchiveFile::ExtractItem(int index, const char* outFilename) const
 536.353 -{
 536.354 -	assert(!s_formatInfos.empty());
 536.355 -	//assert(index >= 0 && index < m_numItems);
 536.356 -	if(!(index >= 0 && index < m_numItems)) return 0;
 536.357 -
 536.358 -	ArchiveItem& item = m_items[index];
 536.359 -	int rv = item.size;
 536.360 -
 536.361 -	DWORD outAttributes = GetFileAttributes(outFilename);
 536.362 -	if(outAttributes & FILE_ATTRIBUTE_READONLY)
 536.363 -		SetFileAttributes(outFilename, outAttributes & ~FILE_ATTRIBUTE_READONLY); // temporarily remove read-only attribute so we can decompress to there
 536.364 -
 536.365 -	if(m_typeIndex < 0)
 536.366 -	{
 536.367 -		// uncompressed
 536.368 -		if(!CopyFile(m_filename, outFilename, false))
 536.369 -			rv = 0;
 536.370 -	}
 536.371 -	else
 536.372 -	{
 536.373 -		IInArchive* object = NULL;
 536.374 -		HRESULT hr = E_FAIL;
 536.375 -		if(SUCCEEDED(CreateObject(&s_formatInfos[m_typeIndex].guid, &IID_IInArchive, (void**)&object)))
 536.376 -		{
 536.377 -			InFileStream* ifs = new InFileStream(m_filename);
 536.378 -			if(SUCCEEDED(object->Open(ifs,0,0)))
 536.379 -			{
 536.380 -				OutStream* os = new OutStream(index, outFilename);
 536.381 -				const UInt32 indices [1] = {index};
 536.382 -				hr = object->Extract(indices, 1, 0, os);
 536.383 -				object->Close();
 536.384 -			}
 536.385 -			object->Release();
 536.386 -		}
 536.387 -		if(FAILED(hr))
 536.388 -			rv = 0;
 536.389 -	}
 536.390 -
 536.391 -	if(outAttributes & FILE_ATTRIBUTE_READONLY)
 536.392 -		SetFileAttributes(outFilename, outAttributes); // restore read-only attribute
 536.393 -
 536.394 -	return rv;
 536.395 -}
   537.1 --- a/src/win32/7zip/7zip.h	Sat Mar 03 10:54:39 2012 -0600
   537.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   537.3 @@ -1,45 +0,0 @@
   537.4 -#ifndef _7ZIP_DEC_HEADER
   537.5 -#define _7ZIP_DEC_HEADER
   537.6 -
   537.7 -// 7zip file extraction
   537.8 -// NOTE: if you want to add support for opening files within archives to something,
   537.9 -// consider using the higher-level interface provided by OpenArchive.h instead
  537.10 -
  537.11 -void InitDecoder();
  537.12 -void CleanupDecoder();
  537.13 -const char* GetSupportedFormatsFilter();
  537.14 -
  537.15 -// simplest way of extracting a file after calling InitDecoder():
  537.16 -// int size = ArchiveFile(filename).ExtractItem(0, buf, sizeof(buf));
  537.17 -
  537.18 -struct ArchiveFile
  537.19 -{
  537.20 -	ArchiveFile(const char* filename, const char* displayFilename=0);
  537.21 -	virtual ~ArchiveFile();
  537.22 -
  537.23 -	int GetNumItems();
  537.24 -	int GetItemSize(int item);
  537.25 -	const char* GetItemName(int item);
  537.26 -	int ExtractItem(int item, unsigned char* outBuffer, int bufSize) const; // returns size, or 0 if failed
  537.27 -	int ExtractItem(int item, const char* outFilename) const;
  537.28 -
  537.29 -	bool IsCompressed();
  537.30 -	const char* GetArchiveTypeName();
  537.31 -	const char* GetArchiveFileName() { return m_displayFilename ? m_displayFilename : m_filename; }
  537.32 -
  537.33 -	bool m_userMadeSelection;
  537.34 -
  537.35 -protected:
  537.36 -	struct ArchiveItem
  537.37 -	{
  537.38 -		int size;
  537.39 -		char* name;
  537.40 -	};
  537.41 -	ArchiveItem* m_items;
  537.42 -	int m_numItems;
  537.43 -	int m_typeIndex;
  537.44 -	char* m_filename;
  537.45 -	char* m_displayFilename;
  537.46 -};
  537.47 -
  537.48 -#endif
   538.1 --- a/src/win32/7zip/7zip.rc	Sat Mar 03 10:54:39 2012 -0600
   538.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   538.3 @@ -1,97 +0,0 @@
   538.4 -// Microsoft Visual C++ generated resource script.
   538.5 -//
   538.6 -#include "../resource.h"
   538.7 -
   538.8 -#define APSTUDIO_READONLY_SYMBOLS
   538.9 -/////////////////////////////////////////////////////////////////////////////
  538.10 -//
  538.11 -// Generated from the TEXTINCLUDE 2 resource.
  538.12 -//
  538.13 -#include "afxres.h"
  538.14 -
  538.15 -/////////////////////////////////////////////////////////////////////////////
  538.16 -#undef APSTUDIO_READONLY_SYMBOLS
  538.17 -
  538.18 -/////////////////////////////////////////////////////////////////////////////
  538.19 -// English (U.S.) resources
  538.20 -
  538.21 -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
  538.22 -#ifdef _WIN32
  538.23 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
  538.24 -#pragma code_page(1252)
  538.25 -#endif //_WIN32
  538.26 -
  538.27 -
  538.28 -/////////////////////////////////////////////////////////////////////////////
  538.29 -//
  538.30 -// Dialog
  538.31 -//
  538.32 -
  538.33 -IDD_ARCHIVEFILECHOOSER DIALOGEX 0, 0, 182, 113
  538.34 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_THICKFRAME
  538.35 -CAPTION "Choose File"
  538.36 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
  538.37 -BEGIN
  538.38 -    DEFPUSHBUTTON   "&OK",IDOK,128,94,50,16
  538.39 -    PUSHBUTTON      "&Cancel",ID_CANCEL,73,94,50,16
  538.40 -    LISTBOX         IDC_LIST1,4,4,173,87,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
  538.41 -END
  538.42 -
  538.43 -
  538.44 -/////////////////////////////////////////////////////////////////////////////
  538.45 -//
  538.46 -// DESIGNINFO
  538.47 -//
  538.48 -
  538.49 -#ifdef APSTUDIO_INVOKED
  538.50 -GUIDELINES DESIGNINFO 
  538.51 -BEGIN
  538.52 -    IDD_ARCHIVEFILECHOOSER, DIALOG
  538.53 -    BEGIN
  538.54 -        RIGHTMARGIN, 181
  538.55 -    END
  538.56 -END
  538.57 -#endif    // APSTUDIO_INVOKED
  538.58 -
  538.59 -
  538.60 -
  538.61 -
  538.62 -#ifdef APSTUDIO_INVOKED
  538.63 -/////////////////////////////////////////////////////////////////////////////
  538.64 -//
  538.65 -// TEXTINCLUDE
  538.66 -//
  538.67 -
  538.68 -1 TEXTINCLUDE 
  538.69 -BEGIN
  538.70 -    "resource.h\0"
  538.71 -END
  538.72 -
  538.73 -3 TEXTINCLUDE 
  538.74 -BEGIN
  538.75 -    "\r\0"
  538.76 -END
  538.77 -
  538.78 -2 TEXTINCLUDE 
  538.79 -BEGIN
  538.80 -    "#include ""afxres.h""\r\0"
  538.81 -END
  538.82 -
  538.83 -#endif    // APSTUDIO_INVOKED
  538.84 -
  538.85 -
  538.86 -#endif    // English (U.S.) resources
  538.87 -/////////////////////////////////////////////////////////////////////////////
  538.88 -
  538.89 -
  538.90 -
  538.91 -#ifndef APSTUDIO_INVOKED
  538.92 -/////////////////////////////////////////////////////////////////////////////
  538.93 -//
  538.94 -// Generated from the TEXTINCLUDE 3 resource.
  538.95 -//
  538.96 -
  538.97 -
  538.98 -/////////////////////////////////////////////////////////////////////////////
  538.99 -#endif    // not APSTUDIO_INVOKED
 538.100 -
   539.1 --- a/src/win32/7zip/7zipstreams.h	Sat Mar 03 10:54:39 2012 -0600
   539.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   539.3 @@ -1,315 +0,0 @@
   539.4 -// This file is (modified) from
   539.5 -// FCEUX (2009)
   539.6 -// FCE Ultra - NES/Famicom Emulator
   539.7 -// Copyright (C) 2003 Xodnizel
   539.8 -// 
   539.9 -// This program is free software; you can redistribute it and/or modify
  539.10 -// it under the terms of the GNU General Public License as published by
  539.11 -// the Free Software Foundation; either version 2 of the License, or
  539.12 -// (at your option) any later version.
  539.13 -// 
  539.14 -// This program is distributed in the hope that it will be useful,
  539.15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
  539.16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  539.17 -// GNU General Public License for more details.
  539.18 -// 
  539.19 -// You should have received a copy of the GNU General Public License
  539.20 -// along with this program; if not, write to the Free Software
  539.21 -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  539.22 -
  539.23 -#ifndef _7ZIPSTREAMS_HEADER
  539.24 -#define _7ZIPSTREAMS_HEADER
  539.25 -
  539.26 -#include "7z/CPP/Common/MyCom.h"
  539.27 -
  539.28 -class ICountedSequentialOutStream : public ISequentialOutStream
  539.29 -{
  539.30 -public:
  539.31 -	virtual UINT32 Size() const = 0;
  539.32 -};
  539.33 -
  539.34 -class SeqMemoryOutStream : public ICountedSequentialOutStream, private CMyUnknownImp
  539.35 -{
  539.36 -	UINT8* const output;
  539.37 -	UINT32 pos;
  539.38 -	const UINT32 size;
  539.39 -	ULONG refCount;
  539.40 -
  539.41 -	HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID, void**)
  539.42 -	{
  539.43 -		return E_NOINTERFACE;
  539.44 -	}
  539.45 -
  539.46 -	HRESULT STDMETHODCALLTYPE Write(const void* data, UInt32 length, UInt32* bytesWritten)
  539.47 -	{
  539.48 -		if (data != NULL || size == 0)
  539.49 -		{
  539.50 -			//assert(length <= size - pos);
  539.51 -
  539.52 -			if (length > size - pos)
  539.53 -				length = size - pos;
  539.54 -
  539.55 -			if(data)
  539.56 -				memcpy(output + pos, data, length);
  539.57 -			pos += length;
  539.58 -
  539.59 -			if (bytesWritten)
  539.60 -				*bytesWritten = length;
  539.61 -
  539.62 -			return S_OK;
  539.63 -		}
  539.64 -		else
  539.65 -		{
  539.66 -			return E_INVALIDARG;
  539.67 -		}
  539.68 -	}
  539.69 -
  539.70 -	MY_ADDREF_RELEASE
  539.71 -
  539.72 -public:
  539.73 -
  539.74 -	SeqMemoryOutStream(void* d, UINT32 s) : output((UINT8*)d), pos(0), size(s), refCount(0) {}
  539.75 -
  539.76 -	virtual ~SeqMemoryOutStream()
  539.77 -	{
  539.78 -		int a = 0;
  539.79 -	}
  539.80 -
  539.81 -	UINT32 Size() const
  539.82 -	{
  539.83 -		return pos;
  539.84 -	}
  539.85 -};
  539.86 -
  539.87 -class SeqFileOutStream : public ICountedSequentialOutStream, private CMyUnknownImp
  539.88 -{
  539.89 -	FILE* file;
  539.90 -	UINT32 pos;
  539.91 -	ULONG refCount;
  539.92 -
  539.93 -	HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID, void**)
  539.94 -	{
  539.95 -		return E_NOINTERFACE;
  539.96 -	}
  539.97 -
  539.98 -	HRESULT STDMETHODCALLTYPE Write(const void* data, UInt32 length, UInt32* bytesWritten)
  539.99 -	{
 539.100 -		if(!file)
 539.101 -			return E_FAIL;
 539.102 -
 539.103 -		if (data != NULL)
 539.104 -		{
 539.105 -			int written = 0;
 539.106 -			if(data)
 539.107 -				written = fwrite(data, 1, length, file);
 539.108 -
 539.109 -			pos += written;
 539.110 -			if (bytesWritten)
 539.111 -				*bytesWritten = written;
 539.112 -
 539.113 -			return S_OK;
 539.114 -		}
 539.115 -		else
 539.116 -		{
 539.117 -			return E_INVALIDARG;
 539.118 -		}
 539.119 -	}
 539.120 -
 539.121 -	MY_ADDREF_RELEASE
 539.122 -
 539.123 -public:
 539.124 -
 539.125 -	SeqFileOutStream(const char* outFilename) : pos(0), refCount(0)
 539.126 -	{
 539.127 -		file = fopen(outFilename, "wb");
 539.128 -	}
 539.129 -	virtual ~SeqFileOutStream()
 539.130 -	{
 539.131 -		if(file)
 539.132 -			fclose(file);
 539.133 -	}
 539.134 -
 539.135 -	UINT32 Size() const
 539.136 -	{
 539.137 -		return pos;
 539.138 -	}
 539.139 -};
 539.140 -
 539.141 -
 539.142 -class OutStream : public IArchiveExtractCallback, private CMyUnknownImp
 539.143 -{
 539.144 -	ICountedSequentialOutStream* seqStream;
 539.145 -	const UINT32 index;
 539.146 -	ULONG refCount;
 539.147 -
 539.148 -	HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID, void**)
 539.149 -	{
 539.150 -		return E_NOINTERFACE;
 539.151 -	}
 539.152 -
 539.153 -	HRESULT STDMETHODCALLTYPE PrepareOperation(Int32)
 539.154 -	{
 539.155 -		return S_OK;
 539.156 -	}
 539.157 -
 539.158 -	HRESULT STDMETHODCALLTYPE SetTotal(UInt64)
 539.159 -	{
 539.160 -		return S_OK;
 539.161 -	}
 539.162 -
 539.163 -	HRESULT STDMETHODCALLTYPE SetCompleted(const UInt64*)
 539.164 -	{
 539.165 -		return S_OK;
 539.166 -	}
 539.167 -
 539.168 -	HRESULT STDMETHODCALLTYPE SetOperationResult(Int32)
 539.169 -	{
 539.170 -		return S_OK;
 539.171 -	}
 539.172 -
 539.173 -	HRESULT STDMETHODCALLTYPE GetStream(UInt32 id, ISequentialOutStream** ptr, Int32 mode)
 539.174 -	{
 539.175 -		switch (mode)
 539.176 -		{
 539.177 -			case NArchive::NExtract::NAskMode::kExtract:
 539.178 -			case NArchive::NExtract::NAskMode::kTest:
 539.179 -
 539.180 -				if (id != index || ptr == NULL)
 539.181 -					return S_FALSE;
 539.182 -				else
 539.183 -					*ptr = seqStream;
 539.184 -			// fall through
 539.185 -			case NArchive::NExtract::NAskMode::kSkip:
 539.186 -				return S_OK;
 539.187 -
 539.188 -			default:
 539.189 -				return E_INVALIDARG;
 539.190 -		}
 539.191 -	}
 539.192 -
 539.193 -	MY_ADDREF_RELEASE
 539.194 -
 539.195 -public:
 539.196 -
 539.197 -	OutStream(UINT32 index, void* data, UINT32 size) : index(index), refCount(0)
 539.198 -	{
 539.199 -		seqStream = new SeqMemoryOutStream(data, size);
 539.200 -		seqStream->AddRef();
 539.201 -	}
 539.202 -	OutStream(UINT32 index, const char* outFilename) : index(index), refCount(0)
 539.203 -	{
 539.204 -		seqStream = new SeqFileOutStream(outFilename);
 539.205 -		seqStream->AddRef();
 539.206 -	}
 539.207 -	virtual ~OutStream()
 539.208 -	{
 539.209 -		//seqStream->Release(); // commented out because apparently IInArchive::Extract() calls Release one more time than it calls AddRef
 539.210 -	}
 539.211 -	UINT32 Size() const
 539.212 -	{
 539.213 -		return seqStream->Size();
 539.214 -	}
 539.215 -};
 539.216 -
 539.217 -class InStream : public IInStream, private IStreamGetSize, private CMyUnknownImp
 539.218 -{
 539.219 -	ULONG refCount;
 539.220 -
 539.221 -	HRESULT STDMETHODCALLTYPE QueryInterface(REFGUID, void**)
 539.222 -	{
 539.223 -		return E_NOINTERFACE;
 539.224 -	}
 539.225 -
 539.226 -	HRESULT STDMETHODCALLTYPE GetSize(UInt64* outSize)
 539.227 -	{
 539.228 -		if (outSize)
 539.229 -		{
 539.230 -			*outSize = size;
 539.231 -			return S_OK;
 539.232 -		}
 539.233 -		else
 539.234 -		{
 539.235 -			return E_INVALIDARG;
 539.236 -		}
 539.237 -	}
 539.238 -
 539.239 -	MY_ADDREF_RELEASE
 539.240 -
 539.241 -protected:
 539.242 -
 539.243 -	UINT32 size;
 539.244 -
 539.245 -public:
 539.246 -
 539.247 -	explicit InStream() : refCount(0) {}
 539.248 -	virtual ~InStream() {}
 539.249 -};
 539.250 -
 539.251 -
 539.252 -class InFileStream : public InStream
 539.253 -{
 539.254 -public:
 539.255 -
 539.256 -	virtual ~InFileStream()
 539.257 -	{
 539.258 -		if(file)
 539.259 -			fclose(file);
 539.260 -	}
 539.261 -
 539.262 -	FILE* file;
 539.263 -
 539.264 -	InFileStream(const char* fname) : file(NULL)
 539.265 -	{
 539.266 -		file = fopen(fname, "rb");
 539.267 -		if(file)
 539.268 -		{
 539.269 -			fseek(file, 0, SEEK_END);
 539.270 -			size = ftell(file);
 539.271 -			fseek(file, 0, SEEK_SET);
 539.272 -		}
 539.273 -	}
 539.274 -
 539.275 -	HRESULT STDMETHODCALLTYPE Read(void* data, UInt32 length, UInt32* bytesRead)
 539.276 -	{
 539.277 -		if(!file)
 539.278 -			return E_FAIL;
 539.279 -
 539.280 -		if (data != NULL || length == 0)
 539.281 -		{
 539.282 -			int read = fread(data, 1, length, file);
 539.283 -			
 539.284 -			if (bytesRead)
 539.285 -				*bytesRead = read;
 539.286 -
 539.287 -			return S_OK;
 539.288 -		}
 539.289 -		else
 539.290 -		{
 539.291 -			return E_INVALIDARG;
 539.292 -		}
 539.293 -	}
 539.294 -
 539.295 -	HRESULT STDMETHODCALLTYPE Seek(Int64 offset, UInt32 origin, UInt64* pos)
 539.296 -	{
 539.297 -		if(!file)
 539.298 -			return E_FAIL;
 539.299 -
 539.300 -		if (origin < 3)
 539.301 -		{
 539.302 -			fseek(file, (long)offset, origin);
 539.303 -			origin = ftell(file);
 539.304 -
 539.305 -			if (pos)
 539.306 -				*pos = origin;
 539.307 -
 539.308 -			return S_OK;
 539.309 -		}
 539.310 -		else
 539.311 -		{
 539.312 -			return E_INVALIDARG;
 539.313 -		}
 539.314 -	
 539.315 -	}
 539.316 -};
 539.317 -
 539.318 -#endif
   540.1 --- a/src/win32/7zip/OpenArchive.cpp	Sat Mar 03 10:54:39 2012 -0600
   540.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   540.3 @@ -1,713 +0,0 @@
   540.4 -#include "../stdafx.h"
   540.5 -#include "../resource.h"
   540.6 -#include <windows.h>
   540.7 -#include <mmsystem.h>
   540.8 -#include <cstdio>
   540.9 -#include <cerrno>
  540.10 -#include <cassert>
  540.11 -#include <cstring>
  540.12 -#include <map>
  540.13 -#include <vector>
  540.14 -#include <algorithm>
  540.15 -#include "7zip.h"
  540.16 -//#include "G_main.h"
  540.17 -//#include "G_dsound.h"
  540.18 -#include "OpenArchive.h"
  540.19 -
  540.20 -LRESULT CALLBACK ArchiveFileChooser(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  540.21 -static int s_archiveFileChooserResult = -1;
  540.22 -
  540.23 -static HWND s_parentHWND = NULL;
  540.24 -void SetArchiveParentHWND(void* hwnd) { s_parentHWND = (HWND)hwnd; }
  540.25 -static HWND GetArchiveParentHWND() { return s_parentHWND ? s_parentHWND : AfxGetApp()->m_pMainWnd->GetSafeHwnd(); }
  540.26 -
  540.27 -static char Str_Tmp [2048];
  540.28 -
  540.29 -struct ArchiveFileChooserInfo
  540.30 -{
  540.31 -	ArchiveFileChooserInfo(ArchiveFile& theArchive, const char** ignoreExtensions, int& numIgnoreExtensions) : archive(theArchive)
  540.32 -	{
  540.33 -tryagain:
  540.34 -		int numItems = archive.GetNumItems();
  540.35 -		for(int i = 0; i < numItems; i++)
  540.36 -		{
  540.37 -			if(archive.GetItemSize(i))
  540.38 -			{
  540.39 -				const char* name = archive.GetItemName(i);
  540.40 -				const char* ext = strrchr(name, '.');
  540.41 -				bool ok = true;
  540.42 -				if(ext++)
  540.43 -				{
  540.44 -					for(int j = 0; j < numIgnoreExtensions; j++)
  540.45 -					{
  540.46 -						const char* ext2 = ignoreExtensions[j];
  540.47 -						const char* wild = strchr(ext2, '*');
  540.48 -						if(!wild)
  540.49 -						{
  540.50 -							if(!_stricmp(ext, ext2))
  540.51 -							{
  540.52 -								ok = false;
  540.53 -								break;
  540.54 -							}
  540.55 -						}
  540.56 -						else // very limited (end only) wildcard support
  540.57 -						{
  540.58 -							if(!_strnicmp(ext, ext2, wild - ext2))
  540.59 -							{
  540.60 -								ok = false;
  540.61 -								break;
  540.62 -							}
  540.63 -						}
  540.64 -					}
  540.65 -				}
  540.66 -				if(ok)
  540.67 -				{
  540.68 -					ArchiveFileChooserInfo::FileInfo fi = { name, i };
  540.69 -					files.push_back(fi);
  540.70 -				}
  540.71 -			}
  540.72 -		}
  540.73 -
  540.74 -		if(files.empty() && numIgnoreExtensions)
  540.75 -		{
  540.76 -			// try again without any exclusions if we excluded everything in the archive
  540.77 -			numIgnoreExtensions = 0;
  540.78 -			goto tryagain;
  540.79 -		}
  540.80 -
  540.81 -		// strip away prefix paths that are common to all the files
  540.82 -		bool stripping = !files.empty();
  540.83 -		while(stripping)
  540.84 -		{
  540.85 -			const char* firstName = files[0].name.c_str();
  540.86 -			const char* slash = strchr(firstName, '\\');
  540.87 -			const char* slash2 = strchr(firstName, '/');
  540.88 -			slash = max(slash, slash2);
  540.89 -			if(!slash++)
  540.90 -				break;
  540.91 -			for(size_t i = 1; i < files.size(); i++)
  540.92 -				if(strncmp(firstName, files[i].name.c_str(), slash - firstName))
  540.93 -					stripping = false;
  540.94 -			if(stripping)
  540.95 -				for(size_t i = 0; i < files.size(); i++)
  540.96 -					files[i].name = files[i].name.substr(slash - firstName, files[i].name.length() - (slash - firstName));
  540.97 -		}
  540.98 -
  540.99 -		// sort by filename
 540.100 -		std::sort(files.begin(), files.end(), FileInfo::Sort);
 540.101 -	}
 540.102 -
 540.103 -//protected:
 540.104 -
 540.105 -	struct FileInfo
 540.106 -	{
 540.107 -		std::string name;
 540.108 -		int itemIndex;
 540.109 -		
 540.110 -		static bool Sort(const FileInfo& elem1, const FileInfo& elem2)
 540.111 -		{
 540.112 -			int comp = elem1.name.compare(elem2.name);
 540.113 -			return comp ? (comp < 0) : (elem1.itemIndex < elem2.itemIndex);
 540.114 -		}
 540.115 -	};
 540.116 -
 540.117 -	ArchiveFile& archive;
 540.118 -	std::vector<FileInfo> files;
 540.119 -};
 540.120 -
 540.121 -static void ClearLayoutStates();
 540.122 -
 540.123 -int ChooseItemFromArchive(ArchiveFile& archive, bool autoChooseIfOnly1, const char** ignoreExtensions, int numIgnoreExtensions)
 540.124 -{
 540.125 -	int prevNumIgnoreExtensions = numIgnoreExtensions;
 540.126 -	archive.m_userMadeSelection = false;
 540.127 -
 540.128 -	// prepare a list of files to choose from the archive
 540.129 -	ArchiveFileChooserInfo info (archive, ignoreExtensions, numIgnoreExtensions);
 540.130 -
 540.131 -	// based on our list, decide which item in the archive to choose
 540.132 -
 540.133 -	// check if there's nothing
 540.134 -	if(info.files.size() < 1)
 540.135 -	{
 540.136 -		MessageBox(GetArchiveParentHWND(), "The archive is either empty or encrypted.", "Nothing to load!", MB_OK | MB_ICONWARNING);
 540.137 -		return -1;
 540.138 -	}
 540.139 -
 540.140 -	// warn if all the files in the archive have extensions we should ignore
 540.141 -	if(numIgnoreExtensions != prevNumIgnoreExtensions)
 540.142 -	{
 540.143 -		CString msg;
 540.144 -		msg.Format("The archive appears to only contain the wrong type of files.\n\n(in \"%s\")", archive.GetArchiveFileName());
 540.145 -		int answer = MessageBox(GetArchiveParentHWND(), msg, "Warning", MB_OKCANCEL | MB_ICONWARNING | MB_DEFBUTTON2);
 540.146 -		if(answer == IDCANCEL)
 540.147 -			return -1;
 540.148 -	}
 540.149 -
 540.150 -	// if there's only 1 item, choose it
 540.151 -	if(info.files.size() == 1 && autoChooseIfOnly1 && numIgnoreExtensions == prevNumIgnoreExtensions)
 540.152 -		return info.files[0].itemIndex;
 540.153 -
 540.154 -	// bring up a dialog to choose the index if there's more than 1
 540.155 -	DialogBoxParam(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_ARCHIVEFILECHOOSER), GetArchiveParentHWND(), (DLGPROC) ArchiveFileChooser,(LPARAM) &info);
 540.156 -	archive.m_userMadeSelection = (s_archiveFileChooserResult != -1);
 540.157 -	return s_archiveFileChooserResult;
 540.158 -}
 540.159 -
 540.160 -
 540.161 -
 540.162 -
 540.163 -#define DEFAULT_EXTENSION ".tmp"
 540.164 -#define DEFAULT_CATEGORY "vba"
 540.165 -
 540.166 -static struct TempFiles
 540.167 -{
 540.168 -	struct TemporaryFile
 540.169 -	{
 540.170 -		TemporaryFile(const char* cat, const char* ext)
 540.171 -		{
 540.172 -			if(!ext || !*ext) ext = DEFAULT_EXTENSION;
 540.173 -			if(!cat || !*cat) cat = DEFAULT_CATEGORY;
 540.174 -			category = cat;
 540.175 -
 540.176 -			char tempPath [2048];
 540.177 -			GetTempPath(2048, tempPath);
 540.178 -			//GetTempFileName(tempPath, cat, 0, filename, ext); // alas
 540.179 -
 540.180 -			char*const fname = tempPath + strlen(tempPath);
 540.181 -			unsigned short start = (unsigned short)(timeGetTime() & 0xFFFF);
 540.182 -			unsigned short n = start + 1;
 540.183 -			while(n != start)
 540.184 -			{
 540.185 -				_snprintf(fname, 2048 - (fname - tempPath), "%s%04X%s", cat, n, ext);
 540.186 -				FILE* file = fopen(tempPath, "wb");
 540.187 -				if(file)
 540.188 -				{
 540.189 -					// mark the temporary file as read-only and (whatever this does) temporary
 540.190 -					DWORD attributes = GetFileAttributes(tempPath);
 540.191 -					attributes |= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_TEMPORARY;
 540.192 -					SetFileAttributes(tempPath, attributes);
 540.193 -
 540.194 -					fclose(file);
 540.195 -
 540.196 -					// add it to our registry of files that need to be deleted, in case we fail to terminate properly
 540.197 -					TempFiles::AddEntryToGarbageRegistry(tempPath);
 540.198 -
 540.199 -					break;
 540.200 -				}
 540.201 -				n++;
 540.202 -			}
 540.203 -			strcpy(filename, tempPath);
 540.204 -		}
 540.205 -		TemporaryFile(const TemporaryFile& copy)
 540.206 -		{
 540.207 -			strcpy(filename, copy.filename);
 540.208 -			category = copy.category;
 540.209 -		}
 540.210 -		TemporaryFile()
 540.211 -		{
 540.212 -			filename[0] = 0;
 540.213 -			// category[0] = 0;	// error
 540.214 -		}
 540.215 -		bool Delete(bool returnFalseOnRegistryRemovalFailure=false)
 540.216 -		{
 540.217 -			if(!*filename)
 540.218 -				return true; // guess it already didn't exist
 540.219 -
 540.220 -			// remove read-only attribute so Windows will let us delete it
 540.221 -			// (our temporary files are read-only to discourage other apps from tampering)
 540.222 -			DWORD attributes = GetFileAttributes(filename);
 540.223 -			if(attributes & FILE_ATTRIBUTE_READONLY)
 540.224 -				SetFileAttributes(filename, attributes & ~FILE_ATTRIBUTE_READONLY);
 540.225 -
 540.226 -			if(_unlink(filename) == 0 || errno != EACCES)
 540.227 -			{
 540.228 -				// remove it from our registry of files that need to be deleted, to reduce accumulation
 540.229 -				bool removed = TempFiles::RemoveEntryFromGarbageRegistry(filename);
 540.230 -
 540.231 -				*filename = '\0';
 540.232 -				return removed || !returnFalseOnRegistryRemovalFailure; // successfully deleted or already didn't exist, return true unless registry removal failure notification was requested and that failed
 540.233 -			}
 540.234 -
 540.235 -			// restore read-only if we couldn't delete it (not sure if this ever succeeds or matters though)
 540.236 -			if(attributes & FILE_ATTRIBUTE_READONLY)
 540.237 -				SetFileAttributes(filename, attributes);
 540.238 -
 540.239 -			return false; // failed to delete read-only or in-use file
 540.240 -		}
 540.241 -		char filename [MAX_PATH];
 540.242 -		std::string category;
 540.243 -	};
 540.244 -
 540.245 -	std::vector<TemporaryFile> tempFiles;
 540.246 -
 540.247 -	const char* GetFile(const char* category, const char* extension)
 540.248 -	{
 540.249 -		tempFiles.push_back(TemporaryFile(category, extension));
 540.250 -		return tempFiles.back().filename;
 540.251 -	}
 540.252 -
 540.253 -	void ReleaseFile(const char* filename)
 540.254 -	{
 540.255 -		for(int i = (int)tempFiles.size()-1; i >= 0; i--)
 540.256 -		{
 540.257 -			if(!strcmp(filename, tempFiles[i].filename))
 540.258 -			{
 540.259 -				if(tempFiles[i].Delete())
 540.260 -					tempFiles.erase(tempFiles.begin() + i);
 540.261 -			}
 540.262 -		}
 540.263 -	}
 540.264 -
 540.265 -	void ReleaseCategory(const char* cat, const char* exceptionFilename)
 540.266 -	{
 540.267 -		for(int i = (int)tempFiles.size()-1; i >= 0; i--)
 540.268 -		{
 540.269 -			if(!strcmp(cat, tempFiles[i].category.c_str()) &&
 540.270 -				(!exceptionFilename ||
 540.271 -				  strcmp(exceptionFilename, tempFiles[i].filename)))
 540.272 -			{
 540.273 -				if(tempFiles[i].Delete())
 540.274 -					tempFiles.erase(tempFiles.begin() + i);
 540.275 -			}
 540.276 -		}
 540.277 -	}
 540.278 -
 540.279 -	// delete all temporary files on shutdown
 540.280 -	~TempFiles()
 540.281 -	{
 540.282 -		for(size_t i = 0; i < tempFiles.size(); i++)
 540.283 -		{
 540.284 -			tempFiles[i].Delete();
 540.285 -		}
 540.286 -
 540.287 -		TempFiles::CleanOutGarbageRegistry();
 540.288 -	}
 540.289 -
 540.290 -	// run this on startup to delete any files that we failed to delete last time
 540.291 -	// in case we crashed or were forcefully terminated
 540.292 -	TempFiles()
 540.293 -	{
 540.294 -		TempFiles::CleanOutGarbageRegistry();
 540.295 -	}
 540.296 -
 540.297 -	static void AddEntryToGarbageRegistry(const char* filename)
 540.298 -	{
 540.299 -		char gbgFile[2048];
 540.300 -		GetTempPath(2048, gbgFile);
 540.301 -		strcat(gbgFile, "VBATempFileRecords");
 540.302 -		char key[64];
 540.303 -		int i = 0;
 540.304 -		while(true)
 540.305 -		{
 540.306 -			sprintf(key, "File%d", i);
 540.307 -			GetPrivateProfileString("Files", key, "", Str_Tmp, 2048, gbgFile);
 540.308 -			if(!*Str_Tmp)
 540.309 -				break;
 540.310 -			i++;
 540.311 -		}
 540.312 -		WritePrivateProfileString("Files", key, filename, gbgFile);
 540.313 -	}
 540.314 -	static bool RemoveEntryFromGarbageRegistry(const char* filename)
 540.315 -	{
 540.316 -		char gbgFile[2048];
 540.317 -		GetTempPath(2048, gbgFile);
 540.318 -		strcat(gbgFile, "VBATempFileRecords");
 540.319 -		char key[64];
 540.320 -		int i = 0;
 540.321 -		int deleteSlot = -1;
 540.322 -		while(true)
 540.323 -		{
 540.324 -			sprintf(key, "File%d", i);
 540.325 -			GetPrivateProfileString("Files", key, "", Str_Tmp, 2048, gbgFile);
 540.326 -			if(!*Str_Tmp)
 540.327 -				break;
 540.328 -			if(!strcmp(Str_Tmp, filename))
 540.329 -				deleteSlot = i;
 540.330 -			i++;
 540.331 -		}
 540.332 -		--i;
 540.333 -		if(i >= 0 && deleteSlot >= 0)
 540.334 -		{
 540.335 -			if(i != deleteSlot)
 540.336 -			{
 540.337 -				sprintf(key, "File%d", i);
 540.338 -				GetPrivateProfileString("Files", key, "", Str_Tmp, 2048, gbgFile);
 540.339 -				sprintf(key, "File%d", deleteSlot);
 540.340 -				WritePrivateProfileString("Files", key, Str_Tmp, gbgFile);
 540.341 -			}
 540.342 -			sprintf(key, "File%d", i);
 540.343 -			if(0 == WritePrivateProfileString("Files", key, NULL, gbgFile))
 540.344 -				return false;
 540.345 -		}
 540.346 -		if(i <= 0 && deleteSlot == 0)
 540.347 -			_unlink(gbgFile);
 540.348 -		return true;
 540.349 -	}
 540.350 -
 540.351 -private:
 540.352 -	static void CleanOutGarbageRegistry()
 540.353 -	{
 540.354 -		char gbgFile[2048];
 540.355 -		GetTempPath(2048, gbgFile);
 540.356 -		strcat(gbgFile, "VBATempFileRecords");
 540.357 -
 540.358 -		char key[64];
 540.359 -		int i = 0;
 540.360 -		while(true)
 540.361 -		{
 540.362 -			sprintf(key, "File%d", i);
 540.363 -			GetPrivateProfileString("Files", key, "", Str_Tmp, 2048, gbgFile);
 540.364 -			if(!*Str_Tmp)
 540.365 -				break;
 540.366 -			TemporaryFile temp;
 540.367 -			strcpy(temp.filename, Str_Tmp);
 540.368 -			if(!temp.Delete(true))
 540.369 -				i++;
 540.370 -		}
 540.371 -	}
 540.372 -
 540.373 -} s_tempFiles;
 540.374 -
 540.375 -
 540.376 -const char* GetTempFile(const char* category, const char* extension)
 540.377 -{
 540.378 -	return s_tempFiles.GetFile(category, extension);
 540.379 -}
 540.380 -void ReleaseTempFile(const char* filename)
 540.381 -{
 540.382 -	s_tempFiles.ReleaseFile(filename);
 540.383 -}
 540.384 -void ReleaseTempFileCategory(const char* cat, const char* exceptionFilename)
 540.385 -{
 540.386 -	if(!cat || !*cat) cat = DEFAULT_CATEGORY;
 540.387 -	s_tempFiles.ReleaseCategory(cat, exceptionFilename);
 540.388 -}
 540.389 -
 540.390 -
 540.391 -
 540.392 -// example input Name:          "C:\games.zip"
 540.393 -// example output LogicalName:  "C:\games.zip|Metroid.gba"
 540.394 -// example output PhysicalName: "C:\Documents and Settings\User\Local Settings\Temp\VBA\rom7A37.gba"
 540.395 -// assumes arguments are character buffers with 2048 bytes each
 540.396 -bool ObtainFile(const char* Name, char *const & LogicalName, char *const & PhysicalName, const char* category, const char** ignoreExtensions, int numIgnoreExtensions)
 540.397 -{
 540.398 -restart:
 540.399 -	char ArchivePaths [2048];
 540.400 -	strcpy(LogicalName, Name);
 540.401 -	strcpy(PhysicalName, Name);
 540.402 -	strcpy(ArchivePaths, Name);
 540.403 -	char* bar = strchr(ArchivePaths, '|');
 540.404 -	if(bar)
 540.405 -	{
 540.406 -		PhysicalName[bar - ArchivePaths] = 0; // doesn't belong in the physical name
 540.407 -		LogicalName[bar - ArchivePaths] = 0; // we'll reconstruct the logical name as we go
 540.408 -		*bar++ = 0; // bar becomes the next logical archive path component
 540.409 -	}
 540.410 -
 540.411 -	bool userSelected = false;
 540.412 -
 540.413 -	while(true)
 540.414 -	{
 540.415 -		ArchiveFile archive (PhysicalName, LogicalName);
 540.416 -		if(!archive.IsCompressed())
 540.417 -		{
 540.418 -			if(archive.GetNumItems() > 0)
 540.419 -				return true;
 540.420 -			else
 540.421 -			{
 540.422 -				// failed or cancelled... backtrack to outermost archive if not already there
 540.423 -				char* div = NULL;
 540.424 -				if(LogicalName[strlen(LogicalName)-1] == '|')
 540.425 -				{
 540.426 -					LogicalName[strlen(LogicalName)-1] = '\0';
 540.427 -					div = strrchr(LogicalName, '|');
 540.428 -				}
 540.429 -				if(div && userSelected)
 540.430 -					goto restart;
 540.431 -				else
 540.432 -					return false;
 540.433 -			}
 540.434 -		}
 540.435 -		else
 540.436 -		{
 540.437 -			int item = -1;
 540.438 -			bool forceManual = false;
 540.439 -			if(bar && *bar) // try following the in-archive part of the logical path
 540.440 -			{
 540.441 -				char* bar2 = strchr(bar, '|');
 540.442 -				if(bar2) *bar2++ = 0;
 540.443 -				int numItems = archive.GetNumItems();
 540.444 -				for(int i = 0; i < numItems; i++)
 540.445 -				{
 540.446 -					if(archive.GetItemSize(i))
 540.447 -					{
 540.448 -						const char* itemName = archive.GetItemName(i);
 540.449 -						if(!_stricmp(itemName, bar))
 540.450 -						{
 540.451 -							item = i; // match found, now we'll auto-follow the path
 540.452 -							break;
 540.453 -						}
 540.454 -					}
 540.455 -				}
 540.456 -				if(item < 0)
 540.457 -				{
 540.458 -					forceManual = true; // we don't want it choosing something else without user permission
 540.459 -					bar = NULL; // remaining archive path is invalid
 540.460 -				}
 540.461 -				else
 540.462 -					bar = bar2; // advance to next archive path part
 540.463 -			}
 540.464 -			if(item < 0)
 540.465 -				item = ChooseItemFromArchive(archive, !forceManual, ignoreExtensions, numIgnoreExtensions);
 540.466 -			
 540.467 -			userSelected |= archive.m_userMadeSelection;
 540.468 -
 540.469 -			const char* TempFileName = s_tempFiles.GetFile(category, strrchr(archive.GetItemName(item), '.'));
 540.470 -			if(!archive.ExtractItem(item, TempFileName))
 540.471 -				s_tempFiles.ReleaseFile(TempFileName);
 540.472 -			s_tempFiles.ReleaseFile(PhysicalName);
 540.473 -			strcpy(PhysicalName, TempFileName);
 540.474 -			_snprintf(LogicalName + strlen(LogicalName), 2048 - (strlen(LogicalName)+1), "|%s", archive.GetItemName(item));
 540.475 -		}
 540.476 -	}
 540.477 -}
 540.478 -
 540.479 -
 540.480 -
 540.481 -struct ControlLayoutInfo
 540.482 -{
 540.483 -	int controlID;
 540.484 -	
 540.485 -	enum LayoutType // what to do when the containing window resizes
 540.486 -	{
 540.487 -		NONE, // leave the control where it was
 540.488 -		RESIZE_END, // resize the control
 540.489 -		MOVE_START, // move the control
 540.490 -	};
 540.491 -	LayoutType horizontalLayout;
 540.492 -	LayoutType verticalLayout;
 540.493 -};
 540.494 -struct ControlLayoutState
 540.495 -{
 540.496 -	int x,y,width,height;
 540.497 -	bool valid;
 540.498 -	ControlLayoutState() : valid(false) {}
 540.499 -};
 540.500 -
 540.501 -static ControlLayoutInfo controlLayoutInfos [] = {
 540.502 -	{IDC_LIST1, ControlLayoutInfo::RESIZE_END, ControlLayoutInfo::RESIZE_END},
 540.503 -	{IDOK,      ControlLayoutInfo::MOVE_START, ControlLayoutInfo::MOVE_START},
 540.504 -	{ID_CANCEL, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::MOVE_START},
 540.505 -};
 540.506 -static const int numControlLayoutInfos = sizeof(controlLayoutInfos)/sizeof(*controlLayoutInfos);
 540.507 -
 540.508 -static ControlLayoutState s_layoutState [numControlLayoutInfos];
 540.509 -static int s_windowWidth = 182, s_windowHeight = 113;
 540.510 -
 540.511 -
 540.512 -LRESULT CALLBACK ArchiveFileChooser(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 540.513 -{
 540.514 -	RECT r, r2;
 540.515 -	int dx1, dy1, dx2, dy2;
 540.516 -	static std::map<int,int> s_listToItemsMap;
 540.517 -
 540.518 -	switch(uMsg)
 540.519 -	{
 540.520 -		case WM_INITDIALOG:
 540.521 -		{
 540.522 -			//Clear_Sound_Buffer();
 540.523 -			
 540.524 -			//if(Full_Screen)
 540.525 -			//{
 540.526 -			//	while (ShowCursor(false) >= 0);
 540.527 -			//	while (ShowCursor(true) < 0);
 540.528 -			//}
 540.529 -
 540.530 -			for(int i = 0; i < numControlLayoutInfos; i++)
 540.531 -				s_layoutState[i].valid = false;
 540.532 -
 540.533 -			GetWindowRect(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), &r);
 540.534 -			dx1 = (r.right - r.left) / 2;
 540.535 -			dy1 = (r.bottom - r.top) / 2;
 540.536 -
 540.537 -			GetWindowRect(hDlg, &r2);
 540.538 -			dx2 = (r2.right - r2.left) / 2;
 540.539 -			dy2 = (r2.bottom - r2.top) / 2;
 540.540 -
 540.541 -			//SetWindowPos(hDlg, NULL, max(0, r.left + (dx1 - dx2)), max(0, r.top + (dy1 - dy2)), NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 540.542 -			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 540.543 -
 540.544 -			ArchiveFileChooserInfo& info = *(ArchiveFileChooserInfo*)lParam;
 540.545 -			std::vector<ArchiveFileChooserInfo::FileInfo>& files = info.files;
 540.546 -			ArchiveFile& archive = info.archive;
 540.547 -
 540.548 -			std::string title = "Choose File in ";
 540.549 -			title += archive.GetArchiveTypeName();
 540.550 -			title += " Archive";
 540.551 -			SetWindowText(hDlg, title.c_str());
 540.552 -
 540.553 -			// populate list
 540.554 -			for(size_t i = 0; i < files.size(); i++)
 540.555 -			{
 540.556 -				int listIndex = SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, (WPARAM) 0, (LONG) (LPTSTR) files[i].name.c_str());
 540.557 -				s_listToItemsMap[listIndex] = files[i].itemIndex;
 540.558 -			}
 540.559 -
 540.560 -			SendDlgItemMessage(hDlg, IDC_LIST1, LB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
 540.561 -
 540.562 -			{
 540.563 -				RECT r3;
 540.564 -				GetClientRect(hDlg, &r3);
 540.565 -				s_windowWidth = r3.right - r3.left;
 540.566 -				s_windowHeight = r3.bottom - r3.top;
 540.567 -			}
 540.568 -
 540.569 -			return true;
 540.570 -		}	break;
 540.571 -
 540.572 -		case WM_SIZING:
 540.573 -		{
 540.574 -			// enforce a minimum window size
 540.575 -
 540.576 -			LPRECT r = (LPRECT) lParam;
 540.577 -			int minimumWidth = 281;
 540.578 -			int minimumHeight = 117;
 540.579 -			if(r->right - r->left < minimumWidth)
 540.580 -				if(wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT)
 540.581 -					r->left = r->right - minimumWidth;
 540.582 -				else
 540.583 -					r->right = r->left + minimumWidth;
 540.584 -			if(r->bottom - r->top < minimumHeight)
 540.585 -				if(wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT)
 540.586 -					r->top = r->bottom - minimumHeight;
 540.587 -				else
 540.588 -					r->bottom = r->top + minimumHeight;
 540.589 -			return TRUE;
 540.590 -		}
 540.591 -
 540.592 -		case WM_SIZE:
 540.593 -		{
 540.594 -			// resize or move controls in the window as necessary when the window is resized
 540.595 -
 540.596 -			int prevDlgWidth = s_windowWidth;
 540.597 -			int prevDlgHeight = s_windowHeight;
 540.598 -
 540.599 -			int dlgWidth = LOWORD(lParam);
 540.600 -			int dlgHeight = HIWORD(lParam);
 540.601 -
 540.602 -			int deltaWidth = dlgWidth - prevDlgWidth;
 540.603 -			int deltaHeight = dlgHeight - prevDlgHeight;
 540.604 -
 540.605 -			for(int i = 0; i < numControlLayoutInfos; i++)
 540.606 -			{
 540.607 -				ControlLayoutInfo layoutInfo = controlLayoutInfos[i];
 540.608 -				ControlLayoutState& layoutState = s_layoutState[i];
 540.609 -
 540.610 -				HWND hCtrl = GetDlgItem(hDlg,layoutInfo.controlID);
 540.611 -
 540.612 -				int x,y,width,height;
 540.613 -				if(layoutState.valid)
 540.614 -				{
 540.615 -					x = layoutState.x;
 540.616 -					y = layoutState.y;
 540.617 -					width = layoutState.width;
 540.618 -					height = layoutState.height;
 540.619 -				}
 540.620 -				else
 540.621 -				{
 540.622 -					RECT r;
 540.623 -					GetWindowRect(hCtrl, &r);
 540.624 -					POINT p = {r.left, r.top};
 540.625 -					ScreenToClient(hDlg, &p);
 540.626 -					x = p.x;
 540.627 -					y = p.y;
 540.628 -					width = r.right - r.left;
 540.629 -					height = r.bottom - r.top;
 540.630 -				}
 540.631 -
 540.632 -				switch(layoutInfo.horizontalLayout)
 540.633 -				{
 540.634 -					case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break;
 540.635 -					case ControlLayoutInfo::MOVE_START: x += deltaWidth; break;
 540.636 -					default: break;
 540.637 -				}
 540.638 -				switch(layoutInfo.verticalLayout)
 540.639 -				{
 540.640 -					case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break;
 540.641 -					case ControlLayoutInfo::MOVE_START: y += deltaHeight; break;
 540.642 -					default: break;
 540.643 -				}
 540.644 -
 540.645 -				SetWindowPos(hCtrl, 0, x,y, width,height, 0);
 540.646 -
 540.647 -				layoutState.x = x;
 540.648 -				layoutState.y = y;
 540.649 -				layoutState.width = width;
 540.650 -				layoutState.height = height;
 540.651 -				layoutState.valid = true;
 540.652 -			}
 540.653 -
 540.654 -			s_windowWidth = dlgWidth;
 540.655 -			s_windowHeight = dlgHeight;
 540.656 -
 540.657 -			RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
 540.658 -		}
 540.659 -		break;
 540.660 -
 540.661 -		case WM_COMMAND:
 540.662 -			switch(LOWORD(wParam))
 540.663 -			{
 540.664 -				case IDC_LIST1:
 540.665 -					if(HIWORD(wParam) == LBN_DBLCLK)
 540.666 -					{
 540.667 -						POINT pos;
 540.668 -						GetCursorPos(&pos);
 540.669 -						int clickedItem = LBItemFromPt(GetDlgItem(hDlg, IDC_LIST1), pos, FALSE);
 540.670 -						if(clickedItem != -1)
 540.671 -						{
 540.672 -							SendMessage(hDlg, WM_COMMAND, IDOK, 0);
 540.673 -						}
 540.674 -					}
 540.675 -					return TRUE;
 540.676 -
 540.677 -				case IDOK:
 540.678 -				{	
 540.679 -					int listIndex = SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
 540.680 -					s_archiveFileChooserResult = s_listToItemsMap[listIndex];
 540.681 -					s_listToItemsMap.clear();
 540.682 -					//if(Full_Screen)
 540.683 -					//{
 540.684 -					//	while (ShowCursor(true) < 0);
 540.685 -					//	while (ShowCursor(false) >= 0);
 540.686 -					//}
 540.687 -					EndDialog(hDlg, false);
 540.688 -				}	return TRUE;
 540.689 -
 540.690 -				case ID_CANCEL:
 540.691 -				case IDCANCEL:
 540.692 -					s_archiveFileChooserResult = -1;
 540.693 -					s_listToItemsMap.clear();
 540.694 -					//if(Full_Screen)
 540.695 -					//{
 540.696 -					//	while (ShowCursor(true) < 0);
 540.697 -					//	while (ShowCursor(false) >= 0);
 540.698 -					//}
 540.699 -					EndDialog(hDlg, false);
 540.700 -					return TRUE;
 540.701 -			}
 540.702 -
 540.703 -		case WM_CLOSE:
 540.704 -			s_archiveFileChooserResult = -1;
 540.705 -			s_listToItemsMap.clear();
 540.706 -			//if(Full_Screen)
 540.707 -			//{
 540.708 -			//	while (ShowCursor(true) < 0);
 540.709 -			//	while (ShowCursor(false) >= 0);
 540.710 -			//}
 540.711 -			EndDialog(hDlg, false);
 540.712 -			return TRUE;
 540.713 -	}
 540.714 -
 540.715 -	return false;
 540.716 -}
   541.1 --- a/src/win32/7zip/OpenArchive.h	Sat Mar 03 10:54:39 2012 -0600
   541.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   541.3 @@ -1,43 +0,0 @@
   541.4 -// for retrieving files from archives and/or managing temporary files
   541.5 -
   541.6 -#ifndef OPENARCHIVE_HEADER
   541.7 -#define OPENARCHIVE_HEADER
   541.8 -
   541.9 -#include "7zip.h"
  541.10 -
  541.11 -// ObtainFile()
  541.12 -// this is the main, high-level function for opening possibly-compressed files.
  541.13 -// you don't need to check whether the file is compressed beforehand,
  541.14 -// this function will figure that out and work correctly either way.
  541.15 -// it also does the work of bringing up a within-archive file selector dialog if necessary,
  541.16 -// which even allows navigating to a file within an archive that's within the archive.
  541.17 -// the output PhysicalName is the filename of an uncompressed file
  541.18 -// for you to load with fopen or whatever,
  541.19 -// unless the function fails (or is cancelled) in which case it will return false.
  541.20 -// example input Name:          "C:\games.zip"
  541.21 -// example output LogicalName:  "C:\games.zip|Metroid.gba"
  541.22 -// example output PhysicalName: "C:\Documents and Settings\User\Local Settings\Temp\VBA\rom7A37.gba"
  541.23 -// assumes the three name arguments are distinct character buffers with exactly 2048 bytes each
  541.24 -bool ObtainFile(const char* Name, char *const & LogicalName, char *const & PhysicalName, const char* category=NULL, const char** ignoreExtensions=NULL, int numIgnoreExtensions=0);
  541.25 -
  541.26 -// ReleaseTempFileCategory()
  541.27 -// this is for deleting the temporary files that ObtainFile() can create.
  541.28 -// using it is optional because they will auto-delete on proper shutdown of the program,
  541.29 -// but it's nice to be able to clean up the files as early as possible.
  541.30 -// pass in the same "category" string you passed into ObtainFile(),
  541.31 -// and this will delete all files of that category.
  541.32 -// you can optionally specify one filename to not delete even if its category matches.
  541.33 -// note that any still-open files cannot be deleted yet and will be skipped.
  541.34 -void ReleaseTempFileCategory(const char* category, const char* exceptionFilename=NULL);
  541.35 -
  541.36 -// sets the parent window of subsequent archive selector dialogs
  541.37 -// NULL resets this to the default (main VBA emulator window)
  541.38 -void SetArchiveParentHWND(void* hwnd=NULL);
  541.39 -
  541.40 -// the rest of these are more internal utility functions,
  541.41 -// but they could be generally useful outside of that
  541.42 -const char* GetTempFile(const char* category=NULL, const char* extension=NULL); // creates a temp file and returns a path to it.  extension if any should include the '.'
  541.43 -void ReleaseTempFile(const char* filename); // deletes a particular temporary file, by filename
  541.44 -int ChooseItemFromArchive(ArchiveFile& archive, bool autoChooseIfOnly1=true, const char** ignoreExtensions=0, int numIgnoreExtensions=0); // gets an index to a file within an already-open archive, using the file chooser if there's more than one choice
  541.45 -
  541.46 -#endif
   542.1 --- a/src/win32/AVIWrite.cpp	Sat Mar 03 10:54:39 2012 -0600
   542.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   542.3 @@ -1,281 +0,0 @@
   542.4 -#include "stdafx.h"
   542.5 -#include <cstdio>
   542.6 -#include <cassert>
   542.7 -
   542.8 -#include "AVIWrite.h"
   542.9 -#include "../common/System.h"
  542.10 -
  542.11 -AVIWrite::AVIWrite()
  542.12 -{
  542.13 -	m_failed = false;
  542.14 -	m_file   = NULL;
  542.15 -	m_stream = NULL;
  542.16 -	m_streamCompressed = NULL;
  542.17 -	m_streamSound      = NULL;
  542.18 -	m_videoFrames      = 0;
  542.19 -	m_samplesSound     = 0;
  542.20 -	m_videoFramesTotal = 0;
  542.21 -	m_samplesSoundTotal= 0;
  542.22 -	m_totalBytes       = 0;
  542.23 -	m_segmentNumber    = 0;
  542.24 -	m_usePrevOptions   = false;
  542.25 -	m_pauseRecording   = false;
  542.26 -
  542.27 -	AVIFileInit();
  542.28 -}
  542.29 -
  542.30 -void AVIWrite::CleanUp()
  542.31 -{
  542.32 -	if (m_streamSound)
  542.33 -	{
  542.34 -		AVIStreamClose(m_streamSound);
  542.35 -		m_streamSound = NULL;
  542.36 -	}
  542.37 -	if (m_streamCompressed)
  542.38 -	{
  542.39 -		AVIStreamClose(m_streamCompressed);
  542.40 -		m_streamCompressed = NULL;
  542.41 -	}
  542.42 -	if (m_stream)
  542.43 -	{
  542.44 -		AVIStreamClose(m_stream);
  542.45 -		m_stream = NULL;
  542.46 -	}
  542.47 -	if (m_file)
  542.48 -	{
  542.49 -		AVIFileClose(m_file);
  542.50 -		m_file = NULL;
  542.51 -	}
  542.52 -}
  542.53 -
  542.54 -AVIWrite::~AVIWrite()
  542.55 -{
  542.56 -	CleanUp();
  542.57 -	AVIFileExit();
  542.58 -}
  542.59 -
  542.60 -void AVIWrite::SetVideoFormat(BITMAPINFOHEADER *bh)
  542.61 -{
  542.62 -	// force size to 0x28 to avoid extra fields
  542.63 -	memcpy(&m_bitmap, bh, 0x28);
  542.64 -}
  542.65 -
  542.66 -void AVIWrite::SetSoundFormat(WAVEFORMATEX *format)
  542.67 -{
  542.68 -	memcpy(&m_soundFormat, format, sizeof(WAVEFORMATEX));
  542.69 -	ZeroMemory(&m_soundHeader, sizeof(AVISTREAMINFO));
  542.70 -	// setup the sound stream header
  542.71 -	m_soundHeader.fccType         = streamtypeAUDIO;
  542.72 -	m_soundHeader.dwQuality       = (DWORD)-1;
  542.73 -	m_soundHeader.dwScale         = format->nBlockAlign;
  542.74 -	m_soundHeader.dwInitialFrames = 1;
  542.75 -	m_soundHeader.dwRate       = format->nAvgBytesPerSec;
  542.76 -	m_soundHeader.dwSampleSize = format->nBlockAlign;
  542.77 -
  542.78 -	// create the sound stream
  542.79 -	if (FAILED(AVIFileCreateStream(m_file, &m_streamSound, &m_soundHeader)))
  542.80 -	{
  542.81 -		m_failed = true;
  542.82 -		return;
  542.83 -	}
  542.84 -
  542.85 -	// setup the sound stream format
  542.86 -	if (FAILED(AVIStreamSetFormat(m_streamSound, 0, (void *)&m_soundFormat,
  542.87 -	                              sizeof(WAVEFORMATEX))))
  542.88 -	{
  542.89 -		m_failed = true;
  542.90 -		return;
  542.91 -	}
  542.92 -}
  542.93 -
  542.94 -bool AVIWrite::Open(const char *filename)
  542.95 -{
  542.96 -	// this is only here because AVIFileOpen doesn't seem to do it for us
  542.97 -	FILE*fd = fopen(filename, "wb");
  542.98 -	if (!fd)
  542.99 -	{
 542.100 -		systemMessage(0, "AVI recording failed: file is read-only or already in use.");
 542.101 -		m_failed = true;
 542.102 -		return false;
 542.103 -	}
 542.104 -	fclose(fd);
 542.105 -
 542.106 -	// create the AVI file
 542.107 -	if (FAILED(AVIFileOpen(&m_file,
 542.108 -	                       filename,
 542.109 -	                       OF_WRITE | OF_CREATE,
 542.110 -	                       NULL)))
 542.111 -	{
 542.112 -		m_failed = true;
 542.113 -		return false;
 542.114 -	}
 542.115 -	// setup the video stream information
 542.116 -	ZeroMemory(&m_header, sizeof(AVISTREAMINFO));
 542.117 -	m_header.fccType = streamtypeVIDEO;
 542.118 -	m_header.dwScale = 1;
 542.119 -	m_header.dwRate  = m_fps;
 542.120 -	m_header.dwSuggestedBufferSize = m_bitmap.biSizeImage;
 542.121 -
 542.122 -	// create the video stream
 542.123 -	if (FAILED(AVIFileCreateStream(m_file,
 542.124 -	                               &m_stream,
 542.125 -	                               &m_header)))
 542.126 -	{
 542.127 -		m_failed = true;
 542.128 -		return false;
 542.129 -	}
 542.130 -
 542.131 -	if (!m_usePrevOptions)
 542.132 -	{
 542.133 -		ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS));
 542.134 -		m_arrayOptions[0] = &m_options;
 542.135 -
 542.136 -		// call the dialog to setup the compress options to be used
 542.137 -		if (!AVISaveOptions(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), 0, 1, &m_stream, m_arrayOptions))
 542.138 -		{
 542.139 -			m_failed = true;
 542.140 -			return false;
 542.141 -		}
 542.142 -	}
 542.143 -
 542.144 -	// create the compressed stream
 542.145 -	if (FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL)))
 542.146 -	{
 542.147 -		m_failed = true;
 542.148 -		return false;
 542.149 -	}
 542.150 -
 542.151 -	// setup the video stream format
 542.152 -	if (FAILED(AVIStreamSetFormat(m_streamCompressed, 0,
 542.153 -	                              &m_bitmap,
 542.154 -	                              m_bitmap.biSize +
 542.155 -	                              m_bitmap.biClrUsed * sizeof(RGBQUAD))))
 542.156 -	{
 542.157 -		m_failed = true;
 542.158 -		return false;
 542.159 -	}
 542.160 -
 542.161 -	m_videoFrames  = 0;
 542.162 -	m_samplesSound = 0;
 542.163 -	m_totalBytes   = 0;
 542.164 -	if (!m_usePrevOptions) {
 542.165 -		m_videoFramesTotal  = 0;
 542.166 -		m_samplesSoundTotal = 0;
 542.167 -	}
 542.168 -
 542.169 -	strncpy(m_aviFileName, filename, MAX_PATH);
 542.170 -	strncpy(m_aviBaseName, filename, MAX_PATH);
 542.171 -	m_aviFileName[MAX_PATH - 1] = '\0';
 542.172 -	m_aviBaseName[MAX_PATH - 1] = '\0';
 542.173 -	char *dot = strrchr(m_aviBaseName, '.');
 542.174 -	if (dot && dot > strrchr(m_aviBaseName, '/') && dot > strrchr(m_aviBaseName, '\\'))
 542.175 -	{
 542.176 -		strcpy(m_aviExtension, dot);
 542.177 -		dot[0] = '\0';
 542.178 -	}
 542.179 -
 542.180 -	return true;
 542.181 -}
 542.182 -
 542.183 -bool AVIWrite::AddSound(const u8 *sound, int len)
 542.184 -{
 542.185 -	LONG byteBuffer;
 542.186 -
 542.187 -	// return if we failed somewhere already
 542.188 -	if (m_failed)
 542.189 -		return false;
 542.190 -
 542.191 -	assert(len % m_soundFormat.nBlockAlign == 0);
 542.192 -	int samples = len / m_soundFormat.nBlockAlign;
 542.193 -
 542.194 -	if (FAILED(AVIStreamWrite(m_streamSound,
 542.195 -	                          m_samplesSound,
 542.196 -	                          samples,
 542.197 -	                          (LPVOID)sound,
 542.198 -	                          len,
 542.199 -	                          0,
 542.200 -	                          NULL,
 542.201 -	                          &byteBuffer)))
 542.202 -	{
 542.203 -		m_failed = true;
 542.204 -		return false;
 542.205 -	}
 542.206 -	m_samplesSound += samples;
 542.207 -	m_samplesSoundTotal += samples;
 542.208 -	m_totalBytes   += byteBuffer;
 542.209 -	return true;
 542.210 -}
 542.211 -
 542.212 -bool AVIWrite::NextSegment()
 542.213 -{
 542.214 -	char avi_fname[MAX_PATH];
 542.215 -	strcpy(avi_fname, m_aviBaseName);
 542.216 -	char avi_fname_temp[MAX_PATH];
 542.217 -	sprintf(avi_fname_temp, "%s_part%d%s", avi_fname, m_segmentNumber+2, m_aviExtension);
 542.218 -	m_segmentNumber++;
 542.219 -
 542.220 -	CleanUp();
 542.221 -
 542.222 -	m_usePrevOptions = true;
 542.223 -	bool ret = Open(avi_fname_temp);
 542.224 -	m_usePrevOptions = false;
 542.225 -	strcpy(m_aviBaseName, avi_fname);
 542.226 -
 542.227 -	return ret;
 542.228 -}
 542.229 -
 542.230 -bool AVIWrite::AddFrame(const u8 *bmp)
 542.231 -{
 542.232 -	LONG byteBuffer;
 542.233 -
 542.234 -	if (m_failed)
 542.235 -		return false;
 542.236 -
 542.237 -	// write the frame to the video stream
 542.238 -	if (FAILED(AVIStreamWrite(m_streamCompressed,
 542.239 -	                          m_videoFrames,
 542.240 -	                          1,
 542.241 -	                          (LPVOID)bmp,
 542.242 -	                          m_bitmap.biSizeImage,
 542.243 -	                          AVIIF_KEYFRAME,
 542.244 -	                          NULL,
 542.245 -	                          &byteBuffer)))
 542.246 -	{
 542.247 -		m_failed = true;
 542.248 -		return false;
 542.249 -	}
 542.250 -	m_videoFrames++;
 542.251 -	m_videoFramesTotal++;
 542.252 -	m_totalBytes += byteBuffer;
 542.253 -
 542.254 -	// segment / split AVI when it's almost 2 GB (2000MB, to be precise)
 542.255 -	if (!(m_videoFrames % 60) && m_totalBytes > 2097152000)
 542.256 -		return NextSegment();
 542.257 -	else
 542.258 -		return true;
 542.259 -}
 542.260 -
 542.261 -bool AVIWrite::IsSoundAdded()
 542.262 -{
 542.263 -	return m_streamSound != NULL;
 542.264 -}
 542.265 -
 542.266 -void AVIWrite::SetFPS(int f)
 542.267 -{
 542.268 -	m_fps = f;
 542.269 -}
 542.270 -
 542.271 -int AVIWrite::videoFrames()
 542.272 -{
 542.273 -	return m_videoFramesTotal;
 542.274 -}
 542.275 -
 542.276 -void AVIWrite::Pause(bool pause)
 542.277 -{
 542.278 -	m_pauseRecording = pause;
 542.279 -}
 542.280 -
 542.281 -bool AVIWrite::IsPaused()
 542.282 -{
 542.283 -	return m_pauseRecording;
 542.284 -}
 542.285 \ No newline at end of file
   543.1 --- a/src/win32/AVIWrite.h	Sat Mar 03 10:54:39 2012 -0600
   543.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   543.3 @@ -1,54 +0,0 @@
   543.4 -#ifndef VBA_WIN32_AVIWRITE_H
   543.5 -#define VBA_WIN32_AVIWRITE_H
   543.6 -
   543.7 -#if _MSC_VER > 1000
   543.8 -#pragma once
   543.9 -#endif // _MSC_VER > 1000
  543.10 -
  543.11 -#include <vfw.h>
  543.12 -
  543.13 -class AVIWrite {
  543.14 - public:
  543.15 -  AVIWrite();
  543.16 -  virtual ~AVIWrite();
  543.17 -
  543.18 -  bool Open(const char *filename);
  543.19 -  virtual bool AddFrame(const u8 *bmp);
  543.20 -  void SetFPS(int fps);
  543.21 -  void SetVideoFormat(BITMAPINFOHEADER *);
  543.22 -  bool IsSoundAdded();
  543.23 -  void SetSoundFormat(WAVEFORMATEX *);
  543.24 -  bool AddSound(const u8 *sound, int len);
  543.25 -  int videoFrames();
  543.26 -  void Pause(bool pause);
  543.27 -  bool IsPaused();
  543.28 -
  543.29 - private:
  543.30 -  int m_fps;
  543.31 -  WAVEFORMATEX m_soundFormat;
  543.32 -  BITMAPINFOHEADER m_bitmap;
  543.33 -  AVISTREAMINFO m_header;
  543.34 -  AVISTREAMINFO m_soundHeader;
  543.35 -  PAVIFILE m_file;
  543.36 -  PAVISTREAM m_stream;
  543.37 -  PAVISTREAM m_streamCompressed;
  543.38 -  PAVISTREAM m_streamSound;
  543.39 -  AVICOMPRESSOPTIONS m_options;
  543.40 -  AVICOMPRESSOPTIONS *m_arrayOptions[1];
  543.41 -  int m_videoFrames;
  543.42 -  int m_samplesSound;
  543.43 -  int m_videoFramesTotal;
  543.44 -  int m_samplesSoundTotal;
  543.45 -  LONG m_totalBytes;
  543.46 -  bool m_failed;
  543.47 -  int m_segmentNumber;
  543.48 -  bool m_usePrevOptions;
  543.49 -  bool m_pauseRecording;
  543.50 -  char m_aviFileName[MAX_PATH];
  543.51 -  char m_aviBaseName[MAX_PATH];
  543.52 -  char m_aviExtension[MAX_PATH];
  543.53 -  void CleanUp();
  543.54 -  bool NextSegment();
  543.55 -};
  543.56 -
  543.57 -#endif // VBA_WIN32_AVIWRITE_H
   544.1 --- a/src/win32/AboutDialog.cpp	Sat Mar 03 10:54:39 2012 -0600
   544.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   544.3 @@ -1,60 +0,0 @@
   544.4 -// AboutDialog.cpp : implementation file
   544.5 -//
   544.6 -
   544.7 -#include "stdafx.h"
   544.8 -#include "resource.h"
   544.9 -#include "AboutDialog.h"
  544.10 -
  544.11 -#include "../version.h"
  544.12 -
  544.13 -/////////////////////////////////////////////////////////////////////////////
  544.14 -// AboutDialog dialog
  544.15 -
  544.16 -AboutDialog::AboutDialog(CWnd*pParent /*=NULL*/)
  544.17 -	: CDialog(AboutDialog::IDD, pParent)
  544.18 -{
  544.19 -	//{{AFX_DATA_INIT(AboutDialog)
  544.20 -	m_version = _T(VBA_VERSION_STRING);
  544.21 -	//}}AFX_DATA_INIT
  544.22 -}
  544.23 -
  544.24 -void AboutDialog::DoDataExchange(CDataExchange*pDX)
  544.25 -{
  544.26 -	CDialog::DoDataExchange(pDX);
  544.27 -	//{{AFX_DATA_MAP(AboutDialog)
  544.28 -	DDX_Text(pDX, IDC_VERSION, m_version);
  544.29 -	DDX_Control(pDX, IDC_URL, m_link);
  544.30 -	//}}AFX_DATA_MAP
  544.31 -}
  544.32 -
  544.33 -BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
  544.34 -//{{AFX_MSG_MAP(AboutDialog)
  544.35 -//}}AFX_MSG_MAP
  544.36 -END_MESSAGE_MAP()
  544.37 -
  544.38 -/////////////////////////////////////////////////////////////////////////////
  544.39 -// AboutDialog message handlers
  544.40 -
  544.41 -BOOL AboutDialog::OnInitDialog()
  544.42 -{
  544.43 -	CDialog::OnInitDialog();
  544.44 -
  544.45 -	CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
  544.46 -	if (p)
  544.47 -	{
  544.48 -		m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
  544.49 -	}
  544.50 -
  544.51 -	m_link.SetWindowText(VBA_RR_SITE);
  544.52 -
  544.53 -	return TRUE; // return TRUE unless you set the focus to a control
  544.54 -	// EXCEPTION: OCX Property Pages should return FALSE
  544.55 -}
  544.56 -
  544.57 -void AboutDialog::OnOK()
  544.58 -{
  544.59 -	// TODO: Add extra validation here
  544.60 -
  544.61 -	CDialog::OnOK();
  544.62 -}
  544.63 -
   545.1 --- a/src/win32/AboutDialog.h	Sat Mar 03 10:54:39 2012 -0600
   545.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   545.3 @@ -1,52 +0,0 @@
   545.4 -#if !defined(AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_)
   545.5 -#define AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_
   545.6 -
   545.7 -#if _MSC_VER > 1000
   545.8 -#pragma once
   545.9 -#endif // _MSC_VER > 1000
  545.10 -
  545.11 -// -*- C++ -*-
  545.12 -// AboutDialog.h : header file
  545.13 -//
  545.14 -
  545.15 -#include "Hyperlink.h"
  545.16 -
  545.17 -/////////////////////////////////////////////////////////////////////////////
  545.18 -// AboutDialog dialog
  545.19 -
  545.20 -class AboutDialog : public CDialog
  545.21 -{
  545.22 -	Hyperlink m_link;
  545.23 -	Hyperlink m_translator;
  545.24 -	// Construction
  545.25 -public:
  545.26 -	AboutDialog(CWnd*pParent = NULL);  // standard constructor
  545.27 -
  545.28 -	// Dialog Data
  545.29 -	//{{AFX_DATA(AboutDialog)
  545.30 -	enum { IDD = IDD_ABOUT };
  545.31 -	CString m_version;
  545.32 -	//}}AFX_DATA
  545.33 -
  545.34 -	// Overrides
  545.35 -	// ClassWizard generated virtual function overrides
  545.36 -	//{{AFX_VIRTUAL(AboutDialog)
  545.37 -protected:
  545.38 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  545.39 -	//}}AFX_VIRTUAL
  545.40 -
  545.41 -	// Implementation
  545.42 -protected:
  545.43 -	// Generated message map functions
  545.44 -	//{{AFX_MSG(AboutDialog)
  545.45 -	virtual BOOL OnInitDialog();
  545.46 -	virtual void OnOK();
  545.47 -	//}}AFX_MSG
  545.48 -
  545.49 -	DECLARE_MESSAGE_MAP()
  545.50 -};
  545.51 -
  545.52 -//{{AFX_INSERT_LOCATION}}
  545.53 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  545.54 -
  545.55 -#endif // !defined(AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_)
   546.1 --- a/src/win32/AccelEditor.cpp	Sat Mar 03 10:54:39 2012 -0600
   546.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   546.3 @@ -1,659 +0,0 @@
   546.4 -// AccelEditor.cpp : implementation file
   546.5 -//
   546.6 -
   546.7 -#include "stdafx.h"
   546.8 -#include "resource.h"
   546.9 -#include "AccelEditor.h"
  546.10 -#include "CmdAccelOb.h"
  546.11 -#include "VBA.h"
  546.12 -
  546.13 -/////////////////////////////////////////////////////////////////////////////
  546.14 -// AccelEditor dialog
  546.15 -
  546.16 -AccelEditor::AccelEditor(CWnd *pParent, CMenu *pMenu, CAcceleratorManager *pExtMgr)
  546.17 -	: ResizeDlg(AccelEditor::IDD, pParent), m_pMenuSrc(pMenu), m_pExtMgr(pExtMgr)
  546.18 -{
  546.19 -	//{{AFX_DATA_INIT(AccelEditor)
  546.20 -	// NOTE: the ClassWizard will add member initialization here
  546.21 -	//}}AFX_DATA_INIT
  546.22 -}
  546.23 -
  546.24 -BOOL AccelEditor::IsModified() const
  546.25 -{
  546.26 -	return m_modified;
  546.27 -}
  546.28 -
  546.29 -const CAcceleratorManager &AccelEditor::GetResultMangager() const
  546.30 -{
  546.31 -	return m_result;
  546.32 -}
  546.33 -
  546.34 -void AccelEditor::DoDataExchange(CDataExchange *pDX)
  546.35 -{
  546.36 -	CDialog::DoDataExchange(pDX);
  546.37 -	//{{AFX_DATA_MAP(AccelEditor)
  546.38 -	DDX_Control(pDX, IDC_CURRENTS, m_currents);
  546.39 -	DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
  546.40 -	DDX_Control(pDX, IDC_COMMANDS, m_commands);
  546.41 -	DDX_Control(pDX, IDC_EDIT_KEY, m_key);
  546.42 -	DDX_Control(pDX, IDC_ACCELEDIT_AUTOTIMEOUT, m_timeout);
  546.43 -	DDX_Control(pDX, IDC_ACCELEDIT_PROGRESSBAR, m_progress);
  546.44 -	//}}AFX_DATA_MAP
  546.45 -}
  546.46 -
  546.47 -BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
  546.48 -//{{AFX_MSG_MAP(AccelEditor)
  546.49 -ON_BN_CLICKED(ID_OK, &AccelEditor::OnOk)
  546.50 -ON_BN_CLICKED(ID_CANCEL, &AccelEditor::OnCancel)
  546.51 -ON_BN_CLICKED(IDC_ACCELEDIT_APPLY, &AccelEditor::OnApply)
  546.52 -ON_BN_CLICKED(IDC_RESET, &AccelEditor::OnReset)
  546.53 -ON_BN_CLICKED(IDC_ASSIGN, &AccelEditor::OnAssign)
  546.54 -ON_BN_CLICKED(IDC_REMOVE, &AccelEditor::OnRemove)
  546.55 -ON_BN_CLICKED(IDC_ACCELEDIT_REPLACE, &AccelEditor::OnReplace)
  546.56 -ON_CONTROL(EN_CHANGE, IDC_EDIT_KEY, &AccelEditor::OnKeyboardEditChange)
  546.57 -ON_CONTROL(EN_KILLFOCUS, IDC_EDIT_KEY, &AccelEditor::OnKeyboardEditKillfocus)
  546.58 -ON_CONTROL(EN_SETFOCUS, IDC_ACCELEDIT_AUTOTIMEOUT, &AccelEditor::OnTimeoutEditSetfocus)
  546.59 -ON_CONTROL(EN_KILLFOCUS, IDC_ACCELEDIT_AUTOTIMEOUT, &AccelEditor::OnTimeoutEditKillfocus)
  546.60 -ON_NOTIFY(TVN_SELCHANGED, IDC_COMMANDS, &AccelEditor::OnTvnSelchangedCommands)
  546.61 -//ON_NOTIFY(LVN_ITEMCHANGED, IDC_CURRENTS, &AccelEditor::OnListItemChanged)
  546.62 -ON_NOTIFY(NM_DBLCLK, IDC_CURRENTS, &AccelEditor::OnListDblClick)
  546.63 -ON_NOTIFY(NM_CLICK, IDC_CURRENTS, &AccelEditor::OnListClick)
  546.64 -ON_WM_TIMER()
  546.65 -//}}AFX_MSG_MAP
  546.66 -END_MESSAGE_MAP()
  546.67 -
  546.68 -/////////////////////////////////////////////////////////////////////////////
  546.69 -// AccelEditor message handlers
  546.70 -
  546.71 -BOOL AccelEditor::OnInitDialog()
  546.72 -{
  546.73 -	CDialog::OnInitDialog();
  546.74 -
  546.75 -	DIALOG_SIZER_START(sz)
  546.76 -	DIALOG_SIZER_ENTRY(ID_OK, DS_MoveX)
  546.77 -	DIALOG_SIZER_ENTRY(ID_CANCEL, DS_MoveX)
  546.78 -	DIALOG_SIZER_ENTRY(IDC_ACCELEDIT_APPLY, DS_MoveX)
  546.79 -	DIALOG_SIZER_ENTRY(IDC_ASSIGN, DS_MoveX)
  546.80 -	DIALOG_SIZER_ENTRY(IDC_REMOVE, DS_MoveX)
  546.81 -	DIALOG_SIZER_ENTRY(IDC_ACCELEDIT_REPLACE, DS_MoveX)
  546.82 -	DIALOG_SIZER_ENTRY(IDC_COMMANDS, DS_SizeX | DS_SizeY)
  546.83 -	DIALOG_SIZER_ENTRY(IDC_CURRENTS, DS_MoveX | DS_SizeY)
  546.84 -	DIALOG_SIZER_ENTRY(IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
  546.85 -	DIALOG_SIZER_ENTRY(IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
  546.86 -	DIALOG_SIZER_ENTRY(IDC_STATIC2, DS_MoveY)
  546.87 -	DIALOG_SIZER_ENTRY(IDC_STATIC3, DS_MoveX | DS_MoveY)
  546.88 -	DIALOG_SIZER_ENTRY(IDC_STATIC4, DS_MoveX | DS_MoveY)
  546.89 -	DIALOG_SIZER_ENTRY(IDC_STATIC5, DS_MoveX | DS_MoveY)
  546.90 -	DIALOG_SIZER_ENTRY(IDC_ACCELEDIT_AUTOTIMEOUT, DS_SizeX | DS_MoveY)
  546.91 -	DIALOG_SIZER_END()
  546.92 -	SetData(sz,
  546.93 -	        TRUE,
  546.94 -	        HKEY_CURRENT_USER,
  546.95 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
  546.96 -	        NULL);
  546.97 -
  546.98 -	if (m_pExtMgr)
  546.99 -		m_result = m_mgr = *m_pExtMgr;
 546.100 -
 546.101 -	m_currents.SetExtendedStyle(LVS_EX_FULLROWSELECT);
 546.102 -	m_currents.InsertColumn(0, "Keys");
 546.103 -	m_currents.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
 546.104 -	InitCommands();
 546.105 -	m_autoMode	   = AUTO_REPLACE;
 546.106 -	m_modified	   = FALSE;
 546.107 -	m_timeoutValue = 1000;
 546.108 -	CString timeoutStr;
 546.109 -	timeoutStr.Format("%d", m_timeoutValue);
 546.110 -	m_timeout.SetWindowText(timeoutStr);
 546.111 -	m_progress.SetPos(0);
 546.112 -
 546.113 -	GetDlgItem(IDC_ACCELEDIT_APPLY)->EnableWindow(FALSE);
 546.114 -	return TRUE; // return TRUE unless you set the focus to a control
 546.115 -	             // EXCEPTION: OCX Property Pages should return FALSE
 546.116 -}
 546.117 -
 546.118 -void AccelEditor::AddCommandsFromTable()
 546.119 -{
 546.120 -	POSITION pos = m_mgr.m_mapAccelString.GetStartPosition();
 546.121 -	while (pos != NULL)
 546.122 -	{
 546.123 -		CString command;
 546.124 -		WORD	wID;
 546.125 -		m_mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
 546.126 -		int nPos = command.Find('\\');
 546.127 -
 546.128 -		if (nPos == 0)  // skip menu commands
 546.129 -		{
 546.130 -			continue;
 546.131 -		}
 546.132 -
 546.133 -		HTREEITEM newItem = TVI_ROOT;
 546.134 -#if 0
 546.135 -/*
 546.136 -        while (nPos != -1)
 546.137 -        {
 546.138 -            newItem = m_commands.InsertItem(command.Left(nPos), newItem);
 546.139 -            command.Delete(0, nPos + 1);
 546.140 -            nPos = command.Find('\\');
 546.141 -        }
 546.142 - */
 546.143 -#endif
 546.144 -		newItem = m_commands.InsertItem(command, newItem);
 546.145 -		m_commands.SetItemData(newItem, wID);
 546.146 -		m_hItems.AddTail(newItem);
 546.147 -	}
 546.148 -}
 546.149 -
 546.150 -// recursive calls
 546.151 -void AccelEditor::AddCommandsFromMenu(CMenu *pMenu, HTREEITEM hParent)
 546.152 -{
 546.153 -	UINT nIndexMax = pMenu->GetMenuItemCount();
 546.154 -	for (UINT nIndex = 0; nIndex < nIndexMax; ++nIndex)
 546.155 -	{
 546.156 -		UINT nID = pMenu->GetMenuItemID(nIndex);
 546.157 -		if (nID == 0)
 546.158 -			continue;  // menu separator or invalid cmd - ignore it
 546.159 -
 546.160 -		if (nID == (UINT)-1)
 546.161 -		{
 546.162 -			// possibly a submenu
 546.163 -			CMenu *pSubMenu = pMenu->GetSubMenu(nIndex);
 546.164 -			if (pSubMenu != NULL)
 546.165 -			{
 546.166 -				CString tempStr;
 546.167 -				pMenu->GetMenuString(nIndex, tempStr, MF_BYPOSITION);
 546.168 -				tempStr.Remove('&');
 546.169 -				HTREEITEM newItem = m_commands.InsertItem(tempStr, hParent);
 546.170 -				AddCommandsFromMenu(pSubMenu, newItem);
 546.171 -			}
 546.172 -		}
 546.173 -		else
 546.174 -		{
 546.175 -			// normal menu item
 546.176 -			// generate the strings
 546.177 -			CString command;
 546.178 -			pMenu->GetMenuString(nIndex, command, MF_BYPOSITION);
 546.179 -			int nPos = command.ReverseFind('\t');
 546.180 -			if (nPos != -1)
 546.181 -			{
 546.182 -				command.Delete(nPos, command.GetLength() - nPos);
 546.183 -			}
 546.184 -			command.Remove('&');
 546.185 -			HTREEITEM newItem = m_commands.InsertItem(command, hParent);
 546.186 -			m_commands.SetItemData(newItem, nID);
 546.187 -			m_hItems.AddTail(newItem);
 546.188 -		}
 546.189 -	}
 546.190 -}
 546.191 -
 546.192 -void AccelEditor::InitCommands()
 546.193 -{
 546.194 -	m_commands.DeleteAllItems();
 546.195 -	m_hItems.RemoveAll();
 546.196 -	m_alreadyAffected.SetWindowText("");
 546.197 -
 546.198 -	AddCommandsFromMenu(m_pMenuSrc, TVI_ROOT);
 546.199 -	AddCommandsFromTable();
 546.200 -}
 546.201 -
 546.202 -BOOL AccelEditor::PreTranslateMessage(MSG *pMsg)
 546.203 -{
 546.204 -	CWnd *pFocus = GetFocus();
 546.205 -	if (pFocus == &m_currents)
 546.206 -	{
 546.207 -		if (pMsg->message == WM_KEYDOWN)
 546.208 -		{
 546.209 -			switch (pMsg->wParam)
 546.210 -			{
 546.211 -			case VK_ESCAPE:
 546.212 -				m_currents.SetItemState(-1, 0, LVIS_SELECTED);
 546.213 -				CheckListSelections();
 546.214 -				break;
 546.215 -			case VK_RETURN:
 546.216 -			case VK_INSERT:
 546.217 -				// kludge to workaround CKeyboardEdit::PreTranslateMessage()
 546.218 -				break;
 546.219 -			case VK_DELETE:
 546.220 -			case VK_BACK:
 546.221 -				OnRemove();
 546.222 -				break;
 546.223 -			case VK_F6:
 546.224 -			case VK_LEFT:
 546.225 -				m_commands.SetFocus();
 546.226 -				break;
 546.227 -			case VK_RIGHT:
 546.228 -				GetDlgItem(ID_OK)->SetFocus();
 546.229 -			default:
 546.230 -				return ResizeDlg::PreTranslateMessage(pMsg);
 546.231 -			}
 546.232 -			return TRUE;
 546.233 -		}
 546.234 -		else if (pMsg->message == WM_KEYUP)	// kludge to workaround CKeyboardEdit::PreTranslateMessage()
 546.235 -		{
 546.236 -			switch (pMsg->wParam)
 546.237 -			{
 546.238 -			case VK_RETURN:
 546.239 -				OnEdit();
 546.240 -				break;
 546.241 -			case VK_INSERT:
 546.242 -				OnNew();
 546.243 -				break;
 546.244 -			default:
 546.245 -				return ResizeDlg::PreTranslateMessage(pMsg);
 546.246 -			}
 546.247 -			return TRUE;
 546.248 -		}
 546.249 -	}
 546.250 -	else if (pFocus == &m_commands)
 546.251 -	{
 546.252 -		if (pMsg->message == WM_KEYDOWN)
 546.253 -		{
 546.254 -			switch (pMsg->wParam)
 546.255 -			{
 546.256 -			case VK_F6:
 546.257 -				m_currents.SetFocus();
 546.258 -				break;
 546.259 -			case VK_RIGHT:
 546.260 -				if (!m_commands.ItemHasChildren(m_commands.GetSelectedItem()))
 546.261 -				{
 546.262 -					m_currents.SetFocus();
 546.263 -					break;
 546.264 -				}
 546.265 -				// fall through
 546.266 -			default:
 546.267 -				return ResizeDlg::PreTranslateMessage(pMsg);
 546.268 -			}
 546.269 -			return TRUE;
 546.270 -		}
 546.271 -	}
 546.272 -
 546.273 -	return ResizeDlg::PreTranslateMessage(pMsg);
 546.274 -}
 546.275 -
 546.276 -void AccelEditor::OnOk()
 546.277 -{
 546.278 -	OnApply();
 546.279 -//	OnTimeoutEditKillfocus();
 546.280 -	EndDialog(TRUE);
 546.281 -}
 546.282 -
 546.283 -void AccelEditor::OnCancel()
 546.284 -{
 546.285 -//	OnTimeoutEditKillfocus();
 546.286 -//	EndDialog(m_modified);
 546.287 -	EndDialog(FALSE);	// this allows the caller to cancel even if the user has Apply'ed
 546.288 -}
 546.289 -
 546.290 -void AccelEditor::OnApply()
 546.291 -{
 546.292 -	m_result   = m_mgr;
 546.293 -	GetDlgItem(IDC_ACCELEDIT_APPLY)->EnableWindow(FALSE);
 546.294 -}
 546.295 -
 546.296 -void AccelEditor::OnReset()
 546.297 -{
 546.298 -	m_mgr.Default(); /// FIXME accelerator reset NYI
 546.299 -	systemMessage(
 546.300 -	    0,
 546.301 -	    "The \"Reset All Accelerators\" feature is currently unimplemented.\nYou can achieve the same result by closing VBA, opening up your \"vba.ini\" file, deleting the line that starts with \"keyboard\", then reopening VBA.");
 546.302 -	InitCommands(); // update the listboxes.
 546.303 -}
 546.304 -
 546.305 -void AccelEditor::OnAssign()
 546.306 -{
 546.307 -	if (CheckAffected())
 546.308 -		return;
 546.309 -
 546.310 -	// get the currently selected group
 546.311 -	HTREEITEM hItem = m_commands.GetSelectedItem();
 546.312 -	if (hItem == NULL)
 546.313 -		return;  // abort
 546.314 -
 546.315 -	// Get the object who manage the accels list, associated to the command.
 546.316 -	WORD wIDCommand = LOWORD(m_commands.GetItemData(hItem));
 546.317 -
 546.318 -	CCmdAccelOb *pCmdAccel;
 546.319 -	if (m_mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
 546.320 -		return;
 546.321 -
 546.322 -	WORD wKey;
 546.323 -	bool bCtrl, bAlt, bShift;
 546.324 -	if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
 546.325 -		return;  // no valid key, abort
 546.326 -
 546.327 -	BYTE cVirt = 0;
 546.328 -	if (bCtrl)
 546.329 -		cVirt |= FCONTROL;
 546.330 -	if (bAlt)
 546.331 -		cVirt |= FALT;
 546.332 -	if (bShift)
 546.333 -		cVirt |= FSHIFT;
 546.334 -
 546.335 -	cVirt |= FVIRTKEY;
 546.336 -
 546.337 -	// Create the new key...
 546.338 -	CAccelsOb *pAccel = new CAccelsOb(cVirt, wKey, false);
 546.339 -	ASSERT(pAccel != NULL);
 546.340 -	// ...and add in the list.
 546.341 -	pCmdAccel->m_Accels.AddTail(pAccel);
 546.342 -
 546.343 -	// Update the listbox.
 546.344 -	CString szBuffer;
 546.345 -	pAccel->GetString(szBuffer);
 546.346 -
 546.347 -	int index = m_currents.GetNextItem(-1, LVNI_SELECTED);
 546.348 -	if (index < 0)
 546.349 -		index = 0;
 546.350 -	m_currents.InsertItem(index, szBuffer);
 546.351 -	m_currents.SetItemData(index, reinterpret_cast<DWORD>(pAccel));
 546.352 -	m_currents.SetItemState(-1, 0, LVIS_SELECTED);	// deselect other items first
 546.353 -	m_currents.SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
 546.354 -	GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
 546.355 -	GetDlgItem(IDC_ACCELEDIT_REPLACE)->EnableWindow(TRUE);
 546.356 -
 546.357 -	// Reset the key editor.
 546.358 -//	m_key.ResetKey();
 546.359 -
 546.360 -	m_modified = TRUE;
 546.361 -	GetDlgItem(IDC_ACCELEDIT_APPLY)->EnableWindow(TRUE);
 546.362 -}
 546.363 -
 546.364 -void AccelEditor::OnRemove()
 546.365 -{
 546.366 -	// Some controls
 546.367 -	POSITION selected = m_currents.GetFirstSelectedItemPosition();
 546.368 -	if (selected == NULL)
 546.369 -		return;
 546.370 -
 546.371 -	HTREEITEM hItem = m_commands.GetSelectedItem();
 546.372 -	if (hItem == NULL)
 546.373 -		return;
 546.374 -
 546.375 -	// Ref to the ID command
 546.376 -	WORD wIDCommand = LOWORD(m_commands.GetItemData(hItem));
 546.377 -
 546.378 -	// Run through the accels, and control if it can be deleted.
 546.379 -	CCmdAccelOb *pCmdAccel;
 546.380 -	if (m_mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE)
 546.381 -	{
 546.382 -		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 546.383 -		POSITION PrevPos;
 546.384 -		while (pos != NULL)
 546.385 -		{
 546.386 -			PrevPos = pos;
 546.387 -			CAccelsOb *pAccel = pCmdAccel->m_Accels.GetNext(pos);
 546.388 -			do
 546.389 -			{
 546.390 -				int indexCurrent = m_currents.GetNextSelectedItem(selected);
 546.391 -				CAccelsOb *pAccelCurrent = reinterpret_cast<CAccelsOb *>(m_currents.GetItemData(indexCurrent));
 546.392 -				if (pAccel == pAccelCurrent)
 546.393 -				{
 546.394 -					if (!pAccel->m_bLocked)
 546.395 -					{
 546.396 -						// not locked, so we delete the key
 546.397 -						pCmdAccel->m_Accels.RemoveAt(PrevPos);
 546.398 -						delete pAccel;
 546.399 -						// and update the listboxes/key editor/static text
 546.400 -						m_currents.DeleteItem(indexCurrent);
 546.401 -						m_modified = TRUE;
 546.402 -						break;
 546.403 -					}
 546.404 -					else
 546.405 -					{
 546.406 -						systemMessage(0, "Unable to remove this locked accelerator: ", m_currents.GetItemText(indexCurrent, KEY_COLUMN));
 546.407 -						m_currents.SetItemState(indexCurrent, 0, LVIS_SELECTED); // deselect it
 546.408 -						break;
 546.409 -					}
 546.410 -				}
 546.411 -			}
 546.412 -			while (selected != NULL);
 546.413 -
 546.414 -			selected = m_currents.GetFirstSelectedItemPosition();
 546.415 -			if (selected == NULL)	// the normal exit of this function
 546.416 -			{
 546.417 -				m_currents.SetItemState(m_currents.GetNextItem(-1, LVIS_FOCUSED), LVIS_SELECTED, LVIS_SELECTED);
 546.418 -				if (m_currents.GetSelectedCount() == 0)
 546.419 -				{
 546.420 -					GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
 546.421 -					GetDlgItem(IDC_ACCELEDIT_REPLACE)->EnableWindow(FALSE);
 546.422 -				}
 546.423 -				GetDlgItem(IDC_ACCELEDIT_APPLY)->EnableWindow(m_modified);
 546.424 -				return;
 546.425 -			}
 546.426 -		}
 546.427 -		systemMessage(0, "internal error (AccelEditor::Remove : pAccel unavailable)");
 546.428 -		return;
 546.429 -	}
 546.430 -	systemMessage(0, "internal error (AccelEditor::Remove : Lookup failed)");
 546.431 -}
 546.432 -
 546.433 -void AccelEditor::OnReplace()
 546.434 -{
 546.435 -	if (CheckAffected())
 546.436 -		return;
 546.437 -	OnRemove();
 546.438 -	OnAssign();
 546.439 -}
 546.440 -
 546.441 -void AccelEditor::OnNew()
 546.442 -{
 546.443 -	m_autoMode = AUTO_NEW;
 546.444 -	m_key.SetFocus();
 546.445 -}
 546.446 -
 546.447 -void AccelEditor::OnEdit()
 546.448 -{
 546.449 -	m_autoMode = AUTO_REPLACE;
 546.450 -	m_key.SetFocus();
 546.451 -}
 546.452 -
 546.453 -BOOL AccelEditor::CheckAffected()
 546.454 -{
 546.455 -	m_alreadyAffected.SetWindowText("");
 546.456 -
 546.457 -	WORD wKey;
 546.458 -	bool bCtrl, bAlt, bShift;
 546.459 -	if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
 546.460 -		return TRUE;  // no valid key, abort
 546.461 -
 546.462 -	POSITION posItem = m_hItems.GetHeadPosition();
 546.463 -	while (posItem != NULL)
 546.464 -	{
 546.465 -		HTREEITEM hItem		  = m_hItems.GetNext(posItem);
 546.466 -		WORD	  wIDCommand2 = LOWORD(m_commands.GetItemData(hItem));
 546.467 -
 546.468 -		CCmdAccelOb *pCmdAccel;
 546.469 -		m_mgr.m_mapAccelTable.Lookup(wIDCommand2, pCmdAccel);
 546.470 -
 546.471 -		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 546.472 -		while (pos != NULL)
 546.473 -		{
 546.474 -			CAccelsOb *pAccel = pCmdAccel->m_Accels.GetNext(pos);
 546.475 -			if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift))
 546.476 -			{
 546.477 -				// the key is already affected (in the same or other command)
 546.478 -				// (the parts that were commented out allow for a one-to-many mapping,
 546.479 -				//  which is only disabled because the MFC stuff that automagically activates the commands
 546.480 -				//  doesn't seem to be capable of activating more than one command per accelerator...)
 546.481 -				m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
 546.482 -				return TRUE;
 546.483 -			}
 546.484 -		}
 546.485 -	}
 546.486 -
 546.487 -	return FALSE;
 546.488 -}
 546.489 -
 546.490 -BOOL AccelEditor::CheckJammed()
 546.491 -{
 546.492 -	WORD jam;
 546.493 -	if (m_key.GetJamKey(jam))
 546.494 -	{
 546.495 -		// these go first, or the timer would be set again
 546.496 -		m_key.ResetKey();
 546.497 -		m_key.SetWindowText("Interrupted");
 546.498 -		if (m_currents.IsWindowEnabled())
 546.499 -			m_currents.SetFocus();
 546.500 -		else
 546.501 -			m_commands.SetFocus();
 546.502 -		return TRUE;
 546.503 -	}
 546.504 -	return FALSE;
 546.505 -}
 546.506 -
 546.507 -BOOL AccelEditor::CheckListSelections()
 546.508 -{
 546.509 -	BOOL result = m_currents.GetFirstSelectedItemPosition() ? TRUE : FALSE;
 546.510 -
 546.511 -	GetDlgItem(IDC_REMOVE)->EnableWindow(result);
 546.512 -	GetDlgItem(IDC_ACCELEDIT_REPLACE)->EnableWindow(result);
 546.513 -
 546.514 -	return result;
 546.515 -}
 546.516 -
 546.517 -void AccelEditor::OnTvnSelchangedCommands(NMHDR *pNMHDR, LRESULT *pResult)
 546.518 -{
 546.519 -//	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
 546.520 -
 546.521 -	// TODO: Add your control notification handler code here
 546.522 -	// Check if some commands exist.
 546.523 -	HTREEITEM hItem = m_commands.GetSelectedItem();
 546.524 -	if (hItem == NULL)
 546.525 -		return;
 546.526 -
 546.527 -	m_currents.DeleteAllItems();
 546.528 -
 546.529 -	WORD wIDCommand = LOWORD(m_commands.GetItemData(hItem));
 546.530 -	CCmdAccelOb *pCmdAccel;
 546.531 -	if (m_mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel))
 546.532 -	{
 546.533 -		CAccelsOb *pAccel;
 546.534 -		CString	   szBuffer;
 546.535 -		POSITION   pos = pCmdAccel->m_Accels.GetHeadPosition();
 546.536 -
 546.537 -		// Add the keys to the 'currents keys' listbox.
 546.538 -		while (pos != NULL)
 546.539 -		{
 546.540 -			pAccel = pCmdAccel->m_Accels.GetNext(pos);
 546.541 -			pAccel->GetString(szBuffer);
 546.542 -			int index = m_currents.InsertItem(m_currents.GetItemCount(), szBuffer);
 546.543 -			// and a pointer to the accel object.
 546.544 -			m_currents.SetItemData(index, (DWORD)pAccel);
 546.545 -		}
 546.546 -
 546.547 -		m_currents.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
 546.548 -		GetDlgItem(IDC_ASSIGN)->EnableWindow(TRUE);
 546.549 -		m_currents.EnableWindow(TRUE);
 546.550 -	}
 546.551 -	else
 546.552 -	{
 546.553 -		GetDlgItem(IDC_ASSIGN)->EnableWindow(FALSE);
 546.554 -		m_currents.EnableWindow(FALSE);
 546.555 -	}
 546.556 -
 546.557 -	// Init the key editor
 546.558 -//  m_pKey->ResetKey();
 546.559 -//	m_alreadyAffected.SetWindowText("");
 546.560 -
 546.561 -	CheckListSelections();
 546.562 -
 546.563 -	*pResult = 0;
 546.564 -}
 546.565 -
 546.566 -/*
 546.567 -void AccelEditor::OnListItemChanged(NMHDR *pNMHDR, LRESULT *pResult)
 546.568 -{
 546.569 -	NMLISTVIEW *pNMListView = reinterpret_cast<NMLISTVIEW *>(pNMHDR);
 546.570 -	if (pNMListView->uChanged == LVIF_STATE)
 546.571 -	{
 546.572 -		if ((pNMListView->uOldState & LVIS_SELECTED) && !(pNMListView->uNewState & LVIS_SELECTED))
 546.573 -		{
 546.574 -		}
 546.575 -	}
 546.576 -
 546.577 -	*pResult = 0;
 546.578 -}
 546.579 -*/
 546.580 -
 546.581 -void AccelEditor::OnListClick(NMHDR *pNMHDR, LRESULT *pResult)
 546.582 -{
 546.583 -	CheckListSelections();
 546.584 -	*pResult = 0;
 546.585 -}
 546.586 -
 546.587 -void AccelEditor::OnListDblClick(NMHDR *pNMHDR, LRESULT *pResult)
 546.588 -{
 546.589 -	if (m_currents.GetFirstSelectedItemPosition())
 546.590 -		OnEdit();
 546.591 -	else
 546.592 -		OnNew();
 546.593 -	*pResult = 0;
 546.594 -}
 546.595 -
 546.596 -void AccelEditor::OnKeyboardEditChange()
 546.597 -{
 546.598 -	if (!m_key.IsDefined())
 546.599 -		return;
 546.600 -
 546.601 -//	if (CheckJammed())
 546.602 -//		return;
 546.603 -
 546.604 -	OnKeyboardEditKillfocus();
 546.605 -	CheckAffected();
 546.606 -	if (m_timeoutValue == 0)
 546.607 -		return;
 546.608 -
 546.609 -	m_progress.SetRange32(0, m_timeoutValue);
 546.610 -	SetTimer(1, 50, NULL);
 546.611 -}
 546.612 -
 546.613 -void AccelEditor::OnKeyboardEditKillfocus()
 546.614 -{
 546.615 -	KillTimer(1);
 546.616 -	m_timer = 0;
 546.617 -	m_progress.SetPos(0);
 546.618 -	m_progress.SetBarColor(RGB(128, 0, 255));
 546.619 -}
 546.620 -
 546.621 -void AccelEditor::OnTimeoutEditSetfocus()
 546.622 -{
 546.623 -	m_timeout.PostMessage(EM_SETSEL, 0, -1);
 546.624 -}
 546.625 -
 546.626 -void AccelEditor::OnTimeoutEditKillfocus()
 546.627 -{
 546.628 -	CString str;
 546.629 -	m_timeout.GetWindowText(str);
 546.630 -	m_timeoutValue = atoi(str);
 546.631 -	m_autoMode	   = AUTO_REPLACE;
 546.632 -}
 546.633 -
 546.634 -void AccelEditor::OnTimer(UINT_PTR nIDEvent)
 546.635 -{
 546.636 -	if (nIDEvent == 1)
 546.637 -	{
 546.638 -		m_timer += 50;
 546.639 -		if (m_timer >= m_timeoutValue)
 546.640 -		{
 546.641 -			m_progress.SetPos(m_timeoutValue);
 546.642 -			m_progress.SetBarColor(RGB(255, 255, 0));
 546.643 -			if (m_autoMode == AUTO_NEW)
 546.644 -			{
 546.645 -				OnAssign();
 546.646 -			}
 546.647 -			else
 546.648 -			{
 546.649 -				OnReplace();
 546.650 -			}
 546.651 -			if (m_currents.IsWindowEnabled())
 546.652 -				m_currents.SetFocus();
 546.653 -			else
 546.654 -				m_commands.SetFocus();
 546.655 -			return;
 546.656 -		}
 546.657 -		UINT green = (m_timer * 255 / m_timeoutValue) ;
 546.658 -		m_progress.SetBarColor(RGB(128 + green / 2, green, 255 - green));
 546.659 -		m_progress.SetPos(m_timer);
 546.660 -	}
 546.661 -}
 546.662 -
   547.1 --- a/src/win32/AccelEditor.h	Sat Mar 03 10:54:39 2012 -0600
   547.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   547.3 @@ -1,93 +0,0 @@
   547.4 -#if !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_)
   547.5 -#define AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_
   547.6 -
   547.7 -#if _MSC_VER > 1000
   547.8 -#pragma once
   547.9 -#endif // _MSC_VER > 1000
  547.10 -// AccelEditor.h : header file
  547.11 -//
  547.12 -#include "AcceleratorManager.h"
  547.13 -#include "KeyboardEdit.h"
  547.14 -#include "ResizeDlg.h"
  547.15 -
  547.16 -/////////////////////////////////////////////////////////////////////////////
  547.17 -// AccelEditor dialog
  547.18 -
  547.19 -class AccelEditor : public ResizeDlg
  547.20 -{
  547.21 -	// Construction
  547.22 -public:
  547.23 -	void InitCommands();
  547.24 -	void AddCommandsFromTable();
  547.25 -	void AddCommandsFromMenu(CMenu *pMenu, HTREEITEM hParent);
  547.26 -	BOOL IsModified() const;
  547.27 -	const CAcceleratorManager &GetResultMangager() const;
  547.28 -	AccelEditor(CWnd *pParent, CMenu *pMenu, CAcceleratorManager *pExtMgr = NULL);  // non-standard constructor
  547.29 -	virtual BOOL PreTranslateMessage(MSG *pMsg);
  547.30 -
  547.31 -	// Dialog Data
  547.32 -	//{{AFX_DATA(AccelEditor)
  547.33 -protected:
  547.34 -	enum { IDD = IDD_ACCEL_EDITOR };
  547.35 -	enum { KEY_COLUMN = 0 };
  547.36 -	enum { AUTO_REPLACE = 0, AUTO_NEW };
  547.37 -	CListCtrl		  m_currents;
  547.38 -	CStatic			  m_alreadyAffected;
  547.39 -	CTreeCtrl		  m_commands;
  547.40 -	CKeyboardEdit	  m_key;
  547.41 -	CEdit			  m_timeout;
  547.42 -	CProgressCtrl	  m_progress;
  547.43 -	CList<HTREEITEM>  m_hItems;
  547.44 -
  547.45 -	int m_timeoutValue;
  547.46 -	int m_timer;
  547.47 -	int m_autoMode;
  547.48 -	BOOL m_modified;
  547.49 -	CAcceleratorManager m_mgr, m_result;
  547.50 -	CAcceleratorManager *m_pExtMgr;
  547.51 -	CMenu *m_pMenuSrc;
  547.52 -	//}}AFX_DATA
  547.53 -
  547.54 -	// Overrides
  547.55 -	// ClassWizard generated virtual function overrides
  547.56 -	//{{AFX_VIRTUAL(AccelEditor)
  547.57 -protected:
  547.58 -	virtual void DoDataExchange(CDataExchange *pDX);   // DDX/DDV support
  547.59 -	//}}AFX_VIRTUAL
  547.60 -
  547.61 -	// Implementation
  547.62 -protected:
  547.63 -	BOOL CheckAffected();
  547.64 -	BOOL CheckJammed();
  547.65 -	BOOL CheckListSelections();
  547.66 -
  547.67 -	// Generated message map functions
  547.68 -	//{{AFX_MSG(AccelEditor)
  547.69 -	virtual BOOL OnInitDialog();
  547.70 -	afx_msg void OnOk();
  547.71 -	afx_msg void OnCancel();
  547.72 -	afx_msg void OnApply();
  547.73 -	afx_msg void OnReset();
  547.74 -	afx_msg void OnAssign();
  547.75 -	afx_msg void OnRemove();
  547.76 -	afx_msg void OnReplace();
  547.77 -	afx_msg void OnNew();
  547.78 -	afx_msg void OnEdit();
  547.79 -
  547.80 -	afx_msg void OnTvnSelchangedCommands(NMHDR *pNMHDR, LRESULT *pResult);
  547.81 -//	afx_msg void OnListItemChanged(NMHDR *pNMHDR, LRESULT *pResult);
  547.82 -	afx_msg void OnListClick(NMHDR *pNMHDR, LRESULT *pResult);
  547.83 -	afx_msg void OnListDblClick(NMHDR *pNMHDR, LRESULT *pResult);
  547.84 -	afx_msg void OnKeyboardEditChange();
  547.85 -	afx_msg void OnKeyboardEditKillfocus();
  547.86 -	afx_msg void OnTimeoutEditSetfocus();
  547.87 -	afx_msg void OnTimeoutEditKillfocus();
  547.88 -	afx_msg void OnTimer(UINT_PTR nIDEvent);
  547.89 -	//}}AFX_MSG
  547.90 -	DECLARE_MESSAGE_MAP()
  547.91 -};
  547.92 -
  547.93 -//{{AFX_INSERT_LOCATION}}
  547.94 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  547.95 -
  547.96 -#endif // !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_)
   548.1 --- a/src/win32/AcceleratorManager.cpp	Sat Mar 03 10:54:39 2012 -0600
   548.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   548.3 @@ -1,729 +0,0 @@
   548.4 -////////////////////////////////////////////////////////////////////////////////
   548.5 -// Copyright (C) 1998 by Thierry Maurel
   548.6 -// All rights reserved
   548.7 -//
   548.8 -// Distribute freely, except: don't remove my name from the source or
   548.9 -// documentation (don't take credit for my work), mark your changes (don't
  548.10 -// get me blamed for your possible bugs), don't alter or remove this
  548.11 -// notice.
  548.12 -// No warrantee of any kind, express or implied, is included with this
  548.13 -// software; use at your own risk, responsibility for damages (if any) to
  548.14 -// anyone resulting from the use of this software rests entirely with the
  548.15 -// user.
  548.16 -//
  548.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  548.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  548.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  548.20 -//
  548.21 -////////////////////////////////////////////////////////////////////////////////
  548.22 -// File    : AcceleratorManager.cpp
  548.23 -// Project : AccelsEditor
  548.24 -////////////////////////////////////////////////////////////////////////////////
  548.25 -// Version : 1.0                       * Author : T.Maurel
  548.26 -// Date    : 17.08.98
  548.27 -//
  548.28 -// Remarks : implementation of the CAcceleratorManager class.
  548.29 -//
  548.30 -////////////////////////////////////////////////////////////////////////////////
  548.31 -// Modified by aquanull:
  548.32 -// All win32 registry stuff removed
  548.33 -
  548.34 -#include "stdafx.h"
  548.35 -#include <windows.h> // MIIM_STRING
  548.36 -#include "resource.h"
  548.37 -#include "AcceleratorManager.h"
  548.38 -#include "CmdAccelOb.h"
  548.39 -#include "Reg.h"
  548.40 -#include "VBA.h"
  548.41 -//#include "../common/System.h"
  548.42 -
  548.43 -CAcceleratorManager::CAcceleratorManager()
  548.44 -{
  548.45 -	m_bAutoSave     = FALSE;
  548.46 -	m_pWndConnected = NULL;
  548.47 -
  548.48 -	m_bDefaultTable = false;
  548.49 -}
  548.50 -
  548.51 -CAcceleratorManager::~CAcceleratorManager()
  548.52 -{
  548.53 -#if 0
  548.54 -	if (m_bAutoSave)
  548.55 -	{
  548.56 -		bool bRet = Write();
  548.57 -		if (!bRet)
  548.58 -			systemMessage(0, "CAcceleratorManager::~CAcceleratorManager\nError in CAcceleratorManager::Write...");
  548.59 -	}
  548.60 -#endif
  548.61 -	Reset();
  548.62 -}
  548.63 -
  548.64 -CAcceleratorManager & CAcceleratorManager::operator=(const CAcceleratorManager& accelmgr)
  548.65 -{
  548.66 -	Reset();
  548.67 -
  548.68 -	CCmdAccelOb*pCmdAccel;
  548.69 -	CCmdAccelOb*pNewCmdAccel;
  548.70 -	WORD        wKey;
  548.71 -	// Copy the 2 tables : normal accel table...
  548.72 -	POSITION pos = accelmgr.m_mapAccelTable.GetStartPosition();
  548.73 -	while (pos != NULL)
  548.74 -	{
  548.75 -		accelmgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
  548.76 -		pNewCmdAccel = new CCmdAccelOb;
  548.77 -		ASSERT(pNewCmdAccel != NULL);
  548.78 -		*pNewCmdAccel = *pCmdAccel;
  548.79 -		m_mapAccelTable.SetAt(wKey, pNewCmdAccel);
  548.80 -	}
  548.81 -	// ... and saved accel table.
  548.82 -	pos = accelmgr.m_mapAccelTableSaved.GetStartPosition();
  548.83 -	while (pos != NULL)
  548.84 -	{
  548.85 -		accelmgr.m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
  548.86 -		pNewCmdAccel = new CCmdAccelOb;
  548.87 -		ASSERT(pNewCmdAccel != NULL);
  548.88 -		*pNewCmdAccel = *pCmdAccel;
  548.89 -		m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
  548.90 -	}
  548.91 -
  548.92 -	// The Strings-ID table
  548.93 -	CString szKey;
  548.94 -	pos = accelmgr.m_mapAccelString.GetStartPosition();
  548.95 -	while (pos != NULL)
  548.96 -	{
  548.97 -		accelmgr.m_mapAccelString.GetNextAssoc(pos, szKey, wKey);
  548.98 -		m_mapAccelString.SetAt(szKey, wKey);
  548.99 -	}
 548.100 -	m_bDefaultTable = accelmgr.m_bDefaultTable;
 548.101 -
 548.102 -	return *this;
 548.103 -}
 548.104 -
 548.105 -//////////////////////////////////////////////////////////////////////
 548.106 -// Internal fcts
 548.107 -//
 548.108 -void CAcceleratorManager::Reset()
 548.109 -{
 548.110 -	CCmdAccelOb*pCmdAccel;
 548.111 -	WORD        wKey;
 548.112 -	POSITION    pos = m_mapAccelTable.GetStartPosition();
 548.113 -	while (pos != NULL)
 548.114 -	{
 548.115 -		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.116 -		delete pCmdAccel;
 548.117 -	}
 548.118 -	m_mapAccelTable.RemoveAll();
 548.119 -	m_mapAccelString.RemoveAll();
 548.120 -
 548.121 -	pos = m_mapAccelTableSaved.GetStartPosition();
 548.122 -	while (pos != NULL)
 548.123 -	{
 548.124 -		m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
 548.125 -		delete pCmdAccel;
 548.126 -	}
 548.127 -	m_mapAccelTableSaved.RemoveAll();
 548.128 -}
 548.129 -
 548.130 -bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
 548.131 -{
 548.132 -	ASSERT(szCommand != NULL);
 548.133 -
 548.134 -	WORD wIDCmd;
 548.135 -	if (m_mapAccelString.Lookup(szCommand, wIDCmd) == TRUE)
 548.136 -	{
 548.137 -		if (wIDCmd != wIDCommand)
 548.138 -			return false;
 548.139 -	}
 548.140 -
 548.141 -	CCmdAccelOb*pCmdAccel = NULL;
 548.142 -	if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE)
 548.143 -	{
 548.144 -		if (pCmdAccel->m_szCommand != szCommand)
 548.145 -		{
 548.146 -			return false;
 548.147 -		}
 548.148 -		CAccelsOb*pAccel;
 548.149 -		POSITION  pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.150 -		while (pos != NULL)
 548.151 -		{
 548.152 -			pAccel = pCmdAccel->m_Accels.GetNext(pos);
 548.153 -			if (pAccel->m_cVirt == cVirt &&
 548.154 -			    pAccel->m_wKey == wKey)
 548.155 -				return FALSE;
 548.156 -		}
 548.157 -		// Adding the accelerator
 548.158 -		pCmdAccel->Add(cVirt, wKey, bLocked);
 548.159 -	}
 548.160 -	else
 548.161 -	{
 548.162 -		pCmdAccel = new CCmdAccelOb(cVirt, wIDCommand, wKey, szCommand, bLocked);
 548.163 -		ASSERT(pCmdAccel != NULL);
 548.164 -		m_mapAccelTable.SetAt(wIDCommand, pCmdAccel);
 548.165 -	}
 548.166 -	// 2nd table
 548.167 -	m_mapAccelString.SetAt(szCommand, wIDCommand);
 548.168 -	return true;
 548.169 -}
 548.170 -
 548.171 -//////////////////////////////////////////////////////////////////////
 548.172 -// Debug fcts
 548.173 -//
 548.174 -#ifdef _DEBUG
 548.175 -void CAcceleratorManager::AssertValid() const
 548.176 -{}
 548.177 -
 548.178 -void CAcceleratorManager::Dump(CDumpContext& dc) const
 548.179 -{
 548.180 -	CCmdAccelOb*pCmdAccel;
 548.181 -	WORD        wKey;
 548.182 -	dc << "CAcceleratorManager::Dump :\n";
 548.183 -	dc << "m_mapAccelTable :\n";
 548.184 -	POSITION pos = m_mapAccelTable.GetStartPosition();
 548.185 -	while (pos != NULL)
 548.186 -	{
 548.187 -		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.188 -		dc << "a CCmdAccelOb at 0x"  << (void *)pCmdAccel << " = {\n";
 548.189 -		dc << pCmdAccel;
 548.190 -		dc << "}\n";
 548.191 -	}
 548.192 -	dc << "\nm_mapAccelTableSaved\n";
 548.193 -	pos = m_mapAccelTableSaved.GetStartPosition();
 548.194 -	while (pos != NULL)
 548.195 -	{
 548.196 -		m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
 548.197 -		dc << "a CCmdAccelOb at 0x" << (void *)pCmdAccel << " = {\n";
 548.198 -		dc << pCmdAccel;
 548.199 -		dc << "}\n";
 548.200 -	}
 548.201 -}
 548.202 -
 548.203 -#endif
 548.204 -
 548.205 -void CAcceleratorManager::Connect(CWnd*pWnd, bool bAutoSave)
 548.206 -{
 548.207 -	ASSERT(m_pWndConnected == NULL);
 548.208 -	m_pWndConnected = pWnd;
 548.209 -	m_bAutoSave     = bAutoSave;
 548.210 -}
 548.211 -
 548.212 -//////////////////////////////////////////////////////////////////////
 548.213 -// Update the application's ACCELs table
 548.214 -//
 548.215 -bool CAcceleratorManager::UpdateWndTable()
 548.216 -{
 548.217 -	int iLoop = 0;
 548.218 -	CTypedPtrArray<CPtrArray, LPACCEL> arrayACCEL;
 548.219 -
 548.220 -	CCmdAccelOb*pCmdAccel;
 548.221 -	WORD        wKey;
 548.222 -	LPACCEL     pACCEL;
 548.223 -	CAccelsOb*  pAccelOb;
 548.224 -	POSITION    pos = m_mapAccelTable.GetStartPosition();
 548.225 -	while (pos != NULL)
 548.226 -	{
 548.227 -		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.228 -		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.229 -		while (pos != NULL)
 548.230 -		{
 548.231 -			pAccelOb = pCmdAccel->m_Accels.GetNext(pos);
 548.232 -
 548.233 -			pACCEL = new ACCEL;
 548.234 -			ASSERT(pACCEL != NULL);
 548.235 -			pACCEL->fVirt = pAccelOb->m_cVirt;
 548.236 -			pACCEL->key   = pAccelOb->m_wKey;
 548.237 -			pACCEL->cmd   = pCmdAccel->m_wIDCommand;
 548.238 -			arrayACCEL.Add(pACCEL);
 548.239 -		}
 548.240 -	}
 548.241 -
 548.242 -	int     nAccel  = arrayACCEL.GetSize();
 548.243 -	LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
 548.244 -	if (!lpAccel)
 548.245 -	{
 548.246 -		for (iLoop = 0; iLoop < nAccel; iLoop++)
 548.247 -			delete arrayACCEL.GetAt(iLoop);
 548.248 -		arrayACCEL.RemoveAll();
 548.249 -
 548.250 -		return false;
 548.251 -	}
 548.252 -
 548.253 -	for (iLoop = 0; iLoop < nAccel; iLoop++)
 548.254 -	{
 548.255 -		pACCEL = arrayACCEL.GetAt(iLoop);
 548.256 -		lpAccel[iLoop].fVirt = pACCEL->fVirt;
 548.257 -		lpAccel[iLoop].key   = pACCEL->key;
 548.258 -		lpAccel[iLoop].cmd   = pACCEL->cmd;
 548.259 -
 548.260 -		delete pACCEL;
 548.261 -	}
 548.262 -	arrayACCEL.RemoveAll();
 548.263 -
 548.264 -	HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel);
 548.265 -	if (!hNewTable)
 548.266 -	{
 548.267 -		::LocalFree(lpAccel);
 548.268 -		return false;
 548.269 -	}
 548.270 -	HACCEL hOldTable = theApp.hAccel;
 548.271 -	if (!::DestroyAcceleratorTable(hOldTable))
 548.272 -	{
 548.273 -		::LocalFree(lpAccel);
 548.274 -		return false;
 548.275 -	}
 548.276 -	theApp.hAccel = hNewTable;
 548.277 -	::LocalFree(lpAccel);
 548.278 -
 548.279 -	UpdateMenu(GetMenu(*AfxGetApp()->m_pMainWnd));
 548.280 -
 548.281 -	return true;
 548.282 -}
 548.283 -
 548.284 -//////////////////////////////////////////////////////////////////////
 548.285 -// Create/Destroy accelerators
 548.286 -//
 548.287 -bool CAcceleratorManager::DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wKey)
 548.288 -{
 548.289 -	CCmdAccelOb*pCmdAccel = NULL;
 548.290 -	if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE)
 548.291 -	{
 548.292 -		POSITION  pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.293 -		POSITION  PrevPos;
 548.294 -		CAccelsOb*pAccel = NULL;
 548.295 -		while (pos != NULL)
 548.296 -		{
 548.297 -			PrevPos = pos;
 548.298 -			pAccel  = pCmdAccel->m_Accels.GetNext(pos);
 548.299 -			if (pAccel->m_bLocked == true)
 548.300 -				return false;
 548.301 -
 548.302 -			if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey)
 548.303 -			{
 548.304 -				pCmdAccel->m_Accels.RemoveAt(PrevPos);
 548.305 -				delete pAccel;
 548.306 -				return true;
 548.307 -			}
 548.308 -		}
 548.309 -	}
 548.310 -	return false;
 548.311 -}
 548.312 -
 548.313 -bool CAcceleratorManager::DeleteEntry(WORD wIDCommand)
 548.314 -{
 548.315 -	CCmdAccelOb*pCmdAccel = NULL;
 548.316 -	VERIFY(m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE);
 548.317 -
 548.318 -	CAccelsOb*pAccel;
 548.319 -	POSITION  pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.320 -	while (pos != NULL)
 548.321 -	{
 548.322 -		pAccel = pCmdAccel->m_Accels.GetNext(pos);
 548.323 -		if (pAccel->m_bLocked == true)
 548.324 -			return false;
 548.325 -	}
 548.326 -	m_mapAccelString.RemoveKey(pCmdAccel->m_szCommand);
 548.327 -	m_mapAccelTable.RemoveKey(wIDCommand);
 548.328 -	delete pCmdAccel;
 548.329 -
 548.330 -	return true;
 548.331 -}
 548.332 -
 548.333 -bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand)
 548.334 -{
 548.335 -	ASSERT(szCommand != NULL);
 548.336 -
 548.337 -	WORD wIDCommand;
 548.338 -	if (m_mapAccelString.Lookup(szCommand, wIDCommand) == TRUE)
 548.339 -	{
 548.340 -		return DeleteEntry(wIDCommand);
 548.341 -	}
 548.342 -	return true;
 548.343 -}
 548.344 -
 548.345 -bool CAcceleratorManager::SetAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
 548.346 -{
 548.347 -	ASSERT(szCommand != NULL);
 548.348 -
 548.349 -	return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked);
 548.350 -}
 548.351 -
 548.352 -bool CAcceleratorManager::AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked)
 548.353 -{
 548.354 -	ASSERT(szCommand != NULL);
 548.355 -
 548.356 -	ASSERT(m_pWndConnected != NULL);
 548.357 -	HACCEL hOriginalTable = theApp.hAccel;
 548.358 -
 548.359 -	int     nAccel  = ::CopyAcceleratorTable(hOriginalTable, NULL, 0);
 548.360 -	LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, (nAccel) * sizeof(ACCEL));
 548.361 -	if (!lpAccel)
 548.362 -		return false;
 548.363 -	::CopyAcceleratorTable(hOriginalTable, lpAccel, nAccel);
 548.364 -
 548.365 -	bool bRet = false;
 548.366 -	for (int i = 0; i < nAccel; i++)
 548.367 -	{
 548.368 -		if (lpAccel[i].cmd == wIDCommand)
 548.369 -			bRet = AddAccel(lpAccel[i].fVirt, wIDCommand, lpAccel[i].key, szCommand, bLocked);
 548.370 -	}
 548.371 -	::LocalFree(lpAccel);
 548.372 -	return bRet;
 548.373 -}
 548.374 -
 548.375 -bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
 548.376 -{
 548.377 -	ASSERT(szCommand != NULL);
 548.378 -
 548.379 -	WORD wIDDummy;
 548.380 -	if (m_mapAccelString.Lookup(szCommand, wIDDummy) == TRUE)
 548.381 -		return false;
 548.382 -
 548.383 -	CCmdAccelOb*pCmdAccel = new CCmdAccelOb(wIDCommand, szCommand);
 548.384 -	ASSERT(pCmdAccel != NULL);
 548.385 -	m_mapAccelTable.SetAt(wIDCommand, pCmdAccel);
 548.386 -	m_mapAccelString.SetAt(szCommand, wIDCommand);
 548.387 -
 548.388 -	return false;
 548.389 -}
 548.390 -
 548.391 -//////////////////////////////////////////////////////////////////////
 548.392 -// Get a string from the ACCEL definition
 548.393 -//
 548.394 -bool CAcceleratorManager::GetStringFromACCEL(ACCEL*pACCEL, CString& szAccel)
 548.395 -{
 548.396 -	ASSERT(pACCEL != NULL);
 548.397 -
 548.398 -	CAccelsOb accel(pACCEL);
 548.399 -	accel.GetString(szAccel);
 548.400 -
 548.401 -	if (szAccel.IsEmpty())
 548.402 -		return false;
 548.403 -	else
 548.404 -		return true;
 548.405 -}
 548.406 -
 548.407 -bool CAcceleratorManager::GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel)
 548.408 -{
 548.409 -	CAccelsOb accel(cVirt, nCode);
 548.410 -	accel.GetString(szAccel);
 548.411 -
 548.412 -	if (szAccel.IsEmpty())
 548.413 -		return false;
 548.414 -	else
 548.415 -		return true;
 548.416 -}
 548.417 -
 548.418 -void CAcceleratorManager::UpdateMenu(HMENU menu)
 548.419 -{
 548.420 -	int count = GetMenuItemCount(menu);
 548.421 -
 548.422 -	OSVERSIONINFO info = {0};
 548.423 -	info.dwOSVersionInfoSize = sizeof(info);
 548.424 -	GetVersionEx(&info);
 548.425 -
 548.426 -	if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
 548.427 -	{
 548.428 -		MENUITEMINFO info = {0};
 548.429 -		info.cbSize = sizeof(info) - sizeof(HBITMAP);
 548.430 -		info.fMask  = MIIM_ID | MIIM_SUBMENU;
 548.431 -		for (int i = 0; i < count; i++)
 548.432 -		{
 548.433 -			GetMenuItemInfo(menu, i, TRUE, &info);
 548.434 -
 548.435 -			if (info.hSubMenu != NULL)
 548.436 -			{
 548.437 -				UpdateMenu(info.hSubMenu);
 548.438 -			}
 548.439 -			else
 548.440 -			{
 548.441 -				if (info.wID != (UINT)-1)
 548.442 -				{
 548.443 -					char         ss[128];
 548.444 -					MENUITEMINFO info2 = {0};
 548.445 -					info2.cbSize     = sizeof(info2) - sizeof(HBITMAP);	// FIXME: why?
 548.446 -					info2.fMask      = MIIM_STRING;
 548.447 -					info2.dwTypeData = ss;
 548.448 -					info2.cch        = 128;
 548.449 -					GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2);
 548.450 -
 548.451 -					CString str(ss);
 548.452 -					int     index = str.Find('\t');
 548.453 -					if (index != -1)
 548.454 -						str = str.Left(index);
 548.455 -
 548.456 -					WORD command = info.wID;
 548.457 -
 548.458 -					CCmdAccelOb *o;
 548.459 -					if (m_mapAccelTable.Lookup(command, o))
 548.460 -					{
 548.461 -						if (o->m_Accels.GetCount())
 548.462 -						{
 548.463 -							POSITION   pos   = o->m_Accels.GetHeadPosition();
 548.464 -							CAccelsOb *accel = o->m_Accels.GetNext(pos);
 548.465 -
 548.466 -							CString s;
 548.467 -							accel->GetString(s);
 548.468 -							str += "\t";
 548.469 -							str += s;
 548.470 -						}
 548.471 -					}
 548.472 -					if (str != ss)
 548.473 -						ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
 548.474 -				}
 548.475 -			}
 548.476 -		}
 548.477 -	}
 548.478 -	else
 548.479 -	{
 548.480 -		MENUITEMINFO info = {0};
 548.481 -		info.cbSize = sizeof(info);
 548.482 -		info.fMask  = MIIM_ID | MIIM_SUBMENU;
 548.483 -		for (int i = 0; i < count; i++)
 548.484 -		{
 548.485 -			GetMenuItemInfo(menu, i, TRUE, &info);
 548.486 -
 548.487 -			if (info.hSubMenu != NULL)
 548.488 -			{
 548.489 -				UpdateMenu(info.hSubMenu);
 548.490 -			}
 548.491 -			else
 548.492 -			{
 548.493 -				if (info.wID != (WORD)-1)
 548.494 -				{
 548.495 -					wchar_t ss[128];
 548.496 -					wchar_t str[512];
 548.497 -					MENUITEMINFOW info2 = {0};
 548.498 -					info2.cbSize     = sizeof(info2);
 548.499 -					info2.fMask      = MIIM_STRING;
 548.500 -					info2.dwTypeData = ss;
 548.501 -					info2.cch        = 128;
 548.502 -					GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2);
 548.503 -
 548.504 -					wcscpy(str, ss);
 548.505 -
 548.506 -					wchar_t *p = wcschr(str, '\t');
 548.507 -					if (p)
 548.508 -						*p = 0;
 548.509 -
 548.510 -					CCmdAccelOb *o;
 548.511 -					WORD         command = info.wID;
 548.512 -					if (m_mapAccelTable.Lookup(command, o))
 548.513 -					{
 548.514 -						if (o->m_Accels.GetCount())
 548.515 -						{
 548.516 -							POSITION pos = o->m_Accels.GetHeadPosition();
 548.517 -
 548.518 -							CAccelsOb *accel = o->m_Accels.GetNext(pos);
 548.519 -
 548.520 -							CString s;
 548.521 -							accel->GetString(s);
 548.522 -
 548.523 -							wchar_t temp[128];
 548.524 -							temp[0] = '\t';
 548.525 -							temp[1] = 0;
 548.526 -							wcscat(str, temp);
 548.527 -							p = temp;
 548.528 -							for (const char *sp = s; *sp; sp++)
 548.529 -								*p++ = *sp;
 548.530 -							*p = 0;
 548.531 -							wcscat(str, temp);
 548.532 -						}
 548.533 -					}
 548.534 -					if (wcscmp(str, ss))
 548.535 -						ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
 548.536 -				}
 548.537 -			}
 548.538 -		}
 548.539 -	}
 548.540 -}
 548.541 -
 548.542 -//////////////////////////////////////////////////////////////////////
 548.543 -// In/Out to the registry
 548.544 -//
 548.545 -bool CAcceleratorManager::Load()
 548.546 -{
 548.547 -//	ASSERT(szRegKey != NULL);
 548.548 -
 548.549 -//	m_hRegKey  = hRegKey;
 548.550 -//	m_szRegKey = szRegKey;
 548.551 -
 548.552 -	DWORD data[2048/sizeof(DWORD)];
 548.553 -
 548.554 -	DWORD len = sizeof(data);
 548.555 -	if (regQueryBinaryValue("keyboard", (char *)data, len))
 548.556 -	{
 548.557 -		int count = len/sizeof(DWORD);
 548.558 -
 548.559 -		CCmdAccelOb*pCmdAccel;
 548.560 -		CAccelsOb*  pAccel;
 548.561 -		DWORD       dwIDAccelData, dwAccelData;
 548.562 -		BOOL        bExistID;
 548.563 -		int         iIndex = 0;
 548.564 -		if (count)
 548.565 -		{
 548.566 -			WORD     wKey;
 548.567 -			POSITION pos = m_mapAccelTable.GetStartPosition();
 548.568 -
 548.569 -			while (pos != NULL)
 548.570 -			{
 548.571 -				m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.572 -				pCmdAccel->DeleteUserAccels();
 548.573 -			}
 548.574 -
 548.575 -			while (iIndex < count)
 548.576 -			{
 548.577 -				dwIDAccelData = data[iIndex++];
 548.578 -
 548.579 -				WORD wIDCommand = LOWORD(dwIDAccelData);
 548.580 -				bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
 548.581 -
 548.582 -				if (bExistID)
 548.583 -				{
 548.584 -					pCmdAccel->DeleteUserAccels();
 548.585 -				}
 548.586 -				for (int j = 0; j < HIWORD(dwIDAccelData) && iIndex < count; j++)
 548.587 -				{
 548.588 -					dwAccelData = data[iIndex++];
 548.589 -					if (bExistID)
 548.590 -					{
 548.591 -						pAccel = new CAccelsOb;
 548.592 -						ASSERT(pAccel != NULL);
 548.593 -						pAccel->SetData(dwAccelData);
 548.594 -						pCmdAccel->Add(pAccel);
 548.595 -					}
 548.596 -				}
 548.597 -			}
 548.598 -		}
 548.599 -		UpdateWndTable();
 548.600 -		return true;
 548.601 -	}
 548.602 -	return false;
 548.603 -}
 548.604 -
 548.605 -bool CAcceleratorManager::Write()
 548.606 -{
 548.607 -	CDWordArray AccelsDatasArray;
 548.608 -	CDWordArray CmdDatasArray;
 548.609 -
 548.610 -	int         iCount = 0;
 548.611 -	CCmdAccelOb*pCmdAccel;
 548.612 -	CAccelsOb*  pAccel;
 548.613 -	DWORD       dwAccelData;
 548.614 -
 548.615 -	WORD     wKey;
 548.616 -	POSITION pos = m_mapAccelTable.GetStartPosition();
 548.617 -	while (pos != NULL)
 548.618 -	{
 548.619 -		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.620 -		CmdDatasArray.RemoveAll();
 548.621 -
 548.622 -		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.623 -		while (pos != NULL)
 548.624 -		{
 548.625 -			pAccel = pCmdAccel->m_Accels.GetNext(pos);
 548.626 -			//      if (!pAccel->m_bLocked) {
 548.627 -			dwAccelData = pAccel->GetData();
 548.628 -			CmdDatasArray.Add(dwAccelData);
 548.629 -			//      }
 548.630 -		}
 548.631 -
 548.632 -		if (CmdDatasArray.GetSize() > 0)
 548.633 -		{
 548.634 -			CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));
 548.635 -
 548.636 -			AccelsDatasArray.Append(CmdDatasArray);
 548.637 -			iCount++;
 548.638 -		}
 548.639 -	}
 548.640 -	//  AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
 548.641 -
 548.642 -	int    count = AccelsDatasArray.GetSize();
 548.643 -	DWORD *data  = (DWORD *)malloc(count * sizeof(DWORD));
 548.644 -	ASSERT(data != NULL);
 548.645 -
 548.646 -	for (int index = 0; index < count; index++)
 548.647 -		data[index] = AccelsDatasArray[index];
 548.648 -
 548.649 -	regSetBinaryValue("keyboard", (char *)data, count*sizeof(DWORD));
 548.650 -
 548.651 -	AccelsDatasArray.RemoveAll();
 548.652 -	CmdDatasArray.RemoveAll();
 548.653 -
 548.654 -	free(data);
 548.655 -
 548.656 -	return true;
 548.657 -}
 548.658 -
 548.659 -//////////////////////////////////////////////////////////////////////
 548.660 -// Defaults values management.
 548.661 -//
 548.662 -bool CAcceleratorManager::CreateDefaultTable()
 548.663 -{
 548.664 -	if (m_bDefaultTable)
 548.665 -		return false;
 548.666 -
 548.667 -	CCmdAccelOb*pCmdAccel;
 548.668 -	CCmdAccelOb*pNewCmdAccel;
 548.669 -
 548.670 -	CAccelsOb*pAccel;
 548.671 -	CAccelsOb*pNewAccel;
 548.672 -
 548.673 -	WORD     wKey;
 548.674 -	POSITION pos = m_mapAccelTable.GetStartPosition();
 548.675 -	while (pos != NULL)
 548.676 -	{
 548.677 -		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 548.678 -		pNewCmdAccel = new CCmdAccelOb;
 548.679 -		ASSERT(pNewCmdAccel != NULL);
 548.680 -
 548.681 -		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 548.682 -		while (pos != NULL)
 548.683 -		{
 548.684 -			pAccel = pCmdAccel->m_Accels.GetNext(pos);
 548.685 -			if (!pAccel->m_bLocked)
 548.686 -			{
 548.687 -				pNewAccel = new CAccelsOb;
 548.688 -				ASSERT(pNewAccel != NULL);
 548.689 -
 548.690 -				*pNewAccel = *pAccel;
 548.691 -				pNewCmdAccel->m_Accels.AddTail(pNewAccel);
 548.692 -			}
 548.693 -		}
 548.694 -		if (pNewCmdAccel->m_Accels.GetCount() != 0)
 548.695 -		{
 548.696 -			pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand;
 548.697 -			pNewCmdAccel->m_szCommand  = pCmdAccel->m_szCommand;
 548.698 -
 548.699 -			m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
 548.700 -		}
 548.701 -		else
 548.702 -			delete pNewCmdAccel;
 548.703 -	}
 548.704 -
 548.705 -	m_bDefaultTable = true;
 548.706 -	return true;
 548.707 -}
 548.708 -
 548.709 -#include "mainwnd.h"
 548.710 -bool CAcceleratorManager::Default()
 548.711 -{
 548.712 -	/// this is NYI for some reason, so the "Reset All" button doesn't work
 548.713 -
 548.714 -#if 0
 548.715 -	// still doesn't work:
 548.716 -    Reset();
 548.717 -    regDeleteValue("keyboard");
 548.718 -    regDeleteValue("keyboardCount");
 548.719 -    Connect((MainWnd *)theApp.m_pMainWnd);
 548.720 -    extern void winAccelAddCommands(CAcceleratorManager& mgr);
 548.721 -    Load();
 548.722 -    CreateDefaultTable();
 548.723 -    winAccelAddCommands(*this);
 548.724 -    UpdateWndTable();
 548.725 -    Write();
 548.726 -    UpdateMenu(theApp.menu);
 548.727 -    m_pWndConnected = NULL;
 548.728 -#endif
 548.729 -
 548.730 -	return true;
 548.731 -}
 548.732 -
   549.1 --- a/src/win32/AcceleratorManager.h	Sat Mar 03 10:54:39 2012 -0600
   549.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   549.3 @@ -1,135 +0,0 @@
   549.4 -////////////////////////////////////////////////////////////////////////////////
   549.5 -// Copyright (C) 1998 by Thierry Maurel
   549.6 -// All rights reserved
   549.7 -//
   549.8 -// Distribute freely, except: don't remove my name from the source or
   549.9 -// documentation (don't take credit for my work), mark your changes (don't
  549.10 -// get me blamed for your possible bugs), don't alter or remove this
  549.11 -// notice.
  549.12 -// No warrantee of any kind, express or implied, is included with this
  549.13 -// software; use at your own risk, responsibility for damages (if any) to
  549.14 -// anyone resulting from the use of this software rests entirely with the
  549.15 -// user.
  549.16 -//
  549.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  549.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  549.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  549.20 -//
  549.21 -////////////////////////////////////////////////////////////////////////////////
  549.22 -// File    : AcceleratorManager.h
  549.23 -// Project : AccelsEditor
  549.24 -////////////////////////////////////////////////////////////////////////////////
  549.25 -// Version : 1.0                       * Author : T.Maurel
  549.26 -// Date    : 17.08.98
  549.27 -//
  549.28 -// Remarks : interface for the CAcceleratorManager class.
  549.29 -//
  549.30 -////////////////////////////////////////////////////////////////////////////////
  549.31 -#if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
  549.32 -#define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_
  549.33 -
  549.34 -#if _MSC_VER >= 1000
  549.35 -#pragma once
  549.36 -#endif // _MSC_VER >= 1000
  549.37 -
  549.38 -#include "afxtempl.h"
  549.39 -
  549.40 -class CCmdAccelOb;
  549.41 -
  549.42 -// Helper map
  549.43 -#ifndef CMapStringToWord
  549.44 -typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord;
  549.45 -#endif
  549.46 -
  549.47 -#ifndef CMapWordToCCmdAccelOb
  549.48 -typedef CMap< WORD, WORD &, CCmdAccelOb *, CCmdAccelOb * & > CMapWordToCCmdAccelOb;
  549.49 -#endif
  549.50 -
  549.51 -////////////////////////////////////////////////////////////////////////////////
  549.52 -// All Registry stuff removed
  549.53 -
  549.54 -class CAcceleratorManager : public CObject
  549.55 -{
  549.56 -	friend class AccelEditor;
  549.57 -public:
  549.58 -	CAcceleratorManager();
  549.59 -	virtual ~CAcceleratorManager();
  549.60 -
  549.61 -	// Operations
  549.62 -public:
  549.63 -	void UpdateMenu(HMENU menu);
  549.64 -	// Connection to the main application wnd
  549.65 -	void Connect(CWnd *pWnd, bool bAutoSave = true);
  549.66 -	// In/Out
  549.67 -	bool Load();
  549.68 -	bool Write();
  549.69 -	// Get the initials accels, not the user's
  549.70 -	bool Default();
  549.71 -	// Save a copy in the 2 maps called xxxSaved, which are used in case
  549.72 -	// of Default(), to reload the defaults accels.
  549.73 -	bool CreateDefaultTable();
  549.74 -	bool IsDefaultTableAvailable() {return m_bDefaultTable;}
  549.75 -	bool IsMapStringCommandsEmpty()
  549.76 -	{
  549.77 -		if (m_mapAccelString.IsEmpty())
  549.78 -			return true;
  549.79 -		else
  549.80 -			return false;
  549.81 -	}
  549.82 -
  549.83 -	bool IsAutoSave() {return m_bAutoSave;}
  549.84 -	void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;}
  549.85 -
  549.86 -	// Helper fct, used for new menus strings
  549.87 -	bool GetStringFromACCEL(ACCEL*pACCEL, CString& szAccel);
  549.88 -	bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
  549.89 -
  549.90 -	// Update the ACCELS table in the application, from the specified
  549.91 -	// datas in the manager.
  549.92 -	bool UpdateWndTable();
  549.93 -
  549.94 -	// Modification helper fcts
  549.95 -	bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract,
  549.96 -	              LPCTSTR szCommand, bool bLocked = false);
  549.97 -	bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
  549.98 -	bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
  549.99 -
 549.100 -	bool DeleteEntry(LPCTSTR szCommand);
 549.101 -	bool DeleteEntry(WORD wIDCommand);
 549.102 -	bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
 549.103 -
 549.104 -	// Affectation operator
 549.105 -	CAcceleratorManager & operator=(const CAcceleratorManager& accelmgr);
 549.106 -public:
 549.107 -#ifdef _DEBUG
 549.108 -	virtual void AssertValid() const;
 549.109 -	virtual void Dump(CDumpContext& dc) const;
 549.110 -#endif
 549.111 -protected:
 549.112 -	// Erase all the datas
 549.113 -	void Reset();
 549.114 -	// Internal affect fct.
 549.115 -	bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey,
 549.116 -	              LPCTSTR szCommand, bool bLocked);
 549.117 -
 549.118 -	// Attributes
 549.119 -protected:
 549.120 -	CWnd *m_pWndConnected;
 549.121 -
 549.122 -	// User datas
 549.123 -/*TEMP HACK*/
 549.124 -public:
 549.125 -	CMapStringToWord m_mapAccelString;
 549.126 -/*TEMP HACK*/
 549.127 -public:
 549.128 -	CMapWordToCCmdAccelOb m_mapAccelTable;
 549.129 -protected:
 549.130 -	// Default datas
 549.131 -	CMapWordToCCmdAccelOb m_mapAccelTableSaved;
 549.132 -	bool m_bDefaultTable;
 549.133 -
 549.134 -	// if true, there is an auto-save, when the destructor is called
 549.135 -	bool m_bAutoSave;
 549.136 -};
 549.137 -
 549.138 -#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
   550.1 --- a/src/win32/Associate.cpp	Sat Mar 03 10:54:39 2012 -0600
   550.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   550.3 @@ -1,105 +0,0 @@
   550.4 -// Associate.cpp : implementation file
   550.5 -//
   550.6 -
   550.7 -#include "stdafx.h"
   550.8 -#include "resource.h"
   550.9 -#include "Associate.h"
  550.10 -#include "Reg.h"
  550.11 -
  550.12 -/////////////////////////////////////////////////////////////////////////////
  550.13 -// Associate dialog
  550.14 -
  550.15 -Associate::Associate(CWnd*pParent /*=NULL*/)
  550.16 -	: CDialog(Associate::IDD, pParent)
  550.17 -{
  550.18 -	//{{AFX_DATA_INIT(Associate)
  550.19 -	m_agb = FALSE;
  550.20 -	m_bin = FALSE;
  550.21 -	m_cgb = FALSE;
  550.22 -	m_gb  = FALSE;
  550.23 -	m_gba = FALSE;
  550.24 -	m_gbc = FALSE;
  550.25 -	m_sgb = FALSE;
  550.26 -	//}}AFX_DATA_INIT
  550.27 -}
  550.28 -
  550.29 -void Associate::DoDataExchange(CDataExchange*pDX)
  550.30 -{
  550.31 -	CDialog::DoDataExchange(pDX);
  550.32 -	//{{AFX_DATA_MAP(Associate)
  550.33 -	DDX_Check(pDX, IDC_AGB, m_agb);
  550.34 -	DDX_Check(pDX, IDC_BIN, m_bin);
  550.35 -	DDX_Check(pDX, IDC_CGB, m_cgb);
  550.36 -	DDX_Check(pDX, IDC_GB, m_gb);
  550.37 -	DDX_Check(pDX, IDC_GBA, m_gba);
  550.38 -	DDX_Check(pDX, IDC_GBC, m_gbc);
  550.39 -	DDX_Check(pDX, IDC_SGB, m_sgb);
  550.40 -	//}}AFX_DATA_MAP
  550.41 -}
  550.42 -
  550.43 -BEGIN_MESSAGE_MAP(Associate, CDialog)
  550.44 -//{{AFX_MSG_MAP(Associate)
  550.45 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  550.46 -ON_BN_CLICKED(ID_OK, OnOk)
  550.47 -//}}AFX_MSG_MAP
  550.48 -END_MESSAGE_MAP()
  550.49 -
  550.50 -/////////////////////////////////////////////////////////////////////////////
  550.51 -// Associate message handlers
  550.52 -
  550.53 -BOOL Associate::OnInitDialog()
  550.54 -{
  550.55 -	CDialog::OnInitDialog();
  550.56 -
  550.57 -	CenterWindow();
  550.58 -
  550.59 -	return TRUE; // return TRUE unless you set the focus to a control
  550.60 -	             // EXCEPTION: OCX Property Pages should return FALSE
  550.61 -}
  550.62 -
  550.63 -void Associate::OnCancel()
  550.64 -{
  550.65 -	EndDialog(FALSE);
  550.66 -}
  550.67 -
  550.68 -void Associate::OnOk()
  550.69 -{
  550.70 -	UpdateData();
  550.71 -
  550.72 -	int mask = 0;
  550.73 -	if (m_gb)
  550.74 -		mask |= 1;
  550.75 -	if (m_sgb)
  550.76 -		mask |= 2;
  550.77 -	if (m_cgb)
  550.78 -		mask |= 4;
  550.79 -	if (m_gbc)
  550.80 -		mask |= 8;
  550.81 -	if (m_gba)
  550.82 -		mask |= 16;
  550.83 -	if (m_agb)
  550.84 -		mask |= 32;
  550.85 -	if (m_bin)
  550.86 -		mask |= 64;
  550.87 -	if (mask)
  550.88 -	{
  550.89 -		char    applicationPath[2048];
  550.90 -		CString commandPath;
  550.91 -		LPCTSTR types[] = { ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
  550.92 -		GetModuleFileName(NULL, applicationPath, 2048);
  550.93 -		commandPath.Format("\"%s\" \"%%1\"", applicationPath);
  550.94 -		regAssociateType("VisualBoyAdvance.Binary",
  550.95 -		                 "Binary",
  550.96 -		                 commandPath);
  550.97 -
  550.98 -		for (int i = 0; i < 7; i++)
  550.99 -		{
 550.100 -			if (mask & (1<<i))
 550.101 -			{
 550.102 -				regCreateFileType(types[i], "VisualBoyAdvance.Binary");
 550.103 -			}
 550.104 -		}
 550.105 -	}
 550.106 -	EndDialog(TRUE);
 550.107 -}
 550.108 -
   551.1 --- a/src/win32/Associate.h	Sat Mar 03 10:54:39 2012 -0600
   551.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   551.3 @@ -1,52 +0,0 @@
   551.4 -#if !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_)
   551.5 -#define AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_
   551.6 -
   551.7 -#if _MSC_VER > 1000
   551.8 -#pragma once
   551.9 -#endif // _MSC_VER > 1000
  551.10 -// Associate.h : header file
  551.11 -//
  551.12 -
  551.13 -/////////////////////////////////////////////////////////////////////////////
  551.14 -// Associate dialog
  551.15 -
  551.16 -class Associate : public CDialog
  551.17 -{
  551.18 -	// Construction
  551.19 -public:
  551.20 -	Associate(CWnd*pParent = NULL);  // standard constructor
  551.21 -
  551.22 -	// Dialog Data
  551.23 -	//{{AFX_DATA(Associate)
  551.24 -	enum { IDD = IDD_ASSOCIATIONS };
  551.25 -	BOOL m_agb;
  551.26 -	BOOL m_bin;
  551.27 -	BOOL m_cgb;
  551.28 -	BOOL m_gb;
  551.29 -	BOOL m_gba;
  551.30 -	BOOL m_gbc;
  551.31 -	BOOL m_sgb;
  551.32 -	//}}AFX_DATA
  551.33 -
  551.34 -	// Overrides
  551.35 -	// ClassWizard generated virtual function overrides
  551.36 -	//{{AFX_VIRTUAL(Associate)
  551.37 -protected:
  551.38 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  551.39 -	//}}AFX_VIRTUAL
  551.40 -
  551.41 -	// Implementation
  551.42 -protected:
  551.43 -	// Generated message map functions
  551.44 -	//{{AFX_MSG(Associate)
  551.45 -	virtual BOOL OnInitDialog();
  551.46 -	afx_msg void OnCancel();
  551.47 -	afx_msg void OnOk();
  551.48 -	//}}AFX_MSG
  551.49 -	DECLARE_MESSAGE_MAP()
  551.50 -};
  551.51 -
  551.52 -//{{AFX_INSERT_LOCATION}}
  551.53 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  551.54 -
  551.55 -#endif // !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_)
   552.1 --- a/src/win32/BitmapControl.cpp	Sat Mar 03 10:54:39 2012 -0600
   552.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   552.3 @@ -1,262 +0,0 @@
   552.4 -// BitmapControl.cpp : implementation file
   552.5 -//
   552.6 -
   552.7 -#include "stdafx.h"
   552.8 -#include "BitmapControl.h"
   552.9 -
  552.10 -bool BitmapControl::isRegistered = false;
  552.11 -
  552.12 -/////////////////////////////////////////////////////////////////////////////
  552.13 -// BitmapControl
  552.14 -
  552.15 -IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
  552.16 -
  552.17 -  BitmapControl::BitmapControl()
  552.18 -{
  552.19 -  w = 0;
  552.20 -  h = 0;
  552.21 -  data = NULL;
  552.22 -  bmpInfo = NULL;
  552.23 -  stretch = false;
  552.24 -  registerClass();
  552.25 -  CSize sizeTotal;
  552.26 -  sizeTotal.cx = sizeTotal.cy = 0;
  552.27 -  SetScrollSizes(MM_TEXT, sizeTotal);
  552.28 -}
  552.29 -
  552.30 -BitmapControl::~BitmapControl()
  552.31 -{
  552.32 -}
  552.33 -
  552.34 -
  552.35 -BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
  552.36 -  //{{AFX_MSG_MAP(BitmapControl)
  552.37 -  ON_WM_ERASEBKGND()
  552.38 -  ON_WM_SIZE()
  552.39 -  ON_WM_LBUTTONDOWN()
  552.40 -  //}}AFX_MSG_MAP
  552.41 -  END_MESSAGE_MAP()
  552.42 -
  552.43 -  /////////////////////////////////////////////////////////////////////////////
  552.44 -// BitmapControl drawing
  552.45 -
  552.46 -void BitmapControl::OnInitialUpdate()
  552.47 -{
  552.48 -  CScrollView::OnInitialUpdate();
  552.49 -
  552.50 -  CSize sizeTotal;
  552.51 -  // TODO: calculate the total size of this view
  552.52 -  sizeTotal.cx = sizeTotal.cy = 100;
  552.53 -  SetScrollSizes(MM_TEXT, sizeTotal);
  552.54 -}
  552.55 -
  552.56 -void BitmapControl::OnDraw(CDC* dc)
  552.57 -{
  552.58 -  RECT r;
  552.59 -  GetClientRect(&r);
  552.60 -  int w1 = r.right - r.left;
  552.61 -  int h1 = r.bottom - r.top;
  552.62 -  CDC memDC;
  552.63 -  memDC.CreateCompatibleDC(dc);
  552.64 -  if(!stretch) {
  552.65 -    if(w > w1)
  552.66 -      w1 = w;
  552.67 -    if(h > h1)
  552.68 -      h1 = h;
  552.69 -  }
  552.70 -  CBitmap bitmap, *pOldBitmap;
  552.71 -  bitmap.CreateCompatibleBitmap(dc, w1, h1);
  552.72 -  pOldBitmap = memDC.SelectObject(&bitmap);
  552.73 -  if(stretch) {
  552.74 -    bmpInfo->bmiHeader.biWidth = w;
  552.75 -    bmpInfo->bmiHeader.biHeight = -h;
  552.76 -    
  552.77 -    StretchDIBits(memDC.GetSafeHdc(),
  552.78 -                  0,
  552.79 -                  0,
  552.80 -                  w1,
  552.81 -                  h1, 
  552.82 -                  0,
  552.83 -                  0,
  552.84 -                  w,
  552.85 -                  h,
  552.86 -                  data,
  552.87 -                  bmpInfo,
  552.88 -                  DIB_RGB_COLORS,
  552.89 -                  SRCCOPY);
  552.90 -  } else {
  552.91 -    FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
  552.92 -    
  552.93 -    bmpInfo->bmiHeader.biWidth = w;
  552.94 -    bmpInfo->bmiHeader.biHeight = -h;
  552.95 -    SetDIBitsToDevice(memDC.GetSafeHdc(),
  552.96 -                      0,
  552.97 -                      0,
  552.98 -                      w,
  552.99 -                      h,
 552.100 -                      0,
 552.101 -                      0,
 552.102 -                      0,
 552.103 -                      h,
 552.104 -                      data,
 552.105 -                      bmpInfo,
 552.106 -                      DIB_RGB_COLORS);
 552.107 -  }
 552.108 -
 552.109 -  dc->BitBlt(0,0,w1,h1,
 552.110 -             &memDC,0,0,SRCCOPY);
 552.111 -  memDC.SelectObject(pOldBitmap);
 552.112 -
 552.113 -  bitmap.DeleteObject();
 552.114 -  memDC.DeleteDC();  
 552.115 -}
 552.116 -
 552.117 -/////////////////////////////////////////////////////////////////////////////
 552.118 -// BitmapControl diagnostics
 552.119 -
 552.120 -#ifdef _DEBUG
 552.121 -void BitmapControl::AssertValid() const
 552.122 -{
 552.123 -  CScrollView::AssertValid();
 552.124 -}
 552.125 -
 552.126 -void BitmapControl::Dump(CDumpContext& dc) const
 552.127 -{
 552.128 -  CScrollView::Dump(dc);
 552.129 -}
 552.130 -#endif //_DEBUG
 552.131 -
 552.132 -/////////////////////////////////////////////////////////////////////////////
 552.133 -// BitmapControl message handlers
 552.134 -
 552.135 -BOOL BitmapControl::OnEraseBkgnd(CDC* pDC) 
 552.136 -{
 552.137 -  return TRUE;
 552.138 -}
 552.139 -
 552.140 -void BitmapControl::OnSize(UINT nType, int cx, int cy) 
 552.141 -{
 552.142 -  if(!stretch)
 552.143 -    CScrollView::OnSize(nType, cx, cy);
 552.144 -}
 552.145 -
 552.146 -void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt) 
 552.147 -{
 552.148 -  if(!data)
 552.149 -    return;
 552.150 -  int x = pt.x;
 552.151 -  int y = pt.y;
 552.152 -
 552.153 -  WPARAM point;
 552.154 -  
 552.155 -  if(stretch) {
 552.156 -    RECT rect;
 552.157 -    GetClientRect(&rect);
 552.158 -  
 552.159 -    int height = rect.bottom - rect.top;
 552.160 -    int width = rect.right - rect.left;
 552.161 -  
 552.162 -    int xx = (x * w) / width;
 552.163 -    int yy = (y * h) / height;
 552.164 -
 552.165 -    point = xx | (yy<<16);
 552.166 -
 552.167 -    int xxx = xx / 8;
 552.168 -    int yyy = yy / 8;
 552.169 -
 552.170 -    for(int i = 0; i < 8; i++) {
 552.171 -      memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
 552.172 -                                   w * yyy * 8 * 3 +
 552.173 -                                   i * w * 3], 8 * 3);
 552.174 -    }
 552.175 -  } else {
 552.176 -    POINT p;
 552.177 -    p.x = GetScrollPos(SB_HORZ);
 552.178 -    p.y = GetScrollPos(SB_VERT);
 552.179 -
 552.180 -    p.x += x;
 552.181 -    p.y += y;
 552.182 -
 552.183 -    if(p.x >= w ||
 552.184 -       p.y >= h)
 552.185 -      return;
 552.186 -
 552.187 -    point = p.x | (p.y<<16);
 552.188 -    
 552.189 -    int xxx = p.x / 8;
 552.190 -    int yyy = p.y / 8;
 552.191 -
 552.192 -    for(int i = 0; i < 8; i++) {
 552.193 -      memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
 552.194 -                                   w * yyy * 8 * 3 +
 552.195 -                                   i * w * 3], 8 * 3);
 552.196 -    }
 552.197 -  }
 552.198 -  
 552.199 -  GetParent()->SendMessage(WM_MAPINFO,
 552.200 -                           point,
 552.201 -                           (LPARAM)colors);
 552.202 -}
 552.203 -
 552.204 -void BitmapControl::setBmpInfo(BITMAPINFO *info)
 552.205 -{
 552.206 -  bmpInfo = info;
 552.207 -}
 552.208 -
 552.209 -void BitmapControl::setData(u8 *d)
 552.210 -{
 552.211 -  data = d;
 552.212 -}
 552.213 -
 552.214 -void BitmapControl::setSize(int w1, int h1)
 552.215 -{
 552.216 -  if(w != w1 || h != h1) {
 552.217 -    w = w1;
 552.218 -    h = h1;
 552.219 -    SIZE s;
 552.220 -    s.cx = w;
 552.221 -    s.cy = h;
 552.222 -    SetScrollSizes(MM_TEXT, s);
 552.223 -  }
 552.224 -}
 552.225 -
 552.226 -void BitmapControl::refresh()
 552.227 -{
 552.228 -  Invalidate();
 552.229 -}
 552.230 -
 552.231 -
 552.232 -void BitmapControl::registerClass()
 552.233 -{
 552.234 -  if(!isRegistered) {
 552.235 -    WNDCLASS wc;
 552.236 -    ZeroMemory(&wc, sizeof(wc));
 552.237 -    wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
 552.238 -    wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
 552.239 -    wc.hInstance = AfxGetInstanceHandle();
 552.240 -    wc.hIcon = NULL;
 552.241 -    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
 552.242 -    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
 552.243 -    wc.lpszMenuName = NULL;
 552.244 -    wc.lpszClassName = "VbaBitmapControl";
 552.245 -    AfxRegisterClass(&wc);
 552.246 -    isRegistered = true;
 552.247 -  }
 552.248 -}
 552.249 -
 552.250 -void BitmapControl::setStretch(bool b)
 552.251 -{
 552.252 -  if(b != stretch) {
 552.253 -    stretch = b;
 552.254 -    Invalidate();
 552.255 -  }
 552.256 -}
 552.257 -
 552.258 -bool BitmapControl::getStretch()
 552.259 -{
 552.260 -  return stretch;
 552.261 -}
 552.262 -
 552.263 -void BitmapControl::PostNcDestroy() 
 552.264 -{
 552.265 -}
   553.1 --- a/src/win32/BitmapControl.h	Sat Mar 03 10:54:39 2012 -0600
   553.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   553.3 @@ -1,75 +0,0 @@
   553.4 -#if !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_)
   553.5 -#define AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_
   553.6 -
   553.7 -#if _MSC_VER > 1000
   553.8 -#pragma once
   553.9 -#endif // _MSC_VER > 1000
  553.10 -// BitmapControl.h : header file
  553.11 -//
  553.12 -#ifndef WM_MAPINFO
  553.13 -#define WM_MAPINFO WM_APP+101
  553.14 -#endif
  553.15 -
  553.16 -/////////////////////////////////////////////////////////////////////////////
  553.17 -// BitmapControl view
  553.18 -
  553.19 -class BitmapControl : public CScrollView
  553.20 -{
  553.21 -public:
  553.22 -	BitmapControl();         // protected constructor used by dynamic creation
  553.23 -protected:
  553.24 -	DECLARE_DYNCREATE(BitmapControl)
  553.25 -
  553.26 -	// Attributes
  553.27 -public:
  553.28 -	// Operations
  553.29 -public:
  553.30 -	void setStretch(bool b);
  553.31 -	void refresh();
  553.32 -	void setSize(int w1, int h1);
  553.33 -	void setData(u8 *d);
  553.34 -	void setBmpInfo(BITMAPINFO *info);
  553.35 -	static bool isRegistered;
  553.36 -
  553.37 -	// Overrides
  553.38 -	// ClassWizard generated virtual function overrides
  553.39 -	//{{AFX_VIRTUAL(BitmapControl)
  553.40 -protected:
  553.41 -	virtual void OnDraw(CDC*pDC);     // overridden to draw this view
  553.42 -	virtual void OnInitialUpdate();   // first time after construct
  553.43 -	virtual void PostNcDestroy();
  553.44 -	//}}AFX_VIRTUAL
  553.45 -
  553.46 -	// Implementation
  553.47 -public:
  553.48 -	bool getStretch();
  553.49 -	virtual ~BitmapControl();
  553.50 -protected:
  553.51 -#ifdef _DEBUG
  553.52 -	virtual void AssertValid() const;
  553.53 -	virtual void Dump(CDumpContext& dc) const;
  553.54 -#endif
  553.55 -
  553.56 -	// Generated message map functions
  553.57 -	//{{AFX_MSG(BitmapControl)
  553.58 -	afx_msg BOOL OnEraseBkgnd(CDC*pDC);
  553.59 -	afx_msg void OnSize(UINT nType, int cx, int cy);
  553.60 -	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  553.61 -	//}}AFX_MSG
  553.62 -	DECLARE_MESSAGE_MAP()
  553.63 -private:
  553.64 -	void registerClass();
  553.65 -	bool        stretch;
  553.66 -	u8          colors[3*64];
  553.67 -	BITMAPINFO *bmpInfo;
  553.68 -	u8 *        data;
  553.69 -	int         h;
  553.70 -	int         w;
  553.71 -};
  553.72 -
  553.73 -/////////////////////////////////////////////////////////////////////////////
  553.74 -
  553.75 -//{{AFX_INSERT_LOCATION}}
  553.76 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  553.77 -
  553.78 -#endif // !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_)
   554.1 --- a/src/win32/BugReport.cpp	Sat Mar 03 10:54:39 2012 -0600
   554.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   554.3 @@ -1,235 +0,0 @@
   554.4 -// BugReport.cpp : implementation file
   554.5 -//
   554.6 -
   554.7 -#include "stdafx.h"
   554.8 -#include "resource.h"
   554.9 -#include "BugReport.h"
  554.10 -#include "VBA.h"
  554.11 -
  554.12 -#include "../version.h"
  554.13 -#include "../gba/agbprint.h"
  554.14 -#include "../gba/Flash.h"
  554.15 -#include "../gba/GBACheats.h"
  554.16 -#include "../gba/GBAGlobals.h"
  554.17 -#include "../gb/gbCheats.h"
  554.18 -#include "../gb/gbGlobals.h"
  554.19 -#include "../gba/RTC.h"
  554.20 -#include "../gba/GBASound.h"
  554.21 -#include "../common/vbalua.h"
  554.22 -
  554.23 -/////////////////////////////////////////////////////////////////////////////
  554.24 -// BugReport dialog
  554.25 -
  554.26 -BugReport::BugReport(CWnd*pParent /*=NULL*/)
  554.27 -	: CDialog(BugReport::IDD, pParent)
  554.28 -{
  554.29 -	//{{AFX_DATA_INIT(BugReport)
  554.30 -	// NOTE: the ClassWizard will add member initialization here
  554.31 -	//}}AFX_DATA_INIT
  554.32 -}
  554.33 -
  554.34 -void BugReport::DoDataExchange(CDataExchange*pDX)
  554.35 -{
  554.36 -	CDialog::DoDataExchange(pDX);
  554.37 -	//{{AFX_DATA_MAP(BugReport)
  554.38 -	DDX_Control(pDX, IDC_BUG_REPORT, m_report);
  554.39 -	//}}AFX_DATA_MAP
  554.40 -}
  554.41 -
  554.42 -BEGIN_MESSAGE_MAP(BugReport, CDialog)
  554.43 -//{{AFX_MSG_MAP(BugReport)
  554.44 -ON_BN_CLICKED(IDC_COPY, OnCopy)
  554.45 -ON_BN_CLICKED(ID_OK, OnOk)
  554.46 -//}}AFX_MSG_MAP
  554.47 -END_MESSAGE_MAP()
  554.48 -
  554.49 -/////////////////////////////////////////////////////////////////////////////
  554.50 -// BugReport message handlers
  554.51 -
  554.52 -void BugReport::OnCopy()
  554.53 -{
  554.54 -	OpenClipboard();
  554.55 -
  554.56 -	EmptyClipboard();
  554.57 -	CString report;
  554.58 -	m_report.GetWindowText(report);
  554.59 -
  554.60 -	HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
  554.61 -	                               (report.GetLength() + 1) * sizeof(CHAR));
  554.62 -	if (hglbCopy == NULL)
  554.63 -	{
  554.64 -		CloseClipboard();
  554.65 -		return;
  554.66 -	}
  554.67 -
  554.68 -	// Lock the handle and copy the text to the buffer.
  554.69 -
  554.70 -	LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
  554.71 -	memcpy(lptstrCopy, (const char *)report,
  554.72 -	       report.GetLength() * sizeof(CHAR));
  554.73 -	lptstrCopy[report.GetLength()] = (TCHAR) 0;  // null character
  554.74 -	GlobalUnlock(hglbCopy);
  554.75 -
  554.76 -	// Place the handle on the clipboard.
  554.77 -
  554.78 -	SetClipboardData(CF_TEXT, hglbCopy);
  554.79 -	CloseClipboard();
  554.80 -
  554.81 -	systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
  554.82 -}
  554.83 -
  554.84 -void BugReport::OnOk()
  554.85 -{
  554.86 -	EndDialog(TRUE);
  554.87 -}
  554.88 -
  554.89 -BOOL BugReport::OnInitDialog()
  554.90 -{
  554.91 -	CDialog::OnInitDialog();
  554.92 -
  554.93 -	CenterWindow();
  554.94 -
  554.95 -	CString report = createReport();
  554.96 -
  554.97 -	m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
  554.98 -
  554.99 -	m_report.SetWindowText(report);
 554.100 -
 554.101 -	return TRUE; // return TRUE unless you set the focus to a control
 554.102 -	// EXCEPTION: OCX Property Pages should return FALSE
 554.103 -}
 554.104 -
 554.105 -static void AppendFormat(CString& report, const char *format, ...)
 554.106 -{
 554.107 -	CString buffer;
 554.108 -	va_list valist;
 554.109 -
 554.110 -	va_start(valist, format);
 554.111 -	buffer.FormatV(format, valist);
 554.112 -	va_end(valist);
 554.113 -	report += buffer;
 554.114 -}
 554.115 -
 554.116 -CString BugReport::createReport()
 554.117 -{
 554.118 -	theApp.winCheckFullscreen();
 554.119 -
 554.120 -	CString report = "";
 554.121 -	AppendFormat(report, "Emu version  : %s\r\n", VBA_VERSION_STRING);
 554.122 -AppendFormat(report, "Emu type     : %s\r\n", VBA_BUILDTYPE_STRING);
 554.123 -
 554.124 -	if (systemIsEmulating())
 554.125 -	{
 554.126 -		AppendFormat(report, "Game         : %s\r\n", theApp.gameFilename);
 554.127 -
 554.128 -		char buffer[20];
 554.129 -		if (systemCartridgeType == 0)
 554.130 -		{
 554.131 -			u32 check = 0;
 554.132 -			for (int i = 0; i < 0x4000; i += 4)
 554.133 -			{
 554.134 -				check += *((u32 *)&bios[i]);
 554.135 -			}
 554.136 -			AppendFormat(report, "BIOS checksum: %08X\r\n", check);
 554.137 -
 554.138 -			strncpy(buffer, (const char *)&rom[0xa0], 12);
 554.139 -			buffer[12] = 0;
 554.140 -			AppendFormat(report, "Internal name: %s\r\n", buffer);
 554.141 -
 554.142 -			strncpy(buffer, (const char *)&rom[0xac], 4);
 554.143 -			buffer[4] = 0;
 554.144 -			AppendFormat(report, "Game code    : %s\r\n", buffer);
 554.145 -
 554.146 -			CString res = "";
 554.147 -			u32 *   p   = (u32 *)rom;
 554.148 -			u32 *   end = (u32 *)((char *)rom+theApp.romSize);
 554.149 -			while (p  < end)
 554.150 -			{
 554.151 -				u32 d = READ32LE(p);
 554.152 -
 554.153 -				if (d == 0x52504545)
 554.154 -				{
 554.155 -					if (memcmp(p, "EEPROM_", 7) == 0)
 554.156 -					{
 554.157 -						res += (const char *)p;
 554.158 -						res += ' ';
 554.159 -					}
 554.160 -				}
 554.161 -				else if (d == 0x4D415253)
 554.162 -				{
 554.163 -					if (memcmp(p, "SRAM_", 5) == 0)
 554.164 -					{
 554.165 -						res += (const char *)p;
 554.166 -						res += ' ';
 554.167 -					}
 554.168 -				}
 554.169 -				else if (d == 0x53414C46)
 554.170 -				{
 554.171 -					if (memcmp(p, "FLASH1M_", 8) == 0)
 554.172 -					{
 554.173 -						res += (const char *)p;
 554.174 -						res += ' ';
 554.175 -					}
 554.176 -				}
 554.177 -				else if (memcmp(p, "FLASH", 5) == 0)
 554.178 -				{
 554.179 -					res += (const char *)p;
 554.180 -					res += ' ';
 554.181 -				}
 554.182 -				else if (d == 0x52494953)
 554.183 -				{
 554.184 -					if (memcmp(p, "SIIRTC_V", 8) == 0)
 554.185 -					{
 554.186 -						res += (const char *)p;
 554.187 -						res += ' ';
 554.188 -					}
 554.189 -				}
 554.190 -				p++;
 554.191 -			}
 554.192 -			if (res.GetLength() > 0)
 554.193 -				AppendFormat(report, "Cart Save    : %s\r\n", res);
 554.194 -		}
 554.195 -		else if (systemCartridgeType == 1)
 554.196 -		{
 554.197 -			strncpy(buffer, (const char *)&gbRom[0x134], 15);
 554.198 -			buffer[15] = 0;
 554.199 -			AppendFormat(report, "Game title   : %s\r\n", buffer);
 554.200 -		}
 554.201 -	}
 554.202 -
 554.203 -	AppendFormat(report, "Using BIOS   : %d\r\n", useBios);
 554.204 -	AppendFormat(report, "Skip BIOS    : %d\r\n", theApp.skipBiosFile);
 554.205 -	AppendFormat(report, "Disable SFX  : %d\r\n", cpuDisableSfx);
 554.206 -///  AppendFormat(report, "Skip intro   : %d\r\n", theApp.removeIntros);
 554.207 -	AppendFormat(report, "Throttle     : %d\r\n", theApp.throttle);
 554.208 -	AppendFormat(report, "Rewind       : %d\r\n", theApp.rewindTimer);
 554.209 -	AppendFormat(report, "Lua          : %d\r\n", VBALuaRunning());
 554.210 -///  AppendFormat(report, "Auto frame   : %d\r\n", theApp.autoFrameSkip);
 554.211 -	AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
 554.212 -	AppendFormat(report, "Render type  : %d\r\n", theApp.renderMethod);
 554.213 -	AppendFormat(report, "Color depth  : %d\r\n", systemColorDepth);
 554.214 -	AppendFormat(report, "Red shift    : %08x\r\n", systemRedShift);
 554.215 -	AppendFormat(report, "Green shift  : %08x\r\n", systemGreenShift);
 554.216 -	AppendFormat(report, "Blue shift   : %08x\r\n", systemBlueShift);
 554.217 -	AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
 554.218 -	AppendFormat(report, "Save type    : %d (%d)\r\n",
 554.219 -	             theApp.winSaveType, cpuSaveType);
 554.220 -	AppendFormat(report, "Flash size   : %08X (%08x)\r\n",
 554.221 -	             theApp.winFlashSize, flashSize);
 554.222 -	AppendFormat(report, "RTC          : %d (%d)\r\n", theApp.winRtcEnable,
 554.223 -	             rtcIsEnabled());
 554.224 -	AppendFormat(report, "AGBPrint     : %d\r\n", agbPrintIsEnabled());
 554.225 -	AppendFormat(report, "Turbo Mode   : %d\r\n", theApp.speedupToggle);
 554.226 -	AppendFormat(report, "Synchronize  : %d\r\n", synchronize);
 554.227 -	AppendFormat(report, "Sound OFF    : %d\r\n", soundOffFlag);
 554.228 -	AppendFormat(report, "Channels     : %04x\r\n", soundGetEnabledChannels() & 0x30f);
 554.229 -	AppendFormat(report, "Old Sync     : %d\r\n", theApp.useOldSync);
 554.230 -	AppendFormat(report, "Priority     : %d\r\n", theApp.threadPriority);
 554.231 -	AppendFormat(report, "Filters      : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
 554.232 -	AppendFormat(report, "Cheats       : %d\r\n", cheatsNumber);
 554.233 -	AppendFormat(report, "GB Cheats    : %d\r\n", gbCheatNumber);
 554.234 -	AppendFormat(report, "GB Emu Type  : %d\r\n", gbEmulatorType);
 554.235 -
 554.236 -	return report;
 554.237 -}
 554.238 -
   555.1 --- a/src/win32/BugReport.h	Sat Mar 03 10:54:39 2012 -0600
   555.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   555.3 @@ -1,48 +0,0 @@
   555.4 -#if !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_)
   555.5 -#define AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_
   555.6 -
   555.7 -#if _MSC_VER > 1000
   555.8 -#pragma once
   555.9 -#endif // _MSC_VER > 1000
  555.10 -// BugReport.h : header file
  555.11 -//
  555.12 -
  555.13 -/////////////////////////////////////////////////////////////////////////////
  555.14 -// BugReport dialog
  555.15 -
  555.16 -class BugReport : public CDialog
  555.17 -{
  555.18 -	// Construction
  555.19 -public:
  555.20 -	BugReport(CWnd*pParent = NULL);  // standard constructor
  555.21 -
  555.22 -	// Dialog Data
  555.23 -	//{{AFX_DATA(BugReport)
  555.24 -	enum { IDD = IDD_BUG_REPORT };
  555.25 -	CEdit m_report;
  555.26 -	//}}AFX_DATA
  555.27 -
  555.28 -	// Overrides
  555.29 -	// ClassWizard generated virtual function overrides
  555.30 -	//{{AFX_VIRTUAL(BugReport)
  555.31 -protected:
  555.32 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  555.33 -	//}}AFX_VIRTUAL
  555.34 -
  555.35 -	// Implementation
  555.36 -protected:
  555.37 -	CString createReport();
  555.38 -
  555.39 -	// Generated message map functions
  555.40 -	//{{AFX_MSG(BugReport)
  555.41 -	afx_msg void OnCopy();
  555.42 -	afx_msg void OnOk();
  555.43 -	virtual BOOL OnInitDialog();
  555.44 -	//}}AFX_MSG
  555.45 -	DECLARE_MESSAGE_MAP()
  555.46 -};
  555.47 -
  555.48 -//{{AFX_INSERT_LOCATION}}
  555.49 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  555.50 -
  555.51 -#endif // !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_)
   556.1 --- a/src/win32/CmdAccelOb.cpp	Sat Mar 03 10:54:39 2012 -0600
   556.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   556.3 @@ -1,539 +0,0 @@
   556.4 -////////////////////////////////////////////////////////////////////////////////
   556.5 -// Copyright (C) 1998 by Thierry Maurel
   556.6 -// All rights reserved
   556.7 -//
   556.8 -// Distribute freely, except: don't remove my name from the source or
   556.9 -// documentation (don't take credit for my work), mark your changes (don't
  556.10 -// get me blamed for your possible bugs), don't alter or remove this
  556.11 -// notice.
  556.12 -// No warrantee of any kind, express or implied, is included with this
  556.13 -// software; use at your own risk, responsibility for damages (if any) to
  556.14 -// anyone resulting from the use of this software rests entirely with the
  556.15 -// user.
  556.16 -//
  556.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  556.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  556.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  556.20 -//
  556.21 -////////////////////////////////////////////////////////////////////////////////
  556.22 -// File    : CmdAccelOb.cpp
  556.23 -// Project : AccelsEditor
  556.24 -////////////////////////////////////////////////////////////////////////////////
  556.25 -// Version : 1.0                       * Author : T.Maurel
  556.26 -// Date    : 17.08.98
  556.27 -//
  556.28 -// Remarks :
  556.29 -//
  556.30 -////////////////////////////////////////////////////////////////////////////////
  556.31 -// modified by the VBA-rr team
  556.32 -
  556.33 -#include "stdafx.h"
  556.34 -#include "CmdAccelOb.h"
  556.35 -
  556.36 -////////////////////////////////////////////////////////////////////////
  556.37 -//
  556.38 -//
  556.39 -MAPVIRTKEYS mapVirtKeys[] = {
  556.40 -	{ VK_LBUTTON,		 "LBUTTON"				},
  556.41 -	{ VK_RBUTTON,		 "RBUTTON"				},
  556.42 -	{ VK_CANCEL,		 "Cancel"				},
  556.43 -	{ VK_MBUTTON,		 "MBUTTON"				},
  556.44 -	{ VK_BACK,			 "Backspace"			},
  556.45 -	{ VK_TAB,			 "Tab"					},
  556.46 -	{ VK_CLEAR,			 "Clear"				},
  556.47 -	{ VK_RETURN,		 "Enter"				},
  556.48 -	{ VK_SHIFT,			 "Shift"				},
  556.49 -	{ VK_LSHIFT,		 "LShift"				},
  556.50 -	{ VK_RSHIFT,		 "RShift"				},
  556.51 -	{ VK_CONTROL,		 "Control"				},
  556.52 -	{ VK_LCONTROL,		 "LControl"				},
  556.53 -	{ VK_RCONTROL,		 "RControl"				},
  556.54 -	{ VK_MENU,			 "Alt"					},
  556.55 -	{ VK_LMENU,			 "LAlt"					},
  556.56 -	{ VK_RMENU,			 "RAlt"					},
  556.57 -	{ VK_PAUSE,			 "Pause"				},
  556.58 -	{ VK_CAPITAL,		 "Caps Lock"			},
  556.59 -	{ VK_ESCAPE,		 "Escape"				},
  556.60 -	{ VK_SPACE,			 "Space"				},
  556.61 -	{ VK_PRIOR,			 "Prior"				},
  556.62 -	{ VK_NEXT,			 "Next"					},
  556.63 -	{ VK_END,			 "End"					},
  556.64 -	{ VK_HOME,			 "Home"					},
  556.65 -	{ VK_LEFT,			 "Left"					},
  556.66 -	{ VK_UP,			 "Up"					},
  556.67 -	{ VK_RIGHT,			 "Right"				},
  556.68 -	{ VK_DOWN,			 "Down"					},
  556.69 -	{ VK_SELECT,		 "Select"				},
  556.70 -	{ VK_PRINT,			 "Print"				},
  556.71 -	{ VK_EXECUTE,		 "Execute"				},
  556.72 -	{ VK_SNAPSHOT,		 "Snapshot"				},
  556.73 -	{ VK_INSERT,		 "Insert"				},
  556.74 -	{ VK_DELETE,		 "Delete"				},
  556.75 -	{ VK_HELP,			 "Help"					},
  556.76 -	{ WORD('0'),		 "0"					},
  556.77 -	{ WORD('1'),		 "1"					},
  556.78 -	{ WORD('2'),		 "2"					},
  556.79 -	{ WORD('3'),		 "3"					},
  556.80 -	{ WORD('4'),		 "4"					},
  556.81 -	{ WORD('5'),		 "5"					},
  556.82 -	{ WORD('6'),		 "6"					},
  556.83 -	{ WORD('7'),		 "7"					},
  556.84 -	{ WORD('8'),		 "8"					},
  556.85 -	{ WORD('9'),		 "9"					},
  556.86 -	{ WORD('A'),		 "A"					},
  556.87 -	{ WORD('B'),		 "B"					},
  556.88 -	{ WORD('C'),		 "C"					},
  556.89 -	{ WORD('D'),		 "D"					},
  556.90 -	{ WORD('E'),		 "E"					},
  556.91 -	{ WORD('F'),		 "F"					},
  556.92 -	{ WORD('G'),		 "G"					},
  556.93 -	{ WORD('H'),		 "H"					},
  556.94 -	{ WORD('I'),		 "I"					},
  556.95 -	{ WORD('J'),		 "J"					},
  556.96 -	{ WORD('K'),		 "K"					},
  556.97 -	{ WORD('L'),		 "L"					},
  556.98 -	{ WORD('M'),		 "M"					},
  556.99 -	{ WORD('N'),		 "N"					},
 556.100 -	{ WORD('O'),		 "O"					},
 556.101 -	{ WORD('P'),		 "P"					},
 556.102 -	{ WORD('Q'),		 "Q"					},
 556.103 -	{ WORD('R'),		 "R"					},
 556.104 -	{ WORD('S'),		 "S"					},
 556.105 -	{ WORD('T'),		 "T"					},
 556.106 -	{ WORD('U'),		 "U"					},
 556.107 -	{ WORD('V'),		 "V"					},
 556.108 -	{ WORD('W'),		 "W"					},
 556.109 -	{ WORD('X'),		 "X"					},
 556.110 -	{ WORD('Y'),		 "Y"					},
 556.111 -	{ WORD('Z'),		 "Z"					},
 556.112 -	{ VK_LWIN,			 "LWIN"					},
 556.113 -	{ VK_RWIN,			 "RWIN"					},
 556.114 -	{ VK_APPS,			 "APPS"					},
 556.115 -	{ VK_NUMPAD0,		 "NumPad0"				},
 556.116 -	{ VK_NUMPAD1,		 "NumPad1"				},
 556.117 -	{ VK_NUMPAD2,		 "NumPad2"				},
 556.118 -	{ VK_NUMPAD3,		 "NumPad3"				},
 556.119 -	{ VK_NUMPAD4,		 "NumPad4"				},
 556.120 -	{ VK_NUMPAD5,		 "NumPad5"				},
 556.121 -	{ VK_NUMPAD6,		 "NumPad6"				},
 556.122 -	{ VK_NUMPAD7,		 "NumPad7"				},
 556.123 -	{ VK_NUMPAD8,		 "NumPad8"				},
 556.124 -	{ VK_NUMPAD9,		 "NumPad9"				},
 556.125 -	{ VK_MULTIPLY,		 "NumpadMultiply"		},
 556.126 -	{ VK_ADD,			 "NumpadAdd"			},
 556.127 -	{ VK_SEPARATOR,		 "Separator"			},
 556.128 -	{ VK_SUBTRACT,		 "NumpadSubtract"		},
 556.129 -	{ VK_DECIMAL,		 "NumpadDecimal"		},
 556.130 -	{ VK_DIVIDE,		 "NumpadDivide"			},
 556.131 -	{ VK_F1,			 "F1"					},
 556.132 -	{ VK_F2,			 "F2"					},
 556.133 -	{ VK_F3,			 "F3"					},
 556.134 -	{ VK_F4,			 "F4"					},
 556.135 -	{ VK_F5,			 "F5"					},
 556.136 -	{ VK_F6,			 "F6"					},
 556.137 -	{ VK_F7,			 "F7"					},
 556.138 -	{ VK_F8,			 "F8"					},
 556.139 -	{ VK_F9,			 "F9"					},
 556.140 -	{ VK_F10,			 "F10"					},
 556.141 -	{ VK_F11,			 "F11"					},
 556.142 -	{ VK_F12,			 "F12"					},
 556.143 -	{ VK_F13,			 "F13"					},
 556.144 -	{ VK_F14,			 "F14"					},
 556.145 -	{ VK_F15,			 "F15"					},
 556.146 -	{ VK_F16,			 "F16"					},
 556.147 -	{ VK_F17,			 "F17"					},
 556.148 -	{ VK_F18,			 "F18"					},
 556.149 -	{ VK_F19,			 "F19"					},
 556.150 -	{ VK_F20,			 "F20"					},
 556.151 -	{ VK_F21,			 "F21"					},
 556.152 -	{ VK_F22,			 "F22"					},
 556.153 -	{ VK_F23,			 "F23"					},
 556.154 -	{ VK_F24,			 "F24"					},
 556.155 -	{ VK_NUMLOCK,		 "Num Lock"				},
 556.156 -	{ VK_SCROLL,		 "Scroll Lock"			},
 556.157 -	{ VK_ATTN,			 "Attention"			},
 556.158 -	{ VK_CRSEL,			 "CRSEL"				},
 556.159 -	{ VK_EXSEL,			 "EXSEL"				},
 556.160 -	{ VK_EREOF,			 "EREOF"				},
 556.161 -	{ VK_PLAY,			 "Play"					},
 556.162 -	{ VK_ZOOM,			 "Zoom"					},
 556.163 -	{ VK_NONAME,		 "No Name"				},
 556.164 -	{ VK_PA1,			 "PA1"					},
 556.165 -	{ VK_OEM_CLEAR,		 "Clear2"				},
 556.166 -	{ VK_OEM_1,			 "Semicolon;"			},
 556.167 -	{ VK_OEM_2,			 "Slash/"				},
 556.168 -	{ VK_OEM_3,			 "Tilde~"				},
 556.169 -	{ VK_OEM_4,			 "LBracket["			},
 556.170 -	{ VK_OEM_5,			 "Backslash\\"			},
 556.171 -	{ VK_OEM_6,			 "RBracket]"			},
 556.172 -	{ VK_OEM_7,			 "Apostrophe'"			},
 556.173 -	{ VK_OEM_8,			 "OEM8"					},
 556.174 -	{ VK_OEM_PLUS,		 "Plus+"				},
 556.175 -	{ VK_OEM_MINUS,		 "Minus-"				},
 556.176 -	{ VK_OEM_COMMA,		 "Comma,"				},
 556.177 -	{ VK_OEM_PERIOD,	 "Period."				},
 556.178 -	{ VK_OEM_AX,		 "Apostrophe`"			},
 556.179 -	{ VK_OEM_102,		 "<> or \\|"			},
 556.180 -	{ VK_ICO_HELP,		 "ICO Help"				},
 556.181 -	{ VK_ICO_00,		 "ICO 00"				},
 556.182 -	{ VK_OEM_FJ_JISHO,	 "JISHO"				},
 556.183 -	{ VK_OEM_FJ_MASSHOU, "MASSHOU"				},
 556.184 -	{ VK_OEM_FJ_TOUROKU, "TOUROKU"				},
 556.185 -	{ VK_OEM_FJ_LOYA,	 "LOYA"					},
 556.186 -	{ VK_OEM_FJ_ROYA,	 "ROYA"					},
 556.187 -	{ VK_OEM_NEC_EQUAL,	 "Numpad Equals"		},
 556.188 -};
 556.189 -
 556.190 -////////////////////////////////////////////////////////////////////////
 556.191 -//
 556.192 -//
 556.193 -MAPVIRTKEYS mapVirtSysKeys[] = {
 556.194 -	{ FCONTROL, "Ctrl"	  },
 556.195 -	{ FALT,		"Alt"	  },
 556.196 -	{ FSHIFT,	"Shift"	  },
 556.197 -};
 556.198 -
 556.199 -////////////////////////////////////////////////////////////////////////
 556.200 -// helper fct for external access
 556.201 -////////////////////////////////////////////////////////////////////////
 556.202 -//
 556.203 -//
 556.204 -TCHAR *mapVirtKeysStringFromWORD(WORD wKey)
 556.205 -{
 556.206 -	for (int index = 0; index < sizeof(mapVirtKeys) / sizeof(mapVirtKeys[0]); index++)
 556.207 -	{
 556.208 -		if (mapVirtKeys[index].wKey == wKey)
 556.209 -			return mapVirtKeys[index].szKey;
 556.210 -	}
 556.211 -	return NULL;
 556.212 -}
 556.213 -
 556.214 -////////////////////////////////////////////////////////////////////////
 556.215 -//
 556.216 -#define DEFAULT_ACCEL   0x01
 556.217 -#define USER_ACCEL              0x02
 556.218 -
 556.219 -////////////////////////////////////////////////////////////////////////
 556.220 -//
 556.221 -////////////////////////////////////////////////////////////////////////
 556.222 -//
 556.223 -//
 556.224 -CAccelsOb::CAccelsOb()
 556.225 -{
 556.226 -	m_cVirt	  = 0;
 556.227 -	m_wKey	  = 0;
 556.228 -	m_bLocked = false;
 556.229 -}
 556.230 -
 556.231 -////////////////////////////////////////////////////////////////////////
 556.232 -//
 556.233 -//
 556.234 -CAccelsOb::CAccelsOb(CAccelsOb *pFrom)
 556.235 -{
 556.236 -	ASSERT(pFrom != NULL);
 556.237 -
 556.238 -	m_cVirt	  = pFrom->m_cVirt;
 556.239 -	m_wKey	  = pFrom->m_wKey;
 556.240 -	m_bLocked = pFrom->m_bLocked;
 556.241 -}
 556.242 -
 556.243 -////////////////////////////////////////////////////////////////////////
 556.244 -//
 556.245 -//
 556.246 -CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
 556.247 -{
 556.248 -	m_cVirt	  = cVirt;
 556.249 -	m_wKey	  = wKey;
 556.250 -	m_bLocked = bLocked;
 556.251 -}
 556.252 -
 556.253 -////////////////////////////////////////////////////////////////////////
 556.254 -//
 556.255 -//
 556.256 -CAccelsOb::CAccelsOb(LPACCEL pACCEL)
 556.257 -{
 556.258 -	ASSERT(pACCEL != NULL);
 556.259 -
 556.260 -	m_cVirt	  = pACCEL->fVirt;
 556.261 -	m_wKey	  = pACCEL->key;
 556.262 -	m_bLocked = false;
 556.263 -}
 556.264 -
 556.265 -////////////////////////////////////////////////////////////////////////
 556.266 -//
 556.267 -//
 556.268 -CAccelsOb & CAccelsOb::operator=(const CAccelsOb &from)
 556.269 -{
 556.270 -	m_cVirt	  = from.m_cVirt;
 556.271 -	m_wKey	  = from.m_wKey;
 556.272 -	m_bLocked = from.m_bLocked;
 556.273 -
 556.274 -	return *this;
 556.275 -}
 556.276 -
 556.277 -////////////////////////////////////////////////////////////////////////
 556.278 -//
 556.279 -////////////////////////////////////////////////////////////////////////
 556.280 -//
 556.281 -//
 556.282 -void CAccelsOb::GetString(CString &szBuffer)
 556.283 -{
 556.284 -	szBuffer = "";
 556.285 -
 556.286 -	// modifiers part
 556.287 -	for (int i = 0; i < sizetable(mapVirtSysKeys); i++)
 556.288 -	{
 556.289 -		if (m_cVirt & mapVirtSysKeys[i].wKey)
 556.290 -		{
 556.291 -			szBuffer += mapVirtSysKeys[i].szKey;
 556.292 -			if (m_wKey)
 556.293 -				szBuffer += "+";
 556.294 -		}
 556.295 -	}
 556.296 -
 556.297 -	// in case of the object is not assigned, we avoid error messages
 556.298 -	if (m_wKey == 0)
 556.299 -		return;
 556.300 -
 556.301 -	// and virtual key part
 556.302 -	for (int i = 0; i < sizetable(mapVirtKeys); i++)
 556.303 -	{
 556.304 -		if (m_wKey == mapVirtKeys[i].wKey)
 556.305 -		{
 556.306 -			szBuffer += mapVirtKeys[i].szKey;
 556.307 -			return;
 556.308 -		}
 556.309 -	}
 556.310 -
 556.311 -	AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
 556.312 -}
 556.313 -
 556.314 -////////////////////////////////////////////////////////////////////////
 556.315 -//
 556.316 -//
 556.317 -bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
 556.318 -{
 556.319 -	bool m_bCtrl  = (m_cVirt & FCONTROL) ? true : false;
 556.320 -	bool m_bAlt	  = (m_cVirt & FALT) ? true : false;
 556.321 -	bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
 556.322 -
 556.323 -	bool bRet = (bCtrl == m_bCtrl) && (bAlt == m_bAlt) && (bShift == m_bShift) && (m_wKey == wKey);
 556.324 -
 556.325 -	return bRet;
 556.326 -}
 556.327 -
 556.328 -////////////////////////////////////////////////////////////////////////
 556.329 -//
 556.330 -//
 556.331 -DWORD CAccelsOb::GetData()
 556.332 -{
 556.333 -	BYTE cLocalCodes = 0;
 556.334 -	if (m_bLocked)
 556.335 -		cLocalCodes = DEFAULT_ACCEL;
 556.336 -	else
 556.337 -		cLocalCodes = USER_ACCEL;
 556.338 -
 556.339 -	WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
 556.340 -	return MAKELONG(m_wKey, bCodes);
 556.341 -}
 556.342 -
 556.343 -////////////////////////////////////////////////////////////////////////
 556.344 -//
 556.345 -//
 556.346 -bool CAccelsOb::SetData(DWORD dwDatas)
 556.347 -{
 556.348 -	m_wKey = LOWORD(dwDatas);
 556.349 -
 556.350 -	WORD bCodes = HIWORD(dwDatas);
 556.351 -	m_cVirt = LOBYTE(bCodes);
 556.352 -
 556.353 -	BYTE cLocalCodes = HIBYTE(bCodes);
 556.354 -	m_bLocked = (cLocalCodes == DEFAULT_ACCEL);
 556.355 -
 556.356 -	return true;
 556.357 -}
 556.358 -
 556.359 -////////////////////////////////////////////////////////////////////////
 556.360 -//
 556.361 -#ifdef _DEBUG
 556.362 -////////////////////////////////////////////////////////////////////////
 556.363 -//
 556.364 -//
 556.365 -void CAccelsOb::AssertValid() const
 556.366 -{
 556.367 -	CObject::AssertValid();
 556.368 -}
 556.369 -
 556.370 -////////////////////////////////////////////////////////////////////////
 556.371 -//
 556.372 -//
 556.373 -void CAccelsOb::Dump(CDumpContext &dc) const
 556.374 -{
 556.375 -	dc << "\t\t";
 556.376 -	CObject::Dump(dc);
 556.377 -	dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
 556.378 -}
 556.379 -
 556.380 -#endif
 556.381 -
 556.382 -////////////////////////////////////////////////////////////////////////
 556.383 -//
 556.384 -////////////////////////////////////////////////////////////////////////
 556.385 -//
 556.386 -//
 556.387 -CCmdAccelOb::CCmdAccelOb()
 556.388 -{}
 556.389 -
 556.390 -////////////////////////////////////////////////////////////////////////
 556.391 -//
 556.392 -//
 556.393 -CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
 556.394 -{
 556.395 -	ASSERT(szCommand != NULL);
 556.396 -
 556.397 -	m_wIDCommand = wIDCommand;
 556.398 -	m_szCommand	 = szCommand;
 556.399 -}
 556.400 -
 556.401 -////////////////////////////////////////////////////////////////////////
 556.402 -//
 556.403 -//
 556.404 -CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
 556.405 -{
 556.406 -	ASSERT(szCommand != NULL);
 556.407 -
 556.408 -	m_wIDCommand = wIDCommand;
 556.409 -	m_szCommand	 = szCommand;
 556.410 -
 556.411 -	CAccelsOb *pAccel = new CAccelsOb(cVirt, wKey, bLocked);
 556.412 -	ASSERT(pAccel != NULL);
 556.413 -	m_Accels.AddTail(pAccel);
 556.414 -}
 556.415 -
 556.416 -////////////////////////////////////////////////////////////////////////
 556.417 -//
 556.418 -//
 556.419 -CCmdAccelOb::~CCmdAccelOb()
 556.420 -{
 556.421 -	POSITION pos = m_Accels.GetHeadPosition();
 556.422 -	while (pos != NULL)
 556.423 -		delete m_Accels.GetNext(pos);
 556.424 -	m_Accels.RemoveAll();
 556.425 -}
 556.426 -
 556.427 -////////////////////////////////////////////////////////////////////////
 556.428 -//
 556.429 -////////////////////////////////////////////////////////////////////////
 556.430 -//
 556.431 -//
 556.432 -void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
 556.433 -{
 556.434 -	CAccelsOb *pAccel = new CAccelsOb(cVirt, wKey, bLocked);
 556.435 -	ASSERT(pAccel != NULL);
 556.436 -	m_Accels.AddTail(pAccel);
 556.437 -}
 556.438 -
 556.439 -////////////////////////////////////////////////////////////////////////
 556.440 -//
 556.441 -//
 556.442 -void CCmdAccelOb::Add(CAccelsOb *pAccel)
 556.443 -{
 556.444 -	ASSERT(pAccel != NULL);
 556.445 -	m_Accels.AddTail(pAccel);
 556.446 -}
 556.447 -
 556.448 -////////////////////////////////////////////////////////////////////////
 556.449 -//
 556.450 -//
 556.451 -CCmdAccelOb & CCmdAccelOb::operator=(const CCmdAccelOb &from)
 556.452 -{
 556.453 -	Reset();
 556.454 -
 556.455 -	m_wIDCommand = from.m_wIDCommand;
 556.456 -	m_szCommand	 = from.m_szCommand;
 556.457 -
 556.458 -	CAccelsOb *pAccel;
 556.459 -	POSITION   pos = from.m_Accels.GetHeadPosition();
 556.460 -	while (pos != NULL)
 556.461 -	{
 556.462 -		pAccel = new CAccelsOb(from.m_Accels.GetNext(pos));
 556.463 -		ASSERT(pAccel != NULL);
 556.464 -		m_Accels.AddTail(pAccel);
 556.465 -	}
 556.466 -	return *this;
 556.467 -}
 556.468 -
 556.469 -////////////////////////////////////////////////////////////////////////
 556.470 -//
 556.471 -//
 556.472 -void CCmdAccelOb::DeleteUserAccels()
 556.473 -{
 556.474 -	CAccelsOb *pAccel;
 556.475 -	POSITION   prevPos;
 556.476 -	POSITION   pos = m_Accels.GetHeadPosition();
 556.477 -	while (pos != NULL)
 556.478 -	{
 556.479 -		prevPos = pos;
 556.480 -		pAccel	= m_Accels.GetNext(pos);
 556.481 -		if (!pAccel->m_bLocked)
 556.482 -		{
 556.483 -			delete pAccel;
 556.484 -			m_Accels.RemoveAt(prevPos);
 556.485 -		}
 556.486 -	}
 556.487 -}
 556.488 -
 556.489 -////////////////////////////////////////////////////////////////////////
 556.490 -//
 556.491 -//
 556.492 -void CCmdAccelOb::Reset()
 556.493 -{
 556.494 -	m_wIDCommand = 0;
 556.495 -	m_szCommand	 = "Empty command";
 556.496 -
 556.497 -	CAccelsOb *pAccel;
 556.498 -	POSITION   pos = m_Accels.GetHeadPosition();
 556.499 -	while (pos != NULL)
 556.500 -	{
 556.501 -		pAccel = m_Accels.GetNext(pos);
 556.502 -		delete pAccel;
 556.503 -	}
 556.504 -}
 556.505 -
 556.506 -////////////////////////////////////////////////////////////////////////
 556.507 -//
 556.508 -#ifdef _DEBUG
 556.509 -////////////////////////////////////////////////////////////////////////
 556.510 -//
 556.511 -//
 556.512 -void CCmdAccelOb::AssertValid() const
 556.513 -{
 556.514 -	// call base class function first
 556.515 -	CObject::AssertValid();
 556.516 -}
 556.517 -
 556.518 -////////////////////////////////////////////////////////////////////////
 556.519 -//
 556.520 -//
 556.521 -void CCmdAccelOb::Dump(CDumpContext &dc) const
 556.522 -{
 556.523 -	// call base class function first
 556.524 -	dc << "\t";
 556.525 -	CObject::Dump(dc);
 556.526 -
 556.527 -	// now do the stuff for our specific class
 556.528 -	dc << "\tIDCommand = " << m_wIDCommand;
 556.529 -	dc << "\n\tszCommand = " << m_szCommand;
 556.530 -	dc << "\n\tAccelerators = {\n";
 556.531 -
 556.532 -	CAccelsOb *pAccel;
 556.533 -	POSITION   pos = m_Accels.GetHeadPosition();
 556.534 -	while (pos != NULL)
 556.535 -	{
 556.536 -		pAccel = m_Accels.GetNext(pos);
 556.537 -		dc << pAccel;
 556.538 -	}
 556.539 -	dc << "\t}\n";
 556.540 -}
 556.541 -
 556.542 -#endif
   557.1 --- a/src/win32/CmdAccelOb.h	Sat Mar 03 10:54:39 2012 -0600
   557.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   557.3 @@ -1,110 +0,0 @@
   557.4 -////////////////////////////////////////////////////////////////////////////////
   557.5 -// Copyright (C) 1998 by Thierry Maurel
   557.6 -// All rights reserved
   557.7 -//
   557.8 -// Distribute freely, except: don't remove my name from the source or
   557.9 -// documentation (don't take credit for my work), mark your changes (don't
  557.10 -// get me blamed for your possible bugs), don't alter or remove this
  557.11 -// notice.
  557.12 -// No warrantee of any kind, express or implied, is included with this
  557.13 -// software; use at your own risk, responsibility for damages (if any) to
  557.14 -// anyone resulting from the use of this software rests entirely with the
  557.15 -// user.
  557.16 -//
  557.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  557.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  557.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  557.20 -//
  557.21 -////////////////////////////////////////////////////////////////////////////////
  557.22 -// File    : CmdAccelOb.h
  557.23 -// Project : AccelsEditor
  557.24 -////////////////////////////////////////////////////////////////////////////////
  557.25 -// Version : 1.0                       * Author : T.Maurel
  557.26 -// Date    : 17.08.98
  557.27 -//
  557.28 -// Remarks :
  557.29 -//
  557.30 -////////////////////////////////////////////////////////////////////////////////
  557.31 -#ifndef __CMDACCEL_OB_INCLUDE
  557.32 -#define __CMDACCEL_OB_INCLUDE
  557.33 -
  557.34 -#if _MSC_VER > 1000
  557.35 -#pragma once
  557.36 -#endif // _MSC_VER > 1000
  557.37 -
  557.38 -#include <afxtempl.h>  // MFC Templates extension
  557.39 -
  557.40 -////////////////////////////////////////////////////////////////////////
  557.41 -//
  557.42 -//
  557.43 -typedef struct tagMAPVIRTKEYS
  557.44 -{
  557.45 -	WORD  wKey;
  557.46 -	TCHAR szKey[15];
  557.47 -} MAPVIRTKEYS, *PMAPVIRTKEYS;
  557.48 -
  557.49 -////////////////////////////////////////////////////////////////////////
  557.50 -//
  557.51 -//
  557.52 -#define sizetable(table) (sizeof(table)/sizeof(table[0]))
  557.53 -
  557.54 -////////////////////////////////////////////////////////////////////////
  557.55 -//
  557.56 -//
  557.57 -class CAccelsOb : public CObject
  557.58 -{
  557.59 -public:
  557.60 -	CAccelsOb();
  557.61 -	CAccelsOb(CAccelsOb*pFrom);
  557.62 -	CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
  557.63 -	CAccelsOb(LPACCEL pACCEL);
  557.64 -public:
  557.65 -	CAccelsOb & operator=(const CAccelsOb& from);
  557.66 -
  557.67 -	void GetString(CString& szBuffer);
  557.68 -	bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
  557.69 -	DWORD GetData();
  557.70 -	bool SetData(DWORD dwDatas);
  557.71 -public:
  557.72 -#ifdef _DEBUG
  557.73 -	virtual void AssertValid() const;
  557.74 -	virtual void Dump(CDumpContext& dc) const;
  557.75 -#endif
  557.76 -public:
  557.77 -	BYTE m_cVirt;
  557.78 -	WORD m_wKey;
  557.79 -	bool m_bLocked;
  557.80 -};
  557.81 -
  557.82 -//////////////////////////////////////////////////////////////////////
  557.83 -//
  557.84 -//
  557.85 -class CCmdAccelOb : public CObject
  557.86 -{
  557.87 -public:
  557.88 -	CCmdAccelOb();
  557.89 -	CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
  557.90 -	CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked = false);
  557.91 -	~CCmdAccelOb();
  557.92 -public:
  557.93 -	void Add(CAccelsOb*pAccel);
  557.94 -	void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
  557.95 -	void Reset();
  557.96 -	void DeleteUserAccels();
  557.97 -
  557.98 -	CCmdAccelOb & operator=(const CCmdAccelOb& from);
  557.99 -public:
 557.100 -#ifdef _DEBUG
 557.101 -	virtual void AssertValid() const;
 557.102 -	virtual void Dump(CDumpContext& dc) const;
 557.103 -#endif
 557.104 -public:
 557.105 -	WORD    m_wIDCommand;
 557.106 -	CString m_szCommand;
 557.107 -
 557.108 -	CList< CAccelsOb *, CAccelsOb * & > m_Accels;
 557.109 -};
 557.110 -
 557.111 -////////////////////////////////////////////////////////////////////////
 557.112 -#endif // __CMDACCEL_OB_INCLUDE
 557.113 -
   558.1 --- a/src/win32/ColorButton.cpp	Sat Mar 03 10:54:39 2012 -0600
   558.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   558.3 @@ -1,95 +0,0 @@
   558.4 -// ColorButton.cpp : implementation file
   558.5 -//
   558.6 -
   558.7 -#include "stdafx.h"
   558.8 -#include "ColorButton.h"
   558.9 -
  558.10 -bool ColorButton::isRegistered = false;
  558.11 -
  558.12 -/////////////////////////////////////////////////////////////////////////////
  558.13 -// ColorButton
  558.14 -
  558.15 -ColorButton::ColorButton()
  558.16 -{
  558.17 -  color = 0;
  558.18 -  registerClass();
  558.19 -}
  558.20 -
  558.21 -ColorButton::~ColorButton()
  558.22 -{
  558.23 -}
  558.24 -
  558.25 -
  558.26 -BEGIN_MESSAGE_MAP(ColorButton, CButton)
  558.27 -  //{{AFX_MSG_MAP(ColorButton)
  558.28 -  // NOTE - the ClassWizard will add and remove mapping macros here.
  558.29 -  //}}AFX_MSG_MAP
  558.30 -  END_MESSAGE_MAP()
  558.31 -
  558.32 -  /////////////////////////////////////////////////////////////////////////////
  558.33 -// ColorButton message handlers
  558.34 -
  558.35 -void ColorButton::PreSubclassWindow()
  558.36 -{
  558.37 -  SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
  558.38 -  CWnd::PreSubclassWindow();
  558.39 -}
  558.40 -
  558.41 -void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
  558.42 -{
  558.43 -  ASSERT(lpDrawItemStruct);
  558.44 -  
  558.45 -  int r = (color & 0x1f) << 3;
  558.46 -  int g = (color & 0x3e0) >> 2;
  558.47 -  int b = (color & 0x7c00) >> 7;
  558.48 -
  558.49 -  HDC dc = lpDrawItemStruct->hDC;
  558.50 -  UINT state = lpDrawItemStruct->itemState;
  558.51 -  RECT rect = lpDrawItemStruct->rcItem;
  558.52 -
  558.53 -  SIZE margins;
  558.54 -  margins.cx = ::GetSystemMetrics(SM_CXEDGE);
  558.55 -  margins.cy = ::GetSystemMetrics(SM_CYEDGE);
  558.56 -
  558.57 -  if(GetState() & BST_PUSHED)
  558.58 -    DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
  558.59 -  else
  558.60 -    DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
  558.61 -
  558.62 -  InflateRect(&rect, -margins.cx, -margins.cy);
  558.63 -  
  558.64 -  HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? 
  558.65 -                               ::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
  558.66 -
  558.67 -  FillRect(dc, &rect, br);
  558.68 -
  558.69 -  if(state & ODS_FOCUS) {
  558.70 -    InflateRect(&rect, -1, -1);
  558.71 -    DrawFocusRect(dc, &rect);
  558.72 -  }
  558.73 -  
  558.74 -  DeleteObject(br);
  558.75 -}
  558.76 -
  558.77 -void ColorButton::setColor(u16 c)
  558.78 -{
  558.79 -  color = c;
  558.80 -  Invalidate();
  558.81 -}
  558.82 -
  558.83 -void ColorButton::registerClass()
  558.84 -{
  558.85 -  if(!isRegistered) {
  558.86 -    WNDCLASS wc;
  558.87 -    ZeroMemory(&wc, sizeof(wc));
  558.88 -    wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
  558.89 -    wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
  558.90 -    wc.hInstance = AfxGetInstanceHandle();
  558.91 -    wc.hIcon = LoadCursor(NULL, IDC_ARROW);
  558.92 -    wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
  558.93 -    wc.lpszMenuName = NULL;
  558.94 -    wc.lpszClassName = "VbaColorButton";
  558.95 -    AfxRegisterClass(&wc);
  558.96 -    isRegistered = true;
  558.97 -  }
  558.98 -}
   559.1 --- a/src/win32/ColorButton.h	Sat Mar 03 10:54:39 2012 -0600
   559.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   559.3 @@ -1,54 +0,0 @@
   559.4 -#if !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_)
   559.5 -#define AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_
   559.6 -
   559.7 -#if _MSC_VER > 1000
   559.8 -#pragma once
   559.9 -#endif // _MSC_VER > 1000
  559.10 -// ColorButton.h : header file
  559.11 -//
  559.12 -
  559.13 -/////////////////////////////////////////////////////////////////////////////
  559.14 -// ColorButton window
  559.15 -
  559.16 -class ColorButton : public CButton
  559.17 -{
  559.18 -	// Construction
  559.19 -public:
  559.20 -	ColorButton();
  559.21 -
  559.22 -	// Attributes
  559.23 -public:
  559.24 -	// Operations
  559.25 -	static bool isRegistered;
  559.26 -public:
  559.27 -	void PreSubclassWindow();
  559.28 -	void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  559.29 -
  559.30 -	// Overrides
  559.31 -	// ClassWizard generated virtual function overrides
  559.32 -	//{{AFX_VIRTUAL(ColorButton)
  559.33 -	//}}AFX_VIRTUAL
  559.34 -
  559.35 -	// Implementation
  559.36 -public:
  559.37 -	void setColor(u16 c);
  559.38 -	u16 color;
  559.39 -	virtual ~ColorButton();
  559.40 -
  559.41 -	void registerClass();
  559.42 -
  559.43 -	// Generated message map functions
  559.44 -protected:
  559.45 -	//{{AFX_MSG(ColorButton)
  559.46 -	// NOTE - the ClassWizard will add and remove member functions here.
  559.47 -	//}}AFX_MSG
  559.48 -
  559.49 -	DECLARE_MESSAGE_MAP()
  559.50 -};
  559.51 -
  559.52 -/////////////////////////////////////////////////////////////////////////////
  559.53 -
  559.54 -//{{AFX_INSERT_LOCATION}}
  559.55 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  559.56 -
  559.57 -#endif // !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_)
   560.1 --- a/src/win32/ColorControl.cpp	Sat Mar 03 10:54:39 2012 -0600
   560.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   560.3 @@ -1,78 +0,0 @@
   560.4 -// ColorControl.cpp : implementation file
   560.5 -//
   560.6 -
   560.7 -#include "stdafx.h"
   560.8 -#include "ColorControl.h"
   560.9 -
  560.10 -bool ColorControl::isRegistered = false;
  560.11 -
  560.12 -/////////////////////////////////////////////////////////////////////////////
  560.13 -// ColorControl
  560.14 -
  560.15 -ColorControl::ColorControl()
  560.16 -{
  560.17 -  color = 0;
  560.18 -  registerClass();
  560.19 -}
  560.20 -
  560.21 -ColorControl::~ColorControl()
  560.22 -{
  560.23 -}
  560.24 -
  560.25 -
  560.26 -BEGIN_MESSAGE_MAP(ColorControl, CWnd)
  560.27 -  //{{AFX_MSG_MAP(ColorControl)
  560.28 -  ON_WM_PAINT()
  560.29 -  ON_WM_ERASEBKGND()
  560.30 -  //}}AFX_MSG_MAP
  560.31 -  END_MESSAGE_MAP()
  560.32 -
  560.33 -
  560.34 -  /////////////////////////////////////////////////////////////////////////////
  560.35 -// ColorControl message handlers
  560.36 -
  560.37 -void ColorControl::OnPaint() 
  560.38 -{
  560.39 -  CPaintDC dc(this); // device context for painting
  560.40 -}
  560.41 -
  560.42 -BOOL ColorControl::OnEraseBkgnd(CDC* pDC) 
  560.43 -{
  560.44 -  int r = (color & 0x1f) << 3;
  560.45 -  int g = (color & 0x3e0) >> 2;
  560.46 -  int b = (color & 0x7c00) >> 7;
  560.47 -
  560.48 -  CBrush br;
  560.49 -  br.CreateSolidBrush(RGB(r,g,b));
  560.50 -
  560.51 -  RECT rect;
  560.52 -  GetClientRect(&rect);
  560.53 -  pDC->FillRect(&rect,&br);
  560.54 -  pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
  560.55 -  br.DeleteObject();
  560.56 -  return TRUE;
  560.57 -}
  560.58 -
  560.59 -void ColorControl::setColor(u16 c)
  560.60 -{
  560.61 -  color = c;
  560.62 -  Invalidate();
  560.63 -}
  560.64 -
  560.65 -void ColorControl::registerClass()
  560.66 -{
  560.67 -  if(!isRegistered) {
  560.68 -    WNDCLASS wc;
  560.69 -    ZeroMemory(&wc, sizeof(wc));
  560.70 -    wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
  560.71 -    wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
  560.72 -    wc.hInstance = AfxGetInstanceHandle();
  560.73 -    wc.hIcon = NULL;
  560.74 -    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  560.75 -    wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
  560.76 -    wc.lpszMenuName = NULL;
  560.77 -    wc.lpszClassName = "VbaColorControl";
  560.78 -    AfxRegisterClass(&wc);
  560.79 -    isRegistered = true;
  560.80 -  }
  560.81 -}
   561.1 --- a/src/win32/ColorControl.h	Sat Mar 03 10:54:39 2012 -0600
   561.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   561.3 @@ -1,53 +0,0 @@
   561.4 -#if !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_)
   561.5 -#define AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_
   561.6 -
   561.7 -#if _MSC_VER > 1000
   561.8 -#pragma once
   561.9 -#endif // _MSC_VER > 1000
  561.10 -// ColorControl.h : header file
  561.11 -//
  561.12 -
  561.13 -/////////////////////////////////////////////////////////////////////////////
  561.14 -// ColorControl window
  561.15 -
  561.16 -class ColorControl : public CWnd
  561.17 -{
  561.18 -	// Construction
  561.19 -public:
  561.20 -	ColorControl();
  561.21 -
  561.22 -	// Attributes
  561.23 -public:
  561.24 -	// Operations
  561.25 -	static bool isRegistered;
  561.26 -
  561.27 -	// Operations
  561.28 -public:
  561.29 -	// Overrides
  561.30 -	// ClassWizard generated virtual function overrides
  561.31 -	//{{AFX_VIRTUAL(ColorControl)
  561.32 -	//}}AFX_VIRTUAL
  561.33 -
  561.34 -	// Implementation
  561.35 -public:
  561.36 -	void setColor(u16 c);
  561.37 -	u16 color;
  561.38 -	virtual ~ColorControl();
  561.39 -
  561.40 -	// Generated message map functions
  561.41 -protected:
  561.42 -	//{{AFX_MSG(ColorControl)
  561.43 -	afx_msg void OnPaint();
  561.44 -	afx_msg BOOL OnEraseBkgnd(CDC*pDC);
  561.45 -	//}}AFX_MSG
  561.46 -	DECLARE_MESSAGE_MAP()
  561.47 -private:
  561.48 -	void registerClass();
  561.49 -};
  561.50 -
  561.51 -/////////////////////////////////////////////////////////////////////////////
  561.52 -
  561.53 -//{{AFX_INSERT_LOCATION}}
  561.54 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  561.55 -
  561.56 -#endif // !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_)
   562.1 --- a/src/win32/Commands.cpp	Sat Mar 03 10:54:39 2012 -0600
   562.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   562.3 @@ -1,75 +0,0 @@
   562.4 -#include "stdafx.h"
   562.5 -#include <afxres.h>
   562.6 -#include "resource.h"
   562.7 -#include "AcceleratorManager.h"
   562.8 -
   562.9 -#ifndef CMapStringToWord
  562.10 -typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord;
  562.11 -#endif
  562.12 -
  562.13 -static CMapStringToWord winAccelStrings;
  562.14 -static bool initialized = false;
  562.15 -
  562.16 -struct
  562.17 -{
  562.18 -	const char *command;
  562.19 -	WORD        id;
  562.20 -} winAccelCommands[] = {
  562.21 -	{	"Minimize",				ID_SYSTEM_MINIMIZE	},
  562.22 -	{	"Maximize",				ID_SYSTEM_MAXIMIZE	},
  562.23 -};
  562.24 -
  562.25 -void winAccelAddCommandsFromTable(CAcceleratorManager &mgr)
  562.26 -{
  562.27 -	int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
  562.28 -
  562.29 -	for (int i = 0; i < count; i++)
  562.30 -	{
  562.31 -		if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
  562.32 -			mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
  562.33 -	}
  562.34 -}
  562.35 -
  562.36 -// recursive calls
  562.37 -void winAccelAddCommandsFromMenu(CAcceleratorManager &mgr, CMenu *pMenu, const CString &parentStr)
  562.38 -{
  562.39 -	UINT nIndexMax = pMenu->GetMenuItemCount();
  562.40 -	for (UINT nIndex = 0; nIndex < nIndexMax; ++nIndex)
  562.41 -	{
  562.42 -		UINT nID = pMenu->GetMenuItemID(nIndex);
  562.43 -		if (nID == 0)
  562.44 -			continue; // menu separator or invalid cmd - ignore it
  562.45 -
  562.46 -		if (nID == (UINT)-1)
  562.47 -		{
  562.48 -			// possibly a submenu
  562.49 -			CMenu *pSubMenu = pMenu->GetSubMenu(nIndex);
  562.50 -			if (pSubMenu != NULL)
  562.51 -			{
  562.52 -				CString tempStr;
  562.53 -				pMenu->GetMenuString(nIndex, tempStr, MF_BYPOSITION);
  562.54 -				tempStr.Remove('&');
  562.55 -				winAccelAddCommandsFromMenu(mgr, pSubMenu, parentStr + '\\' + tempStr);
  562.56 -			}
  562.57 -		}
  562.58 -		else
  562.59 -		{
  562.60 -			// normal menu item
  562.61 -			// generate the strings
  562.62 -			CString command;
  562.63 -			pMenu->GetMenuString(nIndex, command, MF_BYPOSITION);
  562.64 -			int nPos = command.ReverseFind('\t');
  562.65 -			if (nPos != -1)
  562.66 -			{
  562.67 -				command.Delete(nPos, command.GetLength() - nPos);
  562.68 -			}
  562.69 -			command.Remove('&');
  562.70 -			command = parentStr + '\\' + command;
  562.71 -			if (!mgr.AddCommandAccel(nID, command, false))
  562.72 -			{
  562.73 -				mgr.CreateEntry(nID, command);
  562.74 -			}
  562.75 -		}
  562.76 -	}
  562.77 -}
  562.78 -
   563.1 --- a/src/win32/Direct3D.cpp	Sat Mar 03 10:54:39 2012 -0600
   563.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   563.3 @@ -1,752 +0,0 @@
   563.4 -#include "stdafx.h"
   563.5 -
   563.6 -#define DIRECT3D_VERSION 0x0800
   563.7 -#include "d3d8.h"
   563.8 -#include "d3dx8.h"
   563.9 -
  563.10 -#include "resource.h"
  563.11 -#include "MainWnd.h"
  563.12 -#include "Reg.h"
  563.13 -#include "VBA.h"
  563.14 -
  563.15 -//#include "../common/System.h"
  563.16 -#include "../gba/GBAGlobals.h"
  563.17 -#include "../gb/gbGlobals.h"
  563.18 -#include "../common/Text.h"
  563.19 -#include "../version.h"
  563.20 -
  563.21 -#ifdef MMX
  563.22 -extern "C" bool cpu_mmx;
  563.23 -
  563.24 -extern bool detectMMX();
  563.25 -#endif
  563.26 -
  563.27 -extern int Init_2xSaI(u32);
  563.28 -extern void directXMessage(const char *);
  563.29 -extern void winlog(const char *, ...);
  563.30 -
  563.31 -typedef struct _D3DTLVERTEX
  563.32 -{
  563.33 -	float    sx; /* Screen coordinates */
  563.34 -	float    sy;
  563.35 -	float    sz;
  563.36 -	float    rhw; /* Reciprocal of homogeneous w */
  563.37 -	D3DCOLOR color; /* Vertex color */
  563.38 -	float    tu; /* Texture coordinates */
  563.39 -	float    tv;
  563.40 -	_D3DTLVERTEX() { }
  563.41 -	_D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
  563.42 -	             D3DCOLOR _color,
  563.43 -	             float _tu, float _tv)
  563.44 -	{
  563.45 -		sx    = v.x; sy = v.y; sz = v.z; rhw = _rhw;
  563.46 -		color = _color;
  563.47 -		tu    = _tu; tv = _tv;
  563.48 -	}
  563.49 -} D3DTLVERTEX, *LPD3DTLVERTEX;
  563.50 -
  563.51 -#define D3DFVF_TLVERTEX D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1
  563.52 -
  563.53 -class Direct3DDisplay : public IDisplay
  563.54 -{
  563.55 -public:
  563.56 -	Direct3DDisplay();
  563.57 -	virtual ~Direct3DDisplay();
  563.58 -
  563.59 -	virtual bool initialize();
  563.60 -	virtual void cleanup();
  563.61 -	virtual void render();
  563.62 -	virtual void checkFullScreen();
  563.63 -	virtual void renderMenu();
  563.64 -	virtual void clear();
  563.65 -	virtual bool changeRenderSize(int w, int h);
  563.66 -	virtual void resize(int w, int h);
  563.67 -	virtual DISPLAY_TYPE getType() { return DIRECT_3D; };
  563.68 -	virtual void setOption(const char *, int);
  563.69 -	virtual int selectFullScreenMode(GUID * *);
  563.70 -
  563.71 -private:
  563.72 -	HINSTANCE             d3dDLL;
  563.73 -	LPDIRECT3D8           pD3D;
  563.74 -	LPDIRECT3DDEVICE8     pDevice;
  563.75 -	LPDIRECT3DTEXTURE8    pTexture;
  563.76 -	D3DSURFACE_DESC       dsdBackBuffer;
  563.77 -	D3DPRESENT_PARAMETERS dpp;
  563.78 -	D3DFORMAT             screenFormat;
  563.79 -	int  width;
  563.80 -	int  height;
  563.81 -	bool filterDisabled;
  563.82 -	ID3DXFont *pFont;
  563.83 -	bool       failed;
  563.84 -	unsigned int textureSize;
  563.85 -	D3DTLVERTEX verts[4];
  563.86 -
  563.87 -
  563.88 -	void restoreDeviceObjects();
  563.89 -	void invalidateDeviceObjects();
  563.90 -	bool initializeOffscreen(int w, int h);
  563.91 -	void updateFiltering(int);
  563.92 -	void calculateVertices();
  563.93 -};
  563.94 -
  563.95 -Direct3DDisplay::Direct3DDisplay()
  563.96 -{
  563.97 -	d3dDLL         = NULL;
  563.98 -	pD3D           = NULL;
  563.99 -	pDevice        = NULL;
 563.100 -	pTexture       = NULL;
 563.101 -	pFont          = NULL;
 563.102 -	screenFormat   = D3DFMT_R5G6B5;
 563.103 -	width          = 0;
 563.104 -	height         = 0;
 563.105 -	filterDisabled = false;
 563.106 -	failed         = false;
 563.107 -	textureSize    = 0;
 563.108 -}
 563.109 -
 563.110 -Direct3DDisplay::~Direct3DDisplay()
 563.111 -{
 563.112 -	cleanup();
 563.113 -}
 563.114 -
 563.115 -void Direct3DDisplay::cleanup()
 563.116 -{
 563.117 -	if (pD3D != NULL)
 563.118 -	{
 563.119 -		if (pFont)
 563.120 -		{
 563.121 -			pFont->Release();
 563.122 -			pFont = NULL;
 563.123 -		}
 563.124 -
 563.125 -		if (pTexture)
 563.126 -		{
 563.127 -			pTexture->Release();
 563.128 -			pTexture = NULL;
 563.129 -		}
 563.130 -
 563.131 -		if (pDevice)
 563.132 -		{
 563.133 -			pDevice->Release();
 563.134 -			pDevice = NULL;
 563.135 -		}
 563.136 -
 563.137 -		pD3D->Release();
 563.138 -		pD3D = NULL;
 563.139 -
 563.140 -		if (d3dDLL != NULL)
 563.141 -		{
 563.142 -			FreeLibrary(d3dDLL);
 563.143 -			d3dDLL = NULL;
 563.144 -		}
 563.145 -	}
 563.146 -}
 563.147 -
 563.148 -bool Direct3DDisplay::initialize()
 563.149 -{
 563.150 -	CWnd *pWnd = theApp.m_pMainWnd;
 563.151 -
 563.152 -	d3dDLL = LoadLibrary("D3D8.DLL");
 563.153 -	LPDIRECT3D8 (WINAPI *D3DCreate)(UINT);
 563.154 -	if (d3dDLL != NULL)
 563.155 -	{
 563.156 -		D3DCreate = (LPDIRECT3D8 (WINAPI *)(UINT))
 563.157 -		            GetProcAddress(d3dDLL, "Direct3DCreate8");
 563.158 -
 563.159 -		if (D3DCreate == NULL)
 563.160 -		{
 563.161 -			directXMessage("Direct3DCreate8");
 563.162 -			return FALSE;
 563.163 -		}
 563.164 -	}
 563.165 -	else
 563.166 -	{
 563.167 -		directXMessage("D3D8.DLL");
 563.168 -		return FALSE;
 563.169 -	}
 563.170 -
 563.171 -	pD3D = D3DCreate(120);
 563.172 -
 563.173 -	if (pD3D == NULL)
 563.174 -	{
 563.175 -		winlog("Error creating Direct3D object\n");
 563.176 -		return FALSE;
 563.177 -	}
 563.178 -
 563.179 -	theApp.mode320Available = false;
 563.180 -	theApp.mode640Available = false;
 563.181 -	theApp.mode800Available = false;
 563.182 -
 563.183 -	D3DDISPLAYMODE mode;
 563.184 -	pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode);
 563.185 -
 563.186 -	switch (mode.Format)
 563.187 -	{
 563.188 -	case D3DFMT_R8G8B8:
 563.189 -		systemColorDepth = 24;
 563.190 -		systemRedShift   = 19;
 563.191 -		systemGreenShift = 11;
 563.192 -		systemBlueShift  = 3;
 563.193 -		break;
 563.194 -	case D3DFMT_X8R8G8B8:
 563.195 -		systemColorDepth = 32;
 563.196 -		systemRedShift   = 19;
 563.197 -		systemGreenShift = 11;
 563.198 -		systemBlueShift  = 3;
 563.199 -		Init_2xSaI(32);
 563.200 -		break;
 563.201 -	case D3DFMT_R5G6B5:
 563.202 -		systemColorDepth = 16;
 563.203 -		systemRedShift   = 11;
 563.204 -		systemGreenShift = 6;
 563.205 -		systemBlueShift  = 0;
 563.206 -		Init_2xSaI(565);
 563.207 -		break;
 563.208 -	case D3DFMT_X1R5G5B5:
 563.209 -		systemColorDepth = 16;
 563.210 -		systemRedShift   = 10;
 563.211 -		systemGreenShift = 5;
 563.212 -		systemBlueShift  = 0;
 563.213 -		Init_2xSaI(555);
 563.214 -		break;
 563.215 -	default:
 563.216 -		systemMessage(0, "Unsupport D3D format %d", mode.Format);
 563.217 -		return false;
 563.218 -	}
 563.219 -	theApp.fsColorDepth = systemColorDepth;
 563.220 -
 563.221 -#ifdef MMX
 563.222 -	if (!theApp.disableMMX)
 563.223 -		cpu_mmx = theApp.detectMMX();
 563.224 -	else
 563.225 -		cpu_mmx = 0;
 563.226 -#endif
 563.227 -
 563.228 -	screenFormat = mode.Format;
 563.229 -
 563.230 -	// check for available fullscreen modes
 563.231 -	ZeroMemory(&dpp, sizeof(dpp));
 563.232 -	dpp.Windowed         = TRUE;
 563.233 -	dpp.BackBufferFormat = mode.Format;
 563.234 -	dpp.BackBufferCount  = 1;
 563.235 -	dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
 563.236 -	dpp.BackBufferWidth  = theApp.surfaceSizeX;
 563.237 -	dpp.BackBufferHeight = theApp.surfaceSizeY;
 563.238 -
 563.239 -	HRESULT hret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,
 563.240 -	                                  D3DDEVTYPE_HAL,
 563.241 -	                                  pWnd->GetSafeHwnd(),
 563.242 -	                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE,
 563.243 -	                                  &dpp,
 563.244 -	                                  &pDevice);
 563.245 -	if (!SUCCEEDED(hret))
 563.246 -	{
 563.247 -		winlog("Error creating Direct3DDevice %08x\n", hret);
 563.248 -		return false;
 563.249 -	}
 563.250 -
 563.251 -	restoreDeviceObjects();
 563.252 -
 563.253 -	switch (systemColorDepth)
 563.254 -	{
 563.255 -	case 16:
 563.256 -	{
 563.257 -		for (int i = 0; i < 0x10000; i++)
 563.258 -		{
 563.259 -			systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
 563.260 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 563.261 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 563.262 -		}
 563.263 -		break;
 563.264 -	}
 563.265 -	case 24:
 563.266 -	case 32:
 563.267 -	{
 563.268 -		for (int i = 0; i < 0x10000; i++)
 563.269 -		{
 563.270 -			systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 563.271 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 563.272 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 563.273 -		}
 563.274 -		break;
 563.275 -	}
 563.276 -	}
 563.277 -
 563.278 -	theApp.updateFilter();
 563.279 -	theApp.updateIFB();
 563.280 -
 563.281 -	if (failed)
 563.282 -		return false;
 563.283 -
 563.284 -	pWnd->DragAcceptFiles(TRUE);
 563.285 -
 563.286 -	return TRUE;
 563.287 -}
 563.288 -
 563.289 -bool Direct3DDisplay::initializeOffscreen(int w, int h)
 563.290 -{
 563.291 -	int size = 256;
 563.292 -	if (w > 512 || h > 512)
 563.293 -		size = 1024;
 563.294 -	else if (w > 256 || h > 256)
 563.295 -		size = 512;
 563.296 -	textureSize = size;
 563.297 -
 563.298 -	UINT      ww     = size;
 563.299 -	UINT      hh     = size;
 563.300 -	D3DFORMAT format = screenFormat;
 563.301 -
 563.302 -	if (SUCCEEDED(D3DXCheckTextureRequirements(pDevice,
 563.303 -	                                           &ww,
 563.304 -	                                           &hh,
 563.305 -	                                           NULL,
 563.306 -	                                           0,
 563.307 -	                                           &format,
 563.308 -	                                           D3DPOOL_MANAGED)))
 563.309 -	{
 563.310 -		if ((int)ww < w || (int)hh < h)
 563.311 -		{
 563.312 -			if (theApp.filterFunction)
 563.313 -			{
 563.314 -				filterDisabled        = true;
 563.315 -				theApp.filterFunction = NULL;
 563.316 -				systemMessage(0, "3D card cannot support needed texture size for filter function. Disabling it");
 563.317 -			}
 563.318 -		}
 563.319 -		else
 563.320 -			filterDisabled = false;
 563.321 -		if (SUCCEEDED(D3DXCreateTexture(pDevice,
 563.322 -		                                ww,
 563.323 -		                                hh,
 563.324 -		                                0,
 563.325 -		                                0,
 563.326 -		                                format,
 563.327 -		                                D3DPOOL_MANAGED,
 563.328 -		                                &pTexture)))
 563.329 -		{
 563.330 -			width  = w;
 563.331 -			height = h;
 563.332 -			return true;
 563.333 -		}
 563.334 -	}
 563.335 -	return false;
 563.336 -}
 563.337 -
 563.338 -void Direct3DDisplay::updateFiltering(int filter)
 563.339 -{
 563.340 -	switch (filter)
 563.341 -	{
 563.342 -	default:
 563.343 -	case 0:
 563.344 -		// point filtering
 563.345 -		pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT);
 563.346 -		pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
 563.347 -		pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
 563.348 -		break;
 563.349 -	case 1:
 563.350 -		// bilinear
 563.351 -		pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
 563.352 -		pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
 563.353 -		pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
 563.354 -		break;
 563.355 -	}
 563.356 -}
 563.357 -
 563.358 -void Direct3DDisplay::restoreDeviceObjects()
 563.359 -{
 563.360 -	// Store render target surface desc
 563.361 -	LPDIRECT3DSURFACE8 pBackBuffer;
 563.362 -	HRESULT hr;
 563.363 -	if (SUCCEEDED(hr = pDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer)))
 563.364 -	{
 563.365 -		pBackBuffer->GetDesc(&dsdBackBuffer);
 563.366 -		pBackBuffer->Release();
 563.367 -	}
 563.368 -	else
 563.369 -		systemMessage(0, "Failed GetBackBuffer %08x", hr);
 563.370 -
 563.371 -	// Set up the texture
 563.372 -	pDevice->SetTextureStageState(0, D3DTSS_COLOROP,   D3DTOP_MODULATE);
 563.373 -	pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
 563.374 -	pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
 563.375 -
 563.376 -	int filter = regQueryDwordValue("d3dFilter", 0);
 563.377 -	if (filter < 0 || filter > 3)
 563.378 -		filter = 0;
 563.379 -	updateFiltering(filter);
 563.380 -
 563.381 -	// Set miscellaneous render states
 563.382 -	pDevice->SetRenderState(D3DRS_DITHERENABLE,   TRUE);
 563.383 -	pDevice->SetRenderState(D3DRS_ZENABLE,        FALSE);
 563.384 -
 563.385 -	// Set the projection matrix
 563.386 -	D3DXMATRIX matProj;
 563.387 -	FLOAT      fAspect = ((FLOAT)dsdBackBuffer.Width) / dsdBackBuffer.Height;
 563.388 -	D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f);
 563.389 -	pDevice->SetTransform(D3DTS_PROJECTION, &matProj);
 563.390 -
 563.391 -	// turn off lighting
 563.392 -	pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
 563.393 -
 563.394 -	if (pFont)
 563.395 -	{
 563.396 -		pFont->Release();
 563.397 -		pFont = NULL;
 563.398 -	}
 563.399 -	// Create a D3D font using D3DX
 563.400 -	HFONT hFont = CreateFont(14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
 563.401 -	                         ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
 563.402 -	                         ANTIALIASED_QUALITY, FF_DONTCARE, "Arial");
 563.403 -	D3DXCreateFont(pDevice, hFont, &pFont);
 563.404 -}
 563.405 -
 563.406 -void Direct3DDisplay::clear()
 563.407 -{}
 563.408 -
 563.409 -void Direct3DDisplay::renderMenu()
 563.410 -{
 563.411 -	checkFullScreen();
 563.412 -	if (theApp.m_pMainWnd)
 563.413 -		theApp.m_pMainWnd->DrawMenuBar();
 563.414 -}
 563.415 -
 563.416 -void Direct3DDisplay::checkFullScreen()
 563.417 -{
 563.418 -	//  if(tripleBuffering)
 563.419 -	//    pDirect3D->FlipToGDISurface();
 563.420 -}
 563.421 -
 563.422 -void Direct3DDisplay::calculateVertices()
 563.423 -{
 563.424 -	// color
 563.425 -	D3DCOLOR col = 0xFFFFFFFF;
 563.426 -
 563.427 -	// calculate rhw
 563.428 -	FLOAT z	  = 1.0f;
 563.429 -	FLOAT rhw = 1.0f / (z * 990.0f + 10.0f);
 563.430 -
 563.431 -	// -0.5f is necessary in order to match texture alignment to display pixels
 563.432 -	FLOAT left     = -0.5f;
 563.433 -	FLOAT right    = dpp.BackBufferWidth - 0.5f;
 563.434 -	FLOAT top      = -0.5f;
 563.435 -	FLOAT bottom   = dpp.BackBufferHeight - 0.5f;
 563.436 -
 563.437 -	FLOAT textureX = (FLOAT)theApp.rect.right / (FLOAT)textureSize;
 563.438 -	FLOAT textureY = (FLOAT)theApp.rect.bottom / (FLOAT)textureSize;
 563.439 -
 563.440 -//#define D3D_DRAW_SINGLE_RECTANGLE
 563.441 -#ifdef D3D_DRAW_SINGLE_RECTANGLE
 563.442 -	// set up a rectangle
 563.443 -	verts[0] = D3DTLVERTEX(D3DXVECTOR3(left,  top,    z), rhw, col, 0.0f,     0.0f);
 563.444 -	verts[1] = D3DTLVERTEX(D3DXVECTOR3(right, top,    z), rhw, col, textureX, 0.0f);
 563.445 -	verts[2] = D3DTLVERTEX(D3DXVECTOR3(right, bottom, z), rhw, col, textureX, textureY);
 563.446 -	verts[3] = D3DTLVERTEX(D3DXVECTOR3(left,  bottom, z), rhw, col, 0.0f,     textureY);
 563.447 -#else
 563.448 -	// set up triangles
 563.449 -	verts[0] = D3DTLVERTEX(D3DXVECTOR3(left,  bottom, z), rhw, col, 0.0f,     textureY);
 563.450 -	verts[1] = D3DTLVERTEX(D3DXVECTOR3(left,  top,    z), rhw, col, 0.0f,     0.0f);
 563.451 -	verts[2] = D3DTLVERTEX(D3DXVECTOR3(right, bottom, z), rhw, col, textureX, textureY);
 563.452 -	verts[3] = D3DTLVERTEX(D3DXVECTOR3(right, top,    z), rhw, col, textureX, 0.0f);
 563.453 -#endif
 563.454 -}
 563.455 -
 563.456 -void Direct3DDisplay::render()
 563.457 -{
 563.458 -	if (!pDevice)
 563.459 -		return;
 563.460 -
 563.461 -	// Test the cooperative level to see if it's okay to render
 563.462 -	if (FAILED(pDevice->TestCooperativeLevel()))
 563.463 -	{
 563.464 -		return;
 563.465 -	}
 563.466 -	pDevice->Clear(0L, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0L);
 563.467 -
 563.468 -	if (SUCCEEDED(pDevice->BeginScene()))
 563.469 -	{
 563.470 -		D3DLOCKED_RECT locked;
 563.471 -		if (pTexture && SUCCEEDED(pTexture->LockRect(0, &locked, NULL, 0)))
 563.472 -		{
 563.473 -			if (theApp.filterFunction)
 563.474 -			{
 563.475 -				if (systemColorDepth == 16)
 563.476 -					theApp.filterFunction(pix + theApp.filterWidth * 2 + 4,
 563.477 -					                      theApp.filterWidth*2 + 4,
 563.478 -					                      (u8 *)theApp.delta,
 563.479 -					                      (u8 *)locked.pBits,
 563.480 -					                      locked.Pitch,
 563.481 -					                      theApp.filterWidth,
 563.482 -					                      theApp.filterHeight);
 563.483 -				else
 563.484 -					theApp.filterFunction(pix + theApp.filterWidth * 4 + 4,
 563.485 -					                      theApp.filterWidth * 4 + 4,
 563.486 -					                      (u8 *)theApp.delta,
 563.487 -					                      (u8 *)locked.pBits,
 563.488 -					                      locked.Pitch,
 563.489 -					                      theApp.filterWidth,
 563.490 -					                      theApp.filterHeight);
 563.491 -			}
 563.492 -			else
 563.493 -			{
 563.494 -				int copyX = 240;
 563.495 -				int copyY = 160;
 563.496 -
 563.497 -				if (systemCartridgeType == 1)
 563.498 -				{
 563.499 -					if (gbBorderOn)
 563.500 -					{
 563.501 -						copyX = 256;
 563.502 -						copyY = 224;
 563.503 -					}
 563.504 -					else
 563.505 -					{
 563.506 -						copyX = 160;
 563.507 -						copyY = 144;
 563.508 -					}
 563.509 -				}
 563.510 -				// MMX doesn't seem to be faster to copy the data
 563.511 -				__asm {
 563.512 -					mov eax, copyX;
 563.513 -					mov ebx, copyY;
 563.514 -
 563.515 -					mov esi, pix;
 563.516 -					mov edi, locked.pBits;
 563.517 -					mov edx, locked.Pitch;
 563.518 -					cmp systemColorDepth, 16;
 563.519 -					jnz gbaOtherColor;
 563.520 -					sub edx, eax;
 563.521 -					sub edx, eax;
 563.522 -					lea esi, [esi+2*eax+4];
 563.523 -					shr eax, 1;
 563.524 -gbaLoop16bit:
 563.525 -					mov ecx, eax;
 563.526 -					repz movsd;
 563.527 -					inc  esi;
 563.528 -					inc  esi;
 563.529 -					inc  esi;
 563.530 -					inc  esi;
 563.531 -					add  edi, edx;
 563.532 -					dec  ebx;
 563.533 -					jnz  gbaLoop16bit;
 563.534 -					jmp  gbaLoopEnd;
 563.535 -gbaOtherColor:
 563.536 -					cmp systemColorDepth, 32;
 563.537 -					jnz gbaOtherColor2;
 563.538 -
 563.539 -					sub edx, eax;
 563.540 -					sub edx, eax;
 563.541 -					sub edx, eax;
 563.542 -					sub edx, eax;
 563.543 -					lea esi, [esi+4*eax+4];
 563.544 -gbaLoop32bit:
 563.545 -					mov ecx, eax;
 563.546 -					repz movsd;
 563.547 -					add  esi, 4;
 563.548 -					add  edi, edx;
 563.549 -					dec  ebx;
 563.550 -					jnz  gbaLoop32bit;
 563.551 -					jmp  gbaLoopEnd;
 563.552 -gbaOtherColor2:
 563.553 -					lea eax, [eax+2*eax];
 563.554 -					sub edx, eax;
 563.555 -gbaLoop24bit:
 563.556 -					mov ecx, eax;
 563.557 -					shr  ecx, 2;
 563.558 -					repz movsd;
 563.559 -					add  edi, edx;
 563.560 -					dec  ebx;
 563.561 -					jnz  gbaLoop24bit;
 563.562 -gbaLoopEnd:
 563.563 -				}
 563.564 -			}
 563.565 -
 563.566 -			if (theApp.videoOption > VIDEO_4X && theApp.showSpeed)
 563.567 -			{
 563.568 -				char buffer[30];
 563.569 -				if (theApp.showSpeed == 1)
 563.570 -					sprintf(buffer, "%3d%%", systemSpeed);
 563.571 -				else
 563.572 -					sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
 563.573 -					        systemFrameSkip,
 563.574 -					        theApp.showRenderedFrames);
 563.575 -				if (theApp.showSpeedTransparent)
 563.576 -					drawTextTransp((u8 *)locked.pBits,
 563.577 -					               locked.Pitch,
 563.578 -					               theApp.rect.left+10,
 563.579 -					               theApp.rect.bottom-10,
 563.580 -					               buffer);
 563.581 -				else
 563.582 -					drawText((u8 *)locked.pBits,
 563.583 -					         locked.Pitch,
 563.584 -					         theApp.rect.left+10,
 563.585 -					         theApp.rect.bottom-10,
 563.586 -					         buffer);
 563.587 -			}
 563.588 -
 563.589 -			if (textMethod == 1)
 563.590 -			{
 563.591 -				DrawTextMessages((u8 *)locked.pBits, locked.Pitch, theApp.rect.left, theApp.rect.bottom);
 563.592 -			}
 563.593 -
 563.594 -			pTexture->UnlockRect(0);
 563.595 -
 563.596 -			// set the texture
 563.597 -			pDevice->SetTexture(0, pTexture);
 563.598 -
 563.599 -			// configure shader for vertex type
 563.600 -			pDevice->SetVertexShader(D3DFVF_TLVERTEX);
 563.601 -
 563.602 -#ifdef D3D_DRAW_SINGLE_RECTANGLE
 563.603 -			// draw the rectangle
 563.604 -				pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(D3DTLVERTEX));
 563.605 -			//#undef D3D_DRAW_RECT
 563.606 -#else
 563.607 -			// draw the triangles
 563.608 -			pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, verts, sizeof(D3DTLVERTEX));
 563.609 -#endif
 563.610 -		}
 563.611 -
 563.612 -		if (textMethod == 2)
 563.613 -		{
 563.614 -			for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
 563.615 -			{
 563.616 -				if (theApp.screenMessage[slot])
 563.617 -				{
 563.618 -					if ((theApp.screenMessageDuration[slot] < 0 || 
 563.619 -						(int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
 563.620 -					    (!theApp.disableStatusMessage || slot == 1 || slot == 2) && pFont)
 563.621 -					{
 563.622 -						pFont->Begin();
 563.623 -						RECT     r;
 563.624 -						D3DCOLOR color;
 563.625 -
 563.626 -						r.left   = 10;
 563.627 -						r.top    = dpp.BackBufferHeight - 20*(slot+1);
 563.628 -						r.right  = dpp.BackBufferWidth - 10;
 563.629 -						r.bottom = r.top + 20;
 563.630 -
 563.631 -						if (outlinedText)
 563.632 -						{
 563.633 -							color = textColor != 7 ? D3DCOLOR_ARGB(255, 0, 0, 0) : D3DCOLOR_ARGB(255, 255, 255, 255);
 563.634 -
 563.635 -							// draw outline
 563.636 -							const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 563.637 -							const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
 563.638 -							for (int i = 0; i < 8; i++)
 563.639 -							{
 563.640 -								RECT r2 = r;
 563.641 -								r2.left += xd[i]; r2.right += xd[i];
 563.642 -								r2.top  += yd[i]; r2.bottom += yd[i];
 563.643 -
 563.644 -								pFont->DrawText(theApp.screenMessageBuffer[slot], -1, &r2, 0, color);
 563.645 -							}
 563.646 -						}
 563.647 -
 563.648 -						// draw center text
 563.649 -						switch (textColor)
 563.650 -						{
 563.651 -						case 0:
 563.652 -							color = D3DCOLOR_ARGB(255, 255, 255, 255); break;
 563.653 -						case 1:
 563.654 -							color = D3DCOLOR_ARGB(255, 255, 0, 0); break;
 563.655 -						case 2:
 563.656 -							color = D3DCOLOR_ARGB(255, 255, 255, 0); break;
 563.657 -						case 3:
 563.658 -							color = D3DCOLOR_ARGB(255, 0, 255, 0); break;
 563.659 -						case 4:
 563.660 -							color = D3DCOLOR_ARGB(255, 0, 255, 255); break;
 563.661 -						case 5:
 563.662 -							color = D3DCOLOR_ARGB(255, 0, 0, 255); break;
 563.663 -						case 6:
 563.664 -							color = D3DCOLOR_ARGB(255, 255, 0, 255); break;
 563.665 -						case 7:
 563.666 -							color = D3DCOLOR_ARGB(255, 0, 0, 0); break;
 563.667 -						}
 563.668 -						pFont->DrawText(theApp.screenMessageBuffer[slot], -1, &r, 0, color);
 563.669 -
 563.670 -						pFont->End();
 563.671 -					}
 563.672 -					else
 563.673 -					{
 563.674 -						theApp.screenMessage[slot] = false;
 563.675 -					}
 563.676 -				}
 563.677 -			}
 563.678 -		}
 563.679 -
 563.680 -		pDevice->EndScene();
 563.681 -
 563.682 -		pDevice->Present(NULL, NULL, NULL, NULL);
 563.683 -	}
 563.684 -}
 563.685 -
 563.686 -void Direct3DDisplay::invalidateDeviceObjects()
 563.687 -{
 563.688 -	if (pFont)
 563.689 -		pFont->Release();
 563.690 -	pFont = NULL;
 563.691 -}
 563.692 -
 563.693 -void Direct3DDisplay::resize(int w, int h)
 563.694 -{
 563.695 -	if (pDevice && w > 0 && h > 0)
 563.696 -	{
 563.697 -		dpp.BackBufferWidth  = w;
 563.698 -		dpp.BackBufferHeight = h;
 563.699 -		HRESULT hr;
 563.700 -		invalidateDeviceObjects();
 563.701 -		if (SUCCEEDED(hr = pDevice->Reset(&dpp)))
 563.702 -		{
 563.703 -			restoreDeviceObjects();
 563.704 -		}
 563.705 -		else
 563.706 -			systemMessage(0, "Failed device reset %08x", hr);
 563.707 -	}
 563.708 -	calculateVertices();
 563.709 -}
 563.710 -
 563.711 -bool Direct3DDisplay::changeRenderSize(int w, int h)
 563.712 -{
 563.713 -	if (w != width || h != height)
 563.714 -	{
 563.715 -		if (pTexture)
 563.716 -		{
 563.717 -			pTexture->Release();
 563.718 -			pTexture = NULL;
 563.719 -		}
 563.720 -		if (!initializeOffscreen(w, h))
 563.721 -		{
 563.722 -			failed = true;
 563.723 -			return false;
 563.724 -		}
 563.725 -	}
 563.726 -	calculateVertices();
 563.727 -
 563.728 -	return true;
 563.729 -}
 563.730 -
 563.731 -void Direct3DDisplay::setOption(const char *option, int value)
 563.732 -{
 563.733 -	if (!strcmp(option, "d3dFilter"))
 563.734 -		updateFiltering(value);
 563.735 -}
 563.736 -
 563.737 -int Direct3DDisplay::selectFullScreenMode(GUID * *)
 563.738 -{
 563.739 -	HWND wnd = GetDesktopWindow();
 563.740 -	RECT r;
 563.741 -	GetWindowRect(wnd, &r);
 563.742 -	int w  = (r.right - r.left) & 4095;
 563.743 -	int h  = (r.bottom - r.top) & 4095;
 563.744 -	HDC dc = GetDC(wnd);
 563.745 -	int c  = GetDeviceCaps(dc, BITSPIXEL);
 563.746 -	ReleaseDC(wnd, dc);
 563.747 -
 563.748 -	return (c << 24) | (w << 12) | h;
 563.749 -}
 563.750 -
 563.751 -IDisplay *newDirect3DDisplay()
 563.752 -{
 563.753 -	return new Direct3DDisplay();
 563.754 -}
 563.755 -
   564.1 --- a/src/win32/DirectDraw.cpp	Sat Mar 03 10:54:39 2012 -0600
   564.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   564.3 @@ -1,921 +0,0 @@
   564.4 -#include "stdafx.h"
   564.5 -
   564.6 -#define DIRECTDRAW_VERSION 0x0700
   564.7 -#include "ddraw.h"
   564.8 -
   564.9 -#include "resource.h"
  564.10 -#include "MainWnd.h"
  564.11 -#include "Reg.h"
  564.12 -#include "VBA.h"
  564.13 -
  564.14 -#include "../common/System.h"
  564.15 -#include "../gba/GBAGlobals.h"
  564.16 -#include "../gb/gbGlobals.h"
  564.17 -#include "../common/Text.h"
  564.18 -#include "../version.h"
  564.19 -
  564.20 -extern u32 RGB_LOW_BITS_MASK;
  564.21 -extern int systemSpeed;
  564.22 -extern int Init_2xSaI(u32);
  564.23 -extern void directXMessage(const char *);
  564.24 -extern void winlog(const char *, ...);
  564.25 -extern int winVideoModeSelect(CWnd *, GUID * *);
  564.26 -
  564.27 -class DirectDrawDisplay : public IDisplay
  564.28 -{
  564.29 -private:
  564.30 -	HINSTANCE ddrawDLL;
  564.31 -	LPDIRECTDRAW7        pDirectDraw;
  564.32 -	LPDIRECTDRAWSURFACE7 ddsPrimary;
  564.33 -	LPDIRECTDRAWSURFACE7 ddsOffscreen;
  564.34 -	LPDIRECTDRAWSURFACE7 ddsFlip;
  564.35 -	LPDIRECTDRAWCLIPPER  ddsClipper;
  564.36 -	int  width;
  564.37 -	int  height;
  564.38 -	bool failed;
  564.39 -
  564.40 -	bool initializeOffscreen(int w, int h);
  564.41 -public:
  564.42 -	DirectDrawDisplay();
  564.43 -	virtual ~DirectDrawDisplay();
  564.44 -
  564.45 -	virtual bool initialize();
  564.46 -	virtual void cleanup();
  564.47 -	virtual void render();
  564.48 -	virtual void checkFullScreen();
  564.49 -	virtual void renderMenu();
  564.50 -	virtual void clear();
  564.51 -	virtual bool changeRenderSize(int w, int h);
  564.52 -	virtual DISPLAY_TYPE getType() { return DIRECT_DRAW; };
  564.53 -	virtual void setOption(const char *, int) {}
  564.54 -	virtual int selectFullScreenMode(GUID * *);
  564.55 -};
  564.56 -
  564.57 -static HRESULT WINAPI checkModesAvailable(LPDDSURFACEDESC2 surf, LPVOID lpContext)
  564.58 -{
  564.59 -	if (surf->dwWidth == 320 &&
  564.60 -	    surf->dwHeight == 240 &&
  564.61 -	    surf->ddpfPixelFormat.dwRGBBitCount == 16)
  564.62 -	{
  564.63 -		theApp.mode320Available = TRUE;
  564.64 -	}
  564.65 -	if (surf->dwWidth == 640 &&
  564.66 -	    surf->dwHeight == 480 &&
  564.67 -	    surf->ddpfPixelFormat.dwRGBBitCount == 16)
  564.68 -	{
  564.69 -		theApp.mode640Available = TRUE;
  564.70 -	}
  564.71 -	if (surf->dwWidth == 800 &&
  564.72 -	    surf->dwHeight == 600 &&
  564.73 -	    surf->ddpfPixelFormat.dwRGBBitCount == 16)
  564.74 -	{
  564.75 -		theApp.mode800Available = TRUE;
  564.76 -	}
  564.77 -	return DDENUMRET_OK;
  564.78 -}
  564.79 -
  564.80 -static int ffs(UINT mask)
  564.81 -{
  564.82 -	int m = 0;
  564.83 -	if (mask)
  564.84 -	{
  564.85 -		while (!(mask & (1 << m)))
  564.86 -			m++;
  564.87 -
  564.88 -		return (m);
  564.89 -	}
  564.90 -
  564.91 -	return (0);
  564.92 -}
  564.93 -
  564.94 -DirectDrawDisplay::DirectDrawDisplay()
  564.95 -{
  564.96 -	pDirectDraw  = NULL;
  564.97 -	ddsPrimary   = NULL;
  564.98 -	ddsOffscreen = NULL;
  564.99 -	ddsFlip      = NULL;
 564.100 -	ddsClipper   = NULL;
 564.101 -	ddrawDLL     = NULL;
 564.102 -	width        = 0;
 564.103 -	height       = 0;
 564.104 -	failed       = false;
 564.105 -}
 564.106 -
 564.107 -DirectDrawDisplay::~DirectDrawDisplay()
 564.108 -{
 564.109 -	cleanup();
 564.110 -}
 564.111 -
 564.112 -void DirectDrawDisplay::cleanup()
 564.113 -{
 564.114 -	if (pDirectDraw != NULL)
 564.115 -	{
 564.116 -		if (ddsClipper != NULL)
 564.117 -		{
 564.118 -			ddsClipper->Release();
 564.119 -			ddsClipper = NULL;
 564.120 -		}
 564.121 -
 564.122 -		if (ddsFlip != NULL)
 564.123 -		{
 564.124 -			ddsFlip->Release();
 564.125 -			ddsFlip = NULL;
 564.126 -		}
 564.127 -
 564.128 -		if (ddsOffscreen != NULL)
 564.129 -		{
 564.130 -			ddsOffscreen->Release();
 564.131 -			ddsOffscreen = NULL;
 564.132 -		}
 564.133 -
 564.134 -		if (ddsPrimary != NULL)
 564.135 -		{
 564.136 -			ddsPrimary->Release();
 564.137 -			ddsPrimary = NULL;
 564.138 -		}
 564.139 -
 564.140 -		pDirectDraw->Release();
 564.141 -		pDirectDraw = NULL;
 564.142 -	}
 564.143 -
 564.144 -	if (ddrawDLL != NULL)
 564.145 -	{
 564.146 -		/**/ ::FreeLibrary(ddrawDLL);
 564.147 -		ddrawDLL = NULL;
 564.148 -	}
 564.149 -	width  = 0;
 564.150 -	height = 0;
 564.151 -}
 564.152 -
 564.153 -bool DirectDrawDisplay::initialize()
 564.154 -{
 564.155 -	CWnd *pWnd = theApp.m_pMainWnd;
 564.156 -
 564.157 -	GUID *guid = NULL;
 564.158 -	if (theApp.ddrawEmulationOnly)
 564.159 -		guid = (GUID *)DDCREATE_EMULATIONONLY;
 564.160 -
 564.161 -	if (theApp.pVideoDriverGUID)
 564.162 -		guid = theApp.pVideoDriverGUID;
 564.163 -
 564.164 -	ddrawDLL = /**/ ::LoadLibrary("DDRAW.DLL");
 564.165 -	HRESULT (WINAPI *DDrawCreateEx)(GUID *, LPVOID *, REFIID, IUnknown *);
 564.166 -	if (ddrawDLL != NULL)
 564.167 -	{
 564.168 -		DDrawCreateEx = (HRESULT (WINAPI *)(GUID *, LPVOID *, REFIID, IUnknown *))
 564.169 -		                GetProcAddress(ddrawDLL, "DirectDrawCreateEx");
 564.170 -
 564.171 -		if (DDrawCreateEx == NULL)
 564.172 -		{
 564.173 -			directXMessage("DirectDrawCreateEx");
 564.174 -			return FALSE;
 564.175 -		}
 564.176 -	}
 564.177 -	else
 564.178 -	{
 564.179 -		directXMessage("DDRAW.DLL");
 564.180 -		return FALSE;
 564.181 -	}
 564.182 -
 564.183 -	theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly;
 564.184 -
 564.185 -	HRESULT hret = DDrawCreateEx(guid,
 564.186 -	                             (void * *)&pDirectDraw,
 564.187 -	                             IID_IDirectDraw7,
 564.188 -	                             NULL);
 564.189 -
 564.190 -	if (hret != DD_OK)
 564.191 -	{
 564.192 -		winlog("Error creating DirectDraw object %08x\n", hret);
 564.193 -		if (theApp.ddrawEmulationOnly)
 564.194 -		{
 564.195 -			// disable emulation only setting in case of failure
 564.196 -			regSetDwordValue("ddrawEmulationOnly", 0);
 564.197 -		}
 564.198 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret);
 564.199 -		return FALSE;
 564.200 -	}
 564.201 -
 564.202 -	if (theApp.ddrawDebug)
 564.203 -	{
 564.204 -		DDCAPS driver;
 564.205 -		DDCAPS hel;
 564.206 -		ZeroMemory(&driver, sizeof(driver));
 564.207 -		ZeroMemory(&hel, sizeof(hel));
 564.208 -		driver.dwSize = sizeof(driver);
 564.209 -		hel.dwSize    = sizeof(hel);
 564.210 -		pDirectDraw->GetCaps(&driver, &hel);
 564.211 -		int    i;
 564.212 -		DWORD *p = (DWORD *)&driver;
 564.213 -		for (i = 0; i < (int)driver.dwSize; i += 4)
 564.214 -			winlog("Driver CAPS %2d: %08x\n", i>>2, *p++);
 564.215 -		p = (DWORD *)&hel;
 564.216 -		for (i = 0; i < (int)hel.dwSize; i += 4)
 564.217 -			winlog("HEL CAPS %2d: %08x\n", i>>2, *p++);
 564.218 -	}
 564.219 -
 564.220 -	theApp.mode320Available = false;
 564.221 -	theApp.mode640Available = false;
 564.222 -	theApp.mode800Available = false;
 564.223 -
 564.224 -	// check for available fullscreen modes
 564.225 -	pDirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, NULL, checkModesAvailable);
 564.226 -
 564.227 -	DWORD flags = DDSCL_NORMAL;
 564.228 -
 564.229 -	if (theApp.videoOption >= VIDEO_320x240)
 564.230 -		flags = DDSCL_ALLOWMODEX |
 564.231 -		        DDSCL_ALLOWREBOOT |
 564.232 -		        DDSCL_EXCLUSIVE |
 564.233 -		        DDSCL_FULLSCREEN;
 564.234 -
 564.235 -	hret = pDirectDraw->SetCooperativeLevel(pWnd->m_hWnd, flags);
 564.236 -
 564.237 -	if (hret != DD_OK)
 564.238 -	{
 564.239 -		winlog("Error SetCooperativeLevel %08x\n", hret);
 564.240 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWLEVEL), hret);
 564.241 -		return FALSE;
 564.242 -	}
 564.243 -
 564.244 -	if (theApp.videoOption > VIDEO_4X)
 564.245 -	{
 564.246 -		hret = pDirectDraw->SetDisplayMode(theApp.fsWidth,
 564.247 -		                                   theApp.fsHeight,
 564.248 -		                                   theApp.fsColorDepth,
 564.249 -		                                   0,
 564.250 -		                                   0);
 564.251 -		if (hret != DD_OK)
 564.252 -		{
 564.253 -			winlog("Error SetDisplayMode %08x\n", hret);
 564.254 -			//      errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSET), hret);
 564.255 -			return FALSE;
 564.256 -		}
 564.257 -	}
 564.258 -
 564.259 -	DDSURFACEDESC2 ddsd;
 564.260 -	ZeroMemory(&ddsd, sizeof(ddsd));
 564.261 -	ddsd.dwSize         = sizeof(ddsd);
 564.262 -	ddsd.dwFlags        = DDSD_CAPS;
 564.263 -	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 564.264 -
 564.265 -	if (theApp.videoOption > VIDEO_4X && theApp.tripleBuffering)
 564.266 -	{
 564.267 -		// setup triple buffering
 564.268 -		ddsd.dwFlags		  |= DDSD_BACKBUFFERCOUNT;
 564.269 -		ddsd.ddsCaps.dwCaps   |= DDSCAPS_COMPLEX | DDSCAPS_FLIP;
 564.270 -		ddsd.dwBackBufferCount = 2;
 564.271 -	}
 564.272 -
 564.273 -	hret = pDirectDraw->CreateSurface(&ddsd, &ddsPrimary, NULL);
 564.274 -	if (hret != DD_OK)
 564.275 -	{
 564.276 -		winlog("Error primary CreateSurface %08x\n", hret);
 564.277 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSURFACE), hret);
 564.278 -		return FALSE;
 564.279 -	}
 564.280 -
 564.281 -	if (theApp.ddrawDebug)
 564.282 -	{
 564.283 -		DDSCAPS2 caps;
 564.284 -		ZeroMemory(&caps, sizeof(caps));
 564.285 -		ddsPrimary->GetCaps(&caps);
 564.286 -
 564.287 -		winlog("Primary CAPS 1: %08x\n", caps.dwCaps);
 564.288 -		winlog("Primary CAPS 2: %08x\n", caps.dwCaps2);
 564.289 -		winlog("Primary CAPS 3: %08x\n", caps.dwCaps3);
 564.290 -		winlog("Primary CAPS 4: %08x\n", caps.dwCaps4);
 564.291 -	}
 564.292 -
 564.293 -	if (theApp.videoOption > VIDEO_4X && theApp.tripleBuffering)
 564.294 -	{
 564.295 -		DDSCAPS2 caps;
 564.296 -		ZeroMemory(&caps, sizeof(caps));
 564.297 -		// this gets the third surface. The front one is the primary,
 564.298 -		// the second is the backbuffer and the third is the flip
 564.299 -		// surface
 564.300 -		caps.dwCaps = DDSCAPS_BACKBUFFER;
 564.301 -
 564.302 -		hret = ddsPrimary->GetAttachedSurface(&caps, &ddsFlip);
 564.303 -		if (hret != DD_OK)
 564.304 -		{
 564.305 -			winlog("Failed to get attached surface %08x", hret);
 564.306 -			return FALSE;
 564.307 -		}
 564.308 -		ddsFlip->AddRef();
 564.309 -		clear();
 564.310 -	}
 564.311 -
 564.312 -	// create clipper in all modes to avoid paint problems
 564.313 -	//  if(videoOption <= VIDEO_4X) {
 564.314 -	hret = pDirectDraw->CreateClipper(0, &ddsClipper, NULL);
 564.315 -	if (hret == DD_OK)
 564.316 -	{
 564.317 -		ddsClipper->SetHWnd(0, pWnd->m_hWnd);
 564.318 -		if (theApp.videoOption > VIDEO_4X)
 564.319 -		{
 564.320 -			if (theApp.tripleBuffering)
 564.321 -				ddsFlip->SetClipper(ddsClipper);
 564.322 -			else
 564.323 -				ddsPrimary->SetClipper(ddsClipper);
 564.324 -		}
 564.325 -		else
 564.326 -			ddsPrimary->SetClipper(ddsClipper);
 564.327 -	}
 564.328 -	//  }
 564.329 -
 564.330 -	DDPIXELFORMAT px;
 564.331 -
 564.332 -	px.dwSize = sizeof(px);
 564.333 -
 564.334 -	hret = ddsPrimary->GetPixelFormat(&px);
 564.335 -
 564.336 -	switch (px.dwRGBBitCount)
 564.337 -	{
 564.338 -	case 15:
 564.339 -	case 16:
 564.340 -		systemColorDepth = 16;
 564.341 -		break;
 564.342 -	case 24:
 564.343 -		systemColorDepth      = 24;
 564.344 -		theApp.filterFunction = NULL;
 564.345 -		break;
 564.346 -	case 32:
 564.347 -		systemColorDepth = 32;
 564.348 -		break;
 564.349 -	default:
 564.350 -		systemMessage(
 564.351 -		    IDS_ERROR_DISP_COLOR,
 564.352 -		    "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode.",
 564.353 -		    px.dwRGBBitCount);
 564.354 -		return FALSE;
 564.355 -	}
 564.356 -	theApp.updateFilter();
 564.357 -	theApp.updateIFB();
 564.358 -
 564.359 -	if (failed)
 564.360 -		return false;
 564.361 -
 564.362 -	pWnd->DragAcceptFiles(TRUE);
 564.363 -
 564.364 -	return true;
 564.365 -}
 564.366 -
 564.367 -bool DirectDrawDisplay::changeRenderSize(int w, int h)
 564.368 -{
 564.369 -	if (w != width || h != height)
 564.370 -	{
 564.371 -		if (ddsOffscreen)
 564.372 -		{
 564.373 -			ddsOffscreen->Release();
 564.374 -			ddsOffscreen = NULL;
 564.375 -		}
 564.376 -		if (!initializeOffscreen(w, h))
 564.377 -		{
 564.378 -			failed = true;
 564.379 -			return false;
 564.380 -		}
 564.381 -	}
 564.382 -	return true;
 564.383 -}
 564.384 -
 564.385 -bool DirectDrawDisplay::initializeOffscreen(int w, int h)
 564.386 -{
 564.387 -	DDSURFACEDESC2 ddsd;
 564.388 -
 564.389 -	ZeroMemory(&ddsd, sizeof(ddsd));
 564.390 -	ddsd.dwSize         = sizeof(ddsd);
 564.391 -	ddsd.dwFlags        = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
 564.392 -	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 564.393 -	if (theApp.ddrawUseVideoMemory)
 564.394 -		ddsd.ddsCaps.dwCaps |= (DDSCAPS_LOCALVIDMEM|DDSCAPS_VIDEOMEMORY);
 564.395 -	ddsd.dwWidth  = w;
 564.396 -	ddsd.dwHeight = h;
 564.397 -
 564.398 -	HRESULT hret = pDirectDraw->CreateSurface(&ddsd, &ddsOffscreen, NULL);
 564.399 -
 564.400 -	if (hret != DD_OK)
 564.401 -	{
 564.402 -		winlog("Error offscreen CreateSurface %08x\n", hret);
 564.403 -		if (theApp.ddrawUseVideoMemory)
 564.404 -		{
 564.405 -			regSetDwordValue("ddrawUseVideoMemory", 0);
 564.406 -		}
 564.407 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSURFACE2), hret);
 564.408 -		return false;
 564.409 -	}
 564.410 -
 564.411 -	if (theApp.ddrawDebug)
 564.412 -	{
 564.413 -		DDSCAPS2 caps;
 564.414 -		ZeroMemory(&caps, sizeof(caps));
 564.415 -		ddsOffscreen->GetCaps(&caps);
 564.416 -
 564.417 -		winlog("Offscreen CAPS 1: %08x\n", caps.dwCaps);
 564.418 -		winlog("Offscreen CAPS 2: %08x\n", caps.dwCaps2);
 564.419 -		winlog("Offscreen CAPS 3: %08x\n", caps.dwCaps3);
 564.420 -		winlog("Offscreen CAPS 4: %08x\n", caps.dwCaps4);
 564.421 -	}
 564.422 -
 564.423 -	DDPIXELFORMAT px;
 564.424 -
 564.425 -	px.dwSize = sizeof(px);
 564.426 -
 564.427 -	hret = ddsOffscreen->GetPixelFormat(&px);
 564.428 -
 564.429 -	if (theApp.ddrawDebug)
 564.430 -	{
 564.431 -		DWORD *pdword = (DWORD *)&px;
 564.432 -		for (int ii = 0; ii < 8; ii++)
 564.433 -		{
 564.434 -			winlog("Pixel format %d %08x\n", ii, pdword[ii]);
 564.435 -		}
 564.436 -	}
 564.437 -
 564.438 -	switch (px.dwRGBBitCount)
 564.439 -	{
 564.440 -	case 15:
 564.441 -	case 16:
 564.442 -		systemColorDepth = 16;
 564.443 -		break;
 564.444 -	case 24:
 564.445 -		systemColorDepth      = 24;
 564.446 -		theApp.filterFunction = NULL;
 564.447 -		break;
 564.448 -	case 32:
 564.449 -		systemColorDepth = 32;
 564.450 -		break;
 564.451 -	default:
 564.452 -		systemMessage(
 564.453 -		    IDS_ERROR_DISP_COLOR,
 564.454 -		    "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode.",
 564.455 -		    px.dwRGBBitCount);
 564.456 -		return FALSE;
 564.457 -	}
 564.458 -	if (theApp.ddrawDebug)
 564.459 -	{
 564.460 -		winlog("R Mask: %08x\n", px.dwRBitMask);
 564.461 -		winlog("G Mask: %08x\n", px.dwGBitMask);
 564.462 -		winlog("B Mask: %08x\n", px.dwBBitMask);
 564.463 -	}
 564.464 -
 564.465 -	systemRedShift   = ffs(px.dwRBitMask);
 564.466 -	systemGreenShift = ffs(px.dwGBitMask);
 564.467 -	systemBlueShift  = ffs(px.dwBBitMask);
 564.468 -
 564.469 -#ifdef MMX
 564.470 -	if (!theApp.disableMMX)
 564.471 -		cpu_mmx = theApp.detectMMX();
 564.472 -	else
 564.473 -		cpu_mmx = 0;
 564.474 -#endif
 564.475 -
 564.476 -	if ((px.dwFlags&DDPF_RGB) != 0 &&
 564.477 -	    px.dwRBitMask == 0xF800 &&
 564.478 -	    px.dwGBitMask == 0x07E0 &&
 564.479 -	    px.dwBBitMask == 0x001F)
 564.480 -	{
 564.481 -		systemGreenShift++;
 564.482 -		Init_2xSaI(565);
 564.483 -		RGB_LOW_BITS_MASK = 0x821;
 564.484 -	}
 564.485 -	else if ((px.dwFlags&DDPF_RGB) != 0 &&
 564.486 -	         px.dwRBitMask == 0x7C00 &&
 564.487 -	         px.dwGBitMask == 0x03E0 &&
 564.488 -	         px.dwBBitMask == 0x001F)
 564.489 -	{
 564.490 -		Init_2xSaI(555);
 564.491 -		RGB_LOW_BITS_MASK = 0x421;
 564.492 -	}
 564.493 -	else if ((px.dwFlags&DDPF_RGB) != 0 &&
 564.494 -	         px.dwRBitMask == 0x001F &&
 564.495 -	         px.dwGBitMask == 0x07E0 &&
 564.496 -	         px.dwBBitMask == 0xF800)
 564.497 -	{
 564.498 -		systemGreenShift++;
 564.499 -		Init_2xSaI(565);
 564.500 -		RGB_LOW_BITS_MASK = 0x821;
 564.501 -	}
 564.502 -	else if ((px.dwFlags&DDPF_RGB) != 0 &&
 564.503 -	         px.dwRBitMask == 0x001F &&
 564.504 -	         px.dwGBitMask == 0x03E0 &&
 564.505 -	         px.dwBBitMask == 0x7C00)
 564.506 -	{
 564.507 -		Init_2xSaI(555);
 564.508 -		RGB_LOW_BITS_MASK = 0x421;
 564.509 -	}
 564.510 -	else
 564.511 -	{
 564.512 -		// 32-bit or 24-bit
 564.513 -		if (systemColorDepth == 32 || systemColorDepth == 24)
 564.514 -		{
 564.515 -			systemRedShift   += 3;
 564.516 -			systemGreenShift += 3;
 564.517 -			systemBlueShift  += 3;
 564.518 -			if (systemColorDepth == 32)
 564.519 -				Init_2xSaI(32);
 564.520 -		}
 564.521 -	}
 564.522 -
 564.523 -	if (theApp.ddrawDebug)
 564.524 -	{
 564.525 -		winlog("R shift: %d\n", systemRedShift);
 564.526 -		winlog("G shift: %d\n", systemGreenShift);
 564.527 -		winlog("B shift: %d\n", systemBlueShift);
 564.528 -	}
 564.529 -
 564.530 -	switch (systemColorDepth)
 564.531 -	{
 564.532 -	case 16:
 564.533 -	{
 564.534 -		for (int i = 0; i < 0x10000; i++)
 564.535 -		{
 564.536 -			systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
 564.537 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 564.538 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 564.539 -		}
 564.540 -		break;
 564.541 -	}
 564.542 -	case 24:
 564.543 -	case 32:
 564.544 -	{
 564.545 -		for (int i = 0; i < 0x10000; i++)
 564.546 -		{
 564.547 -			systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 564.548 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 564.549 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 564.550 -		}
 564.551 -		break;
 564.552 -	}
 564.553 -	}
 564.554 -	width  = w;
 564.555 -	height = h;
 564.556 -	return true;
 564.557 -}
 564.558 -
 564.559 -void DirectDrawDisplay::clear()
 564.560 -{
 564.561 -	if (theApp.videoOption <= VIDEO_4X || !theApp.tripleBuffering || ddsFlip == NULL)
 564.562 -		return;
 564.563 -
 564.564 -	DDBLTFX fx;
 564.565 -	ZeroMemory(&fx, sizeof(fx));
 564.566 -	fx.dwSize      = sizeof(fx);
 564.567 -	fx.dwFillColor = 0;
 564.568 -	ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
 564.569 -	ddsPrimary->Flip(NULL, 0);
 564.570 -	ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
 564.571 -	ddsPrimary->Flip(NULL, 0);
 564.572 -	ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
 564.573 -	ddsPrimary->Flip(NULL, 0);
 564.574 -}
 564.575 -
 564.576 -void DirectDrawDisplay::renderMenu()
 564.577 -{
 564.578 -	checkFullScreen();
 564.579 -	theApp.m_pMainWnd->DrawMenuBar();
 564.580 -}
 564.581 -
 564.582 -void DirectDrawDisplay::checkFullScreen()
 564.583 -{
 564.584 -	if (theApp.tripleBuffering)
 564.585 -		pDirectDraw->FlipToGDISurface();
 564.586 -}
 564.587 -
 564.588 -void DirectDrawDisplay::render()
 564.589 -{
 564.590 -	HRESULT hret;
 564.591 -
 564.592 -	if (pDirectDraw == NULL ||
 564.593 -	    ddsOffscreen == NULL ||
 564.594 -	    ddsPrimary == NULL)
 564.595 -		return;
 564.596 -
 564.597 -	bool fastForward = speedup;
 564.598 -#if (defined(WIN32) && !defined(SDL))
 564.599 -	if (theApp.frameSearchSkipping)
 564.600 -	{
 564.601 -		if (theApp.frameSearchFirstStep)
 564.602 -			fastForward = true;
 564.603 -		else
 564.604 -			return; // don't render skipped frame search frames
 564.605 -	}
 564.606 -#endif
 564.607 -
 564.608 -	DDSURFACEDESC2 ddsDesc;
 564.609 -
 564.610 -	ZeroMemory(&ddsDesc, sizeof(ddsDesc));
 564.611 -
 564.612 -	ddsDesc.dwSize = sizeof(ddsDesc);
 564.613 -
 564.614 -	hret = ddsOffscreen->Lock(NULL,
 564.615 -	                          &ddsDesc,
 564.616 -#ifndef FINAL_VERSION
 564.617 -	                          DDLOCK_NOSYSLOCK |
 564.618 -#endif
 564.619 -	                          DDLOCK_WRITEONLY | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,
 564.620 -	                          NULL);
 564.621 -
 564.622 -	if (hret == DDERR_SURFACELOST)
 564.623 -	{
 564.624 -		hret = ddsPrimary->Restore();
 564.625 -		if (hret == DD_OK)
 564.626 -		{
 564.627 -			hret = ddsOffscreen->Restore();
 564.628 -
 564.629 -			if (hret == DD_OK)
 564.630 -			{
 564.631 -				hret = ddsOffscreen->Lock(NULL,
 564.632 -				                          &ddsDesc,
 564.633 -#ifndef FINAL_VERSION
 564.634 -				                          DDLOCK_NOSYSLOCK |
 564.635 -#endif
 564.636 -				                          DDLOCK_WRITEONLY | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,
 564.637 -				                          NULL);
 564.638 -			}
 564.639 -		}
 564.640 -	}
 564.641 -
 564.642 -	if (hret == DD_OK)
 564.643 -	{
 564.644 -		if (theApp.filterFunction)
 564.645 -		{
 564.646 -			if (systemColorDepth == 16)
 564.647 -				(*theApp.filterFunction)(pix + theApp.filterWidth * 2 + 4,
 564.648 -				                         theApp.filterWidth * 2 + 4,
 564.649 -				                         (u8 *)theApp.delta,
 564.650 -				                         (u8 *)ddsDesc.lpSurface,
 564.651 -				                         ddsDesc.lPitch,
 564.652 -				                         theApp.filterWidth,
 564.653 -				                         theApp.filterHeight);
 564.654 -			else
 564.655 -				(*theApp.filterFunction)(pix + theApp.filterWidth * 4 + 4,
 564.656 -				                         theApp.filterWidth * 4 + 4,
 564.657 -				                         (u8 *)theApp.delta,
 564.658 -				                         (u8 *)ddsDesc.lpSurface,
 564.659 -				                         ddsDesc.lPitch,
 564.660 -				                         theApp.filterWidth,
 564.661 -				                         theApp.filterHeight);
 564.662 -		}
 564.663 -		else
 564.664 -		{
 564.665 -			int copyX = 240;
 564.666 -			int copyY = 160;
 564.667 -
 564.668 -			if (systemCartridgeType == 1)
 564.669 -			{
 564.670 -				if (gbBorderOn)
 564.671 -				{
 564.672 -					copyX = 256;
 564.673 -					copyY = 224;
 564.674 -				}
 564.675 -				else
 564.676 -				{
 564.677 -					copyX = 160;
 564.678 -					copyY = 144;
 564.679 -				}
 564.680 -			}
 564.681 -			// MMX doesn't seem to be faster to copy the data
 564.682 -			__asm {
 564.683 -				mov eax, copyX;
 564.684 -				mov ebx, copyY;
 564.685 -
 564.686 -				mov esi, pix;
 564.687 -				mov edi, ddsDesc.lpSurface;
 564.688 -				mov edx, ddsDesc.lPitch;
 564.689 -				cmp systemColorDepth, 16;
 564.690 -				jnz gbaOtherColor;
 564.691 -				sub edx, eax;
 564.692 -				sub edx, eax;
 564.693 -				lea esi, [esi+2*eax+4];
 564.694 -				shr eax, 1;
 564.695 -gbaLoop16bit:
 564.696 -				mov ecx, eax;
 564.697 -				repz movsd;
 564.698 -				inc  esi;
 564.699 -				inc  esi;
 564.700 -				inc  esi;
 564.701 -				inc  esi;
 564.702 -				add  edi, edx;
 564.703 -				dec  ebx;
 564.704 -				jnz  gbaLoop16bit;
 564.705 -				jmp  gbaLoopEnd;
 564.706 -gbaOtherColor:
 564.707 -				cmp systemColorDepth, 32;
 564.708 -				jnz gbaOtherColor2;
 564.709 -
 564.710 -				sub edx, eax;
 564.711 -				sub edx, eax;
 564.712 -				sub edx, eax;
 564.713 -				sub edx, eax;
 564.714 -				lea esi, [esi+4*eax+4];
 564.715 -gbaLoop32bit:
 564.716 -				mov ecx, eax;
 564.717 -				repz movsd;
 564.718 -				add  esi, 4;
 564.719 -				add  edi, edx;
 564.720 -				dec  ebx;
 564.721 -				jnz  gbaLoop32bit;
 564.722 -				jmp  gbaLoopEnd;
 564.723 -gbaOtherColor2:
 564.724 -				lea eax, [eax+2*eax];
 564.725 -				sub edx, eax;
 564.726 -gbaLoop24bit:
 564.727 -				mov ecx, eax;
 564.728 -				shr  ecx, 2;
 564.729 -				repz movsd;
 564.730 -				add  edi, edx;
 564.731 -				dec  ebx;
 564.732 -				jnz  gbaLoop24bit;
 564.733 -gbaLoopEnd:
 564.734 -			}
 564.735 -		}
 564.736 -		if (theApp.showSpeed && theApp.videoOption > VIDEO_4X)
 564.737 -		{
 564.738 -			char buffer[30];
 564.739 -			if (theApp.showSpeed == 1)
 564.740 -				sprintf(buffer, "%3d%%", systemSpeed);
 564.741 -			else
 564.742 -				sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
 564.743 -				        systemFrameSkip,
 564.744 -				        theApp.showRenderedFrames);
 564.745 -			if (theApp.showSpeedTransparent)
 564.746 -				drawTextTransp((u8 *)ddsDesc.lpSurface,
 564.747 -				               ddsDesc.lPitch,
 564.748 -				               theApp.rect.left+10,
 564.749 -				               theApp.rect.bottom-10,
 564.750 -				               buffer);
 564.751 -			else
 564.752 -				drawText((u8 *)ddsDesc.lpSurface,
 564.753 -				         ddsDesc.lPitch,
 564.754 -				         theApp.rect.left+10,
 564.755 -				         theApp.rect.bottom-10,
 564.756 -				         buffer);
 564.757 -		}
 564.758 -
 564.759 -		if (textMethod == 1)
 564.760 -		{
 564.761 -			DrawTextMessages((u8 *)ddsDesc.lpSurface, ddsDesc.lPitch, theApp.rect.left, theApp.rect.bottom);
 564.762 -		}
 564.763 -	}
 564.764 -	else if (theApp.ddrawDebug)
 564.765 -		winlog("Error during lock: %08x\n", hret);
 564.766 -
 564.767 -	hret = ddsOffscreen->Unlock(NULL);
 564.768 -
 564.769 -	if (hret == DD_OK)
 564.770 -	{
 564.771 -		// the correct point where to wait
 564.772 -		if (theApp.vsync && !fastForward)
 564.773 -		{
 564.774 -			hret = pDirectDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
 564.775 -		}
 564.776 -
 564.777 -		ddsOffscreen->PageLock(0);
 564.778 -		if (theApp.tripleBuffering && theApp.videoOption > VIDEO_4X)
 564.779 -		{
 564.780 -			hret = ddsFlip->Blt(&theApp.dest, ddsOffscreen, NULL, DDBLT_WAIT, NULL);
 564.781 -			if (hret == DD_OK)
 564.782 -			{
 564.783 -				if (theApp.menuToggle || !theApp.active)
 564.784 -				{
 564.785 -					pDirectDraw->FlipToGDISurface();
 564.786 -					ddsPrimary->SetClipper(ddsClipper);
 564.787 -					hret = ddsPrimary->Blt(&theApp.dest, ddsFlip, NULL, DDBLT_ASYNC, NULL);
 564.788 -					// if using emulation only, then we have to redraw the menu
 564.789 -					// everytime. It seems like a bug in DirectDraw to me as we not
 564.790 -					// overwritting the menu area at all.
 564.791 -					if (theApp.ddrawUsingEmulationOnly)
 564.792 -						theApp.m_pMainWnd->DrawMenuBar();
 564.793 -				}
 564.794 -				else
 564.795 -					hret = ddsPrimary->Flip(NULL, 0);
 564.796 -			}
 564.797 -		}
 564.798 -		else
 564.799 -		{
 564.800 -			hret = ddsPrimary->Blt(&theApp.dest, ddsOffscreen, NULL, DDBLT_ASYNC, NULL);
 564.801 -
 564.802 -			if (hret == DDERR_SURFACELOST)
 564.803 -			{
 564.804 -				hret = ddsPrimary->Restore();
 564.805 -
 564.806 -				if (hret == DD_OK)
 564.807 -				{
 564.808 -					hret = ddsPrimary->Blt(&theApp.dest, ddsOffscreen, NULL, DDBLT_ASYNC, NULL);
 564.809 -				}
 564.810 -			}
 564.811 -		}
 564.812 -		ddsOffscreen->PageUnlock(0);
 564.813 -	}
 564.814 -	else if (theApp.ddrawDebug)
 564.815 -		winlog("Error during unlock: %08x\n", hret);
 564.816 -
 564.817 -	bool textMessageStarted = false;
 564.818 -
 564.819 -	if (textMethod == 2)
 564.820 -	{
 564.821 -		HDC hdc;
 564.822 -
 564.823 -		for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
 564.824 -		{
 564.825 -			if (theApp.screenMessage[slot])
 564.826 -			{
 564.827 -				if ((theApp.screenMessageDuration[slot] < 0 || 
 564.828 -					(int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
 564.829 -				    (!theApp.disableStatusMessage || slot == 1 || slot == 2))
 564.830 -				{
 564.831 -					if (!textMessageStarted)
 564.832 -					{
 564.833 -						textMessageStarted = true;
 564.834 -						ddsPrimary->SetClipper(ddsClipper);
 564.835 -						ddsPrimary->GetDC(&hdc);
 564.836 -						SetBkMode(hdc, TRANSPARENT);
 564.837 -						SetTextColor(hdc, textColor != 7 ? RGB(0, 0, 0) : RGB(255, 255, 255));
 564.838 -					}
 564.839 -
 564.840 -					if (outlinedText)
 564.841 -					{
 564.842 -						// draw black outline
 564.843 -						const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 564.844 -						const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
 564.845 -						for (int i = 0; i < 8; i++)
 564.846 -						{
 564.847 -							TextOut(hdc,
 564.848 -							        theApp.dest.left+10+xd[i],
 564.849 -							        theApp.dest.bottom - 20*(slot+1)+yd[i],
 564.850 -							        theApp.screenMessageBuffer[slot],
 564.851 -							        strlen(theApp.screenMessageBuffer[slot]));
 564.852 -						}
 564.853 -					}
 564.854 -				}
 564.855 -				else
 564.856 -				{
 564.857 -					theApp.screenMessage[slot] = false;
 564.858 -				}
 564.859 -			}
 564.860 -		}
 564.861 -
 564.862 -		if (textMessageStarted)
 564.863 -		{
 564.864 -			COLORREF color;
 564.865 -			switch (textColor)
 564.866 -			{
 564.867 -			case 0:
 564.868 -				color = RGB(255, 255, 255); break;
 564.869 -			case 1:
 564.870 -				color = RGB(255, 0, 0); break;
 564.871 -			case 2:
 564.872 -				color = RGB(255, 255, 0); break;
 564.873 -			case 3:
 564.874 -				color = RGB(0, 255, 0); break;
 564.875 -			case 4:
 564.876 -				color = RGB(0, 255, 255); break;
 564.877 -			case 5:
 564.878 -				color = RGB(0, 0, 255); break;
 564.879 -			case 6:
 564.880 -				color = RGB(255, 0, 255); break;
 564.881 -			case 7:
 564.882 -				color = RGB(0, 0, 0); break;
 564.883 -			}
 564.884 -			SetTextColor(hdc, color);
 564.885 -
 564.886 -			// draw center text
 564.887 -			for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
 564.888 -			{
 564.889 -				if (theApp.screenMessage[slot])
 564.890 -				{
 564.891 -					if ((theApp.screenMessageDuration[slot] < 0 || 
 564.892 -						(int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
 564.893 -					    (!theApp.disableStatusMessage || slot == 1 || slot == 2))
 564.894 -					{
 564.895 -						TextOut(hdc, theApp.dest.left+10, theApp.dest.bottom - 20*(slot+1), theApp.screenMessageBuffer[slot],
 564.896 -						        strlen(theApp.screenMessageBuffer[slot]));
 564.897 -					}
 564.898 -				}
 564.899 -			}
 564.900 -		}
 564.901 -
 564.902 -		if (textMessageStarted)
 564.903 -		{
 564.904 -			ddsPrimary->ReleaseDC(hdc);
 564.905 -		}
 564.906 -	}
 564.907 -
 564.908 -	if (hret != DD_OK)
 564.909 -	{
 564.910 -		if (theApp.ddrawDebug)
 564.911 -			winlog("Error on update screen: %08x\n", hret);
 564.912 -	}
 564.913 -}
 564.914 -
 564.915 -int DirectDrawDisplay::selectFullScreenMode(GUID **pGUID)
 564.916 -{
 564.917 -	return winVideoModeSelect(theApp.m_pMainWnd, pGUID);
 564.918 -}
 564.919 -
 564.920 -IDisplay *newDirectDrawDisplay()
 564.921 -{
 564.922 -	return new DirectDrawDisplay();
 564.923 -}
 564.924 -
   565.1 --- a/src/win32/DirectInput.cpp	Sat Mar 03 10:54:39 2012 -0600
   565.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   565.3 @@ -1,1242 +0,0 @@
   565.4 -//#define USE_GETASYNCKEYSTATE_FOR_KEYBOARD
   565.5 -
   565.6 -#include "stdafx.h"
   565.7 -
   565.8 -#define DIRECTINPUT_VERSION 0x0500
   565.9 -#include "dinput.h"
  565.10 -
  565.11 -#include "resource.h"
  565.12 -#include "Input.h"
  565.13 -#include "Reg.h"
  565.14 -#include "WinResUtil.h"
  565.15 -
  565.16 -// master keyboard translation table
  565.17 -static const struct {
  565.18 -	int dik;
  565.19 -	int vk;
  565.20 -	int ascii;
  565.21 -} win_key_trans_table[] = {
  565.22 -	// dinput key		virtual key		ascii
  565.23 -	{ DIK_ESCAPE,		VK_ESCAPE,	 	27 },
  565.24 -	{ DIK_1,			'1',			'1' },
  565.25 -	{ DIK_2,			'2',			'2' },
  565.26 -	{ DIK_3,			'3',			'3' },
  565.27 -	{ DIK_4,			'4',			'4' },
  565.28 -	{ DIK_5,			'5',			'5' },
  565.29 -	{ DIK_6,			'6',			'6' },
  565.30 -	{ DIK_7,			'7',			'7' },
  565.31 -	{ DIK_8,			'8',			'8' },
  565.32 -	{ DIK_9,			'9',			'9' },
  565.33 -	{ DIK_0,			'0',			'0' },
  565.34 -	{ DIK_MINUS, 		VK_OEM_MINUS,	'-' },
  565.35 -	{ DIK_EQUALS,		VK_OEM_PLUS,	'=' },
  565.36 -	{ DIK_BACK, 		VK_BACK, 		8 },
  565.37 -	{ DIK_TAB, 			VK_TAB, 		9 },
  565.38 -	{ DIK_Q,			'Q',			'Q' },
  565.39 -	{ DIK_W,			'W',			'W' },
  565.40 -	{ DIK_E,			'E',			'E' },
  565.41 -	{ DIK_R,			'R',			'R' },
  565.42 -	{ DIK_T,			'T',			'T' },
  565.43 -	{ DIK_Y,			'Y',			'Y' },
  565.44 -	{ DIK_U,			'U',			'U' },
  565.45 -	{ DIK_I,			'I',			'I' },
  565.46 -	{ DIK_O,			'O',			'O' },
  565.47 -	{ DIK_P,			'P',			'P' },
  565.48 -	{ DIK_LBRACKET, 	VK_OEM_4,		'[' },
  565.49 -	{ DIK_RBRACKET, 	VK_OEM_6,		']' },
  565.50 -	{ DIK_RETURN, 		VK_RETURN, 		13 },
  565.51 -	{ DIK_LCONTROL, 	VK_LCONTROL, 	0 },
  565.52 -	{ DIK_A,			'A',			'A' },
  565.53 -	{ DIK_S,			'S',			'S' },
  565.54 -	{ DIK_D,			'D',			'D' },
  565.55 -	{ DIK_F,			'F',			'F' },
  565.56 -	{ DIK_G,			'G',			'G' },
  565.57 -	{ DIK_H,			'H',			'H' },
  565.58 -	{ DIK_J,			'J',			'J' },
  565.59 -	{ DIK_K,			'K',			'K' },
  565.60 -	{ DIK_L,			'L',			'L' },
  565.61 -	{ DIK_SEMICOLON,	VK_OEM_1,		';' },
  565.62 -	{ DIK_APOSTROPHE,	VK_OEM_7,		'\'' },
  565.63 -	{ DIK_GRAVE, 		VK_OEM_3,		'`' },
  565.64 -	{ DIK_LSHIFT, 		VK_LSHIFT, 		0 },
  565.65 -	{ DIK_BACKSLASH, 	VK_OEM_5,		'\\' },
  565.66 -	{ DIK_Z,			'Z',			'Z' },
  565.67 -	{ DIK_X,			'X',			'X' },
  565.68 -	{ DIK_C,			'C',			'C' },
  565.69 -	{ DIK_V,			'V',			'V' },
  565.70 -	{ DIK_B,			'B',			'B' },
  565.71 -	{ DIK_N,			'N',			'N' },
  565.72 -	{ DIK_M,			'M',			'M' },
  565.73 -	{ DIK_COMMA,		VK_OEM_COMMA,	',' },
  565.74 -	{ DIK_PERIOD, 		VK_OEM_PERIOD,	'.' },
  565.75 -	{ DIK_SLASH, 		VK_OEM_2,		'/' },
  565.76 -	{ DIK_RSHIFT, 		VK_RSHIFT, 		0 },
  565.77 -	{ DIK_MULTIPLY, 	VK_MULTIPLY,	'*' },
  565.78 -	{ DIK_LMENU, 		VK_LMENU, 		0 },
  565.79 -	{ DIK_SPACE, 		VK_SPACE,		' ' },
  565.80 -	{ DIK_CAPITAL, 		VK_CAPITAL, 	0 },
  565.81 -	{ DIK_F1,			VK_F1, 			0 },
  565.82 -	{ DIK_F2,			VK_F2, 			0 },
  565.83 -	{ DIK_F3,			VK_F3, 			0 },
  565.84 -	{ DIK_F4,			VK_F4, 			0 },
  565.85 -	{ DIK_F5,			VK_F5, 			0 },
  565.86 -	{ DIK_F6,			VK_F6, 			0 },
  565.87 -	{ DIK_F7,			VK_F7, 			0 },
  565.88 -	{ DIK_F8,			VK_F8, 			0 },
  565.89 -	{ DIK_F9,			VK_F9, 			0 },
  565.90 -	{ DIK_F10,			VK_F10, 		0 },
  565.91 -	{ DIK_NUMLOCK,		VK_NUMLOCK, 	0 },
  565.92 -	{ DIK_SCROLL,		VK_SCROLL, 		0 },
  565.93 -	{ DIK_NUMPAD7,		VK_NUMPAD7, 	0 },
  565.94 -	{ DIK_NUMPAD8,		VK_NUMPAD8, 	0 },
  565.95 -	{ DIK_NUMPAD9,		VK_NUMPAD9, 	0 },
  565.96 -	{ DIK_SUBTRACT,		VK_SUBTRACT, 	0 },
  565.97 -	{ DIK_NUMPAD4,		VK_NUMPAD4, 	0 },
  565.98 -	{ DIK_NUMPAD5,		VK_NUMPAD5, 	0 },
  565.99 -	{ DIK_NUMPAD6,		VK_NUMPAD6, 	0 },
 565.100 -	{ DIK_ADD,			VK_ADD, 		0 },
 565.101 -	{ DIK_NUMPAD1,		VK_NUMPAD1, 	0 },
 565.102 -	{ DIK_NUMPAD2,		VK_NUMPAD2, 	0 },
 565.103 -	{ DIK_NUMPAD3,		VK_NUMPAD3, 	0 },
 565.104 -	{ DIK_NUMPAD0,		VK_NUMPAD0, 	0 },
 565.105 -	{ DIK_DECIMAL,		VK_DECIMAL, 	0 },
 565.106 -	{ DIK_F11,			VK_F11, 		0 },
 565.107 -	{ DIK_F12,			VK_F12, 		0 },
 565.108 -	{ DIK_F13,			VK_F13, 		0 },
 565.109 -	{ DIK_F14,			VK_F14, 		0 },
 565.110 -	{ DIK_F15,			VK_F15, 		0 },
 565.111 -	{ DIK_NUMPADENTER,	VK_RETURN, 		0 },
 565.112 -	{ DIK_RCONTROL,		VK_RCONTROL, 	0 },
 565.113 -	{ DIK_DIVIDE,		VK_DIVIDE, 		0 },
 565.114 -	{ DIK_SYSRQ, 		0, 				0 },
 565.115 -	{ DIK_RMENU,		VK_RMENU, 		0 },
 565.116 -	{ DIK_HOME,			VK_HOME, 		0 },
 565.117 -	{ DIK_UP,			VK_UP, 			0 },
 565.118 -	{ DIK_PRIOR,		VK_PRIOR, 		0 },
 565.119 -	{ DIK_LEFT,			VK_LEFT, 		0 },
 565.120 -	{ DIK_RIGHT,		VK_RIGHT, 		0 },
 565.121 -	{ DIK_END,			VK_END, 		0 },
 565.122 -	{ DIK_DOWN,			VK_DOWN, 		0 },
 565.123 -	{ DIK_NEXT,			VK_NEXT, 		0 },
 565.124 -	{ DIK_INSERT,		VK_INSERT, 		0 },
 565.125 -	{ DIK_DELETE,		VK_DELETE, 		0 },
 565.126 -	{ DIK_LWIN,			VK_LWIN, 		0 },
 565.127 -	{ DIK_RWIN,			VK_RWIN, 		0 },
 565.128 -	{ DIK_APPS,			VK_APPS, 		0 },
 565.129 -	{ DIK_PAUSE,		VK_PAUSE,		0 },
 565.130 -	{ 0,				VK_CANCEL,		0 },
 565.131 -
 565.132 -	// New keys introduced in Windows 2000. These have no MAME codes to
 565.133 -	// preserve compatibility with old config files that may refer to them
 565.134 -	// as e.g. FORWARD instead of e.g. KEYCODE_WEBFORWARD. They need table
 565.135 -	// entries anyway because otherwise they aren't recognized when
 565.136 -	// GetAsyncKeyState polling is used (as happens currently when MAME is
 565.137 -	// paused). Some codes are missing because the mapping to vkey codes
 565.138 -	// isn't clear, and MapVirtualKey is no help.
 565.139 -
 565.140 -	{ DIK_MUTE,			VK_VOLUME_MUTE,			0 },
 565.141 -	{ DIK_VOLUMEDOWN,	VK_VOLUME_DOWN,			0 },
 565.142 -	{ DIK_VOLUMEUP,		VK_VOLUME_UP,			0 },
 565.143 -	{ DIK_WEBHOME,		VK_BROWSER_HOME,		0 },
 565.144 -	{ DIK_WEBSEARCH,	VK_BROWSER_SEARCH,		0 },
 565.145 -	{ DIK_WEBFAVORITES,	VK_BROWSER_FAVORITES,	0 },
 565.146 -	{ DIK_WEBREFRESH,	VK_BROWSER_REFRESH,		0 },
 565.147 -	{ DIK_WEBSTOP,		VK_BROWSER_STOP,		0 },
 565.148 -	{ DIK_WEBFORWARD,	VK_BROWSER_FORWARD,		0 },
 565.149 -	{ DIK_WEBBACK,		VK_BROWSER_BACK,		0 },
 565.150 -	{ DIK_MAIL,			VK_LAUNCH_MAIL,			0 },
 565.151 -	{ DIK_MEDIASELECT,	VK_LAUNCH_MEDIA_SELECT,	0 },
 565.152 -};
 565.153 -
 565.154 -extern void directXMessage(const char *);
 565.155 -extern void winlog(const char *msg, ...);
 565.156 -
 565.157 -#define POV_UP    1
 565.158 -#define POV_DOWN  2
 565.159 -#define POV_RIGHT 4
 565.160 -#define POV_LEFT  8
 565.161 -
 565.162 -class DirectInput : public Input
 565.163 -{
 565.164 -private:
 565.165 -	HINSTANCE dinputDLL;
 565.166 -public:
 565.167 -	virtual void checkDevices();
 565.168 -	DirectInput();
 565.169 -	virtual ~DirectInput();
 565.170 -
 565.171 -	virtual bool initialize();
 565.172 -	virtual bool readDevices();
 565.173 -	virtual u32 readDevice(int which, bool sensor);
 565.174 -	virtual CString getKeyName(LONG_PTR key);
 565.175 -	virtual void checkKeys();
 565.176 -	virtual void activate();
 565.177 -	virtual void loadSettings();
 565.178 -	virtual void saveSettings();
 565.179 -};
 565.180 -
 565.181 -struct deviceInfo
 565.182 -{
 565.183 -	LPDIRECTINPUTDEVICE device;
 565.184 -	BOOL isPolled;
 565.185 -	int  nButtons;
 565.186 -	int  nAxes;
 565.187 -	int  nPovs;
 565.188 -	BOOL first;
 565.189 -	struct
 565.190 -	{
 565.191 -		DWORD offset;
 565.192 -		LONG  center;
 565.193 -		LONG  negative;
 565.194 -		LONG  positive;
 565.195 -	} axis[8];
 565.196 -	int needed;
 565.197 -	union
 565.198 -	{
 565.199 -		UCHAR      data[256];
 565.200 -		DIJOYSTATE state;
 565.201 -	};
 565.202 -};
 565.203 -
 565.204 -static deviceInfo *  currentDevice = NULL;
 565.205 -static int           numDevices    = 1;
 565.206 -static deviceInfo *  pDevices      = NULL;
 565.207 -static LPDIRECTINPUT pDirectInput  = NULL;
 565.208 -static int           joyDebug      = 0;
 565.209 -static int           axisNumber    = 0;
 565.210 -
 565.211 -USHORT joypad[4][13] = {
 565.212 -	{
 565.213 -		DIK_LEFT,  DIK_RIGHT,
 565.214 -		DIK_UP,    DIK_DOWN,
 565.215 -		DIK_Z,     DIK_X,
 565.216 -		DIK_RETURN, DIK_BACK,
 565.217 -		DIK_A,     DIK_S,
 565.218 -		DIK_SPACE, DIK_F12,
 565.219 -		DIK_C
 565.220 -	},
 565.221 -	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 565.222 -	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 565.223 -	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 565.224 -};
 565.225 -
 565.226 -USHORT motion[4] = {
 565.227 -	DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
 565.228 -};
 565.229 -
 565.230 -static int winReadKey(char *name, int num)
 565.231 -{
 565.232 -	char buffer[80];
 565.233 -
 565.234 -	sprintf(buffer, "Joy%d_%s", num, name);
 565.235 -
 565.236 -	return regQueryDwordValue(buffer, (DWORD)-1);
 565.237 -}
 565.238 -
 565.239 -void winReadKeys()
 565.240 -{
 565.241 -	int key = -1;
 565.242 -
 565.243 -	for (int i = 0; i < 4; i++)
 565.244 -	{
 565.245 -		key = winReadKey("Left", i);
 565.246 -		if (key != -1)
 565.247 -			joypad[i][KEY_LEFT] = key;
 565.248 -		key = winReadKey("Right", i);
 565.249 -		if (key != -1)
 565.250 -			joypad[i][KEY_RIGHT] = key;
 565.251 -		key = winReadKey("Up", i);
 565.252 -		if (key != -1)
 565.253 -			joypad[i][KEY_UP] = key;
 565.254 -		key = winReadKey("Down", i);
 565.255 -		if (key != -1)
 565.256 -			joypad[i][KEY_DOWN] = key;
 565.257 -		key = winReadKey("A", i);
 565.258 -		if (key != -1)
 565.259 -			joypad[i][KEY_BUTTON_A] = key;
 565.260 -		key = winReadKey("B", i);
 565.261 -		if (key != -1)
 565.262 -			joypad[i][KEY_BUTTON_B] = key;
 565.263 -		key = winReadKey("L", i);
 565.264 -		if (key != -1)
 565.265 -			joypad[i][KEY_BUTTON_L] = key;
 565.266 -		key = winReadKey("R", i);
 565.267 -		if (key != -1)
 565.268 -			joypad[i][KEY_BUTTON_R] = key;
 565.269 -		key = winReadKey("Start", i);
 565.270 -		if (key != -1)
 565.271 -			joypad[i][KEY_BUTTON_START] = key;
 565.272 -		key = winReadKey("Select", i);
 565.273 -		if (key != -1)
 565.274 -			joypad[i][KEY_BUTTON_SELECT] = key;
 565.275 -		key = winReadKey("Speed", i);
 565.276 -		if (key != -1)
 565.277 -			joypad[i][KEY_BUTTON_SPEED] = key;
 565.278 -		key = winReadKey("Capture", i);
 565.279 -		if (key != -1)
 565.280 -			joypad[i][KEY_BUTTON_CAPTURE] = key;
 565.281 -		key = winReadKey("GS", i);
 565.282 -		if (key != -1)
 565.283 -			joypad[i][KEY_BUTTON_GS] = key;
 565.284 -	}
 565.285 -	key = regQueryDwordValue("Motion_Left", (DWORD)-1);
 565.286 -	if (key != -1)
 565.287 -		motion[KEY_LEFT] = key;
 565.288 -	key = regQueryDwordValue("Motion_Right", (DWORD)-1);
 565.289 -	if (key != -1)
 565.290 -		motion[KEY_RIGHT] = key;
 565.291 -	key = regQueryDwordValue("Motion_Up", (DWORD)-1);
 565.292 -	if (key != -1)
 565.293 -		motion[KEY_UP] = key;
 565.294 -	key = regQueryDwordValue("Motion_Down", (DWORD)-1);
 565.295 -	if (key != -1)
 565.296 -		motion[KEY_DOWN] = key;
 565.297 -}
 565.298 -
 565.299 -static void winSaveKey(char *name, int num, USHORT value)
 565.300 -{
 565.301 -	char buffer[80];
 565.302 -
 565.303 -	sprintf(buffer, "Joy%d_%s", num, name);
 565.304 -
 565.305 -	regSetDwordValue(buffer, value);
 565.306 -}
 565.307 -
 565.308 -void winSaveKeys()
 565.309 -{
 565.310 -	for (int i = 0; i < 4; i++)
 565.311 -	{
 565.312 -		winSaveKey("Left", i, joypad[i][KEY_LEFT]);
 565.313 -		winSaveKey("Right", i, joypad[i][KEY_RIGHT]);
 565.314 -		winSaveKey("Up", i, joypad[i][KEY_UP]);
 565.315 -		winSaveKey("Speed", i, joypad[i][KEY_BUTTON_SPEED]);
 565.316 -		winSaveKey("Capture", i, joypad[i][KEY_BUTTON_CAPTURE]);
 565.317 -		winSaveKey("GS", i, joypad[i][KEY_BUTTON_GS]);
 565.318 -		winSaveKey("Down", i, joypad[i][KEY_DOWN]);
 565.319 -		winSaveKey("A", i, joypad[i][KEY_BUTTON_A]);
 565.320 -		winSaveKey("B", i, joypad[i][KEY_BUTTON_B]);
 565.321 -		winSaveKey("L", i, joypad[i][KEY_BUTTON_L]);
 565.322 -		winSaveKey("R", i, joypad[i][KEY_BUTTON_R]);
 565.323 -		winSaveKey("Start", i, joypad[i][KEY_BUTTON_START]);
 565.324 -		winSaveKey("Select", i, joypad[i][KEY_BUTTON_SELECT]);
 565.325 -	}
 565.326 -	regSetDwordValue("joyVersion", 1);
 565.327 -
 565.328 -	regSetDwordValue("Motion_Left",
 565.329 -	                 motion[KEY_LEFT]);
 565.330 -	regSetDwordValue("Motion_Right",
 565.331 -	                 motion[KEY_RIGHT]);
 565.332 -	regSetDwordValue("Motion_Up",
 565.333 -	                 motion[KEY_UP]);
 565.334 -	regSetDwordValue("Motion_Down",
 565.335 -	                 motion[KEY_DOWN]);
 565.336 -}
 565.337 -
 565.338 -static BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE*pdidoi,
 565.339 -                                      VOID*pContext)
 565.340 -{
 565.341 -	DIPROPRANGE diprg;
 565.342 -	diprg.diph.dwSize       = sizeof(DIPROPRANGE);
 565.343 -	diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 565.344 -	diprg.diph.dwHow        = DIPH_BYOFFSET;
 565.345 -	diprg.diph.dwObj        = pdidoi->dwOfs; // Specify the enumerated axis
 565.346 -
 565.347 -	diprg.lMin = -32768;
 565.348 -	diprg.lMax = 32767;
 565.349 -	// try to set the range
 565.350 -	if (FAILED(currentDevice->device->SetProperty(DIPROP_RANGE, &diprg.diph)))
 565.351 -	{
 565.352 -		// Get the range for the axis
 565.353 -		if (FAILED(currentDevice->device->
 565.354 -		           GetProperty(DIPROP_RANGE, &diprg.diph)))
 565.355 -		{
 565.356 -			return DIENUM_STOP;
 565.357 -		}
 565.358 -	}
 565.359 -
 565.360 -	DIPROPDWORD didz;
 565.361 -
 565.362 -	didz.diph.dwSize       = sizeof(didz);
 565.363 -	didz.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 565.364 -	didz.diph.dwHow        = DIPH_BYOFFSET;
 565.365 -	didz.diph.dwObj        = pdidoi->dwOfs;
 565.366 -
 565.367 -	didz.dwData = 5000;
 565.368 -
 565.369 -	currentDevice->device->SetProperty(DIPROP_DEADZONE, &didz.diph);
 565.370 -
 565.371 -	LONG center    = (diprg.lMin + diprg.lMax)/2;
 565.372 -	LONG threshold = (diprg.lMax - center)/2;
 565.373 -
 565.374 -	// only 8 axis supported
 565.375 -	if (axisNumber < 8)
 565.376 -	{
 565.377 -		currentDevice->axis[axisNumber].center   = center;
 565.378 -		currentDevice->axis[axisNumber].negative = center - threshold;
 565.379 -		currentDevice->axis[axisNumber].positive = center + threshold;
 565.380 -		currentDevice->axis[axisNumber].offset   = pdidoi->dwOfs;
 565.381 -	}
 565.382 -	axisNumber++;
 565.383 -	return DIENUM_CONTINUE;
 565.384 -}
 565.385 -
 565.386 -static BOOL CALLBACK EnumPovsCallback(const DIDEVICEOBJECTINSTANCE*pdidoi,
 565.387 -                                      VOID*pContext)
 565.388 -{
 565.389 -	return DIENUM_CONTINUE;
 565.390 -}
 565.391 -
 565.392 -static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
 565.393 -                                           LPVOID lpvContext)
 565.394 -{
 565.395 -	ZeroMemory(&pDevices[numDevices], sizeof(deviceInfo));
 565.396 -
 565.397 -	HRESULT hRet = pDirectInput->CreateDevice(pInst->guidInstance,
 565.398 -	                                          &pDevices[numDevices].device,
 565.399 -	                                          NULL);
 565.400 -
 565.401 -	if (hRet != DI_OK)
 565.402 -		return DIENUM_STOP;
 565.403 -
 565.404 -	DIDEVCAPS caps;
 565.405 -	caps.dwSize = sizeof(DIDEVCAPS);
 565.406 -
 565.407 -	hRet = pDevices[numDevices].device->GetCapabilities(&caps);
 565.408 -
 565.409 -	if (hRet == DI_OK)
 565.410 -	{
 565.411 -		if (caps.dwFlags & DIDC_POLLEDDATAFORMAT ||
 565.412 -		    caps.dwFlags & DIDC_POLLEDDEVICE)
 565.413 -			pDevices[numDevices].isPolled = TRUE;
 565.414 -
 565.415 -		pDevices[numDevices].nButtons = caps.dwButtons;
 565.416 -		pDevices[numDevices].nAxes    = caps.dwAxes;
 565.417 -		pDevices[numDevices].nPovs    = caps.dwPOVs;
 565.418 -
 565.419 -		for (int i = 0; i < 6; i++)
 565.420 -		{
 565.421 -			pDevices[numDevices].axis[i].center   = 0x8000;
 565.422 -			pDevices[numDevices].axis[i].negative = 0x4000;
 565.423 -			pDevices[numDevices].axis[i].positive = 0xc000;
 565.424 -		}
 565.425 -	}
 565.426 -	else if (joyDebug)
 565.427 -		winlog("Failed to get device capabilities %08x\n", hRet);
 565.428 -
 565.429 -	if (joyDebug)
 565.430 -	{
 565.431 -		// don't translate. debug only
 565.432 -		winlog("******************************\n");
 565.433 -		winlog("Joystick %2d name    : %s\n", numDevices, pInst->tszProductName);
 565.434 -	}
 565.435 -
 565.436 -	numDevices++;
 565.437 -
 565.438 -	return DIENUM_CONTINUE;
 565.439 -}
 565.440 -
 565.441 -BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst,
 565.442 -                                     LPVOID lpvContext)
 565.443 -{
 565.444 -	numDevices++;
 565.445 -
 565.446 -	return DIENUM_CONTINUE;
 565.447 -}
 565.448 -
 565.449 -static int getPovState(DWORD value)
 565.450 -{
 565.451 -	int state = 0;
 565.452 -	if (LOWORD(value) != 0xFFFF)
 565.453 -	{
 565.454 -		if (value < 9000 || value > 27000)
 565.455 -			state |= POV_UP;
 565.456 -		if (value > 0 && value < 18000)
 565.457 -			state |= POV_RIGHT;
 565.458 -		if (value > 9000 && value < 27000)
 565.459 -			state |= POV_DOWN;
 565.460 -		if (value > 18000)
 565.461 -			state |= POV_LEFT;
 565.462 -	}
 565.463 -	return state;
 565.464 -}
 565.465 -
 565.466 -static void checkKeys()
 565.467 -{
 565.468 -	LONG_PTR dev = 0;
 565.469 -	int      i;
 565.470 -
 565.471 -	for (i = 0; i < numDevices; i++)
 565.472 -		pDevices[i].needed = 0;
 565.473 -
 565.474 -	for (i = 0; i < 4; i++)
 565.475 -	{
 565.476 -		dev = joypad[i][KEY_LEFT] >> 8;
 565.477 -		if (dev < numDevices && dev >= 0)
 565.478 -			pDevices[dev].needed = 1;
 565.479 -		else
 565.480 -			joypad[i][KEY_LEFT] = DIK_LEFT;
 565.481 -
 565.482 -		dev = joypad[i][KEY_RIGHT] >> 8;
 565.483 -		if (dev < numDevices && dev >= 0)
 565.484 -			pDevices[dev].needed = 1;
 565.485 -		else
 565.486 -			joypad[i][KEY_RIGHT] = DIK_RIGHT;
 565.487 -
 565.488 -		dev = joypad[i][KEY_UP] >> 8;
 565.489 -		if (dev < numDevices && dev >= 0)
 565.490 -			pDevices[dev].needed = 1;
 565.491 -		else
 565.492 -			joypad[i][KEY_UP] = DIK_UP;
 565.493 -
 565.494 -		dev = joypad[i][KEY_DOWN] >> 8;
 565.495 -		if (dev < numDevices && dev >= 0)
 565.496 -			pDevices[dev].needed = 1;
 565.497 -		else
 565.498 -			joypad[i][KEY_DOWN] = DIK_DOWN;
 565.499 -
 565.500 -		dev = joypad[i][KEY_BUTTON_A] >> 8;
 565.501 -		if (dev < numDevices && dev >= 0)
 565.502 -			pDevices[dev].needed = 1;
 565.503 -		else
 565.504 -			joypad[i][KEY_BUTTON_A] = DIK_Z;
 565.505 -
 565.506 -		dev = joypad[i][KEY_BUTTON_B] >> 8;
 565.507 -		if (dev < numDevices && dev >= 0)
 565.508 -			pDevices[dev].needed = 1;
 565.509 -		else
 565.510 -			joypad[i][KEY_BUTTON_B] = DIK_X;
 565.511 -
 565.512 -		dev = joypad[i][KEY_BUTTON_L] >> 8;
 565.513 -		if (dev < numDevices && dev >= 0)
 565.514 -			pDevices[dev].needed = 1;
 565.515 -		else
 565.516 -			joypad[i][KEY_BUTTON_L] = DIK_A;
 565.517 -
 565.518 -		dev = joypad[i][KEY_BUTTON_R] >> 8;
 565.519 -		if (dev < numDevices && dev >= 0)
 565.520 -			pDevices[dev].needed = 1;
 565.521 -		else
 565.522 -			joypad[i][KEY_BUTTON_R] = DIK_S;
 565.523 -
 565.524 -		dev = joypad[i][KEY_BUTTON_START] >> 8;
 565.525 -		if (dev < numDevices && dev >= 0)
 565.526 -			pDevices[dev].needed = 1;
 565.527 -		else
 565.528 -			joypad[i][KEY_BUTTON_START] = DIK_RETURN;
 565.529 -
 565.530 -		dev = joypad[i][KEY_BUTTON_SELECT] >> 8;
 565.531 -		if (dev < numDevices && dev >= 0)
 565.532 -			pDevices[dev].needed = 1;
 565.533 -		else
 565.534 -			joypad[i][KEY_BUTTON_SELECT] = DIK_BACK;
 565.535 -
 565.536 -		dev = joypad[i][KEY_BUTTON_SPEED] >> 8;
 565.537 -		if (dev < numDevices && dev >= 0)
 565.538 -			pDevices[dev].needed = 1;
 565.539 -		else
 565.540 -			joypad[i][KEY_BUTTON_SPEED] = DIK_SPACE;
 565.541 -
 565.542 -		dev = joypad[i][KEY_BUTTON_CAPTURE] >> 8;
 565.543 -		if (dev < numDevices && dev >= 0)
 565.544 -			pDevices[dev].needed = 1;
 565.545 -		else
 565.546 -			joypad[i][KEY_BUTTON_CAPTURE] = DIK_F12;
 565.547 -
 565.548 -		dev = joypad[i][KEY_BUTTON_GS] >> 8;
 565.549 -		if (dev < numDevices && dev >= 0)
 565.550 -			pDevices[dev].needed = 1;
 565.551 -		else
 565.552 -			joypad[i][KEY_BUTTON_GS] = DIK_C;
 565.553 -	}
 565.554 -
 565.555 -	dev = motion[KEY_UP] >> 8;
 565.556 -	if (dev < numDevices && dev >= 0)
 565.557 -		pDevices[dev].needed = 1;
 565.558 -	else
 565.559 -		motion[KEY_UP] = DIK_NUMPAD8;
 565.560 -
 565.561 -	dev = motion[KEY_DOWN] >> 8;
 565.562 -	if (dev < numDevices && dev >= 0)
 565.563 -		pDevices[dev].needed = 1;
 565.564 -	else
 565.565 -		motion[KEY_DOWN] = DIK_NUMPAD2;
 565.566 -
 565.567 -	dev = motion[KEY_LEFT] >> 8;
 565.568 -	if (dev < numDevices && dev >= 0)
 565.569 -		pDevices[dev].needed = 1;
 565.570 -	else
 565.571 -		motion[KEY_LEFT] = DIK_NUMPAD4;
 565.572 -
 565.573 -	dev = motion[KEY_RIGHT] >> 8;
 565.574 -	if (dev < numDevices && dev >= 0)
 565.575 -		pDevices[dev].needed = 1;
 565.576 -	else
 565.577 -		motion[KEY_RIGHT] = DIK_NUMPAD6;
 565.578 -}
 565.579 -
 565.580 -#define KEYDOWN(buffer, key) (buffer[key] & 0x80)
 565.581 -
 565.582 -static bool IsKeyDownAsync (WORD KeyIdent)
 565.583 -{
 565.584 -	//if (KeyIdent == 0 || KeyIdent == VK_ESCAPE) // if it's the 'disabled' key, it's never pressed
 565.585 -	//	return false;
 565.586 -
 565.587 -	//if (!GUI.BackgroundInput && GUI.hWnd != GetForegroundWindow())
 565.588 -	//	return false;
 565.589 -
 565.590 -	// the pause key is special, need this to catch all presses of it
 565.591 -	// Both GetKeyState and GetAsyncKeyState cannot catch it anyway,
 565.592 -	// so this should be handled in WM_KEYDOWN message.
 565.593 -	if (KeyIdent == VK_PAUSE)
 565.594 -	{
 565.595 -		return false;
 565.596 -//		if(GetAsyncKeyState(VK_PAUSE)) // not &'ing this with 0x8000 is intentional and necessary
 565.597 -//			return true;
 565.598 -	}
 565.599 -
 565.600 -	if (KeyIdent == VK_CAPITAL || KeyIdent == VK_NUMLOCK || KeyIdent == VK_SCROLL)
 565.601 -		return ((GetKeyState(KeyIdent) & 0x01) != 0);
 565.602 -	else
 565.603 -		return ((GetAsyncKeyState(KeyIdent) & 0x8000) != 0);
 565.604 -	//return ((GetKeyState (KeyIdent) & 0x80) != 0);
 565.605 -}
 565.606 -
 565.607 -static bool readKeyboard()
 565.608 -{
 565.609 -#ifndef USE_GETASYNCKEYSTATE_FOR_KEYBOARD
 565.610 -	if (pDevices[0].needed)
 565.611 -	{
 565.612 -		HRESULT hret = pDevices[0].device->
 565.613 -		               GetDeviceState(256,
 565.614 -		                              (LPVOID)pDevices[0].data);
 565.615 -
 565.616 -		if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED)
 565.617 -		{
 565.618 -			hret = pDevices[0].device->Acquire();
 565.619 -			if (hret != DI_OK)
 565.620 -				return false;
 565.621 -			hret = pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
 565.622 -		}
 565.623 -
 565.624 -		return hret == DI_OK;
 565.625 -	}
 565.626 -#else
 565.627 -	for (int i = 0; i < sizeof(win_key_trans_table)/sizeof(win_key_trans_table[0]); i++) {
 565.628 -		pDevices[0].data[win_key_trans_table[i].dik] = IsKeyDownAsync(win_key_trans_table[i].vk) ? 0x80 : 0;
 565.629 -	}
 565.630 -#endif
 565.631 -	return true;
 565.632 -}
 565.633 -
 565.634 -static bool readJoystick(int joy)
 565.635 -{
 565.636 -	if (pDevices[joy].needed)
 565.637 -	{
 565.638 -		if (pDevices[joy].isPolled)
 565.639 -			((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
 565.640 -
 565.641 -		HRESULT hret = pDevices[joy].device->
 565.642 -		               GetDeviceState(sizeof(DIJOYSTATE),
 565.643 -		                              (LPVOID)&pDevices[joy].state);
 565.644 -
 565.645 -		if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED)
 565.646 -		{
 565.647 -			hret = pDevices[joy].device->Acquire();
 565.648 -
 565.649 -			if (hret == DI_OK)
 565.650 -			{
 565.651 -				if (pDevices[joy].isPolled)
 565.652 -					((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
 565.653 -
 565.654 -				hret = pDevices[joy].device->
 565.655 -				       GetDeviceState(sizeof(DIJOYSTATE),
 565.656 -				                      (LPVOID)&pDevices[joy].state);
 565.657 -			}
 565.658 -		}
 565.659 -
 565.660 -		return hret == DI_OK;
 565.661 -	}
 565.662 -
 565.663 -	return true;
 565.664 -}
 565.665 -
 565.666 -static void checkKeyboard()
 565.667 -{
 565.668 -	// mham fix. Patch #1378104
 565.669 -	UCHAR   keystate[256];
 565.670 -	HRESULT hret = pDevices[0].device->Acquire();
 565.671 -
 565.672 -	if (pDevices[0].first)
 565.673 -	{
 565.674 -		pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
 565.675 -		pDevices[0].first = FALSE;
 565.676 -		return;
 565.677 -	}
 565.678 -
 565.679 -	hret = pDevices[0].device->
 565.680 -	       GetDeviceState(256, (LPVOID)keystate);
 565.681 -
 565.682 -	if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED)
 565.683 -	{
 565.684 -		return;
 565.685 -	}
 565.686 -
 565.687 -	if (hret == DI_OK)
 565.688 -	{
 565.689 -		for (int i = 0; i < 256; i++)
 565.690 -		{
 565.691 -			if (keystate[i] == pDevices[0].data[i])
 565.692 -				continue;
 565.693 -			if (KEYDOWN(keystate, i))
 565.694 -			{
 565.695 -				SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i);
 565.696 -				break;
 565.697 -			}
 565.698 -		}
 565.699 -	}
 565.700 -	memcpy(pDevices[0].data, keystate, sizeof(UCHAR) * 256);
 565.701 -}
 565.702 -
 565.703 -static void checkJoypads()
 565.704 -{
 565.705 -	DIDEVICEOBJECTINSTANCE di;
 565.706 -
 565.707 -	ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
 565.708 -
 565.709 -	di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
 565.710 -
 565.711 -	int i = 0;
 565.712 -
 565.713 -	DIJOYSTATE joystick;
 565.714 -
 565.715 -	for (i = 1; i < numDevices; i++)
 565.716 -	{
 565.717 -		HRESULT hret = pDevices[i].device->Acquire();
 565.718 -
 565.719 -		if (pDevices[i].isPolled)
 565.720 -			((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
 565.721 -
 565.722 -		hret = pDevices[i].device->GetDeviceState(sizeof(joystick), &joystick);
 565.723 -
 565.724 -		int j;
 565.725 -
 565.726 -		if (pDevices[i].first)
 565.727 -		{
 565.728 -			memcpy(&pDevices[i].state, &joystick, sizeof(joystick));
 565.729 -			pDevices[i].first = FALSE;
 565.730 -			continue;
 565.731 -		}
 565.732 -
 565.733 -		for (j = 0; j < pDevices[i].nButtons; j++)
 565.734 -		{
 565.735 -			if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
 565.736 -			     & joystick.rgbButtons[j]) & 0x80)
 565.737 -			{
 565.738 -				HWND focus = GetFocus();
 565.739 -
 565.740 -				SendMessage(focus, JOYCONFIG_MESSAGE, i, j+128);
 565.741 -			}
 565.742 -		}
 565.743 -
 565.744 -		for (j = 0; j < pDevices[i].nAxes && j < 8; j++)
 565.745 -		{
 565.746 -			LONG value = pDevices[i].axis[j].center;
 565.747 -			LONG old   = 0;
 565.748 -			switch (pDevices[i].axis[j].offset)
 565.749 -			{
 565.750 -			case DIJOFS_X:
 565.751 -				value = joystick.lX;
 565.752 -				old   = pDevices[i].state.lX;
 565.753 -				break;
 565.754 -			case DIJOFS_Y:
 565.755 -				value = joystick.lY;
 565.756 -				old   = pDevices[i].state.lY;
 565.757 -				break;
 565.758 -			case DIJOFS_Z:
 565.759 -				value = joystick.lZ;
 565.760 -				old   = pDevices[i].state.lZ;
 565.761 -				break;
 565.762 -			case DIJOFS_RX:
 565.763 -				value = joystick.lRx;
 565.764 -				old   = pDevices[i].state.lRx;
 565.765 -				break;
 565.766 -			case DIJOFS_RY:
 565.767 -				value = joystick.lRy;
 565.768 -				old   = pDevices[i].state.lRy;
 565.769 -				break;
 565.770 -			case DIJOFS_RZ:
 565.771 -				value = joystick.lRz;
 565.772 -				old   = pDevices[i].state.lRz;
 565.773 -				break;
 565.774 -			case DIJOFS_SLIDER(0):
 565.775 -				value = joystick.rglSlider[0];
 565.776 -				old   = pDevices[i].state.rglSlider[0];
 565.777 -				break;
 565.778 -			case DIJOFS_SLIDER(1):
 565.779 -				value = joystick.rglSlider[1];
 565.780 -				old   = pDevices[i].state.rglSlider[1];
 565.781 -				break;
 565.782 -			}
 565.783 -			if (value != old)
 565.784 -			{
 565.785 -				if (value < pDevices[i].axis[j].negative)
 565.786 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1));
 565.787 -				else if (value > pDevices[i].axis[j].positive)
 565.788 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1)+1);
 565.789 -			}
 565.790 -		}
 565.791 -
 565.792 -		for (j = 0; j < 4 && j < pDevices[i].nPovs; j++)
 565.793 -		{
 565.794 -			if (LOWORD(pDevices[i].state.rgdwPOV[j]) != LOWORD(joystick.rgdwPOV[j]))
 565.795 -			{
 565.796 -				int state = getPovState(joystick.rgdwPOV[j]);
 565.797 -
 565.798 -				if (state & POV_UP)
 565.799 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x20);
 565.800 -				else if (state & POV_DOWN)
 565.801 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x21);
 565.802 -				else if (state & POV_RIGHT)
 565.803 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x22);
 565.804 -				else if (state & POV_LEFT)
 565.805 -					SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x23);
 565.806 -			}
 565.807 -		}
 565.808 -
 565.809 -		memcpy(&pDevices[i].state, &joystick, sizeof(joystick));
 565.810 -	}
 565.811 -}
 565.812 -
 565.813 -BOOL checkKey(LONG_PTR key)
 565.814 -{
 565.815 -	LONG_PTR dev = (key >> 8);
 565.816 -
 565.817 -	LONG_PTR k = (key & 255);
 565.818 -
 565.819 -	if (dev == 0)
 565.820 -	{
 565.821 -		return KEYDOWN(pDevices[0].data, k);
 565.822 -	}
 565.823 -	else if (dev >= numDevices)
 565.824 -	{
 565.825 -		return FALSE;
 565.826 -	}
 565.827 -	else
 565.828 -	{
 565.829 -		if (k < 16)
 565.830 -		{
 565.831 -			LONG_PTR axis  = k >> 1;
 565.832 -			LONG     value = pDevices[dev].axis[axis].center;
 565.833 -			switch (pDevices[dev].axis[axis].offset)
 565.834 -			{
 565.835 -			case DIJOFS_X:
 565.836 -				value = pDevices[dev].state.lX;
 565.837 -				break;
 565.838 -			case DIJOFS_Y:
 565.839 -				value = pDevices[dev].state.lY;
 565.840 -				break;
 565.841 -			case DIJOFS_Z:
 565.842 -				value = pDevices[dev].state.lZ;
 565.843 -				break;
 565.844 -			case DIJOFS_RX:
 565.845 -				value = pDevices[dev].state.lRx;
 565.846 -				break;
 565.847 -			case DIJOFS_RY:
 565.848 -				value = pDevices[dev].state.lRy;
 565.849 -				break;
 565.850 -			case DIJOFS_RZ:
 565.851 -				value = pDevices[dev].state.lRz;
 565.852 -				break;
 565.853 -			case DIJOFS_SLIDER(0):
 565.854 -				value = pDevices[dev].state.rglSlider[0];
 565.855 -				break;
 565.856 -			case DIJOFS_SLIDER(1):
 565.857 -				value = pDevices[dev].state.rglSlider[1];
 565.858 -				break;
 565.859 -			}
 565.860 -
 565.861 -			if (k & 1)
 565.862 -				return value > pDevices[dev].axis[axis].positive;
 565.863 -			return value < pDevices[dev].axis[axis].negative;
 565.864 -		}
 565.865 -		else if (k < 48)
 565.866 -		{
 565.867 -			LONG_PTR hat   = (k >> 2) & 3;
 565.868 -			int      state = getPovState(pDevices[dev].state.rgdwPOV[hat]);
 565.869 -			BOOL     res   = FALSE;
 565.870 -			switch (k & 3)
 565.871 -			{
 565.872 -			case 0:
 565.873 -				res = state & POV_UP;
 565.874 -				break;
 565.875 -			case 1:
 565.876 -				res = state & POV_DOWN;
 565.877 -				break;
 565.878 -			case 2:
 565.879 -				res = state & POV_RIGHT;
 565.880 -				break;
 565.881 -			case 3:
 565.882 -				res = state & POV_LEFT;
 565.883 -				break;
 565.884 -			}
 565.885 -			return res;
 565.886 -		}
 565.887 -		else if (k  >= 128)
 565.888 -		{
 565.889 -			return pDevices[dev].state.rgbButtons[k-128] & 0x80;
 565.890 -		}
 565.891 -	}
 565.892 -
 565.893 -	return FALSE;
 565.894 -}
 565.895 -
 565.896 -DirectInput::DirectInput()
 565.897 -{
 565.898 -	dinputDLL = NULL;
 565.899 -}
 565.900 -
 565.901 -DirectInput::~DirectInput()
 565.902 -{
 565.903 -	saveSettings();
 565.904 -	if (pDirectInput != NULL)
 565.905 -	{
 565.906 -		if (pDevices)
 565.907 -		{
 565.908 -			for (int i = 0; i < numDevices; i++)
 565.909 -			{
 565.910 -				if (pDevices[i].device)
 565.911 -				{
 565.912 -					pDevices[i].device->Unacquire();
 565.913 -					pDevices[i].device->Release();
 565.914 -					pDevices[i].device = NULL;
 565.915 -				}
 565.916 -			}
 565.917 -			free(pDevices);
 565.918 -			pDevices = NULL;
 565.919 -		}
 565.920 -
 565.921 -		pDirectInput->Release();
 565.922 -		pDirectInput = NULL;
 565.923 -	}
 565.924 -
 565.925 -	if (dinputDLL)
 565.926 -	{
 565.927 -		/**/ ::FreeLibrary(dinputDLL);
 565.928 -		dinputDLL = NULL;
 565.929 -	}
 565.930 -}
 565.931 -
 565.932 -bool DirectInput::initialize()
 565.933 -{
 565.934 -	joyDebug = GetPrivateProfileInt("config",
 565.935 -	                                "joyDebug",
 565.936 -	                                0,
 565.937 -	                                "VBA.ini");
 565.938 -	dinputDLL = /**/ ::LoadLibrary("DINPUT.DLL");
 565.939 -	HRESULT (WINAPI *DInputCreate)(HINSTANCE, DWORD, LPDIRECTINPUT *, IUnknown *);
 565.940 -	if (dinputDLL != NULL)
 565.941 -	{
 565.942 -		DInputCreate = (HRESULT (WINAPI *)(HINSTANCE, DWORD, LPDIRECTINPUT *, IUnknown *))
 565.943 -		               GetProcAddress(dinputDLL, "DirectInputCreateA");
 565.944 -
 565.945 -		if (DInputCreate == NULL)
 565.946 -		{
 565.947 -			directXMessage("DirectInputCreateA");
 565.948 -			return false;
 565.949 -		}
 565.950 -	}
 565.951 -	else
 565.952 -	{
 565.953 -		directXMessage("DINPUT.DLL");
 565.954 -		return false;
 565.955 -	}
 565.956 -
 565.957 -	HRESULT hret = DInputCreate(AfxGetInstanceHandle(),
 565.958 -	                            DIRECTINPUT_VERSION,
 565.959 -	                            &pDirectInput,
 565.960 -	                            NULL);
 565.961 -	if (hret != DI_OK)
 565.962 -	{
 565.963 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_CREATE), hret);
 565.964 -		return false;
 565.965 -	}
 565.966 -
 565.967 -	hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK,
 565.968 -	                                 DIEnumDevicesCallback2,
 565.969 -	                                 NULL,
 565.970 -	                                 DIEDFL_ATTACHEDONLY);
 565.971 -
 565.972 -	pDevices = (deviceInfo *)calloc(numDevices, sizeof(deviceInfo));
 565.973 -
 565.974 -	hret = pDirectInput->CreateDevice(GUID_SysKeyboard, &pDevices[0].device, NULL);
 565.975 -	pDevices[0].isPolled = false;
 565.976 -	pDevices[0].needed   = true;
 565.977 -	pDevices[0].first    = true;
 565.978 -
 565.979 -	if (hret != DI_OK)
 565.980 -	{
 565.981 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_CREATEDEVICE), hret);
 565.982 -		return false;
 565.983 -	}
 565.984 -
 565.985 -	numDevices = 1;
 565.986 -
 565.987 -	hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK,
 565.988 -	                                 DIEnumDevicesCallback,
 565.989 -	                                 NULL,
 565.990 -	                                 DIEDFL_ATTACHEDONLY);
 565.991 -
 565.992 -	//  hret = pDevices[0].device->SetCooperativeLevel(hWindow,
 565.993 -	//                                             DISCL_FOREGROUND|
 565.994 -	//                                             DISCL_NONEXCLUSIVE);
 565.995 -
 565.996 -	if (hret != DI_OK)
 565.997 -	{
 565.998 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_LEVEL), hret);
 565.999 -		return false;
565.1000 -	}
565.1001 -
565.1002 -	hret = pDevices[0].device->SetDataFormat(&c_dfDIKeyboard);
565.1003 -
565.1004 -	if (hret != DI_OK)
565.1005 -	{
565.1006 -		//    errorMessage(myLoadString(IDS_ERROR_DISP_DATAFORMAT), hret);
565.1007 -		return false;
565.1008 -	}
565.1009 -
565.1010 -	for (int i = 1; i < numDevices; i++)
565.1011 -	{
565.1012 -		pDevices[i].device->SetDataFormat(&c_dfDIJoystick);
565.1013 -		pDevices[i].needed = false;
565.1014 -		pDevices[i].first  = true;
565.1015 -		currentDevice      = &pDevices[i];
565.1016 -		axisNumber         = 0;
565.1017 -		currentDevice->device->EnumObjects(EnumAxesCallback, NULL, DIDFT_AXIS);
565.1018 -		currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
565.1019 -		if (joyDebug)
565.1020 -		{
565.1021 -			// don't translate. debug only
565.1022 -			winlog("Joystick %2d polled  : %d\n",    i, currentDevice->isPolled);
565.1023 -			winlog("Joystick %2d buttons : %d\n",    i, currentDevice->nButtons);
565.1024 -			winlog("Joystick %2d povs    : %d\n",    i, currentDevice->nPovs);
565.1025 -			winlog("Joystick %2d axes    : %d\n",    i, currentDevice->nAxes);
565.1026 -			for (int j = 0; j < currentDevice->nAxes; j++)
565.1027 -			{
565.1028 -				winlog("Axis %2d offset      : %08lx\n", j, currentDevice->axis[j].
565.1029 -				       offset);
565.1030 -				winlog("Axis %2d center      : %08lx\n", j, currentDevice->axis[j].
565.1031 -				       center);
565.1032 -				winlog("Axis %2d negative    : %08lx\n",   j, currentDevice->axis[j].
565.1033 -				       negative);
565.1034 -				winlog("Axis %2d positive    : %08lx\n",   j, currentDevice->axis[j].
565.1035 -				       positive);
565.1036 -			}
565.1037 -		}
565.1038 -
565.1039 -		currentDevice = NULL;
565.1040 -	}
565.1041 -
565.1042 -	for (int i = 0; i < numDevices; i++)
565.1043 -		pDevices[i].device->Acquire();
565.1044 -
565.1045 -	return true;
565.1046 -}
565.1047 -
565.1048 -bool DirectInput::readDevices()
565.1049 -{
565.1050 -	bool ok = true;
565.1051 -	for (int i = 0; i < numDevices; i++)
565.1052 -	{
565.1053 -		if (pDevices[i].needed)
565.1054 -		{
565.1055 -			ok = (i > 0 ? readJoystick(i) : readKeyboard()) || ok;
565.1056 -		}
565.1057 -	}
565.1058 -	return ok;
565.1059 -}
565.1060 -
565.1061 -bool inputActive = true; // used to disable all input when the window is inactive
565.1062 -
565.1063 -u32 DirectInput::readDevice(int i, bool sensor)
565.1064 -{
565.1065 -	// this old hack is evil
565.1066 -	extern int  systemGetDefaultJoypad();
565.1067 -	extern int32 gbSgbMode, gbSgbMultiplayer;
565.1068 -	if (!(gbSgbMode && gbSgbMultiplayer))
565.1069 -		i = systemGetDefaultJoypad();
565.1070 -
565.1071 -	u32 res = 0;
565.1072 -
565.1073 -	// manual input
565.1074 -	if (inputActive)
565.1075 -	{
565.1076 -		if (checkKey(joypad[i][KEY_BUTTON_A]))
565.1077 -			res |= BUTTON_MASK_A;
565.1078 -		if (checkKey(joypad[i][KEY_BUTTON_B]))
565.1079 -			res |= BUTTON_MASK_B;
565.1080 -		if (checkKey(joypad[i][KEY_BUTTON_SELECT]))
565.1081 -			res |= BUTTON_MASK_SELECT;
565.1082 -		if (checkKey(joypad[i][KEY_BUTTON_START]))
565.1083 -			res |= BUTTON_MASK_START;
565.1084 -		if (checkKey(joypad[i][KEY_RIGHT]))
565.1085 -			res |= BUTTON_MASK_RIGHT;
565.1086 -		if (checkKey(joypad[i][KEY_LEFT]))
565.1087 -			res |= BUTTON_MASK_LEFT;
565.1088 -		if (checkKey(joypad[i][KEY_UP]))
565.1089 -			res |= BUTTON_MASK_UP;
565.1090 -		if (checkKey(joypad[i][KEY_DOWN]))
565.1091 -			res |= BUTTON_MASK_DOWN;
565.1092 -		if (checkKey(joypad[i][KEY_BUTTON_R]))
565.1093 -			res |= BUTTON_MASK_R;
565.1094 -		if (checkKey(joypad[i][KEY_BUTTON_L]))
565.1095 -			res |= BUTTON_MASK_L;
565.1096 -
565.1097 -		// unused
565.1098 -		if (checkKey(motion[KEY_LEFT]))
565.1099 -			res |= BUTTON_MASK_LEFT_MOTION;
565.1100 -		else if (checkKey(motion[KEY_RIGHT]))
565.1101 -			res |= BUTTON_MASK_RIGHT_MOTION;
565.1102 -		if (checkKey(motion[KEY_UP]))
565.1103 -			res |= BUTTON_MASK_UP_MOTION;
565.1104 -		else if (checkKey(motion[KEY_DOWN]))
565.1105 -			res |= BUTTON_MASK_DOWN_MOTION;
565.1106 -	}
565.1107 -
565.1108 -	u32 hackedButtons = 0;
565.1109 -	if (inputActive)
565.1110 -	{
565.1111 -		// the "non-button" buttons (what a hack!)
565.1112 -		if (checkKey(joypad[i][KEY_BUTTON_SPEED]))
565.1113 -			hackedButtons |= BUTTON_MASK_SPEED;
565.1114 -		if (checkKey(joypad[i][KEY_BUTTON_CAPTURE]))
565.1115 -			hackedButtons |= BUTTON_MASK_CAPTURE;
565.1116 -		if (checkKey(joypad[i][KEY_BUTTON_GS]))
565.1117 -			hackedButtons |= BUTTON_MASK_GAMESHARK;
565.1118 -	}
565.1119 -
565.1120 -	extern bool systemIsSpedUp();
565.1121 -	if (systemIsSpedUp())
565.1122 -		hackedButtons |= BUTTON_MASK_SPEED;
565.1123 -
565.1124 -	return res | hackedButtons;
565.1125 -}
565.1126 -
565.1127 -CString DirectInput::getKeyName(LONG_PTR key)
565.1128 -{
565.1129 -	LONG_PTR d = (key >> 8);
565.1130 -	LONG_PTR k = key & 255;
565.1131 -
565.1132 -	DIDEVICEOBJECTINSTANCE di;
565.1133 -
565.1134 -	ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
565.1135 -
565.1136 -	di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
565.1137 -
565.1138 -	CString winBuffer = winResLoadString(IDS_ERROR);
565.1139 -
565.1140 -	if (d == 0)
565.1141 -	{
565.1142 -		pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET);
565.1143 -		winBuffer = di.tszName;
565.1144 -	}
565.1145 -	else if (d < numDevices)
565.1146 -	{
565.1147 -		if (k < 16)
565.1148 -		{
565.1149 -			if (k < 4)
565.1150 -			{
565.1151 -				switch (k)
565.1152 -				{
565.1153 -				case 0:
565.1154 -					winBuffer.Format(winResLoadString(IDS_JOY_LEFT), d);
565.1155 -					break;
565.1156 -				case 1:
565.1157 -					winBuffer.Format(winResLoadString(IDS_JOY_RIGHT), d);
565.1158 -					break;
565.1159 -				case 2:
565.1160 -					winBuffer.Format(winResLoadString(IDS_JOY_UP), d);
565.1161 -					break;
565.1162 -				case 3:
565.1163 -					winBuffer.Format(winResLoadString(IDS_JOY_DOWN), d);
565.1164 -					break;
565.1165 -				}
565.1166 -			}
565.1167 -			else
565.1168 -			{
565.1169 -				pDevices[d].device->GetObjectInfo(&di,
565.1170 -				                                  pDevices[d].axis[k>>1].offset,
565.1171 -				                                  DIPH_BYOFFSET);
565.1172 -				if (k & 1)
565.1173 -					winBuffer.Format("Joy %d %s +", d, di.tszName);
565.1174 -				else
565.1175 -					winBuffer.Format("Joy %d %s -", d, di.tszName);
565.1176 -			}
565.1177 -		}
565.1178 -		else if (k < 48)
565.1179 -		{
565.1180 -			LONG_PTR hat = (k >> 2) & 3;
565.1181 -			pDevices[d].device->GetObjectInfo(&di,
565.1182 -			                                  (DWORD)DIJOFS_POV(hat),
565.1183 -			                                  DIPH_BYOFFSET);
565.1184 -			char *   dir = "up";
565.1185 -			LONG_PTR dd  = k & 3;
565.1186 -			if (dd == 1)
565.1187 -				dir = "down";
565.1188 -			else if (dd == 2)
565.1189 -				dir = "right";
565.1190 -			else if (dd == 3)
565.1191 -				dir = "left";
565.1192 -			winBuffer.Format("Joy %d %s %s", d, di.tszName, dir);
565.1193 -		}
565.1194 -		else
565.1195 -		{
565.1196 -			pDevices[d].device->GetObjectInfo(&di,
565.1197 -			                                  (DWORD)DIJOFS_BUTTON(k-128),
565.1198 -			                                  DIPH_BYOFFSET);
565.1199 -			winBuffer.Format(winResLoadString(IDS_JOY_BUTTON), d, di.tszName);
565.1200 -		}
565.1201 -	}
565.1202 -	else
565.1203 -	{
565.1204 -		// Joystick isn't plugged in.  We can't decipher k, so just show its value.
565.1205 -		winBuffer.Format("Joy %d (%d)", d, k);
565.1206 -	}
565.1207 -
565.1208 -	return winBuffer;
565.1209 -}
565.1210 -
565.1211 -void DirectInput::checkKeys()
565.1212 -{
565.1213 -	::checkKeys();
565.1214 -}
565.1215 -
565.1216 -Input *newDirectInput()
565.1217 -{
565.1218 -	return new DirectInput;
565.1219 -}
565.1220 -
565.1221 -void DirectInput::checkDevices()
565.1222 -{
565.1223 -	checkJoypads();
565.1224 -	checkKeyboard();
565.1225 -}
565.1226 -
565.1227 -void DirectInput::activate()
565.1228 -{
565.1229 -	for (int i = 0; i < numDevices; i++)
565.1230 -	{
565.1231 -		if (pDevices != NULL && pDevices[i].device != NULL)
565.1232 -			pDevices[i].device->Acquire();
565.1233 -	}
565.1234 -}
565.1235 -
565.1236 -void DirectInput::loadSettings()
565.1237 -{
565.1238 -	winReadKeys();
565.1239 -}
565.1240 -
565.1241 -void DirectInput::saveSettings()
565.1242 -{
565.1243 -	winSaveKeys();
565.1244 -}
565.1245 -
   566.1 --- a/src/win32/DirectSound.cpp	Sat Mar 03 10:54:39 2012 -0600
   566.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   566.3 @@ -1,534 +0,0 @@
   566.4 -#include "stdafx.h"
   566.5 -#include <mmreg.h>
   566.6 -#include <dsound.h>
   566.7 -
   566.8 -#include "resource.h"
   566.9 -#include "AVIWrite.h"
  566.10 -#include "Sound.h"
  566.11 -#include "WavWriter.h"
  566.12 -#include "VBA.h"
  566.13 -
  566.14 -#include "../gba/GBAGlobals.h"
  566.15 -#include "../gba/GBASound.h"
  566.16 -#include "../common/nesvideos-piece.h"
  566.17 -
  566.18 -extern void directXMessage(const char *);
  566.19 -
  566.20 -class DirectSound : public ISound
  566.21 -{
  566.22 -private:
  566.23 -	HINSTANCE			dsoundDLL;
  566.24 -	LPDIRECTSOUND		pDirectSound;
  566.25 -	LPDIRECTSOUNDBUFFER dsbPrimary;
  566.26 -	LPDIRECTSOUNDBUFFER dsbSecondary;
  566.27 -	LPDIRECTSOUNDNOTIFY dsbNotify;
  566.28 -	HANDLE		 dsbEvent;
  566.29 -	WAVEFORMATEX wfx;
  566.30 -	float		 curRate;
  566.31 -public:
  566.32 -	DirectSound();
  566.33 -	virtual ~DirectSound();
  566.34 -
  566.35 -	bool init();
  566.36 -	void pause();
  566.37 -	void reset();
  566.38 -	void resume();
  566.39 -	void write();
  566.40 -	void setSpeed(float rate);
  566.41 -	bool isPlaying();
  566.42 -	void clearAudioBuffer();
  566.43 -};
  566.44 -
  566.45 -DirectSound::DirectSound()
  566.46 -{
  566.47 -	dsoundDLL	 = NULL;
  566.48 -	pDirectSound = NULL;
  566.49 -	dsbPrimary	 = NULL;
  566.50 -	dsbSecondary = NULL;
  566.51 -	dsbNotify	 = NULL;
  566.52 -	dsbEvent	 = NULL;
  566.53 -}
  566.54 -
  566.55 -DirectSound::~DirectSound()
  566.56 -{
  566.57 -	if (theApp.aviRecorder != NULL)
  566.58 -	{
  566.59 -		delete theApp.aviRecorder;
  566.60 -		theApp.aviRecorder	= NULL;
  566.61 -		theApp.aviRecording = false;
  566.62 -	}
  566.63 -
  566.64 -	if (theApp.soundRecording)
  566.65 -	{
  566.66 -		if (theApp.soundRecorder != NULL)
  566.67 -		{
  566.68 -			delete theApp.soundRecorder;
  566.69 -			theApp.soundRecorder = NULL;
  566.70 -		}
  566.71 -		theApp.soundRecording = false;
  566.72 -	}
  566.73 -
  566.74 -	if (dsbNotify != NULL)
  566.75 -	{
  566.76 -		dsbNotify->Release();
  566.77 -		dsbNotify = NULL;
  566.78 -	}
  566.79 -
  566.80 -	if (dsbEvent != NULL)
  566.81 -	{
  566.82 -		CloseHandle(dsbEvent);
  566.83 -		dsbEvent = NULL;
  566.84 -	}
  566.85 -
  566.86 -	if (pDirectSound != NULL)
  566.87 -	{
  566.88 -		if (dsbPrimary != NULL)
  566.89 -		{
  566.90 -			dsbPrimary->Release();
  566.91 -			dsbPrimary = NULL;
  566.92 -		}
  566.93 -
  566.94 -		if (dsbSecondary != NULL)
  566.95 -		{
  566.96 -			dsbSecondary->Release();
  566.97 -			dsbSecondary = NULL;
  566.98 -		}
  566.99 -
 566.100 -		pDirectSound->Release();
 566.101 -		pDirectSound = NULL;
 566.102 -	}
 566.103 -
 566.104 -	if (dsoundDLL != NULL)
 566.105 -	{
 566.106 -		FreeLibrary(dsoundDLL);
 566.107 -		dsoundDLL = NULL;
 566.108 -	}
 566.109 -}
 566.110 -
 566.111 -bool DirectSound::init()
 566.112 -{
 566.113 -	HRESULT hr;
 566.114 -
 566.115 -	dsoundDLL = LoadLibrary("DSOUND.DLL");
 566.116 -	HRESULT (WINAPI *DSoundCreate)(LPCGUID, LPDIRECTSOUND *, IUnknown *);
 566.117 -	if (dsoundDLL != NULL)
 566.118 -	{
 566.119 -		DSoundCreate = (HRESULT (WINAPI *)(LPCGUID, LPDIRECTSOUND *, IUnknown *))
 566.120 -		               GetProcAddress(dsoundDLL, "DirectSoundCreate");
 566.121 -
 566.122 -		if (DSoundCreate == NULL)
 566.123 -		{
 566.124 -			directXMessage("DirectSoundCreate");
 566.125 -			return false;
 566.126 -		}
 566.127 -	}
 566.128 -	else
 566.129 -	{
 566.130 -		directXMessage("DSOUND.DLL");
 566.131 -		return false;
 566.132 -	}
 566.133 -
 566.134 -	if (FAILED(hr = DSoundCreate(NULL, &pDirectSound, NULL)))
 566.135 -	{
 566.136 -		//    errorMessage(myLoadString(IDS_ERROR_SOUND_CREATE), hr);
 566.137 -		systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND,
 566.138 -		              "Cannot create DirectSound %08x", hr);
 566.139 -		pDirectSound = NULL;
 566.140 -		dsbSecondary = NULL;
 566.141 -		return false;
 566.142 -	}
 566.143 -
 566.144 -	if (FAILED(hr = pDirectSound->SetCooperativeLevel((HWND)*theApp.m_pMainWnd, DSSCL_EXCLUSIVE)))
 566.145 -	{
 566.146 -		//    errorMessage(myLoadString(IDS_ERROR_SOUND_LEVEL), hr);
 566.147 -		systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL,
 566.148 -		              "Cannot SetCooperativeLevel %08x", hr);
 566.149 -		return false;
 566.150 -	}
 566.151 -
 566.152 -	DSBUFFERDESC dsbdesc;
 566.153 -	ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
 566.154 -	dsbdesc.dwSize	= sizeof(DSBUFFERDESC);
 566.155 -	dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
 566.156 -
 566.157 -	if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL)))
 566.158 -	{
 566.159 -		//    errorMessage(myLoadString(IDS_ERROR_SOUND_BUFFER),hr);
 566.160 -		systemMessage(IDS_CANNOT_CREATESOUNDBUFFER,
 566.161 -		              "Cannot CreateSoundBuffer %08x", hr);
 566.162 -		return false;
 566.163 -	}
 566.164 -
 566.165 -	// Set primary buffer format
 566.166 -
 566.167 -	memset(&wfx, 0, sizeof(WAVEFORMATEX));
 566.168 -	wfx.wFormatTag = WAVE_FORMAT_PCM;
 566.169 -	wfx.nChannels  = 2;
 566.170 -	switch (soundQuality)
 566.171 -	{
 566.172 -	case 2:
 566.173 -		wfx.nSamplesPerSec	= 22050;
 566.174 -		soundBufferLen		= 736 * 2;
 566.175 -		soundBufferTotalLen = 7360 * 2;
 566.176 -		break;
 566.177 -	case 4:
 566.178 -		wfx.nSamplesPerSec	= 11025;
 566.179 -		soundBufferLen		= 368 * 2;
 566.180 -		soundBufferTotalLen = 3680 * 2;
 566.181 -		break;
 566.182 -	default:
 566.183 -		soundQuality		= 1;
 566.184 -		wfx.nSamplesPerSec	= 44100;
 566.185 -		soundBufferLen		= 1470 * 2;
 566.186 -		soundBufferTotalLen = 14700 * 2;
 566.187 -	}
 566.188 -	wfx.wBitsPerSample	= 16;
 566.189 -	wfx.nBlockAlign		= (wfx.wBitsPerSample / 8) * wfx.nChannels;
 566.190 -	wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
 566.191 -
 566.192 -	if (FAILED(hr = dsbPrimary->SetFormat(&wfx)))
 566.193 -	{
 566.194 -		//    errorMessage(myLoadString(IDS_ERROR_SOUND_PRIMARY),hr);
 566.195 -		systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY,
 566.196 -		              "Cannot SetFormat for primary %08x", hr);
 566.197 -		return false;
 566.198 -	}
 566.199 -
 566.200 -	ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
 566.201 -	dsbdesc.dwSize		  = sizeof(DSBUFFERDESC);
 566.202 -	dsbdesc.dwFlags		  = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_CTRLFREQUENCY | DSBCAPS_GLOBALFOCUS;
 566.203 -	dsbdesc.dwBufferBytes = soundBufferTotalLen;
 566.204 -	dsbdesc.lpwfxFormat	  = &wfx;
 566.205 -
 566.206 -	if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL)))
 566.207 -	{
 566.208 -		bool ok = false;
 566.209 -		while (dsbdesc.dwFlags != DSBCAPS_GETCURRENTPOSITION2)
 566.210 -		{
 566.211 -			if (dsbdesc.dwFlags & DSBCAPS_CTRLFREQUENCY)
 566.212 -				dsbdesc.dwFlags ^= DSBCAPS_CTRLFREQUENCY;
 566.213 -			else if (dsbdesc.dwFlags & DSBCAPS_GLOBALFOCUS)
 566.214 -				dsbdesc.dwFlags ^= DSBCAPS_GLOBALFOCUS;
 566.215 -			else if (dsbdesc.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY)
 566.216 -				dsbdesc.dwFlags ^= DSBCAPS_CTRLPOSITIONNOTIFY;
 566.217 -			if (SUCCEEDED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL)))
 566.218 -			{
 566.219 -				ok = true;
 566.220 -				break;
 566.221 -			}
 566.222 -		}
 566.223 -		if (!ok)
 566.224 -		{
 566.225 -			systemMessage(IDS_CANNOT_CREATESOUNDBUFFER_SEC, "Cannot CreateSoundBuffer secondary %08x", hr);
 566.226 -			return false;
 566.227 -		}
 566.228 -
 566.229 -		dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
 566.230 -	}
 566.231 -
 566.232 -	dsbSecondary->SetCurrentPosition(0);
 566.233 -
 566.234 -	if (!theApp.useOldSync)
 566.235 -	{
 566.236 -		hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify,
 566.237 -		                                  (void * *)&dsbNotify);
 566.238 -		if (!FAILED(hr))
 566.239 -		{
 566.240 -			dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
 566.241 -
 566.242 -			DSBPOSITIONNOTIFY notify[10];
 566.243 -
 566.244 -			for (int i = 0; i < 10; i++)
 566.245 -			{
 566.246 -				notify[i].dwOffset	   = i * soundBufferLen;
 566.247 -				notify[i].hEventNotify = dsbEvent;
 566.248 -			}
 566.249 -			if (FAILED(dsbNotify->SetNotificationPositions(10, notify)))
 566.250 -			{
 566.251 -				dsbNotify->Release();
 566.252 -				dsbNotify = NULL;
 566.253 -				CloseHandle(dsbEvent);
 566.254 -				dsbEvent = NULL;
 566.255 -			}
 566.256 -		}
 566.257 -	}
 566.258 -
 566.259 -	hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING);
 566.260 -
 566.261 -	if (FAILED(hr))
 566.262 -	{
 566.263 -		//    errorMessage(myLoadString(IDS_ERROR_SOUND_PLAYPRIM), hr);
 566.264 -		systemMessage(IDS_CANNOT_PLAY_PRIMARY, "Cannot Play primary %08x", hr);
 566.265 -		return false;
 566.266 -	}
 566.267 -
 566.268 -	systemSoundOn = true;
 566.269 -
 566.270 -	return true;
 566.271 -}
 566.272 -
 566.273 -void DirectSound::setSpeed(float rate)
 566.274 -{
 566.275 -	if (dsbSecondary == NULL || wfx.nSamplesPerSec <= 0)
 566.276 -		return;
 566.277 -
 566.278 -	if (rate != curRate)
 566.279 -	{
 566.280 -		curRate = rate;
 566.281 -
 566.282 -		if (rate > 4.0f)
 566.283 -			rate = 4.0f;
 566.284 -		if (rate < 0.06f)
 566.285 -			rate = 0.06f;
 566.286 -
 566.287 -		dsbSecondary->SetFrequency((DWORD)((float)wfx.nSamplesPerSec * rate));
 566.288 -	}
 566.289 -}
 566.290 -
 566.291 -void DirectSound::pause()
 566.292 -{
 566.293 -	if (dsbSecondary != NULL)
 566.294 -	{
 566.295 -		DWORD status = 0;
 566.296 -		dsbSecondary->GetStatus(&status);
 566.297 -
 566.298 -		if (status & DSBSTATUS_PLAYING)
 566.299 -		{
 566.300 -			//systemScreenMessage("sound stopped (pause)!", 3);
 566.301 -			dsbSecondary->Stop();
 566.302 -		}
 566.303 -	}
 566.304 -}
 566.305 -
 566.306 -bool DirectSound::isPlaying()
 566.307 -{
 566.308 -	if (dsbSecondary != NULL)
 566.309 -	{
 566.310 -		DWORD status = 0;
 566.311 -		dsbSecondary->GetStatus(&status);
 566.312 -
 566.313 -		if (status & DSBSTATUS_PLAYING)
 566.314 -		{
 566.315 -			return true;
 566.316 -		}
 566.317 -	}
 566.318 -	return false;
 566.319 -}
 566.320 -
 566.321 -void DirectSound::reset()
 566.322 -{
 566.323 -	if (dsbSecondary)
 566.324 -	{
 566.325 -		//systemScreenMessage("sound stopped (reset)!", 3);
 566.326 -		dsbSecondary->Stop();
 566.327 -		dsbSecondary->SetCurrentPosition(0);
 566.328 -	}
 566.329 -}
 566.330 -
 566.331 -void DirectSound::resume()
 566.332 -{
 566.333 -	if (dsbSecondary != NULL)
 566.334 -	{
 566.335 -		dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
 566.336 -	}
 566.337 -}
 566.338 -
 566.339 -long linearFrameCount	   = 0;
 566.340 -long linearSoundByteCount  = 0;
 566.341 -long linearSoundFrameCount = 0;
 566.342 -
 566.343 -void DirectSound::write()
 566.344 -{
 566.345 -	int	   len = soundBufferLen;
 566.346 -	LPVOID lpvPtr1;
 566.347 -	DWORD  dwBytes1;
 566.348 -	LPVOID lpvPtr2;
 566.349 -	DWORD  dwBytes2;
 566.350 -
 566.351 -	do
 566.352 -	{
 566.353 -		linearSoundByteCount += len;
 566.354 -		if (wfx.nAvgBytesPerSec)
 566.355 -			linearSoundFrameCount = 60 * linearSoundByteCount / wfx.nAvgBytesPerSec;
 566.356 -
 566.357 -		if (pDirectSound != NULL)
 566.358 -		{
 566.359 -			if (theApp.soundRecording)
 566.360 -			{
 566.361 -				if (dsbSecondary)
 566.362 -				{
 566.363 -					if (theApp.soundRecorder == NULL)
 566.364 -					{
 566.365 -						theApp.soundRecorder = new WavWriter;
 566.366 -						WAVEFORMATEX format;
 566.367 -						dsbSecondary->GetFormat(&format, sizeof(format), NULL);
 566.368 -						if (theApp.soundRecorder->Open(theApp.soundRecordName))
 566.369 -							theApp.soundRecorder->SetFormat(&format);
 566.370 -					}
 566.371 -				}
 566.372 -
 566.373 -				if (theApp.soundRecorder)
 566.374 -				{
 566.375 -					theApp.soundRecorder->AddSound((u8 *)soundFinalWave, len);
 566.376 -				}
 566.377 -			}
 566.378 -
 566.379 -			if (theApp.nvAudioLog)
 566.380 -			{
 566.381 -				NESVideoLoggingAudio((u8 *)soundFinalWave, wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels, len /
 566.382 -				                     (wfx.nChannels * (wfx.wBitsPerSample / 8)));
 566.383 -			}
 566.384 -
 566.385 -			// alternate avi record routine has been added in VBA.cpp
 566.386 -			if (!theApp.altAviRecordMethod && theApp.aviRecording)
 566.387 -			{
 566.388 -				if (theApp.aviRecorder && !theApp.aviRecorder->IsPaused())
 566.389 -				{
 566.390 -					if (dsbSecondary)
 566.391 -					{
 566.392 -						if (!theApp.aviRecorder->IsSoundAdded())
 566.393 -						{
 566.394 -							WAVEFORMATEX format;
 566.395 -							dsbSecondary->GetFormat(&format, sizeof(format), NULL);
 566.396 -							theApp.aviRecorder->SetSoundFormat(&format);
 566.397 -						}
 566.398 -					}
 566.399 -
 566.400 -					theApp.aviRecorder->AddSound((u8 *)soundFinalWave, len);
 566.401 -				}
 566.402 -			}
 566.403 -		}
 566.404 -	}
 566.405 -	while (linearSoundFrameCount <= linearFrameCount);
 566.406 -
 566.407 -	// arbitrarily wrap counters at 10000 frames to avoid mismatching wrap-around freeze
 566.408 -	if (linearSoundFrameCount > 10000 && linearFrameCount > 10000)
 566.409 -	{
 566.410 -		linearFrameCount	 -= 10000;
 566.411 -		linearSoundByteCount -= wfx.nAvgBytesPerSec * 10000 / 60;
 566.412 -		linearSoundFrameCount = 60 * linearSoundByteCount / wfx.nAvgBytesPerSec;
 566.413 -	}
 566.414 -
 566.415 -	if (!pDirectSound)
 566.416 -		return;
 566.417 -
 566.418 -	HRESULT hr;
 566.419 -
 566.420 -	bool fastForward = speedup;
 566.421 -#if (defined(WIN32) && !defined(SDL))
 566.422 -	fastForward |= theApp.frameSearchSkipping;
 566.423 -#endif
 566.424 -
 566.425 -	// slows down emulator to match up with the sound speed
 566.426 -	if (!fastForward && synchronize && !(theApp.throttle > 100 && theApp.accuratePitchThrottle)
 566.427 -		&& theApp.throttle >= 6 && theApp.throttle <= 400)
 566.428 -	{
 566.429 -		DWORD status = 0;
 566.430 -		hr = dsbSecondary->GetStatus(&status);
 566.431 -		if (status & DSBSTATUS_PLAYING)
 566.432 -		{
 566.433 -			if (!soundPaused)
 566.434 -			{
 566.435 -				DWORD play;
 566.436 -				while (true)
 566.437 -				{
 566.438 -					dsbSecondary->GetCurrentPosition(&play, NULL);
 566.439 -
 566.440 -					if (soundNextPosition + soundBufferLen < soundBufferTotalLen)
 566.441 -					{
 566.442 -						if (play < soundNextPosition
 566.443 -						    || play > soundNextPosition + soundBufferLen)
 566.444 -							break;
 566.445 -					}
 566.446 -					else
 566.447 -					{
 566.448 -						if (play < soundNextPosition
 566.449 -						    && play > (soundNextPosition + soundBufferLen) % soundBufferTotalLen)
 566.450 -							break;
 566.451 -					}
 566.452 -
 566.453 -					if (dsbEvent)
 566.454 -					{
 566.455 -						WaitForSingleObject(dsbEvent, 50);
 566.456 -					}
 566.457 -				}
 566.458 -			}
 566.459 -		}
 566.460 -		else
 566.461 -		{
 566.462 -			soundPaused = 1;
 566.463 -		}
 566.464 -	}
 566.465 -
 566.466 -	// Obtain memory address of write block. This will be in two parts
 566.467 -	// if the block wraps around.
 566.468 -	hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen,
 566.469 -	                        &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2,
 566.470 -	                        0);
 566.471 -
 566.472 -	if (FAILED(hr))
 566.473 -	{
 566.474 -		char str [256];
 566.475 -		sprintf(str, "Locking secondary failed with %d", hr);
 566.476 -		systemScreenMessage(str);
 566.477 -	}
 566.478 -
 566.479 -	// If DSERR_BUFFERLOST is returned, restore and retry lock.
 566.480 -	if (DSERR_BUFFERLOST == hr)
 566.481 -	{
 566.482 -		dsbSecondary->Restore();
 566.483 -		hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen,
 566.484 -		                        &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2,
 566.485 -		                        0);
 566.486 -	}
 566.487 -
 566.488 -	if (SUCCEEDED(hr))
 566.489 -	{
 566.490 -		if (theApp.muteFrameAdvance && theApp.winPauseNextFrame || theApp.winMuteForNow)
 566.491 -		{
 566.492 -			// Write 0 to pointers.
 566.493 -			if (NULL != lpvPtr1)
 566.494 -				ZeroMemory(lpvPtr1, dwBytes1);
 566.495 -			if (NULL != lpvPtr2)
 566.496 -				ZeroMemory(lpvPtr2, dwBytes2);
 566.497 -		}
 566.498 -		else
 566.499 -		{
 566.500 -			// Write to pointers.
 566.501 -			if (NULL != lpvPtr1)
 566.502 -				CopyMemory(lpvPtr1, soundFinalWave, dwBytes1);
 566.503 -			if (NULL != lpvPtr2)
 566.504 -				CopyMemory(lpvPtr2, soundFinalWave + dwBytes1, dwBytes2);
 566.505 -		}
 566.506 -
 566.507 -		// Release the data back to DirectSound.
 566.508 -		hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2,
 566.509 -		                          dwBytes2);
 566.510 -	}
 566.511 -
 566.512 -	soundNextPosition += soundBufferLen;
 566.513 -	soundNextPosition %= soundBufferTotalLen;
 566.514 -}
 566.515 -
 566.516 -void DirectSound::clearAudioBuffer()
 566.517 -{
 566.518 -	LPVOID	lpvPtr1;
 566.519 -	DWORD	dwBytes1;
 566.520 -	LPVOID	lpvPtr2;
 566.521 -	DWORD	dwBytes2;
 566.522 -	HRESULT hr = dsbSecondary->Lock(0, soundBufferTotalLen, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);
 566.523 -	if (!FAILED(hr))
 566.524 -	{
 566.525 -		if (lpvPtr1)
 566.526 -			memset(lpvPtr1, 0, dwBytes1);
 566.527 -		if (lpvPtr2)
 566.528 -			memset(lpvPtr2, 0, dwBytes2);
 566.529 -		hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
 566.530 -	}
 566.531 -}
 566.532 -
 566.533 -ISound *newDirectSound()
 566.534 -{
 566.535 -	return new DirectSound();
 566.536 -}
 566.537 -
   567.1 --- a/src/win32/Directories.cpp	Sat Mar 03 10:54:39 2012 -0600
   567.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   567.3 @@ -1,420 +0,0 @@
   567.4 -// Directories.cpp : implementation file
   567.5 -//
   567.6 -
   567.7 -#include "stdafx.h"
   567.8 -#include <shlobj.h>
   567.9 -#include "resource.h"
  567.10 -#include "Directories.h"
  567.11 -#include "Reg.h"
  567.12 -#include "WinMiscUtil.h"
  567.13 -#include "WinResUtil.h"
  567.14 -
  567.15 -/////////////////////////////////////////////////////////////////////////////
  567.16 -// Directories dialog
  567.17 -
  567.18 -static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg,
  567.19 -                                       LPARAM l, LPARAM data)
  567.20 -{
  567.21 -	char *buffer = (char *)data;
  567.22 -	switch (msg)
  567.23 -	{
  567.24 -	case BFFM_INITIALIZED:
  567.25 -		if (buffer[0])
  567.26 -			SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer);
  567.27 -		break;
  567.28 -	default:
  567.29 -		break;
  567.30 -	}
  567.31 -	return 0;
  567.32 -}
  567.33 -
  567.34 -Directories::Directories(CWnd*pParent /*=NULL*/)
  567.35 -	: CDialog(Directories::IDD, pParent)
  567.36 -{
  567.37 -	//{{AFX_DATA_INIT(Directories)
  567.38 -	// NOTE: the ClassWizard will add member initialization here
  567.39 -	//}}AFX_DATA_INIT
  567.40 -}
  567.41 -
  567.42 -void Directories::DoDataExchange(CDataExchange*pDX)
  567.43 -{
  567.44 -	CDialog::DoDataExchange(pDX);
  567.45 -	//{{AFX_DATA_MAP(Directories)
  567.46 -	DDX_Control(pDX, IDC_ROM_PATH, m_romPath);
  567.47 -	DDX_Control(pDX, IDC_GBXROM_PATH, m_gbxromPath);
  567.48 -	DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
  567.49 -	DDX_Control(pDX, IDC_SAVE_PATH, m_savePath);
  567.50 -	DDX_Control(pDX, IDC_MOVIE_PATH, m_moviePath);
  567.51 -	DDX_Control(pDX, IDC_CHEAT_PATH, m_cheatPath);
  567.52 -	DDX_Control(pDX, IDC_IPS_PATH, m_ipsPath);
  567.53 -	DDX_Control(pDX, IDC_LUA_PATH, m_luaPath);
  567.54 -	DDX_Control(pDX, IDC_AVI_PATH, m_aviPath);
  567.55 -	DDX_Control(pDX, IDC_WAV_PATH, m_wavPath);
  567.56 -	DDX_Control(pDX, IDC_CAPTURE_PATH, m_capturePath);
  567.57 -	DDX_Control(pDX, IDC_WATCH_PATH, m_watchPath);
  567.58 -	//}}AFX_DATA_MAP
  567.59 -}
  567.60 -
  567.61 -BEGIN_MESSAGE_MAP(Directories, CDialog)
  567.62 -//{{AFX_MSG_MAP(Directories)
  567.63 -ON_BN_CLICKED(IDC_ROM_DIR, OnRomDir)
  567.64 -ON_BN_CLICKED(IDC_ROM_DIR_RESET, OnRomDirReset)
  567.65 -ON_BN_CLICKED(IDC_GBXROM_DIR, OnGBxRomDir)
  567.66 -ON_BN_CLICKED(IDC_GBXROM_DIR_RESET, OnGBxRomDirReset)
  567.67 -ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
  567.68 -ON_BN_CLICKED(IDC_BATTERY_DIR_RESET, OnBatteryDirReset)
  567.69 -ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir)
  567.70 -ON_BN_CLICKED(IDC_SAVE_DIR_RESET, OnSaveDirReset)
  567.71 -ON_BN_CLICKED(IDC_MOVIE_DIR, OnMovieDir)
  567.72 -ON_BN_CLICKED(IDC_MOVIE_DIR_RESET, OnMovieDirReset)
  567.73 -ON_BN_CLICKED(IDC_CHEAT_DIR, OnCheatDir)
  567.74 -ON_BN_CLICKED(IDC_CHEAT_DIR_RESET, OnCheatDirReset)
  567.75 -ON_BN_CLICKED(IDC_IPS_DIR, OnIpsDir)
  567.76 -ON_BN_CLICKED(IDC_IPS_DIR_RESET, OnIpsDirReset)
  567.77 -ON_BN_CLICKED(IDC_LUA_DIR, OnLuaDir)
  567.78 -ON_BN_CLICKED(IDC_LUA_DIR_RESET, OnLuaDirReset)
  567.79 -ON_BN_CLICKED(IDC_AVI_DIR, OnAviDir)
  567.80 -ON_BN_CLICKED(IDC_AVI_DIR_RESET, OnAviDirReset)
  567.81 -ON_BN_CLICKED(IDC_WAV_DIR, OnWavDir)
  567.82 -ON_BN_CLICKED(IDC_WAV_DIR_RESET, OnWavDirReset)
  567.83 -ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
  567.84 -ON_BN_CLICKED(IDC_CAPTURE_DIR_RESET, OnCaptureDirReset)
  567.85 -ON_BN_CLICKED(IDC_WATCH_DIR, OnWatchDir)
  567.86 -ON_BN_CLICKED(IDC_WATCH_DIR_RESET, OnWatchDirReset)
  567.87 -//}}AFX_MSG_MAP
  567.88 -END_MESSAGE_MAP()
  567.89 -
  567.90 -/////////////////////////////////////////////////////////////////////////////
  567.91 -// Directories message handlers
  567.92 -
  567.93 -BOOL Directories::OnInitDialog()
  567.94 -{
  567.95 -	CDialog::OnInitDialog();
  567.96 -
  567.97 -	CString p = regQueryStringValue(IDS_ROM_DIR, NULL);
  567.98 -	if (!p.IsEmpty())
  567.99 -		GetDlgItem(IDC_ROM_PATH)->SetWindowText(p);
 567.100 -
 567.101 -	p = regQueryStringValue(IDS_GBXROM_DIR, NULL);
 567.102 -	if (!p.IsEmpty())
 567.103 -		GetDlgItem(IDC_GBXROM_PATH)->SetWindowText(p);
 567.104 -
 567.105 -	p = regQueryStringValue(IDS_BATTERY_DIR, NULL);
 567.106 -	if (!p.IsEmpty())
 567.107 -		GetDlgItem(IDC_BATTERY_PATH)->SetWindowText(p);
 567.108 -
 567.109 -	p = regQueryStringValue(IDS_SAVE_DIR, NULL);
 567.110 -	if (!p.IsEmpty())
 567.111 -		GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p);
 567.112 -
 567.113 -	p = regQueryStringValue(IDS_MOVIE_DIR, NULL);
 567.114 -	if (!p.IsEmpty())
 567.115 -		GetDlgItem(IDC_MOVIE_PATH)->SetWindowText(p);
 567.116 -
 567.117 -	p = regQueryStringValue(IDS_CHEAT_DIR, NULL);
 567.118 -	if (!p.IsEmpty())
 567.119 -		GetDlgItem(IDC_CHEAT_PATH)->SetWindowText(p);
 567.120 -
 567.121 -	p = regQueryStringValue(IDS_IPS_DIR, NULL);
 567.122 -	if (!p.IsEmpty())
 567.123 -		GetDlgItem(IDC_IPS_PATH)->SetWindowText(p);
 567.124 -
 567.125 -	p = regQueryStringValue(IDS_LUA_DIR, NULL);
 567.126 -	if (!p.IsEmpty())
 567.127 -		GetDlgItem(IDC_LUA_PATH)->SetWindowText(p);
 567.128 -
 567.129 -	p = regQueryStringValue(IDS_AVI_DIR, NULL);
 567.130 -	if (!p.IsEmpty())
 567.131 -		GetDlgItem(IDC_AVI_PATH)->SetWindowText(p);
 567.132 -
 567.133 -	p = regQueryStringValue(IDS_WAV_DIR, NULL);
 567.134 -	if (!p.IsEmpty())
 567.135 -		GetDlgItem(IDC_WAV_PATH)->SetWindowText(p);
 567.136 -
 567.137 -	p = regQueryStringValue(IDS_CAPTURE_DIR, NULL);
 567.138 -	if (!p.IsEmpty())
 567.139 -		GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p);
 567.140 -
 567.141 -	p = regQueryStringValue(IDS_WATCH_DIR, NULL);
 567.142 -	if (!p.IsEmpty())
 567.143 -		GetDlgItem(IDC_WATCH_PATH)->SetWindowText(p);
 567.144 -
 567.145 -	CenterWindow();
 567.146 -
 567.147 -	return TRUE; // return TRUE unless you set the focus to a control
 567.148 -	             // EXCEPTION: OCX Property Pages should return FALSE
 567.149 -}
 567.150 -
 567.151 -void Directories::OnRomDir()
 567.152 -{
 567.153 -	m_romPath.GetWindowText(initialFolderDir);
 567.154 -	CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
 567.155 -	if (!p.IsEmpty())
 567.156 -		m_romPath.SetWindowText(p);
 567.157 -}
 567.158 -
 567.159 -void Directories::OnRomDirReset()
 567.160 -{
 567.161 -	m_romPath.SetWindowText("");
 567.162 -}
 567.163 -
 567.164 -void Directories::OnGBxRomDir()
 567.165 -{
 567.166 -	m_gbxromPath.GetWindowText(initialFolderDir);
 567.167 -	CString p = browseForDir(winResLoadString(IDS_SELECT_GBXROM_DIR));
 567.168 -	if (!p.IsEmpty())
 567.169 -		m_gbxromPath.SetWindowText(p);
 567.170 -}
 567.171 -
 567.172 -void Directories::OnGBxRomDirReset()
 567.173 -{
 567.174 -	m_gbxromPath.SetWindowText("");
 567.175 -}
 567.176 -
 567.177 -void Directories::OnBatteryDir()
 567.178 -{
 567.179 -	m_batteryPath.GetWindowText(initialFolderDir);
 567.180 -	CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR));
 567.181 -	if (!p.IsEmpty())
 567.182 -		m_batteryPath.SetWindowText(p);
 567.183 -}
 567.184 -
 567.185 -void Directories::OnBatteryDirReset()
 567.186 -{
 567.187 -	m_batteryPath.SetWindowText("");
 567.188 -}
 567.189 -
 567.190 -void Directories::OnSaveDir()
 567.191 -{
 567.192 -	m_savePath.GetWindowText(initialFolderDir);
 567.193 -	CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR));
 567.194 -	if (!p.IsEmpty())
 567.195 -		m_savePath.SetWindowText(p);
 567.196 -}
 567.197 -
 567.198 -void Directories::OnSaveDirReset()
 567.199 -{
 567.200 -	m_savePath.SetWindowText("");
 567.201 -}
 567.202 -
 567.203 -void Directories::OnMovieDir()
 567.204 -{
 567.205 -	m_moviePath.GetWindowText(initialFolderDir);
 567.206 -	CString p = browseForDir(winResLoadString(IDS_SELECT_MOVIE_DIR));
 567.207 -	if (!p.IsEmpty())
 567.208 -		m_moviePath.SetWindowText(p);
 567.209 -}
 567.210 -
 567.211 -void Directories::OnMovieDirReset()
 567.212 -{
 567.213 -	m_moviePath.SetWindowText("");
 567.214 -}
 567.215 -
 567.216 -void Directories::OnCheatDir()
 567.217 -{
 567.218 -	m_cheatPath.GetWindowText(initialFolderDir);
 567.219 -	CString p = browseForDir(winResLoadString(IDS_SELECT_CHEAT_DIR));
 567.220 -	if (!p.IsEmpty())
 567.221 -		m_cheatPath.SetWindowText(p);
 567.222 -}
 567.223 -
 567.224 -void Directories::OnCheatDirReset()
 567.225 -{
 567.226 -	m_cheatPath.SetWindowText("");
 567.227 -}
 567.228 -
 567.229 -void Directories::OnLuaDir()
 567.230 -{
 567.231 -	m_luaPath.GetWindowText(initialFolderDir);
 567.232 -	CString p = browseForDir(winResLoadString(IDS_SELECT_LUA_DIR));
 567.233 -	if (!p.IsEmpty())
 567.234 -		m_luaPath.SetWindowText(p);
 567.235 -}
 567.236 -
 567.237 -void Directories::OnLuaDirReset()
 567.238 -{
 567.239 -	m_luaPath.SetWindowText("");
 567.240 -}
 567.241 -
 567.242 -void Directories::OnAviDir()
 567.243 -{
 567.244 -	m_aviPath.GetWindowText(initialFolderDir);
 567.245 -	CString p = browseForDir(winResLoadString(IDS_SELECT_AVI_DIR));
 567.246 -	if (!p.IsEmpty())
 567.247 -		m_aviPath.SetWindowText(p);
 567.248 -}
 567.249 -
 567.250 -void Directories::OnAviDirReset()
 567.251 -{
 567.252 -	m_aviPath.SetWindowText("");
 567.253 -}
 567.254 -
 567.255 -void Directories::OnWavDir()
 567.256 -{
 567.257 -	m_wavPath.GetWindowText(initialFolderDir);
 567.258 -	CString p = browseForDir(winResLoadString(IDS_SELECT_WAV_DIR));
 567.259 -	if (!p.IsEmpty())
 567.260 -		m_wavPath.SetWindowText(p);
 567.261 -}
 567.262 -
 567.263 -void Directories::OnWavDirReset()
 567.264 -{
 567.265 -	m_wavPath.SetWindowText("");
 567.266 -}
 567.267 -
 567.268 -void Directories::OnCaptureDir()
 567.269 -{
 567.270 -	m_capturePath.GetWindowText(initialFolderDir);
 567.271 -	CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR));
 567.272 -	if (!p.IsEmpty())
 567.273 -		m_capturePath.SetWindowText(p);
 567.274 -}
 567.275 -
 567.276 -void Directories::OnCaptureDirReset()
 567.277 -{
 567.278 -	m_capturePath.SetWindowText("");
 567.279 -}
 567.280 -
 567.281 -void Directories::OnIpsDir()
 567.282 -{
 567.283 -	m_ipsPath.GetWindowText(initialFolderDir);
 567.284 -	CString p = browseForDir(winResLoadString(IDS_SELECT_IPS_DIR));
 567.285 -	if (!p.IsEmpty())
 567.286 -		m_ipsPath.SetWindowText(p);
 567.287 -}
 567.288 -
 567.289 -void Directories::OnIpsDirReset()
 567.290 -{
 567.291 -	m_ipsPath.SetWindowText("");
 567.292 -}
 567.293 -
 567.294 -void Directories::OnWatchDir()
 567.295 -{
 567.296 -	m_watchPath.GetWindowText(initialFolderDir);
 567.297 -	CString p = browseForDir(winResLoadString(IDS_SELECT_WATCH_DIR));
 567.298 -	if(!p.IsEmpty())
 567.299 -		m_watchPath.SetWindowText(p);
 567.300 -}
 567.301 -
 567.302 -void Directories::OnWatchDirReset()
 567.303 -{
 567.304 -	m_watchPath.SetWindowText("");
 567.305 -}
 567.306 -
 567.307 -void Directories::OnCancel()
 567.308 -{
 567.309 -	EndDialog(FALSE);
 567.310 -}
 567.311 -
 567.312 -void Directories::OnOK()
 567.313 -{
 567.314 -	CString buffer;
 567.315 -
 567.316 -	m_romPath.GetWindowText(buffer);
 567.317 -	if (!buffer.IsEmpty())
 567.318 -		regSetStringValue(IDS_ROM_DIR, buffer);
 567.319 -	else
 567.320 -		regDeleteValue(IDS_ROM_DIR);
 567.321 -
 567.322 -	m_gbxromPath.GetWindowText(buffer);
 567.323 -	if (!buffer.IsEmpty())
 567.324 -		regSetStringValue(IDS_GBXROM_DIR, buffer);
 567.325 -	else
 567.326 -		regDeleteValue(IDS_GBXROM_DIR);
 567.327 -
 567.328 -	m_batteryPath.GetWindowText(buffer);
 567.329 -	if (!buffer.IsEmpty())
 567.330 -		regSetStringValue(IDS_BATTERY_DIR, buffer);
 567.331 -	else
 567.332 -		regDeleteValue(IDS_BATTERY_DIR);
 567.333 -
 567.334 -	m_savePath.GetWindowText(buffer);
 567.335 -	if (!buffer.IsEmpty())
 567.336 -		regSetStringValue(IDS_SAVE_DIR, buffer);
 567.337 -	else
 567.338 -		regDeleteValue(IDS_SAVE_DIR);
 567.339 -
 567.340 -	m_moviePath.GetWindowText(buffer);
 567.341 -	if (!buffer.IsEmpty())
 567.342 -		regSetStringValue(IDS_MOVIE_DIR, buffer);
 567.343 -	else
 567.344 -		regDeleteValue(IDS_MOVIE_DIR);
 567.345 -
 567.346 -	m_cheatPath.GetWindowText(buffer);
 567.347 -	if (!buffer.IsEmpty())
 567.348 -		regSetStringValue(IDS_CHEAT_DIR, buffer);
 567.349 -	else
 567.350 -		regDeleteValue(IDS_CHEAT_DIR);
 567.351 -
 567.352 -	m_ipsPath.GetWindowText(buffer);
 567.353 -	if (!buffer.IsEmpty())
 567.354 -		regSetStringValue(IDS_IPS_DIR, buffer);
 567.355 -	else
 567.356 -		regDeleteValue(IDS_IPS_DIR);
 567.357 -
 567.358 -	m_luaPath.GetWindowText(buffer);
 567.359 -	if (!buffer.IsEmpty())
 567.360 -		regSetStringValue(IDS_LUA_DIR, buffer);
 567.361 -	else
 567.362 -		regDeleteValue(IDS_LUA_DIR);
 567.363 -
 567.364 -	m_aviPath.GetWindowText(buffer);
 567.365 -	if (!buffer.IsEmpty())
 567.366 -		regSetStringValue(IDS_AVI_DIR, buffer);
 567.367 -	else
 567.368 -		regDeleteValue(IDS_AVI_DIR);
 567.369 -
 567.370 -	m_wavPath.GetWindowText(buffer);
 567.371 -	if (!buffer.IsEmpty())
 567.372 -		regSetStringValue(IDS_WAV_DIR, buffer);
 567.373 -	else
 567.374 -		regDeleteValue(IDS_WAV_DIR);
 567.375 -
 567.376 -	m_capturePath.GetWindowText(buffer);
 567.377 -	if (!buffer.IsEmpty())
 567.378 -		regSetStringValue(IDS_CAPTURE_DIR, buffer);
 567.379 -	else
 567.380 -		regDeleteValue(IDS_CAPTURE_DIR);
 567.381 -
 567.382 -	m_watchPath.GetWindowText(buffer);
 567.383 -	if (!buffer.IsEmpty())
 567.384 -		regSetStringValue(IDS_WATCH_DIR, buffer);
 567.385 -	else
 567.386 -		regDeleteValue(IDS_WATCH_DIR);
 567.387 -
 567.388 -	EndDialog(TRUE);
 567.389 -}
 567.390 -
 567.391 -CString Directories::browseForDir(CString title)
 567.392 -{
 567.393 -	static char  buffer[1024];
 567.394 -	LPMALLOC     pMalloc;
 567.395 -	LPITEMIDLIST pidl;
 567.396 -
 567.397 -	CString res;
 567.398 -
 567.399 -	if (SUCCEEDED(SHGetMalloc(&pMalloc)))
 567.400 -	{
 567.401 -		BROWSEINFO bi;
 567.402 -		ZeroMemory(&bi, sizeof(bi));
 567.403 -		bi.hwndOwner = m_hWnd;
 567.404 -		bi.lpszTitle = title;
 567.405 -		bi.pidlRoot  = 0;
 567.406 -		bi.ulFlags   = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;	// will fail if COINIT_MULTITHREADED
 567.407 -		bi.lpfn      = browseCallbackProc;
 567.408 -		bi.lParam    = (LPARAM)(LPCTSTR)initialFolderDir;
 567.409 -
 567.410 -		pidl = SHBrowseForFolder(&bi);
 567.411 -
 567.412 -		if (pidl)
 567.413 -		{
 567.414 -			if (SHGetPathFromIDList(pidl, buffer))
 567.415 -			{
 567.416 -				res = buffer;
 567.417 -			}
 567.418 -			pMalloc->Free(pidl);
 567.419 -			pMalloc->Release();
 567.420 -		}
 567.421 -	}
 567.422 -	return res;
 567.423 -}
   568.1 --- a/src/win32/Directories.h	Sat Mar 03 10:54:39 2012 -0600
   568.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   568.3 @@ -1,84 +0,0 @@
   568.4 -#if !defined(AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_)
   568.5 -#define AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_
   568.6 -
   568.7 -#if _MSC_VER > 1000
   568.8 -#pragma once
   568.9 -#endif // _MSC_VER > 1000
  568.10 -// Directories.h : header file
  568.11 -//
  568.12 -
  568.13 -/////////////////////////////////////////////////////////////////////////////
  568.14 -// Directories dialog
  568.15 -
  568.16 -class Directories : public CDialog
  568.17 -{
  568.18 -	// Construction
  568.19 -public:
  568.20 -	CString initialFolderDir;
  568.21 -	CString browseForDir(CString title);
  568.22 -	Directories(CWnd*pParent = NULL);  // standard constructor
  568.23 -
  568.24 -	// Dialog Data
  568.25 -	//{{AFX_DATA(Directories)
  568.26 -	enum { IDD = IDD_DIRECTORIES };
  568.27 -	CEdit m_romPath;
  568.28 -	CEdit m_gbxromPath;
  568.29 -	CEdit m_batteryPath;
  568.30 -	CEdit m_savePath;
  568.31 -	CEdit m_moviePath;
  568.32 -	CEdit m_cheatPath;
  568.33 -	CEdit m_ipsPath;
  568.34 -	CEdit m_luaPath;
  568.35 -	CEdit m_aviPath;
  568.36 -	CEdit m_wavPath;
  568.37 -	CEdit m_capturePath;
  568.38 -	CEdit m_watchPath;
  568.39 -//  CEdit m_pluginPath;
  568.40 -	//}}AFX_DATA
  568.41 -
  568.42 -	// Overrides
  568.43 -	// ClassWizard generated virtual function overrides
  568.44 -	//{{AFX_VIRTUAL(Directories)
  568.45 -protected:
  568.46 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  568.47 -	//}}AFX_VIRTUAL
  568.48 -
  568.49 -	// Implementation
  568.50 -protected:
  568.51 -	// Generated message map functions
  568.52 -	//{{AFX_MSG(Directories)
  568.53 -	virtual BOOL OnInitDialog();
  568.54 -	afx_msg void OnRomDir();
  568.55 -	afx_msg void OnRomDirReset();
  568.56 -	afx_msg void OnGBxRomDir();
  568.57 -	afx_msg void OnGBxRomDirReset();
  568.58 -	afx_msg void OnBatteryDir();
  568.59 -	afx_msg void OnBatteryDirReset();
  568.60 -	afx_msg void OnSaveDir();
  568.61 -	afx_msg void OnSaveDirReset();
  568.62 -	afx_msg void OnMovieDir();
  568.63 -	afx_msg void OnMovieDirReset();
  568.64 -	afx_msg void OnCheatDir();
  568.65 -	afx_msg void OnCheatDirReset();
  568.66 -	afx_msg void OnIpsDir();
  568.67 -	afx_msg void OnIpsDirReset();
  568.68 -	afx_msg void OnLuaDir();
  568.69 -	afx_msg void OnLuaDirReset();
  568.70 -	afx_msg void OnAviDir();
  568.71 -	afx_msg void OnAviDirReset();
  568.72 -	afx_msg void OnWavDir();
  568.73 -	afx_msg void OnWavDirReset();
  568.74 -	afx_msg void OnCaptureDir();
  568.75 -	afx_msg void OnCaptureDirReset();
  568.76 -	afx_msg void OnWatchDir();
  568.77 -	afx_msg void OnWatchDirReset();
  568.78 -	virtual void OnCancel();
  568.79 -	virtual void OnOK();
  568.80 -	//}}AFX_MSG
  568.81 -	DECLARE_MESSAGE_MAP()
  568.82 -};
  568.83 -
  568.84 -//{{AFX_INSERT_LOCATION}}
  568.85 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  568.86 -
  568.87 -#endif // !defined(AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_)
   569.1 --- a/src/win32/Disassemble.cpp	Sat Mar 03 10:54:39 2012 -0600
   569.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   569.3 @@ -1,342 +0,0 @@
   569.4 -// Disassemble.cpp : implementation file
   569.5 -//
   569.6 -
   569.7 -#include "stdafx.h"
   569.8 -#include "resource.h"
   569.9 -#include "Disassemble.h"
  569.10 -#include "VBA.h"
  569.11 -
  569.12 -#include "../gba/armdis.h"
  569.13 -#include "../gba/GBA.h"
  569.14 -#include "../gba/GBAGlobals.h"
  569.15 -
  569.16 -extern void CPUUpdateCPSR();
  569.17 -
  569.18 -/////////////////////////////////////////////////////////////////////////////
  569.19 -// Disassemble dialog
  569.20 -
  569.21 -Disassemble::Disassemble(CWnd*pParent /*=NULL*/)
  569.22 -	: ResizeDlg(Disassemble::IDD, pParent)
  569.23 -{
  569.24 -	//{{AFX_DATA_INIT(Disassemble)
  569.25 -	m_c  = FALSE;
  569.26 -	m_f  = FALSE;
  569.27 -	m_i  = FALSE;
  569.28 -	m_n  = FALSE;
  569.29 -	m_t  = FALSE;
  569.30 -	m_v  = FALSE;
  569.31 -	m_z  = FALSE;
  569.32 -	//}}AFX_DATA_INIT
  569.33 -	autoUpdate = false;
  569.34 -	address    = 0;
  569.35 -	count      = 1;
  569.36 -	mode       = 0;
  569.37 -}
  569.38 -
  569.39 -void Disassemble::DoDataExchange(CDataExchange*pDX)
  569.40 -{
  569.41 -	CDialog::DoDataExchange(pDX);
  569.42 -	//{{AFX_DATA_MAP(Disassemble)
  569.43 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
  569.44 -	DDX_Control(pDX, IDC_DISASSEMBLE, m_list);
  569.45 -	DDX_Check(pDX, IDC_C, m_c);
  569.46 -	DDX_Check(pDX, IDC_F, m_f);
  569.47 -	DDX_Check(pDX, IDC_I, m_i);
  569.48 -	DDX_Check(pDX, IDC_N, m_n);
  569.49 -	DDX_Check(pDX, IDC_T, m_t);
  569.50 -	DDX_Check(pDX, IDC_V, m_v);
  569.51 -	DDX_Check(pDX, IDC_Z, m_z);
  569.52 -	DDX_Radio(pDX, IDC_AUTOMATIC, mode);
  569.53 -	//}}AFX_DATA_MAP
  569.54 -}
  569.55 -
  569.56 -BEGIN_MESSAGE_MAP(Disassemble, CDialog)
  569.57 -//{{AFX_MSG_MAP(Disassemble)
  569.58 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  569.59 -ON_BN_CLICKED(IDC_AUTOMATIC, OnAutomatic)
  569.60 -ON_BN_CLICKED(IDC_ARM, OnArm)
  569.61 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  569.62 -ON_BN_CLICKED(IDC_GO, OnGo)
  569.63 -ON_BN_CLICKED(IDC_GOPC, OnGopc)
  569.64 -ON_BN_CLICKED(IDC_NEXT, OnNext)
  569.65 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  569.66 -ON_BN_CLICKED(IDC_THUMB, OnThumb)
  569.67 -ON_WM_VSCROLL()
  569.68 -//}}AFX_MSG_MAP
  569.69 -END_MESSAGE_MAP()
  569.70 -
  569.71 -/////////////////////////////////////////////////////////////////////////////
  569.72 -// Disassemble message handlers
  569.73 -
  569.74 -void Disassemble::OnAutoUpdate()
  569.75 -{
  569.76 -	autoUpdate = !autoUpdate;
  569.77 -	if (autoUpdate)
  569.78 -	{
  569.79 -		theApp.winAddUpdateListener(this);
  569.80 -	}
  569.81 -	else
  569.82 -	{
  569.83 -		theApp.winRemoveUpdateListener(this);
  569.84 -	}
  569.85 -}
  569.86 -
  569.87 -void Disassemble::OnAutomatic()
  569.88 -{
  569.89 -	mode = 0;
  569.90 -	refresh();
  569.91 -}
  569.92 -
  569.93 -void Disassemble::OnArm()
  569.94 -{
  569.95 -	mode = 1;
  569.96 -	refresh();
  569.97 -}
  569.98 -
  569.99 -void Disassemble::OnClose()
 569.100 -{
 569.101 -	theApp.winRemoveUpdateListener(this);
 569.102 -
 569.103 -	DestroyWindow();
 569.104 -}
 569.105 -
 569.106 -void Disassemble::OnGo()
 569.107 -{
 569.108 -	CString buffer;
 569.109 -	m_address.GetWindowText(buffer);
 569.110 -	sscanf(buffer, "%x", &address);
 569.111 -	refresh();
 569.112 -}
 569.113 -
 569.114 -void Disassemble::OnGopc()
 569.115 -{
 569.116 -	if (armState)
 569.117 -		address = armNextPC - 16;
 569.118 -	else
 569.119 -		address = armNextPC - 8;
 569.120 -
 569.121 -	refresh();
 569.122 -}
 569.123 -
 569.124 -void Disassemble::OnNext()
 569.125 -{
 569.126 -	CPULoop(1);
 569.127 -	if (armState)
 569.128 -	{
 569.129 -		u32 total = address+count*4;
 569.130 -		if (armNextPC >= address && armNextPC < total)
 569.131 -		{}
 569.132 -		else
 569.133 -		{
 569.134 -			OnGopc();
 569.135 -		}
 569.136 -	}
 569.137 -	else
 569.138 -	{
 569.139 -		u32 total = address+count*2;
 569.140 -		if (armNextPC >= address && armNextPC < total)
 569.141 -		{}
 569.142 -		else
 569.143 -		{
 569.144 -			OnGopc();
 569.145 -		}
 569.146 -	}
 569.147 -	refresh();
 569.148 -}
 569.149 -
 569.150 -void Disassemble::OnRefresh()
 569.151 -{
 569.152 -	refresh();
 569.153 -}
 569.154 -
 569.155 -void Disassemble::OnThumb()
 569.156 -{
 569.157 -	mode = 2;
 569.158 -	refresh();
 569.159 -}
 569.160 -
 569.161 -BOOL Disassemble::OnInitDialog()
 569.162 -{
 569.163 -	CDialog::OnInitDialog();
 569.164 -
 569.165 -	DIALOG_SIZER_START(sz)
 569.166 -	DIALOG_SIZER_ENTRY(IDC_DISASSEMBLE, DS_SizeY)
 569.167 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 569.168 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 569.169 -	DIALOG_SIZER_ENTRY(IDC_NEXT,  DS_MoveY)
 569.170 -	DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveY)
 569.171 -	DIALOG_SIZER_ENTRY(IDC_GOPC, DS_MoveY)
 569.172 -	DIALOG_SIZER_ENTRY(IDC_VSCROLL, DS_SizeY)
 569.173 -	DIALOG_SIZER_END()
 569.174 -	SetData(sz,
 569.175 -	        TRUE,
 569.176 -	        HKEY_CURRENT_USER,
 569.177 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\DisassembleView",
 569.178 -	        NULL);
 569.179 -
 569.180 -	SCROLLINFO si;
 569.181 -	ZeroMemory(&si, sizeof(si));
 569.182 -	si.cbSize = sizeof(si);
 569.183 -	si.fMask  = SIF_PAGE | SIF_RANGE | SIF_POS;
 569.184 -	si.nMin   = 0;
 569.185 -	si.nMax   = 100;
 569.186 -	si.nPos   = 50;
 569.187 -	si.nPage  = 0;
 569.188 -	GetDlgItem(IDC_VSCROLL)->SetScrollInfo(SB_CTL, &si, TRUE);
 569.189 -
 569.190 -	CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
 569.191 -	m_list.SetFont(font, FALSE);
 569.192 -	for (int i = 0; i < 17; i++)
 569.193 -		GetDlgItem(IDC_R0+i)->SetFont(font, FALSE);
 569.194 -
 569.195 -	GetDlgItem(IDC_MODE)->SetFont(font, FALSE);
 569.196 -
 569.197 -	m_address.LimitText(8);
 569.198 -	refresh();
 569.199 -
 569.200 -	return TRUE; // return TRUE unless you set the focus to a control
 569.201 -	             // EXCEPTION: OCX Property Pages should return FALSE
 569.202 -}
 569.203 -
 569.204 -void Disassemble::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 569.205 -{
 569.206 -	switch (nSBCode)
 569.207 -	{
 569.208 -	case SB_LINEDOWN:
 569.209 -		if (mode == 0)
 569.210 -		{
 569.211 -			if (armState)
 569.212 -				address += 4;
 569.213 -			else
 569.214 -				address += 2;
 569.215 -		}
 569.216 -		else if (mode == 1)
 569.217 -			address += 4;
 569.218 -		else
 569.219 -			address += 2;
 569.220 -		break;
 569.221 -	case SB_LINEUP:
 569.222 -		if (mode == 0)
 569.223 -		{
 569.224 -			if (armState)
 569.225 -				address -= 4;
 569.226 -			else
 569.227 -				address -= 2;
 569.228 -		}
 569.229 -		else if (mode == 1)
 569.230 -			address -= 4;
 569.231 -		else
 569.232 -			address -= 2;
 569.233 -		break;
 569.234 -	case SB_PAGEDOWN:
 569.235 -		if (mode == 0)
 569.236 -		{
 569.237 -			if (armState)
 569.238 -				address += count*4;
 569.239 -			else
 569.240 -				address += count*2;
 569.241 -		}
 569.242 -		else if (mode == 1)
 569.243 -			address += count*4;
 569.244 -		else
 569.245 -			address += count*2;
 569.246 -		break;
 569.247 -	case SB_PAGEUP:
 569.248 -		if (mode == 0)
 569.249 -		{
 569.250 -			if (armState)
 569.251 -				address -= count*4;
 569.252 -			else
 569.253 -				address -= count*2;
 569.254 -		}
 569.255 -		else if (mode == 1)
 569.256 -			address -= count*4;
 569.257 -		else
 569.258 -			address -= count*2;
 569.259 -		break;
 569.260 -	}
 569.261 -	refresh();
 569.262 -
 569.263 -	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
 569.264 -}
 569.265 -
 569.266 -void Disassemble::refresh()
 569.267 -{
 569.268 -	if (rom == NULL)
 569.269 -		return;
 569.270 -
 569.271 -	bool8 arm = armState;
 569.272 -
 569.273 -	if (mode != 0)
 569.274 -	{
 569.275 -		if (mode == 1)
 569.276 -			arm = true;
 569.277 -		else
 569.278 -			arm = false;
 569.279 -	}
 569.280 -
 569.281 -	int  h = m_list.GetItemHeight(0);
 569.282 -	RECT r;
 569.283 -	m_list.GetClientRect(&r);
 569.284 -	count = (r.bottom - r.top+1)/h;
 569.285 -
 569.286 -	m_list.ResetContent();
 569.287 -	if (!systemIsEmulating() && systemCartridgeType == 0)
 569.288 -		return;
 569.289 -
 569.290 -	char buffer[80];
 569.291 -	u32  addr = address;
 569.292 -	int  i;
 569.293 -	int  sel = -1;
 569.294 -	for (i = 0; i < count; i++)
 569.295 -	{
 569.296 -		if (addr == armNextPC)
 569.297 -			sel = i;
 569.298 -		if (arm)
 569.299 -		{
 569.300 -			addr += disArm(addr, buffer, 3);
 569.301 -		}
 569.302 -		else
 569.303 -		{
 569.304 -			addr += disThumb(addr, buffer, 3);
 569.305 -		}
 569.306 -		m_list.InsertString(-1, buffer);
 569.307 -	}
 569.308 -
 569.309 -	if (sel != -1)
 569.310 -		m_list.SetCurSel(sel);
 569.311 -
 569.312 -	CPUUpdateCPSR();
 569.313 -
 569.314 -	for (i = 0; i < 17; i++)
 569.315 -	{
 569.316 -		sprintf(buffer, "%08x", reg[i].I);
 569.317 -		GetDlgItem(IDC_R0+i)->SetWindowText(buffer);
 569.318 -	}
 569.319 -
 569.320 -	m_n = (reg[16].I & 0x80000000) != 0;
 569.321 -	m_z = (reg[16].I & 0x40000000) != 0;
 569.322 -	m_c = (reg[16].I & 0x20000000) != 0;
 569.323 -	m_v = (reg[16].I & 0x10000000) != 0;
 569.324 -	m_i = (reg[16].I & 0x80) != 0;
 569.325 -	m_f = (reg[16].I & 0x40) != 0;
 569.326 -	m_t = (reg[16].I & 0x20) != 0;
 569.327 -
 569.328 -	UpdateData(FALSE);
 569.329 -
 569.330 -	int v = reg[16].I & 0x1f;
 569.331 -	sprintf(buffer, "%02x", v);
 569.332 -	GetDlgItem(IDC_MODE)->SetWindowText(buffer);
 569.333 -}
 569.334 -
 569.335 -void Disassemble::update()
 569.336 -{
 569.337 -	OnGopc();
 569.338 -	refresh();
 569.339 -}
 569.340 -
 569.341 -void Disassemble::PostNcDestroy()
 569.342 -{
 569.343 -	delete this;
 569.344 -}
 569.345 -
   570.1 --- a/src/win32/Disassemble.h	Sat Mar 03 10:54:39 2012 -0600
   570.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   570.3 @@ -1,72 +0,0 @@
   570.4 -#if !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_)
   570.5 -#define AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_
   570.6 -
   570.7 -#if _MSC_VER > 1000
   570.8 -#pragma once
   570.9 -#endif // _MSC_VER > 1000
  570.10 -// Disassemble.h : header file
  570.11 -//
  570.12 -
  570.13 -#include "IUpdate.h"
  570.14 -#include "ResizeDlg.h"
  570.15 -
  570.16 -/////////////////////////////////////////////////////////////////////////////
  570.17 -// Disassemble dialog
  570.18 -
  570.19 -class Disassemble : public ResizeDlg, IUpdateListener
  570.20 -{
  570.21 -	// Construction
  570.22 -public:
  570.23 -	virtual void update();
  570.24 -	void refresh();
  570.25 -	Disassemble(CWnd*pParent = NULL);  // standard constructor
  570.26 -
  570.27 -	// Dialog Data
  570.28 -	//{{AFX_DATA(Disassemble)
  570.29 -	enum { IDD = IDD_DISASSEMBLE };
  570.30 -	CEdit    m_address;
  570.31 -	CListBox m_list;
  570.32 -	BOOL     m_c;
  570.33 -	BOOL     m_f;
  570.34 -	BOOL     m_i;
  570.35 -	BOOL     m_n;
  570.36 -	BOOL     m_t;
  570.37 -	BOOL     m_v;
  570.38 -	BOOL     m_z;
  570.39 -	//}}AFX_DATA
  570.40 -	bool autoUpdate;
  570.41 -	int  count;
  570.42 -	u32  address;
  570.43 -	int  mode;
  570.44 -
  570.45 -	// Overrides
  570.46 -	// ClassWizard generated virtual function overrides
  570.47 -	//{{AFX_VIRTUAL(Disassemble)
  570.48 -protected:
  570.49 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  570.50 -	virtual void PostNcDestroy();
  570.51 -	//}}AFX_VIRTUAL
  570.52 -
  570.53 -	// Implementation
  570.54 -protected:
  570.55 -	// Generated message map functions
  570.56 -	//{{AFX_MSG(Disassemble)
  570.57 -	afx_msg void OnAutoUpdate();
  570.58 -	afx_msg void OnAutomatic();
  570.59 -	afx_msg void OnArm();
  570.60 -	afx_msg void OnClose();
  570.61 -	afx_msg void OnGo();
  570.62 -	afx_msg void OnGopc();
  570.63 -	afx_msg void OnNext();
  570.64 -	afx_msg void OnRefresh();
  570.65 -	afx_msg void OnThumb();
  570.66 -	virtual BOOL OnInitDialog();
  570.67 -	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  570.68 -	//}}AFX_MSG
  570.69 -	DECLARE_MESSAGE_MAP()
  570.70 -};
  570.71 -
  570.72 -//{{AFX_INSERT_LOCATION}}
  570.73 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  570.74 -
  570.75 -#endif // !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_)
   571.1 --- a/src/win32/Display.h	Sat Mar 03 10:54:39 2012 -0600
   571.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   571.3 @@ -1,35 +0,0 @@
   571.4 -#ifndef VBA_WIN32_DISASSEMBLE_H
   571.5 -#define VBA_WIN32_DISASSEMBLE_H
   571.6 -
   571.7 -#if _MSC_VER > 1000
   571.8 -#pragma once
   571.9 -#endif // _MSC_VER > 1000
  571.10 -
  571.11 -enum DISPLAY_TYPE
  571.12 -{
  571.13 -	GDI         = 0,
  571.14 -	DIRECT_DRAW = 1,
  571.15 -	DIRECT_3D   = 2,
  571.16 -	OPENGL      = 3
  571.17 -};
  571.18 -
  571.19 -class IDisplay
  571.20 -{
  571.21 -public:
  571.22 -	IDisplay() {};
  571.23 -	virtual ~IDisplay() {};
  571.24 -
  571.25 -	virtual bool initialize() = 0;
  571.26 -	virtual void cleanup()    = 0;
  571.27 -	virtual void render()     = 0;
  571.28 -	virtual void checkFullScreen() { };
  571.29 -	virtual void renderMenu() { };
  571.30 -	virtual void clear() = 0;
  571.31 -	virtual bool changeRenderSize(int w, int h) { return true; };
  571.32 -	virtual void resize(int w, int h) {};
  571.33 -	virtual void setOption(const char *option, int value) = 0;
  571.34 -	virtual DISPLAY_TYPE getType() = 0;
  571.35 -	virtual int selectFullScreenMode(GUID * *) = 0;
  571.36 -};
  571.37 -
  571.38 -#endif // VBA_WIN32_DISASSEMBLE_H
   572.1 --- a/src/win32/ExportGSASnapshot.cpp	Sat Mar 03 10:54:39 2012 -0600
   572.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   572.3 @@ -1,92 +0,0 @@
   572.4 -// ExportGSASnapshot.cpp : implementation file
   572.5 -//
   572.6 -
   572.7 -#include "stdafx.h"
   572.8 -#include "resource.h"
   572.9 -#include "ExportGSASnapshot.h"
  572.10 -
  572.11 -#include "../common/System.h"
  572.12 -#include "../gba/GBA.h"
  572.13 -#include "../NLS.h"
  572.14 -
  572.15 -/////////////////////////////////////////////////////////////////////////////
  572.16 -// ExportGSASnapshot dialog
  572.17 -
  572.18 -ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd*pParent /*=NULL*/)
  572.19 -	: CDialog(ExportGSASnapshot::IDD, pParent)
  572.20 -{
  572.21 -	//{{AFX_DATA_INIT(ExportGSASnapshot)
  572.22 -	m_desc  = _T("");
  572.23 -	m_notes = _T("");
  572.24 -	m_title = _T("");
  572.25 -	//}}AFX_DATA_INIT
  572.26 -	m_title    = title;
  572.27 -	m_filename = filename;
  572.28 -	char date[100];
  572.29 -	char time[100];
  572.30 -
  572.31 -	GetDateFormat(LOCALE_USER_DEFAULT,
  572.32 -	              DATE_SHORTDATE,
  572.33 -	              NULL,
  572.34 -	              NULL,
  572.35 -	              date,
  572.36 -	              100);
  572.37 -	GetTimeFormat(LOCALE_USER_DEFAULT,
  572.38 -	              0,
  572.39 -	              NULL,
  572.40 -	              NULL,
  572.41 -	              time,
  572.42 -	              100);
  572.43 -	m_desc.Format("%s %s", date, time);
  572.44 -}
  572.45 -
  572.46 -void ExportGSASnapshot::DoDataExchange(CDataExchange*pDX)
  572.47 -{
  572.48 -	CDialog::DoDataExchange(pDX);
  572.49 -	//{{AFX_DATA_MAP(ExportGSASnapshot)
  572.50 -	DDX_Text(pDX, IDC_DESC, m_desc);
  572.51 -	DDV_MaxChars(pDX, m_desc, 100);
  572.52 -	DDX_Text(pDX, IDC_NOTES, m_notes);
  572.53 -	DDV_MaxChars(pDX, m_notes, 512);
  572.54 -	DDX_Text(pDX, IDC_TITLE, m_title);
  572.55 -	DDV_MaxChars(pDX, m_title, 100);
  572.56 -	//}}AFX_DATA_MAP
  572.57 -}
  572.58 -
  572.59 -BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog)
  572.60 -//{{AFX_MSG_MAP(ExportGSASnapshot)
  572.61 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  572.62 -ON_BN_CLICKED(ID_OK, OnOk)
  572.63 -//}}AFX_MSG_MAP
  572.64 -END_MESSAGE_MAP()
  572.65 -
  572.66 -/////////////////////////////////////////////////////////////////////////////
  572.67 -// ExportGSASnapshot message handlers
  572.68 -
  572.69 -BOOL ExportGSASnapshot::OnInitDialog()
  572.70 -{
  572.71 -	CDialog::OnInitDialog();
  572.72 -	CenterWindow();
  572.73 -
  572.74 -	return TRUE; // return TRUE unless you set the focus to a control
  572.75 -	             // EXCEPTION: OCX Property Pages should return FALSE
  572.76 -}
  572.77 -
  572.78 -void ExportGSASnapshot::OnCancel()
  572.79 -{
  572.80 -	EndDialog(FALSE);
  572.81 -}
  572.82 -
  572.83 -void ExportGSASnapshot::OnOk()
  572.84 -{
  572.85 -	UpdateData(TRUE);
  572.86 -
  572.87 -	bool result = CPUWriteGSASnapshot(m_filename, m_title, m_desc, m_notes);
  572.88 -
  572.89 -	if (!result)
  572.90 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
  572.91 -		              m_filename);
  572.92 -
  572.93 -	EndDialog(TRUE);
  572.94 -}
  572.95 -
   573.1 --- a/src/win32/ExportGSASnapshot.h	Sat Mar 03 10:54:39 2012 -0600
   573.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   573.3 @@ -1,49 +0,0 @@
   573.4 -#if !defined(AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_)
   573.5 -#define AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_
   573.6 -
   573.7 -#if _MSC_VER > 1000
   573.8 -#pragma once
   573.9 -#endif // _MSC_VER > 1000
  573.10 -// ExportGSASnapshot.h : header file
  573.11 -//
  573.12 -
  573.13 -/////////////////////////////////////////////////////////////////////////////
  573.14 -// ExportGSASnapshot dialog
  573.15 -
  573.16 -class ExportGSASnapshot : public CDialog
  573.17 -{
  573.18 -	// Construction
  573.19 -public:
  573.20 -	ExportGSASnapshot(CString filename, CString title, CWnd*pParent = NULL); // standard constructor
  573.21 -
  573.22 -	// Dialog Data
  573.23 -	//{{AFX_DATA(ExportGSASnapshot)
  573.24 -	enum { IDD = IDD_EXPORT_SPS };
  573.25 -	CString m_desc;
  573.26 -	CString m_notes;
  573.27 -	CString m_title;
  573.28 -	//}}AFX_DATA
  573.29 -	CString m_filename;
  573.30 -
  573.31 -	// Overrides
  573.32 -	// ClassWizard generated virtual function overrides
  573.33 -	//{{AFX_VIRTUAL(ExportGSASnapshot)
  573.34 -protected:
  573.35 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  573.36 -	//}}AFX_VIRTUAL
  573.37 -
  573.38 -	// Implementation
  573.39 -protected:
  573.40 -	// Generated message map functions
  573.41 -	//{{AFX_MSG(ExportGSASnapshot)
  573.42 -	virtual BOOL OnInitDialog();
  573.43 -	afx_msg void OnCancel();
  573.44 -	afx_msg void OnOk();
  573.45 -	//}}AFX_MSG
  573.46 -	DECLARE_MESSAGE_MAP()
  573.47 -};
  573.48 -
  573.49 -//{{AFX_INSERT_LOCATION}}
  573.50 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  573.51 -
  573.52 -#endif // !defined(AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_)
   574.1 --- a/src/win32/FileDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   574.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   574.3 @@ -1,199 +0,0 @@
   574.4 -// FileDlg.cpp: implementation of the FileDlg class.
   574.5 -//
   574.6 -//////////////////////////////////////////////////////////////////////
   574.7 -//#define WINVER 0x0410 // windows 98 - just for this 1 file - just in case
   574.8 -#include "stdafx.h"
   574.9 -#include <commdlg.h>
  574.10 -#include <dlgs.h>
  574.11 -#include "resource.h"
  574.12 -#include "FileDlg.h"
  574.13 -#include "Sound.h"
  574.14 -#include "VBA.h"
  574.15 -
  574.16 -static FileDlg *instance = NULL;
  574.17 -
  574.18 -static UINT_PTR CALLBACK HookFunc(HWND hwnd,
  574.19 -                                  UINT msg,
  574.20 -                                  WPARAM wParam,
  574.21 -                                  LPARAM lParam)
  574.22 -{
  574.23 -	if (instance)
  574.24 -	{
  574.25 -		if (msg == WM_NOTIFY)
  574.26 -		{
  574.27 -			OFNOTIFY *notify = (OFNOTIFY *)lParam;
  574.28 -			if (notify)
  574.29 -			{
  574.30 -				if (notify->hdr.code == CDN_TYPECHANGE)
  574.31 -				{
  574.32 -					instance->OnTypeChange(hwnd);
  574.33 -					return 1;
  574.34 -				}
  574.35 -			}
  574.36 -		}
  574.37 -	}
  574.38 -	return 0;
  574.39 -}
  574.40 -
  574.41 -static UINT_PTR CALLBACK HookFuncOldStyle(HWND hwnd,
  574.42 -                                          UINT msg,
  574.43 -                                          WPARAM wParam,
  574.44 -                                          LPARAM lParam)
  574.45 -{
  574.46 -	if (instance)
  574.47 -	{
  574.48 -		if (msg == WM_COMMAND)
  574.49 -		{
  574.50 -			if (HIWORD(wParam) == CBN_SELCHANGE)
  574.51 -			{
  574.52 -				if (LOWORD(wParam) == cmb1)
  574.53 -				{
  574.54 -					// call method with combobox handle to keep
  574.55 -					// behaviour there
  574.56 -					instance->OnTypeChange((HWND)lParam);
  574.57 -					return 1;
  574.58 -				}
  574.59 -			}
  574.60 -		}
  574.61 -	}
  574.62 -	return 0;
  574.63 -}
  574.64 -
  574.65 -/////////////////////////////////////////////////////////////////////////////
  574.66 -// FileDlg
  574.67 -
  574.68 -//////////////////////////////////////////////////////////////////////
  574.69 -// Construction/Destruction
  574.70 -//////////////////////////////////////////////////////////////////////
  574.71 -
  574.72 -FileDlg::FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter,
  574.73 -                 int filterIndex, LPCTSTR ext, LPCTSTR *exts, LPCTSTR initialDir,
  574.74 -                 LPCTSTR title, bool save, bool noReadOnly)
  574.75 -{
  574.76 -	OSVERSIONINFO info;
  574.77 -	info.dwOSVersionInfoSize = sizeof(info);
  574.78 -	GetVersionEx(&info);
  574.79 -	m_file = file;
  574.80 -	int size = sizeof(OPENFILENAME);
  574.81 -
  574.82 -	// avoid problems if OPENFILENAME is already defined with the extended fields
  574.83 -	// needed for the enhanced open/save dialog
  574.84 -#if _WIN32_WINNT < 0x0500
  574.85 -	if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
  574.86 -	{
  574.87 -		if (info.dwMajorVersion >= 5)
  574.88 -			size = sizeof(OPENFILENAMEEX);
  574.89 -	}
  574.90 -#endif
  574.91 -
  574.92 -	ZeroMemory(&m_ofn, sizeof(m_ofn));
  574.93 -	m_ofn.lpstrFile       = m_file.GetBuffer(MAX_PATH);
  574.94 -	m_ofn.nMaxFile        = MAX_PATH;
  574.95 -	m_ofn.lStructSize     = size;
  574.96 -	m_ofn.hwndOwner       = parent ? parent->GetSafeHwnd() : NULL;
  574.97 -	m_ofn.nFilterIndex    = filterIndex;
  574.98 -	m_ofn.lpstrInitialDir = initialDir;
  574.99 -	m_ofn.lpstrTitle      = title;
 574.100 -	m_ofn.lpstrDefExt     = ext;
 574.101 -	m_ofn.lpfnHook        = HookFunc;
 574.102 -	m_ofn.Flags  = OFN_PATHMUSTEXIST | OFN_ENABLESIZING | OFN_ENABLEHOOK;
 574.103 -	m_ofn.Flags |= OFN_EXPLORER;
 574.104 -	if (noReadOnly)
 574.105 -		m_ofn.Flags |= OFN_HIDEREADONLY;
 574.106 -	m_filter = filter;
 574.107 -
 574.108 -	char *p = m_filter.GetBuffer(0);
 574.109 -
 574.110 -	while ((p = strchr(p, '|')) != NULL)
 574.111 -		*p++ = 0;
 574.112 -	m_ofn.lpstrFilter = m_filter;
 574.113 -
 574.114 -	if (theApp.videoOption == VIDEO_320x240)
 574.115 -	{
 574.116 -		m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG);
 574.117 -		m_ofn.lpfnHook       = HookFuncOldStyle;
 574.118 -		m_ofn.Flags |= OFN_ENABLETEMPLATE;
 574.119 -		m_ofn.Flags &= ~OFN_EXPLORER;
 574.120 -	}
 574.121 -
 574.122 -	isSave     = save;
 574.123 -	extensions = exts;
 574.124 -
 574.125 -	instance = this;
 574.126 -}
 574.127 -
 574.128 -FileDlg::~FileDlg()
 574.129 -{
 574.130 -	instance = NULL;
 574.131 -}
 574.132 -
 574.133 -void FileDlg::OnTypeChange(HWND hwnd)
 574.134 -{
 574.135 -	HWND parent = GetParent(hwnd);
 574.136 -
 574.137 -	HWND fileNameControl = ::GetDlgItem(parent, cmb13);
 574.138 -
 574.139 -	if (fileNameControl == NULL)
 574.140 -		fileNameControl = ::GetDlgItem(parent, edt1);
 574.141 -
 574.142 -	if (fileNameControl == NULL)
 574.143 -		return;
 574.144 -
 574.145 -	CString filename;
 574.146 -	GetWindowText(fileNameControl, filename.GetBuffer(MAX_PATH), MAX_PATH);
 574.147 -	filename.ReleaseBuffer();
 574.148 -
 574.149 -	HWND typeControl = ::GetDlgItem(parent, cmb1);
 574.150 -
 574.151 -	ASSERT(typeControl != NULL);
 574.152 -
 574.153 -	int sel = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0);
 574.154 -
 574.155 -	ASSERT(sel != -1);
 574.156 -
 574.157 -	LPCTSTR typeName = extensions[sel];
 574.158 -
 574.159 -	// sel could easily be an invalid index of extensions, so check for null guard
 574.160 -	for(int i = 0; i <= sel; i++)
 574.161 -		if(extensions[i] == NULL)
 574.162 -			typeName = "";
 574.163 -
 574.164 -	if (filename.GetLength() == 0)
 574.165 -	{
 574.166 -		if(*typeName)
 574.167 -			filename.Format("*%s", typeName);
 574.168 -	}
 574.169 -	else
 574.170 -	{
 574.171 -		int index = filename.Find('.');
 574.172 -		if (index == -1)
 574.173 -		{
 574.174 -			filename = filename + typeName;
 574.175 -		}
 574.176 -		else
 574.177 -		{
 574.178 -			filename = filename.Left(index) + typeName;
 574.179 -		}
 574.180 -	}
 574.181 -	SetWindowText(fileNameControl, filename);
 574.182 -}
 574.183 -
 574.184 -int FileDlg::getFilterIndex()
 574.185 -{
 574.186 -	return m_ofn.nFilterIndex;
 574.187 -}
 574.188 -
 574.189 -int FileDlg::DoModal()
 574.190 -{
 574.191 -	systemSoundClearBuffer();
 574.192 -	BOOL res = isSave ? GetSaveFileName(&m_ofn) :
 574.193 -	           GetOpenFileName(&m_ofn);
 574.194 -
 574.195 -	return res ? IDOK : IDCANCEL;
 574.196 -}
 574.197 -
 574.198 -LPCTSTR FileDlg::GetPathName()
 574.199 -{
 574.200 -	return (LPCTSTR)m_file;
 574.201 -}
 574.202 -
   575.1 --- a/src/win32/FileDlg.h	Sat Mar 03 10:54:39 2012 -0600
   575.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   575.3 @@ -1,43 +0,0 @@
   575.4 -#if !defined(AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_)
   575.5 -#define AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_
   575.6 -
   575.7 -#if _MSC_VER > 1000
   575.8 -#pragma once
   575.9 -#endif // _MSC_VER > 1000
  575.10 -// FileDlg.h : header file
  575.11 -//
  575.12 -
  575.13 -struct OPENFILENAMEEX : public OPENFILENAME
  575.14 -{
  575.15 -	void *pvReserved;
  575.16 -	DWORD dwReserved;
  575.17 -	DWORD FlagsEx;
  575.18 -};
  575.19 -
  575.20 -/////////////////////////////////////////////////////////////////////////////
  575.21 -// FileDlg dialog
  575.22 -
  575.23 -class FileDlg
  575.24 -{
  575.25 -private:
  575.26 -	CString m_file;
  575.27 -	CString m_filter;
  575.28 -public:
  575.29 -	OPENFILENAMEEX m_ofn;
  575.30 -	int DoModal();
  575.31 -	LPCTSTR GetPathName();
  575.32 -	virtual int getFilterIndex();
  575.33 -	virtual void OnTypeChange(HWND hwnd);
  575.34 -	FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter,
  575.35 -	        int filterIndex, LPCTSTR ext, LPCTSTR *exts, LPCTSTR initialDir,
  575.36 -	        LPCTSTR title, bool save, bool noReadOnly = false);
  575.37 -	virtual ~FileDlg();
  575.38 -protected:
  575.39 -	bool     isSave;
  575.40 -	LPCTSTR *extensions;
  575.41 -protected:
  575.42 -	//{{AFX_INSERT_LOCATION}}
  575.43 -	// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  575.44 -};
  575.45 -
  575.46 -#endif // !defined(AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_)
   576.1 --- a/src/win32/GBACheatsDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   576.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   576.3 @@ -1,1279 +0,0 @@
   576.4 -// GBACheats.cpp : implementation file
   576.5 -//
   576.6 -
   576.7 -#include "stdafx.h"
   576.8 -#include "resource.h"
   576.9 -#include "GBACheatsDlg.h"
  576.10 -#include "Reg.h"
  576.11 -#include "StringTokenizer.h"
  576.12 -#include "WinResUtil.h"
  576.13 -#include "Sound.h"
  576.14 -#include "VBA.h"
  576.15 -
  576.16 -#include "../gba/GBACheats.h"
  576.17 -#include "../gba/GBAGlobals.h"
  576.18 -#include "../common/CheatSearch.h"
  576.19 -
  576.20 -////////////////////////////////
  576.21 -
  576.22 -bool winGbaCheatReaddress()
  576.23 -{
  576.24 -	if (cheatSearchData.count != 2)
  576.25 -		return false;
  576.26 -
  576.27 -	CheatSearchBlock *block = &cheatSearchData.blocks[0];
  576.28 -	block->data   = workRAM;
  576.29 -
  576.30 -	block         = &cheatSearchData.blocks[1];
  576.31 -	block->data   = internalRAM;
  576.32 -	
  576.33 -	cheatSearchData.count = 2;
  576.34 -	return true;
  576.35 -}
  576.36 -
  576.37 -/////////////////////////////////////////////////////////////////////////////
  576.38 -// GBACheatSearch dialog
  576.39 -
  576.40 -GBACheatSearch::GBACheatSearch(CWnd*pParent /*=NULL*/)
  576.41 -	: CDialog(GBACheatSearch::IDD, pParent)
  576.42 -{
  576.43 -	//{{AFX_DATA_INIT(GBACheatSearch)
  576.44 -	valueType    = -1;
  576.45 -	sizeType     = -1;
  576.46 -	searchType   = -1;
  576.47 -	numberType   = -1;
  576.48 -	updateValues = FALSE;
  576.49 -	//}}AFX_DATA_INIT
  576.50 -	data = NULL;
  576.51 -}
  576.52 -
  576.53 -GBACheatSearch::~GBACheatSearch()
  576.54 -{
  576.55 -	if (data)
  576.56 -		free(data);
  576.57 -}
  576.58 -
  576.59 -void GBACheatSearch::DoDataExchange(CDataExchange*pDX)
  576.60 -{
  576.61 -	CDialog::DoDataExchange(pDX);
  576.62 -	//{{AFX_DATA_MAP(GBACheatSearch)
  576.63 -	DDX_Control(pDX, IDC_VALUE, m_value);
  576.64 -	DDX_Control(pDX, IDC_CHEAT_LIST, m_list);
  576.65 -	DDX_Radio(pDX, IDC_OLD_VALUE, valueType);
  576.66 -	DDX_Radio(pDX, IDC_SIZE_8, sizeType);
  576.67 -	DDX_Radio(pDX, IDC_EQ, searchType);
  576.68 -	DDX_Radio(pDX, IDC_SIGNED, numberType);
  576.69 -	DDX_Check(pDX, IDC_UPDATE, updateValues);
  576.70 -	//}}AFX_DATA_MAP
  576.71 -}
  576.72 -
  576.73 -BEGIN_MESSAGE_MAP(GBACheatSearch, CDialog)
  576.74 -//{{AFX_MSG_MAP(GBACheatSearch)
  576.75 -ON_BN_CLICKED(ID_OK, OnOk)
  576.76 -ON_BN_CLICKED(IDC_START, OnStart)
  576.77 -ON_BN_CLICKED(IDC_SEARCH, OnSearch)
  576.78 -ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat)
  576.79 -ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
  576.80 -ON_NOTIFY(LVN_GETDISPINFO, IDC_CHEAT_LIST, OnGetdispinfoCheatList)
  576.81 -ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
  576.82 -ON_CONTROL_RANGE(BN_CLICKED, IDC_OLD_VALUE, IDC_SPECIFIC_VALUE, OnValueType)
  576.83 -ON_CONTROL_RANGE(BN_CLICKED, IDC_EQ, IDC_GE, OnSearchType)
  576.84 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType)
  576.85 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType)
  576.86 -//}}AFX_MSG_MAP
  576.87 -ON_WM_CLOSE()
  576.88 -ON_BN_CLICKED(IDC_CHEATREFRESHBUTTON, OnBnClickedCheatrefreshbutton)
  576.89 -//ON_WM_DESTROY()
  576.90 -//ON_WM_NCDESTROY()
  576.91 -//ON_WM_SYSCOMMAND()
  576.92 -//ON_WM_ACTIVATE()
  576.93 -END_MESSAGE_MAP()
  576.94 -
  576.95 -/////////////////////////////////////////////////////////////////////////////
  576.96 -// GBACheatSearch message handlers
  576.97 -
  576.98 -void GBACheatSearch::OnOk()
  576.99 -{
 576.100 -	if (theApp.modelessCheatDialogIsOpen)
 576.101 -	{
 576.102 -		theApp.modelessCheatDialogIsOpen = false;
 576.103 -		DestroyWindow();
 576.104 -	}
 576.105 -	else
 576.106 -	{
 576.107 -		EndDialog(TRUE);
 576.108 -	}
 576.109 -}
 576.110 -
 576.111 -void GBACheatSearch::OnClose()
 576.112 -{
 576.113 -	CDialog::OnClose();
 576.114 -	if (theApp.modelessCheatDialogIsOpen)
 576.115 -	{
 576.116 -		theApp.modelessCheatDialogIsOpen = false;
 576.117 -		DestroyWindow();
 576.118 -	}
 576.119 -	else
 576.120 -	{
 576.121 -		EndDialog(FALSE);
 576.122 -	}
 576.123 -}
 576.124 -
 576.125 -void GBACheatSearch::OnStart()
 576.126 -{
 576.127 -	if (cheatSearchData.count == 0)
 576.128 -	{
 576.129 -		CheatSearchBlock *block = &cheatSearchData.blocks[0];
 576.130 -		block->data   = workRAM;
 576.131 -		block->offset = 0x2000000;
 576.132 -		block->size   = 0x40000;
 576.133 -		block->saved  = (u8 *)malloc(0x40000);
 576.134 -		block->bits   = (u8 *)malloc(0x40000>>3);
 576.135 -
 576.136 -		block         = &cheatSearchData.blocks[1];
 576.137 -		block->data   = internalRAM;
 576.138 -		block->offset = 0x3000000;
 576.139 -		block->size   = 0x8000;
 576.140 -		block->saved  = (u8 *)malloc(0x8000);
 576.141 -		block->bits   = (u8 *)malloc(0x8000>>3);
 576.142 -
 576.143 -		cheatSearchData.count = 2;
 576.144 -	}
 576.145 -
 576.146 -	cheatSearchStart(&cheatSearchData);
 576.147 -	GetDlgItem(IDC_SEARCH)->EnableWindow(TRUE);
 576.148 -
 576.149 -	if (theApp.modelessCheatDialogIsOpen)
 576.150 -	{
 576.151 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE);
 576.152 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE);
 576.153 -	}
 576.154 -}
 576.155 -
 576.156 -void GBACheatSearch::OnSearch()
 576.157 -{
 576.158 -	CString buffer;
 576.159 -
 576.160 -	if (valueType == 0)
 576.161 -		cheatSearch(&cheatSearchData,
 576.162 -		            searchType,
 576.163 -		            sizeType,
 576.164 -		            numberType == 0);
 576.165 -	else
 576.166 -	{
 576.167 -		m_value.GetWindowText(buffer);
 576.168 -		if (buffer.IsEmpty())
 576.169 -		{
 576.170 -			systemMessage(IDS_NUMBER_CANNOT_BE_EMPTY, "Number cannot be empty");
 576.171 -			return;
 576.172 -		}
 576.173 -		int value = 0;
 576.174 -		switch (numberType)
 576.175 -		{
 576.176 -		case 0:
 576.177 -			sscanf(buffer, "%d", &value);
 576.178 -			break;
 576.179 -		case 1:
 576.180 -			sscanf(buffer, "%u", &value);
 576.181 -			break;
 576.182 -		default:
 576.183 -			sscanf(buffer, "%x", &value);
 576.184 -		}
 576.185 -		cheatSearchValue(&cheatSearchData,
 576.186 -		                 searchType,
 576.187 -		                 sizeType,
 576.188 -		                 numberType == 0,
 576.189 -		                 value);
 576.190 -	}
 576.191 -
 576.192 -	addChanges(true);
 576.193 -
 576.194 -	if (updateValues)
 576.195 -		cheatSearchUpdateValues(&cheatSearchData);
 576.196 -
 576.197 -	if (theApp.modelessCheatDialogIsOpen)
 576.198 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE);
 576.199 -
 576.200 -	if (0 == cheatSearchGetCount(&cheatSearchData, sizeType))
 576.201 -		OnStart();
 576.202 -}
 576.203 -
 576.204 -void GBACheatSearch::OnAddCheat()
 576.205 -{
 576.206 -	int mark = m_list.GetSelectionMark();
 576.207 -
 576.208 -	if (mark != -1)
 576.209 -	{
 576.210 -		LVITEM item;
 576.211 -		memset(&item, 0, sizeof(item));
 576.212 -		item.mask  = LVIF_PARAM;
 576.213 -		item.iItem = mark;
 576.214 -		if (m_list.GetItem(&item))
 576.215 -		{
 576.216 -			AddCheat dlg((u32)item.lParam);
 576.217 -			dlg.DoModal();
 576.218 -		}
 576.219 -	}
 576.220 -}
 576.221 -
 576.222 -void GBACheatSearch::OnUpdate()
 576.223 -{
 576.224 -	if (GetDlgItem(IDC_UPDATE)->SendMessage(BM_GETCHECK,
 576.225 -	                                        0,
 576.226 -	                                        0) & BST_CHECKED)
 576.227 -		updateValues = true;
 576.228 -	else
 576.229 -		updateValues = false;
 576.230 -	regSetDwordValue("cheatsUpdate", updateValues);
 576.231 -}
 576.232 -
 576.233 -void GBACheatSearch::OnGetdispinfoCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 576.234 -{
 576.235 -	LV_DISPINFO*info = (LV_DISPINFO *)pNMHDR;
 576.236 -	if (info->item.mask & LVIF_TEXT)
 576.237 -	{
 576.238 -		int index = info->item.iItem;
 576.239 -		int col   = info->item.iSubItem;
 576.240 -
 576.241 -		switch (col)
 576.242 -		{
 576.243 -		case 0:
 576.244 -			strcpy(info->item.pszText, data[index].address);
 576.245 -			break;
 576.246 -		case 1:
 576.247 -			strcpy(info->item.pszText, data[index].oldValue);
 576.248 -			break;
 576.249 -		case 2:
 576.250 -			strcpy(info->item.pszText, data[index].newValue);
 576.251 -			break;
 576.252 -		}
 576.253 -	}
 576.254 -	*pResult = TRUE;
 576.255 -}
 576.256 -
 576.257 -void GBACheatSearch::OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 576.258 -{
 576.259 -	GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(m_list.GetSelectionMark() != -1);
 576.260 -	*pResult = TRUE;
 576.261 -}
 576.262 -
 576.263 -BOOL GBACheatSearch::OnInitDialog()
 576.264 -{
 576.265 -	CDialog::OnInitDialog();
 576.266 -
 576.267 -	CString temp = winResLoadString(IDS_ADDRESS);
 576.268 -
 576.269 -	m_list.InsertColumn(0, temp, LVCFMT_CENTER, 125, 0);
 576.270 -
 576.271 -	temp = winResLoadString(IDS_OLD_VALUE);
 576.272 -	m_list.InsertColumn(1, temp, LVCFMT_CENTER, 125, 1);
 576.273 -
 576.274 -	temp = winResLoadString(IDS_NEW_VALUE);
 576.275 -	m_list.InsertColumn(2, temp, LVCFMT_CENTER, 125, 2);
 576.276 -
 576.277 -	m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)),
 576.278 -	               TRUE);
 576.279 -
 576.280 -	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
 576.281 -
 576.282 -	if (!cheatSearchData.count)
 576.283 -	{
 576.284 -		GetDlgItem(IDC_SEARCH)->EnableWindow(FALSE);
 576.285 -		GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(FALSE);
 576.286 -	}
 576.287 -
 576.288 -	valueType = regQueryDwordValue("cheatsValueType", 0);
 576.289 -	if (valueType < 0 || valueType > 1)
 576.290 -		valueType = 0;
 576.291 -
 576.292 -	searchType = regQueryDwordValue("cheatsSearchType", SEARCH_EQ);
 576.293 -	if (searchType > 5 || searchType < 0)
 576.294 -		searchType = 0;
 576.295 -
 576.296 -	numberType = regQueryDwordValue("cheatsNumberType", 2);
 576.297 -	if (numberType < 0 || numberType > 2)
 576.298 -		numberType = 2;
 576.299 -
 576.300 -	sizeType = regQueryDwordValue("cheatsSizeType", 0);
 576.301 -	if (sizeType < 0 || sizeType > 2)
 576.302 -		sizeType = 0;
 576.303 -
 576.304 -	updateValues = regQueryDwordValue("cheatsUpdate", 0) ?
 576.305 -	               true : false;
 576.306 -
 576.307 -	UpdateData(FALSE);
 576.308 -
 576.309 -	if (valueType == 0)
 576.310 -		m_value.EnableWindow(FALSE);
 576.311 -	CenterWindow();
 576.312 -
 576.313 -	if (theApp.modelessCheatDialogIsOpen)
 576.314 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE);
 576.315 -
 576.316 -	if (cheatSearchData.count)
 576.317 -	{
 576.318 -		addChanges(false);
 576.319 -		if (theApp.modelessCheatDialogIsOpen)
 576.320 -			GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData,
 576.321 -			                                                                     sizeType) == 0 ? FALSE : TRUE);
 576.322 -	}
 576.323 -	else
 576.324 -	{
 576.325 -		if (theApp.modelessCheatDialogIsOpen)
 576.326 -			GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE);
 576.327 -	}
 576.328 -
 576.329 -	return TRUE; // return TRUE unless you set the focus to a control
 576.330 -	             // EXCEPTION: OCX Property Pages should return FALSE
 576.331 -}
 576.332 -
 576.333 -void GBACheatSearch::addChanges(bool showMsgs)
 576.334 -{
 576.335 -	int count = cheatSearchGetCount(&cheatSearchData, sizeType);
 576.336 -
 576.337 -	m_list.DeleteAllItems();
 576.338 -
 576.339 -	if (count > 4000)
 576.340 -	{
 576.341 -		if (showMsgs)
 576.342 -			systemMessage(
 576.343 -			    IDS_SEARCH_PRODUCED_TOO_MANY,
 576.344 -			    "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches.",
 576.345 -			    count);
 576.346 -		return;
 576.347 -	}
 576.348 -
 576.349 -	if (count == 0)
 576.350 -	{
 576.351 -		if (showMsgs)
 576.352 -			systemMessage(IDS_SEARCH_PRODUCED_NO_RESULTS, "Search produced no results.");
 576.353 -		return;
 576.354 -	}
 576.355 -
 576.356 -	m_list.SetItemCount(count);
 576.357 -	if (data)
 576.358 -		free(data);
 576.359 -
 576.360 -	data = (WinCheatsData *)calloc(count, sizeof(WinCheatsData));
 576.361 -
 576.362 -	int inc = 1;
 576.363 -	switch (sizeType)
 576.364 -	{
 576.365 -	case 1:
 576.366 -		inc = 2;
 576.367 -		break;
 576.368 -	case 2:
 576.369 -		inc = 4;
 576.370 -		break;
 576.371 -	}
 576.372 -
 576.373 -	int index = 0;
 576.374 -	if (numberType == 0)
 576.375 -	{
 576.376 -		for (int i = 0; i < cheatSearchData.count; i++)
 576.377 -		{
 576.378 -			CheatSearchBlock *block = &cheatSearchData.blocks[i];
 576.379 -
 576.380 -			for (int j = 0; j < block->size; j += inc)
 576.381 -			{
 576.382 -				if (IS_BIT_SET(block->bits, j))
 576.383 -				{
 576.384 -					addChange(index++,
 576.385 -					          block->offset | j,
 576.386 -					          cheatSearchSignedRead(block->saved,
 576.387 -					                                j,
 576.388 -					                                sizeType),
 576.389 -					          cheatSearchSignedRead(block->data,
 576.390 -					                                j,
 576.391 -					                                sizeType));
 576.392 -				}
 576.393 -			}
 576.394 -		}
 576.395 -	}
 576.396 -	else
 576.397 -	{
 576.398 -		for (int i = 0; i < cheatSearchData.count; i++)
 576.399 -		{
 576.400 -			CheatSearchBlock *block = &cheatSearchData.blocks[i];
 576.401 -
 576.402 -			for (int j = 0; j < block->size; j += inc)
 576.403 -			{
 576.404 -				if (IS_BIT_SET(block->bits, j))
 576.405 -				{
 576.406 -					addChange(index++,
 576.407 -					          block->offset | j,
 576.408 -					          cheatSearchRead(block->saved,
 576.409 -					                          j,
 576.410 -					                          sizeType),
 576.411 -					          cheatSearchRead(block->data,
 576.412 -					                          j,
 576.413 -					                          sizeType));
 576.414 -				}
 576.415 -			}
 576.416 -		}
 576.417 -	}
 576.418 -
 576.419 -	for (int i = 0; i < count; i++)
 576.420 -	{
 576.421 -		LVITEM item;
 576.422 -
 576.423 -		item.mask      = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
 576.424 -		item.iItem     = i;
 576.425 -		item.iSubItem  = 0;
 576.426 -		item.lParam    = data[i].addr;
 576.427 -		item.state     = 0;
 576.428 -		item.stateMask = 0;
 576.429 -		item.pszText   = LPSTR_TEXTCALLBACK;
 576.430 -		m_list.InsertItem(&item);
 576.431 -
 576.432 -		m_list.SetItemText(i, 1, LPSTR_TEXTCALLBACK);
 576.433 -		m_list.SetItemText(i, 2, LPSTR_TEXTCALLBACK);
 576.434 -	}
 576.435 -}
 576.436 -
 576.437 -void GBACheatSearch::addChange(int index, u32 address, u32 oldValue, u32 newValue)
 576.438 -{
 576.439 -	data[index].addr = address;
 576.440 -	sprintf(data[index].address, "%08x", address);
 576.441 -	switch (numberType)
 576.442 -	{
 576.443 -	case 0:
 576.444 -		sprintf(data[index].oldValue, "%d", oldValue);
 576.445 -		sprintf(data[index].newValue, "%d", newValue);
 576.446 -		break;
 576.447 -	case 1:
 576.448 -		sprintf(data[index].oldValue, "%u", oldValue);
 576.449 -		sprintf(data[index].newValue, "%u", newValue);
 576.450 -		break;
 576.451 -	case 2:
 576.452 -		switch (sizeType)
 576.453 -		{
 576.454 -		case 0:
 576.455 -			sprintf(data[index].oldValue, "%02x", oldValue);
 576.456 -			sprintf(data[index].newValue, "%02x", newValue);
 576.457 -			break;
 576.458 -		case 1:
 576.459 -			sprintf(data[index].oldValue, "%04x", oldValue);
 576.460 -			sprintf(data[index].newValue, "%04x", newValue);
 576.461 -			break;
 576.462 -		case 2:
 576.463 -			sprintf(data[index].oldValue, "%08x", oldValue);
 576.464 -			sprintf(data[index].newValue, "%08x", newValue);
 576.465 -			break;
 576.466 -		}
 576.467 -	}
 576.468 -}
 576.469 -
 576.470 -void GBACheatSearch::OnValueType(UINT id)
 576.471 -{
 576.472 -	switch (id)
 576.473 -	{
 576.474 -	case IDC_OLD_VALUE:
 576.475 -		valueType = 0;
 576.476 -		m_value.EnableWindow(FALSE);
 576.477 -		regSetDwordValue("cheatsValueType", 0);
 576.478 -		break;
 576.479 -	case IDC_SPECIFIC_VALUE:
 576.480 -		valueType = 1;
 576.481 -		m_value.EnableWindow(TRUE);
 576.482 -		regSetDwordValue("cheatsValueType", 1);
 576.483 -		break;
 576.484 -	}
 576.485 -}
 576.486 -
 576.487 -void GBACheatSearch::OnSearchType(UINT id)
 576.488 -{
 576.489 -	switch (id)
 576.490 -	{
 576.491 -	case IDC_EQ:
 576.492 -		searchType = SEARCH_EQ;
 576.493 -		regSetDwordValue("cheatsSearchType", 0);
 576.494 -		break;
 576.495 -	case IDC_NE:
 576.496 -		searchType = SEARCH_NE;
 576.497 -		regSetDwordValue("cheatsSearchType", 1);
 576.498 -		break;
 576.499 -	case IDC_LT:
 576.500 -		searchType = SEARCH_LT;
 576.501 -		regSetDwordValue("cheatsSearchType", 2);
 576.502 -		break;
 576.503 -	case IDC_LE:
 576.504 -		searchType = SEARCH_LE;
 576.505 -		regSetDwordValue("cheatsSearchType", 3);
 576.506 -		break;
 576.507 -	case IDC_GT:
 576.508 -		searchType = SEARCH_GT;
 576.509 -		regSetDwordValue("cheatsSearchType", 4);
 576.510 -		break;
 576.511 -	case IDC_GE:
 576.512 -		searchType = SEARCH_GE;
 576.513 -		regSetDwordValue("cheatsSearchType", 5);
 576.514 -		break;
 576.515 -	}
 576.516 -}
 576.517 -
 576.518 -void GBACheatSearch::OnNumberType(UINT id)
 576.519 -{
 576.520 -	switch (id)
 576.521 -	{
 576.522 -	case IDC_SIGNED:
 576.523 -		numberType = 0;
 576.524 -		regSetDwordValue("cheatsNumberType", 0);
 576.525 -		if (m_list.GetItemCount())
 576.526 -		{
 576.527 -			addChanges(false);
 576.528 -		}
 576.529 -		break;
 576.530 -	case IDC_UNSIGNED:
 576.531 -		numberType = 1;
 576.532 -		regSetDwordValue("cheatsNumberType", 1);
 576.533 -		if (m_list.GetItemCount())
 576.534 -		{
 576.535 -			addChanges(false);
 576.536 -		}
 576.537 -		break;
 576.538 -	case IDC_HEXADECIMAL:
 576.539 -		numberType = 2;
 576.540 -		regSetDwordValue("cheatsNumberType", 2);
 576.541 -		if (m_list.GetItemCount())
 576.542 -		{
 576.543 -			addChanges(false);
 576.544 -		}
 576.545 -		break;
 576.546 -	}
 576.547 -}
 576.548 -
 576.549 -void GBACheatSearch::OnSizeType(UINT id)
 576.550 -{
 576.551 -	switch (id)
 576.552 -	{
 576.553 -	case IDC_SIZE_8:
 576.554 -		sizeType = BITS_8;
 576.555 -		regSetDwordValue("cheatsSizeType", 0);
 576.556 -		if (m_list.GetItemCount())
 576.557 -		{
 576.558 -			addChanges(false);
 576.559 -		}
 576.560 -		break;
 576.561 -	case IDC_SIZE_16:
 576.562 -		sizeType = BITS_16;
 576.563 -		regSetDwordValue("cheatsSizeType", 1);
 576.564 -		if (m_list.GetItemCount())
 576.565 -		{
 576.566 -			addChanges(false);
 576.567 -		}
 576.568 -		break;
 576.569 -	case IDC_SIZE_32:
 576.570 -		sizeType = BITS_32;
 576.571 -		regSetDwordValue("cheatsSizeType", 2);
 576.572 -		if (m_list.GetItemCount())
 576.573 -		{
 576.574 -			addChanges(false);
 576.575 -		}
 576.576 -		break;
 576.577 -	}
 576.578 -}
 576.579 -
 576.580 -/////////////////////////////////////////////////////////////////////////////
 576.581 -// AddCheat dialog
 576.582 -
 576.583 -AddCheat::AddCheat(u32 address, CWnd*pParent /*=NULL*/)
 576.584 -	: CDialog(AddCheat::IDD, pParent)
 576.585 -{
 576.586 -	//{{AFX_DATA_INIT(AddCheat)
 576.587 -	numberType = regQueryDwordValue("cheatsNumberType", 2);
 576.588 -	if (numberType < 0 || numberType > 2)
 576.589 -		numberType = 2;
 576.590 -	sizeType = regQueryDwordValue("cheatsSizeType", 0);
 576.591 -	if (sizeType < 0 || sizeType > 2)
 576.592 -		sizeType = 0;
 576.593 -	//}}AFX_DATA_INIT
 576.594 -	this->address = address;
 576.595 -}
 576.596 -
 576.597 -void AddCheat::DoDataExchange(CDataExchange*pDX)
 576.598 -{
 576.599 -	CDialog::DoDataExchange(pDX);
 576.600 -	//{{AFX_DATA_MAP(AddCheat)
 576.601 -	DDX_Control(pDX, IDC_VALUE, m_value);
 576.602 -	DDX_Control(pDX, IDC_DESC, m_desc);
 576.603 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
 576.604 -	DDX_Radio(pDX, IDC_SIZE_8, sizeType);
 576.605 -	DDX_Radio(pDX, IDC_SIGNED, numberType);
 576.606 -	//}}AFX_DATA_MAP
 576.607 -}
 576.608 -
 576.609 -BEGIN_MESSAGE_MAP(AddCheat, CDialog)
 576.610 -//{{AFX_MSG_MAP(AddCheat)
 576.611 -ON_BN_CLICKED(ID_OK, OnOk)
 576.612 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 576.613 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType)
 576.614 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType)
 576.615 -//}}AFX_MSG_MAP
 576.616 -END_MESSAGE_MAP()
 576.617 -
 576.618 -/////////////////////////////////////////////////////////////////////////////
 576.619 -// AddCheat message handlers
 576.620 -
 576.621 -void AddCheat::OnOk()
 576.622 -{
 576.623 -	// add cheat
 576.624 -	if (addCheat())
 576.625 -	{
 576.626 -		EndDialog(TRUE);
 576.627 -	}
 576.628 -}
 576.629 -
 576.630 -void AddCheat::OnCancel()
 576.631 -{
 576.632 -	EndDialog(FALSE);
 576.633 -}
 576.634 -
 576.635 -BOOL AddCheat::OnInitDialog()
 576.636 -{
 576.637 -	CDialog::OnInitDialog();
 576.638 -
 576.639 -	if (address != 0)
 576.640 -	{
 576.641 -		CString buffer;
 576.642 -		buffer.Format("%08x", address);
 576.643 -		m_address.SetWindowText(buffer);
 576.644 -		m_address.EnableWindow(FALSE);
 576.645 -	}
 576.646 -
 576.647 -	UpdateData(FALSE);
 576.648 -
 576.649 -	GetDlgItem(IDC_DESC)->SendMessage(EM_LIMITTEXT,
 576.650 -	                                  32,
 576.651 -	                                  0);
 576.652 -	if (address != 0)
 576.653 -	{
 576.654 -		GetDlgItem(IDC_SIZE_8)->EnableWindow(FALSE);
 576.655 -		GetDlgItem(IDC_SIZE_16)->EnableWindow(FALSE);
 576.656 -		GetDlgItem(IDC_SIZE_32)->EnableWindow(FALSE);
 576.657 -		GetDlgItem(IDC_HEXADECIMAL)->EnableWindow(FALSE);
 576.658 -		GetDlgItem(IDC_UNSIGNED)->EnableWindow(FALSE);
 576.659 -		GetDlgItem(IDC_SIGNED)->EnableWindow(FALSE);
 576.660 -	}
 576.661 -
 576.662 -	CenterWindow();
 576.663 -
 576.664 -	return TRUE; // return TRUE unless you set the focus to a control
 576.665 -	             // EXCEPTION: OCX Property Pages should return FALSE
 576.666 -}
 576.667 -
 576.668 -void AddCheat::OnNumberType(UINT id)
 576.669 -{
 576.670 -	switch (id)
 576.671 -	{
 576.672 -	case IDC_SIGNED:
 576.673 -		numberType = 0;
 576.674 -		regSetDwordValue("cheatsNumberType", 0);
 576.675 -		break;
 576.676 -	case IDC_UNSIGNED:
 576.677 -		numberType = 1;
 576.678 -		regSetDwordValue("cheatsNumberType", 1);
 576.679 -		break;
 576.680 -	case IDC_HEXADECIMAL:
 576.681 -		numberType = 2;
 576.682 -		regSetDwordValue("cheatsNumberType", 2);
 576.683 -		break;
 576.684 -	}
 576.685 -}
 576.686 -
 576.687 -void AddCheat::OnSizeType(UINT id)
 576.688 -{
 576.689 -	switch (id)
 576.690 -	{
 576.691 -	case IDC_SIZE_8:
 576.692 -		sizeType = BITS_8;
 576.693 -		regSetDwordValue("cheatsSizeType", 0);
 576.694 -		break;
 576.695 -	case IDC_SIZE_16:
 576.696 -		sizeType = BITS_16;
 576.697 -		regSetDwordValue("cheatsSizeType", 1);
 576.698 -		break;
 576.699 -	case IDC_SIZE_32:
 576.700 -		sizeType = BITS_32;
 576.701 -		regSetDwordValue("cheatsSizeType", 2);
 576.702 -		break;
 576.703 -	}
 576.704 -}
 576.705 -
 576.706 -bool AddCheat::addCheat()
 576.707 -{
 576.708 -	CString buffer;
 576.709 -	CString code;
 576.710 -
 576.711 -	m_address.GetWindowText(buffer);
 576.712 -	u32 address = 0;
 576.713 -	sscanf(buffer, "%x", &address);
 576.714 -	if ((address >= 0x02000000 && address < 0x02040000) ||
 576.715 -	    (address >= 0x03000000 && address < 0x03008000))
 576.716 -	{}
 576.717 -	else
 576.718 -	{
 576.719 -		systemMessage(IDS_INVALID_ADDRESS, "Invalid address: %08x", address);
 576.720 -		return false;
 576.721 -	}
 576.722 -	if (sizeType != 0)
 576.723 -	{
 576.724 -		if (sizeType == 1 && address & 1)
 576.725 -		{
 576.726 -			systemMessage(IDS_MISALIGNED_HALFWORD, "Misaligned half-word address: %08x", address);
 576.727 -			return false;
 576.728 -		}
 576.729 -		if (sizeType == 2 && address & 3)
 576.730 -		{
 576.731 -			systemMessage(IDS_MISALIGNED_WORD, "Misaligned word address: %08x", address);
 576.732 -			return false;
 576.733 -		}
 576.734 -	}
 576.735 -	u32 value;
 576.736 -	m_value.GetWindowText(buffer);
 576.737 -
 576.738 -	if (buffer.IsEmpty())
 576.739 -	{
 576.740 -		systemMessage(IDS_VALUE_CANNOT_BE_EMPTY, "Value cannot be empty");
 576.741 -		return false;
 576.742 -	}
 576.743 -
 576.744 -	switch (numberType)
 576.745 -	{
 576.746 -	case 0:
 576.747 -		sscanf(buffer, "%d", &value);
 576.748 -		break;
 576.749 -	case 1:
 576.750 -		sscanf(buffer, "%u", &value);
 576.751 -		break;
 576.752 -	default:
 576.753 -		sscanf(buffer, "%x", &value);
 576.754 -	}
 576.755 -
 576.756 -	m_desc.GetWindowText(buffer);
 576.757 -
 576.758 -	switch (sizeType)
 576.759 -	{
 576.760 -	case 0:
 576.761 -		code.Format("%08x:%02x", address, value);
 576.762 -		break;
 576.763 -	case 1:
 576.764 -		code.Format("%08x:%04x", address, value);
 576.765 -		break;
 576.766 -	case 2:
 576.767 -		code.Format("%08x:%08x", address, value);
 576.768 -		break;
 576.769 -	}
 576.770 -
 576.771 -	cheatsAdd(code, buffer, address, value, -1, sizeType);
 576.772 -	return true;
 576.773 -}
 576.774 -
 576.775 -/////////////////////////////////////////////////////////////////////////////
 576.776 -// GBACheatList dialog
 576.777 -
 576.778 -GBACheatList::GBACheatList(CWnd*pParent /*=NULL*/)
 576.779 -	: CDialog(GBACheatList::IDD, pParent)
 576.780 -{
 576.781 -	//{{AFX_DATA_INIT(GBACheatList)
 576.782 -	// NOTE: the ClassWizard will add member initialization here
 576.783 -	//}}AFX_DATA_INIT
 576.784 -}
 576.785 -
 576.786 -void GBACheatList::DoDataExchange(CDataExchange*pDX)
 576.787 -{
 576.788 -	CDialog::DoDataExchange(pDX);
 576.789 -	//{{AFX_DATA_MAP(GBACheatList)
 576.790 -	DDX_Control(pDX, IDC_RESTORE, m_restore);
 576.791 -	DDX_Control(pDX, IDC_CHEAT_LIST, m_list);
 576.792 -	//}}AFX_DATA_MAP
 576.793 -}
 576.794 -
 576.795 -BEGIN_MESSAGE_MAP(GBACheatList, CDialog)
 576.796 -//{{AFX_MSG_MAP(GBACheatList)
 576.797 -ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat)
 576.798 -ON_BN_CLICKED(IDC_ADD_CODE, OnAddCode)
 576.799 -ON_BN_CLICKED(IDC_ADD_CODEBREAKER, OnAddCodebreaker)
 576.800 -ON_BN_CLICKED(IDC_ADD_GAMESHARK, OnAddGameshark)
 576.801 -ON_BN_CLICKED(IDC_ENABLE, OnEnable)
 576.802 -ON_BN_CLICKED(IDC_REMOVE, OnRemove)
 576.803 -ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
 576.804 -ON_BN_CLICKED(IDC_RESTORE, OnRestore)
 576.805 -ON_BN_CLICKED(ID_OK, OnOk)
 576.806 -ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
 576.807 -//}}AFX_MSG_MAP
 576.808 -END_MESSAGE_MAP()
 576.809 -
 576.810 -/////////////////////////////////////////////////////////////////////////////
 576.811 -// GBACheatList message handlers
 576.812 -
 576.813 -void GBACheatList::OnAddCheat()
 576.814 -{
 576.815 -	AddCheat dlg(0);
 576.816 -	dlg.DoModal();
 576.817 -	refresh();
 576.818 -}
 576.819 -
 576.820 -void GBACheatList::OnAddCode()
 576.821 -{
 576.822 -	AddCheatCode dlg;
 576.823 -	dlg.DoModal();
 576.824 -	refresh();
 576.825 -}
 576.826 -
 576.827 -void GBACheatList::OnAddCodebreaker()
 576.828 -{
 576.829 -	AddCBACode dlg;
 576.830 -	dlg.DoModal();
 576.831 -	refresh();
 576.832 -}
 576.833 -
 576.834 -void GBACheatList::OnAddGameshark()
 576.835 -{
 576.836 -	AddGSACode dlg;
 576.837 -	dlg.DoModal();
 576.838 -	refresh();
 576.839 -}
 576.840 -
 576.841 -void GBACheatList::OnEnable()
 576.842 -{
 576.843 -	int mark  = m_list.GetSelectionMark();
 576.844 -	int count = m_list.GetItemCount();
 576.845 -
 576.846 -	if (mark != -1)
 576.847 -	{
 576.848 -		LVITEM item;
 576.849 -		for (int i = 0; i < count; i++)
 576.850 -		{
 576.851 -			memset(&item, 0, sizeof(item));
 576.852 -			item.mask      = LVIF_PARAM|LVIF_STATE;
 576.853 -			item.stateMask = LVIS_SELECTED;
 576.854 -			item.iItem     = i;
 576.855 -			if (m_list.GetItem(&item))
 576.856 -			{
 576.857 -				if (item.state & LVIS_SELECTED)
 576.858 -				{
 576.859 -					if (cheatsList[item.lParam].enabled)
 576.860 -						cheatsDisable(item.lParam);
 576.861 -					else
 576.862 -						cheatsEnable(item.lParam);
 576.863 -				}
 576.864 -			}
 576.865 -		}
 576.866 -		refresh();
 576.867 -	}
 576.868 -}
 576.869 -
 576.870 -void GBACheatList::OnRemove()
 576.871 -{
 576.872 -	int mark  = m_list.GetSelectionMark();
 576.873 -	int count = m_list.GetItemCount();
 576.874 -
 576.875 -	if (mark != -1)
 576.876 -	{
 576.877 -		for (int i = count - 1; i >= 0; i--)
 576.878 -		{
 576.879 -			LVITEM item;
 576.880 -			memset(&item, 0, sizeof(item));
 576.881 -			item.mask      = LVIF_PARAM|LVIF_STATE;
 576.882 -			item.iItem     = i;
 576.883 -			item.stateMask = LVIS_SELECTED;
 576.884 -			if (m_list.GetItem(&item))
 576.885 -			{
 576.886 -				if (item.state & LVIS_SELECTED)
 576.887 -				{
 576.888 -					cheatsDelete(item.lParam, restoreValues);
 576.889 -				}
 576.890 -			}
 576.891 -		}
 576.892 -		refresh();
 576.893 -	}
 576.894 -}
 576.895 -
 576.896 -void GBACheatList::OnRemoveAll()
 576.897 -{
 576.898 -	cheatsDeleteAll(restoreValues);
 576.899 -	refresh();
 576.900 -}
 576.901 -
 576.902 -void GBACheatList::OnRestore()
 576.903 -{
 576.904 -	restoreValues = !restoreValues;
 576.905 -	regSetDwordValue("cheatsRestore", restoreValues);
 576.906 -}
 576.907 -
 576.908 -void GBACheatList::OnOk()
 576.909 -{
 576.910 -	EndDialog(TRUE);
 576.911 -}
 576.912 -
 576.913 -void GBACheatList::OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 576.914 -{
 576.915 -	if (m_list.GetSelectionMark() != -1)
 576.916 -	{
 576.917 -		GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
 576.918 -		GetDlgItem(IDC_ENABLE)->EnableWindow(TRUE);
 576.919 -	}
 576.920 -	else
 576.921 -	{
 576.922 -		GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
 576.923 -		GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE);
 576.924 -	}
 576.925 -
 576.926 -	if (!duringRefresh)
 576.927 -	{
 576.928 -		LPNMLISTVIEW l = (LPNMLISTVIEW)pNMHDR;
 576.929 -		if (l->uChanged & LVIF_STATE)
 576.930 -		{
 576.931 -			if (((l->uOldState & LVIS_STATEIMAGEMASK)>>12) !=
 576.932 -			    (((l->uNewState & LVIS_STATEIMAGEMASK)>>12)))
 576.933 -			{
 576.934 -				if (m_list.GetCheck(l->iItem))
 576.935 -					cheatsEnable(l->lParam);
 576.936 -				else
 576.937 -					cheatsDisable(l->lParam);
 576.938 -				refresh();
 576.939 -			}
 576.940 -		}
 576.941 -	}
 576.942 -
 576.943 -	*pResult = 0;
 576.944 -}
 576.945 -
 576.946 -BOOL GBACheatList::OnInitDialog()
 576.947 -{
 576.948 -	CDialog::OnInitDialog();
 576.949 -
 576.950 -	CString temp = winResLoadString(IDS_CODE);
 576.951 -	m_list.InsertColumn(0, temp, LVCFMT_LEFT, 170, 0);
 576.952 -	temp = winResLoadString(IDS_DESCRIPTION);
 576.953 -	m_list.InsertColumn(1, temp, LVCFMT_LEFT, 150, 1);
 576.954 -	temp = winResLoadString(IDS_STATUS);
 576.955 -	m_list.InsertColumn(2, temp, LVCFMT_LEFT, 80, 1);
 576.956 -
 576.957 -	m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)),
 576.958 -	               TRUE);
 576.959 -
 576.960 -	m_list.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
 576.961 -
 576.962 -	duringRefresh = false;
 576.963 -
 576.964 -	restoreValues = regQueryDwordValue("cheatsRestore", 0) ?
 576.965 -	                true : false;
 576.966 -
 576.967 -	m_restore.SetCheck(restoreValues);
 576.968 -
 576.969 -	refresh();
 576.970 -	GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
 576.971 -	GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE);
 576.972 -	CenterWindow();
 576.973 -
 576.974 -	return TRUE; // return TRUE unless you set the focus to a control
 576.975 -	             // EXCEPTION: OCX Property Pages should return FALSE
 576.976 -}
 576.977 -
 576.978 -void GBACheatList::refresh()
 576.979 -{
 576.980 -	duringRefresh = true;
 576.981 -	m_list.DeleteAllItems();
 576.982 -
 576.983 -	CString buffer;
 576.984 -
 576.985 -	for (int i = 0; i < cheatsNumber; i++)
 576.986 -	{
 576.987 -		LVITEM item;
 576.988 -
 576.989 -		item.mask      = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
 576.990 -		item.iItem     = i;
 576.991 -		item.iSubItem  = 0;
 576.992 -		item.lParam    = i;
 576.993 -		item.state     = 0;
 576.994 -		item.stateMask = 0;
 576.995 -		item.pszText   = cheatsList[i].codestring;
 576.996 -		m_list.InsertItem(&item);
 576.997 -
 576.998 -		m_list.SetCheck(i, (cheatsList[i].enabled) ? TRUE : FALSE);
 576.999 -
576.1000 -		m_list.SetItemText(i, 1, cheatsList[i].desc);
576.1001 -
576.1002 -		buffer = (cheatsList[i].enabled) ? 'E' : 'D';
576.1003 -		m_list.SetItemText(i, 2, buffer);
576.1004 -	}
576.1005 -	duringRefresh = false;
576.1006 -}
576.1007 -
576.1008 -/////////////////////////////////////////////////////////////////////////////
576.1009 -// AddGSACode dialog
576.1010 -
576.1011 -AddGSACode::AddGSACode(CWnd*pParent /*=NULL*/)
576.1012 -	: CDialog(AddGSACode::IDD, pParent)
576.1013 -{
576.1014 -	//{{AFX_DATA_INIT(AddGSACode)
576.1015 -	// NOTE: the ClassWizard will add member initialization here
576.1016 -	//}}AFX_DATA_INIT
576.1017 -}
576.1018 -
576.1019 -void AddGSACode::DoDataExchange(CDataExchange*pDX)
576.1020 -{
576.1021 -	CDialog::DoDataExchange(pDX);
576.1022 -	//{{AFX_DATA_MAP(AddGSACode)
576.1023 -	DDX_Control(pDX, IDC_DESC, m_desc);
576.1024 -	DDX_Control(pDX, IDC_CODE, m_code);
576.1025 -	//}}AFX_DATA_MAP
576.1026 -}
576.1027 -
576.1028 -BEGIN_MESSAGE_MAP(AddGSACode, CDialog)
576.1029 -//{{AFX_MSG_MAP(AddGSACode)
576.1030 -ON_BN_CLICKED(ID_OK, OnOk)
576.1031 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
576.1032 -//}}AFX_MSG_MAP
576.1033 -END_MESSAGE_MAP()
576.1034 -
576.1035 -/////////////////////////////////////////////////////////////////////////////
576.1036 -// AddGSACode message handlers
576.1037 -
576.1038 -void AddGSACode::OnOk()
576.1039 -{
576.1040 -	CString desc;
576.1041 -	CString buffer;
576.1042 -	CString part1;
576.1043 -	CString code;
576.1044 -	CString token;
576.1045 -
576.1046 -	m_code.GetWindowText(buffer);
576.1047 -	m_desc.GetWindowText(desc);
576.1048 -
576.1049 -	StringTokenizer st(buffer, " \t\n\r");
576.1050 -	part1.Empty();
576.1051 -	const char *t = st.next();
576.1052 -	while (t)
576.1053 -	{
576.1054 -		token = t;
576.1055 -		token.MakeUpper();
576.1056 -		if (token.GetLength() == 16)
576.1057 -			cheatsAddGSACode(token, desc, false);
576.1058 -		else if (token.GetLength() == 12)
576.1059 -		{
576.1060 -			code  = token.Left(8);
576.1061 -			code += " ";
576.1062 -			code += token.Right(4);
576.1063 -			cheatsAddCBACode(code, desc);
576.1064 -		}
576.1065 -		else if (part1.IsEmpty())
576.1066 -			part1 = token;
576.1067 -		else
576.1068 -		{
576.1069 -			if (token.GetLength() == 4)
576.1070 -			{
576.1071 -				code  = part1;
576.1072 -				code += " ";
576.1073 -				code += token;
576.1074 -				cheatsAddCBACode(code, desc);
576.1075 -			}
576.1076 -			else
576.1077 -			{
576.1078 -				code = part1 + token;
576.1079 -				cheatsAddGSACode(code, desc, true);
576.1080 -			}
576.1081 -			part1.Empty();
576.1082 -		}
576.1083 -
576.1084 -		t = st.next();
576.1085 -	}
576.1086 -	EndDialog(TRUE);
576.1087 -}
576.1088 -
576.1089 -void AddGSACode::OnCancel()
576.1090 -{
576.1091 -	EndDialog(FALSE);
576.1092 -}
576.1093 -
576.1094 -BOOL AddGSACode::OnInitDialog()
576.1095 -{
576.1096 -	CDialog::OnInitDialog();
576.1097 -
576.1098 -	m_code.LimitText(1024);
576.1099 -	m_desc.LimitText(32);
576.1100 -	CString title = winResLoadString(IDS_ADD_GSA_CODE);
576.1101 -	SetWindowText(title);
576.1102 -	CenterWindow();
576.1103 -
576.1104 -	return TRUE; // return TRUE unless you set the focus to a control
576.1105 -	             // EXCEPTION: OCX Property Pages should return FALSE
576.1106 -}
576.1107 -
576.1108 -/////////////////////////////////////////////////////////////////////////////
576.1109 -// AddCBACode dialog
576.1110 -
576.1111 -AddCBACode::AddCBACode(CWnd*pParent /*=NULL*/)
576.1112 -	: CDialog(AddCBACode::IDD, pParent)
576.1113 -{
576.1114 -	//{{AFX_DATA_INIT(AddCBACode)
576.1115 -	// NOTE: the ClassWizard will add member initialization here
576.1116 -	//}}AFX_DATA_INIT
576.1117 -}
576.1118 -
576.1119 -void AddCBACode::DoDataExchange(CDataExchange*pDX)
576.1120 -{
576.1121 -	CDialog::DoDataExchange(pDX);
576.1122 -	//{{AFX_DATA_MAP(AddCBACode)
576.1123 -	DDX_Control(pDX, IDC_DESC, m_desc);
576.1124 -	DDX_Control(pDX, IDC_CODE, m_code);
576.1125 -	//}}AFX_DATA_MAP
576.1126 -}
576.1127 -
576.1128 -BEGIN_MESSAGE_MAP(AddCBACode, CDialog)
576.1129 -//{{AFX_MSG_MAP(AddCBACode)
576.1130 -ON_BN_CLICKED(ID_OK, OnOk)
576.1131 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
576.1132 -//}}AFX_MSG_MAP
576.1133 -END_MESSAGE_MAP()
576.1134 -
576.1135 -/////////////////////////////////////////////////////////////////////////////
576.1136 -// AddCBACode message handlers
576.1137 -
576.1138 -void AddCBACode::OnOk()
576.1139 -{
576.1140 -	CString desc;
576.1141 -	CString buffer;
576.1142 -	CString part1;
576.1143 -	CString code;
576.1144 -	CString token;
576.1145 -
576.1146 -	m_code.GetWindowText(buffer);
576.1147 -	m_desc.GetWindowText(desc);
576.1148 -
576.1149 -	StringTokenizer st(buffer, " \t\n\r");
576.1150 -	part1.Empty();
576.1151 -	const char *t = st.next();
576.1152 -	while (t)
576.1153 -	{
576.1154 -		token = t;
576.1155 -		token.MakeUpper();
576.1156 -		if (token.GetLength() == 16)
576.1157 -			cheatsAddGSACode(token, desc, false);
576.1158 -		else if (token.GetLength() == 12)
576.1159 -		{
576.1160 -			code  = token.Left(8);
576.1161 -			code += " ";
576.1162 -			code += token.Right(4);
576.1163 -			cheatsAddCBACode(code, desc);
576.1164 -		}
576.1165 -		else if (part1.IsEmpty())
576.1166 -			part1 = token;
576.1167 -		else
576.1168 -		{
576.1169 -			if (token.GetLength() == 4)
576.1170 -			{
576.1171 -				code  = part1;
576.1172 -				code += " ";
576.1173 -				code += token;
576.1174 -				cheatsAddCBACode(code, desc);
576.1175 -			}
576.1176 -			else
576.1177 -			{
576.1178 -				code = part1 + token;
576.1179 -				cheatsAddGSACode(code, desc, true);
576.1180 -			}
576.1181 -			part1.Empty();
576.1182 -		}
576.1183 -
576.1184 -		t = st.next();
576.1185 -	}
576.1186 -	EndDialog(TRUE);
576.1187 -}
576.1188 -
576.1189 -void AddCBACode::OnCancel()
576.1190 -{
576.1191 -	EndDialog(FALSE);
576.1192 -}
576.1193 -
576.1194 -BOOL AddCBACode::OnInitDialog()
576.1195 -{
576.1196 -	CDialog::OnInitDialog();
576.1197 -
576.1198 -	m_code.LimitText(1024);
576.1199 -	m_desc.LimitText(32);
576.1200 -	CString title = winResLoadString(IDS_ADD_CBA_CODE);
576.1201 -	SetWindowText(title);
576.1202 -	CenterWindow();
576.1203 -
576.1204 -	return TRUE; // return TRUE unless you set the focus to a control
576.1205 -	             // EXCEPTION: OCX Property Pages should return FALSE
576.1206 -}
576.1207 -
576.1208 -/////////////////////////////////////////////////////////////////////////////
576.1209 -// AddCheatCode dialog
576.1210 -
576.1211 -AddCheatCode::AddCheatCode(CWnd*pParent /*=NULL*/)
576.1212 -	: CDialog(AddCheatCode::IDD, pParent)
576.1213 -{
576.1214 -	//{{AFX_DATA_INIT(AddCheatCode)
576.1215 -	// NOTE: the ClassWizard will add member initialization here
576.1216 -	//}}AFX_DATA_INIT
576.1217 -}
576.1218 -
576.1219 -void AddCheatCode::DoDataExchange(CDataExchange*pDX)
576.1220 -{
576.1221 -	CDialog::DoDataExchange(pDX);
576.1222 -	//{{AFX_DATA_MAP(AddCheatCode)
576.1223 -	DDX_Control(pDX, IDC_DESC, m_desc);
576.1224 -	DDX_Control(pDX, IDC_CODE, m_code);
576.1225 -	//}}AFX_DATA_MAP
576.1226 -}
576.1227 -
576.1228 -BEGIN_MESSAGE_MAP(AddCheatCode, CDialog)
576.1229 -//{{AFX_MSG_MAP(AddCheatCode)
576.1230 -ON_BN_CLICKED(ID_OK, OnOk)
576.1231 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
576.1232 -//}}AFX_MSG_MAP
576.1233 -END_MESSAGE_MAP()
576.1234 -
576.1235 -/////////////////////////////////////////////////////////////////////////////
576.1236 -// AddCheatCode message handlers
576.1237 -
576.1238 -void AddCheatCode::OnOk()
576.1239 -{
576.1240 -	CString desc;
576.1241 -	CString buffer;
576.1242 -	CString token;
576.1243 -
576.1244 -	m_code.GetWindowText(buffer);
576.1245 -	m_desc.GetWindowText(desc);
576.1246 -
576.1247 -	StringTokenizer st(buffer, " \t\n\r");
576.1248 -	const char *    t = st.next();
576.1249 -	while (t)
576.1250 -	{
576.1251 -		token = t;
576.1252 -		token.MakeUpper();
576.1253 -		cheatsAddCheatCode(token, desc);
576.1254 -		t = st.next();
576.1255 -	}
576.1256 -	EndDialog(TRUE);
576.1257 -}
576.1258 -
576.1259 -void AddCheatCode::OnCancel()
576.1260 -{
576.1261 -	EndDialog(FALSE);
576.1262 -}
576.1263 -
576.1264 -BOOL AddCheatCode::OnInitDialog()
576.1265 -{
576.1266 -	CDialog::OnInitDialog();
576.1267 -
576.1268 -	m_code.LimitText(1024);
576.1269 -	m_desc.LimitText(32);
576.1270 -	CString title = winResLoadString(IDS_ADD_CHEAT_CODE);
576.1271 -	SetWindowText(title);
576.1272 -	CenterWindow();
576.1273 -
576.1274 -	return TRUE; // return TRUE unless you set the focus to a control
576.1275 -	             // EXCEPTION: OCX Property Pages should return FALSE
576.1276 -}
576.1277 -
576.1278 -void GBACheatSearch::OnBnClickedCheatrefreshbutton()
576.1279 -{
576.1280 -	addChanges(false);
576.1281 -}
576.1282 -
   577.1 --- a/src/win32/GBACheatsDlg.h	Sat Mar 03 10:54:39 2012 -0600
   577.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   577.3 @@ -1,264 +0,0 @@
   577.4 -#if !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_)
   577.5 -#define AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_
   577.6 -
   577.7 -#if _MSC_VER > 1000
   577.8 -#pragma once
   577.9 -#endif // _MSC_VER > 1000
  577.10 -// GBACheatsDlg.h : header file
  577.11 -//
  577.12 -
  577.13 -/////////////////////////////////////////////////////////////////////////////
  577.14 -// GBACheatSearch dialog
  577.15 -
  577.16 -struct WinCheatsData
  577.17 -{
  577.18 -	u32  addr;
  577.19 -	char address[9];
  577.20 -	char oldValue[12];
  577.21 -	char newValue[12];
  577.22 -};
  577.23 -
  577.24 -class GBACheatSearch : public CDialog
  577.25 -{
  577.26 -	// Construction
  577.27 -public:
  577.28 -	afx_msg void OnSizeType(UINT id);
  577.29 -	afx_msg void OnNumberType(UINT id);
  577.30 -	afx_msg void OnSearchType(UINT id);
  577.31 -	afx_msg void OnValueType(UINT id);
  577.32 -	void addChange(int index, u32 address, u32 oldValue, u32 newValue);
  577.33 -	GBACheatSearch(CWnd*pParent = NULL);  // standard constructor
  577.34 -	~GBACheatSearch();
  577.35 -
  577.36 -	// Dialog Data
  577.37 -	//{{AFX_DATA(GBACheatSearch)
  577.38 -	enum { IDD = IDD_CHEATS };
  577.39 -	CEdit     m_value;
  577.40 -	CListCtrl m_list;
  577.41 -	int       valueType;
  577.42 -	int       sizeType;
  577.43 -	int       searchType;
  577.44 -	int       numberType;
  577.45 -	BOOL      updateValues;
  577.46 -	//}}AFX_DATA
  577.47 -
  577.48 -	// Overrides
  577.49 -	// ClassWizard generated virtual function overrides
  577.50 -	//{{AFX_VIRTUAL(GBACheatSearch)
  577.51 -protected:
  577.52 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  577.53 -	//}}AFX_VIRTUAL
  577.54 -
  577.55 -	// Implementation
  577.56 -protected:
  577.57 -	// Generated message map functions
  577.58 -	//{{AFX_MSG(GBACheatSearch)
  577.59 -	afx_msg void OnOk();
  577.60 -	afx_msg void OnStart();
  577.61 -	afx_msg void OnSearch();
  577.62 -	afx_msg void OnAddCheat();
  577.63 -	afx_msg void OnUpdate();
  577.64 -	afx_msg void OnGetdispinfoCheatList(NMHDR*pNMHDR, LRESULT*pResult);
  577.65 -	afx_msg void OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult);
  577.66 -	virtual BOOL OnInitDialog();
  577.67 -	//}}AFX_MSG
  577.68 -	DECLARE_MESSAGE_MAP()
  577.69 -private:
  577.70 -	void addChanges(bool showMsgs);
  577.71 -	WinCheatsData *data;
  577.72 -public:
  577.73 -	afx_msg void OnClose();
  577.74 -	afx_msg void OnBnClickedCheatrefreshbutton();
  577.75 -};
  577.76 -
  577.77 -/////////////////////////////////////////////////////////////////////////////
  577.78 -// AddCheat dialog
  577.79 -
  577.80 -class AddCheat : public CDialog
  577.81 -{
  577.82 -	// Construction
  577.83 -public:
  577.84 -	bool addCheat();
  577.85 -	afx_msg void OnSizeType(UINT id);
  577.86 -	afx_msg void OnNumberType(UINT id);
  577.87 -	AddCheat(u32 address, CWnd*pParent = NULL);  // standard constructor
  577.88 -
  577.89 -	// Dialog Data
  577.90 -	//{{AFX_DATA(AddCheat)
  577.91 -	enum { IDD = IDD_ADD_CHEAT };
  577.92 -	CEdit m_value;
  577.93 -	CEdit m_desc;
  577.94 -	CEdit m_address;
  577.95 -	int   sizeType;
  577.96 -	int   numberType;
  577.97 -	//}}AFX_DATA
  577.98 -
  577.99 -	// Overrides
 577.100 -	// ClassWizard generated virtual function overrides
 577.101 -	//{{AFX_VIRTUAL(AddCheat)
 577.102 -protected:
 577.103 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 577.104 -	//}}AFX_VIRTUAL
 577.105 -
 577.106 -	// Implementation
 577.107 -protected:
 577.108 -	u32   address;
 577.109 -
 577.110 -	// Generated message map functions
 577.111 -	//{{AFX_MSG(AddCheat)
 577.112 -	afx_msg void OnOk();
 577.113 -	afx_msg void OnCancel();
 577.114 -	virtual BOOL OnInitDialog();
 577.115 -	//}}AFX_MSG
 577.116 -	DECLARE_MESSAGE_MAP()
 577.117 -};
 577.118 -/////////////////////////////////////////////////////////////////////////////
 577.119 -// GBACheatList dialog
 577.120 -
 577.121 -class GBACheatList : public CDialog
 577.122 -{
 577.123 -	// Construction
 577.124 -public:
 577.125 -	void refresh();
 577.126 -	GBACheatList(CWnd*pParent = NULL);  // standard constructor
 577.127 -
 577.128 -	// Dialog Data
 577.129 -	//{{AFX_DATA(GBACheatList)
 577.130 -	enum { IDD = IDD_CHEAT_LIST };
 577.131 -	CButton   m_restore;
 577.132 -	CListCtrl m_list;
 577.133 -	//}}AFX_DATA
 577.134 -
 577.135 -	// Overrides
 577.136 -	// ClassWizard generated virtual function overrides
 577.137 -	//{{AFX_VIRTUAL(GBACheatList)
 577.138 -protected:
 577.139 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 577.140 -	//}}AFX_VIRTUAL
 577.141 -
 577.142 -	// Implementation
 577.143 -protected:
 577.144 -	bool duringRefresh;
 577.145 -	bool restoreValues;
 577.146 -
 577.147 -	// Generated message map functions
 577.148 -	//{{AFX_MSG(GBACheatList)
 577.149 -	afx_msg void OnAddCheat();
 577.150 -	afx_msg void OnAddCode();
 577.151 -	afx_msg void OnAddCodebreaker();
 577.152 -	afx_msg void OnAddGameshark();
 577.153 -	afx_msg void OnEnable();
 577.154 -	afx_msg void OnRemove();
 577.155 -	afx_msg void OnRemoveAll();
 577.156 -	afx_msg void OnRestore();
 577.157 -	afx_msg void OnOk();
 577.158 -	afx_msg void OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult);
 577.159 -	virtual BOOL OnInitDialog();
 577.160 -	//}}AFX_MSG
 577.161 -	DECLARE_MESSAGE_MAP()
 577.162 -};
 577.163 -/////////////////////////////////////////////////////////////////////////////
 577.164 -// AddGSACode dialog
 577.165 -
 577.166 -class AddGSACode : public CDialog
 577.167 -{
 577.168 -	// Construction
 577.169 -public:
 577.170 -	AddGSACode(CWnd*pParent = NULL);  // standard constructor
 577.171 -
 577.172 -	// Dialog Data
 577.173 -	//{{AFX_DATA(AddGSACode)
 577.174 -	enum { IDD = IDD_ADD_CHEAT_DLG };
 577.175 -	CEdit m_desc;
 577.176 -	CEdit m_code;
 577.177 -	//}}AFX_DATA
 577.178 -
 577.179 -	// Overrides
 577.180 -	// ClassWizard generated virtual function overrides
 577.181 -	//{{AFX_VIRTUAL(AddGSACode)
 577.182 -protected:
 577.183 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 577.184 -	//}}AFX_VIRTUAL
 577.185 -
 577.186 -	// Implementation
 577.187 -protected:
 577.188 -	// Generated message map functions
 577.189 -	//{{AFX_MSG(AddGSACode)
 577.190 -	afx_msg void OnOk();
 577.191 -	afx_msg void OnCancel();
 577.192 -	virtual BOOL OnInitDialog();
 577.193 -	//}}AFX_MSG
 577.194 -	DECLARE_MESSAGE_MAP()
 577.195 -};
 577.196 -
 577.197 -/////////////////////////////////////////////////////////////////////////////
 577.198 -// AddCBACode dialog
 577.199 -
 577.200 -class AddCBACode : public CDialog
 577.201 -{
 577.202 -	// Construction
 577.203 -public:
 577.204 -	AddCBACode(CWnd*pParent = NULL);  // standard constructor
 577.205 -
 577.206 -	// Dialog Data
 577.207 -	//{{AFX_DATA(AddCBACode)
 577.208 -	enum { IDD = IDD_ADD_CHEAT_DLG };
 577.209 -	CEdit m_desc;
 577.210 -	CEdit m_code;
 577.211 -	//}}AFX_DATA
 577.212 -
 577.213 -	// Overrides
 577.214 -	// ClassWizard generated virtual function overrides
 577.215 -	//{{AFX_VIRTUAL(AddCBACode)
 577.216 -protected:
 577.217 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 577.218 -	//}}AFX_VIRTUAL
 577.219 -
 577.220 -	// Implementation
 577.221 -protected:
 577.222 -	// Generated message map functions
 577.223 -	//{{AFX_MSG(AddCBACode)
 577.224 -	afx_msg void OnOk();
 577.225 -	afx_msg void OnCancel();
 577.226 -	virtual BOOL OnInitDialog();
 577.227 -	//}}AFX_MSG
 577.228 -	DECLARE_MESSAGE_MAP()
 577.229 -};
 577.230 -
 577.231 -/////////////////////////////////////////////////////////////////////////////
 577.232 -// AddCheatCode dialog
 577.233 -
 577.234 -class AddCheatCode : public CDialog
 577.235 -{
 577.236 -	// Construction
 577.237 -public:
 577.238 -	AddCheatCode(CWnd*pParent = NULL);  // standard constructor
 577.239 -
 577.240 -	// Dialog Data
 577.241 -	//{{AFX_DATA(AddCheatCode)
 577.242 -	enum { IDD = IDD_ADD_CHEAT_DLG };
 577.243 -	CEdit m_desc;
 577.244 -	CEdit m_code;
 577.245 -	//}}AFX_DATA
 577.246 -
 577.247 -	// Overrides
 577.248 -	// ClassWizard generated virtual function overrides
 577.249 -	//{{AFX_VIRTUAL(AddCheatCode)
 577.250 -protected:
 577.251 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 577.252 -	//}}AFX_VIRTUAL
 577.253 -
 577.254 -	// Implementation
 577.255 -protected:
 577.256 -	// Generated message map functions
 577.257 -	//{{AFX_MSG(AddCheatCode)
 577.258 -	afx_msg void OnOk();
 577.259 -	afx_msg void OnCancel();
 577.260 -	virtual BOOL OnInitDialog();
 577.261 -	//}}AFX_MSG
 577.262 -	DECLARE_MESSAGE_MAP()
 577.263 -};
 577.264 -//{{AFX_INSERT_LOCATION}}
 577.265 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 577.266 -
 577.267 -#endif // !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_)
   578.1 --- a/src/win32/GBCheatsDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   578.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   578.3 @@ -1,1140 +0,0 @@
   578.4 -// GBCheats.cpp : implementation file
   578.5 -//
   578.6 -
   578.7 -#include "stdafx.h"
   578.8 -#include "resource.h"
   578.9 -#include "GBCheatsDlg.h"
  578.10 -#include "Reg.h"
  578.11 -#include "StringTokenizer.h"
  578.12 -#include "WinResUtil.h"
  578.13 -#include "Sound.h"
  578.14 -#include "VBA.h"
  578.15 -
  578.16 -#include "../common/CheatSearch.h"
  578.17 -#include "../gb/gbCheats.h"
  578.18 -#include "../gb/gbGlobals.h"
  578.19 -
  578.20 -static inline bool winGbCheatAddVerifyGs(const char *code, const char *desc)
  578.21 -{
  578.22 -	gbAddGsCheat(code, desc);
  578.23 -	return true;
  578.24 -}
  578.25 -
  578.26 -static inline bool winGbCheatAddVerifyGg(const char *code, const char *desc)
  578.27 -{
  578.28 -	gbAddGgCheat(code, desc);
  578.29 -	return true;
  578.30 -}
  578.31 -
  578.32 -////////////////////////////////
  578.33 -
  578.34 -bool winGbCheatReaddress()
  578.35 -{
  578.36 -	if (cheatSearchData.count != 3)
  578.37 -		return false;
  578.38 -
  578.39 -	CheatSearchBlock *block = &cheatSearchData.blocks[0];
  578.40 -	if (gbRamSize > 0)
  578.41 -	{
  578.42 -		if (gbRam)
  578.43 -			block->data = gbRam;
  578.44 -		else
  578.45 -			block->data = &gbMemory[0xa000];
  578.46 -		block->offset = 0xa000;
  578.47 -		block->size  = gbRamSize;
  578.48 -		cheatSearchSetSavedAndBits(block);
  578.49 -	}
  578.50 -	else
  578.51 -	{
  578.52 -		cheatSearchZeroBlock(&cheatSearchData.blocks[0]);
  578.53 -	}
  578.54 -
  578.55 -	block = &cheatSearchData.blocks[1];
  578.56 -	if (gbCgbMode)
  578.57 -	{
  578.58 -		block->data   = &gbMemory[0xc000];
  578.59 -		block->offset = 0xc000;
  578.60 -		block->size   = 0x1000;
  578.61 -		cheatSearchSetSavedAndBits(block);
  578.62 -
  578.63 -		block         = &cheatSearchData.blocks[2];
  578.64 -		block->data   = gbWram;
  578.65 -		block->offset = 0xd000;
  578.66 -		block->size   = 0x8000;
  578.67 -		cheatSearchSetSavedAndBits(block);
  578.68 -	}
  578.69 -	else
  578.70 -	{
  578.71 -		block->data   = &gbMemory[0xc000];
  578.72 -		block->offset = 0xc000;
  578.73 -		block->size   = 0x2000;
  578.74 -		cheatSearchSetSavedAndBits(block);
  578.75 -
  578.76 -		cheatSearchZeroBlock(&cheatSearchData.blocks[2]);
  578.77 -	}
  578.78 -
  578.79 -	cheatSearchData.count = 3;
  578.80 -	return true;
  578.81 -}
  578.82 -
  578.83 -/////////////////////////////////////////////////////////////////////////////
  578.84 -// GBCheatSearch dialog
  578.85 -
  578.86 -GBCheatSearch::GBCheatSearch(CWnd*pParent /*=NULL*/)
  578.87 -	: CDialog(GBCheatSearch::IDD, pParent)
  578.88 -{
  578.89 -	//{{AFX_DATA_INIT(GBCheatSearch)
  578.90 -	searchType   = -1;
  578.91 -	numberType   = -1;
  578.92 -	sizeType     = -1;
  578.93 -	updateValues = FALSE;
  578.94 -	valueType    = -1;
  578.95 -	//}}AFX_DATA_INIT
  578.96 -	data = NULL;
  578.97 -}
  578.98 -
  578.99 -GBCheatSearch::~GBCheatSearch()
 578.100 -{
 578.101 -	if (data)
 578.102 -		free(data);
 578.103 -}
 578.104 -
 578.105 -void GBCheatSearch::DoDataExchange(CDataExchange*pDX)
 578.106 -{
 578.107 -	CDialog::DoDataExchange(pDX);
 578.108 -	//{{AFX_DATA_MAP(GBCheatSearch)
 578.109 -	DDX_Control(pDX, IDC_VALUE, m_value);
 578.110 -	DDX_Control(pDX, IDC_CHEAT_LIST, m_list);
 578.111 -	DDX_Radio(pDX, IDC_EQ, searchType);
 578.112 -	DDX_Radio(pDX, IDC_SIGNED, numberType);
 578.113 -	DDX_Radio(pDX, IDC_SIZE_8, sizeType);
 578.114 -	DDX_Check(pDX, IDC_UPDATE, updateValues);
 578.115 -	DDX_Radio(pDX, IDC_OLD_VALUE, valueType);
 578.116 -	//}}AFX_DATA_MAP
 578.117 -}
 578.118 -
 578.119 -BEGIN_MESSAGE_MAP(GBCheatSearch, CDialog)
 578.120 -//{{AFX_MSG_MAP(GBCheatSearch)
 578.121 -ON_BN_CLICKED(ID_OK, OnOk)
 578.122 -ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat)
 578.123 -ON_BN_CLICKED(IDC_SEARCH, OnSearch)
 578.124 -ON_BN_CLICKED(IDC_START, OnStart)
 578.125 -ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
 578.126 -ON_NOTIFY(LVN_GETDISPINFO, IDC_CHEAT_LIST, OnGetdispinfoCheatList)
 578.127 -ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
 578.128 -ON_CONTROL_RANGE(BN_CLICKED, IDC_OLD_VALUE, IDC_SPECIFIC_VALUE, OnValueType)
 578.129 -ON_CONTROL_RANGE(BN_CLICKED, IDC_EQ, IDC_GE, OnSearchType)
 578.130 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType)
 578.131 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType)
 578.132 -//}}AFX_MSG_MAP
 578.133 -ON_WM_CLOSE()
 578.134 -ON_BN_CLICKED(IDC_CHEATREFRESHBUTTON, OnBnClickedCheatrefreshbutton)
 578.135 -END_MESSAGE_MAP()
 578.136 -
 578.137 -/////////////////////////////////////////////////////////////////////////////
 578.138 -// GBCheatSearch message handlers
 578.139 -
 578.140 -void GBCheatSearch::OnOk()
 578.141 -{
 578.142 -	if (data)
 578.143 -		free(data);
 578.144 -	data = NULL;
 578.145 -
 578.146 -	if (theApp.modelessCheatDialogIsOpen)
 578.147 -	{
 578.148 -		theApp.modelessCheatDialogIsOpen = false;
 578.149 -		DestroyWindow();
 578.150 -	}
 578.151 -	else
 578.152 -	{
 578.153 -		EndDialog(TRUE);
 578.154 -	}
 578.155 -}
 578.156 -
 578.157 -void GBCheatSearch::OnClose()
 578.158 -{
 578.159 -	CDialog::OnClose();
 578.160 -	if (theApp.modelessCheatDialogIsOpen)
 578.161 -	{
 578.162 -		theApp.modelessCheatDialogIsOpen = false;
 578.163 -		DestroyWindow();
 578.164 -	}
 578.165 -	else
 578.166 -	{
 578.167 -		EndDialog(FALSE);
 578.168 -	}
 578.169 -}
 578.170 -
 578.171 -void GBCheatSearch::OnBnClickedCheatrefreshbutton()
 578.172 -{
 578.173 -	addChanges(false);
 578.174 -}
 578.175 -
 578.176 -void GBCheatSearch::OnAddCheat()
 578.177 -{
 578.178 -	int mark = m_list.GetSelectionMark();
 578.179 -
 578.180 -	if (mark != -1)
 578.181 -	{
 578.182 -		LVITEM item;
 578.183 -		memset(&item, 0, sizeof(item));
 578.184 -		item.mask  = LVIF_PARAM;
 578.185 -		item.iItem = mark;
 578.186 -		if (m_list.GetItem(&item))
 578.187 -		{
 578.188 -			AddGBCheat dlg((u32)item.lParam);
 578.189 -			dlg.DoModal();
 578.190 -		}
 578.191 -	}
 578.192 -}
 578.193 -
 578.194 -void GBCheatSearch::OnSearch()
 578.195 -{
 578.196 -	CString buffer;
 578.197 -	if (valueType == 0)
 578.198 -		cheatSearch(&cheatSearchData,
 578.199 -		            searchType,
 578.200 -		            sizeType,
 578.201 -		            numberType == 0);
 578.202 -	else
 578.203 -	{
 578.204 -		m_value.GetWindowText(buffer);
 578.205 -		if (buffer.IsEmpty())
 578.206 -		{
 578.207 -			systemMessage(IDS_NUMBER_CANNOT_BE_EMPTY, "Number cannot be empty");
 578.208 -			return;
 578.209 -		}
 578.210 -		int value = 0;
 578.211 -		switch (numberType)
 578.212 -		{
 578.213 -		case 0:
 578.214 -			sscanf(buffer, "%d", &value);
 578.215 -			break;
 578.216 -		case 1:
 578.217 -			sscanf(buffer, "%u", &value);
 578.218 -			break;
 578.219 -		default:
 578.220 -			sscanf(buffer, "%x", &value);
 578.221 -		}
 578.222 -		cheatSearchValue(&cheatSearchData,
 578.223 -		                 searchType,
 578.224 -		                 sizeType,
 578.225 -		                 numberType == 0,
 578.226 -		                 value);
 578.227 -	}
 578.228 -
 578.229 -	addChanges(true);
 578.230 -
 578.231 -	if (updateValues)
 578.232 -		cheatSearchUpdateValues(&cheatSearchData);
 578.233 -
 578.234 -	if (theApp.modelessCheatDialogIsOpen)
 578.235 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE);
 578.236 -
 578.237 -	if (0 == cheatSearchGetCount(&cheatSearchData, sizeType))
 578.238 -		OnStart();
 578.239 -}
 578.240 -
 578.241 -void GBCheatSearch::OnStart()
 578.242 -{
 578.243 -	if (cheatSearchData.count == 0)
 578.244 -	{
 578.245 -		CheatSearchBlock *block = &cheatSearchData.blocks[0];
 578.246 -		if (gbRamSize > 0)
 578.247 -		{
 578.248 -			if (gbRam)
 578.249 -				block->data = gbRam;
 578.250 -			else
 578.251 -				block->data = &gbMemory[0xa000];
 578.252 -			block->size  = gbRamSize;
 578.253 -			block->offset = 0xa000;
 578.254 -			block->saved = (u8 *)malloc(gbRamSize);
 578.255 -			block->bits  = (u8 *)malloc(gbRamSize >> 3);
 578.256 -		}
 578.257 -		else
 578.258 -		{
 578.259 -			cheatSearchZeroBlock(&cheatSearchData.blocks[0]);
 578.260 -		}
 578.261 -
 578.262 -		block = &cheatSearchData.blocks[1];
 578.263 -		if (gbCgbMode)
 578.264 -		{
 578.265 -			block->data   = &gbMemory[0xc000];
 578.266 -			block->size   = 0x1000;
 578.267 -			block->offset = 0xc000;
 578.268 -			block->saved  = (u8 *)malloc(0x1000);
 578.269 -			block->bits   = (u8 *)malloc(0x1000 >> 3);
 578.270 -
 578.271 -			block         = &cheatSearchData.blocks[2];
 578.272 -			block->data   = gbWram;
 578.273 -			block->size   = 0x8000;
 578.274 -			block->offset = 0xd000;
 578.275 -			block->saved  = (u8 *)malloc(0x8000);
 578.276 -			block->bits   = (u8 *)malloc(0x8000 >> 3);
 578.277 -		}
 578.278 -		else
 578.279 -		{
 578.280 -			block->data   = &gbMemory[0xc000];
 578.281 -			block->size   = 0x2000;
 578.282 -			block->offset = 0xc000;
 578.283 -			block->saved  = (u8 *)malloc(0x2000);
 578.284 -			block->bits   = (u8 *)malloc(0x2000 >> 3);
 578.285 -
 578.286 -			cheatSearchZeroBlock(&cheatSearchData.blocks[2]);
 578.287 -		}
 578.288 -
 578.289 -		cheatSearchData.count = 3;
 578.290 -	}
 578.291 -
 578.292 -	cheatSearchStart(&cheatSearchData);
 578.293 -	GetDlgItem(IDC_SEARCH)->EnableWindow(TRUE);
 578.294 -
 578.295 -	if (theApp.modelessCheatDialogIsOpen)
 578.296 -	{
 578.297 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE);
 578.298 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE);
 578.299 -	}
 578.300 -}
 578.301 -
 578.302 -void GBCheatSearch::OnUpdate()
 578.303 -{
 578.304 -	if (GetDlgItem(IDC_UPDATE)->SendMessage(BM_GETCHECK,
 578.305 -	                                        0,
 578.306 -	                                        0) & BST_CHECKED)
 578.307 -		updateValues = true;
 578.308 -	else
 578.309 -		updateValues = false;
 578.310 -	regSetDwordValue("gbCheatsUpdate", updateValues);
 578.311 -}
 578.312 -
 578.313 -BOOL GBCheatSearch::OnInitDialog()
 578.314 -{
 578.315 -	CDialog::OnInitDialog();
 578.316 -
 578.317 -	CString temp = winResLoadString(IDS_ADDRESS);
 578.318 -
 578.319 -	m_list.InsertColumn(0, temp, LVCFMT_CENTER, 125, 0);
 578.320 -
 578.321 -	temp = winResLoadString(IDS_OLD_VALUE);
 578.322 -	m_list.InsertColumn(1, temp, LVCFMT_CENTER, 125, 1);
 578.323 -
 578.324 -	temp = winResLoadString(IDS_NEW_VALUE);
 578.325 -	m_list.InsertColumn(2, temp, LVCFMT_CENTER, 125, 2);
 578.326 -
 578.327 -	m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)),
 578.328 -	               TRUE);
 578.329 -
 578.330 -	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
 578.331 -
 578.332 -	if (!cheatSearchData.count)
 578.333 -	{
 578.334 -		GetDlgItem(IDC_SEARCH)->EnableWindow(FALSE);
 578.335 -		GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(FALSE);
 578.336 -	}
 578.337 -
 578.338 -	valueType = regQueryDwordValue("gbCheatsValueType", 0);
 578.339 -	if (valueType < 0 || valueType > 1)
 578.340 -		valueType = 2;
 578.341 -
 578.342 -	searchType = regQueryDwordValue("gbCheatsSearchType",
 578.343 -	                                SEARCH_EQ);
 578.344 -	if (searchType < 0 || searchType > 5)
 578.345 -		searchType = 0;
 578.346 -
 578.347 -	numberType = regQueryDwordValue("gbCheatsNumberType", 2);
 578.348 -	if (numberType < 0 || numberType > 2)
 578.349 -		numberType = 2;
 578.350 -
 578.351 -	sizeType = regQueryDwordValue("gbCheatsSizeType", 0);
 578.352 -	if (sizeType < 0 || sizeType > 2)
 578.353 -		sizeType = 0;
 578.354 -
 578.355 -	updateValues = regQueryDwordValue("gbCheatsUpdate", 0) ?
 578.356 -	               true : false;
 578.357 -
 578.358 -	UpdateData(FALSE);
 578.359 -
 578.360 -	if (valueType == 0)
 578.361 -		m_value.EnableWindow(FALSE);
 578.362 -
 578.363 -	CenterWindow();
 578.364 -
 578.365 -	if (theApp.modelessCheatDialogIsOpen)
 578.366 -		GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE);
 578.367 -
 578.368 -	if (cheatSearchData.count)
 578.369 -	{
 578.370 -		addChanges(false);
 578.371 -		if (theApp.modelessCheatDialogIsOpen)
 578.372 -			GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData,
 578.373 -			                                                                     sizeType) == 0 ? FALSE : TRUE);
 578.374 -	}
 578.375 -	else
 578.376 -	{
 578.377 -		if (theApp.modelessCheatDialogIsOpen)
 578.378 -			GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE);
 578.379 -	}
 578.380 -
 578.381 -	return TRUE; // return TRUE unless you set the focus to a control
 578.382 -	             // EXCEPTION: OCX Property Pages should return FALSE
 578.383 -}
 578.384 -
 578.385 -void GBCheatSearch::OnGetdispinfoCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 578.386 -{
 578.387 -	LV_DISPINFO*info = (LV_DISPINFO *)pNMHDR;
 578.388 -	if (info->item.mask & LVIF_TEXT)
 578.389 -	{
 578.390 -		int index = info->item.iItem;
 578.391 -		int col   = info->item.iSubItem;
 578.392 -
 578.393 -		switch (col)
 578.394 -		{
 578.395 -		case 0:
 578.396 -			strcpy(info->item.pszText, data[index].address);
 578.397 -			break;
 578.398 -		case 1:
 578.399 -			strcpy(info->item.pszText, data[index].oldValue);
 578.400 -			break;
 578.401 -		case 2:
 578.402 -			strcpy(info->item.pszText, data[index].newValue);
 578.403 -			break;
 578.404 -		}
 578.405 -	}
 578.406 -	*pResult = TRUE;
 578.407 -}
 578.408 -
 578.409 -void GBCheatSearch::OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 578.410 -{
 578.411 -	GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(m_list.GetSelectionMark() != -1);
 578.412 -}
 578.413 -
 578.414 -int GBCheatSearch::getBank(u16 addr, int j)
 578.415 -{
 578.416 -	switch (addr >> 12)
 578.417 -	{
 578.418 -	case 0x0a:
 578.419 -		return j / 0x2000;
 578.420 -	case 0x0d:
 578.421 -		return j / 0x1000;
 578.422 -	}
 578.423 -	return 0;
 578.424 -}
 578.425 -
 578.426 -void GBCheatSearch::addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue)
 578.427 -{
 578.428 -	data[index].bank = bank;
 578.429 -	if (bank)
 578.430 -	{
 578.431 -		if (address == 0xa000)
 578.432 -			address |= offset & 0x1fff;
 578.433 -		else
 578.434 -			address |= offset & 0xfff;
 578.435 -	}
 578.436 -	else
 578.437 -		address |= offset;
 578.438 -	data[index].addr = address;
 578.439 -	sprintf(data[index].address, "%02x:%04x", bank, address);
 578.440 -	switch (numberType)
 578.441 -	{
 578.442 -	case 0:
 578.443 -		sprintf(data[index].oldValue, "%d", oldValue);
 578.444 -		sprintf(data[index].newValue, "%d", newValue);
 578.445 -		break;
 578.446 -	case 1:
 578.447 -		sprintf(data[index].oldValue, "%u", oldValue);
 578.448 -		sprintf(data[index].newValue, "%u", newValue);
 578.449 -		break;
 578.450 -	case 2:
 578.451 -		switch (sizeType)
 578.452 -		{
 578.453 -		case 0:
 578.454 -			sprintf(data[index].oldValue, "%02x", oldValue);
 578.455 -			sprintf(data[index].newValue, "%02x", newValue);
 578.456 -			break;
 578.457 -		case 1:
 578.458 -			sprintf(data[index].oldValue, "%04x", oldValue);
 578.459 -			sprintf(data[index].newValue, "%04x", newValue);
 578.460 -			break;
 578.461 -		case 2:
 578.462 -			sprintf(data[index].oldValue, "%08x", oldValue);
 578.463 -			sprintf(data[index].newValue, "%08x", newValue);
 578.464 -			break;
 578.465 -		}
 578.466 -	}
 578.467 -}
 578.468 -
 578.469 -void GBCheatSearch::addChanges(bool showMsg)
 578.470 -{
 578.471 -	int count = cheatSearchGetCount(&cheatSearchData, sizeType);
 578.472 -
 578.473 -	m_list.DeleteAllItems();
 578.474 -
 578.475 -	if (count > 4000)
 578.476 -	{
 578.477 -		if (showMsg)
 578.478 -			systemMessage(
 578.479 -			    IDS_SEARCH_PRODUCED_TOO_MANY,
 578.480 -			    "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches.",
 578.481 -			    count);
 578.482 -		return;
 578.483 -	}
 578.484 -
 578.485 -	if (count == 0)
 578.486 -	{
 578.487 -		if (showMsg)
 578.488 -			systemMessage(IDS_SEARCH_PRODUCED_NO_RESULTS, "Search produced no results");
 578.489 -		return;
 578.490 -	}
 578.491 -
 578.492 -	m_list.SetItemCount(count);
 578.493 -	if (data)
 578.494 -		free(data);
 578.495 -
 578.496 -	data = (WinGbCheatsData *)calloc(count, sizeof(WinGbCheatsData));
 578.497 -
 578.498 -	int inc = 1;
 578.499 -	switch (sizeType)
 578.500 -	{
 578.501 -	case 1:
 578.502 -		inc = 2;
 578.503 -		break;
 578.504 -	case 2:
 578.505 -		inc = 4;
 578.506 -		break;
 578.507 -	}
 578.508 -
 578.509 -	int index = 0;
 578.510 -	if (numberType == 0)
 578.511 -	{
 578.512 -		for (int i = 0; i < cheatSearchData.count; i++)
 578.513 -		{
 578.514 -			CheatSearchBlock *block = &cheatSearchData.blocks[i];
 578.515 -
 578.516 -			for (int j = 0; j < block->size; j += inc)
 578.517 -			{
 578.518 -				if (IS_BIT_SET(block->bits, j))
 578.519 -				{
 578.520 -					addChange(index++,
 578.521 -					          getBank(block->offset|j, j),
 578.522 -					          block->offset,
 578.523 -					          j,
 578.524 -					          cheatSearchSignedRead(block->saved,
 578.525 -					                                j,
 578.526 -					                                sizeType),
 578.527 -					          cheatSearchSignedRead(block->data,
 578.528 -					                                j,
 578.529 -					                                sizeType));
 578.530 -				}
 578.531 -			}
 578.532 -		}
 578.533 -	}
 578.534 -	else
 578.535 -	{
 578.536 -		for (int i = 0; i < cheatSearchData.count; i++)
 578.537 -		{
 578.538 -			CheatSearchBlock *block = &cheatSearchData.blocks[i];
 578.539 -
 578.540 -			for (int j = 0; j < block->size; j += inc)
 578.541 -			{
 578.542 -				if (IS_BIT_SET(block->bits, j))
 578.543 -				{
 578.544 -					addChange(index++,
 578.545 -					          getBank(block->offset|j, j),
 578.546 -					          block->offset,
 578.547 -					          j,
 578.548 -					          cheatSearchRead(block->saved,
 578.549 -					                          j,
 578.550 -					                          sizeType),
 578.551 -					          cheatSearchRead(block->data,
 578.552 -					                          j,
 578.553 -					                          sizeType));
 578.554 -				}
 578.555 -			}
 578.556 -		}
 578.557 -	}
 578.558 -
 578.559 -	for (int i = 0; i < count; i++)
 578.560 -	{
 578.561 -		LVITEM item;
 578.562 -
 578.563 -		item.mask     = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
 578.564 -		item.iItem    = i;
 578.565 -		item.iSubItem = 0;
 578.566 -		item.lParam   = data[i].addr|
 578.567 -		                (data[i].bank << 16);
 578.568 -		item.state     = 0;
 578.569 -		item.stateMask = 0;
 578.570 -		item.pszText   = LPSTR_TEXTCALLBACK;
 578.571 -		m_list.InsertItem(&item);
 578.572 -
 578.573 -		m_list.SetItemText(i, 1, LPSTR_TEXTCALLBACK);
 578.574 -		m_list.SetItemText(i, 2, LPSTR_TEXTCALLBACK);
 578.575 -	}
 578.576 -}
 578.577 -
 578.578 -void GBCheatSearch::OnValueType(UINT id)
 578.579 -{
 578.580 -	switch (id)
 578.581 -	{
 578.582 -	case IDC_OLD_VALUE:
 578.583 -		valueType = 0;
 578.584 -		m_value.EnableWindow(FALSE);
 578.585 -		regSetDwordValue("gbCheatsValueType", 0);
 578.586 -		break;
 578.587 -	case IDC_SPECIFIC_VALUE:
 578.588 -		valueType = 1;
 578.589 -		m_value.EnableWindow(TRUE);
 578.590 -		regSetDwordValue("gbCheatsValueType", 1);
 578.591 -		break;
 578.592 -	}
 578.593 -}
 578.594 -
 578.595 -void GBCheatSearch::OnSearchType(UINT id)
 578.596 -{
 578.597 -	switch (id)
 578.598 -	{
 578.599 -	case IDC_EQ:
 578.600 -		searchType = SEARCH_EQ;
 578.601 -		regSetDwordValue("gbCheatsSearchType", 0);
 578.602 -		break;
 578.603 -	case IDC_NE:
 578.604 -		searchType = SEARCH_NE;
 578.605 -		regSetDwordValue("gbCheatsSearchType", 1);
 578.606 -		break;
 578.607 -	case IDC_LT:
 578.608 -		searchType = SEARCH_LT;
 578.609 -		regSetDwordValue("gbCheatsSearchType", 2);
 578.610 -		break;
 578.611 -	case IDC_LE:
 578.612 -		searchType = SEARCH_LE;
 578.613 -		regSetDwordValue("gbCheatsSearchType", 3);
 578.614 -		break;
 578.615 -	case IDC_GT:
 578.616 -		searchType = SEARCH_GT;
 578.617 -		regSetDwordValue("gbCheatsSearchType", 4);
 578.618 -		break;
 578.619 -	case IDC_GE:
 578.620 -		searchType = SEARCH_GE;
 578.621 -		regSetDwordValue("gbCheatsSearchType", 5);
 578.622 -		break;
 578.623 -	}
 578.624 -}
 578.625 -
 578.626 -void GBCheatSearch::OnNumberType(UINT id)
 578.627 -{
 578.628 -	switch (id)
 578.629 -	{
 578.630 -	case IDC_SIGNED:
 578.631 -		numberType = 0;
 578.632 -		regSetDwordValue("gbCheatsNumberType", 0);
 578.633 -		if (m_list.GetItemCount())
 578.634 -		{
 578.635 -			addChanges(false);
 578.636 -		}
 578.637 -		break;
 578.638 -	case IDC_UNSIGNED:
 578.639 -		numberType = 1;
 578.640 -		regSetDwordValue("gbCheatsNumberType", 1);
 578.641 -		if (m_list.GetItemCount())
 578.642 -		{
 578.643 -			addChanges(false);
 578.644 -		}
 578.645 -		break;
 578.646 -	case IDC_HEXADECIMAL:
 578.647 -		numberType = 2;
 578.648 -		regSetDwordValue("gbCheatsNumberType", 2);
 578.649 -		if (m_list.GetItemCount())
 578.650 -		{
 578.651 -			addChanges(false);
 578.652 -		}
 578.653 -		break;
 578.654 -	}
 578.655 -}
 578.656 -
 578.657 -void GBCheatSearch::OnSizeType(UINT id)
 578.658 -{
 578.659 -	switch (id)
 578.660 -	{
 578.661 -	case IDC_SIZE_8:
 578.662 -		sizeType = BITS_8;
 578.663 -		regSetDwordValue("gbCheatsSizeType", 0);
 578.664 -		if (m_list.GetItemCount())
 578.665 -		{
 578.666 -			addChanges(false);
 578.667 -		}
 578.668 -		break;
 578.669 -	case IDC_SIZE_16:
 578.670 -		sizeType = BITS_16;
 578.671 -		regSetDwordValue("gbCheatsSizeType", 1);
 578.672 -		if (m_list.GetItemCount())
 578.673 -		{
 578.674 -			addChanges(false);
 578.675 -		}
 578.676 -		break;
 578.677 -	case IDC_SIZE_32:
 578.678 -		sizeType = BITS_32;
 578.679 -		regSetDwordValue("gbCheatsSizeType", 2);
 578.680 -		if (m_list.GetItemCount())
 578.681 -		{
 578.682 -			addChanges(false);
 578.683 -		}
 578.684 -		break;
 578.685 -	}
 578.686 -}
 578.687 -
 578.688 -/////////////////////////////////////////////////////////////////////////////
 578.689 -// AddGBCheat dialog
 578.690 -
 578.691 -AddGBCheat::AddGBCheat(u32 addr, CWnd*pParent /*=NULL*/)
 578.692 -	: CDialog(AddGBCheat::IDD, pParent)
 578.693 -{
 578.694 -	//{{AFX_DATA_INIT(AddGBCheat)
 578.695 -	numberType = regQueryDwordValue("gbCheatsNumberType", 2);
 578.696 -	if (numberType < 0 || numberType > 2)
 578.697 -		numberType = 2;
 578.698 -	sizeType = regQueryDwordValue("gbCheatsSizeType", 0);
 578.699 -	if (sizeType < 0 || sizeType > 2)
 578.700 -		sizeType = 0;
 578.701 -	//}}AFX_DATA_INIT
 578.702 -	address = addr;
 578.703 -}
 578.704 -
 578.705 -void AddGBCheat::DoDataExchange(CDataExchange*pDX)
 578.706 -{
 578.707 -	CDialog::DoDataExchange(pDX);
 578.708 -	//{{AFX_DATA_MAP(AddGBCheat)
 578.709 -	DDX_Control(pDX, IDC_VALUE, m_value);
 578.710 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
 578.711 -	DDX_Control(pDX, IDC_DESC, m_desc);
 578.712 -	DDX_Radio(pDX, IDC_SIZE_8, sizeType);
 578.713 -	DDX_Radio(pDX, IDC_SIGNED, numberType);
 578.714 -	//}}AFX_DATA_MAP
 578.715 -}
 578.716 -
 578.717 -BEGIN_MESSAGE_MAP(AddGBCheat, CDialog)
 578.718 -//{{AFX_MSG_MAP(AddGBCheat)
 578.719 -ON_BN_CLICKED(ID_OK, OnOk)
 578.720 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 578.721 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType)
 578.722 -ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType)
 578.723 -//}}AFX_MSG_MAP
 578.724 -END_MESSAGE_MAP()
 578.725 -
 578.726 -/////////////////////////////////////////////////////////////////////////////
 578.727 -// AddGBCheat message handlers
 578.728 -
 578.729 -void AddGBCheat::OnCancel()
 578.730 -{
 578.731 -	EndDialog(FALSE);
 578.732 -}
 578.733 -
 578.734 -void AddGBCheat::OnOk()
 578.735 -{
 578.736 -	// add cheat
 578.737 -	if (addCheat())
 578.738 -	{
 578.739 -		EndDialog(TRUE);
 578.740 -	}
 578.741 -}
 578.742 -
 578.743 -bool AddGBCheat::addCheat()
 578.744 -{
 578.745 -	CString buffer;
 578.746 -	CString code;
 578.747 -
 578.748 -	u32 value;
 578.749 -	m_value.GetWindowText(buffer);
 578.750 -
 578.751 -	if (buffer.IsEmpty())
 578.752 -	{
 578.753 -		systemMessage(IDS_VALUE_CANNOT_BE_EMPTY, "Value cannot be empty");
 578.754 -		return false;
 578.755 -	}
 578.756 -
 578.757 -	switch (numberType)
 578.758 -	{
 578.759 -	case 0:
 578.760 -		sscanf(buffer, "%d", &value);
 578.761 -		break;
 578.762 -	case 1:
 578.763 -		sscanf(buffer, "%u", &value);
 578.764 -		break;
 578.765 -	default:
 578.766 -		sscanf(buffer, "%x", &value);
 578.767 -	}
 578.768 -
 578.769 -	m_desc.GetWindowText(buffer);
 578.770 -
 578.771 -	int bank = (address >> 16);
 578.772 -	address &= 0xFFFF;
 578.773 -
 578.774 -	if (address >= 0xd000)
 578.775 -		bank += 0x90;
 578.776 -	else
 578.777 -		bank = 0x01;
 578.778 -
 578.779 -	switch (sizeType)
 578.780 -	{
 578.781 -	case 0:
 578.782 -		code.Format("%02X%02X%02X%02X", bank, value, address&0xFF, address>>8);
 578.783 -		gbAddGsCheat(code, buffer);
 578.784 -		break;
 578.785 -	case 1:
 578.786 -		code.Format("%02X%02X%02X%02X", bank, value&0xFF, address&0xFF,
 578.787 -		            address>>8);
 578.788 -		gbAddGsCheat(code, buffer);
 578.789 -		address++;
 578.790 -		code.Format("%02X%02X%02X%02X", bank, value>>8, address&0xFF,
 578.791 -		            address>>8);
 578.792 -		gbAddGsCheat(code, buffer);
 578.793 -		break;
 578.794 -	case 2:
 578.795 -		code.Format("%02X%02X%02X%02X", bank, value&0xFF, address&0xFF,
 578.796 -		            address>>8);
 578.797 -		gbAddGsCheat(code, buffer);
 578.798 -		address++;
 578.799 -		code.Format("%02X%02X%02X%02X", bank, (value>>8) & 0xFF, address&0xFF,
 578.800 -		            address>>8);
 578.801 -		gbAddGsCheat(code, buffer);
 578.802 -		address++;
 578.803 -		code.Format("%02X%02X%02X%02X", bank, (value>>16)&0xFF, address&0xFF,
 578.804 -		            address>>8);
 578.805 -		gbAddGsCheat(code, buffer);
 578.806 -		address++;
 578.807 -		code.Format("%02X%02X%02X%02X", bank, value>>24, address&0xFF,
 578.808 -		            address>>8);
 578.809 -		gbAddGsCheat(code, buffer);
 578.810 -		break;
 578.811 -	}
 578.812 -
 578.813 -	return true;
 578.814 -}
 578.815 -
 578.816 -BOOL AddGBCheat::OnInitDialog()
 578.817 -{
 578.818 -	CDialog::OnInitDialog();
 578.819 -
 578.820 -	CString buffer;
 578.821 -	buffer.Format("%02x:%08x", (address>>16), address&0xFFFF);
 578.822 -	m_address.SetWindowText(buffer);
 578.823 -	m_address.EnableWindow(FALSE);
 578.824 -	::SetWindowLong(m_address,
 578.825 -	                GWL_USERDATA,
 578.826 -	                address);
 578.827 -
 578.828 -	UpdateData(FALSE);
 578.829 -
 578.830 -	m_desc.LimitText(32);
 578.831 -
 578.832 -	if (address != 0)
 578.833 -	{
 578.834 -		GetDlgItem(IDC_SIZE_8)->EnableWindow(FALSE);
 578.835 -		GetDlgItem(IDC_SIZE_16)->EnableWindow(FALSE);
 578.836 -		GetDlgItem(IDC_SIZE_32)->EnableWindow(FALSE);
 578.837 -		GetDlgItem(IDC_HEXADECIMAL)->EnableWindow(FALSE);
 578.838 -		GetDlgItem(IDC_UNSIGNED)->EnableWindow(FALSE);
 578.839 -		GetDlgItem(IDC_SIGNED)->EnableWindow(FALSE);
 578.840 -	}
 578.841 -	CenterWindow();
 578.842 -
 578.843 -	return TRUE; // return TRUE unless you set the focus to a control
 578.844 -	             // EXCEPTION: OCX Property Pages should return FALSE
 578.845 -}
 578.846 -
 578.847 -void AddGBCheat::OnNumberType(UINT id)
 578.848 -{
 578.849 -	switch (id)
 578.850 -	{
 578.851 -	case IDC_SIGNED:
 578.852 -		numberType = 0;
 578.853 -		regSetDwordValue("gbCheatsNumberType", 0);
 578.854 -		break;
 578.855 -	case IDC_UNSIGNED:
 578.856 -		numberType = 1;
 578.857 -		regSetDwordValue("gbCheatsNumberType", 1);
 578.858 -		break;
 578.859 -	case IDC_HEXADECIMAL:
 578.860 -		numberType = 2;
 578.861 -		regSetDwordValue("gbCheatsNumberType", 2);
 578.862 -		break;
 578.863 -	}
 578.864 -}
 578.865 -
 578.866 -void AddGBCheat::OnSizeType(UINT id)
 578.867 -{
 578.868 -	switch (id)
 578.869 -	{
 578.870 -	case IDC_SIZE_8:
 578.871 -		sizeType = BITS_8;
 578.872 -		regSetDwordValue("gbCheatsSizeType", 0);
 578.873 -		break;
 578.874 -	case IDC_SIZE_16:
 578.875 -		sizeType = BITS_16;
 578.876 -		regSetDwordValue("gbCheatsSizeType", 1);
 578.877 -		break;
 578.878 -	case IDC_SIZE_32:
 578.879 -		sizeType = BITS_32;
 578.880 -		regSetDwordValue("gbCheatsSizeType", 2);
 578.881 -		break;
 578.882 -	}
 578.883 -}
 578.884 -
 578.885 -/////////////////////////////////////////////////////////////////////////////
 578.886 -// GBCheatList dialog
 578.887 -
 578.888 -GBCheatList::GBCheatList(CWnd*pParent /*=NULL*/)
 578.889 -	: CDialog(GBCheatList::IDD, pParent)
 578.890 -{
 578.891 -	//{{AFX_DATA_INIT(GBCheatList)
 578.892 -	// NOTE: the ClassWizard will add member initialization here
 578.893 -	//}}AFX_DATA_INIT
 578.894 -	duringRefresh = false;
 578.895 -}
 578.896 -
 578.897 -void GBCheatList::DoDataExchange(CDataExchange*pDX)
 578.898 -{
 578.899 -	CDialog::DoDataExchange(pDX);
 578.900 -	//{{AFX_DATA_MAP(GBCheatList)
 578.901 -	DDX_Control(pDX, IDC_CHEAT_LIST, m_list);
 578.902 -	//}}AFX_DATA_MAP
 578.903 -}
 578.904 -
 578.905 -BEGIN_MESSAGE_MAP(GBCheatList, CDialog)
 578.906 -//{{AFX_MSG_MAP(GBCheatList)
 578.907 -ON_BN_CLICKED(ID_OK, OnOk)
 578.908 -ON_BN_CLICKED(IDC_ADD_GG_CHEAT, OnAddGgCheat)
 578.909 -ON_BN_CLICKED(IDC_ADD_GS_CHEAT, OnAddGsCheat)
 578.910 -ON_BN_CLICKED(IDC_ENABLE, OnEnable)
 578.911 -ON_BN_CLICKED(IDC_REMOVE, OnRemove)
 578.912 -ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
 578.913 -ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
 578.914 -//}}AFX_MSG_MAP
 578.915 -END_MESSAGE_MAP()
 578.916 -
 578.917 -/////////////////////////////////////////////////////////////////////////////
 578.918 -// GBCheatList message handlers
 578.919 -
 578.920 -void GBCheatList::OnOk()
 578.921 -{
 578.922 -	EndDialog(TRUE);
 578.923 -}
 578.924 -
 578.925 -void GBCheatList::OnAddGgCheat()
 578.926 -{
 578.927 -	CString   temp = winResLoadString(IDS_ADD_GG_CODE);
 578.928 -	AddGBCode dlg(winGbCheatAddVerifyGg, 11, temp);
 578.929 -	dlg.DoModal();
 578.930 -	refresh();
 578.931 -}
 578.932 -
 578.933 -void GBCheatList::OnAddGsCheat()
 578.934 -{
 578.935 -	CString temp = winResLoadString(IDS_ADD_GS_CODE);
 578.936 -
 578.937 -	AddGBCode dlg(winGbCheatAddVerifyGs, 8, temp);
 578.938 -	dlg.DoModal();
 578.939 -	refresh();
 578.940 -}
 578.941 -
 578.942 -void GBCheatList::OnEnable()
 578.943 -{
 578.944 -	int mark = m_list.GetSelectionMark();
 578.945 -
 578.946 -	if (mark != -1)
 578.947 -	{
 578.948 -		LVITEM item;
 578.949 -		memset(&item, 0, sizeof(item));
 578.950 -		item.mask  = LVIF_PARAM;
 578.951 -		item.iItem = mark;
 578.952 -		if (m_list.GetItem(&item))
 578.953 -		{
 578.954 -			if (gbCheatList[item.lParam].enabled)
 578.955 -				gbCheatDisable(item.lParam);
 578.956 -			else
 578.957 -				gbCheatEnable(item.lParam);
 578.958 -			refresh();
 578.959 -		}
 578.960 -	}
 578.961 -}
 578.962 -
 578.963 -void GBCheatList::OnRemove()
 578.964 -{
 578.965 -	int mark = m_list.GetSelectionMark();
 578.966 -
 578.967 -	if (mark != -1)
 578.968 -	{
 578.969 -		LVITEM item;
 578.970 -		memset(&item, 0, sizeof(item));
 578.971 -		item.mask  = LVIF_PARAM;
 578.972 -		item.iItem = mark;
 578.973 -		if (m_list.GetItem(&item))
 578.974 -		{
 578.975 -			gbCheatRemove(item.lParam);
 578.976 -			refresh();
 578.977 -		}
 578.978 -	}
 578.979 -}
 578.980 -
 578.981 -void GBCheatList::OnRemoveAll()
 578.982 -{
 578.983 -	gbCheatRemoveAll();
 578.984 -	refresh();
 578.985 -}
 578.986 -
 578.987 -void GBCheatList::OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult)
 578.988 -{
 578.989 -	if (m_list.GetSelectionMark() != -1)
 578.990 -	{
 578.991 -		GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
 578.992 -		GetDlgItem(IDC_ENABLE)->EnableWindow(TRUE);
 578.993 -	}
 578.994 -	else
 578.995 -	{
 578.996 -		GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
 578.997 -		GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE);
 578.998 -	}
 578.999 -
578.1000 -	if (!duringRefresh)
578.1001 -	{
578.1002 -		LPNMLISTVIEW l = (LPNMLISTVIEW)pNMHDR;
578.1003 -		if (l->uChanged & LVIF_STATE)
578.1004 -		{
578.1005 -			if (((l->uOldState & LVIS_STATEIMAGEMASK)>>12) !=
578.1006 -			    (((l->uNewState & LVIS_STATEIMAGEMASK)>>12)))
578.1007 -			{
578.1008 -				if (m_list.GetCheck(l->iItem))
578.1009 -					gbCheatEnable(l->lParam);
578.1010 -				else
578.1011 -					gbCheatDisable(l->lParam);
578.1012 -				refresh();
578.1013 -			}
578.1014 -		}
578.1015 -	}
578.1016 -}
578.1017 -
578.1018 -BOOL GBCheatList::OnInitDialog()
578.1019 -{
578.1020 -	CDialog::OnInitDialog();
578.1021 -
578.1022 -	CString temp = winResLoadString(IDS_CODE);
578.1023 -	m_list.InsertColumn(0, temp, LVCFMT_LEFT, 120, 0);
578.1024 -	temp = winResLoadString(IDS_DESCRIPTION);
578.1025 -	m_list.InsertColumn(1, temp, LVCFMT_LEFT, 200, 1);
578.1026 -	temp = winResLoadString(IDS_STATUS);
578.1027 -	m_list.InsertColumn(2, temp, LVCFMT_LEFT, 80, 2);
578.1028 -
578.1029 -	m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)),
578.1030 -	               TRUE);
578.1031 -
578.1032 -	m_list.SetExtendedStyle(LVS_EX_CHECKBOXES |
578.1033 -	                        LVS_EX_FULLROWSELECT);
578.1034 -
578.1035 -	refresh();
578.1036 -	GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
578.1037 -	GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE);
578.1038 -	CenterWindow();
578.1039 -
578.1040 -	return TRUE; // return TRUE unless you set the focus to a control
578.1041 -	             // EXCEPTION: OCX Property Pages should return FALSE
578.1042 -}
578.1043 -
578.1044 -void GBCheatList::refresh()
578.1045 -{
578.1046 -	duringRefresh = true;
578.1047 -
578.1048 -	m_list.DeleteAllItems();
578.1049 -
578.1050 -	char buffer[2];
578.1051 -
578.1052 -	for (int i = 0; i < gbCheatNumber; i++)
578.1053 -	{
578.1054 -		LVITEM item;
578.1055 -
578.1056 -		item.mask      = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
578.1057 -		item.iItem     = i;
578.1058 -		item.iSubItem  = 0;
578.1059 -		item.lParam    = i;
578.1060 -		item.state     = 0;
578.1061 -		item.stateMask = 0;
578.1062 -		item.pszText   = gbCheatList[i].cheatCode;
578.1063 -		m_list.InsertItem(&item);
578.1064 -
578.1065 -		m_list.SetCheck(i, (gbCheatList[i].enabled ? TRUE : FALSE));
578.1066 -
578.1067 -		m_list.SetItemText(i, 1, gbCheatList[i].cheatDesc);
578.1068 -
578.1069 -		buffer[0] = (gbCheatList[i].enabled) ? 'E' : 'D';
578.1070 -		buffer[1] = 0;
578.1071 -		m_list.SetItemText(i, 2, buffer);
578.1072 -	}
578.1073 -	duringRefresh = false;
578.1074 -}
578.1075 -
578.1076 -/////////////////////////////////////////////////////////////////////////////
578.1077 -// AddGBCode dialog
578.1078 -
578.1079 -AddGBCode::AddGBCode(bool(*verify)(const char *, const char *), int len, const char *title, CWnd*pParent /*=NULL*/)
578.1080 -	: CDialog(AddGBCode::IDD, pParent)
578.1081 -{
578.1082 -	//{{AFX_DATA_INIT(AddGBCode)
578.1083 -	// NOTE: the ClassWizard will add member initialization here
578.1084 -	//}}AFX_DATA_INIT
578.1085 -	addVerify = verify;
578.1086 -	addLength = len;
578.1087 -	addTitle  = title;
578.1088 -}
578.1089 -
578.1090 -void AddGBCode::DoDataExchange(CDataExchange*pDX)
578.1091 -{
578.1092 -	CDialog::DoDataExchange(pDX);
578.1093 -	//{{AFX_DATA_MAP(AddGBCode)
578.1094 -	DDX_Control(pDX, IDC_DESC, m_desc);
578.1095 -	DDX_Control(pDX, IDC_CODE, m_code);
578.1096 -	//}}AFX_DATA_MAP
578.1097 -}
578.1098 -
578.1099 -BEGIN_MESSAGE_MAP(AddGBCode, CDialog)
578.1100 -//{{AFX_MSG_MAP(AddGBCode)
578.1101 -ON_BN_CLICKED(ID_OK, OnOk)
578.1102 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
578.1103 -//}}AFX_MSG_MAP
578.1104 -END_MESSAGE_MAP()
578.1105 -
578.1106 -/////////////////////////////////////////////////////////////////////////////
578.1107 -// AddGBCode message handlers
578.1108 -
578.1109 -void AddGBCode::OnOk()
578.1110 -{
578.1111 -	CString desc;
578.1112 -	CString buffer;
578.1113 -	m_code.GetWindowText(buffer);
578.1114 -	m_desc.GetWindowText(desc);
578.1115 -
578.1116 -	StringTokenizer st(buffer, " \t\n\r");
578.1117 -	const char *    t = st.next();
578.1118 -	while (t)
578.1119 -	{
578.1120 -		addVerify(t, desc);
578.1121 -		t = st.next();
578.1122 -	}
578.1123 -	EndDialog(TRUE);
578.1124 -}
578.1125 -
578.1126 -void AddGBCode::OnCancel()
578.1127 -{
578.1128 -	EndDialog(FALSE);
578.1129 -}
578.1130 -
578.1131 -BOOL AddGBCode::OnInitDialog()
578.1132 -{
578.1133 -	CDialog::OnInitDialog();
578.1134 -
578.1135 -	m_code.LimitText(1024);
578.1136 -	m_desc.LimitText(32);
578.1137 -	SetWindowText(addTitle);
578.1138 -	CenterWindow();
578.1139 -
578.1140 -	return TRUE; // return TRUE unless you set the focus to a control
578.1141 -	             // EXCEPTION: OCX Property Pages should return FALSE
578.1142 -}
578.1143 -
   579.1 --- a/src/win32/GBCheatsDlg.h	Sat Mar 03 10:54:39 2012 -0600
   579.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   579.3 @@ -1,198 +0,0 @@
   579.4 -#if !defined(AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_)
   579.5 -#define AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_
   579.6 -
   579.7 -#if _MSC_VER > 1000
   579.8 -#pragma once
   579.9 -#endif // _MSC_VER > 1000
  579.10 -// GBCheats.h : header file
  579.11 -//
  579.12 -
  579.13 -/////////////////////////////////////////////////////////////////////////////
  579.14 -// GBCheatSearch dialog
  579.15 -
  579.16 -struct WinGbCheatsData
  579.17 -{
  579.18 -	int  bank;
  579.19 -	u16  addr;
  579.20 -	char address[9];
  579.21 -	char oldValue[12];
  579.22 -	char newValue[12];
  579.23 -};
  579.24 -
  579.25 -class GBCheatSearch : public CDialog
  579.26 -{
  579.27 -	// Construction
  579.28 -public:
  579.29 -	afx_msg void OnSizeType(UINT id);
  579.30 -	afx_msg void OnNumberType(UINT id);
  579.31 -	afx_msg void OnSearchType(UINT id);
  579.32 -	afx_msg void OnValueType(UINT id);
  579.33 -	void addChanges(bool showMsg);
  579.34 -	void addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue);
  579.35 -	int getBank(u16 addr, int j);
  579.36 -	GBCheatSearch(CWnd*pParent = NULL);  // standard constructor
  579.37 -	~GBCheatSearch();
  579.38 -
  579.39 -	// Dialog Data
  579.40 -	//{{AFX_DATA(GBCheatSearch)
  579.41 -	enum { IDD = IDD_CHEATS };
  579.42 -	CEdit     m_value;
  579.43 -	CListCtrl m_list;
  579.44 -	int       searchType;
  579.45 -	int       numberType;
  579.46 -	int       sizeType;
  579.47 -	BOOL      updateValues;
  579.48 -	int       valueType;
  579.49 -	//}}AFX_DATA
  579.50 -
  579.51 -	// Overrides
  579.52 -	// ClassWizard generated virtual function overrides
  579.53 -	//{{AFX_VIRTUAL(GBCheatSearch)
  579.54 -protected:
  579.55 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  579.56 -	//}}AFX_VIRTUAL
  579.57 -
  579.58 -	// Implementation
  579.59 -protected:
  579.60 -	WinGbCheatsData *data;
  579.61 -
  579.62 -	// Generated message map functions
  579.63 -	//{{AFX_MSG(GBCheatSearch)
  579.64 -	afx_msg void OnOk();
  579.65 -	afx_msg void OnAddCheat();
  579.66 -	afx_msg void OnSearch();
  579.67 -	afx_msg void OnStart();
  579.68 -	afx_msg void OnUpdate();
  579.69 -	virtual BOOL OnInitDialog();
  579.70 -	afx_msg void OnGetdispinfoCheatList(NMHDR*pNMHDR, LRESULT*pResult);
  579.71 -	afx_msg void OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult);
  579.72 -	//}}AFX_MSG
  579.73 -	DECLARE_MESSAGE_MAP()
  579.74 -public:
  579.75 -	afx_msg void OnClose();
  579.76 -	afx_msg void OnBnClickedCheatrefreshbutton();
  579.77 -};
  579.78 -
  579.79 -/////////////////////////////////////////////////////////////////////////////
  579.80 -// AddGBCheat dialog
  579.81 -
  579.82 -class AddGBCheat : public CDialog
  579.83 -{
  579.84 -	// Construction
  579.85 -public:
  579.86 -	afx_msg void OnSizeType(UINT id);
  579.87 -	afx_msg void OnNumberType(UINT id);
  579.88 -	bool addCheat();
  579.89 -	AddGBCheat(u32 addr, CWnd*pParent = NULL);  // standard constructor
  579.90 -
  579.91 -	// Dialog Data
  579.92 -	//{{AFX_DATA(AddGBCheat)
  579.93 -	enum { IDD = IDD_ADD_CHEAT };
  579.94 -	CEdit m_value;
  579.95 -	CEdit m_address;
  579.96 -	CEdit m_desc;
  579.97 -	int   sizeType;
  579.98 -	int   numberType;
  579.99 -	//}}AFX_DATA
 579.100 -
 579.101 -	// Overrides
 579.102 -	// ClassWizard generated virtual function overrides
 579.103 -	//{{AFX_VIRTUAL(AddGBCheat)
 579.104 -protected:
 579.105 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 579.106 -	//}}AFX_VIRTUAL
 579.107 -
 579.108 -	// Implementation
 579.109 -protected:
 579.110 -	u32 address;
 579.111 -
 579.112 -	// Generated message map functions
 579.113 -	//{{AFX_MSG(AddGBCheat)
 579.114 -	afx_msg void OnCancel();
 579.115 -	afx_msg void OnOk();
 579.116 -	virtual BOOL OnInitDialog();
 579.117 -	//}}AFX_MSG
 579.118 -	DECLARE_MESSAGE_MAP()
 579.119 -};
 579.120 -/////////////////////////////////////////////////////////////////////////////
 579.121 -// GBCheatList dialog
 579.122 -
 579.123 -class GBCheatList : public CDialog
 579.124 -{
 579.125 -	// Construction
 579.126 -public:
 579.127 -	void refresh();
 579.128 -	GBCheatList(CWnd*pParent = NULL);  // standard constructor
 579.129 -
 579.130 -	// Dialog Data
 579.131 -	//{{AFX_DATA(GBCheatList)
 579.132 -	enum { IDD = IDD_GB_CHEAT_LIST };
 579.133 -	CListCtrl m_list;
 579.134 -	//}}AFX_DATA
 579.135 -
 579.136 -	// Overrides
 579.137 -	// ClassWizard generated virtual function overrides
 579.138 -	//{{AFX_VIRTUAL(GBCheatList)
 579.139 -protected:
 579.140 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 579.141 -	//}}AFX_VIRTUAL
 579.142 -
 579.143 -	// Implementation
 579.144 -protected:
 579.145 -	bool duringRefresh;
 579.146 -
 579.147 -	// Generated message map functions
 579.148 -	//{{AFX_MSG(GBCheatList)
 579.149 -	afx_msg void OnOk();
 579.150 -	afx_msg void OnAddGgCheat();
 579.151 -	afx_msg void OnAddGsCheat();
 579.152 -	afx_msg void OnEnable();
 579.153 -	afx_msg void OnRemove();
 579.154 -	afx_msg void OnRemoveAll();
 579.155 -	afx_msg void OnItemchangedCheatList(NMHDR*pNMHDR, LRESULT*pResult);
 579.156 -	virtual BOOL OnInitDialog();
 579.157 -	//}}AFX_MSG
 579.158 -	DECLARE_MESSAGE_MAP()
 579.159 -};
 579.160 -
 579.161 -/////////////////////////////////////////////////////////////////////////////
 579.162 -// AddGBCode dialog
 579.163 -
 579.164 -class AddGBCode : public CDialog
 579.165 -{
 579.166 -	// Construction
 579.167 -public:
 579.168 -	AddGBCode(bool(*verify)(const char *, const char *), int, const char *, CWnd*pParent = NULL);  // standard constructor
 579.169 -
 579.170 -	// Dialog Data
 579.171 -	//{{AFX_DATA(AddGBCode)
 579.172 -	enum { IDD = IDD_ADD_CHEAT_DLG };
 579.173 -	CEdit m_desc;
 579.174 -	CEdit m_code;
 579.175 -	//}}AFX_DATA
 579.176 -
 579.177 -	// Overrides
 579.178 -	// ClassWizard generated virtual function overrides
 579.179 -	//{{AFX_VIRTUAL(AddGBCode)
 579.180 -protected:
 579.181 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 579.182 -	//}}AFX_VIRTUAL
 579.183 -
 579.184 -	// Implementation
 579.185 -protected:
 579.186 -	int     addLength;
 579.187 -	CString addTitle;
 579.188 -	bool    (*addVerify)(const char *, const char *);
 579.189 -
 579.190 -	// Generated message map functions
 579.191 -	//{{AFX_MSG(AddGBCode)
 579.192 -	afx_msg void OnOk();
 579.193 -	afx_msg void OnCancel();
 579.194 -	virtual BOOL OnInitDialog();
 579.195 -	//}}AFX_MSG
 579.196 -	DECLARE_MESSAGE_MAP()
 579.197 -};
 579.198 -//{{AFX_INSERT_LOCATION}}
 579.199 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 579.200 -
 579.201 -#endif // !defined(AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_)
   580.1 --- a/src/win32/GBColorDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   580.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   580.3 @@ -1,238 +0,0 @@
   580.4 -// GBColorDlg.cpp : implementation file
   580.5 -//
   580.6 -
   580.7 -#include "stdafx.h"
   580.8 -#include "resource.h"
   580.9 -#include "GBColorDlg.h"
  580.10 -#include "Reg.h"
  580.11 -
  580.12 -extern int32 gbPaletteOption;
  580.13 -extern int   emulating;
  580.14 -extern int   systemCartridgeType;
  580.15 -extern u16   gbPalette[128];
  580.16 -extern u16   systemGbPalette[24];
  580.17 -
  580.18 -static u16 defaultPalettes[][24] = {
  580.19 -	{
  580.20 -		0x7FFF, 0x56B5, 0x318C, 0x0000,  0x7FFF, 0x56B5, 0x318C, 0x0000,
  580.21 -	},
  580.22 -	{
  580.23 -		0x6200, 0x7E10, 0x7C10, 0x5000,  0x6200, 0x7E10, 0x7C10, 0x5000,
  580.24 -	},
  580.25 -	{
  580.26 -		0x4008, 0x4000, 0x2000, 0x2008,  0x4008, 0x4000, 0x2000, 0x2008,
  580.27 -	},
  580.28 -	{
  580.29 -		0x43F0, 0x03E0, 0x4200, 0x2200,  0x43F0, 0x03E0, 0x4200, 0x2200,
  580.30 -	},
  580.31 -	{
  580.32 -		0x43FF, 0x03FF, 0x221F, 0x021F,  0x43FF, 0x03FF, 0x221F, 0x021F,
  580.33 -	},
  580.34 -	{
  580.35 -		0x621F, 0x7E1F, 0x7C1F, 0x2010,  0x621F, 0x7E1F, 0x7C1F, 0x2010,
  580.36 -	},
  580.37 -	{
  580.38 -		0x621F, 0x401F, 0x001F, 0x2010,  0x621F, 0x401F, 0x001F, 0x2010,
  580.39 -	},
  580.40 -	{
  580.41 -		0x1314, 0x0E91, 0x0E0D, 0x2108,  0x1314, 0x0E91, 0x0E0D, 0x2108,
  580.42 -	}
  580.43 -};
  580.44 -
  580.45 -/////////////////////////////////////////////////////////////////////////////
  580.46 -// GBColorDlg dialog
  580.47 -
  580.48 -GBColorDlg::GBColorDlg(CWnd*pParent /*=NULL*/)
  580.49 -	: CDialog(GBColorDlg::IDD, pParent)
  580.50 -{
  580.51 -	//{{AFX_DATA_INIT(GBColorDlg)
  580.52 -	which = -1;
  580.53 -	//}}AFX_DATA_INIT
  580.54 -	which = gbPaletteOption;
  580.55 -}
  580.56 -
  580.57 -void GBColorDlg::DoDataExchange(CDataExchange*pDX)
  580.58 -{
  580.59 -	CDialog::DoDataExchange(pDX);
  580.60 -	//{{AFX_DATA_MAP(GBColorDlg)
  580.61 -	DDX_Control(pDX, IDC_PREDEFINED, m_predefined);
  580.62 -	DDX_Radio(pDX, IDC_DEFAULT, which);
  580.63 -	//}}AFX_DATA_MAP
  580.64 -}
  580.65 -
  580.66 -BEGIN_MESSAGE_MAP(GBColorDlg, CDialog)
  580.67 -//{{AFX_MSG_MAP(GBColorDlg)
  580.68 -ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
  580.69 -ON_BN_CLICKED(IDC_RESET, OnReset)
  580.70 -ON_BN_CLICKED(IDC_USER1, OnUser1)
  580.71 -ON_BN_CLICKED(IDC_USER2, OnUser2)
  580.72 -ON_BN_CLICKED(ID_OK, OnOk)
  580.73 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  580.74 -ON_CBN_SELCHANGE(IDC_PREDEFINED, OnSelchangePredefined)
  580.75 -//}}AFX_MSG_MAP
  580.76 -ON_CONTROL_RANGE(BN_CLICKED, IDC_COLOR_BG0, IDC_COLOR_OB3, OnColorClicked)
  580.77 -END_MESSAGE_MAP()
  580.78 -
  580.79 -/////////////////////////////////////////////////////////////////////////////
  580.80 -// GBColorDlg message handlers
  580.81 -
  580.82 -void GBColorDlg::OnDefault()
  580.83 -{
  580.84 -	setWhich(0);
  580.85 -}
  580.86 -
  580.87 -void GBColorDlg::OnReset()
  580.88 -{
  580.89 -	int s = which * 8;
  580.90 -	colors[s++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
  580.91 -	colors[s++] = (0x15) | (0x15 << 5) | (0x15 << 10);
  580.92 -	colors[s++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
  580.93 -	colors[s++] = 0;
  580.94 -
  580.95 -	colors[s++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
  580.96 -	colors[s++] = (0x15) | (0x15 << 5) | (0x15 << 10);
  580.97 -	colors[s++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
  580.98 -	colors[s]   = 0;
  580.99 -	setWhich(which);
 580.100 -}
 580.101 -
 580.102 -void GBColorDlg::OnUser1()
 580.103 -{
 580.104 -	setWhich(1);
 580.105 -}
 580.106 -
 580.107 -void GBColorDlg::OnUser2()
 580.108 -{
 580.109 -	setWhich(2);
 580.110 -}
 580.111 -
 580.112 -void GBColorDlg::OnCancel()
 580.113 -{
 580.114 -	EndDialog(FALSE);
 580.115 -}
 580.116 -
 580.117 -void GBColorDlg::OnOk()
 580.118 -{
 580.119 -	EndDialog(TRUE);
 580.120 -}
 580.121 -
 580.122 -BOOL GBColorDlg::OnInitDialog()
 580.123 -{
 580.124 -	CDialog::OnInitDialog();
 580.125 -
 580.126 -	colorControls[0].SubclassDlgItem(IDC_COLOR_BG0, this);
 580.127 -	colorControls[1].SubclassDlgItem(IDC_COLOR_BG1, this);
 580.128 -	colorControls[2].SubclassDlgItem(IDC_COLOR_BG2, this);
 580.129 -	colorControls[3].SubclassDlgItem(IDC_COLOR_BG3, this);
 580.130 -	colorControls[4].SubclassDlgItem(IDC_COLOR_OB0, this);
 580.131 -	colorControls[5].SubclassDlgItem(IDC_COLOR_OB1, this);
 580.132 -	colorControls[6].SubclassDlgItem(IDC_COLOR_OB2, this);
 580.133 -	colorControls[7].SubclassDlgItem(IDC_COLOR_OB3, this);
 580.134 -
 580.135 -	for (int i = 0; i < 24; i++)
 580.136 -	{
 580.137 -		colors[i] = systemGbPalette[i];
 580.138 -	}
 580.139 -
 580.140 -	const char *names[] = {
 580.141 -		"Standard",
 580.142 -		"Blue Sea",
 580.143 -		"Dark Night",
 580.144 -		"Green Forest",
 580.145 -		"Hot Desert",
 580.146 -		"Pink Dreams",
 580.147 -		"Weird Colors",
 580.148 -		"Real Colors"
 580.149 -	};
 580.150 -
 580.151 -	for (int j = 0; j < 8; j++)
 580.152 -	{
 580.153 -		int index = m_predefined.AddString(names[j]);
 580.154 -		m_predefined.SetItemData(index, j);
 580.155 -	}
 580.156 -
 580.157 -	RECT cbSize;
 580.158 -	int  Height;
 580.159 -
 580.160 -	m_predefined.GetClientRect(&cbSize);
 580.161 -	Height  = m_predefined.GetItemHeight(0);
 580.162 -	Height += m_predefined.GetItemHeight(0) * (10);
 580.163 -
 580.164 -	// Note: The use of SM_CYEDGE assumes that we're using Windows '95
 580.165 -	// Now add on the height of the border of the edit box
 580.166 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 580.167 -
 580.168 -	// The height of the border of the drop-down box
 580.169 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 580.170 -
 580.171 -	// now set the size of the window
 580.172 -	m_predefined.SetWindowPos(NULL,
 580.173 -	                          0, 0,
 580.174 -	                          cbSize.right, Height,
 580.175 -	                          SWP_NOMOVE | SWP_NOZORDER);
 580.176 -
 580.177 -	setWhich(which);
 580.178 -
 580.179 -	CenterWindow();
 580.180 -
 580.181 -	return TRUE; // return TRUE unless you set the focus to a control
 580.182 -	             // EXCEPTION: OCX Property Pages should return FALSE
 580.183 -}
 580.184 -
 580.185 -void GBColorDlg::setWhich(int w)
 580.186 -{
 580.187 -	which = w;
 580.188 -
 580.189 -	for (int i = 0; i < 8; i++)
 580.190 -	{
 580.191 -		colorControls[i].setColor(colors[which*8+i]);
 580.192 -	}
 580.193 -}
 580.194 -
 580.195 -u16 *GBColorDlg::getColors()
 580.196 -{
 580.197 -	return colors;
 580.198 -}
 580.199 -
 580.200 -void GBColorDlg::OnColorClicked(UINT id)
 580.201 -{
 580.202 -	id -= IDC_COLOR_BG0;
 580.203 -
 580.204 -	u16 color = colors[which*8+id];
 580.205 -
 580.206 -	COLORREF colorInit =
 580.207 -	    RGB((color & 0x1f) << 3, ((color >> 5) & 0x1f) << 3, ((color >> 10) & 0x1f) << 3);
 580.208 -
 580.209 -	CColorDialog dlg(colorInit,
 580.210 -	                 CC_FULLOPEN | CC_ANYCOLOR, this);
 580.211 -
 580.212 -	if (IDOK == dlg.DoModal())
 580.213 -	{
 580.214 -		COLORREF c = dlg.GetColor();
 580.215 -
 580.216 -		colors[which*8+id] = (u16)((c >> 3) & 0x1f | ((c >> 11) & 0x1f) << 5 |
 580.217 -		                           ((c >> 19) & 0x1f) << 10);
 580.218 -		colorControls[id].setColor(colors[which*8+id]);
 580.219 -	}
 580.220 -}
 580.221 -
 580.222 -int GBColorDlg::getWhich()
 580.223 -{
 580.224 -	return which;
 580.225 -}
 580.226 -
 580.227 -void GBColorDlg::OnSelchangePredefined()
 580.228 -{
 580.229 -	int sel = m_predefined.GetCurSel();
 580.230 -
 580.231 -	if (sel != -1)
 580.232 -	{
 580.233 -		int data = m_predefined.GetItemData(sel);
 580.234 -		for (int i = 0; i < 8; i++)
 580.235 -		{
 580.236 -			colorControls[i].setColor(defaultPalettes[data][i]);
 580.237 -			colors[which*8+i] = defaultPalettes[data][i];
 580.238 -		}
 580.239 -	}
 580.240 -}
 580.241 -
   581.1 --- a/src/win32/GBColorDlg.h	Sat Mar 03 10:54:39 2012 -0600
   581.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   581.3 @@ -1,60 +0,0 @@
   581.4 -#if !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_)
   581.5 -#define AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_
   581.6 -
   581.7 -#if _MSC_VER > 1000
   581.8 -#pragma once
   581.9 -#endif // _MSC_VER > 1000
  581.10 -// GBColorDlg.h : header file
  581.11 -//
  581.12 -
  581.13 -#include "ColorButton.h"  // Added by ClassView
  581.14 -
  581.15 -/////////////////////////////////////////////////////////////////////////////
  581.16 -// GBColorDlg dialog
  581.17 -
  581.18 -class GBColorDlg : public CDialog
  581.19 -{
  581.20 -	// Construction
  581.21 -public:
  581.22 -	int getWhich();
  581.23 -	afx_msg void OnColorClicked(UINT id);
  581.24 -	u16 *getColors();
  581.25 -	void setWhich(int w);
  581.26 -	u16         colors[24];
  581.27 -	ColorButton colorControls[8];
  581.28 -	GBColorDlg(CWnd*pParent = NULL);  // standard constructor
  581.29 -
  581.30 -	// Dialog Data
  581.31 -	//{{AFX_DATA(GBColorDlg)
  581.32 -	enum { IDD = IDD_GB_COLORS };
  581.33 -	CComboBox m_predefined;
  581.34 -	int       which;
  581.35 -	//}}AFX_DATA
  581.36 -
  581.37 -	// Overrides
  581.38 -	// ClassWizard generated virtual function overrides
  581.39 -	//{{AFX_VIRTUAL(GBColorDlg)
  581.40 -protected:
  581.41 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  581.42 -	//}}AFX_VIRTUAL
  581.43 -
  581.44 -	// Implementation
  581.45 -protected:
  581.46 -	// Generated message map functions
  581.47 -	//{{AFX_MSG(GBColorDlg)
  581.48 -	afx_msg void OnDefault();
  581.49 -	afx_msg void OnReset();
  581.50 -	afx_msg void OnUser1();
  581.51 -	afx_msg void OnUser2();
  581.52 -	afx_msg void OnCancel();
  581.53 -	afx_msg void OnOk();
  581.54 -	virtual BOOL OnInitDialog();
  581.55 -	afx_msg void OnSelchangePredefined();
  581.56 -	//}}AFX_MSG
  581.57 -	DECLARE_MESSAGE_MAP()
  581.58 -};
  581.59 -
  581.60 -//{{AFX_INSERT_LOCATION}}
  581.61 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  581.62 -
  581.63 -#endif // !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_)
   582.1 --- a/src/win32/GBDisassemble.cpp	Sat Mar 03 10:54:39 2012 -0600
   582.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   582.3 @@ -1,241 +0,0 @@
   582.4 -// GBDisassemble.cpp : implementation file
   582.5 -//
   582.6 -
   582.7 -#include "stdafx.h"
   582.8 -#include "resource.h"
   582.9 -#include "GBDisassemble.h"
  582.10 -#include "VBA.h"
  582.11 -
  582.12 -#include "../gb/GB.h"
  582.13 -#include "../gb/gbGlobals.h"
  582.14 -
  582.15 -extern gbRegister AF;
  582.16 -extern gbRegister BC;
  582.17 -extern gbRegister DE;
  582.18 -extern gbRegister HL;
  582.19 -extern gbRegister SP;
  582.20 -extern gbRegister PC;
  582.21 -extern u16        IFF;
  582.22 -extern int        gbDis(char *, u16);
  582.23 -
  582.24 -/////////////////////////////////////////////////////////////////////////////
  582.25 -// GBDisassemble dialog
  582.26 -
  582.27 -GBDisassemble::GBDisassemble(CWnd*pParent /*=NULL*/)
  582.28 -	: ResizeDlg(GBDisassemble::IDD, pParent)
  582.29 -{
  582.30 -	//{{AFX_DATA_INIT(GBDisassemble)
  582.31 -	m_c = FALSE;
  582.32 -	m_h = FALSE;
  582.33 -	m_n = FALSE;
  582.34 -	m_z = FALSE;
  582.35 -	//}}AFX_DATA_INIT
  582.36 -	address     = 0;
  582.37 -	autoUpdate  = false;
  582.38 -	count       = 1;
  582.39 -	lastAddress = 0;
  582.40 -}
  582.41 -
  582.42 -void GBDisassemble::DoDataExchange(CDataExchange*pDX)
  582.43 -{
  582.44 -	CDialog::DoDataExchange(pDX);
  582.45 -	//{{AFX_DATA_MAP(GBDisassemble)
  582.46 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
  582.47 -	DDX_Control(pDX, IDC_DISASSEMBLE, m_list);
  582.48 -	DDX_Check(pDX, IDC_C, m_c);
  582.49 -	DDX_Check(pDX, IDC_H, m_h);
  582.50 -	DDX_Check(pDX, IDC_N, m_n);
  582.51 -	DDX_Check(pDX, IDC_Z, m_z);
  582.52 -	//}}AFX_DATA_MAP
  582.53 -}
  582.54 -
  582.55 -BEGIN_MESSAGE_MAP(GBDisassemble, CDialog)
  582.56 -//{{AFX_MSG_MAP(GBDisassemble)
  582.57 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  582.58 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  582.59 -ON_BN_CLICKED(IDC_NEXT, OnNext)
  582.60 -ON_BN_CLICKED(IDC_GO, OnGo)
  582.61 -ON_BN_CLICKED(IDC_GOPC, OnGopc)
  582.62 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  582.63 -ON_WM_VSCROLL()
  582.64 -//}}AFX_MSG_MAP
  582.65 -END_MESSAGE_MAP()
  582.66 -
  582.67 -/////////////////////////////////////////////////////////////////////////////
  582.68 -// GBDisassemble message handlers
  582.69 -
  582.70 -void GBDisassemble::OnClose()
  582.71 -{
  582.72 -	theApp.winRemoveUpdateListener(this);
  582.73 -
  582.74 -	DestroyWindow();
  582.75 -}
  582.76 -
  582.77 -void GBDisassemble::OnRefresh()
  582.78 -{
  582.79 -	refresh();
  582.80 -}
  582.81 -
  582.82 -void GBDisassemble::OnNext()
  582.83 -{
  582.84 -	gbEmulate(1);
  582.85 -	if (PC.W < address || PC.W >= lastAddress)
  582.86 -		OnGopc();
  582.87 -	refresh();
  582.88 -}
  582.89 -
  582.90 -void GBDisassemble::OnGo()
  582.91 -{
  582.92 -	CString buffer;
  582.93 -	m_address.GetWindowText(buffer);
  582.94 -	sscanf(buffer, "%x", &address);
  582.95 -	refresh();
  582.96 -}
  582.97 -
  582.98 -void GBDisassemble::OnGopc()
  582.99 -{
 582.100 -	address = PC.W;
 582.101 -
 582.102 -	refresh();
 582.103 -}
 582.104 -
 582.105 -void GBDisassemble::OnAutoUpdate()
 582.106 -{
 582.107 -	autoUpdate = !autoUpdate;
 582.108 -	if (autoUpdate)
 582.109 -	{
 582.110 -		theApp.winAddUpdateListener(this);
 582.111 -	}
 582.112 -	else
 582.113 -	{
 582.114 -		theApp.winRemoveUpdateListener(this);
 582.115 -	}
 582.116 -}
 582.117 -
 582.118 -BOOL GBDisassemble::OnInitDialog()
 582.119 -{
 582.120 -	CDialog::OnInitDialog();
 582.121 -
 582.122 -	DIALOG_SIZER_START(sz)
 582.123 -	DIALOG_SIZER_ENTRY(IDC_DISASSEMBLE, DS_SizeY)
 582.124 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 582.125 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 582.126 -	DIALOG_SIZER_ENTRY(IDC_NEXT,  DS_MoveY)
 582.127 -	DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveY)
 582.128 -	DIALOG_SIZER_ENTRY(IDC_GOPC, DS_MoveY)
 582.129 -	DIALOG_SIZER_ENTRY(IDC_VSCROLL, DS_SizeY)
 582.130 -	DIALOG_SIZER_END()
 582.131 -	SetData(sz,
 582.132 -	        TRUE,
 582.133 -	        HKEY_CURRENT_USER,
 582.134 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBDisassembleView",
 582.135 -	        NULL);
 582.136 -
 582.137 -	SCROLLINFO si;
 582.138 -	ZeroMemory(&si, sizeof(si));
 582.139 -	si.cbSize = sizeof(si);
 582.140 -	si.fMask  = SIF_PAGE | SIF_RANGE | SIF_POS;
 582.141 -	si.nMin   = 0;
 582.142 -	si.nMax   = 100;
 582.143 -	si.nPos   = 50;
 582.144 -	si.nPage  = 0;
 582.145 -	GetDlgItem(IDC_VSCROLL)->SetScrollInfo(SB_CTL, &si, TRUE);
 582.146 -	CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
 582.147 -	m_list.SetFont(font);
 582.148 -
 582.149 -	for (int i = 0; i < 7; i++)
 582.150 -		GetDlgItem(IDC_R0+i)->SetFont(font);
 582.151 -
 582.152 -	m_address.LimitText(4);
 582.153 -	refresh();
 582.154 -
 582.155 -	return TRUE; // return TRUE unless you set the focus to a control
 582.156 -	             // EXCEPTION: OCX Property Pages should return FALSE
 582.157 -}
 582.158 -
 582.159 -void GBDisassemble::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 582.160 -{
 582.161 -	char buffer[80];
 582.162 -
 582.163 -	switch (nSBCode)
 582.164 -	{
 582.165 -	case SB_LINEDOWN:
 582.166 -		address += gbDis(buffer, address);
 582.167 -		break;
 582.168 -	case SB_LINEUP:
 582.169 -		address--;
 582.170 -		break;
 582.171 -	case SB_PAGEDOWN:
 582.172 -		address = lastAddress;
 582.173 -		break;
 582.174 -	case SB_PAGEUP:
 582.175 -		address -= count;
 582.176 -		break;
 582.177 -	}
 582.178 -	refresh();
 582.179 -
 582.180 -	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
 582.181 -}
 582.182 -
 582.183 -void GBDisassemble::refresh()
 582.184 -{
 582.185 -	if (gbRom == NULL)
 582.186 -		return;
 582.187 -
 582.188 -	int  h = m_list.GetItemHeight(0);
 582.189 -	RECT r;
 582.190 -	m_list.GetClientRect(&r);
 582.191 -	count = (r.bottom - r.top+1)/h;
 582.192 -
 582.193 -	m_list.ResetContent();
 582.194 -	if (!systemIsEmulating() || systemCartridgeType != 1)
 582.195 -		return;
 582.196 -
 582.197 -	char buffer[80];
 582.198 -	u16  addr = address;
 582.199 -	int  i;
 582.200 -	int  sel = -1;
 582.201 -	for (i = 0; i < count; i++)
 582.202 -	{
 582.203 -		if (addr == PC.W)
 582.204 -			sel = i;
 582.205 -		addr += gbDis(buffer, addr);
 582.206 -		m_list.InsertString(-1, buffer);
 582.207 -	}
 582.208 -	lastAddress = addr-1;
 582.209 -	if (sel != -1)
 582.210 -		m_list.SetCurSel(sel);
 582.211 -
 582.212 -	sprintf(buffer, "%04x", AF.W);
 582.213 -	GetDlgItem(IDC_R0)->SetWindowText(buffer);
 582.214 -	sprintf(buffer, "%04x", BC.W);
 582.215 -	GetDlgItem(IDC_R1)->SetWindowText(buffer);
 582.216 -	sprintf(buffer, "%04x", DE.W);
 582.217 -	GetDlgItem(IDC_R2)->SetWindowText(buffer);
 582.218 -	sprintf(buffer, "%04x", HL.W);
 582.219 -	GetDlgItem(IDC_R3)->SetWindowText(buffer);
 582.220 -	sprintf(buffer, "%04x", SP.W);
 582.221 -	GetDlgItem(IDC_R4)->SetWindowText(buffer);
 582.222 -	sprintf(buffer, "%04x", PC.W);
 582.223 -	GetDlgItem(IDC_R5)->SetWindowText(buffer);
 582.224 -	sprintf(buffer, "%04x", IFF);
 582.225 -	GetDlgItem(IDC_R6)->SetWindowText(buffer);
 582.226 -
 582.227 -	m_z = (AF.B.B0 & 0x80) != 0;
 582.228 -	m_n = (AF.B.B0 & 0x40) != 0;
 582.229 -	m_h = (AF.B.B0 & 0x20) != 0;
 582.230 -	m_c = (AF.B.B0 & 0x10) != 0;
 582.231 -	UpdateData(FALSE);
 582.232 -}
 582.233 -
 582.234 -void GBDisassemble::update()
 582.235 -{
 582.236 -	OnGopc();
 582.237 -	refresh();
 582.238 -}
 582.239 -
 582.240 -void GBDisassemble::PostNcDestroy()
 582.241 -{
 582.242 -	delete this;
 582.243 -}
 582.244 -
   583.1 --- a/src/win32/GBDisassemble.h	Sat Mar 03 10:54:39 2012 -0600
   583.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   583.3 @@ -1,69 +0,0 @@
   583.4 -#if !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_)
   583.5 -#define AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_
   583.6 -
   583.7 -#if _MSC_VER > 1000
   583.8 -#pragma once
   583.9 -#endif // _MSC_VER > 1000
  583.10 -// -*- C++ -*-
  583.11 -// GBDisassemble.h : header file
  583.12 -//
  583.13 -
  583.14 -#include "IUpdate.h"
  583.15 -#include "ResizeDlg.h"
  583.16 -
  583.17 -/////////////////////////////////////////////////////////////////////////////
  583.18 -// GBDisassemble dialog
  583.19 -
  583.20 -class GBDisassemble : public ResizeDlg, IUpdateListener
  583.21 -{
  583.22 -	// Construction
  583.23 -public:
  583.24 -	//bool autoUpdate;	// If these two variables are defined here, the dialog will crash!
  583.25 -	//u16  address;		// There might be a bug within MFC.
  583.26 -	virtual void update();
  583.27 -	void refresh();
  583.28 -	GBDisassemble(CWnd*pParent = NULL);  // standard constructor
  583.29 -
  583.30 -	// Dialog Data
  583.31 -	//{{AFX_DATA(GBDisassemble)
  583.32 -	enum { IDD = IDD_GB_DISASSEMBLE };
  583.33 -	CEdit    m_address;
  583.34 -	CListBox m_list;
  583.35 -	BOOL     m_c;
  583.36 -	BOOL     m_h;
  583.37 -	BOOL     m_n;
  583.38 -	BOOL     m_z;
  583.39 -	//}}AFX_DATA
  583.40 -	bool autoUpdate;
  583.41 -	int  count;
  583.42 -	u16  address;
  583.43 -	u16  lastAddress;
  583.44 -
  583.45 -	// Overrides
  583.46 -	// ClassWizard generated virtual function overrides
  583.47 -	//{{AFX_VIRTUAL(GBDisassemble)
  583.48 -protected:
  583.49 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  583.50 -	virtual void PostNcDestroy();
  583.51 -	//}}AFX_VIRTUAL
  583.52 -
  583.53 -	// Implementation
  583.54 -protected:
  583.55 -	// Generated message map functions
  583.56 -	//{{AFX_MSG(GBDisassemble)
  583.57 -	afx_msg void OnClose();
  583.58 -	afx_msg void OnRefresh();
  583.59 -	afx_msg void OnNext();
  583.60 -	afx_msg void OnGo();
  583.61 -	afx_msg void OnGopc();
  583.62 -	afx_msg void OnAutoUpdate();
  583.63 -	virtual BOOL OnInitDialog();
  583.64 -	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  583.65 -	//}}AFX_MSG
  583.66 -	DECLARE_MESSAGE_MAP()
  583.67 -};
  583.68 -
  583.69 -//{{AFX_INSERT_LOCATION}}
  583.70 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  583.71 -
  583.72 -#endif // !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_)
   584.1 --- a/src/win32/GBMapView.cpp	Sat Mar 03 10:54:39 2012 -0600
   584.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   584.3 @@ -1,589 +0,0 @@
   584.4 -// GBMapView.cpp : implementation file
   584.5 -//
   584.6 -
   584.7 -#include "stdafx.h"
   584.8 -#include "resource.h"
   584.9 -#include "GBMapView.h"
  584.10 -#include "FileDlg.h"
  584.11 -#include "Reg.h"
  584.12 -#include "WinResUtil.h"
  584.13 -#include "VBA.h"
  584.14 -
  584.15 -//#include "../common/System.h"
  584.16 -#include "../gb/gbGlobals.h"
  584.17 -#include "../NLS.h"
  584.18 -#include "../common/Util.h"
  584.19 -
  584.20 -extern "C" {
  584.21 -#include <png.h>
  584.22 -}
  584.23 -
  584.24 -extern u8 gbInvertTab[256];
  584.25 -
  584.26 -/////////////////////////////////////////////////////////////////////////////
  584.27 -// GBMapView dialog
  584.28 -
  584.29 -GBMapView::GBMapView(CWnd*pParent /*=NULL*/)
  584.30 -	: ResizeDlg(GBMapView::IDD, pParent)
  584.31 -{
  584.32 -	//{{AFX_DATA_INIT(GBMapView)
  584.33 -	// NOTE: the ClassWizard will add member initialization here
  584.34 -	//}}AFX_DATA_INIT
  584.35 -	autoUpdate = false;
  584.36 -
  584.37 -	memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
  584.38 -
  584.39 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  584.40 -	bmpInfo.bmiHeader.biWidth       = 1024;
  584.41 -	bmpInfo.bmiHeader.biHeight      = -1024;
  584.42 -	bmpInfo.bmiHeader.biPlanes      = 1;
  584.43 -	bmpInfo.bmiHeader.biBitCount    = 24;
  584.44 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  584.45 -	data = (u8 *)calloc(1, 3 * 1024 * 1024);
  584.46 -
  584.47 -	mapView.setData(data);
  584.48 -	mapView.setBmpInfo(&bmpInfo);
  584.49 -
  584.50 -	bg   = 0;
  584.51 -	bank = 0;
  584.52 -}
  584.53 -
  584.54 -void GBMapView::DoDataExchange(CDataExchange*pDX)
  584.55 -{
  584.56 -	CDialog::DoDataExchange(pDX);
  584.57 -	//{{AFX_DATA_MAP(GBMapView)
  584.58 -	// NOTE: the ClassWizard will add DDX and DDV calls here
  584.59 -	//}}AFX_DATA_MAP
  584.60 -	DDX_Control(pDX, IDC_MAP_VIEW, mapView);
  584.61 -	DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, mapViewZoom);
  584.62 -	DDX_Control(pDX, IDC_COLOR, color);
  584.63 -}
  584.64 -
  584.65 -BEGIN_MESSAGE_MAP(GBMapView, CDialog)
  584.66 -//{{AFX_MSG_MAP(GBMapView)
  584.67 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  584.68 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  584.69 -ON_BN_CLICKED(IDC_BG0, OnBg0)
  584.70 -ON_BN_CLICKED(IDC_BG1, OnBg1)
  584.71 -ON_BN_CLICKED(IDC_BANK_0, OnBank0)
  584.72 -ON_BN_CLICKED(IDC_BANK_1, OnBank1)
  584.73 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  584.74 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  584.75 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  584.76 -//}}AFX_MSG_MAP
  584.77 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  584.78 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  584.79 -END_MESSAGE_MAP()
  584.80 -
  584.81 -/////////////////////////////////////////////////////////////////////////////
  584.82 -// GBMapView message handlers
  584.83 -
  584.84 -GBMapView::~GBMapView()
  584.85 -{
  584.86 -	free(data);
  584.87 -	data = NULL;
  584.88 -}
  584.89 -
  584.90 -void GBMapView::saveBMP(const char *name)
  584.91 -{
  584.92 -	u8 writeBuffer[1024 * 3];
  584.93 -
  584.94 -	FILE *fp = fopen(name, "wb");
  584.95 -
  584.96 -	if (!fp)
  584.97 -	{
  584.98 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
  584.99 -		return;
 584.100 -	}
 584.101 -
 584.102 -	struct
 584.103 -	{
 584.104 -		u8 ident[2];
 584.105 -		u8 filesize[4];
 584.106 -		u8 reserved[4];
 584.107 -		u8 dataoffset[4];
 584.108 -		u8 headersize[4];
 584.109 -		u8 width[4];
 584.110 -		u8 height[4];
 584.111 -		u8 planes[2];
 584.112 -		u8 bitsperpixel[2];
 584.113 -		u8 compression[4];
 584.114 -		u8 datasize[4];
 584.115 -		u8 hres[4];
 584.116 -		u8 vres[4];
 584.117 -		u8 colors[4];
 584.118 -		u8 importantcolors[4];
 584.119 -		u8 pad[2];
 584.120 -	} bmpheader;
 584.121 -	memset(&bmpheader, 0, sizeof(bmpheader));
 584.122 -
 584.123 -	bmpheader.ident[0] = 'B';
 584.124 -	bmpheader.ident[1] = 'M';
 584.125 -
 584.126 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 584.127 -	utilPutDword(bmpheader.filesize, fsz);
 584.128 -	utilPutDword(bmpheader.dataoffset, 0x38);
 584.129 -	utilPutDword(bmpheader.headersize, 0x28);
 584.130 -	utilPutDword(bmpheader.width, w);
 584.131 -	utilPutDword(bmpheader.height, h);
 584.132 -	utilPutDword(bmpheader.planes, 1);
 584.133 -	utilPutDword(bmpheader.bitsperpixel, 24);
 584.134 -	utilPutDword(bmpheader.datasize, 3*w*h);
 584.135 -
 584.136 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 584.137 -
 584.138 -	u8 *b = writeBuffer;
 584.139 -
 584.140 -	int sizeX = w;
 584.141 -	int sizeY = h;
 584.142 -
 584.143 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 584.144 -	for (int y = 0; y < sizeY; y++)
 584.145 -	{
 584.146 -		for (int x = 0; x < sizeX; x++)
 584.147 -		{
 584.148 -			*b++ = *pixU8++; // B
 584.149 -			*b++ = *pixU8++; // G
 584.150 -			*b++ = *pixU8++; // R
 584.151 -		}
 584.152 -		pixU8 -= 2*3*w;
 584.153 -		fwrite(writeBuffer, 1, 3*w, fp);
 584.154 -
 584.155 -		b = writeBuffer;
 584.156 -	}
 584.157 -
 584.158 -	fclose(fp);
 584.159 -}
 584.160 -
 584.161 -void GBMapView::savePNG(const char *name)
 584.162 -{
 584.163 -	u8 writeBuffer[1024 * 3];
 584.164 -
 584.165 -	FILE *fp = fopen(name, "wb");
 584.166 -
 584.167 -	if (!fp)
 584.168 -	{
 584.169 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 584.170 -		return;
 584.171 -	}
 584.172 -
 584.173 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 584.174 -	                                              NULL,
 584.175 -	                                              NULL,
 584.176 -	                                              NULL);
 584.177 -	if (!png_ptr)
 584.178 -	{
 584.179 -		fclose(fp);
 584.180 -		return;
 584.181 -	}
 584.182 -
 584.183 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 584.184 -
 584.185 -	if (!info_ptr)
 584.186 -	{
 584.187 -		png_destroy_write_struct(&png_ptr, NULL);
 584.188 -		fclose(fp);
 584.189 -		return;
 584.190 -	}
 584.191 -
 584.192 -	if (setjmp(png_ptr->jmpbuf))
 584.193 -	{
 584.194 -		png_destroy_write_struct(&png_ptr, NULL);
 584.195 -		fclose(fp);
 584.196 -		return;
 584.197 -	}
 584.198 -
 584.199 -	png_init_io(png_ptr, fp);
 584.200 -
 584.201 -	png_set_IHDR(png_ptr,
 584.202 -	             info_ptr,
 584.203 -	             w,
 584.204 -	             h,
 584.205 -	             8,
 584.206 -	             PNG_COLOR_TYPE_RGB,
 584.207 -	             PNG_INTERLACE_NONE,
 584.208 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 584.209 -	             PNG_FILTER_TYPE_DEFAULT);
 584.210 -
 584.211 -	png_write_info(png_ptr, info_ptr);
 584.212 -
 584.213 -	u8 *b = writeBuffer;
 584.214 -
 584.215 -	int sizeX = w;
 584.216 -	int sizeY = h;
 584.217 -
 584.218 -	u8 *pixU8 = (u8 *)data;
 584.219 -	for (int y = 0; y < sizeY; y++)
 584.220 -	{
 584.221 -		for (int x = 0; x < sizeX; x++)
 584.222 -		{
 584.223 -			int blue  = *pixU8++;
 584.224 -			int green = *pixU8++;
 584.225 -			int red   = *pixU8++;
 584.226 -
 584.227 -			*b++ = red;
 584.228 -			*b++ = green;
 584.229 -			*b++ = blue;
 584.230 -		}
 584.231 -		png_write_row(png_ptr, writeBuffer);
 584.232 -
 584.233 -		b = writeBuffer;
 584.234 -	}
 584.235 -
 584.236 -	png_write_end(png_ptr, info_ptr);
 584.237 -
 584.238 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 584.239 -
 584.240 -	fclose(fp);
 584.241 -}
 584.242 -
 584.243 -void GBMapView::OnSave()
 584.244 -{
 584.245 -	CString filename;
 584.246 -
 584.247 -	if (theApp.captureFormat == 0)
 584.248 -		filename = "map.png";
 584.249 -	else
 584.250 -		filename = "map.bmp";
 584.251 -
 584.252 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 584.253 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 584.254 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 584.255 -
 584.256 -	FileDlg dlg(this,
 584.257 -	            filename,
 584.258 -	            filter,
 584.259 -	            theApp.captureFormat ? 2 : 1,
 584.260 -	            theApp.captureFormat ? "BMP" : "PNG",
 584.261 -	            exts,
 584.262 -	            "",
 584.263 -	            title,
 584.264 -	            true);
 584.265 -
 584.266 -	if (dlg.DoModal() == IDCANCEL)
 584.267 -	{
 584.268 -		return;
 584.269 -	}
 584.270 -
 584.271 -	if (dlg.getFilterIndex() == 2)
 584.272 -		saveBMP(dlg.GetPathName());
 584.273 -	else
 584.274 -		savePNG(dlg.GetPathName());
 584.275 -}
 584.276 -
 584.277 -void GBMapView::render()
 584.278 -{
 584.279 -	u8 *bank0;
 584.280 -	u8 *bank1;
 584.281 -	if (gbCgbMode)
 584.282 -	{
 584.283 -		bank0 = &gbVram[0x0000];
 584.284 -		bank1 = &gbVram[0x2000];
 584.285 -	}
 584.286 -	else
 584.287 -	{
 584.288 -		bank0 = &gbMemory[0x8000];
 584.289 -		bank1 = NULL;
 584.290 -	}
 584.291 -
 584.292 -	int tile_map_address = 0x1800;
 584.293 -	if (bg == 1)
 584.294 -		tile_map_address = 0x1c00;
 584.295 -
 584.296 -	int tile_pattern = 0x0000;
 584.297 -	if (bank == 1)
 584.298 -		tile_pattern = 0x0800;
 584.299 -
 584.300 -	w = 256;
 584.301 -	h = 256;
 584.302 -
 584.303 -	int tile = 0;
 584.304 -	for (int y = 0; y < 32; y++)
 584.305 -	{
 584.306 -		for (int x = 0; x < 32; x++)
 584.307 -		{
 584.308 -			u8 *bmp   = &data[y * 8 * 32 * 24 + x*24];
 584.309 -			u8  attrs = 0;
 584.310 -			if (bank1 != NULL)
 584.311 -				attrs = bank1[tile_map_address];
 584.312 -			u8 tile = bank0[tile_map_address];
 584.313 -			tile_map_address++;
 584.314 -
 584.315 -			if (bank == 1)
 584.316 -			{
 584.317 -				if (tile < 128)
 584.318 -					tile += 128;
 584.319 -				else
 584.320 -					tile -= 128;
 584.321 -			}
 584.322 -			for (int j = 0; j < 8; j++)
 584.323 -			{
 584.324 -				int tile_pattern_address = attrs & 0x40 ?
 584.325 -				                           tile_pattern + tile*16 + (7-j)*2 :
 584.326 -				                           tile_pattern + tile*16+j*2;
 584.327 -
 584.328 -				u8 tile_a = 0;
 584.329 -				u8 tile_b = 0;
 584.330 -
 584.331 -				if (attrs & 0x08)
 584.332 -				{
 584.333 -					tile_a = bank1[tile_pattern_address++];
 584.334 -					tile_b = bank1[tile_pattern_address];
 584.335 -				}
 584.336 -				else
 584.337 -				{
 584.338 -					tile_a = bank0[tile_pattern_address++];
 584.339 -					tile_b = bank0[tile_pattern_address];
 584.340 -				}
 584.341 -
 584.342 -				if (attrs & 0x20)
 584.343 -				{
 584.344 -					tile_a = gbInvertTab[tile_a];
 584.345 -					tile_b = gbInvertTab[tile_b];
 584.346 -				}
 584.347 -
 584.348 -				u8 mask = 0x80;
 584.349 -
 584.350 -				while (mask > 0)
 584.351 -				{
 584.352 -					u8 c = (tile_a & mask) ? 1 : 0;
 584.353 -					c += (tile_b & mask) ? 2 : 0;
 584.354 -
 584.355 -					if (gbCgbMode)
 584.356 -						c = c + (attrs & 7)*4;
 584.357 -
 584.358 -					u16 color = gbPalette[c];
 584.359 -
 584.360 -					*bmp++ = ((color >> 10) & 0x1f) << 3;
 584.361 -					*bmp++ = ((color >> 5) & 0x1f) << 3;
 584.362 -					*bmp++ = (color & 0x1f) << 3;
 584.363 -
 584.364 -					mask >>= 1;
 584.365 -				}
 584.366 -				bmp += 31*24;
 584.367 -			}
 584.368 -		}
 584.369 -	}
 584.370 -}
 584.371 -
 584.372 -void GBMapView::paint()
 584.373 -{
 584.374 -	if (gbRom == NULL)
 584.375 -		return;
 584.376 -	render();
 584.377 -
 584.378 -	SIZE s;
 584.379 -	if (mapView.getStretch())
 584.380 -	{
 584.381 -		mapView.setSize(w, h);
 584.382 -		s.cx = s.cy = 1;
 584.383 -		mapView.SetScrollSizes(MM_TEXT, s);
 584.384 -	}
 584.385 -	else
 584.386 -	{
 584.387 -		mapView.setSize(w, h);
 584.388 -		s.cx = w;
 584.389 -		s.cy = h;
 584.390 -		mapView.SetScrollSizes(MM_TEXT, s);
 584.391 -	}
 584.392 -
 584.393 -	mapView.refresh();
 584.394 -}
 584.395 -
 584.396 -void GBMapView::OnRefresh()
 584.397 -{
 584.398 -	paint();
 584.399 -}
 584.400 -
 584.401 -void GBMapView::update()
 584.402 -{
 584.403 -	paint();
 584.404 -}
 584.405 -
 584.406 -BOOL GBMapView::OnInitDialog()
 584.407 -{
 584.408 -	CDialog::OnInitDialog();
 584.409 -
 584.410 -	DIALOG_SIZER_START(sz)
 584.411 -	DIALOG_SIZER_ENTRY(IDC_MAP_VIEW, DS_SizeX | DS_SizeY)
 584.412 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 584.413 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 584.414 -	DIALOG_SIZER_ENTRY(IDC_SAVE,  DS_MoveY)
 584.415 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 584.416 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 584.417 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 584.418 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 584.419 -	DIALOG_SIZER_END()
 584.420 -	SetData(sz,
 584.421 -	        TRUE,
 584.422 -	        HKEY_CURRENT_USER,
 584.423 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBMapView",
 584.424 -	        NULL);
 584.425 -
 584.426 -	int s = regQueryDwordValue("mapViewStretch", 0);
 584.427 -	if (s)
 584.428 -		mapView.setStretch(true);
 584.429 -	((CButton *)GetDlgItem(IDC_STRETCH))->SetCheck(s);
 584.430 -
 584.431 -	UINT id = IDC_BANK_0;
 584.432 -	if (bank == 1)
 584.433 -		id = IDC_BANK_1;
 584.434 -	CheckRadioButton(IDC_BANK_0, IDC_BANK_1, id);
 584.435 -	id = IDC_BG0;
 584.436 -	if (bg == 1)
 584.437 -		id = IDC_BG1;
 584.438 -	CheckRadioButton(IDC_BG0, IDC_BG1, id);
 584.439 -	paint();
 584.440 -
 584.441 -	return TRUE; // return TRUE unless you set the focus to a control
 584.442 -	             // EXCEPTION: OCX Property Pages should return FALSE
 584.443 -}
 584.444 -
 584.445 -void GBMapView::OnBg0()
 584.446 -{
 584.447 -	bg = 0;
 584.448 -	paint();
 584.449 -}
 584.450 -
 584.451 -void GBMapView::OnBg1()
 584.452 -{
 584.453 -	bg = 1;
 584.454 -	paint();
 584.455 -}
 584.456 -
 584.457 -void GBMapView::OnBank0()
 584.458 -{
 584.459 -	bank = 0;
 584.460 -	paint();
 584.461 -}
 584.462 -
 584.463 -void GBMapView::OnBank1()
 584.464 -{
 584.465 -	bank = 1;
 584.466 -	paint();
 584.467 -}
 584.468 -
 584.469 -void GBMapView::OnStretch()
 584.470 -{
 584.471 -	mapView.setStretch(!mapView.getStretch());
 584.472 -	paint();
 584.473 -	regSetDwordValue("mapViewStretch", mapView.getStretch());
 584.474 -}
 584.475 -
 584.476 -void GBMapView::OnAutoUpdate()
 584.477 -{
 584.478 -	autoUpdate = !autoUpdate;
 584.479 -	if (autoUpdate)
 584.480 -	{
 584.481 -		theApp.winAddUpdateListener(this);
 584.482 -	}
 584.483 -	else
 584.484 -	{
 584.485 -		theApp.winRemoveUpdateListener(this);
 584.486 -	}
 584.487 -}
 584.488 -
 584.489 -void GBMapView::OnClose()
 584.490 -{
 584.491 -	theApp.winRemoveUpdateListener(this);
 584.492 -
 584.493 -	DestroyWindow();
 584.494 -}
 584.495 -
 584.496 -u32 GBMapView::GetClickAddress(int x, int y)
 584.497 -{
 584.498 -	u32 base = 0x9800;
 584.499 -	if (bg == 1)
 584.500 -		base = 0x9c00;
 584.501 -
 584.502 -	return base + (y >> 3)*32 + (x >> 3);
 584.503 -}
 584.504 -
 584.505 -LRESULT GBMapView::OnMapInfo(WPARAM wParam, LPARAM lParam)
 584.506 -{
 584.507 -	u8 *colors = (u8 *)lParam;
 584.508 -	mapViewZoom.setColors(colors);
 584.509 -
 584.510 -	int x = wParam & 0xffff;
 584.511 -	int y = (wParam >> 16);
 584.512 -
 584.513 -	CString buffer;
 584.514 -	buffer.Format("(%d,%d)", x, y);
 584.515 -	GetDlgItem(IDC_XY)->SetWindowText(buffer);
 584.516 -
 584.517 -	u32 address = GetClickAddress(x, y);
 584.518 -	buffer.Format("0x%08X", address);
 584.519 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 584.520 -
 584.521 -	u8 attrs = 0;
 584.522 -
 584.523 -	u8 tile = gbReadMemoryQuick(0x9000 | (address & 0xfff));
 584.524 -	if (gbCgbMode)
 584.525 -	{
 584.526 -		attrs = gbVram[0x2000 + address - 0x8000];
 584.527 -		tile  = gbVram[address & 0x1fff];
 584.528 -	}
 584.529 -
 584.530 -	if (bank == 1)
 584.531 -	{
 584.532 -		if (tile > 128)
 584.533 -			tile -= 128;
 584.534 -		else
 584.535 -			tile += 128;
 584.536 -	}
 584.537 -
 584.538 -	buffer.Format("%d", tile);
 584.539 -	GetDlgItem(IDC_TILE_NUM)->SetWindowText(buffer);
 584.540 -
 584.541 -	buffer.Empty();
 584.542 -	buffer += attrs & 0x20 ? 'H' : '-';
 584.543 -	buffer += attrs & 0x40 ? 'V' : '-';
 584.544 -	GetDlgItem(IDC_FLIP)->SetWindowText(buffer);
 584.545 -
 584.546 -	if (gbCgbMode)
 584.547 -	{
 584.548 -		buffer.Format("%d", (attrs & 7));
 584.549 -	}
 584.550 -	else
 584.551 -		buffer = "---";
 584.552 -	GetDlgItem(IDC_PALETTE_NUM)->SetWindowText(buffer);
 584.553 -
 584.554 -	buffer.Empty();
 584.555 -	if (gbCgbMode)
 584.556 -		buffer += attrs & 0x80 ? 'P' : '-';
 584.557 -	else
 584.558 -		buffer += '-';
 584.559 -	GetDlgItem(IDC_PRIORITY)->SetWindowText(buffer);
 584.560 -
 584.561 -	return TRUE;
 584.562 -}
 584.563 -
 584.564 -LRESULT GBMapView::OnColInfo(WPARAM wParam, LPARAM)
 584.565 -{
 584.566 -	u16 c = (u16)wParam;
 584.567 -
 584.568 -	color.setColor(c);
 584.569 -
 584.570 -	int r = (c & 0x1f);
 584.571 -	int g = (c & 0x3e0) >> 5;
 584.572 -	int b = (c & 0x7c00) >> 10;
 584.573 -
 584.574 -	CString buffer;
 584.575 -	buffer.Format("R: %d", r);
 584.576 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 584.577 -
 584.578 -	buffer.Format("G: %d", g);
 584.579 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 584.580 -
 584.581 -	buffer.Format("B: %d", b);
 584.582 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 584.583 -
 584.584 -	return TRUE;
 584.585 -}
 584.586 -
 584.587 -void GBMapView::PostNcDestroy()
 584.588 -{
 584.589 -	delete this;
 584.590 -	CDialog::PostNcDestroy();
 584.591 -}
 584.592 -
   585.1 --- a/src/win32/GBMapView.h	Sat Mar 03 10:54:39 2012 -0600
   585.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   585.3 @@ -1,81 +0,0 @@
   585.4 -#if !defined(AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_)
   585.5 -#define AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_
   585.6 -
   585.7 -#if _MSC_VER > 1000
   585.8 -#pragma once
   585.9 -#endif // _MSC_VER > 1000
  585.10 -// -*- C++ -*-
  585.11 -// GBMapView.h : header file
  585.12 -//
  585.13 -
  585.14 -#include "BitmapControl.h"
  585.15 -#include "ColorControl.h"
  585.16 -#include "ZoomControl.h"
  585.17 -#include "ResizeDlg.h"
  585.18 -#include "IUpdate.h"
  585.19 -
  585.20 -/////////////////////////////////////////////////////////////////////////////
  585.21 -// GBMapView dialog
  585.22 -
  585.23 -class GBMapView : public ResizeDlg, IUpdateListener
  585.24 -{
  585.25 -private:
  585.26 -	BITMAPINFO    bmpInfo;
  585.27 -	u8 *          data;
  585.28 -	int           bank;
  585.29 -	int           bg;
  585.30 -	int           w;
  585.31 -	int           h;
  585.32 -	BitmapControl mapView;
  585.33 -	ZoomControl   mapViewZoom;
  585.34 -	ColorControl  color;
  585.35 -	bool          autoUpdate;
  585.36 -	// Construction
  585.37 -public:
  585.38 -	afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  585.39 -	afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  585.40 -	u32 GetClickAddress(int x, int y);
  585.41 -	void update();
  585.42 -	void paint();
  585.43 -	void render();
  585.44 -	void savePNG(const char *name);
  585.45 -	void saveBMP(const char *name);
  585.46 -	~GBMapView();
  585.47 -	GBMapView(CWnd*pParent = NULL);  // standard constructor
  585.48 -
  585.49 -	// Dialog Data
  585.50 -	//{{AFX_DATA(GBMapView)
  585.51 -	enum { IDD = IDD_GB_MAP_VIEW };
  585.52 -	// NOTE: the ClassWizard will add data members here
  585.53 -	//}}AFX_DATA
  585.54 -
  585.55 -	// Overrides
  585.56 -	// ClassWizard generated virtual function overrides
  585.57 -	//{{AFX_VIRTUAL(GBMapView)
  585.58 -protected:
  585.59 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  585.60 -	virtual void PostNcDestroy();
  585.61 -	//}}AFX_VIRTUAL
  585.62 -
  585.63 -	// Implementation
  585.64 -protected:
  585.65 -	// Generated message map functions
  585.66 -	//{{AFX_MSG(GBMapView)
  585.67 -	afx_msg void OnSave();
  585.68 -	afx_msg void OnRefresh();
  585.69 -	virtual BOOL OnInitDialog();
  585.70 -	afx_msg void OnBg0();
  585.71 -	afx_msg void OnBg1();
  585.72 -	afx_msg void OnBank0();
  585.73 -	afx_msg void OnBank1();
  585.74 -	afx_msg void OnStretch();
  585.75 -	afx_msg void OnAutoUpdate();
  585.76 -	afx_msg void OnClose();
  585.77 -	//}}AFX_MSG
  585.78 -	DECLARE_MESSAGE_MAP()
  585.79 -};
  585.80 -
  585.81 -//{{AFX_INSERT_LOCATION}}
  585.82 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  585.83 -
  585.84 -#endif // !defined(AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_)
   586.1 --- a/src/win32/GBMemoryViewerDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   586.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   586.3 @@ -1,448 +0,0 @@
   586.4 -// GBMemoryViewerDlg.cpp : implementation file
   586.5 -//
   586.6 -
   586.7 -#include "stdafx.h"
   586.8 -#include "resource.h"
   586.9 -#include "GBMemoryViewerDlg.h"
  586.10 -#include "FileDlg.h"
  586.11 -#include "MemoryViewerAddressSize.h"
  586.12 -#include "Reg.h"
  586.13 -#include "WinResUtil.h"
  586.14 -#include "VBA.h"
  586.15 -
  586.16 -//#include "../common/System.h"
  586.17 -#include "../gb/gbGlobals.h"
  586.18 -
  586.19 -GBMemoryViewer::GBMemoryViewer()
  586.20 -	: MemoryViewer()
  586.21 -{
  586.22 -	setAddressSize(1);
  586.23 -}
  586.24 -
  586.25 -void GBMemoryViewer::readData(u32 address, int len, u8 *data)
  586.26 -{
  586.27 -	u16 addr = address & 0xffff;
  586.28 -	if (emulating && gbRom != NULL)
  586.29 -	{
  586.30 -		for (int i = 0; i < len; i++)
  586.31 -		{
  586.32 -			*data++ = gbReadMemoryQuick(addr);
  586.33 -			addr++;
  586.34 -		}
  586.35 -	}
  586.36 -	else
  586.37 -	{
  586.38 -		for (int i = 0; i < len; i++)
  586.39 -		{
  586.40 -			*data++ = 0;
  586.41 -			addr++;
  586.42 -		}
  586.43 -	}
  586.44 -}
  586.45 -
  586.46 -void GBMemoryViewer::editData(u32 address, int size, int mask, u32 value)
  586.47 -{
  586.48 -	u32 oldValue;
  586.49 -	u16 addr = (u16)address & 0xffff;
  586.50 -	switch (size)
  586.51 -	{
  586.52 -	case 8:
  586.53 -		oldValue  = gbReadMemoryQuick(addr);
  586.54 -		oldValue &= mask;
  586.55 -		oldValue |= (u8)value;
  586.56 -		gbWriteMemoryQuick(addr, oldValue);
  586.57 -		break;
  586.58 -	case 16:
  586.59 -		oldValue = gbReadMemoryQuick(addr) |
  586.60 -		           (gbReadMemoryQuick(addr + 1) << 8);
  586.61 -		oldValue &= mask;
  586.62 -		oldValue |= (u16)value;
  586.63 -		gbWriteMemoryQuick(addr, (oldValue & 255));
  586.64 -		gbWriteMemoryQuick(addr+1, (oldValue >> 8));
  586.65 -		break;
  586.66 -	case 32:
  586.67 -		oldValue = gbReadMemoryQuick(addr) |
  586.68 -		           (gbReadMemoryQuick(addr + 1) << 8) |
  586.69 -		           (gbReadMemoryQuick(addr + 2) << 16) |
  586.70 -		           (gbReadMemoryQuick(addr + 3) << 24);
  586.71 -		oldValue &= mask;
  586.72 -		oldValue |= (u32)value;
  586.73 -		gbWriteMemoryQuick(addr, (oldValue & 255));
  586.74 -		gbWriteMemoryQuick(addr+1, (oldValue >> 8));
  586.75 -		gbWriteMemoryQuick(addr+2, (oldValue >> 16));
  586.76 -		gbWriteMemoryQuick(addr+3, (oldValue >> 24));
  586.77 -		break;
  586.78 -	}
  586.79 -}
  586.80 -
  586.81 -/////////////////////////////////////////////////////////////////////////////
  586.82 -// GBMemoryViewerDlg dialog
  586.83 -
  586.84 -GBMemoryViewerDlg::GBMemoryViewerDlg(CWnd*pParent /*=NULL*/)
  586.85 -	: ResizeDlg(GBMemoryViewerDlg::IDD, pParent)
  586.86 -{
  586.87 -	//{{AFX_DATA_INIT(GBMemoryViewerDlg)
  586.88 -	m_size = -1;
  586.89 -	//}}AFX_DATA_INIT
  586.90 -	autoUpdate = false;
  586.91 -}
  586.92 -
  586.93 -void GBMemoryViewerDlg::DoDataExchange(CDataExchange*pDX)
  586.94 -{
  586.95 -	CDialog::DoDataExchange(pDX);
  586.96 -	//{{AFX_DATA_MAP(GBMemoryViewerDlg)
  586.97 -	DDX_Control(pDX, IDC_CURRENT_ADDRESS, m_current);
  586.98 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
  586.99 -	DDX_Control(pDX, IDC_ADDRESSES, m_addresses);
 586.100 -	DDX_Radio(pDX, IDC_8_BIT, m_size);
 586.101 -	//}}AFX_DATA_MAP
 586.102 -	DDX_Control(pDX, IDC_VIEWER, m_viewer);
 586.103 -}
 586.104 -
 586.105 -BEGIN_MESSAGE_MAP(GBMemoryViewerDlg, CDialog)
 586.106 -//{{AFX_MSG_MAP(GBMemoryViewerDlg)
 586.107 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
 586.108 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
 586.109 -ON_BN_CLICKED(IDC_8_BIT, On8Bit)
 586.110 -ON_BN_CLICKED(IDC_16_BIT, On16Bit)
 586.111 -ON_BN_CLICKED(IDC_32_BIT, On32Bit)
 586.112 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
 586.113 -ON_BN_CLICKED(IDC_DECIMAL_DISPLAY, OnDecimalDisplay)
 586.114 -ON_BN_CLICKED(IDC_ALIGN, OnAlign)
 586.115 -ON_BN_CLICKED(IDC_GO, OnGo)
 586.116 -ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses)
 586.117 -ON_BN_CLICKED(IDC_SAVE, OnSave)
 586.118 -ON_BN_CLICKED(IDC_LOAD, OnLoad)
 586.119 -//}}AFX_MSG_MAP
 586.120 -END_MESSAGE_MAP()
 586.121 -
 586.122 -/////////////////////////////////////////////////////////////////////////////
 586.123 -// GBMemoryViewerDlg message handlers
 586.124 -
 586.125 -BOOL GBMemoryViewerDlg::OnInitDialog()
 586.126 -{
 586.127 -	CDialog::OnInitDialog();
 586.128 -
 586.129 -	autoUpdate = !regQueryDwordValue("memViewerAutoUpdate", 1);
 586.130 -	OnAutoUpdate(); // inverts and update dialog
 586.131 -
 586.132 -	decimalDisplay = !regQueryDwordValue("memViewerDecimalDisplay", 0);
 586.133 -	OnDecimalDisplay();
 586.134 -
 586.135 -	align = !regQueryDwordValue("memViewerAlign", 0);
 586.136 -	OnAlign();
 586.137 -
 586.138 -	DIALOG_SIZER_START(sz)
 586.139 -	DIALOG_SIZER_ENTRY(IDC_VIEWER, DS_SizeX | DS_SizeY)
 586.140 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 586.141 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 586.142 -	DIALOG_SIZER_ENTRY(IDC_LOAD, DS_MoveY)
 586.143 -	DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
 586.144 -	DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveY)
 586.145 -	DIALOG_SIZER_ENTRY(IDC_DECIMAL_DISPLAY, DS_MoveY)
 586.146 -	DIALOG_SIZER_ENTRY(IDC_ALIGN, DS_MoveY)
 586.147 -	DIALOG_SIZER_ENTRY(IDC_CURRENT_ADDRESS_LABEL, DS_MoveY | DS_MoveX)
 586.148 -	DIALOG_SIZER_ENTRY(IDC_CURRENT_ADDRESS, DS_MoveY | DS_MoveX)
 586.149 -	DIALOG_SIZER_END()
 586.150 -	SetData(sz,
 586.151 -	        TRUE,
 586.152 -	        HKEY_CURRENT_USER,
 586.153 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBMemoryView",
 586.154 -	        NULL);
 586.155 -
 586.156 -	m_viewer.setDialog(this);
 586.157 -	m_viewer.ShowScrollBar(SB_VERT, TRUE);
 586.158 -	m_viewer.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH);
 586.159 -
 586.160 -	LPCTSTR s[] = {
 586.161 -		"0x0000 - ROM",
 586.162 -		"0x4000 - ROM",
 586.163 -		"0x8000 - VRAM",
 586.164 -		"0xA000 - SRAM",
 586.165 -		"0xC000 - RAM",
 586.166 -		"0xD000 - WRAM",
 586.167 -		"0xFF00 - I/O",
 586.168 -		"0xFF80 - RAM"
 586.169 -	};
 586.170 -
 586.171 -	for (int i = 0; i < 8; i++)
 586.172 -		m_addresses.AddString(s[i]);
 586.173 -
 586.174 -	m_addresses.SetCurSel(0);
 586.175 -
 586.176 -	RECT cbSize;
 586.177 -	int  Height;
 586.178 -
 586.179 -	m_addresses.GetClientRect(&cbSize);
 586.180 -	Height  = m_addresses.GetItemHeight(-1);
 586.181 -	Height += m_addresses.GetItemHeight(0) * (9);
 586.182 -
 586.183 -	// Note: The use of SM_CYEDGE assumes that we're using Windows '95
 586.184 -	// Now add on the height of the border of the edit box
 586.185 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 586.186 -
 586.187 -	// The height of the border of the drop-down box
 586.188 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 586.189 -
 586.190 -	// now set the size of the window
 586.191 -	m_addresses.SetWindowPos(NULL,
 586.192 -	                         0, 0,
 586.193 -	                         cbSize.right, Height,
 586.194 -	                         SWP_NOMOVE | SWP_NOZORDER);
 586.195 -
 586.196 -	m_address.LimitText(8);
 586.197 -
 586.198 -	m_size = regQueryDwordValue("memViewerDataSize", 0);
 586.199 -	if (m_size < 0 || m_size > 2)
 586.200 -		m_size = 0;
 586.201 -	m_viewer.setSize(m_size);
 586.202 -	UpdateData(FALSE);
 586.203 -
 586.204 -	m_current.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
 586.205 -
 586.206 -	return TRUE; // return TRUE unless you set the focus to a control
 586.207 -	             // EXCEPTION: OCX Property Pages should return FALSE
 586.208 -}
 586.209 -
 586.210 -void GBMemoryViewerDlg::OnClose()
 586.211 -{
 586.212 -	theApp.winRemoveUpdateListener(this);
 586.213 -
 586.214 -	DestroyWindow();
 586.215 -}
 586.216 -
 586.217 -void GBMemoryViewerDlg::OnRefresh()
 586.218 -{
 586.219 -	m_viewer.Invalidate();
 586.220 -}
 586.221 -
 586.222 -void GBMemoryViewerDlg::update()
 586.223 -{
 586.224 -	OnRefresh();
 586.225 -}
 586.226 -
 586.227 -void GBMemoryViewerDlg::On8Bit()
 586.228 -{
 586.229 -	m_viewer.setSize(0);
 586.230 -	regSetDwordValue("memViewerDataSize", 0);
 586.231 -}
 586.232 -
 586.233 -void GBMemoryViewerDlg::On16Bit()
 586.234 -{
 586.235 -	m_viewer.setSize(1);
 586.236 -	regSetDwordValue("memViewerDataSize", 1);
 586.237 -}
 586.238 -
 586.239 -void GBMemoryViewerDlg::On32Bit()
 586.240 -{
 586.241 -	m_viewer.setSize(2);
 586.242 -	regSetDwordValue("memViewerDataSize", 2);
 586.243 -}
 586.244 -
 586.245 -void GBMemoryViewerDlg::OnAutoUpdate()
 586.246 -{
 586.247 -	autoUpdate = !autoUpdate;
 586.248 -	if (autoUpdate)
 586.249 -	{
 586.250 -		theApp.winAddUpdateListener(this);
 586.251 -	}
 586.252 -	else
 586.253 -	{
 586.254 -		theApp.winRemoveUpdateListener(this);
 586.255 -	}
 586.256 -	if (GetDlgItem(IDC_AUTO_UPDATE))
 586.257 -		((CButton *)GetDlgItem(IDC_AUTO_UPDATE))->SetCheck(autoUpdate ? TRUE : FALSE);
 586.258 -	regSetDwordValue("memViewerAutoUpdate", autoUpdate);
 586.259 -}
 586.260 -
 586.261 -void GBMemoryViewerDlg::OnDecimalDisplay()
 586.262 -{
 586.263 -	decimalDisplay = !decimalDisplay;
 586.264 -	m_viewer.setDecimal(decimalDisplay ? true : false);
 586.265 -	if (GetDlgItem(IDC_DECIMAL_DISPLAY))
 586.266 -		((CButton *)GetDlgItem(IDC_DECIMAL_DISPLAY))->SetCheck(decimalDisplay ? TRUE : FALSE);
 586.267 -
 586.268 -	regSetDwordValue("memViewerDecimalDisplay", decimalDisplay);
 586.269 -}
 586.270 -
 586.271 -void GBMemoryViewerDlg::OnAlign()
 586.272 -{
 586.273 -	align = !align;
 586.274 -	if (GetDlgItem(IDC_ALIGN))
 586.275 -		((CButton *)GetDlgItem(IDC_ALIGN))->SetCheck(align ? TRUE : FALSE);
 586.276 -
 586.277 -	regSetDwordValue("memViewerAlign", align);
 586.278 -}
 586.279 -
 586.280 -void GBMemoryViewerDlg::OnGo()
 586.281 -{
 586.282 -	CString buffer;
 586.283 -
 586.284 -	m_address.GetWindowText(buffer);
 586.285 -
 586.286 -	u32 address;
 586.287 -	sscanf(buffer, "%x", &address);
 586.288 -	if (align)
 586.289 -		address &= ~0xF;
 586.290 -	else
 586.291 -	{
 586.292 -		if (m_viewer.getSize() == 1)
 586.293 -			address &= ~1;
 586.294 -		else if (m_viewer.getSize() == 2)
 586.295 -			address &= ~3;
 586.296 -	}
 586.297 -	m_viewer.setAddress(address);
 586.298 -}
 586.299 -
 586.300 -void GBMemoryViewerDlg::OnSelchangeAddresses()
 586.301 -{
 586.302 -	int cur = m_addresses.GetCurSel();
 586.303 -
 586.304 -	switch (cur)
 586.305 -	{
 586.306 -	case 0:
 586.307 -		m_viewer.setAddress(0x0000);
 586.308 -		break;
 586.309 -	case 1:
 586.310 -		m_viewer.setAddress(0x4000);
 586.311 -		break;
 586.312 -	case 2:
 586.313 -		m_viewer.setAddress(0x8000);
 586.314 -		break;
 586.315 -	case 3:
 586.316 -		m_viewer.setAddress(0xa000);
 586.317 -		break;
 586.318 -	case 4:
 586.319 -		m_viewer.setAddress(0xc000);
 586.320 -		break;
 586.321 -	case 5:
 586.322 -		m_viewer.setAddress(0xd000);
 586.323 -		break;
 586.324 -	case 6:
 586.325 -		m_viewer.setAddress(0xff00);
 586.326 -		break;
 586.327 -	case 7:
 586.328 -		m_viewer.setAddress(0xff80);
 586.329 -		break;
 586.330 -	}
 586.331 -}
 586.332 -
 586.333 -void GBMemoryViewerDlg::setCurrentAddress(u32 address)
 586.334 -{
 586.335 -	CString buffer;
 586.336 -
 586.337 -	buffer.Format("0x%08X", address);
 586.338 -	m_current.SetWindowText(buffer);
 586.339 -}
 586.340 -
 586.341 -void GBMemoryViewerDlg::OnSave()
 586.342 -{
 586.343 -	MemoryViewerAddressSize dlg;
 586.344 -
 586.345 -	dlg.setAddress(m_viewer.getCurrentAddress());
 586.346 -
 586.347 -	LPCTSTR exts[] = { ".dmp", NULL };
 586.348 -
 586.349 -	CString filter = winResLoadFilter(IDS_FILTER_DUMP);
 586.350 -	CString title  = winResLoadString(IDS_SELECT_DUMP_FILE);
 586.351 -
 586.352 -	if (dlg.DoModal() == IDOK)
 586.353 -	{
 586.354 -		CString buffer;
 586.355 -		FileDlg file(this,
 586.356 -		             buffer,
 586.357 -		             filter,
 586.358 -		             0,
 586.359 -		             "DMP",
 586.360 -		             exts,
 586.361 -		             "",
 586.362 -		             title,
 586.363 -		             true);
 586.364 -		if (file.DoModal() == IDOK)
 586.365 -		{
 586.366 -			buffer = file.GetPathName();
 586.367 -			FILE *f = fopen(buffer, "wb");
 586.368 -
 586.369 -			if (f == NULL)
 586.370 -			{
 586.371 -				systemMessage(IDS_ERROR_CREATING_FILE, buffer);
 586.372 -				return;
 586.373 -			}
 586.374 -
 586.375 -			int size = dlg.getSize();
 586.376 -			u16 addr = dlg.getAddress() & 0xffff;
 586.377 -
 586.378 -			for (int i = 0; i < size; i++)
 586.379 -			{
 586.380 -				fputc(gbReadMemoryQuick(addr), f);
 586.381 -				addr++;
 586.382 -			}
 586.383 -
 586.384 -			fclose(f);
 586.385 -		}
 586.386 -	}
 586.387 -}
 586.388 -
 586.389 -void GBMemoryViewerDlg::OnLoad()
 586.390 -{
 586.391 -	CString buffer;
 586.392 -	LPCTSTR exts[] = { ".dmp", NULL };
 586.393 -	CString filter = winResLoadFilter(IDS_FILTER_DUMP);
 586.394 -	CString title  = winResLoadString(IDS_SELECT_DUMP_FILE);
 586.395 -
 586.396 -	FileDlg file(this,
 586.397 -	             buffer,
 586.398 -	             filter,
 586.399 -	             0,
 586.400 -	             "DMP",
 586.401 -	             exts,
 586.402 -	             "",
 586.403 -	             title,
 586.404 -	             false);
 586.405 -
 586.406 -	if (file.DoModal() == IDOK)
 586.407 -	{
 586.408 -		buffer = file.GetPathName();
 586.409 -		FILE *f = fopen(buffer, "rb");
 586.410 -		if (f == NULL)
 586.411 -		{
 586.412 -			systemMessage(IDS_CANNOT_OPEN_FILE,
 586.413 -			              "Cannot open file %s",
 586.414 -			              buffer);
 586.415 -			return;
 586.416 -		}
 586.417 -
 586.418 -		MemoryViewerAddressSize dlg;
 586.419 -
 586.420 -		fseek(f, 0, SEEK_END);
 586.421 -		int size = ftell(f);
 586.422 -
 586.423 -		fseek(f, 0, SEEK_SET);
 586.424 -
 586.425 -		dlg.setAddress(m_viewer.getCurrentAddress());
 586.426 -		dlg.setSize(size);
 586.427 -
 586.428 -		if (dlg.DoModal() == IDOK)
 586.429 -		{
 586.430 -			int size = dlg.getSize();
 586.431 -			u16 addr = dlg.getAddress() & 0xffff;
 586.432 -
 586.433 -			for (int i = 0; i < size; i++)
 586.434 -			{
 586.435 -				int c = fgetc(f);
 586.436 -				if (c == -1)
 586.437 -					break;
 586.438 -				gbWriteMemoryQuick(addr, c);
 586.439 -				addr++;
 586.440 -			}
 586.441 -			OnRefresh();
 586.442 -		}
 586.443 -		fclose(f);
 586.444 -	}
 586.445 -}
 586.446 -
 586.447 -void GBMemoryViewerDlg::PostNcDestroy()
 586.448 -{
 586.449 -	delete this;
 586.450 -}
 586.451 -
   587.1 --- a/src/win32/GBMemoryViewerDlg.h	Sat Mar 03 10:54:39 2012 -0600
   587.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   587.3 @@ -1,79 +0,0 @@
   587.4 -#if !defined(AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_)
   587.5 -#define AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_
   587.6 -
   587.7 -#if _MSC_VER > 1000
   587.8 -#pragma once
   587.9 -#endif // _MSC_VER > 1000
  587.10 -// -*- C++ -*-
  587.11 -// GBMemoryViewerDlg.h : header file
  587.12 -//
  587.13 -#include "MemoryViewer.h"
  587.14 -#include "ResizeDlg.h"
  587.15 -#include "IUpdate.h"
  587.16 -
  587.17 -class GBMemoryViewer : public MemoryViewer
  587.18 -{
  587.19 -public:
  587.20 -	GBMemoryViewer();
  587.21 -	virtual void readData(u32, int, u8 *);
  587.22 -	virtual void editData(u32, int, int, u32);
  587.23 -};
  587.24 -
  587.25 -/////////////////////////////////////////////////////////////////////////////
  587.26 -// GBMemoryViewerDlg dialog
  587.27 -
  587.28 -class GBMemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg
  587.29 -{
  587.30 -	GBMemoryViewer m_viewer;
  587.31 -	bool autoUpdate;
  587.32 -	int  decimalDisplay;
  587.33 -	int  align;
  587.34 -	// Construction
  587.35 -public:
  587.36 -	void setCurrentAddress(u32 address);
  587.37 -	GBMemoryViewerDlg(CWnd*pParent = NULL);  // standard constructor
  587.38 -
  587.39 -	virtual void update();
  587.40 -
  587.41 -	// Dialog Data
  587.42 -	//{{AFX_DATA(GBMemoryViewerDlg)
  587.43 -	enum { IDD = IDD_MEM_VIEWER };
  587.44 -	CEdit     m_current;
  587.45 -	CEdit     m_address;
  587.46 -	CComboBox m_addresses;
  587.47 -	int       m_size;
  587.48 -	//}}AFX_DATA
  587.49 -
  587.50 -	// Overrides
  587.51 -	// ClassWizard generated virtual function overrides
  587.52 -	//{{AFX_VIRTUAL(GBMemoryViewerDlg)
  587.53 -protected:
  587.54 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  587.55 -	virtual void PostNcDestroy();
  587.56 -	//}}AFX_VIRTUAL
  587.57 -
  587.58 -	// Implementation
  587.59 -protected:
  587.60 -	// Generated message map functions
  587.61 -	//{{AFX_MSG(GBMemoryViewerDlg)
  587.62 -	virtual BOOL OnInitDialog();
  587.63 -	afx_msg void OnClose();
  587.64 -	afx_msg void OnRefresh();
  587.65 -	afx_msg void On8Bit();
  587.66 -	afx_msg void On16Bit();
  587.67 -	afx_msg void On32Bit();
  587.68 -	afx_msg void OnAutoUpdate();
  587.69 -	afx_msg void OnDecimalDisplay();
  587.70 -	afx_msg void OnAlign();
  587.71 -	afx_msg void OnGo();
  587.72 -	afx_msg void OnSelchangeAddresses();
  587.73 -	afx_msg void OnSave();
  587.74 -	afx_msg void OnLoad();
  587.75 -	//}}AFX_MSG
  587.76 -	DECLARE_MESSAGE_MAP()
  587.77 -};
  587.78 -
  587.79 -//{{AFX_INSERT_LOCATION}}
  587.80 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  587.81 -
  587.82 -#endif // !defined(AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_)
   588.1 --- a/src/win32/GBOamView.cpp	Sat Mar 03 10:54:39 2012 -0600
   588.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   588.3 @@ -1,598 +0,0 @@
   588.4 -// GBOamView.cpp : implementation file
   588.5 -//
   588.6 -
   588.7 -#include "stdafx.h"
   588.8 -#include "resource.h"
   588.9 -#include "GBOamView.h"
  588.10 -#include "FileDlg.h"
  588.11 -#include "Reg.h"
  588.12 -#include "WinResUtil.h"
  588.13 -#include "VBA.h"
  588.14 -
  588.15 -//#include "../common/System.h"
  588.16 -#include "../gb/gbGlobals.h"
  588.17 -#include "../NLS.h"
  588.18 -#include "../common/Util.h"
  588.19 -
  588.20 -extern "C" {
  588.21 -#include <png.h>
  588.22 -}
  588.23 -
  588.24 -/////////////////////////////////////////////////////////////////////////////
  588.25 -// GBOamView dialog
  588.26 -
  588.27 -GBOamView::GBOamView(CWnd*pParent /*=NULL*/)
  588.28 -	: ResizeDlg(GBOamView::IDD, pParent)
  588.29 -{
  588.30 -	//{{AFX_DATA_INIT(GBOamView)
  588.31 -	m_stretch = FALSE;
  588.32 -	//}}AFX_DATA_INIT
  588.33 -	autoUpdate = false;
  588.34 -
  588.35 -	memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
  588.36 -
  588.37 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  588.38 -	bmpInfo.bmiHeader.biWidth       = 8;
  588.39 -	bmpInfo.bmiHeader.biHeight      = 16;
  588.40 -	bmpInfo.bmiHeader.biPlanes      = 1;
  588.41 -	bmpInfo.bmiHeader.biBitCount    = 24;
  588.42 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  588.43 -	data = (u8 *)calloc(1, 3 * 8 * 16);
  588.44 -
  588.45 -	oamView.setData(data);
  588.46 -	oamView.setBmpInfo(&bmpInfo);
  588.47 -
  588.48 -	number = 0;
  588.49 -}
  588.50 -
  588.51 -void GBOamView::DoDataExchange(CDataExchange*pDX)
  588.52 -{
  588.53 -	CDialog::DoDataExchange(pDX);
  588.54 -	//{{AFX_DATA_MAP(GBOamView)
  588.55 -	DDX_Control(pDX, IDC_SPRITE, m_sprite);
  588.56 -	DDX_Check(pDX, IDC_STRETCH, m_stretch);
  588.57 -	//}}AFX_DATA_MAP
  588.58 -	DDX_Control(pDX, IDC_COLOR, color);
  588.59 -	DDX_Control(pDX, IDC_OAM_VIEW, oamView);
  588.60 -	DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom);
  588.61 -}
  588.62 -
  588.63 -BEGIN_MESSAGE_MAP(GBOamView, CDialog)
  588.64 -//{{AFX_MSG_MAP(GBOamView)
  588.65 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  588.66 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  588.67 -ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite)
  588.68 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  588.69 -ON_WM_HSCROLL()
  588.70 -//}}AFX_MSG_MAP
  588.71 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  588.72 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  588.73 -END_MESSAGE_MAP()
  588.74 -
  588.75 -/////////////////////////////////////////////////////////////////////////////
  588.76 -// GBOamView message handlers
  588.77 -
  588.78 -GBOamView::~GBOamView()
  588.79 -{
  588.80 -	free(data);
  588.81 -	data = NULL;
  588.82 -}
  588.83 -
  588.84 -void GBOamView::paint()
  588.85 -{
  588.86 -	if (gbRom == NULL)
  588.87 -		return;
  588.88 -
  588.89 -	render();
  588.90 -	oamView.setSize(w, h);
  588.91 -	oamView.refresh();
  588.92 -}
  588.93 -
  588.94 -void GBOamView::update()
  588.95 -{
  588.96 -	paint();
  588.97 -}
  588.98 -
  588.99 -void GBOamView::setAttributes(int y, int x, int tile, int flags)
 588.100 -{
 588.101 -	CString buffer;
 588.102 -
 588.103 -	int flipH = flags & 0x20;
 588.104 -	int flipV = flags & 0x40;
 588.105 -	int prio  = (flags & 0x80) >> 7;
 588.106 -	int pal   = flags & 0x7;
 588.107 -	int oap   = (flags & 0x08) >> 3;
 588.108 -	int bank  = (flags & 0x10) >> 4;
 588.109 -
 588.110 -	buffer.Format("%d,%d", x, y);
 588.111 -	GetDlgItem(IDC_POS)->SetWindowText(buffer);
 588.112 -
 588.113 -	buffer.Format("%d", pal);
 588.114 -	GetDlgItem(IDC_PALETTE)->SetWindowText(buffer);
 588.115 -
 588.116 -	buffer.Format("%d", tile);
 588.117 -	GetDlgItem(IDC_TILE)->SetWindowText(buffer);
 588.118 -
 588.119 -	buffer.Format("%d", prio);
 588.120 -	GetDlgItem(IDC_PRIO)->SetWindowText(buffer);
 588.121 -
 588.122 -	buffer.Format("%d", bank);
 588.123 -	GetDlgItem(IDC_BANK)->SetWindowText(buffer);
 588.124 -
 588.125 -	buffer.Empty();
 588.126 -	if (flipH)
 588.127 -		buffer += 'H';
 588.128 -	else
 588.129 -		buffer += ' ';
 588.130 -	if (flipV)
 588.131 -		buffer += 'V';
 588.132 -	else
 588.133 -		buffer += ' ';
 588.134 -	GetDlgItem(IDC_FLAGS)->SetWindowText(buffer);
 588.135 -
 588.136 -	buffer.Format("%d", oap);
 588.137 -	GetDlgItem(IDC_OAP)->SetWindowText(buffer);
 588.138 -}
 588.139 -
 588.140 -void GBOamView::render()
 588.141 -{
 588.142 -	int m = 0;
 588.143 -	if (gbRom == NULL)
 588.144 -		return;
 588.145 -
 588.146 -	u16 addr = number * 4 + 0xfe00;
 588.147 -
 588.148 -	int size = register_LCDC & 4;
 588.149 -
 588.150 -	u8 y    = gbReadMemoryQuick(addr++);
 588.151 -	u8 x    = gbReadMemoryQuick(addr++);
 588.152 -	u8 tile = gbReadMemoryQuick(addr++);
 588.153 -	if (size)
 588.154 -		tile &= 254;
 588.155 -	u8 flags = gbReadMemoryQuick(addr++);
 588.156 -
 588.157 -	u8 *bmp = data;
 588.158 -
 588.159 -	w = 8;
 588.160 -	h = size ? 16 : 8;
 588.161 -
 588.162 -	setAttributes(y, x, tile, flags);
 588.163 -
 588.164 -	u8 *bank0;
 588.165 -	u8 *bank1;
 588.166 -	if (gbCgbMode)
 588.167 -	{
 588.168 -		if (register_VBK & 1)
 588.169 -		{
 588.170 -			bank0 = &gbVram[0x0000];
 588.171 -			bank1 = &gbVram[0x2000];
 588.172 -		}
 588.173 -		else
 588.174 -		{
 588.175 -			bank0 = &gbVram[0x0000];
 588.176 -			bank1 = &gbVram[0x2000];
 588.177 -		}
 588.178 -	}
 588.179 -	else
 588.180 -	{
 588.181 -		bank0 = &gbMemory[0x8000];
 588.182 -		bank1 = NULL;
 588.183 -	}
 588.184 -
 588.185 -	int init = 0x0000;
 588.186 -
 588.187 -	u8 *pal = gbObp0;
 588.188 -
 588.189 -	if ((flags & 0x10))
 588.190 -		pal = gbObp1;
 588.191 -
 588.192 -	for (int yy = 0; yy < h; yy++)
 588.193 -	{
 588.194 -		int address = init + tile * 16 + 2*yy;
 588.195 -		int a       = 0;
 588.196 -		int b       = 0;
 588.197 -
 588.198 -		if (gbCgbMode && flags & 0x08)
 588.199 -		{
 588.200 -			a = bank1[address++];
 588.201 -			b = bank1[address++];
 588.202 -		}
 588.203 -		else
 588.204 -		{
 588.205 -			a = bank0[address++];
 588.206 -			b = bank0[address++];
 588.207 -		}
 588.208 -
 588.209 -		for (int xx = 0; xx < 8; xx++)
 588.210 -		{
 588.211 -			u8 mask = 1 << (7-xx);
 588.212 -			u8 c    = 0;
 588.213 -			if ((a & mask))
 588.214 -				c++;
 588.215 -			if ((b & mask))
 588.216 -				c += 2;
 588.217 -
 588.218 -			// make sure that sprites will work even in CGB mode
 588.219 -			if (gbCgbMode)
 588.220 -			{
 588.221 -				c = c + (flags & 0x07)*4 + 32;
 588.222 -			}
 588.223 -			else
 588.224 -			{
 588.225 -				c = pal[c];
 588.226 -			}
 588.227 -
 588.228 -			u16 color = gbPalette[c];
 588.229 -			*bmp++ = ((color >> 10) & 0x1f) << 3;
 588.230 -			*bmp++ = ((color >> 5) & 0x1f) << 3;
 588.231 -			*bmp++ = (color & 0x1f) << 3;
 588.232 -		}
 588.233 -	}
 588.234 -}
 588.235 -
 588.236 -void GBOamView::saveBMP(const char *name)
 588.237 -{
 588.238 -	u8 writeBuffer[1024 * 3];
 588.239 -
 588.240 -	FILE *fp = fopen(name, "wb");
 588.241 -
 588.242 -	if (!fp)
 588.243 -	{
 588.244 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 588.245 -		return;
 588.246 -	}
 588.247 -
 588.248 -	struct
 588.249 -	{
 588.250 -		u8 ident[2];
 588.251 -		u8 filesize[4];
 588.252 -		u8 reserved[4];
 588.253 -		u8 dataoffset[4];
 588.254 -		u8 headersize[4];
 588.255 -		u8 width[4];
 588.256 -		u8 height[4];
 588.257 -		u8 planes[2];
 588.258 -		u8 bitsperpixel[2];
 588.259 -		u8 compression[4];
 588.260 -		u8 datasize[4];
 588.261 -		u8 hres[4];
 588.262 -		u8 vres[4];
 588.263 -		u8 colors[4];
 588.264 -		u8 importantcolors[4];
 588.265 -		u8 pad[2];
 588.266 -	} bmpheader;
 588.267 -	memset(&bmpheader, 0, sizeof(bmpheader));
 588.268 -
 588.269 -	bmpheader.ident[0] = 'B';
 588.270 -	bmpheader.ident[1] = 'M';
 588.271 -
 588.272 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 588.273 -	utilPutDword(bmpheader.filesize, fsz);
 588.274 -	utilPutDword(bmpheader.dataoffset, 0x38);
 588.275 -	utilPutDword(bmpheader.headersize, 0x28);
 588.276 -	utilPutDword(bmpheader.width, w);
 588.277 -	utilPutDword(bmpheader.height, h);
 588.278 -	utilPutDword(bmpheader.planes, 1);
 588.279 -	utilPutDword(bmpheader.bitsperpixel, 24);
 588.280 -	utilPutDword(bmpheader.datasize, 3*w*h);
 588.281 -
 588.282 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 588.283 -
 588.284 -	u8 *b = writeBuffer;
 588.285 -
 588.286 -	int sizeX = w;
 588.287 -	int sizeY = h;
 588.288 -
 588.289 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 588.290 -	for (int y = 0; y < sizeY; y++)
 588.291 -	{
 588.292 -		for (int x = 0; x < sizeX; x++)
 588.293 -		{
 588.294 -			*b++ = *pixU8++; // B
 588.295 -			*b++ = *pixU8++; // G
 588.296 -			*b++ = *pixU8++; // R
 588.297 -		}
 588.298 -		pixU8 -= 2*3*w;
 588.299 -		fwrite(writeBuffer, 1, 3*w, fp);
 588.300 -
 588.301 -		b = writeBuffer;
 588.302 -	}
 588.303 -
 588.304 -	fclose(fp);
 588.305 -}
 588.306 -
 588.307 -void GBOamView::savePNG(const char *name)
 588.308 -{
 588.309 -	u8 writeBuffer[1024 * 3];
 588.310 -
 588.311 -	FILE *fp = fopen(name, "wb");
 588.312 -
 588.313 -	if (!fp)
 588.314 -	{
 588.315 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 588.316 -		return;
 588.317 -	}
 588.318 -
 588.319 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 588.320 -	                                              NULL,
 588.321 -	                                              NULL,
 588.322 -	                                              NULL);
 588.323 -	if (!png_ptr)
 588.324 -	{
 588.325 -		fclose(fp);
 588.326 -		return;
 588.327 -	}
 588.328 -
 588.329 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 588.330 -
 588.331 -	if (!info_ptr)
 588.332 -	{
 588.333 -		png_destroy_write_struct(&png_ptr, NULL);
 588.334 -		fclose(fp);
 588.335 -		return;
 588.336 -	}
 588.337 -
 588.338 -	if (setjmp(png_ptr->jmpbuf))
 588.339 -	{
 588.340 -		png_destroy_write_struct(&png_ptr, NULL);
 588.341 -		fclose(fp);
 588.342 -		return;
 588.343 -	}
 588.344 -
 588.345 -	png_init_io(png_ptr, fp);
 588.346 -
 588.347 -	png_set_IHDR(png_ptr,
 588.348 -	             info_ptr,
 588.349 -	             w,
 588.350 -	             h,
 588.351 -	             8,
 588.352 -	             PNG_COLOR_TYPE_RGB,
 588.353 -	             PNG_INTERLACE_NONE,
 588.354 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 588.355 -	             PNG_FILTER_TYPE_DEFAULT);
 588.356 -
 588.357 -	png_write_info(png_ptr, info_ptr);
 588.358 -
 588.359 -	u8 *b = writeBuffer;
 588.360 -
 588.361 -	int sizeX = w;
 588.362 -	int sizeY = h;
 588.363 -
 588.364 -	u8 *pixU8 = (u8 *)data;
 588.365 -	for (int y = 0; y < sizeY; y++)
 588.366 -	{
 588.367 -		for (int x = 0; x < sizeX; x++)
 588.368 -		{
 588.369 -			int blue  = *pixU8++;
 588.370 -			int green = *pixU8++;
 588.371 -			int red   = *pixU8++;
 588.372 -
 588.373 -			*b++ = red;
 588.374 -			*b++ = green;
 588.375 -			*b++ = blue;
 588.376 -		}
 588.377 -		png_write_row(png_ptr, writeBuffer);
 588.378 -
 588.379 -		b = writeBuffer;
 588.380 -	}
 588.381 -
 588.382 -	png_write_end(png_ptr, info_ptr);
 588.383 -
 588.384 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 588.385 -
 588.386 -	fclose(fp);
 588.387 -}
 588.388 -
 588.389 -void GBOamView::save()
 588.390 -{
 588.391 -	CString captureBuffer;
 588.392 -
 588.393 -	if (theApp.captureFormat == 0)
 588.394 -		captureBuffer = "oam.png";
 588.395 -	else
 588.396 -		captureBuffer = "oam.bmp";
 588.397 -
 588.398 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 588.399 -
 588.400 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 588.401 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 588.402 -
 588.403 -	FileDlg dlg(this,
 588.404 -	            captureBuffer,
 588.405 -	            filter,
 588.406 -	            theApp.captureFormat ? 2 : 1,
 588.407 -	            theApp.captureFormat ? "BMP" : "PNG",
 588.408 -	            exts,
 588.409 -	            "",
 588.410 -	            title,
 588.411 -	            true);
 588.412 -
 588.413 -	if (dlg.DoModal() == IDCANCEL)
 588.414 -	{
 588.415 -		return;
 588.416 -	}
 588.417 -	captureBuffer = dlg.GetPathName();
 588.418 -
 588.419 -	if (dlg.getFilterIndex() == 2)
 588.420 -		saveBMP(captureBuffer);
 588.421 -	else
 588.422 -		savePNG(captureBuffer);
 588.423 -}
 588.424 -
 588.425 -BOOL GBOamView::OnInitDialog()
 588.426 -{
 588.427 -	CDialog::OnInitDialog();
 588.428 -
 588.429 -	DIALOG_SIZER_START(sz)
 588.430 -	DIALOG_SIZER_ENTRY(IDC_OAM_VIEW, DS_SizeX | DS_SizeY)
 588.431 -	DIALOG_SIZER_ENTRY(IDC_OAM_VIEW_ZOOM, DS_MoveX)
 588.432 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 588.433 -	DIALOG_SIZER_ENTRY(IDC_SAVE,  DS_MoveY)
 588.434 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 588.435 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 588.436 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 588.437 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 588.438 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 588.439 -	DIALOG_SIZER_END()
 588.440 -	SetData(sz,
 588.441 -	        TRUE,
 588.442 -	        HKEY_CURRENT_USER,
 588.443 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBOamView",
 588.444 -	        NULL);
 588.445 -
 588.446 -	m_sprite.SetWindowText("0");
 588.447 -
 588.448 -	updateScrollInfo();
 588.449 -
 588.450 -	m_stretch = regQueryDwordValue("GBOamViewStretch", 0);
 588.451 -	if (m_stretch)
 588.452 -		oamView.setStretch(true);
 588.453 -	UpdateData(FALSE);
 588.454 -
 588.455 -	paint();
 588.456 -
 588.457 -	return TRUE; // return TRUE unless you set the focus to a control
 588.458 -	             // EXCEPTION: OCX Property Pages should return FALSE
 588.459 -}
 588.460 -
 588.461 -void GBOamView::OnStretch()
 588.462 -{
 588.463 -	oamView.setStretch(!oamView.getStretch());
 588.464 -	paint();
 588.465 -	regSetDwordValue("GBOamViewStretch", oamView.getStretch());
 588.466 -}
 588.467 -
 588.468 -void GBOamView::OnAutoUpdate()
 588.469 -{
 588.470 -	autoUpdate = !autoUpdate;
 588.471 -	if (autoUpdate)
 588.472 -	{
 588.473 -		theApp.winAddUpdateListener(this);
 588.474 -	}
 588.475 -	else
 588.476 -	{
 588.477 -		theApp.winRemoveUpdateListener(this);
 588.478 -	}
 588.479 -}
 588.480 -
 588.481 -void GBOamView::OnChangeSprite()
 588.482 -{
 588.483 -	CString buffer;
 588.484 -	m_sprite.GetWindowText(buffer);
 588.485 -	int n = atoi(buffer);
 588.486 -	if (n < 0 || n > 39)
 588.487 -	{
 588.488 -		buffer.Format("%d", number);
 588.489 -		m_sprite.SetWindowText(buffer);
 588.490 -		return;
 588.491 -	}
 588.492 -	number = n;
 588.493 -	paint();
 588.494 -	updateScrollInfo();
 588.495 -}
 588.496 -
 588.497 -void GBOamView::OnClose()
 588.498 -{
 588.499 -	theApp.winRemoveUpdateListener(this);
 588.500 -
 588.501 -	DestroyWindow();
 588.502 -}
 588.503 -
 588.504 -LRESULT GBOamView::OnMapInfo(WPARAM, LPARAM lParam)
 588.505 -{
 588.506 -	u8 *colors = (u8 *)lParam;
 588.507 -	oamZoom.setColors(colors);
 588.508 -
 588.509 -	return TRUE;
 588.510 -}
 588.511 -
 588.512 -LRESULT GBOamView::OnColInfo(WPARAM wParam, LPARAM lParam)
 588.513 -{
 588.514 -	u16 c = (u16)wParam;
 588.515 -
 588.516 -	color.setColor(c);
 588.517 -
 588.518 -	int r = (c & 0x1f);
 588.519 -	int g = (c & 0x3e0) >> 5;
 588.520 -	int b = (c & 0x7c00) >> 10;
 588.521 -
 588.522 -	CString buffer;
 588.523 -	buffer.Format("R: %d", r);
 588.524 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 588.525 -
 588.526 -	buffer.Format("G: %d", g);
 588.527 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 588.528 -
 588.529 -	buffer.Format("B: %d", b);
 588.530 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 588.531 -
 588.532 -	return TRUE;
 588.533 -}
 588.534 -
 588.535 -void GBOamView::updateScrollInfo()
 588.536 -{
 588.537 -	SCROLLINFO si;
 588.538 -	ZeroMemory(&si, sizeof(si));
 588.539 -	si.cbSize = sizeof(si);
 588.540 -	si.fMask  = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS;
 588.541 -	si.nMin   = 0;
 588.542 -	si.nMax   = 39;
 588.543 -	si.nPage  = 1;
 588.544 -	si.nPos   = number;
 588.545 -	GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL,
 588.546 -	                                         &si,
 588.547 -	                                         TRUE);
 588.548 -}
 588.549 -
 588.550 -void GBOamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 588.551 -{
 588.552 -	switch (nSBCode)
 588.553 -	{
 588.554 -	case SB_BOTTOM:
 588.555 -		number = 39;
 588.556 -		break;
 588.557 -	case SB_LINEDOWN:
 588.558 -		number++;
 588.559 -		if (number > 39)
 588.560 -			number = 39;
 588.561 -		break;
 588.562 -	case SB_LINEUP:
 588.563 -		number--;
 588.564 -		if (number < 0)
 588.565 -			number = 0;
 588.566 -		break;
 588.567 -	case SB_PAGEDOWN:
 588.568 -		number += 16;
 588.569 -		if (number > 39)
 588.570 -			number = 39;
 588.571 -		break;
 588.572 -	case SB_PAGEUP:
 588.573 -		number -= 16;
 588.574 -		if (number < 0)
 588.575 -			number = 0;
 588.576 -		break;
 588.577 -	case SB_TOP:
 588.578 -		number = 0;
 588.579 -		break;
 588.580 -	case SB_THUMBTRACK:
 588.581 -		number = nPos;
 588.582 -		if (number < 0)
 588.583 -			number = 0;
 588.584 -		if (number > 39)
 588.585 -			number = 39;
 588.586 -		break;
 588.587 -	}
 588.588 -
 588.589 -	updateScrollInfo();
 588.590 -
 588.591 -	CString buffer;
 588.592 -	buffer.Format("%d", number);
 588.593 -	m_sprite.SetWindowText(buffer);
 588.594 -	paint();
 588.595 -}
 588.596 -
 588.597 -void GBOamView::PostNcDestroy()
 588.598 -{
 588.599 -	delete this;
 588.600 -}
 588.601 -
   589.1 --- a/src/win32/GBOamView.h	Sat Mar 03 10:54:39 2012 -0600
   589.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   589.3 @@ -1,82 +0,0 @@
   589.4 -#if !defined(AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_)
   589.5 -#define AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_
   589.6 -
   589.7 -#if _MSC_VER > 1000
   589.8 -#pragma once
   589.9 -#endif // _MSC_VER > 1000
  589.10 -// -*- C++ -*-
  589.11 -// GBOamView.h : header file
  589.12 -//
  589.13 -
  589.14 -#include "BitmapControl.h"
  589.15 -#include "ZoomControl.h"
  589.16 -#include "ColorControl.h"
  589.17 -
  589.18 -#include "IUpdate.h"
  589.19 -#include "ResizeDlg.h"
  589.20 -
  589.21 -/////////////////////////////////////////////////////////////////////////////
  589.22 -// GBOamView dialog
  589.23 -
  589.24 -class GBOamView : public ResizeDlg, IUpdateListener
  589.25 -{
  589.26 -private:
  589.27 -	BITMAPINFO    bmpInfo;
  589.28 -	u8 *          data;
  589.29 -	int           w;
  589.30 -	int           h;
  589.31 -	int           number;
  589.32 -	bool          autoUpdate;
  589.33 -	BitmapControl oamView;
  589.34 -	ZoomControl   oamZoom;
  589.35 -	ColorControl  color;
  589.36 -
  589.37 -	// Construction
  589.38 -public:
  589.39 -	void updateScrollInfo();
  589.40 -	void save();
  589.41 -	void savePNG(const char *name);
  589.42 -	void saveBMP(const char *name);
  589.43 -	void render();
  589.44 -	void setAttributes(int y, int x, int tile, int flags);
  589.45 -	void paint();
  589.46 -	~GBOamView();
  589.47 -	GBOamView(CWnd*pParent = NULL);  // standard constructor
  589.48 -
  589.49 -	afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  589.50 -	afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  589.51 -	virtual void update();
  589.52 -
  589.53 -	// Dialog Data
  589.54 -	//{{AFX_DATA(GBOamView)
  589.55 -	enum { IDD = IDD_GB_OAM_VIEW };
  589.56 -	CEdit m_sprite;
  589.57 -	BOOL  m_stretch;
  589.58 -	//}}AFX_DATA
  589.59 -
  589.60 -	// Overrides
  589.61 -	// ClassWizard generated virtual function overrides
  589.62 -	//{{AFX_VIRTUAL(GBOamView)
  589.63 -protected:
  589.64 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  589.65 -	virtual void PostNcDestroy();
  589.66 -	//}}AFX_VIRTUAL
  589.67 -
  589.68 -	// Implementation
  589.69 -protected:
  589.70 -	// Generated message map functions
  589.71 -	//{{AFX_MSG(GBOamView)
  589.72 -	virtual BOOL OnInitDialog();
  589.73 -	afx_msg void OnStretch();
  589.74 -	afx_msg void OnAutoUpdate();
  589.75 -	afx_msg void OnChangeSprite();
  589.76 -	afx_msg void OnClose();
  589.77 -	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  589.78 -	//}}AFX_MSG
  589.79 -	DECLARE_MESSAGE_MAP()
  589.80 -};
  589.81 -
  589.82 -//{{AFX_INSERT_LOCATION}}
  589.83 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  589.84 -
  589.85 -#endif // !defined(AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_)
   590.1 --- a/src/win32/GBPaletteView.cpp	Sat Mar 03 10:54:39 2012 -0600
   590.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   590.3 @@ -1,219 +0,0 @@
   590.4 -// GBPaletteView.cpp : implementation file
   590.5 -//
   590.6 -
   590.7 -#include "stdafx.h"
   590.8 -#include "resource.h"
   590.9 -#include "GBPaletteView.h"
  590.10 -#include "FileDlg.h"
  590.11 -#include "WinResUtil.h"
  590.12 -#include "VBA.h"
  590.13 -
  590.14 -#include "../gb/gbGlobals.h"
  590.15 -
  590.16 -void GBPaletteViewControl::updatePalette()
  590.17 -{
  590.18 -	if (gbRom)
  590.19 -	{
  590.20 -		memcpy(palette, &gbPalette[paletteAddress], 64);
  590.21 -	}
  590.22 -}
  590.23 -
  590.24 -/////////////////////////////////////////////////////////////////////////////
  590.25 -// GBPaletteView dialog
  590.26 -
  590.27 -GBPaletteView::GBPaletteView(CWnd*pParent /*=NULL*/)
  590.28 -	: ResizeDlg(GBPaletteView::IDD, pParent)
  590.29 -{
  590.30 -	//{{AFX_DATA_INIT(GBPaletteView)
  590.31 -	// NOTE: the ClassWizard will add member initialization here
  590.32 -	//}}AFX_DATA_INIT
  590.33 -	autoUpdate = false;
  590.34 -}
  590.35 -
  590.36 -GBPaletteView::~GBPaletteView()
  590.37 -{}
  590.38 -
  590.39 -void GBPaletteView::DoDataExchange(CDataExchange*pDX)
  590.40 -{
  590.41 -	CDialog::DoDataExchange(pDX);
  590.42 -	//{{AFX_DATA_MAP(GBPaletteView)
  590.43 -	// NOTE: the ClassWizard will add DDX and DDV calls here
  590.44 -	//}}AFX_DATA_MAP
  590.45 -	DDX_Control(pDX, IDC_PALETTE_VIEW, paletteView);
  590.46 -	DDX_Control(pDX, IDC_PALETTE_VIEW_OBJ, paletteViewOBJ);
  590.47 -	DDX_Control(pDX, IDC_COLOR, colorControl);
  590.48 -}
  590.49 -
  590.50 -BEGIN_MESSAGE_MAP(GBPaletteView, CDialog)
  590.51 -//{{AFX_MSG_MAP(GBPaletteView)
  590.52 -ON_BN_CLICKED(IDC_SAVE_BG, OnSaveBg)
  590.53 -ON_BN_CLICKED(IDC_SAVE_OBJ, OnSaveObj)
  590.54 -ON_BN_CLICKED(IDC_REFRESH2, OnRefresh2)
  590.55 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  590.56 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  590.57 -//}}AFX_MSG_MAP
  590.58 -ON_MESSAGE(WM_PALINFO, OnPalInfo)
  590.59 -END_MESSAGE_MAP()
  590.60 -
  590.61 -/////////////////////////////////////////////////////////////////////////////
  590.62 -// GBPaletteView message handlers
  590.63 -
  590.64 -BOOL GBPaletteView::OnInitDialog()
  590.65 -{
  590.66 -	CDialog::OnInitDialog();
  590.67 -
  590.68 -	DIALOG_SIZER_START(sz)
  590.69 -	DIALOG_SIZER_END()
  590.70 -    SetData(sz,
  590.71 -            FALSE,
  590.72 -            HKEY_CURRENT_USER,
  590.73 -            "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBPaletteView",
  590.74 -            NULL);
  590.75 -
  590.76 -	paletteView.init(32, 64, 128);
  590.77 -	paletteViewOBJ.init(32, 64, 128);
  590.78 -
  590.79 -	paletteView.setPaletteAddress(0);
  590.80 -	paletteView.refresh();
  590.81 -
  590.82 -	paletteViewOBJ.setPaletteAddress(32);
  590.83 -	paletteViewOBJ.refresh();
  590.84 -
  590.85 -	return TRUE; // return TRUE unless you set the focus to a control
  590.86 -	             // EXCEPTION: OCX Property Pages should return FALSE
  590.87 -}
  590.88 -
  590.89 -void GBPaletteView::save(int which)
  590.90 -{
  590.91 -	CString captureBuffer;
  590.92 -
  590.93 -	if (which == 0)
  590.94 -		captureBuffer = "bg.pal";
  590.95 -	else
  590.96 -		captureBuffer = "obj.pal";
  590.97 -
  590.98 -	LPCTSTR exts[] = {".pal", ".pal", ".act", NULL };
  590.99 -
 590.100 -	CString filter = winResLoadFilter(IDS_FILTER_PAL);
 590.101 -	CString title  = winResLoadString(IDS_SELECT_PALETTE_NAME);
 590.102 -	FileDlg dlg(this,
 590.103 -	            captureBuffer,
 590.104 -	            filter,
 590.105 -	            1,
 590.106 -	            "PAL",
 590.107 -	            exts,
 590.108 -	            "",
 590.109 -	            title,
 590.110 -	            true);
 590.111 -
 590.112 -	if (dlg.DoModal() == IDCANCEL)
 590.113 -	{
 590.114 -		return;
 590.115 -	}
 590.116 -
 590.117 -	PaletteViewControl *p = NULL;
 590.118 -
 590.119 -	if (which == 0)
 590.120 -		p = &paletteView;
 590.121 -	else
 590.122 -		p = &paletteViewOBJ;
 590.123 -
 590.124 -	switch (dlg.getFilterIndex())
 590.125 -	{
 590.126 -	case 0:
 590.127 -	case 1:
 590.128 -		p->saveMSPAL(captureBuffer);
 590.129 -		break;
 590.130 -	case 2:
 590.131 -		p->saveJASCPAL(captureBuffer);
 590.132 -		break;
 590.133 -	case 3:
 590.134 -		p->saveAdobe(captureBuffer);
 590.135 -		break;
 590.136 -	}
 590.137 -}
 590.138 -
 590.139 -void GBPaletteView::OnSaveBg()
 590.140 -{
 590.141 -	save(0);
 590.142 -}
 590.143 -
 590.144 -void GBPaletteView::OnSaveObj()
 590.145 -{
 590.146 -	save(1);
 590.147 -}
 590.148 -
 590.149 -void GBPaletteView::OnRefresh2()
 590.150 -{
 590.151 -	paletteView.refresh();
 590.152 -	paletteViewOBJ.refresh();
 590.153 -}
 590.154 -
 590.155 -void GBPaletteView::update()
 590.156 -{
 590.157 -	OnRefresh2();
 590.158 -}
 590.159 -
 590.160 -void GBPaletteView::OnAutoUpdate()
 590.161 -{
 590.162 -	autoUpdate = !autoUpdate;
 590.163 -	if (autoUpdate)
 590.164 -	{
 590.165 -		theApp.winAddUpdateListener(this);
 590.166 -	}
 590.167 -	else
 590.168 -	{
 590.169 -		theApp.winRemoveUpdateListener(this);
 590.170 -	}
 590.171 -}
 590.172 -
 590.173 -void GBPaletteView::OnClose()
 590.174 -{
 590.175 -	theApp.winRemoveUpdateListener(this);
 590.176 -
 590.177 -	DestroyWindow();
 590.178 -}
 590.179 -
 590.180 -LRESULT GBPaletteView::OnPalInfo(WPARAM wParam, LPARAM lParam)
 590.181 -{
 590.182 -	u16     color   = (u16)wParam;
 590.183 -	u32     address = (u32)lParam;
 590.184 -	CString buffer;
 590.185 -
 590.186 -	bool isOBJ = address >= 32;
 590.187 -	address &= 31;
 590.188 -
 590.189 -	buffer.Format("%d", address);
 590.190 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 590.191 -
 590.192 -	int r = (color & 0x1f);
 590.193 -	int g = (color & 0x3e0) >> 5;
 590.194 -	int b = (color & 0x7c00) >> 10;
 590.195 -
 590.196 -	buffer.Format("%d", r);
 590.197 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 590.198 -
 590.199 -	buffer.Format("%d", g);
 590.200 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 590.201 -
 590.202 -	buffer.Format("%d", b);
 590.203 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 590.204 -
 590.205 -	buffer.Format("0x%04X", color);
 590.206 -	GetDlgItem(IDC_VALUE)->SetWindowText(buffer);
 590.207 -
 590.208 -	colorControl.setColor(color);
 590.209 -
 590.210 -	if (isOBJ)
 590.211 -		paletteView.setSelected(-1);
 590.212 -	else
 590.213 -		paletteViewOBJ.setSelected(-1);
 590.214 -
 590.215 -	return TRUE;
 590.216 -}
 590.217 -
 590.218 -void GBPaletteView::PostNcDestroy()
 590.219 -{
 590.220 -	delete this;
 590.221 -}
 590.222 -
   591.1 --- a/src/win32/GBPaletteView.h	Sat Mar 03 10:54:39 2012 -0600
   591.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   591.3 @@ -1,72 +0,0 @@
   591.4 -#if !defined(AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_)
   591.5 -#define AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_
   591.6 -
   591.7 -#if _MSC_VER > 1000
   591.8 -#pragma once
   591.9 -#endif // _MSC_VER > 1000
  591.10 -// -*- C++ -*-
  591.11 -// GBPaletteView.h : header file
  591.12 -//
  591.13 -
  591.14 -#include "ColorControl.h"
  591.15 -#include "IUpdate.h"
  591.16 -#include "PaletteViewControl.h"
  591.17 -#include "ResizeDlg.h"
  591.18 -
  591.19 -class GBPaletteViewControl : public PaletteViewControl
  591.20 -{
  591.21 -public:
  591.22 -	virtual void updatePalette();
  591.23 -};
  591.24 -
  591.25 -/////////////////////////////////////////////////////////////////////////////
  591.26 -// GBPaletteView dialog
  591.27 -
  591.28 -class GBPaletteView : public ResizeDlg, IUpdateListener
  591.29 -{
  591.30 -private:
  591.31 -	GBPaletteViewControl paletteView;
  591.32 -	GBPaletteViewControl paletteViewOBJ;
  591.33 -	ColorControl         colorControl;
  591.34 -	bool autoUpdate;
  591.35 -	// Construction
  591.36 -public:
  591.37 -	void save(int which);
  591.38 -	GBPaletteView(CWnd*pParent = NULL);  // standard constructor
  591.39 -	virtual ~GBPaletteView();
  591.40 -
  591.41 -	// Dialog Data
  591.42 -	//{{AFX_DATA(GBPaletteView)
  591.43 -	enum { IDD = IDD_GB_PALETTE_VIEW };
  591.44 -	// NOTE: the ClassWizard will add data members here
  591.45 -	//}}AFX_DATA
  591.46 -
  591.47 -	// Overrides
  591.48 -	// ClassWizard generated virtual function overrides
  591.49 -	//{{AFX_VIRTUAL(GBPaletteView)
  591.50 -protected:
  591.51 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  591.52 -	virtual void PostNcDestroy();
  591.53 -	//}}AFX_VIRTUAL
  591.54 -
  591.55 -	virtual void update();
  591.56 -
  591.57 -	// Implementation
  591.58 -protected:
  591.59 -	afx_msg virtual LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam);
  591.60 -	// Generated message map functions
  591.61 -	//{{AFX_MSG(GBPaletteView)
  591.62 -	virtual BOOL OnInitDialog();
  591.63 -	afx_msg void OnSaveBg();
  591.64 -	afx_msg void OnSaveObj();
  591.65 -	afx_msg void OnRefresh2();
  591.66 -	afx_msg void OnAutoUpdate();
  591.67 -	afx_msg void OnClose();
  591.68 -	//}}AFX_MSG
  591.69 -	DECLARE_MESSAGE_MAP()
  591.70 -};
  591.71 -
  591.72 -//{{AFX_INSERT_LOCATION}}
  591.73 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  591.74 -
  591.75 -#endif // !defined(AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_)
   592.1 --- a/src/win32/GBPrinterDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   592.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   592.3 @@ -1,485 +0,0 @@
   592.4 -// GBPrinter.cpp : implementation file
   592.5 -//
   592.6 -
   592.7 -#include "stdafx.h"
   592.8 -#include "resource.h"
   592.9 -#include "GBPrinterDlg.h"
  592.10 -#include "FileDlg.h"
  592.11 -#include "Reg.h"
  592.12 -#include "WinResUtil.h"
  592.13 -#include "VBA.h"
  592.14 -
  592.15 -//#include "../common/System.h"
  592.16 -#include "../NLS.h"
  592.17 -#include "../common/Util.h"
  592.18 -
  592.19 -extern "C" {
  592.20 -#include <png.h>
  592.21 -}
  592.22 -
  592.23 -/////////////////////////////////////////////////////////////////////////////
  592.24 -// GBPrinter dialog
  592.25 -
  592.26 -GBPrinterDlg::GBPrinterDlg(CWnd*pParent /*=NULL*/)
  592.27 -	: CDialog(GBPrinterDlg::IDD, pParent)
  592.28 -{
  592.29 -	//{{AFX_DATA_INIT(GBPrinterDlg)
  592.30 -	m_scale = -1;
  592.31 -	//}}AFX_DATA_INIT
  592.32 -	bitmap = (BITMAPINFO *)bitmapHeader;
  592.33 -
  592.34 -	bitmap->bmiHeader.biSize            = sizeof(BITMAPINFOHEADER);
  592.35 -	bitmap->bmiHeader.biWidth           = 160;
  592.36 -	bitmap->bmiHeader.biHeight          = -144;
  592.37 -	bitmap->bmiHeader.biPlanes          = 1;
  592.38 -	bitmap->bmiHeader.biBitCount        = 8;
  592.39 -	bitmap->bmiHeader.biCompression     = BI_RGB;
  592.40 -	bitmap->bmiHeader.biSizeImage       = 160*144;
  592.41 -	bitmap->bmiHeader.biXPelsPerMeter   = 0;
  592.42 -	bitmap->bmiHeader.biYPelsPerMeter   = 0;
  592.43 -	bitmap->bmiHeader.biClrUsed         = 4;
  592.44 -	bitmap->bmiHeader.biClrImportant    = 4;
  592.45 -	bitmap->bmiColors[0].rgbBlue        =
  592.46 -	    bitmap->bmiColors[0].rgbGreen   =
  592.47 -	        bitmap->bmiColors[0].rgbRed =
  592.48 -	            255;
  592.49 -	bitmap->bmiColors[0].rgbReserved    = 0;
  592.50 -	bitmap->bmiColors[1].rgbBlue        =
  592.51 -	    bitmap->bmiColors[1].rgbGreen   =
  592.52 -	        bitmap->bmiColors[1].rgbRed =
  592.53 -	            168;
  592.54 -	bitmap->bmiColors[1].rgbReserved    = 0;
  592.55 -	bitmap->bmiColors[2].rgbBlue        =
  592.56 -	    bitmap->bmiColors[2].rgbGreen   =
  592.57 -	        bitmap->bmiColors[2].rgbRed =
  592.58 -	            96;
  592.59 -	bitmap->bmiColors[2].rgbReserved    = 0;
  592.60 -	bitmap->bmiColors[3].rgbBlue        =
  592.61 -	    bitmap->bmiColors[3].rgbGreen   =
  592.62 -	        bitmap->bmiColors[3].rgbRed =
  592.63 -	            0;
  592.64 -	bitmap->bmiColors[3].rgbReserved = 0;
  592.65 -}
  592.66 -
  592.67 -void GBPrinterDlg::DoDataExchange(CDataExchange*pDX)
  592.68 -{
  592.69 -	CDialog::DoDataExchange(pDX);
  592.70 -	//{{AFX_DATA_MAP(GBPrinterDlg)
  592.71 -	DDX_Radio(pDX, IDC_1X, m_scale);
  592.72 -	//}}AFX_DATA_MAP
  592.73 -}
  592.74 -
  592.75 -BEGIN_MESSAGE_MAP(GBPrinterDlg, CDialog)
  592.76 -//{{AFX_MSG_MAP(GBPrinterDlg)
  592.77 -ON_BN_CLICKED(ID_SAVE, OnSave)
  592.78 -ON_BN_CLICKED(ID_PRINT, OnPrint)
  592.79 -ON_BN_CLICKED(ID_OK, OnOk)
  592.80 -ON_BN_CLICKED(IDC_1X, On1x)
  592.81 -ON_BN_CLICKED(IDC_2X, On2x)
  592.82 -ON_BN_CLICKED(IDC_3X, On3x)
  592.83 -ON_BN_CLICKED(IDC_4X, On4x)
  592.84 -ON_WM_PAINT()
  592.85 -//}}AFX_MSG_MAP
  592.86 -END_MESSAGE_MAP()
  592.87 -
  592.88 -/////////////////////////////////////////////////////////////////////////////
  592.89 -// GBPrinter message handlers
  592.90 -
  592.91 -void GBPrinterDlg::saveAsBMP(const char *name)
  592.92 -{
  592.93 -	u8 writeBuffer[512 * 3];
  592.94 -
  592.95 -	FILE *fp = fopen(name, "wb");
  592.96 -
  592.97 -	if (!fp)
  592.98 -	{
  592.99 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 592.100 -		return;
 592.101 -	}
 592.102 -
 592.103 -	struct
 592.104 -	{
 592.105 -		u8 ident[2];
 592.106 -		u8 filesize[4];
 592.107 -		u8 reserved[4];
 592.108 -		u8 dataoffset[4];
 592.109 -		u8 headersize[4];
 592.110 -		u8 width[4];
 592.111 -		u8 height[4];
 592.112 -		u8 planes[2];
 592.113 -		u8 bitsperpixel[2];
 592.114 -		u8 compression[4];
 592.115 -		u8 datasize[4];
 592.116 -		u8 hres[4];
 592.117 -		u8 vres[4];
 592.118 -		u8 colors[4];
 592.119 -		u8 importantcolors[4];
 592.120 -		u8 pad[2];
 592.121 -	} bmpheader;
 592.122 -	memset(&bmpheader, 0, sizeof(bmpheader));
 592.123 -
 592.124 -	bmpheader.ident[0] = 'B';
 592.125 -	bmpheader.ident[1] = 'M';
 592.126 -
 592.127 -	u32 fsz = sizeof(bmpheader) + 160*144*3;
 592.128 -	utilPutDword(bmpheader.filesize, fsz);
 592.129 -	utilPutDword(bmpheader.dataoffset, 0x38);
 592.130 -	utilPutDword(bmpheader.headersize, 0x28);
 592.131 -	utilPutDword(bmpheader.width, 160);
 592.132 -	utilPutDword(bmpheader.height, 144);
 592.133 -	utilPutDword(bmpheader.planes, 1);
 592.134 -	utilPutDword(bmpheader.bitsperpixel, 24);
 592.135 -	utilPutDword(bmpheader.datasize, 160*144);
 592.136 -
 592.137 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 592.138 -
 592.139 -	u8 *b    = writeBuffer;
 592.140 -	u8 *data = (u8 *)bitmapData;
 592.141 -	u8 *p    = data + (160*143);
 592.142 -	for (int y = 0; y < 144; y++)
 592.143 -	{
 592.144 -		for (int x = 0; x < 160; x++)
 592.145 -		{
 592.146 -			u8 c = *p++;
 592.147 -
 592.148 -			*b++ = bitmap->bmiColors[c].rgbBlue;
 592.149 -			*b++ = bitmap->bmiColors[c].rgbGreen;
 592.150 -			*b++ = bitmap->bmiColors[c].rgbRed;
 592.151 -		}
 592.152 -		p -= 2*(160);
 592.153 -		fwrite(writeBuffer, 1, 3*160, fp);
 592.154 -
 592.155 -		b = writeBuffer;
 592.156 -	}
 592.157 -
 592.158 -	fclose(fp);
 592.159 -}
 592.160 -
 592.161 -void GBPrinterDlg::saveAsPNG(const char *name)
 592.162 -{
 592.163 -	u8 writeBuffer[160 * 3];
 592.164 -
 592.165 -	FILE *fp = fopen(name, "wb");
 592.166 -
 592.167 -	if (!fp)
 592.168 -	{
 592.169 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
 592.170 -		              name);
 592.171 -		return;
 592.172 -	}
 592.173 -
 592.174 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 592.175 -	                                              NULL,
 592.176 -	                                              NULL,
 592.177 -	                                              NULL);
 592.178 -	if (!png_ptr)
 592.179 -	{
 592.180 -		fclose(fp);
 592.181 -		return;
 592.182 -	}
 592.183 -
 592.184 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 592.185 -
 592.186 -	if (!info_ptr)
 592.187 -	{
 592.188 -		png_destroy_write_struct(&png_ptr, NULL);
 592.189 -		fclose(fp);
 592.190 -		return;
 592.191 -	}
 592.192 -
 592.193 -	if (setjmp(png_ptr->jmpbuf))
 592.194 -	{
 592.195 -		png_destroy_write_struct(&png_ptr, NULL);
 592.196 -		fclose(fp);
 592.197 -		return;
 592.198 -	}
 592.199 -
 592.200 -	png_init_io(png_ptr, fp);
 592.201 -
 592.202 -	png_set_IHDR(png_ptr,
 592.203 -	             info_ptr,
 592.204 -	             160,
 592.205 -	             144,
 592.206 -	             8,
 592.207 -	             PNG_COLOR_TYPE_RGB,
 592.208 -	             PNG_INTERLACE_NONE,
 592.209 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 592.210 -	             PNG_FILTER_TYPE_DEFAULT);
 592.211 -
 592.212 -	png_write_info(png_ptr, info_ptr);
 592.213 -
 592.214 -	u8 *b = writeBuffer;
 592.215 -
 592.216 -	int sizeX = 160;
 592.217 -	int sizeY = 144;
 592.218 -
 592.219 -	u8 *pixU8 = (u8 *)bitmapData;
 592.220 -	for (int y = 0; y < sizeY; y++)
 592.221 -	{
 592.222 -		for (int x = 0; x < sizeX; x++)
 592.223 -		{
 592.224 -			u8 c = *pixU8++;
 592.225 -			*b++ = bitmap->bmiColors[c].rgbRed;
 592.226 -			*b++ = bitmap->bmiColors[c].rgbGreen;
 592.227 -			*b++ = bitmap->bmiColors[c].rgbBlue;
 592.228 -		}
 592.229 -		png_write_row(png_ptr, writeBuffer);
 592.230 -
 592.231 -		b = writeBuffer;
 592.232 -	}
 592.233 -
 592.234 -	png_write_end(png_ptr, info_ptr);
 592.235 -
 592.236 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 592.237 -
 592.238 -	fclose(fp);
 592.239 -}
 592.240 -
 592.241 -void GBPrinterDlg::OnSave()
 592.242 -{
 592.243 -	CString captureBuffer;
 592.244 -
 592.245 -	if (theApp.captureFormat == 0)
 592.246 -		captureBuffer = "printer.png";
 592.247 -	else
 592.248 -		captureBuffer = "printer.bmp";
 592.249 -
 592.250 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 592.251 -
 592.252 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 592.253 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 592.254 -
 592.255 -	FileDlg dlg(this,
 592.256 -	            captureBuffer,
 592.257 -	            filter,
 592.258 -	            theApp.captureFormat ? 2 : 1,
 592.259 -	            theApp.captureFormat ? "BMP" : "PNG",
 592.260 -	            exts,
 592.261 -	            "",
 592.262 -	            title,
 592.263 -	            true);
 592.264 -
 592.265 -	if (dlg.DoModal() == IDCANCEL)
 592.266 -	{
 592.267 -		return;
 592.268 -	}
 592.269 -
 592.270 -	captureBuffer = dlg.GetPathName();
 592.271 -
 592.272 -	if (dlg.getFilterIndex() == 2)
 592.273 -		saveAsBMP(captureBuffer);
 592.274 -	else
 592.275 -		saveAsPNG(captureBuffer);
 592.276 -}
 592.277 -
 592.278 -void GBPrinterDlg::OnPrint()
 592.279 -{
 592.280 -	CPrintDialog dlg(FALSE);
 592.281 -
 592.282 -	dlg.m_pd.nFromPage = 1;
 592.283 -	dlg.m_pd.nToPage   = 1;
 592.284 -	dlg.m_pd.nMinPage  = 1;
 592.285 -	dlg.m_pd.nMaxPage  = 1;
 592.286 -	dlg.m_pd.nCopies   = 1;
 592.287 -
 592.288 -	if (dlg.DoModal() == IDOK)
 592.289 -	{
 592.290 -		DOCINFO di;
 592.291 -		float   fLogPelsX1 = 0;
 592.292 -		float   fLogPelsX2 = 0;
 592.293 -		float   fLogPelsY1 = 0;
 592.294 -		float   fLogPelsY2 = 0;
 592.295 -		float   fScaleX    = 0, fScaleY = 0;
 592.296 -		CDC *   winDC      = NULL;
 592.297 -		memset(&di, 0, sizeof(di));
 592.298 -		di.cbSize = sizeof(DOCINFO);
 592.299 -		CString docName = winResLoadString(IDS_POCKET_PRINTER);
 592.300 -		di.lpszDocName = docName;
 592.301 -		CDC dc;
 592.302 -		dc.Attach(dlg.GetPrinterDC());
 592.303 -		int nError = dc.StartDoc(&di);
 592.304 -
 592.305 -		if (nError == SP_ERROR)
 592.306 -		{
 592.307 -			systemMessage(IDS_ERROR_ON_STARTDOC, "Error on StartDoc");
 592.308 -			goto error;
 592.309 -		}
 592.310 -		nError = dc.StartPage();
 592.311 -		if (nError <= 0)
 592.312 -		{
 592.313 -			systemMessage(IDS_ERROR_ON_STARTPAGE, "Error on StartPage");
 592.314 -			goto error;
 592.315 -		}
 592.316 -
 592.317 -		winDC      = GetDC();
 592.318 -		fLogPelsX1 = (float)winDC->GetDeviceCaps(LOGPIXELSX);
 592.319 -		fLogPelsY1 = (float)winDC->GetDeviceCaps(LOGPIXELSY);
 592.320 -		ReleaseDC(winDC);
 592.321 -
 592.322 -		fLogPelsX2 = (float)dc.GetDeviceCaps(LOGPIXELSX);
 592.323 -		fLogPelsY2 = (float)dc.GetDeviceCaps(LOGPIXELSY);
 592.324 -
 592.325 -		if (fLogPelsX1 > fLogPelsX2)
 592.326 -			fScaleX = fLogPelsX1 / fLogPelsX2;
 592.327 -		else
 592.328 -			fScaleX = fLogPelsX2 / fLogPelsX1;
 592.329 -
 592.330 -		if (fLogPelsY1 > fLogPelsY2)
 592.331 -			fScaleY = fLogPelsY1 / fLogPelsY2;
 592.332 -		else
 592.333 -			fScaleY = fLogPelsY2 / fLogPelsY1;
 592.334 -
 592.335 -		fScaleX *= (scale+1);
 592.336 -		fScaleY *= (scale+1);
 592.337 -
 592.338 -		if (StretchDIBits(dc,
 592.339 -		                  0,
 592.340 -		                  0,
 592.341 -		                  (int)((float)160*fScaleX),
 592.342 -		                  (int)((float)144*fScaleY),
 592.343 -		                  0,
 592.344 -		                  0,
 592.345 -		                  160,
 592.346 -		                  144,
 592.347 -		                  bitmapData,
 592.348 -		                  bitmap,
 592.349 -		                  DIB_RGB_COLORS,
 592.350 -		                  SRCCOPY) == GDI_ERROR)
 592.351 -		{
 592.352 -			systemMessage(IDS_ERROR_PRINTING_ON_STRETCH,
 592.353 -			              "Error printing on StretchDIBits");
 592.354 -		}
 592.355 -
 592.356 -		nError = dc.EndPage();
 592.357 -
 592.358 -		if (nError <= 0)
 592.359 -		{
 592.360 -			systemMessage(IDS_ERROR_ON_ENDPAGE, "Error on EndPage");
 592.361 -			goto error;
 592.362 -		}
 592.363 -
 592.364 -		nError = dc.EndDoc();
 592.365 -
 592.366 -		if (nError <= 0)
 592.367 -			systemMessage(IDS_ERROR_ON_ENDDOC, "Error on EndDoc");
 592.368 -error:
 592.369 -		dc.DeleteDC();
 592.370 -	}
 592.371 -}
 592.372 -
 592.373 -void GBPrinterDlg::processData(u8 *data)
 592.374 -{
 592.375 -	for (int y = 0; y < 0x12; y++)
 592.376 -	{
 592.377 -		for (int x = 0; x < 0x14; x++)
 592.378 -		{
 592.379 -			for (int k = 0; k < 8; k++)
 592.380 -			{
 592.381 -				int a = *data++;
 592.382 -				int b = *data++;
 592.383 -				for (int j = 0; j < 8; j++)
 592.384 -				{
 592.385 -					int mask = 1 << (7-j);
 592.386 -					int c    = 0;
 592.387 -					if (a & mask)
 592.388 -						c++;
 592.389 -					if (b & mask)
 592.390 -						c += 2;
 592.391 -					bitmapData[x*8+j + 160*(y*8+k)] = c;
 592.392 -				}
 592.393 -			}
 592.394 -		}
 592.395 -	}
 592.396 -}
 592.397 -
 592.398 -BOOL GBPrinterDlg::OnInitDialog()
 592.399 -{
 592.400 -	CDialog::OnInitDialog();
 592.401 -
 592.402 -	scale = regQueryDwordValue("printerScale", 0);
 592.403 -	if (scale < 0 || scale > 3)
 592.404 -		scale = 0;
 592.405 -	m_scale = scale;
 592.406 -	UpdateData(FALSE);
 592.407 -
 592.408 -	CenterWindow();
 592.409 -
 592.410 -	return TRUE; // return TRUE unless you set the focus to a control
 592.411 -	             // EXCEPTION: OCX Property Pages should return FALSE
 592.412 -}
 592.413 -
 592.414 -void GBPrinterDlg::OnOk()
 592.415 -{
 592.416 -	EndDialog(TRUE);
 592.417 -}
 592.418 -
 592.419 -void GBPrinterDlg::On1x()
 592.420 -{
 592.421 -	regSetDwordValue("printerScale", 0);
 592.422 -	scale = 0;
 592.423 -}
 592.424 -
 592.425 -void GBPrinterDlg::On2x()
 592.426 -{
 592.427 -	regSetDwordValue("printerScale", 1);
 592.428 -	scale = 1;
 592.429 -}
 592.430 -
 592.431 -void GBPrinterDlg::On3x()
 592.432 -{
 592.433 -	regSetDwordValue("printerScale", 2);
 592.434 -	scale = 2;
 592.435 -}
 592.436 -
 592.437 -void GBPrinterDlg::On4x()
 592.438 -{
 592.439 -	regSetDwordValue("printerScale", 3);
 592.440 -	scale = 3;
 592.441 -}
 592.442 -
 592.443 -void GBPrinterDlg::OnPaint()
 592.444 -{
 592.445 -	CPaintDC dc(this); // device context for painting
 592.446 -
 592.447 -	RECT  rect;
 592.448 -	CWnd *h = GetDlgItem(IDC_GB_PRINTER);
 592.449 -	h->GetWindowRect(&rect);
 592.450 -	POINT p;
 592.451 -	p.x = rect.left;
 592.452 -	p.y = rect.top;
 592.453 -	ScreenToClient((POINT *)&p);
 592.454 -	rect.left = p.x+1;
 592.455 -	rect.top  = p.y+1;
 592.456 -	p.x       = rect.right;
 592.457 -	p.y       = rect.bottom;
 592.458 -	ScreenToClient((POINT *)&p);
 592.459 -	rect.right  = p.x-1;
 592.460 -	rect.bottom = p.y-1;
 592.461 -
 592.462 -	StretchDIBits(dc,
 592.463 -	              rect.left,
 592.464 -	              rect.top,
 592.465 -	              rect.right - rect.left,
 592.466 -	              rect.bottom - rect.top,
 592.467 -	              0,
 592.468 -	              0,
 592.469 -	              160,
 592.470 -	              144,
 592.471 -	              bitmapData,
 592.472 -	              bitmap,
 592.473 -	              DIB_RGB_COLORS,
 592.474 -	              SRCCOPY);
 592.475 -}
 592.476 -
 592.477 -void systemGbPrint(u8 *data,
 592.478 -                   int pages,
 592.479 -                   int feed,
 592.480 -                   int palette,
 592.481 -                   int contrast)
 592.482 -{
 592.483 -	theApp.winCheckFullscreen();
 592.484 -	GBPrinterDlg printer;
 592.485 -	printer.processData(data);
 592.486 -	printer.DoModal();
 592.487 -}
 592.488 -
   593.1 --- a/src/win32/GBPrinterDlg.h	Sat Mar 03 10:54:39 2012 -0600
   593.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   593.3 @@ -1,61 +0,0 @@
   593.4 -#if !defined(AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_)
   593.5 -#define AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_
   593.6 -
   593.7 -#if _MSC_VER > 1000
   593.8 -#pragma once
   593.9 -#endif // _MSC_VER > 1000
  593.10 -// -*- C++ -*-
  593.11 -// GBPrinter.h : header file
  593.12 -//
  593.13 -
  593.14 -/////////////////////////////////////////////////////////////////////////////
  593.15 -// GBPrinter dialog
  593.16 -
  593.17 -class GBPrinterDlg : public CDialog
  593.18 -{
  593.19 -private:
  593.20 -	u8 bitmapHeader[sizeof(BITMAPINFO)+4*sizeof(RGBQUAD)];
  593.21 -	BITMAPINFO *bitmap;
  593.22 -	u8  bitmapData[160*144];
  593.23 -	int scale;
  593.24 -	// Construction
  593.25 -public:
  593.26 -	void processData(u8 *data);
  593.27 -	void saveAsPNG(const char *name);
  593.28 -	void saveAsBMP(const char *name);
  593.29 -	GBPrinterDlg(CWnd*pParent = NULL);  // standard constructor
  593.30 -
  593.31 -	// Dialog Data
  593.32 -	//{{AFX_DATA(GBPrinterDlg)
  593.33 -	enum { IDD = IDD_GB_PRINTER };
  593.34 -	int m_scale;
  593.35 -	//}}AFX_DATA
  593.36 -
  593.37 -	// Overrides
  593.38 -	// ClassWizard generated virtual function overrides
  593.39 -	//{{AFX_VIRTUAL(GBPrinterDlg)
  593.40 -protected:
  593.41 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  593.42 -	//}}AFX_VIRTUAL
  593.43 -
  593.44 -	// Implementation
  593.45 -protected:
  593.46 -	// Generated message map functions
  593.47 -	//{{AFX_MSG(GBPrinterDlg)
  593.48 -	afx_msg void OnSave();
  593.49 -	afx_msg void OnPrint();
  593.50 -	virtual BOOL OnInitDialog();
  593.51 -	afx_msg void OnOk();
  593.52 -	afx_msg void On1x();
  593.53 -	afx_msg void On2x();
  593.54 -	afx_msg void On3x();
  593.55 -	afx_msg void On4x();
  593.56 -	afx_msg void OnPaint();
  593.57 -	//}}AFX_MSG
  593.58 -	DECLARE_MESSAGE_MAP()
  593.59 -};
  593.60 -
  593.61 -//{{AFX_INSERT_LOCATION}}
  593.62 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  593.63 -
  593.64 -#endif // !defined(AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_)
   594.1 --- a/src/win32/GBTileView.cpp	Sat Mar 03 10:54:39 2012 -0600
   594.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   594.3 @@ -1,517 +0,0 @@
   594.4 -// GBTileView.cpp : implementation file
   594.5 -//
   594.6 -
   594.7 -#include "stdafx.h"
   594.8 -#include "resource.h"
   594.9 -#include "GBTileView.h"
  594.10 -#include "FileDlg.h"
  594.11 -#include "Reg.h"
  594.12 -#include "WinResUtil.h"
  594.13 -#include "VBA.h"
  594.14 -
  594.15 -//#include "../common/System.h"
  594.16 -#include "../gb/gbGlobals.h"
  594.17 -#include "../NLS.h"
  594.18 -#include "../common/Util.h"
  594.19 -
  594.20 -extern "C" {
  594.21 -#include <png.h>
  594.22 -}
  594.23 -
  594.24 -/////////////////////////////////////////////////////////////////////////////
  594.25 -// GBTileView dialog
  594.26 -
  594.27 -GBTileView::GBTileView(CWnd*pParent /*=NULL*/)
  594.28 -	: ResizeDlg(GBTileView::IDD, pParent)
  594.29 -{
  594.30 -	//{{AFX_DATA_INIT(GBTileView)
  594.31 -	m_charBase = -1;
  594.32 -	m_bank     = -1;
  594.33 -	m_stretch  = FALSE;
  594.34 -	//}}AFX_DATA_INIT
  594.35 -	autoUpdate = false;
  594.36 -
  594.37 -	memset(&bmpInfo, 0, sizeof(bmpInfo));
  594.38 -
  594.39 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  594.40 -	bmpInfo.bmiHeader.biWidth       = 32*8;
  594.41 -	bmpInfo.bmiHeader.biHeight      = 32*8;
  594.42 -	bmpInfo.bmiHeader.biPlanes      = 1;
  594.43 -	bmpInfo.bmiHeader.biBitCount    = 24;
  594.44 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  594.45 -	data = (u8 *)calloc(1, 3 * 32*32 * 64);
  594.46 -
  594.47 -	tileView.setData(data);
  594.48 -	tileView.setBmpInfo(&bmpInfo);
  594.49 -
  594.50 -	charBase = 0;
  594.51 -	palette  = 0;
  594.52 -	bank     = 0;
  594.53 -	w        = h = 0;
  594.54 -}
  594.55 -
  594.56 -GBTileView::~GBTileView()
  594.57 -{
  594.58 -	free(data);
  594.59 -	data = NULL;
  594.60 -}
  594.61 -
  594.62 -void GBTileView::DoDataExchange(CDataExchange*pDX)
  594.63 -{
  594.64 -	CDialog::DoDataExchange(pDX);
  594.65 -	//{{AFX_DATA_MAP(GBTileView)
  594.66 -	DDX_Control(pDX, IDC_PALETTE_SLIDER, m_slider);
  594.67 -	DDX_Radio(pDX, IDC_CHARBASE_0, m_charBase);
  594.68 -	DDX_Radio(pDX, IDC_BANK_0, m_bank);
  594.69 -	DDX_Check(pDX, IDC_STRETCH, m_stretch);
  594.70 -	//}}AFX_DATA_MAP
  594.71 -	DDX_Control(pDX, IDC_TILE_VIEW, tileView);
  594.72 -	DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, zoom);
  594.73 -	DDX_Control(pDX, IDC_COLOR, color);
  594.74 -}
  594.75 -
  594.76 -BEGIN_MESSAGE_MAP(GBTileView, CDialog)
  594.77 -//{{AFX_MSG_MAP(GBTileView)
  594.78 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  594.79 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  594.80 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  594.81 -ON_BN_CLICKED(IDC_CHARBASE_0, OnCharbase0)
  594.82 -ON_BN_CLICKED(IDC_CHARBASE_1, OnCharbase1)
  594.83 -ON_BN_CLICKED(IDC_BANK_0, OnBank0)
  594.84 -ON_BN_CLICKED(IDC_BANK_1, OnBank1)
  594.85 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  594.86 -ON_WM_HSCROLL()
  594.87 -//}}AFX_MSG_MAP
  594.88 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  594.89 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  594.90 -END_MESSAGE_MAP()
  594.91 -
  594.92 -/////////////////////////////////////////////////////////////////////////////
  594.93 -// GBTileView message handlers
  594.94 -
  594.95 -void GBTileView::saveBMP(const char *name)
  594.96 -{
  594.97 -	u8 writeBuffer[1024 * 3];
  594.98 -
  594.99 -	FILE *fp = fopen(name, "wb");
 594.100 -
 594.101 -	if (!fp)
 594.102 -	{
 594.103 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 594.104 -		return;
 594.105 -	}
 594.106 -
 594.107 -	struct
 594.108 -	{
 594.109 -		u8 ident[2];
 594.110 -		u8 filesize[4];
 594.111 -		u8 reserved[4];
 594.112 -		u8 dataoffset[4];
 594.113 -		u8 headersize[4];
 594.114 -		u8 width[4];
 594.115 -		u8 height[4];
 594.116 -		u8 planes[2];
 594.117 -		u8 bitsperpixel[2];
 594.118 -		u8 compression[4];
 594.119 -		u8 datasize[4];
 594.120 -		u8 hres[4];
 594.121 -		u8 vres[4];
 594.122 -		u8 colors[4];
 594.123 -		u8 importantcolors[4];
 594.124 -		u8 pad[2];
 594.125 -	} bmpheader;
 594.126 -	memset(&bmpheader, 0, sizeof(bmpheader));
 594.127 -
 594.128 -	bmpheader.ident[0] = 'B';
 594.129 -	bmpheader.ident[1] = 'M';
 594.130 -
 594.131 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 594.132 -	utilPutDword(bmpheader.filesize, fsz);
 594.133 -	utilPutDword(bmpheader.dataoffset, 0x38);
 594.134 -	utilPutDword(bmpheader.headersize, 0x28);
 594.135 -	utilPutDword(bmpheader.width, w);
 594.136 -	utilPutDword(bmpheader.height, h);
 594.137 -	utilPutDword(bmpheader.planes, 1);
 594.138 -	utilPutDword(bmpheader.bitsperpixel, 24);
 594.139 -	utilPutDword(bmpheader.datasize, 3*w*h);
 594.140 -
 594.141 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 594.142 -
 594.143 -	u8 *b = writeBuffer;
 594.144 -
 594.145 -	int sizeX = w;
 594.146 -	int sizeY = h;
 594.147 -
 594.148 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 594.149 -	for (int y = 0; y < sizeY; y++)
 594.150 -	{
 594.151 -		for (int x = 0; x < sizeX; x++)
 594.152 -		{
 594.153 -			*b++ = *pixU8++; // B
 594.154 -			*b++ = *pixU8++; // G
 594.155 -			*b++ = *pixU8++; // R
 594.156 -		}
 594.157 -		pixU8 -= 2*3*w;
 594.158 -		fwrite(writeBuffer, 1, 3*w, fp);
 594.159 -
 594.160 -		b = writeBuffer;
 594.161 -	}
 594.162 -
 594.163 -	fclose(fp);
 594.164 -}
 594.165 -
 594.166 -void GBTileView::savePNG(const char *name)
 594.167 -{
 594.168 -	u8 writeBuffer[1024 * 3];
 594.169 -
 594.170 -	FILE *fp = fopen(name, "wb");
 594.171 -
 594.172 -	if (!fp)
 594.173 -	{
 594.174 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 594.175 -		return;
 594.176 -	}
 594.177 -
 594.178 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 594.179 -	                                              NULL,
 594.180 -	                                              NULL,
 594.181 -	                                              NULL);
 594.182 -	if (!png_ptr)
 594.183 -	{
 594.184 -		fclose(fp);
 594.185 -		return;
 594.186 -	}
 594.187 -
 594.188 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 594.189 -
 594.190 -	if (!info_ptr)
 594.191 -	{
 594.192 -		png_destroy_write_struct(&png_ptr, NULL);
 594.193 -		fclose(fp);
 594.194 -		return;
 594.195 -	}
 594.196 -
 594.197 -	if (setjmp(png_ptr->jmpbuf))
 594.198 -	{
 594.199 -		png_destroy_write_struct(&png_ptr, NULL);
 594.200 -		fclose(fp);
 594.201 -		return;
 594.202 -	}
 594.203 -
 594.204 -	png_init_io(png_ptr, fp);
 594.205 -
 594.206 -	png_set_IHDR(png_ptr,
 594.207 -	             info_ptr,
 594.208 -	             w,
 594.209 -	             h,
 594.210 -	             8,
 594.211 -	             PNG_COLOR_TYPE_RGB,
 594.212 -	             PNG_INTERLACE_NONE,
 594.213 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 594.214 -	             PNG_FILTER_TYPE_DEFAULT);
 594.215 -
 594.216 -	png_write_info(png_ptr, info_ptr);
 594.217 -
 594.218 -	u8 *b = writeBuffer;
 594.219 -
 594.220 -	int sizeX = w;
 594.221 -	int sizeY = h;
 594.222 -
 594.223 -	u8 *pixU8 = (u8 *)data;
 594.224 -	for (int y = 0; y < sizeY; y++)
 594.225 -	{
 594.226 -		for (int x = 0; x < sizeX; x++)
 594.227 -		{
 594.228 -			int blue  = *pixU8++;
 594.229 -			int green = *pixU8++;
 594.230 -			int red   = *pixU8++;
 594.231 -
 594.232 -			*b++ = red;
 594.233 -			*b++ = green;
 594.234 -			*b++ = blue;
 594.235 -		}
 594.236 -		png_write_row(png_ptr, writeBuffer);
 594.237 -
 594.238 -		b = writeBuffer;
 594.239 -	}
 594.240 -
 594.241 -	png_write_end(png_ptr, info_ptr);
 594.242 -
 594.243 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 594.244 -
 594.245 -	fclose(fp);
 594.246 -}
 594.247 -
 594.248 -void GBTileView::OnSave()
 594.249 -{
 594.250 -	CString captureBuffer;
 594.251 -
 594.252 -	if (theApp.captureFormat == 0)
 594.253 -		captureBuffer = "tiles.png";
 594.254 -	else
 594.255 -		captureBuffer = "tiles.bmp";
 594.256 -
 594.257 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 594.258 -
 594.259 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 594.260 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 594.261 -
 594.262 -	FileDlg dlg(this,
 594.263 -	            captureBuffer,
 594.264 -	            filter,
 594.265 -	            theApp.captureFormat ? 2 : 1,
 594.266 -	            theApp.captureFormat ? "BMP" : "PNG",
 594.267 -	            exts,
 594.268 -	            "",
 594.269 -	            title,
 594.270 -	            true);
 594.271 -
 594.272 -	if (dlg.DoModal() == IDCANCEL)
 594.273 -	{
 594.274 -		return;
 594.275 -	}
 594.276 -
 594.277 -	captureBuffer = dlg.GetPathName();
 594.278 -
 594.279 -	if (theApp.captureFormat)
 594.280 -		saveBMP(captureBuffer);
 594.281 -	else
 594.282 -		savePNG(captureBuffer);
 594.283 -}
 594.284 -
 594.285 -void GBTileView::renderTile(int tile, int x, int y, u8 *charBase)
 594.286 -{
 594.287 -	u8 *bmp = &data[24*x + 8*16*24*y];
 594.288 -
 594.289 -	for (int j = 0; j < 8; j++)
 594.290 -	{
 594.291 -		u8 mask   = 0x80;
 594.292 -		u8 tile_a = charBase[tile*16+j*2];
 594.293 -		u8 tile_b = charBase[tile*16+j*2+1];
 594.294 -
 594.295 -		for (int i = 0; i < 8; i++)
 594.296 -		{
 594.297 -			u8 c = (tile_a & mask) ? 1 : 0;
 594.298 -			c += ((tile_b & mask) ? 2 : 0);
 594.299 -
 594.300 -			if (gbCgbMode)
 594.301 -			{
 594.302 -				c = c + palette*4;
 594.303 -			}
 594.304 -			else
 594.305 -			{
 594.306 -				c = gbBgp[c];
 594.307 -			}
 594.308 -
 594.309 -			u16 color = gbPalette[c];
 594.310 -
 594.311 -			*bmp++ = ((color >> 10) & 0x1f) << 3;
 594.312 -			*bmp++ = ((color >> 5) & 0x1f) << 3;
 594.313 -			*bmp++ = (color & 0x1f) << 3;
 594.314 -
 594.315 -			mask >>= 1;
 594.316 -		}
 594.317 -		bmp += 15*24; // advance line
 594.318 -	}
 594.319 -}
 594.320 -
 594.321 -void GBTileView::render()
 594.322 -{
 594.323 -	int tiles = 0x0000;
 594.324 -	if (charBase)
 594.325 -		tiles = 0x0800;
 594.326 -	u8 *charBase = (gbVram != NULL) ?
 594.327 -	               (bank ? &gbVram[0x2000+tiles] : &gbVram[tiles]) :
 594.328 -	               &gbMemory[0x8000+tiles];
 594.329 -
 594.330 -	int tile = 0;
 594.331 -	for (int y = 0; y < 16; y++)
 594.332 -	{
 594.333 -		for (int x = 0; x < 16; x++)
 594.334 -		{
 594.335 -			renderTile(tile, x, y, charBase);
 594.336 -			tile++;
 594.337 -		}
 594.338 -	}
 594.339 -	tileView.setSize(16*8, 16*8);
 594.340 -	w = 16*8;
 594.341 -	h = 16*8;
 594.342 -	SIZE s;
 594.343 -	s.cx = s.cy = 16*8;
 594.344 -	if (tileView.getStretch())
 594.345 -	{
 594.346 -		s.cx = s.cy = 1;
 594.347 -	}
 594.348 -	tileView.SetScrollSizes(MM_TEXT, s);
 594.349 -}
 594.350 -
 594.351 -void GBTileView::update()
 594.352 -{
 594.353 -	paint();
 594.354 -}
 594.355 -
 594.356 -BOOL GBTileView::OnInitDialog()
 594.357 -{
 594.358 -	CDialog::OnInitDialog();
 594.359 -
 594.360 -	DIALOG_SIZER_START(sz)
 594.361 -	DIALOG_SIZER_ENTRY(IDC_TILE_VIEW, DS_SizeX | DS_SizeY)
 594.362 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 594.363 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 594.364 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 594.365 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 594.366 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 594.367 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 594.368 -	DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
 594.369 -	DIALOG_SIZER_END()
 594.370 -	SetData(sz,
 594.371 -	        TRUE,
 594.372 -	        HKEY_CURRENT_USER,
 594.373 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBTileView",
 594.374 -	        NULL);
 594.375 -
 594.376 -	m_charBase = charBase;
 594.377 -	m_bank     = bank;
 594.378 -
 594.379 -	m_slider.SetRange(0, 7);
 594.380 -	m_slider.SetPageSize(2);
 594.381 -	m_slider.SetTicFreq(1);
 594.382 -	paint();
 594.383 -
 594.384 -	m_stretch = regQueryDwordValue("tileViewStretch", 0);
 594.385 -	if (m_stretch)
 594.386 -		tileView.setStretch(true);
 594.387 -	UpdateData(FALSE);
 594.388 -
 594.389 -	return TRUE; // return TRUE unless you set the focus to a control
 594.390 -	             // EXCEPTION: OCX Property Pages should return FALSE
 594.391 -}
 594.392 -
 594.393 -void GBTileView::OnClose()
 594.394 -{
 594.395 -	theApp.winRemoveUpdateListener(this);
 594.396 -
 594.397 -	DestroyWindow();
 594.398 -}
 594.399 -
 594.400 -void GBTileView::OnAutoUpdate()
 594.401 -{
 594.402 -	autoUpdate = !autoUpdate;
 594.403 -	if (autoUpdate)
 594.404 -	{
 594.405 -		theApp.winAddUpdateListener(this);
 594.406 -	}
 594.407 -	else
 594.408 -	{
 594.409 -		theApp.winRemoveUpdateListener(this);
 594.410 -	}
 594.411 -}
 594.412 -
 594.413 -void GBTileView::paint()
 594.414 -{
 594.415 -	if (gbRom != NULL)
 594.416 -	{
 594.417 -		render();
 594.418 -		tileView.refresh();
 594.419 -	}
 594.420 -}
 594.421 -
 594.422 -void GBTileView::OnCharbase0()
 594.423 -{
 594.424 -	charBase = 0;
 594.425 -	paint();
 594.426 -}
 594.427 -
 594.428 -void GBTileView::OnCharbase1()
 594.429 -{
 594.430 -	charBase = 1;
 594.431 -	paint();
 594.432 -}
 594.433 -
 594.434 -void GBTileView::OnBank0()
 594.435 -{
 594.436 -	bank = 0;
 594.437 -	paint();
 594.438 -}
 594.439 -
 594.440 -void GBTileView::OnBank1()
 594.441 -{
 594.442 -	bank = 1;
 594.443 -	paint();
 594.444 -}
 594.445 -
 594.446 -void GBTileView::OnStretch()
 594.447 -{
 594.448 -	tileView.setStretch(!tileView.getStretch());
 594.449 -	paint();
 594.450 -	regSetDwordValue("tileViewStretch", tileView.getStretch());
 594.451 -}
 594.452 -
 594.453 -LRESULT GBTileView::OnMapInfo(WPARAM wParam, LPARAM lParam)
 594.454 -{
 594.455 -	u8 *colors = (u8 *)lParam;
 594.456 -	zoom.setColors(colors);
 594.457 -
 594.458 -	int x = (wParam & 0xFFFF)/8;
 594.459 -	int y = ((wParam >> 16) & 0xFFFF)/8;
 594.460 -
 594.461 -	int tiles = 0x0000;
 594.462 -	if (charBase)
 594.463 -		tiles = 0x0800;
 594.464 -	u32 address = 0x8000 + tiles;
 594.465 -	int tile    = 16 * y + x;
 594.466 -
 594.467 -	address += 16 * tile;
 594.468 -
 594.469 -	CString buffer;
 594.470 -	buffer.Format("%d", tile);
 594.471 -	GetDlgItem(IDC_TILE_NUMBER)->SetWindowText(buffer);
 594.472 -
 594.473 -	buffer.Format("%04x", address);
 594.474 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 594.475 -
 594.476 -	return TRUE;
 594.477 -}
 594.478 -
 594.479 -LRESULT GBTileView::OnColInfo(WPARAM wParam, LPARAM)
 594.480 -{
 594.481 -	u16 c = (u16)wParam;
 594.482 -
 594.483 -	color.setColor(c);
 594.484 -
 594.485 -	int r = (c & 0x1f);
 594.486 -	int g = (c & 0x3e0) >> 5;
 594.487 -	int b = (c & 0x7c00) >> 10;
 594.488 -
 594.489 -	CString buffer;
 594.490 -	buffer.Format("R: %d", r);
 594.491 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 594.492 -
 594.493 -	buffer.Format("G: %d", g);
 594.494 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 594.495 -
 594.496 -	buffer.Format("B: %d", b);
 594.497 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 594.498 -
 594.499 -	return TRUE;
 594.500 -}
 594.501 -
 594.502 -void GBTileView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 594.503 -{
 594.504 -	switch (nSBCode)
 594.505 -	{
 594.506 -	case TB_THUMBPOSITION:
 594.507 -		palette = nPos;
 594.508 -		break;
 594.509 -	default:
 594.510 -		palette = m_slider.GetPos();
 594.511 -		break;
 594.512 -	}
 594.513 -	paint();
 594.514 -}
 594.515 -
 594.516 -void GBTileView::PostNcDestroy()
 594.517 -{
 594.518 -	delete this;
 594.519 -}
 594.520 -
   595.1 --- a/src/win32/GBTileView.h	Sat Mar 03 10:54:39 2012 -0600
   595.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   595.3 @@ -1,85 +0,0 @@
   595.4 -#if !defined(AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_)
   595.5 -#define AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_
   595.6 -
   595.7 -#if _MSC_VER > 1000
   595.8 -#pragma once
   595.9 -#endif // _MSC_VER > 1000
  595.10 -// -*- C++ -*-
  595.11 -// GBTileView.h : header file
  595.12 -//
  595.13 -#include "BitmapControl.h"
  595.14 -#include "ColorControl.h"
  595.15 -#include "IUpdate.h"
  595.16 -#include "ResizeDlg.h"
  595.17 -#include "ZoomControl.h"
  595.18 -
  595.19 -/////////////////////////////////////////////////////////////////////////////
  595.20 -// GBTileView dialog
  595.21 -
  595.22 -class GBTileView : public ResizeDlg, IUpdateListener
  595.23 -{
  595.24 -	int charBase;
  595.25 -	int palette;
  595.26 -	int bank;
  595.27 -	BitmapControl tileView;
  595.28 -	BITMAPINFO    bmpInfo;
  595.29 -	u8 *         data;
  595.30 -	ZoomControl  zoom;
  595.31 -	ColorControl color;
  595.32 -	int          w;
  595.33 -	int          h;
  595.34 -	bool         autoUpdate;
  595.35 -	// Construction
  595.36 -public:
  595.37 -	void paint();
  595.38 -	void render();
  595.39 -	void renderTile(int tile, int x, int y, u8 *charBase);
  595.40 -	void savePNG(const char *name);
  595.41 -	void saveBMP(const char *name);
  595.42 -	GBTileView(CWnd*pParent = NULL);  // standard constructor
  595.43 -	virtual ~GBTileView();
  595.44 -
  595.45 -	virtual void update();
  595.46 -
  595.47 -	// Dialog Data
  595.48 -	//{{AFX_DATA(GBTileView)
  595.49 -	enum { IDD = IDD_GB_TILE_VIEWER };
  595.50 -	CSliderCtrl m_slider;
  595.51 -	int         m_charBase;
  595.52 -	int         m_bank;
  595.53 -	BOOL        m_stretch;
  595.54 -	//}}AFX_DATA
  595.55 -
  595.56 -	// Overrides
  595.57 -	// ClassWizard generated virtual function overrides
  595.58 -	//{{AFX_VIRTUAL(GBTileView)
  595.59 -protected:
  595.60 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  595.61 -	virtual void PostNcDestroy();
  595.62 -	//}}AFX_VIRTUAL
  595.63 -
  595.64 -	// Implementation
  595.65 -protected:
  595.66 -	virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  595.67 -	virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  595.68 -
  595.69 -	// Generated message map functions
  595.70 -	//{{AFX_MSG(GBTileView)
  595.71 -	afx_msg void OnSave();
  595.72 -	virtual BOOL OnInitDialog();
  595.73 -	afx_msg void OnClose();
  595.74 -	afx_msg void OnAutoUpdate();
  595.75 -	afx_msg void OnCharbase0();
  595.76 -	afx_msg void OnCharbase1();
  595.77 -	afx_msg void OnBank0();
  595.78 -	afx_msg void OnBank1();
  595.79 -	afx_msg void OnStretch();
  595.80 -	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  595.81 -	//}}AFX_MSG
  595.82 -	DECLARE_MESSAGE_MAP()
  595.83 -};
  595.84 -
  595.85 -//{{AFX_INSERT_LOCATION}}
  595.86 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  595.87 -
  595.88 -#endif // !defined(AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_)
   596.1 --- a/src/win32/GDBConnection.cpp	Sat Mar 03 10:54:39 2012 -0600
   596.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   596.3 @@ -1,248 +0,0 @@
   596.4 -// GDBConnection.cpp : implementation file
   596.5 -//
   596.6 -
   596.7 -#include "stdafx.h"
   596.8 -#include "resource.h"
   596.9 -#include "GDBConnection.h"
  596.10 -
  596.11 -#include "../common/System.h"
  596.12 -
  596.13 -#define SOCKET_MESSAGE WM_APP+1
  596.14 -
  596.15 -static bool initialized = false;
  596.16 -
  596.17 -/////////////////////////////////////////////////////////////////////////////
  596.18 -// GDBPortDlg dialog
  596.19 -
  596.20 -GDBPortDlg::GDBPortDlg(CWnd*pParent /*=NULL*/)
  596.21 -	: CDialog(GDBPortDlg::IDD, pParent)
  596.22 -{
  596.23 -	//{{AFX_DATA_INIT(GDBPortDlg)
  596.24 -	// NOTE: the ClassWizard will add member initialization here
  596.25 -	//}}AFX_DATA_INIT
  596.26 -	port = 55555;
  596.27 -	sock = INVALID_SOCKET;
  596.28 -
  596.29 -	if (!initialized)
  596.30 -	{
  596.31 -		WSADATA wsaData;
  596.32 -
  596.33 -		int error = WSAStartup(MAKEWORD(1, 1), &wsaData);
  596.34 -
  596.35 -		initialized = true;
  596.36 -	}
  596.37 -}
  596.38 -
  596.39 -void GDBPortDlg::DoDataExchange(CDataExchange*pDX)
  596.40 -{
  596.41 -	CDialog::DoDataExchange(pDX);
  596.42 -	//{{AFX_DATA_MAP(GDBPortDlg)
  596.43 -	DDX_Control(pDX, IDC_PORT, m_port);
  596.44 -	//}}AFX_DATA_MAP
  596.45 -}
  596.46 -
  596.47 -BEGIN_MESSAGE_MAP(GDBPortDlg, CDialog)
  596.48 -//{{AFX_MSG_MAP(GDBPortDlg)
  596.49 -ON_BN_CLICKED(ID_OK, OnOk)
  596.50 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  596.51 -ON_WM_CLOSE()
  596.52 -//}}AFX_MSG_MAP
  596.53 -END_MESSAGE_MAP()
  596.54 -
  596.55 -/////////////////////////////////////////////////////////////////////////////
  596.56 -// GDBPortDlg message handlers
  596.57 -
  596.58 -int GDBPortDlg::getPort()
  596.59 -{
  596.60 -	return port;
  596.61 -}
  596.62 -
  596.63 -SOCKET GDBPortDlg::getSocket()
  596.64 -{
  596.65 -	return sock;
  596.66 -}
  596.67 -
  596.68 -BOOL GDBPortDlg::OnInitDialog()
  596.69 -{
  596.70 -	CDialog::OnInitDialog();
  596.71 -
  596.72 -	CString buffer;
  596.73 -
  596.74 -	buffer.Format("%d", port);
  596.75 -
  596.76 -	m_port.SetWindowText(buffer);
  596.77 -
  596.78 -	CenterWindow();
  596.79 -
  596.80 -	return TRUE; // return TRUE unless you set the focus to a control
  596.81 -	             // EXCEPTION: OCX Property Pages should return FALSE
  596.82 -}
  596.83 -
  596.84 -void GDBPortDlg::OnOk()
  596.85 -{
  596.86 -	CString buffer;
  596.87 -
  596.88 -	m_port.GetWindowText(buffer);
  596.89 -
  596.90 -	sockaddr_in address;
  596.91 -	address.sin_family      = AF_INET;
  596.92 -	address.sin_addr.s_addr = inet_addr("0.0.0.0");
  596.93 -	address.sin_port        = htons(atoi(buffer));
  596.94 -	port = ntohs(address.sin_port);
  596.95 -
  596.96 -	SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
  596.97 -
  596.98 -	if (s != INVALID_SOCKET)
  596.99 -	{
 596.100 -		int error = bind(s, (sockaddr *)&address, sizeof(address));
 596.101 -
 596.102 -		if (error)
 596.103 -		{
 596.104 -			systemMessage(IDS_ERROR_BINDING, "Error binding socket. Port probably in use.");
 596.105 -			error = closesocket(s);
 596.106 -			EndDialog(FALSE);
 596.107 -		}
 596.108 -		else
 596.109 -		{
 596.110 -			error = listen(s, 1);
 596.111 -			if (!error)
 596.112 -			{
 596.113 -				sock = s;
 596.114 -				EndDialog(TRUE);
 596.115 -			}
 596.116 -			else
 596.117 -			{
 596.118 -				systemMessage(IDS_ERROR_LISTENING, "Error listening on socket.");
 596.119 -				closesocket(s);
 596.120 -				EndDialog(FALSE);
 596.121 -			}
 596.122 -		}
 596.123 -	}
 596.124 -	else
 596.125 -	{
 596.126 -		systemMessage(IDS_ERROR_CREATING_SOCKET, "Error creating socket.");
 596.127 -		EndDialog(FALSE);
 596.128 -	}
 596.129 -}
 596.130 -
 596.131 -void GDBPortDlg::OnCancel()
 596.132 -{
 596.133 -	OnClose();
 596.134 -}
 596.135 -
 596.136 -void GDBPortDlg::OnClose()
 596.137 -{
 596.138 -	EndDialog(FALSE);
 596.139 -}
 596.140 -
 596.141 -/////////////////////////////////////////////////////////////////////////////
 596.142 -// GDBWaitingDlg dialog
 596.143 -
 596.144 -GDBWaitingDlg::GDBWaitingDlg(SOCKET s, int p, CWnd*pParent /*=NULL*/)
 596.145 -	: CDialog(GDBWaitingDlg::IDD, pParent)
 596.146 -{
 596.147 -	//{{AFX_DATA_INIT(GDBWaitingDlg)
 596.148 -	//}}AFX_DATA_INIT
 596.149 -	port         = p & 65535;
 596.150 -	listenSocket = s;
 596.151 -}
 596.152 -
 596.153 -void GDBWaitingDlg::DoDataExchange(CDataExchange*pDX)
 596.154 -{
 596.155 -	CDialog::DoDataExchange(pDX);
 596.156 -	//{{AFX_DATA_MAP(GDBWaitingDlg)
 596.157 -	DDX_Control(pDX, IDC_PORT, m_port);
 596.158 -	//}}AFX_DATA_MAP
 596.159 -}
 596.160 -
 596.161 -BEGIN_MESSAGE_MAP(GDBWaitingDlg, CDialog)
 596.162 -//{{AFX_MSG_MAP(GDBWaitingDlg)
 596.163 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 596.164 -ON_WM_CLOSE()
 596.165 -//}}AFX_MSG_MAP
 596.166 -END_MESSAGE_MAP()
 596.167 -
 596.168 -/////////////////////////////////////////////////////////////////////////////
 596.169 -// GDBWaitingDlg message handlers
 596.170 -
 596.171 -BOOL GDBWaitingDlg::OnInitDialog()
 596.172 -{
 596.173 -	CDialog::OnInitDialog();
 596.174 -
 596.175 -	CString buffer;
 596.176 -
 596.177 -	buffer.Format("%d", port);
 596.178 -
 596.179 -	m_port.SetWindowText(buffer);
 596.180 -
 596.181 -	CenterWindow();
 596.182 -
 596.183 -	int error = WSAAsyncSelect(listenSocket,
 596.184 -	                           (HWND)*this,
 596.185 -	                           SOCKET_MESSAGE,
 596.186 -	                           FD_ACCEPT);
 596.187 -
 596.188 -	return TRUE; // return TRUE unless you set the focus to a control
 596.189 -	             // EXCEPTION: OCX Property Pages should return FALSE
 596.190 -}
 596.191 -
 596.192 -LRESULT GDBWaitingDlg::OnSocketAccept(WPARAM wParam, LPARAM lParam)
 596.193 -{
 596.194 -	if (LOWORD(lParam) == FD_ACCEPT)
 596.195 -	{
 596.196 -		WSAAsyncSelect(listenSocket, (HWND)*this, 0, 0);
 596.197 -
 596.198 -		int flag = 0;
 596.199 -		ioctlsocket(listenSocket, FIONBIO, (unsigned long *)&flag);
 596.200 -
 596.201 -		SOCKET s = accept(listenSocket, NULL, NULL);
 596.202 -		if (s != INVALID_SOCKET)
 596.203 -		{
 596.204 -			char dummy;
 596.205 -			recv(s, &dummy, 1, 0);
 596.206 -			if (dummy != '+')
 596.207 -			{
 596.208 -				systemMessage(IDS_ACK_NOT_RECEIVED, "ACK not received from GDB.");
 596.209 -				OnClose(); // calls EndDialog
 596.210 -			}
 596.211 -			else
 596.212 -			{
 596.213 -				sock = s;
 596.214 -				EndDialog(TRUE);
 596.215 -			}
 596.216 -		}
 596.217 -	}
 596.218 -
 596.219 -	return TRUE;
 596.220 -}
 596.221 -
 596.222 -void GDBWaitingDlg::OnCancel()
 596.223 -{
 596.224 -	OnClose();
 596.225 -}
 596.226 -
 596.227 -void GDBWaitingDlg::OnClose()
 596.228 -{
 596.229 -	if (sock != INVALID_SOCKET)
 596.230 -	{
 596.231 -		closesocket(sock);
 596.232 -		sock = INVALID_SOCKET;
 596.233 -	}
 596.234 -	if (listenSocket != INVALID_SOCKET)
 596.235 -	{
 596.236 -		closesocket(listenSocket);
 596.237 -		listenSocket = INVALID_SOCKET;
 596.238 -	}
 596.239 -	EndDialog(FALSE);
 596.240 -}
 596.241 -
 596.242 -SOCKET GDBWaitingDlg::getListenSocket()
 596.243 -{
 596.244 -	return listenSocket;
 596.245 -}
 596.246 -
 596.247 -SOCKET GDBWaitingDlg::getSocket()
 596.248 -{
 596.249 -	return sock;
 596.250 -}
 596.251 -
   597.1 --- a/src/win32/GDBConnection.h	Sat Mar 03 10:54:39 2012 -0600
   597.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   597.3 @@ -1,92 +0,0 @@
   597.4 -#if !defined(AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_)
   597.5 -#define AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_
   597.6 -
   597.7 -#if _MSC_VER > 1000
   597.8 -#pragma once
   597.9 -#endif // _MSC_VER > 1000
  597.10 -// -*- C++ -*-
  597.11 -// GDBConnection.h : header file
  597.12 -//
  597.13 -
  597.14 -#include <winsock.h>
  597.15 -
  597.16 -/////////////////////////////////////////////////////////////////////////////
  597.17 -// GDBPortDlg dialog
  597.18 -
  597.19 -class GDBPortDlg : public CDialog
  597.20 -{
  597.21 -	int    port;
  597.22 -	SOCKET sock;
  597.23 -	// Construction
  597.24 -public:
  597.25 -	SOCKET getSocket();
  597.26 -	int getPort();
  597.27 -	GDBPortDlg(CWnd*pParent = NULL);  // standard constructor
  597.28 -
  597.29 -	// Dialog Data
  597.30 -	//{{AFX_DATA(GDBPortDlg)
  597.31 -	enum { IDD = IDD_GDB_PORT };
  597.32 -	CEdit m_port;
  597.33 -	//}}AFX_DATA
  597.34 -
  597.35 -	// Overrides
  597.36 -	// ClassWizard generated virtual function overrides
  597.37 -	//{{AFX_VIRTUAL(GDBPortDlg)
  597.38 -protected:
  597.39 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  597.40 -	//}}AFX_VIRTUAL
  597.41 -
  597.42 -	// Implementation
  597.43 -protected:
  597.44 -	// Generated message map functions
  597.45 -	//{{AFX_MSG(GDBPortDlg)
  597.46 -	virtual BOOL OnInitDialog();
  597.47 -	afx_msg void OnOk();
  597.48 -	afx_msg void OnCancel();
  597.49 -	afx_msg void OnClose();
  597.50 -	//}}AFX_MSG
  597.51 -	DECLARE_MESSAGE_MAP()
  597.52 -};
  597.53 -
  597.54 -/////////////////////////////////////////////////////////////////////////////
  597.55 -// GDBWaitingDlg dialog
  597.56 -
  597.57 -class GDBWaitingDlg : public CDialog
  597.58 -{
  597.59 -	int    port;
  597.60 -	SOCKET listenSocket;
  597.61 -	SOCKET sock;
  597.62 -	// Construction
  597.63 -public:
  597.64 -	SOCKET getSocket();
  597.65 -	SOCKET getListenSocket();
  597.66 -	afx_msg LRESULT OnSocketAccept(WPARAM wParam, LPARAM lParam);
  597.67 -	GDBWaitingDlg(SOCKET s, int p, CWnd*pParent = NULL); // standard constructor
  597.68 -
  597.69 -	// Dialog Data
  597.70 -	//{{AFX_DATA(GDBWaitingDlg)
  597.71 -	enum { IDD = IDD_GDB_WAITING };
  597.72 -	CStatic m_port;
  597.73 -	//}}AFX_DATA
  597.74 -
  597.75 -	// Overrides
  597.76 -	// ClassWizard generated virtual function overrides
  597.77 -	//{{AFX_VIRTUAL(GDBWaitingDlg)
  597.78 -protected:
  597.79 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  597.80 -	//}}AFX_VIRTUAL
  597.81 -
  597.82 -	// Implementation
  597.83 -protected:
  597.84 -	// Generated message map functions
  597.85 -	//{{AFX_MSG(GDBWaitingDlg)
  597.86 -	virtual BOOL OnInitDialog();
  597.87 -	afx_msg void OnCancel();
  597.88 -	afx_msg void OnClose();
  597.89 -	//}}AFX_MSG
  597.90 -	DECLARE_MESSAGE_MAP()
  597.91 -};
  597.92 -//{{AFX_INSERT_LOCATION}}
  597.93 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  597.94 -
  597.95 -#endif // !defined(AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_)
   598.1 --- a/src/win32/GDIDisplay.cpp	Sat Mar 03 10:54:39 2012 -0600
   598.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   598.3 @@ -1,387 +0,0 @@
   598.4 -#include "stdafx.h"
   598.5 -#include <cstdio>
   598.6 -
   598.7 -#include "resource.h"
   598.8 -#include "MainWnd.h"
   598.9 -#include "Reg.h"
  598.10 -#include "VBA.h"
  598.11 -
  598.12 -#include "../gba/GBAGlobals.h"
  598.13 -#include "../gb/gbGlobals.h"
  598.14 -#include "../common/Text.h"
  598.15 -#include "../version.h"
  598.16 -
  598.17 -extern u32 RGB_LOW_BITS_MASK;
  598.18 -extern int systemSpeed;
  598.19 -extern void winlog(const char *, ...);
  598.20 -extern int Init_2xSaI(u32);
  598.21 -
  598.22 -class GDIDisplay : public IDisplay
  598.23 -{
  598.24 -private:
  598.25 -	u8 *filterData;
  598.26 -	u8  info[sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)];
  598.27 -public:
  598.28 -	GDIDisplay();
  598.29 -	virtual ~GDIDisplay();
  598.30 -
  598.31 -	virtual bool initialize();
  598.32 -	virtual void cleanup();
  598.33 -	virtual void render();
  598.34 -	virtual void checkFullScreen();
  598.35 -	virtual void renderMenu();
  598.36 -	virtual void clear();
  598.37 -	virtual DISPLAY_TYPE getType() { return GDI; };
  598.38 -	virtual void setOption(const char *, int) {}
  598.39 -	virtual int selectFullScreenMode(GUID * *);
  598.40 -};
  598.41 -
  598.42 -static int calculateShift(u32 mask)
  598.43 -{
  598.44 -	int m = 0;
  598.45 -
  598.46 -	while (mask)
  598.47 -	{
  598.48 -		m++;
  598.49 -		mask >>= 1;
  598.50 -	}
  598.51 -
  598.52 -	return m-5;
  598.53 -}
  598.54 -
  598.55 -GDIDisplay::GDIDisplay()
  598.56 -{
  598.57 -	filterData = (u8 *)malloc(4*16*256*256); // sufficient for 4x filters @ 32bit color depth
  598.58 -}
  598.59 -
  598.60 -GDIDisplay::~GDIDisplay()
  598.61 -{
  598.62 -	cleanup();
  598.63 -}
  598.64 -
  598.65 -void GDIDisplay::cleanup()
  598.66 -{
  598.67 -	if (filterData)
  598.68 -	{
  598.69 -		free(filterData);
  598.70 -		filterData = NULL;
  598.71 -	}
  598.72 -}
  598.73 -
  598.74 -bool GDIDisplay::initialize()
  598.75 -{
  598.76 -	CWnd *pWnd = theApp.m_pMainWnd;
  598.77 -
  598.78 -	theApp.mode320Available = false;
  598.79 -	theApp.mode640Available = false;
  598.80 -	theApp.mode800Available = false;
  598.81 -
  598.82 -	HDC         dc  = GetDC(NULL);
  598.83 -	HBITMAP     hbm = CreateCompatibleBitmap(dc, 1, 1);
  598.84 -	BITMAPINFO *bi  = (BITMAPINFO *)info;
  598.85 -	ZeroMemory(bi, sizeof(info));
  598.86 -	bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  598.87 -	GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
  598.88 -	GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
  598.89 -	DeleteObject(hbm);
  598.90 -	ReleaseDC(NULL, dc);
  598.91 -
  598.92 -	if (bi->bmiHeader.biCompression == BI_BITFIELDS)
  598.93 -	{
  598.94 -		systemColorDepth = bi->bmiHeader.biBitCount;
  598.95 -		if (systemColorDepth == 15)
  598.96 -			systemColorDepth = 16;
  598.97 -		systemRedShift   = calculateShift(*((DWORD *)&bi->bmiColors[0]));
  598.98 -		systemGreenShift = calculateShift(*((DWORD *)&bi->bmiColors[1]));
  598.99 -		systemBlueShift  = calculateShift(*((DWORD *)&bi->bmiColors[2]));
 598.100 -		if (systemColorDepth == 16)
 598.101 -		{
 598.102 -			if (systemGreenShift == 6)
 598.103 -			{
 598.104 -				Init_2xSaI(565);
 598.105 -				RGB_LOW_BITS_MASK = 0x821;
 598.106 -			}
 598.107 -			else
 598.108 -			{
 598.109 -				Init_2xSaI(555);
 598.110 -				RGB_LOW_BITS_MASK = 0x421;
 598.111 -			}
 598.112 -		}
 598.113 -		else if (systemColorDepth == 32)
 598.114 -			Init_2xSaI(32);
 598.115 -	}
 598.116 -	else
 598.117 -	{
 598.118 -		systemColorDepth = 32;
 598.119 -		systemRedShift   = 19;
 598.120 -		systemGreenShift = 11;
 598.121 -		systemBlueShift  = 3;
 598.122 -
 598.123 -		Init_2xSaI(32);
 598.124 -	}
 598.125 -	theApp.fsColorDepth = systemColorDepth;
 598.126 -	if (systemColorDepth == 24)
 598.127 -		theApp.filterFunction = NULL;
 598.128 -#ifdef MMX
 598.129 -	if (!theApp.disableMMX)
 598.130 -		cpu_mmx = theApp.detectMMX();
 598.131 -	else
 598.132 -		cpu_mmx = 0;
 598.133 -#endif
 598.134 -
 598.135 -	switch (systemColorDepth)
 598.136 -	{
 598.137 -	case 16:
 598.138 -	{
 598.139 -		for (int i = 0; i < 0x10000; i++)
 598.140 -		{
 598.141 -			systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
 598.142 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 598.143 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 598.144 -		}
 598.145 -		break;
 598.146 -	}
 598.147 -	case 24:
 598.148 -	case 32:
 598.149 -	{
 598.150 -		for (int i = 0; i < 0x10000; i++)
 598.151 -		{
 598.152 -			systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 598.153 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 598.154 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 598.155 -		}
 598.156 -		break;
 598.157 -	}
 598.158 -	}
 598.159 -	theApp.updateFilter();
 598.160 -	theApp.updateIFB();
 598.161 -
 598.162 -	pWnd->DragAcceptFiles(TRUE);
 598.163 -
 598.164 -	return TRUE;
 598.165 -}
 598.166 -
 598.167 -void GDIDisplay::clear()
 598.168 -{}
 598.169 -
 598.170 -void GDIDisplay::renderMenu()
 598.171 -{
 598.172 -	checkFullScreen();
 598.173 -	theApp.m_pMainWnd->DrawMenuBar();
 598.174 -}
 598.175 -
 598.176 -void GDIDisplay::checkFullScreen()
 598.177 -{}
 598.178 -
 598.179 -void GDIDisplay::render()
 598.180 -{
 598.181 -	void (*filterFunction)(u8 *, u32, u8 *, u8 *, u32, int, int) = theApp.filterFunction;
 598.182 -	int  filterWidth = theApp.filterWidth, filterHeight = theApp.filterHeight;
 598.183 -/*
 598.184 -    if(textMethod == 1)
 598.185 -    {
 598.186 -        int copyX = 240, copyY = 160;
 598.187 -        if(systemCartridgeType == 1)
 598.188 -            if(gbBorderOn) copyX = 256, copyY = 224;
 598.189 -            else           copyX = 160, copyY = 144;
 598.190 -
 598.191 -        extern void Simple1x(u8*,u32,u8*,u8*,u32,int,int);
 598.192 -        filterFunction = Simple1x;
 598.193 -        filterWidth = copyX*2;
 598.194 -        filterHeight = copyY*2;
 598.195 -    }
 598.196 - */
 598.197 -	BITMAPINFO *bi = (BITMAPINFO *)info;
 598.198 -	bi->bmiHeader.biWidth  = filterWidth+1;
 598.199 -	bi->bmiHeader.biHeight = -filterHeight;
 598.200 -
 598.201 -	int pitch = filterWidth * 2 + 4;
 598.202 -	if (systemColorDepth == 32)
 598.203 -		pitch = filterWidth * 4 + 4;
 598.204 -	// FIXME: is the 24bit color depth still being used nowadays?
 598.205 -	else if (systemColorDepth == 24)
 598.206 -		pitch = filterWidth * 3;
 598.207 -
 598.208 -	// FIXME: is this working if systemColorDepth == 24?
 598.209 -	int filterPitch = theApp.rect.right*2;
 598.210 -	if (systemColorDepth == 32)
 598.211 -		filterPitch = theApp.rect.right*4;
 598.212 -	else if (systemColorDepth == 24)
 598.213 -		filterPitch = theApp.rect.right*3;
 598.214 -
 598.215 -/*
 598.216 -	// HACK: see below
 598.217 -	if (textMethod == 1 && !filterFunction)
 598.218 -	{
 598.219 -		textMethod = 0; // must not be after systemMessage!
 598.220 -		systemMessage(
 598.221 -		    0,
 598.222 -		    "The \"On Game\" text display mode does not work with this combination of renderers and filters.\nThe display mode is automatically being changed to \"In Game\" instead,\nbut this may cause message text to go into AVI recordings and screenshots.\nThis can be reconfigured by choosing \"Options->Video->Text Display Options...\"");
 598.223 -	}
 598.224 -*/
 598.225 -
 598.226 -	if (filterFunction)
 598.227 -	{
 598.228 -		bi->bmiHeader.biWidth  = theApp.rect.right;
 598.229 -		bi->bmiHeader.biHeight = -theApp.rect.bottom;
 598.230 -
 598.231 -		(*filterFunction)(pix + pitch,
 598.232 -						  pitch,
 598.233 -						  (u8 *)theApp.delta,
 598.234 -						  (u8 *)filterData,
 598.235 -						  filterPitch,
 598.236 -						  filterWidth,
 598.237 -						  filterHeight);
 598.238 -	}
 598.239 -
 598.240 -	if (theApp.showSpeed && theApp.videoOption > VIDEO_4X)
 598.241 -	{
 598.242 -		char buffer[30];
 598.243 -		if (theApp.showSpeed == 1)
 598.244 -			sprintf(buffer, "%3d%%", systemSpeed);
 598.245 -		else
 598.246 -			sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
 598.247 -			        systemFrameSkip,
 598.248 -			        theApp.showRenderedFrames);
 598.249 -
 598.250 -		if (filterFunction)
 598.251 -		{
 598.252 -			if (theApp.showSpeedTransparent)
 598.253 -				drawTextTransp((u8 *)filterData,
 598.254 -				               filterPitch,
 598.255 -				               theApp.rect.left+10,
 598.256 -				               theApp.rect.bottom-10,
 598.257 -				               buffer);
 598.258 -			else
 598.259 -				drawText((u8 *)filterData,
 598.260 -				         filterPitch,
 598.261 -			             theApp.rect.left+10,
 598.262 -			             theApp.rect.bottom-10,
 598.263 -				         buffer);
 598.264 -		}
 598.265 -		else
 598.266 -		{
 598.267 -			if (theApp.showSpeedTransparent)
 598.268 -				drawTextTransp((u8 *)pix,
 598.269 -				               pitch,
 598.270 -				               theApp.rect.left+10,
 598.271 -				               theApp.rect.bottom-10,
 598.272 -				               buffer);
 598.273 -			else
 598.274 -				drawText((u8 *)pix,
 598.275 -				         pitch,
 598.276 -			             theApp.rect.left+10,
 598.277 -			             theApp.rect.bottom-10,
 598.278 -				         buffer);
 598.279 -		}
 598.280 -	}
 598.281 -
 598.282 -	if (textMethod == 1 && filterFunction)
 598.283 -	{
 598.284 -		DrawTextMessages((u8 *)filterData, filterPitch, theApp.rect.left, theApp.rect.bottom);
 598.285 -	}
 598.286 -
 598.287 -	POINT p;
 598.288 -	p.x = theApp.dest.left;
 598.289 -	p.y = theApp.dest.top;
 598.290 -	CWnd *pWnd = theApp.m_pMainWnd;
 598.291 -	pWnd->ScreenToClient(&p);
 598.292 -	POINT p2;
 598.293 -	p2.x = theApp.dest.right;
 598.294 -	p2.y = theApp.dest.bottom;
 598.295 -	pWnd->ScreenToClient(&p2);
 598.296 -
 598.297 -	CDC *dc = pWnd->GetDC();
 598.298 -
 598.299 -	StretchDIBits((HDC)*dc,
 598.300 -	              p.x,
 598.301 -	              p.y,
 598.302 -	              p2.x - p.x,
 598.303 -	              p2.y - p.y,
 598.304 -	              0,
 598.305 -	              0,
 598.306 -	              theApp.rect.right,
 598.307 -	              theApp.rect.bottom,
 598.308 -	              filterFunction ? filterData : pix+pitch,
 598.309 -	              bi,
 598.310 -	              DIB_RGB_COLORS,
 598.311 -	              SRCCOPY);
 598.312 -
 598.313 -	if (textMethod == 2 || (textMethod == 1 && !filterFunction)) // HACK: so that textMethod isn't changed
 598.314 -		for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
 598.315 -		{
 598.316 -			if (theApp.screenMessage[slot])
 598.317 -			{
 598.318 -				if ((theApp.screenMessageDuration[slot] < 0 || 
 598.319 -					(int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
 598.320 -				    (!theApp.disableStatusMessage || slot == 1 || slot == 2))
 598.321 -				{
 598.322 -					dc->SetBkMode(TRANSPARENT);
 598.323 -
 598.324 -					if (outlinedText)
 598.325 -					{
 598.326 -						dc->SetTextColor(textColor != 7 ? RGB(0, 0, 0) : RGB(255, 255, 255));
 598.327 -
 598.328 -						// draw black outline
 598.329 -						const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 598.330 -						const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
 598.331 -						for (int i = 0; i < 8; i++)
 598.332 -						{
 598.333 -							dc->TextOut(p.x+10+xd[i], p2.y - 20*(slot+1)+yd[i], theApp.screenMessageBuffer[slot]);
 598.334 -						}
 598.335 -					}
 598.336 -
 598.337 -					COLORREF color;
 598.338 -					switch (textColor)
 598.339 -					{
 598.340 -					case 0:
 598.341 -						color = RGB(255, 255, 255); break;
 598.342 -					case 1:
 598.343 -						color = RGB(255, 0, 0); break;
 598.344 -					case 2:
 598.345 -						color = RGB(255, 255, 0); break;
 598.346 -					case 3:
 598.347 -						color = RGB(0, 255, 0); break;
 598.348 -					case 4:
 598.349 -						color = RGB(0, 255, 255); break;
 598.350 -					case 5:
 598.351 -						color = RGB(0, 0, 255); break;
 598.352 -					case 6:
 598.353 -						color = RGB(255, 0, 255); break;
 598.354 -					case 7:
 598.355 -						color = RGB(0, 0, 0); break;
 598.356 -					}
 598.357 -					dc->SetTextColor(color);
 598.358 -
 598.359 -					// draw center text
 598.360 -					dc->TextOut(p.x+10, p2.y - 20*(slot+1), theApp.screenMessageBuffer[slot]);
 598.361 -				}
 598.362 -				else
 598.363 -				{
 598.364 -					theApp.screenMessage[slot] = false;
 598.365 -				}
 598.366 -			}
 598.367 -		}
 598.368 -
 598.369 -	pWnd->ReleaseDC(dc);
 598.370 -}
 598.371 -
 598.372 -int GDIDisplay::selectFullScreenMode(GUID * *)
 598.373 -{
 598.374 -	HWND wnd = GetDesktopWindow();
 598.375 -	RECT r;
 598.376 -	GetWindowRect(wnd, &r);
 598.377 -	int w  = (r.right - r.left) & 4095;
 598.378 -	int h  = (r.bottom - r.top) & 4095;
 598.379 -	HDC dc = GetDC(wnd);
 598.380 -	int c  = GetDeviceCaps(dc, BITSPIXEL);
 598.381 -	ReleaseDC(wnd, dc);
 598.382 -
 598.383 -	return (c << 24) | (w << 12) | h;
 598.384 -}
 598.385 -
 598.386 -IDisplay *newGDIDisplay()
 598.387 -{
 598.388 -	return new GDIDisplay();
 598.389 -}
 598.390 -
   599.1 --- a/src/win32/GSACodeSelect.cpp	Sat Mar 03 10:54:39 2012 -0600
   599.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   599.3 @@ -1,96 +0,0 @@
   599.4 -// GSACodeSelect.cpp : implementation file
   599.5 -//
   599.6 -
   599.7 -#include "stdafx.h"
   599.8 -#include "resource.h"
   599.9 -#include "GSACodeSelect.h"
  599.10 -
  599.11 -/////////////////////////////////////////////////////////////////////////////
  599.12 -// GSACodeSelect dialog
  599.13 -
  599.14 -GSACodeSelect::GSACodeSelect(FILE *file, CWnd*pParent /*=NULL*/)
  599.15 -	: CDialog(GSACodeSelect::IDD, pParent)
  599.16 -{
  599.17 -	//{{AFX_DATA_INIT(GSACodeSelect)
  599.18 -	// NOTE: the ClassWizard will add member initialization here
  599.19 -	//}}AFX_DATA_INIT
  599.20 -	m_file = file;
  599.21 -}
  599.22 -
  599.23 -void GSACodeSelect::DoDataExchange(CDataExchange*pDX)
  599.24 -{
  599.25 -	CDialog::DoDataExchange(pDX);
  599.26 -	//{{AFX_DATA_MAP(GSACodeSelect)
  599.27 -	DDX_Control(pDX, IDC_GAME_LIST, m_games);
  599.28 -	//}}AFX_DATA_MAP
  599.29 -}
  599.30 -
  599.31 -BEGIN_MESSAGE_MAP(GSACodeSelect, CDialog)
  599.32 -//{{AFX_MSG_MAP(GSACodeSelect)
  599.33 -ON_BN_CLICKED(ID_OK, OnOk)
  599.34 -ON_LBN_SELCHANGE(IDC_GAME_LIST, OnSelchangeGameList)
  599.35 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  599.36 -//}}AFX_MSG_MAP
  599.37 -END_MESSAGE_MAP()
  599.38 -
  599.39 -/////////////////////////////////////////////////////////////////////////////
  599.40 -// GSACodeSelect message handlers
  599.41 -
  599.42 -void GSACodeSelect::OnCancel()
  599.43 -{
  599.44 -	EndDialog(-1);
  599.45 -}
  599.46 -
  599.47 -void GSACodeSelect::OnOk()
  599.48 -{
  599.49 -	EndDialog(m_games.GetCurSel());
  599.50 -}
  599.51 -
  599.52 -void GSACodeSelect::OnSelchangeGameList()
  599.53 -{
  599.54 -	int   item = m_games.GetCurSel();
  599.55 -	CWnd *ok   = GetDlgItem(ID_OK);
  599.56 -
  599.57 -	ok->EnableWindow(item != -1);
  599.58 -}
  599.59 -
  599.60 -BOOL GSACodeSelect::OnInitDialog()
  599.61 -{
  599.62 -	CDialog::OnInitDialog();
  599.63 -
  599.64 -	char buffer[1024];
  599.65 -
  599.66 -	FILE *f     = m_file;
  599.67 -	int   games = 0;
  599.68 -	int   len   = 0;
  599.69 -	fseek(f, -4, SEEK_CUR);
  599.70 -	fread(&games, 1, 4, f);
  599.71 -	while (games > 0)
  599.72 -	{
  599.73 -		fread(&len, 1, 4, f);
  599.74 -		fread(buffer, 1, len, f);
  599.75 -		buffer[len] = 0;
  599.76 -		m_games.AddString(buffer);
  599.77 -		int codes = 0;
  599.78 -		fread(&codes, 1, 4, f);
  599.79 -
  599.80 -		while (codes > 0)
  599.81 -		{
  599.82 -			fread(&len, 1, 4, f);
  599.83 -			fseek(f, len, SEEK_CUR);
  599.84 -			fread(&len, 1, 4, f);
  599.85 -			fseek(f, len, SEEK_CUR);
  599.86 -			fseek(f, 4, SEEK_CUR);
  599.87 -			fread(&len, 1, 4, f);
  599.88 -			fseek(f, len*12, SEEK_CUR);
  599.89 -			codes--;
  599.90 -		}
  599.91 -		games--;
  599.92 -	}
  599.93 -	GetDlgItem(ID_OK)->EnableWindow(FALSE);
  599.94 -	CenterWindow();
  599.95 -
  599.96 -	return TRUE; // return TRUE unless you set the focus to a control
  599.97 -	             // EXCEPTION: OCX Property Pages should return FALSE
  599.98 -}
  599.99 -
   600.1 --- a/src/win32/GSACodeSelect.h	Sat Mar 03 10:54:39 2012 -0600
   600.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   600.3 @@ -1,49 +0,0 @@
   600.4 -#if !defined(AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_)
   600.5 -#define AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_
   600.6 -
   600.7 -#if _MSC_VER > 1000
   600.8 -#pragma once
   600.9 -#endif // _MSC_VER > 1000
  600.10 -// -*- C++ -*-
  600.11 -// GSACodeSelect.h : header file
  600.12 -//
  600.13 -
  600.14 -/////////////////////////////////////////////////////////////////////////////
  600.15 -// GSACodeSelect dialog
  600.16 -
  600.17 -class GSACodeSelect : public CDialog
  600.18 -{
  600.19 -	// Construction
  600.20 -public:
  600.21 -	GSACodeSelect(FILE *file, CWnd*pParent = NULL);  // standard constructor
  600.22 -
  600.23 -	// Dialog Data
  600.24 -	//{{AFX_DATA(GSACodeSelect)
  600.25 -	enum { IDD = IDD_CODE_SELECT };
  600.26 -	CListBox m_games;
  600.27 -	//}}AFX_DATA
  600.28 -	FILE *m_file;
  600.29 -
  600.30 -	// Overrides
  600.31 -	// ClassWizard generated virtual function overrides
  600.32 -	//{{AFX_VIRTUAL(GSACodeSelect)
  600.33 -protected:
  600.34 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  600.35 -	//}}AFX_VIRTUAL
  600.36 -
  600.37 -	// Implementation
  600.38 -protected:
  600.39 -	// Generated message map functions
  600.40 -	//{{AFX_MSG(GSACodeSelect)
  600.41 -	afx_msg void OnCancel();
  600.42 -	afx_msg void OnOk();
  600.43 -	afx_msg void OnSelchangeGameList();
  600.44 -	virtual BOOL OnInitDialog();
  600.45 -	//}}AFX_MSG
  600.46 -	DECLARE_MESSAGE_MAP()
  600.47 -};
  600.48 -
  600.49 -//{{AFX_INSERT_LOCATION}}
  600.50 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  600.51 -
  600.52 -#endif // !defined(AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_)
   601.1 --- a/src/win32/Hyperlink.cpp	Sat Mar 03 10:54:39 2012 -0600
   601.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   601.3 @@ -1,93 +0,0 @@
   601.4 -// Hyperlink.cpp : implementation file
   601.5 -//
   601.6 -
   601.7 -#include "stdafx.h"
   601.8 -#include "Hyperlink.h"
   601.9 -
  601.10 -/////////////////////////////////////////////////////////////////////////////
  601.11 -// Hyperlink
  601.12 -
  601.13 -Hyperlink::Hyperlink()
  601.14 -{
  601.15 -  m_over = false;
  601.16 -}
  601.17 -
  601.18 -Hyperlink::~Hyperlink()
  601.19 -{
  601.20 -  m_underlineFont.DeleteObject();
  601.21 -}
  601.22 -
  601.23 -
  601.24 -BEGIN_MESSAGE_MAP(Hyperlink, CStatic)
  601.25 -  //{{AFX_MSG_MAP(Hyperlink)
  601.26 -  ON_WM_CTLCOLOR_REFLECT()
  601.27 -  ON_WM_ERASEBKGND()
  601.28 -  ON_WM_MOUSEMOVE()
  601.29 -  //}}AFX_MSG_MAP
  601.30 -  ON_CONTROL_REFLECT(STN_CLICKED, OnClicked)
  601.31 -END_MESSAGE_MAP()
  601.32 -
  601.33 -  /////////////////////////////////////////////////////////////////////////////
  601.34 -// Hyperlink message handlers
  601.35 -
  601.36 -void Hyperlink::PreSubclassWindow() 
  601.37 -{
  601.38 -  DWORD dwStyle = GetStyle();
  601.39 -  ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
  601.40 -
  601.41 -  // 32649 is the hand cursor
  601.42 -  m_cursor = LoadCursor(NULL, MAKEINTRESOURCE(32649));
  601.43 -
  601.44 -  CFont *font = GetFont();
  601.45 -
  601.46 -  LOGFONT lg;
  601.47 -  font->GetLogFont(&lg);
  601.48 -
  601.49 -  lg.lfUnderline = TRUE;
  601.50 -  
  601.51 -  m_underlineFont.CreateFontIndirect(&lg);
  601.52 -  SetFont(&m_underlineFont);
  601.53 -	
  601.54 -  CStatic::PreSubclassWindow();
  601.55 -}
  601.56 -
  601.57 -void Hyperlink::OnClicked()
  601.58 -{
  601.59 -  CString url;
  601.60 -  GetWindowText(url);
  601.61 -  ::ShellExecute(0, _T("open"), url, 
  601.62 -                 0, 0, SW_SHOWNORMAL);
  601.63 -}
  601.64 -
  601.65 -HBRUSH Hyperlink::CtlColor(CDC* pDC, UINT nCtlColor) 
  601.66 -{
  601.67 -  pDC->SetTextColor(RGB(0,0,240));
  601.68 -	
  601.69 -  return (HBRUSH)GetStockObject(NULL_BRUSH);
  601.70 -}
  601.71 -
  601.72 -BOOL Hyperlink::OnEraseBkgnd(CDC* pDC) 
  601.73 -{
  601.74 -  CRect rect;
  601.75 -  GetClientRect(rect);
  601.76 -  pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));
  601.77 -
  601.78 -  return TRUE;
  601.79 -}
  601.80 -
  601.81 -void Hyperlink::OnMouseMove(UINT nFlags, CPoint point) 
  601.82 -{
  601.83 -  if(!m_over) {
  601.84 -    m_over = true;
  601.85 -    SetCapture();
  601.86 -    ::SetCursor(m_cursor);
  601.87 -  } else {
  601.88 -    CRect r;
  601.89 -    GetClientRect(&r);
  601.90 -
  601.91 -    if(!r.PtInRect(point)) {
  601.92 -      m_over = false;
  601.93 -      ReleaseCapture();
  601.94 -    }
  601.95 -  }
  601.96 -}
   602.1 --- a/src/win32/Hyperlink.h	Sat Mar 03 10:54:39 2012 -0600
   602.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   602.3 @@ -1,54 +0,0 @@
   602.4 -#if !defined(AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_)
   602.5 -#define AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_
   602.6 -
   602.7 -#if _MSC_VER > 1000
   602.8 -#pragma once
   602.9 -#endif // _MSC_VER > 1000
  602.10 -// Hyperlink.h : header file
  602.11 -//
  602.12 -
  602.13 -/////////////////////////////////////////////////////////////////////////////
  602.14 -// Hyperlink window
  602.15 -
  602.16 -class Hyperlink : public CStatic
  602.17 -{
  602.18 -// Construction
  602.19 -public:
  602.20 -	Hyperlink();
  602.21 -
  602.22 -// Attributes
  602.23 -public:
  602.24 -// Operations
  602.25 -public:
  602.26 -// Overrides
  602.27 -	// ClassWizard generated virtual function overrides
  602.28 -	//{{AFX_VIRTUAL(Hyperlink)
  602.29 -protected:
  602.30 -	virtual void PreSubclassWindow();
  602.31 -	//}}AFX_VIRTUAL
  602.32 -
  602.33 -// Implementation
  602.34 -public:
  602.35 -	bool    m_over;
  602.36 -	HCURSOR m_cursor;
  602.37 -	afx_msg void OnClicked();
  602.38 -	CFont m_underlineFont;
  602.39 -	virtual ~Hyperlink();
  602.40 -
  602.41 -	// Generated message map functions
  602.42 -protected:
  602.43 -	//{{AFX_MSG(Hyperlink)
  602.44 -	afx_msg HBRUSH CtlColor(CDC*pDC, UINT nCtlColor);
  602.45 -	afx_msg BOOL OnEraseBkgnd(CDC*pDC);
  602.46 -	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  602.47 -	//}}AFX_MSG
  602.48 -
  602.49 -	DECLARE_MESSAGE_MAP()
  602.50 -};
  602.51 -
  602.52 -/////////////////////////////////////////////////////////////////////////////
  602.53 -
  602.54 -//{{AFX_INSERT_LOCATION}}
  602.55 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  602.56 -
  602.57 -#endif // !defined(AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_)
   603.1 --- a/src/win32/IOViewer.cpp	Sat Mar 03 10:54:39 2012 -0600
   603.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   603.3 @@ -1,183 +0,0 @@
   603.4 -// IOViewer.cpp : implementation file
   603.5 -//
   603.6 -
   603.7 -#include "stdafx.h"
   603.8 -#include "resource.h"
   603.9 -#include "IOViewer.h"
  603.10 -#include "VBA.h"
  603.11 -
  603.12 -#include "../gba/GBA.h" // CPUWriteHalfWord
  603.13 -#include "../gba/GBAGlobals.h"
  603.14 -
  603.15 -#include "IOViewerRegs.h"
  603.16 -
  603.17 -/////////////////////////////////////////////////////////////////////////////
  603.18 -// IOViewer dialog
  603.19 -
  603.20 -IOViewer::IOViewer(CWnd*pParent /*=NULL*/)
  603.21 -	: ResizeDlg(IOViewer::IDD, pParent)
  603.22 -{
  603.23 -	//{{AFX_DATA_INIT(IOViewer)
  603.24 -	// NOTE: the ClassWizard will add member initialization here
  603.25 -	//}}AFX_DATA_INIT
  603.26 -	selected   = 0;
  603.27 -	autoUpdate = false;
  603.28 -}
  603.29 -
  603.30 -void IOViewer::DoDataExchange(CDataExchange*pDX)
  603.31 -{
  603.32 -	CDialog::DoDataExchange(pDX);
  603.33 -	//{{AFX_DATA_MAP(IOViewer)
  603.34 -	DDX_Control(pDX, IDC_VALUE, m_value);
  603.35 -	DDX_Control(pDX, IDC_ADDRESSES, m_address);
  603.36 -	//}}AFX_DATA_MAP
  603.37 -}
  603.38 -
  603.39 -BEGIN_MESSAGE_MAP(IOViewer, CDialog)
  603.40 -//{{AFX_MSG_MAP(IOViewer)
  603.41 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  603.42 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  603.43 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  603.44 -ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses)
  603.45 -ON_BN_CLICKED(IDC_APPLY, OnApply)
  603.46 -//}}AFX_MSG_MAP
  603.47 -END_MESSAGE_MAP()
  603.48 -
  603.49 -/////////////////////////////////////////////////////////////////////////////
  603.50 -// IOViewer message handlers
  603.51 -
  603.52 -void IOViewer::OnClose()
  603.53 -{
  603.54 -	theApp.winRemoveUpdateListener(this);
  603.55 -
  603.56 -	DestroyWindow();
  603.57 -}
  603.58 -
  603.59 -void IOViewer::OnRefresh()
  603.60 -{
  603.61 -	// TODO: Add your control notification handler code here
  603.62 -}
  603.63 -
  603.64 -void IOViewer::OnAutoUpdate()
  603.65 -{
  603.66 -	autoUpdate = !autoUpdate;
  603.67 -	if (autoUpdate)
  603.68 -	{
  603.69 -		theApp.winAddUpdateListener(this);
  603.70 -	}
  603.71 -	else
  603.72 -	{
  603.73 -		theApp.winRemoveUpdateListener(this);
  603.74 -	}
  603.75 -}
  603.76 -
  603.77 -void IOViewer::OnSelchangeAddresses()
  603.78 -{
  603.79 -	selected = m_address.GetCurSel();
  603.80 -
  603.81 -	update();
  603.82 -}
  603.83 -
  603.84 -void IOViewer::PostNcDestroy()
  603.85 -{
  603.86 -	delete this;
  603.87 -}
  603.88 -
  603.89 -BOOL IOViewer::OnInitDialog()
  603.90 -{
  603.91 -	CDialog::OnInitDialog();
  603.92 -
  603.93 -	// winCenterWindow(getHandle());
  603.94 -	DIALOG_SIZER_START(sz)
  603.95 -	DIALOG_SIZER_END()
  603.96 -	SetData(sz,
  603.97 -	        TRUE,
  603.98 -	        HKEY_CURRENT_USER,
  603.99 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\IOView",
 603.100 -	        NULL);
 603.101 -
 603.102 -	CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
 603.103 -	int    i;
 603.104 -	for (i = 0; i < sizeof(ioViewRegisters)/sizeof(IOData); i++)
 603.105 -	{
 603.106 -		m_address.AddString(ioViewRegisters[i].name);
 603.107 -	}
 603.108 -	m_address.SetFont(font);
 603.109 -	for (i = 0; i < 16; i++)
 603.110 -	{
 603.111 -		GetDlgItem(IDC_BIT_0+i)->SetFont(font);
 603.112 -	}
 603.113 -
 603.114 -	RECT cbSize;
 603.115 -	int  Height;
 603.116 -
 603.117 -	m_address.GetClientRect(&cbSize);
 603.118 -	Height  = m_address.GetItemHeight(0);
 603.119 -	Height += m_address.GetItemHeight(0) * (10);
 603.120 -
 603.121 -	// Note: The use of SM_CYEDGE assumes that we're using Windows '95
 603.122 -	// Now add on the height of the border of the edit box
 603.123 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 603.124 -
 603.125 -	// The height of the border of the drop-down box
 603.126 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 603.127 -
 603.128 -	// now set the size of the window
 603.129 -	m_address.SetWindowPos(NULL,
 603.130 -	                       0, 0,
 603.131 -	                       cbSize.right, Height,
 603.132 -	                       SWP_NOMOVE | SWP_NOZORDER);
 603.133 -
 603.134 -	m_address.SetCurSel(0);
 603.135 -	update();
 603.136 -
 603.137 -	return TRUE; // return TRUE unless you set the focus to a control
 603.138 -	             // EXCEPTION: OCX Property Pages should return FALSE
 603.139 -}
 603.140 -
 603.141 -void IOViewer::update()
 603.142 -{
 603.143 -	CString buffer;
 603.144 -
 603.145 -	const IOData *sel = &ioViewRegisters[selected];
 603.146 -	u16 data = sel->address ? *sel->address :
 603.147 -	           (ioMem ? *((u16 *)&ioMem[sel->offset]) : 0);
 603.148 -
 603.149 -	for (int i = 0; i < 16; i++)
 603.150 -	{
 603.151 -		CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
 603.152 -
 603.153 -		if (pWnd)
 603.154 -		{
 603.155 -			if (!(sel->write & (1 << i)))
 603.156 -				pWnd->EnableWindow(FALSE);
 603.157 -			else
 603.158 -				pWnd->EnableWindow(TRUE);
 603.159 -			pWnd->SetCheck(((data & (1 << i)) >> i));
 603.160 -			buffer.Format("%2d %s", i, sel->bits[i]);
 603.161 -			pWnd->SetWindowText(buffer);
 603.162 -		}
 603.163 -	}
 603.164 -
 603.165 -	buffer.Format("%04X", data);
 603.166 -	m_value.SetWindowText(buffer);
 603.167 -}
 603.168 -
 603.169 -void IOViewer::OnApply()
 603.170 -{
 603.171 -	const IOData *sel = &ioViewRegisters[selected];
 603.172 -	u16 res = 0;
 603.173 -	for (int i = 0; i < 16; i++)
 603.174 -	{
 603.175 -		CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
 603.176 -
 603.177 -		if (pWnd)
 603.178 -		{
 603.179 -			if (pWnd->GetCheck())
 603.180 -				res |= (1 << i);
 603.181 -		}
 603.182 -	}
 603.183 -	CPUWriteHalfWord(0x4000000+sel->offset, res);
 603.184 -	update();
 603.185 -}
 603.186 -
   604.1 --- a/src/win32/IOViewer.h	Sat Mar 03 10:54:39 2012 -0600
   604.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   604.3 @@ -1,58 +0,0 @@
   604.4 -#if !defined(AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_)
   604.5 -#define AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_
   604.6 -
   604.7 -#if _MSC_VER > 1000
   604.8 -#pragma once
   604.9 -#endif // _MSC_VER > 1000
  604.10 -// -*- C++ -*-
  604.11 -// IOViewer.h : header file
  604.12 -//
  604.13 -
  604.14 -#include "ResizeDlg.h"
  604.15 -#include "IUpdate.h"
  604.16 -
  604.17 -/////////////////////////////////////////////////////////////////////////////
  604.18 -// IOViewer dialog
  604.19 -
  604.20 -class IOViewer : public ResizeDlg, IUpdateListener
  604.21 -{
  604.22 -	// Construction
  604.23 -public:
  604.24 -	void update();
  604.25 -	bool autoUpdate;
  604.26 -	int  selected;
  604.27 -	IOViewer(CWnd*pParent = NULL);  // standard constructor
  604.28 -
  604.29 -	// Dialog Data
  604.30 -	//{{AFX_DATA(IOViewer)
  604.31 -	enum { IDD = IDD_IO_VIEWER };
  604.32 -	CStatic   m_value;
  604.33 -	CComboBox m_address;
  604.34 -	//}}AFX_DATA
  604.35 -
  604.36 -	// Overrides
  604.37 -	// ClassWizard generated virtual function overrides
  604.38 -	//{{AFX_VIRTUAL(IOViewer)
  604.39 -protected:
  604.40 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  604.41 -	virtual void PostNcDestroy();
  604.42 -	//}}AFX_VIRTUAL
  604.43 -
  604.44 -	// Implementation
  604.45 -protected:
  604.46 -	// Generated message map functions
  604.47 -	//{{AFX_MSG(IOViewer)
  604.48 -	afx_msg void OnClose();
  604.49 -	afx_msg void OnRefresh();
  604.50 -	afx_msg void OnAutoUpdate();
  604.51 -	afx_msg void OnSelchangeAddresses();
  604.52 -	virtual BOOL OnInitDialog();
  604.53 -	afx_msg void OnApply();
  604.54 -	//}}AFX_MSG
  604.55 -	DECLARE_MESSAGE_MAP()
  604.56 -};
  604.57 -
  604.58 -//{{AFX_INSERT_LOCATION}}
  604.59 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  604.60 -
  604.61 -#endif // !defined(AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_)
   605.1 --- a/src/win32/IOViewerRegs.h	Sat Mar 03 10:54:39 2012 -0600
   605.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   605.3 @@ -1,2078 +0,0 @@
   605.4 -#ifndef VBA_IOVIEWERREGS_H
   605.5 -#define VBA_IOVIEWERREGS_H
   605.6 -
   605.7 -#if _MSC_VER > 1000
   605.8 -#pragma once
   605.9 -#endif // _MSC_VER > 1000
  605.10 -
  605.11 -struct IOData
  605.12 -{
  605.13 -	u16 * address;
  605.14 -	u16   offset;
  605.15 -	char *name;
  605.16 -	u16   write;
  605.17 -	char *bits[16];
  605.18 -};
  605.19 -
  605.20 -const IOData ioViewRegisters[] = {
  605.21 -	{
  605.22 -		&DISPCNT, 0, "0x4000000-DISPCNT", 0xFFF7,
  605.23 -		{
  605.24 -			"",
  605.25 -			"",
  605.26 -			"BG Mode (3 bits)",
  605.27 -			"CGB Mode",
  605.28 -			"Display Frame",
  605.29 -			"H-Blank Interval OBJ processing",
  605.30 -			"OBJ Character mapping",
  605.31 -			"Forced blank",
  605.32 -			"BG0",
  605.33 -			"BG1",
  605.34 -			"BG2",
  605.35 -			"BG3",
  605.36 -			"OBJ",
  605.37 -			"WIN0",
  605.38 -			"WIN1",
  605.39 -			"OBJWIN"
  605.40 -		}
  605.41 -	},
  605.42 -	{
  605.43 -		&DISPSTAT, 4, "0x4000004-DISPSTAT", 0xFF38,
  605.44 -		{
  605.45 -			"V-Blank Status",
  605.46 -			"H-Blank Status",
  605.47 -			"VCOUNT Evaluation",
  605.48 -			"V-Blank Interrupt Enable",
  605.49 -			"H-Blank Interrupt Enable",
  605.50 -			"VCOUNT Match Interrupt Enable",
  605.51 -			"",
  605.52 -			"",
  605.53 -			"",
  605.54 -			"",
  605.55 -			"",
  605.56 -			"",
  605.57 -			"",
  605.58 -			"",
  605.59 -			"",
  605.60 -			"VCOUNT setting (8 bits)"
  605.61 -		}
  605.62 -	},
  605.63 -	{
  605.64 -		&VCOUNT, 6, "0x4000006-VCOUNT", 0x0000,
  605.65 -		{
  605.66 -			"",
  605.67 -			"",
  605.68 -			"",
  605.69 -			"",
  605.70 -			"",
  605.71 -			"",
  605.72 -			"",
  605.73 -			"VCOUNT (8 bits)",
  605.74 -			"",
  605.75 -			"",
  605.76 -			"",
  605.77 -			"",
  605.78 -			"",
  605.79 -			"",
  605.80 -			"",
  605.81 -			""
  605.82 -		}
  605.83 -	},
  605.84 -	{
  605.85 -		&BG0CNT, 8, "0x4000008-BG0CNT", 0xDFCF,
  605.86 -		{
  605.87 -			"",
  605.88 -			"Priority (2 bits)",
  605.89 -			"",
  605.90 -			"Char base (2 bits)",
  605.91 -			"",
  605.92 -			"",
  605.93 -			"Mosaic",
  605.94 -			"16/256 colors",
  605.95 -			"",
  605.96 -			"",
  605.97 -			"",
  605.98 -			"",
  605.99 -			"Screen Base Block (5 bits)",
 605.100 -			"",
 605.101 -			"",
 605.102 -			"Size (2 bits)"
 605.103 -		}
 605.104 -	},
 605.105 -	{
 605.106 -		&BG1CNT, 0xA, "0x400000A-BG1CNT", 0xDFCF,
 605.107 -		{
 605.108 -			"",
 605.109 -			"Priority (2 bits)",
 605.110 -			"",
 605.111 -			"Char base (2 bits)",
 605.112 -			"",
 605.113 -			"",
 605.114 -			"Mosaic",
 605.115 -			"16/256 colors",
 605.116 -			"",
 605.117 -			"",
 605.118 -			"",
 605.119 -			"",
 605.120 -			"Screen Base Block (5 bits)",
 605.121 -			"",
 605.122 -			"",
 605.123 -			"Size (2 bits)"
 605.124 -		}
 605.125 -	},
 605.126 -	{
 605.127 -		&BG2CNT, 0xC, "0x400000C-BG2CNT", 0xFFCF,
 605.128 -		{
 605.129 -			"",
 605.130 -			"Priority (2 bits)",
 605.131 -			"",
 605.132 -			"Char base (2 bits)",
 605.133 -			"",
 605.134 -			"",
 605.135 -			"Mosaic",
 605.136 -			"16/256 colors",
 605.137 -			"",
 605.138 -			"",
 605.139 -			"",
 605.140 -			"",
 605.141 -			"Screen Base Block (5 bits)",
 605.142 -			"Area Overflow",
 605.143 -			"",
 605.144 -			"Size (2 bits)"
 605.145 -		}
 605.146 -	},
 605.147 -	{
 605.148 -		&BG3CNT, 0xE, "0x400000E-BG3CNT", 0xFFCF,
 605.149 -		{
 605.150 -			"",
 605.151 -			"Priority (2 bits)",
 605.152 -			"",
 605.153 -			"Char base (2 bits)",
 605.154 -			"",
 605.155 -			"",
 605.156 -			"Mosaic",
 605.157 -			"16/256 colors",
 605.158 -			"",
 605.159 -			"",
 605.160 -			"",
 605.161 -			"",
 605.162 -			"Screen Base Block (5 bits)",
 605.163 -			"Area Overflow",
 605.164 -			"",
 605.165 -			"Size (2 bits)"
 605.166 -		}
 605.167 -	},
 605.168 -	{
 605.169 -		&BG0HOFS, 0x10, "0x4000010-BG0HOFS", 0x01FF,
 605.170 -		{
 605.171 -			"",
 605.172 -			"",
 605.173 -			"",
 605.174 -			"",
 605.175 -			"",
 605.176 -			"",
 605.177 -			"",
 605.178 -			"",
 605.179 -			"Horizontal Offset (9 bits, W)",
 605.180 -			"",
 605.181 -			"",
 605.182 -			"",
 605.183 -			"",
 605.184 -			"",
 605.185 -			"",
 605.186 -			""
 605.187 -		}
 605.188 -	},
 605.189 -	{
 605.190 -		&BG0VOFS, 0x12, "0x4000012-BG0VOFS", 0x01FF,
 605.191 -		{
 605.192 -			"",
 605.193 -			"",
 605.194 -			"",
 605.195 -			"",
 605.196 -			"",
 605.197 -			"",
 605.198 -			"",
 605.199 -			"",
 605.200 -			"Vertical Offset (9 bits, W)",
 605.201 -			"",
 605.202 -			"",
 605.203 -			"",
 605.204 -			"",
 605.205 -			"",
 605.206 -			"",
 605.207 -			""
 605.208 -		}
 605.209 -	},
 605.210 -	{
 605.211 -		&BG1HOFS, 0x14, "0x4000014-BG1HOFS", 0x01FF,
 605.212 -		{
 605.213 -			"",
 605.214 -			"",
 605.215 -			"",
 605.216 -			"",
 605.217 -			"",
 605.218 -			"",
 605.219 -			"",
 605.220 -			"",
 605.221 -			"Horizontal Offset (9 bits, W)",
 605.222 -			"",
 605.223 -			"",
 605.224 -			"",
 605.225 -			"",
 605.226 -			"",
 605.227 -			"",
 605.228 -			""
 605.229 -		}
 605.230 -	},
 605.231 -	{
 605.232 -		&BG1VOFS, 0x16, "0x4000016-BG1VOFS", 0x01FF,
 605.233 -		{
 605.234 -			"",
 605.235 -			"",
 605.236 -			"",
 605.237 -			"",
 605.238 -			"",
 605.239 -			"",
 605.240 -			"",
 605.241 -			"",
 605.242 -			"Vertical Offset (9 bits, W)",
 605.243 -			"",
 605.244 -			"",
 605.245 -			"",
 605.246 -			"",
 605.247 -			"",
 605.248 -			"",
 605.249 -			""
 605.250 -		}
 605.251 -	},
 605.252 -	{
 605.253 -		&BG2HOFS, 0x18, "0x4000018-BG8HOFS", 0x01FF,
 605.254 -		{
 605.255 -			"",
 605.256 -			"",
 605.257 -			"",
 605.258 -			"",
 605.259 -			"",
 605.260 -			"",
 605.261 -			"",
 605.262 -			"",
 605.263 -			"Horizontal Offset (9 bits, W)",
 605.264 -			"",
 605.265 -			"",
 605.266 -			"",
 605.267 -			"",
 605.268 -			"",
 605.269 -			"",
 605.270 -			""
 605.271 -		}
 605.272 -	},
 605.273 -	{
 605.274 -		&BG2VOFS, 0x1A, "0x400001A-BG2VOFS", 0x01FF,
 605.275 -		{
 605.276 -			"",
 605.277 -			"",
 605.278 -			"",
 605.279 -			"",
 605.280 -			"",
 605.281 -			"",
 605.282 -			"",
 605.283 -			"",
 605.284 -			"Vertical Offset (9 bits, W)",
 605.285 -			"",
 605.286 -			"",
 605.287 -			"",
 605.288 -			"",
 605.289 -			"",
 605.290 -			"",
 605.291 -			""
 605.292 -		}
 605.293 -	},
 605.294 -	{
 605.295 -		&BG3HOFS, 0x1C, "0x400001C-BG3HOFS", 0x01FF,
 605.296 -		{
 605.297 -			"",
 605.298 -			"",
 605.299 -			"",
 605.300 -			"",
 605.301 -			"",
 605.302 -			"",
 605.303 -			"",
 605.304 -			"",
 605.305 -			"Horizontal Offset (9 bits,W)",
 605.306 -			"",
 605.307 -			"",
 605.308 -			"",
 605.309 -			"",
 605.310 -			"",
 605.311 -			"",
 605.312 -			""
 605.313 -		}
 605.314 -	},
 605.315 -	{
 605.316 -		&BG3VOFS, 0x1E, "0x400001E-BG3VOFS", 0x01FF,
 605.317 -		{
 605.318 -			"",
 605.319 -			"",
 605.320 -			"",
 605.321 -			"",
 605.322 -			"",
 605.323 -			"",
 605.324 -			"",
 605.325 -			"",
 605.326 -			"Vertical Offset (9 bits,W)",
 605.327 -			"",
 605.328 -			"",
 605.329 -			"",
 605.330 -			"",
 605.331 -			"",
 605.332 -			"",
 605.333 -			""
 605.334 -		}
 605.335 -	},
 605.336 -	{
 605.337 -		&BG2PA, 0x20, "0x4000020-BG2PA", 0xFFFF,
 605.338 -		{
 605.339 -			"",
 605.340 -			"",
 605.341 -			"",
 605.342 -			"",
 605.343 -			"",
 605.344 -			"",
 605.345 -			"",
 605.346 -			"",
 605.347 -			"",
 605.348 -			"",
 605.349 -			"",
 605.350 -			"",
 605.351 -			"",
 605.352 -			"",
 605.353 -			"",
 605.354 -			"dx (16 bits,W)"
 605.355 -		}
 605.356 -	},
 605.357 -	{
 605.358 -		&BG2PB, 0x22, "0x4000022-BG2PB", 0xFFFF,
 605.359 -		{
 605.360 -			"",
 605.361 -			"",
 605.362 -			"",
 605.363 -			"",
 605.364 -			"",
 605.365 -			"",
 605.366 -			"",
 605.367 -			"",
 605.368 -			"",
 605.369 -			"",
 605.370 -			"",
 605.371 -			"",
 605.372 -			"",
 605.373 -			"",
 605.374 -			"",
 605.375 -			"dmx (16 bits,W)"
 605.376 -		}
 605.377 -	},
 605.378 -	{
 605.379 -		&BG2PC, 0x24, "0x4000024-BG2PC", 0xFFFF,
 605.380 -		{
 605.381 -			"",
 605.382 -			"",
 605.383 -			"",
 605.384 -			"",
 605.385 -			"",
 605.386 -			"",
 605.387 -			"",
 605.388 -			"",
 605.389 -			"",
 605.390 -			"",
 605.391 -			"",
 605.392 -			"",
 605.393 -			"",
 605.394 -			"",
 605.395 -			"",
 605.396 -			"dy (16 bits,W)"
 605.397 -		}
 605.398 -	},
 605.399 -	{
 605.400 -		&BG2PD, 0x26, "0x4000026-BG2PD", 0xFFFF,
 605.401 -		{
 605.402 -			"",
 605.403 -			"",
 605.404 -			"",
 605.405 -			"",
 605.406 -			"",
 605.407 -			"",
 605.408 -			"",
 605.409 -			"",
 605.410 -			"",
 605.411 -			"",
 605.412 -			"",
 605.413 -			"",
 605.414 -			"",
 605.415 -			"",
 605.416 -			"",
 605.417 -			"dmy (16 bits,W)"
 605.418 -		}
 605.419 -	},
 605.420 -	{
 605.421 -		&BG2X_L, 0x28, "0x4000028-BG2X_L", 0xFFFF,
 605.422 -		{
 605.423 -			"",
 605.424 -			"",
 605.425 -			"",
 605.426 -			"",
 605.427 -			"",
 605.428 -			"",
 605.429 -			"",
 605.430 -			"",
 605.431 -			"",
 605.432 -			"",
 605.433 -			"",
 605.434 -			"",
 605.435 -			"",
 605.436 -			"",
 605.437 -			"",
 605.438 -			"X low bits (16 bits,W)"
 605.439 -		}
 605.440 -	},
 605.441 -	{
 605.442 -		&BG2X_H, 0x2A, "0x400002A-BG2X_H", 0x0FFF,
 605.443 -		{
 605.444 -			"",
 605.445 -			"",
 605.446 -			"",
 605.447 -			"",
 605.448 -			"",
 605.449 -			"",
 605.450 -			"",
 605.451 -			"",
 605.452 -			"",
 605.453 -			"",
 605.454 -			"",
 605.455 -			"X high bits (12 bits,W)",
 605.456 -			"",
 605.457 -			"",
 605.458 -			"",
 605.459 -			"",
 605.460 -		}
 605.461 -	},
 605.462 -	{
 605.463 -		&BG2Y_L, 0x2C, "0x400002C-BG2Y_L", 0xFFFF,
 605.464 -		{
 605.465 -			"",
 605.466 -			"",
 605.467 -			"",
 605.468 -			"",
 605.469 -			"",
 605.470 -			"",
 605.471 -			"",
 605.472 -			"",
 605.473 -			"",
 605.474 -			"",
 605.475 -			"",
 605.476 -			"",
 605.477 -			"",
 605.478 -			"",
 605.479 -			"",
 605.480 -			"Y low bits (16 bits,W)"
 605.481 -		}
 605.482 -	},
 605.483 -	{
 605.484 -		&BG2Y_H, 0x2E, "0x400002E-BG2Y_H", 0x0FFF,
 605.485 -		{
 605.486 -			"",
 605.487 -			"",
 605.488 -			"",
 605.489 -			"",
 605.490 -			"",
 605.491 -			"",
 605.492 -			"",
 605.493 -			"",
 605.494 -			"",
 605.495 -			"",
 605.496 -			"",
 605.497 -			"Y hight bits (12 bits,W)",
 605.498 -			"",
 605.499 -			"",
 605.500 -			"",
 605.501 -			"",
 605.502 -		}
 605.503 -	},
 605.504 -	{
 605.505 -		&BG3PA, 0x30, "0x4000030-BG3PA", 0xFFFF,
 605.506 -		{
 605.507 -			"",
 605.508 -			"",
 605.509 -			"",
 605.510 -			"",
 605.511 -			"",
 605.512 -			"",
 605.513 -			"",
 605.514 -			"",
 605.515 -			"",
 605.516 -			"",
 605.517 -			"",
 605.518 -			"",
 605.519 -			"",
 605.520 -			"",
 605.521 -			"",
 605.522 -			"dx (16 bits,W)"
 605.523 -		}
 605.524 -	},
 605.525 -	{
 605.526 -		&BG3PB, 0x32, "0x4000032-BG3PB", 0xFFFF,
 605.527 -		{
 605.528 -			"",
 605.529 -			"",
 605.530 -			"",
 605.531 -			"",
 605.532 -			"",
 605.533 -			"",
 605.534 -			"",
 605.535 -			"",
 605.536 -			"",
 605.537 -			"",
 605.538 -			"",
 605.539 -			"",
 605.540 -			"",
 605.541 -			"",
 605.542 -			"",
 605.543 -			"dmx (16 bits,W)"
 605.544 -		}
 605.545 -	},
 605.546 -	{
 605.547 -		&BG3PC, 0x34, "0x4000034-BG3PC", 0xFFFF,
 605.548 -		{
 605.549 -			"",
 605.550 -			"",
 605.551 -			"",
 605.552 -			"",
 605.553 -			"",
 605.554 -			"",
 605.555 -			"",
 605.556 -			"",
 605.557 -			"",
 605.558 -			"",
 605.559 -			"",
 605.560 -			"",
 605.561 -			"",
 605.562 -			"",
 605.563 -			"",
 605.564 -			"dy (16 bits,W)"
 605.565 -		}
 605.566 -	},
 605.567 -	{
 605.568 -		&BG3PD, 0x36, "0x4000036-BG3PD", 0xFFFF,
 605.569 -		{
 605.570 -			"",
 605.571 -			"",
 605.572 -			"",
 605.573 -			"",
 605.574 -			"",
 605.575 -			"",
 605.576 -			"",
 605.577 -			"",
 605.578 -			"",
 605.579 -			"",
 605.580 -			"",
 605.581 -			"",
 605.582 -			"",
 605.583 -			"",
 605.584 -			"",
 605.585 -			"dmy (16 bits,W)"
 605.586 -		}
 605.587 -	},
 605.588 -	{
 605.589 -		&BG3X_L, 0x38, "0x4000038-BG3X_L", 0xFFFF,
 605.590 -		{
 605.591 -			"",
 605.592 -			"",
 605.593 -			"",
 605.594 -			"",
 605.595 -			"",
 605.596 -			"",
 605.597 -			"",
 605.598 -			"",
 605.599 -			"",
 605.600 -			"",
 605.601 -			"",
 605.602 -			"",
 605.603 -			"",
 605.604 -			"",
 605.605 -			"",
 605.606 -			"X low bits (16 bits,W)"
 605.607 -		}
 605.608 -	},
 605.609 -	{
 605.610 -		&BG3X_H, 0x3A, "0x400003A-BG3X_H", 0x0FFF,
 605.611 -		{
 605.612 -			"",
 605.613 -			"",
 605.614 -			"",
 605.615 -			"",
 605.616 -			"",
 605.617 -			"",
 605.618 -			"",
 605.619 -			"",
 605.620 -			"",
 605.621 -			"",
 605.622 -			"",
 605.623 -			"X hight bits (12 bits,W)",
 605.624 -			"",
 605.625 -			"",
 605.626 -			"",
 605.627 -			"",
 605.628 -		}
 605.629 -	},
 605.630 -	{
 605.631 -		&BG3Y_L, 0x3C, "0x400003C-BG3Y_L", 0xFFFF,
 605.632 -		{
 605.633 -			"",
 605.634 -			"",
 605.635 -			"",
 605.636 -			"",
 605.637 -			"",
 605.638 -			"",
 605.639 -			"",
 605.640 -			"",
 605.641 -			"",
 605.642 -			"",
 605.643 -			"",
 605.644 -			"",
 605.645 -			"",
 605.646 -			"",
 605.647 -			"",
 605.648 -			"Y low bits (16 bits,W)"
 605.649 -		}
 605.650 -	},
 605.651 -	{
 605.652 -		&BG3Y_H, 0x3E, "0x400003E-BG3Y_H", 0x0FFF,
 605.653 -		{
 605.654 -			"",
 605.655 -			"",
 605.656 -			"",
 605.657 -			"",
 605.658 -			"",
 605.659 -			"",
 605.660 -			"",
 605.661 -			"",
 605.662 -			"",
 605.663 -			"",
 605.664 -			"",
 605.665 -			"Y hight bits (12 bits,W)",
 605.666 -			"",
 605.667 -			"",
 605.668 -			"",
 605.669 -			"",
 605.670 -		}
 605.671 -	},
 605.672 -	{
 605.673 -		&WIN0H, 0x40, "0x4000040-WIN0H", 0xFFFF,
 605.674 -		{
 605.675 -			"",
 605.676 -			"",
 605.677 -			"",
 605.678 -			"",
 605.679 -			"",
 605.680 -			"",
 605.681 -			"",
 605.682 -			"Win 0 lower-right X (8 bits,W)",
 605.683 -			"",
 605.684 -			"",
 605.685 -			"",
 605.686 -			"",
 605.687 -			"",
 605.688 -			"",
 605.689 -			"",
 605.690 -			"Win 0 upper-left X (8 bits,W)",
 605.691 -		}
 605.692 -	},
 605.693 -	{
 605.694 -		&WIN1H, 0x42, "0x4000042-WIN1H", 0xFFFF,
 605.695 -		{
 605.696 -			"",
 605.697 -			"",
 605.698 -			"",
 605.699 -			"",
 605.700 -			"",
 605.701 -			"",
 605.702 -			"",
 605.703 -			"Win 1 lower-right X (8 bits,W)",
 605.704 -			"",
 605.705 -			"",
 605.706 -			"",
 605.707 -			"",
 605.708 -			"",
 605.709 -			"",
 605.710 -			"",
 605.711 -			"Win 1 upper-left (8 bits,W)",
 605.712 -		}
 605.713 -	},
 605.714 -	{
 605.715 -		&WIN0V, 0x44, "0x4000044-WIN0V", 0xFFFF,
 605.716 -		{
 605.717 -			"",
 605.718 -			"",
 605.719 -			"",
 605.720 -			"",
 605.721 -			"",
 605.722 -			"",
 605.723 -			"",
 605.724 -			"Win 0 lower-right Y (8 bits,W)",
 605.725 -			"",
 605.726 -			"",
 605.727 -			"",
 605.728 -			"",
 605.729 -			"",
 605.730 -			"",
 605.731 -			"",
 605.732 -			"Win 0 upper-left Y (8 bits,W)",
 605.733 -		}
 605.734 -	},
 605.735 -	{
 605.736 -		&WIN1V, 0x46, "0x4000046-WIN1V", 0xFFFF,
 605.737 -		{
 605.738 -			"",
 605.739 -			"",
 605.740 -			"",
 605.741 -			"",
 605.742 -			"",
 605.743 -			"",
 605.744 -			"",
 605.745 -			"Win 1 lower-right Y (8 bits,W)",
 605.746 -			"",
 605.747 -			"",
 605.748 -			"",
 605.749 -			"",
 605.750 -			"",
 605.751 -			"",
 605.752 -			"",
 605.753 -			"Win 1 upper-left Y (8 bits,W)",
 605.754 -		}
 605.755 -	},
 605.756 -	{
 605.757 -		&WININ, 0x48, "0x4000048-WININ", 0x3F3F,
 605.758 -		{
 605.759 -			"WIN0 BG0",
 605.760 -			"WIN0 BG1",
 605.761 -			"WIN0 BG2",
 605.762 -			"WIN0 BG3",
 605.763 -			"WIN0 OBJ",
 605.764 -			"WIN0 Special FX",
 605.765 -			"",
 605.766 -			"",
 605.767 -			"WIN1 BG0",
 605.768 -			"WIN1 BG1",
 605.769 -			"WIN1 BG2",
 605.770 -			"WIN1 BG3",
 605.771 -			"WIN1 OBJ",
 605.772 -			"WIN1 Special FX",
 605.773 -			"",
 605.774 -			"",
 605.775 -		}
 605.776 -	},
 605.777 -	{
 605.778 -		&WINOUT, 0x4A, "0x400004A-WINOUT", 0x3F3F,
 605.779 -		{
 605.780 -			"WIN0/1 BG0",
 605.781 -			"WIN0/1 BG1",
 605.782 -			"WIN0/1 BG2",
 605.783 -			"WIN0/1 BG3",
 605.784 -			"WIN0/1 OBJ",
 605.785 -			"WIN0/1 Special FX",
 605.786 -			"",
 605.787 -			"",
 605.788 -			"OBJWIN BG0",
 605.789 -			"OBJWIN BG1",
 605.790 -			"OBJWIN BG2",
 605.791 -			"OBJWIN BG3",
 605.792 -			"OBJWIN OBJ",
 605.793 -			"OBJWIN Special FX",
 605.794 -			"",
 605.795 -			"",
 605.796 -		}
 605.797 -	},
 605.798 -	{
 605.799 -		&MOSAIC, 0x4C, "0x400004C-MOSAIC", 0xFFFF,
 605.800 -		{
 605.801 -			"",
 605.802 -			"",
 605.803 -			"",
 605.804 -			"BG H Size (4 bits,W)",
 605.805 -			"",
 605.806 -			"",
 605.807 -			"",
 605.808 -			"BG V Size (4 bits,W)",
 605.809 -			"",
 605.810 -			"",
 605.811 -			"",
 605.812 -			"OBJ H Size (4 bits,W)",
 605.813 -			"",
 605.814 -			"",
 605.815 -			"",
 605.816 -			"OBJ V Size (4 bits,W)",
 605.817 -		}
 605.818 -	},
 605.819 -	{
 605.820 -		&BLDMOD, 0x50, "0x4000050-BLDMOD", 0x3FFF,
 605.821 -		{
 605.822 -			"1st BG0",
 605.823 -			"1st BG1",
 605.824 -			"1st BG2",
 605.825 -			"1st BG3",
 605.826 -			"1st OBJ",
 605.827 -			"1st BD",
 605.828 -			"",
 605.829 -			"FX Type (2 bits)",
 605.830 -			"2nd BG0",
 605.831 -			"2nd BG1",
 605.832 -			"2nd BG2",
 605.833 -			"2nd BG3",
 605.834 -			"2nd OBJ",
 605.835 -			"2nd BD",
 605.836 -			"",
 605.837 -			"",
 605.838 -		}
 605.839 -	},
 605.840 -	{
 605.841 -		&COLEV, 0x52, "0x4000052-COLEV", 0x1F1F,
 605.842 -		{
 605.843 -			"",
 605.844 -			"",
 605.845 -			"",
 605.846 -			"",
 605.847 -			"Coefficient EVA (5 bits,W)",
 605.848 -			"",
 605.849 -			"",
 605.850 -			"",
 605.851 -			"",
 605.852 -			"",
 605.853 -			"",
 605.854 -			"",
 605.855 -			"Coefficient EVB (5 bits,W)",
 605.856 -			"",
 605.857 -			"",
 605.858 -			"",
 605.859 -		}
 605.860 -	},
 605.861 -	{
 605.862 -		&COLY, 0x54, "0x4000054-COLEY", 0x001F,
 605.863 -		{
 605.864 -			"",
 605.865 -			"",
 605.866 -			"",
 605.867 -			"",
 605.868 -			"Coefficient EVY (5 bits,W)",
 605.869 -			"",
 605.870 -			"",
 605.871 -			"",
 605.872 -			"",
 605.873 -			"",
 605.874 -			"",
 605.875 -			"",
 605.876 -			"",
 605.877 -			"",
 605.878 -			"",
 605.879 -			"",
 605.880 -		}
 605.881 -	},
 605.882 -	{
 605.883 -		NULL, 0x60, "0x4000060-SG10_L", 0x007F,
 605.884 -		{
 605.885 -			"",
 605.886 -			"",
 605.887 -			"Sweep Shifts (3 bits)",
 605.888 -			"Sweep addition/decrease",
 605.889 -			"",
 605.890 -			"",
 605.891 -			"Sweep Time (3 bits)",
 605.892 -			"",
 605.893 -			"",
 605.894 -			"",
 605.895 -			"",
 605.896 -			"",
 605.897 -			"",
 605.898 -			"",
 605.899 -			"",
 605.900 -			"",
 605.901 -		}
 605.902 -	},
 605.903 -	{
 605.904 -		NULL, 0x62, "0x4000062-SG10_H", 0xFFFF,
 605.905 -		{
 605.906 -			"",
 605.907 -			"",
 605.908 -			"",
 605.909 -			"",
 605.910 -			"",
 605.911 -			"Sound Length (6 bits,W)",
 605.912 -			"",
 605.913 -			"Waveform Type (2 bits)",
 605.914 -			"",
 605.915 -			"",
 605.916 -			"Envelope Steps (3 bits)",
 605.917 -			"Envelope Attenuate/Amplify",
 605.918 -			"",
 605.919 -			"",
 605.920 -			"",
 605.921 -			"Envelope Initial Value",
 605.922 -		}
 605.923 -	},
 605.924 -	{
 605.925 -		NULL, 0x64, "0x4000064-SG11", 0xC7FF,
 605.926 -		{
 605.927 -			"",
 605.928 -			"",
 605.929 -			"",
 605.930 -			"",
 605.931 -			"",
 605.932 -			"",
 605.933 -			"",
 605.934 -			"",
 605.935 -			"",
 605.936 -			"",
 605.937 -			"Frequency (11 bits,W)",
 605.938 -			"",
 605.939 -			"",
 605.940 -			"",
 605.941 -			"Sound Continuous/Counter",
 605.942 -			"Initialization (W)",
 605.943 -		}
 605.944 -	},
 605.945 -	{
 605.946 -		NULL, 0x68, "0x4000068-SG20", 0xFFFF,
 605.947 -		{
 605.948 -			"",
 605.949 -			"",
 605.950 -			"",
 605.951 -			"",
 605.952 -			"",
 605.953 -			"Sound Length (6 bits,W)",
 605.954 -			"",
 605.955 -			"Waveform Type (2 bits)",
 605.956 -			"",
 605.957 -			"",
 605.958 -			"Envelope Steps (3 bits)",
 605.959 -			"Envelope Attenuate/Amplify",
 605.960 -			"",
 605.961 -			"",
 605.962 -			"",
 605.963 -			"Envelope Initial Value",
 605.964 -		}
 605.965 -	},
 605.966 -	{
 605.967 -		NULL, 0x6C, "0x400006C-SG21", 0xC7FF,
 605.968 -		{
 605.969 -			"",
 605.970 -			"",
 605.971 -			"",
 605.972 -			"",
 605.973 -			"",
 605.974 -			"",
 605.975 -			"",
 605.976 -			"",
 605.977 -			"",
 605.978 -			"",
 605.979 -			"Frequency (11 bits,W)",
 605.980 -			"",
 605.981 -			"",
 605.982 -			"",
 605.983 -			"Sound Continuous/Counter",
 605.984 -			"Initialization (W)",
 605.985 -		}
 605.986 -	},
 605.987 -	{
 605.988 -		NULL, 0x70, "0x4000070-SG30_L", 0x00E0,
 605.989 -		{
 605.990 -			"",
 605.991 -			"",
 605.992 -			"",
 605.993 -			"",
 605.994 -			"",
 605.995 -			"Waveform 32/64 Steps",
 605.996 -			"Waveform Bank 0/1",
 605.997 -			"Sound Output",
 605.998 -			"",
 605.999 -			"",
605.1000 -			"",
605.1001 -			"",
605.1002 -			"",
605.1003 -			"",
605.1004 -			"",
605.1005 -			"",
605.1006 -		}
605.1007 -	},
605.1008 -	{
605.1009 -		NULL, 0x72, "0x4000072-SG30_H", 0xE0FF,
605.1010 -		{
605.1011 -			"",
605.1012 -			"",
605.1013 -			"",
605.1014 -			"",
605.1015 -			"",
605.1016 -			"",
605.1017 -			"",
605.1018 -			"Sound Length (8 bits,W)",
605.1019 -			"",
605.1020 -			"",
605.1021 -			"",
605.1022 -			"",
605.1023 -			"",
605.1024 -			"",
605.1025 -			"Output Level (2 bits)",
605.1026 -			"Forced 3/4 Output Level",
605.1027 -		}
605.1028 -	},
605.1029 -	{
605.1030 -		NULL, 0x74, "0x4000074-SG31", 0xC7FF,
605.1031 -		{
605.1032 -			"",
605.1033 -			"",
605.1034 -			"",
605.1035 -			"",
605.1036 -			"",
605.1037 -			"",
605.1038 -			"",
605.1039 -			"",
605.1040 -			"",
605.1041 -			"",
605.1042 -			"Frequency (11 bits,W)",
605.1043 -			"",
605.1044 -			"",
605.1045 -			"",
605.1046 -			"Sound Continuous/Counter",
605.1047 -			"Initialization (W)",
605.1048 -		}
605.1049 -	},
605.1050 -	{
605.1051 -		NULL, 0x78, "0x4000078-SG40", 0xFF3F,
605.1052 -		{
605.1053 -			"",
605.1054 -			"",
605.1055 -			"",
605.1056 -			"",
605.1057 -			"",
605.1058 -			"Sound Length (6 bits,W)",
605.1059 -			"",
605.1060 -			"",
605.1061 -			"",
605.1062 -			"",
605.1063 -			"Envelope Steps (3 bits)",
605.1064 -			"Envelope Attenuate/Amplify",
605.1065 -			"",
605.1066 -			"",
605.1067 -			"",
605.1068 -			"Envelope Initial Value",
605.1069 -		}
605.1070 -	},
605.1071 -	{
605.1072 -		NULL, 0x7C, "0x400007C-SG41", 0xC0FF,
605.1073 -		{
605.1074 -			"",
605.1075 -			"",
605.1076 -			"Dividing Ratio Freq. (3 bits)",
605.1077 -			"Counter 15/7 Steps",
605.1078 -			"",
605.1079 -			"",
605.1080 -			"",
605.1081 -			"Counter Shift Clock (4 bits)",
605.1082 -			"",
605.1083 -			"",
605.1084 -			"",
605.1085 -			"",
605.1086 -			"",
605.1087 -			"",
605.1088 -			"Sound Continuous/Counter",
605.1089 -			"Initialization (W)",
605.1090 -		}
605.1091 -	},
605.1092 -	{
605.1093 -		NULL, 0x80, "0x4000080-SGCNT0_L", 0xFF77,
605.1094 -		{
605.1095 -			"",
605.1096 -			"",
605.1097 -			"Right Volume (3 bits)",
605.1098 -			"",
605.1099 -			"",
605.1100 -			"",
605.1101 -			"Left Volume (3 bits)",
605.1102 -			"",
605.1103 -			"Channel 1->Right",
605.1104 -			"Channel 2->Right",
605.1105 -			"Channel 3->Right",
605.1106 -			"Channel 4->Right",
605.1107 -			"Channel 1->Left",
605.1108 -			"Channel 2->Left",
605.1109 -			"Channel 3->Left",
605.1110 -			"Channel 4->Left",
605.1111 -		}
605.1112 -	},
605.1113 -	{
605.1114 -		NULL, 0x82, "0x4000082-SGCNT0_H", 0xFF1F,
605.1115 -		{
605.1116 -			"",
605.1117 -			"Sound 1-4 Volume (2 bits)",
605.1118 -			"DMA Sound A Volume",
605.1119 -			"DMA Sound B Volume",
605.1120 -			"",
605.1121 -			"",
605.1122 -			"",
605.1123 -			"",
605.1124 -			"DMA Sound A->Right",
605.1125 -			"DMA Sound A->Left",
605.1126 -			"DMA Sound A Timer",
605.1127 -			"DMA Sound A Reset FIFO",
605.1128 -			"DMA Sound B->Right",
605.1129 -			"DMA Sound B->Left",
605.1130 -			"DMA Sound B Timer",
605.1131 -			"DMA Sound B Reset FIFO",
605.1132 -		}
605.1133 -	},
605.1134 -	{
605.1135 -		NULL, 0x84, "0x4000084-SGCNT1", 0x0080,
605.1136 -		{
605.1137 -			"Sound 1 On",
605.1138 -			"Sound 2 On",
605.1139 -			"Sound 3 On",
605.1140 -			"Sound 4 On",
605.1141 -			"",
605.1142 -			"",
605.1143 -			"",
605.1144 -			"Master Sound Enable",
605.1145 -			"",
605.1146 -			"",
605.1147 -			"",
605.1148 -			"",
605.1149 -			"",
605.1150 -			"",
605.1151 -			"",
605.1152 -			"",
605.1153 -		}
605.1154 -	},
605.1155 -	{
605.1156 -		NULL, 0x88, "0x4000088-SGBIAS", 0xC3FF,
605.1157 -		{
605.1158 -			"",
605.1159 -			"",
605.1160 -			"",
605.1161 -			"",
605.1162 -			"",
605.1163 -			"",
605.1164 -			"",
605.1165 -			"",
605.1166 -			"",
605.1167 -			"Bias Level (10 bits)",
605.1168 -			"",
605.1169 -			"",
605.1170 -			"",
605.1171 -			"",
605.1172 -			"",
605.1173 -			"Sampling Rate (2 bits)",
605.1174 -		}
605.1175 -	},
605.1176 -	{
605.1177 -		NULL, 0xA0, "0x40000A0-SIGFIFOA_L", 0xFFFF,
605.1178 -		{
605.1179 -			"",
605.1180 -			"",
605.1181 -			"",
605.1182 -			"",
605.1183 -			"",
605.1184 -			"",
605.1185 -			"",
605.1186 -			"Data 0 (8 bits)",
605.1187 -			"",
605.1188 -			"",
605.1189 -			"",
605.1190 -			"",
605.1191 -			"",
605.1192 -			"",
605.1193 -			"",
605.1194 -			"Data 1 (8 bits)",
605.1195 -		}
605.1196 -	},
605.1197 -	{
605.1198 -		NULL, 0xA2, "0x40000A2-SIGFIFOA_H", 0xFFFF,
605.1199 -		{
605.1200 -			"",
605.1201 -			"",
605.1202 -			"",
605.1203 -			"",
605.1204 -			"",
605.1205 -			"",
605.1206 -			"",
605.1207 -			"Data 2 (8 bits)",
605.1208 -			"",
605.1209 -			"",
605.1210 -			"",
605.1211 -			"",
605.1212 -			"",
605.1213 -			"",
605.1214 -			"",
605.1215 -			"Data 3 (8 bits)",
605.1216 -		}
605.1217 -	},
605.1218 -	{
605.1219 -		NULL, 0xA4, "0x40000A4-SIGFIFOB_L", 0xFFFF,
605.1220 -		{
605.1221 -			"",
605.1222 -			"",
605.1223 -			"",
605.1224 -			"",
605.1225 -			"",
605.1226 -			"",
605.1227 -			"",
605.1228 -			"Data 0 (8 bits)",
605.1229 -			"",
605.1230 -			"",
605.1231 -			"",
605.1232 -			"",
605.1233 -			"",
605.1234 -			"",
605.1235 -			"",
605.1236 -			"Data 1 (8 bits)",
605.1237 -		}
605.1238 -	},
605.1239 -	{
605.1240 -		NULL, 0xA6, "0x40000A6-SIGFIFOB_H", 0xFFFF,
605.1241 -		{
605.1242 -			"",
605.1243 -			"",
605.1244 -			"",
605.1245 -			"",
605.1246 -			"",
605.1247 -			"",
605.1248 -			"",
605.1249 -			"Data 2 (8 bits)",
605.1250 -			"",
605.1251 -			"",
605.1252 -			"",
605.1253 -			"",
605.1254 -			"",
605.1255 -			"",
605.1256 -			"",
605.1257 -			"Data 3 (8 bits)",
605.1258 -		}
605.1259 -	},
605.1260 -	{
605.1261 -		&DM0SAD_L, 0xB0, "0x40000B0-DM0SAD_L", 0xFFFF,
605.1262 -		{
605.1263 -			"",
605.1264 -			"",
605.1265 -			"",
605.1266 -			"",
605.1267 -			"",
605.1268 -			"",
605.1269 -			"",
605.1270 -			"",
605.1271 -			"",
605.1272 -			"",
605.1273 -			"",
605.1274 -			"",
605.1275 -			"",
605.1276 -			"",
605.1277 -			"",
605.1278 -			"Source Address (lower 16 bits)",
605.1279 -		}
605.1280 -	},
605.1281 -	{
605.1282 -		&DM0SAD_H, 0xB2, "0x40000B2-DM0SAD_H", 0x07FF,
605.1283 -		{
605.1284 -			"",
605.1285 -			"",
605.1286 -			"",
605.1287 -			"",
605.1288 -			"",
605.1289 -			"",
605.1290 -			"",
605.1291 -			"",
605.1292 -			"",
605.1293 -			"",
605.1294 -			"Source Address (upper 11 bits)",
605.1295 -			"",
605.1296 -			"",
605.1297 -			"",
605.1298 -			"",
605.1299 -			"",
605.1300 -		}
605.1301 -	},
605.1302 -	{
605.1303 -		&DM0DAD_L, 0xB4, "0x40000B4-DM0DAD_L", 0xFFFF,
605.1304 -		{
605.1305 -			"",
605.1306 -			"",
605.1307 -			"",
605.1308 -			"",
605.1309 -			"",
605.1310 -			"",
605.1311 -			"",
605.1312 -			"",
605.1313 -			"",
605.1314 -			"",
605.1315 -			"",
605.1316 -			"",
605.1317 -			"",
605.1318 -			"",
605.1319 -			"",
605.1320 -			"Destination Address (lower 16 bits)",
605.1321 -		}
605.1322 -	},
605.1323 -	{
605.1324 -		&DM0DAD_H, 0xB6, "0x40000B6-DM0DAD_H", 0x07FF,
605.1325 -		{
605.1326 -			"",
605.1327 -			"",
605.1328 -			"",
605.1329 -			"",
605.1330 -			"",
605.1331 -			"",
605.1332 -			"",
605.1333 -			"",
605.1334 -			"",
605.1335 -			"",
605.1336 -			"Destination Address (upper 11 bits)",
605.1337 -			"",
605.1338 -			"",
605.1339 -			"",
605.1340 -			"",
605.1341 -			"",
605.1342 -		}
605.1343 -	},
605.1344 -	{
605.1345 -		&DM0CNT_L, 0xB8, "0x40000B8-DM0CNT_L", 0x3FFF,
605.1346 -		{
605.1347 -			"",
605.1348 -			"",
605.1349 -			"",
605.1350 -			"",
605.1351 -			"",
605.1352 -			"",
605.1353 -			"",
605.1354 -			"",
605.1355 -			"",
605.1356 -			"",
605.1357 -			"",
605.1358 -			"",
605.1359 -			"",
605.1360 -			"Count (14 bits)",
605.1361 -			"",
605.1362 -			"",
605.1363 -		}
605.1364 -	},
605.1365 -	{
605.1366 -		&DM0CNT_H, 0xBA, "0x40000BA-DM0CNT_H", 0xF7E0,
605.1367 -		{
605.1368 -			"",
605.1369 -			"",
605.1370 -			"",
605.1371 -			"",
605.1372 -			"",
605.1373 -			"",
605.1374 -			"Destination Address Control (2 bits)",
605.1375 -			"",
605.1376 -			"Source Address Control (2 bits)",
605.1377 -			"Repeat",
605.1378 -			"Transfer Type",
605.1379 -			"",
605.1380 -			"",
605.1381 -			"Start Timing (2 bits)",
605.1382 -			"Interrupt Request",
605.1383 -			"Enable",
605.1384 -		}
605.1385 -	},
605.1386 -	{
605.1387 -		&DM1SAD_L, 0xBC, "0x40000BC-DM1SAD_L", 0xFFFF,
605.1388 -		{
605.1389 -			"",
605.1390 -			"",
605.1391 -			"",
605.1392 -			"",
605.1393 -			"",
605.1394 -			"",
605.1395 -			"",
605.1396 -			"",
605.1397 -			"",
605.1398 -			"",
605.1399 -			"",
605.1400 -			"",
605.1401 -			"",
605.1402 -			"",
605.1403 -			"",
605.1404 -			"Source Address (lower 16 bits)",
605.1405 -		}
605.1406 -	},
605.1407 -	{
605.1408 -		&DM1SAD_H, 0xBE, "0x40000BE-DM1SAD_H", 0x0FFF,
605.1409 -		{
605.1410 -			"",
605.1411 -			"",
605.1412 -			"",
605.1413 -			"",
605.1414 -			"",
605.1415 -			"",
605.1416 -			"",
605.1417 -			"",
605.1418 -			"",
605.1419 -			"",
605.1420 -			"",
605.1421 -			"Source Address (upper 12 bits)",
605.1422 -			"",
605.1423 -			"",
605.1424 -			"",
605.1425 -			"",
605.1426 -		}
605.1427 -	},
605.1428 -	{
605.1429 -		&DM1DAD_L, 0xC0, "0x40000C0-DM1DAD_L", 0xFFFF,
605.1430 -		{
605.1431 -			"",
605.1432 -			"",
605.1433 -			"",
605.1434 -			"",
605.1435 -			"",
605.1436 -			"",
605.1437 -			"",
605.1438 -			"",
605.1439 -			"",
605.1440 -			"",
605.1441 -			"",
605.1442 -			"",
605.1443 -			"",
605.1444 -			"",
605.1445 -			"",
605.1446 -			"Destination Address (lower 16 bits)",
605.1447 -		}
605.1448 -	},
605.1449 -	{
605.1450 -		&DM1DAD_H, 0xC2, "0x40000C2-DM1DAD_H", 0x07FF,
605.1451 -		{
605.1452 -			"",
605.1453 -			"",
605.1454 -			"",
605.1455 -			"",
605.1456 -			"",
605.1457 -			"",
605.1458 -			"",
605.1459 -			"",
605.1460 -			"",
605.1461 -			"",
605.1462 -			"Destination Address (upper 11 bits)",
605.1463 -			"",
605.1464 -			"",
605.1465 -			"",
605.1466 -			"",
605.1467 -			"",
605.1468 -		}
605.1469 -	},
605.1470 -	{
605.1471 -		&DM1CNT_L, 0xC4, "0x40000C4-DM1CNT_L", 0x3FFF,
605.1472 -		{
605.1473 -			"",
605.1474 -			"",
605.1475 -			"",
605.1476 -			"",
605.1477 -			"",
605.1478 -			"",
605.1479 -			"",
605.1480 -			"",
605.1481 -			"",
605.1482 -			"",
605.1483 -			"",
605.1484 -			"",
605.1485 -			"",
605.1486 -			"Count (14 bits)",
605.1487 -			"",
605.1488 -			"",
605.1489 -		}
605.1490 -	},
605.1491 -	{
605.1492 -		&DM1CNT_H, 0xC6, "0x40000C6-DM1CNT_H", 0xF7E0,
605.1493 -		{
605.1494 -			"",
605.1495 -			"",
605.1496 -			"",
605.1497 -			"",
605.1498 -			"",
605.1499 -			"",
605.1500 -			"Destination Address Control (2 bits)",
605.1501 -			"",
605.1502 -			"Source Address Control (2 bits)",
605.1503 -			"Repeat",
605.1504 -			"Transfer Type",
605.1505 -			"",
605.1506 -			"",
605.1507 -			"Start Timing (2 bits)",
605.1508 -			"Interrupt Request",
605.1509 -			"Enable",
605.1510 -		}
605.1511 -	},
605.1512 -	{
605.1513 -		&DM2SAD_L, 0xC8, "0x40000C8-DM2SAD_L", 0xFFFF,
605.1514 -		{
605.1515 -			"",
605.1516 -			"",
605.1517 -			"",
605.1518 -			"",
605.1519 -			"",
605.1520 -			"",
605.1521 -			"",
605.1522 -			"",
605.1523 -			"",
605.1524 -			"",
605.1525 -			"",
605.1526 -			"",
605.1527 -			"",
605.1528 -			"",
605.1529 -			"",
605.1530 -			"Source Address (lower 16 bits)",
605.1531 -		}
605.1532 -	},
605.1533 -	{
605.1534 -		&DM2SAD_H, 0xCA, "0x40000CA-DM2SAD_H", 0x0FFF,
605.1535 -		{
605.1536 -			"",
605.1537 -			"",
605.1538 -			"",
605.1539 -			"",
605.1540 -			"",
605.1541 -			"",
605.1542 -			"",
605.1543 -			"",
605.1544 -			"",
605.1545 -			"",
605.1546 -			"",
605.1547 -			"Source Address (upper 12 bits)",
605.1548 -			"",
605.1549 -			"",
605.1550 -			"",
605.1551 -			"",
605.1552 -		}
605.1553 -	},
605.1554 -	{
605.1555 -		&DM2DAD_L, 0xCC, "0x40000CC-DM2DAD_L", 0xFFFF,
605.1556 -		{
605.1557 -			"",
605.1558 -			"",
605.1559 -			"",
605.1560 -			"",
605.1561 -			"",
605.1562 -			"",
605.1563 -			"",
605.1564 -			"",
605.1565 -			"",
605.1566 -			"",
605.1567 -			"",
605.1568 -			"",
605.1569 -			"",
605.1570 -			"",
605.1571 -			"",
605.1572 -			"Destination Address (lower 16 bits)",
605.1573 -		}
605.1574 -	},
605.1575 -	{
605.1576 -		&DM2DAD_H, 0xCE, "0x40000CE-DM2DAD_H", 0x07FF,
605.1577 -		{
605.1578 -			"",
605.1579 -			"",
605.1580 -			"",
605.1581 -			"",
605.1582 -			"",
605.1583 -			"",
605.1584 -			"",
605.1585 -			"",
605.1586 -			"",
605.1587 -			"",
605.1588 -			"Destination Address (upper 11 bits)",
605.1589 -			"",
605.1590 -			"",
605.1591 -			"",
605.1592 -			"",
605.1593 -			"",
605.1594 -		}
605.1595 -	},
605.1596 -	{
605.1597 -		&DM2CNT_L, 0xD0, "0x40000D0-DM2CNT_L", 0x3FFF,
605.1598 -		{
605.1599 -			"",
605.1600 -			"",
605.1601 -			"",
605.1602 -			"",
605.1603 -			"",
605.1604 -			"",
605.1605 -			"",
605.1606 -			"",
605.1607 -			"",
605.1608 -			"",
605.1609 -			"",
605.1610 -			"",
605.1611 -			"",
605.1612 -			"Count (14 bits)",
605.1613 -			"",
605.1614 -			"",
605.1615 -		}
605.1616 -	},
605.1617 -	{
605.1618 -		&DM2CNT_H, 0xD2, "0x40000D2-DM2CNT_H", 0xF7E0,
605.1619 -		{
605.1620 -			"",
605.1621 -			"",
605.1622 -			"",
605.1623 -			"",
605.1624 -			"",
605.1625 -			"",
605.1626 -			"Destination Address Control (2 bits)",
605.1627 -			"",
605.1628 -			"Source Address Control (2 bits)",
605.1629 -			"Repeat",
605.1630 -			"Transfer Type",
605.1631 -			"",
605.1632 -			"",
605.1633 -			"Start Timing (2 bits)",
605.1634 -			"Interrupt Request",
605.1635 -			"Enable",
605.1636 -		}
605.1637 -	},
605.1638 -	{
605.1639 -		&DM3SAD_L, 0xD4, "0x40000D4-DM3SAD_L", 0xFFFF,
605.1640 -		{
605.1641 -			"",
605.1642 -			"",
605.1643 -			"",
605.1644 -			"",
605.1645 -			"",
605.1646 -			"",
605.1647 -			"",
605.1648 -			"",
605.1649 -			"",
605.1650 -			"",
605.1651 -			"",
605.1652 -			"",
605.1653 -			"",
605.1654 -			"",
605.1655 -			"",
605.1656 -			"Source Address (lower 16 bits)",
605.1657 -		}
605.1658 -	},
605.1659 -	{
605.1660 -		&DM3SAD_H, 0xD6, "0x40000D6-DM3SAD_H", 0x0FFF,
605.1661 -		{
605.1662 -			"",
605.1663 -			"",
605.1664 -			"",
605.1665 -			"",
605.1666 -			"",
605.1667 -			"",
605.1668 -			"",
605.1669 -			"",
605.1670 -			"",
605.1671 -			"",
605.1672 -			"",
605.1673 -			"Source Address (upper 12 bits)",
605.1674 -			"",
605.1675 -			"",
605.1676 -			"",
605.1677 -			"",
605.1678 -		}
605.1679 -	},
605.1680 -	{
605.1681 -		&DM3DAD_L, 0xD8, "0x40000D8-DM3DAD_L", 0xFFFF,
605.1682 -		{
605.1683 -			"",
605.1684 -			"",
605.1685 -			"",
605.1686 -			"",
605.1687 -			"",
605.1688 -			"",
605.1689 -			"",
605.1690 -			"",
605.1691 -			"",
605.1692 -			"",
605.1693 -			"",
605.1694 -			"",
605.1695 -			"",
605.1696 -			"",
605.1697 -			"",
605.1698 -			"Destination Address (lower 16 bits)",
605.1699 -		}
605.1700 -	},
605.1701 -	{
605.1702 -		&DM3DAD_H, 0xDA, "0x40000DA-DM3DAD_H", 0x0FFF,
605.1703 -		{
605.1704 -			"",
605.1705 -			"",
605.1706 -			"",
605.1707 -			"",
605.1708 -			"",
605.1709 -			"",
605.1710 -			"",
605.1711 -			"",
605.1712 -			"",
605.1713 -			"",
605.1714 -			"",
605.1715 -			"Destination Address (upper 12 bits)",
605.1716 -			"",
605.1717 -			"",
605.1718 -			"",
605.1719 -			"",
605.1720 -		}
605.1721 -	},
605.1722 -	{
605.1723 -		&DM3CNT_L, 0xDC, "0x40000DC-DM3CNT_L", 0xFFFF,
605.1724 -		{
605.1725 -			"",
605.1726 -			"",
605.1727 -			"",
605.1728 -			"",
605.1729 -			"",
605.1730 -			"",
605.1731 -			"",
605.1732 -			"",
605.1733 -			"",
605.1734 -			"",
605.1735 -			"",
605.1736 -			"",
605.1737 -			"",
605.1738 -			"",
605.1739 -			"",
605.1740 -			"Count (16 bits)",
605.1741 -		}
605.1742 -	},
605.1743 -	{
605.1744 -		&DM3CNT_H, 0xDE, "0x40000DE-DM3CNT_H", 0xFFE0,
605.1745 -		{
605.1746 -			"",
605.1747 -			"",
605.1748 -			"",
605.1749 -			"",
605.1750 -			"",
605.1751 -			"",
605.1752 -			"Destination Address Control (2 bits)",
605.1753 -			"",
605.1754 -			"Source Address Control (2 bits)",
605.1755 -			"Repeat",
605.1756 -			"Transfer Type",
605.1757 -			"Game Pak Data Request",
605.1758 -			"",
605.1759 -			"Start Timing (2 bits)",
605.1760 -			"Interrupt Request",
605.1761 -			"Enable",
605.1762 -		}
605.1763 -	},
605.1764 -	{
605.1765 -		&TM0D, 0x100, "0x4000100-TM0D", 0xFFFF,
605.1766 -		{
605.1767 -			"",
605.1768 -			"",
605.1769 -			"",
605.1770 -			"",
605.1771 -			"",
605.1772 -			"",
605.1773 -			"",
605.1774 -			"",
605.1775 -			"",
605.1776 -			"",
605.1777 -			"",
605.1778 -			"",
605.1779 -			"",
605.1780 -			"",
605.1781 -			"",
605.1782 -			"Timer Counter (16 bits)",
605.1783 -		}
605.1784 -	},
605.1785 -	{
605.1786 -		&TM0CNT, 0x102, "0x4000102-TM0CNT", 0x00C7,
605.1787 -		{
605.1788 -			"",
605.1789 -			"Scalar Selection (2 bits)",
605.1790 -			"Count Up",
605.1791 -			"",
605.1792 -			"",
605.1793 -			"",
605.1794 -			"Interrupt Request",
605.1795 -			"Enable",
605.1796 -			"",
605.1797 -			"",
605.1798 -			"",
605.1799 -			"",
605.1800 -			"",
605.1801 -			"",
605.1802 -			"",
605.1803 -			"",
605.1804 -		}
605.1805 -	},
605.1806 -	{
605.1807 -		&TM1D, 0x104, "0x4000104-TM1D", 0xFFFF,
605.1808 -		{
605.1809 -			"",
605.1810 -			"",
605.1811 -			"",
605.1812 -			"",
605.1813 -			"",
605.1814 -			"",
605.1815 -			"",
605.1816 -			"",
605.1817 -			"",
605.1818 -			"",
605.1819 -			"",
605.1820 -			"",
605.1821 -			"",
605.1822 -			"",
605.1823 -			"",
605.1824 -			"Timer Counter (16 bits)",
605.1825 -		}
605.1826 -	},
605.1827 -	{
605.1828 -		&TM1CNT, 0x106, "0x4000106-TM1CNT", 0x00C7,
605.1829 -		{
605.1830 -			"",
605.1831 -			"Scalar Selection (2 bits)",
605.1832 -			"Count Up",
605.1833 -			"",
605.1834 -			"",
605.1835 -			"",
605.1836 -			"Interrupt Request",
605.1837 -			"Enable",
605.1838 -			"",
605.1839 -			"",
605.1840 -			"",
605.1841 -			"",
605.1842 -			"",
605.1843 -			"",
605.1844 -			"",
605.1845 -			"",
605.1846 -		}
605.1847 -	},
605.1848 -	{
605.1849 -		&TM2D, 0x108, "0x4000108-TM2D", 0xFFFF,
605.1850 -		{
605.1851 -			"",
605.1852 -			"",
605.1853 -			"",
605.1854 -			"",
605.1855 -			"",
605.1856 -			"",
605.1857 -			"",
605.1858 -			"",
605.1859 -			"",
605.1860 -			"",
605.1861 -			"",
605.1862 -			"",
605.1863 -			"",
605.1864 -			"",
605.1865 -			"",
605.1866 -			"Timer Counter (16 bits)",
605.1867 -		}
605.1868 -	},
605.1869 -	{
605.1870 -		&TM2CNT, 0x10A, "0x400010A-TM2CNT", 0x00C7,
605.1871 -		{
605.1872 -			"",
605.1873 -			"Scalar Selection (2 bits)",
605.1874 -			"Count Up",
605.1875 -			"",
605.1876 -			"",
605.1877 -			"",
605.1878 -			"Interrupt Request",
605.1879 -			"Enable",
605.1880 -			"",
605.1881 -			"",
605.1882 -			"",
605.1883 -			"",
605.1884 -			"",
605.1885 -			"",
605.1886 -			"",
605.1887 -			"",
605.1888 -		}
605.1889 -	},
605.1890 -	{
605.1891 -		&TM3D, 0x10C, "0x400010C-TM3D", 0xFFFF,
605.1892 -		{
605.1893 -			"",
605.1894 -			"",
605.1895 -			"",
605.1896 -			"",
605.1897 -			"",
605.1898 -			"",
605.1899 -			"",
605.1900 -			"",
605.1901 -			"",
605.1902 -			"",
605.1903 -			"",
605.1904 -			"",
605.1905 -			"",
605.1906 -			"",
605.1907 -			"",
605.1908 -			"Timer Counter (16 bits)",
605.1909 -		}
605.1910 -	},
605.1911 -	{
605.1912 -		&TM3CNT, 0x10E, "0x400010E-TM3CNT", 0x00C7,
605.1913 -		{
605.1914 -			"",
605.1915 -			"Scalar Selection (2 bits)",
605.1916 -			"Count Up",
605.1917 -			"",
605.1918 -			"",
605.1919 -			"",
605.1920 -			"Interrupt Request",
605.1921 -			"Enable",
605.1922 -			"",
605.1923 -			"",
605.1924 -			"",
605.1925 -			"",
605.1926 -			"",
605.1927 -			"",
605.1928 -			"",
605.1929 -			"",
605.1930 -		}
605.1931 -	},
605.1932 -	{
605.1933 -		&P1, 0x130, "0x4000130-P1", 0x03FF,
605.1934 -		{
605.1935 -			"A",
605.1936 -			"B",
605.1937 -			"Select",
605.1938 -			"Start",
605.1939 -			"Right",
605.1940 -			"Left",
605.1941 -			"Up",
605.1942 -			"Down",
605.1943 -			"Shoulder Right",
605.1944 -			"Shoulder Left",
605.1945 -			"",
605.1946 -			"",
605.1947 -			"",
605.1948 -			"",
605.1949 -			"",
605.1950 -			"",
605.1951 -		}
605.1952 -	},
605.1953 -	{
605.1954 -		NULL, 0x132, "0x4000132-P1CNT", 0xC3FF,
605.1955 -		{
605.1956 -			"A",
605.1957 -			"B",
605.1958 -			"Select",
605.1959 -			"Start",
605.1960 -			"Right",
605.1961 -			"Left",
605.1962 -			"Up",
605.1963 -			"Down",
605.1964 -			"Shoulder Right",
605.1965 -			"Shoulder Left",
605.1966 -			"",
605.1967 -			"",
605.1968 -			"",
605.1969 -			"",
605.1970 -			"Interrupt Request",
605.1971 -			"Interrupt Condition",
605.1972 -		}
605.1973 -	},
605.1974 -	{
605.1975 -		&IE, 0x200, "0x4000200-IE", 0x3FFF,
605.1976 -		{
605.1977 -			"VBlank",
605.1978 -			"HBlank",
605.1979 -			"VCount",
605.1980 -			"Timer 0",
605.1981 -			"Timer 1",
605.1982 -			"Timer 2",
605.1983 -			"Timer 3",
605.1984 -			"Serial",
605.1985 -			"DMA 0",
605.1986 -			"DMA 1",
605.1987 -			"DMA 2",
605.1988 -			"DMA 3",
605.1989 -			"Keypad",
605.1990 -			"Game Pak",
605.1991 -			"",
605.1992 -			"",
605.1993 -		}
605.1994 -	},
605.1995 -	{
605.1996 -		&IF, 0x202, "0x4000202-IF", 0x0000,
605.1997 -		{
605.1998 -			"VBlank",
605.1999 -			"HBlank",
605.2000 -			"VCount",
605.2001 -			"Timer 0",
605.2002 -			"Timer 1",
605.2003 -			"Timer 2",
605.2004 -			"Timer 3",
605.2005 -			"Serial",
605.2006 -			"DMA 0",
605.2007 -			"DMA 1",
605.2008 -			"DMA 2",
605.2009 -			"DMA 3",
605.2010 -			"Keypad",
605.2011 -			"Game Pak",
605.2012 -			"",
605.2013 -			"",
605.2014 -		}
605.2015 -	},
605.2016 -	{
605.2017 -		NULL, 0x204, "0x4000204-WAITCNT", 0x5FFF,
605.2018 -		{
605.2019 -			"",
605.2020 -			"SRAM Wait Control (2 bits)",
605.2021 -			"",
605.2022 -			"Wait State 0 First Access (2 bits)",
605.2023 -			"Wait State 0 Second Access",
605.2024 -			"",
605.2025 -			"Wait State 1 First Access (2 bits)",
605.2026 -			"Wait State 1 Second Access",
605.2027 -			"",
605.2028 -			"Wait State 2 First Access (2 bits)",
605.2029 -			"Wait State 2 Second Access",
605.2030 -			"",
605.2031 -			"PHI Terminal Output (2 bits)",
605.2032 -			"",
605.2033 -			"Game Pak Prefetch Buffer",
605.2034 -			"Game Pak Type Flag",
605.2035 -		}
605.2036 -	},
605.2037 -	{
605.2038 -		&IME, 0x208, "0x4000208-IME", 0x0001,
605.2039 -		{
605.2040 -			"Master Interrupt Enable",
605.2041 -			"",
605.2042 -			"",
605.2043 -			"",
605.2044 -			"",
605.2045 -			"",
605.2046 -			"",
605.2047 -			"",
605.2048 -			"",
605.2049 -			"",
605.2050 -			"",
605.2051 -			"",
605.2052 -			"",
605.2053 -			"",
605.2054 -			"",
605.2055 -			"",
605.2056 -		}
605.2057 -	},
605.2058 -	{
605.2059 -		NULL, 0x300, "0x4000300-HALTCNT", 0x8001,
605.2060 -		{
605.2061 -			"First Boot",
605.2062 -			"",
605.2063 -			"",
605.2064 -			"",
605.2065 -			"",
605.2066 -			"",
605.2067 -			"",
605.2068 -			"",
605.2069 -			"",
605.2070 -			"",
605.2071 -			"",
605.2072 -			"",
605.2073 -			"",
605.2074 -			"",
605.2075 -			"",
605.2076 -			"Power Down",
605.2077 -		}
605.2078 -	},
605.2079 -};
605.2080 -
605.2081 -#endif // VBA_IOVIEWERREGS_H
   606.1 --- a/src/win32/IUpdate.h	Sat Mar 03 10:54:39 2012 -0600
   606.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   606.3 @@ -1,14 +0,0 @@
   606.4 -#ifndef VBA_WIN32_IUPDATE_H
   606.5 -#define VBA_WIN32_IUPDATE_H
   606.6 -
   606.7 -#if _MSC_VER > 1000
   606.8 -#pragma once
   606.9 -#endif // _MSC_VER > 1000
  606.10 -
  606.11 -class IUpdateListener
  606.12 -{
  606.13 -public:
  606.14 -	virtual void update() = 0;
  606.15 -};
  606.16 -
  606.17 -#endif
   607.1 --- a/src/win32/Input.h	Sat Mar 03 10:54:39 2012 -0600
   607.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   607.3 @@ -1,30 +0,0 @@
   607.4 -#ifndef VBA_WIN32_INPUT_H
   607.5 -#define VBA_WIN32_INPUT_H
   607.6 -
   607.7 -#if _MSC_VER > 1000
   607.8 -#pragma once
   607.9 -#endif // _MSC_VER > 1000
  607.10 -
  607.11 -#include "../common/inputGlobal.h"
  607.12 -
  607.13 -#define JOYCONFIG_MESSAGE (WM_USER + 1000)
  607.14 -
  607.15 -class Input
  607.16 -{
  607.17 -public:
  607.18 -	Input() {};
  607.19 -	virtual ~Input() {};
  607.20 -
  607.21 -	virtual bool initialize() = 0;
  607.22 -
  607.23 -	virtual bool readDevices() = 0;
  607.24 -	virtual u32 readDevice(int which, bool sensor) = 0;
  607.25 -	virtual CString getKeyName(LONG_PTR key) = 0;
  607.26 -	virtual void checkKeys()    = 0;
  607.27 -	virtual void checkDevices() = 0;
  607.28 -	virtual void activate()     = 0;
  607.29 -	virtual void loadSettings() = 0;
  607.30 -	virtual void saveSettings() = 0;
  607.31 -};
  607.32 -
  607.33 -#endif
   608.1 --- a/src/win32/Joypad.cpp	Sat Mar 03 10:54:39 2012 -0600
   608.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   608.3 @@ -1,402 +0,0 @@
   608.4 -// Joypad.cpp : implementation file
   608.5 -//
   608.6 -
   608.7 -#include "stdafx.h"
   608.8 -#include "resource.h"
   608.9 -#include "Joypad.h"
  608.10 -#include "Input.h"
  608.11 -#include "VBA.h"
  608.12 -
  608.13 -extern USHORT joypad[4][13];
  608.14 -extern USHORT motion[4];
  608.15 -
  608.16 -/////////////////////////////////////////////////////////////////////////////
  608.17 -// JoypadEditControl
  608.18 -
  608.19 -JoypadEditControl::JoypadEditControl()
  608.20 -{}
  608.21 -
  608.22 -JoypadEditControl::~JoypadEditControl()
  608.23 -{}
  608.24 -
  608.25 -BEGIN_MESSAGE_MAP(JoypadEditControl, CEdit)
  608.26 -//{{AFX_MSG_MAP(JoypadEditControl)
  608.27 -ON_WM_CHAR()
  608.28 -//}}AFX_MSG_MAP
  608.29 -ON_MESSAGE(JOYCONFIG_MESSAGE, OnJoyConfig)
  608.30 -END_MESSAGE_MAP()
  608.31 -
  608.32 -/////////////////////////////////////////////////////////////////////////////
  608.33 -// JoypadEditControl message handlers
  608.34 -
  608.35 -void JoypadEditControl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  608.36 -{}
  608.37 -
  608.38 -LRESULT JoypadEditControl::OnJoyConfig(WPARAM wParam, LPARAM lParam)
  608.39 -{
  608.40 -	SetWindowLong(GetSafeHwnd(), GWL_USERDATA, ((wParam<<8)|lParam));
  608.41 -	SetWindowText(theApp.input->getKeyName((wParam<<8)|lParam));
  608.42 -	GetParent()->GetNextDlgTabItem(this, FALSE)->SetFocus();
  608.43 -	return TRUE;
  608.44 -}
  608.45 -
  608.46 -BOOL JoypadEditControl::PreTranslateMessage(MSG *pMsg)
  608.47 -{
  608.48 -	if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN))
  608.49 -		return TRUE;
  608.50 -
  608.51 -	return CEdit::PreTranslateMessage(pMsg);
  608.52 -}
  608.53 -
  608.54 -/////////////////////////////////////////////////////////////////////////////
  608.55 -// JoypadConfig dialog
  608.56 -
  608.57 -JoypadConfig::JoypadConfig(int w, CWnd*pParent /*=NULL*/)
  608.58 -	: CDialog(JoypadConfig::IDD, pParent)
  608.59 -{
  608.60 -	//{{AFX_DATA_INIT(JoypadConfig)
  608.61 -	//}}AFX_DATA_INIT
  608.62 -	timerId = 0;
  608.63 -	which   = w;
  608.64 -	if (which < 0 || which > 3)
  608.65 -		which = 0;
  608.66 -}
  608.67 -
  608.68 -void JoypadConfig::DoDataExchange(CDataExchange*pDX)
  608.69 -{
  608.70 -	CDialog::DoDataExchange(pDX);
  608.71 -	//{{AFX_DATA_MAP(JoypadConfig)
  608.72 -	DDX_Control(pDX, IDC_EDIT_UP, up);
  608.73 -	DDX_Control(pDX, IDC_EDIT_SPEED, speed);
  608.74 -	DDX_Control(pDX, IDC_EDIT_RIGHT, right);
  608.75 -	DDX_Control(pDX, IDC_EDIT_LEFT, left);
  608.76 -	DDX_Control(pDX, IDC_EDIT_DOWN, down);
  608.77 -	DDX_Control(pDX, IDC_EDIT_CAPTURE, capture);
  608.78 -	DDX_Control(pDX, IDC_EDIT_BUTTON_START, buttonStart);
  608.79 -	DDX_Control(pDX, IDC_EDIT_BUTTON_SELECT, buttonSelect);
  608.80 -	DDX_Control(pDX, IDC_EDIT_BUTTON_R, buttonR);
  608.81 -	DDX_Control(pDX, IDC_EDIT_BUTTON_L, buttonL);
  608.82 -	DDX_Control(pDX, IDC_EDIT_BUTTON_GS, buttonGS);
  608.83 -	DDX_Control(pDX, IDC_EDIT_BUTTON_B, buttonB);
  608.84 -	DDX_Control(pDX, IDC_EDIT_BUTTON_A, buttonA);
  608.85 -	//}}AFX_DATA_MAP
  608.86 -}
  608.87 -
  608.88 -BEGIN_MESSAGE_MAP(JoypadConfig, CDialog)
  608.89 -//{{AFX_MSG_MAP(JoypadConfig)
  608.90 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  608.91 -ON_BN_CLICKED(ID_OK, OnOk)
  608.92 -ON_WM_CHAR()
  608.93 -ON_WM_DESTROY()
  608.94 -ON_WM_TIMER()
  608.95 -ON_WM_KEYDOWN()
  608.96 -//}}AFX_MSG_MAP
  608.97 -END_MESSAGE_MAP()
  608.98 -
  608.99 -/////////////////////////////////////////////////////////////////////////////
 608.100 -// JoypadConfig message handlers
 608.101 -
 608.102 -void JoypadConfig::OnCancel()
 608.103 -{
 608.104 -	EndDialog(FALSE);
 608.105 -}
 608.106 -
 608.107 -void JoypadConfig::OnOk()
 608.108 -{
 608.109 -	assignKeys();
 608.110 -	theApp.input->checkKeys();
 608.111 -	EndDialog(TRUE);
 608.112 -}
 608.113 -
 608.114 -void JoypadConfig::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
 608.115 -{}
 608.116 -
 608.117 -void JoypadConfig::OnDestroy()
 608.118 -{
 608.119 -	CDialog::OnDestroy();
 608.120 -
 608.121 -	KillTimer(timerId);
 608.122 -}
 608.123 -
 608.124 -void JoypadConfig::OnTimer(UINT nIDEvent)
 608.125 -{
 608.126 -	theApp.input->checkDevices();
 608.127 -
 608.128 -	CDialog::OnTimer(nIDEvent);
 608.129 -}
 608.130 -
 608.131 -void JoypadConfig::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 608.132 -{}
 608.133 -
 608.134 -BOOL JoypadConfig::OnInitDialog()
 608.135 -{
 608.136 -	CDialog::OnInitDialog();
 608.137 -
 608.138 -	timerId = SetTimer(0, 200, NULL);
 608.139 -
 608.140 -	SetWindowLong(up, GWL_USERDATA, joypad[which][KEY_UP]);
 608.141 -	up.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_UP]));
 608.142 -
 608.143 -	SetWindowLong(down, GWL_USERDATA, joypad[which][KEY_DOWN]);
 608.144 -	down.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_DOWN]));
 608.145 -
 608.146 -	SetWindowLong(left, GWL_USERDATA, joypad[which][KEY_LEFT]);
 608.147 -	left.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_LEFT]));
 608.148 -
 608.149 -	SetWindowLong(right, GWL_USERDATA, joypad[which][KEY_RIGHT]);
 608.150 -	right.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_RIGHT]));
 608.151 -
 608.152 -	SetWindowLong(buttonA, GWL_USERDATA, joypad[which][KEY_BUTTON_A]);
 608.153 -	buttonA.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_A]));
 608.154 -
 608.155 -	SetWindowLong(buttonB, GWL_USERDATA, joypad[which][KEY_BUTTON_B]);
 608.156 -	buttonB.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_B]));
 608.157 -
 608.158 -	SetWindowLong(buttonL, GWL_USERDATA, joypad[which][KEY_BUTTON_L]);
 608.159 -	buttonL.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_L]));
 608.160 -
 608.161 -	SetWindowLong(buttonR, GWL_USERDATA, joypad[which][KEY_BUTTON_R]);
 608.162 -	buttonR.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_R]));
 608.163 -
 608.164 -	SetWindowLong(buttonSelect, GWL_USERDATA, joypad[which][KEY_BUTTON_SELECT]);
 608.165 -	buttonSelect.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SELECT]));
 608.166 -
 608.167 -	SetWindowLong(buttonStart, GWL_USERDATA, joypad[which][KEY_BUTTON_START]);
 608.168 -	buttonStart.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_START]));
 608.169 -
 608.170 -	SetWindowLong(speed, GWL_USERDATA, joypad[which][KEY_BUTTON_SPEED]);
 608.171 -	speed.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SPEED]));
 608.172 -
 608.173 -	SetWindowLong(capture, GWL_USERDATA, joypad[which][KEY_BUTTON_CAPTURE]);
 608.174 -	capture.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_CAPTURE]));
 608.175 -
 608.176 -	SetWindowLong(buttonGS, GWL_USERDATA, joypad[which][KEY_BUTTON_GS]);
 608.177 -	buttonGS.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_GS]));
 608.178 -
 608.179 -	CenterWindow();
 608.180 -
 608.181 -	return TRUE; // return TRUE unless you set the focus to a control
 608.182 -	             // EXCEPTION: OCX Property Pages should return FALSE
 608.183 -}
 608.184 -
 608.185 -void JoypadConfig::assignKey(int id, int key)
 608.186 -{
 608.187 -	switch (id)
 608.188 -	{
 608.189 -	case IDC_EDIT_LEFT:
 608.190 -		joypad[which][KEY_LEFT] = key;
 608.191 -		break;
 608.192 -	case IDC_EDIT_RIGHT:
 608.193 -		joypad[which][KEY_RIGHT] = key;
 608.194 -		break;
 608.195 -	case IDC_EDIT_UP:
 608.196 -		joypad[which][KEY_UP] = key;
 608.197 -		break;
 608.198 -	case IDC_EDIT_SPEED:
 608.199 -		joypad[which][KEY_BUTTON_SPEED] = key;
 608.200 -		break;
 608.201 -	case IDC_EDIT_CAPTURE:
 608.202 -		joypad[which][KEY_BUTTON_CAPTURE] = key;
 608.203 -		break;
 608.204 -	case IDC_EDIT_DOWN:
 608.205 -		joypad[which][KEY_DOWN] = key;
 608.206 -		break;
 608.207 -	case IDC_EDIT_BUTTON_A:
 608.208 -		joypad[which][KEY_BUTTON_A] = key;
 608.209 -		break;
 608.210 -	case IDC_EDIT_BUTTON_B:
 608.211 -		joypad[which][KEY_BUTTON_B] = key;
 608.212 -		break;
 608.213 -	case IDC_EDIT_BUTTON_L:
 608.214 -		joypad[which][KEY_BUTTON_L] = key;
 608.215 -		break;
 608.216 -	case IDC_EDIT_BUTTON_R:
 608.217 -		joypad[which][KEY_BUTTON_R] = key;
 608.218 -		break;
 608.219 -	case IDC_EDIT_BUTTON_START:
 608.220 -		joypad[which][KEY_BUTTON_START] = key;
 608.221 -		break;
 608.222 -	case IDC_EDIT_BUTTON_SELECT:
 608.223 -		joypad[which][KEY_BUTTON_SELECT] = key;
 608.224 -		break;
 608.225 -	case IDC_EDIT_BUTTON_GS:
 608.226 -		joypad[which][KEY_BUTTON_GS] = key;
 608.227 -		break;
 608.228 -	}
 608.229 -}
 608.230 -
 608.231 -void JoypadConfig::assignKeys()
 608.232 -{
 608.233 -	int id;
 608.234 -
 608.235 -	id = IDC_EDIT_UP;
 608.236 -	assignKey(id, GetWindowLong(up, GWL_USERDATA));
 608.237 -
 608.238 -	id = IDC_EDIT_DOWN;
 608.239 -	assignKey(id, GetWindowLong(down, GWL_USERDATA));
 608.240 -
 608.241 -	id = IDC_EDIT_LEFT;
 608.242 -	assignKey(id, GetWindowLong(left, GWL_USERDATA));
 608.243 -
 608.244 -	id = IDC_EDIT_RIGHT;
 608.245 -	assignKey(id, GetWindowLong(right, GWL_USERDATA));
 608.246 -
 608.247 -	id = IDC_EDIT_BUTTON_A;
 608.248 -	assignKey(id, GetWindowLong(buttonA, GWL_USERDATA));
 608.249 -
 608.250 -	id = IDC_EDIT_BUTTON_B;
 608.251 -	assignKey(id, GetWindowLong(buttonB, GWL_USERDATA));
 608.252 -
 608.253 -	id = IDC_EDIT_BUTTON_L;
 608.254 -	assignKey(id, GetWindowLong(buttonL, GWL_USERDATA));
 608.255 -
 608.256 -	id = IDC_EDIT_BUTTON_R;
 608.257 -	assignKey(id, GetWindowLong(buttonR, GWL_USERDATA));
 608.258 -
 608.259 -	id = IDC_EDIT_BUTTON_SELECT;
 608.260 -	assignKey(id, GetWindowLong(buttonSelect, GWL_USERDATA));
 608.261 -
 608.262 -	id = IDC_EDIT_BUTTON_START;
 608.263 -	assignKey(id, GetWindowLong(buttonStart, GWL_USERDATA));
 608.264 -
 608.265 -	id = IDC_EDIT_SPEED;
 608.266 -	assignKey(id, GetWindowLong(speed, GWL_USERDATA));
 608.267 -
 608.268 -	id = IDC_EDIT_CAPTURE;
 608.269 -	assignKey(id, GetWindowLong(capture, GWL_USERDATA));
 608.270 -
 608.271 -	id = IDC_EDIT_BUTTON_GS;
 608.272 -	assignKey(id, GetWindowLong(buttonGS, GWL_USERDATA));
 608.273 -
 608.274 -	//  winSaveKeys();
 608.275 -}
 608.276 -
 608.277 -/////////////////////////////////////////////////////////////////////////////
 608.278 -// MotionConfig dialog
 608.279 -
 608.280 -MotionConfig::MotionConfig(CWnd*pParent /*=NULL*/)
 608.281 -	: CDialog(MotionConfig::IDD, pParent)
 608.282 -{
 608.283 -	//{{AFX_DATA_INIT(MotionConfig)
 608.284 -	// NOTE: the ClassWizard will add member initialization here
 608.285 -	//}}AFX_DATA_INIT
 608.286 -	timerId = 0;
 608.287 -}
 608.288 -
 608.289 -void MotionConfig::DoDataExchange(CDataExchange*pDX)
 608.290 -{
 608.291 -	CDialog::DoDataExchange(pDX);
 608.292 -	//{{AFX_DATA_MAP(MotionConfig)
 608.293 -	DDX_Control(pDX, IDC_EDIT_UP, up);
 608.294 -	DDX_Control(pDX, IDC_EDIT_RIGHT, right);
 608.295 -	DDX_Control(pDX, IDC_EDIT_LEFT, left);
 608.296 -	DDX_Control(pDX, IDC_EDIT_DOWN, down);
 608.297 -	//}}AFX_DATA_MAP
 608.298 -}
 608.299 -
 608.300 -BEGIN_MESSAGE_MAP(MotionConfig, CDialog)
 608.301 -//{{AFX_MSG_MAP(MotionConfig)
 608.302 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 608.303 -ON_BN_CLICKED(ID_OK, OnOk)
 608.304 -ON_WM_CHAR()
 608.305 -ON_WM_DESTROY()
 608.306 -ON_WM_KEYDOWN()
 608.307 -ON_WM_TIMER()
 608.308 -//}}AFX_MSG_MAP
 608.309 -END_MESSAGE_MAP()
 608.310 -
 608.311 -/////////////////////////////////////////////////////////////////////////////
 608.312 -// MotionConfig message handlers
 608.313 -
 608.314 -void MotionConfig::OnCancel()
 608.315 -{
 608.316 -	EndDialog(FALSE);
 608.317 -}
 608.318 -
 608.319 -void MotionConfig::OnOk()
 608.320 -{
 608.321 -	assignKeys();
 608.322 -	theApp.input->checkKeys();
 608.323 -	EndDialog(TRUE);
 608.324 -}
 608.325 -
 608.326 -void MotionConfig::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
 608.327 -{}
 608.328 -
 608.329 -void MotionConfig::OnDestroy()
 608.330 -{
 608.331 -	CDialog::OnDestroy();
 608.332 -
 608.333 -	KillTimer(timerId);
 608.334 -}
 608.335 -
 608.336 -BOOL MotionConfig::OnInitDialog()
 608.337 -{
 608.338 -	CDialog::OnInitDialog();
 608.339 -
 608.340 -	timerId = SetTimer(0, 200, NULL);
 608.341 -
 608.342 -	SetWindowLong(up, GWL_USERDATA, motion[KEY_UP]);
 608.343 -	up.SetWindowText(theApp.input->getKeyName(motion[KEY_UP]));
 608.344 -
 608.345 -	SetWindowLong(down, GWL_USERDATA, motion[KEY_DOWN]);
 608.346 -	down.SetWindowText(theApp.input->getKeyName(motion[KEY_DOWN]));
 608.347 -
 608.348 -	SetWindowLong(left, GWL_USERDATA, motion[KEY_LEFT]);
 608.349 -	left.SetWindowText(theApp.input->getKeyName(motion[KEY_LEFT]));
 608.350 -
 608.351 -	SetWindowLong(right, GWL_USERDATA, motion[KEY_RIGHT]);
 608.352 -	right.SetWindowText(theApp.input->getKeyName(motion[KEY_RIGHT]));
 608.353 -
 608.354 -	CenterWindow();
 608.355 -
 608.356 -	return TRUE; // return TRUE unless you set the focus to a control
 608.357 -	             // EXCEPTION: OCX Property Pages should return FALSE
 608.358 -}
 608.359 -
 608.360 -void MotionConfig::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 608.361 -{}
 608.362 -
 608.363 -void MotionConfig::OnTimer(UINT nIDEvent)
 608.364 -{
 608.365 -	theApp.input->checkDevices();
 608.366 -
 608.367 -	CDialog::OnTimer(nIDEvent);
 608.368 -}
 608.369 -
 608.370 -void MotionConfig::assignKey(int id, int key)
 608.371 -{
 608.372 -	switch (id)
 608.373 -	{
 608.374 -	case IDC_EDIT_LEFT:
 608.375 -		motion[KEY_LEFT] = key;
 608.376 -		break;
 608.377 -	case IDC_EDIT_RIGHT:
 608.378 -		motion[KEY_RIGHT] = key;
 608.379 -		break;
 608.380 -	case IDC_EDIT_UP:
 608.381 -		motion[KEY_UP] = key;
 608.382 -		break;
 608.383 -	case IDC_EDIT_DOWN:
 608.384 -		motion[KEY_DOWN] = key;
 608.385 -		break;
 608.386 -	}
 608.387 -}
 608.388 -
 608.389 -void MotionConfig::assignKeys()
 608.390 -{
 608.391 -	int id;
 608.392 -
 608.393 -	id = IDC_EDIT_UP;
 608.394 -	assignKey(id, GetWindowLong(up, GWL_USERDATA));
 608.395 -
 608.396 -	id = IDC_EDIT_DOWN;
 608.397 -	assignKey(id, GetWindowLong(down, GWL_USERDATA));
 608.398 -
 608.399 -	id = IDC_EDIT_LEFT;
 608.400 -	assignKey(id, GetWindowLong(left, GWL_USERDATA));
 608.401 -
 608.402 -	id = IDC_EDIT_RIGHT;
 608.403 -	assignKey(id, GetWindowLong(right, GWL_USERDATA));
 608.404 -}
 608.405 -
   609.1 --- a/src/win32/Joypad.h	Sat Mar 03 10:54:39 2012 -0600
   609.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   609.3 @@ -1,145 +0,0 @@
   609.4 -#if !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)
   609.5 -#define AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_
   609.6 -
   609.7 -#if _MSC_VER > 1000
   609.8 -#pragma once
   609.9 -#endif // _MSC_VER > 1000
  609.10 -// -*- C++ -*-
  609.11 -// Joypad.h : header file
  609.12 -//
  609.13 -
  609.14 -/////////////////////////////////////////////////////////////////////////////
  609.15 -// JoypadEditControl window
  609.16 -
  609.17 -class JoypadEditControl : public CEdit
  609.18 -{
  609.19 -	// Construction
  609.20 -public:
  609.21 -	JoypadEditControl();
  609.22 -
  609.23 -	// Attributes
  609.24 -public:
  609.25 -	// Operations
  609.26 -public:
  609.27 -	// Overrides
  609.28 -	// ClassWizard generated virtual function overrides
  609.29 -	//{{AFX_VIRTUAL(JoypadEditControl)
  609.30 -	//}}AFX_VIRTUAL
  609.31 -
  609.32 -	// Implementation
  609.33 -public:
  609.34 -	virtual BOOL PreTranslateMessage(MSG *pMsg);
  609.35 -	afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam);
  609.36 -	virtual ~JoypadEditControl();
  609.37 -
  609.38 -	// Generated message map functions
  609.39 -protected:
  609.40 -	//{{AFX_MSG(JoypadEditControl)
  609.41 -	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  609.42 -	//}}AFX_MSG
  609.43 -
  609.44 -	DECLARE_MESSAGE_MAP()
  609.45 -};
  609.46 -
  609.47 -/////////////////////////////////////////////////////////////////////////////
  609.48 -
  609.49 -/////////////////////////////////////////////////////////////////////////////
  609.50 -// JoypadConfig dialog
  609.51 -
  609.52 -class JoypadConfig : public CDialog
  609.53 -{
  609.54 -	// Construction
  609.55 -public:
  609.56 -	void assignKeys();
  609.57 -	void assignKey(int id, int key);
  609.58 -	JoypadConfig(int w, CWnd*pParent = NULL);  // standard constructor
  609.59 -
  609.60 -	// Dialog Data
  609.61 -	//{{AFX_DATA(JoypadConfig)
  609.62 -	enum { IDD = IDD_CONFIG };
  609.63 -	JoypadEditControl up;
  609.64 -	JoypadEditControl speed;
  609.65 -	JoypadEditControl right;
  609.66 -	JoypadEditControl left;
  609.67 -	JoypadEditControl down;
  609.68 -	JoypadEditControl capture;
  609.69 -	JoypadEditControl buttonStart;
  609.70 -	JoypadEditControl buttonSelect;
  609.71 -	JoypadEditControl buttonR;
  609.72 -	JoypadEditControl buttonL;
  609.73 -	JoypadEditControl buttonGS;
  609.74 -	JoypadEditControl buttonB;
  609.75 -	JoypadEditControl buttonA;
  609.76 -	//}}AFX_DATA
  609.77 -
  609.78 -	// Overrides
  609.79 -	// ClassWizard generated virtual function overrides
  609.80 -	//{{AFX_VIRTUAL(JoypadConfig)
  609.81 -protected:
  609.82 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  609.83 -	//}}AFX_VIRTUAL
  609.84 -
  609.85 -	// Implementation
  609.86 -protected:
  609.87 -	UINT timerId;
  609.88 -	int  which;
  609.89 -
  609.90 -	// Generated message map functions
  609.91 -	//{{AFX_MSG(JoypadConfig)
  609.92 -	afx_msg void OnCancel();
  609.93 -	afx_msg void OnOk();
  609.94 -	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  609.95 -	afx_msg void OnDestroy();
  609.96 -	afx_msg void OnTimer(UINT nIDEvent);
  609.97 -	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  609.98 -	virtual BOOL OnInitDialog();
  609.99 -	//}}AFX_MSG
 609.100 -	DECLARE_MESSAGE_MAP()
 609.101 -};
 609.102 -/////////////////////////////////////////////////////////////////////////////
 609.103 -// MotionConfig dialog
 609.104 -
 609.105 -class MotionConfig : public CDialog
 609.106 -{
 609.107 -	// Construction
 609.108 -public:
 609.109 -	void assignKeys();
 609.110 -	void assignKey(int id, int key);
 609.111 -	MotionConfig(CWnd*pParent = NULL);  // standard constructor
 609.112 -
 609.113 -	// Dialog Data
 609.114 -	//{{AFX_DATA(MotionConfig)
 609.115 -	enum { IDD = IDD_MOTION_CONFIG };
 609.116 -	JoypadEditControl up;
 609.117 -	JoypadEditControl right;
 609.118 -	JoypadEditControl left;
 609.119 -	JoypadEditControl down;
 609.120 -	//}}AFX_DATA
 609.121 -
 609.122 -	// Overrides
 609.123 -	// ClassWizard generated virtual function overrides
 609.124 -	//{{AFX_VIRTUAL(MotionConfig)
 609.125 -protected:
 609.126 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
 609.127 -	//}}AFX_VIRTUAL
 609.128 -
 609.129 -	// Implementation
 609.130 -protected:
 609.131 -	// Generated message map functions
 609.132 -	//{{AFX_MSG(MotionConfig)
 609.133 -	afx_msg void OnCancel();
 609.134 -	afx_msg void OnOk();
 609.135 -	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
 609.136 -	afx_msg void OnDestroy();
 609.137 -	virtual BOOL OnInitDialog();
 609.138 -	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
 609.139 -	afx_msg void OnTimer(UINT nIDEvent);
 609.140 -	//}}AFX_MSG
 609.141 -	DECLARE_MESSAGE_MAP()
 609.142 -private:
 609.143 -	UINT timerId;
 609.144 -};
 609.145 -//{{AFX_INSERT_LOCATION}}
 609.146 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 609.147 -
 609.148 -#endif // !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)
   610.1 --- a/src/win32/KeyboardEdit.cpp	Sat Mar 03 10:54:39 2012 -0600
   610.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   610.3 @@ -1,271 +0,0 @@
   610.4 -////////////////////////////////////////////////////////////////////////////////
   610.5 -// Copyright (C) 1998 by Thierry Maurel
   610.6 -// All rights reserved
   610.7 -//
   610.8 -// Distribute freely, except: don't remove my name from the source or
   610.9 -// documentation (don't take credit for my work), mark your changes (don't
  610.10 -// get me blamed for your possible bugs), don't alter or remove this
  610.11 -// notice.
  610.12 -// No warrantee of any kind, express or implied, is included with this
  610.13 -// software; use at your own risk, responsibility for damages (if any) to
  610.14 -// anyone resulting from the use of this software rests entirely with the
  610.15 -// user.
  610.16 -//
  610.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  610.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  610.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  610.20 -//
  610.21 -////////////////////////////////////////////////////////////////////////////////
  610.22 -// File    : KeyboardEdit.cpp
  610.23 -// Project : AccelsEditor
  610.24 -////////////////////////////////////////////////////////////////////////////////
  610.25 -// Version : 1.0                       * Authors : A.Lebatard + T.Maurel
  610.26 -// Date    : 17.08.98
  610.27 -//
  610.28 -// Remarks : implementation file
  610.29 -//
  610.30 -
  610.31 -////////////////////////////////////////////////////////////////////////////////
  610.32 -// modified by aquanull
  610.33 -
  610.34 -#include "stdafx.h"
  610.35 -#include "KeyboardEdit.h"
  610.36 -
  610.37 -extern TCHAR *mapVirtKeysStringFromWORD(WORD wKey);
  610.38 -
  610.39 -IMPLEMENT_DYNAMIC(CKeyboardEdit, CEdit)
  610.40 -
  610.41 -/////////////////////////////////////////////////////////////////////////////
  610.42 -// CKeyboardEdit
  610.43 -
  610.44 -CKeyboardEdit::CKeyboardEdit()
  610.45 -{
  610.46 -	ResetKey();
  610.47 -}
  610.48 -
  610.49 -CKeyboardEdit::~CKeyboardEdit()
  610.50 -{}
  610.51 -
  610.52 -BEGIN_MESSAGE_MAP(CKeyboardEdit, CEdit)
  610.53 -//{{AFX_MSG_MAP(CKeyboardEdit)
  610.54 -ON_CONTROL_REFLECT_EX(EN_CHANGE, &CKeyboardEdit::OnEnChange)
  610.55 -ON_CONTROL_REFLECT_EX(EN_SETFOCUS, &CKeyboardEdit::OnEnSetfocus)
  610.56 -ON_CONTROL_REFLECT_EX(EN_KILLFOCUS, &CKeyboardEdit::OnEnKillfocus)
  610.57 -//}}AFX_MSG_MAP
  610.58 -END_MESSAGE_MAP()
  610.59 -
  610.60 -/////////////////////////////////////////////////////////////////////////////
  610.61 -// CKeyboardEdit message handlers
  610.62 -BOOL CKeyboardEdit::PreTranslateMessage(MSG *pMsg)
  610.63 -{
  610.64 -	if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
  610.65 -	{
  610.66 -		int key = pMsg->wParam;
  610.67 -		m_keys[key] = true;
  610.68 -		switch (key)
  610.69 -		{
  610.70 -		case VK_CONTROL:
  610.71 -		case VK_MENU:
  610.72 -		case VK_SHIFT:
  610.73 -			m_bCtrlPressed	= m_keys[VK_CONTROL];
  610.74 -			m_bAltPressed	= m_keys[VK_MENU];;
  610.75 -			m_bShiftPressed = m_keys[VK_SHIFT];
  610.76 -			if (!m_keys[m_wVirtKey])
  610.77 -			{
  610.78 -				if (m_keys[m_wJamKey])
  610.79 -				{
  610.80 -					m_wVirtKey = m_wJamKey;
  610.81 -					m_wJamKey  = 0;
  610.82 -				}
  610.83 -				else
  610.84 -					m_wVirtKey = 0;
  610.85 -			}
  610.86 -			if (!m_keys[m_wJamKey])
  610.87 -				m_wJamKey = 0;
  610.88 -			break;
  610.89 -		default:
  610.90 -			m_bCtrlPressed	= m_keys[VK_CONTROL];
  610.91 -			m_bAltPressed	= m_keys[VK_MENU];
  610.92 -			m_bShiftPressed = m_keys[VK_SHIFT];
  610.93 -			if (m_wVirtKey != key)
  610.94 -			{
  610.95 -				if (m_keys[m_wVirtKey])
  610.96 -					m_wJamKey = m_wVirtKey;
  610.97 -				else
  610.98 -					m_wJamKey = 0;
  610.99 -				m_wVirtKey = key;
 610.100 -			}
 610.101 -			else if (!m_keys[m_wJamKey])
 610.102 -				m_wJamKey = 0;
 610.103 -			break;
 610.104 -		}
 610.105 -		DisplayKeyboardString();
 610.106 -		return TRUE;
 610.107 -	}
 610.108 -	else if (pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP)
 610.109 -	{
 610.110 -		int key = pMsg->wParam;
 610.111 -		m_keys[key] = false;
 610.112 -		switch (key)
 610.113 -		{
 610.114 -		case VK_CONTROL:
 610.115 -		case VK_MENU:
 610.116 -		case VK_SHIFT:
 610.117 -			break;
 610.118 -		default:
 610.119 -			m_bCtrlPressed	= m_keys[VK_CONTROL];
 610.120 -			m_bAltPressed	= m_keys[VK_MENU];
 610.121 -			m_bShiftPressed = m_keys[VK_SHIFT];
 610.122 -			if (m_wJamKey)
 610.123 -			{
 610.124 -				if (!m_keys[m_wVirtKey])
 610.125 -				{
 610.126 -					m_wVirtKey = m_wJamKey;
 610.127 -					m_wJamKey  = 0;
 610.128 -				}
 610.129 -				if (!m_keys[m_wJamKey])
 610.130 -					m_wJamKey = 0;
 610.131 -			}
 610.132 -			break;
 610.133 -		}
 610.134 -		DisplayKeyboardString();
 610.135 -		return TRUE;
 610.136 -	}
 610.137 -
 610.138 -	return CEdit::PreTranslateMessage(pMsg);
 610.139 -}
 610.140 -
 610.141 -BOOL CKeyboardEdit::OnEnChange()
 610.142 -{
 610.143 -	return FALSE;
 610.144 -}
 610.145 -
 610.146 -BOOL CKeyboardEdit::OnEnSetfocus()
 610.147 -{
 610.148 -	//SetSel(0, -1, TRUE);	// mouse click makes this in vain, so we use the method below instead
 610.149 -	PostMessage(EM_SETSEL, 0, -1);
 610.150 -	m_bForceUpdate = true;
 610.151 -	return FALSE;
 610.152 -}
 610.153 -
 610.154 -BOOL CKeyboardEdit::OnEnKillfocus()
 610.155 -{
 610.156 -	AllKeyUp();
 610.157 -	return FALSE;
 610.158 -}
 610.159 -
 610.160 -////////////////////////////////////////////////////////////////////////
 610.161 -//
 610.162 -void CKeyboardEdit::DisplayKeyboardString()
 610.163 -{
 610.164 -	CString strKbd;
 610.165 -
 610.166 -	// modifiers
 610.167 -	if (m_bCtrlPressed)
 610.168 -		strKbd = "Ctrl";
 610.169 -
 610.170 -	if (m_bAltPressed)
 610.171 -	{
 610.172 -		if (strKbd.GetLength() > 0)
 610.173 -			strKbd += '+';
 610.174 -		strKbd += "Alt";
 610.175 -	}
 610.176 -	if (m_bShiftPressed)
 610.177 -	{
 610.178 -		if (strKbd.GetLength() > 0)
 610.179 -			strKbd += '+';
 610.180 -		strKbd += "Shift";
 610.181 -	}
 610.182 -	// virtual key
 610.183 -	LPCTSTR szVirtKey = mapVirtKeysStringFromWORD(m_wVirtKey);
 610.184 -	if (szVirtKey != NULL)
 610.185 -	{
 610.186 -		if (strKbd.GetLength() > 0)
 610.187 -			strKbd += '+';
 610.188 -		strKbd += szVirtKey;
 610.189 -	}
 610.190 -	// jammed key
 610.191 -	LPCTSTR szJamKey = mapVirtKeysStringFromWORD(m_wJamKey);
 610.192 -	if (szJamKey != NULL)
 610.193 -	{
 610.194 -		strKbd += '(';
 610.195 -		strKbd += szJamKey;
 610.196 -		strKbd += ')';
 610.197 -	}
 610.198 -
 610.199 -	if (m_bForceUpdate)
 610.200 -	{
 610.201 -		m_bForceUpdate = false;
 610.202 -		SetWindowText(strKbd);
 610.203 -	}
 610.204 -	else
 610.205 -	{
 610.206 -		CString oldString;
 610.207 -		GetWindowText(oldString);
 610.208 -		if (oldString.Compare(strKbd))
 610.209 -			SetWindowText(strKbd);
 610.210 -	}
 610.211 -}
 610.212 -
 610.213 -////////////////////////////////////////////////////////////////////////
 610.214 -//
 610.215 -void CKeyboardEdit::ResetKey()
 610.216 -{
 610.217 -	AllKeyUp();
 610.218 -
 610.219 -	m_bForceUpdate		= true;
 610.220 -	m_bCtrlPressed	= false;
 610.221 -	m_bAltPressed	= false;
 610.222 -	m_bShiftPressed = false;
 610.223 -	m_wVirtKey		= 0;
 610.224 -	m_wJamKey		= 0;
 610.225 -
 610.226 -	if (m_hWnd != NULL)
 610.227 -	{
 610.228 -		CString oldString;
 610.229 -		GetWindowText(oldString);
 610.230 -		if (!oldString.IsEmpty())
 610.231 -			SetWindowText(_T(""));
 610.232 -	}
 610.233 -}
 610.234 -
 610.235 -void CKeyboardEdit::AllKeyUp()
 610.236 -{
 610.237 -	for (int i = 0; i < 256; ++i)
 610.238 -		m_keys[i] = 0;
 610.239 -}
 610.240 -
 610.241 -////////////////////////////////////////////////////////////////////////
 610.242 -//
 610.243 -bool CKeyboardEdit::GetAccelKey(WORD &wVirtKey, bool &bCtrl, bool &bAlt, bool &bShift) const
 610.244 -{
 610.245 -	if (!IsDefined())
 610.246 -		return false;
 610.247 -
 610.248 -	wVirtKey = m_wVirtKey;
 610.249 -	bAlt	 = m_bAltPressed;
 610.250 -	bCtrl	 = m_bCtrlPressed;
 610.251 -	bShift	 = m_bShiftPressed;
 610.252 -	return true;
 610.253 -}
 610.254 -
 610.255 -bool CKeyboardEdit::GetJamKey(WORD &wJamKey) const
 610.256 -{
 610.257 -	if (m_wJamKey != 0)
 610.258 -		wJamKey = m_wJamKey;
 610.259 -	return m_wJamKey != 0;
 610.260 -}
 610.261 -
 610.262 -bool CKeyboardEdit::IsDefined() const
 610.263 -{
 610.264 -	return bool(m_wVirtKey || m_bAltPressed || m_bCtrlPressed || m_bShiftPressed);
 610.265 -}
 610.266 -
 610.267 -bool CKeyboardEdit::IsFinished() const
 610.268 -{
 610.269 -	bool finished = true;
 610.270 -	for (int i = 0; i < 256; ++i)
 610.271 -		if (m_keys[i])
 610.272 -			finished = false;
 610.273 -	return finished;
 610.274 -}
   611.1 --- a/src/win32/KeyboardEdit.h	Sat Mar 03 10:54:39 2012 -0600
   611.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   611.3 @@ -1,96 +0,0 @@
   611.4 -////////////////////////////////////////////////////////////////////////////////
   611.5 -// Copyright (C) 1998 by Thierry Maurel
   611.6 -// All rights reserved
   611.7 -//
   611.8 -// Distribute freely, except: don't remove my name from the source or
   611.9 -// documentation (don't take credit for my work), mark your changes (don't
  611.10 -// get me blamed for your possible bugs), don't alter or remove this
  611.11 -// notice.
  611.12 -// No warrantee of any kind, express or implied, is included with this
  611.13 -// software; use at your own risk, responsibility for damages (if any) to
  611.14 -// anyone resulting from the use of this software rests entirely with the
  611.15 -// user.
  611.16 -//
  611.17 -// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  611.18 -// I'll try to keep a version up to date.  I can be reached as follows:
  611.19 -//    tmaurel@caramail.com   (or tmaurel@hol.fr)
  611.20 -//
  611.21 -////////////////////////////////////////////////////////////////////////////////
  611.22 -// File    : KeyboardEdit.h
  611.23 -// Project : AccelsEditor
  611.24 -////////////////////////////////////////////////////////////////////////////////
  611.25 -// Version : 1.0                       * Authors : A.Lebatard + T.Maurel
  611.26 -// Date    : 17.08.98
  611.27 -//
  611.28 -// Remarks :
  611.29 -//
  611.30 -////////////////////////////////////////////////////////////////////////////////
  611.31 -// Modified by the VBA-rr Team
  611.32 -
  611.33 -#if !defined(AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_)
  611.34 -#define AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_
  611.35 -
  611.36 -#if _MSC_VER >= 1000
  611.37 -#pragma once
  611.38 -#endif // _MSC_VER >= 1000
  611.39 -// KeyboardEdit.h : header file
  611.40 -//
  611.41 -
  611.42 -/////////////////////////////////////////////////////////////////////////////
  611.43 -// CKeyboardEdit window
  611.44 -
  611.45 -class CKeyboardEdit : public CEdit
  611.46 -{
  611.47 -	DECLARE_DYNAMIC(CKeyboardEdit)	// what will this do?
  611.48 -
  611.49 -	// Construction
  611.50 -public:
  611.51 -	CKeyboardEdit();
  611.52 -
  611.53 -	// Operations
  611.54 -public:
  611.55 -	void ResetKey();
  611.56 -	void AllKeyUp();
  611.57 -	bool GetAccelKey(WORD &wVirtKey, bool &bCtrl, bool &bAlt, bool &bShift) const;
  611.58 -	bool GetJamKey(WORD &wJamKey) const;
  611.59 -	bool IsDefined() const;
  611.60 -	bool IsFinished() const;
  611.61 -
  611.62 -	// Overrides
  611.63 -	// ClassWizard generated virtual function overrides
  611.64 -	//{{AFX_VIRTUAL(CKeyboardEdit)
  611.65 -public:
  611.66 -	virtual BOOL PreTranslateMessage(MSG *pMsg);
  611.67 -	virtual ~CKeyboardEdit();
  611.68 -	//}}AFX_VIRTUAL
  611.69 -
  611.70 -protected:
  611.71 -	void DisplayKeyboardString();
  611.72 -
  611.73 -	// Attributes
  611.74 -protected:
  611.75 -	BYTE m_keys[256];
  611.76 -	bool m_bForceUpdate;
  611.77 -	bool m_bCtrlPressed;
  611.78 -	bool m_bAltPressed;
  611.79 -	bool m_bShiftPressed;
  611.80 -	WORD m_wVirtKey;
  611.81 -	WORD m_wJamKey;
  611.82 -
  611.83 -	// Generated message map functions
  611.84 -public:
  611.85 -	//{{AFX_MSG(CKeyboardEdit)
  611.86 -	afx_msg BOOL OnEnChange();
  611.87 -	afx_msg BOOL OnEnSetfocus();
  611.88 -	afx_msg BOOL OnEnKillfocus();
  611.89 -	//}}AFX_MSG
  611.90 -
  611.91 -	DECLARE_MESSAGE_MAP()
  611.92 -};
  611.93 -
  611.94 -/////////////////////////////////////////////////////////////////////////////
  611.95 -
  611.96 -//{{AFX_INSERT_LOCATION}}
  611.97 -// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  611.98 -
  611.99 -#endif // !defined(AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_)
   612.1 --- a/src/win32/LangSelect.cpp	Sat Mar 03 10:54:39 2012 -0600
   612.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   612.3 @@ -1,75 +0,0 @@
   612.4 -// LangSelect.cpp : implementation file
   612.5 -//
   612.6 -
   612.7 -#include "stdafx.h"
   612.8 -#include "resource.h"
   612.9 -#include "LangSelect.h"
  612.10 -#include "VBA.h"
  612.11 -
  612.12 -/////////////////////////////////////////////////////////////////////////////
  612.13 -// LangSelect dialog
  612.14 -
  612.15 -LangSelect::LangSelect(CWnd*pParent /*=NULL*/)
  612.16 -	: CDialog(LangSelect::IDD, pParent)
  612.17 -{
  612.18 -	//{{AFX_DATA_INIT(LangSelect)
  612.19 -	// NOTE: the ClassWizard will add member initialization here
  612.20 -	//}}AFX_DATA_INIT
  612.21 -}
  612.22 -
  612.23 -void LangSelect::DoDataExchange(CDataExchange*pDX)
  612.24 -{
  612.25 -	CDialog::DoDataExchange(pDX);
  612.26 -	//{{AFX_DATA_MAP(LangSelect)
  612.27 -	DDX_Control(pDX, IDC_LANG_STRING, m_langString);
  612.28 -	DDX_Control(pDX, IDC_LANG_NAME, m_langName);
  612.29 -	//}}AFX_DATA_MAP
  612.30 -}
  612.31 -
  612.32 -BEGIN_MESSAGE_MAP(LangSelect, CDialog)
  612.33 -//{{AFX_MSG_MAP(LangSelect)
  612.34 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  612.35 -ON_BN_CLICKED(ID_OK, OnOk)
  612.36 -//}}AFX_MSG_MAP
  612.37 -END_MESSAGE_MAP()
  612.38 -
  612.39 -/////////////////////////////////////////////////////////////////////////////
  612.40 -// LangSelect message handlers
  612.41 -
  612.42 -void LangSelect::OnCancel()
  612.43 -{
  612.44 -	EndDialog(FALSE);
  612.45 -}
  612.46 -
  612.47 -void LangSelect::OnOk()
  612.48 -{
  612.49 -	m_langString.GetWindowText(theApp.languageName);
  612.50 -	EndDialog(TRUE);
  612.51 -}
  612.52 -
  612.53 -BOOL LangSelect::OnInitDialog()
  612.54 -{
  612.55 -	CDialog::OnInitDialog();
  612.56 -
  612.57 -	char lbuffer[10];
  612.58 -	if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME,
  612.59 -	                  lbuffer, 10))
  612.60 -	{
  612.61 -		m_langName.SetWindowText(lbuffer);
  612.62 -	}
  612.63 -	else
  612.64 -	{
  612.65 -		m_langName.SetWindowText("???");
  612.66 -	}
  612.67 -
  612.68 -	if (!theApp.languageName.IsEmpty())
  612.69 -		m_langString.SetWindowText(theApp.languageName);
  612.70 -
  612.71 -	m_langString.LimitText(3);
  612.72 -
  612.73 -	CenterWindow();
  612.74 -
  612.75 -	return TRUE; // return TRUE unless you set the focus to a control
  612.76 -	             // EXCEPTION: OCX Property Pages should return FALSE
  612.77 -}
  612.78 -
   613.1 --- a/src/win32/LangSelect.h	Sat Mar 03 10:54:39 2012 -0600
   613.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   613.3 @@ -1,48 +0,0 @@
   613.4 -#if !defined(AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_)
   613.5 -#define AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_
   613.6 -
   613.7 -#if _MSC_VER > 1000
   613.8 -#pragma once
   613.9 -#endif // _MSC_VER > 1000
  613.10 -// -*- C++ -*-
  613.11 -// LangSelect.h : header file
  613.12 -//
  613.13 -
  613.14 -/////////////////////////////////////////////////////////////////////////////
  613.15 -// LangSelect dialog
  613.16 -
  613.17 -class LangSelect : public CDialog
  613.18 -{
  613.19 -	// Construction
  613.20 -public:
  613.21 -	LangSelect(CWnd*pParent = NULL);  // standard constructor
  613.22 -
  613.23 -	// Dialog Data
  613.24 -	//{{AFX_DATA(LangSelect)
  613.25 -	enum { IDD = IDD_LANG_SELECT };
  613.26 -	CEdit   m_langString;
  613.27 -	CStatic m_langName;
  613.28 -	//}}AFX_DATA
  613.29 -
  613.30 -	// Overrides
  613.31 -	// ClassWizard generated virtual function overrides
  613.32 -	//{{AFX_VIRTUAL(LangSelect)
  613.33 -protected:
  613.34 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  613.35 -	//}}AFX_VIRTUAL
  613.36 -
  613.37 -	// Implementation
  613.38 -protected:
  613.39 -	// Generated message map functions
  613.40 -	//{{AFX_MSG(LangSelect)
  613.41 -	afx_msg void OnCancel();
  613.42 -	afx_msg void OnOk();
  613.43 -	virtual BOOL OnInitDialog();
  613.44 -	//}}AFX_MSG
  613.45 -	DECLARE_MESSAGE_MAP()
  613.46 -};
  613.47 -
  613.48 -//{{AFX_INSERT_LOCATION}}
  613.49 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  613.50 -
  613.51 -#endif // !defined(AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_)
   614.1 --- a/src/win32/Logging.cpp	Sat Mar 03 10:54:39 2012 -0600
   614.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   614.3 @@ -1,273 +0,0 @@
   614.4 -// Logging.cpp : implementation file
   614.5 -//
   614.6 -
   614.7 -#include "stdafx.h"
   614.8 -#include "resource.h"
   614.9 -#include "Logging.h"
  614.10 -#include "FileDlg.h"
  614.11 -
  614.12 -#include "../common/System.h"
  614.13 -
  614.14 -/////////////////////////////////////////////////////////////////////////////
  614.15 -// Logging dialog
  614.16 -
  614.17 -Logging *Logging::instance = NULL;
  614.18 -CString Logging:: text;
  614.19 -
  614.20 -Logging::Logging(CWnd*pParent /*=NULL*/)
  614.21 -	: ResizeDlg(Logging::IDD, pParent)
  614.22 -{
  614.23 -	//{{AFX_DATA_INIT(Logging)
  614.24 -	m_swi = FALSE;
  614.25 -	m_unaligned_access = FALSE;
  614.26 -	m_illegal_write    = FALSE;
  614.27 -	m_illegal_read     = FALSE;
  614.28 -	m_dma0      = FALSE;
  614.29 -	m_dma1      = FALSE;
  614.30 -	m_dma2      = FALSE;
  614.31 -	m_dma3      = FALSE;
  614.32 -	m_agbprint  = FALSE;
  614.33 -	m_undefined = FALSE;
  614.34 -	//}}AFX_DATA_INIT
  614.35 -}
  614.36 -
  614.37 -void Logging::DoDataExchange(CDataExchange*pDX)
  614.38 -{
  614.39 -	CDialog::DoDataExchange(pDX);
  614.40 -	//{{AFX_DATA_MAP(Logging)
  614.41 -	DDX_Control(pDX, IDC_LOG, m_log);
  614.42 -	DDX_Check(pDX, IDC_VERBOSE_SWI, m_swi);
  614.43 -	DDX_Check(pDX, IDC_VERBOSE_UNALIGNED_ACCESS, m_unaligned_access);
  614.44 -	DDX_Check(pDX, IDC_VERBOSE_ILLEGAL_WRITE, m_illegal_write);
  614.45 -	DDX_Check(pDX, IDC_VERBOSE_ILLEGAL_READ, m_illegal_read);
  614.46 -	DDX_Check(pDX, IDC_VERBOSE_DMA0, m_dma0);
  614.47 -	DDX_Check(pDX, IDC_VERBOSE_DMA1, m_dma1);
  614.48 -	DDX_Check(pDX, IDC_VERBOSE_DMA2, m_dma2);
  614.49 -	DDX_Check(pDX, IDC_VERBOSE_DMA3, m_dma3);
  614.50 -	DDX_Check(pDX, IDC_VERBOSE_AGBPRINT, m_agbprint);
  614.51 -	DDX_Check(pDX, IDC_VERBOSE_UNDEFINED, m_undefined);
  614.52 -	//}}AFX_DATA_MAP
  614.53 -}
  614.54 -
  614.55 -BEGIN_MESSAGE_MAP(Logging, CDialog)
  614.56 -//{{AFX_MSG_MAP(Logging)
  614.57 -ON_BN_CLICKED(ID_OK, OnOk)
  614.58 -ON_BN_CLICKED(IDC_CLEAR, OnClear)
  614.59 -ON_BN_CLICKED(IDC_VERBOSE_AGBPRINT, OnVerboseAgbprint)
  614.60 -ON_BN_CLICKED(IDC_VERBOSE_DMA0, OnVerboseDma0)
  614.61 -ON_BN_CLICKED(IDC_VERBOSE_DMA1, OnVerboseDma1)
  614.62 -ON_BN_CLICKED(IDC_VERBOSE_DMA2, OnVerboseDma2)
  614.63 -ON_BN_CLICKED(IDC_VERBOSE_DMA3, OnVerboseDma3)
  614.64 -ON_BN_CLICKED(IDC_VERBOSE_ILLEGAL_READ, OnVerboseIllegalRead)
  614.65 -ON_BN_CLICKED(IDC_VERBOSE_ILLEGAL_WRITE, OnVerboseIllegalWrite)
  614.66 -ON_BN_CLICKED(IDC_VERBOSE_SWI, OnVerboseSwi)
  614.67 -ON_BN_CLICKED(IDC_VERBOSE_UNALIGNED_ACCESS, OnVerboseUnalignedAccess)
  614.68 -ON_BN_CLICKED(IDC_VERBOSE_UNDEFINED, OnVerboseUndefined)
  614.69 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  614.70 -ON_EN_ERRSPACE(IDC_LOG, OnErrspaceLog)
  614.71 -ON_EN_MAXTEXT(IDC_LOG, OnMaxtextLog)
  614.72 -ON_WM_CLOSE()
  614.73 -//}}AFX_MSG_MAP
  614.74 -END_MESSAGE_MAP()
  614.75 -
  614.76 -/////////////////////////////////////////////////////////////////////////////
  614.77 -// Logging message handlers
  614.78 -
  614.79 -void Logging::OnOk()
  614.80 -{
  614.81 -	EndDialog(TRUE);
  614.82 -
  614.83 -	instance = NULL;
  614.84 -}
  614.85 -
  614.86 -void Logging::OnClear()
  614.87 -{
  614.88 -	text = "";
  614.89 -	m_log.SetWindowText("");
  614.90 -}
  614.91 -
  614.92 -void Logging::OnVerboseAgbprint()
  614.93 -{
  614.94 -	systemVerbose ^= 512;
  614.95 -}
  614.96 -
  614.97 -void Logging::OnVerboseDma0()
  614.98 -{
  614.99 -	systemVerbose ^= 16;
 614.100 -}
 614.101 -
 614.102 -void Logging::OnVerboseDma1()
 614.103 -{
 614.104 -	systemVerbose ^= 32;
 614.105 -}
 614.106 -
 614.107 -void Logging::OnVerboseDma2()
 614.108 -{
 614.109 -	systemVerbose ^= 64;
 614.110 -}
 614.111 -
 614.112 -void Logging::OnVerboseDma3()
 614.113 -{
 614.114 -	systemVerbose ^= 128;
 614.115 -}
 614.116 -
 614.117 -void Logging::OnVerboseIllegalRead()
 614.118 -{
 614.119 -	systemVerbose ^= 8;
 614.120 -}
 614.121 -
 614.122 -void Logging::OnVerboseIllegalWrite()
 614.123 -{
 614.124 -	systemVerbose ^= 4;
 614.125 -}
 614.126 -
 614.127 -void Logging::OnVerboseSwi()
 614.128 -{
 614.129 -	systemVerbose ^= 1;
 614.130 -}
 614.131 -
 614.132 -void Logging::OnVerboseUnalignedAccess()
 614.133 -{
 614.134 -	systemVerbose ^= 2;
 614.135 -}
 614.136 -
 614.137 -void Logging::OnVerboseUndefined()
 614.138 -{
 614.139 -	systemVerbose ^= 256;
 614.140 -}
 614.141 -
 614.142 -void Logging::OnSave()
 614.143 -{
 614.144 -	int len = m_log.GetWindowTextLength();
 614.145 -
 614.146 -	char *mem = (char *)malloc(len);
 614.147 -
 614.148 -	if (mem)
 614.149 -	{
 614.150 -		LPCTSTR exts[] = { ".txt", NULL };
 614.151 -		m_log.GetWindowText(mem, len);
 614.152 -		CString filter = "All Files|*.*||";
 614.153 -		FileDlg dlg(this, "", filter, 0,
 614.154 -		            NULL, exts, NULL, "Save output", true);
 614.155 -
 614.156 -		if (dlg.DoModal() == IDOK)
 614.157 -		{
 614.158 -			FILE *f = fopen(dlg.GetPathName(), "w");
 614.159 -			if (f)
 614.160 -			{
 614.161 -				fwrite(mem, 1, len, f);
 614.162 -				fclose(f);
 614.163 -			}
 614.164 -		}
 614.165 -	}
 614.166 -
 614.167 -	free(mem);
 614.168 -}
 614.169 -
 614.170 -void Logging::OnErrspaceLog()
 614.171 -{
 614.172 -	systemMessage(0, "Error allocating space");
 614.173 -}
 614.174 -
 614.175 -void Logging::OnMaxtextLog()
 614.176 -{
 614.177 -	systemMessage(0, "Max text length reached %d", m_log.GetLimitText());
 614.178 -}
 614.179 -
 614.180 -void Logging::PostNcDestroy()
 614.181 -{
 614.182 -	delete this;
 614.183 -}
 614.184 -
 614.185 -BOOL Logging::OnInitDialog()
 614.186 -{
 614.187 -	CDialog::OnInitDialog();
 614.188 -
 614.189 -	DIALOG_SIZER_START(sz)
 614.190 -	DIALOG_SIZER_ENTRY(IDC_LOG, DS_SizeY|DS_SizeX)
 614.191 -	DIALOG_SIZER_ENTRY(ID_OK, DS_MoveY)
 614.192 -	DIALOG_SIZER_ENTRY(IDC_CLEAR, DS_MoveY)
 614.193 -	DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
 614.194 -	DIALOG_SIZER_END()
 614.195 -	SetData(sz,
 614.196 -	        TRUE,
 614.197 -	        HKEY_CURRENT_USER,
 614.198 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\LogView",
 614.199 -	        NULL);
 614.200 -
 614.201 -	m_swi = (systemVerbose & 1) != 0;
 614.202 -	m_unaligned_access = (systemVerbose & 2) != 0;
 614.203 -	m_illegal_write    = (systemVerbose & 4) != 0;
 614.204 -	m_illegal_read     = (systemVerbose & 8) != 0;
 614.205 -	m_dma0      = (systemVerbose & 16) != 0;
 614.206 -	m_dma1      = (systemVerbose & 32) != 0;
 614.207 -	m_dma2      = (systemVerbose & 64) != 0;
 614.208 -	m_dma3      = (systemVerbose & 128) != 0;
 614.209 -	m_undefined = (systemVerbose & 256) != 0;
 614.210 -	m_agbprint  = (systemVerbose & 256) != 0;
 614.211 -	UpdateData(FALSE);
 614.212 -
 614.213 -	m_log.LimitText(-1);
 614.214 -	m_log.SetWindowText(text);
 614.215 -
 614.216 -	return TRUE; // return TRUE unless you set the focus to a control
 614.217 -	             // EXCEPTION: OCX Property Pages should return FALSE
 614.218 -}
 614.219 -
 614.220 -void Logging::log(const char *s)
 614.221 -{
 614.222 -	int size = ::SendMessage(m_log, WM_GETTEXTLENGTH, 0, 0);
 614.223 -	m_log.SetSel(size, size);
 614.224 -	m_log.ReplaceSel(s);
 614.225 -}
 614.226 -
 614.227 -void Logging::OnClose()
 614.228 -{
 614.229 -	EndDialog(FALSE);
 614.230 -
 614.231 -	instance = NULL;
 614.232 -
 614.233 -	CDialog::OnClose();
 614.234 -}
 614.235 -
 614.236 -void toolsLogging()
 614.237 -{
 614.238 -	if (Logging::instance == NULL)
 614.239 -	{
 614.240 -		Logging::instance = new Logging();
 614.241 -		Logging::instance->Create(IDD_LOGGING, AfxGetApp()->m_pMainWnd);
 614.242 -		Logging::instance->ShowWindow(SW_SHOW);
 614.243 -	}
 614.244 -	else
 614.245 -	{
 614.246 -		Logging::instance->SetForegroundWindow();
 614.247 -	}
 614.248 -}
 614.249 -
 614.250 -void toolsLog(const char *s)
 614.251 -{
 614.252 -	CString str;
 614.253 -	int     state = 0;
 614.254 -	if (s)
 614.255 -	{
 614.256 -		char c = *s++;
 614.257 -		while (c)
 614.258 -		{
 614.259 -			if (c == '\n' && state == 0)
 614.260 -				str += '\r';
 614.261 -			else if (c == '\r')
 614.262 -				state = 1;
 614.263 -			else
 614.264 -				state = 0;
 614.265 -			str += c;
 614.266 -			c    = *s++;
 614.267 -		}
 614.268 -	}
 614.269 -
 614.270 -	Logging::text += str;
 614.271 -	if (Logging::instance != NULL)
 614.272 -	{
 614.273 -		Logging::instance->log(str);
 614.274 -	}
 614.275 -}
 614.276 -
   615.1 --- a/src/win32/Logging.h	Sat Mar 03 10:54:39 2012 -0600
   615.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   615.3 @@ -1,78 +0,0 @@
   615.4 -#if !defined(AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_)
   615.5 -#define AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_
   615.6 -
   615.7 -#if _MSC_VER > 1000
   615.8 -#pragma once
   615.9 -#endif // _MSC_VER > 1000
  615.10 -// -*- C++ -*-
  615.11 -// Logging.h : header file
  615.12 -//
  615.13 -
  615.14 -#include "ResizeDlg.h"
  615.15 -
  615.16 -/////////////////////////////////////////////////////////////////////////////
  615.17 -// Logging dialog
  615.18 -
  615.19 -class Logging : public ResizeDlg
  615.20 -{
  615.21 -	// Construction
  615.22 -public:
  615.23 -	void log(const char *);
  615.24 -	Logging(CWnd*pParent = NULL);  // standard constructor
  615.25 -
  615.26 -	// Dialog Data
  615.27 -	//{{AFX_DATA(Logging)
  615.28 -	enum { IDD = IDD_LOGGING };
  615.29 -	CEdit m_log;
  615.30 -	BOOL  m_swi;
  615.31 -	BOOL  m_unaligned_access;
  615.32 -	BOOL  m_illegal_write;
  615.33 -	BOOL  m_illegal_read;
  615.34 -	BOOL  m_dma0;
  615.35 -	BOOL  m_dma1;
  615.36 -	BOOL  m_dma2;
  615.37 -	BOOL  m_dma3;
  615.38 -	BOOL  m_agbprint;
  615.39 -	BOOL  m_undefined;
  615.40 -	//}}AFX_DATA
  615.41 -
  615.42 -	// Overrides
  615.43 -	// ClassWizard generated virtual function overrides
  615.44 -	//{{AFX_VIRTUAL(Logging)
  615.45 -protected:
  615.46 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  615.47 -	virtual void PostNcDestroy();
  615.48 -	//}}AFX_VIRTUAL
  615.49 -
  615.50 -	// Implementation
  615.51 -protected:
  615.52 -	// Generated message map functions
  615.53 -	//{{AFX_MSG(Logging)
  615.54 -	afx_msg void OnOk();
  615.55 -	afx_msg void OnClear();
  615.56 -	afx_msg void OnVerboseAgbprint();
  615.57 -	afx_msg void OnVerboseDma0();
  615.58 -	afx_msg void OnVerboseDma1();
  615.59 -	afx_msg void OnVerboseDma2();
  615.60 -	afx_msg void OnVerboseDma3();
  615.61 -	afx_msg void OnVerboseIllegalRead();
  615.62 -	afx_msg void OnVerboseIllegalWrite();
  615.63 -	afx_msg void OnVerboseSwi();
  615.64 -	afx_msg void OnVerboseUnalignedAccess();
  615.65 -	afx_msg void OnVerboseUndefined();
  615.66 -	afx_msg void OnSave();
  615.67 -	afx_msg void OnErrspaceLog();
  615.68 -	afx_msg void OnMaxtextLog();
  615.69 -	virtual BOOL OnInitDialog();
  615.70 -	afx_msg void OnClose();
  615.71 -	//}}AFX_MSG
  615.72 -	DECLARE_MESSAGE_MAP()
  615.73 -public:
  615.74 -	static Logging *instance;
  615.75 -	static CString  text;
  615.76 -};
  615.77 -
  615.78 -//{{AFX_INSERT_LOCATION}}
  615.79 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  615.80 -
  615.81 -#endif // !defined(AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_)
   616.1 --- a/src/win32/LuaOpenDialog.cpp	Sat Mar 03 10:54:39 2012 -0600
   616.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   616.3 @@ -1,369 +0,0 @@
   616.4 -// LuaOpenDialog.cpp : implementation file
   616.5 -//
   616.6 -
   616.7 -//#include "stdafx.h"
   616.8 -//#include "resource.h"
   616.9 -#include "LuaOpenDialog.h"
  616.10 -#include "MainWnd.h"
  616.11 -#include "WinResUtil.h"
  616.12 -#include "WinMiscUtil.h"
  616.13 -#include "VBA.h"
  616.14 -#include "Sound.h"
  616.15 -
  616.16 -#include "../common/vbalua.h"
  616.17 -
  616.18 -HWND LuaConsoleHWnd = NULL;
  616.19 -HFONT hFont = NULL;
  616.20 -LOGFONT LuaConsoleLogFont;
  616.21 -
  616.22 -struct ControlLayoutInfo
  616.23 -{
  616.24 -	int controlID;
  616.25 -	
  616.26 -	enum LayoutType // what to do when the containing window resizes
  616.27 -	{
  616.28 -		NONE, // leave the control where it was
  616.29 -		RESIZE_END, // resize the control
  616.30 -		MOVE_START, // move the control
  616.31 -	};
  616.32 -	LayoutType horizontalLayout;
  616.33 -	LayoutType verticalLayout;
  616.34 -};
  616.35 -struct ControlLayoutState
  616.36 -{
  616.37 -	int x,y,width,height;
  616.38 -	bool valid;
  616.39 -	ControlLayoutState() : valid(false) {}
  616.40 -};
  616.41 -
  616.42 -static ControlLayoutInfo controlLayoutInfos [] = {
  616.43 -	{IDC_LUACONSOLE, ControlLayoutInfo::RESIZE_END, ControlLayoutInfo::RESIZE_END},
  616.44 -	{IDC_EDIT_LUAPATH, ControlLayoutInfo::RESIZE_END, ControlLayoutInfo::NONE},
  616.45 -	{IDC_BUTTON_LUARUN, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::NONE},
  616.46 -	{IDC_BUTTON_LUASTOP, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::NONE},
  616.47 -};
  616.48 -static const int numControlLayoutInfos = sizeof(controlLayoutInfos)/sizeof(*controlLayoutInfos);
  616.49 -
  616.50 -struct {
  616.51 -	int width; int height;
  616.52 -	ControlLayoutState layoutState [numControlLayoutInfos];
  616.53 -} windowInfo;
  616.54 -
  616.55 -void PrintToWindowConsole(int hDlgAsInt, const char* str)
  616.56 -{
  616.57 -	HWND hDlg = (HWND)hDlgAsInt;
  616.58 -	HWND hConsole = GetDlgItem(hDlg, IDC_LUACONSOLE);
  616.59 -
  616.60 -	int length = GetWindowTextLength(hConsole);
  616.61 -	if(length >= 250000)
  616.62 -	{
  616.63 -		// discard first half of text if it's getting too long
  616.64 -		SendMessage(hConsole, EM_SETSEL, 0, length/2);
  616.65 -		SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)"");
  616.66 -		length = GetWindowTextLength(hConsole);
  616.67 -	}
  616.68 -	SendMessage(hConsole, EM_SETSEL, length, length);
  616.69 -
  616.70 -	//LuaPerWindowInfo& info = LuaWindowInfo[hDlg];
  616.71 -
  616.72 -	{
  616.73 -		SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)str);
  616.74 -	}
  616.75 -}
  616.76 -
  616.77 -void WinLuaOnStart(int hDlgAsInt)
  616.78 -{
  616.79 -	HWND hDlg = (HWND)hDlgAsInt;
  616.80 -	//LuaPerWindowInfo& info = LuaWindowInfo[hDlg];
  616.81 -	//info.started = true;
  616.82 -	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUABROWSE), false); // disable browse while running because it misbehaves if clicked in a frameadvance loop
  616.83 -	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUASTOP), true);
  616.84 -	SetWindowText(GetDlgItem(hDlg, IDC_BUTTON_LUARUN), "Restart");
  616.85 -	SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), ""); // clear the console
  616.86 -//	Show_Genesis_Screen(HWnd); // otherwise we might never show the first thing the script draws
  616.87 -}
  616.88 -
  616.89 -void WinLuaOnStop(int hDlgAsInt)
  616.90 -{
  616.91 -	HWND hDlg = (HWND)hDlgAsInt;
  616.92 -	//LuaPerWindowInfo& info = LuaWindowInfo[hDlg];
  616.93 -
  616.94 -	HWND prevWindow = GetActiveWindow();
  616.95 -	SetActiveWindow(hDlg); // bring to front among other script/secondary windows, since a stopped script will have some message for the user that would be easier to miss otherwise
  616.96 -	if(prevWindow == AfxGetMainWnd()->GetSafeHwnd()) SetActiveWindow(prevWindow);
  616.97 -
  616.98 -	//info.started = false;
  616.99 -	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUABROWSE), true);
 616.100 -	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUASTOP), false);
 616.101 -	SetWindowText(GetDlgItem(hDlg, IDC_BUTTON_LUARUN), "Run");
 616.102 -//	if(statusOK)
 616.103 -//		Show_Genesis_Screen(MainWindow->getHWnd()); // otherwise we might never show the last thing the script draws
 616.104 -	//if(info.closeOnStop)
 616.105 -	//	PostMessage(hDlg, WM_CLOSE, 0, 0);
 616.106 -}
 616.107 -
 616.108 -INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 616.109 -{
 616.110 -	RECT r;
 616.111 -	RECT r2;
 616.112 -	int dx1, dy1, dx2, dy2;
 616.113 -
 616.114 -	switch (msg) {
 616.115 -
 616.116 -	case WM_INITDIALOG:
 616.117 -	{
 616.118 -		// remove the 30000 character limit from the console control
 616.119 -		SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE),EM_LIMITTEXT,0,0);
 616.120 -
 616.121 -		GetWindowRect(AfxGetMainWnd()->GetSafeHwnd(), &r);
 616.122 -		dx1 = (r.right - r.left) / 2;
 616.123 -		dy1 = (r.bottom - r.top) / 2;
 616.124 -
 616.125 -		GetWindowRect(hDlg, &r2);
 616.126 -		dx2 = (r2.right - r2.left) / 2;
 616.127 -		dy2 = (r2.bottom - r2.top) / 2;
 616.128 -
 616.129 -		int windowIndex = 0;//std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin();
 616.130 -		int staggerOffset = windowIndex * 24;
 616.131 -		r.left += staggerOffset;
 616.132 -		r.right += staggerOffset;
 616.133 -		r.top += staggerOffset;
 616.134 -		r.bottom += staggerOffset;
 616.135 -
 616.136 -		// push it away from the main window if we can
 616.137 -		const int width = (r.right-r.left); 
 616.138 -		const int width2 = (r2.right-r2.left); 
 616.139 -		if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN))
 616.140 -		{
 616.141 -			r.right += width;
 616.142 -			r.left += width;
 616.143 -		}
 616.144 -		else if((int)r.left - (int)width2 > 0)
 616.145 -		{
 616.146 -			r.right -= width2;
 616.147 -			r.left -= width2;
 616.148 -		}
 616.149 -
 616.150 -		SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 616.151 -
 616.152 -		RECT r3;
 616.153 -		GetClientRect(hDlg, &r3);
 616.154 -		windowInfo.width = r3.right - r3.left;
 616.155 -		windowInfo.height = r3.bottom - r3.top;
 616.156 -		for(int i = 0; i < numControlLayoutInfos; i++) {
 616.157 -			ControlLayoutState& layoutState = windowInfo.layoutState[i];
 616.158 -			layoutState.valid = false;
 616.159 -		}
 616.160 -
 616.161 -		DragAcceptFiles(hDlg, true);
 616.162 -		SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, VBAGetLuaScriptName());
 616.163 -
 616.164 -		SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font
 616.165 -		return true;
 616.166 -	}	break;
 616.167 -
 616.168 -	case WM_SIZE:
 616.169 -	{
 616.170 -		// resize or move controls in the window as necessary when the window is resized
 616.171 -
 616.172 -		//LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg];
 616.173 -		int prevDlgWidth = windowInfo.width;
 616.174 -		int prevDlgHeight = windowInfo.height;
 616.175 -
 616.176 -		int dlgWidth = LOWORD(lParam);
 616.177 -		int dlgHeight = HIWORD(lParam);
 616.178 -
 616.179 -		int deltaWidth = dlgWidth - prevDlgWidth;
 616.180 -		int deltaHeight = dlgHeight - prevDlgHeight;
 616.181 -
 616.182 -		for(int i = 0; i < numControlLayoutInfos; i++)
 616.183 -		{
 616.184 -			ControlLayoutInfo layoutInfo = controlLayoutInfos[i];
 616.185 -			ControlLayoutState& layoutState = windowInfo.layoutState[i];
 616.186 -
 616.187 -			HWND hCtrl = GetDlgItem(hDlg,layoutInfo.controlID);
 616.188 -
 616.189 -			int x,y,width,height;
 616.190 -			if(layoutState.valid)
 616.191 -			{
 616.192 -				x = layoutState.x;
 616.193 -				y = layoutState.y;
 616.194 -				width = layoutState.width;
 616.195 -				height = layoutState.height;
 616.196 -			}
 616.197 -			else
 616.198 -			{
 616.199 -				RECT r;
 616.200 -				GetWindowRect(hCtrl, &r);
 616.201 -				POINT p = {r.left, r.top};
 616.202 -				ScreenToClient(hDlg, &p);
 616.203 -				x = p.x;
 616.204 -				y = p.y;
 616.205 -				width = r.right - r.left;
 616.206 -				height = r.bottom - r.top;
 616.207 -			}
 616.208 -
 616.209 -			switch(layoutInfo.horizontalLayout)
 616.210 -			{
 616.211 -				case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break;
 616.212 -				case ControlLayoutInfo::MOVE_START: x += deltaWidth; break;
 616.213 -				default: break;
 616.214 -			}
 616.215 -			switch(layoutInfo.verticalLayout)
 616.216 -			{
 616.217 -				case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break;
 616.218 -				case ControlLayoutInfo::MOVE_START: y += deltaHeight; break;
 616.219 -				default: break;
 616.220 -			}
 616.221 -
 616.222 -			SetWindowPos(hCtrl, 0, x,y, width,height, 0);
 616.223 -
 616.224 -			layoutState.x = x;
 616.225 -			layoutState.y = y;
 616.226 -			layoutState.width = width;
 616.227 -			layoutState.height = height;
 616.228 -			layoutState.valid = true;
 616.229 -		}
 616.230 -
 616.231 -		windowInfo.width = dlgWidth;
 616.232 -		windowInfo.height = dlgHeight;
 616.233 -
 616.234 -		RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
 616.235 -	}	break;
 616.236 -
 616.237 -	case WM_COMMAND:
 616.238 -		switch (LOWORD(wParam)) {
 616.239 -			case IDOK:
 616.240 -			case IDCANCEL: {
 616.241 -				EndDialog(hDlg, true); // goto case WM_CLOSE;
 616.242 -			}	break;
 616.243 -
 616.244 -			case IDC_BUTTON_LUARUN:
 616.245 -			{
 616.246 -				char filename[MAX_PATH];
 616.247 -				GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
 616.248 -				VBALoadLuaCode(filename);
 616.249 -			}	break;
 616.250 -
 616.251 -			case IDC_BUTTON_LUASTOP:
 616.252 -			{
 616.253 -				VBALuaStop();
 616.254 -			}	break;
 616.255 -
 616.256 -			case IDC_BUTTON_LUAEDIT:
 616.257 -			{
 616.258 -				char Str_Tmp [1024];
 616.259 -				SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_GETTEXT,(WPARAM)512,(LPARAM)Str_Tmp);
 616.260 -				// tell the OS to open the file with its associated editor,
 616.261 -				// without blocking on it or leaving a command window open.
 616.262 -				if((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
 616.263 -					if((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
 616.264 -						ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
 616.265 -			}	break;
 616.266 -
 616.267 -			case IDC_BUTTON_LUABROWSE:
 616.268 -			{
 616.269 -				systemSoundClearBuffer();
 616.270 -
 616.271 -				CString filter = winResLoadFilter(IDS_FILTER_LUA);
 616.272 -				CString title  = winResLoadString(IDS_SELECT_LUA_NAME);
 616.273 -
 616.274 -				CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua");
 616.275 -				CString luaDir = winGetDestDir(IDS_LUA_DIR);
 616.276 -
 616.277 -				filter.Replace('|', '\000');
 616.278 -//				char *p = filter.GetBuffer(0);
 616.279 -//				while ((p = strchr(p, '|')) != NULL)
 616.280 -//					*p++ = 0;
 616.281 -
 616.282 -				OPENFILENAME  ofn;
 616.283 -				ZeroMemory( (LPVOID)&ofn, sizeof(OPENFILENAME) );
 616.284 -				ofn.lpstrFile       = luaName.GetBuffer(MAX_PATH);
 616.285 -				ofn.nMaxFile        = MAX_PATH;
 616.286 -				ofn.lStructSize     = sizeof(OPENFILENAME);
 616.287 -				ofn.hwndOwner       = hDlg;
 616.288 -				ofn.lpstrFilter     = filter;
 616.289 -				ofn.nFilterIndex    = 0;
 616.290 -				ofn.lpstrInitialDir = luaDir;
 616.291 -				ofn.lpstrTitle      = title;
 616.292 -				ofn.lpstrDefExt     = "lua";
 616.293 -				ofn.Flags           = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself)
 616.294 -				if(GetOpenFileName( &ofn ))
 616.295 -				{
 616.296 -					SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), luaName);
 616.297 -				}
 616.298 -				return true;
 616.299 -			}	break;
 616.300 -
 616.301 -			case IDC_EDIT_LUAPATH:
 616.302 -			{
 616.303 -				char filename[MAX_PATH];
 616.304 -				GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
 616.305 -				FILE* file = fopen(filename, "rb");
 616.306 -				EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL);
 616.307 -				if(file)
 616.308 -					fclose(file);
 616.309 -			}	break;
 616.310 -
 616.311 -			case IDC_LUACONSOLE_CHOOSEFONT:
 616.312 -			{
 616.313 -				CHOOSEFONT cf;
 616.314 -
 616.315 -				ZeroMemory(&cf, sizeof(cf));
 616.316 -				cf.lStructSize = sizeof(CHOOSEFONT);
 616.317 -				cf.hwndOwner = hDlg;
 616.318 -				cf.lpLogFont = &LuaConsoleLogFont;
 616.319 -				cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
 616.320 -				if (ChooseFont(&cf)) {
 616.321 -					if (hFont) {
 616.322 -						DeleteObject(hFont);
 616.323 -						hFont = NULL;
 616.324 -					}
 616.325 -					hFont = CreateFontIndirect(&LuaConsoleLogFont);
 616.326 -					if (hFont)
 616.327 -						SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
 616.328 -				}
 616.329 -			}	break;
 616.330 -
 616.331 -			case IDC_LUACONSOLE_CLEAR:
 616.332 -			{
 616.333 -				SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
 616.334 -			}	break;
 616.335 -		}
 616.336 -		break;
 616.337 -
 616.338 -	case WM_CLOSE: {
 616.339 -		SendMessage(hDlg, WM_DESTROY, 0, 0);
 616.340 -	}	break;
 616.341 -
 616.342 -	case WM_DESTROY: {
 616.343 -		//VBALuaStop();
 616.344 -		DragAcceptFiles(hDlg, FALSE);
 616.345 -		if (hFont) {
 616.346 -			DeleteObject(hFont);
 616.347 -			hFont = NULL;
 616.348 -		}
 616.349 -		LuaConsoleHWnd = NULL;
 616.350 -	}	break;
 616.351 -
 616.352 -	case WM_DROPFILES: {
 616.353 -		HDROP hDrop;
 616.354 -		//UINT fileNo;
 616.355 -		UINT fileCount;
 616.356 -		char filename[_MAX_PATH];
 616.357 -
 616.358 -		hDrop = (HDROP)wParam;
 616.359 -		fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
 616.360 -		if (fileCount > 0) {
 616.361 -			DragQueryFile(hDrop, 0, filename, sizeof(filename));
 616.362 -			SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename);
 616.363 -		}
 616.364 -		DragFinish(hDrop);
 616.365 -		return true;
 616.366 -	}	break;
 616.367 -
 616.368 -	}
 616.369 -
 616.370 -	return false;
 616.371 -
 616.372 -}
   617.1 --- a/src/win32/LuaOpenDialog.h	Sat Mar 03 10:54:39 2012 -0600
   617.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   617.3 @@ -1,21 +0,0 @@
   617.4 -#if !defined(VBA_WIN32_LUAOPENDIALOG_H_INCLUDED)
   617.5 -#define VBA_WIN32_LUAOPENDIALOG_H_INCLUDED
   617.6 -
   617.7 -#if _MSC_VER > 1000
   617.8 -#pragma once
   617.9 -#endif // _MSC_VER > 1000
  617.10 -// -*- C++ -*-
  617.11 -// LuaOpenDialog.h : header file
  617.12 -//
  617.13 -
  617.14 -#include "stdafx.h"
  617.15 -#include "resource.h"
  617.16 -
  617.17 -extern HWND LuaConsoleHWnd;
  617.18 -
  617.19 -void PrintToWindowConsole(int hDlgAsInt, const char* str);
  617.20 -void WinLuaOnStart(int hDlgAsInt);
  617.21 -void WinLuaOnStop(int hDlgAsInt);
  617.22 -INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  617.23 -
  617.24 -#endif // !defined(VBA_WIN32_LUAOPENDIALOG_H_INCLUDED)
   618.1 --- a/src/win32/MainWnd.cpp	Sat Mar 03 10:54:39 2012 -0600
   618.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   618.3 @@ -1,1511 +0,0 @@
   618.4 -// MainWnd.cpp : implementation file
   618.5 -//
   618.6 -
   618.7 -#include "stdafx.h"
   618.8 -#include <winsock.h>
   618.9 -
  618.10 -#include "resource.h"
  618.11 -#include "MainWnd.h"
  618.12 -
  618.13 -#include "CmdAccelOb.h"
  618.14 -#include "FileDlg.h"
  618.15 -#include "ModeConfirm.h"
  618.16 -#include "Reg.h"
  618.17 -#include "WinResUtil.h"
  618.18 -#include "WinMiscUtil.h"
  618.19 -#include "Input.h"
  618.20 -#include "7zip/7zip.h"
  618.21 -#include "7zip/OpenArchive.h"
  618.22 -#include "LuaOpenDialog.h"
  618.23 -#include "ram_search.h"
  618.24 -#include "ramwatch.h"
  618.25 -#include "Sound.h"
  618.26 -#include "VBA.h"
  618.27 -
  618.28 -#include "../version.h"
  618.29 -#include "../common/Util.h"
  618.30 -#include "../common/movie.h"
  618.31 -#include "../common/vbalua.h"
  618.32 -#include "../gba/GBASound.h"
  618.33 -#include "../gba/GBAGlobals.h"
  618.34 -#include "../gb/gbGlobals.h"
  618.35 -
  618.36 -#define VBA_CONFIRM_MODE WM_APP + 100
  618.37 -
  618.38 -/////////////////////////////////////////////////////////////////////////////
  618.39 -// MainWnd
  618.40 -
  618.41 -MainWnd::MainWnd()
  618.42 -{
  618.43 -	m_hAccelTable = NULL;
  618.44 -	arrow		  = LoadCursor(NULL, IDC_ARROW);
  618.45 -
  618.46 -	InitDecoder();
  618.47 -}
  618.48 -
  618.49 -MainWnd::~MainWnd()
  618.50 -{
  618.51 -	CleanupDecoder();
  618.52 -}
  618.53 -
  618.54 -BEGIN_MESSAGE_MAP(MainWnd, CWnd)
  618.55 -//{{AFX_MSG_MAP(MainWnd)
  618.56 -ON_WM_MOVE()
  618.57 -ON_WM_SIZE()
  618.58 -ON_WM_CLOSE()
  618.59 -ON_WM_INITMENUPOPUP()
  618.60 -ON_WM_INITMENU()
  618.61 -ON_WM_CONTEXTMENU()
  618.62 -ON_WM_MOUSEMOVE()
  618.63 -ON_WM_ACTIVATE()
  618.64 -ON_WM_ACTIVATEAPP()
  618.65 -ON_WM_DROPFILES()
  618.66 -ON_WM_PAINT()
  618.67 -
  618.68 -ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
  618.69 -ON_COMMAND(ID_HELP_FAQ, OnHelpFaq)
  618.70 -ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  618.71 -ON_COMMAND(ID_FILE_OPENGAMEBOY, OnFileOpenGBx)
  618.72 -ON_COMMAND(ID_FILE_PAUSE, OnFilePause)
  618.73 -ON_UPDATE_COMMAND_UI(ID_FILE_PAUSE, OnUpdateFilePause)
  618.74 -ON_COMMAND(ID_FILE_RESET, OnFileReset)
  618.75 -ON_UPDATE_COMMAND_UI(ID_FILE_RESET, OnUpdateFileReset)
  618.76 -ON_UPDATE_COMMAND_UI(ID_FILE_RECENT_FREEZE, OnUpdateFileRecentFreeze)
  618.77 -ON_COMMAND(ID_FILE_RECENT_RESET, OnFileRecentReset)
  618.78 -ON_COMMAND(ID_FILE_RECENT_FREEZE, OnFileRecentFreeze)
  618.79 -ON_COMMAND(ID_FILE_EXIT, OnFileExit)
  618.80 -ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
  618.81 -ON_UPDATE_COMMAND_UI(ID_FILE_CLOSE, OnUpdateFileClose)
  618.82 -ON_COMMAND(ID_FILE_LOAD, OnFileLoad)
  618.83 -ON_UPDATE_COMMAND_UI(ID_FILE_LOAD, OnUpdateFileLoad)
  618.84 -ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  618.85 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
  618.86 -ON_COMMAND(ID_FILE_IMPORT_BATTERYFILE, OnFileImportBatteryfile)
  618.87 -ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_BATTERYFILE, OnUpdateFileImportBatteryfile)
  618.88 -ON_COMMAND(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnFileImportGamesharkcodefile)
  618.89 -ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnUpdateFileImportGamesharkcodefile)
  618.90 -ON_COMMAND(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnFileImportGamesharksnapshot)
  618.91 -ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnUpdateFileImportGamesharksnapshot)
  618.92 -ON_COMMAND(ID_FILE_EXPORT_BATTERYFILE, OnFileExportBatteryfile)
  618.93 -ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_BATTERYFILE, OnUpdateFileExportBatteryfile)
  618.94 -ON_COMMAND(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnFileExportGamesharksnapshot)
  618.95 -ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnUpdateFileExportGamesharksnapshot)
  618.96 -ON_COMMAND(ID_FILE_QUICKSCREENCAPTURE, OnFileQuickScreencapture)
  618.97 -ON_COMMAND(ID_FILE_SCREENCAPTURE, OnFileScreencapture)
  618.98 -ON_UPDATE_COMMAND_UI(ID_FILE_SCREENCAPTURE, OnUpdateFileScreencapture)
  618.99 -ON_COMMAND(ID_FILE_ROMINFORMATION, OnFileRominformation)
 618.100 -ON_UPDATE_COMMAND_UI(ID_FILE_ROMINFORMATION, OnUpdateFileRominformation)
 618.101 -ON_COMMAND(ID_FILE_TOGGLEMENU, OnFileTogglemenu)
 618.102 -ON_UPDATE_COMMAND_UI(ID_FILE_TOGGLEMENU, OnUpdateFileTogglemenu)
 618.103 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnUpdateOptionsFrameskipThrottle6)
 618.104 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnUpdateOptionsFrameskipThrottle15)
 618.105 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnUpdateOptionsFrameskipThrottle25)
 618.106 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnUpdateOptionsFrameskipThrottle50)
 618.107 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnUpdateOptionsFrameskipThrottle75)
 618.108 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnUpdateOptionsFrameskipThrottle100)
 618.109 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnUpdateOptionsFrameskipThrottle125)
 618.110 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnUpdateOptionsFrameskipThrottle150)
 618.111 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnUpdateOptionsFrameskipThrottle200)
 618.112 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnUpdateOptionsFrameskipThrottle300)
 618.113 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_400, OnUpdateOptionsFrameskipThrottle400)
 618.114 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_600, OnUpdateOptionsFrameskipThrottle600)
 618.115 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_1000, OnUpdateOptionsFrameskipThrottle1000)
 618.116 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnUpdateOptionsFrameskipThrottleOther)
 618.117 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnUpdateOptionsFrameskipThrottleIncrease)
 618.118 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnUpdateOptionsFrameskipThrottleDecrease)
 618.119 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnOptionsFrameskipThrottle6)
 618.120 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnOptionsFrameskipThrottle15)
 618.121 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnOptionsFrameskipThrottle25)
 618.122 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnOptionsFrameskipThrottle50)
 618.123 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnOptionsFrameskipThrottle75)
 618.124 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnOptionsFrameskipThrottle100)
 618.125 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnOptionsFrameskipThrottle125)
 618.126 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnOptionsFrameskipThrottle150)
 618.127 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnOptionsFrameskipThrottle200)
 618.128 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnOptionsFrameskipThrottle300)
 618.129 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_400, OnOptionsFrameskipThrottle400)
 618.130 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_600, OnOptionsFrameskipThrottle600)
 618.131 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_1000, OnOptionsFrameskipThrottle1000)
 618.132 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnOptionsFrameskipThrottleOther)
 618.133 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnOptionsFrameskipThrottleIncrease)
 618.134 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnOptionsFrameskipThrottleDecrease)
 618.135 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnOptionsFrameskipAccuratePitch)
 618.136 -ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnOptionsFrameskipAccurateSpeed)
 618.137 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnUpdateOptionsFrameskipAccuratePitch)
 618.138 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnUpdateOptionsFrameskipAccurateSpeed)
 618.139 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_0, OnUpdateOptionsVideoFrameskip0)
 618.140 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_1, OnUpdateOptionsVideoFrameskip1)
 618.141 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_2, OnUpdateOptionsVideoFrameskip2)
 618.142 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_3, OnUpdateOptionsVideoFrameskip3)
 618.143 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_4, OnUpdateOptionsVideoFrameskip4)
 618.144 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_5, OnUpdateOptionsVideoFrameskip5)
 618.145 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_6, OnUpdateOptionsVideoFrameskip6)
 618.146 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_7, OnUpdateOptionsVideoFrameskip7)
 618.147 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_8, OnUpdateOptionsVideoFrameskip8)
 618.148 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_9, OnUpdateOptionsVideoFrameskip9)
 618.149 -ON_COMMAND(ID_OPTIONS_VIDEO_VSYNC, OnOptionsVideoVsync)
 618.150 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_VSYNC, OnUpdateOptionsVideoVsync)
 618.151 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X1, OnUpdateOptionsVideoX1)
 618.152 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X2, OnUpdateOptionsVideoX2)
 618.153 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X3, OnUpdateOptionsVideoX3)
 618.154 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X4, OnUpdateOptionsVideoX4)
 618.155 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnUpdateOptionsVideoFullscreen320x240)
 618.156 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnUpdateOptionsVideoFullscreen640x480)
 618.157 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnUpdateOptionsVideoFullscreen800x600)
 618.158 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnOptionsVideoFullscreen320x240)
 618.159 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnOptionsVideoFullscreen640x480)
 618.160 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnOptionsVideoFullscreen800x600)
 618.161 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN, OnOptionsVideoFullscreen)
 618.162 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN, OnUpdateOptionsVideoFullscreen)
 618.163 -ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESFX, OnOptionsVideoDisablesfx)
 618.164 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESFX, OnUpdateOptionsVideoDisablesfx)
 618.165 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnOptionsVideoFullscreenstretchtofit)
 618.166 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnUpdateOptionsVideoFullscreenstretchtofit)
 618.167 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnOptionsVideoRendermethodGdi)
 618.168 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnUpdateOptionsVideoRendermethodGdi)
 618.169 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnOptionsVideoRendermethodDirectdraw)
 618.170 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnUpdateOptionsVideoRendermethodDirectdraw)
 618.171 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnOptionsVideoRendermethodDirect3d)
 618.172 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnUpdateOptionsVideoRendermethodDirect3d)
 618.173 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnOptionsVideoRendermethodOpengl)
 618.174 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnUpdateOptionsVideoRendermethodOpengl)
 618.175 -ON_COMMAND(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnOptionsVideoTriplebuffering)
 618.176 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnUpdateOptionsVideoTriplebuffering)
 618.177 -ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnOptionsVideoDdrawemulationonly)
 618.178 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnUpdateOptionsVideoDdrawemulationonly)
 618.179 -ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnOptionsVideoDdrawusevideomemory)
 618.180 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnUpdateOptionsVideoDdrawusevideomemory)
 618.181 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnOptionsVideoRenderoptionsD3dnofilter)
 618.182 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnUpdateOptionsVideoRenderoptionsD3dnofilter)
 618.183 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnOptionsVideoRenderoptionsD3dbilinear)
 618.184 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnUpdateOptionsVideoRenderoptionsD3dbilinear)
 618.185 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnOptionsVideoRenderoptionsGlnearest)
 618.186 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnUpdateOptionsVideoRenderoptionsGlnearest)
 618.187 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnOptionsVideoRenderoptionsGlbilinear)
 618.188 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnUpdateOptionsVideoRenderoptionsGlbilinear)
 618.189 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnOptionsVideoRenderoptionsGltriangle)
 618.190 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnUpdateOptionsVideoRenderoptionsGltriangle)
 618.191 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnOptionsVideoRenderoptionsGlquads)
 618.192 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnUpdateOptionsVideoRenderoptionsGlquads)
 618.193 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnOptionsVideoRenderoptionsSelectskin)
 618.194 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnUpdateOptionsVideoRenderoptionsSelectskin)
 618.195 -ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnOptionsVideoRenderoptionsSkin)
 618.196 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnUpdateOptionsVideoRenderoptionsSkin)
 618.197 -ON_COMMAND(ID_OPTIONS_EMULATOR_ASSOCIATE, OnOptionsEmulatorAssociate)
 618.198 -ON_COMMAND(ID_OPTIONS_EMULATOR_DIRECTORIES, OnOptionsEmulatorDirectories)
 618.199 -ON_COMMAND_RANGE(ID_OPTIONS_PREFER_ARCHIVE_NAME, ID_OPTIONS_PREFER_ROM_NAME, OnOptionsEmulatorFilenamePreference)
 618.200 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_PREFER_ARCHIVE_NAME, ID_OPTIONS_PREFER_ROM_NAME, OnUpdateOptionsEmulatorFilenamePreference)
 618.201 -ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnOptionsVideoDisablestatusmessages)
 618.202 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnUpdateOptionsVideoDisablestatusmessages)
 618.203 -ON_COMMAND(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnOptionsEmulatorSynchronize)
 618.204 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnUpdateOptionsEmulatorSynchronize)
 618.205 -
 618.206 -ON_COMMAND(ID_OPTIONS_EMULATOR_ALWAYSONTOP, OnOptionsEmulatorAlwaysOnTop)
 618.207 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_ALWAYSONTOP, OnUpdateOptionsEmulatorAlwaysOnTop)
 618.208 -ON_COMMAND(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnOptionsEmulatorPausewheninactive)
 618.209 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnUpdateOptionsEmulatorPausewheninactive)
 618.210 -ON_COMMAND(ID_OPTIONS_EMULATOR_BACKGROUNDINPUT, OnOptionsEmulatorEnableBackgroundInput)
 618.211 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BACKGROUNDINPUT, OnUpdateOptionsEmulatorEnableBackgroundInput)
 618.212 -ON_COMMAND(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnOptionsEmulatorSpeeduptoggle)
 618.213 -
 618.214 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnUpdateOptionsEmulatorSpeeduptoggle)
 618.215 -ON_COMMAND(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnOptionsEmulatorRemoveintrosgba)
 618.216 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnUpdateOptionsEmulatorRemoveintrosgba)
 618.217 -ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnOptionsEmulatorAutomaticallyipspatch)
 618.218 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnUpdateOptionsEmulatorAutomaticallyipspatch)
 618.219 -ON_COMMAND(ID_OPTIONS_EMULATOR_AGBPRINT, OnOptionsEmulatorAgbprint)
 618.220 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AGBPRINT, OnUpdateOptionsEmulatorAgbprint)
 618.221 -ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock)
 618.222 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnUpdateOptionsEmulatorRealtimeclock)
 618.223 -ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnOptionsEmulatorAutohidemenu)
 618.224 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnUpdateOptionsEmulatorAutohidemenu)
 618.225 -ON_COMMAND(ID_OPTIONS_EMULATOR_REWINDINTERVAL, OnOptionsEmulatorRewindinterval)
 618.226 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnOptionsEmulatorSavetypeAutomatic)
 618.227 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnUpdateOptionsEmulatorSavetypeAutomatic)
 618.228 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnOptionsEmulatorSavetypeEeprom)
 618.229 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnUpdateOptionsEmulatorSavetypeEeprom)
 618.230 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnOptionsEmulatorSavetypeSram)
 618.231 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnUpdateOptionsEmulatorSavetypeSram)
 618.232 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnOptionsEmulatorSavetypeFlash)
 618.233 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnUpdateOptionsEmulatorSavetypeFlash)
 618.234 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnOptionsEmulatorSavetypeEepromsensor)
 618.235 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnUpdateOptionsEmulatorSavetypeEepromsensor)
 618.236 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnOptionsEmulatorSavetypeNone)
 618.237 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnUpdateOptionsEmulatorSavetypeNone)
 618.238 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnOptionsEmulatorSavetypeFlash512k)
 618.239 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnUpdateOptionsEmulatorSavetypeFlash512k)
 618.240 -ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnOptionsEmulatorSavetypeFlash1m)
 618.241 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnUpdateOptionsEmulatorSavetypeFlash1m)
 618.242 -ON_COMMAND(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnOptionsEmulatorUsebiosfile)
 618.243 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnUpdateOptionsEmulatorUsebiosfile)
 618.244 -ON_COMMAND(ID_OPTIONS_EMULATOR_SKIPBIOS, OnOptionsEmulatorSkipbios)
 618.245 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SKIPBIOS, OnUpdateOptionsEmulatorSkipbios)
 618.246 -ON_COMMAND(ID_OPTIONS_EMULATOR_SELECTBIOSFILE, OnOptionsEmulatorSelectbiosfile)
 618.247 -
 618.248 -ON_COMMAND(ID_EMULATOR_USE_OLD_FRAME_TIMING, OnOptionsEmulatorUseOldGBTiming)
 618.249 -ON_UPDATE_COMMAND_UI(ID_EMULATOR_USE_OLD_FRAME_TIMING, OnUpdateOptionsEmulatorUseOldGBTiming)
 618.250 -ON_COMMAND(ID_EMULATOR_USE_GB_INPUT_KLUDGE, OnOptionsEmulatorUseGBNullInputKludge)
 618.251 -ON_UPDATE_COMMAND_UI(ID_EMULATOR_USE_GB_INPUT_KLUDGE, OnUpdateOptionsEmulatorUseGBNullInputKludge)
 618.252 -ON_COMMAND(ID_EMULATOR_GBALAG, OnOptionsEmulatorGBALag)
 618.253 -ON_UPDATE_COMMAND_UI(ID_EMULATOR_GBALAG, OnUpdateOptionsEmulatorGBALag)
 618.254 -
 618.255 -ON_COMMAND(ID_OPTIONS_EMULATOR_PNGFORMAT, OnOptionsEmulatorPngformat)
 618.256 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PNGFORMAT, OnUpdateOptionsEmulatorPngformat)
 618.257 -ON_COMMAND(ID_OPTIONS_EMULATOR_BMPFORMAT, OnOptionsEmulatorBmpformat)
 618.258 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BMPFORMAT, OnUpdateOptionsEmulatorBmpformat)
 618.259 -ON_COMMAND(ID_OPTIONS_SOUND_DISABLE, OnOptionsSoundDisable)
 618.260 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DISABLE, OnUpdateOptionsSoundDisable)
 618.261 -ON_COMMAND(ID_OPTIONS_SOUND_MUTE, OnOptionsSoundMute)
 618.262 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTE, OnUpdateOptionsSoundMute)
 618.263 -ON_COMMAND(ID_OPTIONS_SOUND_OFF, OnOptionsSoundOff)
 618.264 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_OFF, OnUpdateOptionsSoundOff)
 618.265 -ON_COMMAND(ID_OPTIONS_SOUND_ON, OnOptionsSoundOn)
 618.266 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ON, OnUpdateOptionsSoundOn)
 618.267 -ON_COMMAND(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnOptionsSoundUseoldsynchronization)
 618.268 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnUpdateOptionsSoundUseoldsynchronization)
 618.269 -ON_COMMAND(ID_OPTIONS_SOUND_ECHO, OnOptionsSoundEcho)
 618.270 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ECHO, OnUpdateOptionsSoundEcho)
 618.271 -ON_COMMAND(ID_OPTIONS_SOUND_LOWPASSFILTER, OnOptionsSoundLowpassfilter)
 618.272 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_LOWPASSFILTER, OnUpdateOptionsSoundLowpassfilter)
 618.273 -ON_COMMAND(ID_OPTIONS_SOUND_REVERSESTEREO, OnOptionsSoundReversestereo)
 618.274 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_REVERSESTEREO, OnUpdateOptionsSoundReversestereo)
 618.275 -ON_COMMAND(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnOptionsSoundMuteFrameAdvance)
 618.276 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnUpdateOptionsSoundMuteFrameAdvance)
 618.277 -ON_COMMAND(ID_OPTIONS_SOUND_MUTEWHENINACTIVE, OnOptionsSoundMuteWhenInactive)
 618.278 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTEWHENINACTIVE, OnUpdateOptionsSoundMuteWhenInactive)
 618.279 -ON_COMMAND(ID_OPTIONS_SOUND_11KHZ, OnOptionsSound11khz)
 618.280 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_11KHZ, OnUpdateOptionsSound11khz)
 618.281 -ON_COMMAND(ID_OPTIONS_SOUND_22KHZ, OnOptionsSound22khz)
 618.282 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_22KHZ, OnUpdateOptionsSound22khz)
 618.283 -ON_COMMAND(ID_OPTIONS_SOUND_44KHZ, OnOptionsSound44khz)
 618.284 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_44KHZ, OnUpdateOptionsSound44khz)
 618.285 -ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL1, OnOptionsSoundChannel1)
 618.286 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL1, OnUpdateOptionsSoundChannel1)
 618.287 -ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL2, OnOptionsSoundChannel2)
 618.288 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL2, OnUpdateOptionsSoundChannel2)
 618.289 -ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL3, OnOptionsSoundChannel3)
 618.290 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL3, OnUpdateOptionsSoundChannel3)
 618.291 -ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL4, OnOptionsSoundChannel4)
 618.292 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL4, OnUpdateOptionsSoundChannel4)
 618.293 -ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnOptionsSoundDirectsounda)
 618.294 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnUpdateOptionsSoundDirectsounda)
 618.295 -ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnOptionsSoundDirectsoundb)
 618.296 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnUpdateOptionsSoundDirectsoundb)
 618.297 -ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDER, OnOptionsGameboyBorder)
 618.298 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDER, OnUpdateOptionsGameboyBorder)
 618.299 -ON_COMMAND(ID_OPTIONS_GAMEBOY_PRINTER, OnOptionsGameboyPrinter)
 618.300 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_PRINTER, OnUpdateOptionsGameboyPrinter)
 618.301 -ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnOptionsGameboyBorderAutomatic)
 618.302 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnUpdateOptionsGameboyBorderAutomatic)
 618.303 -ON_COMMAND(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnOptionsGameboyAutomatic)
 618.304 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnUpdateOptionsGameboyAutomatic)
 618.305 -ON_COMMAND(ID_OPTIONS_GAMEBOY_GBA, OnOptionsGameboyGba)
 618.306 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GBA, OnUpdateOptionsGameboyGba)
 618.307 -ON_COMMAND(ID_OPTIONS_GAMEBOY_CGB, OnOptionsGameboyCgb)
 618.308 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_CGB, OnUpdateOptionsGameboyCgb)
 618.309 -ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB, OnOptionsGameboySgb)
 618.310 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB, OnUpdateOptionsGameboySgb)
 618.311 -ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB2, OnOptionsGameboySgb2)
 618.312 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB2, OnUpdateOptionsGameboySgb2)
 618.313 -ON_COMMAND(ID_OPTIONS_GAMEBOY_GB, OnOptionsGameboyGb)
 618.314 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GB, OnUpdateOptionsGameboyGb)
 618.315 -ON_COMMAND(ID_OPTIONS_GAMEBOY_REALCOLORS, OnOptionsGameboyRealcolors)
 618.316 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_REALCOLORS, OnUpdateOptionsGameboyRealcolors)
 618.317 -ON_COMMAND(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnOptionsGameboyGameboycolors)
 618.318 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnUpdateOptionsGameboyGameboycolors)
 618.319 -ON_COMMAND(ID_OPTIONS_GAMEBOY_COLORS, OnOptionsGameboyColors)
 618.320 -ON_COMMAND(ID_OPTIONS_FILTER_DISABLEMMX, OnOptionsFilterDisablemmx)
 618.321 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_FILTER_DISABLEMMX, OnUpdateOptionsFilterDisablemmx)
 618.322 -ON_COMMAND(ID_OPTIONS_LANGUAGE_SYSTEM, OnOptionsLanguageSystem)
 618.323 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_SYSTEM, OnUpdateOptionsLanguageSystem)
 618.324 -ON_COMMAND(ID_OPTIONS_LANGUAGE_ENGLISH, OnOptionsLanguageEnglish)
 618.325 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_ENGLISH, OnUpdateOptionsLanguageEnglish)
 618.326 -ON_COMMAND(ID_OPTIONS_LANGUAGE_OTHER, OnOptionsLanguageOther)
 618.327 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_OTHER, OnUpdateOptionsLanguageOther)
 618.328 -ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnOptionsJoypadConfigure1)
 618.329 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnUpdateOptionsJoypadConfigure1)
 618.330 -ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnOptionsJoypadConfigure2)
 618.331 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnUpdateOptionsJoypadConfigure2)
 618.332 -ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnOptionsJoypadConfigure3)
 618.333 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnUpdateOptionsJoypadConfigure3)
 618.334 -ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnOptionsJoypadConfigure4)
 618.335 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnUpdateOptionsJoypadConfigure4)
 618.336 -ON_COMMAND(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnOptionsJoypadMotionconfigure)
 618.337 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnUpdateOptionsJoypadMotionconfigure)
 618.338 -ON_COMMAND(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnOptionsJoypadAllowLeftRight)
 618.339 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnUpdateOptionsJoypadAllowLeftRight)
 618.340 -ON_COMMAND(ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG, OnOptionsJoypadAutofireAccountForLag)
 618.341 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG, OnUpdateOptionsJoypadAutofireAccountForLag)
 618.342 -ON_COMMAND(ID_CHEATS_SEARCHFORCHEATS, OnCheatsSearchforcheats)
 618.343 -ON_UPDATE_COMMAND_UI(ID_CHEATS_SEARCHFORCHEATS, OnUpdateCheatsSearchforcheats)
 618.344 -ON_COMMAND(ID_CHEATS_CHEATLIST, OnCheatsCheatlist)
 618.345 -ON_UPDATE_COMMAND_UI(ID_CHEATS_CHEATLIST, OnUpdateCheatsCheatlist)
 618.346 -ON_COMMAND(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnCheatsAutomaticsaveloadcheats)
 618.347 -ON_COMMAND(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnCheatsPauseDuringCheatSearch)
 618.348 -ON_COMMAND(ID_CHEATS_LOADCHEATLIST, OnCheatsLoadcheatlist)
 618.349 -ON_UPDATE_COMMAND_UI(ID_CHEATS_LOADCHEATLIST, OnUpdateCheatsLoadcheatlist)
 618.350 -ON_COMMAND(ID_CHEATS_SAVECHEATLIST, OnCheatsSavecheatlist)
 618.351 -ON_UPDATE_COMMAND_UI(ID_CHEATS_SAVECHEATLIST, OnUpdateCheatsSavecheatlist)
 618.352 -ON_COMMAND(ID_TOOLS_DISASSEMBLE, OnToolsDisassemble)
 618.353 -ON_UPDATE_COMMAND_UI(ID_TOOLS_DISASSEMBLE, OnUpdateToolsDisassemble)
 618.354 -ON_COMMAND(ID_TOOLS_LOGGING, OnToolsLogging)
 618.355 -ON_UPDATE_COMMAND_UI(ID_TOOLS_LOGGING, OnUpdateToolsLogging)
 618.356 -ON_COMMAND(ID_TOOLS_IOVIEWER, OnToolsIoviewer)
 618.357 -ON_UPDATE_COMMAND_UI(ID_TOOLS_IOVIEWER, OnUpdateToolsIoviewer)
 618.358 -ON_COMMAND(ID_TOOLS_MAPVIEW, OnToolsMapview)
 618.359 -ON_UPDATE_COMMAND_UI(ID_TOOLS_MAPVIEW, OnUpdateToolsMapview)
 618.360 -ON_COMMAND(ID_TOOLS_MEMORYVIEWER, OnToolsMemoryviewer)
 618.361 -ON_UPDATE_COMMAND_UI(ID_TOOLS_MEMORYVIEWER, OnUpdateToolsMemoryviewer)
 618.362 -ON_COMMAND(ID_TOOLS_OAMVIEWER, OnToolsOamviewer)
 618.363 -ON_UPDATE_COMMAND_UI(ID_TOOLS_OAMVIEWER, OnUpdateToolsOamviewer)
 618.364 -ON_COMMAND(ID_TOOLS_PALETTEVIEW, OnToolsPaletteview)
 618.365 -ON_UPDATE_COMMAND_UI(ID_TOOLS_PALETTEVIEW, OnUpdateToolsPaletteview)
 618.366 -ON_COMMAND(ID_TOOLS_TILEVIEWER, OnToolsTileviewer)
 618.367 -ON_UPDATE_COMMAND_UI(ID_TOOLS_TILEVIEWER, OnUpdateToolsTileviewer)
 618.368 -
 618.369 -ON_COMMAND(ID_DEBUG_NEXTFRAME, OnDebugNextframe)
 618.370 -ON_UPDATE_COMMAND_UI(ID_DEBUG_NEXTFRAME, OnUpdateDebugNextframe)
 618.371 -ON_COMMAND(ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG, OnDebugNextframeAccountForLag)
 618.372 -ON_UPDATE_COMMAND_UI(ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG, OnUpdateDebugNextframeAccountForLag)
 618.373 -ON_COMMAND(ID_DEBUG_FRAMESEARCH, OnDebugFramesearch)
 618.374 -ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCH, OnUpdateDebugFramesearch)
 618.375 -ON_COMMAND(ID_DEBUG_FRAMESEARCHPREV, OnDebugFramesearchPrev)
 618.376 -ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHPREV, OnUpdateDebugFramesearchPrev)
 618.377 -ON_COMMAND(ID_DEBUG_FRAMESEARCHLOAD, OnDebugFramesearchLoad)
 618.378 -ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHLOAD, OnUpdateDebugFramesearchLoad)
 618.379 -ON_UPDATE_COMMAND_UI(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnUpdateCheatsAutomaticsaveloadcheats)
 618.380 -ON_UPDATE_COMMAND_UI(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnUpdateCheatsPauseDuringCheatSearch)
 618.381 -ON_COMMAND(ID_TOOLS_FRAMECOUNTER, OnToolsFrameCounter)
 618.382 -ON_UPDATE_COMMAND_UI(ID_TOOLS_FRAMECOUNTER, OnUpdateToolsFrameCounter)
 618.383 -ON_COMMAND(ID_TOOLS_LAGCOUNTER, OnToolsLagCounter)
 618.384 -ON_UPDATE_COMMAND_UI(ID_TOOLS_LAGCOUNTER, OnUpdateToolsLagCounter)
 618.385 -ON_COMMAND(ID_TOOLS_EXTRACOUNTER, OnToolsExtraCounter)
 618.386 -ON_UPDATE_COMMAND_UI(ID_TOOLS_EXTRACOUNTER, OnUpdateToolsExtraCounter)
 618.387 -ON_COMMAND(ID_TOOLS_EXTRACOUNTERRESET, OnToolsExtraCounterReset)
 618.388 -ON_COMMAND(ID_TOOLS_INPUTDISPLAY, OnToolsInputDisplay)
 618.389 -ON_UPDATE_COMMAND_UI(ID_TOOLS_INPUTDISPLAY, OnUpdateToolsInputDisplay)
 618.390 -ON_COMMAND(ID_TOOLS_DEBUG_GDB, OnToolsDebugGdb)
 618.391 -ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_GDB, OnUpdateToolsDebugGdb)
 618.392 -ON_COMMAND(ID_TOOLS_DEBUG_LOADANDWAIT, OnToolsDebugLoadandwait)
 618.393 -ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_LOADANDWAIT, OnUpdateToolsDebugLoadandwait)
 618.394 -ON_COMMAND(ID_TOOLS_DEBUG_BREAK, OnToolsDebugBreak)
 618.395 -ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_BREAK, OnUpdateToolsDebugBreak)
 618.396 -ON_COMMAND(ID_TOOLS_DEBUG_DISCONNECT, OnToolsDebugDisconnect)
 618.397 -ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_DISCONNECT, OnUpdateToolsDebugDisconnect)
 618.398 -
 618.399 -ON_COMMAND(ID_TOOLS_SOUNDRECORDING, OnToolsSoundRecording)
 618.400 -ON_UPDATE_COMMAND_UI(ID_TOOLS_SOUNDRECORDING, OnUpdateToolsSoundRecording)
 618.401 -ON_COMMAND(ID_TOOLS_AVIRECORDING, OnToolsAVIRecording)
 618.402 -ON_UPDATE_COMMAND_UI(ID_TOOLS_AVIRECORDING, OnUpdateToolsAVIRecording)
 618.403 -ON_COMMAND(ID_TOOLS_PAUSEAVIRECORDING, OnToolsPauseAVIRecording)
 618.404 -ON_UPDATE_COMMAND_UI(ID_TOOLS_PAUSEAVIRECORDING, OnUpdateToolsPauseAVIRecording)
 618.405 -
 618.406 -ON_COMMAND(ID_MOVIE_RECORD, OnToolsRecordMovie)
 618.407 -ON_UPDATE_COMMAND_UI(ID_MOVIE_RECORD, OnUpdateToolsRecordMovie)
 618.408 -ON_COMMAND(ID_MOVIE_STOP, OnToolsStopMovie)
 618.409 -ON_UPDATE_COMMAND_UI(ID_MOVIE_STOP, OnUpdateToolsStopMovie)
 618.410 -ON_COMMAND(ID_MOVIE_PLAY, OnToolsPlayMovie)
 618.411 -ON_UPDATE_COMMAND_UI(ID_MOVIE_PLAY, OnUpdateToolsPlayMovie)
 618.412 -ON_COMMAND(ID_MOVIE_READONLY, OnToolsPlayReadOnly)
 618.413 -ON_UPDATE_COMMAND_UI(ID_MOVIE_READONLY, OnUpdateToolsPlayReadOnly)
 618.414 -ON_COMMAND(ID_MOVIE_ASSC_WITH_SAVESTATE, OnAsscWithSaveState)
 618.415 -ON_UPDATE_COMMAND_UI(ID_MOVIE_ASSC_WITH_SAVESTATE, OnUpdateAsscWithSaveState)
 618.416 -ON_COMMAND(ID_MOVIE_RESUME_RECORD, OnToolsResumeRecord)
 618.417 -ON_UPDATE_COMMAND_UI(ID_MOVIE_RESUME_RECORD, OnUpdateToolsResumeRecord)
 618.418 -ON_COMMAND(ID_MOVIE_RESTART_PLAY, OnToolsPlayRestart)
 618.419 -ON_UPDATE_COMMAND_UI(ID_MOVIE_RESTART_PLAY, OnUpdateToolsPlayRestart)
 618.420 -
 618.421 -ON_COMMAND(ID_MOVIE_END_PAUSE, OnToolsOnMovieEndPause)
 618.422 -ON_UPDATE_COMMAND_UI(ID_MOVIE_END_PAUSE, OnUpdateToolsOnMovieEndPause)
 618.423 -ON_COMMAND(ID_MOVIE_END_STOP, OnToolsOnMovieEndStop)
 618.424 -ON_UPDATE_COMMAND_UI(ID_MOVIE_END_STOP, OnUpdateToolsOnMovieEndStop)
 618.425 -ON_COMMAND(ID_MOVIE_END_RESTART, OnToolsOnMovieEndRestart)
 618.426 -ON_UPDATE_COMMAND_UI(ID_MOVIE_END_RESTART, OnUpdateToolsOnMovieEndRestart)
 618.427 -ON_COMMAND(ID_MOVIE_END_APPEND, OnToolsOnMovieEndAppend)
 618.428 -ON_UPDATE_COMMAND_UI(ID_MOVIE_END_APPEND, OnUpdateToolsOnMovieEndAppend)
 618.429 -ON_COMMAND(ID_MOVIE_END_KEEP, OnToolsOnMovieEndKeep)
 618.430 -ON_UPDATE_COMMAND_UI(ID_MOVIE_END_KEEP, OnUpdateToolsOnMovieEndKeep)
 618.431 -
 618.432 -ON_COMMAND(ID_MOVIE_TOOL_SET_PAUSE_AT, OnToolsMovieSetPauseAt)
 618.433 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_SET_PAUSE_AT, OnUpdateToolsSetMoviePauseAt)
 618.434 -ON_COMMAND(ID_MOVIE_TOOL_CONVERT, OnToolsMovieConvertCurrent)
 618.435 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_CONVERT, OnUpdateToolsMovieConvertCurrent)
 618.436 -ON_COMMAND(ID_MOVIE_TOOL_AUTO_CONVERT, OnToolsMovieAutoConvert)
 618.437 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_AUTO_CONVERT, OnUpdateToolsMovieAutoConvert)
 618.438 -ON_COMMAND(ID_MOVIE_TOOL_FIX_HEADER, OnToolsMovieFixHeader)
 618.439 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_FIX_HEADER, OnUpdateToolsMovieFixHeader)
 618.440 -ON_COMMAND(ID_MOVIE_TOOL_TRUNCATE, OnToolsMovieTruncateAtCurrent)
 618.441 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_TRUNCATE, OnUpdateToolsMovieTruncateAtCurrent)
 618.442 -ON_COMMAND(ID_MOVIE_TOOL_EXTRACT_FROM_SAVEGAME, OnToolsMovieExtractFromSavegame)
 618.443 -ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_EXTRACT_FROM_SAVEGAME, OnUpdateToolsMovieExtractFromSavegame)
 618.444 -
 618.445 -ON_COMMAND(ID_TOOLS_REWIND, OnToolsRewind)
 618.446 -ON_UPDATE_COMMAND_UI(ID_TOOLS_REWIND, OnUpdateToolsRewind)
 618.447 -ON_COMMAND(ID_TOOLS_CUSTOMIZE, OnToolsCustomize)
 618.448 -ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE, OnUpdateToolsCustomize)
 618.449 -// ON_COMMAND(ID_TOOLS_CUSTOMIZE_COMMON, OnToolsCustomizeCommon)
 618.450 -// ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE_COMMON, OnUpdateToolsCustomizeCommon)
 618.451 -ON_COMMAND(ID_HELP_BUGREPORT, OnHelpBugreport)
 618.452 -
 618.453 -ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnFileRecentFile)
 618.454 -ON_COMMAND_EX_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnFileLoadSlot)
 618.455 -ON_COMMAND_EX_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnFileSaveSlot)
 618.456 -ON_COMMAND_EX_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnSelectSlot)
 618.457 -ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnUpdateFileRecentFile)
 618.458 -ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnUpdateFileLoadSlot)
 618.459 -ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnUpdateFileSaveSlot)
 618.460 -ON_UPDATE_COMMAND_UI_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnUpdateSelectSlot)
 618.461 -
 618.462 -ON_COMMAND(ID_FILE_SAVEGAME_OLDESTSLOT, OnFileSavegameOldestslot)
 618.463 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_OLDESTSLOT, OnUpdateFileSavegameOldestslot)
 618.464 -ON_COMMAND(ID_FILE_LOADGAME_MOSTRECENT, OnFileLoadgameMostrecent)
 618.465 -ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MOSTRECENT, OnUpdateFileLoadgameMostrecent)
 618.466 -ON_COMMAND(ID_FILE_SAVEGAME_CURRENT, OnFileSavegameCurrent)
 618.467 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_CURRENT, OnUpdateFileSavegameCurrent)
 618.468 -ON_COMMAND(ID_FILE_LOADGAME_CURRENT, OnFileLoadgameCurrent)
 618.469 -ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_CURRENT, OnUpdateFileLoadgameCurrent)
 618.470 -ON_COMMAND(ID_FILE_LOADGAME_MAKECURRENT, OnFileLoadgameMakeCurrent)
 618.471 -ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKECURRENT, OnUpdateFileLoadgameMakeCurrent)
 618.472 -ON_COMMAND(ID_FILE_SAVEGAME_MAKECURRENT, OnFileSavegameMakeCurrent)
 618.473 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_MAKECURRENT, OnUpdateFileSavegameMakeCurrent)
 618.474 -
 618.475 -ON_COMMAND(ID_FILE_SAVEGAME_INCREMENTSLOT, OnFileSavegameIncrementSlot)
 618.476 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_INCREMENTSLOT, OnUpdateFileSavegameIncrementSlot)
 618.477 -ON_COMMAND(ID_FILE_SAVEGAME_DECREMENTSLOT, OnFileSavegameDecrementSlot)
 618.478 -ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_DECREMENTSLOT, OnUpdateFileSavegameDecrementSlot)
 618.479 -ON_COMMAND(ID_FILE_SLOT_DISPLAYMODIFICATIONTIME, OnFileSlotDisplayModificationTime)
 618.480 -ON_UPDATE_COMMAND_UI(ID_FILE_SLOT_DISPLAYMODIFICATIONTIME, OnUpdateFileSlotDisplayModificationTime)
 618.481 -
 618.482 -ON_COMMAND(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnFileLoadgameAutoloadmostrecent)
 618.483 -ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnUpdateFileLoadgameAutoloadmostrecent)
 618.484 -ON_COMMAND(ID_FILE_LOADGAME_MAKERECENT, OnFileLoadgameMakeRecent)
 618.485 -ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKERECENT, OnUpdateFileLoadgameMakeRecent)
 618.486 -
 618.487 -ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_25X, OnOptionsSoundVolume25x)
 618.488 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_25X, OnUpdateOptionsSoundVolume25x)
 618.489 -ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_5X, OnOptionsSoundVolume5x)
 618.490 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_5X, OnUpdateOptionsSoundVolume5x)
 618.491 -ON_COMMAND(ID_CHEATS_DISABLECHEATS, OnCheatsDisablecheats)
 618.492 -ON_UPDATE_COMMAND_UI(ID_CHEATS_DISABLECHEATS, OnUpdateCheatsDisablecheats)
 618.493 -ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE, OnOptionsVideoFullscreenmaxscale)
 618.494 -
 618.495 -ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_FRAMESKIP_0, ID_OPTIONS_VIDEO_FRAMESKIP_9, OnOptionsFrameskip)
 618.496 -ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_X1, ID_OPTIONS_VIDEO_X4, OnOptionVideoSize)
 618.497 -ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnVideoLayer)
 618.498 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnUpdateVideoLayer)
 618.499 -ON_COMMAND(ID_SYSTEM_MINIMIZE, OnSystemMinimize)
 618.500 -ON_COMMAND(ID_SYSTEM_MAXIMIZE, OnSystemMaximize)
 618.501 -ON_COMMAND_EX_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE, ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT, OnOptionsEmulatorShowSpeed)
 618.502 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE,
 618.503 -                           ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT,
 618.504 -                           OnUpdateOptionsEmulatorShowSpeed)
 618.505 -ON_COMMAND_EX_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnOptionsSoundVolume)
 618.506 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnUpdateOptionsSoundVolume)
 618.507 -ON_COMMAND_EX_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnOptionsPriority)
 618.508 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnUpdateOptionsPriority)
 618.509 -
 618.510 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnOptionsFilter)
 618.511 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnOptionsFilter)
 618.512 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnOptionsFilter)
 618.513 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnOptionsFilter)
 618.514 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnOptionsFilter)
 618.515 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnOptionsFilter)
 618.516 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_SIMPLE3X, ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X, OnOptionsFilter)
 618.517 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnUpdateOptionsFilter)
 618.518 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnUpdateOptionsFilter)
 618.519 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnUpdateOptionsFilter)
 618.520 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnUpdateOptionsFilter)
 618.521 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnUpdateOptionsFilter)
 618.522 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnUpdateOptionsFilter)
 618.523 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_SIMPLE3X, ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X, OnUpdateOptionsFilter)
 618.524 -ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE, ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART, OnOptionsFilterIFB)
 618.525 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE,
 618.526 -                           ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART,
 618.527 -                           OnUpdateOptionsFilterIFB)
 618.528 -
 618.529 -ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnOptionsJoypadDefault)
 618.530 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnUpdateOptionsJoypadDefault)
 618.531 -ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnOptionsJoypadAutofire)
 618.532 -ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnUpdateOptionsJoypadAutofire)
 618.533 -ON_COMMAND_EX_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnOptionsJoypadSticky)
 618.534 -ON_UPDATE_COMMAND_UI_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnUpdateOptionsJoypadSticky)
 618.535 -ON_MESSAGE(VBA_CONFIRM_MODE, OnConfirmMode)
 618.536 -ON_MESSAGE(WM_SYSCOMMAND, OnMySysCommand)
 618.537 -ON_COMMAND(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnOptionsVideoTextdisplayoptions)
 618.538 -ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnUpdateOptionsVideoTextdisplayoptions)
 618.539 -
 618.540 -ON_COMMAND(ID_FILE_LUA_OPEN, OnFileLuaOpen)
 618.541 -ON_UPDATE_COMMAND_UI(ID_FILE_LUA_OPEN, OnUpdateFileLuaOpen)
 618.542 -ON_COMMAND(ID_FILE_LUA_CLOSE_ALL, OnFileLuaCloseAll)
 618.543 -ON_UPDATE_COMMAND_UI(ID_FILE_LUA_CLOSE_ALL, OnUpdateFileLuaCloseAll)
 618.544 -ON_COMMAND(ID_FILE_LUA_RELOAD, OnFileLuaReload)
 618.545 -ON_COMMAND(ID_FILE_LUA_STOP, OnFileLuaStop)
 618.546 -ON_COMMAND(ID_RAM_SEARCH, OnFileRamSearch)
 618.547 -ON_UPDATE_COMMAND_UI(ID_RAM_SEARCH, OnUpdateFileRamSearch)
 618.548 -ON_COMMAND(ID_RAM_WATCH, OnFileRamWatch)
 618.549 -ON_UPDATE_COMMAND_UI(ID_RAM_WATCH, OnUpdateFileRamWatch)
 618.550 -//}}AFX_MSG_MAP
 618.551 -END_MESSAGE_MAP()
 618.552 -
 618.553 -/////////////////////////////////////////////////////////////////////////////
 618.554 -// MainWnd message handlers
 618.555 -
 618.556 -bool vbaShuttingDown = false;
 618.557 -
 618.558 -void MainWnd::OnClose()
 618.559 -{
 618.560 -	vbaShuttingDown = true; // HACK to fix crash on exit while memory viewer is open
 618.561 -
 618.562 -	CWnd::OnClose();
 618.563 -
 618.564 -	delete this;
 618.565 -}
 618.566 -
 618.567 -void MainWnd::OnMove(int x, int y)
 618.568 -{
 618.569 -	CWnd::OnMove(x, y);
 618.570 -
 618.571 -	if (!theApp.changingVideoSize)
 618.572 -	{
 618.573 -		if (this)
 618.574 -		{
 618.575 -			if (!IsIconic() && !IsZoomed())
 618.576 -			{
 618.577 -				RECT r;
 618.578 -
 618.579 -				GetWindowRect(&r);
 618.580 -				theApp.windowPositionX = r.left;
 618.581 -				theApp.windowPositionY = r.top;
 618.582 -				theApp.adjustDestRect();
 618.583 -				regSetDwordValue("windowX", theApp.windowPositionX);
 618.584 -				regSetDwordValue("windowY", theApp.windowPositionY);
 618.585 -			}
 618.586 -		}
 618.587 -	}
 618.588 -}
 618.589 -
 618.590 -void MainWnd::OnSize(UINT nType, int cx, int cy)
 618.591 -{
 618.592 -	CWnd::OnSize(nType, cx, cy);
 618.593 -
 618.594 -	static int lastType = -1;
 618.595 -
 618.596 -	// FIXME: hack to re-maximize window after it auto-unmaximizes while loading a ROM
 618.597 -	if (nType == SIZE_MAXIMIZED && lastType == SIZE_MAXIMIZED)
 618.598 -	{
 618.599 -		lastType = -1;
 618.600 -		ShowWindow(SW_SHOWMAXIMIZED);
 618.601 -		MoveWindow(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
 618.602 -		return;
 618.603 -	}
 618.604 -
 618.605 -	lastType = nType;
 618.606 -
 618.607 -	if (IsIconic())
 618.608 -	{
 618.609 -		theApp.iconic = true;
 618.610 -		return;
 618.611 -	}
 618.612 -	else if (theApp.iconic)
 618.613 -	{
 618.614 -		theApp.iconic = false;
 618.615 -	}
 618.616 -
 618.617 -	if (!theApp.changingVideoSize)
 618.618 -	{
 618.619 -		if (this)
 618.620 -		{
 618.621 -			if (theApp.videoOption <= VIDEO_4X)
 618.622 -			{
 618.623 -				theApp.surfaceSizeX = cx;
 618.624 -				theApp.surfaceSizeY = cy;
 618.625 -				theApp.adjustDestRect();
 618.626 -				if (theApp.display)
 618.627 -					theApp.display->resize(theApp.dest.right - theApp.dest.left, theApp.dest.bottom - theApp.dest.top);
 618.628 -				systemRefreshScreen();  // useful when shrinking
 618.629 -			}
 618.630 -		}
 618.631 -	}
 618.632 -}
 618.633 -
 618.634 -void MainWnd::OnContextMenu(CWnd *pWnd, CPoint point)
 618.635 -{
 618.636 -	winMouseOn();
 618.637 -}
 618.638 -
 618.639 -void MainWnd::OnSystemMinimize()
 618.640 -{
 618.641 -	ShowWindow(SW_SHOWMINIMIZED);
 618.642 -}
 618.643 -
 618.644 -void MainWnd::OnSystemMaximize()
 618.645 -{
 618.646 -	ShowWindow(SW_SHOWMAXIMIZED);
 618.647 -}
 618.648 -
 618.649 -void MainWnd::OnPaint()
 618.650 -{
 618.651 -	CPaintDC dc(this); // device context for painting, calling BeginPaint/EndPaint internally
 618.652 -	if (emulating && (!theApp.active || theApp.paused))
 618.653 -	{
 618.654 -		systemRedrawScreen();
 618.655 -	}
 618.656 -}
 618.657 -
 618.658 -static bool translatingAccelerator = false;
 618.659 -
 618.660 -// FIXME: this fix for accel keys is ugly
 618.661 -//   using too many static variables for a single accel key kludge
 618.662 -static bool	  recursiveCall	  = true;
 618.663 -static bool	  fullUpdated	  = false;
 618.664 -static bool	  lastKeyModifier = false;  // maybe better check current key press status instead
 618.665 -static WPARAM lastKey		  = 0;
 618.666 -
 618.667 -BOOL MainWnd::PreTranslateMessage(MSG *pMsg)
 618.668 -{
 618.669 -	if (RamSearchHWnd && ::IsDialogMessage(RamSearchHWnd, pMsg))
 618.670 -	{
 618.671 -		return TRUE;
 618.672 -	}
 618.673 -	else if (RamWatchHWnd && ::IsDialogMessage(RamWatchHWnd, pMsg))
 618.674 -	{
 618.675 -		if (RamWatchAccels)
 618.676 -			TranslateAccelerator(RamWatchHWnd, RamWatchAccels, pMsg);
 618.677 -		return TRUE;
 618.678 -	}
 618.679 -	else if (LuaConsoleHWnd && ::IsDialogMessage(LuaConsoleHWnd, pMsg))
 618.680 -	{
 618.681 -		return TRUE;
 618.682 -	}
 618.683 -	else if (CWnd::PreTranslateMessage(pMsg))
 618.684 -	{
 618.685 -		return TRUE;
 618.686 -	}
 618.687 -	else if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
 618.688 -	{
 618.689 -		translatingAccelerator = true;
 618.690 -
 618.691 -		bool bHit		= theApp.hAccel != NULL &&  ::TranslateAccelerator(m_hWnd, theApp.hAccel, pMsg);
 618.692 -		bool isModifier = pMsg->wParam == VK_SHIFT || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_MENU;
 618.693 -
 618.694 -		// HACK to get around the fact that TranslateAccelerator can't handle modifier-only accelerators
 618.695 -		// (it would be better to fix TranslateAccelerator, but its code is in a Microsoft library...)
 618.696 -		if (!bHit)
 618.697 -		{
 618.698 -			if (isModifier)
 618.699 -			{
 618.700 -				// do a linear loop through all accelerators to find modifier-only ones...
 618.701 -				CCmdAccelOb *pCmdAccel;
 618.702 -				WORD		 wKey;
 618.703 -				CAccelsOb *	 pAccelOb;
 618.704 -				POSITION	 pos	   = theApp.winAccelMgr.m_mapAccelTable.GetStartPosition();
 618.705 -				const int	 modifiers = ((pMsg->wParam == VK_SHIFT) ? FSHIFT : ((pMsg->wParam == VK_CONTROL) ? FCONTROL : FALT));
 618.706 -				while (pos != NULL)
 618.707 -				{
 618.708 -					theApp.winAccelMgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
 618.709 -					POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
 618.710 -					while (pos != NULL)
 618.711 -					{
 618.712 -						pAccelOb = pCmdAccel->m_Accels.GetNext(pos);
 618.713 -
 618.714 -						if (pAccelOb->m_wKey == 0) // if accelerator-only
 618.715 -						{
 618.716 -							if ((pAccelOb->m_cVirt & modifiers) == modifiers) // if modifier matches
 618.717 -							{
 618.718 -								bHit = true;
 618.719 -								SendMessage(WM_COMMAND, pCmdAccel->m_wIDCommand, 0); // tell Windows to call the right function
 618.720 -							}
 618.721 -						}
 618.722 -					}
 618.723 -				}
 618.724 -			}
 618.725 -
 618.726 -			if (!bHit)
 618.727 -			{
 618.728 -				lastKeyModifier = true;
 618.729 -			}
 618.730 -		}
 618.731 -
 618.732 -		if (bHit)
 618.733 -		{
 618.734 -			if (lastKeyModifier && !isModifier)
 618.735 -			{
 618.736 -				fullUpdated		= false;
 618.737 -				lastKeyModifier = false;
 618.738 -			}
 618.739 -
 618.740 -			if (lastKey != pMsg->wParam)
 618.741 -			{
 618.742 -				fullUpdated = false;
 618.743 -				lastKey		= pMsg->wParam;
 618.744 -			}
 618.745 -		}
 618.746 -
 618.747 -		translatingAccelerator = false;
 618.748 -		return bHit ? TRUE : FALSE;
 618.749 -	}
 618.750 -
 618.751 -	return FALSE;
 618.752 -}
 618.753 -
 618.754 -void MainWnd::OnMouseMove(UINT nFlags, CPoint point)
 618.755 -{
 618.756 -	winMouseOn();
 618.757 -
 618.758 -	CWnd::OnMouseMove(nFlags, point);
 618.759 -}
 618.760 -
 618.761 -// recursive kludge
 618.762 -static void InitMenuKludge(CMenu *pParentMenu, CMenu *pMenu, CCmdTarget *pWnd)
 618.763 -{
 618.764 -	ASSERT(pMenu != NULL);
 618.765 -
 618.766 -	CCmdUI state;
 618.767 -	state.m_pParentMenu = pParentMenu;
 618.768 -	state.m_pMenu		= pMenu;
 618.769 -	ASSERT(state.m_pOther == NULL);
 618.770 -
 618.771 -	state.m_nIndexMax = pMenu->GetMenuItemCount();
 618.772 -	for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
 618.773 -	     state.m_nIndex++)
 618.774 -	{
 618.775 -		state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
 618.776 -		if (state.m_nID == 0)
 618.777 -			continue;  // menu separator or invalid cmd - ignore it
 618.778 -
 618.779 -		ASSERT(state.m_pOther == NULL);
 618.780 -		ASSERT(state.m_pMenu != NULL);
 618.781 -		if (state.m_nID == (UINT)-1)
 618.782 -		{
 618.783 -			// possibly a popup menu, route to first item of that popup
 618.784 -			state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
 618.785 -			if (state.m_pSubMenu == NULL)
 618.786 -			{
 618.787 -				continue; // first item of popup can't be routed to
 618.788 -			}
 618.789 -
 618.790 -			state.DoUpdate(pWnd, false);
 618.791 -			if (recursiveCall)
 618.792 -			{
 618.793 -				// FIXME: slow recursive calls to fix enabling/disabling of accel keys
 618.794 -				InitMenuKludge(state.m_pMenu, state.m_pSubMenu, pWnd);
 618.795 -			}
 618.796 -		}
 618.797 -		else
 618.798 -		{
 618.799 -			// normal menu item
 618.800 -			// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
 618.801 -			//    set and command is _not_ a system command.
 618.802 -			state.m_pSubMenu = NULL;
 618.803 -			state.DoUpdate(pWnd, state.m_nID < 0xF000);
 618.804 -		}
 618.805 -
 618.806 -		// adjust for menu deletions and additions
 618.807 -		UINT nCount = pMenu->GetMenuItemCount();
 618.808 -		if (nCount < state.m_nIndexMax)
 618.809 -		{
 618.810 -			state.m_nIndex -= (state.m_nIndexMax - nCount);
 618.811 -			while (state.m_nIndex < nCount &&
 618.812 -			       pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
 618.813 -			{
 618.814 -				state.m_nIndex++;
 618.815 -			}
 618.816 -		}
 618.817 -		state.m_nIndexMax = nCount;
 618.818 -	}
 618.819 -}
 618.820 -
 618.821 -void MainWnd::OnInitMenuPopup(CMenu *pMenu, UINT nIndex, BOOL bSysMenu)
 618.822 -{
 618.823 -	ASSERT(pMenu != NULL);
 618.824 -
 618.825 -	CCmdUI state;
 618.826 -	state.m_pMenu = pMenu;
 618.827 -	ASSERT(state.m_pOther == NULL);
 618.828 -	ASSERT(state.m_pParentMenu == NULL);
 618.829 -
 618.830 -	// determine if menu is popup in top-level menu and set m_pOther to
 618.831 -	//  it if so (m_pParentMenu == NULL indicates that it is secondary popup)
 618.832 -	HMENU hParentMenu;
 618.833 -	if (AfxGetThreadState()->m_hTrackingMenu == pMenu->m_hMenu)
 618.834 -		state.m_pParentMenu = pMenu;  // parent == child for tracking popup
 618.835 -	else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
 618.836 -	{
 618.837 -		CWnd *pParent = GetTopLevelParent();
 618.838 -		// children windows don't have menus -- need to go to the top!
 618.839 -		if (pParent != NULL &&
 618.840 -		    (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
 618.841 -		{
 618.842 -			int nIndexMax = ::GetMenuItemCount(hParentMenu);
 618.843 -			for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
 618.844 -			{
 618.845 -				if (::GetSubMenu(hParentMenu, nIndex) == pMenu->m_hMenu)
 618.846 -				{
 618.847 -					// when popup is found, m_pParentMenu is containing menu
 618.848 -					state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
 618.849 -					break;
 618.850 -				}
 618.851 -			}
 618.852 -		}
 618.853 -	}
 618.854 -
 618.855 -	// FIXME: magic to workaround the accel key bug without slowing down too much
 618.856 -	if (translatingAccelerator && !fullUpdated && state.m_pParentMenu == &theApp.m_menu)
 618.857 -	{
 618.858 -		state.m_pMenu = state.m_pParentMenu;
 618.859 -		recursiveCall = true;
 618.860 -		fullUpdated	  = true;
 618.861 -	}
 618.862 -	else if (!translatingAccelerator && fullUpdated)
 618.863 -	{
 618.864 -		fullUpdated = false;
 618.865 -	}
 618.866 -
 618.867 -	InitMenuKludge(state.m_pParentMenu, state.m_pMenu, this);
 618.868 -
 618.869 -	recursiveCall = false;
 618.870 -}
 618.871 -
 618.872 -void MainWnd::OnInitMenu(CMenu *pMenu)
 618.873 -{
 618.874 -//	CWnd::OnInitMenu(pMenu);
 618.875 -
 618.876 -	if (translatingAccelerator)
 618.877 -	{}
 618.878 -	else
 618.879 -	{
 618.880 -		// HACK: we only want to call this if the user is pulling down the menu,
 618.881 -		// but TranslateAccelerator also causes OnInitMenu to be called, so ignore that
 618.882 -
 618.883 -		systemSoundPause();
 618.884 -	}
 618.885 -}
 618.886 -
 618.887 -void MainWnd::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
 618.888 -{
 618.889 -	CWnd::OnActivate(nState, pWndOther, bMinimized);
 618.890 -
 618.891 -	bool activated = (nState == WA_ACTIVE || nState == WA_CLICKACTIVE) && !bMinimized;
 618.892 -
 618.893 -	theApp.active = activated || !theApp.pauseWhenInactive;
 618.894 -
 618.895 -	extern bool inputActive;
 618.896 -	inputActive = activated || (!theApp.pauseWhenInactive && theApp.enableBackgroundInput);
 618.897 -
 618.898 -	if (theApp.active)
 618.899 -	{
 618.900 -		if (theApp.input)
 618.901 -		{
 618.902 -			theApp.input->activate();
 618.903 -		}
 618.904 -
 618.905 -		if (!theApp.paused && emulating)
 618.906 -		{
 618.907 -			systemSoundResume();
 618.908 -		}
 618.909 -	}
 618.910 -	else
 618.911 -	{
 618.912 -		theApp.wasPaused = true;
 618.913 -
 618.914 -		if (!theApp.paused && emulating)
 618.915 -		{
 618.916 -			systemSoundPause();
 618.917 -		}
 618.918 -
 618.919 -		memset(theApp.delta, 255, sizeof(theApp.delta));
 618.920 -	}
 618.921 -
 618.922 -	if (theApp.muteWhenInactive)
 618.923 -	{
 618.924 -		theApp.winMuteForNow = !activated;
 618.925 -	}
 618.926 -
 618.927 -	if (theApp.paused && emulating)
 618.928 -	{
 618.929 -		systemRefreshScreen();
 618.930 -	}
 618.931 -}
 618.932 -
 618.933 -#if _MSC_VER <= 1200
 618.934 -void MainWnd::OnActivateApp(BOOL bActive, HTASK hTask)
 618.935 -#else
 618.936 -void MainWnd::OnActivateApp(BOOL bActive, DWORD hTask)
 618.937 -#endif
 618.938 -{
 618.939 -	CWnd::OnActivateApp(bActive, hTask);
 618.940 -
 618.941 -	if (theApp.tripleBuffering && theApp.videoOption > VIDEO_4X)
 618.942 -	{
 618.943 -		if (bActive)
 618.944 -		{
 618.945 -			if (theApp.display)
 618.946 -				theApp.display->clear();
 618.947 -		}
 618.948 -	}
 618.949 -}
 618.950 -
 618.951 -LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
 618.952 -{
 618.953 -	if (emulating && !theApp.paused)
 618.954 -	{
 618.955 -		if ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER)
 618.956 -			return 0;
 618.957 -	}
 618.958 -	return Default();
 618.959 -}
 618.960 -
 618.961 -void MainWnd::OnDropFiles(HDROP hDropInfo)
 618.962 -{
 618.963 -	// FIXME: required for the accel key fix
 618.964 -	fullUpdated = false;
 618.965 -
 618.966 -	systemSoundClearBuffer();
 618.967 -
 618.968 -	char szFile[1024];
 618.969 -	char ext[1024];
 618.970 -
 618.971 -	if (DragQueryFile(hDropInfo, 0, szFile, 1024))
 618.972 -	{
 618.973 -		DragFinish(hDropInfo);
 618.974 -
 618.975 -		_splitpath(szFile, NULL, NULL, NULL, ext);
 618.976 -		if (strcasecmp(ext, ".lua") == 0)
 618.977 -		{
 618.978 -			if (VBALoadLuaCode(szFile))
 618.979 -			{
 618.980 -				// success, there is nothing to do
 618.981 -			}
 618.982 -			else
 618.983 -			{
 618.984 -				// Errors are displayed by the Lua code.
 618.985 -			}
 618.986 -		}
 618.987 -		else if (strcasecmp(ext, ".vbm") == 0)
 618.988 -		{
 618.989 -			SMovie movieInfo;
 618.990 -			char * movieName = szFile;
 618.991 -			char   romTitle [12];
 618.992 -			uint32 romGameCode;
 618.993 -			uint16 checksum;
 618.994 -			uint8  crc;
 618.995 -
 618.996 -			if (VBAMovieGetInfo(movieName, &movieInfo) != MOVIE_SUCCESS)
 618.997 -			{
 618.998 -				return;
 618.999 -			}
618.1000 -
618.1001 -			int cartType = movieInfo.header.typeFlags & 1 ? 0 : 1;
618.1002 -
618.1003 -			if (!emulating)
618.1004 -			{
618.1005 -				theApp.winCheckFullscreen();
618.1006 -				if (winFileOpenSelect(cartType))
618.1007 -				{
618.1008 -					if (VBAMovieActive())
618.1009 -						VBAMovieStop(false);  // will only get here on user selecting to play a ROM, canceling movie
618.1010 -					if (!winFileRun())
618.1011 -						return;
618.1012 -				}
618.1013 -				else
618.1014 -					return;
618.1015 -			}
618.1016 -			VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
618.1017 -
618.1018 -			while (movieInfo.header.romCRC != crc
618.1019 -			       || strncmp(movieInfo.header.romTitle, romTitle, 12) != 0
618.1020 -			       || movieInfo.header.romOrBiosChecksum != checksum
618.1021 -			       && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) == 0 && checksum == 0))
618.1022 -			{
618.1023 -				char msg[1024], warning1[1024], warning2[1024], buffer[1024];
618.1024 -
618.1025 -				strcpy(warning1, "");
618.1026 -				strcpy(warning2, "");
618.1027 -				{
618.1028 -					char str [13];
618.1029 -					strncpy(str, movieInfo.header.romTitle, 12);
618.1030 -					str[12] = '\0';
618.1031 -					sprintf(buffer, "title=%s  ", str);
618.1032 -					strcat(warning1, buffer);
618.1033 -
618.1034 -					strncpy(str, romTitle, 12);
618.1035 -					str[12] = '\0';
618.1036 -					sprintf(buffer, "title=%s  ", str);
618.1037 -					strcat(warning2, buffer);
618.1038 -				}
618.1039 -				{
618.1040 -					sprintf(buffer, "type=%s  ",
618.1041 -					        (movieInfo.header.typeFlags & MOVIE_TYPE_GBA) ?
618.1042 -					        "GBA" : (movieInfo.header.typeFlags & MOVIE_TYPE_GBC) ?
618.1043 -					        "GBC" : (movieInfo.header.typeFlags & MOVIE_TYPE_SGB) ? "SGB" : "GB");
618.1044 -					strcat(warning1, buffer);
618.1045 -
618.1046 -					sprintf(buffer, "type=%s  ", systemCartridgeType ==
618.1047 -					        0 ? "GBA" : (gbRom[0x143] & 0x80 ? "GBC" : (gbRom[0x146] == 0x03 ? "SGB" : "GB")));
618.1048 -					strcat(warning2, buffer);
618.1049 -				}
618.1050 -				{
618.1051 -					sprintf(buffer, "crc=%02x  ", movieInfo.header.romCRC);
618.1052 -					strcat(warning1, buffer);
618.1053 -
618.1054 -					sprintf(buffer, "crc=%02x  ", crc);
618.1055 -					strcat(warning2, buffer);
618.1056 -				}
618.1057 -				{
618.1058 -					char code [5];
618.1059 -					if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
618.1060 -					{
618.1061 -						memcpy(code, &movieInfo.header.romGameCode, 4);
618.1062 -						code[4] = '\0';
618.1063 -						sprintf(buffer, "code=%s  ", code);
618.1064 -						strcat(warning1, buffer);
618.1065 -					}
618.1066 -
618.1067 -					if (systemCartridgeType == 0)
618.1068 -					{
618.1069 -						memcpy(code, &romGameCode, 4);
618.1070 -						code[4] = '\0';
618.1071 -						sprintf(buffer, "code=%s  ", code);
618.1072 -						strcat(warning2, buffer);
618.1073 -					}
618.1074 -				}
618.1075 -				{
618.1076 -					sprintf(buffer,
618.1077 -					        movieInfo.header.typeFlags &
618.1078 -					        MOVIE_TYPE_GBA ? ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) ==
618.1079 -					                          0 ? "(bios=none)  " : "(bios=%04x)  ") : "check=%04x  ",
618.1080 -					        movieInfo.header.romOrBiosChecksum);
618.1081 -					strcat(warning1, buffer);
618.1082 -
618.1083 -					sprintf(buffer,
618.1084 -					        checksum == 0 ? "(bios=none)  " : systemCartridgeType == 0 ? "(bios=%04x)  " : "check=%04x  ",
618.1085 -					        checksum);
618.1086 -					strcat(warning2, buffer);
618.1087 -				}
618.1088 -
618.1089 -				strcpy(msg, "");
618.1090 -				sprintf(buffer, "Movie ROM: %s\n", warning1);
618.1091 -				strcat(msg, buffer);
618.1092 -				sprintf(buffer, "Your ROM: %s\n", warning2);
618.1093 -				strcat(msg, buffer);
618.1094 -				strcat(msg, "still want to play the movie?");
618.1095 -
618.1096 -				int sel = MessageBox(msg, TEXT("ROM Mismatch"), MB_ABORTRETRYIGNORE | MB_ICONQUESTION);
618.1097 -				switch (sel)
618.1098 -				{
618.1099 -				case IDABORT:
618.1100 -					return;
618.1101 -				case IDRETRY:
618.1102 -					theApp.winCheckFullscreen();
618.1103 -					if (winFileOpenSelect(cartType))
618.1104 -					{
618.1105 -						if (VBAMovieActive())
618.1106 -							VBAMovieStop(false);  // will only get here on user selecting to play a ROM, canceling movie
618.1107 -						if (!winFileRun())
618.1108 -							return;
618.1109 -						VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
618.1110 -					}
618.1111 -					else
618.1112 -						return;
618.1113 -					break;
618.1114 -				default:
618.1115 -					goto romcheck_exit;
618.1116 -				}
618.1117 -			}
618.1118 -romcheck_exit:
618.1119 -
618.1120 -			bool useBIOSFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
618.1121 -			if (useBIOSFile)
618.1122 -			{
618.1123 -				extern bool systemLoadBIOS(const char *biosFileName, bool useBiosFile);
618.1124 -				if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
618.1125 -				{
618.1126 -					systemMessage(0, "This movie requires a valid GBA BIOS file to play.\nPlease locate a BIOS file.");
618.1127 -					((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
618.1128 -					if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
618.1129 -					{
618.1130 -						systemMessage(0, "\"%s\" is not a valid BIOS file; cannot play movie without one.", theApp.biosFileName);
618.1131 -						return;
618.1132 -					}
618.1133 -				}
618.1134 -			}
618.1135 -
618.1136 -			int code = VBAMovieOpen(movieName, TRUE);
618.1137 -
618.1138 -			if (code != MOVIE_SUCCESS)
618.1139 -			{
618.1140 -				if (code == MOVIE_FILE_NOT_FOUND)
618.1141 -					systemMessage(0, "Could not find movie file \"%s\".", (const char *)movieName);
618.1142 -				else if (code == MOVIE_WRONG_FORMAT)
618.1143 -					systemMessage(0, "Movie file \"%s\" is not in proper VBM format.", (const char *)movieName);
618.1144 -				else if (code == MOVIE_WRONG_VERSION)
618.1145 -					systemMessage(0, "Movie file \"%s\" is not a supported version.", (const char *)movieName);
618.1146 -				else
618.1147 -					systemMessage(0, "Failed to open movie \"%s\".", (const char *)movieName);
618.1148 -				return;
618.1149 -			}
618.1150 -		}
618.1151 -		else if (strcasecmp(ext, ".wch") == 0)
618.1152 -		{
618.1153 -			if (emulating)
618.1154 -			{
618.1155 -				MainWnd::OnFileRamWatch();
618.1156 -				Load_Watches(true, szFile);
618.1157 -			}
618.1158 -		}
618.1159 -		else
618.1160 -		{
618.1161 -			theApp.romFilename = szFile;
618.1162 -			if (winFileRun())
618.1163 -			{
618.1164 -				SetForegroundWindow();
618.1165 -			}
618.1166 -		}
618.1167 -	}
618.1168 -	else
618.1169 -		DragFinish(hDropInfo);
618.1170 -}
618.1171 -
618.1172 -/////////////////////
618.1173 -
618.1174 -void MainWnd::winMouseOn()
618.1175 -{
618.1176 -	SetCursor(arrow);
618.1177 -	if (theApp.videoOption > VIDEO_4X)
618.1178 -	{
618.1179 -		theApp.mouseCounter = 120;
618.1180 -	}
618.1181 -	else
618.1182 -		theApp.mouseCounter = 0;
618.1183 -}
618.1184 -
618.1185 -void MainWnd::winConfirmMode()
618.1186 -{
618.1187 -	if (theApp.renderMethod == DIRECT_DRAW && theApp.videoOption > VIDEO_4X)
618.1188 -	{
618.1189 -		theApp.winCheckFullscreen();
618.1190 -		ModeConfirm dlg(this);
618.1191 -
618.1192 -		if (!dlg.DoModal())
618.1193 -		{
618.1194 -			theApp.updateVideoSize(ID_OPTIONS_VIDEO_X2);
618.1195 -		}
618.1196 -	}
618.1197 -}
618.1198 -
618.1199 -bool MainWnd::winFileOpenSelect(int cartridgeType)
618.1200 -{
618.1201 -	int selectedFilter = regQueryDwordValue("selectedFilter", 0);
618.1202 -	if (selectedFilter < 0 || selectedFilter > 2)
618.1203 -		selectedFilter = 0;
618.1204 -
618.1205 -	LPCTSTR exts[] = { NULL };
618.1206 -	CString filter = winResLoadFilter(IDS_FILTER_ROM);
618.1207 -	CString title  = winResLoadString(IDS_SELECT_ROM);
618.1208 -
618.1209 -	bool	isOverrideEmpty = false;
618.1210 -	CString initialDir		= regQueryStringValue(cartridgeType == 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, NULL);
618.1211 -	if (initialDir.IsEmpty())
618.1212 -	{
618.1213 -		isOverrideEmpty = true;
618.1214 -		CString altDir = regQueryStringValue(cartridgeType != 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, NULL);
618.1215 -		initialDir = altDir.IsEmpty() ? theApp.exeDir : altDir;
618.1216 -	}
618.1217 -
618.1218 -	FileDlg dlg(this, "", filter, selectedFilter, "ROM", exts, initialDir, title, false, true);
618.1219 -
618.1220 -	if (dlg.DoModal() == IDOK)
618.1221 -	{
618.1222 -		regSetDwordValue("selectedFilter", dlg.m_ofn.nFilterIndex);
618.1223 -		theApp.romFilename = dlg.GetPathName();
618.1224 -		initialDir		   = winGetDirFromFilename(theApp.romFilename);
618.1225 -
618.1226 -		// we have directory override for that purpose
618.1227 -		// but this can be...desirable
618.1228 -		if (isOverrideEmpty)
618.1229 -			regSetStringValue(cartridgeType == 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, initialDir);
618.1230 -		return true;
618.1231 -	}
618.1232 -	return false;
618.1233 -}
618.1234 -
618.1235 -// some extensions that might commonly be near emulation-related files that we almost certainly can't open, or at least not
618.1236 -// directly.
618.1237 -// also includes definitely non-ROM extensions we know about, since we only use this variable in a ROM opening function.
618.1238 -// we do this by exclusion instead of inclusion because we don't want to exclude extensions used for any archive files, even
618.1239 -// extensionless or unusually-named archives.
618.1240 -static const char *s_romIgnoreExtensions[] = {
618.1241 -	"vbm", "sgm",  "clt",  "dat",	"gbs",	"gcf",	"spc", "xpc", "pal", "act", "dmp", "avi", "ini", "txt", "nfo",
618.1242 -	"htm", "html", "jpg",  "jpeg",	"png",	"bmp",	"gif", "mp3", "wav", "lnk", "exe", "bat", "sav", "luasav"
618.1243 -};
618.1244 -
618.1245 -#include "GBACheatsDlg.h"
618.1246 -#include "GBCheatsDlg.h"
618.1247 -
618.1248 -#include "../common/CheatSearch.h"
618.1249 -#include "../gba/GBA.h"
618.1250 -#include "../gb/GB.h"
618.1251 -#include "../gba/Flash.h"
618.1252 -#include "../gba/RTC.h"
618.1253 -
618.1254 -void MainWnd::winFileClose(bool reopening)
618.1255 -{
618.1256 -	if (rom != NULL || gbRom != NULL)
618.1257 -	{
618.1258 -		if (theApp.autoSaveLoadCheatList)
618.1259 -			winSaveCheatListDefault();
618.1260 -
618.1261 -		if (!reopening)
618.1262 -		{
618.1263 -			// save battery file before we change the filename...
618.1264 -			winWriteBatteryFile();
618.1265 -			cheatSearchCleanup(&cheatSearchData);
618.1266 -			capturePrevious = 0;
618.1267 -			captureNumber	= 0;
618.1268 -		}
618.1269 -
618.1270 -		theApp.emulator.emuCleanUp();
618.1271 -
618.1272 -		extern void remoteCleanUp();
618.1273 -		remoteCleanUp();
618.1274 -	}
618.1275 -
618.1276 -	if (VBAMovieActive())
618.1277 -		VBAMovieStop(false);  // will only get here on user selecting to open a ROM, canceling movie
618.1278 -
618.1279 -	theApp.frameSearching	   = false;
618.1280 -	theApp.frameSearchSkipping = false;
618.1281 -	emulating = 0;
618.1282 -
618.1283 -	if (this)
618.1284 -		RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
618.1285 -	systemSetTitle(VBA_NAME_AND_VERSION);
618.1286 -}
618.1287 -
618.1288 -bool MainWnd::winFileRun(bool reopening)
618.1289 -{
618.1290 -	int prevCartridgeType = systemCartridgeType;
618.1291 -
618.1292 -	//bool requiresInitRAMSearch = (rom == NULL && gbRom == NULL) || !reopening;
618.1293 -	winFileClose(reopening);
618.1294 -
618.1295 -	// use ObtainFile to support opening files within archives (.7z, .rar, .zip, .zip.rar.7z, etc.)
618.1296 -	if (theApp.romFilename.GetLength() > 2048) theApp.romFilename.Truncate(2048);
618.1297 -
618.1298 -	char logicalName[2048], physicalName[2048];
618.1299 -
618.1300 -	// FIXME: assertion failure in fopen.c if canceled
618.1301 -	if (ObtainFile(theApp.romFilename, logicalName, physicalName, "rom", s_romIgnoreExtensions,
618.1302 -	               sizeof(s_romIgnoreExtensions) / sizeof(*s_romIgnoreExtensions)))
618.1303 -	{
618.1304 -		// theApp.romFilename is exactly the filename used for opening, while theApp.gameFilename is always the logical name
618.1305 -		theApp.romFilename = theApp.gameFilename = logicalName;
618.1306 -		ReleaseTempFileCategory("rom", physicalName);
618.1307 -	}
618.1308 -	else
618.1309 -	{
618.1310 -		return false;
618.1311 -	}
618.1312 -
618.1313 -	IMAGE_TYPE type = utilFindType(physicalName);
618.1314 -
618.1315 -	if (type == IMAGE_UNKNOWN)
618.1316 -	{
618.1317 -		systemMessage(IDS_UNSUPPORTED_FILE_TYPE,
618.1318 -		              "The file \"%s\" is an unsupported type.", logicalName);
618.1319 -		return false;
618.1320 -	}
618.1321 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
618.1322 -	systemCartridgeType		= (int)type;
618.1323 -	if (type == IMAGE_GB)
618.1324 -	{
618.1325 -		if (!gbLoadRom(physicalName))
618.1326 -			return false;
618.1327 -
618.1328 -		gbBorderOn		= theApp.winGbBorderOn;
618.1329 -		theApp.emulator = GBSystem;
618.1330 -		theApp.romSize	= gbRomSize;
618.1331 -		if (theApp.autoIPS)
618.1332 -		{
618.1333 -			CString ipsname = winGetDestFilename(logicalName, IDS_IPS_DIR, ".ips");
618.1334 -			int		size	= gbRomSize;
618.1335 -			utilApplyIPS(ipsname, &gbRom, &size);
618.1336 -			if (size != gbRomSize)
618.1337 -			{
618.1338 -				extern bool gbUpdateSizes();
618.1339 -				gbUpdateSizes();
618.1340 -				theApp.romSize = size;
618.1341 -			}
618.1342 -		}
618.1343 -
618.1344 -		useBios = false;    // FIXME
618.1345 -		
618.1346 -		if (reopening)
618.1347 -		{
618.1348 -			bool winGbCheatReaddress();
618.1349 -			winGbCheatReaddress();
618.1350 -		}
618.1351 -	}
618.1352 -	else
618.1353 -	{
618.1354 -		int size = CPULoadRom(physicalName);
618.1355 -		if (!size)
618.1356 -			return false;
618.1357 -
618.1358 -		flashSetSize(theApp.winFlashSize);
618.1359 -		rtcEnable(theApp.winRtcEnable);
618.1360 -		cpuSaveType = theApp.winSaveType;
618.1361 -
618.1362 -		//    if(cpuEnhancedDetection && winSaveType == 0) {
618.1363 -		//      utilGBAFindSave(rom, size);
618.1364 -		//    }
618.1365 -
618.1366 -		char buffer[5];
618.1367 -		strncpy(buffer, (const char *)&rom[0xac], 4);
618.1368 -		buffer[4] = 0;
618.1369 -
618.1370 -		// vba-over.ini
618.1371 -		CString vbaOverINI = theApp.exeDir;
618.1372 -		vbaOverINI += "\\vba-over.ini";
618.1373 -
618.1374 -		UINT i = GetPrivateProfileInt(buffer, "rtcEnabled", -1, vbaOverINI);
618.1375 -		if (i != (UINT)-1)
618.1376 -			rtcEnable(i == 0 ? false : true);
618.1377 -
618.1378 -		i = GetPrivateProfileInt(buffer, "flashSize", -1, vbaOverINI);
618.1379 -		if (i != (UINT)-1 && (i == 0x10000 || i == 0x20000))
618.1380 -			flashSetSize((int)i);
618.1381 -
618.1382 -		i = GetPrivateProfileInt(buffer, "saveType", -1, vbaOverINI);
618.1383 -		if (i != (UINT)-1 && (i <= 5))
618.1384 -			cpuSaveType = (int)i;
618.1385 -
618.1386 -		/* disabled due to problems
618.1387 -		   if(theApp.removeIntros && rom != NULL) {
618.1388 -		   *((u32 *)rom)= 0xea00002e;
618.1389 -		   }
618.1390 -		 */
618.1391 -		theApp.emulator = GBASystem;
618.1392 -		theApp.romSize	= size;
618.1393 -		if (theApp.autoIPS)
618.1394 -		{
618.1395 -			CString ipsname = winGetDestFilename(logicalName, IDS_IPS_DIR, ".ips");
618.1396 -			int		size	= 0x2000000;
618.1397 -			utilApplyIPS(ipsname, &rom, &size);
618.1398 -		}
618.1399 -
618.1400 -		skipBios = theApp.skipBiosFile ? true : false;
618.1401 -		CPUInit();
618.1402 -		CPULoadBios(theApp.biosFileName, theApp.useBiosFile ? true : false);
618.1403 -		CPUReset();
618.1404 -
618.1405 -		if (reopening)
618.1406 -		{
618.1407 -			bool winGbaCheatReaddress();
618.1408 -			winGbaCheatReaddress();
618.1409 -		}
618.1410 -	}
618.1411 -
618.1412 -	if (theApp.soundInitialized)
618.1413 -	{
618.1414 -		if (systemCartridgeType == 1)
618.1415 -			gbSoundReset();
618.1416 -		else
618.1417 -			soundReset();
618.1418 -	}
618.1419 -	else
618.1420 -	{
618.1421 -		if (!soundOffFlag)
618.1422 -			soundInit();
618.1423 -		theApp.soundInitialized = true;
618.1424 -	}
618.1425 -
618.1426 -	winReadBatteryFile();
618.1427 -
618.1428 -	emulating = true;
618.1429 -
618.1430 -	if (theApp.autoSaveLoadCheatList)
618.1431 -		winLoadCheatListDefault();
618.1432 -
618.1433 -	if (theApp.filenamePreference == 0)
618.1434 -		theApp.addRecentFile(winGetOriginalFilename(logicalName));
618.1435 -	else
618.1436 -		theApp.addRecentFile(logicalName);
618.1437 -
618.1438 -	theApp.updateWindowSize(theApp.videoOption);
618.1439 -
618.1440 -	theApp.updateFrameSkip();
618.1441 -
618.1442 -	if (theApp.autoHideMenu && theApp.videoOption > VIDEO_4X && theApp.menuToggle)
618.1443 -		OnFileTogglemenu();
618.1444 -
618.1445 -	if (theApp.autoLoadMostRecent && !VBAMovieActive() && !VBAMovieLoading()) // would cause desync in movies...
618.1446 -		OnFileLoadgameMostrecent();
618.1447 -
618.1448 -	theApp.renderedFrames = 0;
618.1449 -
618.1450 -	theApp.rewindCount		= 0;
618.1451 -	theApp.rewindCounter	= 0;
618.1452 -	theApp.rewindSaveNeeded = false;
618.1453 -
618.1454 -	{
618.1455 -		extern bool playMovieFile, playMovieFileReadOnly, outputWavFile, outputAVIFile, flagHideMenu; // from VBA.cpp
618.1456 -		extern char movieFileToPlay[1024], wavFileToOutput[1024]; // from VBA.cpp
618.1457 -		extern int	pauseAfterTime; // from VBA.cpp
618.1458 -		if (playMovieFile)
618.1459 -		{
618.1460 -			playMovieFile = false;
618.1461 -			VBAMovieOpen(movieFileToPlay, playMovieFileReadOnly);
618.1462 -		}
618.1463 -		if (outputWavFile)
618.1464 -		{
618.1465 -			outputWavFile = false;
618.1466 -			theApp.soundRecordName = wavFileToOutput;
618.1467 -			theApp.soundRecording  = true;
618.1468 -		}
618.1469 -		if (outputAVIFile)
618.1470 -		{
618.1471 -			outputAVIFile = false;
618.1472 -			OnToolsStartAVIRecording();
618.1473 -		}
618.1474 -		if (pauseAfterTime >= 0)
618.1475 -		{
618.1476 -			VBAMovieSetPauseAt(pauseAfterTime);
618.1477 -		}
618.1478 -		if (flagHideMenu)
618.1479 -		{
618.1480 -			OnFileTogglemenu();
618.1481 -			theApp.updateWindowSize(theApp.videoOption);
618.1482 -		}
618.1483 -	}
618.1484 -
618.1485 -	if (systemCartridgeType != prevCartridgeType)
618.1486 -	{
618.1487 -		extern GBACheatSearch gbaDlg;
618.1488 -		extern GBCheatSearch  gbDlg;
618.1489 -		if (!theApp.pauseDuringCheatSearch && theApp.modelessCheatDialogIsOpen)
618.1490 -		{
618.1491 -			gbaDlg.DestroyWindow();
618.1492 -			gbDlg.DestroyWindow();
618.1493 -			theApp.modelessCheatDialogIsOpen = false;
618.1494 -		}
618.1495 -	}
618.1496 -
618.1497 -	theApp.winCheckFullscreen();
618.1498 -	ReopenRamWindows();
618.1499 -
618.1500 -	// FIXME
618.1501 -	reset_address_info();
618.1502 -	//if (requiresInitRAMSearch)
618.1503 -	{
618.1504 -		// extern void soft_reset_address_info();
618.1505 -		// soft_reset_address_info();
618.1506 -	}
618.1507 -
618.1508 -	VBAUpdateButtonPressDisplay();
618.1509 -	VBAUpdateFrameCountDisplay();
618.1510 -	systemRefreshScreen();
618.1511 -
618.1512 -	return true;
618.1513 -}
618.1514 -
   619.1 --- a/src/win32/MainWnd.h	Sat Mar 03 10:54:39 2012 -0600
   619.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   619.3 @@ -1,541 +0,0 @@
   619.4 -#if !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)
   619.5 -#define AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_
   619.6 -
   619.7 -#if _MSC_VER > 1000
   619.8 -#pragma once
   619.9 -#endif // _MSC_VER > 1000
  619.10 -// MainWnd.h : header file
  619.11 -//
  619.12 -
  619.13 -/////////////////////////////////////////////////////////////////////////////
  619.14 -// MainWnd window
  619.15 -
  619.16 -class MainWnd : public CWnd
  619.17 -{
  619.18 -	// Constructor/Destructor
  619.19 -public:
  619.20 -	MainWnd();
  619.21 -	virtual ~MainWnd();
  619.22 -
  619.23 -	// Attributes
  619.24 -private:
  619.25 -	HCURSOR arrow;
  619.26 -	HACCEL m_hAccelTable;
  619.27 -
  619.28 -	// Implementation
  619.29 -private:
  619.30 -
  619.31 -	// Operations
  619.32 -public:
  619.33 -	afx_msg void OnOptionsEmulatorSelectbiosfile();
  619.34 -	void winFileClose(bool reopening = false);
  619.35 -	bool winFileRun(bool reopening = false);
  619.36 -	bool winFileOpenSelect(int cartridgeType);
  619.37 -	void winMouseOn();
  619.38 -	void winConfirmMode();
  619.39 -
  619.40 -	// Overrides
  619.41 -	// ClassWizard generated virtual function overrides
  619.42 -	//{{AFX_VIRTUAL(MainWnd)
  619.43 -public:
  619.44 -	virtual BOOL PreTranslateMessage(MSG*pMsg);
  619.45 -	//}}AFX_VIRTUAL
  619.46 -
  619.47 -	// Generated message map functions
  619.48 -protected:
  619.49 -	//{{AFX_MSG(MainWnd)
  619.50 -	afx_msg LRESULT OnConfirmMode(WPARAM, LPARAM);
  619.51 -	afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM);
  619.52 -
  619.53 -	afx_msg void OnMove(int x, int y);
  619.54 -	afx_msg void OnContextMenu(CWnd*pWnd, CPoint point);
  619.55 -	afx_msg void OnSize(UINT nType, int cx, int cy);
  619.56 -	afx_msg void OnClose();
  619.57 -	afx_msg void OnInitMenuPopup(CMenu*pPopupMenu, UINT nIndex, BOOL bSysMenu);
  619.58 -	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  619.59 -	afx_msg void OnInitMenu(CMenu*pMenu);
  619.60 -	afx_msg void OnPaint();
  619.61 -	afx_msg void OnDropFiles(HDROP hDropInfo);
  619.62 -	afx_msg void OnActivate(UINT nState, CWnd*pWndOther, BOOL bMinimized);
  619.63 -#if _MSC_VER <= 1200
  619.64 -	afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
  619.65 -#else
  619.66 -	afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
  619.67 -#endif
  619.68 -
  619.69 -	afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI);
  619.70 -	afx_msg BOOL OnOptionsJoypadAutofire(UINT nID);
  619.71 -	afx_msg void OnUpdateOptionsJoypadSticky(CCmdUI *pCmdUI);
  619.72 -	afx_msg BOOL OnOptionsJoypadSticky(UINT nID);
  619.73 -	afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI);
  619.74 -	afx_msg BOOL OnOptionsJoypadDefault(UINT nID);
  619.75 -	afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI);
  619.76 -	afx_msg BOOL OnOptionsFilterIFB(UINT nID);
  619.77 -	afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI);
  619.78 -	afx_msg BOOL OnOptionsFilter(UINT nID);
  619.79 -	afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI);
  619.80 -	afx_msg BOOL OnOptionsPriority(UINT nID);
  619.81 -	afx_msg void OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI);
  619.82 -	afx_msg BOOL OnOptionsSoundVolume(UINT nID);
  619.83 -	afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI);
  619.84 -	afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID);
  619.85 -	afx_msg void OnUpdateVideoLayer(CCmdUI*pCmdUI);
  619.86 -	afx_msg BOOL OnVideoLayer(UINT nID);
  619.87 -	afx_msg BOOL OnOptionVideoSize(UINT nID);
  619.88 -	afx_msg BOOL OnOptionsFrameskip(UINT nID);
  619.89 -	afx_msg void OnFileTogglemenu();
  619.90 -
  619.91 -	afx_msg void OnSystemMinimize();
  619.92 -	afx_msg void OnSystemMaximize();
  619.93 -
  619.94 -	afx_msg void OnHelpAbout();
  619.95 -	afx_msg void OnHelpFaq();
  619.96 -	afx_msg void OnFileOpen();
  619.97 -	afx_msg void OnFileOpenGBx();
  619.98 -	afx_msg void OnFilePause();
  619.99 -	afx_msg void OnUpdateFilePause(CCmdUI*pCmdUI);
 619.100 -	afx_msg void OnFileReset();
 619.101 -	afx_msg void OnUpdateFileReset(CCmdUI*pCmdUI);
 619.102 -	afx_msg void OnUpdateFileRecentFreeze(CCmdUI*pCmdUI);
 619.103 -	afx_msg void OnFileRecentReset();
 619.104 -	afx_msg void OnFileRecentFreeze();
 619.105 -	afx_msg void OnFileExit();
 619.106 -	afx_msg void OnFileClose();
 619.107 -	afx_msg void OnUpdateFileClose(CCmdUI*pCmdUI);
 619.108 -	afx_msg void OnFileLoad();
 619.109 -	afx_msg void OnUpdateFileLoad(CCmdUI*pCmdUI);
 619.110 -	afx_msg void OnFileSave();
 619.111 -	afx_msg void OnUpdateFileSave(CCmdUI*pCmdUI);
 619.112 -	afx_msg void OnFileImportBatteryfile();
 619.113 -	afx_msg void OnUpdateFileImportBatteryfile(CCmdUI*pCmdUI);
 619.114 -	afx_msg void OnFileImportGamesharkcodefile();
 619.115 -	afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI*pCmdUI);
 619.116 -	afx_msg void OnFileImportGamesharksnapshot();
 619.117 -	afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI*pCmdUI);
 619.118 -	afx_msg void OnFileExportBatteryfile();
 619.119 -	afx_msg void OnUpdateFileExportBatteryfile(CCmdUI*pCmdUI);
 619.120 -	afx_msg void OnFileExportGamesharksnapshot();
 619.121 -	afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI*pCmdUI);
 619.122 -	afx_msg void OnFileQuickScreencapture();
 619.123 -	afx_msg void OnFileScreencapture();
 619.124 -	afx_msg void OnUpdateFileScreencapture(CCmdUI*pCmdUI);
 619.125 -	afx_msg void OnFileRominformation();
 619.126 -	afx_msg void OnUpdateFileRominformation(CCmdUI*pCmdUI);
 619.127 -	afx_msg void OnUpdateFileTogglemenu(CCmdUI*pCmdUI);
 619.128 -	afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI*pCmdUI);
 619.129 -	afx_msg void OnUpdateOptionsFrameskipThrottle6(CCmdUI*pCmdUI);
 619.130 -	afx_msg void OnUpdateOptionsFrameskipThrottle15(CCmdUI*pCmdUI);
 619.131 -	afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI*pCmdUI);
 619.132 -	afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI*pCmdUI);
 619.133 -	afx_msg void OnUpdateOptionsFrameskipThrottle75(CCmdUI*pCmdUI);
 619.134 -	afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI*pCmdUI);
 619.135 -	afx_msg void OnUpdateOptionsFrameskipThrottle125(CCmdUI*pCmdUI);
 619.136 -	afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI*pCmdUI);
 619.137 -	afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI*pCmdUI);
 619.138 -	afx_msg void OnUpdateOptionsFrameskipThrottle300(CCmdUI*pCmdUI);
 619.139 -	afx_msg void OnUpdateOptionsFrameskipThrottle400(CCmdUI*pCmdUI);
 619.140 -	afx_msg void OnUpdateOptionsFrameskipThrottle600(CCmdUI*pCmdUI);
 619.141 -	afx_msg void OnUpdateOptionsFrameskipThrottle1000(CCmdUI*pCmdUI);
 619.142 -	afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI*pCmdUI);
 619.143 -	afx_msg void OnUpdateOptionsFrameskipThrottleIncrease(CCmdUI*pCmdUI);
 619.144 -	afx_msg void OnUpdateOptionsFrameskipThrottleDecrease(CCmdUI*pCmdUI);
 619.145 -	afx_msg void OnOptionsFrameskipThrottleNothrottle();
 619.146 -	afx_msg void OnOptionsFrameskipThrottle6();
 619.147 -	afx_msg void OnOptionsFrameskipThrottle15();
 619.148 -	afx_msg void OnOptionsFrameskipThrottle25();
 619.149 -	afx_msg void OnOptionsFrameskipThrottle50();
 619.150 -	afx_msg void OnOptionsFrameskipThrottle75();
 619.151 -	afx_msg void OnOptionsFrameskipThrottle100();
 619.152 -	afx_msg void OnOptionsFrameskipThrottle125();
 619.153 -	afx_msg void OnOptionsFrameskipThrottle150();
 619.154 -	afx_msg void OnOptionsFrameskipThrottle200();
 619.155 -	afx_msg void OnOptionsFrameskipThrottle300();
 619.156 -	afx_msg void OnOptionsFrameskipThrottle400();
 619.157 -	afx_msg void OnOptionsFrameskipThrottle600();
 619.158 -	afx_msg void OnOptionsFrameskipThrottle1000();
 619.159 -	afx_msg void OnOptionsFrameskipThrottleOther();
 619.160 -	afx_msg void OnOptionsFrameskipThrottleIncrease();
 619.161 -	afx_msg void OnOptionsFrameskipThrottleDecrease();
 619.162 -	afx_msg void OnOptionsFrameskipAccuratePitch();
 619.163 -	afx_msg void OnOptionsFrameskipAccurateSpeed();
 619.164 -	afx_msg void OnUpdateOptionsFrameskipAccuratePitch(CCmdUI*pCmdUI);
 619.165 -	afx_msg void OnUpdateOptionsFrameskipAccurateSpeed(CCmdUI*pCmdUI);
 619.166 -	afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI*pCmdUI);
 619.167 -	afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI*pCmdUI);
 619.168 -	afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI*pCmdUI);
 619.169 -	afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI*pCmdUI);
 619.170 -	afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI*pCmdUI);
 619.171 -	afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI*pCmdUI);
 619.172 -	afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI*pCmdUI);
 619.173 -	afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI*pCmdUI);
 619.174 -	afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI*pCmdUI);
 619.175 -	afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI*pCmdUI);
 619.176 -	afx_msg void OnOptionsVideoVsync();
 619.177 -	afx_msg void OnUpdateOptionsVideoVsync(CCmdUI*pCmdUI);
 619.178 -	afx_msg void OnUpdateOptionsVideoX1(CCmdUI*pCmdUI);
 619.179 -	afx_msg void OnUpdateOptionsVideoX2(CCmdUI*pCmdUI);
 619.180 -	afx_msg void OnUpdateOptionsVideoX3(CCmdUI*pCmdUI);
 619.181 -	afx_msg void OnUpdateOptionsVideoX4(CCmdUI*pCmdUI);
 619.182 -	afx_msg void OnUpdateOptionsVideoFullscreen320x240(CCmdUI*pCmdUI);
 619.183 -	afx_msg void OnUpdateOptionsVideoFullscreen640x480(CCmdUI*pCmdUI);
 619.184 -	afx_msg void OnUpdateOptionsVideoFullscreen800x600(CCmdUI*pCmdUI);
 619.185 -	afx_msg void OnOptionsVideoFullscreen320x240();
 619.186 -	afx_msg void OnOptionsVideoFullscreen640x480();
 619.187 -	afx_msg void OnOptionsVideoFullscreen800x600();
 619.188 -	afx_msg void OnOptionsVideoFullscreen();
 619.189 -	afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI*pCmdUI);
 619.190 -	afx_msg void OnOptionsVideoDisablesfx();
 619.191 -	afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI*pCmdUI);
 619.192 -	afx_msg void OnOptionsVideoFullscreenstretchtofit();
 619.193 -	afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI*pCmdUI);
 619.194 -	afx_msg void OnOptionsVideoRendermethodGdi();
 619.195 -	afx_msg void OnUpdateOptionsVideoRendermethodGdi(CCmdUI*pCmdUI);
 619.196 -	afx_msg void OnOptionsVideoRendermethodDirectdraw();
 619.197 -	afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI*pCmdUI);
 619.198 -	afx_msg void OnOptionsVideoRendermethodDirect3d();
 619.199 -	afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI*pCmdUI);
 619.200 -	afx_msg void OnOptionsVideoRendermethodOpengl();
 619.201 -	afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI*pCmdUI);
 619.202 -	afx_msg void OnOptionsVideoTriplebuffering();
 619.203 -	afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI*pCmdUI);
 619.204 -	afx_msg void OnOptionsVideoDdrawemulationonly();
 619.205 -	afx_msg void OnUpdateOptionsVideoDdrawemulationonly(CCmdUI*pCmdUI);
 619.206 -	afx_msg void OnOptionsVideoDdrawusevideomemory();
 619.207 -	afx_msg void OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI*pCmdUI);
 619.208 -	afx_msg void OnOptionsVideoRenderoptionsD3dnofilter();
 619.209 -	afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI*pCmdUI);
 619.210 -	afx_msg void OnOptionsVideoRenderoptionsD3dbilinear();
 619.211 -	afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI*pCmdUI);
 619.212 -	afx_msg void OnOptionsVideoRenderoptionsGlnearest();
 619.213 -	afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI*pCmdUI);
 619.214 -	afx_msg void OnOptionsVideoRenderoptionsGlbilinear();
 619.215 -	afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI*pCmdUI);
 619.216 -	afx_msg void OnOptionsVideoRenderoptionsGltriangle();
 619.217 -	afx_msg void OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI*pCmdUI);
 619.218 -	afx_msg void OnOptionsVideoRenderoptionsGlquads();
 619.219 -	afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI*pCmdUI);
 619.220 -	afx_msg void OnOptionsVideoRenderoptionsSelectskin();
 619.221 -	afx_msg void OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI*pCmdUI);
 619.222 -	afx_msg void OnOptionsVideoRenderoptionsSkin();
 619.223 -	afx_msg void OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI*pCmdUI);
 619.224 -
 619.225 -	afx_msg void OnOptionsEmulatorAssociate();
 619.226 -	afx_msg void OnOptionsEmulatorDirectories();
 619.227 -	afx_msg void OnOptionsEmulatorFilenamePreference(UINT nID);
 619.228 -	afx_msg void OnUpdateOptionsEmulatorFilenamePreference(CCmdUI*pCmdUI);
 619.229 -	afx_msg void OnOptionsVideoDisablestatusmessages();
 619.230 -	afx_msg void OnUpdateOptionsVideoDisablestatusmessages(CCmdUI*pCmdUI);
 619.231 -	afx_msg void OnOptionsEmulatorSynchronize();
 619.232 -	afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI*pCmdUI);
 619.233 -	afx_msg void OnOptionsEmulatorAlwaysOnTop();
 619.234 -	afx_msg void OnUpdateOptionsEmulatorAlwaysOnTop(CCmdUI*pCmdUI);
 619.235 -	afx_msg void OnOptionsEmulatorPausewheninactive();
 619.236 -	afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI*pCmdUI);
 619.237 -	afx_msg void OnOptionsEmulatorEnableBackgroundInput();
 619.238 -	afx_msg void OnUpdateOptionsEmulatorEnableBackgroundInput(CCmdUI*pCmdUI);
 619.239 -	afx_msg void OnOptionsEmulatorSpeeduptoggle();
 619.240 -	afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI*pCmdUI);
 619.241 -	afx_msg void OnOptionsEmulatorRemoveintrosgba();
 619.242 -	afx_msg void OnUpdateOptionsEmulatorRemoveintrosgba(CCmdUI*pCmdUI);
 619.243 -	afx_msg void OnOptionsEmulatorAutomaticallyipspatch();
 619.244 -	afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI*pCmdUI);
 619.245 -	afx_msg void OnOptionsEmulatorAgbprint();
 619.246 -	afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI*pCmdUI);
 619.247 -	afx_msg void OnOptionsEmulatorRealtimeclock();
 619.248 -	afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI*pCmdUI);
 619.249 -	afx_msg void OnOptionsEmulatorAutohidemenu();
 619.250 -	afx_msg void OnUpdateOptionsEmulatorAutohidemenu(CCmdUI*pCmdUI);
 619.251 -	afx_msg void OnOptionsEmulatorRewindinterval();
 619.252 -	afx_msg void OnOptionsEmulatorSavetypeAutomatic();
 619.253 -	afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI*pCmdUI);
 619.254 -	afx_msg void OnOptionsEmulatorSavetypeEeprom();
 619.255 -	afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI*pCmdUI);
 619.256 -	afx_msg void OnOptionsEmulatorSavetypeSram();
 619.257 -	afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI*pCmdUI);
 619.258 -	afx_msg void OnOptionsEmulatorSavetypeFlash();
 619.259 -	afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI*pCmdUI);
 619.260 -	afx_msg void OnOptionsEmulatorSavetypeEepromsensor();
 619.261 -	afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI*pCmdUI);
 619.262 -	afx_msg void OnOptionsEmulatorSavetypeNone();
 619.263 -	afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI*pCmdUI);
 619.264 -	afx_msg void OnOptionsEmulatorSavetypeFlash512k();
 619.265 -	afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI*pCmdUI);
 619.266 -	afx_msg void OnOptionsEmulatorSavetypeFlash1m();
 619.267 -	afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI*pCmdUI);
 619.268 -	afx_msg void OnOptionsEmulatorUseOldGBTiming();
 619.269 -	afx_msg void OnUpdateOptionsEmulatorUseOldGBTiming(CCmdUI*pCmdUI);
 619.270 -	afx_msg void OnOptionsEmulatorUseGBNullInputKludge();
 619.271 -	afx_msg void OnUpdateOptionsEmulatorUseGBNullInputKludge(CCmdUI*pCmdUI);
 619.272 -	afx_msg void OnOptionsEmulatorGBALag();
 619.273 -	afx_msg void OnUpdateOptionsEmulatorGBALag(CCmdUI*pCmdUI);
 619.274 -	afx_msg void OnOptionsEmulatorUsebiosfile();
 619.275 -	afx_msg void OnUpdateOptionsEmulatorUsebiosfile(CCmdUI*pCmdUI);
 619.276 -
 619.277 -	afx_msg void OnOptionsEmulatorSkipbios();
 619.278 -	afx_msg void OnUpdateOptionsEmulatorSkipbios(CCmdUI*pCmdUI);
 619.279 -	afx_msg void OnOptionsEmulatorPngformat();
 619.280 -	afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI*pCmdUI);
 619.281 -	afx_msg void OnOptionsEmulatorBmpformat();
 619.282 -	afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI*pCmdUI);
 619.283 -
 619.284 -	afx_msg void OnOptionsSoundDisable();
 619.285 -	afx_msg void OnUpdateOptionsSoundDisable(CCmdUI*pCmdUI);
 619.286 -	afx_msg void OnOptionsSoundMute();
 619.287 -	afx_msg void OnUpdateOptionsSoundMute(CCmdUI*pCmdUI);
 619.288 -	afx_msg void OnOptionsSoundOff();
 619.289 -	afx_msg void OnUpdateOptionsSoundOff(CCmdUI*pCmdUI);
 619.290 -	afx_msg void OnOptionsSoundOn();
 619.291 -	afx_msg void OnUpdateOptionsSoundOn(CCmdUI*pCmdUI);
 619.292 -	afx_msg void OnOptionsSoundUseoldsynchronization();
 619.293 -	afx_msg void OnUpdateOptionsSoundUseoldsynchronization(CCmdUI*pCmdUI);
 619.294 -	afx_msg void OnOptionsSoundEcho();
 619.295 -	afx_msg void OnUpdateOptionsSoundEcho(CCmdUI*pCmdUI);
 619.296 -	afx_msg void OnOptionsSoundLowpassfilter();
 619.297 -	afx_msg void OnUpdateOptionsSoundLowpassfilter(CCmdUI*pCmdUI);
 619.298 -	afx_msg void OnOptionsSoundReversestereo();
 619.299 -	afx_msg void OnUpdateOptionsSoundReversestereo(CCmdUI*pCmdUI);
 619.300 -	afx_msg void OnOptionsSoundMuteFrameAdvance();
 619.301 -	afx_msg void OnUpdateOptionsSoundMuteFrameAdvance(CCmdUI*pCmdUI);
 619.302 -	afx_msg void OnOptionsSoundMuteWhenInactive();
 619.303 -	afx_msg void OnUpdateOptionsSoundMuteWhenInactive(CCmdUI*pCmdUI);
 619.304 -	afx_msg void OnOptionsSound11khz();
 619.305 -	afx_msg void OnUpdateOptionsSound11khz(CCmdUI*pCmdUI);
 619.306 -	afx_msg void OnOptionsSound22khz();
 619.307 -	afx_msg void OnUpdateOptionsSound22khz(CCmdUI*pCmdUI);
 619.308 -	afx_msg void OnOptionsSound44khz();
 619.309 -	afx_msg void OnUpdateOptionsSound44khz(CCmdUI*pCmdUI);
 619.310 -	afx_msg void OnOptionsSoundChannel1();
 619.311 -	afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI*pCmdUI);
 619.312 -	afx_msg void OnOptionsSoundChannel2();
 619.313 -	afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI*pCmdUI);
 619.314 -	afx_msg void OnOptionsSoundChannel3();
 619.315 -	afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI*pCmdUI);
 619.316 -	afx_msg void OnOptionsSoundChannel4();
 619.317 -	afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI*pCmdUI);
 619.318 -	afx_msg void OnOptionsSoundDirectsounda();
 619.319 -	afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI*pCmdUI);
 619.320 -	afx_msg void OnOptionsSoundDirectsoundb();
 619.321 -	afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI*pCmdUI);
 619.322 -	afx_msg void OnOptionsGameboyBorder();
 619.323 -	afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI*pCmdUI);
 619.324 -	afx_msg void OnOptionsGameboyPrinter();
 619.325 -	afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI*pCmdUI);
 619.326 -	afx_msg void OnOptionsGameboyBorderAutomatic();
 619.327 -	afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI*pCmdUI);
 619.328 -	afx_msg void OnOptionsGameboyAutomatic();
 619.329 -	afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI*pCmdUI);
 619.330 -	afx_msg void OnOptionsGameboyGba();
 619.331 -	afx_msg void OnUpdateOptionsGameboyGba(CCmdUI*pCmdUI);
 619.332 -	afx_msg void OnOptionsGameboyCgb();
 619.333 -	afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI*pCmdUI);
 619.334 -	afx_msg void OnOptionsGameboySgb();
 619.335 -	afx_msg void OnUpdateOptionsGameboySgb(CCmdUI*pCmdUI);
 619.336 -	afx_msg void OnOptionsGameboySgb2();
 619.337 -	afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI*pCmdUI);
 619.338 -	afx_msg void OnOptionsGameboyGb();
 619.339 -	afx_msg void OnUpdateOptionsGameboyGb(CCmdUI*pCmdUI);
 619.340 -	afx_msg void OnOptionsGameboyRealcolors();
 619.341 -	afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI*pCmdUI);
 619.342 -	afx_msg void OnOptionsGameboyGameboycolors();
 619.343 -	afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI*pCmdUI);
 619.344 -	afx_msg void OnOptionsGameboyColors();
 619.345 -	afx_msg void OnOptionsFilterDisablemmx();
 619.346 -	afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI*pCmdUI);
 619.347 -	afx_msg void OnOptionsLanguageSystem();
 619.348 -	afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI*pCmdUI);
 619.349 -	afx_msg void OnOptionsLanguageEnglish();
 619.350 -	afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI*pCmdUI);
 619.351 -	afx_msg void OnOptionsLanguageOther();
 619.352 -	afx_msg void OnUpdateOptionsLanguageOther(CCmdUI*pCmdUI);
 619.353 -	afx_msg void OnOptionsJoypadConfigure1();
 619.354 -	afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI*pCmdUI);
 619.355 -	afx_msg void OnOptionsJoypadConfigure2();
 619.356 -	afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI*pCmdUI);
 619.357 -	afx_msg void OnOptionsJoypadConfigure3();
 619.358 -	afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI*pCmdUI);
 619.359 -	afx_msg void OnOptionsJoypadConfigure4();
 619.360 -	afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI*pCmdUI);
 619.361 -	afx_msg void OnOptionsJoypadMotionconfigure();
 619.362 -	afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI*pCmdUI);
 619.363 -	afx_msg void OnOptionsJoypadAllowLeftRight();
 619.364 -	afx_msg void OnUpdateOptionsJoypadAllowLeftRight(CCmdUI*pCmdUI);
 619.365 -	afx_msg void OnOptionsJoypadAutofireAccountForLag();
 619.366 -	afx_msg void OnUpdateOptionsJoypadAutofireAccountForLag(CCmdUI*pCmdUI);
 619.367 -	afx_msg void OnCheatsSearchforcheats();
 619.368 -	afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI*pCmdUI);
 619.369 -	afx_msg void OnCheatsCheatlist();
 619.370 -	afx_msg void OnUpdateCheatsCheatlist(CCmdUI*pCmdUI);
 619.371 -	afx_msg void OnCheatsAutomaticsaveloadcheats();
 619.372 -	afx_msg void OnCheatsPauseDuringCheatSearch();
 619.373 -	afx_msg void OnCheatsLoadcheatlist();
 619.374 -	afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI*pCmdUI);
 619.375 -	afx_msg void OnCheatsSavecheatlist();
 619.376 -	afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI*pCmdUI);
 619.377 -	afx_msg void OnToolsDisassemble();
 619.378 -	afx_msg void OnUpdateToolsDisassemble(CCmdUI*pCmdUI);
 619.379 -	afx_msg void OnToolsLogging();
 619.380 -	afx_msg void OnUpdateToolsLogging(CCmdUI*pCmdUI);
 619.381 -	afx_msg void OnToolsIoviewer();
 619.382 -	afx_msg void OnUpdateToolsIoviewer(CCmdUI*pCmdUI);
 619.383 -	afx_msg void OnToolsMapview();
 619.384 -	afx_msg void OnUpdateToolsMapview(CCmdUI*pCmdUI);
 619.385 -	afx_msg void OnToolsMemoryviewer();
 619.386 -	afx_msg void OnUpdateToolsMemoryviewer(CCmdUI*pCmdUI);
 619.387 -	afx_msg void OnToolsOamviewer();
 619.388 -	afx_msg void OnUpdateToolsOamviewer(CCmdUI*pCmdUI);
 619.389 -	afx_msg void OnToolsPaletteview();
 619.390 -	afx_msg void OnUpdateToolsPaletteview(CCmdUI*pCmdUI);
 619.391 -	afx_msg void OnToolsTileviewer();
 619.392 -	afx_msg void OnUpdateToolsTileviewer(CCmdUI*pCmdUI);
 619.393 -	afx_msg void OnDebugNextframe();
 619.394 -	afx_msg void OnUpdateDebugNextframe(CCmdUI*pCmdUI);
 619.395 -	afx_msg void OnDebugNextframeAccountForLag();
 619.396 -	afx_msg void OnUpdateDebugNextframeAccountForLag(CCmdUI*pCmdUI);
 619.397 -	afx_msg void OnDebugFramesearch();
 619.398 -	afx_msg void OnUpdateDebugFramesearch(CCmdUI*pCmdUI);
 619.399 -	afx_msg void OnDebugFramesearchPrev();
 619.400 -	afx_msg void OnUpdateDebugFramesearchPrev(CCmdUI*pCmdUI);
 619.401 -	afx_msg void OnDebugFramesearchLoad();
 619.402 -	afx_msg void OnUpdateDebugFramesearchLoad(CCmdUI*pCmdUI);
 619.403 -	afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI*pCmdUI);
 619.404 -	afx_msg void OnUpdateCheatsPauseDuringCheatSearch(CCmdUI*pCmdUI);
 619.405 -	afx_msg void OnToolsFrameCounter();
 619.406 -	afx_msg void OnUpdateToolsFrameCounter(CCmdUI*pCmdUI);
 619.407 -	afx_msg void OnToolsLagCounter();
 619.408 -	afx_msg void OnUpdateToolsLagCounter(CCmdUI*pCmdUI);
 619.409 -	afx_msg void OnToolsExtraCounter();
 619.410 -	afx_msg void OnUpdateToolsExtraCounter(CCmdUI*pCmdUI);
 619.411 -	afx_msg void OnToolsExtraCounterReset();
 619.412 -	afx_msg void OnToolsInputDisplay();
 619.413 -	afx_msg void OnUpdateToolsInputDisplay(CCmdUI*pCmdUI);
 619.414 -	afx_msg void OnToolsDebugGdb();
 619.415 -	afx_msg void OnUpdateToolsDebugGdb(CCmdUI*pCmdUI);
 619.416 -	afx_msg void OnToolsDebugLoadandwait();
 619.417 -	afx_msg void OnUpdateToolsDebugLoadandwait(CCmdUI*pCmdUI);
 619.418 -	afx_msg void OnToolsDebugBreak();
 619.419 -	afx_msg void OnUpdateToolsDebugBreak(CCmdUI*pCmdUI);
 619.420 -	afx_msg void OnToolsDebugDisconnect();
 619.421 -	afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI*pCmdUI);
 619.422 -	afx_msg void OnToolsSoundStartrecording();
 619.423 -	afx_msg void OnToolsSoundStoprecording();
 619.424 -	afx_msg void OnToolsSoundRecording();
 619.425 -	afx_msg void OnUpdateToolsSoundRecording(CCmdUI*pCmdUI);
 619.426 -	afx_msg void OnToolsStartAVIRecording();
 619.427 -	afx_msg void OnToolsPauseAVIRecording();
 619.428 -	afx_msg void OnToolsStopAVIRecording();
 619.429 -	afx_msg void OnToolsAVIRecording();
 619.430 -	afx_msg void OnUpdateToolsAVIRecording(CCmdUI*pCmdUI);
 619.431 -	afx_msg void OnUpdateToolsPauseAVIRecording(CCmdUI*pCmdUI);
 619.432 -
 619.433 -	afx_msg void OnToolsRecordMovie();
 619.434 -	afx_msg void OnUpdateToolsRecordMovie(CCmdUI*pCmdUI);
 619.435 -	afx_msg void OnToolsStopMovie();
 619.436 -	afx_msg void OnUpdateToolsStopMovie(CCmdUI*pCmdUI);
 619.437 -	afx_msg void OnToolsPlayMovie();
 619.438 -	afx_msg void OnUpdateToolsPlayMovie(CCmdUI*pCmdUI);
 619.439 -	afx_msg void OnToolsPlayReadOnly();
 619.440 -	afx_msg void OnUpdateToolsPlayReadOnly(CCmdUI*pCmdUI);
 619.441 -	afx_msg void OnAsscWithSaveState();
 619.442 -	afx_msg void OnUpdateAsscWithSaveState(CCmdUI*pCmdUI);
 619.443 -	afx_msg void OnToolsResumeRecord();
 619.444 -	afx_msg void OnUpdateToolsResumeRecord(CCmdUI*pCmdUI);
 619.445 -	afx_msg void OnToolsPlayRestart();
 619.446 -	afx_msg void OnUpdateToolsPlayRestart(CCmdUI*pCmdUI);
 619.447 -
 619.448 -	afx_msg void OnToolsOnMovieEndPause();
 619.449 -	afx_msg void OnUpdateToolsOnMovieEndPause(CCmdUI*pCmdUI);
 619.450 -	afx_msg void OnToolsOnMovieEndStop();
 619.451 -	afx_msg void OnUpdateToolsOnMovieEndStop(CCmdUI*pCmdUI);
 619.452 -	afx_msg void OnToolsOnMovieEndRestart();
 619.453 -	afx_msg void OnUpdateToolsOnMovieEndRestart(CCmdUI*pCmdUI);
 619.454 -	afx_msg void OnToolsOnMovieEndAppend();
 619.455 -	afx_msg void OnUpdateToolsOnMovieEndAppend(CCmdUI*pCmdUI);
 619.456 -	afx_msg void OnToolsOnMovieEndKeep();
 619.457 -	afx_msg void OnUpdateToolsOnMovieEndKeep(CCmdUI*pCmdUI);
 619.458 -
 619.459 -	afx_msg void OnToolsMovieSetPauseAt();
 619.460 -	afx_msg void OnUpdateToolsSetMoviePauseAt(CCmdUI*pCmdUI);
 619.461 -	afx_msg void OnToolsMovieConvertCurrent();
 619.462 -	afx_msg void OnUpdateToolsMovieConvertCurrent(CCmdUI*pCmdUI);
 619.463 -	afx_msg void OnToolsMovieAutoConvert();
 619.464 -	afx_msg void OnUpdateToolsMovieAutoConvert(CCmdUI*pCmdUI);
 619.465 -	afx_msg void OnToolsMovieFixHeader();
 619.466 -	afx_msg void OnUpdateToolsMovieFixHeader(CCmdUI*pCmdUI);
 619.467 -	afx_msg void OnToolsMovieTruncateAtCurrent();
 619.468 -	afx_msg void OnUpdateToolsMovieTruncateAtCurrent(CCmdUI*pCmdUI);
 619.469 -	afx_msg void OnToolsMovieExtractFromSavegame();
 619.470 -	afx_msg void OnUpdateToolsMovieExtractFromSavegame(CCmdUI*pCmdUI);
 619.471 -
 619.472 -	afx_msg void OnToolsRewind();
 619.473 -	afx_msg void OnUpdateToolsRewind(CCmdUI*pCmdUI);
 619.474 -	afx_msg void OnToolsCustomize();
 619.475 -	afx_msg void OnUpdateToolsCustomize(CCmdUI*pCmdUI);
 619.476 -//	afx_msg void OnToolsCustomizeCommon();
 619.477 -//	afx_msg void OnUpdateToolsCustomizeCommon(CCmdUI*pCmdUI);
 619.478 -	afx_msg void OnToolsCopyVBAWatchSetting();
 619.479 -	afx_msg void OnToolsCopyVBxWatchSetting();
 619.480 -	afx_msg void OnHelpBugreport();
 619.481 -
 619.482 -	afx_msg void OnFileSavegameOldestslot();
 619.483 -	afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI*pCmdUI);
 619.484 -	afx_msg void OnFileLoadgameMostrecent();
 619.485 -	afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI*pCmdUI);
 619.486 -	afx_msg void OnFileLoadgameAutoloadmostrecent();
 619.487 -	afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI*pCmdUI);
 619.488 -	afx_msg void OnFileLoadgameMakeRecent();
 619.489 -	afx_msg void OnUpdateFileLoadgameMakeRecent(CCmdUI*pCmdUI);
 619.490 -
 619.491 -	afx_msg void OnFileSavegameCurrent();
 619.492 -	afx_msg void OnUpdateFileSavegameCurrent(CCmdUI*pCmdUI);
 619.493 -	afx_msg void OnFileLoadgameCurrent();
 619.494 -	afx_msg void OnUpdateFileLoadgameCurrent(CCmdUI*pCmdUI);
 619.495 -	afx_msg void OnFileLoadgameMakeCurrent();
 619.496 -	afx_msg void OnUpdateFileLoadgameMakeCurrent(CCmdUI*pCmdUI);
 619.497 -	afx_msg void OnFileSavegameMakeCurrent();
 619.498 -	afx_msg void OnUpdateFileSavegameMakeCurrent(CCmdUI*pCmdUI);
 619.499 -	afx_msg void OnFileSavegameIncrementSlot();
 619.500 -	afx_msg void OnUpdateFileSavegameIncrementSlot(CCmdUI*pCmdUI);
 619.501 -	afx_msg void OnFileSavegameDecrementSlot();
 619.502 -	afx_msg void OnUpdateFileSavegameDecrementSlot(CCmdUI*pCmdUI);
 619.503 -	afx_msg void OnFileSlotDisplayModificationTime();
 619.504 -	afx_msg void OnUpdateFileSlotDisplayModificationTime(CCmdUI*pCmdUI);
 619.505 -
 619.506 -	afx_msg void OnOptionsSoundVolume25x();
 619.507 -	afx_msg void OnUpdateOptionsSoundVolume25x(CCmdUI*pCmdUI);
 619.508 -	afx_msg void OnOptionsSoundVolume5x();
 619.509 -	afx_msg void OnUpdateOptionsSoundVolume5x(CCmdUI*pCmdUI);
 619.510 -	afx_msg void OnCheatsDisablecheats();
 619.511 -	afx_msg void OnUpdateCheatsDisablecheats(CCmdUI*pCmdUI);
 619.512 -	afx_msg void OnOptionsVideoFullscreenmaxscale();
 619.513 -	afx_msg void OnOptionsVideoTextdisplayoptions();
 619.514 -	afx_msg void OnUpdateOptionsVideoTextdisplayoptions(CCmdUI *pCmdUI);
 619.515 -
 619.516 -	afx_msg void OnUpdateFileRecentFile(CCmdUI *pCmdUI);
 619.517 -	afx_msg void OnUpdateFileLoadSlot(CCmdUI *pCmdUI);
 619.518 -	afx_msg void OnUpdateFileSaveSlot(CCmdUI *pCmdUI);
 619.519 -	afx_msg void OnUpdateSelectSlot(CCmdUI *pCmdUI);
 619.520 -	afx_msg BOOL OnFileRecentFile(UINT nID);
 619.521 -	afx_msg BOOL OnFileLoadSlot(UINT nID);
 619.522 -	afx_msg BOOL OnFileSaveSlot(UINT nID);
 619.523 -	afx_msg BOOL OnSelectSlot(UINT nID);
 619.524 -
 619.525 -	afx_msg void OnFileLuaOpen();
 619.526 -	afx_msg void OnUpdateFileLuaOpen(CCmdUI *pCmdUI);
 619.527 -	afx_msg void OnFileLuaCloseAll();
 619.528 -	afx_msg void OnUpdateFileLuaCloseAll(CCmdUI *pCmdUI);
 619.529 -	afx_msg void OnFileLuaReload();
 619.530 -	afx_msg void OnFileLuaStop();
 619.531 -	afx_msg void OnFileRamSearch();
 619.532 -	afx_msg void OnUpdateFileRamSearch(CCmdUI *pCmdUI);
 619.533 -	afx_msg void OnFileRamWatch();
 619.534 -	afx_msg void OnUpdateFileRamWatch(CCmdUI *pCmdUI);
 619.535 -	//}}AFX_MSG
 619.536 -	DECLARE_MESSAGE_MAP()
 619.537 -};
 619.538 -
 619.539 -/////////////////////////////////////////////////////////////////////////////
 619.540 -
 619.541 -//{{AFX_INSERT_LOCATION}}
 619.542 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 619.543 -
 619.544 -#endif // !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)
   620.1 --- a/src/win32/MainWndCheats.cpp	Sat Mar 03 10:54:39 2012 -0600
   620.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   620.3 @@ -1,164 +0,0 @@
   620.4 -#include "stdafx.h"
   620.5 -#include "resource.h"
   620.6 -#include "MainWnd.h"
   620.7 -#include "FileDlg.h"
   620.8 -#include "GBACheatsDlg.h"
   620.9 -#include "GBCheatsDlg.h"
  620.10 -#include "Reg.h"
  620.11 -#include "WinResUtil.h"
  620.12 -#include "WinMiscUtil.h"
  620.13 -#include "VBA.h"
  620.14 -
  620.15 -#include "../gba/GBA.h"
  620.16 -#include "../gba/GBAGlobals.h"
  620.17 -#include "../gb/gbCheats.h"
  620.18 -
  620.19 -GBACheatSearch gbaDlg;
  620.20 -GBCheatSearch  gbDlg;
  620.21 -
  620.22 -void MainWnd::OnCheatsSearchforcheats()
  620.23 -{
  620.24 -	theApp.winCheckFullscreen();
  620.25 -
  620.26 -	if (theApp.modelessCheatDialogIsOpen)
  620.27 -	{
  620.28 -		gbaDlg.DestroyWindow();
  620.29 -		gbDlg.DestroyWindow();
  620.30 -		theApp.modelessCheatDialogIsOpen = false;
  620.31 -	}
  620.32 -
  620.33 -	if (systemCartridgeType == 0)
  620.34 -	{
  620.35 -		if (theApp.pauseDuringCheatSearch)
  620.36 -		{
  620.37 -			gbaDlg.DoModal();
  620.38 -		}
  620.39 -		else
  620.40 -		{
  620.41 -			if (!theApp.modelessCheatDialogIsOpen)
  620.42 -			{
  620.43 -				theApp.modelessCheatDialogIsOpen = true;
  620.44 -				gbaDlg.Create(GBACheatSearch::IDD, theApp.m_pMainWnd);
  620.45 -			}
  620.46 -		}
  620.47 -	}
  620.48 -	else
  620.49 -	{
  620.50 -		if (theApp.pauseDuringCheatSearch)
  620.51 -		{
  620.52 -			gbDlg.DoModal();
  620.53 -		}
  620.54 -		else
  620.55 -		{
  620.56 -			if (!theApp.modelessCheatDialogIsOpen)
  620.57 -			{
  620.58 -				theApp.modelessCheatDialogIsOpen = true;
  620.59 -				gbDlg.Create(GBCheatSearch::IDD, theApp.m_pMainWnd);
  620.60 -			}
  620.61 -		}
  620.62 -	}
  620.63 -}
  620.64 -
  620.65 -void MainWnd::OnUpdateCheatsSearchforcheats(CCmdUI*pCmdUI)
  620.66 -{
  620.67 -	pCmdUI->Enable(emulating);
  620.68 -}
  620.69 -
  620.70 -void MainWnd::OnCheatsCheatlist()
  620.71 -{
  620.72 -	theApp.winCheckFullscreen();
  620.73 -	if (systemCartridgeType == 0)
  620.74 -	{
  620.75 -		GBACheatList dlg;
  620.76 -		dlg.DoModal();
  620.77 -	}
  620.78 -	else
  620.79 -	{
  620.80 -		GBCheatList dlg;
  620.81 -		dlg.DoModal();
  620.82 -	}
  620.83 -}
  620.84 -
  620.85 -void MainWnd::OnUpdateCheatsCheatlist(CCmdUI*pCmdUI)
  620.86 -{
  620.87 -	pCmdUI->Enable(emulating);
  620.88 -}
  620.89 -
  620.90 -void MainWnd::OnCheatsAutomaticsaveloadcheats()
  620.91 -{
  620.92 -	theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
  620.93 -}
  620.94 -
  620.95 -void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI*pCmdUI)
  620.96 -{
  620.97 -	pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
  620.98 -}
  620.99 -
 620.100 -void MainWnd::OnCheatsPauseDuringCheatSearch()
 620.101 -{
 620.102 -	theApp.pauseDuringCheatSearch = !theApp.pauseDuringCheatSearch;
 620.103 -}
 620.104 -
 620.105 -void MainWnd::OnUpdateCheatsPauseDuringCheatSearch(CCmdUI*pCmdUI)
 620.106 -{
 620.107 -	pCmdUI->SetCheck(theApp.pauseDuringCheatSearch);
 620.108 -}
 620.109 -
 620.110 -void MainWnd::OnCheatsLoadcheatlist()
 620.111 -{
 620.112 -	theApp.winCheckFullscreen();
 620.113 -
 620.114 -	LPCTSTR exts[] = { ".clt", NULL };
 620.115 -	CString filter = winResLoadFilter(IDS_FILTER_CHEAT_LIST);
 620.116 -	CString title  = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
 620.117 -
 620.118 -	CString cheatName = winGetDestFilename(theApp.gameFilename, IDS_CHEAT_DIR, exts[0]);
 620.119 -	CString cheatDir = winGetDestDir(IDS_CHEAT_DIR);
 620.120 -
 620.121 -	FileDlg dlg(this, cheatName, filter, 0, "CLT", exts, cheatDir, title, false);
 620.122 -
 620.123 -	if (dlg.DoModal() == IDOK)
 620.124 -	{
 620.125 -		winLoadCheatList(dlg.GetPathName());
 620.126 -	}
 620.127 -}
 620.128 -
 620.129 -void MainWnd::OnUpdateCheatsLoadcheatlist(CCmdUI*pCmdUI)
 620.130 -{
 620.131 -	pCmdUI->Enable(emulating);
 620.132 -}
 620.133 -
 620.134 -void MainWnd::OnCheatsSavecheatlist()
 620.135 -{
 620.136 -	theApp.winCheckFullscreen();
 620.137 -
 620.138 -	LPCTSTR exts[] = { ".clt", NULL };
 620.139 -	CString filter = winResLoadFilter(IDS_FILTER_CHEAT_LIST);
 620.140 -	CString title  = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
 620.141 -
 620.142 -	CString cheatName = winGetDestFilename(theApp.gameFilename, IDS_CHEAT_DIR, exts[0]);
 620.143 -	CString cheatDir = winGetDestDir(IDS_CHEAT_DIR);
 620.144 -
 620.145 -	FileDlg dlg(this, cheatName, filter, 0, "CLT", exts, cheatDir, title, true);
 620.146 -
 620.147 -	if (dlg.DoModal() == IDOK)
 620.148 -	{
 620.149 -		winSaveCheatList(dlg.GetPathName());
 620.150 -	}
 620.151 -}
 620.152 -
 620.153 -void MainWnd::OnUpdateCheatsSavecheatlist(CCmdUI*pCmdUI)
 620.154 -{
 620.155 -	pCmdUI->Enable(emulating);
 620.156 -}
 620.157 -
 620.158 -void MainWnd::OnCheatsDisablecheats()
 620.159 -{
 620.160 -	cheatsEnabled = !cheatsEnabled;
 620.161 -}
 620.162 -
 620.163 -void MainWnd::OnUpdateCheatsDisablecheats(CCmdUI*pCmdUI)
 620.164 -{
 620.165 -	pCmdUI->SetCheck(!cheatsEnabled);
 620.166 -}
 620.167 -
   621.1 --- a/src/win32/MainWndFile.cpp	Sat Mar 03 10:54:39 2012 -0600
   621.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   621.3 @@ -1,1004 +0,0 @@
   621.4 -#include "stdafx.h"
   621.5 -#include "resource.h"
   621.6 -#include "MainWnd.h"
   621.7 -#include "ExportGSASnapshot.h"
   621.8 -#include "FileDlg.h"
   621.9 -#include "GSACodeSelect.h"
  621.10 -#include "RomInfo.h"
  621.11 -#include "Reg.h"
  621.12 -#include "WinResUtil.h"
  621.13 -#include "WinMiscUtil.h"
  621.14 -#include "LuaOpenDialog.h"
  621.15 -#include "ram_search.h"
  621.16 -#include "ramwatch.h"
  621.17 -#include "Sound.h"
  621.18 -#include "VBA.h"
  621.19 -
  621.20 -#include "../NLS.h"
  621.21 -#include "../version.h"
  621.22 -#include "../gba/GBA.h"
  621.23 -#include "../gba/GBAGlobals.h"
  621.24 -#include "../gba/EEprom.h"
  621.25 -#include "../gba/GBASound.h"
  621.26 -#include "../gb/GB.h"
  621.27 -#include "../gb/gbGlobals.h"
  621.28 -#include "../common/movie.h"
  621.29 -#include "../common/vbalua.h"
  621.30 -
  621.31 -void MainWnd::OnFileOpen()
  621.32 -{
  621.33 -	theApp.winCheckFullscreen();
  621.34 -	if (winFileOpenSelect(0))
  621.35 -	{
  621.36 -		winFileRun();
  621.37 -	}
  621.38 -}
  621.39 -
  621.40 -void MainWnd::OnFileOpenGBx()
  621.41 -{
  621.42 -	theApp.winCheckFullscreen();
  621.43 -	if (winFileOpenSelect(1))
  621.44 -	{
  621.45 -		winFileRun();
  621.46 -	}
  621.47 -}
  621.48 -
  621.49 -void MainWnd::OnFilePause()
  621.50 -{
  621.51 -	systemSetPause(!theApp.paused);
  621.52 -}
  621.53 -
  621.54 -void MainWnd::OnUpdateFilePause(CCmdUI *pCmdUI)
  621.55 -{
  621.56 -	pCmdUI->SetCheck(theApp.paused);
  621.57 -}
  621.58 -
  621.59 -void MainWnd::OnFileReset()
  621.60 -{
  621.61 -	if (emulating)
  621.62 -	{
  621.63 -		if (VBAMovieGetState() == MOVIE_STATE_PLAY)
  621.64 -		{
  621.65 -			OnToolsPlayRestart();   // HACK: shortcut
  621.66 -		}
  621.67 -		else
  621.68 -		{
  621.69 -			theApp.emulator.emuReset(true);
  621.70 -			systemScreenMessage(winResLoadString(IDS_RESET));
  621.71 -		}
  621.72 -	}
  621.73 -}
  621.74 -
  621.75 -void MainWnd::OnUpdateFileReset(CCmdUI *pCmdUI)
  621.76 -{
  621.77 -	pCmdUI->Enable(emulating);
  621.78 -}
  621.79 -
  621.80 -void MainWnd::OnFileRecentFreeze()
  621.81 -{
  621.82 -	theApp.recentFreeze = !theApp.recentFreeze;
  621.83 -}
  621.84 -
  621.85 -void MainWnd::OnUpdateFileRecentFreeze(CCmdUI *pCmdUI)
  621.86 -{
  621.87 -	pCmdUI->SetCheck(theApp.recentFreeze);
  621.88 -}
  621.89 -
  621.90 -void MainWnd::OnFileRecentReset()
  621.91 -{
  621.92 -	theApp.winCheckFullscreen();
  621.93 -	systemSoundClearBuffer();
  621.94 -	if (MessageBox("Really clear your recent ROMs list?", //winResLoadString(IDS_REALLY_CLEAR),
  621.95 -	               winResLoadString(IDS_CONFIRM_ACTION),
  621.96 -	               MB_YESNO | MB_DEFBUTTON2) == IDNO)
  621.97 -		return;
  621.98 -
  621.99 -	for (int i = 0; i < 10; ++i)
 621.100 -		theApp.recentFiles[i] = "";
 621.101 -}
 621.102 -
 621.103 -BOOL MainWnd::OnFileRecentFile(UINT nID)
 621.104 -{
 621.105 -	if (theApp.recentFiles[(nID & 0xFFFF) - ID_FILE_MRU_FILE1].GetLength())
 621.106 -	{
 621.107 -		theApp.romFilename = theApp.recentFiles[(nID & 0xFFFF) - ID_FILE_MRU_FILE1];
 621.108 -		winFileRun();
 621.109 -	}
 621.110 -	return TRUE;
 621.111 -}
 621.112 -
 621.113 -void MainWnd::OnUpdateFileRecentFile(CCmdUI *pCmdUI)
 621.114 -{
 621.115 -	int fileID = pCmdUI->m_nID - ID_FILE_MRU_FILE1;
 621.116 -
 621.117 -	bool bExist = !theApp.recentFiles[fileID].IsEmpty();
 621.118 -
 621.119 -	if (pCmdUI->m_pMenu != NULL)
 621.120 -	{
 621.121 -		CString p = theApp.recentFiles[fileID];
 621.122 -
 621.123 -		int index = max(p.ReverseFind('/'), max(p.ReverseFind('\\'), p.ReverseFind('|')));
 621.124 -
 621.125 -		if (index != -1)
 621.126 -		{
 621.127 -			p.Delete(0, index + 1);
 621.128 -		}
 621.129 -
 621.130 -		p.Replace("&", "&&");
 621.131 -
 621.132 -		CString number("1&0 - ");
 621.133 -		if (fileID < 9)
 621.134 -			number.Format("&%d - ", fileID + 1);
 621.135 -
 621.136 -		if (p.IsEmpty())
 621.137 -		{
 621.138 -			p	   = "No Recent ROM";
 621.139 -			bExist = false;
 621.140 -		}
 621.141 -
 621.142 -		pCmdUI->SetText(number + p);
 621.143 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.144 -	}
 621.145 -
 621.146 -	pCmdUI->Enable(bExist);
 621.147 -}
 621.148 -
 621.149 -void MainWnd::OnFileExit()
 621.150 -{
 621.151 -	if (AskSave())
 621.152 -		SendMessage(WM_CLOSE);
 621.153 -}
 621.154 -
 621.155 -void MainWnd::OnFileClose()
 621.156 -{
 621.157 -	// save battery file before we change the filename...
 621.158 -	CloseRamWindows();
 621.159 -	winFileClose();
 621.160 -}
 621.161 -
 621.162 -void MainWnd::OnUpdateFileClose(CCmdUI *pCmdUI)
 621.163 -{
 621.164 -	pCmdUI->Enable(emulating);
 621.165 -}
 621.166 -
 621.167 -void MainWnd::OnFileLoad()
 621.168 -{
 621.169 -	theApp.winCheckFullscreen();
 621.170 -
 621.171 -	LPCTSTR exts[] = { ".sgm", NULL };
 621.172 -	CString filter = winResLoadFilter(IDS_FILTER_SGM);
 621.173 -	CString title  = winResLoadString(IDS_SELECT_SAVE_GAME_NAME);
 621.174 -
 621.175 -	CString saveName = winGetDestFilename(theApp.gameFilename, IDS_SAVE_DIR, exts[0]);
 621.176 -	CString saveDir	 = winGetDestDir(IDS_SAVE_DIR);
 621.177 -
 621.178 -	FileDlg dlg(this, saveName, filter, 0, "SGM", exts, saveDir, title, false, true);
 621.179 -
 621.180 -	if (dlg.DoModal() == IDOK)
 621.181 -	{
 621.182 -		bool res = winReadSaveGame(dlg.GetPathName());
 621.183 -
 621.184 -		theApp.rewindCount		= 0;
 621.185 -		theApp.rewindCounter	= 0;
 621.186 -		theApp.rewindSaveNeeded = false;
 621.187 -
 621.188 -		if (res)
 621.189 -		{
 621.190 -			if (VBAMovieActive() && !VBAMovieReadOnly())
 621.191 -			{
 621.192 -				VBAMovieSwitchToRecording();
 621.193 -			}
 621.194 -			systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
 621.195 -		}
 621.196 -	}
 621.197 -}
 621.198 -
 621.199 -void MainWnd::OnUpdateFileLoad(CCmdUI *pCmdUI)
 621.200 -{
 621.201 -	pCmdUI->Enable(emulating);
 621.202 -}
 621.203 -
 621.204 -BOOL MainWnd::OnFileLoadSlot(UINT nID)
 621.205 -{
 621.206 -	nID = nID + 1 - ID_FILE_LOADGAME_SLOT1;
 621.207 -
 621.208 -	CString filename = winGetSavestateFilename(theApp.gameFilename, nID);
 621.209 -
 621.210 -	bool res = winReadSaveGame(filename);
 621.211 -
 621.212 -	// deleting rewinds because you loaded a save state is stupid
 621.213 -///  theApp.rewindCount = 0;
 621.214 -///  theApp.rewindCounter = 0;
 621.215 -///  theApp.rewindSaveNeeded = false;
 621.216 -
 621.217 -	if (res)
 621.218 -	{
 621.219 -		CString format;
 621.220 -		if (VBAMovieActive())
 621.221 -		{
 621.222 -			if (VBAMovieReadOnly())
 621.223 -			{
 621.224 -				format = winResLoadString(IDS_REPLAYED_STATE_N);
 621.225 -			}
 621.226 -			else
 621.227 -			{
 621.228 -				VBAMovieSwitchToRecording();
 621.229 -				format = winResLoadString(IDS_RERECORDED_STATE_N);
 621.230 -			}
 621.231 -		}
 621.232 -		else
 621.233 -		{
 621.234 -			format = winResLoadString(IDS_LOADED_STATE_N);
 621.235 -		}
 621.236 -
 621.237 -		CString buffer;
 621.238 -		buffer.Format(format, nID);
 621.239 -		systemScreenMessage(buffer);
 621.240 -
 621.241 -		int lastSlot = theApp.currentSlot;
 621.242 -
 621.243 -		if (theApp.loadMakesRecent)
 621.244 -		{
 621.245 -			// to update the file's modification date
 621.246 -			SYSTEMTIME st;
 621.247 -			FILETIME   ft;
 621.248 -			GetSystemTime(&st);
 621.249 -			SystemTimeToFileTime(&st, &ft);
 621.250 -			HANDLE fh = CreateFile(filename, 
 621.251 -									GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 
 621.252 -									NULL, 
 621.253 -									OPEN_EXISTING, 
 621.254 -									0, 
 621.255 -									NULL);
 621.256 -			if (fh != INVALID_HANDLE_VALUE)
 621.257 -				SetFileTime(fh, NULL, NULL, &ft);
 621.258 -			CloseHandle(fh);
 621.259 -		}
 621.260 -
 621.261 -		if (theApp.loadMakesCurrent)
 621.262 -			theApp.currentSlot = nID - 1;
 621.263 -		else
 621.264 -			theApp.currentSlot = lastSlot;  // restore value in case the call to OnFileSaveSlot changed it
 621.265 -
 621.266 -		theApp.frameSearching	   = false;
 621.267 -		theApp.frameSearchSkipping = false;
 621.268 -	}
 621.269 -
 621.270 -	return res;
 621.271 -}
 621.272 -
 621.273 -void MainWnd::OnFileSave()
 621.274 -{
 621.275 -	theApp.winCheckFullscreen();
 621.276 -
 621.277 -	LPCTSTR exts[] = { ".sgm", NULL };
 621.278 -	CString filter = winResLoadFilter(IDS_FILTER_SGM);
 621.279 -	CString title  = winResLoadString(IDS_SELECT_SAVE_GAME_NAME);
 621.280 -
 621.281 -	CString saveName = winGetDestFilename(theApp.gameFilename, IDS_SAVE_DIR, exts[0]);
 621.282 -	CString saveDir	 = winGetDestDir(IDS_SAVE_DIR);
 621.283 -
 621.284 -	FileDlg dlg(this, saveName, filter, 0, "SGM", exts, saveDir, title, true);
 621.285 -
 621.286 -	if (dlg.DoModal() == IDOK)
 621.287 -	{
 621.288 -		bool res = winWriteSaveGame(dlg.GetPathName());
 621.289 -		if (res)
 621.290 -			systemScreenMessage(winResLoadString(IDS_WROTE_STATE));
 621.291 -	}
 621.292 -}
 621.293 -
 621.294 -void MainWnd::OnUpdateFileSave(CCmdUI *pCmdUI)
 621.295 -{
 621.296 -	pCmdUI->Enable(emulating);
 621.297 -}
 621.298 -
 621.299 -BOOL MainWnd::OnFileSaveSlot(UINT nID)
 621.300 -{
 621.301 -	nID = nID + 1 - ID_FILE_SAVEGAME_SLOT1;
 621.302 -
 621.303 -	if (theApp.saveMakesCurrent)
 621.304 -		theApp.currentSlot = nID - 1;
 621.305 -
 621.306 -	CString filename = winGetSavestateFilename(theApp.gameFilename, nID);
 621.307 -
 621.308 -	bool res = winWriteSaveGame(filename);
 621.309 -
 621.310 -	CString format = winResLoadString(IDS_WROTE_STATE_N);
 621.311 -	CString buffer;
 621.312 -	buffer.Format(format, nID);
 621.313 -
 621.314 -	systemScreenMessage(buffer);
 621.315 -
 621.316 -	return res;
 621.317 -}
 621.318 -
 621.319 -BOOL MainWnd::OnSelectSlot(UINT nID)
 621.320 -{
 621.321 -	nID -= ID_SELECT_SLOT1;
 621.322 -	theApp.currentSlot = nID;
 621.323 -
 621.324 -	CString buffer;
 621.325 -	buffer.Format("Slot %d selected", nID + 1);
 621.326 -	systemScreenMessage(buffer, 0);
 621.327 -
 621.328 -	return true;
 621.329 -}
 621.330 -
 621.331 -void MainWnd::OnFileImportBatteryfile()
 621.332 -{
 621.333 -	theApp.winCheckFullscreen();
 621.334 -
 621.335 -	LPCTSTR exts[] = { ".sav", NULL };
 621.336 -	CString filter = winResLoadFilter(IDS_FILTER_SAV);
 621.337 -	CString title  = winResLoadString(IDS_SELECT_BATTERY_FILE);
 621.338 -
 621.339 -	CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, exts[0]);
 621.340 -	CString batteryDir	= winGetDestDir(IDS_BATTERY_DIR);
 621.341 -
 621.342 -	FileDlg dlg(this, batteryName, filter, 0, "SAV", exts, batteryDir, title, false, true);
 621.343 -
 621.344 -	if (dlg.DoModal() == IDCANCEL)
 621.345 -		return;
 621.346 -
 621.347 -	CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST);
 621.348 -	CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
 621.349 -
 621.350 -	systemSoundClearBuffer();
 621.351 -	if (MessageBox(str1,
 621.352 -	               str2,
 621.353 -	               MB_OKCANCEL) == IDCANCEL)
 621.354 -		return;
 621.355 -
 621.356 -	bool res = false;
 621.357 -
 621.358 -	res = theApp.emulator.emuReadBattery(dlg.GetPathName());
 621.359 -
 621.360 -	if (!res)
 621.361 -		systemMessage(MSG_CANNOT_OPEN_FILE, "Cannot open file %s", dlg.GetPathName());
 621.362 -	else
 621.363 -	{
 621.364 -		theApp.emulator.emuReset(true);
 621.365 -	}
 621.366 -}
 621.367 -
 621.368 -void MainWnd::OnUpdateFileImportBatteryfile(CCmdUI *pCmdUI)
 621.369 -{
 621.370 -	// we allow this as we allow using cheats during recording
 621.371 -	pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
 621.372 -}
 621.373 -
 621.374 -void MainWnd::OnFileImportGamesharkcodefile()
 621.375 -{
 621.376 -	theApp.winCheckFullscreen();
 621.377 -
 621.378 -	LPCTSTR exts[] = { NULL };
 621.379 -	CString filter = systemCartridgeType == 0 ? winResLoadFilter(IDS_FILTER_SPC) : winResLoadFilter(IDS_FILTER_GCF);
 621.380 -	CString title  = winResLoadString(IDS_SELECT_CODE_FILE);
 621.381 -
 621.382 -	FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true);
 621.383 -
 621.384 -	if (dlg.DoModal() == IDCANCEL)
 621.385 -		return;
 621.386 -
 621.387 -	CString str1 = winResLoadString(IDS_CODES_WILL_BE_LOST);
 621.388 -	CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
 621.389 -
 621.390 -	systemSoundClearBuffer();
 621.391 -	if (MessageBox(str1,
 621.392 -	               str2,
 621.393 -	               MB_OKCANCEL) == IDCANCEL)
 621.394 -		return;
 621.395 -
 621.396 -	CString file = dlg.GetPathName();
 621.397 -	bool	res	 = winImportGSACodeFile(file);
 621.398 -}
 621.399 -
 621.400 -void MainWnd::OnUpdateFileImportGamesharkcodefile(CCmdUI *pCmdUI)
 621.401 -{
 621.402 -	pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
 621.403 -}
 621.404 -
 621.405 -void MainWnd::OnFileImportGamesharksnapshot()
 621.406 -{
 621.407 -	theApp.winCheckFullscreen();
 621.408 -
 621.409 -	LPCTSTR exts[] = { NULL };
 621.410 -	CString filter = systemCartridgeType == 1 ? winResLoadFilter(IDS_FILTER_GBS) : winResLoadFilter(IDS_FILTER_SPS);
 621.411 -	CString title  = winResLoadString(IDS_SELECT_SNAPSHOT_FILE);
 621.412 -
 621.413 -	FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true);
 621.414 -
 621.415 -	if (dlg.DoModal() == IDCANCEL)
 621.416 -		return;
 621.417 -
 621.418 -	CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST);
 621.419 -	CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
 621.420 -
 621.421 -	systemSoundClearBuffer();
 621.422 -	if (MessageBox(str1,
 621.423 -	               str2,
 621.424 -	               MB_OKCANCEL) == IDCANCEL)
 621.425 -		return;
 621.426 -
 621.427 -	if (systemCartridgeType == 1)
 621.428 -		gbReadGSASnapshot(dlg.GetPathName());
 621.429 -	else
 621.430 -		CPUReadGSASnapshot(dlg.GetPathName());
 621.431 -}
 621.432 -
 621.433 -void MainWnd::OnUpdateFileImportGamesharksnapshot(CCmdUI *pCmdUI)
 621.434 -{
 621.435 -	pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
 621.436 -}
 621.437 -
 621.438 -void MainWnd::OnFileExportBatteryfile()
 621.439 -{
 621.440 -	theApp.winCheckFullscreen();
 621.441 -
 621.442 -	LPCTSTR exts[] = { ".sav", ".dat", NULL };
 621.443 -	CString filter = winResLoadFilter(IDS_FILTER_SAV);
 621.444 -	CString title  = winResLoadString(IDS_SELECT_BATTERY_FILE);
 621.445 -
 621.446 -	CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, exts[0]);
 621.447 -	CString batteryDir	= winGetDestDir(IDS_BATTERY_DIR);
 621.448 -
 621.449 -	FileDlg dlg(this, batteryName, filter, 1, "SAV", exts, batteryDir, title, true);
 621.450 -
 621.451 -	if (dlg.DoModal() == IDCANCEL)
 621.452 -	{
 621.453 -		return;
 621.454 -	}
 621.455 -
 621.456 -	bool result = false;
 621.457 -
 621.458 -	if (systemCartridgeType == 1)
 621.459 -	{
 621.460 -		result = gbWriteBatteryFile(dlg.GetPathName(), false);
 621.461 -	}
 621.462 -	else
 621.463 -		result = theApp.emulator.emuWriteBattery(dlg.GetPathName());
 621.464 -
 621.465 -	if (!result)
 621.466 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
 621.467 -		              dlg.GetPathName());
 621.468 -}
 621.469 -
 621.470 -void MainWnd::OnUpdateFileExportBatteryfile(CCmdUI *pCmdUI)
 621.471 -{
 621.472 -	pCmdUI->Enable(emulating);
 621.473 -}
 621.474 -
 621.475 -void MainWnd::OnFileExportGamesharksnapshot()
 621.476 -{
 621.477 -	theApp.winCheckFullscreen();
 621.478 -	if (eepromInUse)
 621.479 -	{
 621.480 -		systemMessage(IDS_EEPROM_NOT_SUPPORTED, "EEPROM saves cannot be exported");
 621.481 -		return;
 621.482 -	}
 621.483 -
 621.484 -	LPCTSTR exts[] = { ".sps", NULL };
 621.485 -
 621.486 -	CString filter = winResLoadFilter(IDS_FILTER_SPS);
 621.487 -	CString title  = winResLoadString(IDS_SELECT_SNAPSHOT_FILE);
 621.488 -
 621.489 -	CString name = winGetDestFilename(theApp.gameFilename, CString(), exts[0]);
 621.490 -
 621.491 -	FileDlg dlg(this, name, filter, 1, "SPS", exts, "", title, true);
 621.492 -
 621.493 -	if (dlg.DoModal() == IDCANCEL)
 621.494 -		return;
 621.495 -
 621.496 -	char buffer[16];
 621.497 -	strncpy(buffer, (const char *)&rom[0xa0], 12);
 621.498 -	buffer[12] = 0;
 621.499 -
 621.500 -	ExportGSASnapshot dlg2(dlg.GetPathName(), buffer, this);
 621.501 -	dlg2.DoModal();
 621.502 -}
 621.503 -
 621.504 -void MainWnd::OnUpdateFileExportGamesharksnapshot(CCmdUI *pCmdUI)
 621.505 -{
 621.506 -	pCmdUI->Enable(emulating && systemCartridgeType == 0);
 621.507 -}
 621.508 -
 621.509 -void MainWnd::OnFileQuickScreencapture()
 621.510 -{
 621.511 -	extern int32 captureNumber;   // GBAGlobals.cpp
 621.512 -	captureNumber = winScreenCapture(captureNumber);
 621.513 -}
 621.514 -
 621.515 -void MainWnd::OnFileScreencapture()
 621.516 -{
 621.517 -	theApp.winCheckFullscreen();
 621.518 -
 621.519 -	LPCTSTR exts[] = { ".png", ".bmp", NULL };
 621.520 -
 621.521 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 621.522 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 621.523 -
 621.524 -	CString ext;
 621.525 -
 621.526 -	if (theApp.captureFormat != 0)
 621.527 -		ext.Format(".bmp");
 621.528 -	else
 621.529 -		ext.Format(".png");
 621.530 -
 621.531 -	CString captureName = winGetDestFilename(theApp.gameFilename, IDS_CAPTURE_DIR, ext);
 621.532 -	CString captureDir	= winGetDestDir(IDS_CAPTURE_DIR);
 621.533 -
 621.534 -	FileDlg dlg(this,
 621.535 -	            captureName,
 621.536 -	            filter,
 621.537 -	            theApp.captureFormat ? 2 : 1,
 621.538 -	            theApp.captureFormat ? "BMP" : "PNG",
 621.539 -	            exts,
 621.540 -	            captureDir,
 621.541 -	            title,
 621.542 -	            true);
 621.543 -
 621.544 -	if (dlg.DoModal() == IDCANCEL)
 621.545 -		return;
 621.546 -
 621.547 -	if (dlg.getFilterIndex() == 2)
 621.548 -		theApp.emulator.emuWriteBMP(dlg.GetPathName());
 621.549 -	else
 621.550 -		theApp.emulator.emuWritePNG(dlg.GetPathName());
 621.551 -
 621.552 -	systemScreenMessage(winResLoadString(IDS_SCREEN_CAPTURE));
 621.553 -}
 621.554 -
 621.555 -void MainWnd::OnUpdateFileScreencapture(CCmdUI *pCmdUI)
 621.556 -{
 621.557 -	pCmdUI->Enable(emulating);
 621.558 -}
 621.559 -
 621.560 -void MainWnd::OnFileRominformation()
 621.561 -{
 621.562 -	theApp.winCheckFullscreen();
 621.563 -	if (systemCartridgeType == 0)
 621.564 -	{
 621.565 -		RomInfoGBA dlg(rom);
 621.566 -		dlg.DoModal();
 621.567 -	}
 621.568 -	else
 621.569 -	{
 621.570 -		RomInfoGB dlg(gbRom);
 621.571 -		dlg.DoModal();
 621.572 -	}
 621.573 -}
 621.574 -
 621.575 -void MainWnd::OnUpdateFileRominformation(CCmdUI *pCmdUI)
 621.576 -{
 621.577 -	pCmdUI->Enable(emulating);
 621.578 -}
 621.579 -
 621.580 -void MainWnd::OnFileTogglemenu()
 621.581 -{
 621.582 -	theApp.menuToggle = !theApp.menuToggle;
 621.583 -
 621.584 -	if (theApp.menuToggle)
 621.585 -	{
 621.586 -		SetMenu(&theApp.m_menu);
 621.587 -		if (theApp.tripleBuffering)
 621.588 -		{
 621.589 -			if (theApp.display)
 621.590 -				theApp.display->renderMenu();
 621.591 -		}
 621.592 -	}
 621.593 -	else
 621.594 -	{
 621.595 -		SetMenu(NULL);
 621.596 -	}
 621.597 -
 621.598 -	theApp.adjustDestRect();
 621.599 -}
 621.600 -
 621.601 -void MainWnd::OnUpdateFileTogglemenu(CCmdUI *pCmdUI)
 621.602 -{
 621.603 -	pCmdUI->Enable(theApp.videoOption > VIDEO_4X);
 621.604 -}
 621.605 -
 621.606 -void MainWnd::OnFileSavegameOldestslot()
 621.607 -{
 621.608 -	if (!emulating)
 621.609 -		return;
 621.610 -
 621.611 -	CFileStatus status;
 621.612 -	CString		str;
 621.613 -	time_t		time  = -1;
 621.614 -	int			found = -1;
 621.615 -
 621.616 -	for (int i = 0; i < 10; i++)
 621.617 -	{
 621.618 -		if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
 621.619 -		{
 621.620 -			if (time - status.m_mtime.GetTime() > 0 || time == -1)
 621.621 -			{
 621.622 -				time  = (time_t)status.m_mtime.GetTime();
 621.623 -				found = i;
 621.624 -			}
 621.625 -		}
 621.626 -		else
 621.627 -		{
 621.628 -			found = i;
 621.629 -			break;
 621.630 -		}
 621.631 -	}
 621.632 -
 621.633 -	OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1 + found);
 621.634 -}
 621.635 -
 621.636 -void MainWnd::OnUpdateFileSavegameOldestslot(CCmdUI *pCmdUI)
 621.637 -{
 621.638 -	bool enabled = emulating;
 621.639 -	if (pCmdUI->m_pMenu != NULL)
 621.640 -	{
 621.641 -		CFileStatus status;
 621.642 -		time_t		time  = -1;
 621.643 -		int			found = -1;
 621.644 -
 621.645 -		if (emulating)
 621.646 -		{
 621.647 -			for (int i = 0; i < 10; i++)
 621.648 -			{
 621.649 -				if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
 621.650 -				{
 621.651 -					if (time - status.m_mtime.GetTime() > 0 || time == -1)
 621.652 -					{
 621.653 -						time  = (time_t)status.m_mtime.GetTime();
 621.654 -						found = i;
 621.655 -					}
 621.656 -				}
 621.657 -				else
 621.658 -				{
 621.659 -					found = i;
 621.660 -					break;
 621.661 -				}
 621.662 -			}
 621.663 -		}
 621.664 -
 621.665 -		CString str;
 621.666 -		enabled = (found != -1);
 621.667 -		if (enabled)
 621.668 -			str.Format("&Oldest Slot (#%d)", found + 1);
 621.669 -		else
 621.670 -			str.Format("&Oldest Slot", found + 1);
 621.671 -
 621.672 -		pCmdUI->SetText(str);
 621.673 -
 621.674 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.675 -	}
 621.676 -
 621.677 -	pCmdUI->Enable(enabled);
 621.678 -}
 621.679 -
 621.680 -void MainWnd::OnFileLoadgameMostrecent()
 621.681 -{
 621.682 -	if (!emulating)
 621.683 -		return;
 621.684 -
 621.685 -	CFileStatus status;
 621.686 -	CString		str;
 621.687 -	time_t		time  = 0;
 621.688 -	int			found = -1;
 621.689 -
 621.690 -	for (int i = 0; i < 10; i++)
 621.691 -	{
 621.692 -		if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
 621.693 -		{
 621.694 -			if (status.m_mtime.GetTime() > time)
 621.695 -			{
 621.696 -				time  = (time_t)status.m_mtime.GetTime();
 621.697 -				found = i;
 621.698 -			}
 621.699 -		}
 621.700 -	}
 621.701 -
 621.702 -	if (found != -1)
 621.703 -	{
 621.704 -		OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1 + found);
 621.705 -	}
 621.706 -}
 621.707 -
 621.708 -void MainWnd::OnUpdateFileLoadgameMostrecent(CCmdUI *pCmdUI)
 621.709 -{
 621.710 -	bool enabled = emulating;
 621.711 -	if (pCmdUI->m_pMenu != NULL)
 621.712 -	{
 621.713 -		CFileStatus status;
 621.714 -		int			found = -1;
 621.715 -
 621.716 -		time_t time = 0;
 621.717 -		if (emulating)
 621.718 -		{
 621.719 -			for (int i = 0; i < 10; i++)
 621.720 -			{
 621.721 -				if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
 621.722 -				{
 621.723 -					if (status.m_mtime.GetTime() > time)
 621.724 -					{
 621.725 -						time  = (time_t)status.m_mtime.GetTime();
 621.726 -						found = i;
 621.727 -					}
 621.728 -				}
 621.729 -			}
 621.730 -		}
 621.731 -
 621.732 -		CString str;
 621.733 -		enabled = (found != -1);
 621.734 -		if (enabled)
 621.735 -			str.Format("Most &Recent Slot (#%d)", found + 1);
 621.736 -		else
 621.737 -			str.Format("Most &Recent Slot", found + 1);
 621.738 -
 621.739 -		pCmdUI->SetText(str);
 621.740 -
 621.741 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.742 -	}
 621.743 -
 621.744 -	pCmdUI->Enable(enabled);
 621.745 -}
 621.746 -
 621.747 -void MainWnd::OnUpdateFileLoadSlot(CCmdUI *pCmdUI)
 621.748 -{
 621.749 -	int slotID = pCmdUI->m_nID - ID_FILE_LOADGAME_SLOT1 + 1;
 621.750 -
 621.751 -	if (pCmdUI->m_pMenu != NULL)
 621.752 -	{
 621.753 -		pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slotID));
 621.754 -
 621.755 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.756 -	}
 621.757 -
 621.758 -	pCmdUI->Enable(emulating && winFileExists(winGetSavestateFilename(theApp.gameFilename, slotID)));
 621.759 -}
 621.760 -
 621.761 -void MainWnd::OnUpdateFileSaveSlot(CCmdUI *pCmdUI)
 621.762 -{
 621.763 -	if (pCmdUI->m_pMenu != NULL)
 621.764 -	{
 621.765 -		int slotID = pCmdUI->m_nID - ID_FILE_SAVEGAME_SLOT1 + 1;
 621.766 -
 621.767 -		pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slotID));
 621.768 -
 621.769 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.770 -	}
 621.771 -
 621.772 -	pCmdUI->Enable(emulating);
 621.773 -}
 621.774 -
 621.775 -void MainWnd::OnUpdateSelectSlot(CCmdUI *pCmdUI)
 621.776 -{
 621.777 -	if (pCmdUI->m_pMenu != NULL)
 621.778 -	{
 621.779 -		int slot = pCmdUI->m_nID - ID_SELECT_SLOT1;
 621.780 -
 621.781 -		pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slot + 1));
 621.782 -
 621.783 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.784 -
 621.785 -		pCmdUI->SetCheck(slot == theApp.currentSlot);
 621.786 -	}
 621.787 -}
 621.788 -
 621.789 -void MainWnd::OnFileLoadgameAutoloadmostrecent()
 621.790 -{
 621.791 -	theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent;
 621.792 -}
 621.793 -
 621.794 -void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI *pCmdUI)
 621.795 -{
 621.796 -	pCmdUI->SetCheck(theApp.autoLoadMostRecent);
 621.797 -}
 621.798 -
 621.799 -void MainWnd::OnFileLoadgameMakeRecent()
 621.800 -{
 621.801 -	theApp.loadMakesRecent = !theApp.loadMakesRecent;
 621.802 -}
 621.803 -
 621.804 -void MainWnd::OnUpdateFileLoadgameMakeRecent(CCmdUI *pCmdUI)
 621.805 -{
 621.806 -	pCmdUI->SetCheck(theApp.loadMakesRecent);
 621.807 -}
 621.808 -
 621.809 -void MainWnd::OnFileSavegameCurrent()
 621.810 -{
 621.811 -	OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1 + theApp.currentSlot);
 621.812 -}
 621.813 -
 621.814 -void MainWnd::OnUpdateFileSavegameCurrent(CCmdUI *pCmdUI)
 621.815 -{
 621.816 -	if (pCmdUI->m_pMenu != NULL)
 621.817 -	{
 621.818 -		int slotID = theApp.currentSlot + 1;
 621.819 -
 621.820 -		CString str;
 621.821 -		str.Format("&Current Slot (#%d)", slotID);
 621.822 -
 621.823 -		pCmdUI->SetText(str);
 621.824 -
 621.825 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.826 -	}
 621.827 -
 621.828 -	pCmdUI->Enable(emulating);
 621.829 -}
 621.830 -
 621.831 -void MainWnd::OnFileLoadgameCurrent()
 621.832 -{
 621.833 -	OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1 + theApp.currentSlot);
 621.834 -}
 621.835 -
 621.836 -void MainWnd::OnUpdateFileLoadgameCurrent(CCmdUI *pCmdUI)
 621.837 -{
 621.838 -	int slotID = theApp.currentSlot + 1;
 621.839 -
 621.840 -	if (pCmdUI->m_pMenu != NULL)
 621.841 -	{
 621.842 -		CString str;
 621.843 -		str.Format("&Current Slot (#%d)", slotID);
 621.844 -
 621.845 -		pCmdUI->SetText(str);
 621.846 -
 621.847 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.848 -	}
 621.849 -
 621.850 -	CFileStatus status;
 621.851 -	pCmdUI->Enable(emulating && CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, slotID), status));
 621.852 -}
 621.853 -
 621.854 -void MainWnd::OnFileLoadgameMakeCurrent()
 621.855 -{
 621.856 -	theApp.loadMakesCurrent = !theApp.loadMakesCurrent;
 621.857 -}
 621.858 -
 621.859 -void MainWnd::OnUpdateFileLoadgameMakeCurrent(CCmdUI *pCmdUI)
 621.860 -{
 621.861 -	pCmdUI->SetCheck(theApp.loadMakesCurrent);
 621.862 -}
 621.863 -
 621.864 -void MainWnd::OnFileSavegameMakeCurrent()
 621.865 -{
 621.866 -	theApp.saveMakesCurrent = !theApp.saveMakesCurrent;
 621.867 -}
 621.868 -
 621.869 -void MainWnd::OnUpdateFileSavegameMakeCurrent(CCmdUI *pCmdUI)
 621.870 -{
 621.871 -	pCmdUI->SetCheck(theApp.saveMakesCurrent);
 621.872 -}
 621.873 -
 621.874 -void MainWnd::OnFileSavegameIncrementSlot()
 621.875 -{
 621.876 -	theApp.currentSlot = (theApp.currentSlot + 1) % 10;
 621.877 -
 621.878 -	char str [32];
 621.879 -	sprintf(str, "Current Slot: %d", theApp.currentSlot + 1);
 621.880 -	systemScreenMessage(str, 0);
 621.881 -}
 621.882 -
 621.883 -void MainWnd::OnUpdateFileSavegameIncrementSlot(CCmdUI *pCmdUI)
 621.884 -{
 621.885 -	if (pCmdUI->m_pMenu != NULL)
 621.886 -	{
 621.887 -		int slotID = theApp.currentSlot + 1;
 621.888 -
 621.889 -		CString str;
 621.890 -		str.Format("&Increase Current Slot (#%d -> #%d)", slotID, slotID % 10 + 1);
 621.891 -
 621.892 -		pCmdUI->SetText(str);
 621.893 -
 621.894 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.895 -	}
 621.896 -}
 621.897 -
 621.898 -void MainWnd::OnFileSavegameDecrementSlot()
 621.899 -{
 621.900 -	theApp.currentSlot = (theApp.currentSlot + 9) % 10;
 621.901 -
 621.902 -	char str [32];
 621.903 -	sprintf(str, "Current Slot: %d", theApp.currentSlot + 1);
 621.904 -	systemScreenMessage(str, 0);
 621.905 -}
 621.906 -
 621.907 -void MainWnd::OnUpdateFileSavegameDecrementSlot(CCmdUI *pCmdUI)
 621.908 -{
 621.909 -	if (pCmdUI->m_pMenu != NULL)
 621.910 -	{
 621.911 -		int slotID = theApp.currentSlot + 1;
 621.912 -
 621.913 -		CString str;
 621.914 -		str.Format("&Decrease Current Slot (#%d -> #%d)", slotID, (slotID + 8) % 10 + 1);
 621.915 -
 621.916 -		pCmdUI->SetText(str);
 621.917 -
 621.918 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 621.919 -	}
 621.920 -}
 621.921 -
 621.922 -void MainWnd::OnFileSlotDisplayModificationTime()
 621.923 -{
 621.924 -	theApp.showSlotTime = !theApp.showSlotTime;
 621.925 -}
 621.926 -
 621.927 -void MainWnd::OnUpdateFileSlotDisplayModificationTime(CCmdUI *pCmdUI)
 621.928 -{
 621.929 -	pCmdUI->SetCheck(theApp.showSlotTime);
 621.930 -}
 621.931 -
 621.932 -void MainWnd::OnFileLuaOpen()
 621.933 -{
 621.934 -	theApp.winCheckFullscreen();
 621.935 -
 621.936 -	if (!LuaConsoleHWnd)
 621.937 -	{
 621.938 -		LuaConsoleHWnd = ::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_LUA), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) DlgLuaScriptDialog);
 621.939 -	}
 621.940 -	else
 621.941 -		::SetForegroundWindow(LuaConsoleHWnd);
 621.942 -}
 621.943 -
 621.944 -void MainWnd::OnUpdateFileLuaOpen(CCmdUI *pCmdUI)
 621.945 -{
 621.946 -	pCmdUI->SetCheck(LuaConsoleHWnd != NULL);
 621.947 -	pCmdUI->Enable(true);
 621.948 -}
 621.949 -
 621.950 -void MainWnd::OnFileLuaCloseAll()
 621.951 -{
 621.952 -	if (LuaConsoleHWnd)
 621.953 -		::PostMessage(LuaConsoleHWnd, WM_CLOSE, 0, 0);
 621.954 -}
 621.955 -
 621.956 -void MainWnd::OnFileLuaReload()
 621.957 -{
 621.958 -	VBAReloadLuaCode();
 621.959 -}
 621.960 -
 621.961 -void MainWnd::OnFileLuaStop()
 621.962 -{
 621.963 -	VBALuaStop();
 621.964 -}
 621.965 -
 621.966 -void MainWnd::OnFileRamSearch()
 621.967 -{
 621.968 -	theApp.winCheckFullscreen();
 621.969 -
 621.970 -	if (!RamSearchHWnd)
 621.971 -	{
 621.972 -		reset_address_info();
 621.973 -		LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 621.974 -		::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_RAMSEARCH), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) RamSearchProc);
 621.975 -	}
 621.976 -	else
 621.977 -		::SetForegroundWindow(RamSearchHWnd);
 621.978 -}
 621.979 -
 621.980 -void MainWnd::OnUpdateFileRamSearch(CCmdUI *pCmdUI)
 621.981 -{
 621.982 -	pCmdUI->Enable(TRUE);
 621.983 -}
 621.984 -
 621.985 -void MainWnd::OnFileRamWatch()
 621.986 -{
 621.987 -	theApp.winCheckFullscreen();
 621.988 -
 621.989 -	if (!RamWatchHWnd)
 621.990 -	{
 621.991 -		LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 621.992 -		RamWatchHWnd = ::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_RAMWATCH), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) RamWatchProc);
 621.993 -	}
 621.994 -	else
 621.995 -		::SetForegroundWindow(RamWatchHWnd);
 621.996 -}
 621.997 -
 621.998 -void MainWnd::OnUpdateFileRamWatch(CCmdUI *pCmdUI)
 621.999 -{
621.1000 -	pCmdUI->Enable(TRUE);
621.1001 -}
621.1002 -
621.1003 -void MainWnd::OnUpdateFileLuaCloseAll(CCmdUI *pCmdUI)
621.1004 -{
621.1005 -	pCmdUI->Enable(LuaConsoleHWnd != NULL);
621.1006 -}
621.1007 -
   622.1 --- a/src/win32/MainWndHelp.cpp	Sat Mar 03 10:54:39 2012 -0600
   622.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   622.3 @@ -1,30 +0,0 @@
   622.4 -#include "stdafx.h"
   622.5 -#include "resource.h"
   622.6 -#include "MainWnd.h"
   622.7 -#include "AboutDialog.h"
   622.8 -#include "BugReport.h"
   622.9 -#include "VBA.h"
  622.10 -
  622.11 -extern int emulating;
  622.12 -
  622.13 -void MainWnd::OnHelpAbout()
  622.14 -{
  622.15 -	theApp.winCheckFullscreen();
  622.16 -	AboutDialog dlg;
  622.17 -
  622.18 -	dlg.DoModal();
  622.19 -}
  622.20 -
  622.21 -void MainWnd::OnHelpFaq()
  622.22 -{
  622.23 -	::ShellExecute(0, _T("open"), "http://vba.ngemu.com/faq.shtml",
  622.24 -	               0, 0, SW_SHOWNORMAL);
  622.25 -}
  622.26 -
  622.27 -void MainWnd::OnHelpBugreport()
  622.28 -{
  622.29 -	BugReport dlg(theApp.m_pMainWnd);
  622.30 -
  622.31 -	dlg.DoModal();
  622.32 -}
  622.33 -
   623.1 --- a/src/win32/MainWndOptions.cpp	Sat Mar 03 10:54:39 2012 -0600
   623.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   623.3 @@ -1,2309 +0,0 @@
   623.4 -#include "stdafx.h"
   623.5 -#include "resource.h"
   623.6 -#include "MainWnd.h"
   623.7 -#include "Associate.h"
   623.8 -#include "Directories.h"
   623.9 -#include "FileDlg.h"
  623.10 -#include "GBColorDlg.h"
  623.11 -#include "Joypad.h"
  623.12 -#include "MaxScale.h"
  623.13 -#include "ModeConfirm.h"
  623.14 -#include "Reg.h"
  623.15 -#include "RewindInterval.h"
  623.16 -#include "Throttle.h"
  623.17 -#include "TextOptions.h"
  623.18 -#include "WinResUtil.h"
  623.19 -#include "VBA.h"
  623.20 -
  623.21 -#include "../gba/GBA.h"
  623.22 -#include "../gba/GBAGlobals.h"
  623.23 -#include "../gba/Flash.h"
  623.24 -#include "../gba/GBASound.h"
  623.25 -#include "../gba/agbprint.h"
  623.26 -#include "../gb/GB.h"
  623.27 -#include "../gb/gbGlobals.h"
  623.28 -#include "../gb/gbPrinter.h"
  623.29 -#include "../common/inputGlobal.h"
  623.30 -#include "../common/movie.h"
  623.31 -#include "../version.h"
  623.32 -
  623.33 -extern int emulating;
  623.34 -
  623.35 -#define VBA_CONFIRM_MODE WM_APP + 100
  623.36 -
  623.37 -void MainWnd::OnOptionsFrameskipThrottleNothrottle()
  623.38 -{
  623.39 -	systemSetThrottle(0);
  623.40 -}
  623.41 -
  623.42 -void MainWnd::OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI*pCmdUI)
  623.43 -{
  623.44 -	pCmdUI->SetCheck(theApp.throttle == 0);
  623.45 -}
  623.46 -
  623.47 -void MainWnd::OnOptionsFrameskipThrottle6()
  623.48 -{
  623.49 -	systemSetThrottle(6);
  623.50 -}
  623.51 -
  623.52 -void MainWnd::OnUpdateOptionsFrameskipThrottle6(CCmdUI*pCmdUI)
  623.53 -{
  623.54 -	pCmdUI->SetCheck(theApp.throttle == 6);
  623.55 -}
  623.56 -
  623.57 -void MainWnd::OnOptionsFrameskipThrottle15()
  623.58 -{
  623.59 -	systemSetThrottle(15);
  623.60 -}
  623.61 -
  623.62 -void MainWnd::OnUpdateOptionsFrameskipThrottle15(CCmdUI*pCmdUI)
  623.63 -{
  623.64 -	pCmdUI->SetCheck(theApp.throttle == 15);
  623.65 -}
  623.66 -
  623.67 -void MainWnd::OnOptionsFrameskipThrottle25()
  623.68 -{
  623.69 -	systemSetThrottle(25);
  623.70 -}
  623.71 -
  623.72 -void MainWnd::OnUpdateOptionsFrameskipThrottle25(CCmdUI*pCmdUI)
  623.73 -{
  623.74 -	pCmdUI->SetCheck(theApp.throttle == 25);
  623.75 -}
  623.76 -
  623.77 -void MainWnd::OnOptionsFrameskipThrottle50()
  623.78 -{
  623.79 -	systemSetThrottle(50);
  623.80 -}
  623.81 -
  623.82 -void MainWnd::OnUpdateOptionsFrameskipThrottle50(CCmdUI*pCmdUI)
  623.83 -{
  623.84 -	pCmdUI->SetCheck(theApp.throttle == 50);
  623.85 -}
  623.86 -
  623.87 -void MainWnd::OnOptionsFrameskipThrottle75()
  623.88 -{
  623.89 -	systemSetThrottle(75);
  623.90 -}
  623.91 -
  623.92 -void MainWnd::OnUpdateOptionsFrameskipThrottle75(CCmdUI*pCmdUI)
  623.93 -{
  623.94 -	pCmdUI->SetCheck(theApp.throttle == 75);
  623.95 -}
  623.96 -
  623.97 -void MainWnd::OnOptionsFrameskipThrottle100()
  623.98 -{
  623.99 -	systemSetThrottle(100);
 623.100 -}
 623.101 -
 623.102 -void MainWnd::OnUpdateOptionsFrameskipThrottle100(CCmdUI*pCmdUI)
 623.103 -{
 623.104 -	pCmdUI->SetCheck(theApp.throttle == 100);
 623.105 -}
 623.106 -
 623.107 -void MainWnd::OnOptionsFrameskipThrottle125()
 623.108 -{
 623.109 -	systemSetThrottle(125);
 623.110 -}
 623.111 -
 623.112 -void MainWnd::OnUpdateOptionsFrameskipThrottle125(CCmdUI*pCmdUI)
 623.113 -{
 623.114 -	pCmdUI->SetCheck(theApp.throttle == 125);
 623.115 -}
 623.116 -
 623.117 -void MainWnd::OnOptionsFrameskipThrottle150()
 623.118 -{
 623.119 -	systemSetThrottle(150);
 623.120 -}
 623.121 -
 623.122 -void MainWnd::OnUpdateOptionsFrameskipThrottle150(CCmdUI*pCmdUI)
 623.123 -{
 623.124 -	pCmdUI->SetCheck(theApp.throttle == 150);
 623.125 -}
 623.126 -
 623.127 -void MainWnd::OnOptionsFrameskipThrottle200()
 623.128 -{
 623.129 -	systemSetThrottle(200);
 623.130 -}
 623.131 -
 623.132 -void MainWnd::OnUpdateOptionsFrameskipThrottle200(CCmdUI*pCmdUI)
 623.133 -{
 623.134 -	pCmdUI->SetCheck(theApp.throttle == 200);
 623.135 -}
 623.136 -
 623.137 -void MainWnd::OnOptionsFrameskipThrottle300()
 623.138 -{
 623.139 -	systemSetThrottle(300);
 623.140 -}
 623.141 -
 623.142 -void MainWnd::OnUpdateOptionsFrameskipThrottle300(CCmdUI*pCmdUI)
 623.143 -{
 623.144 -	pCmdUI->SetCheck(theApp.throttle == 300);
 623.145 -}
 623.146 -
 623.147 -void MainWnd::OnOptionsFrameskipThrottle400()
 623.148 -{
 623.149 -	systemSetThrottle(400);
 623.150 -}
 623.151 -
 623.152 -void MainWnd::OnUpdateOptionsFrameskipThrottle400(CCmdUI*pCmdUI)
 623.153 -{
 623.154 -	pCmdUI->SetCheck(theApp.throttle == 400);
 623.155 -}
 623.156 -
 623.157 -void MainWnd::OnOptionsFrameskipThrottle600()
 623.158 -{
 623.159 -	systemSetThrottle(600);
 623.160 -}
 623.161 -
 623.162 -void MainWnd::OnUpdateOptionsFrameskipThrottle600(CCmdUI*pCmdUI)
 623.163 -{
 623.164 -	pCmdUI->SetCheck(theApp.throttle == 600);
 623.165 -}
 623.166 -
 623.167 -void MainWnd::OnOptionsFrameskipThrottle1000()
 623.168 -{
 623.169 -	systemSetThrottle(1000);
 623.170 -}
 623.171 -
 623.172 -void MainWnd::OnUpdateOptionsFrameskipThrottle1000(CCmdUI*pCmdUI)
 623.173 -{
 623.174 -	pCmdUI->SetCheck(theApp.throttle == 1000);
 623.175 -}
 623.176 -
 623.177 -void MainWnd::OnOptionsFrameskipThrottleOther()
 623.178 -{
 623.179 -	Throttle dlg;
 623.180 -	int      v = dlg.DoModal();
 623.181 -	if (v)
 623.182 -		systemSetThrottle(v);
 623.183 -}
 623.184 -
 623.185 -void MainWnd::OnUpdateOptionsFrameskipThrottleOther(CCmdUI*pCmdUI)
 623.186 -{
 623.187 -}
 623.188 -
 623.189 -void MainWnd::OnOptionsFrameskipThrottleIncrease()
 623.190 -{
 623.191 -	systemIncreaseThrottle();
 623.192 -}
 623.193 -
 623.194 -void MainWnd::OnUpdateOptionsFrameskipThrottleIncrease(CCmdUI*pCmdUI)
 623.195 -{
 623.196 -}
 623.197 -
 623.198 -void MainWnd::OnOptionsFrameskipThrottleDecrease()
 623.199 -{
 623.200 -	systemDecreaseThrottle();
 623.201 -}
 623.202 -
 623.203 -void MainWnd::OnUpdateOptionsFrameskipThrottleDecrease(CCmdUI*pCmdUI)
 623.204 -{
 623.205 -}
 623.206 -
 623.207 -/*
 623.208 -   void MainWnd::OnOptionsFrameskipAutomatic()
 623.209 -   {
 623.210 -   theApp.autoFrameSkip = !theApp.autoFrameSkip;
 623.211 -   if(!theApp.autoFrameSkip && emulating)
 623.212 -    theApp.updateFrameSkip();
 623.213 -   }
 623.214 -
 623.215 -   void MainWnd::OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI)
 623.216 -   {
 623.217 -   pCmdUI->SetCheck(theApp.autoFrameSkip);
 623.218 -   }
 623.219 - */
 623.220 -
 623.221 -void MainWnd::OnOptionsFrameskipAccuratePitch()
 623.222 -{
 623.223 -	theApp.accuratePitchThrottle = true;
 623.224 -}
 623.225 -
 623.226 -void MainWnd::OnUpdateOptionsFrameskipAccuratePitch(CCmdUI*pCmdUI)
 623.227 -{
 623.228 -	pCmdUI->SetCheck(theApp.accuratePitchThrottle);
 623.229 -	pCmdUI->Enable(!soundOffFlag && synchronize);
 623.230 -}
 623.231 -
 623.232 -void MainWnd::OnOptionsFrameskipAccurateSpeed()
 623.233 -{
 623.234 -	theApp.accuratePitchThrottle = false;
 623.235 -}
 623.236 -
 623.237 -void MainWnd::OnUpdateOptionsFrameskipAccurateSpeed(CCmdUI*pCmdUI)
 623.238 -{
 623.239 -	pCmdUI->SetCheck(!theApp.accuratePitchThrottle);
 623.240 -	pCmdUI->Enable(!soundOffFlag && synchronize);
 623.241 -}
 623.242 -
 623.243 -BOOL MainWnd::OnOptionsFrameskip(UINT nID)
 623.244 -{
 623.245 -	switch (nID)
 623.246 -	{
 623.247 -	case ID_OPTIONS_VIDEO_FRAMESKIP_0:
 623.248 -	case ID_OPTIONS_VIDEO_FRAMESKIP_1:
 623.249 -	case ID_OPTIONS_VIDEO_FRAMESKIP_2:
 623.250 -	case ID_OPTIONS_VIDEO_FRAMESKIP_3:
 623.251 -	case ID_OPTIONS_VIDEO_FRAMESKIP_4:
 623.252 -	case ID_OPTIONS_VIDEO_FRAMESKIP_5:
 623.253 -	case ID_OPTIONS_VIDEO_FRAMESKIP_6:
 623.254 -	case ID_OPTIONS_VIDEO_FRAMESKIP_7:
 623.255 -	case ID_OPTIONS_VIDEO_FRAMESKIP_8:
 623.256 -	case ID_OPTIONS_VIDEO_FRAMESKIP_9:
 623.257 -		if (systemCartridgeType == 0)
 623.258 -		{
 623.259 -			frameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0;
 623.260 -		}
 623.261 -		else
 623.262 -		{
 623.263 -			gbFrameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0;
 623.264 -		}
 623.265 -		if (emulating)
 623.266 -			theApp.updateFrameSkip();
 623.267 -		return TRUE;
 623.268 -		break;
 623.269 -	}
 623.270 -	return FALSE;
 623.271 -}
 623.272 -
 623.273 -void MainWnd::OnUpdateOptionsVideoFrameskip0(CCmdUI*pCmdUI)
 623.274 -{
 623.275 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 0 : gbFrameSkip == 0);
 623.276 -}
 623.277 -
 623.278 -void MainWnd::OnUpdateOptionsVideoFrameskip1(CCmdUI*pCmdUI)
 623.279 -{
 623.280 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 1 : gbFrameSkip == 1);
 623.281 -}
 623.282 -
 623.283 -void MainWnd::OnUpdateOptionsVideoFrameskip2(CCmdUI*pCmdUI)
 623.284 -{
 623.285 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 2 : gbFrameSkip == 2);
 623.286 -}
 623.287 -
 623.288 -void MainWnd::OnUpdateOptionsVideoFrameskip3(CCmdUI*pCmdUI)
 623.289 -{
 623.290 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 3 : gbFrameSkip == 3);
 623.291 -}
 623.292 -
 623.293 -void MainWnd::OnUpdateOptionsVideoFrameskip4(CCmdUI*pCmdUI)
 623.294 -{
 623.295 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 4 : gbFrameSkip == 4);
 623.296 -}
 623.297 -
 623.298 -void MainWnd::OnUpdateOptionsVideoFrameskip5(CCmdUI*pCmdUI)
 623.299 -{
 623.300 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 5 : gbFrameSkip == 5);
 623.301 -}
 623.302 -
 623.303 -void MainWnd::OnUpdateOptionsVideoFrameskip6(CCmdUI*pCmdUI)
 623.304 -{
 623.305 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 6 : gbFrameSkip == 6);
 623.306 -}
 623.307 -
 623.308 -void MainWnd::OnUpdateOptionsVideoFrameskip7(CCmdUI*pCmdUI)
 623.309 -{
 623.310 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 7 : gbFrameSkip == 7);
 623.311 -}
 623.312 -
 623.313 -void MainWnd::OnUpdateOptionsVideoFrameskip8(CCmdUI*pCmdUI)
 623.314 -{
 623.315 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 8 : gbFrameSkip == 8);
 623.316 -}
 623.317 -
 623.318 -void MainWnd::OnUpdateOptionsVideoFrameskip9(CCmdUI*pCmdUI)
 623.319 -{
 623.320 -	pCmdUI->SetCheck(systemCartridgeType == 0 ? frameSkip == 9 : gbFrameSkip == 9);
 623.321 -}
 623.322 -
 623.323 -void MainWnd::OnOptionsVideoVsync()
 623.324 -{
 623.325 -	theApp.vsync = !theApp.vsync;
 623.326 -}
 623.327 -
 623.328 -void MainWnd::OnUpdateOptionsVideoVsync(CCmdUI*pCmdUI)
 623.329 -{
 623.330 -	pCmdUI->SetCheck(theApp.vsync);
 623.331 -}
 623.332 -
 623.333 -void MainWnd::OnUpdateOptionsVideoX1(CCmdUI*pCmdUI)
 623.334 -{
 623.335 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_1X);
 623.336 -}
 623.337 -
 623.338 -void MainWnd::OnUpdateOptionsVideoX2(CCmdUI*pCmdUI)
 623.339 -{
 623.340 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_2X);
 623.341 -}
 623.342 -
 623.343 -void MainWnd::OnUpdateOptionsVideoX3(CCmdUI*pCmdUI)
 623.344 -{
 623.345 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_3X);
 623.346 -}
 623.347 -
 623.348 -void MainWnd::OnUpdateOptionsVideoX4(CCmdUI*pCmdUI)
 623.349 -{
 623.350 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_4X);
 623.351 -}
 623.352 -
 623.353 -void MainWnd::OnUpdateOptionsVideoFullscreen320x240(CCmdUI*pCmdUI)
 623.354 -{
 623.355 -	pCmdUI->Enable(theApp.mode320Available);
 623.356 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_320x240);
 623.357 -}
 623.358 -
 623.359 -void MainWnd::OnUpdateOptionsVideoFullscreen640x480(CCmdUI*pCmdUI)
 623.360 -{
 623.361 -	pCmdUI->Enable(theApp.mode640Available);
 623.362 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_640x480);
 623.363 -}
 623.364 -
 623.365 -void MainWnd::OnUpdateOptionsVideoFullscreen800x600(CCmdUI*pCmdUI)
 623.366 -{
 623.367 -	pCmdUI->Enable(theApp.mode800Available);
 623.368 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_800x600);
 623.369 -}
 623.370 -
 623.371 -BOOL MainWnd::OnOptionVideoSize(UINT nID)
 623.372 -{
 623.373 -	theApp.updateVideoSize(nID);
 623.374 -	theApp.m_pMainWnd->PostMessage(VBA_CONFIRM_MODE);
 623.375 -	return TRUE;
 623.376 -}
 623.377 -
 623.378 -void MainWnd::OnOptionsVideoFullscreen320x240()
 623.379 -{
 623.380 -	OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN320X240);
 623.381 -}
 623.382 -
 623.383 -void MainWnd::OnOptionsVideoFullscreen640x480()
 623.384 -{
 623.385 -	OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN640X480);
 623.386 -}
 623.387 -
 623.388 -void MainWnd::OnOptionsVideoFullscreen800x600()
 623.389 -{
 623.390 -	OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN800X600);
 623.391 -}
 623.392 -
 623.393 -void MainWnd::OnOptionsVideoFullscreen()
 623.394 -{
 623.395 -	theApp.winCheckFullscreen();
 623.396 -	GUID *pGUID = NULL;
 623.397 -	int   size  = theApp.display->selectFullScreenMode(&pGUID);
 623.398 -	if (size != -1)
 623.399 -	{
 623.400 -		int width      = (size >> 12) & 4095;
 623.401 -		int height     = (size & 4095);
 623.402 -		int colorDepth = (size >> 24);
 623.403 -		if (width != theApp.fsWidth ||
 623.404 -		    height != theApp.fsHeight ||
 623.405 -		    colorDepth != theApp.fsColorDepth ||
 623.406 -		    pGUID != theApp.pVideoDriverGUID ||
 623.407 -		    theApp.videoOption != VIDEO_OTHER)
 623.408 -		{
 623.409 -			theApp.fsForceChange    = true;
 623.410 -			theApp.fsWidth          = width;
 623.411 -			theApp.fsHeight         = height;
 623.412 -			theApp.fsColorDepth     = colorDepth;
 623.413 -			theApp.pVideoDriverGUID = pGUID;
 623.414 -			if (pGUID)
 623.415 -			{
 623.416 -				theApp.videoDriverGUID = *pGUID;
 623.417 -				regSetDwordValue("defaultVideoDriver", FALSE);
 623.418 -				regSetBinaryValue("videoDriverGUID",
 623.419 -				                  (char *)pGUID, sizeof(GUID));
 623.420 -			}
 623.421 -			else
 623.422 -			{
 623.423 -				regSetDwordValue("defaultVideoDriver", TRUE);
 623.424 -			}
 623.425 -			theApp.updateVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN);
 623.426 -			theApp.m_pMainWnd->PostMessage(VBA_CONFIRM_MODE);
 623.427 -		}
 623.428 -	}
 623.429 -}
 623.430 -
 623.431 -void MainWnd::OnUpdateOptionsVideoFullscreen(CCmdUI*pCmdUI)
 623.432 -{
 623.433 -	pCmdUI->SetCheck(theApp.videoOption == VIDEO_OTHER);
 623.434 -}
 623.435 -
 623.436 -void MainWnd::OnOptionsVideoDisablesfx()
 623.437 -{
 623.438 -	cpuDisableSfx = !cpuDisableSfx;
 623.439 -	if (emulating && systemCartridgeType == 0)
 623.440 -		CPUUpdateRender();
 623.441 -}
 623.442 -
 623.443 -void MainWnd::OnUpdateOptionsVideoDisablesfx(CCmdUI*pCmdUI)
 623.444 -{
 623.445 -	pCmdUI->SetCheck(cpuDisableSfx);
 623.446 -}
 623.447 -
 623.448 -void MainWnd::OnOptionsVideoFullscreenstretchtofit()
 623.449 -{
 623.450 -	theApp.fullScreenStretch = !theApp.fullScreenStretch;
 623.451 -	theApp.updateWindowSize(theApp.videoOption);
 623.452 -	if (theApp.display)
 623.453 -		theApp.display->clear();
 623.454 -}
 623.455 -
 623.456 -void MainWnd::OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI*pCmdUI)
 623.457 -{
 623.458 -	pCmdUI->SetCheck(theApp.fullScreenStretch);
 623.459 -}
 623.460 -
 623.461 -BOOL MainWnd::OnVideoLayer(UINT nID)
 623.462 -{
 623.463 -	layerSettings ^= 0x0100 << ((nID & 0xFFFF) - ID_OPTIONS_VIDEO_LAYERS_BG0);
 623.464 -	layerEnable = DISPCNT & layerSettings;
 623.465 -	CPUUpdateRenderBuffers(false);
 623.466 -	return TRUE;
 623.467 -}
 623.468 -
 623.469 -void MainWnd::OnUpdateVideoLayer(CCmdUI *pCmdUI)
 623.470 -{
 623.471 -	pCmdUI->SetCheck((layerSettings >> (8 + pCmdUI->m_nID - ID_OPTIONS_VIDEO_LAYERS_BG0)) & 1);
 623.472 -	switch (pCmdUI->m_nID)
 623.473 -	{
 623.474 -	case ID_OPTIONS_VIDEO_LAYERS_BG1:
 623.475 -	case ID_OPTIONS_VIDEO_LAYERS_BG2:
 623.476 -	case ID_OPTIONS_VIDEO_LAYERS_BG3:
 623.477 -	case ID_OPTIONS_VIDEO_LAYERS_WIN1:
 623.478 -	case ID_OPTIONS_VIDEO_LAYERS_OBJWIN:
 623.479 -		pCmdUI->Enable(systemCartridgeType == 0);
 623.480 -		break;
 623.481 -	}
 623.482 -}
 623.483 -
 623.484 -void MainWnd::OnOptionsVideoRendermethodGdi()
 623.485 -{
 623.486 -	theApp.renderMethod = GDI;
 623.487 -	theApp.updateRenderMethod(false);
 623.488 -}
 623.489 -
 623.490 -void MainWnd::OnUpdateOptionsVideoRendermethodGdi(CCmdUI*pCmdUI)
 623.491 -{
 623.492 -	pCmdUI->SetCheck(theApp.renderMethod == GDI);
 623.493 -}
 623.494 -
 623.495 -void MainWnd::OnOptionsVideoRendermethodDirectdraw()
 623.496 -{
 623.497 -	theApp.renderMethod = DIRECT_DRAW;
 623.498 -	theApp.updateRenderMethod(false);
 623.499 -}
 623.500 -
 623.501 -void MainWnd::OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI*pCmdUI)
 623.502 -{
 623.503 -	pCmdUI->SetCheck(theApp.renderMethod == DIRECT_DRAW);
 623.504 -}
 623.505 -
 623.506 -void MainWnd::OnOptionsVideoRendermethodDirect3d()
 623.507 -{
 623.508 -	theApp.renderMethod = DIRECT_3D;
 623.509 -	theApp.updateRenderMethod(false);
 623.510 -}
 623.511 -
 623.512 -void MainWnd::OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI*pCmdUI)
 623.513 -{
 623.514 -	pCmdUI->SetCheck(theApp.renderMethod == DIRECT_3D);
 623.515 -}
 623.516 -
 623.517 -void MainWnd::OnOptionsVideoRendermethodOpengl()
 623.518 -{
 623.519 -	theApp.renderMethod = OPENGL;
 623.520 -	theApp.updateRenderMethod(false);
 623.521 -}
 623.522 -
 623.523 -void MainWnd::OnUpdateOptionsVideoRendermethodOpengl(CCmdUI*pCmdUI)
 623.524 -{
 623.525 -	pCmdUI->SetCheck(theApp.renderMethod == OPENGL);
 623.526 -}
 623.527 -
 623.528 -void MainWnd::OnOptionsVideoTriplebuffering()
 623.529 -{
 623.530 -	theApp.tripleBuffering = !theApp.tripleBuffering;
 623.531 -}
 623.532 -
 623.533 -void MainWnd::OnUpdateOptionsVideoTriplebuffering(CCmdUI*pCmdUI)
 623.534 -{
 623.535 -	pCmdUI->SetCheck(theApp.tripleBuffering);
 623.536 -}
 623.537 -
 623.538 -void MainWnd::OnOptionsVideoDdrawemulationonly()
 623.539 -{
 623.540 -	theApp.ddrawEmulationOnly = !theApp.ddrawEmulationOnly;
 623.541 -}
 623.542 -
 623.543 -void MainWnd::OnUpdateOptionsVideoDdrawemulationonly(CCmdUI*pCmdUI)
 623.544 -{
 623.545 -	pCmdUI->SetCheck(theApp.ddrawEmulationOnly);
 623.546 -}
 623.547 -
 623.548 -void MainWnd::OnOptionsVideoDdrawusevideomemory()
 623.549 -{
 623.550 -	theApp.ddrawUseVideoMemory = !theApp.ddrawUseVideoMemory;
 623.551 -}
 623.552 -
 623.553 -void MainWnd::OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI*pCmdUI)
 623.554 -{
 623.555 -	pCmdUI->SetCheck(theApp.ddrawUseVideoMemory);
 623.556 -}
 623.557 -
 623.558 -void MainWnd::OnOptionsVideoRenderoptionsD3dnofilter()
 623.559 -{
 623.560 -	theApp.d3dFilter = 0;
 623.561 -	if (theApp.display)
 623.562 -		theApp.display->setOption("d3dFilter", 0);
 623.563 -}
 623.564 -
 623.565 -void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI*pCmdUI)
 623.566 -{
 623.567 -	pCmdUI->SetCheck(theApp.d3dFilter == 0);
 623.568 -}
 623.569 -
 623.570 -void MainWnd::OnOptionsVideoRenderoptionsD3dbilinear()
 623.571 -{
 623.572 -	theApp.d3dFilter = 1;
 623.573 -	if (theApp.display)
 623.574 -		theApp.display->setOption("d3dFilter", 1);
 623.575 -}
 623.576 -
 623.577 -void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI*pCmdUI)
 623.578 -{
 623.579 -	pCmdUI->SetCheck(theApp.d3dFilter == 1);
 623.580 -}
 623.581 -
 623.582 -void MainWnd::OnOptionsVideoRenderoptionsGlnearest()
 623.583 -{
 623.584 -	theApp.glFilter = 0;
 623.585 -	if (theApp.display)
 623.586 -		theApp.display->setOption("glFilter", 0);
 623.587 -}
 623.588 -
 623.589 -void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI*pCmdUI)
 623.590 -{
 623.591 -	pCmdUI->SetCheck(theApp.glFilter == 0);
 623.592 -}
 623.593 -
 623.594 -void MainWnd::OnOptionsVideoRenderoptionsGlbilinear()
 623.595 -{
 623.596 -	theApp.glFilter = 1;
 623.597 -	if (theApp.display)
 623.598 -		theApp.display->setOption("glFilter", 1);
 623.599 -}
 623.600 -
 623.601 -void MainWnd::OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI*pCmdUI)
 623.602 -{
 623.603 -	pCmdUI->SetCheck(theApp.glFilter == 1);
 623.604 -}
 623.605 -
 623.606 -void MainWnd::OnOptionsVideoRenderoptionsGltriangle()
 623.607 -{
 623.608 -	theApp.glType = 0;
 623.609 -	if (theApp.display)
 623.610 -		theApp.display->setOption("glType", 0);
 623.611 -}
 623.612 -
 623.613 -void MainWnd::OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI*pCmdUI)
 623.614 -{
 623.615 -	pCmdUI->SetCheck(theApp.glType == 0);
 623.616 -}
 623.617 -
 623.618 -void MainWnd::OnOptionsVideoRenderoptionsGlquads()
 623.619 -{
 623.620 -	theApp.glType = 1;
 623.621 -	if (theApp.display)
 623.622 -		theApp.display->setOption("glType", 1);
 623.623 -}
 623.624 -
 623.625 -void MainWnd::OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI*pCmdUI)
 623.626 -{
 623.627 -	pCmdUI->SetCheck(theApp.glType == 1);
 623.628 -}
 623.629 -
 623.630 -void MainWnd::OnOptionsVideoRenderoptionsSelectskin()
 623.631 -{}
 623.632 -
 623.633 -void MainWnd::OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI*pCmdUI)
 623.634 -{}
 623.635 -
 623.636 -void MainWnd::OnOptionsVideoRenderoptionsSkin()
 623.637 -{}
 623.638 -
 623.639 -void MainWnd::OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI*pCmdUI)
 623.640 -{}
 623.641 -
 623.642 -void MainWnd::OnOptionsEmulatorAssociate()
 623.643 -{
 623.644 -	theApp.winCheckFullscreen();
 623.645 -	Associate dlg;
 623.646 -	dlg.DoModal();
 623.647 -}
 623.648 -
 623.649 -void MainWnd::OnOptionsEmulatorDirectories()
 623.650 -{
 623.651 -	theApp.winCheckFullscreen();
 623.652 -	Directories dlg;
 623.653 -	dlg.DoModal();
 623.654 -}
 623.655 -
 623.656 -void MainWnd::OnOptionsEmulatorFilenamePreference(UINT nID)
 623.657 -{
 623.658 -	theApp.filenamePreference = nID - ID_OPTIONS_PREFER_ARCHIVE_NAME;
 623.659 -}
 623.660 -
 623.661 -void MainWnd::OnUpdateOptionsEmulatorFilenamePreference(CCmdUI *pCmdUI)
 623.662 -{
 623.663 -	pCmdUI->SetRadio(pCmdUI->m_nID == theApp.filenamePreference + ID_OPTIONS_PREFER_ARCHIVE_NAME);
 623.664 -}
 623.665 -
 623.666 -void MainWnd::OnOptionsVideoDisablestatusmessages()
 623.667 -{
 623.668 -	theApp.disableStatusMessage = !theApp.disableStatusMessage;
 623.669 -}
 623.670 -
 623.671 -void MainWnd::OnUpdateOptionsVideoDisablestatusmessages(CCmdUI*pCmdUI)
 623.672 -{
 623.673 -	pCmdUI->SetCheck(theApp.disableStatusMessage);
 623.674 -}
 623.675 -
 623.676 -void MainWnd::OnOptionsEmulatorSynchronize()
 623.677 -{
 623.678 -	synchronize = !synchronize;
 623.679 -}
 623.680 -
 623.681 -void MainWnd::OnUpdateOptionsEmulatorSynchronize(CCmdUI*pCmdUI)
 623.682 -{
 623.683 -	pCmdUI->SetCheck(synchronize);
 623.684 -}
 623.685 -
 623.686 -void MainWnd::OnOptionsEmulatorAlwaysOnTop()
 623.687 -{
 623.688 -	theApp.alwaysOnTop = !theApp.alwaysOnTop;
 623.689 -	SetWindowPos((theApp.alwaysOnTop ? &wndTopMost : &wndNoTopMost), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
 623.690 -}
 623.691 -
 623.692 -void MainWnd::OnUpdateOptionsEmulatorAlwaysOnTop(CCmdUI*pCmdUI)
 623.693 -{
 623.694 -	pCmdUI->SetCheck(theApp.alwaysOnTop);
 623.695 -}
 623.696 -
 623.697 -void MainWnd::OnOptionsEmulatorPausewheninactive()
 623.698 -{
 623.699 -	theApp.pauseWhenInactive = !theApp.pauseWhenInactive;
 623.700 -}
 623.701 -
 623.702 -void MainWnd::OnUpdateOptionsEmulatorPausewheninactive(CCmdUI*pCmdUI)
 623.703 -{
 623.704 -	pCmdUI->SetCheck(theApp.pauseWhenInactive);
 623.705 -}
 623.706 -
 623.707 -void MainWnd::OnOptionsEmulatorEnableBackgroundInput()
 623.708 -{
 623.709 -	theApp.enableBackgroundInput = !theApp.enableBackgroundInput;
 623.710 -}
 623.711 -
 623.712 -void MainWnd::OnUpdateOptionsEmulatorEnableBackgroundInput(CCmdUI*pCmdUI)
 623.713 -{
 623.714 -	pCmdUI->SetCheck(theApp.enableBackgroundInput);
 623.715 -}
 623.716 -
 623.717 -BOOL MainWnd::OnOptionsPriority(UINT nID)
 623.718 -{
 623.719 -	switch (nID)
 623.720 -	{
 623.721 -	case ID_OPTIONS_PRIORITY_HIGHEST:
 623.722 -		theApp.threadPriority = 0;
 623.723 -		break;
 623.724 -	case ID_OPTIONS_PRIORITY_ABOVENORMAL:
 623.725 -		theApp.threadPriority = 1;
 623.726 -		break;
 623.727 -	case ID_OPTIONS_PRIORITY_NORMAL:
 623.728 -		theApp.threadPriority = 2;
 623.729 -		break;
 623.730 -	case ID_OPTIONS_PRIORITY_BELOWNORMAL:
 623.731 -		theApp.threadPriority = 3;
 623.732 -		break;
 623.733 -	default:
 623.734 -		return FALSE;
 623.735 -	}
 623.736 -	theApp.updatePriority();
 623.737 -
 623.738 -	return TRUE;
 623.739 -}
 623.740 -
 623.741 -void MainWnd::OnUpdateOptionsPriority(CCmdUI *pCmdUI)
 623.742 -{
 623.743 -	switch (pCmdUI->m_nID)
 623.744 -	{
 623.745 -	case ID_OPTIONS_PRIORITY_HIGHEST:
 623.746 -		pCmdUI->SetCheck(theApp.threadPriority == 0);
 623.747 -		break;
 623.748 -	case ID_OPTIONS_PRIORITY_ABOVENORMAL:
 623.749 -		pCmdUI->SetCheck(theApp.threadPriority == 1);
 623.750 -		break;
 623.751 -	case ID_OPTIONS_PRIORITY_NORMAL:
 623.752 -		pCmdUI->SetCheck(theApp.threadPriority == 2);
 623.753 -		break;
 623.754 -	case ID_OPTIONS_PRIORITY_BELOWNORMAL:
 623.755 -		pCmdUI->SetCheck(theApp.threadPriority == 3);
 623.756 -		break;
 623.757 -	}
 623.758 -}
 623.759 -
 623.760 -void MainWnd::OnOptionsEmulatorSpeeduptoggle()
 623.761 -{
 623.762 -	theApp.speedupToggle = !theApp.speedupToggle;
 623.763 -}
 623.764 -
 623.765 -void MainWnd::OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI*pCmdUI)
 623.766 -{
 623.767 -	pCmdUI->SetCheck(theApp.speedupToggle);
 623.768 -}
 623.769 -
 623.770 -void MainWnd::OnOptionsEmulatorRemoveintrosgba()
 623.771 -{
 623.772 -	//  theApp.removeIntros = !theApp.removeIntros;
 623.773 -}
 623.774 -
 623.775 -void MainWnd::OnUpdateOptionsEmulatorRemoveintrosgba(CCmdUI*pCmdUI)
 623.776 -{
 623.777 -	pCmdUI->Enable(false);
 623.778 -	//  pCmdUI->SetCheck(theApp.removeIntros);
 623.779 -}
 623.780 -
 623.781 -void MainWnd::OnOptionsEmulatorAutomaticallyipspatch()
 623.782 -{
 623.783 -	theApp.autoIPS = !theApp.autoIPS;
 623.784 -}
 623.785 -
 623.786 -void MainWnd::OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI*pCmdUI)
 623.787 -{
 623.788 -	pCmdUI->SetCheck(theApp.autoIPS);
 623.789 -}
 623.790 -
 623.791 -void MainWnd::OnOptionsEmulatorAgbprint()
 623.792 -{
 623.793 -	agbPrintEnable(!agbPrintIsEnabled());
 623.794 -}
 623.795 -
 623.796 -void MainWnd::OnUpdateOptionsEmulatorAgbprint(CCmdUI*pCmdUI)
 623.797 -{
 623.798 -	pCmdUI->SetCheck(agbPrintIsEnabled());
 623.799 -}
 623.800 -
 623.801 -void MainWnd::OnOptionsEmulatorRealtimeclock()
 623.802 -{
 623.803 -	theApp.winRtcEnable = !theApp.winRtcEnable;
 623.804 -}
 623.805 -
 623.806 -void MainWnd::OnUpdateOptionsEmulatorRealtimeclock(CCmdUI*pCmdUI)
 623.807 -{
 623.808 -	pCmdUI->SetCheck(theApp.winRtcEnable);
 623.809 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.810 -}
 623.811 -
 623.812 -void MainWnd::OnOptionsEmulatorAutohidemenu()
 623.813 -{
 623.814 -	theApp.autoHideMenu = !theApp.autoHideMenu;
 623.815 -}
 623.816 -
 623.817 -void MainWnd::OnUpdateOptionsEmulatorAutohidemenu(CCmdUI*pCmdUI)
 623.818 -{
 623.819 -	pCmdUI->SetCheck(theApp.autoHideMenu);
 623.820 -}
 623.821 -
 623.822 -void MainWnd::OnOptionsEmulatorRewindinterval()
 623.823 -{
 623.824 -	RewindInterval dlg((float)theApp.rewindTimer/6.0f, theApp.rewindSlots);
 623.825 -	int v = dlg.DoModal();
 623.826 -
 623.827 -	if (v >= 0)
 623.828 -	{
 623.829 -		int interval = v & 0x0000ffff;
 623.830 -		int slots    = (v & 0xffff0000) >> 16;
 623.831 -
 623.832 -		int prevSlots = theApp.rewindSlots;
 623.833 -
 623.834 -		theApp.rewindTimer = interval; // already converted to a multiple of 10 frames
 623.835 -		theApp.rewindSlots = slots;
 623.836 -		if (interval == 0 || slots == 0)
 623.837 -		{
 623.838 -			theApp.rewindTimer = theApp.rewindSlots = 0;
 623.839 -			regSetDwordValue("rewindTimer", interval);
 623.840 -			regSetDwordValue("rewindSlots", slots);
 623.841 -			if (theApp.rewindMemory)
 623.842 -				free(theApp.rewindMemory);
 623.843 -			theApp.rewindMemory     = NULL;
 623.844 -			theApp.rewindCount      = 0;
 623.845 -			theApp.rewindCounter    = 0;
 623.846 -			theApp.rewindSaveNeeded = false;
 623.847 -		}
 623.848 -		else
 623.849 -		{
 623.850 -			regSetDwordValue("rewindTimer", interval);
 623.851 -			regSetDwordValue("rewindSlots", slots);
 623.852 -			if (slots != prevSlots)
 623.853 -			{
 623.854 -				if (theApp.rewindMemory)
 623.855 -					free(theApp.rewindMemory);
 623.856 -				theApp.rewindMemory = NULL;
 623.857 -				theApp.rewindPos    = 0;
 623.858 -			}
 623.859 -			if (theApp.rewindMemory == NULL)
 623.860 -				theApp.rewindMemory = (char *)malloc(theApp.rewindSlots*REWIND_SIZE);
 623.861 -			theApp.rewindCount      = 0;
 623.862 -			theApp.rewindSaveNeeded = true;
 623.863 -		}
 623.864 -	}
 623.865 -}
 623.866 -
 623.867 -BOOL MainWnd::OnOptionsEmulatorShowSpeed(UINT nID)
 623.868 -{
 623.869 -	switch (nID)
 623.870 -	{
 623.871 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE:
 623.872 -		theApp.showSpeed = 0;
 623.873 -		systemSetTitle(VBA_NAME_AND_VERSION);
 623.874 -		break;
 623.875 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE:
 623.876 -		theApp.showSpeed = 1;
 623.877 -		break;
 623.878 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED:
 623.879 -		theApp.showSpeed = 2;
 623.880 -		break;
 623.881 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT:
 623.882 -		theApp.showSpeedTransparent = !theApp.showSpeedTransparent;
 623.883 -		break;
 623.884 -	default:
 623.885 -		return FALSE;
 623.886 -	}
 623.887 -	return TRUE;
 623.888 -}
 623.889 -
 623.890 -void MainWnd::OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI)
 623.891 -{
 623.892 -	switch (pCmdUI->m_nID)
 623.893 -	{
 623.894 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE:
 623.895 -		pCmdUI->SetCheck(theApp.showSpeed == 0);
 623.896 -		break;
 623.897 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE:
 623.898 -		pCmdUI->SetCheck(theApp.showSpeed == 1);
 623.899 -		break;
 623.900 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED:
 623.901 -		pCmdUI->SetCheck(theApp.showSpeed == 2);
 623.902 -		break;
 623.903 -	case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT:
 623.904 -		pCmdUI->SetCheck(theApp.showSpeedTransparent);
 623.905 -		break;
 623.906 -	}
 623.907 -}
 623.908 -
 623.909 -void MainWnd::OnOptionsEmulatorSavetypeAutomatic()
 623.910 -{
 623.911 -	theApp.winSaveType = 0;
 623.912 -}
 623.913 -
 623.914 -void MainWnd::OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI*pCmdUI)
 623.915 -{
 623.916 -	pCmdUI->SetCheck(theApp.winSaveType == 0);
 623.917 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.918 -}
 623.919 -
 623.920 -void MainWnd::OnOptionsEmulatorSavetypeEeprom()
 623.921 -{
 623.922 -	theApp.winSaveType = 1;
 623.923 -}
 623.924 -
 623.925 -void MainWnd::OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI*pCmdUI)
 623.926 -{
 623.927 -	pCmdUI->SetCheck(theApp.winSaveType == 1);
 623.928 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.929 -}
 623.930 -
 623.931 -void MainWnd::OnOptionsEmulatorSavetypeSram()
 623.932 -{
 623.933 -	theApp.winSaveType = 2;
 623.934 -}
 623.935 -
 623.936 -void MainWnd::OnUpdateOptionsEmulatorSavetypeSram(CCmdUI*pCmdUI)
 623.937 -{
 623.938 -	pCmdUI->SetCheck(theApp.winSaveType == 2);
 623.939 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.940 -}
 623.941 -
 623.942 -void MainWnd::OnOptionsEmulatorSavetypeFlash()
 623.943 -{
 623.944 -	theApp.winSaveType = 3;
 623.945 -}
 623.946 -
 623.947 -void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI*pCmdUI)
 623.948 -{
 623.949 -	pCmdUI->SetCheck(theApp.winSaveType == 3);
 623.950 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.951 -}
 623.952 -
 623.953 -void MainWnd::OnOptionsEmulatorSavetypeEepromsensor()
 623.954 -{
 623.955 -	theApp.winSaveType = 4;
 623.956 -}
 623.957 -
 623.958 -void MainWnd::OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI*pCmdUI)
 623.959 -{
 623.960 -	pCmdUI->SetCheck(theApp.winSaveType == 4);
 623.961 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.962 -}
 623.963 -
 623.964 -void MainWnd::OnOptionsEmulatorSavetypeNone()
 623.965 -{
 623.966 -	theApp.winSaveType = 5;
 623.967 -}
 623.968 -
 623.969 -void MainWnd::OnUpdateOptionsEmulatorSavetypeNone(CCmdUI*pCmdUI)
 623.970 -{
 623.971 -	pCmdUI->SetCheck(theApp.winSaveType == 5);
 623.972 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.973 -}
 623.974 -
 623.975 -void MainWnd::OnOptionsEmulatorSavetypeFlash512k()
 623.976 -{
 623.977 -	flashSetSize(0x10000);
 623.978 -	theApp.winFlashSize = 0x10000;
 623.979 -}
 623.980 -
 623.981 -void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI*pCmdUI)
 623.982 -{
 623.983 -	pCmdUI->SetCheck(theApp.winFlashSize == 0x10000);
 623.984 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.985 -}
 623.986 -
 623.987 -void MainWnd::OnOptionsEmulatorSavetypeFlash1m()
 623.988 -{
 623.989 -	flashSetSize(0x20000);
 623.990 -	theApp.winFlashSize = 0x20000;
 623.991 -}
 623.992 -
 623.993 -void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI*pCmdUI)
 623.994 -{
 623.995 -	pCmdUI->SetCheck(theApp.winFlashSize == 0x20000);
 623.996 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
 623.997 -}
 623.998 -
 623.999 -void MainWnd::OnOptionsEmulatorUsebiosfile()
623.1000 -{
623.1001 -	if (!theApp.biosFileName.IsEmpty())
623.1002 -		theApp.useBiosFile = !theApp.useBiosFile;
623.1003 -}
623.1004 -
623.1005 -void MainWnd::OnUpdateOptionsEmulatorUsebiosfile(CCmdUI*pCmdUI)
623.1006 -{
623.1007 -	pCmdUI->SetCheck(theApp.useBiosFile);
623.1008 -	pCmdUI->Enable(!theApp.biosFileName.IsEmpty() && (!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)));
623.1009 -}
623.1010 -
623.1011 -void MainWnd::OnOptionsEmulatorSkipbios()
623.1012 -{
623.1013 -	theApp.skipBiosFile = !theApp.skipBiosFile;
623.1014 -}
623.1015 -
623.1016 -void MainWnd::OnUpdateOptionsEmulatorSkipbios(CCmdUI*pCmdUI)
623.1017 -{
623.1018 -	pCmdUI->SetCheck(theApp.skipBiosFile);
623.1019 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1020 -}
623.1021 -
623.1022 -void MainWnd::OnOptionsEmulatorUseOldGBTiming()
623.1023 -{
623.1024 -	useOldFrameTiming = !useOldFrameTiming;
623.1025 -}
623.1026 -
623.1027 -void MainWnd::OnUpdateOptionsEmulatorUseOldGBTiming(CCmdUI*pCmdUI)
623.1028 -{
623.1029 -	pCmdUI->SetCheck(useOldFrameTiming);
623.1030 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1031 -}
623.1032 -
623.1033 -void MainWnd::OnOptionsEmulatorUseGBNullInputKludge()
623.1034 -{
623.1035 -	if (VBAMovieActive())
623.1036 -		gbNullInputHackTempEnabled = !gbNullInputHackTempEnabled;
623.1037 -	else
623.1038 -		gbNullInputHackTempEnabled = gbNullInputHackEnabled = !gbNullInputHackEnabled;
623.1039 -}
623.1040 -
623.1041 -void MainWnd::OnUpdateOptionsEmulatorUseGBNullInputKludge(CCmdUI*pCmdUI)
623.1042 -{
623.1043 -	pCmdUI->SetCheck(VBAMovieActive() || GetAsyncKeyState(VK_CONTROL) ? gbNullInputHackTempEnabled : gbNullInputHackEnabled);
623.1044 -	pCmdUI->Enable((!VBAMovieActive() && !useOldFrameTiming) || GetAsyncKeyState(VK_CONTROL));
623.1045 -}
623.1046 -
623.1047 -void MainWnd::OnOptionsEmulatorGBALag()
623.1048 -{
623.1049 -	extern void TogglePrefetchHack();
623.1050 -	TogglePrefetchHack();
623.1051 -	memLagEnabled = memLagTempEnabled; // memLagEnabled is only to hold the last value that the user chose, so temporary changes
623.1052 -                                       // don't get into the registry
623.1053 -}
623.1054 -
623.1055 -void MainWnd::OnUpdateOptionsEmulatorGBALag(CCmdUI*pCmdUI)
623.1056 -{
623.1057 -	pCmdUI->SetCheck(!memLagTempEnabled);
623.1058 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1059 -}
623.1060 -
623.1061 -void MainWnd::OnOptionsEmulatorSelectbiosfile()
623.1062 -{
623.1063 -	theApp.winCheckFullscreen();
623.1064 -	LPCTSTR exts[] = { NULL };
623.1065 -	CString filter = winResLoadFilter(IDS_FILTER_BIOS);
623.1066 -	CString title  = winResLoadString(IDS_SELECT_BIOS_FILE);
623.1067 -
623.1068 -	FileDlg dlg(this,
623.1069 -	            theApp.biosFileName,
623.1070 -	            filter,
623.1071 -	            0,
623.1072 -	            "BIOS",
623.1073 -	            exts,
623.1074 -	            "",
623.1075 -	            title,
623.1076 -	            false);
623.1077 -
623.1078 -	if (dlg.DoModal() == IDOK)
623.1079 -	{
623.1080 -		theApp.biosFileName = dlg.GetPathName();
623.1081 -	}
623.1082 -}
623.1083 -
623.1084 -void MainWnd::OnOptionsEmulatorPngformat()
623.1085 -{
623.1086 -	theApp.captureFormat = 0;
623.1087 -}
623.1088 -
623.1089 -void MainWnd::OnUpdateOptionsEmulatorPngformat(CCmdUI*pCmdUI)
623.1090 -{
623.1091 -	pCmdUI->SetCheck(theApp.captureFormat == 0);
623.1092 -}
623.1093 -
623.1094 -void MainWnd::OnOptionsEmulatorBmpformat()
623.1095 -{
623.1096 -	theApp.captureFormat = 1;
623.1097 -}
623.1098 -
623.1099 -void MainWnd::OnUpdateOptionsEmulatorBmpformat(CCmdUI*pCmdUI)
623.1100 -{
623.1101 -	pCmdUI->SetCheck(theApp.captureFormat == 1);
623.1102 -}
623.1103 -
623.1104 -void MainWnd::OnOptionsSoundDisable()
623.1105 -{
623.1106 -	if (soundOffFlag)
623.1107 -	{
623.1108 -		soundOffFlag = false;
623.1109 -		soundInit();
623.1110 -	}
623.1111 -	else
623.1112 -	{
623.1113 -		soundOffFlag = true;
623.1114 -		soundShutdown();
623.1115 -	}
623.1116 -}
623.1117 -
623.1118 -void MainWnd::OnUpdateOptionsSoundDisable(CCmdUI*pCmdUI)
623.1119 -{
623.1120 -	pCmdUI->SetCheck(soundOffFlag);
623.1121 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1122 -}
623.1123 -
623.1124 -static void OnSoundToggleEnabled(int c)
623.1125 -{
623.1126 -	if (soundGetEnabledChannels() & c)
623.1127 -	{
623.1128 -		soundDisableChannels(c);
623.1129 -	}
623.1130 -	else
623.1131 -	{
623.1132 -		soundEnableChannels(c);
623.1133 -	}
623.1134 -}
623.1135 -
623.1136 -void MainWnd::OnOptionsSoundMute()
623.1137 -{
623.1138 -	if ((soundGetEnabledChannels() & 0x030f) == 0)
623.1139 -		soundEnableChannels(0x030f);
623.1140 -	else
623.1141 -		soundDisableChannels(0x030f);
623.1142 -}
623.1143 -
623.1144 -void MainWnd::OnUpdateOptionsSoundMute(CCmdUI*pCmdUI)
623.1145 -{
623.1146 -	pCmdUI->SetCheck((soundGetEnabledChannels() & 0x030f) == 0);
623.1147 -}
623.1148 -
623.1149 -void MainWnd::OnOptionsSoundOff()
623.1150 -{
623.1151 -	soundDisableChannels(0x030f);
623.1152 -}
623.1153 -
623.1154 -void MainWnd::OnUpdateOptionsSoundOff(CCmdUI*pCmdUI)
623.1155 -{
623.1156 -	pCmdUI->SetCheck((soundGetEnabledChannels() & 0x030f) == 0);
623.1157 -}
623.1158 -
623.1159 -void MainWnd::OnOptionsSoundOn()
623.1160 -{
623.1161 -	soundEnableChannels(0x030f);
623.1162 -}
623.1163 -
623.1164 -void MainWnd::OnUpdateOptionsSoundOn(CCmdUI*pCmdUI)
623.1165 -{
623.1166 -	pCmdUI->SetCheck(soundGetEnabledChannels() == 0x030f);
623.1167 -}
623.1168 -
623.1169 -void MainWnd::OnOptionsSoundUseoldsynchronization()
623.1170 -{
623.1171 -	theApp.useOldSync = !theApp.useOldSync;
623.1172 -	systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE,
623.1173 -	              "Setting will be effective the next time you start the emulator");
623.1174 -}
623.1175 -
623.1176 -void MainWnd::OnUpdateOptionsSoundUseoldsynchronization(CCmdUI*pCmdUI)
623.1177 -{
623.1178 -	pCmdUI->SetCheck(theApp.useOldSync);
623.1179 -}
623.1180 -
623.1181 -void MainWnd::OnOptionsSoundEcho()
623.1182 -{
623.1183 -	soundEcho = !soundEcho;
623.1184 -}
623.1185 -
623.1186 -void MainWnd::OnUpdateOptionsSoundEcho(CCmdUI*pCmdUI)
623.1187 -{
623.1188 -	pCmdUI->SetCheck(soundEcho);
623.1189 -}
623.1190 -
623.1191 -void MainWnd::OnOptionsSoundLowpassfilter()
623.1192 -{
623.1193 -	soundLowPass = !soundLowPass;
623.1194 -}
623.1195 -
623.1196 -void MainWnd::OnUpdateOptionsSoundLowpassfilter(CCmdUI*pCmdUI)
623.1197 -{
623.1198 -	pCmdUI->SetCheck(soundLowPass);
623.1199 -}
623.1200 -
623.1201 -void MainWnd::OnOptionsSoundReversestereo()
623.1202 -{
623.1203 -	soundReverse = !soundReverse;
623.1204 -}
623.1205 -
623.1206 -void MainWnd::OnUpdateOptionsSoundReversestereo(CCmdUI*pCmdUI)
623.1207 -{
623.1208 -	pCmdUI->SetCheck(soundReverse);
623.1209 -}
623.1210 -
623.1211 -void MainWnd::OnOptionsSoundMuteFrameAdvance()
623.1212 -{
623.1213 -	theApp.muteFrameAdvance = !theApp.muteFrameAdvance;
623.1214 -}
623.1215 -
623.1216 -void MainWnd::OnUpdateOptionsSoundMuteFrameAdvance(CCmdUI*pCmdUI)
623.1217 -{
623.1218 -	pCmdUI->SetCheck(theApp.muteFrameAdvance);
623.1219 -}
623.1220 -
623.1221 -void MainWnd::OnOptionsSoundMuteWhenInactive()
623.1222 -{
623.1223 -	theApp.muteWhenInactive = !theApp.muteWhenInactive;
623.1224 -}
623.1225 -
623.1226 -void MainWnd::OnUpdateOptionsSoundMuteWhenInactive(CCmdUI*pCmdUI)
623.1227 -{
623.1228 -	pCmdUI->SetCheck(theApp.muteWhenInactive);
623.1229 -}
623.1230 -
623.1231 -void MainWnd::OnOptionsSound11khz()
623.1232 -{
623.1233 -	if (systemCartridgeType == 0)
623.1234 -		soundSetQuality(4);
623.1235 -	else
623.1236 -		gbSoundSetQuality(4);
623.1237 -}
623.1238 -
623.1239 -void MainWnd::OnUpdateOptionsSound11khz(CCmdUI*pCmdUI)
623.1240 -{
623.1241 -	pCmdUI->SetCheck(soundQuality == 4);
623.1242 -	pCmdUI->Enable((!VBAMovieActive() ||
623.1243 -	                GetAsyncKeyState(VK_CONTROL)) && !(theApp.soundRecording || theApp.aviRecording || theApp.nvAudioLog));
623.1244 -}
623.1245 -
623.1246 -void MainWnd::OnOptionsSound22khz()
623.1247 -{
623.1248 -	if (systemCartridgeType == 0)
623.1249 -		soundSetQuality(2);
623.1250 -	else
623.1251 -		gbSoundSetQuality(2);
623.1252 -}
623.1253 -
623.1254 -void MainWnd::OnUpdateOptionsSound22khz(CCmdUI*pCmdUI)
623.1255 -{
623.1256 -	pCmdUI->SetCheck(soundQuality == 2);
623.1257 -	pCmdUI->Enable((!VBAMovieActive() ||
623.1258 -	                GetAsyncKeyState(VK_CONTROL)) && !(theApp.soundRecording || theApp.aviRecording || theApp.nvAudioLog));
623.1259 -}
623.1260 -
623.1261 -void MainWnd::OnOptionsSound44khz()
623.1262 -{
623.1263 -	systemSoundSetQuality(1);
623.1264 -}
623.1265 -
623.1266 -void MainWnd::OnUpdateOptionsSound44khz(CCmdUI*pCmdUI)
623.1267 -{
623.1268 -	pCmdUI->SetCheck(soundQuality == 1);
623.1269 -	pCmdUI->Enable(!(theApp.soundRecording || theApp.aviRecording || theApp.nvAudioLog));
623.1270 -}
623.1271 -
623.1272 -BOOL MainWnd::OnOptionsSoundVolume(UINT nID)
623.1273 -{
623.1274 -	soundVolume = nID - ID_OPTIONS_SOUND_VOLUME_1X;
623.1275 -	return TRUE;
623.1276 -}
623.1277 -
623.1278 -void MainWnd::OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI)
623.1279 -{
623.1280 -	pCmdUI->SetCheck(soundVolume == (int)(pCmdUI->m_nID - ID_OPTIONS_SOUND_VOLUME_1X));
623.1281 -}
623.1282 -
623.1283 -void MainWnd::OnOptionsSoundVolume25x()
623.1284 -{
623.1285 -	soundVolume = 4;
623.1286 -}
623.1287 -
623.1288 -void MainWnd::OnUpdateOptionsSoundVolume25x(CCmdUI*pCmdUI)
623.1289 -{
623.1290 -	pCmdUI->SetCheck(soundVolume == 4);
623.1291 -}
623.1292 -
623.1293 -void MainWnd::OnOptionsSoundVolume5x()
623.1294 -{
623.1295 -	soundVolume = 5;
623.1296 -}
623.1297 -
623.1298 -void MainWnd::OnUpdateOptionsSoundVolume5x(CCmdUI*pCmdUI)
623.1299 -{
623.1300 -	pCmdUI->SetCheck(soundVolume == 5);
623.1301 -}
623.1302 -
623.1303 -void MainWnd::OnOptionsSoundChannel1()
623.1304 -{
623.1305 -	OnSoundToggleEnabled(0x01);
623.1306 -}
623.1307 -
623.1308 -void MainWnd::OnUpdateOptionsSoundChannel1(CCmdUI*pCmdUI)
623.1309 -{
623.1310 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x01);
623.1311 -}
623.1312 -
623.1313 -void MainWnd::OnOptionsSoundChannel2()
623.1314 -{
623.1315 -	OnSoundToggleEnabled(0x02);
623.1316 -}
623.1317 -
623.1318 -void MainWnd::OnUpdateOptionsSoundChannel2(CCmdUI*pCmdUI)
623.1319 -{
623.1320 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x02);
623.1321 -}
623.1322 -
623.1323 -void MainWnd::OnOptionsSoundChannel3()
623.1324 -{
623.1325 -	OnSoundToggleEnabled(0x04);
623.1326 -}
623.1327 -
623.1328 -void MainWnd::OnUpdateOptionsSoundChannel3(CCmdUI*pCmdUI)
623.1329 -{
623.1330 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x04);
623.1331 -}
623.1332 -
623.1333 -void MainWnd::OnOptionsSoundChannel4()
623.1334 -{
623.1335 -	OnSoundToggleEnabled(0x08);
623.1336 -}
623.1337 -
623.1338 -void MainWnd::OnUpdateOptionsSoundChannel4(CCmdUI*pCmdUI)
623.1339 -{
623.1340 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x08);
623.1341 -}
623.1342 -
623.1343 -void MainWnd::OnOptionsSoundDirectsounda()
623.1344 -{
623.1345 -	OnSoundToggleEnabled(0x0100);
623.1346 -}
623.1347 -
623.1348 -void MainWnd::OnUpdateOptionsSoundDirectsounda(CCmdUI*pCmdUI)
623.1349 -{
623.1350 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x0100);
623.1351 -	//pCmdUI->Enable(systemCartridgeType == 0);
623.1352 -}
623.1353 -
623.1354 -void MainWnd::OnOptionsSoundDirectsoundb()
623.1355 -{
623.1356 -	OnSoundToggleEnabled(0x0200);
623.1357 -}
623.1358 -
623.1359 -void MainWnd::OnUpdateOptionsSoundDirectsoundb(CCmdUI*pCmdUI)
623.1360 -{
623.1361 -	pCmdUI->SetCheck(soundGetEnabledChannels() & 0x0200);
623.1362 -	//pCmdUI->Enable(systemCartridgeType == 0);
623.1363 -}
623.1364 -
623.1365 -void MainWnd::OnOptionsGameboyBorder()
623.1366 -{
623.1367 -	theApp.winGbBorderOn = !theApp.winGbBorderOn;
623.1368 -	gbBorderOn = theApp.winGbBorderOn;
623.1369 -	if (emulating && systemCartridgeType == 1 && gbBorderOn)
623.1370 -	{
623.1371 -		gbSgbRenderBorder();
623.1372 -	}
623.1373 -	theApp.updateWindowSize(theApp.videoOption);
623.1374 -}
623.1375 -
623.1376 -void MainWnd::OnUpdateOptionsGameboyBorder(CCmdUI*pCmdUI)
623.1377 -{
623.1378 -	pCmdUI->SetCheck(theApp.winGbBorderOn);
623.1379 -}
623.1380 -
623.1381 -void MainWnd::OnOptionsGameboyPrinter()
623.1382 -{
623.1383 -	theApp.winGbPrinterEnabled = !theApp.winGbPrinterEnabled;
623.1384 -	if (theApp.winGbPrinterEnabled)
623.1385 -		gbSerialFunction = gbPrinterSend;
623.1386 -	else
623.1387 -		gbSerialFunction = NULL;
623.1388 -}
623.1389 -
623.1390 -void MainWnd::OnUpdateOptionsGameboyPrinter(CCmdUI*pCmdUI)
623.1391 -{
623.1392 -	pCmdUI->SetCheck(gbSerialFunction == gbPrinterSend);
623.1393 -}
623.1394 -
623.1395 -void MainWnd::OnOptionsGameboyBorderAutomatic()
623.1396 -{
623.1397 -	gbBorderAutomatic = !gbBorderAutomatic;
623.1398 -	if (emulating && systemCartridgeType == 1 && gbBorderOn)
623.1399 -	{
623.1400 -		gbSgbRenderBorder();
623.1401 -		theApp.updateWindowSize(theApp.videoOption);
623.1402 -	}
623.1403 -}
623.1404 -
623.1405 -void MainWnd::OnUpdateOptionsGameboyBorderAutomatic(CCmdUI*pCmdUI)
623.1406 -{
623.1407 -	pCmdUI->SetCheck(gbBorderAutomatic);
623.1408 -}
623.1409 -
623.1410 -void MainWnd::OnOptionsGameboyAutomatic()
623.1411 -{
623.1412 -	gbEmulatorType = 0;
623.1413 -}
623.1414 -
623.1415 -void MainWnd::OnUpdateOptionsGameboyAutomatic(CCmdUI*pCmdUI)
623.1416 -{
623.1417 -	pCmdUI->SetCheck(gbEmulatorType == 0);
623.1418 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1419 -}
623.1420 -
623.1421 -void MainWnd::OnOptionsGameboyGba()
623.1422 -{
623.1423 -	gbEmulatorType = 4;
623.1424 -}
623.1425 -
623.1426 -void MainWnd::OnUpdateOptionsGameboyGba(CCmdUI*pCmdUI)
623.1427 -{
623.1428 -	pCmdUI->SetCheck(gbEmulatorType == 4);
623.1429 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1430 -}
623.1431 -
623.1432 -void MainWnd::OnOptionsGameboyCgb()
623.1433 -{
623.1434 -	gbEmulatorType = 1;
623.1435 -}
623.1436 -
623.1437 -void MainWnd::OnUpdateOptionsGameboyCgb(CCmdUI*pCmdUI)
623.1438 -{
623.1439 -	pCmdUI->SetCheck(gbEmulatorType == 1);
623.1440 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1441 -}
623.1442 -
623.1443 -void MainWnd::OnOptionsGameboySgb()
623.1444 -{
623.1445 -	gbEmulatorType = 2;
623.1446 -}
623.1447 -
623.1448 -void MainWnd::OnUpdateOptionsGameboySgb(CCmdUI*pCmdUI)
623.1449 -{
623.1450 -	pCmdUI->SetCheck(gbEmulatorType == 2);
623.1451 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1452 -}
623.1453 -
623.1454 -void MainWnd::OnOptionsGameboySgb2()
623.1455 -{
623.1456 -	gbEmulatorType = 5;
623.1457 -}
623.1458 -
623.1459 -void MainWnd::OnUpdateOptionsGameboySgb2(CCmdUI*pCmdUI)
623.1460 -{
623.1461 -	pCmdUI->SetCheck(gbEmulatorType == 5);
623.1462 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1463 -}
623.1464 -
623.1465 -void MainWnd::OnOptionsGameboyGb()
623.1466 -{
623.1467 -	gbEmulatorType = 3;
623.1468 -}
623.1469 -
623.1470 -void MainWnd::OnUpdateOptionsGameboyGb(CCmdUI*pCmdUI)
623.1471 -{
623.1472 -	pCmdUI->SetCheck(gbEmulatorType == 3);
623.1473 -	pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL));
623.1474 -}
623.1475 -
623.1476 -void MainWnd::OnOptionsGameboyRealcolors()
623.1477 -{
623.1478 -	gbColorOption = 0;
623.1479 -}
623.1480 -
623.1481 -void MainWnd::OnUpdateOptionsGameboyRealcolors(CCmdUI*pCmdUI)
623.1482 -{
623.1483 -	pCmdUI->SetCheck(gbColorOption == 0);
623.1484 -}
623.1485 -
623.1486 -void MainWnd::OnOptionsGameboyGameboycolors()
623.1487 -{
623.1488 -	gbColorOption = 1;
623.1489 -}
623.1490 -
623.1491 -void MainWnd::OnUpdateOptionsGameboyGameboycolors(CCmdUI*pCmdUI)
623.1492 -{
623.1493 -	pCmdUI->SetCheck(gbColorOption == 1);
623.1494 -}
623.1495 -
623.1496 -void MainWnd::OnOptionsGameboyColors()
623.1497 -{
623.1498 -	theApp.winCheckFullscreen();
623.1499 -	GBColorDlg dlg;
623.1500 -	if (dlg.DoModal())
623.1501 -	{
623.1502 -		gbPaletteOption = dlg.getWhich();
623.1503 -		memcpy(systemGbPalette, dlg.getColors(), 24*sizeof(u16));
623.1504 -		if (emulating && systemCartridgeType == 1)
623.1505 -		{
623.1506 -			memcpy(gbPalette, &systemGbPalette[dlg.getWhich()*8], 8*sizeof(u16));
623.1507 -		}
623.1508 -	}
623.1509 -}
623.1510 -
623.1511 -BOOL MainWnd::OnOptionsFilter(UINT nID)
623.1512 -{
623.1513 -	switch (nID)
623.1514 -	{
623.1515 -	case ID_OPTIONS_FILTER_NORMAL:
623.1516 -		theApp.filterType = 0;
623.1517 -		break;
623.1518 -	case ID_OPTIONS_FILTER_TVMODE:
623.1519 -		theApp.filterType = 1;
623.1520 -		break;
623.1521 -	case ID_OPTIONS_FILTER_2XSAI:
623.1522 -		theApp.filterType = 2;
623.1523 -		break;
623.1524 -	case ID_OPTIONS_FILTER_SUPER2XSAI:
623.1525 -		theApp.filterType = 3;
623.1526 -		break;
623.1527 -	case ID_OPTIONS_FILTER_SUPEREAGLE:
623.1528 -		theApp.filterType = 4;
623.1529 -		break;
623.1530 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL:
623.1531 -		theApp.filterType = 5;
623.1532 -		break;
623.1533 -	case ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL:
623.1534 -		theApp.filterType = 6;
623.1535 -		break;
623.1536 -	case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X:
623.1537 -		theApp.filterType = 7;
623.1538 -		break;
623.1539 -	case ID_OPTIONS_FILTER16BIT_SIMPLE2X:
623.1540 -		theApp.filterType = 8;
623.1541 -		break;
623.1542 -	case ID_OPTIONS_FILTER_BILINEAR:
623.1543 -		theApp.filterType = 9;
623.1544 -		break;
623.1545 -	case ID_OPTIONS_FILTER_BILINEARPLUS:
623.1546 -		theApp.filterType = 10;
623.1547 -		break;
623.1548 -	case ID_OPTIONS_FILTER_SCANLINES:
623.1549 -		theApp.filterType = 11;
623.1550 -		break;
623.1551 -	case ID_OPTIONS_FILTER_HQ2X2:
623.1552 -		theApp.filterType = 12;
623.1553 -		break;
623.1554 -	case ID_OPTIONS_FILTER_HQ2X:
623.1555 -		theApp.filterType = 13;
623.1556 -		break;
623.1557 -	case ID_OPTIONS_FILTER_LQ2X:
623.1558 -		theApp.filterType = 14;
623.1559 -		break;
623.1560 -	case ID_OPTIONS_FILTER_HQ3X2:
623.1561 -		theApp.filterType = 15;
623.1562 -		break;
623.1563 -	case ID_OPTIONS_FILTER_HQ3X:
623.1564 -		theApp.filterType = 16;
623.1565 -		break;
623.1566 -	case ID_OPTIONS_FILTER16BIT_SIMPLE3X:
623.1567 -		theApp.filterType = 17;
623.1568 -		break;
623.1569 -	case ID_OPTIONS_FILTER16BIT_SIMPLE4X:
623.1570 -		theApp.filterType = 18;
623.1571 -		break;
623.1572 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL3X:
623.1573 -		theApp.filterType = 19;
623.1574 -		break;
623.1575 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X:
623.1576 -		theApp.filterType = 20;
623.1577 -		break;
623.1578 -	default:
623.1579 -		return FALSE;
623.1580 -	}
623.1581 -	theApp.updateFilter();
623.1582 -	return TRUE;
623.1583 -}
623.1584 -
623.1585 -void MainWnd::OnUpdateOptionsFilter(CCmdUI *pCmdUI)
623.1586 -{
623.1587 -	pCmdUI->Enable(systemColorDepth == 16 || systemColorDepth == 32);
623.1588 -	switch (pCmdUI->m_nID)
623.1589 -	{
623.1590 -	case ID_OPTIONS_FILTER_NORMAL:
623.1591 -		pCmdUI->SetCheck(theApp.filterType == 0);
623.1592 -		break;
623.1593 -	case ID_OPTIONS_FILTER_TVMODE:
623.1594 -		pCmdUI->SetCheck(theApp.filterType == 1);
623.1595 -		break;
623.1596 -	case ID_OPTIONS_FILTER_2XSAI:
623.1597 -		pCmdUI->SetCheck(theApp.filterType == 2);
623.1598 -		break;
623.1599 -	case ID_OPTIONS_FILTER_SUPER2XSAI:
623.1600 -		pCmdUI->SetCheck(theApp.filterType == 3);
623.1601 -		break;
623.1602 -	case ID_OPTIONS_FILTER_SUPEREAGLE:
623.1603 -		pCmdUI->SetCheck(theApp.filterType == 4);
623.1604 -		break;
623.1605 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL:
623.1606 -		pCmdUI->SetCheck(theApp.filterType == 5);
623.1607 -		break;
623.1608 -	case ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL:
623.1609 -		pCmdUI->SetCheck(theApp.filterType == 6);
623.1610 -		break;
623.1611 -	case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X:
623.1612 -		pCmdUI->SetCheck(theApp.filterType == 7);
623.1613 -		break;
623.1614 -	case ID_OPTIONS_FILTER16BIT_SIMPLE2X:
623.1615 -		pCmdUI->SetCheck(theApp.filterType == 8);
623.1616 -		break;
623.1617 -	case ID_OPTIONS_FILTER_BILINEAR:
623.1618 -		pCmdUI->SetCheck(theApp.filterType == 9);
623.1619 -		break;
623.1620 -	case ID_OPTIONS_FILTER_BILINEARPLUS:
623.1621 -		pCmdUI->SetCheck(theApp.filterType == 10);
623.1622 -		break;
623.1623 -	case ID_OPTIONS_FILTER_SCANLINES:
623.1624 -		pCmdUI->SetCheck(theApp.filterType == 11);
623.1625 -		break;
623.1626 -	case ID_OPTIONS_FILTER_HQ2X2:
623.1627 -		pCmdUI->SetCheck(theApp.filterType == 12);
623.1628 -		break;
623.1629 -	case ID_OPTIONS_FILTER_HQ2X:
623.1630 -		pCmdUI->SetCheck(theApp.filterType == 13);
623.1631 -		break;
623.1632 -	case ID_OPTIONS_FILTER_LQ2X:
623.1633 -		pCmdUI->SetCheck(theApp.filterType == 14);
623.1634 -		break;
623.1635 -	case ID_OPTIONS_FILTER_HQ3X2:
623.1636 -		pCmdUI->SetCheck(theApp.filterType == 15);
623.1637 -		break;
623.1638 -	case ID_OPTIONS_FILTER_HQ3X:
623.1639 -		pCmdUI->SetCheck(theApp.filterType == 16);
623.1640 -		break;
623.1641 -	case ID_OPTIONS_FILTER16BIT_SIMPLE3X:
623.1642 -		pCmdUI->SetCheck(theApp.filterType == 17);
623.1643 -		break;
623.1644 -	case ID_OPTIONS_FILTER16BIT_SIMPLE4X:
623.1645 -		pCmdUI->SetCheck(theApp.filterType == 18);
623.1646 -		break;
623.1647 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL3X:
623.1648 -		pCmdUI->SetCheck(theApp.filterType == 19);
623.1649 -		break;
623.1650 -	case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X:
623.1651 -		pCmdUI->SetCheck(theApp.filterType == 20);
623.1652 -		break;
623.1653 -	}
623.1654 -}
623.1655 -
623.1656 -BOOL MainWnd::OnOptionsFilterIFB(UINT nID)
623.1657 -{
623.1658 -	switch (nID)
623.1659 -	{
623.1660 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE:
623.1661 -		theApp.ifbType = 0;
623.1662 -		break;
623.1663 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR:
623.1664 -		theApp.ifbType = 1;
623.1665 -		break;
623.1666 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART:
623.1667 -		theApp.ifbType = 2;
623.1668 -		break;
623.1669 -	default:
623.1670 -		return FALSE;
623.1671 -	}
623.1672 -	theApp.updateIFB();
623.1673 -	return TRUE;
623.1674 -}
623.1675 -
623.1676 -void MainWnd::OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI)
623.1677 -{
623.1678 -	switch (pCmdUI->m_nID)
623.1679 -	{
623.1680 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE:
623.1681 -		pCmdUI->SetCheck(theApp.ifbType == 0);
623.1682 -		break;
623.1683 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR:
623.1684 -		pCmdUI->SetCheck(theApp.ifbType == 1);
623.1685 -		break;
623.1686 -	case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART:
623.1687 -		pCmdUI->SetCheck(theApp.ifbType == 2);
623.1688 -		break;
623.1689 -	}
623.1690 -}
623.1691 -
623.1692 -void MainWnd::OnOptionsFilterDisablemmx()
623.1693 -{
623.1694 -	theApp.disableMMX = !theApp.disableMMX;
623.1695 -	if (!theApp.disableMMX)
623.1696 -		cpu_mmx = theApp.detectMMX();
623.1697 -	else
623.1698 -		cpu_mmx = 0;
623.1699 -}
623.1700 -
623.1701 -void MainWnd::OnUpdateOptionsFilterDisablemmx(CCmdUI*pCmdUI)
623.1702 -{
623.1703 -	pCmdUI->SetCheck(theApp.disableMMX);
623.1704 -}
623.1705 -
623.1706 -void MainWnd::OnOptionsLanguageSystem()
623.1707 -{
623.1708 -	theApp.winSetLanguageOption(0, false);
623.1709 -}
623.1710 -
623.1711 -void MainWnd::OnUpdateOptionsLanguageSystem(CCmdUI*pCmdUI)
623.1712 -{
623.1713 -	pCmdUI->SetCheck(theApp.languageOption == 0);
623.1714 -}
623.1715 -
623.1716 -void MainWnd::OnOptionsLanguageEnglish()
623.1717 -{
623.1718 -	theApp.winSetLanguageOption(1, false);
623.1719 -}
623.1720 -
623.1721 -void MainWnd::OnUpdateOptionsLanguageEnglish(CCmdUI*pCmdUI)
623.1722 -{
623.1723 -	pCmdUI->SetCheck(theApp.languageOption == 1);
623.1724 -}
623.1725 -
623.1726 -void MainWnd::OnOptionsLanguageOther()
623.1727 -{
623.1728 -	theApp.winCheckFullscreen();
623.1729 -	theApp.winSetLanguageOption(2, false);
623.1730 -}
623.1731 -
623.1732 -void MainWnd::OnUpdateOptionsLanguageOther(CCmdUI*pCmdUI)
623.1733 -{
623.1734 -	pCmdUI->SetCheck(theApp.languageOption == 2);
623.1735 -}
623.1736 -
623.1737 -void MainWnd::OnOptionsJoypadConfigure1()
623.1738 -{
623.1739 -	theApp.winCheckFullscreen();
623.1740 -	JoypadConfig dlg(0);
623.1741 -	dlg.DoModal();
623.1742 -}
623.1743 -
623.1744 -void MainWnd::OnUpdateOptionsJoypadConfigure1(CCmdUI*pCmdUI)
623.1745 -{
623.1746 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
623.1747 -}
623.1748 -
623.1749 -void MainWnd::OnOptionsJoypadConfigure2()
623.1750 -{
623.1751 -	theApp.winCheckFullscreen();
623.1752 -	JoypadConfig dlg(1);
623.1753 -	dlg.DoModal();
623.1754 -}
623.1755 -
623.1756 -void MainWnd::OnUpdateOptionsJoypadConfigure2(CCmdUI*pCmdUI)
623.1757 -{
623.1758 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
623.1759 -}
623.1760 -
623.1761 -void MainWnd::OnOptionsJoypadConfigure3()
623.1762 -{
623.1763 -	theApp.winCheckFullscreen();
623.1764 -	JoypadConfig dlg(2);
623.1765 -	dlg.DoModal();
623.1766 -}
623.1767 -
623.1768 -void MainWnd::OnUpdateOptionsJoypadConfigure3(CCmdUI*pCmdUI)
623.1769 -{
623.1770 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
623.1771 -}
623.1772 -
623.1773 -void MainWnd::OnOptionsJoypadConfigure4()
623.1774 -{
623.1775 -	theApp.winCheckFullscreen();
623.1776 -	JoypadConfig dlg(3);
623.1777 -	dlg.DoModal();
623.1778 -}
623.1779 -
623.1780 -void MainWnd::OnUpdateOptionsJoypadConfigure4(CCmdUI*pCmdUI)
623.1781 -{
623.1782 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
623.1783 -}
623.1784 -
623.1785 -BOOL MainWnd::OnOptionsJoypadDefault(UINT nID)
623.1786 -{
623.1787 -	theApp.joypadDefault = nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1;
623.1788 -	return TRUE;
623.1789 -}
623.1790 -
623.1791 -void MainWnd::OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI)
623.1792 -{
623.1793 -	pCmdUI->SetCheck(theApp.joypadDefault == (int)(pCmdUI->m_nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1));
623.1794 -}
623.1795 -
623.1796 -void MainWnd::OnOptionsJoypadMotionconfigure()
623.1797 -{
623.1798 -	theApp.winCheckFullscreen();
623.1799 -	MotionConfig dlg;
623.1800 -	dlg.DoModal();
623.1801 -}
623.1802 -
623.1803 -void MainWnd::OnUpdateOptionsJoypadMotionconfigure(CCmdUI*pCmdUI)
623.1804 -{
623.1805 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
623.1806 -}
623.1807 -
623.1808 -void MainWnd::OnOptionsJoypadAllowLeftRight()
623.1809 -{
623.1810 -	theApp.allowLeftRight = !theApp.allowLeftRight;
623.1811 -}
623.1812 -
623.1813 -void MainWnd::OnUpdateOptionsJoypadAllowLeftRight(CCmdUI*pCmdUI)
623.1814 -{
623.1815 -	pCmdUI->SetCheck(theApp.allowLeftRight);
623.1816 -}
623.1817 -
623.1818 -void MainWnd::OnOptionsJoypadAutofireAccountForLag()
623.1819 -{
623.1820 -	theApp.autofireAccountForLag = !theApp.autofireAccountForLag;
623.1821 -}
623.1822 -
623.1823 -void MainWnd::OnUpdateOptionsJoypadAutofireAccountForLag(CCmdUI*pCmdUI)
623.1824 -{
623.1825 -	pCmdUI->SetCheck(theApp.autofireAccountForLag);
623.1826 -}
623.1827 -
623.1828 -BOOL MainWnd::OnOptionsJoypadAutofire(UINT nID)
623.1829 -{
623.1830 -	int & autoFire  = (theApp.autoFireToggle ? theApp.autoFire : theApp.autoFire2);
623.1831 -	int & autoFire2 = (theApp.autoFireToggle ? theApp.autoFire2 : theApp.autoFire);
623.1832 -	int   autoFires = (theApp.autoFire | theApp.autoFire2);
623.1833 -
623.1834 -	switch (nID)
623.1835 -	{
623.1836 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_A:
623.1837 -		if (autoFires & BUTTON_MASK_A)
623.1838 -		{
623.1839 -			autoFire &= ~BUTTON_MASK_A;
623.1840 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A_DISABLED));
623.1841 -		}
623.1842 -		else
623.1843 -		{
623.1844 -			autoFire |= BUTTON_MASK_A;
623.1845 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A));
623.1846 -		}
623.1847 -		autoFire2       &= ~BUTTON_MASK_A;
623.1848 -		theApp.autoHold &= ~BUTTON_MASK_A;
623.1849 -		break;
623.1850 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_B:
623.1851 -		if (autoFires & BUTTON_MASK_B)
623.1852 -		{
623.1853 -			autoFire &= ~BUTTON_MASK_B;
623.1854 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B_DISABLED));
623.1855 -		}
623.1856 -		else
623.1857 -		{
623.1858 -			autoFire |= BUTTON_MASK_B;
623.1859 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B));
623.1860 -		}
623.1861 -		autoFire2       &= ~BUTTON_MASK_B;
623.1862 -		theApp.autoHold &= ~BUTTON_MASK_B;
623.1863 -		break;
623.1864 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_L:
623.1865 -		if (autoFires & BUTTON_MASK_L)
623.1866 -		{
623.1867 -			autoFire &= ~BUTTON_MASK_L;
623.1868 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L_DISABLED));
623.1869 -		}
623.1870 -		else
623.1871 -		{
623.1872 -			autoFire |= BUTTON_MASK_L;
623.1873 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L));
623.1874 -		}
623.1875 -		autoFire2       &= ~BUTTON_MASK_L;
623.1876 -		theApp.autoHold &= ~BUTTON_MASK_L;
623.1877 -		break;
623.1878 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_R:
623.1879 -		if (autoFires & BUTTON_MASK_R)
623.1880 -		{
623.1881 -			autoFire &= ~BUTTON_MASK_R;
623.1882 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R_DISABLED));
623.1883 -		}
623.1884 -		else
623.1885 -		{
623.1886 -			autoFire |= BUTTON_MASK_R;
623.1887 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R));
623.1888 -		}
623.1889 -		autoFire2       &= ~BUTTON_MASK_R;
623.1890 -		theApp.autoHold &= ~BUTTON_MASK_R;
623.1891 -		break;
623.1892 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_START:
623.1893 -		if (autoFires & BUTTON_MASK_START)
623.1894 -		{
623.1895 -			autoFire &= ~BUTTON_MASK_START;
623.1896 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_START_DISABLED));
623.1897 -		}
623.1898 -		else
623.1899 -		{
623.1900 -			autoFire |= BUTTON_MASK_START;
623.1901 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_START));
623.1902 -		}
623.1903 -		autoFire2       &= ~BUTTON_MASK_START;
623.1904 -		theApp.autoHold &= ~BUTTON_MASK_START;
623.1905 -		break;
623.1906 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT:
623.1907 -		if (autoFires & BUTTON_MASK_SELECT)
623.1908 -		{
623.1909 -			autoFire &= ~BUTTON_MASK_SELECT;
623.1910 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_SELECT_DISABLED));
623.1911 -		}
623.1912 -		else
623.1913 -		{
623.1914 -			autoFire |= BUTTON_MASK_SELECT;
623.1915 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_SELECT));
623.1916 -		}
623.1917 -		autoFire2       &= ~BUTTON_MASK_SELECT;
623.1918 -		theApp.autoHold &= ~BUTTON_MASK_SELECT;
623.1919 -		break;
623.1920 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_UP:
623.1921 -		if (autoFires & BUTTON_MASK_UP)
623.1922 -		{
623.1923 -			autoFire &= ~BUTTON_MASK_UP;
623.1924 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_UP_DISABLED));
623.1925 -		}
623.1926 -		else
623.1927 -		{
623.1928 -			autoFire |= BUTTON_MASK_UP;
623.1929 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_UP));
623.1930 -		}
623.1931 -		autoFire2       &= ~BUTTON_MASK_UP;
623.1932 -		theApp.autoHold &= ~BUTTON_MASK_UP;
623.1933 -		break;
623.1934 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN:
623.1935 -		if (autoFires & BUTTON_MASK_DOWN)
623.1936 -		{
623.1937 -			autoFire &= ~BUTTON_MASK_DOWN;
623.1938 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DOWN_DISABLED));
623.1939 -		}
623.1940 -		else
623.1941 -		{
623.1942 -			autoFire |= BUTTON_MASK_DOWN;
623.1943 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DOWN));
623.1944 -		}
623.1945 -		autoFire2       &= ~BUTTON_MASK_DOWN;
623.1946 -		theApp.autoHold &= ~BUTTON_MASK_DOWN;
623.1947 -		break;
623.1948 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT:
623.1949 -		if (autoFires & BUTTON_MASK_LEFT)
623.1950 -		{
623.1951 -			autoFire &= ~BUTTON_MASK_LEFT;
623.1952 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_LEFT_DISABLED));
623.1953 -		}
623.1954 -		else
623.1955 -		{
623.1956 -			autoFire |= BUTTON_MASK_LEFT;
623.1957 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_LEFT));
623.1958 -		}
623.1959 -		autoFire2       &= ~BUTTON_MASK_LEFT;
623.1960 -		theApp.autoHold &= ~BUTTON_MASK_LEFT;
623.1961 -		break;
623.1962 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT:
623.1963 -		if (autoFires & BUTTON_MASK_RIGHT)
623.1964 -		{
623.1965 -			autoFire &= ~BUTTON_MASK_RIGHT;
623.1966 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_RIGHT_DISABLED));
623.1967 -		}
623.1968 -		else
623.1969 -		{
623.1970 -			autoFire |= BUTTON_MASK_RIGHT;
623.1971 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_RIGHT));
623.1972 -		}
623.1973 -		autoFire2       &= ~BUTTON_MASK_RIGHT;
623.1974 -		theApp.autoHold &= ~BUTTON_MASK_RIGHT;
623.1975 -		break;
623.1976 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR:
623.1977 -		if (autoFires != 0)
623.1978 -		{
623.1979 -			theApp.autoFire = theApp.autoFire2 = 0;
623.1980 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DISABLED));
623.1981 -		}
623.1982 -		else
623.1983 -		{
623.1984 -///      systemScreenMessage(winResLoadString(IDS_AUTOFIRE_ALREADY_DISABLED));
623.1985 -			systemScreenMessage("already cleared");
623.1986 -		}
623.1987 -		break;
623.1988 -	default:
623.1989 -		return FALSE;
623.1990 -	}
623.1991 -
623.1992 -	extern void VBAUpdateButtonPressDisplay(); VBAUpdateButtonPressDisplay();
623.1993 -
623.1994 -	return TRUE;
623.1995 -}
623.1996 -
623.1997 -void MainWnd::OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI)
623.1998 -{
623.1999 -///  pCmdUI->Enable(emulating); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2000 -// menu!
623.2001 -	pCmdUI->Enable(TRUE); // TEMP
623.2002 -
623.2003 -	int autoFires = (theApp.autoFire | theApp.autoFire2);
623.2004 -
623.2005 -	bool check = true;
623.2006 -	switch (pCmdUI->m_nID)
623.2007 -	{
623.2008 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_A:
623.2009 -		check = (autoFires & BUTTON_MASK_A) != 0;
623.2010 -		break;
623.2011 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_B:
623.2012 -		check = (autoFires & BUTTON_MASK_B) != 0;
623.2013 -		break;
623.2014 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_L:
623.2015 -		check = (autoFires & BUTTON_MASK_L) != 0;
623.2016 -///	extern int gbSgbMode; // from gbSGB.cpp
623.2017 -///	if(emulating && systemCartridgeType != 0 && !gbSgbMode) // regular GB has no L button
623.2018 -///      pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2019 -// menu!
623.2020 -		break;
623.2021 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_R:
623.2022 -		check = (autoFires & BUTTON_MASK_R) != 0;
623.2023 -///	extern int gbSgbMode; // from gbSGB.cpp
623.2024 -///	if(emulating && systemCartridgeType != 0 && !gbSgbMode) // regular GB has no R button
623.2025 -///      pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2026 -// menu!
623.2027 -		break;
623.2028 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_START:
623.2029 -		check = (autoFires & BUTTON_MASK_START) != 0;
623.2030 -		break;
623.2031 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT:
623.2032 -		check = (autoFires & BUTTON_MASK_SELECT) != 0;
623.2033 -		break;
623.2034 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_UP:
623.2035 -		check = (autoFires & BUTTON_MASK_UP) != 0;
623.2036 -		break;
623.2037 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN:
623.2038 -		check = (autoFires & BUTTON_MASK_DOWN) != 0;
623.2039 -		break;
623.2040 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT:
623.2041 -		check = (autoFires & BUTTON_MASK_LEFT) != 0;
623.2042 -		break;
623.2043 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT:
623.2044 -		check = (autoFires & BUTTON_MASK_RIGHT) != 0;
623.2045 -		break;
623.2046 -	case ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR:
623.2047 -		check = (autoFires == 0);
623.2048 -///    pCmdUI->Enable(!check); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu!
623.2049 -		break;
623.2050 -	}
623.2051 -	pCmdUI->SetCheck(check);
623.2052 -}
623.2053 -
623.2054 -BOOL MainWnd::OnOptionsJoypadSticky(UINT nID)
623.2055 -{
623.2056 -	switch (nID)
623.2057 -	{
623.2058 -	case ID_STICKY_A:
623.2059 -		if (theApp.autoHold & BUTTON_MASK_A)
623.2060 -		{
623.2061 -			theApp.autoHold &= ~BUTTON_MASK_A;
623.2062 -///      systemScreenMessage(winResLoadString(IDS_STICKY_A_DISABLED));
623.2063 -		}
623.2064 -		else
623.2065 -		{
623.2066 -			theApp.autoHold |= BUTTON_MASK_A;
623.2067 -///      systemScreenMessage(winResLoadString(IDS_STICKY_A));
623.2068 -		}
623.2069 -		theApp.autoFire  &= ~BUTTON_MASK_A;
623.2070 -		theApp.autoFire2 &= ~BUTTON_MASK_A;
623.2071 -		break;
623.2072 -	case ID_STICKY_B:
623.2073 -		if (theApp.autoHold & BUTTON_MASK_B)
623.2074 -		{
623.2075 -			theApp.autoHold &= ~BUTTON_MASK_B;
623.2076 -///      systemScreenMessage(winResLoadString(IDS_STICKY_B_DISABLED));
623.2077 -		}
623.2078 -		else
623.2079 -		{
623.2080 -			theApp.autoHold |= BUTTON_MASK_B;
623.2081 -///      systemScreenMessage(winResLoadString(IDS_STICKY_B));
623.2082 -		}
623.2083 -		theApp.autoFire  &= ~BUTTON_MASK_B;
623.2084 -		theApp.autoFire2 &= ~BUTTON_MASK_B;
623.2085 -		break;
623.2086 -	case ID_STICKY_L:
623.2087 -		if (theApp.autoHold & BUTTON_MASK_L)
623.2088 -		{
623.2089 -			theApp.autoHold &= ~BUTTON_MASK_L;
623.2090 -///      systemScreenMessage(winResLoadString(IDS_STICKY_L_DISABLED));
623.2091 -		}
623.2092 -		else
623.2093 -		{
623.2094 -			theApp.autoHold |= BUTTON_MASK_L;
623.2095 -///      systemScreenMessage(winResLoadString(IDS_STICKY_L));
623.2096 -		}
623.2097 -		theApp.autoFire  &= ~BUTTON_MASK_L;
623.2098 -		theApp.autoFire2 &= ~BUTTON_MASK_L;
623.2099 -		break;
623.2100 -	case ID_STICKY_R:
623.2101 -		if (theApp.autoHold & BUTTON_MASK_R)
623.2102 -		{
623.2103 -			theApp.autoHold &= ~BUTTON_MASK_R;
623.2104 -///      systemScreenMessage(winResLoadString(IDS_STICKY_R_DISABLED));
623.2105 -		}
623.2106 -		else
623.2107 -		{
623.2108 -			theApp.autoHold |= BUTTON_MASK_R;
623.2109 -///      systemScreenMessage(winResLoadString(IDS_STICKY_R));
623.2110 -		}
623.2111 -		theApp.autoFire  &= ~BUTTON_MASK_R;
623.2112 -		theApp.autoFire2 &= ~BUTTON_MASK_R;
623.2113 -		break;
623.2114 -	case ID_STICKY_START:
623.2115 -		if (theApp.autoHold & BUTTON_MASK_START)
623.2116 -		{
623.2117 -			theApp.autoHold &= ~BUTTON_MASK_START;
623.2118 -///      systemScreenMessage(winResLoadString(IDS_STICKY_START_DISABLED));
623.2119 -		}
623.2120 -		else
623.2121 -		{
623.2122 -			theApp.autoHold |= BUTTON_MASK_START;
623.2123 -///      systemScreenMessage(winResLoadString(IDS_STICKY_START));
623.2124 -		}
623.2125 -		theApp.autoFire  &= ~BUTTON_MASK_START;
623.2126 -		theApp.autoFire2 &= ~BUTTON_MASK_START;
623.2127 -		break;
623.2128 -	case ID_STICKY_SELECT:
623.2129 -		if (theApp.autoHold & BUTTON_MASK_SELECT)
623.2130 -		{
623.2131 -			theApp.autoHold &= ~BUTTON_MASK_SELECT;
623.2132 -///      systemScreenMessage(winResLoadString(IDS_STICKY_SELECT_DISABLED));
623.2133 -		}
623.2134 -		else
623.2135 -		{
623.2136 -			theApp.autoHold |= BUTTON_MASK_SELECT;
623.2137 -///      systemScreenMessage(winResLoadString(IDS_STICKY_SELECT));
623.2138 -		}
623.2139 -		theApp.autoFire  &= ~BUTTON_MASK_SELECT;
623.2140 -		theApp.autoFire2 &= ~BUTTON_MASK_SELECT;
623.2141 -		break;
623.2142 -	case ID_STICKY_UP:
623.2143 -		if (theApp.autoHold & BUTTON_MASK_UP)
623.2144 -		{
623.2145 -			theApp.autoHold &= ~BUTTON_MASK_UP;
623.2146 -///      systemScreenMessage(winResLoadString(IDS_STICKY_UP_DISABLED));
623.2147 -		}
623.2148 -		else
623.2149 -		{
623.2150 -			theApp.autoHold |= BUTTON_MASK_UP;
623.2151 -///      systemScreenMessage(winResLoadString(IDS_STICKY_UP));
623.2152 -		}
623.2153 -		theApp.autoFire  &= ~BUTTON_MASK_UP;
623.2154 -		theApp.autoFire2 &= ~BUTTON_MASK_UP;
623.2155 -		if (!theApp.allowLeftRight)
623.2156 -			theApp.autoHold &= ~BUTTON_MASK_DOWN;
623.2157 -		break;
623.2158 -	case ID_STICKY_DOWN:
623.2159 -		if (theApp.autoHold & BUTTON_MASK_DOWN)
623.2160 -		{
623.2161 -			theApp.autoHold &= ~BUTTON_MASK_DOWN;
623.2162 -///      systemScreenMessage(winResLoadString(IDS_STICKY_DOWN_DISABLED));
623.2163 -		}
623.2164 -		else
623.2165 -		{
623.2166 -			theApp.autoHold |= BUTTON_MASK_DOWN;
623.2167 -///      systemScreenMessage(winResLoadString(IDS_STICKY_DOWN));
623.2168 -		}
623.2169 -		theApp.autoFire  &= ~BUTTON_MASK_DOWN;
623.2170 -		theApp.autoFire2 &= ~BUTTON_MASK_DOWN;
623.2171 -		if (!theApp.allowLeftRight)
623.2172 -			theApp.autoHold &= ~BUTTON_MASK_UP;
623.2173 -		break;
623.2174 -	case ID_STICKY_LEFT:
623.2175 -		if (theApp.autoHold & BUTTON_MASK_LEFT)
623.2176 -		{
623.2177 -			theApp.autoHold &= ~BUTTON_MASK_LEFT;
623.2178 -///      systemScreenMessage(winResLoadString(IDS_STICKY_LEFT_DISABLED));
623.2179 -		}
623.2180 -		else
623.2181 -		{
623.2182 -			theApp.autoHold |= BUTTON_MASK_LEFT;
623.2183 -///      systemScreenMessage(winResLoadString(IDS_STICKY_LEFT));
623.2184 -		}
623.2185 -		theApp.autoFire  &= ~BUTTON_MASK_LEFT;
623.2186 -		theApp.autoFire2 &= ~BUTTON_MASK_LEFT;
623.2187 -		if (!theApp.allowLeftRight)
623.2188 -			theApp.autoHold &= ~BUTTON_MASK_RIGHT;
623.2189 -		break;
623.2190 -	case ID_STICKY_RIGHT:
623.2191 -		if (theApp.autoHold & BUTTON_MASK_RIGHT)
623.2192 -		{
623.2193 -			theApp.autoHold &= ~BUTTON_MASK_RIGHT;
623.2194 -///      systemScreenMessage(winResLoadString(IDS_STICKY_RIGHT_DISABLED));
623.2195 -		}
623.2196 -		else
623.2197 -		{
623.2198 -			theApp.autoHold |= BUTTON_MASK_RIGHT;
623.2199 -///      systemScreenMessage(winResLoadString(IDS_STICKY_RIGHT));
623.2200 -		}
623.2201 -		theApp.autoFire  &= ~BUTTON_MASK_RIGHT;
623.2202 -		theApp.autoFire2 &= ~BUTTON_MASK_RIGHT;
623.2203 -		if (!theApp.allowLeftRight)
623.2204 -			theApp.autoHold &= ~BUTTON_MASK_LEFT;
623.2205 -		break;
623.2206 -	case ID_STICKY_CLEAR:
623.2207 -		if (theApp.autoHold != 0)
623.2208 -		{
623.2209 -			theApp.autoHold = 0;
623.2210 -///      systemScreenMessage(winResLoadString(IDS_STICKY_DISABLED));
623.2211 -		}
623.2212 -		else
623.2213 -		{
623.2214 -///      systemScreenMessage(winResLoadString(IDS_STICKY_ALREADY_DISABLED));
623.2215 -			systemScreenMessage("already cleared");
623.2216 -		}
623.2217 -		break;
623.2218 -	default:
623.2219 -		return FALSE;
623.2220 -	}
623.2221 -
623.2222 -	extern void VBAUpdateButtonPressDisplay(); VBAUpdateButtonPressDisplay();
623.2223 -
623.2224 -	return TRUE;
623.2225 -}
623.2226 -
623.2227 -void MainWnd::OnUpdateOptionsJoypadSticky(CCmdUI *pCmdUI)
623.2228 -{
623.2229 -///  pCmdUI->Enable(emulating); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2230 -// menu!
623.2231 -	pCmdUI->Enable(TRUE); // TEMP
623.2232 -
623.2233 -	bool check = true;
623.2234 -	switch (pCmdUI->m_nID)
623.2235 -	{
623.2236 -	case ID_STICKY_A:
623.2237 -		check = (theApp.autoHold & BUTTON_MASK_A) != 0;
623.2238 -		break;
623.2239 -	case ID_STICKY_B:
623.2240 -		check = (theApp.autoHold & BUTTON_MASK_B) != 0;
623.2241 -		break;
623.2242 -	case ID_STICKY_L:
623.2243 -		check = (theApp.autoHold & BUTTON_MASK_L) != 0;
623.2244 -///	extern int gbSgbMode; // from gbSGB.cpp
623.2245 -///	if(emulating && systemCartridgeType != 0 && !gbSgbMode) // regular GB has no L button
623.2246 -///      pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2247 -// menu!
623.2248 -		break;
623.2249 -	case ID_STICKY_R:
623.2250 -		check = (theApp.autoHold & BUTTON_MASK_R) != 0;
623.2251 -///	extern int gbSgbMode; // from gbSGB.cpp
623.2252 -///	if(emulating && systemCartridgeType != 0 && !gbSgbMode) // regular GB has no R button
623.2253 -///      pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the
623.2254 -// menu!
623.2255 -		break;
623.2256 -	case ID_STICKY_START:
623.2257 -		check = (theApp.autoHold & BUTTON_MASK_START) != 0;
623.2258 -		break;
623.2259 -	case ID_STICKY_SELECT:
623.2260 -		check = (theApp.autoHold & BUTTON_MASK_SELECT) != 0;
623.2261 -		break;
623.2262 -	case ID_STICKY_UP:
623.2263 -		check = (theApp.autoHold & BUTTON_MASK_UP) != 0;
623.2264 -		break;
623.2265 -	case ID_STICKY_DOWN:
623.2266 -		check = (theApp.autoHold & BUTTON_MASK_DOWN) != 0;
623.2267 -		break;
623.2268 -	case ID_STICKY_LEFT:
623.2269 -		check = (theApp.autoHold & BUTTON_MASK_LEFT) != 0;
623.2270 -		break;
623.2271 -	case ID_STICKY_RIGHT:
623.2272 -		check = (theApp.autoHold & BUTTON_MASK_RIGHT) != 0;
623.2273 -		break;
623.2274 -	case ID_STICKY_CLEAR:
623.2275 -		check = (theApp.autoHold == 0);
623.2276 -///    pCmdUI->Enable(!check); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu!
623.2277 -		break;
623.2278 -	}
623.2279 -	pCmdUI->SetCheck(check);
623.2280 -}
623.2281 -
623.2282 -LRESULT MainWnd::OnConfirmMode(WPARAM, LPARAM)
623.2283 -{
623.2284 -	// we need to do this separately or the window will not have the right
623.2285 -	// parent. must be related to the way MFC does modal dialogs
623.2286 -	winConfirmMode();
623.2287 -	return 0;
623.2288 -}
623.2289 -
623.2290 -void MainWnd::OnOptionsVideoFullscreenmaxscale()
623.2291 -{
623.2292 -	MaxScale dlg;
623.2293 -
623.2294 -	theApp.winCheckFullscreen();
623.2295 -
623.2296 -	dlg.DoModal();
623.2297 -}
623.2298 -
623.2299 -void MainWnd::OnOptionsVideoTextdisplayoptions()
623.2300 -{
623.2301 -	TextOptions dlg;
623.2302 -
623.2303 -	theApp.winCheckFullscreen();
623.2304 -
623.2305 -	dlg.DoModal();
623.2306 -}
623.2307 -
623.2308 -void MainWnd::OnUpdateOptionsVideoTextdisplayoptions(CCmdUI *pCmdUI)
623.2309 -{
623.2310 -	pCmdUI->Enable(TRUE);
623.2311 -}
623.2312 -
   624.1 --- a/src/win32/MainWndTools.cpp	Sat Mar 03 10:54:39 2012 -0600
   624.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   624.3 @@ -1,1000 +0,0 @@
   624.4 -#include "stdafx.h"
   624.5 -#include <cassert>
   624.6 -#include "resource.h"
   624.7 -#include "MainWnd.h"
   624.8 -#include "AccelEditor.h"
   624.9 -#include "AVIWrite.h"
  624.10 -#include "Disassemble.h"
  624.11 -#include "FileDlg.h"
  624.12 -#include "GBDisassemble.h"
  624.13 -#include "GBMapView.h"
  624.14 -#include "GBMemoryViewerDlg.h"
  624.15 -#include "GBOamView.h"
  624.16 -#include "GBPaletteView.h"
  624.17 -#include "GBTileView.h"
  624.18 -#include "GDBConnection.h"
  624.19 -#include "IOViewer.h"
  624.20 -#include "MapView.h"
  624.21 -#include "MemoryViewerDlg.h"
  624.22 -#include "MovieOpen.h"
  624.23 -#include "MovieCreate.h"
  624.24 -#include "OamView.h"
  624.25 -#include "PaletteView.h"
  624.26 -#include "Reg.h"
  624.27 -#include "TileView.h"
  624.28 -#include "WavWriter.h"
  624.29 -#include "WinResUtil.h"
  624.30 -#include "WinMiscUtil.h"
  624.31 -#include "VBA.h"
  624.32 -
  624.33 -#include "../gba/GBA.h"
  624.34 -#include "../gba/GBAGlobals.h"
  624.35 -#include "../gb/GB.h"
  624.36 -
  624.37 -extern int32 gbBorderOn;
  624.38 -extern int32 soundQuality;
  624.39 -
  624.40 -extern bool debugger;
  624.41 -extern int	emulating;
  624.42 -extern int	remoteSocket;
  624.43 -
  624.44 -extern void remoteCleanUp();
  624.45 -extern void remoteSetSockets(SOCKET, SOCKET);
  624.46 -extern void toolsLogging();
  624.47 -
  624.48 -void MainWnd::OnToolsDisassemble()
  624.49 -{
  624.50 -	if (systemCartridgeType == 0)
  624.51 -	{
  624.52 -		Disassemble *dlg = new Disassemble();
  624.53 -		dlg->Create(IDD_DISASSEMBLE, this);
  624.54 -		dlg->ShowWindow(SW_SHOW);
  624.55 -	}
  624.56 -	else
  624.57 -	{
  624.58 -		GBDisassemble *dlg = new GBDisassemble();
  624.59 -		dlg->Create(IDD_GB_DISASSEMBLE, this);
  624.60 -		dlg->ShowWindow(SW_SHOW);
  624.61 -	}
  624.62 -}
  624.63 -
  624.64 -void MainWnd::OnUpdateToolsDisassemble(CCmdUI *pCmdUI)
  624.65 -{
  624.66 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
  624.67 -}
  624.68 -
  624.69 -void MainWnd::OnToolsLogging()
  624.70 -{
  624.71 -	toolsLogging();
  624.72 -}
  624.73 -
  624.74 -void MainWnd::OnUpdateToolsLogging(CCmdUI *pCmdUI)
  624.75 -{
  624.76 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
  624.77 -}
  624.78 -
  624.79 -void MainWnd::OnToolsIoviewer()
  624.80 -{
  624.81 -	IOViewer *dlg = new IOViewer;
  624.82 -	dlg->Create(IDD_IO_VIEWER, this);
  624.83 -	dlg->ShowWindow(SW_SHOW);
  624.84 -}
  624.85 -
  624.86 -void MainWnd::OnUpdateToolsIoviewer(CCmdUI *pCmdUI)
  624.87 -{
  624.88 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && systemCartridgeType == 0);
  624.89 -}
  624.90 -
  624.91 -void MainWnd::OnToolsMapview()
  624.92 -{
  624.93 -	if (systemCartridgeType == 0)
  624.94 -	{
  624.95 -		MapView *dlg = new MapView;
  624.96 -		dlg->Create(IDD_MAP_VIEW, this);
  624.97 -		dlg->ShowWindow(SW_SHOW);
  624.98 -	}
  624.99 -	else
 624.100 -	{
 624.101 -		GBMapView *dlg = new GBMapView;
 624.102 -		dlg->Create(IDD_GB_MAP_VIEW, this);
 624.103 -		dlg->ShowWindow(SW_SHOW);
 624.104 -	}
 624.105 -}
 624.106 -
 624.107 -void MainWnd::OnUpdateToolsMapview(CCmdUI *pCmdUI)
 624.108 -{
 624.109 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
 624.110 -}
 624.111 -
 624.112 -void MainWnd::OnToolsMemoryviewer()
 624.113 -{
 624.114 -	if (systemCartridgeType == 0)
 624.115 -	{
 624.116 -		MemoryViewerDlg *dlg = new MemoryViewerDlg;
 624.117 -		dlg->Create(IDD_MEM_VIEWER, this);
 624.118 -		dlg->ShowWindow(SW_SHOW);
 624.119 -	}
 624.120 -	else
 624.121 -	{
 624.122 -		GBMemoryViewerDlg *dlg = new GBMemoryViewerDlg;
 624.123 -		dlg->Create(IDD_MEM_VIEWER, this);
 624.124 -		dlg->ShowWindow(SW_SHOW);
 624.125 -	}
 624.126 -}
 624.127 -
 624.128 -void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI *pCmdUI)
 624.129 -{
 624.130 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
 624.131 -}
 624.132 -
 624.133 -void MainWnd::OnToolsOamviewer()
 624.134 -{
 624.135 -	if (systemCartridgeType == 0)
 624.136 -	{
 624.137 -		OamView *dlg = new OamView;
 624.138 -		dlg->Create(IDD_OAM_VIEW, this);
 624.139 -		dlg->ShowWindow(SW_SHOW);
 624.140 -	}
 624.141 -	else
 624.142 -	{
 624.143 -		GBOamView *dlg = new GBOamView;
 624.144 -		dlg->Create(IDD_GB_OAM_VIEW, this);
 624.145 -		dlg->ShowWindow(SW_SHOW);
 624.146 -	}
 624.147 -}
 624.148 -
 624.149 -void MainWnd::OnUpdateToolsOamviewer(CCmdUI *pCmdUI)
 624.150 -{
 624.151 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
 624.152 -}
 624.153 -
 624.154 -void MainWnd::OnToolsPaletteview()
 624.155 -{
 624.156 -	if (systemCartridgeType == 0)
 624.157 -	{
 624.158 -		PaletteView *dlg = new PaletteView;
 624.159 -		dlg->Create(IDD_PALETTE_VIEW, this);
 624.160 -		dlg->ShowWindow(SW_SHOW);
 624.161 -	}
 624.162 -	else
 624.163 -	{
 624.164 -		GBPaletteView *dlg = new GBPaletteView;
 624.165 -		dlg->Create(IDD_GB_PALETTE_VIEW, this);
 624.166 -		dlg->ShowWindow(SW_SHOW);
 624.167 -	}
 624.168 -}
 624.169 -
 624.170 -void MainWnd::OnUpdateToolsPaletteview(CCmdUI *pCmdUI)
 624.171 -{
 624.172 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
 624.173 -}
 624.174 -
 624.175 -void MainWnd::OnToolsTileviewer()
 624.176 -{
 624.177 -	if (systemCartridgeType == 0)
 624.178 -	{
 624.179 -		TileView *dlg = new TileView;
 624.180 -		dlg->Create(IDD_TILE_VIEWER, this);
 624.181 -		dlg->ShowWindow(SW_SHOW);
 624.182 -	}
 624.183 -	else
 624.184 -	{
 624.185 -		GBTileView *dlg = new GBTileView;
 624.186 -		dlg->Create(IDD_GB_TILE_VIEWER, this);
 624.187 -		dlg->ShowWindow(SW_SHOW);
 624.188 -	}
 624.189 -}
 624.190 -
 624.191 -void MainWnd::OnUpdateToolsTileviewer(CCmdUI *pCmdUI)
 624.192 -{
 624.193 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X);
 624.194 -}
 624.195 -
 624.196 -void MainWnd::OnDebugNextframe()
 624.197 -{
 624.198 -	systemSetPause(false);
 624.199 -	theApp.winPauseNextFrame = true;
 624.200 -}
 624.201 -
 624.202 -void MainWnd::OnUpdateDebugNextframe(CCmdUI *pCmdUI)
 624.203 -{
 624.204 -	pCmdUI->Enable(emulating);
 624.205 -}
 624.206 -
 624.207 -void MainWnd::OnDebugNextframeAccountForLag()
 624.208 -{
 624.209 -	theApp.nextframeAccountForLag = !theApp.nextframeAccountForLag;
 624.210 -}
 624.211 -
 624.212 -void MainWnd::OnUpdateDebugNextframeAccountForLag(CCmdUI *pCmdUI)
 624.213 -{
 624.214 -	pCmdUI->SetCheck(theApp.nextframeAccountForLag);
 624.215 -}
 624.216 -
 624.217 -void MainWnd::OnDebugFramesearch()
 624.218 -{
 624.219 -	extern u16	  currentButtons [4];  // from System.cpp
 624.220 -	extern SMovie Movie;
 624.221 -	if (!theApp.frameSearching)
 624.222 -	{
 624.223 -		// starting a new search
 624.224 -		theApp.frameSearching		= true;
 624.225 -		theApp.frameSearchStart		= (Movie.state == MOVIE_STATE_NONE) ? systemCounters.frameCount : Movie.currentFrame;
 624.226 -		theApp.frameSearchLength	= 0;
 624.227 -		theApp.frameSearchLoadValid = false;
 624.228 -		theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE * 0], REWIND_SIZE); // 0 is start state, 1 is
 624.229 -		                                                                                           // intermediate state (for
 624.230 -		                                                                                           // speedup when going
 624.231 -		                                                                                           // forward),
 624.232 -		                                                                                           // 2 is end state
 624.233 -		theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE * 1], REWIND_SIZE);
 624.234 -
 624.235 -		// store old buttons from frame before the search
 624.236 -		for (int i = 0; i < 4; i++)
 624.237 -			theApp.frameSearchOldInput[i] = currentButtons[i];
 624.238 -	}
 624.239 -	else
 624.240 -	{
 624.241 -		// advance forward 1 step in the search
 624.242 -		theApp.frameSearchLength++;
 624.243 -
 624.244 -		// try it
 624.245 -		theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE * 1], REWIND_SIZE);
 624.246 -	}
 624.247 -
 624.248 -	char str [32];
 624.249 -	sprintf(str, "%d frame search", theApp.frameSearchLength);
 624.250 -	systemScreenMessage(str, 0);
 624.251 -
 624.252 -	theApp.frameSearchSkipping = true;
 624.253 -
 624.254 -	// make sure the display updates at least 1 frame to show the new message
 624.255 -	theApp.frameSearchFirstStep = true;
 624.256 -
 624.257 -	if (theApp.paused)
 624.258 -		theApp.paused = false;
 624.259 -}
 624.260 -
 624.261 -void MainWnd::OnUpdateDebugFramesearch(CCmdUI *pCmdUI)
 624.262 -{
 624.263 -	extern SMovie Movie;
 624.264 -	pCmdUI->Enable(emulating && Movie.state != MOVIE_STATE_PLAY);
 624.265 -	pCmdUI->SetCheck(theApp.frameSearching);
 624.266 -}
 624.267 -
 624.268 -void MainWnd::OnDebugFramesearchPrev()
 624.269 -{
 624.270 -	if (theApp.frameSearching)
 624.271 -	{
 624.272 -		if (theApp.frameSearchLength > 0)
 624.273 -		{
 624.274 -			// rewind 1 step in the search
 624.275 -			theApp.frameSearchLength--;
 624.276 -		}
 624.277 -
 624.278 -		// try it
 624.279 -		theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE * 0], REWIND_SIZE);
 624.280 -
 624.281 -		char str[32];
 624.282 -		sprintf(str, "%d frame search", theApp.frameSearchLength);
 624.283 -		systemScreenMessage(str, 0);
 624.284 -
 624.285 -		theApp.frameSearchSkipping = true;
 624.286 -
 624.287 -		// make sure the display updates at least 1 frame to show the new message
 624.288 -		theApp.frameSearchFirstStep = true;
 624.289 -
 624.290 -		if (theApp.paused)
 624.291 -			theApp.paused = false;
 624.292 -	}
 624.293 -}
 624.294 -
 624.295 -void MainWnd::OnUpdateDebugFramesearchPrev(CCmdUI *pCmdUI)
 624.296 -{
 624.297 -	extern SMovie Movie;
 624.298 -	pCmdUI->Enable(emulating && theApp.frameSearching && Movie.state != MOVIE_STATE_PLAY);
 624.299 -}
 624.300 -
 624.301 -void MainWnd::OnDebugFramesearchLoad()
 624.302 -{
 624.303 -	if (theApp.frameSearchLoadValid)
 624.304 -	{
 624.305 -		theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE * 2], REWIND_SIZE);
 624.306 -		theApp.paused = true;
 624.307 -
 624.308 -		if (theApp.frameSearching)
 624.309 -			systemScreenMessage("end frame search", 0);
 624.310 -		else
 624.311 -			systemScreenMessage("restore search end", 0);
 624.312 -	}
 624.313 -	theApp.frameSearching	   = false;
 624.314 -	theApp.frameSearchSkipping = false;
 624.315 -}
 624.316 -
 624.317 -void MainWnd::OnUpdateDebugFramesearchLoad(CCmdUI *pCmdUI)
 624.318 -{
 624.319 -	extern SMovie Movie;
 624.320 -	pCmdUI->Enable(emulating && Movie.state != MOVIE_STATE_PLAY);
 624.321 -}
 624.322 -
 624.323 -void MainWnd::OnToolsFrameCounter()
 624.324 -{
 624.325 -	theApp.frameCounter = !theApp.frameCounter;
 624.326 -	extern void VBAUpdateFrameCountDisplay(); VBAUpdateFrameCountDisplay();
 624.327 -}
 624.328 -
 624.329 -void MainWnd::OnUpdateToolsFrameCounter(CCmdUI *pCmdUI)
 624.330 -{
 624.331 -	pCmdUI->SetCheck(theApp.frameCounter);
 624.332 -}
 624.333 -
 624.334 -void MainWnd::OnToolsLagCounter()
 624.335 -{
 624.336 -	theApp.lagCounter = !theApp.lagCounter;
 624.337 -	extern void VBAUpdateFrameCountDisplay(); VBAUpdateFrameCountDisplay();
 624.338 -}
 624.339 -
 624.340 -void MainWnd::OnUpdateToolsLagCounter(CCmdUI *pCmdUI)
 624.341 -{
 624.342 -	pCmdUI->SetCheck(theApp.lagCounter);
 624.343 -}
 624.344 -
 624.345 -void MainWnd::OnToolsExtraCounter()
 624.346 -{
 624.347 -	theApp.extraCounter = !theApp.extraCounter;
 624.348 -	extern void VBAUpdateFrameCountDisplay(); VBAUpdateFrameCountDisplay();
 624.349 -}
 624.350 -
 624.351 -void MainWnd::OnUpdateToolsExtraCounter(CCmdUI *pCmdUI)
 624.352 -{
 624.353 -	pCmdUI->SetCheck(theApp.extraCounter);
 624.354 -}
 624.355 -
 624.356 -void MainWnd::OnToolsExtraCounterReset()
 624.357 -{
 624.358 -	systemCounters.extraCount = systemCounters.frameCount;
 624.359 -}
 624.360 -
 624.361 -void MainWnd::OnToolsInputDisplay()
 624.362 -{
 624.363 -	theApp.inputDisplay = !theApp.inputDisplay;
 624.364 -	systemScreenMessage(theApp.inputDisplay ? "Input Display On" : "Input Display Off");
 624.365 -	extern void VBAUpdateButtonPressDisplay(); VBAUpdateButtonPressDisplay();
 624.366 -}
 624.367 -
 624.368 -void MainWnd::OnUpdateToolsInputDisplay(CCmdUI *pCmdUI)
 624.369 -{
 624.370 -	pCmdUI->SetCheck(theApp.inputDisplay);
 624.371 -}
 624.372 -
 624.373 -void MainWnd::OnToolsDebugGdb()
 624.374 -{
 624.375 -	theApp.winCheckFullscreen();
 624.376 -	GDBPortDlg dlg;
 624.377 -
 624.378 -	if (dlg.DoModal())
 624.379 -	{
 624.380 -		GDBWaitingDlg wait(dlg.getSocket(), dlg.getPort());
 624.381 -		if (wait.DoModal())
 624.382 -		{
 624.383 -			remoteSetSockets(wait.getListenSocket(), wait.getSocket());
 624.384 -			debugger  = true;
 624.385 -			emulating = 1;
 624.386 -			systemCartridgeType = 0;
 624.387 -			theApp.gameFilename = "\\gnu_stub";
 624.388 -			rom					= (u8 *)malloc(0x2000000 + 4);
 624.389 -			workRAM				= (u8 *)calloc(1, 0x40000 + 4);
 624.390 -			bios				= (u8 *)calloc(1, 0x4000 + 4);
 624.391 -			internalRAM			= (u8 *)calloc(1, 0x8000 + 4);
 624.392 -			paletteRAM			= (u8 *)calloc(1, 0x400 + 4);
 624.393 -			vram				= (u8 *)calloc(1, 0x20000 + 4);
 624.394 -			oam					= (u8 *)calloc(1, 0x400 + 4);
 624.395 -			pix					= (u8 *)calloc(1, 4 * 240 * 160);
 624.396 -			ioMem				= (u8 *)calloc(1, 0x400 + 4);
 624.397 -
 624.398 -			theApp.emulator = GBASystem;
 624.399 -
 624.400 -			CPUInit();
 624.401 -			CPULoadBios(theApp.biosFileName, theApp.useBiosFile ? true : false);
 624.402 -			CPUReset();
 624.403 -		}
 624.404 -	}
 624.405 -}
 624.406 -
 624.407 -void MainWnd::OnUpdateToolsDebugGdb(CCmdUI *pCmdUI)
 624.408 -{
 624.409 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket == -1);
 624.410 -}
 624.411 -
 624.412 -void MainWnd::OnToolsDebugLoadandwait()
 624.413 -{
 624.414 -	theApp.winCheckFullscreen();
 624.415 -	if (winFileOpenSelect(0))
 624.416 -	{
 624.417 -		if (winFileRun())
 624.418 -		{
 624.419 -			if (systemCartridgeType != 0)
 624.420 -			{
 624.421 -				systemMessage(IDS_ERROR_NOT_GBA_IMAGE, "Error: not a GBA image");
 624.422 -				OnFileClose();
 624.423 -				return;
 624.424 -			}
 624.425 -			GDBPortDlg dlg;
 624.426 -
 624.427 -			if (dlg.DoModal())
 624.428 -			{
 624.429 -				GDBWaitingDlg wait(dlg.getSocket(), dlg.getPort());
 624.430 -				if (wait.DoModal())
 624.431 -				{
 624.432 -					remoteSetSockets(wait.getListenSocket(), wait.getSocket());
 624.433 -					debugger  = true;
 624.434 -					emulating = 1;
 624.435 -				}
 624.436 -			}
 624.437 -		}
 624.438 -	}
 624.439 -}
 624.440 -
 624.441 -void MainWnd::OnUpdateToolsDebugLoadandwait(CCmdUI *pCmdUI)
 624.442 -{
 624.443 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket == -1);
 624.444 -}
 624.445 -
 624.446 -void MainWnd::OnToolsDebugBreak()
 624.447 -{
 624.448 -	if (armState)
 624.449 -	{
 624.450 -		armNextPC -= 4;
 624.451 -		reg[15].I -= 4;
 624.452 -	}
 624.453 -	else
 624.454 -	{
 624.455 -		armNextPC -= 2;
 624.456 -		reg[15].I -= 2;
 624.457 -	}
 624.458 -	debugger = true;
 624.459 -}
 624.460 -
 624.461 -void MainWnd::OnUpdateToolsDebugBreak(CCmdUI *pCmdUI)
 624.462 -{
 624.463 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket != -1);
 624.464 -}
 624.465 -
 624.466 -void MainWnd::OnToolsDebugDisconnect()
 624.467 -{
 624.468 -	remoteCleanUp();
 624.469 -	debugger = false;
 624.470 -}
 624.471 -
 624.472 -void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI *pCmdUI)
 624.473 -{
 624.474 -	pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket != -1);
 624.475 -}
 624.476 -
 624.477 -void MainWnd::OnToolsSoundRecording()
 624.478 -{
 624.479 -	if (!theApp.soundRecording)
 624.480 -		OnToolsSoundStartrecording();
 624.481 -	else
 624.482 -		OnToolsSoundStoprecording();
 624.483 -}
 624.484 -
 624.485 -void MainWnd::OnToolsSoundStartrecording()
 624.486 -{
 624.487 -	theApp.winCheckFullscreen();
 624.488 -
 624.489 -	CString wavName = theApp.gameFilename;
 624.490 -
 624.491 -	if (VBAMovieActive())
 624.492 -	{
 624.493 -		extern SMovie Movie;
 624.494 -		wavName = Movie.filename;
 624.495 -		int index = wavName.ReverseFind('.');
 624.496 -		if (index != -1)
 624.497 -			wavName = wavName.Left(index);
 624.498 -	}
 624.499 -
 624.500 -	LPCTSTR exts[] = { ".wav", NULL };
 624.501 -
 624.502 -	CString filter = winResLoadFilter(IDS_FILTER_WAV);
 624.503 -	CString title  = winResLoadString(IDS_SELECT_WAV_NAME);
 624.504 -
 624.505 -	wavName = winGetDestFilename(wavName, IDS_WAV_DIR, exts[0]);
 624.506 -	CString wavDir = winGetDestDir(IDS_WAV_DIR);
 624.507 -
 624.508 -	FileDlg dlg(this, wavName, filter, 1, "WAV", exts, wavDir, title, true);
 624.509 -
 624.510 -	if (dlg.DoModal() == IDCANCEL)
 624.511 -	{
 624.512 -		return;
 624.513 -	}
 624.514 -
 624.515 -	theApp.soundRecordName = dlg.GetPathName();
 624.516 -	theApp.soundRecording  = true;
 624.517 -}
 624.518 -
 624.519 -void MainWnd::OnToolsSoundStoprecording()
 624.520 -{
 624.521 -	if (theApp.soundRecorder)
 624.522 -	{
 624.523 -		delete theApp.soundRecorder;
 624.524 -		theApp.soundRecorder = NULL;
 624.525 -	}
 624.526 -	theApp.soundRecording = false;
 624.527 -}
 624.528 -
 624.529 -void MainWnd::OnUpdateToolsSoundRecording(CCmdUI *pCmdUI)
 624.530 -{
 624.531 -	if (pCmdUI->m_pMenu != NULL)
 624.532 -	{
 624.533 -		if (!theApp.soundRecording)
 624.534 -			pCmdUI->SetText(winResLoadString(IDS_STARTSOUNDRECORDING));
 624.535 -		else
 624.536 -			pCmdUI->SetText(winResLoadString(IDS_STOPSOUNDRECORDING));
 624.537 -
 624.538 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 624.539 -	}
 624.540 -
 624.541 -	pCmdUI->Enable(emulating);
 624.542 -}
 624.543 -
 624.544 -void MainWnd::OnToolsAVIRecording()
 624.545 -{
 624.546 -	if (!theApp.aviRecording)
 624.547 -		OnToolsStartAVIRecording();
 624.548 -	else
 624.549 -		OnToolsStopAVIRecording();
 624.550 -}
 624.551 -
 624.552 -void MainWnd::OnToolsStartAVIRecording()
 624.553 -{
 624.554 -	theApp.winCheckFullscreen();
 624.555 -
 624.556 -	CString aviName = theApp.gameFilename;
 624.557 -
 624.558 -	if (VBAMovieActive())
 624.559 -	{
 624.560 -		extern SMovie Movie;
 624.561 -		aviName = Movie.filename;
 624.562 -		int index = aviName.ReverseFind('.');
 624.563 -		if (index != -1)
 624.564 -			aviName = aviName.Left(index);
 624.565 -	}
 624.566 -
 624.567 -	LPCTSTR exts[] = { ".avi", NULL };
 624.568 -
 624.569 -	CString filter = winResLoadFilter(IDS_FILTER_AVI);
 624.570 -	CString title  = winResLoadString(IDS_SELECT_AVI_NAME);
 624.571 -
 624.572 -	aviName = winGetDestFilename(aviName, IDS_AVI_DIR, exts[0]);
 624.573 -	CString aviDir = winGetDestDir(IDS_AVI_DIR);
 624.574 -
 624.575 -	FileDlg dlg(this, aviName, filter, 1, "AVI", exts, aviDir, title, true);
 624.576 -
 624.577 -	if (dlg.DoModal() == IDCANCEL)
 624.578 -	{
 624.579 -		return;
 624.580 -	}
 624.581 -
 624.582 -	theApp.aviRecordName = theApp.soundRecordName =  dlg.GetPathName();
 624.583 -	theApp.aviRecording	 = true;
 624.584 -
 624.585 -///  extern long linearFrameCount; linearFrameCount = 0;
 624.586 -///  extern long linearSoundByteCount; linearSoundByteCount = 0;
 624.587 -
 624.588 -	if (theApp.aviRecorder == NULL)
 624.589 -	{
 624.590 -		int width  = 240;
 624.591 -		int height = 160;
 624.592 -		switch (systemCartridgeType)
 624.593 -		{
 624.594 -		case 0:
 624.595 -			width  = 240;
 624.596 -			height = 160;
 624.597 -			break;
 624.598 -		case 1:
 624.599 -			if (gbBorderOn)
 624.600 -			{
 624.601 -				width  = 256;
 624.602 -				height = 224;
 624.603 -			}
 624.604 -			else
 624.605 -			{
 624.606 -				width  = 160;
 624.607 -				height = 144;
 624.608 -			}
 624.609 -			break;
 624.610 -		}
 624.611 -
 624.612 -		theApp.aviRecorder = new AVIWrite();
 624.613 -
 624.614 -		theApp.aviRecorder->SetFPS(60);
 624.615 -
 624.616 -		BITMAPINFOHEADER bi;
 624.617 -		memset(&bi, 0, sizeof(bi));
 624.618 -		bi.biSize	   = 0x28;
 624.619 -		bi.biPlanes	   = 1;
 624.620 -		bi.biBitCount  = 24;
 624.621 -		bi.biWidth	   = width;
 624.622 -		bi.biHeight	   = height;
 624.623 -		bi.biSizeImage = 3 * width * height;
 624.624 -		theApp.aviRecorder->SetVideoFormat(&bi);
 624.625 -		if (!theApp.aviRecorder->Open(theApp.aviRecordName))
 624.626 -		{
 624.627 -			delete theApp.aviRecorder;
 624.628 -			theApp.aviRecorder	= NULL;
 624.629 -			theApp.aviRecording = false;
 624.630 -		}
 624.631 -
 624.632 -		if (theApp.aviRecorder)
 624.633 -		{
 624.634 -			WAVEFORMATEX wfx;
 624.635 -			memset(&wfx, 0, sizeof(wfx));
 624.636 -			wfx.wFormatTag		= WAVE_FORMAT_PCM;
 624.637 -			wfx.nChannels		= 2;
 624.638 -			wfx.nSamplesPerSec	= 44100 / soundQuality;
 624.639 -			wfx.wBitsPerSample	= 16;
 624.640 -			wfx.nBlockAlign		= (wfx.wBitsPerSample / 8) * wfx.nChannels;
 624.641 -			wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
 624.642 -			wfx.cbSize = 0;
 624.643 -			theApp.aviRecorder->SetSoundFormat(&wfx);
 624.644 -		}
 624.645 -	}
 624.646 -}
 624.647 -
 624.648 -void MainWnd::OnToolsPauseAVIRecording()
 624.649 -{
 624.650 -	theApp.aviRecorder->Pause(!theApp.aviRecorder->IsPaused());
 624.651 -}
 624.652 -
 624.653 -void MainWnd::OnToolsStopAVIRecording()
 624.654 -{
 624.655 -	if (theApp.aviRecorder != NULL)
 624.656 -	{
 624.657 -		delete theApp.aviRecorder;
 624.658 -		theApp.aviRecorder = NULL;
 624.659 -	}
 624.660 -	theApp.aviRecording = false;
 624.661 -}
 624.662 -
 624.663 -void MainWnd::OnUpdateToolsAVIRecording(CCmdUI *pCmdUI)
 624.664 -{
 624.665 -	if (pCmdUI->m_pMenu != NULL)
 624.666 -	{
 624.667 -		if (!theApp.aviRecording)
 624.668 -			pCmdUI->SetText(winResLoadString(IDS_STARTAVIRECORDING));
 624.669 -		else
 624.670 -			pCmdUI->SetText(winResLoadString(IDS_STOPAVIRECORDING));
 624.671 -
 624.672 -		theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 624.673 -	}
 624.674 -
 624.675 -	pCmdUI->Enable(emulating);
 624.676 -}
 624.677 -
 624.678 -void MainWnd::OnUpdateToolsPauseAVIRecording(CCmdUI *pCmdUI)
 624.679 -{
 624.680 -	if (pCmdUI->m_pMenu != NULL)
 624.681 -	{
 624.682 -		if (!theApp.aviRecording)
 624.683 -		{
 624.684 -			pCmdUI->SetText(winResLoadString(IDS_PAUSEAVIRECORDING));
 624.685 -			theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 624.686 -			pCmdUI->Enable(false);
 624.687 -		}
 624.688 -		else
 624.689 -		{
 624.690 -			if (!theApp.aviRecorder->IsPaused())
 624.691 -				pCmdUI->SetText(winResLoadString(IDS_PAUSEAVIRECORDING));
 624.692 -			else
 624.693 -				pCmdUI->SetText(winResLoadString(IDS_RESUMEAVIRECORDING));
 624.694 -
 624.695 -			theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
 624.696 -			pCmdUI->Enable(emulating);
 624.697 -		}
 624.698 -	}
 624.699 -}
 624.700 -
 624.701 -void MainWnd::OnToolsRecordMovie()
 624.702 -{
 624.703 -	MovieCreate dlg;
 624.704 -	dlg.DoModal();
 624.705 -}
 624.706 -
 624.707 -void MainWnd::OnUpdateToolsRecordMovie(CCmdUI *pCmdUI)
 624.708 -{
 624.709 -	pCmdUI->Enable(emulating);
 624.710 -}
 624.711 -
 624.712 -void MainWnd::OnToolsStopMovie()
 624.713 -{
 624.714 -	VBAMovieStop(false);
 624.715 -}
 624.716 -
 624.717 -void MainWnd::OnUpdateToolsStopMovie(CCmdUI *pCmdUI)
 624.718 -{
 624.719 -	pCmdUI->Enable(emulating && VBAMovieActive());
 624.720 -}
 624.721 -
 624.722 -void MainWnd::OnToolsPlayMovie()
 624.723 -{
 624.724 -	MovieOpen dlg;
 624.725 -	dlg.DoModal();
 624.726 -}
 624.727 -
 624.728 -void MainWnd::OnUpdateToolsPlayMovie(CCmdUI *pCmdUI)
 624.729 -{
 624.730 -	pCmdUI->Enable(emulating);
 624.731 -}
 624.732 -
 624.733 -void MainWnd::OnToolsPlayReadOnly()
 624.734 -{
 624.735 -	if (!VBAMovieActive())
 624.736 -	{
 624.737 -		theApp.movieReadOnly = !theApp.movieReadOnly;
 624.738 -		systemScreenMessage(theApp.movieReadOnly ? "Movie now read-only" : "Movie now editable");
 624.739 -	}
 624.740 -	else
 624.741 -		VBAMovieToggleReadOnly();
 624.742 -}
 624.743 -
 624.744 -void MainWnd::OnUpdateToolsPlayReadOnly(CCmdUI *pCmdUI)
 624.745 -{
 624.746 -///  pCmdUI->Enable(VBAMovieActive()); // FIXME: this is right, but disabling menu items screws up accelerators until you view
 624.747 -// the menu!
 624.748 -///  pCmdUI->SetCheck(VBAMovieReadOnly());
 624.749 -	pCmdUI->Enable(TRUE); // TEMP
 624.750 -	pCmdUI->SetCheck(VBAMovieActive() ? VBAMovieReadOnly() : theApp.movieReadOnly);
 624.751 -}
 624.752 -
 624.753 -void MainWnd::OnAsscWithSaveState()
 624.754 -{
 624.755 -	theApp.AsscWithSaveState = !theApp.AsscWithSaveState;
 624.756 -}
 624.757 -
 624.758 -void MainWnd::OnUpdateAsscWithSaveState(CCmdUI *pCmdUI)
 624.759 -{
 624.760 -	pCmdUI->Enable(TRUE); // TEMP
 624.761 -	pCmdUI->SetCheck(theApp.AsscWithSaveState);
 624.762 -}
 624.763 -
 624.764 -void MainWnd::OnToolsResumeRecord()
 624.765 -{
 624.766 -	// toggle playing/recording
 624.767 -	if (VBAMovieRecording())
 624.768 -	{
 624.769 -		if (!VBAMovieSwitchToPlaying())
 624.770 -			systemScreenMessage("Cannot continue playing");
 624.771 -	}
 624.772 -	else
 624.773 -	{
 624.774 -		if (!VBAMovieSwitchToRecording())
 624.775 -			systemScreenMessage("Cannot resume recording now");
 624.776 -	}
 624.777 -}
 624.778 -
 624.779 -void MainWnd::OnUpdateToolsResumeRecord(CCmdUI *pCmdUI)
 624.780 -{
 624.781 -	pCmdUI->Enable(VBAMovieActive());
 624.782 -}
 624.783 -
 624.784 -void MainWnd::OnToolsPlayRestart()
 624.785 -{
 624.786 -	VBAMovieRestart();
 624.787 -}
 624.788 -
 624.789 -void MainWnd::OnUpdateToolsPlayRestart(CCmdUI *pCmdUI)
 624.790 -{
 624.791 -	pCmdUI->Enable(VBAMovieActive());
 624.792 -}
 624.793 -
 624.794 -void MainWnd::OnToolsOnMovieEndPause()
 624.795 -{
 624.796 -	theApp.movieOnEndPause = !theApp.movieOnEndPause;
 624.797 -}
 624.798 -
 624.799 -void MainWnd::OnUpdateToolsOnMovieEndPause(CCmdUI *pCmdUI)
 624.800 -{
 624.801 -	pCmdUI->SetCheck(theApp.movieOnEndPause);
 624.802 -}
 624.803 -
 624.804 -void MainWnd::OnToolsOnMovieEndStop()
 624.805 -{
 624.806 -	theApp.movieOnEndBehavior = 0;
 624.807 -}
 624.808 -
 624.809 -void MainWnd::OnUpdateToolsOnMovieEndStop(CCmdUI *pCmdUI)
 624.810 -{
 624.811 -	pCmdUI->SetRadio(theApp.movieOnEndBehavior == 0);
 624.812 -}
 624.813 -
 624.814 -void MainWnd::OnToolsOnMovieEndRestart()
 624.815 -{
 624.816 -	theApp.movieOnEndBehavior = 1;
 624.817 -}
 624.818 -
 624.819 -void MainWnd::OnUpdateToolsOnMovieEndRestart(CCmdUI *pCmdUI)
 624.820 -{
 624.821 -	pCmdUI->SetRadio(theApp.movieOnEndBehavior == 1);
 624.822 -}
 624.823 -
 624.824 -void MainWnd::OnToolsOnMovieEndAppend()
 624.825 -{
 624.826 -	theApp.movieOnEndBehavior = 2;
 624.827 -}
 624.828 -
 624.829 -void MainWnd::OnUpdateToolsOnMovieEndAppend(CCmdUI *pCmdUI)
 624.830 -{
 624.831 -	pCmdUI->SetRadio(theApp.movieOnEndBehavior == 2);
 624.832 -}
 624.833 -
 624.834 -void MainWnd::OnToolsOnMovieEndKeep()
 624.835 -{
 624.836 -	theApp.movieOnEndBehavior = 3;
 624.837 -}
 624.838 -
 624.839 -void MainWnd::OnUpdateToolsOnMovieEndKeep(CCmdUI *pCmdUI)
 624.840 -{
 624.841 -	pCmdUI->SetRadio(theApp.movieOnEndBehavior == 3);
 624.842 -}
 624.843 -
 624.844 -/////////////////////////////////
 624.845 -
 624.846 -void MainWnd::OnToolsMovieSetPauseAt()
 624.847 -{
 624.848 -	// TODO
 624.849 -	VBAMovieSetPauseAt(-1);
 624.850 -}
 624.851 -
 624.852 -void MainWnd::OnUpdateToolsSetMoviePauseAt(CCmdUI *pCmdUI)
 624.853 -{
 624.854 -	// TODO
 624.855 -	pCmdUI->SetCheck(VBAMovieGetPauseAt() >= 0);
 624.856 -	pCmdUI->Enable(FALSE && VBAMovieActive());
 624.857 -}
 624.858 -
 624.859 -void MainWnd::OnToolsMovieConvertCurrent()
 624.860 -{
 624.861 -	// temporary
 624.862 -	int result = VBAMovieConvertCurrent();
 624.863 -	switch (result)
 624.864 -	{
 624.865 -	case MOVIE_SUCCESS:
 624.866 -		systemScreenMessage("Movie converted");
 624.867 -		break;
 624.868 -	case MOVIE_WRONG_VERSION:
 624.869 -		systemMessage(0, "Cannot convert from VBM revision %u", VBAMovieGetMinorVersion());
 624.870 -		break;
 624.871 -	default:
 624.872 -		systemScreenMessage("Nothing to convert");
 624.873 -		break;
 624.874 -	}
 624.875 -}
 624.876 -
 624.877 -void MainWnd::OnUpdateToolsMovieConvertCurrent(CCmdUI *pCmdUI)
 624.878 -{
 624.879 -	pCmdUI->Enable(VBAMovieActive());
 624.880 -}
 624.881 -
 624.882 -void MainWnd::OnToolsMovieAutoConvert()
 624.883 -{
 624.884 -	extern bool autoConvertMovieWhenPlaying;    // from movie.cpp
 624.885 -	autoConvertMovieWhenPlaying = !autoConvertMovieWhenPlaying;
 624.886 -	if (autoConvertMovieWhenPlaying)
 624.887 -	{
 624.888 -		int result = VBAMovieConvertCurrent();
 624.889 -		switch (result)
 624.890 -		{
 624.891 -		case MOVIE_SUCCESS:
 624.892 -			systemScreenMessage("Movie converted");
 624.893 -			break;
 624.894 -		case MOVIE_WRONG_VERSION:
 624.895 -			systemMessage(0, "Cannot convert from VBM revision %u", VBAMovieGetMinorVersion());
 624.896 -			break;
 624.897 -		default:
 624.898 -			systemScreenMessage("Auto movie conversion enabled");
 624.899 -			break;
 624.900 -		}
 624.901 -	}
 624.902 -}
 624.903 -
 624.904 -void MainWnd::OnUpdateToolsMovieAutoConvert(CCmdUI *pCmdUI)
 624.905 -{
 624.906 -	extern bool autoConvertMovieWhenPlaying;    // from movie.cpp
 624.907 -	pCmdUI->SetCheck(autoConvertMovieWhenPlaying);
 624.908 -}
 624.909 -
 624.910 -void MainWnd::OnToolsMovieTruncateAtCurrent()
 624.911 -{
 624.912 -	if (VBAMovieReadOnly())
 624.913 -		systemScreenMessage("Cannot truncate movie in this mode");
 624.914 -	else
 624.915 -		VBAMovieTuncateAtCurrentFrame();
 624.916 -}
 624.917 -
 624.918 -void MainWnd::OnUpdateToolsMovieTruncateAtCurrent(CCmdUI *pCmdUI)
 624.919 -{
 624.920 -	pCmdUI->Enable(VBAMovieActive());
 624.921 -}
 624.922 -
 624.923 -void MainWnd::OnToolsMovieFixHeader()
 624.924 -{
 624.925 -	VBAMovieFixHeader();
 624.926 -}
 624.927 -
 624.928 -void MainWnd::OnUpdateToolsMovieFixHeader(CCmdUI *pCmdUI)
 624.929 -{
 624.930 -	pCmdUI->Enable(VBAMovieActive());
 624.931 -}
 624.932 -
 624.933 -// TODO
 624.934 -void MainWnd::OnToolsMovieExtractFromSavegame()
 624.935 -{
 624.936 -	// Currently, snapshots taken from a movie don't contain the initial SRAM or savestate of the movie,
 624.937 -	// even if the movie was recorded from either of them. If a snapshot was taken at the first frame
 624.938 -	// i.e. Frame 0, it can be safely assumed that the snapshot reflects the initial state of such a movie.
 624.939 -	// However, if it was taken after the first frame, the SRAM contained might either be still the same
 624.940 -	// as the original (usually true if no write operations on the SRAM occured) or have been modified,
 624.941 -	// while the exact original state could hardly, if not impossibly, be safely worked out.
 624.942 -
 624.943 -	// TODO
 624.944 -}
 624.945 -
 624.946 -void MainWnd::OnUpdateToolsMovieExtractFromSavegame(CCmdUI *pCmdUI)
 624.947 -{
 624.948 -	pCmdUI->Enable(FALSE);
 624.949 -}
 624.950 -
 624.951 -///////////////////////////////////////////////////////////
 624.952 -
 624.953 -void MainWnd::OnToolsRewind()
 624.954 -{
 624.955 -	assert(theApp.rewindTimer > 0 && theApp.rewindSlots > 0);
 624.956 -	if (emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && theApp.rewindCount)
 624.957 -	{
 624.958 -		assert(theApp.rewindPos >= 0 && theApp.rewindPos < theApp.rewindSlots);
 624.959 -		theApp.rewindPos = (--theApp.rewindPos + theApp.rewindSlots) % theApp.rewindSlots;
 624.960 -		assert(theApp.rewindPos >= 0 && theApp.rewindPos < theApp.rewindSlots);
 624.961 -		theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE * theApp.rewindPos], REWIND_SIZE);
 624.962 -		theApp.rewindCount--;
 624.963 -		if (theApp.rewindCount > 0)
 624.964 -			theApp.rewindCounter = 0;
 624.965 -		else
 624.966 -		{
 624.967 -			theApp.rewindCounter	= theApp.rewindTimer;
 624.968 -			theApp.rewindSaveNeeded = true;
 624.969 -
 624.970 -			// immediately save state to avoid eroding away the earliest you can rewind to
 624.971 -			theApp.saveRewindStateIfNecessary();
 624.972 -
 624.973 -			theApp.rewindSaveNeeded = false;
 624.974 -		}
 624.975 -	}
 624.976 -}
 624.977 -
 624.978 -void MainWnd::OnUpdateToolsRewind(CCmdUI *pCmdUI)
 624.979 -{
 624.980 -	pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && theApp.rewindCount);
 624.981 -}
 624.982 -
 624.983 -void MainWnd::OnToolsCustomize()
 624.984 -{
 624.985 -	theApp.recreateMenuBar();
 624.986 -
 624.987 -	AccelEditor dlg(this, &theApp.m_menu, &theApp.winAccelMgr);
 624.988 -	dlg.DoModal();
 624.989 -	if (dlg.IsModified())
 624.990 -	{
 624.991 -		theApp.winAccelMgr = dlg.GetResultMangager();
 624.992 -		theApp.winAccelMgr.UpdateWndTable();
 624.993 -		theApp.winAccelMgr.Write();
 624.994 -	}
 624.995 -
 624.996 -	theApp.winAccelMgr.UpdateMenu(theApp.menu); // we should always do this since the menu has been reloaded
 624.997 -}
 624.998 -
 624.999 -void MainWnd::OnUpdateToolsCustomize(CCmdUI *pCmdUI)
624.1000 -{
624.1001 -	pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
624.1002 -}
624.1003 -
   625.1 --- a/src/win32/MapView.cpp	Sat Mar 03 10:54:39 2012 -0600
   625.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   625.3 @@ -1,1066 +0,0 @@
   625.4 -// MapView.cpp : implementation file
   625.5 -//
   625.6 -
   625.7 -#include "stdafx.h"
   625.8 -#include "resource.h"
   625.9 -#include "MapView.h"
  625.10 -#include "FileDlg.h"
  625.11 -#include "Reg.h"
  625.12 -#include "WinResUtil.h"
  625.13 -#include "VBA.h"
  625.14 -
  625.15 -#include "../gba/GBAGlobals.h"
  625.16 -#include "../NLS.h"
  625.17 -#include "../common/Util.h"
  625.18 -
  625.19 -extern "C" {
  625.20 -#include <png.h>
  625.21 -}
  625.22 -
  625.23 -/////////////////////////////////////////////////////////////////////////////
  625.24 -// MapView dialog
  625.25 -
  625.26 -MapView::MapView(CWnd*pParent /*=NULL*/)
  625.27 -	: ResizeDlg(MapView::IDD, pParent)
  625.28 -{
  625.29 -	//{{AFX_DATA_INIT(MapView)
  625.30 -	//}}AFX_DATA_INIT
  625.31 -	autoUpdate = false;
  625.32 -
  625.33 -	memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
  625.34 -
  625.35 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  625.36 -	bmpInfo.bmiHeader.biWidth       = 1024;
  625.37 -	bmpInfo.bmiHeader.biHeight      = -1024;
  625.38 -	bmpInfo.bmiHeader.biPlanes      = 1;
  625.39 -	bmpInfo.bmiHeader.biBitCount    = 24;
  625.40 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  625.41 -	data = (u8 *)calloc(1, 3 * 1024 * 1024);
  625.42 -
  625.43 -	mapView.setData(data);
  625.44 -	mapView.setBmpInfo(&bmpInfo);
  625.45 -
  625.46 -	control = BG0CNT;
  625.47 -
  625.48 -	bg    = 0;
  625.49 -	frame = 0;
  625.50 -}
  625.51 -
  625.52 -MapView::~MapView()
  625.53 -{
  625.54 -	free(data);
  625.55 -	data = NULL;
  625.56 -}
  625.57 -
  625.58 -void MapView::DoDataExchange(CDataExchange*pDX)
  625.59 -{
  625.60 -	CDialog::DoDataExchange(pDX);
  625.61 -	//{{AFX_DATA_MAP(MapView)
  625.62 -	DDX_Control(pDX, IDC_NUMCOLORS, m_numcolors);
  625.63 -	DDX_Control(pDX, IDC_MODE, m_mode);
  625.64 -	DDX_Control(pDX, IDC_OVERFLOW, m_overflow);
  625.65 -	DDX_Control(pDX, IDC_MOSAIC, m_mosaic);
  625.66 -	DDX_Control(pDX, IDC_PRIORITY, m_priority);
  625.67 -	DDX_Control(pDX, IDC_DIM, m_dim);
  625.68 -	DDX_Control(pDX, IDC_CHARBASE, m_charbase);
  625.69 -	DDX_Control(pDX, IDC_MAPBASE, m_mapbase);
  625.70 -	//}}AFX_DATA_MAP
  625.71 -	DDX_Control(pDX, IDC_MAP_VIEW, mapView);
  625.72 -	DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, mapViewZoom);
  625.73 -	DDX_Control(pDX, IDC_COLOR, color);
  625.74 -}
  625.75 -
  625.76 -BEGIN_MESSAGE_MAP(MapView, CDialog)
  625.77 -//{{AFX_MSG_MAP(MapView)
  625.78 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  625.79 -ON_BN_CLICKED(IDC_FRAME_0, OnFrame0)
  625.80 -ON_BN_CLICKED(IDC_FRAME_1, OnFrame1)
  625.81 -ON_BN_CLICKED(IDC_BG0, OnBg0)
  625.82 -ON_BN_CLICKED(IDC_BG1, OnBg1)
  625.83 -ON_BN_CLICKED(IDC_BG2, OnBg2)
  625.84 -ON_BN_CLICKED(IDC_BG3, OnBg3)
  625.85 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  625.86 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  625.87 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  625.88 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  625.89 -//}}AFX_MSG_MAP
  625.90 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  625.91 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  625.92 -END_MESSAGE_MAP()
  625.93 -
  625.94 -/////////////////////////////////////////////////////////////////////////////
  625.95 -// MapView message handlers
  625.96 -
  625.97 -void MapView::renderTextScreen(u16 control)
  625.98 -{
  625.99 -	u16 *palette    = (u16 *)paletteRAM;
 625.100 -	u8 * charBase   = &vram[((control >> 2) & 0x03) * 0x4000];
 625.101 -	u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
 625.102 -	u8 * bmp        = data;
 625.103 -
 625.104 -	int sizeX = 256;
 625.105 -	int sizeY = 256;
 625.106 -	switch ((control >> 14) & 3)
 625.107 -	{
 625.108 -	case 0:
 625.109 -		break;
 625.110 -	case 1:
 625.111 -		sizeX = 512;
 625.112 -		break;
 625.113 -	case 2:
 625.114 -		sizeY = 512;
 625.115 -		break;
 625.116 -	case 3:
 625.117 -		sizeX = 512;
 625.118 -		sizeY = 512;
 625.119 -		break;
 625.120 -	}
 625.121 -
 625.122 -	w = sizeX;
 625.123 -	h = sizeY;
 625.124 -
 625.125 -	if (control & 0x80)
 625.126 -	{
 625.127 -		for (int y = 0; y < sizeY; y++)
 625.128 -		{
 625.129 -			int yy = y & 255;
 625.130 -
 625.131 -			if (y == 256 && sizeY > 256)
 625.132 -			{
 625.133 -				screenBase += 0x400;
 625.134 -				if (sizeX > 256)
 625.135 -					screenBase += 0x400;
 625.136 -			}
 625.137 -			u16 *screenSource = screenBase + ((yy>>3)*32);
 625.138 -
 625.139 -			for (int x = 0; x < sizeX; x++)
 625.140 -			{
 625.141 -				u16 data = *screenSource;
 625.142 -
 625.143 -				int tile  = data & 0x3FF;
 625.144 -				int tileX = (x & 7);
 625.145 -				int tileY = y & 7;
 625.146 -
 625.147 -				if (data & 0x0400)
 625.148 -					tileX = 7 - tileX;
 625.149 -				if (data & 0x0800)
 625.150 -					tileY = 7 - tileY;
 625.151 -
 625.152 -				u8 c = charBase[tile * 64 + tileY * 8 + tileX];
 625.153 -
 625.154 -				u16 color = palette[c];
 625.155 -
 625.156 -				*bmp++ = ((color >> 10) & 0x1f) << 3;
 625.157 -				*bmp++ = ((color >> 5) & 0x1f) << 3;
 625.158 -				*bmp++ = (color & 0x1f) << 3;
 625.159 -
 625.160 -				if (data & 0x0400)
 625.161 -				{
 625.162 -					if (tileX == 0)
 625.163 -						screenSource++;
 625.164 -				}
 625.165 -				else if (tileX == 7)
 625.166 -					screenSource++;
 625.167 -				if (x == 255 && sizeX > 256)
 625.168 -				{
 625.169 -					screenSource = screenBase + 0x400 + ((yy>>3)*32);
 625.170 -				}
 625.171 -			}
 625.172 -		}
 625.173 -	}
 625.174 -	else
 625.175 -	{
 625.176 -		for (int y = 0; y < sizeY; y++)
 625.177 -		{
 625.178 -			int yy = y & 255;
 625.179 -
 625.180 -			if (y == 256 && sizeY > 256)
 625.181 -			{
 625.182 -				screenBase += 0x400;
 625.183 -				if (sizeX > 256)
 625.184 -					screenBase += 0x400;
 625.185 -			}
 625.186 -			u16 *screenSource = screenBase + ((yy>>3)*32);
 625.187 -
 625.188 -			for (int x = 0; x < sizeX; x++)
 625.189 -			{
 625.190 -				u16 data = *screenSource;
 625.191 -
 625.192 -				int tile  = data & 0x3FF;
 625.193 -				int tileX = (x & 7);
 625.194 -				int tileY = y & 7;
 625.195 -
 625.196 -				if (data & 0x0400)
 625.197 -					tileX = 7 - tileX;
 625.198 -				if (data & 0x0800)
 625.199 -					tileY = 7 - tileY;
 625.200 -
 625.201 -				u8 color = charBase[tile * 32 + tileY * 4 + (tileX>>1)];
 625.202 -
 625.203 -				if (tileX & 1)
 625.204 -				{
 625.205 -					color = (color >> 4);
 625.206 -				}
 625.207 -				else
 625.208 -				{
 625.209 -					color &= 0x0F;
 625.210 -				}
 625.211 -
 625.212 -				int pal    = (*screenSource>>8) & 0xF0;
 625.213 -				u16 color2 = palette[pal + color];
 625.214 -
 625.215 -				*bmp++ = ((color2 >> 10) & 0x1f) << 3;
 625.216 -				*bmp++ = ((color2 >> 5) & 0x1f) << 3;
 625.217 -				*bmp++ = (color2 & 0x1f) << 3;
 625.218 -
 625.219 -				if (data & 0x0400)
 625.220 -				{
 625.221 -					if (tileX == 0)
 625.222 -						screenSource++;
 625.223 -				}
 625.224 -				else if (tileX == 7)
 625.225 -					screenSource++;
 625.226 -
 625.227 -				if (x == 255 && sizeX > 256)
 625.228 -				{
 625.229 -					screenSource = screenBase + 0x400 + ((yy>>3)*32);
 625.230 -				}
 625.231 -			}
 625.232 -		}
 625.233 -	}
 625.234 -	/*
 625.235 -	   switch(bg) {
 625.236 -	   case 0:
 625.237 -	   renderView(BG0HOFS<<8, BG0VOFS<<8,
 625.238 -	   0x100, 0x000,
 625.239 -	   0x000, 0x100,
 625.240 -	   (sizeX -1) <<8,
 625.241 -	   (sizeY -1) << 8,
 625.242 -	   true);
 625.243 -	   break;
 625.244 -	   case 1:
 625.245 -	   renderView(BG1HOFS<<8, BG1VOFS<<8,
 625.246 -	   0x100, 0x000,
 625.247 -	   0x000, 0x100,
 625.248 -	   (sizeX -1) <<8,
 625.249 -	   (sizeY -1) << 8,
 625.250 -	   true);
 625.251 -	   break;
 625.252 -	   case 2:
 625.253 -	   renderView(BG2HOFS<<8, BG2VOFS<<8,
 625.254 -	   0x100, 0x000,
 625.255 -	   0x000, 0x100,
 625.256 -	   (sizeX -1) <<8,
 625.257 -	   (sizeY -1) << 8,
 625.258 -	   true);
 625.259 -	   break;
 625.260 -	   case 3:
 625.261 -	   renderView(BG3HOFS<<8, BG3VOFS<<8,
 625.262 -	   0x100, 0x000,
 625.263 -	   0x000, 0x100,
 625.264 -	   (sizeX -1) <<8,
 625.265 -	   (sizeY -1) << 8,
 625.266 -	   true);
 625.267 -	   break;
 625.268 -	   }
 625.269 -	 */
 625.270 -}
 625.271 -
 625.272 -void MapView::renderRotScreen(u16 control)
 625.273 -{
 625.274 -	u16 *palette    = (u16 *)paletteRAM;
 625.275 -	u8 * charBase   = &vram[((control >> 2) & 0x03) * 0x4000];
 625.276 -	u8 * screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800];
 625.277 -	u8 * bmp        = data;
 625.278 -
 625.279 -	int sizeX = 128;
 625.280 -	int sizeY = 128;
 625.281 -	switch ((control >> 14) & 3)
 625.282 -	{
 625.283 -	case 0:
 625.284 -		break;
 625.285 -	case 1:
 625.286 -		sizeX = sizeY = 256;
 625.287 -		break;
 625.288 -	case 2:
 625.289 -		sizeX = sizeY = 512;
 625.290 -		break;
 625.291 -	case 3:
 625.292 -		sizeX = sizeY = 1024;
 625.293 -		break;
 625.294 -	}
 625.295 -
 625.296 -	w = sizeX;
 625.297 -	h = sizeY;
 625.298 -
 625.299 -	if (control & 0x80)
 625.300 -	{
 625.301 -		for (int y = 0; y < sizeY; y++)
 625.302 -		{
 625.303 -			for (int x = 0; x < sizeX; x++)
 625.304 -			{
 625.305 -				int tile = screenBase[(x>>3) + (y>>3)*(w>>3)];
 625.306 -
 625.307 -				int tileX = (x & 7);
 625.308 -				int tileY = y & 7;
 625.309 -
 625.310 -				u8  color  = charBase[tile * 64 + tileY * 8 + tileX];
 625.311 -				u16 color2 = palette[color];
 625.312 -
 625.313 -				*bmp++ = ((color2 >> 10) & 0x1f) << 3;
 625.314 -				*bmp++ = ((color2 >> 5) & 0x1f) << 3;
 625.315 -				*bmp++ = (color2 & 0x1f) << 3;
 625.316 -			}
 625.317 -		}
 625.318 -	}
 625.319 -	else
 625.320 -	{
 625.321 -		for (int y = 0; y < sizeY; y++)
 625.322 -		{
 625.323 -			for (int x = 0; x < sizeX; x++)
 625.324 -			{
 625.325 -				int tile = screenBase[(x>>3) + (y>>3)*(w>>3)];
 625.326 -
 625.327 -				int tileX = (x & 7);
 625.328 -				int tileY = y & 7;
 625.329 -
 625.330 -				u8  color  = charBase[tile * 64 + tileY * 8 + tileX];
 625.331 -				u16 color2 = palette[color];
 625.332 -
 625.333 -				*bmp++ = ((color2 >> 10) & 0x1f) << 3;
 625.334 -				*bmp++ = ((color2 >> 5) & 0x1f) << 3;
 625.335 -				*bmp++ = (color2 & 0x1f) << 3;
 625.336 -			}
 625.337 -		}
 625.338 -	}
 625.339 -
 625.340 -	u32 xx;
 625.341 -	u32 yy;
 625.342 -
 625.343 -	switch (bg)
 625.344 -	{
 625.345 -	case 2:
 625.346 -		xx = BG2X_L | BG2X_H << 16;
 625.347 -		yy = BG2Y_L | BG2Y_H << 16;
 625.348 -
 625.349 -		/*
 625.350 -		      renderView(xx, yy,
 625.351 -		      BG2PA, BG2PC,
 625.352 -		      BG2PB, BG2PD,
 625.353 -		      (sizeX -1) <<8,
 625.354 -		      (sizeY -1) << 8,
 625.355 -		      (control & 0x2000) != 0);
 625.356 -		 */
 625.357 -		break;
 625.358 -	case 3:
 625.359 -		xx = BG3X_L | BG3X_H << 16;
 625.360 -		yy = BG3Y_L | BG3Y_H << 16;
 625.361 -		/*
 625.362 -		      renderView(xx, yy,
 625.363 -		      BG3PA, BG3PC,
 625.364 -		      BG3PB, BG3PD,
 625.365 -		      (sizeX -1) <<8,
 625.366 -		      (sizeY -1) << 8,
 625.367 -		      (control & 0x2000) != 0);
 625.368 -		 */
 625.369 -		break;
 625.370 -	}
 625.371 -}
 625.372 -
 625.373 -void MapView::renderMode0()
 625.374 -{
 625.375 -	renderTextScreen(control);
 625.376 -}
 625.377 -
 625.378 -void MapView::renderMode1()
 625.379 -{
 625.380 -	switch (bg)
 625.381 -	{
 625.382 -	case 0:
 625.383 -	case 1:
 625.384 -		renderTextScreen(control);
 625.385 -		break;
 625.386 -	case 2:
 625.387 -		renderRotScreen(control);
 625.388 -		break;
 625.389 -	default:
 625.390 -		bg      = 0;
 625.391 -		control = BG0CNT;
 625.392 -		renderTextScreen(control);
 625.393 -		break;
 625.394 -	}
 625.395 -}
 625.396 -
 625.397 -void MapView::renderMode2()
 625.398 -{
 625.399 -	switch (bg)
 625.400 -	{
 625.401 -	case 2:
 625.402 -	case 3:
 625.403 -		renderRotScreen(control);
 625.404 -		break;
 625.405 -	default:
 625.406 -		bg      = 2;
 625.407 -		control = BG2CNT;
 625.408 -		renderRotScreen(control);
 625.409 -		break;
 625.410 -	}
 625.411 -}
 625.412 -
 625.413 -void MapView::renderMode3()
 625.414 -{
 625.415 -	u8 * bmp = data;
 625.416 -	u16 *src = (u16 *)&vram[0];
 625.417 -
 625.418 -	w = 240;
 625.419 -	h = 160;
 625.420 -
 625.421 -	for (int y = 0; y < 160; y++)
 625.422 -	{
 625.423 -		for (int x = 0; x < 240; x++)
 625.424 -		{
 625.425 -			u16 data = *src++;
 625.426 -			*bmp++ = ((data >> 10) & 0x1f) << 3;
 625.427 -			*bmp++ = ((data >> 5) & 0x1f) << 3;
 625.428 -			*bmp++ = (data & 0x1f) << 3;
 625.429 -		}
 625.430 -	}
 625.431 -	bg = 2;
 625.432 -}
 625.433 -
 625.434 -void MapView::renderMode4()
 625.435 -{
 625.436 -	u8 * bmp = data;
 625.437 -	u8 * src = frame ? &vram[0xa000] : &vram[0];
 625.438 -	u16 *pal = (u16 *)&paletteRAM[0];
 625.439 -
 625.440 -	w = 240;
 625.441 -	h = 160;
 625.442 -
 625.443 -	for (int y = 0; y < 160; y++)
 625.444 -	{
 625.445 -		for (int x = 0; x < 240; x++)
 625.446 -		{
 625.447 -			u8  c    = *src++;
 625.448 -			u16 data = pal[c];
 625.449 -			*bmp++ = ((data >> 10) & 0x1f) << 3;
 625.450 -			*bmp++ = ((data >> 5) & 0x1f) << 3;
 625.451 -			*bmp++ = (data & 0x1f) << 3;
 625.452 -		}
 625.453 -	}
 625.454 -	bg = 2;
 625.455 -}
 625.456 -
 625.457 -void MapView::renderMode5()
 625.458 -{
 625.459 -	u8 * bmp = data;
 625.460 -	u16 *src = (u16 *)(frame ? &vram[0xa000] : &vram[0]);
 625.461 -
 625.462 -	w = 160;
 625.463 -	h = 128;
 625.464 -
 625.465 -	for (int y = 0; y < 128; y++)
 625.466 -	{
 625.467 -		for (int x = 0; x < 160; x++)
 625.468 -		{
 625.469 -			u16 data = *src++;
 625.470 -			*bmp++ = ((data >> 10) & 0x1f) << 3;
 625.471 -			*bmp++ = ((data >> 5) & 0x1f) << 3;
 625.472 -			*bmp++ = (data & 0x1f) << 3;
 625.473 -		}
 625.474 -	}
 625.475 -	bg = 2;
 625.476 -}
 625.477 -
 625.478 -void MapView::OnRefresh()
 625.479 -{
 625.480 -	paint();
 625.481 -}
 625.482 -
 625.483 -void MapView::paint()
 625.484 -{
 625.485 -	if (vram == NULL)
 625.486 -		return;
 625.487 -	int mode = DISPCNT & 7;
 625.488 -
 625.489 -	switch (bg)
 625.490 -	{
 625.491 -	default:
 625.492 -	case 0:
 625.493 -		control = BG0CNT;
 625.494 -		break;
 625.495 -	case 1:
 625.496 -		control = BG1CNT;
 625.497 -		break;
 625.498 -	case 2:
 625.499 -		control = BG2CNT;
 625.500 -		break;
 625.501 -	case 3:
 625.502 -		control = BG3CNT;
 625.503 -		break;
 625.504 -	}
 625.505 -
 625.506 -	switch (mode)
 625.507 -	{
 625.508 -	case 0:
 625.509 -		renderMode0();
 625.510 -		break;
 625.511 -	case 1:
 625.512 -		renderMode1();
 625.513 -		break;
 625.514 -	case 2:
 625.515 -		renderMode2();
 625.516 -		break;
 625.517 -	case 3:
 625.518 -		renderMode3();
 625.519 -		break;
 625.520 -	case 4:
 625.521 -		renderMode4();
 625.522 -		break;
 625.523 -	case 5:
 625.524 -		renderMode5();
 625.525 -		break;
 625.526 -	}
 625.527 -	enableButtons(mode);
 625.528 -	SIZE s;
 625.529 -
 625.530 -	if (mapView.getStretch())
 625.531 -	{
 625.532 -		mapView.setSize(w, h);
 625.533 -		s.cx = s.cy = 1;
 625.534 -		mapView.SetScrollSizes(MM_TEXT, s);
 625.535 -	}
 625.536 -	else
 625.537 -	{
 625.538 -		mapView.setSize(w, h);
 625.539 -		s.cx = w;
 625.540 -		s.cy = h;
 625.541 -		mapView.SetScrollSizes(MM_TEXT, s);
 625.542 -	}
 625.543 -
 625.544 -	mapView.refresh();
 625.545 -
 625.546 -	CString buffer;
 625.547 -
 625.548 -	u32 charBase   = ((control >> 2) & 0x03) * 0x4000 + 0x6000000;
 625.549 -	u32 screenBase = ((control >> 8) & 0x1f) * 0x800 + 0x6000000;
 625.550 -
 625.551 -	buffer.Format("%d", mode);
 625.552 -	m_mode.SetWindowText(buffer);
 625.553 -
 625.554 -	if (mode >= 3)
 625.555 -	{
 625.556 -		m_mapbase.SetWindowText("");
 625.557 -		m_charbase.SetWindowText("");
 625.558 -	}
 625.559 -	else
 625.560 -	{
 625.561 -		buffer.Format("0x%08X", screenBase);
 625.562 -		m_mapbase.SetWindowText(buffer);
 625.563 -
 625.564 -		buffer.Format("0x%08X", charBase);
 625.565 -		m_charbase.SetWindowText(buffer);
 625.566 -	}
 625.567 -
 625.568 -	buffer.Format("%dx%d", w, h);
 625.569 -	m_dim.SetWindowText(buffer);
 625.570 -
 625.571 -	m_numcolors.SetWindowText(control & 0x80 ? "256" : "16");
 625.572 -
 625.573 -	buffer.Format("%d", control & 3);
 625.574 -	m_priority.SetWindowText(buffer);
 625.575 -
 625.576 -	m_mosaic.SetWindowText(control & 0x40 ? "1" : "0");
 625.577 -
 625.578 -	m_overflow.SetWindowText(bg <= 1 ? "" :
 625.579 -	                         control & 0x2000 ? "1" : "0");
 625.580 -}
 625.581 -
 625.582 -BOOL MapView::OnInitDialog()
 625.583 -{
 625.584 -	CDialog::OnInitDialog();
 625.585 -
 625.586 -	DIALOG_SIZER_START(sz)
 625.587 -	DIALOG_SIZER_ENTRY(IDC_MAP_VIEW, DS_SizeX | DS_SizeY)
 625.588 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 625.589 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 625.590 -	DIALOG_SIZER_ENTRY(IDC_SAVE,  DS_MoveY)
 625.591 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 625.592 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 625.593 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 625.594 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 625.595 -	DIALOG_SIZER_END()
 625.596 -	SetData(sz,
 625.597 -	        TRUE,
 625.598 -	        HKEY_CURRENT_USER,
 625.599 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\MapView",
 625.600 -	        NULL);
 625.601 -
 625.602 -	SIZE size;
 625.603 -	size.cx = 1;
 625.604 -	size.cy = 1;
 625.605 -	mapView.SetScrollSizes(MM_TEXT, size);
 625.606 -	int s = regQueryDwordValue("mapViewStretch", 0);
 625.607 -	if (s)
 625.608 -		mapView.setStretch(true);
 625.609 -	((CButton *)GetDlgItem(IDC_STRETCH))->SetCheck(s);
 625.610 -	paint();
 625.611 -
 625.612 -	return TRUE; // return TRUE unless you set the focus to a control
 625.613 -	             // EXCEPTION: OCX Property Pages should return FALSE
 625.614 -}
 625.615 -
 625.616 -void MapView::PostNcDestroy()
 625.617 -{
 625.618 -	delete this;
 625.619 -}
 625.620 -
 625.621 -void MapView::enableButtons(int mode)
 625.622 -{
 625.623 -	bool enable[6] = { true, true, true, true, true, true };
 625.624 -
 625.625 -	switch (mode)
 625.626 -	{
 625.627 -	case 0:
 625.628 -		enable[4] = false;
 625.629 -		enable[5] = false;
 625.630 -		break;
 625.631 -	case 1:
 625.632 -		enable[3] = false;
 625.633 -		enable[4] = false;
 625.634 -		enable[5] = false;
 625.635 -		break;
 625.636 -	case 2:
 625.637 -		enable[0] = false;
 625.638 -		enable[1] = false;
 625.639 -		enable[4] = false;
 625.640 -		enable[5] = false;
 625.641 -		break;
 625.642 -	case 3:
 625.643 -		enable[0] = false;
 625.644 -		enable[1] = false;
 625.645 -		enable[2] = false;
 625.646 -		enable[3] = false;
 625.647 -		enable[4] = false;
 625.648 -		enable[5] = false;
 625.649 -		break;
 625.650 -	case 4:
 625.651 -		enable[0] = false;
 625.652 -		enable[1] = false;
 625.653 -		enable[2] = false;
 625.654 -		enable[3] = false;
 625.655 -		break;
 625.656 -	case 5:
 625.657 -		enable[0] = false;
 625.658 -		enable[1] = false;
 625.659 -		enable[2] = false;
 625.660 -		enable[3] = false;
 625.661 -		break;
 625.662 -	}
 625.663 -	GetDlgItem(IDC_BG0)->EnableWindow(enable[0]);
 625.664 -	GetDlgItem(IDC_BG1)->EnableWindow(enable[1]);
 625.665 -	GetDlgItem(IDC_BG2)->EnableWindow(enable[2]);
 625.666 -	GetDlgItem(IDC_BG3)->EnableWindow(enable[3]);
 625.667 -	GetDlgItem(IDC_FRAME_0)->EnableWindow(enable[4]);
 625.668 -	GetDlgItem(IDC_FRAME_1)->EnableWindow(enable[5]);
 625.669 -	int id = IDC_BG0;
 625.670 -	switch (bg)
 625.671 -	{
 625.672 -	case 1:
 625.673 -		id = IDC_BG1;
 625.674 -		break;
 625.675 -	case 2:
 625.676 -		id = IDC_BG2;
 625.677 -		break;
 625.678 -	case 3:
 625.679 -		id = IDC_BG3;
 625.680 -		break;
 625.681 -	}
 625.682 -	CheckRadioButton(IDC_BG0, IDC_BG3, id);
 625.683 -	id = IDC_FRAME_0;
 625.684 -	if (frame != 0)
 625.685 -		id = IDC_FRAME_1;
 625.686 -	CheckRadioButton(IDC_FRAME_0, IDC_FRAME_1, id);
 625.687 -}
 625.688 -
 625.689 -void MapView::OnFrame0()
 625.690 -{
 625.691 -	frame = 0;
 625.692 -	paint();
 625.693 -}
 625.694 -
 625.695 -void MapView::OnFrame1()
 625.696 -{
 625.697 -	frame = 1;
 625.698 -	paint();
 625.699 -}
 625.700 -
 625.701 -void MapView::OnBg0()
 625.702 -{
 625.703 -	bg      = 0;
 625.704 -	control = BG0CNT;
 625.705 -	paint();
 625.706 -}
 625.707 -
 625.708 -void MapView::OnBg1()
 625.709 -{
 625.710 -	bg      = 1;
 625.711 -	control = BG1CNT;
 625.712 -	paint();
 625.713 -}
 625.714 -
 625.715 -void MapView::OnBg2()
 625.716 -{
 625.717 -	bg      = 2;
 625.718 -	control = BG2CNT;
 625.719 -	paint();
 625.720 -}
 625.721 -
 625.722 -void MapView::OnBg3()
 625.723 -{
 625.724 -	bg      = 3;
 625.725 -	control = BG3CNT;
 625.726 -	paint();
 625.727 -}
 625.728 -
 625.729 -void MapView::OnStretch()
 625.730 -{
 625.731 -	mapView.setStretch(!mapView.getStretch());
 625.732 -	paint();
 625.733 -	regSetDwordValue("mapViewStretch", mapView.getStretch());
 625.734 -}
 625.735 -
 625.736 -void MapView::OnAutoUpdate()
 625.737 -{
 625.738 -	autoUpdate = !autoUpdate;
 625.739 -	if (autoUpdate)
 625.740 -	{
 625.741 -		theApp.winAddUpdateListener(this);
 625.742 -	}
 625.743 -	else
 625.744 -	{
 625.745 -		theApp.winRemoveUpdateListener(this);
 625.746 -	}
 625.747 -}
 625.748 -
 625.749 -void MapView::update()
 625.750 -{
 625.751 -	paint();
 625.752 -}
 625.753 -
 625.754 -void MapView::OnClose()
 625.755 -{
 625.756 -	theApp.winRemoveUpdateListener(this);
 625.757 -
 625.758 -	DestroyWindow();
 625.759 -}
 625.760 -
 625.761 -u32 MapView::GetTextClickAddress(u32 base, int x, int y)
 625.762 -{
 625.763 -	if (y > 255 && h > 256)
 625.764 -	{
 625.765 -		base += 0x800;
 625.766 -		if (w > 256)
 625.767 -			base += 0x800;
 625.768 -	}
 625.769 -	if (x >= 256)
 625.770 -		base += 0x800;
 625.771 -	x    &= 255;
 625.772 -	y    &= 255;
 625.773 -	base += (x>>3)*2 + 64*(y>>3);
 625.774 -
 625.775 -	return base;
 625.776 -}
 625.777 -
 625.778 -u32 MapView::GetClickAddress(int x, int y)
 625.779 -{
 625.780 -	int mode = DISPCNT & 7;
 625.781 -
 625.782 -	u32 base = ((control >> 8) & 0x1f) * 0x800 + 0x6000000;
 625.783 -
 625.784 -	// all text bgs (16 bits)
 625.785 -	if (mode == 0 || (mode < 3 && bg < 2))
 625.786 -	{
 625.787 -		return GetTextClickAddress(base, x, y);
 625.788 -	}
 625.789 -	// rot bgs (8 bits)
 625.790 -	if (mode < 3)
 625.791 -	{
 625.792 -		return base + (x>>3) + (w>>3)*(y>>3);
 625.793 -	}
 625.794 -	// mode 3/5 (16 bits)
 625.795 -	if (mode != 4)
 625.796 -	{
 625.797 -		return 0x6000000 + 0xa000*frame + 2*x + w*y*2;
 625.798 -	}
 625.799 -	// mode 4 (8 bits)
 625.800 -	return 0x6000000 + 0xa000*frame + x + w*y;
 625.801 -}
 625.802 -
 625.803 -LRESULT MapView::OnMapInfo(WPARAM wParam, LPARAM lParam)
 625.804 -{
 625.805 -	u8 *colors = (u8 *)lParam;
 625.806 -	mapViewZoom.setColors(colors);
 625.807 -
 625.808 -	int x = wParam & 0xffff;
 625.809 -	int y = (wParam >> 16);
 625.810 -
 625.811 -	CString buffer;
 625.812 -	buffer.Format("(%d,%d)", x, y);
 625.813 -	GetDlgItem(IDC_XY)->SetWindowText(buffer);
 625.814 -
 625.815 -	u32 address = GetClickAddress(x, y);
 625.816 -	buffer.Format("0x%08X", address);
 625.817 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 625.818 -
 625.819 -	int mode = DISPCNT & 7;
 625.820 -	if (mode >= 3)
 625.821 -	{
 625.822 -		// bitmap modes
 625.823 -		GetDlgItem(IDC_TILE_NUM)->SetWindowText("---");
 625.824 -		GetDlgItem(IDC_FLIP)->SetWindowText("--");
 625.825 -		GetDlgItem(IDC_PALETTE_NUM)->SetWindowText("---");
 625.826 -	}
 625.827 -	else if (mode == 0 || bg < 2)
 625.828 -	{
 625.829 -		// text bgs
 625.830 -		u16 value = *((u16 *)&vram[address - 0x6000000]);
 625.831 -
 625.832 -		int tile = value & 1023;
 625.833 -		buffer.Format("%d", tile);
 625.834 -		GetDlgItem(IDC_TILE_NUM)->SetWindowText(buffer);
 625.835 -		buffer.Empty();
 625.836 -		buffer += value & 1024 ? 'H' : '-';
 625.837 -		buffer += value & 2048 ? 'V' : '-';
 625.838 -		GetDlgItem(IDC_FLIP)->SetWindowText(buffer);
 625.839 -
 625.840 -		if (!(control & 0x80))
 625.841 -		{
 625.842 -			buffer.Format("%d", (value >> 12) & 15);
 625.843 -		}
 625.844 -		else
 625.845 -			buffer = "---";
 625.846 -		GetDlgItem(IDC_PALETTE_NUM)->SetWindowText(buffer);
 625.847 -	}
 625.848 -	else
 625.849 -	{
 625.850 -		// rot bgs
 625.851 -		GetDlgItem(IDC_TILE_NUM)->SetWindowText("---");
 625.852 -		GetDlgItem(IDC_FLIP)->SetWindowText("--");
 625.853 -		GetDlgItem(IDC_PALETTE_NUM)->SetWindowText("---");
 625.854 -	}
 625.855 -
 625.856 -	return TRUE;
 625.857 -}
 625.858 -
 625.859 -LRESULT MapView::OnColInfo(WPARAM wParam, LPARAM lParam)
 625.860 -{
 625.861 -	u16 c = (u16)wParam;
 625.862 -
 625.863 -	color.setColor(c);
 625.864 -
 625.865 -	int r = (c & 0x1f);
 625.866 -	int g = (c & 0x3e0) >> 5;
 625.867 -	int b = (c & 0x7c00) >> 10;
 625.868 -
 625.869 -	CString buffer;
 625.870 -	buffer.Format("R: %d", r);
 625.871 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 625.872 -
 625.873 -	buffer.Format("G: %d", g);
 625.874 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 625.875 -
 625.876 -	buffer.Format("B: %d", b);
 625.877 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 625.878 -
 625.879 -	return TRUE;
 625.880 -}
 625.881 -
 625.882 -void MapView::saveBMP(const char *name)
 625.883 -{
 625.884 -	u8 writeBuffer[1024 * 3];
 625.885 -
 625.886 -	FILE *fp = fopen(name, "wb");
 625.887 -
 625.888 -	if (!fp)
 625.889 -	{
 625.890 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 625.891 -		return;
 625.892 -	}
 625.893 -
 625.894 -	struct
 625.895 -	{
 625.896 -		u8 ident[2];
 625.897 -		u8 filesize[4];
 625.898 -		u8 reserved[4];
 625.899 -		u8 dataoffset[4];
 625.900 -		u8 headersize[4];
 625.901 -		u8 width[4];
 625.902 -		u8 height[4];
 625.903 -		u8 planes[2];
 625.904 -		u8 bitsperpixel[2];
 625.905 -		u8 compression[4];
 625.906 -		u8 datasize[4];
 625.907 -		u8 hres[4];
 625.908 -		u8 vres[4];
 625.909 -		u8 colors[4];
 625.910 -		u8 importantcolors[4];
 625.911 -		u8 pad[2];
 625.912 -	} bmpheader;
 625.913 -	memset(&bmpheader, 0, sizeof(bmpheader));
 625.914 -
 625.915 -	bmpheader.ident[0] = 'B';
 625.916 -	bmpheader.ident[1] = 'M';
 625.917 -
 625.918 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 625.919 -	utilPutDword(bmpheader.filesize, fsz);
 625.920 -	utilPutDword(bmpheader.dataoffset, 0x38);
 625.921 -	utilPutDword(bmpheader.headersize, 0x28);
 625.922 -	utilPutDword(bmpheader.width, w);
 625.923 -	utilPutDword(bmpheader.height, h);
 625.924 -	utilPutDword(bmpheader.planes, 1);
 625.925 -	utilPutDword(bmpheader.bitsperpixel, 24);
 625.926 -	utilPutDword(bmpheader.datasize, 3*w*h);
 625.927 -
 625.928 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 625.929 -
 625.930 -	u8 *b = writeBuffer;
 625.931 -
 625.932 -	int sizeX = w;
 625.933 -	int sizeY = h;
 625.934 -
 625.935 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 625.936 -	for (int y = 0; y < sizeY; y++)
 625.937 -	{
 625.938 -		for (int x = 0; x < sizeX; x++)
 625.939 -		{
 625.940 -			*b++ = *pixU8++; // B
 625.941 -			*b++ = *pixU8++; // G
 625.942 -			*b++ = *pixU8++; // R
 625.943 -		}
 625.944 -		pixU8 -= 2*3*w;
 625.945 -		fwrite(writeBuffer, 1, 3*w, fp);
 625.946 -
 625.947 -		b = writeBuffer;
 625.948 -	}
 625.949 -
 625.950 -	fclose(fp);
 625.951 -}
 625.952 -
 625.953 -void MapView::savePNG(const char *name)
 625.954 -{
 625.955 -	u8 writeBuffer[1024 * 3];
 625.956 -
 625.957 -	FILE *fp = fopen(name, "wb");
 625.958 -
 625.959 -	if (!fp)
 625.960 -	{
 625.961 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 625.962 -		return;
 625.963 -	}
 625.964 -
 625.965 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 625.966 -	                                              NULL,
 625.967 -	                                              NULL,
 625.968 -	                                              NULL);
 625.969 -	if (!png_ptr)
 625.970 -	{
 625.971 -		fclose(fp);
 625.972 -		return;
 625.973 -	}
 625.974 -
 625.975 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 625.976 -
 625.977 -	if (!info_ptr)
 625.978 -	{
 625.979 -		png_destroy_write_struct(&png_ptr, NULL);
 625.980 -		fclose(fp);
 625.981 -		return;
 625.982 -	}
 625.983 -
 625.984 -	if (setjmp(png_ptr->jmpbuf))
 625.985 -	{
 625.986 -		png_destroy_write_struct(&png_ptr, NULL);
 625.987 -		fclose(fp);
 625.988 -		return;
 625.989 -	}
 625.990 -
 625.991 -	png_init_io(png_ptr, fp);
 625.992 -
 625.993 -	png_set_IHDR(png_ptr,
 625.994 -	             info_ptr,
 625.995 -	             w,
 625.996 -	             h,
 625.997 -	             8,
 625.998 -	             PNG_COLOR_TYPE_RGB,
 625.999 -	             PNG_INTERLACE_NONE,
625.1000 -	             PNG_COMPRESSION_TYPE_DEFAULT,
625.1001 -	             PNG_FILTER_TYPE_DEFAULT);
625.1002 -
625.1003 -	png_write_info(png_ptr, info_ptr);
625.1004 -
625.1005 -	u8 *b = writeBuffer;
625.1006 -
625.1007 -	int sizeX = w;
625.1008 -	int sizeY = h;
625.1009 -
625.1010 -	u8 *pixU8 = (u8 *)data;
625.1011 -	for (int y = 0; y < sizeY; y++)
625.1012 -	{
625.1013 -		for (int x = 0; x < sizeX; x++)
625.1014 -		{
625.1015 -			int blue  = *pixU8++;
625.1016 -			int green = *pixU8++;
625.1017 -			int red   = *pixU8++;
625.1018 -
625.1019 -			*b++ = red;
625.1020 -			*b++ = green;
625.1021 -			*b++ = blue;
625.1022 -		}
625.1023 -		png_write_row(png_ptr, writeBuffer);
625.1024 -
625.1025 -		b = writeBuffer;
625.1026 -	}
625.1027 -
625.1028 -	png_write_end(png_ptr, info_ptr);
625.1029 -
625.1030 -	png_destroy_write_struct(&png_ptr, &info_ptr);
625.1031 -
625.1032 -	fclose(fp);
625.1033 -}
625.1034 -
625.1035 -void MapView::OnSave()
625.1036 -{
625.1037 -	CString filename;
625.1038 -
625.1039 -	if (theApp.captureFormat == 0)
625.1040 -		filename = "map.png";
625.1041 -	else
625.1042 -		filename = "map.bmp";
625.1043 -
625.1044 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
625.1045 -
625.1046 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
625.1047 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
625.1048 -
625.1049 -	FileDlg dlg(this,
625.1050 -	            filename,
625.1051 -	            filter,
625.1052 -	            theApp.captureFormat ? 2 : 1,
625.1053 -	            theApp.captureFormat ? "BMP" : "PNG",
625.1054 -	            exts,
625.1055 -	            "",
625.1056 -	            title,
625.1057 -	            true);
625.1058 -
625.1059 -	if (dlg.DoModal() == IDCANCEL)
625.1060 -	{
625.1061 -		return;
625.1062 -	}
625.1063 -
625.1064 -	if (dlg.getFilterIndex() == 2)
625.1065 -		saveBMP(dlg.GetPathName());
625.1066 -	else
625.1067 -		savePNG(dlg.GetPathName());
625.1068 -}
625.1069 -
   626.1 --- a/src/win32/MapView.h	Sat Mar 03 10:54:39 2012 -0600
   626.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   626.3 @@ -1,101 +0,0 @@
   626.4 -#if !defined(AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_)
   626.5 -#define AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_
   626.6 -
   626.7 -#if _MSC_VER > 1000
   626.8 -#pragma once
   626.9 -#endif // _MSC_VER > 1000
  626.10 -// -*- C++ -*-
  626.11 -// MapView.h : header file
  626.12 -//
  626.13 -
  626.14 -#include "BitmapControl.h"
  626.15 -#include "ColorControl.h"
  626.16 -#include "ZoomControl.h"
  626.17 -#include "ResizeDlg.h"
  626.18 -#include "IUpdate.h"
  626.19 -
  626.20 -/////////////////////////////////////////////////////////////////////////////
  626.21 -// MapView dialog
  626.22 -
  626.23 -class MapView : public ResizeDlg, IUpdateListener
  626.24 -{
  626.25 -private:
  626.26 -	BITMAPINFO    bmpInfo;
  626.27 -	u8 *          data;
  626.28 -	int           frame;
  626.29 -	u16           control;
  626.30 -	int           bg;
  626.31 -	int           w;
  626.32 -	int           h;
  626.33 -	BitmapControl mapView;
  626.34 -	ZoomControl   mapViewZoom;
  626.35 -	ColorControl  color;
  626.36 -	bool          autoUpdate;
  626.37 -
  626.38 -	// Construction
  626.39 -public:
  626.40 -	void savePNG(const char *name);
  626.41 -	void saveBMP(const char *name);
  626.42 -	afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  626.43 -	afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  626.44 -	u32 GetClickAddress(int x, int y);
  626.45 -	u32 GetTextClickAddress(u32 base, int x, int y);
  626.46 -	void update();
  626.47 -	void enableButtons(int mode);
  626.48 -	void paint();
  626.49 -	void renderMode5();
  626.50 -	void renderMode4();
  626.51 -	void renderMode3();
  626.52 -	void renderMode2();
  626.53 -	void renderMode1();
  626.54 -	void renderMode0();
  626.55 -	void renderRotScreen(u16 control);
  626.56 -	void renderTextScreen(u16 control);
  626.57 -	MapView(CWnd*pParent = NULL);  // standard constructor
  626.58 -	~MapView();
  626.59 -
  626.60 -	// Dialog Data
  626.61 -	//{{AFX_DATA(MapView)
  626.62 -	enum { IDD = IDD_MAP_VIEW };
  626.63 -	CStatic m_numcolors;
  626.64 -	CStatic m_mode;
  626.65 -	CStatic m_overflow;
  626.66 -	CStatic m_mosaic;
  626.67 -	CStatic m_priority;
  626.68 -	CStatic m_dim;
  626.69 -	CStatic m_charbase;
  626.70 -	CStatic m_mapbase;
  626.71 -	//}}AFX_DATA
  626.72 -
  626.73 -	// Overrides
  626.74 -	// ClassWizard generated virtual function overrides
  626.75 -	//{{AFX_VIRTUAL(MapView)
  626.76 -protected:
  626.77 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  626.78 -	virtual void PostNcDestroy();
  626.79 -	//}}AFX_VIRTUAL
  626.80 -
  626.81 -	// Implementation
  626.82 -protected:
  626.83 -	// Generated message map functions
  626.84 -	//{{AFX_MSG(MapView)
  626.85 -	afx_msg void OnRefresh();
  626.86 -	virtual BOOL OnInitDialog();
  626.87 -	afx_msg void OnFrame0();
  626.88 -	afx_msg void OnFrame1();
  626.89 -	afx_msg void OnBg0();
  626.90 -	afx_msg void OnBg1();
  626.91 -	afx_msg void OnBg2();
  626.92 -	afx_msg void OnBg3();
  626.93 -	afx_msg void OnStretch();
  626.94 -	afx_msg void OnAutoUpdate();
  626.95 -	afx_msg void OnClose();
  626.96 -	afx_msg void OnSave();
  626.97 -	//}}AFX_MSG
  626.98 -	DECLARE_MESSAGE_MAP()
  626.99 -};
 626.100 -
 626.101 -//{{AFX_INSERT_LOCATION}}
 626.102 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 626.103 -
 626.104 -#endif // !defined(AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_)
   627.1 --- a/src/win32/MaxScale.cpp	Sat Mar 03 10:54:39 2012 -0600
   627.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   627.3 @@ -1,64 +0,0 @@
   627.4 -// MaxScale.cpp : implementation file
   627.5 -//
   627.6 -
   627.7 -#include "stdafx.h"
   627.8 -#include "resource.h"
   627.9 -#include "MaxScale.h"
  627.10 -#include "VBA.h"
  627.11 -
  627.12 -/////////////////////////////////////////////////////////////////////////////
  627.13 -// MaxScale dialog
  627.14 -
  627.15 -MaxScale::MaxScale(CWnd*pParent /*=NULL*/)
  627.16 -	: CDialog(MaxScale::IDD, pParent)
  627.17 -{
  627.18 -	//{{AFX_DATA_INIT(MaxScale)
  627.19 -	// NOTE: the ClassWizard will add member initialization here
  627.20 -	//}}AFX_DATA_INIT
  627.21 -}
  627.22 -
  627.23 -void MaxScale::DoDataExchange(CDataExchange*pDX)
  627.24 -{
  627.25 -	CDialog::DoDataExchange(pDX);
  627.26 -	//{{AFX_DATA_MAP(MaxScale)
  627.27 -	DDX_Control(pDX, IDC_VALUE, m_value);
  627.28 -	//}}AFX_DATA_MAP
  627.29 -}
  627.30 -
  627.31 -BEGIN_MESSAGE_MAP(MaxScale, CDialog)
  627.32 -//{{AFX_MSG_MAP(MaxScale)
  627.33 -ON_BN_CLICKED(ID_OK, OnOk)
  627.34 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  627.35 -//}}AFX_MSG_MAP
  627.36 -END_MESSAGE_MAP()
  627.37 -
  627.38 -/////////////////////////////////////////////////////////////////////////////
  627.39 -// MaxScale message handlers
  627.40 -
  627.41 -void MaxScale::OnCancel()
  627.42 -{
  627.43 -	EndDialog(FALSE);
  627.44 -}
  627.45 -
  627.46 -void MaxScale::OnOk()
  627.47 -{
  627.48 -	CString tmp;
  627.49 -	m_value.GetWindowText(tmp);
  627.50 -	theApp.fsMaxScale = atoi(tmp);
  627.51 -	EndDialog(TRUE);
  627.52 -}
  627.53 -
  627.54 -BOOL MaxScale::OnInitDialog()
  627.55 -{
  627.56 -	CDialog::OnInitDialog();
  627.57 -
  627.58 -	CString temp;
  627.59 -
  627.60 -	temp.Format("%d", theApp.fsMaxScale);
  627.61 -
  627.62 -	m_value.SetWindowText(temp);
  627.63 -
  627.64 -	return TRUE;  // return TRUE unless you set the focus to a control
  627.65 -	              // EXCEPTION: OCX Property Pages should return FALSE
  627.66 -}
  627.67 -
   628.1 --- a/src/win32/MaxScale.h	Sat Mar 03 10:54:39 2012 -0600
   628.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   628.3 @@ -1,47 +0,0 @@
   628.4 -#if !defined(AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_)
   628.5 -#define AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_
   628.6 -
   628.7 -#if _MSC_VER > 1000
   628.8 -#pragma once
   628.9 -#endif // _MSC_VER > 1000
  628.10 -// -*- C++ -*-
  628.11 -// MaxScale.h : header file
  628.12 -//
  628.13 -
  628.14 -/////////////////////////////////////////////////////////////////////////////
  628.15 -// MaxScale dialog
  628.16 -
  628.17 -class MaxScale : public CDialog
  628.18 -{
  628.19 -// Construction
  628.20 -public:
  628.21 -	MaxScale(CWnd*pParent = NULL);    // standard constructor
  628.22 -
  628.23 -// Dialog Data
  628.24 -	//{{AFX_DATA(MaxScale)
  628.25 -	enum { IDD = IDD_MAX_SCALE };
  628.26 -	CEdit m_value;
  628.27 -	//}}AFX_DATA
  628.28 -
  628.29 -// Overrides
  628.30 -	// ClassWizard generated virtual function overrides
  628.31 -	//{{AFX_VIRTUAL(MaxScale)
  628.32 -protected:
  628.33 -	virtual void DoDataExchange(CDataExchange*pDX);     // DDX/DDV support
  628.34 -	//}}AFX_VIRTUAL
  628.35 -
  628.36 -// Implementation
  628.37 -protected:
  628.38 -	// Generated message map functions
  628.39 -	//{{AFX_MSG(MaxScale)
  628.40 -	afx_msg void OnCancel();
  628.41 -	afx_msg void OnOk();
  628.42 -	virtual BOOL OnInitDialog();
  628.43 -	//}}AFX_MSG
  628.44 -	DECLARE_MESSAGE_MAP()
  628.45 -};
  628.46 -
  628.47 -//{{AFX_INSERT_LOCATION}}
  628.48 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  628.49 -
  628.50 -#endif // !defined(AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_)
   629.1 --- a/src/win32/MemoryViewer.cpp	Sat Mar 03 10:54:39 2012 -0600
   629.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   629.3 @@ -1,688 +0,0 @@
   629.4 -// MemoryViewer.cpp : implementation file
   629.5 -//
   629.6 -
   629.7 -#include "stdafx.h"
   629.8 -#include "resource.h"
   629.9 -#include "MemoryViewer.h"
  629.10 -
  629.11 -extern int emulating;
  629.12 -
  629.13 -/////////////////////////////////////////////////////////////////////////////
  629.14 -// MemoryViewer
  629.15 -
  629.16 -bool MemoryViewer::isRegistered = false;
  629.17 -
  629.18 -MemoryViewer::MemoryViewer()
  629.19 -{
  629.20 -	address        = 0;
  629.21 -	addressSize    = 0;
  629.22 -	dataSize       = 0;
  629.23 -	editAddress    = 0;
  629.24 -	editNibble     = 0;
  629.25 -	displayedLines = 0;
  629.26 -	hasCaret       = false;
  629.27 -	maxNibble      = 0;
  629.28 -	font        = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
  629.29 -	fontSize.cx = fontSize.cy = 0;
  629.30 -	beginAscii  = 0;
  629.31 -	beginHex    = 0;
  629.32 -	dlg         = NULL;
  629.33 -	registerClass();
  629.34 -}
  629.35 -
  629.36 -MemoryViewer::~MemoryViewer()
  629.37 -{}
  629.38 -
  629.39 -BEGIN_MESSAGE_MAP(MemoryViewer, CWnd)
  629.40 -//{{AFX_MSG_MAP(MemoryViewer)
  629.41 -ON_WM_ERASEBKGND()
  629.42 -ON_WM_PAINT()
  629.43 -ON_WM_VSCROLL()
  629.44 -ON_WM_GETDLGCODE()
  629.45 -ON_WM_LBUTTONDOWN()
  629.46 -ON_WM_SETFOCUS()
  629.47 -ON_WM_KILLFOCUS()
  629.48 -ON_WM_KEYDOWN()
  629.49 -//}}AFX_MSG_MAP
  629.50 -ON_MESSAGE(WM_CHAR, OnWMChar)
  629.51 -END_MESSAGE_MAP()
  629.52 -
  629.53 -/////////////////////////////////////////////////////////////////////////////
  629.54 -// MemoryViewer message handlers
  629.55 -
  629.56 -void MemoryViewer::setDialog(IMemoryViewerDlg *d)
  629.57 -{
  629.58 -	dlg = d;
  629.59 -}
  629.60 -
  629.61 -void MemoryViewer::setAddress(u32 a)
  629.62 -{
  629.63 -	address = a;
  629.64 -	if (displayedLines)
  629.65 -	{
  629.66 -		if (addressSize)
  629.67 -		{
  629.68 -			u16 addr = address;
  629.69 -			if ((u16)((addr+(displayedLines<<4)) & 0xFFFF) < addr)
  629.70 -			{
  629.71 -				address = 0xffff - (displayedLines<<4) + 1;
  629.72 -			}
  629.73 -		}
  629.74 -		else
  629.75 -		{
  629.76 -			if ((address+(displayedLines<<4)) < address)
  629.77 -			{
  629.78 -				address = 0xffffffff - (displayedLines<<4) + 1;
  629.79 -			}
  629.80 -		}
  629.81 -	}
  629.82 -	if (addressSize)
  629.83 -		address &= 0xffff;
  629.84 -	setCaretPos();
  629.85 -	InvalidateRect(NULL, TRUE);
  629.86 -}
  629.87 -
  629.88 -void MemoryViewer::setSize(int s)
  629.89 -{
  629.90 -	dataSize = s;
  629.91 -	if (s == 0)
  629.92 -		maxNibble = 1;
  629.93 -	else if (s == 1)
  629.94 -		maxNibble = 3;
  629.95 -	else
  629.96 -		maxNibble = 7;
  629.97 -
  629.98 -	InvalidateRect(NULL, TRUE);
  629.99 -}
 629.100 -
 629.101 -void MemoryViewer::setDecimal(bool decimalDisplayMode)
 629.102 -{
 629.103 -	decimalDisplay = decimalDisplayMode;
 629.104 -	InvalidateRect(NULL, TRUE);
 629.105 -}
 629.106 -
 629.107 -BOOL MemoryViewer::OnEraseBkgnd(CDC*pDC)
 629.108 -{
 629.109 -	return TRUE;
 629.110 -}
 629.111 -
 629.112 -void MemoryViewer::updateScrollInfo(int lines)
 629.113 -{
 629.114 -	int        page = lines * 16;
 629.115 -	SCROLLINFO si;
 629.116 -	ZeroMemory(&si, sizeof(si));
 629.117 -	si.cbSize = sizeof(si);
 629.118 -	si.fMask  = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS;
 629.119 -	si.nMin   = 0;
 629.120 -	if (addressSize)
 629.121 -	{
 629.122 -		si.nMax  = 0x10000/page;
 629.123 -		si.nPage = 1;
 629.124 -	}
 629.125 -	else
 629.126 -	{
 629.127 -		si.nMax  = 0xa000000 / page;
 629.128 -		si.nPage = page;
 629.129 -	}
 629.130 -
 629.131 -	si.nPos = address / page;
 629.132 -	SetScrollInfo(SB_VERT,
 629.133 -	              &si,
 629.134 -	              TRUE);
 629.135 -}
 629.136 -
 629.137 -void MemoryViewer::OnPaint()
 629.138 -{
 629.139 -	CPaintDC dc(this); // device context for painting
 629.140 -
 629.141 -	RECT rect;
 629.142 -	GetClientRect(&rect);
 629.143 -	int w = rect.right - rect.left;
 629.144 -	int h = rect.bottom - rect.top - 6;
 629.145 -
 629.146 -	CDC memDC;
 629.147 -	memDC.CreateCompatibleDC(&dc);
 629.148 -	CBitmap bitmap, *pOldBitmap;
 629.149 -	bitmap.CreateCompatibleBitmap(&dc, w, rect.bottom - rect.top);
 629.150 -	pOldBitmap = memDC.SelectObject(&bitmap);
 629.151 -
 629.152 -	memDC.FillRect(&rect, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
 629.153 -	memDC.DrawEdge(&rect, EDGE_ETCHED, BF_RECT);
 629.154 -
 629.155 -	CFont *oldFont = memDC.SelectObject(CFont::FromHandle(font));
 629.156 -
 629.157 -	fontSize = memDC.GetTextExtent("0", 1);
 629.158 -
 629.159 -	int lines = h / fontSize.cy;
 629.160 -
 629.161 -	displayedLines = lines;
 629.162 -
 629.163 -	updateScrollInfo(lines);
 629.164 -
 629.165 -	u32 addr = address;
 629.166 -
 629.167 -	memDC.SetTextColor(RGB(0, 0, 0));
 629.168 -
 629.169 -	u8 data[32];
 629.170 -
 629.171 -	RECT r;
 629.172 -	r.top    = 3;
 629.173 -	r.left   = 3;
 629.174 -	r.bottom = r.top+fontSize.cy;
 629.175 -	r.right  = rect.right-3;
 629.176 -
 629.177 -	int line = 0;
 629.178 -
 629.179 -	for (int i = 0; i < lines; i++)
 629.180 -	{
 629.181 -		CString buffer;
 629.182 -		if (addressSize)
 629.183 -			buffer.Format("%04X", addr);
 629.184 -		else
 629.185 -			buffer.Format("%08X", addr);
 629.186 -		memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
 629.187 -		r.left  += 10*fontSize.cx;
 629.188 -		beginHex = r.left;
 629.189 -		readData(addr, 16, data);
 629.190 -
 629.191 -		int j;
 629.192 -
 629.193 -		if (dataSize == 0)
 629.194 -		{
 629.195 -			for (j = 0; j < 16; j++)
 629.196 -			{
 629.197 -				const int nextRLeft = r.left + 3*fontSize.cx;
 629.198 -				if (!decimalDisplay)
 629.199 -					buffer.Format("%02X", data[j]);
 629.200 -				else
 629.201 -				{
 629.202 -					const signed char num = data[j];
 629.203 -					if (num < -9 || num > 99)
 629.204 -						r.left -= fontSize.cx;
 629.205 -					if (num >= -99 && num <= 99)
 629.206 -						buffer.Format("%2d", num);
 629.207 -					else
 629.208 -						buffer.Format("");
 629.209 -				}
 629.210 -				memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
 629.211 -				r.left = nextRLeft;
 629.212 -			}
 629.213 -		}
 629.214 -		if (dataSize == 1)
 629.215 -		{
 629.216 -			for (j = 0; j < 16; j += 2)
 629.217 -			{
 629.218 -				const int nextRLeft = r.left + 5*fontSize.cx;
 629.219 -				if (!decimalDisplay)
 629.220 -					buffer.Format("%04X", data[j] | data[j+1]<<8);
 629.221 -				else
 629.222 -				{
 629.223 -					const signed short num = data[j] | data[j+1]<<8;
 629.224 -					if (num < -999 || num > 9999)
 629.225 -						r.left -= fontSize.cx;
 629.226 -					if (num >= -9999 && num <= 9999)
 629.227 -						buffer.Format("%4d", num);
 629.228 -					else
 629.229 -						buffer.Format("");
 629.230 -				}
 629.231 -				memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
 629.232 -				r.left = nextRLeft;
 629.233 -			}
 629.234 -		}
 629.235 -		if (dataSize == 2)
 629.236 -		{
 629.237 -			for (j = 0; j < 16; j += 4)
 629.238 -			{
 629.239 -				if (!decimalDisplay)
 629.240 -					buffer.Format("%08X", data[j] | data[j+1]<<8 | data[j+2] << 16 | data[j+3] << 24);
 629.241 -				else
 629.242 -				{
 629.243 -					const signed long num = data[j] | data[j+1]<<8 | data[j+2] << 16 | data[j+3] << 24;
 629.244 -					if (num >= -9999999 && num <= 99999999)
 629.245 -						buffer.Format("%8d", num);
 629.246 -					else
 629.247 -						buffer.Format("");
 629.248 -				}
 629.249 -				memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
 629.250 -				r.left += 9*fontSize.cx;
 629.251 -			}
 629.252 -		}
 629.253 -
 629.254 -		line = r.left;
 629.255 -
 629.256 -		r.left    += fontSize.cx;
 629.257 -		beginAscii = r.left;
 629.258 -		buffer.Empty();
 629.259 -		for (j = 0; j < 16; j++)
 629.260 -		{
 629.261 -			char c = data[j];
 629.262 -			if (c >= 32 && c <= 127)
 629.263 -			{
 629.264 -				buffer += c;
 629.265 -			}
 629.266 -			else
 629.267 -				buffer += '.';
 629.268 -		}
 629.269 -
 629.270 -		memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
 629.271 -		addr += 16;
 629.272 -		if (addressSize)
 629.273 -			addr &= 0xffff;
 629.274 -		r.top    += fontSize.cy;
 629.275 -		r.bottom += fontSize.cy;
 629.276 -		r.left    = 3;
 629.277 -	}
 629.278 -	CPen pen;
 629.279 -	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
 629.280 -	CPen *old = memDC.SelectObject(&pen);
 629.281 -
 629.282 -	memDC.MoveTo(3+fontSize.cx*9, 3);
 629.283 -	memDC.LineTo(3+fontSize.cx*9, 3+displayedLines*fontSize.cy);
 629.284 -
 629.285 -	memDC.MoveTo(line, 3);
 629.286 -	memDC.LineTo(line, 3+displayedLines*fontSize.cy);
 629.287 -
 629.288 -	memDC.SelectObject(old);
 629.289 -	pen.DeleteObject();
 629.290 -
 629.291 -	memDC.SelectObject(oldFont);
 629.292 -
 629.293 -	dc.BitBlt(0, 0, w, rect.bottom - rect.top, &memDC, 0, 0, SRCCOPY);
 629.294 -
 629.295 -	memDC.SelectObject(pOldBitmap);
 629.296 -	memDC.DeleteDC();
 629.297 -	bitmap.DeleteObject();
 629.298 -}
 629.299 -
 629.300 -void MemoryViewer::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 629.301 -{
 629.302 -	int address = this->address;
 629.303 -	switch (nSBCode)
 629.304 -	{
 629.305 -	case SB_BOTTOM:
 629.306 -		address = 0xffffff00;
 629.307 -		break;
 629.308 -	case SB_LINEDOWN:
 629.309 -		address += 0x10;
 629.310 -		break;
 629.311 -	case SB_LINEUP:
 629.312 -		address -= 0x10;
 629.313 -		break;
 629.314 -	case SB_PAGEDOWN:
 629.315 -		address += (displayedLines<<4);
 629.316 -		break;
 629.317 -	case SB_PAGEUP:
 629.318 -		address -= (displayedLines<<4);
 629.319 -		break;
 629.320 -	case SB_TOP:
 629.321 -		address = 0;
 629.322 -		break;
 629.323 -	case SB_THUMBTRACK:
 629.324 -	{
 629.325 -		int        page = displayedLines * 16;
 629.326 -		SCROLLINFO si;
 629.327 -		ZeroMemory(&si, sizeof(si));
 629.328 -		si.cbSize = sizeof(si);
 629.329 -		si.fMask  = SIF_TRACKPOS;
 629.330 -		GetScrollInfo(SB_VERT, &si);
 629.331 -		address = page * si.nTrackPos;
 629.332 -		break;
 629.333 -	}
 629.334 -	}
 629.335 -	setAddress(address);
 629.336 -}
 629.337 -
 629.338 -UINT MemoryViewer::OnGetDlgCode()
 629.339 -{
 629.340 -	return DLGC_WANTALLKEYS;
 629.341 -}
 629.342 -
 629.343 -void MemoryViewer::createEditCaret(int w, int h)
 629.344 -{
 629.345 -	if (!hasCaret || caretWidth != w || caretHeight != h)
 629.346 -	{
 629.347 -		hasCaret    = true;
 629.348 -		caretWidth  = w;
 629.349 -		caretHeight = h;
 629.350 -		::CreateCaret(m_hWnd, (HBITMAP)0, w, h);
 629.351 -	}
 629.352 -}
 629.353 -
 629.354 -void MemoryViewer::destroyEditCaret()
 629.355 -{
 629.356 -	hasCaret = false;
 629.357 -	DestroyCaret();
 629.358 -}
 629.359 -
 629.360 -void MemoryViewer::setCaretPos()
 629.361 -{
 629.362 -	if (GetFocus() != this)
 629.363 -	{
 629.364 -		destroyEditCaret();
 629.365 -		return;
 629.366 -	}
 629.367 -
 629.368 -	if (dlg)
 629.369 -		dlg->setCurrentAddress(editAddress);
 629.370 -
 629.371 -	if (editAddress < address || editAddress > (address -1 + (displayedLines<<4)))
 629.372 -	{
 629.373 -		destroyEditCaret();
 629.374 -		return;
 629.375 -	}
 629.376 -
 629.377 -	int subAddress = (editAddress - address);
 629.378 -
 629.379 -	int x = 3+10*fontSize.cx+editNibble*fontSize.cx;
 629.380 -	int y = 3+fontSize.cy*((editAddress-address)>>4);
 629.381 -
 629.382 -	if (editAscii)
 629.383 -	{
 629.384 -		x = beginAscii + fontSize.cx*(subAddress&15);
 629.385 -	}
 629.386 -	else
 629.387 -	{
 629.388 -		switch (dataSize)
 629.389 -		{
 629.390 -		case 0:
 629.391 -			x += 3*fontSize.cx*(subAddress & 15);
 629.392 -			break;
 629.393 -		case 1:
 629.394 -			x += 5*fontSize.cx*((subAddress>>1) & 7);
 629.395 -			break;
 629.396 -		case 2:
 629.397 -			x += 9*fontSize.cx*((subAddress>>2) & 3);
 629.398 -			break;
 629.399 -		}
 629.400 -	}
 629.401 -
 629.402 -	RECT r;
 629.403 -	GetClientRect(&r);
 629.404 -	r.right -= 3;
 629.405 -	if (x >= r.right)
 629.406 -	{
 629.407 -		destroyEditCaret();
 629.408 -		return;
 629.409 -	}
 629.410 -	int w = fontSize.cx;
 629.411 -	if ((x+fontSize.cx) >= r.right)
 629.412 -		w = r.right - x;
 629.413 -	createEditCaret(w, fontSize.cy);
 629.414 -	::SetCaretPos(x, y);
 629.415 -	ShowCaret();
 629.416 -}
 629.417 -
 629.418 -void MemoryViewer::OnLButtonDown(UINT nFlags, CPoint point)
 629.419 -{
 629.420 -	int x           = point.x;
 629.421 -	int y           = point.y;
 629.422 -	int line        = (y-3)/fontSize.cy;
 629.423 -	int beforeAscii = beginHex;
 629.424 -	int inc         = 1;
 629.425 -	int sub         = 3*fontSize.cx;
 629.426 -	switch (dataSize)
 629.427 -	{
 629.428 -	case 0:
 629.429 -		beforeAscii += 47*fontSize.cx;
 629.430 -		break;
 629.431 -	case 1:
 629.432 -		beforeAscii += 39*fontSize.cx;
 629.433 -		inc          = 2;
 629.434 -		sub          = 5*fontSize.cx;
 629.435 -		break;
 629.436 -	case 2:
 629.437 -		beforeAscii += 35*fontSize.cx;
 629.438 -		inc          = 4;
 629.439 -		sub          = 9*fontSize.cx;
 629.440 -		break;
 629.441 -	}
 629.442 -
 629.443 -	editAddress = address + (line<<4);
 629.444 -	if (x >= beginHex && x < beforeAscii)
 629.445 -	{
 629.446 -		x -= beginHex;
 629.447 -		editNibble = 0;
 629.448 -		while (x > 0)
 629.449 -		{
 629.450 -			x -= sub;
 629.451 -			if (x >= 0)
 629.452 -				editAddress += inc;
 629.453 -			else
 629.454 -			{
 629.455 -				editNibble = (x + sub)/fontSize.cx;
 629.456 -			}
 629.457 -		}
 629.458 -		editAscii = false;
 629.459 -	}
 629.460 -	else if (x >= beginAscii)
 629.461 -	{
 629.462 -		int afterAscii = beginAscii+16*fontSize.cx;
 629.463 -		if (x >= afterAscii)
 629.464 -			x = afterAscii-1;
 629.465 -		editAddress += (x-beginAscii)/fontSize.cx;
 629.466 -		editNibble   = 0;
 629.467 -		editAscii    = true;
 629.468 -	}
 629.469 -	else
 629.470 -	{
 629.471 -		return;
 629.472 -	}
 629.473 -
 629.474 -	if (editNibble > maxNibble)
 629.475 -		editNibble = maxNibble;
 629.476 -	SetFocus();
 629.477 -	setCaretPos();
 629.478 -}
 629.479 -
 629.480 -void MemoryViewer::OnSetFocus(CWnd*pOldWnd)
 629.481 -{
 629.482 -	setCaretPos();
 629.483 -	InvalidateRect(NULL, TRUE);
 629.484 -}
 629.485 -
 629.486 -void MemoryViewer::OnKillFocus(CWnd*pNewWnd)
 629.487 -{
 629.488 -	destroyEditCaret();
 629.489 -	InvalidateRect(NULL, TRUE);
 629.490 -}
 629.491 -
 629.492 -void MemoryViewer::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 629.493 -{
 629.494 -	bool isShift = (GetKeyState(VK_SHIFT) & 0x80000000) == 0x80000000;
 629.495 -
 629.496 -	switch (nChar)
 629.497 -	{
 629.498 -	case VK_RIGHT:
 629.499 -		if (editAscii)
 629.500 -			moveAddress(1, 0);
 629.501 -		else if (isShift)
 629.502 -			moveAddress((maxNibble+1)>>1, 0);
 629.503 -		else
 629.504 -			moveAddress(0, 1);
 629.505 -		break;
 629.506 -	case VK_LEFT:
 629.507 -		if (editAscii)
 629.508 -			moveAddress(-1, 0);
 629.509 -		else if (isShift)
 629.510 -			moveAddress(-((maxNibble+1)>>1), 0);
 629.511 -		else
 629.512 -			moveAddress(0, -1);
 629.513 -		break;
 629.514 -	case VK_DOWN:
 629.515 -		moveAddress(16, 0);
 629.516 -		break;
 629.517 -	case VK_UP:
 629.518 -		moveAddress(-16, 0);
 629.519 -		break;
 629.520 -	case VK_TAB:
 629.521 -		GetNextDlgTabItem(GetParent(), isShift)->SetFocus();
 629.522 -		break;
 629.523 -	}
 629.524 -}
 629.525 -
 629.526 -void MemoryViewer::moveAddress(s32 offset, int nibbleOff)
 629.527 -{
 629.528 -	if (offset == 0)
 629.529 -	{
 629.530 -		if (nibbleOff == -1)
 629.531 -		{
 629.532 -			editNibble--;
 629.533 -			if (editNibble == -1)
 629.534 -			{
 629.535 -				editAddress -= (maxNibble + 1) >> 1;
 629.536 -				editNibble   = maxNibble;
 629.537 -			}
 629.538 -			if (address == 0 && (editAddress >= (u32)(displayedLines<<4)))
 629.539 -			{
 629.540 -				editAddress = 0;
 629.541 -				editNibble  = 0;
 629.542 -				beep();
 629.543 -			}
 629.544 -			if (editAddress < address)
 629.545 -				setAddress(address - 16);
 629.546 -		}
 629.547 -		else
 629.548 -		{
 629.549 -			editNibble++;
 629.550 -			if (editNibble > maxNibble)
 629.551 -			{
 629.552 -				editNibble   = 0;
 629.553 -				editAddress += (maxNibble + 1) >> 1;
 629.554 -			}
 629.555 -			if (editAddress < address)
 629.556 -			{
 629.557 -				editAddress -= (maxNibble + 1) >> 1;
 629.558 -				editNibble   = maxNibble;
 629.559 -				beep();
 629.560 -			}
 629.561 -			if (editAddress >= (address+(displayedLines<<4)))
 629.562 -				setAddress(address+16);
 629.563 -		}
 629.564 -	}
 629.565 -	else
 629.566 -	{
 629.567 -		editAddress += offset;
 629.568 -		if (offset < 0 && editAddress > (address-1+(displayedLines<<4)))
 629.569 -		{
 629.570 -			editAddress -= offset;
 629.571 -			beep();
 629.572 -			return;
 629.573 -		}
 629.574 -		if (offset > 0 && (editAddress < address))
 629.575 -		{
 629.576 -			editAddress -= offset;
 629.577 -			beep();
 629.578 -			return;
 629.579 -		}
 629.580 -		if (editAddress < address)
 629.581 -		{
 629.582 -			if (offset & 15)
 629.583 -				setAddress((address+offset-16) & ~15);
 629.584 -			else
 629.585 -				setAddress(address+offset);
 629.586 -		}
 629.587 -		else if (editAddress > (address - 1 + (displayedLines<<4)))
 629.588 -		{
 629.589 -			if (offset & 15)
 629.590 -				setAddress((address+offset+16) & ~15);
 629.591 -			else
 629.592 -				setAddress(address+offset);
 629.593 -		}
 629.594 -	}
 629.595 -
 629.596 -	setCaretPos();
 629.597 -}
 629.598 -
 629.599 -LRESULT MemoryViewer::OnWMChar(WPARAM wParam, LPARAM LPARAM)
 629.600 -{
 629.601 -	if (OnEditInput(wParam))
 629.602 -		return 0;
 629.603 -	return 1;
 629.604 -}
 629.605 -
 629.606 -bool MemoryViewer::OnEditInput(UINT c)
 629.607 -{
 629.608 -	if (c > 255 || !emulating)
 629.609 -	{
 629.610 -		beep();
 629.611 -		return false;
 629.612 -	}
 629.613 -
 629.614 -	if (!editAscii)
 629.615 -		c = tolower(c);
 629.616 -
 629.617 -	u32 value = 256;
 629.618 -
 629.619 -	if (c >= 'a' && c <= 'f')
 629.620 -		value = 10 + (c - 'a');
 629.621 -	else if (c >= '0' && c <= '9')
 629.622 -		value = (c - '0');
 629.623 -	if (editAscii)
 629.624 -	{
 629.625 -		editData(editAddress, 8, 0, c);
 629.626 -		moveAddress(1, 0);
 629.627 -		InvalidateRect(NULL, TRUE);
 629.628 -	}
 629.629 -	else
 629.630 -	{
 629.631 -		if (value != 256)
 629.632 -		{
 629.633 -			value <<= 4*(maxNibble-editNibble);
 629.634 -			u32 mask = ~(15 << 4*(maxNibble - editNibble));
 629.635 -			switch (dataSize)
 629.636 -			{
 629.637 -			case 0:
 629.638 -				editData(editAddress, 8, mask, value);
 629.639 -				break;
 629.640 -			case 1:
 629.641 -				editData(editAddress, 16, mask, value);
 629.642 -				break;
 629.643 -			case 2:
 629.644 -				editData(editAddress, 32, mask, value);
 629.645 -				break;
 629.646 -			}
 629.647 -			moveAddress(0, 1);
 629.648 -			InvalidateRect(NULL, TRUE);
 629.649 -		}
 629.650 -	}
 629.651 -	return true;
 629.652 -}
 629.653 -
 629.654 -void MemoryViewer::beep()
 629.655 -{
 629.656 -	MessageBeep((UINT)-1);
 629.657 -}
 629.658 -
 629.659 -void MemoryViewer::registerClass()
 629.660 -{
 629.661 -	if (!isRegistered)
 629.662 -	{
 629.663 -		WNDCLASS wc;
 629.664 -		ZeroMemory(&wc, sizeof(wc));
 629.665 -		wc.style         = CS_PARENTDC | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
 629.666 -		wc.lpfnWndProc   = (WNDPROC) ::DefWindowProc;
 629.667 -		wc.hInstance     = AfxGetInstanceHandle();
 629.668 -		wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
 629.669 -		wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
 629.670 -		wc.lpszMenuName  = NULL;
 629.671 -		wc.lpszClassName = "VbaMemoryViewer";
 629.672 -		AfxRegisterClass(&wc);
 629.673 -		isRegistered = true;
 629.674 -	}
 629.675 -}
 629.676 -
 629.677 -void MemoryViewer::setAddressSize(int s)
 629.678 -{
 629.679 -	addressSize = s;
 629.680 -}
 629.681 -
 629.682 -u32 MemoryViewer::getCurrentAddress()
 629.683 -{
 629.684 -	return editAddress;
 629.685 -}
 629.686 -
 629.687 -int MemoryViewer::getSize()
 629.688 -{
 629.689 -	return dataSize;
 629.690 -}
 629.691 -
   630.1 --- a/src/win32/MemoryViewer.h	Sat Mar 03 10:54:39 2012 -0600
   630.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   630.3 @@ -1,97 +0,0 @@
   630.4 -#if !defined(AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_)
   630.5 -#define AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_
   630.6 -
   630.7 -#if _MSC_VER > 1000
   630.8 -#pragma once
   630.9 -#endif // _MSC_VER > 1000
  630.10 -// -*- C++ -*-
  630.11 -// MemoryViewer.h : header file
  630.12 -//
  630.13 -
  630.14 -/////////////////////////////////////////////////////////////////////////////
  630.15 -// MemoryViewer window
  630.16 -
  630.17 -class IMemoryViewerDlg
  630.18 -{
  630.19 -public:
  630.20 -	virtual void setCurrentAddress(u32 address) = 0;
  630.21 -};
  630.22 -
  630.23 -class MemoryViewer : public CWnd
  630.24 -{
  630.25 -	u32   address;
  630.26 -	int   addressSize;
  630.27 -	int   dataSize;
  630.28 -	bool  hasCaret;
  630.29 -	int   caretWidth;
  630.30 -	int   caretHeight;
  630.31 -	HFONT font;
  630.32 -	CSize fontSize;
  630.33 -	u32   editAddress;
  630.34 -	int   editNibble;
  630.35 -	int   maxNibble;
  630.36 -	int   displayedLines;
  630.37 -	int   beginAscii;
  630.38 -	int   beginHex;
  630.39 -	bool  editAscii;
  630.40 -	bool  decimalDisplay;
  630.41 -	IMemoryViewerDlg *dlg;
  630.42 -
  630.43 -	static bool isRegistered;
  630.44 -	// Construction
  630.45 -public:
  630.46 -	MemoryViewer();
  630.47 -
  630.48 -	// Attributes
  630.49 -public:
  630.50 -	// Operations
  630.51 -public:
  630.52 -	virtual void readData(u32, int, u8 *)     = 0;
  630.53 -	virtual void editData(u32, int, int, u32) = 0;
  630.54 -
  630.55 -	// Overrides
  630.56 -	// ClassWizard generated virtual function overrides
  630.57 -	//{{AFX_VIRTUAL(MemoryViewer)
  630.58 -	//}}AFX_VIRTUAL
  630.59 -
  630.60 -	// Implementation
  630.61 -public:
  630.62 -	int getSize();
  630.63 -	u32 getCurrentAddress();
  630.64 -	void setAddressSize(int s);
  630.65 -	void registerClass();
  630.66 -	void beep();
  630.67 -	bool OnEditInput(UINT c);
  630.68 -	void moveAddress(s32 offset, int nibbleOff);
  630.69 -	void setCaretPos();
  630.70 -	void destroyEditCaret();
  630.71 -	void createEditCaret(int w, int h);
  630.72 -	void updateScrollInfo(int lines);
  630.73 -	void setSize(int s);
  630.74 -	void setDecimal(bool decimalDisplayMode);
  630.75 -	void setAddress(u32 a);
  630.76 -	void setDialog(IMemoryViewerDlg *d);
  630.77 -	virtual ~MemoryViewer();
  630.78 -
  630.79 -	// Generated message map functions
  630.80 -protected:
  630.81 -	//{{AFX_MSG(MemoryViewer)
  630.82 -	afx_msg BOOL OnEraseBkgnd(CDC*pDC);
  630.83 -	afx_msg void OnPaint();
  630.84 -	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  630.85 -	afx_msg UINT OnGetDlgCode();
  630.86 -	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  630.87 -	afx_msg void OnSetFocus(CWnd*pOldWnd);
  630.88 -	afx_msg void OnKillFocus(CWnd*pNewWnd);
  630.89 -	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  630.90 -	//}}AFX_MSG
  630.91 -	DECLARE_MESSAGE_MAP()
  630.92 -	afx_msg LRESULT OnWMChar(WPARAM wParam, LPARAM lParam);
  630.93 -};
  630.94 -
  630.95 -/////////////////////////////////////////////////////////////////////////////
  630.96 -
  630.97 -//{{AFX_INSERT_LOCATION}}
  630.98 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  630.99 -
 630.100 -#endif // !defined(AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_)
   631.1 --- a/src/win32/MemoryViewerAddressSize.cpp	Sat Mar 03 10:54:39 2012 -0600
   631.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   631.3 @@ -1,115 +0,0 @@
   631.4 -// MemoryViewerAddressSize.cpp : implementation file
   631.5 -//
   631.6 -
   631.7 -#include "stdafx.h"
   631.8 -#include "resource.h"
   631.9 -#include "MemoryViewerAddressSize.h"
  631.10 -
  631.11 -/////////////////////////////////////////////////////////////////////////////
  631.12 -// MemoryViewerAddressSize dialog
  631.13 -
  631.14 -MemoryViewerAddressSize::MemoryViewerAddressSize(u32 a, int s, CWnd*pParent /*=NULL*/)
  631.15 -	: CDialog(MemoryViewerAddressSize::IDD, pParent)
  631.16 -{
  631.17 -	//{{AFX_DATA_INIT(MemoryViewerAddressSize)
  631.18 -	// NOTE: the ClassWizard will add member initialization here
  631.19 -	//}}AFX_DATA_INIT
  631.20 -	address = a;
  631.21 -	size    = s;
  631.22 -}
  631.23 -
  631.24 -void MemoryViewerAddressSize::DoDataExchange(CDataExchange*pDX)
  631.25 -{
  631.26 -	CDialog::DoDataExchange(pDX);
  631.27 -	//{{AFX_DATA_MAP(MemoryViewerAddressSize)
  631.28 -	DDX_Control(pDX, IDC_SIZE_CONTROL, m_size);
  631.29 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
  631.30 -	//}}AFX_DATA_MAP
  631.31 -}
  631.32 -
  631.33 -BEGIN_MESSAGE_MAP(MemoryViewerAddressSize, CDialog)
  631.34 -//{{AFX_MSG_MAP(MemoryViewerAddressSize)
  631.35 -ON_BN_CLICKED(ID_OK, OnOk)
  631.36 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  631.37 -//}}AFX_MSG_MAP
  631.38 -END_MESSAGE_MAP()
  631.39 -
  631.40 -/////////////////////////////////////////////////////////////////////////////
  631.41 -// MemoryViewerAddressSize message handlers
  631.42 -
  631.43 -BOOL MemoryViewerAddressSize::OnInitDialog()
  631.44 -{
  631.45 -	CDialog::OnInitDialog();
  631.46 -
  631.47 -	CString buffer;
  631.48 -	if (address != 0xFFFFFFFF)
  631.49 -	{
  631.50 -		buffer.Format("%08X", address);
  631.51 -		m_address.SetWindowText(buffer);
  631.52 -	}
  631.53 -	if (size != -1)
  631.54 -	{
  631.55 -		buffer.Format("%08X", size);
  631.56 -		m_size.SetWindowText(buffer);
  631.57 -		m_size.EnableWindow(FALSE);
  631.58 -	}
  631.59 -
  631.60 -	if (size == -1 && address != 0xFFFFFFFF)
  631.61 -		m_size.SetFocus();
  631.62 -
  631.63 -	m_address.LimitText(9);
  631.64 -	m_size.LimitText(9);
  631.65 -
  631.66 -	return TRUE; // return TRUE unless you set the focus to a control
  631.67 -	             // EXCEPTION: OCX Property Pages should return FALSE
  631.68 -}
  631.69 -
  631.70 -void MemoryViewerAddressSize::OnOk()
  631.71 -{
  631.72 -	CString buffer;
  631.73 -
  631.74 -	m_address.GetWindowText(buffer);
  631.75 -	if (buffer.IsEmpty())
  631.76 -	{
  631.77 -		m_address.SetFocus();
  631.78 -		return;
  631.79 -	}
  631.80 -	sscanf(buffer, "%x", &address);
  631.81 -
  631.82 -	m_size.GetWindowText(buffer);
  631.83 -	if (buffer.IsEmpty())
  631.84 -	{
  631.85 -		m_size.SetFocus();
  631.86 -		return;
  631.87 -	}
  631.88 -	sscanf(buffer, "%x", &size);
  631.89 -	EndDialog(TRUE);
  631.90 -}
  631.91 -
  631.92 -void MemoryViewerAddressSize::OnCancel()
  631.93 -{
  631.94 -	EndDialog(FALSE);
  631.95 -}
  631.96 -
  631.97 -void MemoryViewerAddressSize::setAddress(u32 a)
  631.98 -{
  631.99 -	address = a;
 631.100 -}
 631.101 -
 631.102 -void MemoryViewerAddressSize::setSize(int s)
 631.103 -{
 631.104 -	size = s;
 631.105 -}
 631.106 -
 631.107 -u32 MemoryViewerAddressSize::getAddress()
 631.108 -{
 631.109 -	return address;
 631.110 -}
 631.111 -
 631.112 -\
 631.113 -
 631.114 -int MemoryViewerAddressSize::getSize()
 631.115 -{
 631.116 -	return size;
 631.117 -}
 631.118 -
   632.1 --- a/src/win32/MemoryViewerAddressSize.h	Sat Mar 03 10:54:39 2012 -0600
   632.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   632.3 @@ -1,54 +0,0 @@
   632.4 -#if !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_)
   632.5 -#define AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_
   632.6 -
   632.7 -#if _MSC_VER > 1000
   632.8 -#pragma once
   632.9 -#endif // _MSC_VER > 1000
  632.10 -// -*- C++ -*-
  632.11 -// MemoryViewerAddressSize.h : header file
  632.12 -//
  632.13 -
  632.14 -/////////////////////////////////////////////////////////////////////////////
  632.15 -// MemoryViewerAddressSize dialog
  632.16 -
  632.17 -class MemoryViewerAddressSize : public CDialog
  632.18 -{
  632.19 -	u32 address;
  632.20 -	int size;
  632.21 -	// Construction
  632.22 -public:
  632.23 -	int getSize();
  632.24 -	u32 getAddress();
  632.25 -	void setSize(int s);
  632.26 -	void setAddress(u32 a);
  632.27 -	MemoryViewerAddressSize(u32 a = 0xffffff, int s = -1, CWnd*pParent = NULL); // standard constructor
  632.28 -
  632.29 -	// Dialog Data
  632.30 -	//{{AFX_DATA(MemoryViewerAddressSize)
  632.31 -	enum { IDD = IDD_ADDR_SIZE };
  632.32 -	CEdit m_size;
  632.33 -	CEdit m_address;
  632.34 -	//}}AFX_DATA
  632.35 -
  632.36 -	// Overrides
  632.37 -	// ClassWizard generated virtual function overrides
  632.38 -	//{{AFX_VIRTUAL(MemoryViewerAddressSize)
  632.39 -protected:
  632.40 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  632.41 -	//}}AFX_VIRTUAL
  632.42 -
  632.43 -	// Implementation
  632.44 -protected:
  632.45 -	// Generated message map functions
  632.46 -	//{{AFX_MSG(MemoryViewerAddressSize)
  632.47 -	virtual BOOL OnInitDialog();
  632.48 -	afx_msg void OnOk();
  632.49 -	afx_msg void OnCancel();
  632.50 -	//}}AFX_MSG
  632.51 -	DECLARE_MESSAGE_MAP()
  632.52 -};
  632.53 -
  632.54 -//{{AFX_INSERT_LOCATION}}
  632.55 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  632.56 -
  632.57 -#endif // !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_)
   633.1 --- a/src/win32/MemoryViewerDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   633.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   633.3 @@ -1,449 +0,0 @@
   633.4 -// MemoryViewerDlg.cpp : implementation file
   633.5 -//
   633.6 -
   633.7 -#include "stdafx.h"
   633.8 -#include "resource.h"
   633.9 -#include "MemoryViewerDlg.h"
  633.10 -#include "FileDlg.h"
  633.11 -#include "MemoryViewerAddressSize.h"
  633.12 -#include "Reg.h"
  633.13 -#include "WinResUtil.h"
  633.14 -#include "VBA.h"
  633.15 -
  633.16 -#include "../gba/GBAGlobals.h"
  633.17 -
  633.18 -#define CPUReadByteQuick(addr) \
  633.19 -    ::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]
  633.20 -#define CPUWriteByteQuick(addr, b) \
  633.21 -    ::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask] = (b)
  633.22 -#define CPUReadHalfWordQuick(addr) \
  633.23 -    *((u16 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask])
  633.24 -#define CPUWriteHalfWordQuick(addr, b) \
  633.25 -    *((u16 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) = (b)
  633.26 -#define CPUReadMemoryQuick(addr) \
  633.27 -    *((u32 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask])
  633.28 -#define CPUWriteMemoryQuick(addr, b) \
  633.29 -    *((u32 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) = (b)
  633.30 -
  633.31 -/////////////////////////////////////////////////////////////////////////////
  633.32 -// GBAMemoryViewer control
  633.33 -
  633.34 -GBAMemoryViewer::GBAMemoryViewer()
  633.35 -	: MemoryViewer()
  633.36 -{
  633.37 -	setAddressSize(0);
  633.38 -}
  633.39 -
  633.40 -void GBAMemoryViewer::readData(u32 address, int len, u8 *data)
  633.41 -{
  633.42 -	if (emulating && rom != NULL)
  633.43 -	{
  633.44 -		for (int i = 0; i < len; i++)
  633.45 -		{
  633.46 -			*data++ = CPUReadByteQuick(address);
  633.47 -			address++;
  633.48 -		}
  633.49 -	}
  633.50 -	else
  633.51 -	{
  633.52 -		for (int i = 0; i < len; i++)
  633.53 -		{
  633.54 -			*data++ = 0;
  633.55 -			address++;
  633.56 -		}
  633.57 -	}
  633.58 -}
  633.59 -
  633.60 -void GBAMemoryViewer::editData(u32 address, int size, int mask, u32 value)
  633.61 -{
  633.62 -	u32 oldValue;
  633.63 -
  633.64 -	switch (size)
  633.65 -	{
  633.66 -	case 8:
  633.67 -		oldValue = (CPUReadByteQuick(address) & mask) | value;
  633.68 -		CPUWriteByteQuick(address, oldValue);
  633.69 -		break;
  633.70 -	case 16:
  633.71 -		oldValue = (CPUReadHalfWordQuick(address) & mask) | value;
  633.72 -		CPUWriteHalfWordQuick(address, oldValue);
  633.73 -		break;
  633.74 -	case 32:
  633.75 -		oldValue = (CPUReadMemoryQuick(address) & mask) | value;
  633.76 -		CPUWriteMemoryQuick(address, oldValue);
  633.77 -		break;
  633.78 -	}
  633.79 -}
  633.80 -
  633.81 -/////////////////////////////////////////////////////////////////////////////
  633.82 -// MemoryViewerDlg dialog
  633.83 -
  633.84 -MemoryViewerDlg::MemoryViewerDlg(CWnd*pParent /*=NULL*/)
  633.85 -	: ResizeDlg(MemoryViewerDlg::IDD, pParent)
  633.86 -{
  633.87 -	//{{AFX_DATA_INIT(MemoryViewerDlg)
  633.88 -	m_size = -1;
  633.89 -	//}}AFX_DATA_INIT
  633.90 -}
  633.91 -
  633.92 -void MemoryViewerDlg::DoDataExchange(CDataExchange*pDX)
  633.93 -{
  633.94 -	CDialog::DoDataExchange(pDX);
  633.95 -	//{{AFX_DATA_MAP(MemoryViewerDlg)
  633.96 -	DDX_Control(pDX, IDC_CURRENT_ADDRESS, m_current);
  633.97 -	DDX_Control(pDX, IDC_ADDRESS, m_address);
  633.98 -	DDX_Control(pDX, IDC_ADDRESSES, m_addresses);
  633.99 -	DDX_Check(pDX, IDC_AUTO_UPDATE, autoUpdate);
 633.100 -	DDX_Check(pDX, IDC_DECIMAL_DISPLAY, decimalDisplay);
 633.101 -	DDX_Check(pDX, IDC_ALIGN, align);
 633.102 -	DDX_Radio(pDX, IDC_8_BIT, m_size);
 633.103 -	//}}AFX_DATA_MAP
 633.104 -	DDX_Control(pDX, IDC_VIEWER, m_viewer);
 633.105 -}
 633.106 -
 633.107 -BEGIN_MESSAGE_MAP(MemoryViewerDlg, CDialog)
 633.108 -//{{AFX_MSG_MAP(MemoryViewerDlg)
 633.109 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
 633.110 -ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
 633.111 -ON_BN_CLICKED(IDC_8_BIT, On8Bit)
 633.112 -ON_BN_CLICKED(IDC_16_BIT, On16Bit)
 633.113 -ON_BN_CLICKED(IDC_32_BIT, On32Bit)
 633.114 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
 633.115 -ON_BN_CLICKED(IDC_DECIMAL_DISPLAY, OnDecimalDisplay)
 633.116 -ON_BN_CLICKED(IDC_ALIGN, OnAlign)
 633.117 -ON_BN_CLICKED(IDC_GO, OnGo)
 633.118 -ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses)
 633.119 -ON_BN_CLICKED(IDC_SAVE, OnSave)
 633.120 -ON_BN_CLICKED(IDC_LOAD, OnLoad)
 633.121 -//}}AFX_MSG_MAP
 633.122 -END_MESSAGE_MAP()
 633.123 -
 633.124 -/////////////////////////////////////////////////////////////////////////////
 633.125 -// MemoryViewerDlg message handlers
 633.126 -
 633.127 -BOOL MemoryViewerDlg::OnInitDialog()
 633.128 -{
 633.129 -	CDialog::OnInitDialog();
 633.130 -
 633.131 -	DIALOG_SIZER_START(sz)
 633.132 -	DIALOG_SIZER_ENTRY(IDC_VIEWER, DS_SizeX | DS_SizeY)
 633.133 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 633.134 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 633.135 -	DIALOG_SIZER_ENTRY(IDC_LOAD, DS_MoveY)
 633.136 -	DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
 633.137 -	DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveY)
 633.138 -	DIALOG_SIZER_ENTRY(IDC_DECIMAL_DISPLAY, DS_MoveY)
 633.139 -	DIALOG_SIZER_ENTRY(IDC_ALIGN, DS_MoveY)
 633.140 -	DIALOG_SIZER_ENTRY(IDC_CURRENT_ADDRESS_LABEL, DS_MoveY | DS_MoveX)
 633.141 -	DIALOG_SIZER_ENTRY(IDC_CURRENT_ADDRESS, DS_MoveY | DS_MoveX)
 633.142 -	DIALOG_SIZER_END()
 633.143 -	SetData(sz,
 633.144 -			TRUE,
 633.145 -			HKEY_CURRENT_USER,
 633.146 -			"Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBDisassembleView",
 633.147 -			NULL);
 633.148 -
 633.149 -	autoUpdate = regQueryDwordValue("memViewerAutoUpdate", 1);
 633.150 -	if (autoUpdate)
 633.151 -	{
 633.152 -		theApp.winAddUpdateListener(this);
 633.153 -	}
 633.154 -	else
 633.155 -	{
 633.156 -		theApp.winRemoveUpdateListener(this);
 633.157 -	}
 633.158 -
 633.159 -	decimalDisplay = regQueryDwordValue("memViewerDecimalDisplay", 0);
 633.160 -	m_viewer.setDecimal(decimalDisplay ? true : false);
 633.161 -	align = regQueryDwordValue("memViewerAlign", 0);
 633.162 -
 633.163 -	m_viewer.setDialog(this);
 633.164 -	m_viewer.ShowScrollBar(SB_VERT, TRUE);
 633.165 -	m_viewer.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH);
 633.166 -
 633.167 -	LPCTSTR s[] = {
 633.168 -		"0x00000000 - BIOS",
 633.169 -		"0x02000000 - WRAM",
 633.170 -		"0x03000000 - IRAM",
 633.171 -		"0x04000000 - I/O",
 633.172 -		"0x05000000 - PALETTE",
 633.173 -		"0x06000000 - VRAM",
 633.174 -		"0x07000000 - OAM",
 633.175 -		"0x08000000 - ROM"
 633.176 -	};
 633.177 -
 633.178 -	for (int i = 0; i < 8; i++)
 633.179 -		m_addresses.AddString(s[i]);
 633.180 -
 633.181 -	m_addresses.SetCurSel(0);
 633.182 -
 633.183 -	RECT cbSize;
 633.184 -	int  Height;
 633.185 -
 633.186 -	m_addresses.GetClientRect(&cbSize);
 633.187 -	Height  = m_addresses.GetItemHeight(-1);
 633.188 -	Height += m_addresses.GetItemHeight(0) * (9);
 633.189 -
 633.190 -	// Note: The use of SM_CYEDGE assumes that we're using Windows '95
 633.191 -	// Now add on the height of the border of the edit box
 633.192 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 633.193 -
 633.194 -	// The height of the border of the drop-down box
 633.195 -	Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
 633.196 -
 633.197 -	// now set the size of the window
 633.198 -	m_addresses.SetWindowPos(NULL,
 633.199 -	                         0, 0,
 633.200 -	                         cbSize.right, Height,
 633.201 -	                         SWP_NOMOVE | SWP_NOZORDER);
 633.202 -
 633.203 -	m_address.LimitText(8);
 633.204 -
 633.205 -	m_size = regQueryDwordValue("memViewerDataSize", 1);
 633.206 -	if (m_size < 0 || m_size > 2)
 633.207 -		m_size = 0;
 633.208 -	m_viewer.setSize(m_size);
 633.209 -	UpdateData(FALSE);
 633.210 -
 633.211 -	m_current.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
 633.212 -
 633.213 -	return TRUE; // return TRUE unless you set the focus to a control
 633.214 -	             // EXCEPTION: OCX Property Pages should return FALSE
 633.215 -}
 633.216 -
 633.217 -void MemoryViewerDlg::OnClose()
 633.218 -{
 633.219 -	theApp.winRemoveUpdateListener(this);
 633.220 -
 633.221 -	DestroyWindow();
 633.222 -}
 633.223 -
 633.224 -void MemoryViewerDlg::OnRefresh()
 633.225 -{
 633.226 -	m_viewer.Invalidate();
 633.227 -}
 633.228 -
 633.229 -void MemoryViewerDlg::update()
 633.230 -{
 633.231 -	OnRefresh();
 633.232 -}
 633.233 -
 633.234 -void MemoryViewerDlg::On8Bit()
 633.235 -{
 633.236 -	m_viewer.setSize(0);
 633.237 -	regSetDwordValue("memViewerDataSize", 0);
 633.238 -}
 633.239 -
 633.240 -void MemoryViewerDlg::On16Bit()
 633.241 -{
 633.242 -	m_viewer.setSize(1);
 633.243 -	regSetDwordValue("memViewerDataSize", 1);
 633.244 -}
 633.245 -
 633.246 -void MemoryViewerDlg::On32Bit()
 633.247 -{
 633.248 -	m_viewer.setSize(2);
 633.249 -	regSetDwordValue("memViewerDataSize", 2);
 633.250 -}
 633.251 -
 633.252 -void MemoryViewerDlg::OnAutoUpdate()
 633.253 -{
 633.254 -	autoUpdate = !autoUpdate;
 633.255 -	if (autoUpdate)
 633.256 -	{
 633.257 -		theApp.winAddUpdateListener(this);
 633.258 -	}
 633.259 -	else
 633.260 -	{
 633.261 -		theApp.winRemoveUpdateListener(this);
 633.262 -	}
 633.263 -	regSetDwordValue("memViewerAutoUpdate", autoUpdate);
 633.264 -}
 633.265 -
 633.266 -void MemoryViewerDlg::OnDecimalDisplay()
 633.267 -{
 633.268 -	decimalDisplay = !decimalDisplay;
 633.269 -	m_viewer.setDecimal(decimalDisplay ? true : false);
 633.270 -	regSetDwordValue("memViewerDecimalDisplay", decimalDisplay);
 633.271 -}
 633.272 -
 633.273 -void MemoryViewerDlg::OnAlign()
 633.274 -{
 633.275 -	align = !align;
 633.276 -	regSetDwordValue("memViewerAlign", align);
 633.277 -}
 633.278 -
 633.279 -void MemoryViewerDlg::OnGo()
 633.280 -{
 633.281 -	CString buffer;
 633.282 -
 633.283 -	m_address.GetWindowText(buffer);
 633.284 -
 633.285 -	u32 address;
 633.286 -	sscanf(buffer, "%x", &address);
 633.287 -	if (align)
 633.288 -		address &= ~0xF;
 633.289 -	else
 633.290 -	{
 633.291 -		if (m_viewer.getSize() == 1)
 633.292 -			address &= ~1;
 633.293 -		else if (m_viewer.getSize() == 2)
 633.294 -			address &= ~3;
 633.295 -	}
 633.296 -	m_viewer.setAddress(address);
 633.297 -}
 633.298 -
 633.299 -void MemoryViewerDlg::OnSelchangeAddresses()
 633.300 -{
 633.301 -	int cur = m_addresses.GetCurSel();
 633.302 -
 633.303 -	switch (cur)
 633.304 -	{
 633.305 -	case 0:
 633.306 -		m_viewer.setAddress(0);
 633.307 -		break;
 633.308 -	case 1:
 633.309 -		m_viewer.setAddress(0x2000000);
 633.310 -		break;
 633.311 -	case 2:
 633.312 -		m_viewer.setAddress(0x3000000);
 633.313 -		break;
 633.314 -	case 3:
 633.315 -		m_viewer.setAddress(0x4000000);
 633.316 -		break;
 633.317 -	case 4:
 633.318 -		m_viewer.setAddress(0x5000000);
 633.319 -		break;
 633.320 -	case 5:
 633.321 -		m_viewer.setAddress(0x6000000);
 633.322 -		break;
 633.323 -	case 6:
 633.324 -		m_viewer.setAddress(0x7000000);
 633.325 -		break;
 633.326 -	case 7:
 633.327 -		m_viewer.setAddress(0x8000000);
 633.328 -		break;
 633.329 -	}
 633.330 -}
 633.331 -
 633.332 -void MemoryViewerDlg::setCurrentAddress(u32 address)
 633.333 -{
 633.334 -	CString buffer;
 633.335 -
 633.336 -	buffer.Format("0x%08X", address);
 633.337 -	m_current.SetWindowText(buffer);
 633.338 -}
 633.339 -
 633.340 -void MemoryViewerDlg::OnSave()
 633.341 -{
 633.342 -	MemoryViewerAddressSize dlg;
 633.343 -	CString buffer;
 633.344 -
 633.345 -	dlg.setAddress(m_viewer.getCurrentAddress());
 633.346 -
 633.347 -	LPCTSTR exts[] = { ".dmp", NULL };
 633.348 -
 633.349 -	if (dlg.DoModal() == IDOK)
 633.350 -	{
 633.351 -		CString filter = winResLoadFilter(IDS_FILTER_DUMP);
 633.352 -		CString title  = winResLoadString(IDS_SELECT_DUMP_FILE);
 633.353 -
 633.354 -		FileDlg file(this,
 633.355 -		             buffer,
 633.356 -		             filter,
 633.357 -		             0,
 633.358 -		             "DMP",
 633.359 -		             exts,
 633.360 -		             "",
 633.361 -		             title,
 633.362 -		             true);
 633.363 -		if (file.DoModal() == IDOK)
 633.364 -		{
 633.365 -			buffer = file.GetPathName();
 633.366 -
 633.367 -			FILE *f = fopen(buffer, "wb");
 633.368 -
 633.369 -			if (f == NULL)
 633.370 -			{
 633.371 -				systemMessage(IDS_ERROR_CREATING_FILE, buffer);
 633.372 -				return;
 633.373 -			}
 633.374 -
 633.375 -			int size = dlg.getSize();
 633.376 -			u32 addr = dlg.getAddress();
 633.377 -
 633.378 -			for (int i = 0; i < size; i++)
 633.379 -			{
 633.380 -				fputc(CPUReadByteQuick(addr), f);
 633.381 -				addr++;
 633.382 -			}
 633.383 -
 633.384 -			fclose(f);
 633.385 -		}
 633.386 -	}
 633.387 -}
 633.388 -
 633.389 -void MemoryViewerDlg::OnLoad()
 633.390 -{
 633.391 -	CString buffer;
 633.392 -	LPCTSTR exts[] = { ".dmp", NULL };
 633.393 -
 633.394 -	CString filter = winResLoadFilter(IDS_FILTER_DUMP);
 633.395 -	CString title  = winResLoadString(IDS_SELECT_DUMP_FILE);
 633.396 -
 633.397 -	FileDlg file(this,
 633.398 -	             buffer,
 633.399 -	             filter,
 633.400 -	             0,
 633.401 -	             "DMP",
 633.402 -	             exts,
 633.403 -	             "",
 633.404 -	             title,
 633.405 -	             false);
 633.406 -
 633.407 -	if (file.DoModal() == IDOK)
 633.408 -	{
 633.409 -		buffer = file.GetPathName();
 633.410 -		FILE *f = fopen(buffer, "rb");
 633.411 -		if (f == NULL)
 633.412 -		{
 633.413 -			systemMessage(IDS_CANNOT_OPEN_FILE,
 633.414 -			              "Cannot open file %s",
 633.415 -			              buffer);
 633.416 -			return;
 633.417 -		}
 633.418 -
 633.419 -		MemoryViewerAddressSize dlg;
 633.420 -
 633.421 -		fseek(f, 0, SEEK_END);
 633.422 -		int size = ftell(f);
 633.423 -
 633.424 -		fseek(f, 0, SEEK_SET);
 633.425 -
 633.426 -		dlg.setAddress(m_viewer.getCurrentAddress());
 633.427 -		dlg.setSize(size);
 633.428 -
 633.429 -		if (dlg.DoModal() == IDOK)
 633.430 -		{
 633.431 -			int size = dlg.getSize();
 633.432 -			u32 addr = dlg.getAddress();
 633.433 -
 633.434 -			for (int i = 0; i < size; i++)
 633.435 -			{
 633.436 -				int c = fgetc(f);
 633.437 -				if (c == -1)
 633.438 -					break;
 633.439 -				CPUWriteByteQuick(addr, c);
 633.440 -				addr++;
 633.441 -			}
 633.442 -			OnRefresh();
 633.443 -		}
 633.444 -		fclose(f);
 633.445 -	}
 633.446 -}
 633.447 -
 633.448 -void MemoryViewerDlg::PostNcDestroy()
 633.449 -{
 633.450 -	delete this;
 633.451 -}
 633.452 -
   634.1 --- a/src/win32/MemoryViewerDlg.h	Sat Mar 03 10:54:39 2012 -0600
   634.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   634.3 @@ -1,79 +0,0 @@
   634.4 -#if !defined(AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_)
   634.5 -#define AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_
   634.6 -
   634.7 -#if _MSC_VER > 1000
   634.8 -#pragma once
   634.9 -#endif // _MSC_VER > 1000
  634.10 -// -*- C++ -*-
  634.11 -// MemoryViewerDlg.h : header file
  634.12 -//
  634.13 -
  634.14 -#include "MemoryViewer.h"
  634.15 -#include "ResizeDlg.h"
  634.16 -#include "IUpdate.h"
  634.17 -
  634.18 -class GBAMemoryViewer : public MemoryViewer
  634.19 -{
  634.20 -public:
  634.21 -	GBAMemoryViewer();
  634.22 -	virtual void readData(u32, int, u8 *);
  634.23 -	virtual void editData(u32, int, int, u32);
  634.24 -};
  634.25 -
  634.26 -/////////////////////////////////////////////////////////////////////////////
  634.27 -// MemoryViewerDlg dialog
  634.28 -
  634.29 -class MemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg
  634.30 -{
  634.31 -	GBAMemoryViewer m_viewer;
  634.32 -	// Construction
  634.33 -public:
  634.34 -	void setCurrentAddress(u32 address);
  634.35 -	int autoUpdate;
  634.36 -	int decimalDisplay;
  634.37 -	int align;
  634.38 -	void update();
  634.39 -	MemoryViewerDlg(CWnd*pParent = NULL);  // standard constructor
  634.40 -
  634.41 -	// Dialog Data
  634.42 -	//{{AFX_DATA(MemoryViewerDlg)
  634.43 -	enum { IDD = IDD_MEM_VIEWER };
  634.44 -	CEdit     m_current;
  634.45 -	CEdit     m_address;
  634.46 -	CComboBox m_addresses;
  634.47 -	int       m_size;
  634.48 -	//}}AFX_DATA
  634.49 -
  634.50 -	// Overrides
  634.51 -	// ClassWizard generated virtual function overrides
  634.52 -	//{{AFX_VIRTUAL(MemoryViewerDlg)
  634.53 -protected:
  634.54 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  634.55 -	virtual void PostNcDestroy();
  634.56 -	//}}AFX_VIRTUAL
  634.57 -
  634.58 -	// Implementation
  634.59 -protected:
  634.60 -	// Generated message map functions
  634.61 -	//{{AFX_MSG(MemoryViewerDlg)
  634.62 -	virtual BOOL OnInitDialog();
  634.63 -	afx_msg void OnClose();
  634.64 -	afx_msg void OnRefresh();
  634.65 -	afx_msg void On8Bit();
  634.66 -	afx_msg void On16Bit();
  634.67 -	afx_msg void On32Bit();
  634.68 -	afx_msg void OnAutoUpdate();
  634.69 -	afx_msg void OnDecimalDisplay();
  634.70 -	afx_msg void OnAlign();
  634.71 -	afx_msg void OnGo();
  634.72 -	afx_msg void OnSelchangeAddresses();
  634.73 -	afx_msg void OnSave();
  634.74 -	afx_msg void OnLoad();
  634.75 -	//}}AFX_MSG
  634.76 -	DECLARE_MESSAGE_MAP()
  634.77 -};
  634.78 -
  634.79 -//{{AFX_INSERT_LOCATION}}
  634.80 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  634.81 -
  634.82 -#endif // !defined(AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_)
   635.1 --- a/src/win32/ModeConfirm.cpp	Sat Mar 03 10:54:39 2012 -0600
   635.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   635.3 @@ -1,90 +0,0 @@
   635.4 -// ModeConfirm.cpp : implementation file
   635.5 -//
   635.6 -
   635.7 -#include "stdafx.h"
   635.8 -#include "resource.h"
   635.9 -#include "ModeConfirm.h"
  635.10 -#include "VBA.h"
  635.11 -
  635.12 -/////////////////////////////////////////////////////////////////////////////
  635.13 -// ModeConfirm dialog
  635.14 -
  635.15 -
  635.16 -ModeConfirm::ModeConfirm(CWnd* pParent /*=NULL*/)
  635.17 -  : CDialog(ModeConfirm::IDD, pParent)
  635.18 -{
  635.19 -  //{{AFX_DATA_INIT(ModeConfirm)
  635.20 -  // NOTE: the ClassWizard will add member initialization here
  635.21 -  //}}AFX_DATA_INIT
  635.22 -}
  635.23 -
  635.24 -
  635.25 -void ModeConfirm::DoDataExchange(CDataExchange* pDX)
  635.26 -{
  635.27 -  CDialog::DoDataExchange(pDX);
  635.28 -  //{{AFX_DATA_MAP(ModeConfirm)
  635.29 -  // NOTE: the ClassWizard will add DDX and DDV calls here
  635.30 -  //}}AFX_DATA_MAP
  635.31 -}
  635.32 -
  635.33 -
  635.34 -BEGIN_MESSAGE_MAP(ModeConfirm, CDialog)
  635.35 -  //{{AFX_MSG_MAP(ModeConfirm)
  635.36 -  ON_BN_CLICKED(ID_CANCEL, OnCancel)
  635.37 -  ON_BN_CLICKED(ID_OK, OnOk)
  635.38 -  ON_WM_DESTROY()
  635.39 -  ON_WM_TIMER()
  635.40 -  //}}AFX_MSG_MAP
  635.41 -  END_MESSAGE_MAP()
  635.42 -
  635.43 -  /////////////////////////////////////////////////////////////////////////////
  635.44 -// ModeConfirm message handlers
  635.45 -
  635.46 -void ModeConfirm::OnCancel() 
  635.47 -{
  635.48 -  EndDialog(FALSE);
  635.49 -}
  635.50 -
  635.51 -void ModeConfirm::OnOk() 
  635.52 -{
  635.53 -  EndDialog(TRUE);
  635.54 -}
  635.55 -
  635.56 -void ModeConfirm::OnDestroy() 
  635.57 -{
  635.58 -  CDialog::OnDestroy();
  635.59 -  
  635.60 -  KillTimer(timer);
  635.61 -  timer = 0;
  635.62 -}
  635.63 -
  635.64 -BOOL ModeConfirm::OnInitDialog() 
  635.65 -{
  635.66 -  CDialog::OnInitDialog();
  635.67 -  
  635.68 -  timer = SetTimer(0, 1000, NULL);
  635.69 -
  635.70 -  count = 10;
  635.71 -
  635.72 -  CString buffer;
  635.73 -  buffer.Format("%d", count);
  635.74 -
  635.75 -  GetDlgItem(IDC_TIMER)->SetWindowText(buffer);
  635.76 -
  635.77 -  CenterWindow(theApp.m_pMainWnd);
  635.78 -  
  635.79 -  return TRUE;  // return TRUE unless you set the focus to a control
  635.80 -                // EXCEPTION: OCX Property Pages should return FALSE
  635.81 -}
  635.82 -
  635.83 -void ModeConfirm::OnTimer(UINT nIDEvent) 
  635.84 -{
  635.85 -  CString buffer;  
  635.86 -  count--;
  635.87 -  if(count == 0)
  635.88 -    EndDialog(FALSE);
  635.89 -  buffer.Format("%d", count);
  635.90 -  GetDlgItem(IDC_TIMER)->SetWindowText(buffer);
  635.91 -  
  635.92 -  CDialog::OnTimer(nIDEvent);
  635.93 -}
   636.1 --- a/src/win32/ModeConfirm.h	Sat Mar 03 10:54:39 2012 -0600
   636.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   636.3 @@ -1,51 +0,0 @@
   636.4 -#if !defined(AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_)
   636.5 -#define AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_
   636.6 -
   636.7 -#if _MSC_VER > 1000
   636.8 -#pragma once
   636.9 -#endif // _MSC_VER > 1000
  636.10 -// -*- C++ -*-
  636.11 -// ModeConfirm.h : header file
  636.12 -//
  636.13 -
  636.14 -/////////////////////////////////////////////////////////////////////////////
  636.15 -// ModeConfirm dialog
  636.16 -
  636.17 -class ModeConfirm : public CDialog
  636.18 -{
  636.19 -	// Construction
  636.20 -public:
  636.21 -	int  count;
  636.22 -	UINT timer;
  636.23 -	ModeConfirm(CWnd*pParent);  // standard constructor
  636.24 -
  636.25 -	// Dialog Data
  636.26 -	//{{AFX_DATA(ModeConfirm)
  636.27 -	enum { IDD = IDD_MODE_CONFIRM };
  636.28 -	// NOTE: the ClassWizard will add data members here
  636.29 -	//}}AFX_DATA
  636.30 -
  636.31 -	// Overrides
  636.32 -	// ClassWizard generated virtual function overrides
  636.33 -	//{{AFX_VIRTUAL(ModeConfirm)
  636.34 -protected:
  636.35 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  636.36 -	//}}AFX_VIRTUAL
  636.37 -
  636.38 -	// Implementation
  636.39 -protected:
  636.40 -	// Generated message map functions
  636.41 -	//{{AFX_MSG(ModeConfirm)
  636.42 -	afx_msg void OnCancel();
  636.43 -	afx_msg void OnOk();
  636.44 -	afx_msg void OnDestroy();
  636.45 -	virtual BOOL OnInitDialog();
  636.46 -	afx_msg void OnTimer(UINT nIDEvent);
  636.47 -	//}}AFX_MSG
  636.48 -	DECLARE_MESSAGE_MAP()
  636.49 -};
  636.50 -
  636.51 -//{{AFX_INSERT_LOCATION}}
  636.52 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  636.53 -
  636.54 -#endif // !defined(AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_)
   637.1 --- a/src/win32/MovieCreate.cpp	Sat Mar 03 10:54:39 2012 -0600
   637.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   637.3 @@ -1,389 +0,0 @@
   637.4 -// MovieCreate.cpp : implementation file
   637.5 -//
   637.6 -
   637.7 -#include "stdafx.h"
   637.8 -#include "resource.h"
   637.9 -#include "MovieCreate.h"
  637.10 -#include "MainWnd.h"
  637.11 -#include "FileDlg.h"
  637.12 -#include "WinResUtil.h"
  637.13 -#include "WinMiscUtil.h"
  637.14 -#include "VBA.h"
  637.15 -
  637.16 -#include "../NLS.h"
  637.17 -#include "../common/Util.h"
  637.18 -#include "../common/movie.h"
  637.19 -#include "../gba/GBAGlobals.h"
  637.20 -#include "../gb/gbGlobals.h"
  637.21 -
  637.22 -extern u32 myROM[];
  637.23 -
  637.24 -#define GBC_CAPABLE ((gbRom[0x143] & 0x80) != 0)
  637.25 -#define SGB_CAPABLE (gbRom[0x146] == 0x03)
  637.26 -
  637.27 -// MovieCreate dialog
  637.28 -
  637.29 -IMPLEMENT_DYNAMIC(MovieCreate, CDialog)
  637.30 -MovieCreate::MovieCreate(CWnd *pParent /*=NULL*/)
  637.31 -	: CDialog(MovieCreate::IDD, pParent)
  637.32 -{
  637.33 -	//{{AFX_DATA_INIT(MovieCreate)
  637.34 -	m_startOption  = 2; // "from start" as default
  637.35 -	m_systemOption = systemCartridgeType == 0 ? 0 : (GBC_CAPABLE ? 1 : (SGB_CAPABLE ? 2 : 3)); // GBA, GBC, SGB, or GB
  637.36 -	m_biosOption   = systemCartridgeType == 0 ? (useBios ? 2 : 1) : 0; // none for non-GBA, or introless and based on settings
  637.37 -	//}}AFX_DATA_INIT
  637.38 -}
  637.39 -
  637.40 -MovieCreate::~MovieCreate()
  637.41 -{}
  637.42 -
  637.43 -BOOL MovieCreate::OnInitDialog()
  637.44 -{
  637.45 -	CDialog::OnInitDialog();
  637.46 -
  637.47 -	GetDlgItem(IDC_REC_GBA)->EnableWindow(systemCartridgeType == 0);
  637.48 -	GetDlgItem(IDC_REC_GBC)->EnableWindow(systemCartridgeType != 0 && GBC_CAPABLE);
  637.49 -	GetDlgItem(IDC_REC_SGB)->EnableWindow(systemCartridgeType != 0 && SGB_CAPABLE);
  637.50 -	GetDlgItem(IDC_REC_GB)->EnableWindow(systemCartridgeType != 0);
  637.51 -
  637.52 -	GetDlgItem(IDC_REC_NOBIOS)->EnableWindow(systemCartridgeType != 0);
  637.53 -	GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(systemCartridgeType == 0);
  637.54 -	GetDlgItem(IDC_REC_GBABIOS)->EnableWindow(systemCartridgeType == 0);
  637.55 -	GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(systemCartridgeType == 0);
  637.56 -
  637.57 -	CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption);
  637.58 -
  637.59 -	m_editFilename.LimitText(_MAX_PATH);
  637.60 -	m_editAuthor.LimitText(MOVIE_METADATA_AUTHOR_SIZE);
  637.61 -	m_editDescription.LimitText(MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
  637.62 -
  637.63 -	// convert the ROM filename into a default movie name
  637.64 -	CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, ".vbm");
  637.65 -
  637.66 -	GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
  637.67 -
  637.68 -	// scroll to show the rightmost side of the movie filename
  637.69 -	((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
  637.70 -
  637.71 -	return TRUE; // return TRUE unless you set the focus to a control
  637.72 -	// EXCEPTION: OCX Property Pages should return FALSE
  637.73 -}
  637.74 -
  637.75 -void MovieCreate::DoDataExchange(CDataExchange *pDX)
  637.76 -{
  637.77 -	CDialog::DoDataExchange(pDX);
  637.78 -	//{{AFX_DATA_MAP(MovieCreate)
  637.79 -	DDX_Radio(pDX, IDC_RECNOW, m_startOption);
  637.80 -	DDX_Radio(pDX, IDC_REC_GBA, m_systemOption);
  637.81 -///	done manually DDX_Radio(pDX, IDC_REC_NOBIOS, m_biosOption);
  637.82 -	DDX_Control(pDX, IDC_EDIT_AUTHOR, m_editAuthor);
  637.83 -	DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_editDescription);
  637.84 -	DDX_Control(pDX, IDC_MOVIE_FILENAME, m_editFilename);
  637.85 -	//}}AFX_DATA_MAP
  637.86 -}
  637.87 -
  637.88 -BEGIN_MESSAGE_MAP(MovieCreate, CDialog)
  637.89 -ON_BN_CLICKED(IDOK, OnBnClickedOk)
  637.90 -ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
  637.91 -ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse)
  637.92 -ON_BN_CLICKED(IDC_RECSTART, OnBnClickedRecstart)
  637.93 -ON_BN_CLICKED(IDC_RECRESET, OnBnClickedRecreset)
  637.94 -ON_BN_CLICKED(IDC_RECNOW, OnBnClickedRecnow)
  637.95 -ON_BN_CLICKED(IDC_REC_GBA, OnBnClickedRecGba)
  637.96 -ON_BN_CLICKED(IDC_REC_GBC, OnBnClickedRecGbc)
  637.97 -ON_BN_CLICKED(IDC_REC_SGB, OnBnClickedRecSgb)
  637.98 -ON_BN_CLICKED(IDC_REC_GB, OnBnClickedRecGb)
  637.99 -ON_BN_CLICKED(IDC_REC_NOBIOS, OnBnClickedRecNobios)
 637.100 -ON_BN_CLICKED(IDC_REC_EMUBIOS, OnBnClickedRecEmubios)
 637.101 -ON_BN_CLICKED(IDC_REC_GBABIOS, OnBnClickedRecGbabios)
 637.102 -ON_BN_CLICKED(IDC_REC_GBABIOSINTRO, OnBnClickedRecGbabiosintro)
 637.103 -END_MESSAGE_MAP()
 637.104 -
 637.105 -// MovieCreate message handlers
 637.106 -
 637.107 -void MovieCreate::OnBnClickedBrowse()
 637.108 -{
 637.109 -	theApp.winCheckFullscreen();
 637.110 -
 637.111 -	LPCTSTR exts[] = { ".vbm", NULL };
 637.112 -
 637.113 -	CString filter = winResLoadFilter(IDS_FILTER_MOVIE);
 637.114 -	CString title  = winResLoadString(IDS_SELECT_MOVIE_NAME);
 637.115 -
 637.116 -	CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, exts[0]);
 637.117 -	CString movieDir  = winGetDestDir(IDS_MOVIE_DIR);
 637.118 -
 637.119 -	FileDlg dlg(this, movieName, filter, 1, "VBM", exts, movieDir, title, true);
 637.120 -
 637.121 -	if (dlg.DoModal() == IDCANCEL)
 637.122 -	{
 637.123 -		return;
 637.124 -	}
 637.125 -
 637.126 -	movieName = dlg.GetPathName();
 637.127 -
 637.128 -	GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
 637.129 -
 637.130 -	// scroll to show the rightmost side of the movie filename
 637.131 -	((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
 637.132 -}
 637.133 -
 637.134 -void MovieCreate::OnBnClickedOk()
 637.135 -{
 637.136 -	// has to be done before creating the movie
 637.137 -	bool useBiosFile  = false;
 637.138 -	bool skipBiosFile = false;
 637.139 -
 637.140 -	if (m_biosOption == 1)
 637.141 -	{
 637.142 -		useBiosFile = false;
 637.143 -	}
 637.144 -	else if (m_biosOption == 2)
 637.145 -	{
 637.146 -		useBiosFile	 = true;
 637.147 -		skipBiosFile = true;
 637.148 -	}
 637.149 -	else if (m_biosOption == 3)
 637.150 -	{
 637.151 -		useBiosFile	 = true;
 637.152 -		skipBiosFile = false;
 637.153 -	}
 637.154 -
 637.155 -	extern bool systemLoadBIOS(const char *biosFileName, bool useBiosFile);
 637.156 -	if (!systemLoadBIOS(theApp.biosFileName, useBiosFile))
 637.157 -	{
 637.158 -		if (m_biosOption > 1)
 637.159 -		{
 637.160 -			systemMessage(0, "Invalid GBA BIOS file!");
 637.161 -			return;
 637.162 -		}
 637.163 -	}
 637.164 -
 637.165 -	theApp.useBiosFile = useBiosFile;
 637.166 -	if (useBiosFile)
 637.167 -		theApp.skipBiosFile = skipBiosFile;
 637.168 -
 637.169 -	int startFlags = 0, controllerFlags = 0, typeFlags = 0;
 637.170 -
 637.171 -	if (m_startOption == 0)
 637.172 -		startFlags |= MOVIE_START_FROM_SNAPSHOT;
 637.173 -	else if (m_startOption == 1)
 637.174 -		startFlags |= MOVIE_START_FROM_SRAM;
 637.175 -	//else
 637.176 -	//	startFlags = 0; // no SRAM or snapshot
 637.177 -
 637.178 -	if (m_systemOption == 0)
 637.179 -	{
 637.180 -		typeFlags	  |= MOVIE_TYPE_GBA;
 637.181 -		gbEmulatorType = 4;
 637.182 -	}
 637.183 -	else if (m_systemOption == 1)
 637.184 -	{
 637.185 -		typeFlags	  |= MOVIE_TYPE_GBC;
 637.186 -		gbEmulatorType = 1;
 637.187 -	}
 637.188 -	else if (m_systemOption == 2)
 637.189 -	{
 637.190 -		typeFlags	  |= MOVIE_TYPE_SGB;
 637.191 -		gbEmulatorType = 2;
 637.192 -	}
 637.193 -	else
 637.194 -	{
 637.195 -		gbEmulatorType = 3;  // plain old GB
 637.196 -	}
 637.197 -
 637.198 -	controllerFlags |= MOVIE_CONTROLLER(0);
 637.199 -	if (typeFlags & MOVIE_TYPE_SGB)
 637.200 -	{
 637.201 -		// XXX FIXME - the code for multiple controllers must be broken somehow
 637.202 -		// (it crashes strangely during FreezeToStream in SGB games)
 637.203 -
 637.204 -		// SGB games are free to request controllers while running, so we have to assume it needs all 4
 637.205 -///		controllerFlags |= MOVIE_CONTROLLER(1) | MOVIE_CONTROLLER(2) | MOVIE_CONTROLLER(3);
 637.206 -	}
 637.207 -
 637.208 -	// get author and movie info from the edit fields:
 637.209 -	char info [MOVIE_METADATA_SIZE], buffer [MOVIE_METADATA_SIZE];
 637.210 -
 637.211 -	GetDlgItem(IDC_EDIT_AUTHOR)->GetWindowText(buffer, MOVIE_METADATA_AUTHOR_SIZE);
 637.212 -	strncpy(info, buffer, MOVIE_METADATA_AUTHOR_SIZE);
 637.213 -	info[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
 637.214 -
 637.215 -	GetDlgItem(IDC_EDIT_DESCRIPTION)->GetWindowText(buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
 637.216 -	strncpy(info + MOVIE_METADATA_AUTHOR_SIZE, buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
 637.217 -	info[MOVIE_METADATA_SIZE - 1] = '\0';
 637.218 -
 637.219 -	if (memLagTempEnabled && systemCartridgeType == 0)
 637.220 -	{
 637.221 -		// lag reduction is off -- if the user didn't turn it off, silently turn it back on, otherwise ask
 637.222 -		int ans = !memLagEnabled ? IDYES : AfxGetApp()->m_pMainWnd->MessageBox(
 637.223 -		    "Lag reduction is currently OFF.\nIt is recommended that you turn this ON for recording.\nWould you like to turn it on now?",
 637.224 -		    "Warning",
 637.225 -		    MB_YESNOCANCEL | MB_ICONWARNING);
 637.226 -		switch (ans)
 637.227 -		{
 637.228 -		case IDYES:
 637.229 -			extern void SetPrefetchHack(bool);
 637.230 -			SetPrefetchHack(true);
 637.231 -			break;
 637.232 -		case IDNO:
 637.233 -			break;
 637.234 -		case IDCANCEL:
 637.235 -			return;
 637.236 -		}
 637.237 -	}
 637.238 -
 637.239 -	CString movieName;
 637.240 -	GetDlgItem(IDC_MOVIE_FILENAME)->GetWindowText(movieName);
 637.241 -
 637.242 -	// actually make the movie file:
 637.243 -	int code = VBAMovieCreate(movieName, info, startFlags, controllerFlags, typeFlags);
 637.244 -
 637.245 -	if (code != MOVIE_SUCCESS)
 637.246 -	{
 637.247 -		systemMessage(0, "Failed to create movie %s", (const char *)movieName);
 637.248 -		return;
 637.249 -	}
 637.250 -
 637.251 -	OnOK();
 637.252 -}
 637.253 -
 637.254 -void MovieCreate::OnBnClickedCancel()
 637.255 -{
 637.256 -	OnCancel();
 637.257 -}
 637.258 -
 637.259 -void MovieCreate::OnBnClickedRecstart()
 637.260 -{
 637.261 -	m_startOption = 2;
 637.262 -	if (systemCartridgeType == 0)
 637.263 -	{
 637.264 -		GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(TRUE);
 637.265 -		GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(TRUE);
 637.266 -	}
 637.267 -	else
 637.268 -	{
 637.269 -		GetDlgItem(IDC_REC_GBC)->EnableWindow(GBC_CAPABLE);
 637.270 -		GetDlgItem(IDC_REC_SGB)->EnableWindow(SGB_CAPABLE);
 637.271 -		GetDlgItem(IDC_REC_GB)->EnableWindow(TRUE);
 637.272 -	}
 637.273 -}
 637.274 -
 637.275 -void MovieCreate::OnBnClickedRecreset()
 637.276 -{
 637.277 -	m_startOption = 1;
 637.278 -	if (systemCartridgeType == 0)
 637.279 -	{
 637.280 -		GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(TRUE);
 637.281 -		GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(TRUE);
 637.282 -	}
 637.283 -	else
 637.284 -	{
 637.285 -		GetDlgItem(IDC_REC_GBC)->EnableWindow(GBC_CAPABLE);
 637.286 -		GetDlgItem(IDC_REC_SGB)->EnableWindow(SGB_CAPABLE);
 637.287 -		GetDlgItem(IDC_REC_GB)->EnableWindow(TRUE);
 637.288 -	}
 637.289 -}
 637.290 -
 637.291 -void MovieCreate::OnBnClickedRecnow()
 637.292 -{
 637.293 -	m_startOption = 0;
 637.294 -
 637.295 -	// starting from emulator bios file from a snapshot made while playing with GBA bios file won't work
 637.296 -	if (systemCartridgeType == 0 && useBios)
 637.297 -	{
 637.298 -		if (m_biosOption == 1)
 637.299 -		{
 637.300 -			OnBnClickedRecGbabios();
 637.301 -			CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption);
 637.302 -		}
 637.303 -		GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(FALSE);
 637.304 -	}
 637.305 -
 637.306 -	// "with intro" distinction makes no sense when continuing from snapshot
 637.307 -	if (systemCartridgeType == 0)
 637.308 -	{
 637.309 -		if (m_biosOption == 3)
 637.310 -		{
 637.311 -			OnBnClickedRecGbabios();
 637.312 -			CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption);
 637.313 -		}
 637.314 -		GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(FALSE);
 637.315 -	}
 637.316 -
 637.317 -	// can't switch systems while recording from snapshot!
 637.318 -	if (systemCartridgeType != 0)
 637.319 -	{
 637.320 -		int curSystemOption = (gbCgbMode == 1 ? 1 : (gbSgbMode == 1 ? 2 : 3)); // GBC, SGB, or GB
 637.321 -		GetDlgItem(IDC_REC_GBC)->EnableWindow(curSystemOption == 1);
 637.322 -		GetDlgItem(IDC_REC_SGB)->EnableWindow(curSystemOption == 2);
 637.323 -		GetDlgItem(IDC_REC_GB)->EnableWindow(curSystemOption == 3);
 637.324 -		m_systemOption = curSystemOption;
 637.325 -		CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, IDC_REC_GBA + m_systemOption);
 637.326 -	}
 637.327 -}
 637.328 -
 637.329 -void MovieCreate::OnBnClickedRecGba()
 637.330 -{
 637.331 -	m_systemOption = 0;
 637.332 -}
 637.333 -
 637.334 -void MovieCreate::OnBnClickedRecGbc()
 637.335 -{
 637.336 -	m_systemOption = 1;
 637.337 -}
 637.338 -
 637.339 -void MovieCreate::OnBnClickedRecSgb()
 637.340 -{
 637.341 -	m_systemOption = 2;
 637.342 -}
 637.343 -
 637.344 -void MovieCreate::OnBnClickedRecGb()
 637.345 -{
 637.346 -	m_systemOption = 3;
 637.347 -}
 637.348 -
 637.349 -void MovieCreate::OnBnClickedRecNobios()
 637.350 -{
 637.351 -	m_biosOption = 0;
 637.352 -}
 637.353 -
 637.354 -void MovieCreate::OnBnClickedRecEmubios()
 637.355 -{
 637.356 -	m_biosOption = 1;
 637.357 -}
 637.358 -
 637.359 -void MovieCreate::OnBnClickedRecGbabios()
 637.360 -{
 637.361 -	if (utilCheckBIOS(theApp.biosFileName, 4))
 637.362 -		m_biosOption = 2;
 637.363 -	else
 637.364 -	{
 637.365 -		((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
 637.366 -		if (utilCheckBIOS(theApp.biosFileName, 4))
 637.367 -			m_biosOption = 2;
 637.368 -		else
 637.369 -		{
 637.370 -			systemMessage(0, "This option requires a valid GBA BIOS file.");
 637.371 -			CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_EMUBIOS);
 637.372 -		}
 637.373 -	}
 637.374 -}
 637.375 -
 637.376 -void MovieCreate::OnBnClickedRecGbabiosintro()
 637.377 -{
 637.378 -	if (utilCheckBIOS(theApp.biosFileName, 4))
 637.379 -		m_biosOption = 3;
 637.380 -	else
 637.381 -	{
 637.382 -		((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
 637.383 -		if (utilCheckBIOS(theApp.biosFileName, 4))
 637.384 -			m_biosOption = 3;
 637.385 -		else
 637.386 -		{
 637.387 -			systemMessage(0, "This option requires a valid GBA BIOS file.");
 637.388 -			CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_EMUBIOS);
 637.389 -		}
 637.390 -	}
 637.391 -}
 637.392 -
   638.1 --- a/src/win32/MovieCreate.h	Sat Mar 03 10:54:39 2012 -0600
   638.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   638.3 @@ -1,50 +0,0 @@
   638.4 -#ifndef VBA_MOVIECREATE_H
   638.5 -#define VBA_MOVIECREATE_H
   638.6 -
   638.7 -#if _MSC_VER > 1000
   638.8 -#pragma once
   638.9 -#endif // _MSC_VER > 1000
  638.10 -
  638.11 -// MovieCreate dialog
  638.12 -class MovieCreate : public CDialog
  638.13 -{
  638.14 -	DECLARE_DYNAMIC(MovieCreate)
  638.15 -
  638.16 -public:
  638.17 -	MovieCreate(CWnd* pParent = NULL);   // standard constructor
  638.18 -	virtual ~MovieCreate();
  638.19 -	virtual BOOL OnInitDialog() ;
  638.20 -
  638.21 -// Dialog Data
  638.22 -  //{{AFX_DATA(MovieCreate)
  638.23 -	enum { IDD = IDD_MOVIECREATE };
  638.24 -    int    m_startOption;
  638.25 -    int    m_systemOption;
  638.26 -    int    m_biosOption;
  638.27 -    CEdit  m_editAuthor;
  638.28 -    CEdit  m_editDescription;
  638.29 -    CEdit  m_editFilename;
  638.30 -	//}}AFX_DATA
  638.31 -
  638.32 -protected:
  638.33 -	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  638.34 -
  638.35 -	DECLARE_MESSAGE_MAP()
  638.36 -public:
  638.37 -	afx_msg void OnBnClickedOk();
  638.38 -	afx_msg void OnBnClickedCancel();
  638.39 -	afx_msg void OnBnClickedBrowse();
  638.40 -	afx_msg void OnBnClickedRecstart();
  638.41 -	afx_msg void OnBnClickedRecreset();
  638.42 -	afx_msg void OnBnClickedRecnow();
  638.43 -	afx_msg void OnBnClickedRecGba();
  638.44 -	afx_msg void OnBnClickedRecGbc();
  638.45 -	afx_msg void OnBnClickedRecSgb();
  638.46 -	afx_msg void OnBnClickedRecGb();
  638.47 -	afx_msg void OnBnClickedRecNobios();
  638.48 -	afx_msg void OnBnClickedRecEmubios();
  638.49 -	afx_msg void OnBnClickedRecGbabios();
  638.50 -	afx_msg void OnBnClickedRecGbabiosintro();
  638.51 -};
  638.52 -
  638.53 -#endif // VBA_MOVIECREATE_H
   639.1 --- a/src/win32/MovieOpen.cpp	Sat Mar 03 10:54:39 2012 -0600
   639.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   639.3 @@ -1,532 +0,0 @@
   639.4 -// MovieOpen.cpp : implementation file
   639.5 -//
   639.6 -
   639.7 -#include "stdafx.h"
   639.8 -#include "resource.h"
   639.9 -#include "MovieOpen.h"
  639.10 -#include "MainWnd.h"
  639.11 -#include "FileDlg.h"
  639.12 -#include "WinResUtil.h"
  639.13 -#include "WinMiscUtil.h"
  639.14 -#include "VBA.h"
  639.15 -
  639.16 -#include "../gba/GBA.h"
  639.17 -#include "../gb/gbGlobals.h"
  639.18 -#include "../common/Util.h"
  639.19 -#include "7zip/OpenArchive.h"
  639.20 -
  639.21 -// MovieOpen dialog
  639.22 -
  639.23 -IMPLEMENT_DYNAMIC(MovieOpen, CDialog)
  639.24 -MovieOpen::MovieOpen(CWnd *pParent /*=NULL*/)
  639.25 -	: CDialog(MovieOpen::IDD, pParent)
  639.26 -{}
  639.27 -
  639.28 -MovieOpen::~MovieOpen()
  639.29 -{
  639.30 -	SetArchiveParentHWND(NULL);
  639.31 -}
  639.32 -
  639.33 -BOOL MovieOpen::OnInitDialog()
  639.34 -{
  639.35 -	CDialog::OnInitDialog();
  639.36 -
  639.37 -	pauseFrame = 0;
  639.38 -	ZeroMemory(&movieInfo, sizeof SMovie);
  639.39 -
  639.40 -	SetArchiveParentHWND(GetSafeHwnd());
  639.41 -
  639.42 -	GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(FALSE);
  639.43 -	GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText("");
  639.44 -	GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText("");
  639.45 -	GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
  639.46 -	GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
  639.47 -	GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE);
  639.48 -
  639.49 -	CheckDlgButton(IDC_READONLY, TRUE);
  639.50 -	m_editDescription.SetReadOnly(theApp.movieReadOnly);
  639.51 -
  639.52 -	m_editFilename.LimitText(_MAX_PATH);
  639.53 -	m_editAuthor.LimitText(MOVIE_METADATA_AUTHOR_SIZE);
  639.54 -	m_editDescription.LimitText(MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
  639.55 -	m_editPauseFrame.LimitText(8);
  639.56 -
  639.57 -	// convert the ROM filename into a default movie name
  639.58 -	CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, ".vbm");
  639.59 -
  639.60 -	GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
  639.61 -
  639.62 -	// scroll to show the rightmost side of the movie filename
  639.63 -	((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
  639.64 -
  639.65 -	OnBnClickedMovieRefresh();
  639.66 -
  639.67 -	return TRUE; // return TRUE unless you set the focus to a control
  639.68 -	// EXCEPTION: OCX Property Pages should return FALSE
  639.69 -}
  639.70 -
  639.71 -void MovieOpen::DoDataExchange(CDataExchange *pDX)
  639.72 -{
  639.73 -	CDialog::DoDataExchange(pDX);
  639.74 -	//{{AFX_DATA_MAP(MovieCreate)
  639.75 -	DDX_Control(pDX, IDC_EDIT_AUTHOR, m_editAuthor);
  639.76 -	DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_editDescription);
  639.77 -	DDX_Control(pDX, IDC_MOVIE_FILENAME, m_editFilename);
  639.78 -	DDX_Control(pDX, IDC_EDIT_PAUSEFRAME, m_editPauseFrame);
  639.79 -	//}}AFX_DATA_MAP
  639.80 -}
  639.81 -
  639.82 -BEGIN_MESSAGE_MAP(MovieOpen, CDialog)
  639.83 -ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse)
  639.84 -ON_BN_CLICKED(IDOK, OnBnClickedOk)
  639.85 -ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
  639.86 -ON_BN_CLICKED(IDC_MOVIE_REFRESH, OnBnClickedMovieRefresh)
  639.87 -ON_BN_CLICKED(IDC_READONLY, OnBnClickedReadonly)
  639.88 -ON_BN_CLICKED(IDC_CHECK_PAUSEFRAME, OnBnClickedCheckPauseframe)
  639.89 -ON_BN_CLICKED(IDC_CHECK_HIDEBORDER, OnBnClickedHideborder)
  639.90 -ON_EN_CHANGE(IDC_MOVIE_FILENAME, OnEnChangeMovieFilename)
  639.91 -END_MESSAGE_MAP()
  639.92 -
  639.93 -// MovieOpen message handlers
  639.94 -
  639.95 -// FIXME: file-scope-global
  639.96 -static bool shouldReopenBrowse = false;
  639.97 -
  639.98 -void MovieOpen::OnBnClickedBrowse()
  639.99 -{
 639.100 -	theApp.winCheckFullscreen();    // FIXME: necessary or not?
 639.101 -
 639.102 -	LPCTSTR exts[] = { ".vbm", NULL };
 639.103 -
 639.104 -	CString filter = winResLoadFilter(IDS_FILTER_MOVIE);
 639.105 -	CString title  = winResLoadString(IDS_SELECT_MOVIE_NAME);
 639.106 -
 639.107 -	CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, exts[0]);
 639.108 -	CString movieDir  = winGetDestDir(IDS_MOVIE_DIR);
 639.109 -
 639.110 -	FileDlg dlg(this, movieName, filter, 1, "VBM", exts, movieDir, title, false, true);
 639.111 -
 639.112 -	do
 639.113 -	{
 639.114 -		shouldReopenBrowse = false;
 639.115 -
 639.116 -		if (dlg.DoModal() == IDCANCEL)
 639.117 -		{
 639.118 -			return;
 639.119 -		}
 639.120 -
 639.121 -		movieName = dlg.GetPathName();
 639.122 -
 639.123 -		GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
 639.124 -
 639.125 -		// SetWindowText calls OnEnChangeMovieFilename which calls OnBnClickedMovieRefresh
 639.126 -		// so this extra call to OnBnClickedMovieRefresh is bad
 639.127 -		//OnBnClickedMovieRefresh();
 639.128 -	}
 639.129 -	while (shouldReopenBrowse);
 639.130 -
 639.131 -	// scroll to show the rightmost side of the movie filename
 639.132 -	((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
 639.133 -}
 639.134 -
 639.135 -// some extensions that might commonly be near emulation-related files that we almost certainly can't open, or at least not
 639.136 -// directly.
 639.137 -// also includes definitely non-movie extensions we know about, since we only use this variable in a movie opening function.
 639.138 -// we do this by exclusion instead of inclusion because we don't want to exclude extensions used for any archive files, even
 639.139 -// extensionless or unusually-named archives.
 639.140 -static const char *s_movieIgnoreExtensions [] = {
 639.141 -	"gba", "gbc", "gb",	 "sgb",	 "cgb",	 "bin", "agb", "bios", "mb",   "elf",	"sgm",	"clt",	 "dat",	 "gbs",	 "gcf", "spc",
 639.142 -	"xpc", "pal", "act", "dmp",	 "avi",	 "ini", "txt", "nfo",  "htm",  "html",	"jpg",	"jpeg",	 "png",	 "bmp",	 "gif", "mp3",
 639.143 -	"wav", "lnk", "exe", "bat",	 "sav",	 "luasav"
 639.144 -};
 639.145 -
 639.146 -void MovieOpen::OnBnClickedMovieRefresh()
 639.147 -{
 639.148 -	static int recursionDepth = 0;
 639.149 -	if (recursionDepth > 0)
 639.150 -		return;
 639.151 -	struct Scope {Scope(){ ++ recursionDepth; } ~Scope(){ --recursionDepth; }} scope;
 639.152 -
 639.153 -	CString tempName;
 639.154 -	GetDlgItem(IDC_MOVIE_FILENAME)->GetWindowText(tempName);
 639.155 -
 639.156 -#if 1
 639.157 -	// use ObtainFile to support opening files within archives (.7z, .rar, .zip, .zip.rar.7z, etc.)
 639.158 -
 639.159 -	if (movieLogicalName.GetLength() > 2048) movieLogicalName.Truncate(2048);
 639.160 -
 639.161 -	char LogicalName[2048], PhysicalName[2048];
 639.162 -	if (ObtainFile(tempName, LogicalName, PhysicalName, "mov", s_movieIgnoreExtensions,
 639.163 -	               sizeof(s_movieIgnoreExtensions) / sizeof(*s_movieIgnoreExtensions)))
 639.164 -	{
 639.165 -		if (tempName != LogicalName)
 639.166 -		{
 639.167 -			int selStart = 0, selEnd = 0;
 639.168 -			((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->GetSel(selStart, selEnd);
 639.169 -
 639.170 -			GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(LogicalName);
 639.171 -
 639.172 -			((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel(selStart, selEnd, FALSE);
 639.173 -		}
 639.174 -		moviePhysicalName = PhysicalName;
 639.175 -		movieLogicalName  = LogicalName;
 639.176 -		ReleaseTempFileCategory("mov", PhysicalName);
 639.177 -	}
 639.178 -	else
 639.179 -	{
 639.180 -		shouldReopenBrowse = true;
 639.181 -		return;
 639.182 -	}
 639.183 -#else
 639.184 -	// old version that only supports uncompressed movies
 639.185 -	moviePhysicalName = tempName;
 639.186 -	movieLogicalName  = tempName;
 639.187 -#endif
 639.188 -
 639.189 -	if (VBAMovieGetInfo(moviePhysicalName, &movieInfo) == MOVIE_SUCCESS)
 639.190 -	{
 639.191 -		if (movieInfo.readOnly)
 639.192 -		{
 639.193 -			CheckDlgButton(IDC_READONLY, TRUE);
 639.194 -			m_editDescription.SetReadOnly(TRUE);
 639.195 -		}
 639.196 -
 639.197 -		char buffer[MOVIE_METADATA_SIZE];
 639.198 -
 639.199 -		strncpy(buffer, movieInfo.authorInfo, MOVIE_METADATA_AUTHOR_SIZE);
 639.200 -		buffer[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
 639.201 -		GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(buffer);
 639.202 -
 639.203 -		strncpy(buffer, movieInfo.authorInfo + MOVIE_METADATA_AUTHOR_SIZE, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
 639.204 -		buffer[MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
 639.205 -		GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(buffer);
 639.206 -
 639.207 -		int option = 2;
 639.208 -		if (movieInfo.header.startFlags & MOVIE_START_FROM_SRAM)
 639.209 -			option = 1;
 639.210 -		if (movieInfo.header.startFlags & MOVIE_START_FROM_SNAPSHOT)
 639.211 -			option = 0;
 639.212 -		CheckRadioButton(IDC_RECNOW, IDC_RECSTART, IDC_RECNOW + option);
 639.213 -
 639.214 -		option = 3;
 639.215 -		if (movieInfo.header.typeFlags & MOVIE_TYPE_SGB)
 639.216 -			option = 2;
 639.217 -		if (movieInfo.header.typeFlags & MOVIE_TYPE_GBC)
 639.218 -			option = 1;
 639.219 -		if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
 639.220 -			option = 0;
 639.221 -		CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, IDC_REC_GBA + option);
 639.222 -
 639.223 -		GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(option == 2 ? TRUE : FALSE);
 639.224 -
 639.225 -		if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
 639.226 -		{
 639.227 -			if (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE)
 639.228 -			{
 639.229 -				if (movieInfo.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE)
 639.230 -					option = 2;
 639.231 -				else
 639.232 -					option = 3;
 639.233 -			}
 639.234 -			else
 639.235 -				option = 1;
 639.236 -		}
 639.237 -		else
 639.238 -			option = 0;
 639.239 -
 639.240 -		CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + option);
 639.241 -
 639.242 -		{
 639.243 -			char * p;
 639.244 -			time_t ttime = (time_t)movieInfo.header.uid;
 639.245 -			strncpy(buffer, ctime(&ttime), 127);
 639.246 -			buffer[127] = '\0';
 639.247 -			if ((p = strrchr(buffer, '\n')))
 639.248 -				*p = '\0';
 639.249 -			GetDlgItem(IDC_LABEL_DATE)->SetWindowText(buffer);
 639.250 -
 639.251 -			uint32 div	   = 60;
 639.252 -			uint32 l	   = (movieInfo.header.length_frames + (div >> 1)) / div;
 639.253 -			uint32 seconds = l % 60;
 639.254 -			l /= 60;
 639.255 -			uint32 minutes = l % 60;
 639.256 -			l /= 60;
 639.257 -			uint32 hours = l % 60;
 639.258 -			sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds);
 639.259 -			GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(buffer);
 639.260 -			sprintf(buffer, "%ld", movieInfo.header.length_frames);
 639.261 -			GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(buffer);
 639.262 -			sprintf(buffer, "%ld", movieInfo.header.rerecord_count);
 639.263 -			GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(buffer);
 639.264 -		}
 639.265 -
 639.266 -		{
 639.267 -			char warning1 [1024], warning2 [1024], buffer [1024];
 639.268 -
 639.269 -			strcpy(warning1, "");
 639.270 -			strcpy(warning2, "");
 639.271 -
 639.272 -			char   romTitle [12];
 639.273 -			uint32 romGameCode;
 639.274 -			uint16 checksum;
 639.275 -			uint8  crc;
 639.276 -
 639.277 -			VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
 639.278 -
 639.279 -			// rather than treat these as warnings, might as well always show the info in the dialog (it's probably more
 639.280 -			// informative and reassuring)
 639.281 -///			if (strncmp(movieInfo.header.romTitle,romTitle,12) != 0)
 639.282 -			{
 639.283 -				char str [13];
 639.284 -				strncpy(str, movieInfo.header.romTitle, 12);
 639.285 -				str[12] = '\0';
 639.286 -				sprintf(buffer, "title=%s  ", str);
 639.287 -				strcat(warning1, buffer);
 639.288 -
 639.289 -				strncpy(str, romTitle, 12);
 639.290 -				str[12] = '\0';
 639.291 -				sprintf(buffer, "title=%s  ", str);
 639.292 -				strcat(warning2, buffer);
 639.293 -			}
 639.294 -///			if (((movieInfo.header.typeFlags & MOVIE_TYPE_GBA)!=0) != (systemCartridgeType == 0))
 639.295 -			{
 639.296 -				sprintf(buffer, "type=%s  ",
 639.297 -				        (movieInfo.header.typeFlags & MOVIE_TYPE_GBA) ? "GBA" : (movieInfo.header.typeFlags &
 639.298 -				                                                                 MOVIE_TYPE_GBC) ? "GBC" : (movieInfo.header.
 639.299 -				                                                                                            typeFlags &
 639.300 -				                                                                                            MOVIE_TYPE_SGB) ? "SGB" : "GB");
 639.301 -				strcat(warning1, buffer);
 639.302 -
 639.303 -				sprintf(buffer, "type=%s  ", systemCartridgeType ==
 639.304 -				        0 ? "GBA" : (gbRom[0x143] & 0x80 ? "GBC" : (gbRom[0x146] == 0x03 ? "SGB" : "GB")));
 639.305 -				strcat(warning2, buffer);
 639.306 -			}
 639.307 -///			if (movieInfo.header.romCRC != crc)
 639.308 -			{
 639.309 -				sprintf(buffer, "crc=%02x  ", movieInfo.header.romCRC);
 639.310 -				strcat(warning1, buffer);
 639.311 -
 639.312 -				sprintf(buffer, "crc=%02x  ", crc);
 639.313 -				strcat(warning2, buffer);
 639.314 -			}
 639.315 -///			if (movieInfo.header.romGameCode != romGameCode)
 639.316 -			{
 639.317 -				char code [5];
 639.318 -				if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
 639.319 -				{
 639.320 -					memcpy(code, &movieInfo.header.romGameCode, 4);
 639.321 -					code[4] = '\0';
 639.322 -					sprintf(buffer, "code=%s  ", code);
 639.323 -					strcat(warning1, buffer);
 639.324 -				}
 639.325 -
 639.326 -				if (systemCartridgeType == 0)
 639.327 -				{
 639.328 -					memcpy(code, &romGameCode, 4);
 639.329 -					code[4] = '\0';
 639.330 -					sprintf(buffer, "code=%s  ", code);
 639.331 -					strcat(warning2, buffer);
 639.332 -				}
 639.333 -			}
 639.334 -///			if (movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags &
 639.335 -// MOVIE_SETTING_USEBIOSFILE)==0
 639.336 -// && checksum==0))
 639.337 -			{
 639.338 -				sprintf(buffer,
 639.339 -				        movieInfo.header.typeFlags &
 639.340 -				        MOVIE_TYPE_GBA ? ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) ==
 639.341 -				                          0 ? "(bios=none)  " : "(bios=%04x)  ") : "check=%04x  ",
 639.342 -				        movieInfo.header.romOrBiosChecksum);
 639.343 -				strcat(warning1, buffer);
 639.344 -
 639.345 -				sprintf(buffer,
 639.346 -				        checksum == 0 ? "(bios=none)  " : systemCartridgeType == 0 ? "(bios=%04x)  " : "check=%04x  ",
 639.347 -				        checksum);
 639.348 -				strcat(warning2, buffer);
 639.349 -			}
 639.350 -
 639.351 -			if (strlen(warning1) > 0)
 639.352 -			{
 639.353 -				sprintf(buffer, "Movie ROM: %s", warning1);
 639.354 -				GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(buffer);
 639.355 -
 639.356 -				sprintf(buffer, "Your ROM: %s", warning2);
 639.357 -
 639.358 -				//if(movieInfo.header.romCRC != crc
 639.359 -				//|| strncmp(movieInfo.header.romTitle,romTitle,12) != 0
 639.360 -				//|| movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags &
 639.361 -				// MOVIE_SETTING_USEBIOSFILE)==0 && checksum==0))
 639.362 -				//	strcat(buffer, "<-- MISMATCH");
 639.363 -
 639.364 -				GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(buffer);
 639.365 -			}
 639.366 -			else
 639.367 -			{
 639.368 -				GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText("(No problems detected)");
 639.369 -				GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" ");
 639.370 -			}
 639.371 -		}
 639.372 -		GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(TRUE);
 639.373 -	}
 639.374 -	else
 639.375 -	{
 639.376 -		GetDlgItem(IDC_LABEL_DATE)->SetWindowText(" ");
 639.377 -		GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(" ");
 639.378 -		GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(" ");
 639.379 -		GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(" ");
 639.380 -		GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(" ");
 639.381 -		GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(" ");
 639.382 -		GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(" ");
 639.383 -		GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" ");
 639.384 -
 639.385 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
 639.386 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
 639.387 -		GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE);
 639.388 -		CheckDlgButton(IDC_CHECK_PAUSEFRAME, FALSE);
 639.389 -/*
 639.390 -        /// FIXME: how to un-check all the radio buttons?
 639.391 -        CheckRadioButton(IDC_RECNOW, IDC_RECSTART, -1);
 639.392 -        CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, -1);
 639.393 -        CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, -1);*/
 639.394 -	}
 639.395 -}
 639.396 -
 639.397 -BOOL MovieOpen::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *res)
 639.398 -{
 639.399 -	switch (msg)
 639.400 -	{
 639.401 -	case WM_CTLCOLORSTATIC:
 639.402 -	{
 639.403 -		//HWND hwndDlg = GetSafeHwnd();
 639.404 -		HWND warnDlg = NULL;
 639.405 -		GetDlgItem(IDC_LABEL_WARNING2, &warnDlg);
 639.406 -
 639.407 -		if ((HWND)lParam == warnDlg)
 639.408 -		{
 639.409 -			char   romTitle [12];
 639.410 -			uint32 romGameCode;
 639.411 -			uint16 checksum;
 639.412 -			uint8  crc;
 639.413 -
 639.414 -			VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
 639.415 -
 639.416 -			if (movieInfo.header.romCRC != crc
 639.417 -			    || strncmp(movieInfo.header.romTitle, romTitle, 12) != 0
 639.418 -			    || movieInfo.header.romOrBiosChecksum != checksum
 639.419 -			    && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) == 0 && checksum == 0))
 639.420 -			{
 639.421 -				// draw the md5 sum in red if it's different from the md5 of the rom used in the replay
 639.422 -				HDC hdcStatic = (HDC)wParam;
 639.423 -				SetTextColor(hdcStatic, RGB(255, 0, 0));      // use red for a mismatch
 639.424 -
 639.425 -				// I'm not sure why this doesn't work to make the background transparent... it turns white anyway
 639.426 -				SetBkMode(hdcStatic, TRANSPARENT);
 639.427 -				return (LONG)GetStockObject(NULL_BRUSH);
 639.428 -			}
 639.429 -		}
 639.430 -		return FALSE;
 639.431 -	}
 639.432 -	}
 639.433 -	return CDialog::OnWndMsg(msg, wParam, lParam, res);
 639.434 -}
 639.435 -
 639.436 -void MovieOpen::OnBnClickedOk()
 639.437 -{
 639.438 -	bool useBIOSFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
 639.439 -	if (useBIOSFile)
 639.440 -	{
 639.441 -		extern bool systemLoadBIOS(const char *biosFileName, bool useBiosFile);
 639.442 -		if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
 639.443 -		{
 639.444 -			systemMessage(0, "This movie requires a valid GBA BIOS file to play.\nPlease locate a BIOS file.");
 639.445 -			((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
 639.446 -			if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
 639.447 -			{
 639.448 -				systemMessage(0, "\"%s\" is not a valid BIOS file; cannot play movie without one.", theApp.biosFileName);
 639.449 -				return;
 639.450 -			}
 639.451 -		}
 639.452 -	}
 639.453 -
 639.454 -	int code = VBAMovieOpen(moviePhysicalName, IsDlgButtonChecked(IDC_READONLY) != FALSE);
 639.455 -
 639.456 -	if (code != MOVIE_SUCCESS)
 639.457 -	{
 639.458 -		if (code == MOVIE_FILE_NOT_FOUND)
 639.459 -			systemMessage(0, "Could not find movie file \"%s\".", (const char *)movieLogicalName);
 639.460 -		else if (code == MOVIE_WRONG_FORMAT)
 639.461 -			systemMessage(0, "Movie file \"%s\" is not in proper VBM format.", (const char *)movieLogicalName);
 639.462 -		else if (code == MOVIE_WRONG_VERSION)
 639.463 -			systemMessage(0, "Movie file \"%s\" is not a supported version.", (const char *)movieLogicalName);
 639.464 -		else
 639.465 -			systemMessage(0, "Failed to open movie \"%s\".", (const char *)movieLogicalName);
 639.466 -		return;
 639.467 -	}
 639.468 -	else
 639.469 -	{
 639.470 -		// get author and movie info from the edit fields (the description might change):
 639.471 -		char info[MOVIE_METADATA_SIZE], buffer[MOVIE_METADATA_SIZE];
 639.472 -
 639.473 -		GetDlgItem(IDC_EDIT_AUTHOR)->GetWindowText(buffer, MOVIE_METADATA_AUTHOR_SIZE);
 639.474 -		strncpy(info, buffer, MOVIE_METADATA_AUTHOR_SIZE);
 639.475 -		info[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
 639.476 -
 639.477 -		GetDlgItem(IDC_EDIT_DESCRIPTION)->GetWindowText(buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
 639.478 -		strncpy(info + MOVIE_METADATA_AUTHOR_SIZE, buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
 639.479 -		info[MOVIE_METADATA_SIZE - 1] = '\0';
 639.480 -
 639.481 -		VBAMovieSetMetadata(info);
 639.482 -	}
 639.483 -
 639.484 -	if (IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME))
 639.485 -	{
 639.486 -		char buffer [9];
 639.487 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->GetWindowText(buffer, 8);
 639.488 -		buffer[8] = '\0';
 639.489 -
 639.490 -		int pauseFrame = atoi(buffer);
 639.491 -		if (pauseFrame >= 0)
 639.492 -			VBAMovieSetPauseAt(pauseFrame);
 639.493 -	}
 639.494 -
 639.495 -	OnOK();
 639.496 -}
 639.497 -
 639.498 -void MovieOpen::OnBnClickedCancel()
 639.499 -{
 639.500 -	OnCancel();
 639.501 -}
 639.502 -
 639.503 -void MovieOpen::OnBnClickedReadonly()
 639.504 -{
 639.505 -	theApp.movieReadOnly = IsDlgButtonChecked(IDC_READONLY) != 0;
 639.506 -	m_editDescription.SetReadOnly(theApp.movieReadOnly);
 639.507 -	OnBnClickedMovieRefresh();
 639.508 -}
 639.509 -
 639.510 -void MovieOpen::OnBnClickedCheckPauseframe()
 639.511 -{
 639.512 -	if (IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME))
 639.513 -	{
 639.514 -		char buffer [8];
 639.515 -		_itoa(movieInfo.header.length_frames, buffer, 10);
 639.516 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(buffer);
 639.517 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(TRUE);
 639.518 -	}
 639.519 -	else
 639.520 -	{
 639.521 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
 639.522 -		GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
 639.523 -	}
 639.524 -}
 639.525 -
 639.526 -void MovieOpen::OnBnClickedHideborder()
 639.527 -{
 639.528 -	theApp.hideMovieBorder = IsDlgButtonChecked(IDC_CHECK_HIDEBORDER) != 0;
 639.529 -}
 639.530 -
 639.531 -void MovieOpen::OnEnChangeMovieFilename()
 639.532 -{
 639.533 -	OnBnClickedMovieRefresh();
 639.534 -}
 639.535 -
   640.1 --- a/src/win32/MovieOpen.h	Sat Mar 03 10:54:39 2012 -0600
   640.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   640.3 @@ -1,58 +0,0 @@
   640.4 -#ifndef VBA_MOVIE_OPEN_H
   640.5 -#define VBA_MOVIE_OPEN_H
   640.6 -
   640.7 -#if _MSC_VER > 1000
   640.8 -#pragma once
   640.9 -#endif // _MSC_VER > 1000
  640.10 -
  640.11 -#include "../common/movie.h"
  640.12 -
  640.13 -// MovieOpen dialog
  640.14 -
  640.15 -class MovieOpen : public CDialog
  640.16 -{
  640.17 -	DECLARE_DYNAMIC(MovieOpen)
  640.18 -public:
  640.19 -	MovieOpen(CWnd*pParent = NULL);    // standard constructor
  640.20 -	virtual ~MovieOpen();
  640.21 -
  640.22 -// Dialog Data
  640.23 -	//{{AFX_DATA(MovieOpen)
  640.24 -	enum { IDD = IDD_MOVIEOPEN };
  640.25 -	CEdit   m_editAuthor;
  640.26 -	CEdit   m_editDescription;
  640.27 -	CEdit   m_editFilename;
  640.28 -	CEdit   m_editPauseFrame;
  640.29 -	CString moviePhysicalName;
  640.30 -	CString movieLogicalName;
  640.31 -	//}}AFX_DATA
  640.32 -
  640.33 -	// Overrides
  640.34 -	// ClassWizard generated virtual function overrides
  640.35 -	//{{AFX_VIRTUAL(GBACheatList)
  640.36 -protected:
  640.37 -	virtual void DoDataExchange(CDataExchange*pDX);     // DDX/DDV support
  640.38 -	//}}AFX_VIRTUAL
  640.39 -
  640.40 -	// Implementation
  640.41 -protected:
  640.42 -	SMovie  movieInfo;
  640.43 -	int     pauseFrame;
  640.44 -
  640.45 -	// Generated message map functions
  640.46 -	//{{AFX_MSG(GBACheatList)
  640.47 -	afx_msg void OnBnClickedBrowse();
  640.48 -	afx_msg void OnBnClickedOk();
  640.49 -	afx_msg void OnBnClickedCancel();
  640.50 -	afx_msg void OnBnClickedMovieRefresh();
  640.51 -	afx_msg void OnBnClickedReadonly();
  640.52 -	afx_msg void OnBnClickedCheckPauseframe();
  640.53 -	afx_msg void OnBnClickedHideborder();
  640.54 -	afx_msg void OnEnChangeMovieFilename();
  640.55 -	virtual BOOL OnInitDialog() ;
  640.56 -	virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *);
  640.57 -	//}}AFX_MSG
  640.58 -	DECLARE_MESSAGE_MAP()
  640.59 -};
  640.60 -
  640.61 -#endif // VBA_MOVIE_OPEN_H
   641.1 --- a/src/win32/OamView.cpp	Sat Mar 03 10:54:39 2012 -0600
   641.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   641.3 @@ -1,668 +0,0 @@
   641.4 -// OamView.cpp : implementation file
   641.5 -//
   641.6 -
   641.7 -#include "stdafx.h"
   641.8 -#include "resource.h"
   641.9 -#include "OamView.h"
  641.10 -#include "FileDlg.h"
  641.11 -#include "Reg.h"
  641.12 -#include "WinResUtil.h"
  641.13 -#include "VBA.h"
  641.14 -
  641.15 -#include "../gba/GBAGlobals.h"
  641.16 -#include "../NLS.h"
  641.17 -#include "../common/Util.h"
  641.18 -
  641.19 -extern "C" {
  641.20 -#include <png.h>
  641.21 -}
  641.22 -
  641.23 -/////////////////////////////////////////////////////////////////////////////
  641.24 -// OamView dialog
  641.25 -
  641.26 -OamView::OamView(CWnd*pParent /*=NULL*/)
  641.27 -	: ResizeDlg(OamView::IDD, pParent)
  641.28 -{
  641.29 -	//{{AFX_DATA_INIT(OamView)
  641.30 -	m_stretch = FALSE;
  641.31 -	//}}AFX_DATA_INIT
  641.32 -	autoUpdate = false;
  641.33 -
  641.34 -	memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
  641.35 -
  641.36 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  641.37 -	bmpInfo.bmiHeader.biWidth       = 32;
  641.38 -	bmpInfo.bmiHeader.biHeight      = 32;
  641.39 -	bmpInfo.bmiHeader.biPlanes      = 1;
  641.40 -	bmpInfo.bmiHeader.biBitCount    = 24;
  641.41 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  641.42 -	data = (u8 *)calloc(1, 3 * 64 * 64);
  641.43 -
  641.44 -	oamView.setData(data);
  641.45 -	oamView.setBmpInfo(&bmpInfo);
  641.46 -
  641.47 -	number = 0;
  641.48 -}
  641.49 -
  641.50 -void OamView::DoDataExchange(CDataExchange*pDX)
  641.51 -{
  641.52 -	CDialog::DoDataExchange(pDX);
  641.53 -	//{{AFX_DATA_MAP(OamView)
  641.54 -	DDX_Control(pDX, IDC_SPRITE, m_sprite);
  641.55 -	DDX_Check(pDX, IDC_STRETCH, m_stretch);
  641.56 -	//}}AFX_DATA_MAP
  641.57 -	DDX_Control(pDX, IDC_COLOR, color);
  641.58 -	DDX_Control(pDX, IDC_OAM_VIEW, oamView);
  641.59 -	DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom);
  641.60 -}
  641.61 -
  641.62 -BEGIN_MESSAGE_MAP(OamView, CDialog)
  641.63 -//{{AFX_MSG_MAP(OamView)
  641.64 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  641.65 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  641.66 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  641.67 -ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite)
  641.68 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  641.69 -ON_WM_HSCROLL()
  641.70 -//}}AFX_MSG_MAP
  641.71 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  641.72 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  641.73 -END_MESSAGE_MAP()
  641.74 -
  641.75 -/////////////////////////////////////////////////////////////////////////////
  641.76 -// OamView message handlers
  641.77 -
  641.78 -OamView::~OamView()
  641.79 -{
  641.80 -	free(data);
  641.81 -	data = NULL;
  641.82 -}
  641.83 -
  641.84 -void OamView::paint()
  641.85 -{
  641.86 -	if (oam == NULL || paletteRAM == NULL || vram == NULL)
  641.87 -		return;
  641.88 -
  641.89 -	render();
  641.90 -	oamView.setSize(w, h);
  641.91 -	oamView.refresh();
  641.92 -}
  641.93 -
  641.94 -void OamView::update()
  641.95 -{
  641.96 -	paint();
  641.97 -}
  641.98 -
  641.99 -void OamView::setAttributes(u16 a0, u16 a1, u16 a2)
 641.100 -{
 641.101 -	CString buffer;
 641.102 -
 641.103 -	int y        = a0 & 255;
 641.104 -	int rot      = a0 & 512;
 641.105 -	int mode     = (a0 >> 10) & 3;
 641.106 -	int mosaic   = a0 & 4096;
 641.107 -	int color    = a0 & 8192;
 641.108 -	int duple    = a0 & 1024;
 641.109 -	int shape    = (a0 >> 14) & 3;
 641.110 -	int x        = a1 & 511;
 641.111 -	int rotParam = (a1 >> 9) & 31;
 641.112 -	int flipH    = a1 & 4096;
 641.113 -	int flipV    = a1 & 8192;
 641.114 -	int size     = (a1 >> 14) & 3;
 641.115 -	int tile     = a2 & 1023;
 641.116 -	int prio     = (a2 >> 10) & 3;
 641.117 -	int pal      = (a2 >> 12) & 15;
 641.118 -
 641.119 -	buffer.Format("%d,%d", x, y);
 641.120 -	GetDlgItem(IDC_POS)->SetWindowText(buffer);
 641.121 -
 641.122 -	buffer.Format("%d", mode);
 641.123 -	GetDlgItem(IDC_MODE)->SetWindowText(buffer);
 641.124 -
 641.125 -	GetDlgItem(IDC_COLORS)->SetWindowText(color ? "256" : "16");
 641.126 -
 641.127 -	buffer.Format("%d", pal);
 641.128 -	GetDlgItem(IDC_PALETTE)->SetWindowText(buffer);
 641.129 -
 641.130 -	buffer.Format("%d", tile);
 641.131 -	GetDlgItem(IDC_TILE)->SetWindowText(buffer);
 641.132 -
 641.133 -	buffer.Format("%d", prio);
 641.134 -	GetDlgItem(IDC_PRIO)->SetWindowText(buffer);
 641.135 -
 641.136 -	buffer.Format("%d,%d", w, h);
 641.137 -	GetDlgItem(IDC_SIZE2)->SetWindowText(buffer);
 641.138 -
 641.139 -	if (rot)
 641.140 -	{
 641.141 -		buffer.Format("%d", rotParam);
 641.142 -	}
 641.143 -	else
 641.144 -		buffer.Empty();
 641.145 -	GetDlgItem(IDC_ROT)->SetWindowText(buffer);
 641.146 -
 641.147 -	buffer.Empty();
 641.148 -
 641.149 -	if (rot)
 641.150 -		buffer += 'R';
 641.151 -	else
 641.152 -		buffer += ' ';
 641.153 -	if (!rot)
 641.154 -	{
 641.155 -		if (flipH)
 641.156 -			buffer += 'H';
 641.157 -		else
 641.158 -			buffer += ' ';
 641.159 -		if (flipV)
 641.160 -			buffer += 'V';
 641.161 -		else
 641.162 -			buffer += ' ';
 641.163 -	}
 641.164 -	else
 641.165 -	{
 641.166 -		buffer += ' ';
 641.167 -		buffer += ' ';
 641.168 -	}
 641.169 -	if (mosaic)
 641.170 -		buffer += 'M';
 641.171 -	else
 641.172 -		buffer += ' ';
 641.173 -	if (duple)
 641.174 -		buffer += 'D';
 641.175 -	else
 641.176 -		buffer += ' ';
 641.177 -
 641.178 -	GetDlgItem(IDC_FLAGS)->SetWindowText(buffer);
 641.179 -}
 641.180 -
 641.181 -void OamView::render()
 641.182 -{
 641.183 -	int m = 0;
 641.184 -	if (oam == NULL || paletteRAM == NULL || vram == NULL)
 641.185 -		return;
 641.186 -
 641.187 -	u16 *sprites       = &((u16 *)oam)[4*number];
 641.188 -	u16 *spritePalette = &((u16 *)paletteRAM)[0x100];
 641.189 -	u8 * bmp = data;
 641.190 -
 641.191 -	u16 a0 = *sprites++;
 641.192 -	u16 a1 = *sprites++;
 641.193 -	u16 a2 = *sprites++;
 641.194 -
 641.195 -	int sizeY = 8;
 641.196 -	int sizeX = 8;
 641.197 -
 641.198 -	switch (((a0 >>12) & 0x0c)|(a1>>14))
 641.199 -	{
 641.200 -	case 0:
 641.201 -		break;
 641.202 -	case 1:
 641.203 -		sizeX = sizeY = 16;
 641.204 -		break;
 641.205 -	case 2:
 641.206 -		sizeX = sizeY = 32;
 641.207 -		break;
 641.208 -	case 3:
 641.209 -		sizeX = sizeY = 64;
 641.210 -		break;
 641.211 -	case 4:
 641.212 -		sizeX = 16;
 641.213 -		break;
 641.214 -	case 5:
 641.215 -		sizeX = 32;
 641.216 -		break;
 641.217 -	case 6:
 641.218 -		sizeX = 32;
 641.219 -		sizeY = 16;
 641.220 -		break;
 641.221 -	case 7:
 641.222 -		sizeX = 64;
 641.223 -		sizeY = 32;
 641.224 -		break;
 641.225 -	case 8:
 641.226 -		sizeY = 16;
 641.227 -		break;
 641.228 -	case 9:
 641.229 -		sizeY = 32;
 641.230 -		break;
 641.231 -	case 10:
 641.232 -		sizeX = 16;
 641.233 -		sizeY = 32;
 641.234 -		break;
 641.235 -	case 11:
 641.236 -		sizeX = 32;
 641.237 -		sizeY = 64;
 641.238 -		break;
 641.239 -	default:
 641.240 -		return;
 641.241 -	}
 641.242 -
 641.243 -	w = sizeX;
 641.244 -	h = sizeY;
 641.245 -
 641.246 -	setAttributes(a0, a1, a2);
 641.247 -
 641.248 -	int sy = (a0 & 255);
 641.249 -
 641.250 -	if (a0 & 0x2000)
 641.251 -	{
 641.252 -		int c = (a2 & 0x3FF);
 641.253 -		//          if((DISPCNT & 7) > 2 && (c < 512))
 641.254 -		//            return;
 641.255 -		int inc = 32;
 641.256 -		if (DISPCNT & 0x40)
 641.257 -			inc = sizeX >> 2;
 641.258 -		else
 641.259 -			c &= 0x3FE;
 641.260 -
 641.261 -		for (int y = 0; y < sizeY; y++)
 641.262 -		{
 641.263 -			for (int x = 0; x < sizeX; x++)
 641.264 -			{
 641.265 -				u32 color = vram[0x10000 + (((c + (y>>3) * inc)*
 641.266 -				                             32 + (y & 7) * 8 + (x >> 3) * 64 +
 641.267 -				                             (x & 7))&0x7FFF)];
 641.268 -				color  = spritePalette[color];
 641.269 -				*bmp++ = ((color >> 10) & 0x1f) << 3;
 641.270 -				*bmp++ = ((color >> 5) & 0x1f) << 3;
 641.271 -				*bmp++ = (color & 0x1f) << 3;
 641.272 -			}
 641.273 -		}
 641.274 -	}
 641.275 -	else
 641.276 -	{
 641.277 -		int c = (a2 & 0x3FF);
 641.278 -		//      if((DISPCNT & 7) > 2 && (c < 512))
 641.279 -		//          continue;
 641.280 -
 641.281 -		int inc = 32;
 641.282 -		if (DISPCNT & 0x40)
 641.283 -			inc = sizeX >> 3;
 641.284 -		int palette = (a2 >> 8) & 0xF0;
 641.285 -		for (int y = 0; y < sizeY; y++)
 641.286 -		{
 641.287 -			for (int x = 0; x < sizeX; x++)
 641.288 -			{
 641.289 -				u32 color = vram[0x10000 + (((c + (y>>3) * inc)*
 641.290 -				                             32 + (y & 7) * 4 + (x >> 3) * 32 +
 641.291 -				                             ((x & 7)>>1))&0x7FFF)];
 641.292 -				if (x & 1)
 641.293 -					color >>= 4;
 641.294 -				else
 641.295 -					color &= 0x0F;
 641.296 -
 641.297 -				color  = spritePalette[palette+color];
 641.298 -				*bmp++ = ((color >> 10) & 0x1f) << 3;
 641.299 -				*bmp++ = ((color >> 5) & 0x1f) << 3;
 641.300 -				*bmp++ = (color & 0x1f) << 3;
 641.301 -			}
 641.302 -		}
 641.303 -	}
 641.304 -}
 641.305 -
 641.306 -void OamView::saveBMP(const char *name)
 641.307 -{
 641.308 -	u8 writeBuffer[1024 * 3];
 641.309 -
 641.310 -	FILE *fp = fopen(name, "wb");
 641.311 -
 641.312 -	if (!fp)
 641.313 -	{
 641.314 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 641.315 -		return;
 641.316 -	}
 641.317 -
 641.318 -	struct
 641.319 -	{
 641.320 -		u8 ident[2];
 641.321 -		u8 filesize[4];
 641.322 -		u8 reserved[4];
 641.323 -		u8 dataoffset[4];
 641.324 -		u8 headersize[4];
 641.325 -		u8 width[4];
 641.326 -		u8 height[4];
 641.327 -		u8 planes[2];
 641.328 -		u8 bitsperpixel[2];
 641.329 -		u8 compression[4];
 641.330 -		u8 datasize[4];
 641.331 -		u8 hres[4];
 641.332 -		u8 vres[4];
 641.333 -		u8 colors[4];
 641.334 -		u8 importantcolors[4];
 641.335 -		u8 pad[2];
 641.336 -	} bmpheader;
 641.337 -	memset(&bmpheader, 0, sizeof(bmpheader));
 641.338 -
 641.339 -	bmpheader.ident[0] = 'B';
 641.340 -	bmpheader.ident[1] = 'M';
 641.341 -
 641.342 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 641.343 -	utilPutDword(bmpheader.filesize, fsz);
 641.344 -	utilPutDword(bmpheader.dataoffset, 0x38);
 641.345 -	utilPutDword(bmpheader.headersize, 0x28);
 641.346 -	utilPutDword(bmpheader.width, w);
 641.347 -	utilPutDword(bmpheader.height, h);
 641.348 -	utilPutDword(bmpheader.planes, 1);
 641.349 -	utilPutDword(bmpheader.bitsperpixel, 24);
 641.350 -	utilPutDword(bmpheader.datasize, 3*w*h);
 641.351 -
 641.352 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 641.353 -
 641.354 -	u8 *b = writeBuffer;
 641.355 -
 641.356 -	int sizeX = w;
 641.357 -	int sizeY = h;
 641.358 -
 641.359 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 641.360 -	for (int y = 0; y < sizeY; y++)
 641.361 -	{
 641.362 -		for (int x = 0; x < sizeX; x++)
 641.363 -		{
 641.364 -			*b++ = *pixU8++; // B
 641.365 -			*b++ = *pixU8++; // G
 641.366 -			*b++ = *pixU8++; // R
 641.367 -		}
 641.368 -		pixU8 -= 2*3*w;
 641.369 -		fwrite(writeBuffer, 1, 3*w, fp);
 641.370 -
 641.371 -		b = writeBuffer;
 641.372 -	}
 641.373 -
 641.374 -	fclose(fp);
 641.375 -}
 641.376 -
 641.377 -void OamView::savePNG(const char *name)
 641.378 -{
 641.379 -	u8 writeBuffer[1024 * 3];
 641.380 -
 641.381 -	FILE *fp = fopen(name, "wb");
 641.382 -
 641.383 -	if (!fp)
 641.384 -	{
 641.385 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 641.386 -		return;
 641.387 -	}
 641.388 -
 641.389 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 641.390 -	                                              NULL,
 641.391 -	                                              NULL,
 641.392 -	                                              NULL);
 641.393 -	if (!png_ptr)
 641.394 -	{
 641.395 -		fclose(fp);
 641.396 -		return;
 641.397 -	}
 641.398 -
 641.399 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 641.400 -
 641.401 -	if (!info_ptr)
 641.402 -	{
 641.403 -		png_destroy_write_struct(&png_ptr, NULL);
 641.404 -		fclose(fp);
 641.405 -		return;
 641.406 -	}
 641.407 -
 641.408 -	if (setjmp(png_ptr->jmpbuf))
 641.409 -	{
 641.410 -		png_destroy_write_struct(&png_ptr, NULL);
 641.411 -		fclose(fp);
 641.412 -		return;
 641.413 -	}
 641.414 -
 641.415 -	png_init_io(png_ptr, fp);
 641.416 -
 641.417 -	png_set_IHDR(png_ptr,
 641.418 -	             info_ptr,
 641.419 -	             w,
 641.420 -	             h,
 641.421 -	             8,
 641.422 -	             PNG_COLOR_TYPE_RGB,
 641.423 -	             PNG_INTERLACE_NONE,
 641.424 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 641.425 -	             PNG_FILTER_TYPE_DEFAULT);
 641.426 -
 641.427 -	png_write_info(png_ptr, info_ptr);
 641.428 -
 641.429 -	u8 *b = writeBuffer;
 641.430 -
 641.431 -	int sizeX = w;
 641.432 -	int sizeY = h;
 641.433 -
 641.434 -	u8 *pixU8 = (u8 *)data;
 641.435 -	for (int y = 0; y < sizeY; y++)
 641.436 -	{
 641.437 -		for (int x = 0; x < sizeX; x++)
 641.438 -		{
 641.439 -			int blue  = *pixU8++;
 641.440 -			int green = *pixU8++;
 641.441 -			int red   = *pixU8++;
 641.442 -
 641.443 -			*b++ = red;
 641.444 -			*b++ = green;
 641.445 -			*b++ = blue;
 641.446 -		}
 641.447 -		png_write_row(png_ptr, writeBuffer);
 641.448 -
 641.449 -		b = writeBuffer;
 641.450 -	}
 641.451 -
 641.452 -	png_write_end(png_ptr, info_ptr);
 641.453 -
 641.454 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 641.455 -
 641.456 -	fclose(fp);
 641.457 -}
 641.458 -
 641.459 -void OamView::OnSave()
 641.460 -{
 641.461 -	CString captureBuffer;
 641.462 -
 641.463 -	if (theApp.captureFormat == 0)
 641.464 -		captureBuffer = "oam.png";
 641.465 -	else
 641.466 -		captureBuffer = "oam.bmp";
 641.467 -
 641.468 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 641.469 -
 641.470 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 641.471 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 641.472 -
 641.473 -	FileDlg dlg(this,
 641.474 -	            captureBuffer,
 641.475 -	            filter,
 641.476 -	            theApp.captureFormat ? 2 : 1,
 641.477 -	            theApp.captureFormat ? "BMP" : "PNG",
 641.478 -	            exts,
 641.479 -	            "",
 641.480 -	            title,
 641.481 -	            true);
 641.482 -
 641.483 -	if (dlg.DoModal() == IDCANCEL)
 641.484 -	{
 641.485 -		return;
 641.486 -	}
 641.487 -	captureBuffer = dlg.GetPathName();
 641.488 -
 641.489 -	if (dlg.getFilterIndex() == 2)
 641.490 -		saveBMP(captureBuffer);
 641.491 -	else
 641.492 -		savePNG(captureBuffer);
 641.493 -}
 641.494 -
 641.495 -BOOL OamView::OnInitDialog()
 641.496 -{
 641.497 -	CDialog::OnInitDialog();
 641.498 -
 641.499 -	DIALOG_SIZER_START(sz)
 641.500 -	DIALOG_SIZER_ENTRY(IDC_OAM_VIEW, DS_SizeX | DS_SizeY)
 641.501 -	DIALOG_SIZER_ENTRY(IDC_OAM_VIEW_ZOOM, DS_MoveX)
 641.502 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 641.503 -	DIALOG_SIZER_ENTRY(IDC_SAVE,  DS_MoveY)
 641.504 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 641.505 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 641.506 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 641.507 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 641.508 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 641.509 -	DIALOG_SIZER_END()
 641.510 -	SetData(sz,
 641.511 -	        TRUE,
 641.512 -	        HKEY_CURRENT_USER,
 641.513 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\OamView",
 641.514 -	        NULL);
 641.515 -
 641.516 -	m_sprite.SetWindowText("0");
 641.517 -
 641.518 -	updateScrollInfo();
 641.519 -
 641.520 -	m_stretch = regQueryDwordValue("oamViewStretch", 0);
 641.521 -	if (m_stretch)
 641.522 -		oamView.setStretch(true);
 641.523 -	UpdateData(FALSE);
 641.524 -
 641.525 -	paint();
 641.526 -
 641.527 -	return TRUE; // return TRUE unless you set the focus to a control
 641.528 -	             // EXCEPTION: OCX Property Pages should return FALSE
 641.529 -}
 641.530 -
 641.531 -void OamView::OnStretch()
 641.532 -{
 641.533 -	oamView.setStretch(!oamView.getStretch());
 641.534 -	paint();
 641.535 -	regSetDwordValue("oamViewStretch", oamView.getStretch());
 641.536 -}
 641.537 -
 641.538 -void OamView::OnAutoUpdate()
 641.539 -{
 641.540 -	autoUpdate = !autoUpdate;
 641.541 -	if (autoUpdate)
 641.542 -	{
 641.543 -		theApp.winAddUpdateListener(this);
 641.544 -	}
 641.545 -	else
 641.546 -	{
 641.547 -		theApp.winRemoveUpdateListener(this);
 641.548 -	}
 641.549 -}
 641.550 -
 641.551 -void OamView::OnChangeSprite()
 641.552 -{
 641.553 -	CString buffer;
 641.554 -	m_sprite.GetWindowText(buffer);
 641.555 -	int n = atoi(buffer);
 641.556 -	if (n < 0 || n > 127)
 641.557 -	{
 641.558 -		buffer.Format("%d", number);
 641.559 -		m_sprite.SetWindowText(buffer);
 641.560 -		return;
 641.561 -	}
 641.562 -	number = n;
 641.563 -	paint();
 641.564 -	updateScrollInfo();
 641.565 -}
 641.566 -
 641.567 -void OamView::OnClose()
 641.568 -{
 641.569 -	theApp.winRemoveUpdateListener(this);
 641.570 -
 641.571 -	DestroyWindow();
 641.572 -}
 641.573 -
 641.574 -LRESULT OamView::OnMapInfo(WPARAM wParam, LPARAM lParam)
 641.575 -{
 641.576 -	u8 *colors = (u8 *)lParam;
 641.577 -	oamZoom.setColors(colors);
 641.578 -
 641.579 -	return TRUE;
 641.580 -}
 641.581 -
 641.582 -LRESULT OamView::OnColInfo(WPARAM wParam, LPARAM lParam)
 641.583 -{
 641.584 -	u16 c = (u16)wParam;
 641.585 -
 641.586 -	color.setColor(c);
 641.587 -
 641.588 -	int r = (c & 0x1f);
 641.589 -	int g = (c & 0x3e0) >> 5;
 641.590 -	int b = (c & 0x7c00) >> 10;
 641.591 -
 641.592 -	CString buffer;
 641.593 -	buffer.Format("R: %d", r);
 641.594 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 641.595 -
 641.596 -	buffer.Format("G: %d", g);
 641.597 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 641.598 -
 641.599 -	buffer.Format("B: %d", b);
 641.600 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 641.601 -
 641.602 -	return TRUE;
 641.603 -}
 641.604 -
 641.605 -void OamView::updateScrollInfo()
 641.606 -{
 641.607 -	SCROLLINFO si;
 641.608 -	ZeroMemory(&si, sizeof(si));
 641.609 -	si.cbSize = sizeof(si);
 641.610 -	si.fMask  = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS;
 641.611 -	si.nMin   = 0;
 641.612 -	si.nMax   = 127;
 641.613 -	si.nPage  = 1;
 641.614 -	si.nPos   = number;
 641.615 -	GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL,
 641.616 -	                                         &si,
 641.617 -	                                         TRUE);
 641.618 -}
 641.619 -
 641.620 -void OamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 641.621 -{
 641.622 -	switch (nSBCode)
 641.623 -	{
 641.624 -	case SB_BOTTOM:
 641.625 -		number = 127;
 641.626 -		break;
 641.627 -	case SB_LINEDOWN:
 641.628 -		number++;
 641.629 -		if (number > 127)
 641.630 -			number = 127;
 641.631 -		break;
 641.632 -	case SB_LINEUP:
 641.633 -		number--;
 641.634 -		if (number < 0)
 641.635 -			number = 0;
 641.636 -		break;
 641.637 -	case SB_PAGEDOWN:
 641.638 -		number += 16;
 641.639 -		if (number > 127)
 641.640 -			number = 127;
 641.641 -		break;
 641.642 -	case SB_PAGEUP:
 641.643 -		number -= 16;
 641.644 -		if (number < 0)
 641.645 -			number = 0;
 641.646 -		break;
 641.647 -	case SB_TOP:
 641.648 -		number = 0;
 641.649 -		break;
 641.650 -	case SB_THUMBTRACK:
 641.651 -		number = nPos;
 641.652 -		if (number < 0)
 641.653 -			number = 0;
 641.654 -		if (number > 127)
 641.655 -			number = 127;
 641.656 -		break;
 641.657 -	}
 641.658 -
 641.659 -	updateScrollInfo();
 641.660 -
 641.661 -	CString buffer;
 641.662 -	buffer.Format("%d", number);
 641.663 -	m_sprite.SetWindowText(buffer);
 641.664 -	paint();
 641.665 -}
 641.666 -
 641.667 -void OamView::PostNcDestroy()
 641.668 -{
 641.669 -	delete this;
 641.670 -}
 641.671 -
   642.1 --- a/src/win32/OamView.h	Sat Mar 03 10:54:39 2012 -0600
   642.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   642.3 @@ -1,78 +0,0 @@
   642.4 -#if !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_)
   642.5 -#define AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_
   642.6 -
   642.7 -#if _MSC_VER > 1000
   642.8 -#pragma once
   642.9 -#endif // _MSC_VER > 1000
  642.10 -// OamView.h : header file
  642.11 -//
  642.12 -#include "BitmapControl.h"
  642.13 -#include "ZoomControl.h"
  642.14 -#include "ColorControl.h"
  642.15 -#include "IUpdate.h"
  642.16 -#include "ResizeDlg.h"
  642.17 -
  642.18 -/////////////////////////////////////////////////////////////////////////////
  642.19 -// OamView dialog
  642.20 -
  642.21 -class OamView : public ResizeDlg, IUpdateListener
  642.22 -{
  642.23 -private:
  642.24 -	BITMAPINFO    bmpInfo;
  642.25 -	u8 *          data;
  642.26 -	int           w;
  642.27 -	int           h;
  642.28 -	int           number;
  642.29 -	bool          autoUpdate;
  642.30 -	BitmapControl oamView;
  642.31 -	ZoomControl   oamZoom;
  642.32 -	ColorControl  color;
  642.33 -
  642.34 -	// Construction
  642.35 -public:
  642.36 -	void updateScrollInfo();
  642.37 -	afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  642.38 -	afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  642.39 -	void savePNG(const char *name);
  642.40 -	void saveBMP(const char *name);
  642.41 -	void render();
  642.42 -	void setAttributes(u16 a0, u16 a1, u16 a2);
  642.43 -	void paint();
  642.44 -	~OamView();
  642.45 -	OamView(CWnd*pParent = NULL);  // standard constructor
  642.46 -
  642.47 -	virtual void update();
  642.48 -	// Dialog Data
  642.49 -	//{{AFX_DATA(OamView)
  642.50 -	enum { IDD = IDD_OAM_VIEW };
  642.51 -	CEdit m_sprite;
  642.52 -	BOOL  m_stretch;
  642.53 -	//}}AFX_DATA
  642.54 -
  642.55 -	// Overrides
  642.56 -	// ClassWizard generated virtual function overrides
  642.57 -	//{{AFX_VIRTUAL(OamView)
  642.58 -protected:
  642.59 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  642.60 -	virtual void PostNcDestroy();
  642.61 -	//}}AFX_VIRTUAL
  642.62 -
  642.63 -	// Implementation
  642.64 -protected:
  642.65 -	// Generated message map functions
  642.66 -	//{{AFX_MSG(OamView)
  642.67 -	afx_msg void OnSave();
  642.68 -	virtual BOOL OnInitDialog();
  642.69 -	afx_msg void OnStretch();
  642.70 -	afx_msg void OnAutoUpdate();
  642.71 -	afx_msg void OnChangeSprite();
  642.72 -	afx_msg void OnClose();
  642.73 -	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar);
  642.74 -	//}}AFX_MSG
  642.75 -	DECLARE_MESSAGE_MAP()
  642.76 -};
  642.77 -
  642.78 -//{{AFX_INSERT_LOCATION}}
  642.79 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  642.80 -
  642.81 -#endif // !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_)
   643.1 --- a/src/win32/OpenGL.cpp	Sat Mar 03 10:54:39 2012 -0600
   643.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   643.3 @@ -1,544 +0,0 @@
   643.4 -#include "stdafx.h"
   643.5 -#include <gl/GL.h>
   643.6 -
   643.7 -#include "resource.h"
   643.8 -#include "MainWnd.h"
   643.9 -#include "Reg.h"
  643.10 -#include "VBA.h"
  643.11 -
  643.12 -#include "../gba/GBAGlobals.h"
  643.13 -#include "../gb/gbGlobals.h"
  643.14 -#include "../common/Text.h"
  643.15 -#include "../version.h"
  643.16 -
  643.17 -#ifdef MMX
  643.18 -extern "C" bool cpu_mmx;
  643.19 -
  643.20 -extern bool detectMMX();
  643.21 -#endif
  643.22 -
  643.23 -extern int systemSpeed;
  643.24 -extern int Init_2xSaI(u32);
  643.25 -extern void winlog(const char *, ...);
  643.26 -
  643.27 -class OpenGLDisplay : public IDisplay
  643.28 -{
  643.29 -private:
  643.30 -	HDC    hDC;
  643.31 -	HGLRC  hglrc;
  643.32 -	GLuint texture;
  643.33 -	int    width;
  643.34 -	int    height;
  643.35 -	float  size;
  643.36 -	u8 *   filterData;
  643.37 -	bool   failed;
  643.38 -
  643.39 -	bool initializeTexture(int w, int h);
  643.40 -	void updateFiltering(int);
  643.41 -public:
  643.42 -	OpenGLDisplay();
  643.43 -	virtual ~OpenGLDisplay();
  643.44 -
  643.45 -	virtual bool initialize();
  643.46 -	virtual void cleanup();
  643.47 -	virtual void render();
  643.48 -	virtual void checkFullScreen();
  643.49 -	virtual void renderMenu();
  643.50 -	virtual void clear();
  643.51 -	virtual bool changeRenderSize(int w, int h);
  643.52 -	virtual void resize(int w, int h);
  643.53 -	virtual DISPLAY_TYPE getType() { return OPENGL; };
  643.54 -	virtual void setOption(const char *, int);
  643.55 -	virtual int selectFullScreenMode(GUID * *);
  643.56 -};
  643.57 -
  643.58 -OpenGLDisplay::OpenGLDisplay()
  643.59 -{
  643.60 -	hDC        = NULL;
  643.61 -	hglrc      = NULL;
  643.62 -	texture    = 0;
  643.63 -	width      = 0;
  643.64 -	height     = 0;
  643.65 -	size       = 0.0f;
  643.66 -	filterData = (u8 *)malloc(4*16*256*256); // sufficient for 4x filters @ 32bit color depth
  643.67 -	failed     = false;
  643.68 -}
  643.69 -
  643.70 -OpenGLDisplay::~OpenGLDisplay()
  643.71 -{
  643.72 -	cleanup();
  643.73 -}
  643.74 -
  643.75 -void OpenGLDisplay::cleanup()
  643.76 -{
  643.77 -	if (texture != 0)
  643.78 -	{
  643.79 -		glDeleteTextures(1, &texture);
  643.80 -		texture = 0;
  643.81 -	}
  643.82 -	if (hglrc != NULL)
  643.83 -	{
  643.84 -		wglDeleteContext(hglrc);
  643.85 -		wglMakeCurrent(NULL, NULL);
  643.86 -		hglrc = NULL;
  643.87 -	}
  643.88 -	if (hDC != NULL)
  643.89 -	{
  643.90 -		ReleaseDC(*theApp.m_pMainWnd, hDC);
  643.91 -		hDC = NULL;
  643.92 -	}
  643.93 -	if (filterData)
  643.94 -	{
  643.95 -		free(filterData);
  643.96 -		filterData = NULL;
  643.97 -	}
  643.98 -	width  = 0;
  643.99 -	height = 0;
 643.100 -	size   = 0.0f;
 643.101 -}
 643.102 -
 643.103 -bool OpenGLDisplay::initialize()
 643.104 -{
 643.105 -	CWnd *pWnd = theApp.m_pMainWnd;
 643.106 -
 643.107 -	theApp.mode320Available = false;
 643.108 -	theApp.mode640Available = false;
 643.109 -	theApp.mode800Available = false;
 643.110 -
 643.111 -	CDC *dc  = pWnd->GetDC();
 643.112 -	HDC  hDC = dc->GetSafeHdc();
 643.113 -
 643.114 -	PIXELFORMATDESCRIPTOR pfd = {
 643.115 -		sizeof(PIXELFORMATDESCRIPTOR), //  size of this pfd
 643.116 -		1, // version number
 643.117 -		PFD_DRAW_TO_WINDOW | // support window
 643.118 -		PFD_SUPPORT_OPENGL | // support OpenGL
 643.119 -		PFD_DOUBLEBUFFER, // double buffered
 643.120 -		PFD_TYPE_RGBA, // RGBA type
 643.121 -		16, // 16-bit color depth
 643.122 -		0, 0, 0, 0, 0, 0,  // color bits ignored
 643.123 -		0, // no alpha buffer
 643.124 -		0, // shift bit ignored
 643.125 -		0, // no accumulation buffer
 643.126 -		0, 0, 0, 0, // accum bits ignored
 643.127 -		32, // 32-bit z-buffer
 643.128 -		0, // no stencil buffer
 643.129 -		0, // no auxiliary buffer
 643.130 -		PFD_MAIN_PLANE, // main layer
 643.131 -		0, // reserved
 643.132 -		0, 0, 0            // layer masks ignored
 643.133 -	};
 643.134 -	int iPixelFormat;
 643.135 -
 643.136 -	if (!(iPixelFormat = ChoosePixelFormat(hDC, &pfd)))
 643.137 -	{
 643.138 -		winlog("Failed ChoosePixelFormat\n");
 643.139 -		return false;
 643.140 -	}
 643.141 -
 643.142 -	// obtain detailed information about
 643.143 -	// the device context's first pixel format
 643.144 -	if (!(DescribePixelFormat(hDC, iPixelFormat,
 643.145 -	                          sizeof(PIXELFORMATDESCRIPTOR), &pfd)))
 643.146 -	{
 643.147 -		winlog("Failed DescribePixelFormat\n");
 643.148 -		return false;
 643.149 -	}
 643.150 -
 643.151 -	if (!SetPixelFormat(hDC, iPixelFormat, &pfd))
 643.152 -	{
 643.153 -		winlog("Failed SetPixelFormat\n");
 643.154 -		return false;
 643.155 -	}
 643.156 -
 643.157 -	if (!(hglrc = wglCreateContext(hDC)))
 643.158 -	{
 643.159 -		winlog("Failed wglCreateContext\n");
 643.160 -		return false;
 643.161 -	}
 643.162 -
 643.163 -	if (!wglMakeCurrent(hDC, hglrc))
 643.164 -	{
 643.165 -		winlog("Failed wglMakeCurrent\n");
 643.166 -		return false;
 643.167 -	}
 643.168 -	pWnd->ReleaseDC(dc);
 643.169 -
 643.170 -	// setup 2D gl environment
 643.171 -	glPushAttrib(GL_ENABLE_BIT);
 643.172 -	glDisable(GL_DEPTH_TEST);
 643.173 -	glDisable(GL_CULL_FACE);
 643.174 -	glEnable(GL_TEXTURE_2D);
 643.175 -
 643.176 -	glViewport(0, 0, theApp.surfaceSizeX, theApp.surfaceSizeY);
 643.177 -
 643.178 -	glMatrixMode(GL_PROJECTION);
 643.179 -	glLoadIdentity();
 643.180 -
 643.181 -	glOrtho(0.0, (GLdouble)(theApp.surfaceSizeX), (GLdouble)(theApp.surfaceSizeY),
 643.182 -	        0.0, 0.0, 1.0);
 643.183 -	glMatrixMode(GL_MODELVIEW);
 643.184 -	glLoadIdentity();
 643.185 -
 643.186 -	systemRedShift      = 3;
 643.187 -	systemGreenShift    = 11;
 643.188 -	systemBlueShift     = 19;
 643.189 -	systemColorDepth    = 32;
 643.190 -	theApp.fsColorDepth = 32;
 643.191 -
 643.192 -	Init_2xSaI(32);
 643.193 -#ifdef MMX
 643.194 -	if (!theApp.disableMMX)
 643.195 -		cpu_mmx = theApp.detectMMX();
 643.196 -	else
 643.197 -		cpu_mmx = 0;
 643.198 -#endif
 643.199 -
 643.200 -	if (theApp.ddrawDebug)
 643.201 -	{
 643.202 -		winlog("R shift: %d\n", systemRedShift);
 643.203 -		winlog("G shift: %d\n", systemGreenShift);
 643.204 -		winlog("B shift: %d\n", systemBlueShift);
 643.205 -	}
 643.206 -
 643.207 -	switch (systemColorDepth)
 643.208 -	{
 643.209 -	case 16:
 643.210 -	{
 643.211 -		for (int i = 0; i < 0x10000; i++)
 643.212 -		{
 643.213 -			systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
 643.214 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 643.215 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 643.216 -		}
 643.217 -		break;
 643.218 -	}
 643.219 -	case 24:
 643.220 -	case 32:
 643.221 -	{
 643.222 -		for (int i = 0; i < 0x10000; i++)
 643.223 -		{
 643.224 -			systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
 643.225 -			                      (((i & 0x3e0) >> 5) << systemGreenShift) |
 643.226 -			                      (((i & 0x7c00) >> 10) << systemBlueShift);
 643.227 -		}
 643.228 -		break;
 643.229 -	}
 643.230 -	}
 643.231 -	theApp.updateFilter();
 643.232 -	theApp.updateIFB();
 643.233 -
 643.234 -	if (failed)
 643.235 -		return false;
 643.236 -
 643.237 -	pWnd->DragAcceptFiles(TRUE);
 643.238 -
 643.239 -	return TRUE;
 643.240 -}
 643.241 -
 643.242 -void OpenGLDisplay::clear()
 643.243 -{}
 643.244 -
 643.245 -void OpenGLDisplay::renderMenu()
 643.246 -{
 643.247 -	checkFullScreen();
 643.248 -	if (theApp.m_pMainWnd)
 643.249 -		theApp.m_pMainWnd->DrawMenuBar();
 643.250 -}
 643.251 -
 643.252 -void OpenGLDisplay::checkFullScreen()
 643.253 -{
 643.254 -	//  if(tripleBuffering)
 643.255 -	//    pOpenGL->FlipToGDISurface();
 643.256 -}
 643.257 -
 643.258 -void OpenGLDisplay::render()
 643.259 -{
 643.260 -	void (*filterFunction)(u8 *, u32, u8 *, u8 *, u32, int, int) = theApp.filterFunction;
 643.261 -	int  filterWidth = theApp.filterWidth, filterHeight = theApp.filterHeight;
 643.262 -/*
 643.263 -    if(textMethod == 1)
 643.264 -    {
 643.265 -        int copyX = 240, copyY = 160;
 643.266 -        if(systemCartridgeType == 1)
 643.267 -            if(gbBorderOn) copyX = 256, copyY = 224;
 643.268 -            else           copyX = 160, copyY = 144;
 643.269 -
 643.270 -        extern void Simple1x(u8*,u32,u8*,u8*,u32,int,int);
 643.271 -        filterFunction = Simple1x;
 643.272 -        filterWidth = copyX;
 643.273 -        filterHeight = copyY;
 643.274 -    }
 643.275 - */
 643.276 -	int pitch = filterWidth * 4 + 4;
 643.277 -	u8 *data  = pix + (theApp.sizeX+1)*4;
 643.278 -
 643.279 -	int filterPitch = theApp.rect.right*4;
 643.280 -
 643.281 -/*
 643.282 -	// HACK: see below
 643.283 -	if (textMethod == 1 && !filterFunction)
 643.284 -	{
 643.285 -		textMethod = 0; // must not be after systemMessage!
 643.286 -		systemMessage(
 643.287 -		    0,
 643.288 -		    "The \"On Game\" text display mode does not work with this combination of renderers and filters.\nThe display mode is automatically being changed to \"In Game\" instead,\nbut this may cause message text to go into AVI recordings and screenshots.\nThis can be reconfigured by choosing \"Options->Video->Text Display Options...\"");
 643.289 -	}
 643.290 -*/
 643.291 -
 643.292 -	if (filterFunction)
 643.293 -	{
 643.294 -		data = filterData;
 643.295 -		filterFunction(pix + pitch,
 643.296 -		               pitch,
 643.297 -		               (u8 *)theApp.delta,
 643.298 -		               (u8 *)filterData,
 643.299 -		               filterPitch,
 643.300 -		               filterWidth,
 643.301 -		               filterHeight);
 643.302 -	}
 643.303 -
 643.304 -	if (theApp.showSpeed && theApp.videoOption > VIDEO_4X)
 643.305 -	{
 643.306 -		char buffer[30];
 643.307 -		if (theApp.showSpeed == 1)
 643.308 -			sprintf(buffer, "%3d%%", systemSpeed);
 643.309 -		else
 643.310 -			sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
 643.311 -			        systemFrameSkip,
 643.312 -			        theApp.showRenderedFrames);
 643.313 -
 643.314 -		if (filterFunction)
 643.315 -		{
 643.316 -			if (theApp.showSpeedTransparent)
 643.317 -				drawTextTransp((u8 *)filterData,
 643.318 -				               filterPitch,
 643.319 -				               theApp.rect.left+10,
 643.320 -				               theApp.rect.bottom-10,
 643.321 -				               buffer);
 643.322 -			else
 643.323 -				drawText((u8 *)filterData,
 643.324 -				         filterPitch,
 643.325 -			             theApp.rect.left+10,
 643.326 -			             theApp.rect.bottom-10,
 643.327 -				         buffer);
 643.328 -		}
 643.329 -		else
 643.330 -		{
 643.331 -			if (theApp.showSpeedTransparent)
 643.332 -				drawTextTransp((u8 *)pix,
 643.333 -				               pitch,
 643.334 -				               theApp.rect.left+10,
 643.335 -				               theApp.rect.bottom-10,
 643.336 -				               buffer);
 643.337 -			else
 643.338 -				drawText((u8 *)pix,
 643.339 -				         pitch,
 643.340 -			             theApp.rect.left+10,
 643.341 -			             theApp.rect.bottom-10,
 643.342 -				         buffer);
 643.343 -		}
 643.344 -	}
 643.345 -
 643.346 -	if (textMethod == 1 && filterFunction)
 643.347 -	{
 643.348 -		DrawTextMessages((u8 *)filterData, filterPitch, theApp.rect.left, theApp.rect.bottom);
 643.349 -	}
 643.350 -
 643.351 -	// Texturemap complete texture to surface so we have free scaling
 643.352 -	// and antialiasing
 643.353 -	if (filterFunction)
 643.354 -	{
 643.355 -		glPixelStorei(GL_UNPACK_ROW_LENGTH, theApp.rect.right);
 643.356 -	}
 643.357 -	else
 643.358 -	{
 643.359 -		glPixelStorei(GL_UNPACK_ROW_LENGTH, theApp.sizeX+1);
 643.360 -	}
 643.361 -
 643.362 -	glTexSubImage2D(GL_TEXTURE_2D, 0,
 643.363 -					0, 0, theApp.rect.right, theApp.rect.bottom,
 643.364 -	                GL_RGBA, GL_UNSIGNED_BYTE, data);
 643.365 -
 643.366 -	if (theApp.glType == 0)
 643.367 -	{
 643.368 -		glBegin(GL_TRIANGLE_STRIP);
 643.369 -		glTexCoord2f(0.0, 0.0); glVertex3i(0, 0, 0);
 643.370 -		glTexCoord2f(theApp.rect.right/size, 0.0); glVertex3i(theApp.surfaceSizeX, 0, 0);
 643.371 -		glTexCoord2f(0.0, theApp.rect.bottom/size); glVertex3i(0, theApp.surfaceSizeY, 0);
 643.372 -		glTexCoord2f(theApp.rect.right/size, theApp.rect.bottom/size); glVertex3i(theApp.surfaceSizeX, theApp.surfaceSizeY, 0);
 643.373 -		glEnd();
 643.374 -	}
 643.375 -	else
 643.376 -	{
 643.377 -		glBegin(GL_QUADS);
 643.378 -		glTexCoord2f(0.0, 0.0); glVertex3i(0, 0, 0);
 643.379 -		glTexCoord2f(theApp.rect.right/size, 0.0); glVertex3i(theApp.surfaceSizeX, 0, 0);
 643.380 -		glTexCoord2f(theApp.rect.right/size, theApp.rect.bottom/size); glVertex3i(theApp.surfaceSizeX, theApp.surfaceSizeY, 0);
 643.381 -		glTexCoord2f(0.0, theApp.rect.bottom/size); glVertex3i(0, theApp.surfaceSizeY, 0);
 643.382 -		glEnd();
 643.383 -	}
 643.384 -
 643.385 -	CDC *dc = theApp.m_pMainWnd->GetDC();
 643.386 -
 643.387 -	if (textMethod == 2 || (textMethod == 1 && !filterFunction)) // HACK: so that textMethod isn't changed
 643.388 -	{
 643.389 -		for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
 643.390 -		{
 643.391 -			if (theApp.screenMessage[slot])
 643.392 -			{
 643.393 -				if ((theApp.screenMessageDuration[slot] < 0 || 
 643.394 -					(int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
 643.395 -				    (!theApp.disableStatusMessage || slot == 1 || slot == 2))
 643.396 -				{
 643.397 -					dc->SetBkMode(TRANSPARENT);
 643.398 -
 643.399 -					if (outlinedText)
 643.400 -					{
 643.401 -						dc->SetTextColor(textColor != 7 ? RGB(0, 0, 0) : RGB(255, 255, 255));
 643.402 -						// draw black outline
 643.403 -						const static int xd [8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 643.404 -						const static int yd [8] = {-1, -1, -1, 0, 1, 1, 1, 0};
 643.405 -						for (int i = 0; i < 8; i++)
 643.406 -						{
 643.407 -							dc->TextOut(10+xd[i], theApp.surfaceSizeY - 20*(slot+1)+yd[i], theApp.screenMessageBuffer[slot]);
 643.408 -						}
 643.409 -					}
 643.410 -
 643.411 -					COLORREF color;
 643.412 -					switch (textColor)
 643.413 -					{
 643.414 -					case 0:
 643.415 -						color = RGB(255, 255, 255); break;
 643.416 -					case 1:
 643.417 -						color = RGB(255, 0, 0); break;
 643.418 -					case 2:
 643.419 -						color = RGB(255, 255, 0); break;
 643.420 -					case 3:
 643.421 -						color = RGB(0, 255, 0); break;
 643.422 -					case 4:
 643.423 -						color = RGB(0, 255, 255); break;
 643.424 -					case 5:
 643.425 -						color = RGB(0, 0, 255); break;
 643.426 -					case 6:
 643.427 -						color = RGB(255, 0, 255); break;
 643.428 -					case 7:
 643.429 -						color = RGB(0, 0, 0); break;
 643.430 -					}
 643.431 -					dc->SetTextColor(color);
 643.432 -
 643.433 -					// draw center text
 643.434 -					dc->TextOut(10, theApp.surfaceSizeY - 20*(slot+1), theApp.screenMessageBuffer[slot]);
 643.435 -				}
 643.436 -				else
 643.437 -				{
 643.438 -					theApp.screenMessage[slot] = false;
 643.439 -				}
 643.440 -			}
 643.441 -		}
 643.442 -	}
 643.443 -
 643.444 -	SwapBuffers(dc->GetSafeHdc());
 643.445 -
 643.446 -	theApp.m_pMainWnd->ReleaseDC(dc);
 643.447 -}
 643.448 -
 643.449 -void OpenGLDisplay::resize(int w, int h)
 643.450 -{
 643.451 -	glViewport(0, 0, w, h);
 643.452 -	glMatrixMode(GL_PROJECTION);
 643.453 -	glLoadIdentity();
 643.454 -
 643.455 -	glOrtho(0.0, (GLdouble)(w), (GLdouble)(h), 0.0, 0.0, 1.0);
 643.456 -	glMatrixMode(GL_MODELVIEW);
 643.457 -	glLoadIdentity();
 643.458 -}
 643.459 -
 643.460 -void OpenGLDisplay::updateFiltering(int value)
 643.461 -{
 643.462 -	switch (value)
 643.463 -	{
 643.464 -	case 0:
 643.465 -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 643.466 -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 643.467 -		break;
 643.468 -	case 1:
 643.469 -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 643.470 -		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 643.471 -		break;
 643.472 -	}
 643.473 -}
 643.474 -
 643.475 -bool OpenGLDisplay::initializeTexture(int w, int h)
 643.476 -{
 643.477 -	int mySize = 256;
 643.478 -	size = 256.0f;
 643.479 -	if (w > 511 || h > 511)
 643.480 -	{
 643.481 -		size   = 1024.0f;
 643.482 -		mySize = 1024;
 643.483 -	}
 643.484 -	else if (w > 255 || h > 255)
 643.485 -	{
 643.486 -		size   = 512.0f;
 643.487 -		mySize = 512;
 643.488 -	}
 643.489 -	glGenTextures(1, &texture);
 643.490 -	glBindTexture(GL_TEXTURE_2D, texture);
 643.491 -
 643.492 -	int filter = regQueryDwordValue("glFilter", 0);
 643.493 -	if (filter < 0 || filter > 1)
 643.494 -		filter = 0;
 643.495 -	updateFiltering(filter);
 643.496 -
 643.497 -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mySize, mySize, 0, GL_RGBA,
 643.498 -	             GL_UNSIGNED_BYTE, NULL);
 643.499 -	width  = w;
 643.500 -	height = h;
 643.501 -
 643.502 -	return true;
 643.503 -}
 643.504 -
 643.505 -bool OpenGLDisplay::changeRenderSize(int w, int h)
 643.506 -{
 643.507 -	if (width != w || height != h)
 643.508 -	{
 643.509 -		if (texture != 0)
 643.510 -		{
 643.511 -			glDeleteTextures(1, &texture);
 643.512 -			texture = 0;
 643.513 -		}
 643.514 -		if (!initializeTexture(w, h))
 643.515 -		{
 643.516 -			failed = true;
 643.517 -			return false;
 643.518 -		}
 643.519 -	}
 643.520 -	return true;
 643.521 -}
 643.522 -
 643.523 -void OpenGLDisplay::setOption(const char *option, int value)
 643.524 -{
 643.525 -	if (!strcmp(option, "glFilter"))
 643.526 -		updateFiltering(value);
 643.527 -}
 643.528 -
 643.529 -int OpenGLDisplay::selectFullScreenMode(GUID * *)
 643.530 -{
 643.531 -	HWND wnd = GetDesktopWindow();
 643.532 -	RECT r;
 643.533 -	GetWindowRect(wnd, &r);
 643.534 -	int w  = (r.right - r.left) & 4095;
 643.535 -	int h  = (r.bottom - r.top) & 4095;
 643.536 -	HDC dc = GetDC(wnd);
 643.537 -	int c  = GetDeviceCaps(dc, BITSPIXEL);
 643.538 -	ReleaseDC(wnd, dc);
 643.539 -
 643.540 -	return (c << 24) | (w << 12) | h;
 643.541 -}
 643.542 -
 643.543 -IDisplay *newOpenGLDisplay()
 643.544 -{
 643.545 -	return new OpenGLDisplay();
 643.546 -}
 643.547 -
   644.1 --- a/src/win32/PaletteView.cpp	Sat Mar 03 10:54:39 2012 -0600
   644.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   644.3 @@ -1,217 +0,0 @@
   644.4 -// PaletteView.cpp : implementation file
   644.5 -//
   644.6 -
   644.7 -#include "stdafx.h"
   644.8 -#include "FileDlg.h"
   644.9 -#include "PaletteView.h"
  644.10 -#include "WinResUtil.h"
  644.11 -#include "VBA.h" // for theApp
  644.12 -
  644.13 -#include "../gba/GBAGlobals.h"
  644.14 -
  644.15 -void GBAPaletteViewControl::updatePalette()
  644.16 -{
  644.17 -	if (paletteRAM != NULL)
  644.18 -		memcpy(palette, &paletteRAM[paletteAddress], 512);
  644.19 -}
  644.20 -
  644.21 -/////////////////////////////////////////////////////////////////////////////
  644.22 -// PaletteView dialog
  644.23 -
  644.24 -PaletteView::PaletteView(CWnd*pParent /*=NULL*/)
  644.25 -	: ResizeDlg(PaletteView::IDD, pParent)
  644.26 -{
  644.27 -	//{{AFX_DATA_INIT(PaletteView)
  644.28 -	// NOTE: the ClassWizard will add member initialization here
  644.29 -	//}}AFX_DATA_INIT
  644.30 -	autoUpdate = false;
  644.31 -}
  644.32 -
  644.33 -PaletteView::~PaletteView()
  644.34 -{}
  644.35 -
  644.36 -void PaletteView::DoDataExchange(CDataExchange*pDX)
  644.37 -{
  644.38 -	CDialog::DoDataExchange(pDX);
  644.39 -	//{{AFX_DATA_MAP(PaletteView)
  644.40 -	// NOTE: the ClassWizard will add DDX and DDV calls here
  644.41 -	//}}AFX_DATA_MAP
  644.42 -	DDX_Control(pDX, IDC_PALETTE_VIEW, paletteView);
  644.43 -	DDX_Control(pDX, IDC_PALETTE_VIEW_OBJ, paletteViewOBJ);
  644.44 -	DDX_Control(pDX, IDC_COLOR, colorControl);
  644.45 -}
  644.46 -
  644.47 -BEGIN_MESSAGE_MAP(PaletteView, CDialog)
  644.48 -//{{AFX_MSG_MAP(PaletteView)
  644.49 -ON_BN_CLICKED(IDC_SAVE_BG, OnSaveBg)
  644.50 -ON_BN_CLICKED(IDC_SAVE_OBJ, OnSaveObj)
  644.51 -ON_BN_CLICKED(IDC_REFRESH2, OnRefresh2)
  644.52 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  644.53 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  644.54 -//}}AFX_MSG_MAP
  644.55 -ON_MESSAGE(WM_PALINFO, OnPalInfo)
  644.56 -END_MESSAGE_MAP()
  644.57 -
  644.58 -/////////////////////////////////////////////////////////////////////////////
  644.59 -// PaletteView message handlers
  644.60 -
  644.61 -BOOL PaletteView::OnInitDialog()
  644.62 -{
  644.63 -	CDialog::OnInitDialog();
  644.64 -
  644.65 -	DIALOG_SIZER_START(sz)
  644.66 -	DIALOG_SIZER_END()
  644.67 -	SetData(sz,
  644.68 -	        FALSE,
  644.69 -	        HKEY_CURRENT_USER,
  644.70 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\PaletteView",
  644.71 -	        NULL);
  644.72 -
  644.73 -	paletteView.setPaletteAddress(0);
  644.74 -	paletteView.refresh();
  644.75 -
  644.76 -	paletteViewOBJ.setPaletteAddress(0x200);
  644.77 -	paletteViewOBJ.refresh();
  644.78 -
  644.79 -	return TRUE; // return TRUE unless you set the focus to a control
  644.80 -	             // EXCEPTION: OCX Property Pages should return FALSE
  644.81 -}
  644.82 -
  644.83 -void PaletteView::save(int which)
  644.84 -{
  644.85 -	CString captureBuffer;
  644.86 -
  644.87 -	if (which == 0)
  644.88 -		captureBuffer = "bg.pal";
  644.89 -	else
  644.90 -		captureBuffer = "obj.pal";
  644.91 -
  644.92 -	LPCTSTR exts[] = {".pal", ".pal", ".act", NULL };
  644.93 -
  644.94 -	CString filter = winResLoadFilter(IDS_FILTER_PAL);
  644.95 -	CString title  = winResLoadString(IDS_SELECT_PALETTE_NAME);
  644.96 -	FileDlg dlg(this,
  644.97 -	            captureBuffer,
  644.98 -	            filter,
  644.99 -	            1,
 644.100 -	            "PAL",
 644.101 -	            exts,
 644.102 -	            "",
 644.103 -	            title,
 644.104 -	            true);
 644.105 -
 644.106 -	if (dlg.DoModal() == IDCANCEL)
 644.107 -	{
 644.108 -		return;
 644.109 -	}
 644.110 -
 644.111 -	PaletteViewControl *p = NULL;
 644.112 -
 644.113 -	if (which == 0)
 644.114 -		p = &paletteView;
 644.115 -	else
 644.116 -		p = &paletteViewOBJ;
 644.117 -
 644.118 -	switch (dlg.getFilterIndex())
 644.119 -	{
 644.120 -	case 0:
 644.121 -	case 1:
 644.122 -		p->saveMSPAL(captureBuffer);
 644.123 -		break;
 644.124 -	case 2:
 644.125 -		p->saveJASCPAL(captureBuffer);
 644.126 -		break;
 644.127 -	case 3:
 644.128 -		p->saveAdobe(captureBuffer);
 644.129 -		break;
 644.130 -	}
 644.131 -}
 644.132 -
 644.133 -void PaletteView::OnSaveBg()
 644.134 -{
 644.135 -	save(0);
 644.136 -}
 644.137 -
 644.138 -void PaletteView::OnSaveObj()
 644.139 -{
 644.140 -	save(1);
 644.141 -}
 644.142 -
 644.143 -void PaletteView::OnRefresh2()
 644.144 -{
 644.145 -	paletteView.refresh();
 644.146 -	paletteViewOBJ.refresh();
 644.147 -}
 644.148 -
 644.149 -void PaletteView::update()
 644.150 -{
 644.151 -	OnRefresh2();
 644.152 -}
 644.153 -
 644.154 -void PaletteView::OnAutoUpdate()
 644.155 -{
 644.156 -	autoUpdate = !autoUpdate;
 644.157 -	if (autoUpdate)
 644.158 -	{
 644.159 -		theApp.winAddUpdateListener(this);
 644.160 -	}
 644.161 -	else
 644.162 -	{
 644.163 -		theApp.winRemoveUpdateListener(this);
 644.164 -	}
 644.165 -}
 644.166 -
 644.167 -void PaletteView::OnClose()
 644.168 -{
 644.169 -	theApp.winRemoveUpdateListener(this);
 644.170 -
 644.171 -	DestroyWindow();
 644.172 -}
 644.173 -
 644.174 -LRESULT PaletteView::OnPalInfo(WPARAM wParam, LPARAM lParam)
 644.175 -{
 644.176 -	u16     color   = (u16)wParam;
 644.177 -	u32     address = (u32)lParam;
 644.178 -	CString buffer;
 644.179 -
 644.180 -	if (address >= 0x200)
 644.181 -		address = 0x5000200 + 2*(address & 255);
 644.182 -	else
 644.183 -		address = 0x5000000 + 2*(address & 255);
 644.184 -
 644.185 -	buffer.Format("0x%08X", address);
 644.186 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 644.187 -
 644.188 -	int r = (color & 0x1f);
 644.189 -	int g = (color & 0x3e0) >> 5;
 644.190 -	int b = (color & 0x7c00) >> 10;
 644.191 -
 644.192 -	buffer.Format("%d", r);
 644.193 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 644.194 -
 644.195 -	buffer.Format("%d", g);
 644.196 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 644.197 -
 644.198 -	buffer.Format("%d", b);
 644.199 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 644.200 -
 644.201 -	buffer.Format("0x%04X", color);
 644.202 -	GetDlgItem(IDC_VALUE)->SetWindowText(buffer);
 644.203 -
 644.204 -	colorControl.setColor(color);
 644.205 -
 644.206 -	if (address >= 0x5000200)
 644.207 -	{
 644.208 -		paletteView.setSelected(-1);
 644.209 -	}
 644.210 -	else
 644.211 -		paletteViewOBJ.setSelected(-1);
 644.212 -
 644.213 -	return TRUE;
 644.214 -}
 644.215 -
 644.216 -void PaletteView::PostNcDestroy()
 644.217 -{
 644.218 -	delete this;
 644.219 -}
 644.220 -
   645.1 --- a/src/win32/PaletteView.h	Sat Mar 03 10:54:39 2012 -0600
   645.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   645.3 @@ -1,73 +0,0 @@
   645.4 -#if !defined(AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_)
   645.5 -#define AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_
   645.6 -
   645.7 -#if _MSC_VER > 1000
   645.8 -#pragma once
   645.9 -#endif // _MSC_VER > 1000
  645.10 -// -*- C++ -*-
  645.11 -// PaletteView.h : header file
  645.12 -//
  645.13 -
  645.14 -#include "IUpdate.h"
  645.15 -#include "resource.h"
  645.16 -#include "ResizeDlg.h"
  645.17 -#include "ColorControl.h"
  645.18 -#include "PaletteViewControl.h"
  645.19 -
  645.20 -class GBAPaletteViewControl : public PaletteViewControl
  645.21 -{
  645.22 -public:
  645.23 -	virtual void updatePalette();
  645.24 -};
  645.25 -
  645.26 -/////////////////////////////////////////////////////////////////////////////
  645.27 -// PaletteView dialog
  645.28 -
  645.29 -class PaletteView : public ResizeDlg, IUpdateListener
  645.30 -{
  645.31 -private:
  645.32 -	GBAPaletteViewControl paletteView;
  645.33 -	GBAPaletteViewControl paletteViewOBJ;
  645.34 -	ColorControl colorControl;
  645.35 -	bool         autoUpdate;
  645.36 -	// Construction
  645.37 -public:
  645.38 -	void save(int which);
  645.39 -	PaletteView(CWnd*pParent = NULL);  // standard constructor
  645.40 -	~PaletteView();
  645.41 -	afx_msg LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam);
  645.42 -
  645.43 -	// Dialog Data
  645.44 -	//{{AFX_DATA(PaletteView)
  645.45 -	enum { IDD = IDD_PALETTE_VIEW };
  645.46 -	// NOTE: the ClassWizard will add data members here
  645.47 -	//}}AFX_DATA
  645.48 -
  645.49 -	// Overrides
  645.50 -	// ClassWizard generated virtual function overrides
  645.51 -	//{{AFX_VIRTUAL(PaletteView)
  645.52 -protected:
  645.53 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  645.54 -	virtual void PostNcDestroy();
  645.55 -	//}}AFX_VIRTUAL
  645.56 -
  645.57 -	virtual void update();
  645.58 -
  645.59 -	// Implementation
  645.60 -protected:
  645.61 -	// Generated message map functions
  645.62 -	//{{AFX_MSG(PaletteView)
  645.63 -	virtual BOOL OnInitDialog();
  645.64 -	afx_msg void OnSaveBg();
  645.65 -	afx_msg void OnSaveObj();
  645.66 -	afx_msg void OnRefresh2();
  645.67 -	afx_msg void OnAutoUpdate();
  645.68 -	afx_msg void OnClose();
  645.69 -	//}}AFX_MSG
  645.70 -	DECLARE_MESSAGE_MAP()
  645.71 -};
  645.72 -
  645.73 -//{{AFX_INSERT_LOCATION}}
  645.74 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  645.75 -
  645.76 -#endif // !defined(AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_)
   646.1 --- a/src/win32/PaletteViewControl.cpp	Sat Mar 03 10:54:39 2012 -0600
   646.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   646.3 @@ -1,384 +0,0 @@
   646.4 -// PaletteViewControl.cpp : implementation file
   646.5 -//
   646.6 -
   646.7 -#include "stdafx.h"
   646.8 -#include "PaletteViewControl.h"
   646.9 -
  646.10 -#include "../common/Util.h"
  646.11 -
  646.12 -bool PaletteViewControl::isRegistered = false;
  646.13 -
  646.14 -/////////////////////////////////////////////////////////////////////////////
  646.15 -// PaletteViewControl
  646.16 -
  646.17 -PaletteViewControl::PaletteViewControl()
  646.18 -{
  646.19 -  memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
  646.20 -  
  646.21 -  bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);
  646.22 -  bmpInfo.bmiHeader.biWidth = 256;
  646.23 -  bmpInfo.bmiHeader.biHeight = -256;
  646.24 -  bmpInfo.bmiHeader.biPlanes = 1;
  646.25 -  bmpInfo.bmiHeader.biBitCount = 24;
  646.26 -  bmpInfo.bmiHeader.biCompression = BI_RGB;
  646.27 -  data = (u8 *)malloc(3 * 256 * 256);
  646.28 -
  646.29 -  w = 256;
  646.30 -  h = 256;
  646.31 -
  646.32 -  colors = 256;
  646.33 -
  646.34 -  paletteAddress = 0;
  646.35 -  
  646.36 -  ZeroMemory(palette, 512);
  646.37 -
  646.38 -  selected = -1;
  646.39 -  registerClass();
  646.40 -}
  646.41 -
  646.42 -PaletteViewControl::~PaletteViewControl()
  646.43 -{
  646.44 -  if(data)
  646.45 -    free(data);
  646.46 -}
  646.47 -
  646.48 -
  646.49 -BEGIN_MESSAGE_MAP(PaletteViewControl, CWnd)
  646.50 -  //{{AFX_MSG_MAP(PaletteViewControl)
  646.51 -  ON_WM_LBUTTONDOWN()
  646.52 -  ON_WM_ERASEBKGND()
  646.53 -  ON_WM_PAINT()
  646.54 -  //}}AFX_MSG_MAP
  646.55 -  END_MESSAGE_MAP()
  646.56 -
  646.57 -
  646.58 -  /////////////////////////////////////////////////////////////////////////////
  646.59 -// PaletteViewControl message handlers
  646.60 -
  646.61 -void PaletteViewControl::init(int c, int w, int h)
  646.62 -{
  646.63 -  this->w = w;
  646.64 -  this->h = h;
  646.65 -  this->colors = c;
  646.66 -
  646.67 -  bmpInfo.bmiHeader.biWidth = w;
  646.68 -  bmpInfo.bmiHeader.biHeight = -h;  
  646.69 -}
  646.70 -
  646.71 -
  646.72 -bool PaletteViewControl::saveAdobe(const char *name)
  646.73 -{
  646.74 -  FILE *f = fopen(name, "wb");
  646.75 -
  646.76 -  if(!f)
  646.77 -    return false;
  646.78 -
  646.79 -  for(int i = 0; i < colors; i++) {
  646.80 -    u16 c = palette[i];
  646.81 -    int r = (c & 0x1f) << 3;
  646.82 -    int g = (c & 0x3e0) >> 2;
  646.83 -    int b = (c & 0x7c00) >> 7;
  646.84 -
  646.85 -    u8 data[3] = { r, g, b };
  646.86 -    fwrite(data, 1, 3, f);
  646.87 -  }
  646.88 -  if(colors < 256) {
  646.89 -    for(int i = colors; i < 256; i++) {
  646.90 -      u8 data[3] = { 0, 0, 0 };
  646.91 -      fwrite(data, 1, 3, f);
  646.92 -    }
  646.93 -  }
  646.94 -  fclose(f);
  646.95 -
  646.96 -  return true;
  646.97 -}
  646.98 -
  646.99 -
 646.100 -bool PaletteViewControl::saveMSPAL(const char *name)
 646.101 -{
 646.102 -  FILE *f = fopen(name, "wb");
 646.103 -
 646.104 -  if(!f)
 646.105 -    return false;
 646.106 -
 646.107 -  u8 data[4] = { 'R', 'I', 'F', 'F' };
 646.108 -
 646.109 -  fwrite(data, 1, 4, f);
 646.110 -  utilPutDword(data, 256 * 4 + 16);
 646.111 -  fwrite(data, 1, 4, f);
 646.112 -  u8 data3[4] = { 'P', 'A', 'L', ' ' };
 646.113 -  fwrite(data3, 1, 4, f);
 646.114 -  u8 data4[4] = { 'd', 'a', 't', 'a' };
 646.115 -  fwrite(data4, 1, 4, f);
 646.116 -  utilPutDword(data, 256*4+4);
 646.117 -  fwrite(data, 1, 4, f);
 646.118 -  utilPutWord(&data[0], 0x0300);
 646.119 -  utilPutWord(&data[2], 256); // causes problems if not 16 or 256
 646.120 -  fwrite(data, 1, 4, f);
 646.121 -  
 646.122 -  for(int i = 0; i < colors; i++) {
 646.123 -    u16 c = palette[i];
 646.124 -    int r = (c & 0x1f) << 3;
 646.125 -    int g = (c & 0x3e0) >> 2;
 646.126 -    int b = (c & 0x7c00) >> 7;
 646.127 -
 646.128 -    u8 data7[4] = { r, g, b, 0 };
 646.129 -    fwrite(data7, 1, 4, f);
 646.130 -  }
 646.131 -  if(colors < 256) {
 646.132 -    for(int i = colors; i < 256; i++) {
 646.133 -      u8 data7[4] = { 0, 0, 0, 0 };
 646.134 -      fwrite(data7, 1, 4, f);
 646.135 -    }
 646.136 -  }
 646.137 -  fclose(f);
 646.138 -
 646.139 -  return true;
 646.140 -}
 646.141 -
 646.142 -
 646.143 -bool PaletteViewControl::saveJASCPAL(const char *name)
 646.144 -{
 646.145 -  FILE *f = fopen(name, "wb");
 646.146 -
 646.147 -  if(!f)
 646.148 -    return false;
 646.149 -
 646.150 -  fprintf(f, "JASC-PAL\r\n0100\r\n256\r\n");
 646.151 -  
 646.152 -  for(int i = 0; i < colors; i++) {
 646.153 -    u16 c = palette[i];
 646.154 -    int r = (c & 0x1f) << 3;
 646.155 -    int g = (c & 0x3e0) >> 2;
 646.156 -    int b = (c & 0x7c00) >> 7;
 646.157 -
 646.158 -    fprintf(f, "%d %d %d\r\n", r, g, b);
 646.159 -  }
 646.160 -  if(colors < 256) {
 646.161 -    for(int i = colors; i < 256; i++)
 646.162 -      fprintf(f, "0 0 0\r\n");
 646.163 -  }
 646.164 -  fclose(f);
 646.165 -
 646.166 -  return true;  
 646.167 -}
 646.168 -
 646.169 -void PaletteViewControl::setPaletteAddress(int address)
 646.170 -{
 646.171 -  paletteAddress = address;
 646.172 -}
 646.173 -
 646.174 -
 646.175 -void PaletteViewControl::setSelected(int s)
 646.176 -{
 646.177 -  selected = s;
 646.178 -  InvalidateRect(NULL, FALSE);
 646.179 -}
 646.180 -
 646.181 -
 646.182 -void PaletteViewControl::render(u16 color, int x, int y)
 646.183 -{
 646.184 -  u8 *start = data + y*16*w*3 + x*16*3;
 646.185 -  int skip = w*3-16*3;
 646.186 -
 646.187 -  int r = (color & 0x1f) << 3;
 646.188 -  int g = (color & 0x3e0) >> 2;
 646.189 -  int b = (color & 0x7c00) >> 7;
 646.190 -
 646.191 -  for(int i = 0; i < 16; i++) {
 646.192 -    *start++ = b;
 646.193 -    *start++ = g;
 646.194 -    *start++ = r;
 646.195 -
 646.196 -    *start++ = b;
 646.197 -    *start++ = g;
 646.198 -    *start++ = r;
 646.199 -
 646.200 -    *start++ = b;
 646.201 -    *start++ = g;
 646.202 -    *start++ = r;
 646.203 -
 646.204 -    *start++ = b;
 646.205 -    *start++ = g;
 646.206 -    *start++ = r;
 646.207 -
 646.208 -    *start++ = b;
 646.209 -    *start++ = g;
 646.210 -    *start++ = r;
 646.211 -
 646.212 -    *start++ = b;
 646.213 -    *start++ = g;
 646.214 -    *start++ = r;
 646.215 -
 646.216 -    *start++ = b;
 646.217 -    *start++ = g;
 646.218 -    *start++ = r;
 646.219 -
 646.220 -    *start++ = b;
 646.221 -    *start++ = g;
 646.222 -    *start++ = r;
 646.223 -
 646.224 -    *start++ = b;
 646.225 -    *start++ = g;
 646.226 -    *start++ = r;
 646.227 -
 646.228 -    *start++ = b;
 646.229 -    *start++ = g;
 646.230 -    *start++ = r;
 646.231 -
 646.232 -    *start++ = b;
 646.233 -    *start++ = g;
 646.234 -    *start++ = r;
 646.235 -
 646.236 -    *start++ = b;
 646.237 -    *start++ = g;
 646.238 -    *start++ = r;
 646.239 -
 646.240 -    *start++ = b;
 646.241 -    *start++ = g;
 646.242 -    *start++ = r;
 646.243 -
 646.244 -    *start++ = b;
 646.245 -    *start++ = g;
 646.246 -    *start++ = r;
 646.247 -
 646.248 -    *start++ = b;
 646.249 -    *start++ = g;
 646.250 -    *start++ = r;
 646.251 -
 646.252 -    *start++ = b;
 646.253 -    *start++ = g;
 646.254 -    *start++ = r;
 646.255 -    
 646.256 -    start += skip;
 646.257 -  }
 646.258 -}
 646.259 -
 646.260 -void PaletteViewControl::refresh()
 646.261 -{
 646.262 -  updatePalette();
 646.263 -  int sw = w/16;
 646.264 -  int sh = h/16;
 646.265 -  for(int i = 0; i < colors; i++) {
 646.266 -    render(palette[i], i & (sw-1), i/sw);
 646.267 -  }
 646.268 -  InvalidateRect(NULL, FALSE);
 646.269 -}
 646.270 -
 646.271 -void PaletteViewControl::OnLButtonDown(UINT nFlags, CPoint point) 
 646.272 -{
 646.273 -  int x = point.x;
 646.274 -  int y = point.y;
 646.275 -  RECT rect;
 646.276 -  GetClientRect(&rect);
 646.277 -  int h = rect.bottom - rect.top;
 646.278 -  int w = rect.right - rect.left;
 646.279 -  int sw = (this->w/16);
 646.280 -  int sh = (this->h/16);
 646.281 -  int mult = w / sw;
 646.282 -  int multY = h / sh;
 646.283 -
 646.284 -  setSelected(x/mult + (y/multY)*sw);
 646.285 -  
 646.286 -  GetParent()->SendMessage(WM_PALINFO,
 646.287 -                           palette[x/mult+(y/multY)*sw],
 646.288 -                           paletteAddress+(x/mult+(y/multY)*sw));
 646.289 -}
 646.290 -
 646.291 -BOOL PaletteViewControl::OnEraseBkgnd(CDC* pDC) 
 646.292 -{
 646.293 -  return TRUE;
 646.294 -}
 646.295 -
 646.296 -
 646.297 -void PaletteViewControl::OnPaint() 
 646.298 -{
 646.299 -  CPaintDC dc(this); // device context for painting
 646.300 -  
 646.301 -  RECT rect;
 646.302 -  GetClientRect(&rect);
 646.303 -  int w = rect.right - rect.left;
 646.304 -  int h = rect.bottom - rect.top;
 646.305 -  
 646.306 -  CDC memDC;
 646.307 -  memDC.CreateCompatibleDC(&dc);
 646.308 -  CBitmap bitmap, *pOldBitmap;
 646.309 -  bitmap.CreateCompatibleBitmap(&dc, w, h);
 646.310 -  pOldBitmap = memDC.SelectObject(&bitmap);
 646.311 -  
 646.312 -  StretchDIBits(memDC.GetSafeHdc(),
 646.313 -                0,
 646.314 -                0,
 646.315 -                w,
 646.316 -                h,
 646.317 -                0,
 646.318 -                0,
 646.319 -                this->w,
 646.320 -                this->h,
 646.321 -                data,
 646.322 -                &bmpInfo,
 646.323 -                DIB_RGB_COLORS,
 646.324 -                SRCCOPY);
 646.325 -  int sw = this->w / 16;
 646.326 -  int sh = this->h / 16;
 646.327 -  int mult  = w / sw;
 646.328 -  int multY = h / sh;
 646.329 -  CPen pen;
 646.330 -  pen.CreatePen(PS_SOLID, 1, RGB(192,192,192));
 646.331 -  CPen *old = memDC.SelectObject(&pen);
 646.332 -  int i;
 646.333 -  for(i = 1; i < sh; i++) {
 646.334 -    memDC.MoveTo(0, i * multY);
 646.335 -    memDC.LineTo(w, i * multY);
 646.336 -  }
 646.337 -  for(i = 1; i < sw; i++) {
 646.338 -    memDC.MoveTo(i * mult, 0);
 646.339 -    memDC.LineTo(i * mult, h);
 646.340 -  }
 646.341 -  memDC.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
 646.342 -  memDC.SelectObject(old);
 646.343 -  pen.DeleteObject();
 646.344 -
 646.345 -  if(selected != -1) {
 646.346 -    pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
 646.347 -    old = memDC.SelectObject(&pen);
 646.348 -
 646.349 -    int startX = (selected & (sw-1))*mult+1;
 646.350 -    int startY = (selected / sw)*multY+1;
 646.351 -    int endX = startX + mult-2;
 646.352 -    int endY = startY + multY-2;
 646.353 -    
 646.354 -    memDC.MoveTo(startX, startY);
 646.355 -    memDC.LineTo(endX, startY);
 646.356 -    memDC.LineTo(endX, endY);
 646.357 -    memDC.LineTo(startX, endY);
 646.358 -    memDC.LineTo(startX, startY-1);
 646.359 -
 646.360 -    memDC.SelectObject(old);
 646.361 -    pen.DeleteObject();
 646.362 -  }
 646.363 -  
 646.364 -  dc.BitBlt(0,0,w,h,
 646.365 -            &memDC,0,0,SRCCOPY);
 646.366 -
 646.367 -  memDC.SelectObject(pOldBitmap);
 646.368 -  bitmap.DeleteObject();
 646.369 -  memDC.DeleteDC();
 646.370 -}
 646.371 -
 646.372 -void PaletteViewControl::registerClass()
 646.373 -{
 646.374 -  if(!isRegistered) {
 646.375 -    WNDCLASS wc;
 646.376 -    ZeroMemory(&wc, sizeof(wc));
 646.377 -    wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
 646.378 -    wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
 646.379 -    wc.hInstance = AfxGetInstanceHandle();
 646.380 -    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
 646.381 -    wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
 646.382 -    wc.lpszMenuName = NULL;
 646.383 -    wc.lpszClassName = "VbaPaletteViewControl";
 646.384 -    AfxRegisterClass(&wc);
 646.385 -    isRegistered = true;
 646.386 -  }
 646.387 -}
   647.1 --- a/src/win32/PaletteViewControl.h	Sat Mar 03 10:54:39 2012 -0600
   647.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   647.3 @@ -1,71 +0,0 @@
   647.4 -#if !defined(AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_)
   647.5 -#define AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_
   647.6 -
   647.7 -#if _MSC_VER > 1000
   647.8 -#pragma once
   647.9 -#endif // _MSC_VER > 1000
  647.10 -// PaletteViewControl.h : header file
  647.11 -//
  647.12 -#define WM_PALINFO WM_APP+1
  647.13 -
  647.14 -/////////////////////////////////////////////////////////////////////////////
  647.15 -// PaletteViewControl window
  647.16 -
  647.17 -class PaletteViewControl : public CWnd
  647.18 -{
  647.19 -  int w;
  647.20 -  int h;
  647.21 -  int colors;
  647.22 -  u8 *data;
  647.23 -  BITMAPINFO bmpInfo;
  647.24 -  static bool isRegistered;
  647.25 -  int selected;
  647.26 - protected:
  647.27 -  u16 palette[256];
  647.28 -  int paletteAddress;  
  647.29 -  // Construction
  647.30 - public:
  647.31 -  PaletteViewControl();
  647.32 -
  647.33 -  virtual void updatePalette()=0;
  647.34 -
  647.35 -  // Attributes
  647.36 - public:
  647.37 -
  647.38 -  // Operations
  647.39 - public:
  647.40 -
  647.41 -  // Overrides
  647.42 -  // ClassWizard generated virtual function overrides
  647.43 -  //{{AFX_VIRTUAL(PaletteViewControl)
  647.44 -  //}}AFX_VIRTUAL
  647.45 -
  647.46 -  // Implementation
  647.47 - public:
  647.48 -  void registerClass();
  647.49 -  void refresh();
  647.50 -  void render(u16 color, int x, int y);
  647.51 -  void setSelected(int s);
  647.52 -  void setPaletteAddress(int address);
  647.53 -  bool saveJASCPAL(const char *name);
  647.54 -  bool saveMSPAL(const char *name);
  647.55 -  bool saveAdobe(const char *name);
  647.56 -  void init(int c, int w, int h);
  647.57 -  virtual ~PaletteViewControl();
  647.58 -
  647.59 -  // Generated message map functions
  647.60 - protected:
  647.61 -  //{{AFX_MSG(PaletteViewControl)
  647.62 -  afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  647.63 -  afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  647.64 -  afx_msg void OnPaint();
  647.65 -  //}}AFX_MSG
  647.66 -  DECLARE_MESSAGE_MAP()
  647.67 -    };
  647.68 -
  647.69 -    /////////////////////////////////////////////////////////////////////////////
  647.70 -
  647.71 -//{{AFX_INSERT_LOCATION}}
  647.72 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  647.73 -
  647.74 -#endif // !defined(AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_)
   648.1 --- a/src/win32/PerfTimer.cpp	Sat Mar 03 10:54:39 2012 -0600
   648.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   648.3 @@ -1,35 +0,0 @@
   648.4 -// CPerfTimer - a simple Win32 performance counter wrapper
   648.5 -// by Dean Wyant dwyant@mindspring.com
   648.6 -
   648.7 -#include "stdafx.h"
   648.8 -#include "PerfTimer.h"
   648.9 -
  648.10 -// Declare and initialize static member vars that get set only once and never change
  648.11 -__int64 CPerfTimer::m_Freq = 0; 
  648.12 -__int64 CPerfTimer::m_Adjust = 0; 
  648.13 -
  648.14 -// All functions defined inline for speed. After all, the performance counter is 
  648.15 -// supposed to be able to time very short events fairly accurately.
  648.16 -
  648.17 -
  648.18 -
  648.19 -BOOL CPerfTimer::IsSupported()
  648.20 -{ // Returns FALSE if performance counter not supported.
  648.21 -	// Call after constructing at least one CPerfTimer
  648.22 -	return (m_Freq > 1);
  648.23 -}
  648.24 -
  648.25 -const double CPerfTimer::Resolution()   
  648.26 -{ // Returns timer resolution in seconds
  648.27 -	return 1.0/(double)m_Freq; 
  648.28 -}
  648.29 -
  648.30 -const double CPerfTimer::Resolutionms() 
  648.31 -{ // Returns timer resolution in milliseconds
  648.32 -	return 1000.0/(double)m_Freq; 
  648.33 -}
  648.34 -
  648.35 -const double CPerfTimer::Resolutionus() 
  648.36 -{ // Returns timer resolution in microseconds
  648.37 -	return 1000000.0/(double)m_Freq; 
  648.38 -}
   649.1 --- a/src/win32/PerfTimer.h	Sat Mar 03 10:54:39 2012 -0600
   649.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   649.3 @@ -1,403 +0,0 @@
   649.4 -// CPerfTimer - a simple Win32 performance counter wrapper
   649.5 -// by Dean Wyant dwyant@mindspring.com
   649.6 -
   649.7 -/*
   649.8 -
   649.9 -This class is simple to use. Just declare a variable(s) as type CPerfTimer,
  649.10 -call Start() to start timimg and call Stop() to stop timimg. You can pause a
  649.11 -timer by calling Stop() and then you can call Start() to resume. Retrieve the
  649.12 -elapsed time by calling an Elapsed..() function. Assignment, addition, 
  649.13 -subtraction and comparison are supported. There are a few information calls
  649.14 -available also. All calls except Start and Stop can be performed on a timer
  649.15 -without stopping it.
  649.16 -
  649.17 -*/
  649.18 -
  649.19 -#ifndef __PERFTIMER_H__
  649.20 -#define __PERFTIMER_H__
  649.21 -
  649.22 -class CPerfTimer
  649.23 -{
  649.24 -public:
  649.25 -	CPerfTimer(BOOL bStart = FALSE) {Init(bStart);}
  649.26 -
  649.27 -	CPerfTimer(const CPerfTimer& Src); 
  649.28 -
  649.29 -	virtual ~CPerfTimer() {;}
  649.30 -
  649.31 -	void Start(BOOL bReset = FALSE);   // Start from current value or optionally from 0
  649.32 -	void Stop();                       // Stop timing. Use Start afterwards to continue.
  649.33 -
  649.34 -	BOOL IsRunning();                  // Returns FALSE if stopped.
  649.35 -
  649.36 -	BOOL IsSupported();                // Returns FALSE if performance counter not supported.
  649.37 -	// Call after constructing at least one CPerfTimer
  649.38 -
  649.39 -	const double Resolution();         // Returns timer resolution in seconds
  649.40 -	const double Resolutionms();       // Returns timer resolution in milliseconds
  649.41 -	const double Resolutionus();       // Returns timer resolution in microseconds
  649.42 -
  649.43 -	const double Elapsed();            // Returns elapsed time in seconds
  649.44 -	const double Elapsedms();          // Returns elapsed time in milliseconds 
  649.45 -	const double Elapsedus();          // Returns elapsed time in microseconds
  649.46 -
  649.47 -	const CPerfTimer& operator=(const CPerfTimer& Src); // Assignment operator 
  649.48 -
  649.49 -	// Math operators
  649.50 -	CPerfTimer operator+(const CPerfTimer& Src) const;
  649.51 -	CPerfTimer operator-(const CPerfTimer& Src) const;
  649.52 -	const CPerfTimer& operator+=(const CPerfTimer& Src);
  649.53 -	const CPerfTimer& operator-=(const CPerfTimer& Src);
  649.54 -	// For time in seconds
  649.55 -	CPerfTimer operator+(const double Secs) const;
  649.56 -	CPerfTimer operator-(const double Secs) const;
  649.57 -	const CPerfTimer& operator+=(const double Secs);
  649.58 -	const CPerfTimer& operator-=(const double Secs);
  649.59 -
  649.60 -	// Boolean comparison operators
  649.61 -	BOOL operator<(const CPerfTimer& Src);
  649.62 -	BOOL operator>(const CPerfTimer& Src);
  649.63 -	BOOL operator<=(const CPerfTimer& Src);
  649.64 -	BOOL operator>=(const CPerfTimer& Src);
  649.65 -	// For time in seconds
  649.66 -	BOOL operator<(const double Secs);
  649.67 -	BOOL operator>(const double Secs);
  649.68 -	BOOL operator<=(const double Secs);
  649.69 -	BOOL operator>=(const double Secs);
  649.70 -
  649.71 -	virtual void Lock() const {;}     // Override for thread safe operation
  649.72 -	virtual void Unlock() const {;}     // Override for thread safe operation
  649.73 -protected:
  649.74 -	void Init(BOOL bStart);
  649.75 -	void Copy(const CPerfTimer& Src);
  649.76 -
  649.77 -private:
  649.78 -	__int64 m_Start;
  649.79 -	static __int64 m_Freq;   // does not change while system is running
  649.80 -	static __int64 m_Adjust; // Adjustment time it takes to Start and Stop
  649.81 -};
  649.82 -
  649.83 -class CPerfTimerT : public CPerfTimer
  649.84 -{ // You only need to use types of this class if a timer is going to be shared between threads
  649.85 -public:
  649.86 -	CPerfTimerT(BOOL bStart = FALSE)
  649.87 -	{
  649.88 -		m_hMutex = CreateMutex(NULL,FALSE,"");
  649.89 -		Init(bStart);
  649.90 -	}
  649.91 -
  649.92 -	CPerfTimerT(const CPerfTimerT& Src) 
  649.93 -	{ 
  649.94 -		m_hMutex = CreateMutex(NULL,FALSE,"");
  649.95 -		Copy(Src); 
  649.96 -	}
  649.97 -
  649.98 -	CPerfTimerT(const CPerfTimer& Src) 
  649.99 -	{ 
 649.100 -		m_hMutex = CreateMutex(NULL,FALSE,"");
 649.101 -		Copy(Src); 
 649.102 -	}
 649.103 -
 649.104 -	virtual ~CPerfTimerT() 
 649.105 -	{ CloseHandle(m_hMutex); }
 649.106 -
 649.107 -	const CPerfTimerT& operator=(const CPerfTimerT& Src) // Assignment operator 
 649.108 -	{
 649.109 -		Copy(Src);
 649.110 -		return *this; 
 649.111 -	}
 649.112 -
 649.113 -	virtual void Lock() const { WaitForSingleObject(m_hMutex,10000); }   
 649.114 -	virtual void Unlock() const { ReleaseMutex(m_hMutex); }   
 649.115 -private:
 649.116 -	HANDLE m_hMutex;
 649.117 -};
 649.118 -
 649.119 -inline void CPerfTimer::Init(BOOL bStart)
 649.120 -{
 649.121 -	if (!m_Freq) 
 649.122 -	{ // Initialization should only run once
 649.123 -		QueryPerformanceFrequency((LARGE_INTEGER *)&m_Freq); 
 649.124 -		if (!m_Freq)
 649.125 -			m_Freq = 1; // Timer will be useless but will not cause divide by zero
 649.126 -		m_Start = 0; 
 649.127 -		m_Adjust = 0; 
 649.128 -		Start();            // Time a Stop
 649.129 -		Stop(); 
 649.130 -		m_Adjust = m_Start;
 649.131 -	}
 649.132 -	// This is the only part that normally runs
 649.133 -	m_Start = 0; 
 649.134 -	if (bStart)
 649.135 -		Start(); 
 649.136 -}
 649.137 -
 649.138 -inline CPerfTimer::CPerfTimer(const CPerfTimer& Src)  
 649.139 -{
 649.140 -	Copy(Src);
 649.141 -}
 649.142 -
 649.143 -inline void CPerfTimer::Copy(const CPerfTimer& Src)
 649.144 -{
 649.145 -	if (&Src == this) 
 649.146 -		return; // avoid deadlock if someone tries to copy it to itself
 649.147 -	Src.Lock();
 649.148 -	Lock();
 649.149 -	m_Start = Src.m_Start; 
 649.150 -	Unlock();
 649.151 -	Src.Unlock();
 649.152 -}
 649.153 -
 649.154 -inline void CPerfTimer::Start(BOOL bReset) 
 649.155 -{ // Start from current value or optionally from 0
 649.156 -	__int64 i;
 649.157 -	QueryPerformanceCounter((LARGE_INTEGER *)&i);
 649.158 -	Lock();
 649.159 -	if ((!bReset) && (m_Start < 0))
 649.160 -		m_Start += i;   // We are starting with an accumulated time
 649.161 -	else 
 649.162 -		m_Start = i;    // Starting from 0
 649.163 -	Unlock();
 649.164 -} 
 649.165 -
 649.166 -inline void CPerfTimer::Stop() 
 649.167 -{ // Stop timing. Use Start afterwards to continue
 649.168 -	Lock();
 649.169 -	if (m_Start <= 0)
 649.170 -	{
 649.171 -		Unlock();
 649.172 -		return;          // Was not running
 649.173 -	}
 649.174 -	__int64 i;
 649.175 -	QueryPerformanceCounter((LARGE_INTEGER *)&i); 
 649.176 -	m_Start += -i;          // Stopped timer keeps elapsed timer ticks as a negative 
 649.177 -	if (m_Start < m_Adjust) // Do not overflow
 649.178 -		m_Start -= m_Adjust;  // Adjust for time timer code takes to run
 649.179 -	else 
 649.180 -		m_Start = 0;          // Stop must have been called directly after Start
 649.181 -	Unlock();
 649.182 -} 
 649.183 -
 649.184 -inline BOOL CPerfTimer::IsRunning() 
 649.185 -{ // Returns FALSE if stopped.
 649.186 -	Lock();
 649.187 -	BOOL bRet = (m_Start > 0); // When < 0, holds elpased clicks
 649.188 -	Unlock();
 649.189 -	return bRet;   
 649.190 -}
 649.191 -inline const double CPerfTimer::Elapsed()
 649.192 -{ // Returns elapsed time in seconds
 649.193 -	CPerfTimer Result(*this);
 649.194 -	Result.Stop();
 649.195 -	return (double)(-Result.m_Start)/(double)m_Freq; 
 649.196 -}
 649.197 -
 649.198 -inline const double CPerfTimer::Elapsedms() 
 649.199 -{ // Returns elapsed time in milliseconds
 649.200 -	CPerfTimer Result(*this);
 649.201 -	Result.Stop();
 649.202 -	return (-Result.m_Start*1000.0)/(double)m_Freq; 
 649.203 -}
 649.204 -
 649.205 -inline const double CPerfTimer::Elapsedus() 
 649.206 -{ // Returns elapsed time in microseconds
 649.207 -	CPerfTimer Result(*this);
 649.208 -
 649.209 -	return (-Result.m_Start * 1000000.0)/(double)m_Freq; 
 649.210 -}
 649.211 -
 649.212 -
 649.213 -// Assignment operator
 649.214 -inline const CPerfTimer& CPerfTimer::operator=(const CPerfTimer& Src) 
 649.215 -{
 649.216 -	Copy(Src);
 649.217 -	return *this; 
 649.218 -}
 649.219 -
 649.220 -
 649.221 -// Math operators
 649.222 -inline CPerfTimer CPerfTimer::operator+(const CPerfTimer& Src) const
 649.223 -{
 649.224 -	CPerfTimer Result(*this);
 649.225 -	Result += Src; 
 649.226 -	return Result; 
 649.227 -}
 649.228 -
 649.229 -inline CPerfTimer CPerfTimer::operator-(const CPerfTimer& Src) const
 649.230 -{
 649.231 -	CPerfTimer Result(*this);
 649.232 -	Result -= Src; 
 649.233 -	return Result; 
 649.234 -}
 649.235 -
 649.236 -inline const CPerfTimer& CPerfTimer::operator+=(const CPerfTimer& Src)
 649.237 -{
 649.238 -	CPerfTimer SrcStop(Src);  // Temp is necessary in case Src is not stopped
 649.239 -	SrcStop.Stop();
 649.240 -	Lock();
 649.241 -	m_Start += SrcStop.m_Start;
 649.242 -	Unlock();
 649.243 -	return *this; 
 649.244 -}
 649.245 -
 649.246 -inline const CPerfTimer& CPerfTimer::operator-=(const CPerfTimer& Src)
 649.247 -{
 649.248 -	CPerfTimer SrcStop(Src);  // Temp is necessary in case Src is not stopped
 649.249 -	SrcStop.Stop();
 649.250 -	Lock();
 649.251 -	m_Start -= SrcStop.m_Start; 
 649.252 -	Unlock();
 649.253 -	return *this; 
 649.254 -}
 649.255 -
 649.256 -// For time in seconds
 649.257 -inline CPerfTimer CPerfTimer::operator+(const double Secs) const
 649.258 -{
 649.259 -	CPerfTimer Result(*this);
 649.260 -	Result += Secs; 
 649.261 -	return Result; 
 649.262 -}
 649.263 -
 649.264 -inline CPerfTimer CPerfTimer::operator-(const double Secs) const
 649.265 -{
 649.266 -	CPerfTimer Result(*this);
 649.267 -	Result += Secs; 
 649.268 -	return Result; 
 649.269 -}
 649.270 -
 649.271 -inline const CPerfTimer& CPerfTimer::operator+=(const double Secs)
 649.272 -{
 649.273 -	Lock();
 649.274 -	m_Start -= (__int64)(Secs*(double)m_Freq);
 649.275 -	Unlock();
 649.276 -	return *this; 
 649.277 -}
 649.278 -
 649.279 -inline const CPerfTimer& CPerfTimer::operator-=(const double Secs)
 649.280 -{
 649.281 -	Lock();
 649.282 -	m_Start += (__int64)(Secs*(double)m_Freq);
 649.283 -	Unlock();
 649.284 -	return *this; 
 649.285 -}
 649.286 -
 649.287 -
 649.288 -
 649.289 -// Boolean comparison operators
 649.290 -inline BOOL CPerfTimer::operator<(const CPerfTimer& Src)
 649.291 -{ 
 649.292 -	BOOL bRet; 
 649.293 -	CPerfTimer Temp(Src);
 649.294 -	Lock();
 649.295 -	if (m_Start <= 0)
 649.296 -	{
 649.297 -		Temp.Stop();
 649.298 -		bRet = (m_Start > Temp.m_Start); 
 649.299 -		Unlock();
 649.300 -		return bRet;
 649.301 -	}
 649.302 -	else
 649.303 -		if (Temp.m_Start > 0)
 649.304 -		{
 649.305 -			bRet = (m_Start < Temp.m_Start); 
 649.306 -			Unlock();
 649.307 -			return bRet;
 649.308 -		}
 649.309 -		else
 649.310 -		{
 649.311 -			Unlock();
 649.312 -			CPerfTimer ThisStop(*this);
 649.313 -			ThisStop.Stop();
 649.314 -			return (ThisStop.m_Start > Temp.m_Start); 
 649.315 -		}
 649.316 -}
 649.317 -
 649.318 -inline BOOL CPerfTimer::operator>(const CPerfTimer& Src)
 649.319 -{ 
 649.320 -	BOOL bRet; 
 649.321 -	CPerfTimer Temp(Src);
 649.322 -	Lock();
 649.323 -	if (m_Start <= 0)
 649.324 -	{
 649.325 -		Temp.Stop();
 649.326 -		bRet = (m_Start < Temp.m_Start); 
 649.327 -		Unlock();
 649.328 -		return bRet;
 649.329 -	}
 649.330 -	else
 649.331 -		if (Temp.m_Start > 0)
 649.332 -		{
 649.333 -			bRet = (m_Start > Temp.m_Start); 
 649.334 -			Unlock();
 649.335 -			return bRet;
 649.336 -		}
 649.337 -		else
 649.338 -		{
 649.339 -			Unlock();
 649.340 -			CPerfTimer ThisStop(*this);
 649.341 -			ThisStop.Stop();
 649.342 -			return (ThisStop.m_Start < Temp.m_Start); 
 649.343 -		}
 649.344 -}
 649.345 -
 649.346 -inline BOOL CPerfTimer::operator<=(const CPerfTimer& Src)
 649.347 -{ 
 649.348 -	return !(*this > Src);
 649.349 -}
 649.350 -
 649.351 -inline BOOL CPerfTimer::operator>=(const CPerfTimer& Src)
 649.352 -{ 
 649.353 -	return !(*this < Src);
 649.354 -}
 649.355 -
 649.356 -// For time in seconds
 649.357 -inline BOOL CPerfTimer::operator<(const double Secs)
 649.358 -{ 
 649.359 -	BOOL bRet; 
 649.360 -	Lock();
 649.361 -	if (m_Start <= 0)
 649.362 -	{
 649.363 -		bRet = (m_Start > (__int64)(-Secs*(double)m_Freq)); 
 649.364 -		Unlock();
 649.365 -		return bRet;
 649.366 -	}
 649.367 -	else
 649.368 -	{
 649.369 -		Unlock();
 649.370 -		CPerfTimer ThisStop(*this);
 649.371 -		ThisStop.Stop();
 649.372 -		return (ThisStop.m_Start > (__int64)(-Secs*(double)m_Freq)); 
 649.373 -	}
 649.374 -}
 649.375 -
 649.376 -inline BOOL CPerfTimer::operator>(const double Secs)
 649.377 -{ 
 649.378 -	BOOL bRet; 
 649.379 -	Lock();
 649.380 -	if (m_Start <= 0)
 649.381 -	{
 649.382 -		bRet = (m_Start < (__int64)(-Secs*(double)m_Freq)); 
 649.383 -		Unlock();
 649.384 -		return bRet;
 649.385 -	}
 649.386 -	else
 649.387 -	{
 649.388 -		Unlock();
 649.389 -		CPerfTimer ThisStop(*this);
 649.390 -		ThisStop.Stop();
 649.391 -		return (ThisStop.m_Start < (__int64)(-Secs*(double)m_Freq)); 
 649.392 -	}
 649.393 -}
 649.394 -
 649.395 -inline BOOL CPerfTimer::operator<=(const double Secs)
 649.396 -{ 
 649.397 -	return !(*this > Secs);
 649.398 -}
 649.399 -
 649.400 -inline BOOL CPerfTimer::operator>=(const double Secs)
 649.401 -{ 
 649.402 -	return !(*this < Secs);
 649.403 -}
 649.404 -
 649.405 -
 649.406 -#endif //__PERFTIMER_H__
 649.407 \ No newline at end of file
   650.1 --- a/src/win32/Reg.cpp	Sat Mar 03 10:54:39 2012 -0600
   650.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   650.3 @@ -1,379 +0,0 @@
   650.4 -#include "stdafx.h"
   650.5 -#include "Reg.h"
   650.6 -
   650.7 -static char    buffer[2048];
   650.8 -static HKEY    vbKey = NULL;
   650.9 -static CString regVbaPath;
  650.10 -
  650.11 -#define VBA_PREF "preferences"
  650.12 -
  650.13 -bool regEnabled = true;
  650.14 -
  650.15 -void regInit(const char *path)
  650.16 -{
  650.17 -	if (regEnabled)
  650.18 -	{
  650.19 -		DWORD disp = 0;
  650.20 -		LONG  res  = RegCreateKeyEx(HKEY_CURRENT_USER,
  650.21 -	                            "Software\\Emulators\\VisualBoyAdvance",
  650.22 -	                            0,
  650.23 -	                            "",
  650.24 -	                            REG_OPTION_NON_VOLATILE,
  650.25 -	                            KEY_ALL_ACCESS,
  650.26 -	                            NULL,
  650.27 -	                            &vbKey,
  650.28 -	                            &disp);
  650.29 -	}
  650.30 -	regVbaPath.Format("%s\\vba.ini", path);
  650.31 -}
  650.32 -
  650.33 -void regShutdown()
  650.34 -{
  650.35 -	LONG res = RegCloseKey(vbKey);
  650.36 -}
  650.37 -
  650.38 -const char *regGetINIPath()
  650.39 -{
  650.40 -	return regVbaPath;
  650.41 -}
  650.42 -
  650.43 -const char *regQueryStringValue(const char *key, const char *def)
  650.44 -{
  650.45 -	if (regEnabled)
  650.46 -	{
  650.47 -		DWORD type = 0;
  650.48 -		DWORD size = 2048;
  650.49 -
  650.50 -		LONG res = RegQueryValueEx(vbKey,
  650.51 -		                           key,
  650.52 -		                           NULL,
  650.53 -		                           &type,
  650.54 -		                           (UCHAR *)buffer,
  650.55 -		                           &size);
  650.56 -
  650.57 -		if (res == ERROR_SUCCESS && type == REG_SZ)
  650.58 -			return buffer;
  650.59 -
  650.60 -		return def;
  650.61 -	}
  650.62 -
  650.63 -	DWORD res = GetPrivateProfileString(VBA_PREF,
  650.64 -	                                    key,
  650.65 -	                                    def,
  650.66 -	                                    (LPTSTR)buffer,
  650.67 -	                                    2048,
  650.68 -	                                    regVbaPath);
  650.69 -
  650.70 -	if (res)
  650.71 -		return buffer;
  650.72 -
  650.73 -	return def;
  650.74 -}
  650.75 -
  650.76 -DWORD regQueryDwordValue(const char *key, DWORD def, bool force)
  650.77 -{
  650.78 -	if (regEnabled || force)
  650.79 -	{
  650.80 -		DWORD type   = 0;
  650.81 -		DWORD size   = sizeof(DWORD);
  650.82 -		DWORD result = 0;
  650.83 -
  650.84 -		LONG res = RegQueryValueEx(vbKey,
  650.85 -		                           key,
  650.86 -		                           NULL,
  650.87 -		                           &type,
  650.88 -		                           (UCHAR *)&result,
  650.89 -		                           &size);
  650.90 -
  650.91 -		if (res == ERROR_SUCCESS && type == REG_DWORD)
  650.92 -			return result;
  650.93 -
  650.94 -		return def;
  650.95 -	}
  650.96 -
  650.97 -	return GetPrivateProfileInt(VBA_PREF,
  650.98 -	                            key,
  650.99 -	                            def,
 650.100 -	                            regVbaPath);
 650.101 -}
 650.102 -
 650.103 -BOOL regQueryBinaryValue(const char *key, char *value, int count)
 650.104 -{
 650.105 -	if (regEnabled)
 650.106 -	{
 650.107 -		DWORD type   = 0;
 650.108 -		DWORD size   = count;
 650.109 -		DWORD result = 0;
 650.110 -
 650.111 -		LONG res = RegQueryValueEx(vbKey,
 650.112 -		                           key,
 650.113 -		                           NULL,
 650.114 -		                           &type,
 650.115 -		                           (UCHAR *)value,
 650.116 -		                           &size);
 650.117 -
 650.118 -		if (res == ERROR_SUCCESS && type == REG_BINARY)
 650.119 -			return TRUE;
 650.120 -
 650.121 -		return FALSE;
 650.122 -	}
 650.123 -	CString k = key;
 650.124 -	k += "Count";
 650.125 -	int size = GetPrivateProfileInt(VBA_PREF,
 650.126 -	                                k,
 650.127 -	                                -1,
 650.128 -	                                regVbaPath);
 650.129 -	if (size >= 0 && size < count)
 650.130 -		count = size;
 650.131 -	return GetPrivateProfileStruct(VBA_PREF,
 650.132 -	                               key,
 650.133 -	                               value,
 650.134 -	                               count,
 650.135 -	                               regVbaPath);
 650.136 -}
 650.137 -
 650.138 -void regSetStringValue(const char *key, const char *value)
 650.139 -{
 650.140 -	if (regEnabled)
 650.141 -	{
 650.142 -		LONG res = RegSetValueEx(vbKey,
 650.143 -		                         key,
 650.144 -		                         NULL,
 650.145 -		                         REG_SZ,
 650.146 -		                         (const UCHAR *)value,
 650.147 -		                         strlen(value)+1);
 650.148 -	}
 650.149 -	else
 650.150 -	{
 650.151 -		WritePrivateProfileString(VBA_PREF,
 650.152 -		                          key,
 650.153 -		                          value,
 650.154 -		                          regVbaPath);
 650.155 -	}
 650.156 -}
 650.157 -
 650.158 -void regSetDwordValue(const char *key, DWORD value, bool force)
 650.159 -{
 650.160 -	if (regEnabled || force)
 650.161 -	{
 650.162 -		LONG res = RegSetValueEx(vbKey,
 650.163 -		                         key,
 650.164 -		                         NULL,
 650.165 -		                         REG_DWORD,
 650.166 -		                         (const UCHAR *)&value,
 650.167 -		                         sizeof(DWORD));
 650.168 -	}
 650.169 -	else
 650.170 -	{
 650.171 -		wsprintf(buffer, "%u", value);
 650.172 -		WritePrivateProfileString(VBA_PREF,
 650.173 -		                          key,
 650.174 -		                          buffer,
 650.175 -		                          regVbaPath);
 650.176 -	}
 650.177 -}
 650.178 -
 650.179 -void regSetBinaryValue(const char *key, char *value, int count)
 650.180 -{
 650.181 -	if (regEnabled)
 650.182 -	{
 650.183 -		LONG res = RegSetValueEx(vbKey,
 650.184 -		                         key,
 650.185 -		                         NULL,
 650.186 -		                         REG_BINARY,
 650.187 -		                         (const UCHAR *)value,
 650.188 -		                         count);
 650.189 -	}
 650.190 -	else
 650.191 -	{
 650.192 -		CString k = key;
 650.193 -		k += "Count";
 650.194 -		wsprintf(buffer, "%u", count);
 650.195 -
 650.196 -		WritePrivateProfileString(VBA_PREF,
 650.197 -		                          k,
 650.198 -		                          buffer,
 650.199 -		                          regVbaPath);
 650.200 -
 650.201 -		WritePrivateProfileStruct(VBA_PREF,
 650.202 -		                          key,
 650.203 -		                          value,
 650.204 -		                          count,
 650.205 -		                          regVbaPath);
 650.206 -	}
 650.207 -}
 650.208 -
 650.209 -void regDeleteValue(const char *key)
 650.210 -{
 650.211 -	if (regEnabled)
 650.212 -	{
 650.213 -		LONG res = RegDeleteValue(vbKey,
 650.214 -		                          key);
 650.215 -	}
 650.216 -	else
 650.217 -	{
 650.218 -		WritePrivateProfileString(VBA_PREF,
 650.219 -		                          key,
 650.220 -		                          NULL,
 650.221 -		                          regVbaPath);
 650.222 -	}
 650.223 -}
 650.224 -
 650.225 -bool regCreateFileType(const char *ext, const char *type)
 650.226 -{
 650.227 -	DWORD disp = 0;
 650.228 -	HKEY  key;
 650.229 -	LONG  res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
 650.230 -	                           ext,
 650.231 -	                           0,
 650.232 -	                           "",
 650.233 -	                           REG_OPTION_NON_VOLATILE,
 650.234 -	                           KEY_ALL_ACCESS,
 650.235 -	                           NULL,
 650.236 -	                           &key,
 650.237 -	                           &disp);
 650.238 -	if (res == ERROR_SUCCESS)
 650.239 -	{
 650.240 -		res = RegSetValueEx(key,
 650.241 -		                    "",
 650.242 -		                    0,
 650.243 -		                    REG_SZ,
 650.244 -		                    (const UCHAR *)type,
 650.245 -		                    strlen(type)+1);
 650.246 -		RegCloseKey(key);
 650.247 -		return true;
 650.248 -	}
 650.249 -	return false;
 650.250 -}
 650.251 -
 650.252 -bool regAssociateType(const char *type, const char *desc, const char *application)
 650.253 -{
 650.254 -	DWORD disp = 0;
 650.255 -	HKEY  key;
 650.256 -	LONG  res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
 650.257 -	                           type,
 650.258 -	                           0,
 650.259 -	                           "",
 650.260 -	                           REG_OPTION_NON_VOLATILE,
 650.261 -	                           KEY_ALL_ACCESS,
 650.262 -	                           NULL,
 650.263 -	                           &key,
 650.264 -	                           &disp);
 650.265 -	if (res == ERROR_SUCCESS)
 650.266 -	{
 650.267 -		res = RegSetValueEx(key,
 650.268 -		                    "",
 650.269 -		                    0,
 650.270 -		                    REG_SZ,
 650.271 -		                    (const UCHAR *)desc,
 650.272 -		                    strlen(desc)+1);
 650.273 -		HKEY key2;
 650.274 -		res = RegCreateKeyEx(key,
 650.275 -		                     "Shell\\Open\\Command",
 650.276 -		                     0,
 650.277 -		                     "",
 650.278 -		                     REG_OPTION_NON_VOLATILE,
 650.279 -		                     KEY_ALL_ACCESS,
 650.280 -		                     NULL,
 650.281 -		                     &key2,
 650.282 -		                     &disp);
 650.283 -		if (res == ERROR_SUCCESS)
 650.284 -		{
 650.285 -			res = RegSetValueEx(key2,
 650.286 -			                    "",
 650.287 -			                    0,
 650.288 -			                    REG_SZ,
 650.289 -			                    (const UCHAR *)application,
 650.290 -			                    strlen(application)+1);
 650.291 -			RegCloseKey(key2);
 650.292 -			RegCloseKey(key);
 650.293 -			return true;
 650.294 -		}
 650.295 -
 650.296 -		RegCloseKey(key);
 650.297 -	}
 650.298 -	return false;
 650.299 -}
 650.300 -
 650.301 -static void regExportSettingsToINI(HKEY key, const char *section)
 650.302 -{
 650.303 -	char valueName[256];
 650.304 -	int  index = 0;
 650.305 -	while (1)
 650.306 -	{
 650.307 -		DWORD nameSize = 256;
 650.308 -		DWORD size     = 2048;
 650.309 -		DWORD type;
 650.310 -		LONG  res = RegEnumValue(key,
 650.311 -		                         index,
 650.312 -		                         valueName,
 650.313 -		                         &nameSize,
 650.314 -		                         NULL,
 650.315 -		                         &type,
 650.316 -		                         (LPBYTE)buffer,
 650.317 -		                         &size);
 650.318 -
 650.319 -		if (res == ERROR_SUCCESS)
 650.320 -		{
 650.321 -			switch (type)
 650.322 -			{
 650.323 -			case REG_DWORD:
 650.324 -			{
 650.325 -				char temp[256];
 650.326 -				wsprintf(temp, "%u", *((DWORD *)buffer));
 650.327 -				WritePrivateProfileString(section,
 650.328 -				                          valueName,
 650.329 -				                          temp,
 650.330 -				                          regVbaPath);
 650.331 -				break;
 650.332 -			}
 650.333 -			case REG_SZ:
 650.334 -				WritePrivateProfileString(section,
 650.335 -				                          valueName,
 650.336 -				                          buffer,
 650.337 -				                          regVbaPath);
 650.338 -				break;
 650.339 -			case REG_BINARY:
 650.340 -			{
 650.341 -				char temp[256];
 650.342 -
 650.343 -				wsprintf(temp, "%u", size);
 650.344 -				CString k = valueName;
 650.345 -				k += "Count";
 650.346 -				WritePrivateProfileString(section,
 650.347 -				                          k,
 650.348 -				                          temp,
 650.349 -				                          regVbaPath);
 650.350 -				WritePrivateProfileStruct(section,
 650.351 -				                          valueName,
 650.352 -				                          buffer,
 650.353 -				                          size,
 650.354 -				                          regVbaPath);
 650.355 -				break;
 650.356 -			}
 650.357 -			}
 650.358 -			index++;
 650.359 -		}
 650.360 -		else
 650.361 -			break;
 650.362 -	}
 650.363 -}
 650.364 -
 650.365 -void regExportSettingsToINI()
 650.366 -{
 650.367 -	if (vbKey != NULL)
 650.368 -	{
 650.369 -		regExportSettingsToINI(vbKey, VBA_PREF);
 650.370 -	}
 650.371 -
 650.372 -	HKEY key;
 650.373 -
 650.374 -	if (RegOpenKey(HKEY_CURRENT_USER,
 650.375 -	               "Software\\Emulators\\VisualBoyAdvance\\Viewer", &key) ==
 650.376 -	    ERROR_SUCCESS)
 650.377 -	{
 650.378 -		regExportSettingsToINI(key, "Viewer");
 650.379 -		RegCloseKey(key);
 650.380 -	}
 650.381 -}
 650.382 -
   651.1 --- a/src/win32/Reg.h	Sat Mar 03 10:54:39 2012 -0600
   651.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   651.3 @@ -1,18 +0,0 @@
   651.4 -#ifndef VBA_REG_H
   651.5 -#define VBA_REG_H
   651.6 -
   651.7 -extern bool regEnabled;
   651.8 -
   651.9 -const char *regQueryStringValue(const char *key, const char *def);
  651.10 -DWORD regQueryDwordValue(const char *key, DWORD def, bool force = false);
  651.11 -BOOL regQueryBinaryValue(const char *key, char *value, int count);
  651.12 -void regSetStringValue(const char *key, const char *value);
  651.13 -void regSetDwordValue(const char *key, DWORD value, bool force = false);
  651.14 -void regSetBinaryValue(const char *key, char *value, int count);
  651.15 -void regDeleteValue(const char *key);
  651.16 -void regInit(const char *);
  651.17 -void regShutdown();
  651.18 -bool regCreateFileType(const char *ext, const char *type);
  651.19 -bool regAssociateType(const char *type, const char *desc, const char *application);
  651.20 -void regExportSettingsToINI();
  651.21 -#endif // VBA_REG_H
   652.1 --- a/src/win32/ResizeDlg.cpp	Sat Mar 03 10:54:39 2012 -0600
   652.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   652.3 @@ -1,609 +0,0 @@
   652.4 -/*----------------------------------------------------------------------
   652.5 -   Copyright (c)  Gipsysoft. All Rights Reserved.
   652.6 -   File:   DialogSizer_Set.cpp
   652.7 -   Web site: http://gipsysoft.com
   652.8 -
   652.9 -   This software is provided 'as-is', without any express or implied warranty.
  652.10 -
  652.11 -   In no event will the author be held liable for any damages arising from the
  652.12 -   use of this software.
  652.13 -
  652.14 -   Permission is granted to anyone to use this software for any purpose, including
  652.15 -   commercial applications, and to alter it and redistribute it freely, subject
  652.16 -   to the following restrictions:
  652.17 -
  652.18 -   1) The origin of this software must not be misrepresented; you must not claim
  652.19 -   that you wrote the original software. If you use this software in a product,
  652.20 -   an acknowledgment in the product documentation is requested but not required.
  652.21 -   2) Altered source versions must be plainly marked as such, and must not be
  652.22 -   misrepresented as being the original software. Altered source is encouraged
  652.23 -   to be submitted back to the original author so it can be shared with the
  652.24 -   community. Please share your changes.
  652.25 -   3) This notice may not be removed or altered from any source distribution.
  652.26 -
  652.27 -   Owner:  russf@gipsysoft.com
  652.28 -   Purpose:        Main functionality for sizeable dialogs
  652.29 -
  652.30 -   Store a local copy of the user settings
  652.31 -   Subclass the window
  652.32 -   Respond to various messages withinn the subclassed window.
  652.33 -
  652.34 -   ----------------------------------------------------------------------*/
  652.35 -// modified by the VBA-rr Team
  652.36 -
  652.37 -#include "stdafx.h"
  652.38 -#include "ResizeDlg.h"
  652.39 -#include "VBA.h"
  652.40 -#include "Sound.h"
  652.41 -#include "WinHelper.h"
  652.42 -
  652.43 -IMPLEMENT_DYNAMIC(ResizeDlg, CDialog)
  652.44 -
  652.45 -// moved functions to this file to reduce number of files
  652.46 -
  652.47 -struct RegistryData
  652.48 -{
  652.49 -	WINDOWPLACEMENT m_wpl;
  652.50 -};
  652.51 -
  652.52 -struct DialogData       //      dd
  652.53 -{
  652.54 -	HKEY    hkRootSave;
  652.55 -	LPCTSTR pcszName;
  652.56 -
  652.57 -	//
  652.58 -	//    The number of items contained in the psd member.
  652.59 -	//    Used in the DeferWindowPos structure and in allocating memory
  652.60 -	int nItemCount;
  652.61 -	DialogSizerSizingItem *psd;
  652.62 -
  652.63 -	//
  652.64 -	//    We need the smallest to respond to the WM_GETMINMAXINFO message
  652.65 -	POINT m_ptSmallest;
  652.66 -
  652.67 -	//
  652.68 -	//    We don't strictly speaking need to say how big the biggest can be but
  652.69 -	POINT m_ptLargest;
  652.70 -	bool  m_bLargestSet;
  652.71 -
  652.72 -	//
  652.73 -	//    we need this to decide how much the window has changed size when we get a WM_SIZE message
  652.74 -	SIZE m_sizeClient;
  652.75 -
  652.76 -	//
  652.77 -	//    Draw the sizing grip...or not
  652.78 -	bool m_bMaximised;
  652.79 -	BOOL m_bShowSizingGrip;
  652.80 -
  652.81 -	WinHelper::CRect m_rcGrip;
  652.82 -};
  652.83 -
  652.84 -extern bool regEnabled;
  652.85 -extern const char *regGetINIPath();
  652.86 -
  652.87 -void AssertFailed(char *file, int line, char *exp)
  652.88 -{
  652.89 -	char buffer[1024];
  652.90 -
  652.91 -	sprintf(buffer, "File %s\nLine %d\nExpression %s\nPress Retry to debug",
  652.92 -	        file, line, exp);
  652.93 -	systemSoundClearBuffer();
  652.94 -	int res = MessageBox(*theApp.m_pMainWnd, buffer, "Assertion failed!",
  652.95 -	                     MB_ICONHAND | MB_SETFOREGROUND | MB_TASKMODAL |
  652.96 -	                     MB_ABORTRETRYIGNORE);
  652.97 -
  652.98 -	if (res == IDRETRY)
  652.99 -	{
 652.100 -		__asm int 3;
 652.101 -	}
 652.102 -	else if (res == IDABORT)
 652.103 -		SendMessage(*theApp.m_pMainWnd, WM_QUIT, 0, 0);
 652.104 -}
 652.105 -
 652.106 -void ApiFailure(char *pcszFilename, int nLine, char *pcszExpression)
 652.107 -{
 652.108 -	const DWORD dwLastError = ::GetLastError();
 652.109 -	LPCTSTR     lpMsgBuf;
 652.110 -	(void)::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
 652.111 -	                      FORMAT_MESSAGE_FROM_SYSTEM |
 652.112 -	                      FORMAT_MESSAGE_IGNORE_INSERTS,
 652.113 -	                      NULL, dwLastError,
 652.114 -	                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
 652.115 -	                      (LPTSTR) &lpMsgBuf, 0, NULL);
 652.116 -
 652.117 -	char szExeName[ MAX_PATH ];
 652.118 -
 652.119 -	if (!GetModuleFileName(NULL, szExeName, countof(szExeName)))
 652.120 -		strcpy(szExeName, "<No Program Name>");
 652.121 -
 652.122 -	char szMessage[ 1024 ];
 652.123 -	_snprintf(szMessage, countof(szMessage),
 652.124 -	          "API VERIFY Failure!"
 652.125 -	          "\nProgram: %s"
 652.126 -	          "\n"
 652.127 -	          "\nFile %s"
 652.128 -	          "\nLine %d"
 652.129 -	          "\n"
 652.130 -	          "\nExpression %s"
 652.131 -	          "\n"
 652.132 -	          "\nLast Error %d"
 652.133 -	          "\n           %s"
 652.134 -	          "\n\nPress Retry to debug the application",
 652.135 -	          szExeName,
 652.136 -	          pcszFilename,
 652.137 -	          nLine,
 652.138 -	          pcszExpression,
 652.139 -	          dwLastError,
 652.140 -	          lpMsgBuf
 652.141 -	          );
 652.142 -
 652.143 -	(void)LocalFree((LPVOID)lpMsgBuf);
 652.144 -	HWND hwndParent = ::GetActiveWindow();
 652.145 -	hwndParent = ::GetLastActivePopup(hwndParent);
 652.146 -	systemSoundClearBuffer();
 652.147 -	int nCode = ::MessageBoxA(hwndParent,
 652.148 -	                          szMessage,
 652.149 -	                          "Debug Helper",
 652.150 -	                          MB_TASKMODAL | MB_ICONHAND | MB_ABORTRETRYIGNORE |
 652.151 -	                          MB_SETFOREGROUND);
 652.152 -	if (nCode == IDABORT)
 652.153 -	{
 652.154 -		::SendMessage(*theApp.m_pMainWnd, WM_QUIT, 0, 0);
 652.155 -	}
 652.156 -	else if (nCode == IDRETRY)
 652.157 -		__asm int 3;
 652.158 -}
 652.159 -
 652.160 -long FASTCALL RegQueryValueExRecursive(HKEY hKey,
 652.161 -                                       LPCTSTR lpValueName,
 652.162 -                                       LPDWORD lpReserved,
 652.163 -                                       LPDWORD lpType,
 652.164 -                                       LPBYTE lpData,
 652.165 -                                       LPDWORD lpcbData)
 652.166 -{
 652.167 -	TCHAR szBuffer[ 256 ];
 652.168 -	R_ASSERT(lstrlen(lpValueName) < countof(szBuffer));
 652.169 -	(void)lstrcpy(szBuffer, lpValueName);
 652.170 -
 652.171 -	LPTSTR pszBuffer = szBuffer;
 652.172 -	LPTSTR pszLast   = szBuffer;
 652.173 -	while (*pszBuffer)
 652.174 -	{
 652.175 -		if (*pszBuffer == _T('\\') || *pszBuffer == _T('/'))
 652.176 -		{
 652.177 -			pszLast     = pszBuffer;
 652.178 -			lpValueName = pszLast + 1;
 652.179 -		}
 652.180 -		pszBuffer++;
 652.181 -	}
 652.182 -
 652.183 -	if (!regEnabled)
 652.184 -	{
 652.185 -		if (GetPrivateProfileStruct("Viewer",
 652.186 -		                            lpValueName,
 652.187 -		                            lpData,
 652.188 -		                            *lpcbData,
 652.189 -		                            regGetINIPath()))
 652.190 -		{
 652.191 -			*lpType = REG_BINARY;
 652.192 -			return ERROR_SUCCESS;
 652.193 -		}
 652.194 -		return -1;
 652.195 -	}
 652.196 -
 652.197 -	bool m_bNeedToCloseKey = false;
 652.198 -	if (pszLast != szBuffer)
 652.199 -	{
 652.200 -		*pszLast = _T('\000');
 652.201 -		HKEY hkeyTemp;
 652.202 -		long lRet = RegOpenKey(hKey, szBuffer, &hkeyTemp);
 652.203 -		if (lRet != ERROR_SUCCESS)
 652.204 -		{
 652.205 -			return lRet;
 652.206 -		}
 652.207 -		hKey = hkeyTemp;
 652.208 -		m_bNeedToCloseKey = true;
 652.209 -	}
 652.210 -
 652.211 -	long lRet = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
 652.212 -	if (m_bNeedToCloseKey)
 652.213 -	{
 652.214 -		R_VERIFY(RegCloseKey(hKey) == ERROR_SUCCESS);
 652.215 -	}
 652.216 -	return lRet;
 652.217 -}
 652.218 -
 652.219 -long FASTCALL RegSetValueExRecursive(HKEY hKey,
 652.220 -                                     LPCTSTR lpValueName,
 652.221 -                                     DWORD Reserved,
 652.222 -                                     DWORD dwType,
 652.223 -                                     CONST BYTE*lpData,
 652.224 -                                     DWORD cbData)
 652.225 -{
 652.226 -	TCHAR szBuffer[ 256 ];
 652.227 -	R_ASSERT(lstrlen(lpValueName) < countof(szBuffer));
 652.228 -	(void)lstrcpy(szBuffer, lpValueName);
 652.229 -
 652.230 -	LPTSTR pszBuffer = szBuffer;
 652.231 -	LPTSTR pszLast   = szBuffer;
 652.232 -	while (*pszBuffer)
 652.233 -	{
 652.234 -		if (*pszBuffer == _T('\\') || *pszBuffer == _T('/'))
 652.235 -		{
 652.236 -			pszLast     = pszBuffer;
 652.237 -			lpValueName = pszLast + 1;
 652.238 -		}
 652.239 -		pszBuffer++;
 652.240 -	}
 652.241 -
 652.242 -	if (!regEnabled)
 652.243 -	{
 652.244 -		if (WritePrivateProfileStruct("Viewer",
 652.245 -		                              lpValueName,
 652.246 -		                              (LPVOID)lpData,
 652.247 -		                              cbData,
 652.248 -		                              regGetINIPath()))
 652.249 -		{
 652.250 -			return ERROR_SUCCESS;
 652.251 -		}
 652.252 -		return -1;
 652.253 -	}
 652.254 -
 652.255 -	bool m_bNeedToCloseKey = false;
 652.256 -	if (pszLast != szBuffer)
 652.257 -	{
 652.258 -		*pszLast = _T('\000');
 652.259 -		HKEY hkeyTemp;
 652.260 -		long lRet = RegOpenKey(hKey, szBuffer, &hkeyTemp);
 652.261 -		if (lRet != ERROR_SUCCESS)
 652.262 -		{
 652.263 -			lRet = RegCreateKey(hKey, szBuffer, &hkeyTemp);
 652.264 -			if (lRet != ERROR_SUCCESS)
 652.265 -				return lRet;
 652.266 -		}
 652.267 -		hKey = hkeyTemp;
 652.268 -		m_bNeedToCloseKey = true;
 652.269 -	}
 652.270 -
 652.271 -	long lRet = RegSetValueEx(hKey, lpValueName, Reserved, dwType, lpData, cbData);
 652.272 -	if (m_bNeedToCloseKey)
 652.273 -	{
 652.274 -		R_VERIFY(RegCloseKey(hKey) == ERROR_SUCCESS);
 652.275 -	}
 652.276 -	return lRet;
 652.277 -}
 652.278 -
 652.279 -int ResizeDlgGetItemCount(const DialogSizerSizingItem *psd)
 652.280 -{
 652.281 -	R_ASSERT(psd);
 652.282 -	int nCount = 0;
 652.283 -	while (psd->uSizeInfo != 0xFFFFFFFF)
 652.284 -	{
 652.285 -		nCount++;
 652.286 -		psd++;
 652.287 -	}
 652.288 -	return nCount;
 652.289 -}
 652.290 -
 652.291 -void ResizeDlgUpdateGripperRect(const int cx, const int cy, WinHelper::CRect &rcGrip)
 652.292 -{
 652.293 -	const int nGripWidth  = GetSystemMetrics(SM_CYVSCROLL);
 652.294 -	const int nGripHeight = GetSystemMetrics(SM_CXVSCROLL);
 652.295 -	rcGrip.left   = cx - nGripWidth;
 652.296 -	rcGrip.top    = cy - nGripHeight;
 652.297 -	rcGrip.right  = cx;
 652.298 -	rcGrip.bottom = cy;
 652.299 -}
 652.300 -
 652.301 -void ResizeDlgUpdateGripper(HWND hwnd, DialogData *pdd)
 652.302 -{
 652.303 -	if (pdd->m_bShowSizingGrip)
 652.304 -	{
 652.305 -		WinHelper::CRect rcOld(pdd->m_rcGrip);
 652.306 -
 652.307 -		ResizeDlgUpdateGripperRect(pdd->m_sizeClient.cx, pdd->m_sizeClient.cy, pdd->m_rcGrip);
 652.308 -
 652.309 -		//
 652.310 -		//        We also need to invalidate the combined area of the old and new rectangles
 652.311 -		//        otherwise we would have trail of grippers when we sized the dialog larger
 652.312 -		//        in any axis
 652.313 -		(void)UnionRect(&rcOld, &rcOld, &pdd->m_rcGrip);
 652.314 -		(void)InvalidateRect(hwnd, &rcOld, TRUE);
 652.315 -	}
 652.316 -}
 652.317 -
 652.318 -void ResizeDlgCopyItems(DialogSizerSizingItem *psdDest, const DialogSizerSizingItem *psdSource)
 652.319 -//
 652.320 -//    Will copy all of the items in psdSource into psdDest.
 652.321 -{
 652.322 -	//
 652.323 -	//    Loop til we reach the end
 652.324 -	while (psdSource->uSizeInfo != 0xFFFFFFFF)
 652.325 -	{
 652.326 -		*psdDest = *psdSource;
 652.327 -		psdDest++;
 652.328 -		psdSource++;
 652.329 -	}
 652.330 -	//    And when we do copy the last item
 652.331 -	*psdDest = *psdSource;
 652.332 -}
 652.333 -
 652.334 -ResizeDlg::ResizeDlg(UINT id, CWnd *parent)
 652.335 -	: CDialog(id, parent)
 652.336 -{
 652.337 -	dd = NULL;
 652.338 -}
 652.339 -
 652.340 -void *ResizeDlg::AddDialogData()
 652.341 -//
 652.342 -//    Firstly determine if the data already exists, if it does then return that, if not then we will
 652.343 -//    create and initialise a brand new structure.
 652.344 -{
 652.345 -	DialogData *pdd = (DialogData *)dd;
 652.346 -	if (!pdd)
 652.347 -	{
 652.348 -		pdd = (DialogData *)calloc(1, sizeof(DialogData));
 652.349 -	}
 652.350 -
 652.351 -	if (pdd)
 652.352 -	{
 652.353 -		//
 652.354 -		//  Store some sizes etc. for later.
 652.355 -		CRect rc;
 652.356 -		GetWindowRect(rc);
 652.357 -		pdd->m_ptSmallest.x = rc.Width();
 652.358 -		pdd->m_ptSmallest.y = rc.Height();
 652.359 -
 652.360 -		GetClientRect(rc);
 652.361 -		pdd->m_sizeClient = rc.Size();
 652.362 -		dd = pdd;
 652.363 -		ResizeDlgUpdateGripperRect(pdd->m_sizeClient.cx, pdd->m_sizeClient.cy, pdd->m_rcGrip);
 652.364 -	}
 652.365 -	return pdd;
 652.366 -}
 652.367 -
 652.368 -BOOL ResizeDlg::SetData(const DialogSizerSizingItem *psd,
 652.369 -                        BOOL bShowSizingGrip,
 652.370 -                        HKEY hkRootSave,
 652.371 -                        LPCTSTR pcszName,
 652.372 -                        SIZE *psizeMax)
 652.373 -//
 652.374 -//    Setting a dialog sizeable involves subclassing the window and handling it's
 652.375 -//    WM_SIZE messages, if we have a hkRootSave and pcszName then we will also be loading/saving
 652.376 -//    the size and position of the window from the registry. We load from the registry when we
 652.377 -//    subclass the window and we save to the registry when we get a WM_DESTROY.
 652.378 -//
 652.379 -//    It will return non-zero for success and zero if it fails
 652.380 -{
 652.381 -	R_ASSERT(psd);
 652.382 -	R_ASSERT((hkRootSave != NULL && pcszName != NULL)
 652.383 -	         || (hkRootSave == NULL && pcszName == NULL));
 652.384 -	//
 652.385 -	//    Make sure all of the parameters are valid.
 652.386 -	if (::IsWindow(*this)
 652.387 -	    && psd
 652.388 -	    && ((hkRootSave != NULL && pcszName != NULL &&
 652.389 -	         !IsBadStringPtr(pcszName, 0xFFFF)) ||
 652.390 -	        (hkRootSave == NULL && pcszName == NULL))
 652.391 -	    && (psizeMax == NULL || !IsBadReadPtr(psizeMax, sizeof(SIZE)))
 652.392 -	    )
 652.393 -	{
 652.394 -		DialogData *pdd = (DialogData *)AddDialogData();
 652.395 -		if (pdd)
 652.396 -		{
 652.397 -			pdd->hkRootSave        = hkRootSave;
 652.398 -			pdd->pcszName          = pcszName;
 652.399 -			pdd->m_bShowSizingGrip = bShowSizingGrip;
 652.400 -			pdd->nItemCount        = ResizeDlgGetItemCount(psd) + 1;
 652.401 -			pdd->psd = (DialogSizerSizingItem *)
 652.402 -			           calloc(pdd->nItemCount,
 652.403 -			                  sizeof(DialogSizerSizingItem));
 652.404 -			if (pdd->psd)
 652.405 -			{
 652.406 -				//
 652.407 -				//      Copy all of the user controls etc. for later, this way the user can quite happily
 652.408 -				//      let the structure go out of scope.
 652.409 -				ResizeDlgCopyItems(pdd->psd, psd);
 652.410 -				if (psizeMax)
 652.411 -				{
 652.412 -					pdd->m_ptLargest.x = psizeMax->cx;
 652.413 -					pdd->m_ptLargest.y = psizeMax->cy;
 652.414 -					pdd->m_bLargestSet = true;
 652.415 -				}
 652.416 -
 652.417 -				//
 652.418 -				//      If the there was save info passed in then we need to make damn good use of it
 652.419 -				//      by attempting to load the RegistryData structure
 652.420 -				if (hkRootSave && pcszName)
 652.421 -				{
 652.422 -					RegistryData rd;
 652.423 -					DWORD        dwSize = sizeof(RegistryData);
 652.424 -					DWORD        dwType = REG_BINARY;
 652.425 -					if (RegQueryValueExRecursive(hkRootSave, pcszName, NULL, &dwType, reinterpret_cast<LPBYTE>(&rd),
 652.426 -					                             &dwSize) == ERROR_SUCCESS && dwSize == sizeof(rd))
 652.427 -					{
 652.428 -						if (!(GetWindowLong(*this, GWL_STYLE) & WS_VISIBLE))
 652.429 -							rd.m_wpl.showCmd = SW_HIDE;
 652.430 -
 652.431 -						VAPI(SetWindowPlacement(&rd.m_wpl));
 652.432 -					}
 652.433 -				}
 652.434 -				return TRUE;
 652.435 -			}
 652.436 -			else
 652.437 -			{
 652.438 -				free(pdd);
 652.439 -			}
 652.440 -		}
 652.441 -	}
 652.442 -	return FALSE;
 652.443 -}
 652.444 -
 652.445 -void ResizeDlg::UpdateWindowSize(const int cx, const int cy, HWND hwnd)
 652.446 -{
 652.447 -	DialogData *pdd = (DialogData *)dd;
 652.448 -	if (pdd)
 652.449 -	{
 652.450 -		const int nDeltaX = cx - pdd->m_sizeClient.cx;
 652.451 -		const int nDeltaY = cy - pdd->m_sizeClient.cy;
 652.452 -		WinHelper::CDeferWindowPos def(pdd->nItemCount);
 652.453 -		WinHelper::CRect rc;
 652.454 -		const DialogSizerSizingItem *psd = pdd->psd;
 652.455 -		while (psd->uSizeInfo != 0xFFFFFFFF)
 652.456 -		{
 652.457 -			HWND hwndChild = ::GetDlgItem(*this, psd->uControlID);
 652.458 -			if (::IsWindow(hwndChild))
 652.459 -			{
 652.460 -				VAPI(::GetWindowRect(hwndChild, rc));
 652.461 -				(void)::MapWindowPoints(::GetDesktopWindow(),  hwnd,
 652.462 -				                        (LPPOINT)&rc, 2);
 652.463 -
 652.464 -				//
 652.465 -				//      Adjust the window horizontally
 652.466 -				if (psd->uSizeInfo & DS_MoveX)
 652.467 -				{
 652.468 -					rc.left  += nDeltaX;
 652.469 -					rc.right += nDeltaX;
 652.470 -				}
 652.471 -
 652.472 -				//
 652.473 -				//      Adjust the window vertically
 652.474 -				if (psd->uSizeInfo & DS_MoveY)
 652.475 -				{
 652.476 -					rc.top    += nDeltaY;
 652.477 -					rc.bottom += nDeltaY;
 652.478 -				}
 652.479 -
 652.480 -				//
 652.481 -				//      Size the window horizontally
 652.482 -				if (psd->uSizeInfo & DS_SizeX)
 652.483 -				{
 652.484 -					rc.right += nDeltaX;
 652.485 -				}
 652.486 -
 652.487 -				//
 652.488 -				//      Size the window vertically
 652.489 -				if (psd->uSizeInfo & DS_SizeY)
 652.490 -				{
 652.491 -					rc.bottom += nDeltaY;
 652.492 -				}
 652.493 -
 652.494 -				(void)def.DeferWindowPos(hwndChild, NULL, rc,
 652.495 -				                         SWP_NOACTIVATE | SWP_NOZORDER);
 652.496 -			}
 652.497 -			psd++;
 652.498 -		}
 652.499 -
 652.500 -		pdd->m_sizeClient.cx = cx;
 652.501 -		pdd->m_sizeClient.cy = cy;
 652.502 -
 652.503 -		//
 652.504 -		//  If we have a sizing grip enabled then adjust it's position
 652.505 -		ResizeDlgUpdateGripper(hwnd, pdd);
 652.506 -	}
 652.507 -}
 652.508 -
 652.509 -BOOL ResizeDlg::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *res)
 652.510 -//    Actual window procedure that will handle saving window size/position and moving
 652.511 -//    the controls whilst the window sizes.
 652.512 -{
 652.513 -	if (dd == NULL)
 652.514 -	{
 652.515 -		return CDialog::OnWndMsg(msg, wParam, lParam, res);
 652.516 -	}
 652.517 -	switch (msg)
 652.518 -	{
 652.519 -	case WM_ERASEBKGND:
 652.520 -	{
 652.521 -		BOOL        r   = CDialog::OnWndMsg(msg, wParam, lParam, res);
 652.522 -		DialogData *pdd = (DialogData *)dd;
 652.523 -		if (pdd && pdd->m_bShowSizingGrip && !pdd->m_bMaximised)
 652.524 -		{
 652.525 -			VAPI(::DrawFrameControl(reinterpret_cast<HDC>(wParam),
 652.526 -			                        pdd->m_rcGrip,
 652.527 -			                        DFC_SCROLL, DFCS_SCROLLSIZEGRIP));
 652.528 -		}
 652.529 -		return r;
 652.530 -	}
 652.531 -	case WM_SIZE:
 652.532 -	{
 652.533 -		DialogData *pdd = (DialogData *)dd;
 652.534 -		if (pdd && wParam != SIZE_MINIMIZED)
 652.535 -		{
 652.536 -			pdd->m_bMaximised = (wParam == SIZE_MAXIMIZED ? true : false);
 652.537 -			UpdateWindowSize(LOWORD(lParam), HIWORD(lParam), *this);
 652.538 -		}
 652.539 -		break;
 652.540 -	}
 652.541 -	case WM_NCHITTEST:
 652.542 -	{
 652.543 -		//
 652.544 -		//        If the gripper is enabled then perform a simple hit test on our gripper area.
 652.545 -		DialogData *pdd = (DialogData *)dd;
 652.546 -		if (pdd && pdd->m_bShowSizingGrip)
 652.547 -		{
 652.548 -			POINT pt = { LOWORD(lParam), HIWORD(lParam) };
 652.549 -			(void)ScreenToClient(&pt);
 652.550 -			if (PtInRect(pdd->m_rcGrip, pt))
 652.551 -				return (BOOL)HTBOTTOMRIGHT;
 652.552 -		}
 652.553 -		break;
 652.554 -	}
 652.555 -	case WM_GETMINMAXINFO:
 652.556 -	{
 652.557 -		//
 652.558 -		//        Our opportunity to say that we do not want the dialog to grow or shrink any more.
 652.559 -		DialogData * pdd   = (DialogData *)dd;
 652.560 -		LPMINMAXINFO lpmmi = reinterpret_cast<LPMINMAXINFO>(lParam);
 652.561 -		lpmmi->ptMinTrackSize = pdd->m_ptSmallest;
 652.562 -		if (pdd->m_bLargestSet)
 652.563 -		{
 652.564 -			lpmmi->ptMaxTrackSize = pdd->m_ptLargest;
 652.565 -		}
 652.566 -	}
 652.567 -		return (BOOL)0;
 652.568 -	case WM_NOTIFY:
 652.569 -	{
 652.570 -		if (reinterpret_cast<LPNMHDR>(lParam)->code == PSN_SETACTIVE)
 652.571 -		{
 652.572 -			CRect rc;
 652.573 -			VAPI(::GetClientRect(*GetParent(), &rc));
 652.574 -			UpdateWindowSize(rc.Width(), rc.Height(), *GetParent());
 652.575 -		}
 652.576 -		break;
 652.577 -	}
 652.578 -	case WM_DESTROY:
 652.579 -	{
 652.580 -		//
 652.581 -		//        Our opportunty for cleanup.
 652.582 -		//        Simply acquire all of our objects, free the appropriate memory and remove the
 652.583 -		//        properties from the window. If we do not remove the properties then they will constitute
 652.584 -		//        a resource leak.
 652.585 -		DialogData *pdd = (DialogData *)dd;
 652.586 -		if (pdd)
 652.587 -		{
 652.588 -			RegistryData rd;
 652.589 -			rd.m_wpl.length = sizeof(rd.m_wpl);
 652.590 -			VAPI(GetWindowPlacement(&rd.m_wpl));
 652.591 -
 652.592 -			if (pdd->hkRootSave && pdd->pcszName)
 652.593 -			{
 652.594 -				(void)RegSetValueExRecursive(pdd->hkRootSave, pdd->pcszName,
 652.595 -				                             NULL, REG_BINARY,
 652.596 -				                             reinterpret_cast<LPBYTE>(&rd),
 652.597 -				                             sizeof(rd));
 652.598 -			}
 652.599 -
 652.600 -			if (pdd->psd)
 652.601 -			{
 652.602 -				free(pdd->psd);
 652.603 -			}
 652.604 -			free(pdd);
 652.605 -		}
 652.606 -
 652.607 -		break;
 652.608 -	}
 652.609 -	}
 652.610 -	return CDialog::OnWndMsg(msg, wParam, lParam, res);
 652.611 -}
 652.612 -
   653.1 --- a/src/win32/ResizeDlg.h	Sat Mar 03 10:54:39 2012 -0600
   653.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   653.3 @@ -1,44 +0,0 @@
   653.4 -#ifndef VBA_WIN32_RESIZEDLG_H
   653.5 -#define VBA_WIN32_RESIZEDLG_H
   653.6 -
   653.7 -#ifndef _INC_TCHAR
   653.8 -#include <tchar.h>
   653.9 -#endif  //      _INC_TCHAR
  653.10 -
  653.11 -//
  653.12 -//      Predefined sizing information
  653.13 -#define DS_MoveX                1
  653.14 -#define DS_MoveY                2
  653.15 -#define DS_SizeX                4
  653.16 -#define DS_SizeY                8
  653.17 -
  653.18 -typedef struct DialogSizerSizingItem    //      sdi
  653.19 -{
  653.20 -	UINT uControlID;
  653.21 -	UINT uSizeInfo;
  653.22 -} DialogSizerSizingItem;
  653.23 -
  653.24 -#define DIALOG_SIZER_START(name)      DialogSizerSizingItem name[] = {
  653.25 -#define DIALOG_SIZER_ENTRY(controlID, flags)  { controlID, flags },
  653.26 -#define DIALOG_SIZER_END()      { 0xFFFFFFFF, 0xFFFFFFFF } };
  653.27 -
  653.28 -class ResizeDlg : public CDialog
  653.29 -{
  653.30 -	DECLARE_DYNAMIC(ResizeDlg)	// what will this do?
  653.31 -public:
  653.32 -	ResizeDlg(UINT id, CWnd *parent = NULL);
  653.33 -
  653.34 -	void *AddDialogData();
  653.35 -	BOOL SetData(const DialogSizerSizingItem *psd,
  653.36 -	             BOOL bShowSizingGrip,
  653.37 -	             HKEY hkRootSave,
  653.38 -	             LPCTSTR pcszName,
  653.39 -	             SIZE *psizeMax);
  653.40 -	void UpdateWindowSize(const int cx, const int cy, HWND);
  653.41 -
  653.42 -	virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *);
  653.43 -private:
  653.44 -	void *dd;
  653.45 -};
  653.46 -
  653.47 -#endif
   654.1 --- a/src/win32/RewindInterval.cpp	Sat Mar 03 10:54:39 2012 -0600
   654.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   654.3 @@ -1,96 +0,0 @@
   654.4 -// RewindInterval.cpp : implementation file
   654.5 -//
   654.6 -
   654.7 -#include "stdafx.h"
   654.8 -#include <cmath>
   654.9 -#include "resource.h"
  654.10 -#include "RewindInterval.h"
  654.11 -#include "VBA.h"
  654.12 -
  654.13 -/////////////////////////////////////////////////////////////////////////////
  654.14 -// RewindInterval dialog
  654.15 -
  654.16 -RewindInterval::RewindInterval(float interval, int slots, CWnd*pParent /*=NULL*/)
  654.17 -	: CDialog(RewindInterval::IDD, pParent)
  654.18 -{
  654.19 -	//{{AFX_DATA_INIT(RewindInterval)
  654.20 -	// NOTE: the ClassWizard will add member initialization here
  654.21 -	//}}AFX_DATA_INIT
  654.22 -	this->interval = interval;
  654.23 -	this->slots    = slots;
  654.24 -}
  654.25 -
  654.26 -void RewindInterval::DoDataExchange(CDataExchange*pDX)
  654.27 -{
  654.28 -	CDialog::DoDataExchange(pDX);
  654.29 -	//{{AFX_DATA_MAP(RewindInterval)
  654.30 -	DDX_Control(pDX, IDC_INTERVAL, m_interval);
  654.31 -	DDX_Control(pDX, IDC_REWINDSLOTS, m_slots);
  654.32 -	//}}AFX_DATA_MAP
  654.33 -}
  654.34 -
  654.35 -BEGIN_MESSAGE_MAP(RewindInterval, CDialog)
  654.36 -//{{AFX_MSG_MAP(RewindInterval)
  654.37 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  654.38 -ON_BN_CLICKED(ID_OK, OnOk)
  654.39 -//}}AFX_MSG_MAP
  654.40 -END_MESSAGE_MAP()
  654.41 -
  654.42 -/////////////////////////////////////////////////////////////////////////////
  654.43 -// RewindInterval message handlers
  654.44 -
  654.45 -void RewindInterval::OnCancel()
  654.46 -{
  654.47 -	EndDialog(-1);
  654.48 -}
  654.49 -
  654.50 -void RewindInterval::OnOk()
  654.51 -{
  654.52 -	CString buffer, buffer2;
  654.53 -
  654.54 -	m_interval.GetWindowText(buffer);
  654.55 -	m_slots.GetWindowText(buffer2);
  654.56 -
  654.57 -	float interval = (float)atof(buffer);
  654.58 -	int   slots    = atoi(buffer2);
  654.59 -
  654.60 -	if (interval >= 0 && (int)interval <= 600)
  654.61 -	{
  654.62 -		if (slots >= 0 && slots <= MAX_REWIND_SLOTS)
  654.63 -		{
  654.64 -			int iInterval = (int)(interval*6.0f + 0.5f);
  654.65 -			if (interval > 0 && iInterval == 0)
  654.66 -				iInterval = 1;
  654.67 -			EndDialog(iInterval | (slots << 16));
  654.68 -			theApp.winAccelMgr.UpdateMenu(theApp.menu);
  654.69 -		}
  654.70 -		else
  654.71 -			systemMessage(IDS_INVALID_INTERVAL_VALUE,
  654.72 -			              "Invalid rewind slot amount. Please enter a number "
  654.73 -			              "between 0 and 128 slots");
  654.74 -	}
  654.75 -	else
  654.76 -		systemMessage(IDS_INVALID_INTERVAL_VALUE,
  654.77 -		              "Invalid rewind interval value. Please enter a number "
  654.78 -		              "between 0 and 600 seconds");
  654.79 -}
  654.80 -
  654.81 -BOOL RewindInterval::OnInitDialog()
  654.82 -{
  654.83 -	CDialog::OnInitDialog();
  654.84 -
  654.85 -	m_interval.LimitText(5);
  654.86 -	m_slots.LimitText(3);
  654.87 -
  654.88 -	CString buffer, buffer2;
  654.89 -	buffer.Format("%.1f", interval);
  654.90 -	m_interval.SetWindowText(buffer);
  654.91 -	buffer2.Format("%d", slots);
  654.92 -	m_slots.SetWindowText(buffer2);
  654.93 -
  654.94 -	CenterWindow();
  654.95 -
  654.96 -	return TRUE; // return TRUE unless you set the focus to a control
  654.97 -	             // EXCEPTION: OCX Property Pages should return FALSE
  654.98 -}
  654.99 -
   655.1 --- a/src/win32/RewindInterval.h	Sat Mar 03 10:54:39 2012 -0600
   655.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   655.3 @@ -1,49 +0,0 @@
   655.4 -#if !defined(AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_)
   655.5 -#define AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_
   655.6 -
   655.7 -#if _MSC_VER > 1000
   655.8 -#pragma once
   655.9 -#endif // _MSC_VER > 1000
  655.10 -// RewindInterval.h : header file
  655.11 -//
  655.12 -
  655.13 -/////////////////////////////////////////////////////////////////////////////
  655.14 -// RewindInterval dialog
  655.15 -
  655.16 -class RewindInterval : public CDialog
  655.17 -{
  655.18 -	// Construction
  655.19 -public:
  655.20 -	float interval;
  655.21 -	int   slots;
  655.22 -	RewindInterval(float interval, int slots, CWnd*pParent = NULL);  // standard constructor
  655.23 -
  655.24 -	// Dialog Data
  655.25 -	//{{AFX_DATA(RewindInterval)
  655.26 -	enum { IDD = IDD_REWIND_INTERVAL };
  655.27 -	CEdit m_interval;
  655.28 -	CEdit m_slots;
  655.29 -	//}}AFX_DATA
  655.30 -
  655.31 -	// Overrides
  655.32 -	// ClassWizard generated virtual function overrides
  655.33 -	//{{AFX_VIRTUAL(RewindInterval)
  655.34 -protected:
  655.35 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  655.36 -	//}}AFX_VIRTUAL
  655.37 -
  655.38 -	// Implementation
  655.39 -protected:
  655.40 -	// Generated message map functions
  655.41 -	//{{AFX_MSG(RewindInterval)
  655.42 -	afx_msg void OnCancel();
  655.43 -	afx_msg void OnOk();
  655.44 -	virtual BOOL OnInitDialog();
  655.45 -	//}}AFX_MSG
  655.46 -	DECLARE_MESSAGE_MAP()
  655.47 -};
  655.48 -
  655.49 -//{{AFX_INSERT_LOCATION}}
  655.50 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  655.51 -
  655.52 -#endif // !defined(AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_)
   656.1 --- a/src/win32/RomInfo.cpp	Sat Mar 03 10:54:39 2012 -0600
   656.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   656.3 @@ -1,555 +0,0 @@
   656.4 -// RomInfo.cpp : implementation file
   656.5 -//
   656.6 -
   656.7 -#include "stdafx.h"
   656.8 -#include "resource.h"
   656.9 -#include "RomInfo.h"
  656.10 -#include "WinResUtil.h"
  656.11 -
  656.12 -extern int32 gbRomSize;
  656.13 -
  656.14 -struct WinGBACompanyName
  656.15 -{
  656.16 -	LPCTSTR code;
  656.17 -	LPCTSTR name;
  656.18 -};
  656.19 -
  656.20 -static WinGBACompanyName winGBARomInfoCompanies[] = {
  656.21 -	{ "01", "Nintendo"							  },
  656.22 -	{ "02", "Rocket Games"						  },
  656.23 -	{ "08", "Capcom"							  },
  656.24 -	{ "09", "Hot B Co."							  },
  656.25 -	{ "0A", "Jaleco"							  },
  656.26 -	{ "0B", "Coconuts Japan"					  },
  656.27 -	{ "0C", "Coconuts Japan/G.X.Media"			  },
  656.28 -	{ "0H", "Starfish"							  },
  656.29 -	{ "0L", "Warashi Inc."						  },
  656.30 -	{ "0N", "Nowpro"							  },
  656.31 -	{ "0P", "Game Village"						  },
  656.32 -	{ "13", "Electronic Arts Japan"				  },
  656.33 -	{ "18", "Hudson Soft Japan"					  },
  656.34 -	{ "19", "S.C.P."							  },
  656.35 -	{ "1A", "Yonoman"							  },
  656.36 -	{ "1G", "SMDE"								  },
  656.37 -	{ "1P", "Creatures Inc."					  },
  656.38 -	{ "1Q", "TDK Deep Impresion"				  },
  656.39 -	{ "20", "Destination Software"				  },
  656.40 -	{ "22", "VR 1 Japan"						  },
  656.41 -	{ "25", "San-X"								  },
  656.42 -	{ "28", "Kemco Japan"						  },
  656.43 -	{ "29", "Seta"								  },
  656.44 -	{ "2H", "Ubisoft Japan"						  },
  656.45 -	{ "2K", "NEC InterChannel"					  },
  656.46 -	{ "2L", "Tam"								  },
  656.47 -	{ "2M", "Jordan"							  },
  656.48 -	{ "2N", "Smilesoft"							  },
  656.49 -	{ "2Q", "Mediakite"							  },
  656.50 -	{ "36", "Codemasters"						  },
  656.51 -	{ "37", "GAGA Communications"				  },
  656.52 -	{ "38", "Laguna"							  },
  656.53 -	{ "39", "Telstar Fun and Games"				  },
  656.54 -	{ "41", "Ubi Soft Entertainment"			  },
  656.55 -	{ "42", "Sunsoft"							  },
  656.56 -	{ "47", "Spectrum Holobyte"					  },
  656.57 -	{ "49", "IREM"								  },
  656.58 -	{ "4D", "Malibu Games"						  },
  656.59 -	{ "4F", "Eidos/U.S. Gold"					  },
  656.60 -	{ "4J", "Fox Interactive"					  },
  656.61 -	{ "4K", "Time Warner Interactive"			  },
  656.62 -	{ "4Q", "Disney"							  },
  656.63 -	{ "4S", "Black Pearl"						  },
  656.64 -	{ "4X", "GT Interactive"					  },
  656.65 -	{ "4Y", "RARE"								  },
  656.66 -	{ "4Z", "Crave Entertainment"				  },
  656.67 -	{ "50", "Absolute Entertainment"			  },
  656.68 -	{ "51", "Acclaim"							  },
  656.69 -	{ "52", "Activision"						  },
  656.70 -	{ "53", "American Sammy Corp."				  },
  656.71 -	{ "54", "Take 2 Interactive"				  },
  656.72 -	{ "55", "Hi Tech"							  },
  656.73 -	{ "56", "LJN LTD."							  },
  656.74 -	{ "58", "Mattel"							  },
  656.75 -	{ "5A", "Mindscape/Red Orb Ent."			  },
  656.76 -	{ "5C", "Taxan"								  },
  656.77 -	{ "5D", "Midway"							  },
  656.78 -	{ "5F", "American Softworks"				  },
  656.79 -	{ "5G", "Majesco Sales Inc"					  },
  656.80 -	{ "5H", "3DO"								  },
  656.81 -	{ "5K", "Hasbro"							  },
  656.82 -	{ "5L", "NewKidCo"							  },
  656.83 -	{ "5M", "Telegames"							  },
  656.84 -	{ "5N", "Metro3D"							  },
  656.85 -	{ "5P", "Vatical Entertainment"				  },
  656.86 -	{ "5Q", "LEGO Media"						  },
  656.87 -	{ "5S", "Xicat Interactive"					  },
  656.88 -	{ "5T", "Cryo Interactive"					  },
  656.89 -	{ "5W", "Red Storm Ent./BKN Ent."			  },
  656.90 -	{ "5X", "Microids"							  },
  656.91 -	{ "5Z", "Conspiracy Entertainment Corp."	  },
  656.92 -	{ "60", "Titus Interactive Studios"			  },
  656.93 -	{ "61", "Virgin Interactive"				  },
  656.94 -	{ "62", "Maxis"								  },
  656.95 -	{ "64", "LucasArts Entertainment"			  },
  656.96 -	{ "67", "Ocean"								  },
  656.97 -	{ "69", "Electronic Arts"					  },
  656.98 -	{ "6E", "Elite Systems Ltd."				  },
  656.99 -	{ "6F", "Electro Brain"						  },
 656.100 -	{ "6G", "The Learning Company"				  },
 656.101 -	{ "6H", "BBC"								  },
 656.102 -	{ "6J", "Software 2000"						  },
 656.103 -	{ "6L", "BAM! Entertainment"				  },
 656.104 -	{ "6M", "Studio 3"							  },
 656.105 -	{ "6Q", "Classified Games"					  },
 656.106 -	{ "6S", "TDK Mediactive"					  },
 656.107 -	{ "6U", "DreamCatcher"						  },
 656.108 -	{ "6V", "JoWood Productions"				  },
 656.109 -	{ "6W", "SEGA"								  },
 656.110 -	{ "6X", "Wannado Edition"					  },
 656.111 -	{ "6Y", "LSP"								  },
 656.112 -	{ "6Z", "ITE Media"							  },
 656.113 -	{ "70", "Infogrames"						  },
 656.114 -	{ "71", "Interplay"							  },
 656.115 -	{ "72", "JVC Musical Industries Inc"		  },
 656.116 -	{ "73", "Parker Brothers"					  },
 656.117 -	{ "75", "SCI"								  },
 656.118 -	{ "78", "THQ"								  },
 656.119 -	{ "79", "Accolade"							  },
 656.120 -	{ "7A", "Triffix Ent. Inc."					  },
 656.121 -	{ "7C", "Microprose Software"				  },
 656.122 -	{ "7D", "Universal Interactive Studios"		  },
 656.123 -	{ "7F", "Kemco"								  },
 656.124 -	{ "7G", "Rage Software"						  },
 656.125 -	{ "7H", "Encore"							  },
 656.126 -	{ "7J", "Zoo"								  },
 656.127 -	{ "7K", "BVM"								  },
 656.128 -	{ "7L", "Simon & Schuster Interactive"		  },
 656.129 -	{ "7M", "Asmik Ace Entertainment Inc./AIA"	  },
 656.130 -	{ "7N", "Empire Interactive"				  },
 656.131 -	{ "7Q", "Jester Interactive"				  },
 656.132 -	{ "7T", "Scholastic"						  },
 656.133 -	{ "7U", "Ignition Entertainment"			  },
 656.134 -	{ "7W", "Stadlbauer"						  },
 656.135 -	{ "80", "Misawa"							  },
 656.136 -	{ "83", "LOZC"								  },
 656.137 -	{ "8B", "Bulletproof Software"				  },
 656.138 -	{ "8C", "Vic Tokai Inc."					  },
 656.139 -	{ "8J", "General Entertainment"				  },
 656.140 -	{ "8N", "Success"							  },
 656.141 -	{ "8P", "SEGA Japan"						  },
 656.142 -	{ "91", "Chun Soft"							  },
 656.143 -	{ "92", "Video System"						  },
 656.144 -	{ "93", "BEC"								  },
 656.145 -	{ "96", "Yonezawa/S'pal"					  },
 656.146 -	{ "97", "Kaneko"							  },
 656.147 -	{ "99", "Victor Interactive Software"		  },
 656.148 -	{ "9A", "Nichibutsu/Nihon Bussan"			  },
 656.149 -	{ "9B", "Tecmo"								  },
 656.150 -	{ "9C", "Imagineer"							  },
 656.151 -	{ "9F", "Nova"								  },
 656.152 -	{ "9H", "Bottom Up"							  },
 656.153 -	{ "9L", "Hasbro Japan"						  },
 656.154 -	{ "9N", "Marvelous Entertainment"			  },
 656.155 -	{ "9P", "Keynet Inc."						  },
 656.156 -	{ "9Q", "Hands-On Entertainment"			  },
 656.157 -	{ "A0", "Telenet"							  },
 656.158 -	{ "A1", "Hori"								  },
 656.159 -	{ "A4", "Konami"							  },
 656.160 -	{ "A6", "Kawada"							  },
 656.161 -	{ "A7", "Takara"							  },
 656.162 -	{ "A9", "Technos Japan Corp."				  },
 656.163 -	{ "AA", "JVC"								  },
 656.164 -	{ "AC", "Toei Animation"					  },
 656.165 -	{ "AD", "Toho"								  },
 656.166 -	{ "AF", "Namco"								  },
 656.167 -	{ "AG", "Media Rings Corporation"			  },
 656.168 -	{ "AH", "J-Wing"							  },
 656.169 -	{ "AK", "KID"								  },
 656.170 -	{ "AL", "MediaFactory"						  },
 656.171 -	{ "AP", "Infogrames Hudson"					  },
 656.172 -	{ "AQ", "Kiratto. Ludic Inc"				  },
 656.173 -	{ "B0", "Acclaim Japan"						  },
 656.174 -	{ "B1", "ASCII"								  },
 656.175 -	{ "B2", "Bandai"							  },
 656.176 -	{ "B4", "Enix"								  },
 656.177 -	{ "B6", "HAL Laboratory"					  },
 656.178 -	{ "B7", "SNK"								  },
 656.179 -	{ "B9", "Pony Canyon Hanbai"				  },
 656.180 -	{ "BA", "Culture Brain"						  },
 656.181 -	{ "BB", "Sunsoft"							  },
 656.182 -	{ "BD", "Sony Imagesoft"					  },
 656.183 -	{ "BF", "Sammy"								  },
 656.184 -	{ "BG", "Magical"							  },
 656.185 -	{ "BJ", "Compile"							  },
 656.186 -	{ "BL", "MTO Inc."							  },
 656.187 -	{ "BN", "Sunrise Interactive"				  },
 656.188 -	{ "BP", "Global A Entertainment"			  },
 656.189 -	{ "BQ", "Fuuki"								  },
 656.190 -	{ "C0", "Taito"								  },
 656.191 -	{ "C2", "Kemco"								  },
 656.192 -	{ "C3", "Square Soft"						  },
 656.193 -	{ "C5", "Data East"							  },
 656.194 -	{ "C6", "Tonkin House"						  },
 656.195 -	{ "C8", "Koei"								  },
 656.196 -	{ "CA", "Konami/Palcom/Ultra"				  },
 656.197 -	{ "CB", "Vapinc/NTVIC"						  },
 656.198 -	{ "CC", "Use Co.,Ltd."						  },
 656.199 -	{ "CD", "Meldac"							  },
 656.200 -	{ "CE", "FCI/Pony Canyon"					  },
 656.201 -	{ "CF", "Angel"								  },
 656.202 -	{ "CM", "Konami Computer Entertainment Osaka" },
 656.203 -	{ "CP", "Enterbrain"						  },
 656.204 -	{ "D1", "Sofel"								  },
 656.205 -	{ "D2", "Quest"								  },
 656.206 -	{ "D3", "Sigma Enterprises"					  },
 656.207 -	{ "D4", "Ask Kodansa"						  },
 656.208 -	{ "D6", "Naxat"								  },
 656.209 -	{ "D7", "Copya System"						  },
 656.210 -	{ "D9", "Banpresto"							  },
 656.211 -	{ "DA", "TOMY"								  },
 656.212 -	{ "DB", "LJN Japan"							  },
 656.213 -	{ "DD", "NCS"								  },
 656.214 -	{ "DF", "Altron Corporation"				  },
 656.215 -	{ "DH", "Gaps Inc."							  },
 656.216 -	{ "DN", "ELF"								  },
 656.217 -	{ "E2", "Yutaka"							  },
 656.218 -	{ "E3", "Varie"								  },
 656.219 -	{ "E5", "Epoch"								  },
 656.220 -	{ "E7", "Athena"							  },
 656.221 -	{ "E8", "Asmik Ace Entertainment Inc."		  },
 656.222 -	{ "E9", "Natsume"							  },
 656.223 -	{ "EA", "King Records"						  },
 656.224 -	{ "EB", "Atlus"								  },
 656.225 -	{ "EC", "Epic/Sony Records"					  },
 656.226 -	{ "EE", "IGS"								  },
 656.227 -	{ "EL", "Spike"								  },
 656.228 -	{ "EM", "Konami Computer Entertainment Tokyo" },
 656.229 -	{ "EN", "Alphadream Corporation"			  },
 656.230 -	{ "F0", "A Wave"							  },
 656.231 -	{ "G1", "PCCW"								  },
 656.232 -	{ "G4", "KiKi Co Ltd"						  },
 656.233 -	{ "G5", "Open Sesame Inc."					  },
 656.234 -	{ "G6", "Sims"								  },
 656.235 -	{ "G7", "Broccoli"							  },
 656.236 -	{ "G8", "Avex"								  },
 656.237 -	{ "G9", "D3 Publisher"						  },
 656.238 -	{ "GB", "Konami Computer Entertainment Japan" },
 656.239 -	{ "GD", "Square-Enix"						  },
 656.240 -	{ "HY", "Sachen"							  },
 656.241 -	{ NULL, NULL								  }
 656.242 -};
 656.243 -
 656.244 -static LPCTSTR winGBARomInfoFindMakerCode(LPCTSTR code)
 656.245 -{
 656.246 -	int i = 0;
 656.247 -	while (winGBARomInfoCompanies[i].code)
 656.248 -	{
 656.249 -		if (!strcmp(winGBARomInfoCompanies[i].code, code))
 656.250 -			return winGBARomInfoCompanies[i].name;
 656.251 -		i++;
 656.252 -	}
 656.253 -	return (LPCTSTR)winResLoadString(IDS_UNKNOWN);
 656.254 -}
 656.255 -
 656.256 -/////////////////////////////////////////////////////////////////////////////
 656.257 -// RomInfoGB dialog
 656.258 -
 656.259 -RomInfoGB::RomInfoGB(u8 *rom, CWnd *pParent /*=NULL*/)
 656.260 -	: CDialog(RomInfoGB::IDD, pParent)
 656.261 -{
 656.262 -	//{{AFX_DATA_INIT(RomInfoGB)
 656.263 -	// NOTE: the ClassWizard will add member initialization here
 656.264 -	//}}AFX_DATA_INIT
 656.265 -	this->rom = rom;
 656.266 -}
 656.267 -
 656.268 -void RomInfoGB::DoDataExchange(CDataExchange *pDX)
 656.269 -{
 656.270 -	CDialog::DoDataExchange(pDX);
 656.271 -	//{{AFX_DATA_MAP(RomInfoGB)
 656.272 -	// NOTE: the ClassWizard will add DDX and DDV calls here
 656.273 -	//}}AFX_DATA_MAP
 656.274 -}
 656.275 -
 656.276 -BEGIN_MESSAGE_MAP(RomInfoGB, CDialog)
 656.277 -//{{AFX_MSG_MAP(RomInfoGB)
 656.278 -ON_BN_CLICKED(ID_OK, OnOk)
 656.279 -//}}AFX_MSG_MAP
 656.280 -END_MESSAGE_MAP()
 656.281 -
 656.282 -/////////////////////////////////////////////////////////////////////////////
 656.283 -// RomInfoGB message handlers
 656.284 -
 656.285 -void RomInfoGB::OnOk()
 656.286 -{
 656.287 -	EndDialog(TRUE);
 656.288 -}
 656.289 -
 656.290 -BOOL RomInfoGB::OnInitDialog()
 656.291 -{
 656.292 -	CDialog::OnInitDialog();
 656.293 -
 656.294 -	char buffer[128];
 656.295 -
 656.296 -	strncpy(buffer, (const char *)&rom[0x134], 15);
 656.297 -	buffer[15] = 0;
 656.298 -	GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer);
 656.299 -
 656.300 -	sprintf(buffer, "%02x", rom[0x143]);
 656.301 -	GetDlgItem(IDC_ROM_COLOR)->SetWindowText(buffer);
 656.302 -
 656.303 -	strncpy(buffer, (const char *)&rom[0x144], 2);
 656.304 -	buffer[2] = 0;
 656.305 -	GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
 656.306 -
 656.307 -	if (rom[0x14b] != 0x33)
 656.308 -	{
 656.309 -		sprintf(buffer, "%02X", rom[0x14b]);
 656.310 -		GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
 656.311 -	}
 656.312 -	GetDlgItem(IDC_ROM_MAKER_NAME2)->SetWindowText(winGBARomInfoFindMakerCode(buffer));
 656.313 -
 656.314 -	sprintf(buffer, "%02x", rom[0x146]);
 656.315 -	GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer);
 656.316 -
 656.317 -	CString type = winResLoadString(IDS_UNKNOWN);
 656.318 -	switch (rom[0x147])
 656.319 -	{
 656.320 -	case 0x00:
 656.321 -		type = "ROM";
 656.322 -		break;
 656.323 -	case 0x01:
 656.324 -		type = "ROM+MBC1";
 656.325 -		break;
 656.326 -	case 0x02:
 656.327 -		type = "ROM+MBC1+RAM";
 656.328 -		break;
 656.329 -	case 0x03:
 656.330 -		type = "ROM+MBC1+RAM+BATT";
 656.331 -		break;
 656.332 -	case 0x05:
 656.333 -		type = "ROM+MBC2";
 656.334 -		break;
 656.335 -	case 0x06:
 656.336 -		type = "ROM+MBC2+BATT";
 656.337 -		break;
 656.338 -	case 0x0f:
 656.339 -		type = "ROM+MBC3+TIMER+BATT";
 656.340 -		break;
 656.341 -	case 0x10:
 656.342 -		type = "ROM+MBC3+TIMER+RAM+BATT";
 656.343 -		break;
 656.344 -	case 0x11:
 656.345 -		type = "ROM+MBC3";
 656.346 -		break;
 656.347 -	case 0x12:
 656.348 -		type = "ROM+MBC3+RAM";
 656.349 -		break;
 656.350 -	case 0x13:
 656.351 -		type = "ROM+MBC3+RAM+BATT";
 656.352 -		break;
 656.353 -	case 0x19:
 656.354 -		type = "ROM+MBC5";
 656.355 -		break;
 656.356 -	case 0x1a:
 656.357 -		type = "ROM+MBC5+RAM";
 656.358 -		break;
 656.359 -	case 0x1b:
 656.360 -		type = "ROM+MBC5+RAM+BATT";
 656.361 -		break;
 656.362 -	case 0x1c:
 656.363 -		type = "ROM+MBC5+RUMBLE";
 656.364 -		break;
 656.365 -	case 0x1d:
 656.366 -		type = "ROM+MBC5+RUMBLE+RAM";
 656.367 -		break;
 656.368 -	case 0x1e:
 656.369 -		type = "ROM+MBC5+RUMBLE+RAM+BATT";
 656.370 -		break;
 656.371 -	case 0x22:
 656.372 -		type = "ROM+MBC7+BATT";
 656.373 -		break;
 656.374 -	case 0xfe:
 656.375 -		type = "ROM+HuC-3";
 656.376 -		break;
 656.377 -	case 0xff:
 656.378 -		type = "ROM+HuC-1";
 656.379 -		break;
 656.380 -	}
 656.381 -	sprintf(buffer, "%02x (%s)", rom[0x147], (const char *)type);
 656.382 -	GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer);
 656.383 -
 656.384 -	type = winResLoadString(IDS_UNKNOWN);
 656.385 -	switch (rom[0x148])
 656.386 -	{
 656.387 -	case 0:
 656.388 -		type = "32K";
 656.389 -		break;
 656.390 -	case 1:
 656.391 -		type = "64K";
 656.392 -		break;
 656.393 -	case 2:
 656.394 -		type = "128K";
 656.395 -		break;
 656.396 -	case 3:
 656.397 -		type = "256K";
 656.398 -		break;
 656.399 -	case 4:
 656.400 -		type = "512K";
 656.401 -		break;
 656.402 -	case 5:
 656.403 -		type = "1M";
 656.404 -		break;
 656.405 -	case 6:
 656.406 -		type = "2M";
 656.407 -		break;
 656.408 -	case 7:
 656.409 -		type = "4M";
 656.410 -		break;
 656.411 -	}
 656.412 -
 656.413 -	sprintf(buffer, "%02x (%s)", rom[0x148], (const char *)type);
 656.414 -	GetDlgItem(IDC_ROM_SIZE)->SetWindowText(buffer);
 656.415 -
 656.416 -	type = winResLoadString(IDS_UNKNOWN);
 656.417 -	switch (rom[0x149])
 656.418 -	{
 656.419 -	case 0:
 656.420 -		type = winResLoadString(IDS_NONE);
 656.421 -		break;
 656.422 -	case 1:
 656.423 -		type = "2K";
 656.424 -		break;
 656.425 -	case 2:
 656.426 -		type = "8K";
 656.427 -		break;
 656.428 -	case 3:
 656.429 -		type = "32K";
 656.430 -		break;
 656.431 -	case 4:
 656.432 -		type = "128K";
 656.433 -		break;
 656.434 -	case 5:
 656.435 -		type = "64K";
 656.436 -		break;
 656.437 -	}
 656.438 -
 656.439 -	sprintf(buffer, "%02x (%s)", rom[0x149], (const char *)type);
 656.440 -	GetDlgItem(IDC_ROM_RAM_SIZE)->SetWindowText(buffer);
 656.441 -
 656.442 -	sprintf(buffer, "%02x", rom[0x14a]);
 656.443 -	GetDlgItem(IDC_ROM_DEST_CODE)->SetWindowText(buffer);
 656.444 -
 656.445 -	sprintf(buffer, "%02x", rom[0x14b]);
 656.446 -	GetDlgItem(IDC_ROM_LIC_CODE)->SetWindowText(buffer);
 656.447 -
 656.448 -	sprintf(buffer, "%02x", rom[0x14c]);
 656.449 -	GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer);
 656.450 -
 656.451 -	u8	crc8 = 25;
 656.452 -	int i;
 656.453 -	for (i = 0x134; i < 0x14d; i++)
 656.454 -	{
 656.455 -		crc8 = (crc8 + rom[i]) & 0xFF;
 656.456 -	}
 656.457 -
 656.458 -	crc8 = 256 - crc8;
 656.459 -
 656.460 -	sprintf(buffer, "%02x (%02x)", crc8, rom[0x14d]);
 656.461 -	GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer);
 656.462 -
 656.463 -	u16 crc16 = 0;
 656.464 -	for (i = 0; i < gbRomSize; i++)
 656.465 -	{
 656.466 -		crc16 = (crc16 + rom[i]) & 0xFFFF;
 656.467 -	}
 656.468 -
 656.469 -	crc16 -= rom[0x14e];
 656.470 -	crc16 -= rom[0x14f];
 656.471 -	sprintf(buffer, "%04x (%04x)", crc16, (rom[0x14e] << 8) | rom[0x14f]);
 656.472 -	GetDlgItem(IDC_ROM_CHECKSUM)->SetWindowText(buffer);
 656.473 -
 656.474 -	CenterWindow();
 656.475 -
 656.476 -	return TRUE; // return TRUE unless you set the focus to a control
 656.477 -	             // EXCEPTION: OCX Property Pages should return FALSE
 656.478 -}
 656.479 -
 656.480 -/////////////////////////////////////////////////////////////////////////////
 656.481 -// RomInfoGBA dialog
 656.482 -
 656.483 -RomInfoGBA::RomInfoGBA(u8 *rom, CWnd *pParent /*=NULL*/)
 656.484 -	: CDialog(RomInfoGBA::IDD, pParent)
 656.485 -{
 656.486 -	//{{AFX_DATA_INIT(RomInfoGBA)
 656.487 -	// NOTE: the ClassWizard will add member initialization here
 656.488 -	//}}AFX_DATA_INIT
 656.489 -	this->rom = rom;
 656.490 -}
 656.491 -
 656.492 -void RomInfoGBA::DoDataExchange(CDataExchange *pDX)
 656.493 -{
 656.494 -	CDialog::DoDataExchange(pDX);
 656.495 -	//{{AFX_DATA_MAP(RomInfoGBA)
 656.496 -	// NOTE: the ClassWizard will add DDX and DDV calls here
 656.497 -	//}}AFX_DATA_MAP
 656.498 -}
 656.499 -
 656.500 -BEGIN_MESSAGE_MAP(RomInfoGBA, CDialog)
 656.501 -//{{AFX_MSG_MAP(RomInfoGBA)
 656.502 -ON_BN_CLICKED(ID_OK, OnOk)
 656.503 -//}}AFX_MSG_MAP
 656.504 -END_MESSAGE_MAP()
 656.505 -
 656.506 -/////////////////////////////////////////////////////////////////////////////
 656.507 -// RomInfoGBA message handlers
 656.508 -
 656.509 -void RomInfoGBA::OnOk()
 656.510 -{
 656.511 -	EndDialog(TRUE);
 656.512 -}
 656.513 -
 656.514 -BOOL RomInfoGBA::OnInitDialog()
 656.515 -{
 656.516 -	CDialog::OnInitDialog();
 656.517 -
 656.518 -	char buffer[13];
 656.519 -
 656.520 -	strncpy(buffer, (const char *)&rom[0xa0], 12);
 656.521 -	buffer[12] = 0;
 656.522 -	GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer);
 656.523 -
 656.524 -	strncpy(buffer, (const char *)&rom[0xac], 4);
 656.525 -	buffer[4] = 0;
 656.526 -	GetDlgItem(IDC_ROM_GAME_CODE)->SetWindowText(buffer);
 656.527 -
 656.528 -	strncpy(buffer, (const char *)&rom[0xb0], 2);
 656.529 -	buffer[2] = 0;
 656.530 -	GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
 656.531 -
 656.532 -	GetDlgItem(IDC_ROM_MAKER_NAME)->SetWindowText(winGBARomInfoFindMakerCode(buffer));
 656.533 -
 656.534 -	sprintf(buffer, "%02x", rom[0xb3]);
 656.535 -	GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer);
 656.536 -
 656.537 -	sprintf(buffer, "%02x", rom[0xb4]);
 656.538 -	GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer);
 656.539 -
 656.540 -	sprintf(buffer, "%02x", rom[0xbc]);
 656.541 -	GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer);
 656.542 -
 656.543 -	u8 crc = 0x19;
 656.544 -	for (int i = 0xa0; i < 0xbd; i++)
 656.545 -	{
 656.546 -		crc = (crc + rom[i]) & 0xff;
 656.547 -	}
 656.548 -
 656.549 -	crc = (-crc) & 0xff;
 656.550 -
 656.551 -	sprintf(buffer, "%02x (%02x)", crc, rom[0xbd]);
 656.552 -	GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer);
 656.553 -	CenterWindow();
 656.554 -
 656.555 -	return TRUE; // return TRUE unless you set the focus to a control
 656.556 -	             // EXCEPTION: OCX Property Pages should return FALSE
 656.557 -}
 656.558 -
   657.1 --- a/src/win32/RomInfo.h	Sat Mar 03 10:54:39 2012 -0600
   657.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   657.3 @@ -1,79 +0,0 @@
   657.4 -#if !defined(AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_)
   657.5 -#define AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_
   657.6 -
   657.7 -#if _MSC_VER > 1000
   657.8 -#pragma once
   657.9 -#endif // _MSC_VER > 1000
  657.10 -// -*- C++ -*-
  657.11 -// RomInfo.h : header file
  657.12 -//
  657.13 -
  657.14 -/////////////////////////////////////////////////////////////////////////////
  657.15 -// RomInfoGB dialog
  657.16 -
  657.17 -class RomInfoGB : public CDialog
  657.18 -{
  657.19 -	// Construction
  657.20 -public:
  657.21 -	RomInfoGB(u8 *rom, CWnd*pParent = NULL);  // standard constructor
  657.22 -
  657.23 -	// Dialog Data
  657.24 -	//{{AFX_DATA(RomInfoGB)
  657.25 -	enum { IDD = IDD_GB_ROM_INFO };
  657.26 -	// NOTE: the ClassWizard will add data members here
  657.27 -	//}}AFX_DATA
  657.28 -
  657.29 -	// Overrides
  657.30 -	// ClassWizard generated virtual function overrides
  657.31 -	//{{AFX_VIRTUAL(RomInfoGB)
  657.32 -protected:
  657.33 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  657.34 -	//}}AFX_VIRTUAL
  657.35 -	u8 *rom;
  657.36 -
  657.37 -	// Implementation
  657.38 -protected:
  657.39 -	// Generated message map functions
  657.40 -	//{{AFX_MSG(RomInfoGB)
  657.41 -	afx_msg void OnOk();
  657.42 -	virtual BOOL OnInitDialog();
  657.43 -	//}}AFX_MSG
  657.44 -	DECLARE_MESSAGE_MAP()
  657.45 -};
  657.46 -
  657.47 -/////////////////////////////////////////////////////////////////////////////
  657.48 -// RomInfoGBA dialog
  657.49 -
  657.50 -class RomInfoGBA : public CDialog
  657.51 -{
  657.52 -	// Construction
  657.53 -public:
  657.54 -	RomInfoGBA(u8 *rom, CWnd*pParent = NULL);  // standard constructor
  657.55 -
  657.56 -	// Dialog Data
  657.57 -	//{{AFX_DATA(RomInfoGBA)
  657.58 -	enum { IDD = IDD_GBA_ROM_INFO };
  657.59 -	// NOTE: the ClassWizard will add data members here
  657.60 -	//}}AFX_DATA
  657.61 -	u8 *rom;
  657.62 -
  657.63 -	// Overrides
  657.64 -	// ClassWizard generated virtual function overrides
  657.65 -	//{{AFX_VIRTUAL(RomInfoGBA)
  657.66 -protected:
  657.67 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  657.68 -	//}}AFX_VIRTUAL
  657.69 -
  657.70 -	// Implementation
  657.71 -protected:
  657.72 -	// Generated message map functions
  657.73 -	//{{AFX_MSG(RomInfoGBA)
  657.74 -	afx_msg void OnOk();
  657.75 -	virtual BOOL OnInitDialog();
  657.76 -	//}}AFX_MSG
  657.77 -	DECLARE_MESSAGE_MAP()
  657.78 -};
  657.79 -//{{AFX_INSERT_LOCATION}}
  657.80 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  657.81 -
  657.82 -#endif // !defined(AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_)
   658.1 --- a/src/win32/Sound.h	Sat Mar 03 10:54:39 2012 -0600
   658.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   658.3 @@ -1,19 +0,0 @@
   658.4 -#ifndef VBA_WIN32_SOUND_H
   658.5 -#define VBA_WIN32_SOUND_H
   658.6 -
   658.7 -class ISound
   658.8 -{
   658.9 -public:
  658.10 -	virtual ~ISound() {};
  658.11 -
  658.12 -	virtual bool init()   = 0;
  658.13 -	virtual void pause()  = 0;
  658.14 -	virtual void reset()  = 0;
  658.15 -	virtual void resume() = 0;
  658.16 -	virtual void write()  = 0;
  658.17 -	virtual void setSpeed(float rate) = 0;
  658.18 -	virtual bool isPlaying() = 0;
  658.19 -	virtual void clearAudioBuffer() {}
  658.20 -};
  658.21 -
  658.22 -#endif
   659.1 --- a/src/win32/StringTokenizer.cpp	Sat Mar 03 10:54:39 2012 -0600
   659.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   659.3 @@ -1,44 +0,0 @@
   659.4 -// StringTokenizer.cpp: implementation of the StringTokenizer class.
   659.5 -//
   659.6 -//////////////////////////////////////////////////////////////////////
   659.7 -
   659.8 -#include "stdafx.h"
   659.9 -#include "StringTokenizer.h"
  659.10 -
  659.11 -//////////////////////////////////////////////////////////////////////
  659.12 -// Construction/Destruction
  659.13 -//////////////////////////////////////////////////////////////////////
  659.14 -
  659.15 -StringTokenizer::StringTokenizer(CString str, CString del)
  659.16 -{
  659.17 -	m_right = str;
  659.18 -	m_delim = del;
  659.19 -}
  659.20 -
  659.21 -StringTokenizer::~StringTokenizer()
  659.22 -{}
  659.23 -
  659.24 -const char *StringTokenizer::next()
  659.25 -{
  659.26 -	int index = m_right.FindOneOf(m_delim);
  659.27 -
  659.28 -	while (index == 0)
  659.29 -	{
  659.30 -		m_right = m_right.Right(m_right.GetLength()-1);
  659.31 -		index   = m_right.FindOneOf(m_delim);
  659.32 -	}
  659.33 -	if (index == -1)
  659.34 -	{
  659.35 -		if (m_right.IsEmpty())
  659.36 -			return NULL;
  659.37 -		m_token = m_right;
  659.38 -		m_right.Empty();
  659.39 -		return m_token;
  659.40 -	}
  659.41 -
  659.42 -	m_token = m_right.Left(index);
  659.43 -	m_right = m_right.Right(m_right.GetLength()-(1+index));
  659.44 -
  659.45 -	return m_token;
  659.46 -}
  659.47 -
   660.1 --- a/src/win32/StringTokenizer.h	Sat Mar 03 10:54:39 2012 -0600
   660.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   660.3 @@ -1,24 +0,0 @@
   660.4 -// StringTokenizer.h: interface for the StringTokenizer class.
   660.5 -//
   660.6 -//////////////////////////////////////////////////////////////////////
   660.7 -
   660.8 -#if !defined(AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_)
   660.9 -#define AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_
  660.10 -
  660.11 -#if _MSC_VER > 1000
  660.12 -#pragma once
  660.13 -#endif // _MSC_VER > 1000
  660.14 -
  660.15 -class StringTokenizer
  660.16 -{
  660.17 -public:
  660.18 -	const char *next();
  660.19 -	StringTokenizer(CString str, CString token);
  660.20 -	virtual ~StringTokenizer();
  660.21 -private:
  660.22 -	CString m_token;
  660.23 -	CString m_delim;
  660.24 -	CString m_right;
  660.25 -};
  660.26 -
  660.27 -#endif // !defined(AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_)
   661.1 --- a/src/win32/System.cpp	Sat Mar 03 10:54:39 2012 -0600
   661.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   661.3 @@ -1,936 +0,0 @@
   661.4 -// System.cpp : Defines the system behaviors for the emulator.
   661.5 -//
   661.6 -#include "stdafx.h"
   661.7 -#include "Sound.h"
   661.8 -#include "Input.h"
   661.9 -#include "IUpdate.h"
  661.10 -#include "ram_search.h"
  661.11 -#include "WinMiscUtil.h"
  661.12 -#include "WinResUtil.h"
  661.13 -#include "resource.h"
  661.14 -#include "VBA.h"
  661.15 -#include "../gba/GBA.h"
  661.16 -#include "../gba/GBAGlobals.h"
  661.17 -#include "../gba/GBASound.h"
  661.18 -#include "../gb/GB.h"
  661.19 -#include "../gb/gbGlobals.h"
  661.20 -//#include "../common/System.h"
  661.21 -#include "../common/movie.h"
  661.22 -#include "../common/vbalua.h"
  661.23 -#include "../common/Text.h"
  661.24 -#include "../common/Util.h"
  661.25 -#include "../common/nesvideos-piece.h"
  661.26 -#include "../version.h"
  661.27 -#include <cassert>
  661.28 -
  661.29 -struct EmulatedSystem theEmulator;
  661.30 -
  661.31 -u32	 RGB_LOW_BITS_MASK		 = 0;
  661.32 -int	 emulating				 = 0;
  661.33 -int	 systemCartridgeType	 = 0;
  661.34 -int	 systemSpeed			 = 0;
  661.35 -bool systemSoundOn			 = false;
  661.36 -u32	 systemColorMap32[0x10000];
  661.37 -u16	 systemColorMap16[0x10000];
  661.38 -u16	 systemGbPalette[24];
  661.39 -int	 systemRedShift			 = 0;
  661.40 -int	 systemBlueShift		 = 0;
  661.41 -int	 systemGreenShift		 = 0;
  661.42 -int	 systemColorDepth		 = 16;
  661.43 -int	 systemDebug			 = 0;
  661.44 -int	 systemVerbose			 = 0;
  661.45 -int	 systemFrameSkip		 = 0;
  661.46 -int	 systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
  661.47 -
  661.48 -const int32 INITIAL_SENSOR_VALUE = 2047;
  661.49 -
  661.50 -int32 sensorX = INITIAL_SENSOR_VALUE;
  661.51 -int32 sensorY = INITIAL_SENSOR_VALUE;
  661.52 -u16	  currentButtons [4] = { 0, 0, 0, 0 };	// constrain: never contains hacked buttons, only the lower 16 bits of each are used
  661.53 -u16   lastKeys = 0;
  661.54 -
  661.55 -// static_assertion that BUTTON_REGULAR_RECORDING_MASK should be an u16 constant
  661.56 -namespace { const void * const s_STATIC_ASSERTION_(static_cast<void *>(BUTTON_REGULAR_RECORDING_MASK & 0xFFFF0000)); }
  661.57 -
  661.58 -#define BMP_BUFFER_MAX_WIDTH (256)
  661.59 -#define BMP_BUFFER_MAX_HEIGHT (224)
  661.60 -#define BMP_BUFFER_MAX_DEPTH (4)
  661.61 -static u8 bmpBuffer[BMP_BUFFER_MAX_WIDTH * BMP_BUFFER_MAX_HEIGHT * BMP_BUFFER_MAX_DEPTH];
  661.62 -
  661.63 -static int s_stockThrottleValues[] = {
  661.64 -	6, 15, 25, 25, 37, 50, 75, 87, 100, 112, 125, 150, 200, 300, 400, 600, 800, 1000
  661.65 -};
  661.66 -
  661.67 -// systemXYZ: Win32 stuff
  661.68 -
  661.69 -// input
  661.70 -
  661.71 -void systemSetSensorX(int32 x)
  661.72 -{
  661.73 -	sensorX = x;
  661.74 -}
  661.75 -
  661.76 -void systemSetSensorY(int32 y)
  661.77 -{
  661.78 -	sensorY = y;
  661.79 -}
  661.80 -
  661.81 -void systemResetSensor()
  661.82 -{
  661.83 -	sensorX = sensorY = INITIAL_SENSOR_VALUE;
  661.84 -}
  661.85 -
  661.86 -int32 systemGetSensorX()
  661.87 -{
  661.88 -	return sensorX;
  661.89 -}
  661.90 -
  661.91 -int32 systemGetSensorY()
  661.92 -{
  661.93 -	return sensorY;
  661.94 -}
  661.95 -
  661.96 -// handles motion sensor input
  661.97 -void systemUpdateMotionSensor(int i)
  661.98 -{
  661.99 -	if (i < 0 || i > 3)
 661.100 -		i = 0;
 661.101 -
 661.102 -	if (currentButtons[i] & BUTTON_MASK_LEFT_MOTION)
 661.103 -	{
 661.104 -		sensorX += 3;
 661.105 -		if (sensorX > 2197)
 661.106 -			sensorX = 2197;
 661.107 -		if (sensorX < 2047)
 661.108 -			sensorX = 2057;
 661.109 -	}
 661.110 -	else if (currentButtons[i] & BUTTON_MASK_RIGHT_MOTION)
 661.111 -	{
 661.112 -		sensorX -= 3;
 661.113 -		if (sensorX < 1897)
 661.114 -			sensorX = 1897;
 661.115 -		if (sensorX > 2047)
 661.116 -			sensorX = 2037;
 661.117 -	}
 661.118 -	else if (sensorX > 2047)
 661.119 -	{
 661.120 -		sensorX -= 2;
 661.121 -		if (sensorX < 2047)
 661.122 -			sensorX = 2047;
 661.123 -	}
 661.124 -	else
 661.125 -	{
 661.126 -		sensorX += 2;
 661.127 -		if (sensorX > 2047)
 661.128 -			sensorX = 2047;
 661.129 -	}
 661.130 -
 661.131 -	if (currentButtons[i] & BUTTON_MASK_UP_MOTION)
 661.132 -	{
 661.133 -		sensorY += 3;
 661.134 -		if (sensorY > 2197)
 661.135 -			sensorY = 2197;
 661.136 -		if (sensorY < 2047)
 661.137 -			sensorY = 2057;
 661.138 -	}
 661.139 -	else if (currentButtons[i] & BUTTON_MASK_DOWN_MOTION)
 661.140 -	{
 661.141 -		sensorY -= 3;
 661.142 -		if (sensorY < 1897)
 661.143 -			sensorY = 1897;
 661.144 -		if (sensorY > 2047)
 661.145 -			sensorY = 2037;
 661.146 -	}
 661.147 -	else if (sensorY > 2047)
 661.148 -	{
 661.149 -		sensorY -= 2;
 661.150 -		if (sensorY < 2047)
 661.151 -			sensorY = 2047;
 661.152 -	}
 661.153 -	else
 661.154 -	{
 661.155 -		sensorY += 2;
 661.156 -		if (sensorY > 2047)
 661.157 -			sensorY = 2047;
 661.158 -	}
 661.159 -}
 661.160 -
 661.161 -int systemGetDefaultJoypad()
 661.162 -{
 661.163 -	return theApp.joypadDefault;
 661.164 -}
 661.165 -
 661.166 -void systemSetDefaultJoypad(int which)
 661.167 -{
 661.168 -	theApp.joypadDefault = which;
 661.169 -}
 661.170 -
 661.171 -bool systemReadJoypads()
 661.172 -{
 661.173 -	// this function is called at every frame, even if vba is fast-forwarded.
 661.174 -	// so we try to limit the input frequency here just in case.
 661.175 -	static u32 lastTime = systemGetClock();
 661.176 -	if ((u32)(systemGetClock() - lastTime) < 10)
 661.177 -		return false;
 661.178 -	lastTime = systemGetClock();
 661.179 -
 661.180 -	if (theApp.input)
 661.181 -		return theApp.input->readDevices();
 661.182 -	return false;
 661.183 -}
 661.184 -
 661.185 -u32 systemGetOriginalJoypad(int i, bool sensor)
 661.186 -{
 661.187 -	if (i < 0 || i > 3)
 661.188 -		i = 0;
 661.189 -
 661.190 -	u32 res = 0;
 661.191 -	if (theApp.input)
 661.192 -		res = theApp.input->readDevice(i, sensor);
 661.193 -
 661.194 -	// +auto input, XOR
 661.195 -	// maybe these should be moved into DirectInput.cpp
 661.196 -	if (theApp.autoFire || theApp.autoFire2)
 661.197 -	{
 661.198 -		res ^= (theApp.autoFireToggle ? theApp.autoFire : theApp.autoFire2);
 661.199 -		if (!theApp.autofireAccountForLag || !systemCounters.laggedLast)
 661.200 -		{
 661.201 -			theApp.autoFireToggle = !theApp.autoFireToggle;
 661.202 -		}
 661.203 -	}
 661.204 -	if (theApp.autoHold)
 661.205 -	{
 661.206 -		res ^= theApp.autoHold;
 661.207 -	}
 661.208 -
 661.209 -	// filter buttons
 661.210 -	// maybe better elsewhere?
 661.211 -	if (!theApp.allowLeftRight)
 661.212 -	{
 661.213 -		// disallow L+R or U+D to being pressed at the same time
 661.214 -		if ((res & (BUTTON_MASK_RIGHT | BUTTON_MASK_LEFT)) == (BUTTON_MASK_RIGHT | BUTTON_MASK_LEFT))
 661.215 -			res &= ~BUTTON_MASK_RIGHT;  // leave only LEFT on
 661.216 -		if ((res & (BUTTON_MASK_DOWN | BUTTON_MASK_UP)) == (BUTTON_MASK_DOWN | BUTTON_MASK_UP))
 661.217 -			res &= ~BUTTON_MASK_DOWN;  // leave only UP on
 661.218 -	}
 661.219 -
 661.220 -	if (!sensor)
 661.221 -	{
 661.222 -		if (res & BUTTON_MOTION_MASK)
 661.223 -			res &= ~BUTTON_MOTION_MASK;
 661.224 -	}
 661.225 -
 661.226 -	if (systemCartridgeType != 0 && !gbSgbMode) // regular GB has no L/R buttons
 661.227 -	{
 661.228 -		if (res & (BUTTON_GBA_ONLY))
 661.229 -			res &= ~BUTTON_GBA_ONLY;
 661.230 -	}
 661.231 -
 661.232 -	currentButtons[i] = res & BUTTON_REGULAR_RECORDING_MASK;
 661.233 -
 661.234 -	return res;
 661.235 -}
 661.236 -
 661.237 -u32 systemGetJoypad(int i, bool sensor)
 661.238 -{
 661.239 -	if (i < 0 || i > 3)
 661.240 -		i = 0;
 661.241 -
 661.242 -	// input priority: original+auto < Lua < frame search < movie, correct this if wrong
 661.243 -
 661.244 -	// get original+auto input
 661.245 -	u32 hackedButtons = systemGetOriginalJoypad(i, sensor) & BUTTON_NONRECORDINGONLY_MASK;
 661.246 -	u32 res = currentButtons[i];
 661.247 -
 661.248 -	// since movie input has the highest priority, there's no point to read from other input
 661.249 -	if (VBAMoviePlaying())
 661.250 -	{
 661.251 -		// VBAMovieRead() overwrites currentButtons[i]
 661.252 -		VBAMovieRead(i, sensor);
 661.253 -		res = currentButtons[i];
 661.254 -	}
 661.255 -	else
 661.256 -	{
 661.257 -		// Lua input, shouldn't have any side effect within them
 661.258 -		if (VBALuaUsingJoypad(i))
 661.259 -			res = VBALuaReadJoypad(i);
 661.260 -
 661.261 -		// override input above
 661.262 -		if (theApp.frameSearchSkipping)
 661.263 -			res = theApp.frameSearchOldInput[i];
 661.264 -
 661.265 -		// flush non-hack buttons into the "current buttons" input buffer, which will be read by the movie routine
 661.266 -		currentButtons[i] = res & BUTTON_REGULAR_RECORDING_MASK;
 661.267 -		VBAMovieWrite(i, sensor);
 661.268 -	}
 661.269 -
 661.270 -	return res | hackedButtons;
 661.271 -}
 661.272 -
 661.273 -void systemSetJoypad(int which, u32 buttons)
 661.274 -{
 661.275 -	if (which < 0 || which > 3)
 661.276 -		which = 0;
 661.277 -
 661.278 -	currentButtons[which] = buttons;
 661.279 -
 661.280 -	lastKeys = 0;
 661.281 -}
 661.282 -
 661.283 -void systemClearJoypads()
 661.284 -{
 661.285 -	for (int i = 0; i < 3; ++i)
 661.286 -		currentButtons[i] = 0;
 661.287 -
 661.288 -	lastKeys = 0;
 661.289 -}
 661.290 -
 661.291 -// screen
 661.292 -
 661.293 -// delayed repaint
 661.294 -void systemRefreshScreen()
 661.295 -{
 661.296 -	if (theApp.m_pMainWnd)
 661.297 -	{
 661.298 -		theApp.m_pMainWnd->PostMessage(WM_PAINT, NULL, NULL);
 661.299 -	}
 661.300 -}
 661.301 -
 661.302 -extern bool vbaShuttingDown;
 661.303 -
 661.304 -void systemRenderFrame()
 661.305 -{
 661.306 -	extern long linearSoundFrameCount;
 661.307 -	extern long linearFrameCount;
 661.308 -
 661.309 -	if (vbaShuttingDown)
 661.310 -		return;
 661.311 -
 661.312 -	++theApp.renderedFrames;
 661.313 -
 661.314 -	VBAUpdateFrameCountDisplay();
 661.315 -	VBAUpdateButtonPressDisplay();
 661.316 -
 661.317 -	// "in-game" text rendering
 661.318 -	if (textMethod == 0) // transparent text can only be painted once, so timed messages will not be updated
 661.319 -	{
 661.320 -		extern void DrawLuaGui();
 661.321 -		DrawLuaGui();
 661.322 -
 661.323 -		int copyX = 240, copyY = 160;
 661.324 -		if (systemCartridgeType == 1)
 661.325 -			if (gbBorderOn)
 661.326 -				copyX = 256, copyY = 224;
 661.327 -			else
 661.328 -				copyX = 160, copyY = 144;
 661.329 -		int pitch = copyX * (systemColorDepth / 8) + (systemColorDepth == 24 ? 0 : 4);  // FIXME: sure?
 661.330 -
 661.331 -		DrawTextMessages((u8 *)pix, pitch, 0, copyY);
 661.332 -	}
 661.333 -
 661.334 -	++linearFrameCount;
 661.335 -	if (!theApp.sound)
 661.336 -	{
 661.337 -		if (linearFrameCount > 10000)
 661.338 -			linearFrameCount -= 10000;
 661.339 -		linearSoundFrameCount = linearFrameCount;
 661.340 -	}
 661.341 -
 661.342 -	// record avi
 661.343 -	int width  = 240;
 661.344 -	int height = 160;
 661.345 -	switch (systemCartridgeType)
 661.346 -	{
 661.347 -	case 0:
 661.348 -		width  = 240;
 661.349 -		height = 160;
 661.350 -		break;
 661.351 -	case 1:
 661.352 -		if (gbBorderOn)
 661.353 -		{
 661.354 -			width  = 256;
 661.355 -			height = 224;
 661.356 -		}
 661.357 -		else
 661.358 -		{
 661.359 -			width  = 160;
 661.360 -			height = 144;
 661.361 -		}
 661.362 -		break;
 661.363 -	}
 661.364 -
 661.365 -	bool firstFrameLogged = false;
 661.366 -	--linearFrameCount;
 661.367 -	do
 661.368 -	{
 661.369 -		++linearFrameCount;
 661.370 -
 661.371 -		if (theApp.aviRecording && (!theApp.altAviRecordMethod || (theApp.altAviRecordMethod && !firstFrameLogged)))
 661.372 -		{
 661.373 -			// usually aviRecorder is created when vba starts avi recording, though
 661.374 -			if (theApp.aviRecorder == NULL)
 661.375 -			{
 661.376 -				theApp.aviRecorder = new AVIWrite();
 661.377 -
 661.378 -				theApp.aviRecorder->SetFPS(60);
 661.379 -
 661.380 -				BITMAPINFOHEADER bi;
 661.381 -				memset(&bi, 0, sizeof(bi));
 661.382 -				bi.biSize	   = 0x28;
 661.383 -				bi.biPlanes	   = 1;
 661.384 -				bi.biBitCount  = 24;
 661.385 -				bi.biWidth	   = width;
 661.386 -				bi.biHeight	   = height;
 661.387 -				bi.biSizeImage = 3 * width * height;
 661.388 -				theApp.aviRecorder->SetVideoFormat(&bi);
 661.389 -				if (!theApp.aviRecorder->Open(theApp.aviRecordName))
 661.390 -				{
 661.391 -					delete theApp.aviRecorder;
 661.392 -					theApp.aviRecorder	= NULL;
 661.393 -					theApp.aviRecording = false;
 661.394 -				}
 661.395 -			}
 661.396 -
 661.397 -			if (theApp.aviRecorder != NULL && !theApp.aviRecorder->IsPaused())
 661.398 -			{
 661.399 -				assert(
 661.400 -				    width <= BMP_BUFFER_MAX_WIDTH && height <= BMP_BUFFER_MAX_HEIGHT && systemColorDepth <=
 661.401 -				    BMP_BUFFER_MAX_DEPTH * 8);
 661.402 -				utilWriteBMP(bmpBuffer, width, height, systemColorDepth, pix);
 661.403 -				theApp.aviRecorder->AddFrame(bmpBuffer);
 661.404 -			}
 661.405 -		}
 661.406 -
 661.407 -		if (theApp.nvVideoLog)
 661.408 -		{
 661.409 -			// convert from whatever bit depth to 16-bit, while stripping away extra pixels
 661.410 -			assert(width <= BMP_BUFFER_MAX_WIDTH && height <= BMP_BUFFER_MAX_HEIGHT && 16 <= BMP_BUFFER_MAX_DEPTH * 8);
 661.411 -			utilWriteBMP(bmpBuffer, width, -height, 16, pix);
 661.412 -			NESVideoLoggingVideo((u8 *)bmpBuffer, width, height, 0x1000000 * 60);
 661.413 -		}
 661.414 -
 661.415 -		firstFrameLogged = true;
 661.416 -	}
 661.417 -	while (linearFrameCount < linearSoundFrameCount); // compensate for frames lost due to frame skip being nonzero, etc.
 661.418 -
 661.419 -	if (textMethod != 0) // do not draw Lua HUD to a video dump
 661.420 -	{
 661.421 -		extern void DrawLuaGui();
 661.422 -		DrawLuaGui();
 661.423 -	}
 661.424 -
 661.425 -	// interframe blending
 661.426 -	if (theApp.ifbFunction)
 661.427 -	{
 661.428 -		if (systemColorDepth == 16)
 661.429 -			theApp.ifbFunction(pix + theApp.filterWidth * 2 + 4, theApp.filterWidth * 2 + 4,
 661.430 -			                   theApp.filterWidth, theApp.filterHeight);
 661.431 -		else
 661.432 -			theApp.ifbFunction(pix + theApp.filterWidth * 4 + 4, theApp.filterWidth * 4 + 4,
 661.433 -			                   theApp.filterWidth, theApp.filterHeight);
 661.434 -	}
 661.435 -
 661.436 -	systemRedrawScreen();
 661.437 -}
 661.438 -
 661.439 -void systemRedrawScreen()
 661.440 -{
 661.441 -	if (vbaShuttingDown)
 661.442 -		return;
 661.443 -
 661.444 -	if (theApp.display)
 661.445 -		theApp.display->render();
 661.446 -
 661.447 -	systemUpdateListeners();
 661.448 -}
 661.449 -
 661.450 -void systemUpdateListeners()
 661.451 -{
 661.452 -	if (vbaShuttingDown)
 661.453 -		return;
 661.454 -
 661.455 -	Update_RAM_Search(); // updates RAM search and RAM watch
 661.456 -
 661.457 -	// update viewers etc.
 661.458 -	if (theApp.updateCount)
 661.459 -	{
 661.460 -		POSITION pos = theApp.updateList.GetHeadPosition();
 661.461 -		while (pos)
 661.462 -		{
 661.463 -			IUpdateListener *up = theApp.updateList.GetNext(pos);
 661.464 -			if (up)
 661.465 -				up->update();
 661.466 -		}
 661.467 -	}
 661.468 -}
 661.469 -
 661.470 -int systemScreenCapture(int captureNumber)
 661.471 -{
 661.472 -	return winScreenCapture(captureNumber);
 661.473 -}
 661.474 -
 661.475 -void systemMessage(int number, const char *defaultMsg, ...)
 661.476 -{
 661.477 -	CString buffer;
 661.478 -	va_list valist;
 661.479 -	CString msg = defaultMsg;
 661.480 -	if (number)
 661.481 -		msg = winResLoadString(number);
 661.482 -
 661.483 -	va_start(valist, defaultMsg);
 661.484 -	buffer.FormatV(msg, valist);
 661.485 -
 661.486 -	theApp.winCheckFullscreen();
 661.487 -	systemSoundClearBuffer();
 661.488 -	AfxGetApp()->m_pMainWnd->MessageBox(buffer, winResLoadString(IDS_ERROR), MB_OK | MB_ICONERROR);
 661.489 -
 661.490 -	va_end(valist);
 661.491 -}
 661.492 -
 661.493 -void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList)
 661.494 -{
 661.495 -	if (slot < 0 || slot > SCREEN_MESSAGE_SLOTS)
 661.496 -		return;
 661.497 -
 661.498 -	theApp.screenMessage[slot] = true;
 661.499 -	theApp.screenMessageTime[slot]		  = GetTickCount();
 661.500 -	theApp.screenMessageDuration[slot]	  = duration;
 661.501 -	theApp.screenMessageBuffer[slot]	  = msg;
 661.502 -	theApp.screenMessageColorBuffer[slot] = colorList ? colorList : "";
 661.503 -
 661.504 -	if (theApp.screenMessageBuffer[slot].GetLength() > 40)
 661.505 -		theApp.screenMessageBuffer[slot] = theApp.screenMessageBuffer[slot].Left(40);
 661.506 -
 661.507 -	// update the display when a main slot message appears while the game is paused
 661.508 -	if (slot == 0 && (theApp.paused || (theApp.frameSearching)))
 661.509 -		systemRefreshScreen();
 661.510 -}
 661.511 -
 661.512 -void systemShowSpeed(int speed)
 661.513 -{
 661.514 -	systemSpeed = speed;
 661.515 -	theApp.showRenderedFrames = theApp.renderedFrames;
 661.516 -	theApp.renderedFrames	  = 0;
 661.517 -	if (theApp.videoOption <= VIDEO_4X && theApp.showSpeed)
 661.518 -	{
 661.519 -		CString buffer;
 661.520 -		if (theApp.showSpeed == 1)
 661.521 -			buffer.Format(VBA_NAME_AND_VERSION " %3d%%", systemSpeed);
 661.522 -		else
 661.523 -			buffer.Format(VBA_NAME_AND_VERSION " %3d%% (%d fps | %d skipped)",
 661.524 -			              systemSpeed,
 661.525 -			              theApp.showRenderedFrames,
 661.526 -			              systemFrameSkip);
 661.527 -
 661.528 -		systemSetTitle(buffer);
 661.529 -	}
 661.530 -}
 661.531 -
 661.532 -void systemSetTitle(const char *title)
 661.533 -{
 661.534 -	if (theApp.m_pMainWnd != NULL)
 661.535 -	{
 661.536 -		AfxGetApp()->m_pMainWnd->SetWindowText(title);
 661.537 -	}
 661.538 -}
 661.539 -
 661.540 -// timing/speed
 661.541 -
 661.542 -u32 systemGetClock()
 661.543 -{
 661.544 -	return timeGetTime();
 661.545 -}
 661.546 -
 661.547 -void systemIncreaseThrottle()
 661.548 -{
 661.549 -	int throttle = theApp.throttle;
 661.550 -
 661.551 -	if (throttle < 6)
 661.552 -		++throttle;
 661.553 -	else if (throttle < s_stockThrottleValues[_countof(s_stockThrottleValues) - 1])
 661.554 -	{
 661.555 -		int i = 0;
 661.556 -		while (throttle >= s_stockThrottleValues[i])
 661.557 -		{
 661.558 -			++i;
 661.559 -		}
 661.560 -		throttle = s_stockThrottleValues[i];
 661.561 -	}
 661.562 -
 661.563 -	systemSetThrottle(throttle);
 661.564 -}
 661.565 -
 661.566 -void systemDecreaseThrottle()
 661.567 -{
 661.568 -	int throttle = theApp.throttle;
 661.569 -
 661.570 -	if (throttle > 6)
 661.571 -	{
 661.572 -		int i = _countof(s_stockThrottleValues) - 1;
 661.573 -		while (throttle <= s_stockThrottleValues[i])
 661.574 -		{
 661.575 -			--i;
 661.576 -		}
 661.577 -		throttle = s_stockThrottleValues[i];
 661.578 -	}
 661.579 -	else if (throttle > 1)
 661.580 -		--throttle;
 661.581 -
 661.582 -	systemSetThrottle(throttle);
 661.583 -}
 661.584 -
 661.585 -void systemSetThrottle(int throttle)
 661.586 -{
 661.587 -	theApp.throttle = throttle;
 661.588 -	char str[256];
 661.589 -	sprintf(str, "%d%% throttle speed", theApp.throttle);
 661.590 -	systemScreenMessage(str);
 661.591 -}
 661.592 -
 661.593 -int systemGetThrottle()
 661.594 -{
 661.595 -	return theApp.throttle;
 661.596 -}
 661.597 -
 661.598 -void systemFrame()
 661.599 -{
 661.600 -	if (theApp.altAviRecordMethod && theApp.aviRecording)
 661.601 -	{
 661.602 -		if (theApp.aviRecorder)
 661.603 -		{
 661.604 -			if (!theApp.aviRecorder->IsSoundAdded())
 661.605 -			{
 661.606 -				WAVEFORMATEX wfx;
 661.607 -				memset(&wfx, 0, sizeof(wfx));
 661.608 -				wfx.wFormatTag		= WAVE_FORMAT_PCM;
 661.609 -				wfx.nChannels		= 2;
 661.610 -				wfx.nSamplesPerSec	= 44100 / soundQuality;
 661.611 -				wfx.wBitsPerSample	= 16;
 661.612 -				wfx.nBlockAlign		= (wfx.wBitsPerSample / 8) * wfx.nChannels;
 661.613 -				wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
 661.614 -				wfx.cbSize = 0;
 661.615 -				theApp.aviRecorder->SetSoundFormat(&wfx);
 661.616 -			}
 661.617 -			theApp.aviRecorder->AddSound((u8 *)soundFrameSound, soundFrameSoundWritten * 2);
 661.618 -		}
 661.619 -	}
 661.620 -
 661.621 -	soundFrameSoundWritten = 0;
 661.622 -
 661.623 -	// no more stupid updates :)
 661.624 -
 661.625 -	extern int quitAfterTime;                   // from VBA.cpp
 661.626 -	void	   VBAMovieStop(bool8 suppress_message); // from ../movie.cpp
 661.627 -	if (quitAfterTime >= 0 && systemCounters.frameCount == quitAfterTime)
 661.628 -	{
 661.629 -		VBAMovieStop(true);
 661.630 -		AfxPostQuitMessage(0);
 661.631 -	}
 661.632 -
 661.633 -	// change the sound speed, or set it to normal - must always do this or it won't get reset after a change, but that's OK
 661.634 -	// because it's inexpensive
 661.635 -	if (theApp.sound)
 661.636 -	{
 661.637 -		theApp.sound->setSpeed(
 661.638 -		    speedup || theApp.winPauseNextFrame || !synchronize || theApp.accuratePitchThrottle || theApp.useOldSync
 661.639 -			? 1.0f : (float)theApp.throttle / 100.0f);
 661.640 -	}
 661.641 -
 661.642 -	// if a throttle speed is set and we're not allowed to change the sound frequency to achieve it,
 661.643 -	// sleep for a certain amount each time we get here to approximate the necessary slowdown
 661.644 -	if (synchronize && (theApp.accuratePitchThrottle || !theApp.sound || theApp.throttle < 6) /*&& !theApp.winPauseNextFrame*/)
 661.645 -	{
 661.646 -		/// FIXME: this is still a horrible way of achieving a certain frame time
 661.647 -		///        (look at what Snes9x does - it's complicated but much much better)
 661.648 -
 661.649 -		static float sleepAmt = 0.0f; // variable to smooth out the sleeping amount so it doesn't oscillate so fast
 661.650 -//		if(!theApp.wasPaused) {
 661.651 -		if (!speedup)
 661.652 -		{
 661.653 -			u32 time = systemGetClock();
 661.654 -			u32 diff = time - theApp.throttleLastTime;
 661.655 -			if (theApp.wasPaused)
 661.656 -				diff = 0;
 661.657 -
 661.658 -			int target = (100000 / (60 * theApp.throttle));
 661.659 -			int d	   = (target - diff);
 661.660 -
 661.661 -			if (d > 1000) // added to avoid 500-day waits for vba to start emulating.
 661.662 -				d = 1000;  // I suspect most users aren't that patient, and would find 1 second to be a more reasonable delay.
 661.663 -
 661.664 -			sleepAmt = 0.8f * sleepAmt + 0.2f * (float)d;
 661.665 -			if (d - sleepAmt <= 1.5f && d - sleepAmt >= -1.5f)
 661.666 -				d = (int)(sleepAmt);
 661.667 -
 661.668 -			if (d > 0)
 661.669 -			{
 661.670 -				Sleep(d);
 661.671 -			}
 661.672 -		}
 661.673 -		theApp.throttleLastTime = systemGetClock();
 661.674 -		//}
 661.675 -		//else
 661.676 -		//{
 661.677 -		// Sleep(100);
 661.678 -		//}
 661.679 -	}
 661.680 -
 661.681 -	if (systemCounters.frameCount % 10 == 0)
 661.682 -	{
 661.683 -		if (theApp.rewindMemory)
 661.684 -		{
 661.685 -			if (++theApp.rewindCounter >= (theApp.rewindTimer))
 661.686 -			{
 661.687 -				theApp.rewindSaveNeeded = true;
 661.688 -				theApp.rewindCounter	= 0;
 661.689 -			}
 661.690 -		}
 661.691 -		if (systemSaveUpdateCounter)
 661.692 -		{
 661.693 -			if (--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED)
 661.694 -			{
 661.695 -				winWriteBatteryFile();
 661.696 -				systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 661.697 -			}
 661.698 -		}
 661.699 -	}
 661.700 -
 661.701 -	theApp.wasPaused = false;
 661.702 -///  theApp.autoFrameSkipLastTime = time;
 661.703 -}
 661.704 -
 661.705 -int systemFramesToSkip()
 661.706 -{
 661.707 -	int framesToSkip = systemFrameSkip;
 661.708 -
 661.709 -	bool fastForward = speedup;
 661.710 -
 661.711 -#if (defined(WIN32) && !defined(SDL))
 661.712 -	fastForward = (fastForward || theApp.frameSearchSkipping);
 661.713 -	int throttle = theApp.throttle;
 661.714 -	if (theApp.frameSearching && throttle < 100)
 661.715 -		throttle = 100;
 661.716 -#else
 661.717 -	extern int throttle;
 661.718 -#endif
 661.719 -
 661.720 -#if (defined(WIN32) && !defined(SDL))
 661.721 -	if (theApp.aviRecording || theApp.nvVideoLog)
 661.722 -	{
 661.723 -		framesToSkip = 0; // render all frames
 661.724 -	}
 661.725 -	else
 661.726 -	{
 661.727 -		if (fastForward)
 661.728 -			framesToSkip = 9;  // try 6 FPS during speedup
 661.729 -		else if (throttle != 100)
 661.730 -			framesToSkip = (framesToSkip * throttle) / 100;
 661.731 -	}
 661.732 -#endif
 661.733 -
 661.734 -	return framesToSkip;
 661.735 -}
 661.736 -
 661.737 -// sound
 661.738 -
 661.739 -bool systemSoundInit()
 661.740 -{
 661.741 -	if (theApp.sound)
 661.742 -		delete theApp.sound;
 661.743 -
 661.744 -	extern ISound *newDirectSound();
 661.745 -	theApp.sound = newDirectSound();
 661.746 -	return theApp.sound->init();
 661.747 -}
 661.748 -
 661.749 -void systemSoundShutdown()
 661.750 -{
 661.751 -	if (theApp.sound)
 661.752 -		delete theApp.sound;
 661.753 -	theApp.sound = NULL;
 661.754 -}
 661.755 -
 661.756 -void systemSoundPause()
 661.757 -{
 661.758 -	if (theApp.sound)
 661.759 -		theApp.sound->pause();
 661.760 -	soundPaused = 1;
 661.761 -}
 661.762 -
 661.763 -void systemSoundResume()
 661.764 -{
 661.765 -	if (theApp.sound)
 661.766 -		theApp.sound->resume();
 661.767 -	soundPaused = 0;
 661.768 -}
 661.769 -
 661.770 -bool systemSoundIsPaused()
 661.771 -{
 661.772 -//	return soundPaused;
 661.773 -	return !(theApp.sound && theApp.sound->isPlaying());
 661.774 -}
 661.775 -
 661.776 -void systemSoundClearBuffer()
 661.777 -{
 661.778 -	if (theApp.sound)
 661.779 -		theApp.sound->clearAudioBuffer();
 661.780 -}
 661.781 -
 661.782 -void systemSoundReset()
 661.783 -{
 661.784 -	if (theApp.sound)
 661.785 -		theApp.sound->reset();
 661.786 -}
 661.787 -
 661.788 -void systemSoundWriteToBuffer()
 661.789 -{
 661.790 -	if (theApp.sound)
 661.791 -		theApp.sound->write();
 661.792 -}
 661.793 -
 661.794 -bool systemSoundCanChangeQuality()
 661.795 -{
 661.796 -	return true;
 661.797 -}
 661.798 -
 661.799 -bool systemSoundSetQuality(int quality)
 661.800 -{
 661.801 -	if (systemCartridgeType == 0)
 661.802 -		soundSetQuality(quality);
 661.803 -	else
 661.804 -		gbSoundSetQuality(quality);
 661.805 -
 661.806 -	return true;
 661.807 -}
 661.808 -
 661.809 -// emulation
 661.810 -
 661.811 -bool systemIsEmulating()
 661.812 -{
 661.813 -	return emulating != 0;
 661.814 -}
 661.815 -
 661.816 -void systemGbBorderOn()
 661.817 -{
 661.818 -	if (vbaShuttingDown)
 661.819 -		return;
 661.820 -
 661.821 -	if (emulating && systemCartridgeType == 1)
 661.822 -	{
 661.823 -		theApp.updateWindowSize(theApp.videoOption);
 661.824 -	}
 661.825 -}
 661.826 -
 661.827 -bool systemIsRunningGBA()
 661.828 -{
 661.829 -	return (systemCartridgeType == 0);
 661.830 -}
 661.831 -
 661.832 -bool systemIsSpedUp()
 661.833 -{
 661.834 -	return theApp.speedupToggle;
 661.835 -}
 661.836 -
 661.837 -bool systemIsPaused()
 661.838 -{
 661.839 -	return theApp.paused;
 661.840 -}
 661.841 -
 661.842 -void systemSetPause(bool pause)
 661.843 -{
 661.844 -	if (pause)
 661.845 -	{
 661.846 -		capturePrevious	 = false;
 661.847 -		theApp.wasPaused = true;
 661.848 -		theApp.paused	 = true;
 661.849 -		theApp.speedupToggle = false;
 661.850 -		theApp.winPauseNextFrame = false;
 661.851 -		systemSoundPause();
 661.852 -		systemRefreshScreen();;
 661.853 -	}
 661.854 -	else
 661.855 -	{
 661.856 -		theApp.paused	 = false;
 661.857 -		systemSoundResume();
 661.858 -	}
 661.859 -}
 661.860 -
 661.861 -// aka. frame advance
 661.862 -bool systemPauseOnFrame()
 661.863 -{
 661.864 -	if (theApp.winPauseNextFrame)
 661.865 -	{
 661.866 -		if (!theApp.nextframeAccountForLag || !systemCounters.laggedLast)
 661.867 -		{
 661.868 -			theApp.winPauseNextFrame   = false;
 661.869 -			return true;
 661.870 -		}
 661.871 -	}
 661.872 -
 661.873 -	return false;
 661.874 -}
 661.875 -
 661.876 -bool systemLoadBIOS(const char *biosFileName, bool useBiosFile)
 661.877 -{
 661.878 -	bool use = false;
 661.879 -	if (systemCartridgeType == 0)
 661.880 -		use = CPULoadBios(biosFileName, useBiosFile);
 661.881 -	else
 661.882 -		use = false;
 661.883 -	return use;
 661.884 -}
 661.885 -
 661.886 -// FIXME: now platform-independant stuff
 661.887 -// it should be admitted that the naming schema/code organization is a whole mess
 661.888 -// these things should be moved somewhere else
 661.889 -
 661.890 -EmulatedSystemCounters systemCounters =
 661.891 -{
 661.892 -	// frameCount
 661.893 -	0,
 661.894 -	// lagCount
 661.895 -	0,
 661.896 -	// extraCount
 661.897 -	0,
 661.898 -	// lagged
 661.899 -	true,
 661.900 -	// laggedLast
 661.901 -	true,
 661.902 -};
 661.903 -
 661.904 -// VBAxyz stuff are not part of the core.
 661.905 -
 661.906 -void VBAOnEnteringFrameBoundary()
 661.907 -{
 661.908 -	CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
 661.909 -
 661.910 -	if (VBALuaRunning())
 661.911 -	{
 661.912 -		VBALuaFrameBoundary();
 661.913 -	}
 661.914 -
 661.915 -	VBAMovieUpdateState();
 661.916 -}
 661.917 -
 661.918 -void VBAOnExitingFrameBoundary()
 661.919 -{
 661.920 -	;
 661.921 -}
 661.922 -
 661.923 -//////////////////////////////////////////////
 661.924 -// ultility
 661.925 -
 661.926 -extern void toolsLog(const char *);
 661.927 -
 661.928 -void log(const char *msg, ...)
 661.929 -{
 661.930 -	CString buffer;
 661.931 -	va_list valist;
 661.932 -
 661.933 -	va_start(valist, msg);
 661.934 -	buffer.FormatV(msg, valist);
 661.935 -
 661.936 -	toolsLog(buffer);
 661.937 -
 661.938 -	va_end(valist);
 661.939 -}
   662.1 --- a/src/win32/TextOptions.cpp	Sat Mar 03 10:54:39 2012 -0600
   662.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   662.3 @@ -1,81 +0,0 @@
   662.4 -// TextOptions.cpp : implementation file
   662.5 -//
   662.6 -
   662.7 -#include "stdafx.h"
   662.8 -#include "../common/Text.h"
   662.9 -#include "resource.h"
  662.10 -#include "TextOptions.h"
  662.11 -
  662.12 -// TextOptions dialog
  662.13 -
  662.14 -IMPLEMENT_DYNAMIC(TextOptions, CDialog)
  662.15 -TextOptions::TextOptions(CWnd*pParent /*=NULL*/)
  662.16 -	: CDialog(TextOptions::IDD, pParent)
  662.17 -{}
  662.18 -
  662.19 -TextOptions::~TextOptions()
  662.20 -{}
  662.21 -
  662.22 -BOOL TextOptions::OnInitDialog()
  662.23 -{
  662.24 -	CDialog::OnInitDialog();
  662.25 -
  662.26 -	CheckRadioButton(IDC_RADIO_WHITE, IDC_RADIO_BLACK, IDC_RADIO_WHITE + textColor);
  662.27 -	CheckRadioButton(IDC_RADIO_PREFILTER, IDC_RADIO_POSTRENDER, IDC_RADIO_PREFILTER + textMethod);
  662.28 -	CheckDlgButton(IDC_CHECK_OUTLINED, outlinedText);
  662.29 -	CheckDlgButton(IDC_CHECK_TRANSPARENT, transparentText);
  662.30 -	GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(GetCheckedRadioButton(IDC_RADIO_PREFILTER,
  662.31 -	                                                                      IDC_RADIO_POSTRENDER) != IDC_RADIO_POSTRENDER);
  662.32 -
  662.33 -	return TRUE;  // return TRUE unless you set the focus to a control
  662.34 -	// EXCEPTION: OCX Property Pages should return FALSE
  662.35 -}
  662.36 -
  662.37 -void TextOptions::DoDataExchange(CDataExchange*pDX)
  662.38 -{
  662.39 -	CDialog::DoDataExchange(pDX);
  662.40 -}
  662.41 -
  662.42 -BEGIN_MESSAGE_MAP(TextOptions, CDialog)
  662.43 -ON_BN_CLICKED(IDOK, OnBnClickedOk)
  662.44 -ON_BN_CLICKED(IDC_RADIO_PREFILTER, OnBnClickedRadioPrefilter)
  662.45 -ON_BN_CLICKED(IDC_RADIO_POSTFILTER, OnBnClickedRadioPostfilter)
  662.46 -ON_BN_CLICKED(IDC_RADIO_POSTRENDER, OnBnClickedRadioPostrender)
  662.47 -END_MESSAGE_MAP()
  662.48 -
  662.49 -// TextOptions message handlers
  662.50 -
  662.51 -void TextOptions::OnBnClickedOk()
  662.52 -{
  662.53 -	transparentText = IsDlgButtonChecked(IDC_CHECK_TRANSPARENT) != 0;
  662.54 -	outlinedText    = IsDlgButtonChecked(IDC_CHECK_OUTLINED) != 0;
  662.55 -	textMethod      = GetCheckedRadioButton(IDC_RADIO_PREFILTER, IDC_RADIO_POSTRENDER) - IDC_RADIO_PREFILTER;
  662.56 -	textColor       = GetCheckedRadioButton(IDC_RADIO_WHITE, IDC_RADIO_BLACK) - IDC_RADIO_WHITE;
  662.57 -	if (textMethod < 0)
  662.58 -		textMethod = 0;
  662.59 -	if (textMethod > 2)
  662.60 -		textMethod = 2;
  662.61 -	if (textColor < 0)
  662.62 -		textColor = 0;
  662.63 -	if (textColor > 7)
  662.64 -		textColor = 7;
  662.65 -
  662.66 -	OnOK();
  662.67 -}
  662.68 -
  662.69 -void TextOptions::OnBnClickedRadioPrefilter()
  662.70 -{
  662.71 -	GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(TRUE);
  662.72 -}
  662.73 -
  662.74 -void TextOptions::OnBnClickedRadioPostfilter()
  662.75 -{
  662.76 -	GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(TRUE);
  662.77 -}
  662.78 -
  662.79 -void TextOptions::OnBnClickedRadioPostrender()
  662.80 -{
  662.81 -	GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(FALSE);
  662.82 -	CheckDlgButton(IDC_CHECK_TRANSPARENT, FALSE);
  662.83 -}
  662.84 -
   663.1 --- a/src/win32/TextOptions.h	Sat Mar 03 10:54:39 2012 -0600
   663.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   663.3 @@ -1,34 +0,0 @@
   663.4 -#ifndef VBA_WIN32_TEXT_OPTIONS_H
   663.5 -#define VBA_WIN32_TEXT_OPTIONS_H
   663.6 -
   663.7 -#if _MSC_VER > 1000
   663.8 -#pragma once
   663.9 -#endif // _MSC_VER > 1000
  663.10 -
  663.11 -// TextOptions dialog
  663.12 -
  663.13 -class TextOptions : public CDialog
  663.14 -{
  663.15 -	DECLARE_DYNAMIC(TextOptions)
  663.16 -
  663.17 -public:
  663.18 -	TextOptions(CWnd* pParent = NULL);   // standard constructor
  663.19 -	virtual ~TextOptions();
  663.20 -
  663.21 -	virtual BOOL OnInitDialog() ;
  663.22 -
  663.23 -// Dialog Data
  663.24 -	enum { IDD = IDD_TEXTCONFIG };
  663.25 -
  663.26 -protected:
  663.27 -	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  663.28 -
  663.29 -	DECLARE_MESSAGE_MAP()
  663.30 -public:
  663.31 -	afx_msg void OnBnClickedOk();
  663.32 -	afx_msg void OnBnClickedRadioPrefilter();
  663.33 -	afx_msg void OnBnClickedRadioPostfilter();
  663.34 -	afx_msg void OnBnClickedRadioPostrender();
  663.35 -};
  663.36 -
  663.37 -#endif
   664.1 --- a/src/win32/Throttle.cpp	Sat Mar 03 10:54:39 2012 -0600
   664.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   664.3 @@ -1,62 +0,0 @@
   664.4 -// Throttle.cpp : implementation file
   664.5 -//
   664.6 -
   664.7 -#include "stdafx.h"
   664.8 -#include "resource.h"
   664.9 -#include "Throttle.h"
  664.10 -#include "../common/System.h" // for system messages
  664.11 -
  664.12 -/////////////////////////////////////////////////////////////////////////////
  664.13 -// Throttle dialog
  664.14 -
  664.15 -Throttle::Throttle(CWnd*pParent /*=NULL*/)
  664.16 -	: CDialog(Throttle::IDD, pParent)
  664.17 -{
  664.18 -	//{{AFX_DATA_INIT(Throttle)
  664.19 -	m_throttle = 100;
  664.20 -	//}}AFX_DATA_INIT
  664.21 -}
  664.22 -
  664.23 -void Throttle::DoDataExchange(CDataExchange*pDX)
  664.24 -{
  664.25 -	CDialog::DoDataExchange(pDX);
  664.26 -	//{{AFX_DATA_MAP(Throttle)
  664.27 -	DDX_Text(pDX, IDC_THROTTLE, m_throttle);
  664.28 -	//}}AFX_DATA_MAP
  664.29 -}
  664.30 -
  664.31 -BEGIN_MESSAGE_MAP(Throttle, CDialog)
  664.32 -//{{AFX_MSG_MAP(Throttle)
  664.33 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
  664.34 -ON_BN_CLICKED(ID_OK, OnOk)
  664.35 -//}}AFX_MSG_MAP
  664.36 -END_MESSAGE_MAP()
  664.37 -
  664.38 -/////////////////////////////////////////////////////////////////////////////
  664.39 -// Throttle message handlers
  664.40 -
  664.41 -BOOL Throttle::OnInitDialog()
  664.42 -{
  664.43 -	CDialog::OnInitDialog();
  664.44 -
  664.45 -	CenterWindow();
  664.46 -
  664.47 -	return TRUE; // return TRUE unless you set the focus to a control
  664.48 -	             // EXCEPTION: OCX Property Pages should return FALSE
  664.49 -}
  664.50 -
  664.51 -void Throttle::OnCancel()
  664.52 -{
  664.53 -	EndDialog(false);
  664.54 -}
  664.55 -
  664.56 -void Throttle::OnOk()
  664.57 -{
  664.58 -	UpdateData();
  664.59 -
  664.60 -	if (m_throttle < 1 || m_throttle > 1000)
  664.61 -		systemMessage(IDS_INVALID_THROTTLE_VALUE, "Invalid throttle value. Please enter a number between 1 and 1000");
  664.62 -	else
  664.63 -		EndDialog(m_throttle);
  664.64 -}
  664.65 -
   665.1 --- a/src/win32/Throttle.h	Sat Mar 03 10:54:39 2012 -0600
   665.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   665.3 @@ -1,46 +0,0 @@
   665.4 -#if !defined(AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_)
   665.5 -#define AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_
   665.6 -
   665.7 -#if _MSC_VER > 1000
   665.8 -#pragma once
   665.9 -#endif // _MSC_VER > 1000
  665.10 -// Throttle.h : header file
  665.11 -//
  665.12 -
  665.13 -/////////////////////////////////////////////////////////////////////////////
  665.14 -// Throttle dialog
  665.15 -
  665.16 -class Throttle : public CDialog
  665.17 -{
  665.18 -	// Construction
  665.19 -public:
  665.20 -	Throttle(CWnd*pParent = NULL);  // standard constructor
  665.21 -
  665.22 -	// Dialog Data
  665.23 -	//{{AFX_DATA(Throttle)
  665.24 -	enum { IDD = IDD_THROTTLE };
  665.25 -	int m_throttle;
  665.26 -	//}}AFX_DATA
  665.27 -
  665.28 -	// Overrides
  665.29 -	// ClassWizard generated virtual function overrides
  665.30 -	//{{AFX_VIRTUAL(Throttle)
  665.31 -protected:
  665.32 -	virtual void DoDataExchange(CDataExchange*pDX);   // DDX/DDV support
  665.33 -	//}}AFX_VIRTUAL
  665.34 -
  665.35 -	// Implementation
  665.36 -protected:
  665.37 -	// Generated message map functions
  665.38 -	//{{AFX_MSG(Throttle)
  665.39 -	virtual BOOL OnInitDialog();
  665.40 -	afx_msg void OnCancel();
  665.41 -	afx_msg void OnOk();
  665.42 -	//}}AFX_MSG
  665.43 -	DECLARE_MESSAGE_MAP()
  665.44 -};
  665.45 -
  665.46 -//{{AFX_INSERT_LOCATION}}
  665.47 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  665.48 -
  665.49 -#endif // !defined(AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_)
   666.1 --- a/src/win32/TileView.cpp	Sat Mar 03 10:54:39 2012 -0600
   666.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   666.3 @@ -1,582 +0,0 @@
   666.4 -// TileView.cpp : implementation file
   666.5 -//
   666.6 -
   666.7 -#include "stdafx.h"
   666.8 -#include "resource.h"
   666.9 -#include "FileDlg.h"
  666.10 -#include "Reg.h"
  666.11 -#include "TileView.h"
  666.12 -#include "WinResUtil.h"
  666.13 -#include "VBA.h" // for theApp
  666.14 -
  666.15 -#include "../gba/GBAGlobals.h"
  666.16 -#include "../NLS.h"
  666.17 -#include "../common/Util.h"
  666.18 -
  666.19 -extern "C" {
  666.20 -#include <png.h>
  666.21 -}
  666.22 -
  666.23 -/////////////////////////////////////////////////////////////////////////////
  666.24 -// TileView dialog
  666.25 -
  666.26 -TileView::TileView(CWnd*pParent /*=NULL*/)
  666.27 -	: ResizeDlg(TileView::IDD, pParent)
  666.28 -{
  666.29 -	//{{AFX_DATA_INIT(TileView)
  666.30 -	m_colors   = -1;
  666.31 -	m_charBase = -1;
  666.32 -	m_stretch  = FALSE;
  666.33 -	//}}AFX_DATA_INIT
  666.34 -	autoUpdate = false;
  666.35 -
  666.36 -	memset(&bmpInfo, 0, sizeof(bmpInfo));
  666.37 -
  666.38 -	bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
  666.39 -	bmpInfo.bmiHeader.biWidth       = 32*8;
  666.40 -	bmpInfo.bmiHeader.biHeight      = 32*8;
  666.41 -	bmpInfo.bmiHeader.biPlanes      = 1;
  666.42 -	bmpInfo.bmiHeader.biBitCount    = 24;
  666.43 -	bmpInfo.bmiHeader.biCompression = BI_RGB;
  666.44 -	data = (u8 *)calloc(1, 3 * 32*32 * 64);
  666.45 -
  666.46 -	tileView.setData(data);
  666.47 -	tileView.setBmpInfo(&bmpInfo);
  666.48 -
  666.49 -	charBase    = 0;
  666.50 -	is256Colors = 0;
  666.51 -	palette     = 0;
  666.52 -	w = h = 0;
  666.53 -}
  666.54 -
  666.55 -TileView::~TileView()
  666.56 -{
  666.57 -	free(data);
  666.58 -	data = NULL;
  666.59 -}
  666.60 -
  666.61 -void TileView::DoDataExchange(CDataExchange*pDX)
  666.62 -{
  666.63 -	CDialog::DoDataExchange(pDX);
  666.64 -	//{{AFX_DATA_MAP(TileView)
  666.65 -	DDX_Control(pDX, IDC_PALETTE_SLIDER, m_slider);
  666.66 -	DDX_Radio(pDX, IDC_16_COLORS, m_colors);
  666.67 -	DDX_Radio(pDX, IDC_CHARBASE_0, m_charBase);
  666.68 -	DDX_Check(pDX, IDC_STRETCH, m_stretch);
  666.69 -	//}}AFX_DATA_MAP
  666.70 -	DDX_Control(pDX, IDC_TILE_VIEW, tileView);
  666.71 -	DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, zoom);
  666.72 -	DDX_Control(pDX, IDC_COLOR, color);
  666.73 -}
  666.74 -
  666.75 -BEGIN_MESSAGE_MAP(TileView, CDialog)
  666.76 -//{{AFX_MSG_MAP(TileView)
  666.77 -ON_BN_CLICKED(IDC_SAVE, OnSave)
  666.78 -ON_BN_CLICKED(IDC_CLOSE, OnClose)
  666.79 -ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
  666.80 -ON_BN_CLICKED(IDC_16_COLORS, On16Colors)
  666.81 -ON_BN_CLICKED(IDC_256_COLORS, On256Colors)
  666.82 -ON_BN_CLICKED(IDC_CHARBASE_0, OnCharbase0)
  666.83 -ON_BN_CLICKED(IDC_CHARBASE_1, OnCharbase1)
  666.84 -ON_BN_CLICKED(IDC_CHARBASE_2, OnCharbase2)
  666.85 -ON_BN_CLICKED(IDC_CHARBASE_3, OnCharbase3)
  666.86 -ON_BN_CLICKED(IDC_CHARBASE_4, OnCharbase4)
  666.87 -ON_BN_CLICKED(IDC_STRETCH, OnStretch)
  666.88 -ON_WM_HSCROLL()
  666.89 -//}}AFX_MSG_MAP
  666.90 -ON_MESSAGE(WM_MAPINFO, OnMapInfo)
  666.91 -ON_MESSAGE(WM_COLINFO, OnColInfo)
  666.92 -END_MESSAGE_MAP()
  666.93 -
  666.94 -/////////////////////////////////////////////////////////////////////////////
  666.95 -// TileView message handlers
  666.96 -
  666.97 -void TileView::saveBMP(const char *name)
  666.98 -{
  666.99 -	u8 writeBuffer[1024 * 3];
 666.100 -
 666.101 -	FILE *fp = fopen(name, "wb");
 666.102 -
 666.103 -	if (!fp)
 666.104 -	{
 666.105 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 666.106 -		return;
 666.107 -	}
 666.108 -
 666.109 -	struct
 666.110 -	{
 666.111 -		u8 ident[2];
 666.112 -		u8 filesize[4];
 666.113 -		u8 reserved[4];
 666.114 -		u8 dataoffset[4];
 666.115 -		u8 headersize[4];
 666.116 -		u8 width[4];
 666.117 -		u8 height[4];
 666.118 -		u8 planes[2];
 666.119 -		u8 bitsperpixel[2];
 666.120 -		u8 compression[4];
 666.121 -		u8 datasize[4];
 666.122 -		u8 hres[4];
 666.123 -		u8 vres[4];
 666.124 -		u8 colors[4];
 666.125 -		u8 importantcolors[4];
 666.126 -		u8 pad[2];
 666.127 -	} bmpheader;
 666.128 -	memset(&bmpheader, 0, sizeof(bmpheader));
 666.129 -
 666.130 -	bmpheader.ident[0] = 'B';
 666.131 -	bmpheader.ident[1] = 'M';
 666.132 -
 666.133 -	u32 fsz = sizeof(bmpheader) + w*h*3;
 666.134 -	utilPutDword(bmpheader.filesize, fsz);
 666.135 -	utilPutDword(bmpheader.dataoffset, 0x38);
 666.136 -	utilPutDword(bmpheader.headersize, 0x28);
 666.137 -	utilPutDword(bmpheader.width, w);
 666.138 -	utilPutDword(bmpheader.height, h);
 666.139 -	utilPutDword(bmpheader.planes, 1);
 666.140 -	utilPutDword(bmpheader.bitsperpixel, 24);
 666.141 -	utilPutDword(bmpheader.datasize, 3*w*h);
 666.142 -
 666.143 -	fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
 666.144 -
 666.145 -	u8 *b = writeBuffer;
 666.146 -
 666.147 -	int sizeX = w;
 666.148 -	int sizeY = h;
 666.149 -
 666.150 -	u8 *pixU8 = (u8 *)data+3*w*(h-1);
 666.151 -	for (int y = 0; y < sizeY; y++)
 666.152 -	{
 666.153 -		for (int x = 0; x < sizeX; x++)
 666.154 -		{
 666.155 -			*b++ = *pixU8++; // B
 666.156 -			*b++ = *pixU8++; // G
 666.157 -			*b++ = *pixU8++; // R
 666.158 -		}
 666.159 -		pixU8 -= 2*3*w;
 666.160 -		fwrite(writeBuffer, 1, 3*w, fp);
 666.161 -
 666.162 -		b = writeBuffer;
 666.163 -	}
 666.164 -
 666.165 -	fclose(fp);
 666.166 -}
 666.167 -
 666.168 -void TileView::savePNG(const char *name)
 666.169 -{
 666.170 -	u8 writeBuffer[1024 * 3];
 666.171 -
 666.172 -	FILE *fp = fopen(name, "wb");
 666.173 -
 666.174 -	if (!fp)
 666.175 -	{
 666.176 -		systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
 666.177 -		return;
 666.178 -	}
 666.179 -
 666.180 -	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 666.181 -	                                              NULL,
 666.182 -	                                              NULL,
 666.183 -	                                              NULL);
 666.184 -	if (!png_ptr)
 666.185 -	{
 666.186 -		fclose(fp);
 666.187 -		return;
 666.188 -	}
 666.189 -
 666.190 -	png_infop info_ptr = png_create_info_struct(png_ptr);
 666.191 -
 666.192 -	if (!info_ptr)
 666.193 -	{
 666.194 -		png_destroy_write_struct(&png_ptr, NULL);
 666.195 -		fclose(fp);
 666.196 -		return;
 666.197 -	}
 666.198 -
 666.199 -	if (setjmp(png_ptr->jmpbuf))
 666.200 -	{
 666.201 -		png_destroy_write_struct(&png_ptr, NULL);
 666.202 -		fclose(fp);
 666.203 -		return;
 666.204 -	}
 666.205 -
 666.206 -	png_init_io(png_ptr, fp);
 666.207 -
 666.208 -	png_set_IHDR(png_ptr,
 666.209 -	             info_ptr,
 666.210 -	             w,
 666.211 -	             h,
 666.212 -	             8,
 666.213 -	             PNG_COLOR_TYPE_RGB,
 666.214 -	             PNG_INTERLACE_NONE,
 666.215 -	             PNG_COMPRESSION_TYPE_DEFAULT,
 666.216 -	             PNG_FILTER_TYPE_DEFAULT);
 666.217 -
 666.218 -	png_write_info(png_ptr, info_ptr);
 666.219 -
 666.220 -	u8 *b = writeBuffer;
 666.221 -
 666.222 -	int sizeX = w;
 666.223 -	int sizeY = h;
 666.224 -
 666.225 -	u8 *pixU8 = (u8 *)data;
 666.226 -	for (int y = 0; y < sizeY; y++)
 666.227 -	{
 666.228 -		for (int x = 0; x < sizeX; x++)
 666.229 -		{
 666.230 -			int blue  = *pixU8++;
 666.231 -			int green = *pixU8++;
 666.232 -			int red   = *pixU8++;
 666.233 -
 666.234 -			*b++ = red;
 666.235 -			*b++ = green;
 666.236 -			*b++ = blue;
 666.237 -		}
 666.238 -		png_write_row(png_ptr, writeBuffer);
 666.239 -
 666.240 -		b = writeBuffer;
 666.241 -	}
 666.242 -
 666.243 -	png_write_end(png_ptr, info_ptr);
 666.244 -
 666.245 -	png_destroy_write_struct(&png_ptr, &info_ptr);
 666.246 -
 666.247 -	fclose(fp);
 666.248 -}
 666.249 -
 666.250 -void TileView::OnSave()
 666.251 -{
 666.252 -	CString captureBuffer;
 666.253 -
 666.254 -	if (theApp.captureFormat == 0)
 666.255 -		captureBuffer = "tiles.png";
 666.256 -	else
 666.257 -		captureBuffer = "tiles.bmp";
 666.258 -
 666.259 -	LPCTSTR exts[] = {".png", ".bmp", NULL };
 666.260 -
 666.261 -	CString filter = winResLoadFilter(IDS_FILTER_PNG);
 666.262 -	CString title  = winResLoadString(IDS_SELECT_CAPTURE_NAME);
 666.263 -
 666.264 -	FileDlg dlg(this,
 666.265 -	            captureBuffer,
 666.266 -	            filter,
 666.267 -	            theApp.captureFormat ? 2 : 1,
 666.268 -	            theApp.captureFormat ? "BMP" : "PNG",
 666.269 -	            exts,
 666.270 -	            "",
 666.271 -	            title,
 666.272 -	            true);
 666.273 -
 666.274 -	if (dlg.DoModal() == IDCANCEL)
 666.275 -	{
 666.276 -		return;
 666.277 -	}
 666.278 -
 666.279 -	captureBuffer = dlg.GetPathName();
 666.280 -
 666.281 -	if (dlg.getFilterIndex() == 2)
 666.282 -		saveBMP(captureBuffer);
 666.283 -	else
 666.284 -		savePNG(captureBuffer);
 666.285 -}
 666.286 -
 666.287 -void TileView::renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette)
 666.288 -{
 666.289 -	u8 *bmp = &data[24*x + 8*32*24*y];
 666.290 -
 666.291 -	for (int j = 0; j < 8; j++)
 666.292 -	{
 666.293 -		for (int i = 0; i < 8; i++)
 666.294 -		{
 666.295 -			u8 c = charBase[tile*64 + j * 8 + i];
 666.296 -
 666.297 -			u16 color = palette[c];
 666.298 -
 666.299 -			*bmp++ = ((color >> 10) & 0x1f) << 3;
 666.300 -			*bmp++ = ((color >> 5) & 0x1f) << 3;
 666.301 -			*bmp++ = (color & 0x1f) << 3;
 666.302 -		}
 666.303 -		bmp += 31*24; // advance line
 666.304 -	}
 666.305 -}
 666.306 -
 666.307 -void TileView::renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette)
 666.308 -{
 666.309 -	u8 *bmp = &data[24*x + 8*32*24*y];
 666.310 -
 666.311 -	int pal = this->palette;
 666.312 -
 666.313 -	if (this->charBase == 4)
 666.314 -		pal += 16;
 666.315 -
 666.316 -	for (int j = 0; j < 8; j++)
 666.317 -	{
 666.318 -		for (int i = 0; i < 8; i++)
 666.319 -		{
 666.320 -			u8 c = charBase[tile*32 + j * 4 + (i>>1)];
 666.321 -
 666.322 -			if (i & 1)
 666.323 -				c = c>>4;
 666.324 -			else
 666.325 -				c = c & 15;
 666.326 -
 666.327 -			u16 color = palette[pal*16+c];
 666.328 -
 666.329 -			*bmp++ = ((color >> 10) & 0x1f) << 3;
 666.330 -			*bmp++ = ((color >> 5) & 0x1f) << 3;
 666.331 -			*bmp++ = (color & 0x1f) << 3;
 666.332 -		}
 666.333 -		bmp += 31*24; // advance line
 666.334 -	}
 666.335 -}
 666.336 -
 666.337 -void TileView::render()
 666.338 -{
 666.339 -	u16 *palette  = (u16 *)paletteRAM;
 666.340 -	u8 * charBase = &vram[this->charBase * 0x4000];
 666.341 -
 666.342 -	int maxY;
 666.343 -
 666.344 -	if (is256Colors)
 666.345 -	{
 666.346 -		int tile = 0;
 666.347 -		maxY = 16;
 666.348 -		for (int y = 0; y < maxY; y++)
 666.349 -		{
 666.350 -			for (int x = 0; x < 32; x++)
 666.351 -			{
 666.352 -				if (this->charBase == 4)
 666.353 -					renderTile256(tile, x, y, charBase, &palette[256]);
 666.354 -				else
 666.355 -					renderTile256(tile, x, y, charBase, palette);
 666.356 -				tile++;
 666.357 -			}
 666.358 -		}
 666.359 -		tileView.setSize(32*8, maxY*8);
 666.360 -		w = 32*8;
 666.361 -		h = maxY*8;
 666.362 -		SIZE s;
 666.363 -		s.cx = 32*8;
 666.364 -		s.cy = maxY*8;
 666.365 -		if (tileView.getStretch())
 666.366 -		{
 666.367 -			s.cx = s.cy = 1;
 666.368 -		}
 666.369 -		tileView.SetScrollSizes(MM_TEXT, s);
 666.370 -	}
 666.371 -	else
 666.372 -	{
 666.373 -		int tile = 0;
 666.374 -		maxY = 32;
 666.375 -		if (this->charBase == 3)
 666.376 -			maxY = 16;
 666.377 -		for (int y = 0; y < maxY; y++)
 666.378 -		{
 666.379 -			for (int x = 0; x < 32; x++)
 666.380 -			{
 666.381 -				renderTile16(tile, x, y, charBase, palette);
 666.382 -				tile++;
 666.383 -			}
 666.384 -		}
 666.385 -		tileView.setSize(32*8, maxY*8);
 666.386 -		w = 32*8;
 666.387 -		h = maxY*8;
 666.388 -		SIZE s;
 666.389 -		s.cx = 32*8;
 666.390 -		s.cy = maxY*8;
 666.391 -		if (tileView.getStretch())
 666.392 -		{
 666.393 -			s.cx = s.cy = 1;
 666.394 -		}
 666.395 -		tileView.SetScrollSizes(MM_TEXT, s);
 666.396 -	}
 666.397 -}
 666.398 -
 666.399 -void TileView::update()
 666.400 -{
 666.401 -	paint();
 666.402 -}
 666.403 -
 666.404 -BOOL TileView::OnInitDialog()
 666.405 -{
 666.406 -	CDialog::OnInitDialog();
 666.407 -
 666.408 -	DIALOG_SIZER_START(sz)
 666.409 -	DIALOG_SIZER_ENTRY(IDC_TILE_VIEW, DS_SizeX | DS_SizeY)
 666.410 -	DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
 666.411 -	DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
 666.412 -	DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
 666.413 -	DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
 666.414 -	DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
 666.415 -	DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
 666.416 -	DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
 666.417 -	DIALOG_SIZER_END()
 666.418 -	SetData(sz,
 666.419 -	        TRUE,
 666.420 -	        HKEY_CURRENT_USER,
 666.421 -	        "Software\\Emulators\\VisualBoyAdvance\\Viewer\\TileView",
 666.422 -	        NULL);
 666.423 -
 666.424 -	m_colors   = is256Colors;
 666.425 -	m_charBase = charBase;
 666.426 -
 666.427 -	m_slider.SetRange(0, 15);
 666.428 -	m_slider.SetPageSize(4);
 666.429 -	m_slider.SetTicFreq(1);
 666.430 -
 666.431 -	paint();
 666.432 -
 666.433 -	m_stretch = regQueryDwordValue("tileViewStretch", 0);
 666.434 -	if (m_stretch)
 666.435 -		tileView.setStretch(true);
 666.436 -	UpdateData(FALSE);
 666.437 -
 666.438 -	return TRUE; // return TRUE unless you set the focus to a control
 666.439 -	             // EXCEPTION: OCX Property Pages should return FALSE
 666.440 -}
 666.441 -
 666.442 -void TileView::OnClose()
 666.443 -{
 666.444 -	theApp.winRemoveUpdateListener(this);
 666.445 -
 666.446 -	DestroyWindow();
 666.447 -}
 666.448 -
 666.449 -void TileView::OnAutoUpdate()
 666.450 -{
 666.451 -	autoUpdate = !autoUpdate;
 666.452 -	if (autoUpdate)
 666.453 -	{
 666.454 -		theApp.winAddUpdateListener(this);
 666.455 -	}
 666.456 -	else
 666.457 -	{
 666.458 -		theApp.winRemoveUpdateListener(this);
 666.459 -	}
 666.460 -}
 666.461 -
 666.462 -void TileView::paint()
 666.463 -{
 666.464 -	if (vram != NULL && paletteRAM != NULL)
 666.465 -	{
 666.466 -		render();
 666.467 -		tileView.refresh();
 666.468 -	}
 666.469 -}
 666.470 -
 666.471 -void TileView::On16Colors()
 666.472 -{
 666.473 -	is256Colors = 0;
 666.474 -	paint();
 666.475 -}
 666.476 -
 666.477 -void TileView::On256Colors()
 666.478 -{
 666.479 -	is256Colors = 1;
 666.480 -	paint();
 666.481 -}
 666.482 -
 666.483 -void TileView::OnCharbase0()
 666.484 -{
 666.485 -	charBase = 0;
 666.486 -	paint();
 666.487 -}
 666.488 -
 666.489 -void TileView::OnCharbase1()
 666.490 -{
 666.491 -	charBase = 1;
 666.492 -	paint();
 666.493 -}
 666.494 -
 666.495 -void TileView::OnCharbase2()
 666.496 -{
 666.497 -	charBase = 2;
 666.498 -	paint();
 666.499 -}
 666.500 -
 666.501 -void TileView::OnCharbase3()
 666.502 -{
 666.503 -	charBase = 3;
 666.504 -	paint();
 666.505 -}
 666.506 -
 666.507 -void TileView::OnCharbase4()
 666.508 -{
 666.509 -	charBase = 4;
 666.510 -	paint();
 666.511 -}
 666.512 -
 666.513 -void TileView::OnStretch()
 666.514 -{
 666.515 -	tileView.setStretch(!tileView.getStretch());
 666.516 -	paint();
 666.517 -	regSetDwordValue("tileViewStretch", tileView.getStretch());
 666.518 -}
 666.519 -
 666.520 -LRESULT TileView::OnMapInfo(WPARAM wParam, LPARAM lParam)
 666.521 -{
 666.522 -	u8 *colors = (u8 *)lParam;
 666.523 -	zoom.setColors(colors);
 666.524 -
 666.525 -	int x = (wParam & 0xFFFF)/8;
 666.526 -	int y = ((wParam >> 16) & 0xFFFF)/8;
 666.527 -
 666.528 -	u32 address = 0x6000000 + 0x4000 * charBase;
 666.529 -	int tile    = 32 * y + x;
 666.530 -	if (is256Colors)
 666.531 -		tile *= 2;
 666.532 -	address += 32 * tile;
 666.533 -
 666.534 -	CString buffer;
 666.535 -	buffer.Format("%d", tile);
 666.536 -	GetDlgItem(IDC_TILE_NUMBER)->SetWindowText(buffer);
 666.537 -
 666.538 -	buffer.Format("%08x", address);
 666.539 -	GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer);
 666.540 -
 666.541 -	return TRUE;
 666.542 -}
 666.543 -
 666.544 -LRESULT TileView::OnColInfo(WPARAM wParam, LPARAM)
 666.545 -{
 666.546 -	u16 c = (u16)wParam;
 666.547 -
 666.548 -	color.setColor(c);
 666.549 -
 666.550 -	int r = (c & 0x1f);
 666.551 -	int g = (c & 0x3e0) >> 5;
 666.552 -	int b = (c & 0x7c00) >> 10;
 666.553 -
 666.554 -	CString buffer;
 666.555 -	buffer.Format("R: %d", r);
 666.556 -	GetDlgItem(IDC_R)->SetWindowText(buffer);
 666.557 -
 666.558 -	buffer.Format("G: %d", g);
 666.559 -	GetDlgItem(IDC_G)->SetWindowText(buffer);
 666.560 -
 666.561 -	buffer.Format("B: %d", b);
 666.562 -	GetDlgItem(IDC_B)->SetWindowText(buffer);
 666.563 -
 666.564 -	return TRUE;
 666.565 -}
 666.566 -
 666.567 -void TileView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
 666.568 -{
 666.569 -	switch (nSBCode)
 666.570 -	{
 666.571 -	case TB_THUMBPOSITION:
 666.572 -		palette = nPos;
 666.573 -		break;
 666.574 -	default:
 666.575 -		palette = m_slider.GetPos();
 666.576 -		break;
 666.577 -	}
 666.578 -	paint();
 666.579 -}
 666.580 -
 666.581 -void TileView::PostNcDestroy()
 666.582 -{
 666.583 -	delete this;
 666.584 -}
 666.585 -
   667.1 --- a/src/win32/TileView.h	Sat Mar 03 10:54:39 2012 -0600
   667.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   667.3 @@ -1,90 +0,0 @@
   667.4 -#if !defined(AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_)
   667.5 -#define AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_
   667.6 -
   667.7 -#if _MSC_VER > 1000
   667.8 -#pragma once
   667.9 -#endif // _MSC_VER > 1000
  667.10 -// TileView.h : header file
  667.11 -//
  667.12 -
  667.13 -#include "BitmapControl.h"
  667.14 -#include "ColorControl.h"
  667.15 -#include "IUpdate.h"
  667.16 -#include "ResizeDlg.h"
  667.17 -#include "ZoomControl.h"
  667.18 -
  667.19 -/////////////////////////////////////////////////////////////////////////////
  667.20 -// TileView dialog
  667.21 -
  667.22 -class TileView : public ResizeDlg, IUpdateListener
  667.23 -{
  667.24 -  int charBase;
  667.25 -  int is256Colors;
  667.26 -  int palette;
  667.27 -  BitmapControl tileView;
  667.28 -  BITMAPINFO bmpInfo;
  667.29 -  u8 *data;
  667.30 -  ZoomControl zoom;
  667.31 -  ColorControl color;
  667.32 -  int w;
  667.33 -  int h;
  667.34 -  bool autoUpdate;
  667.35 -  // Construction
  667.36 - public:
  667.37 -  void paint();
  667.38 -  void render();
  667.39 -  void renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette);
  667.40 -  void renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette);
  667.41 -  void savePNG(const char *name);
  667.42 -  void saveBMP(const char *name);
  667.43 -  TileView(CWnd* pParent = NULL);   // standard constructor
  667.44 -  virtual ~TileView();
  667.45 -
  667.46 -  virtual void update();
  667.47 -
  667.48 -  // Dialog Data
  667.49 -  //{{AFX_DATA(TileView)
  667.50 -  enum { IDD = IDD_TILE_VIEWER };
  667.51 -  CSliderCtrl  m_slider;
  667.52 -  int    m_colors;
  667.53 -  int    m_charBase;
  667.54 -  BOOL  m_stretch;
  667.55 -  //}}AFX_DATA
  667.56 -
  667.57 -
  667.58 -  // Overrides
  667.59 -  // ClassWizard generated virtual function overrides
  667.60 -  //{{AFX_VIRTUAL(TileView)
  667.61 - protected:
  667.62 -  virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  667.63 -  virtual void PostNcDestroy();
  667.64 -  //}}AFX_VIRTUAL
  667.65 -
  667.66 -  // Implementation
  667.67 - protected:
  667.68 -  virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
  667.69 -  virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
  667.70 -
  667.71 -  // Generated message map functions
  667.72 -  //{{AFX_MSG(TileView)
  667.73 -  afx_msg void OnSave();
  667.74 -  virtual BOOL OnInitDialog();
  667.75 -  afx_msg void OnClose();
  667.76 -  afx_msg void OnAutoUpdate();
  667.77 -  afx_msg void On16Colors();
  667.78 -  afx_msg void On256Colors();
  667.79 -  afx_msg void OnCharbase0();
  667.80 -  afx_msg void OnCharbase1();
  667.81 -  afx_msg void OnCharbase2();
  667.82 -  afx_msg void OnCharbase3();
  667.83 -  afx_msg void OnCharbase4();
  667.84 -  afx_msg void OnStretch();
  667.85 -  afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  667.86 -  //}}AFX_MSG
  667.87 -  DECLARE_MESSAGE_MAP()
  667.88 -    };
  667.89 -
  667.90 -    //{{AFX_INSERT_LOCATION}}
  667.91 -    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  667.92 -
  667.93 -#endif // !defined(AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_)
   668.1 --- a/src/win32/VBA.clw	Sat Mar 03 10:54:39 2012 -0600
   668.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   668.3 @@ -1,1715 +0,0 @@
   668.4 -; CLW file contains information for the MFC ClassWizard
   668.5 -
   668.6 -[General Info]
   668.7 -Version=1
   668.8 -LastClass=Hyperlink
   668.9 -LastTemplate=CDialog
  668.10 -NewFileInclude1=#include "stdafx.h"
  668.11 -NewFileInclude2=#include "vba.h"
  668.12 -LastPage=0
  668.13 -
  668.14 -ClassCount=57
  668.15 -Class1=AboutDialog
  668.16 -Class2=Associate
  668.17 -Class3=ColorButton
  668.18 -Class4=ColorControl
  668.19 -Class5=Directories
  668.20 -Class6=ExportGSASnapshot
  668.21 -Class7=FileDlg
  668.22 -Class8=GBACheatSearch
  668.23 -Class9=AddCheat
  668.24 -Class10=GBACheatList
  668.25 -Class11=GBCheatSearch
  668.26 -Class12=AddGBCheat
  668.27 -Class13=GBColorDlg
  668.28 -Class14=GSACodeSelect
  668.29 -Class15=JoypadEditControl
  668.30 -Class16=JoypadConfig
  668.31 -Class17=MotionConfig
  668.32 -Class18=Hyperlink
  668.33 -Class19=LangSelect
  668.34 -Class20=MainWnd
  668.35 -Class21=ModeConfirm
  668.36 -Class22=RewindInterval
  668.37 -Class23=RomInfoGB
  668.38 -Class24=RomInfoGBA
  668.39 -Class25=SkinButton
  668.40 -Class26=Throttle
  668.41 -Class27=VBA
  668.42 -Class28=VideoMode
  668.43 -Class29=VideoDriverSelect
  668.44 -
  668.45 -ResourceCount=44
  668.46 -Resource1=IDD_MAX_SCALE
  668.47 -Resource2=IDD_GDB_WAITING
  668.48 -Resource3=IDD_GB_CHEAT_LIST
  668.49 -Resource4=IDD_CONFIG
  668.50 -Resource5=IDD_ADD_CHEAT_DLG
  668.51 -Resource6=IDD_GB_OAM_VIEW
  668.52 -Resource7=IDD_GB_ROM_INFO
  668.53 -Resource8=IDD_OPENDLG
  668.54 -Resource9=IDD_MAP_VIEW
  668.55 -Resource10=IDD_ABOUT
  668.56 -Resource11=IDD_CHEAT_LIST
  668.57 -Resource12=IDD_OAM_VIEW
  668.58 -Resource13=IDD_CODE_SELECT
  668.59 -Resource14=IDD_CHEATS
  668.60 -Resource15=IDD_GBA_ROM_INFO
  668.61 -Resource16=IDD_IO_VIEWER
  668.62 -Resource17=IDD_MEM_VIEWER
  668.63 -Resource18=IDD_ADDR_SIZE
  668.64 -Resource19=IDR_MENU
  668.65 -Resource20=IDD_PALETTE_VIEW
  668.66 -Resource21=IDD_ASSOCIATIONS
  668.67 -Resource22=IDD_GB_COLORS
  668.68 -Resource23=IDD_ADD_CHEAT
  668.69 -Resource24=IDD_DISASSEMBLE
  668.70 -Resource25=IDD_MODES
  668.71 -Resource26=IDD_GDB_PORT
  668.72 -Resource27=IDD_LANG_SELECT
  668.73 -Resource28=IDD_LOGGING
  668.74 -Resource29=IDD_DRIVERS
  668.75 -Resource30=IDD_EXPORT_SPS
  668.76 -Resource31=IDD_THROTTLE
  668.77 -Resource32=IDD_MODE_CONFIRM
  668.78 -Resource33=IDD_GB_DISASSEMBLE
  668.79 -Resource34=IDD_GB_PALETTE_VIEW
  668.80 -Resource35=IDD_REWIND_INTERVAL
  668.81 -Resource36=IDD_GB_TILE_VIEWER
  668.82 -Resource37=IDD_ACCEL_EDITOR
  668.83 -Resource38=IDD_GB_MAP_VIEW
  668.84 -Resource39=IDD_BUG_REPORT
  668.85 -Resource40=IDD_MOTION_CONFIG
  668.86 -Resource41=IDD_TILE_VIEWER
  668.87 -Class30=AddGSACode
  668.88 -Class31=GBCheatList
  668.89 -Class32=Disassemble
  668.90 -Class33=GBDisassemble
  668.91 -Class34=Logging
  668.92 -Class35=IOViewer
  668.93 -Class36=ZoomControl
  668.94 -Class37=BitmapControl
  668.95 -Class38=MapView
  668.96 -Class39=GBMapView
  668.97 -Class40=MemoryViewer
  668.98 -Class41=MemoryViewerDlg
  668.99 -Class42=MemoryViewerAddressSize
 668.100 -Class43=GBMemoryViewerDlg
 668.101 -Class44=OamView
 668.102 -Class45=GBOamView
 668.103 -Class46=PaletteViewControl
 668.104 -Class47=PaletteView
 668.105 -Class48=GBPaletteView
 668.106 -Class49=TileView
 668.107 -Class50=GBTileView
 668.108 -Class51=GBPrinterDlg
 668.109 -Class52=GDBPortDlg
 668.110 -Class53=GDBWaitingDlg
 668.111 -Class54=AccelEditor
 668.112 -Class55=CKeyboardEdit
 668.113 -Resource42=IDD_DIRECTORIES
 668.114 -Class56=MaxScale
 668.115 -Resource43=IDD_GB_PRINTER
 668.116 -Class57=BugReport
 668.117 -Resource44=IDR_ACCELERATOR
 668.118 -
 668.119 -[CLS:AboutDialog]
 668.120 -Type=0
 668.121 -BaseClass=CDialog
 668.122 -HeaderFile=AboutDialog.h
 668.123 -ImplementationFile=AboutDialog.cpp
 668.124 -LastObject=AboutDialog
 668.125 -
 668.126 -[CLS:Associate]
 668.127 -Type=0
 668.128 -BaseClass=CDialog
 668.129 -HeaderFile=Associate.h
 668.130 -ImplementationFile=Associate.cpp
 668.131 -LastObject=ID_OK
 668.132 -
 668.133 -[CLS:ColorButton]
 668.134 -Type=0
 668.135 -BaseClass=CButton
 668.136 -HeaderFile=ColorButton.h
 668.137 -ImplementationFile=ColorButton.cpp
 668.138 -
 668.139 -[CLS:ColorControl]
 668.140 -Type=0
 668.141 -BaseClass=CWnd
 668.142 -HeaderFile=ColorControl.h
 668.143 -ImplementationFile=ColorControl.cpp
 668.144 -
 668.145 -[CLS:Directories]
 668.146 -Type=0
 668.147 -BaseClass=CDialog
 668.148 -HeaderFile=Directories.h
 668.149 -ImplementationFile=Directories.cpp
 668.150 -
 668.151 -[CLS:ExportGSASnapshot]
 668.152 -Type=0
 668.153 -BaseClass=CDialog
 668.154 -HeaderFile=ExportGSASnapshot.h
 668.155 -ImplementationFile=ExportGSASnapshot.cpp
 668.156 -
 668.157 -[CLS:FileDlg]
 668.158 -Type=0
 668.159 -BaseClass=CFileDialog
 668.160 -HeaderFile=FileDlg.h
 668.161 -ImplementationFile=FileDlg.cpp
 668.162 -
 668.163 -[CLS:GBACheatSearch]
 668.164 -Type=0
 668.165 -BaseClass=CDialog
 668.166 -HeaderFile=GBACheats.h
 668.167 -ImplementationFile=GBACheats.cpp
 668.168 -
 668.169 -[CLS:AddCheat]
 668.170 -Type=0
 668.171 -BaseClass=CDialog
 668.172 -HeaderFile=GBACheats.h
 668.173 -ImplementationFile=GBACheats.cpp
 668.174 -
 668.175 -[CLS:GBACheatList]
 668.176 -Type=0
 668.177 -BaseClass=CDialog
 668.178 -HeaderFile=GBACheats.h
 668.179 -ImplementationFile=GBACheats.cpp
 668.180 -LastObject=GBACheatList
 668.181 -
 668.182 -[CLS:GBCheatSearch]
 668.183 -Type=0
 668.184 -BaseClass=CDialog
 668.185 -HeaderFile=GBCheatsDlg.h
 668.186 -ImplementationFile=GBCheatsDlg.cpp
 668.187 -
 668.188 -[CLS:AddGBCheat]
 668.189 -Type=0
 668.190 -BaseClass=CDialog
 668.191 -HeaderFile=GBCheatsDlg.h
 668.192 -ImplementationFile=GBCheatsDlg.cpp
 668.193 -LastObject=AddGBCheat
 668.194 -
 668.195 -[CLS:GBColorDlg]
 668.196 -Type=0
 668.197 -BaseClass=CDialog
 668.198 -HeaderFile=GBColorDlg.h
 668.199 -ImplementationFile=GBColorDlg.cpp
 668.200 -LastObject=IDC_PREDEFINED
 668.201 -Filter=D
 668.202 -VirtualFilter=dWC
 668.203 -
 668.204 -[CLS:GSACodeSelect]
 668.205 -Type=0
 668.206 -BaseClass=CDialog
 668.207 -HeaderFile=GSACodeSelect.h
 668.208 -ImplementationFile=GSACodeSelect.cpp
 668.209 -
 668.210 -[CLS:JoypadEditControl]
 668.211 -Type=0
 668.212 -BaseClass=CEdit
 668.213 -HeaderFile=Joypad.h
 668.214 -ImplementationFile=Joypad.cpp
 668.215 -
 668.216 -[CLS:JoypadConfig]
 668.217 -Type=0
 668.218 -BaseClass=CDialog
 668.219 -HeaderFile=Joypad.h
 668.220 -ImplementationFile=Joypad.cpp
 668.221 -
 668.222 -[CLS:CKeyboardEdit]
 668.223 -Type=0
 668.224 -BaseClass=CEdit
 668.225 -HeaderFile=KeyboardEdit.h
 668.226 -ImplementationFile=KeyboardEdit.cpp
 668.227 -
 668.228 -[CLS:MotionConfig]
 668.229 -Type=0
 668.230 -BaseClass=CDialog
 668.231 -HeaderFile=Joypad.h
 668.232 -ImplementationFile=Joypad.cpp
 668.233 -
 668.234 -[CLS:LangSelect]
 668.235 -Type=0
 668.236 -BaseClass=CDialog
 668.237 -HeaderFile=LangSelect.h
 668.238 -ImplementationFile=LangSelect.cpp
 668.239 -
 668.240 -[CLS:MainWnd]
 668.241 -Type=0
 668.242 -BaseClass=CWnd
 668.243 -HeaderFile=MainWnd.h
 668.244 -ImplementationFile=MainWnd.cpp
 668.245 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
 668.246 -Filter=W
 668.247 -VirtualFilter=WC
 668.248 -
 668.249 -[CLS:ModeConfirm]
 668.250 -Type=0
 668.251 -BaseClass=CDialog
 668.252 -HeaderFile=ModeConfirm.h
 668.253 -ImplementationFile=ModeConfirm.cpp
 668.254 -
 668.255 -[CLS:RewindInterval]
 668.256 -Type=0
 668.257 -BaseClass=CDialog
 668.258 -HeaderFile=RewindInterval.h
 668.259 -ImplementationFile=RewindInterval.cpp
 668.260 -
 668.261 -[CLS:RomInfoGB]
 668.262 -Type=0
 668.263 -BaseClass=CDialog
 668.264 -HeaderFile=RomInfo.h
 668.265 -ImplementationFile=RomInfo.cpp
 668.266 -
 668.267 -[CLS:RomInfoGBA]
 668.268 -Type=0
 668.269 -BaseClass=CDialog
 668.270 -HeaderFile=RomInfo.h
 668.271 -ImplementationFile=RomInfo.cpp
 668.272 -
 668.273 -[CLS:SkinButton]
 668.274 -Type=0
 668.275 -BaseClass=CWnd
 668.276 -HeaderFile=skinButton.h
 668.277 -ImplementationFile=skinButton.cpp
 668.278 -
 668.279 -[CLS:Throttle]
 668.280 -Type=0
 668.281 -BaseClass=CDialog
 668.282 -HeaderFile=Throttle.h
 668.283 -ImplementationFile=Throttle.cpp
 668.284 -
 668.285 -[CLS:VBA]
 668.286 -Type=0
 668.287 -BaseClass=CWinApp
 668.288 -HeaderFile=VBA.h
 668.289 -ImplementationFile=VBA.cpp
 668.290 -
 668.291 -[CLS:VideoMode]
 668.292 -Type=0
 668.293 -BaseClass=CDialog
 668.294 -HeaderFile=VideoMode.h
 668.295 -ImplementationFile=VideoMode.cpp
 668.296 -
 668.297 -[CLS:VideoDriverSelect]
 668.298 -Type=0
 668.299 -BaseClass=CDialog
 668.300 -HeaderFile=VideoMode.h
 668.301 -ImplementationFile=VideoMode.cpp
 668.302 -Filter=D
 668.303 -VirtualFilter=dWC
 668.304 -LastObject=ID_CANCEL
 668.305 -
 668.306 -[DLG:IDD_ABOUT]
 668.307 -Type=1
 668.308 -Class=AboutDialog
 668.309 -ControlCount=8
 668.310 -Control1=IDOK,button,1342242817
 668.311 -Control2=IDC_STATIC,static,1342177283
 668.312 -Control3=IDC_STATIC,static,1342308353
 668.313 -Control4=IDC_STATIC,static,1342308353
 668.314 -Control5=IDC_URL,static,1342308353
 668.315 -Control6=IDC_STATIC,static,1342308353
 668.316 -Control7=IDC_STATIC,static,1342308353
 668.317 -Control8=IDC_VERSION,static,1342308353
 668.318 -
 668.319 -[DLG:IDD_ASSOCIATIONS]
 668.320 -Type=1
 668.321 -Class=Associate
 668.322 -ControlCount=11
 668.323 -Control1=IDC_GB,button,1342242819
 668.324 -Control2=IDC_SGB,button,1342242819
 668.325 -Control3=IDC_CGB,button,1342242819
 668.326 -Control4=IDC_GBC,button,1342242819
 668.327 -Control5=IDC_GBA,button,1342242819
 668.328 -Control6=IDC_AGB,button,1342242819
 668.329 -Control7=IDC_BIN,button,1342242819
 668.330 -Control8=ID_OK,button,1342242817
 668.331 -Control9=ID_CANCEL,button,1342242816
 668.332 -Control10=IDC_STATIC,button,1342177287
 668.333 -Control11=IDC_STATIC,button,1342177287
 668.334 -
 668.335 -[DLG:IDD_DIRECTORIES]
 668.336 -Type=1
 668.337 -Class=Directories
 668.338 -ControlCount=22
 668.339 -Control1=IDC_ROM_DIR,button,1342242816
 668.340 -Control2=IDC_GBROM_DIR,button,1342242816
 668.341 -Control3=IDC_BATTERY_DIR,button,1342242816
 668.342 -Control4=IDC_SAVE_DIR,button,1342242816
 668.343 -Control5=IDC_CAPTURE_DIR,button,1342242816
 668.344 -Control6=IDOK,button,1342242817
 668.345 -Control7=IDCANCEL,button,1342242816
 668.346 -Control8=IDC_STATIC,static,1342308352
 668.347 -Control9=IDC_STATIC,static,1342308352
 668.348 -Control10=IDC_STATIC,static,1342308352
 668.349 -Control11=IDC_STATIC,static,1342308352
 668.350 -Control12=IDC_ROM_PATH,edit,1484849280
 668.351 -Control13=IDC_BATTERY_PATH,edit,1484849280
 668.352 -Control14=IDC_SAVE_PATH,edit,1484849280
 668.353 -Control15=IDC_CAPTURE_PATH,edit,1484849280
 668.354 -Control16=IDC_STATIC,static,1342308352
 668.355 -Control17=IDC_GBROM_PATH,edit,1484849280
 668.356 -Control18=IDC_ROM_DIR_RESET,button,1342242816
 668.357 -Control19=IDC_GBROM_DIR_RESET,button,1342242816
 668.358 -Control20=IDC_BATTERY_DIR_RESET,button,1342242816
 668.359 -Control21=IDC_SAVE_DIR_RESET,button,1342242816
 668.360 -Control22=IDC_CAPTURE_DIR_RESET,button,1342242816
 668.361 -
 668.362 -[DLG:IDD_EXPORT_SPS]
 668.363 -Type=1
 668.364 -Class=ExportGSASnapshot
 668.365 -ControlCount=8
 668.366 -Control1=IDC_TITLE,edit,1350631552
 668.367 -Control2=IDC_DESC,edit,1350631552
 668.368 -Control3=IDC_NOTES,edit,1350635652
 668.369 -Control4=ID_OK,button,1342242817
 668.370 -Control5=ID_CANCEL,button,1342242816
 668.371 -Control6=IDC_STATIC,static,1342308352
 668.372 -Control7=IDC_STATIC,static,1342308352
 668.373 -Control8=IDC_STATIC,static,1342308352
 668.374 -
 668.375 -[DLG:IDD_CHEATS]
 668.376 -Type=1
 668.377 -Class=GBACheatSearch
 668.378 -ControlCount=26
 668.379 -Control1=IDC_CHEAT_LIST,SysListView32,1350631429
 668.380 -Control2=IDC_OLD_VALUE,button,1342308361
 668.381 -Control3=IDC_SPECIFIC_VALUE,button,1342177289
 668.382 -Control4=IDC_SIZE_8,button,1342308361
 668.383 -Control5=IDC_SIZE_16,button,1342177289
 668.384 -Control6=IDC_SIZE_32,button,1342177289
 668.385 -Control7=IDC_EQ,button,1342308361
 668.386 -Control8=IDC_NE,button,1342177289
 668.387 -Control9=IDC_LT,button,1342177289
 668.388 -Control10=IDC_LE,button,1342177289
 668.389 -Control11=IDC_GT,button,1342177289
 668.390 -Control12=IDC_GE,button,1342177289
 668.391 -Control13=IDC_SIGNED,button,1342308361
 668.392 -Control14=IDC_UNSIGNED,button,1342177289
 668.393 -Control15=IDC_HEXADECIMAL,button,1342177289
 668.394 -Control16=IDC_UPDATE,button,1342373891
 668.395 -Control17=IDC_VALUE,edit,1350631552
 668.396 -Control18=IDC_START,button,1342373888
 668.397 -Control19=IDC_SEARCH,button,1342242816
 668.398 -Control20=IDC_ADD_CHEAT,button,1342242816
 668.399 -Control21=ID_OK,button,1342242817
 668.400 -Control22=IDC_STATIC,button,1342177287
 668.401 -Control23=IDC_STATIC,button,1342177287
 668.402 -Control24=IDC_STATIC,button,1342177287
 668.403 -Control25=IDC_STATIC,button,1342177287
 668.404 -Control26=IDC_STATIC,static,1342308352
 668.405 -
 668.406 -[DLG:IDD_ADD_CHEAT]
 668.407 -Type=1
 668.408 -Class=AddCheat
 668.409 -ControlCount=16
 668.410 -Control1=IDC_ADDRESS,edit,1350631552
 668.411 -Control2=IDC_VALUE,edit,1350631552
 668.412 -Control3=IDC_DESC,edit,1350631552
 668.413 -Control4=IDC_SIZE_8,button,1342373897
 668.414 -Control5=IDC_SIZE_16,button,1342177289
 668.415 -Control6=IDC_SIZE_32,button,1342177289
 668.416 -Control7=IDC_SIGNED,button,1342373897
 668.417 -Control8=IDC_UNSIGNED,button,1342177289
 668.418 -Control9=IDC_HEXADECIMAL,button,1342177289
 668.419 -Control10=ID_OK,button,1342373889
 668.420 -Control11=ID_CANCEL,button,1342242816
 668.421 -Control12=IDC_STATIC,static,1342308352
 668.422 -Control13=IDC_STATIC,button,1342177287
 668.423 -Control14=IDC_STATIC,static,1342308352
 668.424 -Control15=IDC_STATIC,button,1342177287
 668.425 -Control16=IDC_STATIC,static,1342308352
 668.426 -
 668.427 -[DLG:IDD_CHEAT_LIST]
 668.428 -Type=1
 668.429 -Class=GBACheatList
 668.430 -ControlCount=14
 668.431 -Control1=IDC_RESTORE,button,1342373891
 668.432 -Control2=IDC_ADD_CODE,button,1342373888
 668.433 -Control3=IDC_ADD_CHEAT,button,1342242816
 668.434 -Control4=IDC_ADD_GAMESHARK,button,1342242816
 668.435 -Control5=IDC_ADD_CODEBREAKER,button,1342242816
 668.436 -Control6=IDC_REMOVE,button,1342242816
 668.437 -Control7=IDC_REMOVE_ALL,button,1342242816
 668.438 -Control8=IDC_ENABLE,button,1342242816
 668.439 -Control9=ID_OK,button,1342373889
 668.440 -Control10=IDC_CHEAT_LIST,SysListView32,1350762497
 668.441 -Control11=IDC_STATIC,static,1342308352
 668.442 -Control12=IDC_STATIC,static,1342308352
 668.443 -Control13=IDC_STATIC,static,1342308352
 668.444 -Control14=IDC_STATIC,button,1342177287
 668.445 -
 668.446 -[DLG:IDD_GB_COLORS]
 668.447 -Type=1
 668.448 -Class=GBColorDlg
 668.449 -ControlCount=17
 668.450 -Control1=IDC_DEFAULT,button,1342308361
 668.451 -Control2=IDC_USER1,button,1342177289
 668.452 -Control3=IDC_USER2,button,1342177289
 668.453 -Control4=IDC_PREDEFINED,combobox,1344340227
 668.454 -Control5=IDC_COLOR_BG0,button,1342373888
 668.455 -Control6=IDC_COLOR_BG1,button,1342242816
 668.456 -Control7=IDC_COLOR_BG2,button,1342242816
 668.457 -Control8=IDC_COLOR_BG3,button,1342242816
 668.458 -Control9=IDC_COLOR_OB0,button,1342242816
 668.459 -Control10=IDC_COLOR_OB1,button,1342242816
 668.460 -Control11=IDC_COLOR_OB2,button,1342242816
 668.461 -Control12=IDC_COLOR_OB3,button,1342242816
 668.462 -Control13=IDC_RESET,button,1342242816
 668.463 -Control14=ID_OK,button,1342242817
 668.464 -Control15=ID_CANCEL,button,1342242816
 668.465 -Control16=IDC_STATIC,button,1342177287
 668.466 -Control17=IDC_STATIC,button,1342177287
 668.467 -
 668.468 -[DLG:IDD_CODE_SELECT]
 668.469 -Type=1
 668.470 -Class=GSACodeSelect
 668.471 -ControlCount=3
 668.472 -Control1=ID_OK,button,1342242817
 668.473 -Control2=ID_CANCEL,button,1342242816
 668.474 -Control3=IDC_GAME_LIST,listbox,1353777411
 668.475 -
 668.476 -[DLG:IDD_CONFIG]
 668.477 -Type=1
 668.478 -Class=JoypadConfig
 668.479 -ControlCount=28
 668.480 -Control1=IDC_EDIT_UP,edit,1350631552
 668.481 -Control2=IDC_EDIT_DOWN,edit,1350631552
 668.482 -Control3=IDC_EDIT_LEFT,edit,1350631552
 668.483 -Control4=IDC_EDIT_RIGHT,edit,1350631552
 668.484 -Control5=IDC_EDIT_BUTTON_A,edit,1350631552
 668.485 -Control6=IDC_EDIT_BUTTON_B,edit,1350631552
 668.486 -Control7=IDC_EDIT_BUTTON_L,edit,1350631552
 668.487 -Control8=IDC_EDIT_BUTTON_R,edit,1350631552
 668.488 -Control9=IDC_EDIT_BUTTON_SELECT,edit,1350631552
 668.489 -Control10=IDC_EDIT_BUTTON_START,edit,1350631552
 668.490 -Control11=IDC_EDIT_SPEED,edit,1350631552
 668.491 -Control12=IDC_EDIT_CAPTURE,edit,1350631552
 668.492 -Control13=IDC_EDIT_BUTTON_GS,edit,1350631552
 668.493 -Control14=ID_OK,button,1342242816
 668.494 -Control15=ID_CANCEL,button,1342242816
 668.495 -Control16=IDC_STATIC,static,1342308352
 668.496 -Control17=IDC_STATIC,static,1342308352
 668.497 -Control18=IDC_STATIC,static,1342308352
 668.498 -Control19=IDC_STATIC,static,1342308352
 668.499 -Control20=IDC_STATIC,static,1342308352
 668.500 -Control21=IDC_STATIC,static,1342308352
 668.501 -Control22=IDC_STATIC,static,1342308352
 668.502 -Control23=IDC_STATIC,static,1342308352
 668.503 -Control24=IDC_STATIC,static,1342308352
 668.504 -Control25=IDC_STATIC,static,1342308352
 668.505 -Control26=IDC_STATIC,static,1342308352
 668.506 -Control27=IDC_STATIC,static,1342308352
 668.507 -Control28=IDC_STATIC,static,1342308352
 668.508 -
 668.509 -[DLG:IDD_MOTION_CONFIG]
 668.510 -Type=1
 668.511 -Class=MotionConfig
 668.512 -ControlCount=10
 668.513 -Control1=IDC_EDIT_UP,edit,1350631552
 668.514 -Control2=IDC_EDIT_DOWN,edit,1350631552
 668.515 -Control3=IDC_EDIT_LEFT,edit,1350631552
 668.516 -Control4=IDC_EDIT_RIGHT,edit,1350631552
 668.517 -Control5=ID_OK,button,1342242816
 668.518 -Control6=ID_CANCEL,button,1342242816
 668.519 -Control7=IDC_STATIC,static,1342308352
 668.520 -Control8=IDC_STATIC,static,1342308352
 668.521 -Control9=IDC_STATIC,static,1342308352
 668.522 -Control10=IDC_STATIC,static,1342308352
 668.523 -
 668.524 -[DLG:IDD_LANG_SELECT]
 668.525 -Type=1
 668.526 -Class=LangSelect
 668.527 -ControlCount=6
 668.528 -Control1=IDC_LANG_STRING,edit,1350631552
 668.529 -Control2=ID_OK,button,1342242817
 668.530 -Control3=ID_CANCEL,button,1342242816
 668.531 -Control4=IDC_STATIC,static,1342308352
 668.532 -Control5=IDC_STATIC,static,1342308352
 668.533 -Control6=IDC_LANG_NAME,static,1342308352
 668.534 -
 668.535 -[DLG:IDD_MODE_CONFIRM]
 668.536 -Type=1
 668.537 -Class=ModeConfirm
 668.538 -ControlCount=4
 668.539 -Control1=ID_OK,button,1342242817
 668.540 -Control2=ID_CANCEL,button,1342242816
 668.541 -Control3=IDC_STATIC,static,1342308353
 668.542 -Control4=IDC_TIMER,static,1342308353
 668.543 -
 668.544 -[DLG:IDD_REWIND_INTERVAL]
 668.545 -Type=1
 668.546 -Class=RewindInterval
 668.547 -ControlCount=5
 668.548 -Control1=IDC_INTERVAL,edit,1350631552
 668.549 -Control2=ID_OK,button,1342242817
 668.550 -Control3=ID_CANCEL,button,1342242816
 668.551 -Control4=IDC_STATIC,static,1342308352
 668.552 -Control5=IDC_STATIC,static,1342308352
 668.553 -
 668.554 -[DLG:IDD_GB_ROM_INFO]
 668.555 -Type=1
 668.556 -Class=RomInfoGB
 668.557 -ControlCount=27
 668.558 -Control1=ID_OK,button,1342242817
 668.559 -Control2=IDC_STATIC,static,1342308352
 668.560 -Control3=IDC_STATIC,static,1342308352
 668.561 -Control4=IDC_STATIC,static,1342308352
 668.562 -Control5=IDC_STATIC,static,1342308352
 668.563 -Control6=IDC_STATIC,static,1342308352
 668.564 -Control7=IDC_STATIC,static,1342308352
 668.565 -Control8=IDC_ROM_TITLE,static,1342308352
 668.566 -Control9=IDC_ROM_MAKER_CODE,static,1342308352
 668.567 -Control10=IDC_ROM_UNIT_CODE,static,1342308352
 668.568 -Control11=IDC_ROM_DEVICE_TYPE,static,1342308352
 668.569 -Control12=IDC_ROM_VERSION,static,1342308352
 668.570 -Control13=IDC_ROM_CRC,static,1342308352
 668.571 -Control14=IDC_STATIC,static,1342308352
 668.572 -Control15=IDC_ROM_COLOR,static,1342308352
 668.573 -Control16=IDC_STATIC,static,1342308352
 668.574 -Control17=IDC_ROM_SIZE,static,1342308352
 668.575 -Control18=IDC_STATIC,static,1342308352
 668.576 -Control19=IDC_ROM_RAM_SIZE,static,1342308352
 668.577 -Control20=IDC_STATIC,static,1342308352
 668.578 -Control21=IDC_ROM_DEST_CODE,static,1342308352
 668.579 -Control22=IDC_STATIC,static,1342308352
 668.580 -Control23=IDC_ROM_LIC_CODE,static,1342308352
 668.581 -Control24=IDC_STATIC,static,1342308352
 668.582 -Control25=IDC_ROM_CHECKSUM,static,1342308352
 668.583 -Control26=IDC_ROM_MAKER_NAME2,static,1342308352
 668.584 -Control27=IDC_STATIC,static,1342308352
 668.585 -
 668.586 -[DLG:IDD_GBA_ROM_INFO]
 668.587 -Type=1
 668.588 -Class=RomInfoGBA
 668.589 -ControlCount=17
 668.590 -Control1=ID_OK,button,1342242817
 668.591 -Control2=IDC_STATIC,static,1342308352
 668.592 -Control3=IDC_STATIC,static,1342308352
 668.593 -Control4=IDC_STATIC,static,1342308352
 668.594 -Control5=IDC_STATIC,static,1342308352
 668.595 -Control6=IDC_STATIC,static,1342308352
 668.596 -Control7=IDC_STATIC,static,1342308352
 668.597 -Control8=IDC_STATIC,static,1342308352
 668.598 -Control9=IDC_ROM_TITLE,static,1342308352
 668.599 -Control10=IDC_ROM_GAME_CODE,static,1342308352
 668.600 -Control11=IDC_ROM_MAKER_CODE,static,1342308352
 668.601 -Control12=IDC_ROM_UNIT_CODE,static,1342308352
 668.602 -Control13=IDC_ROM_DEVICE_TYPE,static,1342308352
 668.603 -Control14=IDC_ROM_VERSION,static,1342308352
 668.604 -Control15=IDC_ROM_CRC,static,1342308352
 668.605 -Control16=IDC_ROM_MAKER_NAME,static,1342308352
 668.606 -Control17=IDC_STATIC,static,1342308352
 668.607 -
 668.608 -[DLG:IDD_THROTTLE]
 668.609 -Type=1
 668.610 -Class=Throttle
 668.611 -ControlCount=4
 668.612 -Control1=IDC_THROTTLE,edit,1350631552
 668.613 -Control2=ID_OK,button,1342242817
 668.614 -Control3=ID_CANCEL,button,1342242816
 668.615 -Control4=IDC_STATIC,static,1342308352
 668.616 -
 668.617 -[DLG:IDD_MODES]
 668.618 -Type=1
 668.619 -Class=VideoMode
 668.620 -ControlCount=4
 668.621 -Control1=IDC_MODES,listbox,1352728835
 668.622 -Control2=ID_OK,button,1342242817
 668.623 -Control3=ID_CANCEL,button,1342242816
 668.624 -Control4=IDC_STATIC,static,1342308352
 668.625 -
 668.626 -[DLG:IDD_DRIVERS]
 668.627 -Type=1
 668.628 -Class=VideoDriverSelect
 668.629 -ControlCount=4
 668.630 -Control1=IDC_DRIVERS,listbox,1352728833
 668.631 -Control2=ID_OK,button,1342242817
 668.632 -Control3=ID_CANCEL,button,1342242816
 668.633 -Control4=IDC_STATIC,static,1342308352
 668.634 -
 668.635 -[DLG:IDD_OPENDLG]
 668.636 -Type=1
 668.637 -Class=GBMemoryViewerDlg
 668.638 -ControlCount=12
 668.639 -Control1=1090,static,1342308352
 668.640 -Control2=1152,edit,1350632576
 668.641 -Control3=1120,listbox,1352732755
 668.642 -Control4=65535,static,1342308352
 668.643 -Control5=1088,static,1342308480
 668.644 -Control6=1121,listbox,1352732755
 668.645 -Control7=1089,static,1342308352
 668.646 -Control8=1136,combobox,1344340035
 668.647 -Control9=1091,static,1342308352
 668.648 -Control10=1137,combobox,1344340819
 668.649 -Control11=IDOK,button,1342373889
 668.650 -Control12=IDCANCEL,button,1342373888
 668.651 -
 668.652 -[DLG:IDD_GB_CHEAT_LIST]
 668.653 -Type=1
 668.654 -Class=GBCheatList
 668.655 -ControlCount=10
 668.656 -Control1=IDC_CHEAT_LIST,SysListView32,1350762497
 668.657 -Control2=IDC_ADD_GG_CHEAT,button,1342373888
 668.658 -Control3=IDC_ADD_GS_CHEAT,button,1342373888
 668.659 -Control4=IDC_REMOVE,button,1342242816
 668.660 -Control5=IDC_REMOVE_ALL,button,1342242816
 668.661 -Control6=IDC_ENABLE,button,1342242816
 668.662 -Control7=ID_OK,button,1342242817
 668.663 -Control8=IDC_STATIC,static,1342308352
 668.664 -Control9=IDC_STATIC,static,1342308352
 668.665 -Control10=IDC_STATIC,static,1342308352
 668.666 -
 668.667 -[DLG:IDD_ADD_CHEAT_DLG]
 668.668 -Type=1
 668.669 -Class=AddGSACode
 668.670 -ControlCount=6
 668.671 -Control1=IDC_DESC,edit,1350631552
 668.672 -Control2=IDC_CODE,edit,1350635724
 668.673 -Control3=ID_OK,button,1342242817
 668.674 -Control4=ID_CANCEL,button,1342242816
 668.675 -Control5=IDC_STATIC,static,1342308352
 668.676 -Control6=IDC_STATIC,static,1342308352
 668.677 -
 668.678 -[DLG:IDD_GB_PRINTER]
 668.679 -Type=1
 668.680 -Class=GBPrinterDlg
 668.681 -ControlCount=9
 668.682 -Control1=IDC_1X,button,1342308361
 668.683 -Control2=IDC_2X,button,1342177289
 668.684 -Control3=IDC_3X,button,1342177289
 668.685 -Control4=IDC_4X,button,1342177289
 668.686 -Control5=ID_PRINT,button,1342373889
 668.687 -Control6=ID_SAVE,button,1342242816
 668.688 -Control7=ID_OK,button,1342242816
 668.689 -Control8=IDC_GB_PRINTER,static,1342308359
 668.690 -Control9=IDC_STATIC,button,1342177287
 668.691 -
 668.692 -[DLG:IDD_MAP_VIEW]
 668.693 -Type=1
 668.694 -Class=MapView
 668.695 -ControlCount=44
 668.696 -Control1=IDC_FRAME_0,button,1342308361
 668.697 -Control2=IDC_FRAME_1,button,1342177289
 668.698 -Control3=IDC_BG0,button,1342308361
 668.699 -Control4=IDC_BG1,button,1342177289
 668.700 -Control5=IDC_BG2,button,1342177289
 668.701 -Control6=IDC_BG3,button,1342177289
 668.702 -Control7=IDC_STRETCH,button,1342242819
 668.703 -Control8=IDC_REFRESH,button,1342373888
 668.704 -Control9=IDC_SAVE,button,1342373888
 668.705 -Control10=IDC_CLOSE,button,1342242816
 668.706 -Control11=IDC_MAP_VIEW,VbaBitmapControl,1342373888
 668.707 -Control12=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888
 668.708 -Control13=IDC_COLOR,VbaColorControl,1342242816
 668.709 -Control14=IDC_R,static,1342308352
 668.710 -Control15=IDC_G,static,1342308352
 668.711 -Control16=IDC_B,static,1342308352
 668.712 -Control17=IDC_STATIC,button,1342177287
 668.713 -Control18=IDC_STATIC,button,1342177287
 668.714 -Control19=IDC_AUTO_UPDATE,button,1342242819
 668.715 -Control20=IDC_XY,static,1342308352
 668.716 -Control21=IDC_STATIC,static,1342308352
 668.717 -Control22=IDC_MODE,static,1342308352
 668.718 -Control23=IDC_STATIC,static,1342308352
 668.719 -Control24=IDC_MAPBASE,static,1342308352
 668.720 -Control25=IDC_STATIC,static,1342308352
 668.721 -Control26=IDC_CHARBASE,static,1342308352
 668.722 -Control27=IDC_STATIC,static,1342308352
 668.723 -Control28=IDC_DIM,static,1342308352
 668.724 -Control29=IDC_STATIC,static,1342308352
 668.725 -Control30=IDC_NUMCOLORS,static,1342308352
 668.726 -Control31=IDC_STATIC,static,1342308352
 668.727 -Control32=IDC_PRIORITY,static,1342308352
 668.728 -Control33=IDC_STATIC,static,1342308352
 668.729 -Control34=IDC_MOSAIC,static,1342308352
 668.730 -Control35=IDC_STATIC,static,1342308352
 668.731 -Control36=IDC_OVERFLOW,static,1342308352
 668.732 -Control37=IDC_STATIC,static,1342308352
 668.733 -Control38=IDC_ADDRESS,static,1342308352
 668.734 -Control39=IDC_STATIC,static,1342308352
 668.735 -Control40=IDC_TILE_NUM,static,1342308352
 668.736 -Control41=IDC_STATIC,static,1342308352
 668.737 -Control42=IDC_FLIP,static,1342308352
 668.738 -Control43=IDC_STATIC,static,1342308352
 668.739 -Control44=IDC_PALETTE_NUM,static,1342308352
 668.740 -
 668.741 -[DLG:IDD_PALETTE_VIEW]
 668.742 -Type=1
 668.743 -Class=PaletteView
 668.744 -ControlCount=21
 668.745 -Control1=IDC_SAVE_BG,button,1342242816
 668.746 -Control2=IDC_SAVE_OBJ,button,1342242816
 668.747 -Control3=IDC_REFRESH2,button,1342242816
 668.748 -Control4=IDC_CLOSE,button,1342242816
 668.749 -Control5=IDC_ADDRESS,static,1342308352
 668.750 -Control6=IDC_R,static,1342308352
 668.751 -Control7=IDC_G,static,1342308352
 668.752 -Control8=IDC_B,static,1342308352
 668.753 -Control9=IDC_VALUE,static,1342308352
 668.754 -Control10=IDC_COLOR,VbaColorControl,1342242816
 668.755 -Control11=IDC_PALETTE_VIEW,VbaPaletteViewControl,1342242816
 668.756 -Control12=IDC_PALETTE_VIEW_OBJ,VbaPaletteViewControl,1342242816
 668.757 -Control13=IDC_STATIC,button,1342177287
 668.758 -Control14=IDC_STATIC,button,1342177287
 668.759 -Control15=IDC_STATIC,static,1342308352
 668.760 -Control16=IDC_STATIC,static,1342308352
 668.761 -Control17=IDC_STATIC,static,1342308352
 668.762 -Control18=IDC_STATIC,static,1342308352
 668.763 -Control19=IDC_STATIC,static,1342308352
 668.764 -Control20=IDC_STATIC,static,1342308352
 668.765 -Control21=IDC_AUTO_UPDATE,button,1342242819
 668.766 -
 668.767 -[DLG:IDD_MEM_VIEWER]
 668.768 -Type=1
 668.769 -Class=MemoryViewerDlg
 668.770 -ControlCount=14
 668.771 -Control1=IDC_ADDRESSES,combobox,1344339971
 668.772 -Control2=IDC_8_BIT,button,1342308361
 668.773 -Control3=IDC_16_BIT,button,1342177289
 668.774 -Control4=IDC_32_BIT,button,1342177289
 668.775 -Control5=IDC_ADDRESS,edit,1350766728
 668.776 -Control6=IDC_GO,button,1342373889
 668.777 -Control7=IDC_VIEWER,VbaMemoryViewer,1342242816
 668.778 -Control8=IDC_AUTO_UPDATE,button,1342242819
 668.779 -Control9=IDC_REFRESH,button,1342242816
 668.780 -Control10=IDC_LOAD,button,1342242816
 668.781 -Control11=IDC_SAVE,button,1342242816
 668.782 -Control12=IDC_CLOSE,button,1342242816
 668.783 -Control13=IDC_CURRENT_ADDRESS_LABEL,static,1342308352
 668.784 -Control14=IDC_CURRENT_ADDRESS,edit,1484849282
 668.785 -
 668.786 -[DLG:IDD_OAM_VIEW]
 668.787 -Type=1
 668.788 -Class=OamView
 668.789 -ControlCount=32
 668.790 -Control1=IDC_SPRITE,edit,1350639746
 668.791 -Control2=IDC_SCROLLBAR,scrollbar,1342177280
 668.792 -Control3=IDC_STRETCH,button,1342242819
 668.793 -Control4=IDC_REFRESH,button,1342373888
 668.794 -Control5=IDC_SAVE,button,1342373888
 668.795 -Control6=IDC_CLOSE,button,1342242816
 668.796 -Control7=IDC_OAM_VIEW,VbaBitmapControl,1342373888
 668.797 -Control8=IDC_OAM_VIEW_ZOOM,VbaZoomControl,1342373888
 668.798 -Control9=IDC_COLOR,VbaColorControl,1342242816
 668.799 -Control10=IDC_POS,static,1342308352
 668.800 -Control11=IDC_MODE,static,1342308352
 668.801 -Control12=IDC_COLORS,static,1342308352
 668.802 -Control13=IDC_PALETTE,static,1342308352
 668.803 -Control14=IDC_TILE,static,1342308352
 668.804 -Control15=IDC_PRIO,static,1342308352
 668.805 -Control16=IDC_SIZE2,static,1342308352
 668.806 -Control17=IDC_ROT,static,1342308352
 668.807 -Control18=IDC_FLAGS,static,1342308352
 668.808 -Control19=IDC_R,static,1342308352
 668.809 -Control20=IDC_G,static,1342308352
 668.810 -Control21=IDC_B,static,1342308352
 668.811 -Control22=IDC_STATIC,static,1342308352
 668.812 -Control23=IDC_STATIC,static,1342308352
 668.813 -Control24=IDC_STATIC,static,1342308352
 668.814 -Control25=IDC_STATIC,static,1342308352
 668.815 -Control26=IDC_STATIC,static,1342308352
 668.816 -Control27=IDC_STATIC,static,1342308352
 668.817 -Control28=IDC_STATIC,static,1342308352
 668.818 -Control29=IDC_STATIC,static,1342308352
 668.819 -Control30=IDC_STATIC,static,1342308352
 668.820 -Control31=IDC_STATIC,static,1342308352
 668.821 -Control32=IDC_AUTO_UPDATE,button,1342242819
 668.822 -
 668.823 -[DLG:IDD_ACCEL_EDITOR]
 668.824 -Type=1
 668.825 -Class=AccelEditor
 668.826 -ControlCount=13
 668.827 -Control1=IDC_STATIC,static,1342308352
 668.828 -Control2=IDC_COMMANDS,listbox,1352732931
 668.829 -Control3=IDC_STATIC1,static,1342308352
 668.830 -Control4=IDC_CURRENTS,listbox,1352728835
 668.831 -Control5=ID_OK,button,1342242817
 668.832 -Control6=ID_CANCEL,button,1342242816
 668.833 -Control7=IDC_STATIC3,static,1342308352
 668.834 -Control8=IDC_EDIT_KEY,edit,1350631552
 668.835 -Control9=IDC_ASSIGN,button,1342242816
 668.836 -Control10=IDC_REMOVE,button,1342242816
 668.837 -Control11=IDC_RESET,button,1342242816
 668.838 -Control12=IDC_ALREADY_AFFECTED,static,1342308864
 668.839 -Control13=IDC_STATIC2,static,1342308352
 668.840 -
 668.841 -[DLG:IDD_TILE_VIEWER]
 668.842 -Type=1
 668.843 -Class=TileView
 668.844 -ControlCount=26
 668.845 -Control1=IDC_16_COLORS,button,1342308361
 668.846 -Control2=IDC_256_COLORS,button,1342177289
 668.847 -Control3=IDC_CHARBASE_0,button,1342308361
 668.848 -Control4=IDC_CHARBASE_1,button,1342177289
 668.849 -Control5=IDC_CHARBASE_2,button,1342177289
 668.850 -Control6=IDC_CHARBASE_3,button,1342177289
 668.851 -Control7=IDC_CHARBASE_4,button,1342177289
 668.852 -Control8=IDC_PALETTE_SLIDER,msctls_trackbar32,1342373889
 668.853 -Control9=IDC_STRETCH,button,1342242819
 668.854 -Control10=IDC_REFRESH,button,1342373888
 668.855 -Control11=IDC_SAVE,button,1342242816
 668.856 -Control12=IDC_CLOSE,button,1342242816
 668.857 -Control13=IDC_TILE_VIEW,VbaBitmapControl,1342373888
 668.858 -Control14=IDC_STATIC,button,1342177287
 668.859 -Control15=IDC_STATIC,button,1342177287
 668.860 -Control16=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888
 668.861 -Control17=IDC_COLOR,VbaColorControl,1342242816
 668.862 -Control18=IDC_R,static,1342308352
 668.863 -Control19=IDC_G,static,1342308352
 668.864 -Control20=IDC_B,static,1342308352
 668.865 -Control21=IDC_STATIC,static,1342308352
 668.866 -Control22=IDC_AUTO_UPDATE,button,1342242819
 668.867 -Control23=IDC_STATIC,static,1342308352
 668.868 -Control24=IDC_STATIC,static,1342308352
 668.869 -Control25=IDC_TILE_NUMBER,static,1342308352
 668.870 -Control26=IDC_ADDRESS,static,1342308352
 668.871 -
 668.872 -[DLG:IDD_DISASSEMBLE]
 668.873 -Type=1
 668.874 -Class=Disassemble
 668.875 -ControlCount=55
 668.876 -Control1=IDC_AUTOMATIC,button,1342308361
 668.877 -Control2=IDC_ARM,button,1342177289
 668.878 -Control3=IDC_THUMB,button,1342177289
 668.879 -Control4=IDC_ADDRESS,edit,1350762632
 668.880 -Control5=IDC_GO,button,1342242816
 668.881 -Control6=IDC_DISASSEMBLE,listbox,1350631683
 668.882 -Control7=IDC_AUTO_UPDATE,button,1342242819
 668.883 -Control8=IDC_REFRESH,button,1342242816
 668.884 -Control9=IDC_NEXT,button,1342242816
 668.885 -Control10=IDC_CLOSE,button,1342242817
 668.886 -Control11=IDC_STATIC,static,1342308352
 668.887 -Control12=IDC_STATIC,static,1342308352
 668.888 -Control13=IDC_STATIC,static,1342308352
 668.889 -Control14=IDC_STATIC,static,1342308352
 668.890 -Control15=IDC_STATIC,static,1342308352
 668.891 -Control16=IDC_STATIC,static,1342308352
 668.892 -Control17=IDC_STATIC,static,1342308352
 668.893 -Control18=IDC_STATIC,static,1342308352
 668.894 -Control19=IDC_R0,static,1342308352
 668.895 -Control20=IDC_R1,static,1342308352
 668.896 -Control21=IDC_R2,static,1342308352
 668.897 -Control22=IDC_R3,static,1342308352
 668.898 -Control23=IDC_R4,static,1342308352
 668.899 -Control24=IDC_R5,static,1342308352
 668.900 -Control25=IDC_R6,static,1342308352
 668.901 -Control26=IDC_R7,static,1342308352
 668.902 -Control27=IDC_R8,static,1342308352
 668.903 -Control28=IDC_R9,static,1342308352
 668.904 -Control29=IDC_R10,static,1342308352
 668.905 -Control30=IDC_R11,static,1342308352
 668.906 -Control31=IDC_R12,static,1342308352
 668.907 -Control32=IDC_R13,static,1342308352
 668.908 -Control33=IDC_R14,static,1342308352
 668.909 -Control34=IDC_R15,static,1342308352
 668.910 -Control35=IDC_STATIC,static,1342308352
 668.911 -Control36=IDC_STATIC,static,1342308352
 668.912 -Control37=IDC_STATIC,static,1342308352
 668.913 -Control38=IDC_STATIC,static,1342308352
 668.914 -Control39=IDC_STATIC,static,1342308352
 668.915 -Control40=IDC_STATIC,static,1342308352
 668.916 -Control41=IDC_STATIC,static,1342308352
 668.917 -Control42=IDC_STATIC,static,1342308352
 668.918 -Control43=IDC_R16,static,1342308352
 668.919 -Control44=IDC_STATIC,static,1342308352
 668.920 -Control45=IDC_N,button,1476460547
 668.921 -Control46=IDC_Z,button,1476460547
 668.922 -Control47=IDC_C,button,1476460547
 668.923 -Control48=IDC_V,button,1476460547
 668.924 -Control49=IDC_F,button,1476460547
 668.925 -Control50=IDC_I,button,1476460547
 668.926 -Control51=IDC_T,button,1476460547
 668.927 -Control52=IDC_STATIC,static,1342308352
 668.928 -Control53=IDC_MODE,static,1342308352
 668.929 -Control54=IDC_VSCROLL,scrollbar,1342177281
 668.930 -Control55=IDC_GOPC,button,1342242816
 668.931 -
 668.932 -[DLG:IDD_GDB_PORT]
 668.933 -Type=1
 668.934 -Class=GDBPortDlg
 668.935 -ControlCount=4
 668.936 -Control1=ID_OK,button,1342242817
 668.937 -Control2=ID_CANCEL,button,1342242816
 668.938 -Control3=IDC_STATIC,static,1342308352
 668.939 -Control4=IDC_PORT,edit,1350631554
 668.940 -
 668.941 -[DLG:IDD_GDB_WAITING]
 668.942 -Type=1
 668.943 -Class=GDBWaitingDlg
 668.944 -ControlCount=3
 668.945 -Control1=ID_CANCEL,button,1342242816
 668.946 -Control2=IDC_STATIC,static,1342308352
 668.947 -Control3=IDC_PORT,static,1342308352
 668.948 -
 668.949 -[DLG:IDD_LOGGING]
 668.950 -Type=1
 668.951 -Class=Logging
 668.952 -ControlCount=15
 668.953 -Control1=IDC_VERBOSE_SWI,button,1342242819
 668.954 -Control2=IDC_VERBOSE_UNALIGNED_ACCESS,button,1342242819
 668.955 -Control3=IDC_VERBOSE_ILLEGAL_WRITE,button,1342242819
 668.956 -Control4=IDC_VERBOSE_ILLEGAL_READ,button,1342242819
 668.957 -Control5=IDC_VERBOSE_DMA0,button,1342242819
 668.958 -Control6=IDC_VERBOSE_DMA1,button,1342242819
 668.959 -Control7=IDC_VERBOSE_DMA2,button,1342242819
 668.960 -Control8=IDC_VERBOSE_DMA3,button,1342242819
 668.961 -Control9=IDC_VERBOSE_UNDEFINED,button,1342242819
 668.962 -Control10=IDC_VERBOSE_AGBPRINT,button,1342242819
 668.963 -Control11=IDC_LOG,edit,1353779396
 668.964 -Control12=IDC_SAVE,button,1342242816
 668.965 -Control13=IDC_CLEAR,button,1342242816
 668.966 -Control14=ID_OK,button,1342242817
 668.967 -Control15=IDC_STATIC,button,1342177287
 668.968 -
 668.969 -[DLG:IDD_ADDR_SIZE]
 668.970 -Type=1
 668.971 -Class=MemoryViewerAddressSize
 668.972 -ControlCount=6
 668.973 -Control1=IDC_ADDRESS,edit,1350631552
 668.974 -Control2=IDC_SIZE_CONTROL,edit,1350631552
 668.975 -Control3=ID_OK,button,1342242817
 668.976 -Control4=ID_CANCEL,button,1342242816
 668.977 -Control5=IDC_STATIC,static,1342308352
 668.978 -Control6=IDC_STATIC,static,1342308352
 668.979 -
 668.980 -[DLG:IDD_GB_DISASSEMBLE]
 668.981 -Type=1
 668.982 -Class=GBDisassemble
 668.983 -ControlCount=27
 668.984 -Control1=IDC_ADDRESS,edit,1350762632
 668.985 -Control2=IDC_GO,button,1342242816
 668.986 -Control3=IDC_DISASSEMBLE,listbox,1350631683
 668.987 -Control4=IDC_AUTO_UPDATE,button,1342242819
 668.988 -Control5=IDC_REFRESH,button,1342242816
 668.989 -Control6=IDC_NEXT,button,1342242816
 668.990 -Control7=IDC_CLOSE,button,1342242817
 668.991 -Control8=IDC_STATIC,static,1342308352
 668.992 -Control9=IDC_STATIC,static,1342308352
 668.993 -Control10=IDC_STATIC,static,1342308352
 668.994 -Control11=IDC_STATIC,static,1342308352
 668.995 -Control12=IDC_STATIC,static,1342308352
 668.996 -Control13=IDC_R0,static,1342308352
 668.997 -Control14=IDC_R1,static,1342308352
 668.998 -Control15=IDC_R2,static,1342308352
 668.999 -Control16=IDC_R3,static,1342308352
668.1000 -Control17=IDC_R6,static,1342308352
668.1001 -Control18=IDC_N,button,1476460547
668.1002 -Control19=IDC_Z,button,1476460547
668.1003 -Control20=IDC_C,button,1476460547
668.1004 -Control21=IDC_H,button,1476460547
668.1005 -Control22=IDC_VSCROLL,scrollbar,1342177281
668.1006 -Control23=IDC_GOPC,button,1342242816
668.1007 -Control24=IDC_STATIC,static,1342308352
668.1008 -Control25=IDC_R4,static,1342308352
668.1009 -Control26=IDC_STATIC,static,1342308352
668.1010 -Control27=IDC_R5,static,1342308352
668.1011 -
668.1012 -[DLG:IDD_GB_OAM_VIEW]
668.1013 -Type=1
668.1014 -Class=GBOamView
668.1015 -ControlCount=28
668.1016 -Control1=IDC_SPRITE,edit,1350639746
668.1017 -Control2=IDC_SCROLLBAR,scrollbar,1342177280
668.1018 -Control3=IDC_STRETCH,button,1342242819
668.1019 -Control4=IDC_REFRESH,button,1342373888
668.1020 -Control5=IDC_SAVE,button,1342373888
668.1021 -Control6=IDC_CLOSE,button,1342242816
668.1022 -Control7=IDC_OAM_VIEW,VbaBitmapControl,1342373888
668.1023 -Control8=IDC_OAM_VIEW_ZOOM,VbaZoomControl,1342373888
668.1024 -Control9=IDC_COLOR,VbaColorControl,1342242816
668.1025 -Control10=IDC_POS,static,1342308352
668.1026 -Control11=IDC_PALETTE,static,1342308352
668.1027 -Control12=IDC_TILE,static,1342308352
668.1028 -Control13=IDC_PRIO,static,1342308352
668.1029 -Control14=IDC_OAP,static,1342308352
668.1030 -Control15=IDC_FLAGS,static,1342308352
668.1031 -Control16=IDC_R,static,1342308352
668.1032 -Control17=IDC_G,static,1342308352
668.1033 -Control18=IDC_B,static,1342308352
668.1034 -Control19=IDC_STATIC,static,1342308352
668.1035 -Control20=IDC_STATIC,static,1342308352
668.1036 -Control21=IDC_STATIC,static,1342308352
668.1037 -Control22=IDC_STATIC,static,1342308352
668.1038 -Control23=IDC_STATIC,static,1342308352
668.1039 -Control24=IDC_STATIC,static,1342308352
668.1040 -Control25=IDC_STATIC,static,1342308352
668.1041 -Control26=IDC_AUTO_UPDATE,button,1342242819
668.1042 -Control27=IDC_BANK,static,1342308352
668.1043 -Control28=IDC_STATIC,static,1342308352
668.1044 -
668.1045 -[DLG:IDD_GB_TILE_VIEWER]
668.1046 -Type=1
668.1047 -Class=GBTileView
668.1048 -ControlCount=23
668.1049 -Control1=IDC_BANK_0,button,1342308361
668.1050 -Control2=IDC_BANK_1,button,1342177289
668.1051 -Control3=IDC_CHARBASE_0,button,1342308361
668.1052 -Control4=IDC_CHARBASE_1,button,1342177289
668.1053 -Control5=IDC_STRETCH,button,1342242819
668.1054 -Control6=IDC_REFRESH,button,1342373888
668.1055 -Control7=IDC_SAVE,button,1342242816
668.1056 -Control8=IDC_CLOSE,button,1342242816
668.1057 -Control9=IDC_TILE_VIEW,VbaBitmapControl,1342373888
668.1058 -Control10=IDC_STATIC,button,1342177287
668.1059 -Control11=IDC_STATIC,button,1342177287
668.1060 -Control12=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888
668.1061 -Control13=IDC_COLOR,VbaColorControl,1342242816
668.1062 -Control14=IDC_R,static,1342308352
668.1063 -Control15=IDC_G,static,1342308352
668.1064 -Control16=IDC_B,static,1342308352
668.1065 -Control17=IDC_STATIC,static,1342308352
668.1066 -Control18=IDC_AUTO_UPDATE,button,1342242819
668.1067 -Control19=IDC_STATIC,static,1342308352
668.1068 -Control20=IDC_STATIC,static,1342308352
668.1069 -Control21=IDC_TILE_NUMBER,static,1342308352
668.1070 -Control22=IDC_ADDRESS,static,1342308352
668.1071 -Control23=IDC_PALETTE_SLIDER,msctls_trackbar32,1342373889
668.1072 -
668.1073 -[DLG:IDD_GB_MAP_VIEW]
668.1074 -Type=1
668.1075 -Class=GBMapView
668.1076 -ControlCount=28
668.1077 -Control1=IDC_BANK_0,button,1342308361
668.1078 -Control2=IDC_BANK_1,button,1342177289
668.1079 -Control3=IDC_BG0,button,1342308361
668.1080 -Control4=IDC_BG1,button,1342177289
668.1081 -Control5=IDC_STRETCH,button,1342242819
668.1082 -Control6=IDC_REFRESH,button,1342373888
668.1083 -Control7=IDC_SAVE,button,1342373888
668.1084 -Control8=IDC_CLOSE,button,1342242816
668.1085 -Control9=IDC_MAP_VIEW,VbaBitmapControl,1342373888
668.1086 -Control10=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888
668.1087 -Control11=IDC_COLOR,VbaColorControl,1342242816
668.1088 -Control12=IDC_R,static,1342308352
668.1089 -Control13=IDC_G,static,1342308352
668.1090 -Control14=IDC_B,static,1342308352
668.1091 -Control15=IDC_STATIC,button,1342177287
668.1092 -Control16=IDC_STATIC,button,1342177287
668.1093 -Control17=IDC_AUTO_UPDATE,button,1342242819
668.1094 -Control18=IDC_XY,static,1342308352
668.1095 -Control19=IDC_STATIC,static,1342308352
668.1096 -Control20=IDC_PRIORITY,static,1342308352
668.1097 -Control21=IDC_STATIC,static,1342308352
668.1098 -Control22=IDC_ADDRESS,static,1342308352
668.1099 -Control23=IDC_STATIC,static,1342308352
668.1100 -Control24=IDC_TILE_NUM,static,1342308352
668.1101 -Control25=IDC_STATIC,static,1342308352
668.1102 -Control26=IDC_FLIP,static,1342308352
668.1103 -Control27=IDC_STATIC,static,1342308352
668.1104 -Control28=IDC_PALETTE_NUM,static,1342308352
668.1105 -
668.1106 -[DLG:IDD_GB_PALETTE_VIEW]
668.1107 -Type=1
668.1108 -Class=GBPaletteView
668.1109 -ControlCount=21
668.1110 -Control1=IDC_SAVE_BG,button,1342242816
668.1111 -Control2=IDC_SAVE_OBJ,button,1342242816
668.1112 -Control3=IDC_REFRESH2,button,1342242816
668.1113 -Control4=IDC_CLOSE,button,1342242816
668.1114 -Control5=IDC_ADDRESS,static,1342308352
668.1115 -Control6=IDC_R,static,1342308352
668.1116 -Control7=IDC_G,static,1342308352
668.1117 -Control8=IDC_B,static,1342308352
668.1118 -Control9=IDC_VALUE,static,1342308352
668.1119 -Control10=IDC_COLOR,VbaColorControl,1342242816
668.1120 -Control11=IDC_PALETTE_VIEW,VbaPaletteViewControl,1342242816
668.1121 -Control12=IDC_PALETTE_VIEW_OBJ,VbaPaletteViewControl,1342242816
668.1122 -Control13=IDC_STATIC,button,1342177287
668.1123 -Control14=IDC_STATIC,button,1342177287
668.1124 -Control15=IDC_STATIC,static,1342308352
668.1125 -Control16=IDC_STATIC,static,1342308352
668.1126 -Control17=IDC_STATIC,static,1342308352
668.1127 -Control18=IDC_STATIC,static,1342308352
668.1128 -Control19=IDC_STATIC,static,1342308352
668.1129 -Control20=IDC_STATIC,static,1342308352
668.1130 -Control21=IDC_AUTO_UPDATE,button,1342242819
668.1131 -
668.1132 -[DLG:IDD_IO_VIEWER]
668.1133 -Type=1
668.1134 -Class=IOViewer
668.1135 -ControlCount=23
668.1136 -Control1=IDC_ADDRESSES,combobox,1344339971
668.1137 -Control2=IDC_VALUE,static,1342308354
668.1138 -Control3=IDC_BIT_15,button,1342242819
668.1139 -Control4=IDC_BIT_14,button,1342242819
668.1140 -Control5=IDC_BIT_13,button,1342242819
668.1141 -Control6=IDC_BIT_12,button,1342242819
668.1142 -Control7=IDC_BIT_11,button,1342242819
668.1143 -Control8=IDC_BIT_10,button,1342242819
668.1144 -Control9=IDC_BIT_9,button,1342242819
668.1145 -Control10=IDC_BIT_8,button,1342242819
668.1146 -Control11=IDC_BIT_7,button,1342242819
668.1147 -Control12=IDC_BIT_6,button,1342242819
668.1148 -Control13=IDC_BIT_5,button,1342242819
668.1149 -Control14=IDC_BIT_4,button,1342242819
668.1150 -Control15=IDC_BIT_3,button,1342242819
668.1151 -Control16=IDC_BIT_2,button,1342242819
668.1152 -Control17=IDC_BIT_1,button,1342242819
668.1153 -Control18=IDC_BIT_0,button,1342242819
668.1154 -Control19=IDC_AUTO_UPDATE,button,1342242819
668.1155 -Control20=IDC_REFRESH,button,1342242817
668.1156 -Control21=IDC_APPLY,button,1342242817
668.1157 -Control22=IDC_CLOSE,button,1342242816
668.1158 -Control23=IDC_STATIC,static,1342308352
668.1159 -
668.1160 -[MNU:IDR_MENU]
668.1161 -Type=1
668.1162 -Class=MainWnd
668.1163 -Command1=ID_FILE_OPEN
668.1164 -Command2=ID_FILE_OPENGAMEBOY
668.1165 -Command3=ID_FILE_LOAD
668.1166 -Command4=ID_FILE_SAVE
668.1167 -Command5=ID_FILE_LOADGAME_MOSTRECENT
668.1168 -Command6=ID_FILE_LOADGAME_AUTOLOADMOSTRECENT
668.1169 -Command7=ID_FILE_LOADGAME_SLOT1
668.1170 -Command8=ID_FILE_LOADGAME_SLOT2
668.1171 -Command9=ID_FILE_LOADGAME_SLOT3
668.1172 -Command10=ID_FILE_LOADGAME_SLOT4
668.1173 -Command11=ID_FILE_LOADGAME_SLOT5
668.1174 -Command12=ID_FILE_LOADGAME_SLOT6
668.1175 -Command13=ID_FILE_LOADGAME_SLOT7
668.1176 -Command14=ID_FILE_LOADGAME_SLOT8
668.1177 -Command15=ID_FILE_LOADGAME_SLOT9
668.1178 -Command16=ID_FILE_LOADGAME_SLOT10
668.1179 -Command17=ID_FILE_SAVEGAME_OLDESTSLOT
668.1180 -Command18=ID_FILE_SAVEGAME_SLOT1
668.1181 -Command19=ID_FILE_SAVEGAME_SLOT2
668.1182 -Command20=ID_FILE_SAVEGAME_SLOT3
668.1183 -Command21=ID_FILE_SAVEGAME_SLOT4
668.1184 -Command22=ID_FILE_SAVEGAME_SLOT5
668.1185 -Command23=ID_FILE_SAVEGAME_SLOT6
668.1186 -Command24=ID_FILE_SAVEGAME_SLOT7
668.1187 -Command25=ID_FILE_SAVEGAME_SLOT8
668.1188 -Command26=ID_FILE_SAVEGAME_SLOT9
668.1189 -Command27=ID_FILE_SAVEGAME_SLOT10
668.1190 -Command28=ID_FILE_PAUSE
668.1191 -Command29=ID_FILE_RESET
668.1192 -Command30=ID_FILE_RECENT_RESET
668.1193 -Command31=ID_FILE_RECENT_FREEZE
668.1194 -Command32=ID_FILE_IMPORT_BATTERYFILE
668.1195 -Command33=ID_FILE_IMPORT_GAMESHARKCODEFILE
668.1196 -Command34=ID_FILE_IMPORT_GAMESHARKSNAPSHOT
668.1197 -Command35=ID_FILE_EXPORT_BATTERYFILE
668.1198 -Command36=ID_FILE_EXPORT_GAMESHARKSNAPSHOT
668.1199 -Command37=ID_FILE_SCREENCAPTURE
668.1200 -Command38=ID_FILE_ROMINFORMATION
668.1201 -Command39=ID_FILE_TOGGLEMENU
668.1202 -Command40=ID_FILE_CLOSE
668.1203 -Command41=ID_FILE_EXIT
668.1204 -Command42=ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE
668.1205 -Command43=ID_OPTIONS_FRAMESKIP_THROTTLE_25
668.1206 -Command44=ID_OPTIONS_FRAMESKIP_THROTTLE_50
668.1207 -Command45=ID_OPTIONS_FRAMESKIP_THROTTLE_100
668.1208 -Command46=ID_OPTIONS_FRAMESKIP_THROTTLE_150
668.1209 -Command47=ID_OPTIONS_FRAMESKIP_THROTTLE_200
668.1210 -Command48=ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER
668.1211 -Command49=ID_OPTIONS_FRAMESKIP_AUTOMATIC
668.1212 -Command50=ID_OPTIONS_VIDEO_FRAMESKIP_0
668.1213 -Command51=ID_OPTIONS_VIDEO_FRAMESKIP_1
668.1214 -Command52=ID_OPTIONS_VIDEO_FRAMESKIP_2
668.1215 -Command53=ID_OPTIONS_VIDEO_FRAMESKIP_3
668.1216 -Command54=ID_OPTIONS_VIDEO_FRAMESKIP_4
668.1217 -Command55=ID_OPTIONS_VIDEO_FRAMESKIP_5
668.1218 -Command56=ID_OPTIONS_VIDEO_FRAMESKIP_6
668.1219 -Command57=ID_OPTIONS_VIDEO_FRAMESKIP_7
668.1220 -Command58=ID_OPTIONS_VIDEO_FRAMESKIP_8
668.1221 -Command59=ID_OPTIONS_VIDEO_FRAMESKIP_9
668.1222 -Command60=ID_OPTIONS_VIDEO_VSYNC
668.1223 -Command61=ID_OPTIONS_VIDEO_RENDERMETHOD_GDI
668.1224 -Command62=ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW
668.1225 -Command63=ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D
668.1226 -Command64=ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL
668.1227 -Command65=ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY
668.1228 -Command66=ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY
668.1229 -Command67=ID_OPTIONS_VIDEO_TRIPLEBUFFERING
668.1230 -Command68=ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER
668.1231 -Command69=ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR
668.1232 -Command70=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST
668.1233 -Command71=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR
668.1234 -Command72=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE
668.1235 -Command73=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS
668.1236 -Command74=ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN
668.1237 -Command75=ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN
668.1238 -Command76=ID_OPTIONS_VIDEO_X1
668.1239 -Command77=ID_OPTIONS_VIDEO_X2
668.1240 -Command78=ID_OPTIONS_VIDEO_X3
668.1241 -Command79=ID_OPTIONS_VIDEO_X4
668.1242 -Command80=ID_OPTIONS_VIDEO_FULLSCREEN320X240
668.1243 -Command81=ID_OPTIONS_VIDEO_FULLSCREEN640X480
668.1244 -Command82=ID_OPTIONS_VIDEO_FULLSCREEN800X600
668.1245 -Command83=ID_OPTIONS_VIDEO_FULLSCREEN
668.1246 -Command84=ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE
668.1247 -Command85=ID_OPTIONS_VIDEO_DISABLESFX
668.1248 -Command86=ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT
668.1249 -Command87=ID_OPTIONS_VIDEO_LAYERS_BG0
668.1250 -Command88=ID_OPTIONS_VIDEO_LAYERS_BG1
668.1251 -Command89=ID_OPTIONS_VIDEO_LAYERS_BG2
668.1252 -Command90=ID_OPTIONS_VIDEO_LAYERS_BG3
668.1253 -Command91=ID_OPTIONS_VIDEO_LAYERS_OBJ
668.1254 -Command92=ID_OPTIONS_VIDEO_LAYERS_WIN0
668.1255 -Command93=ID_OPTIONS_VIDEO_LAYERS_WIN1
668.1256 -Command94=ID_OPTIONS_VIDEO_LAYERS_OBJWIN
668.1257 -Command95=ID_OPTIONS_EMULATOR_ASSOCIATE
668.1258 -Command96=ID_OPTIONS_EMULATOR_DIRECTORIES
668.1259 -Command97=ID_OPTIONS_EMULATOR_DISABLESTATUSMESSAGES
668.1260 -Command98=ID_OPTIONS_EMULATOR_SYNCHRONIZE
668.1261 -Command99=ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE
668.1262 -Command100=ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE
668.1263 -Command101=ID_OPTIONS_EMULATOR_REMOVEINTROSGBA
668.1264 -Command102=ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH
668.1265 -Command103=ID_OPTIONS_EMULATOR_AGBPRINT
668.1266 -Command104=ID_OPTIONS_EMULATOR_REALTIMECLOCK
668.1267 -Command105=ID_OPTIONS_EMULATOR_AUTOHIDEMENU
668.1268 -Command106=ID_OPTIONS_EMULATOR_REWINDINTERVAL
668.1269 -Command107=ID_OPTIONS_EMULATOR_SHOWSPEED_NONE
668.1270 -Command108=ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE
668.1271 -Command109=ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED
668.1272 -Command110=ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT
668.1273 -Command111=ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC
668.1274 -Command112=ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM
668.1275 -Command113=ID_OPTIONS_EMULATOR_SAVETYPE_SRAM
668.1276 -Command114=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH
668.1277 -Command115=ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR
668.1278 -Command116=ID_OPTIONS_EMULATOR_SAVETYPE_NONE
668.1279 -Command117=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K
668.1280 -Command118=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M
668.1281 -Command119=ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION
668.1282 -Command120=ID_OPTIONS_EMULATOR_USEBIOSFILE
668.1283 -Command121=ID_OPTIONS_EMULATOR_SKIPBIOS
668.1284 -Command122=ID_OPTIONS_EMULATOR_SELECTBIOSFILE
668.1285 -Command123=ID_OPTIONS_EMULATOR_PNGFORMAT
668.1286 -Command124=ID_OPTIONS_EMULATOR_BMPFORMAT
668.1287 -Command125=ID_OPTIONS_SOUND_OFF
668.1288 -Command126=ID_OPTIONS_SOUND_MUTE
668.1289 -Command127=ID_OPTIONS_SOUND_ON
668.1290 -Command128=ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION
668.1291 -Command129=ID_OPTIONS_SOUND_ECHO
668.1292 -Command130=ID_OPTIONS_SOUND_LOWPASSFILTER
668.1293 -Command131=ID_OPTIONS_SOUND_REVERSESTEREO
668.1294 -Command132=ID_OPTIONS_SOUND_CHANNEL1
668.1295 -Command133=ID_OPTIONS_SOUND_CHANNEL2
668.1296 -Command134=ID_OPTIONS_SOUND_CHANNEL3
668.1297 -Command135=ID_OPTIONS_SOUND_CHANNEL4
668.1298 -Command136=ID_OPTIONS_SOUND_DIRECTSOUNDA
668.1299 -Command137=ID_OPTIONS_SOUND_DIRECTSOUNDB
668.1300 -Command138=ID_OPTIONS_SOUND_11KHZ
668.1301 -Command139=ID_OPTIONS_SOUND_22KHZ
668.1302 -Command140=ID_OPTIONS_SOUND_44KHZ
668.1303 -Command141=ID_OPTIONS_SOUND_VOLUME_25X
668.1304 -Command142=ID_OPTIONS_SOUND_VOLUME_5X
668.1305 -Command143=ID_OPTIONS_SOUND_VOLUME_1X
668.1306 -Command144=ID_OPTIONS_SOUND_VOLUME_2X
668.1307 -Command145=ID_OPTIONS_SOUND_VOLUME_3X
668.1308 -Command146=ID_OPTIONS_SOUND_VOLUME_4X
668.1309 -Command147=ID_OPTIONS_GAMEBOY_BORDER
668.1310 -Command148=ID_OPTIONS_GAMEBOY_PRINTER
668.1311 -Command149=ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC
668.1312 -Command150=ID_OPTIONS_GAMEBOY_AUTOMATIC
668.1313 -Command151=ID_OPTIONS_GAMEBOY_GBA
668.1314 -Command152=ID_OPTIONS_GAMEBOY_CGB
668.1315 -Command153=ID_OPTIONS_GAMEBOY_SGB
668.1316 -Command154=ID_OPTIONS_GAMEBOY_SGB2
668.1317 -Command155=ID_OPTIONS_GAMEBOY_GB
668.1318 -Command156=ID_OPTIONS_GAMEBOY_REALCOLORS
668.1319 -Command157=ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS
668.1320 -Command158=ID_OPTIONS_GAMEBOY_COLORS
668.1321 -Command159=ID_OPTIONS_PRIORITY_HIGHEST
668.1322 -Command160=ID_OPTIONS_PRIORITY_ABOVENORMAL
668.1323 -Command161=ID_OPTIONS_PRIORITY_NORMAL
668.1324 -Command162=ID_OPTIONS_PRIORITY_BELOWNORMAL
668.1325 -Command163=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE
668.1326 -Command164=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR
668.1327 -Command165=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART
668.1328 -Command166=ID_OPTIONS_FILTER_NORMAL
668.1329 -Command167=ID_OPTIONS_FILTER_TVMODE
668.1330 -Command168=ID_OPTIONS_FILTER_2XSAI
668.1331 -Command169=ID_OPTIONS_FILTER_SUPER2XSAI
668.1332 -Command170=ID_OPTIONS_FILTER_SUPEREAGLE
668.1333 -Command171=ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL
668.1334 -Command172=ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL
668.1335 -Command173=ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X
668.1336 -Command174=ID_OPTIONS_FILTER16BIT_SIMPLE2X
668.1337 -Command175=ID_OPTIONS_FILTER_BILINEAR
668.1338 -Command176=ID_OPTIONS_FILTER_BILINEARPLUS
668.1339 -Command177=ID_OPTIONS_FILTER_SCANLINES
668.1340 -Command178=ID_OPTIONS_FILTER_HQ2X
668.1341 -Command179=ID_OPTIONS_FILTER_LQ2X
668.1342 -Command180=ID_OPTIONS_FILTER_DISABLEMMX
668.1343 -Command181=ID_OPTIONS_JOYPAD_CONFIGURE_1
668.1344 -Command182=ID_OPTIONS_JOYPAD_CONFIGURE_2
668.1345 -Command183=ID_OPTIONS_JOYPAD_CONFIGURE_3
668.1346 -Command184=ID_OPTIONS_JOYPAD_CONFIGURE_4
668.1347 -Command185=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1
668.1348 -Command186=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2
668.1349 -Command187=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3
668.1350 -Command188=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4
668.1351 -Command189=ID_OPTIONS_JOYPAD_MOTIONCONFIGURE
668.1352 -Command190=ID_OPTIONS_JOYPAD_AUTOFIRE_A
668.1353 -Command191=ID_OPTIONS_JOYPAD_AUTOFIRE_B
668.1354 -Command192=ID_OPTIONS_JOYPAD_AUTOFIRE_L
668.1355 -Command193=ID_OPTIONS_JOYPAD_AUTOFIRE_R
668.1356 -Command194=ID_OPTIONS_LANGUAGE_SYSTEM
668.1357 -Command195=ID_OPTIONS_LANGUAGE_ENGLISH
668.1358 -Command196=ID_OPTIONS_LANGUAGE_OTHER
668.1359 -Command197=ID_CHEATS_SEARCHFORCHEATS
668.1360 -Command198=ID_CHEATS_CHEATLIST
668.1361 -Command199=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1362 -Command200=ID_CHEATS_DISABLECHEATS
668.1363 -Command201=ID_CHEATS_LOADCHEATLIST
668.1364 -Command202=ID_CHEATS_SAVECHEATLIST
668.1365 -Command203=ID_TOOLS_DISASSEMBLE
668.1366 -Command204=ID_TOOLS_LOGGING
668.1367 -Command205=ID_TOOLS_IOVIEWER
668.1368 -Command206=ID_TOOLS_MAPVIEW
668.1369 -Command207=ID_TOOLS_MEMORYVIEWER
668.1370 -Command208=ID_TOOLS_OAMVIEWER
668.1371 -Command209=ID_TOOLS_PALETTEVIEW
668.1372 -Command210=ID_TOOLS_TILEVIEWER
668.1373 -Command211=ID_DEBUG_NEXTFRAME
668.1374 -Command212=ID_TOOLS_DEBUG_GDB
668.1375 -Command213=ID_TOOLS_DEBUG_LOADANDWAIT
668.1376 -Command214=ID_TOOLS_DEBUG_BREAK
668.1377 -Command215=ID_TOOLS_DEBUG_DISCONNECT
668.1378 -Command216=ID_OPTIONS_SOUND_STARTRECORDING
668.1379 -Command217=ID_OPTIONS_SOUND_STOPRECORDING
668.1380 -Command218=ID_TOOLS_RECORD_STARTAVIRECORDING
668.1381 -Command219=ID_TOOLS_RECORD_STOPAVIRECORDING
668.1382 -Command220=ID_TOOLS_RECORD_STARTMOVIERECORDING
668.1383 -Command221=ID_TOOLS_RECORD_STOPMOVIERECORDING
668.1384 -Command222=ID_TOOLS_PLAY_STARTMOVIEPLAYING
668.1385 -Command223=ID_TOOLS_PLAY_STOPMOVIEPLAYING
668.1386 -Command224=ID_TOOLS_REWIND
668.1387 -Command225=ID_TOOLS_CUSTOMIZE
668.1388 -Command226=ID_HELP_BUGREPORT
668.1389 -Command227=ID_HELP_FAQ
668.1390 -Command228=ID_HELP_ABOUT
668.1391 -CommandCount=228
668.1392 -
668.1393 -[ACL:IDR_ACCELERATOR]
668.1394 -Type=1
668.1395 -Class=?
668.1396 -Command1=ID_OPTIONS_VIDEO_LAYERS_BG0
668.1397 -Command2=ID_OPTIONS_JOYPAD_AUTOFIRE_A
668.1398 -Command3=ID_OPTIONS_VIDEO_LAYERS_BG1
668.1399 -Command4=ID_OPTIONS_JOYPAD_AUTOFIRE_B
668.1400 -Command5=ID_OPTIONS_VIDEO_LAYERS_BG2
668.1401 -Command6=ID_OPTIONS_JOYPAD_AUTOFIRE_L
668.1402 -Command7=ID_OPTIONS_VIDEO_LAYERS_BG3
668.1403 -Command8=ID_OPTIONS_JOYPAD_AUTOFIRE_R
668.1404 -Command9=ID_OPTIONS_VIDEO_LAYERS_OBJ
668.1405 -Command10=ID_OPTIONS_VIDEO_LAYERS_WIN0
668.1406 -Command11=ID_OPTIONS_VIDEO_LAYERS_WIN1
668.1407 -Command12=ID_OPTIONS_VIDEO_LAYERS_OBJWIN
668.1408 -Command13=ID_TOOLS_REWIND
668.1409 -Command14=ID_CHEATS_SEARCHFORCHEATS
668.1410 -Command15=ID_FILE_LOAD
668.1411 -Command16=ID_DEBUG_NEXTFRAME
668.1412 -Command17=ID_FILE_OPEN
668.1413 -Command18=ID_FILE_PAUSE
668.1414 -Command19=ID_FILE_RESET
668.1415 -Command20=ID_FILE_SAVE
668.1416 -Command21=ID_FILE_TOGGLEMENU
668.1417 -Command22=ID_FILE_LOADGAME_SLOT1
668.1418 -Command23=ID_FILE_MRU_FILE1
668.1419 -Command24=ID_FILE_SAVEGAME_SLOT1
668.1420 -Command25=ID_FILE_LOADGAME_SLOT10
668.1421 -Command26=ID_FILE_MRU_FILE10
668.1422 -Command27=ID_FILE_SAVEGAME_SLOT10
668.1423 -Command28=ID_FILE_LOADGAME_SLOT2
668.1424 -Command29=ID_FILE_MRU_FILE2
668.1425 -Command30=ID_FILE_SAVEGAME_SLOT2
668.1426 -Command31=ID_FILE_LOADGAME_SLOT3
668.1427 -Command32=ID_FILE_MRU_FILE3
668.1428 -Command33=ID_FILE_SAVEGAME_SLOT3
668.1429 -Command34=ID_FILE_LOADGAME_SLOT4
668.1430 -Command35=ID_FILE_MRU_FILE4
668.1431 -Command36=ID_FILE_SAVEGAME_SLOT4
668.1432 -Command37=ID_FILE_LOADGAME_SLOT5
668.1433 -Command38=ID_FILE_MRU_FILE5
668.1434 -Command39=ID_FILE_SAVEGAME_SLOT5
668.1435 -Command40=ID_FILE_LOADGAME_SLOT6
668.1436 -Command41=ID_FILE_MRU_FILE6
668.1437 -Command42=ID_FILE_SAVEGAME_SLOT6
668.1438 -Command43=ID_FILE_LOADGAME_SLOT7
668.1439 -Command44=ID_FILE_MRU_FILE7
668.1440 -Command45=ID_FILE_SAVEGAME_SLOT7
668.1441 -Command46=ID_FILE_LOADGAME_SLOT8
668.1442 -Command47=ID_FILE_MRU_FILE8
668.1443 -Command48=ID_FILE_SAVEGAME_SLOT8
668.1444 -Command49=ID_FILE_LOADGAME_SLOT9
668.1445 -Command50=ID_FILE_MRU_FILE9
668.1446 -Command51=ID_FILE_SAVEGAME_SLOT9
668.1447 -Command52=ID_FILE_EXIT
668.1448 -CommandCount=52
668.1449 -
668.1450 -[CLS:AddGSACode]
668.1451 -Type=0
668.1452 -HeaderFile=GBACheats.h
668.1453 -ImplementationFile=GBACheats.cpp
668.1454 -BaseClass=CDialog
668.1455 -Filter=D
668.1456 -VirtualFilter=dWC
668.1457 -LastObject=AddGSACode
668.1458 -
668.1459 -[CLS:GBCheatList]
668.1460 -Type=0
668.1461 -HeaderFile=GBCheatsDlg.h
668.1462 -ImplementationFile=GBCheatsDlg.cpp
668.1463 -BaseClass=CDialog
668.1464 -Filter=D
668.1465 -VirtualFilter=dWC
668.1466 -LastObject=GBCheatList
668.1467 -
668.1468 -[CLS:Disassemble]
668.1469 -Type=0
668.1470 -HeaderFile=Disassemble.h
668.1471 -ImplementationFile=Disassemble.cpp
668.1472 -BaseClass=CDialog
668.1473 -Filter=D
668.1474 -VirtualFilter=dWC
668.1475 -LastObject=Disassemble
668.1476 -
668.1477 -[CLS:GBDisassemble]
668.1478 -Type=0
668.1479 -HeaderFile=GBDisassemble.h
668.1480 -ImplementationFile=GBDisassemble.cpp
668.1481 -BaseClass=CDialog
668.1482 -Filter=D
668.1483 -LastObject=IDC_GO
668.1484 -VirtualFilter=dWC
668.1485 -
668.1486 -[CLS:Logging]
668.1487 -Type=0
668.1488 -HeaderFile=Logging.h
668.1489 -ImplementationFile=Logging.cpp
668.1490 -BaseClass=CDialog
668.1491 -Filter=D
668.1492 -VirtualFilter=dWC
668.1493 -LastObject=IDC_LOG
668.1494 -
668.1495 -[CLS:IOViewer]
668.1496 -Type=0
668.1497 -HeaderFile=IOViewer.h
668.1498 -ImplementationFile=IOViewer.cpp
668.1499 -BaseClass=CDialog
668.1500 -Filter=D
668.1501 -VirtualFilter=dWC
668.1502 -LastObject=ID_FILE_LOADGAME_SLOT1
668.1503 -
668.1504 -[CLS:ZoomControl]
668.1505 -Type=0
668.1506 -HeaderFile=ZoomControl.h
668.1507 -ImplementationFile=ZoomControl.cpp
668.1508 -BaseClass=CWnd
668.1509 -Filter=W
668.1510 -VirtualFilter=WC
668.1511 -LastObject=ZoomControl
668.1512 -
668.1513 -[CLS:BitmapControl]
668.1514 -Type=0
668.1515 -HeaderFile=BitmapControl.h
668.1516 -ImplementationFile=BitmapControl.cpp
668.1517 -BaseClass=CScrollView
668.1518 -Filter=C
668.1519 -VirtualFilter=VWC
668.1520 -LastObject=BitmapControl
668.1521 -
668.1522 -[CLS:MapView]
668.1523 -Type=0
668.1524 -HeaderFile=MapView.h
668.1525 -ImplementationFile=MapView.cpp
668.1526 -BaseClass=CDialog
668.1527 -Filter=D
668.1528 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1529 -VirtualFilter=dWC
668.1530 -
668.1531 -[CLS:GBMapView]
668.1532 -Type=0
668.1533 -HeaderFile=GBMapView.h
668.1534 -ImplementationFile=GBMapView.cpp
668.1535 -BaseClass=CDialog
668.1536 -Filter=D
668.1537 -LastObject=GBMapView
668.1538 -VirtualFilter=dWC
668.1539 -
668.1540 -[CLS:MemoryViewer]
668.1541 -Type=0
668.1542 -HeaderFile=MemoryViewer.h
668.1543 -ImplementationFile=MemoryViewer.cpp
668.1544 -BaseClass=CWnd
668.1545 -Filter=W
668.1546 -VirtualFilter=WC
668.1547 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1548 -
668.1549 -[CLS:MemoryViewerDlg]
668.1550 -Type=0
668.1551 -HeaderFile=MemoryViewerDlg.h
668.1552 -ImplementationFile=MemoryViewerDlg.cpp
668.1553 -BaseClass=CDialog
668.1554 -Filter=D
668.1555 -VirtualFilter=dWC
668.1556 -LastObject=MemoryViewerDlg
668.1557 -
668.1558 -[CLS:MemoryViewerAddressSize]
668.1559 -Type=0
668.1560 -HeaderFile=MemoryViewerAddressSize.h
668.1561 -ImplementationFile=MemoryViewerAddressSize.cpp
668.1562 -BaseClass=CDialog
668.1563 -Filter=D
668.1564 -LastObject=ID_CANCEL
668.1565 -VirtualFilter=dWC
668.1566 -
668.1567 -[CLS:GBMemoryViewerDlg]
668.1568 -Type=0
668.1569 -HeaderFile=GBMemoryViewerDlg.h
668.1570 -ImplementationFile=GBMemoryViewerDlg.cpp
668.1571 -BaseClass=CDialog
668.1572 -Filter=D
668.1573 -LastObject=GBMemoryViewerDlg
668.1574 -VirtualFilter=dWC
668.1575 -
668.1576 -[CLS:OamView]
668.1577 -Type=0
668.1578 -HeaderFile=OamView.h
668.1579 -ImplementationFile=OamView.cpp
668.1580 -BaseClass=CDialog
668.1581 -Filter=D
668.1582 -VirtualFilter=dWC
668.1583 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1584 -
668.1585 -[CLS:GBOamView]
668.1586 -Type=0
668.1587 -HeaderFile=GBOamView.h
668.1588 -ImplementationFile=GBOamView.cpp
668.1589 -BaseClass=CDialog
668.1590 -Filter=D
668.1591 -LastObject=GBOamView
668.1592 -VirtualFilter=dWC
668.1593 -
668.1594 -[CLS:PaletteViewControl]
668.1595 -Type=0
668.1596 -HeaderFile=PaletteViewControl.h
668.1597 -ImplementationFile=PaletteViewControl.cpp
668.1598 -BaseClass=CWnd
668.1599 -Filter=W
668.1600 -VirtualFilter=WC
668.1601 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1602 -
668.1603 -[CLS:PaletteView]
668.1604 -Type=0
668.1605 -HeaderFile=paletteview.h
668.1606 -ImplementationFile=paletteview.cpp
668.1607 -BaseClass=CDialog
668.1608 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1609 -
668.1610 -[CLS:GBPaletteView]
668.1611 -Type=0
668.1612 -HeaderFile=GBPaletteView.h
668.1613 -ImplementationFile=GBPaletteView.cpp
668.1614 -BaseClass=CDialog
668.1615 -Filter=D
668.1616 -LastObject=GBPaletteView
668.1617 -VirtualFilter=dWC
668.1618 -
668.1619 -[CLS:TileView]
668.1620 -Type=0
668.1621 -HeaderFile=TileView.h
668.1622 -ImplementationFile=TileView.cpp
668.1623 -BaseClass=CDialog
668.1624 -Filter=D
668.1625 -VirtualFilter=dWC
668.1626 -LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS
668.1627 -
668.1628 -[CLS:GBTileView]
668.1629 -Type=0
668.1630 -HeaderFile=GBTileView.h
668.1631 -ImplementationFile=GBTileView.cpp
668.1632 -BaseClass=CDialog
668.1633 -Filter=D
668.1634 -LastObject=GBTileView
668.1635 -VirtualFilter=dWC
668.1636 -
668.1637 -[CLS:GBPrinterDlg]
668.1638 -Type=0
668.1639 -HeaderFile=gbprinterdlg.h
668.1640 -ImplementationFile=gbprinterdlg.cpp
668.1641 -BaseClass=CDialog
668.1642 -Filter=D
668.1643 -VirtualFilter=dWC
668.1644 -LastObject=GBPrinterDlg
668.1645 -
668.1646 -[CLS:GDBPortDlg]
668.1647 -Type=0
668.1648 -HeaderFile=GDBConnection.h
668.1649 -ImplementationFile=GDBConnection.cpp
668.1650 -BaseClass=CDialog
668.1651 -Filter=D
668.1652 -LastObject=GDBPortDlg
668.1653 -VirtualFilter=dWC
668.1654 -
668.1655 -[CLS:GDBWaitingDlg]
668.1656 -Type=0
668.1657 -HeaderFile=GDBConnection.h
668.1658 -ImplementationFile=GDBConnection.cpp
668.1659 -BaseClass=CDialog
668.1660 -Filter=D
668.1661 -LastObject=GDBWaitingDlg
668.1662 -VirtualFilter=dWC
668.1663 -
668.1664 -[CLS:AccelEditor]
668.1665 -Type=0
668.1666 -HeaderFile=AccelEditor.h
668.1667 -ImplementationFile=AccelEditor.cpp
668.1668 -BaseClass=CDialog
668.1669 -Filter=D
668.1670 -LastObject=IDC_REMOVE
668.1671 -VirtualFilter=dWC
668.1672 -
668.1673 -[CLS:Hyperlink]
668.1674 -Type=0
668.1675 -HeaderFile=Hyperlink.h
668.1676 -ImplementationFile=Hyperlink.cpp
668.1677 -BaseClass=CStatic
668.1678 -Filter=W
668.1679 -VirtualFilter=WC
668.1680 -LastObject=Hyperlink
668.1681 -
668.1682 -[DLG:IDD_MAX_SCALE]
668.1683 -Type=1
668.1684 -Class=MaxScale
668.1685 -ControlCount=5
668.1686 -Control1=IDC_VALUE,edit,1350631552
668.1687 -Control2=ID_OK,button,1342242817
668.1688 -Control3=ID_CANCEL,button,1342242816
668.1689 -Control4=IDC_STATIC,static,1342308352
668.1690 -Control5=IDC_STATIC,static,1342308352
668.1691 -
668.1692 -[CLS:MaxScale]
668.1693 -Type=0
668.1694 -HeaderFile=MaxScale.h
668.1695 -ImplementationFile=MaxScale.cpp
668.1696 -BaseClass=CDialog
668.1697 -Filter=D
668.1698 -VirtualFilter=dWC
668.1699 -LastObject=MaxScale
668.1700 -
668.1701 -[DLG:IDD_BUG_REPORT]
668.1702 -Type=1
668.1703 -Class=BugReport
668.1704 -ControlCount=4
668.1705 -Control1=ID_OK,button,1342242816
668.1706 -Control2=IDC_BUG_REPORT,edit,1352730820
668.1707 -Control3=IDC_STATIC,static,1342308352
668.1708 -Control4=IDC_COPY,button,1342242817
668.1709 -
668.1710 -[CLS:BugReport]
668.1711 -Type=0
668.1712 -HeaderFile=BugReport.h
668.1713 -ImplementationFile=BugReport.cpp
668.1714 -BaseClass=CDialog
668.1715 -Filter=D
668.1716 -VirtualFilter=dWC
668.1717 -LastObject=BugReport
668.1718 -
   669.1 --- a/src/win32/VBA.cpp	Sat Mar 03 10:54:39 2012 -0600
   669.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   669.3 @@ -1,2272 +0,0 @@
   669.4 -// VBA.cpp : Defines the class behaviors for the application.
   669.5 -//
   669.6 -#include "stdafx.h"
   669.7 -#include <mmsystem.h>
   669.8 -#include <cassert>
   669.9 -
  669.10 -#include "resource.h"
  669.11 -#include "VBA.h"
  669.12 -#include "AVIWrite.h"
  669.13 -#include "Input.h"
  669.14 -#include "IUpdate.h"
  669.15 -#include "LangSelect.h"
  669.16 -#include "MainWnd.h"
  669.17 -#include "Reg.h"
  669.18 -#include "WavWriter.h"
  669.19 -#include "WinResUtil.h"
  669.20 -#include "WinMiscUtil.h"
  669.21 -#include "ramwatch.h"
  669.22 -
  669.23 -#include "../gba/GBA.h"
  669.24 -#include "../gba/GBAGlobals.h"
  669.25 -#include "../gba/agbprint.h"
  669.26 -#include "../gb/GB.h"
  669.27 -#include "../gb/gbGlobals.h"
  669.28 -#include "../gb/gbPrinter.h"
  669.29 -#include "../common/CheatSearch.h"
  669.30 -#include "../gba/RTC.h"
  669.31 -#include "../gba/GBASound.h"
  669.32 -#include "../common/Util.h"
  669.33 -#include "../common/Text.h"
  669.34 -#include "../common/movie.h"
  669.35 -#include "../common/nesvideos-piece.h"
  669.36 -#include "../common/vbalua.h"
  669.37 -#include "../filters/filters.h"
  669.38 -#include "../version.h"
  669.39 -
  669.40 -extern IDisplay *newGDIDisplay();
  669.41 -extern IDisplay *newDirectDrawDisplay();
  669.42 -extern IDisplay *newDirect3DDisplay();
  669.43 -extern IDisplay *newOpenGLDisplay();
  669.44 -
  669.45 -extern Input *newDirectInput();
  669.46 -
  669.47 -extern void remoteStubSignal(int, int);
  669.48 -extern void remoteOutput(char *, u32);
  669.49 -extern void remoteStubMain();
  669.50 -extern void remoteSetProtocol(int);
  669.51 -extern void remoteCleanUp();
  669.52 -extern int remoteSocket;
  669.53 -
  669.54 -void winlog(const char *msg, ...);
  669.55 -
  669.56 -bool debugger = false;
  669.57 -
  669.58 -char movieFileToPlay[1024];
  669.59 -bool playMovieFile		   = false;
  669.60 -bool playMovieFileReadOnly = false;
  669.61 -char wavFileToOutput [1024];
  669.62 -bool outputWavFile	= false;
  669.63 -bool outputAVIFile	= false;
  669.64 -bool flagHideMenu	= false;
  669.65 -int	 quitAfterTime	= -1;
  669.66 -int	 pauseAfterTime = -1;
  669.67 -
  669.68 -void winSignal(int, int);
  669.69 -void winOutput(char *, u32);
  669.70 -
  669.71 -void (*dbgSignal)(int, int)	   = winSignal;
  669.72 -void (*dbgOutput)(char *, u32) = winOutput;
  669.73 -
  669.74 -#ifdef MMX
  669.75 -extern "C" bool cpu_mmx;
  669.76 -#endif
  669.77 -
  669.78 -// nowhere good to put them to
  669.79 -
  669.80 -void DrawTextMessages(u8 *dest, int pitch, int left, int bottom)
  669.81 -{
  669.82 -	for (int slot = 0; slot < SCREEN_MESSAGE_SLOTS; slot++)
  669.83 -	{
  669.84 -		if (theApp.screenMessage[slot])
  669.85 -		{
  669.86 -			if ((theApp.screenMessageDuration[slot] < 0 ||
  669.87 -			     (int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) &&
  669.88 -			    (!theApp.disableStatusMessage || slot == 1 || slot == 2))
  669.89 -			{
  669.90 -				drawText(dest,
  669.91 -				         pitch,
  669.92 -				         left,
  669.93 -				         bottom - 10 * (slot + 1),
  669.94 -				         theApp.screenMessageBuffer[slot],
  669.95 -				         theApp.screenMessageColorBuffer[slot]);
  669.96 -			}
  669.97 -			else
  669.98 -			{
  669.99 -				theApp.screenMessage[slot] = false;
 669.100 -			}
 669.101 -		}
 669.102 -	}
 669.103 -}
 669.104 -
 669.105 -// draw Lua graphics in game screen
 669.106 -void DrawLuaGui()
 669.107 -{
 669.108 -	int copyX		= 240, copyY       = 160;
 669.109 -	int screenX		= 240, screenY     = 160;
 669.110 -	int copyOffsetX = 0,   copyOffsetY = 0;
 669.111 -	if (systemCartridgeType == 1)
 669.112 -	{
 669.113 -		if (gbBorderOn)
 669.114 -		{
 669.115 -			copyX		= 256, copyY       = 224;
 669.116 -			screenX		= 256, screenY     = 224;
 669.117 -		}
 669.118 -		else
 669.119 -		{
 669.120 -			copyX = 160, copyY = 144;
 669.121 -			screenX = 160, screenY = 144;
 669.122 -		}
 669.123 -	}
 669.124 -	int pitch = copyX * (systemColorDepth / 8) + (systemColorDepth == 24 ? 0 : 4);
 669.125 -
 669.126 -	++copyOffsetY; // don't know why it's needed
 669.127 -
 669.128 -	VBALuaGui(&pix[copyOffsetY * pitch + copyOffsetX * (systemColorDepth / 8)], copyX, screenX, screenY);
 669.129 -	VBALuaClearGui();
 669.130 -}
 669.131 -
 669.132 -void directXMessage(const char *msg)
 669.133 -{
 669.134 -	systemMessage(
 669.135 -	    IDS_DIRECTX_7_REQUIRED,
 669.136 -	    "DirectX 7.0 or greater is required to run.\nDownload at http://www.microsoft.com/directx.\n\nError found at: %s",
 669.137 -	    msg);
 669.138 -}
 669.139 -
 669.140 -void winlog(const char *msg, ...)
 669.141 -{
 669.142 -	CString buffer;
 669.143 -	va_list valist;
 669.144 -
 669.145 -	va_start(valist, msg);
 669.146 -	buffer.FormatV(msg, valist);
 669.147 -
 669.148 -	FILE *winout = fopen("vba-trace.log", "w");
 669.149 -
 669.150 -	fputs(buffer, winout);
 669.151 -
 669.152 -	fclose(winout);
 669.153 -
 669.154 -	va_end(valist);
 669.155 -}
 669.156 -
 669.157 -// code from SDL_main.c for Windows
 669.158 -/* Parse a command line buffer into arguments */
 669.159 -
 669.160 -static int parseCommandLine(char *cmdline, char * *argv)
 669.161 -{
 669.162 -	char *bufp;
 669.163 -	int	  argc;
 669.164 -
 669.165 -	argc = 0;
 669.166 -	for (bufp = cmdline; *bufp; )
 669.167 -	{
 669.168 -		/* Skip leading whitespace */
 669.169 -		while (isspace(*bufp))
 669.170 -		{
 669.171 -			++bufp;
 669.172 -		}
 669.173 -		/* Skip over argument */
 669.174 -		if (*bufp == '"')
 669.175 -		{
 669.176 -			++bufp;
 669.177 -			if (*bufp)
 669.178 -			{
 669.179 -				if (argv)
 669.180 -				{
 669.181 -					argv[argc] = bufp;
 669.182 -				}
 669.183 -				++argc;
 669.184 -			}
 669.185 -			/* Skip over word */
 669.186 -			while (*bufp && (*bufp != '"'))
 669.187 -			{
 669.188 -				++bufp;
 669.189 -			}
 669.190 -		}
 669.191 -		else
 669.192 -		{
 669.193 -			if (*bufp)
 669.194 -			{
 669.195 -				if (argv)
 669.196 -				{
 669.197 -					argv[argc] = bufp;
 669.198 -				}
 669.199 -				++argc;
 669.200 -			}
 669.201 -			/* Skip over word */
 669.202 -			while (*bufp && !isspace(*bufp))
 669.203 -			{
 669.204 -				++bufp;
 669.205 -			}
 669.206 -		}
 669.207 -		if (*bufp)
 669.208 -		{
 669.209 -			if (argv)
 669.210 -			{
 669.211 -				*bufp = '\0';
 669.212 -			}
 669.213 -			++bufp;
 669.214 -		}
 669.215 -	}
 669.216 -	if (argv)
 669.217 -	{
 669.218 -		argv[argc] = NULL;
 669.219 -	}
 669.220 -	return(argc);
 669.221 -}
 669.222 -
 669.223 -static void debugSystemScreenMessage1(const char *msg)
 669.224 -{
 669.225 -	systemScreenMessage(msg, 3);
 669.226 -}
 669.227 -
 669.228 -static void debugSystemScreenMessage2(const char *msg)
 669.229 -{
 669.230 -	systemScreenMessage(msg, 4);
 669.231 -}
 669.232 -
 669.233 -static void winSignal(int, int)
 669.234 -{}
 669.235 -
 669.236 -#define CPUReadByteQuick(addr) \
 669.237 -    map[(addr) >> 24].address[(addr) & map[(addr) >> 24].mask]
 669.238 -
 669.239 -static void winOutput(char *s, u32 addr)
 669.240 -{
 669.241 -	if (s)
 669.242 -	{
 669.243 -		log(s);
 669.244 -	}
 669.245 -	else
 669.246 -	{
 669.247 -		CString str;
 669.248 -		char	c;
 669.249 -
 669.250 -		c = CPUReadByteQuick(addr);
 669.251 -		addr++;
 669.252 -		while (c)
 669.253 -		{
 669.254 -			str += c;
 669.255 -			c	 = CPUReadByteQuick(addr);
 669.256 -			addr++;
 669.257 -		}
 669.258 -		log(str);
 669.259 -	}
 669.260 -}
 669.261 -
 669.262 -typedef BOOL (WINAPI * GETMENUBARINFO)(HWND, LONG, LONG, PMENUBARINFO);
 669.263 -
 669.264 -static int winGetMenuBarHeight()
 669.265 -{
 669.266 -	HINSTANCE hinstDll = /**/ ::LoadLibrary("USER32.DLL");
 669.267 -
 669.268 -	if (hinstDll)
 669.269 -	{
 669.270 -		GETMENUBARINFO func = (GETMENUBARINFO)GetProcAddress(hinstDll, "GetMenuBarInfo");
 669.271 -
 669.272 -		if (func)
 669.273 -		{
 669.274 -			MENUBARINFO info;
 669.275 -			info.cbSize = sizeof(info);
 669.276 -
 669.277 -			func(AfxGetMainWnd()->GetSafeHwnd(), OBJID_MENU, 0, &info);
 669.278 -
 669.279 -			/**/ ::FreeLibrary(hinstDll);
 669.280 -
 669.281 -			return info.rcBar.bottom - info.rcBar.top + 1;
 669.282 -		}
 669.283 -	}
 669.284 -
 669.285 -	return GetSystemMetrics(SM_CYMENU);
 669.286 -}
 669.287 -
 669.288 -/////////////////////////////////////////////////////////////////////////////
 669.289 -// VBA
 669.290 -
 669.291 -BEGIN_MESSAGE_MAP(VBA, CWinApp)
 669.292 -//{{AFX_MSG_MAP(VBA)
 669.293 -// NOTE - the ClassWizard will add and remove mapping macros here.
 669.294 -//    DO NOT EDIT what you see in these blocks of generated code!
 669.295 -//}}AFX_MSG_MAP
 669.296 -END_MESSAGE_MAP()
 669.297 -
 669.298 -/////////////////////////////////////////////////////////////////////////////
 669.299 -// The one and only VBA object
 669.300 -
 669.301 -VBA theApp;
 669.302 -
 669.303 -/////////////////////////////////////////////////////////////////////////////
 669.304 -// VBA construction
 669.305 -
 669.306 -VBA::VBA() : emulator(::theEmulator)
 669.307 -{
 669.308 -	// important
 669.309 -	{
 669.310 -#ifdef MULTITHREAD_STDLOCALE_WORKAROUND
 669.311 -		// Note: there's a known threading bug regarding std::locale with MSVC according to
 669.312 -		// http://connect.microsoft.com/VisualStudio/feedback/details/492128/std-locale-constructor-modifies-global-locale-via-setlocale
 669.313 -		int iPreviousFlag = ::_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
 669.314 -#endif
 669.315 -		using std::locale;
 669.316 -		locale::global(locale(locale::classic(), "", locale::collate | locale::ctype));
 669.317 -
 669.318 -#ifdef MULTITHREAD_STDLOCALE_WORKAROUND
 669.319 -		if (iPreviousFlag > 0 )
 669.320 -			::_configthreadlocale(iPreviousFlag);
 669.321 -#endif
 669.322 -	}
 669.323 -
 669.324 -	mode320Available	 = false;
 669.325 -	mode640Available	 = false;
 669.326 -	mode800Available	 = false;
 669.327 -	windowPositionX		 = 0;
 669.328 -	windowPositionY		 = 0;
 669.329 -	filterFunction		 = NULL;
 669.330 -	ifbFunction			 = NULL;
 669.331 -	ifbType				 = 0;
 669.332 -	filterType			 = 0;
 669.333 -	filterWidth			 = 0;
 669.334 -	filterHeight		 = 0;
 669.335 -	fsWidth				 = 0;
 669.336 -	fsHeight			 = 0;
 669.337 -	fsColorDepth		 = 0;
 669.338 -	fsForceChange		 = false;
 669.339 -	surfaceSizeX		 = 0;
 669.340 -	surfaceSizeY		 = 0;
 669.341 -	sizeX				 = 0;
 669.342 -	sizeY				 = 0;
 669.343 -	videoOption			 = 0;
 669.344 -	fullScreenStretch	 = false;
 669.345 -	disableStatusMessage = false;
 669.346 -	showSpeed			 = 1;
 669.347 -	showSpeedTransparent = true;
 669.348 -	showRenderedFrames	 = 0;
 669.349 -	for (int j = 0; j < SCREEN_MESSAGE_SLOTS; j++)
 669.350 -	{
 669.351 -		screenMessage[j]		 = false;
 669.352 -		screenMessageTime[j]	 = 0;
 669.353 -		screenMessageDuration[j] = 0;
 669.354 -	}
 669.355 -	menuToggle		 = true;
 669.356 -	display			 = NULL;
 669.357 -	menu			 = NULL;
 669.358 -	popup			 = NULL;
 669.359 -	soundInitialized = false;
 669.360 -	useBiosFile		 = false;
 669.361 -	skipBiosFile	 = false;
 669.362 -	active			 = true;
 669.363 -	paused			 = false;
 669.364 -	recentFreeze	 = false;
 669.365 -	autoSaveLoadCheatList	  = false;
 669.366 -	pauseDuringCheatSearch	  = false;
 669.367 -	modelessCheatDialogIsOpen = false;
 669.368 -//	winout						= NULL;
 669.369 -//	removeIntros				= false;
 669.370 -	autoIPS = true;
 669.371 -	winGbBorderOn	  = 0;
 669.372 -	hideMovieBorder	  = false;
 669.373 -	winFlashSize	  = 0x10000;
 669.374 -	winRtcEnable	  = false;
 669.375 -	winSaveType		  = 0;
 669.376 -	rewindMemory	  = NULL;
 669.377 -	frameSearchMemory = NULL;
 669.378 -	rewindPos		  = 0;
 669.379 -	rewindTopPos	  = 0;
 669.380 -	rewindCounter	  = 0;
 669.381 -	rewindCount		  = 0;
 669.382 -	rewindSaveNeeded  = false;
 669.383 -	rewindTimer		  = 0;
 669.384 -	captureFormat	  = 0;
 669.385 -	tripleBuffering	  = true;
 669.386 -	autoHideMenu	  = false;
 669.387 -	throttle		  = 100;
 669.388 -	throttleLastTime  = 0;
 669.389 -///  autoFrameSkipLastTime		= 0;
 669.390 -///  autoFrameSkip				= false;
 669.391 -	vsync = false;
 669.392 -	changingVideoSize = false;
 669.393 -	pVideoDriverGUID  = NULL;
 669.394 -	renderMethod	  = DIRECT_DRAW;
 669.395 -	iconic = false;
 669.396 -	ddrawEmulationOnly		= false;
 669.397 -	ddrawUsingEmulationOnly = false;
 669.398 -	ddrawDebug				= false;
 669.399 -	ddrawUseVideoMemory		= false;
 669.400 -	d3dFilter				= 0;
 669.401 -	glFilter				= 0;
 669.402 -	glType					= 0;
 669.403 -	regEnabled				= false;
 669.404 -	pauseWhenInactive		= true;
 669.405 -	muteWhenInactive		= true;
 669.406 -	enableBackgroundInput	= false;
 669.407 -	alwaysOnTop				= false;
 669.408 -	filenamePreference		= true;
 669.409 -	frameCounter			= false;
 669.410 -	lagCounter				= false;
 669.411 -	extraCounter			= false;
 669.412 -	inputDisplay			= false;
 669.413 -	speedupToggle			= false;
 669.414 -	useOldSync				= false;
 669.415 -	allowLeftRight			= false;
 669.416 -	autofireAccountForLag	= false;
 669.417 -	nextframeAccountForLag	= false;
 669.418 -	muteFrameAdvance		= false;
 669.419 -	muteWhenInactive		= false;
 669.420 -	winMuteForNow		= false;
 669.421 -	winGbPrinterEnabled		= false;
 669.422 -	threadPriority			= 2;
 669.423 -	disableMMX				= false;
 669.424 -	languageOption			= 0;
 669.425 -	languageModule			= NULL;
 669.426 -	languageName			= "";
 669.427 -	renderedFrames			= 0;
 669.428 -	input					= NULL;
 669.429 -	joypadDefault			= 0;
 669.430 -	autoFire				= 0;
 669.431 -	autoFire2				= 0;
 669.432 -	autoHold				= 0;
 669.433 -	autoFireToggle			= false;
 669.434 -	winPauseNextFrame		= false;
 669.435 -	soundRecording			= false;
 669.436 -	soundRecorder			= NULL;
 669.437 -	sound					= NULL;
 669.438 -	aviRecording			= false;
 669.439 -	aviRecorder				= NULL;
 669.440 -	painting				= false;
 669.441 -	mouseCounter			= 0;
 669.442 -	movieReadOnly			= true;
 669.443 -	movieOnEndPause			= false;
 669.444 -	movieOnEndBehavior		= 0;
 669.445 -	wasPaused				= false;
 669.446 -	fsMaxScale				= 0;
 669.447 -	romSize					= 0;
 669.448 -	autoLoadMostRecent		= false;
 669.449 -	loadMakesRecent			= false;
 669.450 -	loadMakesCurrent		= false;
 669.451 -	saveMakesCurrent		= false;
 669.452 -	currentSlot				= 0;
 669.453 -	showSlotTime			= false;
 669.454 -	frameSearchLoadValid	= false;
 669.455 -	frameSearching			= false;
 669.456 -	frameSearchSkipping		= false;
 669.457 -	nvVideoLog				= false;
 669.458 -	nvAudioLog				= false;
 669.459 -	LoggingEnabled			= 0;
 669.460 -///  FPS = 60;
 669.461 -
 669.462 -	updateCount = 0;
 669.463 -
 669.464 -	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
 669.465 -
 669.466 -	ZeroMemory(&emulator, sizeof(emulator));
 669.467 -
 669.468 -	hAccel = NULL;
 669.469 -
 669.470 -	for (int i = 0; i < 24; )
 669.471 -	{
 669.472 -		systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
 669.473 -		systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
 669.474 -		systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
 669.475 -		systemGbPalette[i++] = 0;
 669.476 -	}
 669.477 -
 669.478 -	VBAMovieInit();
 669.479 -
 669.480 -	TIMECAPS tc;
 669.481 -	if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR)
 669.482 -	{
 669.483 -		wmTimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
 669.484 -		timeBeginPeriod(wmTimerRes);
 669.485 -	}
 669.486 -	else
 669.487 -	{
 669.488 -		wmTimerRes = 5;
 669.489 -		timeBeginPeriod(wmTimerRes);
 669.490 -	}
 669.491 -}
 669.492 -
 669.493 -VBA::~VBA()
 669.494 -{
 669.495 -	if (VBAMovieActive())
 669.496 -		VBAMovieStop(true);
 669.497 -
 669.498 -	saveSettings();
 669.499 -
 669.500 -	InterframeCleanup();
 669.501 -
 669.502 -	if (aviRecorder)
 669.503 -	{
 669.504 -		delete aviRecorder;
 669.505 -		aviRecorder	 = NULL;
 669.506 -		aviRecording = false;
 669.507 -	}
 669.508 -
 669.509 -	if (soundRecorder)
 669.510 -	{
 669.511 -		delete soundRecorder;
 669.512 -		soundRecorder = NULL;
 669.513 -	}
 669.514 -	soundRecording = false;
 669.515 -	soundPause();
 669.516 -	soundShutdown();
 669.517 -
 669.518 -	((MainWnd *)(m_pMainWnd))->winFileClose();
 669.519 -
 669.520 -	if (input)
 669.521 -		delete input;
 669.522 -
 669.523 -	shutdownDisplay();
 669.524 -
 669.525 -	if (rewindMemory)
 669.526 -		free(rewindMemory);
 669.527 -
 669.528 -	if (frameSearchMemory)
 669.529 -		free(frameSearchMemory);
 669.530 -
 669.531 -	timeEndPeriod(wmTimerRes);
 669.532 -}
 669.533 -
 669.534 -/////////////////////////////////////////////////////////////////////////////
 669.535 -// VBA initialization
 669.536 -
 669.537 -#include <afxdisp.h>
 669.538 -
 669.539 -BOOL VBA::InitInstance()
 669.540 -{
 669.541 -	AfxEnableControlContainer();
 669.542 -	// Standard initialization
 669.543 -	// If you are not using these features and wish to reduce the size
 669.544 -	//  of your final executable, you should remove from the following
 669.545 -	//  the specific initialization routines you do not need.
 669.546 -
 669.547 -//#ifdef _AFXDLL
 669.548 -//  Enable3dControls();      // Call this when using MFC in a shared DLL
 669.549 -//#else
 669.550 -//  Enable3dControlsStatic();  // Call this when linking to MFC statically
 669.551 -//#endif
 669.552 -
 669.553 -	SetRegistryKey(_T("VBA"));
 669.554 -
 669.555 -	remoteSetProtocol(0);
 669.556 -
 669.557 -	systemVerbose = GetPrivateProfileInt("config", "verbose", 0, "VBA.ini");
 669.558 -	systemDebug = GetPrivateProfileInt("config", "debug", 0, "VBA.ini");
 669.559 -	ddrawDebug = GetPrivateProfileInt("config", "ddrawDebug", 0, "VBA.ini") ? true : false;
 669.560 -
 669.561 -	wndClass = AfxRegisterWndClass(0, LoadCursor(IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), LoadIcon(IDI_ICON));
 669.562 -
 669.563 -	char winBuffer[2048];
 669.564 -	GetModuleFileName(NULL, winBuffer, 2048);
 669.565 -	char *p = strrchr(winBuffer, '\\');
 669.566 -	if (p)
 669.567 -		*p = 0;
 669.568 -	exeDir = winBuffer;
 669.569 -
 669.570 -	regInit(winBuffer);
 669.571 -
 669.572 -	loadSettings();
 669.573 -	theApp.LuaFastForward = -1;
 669.574 -	if (!initInput())
 669.575 -		return FALSE;
 669.576 -
 669.577 -	if (!initDisplay())
 669.578 -	{
 669.579 -		if (videoOption >= VIDEO_320x240)
 669.580 -		{
 669.581 -			regSetDwordValue("video", VIDEO_1X);
 669.582 -			if (pVideoDriverGUID)
 669.583 -				regSetDwordValue("defaultVideoDriver", TRUE);
 669.584 -		}
 669.585 -		return FALSE;
 669.586 -	}
 669.587 -
 669.588 -	hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR));
 669.589 -
 669.590 -	winAccelMgr.Connect((MainWnd *)m_pMainWnd);
 669.591 -
 669.592 -	extern void winAccelAddCommandsFromMenu(CAcceleratorManager & mgr, CMenu * pMenu, const CString &parentStr);
 669.593 -	extern void winAccelAddCommandsFromTable(CAcceleratorManager & mgr);
 669.594 -
 669.595 -	winAccelAddCommandsFromMenu(winAccelMgr, &m_menu, CString());
 669.596 -	winAccelAddCommandsFromTable(winAccelMgr);
 669.597 -
 669.598 -	winAccelMgr.CreateDefaultTable();
 669.599 -	winAccelMgr.Load();
 669.600 -	winAccelMgr.UpdateWndTable();
 669.601 -	winAccelMgr.UpdateMenu(menu);
 669.602 -
 669.603 -	if (m_lpCmdLine[0])
 669.604 -	{
 669.605 -		int		argc = parseCommandLine(m_lpCmdLine, NULL);
 669.606 -		char * *argv = (char * *)malloc((argc + 1) * sizeof(char *));
 669.607 -		parseCommandLine(m_lpCmdLine, argv);
 669.608 -
 669.609 -		bool gotFlag = false, enoughArgs = false;
 669.610 -		for (int i = 0; i < argc; i++)
 669.611 -		{
 669.612 -			if (argv[i][0] == '-' || gotFlag)
 669.613 -			{
 669.614 -				if (!gotFlag)
 669.615 -					loadSettings();
 669.616 -				gotFlag = true;
 669.617 -				if (_stricmp(argv[i], "-rom") == 0)
 669.618 -				{
 669.619 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.620 -						goto invalidArgument;
 669.621 -					romFilename = argv[++i];
 669.622 -					winCorrectPath(romFilename);
 669.623 -					gameFilename = romFilename;
 669.624 -				}
 669.625 -				else if (_stricmp(argv[i], "-bios") == 0)
 669.626 -				{
 669.627 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.628 -						goto invalidArgument;
 669.629 -					biosFileName = argv[++i];
 669.630 -					winCorrectPath(biosFileName);
 669.631 -
 669.632 -					//systemLoadBIOS();
 669.633 -				}
 669.634 -				else if (_stricmp(argv[i], "-frameskip") == 0)
 669.635 -				{
 669.636 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.637 -						goto invalidArgument;
 669.638 -					frameSkip = atoi(argv[++i]);
 669.639 -					if (frameSkip < 0)
 669.640 -						frameSkip = 0;
 669.641 -					if (frameSkip > 9)
 669.642 -						frameSkip = 9;
 669.643 -					gbFrameSkip = frameSkip;
 669.644 -				}
 669.645 -				else if (_stricmp(argv[i], "-throttle") == 0)
 669.646 -				{
 669.647 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.648 -						goto invalidArgument;
 669.649 -					throttle = atoi(argv[++i]);
 669.650 -					if (throttle < 5)
 669.651 -						throttle = 5;
 669.652 -					if (throttle > 1000)
 669.653 -						throttle = 1000;
 669.654 -				}
 669.655 -				else if (_stricmp(argv[i], "-throttleKeepPitch") == 0)
 669.656 -				{
 669.657 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.658 -						goto invalidArgument;
 669.659 -					accuratePitchThrottle = atoi(argv[++i]) != 0;
 669.660 -				}
 669.661 -				else if (_stricmp(argv[i], "-synchronize") == 0)
 669.662 -				{
 669.663 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.664 -						goto invalidArgument;
 669.665 -					synchronize = atoi(argv[++i]) != 0;
 669.666 -				}
 669.667 -				else if (_stricmp(argv[i], "-hideborder") == 0)
 669.668 -				{
 669.669 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.670 -						goto invalidArgument;
 669.671 -					hideMovieBorder = atoi(argv[++i]) != 0;
 669.672 -				}
 669.673 -				else if (_stricmp(argv[i], "-play") == 0)
 669.674 -				{
 669.675 -					playMovieFile = true;
 669.676 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.677 -						goto invalidArgument;
 669.678 -					strcpy(movieFileToPlay, argv[++i]);
 669.679 -					winCorrectPath(movieFileToPlay);
 669.680 -					if (i + 1 >= argc || argv[i + 1][0] == '-') { --i; goto invalidArgument; }
 669.681 -					playMovieFileReadOnly = atoi(argv[++i]) != 0;
 669.682 -				}
 669.683 -				else if (_stricmp(argv[i], "-videoLog") == 0)
 669.684 -				{
 669.685 -					nvVideoLog	   = true;
 669.686 -					nvAudioLog	   = true;
 669.687 -					LoggingEnabled = 2;
 669.688 -					if (i + 1 >= argc || argv[i + 1][0] == '-') {}
 669.689 -					else
 669.690 -						NESVideoSetVideoCmd(argv[++i]);
 669.691 -				}
 669.692 -				else if (_stricmp(argv[i], "-logDebug") == 0)
 669.693 -				{
 669.694 -					NESVideoEnableDebugging(debugSystemScreenMessage1, debugSystemScreenMessage2);
 669.695 -				}
 669.696 -				else if (_stricmp(argv[i], "-logToFile") == 0)
 669.697 -				{
 669.698 -					NESVideoSetFileFuncs(fopen, fclose);
 669.699 -				}
 669.700 -				else if (_stricmp(argv[i], "-outputWAV") == 0)
 669.701 -				{
 669.702 -					outputWavFile = true;
 669.703 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.704 -						goto invalidArgument;
 669.705 -					strcpy(wavFileToOutput, argv[++i]);
 669.706 -				}
 669.707 -				else if (_stricmp(argv[i], "-outputAVI") == 0)
 669.708 -				{
 669.709 -					outputAVIFile = true;
 669.710 -				}
 669.711 -				else if (_stricmp(argv[i], "-quitAfter") == 0)
 669.712 -				{
 669.713 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.714 -						goto invalidArgument;
 669.715 -					quitAfterTime = atoi(argv[++i]);
 669.716 -				}
 669.717 -				else if (_stricmp(argv[i], "-pauseAt") == 0)
 669.718 -				{
 669.719 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.720 -						goto invalidArgument;
 669.721 -					pauseAfterTime = atoi(argv[++i]);
 669.722 -				}
 669.723 -				else if (_stricmp(argv[i], "-videoScale") == 0)
 669.724 -				{
 669.725 -					if (i + 1 >= argc || argv[i + 1][0] == '-')
 669.726 -						goto invalidArgument;
 669.727 -					int size = atoi(argv[++i]);
 669.728 -					if (size < 1)
 669.729 -						size = 1;
 669.730 -					if (size > 4)
 669.731 -						size = 4;
 669.732 -					switch (size)
 669.733 -					{
 669.734 -					case 1:
 669.735 -						videoOption = VIDEO_1X; break;
 669.736 -					case 2:
 669.737 -						videoOption = VIDEO_2X; break;
 669.738 -					case 3:
 669.739 -						videoOption = VIDEO_3X; break;
 669.740 -					case 4:
 669.741 -						videoOption = VIDEO_4X; break;
 669.742 -					}
 669.743 -				}
 669.744 -				else if (_stricmp(argv[i], "-hideMenu") == 0)
 669.745 -				{
 669.746 -					flagHideMenu = true;
 669.747 -				}
 669.748 -				else
 669.749 -				{
 669.750 -					enoughArgs = true;
 669.751 -invalidArgument:
 669.752 -					char str [2048];    // the string is larger than 1024 bytes
 669.753 -					strcpy(str, "");
 669.754 -					if (_stricmp(argv[i], "-h") != 0)
 669.755 -						if (enoughArgs)
 669.756 -							sprintf(str, "Invalid commandline argument %d: %s\n", i, argv[i]);
 669.757 -						else
 669.758 -							sprintf(str, "Not enough arguments for arg %d: %s\n", i, argv[i]);
 669.759 -					strcat(str, "Valid commands:\n"
 669.760 -					            "-h \t\t\t displays this help\n"
 669.761 -					            "-rom filename \t\t opens the given ROM\n"
 669.762 -					            "-bios filename \t\t use the given GBA BIOS\n"
 669.763 -					            "-play filename val \t\t plays the given VBM movie (val: 1 = read-only, 0 = editable)\n"
 669.764 -					            "-outputWAV filename \t outputs WAV audio to the given file\n"
 669.765 -					            "-outputAVI \t\t outputs an AVI (you are prompted for location and codec)\n"
 669.766 -					            "-frameskip val \t\t sets the frameskip amount to the given value\n"
 669.767 -					            "-synchronize val \t\t limits running speed to sound playing speed, (0 = off, 1 = on)\n"
 669.768 -					            "-throttle val \t\t sets the throttle speed to the given percentage\n"
 669.769 -					            "-hideborder val \t\t hides SGB border, if any (0 = show, 1 = hide)\n"
 669.770 -					            "-throttleKeepPitch val \t if throttle and synch, don't change sound freq (0 = off, 1 = on)\n"
 669.771 -					            "-quitAfter val \t\t close program when frame counter == val\n"
 669.772 -					            "-pauseAt val \t\t pause (movie) once when frame counter == val\n"
 669.773 -					            "-videoScale val \t\t sets the video size (val = 1 for 1X, 2 for 2X, 3 for 3X, or 4 for 4X)\n"
 669.774 -					            "-hideMenu \t\t hides the menu until program exit\n"
 669.775 -					            "\n"
 669.776 -					            "-videoLog args \t does (nesvideos) video+audio logging with the given arguments\n"
 669.777 -					            "-logToFile \t tells logging to use fopen/fclose of args, if logging is enabled\n"
 669.778 -					            "-logDebug  \t tells logging to output debug info to screen, if logging is enabled\n"
 669.779 -					       );
 669.780 -					theApp.winCheckFullscreen();
 669.781 -					AfxGetApp()->m_pMainWnd->MessageBox(str, "Commandline Help", MB_OK | MB_ICONINFORMATION);
 669.782 -					exit(0);
 669.783 -				}
 669.784 -			}
 669.785 -			else
 669.786 -			{
 669.787 -				// assume anything else is a ROM, for backward compatibility
 669.788 -				romFilename	 = argv[i++];
 669.789 -				gameFilename = romFilename;
 669.790 -				loadSettings();
 669.791 -			}
 669.792 -		}
 669.793 -
 669.794 -/*
 669.795 -        int index = filename.ReverseFind('.');
 669.796 -
 669.797 -        if (index != -1)
 669.798 -            filename = filename.Left(index);
 669.799 - */
 669.800 -		if (romFilename.GetLength() > 0)
 669.801 -		{
 669.802 -			((MainWnd *)theApp.m_pMainWnd)->winFileRun();
 669.803 -		}
 669.804 -		free(argv);
 669.805 -	}
 669.806 -
 669.807 -	return TRUE;
 669.808 -}
 669.809 -
 669.810 -void VBA::adjustDestRect()
 669.811 -{
 669.812 -	POINT point;
 669.813 -
 669.814 -	point.x = 0;
 669.815 -	point.y = 0;
 669.816 -
 669.817 -	m_pMainWnd->ClientToScreen(&point);
 669.818 -	dest.top  = point.y;
 669.819 -	dest.left = point.x;
 669.820 -
 669.821 -	point.x = surfaceSizeX;
 669.822 -	point.y = surfaceSizeY;
 669.823 -
 669.824 -	m_pMainWnd->ClientToScreen(&point);
 669.825 -	dest.bottom = point.y;
 669.826 -	dest.right	= point.x;
 669.827 -
 669.828 -	if (videoOption > VIDEO_4X)
 669.829 -	{
 669.830 -		int menuSkip = 0;
 669.831 -		if (menuToggle)
 669.832 -		{
 669.833 -			menuSkip = winGetMenuBarHeight();
 669.834 -		}
 669.835 -
 669.836 -		if (fullScreenStretch)
 669.837 -		{
 669.838 -			dest.top	= menuSkip;
 669.839 -			dest.left	= 0;
 669.840 -			dest.right	= fsWidth;
 669.841 -			dest.bottom = fsHeight;
 669.842 -		}
 669.843 -		else
 669.844 -		{
 669.845 -			int top	 = (fsHeight - surfaceSizeY) / 2;
 669.846 -			int left = (fsWidth - surfaceSizeX) / 2;
 669.847 -			dest.top	+= top - menuSkip * 2;
 669.848 -			dest.bottom += top;
 669.849 -			dest.left	+= left;
 669.850 -			dest.right	+= left;
 669.851 -		}
 669.852 -	}
 669.853 -}
 669.854 -
 669.855 -void VBA::updateIFB()
 669.856 -{
 669.857 -	if (systemColorDepth == 16)
 669.858 -	{
 669.859 -		switch (ifbType)
 669.860 -		{
 669.861 -		case 0:
 669.862 -		default:
 669.863 -			ifbFunction = NULL;
 669.864 -			break;
 669.865 -		case 1:
 669.866 -			ifbFunction = MotionBlurIB;
 669.867 -			break;
 669.868 -		case 2:
 669.869 -			ifbFunction = SmartIB;
 669.870 -			break;
 669.871 -		}
 669.872 -	}
 669.873 -	else if (systemColorDepth == 32)
 669.874 -	{
 669.875 -		switch (ifbType)
 669.876 -		{
 669.877 -		case 0:
 669.878 -		default:
 669.879 -			ifbFunction = NULL;
 669.880 -			break;
 669.881 -		case 1:
 669.882 -			ifbFunction = MotionBlurIB32;
 669.883 -			break;
 669.884 -		case 2:
 669.885 -			ifbFunction = SmartIB32;
 669.886 -			break;
 669.887 -		}
 669.888 -	}
 669.889 -	else
 669.890 -		ifbFunction = NULL;
 669.891 -}
 669.892 -
 669.893 -void VBA::updateFilter()
 669.894 -{
 669.895 -	filterWidth	 = sizeX;
 669.896 -	filterHeight = sizeY;
 669.897 -
 669.898 -	if (systemColorDepth == 16 && (videoOption > VIDEO_1X &&
 669.899 -	                               videoOption != VIDEO_320x240))
 669.900 -	{
 669.901 -		switch (filterType)
 669.902 -		{
 669.903 -		default:
 669.904 -		case 0:
 669.905 -			filterFunction = NULL;
 669.906 -			break;
 669.907 -		case 1:
 669.908 -			filterFunction = ScanlinesTV;
 669.909 -			break;
 669.910 -		case 2:
 669.911 -			filterFunction = _2xSaI;
 669.912 -			break;
 669.913 -		case 3:
 669.914 -			filterFunction = Super2xSaI;
 669.915 -			break;
 669.916 -		case 4:
 669.917 -			filterFunction = SuperEagle;
 669.918 -			break;
 669.919 -		case 5:
 669.920 -			filterFunction = Pixelate2x16;
 669.921 -			break;
 669.922 -		case 6:
 669.923 -			filterFunction = MotionBlur;
 669.924 -			break;
 669.925 -		case 7:
 669.926 -			filterFunction = AdMame2x;
 669.927 -			break;
 669.928 -		case 8:
 669.929 -			filterFunction = Simple2x16;
 669.930 -			break;
 669.931 -		case 9:
 669.932 -			filterFunction = Bilinear;
 669.933 -			break;
 669.934 -		case 10:
 669.935 -			filterFunction = BilinearPlus;
 669.936 -			break;
 669.937 -		case 11:
 669.938 -			filterFunction = Scanlines;
 669.939 -			break;
 669.940 -		case 12:
 669.941 -			filterFunction = hq2xS;
 669.942 -			break;
 669.943 -		case 13:
 669.944 -			filterFunction = hq2x;
 669.945 -			break;
 669.946 -		case 14:
 669.947 -			filterFunction = lq2x;
 669.948 -			break;
 669.949 -		case 15:
 669.950 -			filterFunction = hq3xS;
 669.951 -			break;
 669.952 -		case 16:
 669.953 -			filterFunction = hq3x;
 669.954 -			break;
 669.955 -		case 17:
 669.956 -			filterFunction = Simple3x16;
 669.957 -			break;
 669.958 -		case 18:
 669.959 -			filterFunction = Simple4x16;
 669.960 -			break;
 669.961 -		case 19:
 669.962 -			filterFunction = Pixelate3x16;
 669.963 -			break;
 669.964 -		case 20:
 669.965 -			filterFunction = Pixelate4x16;
 669.966 -			break;
 669.967 -		}
 669.968 -		switch (filterType)
 669.969 -		{
 669.970 -		case 0: // normal -> 1x texture
 669.971 -			rect.right	= sizeX;
 669.972 -			rect.bottom = sizeY;
 669.973 -			break;
 669.974 -		default: // other -> 2x texture
 669.975 -			rect.right	= sizeX * 2;
 669.976 -			rect.bottom = sizeY * 2;
 669.977 -			memset(delta, 255, sizeof(delta));
 669.978 -			break;
 669.979 -		case 15: // hq3x -> 3x texture
 669.980 -		case 16:
 669.981 -		case 17:
 669.982 -		case 19:
 669.983 -			rect.right	= sizeX * 3;
 669.984 -			rect.bottom = sizeY * 3;
 669.985 -			memset(delta, 255, sizeof(delta));
 669.986 -			break;
 669.987 -		case 18: // Simple4x -> 4x texture
 669.988 -		case 20:
 669.989 -			rect.right	= sizeX * 4;
 669.990 -			rect.bottom = sizeY * 4;
 669.991 -			memset(delta, 255, sizeof(delta));
 669.992 -			break;
 669.993 -		}
 669.994 -	}
 669.995 -	else
 669.996 -	{
 669.997 -		if (systemColorDepth == 32 && videoOption > VIDEO_1X &&
 669.998 -		    videoOption != VIDEO_320x240)
 669.999 -		{
669.1000 -			switch (filterType)
669.1001 -			{
669.1002 -			default:
669.1003 -			case 0:
669.1004 -				filterFunction = NULL;
669.1005 -				break;
669.1006 -			case 1:
669.1007 -				filterFunction = ScanlinesTV32;
669.1008 -				break;
669.1009 -			case 2:
669.1010 -				filterFunction = _2xSaI32;
669.1011 -				break;
669.1012 -			case 3:
669.1013 -				filterFunction = Super2xSaI32;
669.1014 -				break;
669.1015 -			case 4:
669.1016 -				filterFunction = SuperEagle32;
669.1017 -				break;
669.1018 -			case 5:
669.1019 -				filterFunction = Pixelate2x32;
669.1020 -				break;
669.1021 -			case 6:
669.1022 -				filterFunction = MotionBlur32;
669.1023 -				break;
669.1024 -			case 7:
669.1025 -				filterFunction = AdMame2x32;
669.1026 -				break;
669.1027 -			case 8:
669.1028 -				filterFunction = Simple2x32;
669.1029 -				break;
669.1030 -			case 9:
669.1031 -				filterFunction = Bilinear32;
669.1032 -				break;
669.1033 -			case 10:
669.1034 -				filterFunction = BilinearPlus32;
669.1035 -				break;
669.1036 -			case 11:
669.1037 -				filterFunction = Scanlines32;
669.1038 -				break;
669.1039 -			case 12:
669.1040 -				filterFunction = hq2xS32;
669.1041 -				break;
669.1042 -			case 13:
669.1043 -				filterFunction = hq2x32;
669.1044 -				break;
669.1045 -			case 14:
669.1046 -				filterFunction = lq2x32;
669.1047 -				break;
669.1048 -			case 15:
669.1049 -				filterFunction = hq3xS32;
669.1050 -				break;
669.1051 -			case 16:
669.1052 -				filterFunction = hq3x32;
669.1053 -				break;
669.1054 -			case 17:
669.1055 -				filterFunction = Simple3x32;
669.1056 -				break;
669.1057 -			case 18:
669.1058 -				filterFunction = Simple4x32;
669.1059 -				break;
669.1060 -			case 19:
669.1061 -				filterFunction = Pixelate3x32;
669.1062 -				break;
669.1063 -			case 20:
669.1064 -				filterFunction = Pixelate4x32;
669.1065 -				break;
669.1066 -			}
669.1067 -			switch (filterType)
669.1068 -			{
669.1069 -			case 0: // normal -> 1x texture
669.1070 -				rect.right	= sizeX;
669.1071 -				rect.bottom = sizeY;
669.1072 -				break;
669.1073 -			default: // other -> 2x texture
669.1074 -				rect.right	= sizeX * 2;
669.1075 -				rect.bottom = sizeY * 2;
669.1076 -				memset(delta, 255, sizeof(delta));
669.1077 -				break;
669.1078 -			case 15: // hq3x -> 3x texture
669.1079 -			case 16:
669.1080 -			case 17:
669.1081 -			case 19:
669.1082 -				rect.right	= sizeX * 3;
669.1083 -				rect.bottom = sizeY * 3;
669.1084 -				memset(delta, 255, sizeof(delta));
669.1085 -				break;
669.1086 -			case 18: // Simple4x -> 4x texture
669.1087 -			case 20:
669.1088 -				rect.right	= sizeX * 4;
669.1089 -				rect.bottom = sizeY * 4;
669.1090 -				memset(delta, 255, sizeof(delta));
669.1091 -				break;
669.1092 -			}
669.1093 -		}
669.1094 -		else
669.1095 -			filterFunction = NULL;
669.1096 -	}
669.1097 -
669.1098 -	if (display)
669.1099 -		display->changeRenderSize(rect.right, rect.bottom);
669.1100 -}
669.1101 -
669.1102 -void VBA::recreateMenuBar()
669.1103 -{
669.1104 -	m_menu.Detach();
669.1105 -	m_menu.Attach(winResLoadMenu(MAKEINTRESOURCE(IDR_MENU)));
669.1106 -
669.1107 -	if (m_pMainWnd && menuToggle)   // assuming that whether the menu has been set is always kept tracked
669.1108 -	{
669.1109 -		m_pMainWnd->SetMenu(&m_menu);
669.1110 -	}
669.1111 -
669.1112 -	if (menu != NULL)
669.1113 -	{
669.1114 -		DestroyMenu(menu);
669.1115 -	}
669.1116 -
669.1117 -	menu = m_menu.GetSafeHmenu();
669.1118 -}
669.1119 -
669.1120 -void VBA::updateMenuBar()
669.1121 -{
669.1122 -	if (flagHideMenu)
669.1123 -		return;
669.1124 -
669.1125 -	recreateMenuBar();
669.1126 -
669.1127 -	if (popup != NULL)
669.1128 -	{
669.1129 -		// force popup recreation if language changed
669.1130 -		DestroyMenu(popup);
669.1131 -		popup = NULL;
669.1132 -	}
669.1133 -}
669.1134 -
669.1135 -void VBA::saveRewindStateIfNecessary()
669.1136 -{
669.1137 -	if (rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState)
669.1138 -	{
669.1139 -		rewindCount++;
669.1140 -		if (rewindCount > rewindSlots)
669.1141 -			rewindCount = rewindSlots;
669.1142 -		assert(rewindPos >= 0 && rewindPos < rewindSlots);
669.1143 -		if (emulator.emuWriteMemState(&rewindMemory[rewindPos * REWIND_SIZE], REWIND_SIZE))
669.1144 -		{
669.1145 -			rewindPos = ++rewindPos % rewindSlots;
669.1146 -			assert(rewindPos >= 0 && rewindPos < rewindSlots);
669.1147 -			if (rewindCount == rewindSlots)
669.1148 -				rewindTopPos = ++rewindTopPos % rewindSlots;
669.1149 -		}
669.1150 -	}
669.1151 -
669.1152 -	// also update/cache some frame search stuff
669.1153 -	if (frameSearching)
669.1154 -	{
669.1155 -		extern SMovie Movie;
669.1156 -		int curFrame = (Movie.state == MOVIE_STATE_NONE) ? systemCounters.frameCount : Movie.currentFrame;
669.1157 -		int endFrame = theApp.frameSearchStart + theApp.frameSearchLength;
669.1158 -		frameSearchSkipping	 = (curFrame < endFrame);
669.1159 -		frameSearchFirstStep = false;
669.1160 -
669.1161 -		if (curFrame == endFrame)
669.1162 -		{
669.1163 -			// cache intermediate state to speed up searching forward
669.1164 -			emulator.emuWriteMemState(&frameSearchMemory[REWIND_SIZE * 1], REWIND_SIZE);
669.1165 -		}
669.1166 -
669.1167 -		if (curFrame == endFrame + 1)
669.1168 -		{
669.1169 -			emulator.emuWriteMemState(&frameSearchMemory[REWIND_SIZE * 2], REWIND_SIZE);
669.1170 -			frameSearchLoadValid = true;
669.1171 -		}
669.1172 -	}
669.1173 -	else
669.1174 -	{
669.1175 -		frameSearchFirstStep = false;
669.1176 -
669.1177 -		assert(!frameSearchSkipping);
669.1178 -		// just in case
669.1179 -		frameSearchSkipping = false;
669.1180 -	}
669.1181 -}
669.1182 -
669.1183 -BOOL VBA::OnIdle(LONG lCount)
669.1184 -{
669.1185 -	if (emulating && debugger)
669.1186 -	{
669.1187 -		MSG msg;
669.1188 -		remoteStubMain();
669.1189 -		if (debugger)
669.1190 -			return TRUE;  // continue loop
669.1191 -		return !::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE);
669.1192 -	}
669.1193 -	else if (emulating && active && !paused)
669.1194 -	{
669.1195 -///    for(int i = 0; i < 2; i++)
669.1196 -		{
669.1197 -			emulator.emuMain(emulator.emuCount);
669.1198 -
669.1199 -			// save the state for rewinding, if necessary
669.1200 -			saveRewindStateIfNecessary();
669.1201 -
669.1202 -			rewindSaveNeeded = false;
669.1203 -		}
669.1204 -
669.1205 -		if (mouseCounter)
669.1206 -		{
669.1207 -			if (--mouseCounter == 0)
669.1208 -			{
669.1209 -				SetCursor(NULL);
669.1210 -			}
669.1211 -		}
669.1212 -		return TRUE;
669.1213 -	}
669.1214 -	else if (emulating) // this fixes display if resetting while paused
669.1215 -	{
669.1216 -//		VBAUpdateButtonPressDisplay();
669.1217 -		VBAUpdateFrameCountDisplay();
669.1218 -		systemRefreshScreen();
669.1219 -	}
669.1220 -
669.1221 -	return FALSE;
669.1222 -
669.1223 -	//  return CWinApp::OnIdle(lCount);
669.1224 -}
669.1225 -
669.1226 -void VBA::addRecentFile(const CString &file)
669.1227 -{
669.1228 -	// Do not change recent list if frozen
669.1229 -	if (recentFreeze)
669.1230 -		return;
669.1231 -	int i = 0;
669.1232 -	for (i = 0; i < 10; ++i)
669.1233 -	{
669.1234 -		if (recentFiles[i].GetLength() == 0)
669.1235 -			break;
669.1236 -
669.1237 -		if (recentFiles[i].Compare(file) == 0)
669.1238 -		{
669.1239 -			if (i == 0)
669.1240 -				return;
669.1241 -			CString p = recentFiles[i];
669.1242 -			for (int j = i; j > 0; --j)
669.1243 -			{
669.1244 -				recentFiles[j] = recentFiles[j - 1];
669.1245 -			}
669.1246 -			recentFiles[0] = p;
669.1247 -			return;
669.1248 -		}
669.1249 -	}
669.1250 -	int num = 0;
669.1251 -	for (i = 0; i < 10; ++i)
669.1252 -	{
669.1253 -		if (recentFiles[i].GetLength() != 0)
669.1254 -			++num;
669.1255 -	}
669.1256 -	if (num == 10)
669.1257 -	{
669.1258 -		--num;
669.1259 -	}
669.1260 -
669.1261 -	for (i = num; i >= 1; --i)
669.1262 -	{
669.1263 -		recentFiles[i] = recentFiles[i - 1];
669.1264 -	}
669.1265 -	recentFiles[0] = file;
669.1266 -}
669.1267 -
669.1268 -void VBA::updateFrameSkip()
669.1269 -{
669.1270 -	switch (systemCartridgeType)
669.1271 -	{
669.1272 -	case 0:
669.1273 -		systemFrameSkip = frameSkip;
669.1274 -		break;
669.1275 -	case 1:
669.1276 -		systemFrameSkip = gbFrameSkip;
669.1277 -		break;
669.1278 -	}
669.1279 -}
669.1280 -
669.1281 -void VBA::updateVideoSize(UINT id)
669.1282 -{
669.1283 -	int	 value		 = 0;
669.1284 -	bool forceUpdate = false;
669.1285 -
669.1286 -	switch (id)
669.1287 -	{
669.1288 -	case ID_OPTIONS_VIDEO_X1:
669.1289 -		value		= VIDEO_1X;
669.1290 -		forceUpdate = true;
669.1291 -		break;
669.1292 -	case ID_OPTIONS_VIDEO_X2:
669.1293 -		value		= VIDEO_2X;
669.1294 -		forceUpdate = true;
669.1295 -		break;
669.1296 -	case ID_OPTIONS_VIDEO_X3:
669.1297 -		value		= VIDEO_3X;
669.1298 -		forceUpdate = true;
669.1299 -		break;
669.1300 -	case ID_OPTIONS_VIDEO_X4:
669.1301 -		value		= VIDEO_4X;
669.1302 -		forceUpdate = true;
669.1303 -		break;
669.1304 -	case ID_OPTIONS_VIDEO_FULLSCREEN320X240:
669.1305 -		value		 = VIDEO_320x240;
669.1306 -		fsWidth		 = 320;
669.1307 -		fsHeight	 = 240;
669.1308 -		fsColorDepth = 16;
669.1309 -		break;
669.1310 -	case ID_OPTIONS_VIDEO_FULLSCREEN640X480:
669.1311 -		value		 = VIDEO_640x480;
669.1312 -		fsWidth		 = 640;
669.1313 -		fsHeight	 = 480;
669.1314 -		fsColorDepth = 16;
669.1315 -		break;
669.1316 -	case ID_OPTIONS_VIDEO_FULLSCREEN800X600:
669.1317 -		value		 = VIDEO_800x600;
669.1318 -		fsWidth		 = 800;
669.1319 -		fsHeight	 = 600;
669.1320 -		fsColorDepth = 16;
669.1321 -		break;
669.1322 -	case ID_OPTIONS_VIDEO_FULLSCREEN:
669.1323 -		value		= VIDEO_OTHER;
669.1324 -		forceUpdate = true;
669.1325 -		break;
669.1326 -	}
669.1327 -
669.1328 -	if (videoOption != value || forceUpdate)
669.1329 -		updateWindowSize(value);
669.1330 -}
669.1331 -
669.1332 -void VBA::updateWindowSize(int value)
669.1333 -{
669.1334 -	regSetDwordValue("video", value);
669.1335 -
669.1336 -	if (value == VIDEO_OTHER)
669.1337 -	{
669.1338 -		regSetDwordValue("fsWidth", fsWidth);
669.1339 -		regSetDwordValue("fsHeight", fsHeight);
669.1340 -		regSetDwordValue("fsColorDepth", fsColorDepth);
669.1341 -	}
669.1342 -
669.1343 -	if (display &&
669.1344 -	    (((value >= VIDEO_320x240 || videoOption >= VIDEO_320x240) && videoOption != value) ||
669.1345 -	     fsForceChange))
669.1346 -	{
669.1347 -		fsForceChange = false;
669.1348 -		videoOption	  = value;
669.1349 -		initDisplay();
669.1350 -	}
669.1351 -
669.1352 -	videoOption = value;
669.1353 -
669.1354 -	if (systemCartridgeType == 1)
669.1355 -	{
669.1356 -		if (gbBorderOn)
669.1357 -		{
669.1358 -			sizeX = 256;
669.1359 -			sizeY = 224;
669.1360 -			gbBorderLineSkip   = 256;
669.1361 -			gbBorderColumnSkip = 48;
669.1362 -			gbBorderRowSkip	   = 40;
669.1363 -		}
669.1364 -		else
669.1365 -		{
669.1366 -			sizeX = 160;
669.1367 -			sizeY = 144;
669.1368 -			gbBorderLineSkip   = 160;
669.1369 -			gbBorderColumnSkip = 0;
669.1370 -			gbBorderRowSkip	   = 0;
669.1371 -		}
669.1372 -	}
669.1373 -	else
669.1374 -	{
669.1375 -		sizeX = 240;
669.1376 -		sizeY = 160;
669.1377 -	}
669.1378 -
669.1379 -	switch (videoOption)
669.1380 -	{
669.1381 -	case VIDEO_1X:
669.1382 -		surfaceSizeX = sizeX;
669.1383 -		surfaceSizeY = sizeY;
669.1384 -		break;
669.1385 -	case VIDEO_2X:
669.1386 -		surfaceSizeX = sizeX * 2;
669.1387 -		surfaceSizeY = sizeY * 2;
669.1388 -		break;
669.1389 -	case VIDEO_3X:
669.1390 -		surfaceSizeX = sizeX * 3;
669.1391 -		surfaceSizeY = sizeY * 3;
669.1392 -		break;
669.1393 -	case VIDEO_4X:
669.1394 -		surfaceSizeX = sizeX * 4;
669.1395 -		surfaceSizeY = sizeY * 4;
669.1396 -		break;
669.1397 -	case VIDEO_320x240:
669.1398 -	case VIDEO_640x480:
669.1399 -	case VIDEO_800x600:
669.1400 -	case VIDEO_OTHER:
669.1401 -		// Need to fix this code later. For now, Fullscreen takes the whole screen.
669.1402 -		if (fullScreenStretch)
669.1403 -		{
669.1404 -			surfaceSizeX = fsWidth;
669.1405 -			surfaceSizeY = fsHeight;
669.1406 -		}
669.1407 -		else
669.1408 -		{
669.1409 -			double scaleX	= (double)fsWidth / (double)sizeX;
669.1410 -			double scaleY	= (double)fsHeight / (double)sizeY;
669.1411 -			double scaleMin = scaleX < scaleY ? scaleX : scaleY;
669.1412 -			if (fsMaxScale)
669.1413 -				scaleMin = scaleMin > fsMaxScale ? fsMaxScale : scaleMin;
669.1414 -			surfaceSizeX = (int)(scaleMin * sizeX);
669.1415 -			surfaceSizeY = (int)(scaleMin * sizeY);
669.1416 -		}
669.1417 -		break;
669.1418 -	}
669.1419 -
669.1420 -	rect.left	= 0;
669.1421 -	rect.top	= 0;
669.1422 -	rect.right	= sizeX;
669.1423 -	rect.bottom = sizeY;
669.1424 -
669.1425 -	int winSizeX = 0;
669.1426 -	int winSizeY = 0;
669.1427 -	int x		 = 0;
669.1428 -	int y		 = 0;
669.1429 -
669.1430 -	DWORD style	  = WS_POPUP | WS_VISIBLE;
669.1431 -	DWORD styleEx = alwaysOnTop ? WS_EX_TOPMOST : 0;
669.1432 -
669.1433 -	if (videoOption <= VIDEO_4X)
669.1434 -	{
669.1435 -		style |= WS_OVERLAPPEDWINDOW;
669.1436 -
669.1437 -		dest.left	= 0;
669.1438 -		dest.top	= 0;
669.1439 -		dest.right	= surfaceSizeX;
669.1440 -		dest.bottom = surfaceSizeY;
669.1441 -
669.1442 -		x = windowPositionX;
669.1443 -		y = windowPositionY;
669.1444 -	}
669.1445 -	else
669.1446 -	{
669.1447 -		dest.left	= 0;
669.1448 -		dest.top	= 0;
669.1449 -		dest.right	= fsWidth;
669.1450 -		dest.bottom = fsHeight;
669.1451 -	}
669.1452 -
669.1453 -	AdjustWindowRectEx(&dest, style, flagHideMenu ? FALSE : TRUE, styleEx);
669.1454 -	winSizeX = dest.right  - dest.left;
669.1455 -	winSizeY = dest.bottom - dest.top;
669.1456 -
669.1457 -	if (m_pMainWnd == NULL)
669.1458 -	{
669.1459 -		// Create a new window
669.1460 -		m_pMainWnd = new MainWnd;
669.1461 -		m_pMainWnd->CreateEx(styleEx,
669.1462 -		                     theApp.wndClass,
669.1463 -		                     VBA_NAME_AND_VERSION,
669.1464 -		                     style,
669.1465 -		                     x, y, winSizeX, winSizeY,
669.1466 -		                     NULL,
669.1467 -		                     0);
669.1468 -
669.1469 -		if (!(HWND)*m_pMainWnd)
669.1470 -		{
669.1471 -			winlog("Error creating Window %08x\n", GetLastError());
669.1472 -			AfxPostQuitMessage(0);
669.1473 -			return;
669.1474 -		}
669.1475 -	}
669.1476 -	else
669.1477 -	{
669.1478 -		m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST,
669.1479 -		                         x,
669.1480 -		                         y,
669.1481 -		                         winSizeX,
669.1482 -		                         winSizeY,
669.1483 -		                         SWP_NOMOVE | SWP_SHOWWINDOW);
669.1484 -	}
669.1485 -
669.1486 -	updateMenuBar(); // add menubar first of all, or winGetMenuBarHeight() will get random height.
669.1487 -	winAccelMgr.UpdateMenu(menu);
669.1488 -	adjustDestRect();
669.1489 -
669.1490 -	updateIFB();
669.1491 -	updateFilter();
669.1492 -
669.1493 -	m_pMainWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
669.1494 -}
669.1495 -
669.1496 -bool VBA::initDisplay()
669.1497 -{
669.1498 -	if (display)
669.1499 -	{
669.1500 -		changingVideoSize = true;
669.1501 -		shutdownDisplay();
669.1502 -		if (input)
669.1503 -		{
669.1504 -			delete input;
669.1505 -			input = NULL;
669.1506 -		}
669.1507 -		CWnd *pWnd = m_pMainWnd;
669.1508 -
669.1509 -		m_pMainWnd = NULL;
669.1510 -		pWnd->DragAcceptFiles(FALSE);
669.1511 -		pWnd->DestroyWindow();
669.1512 -		delete pWnd;
669.1513 -
669.1514 -		display = NULL;
669.1515 -	}
669.1516 -
669.1517 -	if (display == NULL)
669.1518 -	{
669.1519 -		updateWindowSize(videoOption);
669.1520 -
669.1521 -		switch (renderMethod)
669.1522 -		{
669.1523 -		case GDI:
669.1524 -			display = newGDIDisplay();
669.1525 -			break;
669.1526 -		case DIRECT_DRAW:
669.1527 -			display = newDirectDrawDisplay();
669.1528 -			break;
669.1529 -		case DIRECT_3D:
669.1530 -			display = newDirect3DDisplay();
669.1531 -			break;
669.1532 -		case OPENGL:
669.1533 -			display = newOpenGLDisplay();
669.1534 -			break;
669.1535 -		}
669.1536 -
669.1537 -		if (display->initialize())
669.1538 -		{
669.1539 -			if (input == NULL)
669.1540 -			{
669.1541 -				if (!initInput())
669.1542 -				{
669.1543 -					changingVideoSize = false;
669.1544 -					AfxPostQuitMessage(0);
669.1545 -					return false;
669.1546 -				}
669.1547 -			}
669.1548 -
669.1549 -			input->checkKeys();
669.1550 -
669.1551 -			changingVideoSize = false;
669.1552 -		}
669.1553 -		else
669.1554 -		{
669.1555 -			if (videoOption == VIDEO_320x240 ||
669.1556 -			    videoOption == VIDEO_640x480 ||
669.1557 -			    videoOption == VIDEO_800x600 ||
669.1558 -			    videoOption == VIDEO_OTHER)
669.1559 -			{
669.1560 -				regSetDwordValue("video", VIDEO_1X);
669.1561 -				if (pVideoDriverGUID)
669.1562 -					regSetDwordValue("defaultVideoDriver", TRUE);
669.1563 -			}
669.1564 -			changingVideoSize = false;
669.1565 -			return false;
669.1566 -		}
669.1567 -	}
669.1568 -	changingVideoSize = false;
669.1569 -	return true;
669.1570 -}
669.1571 -
669.1572 -bool VBA::updateRenderMethod(bool force)
669.1573 -{
669.1574 -	bool res = true;
669.1575 -	if (force || (display && display->getType() != renderMethod))
669.1576 -	{
669.1577 -		res = initDisplay();
669.1578 -
669.1579 -		while (!res && renderMethod > 0)
669.1580 -		{
669.1581 -			if (renderMethod == OPENGL)
669.1582 -				renderMethod = DIRECT_3D;
669.1583 -			else if (renderMethod == DIRECT_3D)
669.1584 -				renderMethod = DIRECT_DRAW;
669.1585 -			else if (renderMethod == DIRECT_DRAW)
669.1586 -				renderMethod = GDI;
669.1587 -
669.1588 -			res = initDisplay();
669.1589 -		}
669.1590 -	}
669.1591 -
669.1592 -	updateIFB();
669.1593 -	updateFilter();
669.1594 -
669.1595 -	m_pMainWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
669.1596 -
669.1597 -	regSetDwordValue("renderMethod", renderMethod);
669.1598 -
669.1599 -	return res;
669.1600 -}
669.1601 -
669.1602 -void VBA::winCheckFullscreen()
669.1603 -{
669.1604 -	if (videoOption > VIDEO_4X && tripleBuffering)
669.1605 -	{
669.1606 -		if (display)
669.1607 -			display->checkFullScreen();
669.1608 -	}
669.1609 -}
669.1610 -
669.1611 -void VBA::shutdownDisplay()
669.1612 -{
669.1613 -	if (display != NULL)
669.1614 -	{
669.1615 -		display->cleanup();
669.1616 -		delete display;
669.1617 -		display = NULL;
669.1618 -	}
669.1619 -}
669.1620 -
669.1621 -void VBA::updatePriority()
669.1622 -{
669.1623 -	switch (threadPriority)
669.1624 -	{
669.1625 -	case 0:
669.1626 -		SetThreadPriority(THREAD_PRIORITY_HIGHEST);
669.1627 -		break;
669.1628 -	case 1:
669.1629 -		SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL);
669.1630 -		break;
669.1631 -	case 3:
669.1632 -		SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
669.1633 -		break;
669.1634 -	default:
669.1635 -		SetThreadPriority(THREAD_PRIORITY_NORMAL);
669.1636 -	}
669.1637 -}
669.1638 -
669.1639 -#ifdef MMX
669.1640 -bool VBA::detectMMX()
669.1641 -{
669.1642 -	bool support = false;
669.1643 -	char brand[13];
669.1644 -
669.1645 -	// check for Intel chip
669.1646 -	__try {
669.1647 -		__asm {
669.1648 -			mov eax, 0;
669.1649 -			cpuid;
669.1650 -			mov [dword ptr brand + 0], ebx;
669.1651 -			mov [dword ptr brand + 4], edx;
669.1652 -			mov [dword ptr brand + 8], ecx;
669.1653 -		}
669.1654 -	}
669.1655 -	__except(EXCEPTION_EXECUTE_HANDLER) {
669.1656 -		if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
669.1657 -		{
669.1658 -			return false;
669.1659 -		}
669.1660 -		return false;
669.1661 -	}
669.1662 -	// Check for Intel or AMD CPUs
669.1663 -	if (strncmp(brand, "GenuineIntel", 12))
669.1664 -	{
669.1665 -		if (strncmp(brand, "AuthenticAMD", 12))
669.1666 -		{
669.1667 -			return false;
669.1668 -		}
669.1669 -	}
669.1670 -
669.1671 -	__asm {
669.1672 -		mov eax, 1;
669.1673 -		cpuid;
669.1674 -		test edx, 00800000h;
669.1675 -		jz	 NotFound;
669.1676 -		mov [support], 1;
669.1677 -NotFound:
669.1678 -	}
669.1679 -	return support;
669.1680 -}
669.1681 -
669.1682 -#endif
669.1683 -
669.1684 -void VBA::winSetLanguageOption(int option, bool force)
669.1685 -{
669.1686 -	if (((option == languageOption) && option != 2) && !force)
669.1687 -		return;
669.1688 -	switch (option)
669.1689 -	{
669.1690 -	case 0:
669.1691 -	{
669.1692 -		char lbuffer[10];
669.1693 -
669.1694 -		if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME,
669.1695 -		                  lbuffer, 10))
669.1696 -		{
669.1697 -			HINSTANCE l = winLoadLanguage(lbuffer);
669.1698 -			if (l == NULL)
669.1699 -			{
669.1700 -				LCID locIdBase = MAKELCID(MAKELANGID(PRIMARYLANGID(GetSystemDefaultLangID()), SUBLANG_NEUTRAL), SORT_DEFAULT);
669.1701 -				if (GetLocaleInfo(locIdBase, LOCALE_SABBREVLANGNAME,
669.1702 -				                  lbuffer, 10))
669.1703 -				{
669.1704 -					l = winLoadLanguage(lbuffer);
669.1705 -					if (l == NULL)
669.1706 -					{
669.1707 -						systemMessage(IDS_FAILED_TO_LOAD_LIBRARY,
669.1708 -						              "Failed to load library %s",
669.1709 -						              lbuffer);
669.1710 -						return;
669.1711 -					}
669.1712 -				}
669.1713 -			}
669.1714 -			AfxSetResourceHandle(l);
669.1715 -			if (languageModule != NULL)
669.1716 -				/**/ ::FreeLibrary(languageModule);
669.1717 -			languageModule = l;
669.1718 -		}
669.1719 -		else
669.1720 -		{
669.1721 -			systemMessage(IDS_FAILED_TO_GET_LOCINFO,
669.1722 -			              "Failed to get locale information");
669.1723 -			return;
669.1724 -		}
669.1725 -		break;
669.1726 -	}
669.1727 -	case 1:
669.1728 -		if (languageModule != NULL)
669.1729 -			/**/ ::FreeLibrary(languageModule);
669.1730 -		languageModule = NULL;
669.1731 -		AfxSetResourceHandle(AfxGetInstanceHandle());
669.1732 -		break;
669.1733 -	case 2:
669.1734 -	{
669.1735 -		if (!force)
669.1736 -		{
669.1737 -			LangSelect dlg;
669.1738 -			if (dlg.DoModal())
669.1739 -			{
669.1740 -				HINSTANCE l = winLoadLanguage(languageName);
669.1741 -				if (l == NULL)
669.1742 -				{
669.1743 -					systemMessage(IDS_FAILED_TO_LOAD_LIBRARY,
669.1744 -					              "Failed to load library %s",
669.1745 -					              languageName);
669.1746 -					return;
669.1747 -				}
669.1748 -				AfxSetResourceHandle(l);
669.1749 -				if (languageModule != NULL)
669.1750 -					/**/ ::FreeLibrary(languageModule);
669.1751 -				languageModule = l;
669.1752 -			}
669.1753 -		}
669.1754 -		else
669.1755 -		{
669.1756 -			if (languageName.IsEmpty())
669.1757 -				return;
669.1758 -			HINSTANCE l = winLoadLanguage(languageName);
669.1759 -			if (l == NULL)
669.1760 -			{
669.1761 -				systemMessage(IDS_FAILED_TO_LOAD_LIBRARY,
669.1762 -				              "Failed to load library %s",
669.1763 -				              languageName);
669.1764 -				return;
669.1765 -			}
669.1766 -			AfxSetResourceHandle(l);
669.1767 -			if (languageModule != NULL)
669.1768 -				FreeLibrary(languageModule);
669.1769 -			languageModule = l;
669.1770 -		}
669.1771 -		break;
669.1772 -	}
669.1773 -	}
669.1774 -	languageOption = option;
669.1775 -	updateMenuBar();
669.1776 -	theApp.winAccelMgr.UpdateMenu(theApp.menu);
669.1777 -}
669.1778 -
669.1779 -HINSTANCE VBA::winLoadLanguage(const char *name)
669.1780 -{
669.1781 -	CString buffer;
669.1782 -
669.1783 -	buffer.Format("vba_%s.dll", name);
669.1784 -
669.1785 -	HINSTANCE l = /**/ ::LoadLibrary(buffer);
669.1786 -
669.1787 -	if (l == NULL)
669.1788 -	{
669.1789 -		if (strlen(name) == 3)
669.1790 -		{
669.1791 -			char buffer2[3];
669.1792 -			buffer2[0] = name[0];
669.1793 -			buffer2[1] = name[1];
669.1794 -			buffer2[2] = 0;
669.1795 -			buffer.Format("vba_%s.dll", buffer2);
669.1796 -
669.1797 -			return /**/ ::LoadLibrary(buffer);
669.1798 -		}
669.1799 -	}
669.1800 -	return l;
669.1801 -}
669.1802 -
669.1803 -bool VBA::initInput()
669.1804 -{
669.1805 -	if (input)
669.1806 -		delete input;
669.1807 -	input = newDirectInput();
669.1808 -	if (input->initialize())
669.1809 -	{
669.1810 -		input->loadSettings();
669.1811 -		input->checkKeys();
669.1812 -		return true;
669.1813 -	}
669.1814 -	delete input;
669.1815 -	return false;
669.1816 -}
669.1817 -
669.1818 -void VBA::winAddUpdateListener(IUpdateListener *l)
669.1819 -{
669.1820 -	updateList.AddTail(l);
669.1821 -	updateCount++;
669.1822 -}
669.1823 -
669.1824 -void VBA::winRemoveUpdateListener(IUpdateListener *l)
669.1825 -{
669.1826 -	POSITION pos = updateList.Find(l);
669.1827 -	if (pos)
669.1828 -	{
669.1829 -		updateList.RemoveAt(pos);
669.1830 -		updateCount--;
669.1831 -		if (updateCount < 0)
669.1832 -			updateCount = 0;
669.1833 -	}
669.1834 -}
669.1835 -
669.1836 -void VBA::loadSettings()
669.1837 -{
669.1838 -	CString	buffer;
669.1839 -	// video
669.1840 -	bool defaultVideoDriver = regQueryDwordValue("defaultVideoDriver", true) ? true : false;
669.1841 -	if (!regQueryBinaryValue("videoDriverGUID", (char *)&videoDriverGUID, sizeof(GUID)))
669.1842 -	{
669.1843 -		defaultVideoDriver = TRUE;
669.1844 -	}
669.1845 -	if (defaultVideoDriver)
669.1846 -		pVideoDriverGUID = NULL;
669.1847 -	else
669.1848 -		pVideoDriverGUID = &videoDriverGUID;
669.1849 -
669.1850 -	videoOption = regQueryDwordValue("video", 0);
669.1851 -	if (videoOption < 0 || videoOption > VIDEO_OTHER)
669.1852 -		videoOption = 0;
669.1853 -	switch (videoOption)
669.1854 -	{
669.1855 -	case VIDEO_320x240:
669.1856 -		fsWidth		 = 320;
669.1857 -		fsHeight	 = 240;
669.1858 -		fsColorDepth = 16;
669.1859 -		break;
669.1860 -	case VIDEO_640x480:
669.1861 -		fsWidth		 = 640;
669.1862 -		fsHeight	 = 480;
669.1863 -		fsColorDepth = 16;
669.1864 -		break;
669.1865 -	case VIDEO_800x600:
669.1866 -		fsWidth		 = 800;
669.1867 -		fsHeight	 = 600;
669.1868 -		fsColorDepth = 16;
669.1869 -		break;
669.1870 -	}
669.1871 -	if (videoOption == VIDEO_OTHER)
669.1872 -	{
669.1873 -		if (fsWidth < 0 || fsWidth > 4095 || fsHeight < 0 || fsHeight > 4095)
669.1874 -			videoOption = 0;
669.1875 -		if (fsColorDepth != 16 && fsColorDepth != 24 && fsColorDepth != 32)
669.1876 -			videoOption = 0;
669.1877 -	}
669.1878 -
669.1879 -	fsWidth = regQueryDwordValue("fsWidth", 0);
669.1880 -	fsHeight = regQueryDwordValue("fsHeight", 0);
669.1881 -	fsColorDepth	  = regQueryDwordValue("fsColorDepth", 0);
669.1882 -	fsMaxScale		  = regQueryDwordValue("fsMaxScale", 0);
669.1883 -	fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false;
669.1884 -
669.1885 -	renderMethod = (DISPLAY_TYPE)regQueryDwordValue("renderMethod", DIRECT_DRAW);
669.1886 -	if (renderMethod < GDI || renderMethod > OPENGL)
669.1887 -		renderMethod = DIRECT_DRAW;
669.1888 -
669.1889 -	ddrawEmulationOnly	= regQueryDwordValue("ddrawEmulationOnly", false) ? true : false;
669.1890 -	ddrawUseVideoMemory = regQueryDwordValue("ddrawUseVideoMemory", false) ? true : false;
669.1891 -	tripleBuffering		= regQueryDwordValue("tripleBuffering", true) ? true : false;
669.1892 -	vsync = regQueryDwordValue("vsync", false) ? true : false;
669.1893 -
669.1894 -	d3dFilter = regQueryDwordValue("d3dFilter", 0);
669.1895 -	if (d3dFilter < 0 || d3dFilter > 1)
669.1896 -		d3dFilter = 0;
669.1897 -	glFilter = regQueryDwordValue("glFilter", 0);
669.1898 -	if (glFilter < 0 || glFilter > 1)
669.1899 -		glFilter = 0;
669.1900 -	glType = regQueryDwordValue("glType", 0);
669.1901 -	if (glType < 0 || glType > 1)
669.1902 -		glType = 0;
669.1903 -
669.1904 -	// pixel filter & ifb
669.1905 -	filterType = regQueryDwordValue("filter", 0);
669.1906 -	if (filterType < 0 || filterType > 20)
669.1907 -		filterType = 0;
669.1908 -	disableMMX = regQueryDwordValue("disableMMX", 0) ? true : false;
669.1909 -	ifbType	   = regQueryDwordValue("ifbType", 0);
669.1910 -	if (ifbType < 0 || ifbType > 2)
669.1911 -		ifbType = 0;
669.1912 -
669.1913 -	// frame skipping
669.1914 -	frameSkip = regQueryDwordValue("frameSkip", /*2*/ 0);
669.1915 -	if (frameSkip < 0 || frameSkip > 9)
669.1916 -		frameSkip = 1;
669.1917 -	gbFrameSkip = regQueryDwordValue("gbFrameSkip", 0);
669.1918 -	if (gbFrameSkip < 0 || gbFrameSkip > 9)
669.1919 -		gbFrameSkip = 0;
669.1920 -///  autoFrameSkip = regQueryDwordValue("autoFrameSkip", FALSE) ? TRUE : FALSE;
669.1921 -
669.1922 -	// input
669.1923 -	joypadDefault = regQueryDwordValue("joypadDefault", 0);
669.1924 -	if (joypadDefault < 0 || joypadDefault > 3)
669.1925 -		joypadDefault = 0;
669.1926 -	allowLeftRight		   = regQueryDwordValue("allowLeftRight", false) ? true : false;
669.1927 -	autofireAccountForLag  = regQueryDwordValue("autofireAccountForLag", false) ? true : false;
669.1928 -	nextframeAccountForLag = regQueryDwordValue("nextframeAccountForLag", false) ? true : false;
669.1929 -	theApp.AsscWithSaveState = regQueryDwordValue("AsscWithSaveState", false) ? true : false;
669.1930 -
669.1931 -	// speed
669.1932 -	throttle = regQueryDwordValue("throttle", 0);
669.1933 -	if (throttle < 5 || throttle > 1000)
669.1934 -		throttle = 100;
669.1935 -
669.1936 -	synchronize = regQueryDwordValue("synchronize", 1) ? true : false;
669.1937 -	accuratePitchThrottle = regQueryDwordValue("accuratePitchThrottle", FALSE) ? TRUE : FALSE;
669.1938 -
669.1939 -	// sound
669.1940 -	int resChannels = regQueryDwordValue("soundEnable", 0x30f);
669.1941 -	soundEnableChannels(resChannels);
669.1942 -	soundDisableChannels(~resChannels);
669.1943 -	soundOffFlag = (regQueryDwordValue("soundOff", 0)) ? true : false;
669.1944 -	soundQuality = regQueryDwordValue("soundQuality", 2);
669.1945 -	soundEcho	 = regQueryDwordValue("soundEcho", 0) ? true : false;
669.1946 -	soundLowPass = regQueryDwordValue("soundLowPass", 0) ? true : false;
669.1947 -	soundReverse = regQueryDwordValue("soundReverse", 0) ? true : false;
669.1948 -	soundVolume	 = regQueryDwordValue("soundVolume", 0);
669.1949 -	if (soundVolume < 0 || soundVolume > 5)
669.1950 -		soundVolume = 0;
669.1951 -	muteFrameAdvance = regQueryDwordValue("muteFrameAdvance", 0) ? TRUE : FALSE;
669.1952 -	muteWhenInactive = regQueryDwordValue("muteWhenInactive", 0) ? TRUE : FALSE;
669.1953 -
669.1954 -	// emulation
669.1955 -	memLagEnabled	  = regQueryDwordValue("memLagEnabled", false) ? true : false;
669.1956 -	memLagTempEnabled = memLagEnabled;
669.1957 -	gbNullInputHackEnabled	   = regQueryDwordValue("gbNullInputHackEnabled", false) ? true : false;
669.1958 -	gbNullInputHackTempEnabled = gbNullInputHackEnabled;
669.1959 -	useOldSync		  = regQueryDwordValue("useOldSync", 0) ? TRUE : FALSE;
669.1960 -	useOldFrameTiming = regQueryDwordValue("useOldGBTiming", false) ? true : false;
669.1961 -
669.1962 -	useBiosFile	 = regQueryDwordValue("useBios", 0) ? true : false;
669.1963 -	skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false;
669.1964 -	buffer		 = regQueryStringValue("biosFile", "");
669.1965 -	if (!buffer.IsEmpty())
669.1966 -	{
669.1967 -		biosFileName = buffer;
669.1968 -	}
669.1969 -//	removeIntros = regQueryDwordValue("removeIntros", false) ? true : false;
669.1970 -
669.1971 -	autoIPS = regQueryDwordValue("autoIPS", true) ? true : false;
669.1972 -
669.1973 -	agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false);
669.1974 -	winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false;
669.1975 -	rtcEnable(winRtcEnable);
669.1976 -
669.1977 -	winSaveType = regQueryDwordValue("saveType", 0);
669.1978 -	if (winSaveType < 0 || winSaveType > 5)
669.1979 -		winSaveType = 0;
669.1980 -	cpuEnhancedDetection = regQueryDwordValue("enhancedDetection", 1) ? true : false;
669.1981 -	winFlashSize		 = regQueryDwordValue("flashSize", 0x10000);
669.1982 -	if (winFlashSize != 0x10000 && winFlashSize != 0x20000)
669.1983 -		winFlashSize = 0x10000;
669.1984 -
669.1985 -	cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
669.1986 -
669.1987 -	// GBx
669.1988 -	winGbPrinterEnabled = regQueryDwordValue("gbPrinter", false) ? true : false;
669.1989 -	if (winGbPrinterEnabled)
669.1990 -		gbSerialFunction = gbPrinterSend;
669.1991 -	else
669.1992 -		gbSerialFunction = NULL;
669.1993 -	gbEmulatorType = regQueryDwordValue("emulatorType", 0);
669.1994 -	if (gbEmulatorType < 0 || gbEmulatorType > 5)
669.1995 -		gbEmulatorType = 1;
669.1996 -	winGbBorderOn	  = regQueryDwordValue("borderOn", 0);
669.1997 -	gbBorderAutomatic = regQueryDwordValue("borderAutomatic", 0);
669.1998 -
669.1999 -	gbColorOption	= regQueryDwordValue("colorOption", 0);
669.2000 -	gbPaletteOption = regQueryDwordValue("gbPaletteOption", 0);
669.2001 -	if (gbPaletteOption < 0)
669.2002 -		gbPaletteOption = 0;
669.2003 -	if (gbPaletteOption > 2)
669.2004 -		gbPaletteOption = 2;
669.2005 -	regQueryBinaryValue("gbPalette", (char *)systemGbPalette, 24 * sizeof(u16));
669.2006 -
669.2007 -	// head-up display
669.2008 -	showSpeed = regQueryDwordValue("showSpeed", 1);
669.2009 -	if (showSpeed < 0 || showSpeed > 2)
669.2010 -		showSpeed = 1;
669.2011 -	showSpeedTransparent = regQueryDwordValue("showSpeedTransparent", TRUE) ? TRUE : FALSE;
669.2012 -	outlinedText		 = regQueryDwordValue("outlinedText", TRUE) != 0;
669.2013 -	transparentText		 = regQueryDwordValue("transparentText", FALSE) != 0;
669.2014 -	textColor			 = regQueryDwordValue("textColor", 0);
669.2015 -	textMethod			 = regQueryDwordValue("textMethod", 1);
669.2016 -	frameCounter		 = regQueryDwordValue("frameCounter", false) ? true : false;
669.2017 -	lagCounter			 = regQueryDwordValue("lagCounter", false) ? true : false;
669.2018 -	extraCounter		 = regQueryDwordValue("extraCounter", false) ? true : false;
669.2019 -	inputDisplay		 = regQueryDwordValue("inputDisplay", false) ? true : false;
669.2020 -	disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;
669.2021 -
669.2022 -	// UI
669.2023 -	windowPositionX = regQueryDwordValue("windowX", 0);
669.2024 -	if (windowPositionX < 0)
669.2025 -		windowPositionX = 0;
669.2026 -	windowPositionY = regQueryDwordValue("windowY", 0);
669.2027 -	if (windowPositionY < 0)
669.2028 -		windowPositionY = 0;
669.2029 -
669.2030 -	autoHideMenu = regQueryDwordValue("autoHideMenu", 0) ? true : false;
669.2031 -
669.2032 -	languageOption = regQueryDwordValue("language", 1);
669.2033 -	if (languageOption < 0 || languageOption > 2)
669.2034 -		languageOption = 1;
669.2035 -	buffer = regQueryStringValue("languageName", "");
669.2036 -	if (!buffer.IsEmpty())
669.2037 -	{
669.2038 -		languageName = buffer.Left(3);
669.2039 -	}
669.2040 -	else
669.2041 -		languageName = "";
669.2042 -	winSetLanguageOption(languageOption, true);
669.2043 -
669.2044 -	// preferences
669.2045 -	alwaysOnTop = regQueryDwordValue("alwaysOnTop", false) ? true : false;
669.2046 -	pauseWhenInactive	  = regQueryDwordValue("pauseWhenInactive", 1) ? true : false;
669.2047 -	enableBackgroundInput = regQueryDwordValue("enableBackgroundInput", 0) ? true : false;
669.2048 -	threadPriority		  = regQueryDwordValue("priority", 2);
669.2049 -	if (threadPriority < 0 || threadPriority > 3)
669.2050 -		threadPriority = 2;
669.2051 -	updatePriority();
669.2052 -
669.2053 -	filenamePreference = regQueryDwordValue("filenamePreference", 0);
669.2054 -	altAviRecordMethod = regQueryDwordValue("altAviRecordMethod", false) ? true : false;
669.2055 -	captureFormat	   = regQueryDwordValue("captureFormat", 0);
669.2056 -
669.2057 -	rewindTimer = regQueryDwordValue("rewindTimer", 0);
669.2058 -	rewindSlots = regQueryDwordValue("rewindSlots", 64);
669.2059 -	if (rewindTimer < 0 || rewindTimer > 600)
669.2060 -		rewindTimer = 0;
669.2061 -	if (rewindSlots <= 0)
669.2062 -		rewindTimer = rewindSlots = 0;
669.2063 -	if (rewindSlots > MAX_REWIND_SLOTS)
669.2064 -		rewindSlots = MAX_REWIND_SLOTS;
669.2065 -	if (rewindTimer != 0)
669.2066 -	{
669.2067 -		if (rewindMemory == NULL)
669.2068 -			rewindMemory = (char *)malloc(rewindSlots * REWIND_SIZE);
669.2069 -	}
669.2070 -
669.2071 -	if (frameSearchMemory == NULL)
669.2072 -		frameSearchMemory = (char *)malloc(3 * REWIND_SIZE);
669.2073 -
669.2074 -	recentFreeze = regQueryDwordValue("recentFreeze", false) ? true : false;
669.2075 -	for (int i = 0, j = 0; i < 10; ++i)
669.2076 -	{
669.2077 -		buffer.Format("recent%d", i);
669.2078 -		const char *s = regQueryStringValue(buffer, NULL);
669.2079 -		if (s == NULL)
669.2080 -			continue;
669.2081 -		recentFiles[j] = s;
669.2082 -		++j;
669.2083 -	}
669.2084 -
669.2085 -	autoLoadMostRecent = regQueryDwordValue("autoLoadMostRecent", false) ? true : false;
669.2086 -	loadMakesRecent	   = regQueryDwordValue("loadMakesRecent", false) ? true : false;
669.2087 -	loadMakesCurrent   = regQueryDwordValue("loadMakesCurrent", false) ? true : false;
669.2088 -	saveMakesCurrent   = regQueryDwordValue("saveMakesCurrent", false) ? true : false;
669.2089 -	currentSlot		   = regQueryDwordValue("currentSlot", 0);
669.2090 -	showSlotTime	   = regQueryDwordValue("showSlotTime", 0) ? true : false;
669.2091 -
669.2092 -	cheatsEnabled = regQueryDwordValue("cheatsEnabled", true) ? true : false;
669.2093 -	autoSaveLoadCheatList  = regQueryDwordValue("autoSaveCheatList", 0) ? true : false;
669.2094 -	pauseDuringCheatSearch = regQueryDwordValue("pauseDuringCheatSearch2", 0) ? true : false;
669.2095 -
669.2096 -	movieOnEndBehavior = regQueryDwordValue("movieOnEndBehavior", 0);
669.2097 -	movieOnEndPause	   = regQueryDwordValue("movieOnEndPause", 0) ? true : false;
669.2098 -
669.2099 -	extern bool autoConvertMovieWhenPlaying;    // from movie.cpp
669.2100 -	autoConvertMovieWhenPlaying = regQueryDwordValue("autoConvertMovieWhenPlaying", 0) ? true : false;
669.2101 -
669.2102 -	// RamWatch Settings
669.2103 -	AutoRWLoad		= regQueryDwordValue(AUTORWLOAD, false);
669.2104 -	RWSaveWindowPos = regQueryDwordValue(RWSAVEPOS, false);
669.2105 -	ramw_x = regQueryDwordValue(RAMWX, 0);
669.2106 -	ramw_y = regQueryDwordValue(RAMWY, 0);
669.2107 -
669.2108 -	// this is FILO
669.2109 -	for (int i = MAX_RECENT_WATCHES; i > 0; --i)
669.2110 -	{
669.2111 -		buffer.Format("recentWatch%d", i);
669.2112 -		const char *s = regQueryStringValue(buffer, NULL);
669.2113 -		if (s == NULL)
669.2114 -			continue;
669.2115 -		RWAddRecentFile(s);
669.2116 -	}
669.2117 -}
669.2118 -
669.2119 -void VBA::saveSettings()
669.2120 -{
669.2121 -	regSetDwordValue("defaultVideoDriver", pVideoDriverGUID == NULL);
669.2122 -	if (pVideoDriverGUID)
669.2123 -	{
669.2124 -		regSetBinaryValue("videoDriverGUID", (char *)&videoDriverGUID,
669.2125 -		                  sizeof(GUID));
669.2126 -	}
669.2127 -	regSetDwordValue("video", videoOption);
669.2128 -
669.2129 -	regSetDwordValue("fsWidth", fsWidth);
669.2130 -	regSetDwordValue("fsHeight", fsHeight);
669.2131 -	regSetDwordValue("fsColorDepth", fsColorDepth);
669.2132 -	regSetDwordValue("fsMaxScale", fsMaxScale);
669.2133 -
669.2134 -	regSetDwordValue("stretch", fullScreenStretch);
669.2135 -
669.2136 -	regSetDwordValue("renderMethod", renderMethod);
669.2137 -
669.2138 -	regSetDwordValue("ddrawEmulationOnly", ddrawEmulationOnly);
669.2139 -	regSetDwordValue("ddrawUseVideoMemory", ddrawUseVideoMemory);
669.2140 -	regSetDwordValue("tripleBuffering", tripleBuffering);
669.2141 -	regSetDwordValue("vsync", vsync);
669.2142 -
669.2143 -	regSetDwordValue("d3dFilter", d3dFilter);
669.2144 -	regSetDwordValue("glFilter", glFilter);
669.2145 -	regSetDwordValue("glType", glType);
669.2146 -
669.2147 -	// pixel filter & ifb
669.2148 -	regSetDwordValue("filter", filterType);
669.2149 -	regSetDwordValue("ifbType", ifbType);
669.2150 -	regSetDwordValue("disableMMX", disableMMX);
669.2151 -
669.2152 -	// frame skipping
669.2153 -	regSetDwordValue("frameSkip", frameSkip);
669.2154 -	regSetDwordValue("gbFrameSkip", gbFrameSkip);
669.2155 -///  regSetDwordValue("autoFrameSkip", autoFrameSkip);
669.2156 -
669.2157 -	// input
669.2158 -	regSetDwordValue("joypadDefault", joypadDefault);
669.2159 -	regSetDwordValue("allowLeftRight", allowLeftRight);
669.2160 -	regSetDwordValue("autofireAccountforLag", autofireAccountForLag);
669.2161 -	regSetDwordValue("nextframeAccountforLag", nextframeAccountForLag);
669.2162 -	regSetDwordValue("AsscWithSaveState", theApp.AsscWithSaveState);
669.2163 -
669.2164 -
669.2165 -	// speed
669.2166 -	regSetDwordValue("throttle", throttle);
669.2167 -	regSetDwordValue("synchronize", synchronize);
669.2168 -	regSetDwordValue("accuratePitchThrottle", accuratePitchThrottle);
669.2169 -
669.2170 -	// sound
669.2171 -	regSetDwordValue("soundEnable", soundGetEnabledChannels() & 0x030f);
669.2172 -	regSetDwordValue("soundOff", soundOffFlag);
669.2173 -	regSetDwordValue("soundQuality", soundQuality);
669.2174 -	regSetDwordValue("soundEcho", soundEcho);
669.2175 -	regSetDwordValue("soundLowPass", soundLowPass);
669.2176 -	regSetDwordValue("soundReverse", soundReverse);
669.2177 -	regSetDwordValue("soundVolume", soundVolume);
669.2178 -	regSetDwordValue("muteFrameAdvance", muteFrameAdvance);
669.2179 -	regSetDwordValue("muteWhenInactive", muteWhenInactive);
669.2180 -
669.2181 -	// emulation
669.2182 -	regSetDwordValue("useBios", useBiosFile);
669.2183 -	regSetDwordValue("skipBios", skipBiosFile);
669.2184 -	if (!biosFileName.IsEmpty())
669.2185 -		regSetStringValue("biosFile", biosFileName);
669.2186 -//	regSetDwordValue("removeIntros", removeIntros);
669.2187 -
669.2188 -	regSetDwordValue("autoIPS", autoIPS);
669.2189 -
669.2190 -	regSetDwordValue("memLagEnabled", memLagEnabled);
669.2191 -	regSetDwordValue("gbNullInputHackEnabled", gbNullInputHackEnabled);
669.2192 -	regSetDwordValue("useOldGBTiming", useOldFrameTiming);
669.2193 -	regSetDwordValue("useOldSync", useOldSync);
669.2194 -
669.2195 -	regSetDwordValue("agbPrint", agbPrintIsEnabled());
669.2196 -	regSetDwordValue("rtcEnabled", winRtcEnable);
669.2197 -
669.2198 -	regSetDwordValue("saveType", winSaveType);
669.2199 -	regSetDwordValue("enhancedDetection", cpuEnhancedDetection);
669.2200 -	regSetDwordValue("flashSize", winFlashSize);
669.2201 -
669.2202 -	regSetDwordValue("disableSfx", cpuDisableSfx);
669.2203 -
669.2204 -	// GBx
669.2205 -	regSetDwordValue("emulatorType", gbEmulatorType);
669.2206 -	regSetDwordValue("gbPrinter", winGbPrinterEnabled);
669.2207 -	regSetDwordValue("borderOn", winGbBorderOn);
669.2208 -	regSetDwordValue("borderAutomatic", gbBorderAutomatic);
669.2209 -
669.2210 -	regSetDwordValue("colorOption", gbColorOption);
669.2211 -	regSetDwordValue("gbPaletteOption", gbPaletteOption);
669.2212 -	regSetBinaryValue("gbPalette", (char *)systemGbPalette, 24 * sizeof(u16));
669.2213 -
669.2214 -	// head-up display
669.2215 -	regSetDwordValue("showSpeed", showSpeed);
669.2216 -	regSetDwordValue("showSpeedTransparent", showSpeedTransparent);
669.2217 -
669.2218 -	regSetDwordValue("outlinedText", outlinedText);
669.2219 -	regSetDwordValue("transparentText", transparentText);
669.2220 -	regSetDwordValue("textColor", textColor);
669.2221 -	regSetDwordValue("textMethod", textMethod);
669.2222 -	regSetDwordValue("frameCounter", frameCounter);
669.2223 -	regSetDwordValue("lagCounter", lagCounter);
669.2224 -	regSetDwordValue("extraCounter", extraCounter);
669.2225 -	regSetDwordValue("inputDisplay", inputDisplay);
669.2226 -	regSetDwordValue("disableStatus", disableStatusMessage);
669.2227 -
669.2228 -	// UI
669.2229 -	regSetDwordValue("windowX", windowPositionX);
669.2230 -	regSetDwordValue("windowY", windowPositionY);
669.2231 -
669.2232 -	regSetDwordValue("autoHideMenu", autoHideMenu);
669.2233 -
669.2234 -	regSetDwordValue("language", languageOption);
669.2235 -	regSetStringValue("languageName", languageName);
669.2236 -
669.2237 -	// preferences
669.2238 -	regSetDwordValue("alwaysOnTop", alwaysOnTop);
669.2239 -	regSetDwordValue("pauseWhenInactive", pauseWhenInactive);
669.2240 -	regSetDwordValue("enableBackgroundInput", enableBackgroundInput);
669.2241 -	regSetDwordValue("priority", threadPriority);
669.2242 -
669.2243 -	regSetDwordValue("filenamePreference", filenamePreference);
669.2244 -	regSetDwordValue("altAviRecordMethod", altAviRecordMethod);
669.2245 -	regSetDwordValue("captureFormat", captureFormat);
669.2246 -
669.2247 -	regSetDwordValue("cheatsEnabled", cheatsEnabled);
669.2248 -	regSetDwordValue("autoSaveCheatList", autoSaveLoadCheatList);
669.2249 -	regSetDwordValue("pauseDuringCheatSearch2", pauseDuringCheatSearch);
669.2250 -
669.2251 -	regSetDwordValue("rewindTimer", rewindTimer);
669.2252 -	regSetDwordValue("rewindSlots", rewindSlots);
669.2253 -
669.2254 -	regSetDwordValue("recentFreeze", recentFreeze);
669.2255 -	CString buffer;
669.2256 -	for (int i = 0; i < 10; i++)
669.2257 -	{
669.2258 -		buffer.Format("recent%d", i);
669.2259 -		regSetStringValue(buffer, recentFiles[i]);
669.2260 -	}
669.2261 -
669.2262 -	regSetDwordValue("autoLoadMostRecent", autoLoadMostRecent);
669.2263 -	regSetDwordValue("loadMakesRecent", loadMakesRecent);
669.2264 -	regSetDwordValue("loadMakesCurrent", loadMakesCurrent);
669.2265 -	regSetDwordValue("saveMakesCurrent", saveMakesCurrent);
669.2266 -	regSetDwordValue("currentSlot", currentSlot);
669.2267 -	regSetDwordValue("showSlotTime", showSlotTime);
669.2268 -
669.2269 -	regSetDwordValue("movieOnEndBehavior", movieOnEndBehavior);
669.2270 -	regSetDwordValue("movieOnEndPause", movieOnEndPause);
669.2271 -
669.2272 -	extern bool autoConvertMovieWhenPlaying;    // from movie.cpp
669.2273 -	regSetDwordValue("autoConvertMovieWhenPlaying", autoConvertMovieWhenPlaying);
669.2274 -}
669.2275 -
   670.1 --- a/src/win32/VBA.h	Sat Mar 03 10:54:39 2012 -0600
   670.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   670.3 @@ -1,274 +0,0 @@
   670.4 -#if !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_)
   670.5 -#define AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_
   670.6 -
   670.7 -#if _MSC_VER > 1000
   670.8 -#pragma once
   670.9 -#endif // _MSC_VER > 1000
  670.10 -
  670.11 -/*
  670.12 -   #ifndef __AFXWIN_H__
  670.13 -   #error include 'stdafx.h' before including this file for PCH
  670.14 -   #endif
  670.15 - */
  670.16 -
  670.17 -#include <afxtempl.h>
  670.18 -
  670.19 -#include "AcceleratorManager.h"
  670.20 -#include "AVIWrite.h"
  670.21 -#include "Display.h"
  670.22 -#include "../common/System.h"
  670.23 -
  670.24 -/////////////////////////////////////////////////////////////////////////////
  670.25 -// VBA:
  670.26 -// See VBA.cpp for the implementation of this class
  670.27 -//
  670.28 -
  670.29 -enum
  670.30 -{
  670.31 -	VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X,
  670.32 -	VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_OTHER
  670.33 -};
  670.34 -
  670.35 -#define REWIND_SIZE 400000
  670.36 -#define MAX_REWIND_SLOTS 256
  670.37 -#define SCREEN_MESSAGE_SLOTS 8
  670.38 -
  670.39 -/////////////////////////////////////////////////////////////////////////////
  670.40 -// forward decl
  670.41 -class IUpdateListener;
  670.42 -class Input;
  670.43 -class ISound;
  670.44 -class AVIWrite;
  670.45 -class WavWriter;
  670.46 -
  670.47 -class VBA : public CWinApp
  670.48 -{
  670.49 -public:
  670.50 -	CMenu	  m_menu;
  670.51 -	HMENU	  menu;
  670.52 -	HMENU	  popup;
  670.53 -	bool	  mode320Available;
  670.54 -	bool	  mode640Available;
  670.55 -	bool	  mode800Available;
  670.56 -	int		  windowPositionX;
  670.57 -	int		  windowPositionY;
  670.58 -	void	  (*filterFunction)(u8 *, u32, u8 *, u8 *, u32, int, int);
  670.59 -	void	  (*ifbFunction)(u8 *, u32, int, int);
  670.60 -	int		  ifbType;
  670.61 -	int		  filterType;
  670.62 -	int		  filterWidth;
  670.63 -	int		  filterHeight;
  670.64 -	int		  fsWidth;
  670.65 -	int		  fsHeight;
  670.66 -	int		  fsColorDepth;
  670.67 -	bool	  fsForceChange;
  670.68 -	bool	  AsscWithSaveState;
  670.69 -	int		  sizeX;
  670.70 -	int		  sizeY;
  670.71 -	int		  surfaceSizeX;
  670.72 -	int		  surfaceSizeY;
  670.73 -	int		  videoOption;
  670.74 -	bool	  fullScreenStretch;
  670.75 -	bool	  disableStatusMessage;
  670.76 -	int		  showSpeed;
  670.77 -	BOOL	  showSpeedTransparent;
  670.78 -	int		  showRenderedFrames;
  670.79 -	bool	  screenMessage [SCREEN_MESSAGE_SLOTS];
  670.80 -	CString	  screenMessageBuffer [SCREEN_MESSAGE_SLOTS];
  670.81 -	DWORD	  screenMessageTime [SCREEN_MESSAGE_SLOTS];
  670.82 -	int		  screenMessageDuration [SCREEN_MESSAGE_SLOTS];
  670.83 -	CString	  screenMessageColorBuffer [SCREEN_MESSAGE_SLOTS];
  670.84 -	u8 *	  delta[257 * 244 * 4];
  670.85 -	bool	  menuToggle;
  670.86 -	IDisplay *display;
  670.87 -	bool	  soundInitialized;
  670.88 -	bool	  useBiosFile;
  670.89 -	bool	  skipBiosFile;
  670.90 -	CString	  biosFileName;
  670.91 -	bool	  allowLeftRight;
  670.92 -	bool	  autofireAccountForLag;
  670.93 -	bool	  nextframeAccountForLag;
  670.94 -	bool	  active;
  670.95 -	bool	  iconic;
  670.96 -	bool	  paused;
  670.97 -	CString	  recentFiles[10];
  670.98 -	bool	  recentFreeze;
  670.99 -	bool	  autoSaveLoadCheatList;
 670.100 -	bool	  pauseDuringCheatSearch;
 670.101 -	bool	  modelessCheatDialogIsOpen;
 670.102 -//	FILE *    winout;
 670.103 -//	bool      removeIntros;
 670.104 -	bool  autoIPS;
 670.105 -	int	  winGbBorderOn;
 670.106 -	bool  hideMovieBorder;
 670.107 -	int	  winFlashSize;
 670.108 -	bool  winRtcEnable;
 670.109 -	int	  winSaveType;
 670.110 -	char *rewindMemory;
 670.111 -	int	  rewindPos;
 670.112 -	int	  rewindTopPos;
 670.113 -	int	  rewindCounter;
 670.114 -	int	  rewindCount;
 670.115 -	bool  rewindSaveNeeded;
 670.116 -	int	  rewindTimer;
 670.117 -	int	  rewindSlots;
 670.118 -	int	  captureFormat;
 670.119 -	bool  tripleBuffering;
 670.120 -	bool  autoHideMenu;
 670.121 -	bool  speedupToggle;
 670.122 -	int	  throttle;
 670.123 -	u32	  throttleLastTime;
 670.124 -///  u32 autoFrameSkipLastTime;
 670.125 -///  bool autoFrameSkip;
 670.126 -	bool		 accuratePitchThrottle;
 670.127 -	bool		 vsync;
 670.128 -	bool		 changingVideoSize;
 670.129 -	GUID		 videoDriverGUID;
 670.130 -	GUID *		 pVideoDriverGUID;
 670.131 -	DISPLAY_TYPE renderMethod;
 670.132 -	bool		 ddrawEmulationOnly;
 670.133 -	bool		 ddrawUsingEmulationOnly;
 670.134 -	bool		 ddrawDebug;
 670.135 -	bool		 ddrawUseVideoMemory;
 670.136 -	int			 d3dFilter;
 670.137 -	int			 glFilter;
 670.138 -	int			 glType;
 670.139 -	bool		 muteWhenInactive;
 670.140 -	bool		 muteFrameAdvance;
 670.141 -	bool		 pauseWhenInactive;
 670.142 -	bool		 enableBackgroundInput;
 670.143 -	bool		 alwaysOnTop;
 670.144 -	bool		 useOldSync;
 670.145 -	bool		 winGbPrinterEnabled;
 670.146 -	int			 threadPriority;
 670.147 -	bool		 disableMMX;
 670.148 -	int			 languageOption;
 670.149 -	CString		 languageName;
 670.150 -	HINSTANCE	 languageModule;
 670.151 -	int			 renderedFrames;
 670.152 -	Input *		 input;
 670.153 -	int			 joypadDefault;
 670.154 -	int			 autoFire, autoFire2;
 670.155 -	int			 autoHold;
 670.156 -	bool		 autoFireToggle;
 670.157 -	bool		 frameCounter;
 670.158 -	bool		 lagCounter;
 670.159 -	bool		 extraCounter;
 670.160 -	bool		 inputDisplay;
 670.161 -	bool		 movieReadOnly;
 670.162 -	bool		 movieOnEndPause;
 670.163 -	int			 movieOnEndBehavior;
 670.164 -	bool		 soundRecording;
 670.165 -	WavWriter *	 soundRecorder;
 670.166 -	CString		 soundRecordName;
 670.167 -	ISound *	 sound;
 670.168 -	bool		 aviRecording;
 670.169 -	AVIWrite *	 aviRecorder;
 670.170 -	CString		 aviRecordName;
 670.171 -	bool		 altAviRecordMethod;
 670.172 -	bool		 nvVideoLog;
 670.173 -	bool		 nvAudioLog;
 670.174 -	bool		 painting;  // for systemDrawScreen()
 670.175 -	int			 mouseCounter;
 670.176 -	bool		 winMuteForNow;
 670.177 -	bool		 winPauseNextFrame;
 670.178 -	bool		 wasPaused;
 670.179 -	int			 fsMaxScale;
 670.180 -	int			 romSize;
 670.181 -	bool		 autoLoadMostRecent;
 670.182 -	bool		 loadMakesRecent;
 670.183 -	bool		 loadMakesCurrent;
 670.184 -	bool		 saveMakesCurrent;
 670.185 -	int			 currentSlot;
 670.186 -	bool		 showSlotTime;
 670.187 -	int			 filenamePreference;
 670.188 -	int			 LuaFastForward;
 670.189 -	bool		 frameSearching;
 670.190 -	bool		 frameSearchSkipping;
 670.191 -	bool		 frameSearchFirstStep;
 670.192 -	bool		 frameSearchLoadValid;
 670.193 -	int			 frameSearchLength;
 670.194 -	int			 frameSearchStart;
 670.195 -	u32			 frameSearchOldInput[4];
 670.196 -	char *		 frameSearchMemory;
 670.197 -	DWORD		 wmTimerRes;
 670.198 -
 670.199 -	CList<IUpdateListener *, IUpdateListener * &> updateList;
 670.200 -	int updateCount;
 670.201 -
 670.202 -	CAcceleratorManager winAccelMgr;
 670.203 -	HACCEL hAccel;
 670.204 -
 670.205 -	RECT rect;
 670.206 -	RECT dest;
 670.207 -
 670.208 -	struct EmulatedSystem &emulator;
 670.209 -
 670.210 -	CString romFilename;
 670.211 -	CString gameFilename;
 670.212 -	CString exeName;
 670.213 -	CString exeDir;
 670.214 -	CString wndClass;
 670.215 -
 670.216 -public:
 670.217 -	VBA();
 670.218 -	~VBA();
 670.219 -
 670.220 -	void adjustDestRect();
 670.221 -	void recreateMenuBar();
 670.222 -	void updateIFB();
 670.223 -	void updateFilter();
 670.224 -	void updateMenuBar();
 670.225 -	void winAddUpdateListener(IUpdateListener *l);
 670.226 -	void winRemoveUpdateListener(IUpdateListener *l);
 670.227 -
 670.228 -	// Overrides
 670.229 -	// ClassWizard generated virtual function overrides
 670.230 -	//{{AFX_VIRTUAL(VBA)
 670.231 -public:
 670.232 -	virtual BOOL InitInstance();
 670.233 -	virtual BOOL OnIdle(LONG lCount);
 670.234 -	//}}AFX_VIRTUAL
 670.235 -
 670.236 -	// Implementation
 670.237 -public:
 670.238 -	HINSTANCE winLoadLanguage(const char *name);
 670.239 -	void winSetLanguageOption(int option, bool force);
 670.240 -#ifdef MMX
 670.241 -	bool detectMMX();
 670.242 -#endif
 670.243 -	void updatePriority();
 670.244 -	void shutdownDisplay();
 670.245 -	void winCheckFullscreen();
 670.246 -	bool updateRenderMethod(bool force);
 670.247 -	bool initDisplay();
 670.248 -	void updateWindowSize(int value);
 670.249 -	void updateVideoSize(UINT id);
 670.250 -	void updateFrameSkip();
 670.251 -	void loadSettings();
 670.252 -	void saveSettings();
 670.253 -	bool initInput();
 670.254 -	void addRecentFile(const CString &file);
 670.255 -	void saveRewindStateIfNecessary();
 670.256 -	//{{AFX_MSG(VBA)
 670.257 -	afx_msg void OnAppAbout();
 670.258 -	// NOTE - the ClassWizard will add and remove member functions here.
 670.259 -	//    DO NOT EDIT what you see in these blocks of generated code !
 670.260 -	//}}AFX_MSG
 670.261 -	DECLARE_MESSAGE_MAP()
 670.262 -};
 670.263 -
 670.264 -extern VBA theApp;
 670.265 -
 670.266 -#ifdef MMX
 670.267 -extern "C" bool cpu_mmx;
 670.268 -#endif
 670.269 -
 670.270 -extern void DrawTextMessages(u8 *dest, int pitch, int left, int bottom);
 670.271 -
 670.272 -/////////////////////////////////////////////////////////////////////////////
 670.273 -
 670.274 -//{{AFX_INSERT_LOCATION}}
 670.275 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 670.276 -
 670.277 -#endif // !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_)
   671.1 --- a/src/win32/VersionInfo.h	Sat Mar 03 10:54:39 2012 -0600
   671.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   671.3 @@ -1,33 +0,0 @@
   671.4 -#ifndef VBA_VERSIONINFO_H
   671.5 -#define VBA_VERSIONINFO_H
   671.6 -
   671.7 -#if _MSC_VER > 1000
   671.8 -#pragma once
   671.9 -#endif // _MSC_VER > 1000
  671.10 -
  671.11 -#include "../version.h"
  671.12 -
  671.13 -#if SVN_REV > 65535
  671.14 -#	define VBA_RR_BUILD_NO 0
  671.15 -#else
  671.16 -#	define VBA_RR_BUILD_NO SVN_REV
  671.17 -#endif
  671.18 -
  671.19 -// diaplayed in the file attribute dialog
  671.20 -#define VBA_VERSIONINFO_FILEVER        7, VBA_RR_MAJOR_VERSION_NO, VBA_RR_MINOR_VERSION_NO, VBA_RR_BUILD_NO
  671.21 -#define VBA_VERSIONINFO_STRFILEVER     STRINGIZE_VALUE(VBA_VERSIONINFO_FILEVER) "\0"
  671.22 -
  671.23 -#define VBA_VERSIONINFO_PRODUCTVER     VBA_VERSIONINFO_FILEVER
  671.24 -#define VBA_VERSIONINFO_STRPRODUCTVER  VBA_VERSIONINFO_STRFILEVER
  671.25 -#define VBA_VERSIONINFO_STRCOPYRIGHT   "Copyright (C) 2005-2011 VBA-RR Development Team"
  671.26 -#define VBA_VERSIONINFO_ORGANIZATION   VBA_RR_SITE
  671.27 -
  671.28 -#ifdef _DEBUG
  671.29 -#	define VBA_VERSIONINFO_FILEFLAGS    VS_FF_DEBUG
  671.30 -#elif defined(PUBLIC_RELEASE)
  671.31 -#	define VBA_VERSIONINFO_FILEFLAGS    0
  671.32 -#else
  671.33 -#	define VBA_VERSIONINFO_FILEFLAGS    VS_FF_PRERELEASE
  671.34 -#endif
  671.35 -
  671.36 -#endif // VBA_VERSIONINFO_H
   672.1 --- a/src/win32/VideoMode.cpp	Sat Mar 03 10:54:39 2012 -0600
   672.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   672.3 @@ -1,347 +0,0 @@
   672.4 -// VideoMode.cpp : implementation file
   672.5 -//
   672.6 -
   672.7 -#include "stdafx.h"
   672.8 -#include "resource.h"
   672.9 -
  672.10 -///		#define _AFXDLL /// EVIL
  672.11 -///		#include "afxwin.h" /// EVIL
  672.12 -///		#include "afxdll_.h" /// EVIL
  672.13 -
  672.14 -#define DIRECTDRAW_VERSION 0x0700
  672.15 -#include "ddraw.h"
  672.16 -
  672.17 -#include "VideoMode.h"
  672.18 -
  672.19 -#include "../common/System.h" // for system messages
  672.20 -
  672.21 -#define MAX_DRIVERS         32                  // 32 drivers maximum
  672.22 -
  672.23 -//-----------------------------------------------------------------------------
  672.24 -// Local structures
  672.25 -//-----------------------------------------------------------------------------
  672.26 -// Keeps data on the available DDraw drivers
  672.27 -struct
  672.28 -{
  672.29 -	char     szDescription[128];
  672.30 -	char     szName[128];
  672.31 -	GUID *   pGUID;
  672.32 -	GUID     GUIDcopy;
  672.33 -	HMONITOR hm;
  672.34 -} Drivers[MAX_DRIVERS];
  672.35 -
  672.36 -//-----------------------------------------------------------------------------
  672.37 -// Local data
  672.38 -//-----------------------------------------------------------------------------
  672.39 -static int gDriverCnt = 0;                      // Total number of drivers
  672.40 -static GUID *gpSelectedDriverGUID;
  672.41 -
  672.42 -//-----------------------------------------------------------------------------
  672.43 -// Name: DDEnumCallbackEx()
  672.44 -// Desc: This call back is used to determine the existing available DDraw
  672.45 -//       devices, so the user can pick which one to run on.
  672.46 -//-----------------------------------------------------------------------------
  672.47 -BOOL WINAPI
  672.48 -DDEnumCallbackEx(GUID *pGUID, LPSTR pDescription, LPSTR pName, LPVOID pContext, HMONITOR hm)
  672.49 -{
  672.50 -	if (pGUID)
  672.51 -	{
  672.52 -		Drivers[gDriverCnt].GUIDcopy = *pGUID;
  672.53 -		Drivers[gDriverCnt].pGUID    = &Drivers[gDriverCnt].GUIDcopy;
  672.54 -	}
  672.55 -	else
  672.56 -		Drivers[gDriverCnt].pGUID = NULL;
  672.57 -	Drivers[gDriverCnt].szDescription[127] = '\0';
  672.58 -	Drivers[gDriverCnt].szName[127]        = '\0';
  672.59 -	strncpy(Drivers[gDriverCnt].szDescription, pDescription, 127);
  672.60 -	strncpy(Drivers[gDriverCnt].szName, pName, 127);
  672.61 -	Drivers[gDriverCnt].hm = hm;
  672.62 -	if (gDriverCnt < MAX_DRIVERS)
  672.63 -		gDriverCnt++;
  672.64 -	else
  672.65 -		return DDENUMRET_CANCEL;
  672.66 -	return DDENUMRET_OK;
  672.67 -}
  672.68 -
  672.69 -//-----------------------------------------------------------------------------
  672.70 -// Name: DDEnumCallback()
  672.71 -// Desc: This callback is used only with old versions of DDraw.
  672.72 -//-----------------------------------------------------------------------------
  672.73 -BOOL WINAPI
  672.74 -DDEnumCallback(GUID *pGUID, LPSTR pDescription, LPSTR pName, LPVOID context)
  672.75 -{
  672.76 -	return (DDEnumCallbackEx(pGUID, pDescription, pName, context, NULL));
  672.77 -}
  672.78 -
  672.79 -static HRESULT WINAPI addVideoMode(LPDDSURFACEDESC2 surf, LPVOID lpContext)
  672.80 -{
  672.81 -	HWND h = (HWND)lpContext;
  672.82 -	char buffer[50];
  672.83 -
  672.84 -	switch (surf->ddpfPixelFormat.dwRGBBitCount)
  672.85 -	{
  672.86 -	case 16:
  672.87 -	case 24:
  672.88 -	case 32:
  672.89 -		if (surf->dwWidth >= 640 && surf->dwHeight >= 480)
  672.90 -		{
  672.91 -			sprintf(buffer, "%4dx%4dx%2d", surf->dwWidth, surf->dwHeight,
  672.92 -			        surf->ddpfPixelFormat.dwRGBBitCount);
  672.93 -			int pos = ::SendMessage(h, LB_ADDSTRING, 0, (LPARAM)buffer);
  672.94 -			::SendMessage(h, LB_SETITEMDATA, pos,
  672.95 -			              (surf->ddpfPixelFormat.dwRGBBitCount << 24) |
  672.96 -			              ((surf->dwWidth & 4095) << 12) |
  672.97 -			              (surf->dwHeight & 4095));
  672.98 -		}
  672.99 -	}
 672.100 -
 672.101 -	return DDENUMRET_OK;
 672.102 -}
 672.103 -
 672.104 -int winVideoModeSelect(CWnd *pWnd, GUID **guid)
 672.105 -{
 672.106 -	HINSTANCE h = /**/ ::LoadLibrary("ddraw.dll");
 672.107 -
 672.108 -	// If ddraw.dll doesn't exist in the search path,
 672.109 -	// then DirectX probably isn't installed, so fail.
 672.110 -	if (!h)
 672.111 -		return -1;
 672.112 -
 672.113 -	gDriverCnt = 0;
 672.114 -
 672.115 -	// Note that you must know which version of the
 672.116 -	// function to retrieve (see the following text).
 672.117 -	// For this example, we use the ANSI version.
 672.118 -	LPDIRECTDRAWENUMERATEEX lpDDEnumEx;
 672.119 -	lpDDEnumEx = (LPDIRECTDRAWENUMERATEEX)
 672.120 -	             GetProcAddress(h, "DirectDrawEnumerateExA");
 672.121 -
 672.122 -	// If the function is there, call it to enumerate all display
 672.123 -	// devices attached to the desktop, and any non-display DirectDraw
 672.124 -	// devices.
 672.125 -	if (lpDDEnumEx)
 672.126 -		lpDDEnumEx(DDEnumCallbackEx, NULL,
 672.127 -		           DDENUM_ATTACHEDSECONDARYDEVICES |
 672.128 -		           DDENUM_NONDISPLAYDEVICES
 672.129 -		           );
 672.130 -	else
 672.131 -	{
 672.132 -		/*
 672.133 -		 * We must be running on an old version of DirectDraw.
 672.134 -		 * Therefore MultiMon isn't supported. Fall back on
 672.135 -		 * DirectDrawEnumerate to enumerate standard devices on a
 672.136 -		 * single-monitor system.
 672.137 -		 */
 672.138 -		BOOL (WINAPI *lpDDEnum)(LPDDENUMCALLBACK, LPVOID);
 672.139 -
 672.140 -		lpDDEnum = (BOOL (WINAPI *)(LPDDENUMCALLBACK, LPVOID))
 672.141 -		           GetProcAddress(h, "DirectDrawEnumerateA");
 672.142 -		if (lpDDEnum)
 672.143 -			lpDDEnum(DDEnumCallback, NULL);
 672.144 -
 672.145 -		/* Note that it could be handy to let the OldCallback function
 672.146 -		 * be a wrapper for a DDEnumCallbackEx.
 672.147 -		 *
 672.148 -		 * Such a function would look like:
 672.149 -		 *    BOOL FAR PASCAL OldCallback(GUID FAR *lpGUID,
 672.150 -		 *                                LPSTR pDesc,
 672.151 -		 *                                LPSTR pName,
 672.152 -		 *                                LPVOID pContext)
 672.153 -		 *    {
 672.154 -		 *         return Callback(lpGUID,pDesc,pName,pContext,NULL);
 672.155 -		 *    }
 672.156 -		 */
 672.157 -	}
 672.158 -
 672.159 -	int selected = 0;
 672.160 -
 672.161 -	if (gDriverCnt > 1)
 672.162 -	{
 672.163 -		VideoDriverSelect d(pWnd);
 672.164 -
 672.165 -		selected = d.DoModal();
 672.166 -
 672.167 -		if (selected == -1)
 672.168 -		{
 672.169 -			// If the library was loaded by calling LoadLibrary(),
 672.170 -			// then you must use FreeLibrary() to let go of it.
 672.171 -			/**/ ::FreeLibrary(h);
 672.172 -
 672.173 -			return -1;
 672.174 -		}
 672.175 -	}
 672.176 -
 672.177 -	HRESULT (WINAPI *DDrawCreateEx)(GUID *, LPVOID *, REFIID, IUnknown *);
 672.178 -	DDrawCreateEx = (HRESULT (WINAPI *)(GUID *, LPVOID *, REFIID, IUnknown *))
 672.179 -	                GetProcAddress(h, "DirectDrawCreateEx");
 672.180 -
 672.181 -	LPDIRECTDRAW7 ddraw = NULL;
 672.182 -	if (DDrawCreateEx)
 672.183 -	{
 672.184 -		HRESULT hret = DDrawCreateEx(Drivers[selected].pGUID,
 672.185 -		                             (void * *)&ddraw,
 672.186 -		                             IID_IDirectDraw7,
 672.187 -		                             NULL);
 672.188 -		if (hret != DD_OK)
 672.189 -		{
 672.190 -			systemMessage(0, "Error during DirectDrawCreateEx: %08x", hret);
 672.191 -			/**/ ::FreeLibrary(h);
 672.192 -			return -1;
 672.193 -		}
 672.194 -	}
 672.195 -	else
 672.196 -	{
 672.197 -		// should not happen....
 672.198 -		systemMessage(0, "Error getting DirectDrawCreateEx");
 672.199 -		/**/ ::FreeLibrary(h);
 672.200 -		return -1;
 672.201 -	}
 672.202 -
 672.203 -	VideoMode dlg(ddraw, pWnd);
 672.204 -
 672.205 -	int res = dlg.DoModal();
 672.206 -
 672.207 -	if (res != -1)
 672.208 -	{
 672.209 -		*guid = Drivers[selected].pGUID;
 672.210 -	}
 672.211 -	ddraw->Release();
 672.212 -	ddraw = NULL;
 672.213 -
 672.214 -	// If the library was loaded by calling LoadLibrary(),
 672.215 -	// then you must use FreeLibrary() to let go of it.
 672.216 -	/**/ ::FreeLibrary(h);
 672.217 -
 672.218 -	return res;
 672.219 -}
 672.220 -
 672.221 -/////////////////////////////////////////////////////////////////////////////
 672.222 -// VideoMode dialog
 672.223 -
 672.224 -VideoMode::VideoMode(LPDIRECTDRAW7 pDraw, CWnd*pParent /*=NULL*/)
 672.225 -	: CDialog(VideoMode::IDD, pParent)
 672.226 -{
 672.227 -	//{{AFX_DATA_INIT(VideoMode)
 672.228 -	// NOTE: the ClassWizard will add member initialization here
 672.229 -	//}}AFX_DATA_INIT
 672.230 -	pDirectDraw = pDraw;
 672.231 -}
 672.232 -
 672.233 -void VideoMode::DoDataExchange(CDataExchange*pDX)
 672.234 -{
 672.235 -	CDialog::DoDataExchange(pDX);
 672.236 -	//{{AFX_DATA_MAP(VideoMode)
 672.237 -	DDX_Control(pDX, IDC_MODES, m_modes);
 672.238 -	//}}AFX_DATA_MAP
 672.239 -}
 672.240 -
 672.241 -BEGIN_MESSAGE_MAP(VideoMode, CDialog)
 672.242 -//{{AFX_MSG_MAP(VideoMode)
 672.243 -ON_LBN_SELCHANGE(IDC_MODES, OnSelchangeModes)
 672.244 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 672.245 -ON_BN_CLICKED(ID_OK, OnOk)
 672.246 -//}}AFX_MSG_MAP
 672.247 -END_MESSAGE_MAP()
 672.248 -
 672.249 -/////////////////////////////////////////////////////////////////////////////
 672.250 -// VideoMode message handlers
 672.251 -
 672.252 -void VideoMode::OnSelchangeModes()
 672.253 -{
 672.254 -	int item = m_modes.GetCurSel();
 672.255 -
 672.256 -	GetDlgItem(ID_OK)->EnableWindow(item != -1);
 672.257 -}
 672.258 -
 672.259 -void VideoMode::OnCancel()
 672.260 -{
 672.261 -	EndDialog(-1);
 672.262 -}
 672.263 -
 672.264 -void VideoMode::OnOk()
 672.265 -{
 672.266 -	int cur = m_modes.GetCurSel();
 672.267 -
 672.268 -	if (cur != -1)
 672.269 -	{
 672.270 -		cur = m_modes.GetItemData(cur);
 672.271 -	}
 672.272 -	EndDialog(cur);
 672.273 -}
 672.274 -
 672.275 -BOOL VideoMode::OnInitDialog()
 672.276 -{
 672.277 -	CDialog::OnInitDialog();
 672.278 -
 672.279 -	// check for available fullscreen modes
 672.280 -	pDirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, m_modes.m_hWnd,
 672.281 -	                              addVideoMode);
 672.282 -
 672.283 -	GetDlgItem(ID_OK)->EnableWindow(FALSE);
 672.284 -	CenterWindow();
 672.285 -
 672.286 -	return TRUE; // return TRUE unless you set the focus to a control
 672.287 -	             // EXCEPTION: OCX Property Pages should return FALSE
 672.288 -}
 672.289 -
 672.290 -/////////////////////////////////////////////////////////////////////////////
 672.291 -// VideoDriverSelect dialog
 672.292 -
 672.293 -VideoDriverSelect::VideoDriverSelect(CWnd*pParent /*=NULL*/)
 672.294 -	: CDialog(VideoDriverSelect::IDD, pParent)
 672.295 -{
 672.296 -	//{{AFX_DATA_INIT(VideoDriverSelect)
 672.297 -	// NOTE: the ClassWizard will add member initialization here
 672.298 -	//}}AFX_DATA_INIT
 672.299 -}
 672.300 -
 672.301 -void VideoDriverSelect::DoDataExchange(CDataExchange*pDX)
 672.302 -{
 672.303 -	CDialog::DoDataExchange(pDX);
 672.304 -	//{{AFX_DATA_MAP(VideoDriverSelect)
 672.305 -	DDX_Control(pDX, IDC_DRIVERS, m_drivers);
 672.306 -	//}}AFX_DATA_MAP
 672.307 -}
 672.308 -
 672.309 -BEGIN_MESSAGE_MAP(VideoDriverSelect, CDialog)
 672.310 -//{{AFX_MSG_MAP(VideoDriverSelect)
 672.311 -ON_BN_CLICKED(ID_OK, OnOk)
 672.312 -ON_BN_CLICKED(ID_CANCEL, OnCancel)
 672.313 -ON_LBN_SELCHANGE(IDC_DRIVERS, OnSelchangeDrivers)
 672.314 -//}}AFX_MSG_MAP
 672.315 -END_MESSAGE_MAP()
 672.316 -
 672.317 -/////////////////////////////////////////////////////////////////////////////
 672.318 -// VideoDriverSelect message handlers
 672.319 -
 672.320 -void VideoDriverSelect::OnCancel()
 672.321 -{
 672.322 -	EndDialog(-1);
 672.323 -}
 672.324 -
 672.325 -void VideoDriverSelect::OnOk()
 672.326 -{
 672.327 -	EndDialog(m_drivers.GetCurSel());
 672.328 -}
 672.329 -
 672.330 -BOOL VideoDriverSelect::OnInitDialog()
 672.331 -{
 672.332 -	CDialog::OnInitDialog();
 672.333 -
 672.334 -	for (int i = 0; i < gDriverCnt; i++)
 672.335 -	{
 672.336 -		m_drivers.AddString(Drivers[i].szDescription);
 672.337 -	}
 672.338 -
 672.339 -	GetDlgItem(ID_OK)->EnableWindow(FALSE);
 672.340 -	CenterWindow();
 672.341 -
 672.342 -	return TRUE; // return TRUE unless you set the focus to a control
 672.343 -	             // EXCEPTION: OCX Property Pages should return FALSE
 672.344 -}
 672.345 -
 672.346 -void VideoDriverSelect::OnSelchangeDrivers()
 672.347 -{
 672.348 -	GetDlgItem(ID_OK)->EnableWindow(m_drivers.GetCurSel() != -1);
 672.349 -}
 672.350 -
   673.1 --- a/src/win32/VideoMode.h	Sat Mar 03 10:54:39 2012 -0600
   673.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   673.3 @@ -1,79 +0,0 @@
   673.4 -#if !defined(AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_)
   673.5 -#define AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_
   673.6 -
   673.7 -#if _MSC_VER > 1000
   673.8 -#pragma once
   673.9 -#endif // _MSC_VER > 1000
  673.10 -// VideoMode.h : header file
  673.11 -//
  673.12 -
  673.13 -/////////////////////////////////////////////////////////////////////////////
  673.14 -// VideoMode dialog
  673.15 -
  673.16 -class VideoMode : public CDialog
  673.17 -{
  673.18 -	// Construction
  673.19 -public:
  673.20 -	VideoMode(LPDIRECTDRAW7 pDraw, CWnd *pParent = NULL); // standard constructor
  673.21 -
  673.22 -	// Dialog Data
  673.23 -	//{{AFX_DATA(VideoMode)
  673.24 -	enum { IDD = IDD_MODES };
  673.25 -	CListBox m_modes;
  673.26 -	//}}AFX_DATA
  673.27 -
  673.28 -	// Overrides
  673.29 -	// ClassWizard generated virtual function overrides
  673.30 -	//{{AFX_VIRTUAL(VideoMode)
  673.31 -protected:
  673.32 -	virtual void DoDataExchange(CDataExchange *pDX);  // DDX/DDV support
  673.33 -	//}}AFX_VIRTUAL
  673.34 -
  673.35 -	// Implementation
  673.36 -protected:
  673.37 -	// Generated message map functions
  673.38 -	//{{AFX_MSG(VideoMode)
  673.39 -	afx_msg void OnSelchangeModes();
  673.40 -	afx_msg void OnCancel();
  673.41 -	afx_msg void OnOk();
  673.42 -	virtual BOOL OnInitDialog();
  673.43 -	//}}AFX_MSG
  673.44 -	DECLARE_MESSAGE_MAP()
  673.45 -private:
  673.46 -	LPDIRECTDRAW7 pDirectDraw;
  673.47 -};
  673.48 -
  673.49 -/////////////////////////////////////////////////////////////////////////////
  673.50 -// VideoDriverSelect dialog
  673.51 -
  673.52 -class VideoDriverSelect : public CDialog
  673.53 -{
  673.54 -	// Construction
  673.55 -public:
  673.56 -	VideoDriverSelect(CWnd *pParent = NULL); // standard constructor
  673.57 -
  673.58 -	// Dialog Data
  673.59 -	//{{AFX_DATA(VideoDriverSelect)
  673.60 -	enum { IDD = IDD_DRIVERS };
  673.61 -	CListBox m_drivers;
  673.62 -	//}}AFX_DATA
  673.63 -
  673.64 -	// Overrides
  673.65 -	// ClassWizard generated virtual function overrides
  673.66 -	//{{AFX_VIRTUAL(VideoDriverSelect)
  673.67 -protected:
  673.68 -	virtual void DoDataExchange(CDataExchange *pDX);  // DDX/DDV support
  673.69 -	//}}AFX_VIRTUAL
  673.70 -
  673.71 -	// Implementation
  673.72 -protected:
  673.73 -	// Generated message map functions
  673.74 -	//{{AFX_MSG(VideoDriverSelect)
  673.75 -	afx_msg void OnCancel();
  673.76 -	afx_msg void OnOk();
  673.77 -	virtual BOOL OnInitDialog();
  673.78 -	afx_msg void OnSelchangeDrivers();
  673.79 -	//}}AFX_MSG
  673.80 -	DECLARE_MESSAGE_MAP()
  673.81 -};
  673.82 -#endif // !defined(AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_)
   674.1 --- a/src/win32/VisualBoyAdvance.exe.manifest	Sat Mar 03 10:54:39 2012 -0600
   674.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   674.3 @@ -1,23 +0,0 @@
   674.4 -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   674.5 -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   674.6 -<assemblyIdentity
   674.7 -    version="0.6.0.0"
   674.8 -    processorArchitecture="X86"
   674.9 -    name="VisualBoyAdvance"
  674.10 -    type="win32"
  674.11 -/>
  674.12 -<description>VisualBoyAdvance Emulator.</description>
  674.13 -<dependency>
  674.14 -    <dependentAssembly>
  674.15 -        <assemblyIdentity
  674.16 -            type="win32"
  674.17 -            name="Microsoft.Windows.Common-Controls"
  674.18 -            version="6.0.0.0"
  674.19 -            processorArchitecture="X86"
  674.20 -            publicKeyToken="6595b64144ccf1df"
  674.21 -            language="*"
  674.22 -        />
  674.23 -    </dependentAssembly>
  674.24 -</dependency>
  674.25 -</assembly>
  674.26 -
   675.1 --- a/src/win32/WavWriter.cpp	Sat Mar 03 10:54:39 2012 -0600
   675.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   675.3 @@ -1,92 +0,0 @@
   675.4 -// WavWriter.cpp: implementation of the WavWriter class.
   675.5 -//
   675.6 -//////////////////////////////////////////////////////////////////////
   675.7 -
   675.8 -#include "stdafx.h"
   675.9 -#include "WavWriter.h"
  675.10 -
  675.11 -#include "../common/Util.h"
  675.12 -
  675.13 -//////////////////////////////////////////////////////////////////////
  675.14 -// Construction/Destruction
  675.15 -//////////////////////////////////////////////////////////////////////
  675.16 -
  675.17 -WavWriter::WavWriter()
  675.18 -{
  675.19 -	m_file    = NULL;
  675.20 -	m_len     = 0;
  675.21 -	m_posSize = 0;
  675.22 -}
  675.23 -
  675.24 -WavWriter::~WavWriter()
  675.25 -{
  675.26 -	if (m_file)
  675.27 -		Close();
  675.28 -}
  675.29 -
  675.30 -void WavWriter::Close()
  675.31 -{
  675.32 -	// calculate the total file length
  675.33 -	u32 len = ftell(m_file)-8;
  675.34 -	fseek(m_file, 4, SEEK_SET);
  675.35 -	u8 data[4];
  675.36 -	utilPutDword(data, len);
  675.37 -	fwrite(data, 1, 4, m_file);
  675.38 -	// write out the size of the data section
  675.39 -	fseek(m_file, m_posSize, SEEK_SET);
  675.40 -	utilPutDword(data, m_len);
  675.41 -	fwrite(data, 1, 4, m_file);
  675.42 -	fclose(m_file);
  675.43 -	m_file = NULL;
  675.44 -}
  675.45 -
  675.46 -bool WavWriter::Open(const char *name)
  675.47 -{
  675.48 -	if (m_file)
  675.49 -		Close();
  675.50 -	m_file = fopen(name, "wb");
  675.51 -
  675.52 -	if (!m_file)
  675.53 -		return false;
  675.54 -	// RIFF header
  675.55 -	u8 data[4] = { 'R', 'I', 'F', 'F' };
  675.56 -	fwrite(data, 1, 4, m_file);
  675.57 -	utilPutDword(data, 0);
  675.58 -	// write 0 for now. Will get filled during close
  675.59 -	fwrite(data, 1, 4, m_file);
  675.60 -	// write WAVE header
  675.61 -	u8 data2[4] = { 'W', 'A', 'V', 'E' };
  675.62 -	fwrite(data2, 1, 4, m_file);
  675.63 -	return true;
  675.64 -}
  675.65 -
  675.66 -void WavWriter::SetFormat(const WAVEFORMATEX *format)
  675.67 -{
  675.68 -	if (m_file == NULL)
  675.69 -		return;
  675.70 -	// write fmt header
  675.71 -	u8 data[4] = { 'f', 'm', 't', ' ' };
  675.72 -	fwrite(data, 1, 4, m_file);
  675.73 -	u32 value = sizeof(WAVEFORMATEX);
  675.74 -	utilPutDword(data, value);
  675.75 -	fwrite(data, 1, 4, m_file);
  675.76 -	fwrite(format, 1, sizeof(WAVEFORMATEX), m_file);
  675.77 -	// start data header
  675.78 -	u8 data2[4] = { 'd', 'a', 't', 'a' };
  675.79 -	fwrite(data2, 1, 4, m_file);
  675.80 -
  675.81 -	m_posSize = ftell(m_file);
  675.82 -	// write 0 for data chunk size. Filled out during Close()
  675.83 -	utilPutDword(data, 0);
  675.84 -	fwrite(data, 1, 4, m_file);
  675.85 -}
  675.86 -
  675.87 -void WavWriter::AddSound(const u8 *data, int len)
  675.88 -{
  675.89 -	if (m_file == NULL)
  675.90 -		return;
  675.91 -	// write a block of sound data
  675.92 -	fwrite(data, 1, len, m_file);
  675.93 -	m_len += len;
  675.94 -}
  675.95 -
   676.1 --- a/src/win32/WavWriter.h	Sat Mar 03 10:54:39 2012 -0600
   676.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   676.3 @@ -1,33 +0,0 @@
   676.4 -#if !defined(AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_)
   676.5 -#define AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_
   676.6 -
   676.7 -#if _MSC_VER > 1000
   676.8 -#pragma once
   676.9 -#endif // _MSC_VER > 1000
  676.10 -
  676.11 -// -*- C++ -*-
  676.12 -// WavWriter.h: interface for the WavWriter class.
  676.13 -//
  676.14 -
  676.15 -#include <mmreg.h>
  676.16 -
  676.17 -class WavWriter  
  676.18 -{
  676.19 - private:
  676.20 -  FILE *m_file;
  676.21 -  int m_len;
  676.22 -  long m_posSize;
  676.23 -
  676.24 - public:
  676.25 -  WavWriter();
  676.26 -  ~WavWriter();
  676.27 -
  676.28 -  bool Open(const char *name);
  676.29 -  void SetFormat(const WAVEFORMATEX *format);
  676.30 -  void AddSound(const u8 *data, int len);
  676.31 -
  676.32 - private:
  676.33 -  void Close();
  676.34 -};
  676.35 -
  676.36 -#endif // !defined(AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_)
   677.1 --- a/src/win32/WinHelper.h	Sat Mar 03 10:54:39 2012 -0600
   677.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   677.3 @@ -1,229 +0,0 @@
   677.4 -/*----------------------------------------------------------------------
   677.5 -   Copyright (c) 1998 Gipsysoft. All Rights Reserved.
   677.6 -   Please see the file "licence.txt" for licencing details.
   677.7 -   File:   WinHelper.h
   677.8 -   Owner:  russf@gipsysoft.com
   677.9 -   Purpose:        Windows helper functions, classes, structures and macros
  677.10 -   that make life a little easier
  677.11 -   These should all be zero impact classes etc. that is they
  677.12 -   should *not* have a cpp file associated with them.
  677.13 -   ----------------------------------------------------------------------*/
  677.14 -#ifndef WINHELPER_H
  677.15 -#define WINHELPER_H
  677.16 -
  677.17 -//#ifndef DEBUGHLP_H
  677.18 -//      #include <DebugHlp.h>
  677.19 -//#endif        //      DEBUGHLP_H
  677.20 -
  677.21 -#ifndef FASTCALL
  677.22 -#define FASTCALL
  677.23 -#endif  //      FASTCALL
  677.24 -
  677.25 -extern void AssertFailed(char *, int, char *);
  677.26 -extern void ApiFailure(char *, int, char *);
  677.27 -
  677.28 -#define R_VERIFY(a) R_ASSERT(a)
  677.29 -#define R_ASSERT(a) \
  677.30 -    do { \
  677.31 -		if (!(a)) { \
  677.32 -			AssertFailed(__FILE__, __LINE__, # a); \
  677.33 -		} \
  677.34 -	} while (0);
  677.35 -
  677.36 -#define VAPI(a) \
  677.37 -    do { \
  677.38 -		if (!(a)) { \
  677.39 -			ApiFailure(__FILE__, __LINE__, # a); \
  677.40 -		} \
  677.41 -	} while (0);
  677.42 -
  677.43 -#define ASSERT_VALID_HWND(a) ASSERT(::IsWindow(a))
  677.44 -
  677.45 -namespace WinHelper
  677.46 -{
  677.47 -	class CSize : public tagSIZE
  677.48 -		//
  677.49 -		//      Wrapper for the SIZE structure
  677.50 -	{
  677.51 -public:
  677.52 -		inline CSize() {};
  677.53 -		inline explicit CSize(const SIZE &size) { cx = size.cx; cy = size.cy; }
  677.54 -		inline explicit CSize(long nSizeX, long nSizeY) { cx = nSizeX; cy = nSizeY; }
  677.55 -		inline void Set(long nSizeX, long nSizeY) { cx = nSizeX; cy = nSizeY; }
  677.56 -		inline operator LPSIZE() { return this; };
  677.57 -
  677.58 -		inline bool operator !=(const SIZE &size) const { return cx != size.cx || cy != size.cy;}
  677.59 -		inline CSize & operator =(const SIZE &size) { cx = size.cx; cy = size.cy; return *this; }
  677.60 -		inline void Empty() { cx = cy = 0; }
  677.61 -	};
  677.62 -
  677.63 -	class CRect : public tagRECT
  677.64 -		//
  677.65 -		//      Wrapper for a RECT structure
  677.66 -	{
  677.67 -public:
  677.68 -		inline CRect() {}
  677.69 -		//      Initialisation constructor
  677.70 -		inline explicit CRect(const RECT& rhs) { Set(rhs.left, rhs.top, rhs.right, rhs.bottom);}
  677.71 -		inline CRect(int xLeft, int yTop, int xRight, int yBottom) { Set(xLeft, yTop, xRight, yBottom); }
  677.72 -		//      Get the width of the rectangle
  677.73 -		inline int Width() const { return right - left; }
  677.74 -		//      Get the height of the rectangle
  677.75 -		inline int Height() const { return bottom - top; }
  677.76 -		//      overloaded operator so you don't have to do &rc anymore
  677.77 -		inline operator LPCRECT() const { return this; };
  677.78 -		inline operator LPRECT() { return this; };
  677.79 -		//      Return the SIZE of the rectangle;
  677.80 -		inline CSize Size() const { CSize s(Width(), Height()); return s; }
  677.81 -		//      Return the top left of the rectangle
  677.82 -		inline POINT TopLeft() const { POINT pt = { left, top }; return pt; }
  677.83 -		//      Return the bottom right of the rectangle
  677.84 -		inline POINT BottomRight() const { POINT pt = { right, bottom }; return pt; }
  677.85 -		//      Set the rectangles left, top, right and bottom
  677.86 -		inline void Set(int xLeft, int yTop, int xRight, int yBottom) { top = yTop; bottom = yBottom; right = xRight; left =
  677.87 -			                                                                xLeft; }
  677.88 -		//      Return true if the rectangle contains all zeros
  677.89 -		inline bool IsEmpty() const { return left == 0 && right == 0 && top == 0 && bottom == 0 ? true : false; }
  677.90 -		//      Zero out our rectangle
  677.91 -		inline void Empty() { left = right = top = bottom = 0; }
  677.92 -		//      Set the size of the rect but leave the top left position untouched.
  677.93 -		inline void SetSize(const CSize &size) { bottom = top + size.cy; right = left + size.cx; }
  677.94 -		inline void SetSize(const SIZE &size) { bottom = top + size.cy; right = left + size.cx; }
  677.95 -		inline void SetSize(int cx, int cy) { bottom = top + cy; right = left + cx; }
  677.96 -		//      Move the rectangle by an offset
  677.97 -		inline void Offset(int cx, int cy)
  677.98 -		{
  677.99 -			top    += cy;
 677.100 -			bottom += cy;
 677.101 -			right  += cx;
 677.102 -			left   += cx;
 677.103 -		}
 677.104 -
 677.105 -		//      Inflate the rectangle by the cx and cy, use negative to shrink the rectangle
 677.106 -		inline void Inflate(int cx, int cy)
 677.107 -		{
 677.108 -			top    -= cy;
 677.109 -			bottom += cy;
 677.110 -			right  += cx;
 677.111 -			left   -= cx;
 677.112 -		}
 677.113 -
 677.114 -		//      Assignment from a RECT
 677.115 -		inline CRect &operator =(const RECT&rhs)
 677.116 -		{
 677.117 -			left  = rhs.left; top = rhs.top;
 677.118 -			right = rhs.right; bottom = rhs.bottom;
 677.119 -			return *this;
 677.120 -		}
 677.121 -
 677.122 -		//      Return true if the point passed is within the rectangle
 677.123 -		inline bool PtInRect(const POINT &pt) const {       return  (pt.x >= left && pt.x < right && pt.y >= top && pt.y <
 677.124 -			                                                         bottom); }
 677.125 -		//      Return true if the rectangle passed overlaps this rectangle
 677.126 -		inline bool Intersect(const RECT &rc) const { return (rc.left < right &&
 677.127 -			                                                            rc.right > left && rc.top < bottom && rc.bottom > top); }
 677.128 -	};
 677.129 -
 677.130 -	class CPoint : public tagPOINT
 677.131 -		//
 677.132 -		//      Wrapper for the POINT structure
 677.133 -	{
 677.134 -public:
 677.135 -		inline CPoint() {};
 677.136 -		inline CPoint(LPARAM lParam) { x = LOWORD(lParam); y = HIWORD(lParam); }
 677.137 -		inline CPoint(int nX, int nY) { x = nX; y = nY; }
 677.138 -		inline CPoint(const POINT &pt) { x = pt.x; y = pt.y; }
 677.139 -		inline bool operator ==(const CPoint &rhs) const { return x == rhs.x && y == rhs.y; }
 677.140 -		inline bool operator !=(const CPoint &rhs) const { return x != rhs.x || y != rhs.y; }
 677.141 -		inline operator LPPOINT() { return this; }
 677.142 -	};
 677.143 -
 677.144 -	class CScrollInfo : public tagSCROLLINFO
 677.145 -	{
 677.146 -public:
 677.147 -		CScrollInfo(UINT fPassedMask) { cbSize = sizeof(tagSCROLLINFO); fMask = fPassedMask; }
 677.148 -	};
 677.149 -
 677.150 -	class CCriticalSection
 677.151 -	//
 677.152 -	//      Simple crtical section handler/wrapper
 677.153 -	{
 677.154 -public:
 677.155 -		inline CCriticalSection()       { ::InitializeCriticalSection(&m_sect); }
 677.156 -		inline ~CCriticalSection() { ::DeleteCriticalSection(&m_sect); }
 677.157 -
 677.158 -		//      Blocking lock.
 677.159 -		inline void Lock()                      { ::EnterCriticalSection(&m_sect); }
 677.160 -		//      Unlock
 677.161 -		inline void Unlock()            { ::LeaveCriticalSection(&m_sect); }
 677.162 -
 677.163 -		class CLock
 677.164 -		//
 677.165 -		//      Simple lock class for the critcal section
 677.166 -		{
 677.167 -public:
 677.168 -			inline CLock(CCriticalSection &sect) : m_sect(sect) { m_sect.Lock(); }
 677.169 -			inline ~CLock() { m_sect.Unlock(); }
 677.170 -private:
 677.171 -			CCriticalSection &m_sect;
 677.172 -
 677.173 -			CLock();
 677.174 -			CLock(const CLock &);
 677.175 -			CLock & operator =(const CLock &);
 677.176 -		};
 677.177 -private:
 677.178 -		CRITICAL_SECTION m_sect;
 677.179 -
 677.180 -		CCriticalSection(const CCriticalSection &);
 677.181 -		CCriticalSection & operator =(const CCriticalSection &);
 677.182 -	};
 677.183 -
 677.184 -#define ZeroStructure(t) ZeroMemory(&t, sizeof(t))
 677.185 -#define countof(t)    (sizeof((t)) / sizeof((t)[0]))
 677.186 -#define UNREF(P) UNREFERENCED_PARAMETER(P)
 677.187 -
 677.188 -	inline bool IsShiftPressed()
 677.189 -	{
 677.190 -		return GetKeyState(VK_SHIFT) & 0x8000 ? true : false;
 677.191 -	}
 677.192 -
 677.193 -	inline bool IsAltPressed()
 677.194 -	{
 677.195 -		return GetKeyState(VK_MENU) & 0x8000 ? true : false;
 677.196 -	}
 677.197 -
 677.198 -	inline bool IsControlPressed()
 677.199 -	{
 677.200 -		return GetKeyState(VK_CONTROL) & 0x8000 ? true : false;
 677.201 -	}
 677.202 -
 677.203 -	inline HICON LoadIcon16x16(HINSTANCE hInst, UINT uID)
 677.204 -	//
 677.205 -	//      Load a 16x16 icon from the same resource as the other size icons.
 677.206 -	{
 677.207 -		return reinterpret_cast<HICON>(::LoadImage(hInst, MAKEINTRESOURCE(uID), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
 677.208 -	}
 677.209 -
 677.210 -	class CDeferWindowPos
 677.211 -	//
 677.212 -	//      Wrapper for the Begin, Defer and End WindowPos functions. Nothing glamorous.
 677.213 -	{
 677.214 -public:
 677.215 -		inline CDeferWindowPos(const int nWindows = 1) : m_hdlDef(::BeginDeferWindowPos(nWindows)) {}
 677.216 -		inline ~CDeferWindowPos() { R_VERIFY(::EndDeferWindowPos(m_hdlDef)); }
 677.217 -		inline HDWP DeferWindowPos(HWND hWnd, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
 677.218 -		{
 677.219 -			return ::DeferWindowPos(m_hdlDef, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags);
 677.220 -		}
 677.221 -
 677.222 -		inline HDWP DeferWindowPos(HWND hWnd, HWND hWndInsertAfter, const CRect &rc, UINT uFlags)
 677.223 -		{
 677.224 -			return ::DeferWindowPos(m_hdlDef, hWnd, hWndInsertAfter, rc.left, rc.top, rc.Width(), rc.Height(), uFlags);
 677.225 -		}
 677.226 -
 677.227 -private:
 677.228 -		HDWP m_hdlDef;
 677.229 -	};
 677.230 -}       //      WinHelper
 677.231 -
 677.232 -#endif //WINHELPER_H
   678.1 --- a/src/win32/WinMiscUtil.cpp	Sat Mar 03 10:54:39 2012 -0600
   678.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   678.3 @@ -1,497 +0,0 @@
   678.4 -#include "stdafx.h"
   678.5 -#include "WinMiscUtil.h"
   678.6 -#include "WinResUtil.h"
   678.7 -#include "resource.h"
   678.8 -#include "../NLS.h"
   678.9 -#include "VBA.h"
  678.10 -#include "Reg.h"
  678.11 -#include "../common/movie.h"
  678.12 -#include <direct.h>
  678.13 -
  678.14 -#include "GSACodeSelect.h"
  678.15 -#include "../gba/GBACheats.h"
  678.16 -#include "../gb/gbCheats.h"
  678.17 -
  678.18 -// #undef WinDef macro garbage
  678.19 -#ifdef max
  678.20 -#undef max
  678.21 -#endif
  678.22 -
  678.23 -#ifdef min
  678.24 -#undef min
  678.25 -#endif
  678.26 -
  678.27 -using std::max;
  678.28 -using std::min;
  678.29 -
  678.30 -extern int emulating;
  678.31 -
  678.32 -extern const char IDS_ROM_DIR[]		= "romDir";
  678.33 -extern const char IDS_GBXROM_DIR[]	= "gbromDir";
  678.34 -extern const char IDS_BATTERY_DIR[]	= "batteryDir";
  678.35 -extern const char IDS_SAVE_DIR[]	= "saveDir";
  678.36 -extern const char IDS_MOVIE_DIR[]	= "moviesDir";
  678.37 -extern const char IDS_CHEAT_DIR[]	= "cheatsDir";
  678.38 -extern const char IDS_LUA_DIR[]		= "luaDir";
  678.39 -extern const char IDS_IPS_DIR[]		= "ipsDir";
  678.40 -extern const char IDS_AVI_DIR[]		= "aviRecordDir";
  678.41 -extern const char IDS_WAV_DIR[]		= "soundRecordDir";
  678.42 -extern const char IDS_CAPTURE_DIR[] = "captureDir";
  678.43 -extern const char IDS_WATCH_DIR[]	= "watchDir";
  678.44 -
  678.45 -extern const char IDS_ROM_DEFAULT_DIR[]		= "\\roms";
  678.46 -extern const char IDS_GBXROM_DEFAULT_DIR[]	= "\\gbroms";
  678.47 -extern const char IDS_BATTERY_DEFAULT_DIR[]	= "\\battery";
  678.48 -extern const char IDS_SAVE_DEFAULT_DIR[]	= "\\save";
  678.49 -extern const char IDS_MOVIE_DEFAULT_DIR[]	= "\\movies";
  678.50 -extern const char IDS_CHEAT_DEFAULT_DIR[]	= "\\cheats";
  678.51 -extern const char IDS_LUA_DEFAULT_DIR[]		= "\\lua";
  678.52 -extern const char IDS_IPS_DEFAULT_DIR[]		= "\\ips";
  678.53 -extern const char IDS_AVI_DEFAULT_DIR[]		= "\\avi";
  678.54 -extern const char IDS_WAV_DEFAULT_DIR[]		= "\\wav";
  678.55 -extern const char IDS_CAPTURE_DEFAULT_DIR[] = "\\screen";
  678.56 -extern const char IDS_WATCH_DEFAULT_DIR[]	= "\\watches";
  678.57 -
  678.58 -extern const char *IDS_tbl[] = {
  678.59 -	IDS_ROM_DIR,   IDS_GBXROM_DIR, IDS_BATTERY_DIR, IDS_SAVE_DIR, 
  678.60 -	IDS_MOVIE_DIR, IDS_CHEAT_DIR,  IDS_LUA_DIR,     IDS_IPS_DIR, 
  678.61 -	IDS_AVI_DIR,   IDS_WAV_DIR,    IDS_CAPTURE_DIR, IDS_WATCH_DIR
  678.62 -};
  678.63 -
  678.64 -extern const char *IDS_def_tbl[] = {
  678.65 -	IDS_ROM_DEFAULT_DIR,   IDS_GBXROM_DEFAULT_DIR, IDS_BATTERY_DEFAULT_DIR, IDS_SAVE_DEFAULT_DIR, 
  678.66 -	IDS_MOVIE_DEFAULT_DIR, IDS_CHEAT_DEFAULT_DIR,  IDS_LUA_DEFAULT_DIR,     IDS_IPS_DEFAULT_DIR, 
  678.67 -	IDS_AVI_DEFAULT_DIR,   IDS_WAV_DEFAULT_DIR,    IDS_CAPTURE_DEFAULT_DIR, IDS_WATCH_DEFAULT_DIR
  678.68 -};
  678.69 -
  678.70 -// these could be made VBA members, but  the VBA class is already oversized too much
  678.71 -//
  678.72 -
  678.73 -bool winFileExists(const CString &filename)
  678.74 -{
  678.75 -	FILE *f = fopen(filename, "rb");
  678.76 -	if (f)
  678.77 -	{
  678.78 -		fclose(f);
  678.79 -		return true;
  678.80 -	}
  678.81 -	return false;
  678.82 -}
  678.83 -
  678.84 -bool winIsDriveRoot(const CString &file)
  678.85 -{
  678.86 -	if (file.GetLength() == 3)
  678.87 -	{
  678.88 -		if (file[1] == ':' && file[2] == '\\')
  678.89 -			return true;
  678.90 -	}
  678.91 -	return false;
  678.92 -}
  678.93 -
  678.94 -CString winGetOriginalFilename(const CString &file)
  678.95 -{
  678.96 -	int index = file.Find('|');
  678.97 -
  678.98 -	if (index != -1)
  678.99 -		return file.Left(index);
 678.100 -	else
 678.101 -		return file;
 678.102 -}
 678.103 -
 678.104 -CString winGetDirFromFilename(const CString &file)
 678.105 -{
 678.106 -	CString temp  = winGetOriginalFilename(file);
 678.107 -	int		index = max(temp.ReverseFind('/'), temp.ReverseFind('\\'));
 678.108 -	if (index != -1)
 678.109 -	{
 678.110 -		temp = temp.Left(index);
 678.111 -		if (temp.GetLength() == 2 && temp[1] == ':')
 678.112 -			temp += "\\";
 678.113 -	}
 678.114 -
 678.115 -	return temp;
 678.116 -}
 678.117 -
 678.118 -CString winGetDestDir(const CString &TargetDirReg)
 678.119 -{
 678.120 -	CString targetDir = regQueryStringValue(TargetDirReg, NULL);
 678.121 -	int pos = targetDir.ReverseFind('\\');
 678.122 -	if (pos > 0 && pos == targetDir.GetLength() - 1)
 678.123 -		targetDir.Delete(pos);
 678.124 -
 678.125 -	// it makes no sense to create rom directories
 678.126 -	// see MainWnd::winFileOpenSelect for more info
 678.127 -	if (!TargetDirReg.Compare(IDS_ROM_DIR) || !TargetDirReg.Compare(IDS_GBXROM_DIR))
 678.128 -		return targetDir;
 678.129 -
 678.130 -	if (targetDir.IsEmpty())
 678.131 -	{
 678.132 -		targetDir = theApp.exeDir;		// reset the targetDir to the application's path
 678.133 -		if (!TargetDirReg.Compare(IDS_BATTERY_DIR))
 678.134 -		{
 678.135 -			targetDir += IDS_BATTERY_DEFAULT_DIR;
 678.136 -		}
 678.137 -		else if (!TargetDirReg.Compare(IDS_SAVE_DIR))
 678.138 -		{
 678.139 -			targetDir += IDS_SAVE_DEFAULT_DIR;
 678.140 -		}
 678.141 -		else if (!TargetDirReg.Compare(IDS_MOVIE_DIR))
 678.142 -		{
 678.143 -			targetDir += IDS_MOVIE_DEFAULT_DIR;
 678.144 -		}
 678.145 -		else if (!TargetDirReg.Compare(IDS_CHEAT_DIR))
 678.146 -		{
 678.147 -			targetDir += IDS_CHEAT_DEFAULT_DIR;
 678.148 -		}
 678.149 -		else if (!TargetDirReg.Compare(IDS_LUA_DIR))
 678.150 -		{
 678.151 -			targetDir += IDS_LUA_DEFAULT_DIR;
 678.152 -		}
 678.153 -		else if (!TargetDirReg.Compare(IDS_IPS_DIR))
 678.154 -		{
 678.155 -			targetDir += IDS_IPS_DEFAULT_DIR;
 678.156 -		}
 678.157 -		else if (!TargetDirReg.Compare(IDS_AVI_DIR))
 678.158 -		{
 678.159 -			targetDir += IDS_AVI_DEFAULT_DIR;
 678.160 -		}
 678.161 -		else if (!TargetDirReg.Compare(IDS_WAV_DIR))
 678.162 -		{
 678.163 -			targetDir += IDS_WAV_DEFAULT_DIR;
 678.164 -		}
 678.165 -		else if (!TargetDirReg.Compare(IDS_CAPTURE_DIR))
 678.166 -		{
 678.167 -			targetDir += IDS_CAPTURE_DEFAULT_DIR;
 678.168 -		}
 678.169 -		else if (!TargetDirReg.Compare(IDS_WATCH_DIR))
 678.170 -		{
 678.171 -			targetDir += IDS_WATCH_DEFAULT_DIR;
 678.172 -		}
 678.173 -		regSetStringValue(TargetDirReg, targetDir);	// Add the directory to the INI file
 678.174 -	}
 678.175 -
 678.176 -	_mkdir(targetDir);			// make the directory
 678.177 -
 678.178 -	return targetDir;
 678.179 -}
 678.180 -
 678.181 -CString winGetDestFilename(const CString &LogicalRomName, const CString &TargetDirReg, const CString &ext)
 678.182 -{
 678.183 -	if (LogicalRomName.GetLength() == 0)
 678.184 -		return CString();
 678.185 -
 678.186 -	CString targetDir = winGetDestDir(TargetDirReg);
 678.187 -	targetDir += '\\';
 678.188 -
 678.189 -	CString buffer = LogicalRomName;
 678.190 -
 678.191 -	int index = max(buffer.ReverseFind('/'), max(buffer.ReverseFind('\\'), buffer.ReverseFind('|')));
 678.192 -	if (index != -1)
 678.193 -		buffer = buffer.Right(buffer.GetLength() - index - 1);
 678.194 -
 678.195 -	index = buffer.ReverseFind('.');
 678.196 -	if (index != -1)
 678.197 -		buffer = buffer.Left(index);
 678.198 -
 678.199 -	CString filename;
 678.200 -	filename.Format("%s%s%s", targetDir, buffer, ext);
 678.201 -	bool fileExists = winFileExists(filename);
 678.202 -
 678.203 -	// check for old style of naming, for better backward compatibility
 678.204 -	if (!fileExists || theApp.filenamePreference == 0)
 678.205 -	{
 678.206 -		index = LogicalRomName.Find('|');
 678.207 -		if (index != -1)
 678.208 -		{
 678.209 -			buffer = LogicalRomName.Left(index);
 678.210 -			index  = max(buffer.ReverseFind('/'), buffer.ReverseFind('\\'));
 678.211 -
 678.212 -			int dotIndex = buffer.ReverseFind('.');
 678.213 -			if (dotIndex > index)
 678.214 -				buffer = buffer.Left(dotIndex);
 678.215 -
 678.216 -			if (index != -1)
 678.217 -				buffer = buffer.Right(buffer.GetLength() - index - 1);
 678.218 -
 678.219 -			CString filename2;
 678.220 -			filename2.Format("%s%s%s", targetDir, buffer, ext);
 678.221 -			bool file2Exists = winFileExists(filename2);
 678.222 -
 678.223 -			if ((file2Exists && !fileExists) || (theApp.filenamePreference == 0 && (file2Exists || !fileExists)))
 678.224 -				return filename2;
 678.225 -		}
 678.226 -	}
 678.227 -
 678.228 -	return filename;
 678.229 -}
 678.230 -
 678.231 -CString winGetSavestateFilename(const CString &LogicalRomName, int nID)
 678.232 -{
 678.233 -	CString		ext;
 678.234 -//	size_t		startindex;	// forget about C89/ANSI-C
 678.235 -//	size_t		endindex;
 678.236 -	if (VBAMovieActive() && theApp.AsscWithSaveState)
 678.237 -	{
 678.238 -		std::string fs(VBAMovieGetFilename());	// RVO tip
 678.239 -		size_t startindex = fs.find_last_of("/\\") ;
 678.240 -		if (startindex < fs.length())
 678.241 -			++startindex;	// luckily the found character can't be at the end of fs
 678.242 -		else
 678.243 -			startindex = 0;
 678.244 -		size_t endindex = fs.find_last_of(".");
 678.245 -		if (endindex < fs.length() && endindex > startindex)
 678.246 -			endindex;	//??
 678.247 -		else
 678.248 -			endindex = fs.length();
 678.249 -		fs = fs.substr(startindex, endindex - startindex);
 678.250 -		ext.Format("-%s-%d.sgm", fs.c_str(), nID);
 678.251 -	}
 678.252 -	else
 678.253 -	{
 678.254 -		ext.Format("%d.sgm", nID);
 678.255 -	}
 678.256 -	return winGetDestFilename(LogicalRomName, IDS_SAVE_DIR, ext);
 678.257 -}
 678.258 -
 678.259 -CString winGetSavestateMenuString(const CString &LogicalRomName, int nID)
 678.260 -{
 678.261 -	CString str;
 678.262 -	if (theApp.showSlotTime)
 678.263 -	{
 678.264 -		CFileStatus status;
 678.265 -		if (emulating && CFile::GetStatus(winGetSavestateFilename(LogicalRomName, nID), status))
 678.266 -		{
 678.267 -			str.Format("#&%d %s", nID, status.m_mtime.Format("%Y/%m/%d %H:%M:%S"));
 678.268 -		}
 678.269 -		else
 678.270 -		{
 678.271 -			str.Format("#&%d ----/--/-- --:--:--", nID);
 678.272 -		}
 678.273 -	}
 678.274 -	else
 678.275 -	{
 678.276 -		str.Format("Slot #&%d", nID);
 678.277 -	}
 678.278 -
 678.279 -	return str;
 678.280 -}
 678.281 -
 678.282 -void winCorrectPath(CString &path)
 678.283 -{
 678.284 -	if (winFileExists(path))
 678.285 -	{
 678.286 -		return;
 678.287 -	}
 678.288 -
 678.289 -	CString tempStr = theApp.exeDir;
 678.290 -	tempStr += "\\";
 678.291 -	tempStr += path;
 678.292 -
 678.293 -	if (winFileExists(tempStr))
 678.294 -	{
 678.295 -		path = tempStr;
 678.296 -		return;
 678.297 -	}
 678.298 -
 678.299 -	for (int i = 0; i < _countof(IDS_tbl); ++i)
 678.300 -	{
 678.301 -		tempStr = winGetDestDir(IDS_tbl[i]);
 678.302 -		tempStr += "\\";
 678.303 -		tempStr += path;
 678.304 -
 678.305 -		if (winFileExists(tempStr))
 678.306 -		{
 678.307 -			path = tempStr;
 678.308 -			return;
 678.309 -		}
 678.310 -	}
 678.311 -}
 678.312 -
 678.313 -void winCorrectPath(char *path)
 678.314 -{
 678.315 -	CString pathCStr(path);
 678.316 -	winCorrectPath(pathCStr);
 678.317 -	strcpy(path, pathCStr);
 678.318 -}
 678.319 -
 678.320 -// some file I/O
 678.321 -
 678.322 -int winScreenCapture(int captureNumber)
 678.323 -{
 678.324 -	CString ext;
 678.325 -	CString captureName;
 678.326 -
 678.327 -	do
 678.328 -	{
 678.329 -		if (theApp.captureFormat == 0)
 678.330 -			ext.Format("_%03d.png", captureNumber);
 678.331 -		else
 678.332 -			ext.Format("_%03d.bmp", captureNumber);
 678.333 -
 678.334 -		captureName = winGetDestFilename(theApp.gameFilename, IDS_CAPTURE_DIR, ext);
 678.335 -		++captureNumber;
 678.336 -	} while (winFileExists(captureName) && captureNumber > 0);
 678.337 -
 678.338 -	if (captureNumber < 0)
 678.339 -	{
 678.340 -		systemMessage(0, "Too many existing files (not less than %d)! Screen capture failed!", captureNumber - 1);
 678.341 -		return 0;
 678.342 -	}
 678.343 -
 678.344 -	if (theApp.captureFormat == 0)
 678.345 -		theApp.emulator.emuWritePNG(captureName);
 678.346 -	else
 678.347 -		theApp.emulator.emuWriteBMP(captureName);
 678.348 -
 678.349 -	systemScreenMessage(winResLoadString(IDS_SCREEN_CAPTURE));
 678.350 -
 678.351 -	return captureNumber;
 678.352 -}
 678.353 -
 678.354 -bool winImportGSACodeFile(CString &fileName)
 678.355 -{
 678.356 -	FILE *f = fopen(fileName, "rb");
 678.357 -
 678.358 -	if (f == NULL)
 678.359 -	{
 678.360 -		systemMessage(MSG_CANNOT_OPEN_FILE, "Cannot open file %s", fileName);
 678.361 -		return false;
 678.362 -	}
 678.363 -
 678.364 -	if (systemCartridgeType == 1)
 678.365 -	{
 678.366 -		fclose(f);
 678.367 -		return gbCheatReadGSCodeFile(fileName);
 678.368 -	}
 678.369 -
 678.370 -	u32 len;
 678.371 -	fread(&len, 1, 4, f);
 678.372 -	if (len != 14)
 678.373 -	{
 678.374 -		fclose(f);
 678.375 -		systemMessage(MSG_UNSUPPORTED_CODE_FILE, "Unsupported code file %s",
 678.376 -		              fileName);
 678.377 -		return false;
 678.378 -	}
 678.379 -	char buffer[16];
 678.380 -	fread(buffer, 1, 14, f);
 678.381 -	buffer[14] = 0;
 678.382 -	if (memcmp(buffer, "SharkPortCODES", 14))
 678.383 -	{
 678.384 -		fclose(f);
 678.385 -		systemMessage(MSG_UNSUPPORTED_CODE_FILE, "Unsupported code file %s",
 678.386 -		              fileName);
 678.387 -		return false;
 678.388 -	}
 678.389 -	fseek(f, 0x1e, SEEK_SET);
 678.390 -	fread(&len, 1, 4, f);
 678.391 -	int game = 0;
 678.392 -	if (len > 1)
 678.393 -	{
 678.394 -		GSACodeSelect dlg(f);
 678.395 -		game = dlg.DoModal();
 678.396 -	}
 678.397 -	fclose(f);
 678.398 -
 678.399 -	bool v3 = false;
 678.400 -
 678.401 -	int index = fileName.ReverseFind('.');
 678.402 -
 678.403 -	if (index != -1)
 678.404 -	{
 678.405 -		if (fileName.Right(3).CompareNoCase("XPC") == 0)
 678.406 -			v3 = true;
 678.407 -	}
 678.408 -
 678.409 -	if (game != -1)
 678.410 -	{
 678.411 -		return cheatsImportGSACodeFile(fileName, game, v3);
 678.412 -	}
 678.413 -
 678.414 -	return true;
 678.415 -}
 678.416 -
 678.417 -void winLoadCheatList(const char *name)
 678.418 -{
 678.419 -	bool res = false;
 678.420 -
 678.421 -	if (systemCartridgeType == 0)
 678.422 -		res = cheatsLoadCheatList(name);
 678.423 -	else
 678.424 -		res = gbCheatsLoadCheatList(name);
 678.425 -
 678.426 -	if (res)
 678.427 -		systemScreenMessage(winResLoadString(IDS_LOADED_CHEATS));
 678.428 -}
 678.429 -
 678.430 -void winSaveCheatList(const char *name)
 678.431 -{
 678.432 -	if (systemCartridgeType == 0)
 678.433 -		cheatsSaveCheatList(name);
 678.434 -	else
 678.435 -		gbCheatsSaveCheatList(name);
 678.436 -}
 678.437 -
 678.438 -void winLoadCheatListDefault()
 678.439 -{
 678.440 -	CString cheatName = winGetDestFilename(theApp.gameFilename, IDS_CHEAT_DIR, ".clt");
 678.441 -
 678.442 -	winLoadCheatList(cheatName);
 678.443 -}
 678.444 -
 678.445 -void winSaveCheatListDefault()
 678.446 -{
 678.447 -	CString cheatName = winGetDestFilename(theApp.gameFilename, IDS_CHEAT_DIR, ".clt");
 678.448 -
 678.449 -	winSaveCheatList(cheatName);
 678.450 -}
 678.451 -
 678.452 -bool winReadBatteryFile()
 678.453 -{
 678.454 -	CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, ".sav");
 678.455 -
 678.456 -	bool res = false;
 678.457 -
 678.458 -	if (theApp.emulator.emuReadBattery)
 678.459 -		res = theApp.emulator.emuReadBattery(batteryName);
 678.460 -
 678.461 -	if (res)
 678.462 -		systemScreenMessage(winResLoadString(IDS_LOADED_BATTERY));
 678.463 -
 678.464 -	return res;
 678.465 -}
 678.466 -
 678.467 -bool winWriteBatteryFile()
 678.468 -{
 678.469 -	CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, ".sav");
 678.470 -
 678.471 -	if (theApp.emulator.emuWriteBattery)
 678.472 -		return theApp.emulator.emuWriteBattery(batteryName);
 678.473 -
 678.474 -	return false;
 678.475 -}
 678.476 -
 678.477 -bool winEraseBatteryFile()
 678.478 -{
 678.479 -	CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, ".sav");
 678.480 -	return !remove(batteryName);
 678.481 -}
 678.482 -
 678.483 -bool winReadSaveGame(const char *name)
 678.484 -{
 678.485 -	if (theApp.emulator.emuReadState)
 678.486 -		return theApp.emulator.emuReadState(name);
 678.487 -	return false;
 678.488 -}
 678.489 -
 678.490 -bool winWriteSaveGame(const char *name)
 678.491 -{
 678.492 -	if (theApp.emulator.emuWriteState)
 678.493 -		return theApp.emulator.emuWriteState(name);
 678.494 -	return false;
 678.495 -}
 678.496 -
 678.497 -bool winEraseSaveGame(const char *name)
 678.498 -{
 678.499 -	return !remove(name);
 678.500 -}
   679.1 --- a/src/win32/WinMiscUtil.h	Sat Mar 03 10:54:39 2012 -0600
   679.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   679.3 @@ -1,45 +0,0 @@
   679.4 -#ifndef VBA_WIN32_WINMISCUTIL_H
   679.5 -#define VBA_WIN32_WINMISCUTIL_H
   679.6 -
   679.7 -#if _MSC_VER > 1000
   679.8 -#pragma once
   679.9 -#endif // _MSC_VER > 1000
  679.10 -
  679.11 -extern const char IDS_ROM_DIR[];
  679.12 -extern const char IDS_GBXROM_DIR[];
  679.13 -extern const char IDS_BATTERY_DIR[];
  679.14 -extern const char IDS_SAVE_DIR[];
  679.15 -extern const char IDS_MOVIE_DIR[];
  679.16 -extern const char IDS_CHEAT_DIR[];
  679.17 -extern const char IDS_LUA_DIR[];
  679.18 -extern const char IDS_IPS_DIR[];
  679.19 -extern const char IDS_AVI_DIR[];
  679.20 -extern const char IDS_WAV_DIR[];
  679.21 -extern const char IDS_CAPTURE_DIR[];
  679.22 -extern const char IDS_WATCH_DIR[];
  679.23 -
  679.24 -extern bool winFileExists(const CString &filename);
  679.25 -extern bool winIsDriveRoot(const CString &file);
  679.26 -extern CString winGetOriginalFilename(const CString &file);
  679.27 -extern CString winGetDirFromFilename(const CString &file);
  679.28 -extern CString winGetSavestateFilename(const CString &LogicalRomName, int nID);
  679.29 -extern CString winGetSavestateMenuString(const CString &LogicalRomName, int nID);
  679.30 -extern CString winGetDestDir(const CString &TargetDirReg);
  679.31 -extern CString winGetDestFilename(const CString &LogicalRomName, const CString &TargetDirReg, const CString &ext);
  679.32 -extern void winCorrectPath(CString &path);
  679.33 -extern void winCorrectPath(char *path);
  679.34 -
  679.35 -int winScreenCapture(int captureNumber = 0);
  679.36 -bool winImportGSACodeFile(CString& fileName);
  679.37 -void winLoadCheatList(const char *name);
  679.38 -void winSaveCheatList(const char *name);
  679.39 -void winLoadCheatListDefault();
  679.40 -void winSaveCheatListDefault();
  679.41 -bool winReadBatteryFile();
  679.42 -bool winWriteBatteryFile();
  679.43 -bool winEraseBatteryFile();
  679.44 -bool winReadSaveGame(const char *name);
  679.45 -bool winWriteSaveGame(const char *name);
  679.46 -bool winEraseSaveGame(const char *name);
  679.47 -
  679.48 -#endif // VBA_WIN32_WINMISCUTIL_H
   680.1 --- a/src/win32/WinResUtil.cpp	Sat Mar 03 10:54:39 2012 -0600
   680.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   680.3 @@ -1,99 +0,0 @@
   680.4 -#include "stdafx.h"
   680.5 -#include "WinResUtil.h"
   680.6 -
   680.7 -static HINSTANCE winResGetInstance(LPCTSTR resType, LPCTSTR resName)
   680.8 -{
   680.9 -	// TODO: make language DLL first
  680.10 -	return AfxFindResourceHandle(resName, resType);
  680.11 -}
  680.12 -
  680.13 -UCHAR *winResGetResource(LPCTSTR resType, LPCTSTR resName)
  680.14 -{
  680.15 -	HINSTANCE winResInstance = winResGetInstance(resType, resName);
  680.16 -
  680.17 -	HRSRC hRsrc = FindResourceEx(winResInstance, resType, resName, 0);
  680.18 -
  680.19 -	if (hRsrc != NULL)
  680.20 -	{
  680.21 -		HGLOBAL hGlobal = LoadResource(winResInstance, hRsrc);
  680.22 -
  680.23 -		if (hGlobal != NULL)
  680.24 -		{
  680.25 -			UCHAR *b = (UCHAR *)LockResource(hGlobal);
  680.26 -
  680.27 -			return b;
  680.28 -		}
  680.29 -	}
  680.30 -	return NULL;
  680.31 -}
  680.32 -
  680.33 -HMENU winResLoadMenu(LPCTSTR menuName)
  680.34 -{
  680.35 -	UCHAR *b = winResGetResource(RT_MENU, menuName);
  680.36 -
  680.37 -	if (b != NULL)
  680.38 -	{
  680.39 -		HMENU menu = LoadMenuIndirect((CONST MENUTEMPLATE *)b);
  680.40 -
  680.41 -		if (menu != NULL)
  680.42 -			return menu;
  680.43 -	}
  680.44 -
  680.45 -	return LoadMenu(NULL, menuName);
  680.46 -}
  680.47 -
  680.48 -int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc, LPARAM lParam)
  680.49 -{
  680.50 -	/*
  680.51 -	   UCHAR * b = winResGetResource(RT_DIALOG, boxName);
  680.52 -
  680.53 -	   if(b != NULL) {
  680.54 -
  680.55 -	   return DialogBoxIndirectParam(hInstance,
  680.56 -	   (LPCDLGTEMPLATE)b,
  680.57 -	   parent,
  680.58 -	   dlgProc,
  680.59 -	   lParam);
  680.60 -	   }
  680.61 -
  680.62 -	   return DialogBoxParam(hInstance,
  680.63 -	   boxName,
  680.64 -	   parent,
  680.65 -	   dlgProc,
  680.66 -	   lParam);
  680.67 -	 */
  680.68 -	return 0;
  680.69 -}
  680.70 -
  680.71 -int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc)
  680.72 -{
  680.73 -	return winResDialogBox(boxName,
  680.74 -	                       parent,
  680.75 -	                       dlgProc,
  680.76 -	                       0);
  680.77 -}
  680.78 -
  680.79 -CString winResLoadString(UINT id)
  680.80 -{
  680.81 -	int       stId = id / 16 + 1;
  680.82 -	HINSTANCE inst = winResGetInstance(RT_STRING, MAKEINTRESOURCE(stId));
  680.83 -
  680.84 -	CString res;
  680.85 -	if (!res.LoadString(id))
  680.86 -	{
  680.87 -		// TODO: handle case where string is only in the default English
  680.88 -		res = "";
  680.89 -	}
  680.90 -
  680.91 -	res.Replace('_', '|');
  680.92 -
  680.93 -	return res;
  680.94 -}
  680.95 -
  680.96 -CString winResLoadFilter(UINT id)
  680.97 -{
  680.98 -	CString res = winResLoadString(id);
  680.99 -	res.Replace('_', '|');
 680.100 -
 680.101 -	return res;
 680.102 -}
   681.1 --- a/src/win32/WinResUtil.h	Sat Mar 03 10:54:39 2012 -0600
   681.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   681.3 @@ -1,14 +0,0 @@
   681.4 -#ifndef VBA_WIN32_WINRESUTIL_H
   681.5 -#define VBA_WIN32_WINRESUTIL_H
   681.6 -
   681.7 -#if _MSC_VER > 1000
   681.8 -#pragma once
   681.9 -#endif // _MSC_VER > 1000
  681.10 -
  681.11 -extern HMENU winResLoadMenu(LPCTSTR menuName);
  681.12 -extern int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc);
  681.13 -extern int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc, LPARAM lParam);
  681.14 -extern CString winResLoadString(UINT id);
  681.15 -extern CString winResLoadFilter(UINT id);
  681.16 -
  681.17 -#endif // VBA_WIN32_WINRESUTIL_H
   682.1 --- a/src/win32/ZoomControl.cpp	Sat Mar 03 10:54:39 2012 -0600
   682.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   682.3 @@ -1,166 +0,0 @@
   682.4 -// ZoomControl.cpp : implementation file
   682.5 -//
   682.6 -
   682.7 -#include "stdafx.h"
   682.8 -#include "ZoomControl.h"
   682.9 -
  682.10 -bool ZoomControl::isRegistered = false;
  682.11 -
  682.12 -/////////////////////////////////////////////////////////////////////////////
  682.13 -// ZoomControl
  682.14 -
  682.15 -ZoomControl::ZoomControl()
  682.16 -{
  682.17 -	ZeroMemory(colors, 3*64);
  682.18 -	selected = -1;
  682.19 -	registerClass();
  682.20 -}
  682.21 -
  682.22 -ZoomControl::~ZoomControl()
  682.23 -{}
  682.24 -
  682.25 -BEGIN_MESSAGE_MAP(ZoomControl, CWnd)
  682.26 -//{{AFX_MSG_MAP(ZoomControl)
  682.27 -ON_WM_PAINT()
  682.28 -ON_WM_LBUTTONDOWN()
  682.29 -ON_WM_ERASEBKGND()
  682.30 -//}}AFX_MSG_MAP
  682.31 -END_MESSAGE_MAP()
  682.32 -
  682.33 -/////////////////////////////////////////////////////////////////////////////
  682.34 -// ZoomControl message handlers
  682.35 -
  682.36 -void ZoomControl::registerClass()
  682.37 -{
  682.38 -	if (!isRegistered)
  682.39 -	{
  682.40 -		WNDCLASS wc;
  682.41 -		ZeroMemory(&wc, sizeof(wc));
  682.42 -		wc.style         = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
  682.43 -		wc.lpfnWndProc   = (WNDPROC) ::DefWindowProc;
  682.44 -		wc.hInstance     = AfxGetInstanceHandle();
  682.45 -		wc.hIcon         = NULL;
  682.46 -		wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  682.47 -		wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
  682.48 -		wc.lpszMenuName  = NULL;
  682.49 -		wc.lpszClassName = "VbaZoomControl";
  682.50 -		AfxRegisterClass(&wc);
  682.51 -		isRegistered = true;
  682.52 -	}
  682.53 -}
  682.54 -
  682.55 -void ZoomControl::OnPaint()
  682.56 -{
  682.57 -	CPaintDC dc(this); // device context for painting
  682.58 -
  682.59 -	RECT rect;
  682.60 -	GetClientRect(&rect);
  682.61 -
  682.62 -	int w = rect.right - rect.left;
  682.63 -	int h = rect.bottom - rect.top;
  682.64 -
  682.65 -	CDC memDC ;
  682.66 -	memDC.CreateCompatibleDC(&dc);
  682.67 -	CBitmap bitmap, *pOldBitmap;
  682.68 -	bitmap.CreateCompatibleBitmap(&dc, w, h);
  682.69 -
  682.70 -	pOldBitmap = memDC.SelectObject(&bitmap);
  682.71 -
  682.72 -	int multX = w / 8;
  682.73 -	int multY = h / 8;
  682.74 -
  682.75 -	int i;
  682.76 -	for (i = 0; i < 64; i++)
  682.77 -	{
  682.78 -		CBrush b;
  682.79 -		b.CreateSolidBrush(RGB(colors[i*3+2], colors[i*3+1], colors[i*3]));
  682.80 -
  682.81 -		RECT r;
  682.82 -		int  x = i & 7;
  682.83 -		int  y = i / 8;
  682.84 -		r.top    = y*multY;
  682.85 -		r.left   = x*multX;
  682.86 -		r.bottom = r.top + multY;
  682.87 -		r.right  = r.left + multX;
  682.88 -		memDC.FillRect(&r, &b);
  682.89 -		b.DeleteObject();
  682.90 -	}
  682.91 -
  682.92 -	CPen pen;
  682.93 -	pen.CreatePen(PS_SOLID, 1, RGB(192, 192, 192));
  682.94 -	CPen *old = (CPen *)memDC.SelectObject(&pen);
  682.95 -
  682.96 -	for (i = 0; i < 8; i++)
  682.97 -	{
  682.98 -		memDC.MoveTo(0, i * multY);
  682.99 -		memDC.LineTo(w, i * multY);
 682.100 -		memDC.MoveTo(i * multX, 0);
 682.101 -		memDC.LineTo(i * multX, h);
 682.102 -	}
 682.103 -
 682.104 -	if (selected != -1)
 682.105 -	{
 682.106 -		CPen pen2;
 682.107 -		pen2.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
 682.108 -		CPen *old2 = (CPen *)memDC.SelectObject(&pen2);
 682.109 -
 682.110 -		int startX = (selected & 7)*multX+1;
 682.111 -		int startY = (selected / 8)*multY+1;
 682.112 -		int endX   = startX + multX-2;
 682.113 -		int endY   = startY + multY-2;
 682.114 -
 682.115 -		memDC.MoveTo(startX, startY);
 682.116 -		memDC.LineTo(endX, startY);
 682.117 -		memDC.LineTo(endX, endY);
 682.118 -		memDC.LineTo(startX, endY);
 682.119 -		memDC.LineTo(startX, startY-1);
 682.120 -		memDC.SelectObject(old2);
 682.121 -		pen2.DeleteObject();
 682.122 -	}
 682.123 -	memDC.SelectObject(old);
 682.124 -	pen.DeleteObject();
 682.125 -
 682.126 -	dc.BitBlt(0, 0, w, h,
 682.127 -	          &memDC, 0, 0, SRCCOPY);
 682.128 -
 682.129 -	memDC.SelectObject(pOldBitmap);
 682.130 -	bitmap.DeleteObject();
 682.131 -	memDC.DeleteDC();
 682.132 -}
 682.133 -
 682.134 -void ZoomControl::OnLButtonDown(UINT nFlags, CPoint point)
 682.135 -{
 682.136 -	RECT rect;
 682.137 -	GetClientRect(&rect);
 682.138 -
 682.139 -	int height = rect.bottom - rect.top;
 682.140 -	int width  = rect.right - rect.left;
 682.141 -
 682.142 -	int multX = width / 8;
 682.143 -	int multY = height / 8;
 682.144 -
 682.145 -	selected = point.x / multX + 8 * (point.y / multY);
 682.146 -
 682.147 -	int c     = point.x / multX + 8 * (point.y/multY);
 682.148 -	u16 color = colors[c*3] << 7 |
 682.149 -	            colors[c*3+1] << 2 |
 682.150 -	            (colors[c*3+2] >> 3);
 682.151 -
 682.152 -	GetParent()->PostMessage(WM_COLINFO,
 682.153 -	                         color,
 682.154 -	                         0);
 682.155 -
 682.156 -	Invalidate();
 682.157 -}
 682.158 -
 682.159 -BOOL ZoomControl::OnEraseBkgnd(CDC*pDC)
 682.160 -{
 682.161 -	return TRUE;
 682.162 -}
 682.163 -
 682.164 -void ZoomControl::setColors(const u8 *c)
 682.165 -{
 682.166 -	memcpy(colors, c, 3*64);
 682.167 -	selected = -1;
 682.168 -	Invalidate();
 682.169 -}
   683.1 --- a/src/win32/ZoomControl.h	Sat Mar 03 10:54:39 2012 -0600
   683.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   683.3 @@ -1,56 +0,0 @@
   683.4 -#if !defined(AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_)
   683.5 -#define AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_
   683.6 -
   683.7 -#if _MSC_VER > 1000
   683.8 -#pragma once
   683.9 -#endif // _MSC_VER > 1000
  683.10 -// ZoomControl.h : header file
  683.11 -//
  683.12 -#ifndef WM_COLINFO
  683.13 -#define WM_COLINFO WM_APP+100
  683.14 -#endif
  683.15 -
  683.16 -/////////////////////////////////////////////////////////////////////////////
  683.17 -// ZoomControl window
  683.18 -
  683.19 -class ZoomControl : public CWnd
  683.20 -{
  683.21 -	// Construction
  683.22 -public:
  683.23 -	ZoomControl();
  683.24 -
  683.25 -	// Attributes
  683.26 -public:
  683.27 -	// Operations
  683.28 -public:
  683.29 -	// Overrides
  683.30 -	// ClassWizard generated virtual function overrides
  683.31 -	//{{AFX_VIRTUAL(ZoomControl)
  683.32 -	//}}AFX_VIRTUAL
  683.33 -
  683.34 -	// Implementation
  683.35 -public:
  683.36 -	void setColors(const u8 *c);
  683.37 -	static bool isRegistered;
  683.38 -	virtual ~ZoomControl();
  683.39 -
  683.40 -	// Generated message map functions
  683.41 -protected:
  683.42 -	//{{AFX_MSG(ZoomControl)
  683.43 -	afx_msg void OnPaint();
  683.44 -	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  683.45 -	afx_msg BOOL OnEraseBkgnd(CDC*pDC);
  683.46 -	//}}AFX_MSG
  683.47 -	DECLARE_MESSAGE_MAP()
  683.48 -private:
  683.49 -	int selected;
  683.50 -	u8  colors[3*64];
  683.51 -	void registerClass();
  683.52 -};
  683.53 -
  683.54 -/////////////////////////////////////////////////////////////////////////////
  683.55 -
  683.56 -//{{AFX_INSERT_LOCATION}}
  683.57 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  683.58 -
  683.59 -#endif // !defined(AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_)
   684.1 Binary file src/win32/gbadvance.ico has changed
   685.1 --- a/src/win32/ram_search.cpp	Sat Mar 03 10:54:39 2012 -0600
   685.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   685.3 @@ -1,2127 +0,0 @@
   685.4 -// A few notes about this implementation of a RAM search window:
   685.5 -//
   685.6 -// Speed of update was one of the highest priories.
   685.7 -// This is because I wanted the RAM search window to be able to
   685.8 -// update every single value in RAM every single frame, and
   685.9 -// keep track of the exact number of frames across which each value has changed,
  685.10 -// without causing the emulation to run noticeably slower than normal.
  685.11 -//
  685.12 -// The data representation was changed from one entry per valid address
  685.13 -// to one entry per contiguous range of uneliminated addresses
  685.14 -// which references uniform pools of per-address properties.
  685.15 -// - This saves time when there are many items because
  685.16 -//   it minimizes the amount of data that needs to be stored and processed per address.
  685.17 -// - It also saves time when there are few items because
  685.18 -//   it ensures that no time is wasted in iterating through
  685.19 -//   addresses that have already been eliminated from the search.
  685.20 -//
  685.21 -// The worst-case scenario is when every other item has been
  685.22 -// eliminated from the search, maximizing the number of regions.
  685.23 -// This implementation manages to handle even that pathological case
  685.24 -// acceptably well. In fact, it still updates faster than the previous implementation.
  685.25 -// The time spent setting up or clearing such a large number of regions
  685.26 -// is somewhat horrendous, but it seems reasonable to have poor worst-case speed
  685.27 -// during these sporadic "setup" steps to achieve an all-around faster per-update speed.
  685.28 -// (You can test this case by performing the search: Modulo 2 Is Specific Address 0)
  685.29 -
  685.30 -
  685.31 -#ifdef _WIN32
  685.32 -	#include "stdafx.h"
  685.33 -	#include "resource.h"
  685.34 -	#include "VBA.h"
  685.35 -	//#include <windows.h>
  685.36 -	#include <commctrl.h>
  685.37 -	#include "BaseTsd.h"
  685.38 -	#include "GBACheatsDlg.h"
  685.39 -	#include "GBCheatsDlg.h"
  685.40 -	typedef INT_PTR intptr_t;
  685.41 -#else
  685.42 -	#include "stdint.h"
  685.43 -#endif
  685.44 -#include <cassert>
  685.45 -#include <list>
  685.46 -#include <vector>
  685.47 -
  685.48 -#include "ram_search.h"
  685.49 -#include "ramwatch.h"
  685.50 -#include "../gba/GBAGlobals.h"
  685.51 -#include "../gb/gbGlobals.h"
  685.52 -#include "../common/vbalua.h"
  685.53 -#include "Reg.h"
  685.54 -
  685.55 -static inline u8* HardwareToSoftwareAddress(HWAddressType address)
  685.56 -{
  685.57 -	if(!emulating)
  685.58 -		return NULL;
  685.59 -
  685.60 -	// note: this currently follows the "quick" memory rules,
  685.61 -	// meaning it will miss whatever special cases aren't handled by read/writeMemoryQuick.
  685.62 -	// if this is made more accurate, it may be necessary to reduce regionSearchGranularity.
  685.63 -	if(systemCartridgeType == 0)
  685.64 -	{
  685.65 -		// GBA
  685.66 -		HWAddressType mask = ::map[address >> 24].mask;
  685.67 -		if(!mask || (address & 0xFFFFFF) > mask)
  685.68 -			return NULL;
  685.69 -		return &::map[address >> 24].address[address & mask];
  685.70 -	}
  685.71 -	else
  685.72 -	{
  685.73 -		// GB
  685.74 -		extern int32 gbEchoRAMFixOn;
  685.75 -		if (gbEchoRAMFixOn)
  685.76 -			if (address >= 0xe000 && address < 0xfe00)
  685.77 -				address -= 0x2000;
  685.78 -		if((address>>12) >= sizeof(gbMemoryMap)/sizeof(*gbMemoryMap))
  685.79 -			return NULL;
  685.80 -		return &gbMemoryMap[address>>12][address&0xfff];
  685.81 -	}
  685.82 -}
  685.83 -
  685.84 -
  685.85 -struct MemoryRegion
  685.86 -{
  685.87 -	HWAddressType hardwareAddress; // hardware address of the start of this region
  685.88 -	unsigned int size; // number of bytes to the end of this region
  685.89 -	unsigned char* softwareAddress; // pointer to the start of the live emulator source values for this region
  685.90 -
  685.91 -	unsigned int virtualIndex; // index into s_prevValues, s_curValues, and s_numChanges, valid after being initialized in ResetMemoryRegions()
  685.92 -	unsigned int itemIndex; // index into listbox items, valid when s_itemIndicesInvalid is false
  685.93 -};
  685.94 -
  685.95 -int MAX_RAM_SIZE = 0;
  685.96 -static unsigned char* s_prevValues = 0; // values at last search or reset
  685.97 -static unsigned char* s_curValues = 0; // values at last frame update
  685.98 -static unsigned short* s_numChanges = 0; // number of changes of the item starting at this virtual index address
  685.99 -static MemoryRegion** s_itemIndexToRegionPointer = 0; // used for random access into the memory list (trading memory size to get speed here, too bad it's so much memory), only valid when s_itemIndicesInvalid is false
 685.100 -static BOOL s_itemIndicesInvalid = true; // if true, the link from listbox items to memory regions (s_itemIndexToRegionPointer) and the link from memory regions to list box items (MemoryRegion::itemIndex) both need to be recalculated
 685.101 -static BOOL s_prevValuesNeedUpdate = true; // if true, the "prev" values should be updated using the "cur" values on the next frame update signaled
 685.102 -static unsigned int s_maxItemIndex = 0; // max currently valid item index, the listbox sometimes tries to update things past the end of the list so we need to know this to ignore those attempts
 685.103 -static int s_prevSelCount = -1;
 685.104 -
 685.105 -HWND RamSearchHWnd;
 685.106 -#define hWnd AfxGetMainWnd()->GetSafeHwnd()
 685.107 -#define hInst AfxGetInstanceHandle()
 685.108 -static char Str_Tmp [1024];
 685.109 -
 685.110 -int disableRamSearchUpdate = false;
 685.111 -
 685.112 -
 685.113 -
 685.114 -//static const MemoryRegion s_prgRegion    = {  0x020000, SEGACD_RAM_PRG_SIZE, (unsigned char*)Ram_Prg,     true};
 685.115 -//static const MemoryRegion s_word1MRegion = {  0x200000, SEGACD_1M_RAM_SIZE,  (unsigned char*)Ram_Word_1M, true};
 685.116 -//static const MemoryRegion s_word2MRegion = {  0x200000, SEGACD_2M_RAM_SIZE,  (unsigned char*)Ram_Word_2M, true};
 685.117 -//static const MemoryRegion s_z80Region    = {  0xA00000, Z80_RAM_SIZE,        (unsigned char*)Ram_Z80,     true};
 685.118 -//static const MemoryRegion s_68kRegion    = {  0xFF0000, _68K_RAM_SIZE,       (unsigned char*)Ram_68k,     true};
 685.119 -//static const MemoryRegion s_32xRegion    = {0x06000000, _32X_RAM_SIZE,       (unsigned char*)_32X_Ram,    false};
 685.120 -
 685.121 -// list of contiguous uneliminated memory regions
 685.122 -typedef std::list<MemoryRegion> MemoryList;
 685.123 -static MemoryList s_activeMemoryRegions;
 685.124 -static CRITICAL_SECTION s_activeMemoryRegionsCS;
 685.125 -
 685.126 -// for undo support (could be better, but this way was really easy)
 685.127 -static MemoryList s_activeMemoryRegionsBackup;
 685.128 -static int s_undoType = 0; // 0 means can't undo, 1 means can undo, 2 means can redo
 685.129 -
 685.130 -void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg);
 685.131 -static const int tooManyRegionsForUndo = 10000;
 685.132 -
 685.133 -void ResetMemoryRegions()
 685.134 -{
 685.135 -	systemSoundClearBuffer();
 685.136 -	EnterCriticalSection(&s_activeMemoryRegionsCS);
 685.137 -
 685.138 -	s_activeMemoryRegions.clear();
 685.139 -
 685.140 -	// use HardwareToSoftwareAddress to figure out what all the possible memory regions are,
 685.141 -	// split up wherever there's a discontinuity in the address in our software RAM.
 685.142 -	static const int regionSearchGranularity = 0x100; // if this is too small, we'll waste time (in this function only), but if any region in RAM isn't evenly divisible by this, we might crash.
 685.143 -	HWAddressType hwRegionStart = 0;
 685.144 -	u8* regionStart = NULL;
 685.145 -	u8* regionEnd = NULL;
 685.146 -	for(HWAddressType addr = 0; addr != 0x10000000+regionSearchGranularity; addr += regionSearchGranularity)
 685.147 -	{
 685.148 -		u8* swAddr = HardwareToSoftwareAddress(addr);
 685.149 -		if(regionEnd && swAddr != regionEnd+regionSearchGranularity)
 685.150 -		{
 685.151 -			// hit end of region
 685.152 -			// check to see if it mirrors an existing one (in which case we discard it)
 685.153 -			bool discard = false;
 685.154 -			for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter)
 685.155 -			{
 685.156 -				MemoryRegion& region = *iter;
 685.157 -				if(region.softwareAddress == regionStart)
 685.158 -				{
 685.159 -					unsigned int size = regionSearchGranularity + (regionEnd - regionStart);
 685.160 -					if(size <= region.size)
 685.161 -					{
 685.162 -						discard = true;
 685.163 -					}
 685.164 -					else
 685.165 -					{
 685.166 -						hwRegionStart += region.size;
 685.167 -						regionStart += region.size;
 685.168 -					}
 685.169 -					break;
 685.170 -				}
 685.171 -			}
 685.172 -			
 685.173 -			// don't include ROM in our RAM search (it's too huge)
 685.174 -			if(regionStart == rom || regionStart == gbRom)
 685.175 -				discard = true;
 685.176 -
 685.177 -			// create the region
 685.178 -			if(!discard)
 685.179 -			{
 685.180 -				MemoryRegion region = { hwRegionStart, regionSearchGranularity + (regionEnd - regionStart), regionStart };
 685.181 -				s_activeMemoryRegions.push_back(region);
 685.182 -			}
 685.183 -
 685.184 -			hwRegionStart = 0;
 685.185 -			regionStart = NULL;
 685.186 -			regionEnd = NULL;
 685.187 -		}
 685.188 -		if(swAddr)
 685.189 -		{
 685.190 -			if(regionStart)
 685.191 -			{
 685.192 -				// continue region
 685.193 -				regionEnd = swAddr;
 685.194 -			}
 685.195 -			else
 685.196 -			{
 685.197 -				// start new region
 685.198 -				hwRegionStart = addr;
 685.199 -				regionStart = swAddr;
 685.200 -				regionEnd = swAddr;
 685.201 -			}
 685.202 -		}
 685.203 -	}
 685.204 -
 685.205 -
 685.206 -	int nextVirtualIndex = 0;
 685.207 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter)
 685.208 -	{
 685.209 -		MemoryRegion& region = *iter;
 685.210 -		region.virtualIndex = nextVirtualIndex;
 685.211 -		assert(((intptr_t)region.softwareAddress & 1) == 0 && "somebody needs to reimplement ReadValueAtSoftwareAddress()");
 685.212 -		nextVirtualIndex = region.virtualIndex + region.size;
 685.213 -	}
 685.214 -	//assert(nextVirtualIndex <= MAX_RAM_SIZE);
 685.215 -
 685.216 -	if(nextVirtualIndex > MAX_RAM_SIZE)
 685.217 -	{
 685.218 -		s_prevValues = (unsigned char*)realloc(s_prevValues, sizeof(char)*(nextVirtualIndex+4));
 685.219 -		memset(s_prevValues, 0, sizeof(char)*(nextVirtualIndex+4));
 685.220 -
 685.221 -		s_curValues = (unsigned char*)realloc(s_curValues, sizeof(char)*(nextVirtualIndex+4));
 685.222 -		memset(s_curValues, 0, sizeof(char)*(nextVirtualIndex+4));
 685.223 -
 685.224 -		s_numChanges = (unsigned short*)realloc(s_numChanges, sizeof(short)*(nextVirtualIndex+4));
 685.225 -		memset(s_numChanges, 0, sizeof(short)*(nextVirtualIndex+4));
 685.226 -
 685.227 -		s_itemIndexToRegionPointer = (MemoryRegion**)realloc(s_itemIndexToRegionPointer, sizeof(MemoryRegion*)*(nextVirtualIndex+4));
 685.228 -		memset(s_itemIndexToRegionPointer, 0, sizeof(MemoryRegion*)*(nextVirtualIndex+4));
 685.229 -
 685.230 -		MAX_RAM_SIZE = nextVirtualIndex;
 685.231 -	}
 685.232 -	LeaveCriticalSection(&s_activeMemoryRegionsCS);
 685.233 -}
 685.234 -
 685.235 -// eliminates a range of hardware addresses from the search results
 685.236 -// returns 2 if it changed the region and moved the iterator to another region
 685.237 -// returns 1 if it changed the region but didn't move the iterator
 685.238 -// returns 0 if it had no effect
 685.239 -// warning: don't call anything that takes an itemIndex in a loop that calls DeactivateRegion...
 685.240 -//   doing so would be tremendously slow because DeactivateRegion invalidates the index cache
 685.241 -int DeactivateRegion(MemoryRegion& region, MemoryList::iterator& iter, HWAddressType hardwareAddress, unsigned int size)
 685.242 -{
 685.243 -	if(hardwareAddress + size <= region.hardwareAddress || hardwareAddress >= region.hardwareAddress + region.size)
 685.244 -	{
 685.245 -		// region is unaffected
 685.246 -		return 0;
 685.247 -	}
 685.248 -	else if(hardwareAddress > region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size)
 685.249 -	{
 685.250 -		// erase end of region
 685.251 -		region.size = hardwareAddress - region.hardwareAddress;
 685.252 -		return 1;
 685.253 -	}
 685.254 -	else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size)
 685.255 -	{
 685.256 -		// erase start of region
 685.257 -		int eraseSize = (hardwareAddress + size) - region.hardwareAddress;
 685.258 -		region.hardwareAddress += eraseSize;
 685.259 -		region.size -= eraseSize;
 685.260 -		region.softwareAddress += eraseSize;
 685.261 -		region.virtualIndex += eraseSize;
 685.262 -		return 1;
 685.263 -	}
 685.264 -	else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size)
 685.265 -	{
 685.266 -		// erase entire region
 685.267 -		iter = s_activeMemoryRegions.erase(iter);
 685.268 -		s_itemIndicesInvalid = TRUE;
 685.269 -		return 2;
 685.270 -	}
 685.271 -	else //if(hardwareAddress > region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size)
 685.272 -	{
 685.273 -		// split region
 685.274 -		int eraseSize = (hardwareAddress + size) - region.hardwareAddress;
 685.275 -		MemoryRegion region2 = {region.hardwareAddress + eraseSize, region.size - eraseSize, region.softwareAddress + eraseSize, region.virtualIndex + eraseSize};
 685.276 -		region.size = hardwareAddress - region.hardwareAddress;
 685.277 -		iter = s_activeMemoryRegions.insert(++iter, region2);
 685.278 -		s_itemIndicesInvalid = TRUE;
 685.279 -		return 2;
 685.280 -	}
 685.281 -}
 685.282 -
 685.283 -/*
 685.284 -// eliminates a range of hardware addresses from the search results
 685.285 -// this is a simpler but usually slower interface for the above function
 685.286 -void DeactivateRegion(HWAddressType hardwareAddress, unsigned int size)
 685.287 -{
 685.288 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); )
 685.289 -	{
 685.290 -		MemoryRegion& region = *iter;
 685.291 -		if(2 != DeactivateRegion(region, iter, hardwareAddress, size))
 685.292 -			++iter;
 685.293 -	}
 685.294 -}
 685.295 -*/
 685.296 -
 685.297 -struct AutoCritSect
 685.298 -{
 685.299 -	AutoCritSect(CRITICAL_SECTION* cs) : m_cs(cs) { EnterCriticalSection(m_cs); }
 685.300 -	~AutoCritSect() { LeaveCriticalSection(m_cs); }
 685.301 -	CRITICAL_SECTION* m_cs;
 685.302 -};
 685.303 -
 685.304 -// warning: can be slow
 685.305 -void CalculateItemIndices(int itemSize)
 685.306 -{
 685.307 -	AutoCritSect cs(&s_activeMemoryRegionsCS);
 685.308 -	unsigned int itemIndex = 0;
 685.309 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter)
 685.310 -	{
 685.311 -		MemoryRegion& region = *iter;
 685.312 -		region.itemIndex = itemIndex;
 685.313 -		int startSkipSize = ((unsigned int)(itemSize - (unsigned int)region.hardwareAddress)) % itemSize; // FIXME: is this still ok?
 685.314 -		unsigned int start = startSkipSize;
 685.315 -		unsigned int end = region.size;
 685.316 -		for(unsigned int i = start; i < end; i += itemSize)
 685.317 -			s_itemIndexToRegionPointer[itemIndex++] = &region;
 685.318 -	}
 685.319 -	s_maxItemIndex = itemIndex;
 685.320 -	s_itemIndicesInvalid = FALSE;
 685.321 -}
 685.322 -
 685.323 -template<typename stepType, typename compareType>
 685.324 -void UpdateRegionT(const MemoryRegion& region, const MemoryRegion* nextRegionPtr)
 685.325 -{
 685.326 -	//if(GetAsyncKeyState(VK_SHIFT) & 0x8000) // speed hack
 685.327 -	//	return;
 685.328 -
 685.329 -	if(s_prevValuesNeedUpdate)
 685.330 -		memcpy(s_prevValues + region.virtualIndex, s_curValues + region.virtualIndex, region.size + sizeof(compareType) - sizeof(stepType));
 685.331 -
 685.332 -	unsigned int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.333 -
 685.334 -
 685.335 -	unsigned char* sourceAddr = region.softwareAddress - region.virtualIndex;
 685.336 -
 685.337 -	unsigned int indexStart = region.virtualIndex + startSkipSize;
 685.338 -	unsigned int indexEnd = region.virtualIndex + region.size;
 685.339 -
 685.340 -	if(sizeof(compareType) == 1)
 685.341 -	{
 685.342 -		for(unsigned int i = indexStart; i < indexEnd; i++)
 685.343 -		{
 685.344 -			if(s_curValues[i] != sourceAddr[i]) // if value changed
 685.345 -			{
 685.346 -				s_curValues[i] = sourceAddr[i]; // update value
 685.347 -				//if(s_numChanges[i] != 0xFFFF)
 685.348 -					s_numChanges[i]++; // increase change count
 685.349 -			}
 685.350 -		}
 685.351 -	}
 685.352 -	else // it's more complicated for non-byte sizes because:
 685.353 -	{    // - more than one byte can affect a given change count entry
 685.354 -	     // - when more than one of those bytes changes simultaneously the entry's change count should only increase by 1
 685.355 -	     // - a few of those bytes can be outside the region
 685.356 -
 685.357 -		unsigned int endSkipSize = ((unsigned int)(startSkipSize - region.size)) % sizeof(stepType);
 685.358 -		unsigned int lastIndexToRead = indexEnd + endSkipSize + sizeof(compareType) - sizeof(stepType);
 685.359 -		unsigned int lastIndexToCopy = lastIndexToRead;
 685.360 -		if(nextRegionPtr)
 685.361 -		{
 685.362 -			const MemoryRegion& nextRegion = *nextRegionPtr;
 685.363 -			int nextStartSkipSize = ((unsigned int)(sizeof(stepType) - nextRegion.hardwareAddress)) % sizeof(stepType);
 685.364 -			unsigned int nextIndexStart = nextRegion.virtualIndex + nextStartSkipSize;
 685.365 -			if(lastIndexToCopy > nextIndexStart)
 685.366 -				lastIndexToCopy = nextIndexStart;
 685.367 -		}
 685.368 -
 685.369 -		unsigned int nextValidChange [sizeof(compareType)];
 685.370 -		for(unsigned int i = 0; i < sizeof(compareType); i++)
 685.371 -			nextValidChange[i] = indexStart + i;
 685.372 -
 685.373 -		for(unsigned int i = indexStart, j = 0; i < lastIndexToRead; i++, j++)
 685.374 -		{
 685.375 -			if(s_curValues[i] != sourceAddr[i]) // if value of this byte changed
 685.376 -			{
 685.377 -				if(i < lastIndexToCopy)
 685.378 -					s_curValues[i] = sourceAddr[i]; // update value
 685.379 -				for(int k = 0; k < sizeof(compareType); k++) // loop through the previous entries that contain this byte
 685.380 -				{
 685.381 -					if(i >= indexEnd+k)
 685.382 -						continue;
 685.383 -					int m = (j-k+sizeof(compareType)) & (sizeof(compareType)-1);
 685.384 -					if(nextValidChange[m] <= i) // if we didn't already increase the change count for this entry
 685.385 -					{
 685.386 -						//if(s_numChanges[i-k] != 0xFFFF)
 685.387 -							s_numChanges[i-k]++; // increase the change count for this entry
 685.388 -						nextValidChange[m] = i-k+sizeof(compareType); // and remember not to increase it again
 685.389 -					}
 685.390 -				}
 685.391 -			}
 685.392 -		}
 685.393 -	}
 685.394 -}
 685.395 -
 685.396 -template<typename stepType, typename compareType>
 685.397 -void UpdateRegionsT()
 685.398 -{
 685.399 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end();)
 685.400 -	{
 685.401 -		const MemoryRegion& region = *iter;
 685.402 -		++iter;
 685.403 -		const MemoryRegion* nextRegion = (iter == s_activeMemoryRegions.end()) ? NULL : &*iter;
 685.404 -
 685.405 -		UpdateRegionT<stepType, compareType>(region, nextRegion);
 685.406 -	}
 685.407 -
 685.408 -	s_prevValuesNeedUpdate = false;
 685.409 -}
 685.410 -
 685.411 -template<typename stepType, typename compareType>
 685.412 -int CountRegionItemsT()
 685.413 -{
 685.414 -	AutoCritSect cs(&s_activeMemoryRegionsCS);
 685.415 -	if(sizeof(stepType) == 1)
 685.416 -	{
 685.417 -		if(s_activeMemoryRegions.empty())
 685.418 -			return 0;
 685.419 -
 685.420 -		if(s_itemIndicesInvalid)
 685.421 -			CalculateItemIndices(sizeof(stepType));
 685.422 -
 685.423 -		MemoryRegion& lastRegion = s_activeMemoryRegions.back();
 685.424 -		return lastRegion.itemIndex + lastRegion.size;
 685.425 -	}
 685.426 -	else // the branch above is faster but won't work if the step size isn't 1
 685.427 -	{
 685.428 -		int total = 0;
 685.429 -		for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter)
 685.430 -		{
 685.431 -			MemoryRegion& region = *iter;
 685.432 -			int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.433 -			total += (region.size - startSkipSize + (sizeof(stepType)-1)) / sizeof(stepType);
 685.434 -		}
 685.435 -		return total;
 685.436 -	}
 685.437 -}
 685.438 -
 685.439 -// returns information about the item in the form of a "fake" region
 685.440 -// that has the item in it and nothing else
 685.441 -template<typename stepType, typename compareType>
 685.442 -void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegion)
 685.443 -{
 685.444 -	if(s_itemIndicesInvalid)
 685.445 -		CalculateItemIndices(sizeof(stepType));
 685.446 -
 685.447 -	if(itemIndex >= s_maxItemIndex)
 685.448 -	{
 685.449 -		memset(&virtualRegion, 0, sizeof(MemoryRegion));
 685.450 -		return;
 685.451 -	}
 685.452 -
 685.453 -	const MemoryRegion* regionPtr = s_itemIndexToRegionPointer[itemIndex];
 685.454 -	const MemoryRegion& region = *regionPtr;
 685.455 -
 685.456 -	int bytesWithinRegion = (itemIndex - region.itemIndex) * sizeof(stepType);
 685.457 -	int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.458 -	bytesWithinRegion += startSkipSize;
 685.459 -	
 685.460 -	virtualRegion.size = sizeof(compareType);
 685.461 -	virtualRegion.hardwareAddress = region.hardwareAddress + bytesWithinRegion;
 685.462 -	virtualRegion.softwareAddress = region.softwareAddress + bytesWithinRegion;
 685.463 -	virtualRegion.virtualIndex = region.virtualIndex + bytesWithinRegion;
 685.464 -	virtualRegion.itemIndex = itemIndex;
 685.465 -	return;
 685.466 -}
 685.467 -
 685.468 -template<typename stepType, typename compareType>
 685.469 -unsigned int ItemIndexToVirtualIndex(unsigned int itemIndex)
 685.470 -{
 685.471 -	MemoryRegion virtualRegion;
 685.472 -	ItemIndexToVirtualRegion<stepType,compareType>(itemIndex, virtualRegion);
 685.473 -	return virtualRegion.virtualIndex;
 685.474 -}
 685.475 -
 685.476 -template<typename T>
 685.477 -T ReadLocalValue(const unsigned char* data)
 685.478 -{
 685.479 -	return *(const T*)data;
 685.480 -}
 685.481 -//template<> signed char ReadLocalValue(const unsigned char* data) { return *data; }
 685.482 -//template<> unsigned char ReadLocalValue(const unsigned char* data) { return *data; }
 685.483 -
 685.484 -
 685.485 -template<typename stepType, typename compareType>
 685.486 -compareType GetPrevValueFromVirtualIndex(unsigned int virtualIndex)
 685.487 -{
 685.488 -	return ReadLocalValue<compareType>(s_prevValues + virtualIndex);
 685.489 -	//return *(compareType*)(s_prevValues+virtualIndex);
 685.490 -}
 685.491 -template<typename stepType, typename compareType>
 685.492 -compareType GetCurValueFromVirtualIndex(unsigned int virtualIndex)
 685.493 -{
 685.494 -	return ReadLocalValue<compareType>(s_curValues + virtualIndex);
 685.495 -//	return *(compareType*)(s_curValues+virtualIndex);
 685.496 -}
 685.497 -template<typename stepType, typename compareType>
 685.498 -unsigned short GetNumChangesFromVirtualIndex(unsigned int virtualIndex)
 685.499 -{
 685.500 -	unsigned short num = s_numChanges[virtualIndex];
 685.501 -	//for(unsigned int i = 1; i < sizeof(stepType); i++)
 685.502 -	//	if(num < s_numChanges[virtualIndex+i])
 685.503 -	//		num = s_numChanges[virtualIndex+i];
 685.504 -	return num;
 685.505 -}
 685.506 -
 685.507 -template<typename stepType, typename compareType>
 685.508 -compareType GetPrevValueFromItemIndex(unsigned int itemIndex)
 685.509 -{
 685.510 -	int virtualIndex = ItemIndexToVirtualIndex<stepType,compareType>(itemIndex);
 685.511 -	return GetPrevValueFromVirtualIndex<stepType,compareType>(virtualIndex);
 685.512 -}
 685.513 -template<typename stepType, typename compareType>
 685.514 -compareType GetCurValueFromItemIndex(unsigned int itemIndex)
 685.515 -{
 685.516 -	int virtualIndex = ItemIndexToVirtualIndex<stepType,compareType>(itemIndex);
 685.517 -	return GetCurValueFromVirtualIndex<stepType,compareType>(virtualIndex);
 685.518 -}
 685.519 -template<typename stepType, typename compareType>
 685.520 -unsigned short GetNumChangesFromItemIndex(unsigned int itemIndex)
 685.521 -{
 685.522 -	int virtualIndex = ItemIndexToVirtualIndex<stepType,compareType>(itemIndex);
 685.523 -	return GetNumChangesFromVirtualIndex<stepType,compareType>(virtualIndex);
 685.524 -}
 685.525 -template<typename stepType, typename compareType>
 685.526 -unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex)
 685.527 -{
 685.528 -	MemoryRegion virtualRegion;
 685.529 -	ItemIndexToVirtualRegion<stepType,compareType>(itemIndex, virtualRegion);
 685.530 -	return virtualRegion.hardwareAddress;
 685.531 -}
 685.532 -
 685.533 -// this one might be unreliable, haven't used it much
 685.534 -template<typename stepType, typename compareType>
 685.535 -unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
 685.536 -{
 685.537 -	if(s_itemIndicesInvalid)
 685.538 -		CalculateItemIndices(sizeof(stepType));
 685.539 -
 685.540 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter)
 685.541 -	{
 685.542 -		MemoryRegion& region = *iter;
 685.543 -		if(hardwareAddress >= region.hardwareAddress && hardwareAddress < region.hardwareAddress + region.size)
 685.544 -		{
 685.545 -			int indexWithinRegion = (hardwareAddress - region.hardwareAddress) / sizeof(stepType);
 685.546 -			return region.itemIndex + indexWithinRegion;
 685.547 -		}
 685.548 -	}
 685.549 -
 685.550 -	return -1;
 685.551 -}
 685.552 -
 685.553 -
 685.554 -
 685.555 -// workaround for MSVC 7 that doesn't support varadic C99 macros
 685.556 -#define CALL_WITH_T_SIZE_TYPES_0(functionName, sizeTypeID, isSigned, requiresAligned) \
 685.557 -	(sizeTypeID == 'b' \
 685.558 -		? (isSigned \
 685.559 -			? functionName<char, signed char>() \
 685.560 -			: functionName<char, unsigned char>()) \
 685.561 -	: sizeTypeID == 'w' \
 685.562 -		? (isSigned \
 685.563 -			? (requiresAligned \
 685.564 -				? functionName<short, signed short>() \
 685.565 -				: functionName<char, signed short>()) \
 685.566 -			: (requiresAligned \
 685.567 -				? functionName<short, unsigned short>() \
 685.568 -				: functionName<char, unsigned short>())) \
 685.569 -	: sizeTypeID == 'd' \
 685.570 -		? (isSigned \
 685.571 -			? (requiresAligned \
 685.572 -				? functionName<short, signed long>() \
 685.573 -				: functionName<char, signed long>()) \
 685.574 -			: (requiresAligned \
 685.575 -				? functionName<short, unsigned long>() \
 685.576 -				: functionName<char, unsigned long>())) \
 685.577 -	: functionName<char, signed char>())
 685.578 -
 685.579 -#define CALL_WITH_T_SIZE_TYPES_1(functionName, sizeTypeID, isSigned, requiresAligned, p0) \
 685.580 -	(sizeTypeID == 'b' \
 685.581 -		? (isSigned \
 685.582 -			? functionName<char, signed char>(p0) \
 685.583 -			: functionName<char, unsigned char>(p0)) \
 685.584 -	: sizeTypeID == 'w' \
 685.585 -		? (isSigned \
 685.586 -			? (requiresAligned \
 685.587 -				? functionName<short, signed short>(p0) \
 685.588 -				: functionName<char, signed short>(p0)) \
 685.589 -			: (requiresAligned \
 685.590 -				? functionName<short, unsigned short>(p0) \
 685.591 -				: functionName<char, unsigned short>(p0))) \
 685.592 -	: sizeTypeID == 'd' \
 685.593 -		? (isSigned \
 685.594 -			? (requiresAligned \
 685.595 -				? functionName<short, signed long>(p0) \
 685.596 -				: functionName<char, signed long>(p0)) \
 685.597 -			: (requiresAligned \
 685.598 -				? functionName<short, unsigned long>(p0) \
 685.599 -				: functionName<char, unsigned long>(p0))) \
 685.600 -	: functionName<char, signed char>(p0))
 685.601 -
 685.602 -#define CALL_WITH_T_SIZE_TYPES_3(functionName, sizeTypeID, isSigned, requiresAligned, p0, p1, p2) \
 685.603 -	(sizeTypeID == 'b' \
 685.604 -		? (isSigned \
 685.605 -			? functionName<char, signed char>(p0, p1, p2) \
 685.606 -			: functionName<char, unsigned char>(p0, p1, p2)) \
 685.607 -	: sizeTypeID == 'w' \
 685.608 -		? (isSigned \
 685.609 -			? (requiresAligned \
 685.610 -				? functionName<short, signed short>(p0, p1, p2) \
 685.611 -				: functionName<char, signed short>(p0, p1, p2)) \
 685.612 -			: (requiresAligned \
 685.613 -				? functionName<short, unsigned short>(p0, p1, p2) \
 685.614 -				: functionName<char, unsigned short>(p0, p1, p2))) \
 685.615 -	: sizeTypeID == 'd' \
 685.616 -		? (isSigned \
 685.617 -			? (requiresAligned \
 685.618 -				? functionName<short, signed long>(p0, p1, p2) \
 685.619 -				: functionName<char, signed long>(p0, p1, p2)) \
 685.620 -			: (requiresAligned \
 685.621 -				? functionName<short, unsigned long>(p0, p1, p2) \
 685.622 -				: functionName<char, unsigned long>(p0, p1, p2))) \
 685.623 -	: functionName<char, signed char>(p0, p1, p2))
 685.624 -
 685.625 -#define CALL_WITH_T_SIZE_TYPES_4(functionName, sizeTypeID, isSigned, requiresAligned, p0, p1, p2, p3) \
 685.626 -	(sizeTypeID == 'b' \
 685.627 -		? (isSigned \
 685.628 -			? functionName<char, signed char>(p0, p1, p2, p3) \
 685.629 -			: functionName<char, unsigned char>(p0, p1, p2, p3)) \
 685.630 -	: sizeTypeID == 'w' \
 685.631 -		? (isSigned \
 685.632 -			? (requiresAligned \
 685.633 -				? functionName<short, signed short>(p0, p1, p2, p3) \
 685.634 -				: functionName<char, signed short>(p0, p1, p2, p3)) \
 685.635 -			: (requiresAligned \
 685.636 -				? functionName<short, unsigned short>(p0, p1, p2, p3) \
 685.637 -				: functionName<char, unsigned short>(p0, p1, p2, p3))) \
 685.638 -	: sizeTypeID == 'd' \
 685.639 -		? (isSigned \
 685.640 -			? (requiresAligned \
 685.641 -				? functionName<short, signed long>(p0, p1, p2, p3) \
 685.642 -				: functionName<char, signed long>(p0, p1, p2, p3)) \
 685.643 -			: (requiresAligned \
 685.644 -				? functionName<short, unsigned long>(p0, p1, p2, p3) \
 685.645 -				: functionName<char, unsigned long>(p0, p1, p2, p3))) \
 685.646 -	: functionName<char, signed char>(p0, p1, p2, p3))
 685.647 -
 685.648 -// version that takes a forced comparison type
 685.649 -#define CALL_WITH_T_STEP_3(functionName, sizeTypeID, type, requiresAligned, p0, p1, p2) \
 685.650 -	(sizeTypeID == 'b' \
 685.651 -		? functionName<char, type>(p0, p1, p2) \
 685.652 -	: sizeTypeID == 'w' \
 685.653 -		? (requiresAligned \
 685.654 -			? functionName<short, type>(p0, p1, p2) \
 685.655 -			: functionName<char, type>(p0, p1, p2)) \
 685.656 -	: sizeTypeID == 'd' \
 685.657 -		? (requiresAligned \
 685.658 -			? functionName<short, type>(p0, p1, p2) \
 685.659 -			: functionName<char, type>(p0, p1, p2)) \
 685.660 -	: functionName<char, type>(p0, p1, p2))
 685.661 -
 685.662 -// version that takes a forced comparison type
 685.663 -#define CALL_WITH_T_STEP_4(functionName, sizeTypeID, type, requiresAligned, p0, p1, p2, p3) \
 685.664 -	(sizeTypeID == 'b' \
 685.665 -		? functionName<char, type>(p0, p1, p2, p3) \
 685.666 -	: sizeTypeID == 'w' \
 685.667 -		? (requiresAligned \
 685.668 -			? functionName<short, type>(p0, p1, p2, p3) \
 685.669 -			: functionName<char, type>(p0, p1, p2, p3)) \
 685.670 -	: sizeTypeID == 'd' \
 685.671 -		? (requiresAligned \
 685.672 -			? functionName<short, type>(p0, p1, p2, p3) \
 685.673 -			: functionName<char, type>(p0, p1, p2, p3)) \
 685.674 -	: functionName<char, type>(p0, p1, p2, p3))
 685.675 -
 685.676 -// basic comparison functions:
 685.677 -template <typename T> inline bool LessCmp (T x, T y, T i)        { return x < y; }
 685.678 -template <typename T> inline bool MoreCmp (T x, T y, T i)        { return x > y; }
 685.679 -template <typename T> inline bool LessEqualCmp (T x, T y, T i)   { return x <= y; }
 685.680 -template <typename T> inline bool MoreEqualCmp (T x, T y, T i)   { return x >= y; }
 685.681 -template <typename T> inline bool EqualCmp (T x, T y, T i)       { return x == y; }
 685.682 -template <typename T> inline bool UnequalCmp (T x, T y, T i)     { return x != y; }
 685.683 -template <typename T> inline bool DiffByCmp (T x, T y, T p)      { return x - y == p || y - x == p; }
 685.684 -template <typename T> inline bool ModIsCmp (T x, T y, T p)       { return p && x % p == y; }
 685.685 -
 685.686 -// compare-to type functions:
 685.687 -template<typename stepType, typename T>
 685.688 -void SearchRelative (bool(*cmpFun)(T,T,T), T ignored, T param)
 685.689 -{
 685.690 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); )
 685.691 -	{
 685.692 -		MemoryRegion& region = *iter;
 685.693 -		int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.694 -		unsigned int start = region.virtualIndex + startSkipSize;
 685.695 -		unsigned int end = region.virtualIndex + region.size;
 685.696 -		for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType))
 685.697 -			if(!cmpFun(GetCurValueFromVirtualIndex<stepType,T>(i), GetPrevValueFromVirtualIndex<stepType,T>(i), param))
 685.698 -				if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType)))
 685.699 -					goto outerContinue;
 685.700 -		++iter;
 685.701 -outerContinue:
 685.702 -		continue;
 685.703 -	}
 685.704 -}
 685.705 -template<typename stepType, typename T>
 685.706 -void SearchSpecific (bool(*cmpFun)(T,T,T), T value, T param)
 685.707 -{
 685.708 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); )
 685.709 -	{
 685.710 -		MemoryRegion& region = *iter;
 685.711 -		int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.712 -		unsigned int start = region.virtualIndex + startSkipSize;
 685.713 -		unsigned int end = region.virtualIndex + region.size;
 685.714 -		for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType))
 685.715 -			if(!cmpFun(GetCurValueFromVirtualIndex<stepType,T>(i), value, param))
 685.716 -				if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType)))
 685.717 -					goto outerContinue;
 685.718 -		++iter;
 685.719 -outerContinue:
 685.720 -		continue;
 685.721 -	}
 685.722 -}
 685.723 -template<typename stepType, typename T>
 685.724 -void SearchAddress (bool(*cmpFun)(T,T,T), T address, T param)
 685.725 -{
 685.726 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); )
 685.727 -	{
 685.728 -		MemoryRegion& region = *iter;
 685.729 -		int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.730 -		unsigned int start = region.virtualIndex + startSkipSize;
 685.731 -		unsigned int end = region.virtualIndex + region.size;
 685.732 -		for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType))
 685.733 -			if(!cmpFun(hwaddr, address, param))
 685.734 -				if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType)))
 685.735 -					goto outerContinue;
 685.736 -		++iter;
 685.737 -outerContinue:
 685.738 -		continue;
 685.739 -	}
 685.740 -}
 685.741 -template<typename stepType, typename T>
 685.742 -void SearchChanges (bool(*cmpFun)(T,T,T), T changes, T param)
 685.743 -{
 685.744 -	for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); )
 685.745 -	{
 685.746 -		MemoryRegion& region = *iter;
 685.747 -		int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType);
 685.748 -		unsigned int start = region.virtualIndex + startSkipSize;
 685.749 -		unsigned int end = region.virtualIndex + region.size;
 685.750 -		for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType))
 685.751 -			if(!cmpFun(GetNumChangesFromVirtualIndex<stepType,T>(i), changes, param))
 685.752 -				if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType)))
 685.753 -					goto outerContinue;
 685.754 -		++iter;
 685.755 -outerContinue:
 685.756 -		continue;
 685.757 -	}
 685.758 -}
 685.759 -
 685.760 -char rs_c='s';
 685.761 -char rs_o='=';
 685.762 -char rs_t='s';
 685.763 -int rs_param=0, rs_val=0, rs_val_valid=0;
 685.764 -char rs_type_size = 'b', rs_last_type_size = rs_type_size;
 685.765 -bool noMisalign = true, rs_last_no_misalign = noMisalign;
 685.766 -//bool littleEndian = false;
 685.767 -int last_rs_possible = -1;
 685.768 -int last_rs_regions = -1;
 685.769 -
 685.770 -void prune(char c,char o,char t,int v,int p)
 685.771 -{
 685.772 -	// repetition-reducing macros
 685.773 -	#define DO_SEARCH(sf) \
 685.774 -	switch (o) \
 685.775 -	{ \
 685.776 -		case '<': DO_SEARCH_2(LessCmp,sf); break; \
 685.777 -		case '>': DO_SEARCH_2(MoreCmp,sf); break; \
 685.778 -		case '=': DO_SEARCH_2(EqualCmp,sf); break; \
 685.779 -		case '!': DO_SEARCH_2(UnequalCmp,sf); break; \
 685.780 -		case 'l': DO_SEARCH_2(LessEqualCmp,sf); break; \
 685.781 -		case 'm': DO_SEARCH_2(MoreEqualCmp,sf); break; \
 685.782 -		case 'd': DO_SEARCH_2(DiffByCmp,sf); break; \
 685.783 -		case '%': DO_SEARCH_2(ModIsCmp,sf); break; \
 685.784 -		default: assert(!"Invalid operator for this search type."); break; \
 685.785 -	}
 685.786 -
 685.787 -	// perform the search, eliminating nonmatching values
 685.788 -	switch (c)
 685.789 -	{
 685.790 -		#define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_SIZE_TYPES_3(sf, rs_type_size, t, noMisalign, CmpFun,v,p)
 685.791 -		case 'r': DO_SEARCH(SearchRelative); break;
 685.792 -		case 's': DO_SEARCH(SearchSpecific); break;
 685.793 -
 685.794 -		#undef DO_SEARCH_2
 685.795 -		#define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP_3(sf, rs_type_size, unsigned int, noMisalign, CmpFun,v,p)
 685.796 -		case 'a': DO_SEARCH(SearchAddress); break;
 685.797 -
 685.798 -		#undef DO_SEARCH_2
 685.799 -		#define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP_3(sf, rs_type_size, unsigned short, noMisalign, CmpFun,v,p)
 685.800 -		case 'n': DO_SEARCH(SearchChanges); break;
 685.801 -
 685.802 -		default: assert(!"Invalid search comparison type."); break;
 685.803 -	}
 685.804 -
 685.805 -	s_prevValuesNeedUpdate = true;
 685.806 -
 685.807 -	int prevNumItems = last_rs_possible;
 685.808 -
 685.809 -	CompactAddrs();
 685.810 -
 685.811 -	if(prevNumItems == last_rs_possible)
 685.812 -	{
 685.813 -		SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo
 685.814 -	}
 685.815 -}
 685.816 -
 685.817 -
 685.818 -
 685.819 -
 685.820 -template<typename stepType, typename T>
 685.821 -bool CompareRelativeAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T ignored, T param)
 685.822 -{
 685.823 -	return cmpFun(GetCurValueFromItemIndex<stepType,T>(itemIndex), GetPrevValueFromItemIndex<stepType,T>(itemIndex), param);
 685.824 -}
 685.825 -template<typename stepType, typename T>
 685.826 -bool CompareSpecificAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T value, T param)
 685.827 -{
 685.828 -	return cmpFun(GetCurValueFromItemIndex<stepType,T>(itemIndex), value, param);
 685.829 -}
 685.830 -template<typename stepType, typename T>
 685.831 -bool CompareAddressAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T address, T param)
 685.832 -{
 685.833 -	return cmpFun(GetHardwareAddressFromItemIndex<stepType,T>(itemIndex), address, param);
 685.834 -}
 685.835 -template<typename stepType, typename T>
 685.836 -bool CompareChangesAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T changes, T param)
 685.837 -{
 685.838 -	return cmpFun(GetNumChangesFromItemIndex<stepType,T>(itemIndex), changes, param);
 685.839 -}
 685.840 -
 685.841 -int ReadControlInt(int controlID, bool forceHex, BOOL& success)
 685.842 -{
 685.843 -	int rv = 0;
 685.844 -	BOOL ok = false;
 685.845 -
 685.846 -	if(!forceHex)
 685.847 -	{
 685.848 -		rv = GetDlgItemInt(RamSearchHWnd,controlID,&ok,(rs_t == 's'));
 685.849 -	}
 685.850 -
 685.851 -	if(!ok)
 685.852 -	{
 685.853 -		if(GetDlgItemText(RamSearchHWnd,controlID,Str_Tmp,16))
 685.854 -		{
 685.855 -			for(int i = 0; Str_Tmp[i]; i++) {if(toupper(Str_Tmp[i]) == 'O') Str_Tmp[i] = '0';}
 685.856 -			const char* strPtr = Str_Tmp;
 685.857 -			bool negate = false;
 685.858 -			while(strPtr[0] == '-')
 685.859 -				strPtr++, negate = !negate;
 685.860 -			if(strPtr[0] == '+')
 685.861 -				strPtr++;
 685.862 -			if(strPtr[0] == '0' && tolower(strPtr[1]) == 'x')
 685.863 -				strPtr += 2, forceHex = true;
 685.864 -			if(strPtr[0] == '$')
 685.865 -				strPtr++, forceHex = true;
 685.866 -			if(!forceHex)
 685.867 -			{
 685.868 -				const char* strSearchPtr = strPtr;
 685.869 -				while(*strSearchPtr)
 685.870 -				{
 685.871 -					int c = tolower(*strSearchPtr++);
 685.872 -					if(c >= 'a' && c <= 'f')
 685.873 -						forceHex = true;
 685.874 -				}
 685.875 -			}
 685.876 -			const char* formatString = forceHex ? "%X" : ((rs_t=='s') ? "%d" : "%u");
 685.877 -			if(sscanf(strPtr, formatString, &rv) > 0)
 685.878 -				ok = true;
 685.879 -			if(negate)
 685.880 -				rv = -rv;
 685.881 -		}
 685.882 -	}
 685.883 -
 685.884 -	success = ok;
 685.885 -	return rv;
 685.886 -}
 685.887 -
 685.888 -
 685.889 -bool Set_RS_Val()
 685.890 -{
 685.891 -	BOOL success;
 685.892 -
 685.893 -	// update rs_val
 685.894 -	switch(rs_c)
 685.895 -	{
 685.896 -		case 'r':
 685.897 -		default:
 685.898 -			rs_val = 0;
 685.899 -			break;
 685.900 -		case 's':
 685.901 -			rs_val = ReadControlInt(IDC_EDIT_COMPAREVALUE, rs_t == 'h', success);
 685.902 -			if(!success)
 685.903 -				return false;
 685.904 -			if((rs_type_size == 'b' && rs_t == 's' && (rs_val < -128 || rs_val > 127)) ||
 685.905 -			   (rs_type_size == 'b' && rs_t != 's' && (rs_val < 0 || rs_val > 255)) ||
 685.906 -			   (rs_type_size == 'w' && rs_t == 's' && (rs_val < -32768 || rs_val > 32767)) ||
 685.907 -			   (rs_type_size == 'w' && rs_t != 's' && (rs_val < 0 || rs_val > 65535)))
 685.908 -			   return false;
 685.909 -			break;
 685.910 -		case 'a':
 685.911 -			rs_val = ReadControlInt(IDC_EDIT_COMPAREADDRESS, true, success);
 685.912 -			if(!success || rs_val < 0 || rs_val > 0x06040000)
 685.913 -				return false;
 685.914 -			break;
 685.915 -		case 'n': {
 685.916 -			rs_val = ReadControlInt(IDC_EDIT_COMPARECHANGES, false, success);
 685.917 -			if(!success || rs_val < 0 || rs_val > 0xFFFF)
 685.918 -				return false;
 685.919 -		}	break;
 685.920 -	}
 685.921 -
 685.922 -	// also update rs_param
 685.923 -	switch(rs_o)
 685.924 -	{
 685.925 -		default:
 685.926 -			rs_param = 0;
 685.927 -			break;
 685.928 -		case 'd':
 685.929 -			rs_param = ReadControlInt(IDC_EDIT_DIFFBY, false, success);
 685.930 -			if(!success)
 685.931 -				return false;
 685.932 -			if(rs_param < 0)
 685.933 -				rs_param = -rs_param;
 685.934 -			break;
 685.935 -		case '%':
 685.936 -			rs_param = ReadControlInt(IDC_EDIT_MODBY, false, success);
 685.937 -			if(!success || rs_param == 0)
 685.938 -				return false;
 685.939 -			break;
 685.940 -	}
 685.941 -
 685.942 -	// validate that rs_param fits in the comparison data type
 685.943 -	{
 685.944 -		int appliedSize = rs_type_size;
 685.945 -		int appliedSign = rs_t;
 685.946 -		if(rs_c == 'n')
 685.947 -			appliedSize = 'w', appliedSign = 'u';
 685.948 -		if(rs_c == 'a')
 685.949 -			appliedSize = 'd', appliedSign = 'u';
 685.950 -		if((appliedSize == 'b' && appliedSize == 's' && (rs_param < -128 || rs_param > 127)) ||
 685.951 -		   (appliedSize == 'b' && appliedSize != 's' && (rs_param < 0 || rs_param > 255)) ||
 685.952 -		   (appliedSize == 'w' && appliedSize == 's' && (rs_param < -32768 || rs_param > 32767)) ||
 685.953 -		   (appliedSize == 'w' && appliedSize != 's' && (rs_param < 0 || rs_param > 65535)))
 685.954 -		   return false;
 685.955 -	}
 685.956 -
 685.957 -	return true;
 685.958 -}
 685.959 -
 685.960 -bool IsSatisfied(int itemIndex)
 685.961 -{
 685.962 -	if(!rs_val_valid)
 685.963 -		return true;
 685.964 -	int o = rs_o;
 685.965 -	switch (rs_c)
 685.966 -	{
 685.967 -		#undef DO_SEARCH_2
 685.968 -		#define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_SIZE_TYPES_4(sf, rs_type_size,(rs_t=='s'),noMisalign, CmpFun,itemIndex,rs_val,rs_param);
 685.969 -		case 'r': DO_SEARCH(CompareRelativeAtItem); break;
 685.970 -		case 's': DO_SEARCH(CompareSpecificAtItem); break;
 685.971 -
 685.972 -		#undef DO_SEARCH_2
 685.973 -		#define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP_4(sf, rs_type_size, unsigned int, noMisalign, CmpFun,itemIndex,rs_val,rs_param);
 685.974 -		case 'a': DO_SEARCH(CompareAddressAtItem); break;
 685.975 -
 685.976 -		#undef DO_SEARCH_2
 685.977 -		#define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP_4(sf, rs_type_size, unsigned short, noMisalign, CmpFun,itemIndex,rs_val,rs_param);
 685.978 -		case 'n': DO_SEARCH(CompareChangesAtItem); break;
 685.979 -	}
 685.980 -	return false;
 685.981 -}
 685.982 -
 685.983 -
 685.984 -
 685.985 -unsigned int ReadValueAtSoftwareAddress(const unsigned char* address, unsigned int size)
 685.986 -{
 685.987 -	unsigned int value = 0;
 685.988 -	if(address)
 685.989 -	{
 685.990 -		// assumes we're little-endian
 685.991 -		memcpy(&value, address, size);
 685.992 -	}
 685.993 -	return value;
 685.994 -}
 685.995 -void WriteValueAtSoftwareAddress(unsigned char* address, unsigned int value, unsigned int size)
 685.996 -{
 685.997 -	if(address)
 685.998 -	{
 685.999 -		// assumes we're little-endian
685.1000 -		memcpy(address, &value, size);
685.1001 -	}
685.1002 -}
685.1003 -unsigned int ReadValueAtHardwareAddress(HWAddressType address, unsigned int size)
685.1004 -{
685.1005 -	return ReadValueAtSoftwareAddress(HardwareToSoftwareAddress(address), size);
685.1006 -}
685.1007 -bool WriteValueAtHardwareAddress(HWAddressType address, unsigned int value, unsigned int size)
685.1008 -{
685.1009 -	WriteValueAtSoftwareAddress(HardwareToSoftwareAddress(address), value, size);
685.1010 -	return true;
685.1011 -}
685.1012 -bool IsHardwareAddressValid(HWAddressType address)
685.1013 -{
685.1014 -	return HardwareToSoftwareAddress(address) != NULL;
685.1015 -}
685.1016 -
685.1017 -
685.1018 -
685.1019 -int ResultCount=0;
685.1020 -bool AutoSearch=false;
685.1021 -bool AutoSearchAutoRetry=false;
685.1022 -LRESULT CALLBACK PromptWatchNameProc(HWND, UINT, WPARAM, LPARAM);
685.1023 -void UpdatePossibilities(int rs_possible, int regions);
685.1024 -
685.1025 -
685.1026 -void CompactAddrs()
685.1027 -{
685.1028 -	int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2;
685.1029 -	int prevResultCount = ResultCount;
685.1030 -
685.1031 -	CalculateItemIndices(size);
685.1032 -	ResultCount = CALL_WITH_T_SIZE_TYPES_0(CountRegionItemsT, rs_type_size,rs_t=='s',noMisalign);
685.1033 -
685.1034 -	UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size());
685.1035 -
685.1036 -	if(ResultCount != prevResultCount)
685.1037 -		ListView_SetItemCount(GetDlgItem(RamSearchHWnd,IDC_RAMLIST),ResultCount);
685.1038 -}
685.1039 -
685.1040 -void soft_reset_address_info ()
685.1041 -{
685.1042 -	s_prevValuesNeedUpdate = false;
685.1043 -	ResetMemoryRegions();
685.1044 -	if(!RamSearchHWnd)
685.1045 -	{
685.1046 -		EnterCriticalSection(&s_activeMemoryRegionsCS);
685.1047 -		s_activeMemoryRegions.clear();
685.1048 -		LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1049 -		ResultCount = 0;
685.1050 -	}
685.1051 -	else
685.1052 -	{
685.1053 -		// force s_prevValues to be valid
685.1054 -		signal_new_frame();
685.1055 -		s_prevValuesNeedUpdate = true;
685.1056 -		signal_new_frame();
685.1057 -	}
685.1058 -	if(s_numChanges)
685.1059 -		memset(s_numChanges, 0, (sizeof(*s_numChanges)*(MAX_RAM_SIZE)));
685.1060 -	CompactAddrs();
685.1061 -}
685.1062 -void reset_address_info ()
685.1063 -{
685.1064 -	SetRamSearchUndoType(RamSearchHWnd, 0);
685.1065 -	EnterCriticalSection(&s_activeMemoryRegionsCS);
685.1066 -	s_activeMemoryRegionsBackup.clear(); // not necessary, but we'll take the time hit here instead of at the next thing that sets up an undo
685.1067 -	LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1068 -	if(s_prevValues)
685.1069 -		memcpy(s_prevValues, s_curValues, (sizeof(*s_prevValues)*(MAX_RAM_SIZE)));
685.1070 -	s_prevValuesNeedUpdate = false;
685.1071 -	ResetMemoryRegions();
685.1072 -	if(!RamSearchHWnd)
685.1073 -	{
685.1074 -		EnterCriticalSection(&s_activeMemoryRegionsCS);
685.1075 -		s_activeMemoryRegions.clear();
685.1076 -		LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1077 -		ResultCount = 0;
685.1078 -	}
685.1079 -	else
685.1080 -	{
685.1081 -		// force s_prevValues to be valid
685.1082 -		signal_new_frame();
685.1083 -		s_prevValuesNeedUpdate = true;
685.1084 -		signal_new_frame();
685.1085 -	}
685.1086 -	memset(s_numChanges, 0, (sizeof(*s_numChanges)*(MAX_RAM_SIZE)));
685.1087 -	CompactAddrs();
685.1088 -}
685.1089 -
685.1090 -void signal_new_frame ()
685.1091 -{
685.1092 -	EnterCriticalSection(&s_activeMemoryRegionsCS);
685.1093 -	CALL_WITH_T_SIZE_TYPES_0(UpdateRegionsT, rs_type_size, rs_t=='s', noMisalign);
685.1094 -	LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1095 -}
685.1096 -
685.1097 -
685.1098 -
685.1099 -
685.1100 -
685.1101 -bool RamSearchClosed = false;
685.1102 -bool RamWatchClosed = false;
685.1103 -
685.1104 -void ResetResults()
685.1105 -{
685.1106 -	reset_address_info();
685.1107 -	ResultCount = 0;
685.1108 -	if (RamSearchHWnd)
685.1109 -		ListView_SetItemCount(GetDlgItem(RamSearchHWnd,IDC_RAMLIST),ResultCount);
685.1110 -}
685.1111 -void CloseRamWindows() //Close the Ram Search & Watch windows when rom closes
685.1112 -{
685.1113 -	ResetWatches();
685.1114 -	ResetResults();
685.1115 -	if (RamSearchHWnd)
685.1116 -	{
685.1117 -		SendMessage(RamSearchHWnd,WM_CLOSE,NULL,NULL);
685.1118 -		RamSearchClosed = true;
685.1119 -	}
685.1120 -	if (RamWatchHWnd)
685.1121 -	{
685.1122 -		SendMessage(RamWatchHWnd,WM_CLOSE,NULL,NULL);
685.1123 -		RamWatchClosed = true;
685.1124 -	}
685.1125 -}
685.1126 -void ReopenRamWindows() //Reopen them when a new Rom is loaded
685.1127 -{
685.1128 -	HWND hwnd = GetActiveWindow();
685.1129 -
685.1130 -	if (RamSearchClosed)
685.1131 -	{
685.1132 -		RamSearchClosed = false;
685.1133 -		if(!RamSearchHWnd)
685.1134 -		{
685.1135 -			reset_address_info();
685.1136 -			LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
685.1137 -			RamSearchHWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_RAMSEARCH), hWnd, (DLGPROC) RamSearchProc);
685.1138 -		}
685.1139 -		else
685.1140 -			::SetForegroundWindow(RamSearchHWnd);
685.1141 -	}
685.1142 -	if (RamWatchClosed || AutoRWLoad)
685.1143 -	{
685.1144 -		RamWatchClosed = false;
685.1145 -		if(!RamWatchHWnd)
685.1146 -		{
685.1147 -			if (AutoRWLoad) OpenRWRecentFile(0);
685.1148 -			LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
685.1149 -			RamWatchHWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc);
685.1150 -		}
685.1151 -		else
685.1152 -			::SetForegroundWindow(RamWatchHWnd);
685.1153 -	}
685.1154 -
685.1155 -	if (hwnd == hWnd && hwnd != GetActiveWindow())
685.1156 -		SetActiveWindow(hWnd); // restore focus to the main window if it had it before
685.1157 -}
685.1158 -
685.1159 -
685.1160 -
685.1161 -
685.1162 -
685.1163 -void RefreshRamListSelectedCountControlStatus(HWND hDlg)
685.1164 -{
685.1165 -	int selCount = ListView_GetSelectedCount(GetDlgItem(hDlg,IDC_RAMLIST));
685.1166 -	if(selCount != s_prevSelCount)
685.1167 -	{
685.1168 -		if(selCount < 2 || s_prevSelCount < 2)
685.1169 -		{
685.1170 -			EnableWindow(GetDlgItem(hDlg, IDC_C_WATCH), (WatchCount < MAX_WATCH_COUNT) ? TRUE : FALSE);
685.1171 -			EnableWindow(GetDlgItem(hDlg, IDC_C_ADDCHEAT), (selCount >= 1) ? TRUE : FALSE);
685.1172 -			EnableWindow(GetDlgItem(hDlg, IDC_C_ELIMINATE), (selCount >= 1) ? TRUE : FALSE);
685.1173 -		}
685.1174 -		s_prevSelCount = selCount;
685.1175 -	}
685.1176 -}
685.1177 -
685.1178 -
685.1179 -
685.1180 -
685.1181 -struct AddrRange
685.1182 -{
685.1183 -	unsigned int addr;
685.1184 -	unsigned int size;
685.1185 -	unsigned int End() const { return addr + size; }
685.1186 -	AddrRange(unsigned int a, unsigned int s) : addr(a),size(s){}
685.1187 -};
685.1188 -
685.1189 -void signal_new_size ()
685.1190 -{
685.1191 -	HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST);
685.1192 -
685.1193 -	int oldSize = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2;
685.1194 -	int newSize = (rs_type_size=='b' || !noMisalign) ? 1 : 2;
685.1195 -	bool numberOfItemsChanged = (oldSize != newSize);
685.1196 -
685.1197 -	unsigned int itemsPerPage = ListView_GetCountPerPage(lv);
685.1198 -	unsigned int oldTopIndex = ListView_GetTopIndex(lv);
685.1199 -	unsigned int oldSelectionIndex = ListView_GetSelectionMark(lv);
685.1200 -	unsigned int oldTopAddr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldTopIndex);
685.1201 -	unsigned int oldSelectionAddr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldSelectionIndex);
685.1202 -
685.1203 -	std::vector<AddrRange> selHardwareAddrs;
685.1204 -	if(numberOfItemsChanged)
685.1205 -	{
685.1206 -		// store selection ranges
685.1207 -		// unfortunately this can take a while if the user has a huge range of items selected
685.1208 -		systemSoundClearBuffer();
685.1209 -		int selCount = ListView_GetSelectedCount(lv);
685.1210 -		int size = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2;
685.1211 -		int watchIndex = -1;
685.1212 -		for(int i = 0; i < selCount; ++i)
685.1213 -		{
685.1214 -			watchIndex = ListView_GetNextItem(lv, watchIndex, LVNI_SELECTED);
685.1215 -			int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, watchIndex);
685.1216 -			if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
685.1217 -				selHardwareAddrs.back().size += size;
685.1218 -			else if (!(noMisalign && oldSize < newSize && addr % newSize != 0))
685.1219 -				selHardwareAddrs.push_back(AddrRange(addr,size));
685.1220 -		}
685.1221 -	}
685.1222 -
685.1223 -	CompactAddrs();
685.1224 -
685.1225 -	rs_last_type_size = rs_type_size;
685.1226 -	rs_last_no_misalign = noMisalign;
685.1227 -
685.1228 -	if(numberOfItemsChanged)
685.1229 -	{
685.1230 -		// restore selection ranges
685.1231 -		unsigned int newTopIndex = CALL_WITH_T_SIZE_TYPES_1(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, oldTopAddr);
685.1232 -		unsigned int newBottomIndex = newTopIndex + itemsPerPage - 1;
685.1233 -		SendMessage(lv, WM_SETREDRAW, FALSE, 0);
685.1234 -		ListView_SetItemState(lv, -1, 0, LVIS_SELECTED|LVIS_FOCUSED); // deselect all
685.1235 -		for(unsigned int i = 0; i < selHardwareAddrs.size(); i++)
685.1236 -		{
685.1237 -			// calculate index ranges of this selection
685.1238 -			const AddrRange& range = selHardwareAddrs[i];
685.1239 -			int selRangeTop = CALL_WITH_T_SIZE_TYPES_1(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, range.addr);
685.1240 -			int selRangeBottom = -1;
685.1241 -			for(int endAddr = range.End()-1; endAddr >= selRangeTop && selRangeBottom == -1; endAddr--)
685.1242 -				selRangeBottom = CALL_WITH_T_SIZE_TYPES_1(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, endAddr);
685.1243 -			if(selRangeBottom == -1)
685.1244 -				selRangeBottom = selRangeTop;
685.1245 -			if(selRangeTop == -1)
685.1246 -				continue;
685.1247 -
685.1248 -			// select the entire range
685.1249 -			for (int j = selRangeTop; j <= selRangeBottom; j++)
685.1250 -			{
685.1251 -				ListView_SetItemState(lv, j, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
685.1252 -			}
685.1253 -		}
685.1254 -
685.1255 -		// restore previous scroll position
685.1256 -		if(newBottomIndex != -1)
685.1257 -			ListView_EnsureVisible(lv, newBottomIndex, 0);
685.1258 -		if(newTopIndex != -1)
685.1259 -			ListView_EnsureVisible(lv, newTopIndex, 0);
685.1260 -
685.1261 -		SendMessage(lv, WM_SETREDRAW, TRUE, 0);
685.1262 -
685.1263 -		RefreshRamListSelectedCountControlStatus(RamSearchHWnd);
685.1264 -
685.1265 -		EnableWindow(GetDlgItem(RamSearchHWnd,IDC_MISALIGN), rs_type_size != 'b');
685.1266 -	}
685.1267 -	else
685.1268 -	{
685.1269 -		ListView_Update(lv, -1);
685.1270 -	}
685.1271 -	InvalidateRect(lv, NULL, TRUE);
685.1272 -	//SetFocus(lv);
685.1273 -}
685.1274 -
685.1275 -
685.1276 -
685.1277 -
685.1278 -LRESULT CustomDraw (LPARAM lParam)
685.1279 -{
685.1280 -	LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
685.1281 -
685.1282 -	switch(lplvcd->nmcd.dwDrawStage) 
685.1283 -	{
685.1284 -		case CDDS_PREPAINT :
685.1285 -			return CDRF_NOTIFYITEMDRAW;
685.1286 -
685.1287 -		case CDDS_ITEMPREPAINT:
685.1288 -		{
685.1289 -			int rv = CDRF_DODEFAULT;
685.1290 -
685.1291 -			if(lplvcd->nmcd.dwItemSpec % 2)
685.1292 -			{
685.1293 -				// alternate the background color slightly
685.1294 -				lplvcd->clrTextBk = RGB(248,248,255);
685.1295 -				rv = CDRF_NEWFONT;
685.1296 -			}
685.1297 -
685.1298 -			if(!IsSatisfied(lplvcd->nmcd.dwItemSpec))
685.1299 -			{
685.1300 -				// tint red any items that would be eliminated if a search were to run now
685.1301 -				lplvcd->clrText = RGB(192,64,64);
685.1302 -				rv = CDRF_NEWFONT;
685.1303 -			}
685.1304 -
685.1305 -			return rv;
685.1306 -		}	break;
685.1307 -	}
685.1308 -	return CDRF_DODEFAULT;
685.1309 -}
685.1310 -
685.1311 -void Update_RAM_Search() //keeps RAM values up to date in the search and watch windows
685.1312 -{
685.1313 -	if(disableRamSearchUpdate)
685.1314 -		return;
685.1315 -
685.1316 -	int prevValuesNeededUpdate;
685.1317 -	if (AutoSearch && !ResultCount)
685.1318 -	{
685.1319 -		if(!AutoSearchAutoRetry)
685.1320 -		{
685.1321 -			systemSoundClearBuffer();
685.1322 -			int answer = MessageBox(RamSearchHWnd,"Choosing Retry will reset the search once and continue autosearching.\nChoose Ignore will reset the search whenever necessary and continue autosearching.\nChoosing Abort will reset the search once and stop autosearching.","Autosearch - out of results.",MB_ABORTRETRYIGNORE|MB_DEFBUTTON2|MB_ICONINFORMATION);
685.1323 -			if(answer == IDABORT)
685.1324 -			{
685.1325 -				SendDlgItemMessage(RamSearchHWnd, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0);
685.1326 -				SendMessage(RamSearchHWnd, WM_COMMAND, IDC_C_AUTOSEARCH, 0);
685.1327 -			}
685.1328 -			if(answer == IDIGNORE)
685.1329 -				AutoSearchAutoRetry = true;
685.1330 -		}
685.1331 -		reset_address_info();
685.1332 -		prevValuesNeededUpdate = s_prevValuesNeedUpdate;
685.1333 -	}
685.1334 -	else
685.1335 -	{
685.1336 -		prevValuesNeededUpdate = s_prevValuesNeedUpdate;
685.1337 -		if (RamSearchHWnd)
685.1338 -		{
685.1339 -			// update active RAM values
685.1340 -			signal_new_frame();
685.1341 -		}
685.1342 -
685.1343 -		if (AutoSearch && ResultCount)
685.1344 -		{
685.1345 -			systemSoundClearBuffer();
685.1346 -			if(!rs_val_valid)
685.1347 -				rs_val_valid = Set_RS_Val();
685.1348 -			if(rs_val_valid)
685.1349 -				prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param);
685.1350 -		}
685.1351 -	}
685.1352 -
685.1353 -	if(RamSearchHWnd)
685.1354 -	{
685.1355 -		HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST);
685.1356 -		if(prevValuesNeededUpdate != s_prevValuesNeedUpdate)
685.1357 -		{
685.1358 -			// previous values got updated, refresh everything visible
685.1359 -			ListView_Update(lv, -1);
685.1360 -		}
685.1361 -		else
685.1362 -		{
685.1363 -			// refresh any visible parts of the listview box that changed
685.1364 -			static int changes[128];
685.1365 -			int top = ListView_GetTopIndex(lv);
685.1366 -			int count = ListView_GetCountPerPage(lv);
685.1367 -			int start = -1;
685.1368 -			for(int i = top; i <= top+count; i++)
685.1369 -			{
685.1370 -				int changeNum = CALL_WITH_T_SIZE_TYPES_1(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, i); //s_numChanges[i];
685.1371 -				int changed = changeNum != changes[i-top];
685.1372 -				if(changed)
685.1373 -					changes[i-top] = changeNum;
685.1374 -
685.1375 -				if(start == -1)
685.1376 -				{
685.1377 -					if(i != top+count && changed)
685.1378 -					{
685.1379 -						start = i;
685.1380 -						//somethingChanged = true;
685.1381 -					}
685.1382 -				}
685.1383 -				else
685.1384 -				{
685.1385 -					if(i == top+count || !changed)
685.1386 -					{
685.1387 -						ListView_RedrawItems(lv, start, i-1);
685.1388 -						start = -1;
685.1389 -					}
685.1390 -				}
685.1391 -			}
685.1392 -		}
685.1393 -	}
685.1394 -
685.1395 -	if(RamWatchHWnd)
685.1396 -	{
685.1397 -		Update_RAM_Watch();
685.1398 -	}
685.1399 -}
685.1400 -
685.1401 -static int rs_lastPercent = -1;
685.1402 -inline void UpdateRamSearchProgressBar(int percent)
685.1403 -{
685.1404 -	if(rs_lastPercent != percent)
685.1405 -	{
685.1406 -		rs_lastPercent = percent;
685.1407 -		UpdateRamSearchTitleBar(percent);
685.1408 -	}
685.1409 -}
685.1410 -
685.1411 -static void SelectEditControl(int controlID)
685.1412 -{
685.1413 -	HWND hEdit = GetDlgItem(RamSearchHWnd,controlID);
685.1414 -	SetFocus(hEdit);
685.1415 -	SendMessage(hEdit, EM_SETSEL, 0, -1);
685.1416 -}
685.1417 -
685.1418 -static BOOL SelectingByKeyboard()
685.1419 -{
685.1420 -	int a = GetKeyState(VK_LEFT);
685.1421 -	int b = GetKeyState(VK_RIGHT);
685.1422 -	int c = GetKeyState(VK_UP);
685.1423 -	int d = GetKeyState(VK_DOWN); // space and tab are intentionally omitted
685.1424 -	return (a | b | c | d) & 0x80;
685.1425 -}
685.1426 -
685.1427 -
685.1428 -LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
685.1429 -{
685.1430 -	static int watchIndex=0;
685.1431 -
685.1432 -	switch(uMsg)
685.1433 -	{
685.1434 -		case WM_INITDIALOG: {
685.1435 -			RamSearchHWnd = hDlg;
685.1436 -			
685.1437 -			SetWindowPos(hDlg, NULL, regQueryDwordValue("ramSearchX", 0), regQueryDwordValue("ramSearchY", 0), NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
685.1438 -			switch(rs_o)
685.1439 -			{
685.1440 -				case '<':
685.1441 -					SendDlgItemMessage(hDlg, IDC_LESSTHAN, BM_SETCHECK, BST_CHECKED, 0);
685.1442 -					break;
685.1443 -				case '>':
685.1444 -					SendDlgItemMessage(hDlg, IDC_MORETHAN, BM_SETCHECK, BST_CHECKED, 0);
685.1445 -					break;
685.1446 -				case 'l':
685.1447 -					SendDlgItemMessage(hDlg, IDC_NOMORETHAN, BM_SETCHECK, BST_CHECKED, 0);
685.1448 -					break;
685.1449 -				case 'm':
685.1450 -					SendDlgItemMessage(hDlg, IDC_NOLESSTHAN, BM_SETCHECK, BST_CHECKED, 0);
685.1451 -					break;
685.1452 -				case '=': 
685.1453 -					SendDlgItemMessage(hDlg, IDC_EQUALTO, BM_SETCHECK, BST_CHECKED, 0);
685.1454 -					break;
685.1455 -				case '!':
685.1456 -					SendDlgItemMessage(hDlg, IDC_DIFFERENTFROM, BM_SETCHECK, BST_CHECKED, 0);
685.1457 -					break;
685.1458 -				case 'd':
685.1459 -					SendDlgItemMessage(hDlg, IDC_DIFFERENTBY, BM_SETCHECK, BST_CHECKED, 0);
685.1460 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true);
685.1461 -					break;
685.1462 -				case '%':
685.1463 -					SendDlgItemMessage(hDlg, IDC_MODULO, BM_SETCHECK, BST_CHECKED, 0);
685.1464 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true);
685.1465 -					break;
685.1466 -			}
685.1467 -			switch (rs_c)
685.1468 -			{
685.1469 -				case 'r':
685.1470 -					SendDlgItemMessage(hDlg, IDC_PREVIOUSVALUE, BM_SETCHECK, BST_CHECKED, 0);
685.1471 -					break;
685.1472 -				case 's':
685.1473 -					SendDlgItemMessage(hDlg, IDC_SPECIFICVALUE, BM_SETCHECK, BST_CHECKED, 0);
685.1474 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true);
685.1475 -					break;
685.1476 -				case 'a':
685.1477 -					SendDlgItemMessage(hDlg, IDC_SPECIFICADDRESS, BM_SETCHECK, BST_CHECKED, 0);
685.1478 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true);
685.1479 -					break;
685.1480 -				case 'n':
685.1481 -					SendDlgItemMessage(hDlg, IDC_NUMBEROFCHANGES, BM_SETCHECK, BST_CHECKED, 0);
685.1482 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true);
685.1483 -					break;
685.1484 -			}
685.1485 -			switch (rs_t)
685.1486 -			{
685.1487 -				case 's':
685.1488 -					SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0);
685.1489 -					break;
685.1490 -				case 'u':
685.1491 -					SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0);
685.1492 -					break;
685.1493 -				case 'h':
685.1494 -					SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0);
685.1495 -					break;
685.1496 -			}
685.1497 -			switch (rs_type_size)
685.1498 -			{
685.1499 -				case 'b':
685.1500 -					SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0);
685.1501 -					break;
685.1502 -				case 'w':
685.1503 -					SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0);
685.1504 -					break;
685.1505 -				case 'd':
685.1506 -					SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0);
685.1507 -					break;
685.1508 -			}
685.1509 -
685.1510 -			s_prevValuesNeedUpdate = true;
685.1511 -
685.1512 -			SendDlgItemMessage(hDlg,IDC_C_AUTOSEARCH,BM_SETCHECK,AutoSearch?BST_CHECKED:BST_UNCHECKED,0);
685.1513 -			//const char* names[5] = {"Address","Value","Previous","Changes","Notes"};
685.1514 -			//int widths[5] = {62,64,64,55,55};
685.1515 -			const char* names[] = {"Address","Value","Previous","Changes"};
685.1516 -			int widths[4] = {68,76,76,68};
685.1517 -			if (!ResultCount)
685.1518 -				reset_address_info();
685.1519 -			else
685.1520 -			{
685.1521 -				signal_new_frame();
685.1522 -				CompactAddrs();
685.1523 -			}
685.1524 -			void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths);
685.1525 -			init_list_box(GetDlgItem(hDlg,IDC_RAMLIST),names,4,widths);
685.1526 -			//ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount);
685.1527 -			if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0);
685.1528 -			//if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0);
685.1529 -			last_rs_possible = -1;
685.1530 -
685.1531 -			s_prevSelCount = -1;
685.1532 -			RefreshRamListSelectedCountControlStatus(hDlg);
685.1533 -
685.1534 -			// force misalign checkbox to refresh
685.1535 -			signal_new_size();
685.1536 -
685.1537 -			// force undo button to refresh
685.1538 -			int undoType = s_undoType;
685.1539 -			SetRamSearchUndoType(hDlg, -2);
685.1540 -			SetRamSearchUndoType(hDlg, undoType);
685.1541 -
685.1542 -			// force possibility count to refresh
685.1543 -			last_rs_possible--;
685.1544 -			UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size());
685.1545 -			
685.1546 -			rs_val_valid = Set_RS_Val();
685.1547 -
685.1548 -			ListView_SetCallbackMask(GetDlgItem(hDlg,IDC_RAMLIST), LVIS_FOCUSED|LVIS_SELECTED);
685.1549 -
685.1550 -			return true;
685.1551 -		}	break;
685.1552 -
685.1553 -		case WM_NOTIFY:
685.1554 -		{
685.1555 -			LPNMHDR lP = (LPNMHDR) lParam;
685.1556 -			switch (lP->code)
685.1557 -			{
685.1558 -				case LVN_ITEMCHANGED: // selection changed event
685.1559 -				{
685.1560 -					NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP;
685.1561 -					if(pNMListView->uNewState & LVIS_FOCUSED ||
685.1562 -						(pNMListView->uNewState ^ pNMListView->uOldState) & LVIS_SELECTED)
685.1563 -					{
685.1564 -						// disable buttons that we don't have the right number of selected items for
685.1565 -						RefreshRamListSelectedCountControlStatus(hDlg);
685.1566 -					}
685.1567 -				}	break;
685.1568 -
685.1569 -				case LVN_GETDISPINFO:
685.1570 -				{
685.1571 -					LV_DISPINFO *Item = (LV_DISPINFO *)lParam;
685.1572 -					Item->item.mask = LVIF_TEXT;
685.1573 -					Item->item.state = 0;
685.1574 -					Item->item.iImage = 0;
685.1575 -					const unsigned int iNum = Item->item.iItem;
685.1576 -					static char num[11];
685.1577 -					switch (Item->item.iSubItem)
685.1578 -					{
685.1579 -						case 0:
685.1580 -						{
685.1581 -							int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
685.1582 -							sprintf(num,"%08X",addr);
685.1583 -							Item->item.pszText = num;
685.1584 -						}	return true;
685.1585 -						case 1:
685.1586 -						{
685.1587 -							int i = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
685.1588 -							const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X"));
685.1589 -							switch (rs_type_size)
685.1590 -							{
685.1591 -								case 'b':
685.1592 -								default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
685.1593 -								case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
685.1594 -								case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
685.1595 -							}
685.1596 -							Item->item.pszText = num;
685.1597 -						}	return true;
685.1598 -						case 2:
685.1599 -						{
685.1600 -							int i = CALL_WITH_T_SIZE_TYPES_1(GetPrevValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
685.1601 -							const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X"));
685.1602 -							switch (rs_type_size)
685.1603 -							{
685.1604 -								case 'b':
685.1605 -								default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
685.1606 -								case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
685.1607 -								case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
685.1608 -							}
685.1609 -							Item->item.pszText = num;
685.1610 -						}	return true;
685.1611 -						case 3:
685.1612 -						{
685.1613 -							int i = CALL_WITH_T_SIZE_TYPES_1(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
685.1614 -							sprintf(num,"%d",i);
685.1615 -
685.1616 -							Item->item.pszText = num;
685.1617 -						}	return true;
685.1618 -						//case 4:
685.1619 -						//	Item->item.pszText = rsaddrs[rsresults[iNum].Index].comment ? rsaddrs[rsresults[iNum].Index].comment : "";
685.1620 -						//	return true;
685.1621 -						default:
685.1622 -							return false;
685.1623 -					}
685.1624 -				}
685.1625 -
685.1626 -				case NM_CUSTOMDRAW:
685.1627 -				{
685.1628 -					SetWindowLong(hDlg, DWL_MSGRESULT, CustomDraw(lParam));
685.1629 -					return TRUE;
685.1630 -				}	break;
685.1631 -
685.1632 -				//case LVN_ODCACHEHINT: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something.
685.1633 -				//{
685.1634 -				//	LPNMLVCACHEHINT   lpCacheHint = (LPNMLVCACHEHINT)lParam;
685.1635 -				//	return 0;
685.1636 -				//}
685.1637 -				//case LVN_ODFINDITEM: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something.
685.1638 -				//{	
685.1639 -				//	LPNMLVFINDITEM lpFindItem = (LPNMLVFINDITEM)lParam;
685.1640 -				//	return 0;
685.1641 -				//}
685.1642 -			}
685.1643 -		}	break;
685.1644 -
685.1645 -		case WM_COMMAND:
685.1646 -		{
685.1647 -			int rv = false;
685.1648 -			switch(LOWORD(wParam))
685.1649 -			{
685.1650 -				case IDC_SIGNED:
685.1651 -					rs_t='s';
685.1652 -					signal_new_size();
685.1653 -					{rv = true; break;}
685.1654 -				case IDC_UNSIGNED:
685.1655 -					rs_t='u';
685.1656 -					signal_new_size();
685.1657 -					{rv = true; break;}
685.1658 -				case IDC_HEX:
685.1659 -					rs_t='h';
685.1660 -					signal_new_size();
685.1661 -					{rv = true; break;}
685.1662 -				case IDC_1_BYTE:
685.1663 -					rs_type_size = 'b';
685.1664 -					signal_new_size();
685.1665 -					{rv = true; break;}
685.1666 -				case IDC_2_BYTES:
685.1667 -					rs_type_size = 'w';
685.1668 -					signal_new_size();
685.1669 -					{rv = true; break;}
685.1670 -				case IDC_4_BYTES:
685.1671 -					rs_type_size = 'd';
685.1672 -					signal_new_size();
685.1673 -					{rv = true; break;}
685.1674 -				case IDC_MISALIGN:
685.1675 -					noMisalign = !noMisalign;
685.1676 -					//CompactAddrs();
685.1677 -					signal_new_size();
685.1678 -					{rv = true; break;}
685.1679 -//				case IDC_ENDIAN:
685.1680 -////					littleEndian = !littleEndian;
685.1681 -////					signal_new_size();
685.1682 -//					{rv = true; break;}				
685.1683 -				case IDC_LESSTHAN:
685.1684 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1685 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1686 -					rs_o = '<';
685.1687 -					{rv = true; break;}
685.1688 -				case IDC_MORETHAN:
685.1689 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1690 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1691 -					rs_o = '>';
685.1692 -					{rv = true; break;}
685.1693 -				case IDC_NOMORETHAN:
685.1694 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1695 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1696 -					rs_o = 'l';
685.1697 -					{rv = true; break;}
685.1698 -				case IDC_NOLESSTHAN:
685.1699 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1700 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1701 -					rs_o = 'm';
685.1702 -					{rv = true; break;}
685.1703 -				case IDC_EQUALTO:
685.1704 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1705 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1706 -					rs_o = '=';
685.1707 -					{rv = true; break;}
685.1708 -				case IDC_DIFFERENTFROM:
685.1709 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1710 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1711 -					rs_o = '!';
685.1712 -					{rv = true; break;}
685.1713 -				case IDC_DIFFERENTBY:
685.1714 -				{
685.1715 -					rs_o = 'd';
685.1716 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true);
685.1717 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
685.1718 -					if(!SelectingByKeyboard())
685.1719 -						SelectEditControl(IDC_EDIT_DIFFBY);
685.1720 -				}	{rv = true; break;}
685.1721 -				case IDC_MODULO:
685.1722 -				{
685.1723 -					rs_o = '%';
685.1724 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
685.1725 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true);
685.1726 -					if(!SelectingByKeyboard())
685.1727 -						SelectEditControl(IDC_EDIT_MODBY);
685.1728 -				}	{rv = true; break;}
685.1729 -				case IDC_PREVIOUSVALUE:
685.1730 -					rs_c='r';
685.1731 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
685.1732 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
685.1733 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
685.1734 -					{rv = true; break;}
685.1735 -				case IDC_SPECIFICVALUE:
685.1736 -				{
685.1737 -					rs_c = 's';
685.1738 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true);
685.1739 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
685.1740 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
685.1741 -					if(!SelectingByKeyboard())
685.1742 -						SelectEditControl(IDC_EDIT_COMPAREVALUE);
685.1743 -					{rv = true; break;}
685.1744 -				}
685.1745 -				case IDC_SPECIFICADDRESS:
685.1746 -				{
685.1747 -					rs_c = 'a';
685.1748 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true);
685.1749 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
685.1750 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
685.1751 -					if(!SelectingByKeyboard())
685.1752 -						SelectEditControl(IDC_EDIT_COMPAREADDRESS);
685.1753 -				}	{rv = true; break;}
685.1754 -				case IDC_NUMBEROFCHANGES:
685.1755 -				{
685.1756 -					rs_c = 'n';
685.1757 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true);
685.1758 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
685.1759 -					EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
685.1760 -					if(!SelectingByKeyboard())
685.1761 -						SelectEditControl(IDC_EDIT_COMPARECHANGES);
685.1762 -				}	{rv = true; break;}
685.1763 -				case IDC_C_ADDCHEAT:
685.1764 -				{
685.1765 -					HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
685.1766 -					int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
685.1767 -					while (watchItemIndex >= 0)
685.1768 -					{
685.1769 -						unsigned long address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
685.1770 -
685.1771 -						int sizeType = -1;
685.1772 -						if(rs_type_size == 'b')
685.1773 -							sizeType = 0;
685.1774 -						else if(rs_type_size == 'w')
685.1775 -							sizeType = 1;
685.1776 -						else if(rs_type_size == 'd')
685.1777 -							sizeType = 2;
685.1778 -
685.1779 -						int numberType = -1;
685.1780 -						if(rs_t == 's')
685.1781 -							numberType = 0;
685.1782 -						else if(rs_t == 'u')
685.1783 -							numberType = 1;
685.1784 -						else if(rs_t == 'h')
685.1785 -							numberType = 2;
685.1786 -
685.1787 -						if(systemCartridgeType == 0)
685.1788 -						{
685.1789 -							AddCheat dlg (address/*, hDlg*/);
685.1790 -							if(sizeType != -1) dlg.sizeType = sizeType;
685.1791 -							if(numberType != -1) dlg.numberType = numberType;
685.1792 -							dlg.DoModal();
685.1793 -						}
685.1794 -						else
685.1795 -						{
685.1796 -							AddGBCheat dlg (address/*, hDlg*/);
685.1797 -							if(sizeType != -1) dlg.sizeType = sizeType;
685.1798 -							if(numberType != -1) dlg.numberType = numberType;
685.1799 -							dlg.DoModal();
685.1800 -						}
685.1801 -						watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
685.1802 -					}
685.1803 -				}	{rv = true; break;}
685.1804 -				case IDC_C_RESET:
685.1805 -				{
685.1806 -					RamSearchSaveUndoStateIfNotTooBig(RamSearchHWnd);
685.1807 -					int prevNumItems = last_rs_possible;
685.1808 -
685.1809 -					soft_reset_address_info();
685.1810 -
685.1811 -					if(prevNumItems == last_rs_possible)
685.1812 -						SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo
685.1813 -
685.1814 -					ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
685.1815 -					//ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount);
685.1816 -					ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0);
685.1817 -					RefreshRamListSelectedCountControlStatus(hDlg);
685.1818 -					{rv = true; break;}
685.1819 -				}
685.1820 -				case IDC_C_RESET_CHANGES:
685.1821 -					memset(s_numChanges, 0, (sizeof(*s_numChanges)*(MAX_RAM_SIZE)));
685.1822 -					ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1);
685.1823 -					//SetRamSearchUndoType(hDlg, 0);
685.1824 -					{rv = true; break;}
685.1825 -				case IDC_C_UNDO:
685.1826 -					if(s_undoType>0)
685.1827 -					{
685.1828 -						systemSoundClearBuffer();
685.1829 -						EnterCriticalSection(&s_activeMemoryRegionsCS);
685.1830 -						if(s_activeMemoryRegions.size() < tooManyRegionsForUndo)
685.1831 -						{
685.1832 -							MemoryList tempMemoryList = s_activeMemoryRegions;
685.1833 -							s_activeMemoryRegions = s_activeMemoryRegionsBackup;
685.1834 -							s_activeMemoryRegionsBackup = tempMemoryList;
685.1835 -							LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1836 -							SetRamSearchUndoType(hDlg, 3 - s_undoType);
685.1837 -						}
685.1838 -						else
685.1839 -						{
685.1840 -							s_activeMemoryRegions = s_activeMemoryRegionsBackup;
685.1841 -							LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.1842 -							SetRamSearchUndoType(hDlg, -1);
685.1843 -						}
685.1844 -						CompactAddrs();
685.1845 -						ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
685.1846 -						ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0);
685.1847 -						RefreshRamListSelectedCountControlStatus(hDlg);
685.1848 -					}
685.1849 -					{rv = true; break;}
685.1850 -				case IDC_C_AUTOSEARCH:
685.1851 -					AutoSearch = SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_GETCHECK, 0, 0) != 0;
685.1852 -					AutoSearchAutoRetry = false;
685.1853 -					if (!AutoSearch) {rv = true; break;}
685.1854 -				case IDC_C_SEARCH:
685.1855 -				{
685.1856 -					systemSoundClearBuffer();
685.1857 -
685.1858 -					if(!rs_val_valid && !(rs_val_valid = Set_RS_Val()))
685.1859 -						goto invalid_field;
685.1860 -
685.1861 -					if(ResultCount)
685.1862 -					{
685.1863 -						RamSearchSaveUndoStateIfNotTooBig(hDlg);
685.1864 -
685.1865 -						prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param);
685.1866 -
685.1867 -						RefreshRamListSelectedCountControlStatus(hDlg);
685.1868 -					}
685.1869 -
685.1870 -					if(!ResultCount)
685.1871 -					{
685.1872 -
685.1873 -						MessageBox(RamSearchHWnd,"Resetting search.","Out of results.",MB_OK|MB_ICONINFORMATION);
685.1874 -						soft_reset_address_info();
685.1875 -					}
685.1876 -
685.1877 -					{rv = true; break;}
685.1878 -
685.1879 -invalid_field:
685.1880 -					MessageBox(RamSearchHWnd,"Invalid or out-of-bound entered value.","Error",MB_OK|MB_ICONSTOP);
685.1881 -					if(AutoSearch) // stop autosearch if it just started
685.1882 -					{
685.1883 -						SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0);
685.1884 -						SendMessage(hDlg, WM_COMMAND, IDC_C_AUTOSEARCH, 0);
685.1885 -					}
685.1886 -					{rv = true; break;}
685.1887 -				}
685.1888 -				case IDC_C_WATCH:
685.1889 -				{
685.1890 -					HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
685.1891 -					int selCount = ListView_GetSelectedCount(ramListControl);
685.1892 -
685.1893 -					bool inserted = false;
685.1894 -					int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
685.1895 -					while (watchItemIndex >= 0)
685.1896 -					{
685.1897 -						AddressWatcher tempWatch;
685.1898 -						tempWatch.Address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
685.1899 -						tempWatch.Size = rs_type_size;
685.1900 -						tempWatch.Type = rs_t;
685.1901 -						tempWatch.WrongEndian = 0; //Replace when I get little endian working
685.1902 -						tempWatch.comment = NULL;
685.1903 -
685.1904 -						if (selCount == 1)
685.1905 -							inserted |= InsertWatch(tempWatch, hDlg);
685.1906 -						else
685.1907 -							inserted |= InsertWatch(tempWatch, "");
685.1908 -
685.1909 -						watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
685.1910 -					}
685.1911 -					// bring up the ram watch window if it's not already showing so the user knows where the watch went
685.1912 -					if(inserted && !RamWatchHWnd)
685.1913 -						SendMessage(hWnd, WM_COMMAND, ID_RAM_WATCH, 0);
685.1914 -					SetForegroundWindow(RamSearchHWnd);
685.1915 -					{rv = true; break;}
685.1916 -				}
685.1917 -
685.1918 -				// eliminate all selected items
685.1919 -				case IDC_C_ELIMINATE:
685.1920 -				{
685.1921 -					RamSearchSaveUndoStateIfNotTooBig(hDlg);
685.1922 -
685.1923 -					HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
685.1924 -					int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2;
685.1925 -					int selCount = ListView_GetSelectedCount(ramListControl);
685.1926 -					int watchIndex = -1;
685.1927 -
685.1928 -					// time-saving trick #1:
685.1929 -					// condense the selected items into an array of address ranges
685.1930 -					std::vector<AddrRange> selHardwareAddrs;
685.1931 -					for(int i = 0, j = 1024; i < selCount; ++i, --j)
685.1932 -					{
685.1933 -						watchIndex = ListView_GetNextItem(ramListControl, watchIndex, LVNI_SELECTED);
685.1934 -						int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchIndex);
685.1935 -						if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
685.1936 -							selHardwareAddrs.back().size += size;
685.1937 -						else
685.1938 -							selHardwareAddrs.push_back(AddrRange(addr,size));
685.1939 -
685.1940 -						if(!j) UpdateRamSearchProgressBar(i * 50 / selCount), j = 1024;
685.1941 -					}
685.1942 -
685.1943 -					// now deactivate the ranges
685.1944 -
685.1945 -					// time-saving trick #2:
685.1946 -					// take advantage of the fact that the listbox items must be in the same order as the regions
685.1947 -					MemoryList::iterator iter = s_activeMemoryRegions.begin();
685.1948 -					int numHardwareAddrRanges = selHardwareAddrs.size();
685.1949 -					for(int i = 0, j = 16; i < numHardwareAddrRanges; ++i, --j)
685.1950 -					{
685.1951 -						int addr = selHardwareAddrs[i].addr;
685.1952 -						int size = selHardwareAddrs[i].size;
685.1953 -						bool affected = false;
685.1954 -						while(iter != s_activeMemoryRegions.end())
685.1955 -						{
685.1956 -							MemoryRegion& region = *iter;
685.1957 -							int affNow = DeactivateRegion(region, iter, addr, size);
685.1958 -							if(affNow)
685.1959 -								affected = true;
685.1960 -							else if(affected)
685.1961 -								break;
685.1962 -							if(affNow != 2)
685.1963 -								++iter;
685.1964 -						}
685.1965 -
685.1966 -						if(!j) UpdateRamSearchProgressBar(50 + (i * 50 / selCount)), j = 16;
685.1967 -					}
685.1968 -					UpdateRamSearchTitleBar();
685.1969 -
685.1970 -					// careful -- if the above two time-saving tricks aren't working,
685.1971 -					// the runtime can absolutely explode (seconds -> hours) when there are lots of regions
685.1972 -
685.1973 -					ListView_SetItemState(ramListControl, -1, 0, LVIS_SELECTED); // deselect all
685.1974 -					signal_new_size();
685.1975 -					{rv = true; break;}
685.1976 -				}
685.1977 -				//case IDOK:
685.1978 -				case IDCANCEL:
685.1979 -					RamSearchHWnd = NULL;
685.1980 -/*					if (theApp.pauseDuringCheatSearch)
685.1981 -						EndDialog(hDlg, true);	// this should never be called on a modeless dialog
685.1982 -					else
685.1983 -*/
685.1984 -						DestroyWindow(hDlg);
685.1985 -					{rv = true; break;}
685.1986 -			}
685.1987 -
685.1988 -			// check refresh for comparison preview color update
685.1989 -			// also, update rs_val if needed
685.1990 -			bool needRefresh = false;
685.1991 -			switch(LOWORD(wParam))
685.1992 -			{
685.1993 -				case IDC_LESSTHAN:
685.1994 -				case IDC_MORETHAN:
685.1995 -				case IDC_NOMORETHAN:
685.1996 -				case IDC_NOLESSTHAN:
685.1997 -				case IDC_EQUALTO:
685.1998 -				case IDC_DIFFERENTFROM:
685.1999 -				case IDC_DIFFERENTBY:
685.2000 -				case IDC_MODULO:
685.2001 -				case IDC_PREVIOUSVALUE:
685.2002 -				case IDC_SPECIFICVALUE:
685.2003 -				case IDC_SPECIFICADDRESS:
685.2004 -				case IDC_NUMBEROFCHANGES:
685.2005 -				case IDC_SIGNED:
685.2006 -				case IDC_UNSIGNED:
685.2007 -				case IDC_HEX:
685.2008 -					rs_val_valid = Set_RS_Val();
685.2009 -					needRefresh = true;
685.2010 -					break;
685.2011 -				case IDC_EDIT_COMPAREVALUE:
685.2012 -				case IDC_EDIT_COMPAREADDRESS:
685.2013 -				case IDC_EDIT_COMPARECHANGES:
685.2014 -				case IDC_EDIT_DIFFBY:
685.2015 -				case IDC_EDIT_MODBY:
685.2016 -					if(HIWORD(wParam) == EN_CHANGE)
685.2017 -					{
685.2018 -						rs_val_valid = Set_RS_Val();
685.2019 -						needRefresh = true;
685.2020 -					}
685.2021 -					break;
685.2022 -			}
685.2023 -			if(needRefresh)
685.2024 -				ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1);
685.2025 -
685.2026 -
685.2027 -			return rv;
685.2028 -		}	break;
685.2029 -
685.2030 -		case WM_CLOSE:
685.2031 -			RECT r;
685.2032 -			GetWindowRect(hDlg, &r);
685.2033 -			regSetDwordValue("ramSearchX", r.left);
685.2034 -			regSetDwordValue("ramSearchY", r.top);
685.2035 -			SendMessage(RamSearchHWnd, WM_DESTROY, 0, 0);
685.2036 -			break;
685.2037 -		case WM_DESTROY:
685.2038 -			RamSearchHWnd = NULL;
685.2039 -//			theApp.modelessCheatDialogIsOpen = false;
685.2040 -//			return true;
685.2041 -			break;
685.2042 -	}
685.2043 -
685.2044 -	return false;
685.2045 -}
685.2046 -
685.2047 -void UpdateRamSearchTitleBar(int percent)
685.2048 -{
685.2049 -#define HEADER_STR " RAM Search - "
685.2050 -#define PROGRESS_STR " %d%% ... "
685.2051 -#define STATUS_STR "%d Possibilit%s (%d Region%s)"
685.2052 -
685.2053 -	int poss = last_rs_possible;
685.2054 -	int regions = last_rs_regions;
685.2055 -	if(poss <= 0)
685.2056 -		strcpy(Str_Tmp," RAM Search");
685.2057 -	else if(percent <= 0)
685.2058 -		sprintf(Str_Tmp, HEADER_STR STATUS_STR, poss, poss==1?"y":"ies", regions, regions==1?"":"s");
685.2059 -	else
685.2060 -		sprintf(Str_Tmp, PROGRESS_STR STATUS_STR, percent, poss, poss==1?"y":"ies", regions, regions==1?"":"s");
685.2061 -	SetWindowText(RamSearchHWnd, Str_Tmp);
685.2062 -}
685.2063 -
685.2064 -void UpdatePossibilities(int rs_possible, int regions)
685.2065 -{
685.2066 -	if(rs_possible != last_rs_possible)
685.2067 -	{
685.2068 -		last_rs_possible = rs_possible;
685.2069 -		last_rs_regions = regions;
685.2070 -		UpdateRamSearchTitleBar();
685.2071 -	}
685.2072 -}
685.2073 -
685.2074 -void SetRamSearchUndoType(HWND hDlg, int type)
685.2075 -{
685.2076 -	if(s_undoType != type)
685.2077 -	{
685.2078 -		if((s_undoType!=2 && s_undoType!=-1)!=(type!=2 && type!=-1))
685.2079 -			SendDlgItemMessage(hDlg,IDC_C_UNDO,WM_SETTEXT,0,(LPARAM)((type == 2 || type == -1) ? "Redo" : "Undo"));
685.2080 -		if((s_undoType>0)!=(type>0))
685.2081 -			EnableWindow(GetDlgItem(hDlg,IDC_C_UNDO),type>0);
685.2082 -		s_undoType = type;
685.2083 -	}
685.2084 -}
685.2085 -
685.2086 -void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg)
685.2087 -{
685.2088 -	EnterCriticalSection(&s_activeMemoryRegionsCS);
685.2089 -	if(s_activeMemoryRegions.size() < tooManyRegionsForUndo)
685.2090 -	{
685.2091 -		s_activeMemoryRegionsBackup = s_activeMemoryRegions;
685.2092 -		LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.2093 -		SetRamSearchUndoType(hDlg, 1);
685.2094 -	}
685.2095 -	else
685.2096 -	{
685.2097 -		LeaveCriticalSection(&s_activeMemoryRegionsCS);
685.2098 -		SetRamSearchUndoType(hDlg, 0);
685.2099 -	}
685.2100 -}
685.2101 -
685.2102 -struct InitRamSearch
685.2103 -{
685.2104 -	InitRamSearch()
685.2105 -	{
685.2106 -		InitializeCriticalSection(&s_activeMemoryRegionsCS);
685.2107 -	}
685.2108 -	~InitRamSearch()
685.2109 -	{
685.2110 -		DeleteCriticalSection(&s_activeMemoryRegionsCS);
685.2111 -	}
685.2112 -} initRamSearch;
685.2113 -
685.2114 -
685.2115 -void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths) //initializes the ram search and/or ram watch listbox
685.2116 -{
685.2117 -	LVCOLUMN Col;
685.2118 -	Col.mask = LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
685.2119 -	Col.fmt = LVCFMT_CENTER;
685.2120 -	for (int i = 0; i < numColumns; i++)
685.2121 -	{
685.2122 -		Col.iOrder = i;
685.2123 -		Col.iSubItem = i;
685.2124 -		Col.pszText = (LPSTR)(Strs[i]);
685.2125 -		Col.cx = columnWidths[i];
685.2126 -		ListView_InsertColumn(Box,i,&Col);
685.2127 -	}
685.2128 -
685.2129 -	ListView_SetExtendedListViewStyle(Box, LVS_EX_FULLROWSELECT);
685.2130 -}
   686.1 --- a/src/win32/ram_search.h	Sat Mar 03 10:54:39 2012 -0600
   686.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   686.3 @@ -1,34 +0,0 @@
   686.4 -#ifndef RAM_SEARCH_H
   686.5 -#define RAM_SEARCH_H
   686.6 -
   686.7 -
   686.8 -extern char rs_type_size;
   686.9 -extern int ResultCount;
  686.10 -typedef unsigned int HWAddressType;
  686.11 -
  686.12 -unsigned int sizeConv(unsigned int index,char size, char *prevSize = &rs_type_size, bool usePrev = false);
  686.13 -unsigned int GetRamValue(unsigned int Addr,char Size);
  686.14 -void prune(char Search, char Operater, char Type, int Value, int OperatorParameter);
  686.15 -void CompactAddrs();
  686.16 -void reset_address_info();
  686.17 -void signal_new_frame();
  686.18 -void signal_new_size();
  686.19 -void UpdateRamSearchTitleBar(int percent = 0);
  686.20 -void SetRamSearchUndoType(HWND hDlg, int type);
  686.21 -unsigned int ReadValueAtHardwareAddress(HWAddressType address, unsigned int size);
  686.22 -bool WriteValueAtHardwareAddress(HWAddressType address, unsigned int value, unsigned int size);
  686.23 -bool IsHardwareAddressValid(HWAddressType address);
  686.24 -extern int curr_ram_size;
  686.25 -extern bool noMisalign;
  686.26 -extern HWND RamSearchHWnd;
  686.27 -
  686.28 -
  686.29 -void ResetResults();
  686.30 -void CloseRamWindows(); //Close the Ram Search & Watch windows when rom closes
  686.31 -void ReopenRamWindows(); //Reopen them when a new Rom is loaded
  686.32 -void Update_RAM_Search(); //keeps RAM values up to date in the search and watch windows
  686.33 -
  686.34 -
  686.35 -
  686.36 -#endif
  686.37 -
   687.1 --- a/src/win32/ramwatch.cpp	Sat Mar 03 10:54:39 2012 -0600
   687.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   687.3 @@ -1,1249 +0,0 @@
   687.4 -#include "stdafx.h"
   687.5 -#include "VBA.h"
   687.6 -#include "resource.h"
   687.7 -#include "WinMiscUtil.h"
   687.8 -#include "GBACheatsDlg.h"
   687.9 -#include "GBCheatsDlg.h"
  687.10 -#include "ram_search.h"
  687.11 -#include "ramwatch.h"
  687.12 -#include "reg.h"
  687.13 -#include "Sound.h"
  687.14 -#include <cassert>
  687.15 -#include <windows.h>
  687.16 -#include <string>
  687.17 -
  687.18 -/*
  687.19 -#include <commctrl.h>
  687.20 -#pragma comment(lib, "comctl32.lib")
  687.21 -#include <shellapi.h>
  687.22 -#pragma comment(lib, "shell32.lib")
  687.23 -#include <commdlg.h>
  687.24 -#pragma comment(lib, "comdlg32.lib")
  687.25 -*/
  687.26 -
  687.27 -static HMENU ramwatchmenu;
  687.28 -static HMENU rwrecentmenu;
  687.29 -/*static*/ HACCEL RamWatchAccels = NULL;
  687.30 -char rw_recent_files[MAX_RECENT_WATCHES][1024];
  687.31 -//char Watch_Dir[1024]="";
  687.32 -bool RWfileChanged = false; //Keeps track of whether the current watch file has been changed, if so, ramwatch will prompt to save changes
  687.33 -bool AutoRWLoad = false;    //Keeps track of whether Auto-load is checked
  687.34 -bool RWSaveWindowPos = false; //Keeps track of whether Save Window position is checked
  687.35 -char currentWatch[1024];
  687.36 -int ramw_x, ramw_y;			//Used to store ramwatch dialog window positions
  687.37 -AddressWatcher rswatches[MAX_WATCH_COUNT];
  687.38 -int WatchCount=0;
  687.39 -static int s_prevSelCount=-1;
  687.40 -
  687.41 -HWND RamWatchHWnd;
  687.42 -#define gamefilename theApp.gameFilename
  687.43 -#define hWnd AfxGetMainWnd()->GetSafeHwnd()
  687.44 -#define hInst AfxGetInstanceHandle()
  687.45 -static char Str_Tmp [1024];
  687.46 -
  687.47 -void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths); //initializes the ram search and/or ram watch listbox
  687.48 -
  687.49 -#define MESSAGEBOXPARENT (RamWatchHWnd ? RamWatchHWnd : hWnd)
  687.50 -
  687.51 -bool QuickSaveWatches();
  687.52 -bool ResetWatches();
  687.53 -
  687.54 -void RefreshWatchListSelectedCountControlStatus(HWND hDlg);
  687.55 -
  687.56 -unsigned int GetCurrentValue(AddressWatcher& watch)
  687.57 -{
  687.58 -	return ReadValueAtHardwareAddress(watch.Address, watch.Size == 'd' ? 4 : watch.Size == 'w' ? 2 : 1);
  687.59 -}
  687.60 -
  687.61 -bool IsSameWatch(const AddressWatcher& l, const AddressWatcher& r)
  687.62 -{
  687.63 -	if (r.Size == 'S') return false;
  687.64 -	return ((l.Address == r.Address) && (l.Size == r.Size) && (l.Type == r.Type)/* && (l.WrongEndian == r.WrongEndian)*/);
  687.65 -}
  687.66 -
  687.67 -bool VerifyWatchNotAlreadyAdded(const AddressWatcher& watch)
  687.68 -{
  687.69 -	for (int j = 0; j < WatchCount; j++)
  687.70 -	{
  687.71 -		if (IsSameWatch(rswatches[j], watch))
  687.72 -		{
  687.73 -			if(RamWatchHWnd)
  687.74 -				SetForegroundWindow(RamWatchHWnd);
  687.75 -			return false;
  687.76 -		}
  687.77 -	}
  687.78 -	return true;
  687.79 -}
  687.80 -
  687.81 -
  687.82 -bool InsertWatch(const AddressWatcher& Watch, char *Comment)
  687.83 -{
  687.84 -	if(WatchCount >= MAX_WATCH_COUNT)
  687.85 -		return false;
  687.86 -
  687.87 -	int i = WatchCount++;
  687.88 -	AddressWatcher& NewWatch = rswatches[i];
  687.89 -	NewWatch = Watch;
  687.90 -	//if (NewWatch.comment) free(NewWatch.comment);
  687.91 -	NewWatch.comment = (char *) malloc(strlen(Comment)+2);
  687.92 -	NewWatch.CurValue = GetCurrentValue(NewWatch);
  687.93 -	strcpy(NewWatch.comment, Comment);
  687.94 -	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
  687.95 -	RWfileChanged=true;
  687.96 -
  687.97 -	return true;
  687.98 -}
  687.99 -
 687.100 -LRESULT CALLBACK PromptWatchNameProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets the description of a watched address
 687.101 -{
 687.102 -	RECT r;
 687.103 -	RECT r2;
 687.104 -	int dx1, dy1, dx2, dy2;
 687.105 -
 687.106 -	switch(uMsg)
 687.107 -	{
 687.108 -		case WM_INITDIALOG:
 687.109 -			//Clear_Sound_Buffer();
 687.110 -
 687.111 -			GetWindowRect(hWnd, &r);
 687.112 -			dx1 = (r.right - r.left) / 2;
 687.113 -			dy1 = (r.bottom - r.top) / 2;
 687.114 -
 687.115 -			GetWindowRect(hDlg, &r2);
 687.116 -			dx2 = (r2.right - r2.left) / 2;
 687.117 -			dy2 = (r2.bottom - r2.top) / 2;
 687.118 -
 687.119 -			//SetWindowPos(hDlg, NULL, max(0, r.left + (dx1 - dx2)), max(0, r.top + (dy1 - dy2)), NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 687.120 -			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 687.121 -			strcpy(Str_Tmp,"Enter a name for this RAM address.");
 687.122 -			SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT,WM_SETTEXT,0,(LPARAM)Str_Tmp);
 687.123 -			strcpy(Str_Tmp,"");
 687.124 -			SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT2,WM_SETTEXT,0,(LPARAM)Str_Tmp);
 687.125 -			return true;
 687.126 -			break;
 687.127 -
 687.128 -		case WM_COMMAND:
 687.129 -			switch(LOWORD(wParam))
 687.130 -			{
 687.131 -				case IDOK:
 687.132 -				{
 687.133 -					GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80);
 687.134 -					InsertWatch(rswatches[WatchCount],Str_Tmp);
 687.135 -					EndDialog(hDlg, true);
 687.136 -					return true;
 687.137 -					break;
 687.138 -				}
 687.139 -				case ID_CANCEL:
 687.140 -				case IDCANCEL:
 687.141 -					EndDialog(hDlg, false);
 687.142 -					return false;
 687.143 -					break;
 687.144 -			}
 687.145 -			break;
 687.146 -
 687.147 -		case WM_CLOSE:
 687.148 -			EndDialog(hDlg, false);
 687.149 -			return false;
 687.150 -			break;
 687.151 -	}
 687.152 -
 687.153 -	return false;
 687.154 -}
 687.155 -
 687.156 -bool InsertWatch(const AddressWatcher& Watch, HWND parent)
 687.157 -{
 687.158 -	if(!VerifyWatchNotAlreadyAdded(Watch))
 687.159 -		return false;
 687.160 -
 687.161 -	if(!parent)
 687.162 -		parent = RamWatchHWnd;
 687.163 -	if(!parent)
 687.164 -		parent = hWnd;
 687.165 -
 687.166 -	int prevWatchCount = WatchCount;
 687.167 -
 687.168 -	rswatches[WatchCount] = Watch;
 687.169 -	rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]);
 687.170 -	systemSoundClearBuffer();
 687.171 -	DialogBox(hInst, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc);
 687.172 -
 687.173 -	return WatchCount > prevWatchCount;
 687.174 -}
 687.175 -
 687.176 -void Update_RAM_Watch()
 687.177 -{
 687.178 -	BOOL watchChanged[MAX_WATCH_COUNT] = {0};
 687.179 -
 687.180 -	if(WatchCount)
 687.181 -	{
 687.182 -		// update cached values and detect changes to displayed listview items
 687.183 -
 687.184 -		for(int i = 0; i < WatchCount; i++)
 687.185 -		{
 687.186 -			unsigned int prevCurValue = rswatches[i].CurValue;
 687.187 -			unsigned int newCurValue = GetCurrentValue(rswatches[i]);
 687.188 -			if(prevCurValue != newCurValue)
 687.189 -			{
 687.190 -				rswatches[i].CurValue = newCurValue;
 687.191 -				watchChanged[i] = TRUE;
 687.192 -			}
 687.193 -		}
 687.194 -	}
 687.195 -
 687.196 -	// refresh any visible parts of the listview box that changed
 687.197 -	HWND lv = GetDlgItem(RamWatchHWnd,IDC_WATCHLIST);
 687.198 -	int top = ListView_GetTopIndex(lv);
 687.199 -	int bottom = top + ListView_GetCountPerPage(lv) + 1; // +1 is so we will update a partially-displayed last item
 687.200 -	if(top < 0) top = 0;
 687.201 -	if(bottom > WatchCount) bottom = WatchCount;
 687.202 -	int start = -1;
 687.203 -	for(int i = top; i <= bottom; i++)
 687.204 -	{
 687.205 -		if(start == -1)
 687.206 -		{
 687.207 -			if(i != bottom && watchChanged[i])
 687.208 -			{
 687.209 -				start = i;
 687.210 -				//somethingChanged = true;
 687.211 -			}
 687.212 -		}
 687.213 -		else
 687.214 -		{
 687.215 -			if(i == bottom || !watchChanged[i])
 687.216 -			{
 687.217 -				ListView_RedrawItems(lv, start, i-1);
 687.218 -				start = -1;
 687.219 -			}
 687.220 -		}
 687.221 -	}
 687.222 -}
 687.223 -
 687.224 -bool AskSave()
 687.225 -{
 687.226 -	//This function asks to save changes if the watch file contents have changed
 687.227 -	//returns false only if a save was attempted but failed or was cancelled
 687.228 -	if (RWfileChanged)
 687.229 -	{
 687.230 -		systemSoundClearBuffer();
 687.231 -		int answer = MessageBox(MESSAGEBOXPARENT, "Save Changes?", "Ram Watch", MB_YESNOCANCEL);
 687.232 -		if(answer == IDYES)
 687.233 -			if(!QuickSaveWatches())
 687.234 -				return false;
 687.235 -		return (answer != IDCANCEL);
 687.236 -	}
 687.237 -	return true;
 687.238 -}
 687.239 -
 687.240 -void WriteRecentRWFiles()
 687.241 -{
 687.242 -	char str[2048];
 687.243 -	for (int i = 0; i < MAX_RECENT_WATCHES; i++)
 687.244 -	{
 687.245 -		sprintf(str, "recentWatch%d", i+1);
 687.246 -		regSetStringValue(str, &rw_recent_files[i][0]);
 687.247 -	}
 687.248 -}
 687.249 -
 687.250 -void UpdateRW_RMenu(HMENU menu, unsigned int mitem, unsigned int baseid)
 687.251 -{
 687.252 -	MENUITEMINFO moo;
 687.253 -	int x;
 687.254 -
 687.255 -	moo.cbSize = sizeof(moo);
 687.256 -	moo.fMask = MIIM_SUBMENU | MIIM_STATE;
 687.257 -
 687.258 -	GetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo);
 687.259 -	moo.hSubMenu = menu;
 687.260 -	moo.fState = strlen(rw_recent_files[0]) ? MFS_ENABLED : MFS_GRAYED;
 687.261 -
 687.262 -	SetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo);
 687.263 -
 687.264 -	// Remove all recent files submenus
 687.265 -	for(x = 0; x < MAX_RECENT_WATCHES; x++)
 687.266 -	{
 687.267 -		RemoveMenu(menu, baseid + x, MF_BYCOMMAND);
 687.268 -	}
 687.269 -
 687.270 -	// Recreate the menus
 687.271 -	for(x = MAX_RECENT_WATCHES - 1; x >= 0; x--)
 687.272 -	{  
 687.273 -		// Skip empty strings
 687.274 -		if(!strlen(rw_recent_files[x]))
 687.275 -		{
 687.276 -			continue;
 687.277 -		}
 687.278 -
 687.279 -		moo.cbSize = sizeof(moo);
 687.280 -		moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
 687.281 -
 687.282 -#if 0
 687.283 -		const int TEMP_STRING_LENGTH = 128 + 5;
 687.284 -		char tmp[TEMP_STRING_LENGTH];	// FIXME?
 687.285 -
 687.286 -		// Fill in the menu text.
 687.287 -		if(strlen(rw_recent_files[x]) < 128)
 687.288 -		{
 687.289 -			sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x]);
 687.290 -		}
 687.291 -		else
 687.292 -		{
 687.293 -			sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x] + strlen( rw_recent_files[x] ) - 127);
 687.294 -		}
 687.295 -#endif
 687.296 -		// the ATL way; it is really pain to work out a MBCS-compatible string replace function in the pure c way
 687.297 -		CString atltmp(rw_recent_files[x]);
 687.298 -		atltmp.Replace("&", "&&");
 687.299 -		char *tmp = atltmp.GetBuffer(0);
 687.300 -
 687.301 -		// Insert the menu item
 687.302 -		moo.cch = strlen(tmp);
 687.303 -		moo.fType = 0;
 687.304 -		moo.wID = baseid + x;
 687.305 -		moo.dwTypeData = tmp;
 687.306 -		InsertMenuItem(menu, 0, 1, &moo);
 687.307 -
 687.308 -		// atltmp.ReleaseBuffer();
 687.309 -	}
 687.310 -
 687.311 -	// I don't think one function shall do so many things in a row
 687.312 -//	WriteRecentRWFiles();	// write recent menu to ini
 687.313 -}
 687.314 -
 687.315 -void UpdateRWRecentArray(const char* addString, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId)
 687.316 -{
 687.317 -	const size_t len = 1024; // Avoid magic numbers
 687.318 -
 687.319 -	// Try to find out if the filename is already in the recent files list.
 687.320 -	for(unsigned int x = 0; x < arrayLen; x++)
 687.321 -	{
 687.322 -		if(strlen(rw_recent_files[x]))
 687.323 -		{
 687.324 -			if(!strncmp(rw_recent_files[x], addString, 1024))    // Item is already in list.
 687.325 -			{
 687.326 -				// If the filename is in the file list don't add it again.
 687.327 -				// Move it up in the list instead.
 687.328 -
 687.329 -				int y;
 687.330 -				char tmp[len];
 687.331 -
 687.332 -				// Save pointer.
 687.333 -				strncpy(tmp, rw_recent_files[x], len - 1);	// assuming rw_recent_files[n] is 0-terminated
 687.334 -				
 687.335 -				for(y = x; y; y--)
 687.336 -				{
 687.337 -					// Move items down.
 687.338 -					strncpy(rw_recent_files[y], rw_recent_files[y - 1], len);
 687.339 -				}
 687.340 -
 687.341 -				// Put item on top.
 687.342 -				strncpy(rw_recent_files[0],tmp, len);
 687.343 -
 687.344 -				// Update the recent files menu
 687.345 -				UpdateRW_RMenu(menu, menuItem, baseId);
 687.346 -
 687.347 -				return;
 687.348 -			}
 687.349 -		}
 687.350 -	}
 687.351 -
 687.352 -	// The filename wasn't found in the list. That means we need to add it.
 687.353 -
 687.354 -	// Move the other items down.
 687.355 -	for(unsigned int x = arrayLen - 1; x; x--)
 687.356 -	{
 687.357 -		strncpy(rw_recent_files[x],rw_recent_files[x - 1], len);
 687.358 -	}
 687.359 -
 687.360 -	// Add the new item.
 687.361 -	strncpy(rw_recent_files[0], addString, len);
 687.362 -	rw_recent_files[0][len - 1] = '\0';	// better not assume that
 687.363 -
 687.364 -	// Update the recent files menu
 687.365 -	UpdateRW_RMenu(menu, menuItem, baseId);
 687.366 -}
 687.367 -
 687.368 -void RWAddRecentFile(const char *filename)
 687.369 -{
 687.370 -	UpdateRWRecentArray(filename, MAX_RECENT_WATCHES, rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE);
 687.371 -}
 687.372 -
 687.373 -void OpenRWRecentFile(int memwRFileNumber)
 687.374 -{
 687.375 -	if(!ResetWatches())
 687.376 -		return;
 687.377 -
 687.378 -	int rnum = memwRFileNumber;
 687.379 -	if ((unsigned int)rnum >= MAX_RECENT_WATCHES)
 687.380 -		return; //just in case
 687.381 -
 687.382 -	char* x;
 687.383 -
 687.384 -	while(true)
 687.385 -	{
 687.386 -		x = rw_recent_files[rnum];
 687.387 -		if (!*x) 
 687.388 -			return;		//If no recent files exist just return.  Useful for Load last file on startup (or if something goes screwy)
 687.389 -
 687.390 -		if (rnum) //Change order of recent files if not most recent
 687.391 -		{
 687.392 -			RWAddRecentFile(x);
 687.393 -			rnum = 0;
 687.394 -		}
 687.395 -		else
 687.396 -		{
 687.397 -			break;
 687.398 -		}
 687.399 -	}
 687.400 -
 687.401 -	strcpy(currentWatch,x);
 687.402 -	strcpy(Str_Tmp,currentWatch);
 687.403 -
 687.404 -	//loadwatches here
 687.405 -	FILE *WatchFile = fopen(Str_Tmp,"rb");
 687.406 -	if (!WatchFile)
 687.407 -	{
 687.408 -		systemSoundClearBuffer();
 687.409 -		int answer = MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OKCANCEL);
 687.410 -		if (answer == IDOK)
 687.411 -		{
 687.412 -			rw_recent_files[rnum][0] = '\0';	//Clear file from list 
 687.413 -			if (rnum)							//Update the ramwatch list
 687.414 -				RWAddRecentFile(rw_recent_files[0]); 
 687.415 -			else
 687.416 -				RWAddRecentFile(rw_recent_files[1]);
 687.417 -		}
 687.418 -		return;
 687.419 -	}
 687.420 -	const char DELIM = '\t';
 687.421 -	AddressWatcher Temp;
 687.422 -	char mode;
 687.423 -	fgets(Str_Tmp,1024,WatchFile);
 687.424 -	sscanf(Str_Tmp,"%c%*s",&mode);
 687.425 -	//if ((mode == '1' && !(SegaCD_Started)) || (mode == '2' && !(_32X_Started)))
 687.426 -	//{
 687.427 -	//	char Device[8];
 687.428 -	//	strcpy(Device,(mode > '1')?"32X":"SegaCD");
 687.429 -	//	sprintf(Str_Tmp,"Warning: %s not started. \nWatches for %s addresses will be ignored.",Device,Device);
 687.430 -	//	MessageBox(MESSAGEBOXPARENT,Str_Tmp,"Possible Device Mismatch",MB_OK);
 687.431 -	//}
 687.432 -	int WatchAdd;
 687.433 -	fgets(Str_Tmp,1024,WatchFile);
 687.434 -	sscanf(Str_Tmp,"%d%*s",&WatchAdd);
 687.435 -	WatchAdd+=WatchCount;
 687.436 -	for (int i = WatchCount; i < WatchAdd; i++)
 687.437 -	{
 687.438 -		while (i < 0)
 687.439 -			i++;
 687.440 -		do {
 687.441 -			fgets(Str_Tmp,1024,WatchFile);
 687.442 -		} while (Str_Tmp[0] == '\n');
 687.443 -		sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian));
 687.444 -		Temp.WrongEndian = 0;
 687.445 -		char *Comment = strrchr(Str_Tmp,DELIM) + 1;
 687.446 -		*strrchr(Comment,'\n') = '\0';
 687.447 -		InsertWatch(Temp,Comment);
 687.448 -	}
 687.449 -
 687.450 -	fclose(WatchFile);
 687.451 -	if (RamWatchHWnd) {
 687.452 -		ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
 687.453 -		RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
 687.454 -	}
 687.455 -	RWfileChanged=false;
 687.456 -	return;
 687.457 -}
 687.458 -
 687.459 -int Change_File_L(char *Dest, const char *Dir, const char *Titre, const char *Filter, const char *Ext, HWND hwnd)
 687.460 -{
 687.461 -	if (!strcmp(Dest, ""))
 687.462 -	{
 687.463 -		strcpy(Dest, "default.");
 687.464 -		strcat(Dest, Ext);
 687.465 -	}
 687.466 -
 687.467 -	SetCurrentDirectory(winGetDestDir(IDS_WATCH_DIR));
 687.468 -
 687.469 -	OPENFILENAME ofn;
 687.470 -
 687.471 -	memset(&ofn, 0, sizeof(OPENFILENAME));
 687.472 -
 687.473 -	ofn.lStructSize = sizeof(OPENFILENAME);
 687.474 -	ofn.hwndOwner = hwnd;
 687.475 -	ofn.hInstance = hInst;
 687.476 -	ofn.lpstrFile = Dest;
 687.477 -	ofn.nMaxFile = 2047;
 687.478 -	ofn.lpstrFilter = Filter;
 687.479 -	ofn.nFilterIndex = 1;
 687.480 -	ofn.lpstrInitialDir = Dir;
 687.481 -	ofn.lpstrTitle = Titre;
 687.482 -	ofn.lpstrDefExt = Ext;
 687.483 -	ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 687.484 -
 687.485 -	systemSoundClearBuffer();
 687.486 -
 687.487 -	if (GetOpenFileName(&ofn)) return 1;
 687.488 -
 687.489 -	return 0;
 687.490 -}
 687.491 -
 687.492 -int Change_File_S(char *Dest, const char *Dir, const char *Titre, const char *Filter, const char *Ext, HWND hwnd)
 687.493 -{
 687.494 -	if (!strcmp(Dest, ""))
 687.495 -	{
 687.496 -		strcpy(Dest, "default.");
 687.497 -		strcat(Dest, Ext);
 687.498 -	}
 687.499 -
 687.500 -	SetCurrentDirectory(winGetDestDir(IDS_WATCH_DIR));
 687.501 -
 687.502 -	OPENFILENAME ofn;
 687.503 -
 687.504 -	memset(&ofn, 0, sizeof(OPENFILENAME));
 687.505 -
 687.506 -	ofn.lStructSize = sizeof(OPENFILENAME);
 687.507 -	ofn.hwndOwner = hwnd;
 687.508 -	ofn.hInstance = hInst;
 687.509 -	ofn.lpstrFile = Dest;
 687.510 -	ofn.nMaxFile = 2047;
 687.511 -	ofn.lpstrFilter = Filter;
 687.512 -	ofn.nFilterIndex = 1;
 687.513 -	ofn.lpstrInitialDir = Dir;
 687.514 -	ofn.lpstrTitle = Titre;
 687.515 -	ofn.lpstrDefExt = Ext;
 687.516 -	ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
 687.517 -
 687.518 -	if (GetSaveFileName(&ofn)) return 1;
 687.519 -
 687.520 -	return 0;
 687.521 -}
 687.522 -
 687.523 -bool Save_Watches()
 687.524 -{
 687.525 -	const char* slash = max(strrchr(gamefilename, '|'), max(strrchr(gamefilename, '\\'), strrchr(gamefilename, '/')));
 687.526 -	strcpy(Str_Tmp,slash ? slash+1 : gamefilename);
 687.527 -	char* dot = strrchr(Str_Tmp, '.');
 687.528 -	if(dot) *dot = 0;
 687.529 -	strcat(Str_Tmp,".wch");
 687.530 -	if(Change_File_S(Str_Tmp, winGetDestDir(IDS_WATCH_DIR), "Save Watches", "Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd))
 687.531 -	{
 687.532 -		FILE *WatchFile = fopen(Str_Tmp,"r+b");
 687.533 -		if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b");
 687.534 -		fputc('\n',WatchFile);
 687.535 -		strcpy(currentWatch,Str_Tmp);
 687.536 -		RWAddRecentFile(currentWatch);
 687.537 -		sprintf(Str_Tmp,"%d\n",WatchCount);
 687.538 -		fputs(Str_Tmp,WatchFile);
 687.539 -		const char DELIM = '\t';
 687.540 -		for (int i = 0; i < WatchCount; i++)
 687.541 -		{
 687.542 -			sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment);
 687.543 -			fputs(Str_Tmp,WatchFile);
 687.544 -		}
 687.545 -		
 687.546 -		fclose(WatchFile);
 687.547 -		RWfileChanged=false;
 687.548 -		//TODO: Add to recent list function call here
 687.549 -		return true;
 687.550 -	}
 687.551 -	return false;
 687.552 -}
 687.553 -
 687.554 -bool QuickSaveWatches()
 687.555 -{
 687.556 -if (RWfileChanged==false) return true; //If file has not changed, no need to save changes
 687.557 -if (currentWatch[0] == NULL) //If there is no currently loaded file, run to Save as and then return
 687.558 -	{
 687.559 -		return Save_Watches();
 687.560 -	}
 687.561 -		
 687.562 -		strcpy(Str_Tmp,currentWatch);
 687.563 -		FILE *WatchFile = fopen(Str_Tmp,"r+b");
 687.564 -		if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b");
 687.565 -		fputc('\n',WatchFile);
 687.566 -		sprintf(Str_Tmp,"%d\n",WatchCount);
 687.567 -		fputs(Str_Tmp,WatchFile);
 687.568 -		const char DELIM = '\t';
 687.569 -		for (int i = 0; i < WatchCount; i++)
 687.570 -		{
 687.571 -			sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment);
 687.572 -			fputs(Str_Tmp,WatchFile);
 687.573 -		}
 687.574 -		fclose(WatchFile);
 687.575 -		RWfileChanged=false;
 687.576 -		return true;
 687.577 -}
 687.578 -
 687.579 -bool Load_Watches(bool clear, const char* filename)
 687.580 -{
 687.581 -	const char DELIM = '\t';
 687.582 -	FILE* WatchFile = fopen(filename,"rb");
 687.583 -	if (!WatchFile)
 687.584 -	{
 687.585 -		systemSoundClearBuffer();
 687.586 -		MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OK);
 687.587 -		return false;
 687.588 -	}
 687.589 -	if(clear)
 687.590 -	{
 687.591 -		if(!ResetWatches())
 687.592 -		{
 687.593 -			fclose(WatchFile);
 687.594 -			return false;
 687.595 -		}
 687.596 -	}
 687.597 -	strcpy(currentWatch,filename);
 687.598 -	RWAddRecentFile(currentWatch);
 687.599 -	AddressWatcher Temp;
 687.600 -	char mode;
 687.601 -	fgets(Str_Tmp,1024,WatchFile);
 687.602 -	sscanf(Str_Tmp,"%c%*s",&mode);
 687.603 -	int WatchAdd;
 687.604 -	fgets(Str_Tmp,1024,WatchFile);
 687.605 -	sscanf(Str_Tmp,"%d%*s",&WatchAdd);
 687.606 -	WatchAdd+=WatchCount;
 687.607 -	for (int i = WatchCount; i < WatchAdd; i++)
 687.608 -	{
 687.609 -		while (i < 0)
 687.610 -			i++;
 687.611 -		do {
 687.612 -			fgets(Str_Tmp,1024,WatchFile);
 687.613 -		} while (Str_Tmp[0] == '\n');
 687.614 -		sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian));
 687.615 -		Temp.WrongEndian = 0;
 687.616 -		char *Comment = strrchr(Str_Tmp,DELIM) + 1;
 687.617 -		*strrchr(Comment,'\n') = '\0';
 687.618 -		InsertWatch(Temp,Comment);
 687.619 -	}
 687.620 -	
 687.621 -	fclose(WatchFile);
 687.622 -	if (RamWatchHWnd)
 687.623 -		ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
 687.624 -	RWfileChanged=false;
 687.625 -	return true;
 687.626 -}
 687.627 -
 687.628 -bool Load_Watches(bool clear)
 687.629 -{
 687.630 -	const char* slash = max(strrchr(gamefilename, '|'), max(strrchr(gamefilename, '\\'), strrchr(gamefilename, '/')));
 687.631 -	strcpy(Str_Tmp,slash ? slash+1 : gamefilename);
 687.632 -	char* dot = strrchr(Str_Tmp, '.');
 687.633 -	if(dot) *dot = 0;
 687.634 -	strcat(Str_Tmp,".wch");
 687.635 -	if(Change_File_L(Str_Tmp, winGetDestDir(IDS_WATCH_DIR), "Load Watches", "Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd))
 687.636 -	{
 687.637 -		return Load_Watches(clear, Str_Tmp);
 687.638 -	}
 687.639 -	return false;
 687.640 -}
 687.641 -
 687.642 -bool ResetWatches()
 687.643 -{
 687.644 -	if(!AskSave())
 687.645 -		return false;
 687.646 -	for (;WatchCount>=0;WatchCount--)
 687.647 -	{
 687.648 -		free(rswatches[WatchCount].comment);
 687.649 -		rswatches[WatchCount].comment = NULL;
 687.650 -	}
 687.651 -	WatchCount++;
 687.652 -	if (RamWatchHWnd) {
 687.653 -		ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
 687.654 -		RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
 687.655 -	}
 687.656 -	RWfileChanged = false;
 687.657 -	currentWatch[0] = NULL;
 687.658 -	return true;
 687.659 -}
 687.660 -
 687.661 -void RemoveWatch(int watchIndex)
 687.662 -{
 687.663 -	free(rswatches[watchIndex].comment);
 687.664 -	rswatches[watchIndex].comment = NULL;
 687.665 -	for (int i = watchIndex; i <= WatchCount; i++)
 687.666 -		rswatches[i] = rswatches[i+1];
 687.667 -	WatchCount--;
 687.668 -}
 687.669 -
 687.670 -LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List
 687.671 -{
 687.672 -	RECT r;
 687.673 -	RECT r2;
 687.674 -	int dx1, dy1, dx2, dy2;
 687.675 -	static int index;
 687.676 -	static char s,t = s = 0;
 687.677 -
 687.678 -	switch(uMsg)
 687.679 -	{
 687.680 -		case WM_INITDIALOG:
 687.681 -			//Clear_Sound_Buffer();
 687.682 -			
 687.683 -
 687.684 -			GetWindowRect(hWnd, &r);
 687.685 -			dx1 = (r.right - r.left) / 2;
 687.686 -			dy1 = (r.bottom - r.top) / 2;
 687.687 -
 687.688 -			GetWindowRect(hDlg, &r2);
 687.689 -			dx2 = (r2.right - r2.left) / 2;
 687.690 -			dy2 = (r2.bottom - r2.top) / 2;
 687.691 -
 687.692 -			//SetWindowPos(hDlg, NULL, max(0, r.left + (dx1 - dx2)), max(0, r.top + (dy1 - dy2)), NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 687.693 -			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 687.694 -			index = (int)lParam;
 687.695 -			sprintf(Str_Tmp,"%08X",rswatches[index].Address);
 687.696 -			SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp);
 687.697 -			if (rswatches[index].comment != NULL)
 687.698 -				SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment);
 687.699 -			s = rswatches[index].Size;
 687.700 -			t = rswatches[index].Type;
 687.701 -			switch (s)
 687.702 -			{
 687.703 -				case 'b':
 687.704 -					SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0);
 687.705 -					break;
 687.706 -				case 'w':
 687.707 -					SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0);
 687.708 -					break;
 687.709 -				case 'd':
 687.710 -					SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0);
 687.711 -					break;
 687.712 -				default:
 687.713 -					s = 0;
 687.714 -					break;
 687.715 -			}
 687.716 -			switch (t)
 687.717 -			{
 687.718 -				case 's':
 687.719 -					SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0);
 687.720 -					break;
 687.721 -				case 'u':
 687.722 -					SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0);
 687.723 -					break;
 687.724 -				case 'h':
 687.725 -					SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0);
 687.726 -					break;
 687.727 -				default:
 687.728 -					t = 0;
 687.729 -					break;
 687.730 -			}
 687.731 -
 687.732 -			return true;
 687.733 -			break;
 687.734 -		
 687.735 -		case WM_COMMAND:
 687.736 -			switch(LOWORD(wParam))
 687.737 -			{
 687.738 -				case IDC_SIGNED:
 687.739 -					t='s';
 687.740 -					return true;
 687.741 -				case IDC_UNSIGNED:
 687.742 -					t='u';
 687.743 -					return true;
 687.744 -				case IDC_HEX:
 687.745 -					t='h';
 687.746 -					return true;
 687.747 -				case IDC_1_BYTE:
 687.748 -					s = 'b';
 687.749 -					return true;
 687.750 -				case IDC_2_BYTES:
 687.751 -					s = 'w';
 687.752 -					return true;
 687.753 -				case IDC_4_BYTES:
 687.754 -					s = 'd';
 687.755 -					return true;
 687.756 -				case IDOK:
 687.757 -				{
 687.758 -					if (s && t)
 687.759 -					{
 687.760 -						AddressWatcher Temp;
 687.761 -						Temp.Size = s;
 687.762 -						Temp.Type = t;
 687.763 -						Temp.WrongEndian = false; //replace this when I get little endian working properly
 687.764 -						GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp,1024);
 687.765 -						char *addrstr = Str_Tmp;
 687.766 -						if (strlen(Str_Tmp) > 8) addrstr = &(Str_Tmp[strlen(Str_Tmp) - 9]);
 687.767 -						for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';}
 687.768 -						sscanf(addrstr,"%08X",&(Temp.Address));
 687.769 -
 687.770 -						if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF)
 687.771 -							Temp.Address &= 0xFFFFFF;
 687.772 -
 687.773 -						if(IsHardwareAddressValid(Temp.Address))
 687.774 -						{
 687.775 -							GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80);
 687.776 -							if (index < WatchCount) RemoveWatch(index);
 687.777 -							InsertWatch(Temp,Str_Tmp);
 687.778 -							if(RamWatchHWnd)
 687.779 -							{
 687.780 -								ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
 687.781 -							}
 687.782 -							EndDialog(hDlg, true);
 687.783 -						}
 687.784 -						else
 687.785 -						{
 687.786 -							MessageBox(hDlg,"Invalid Address","ERROR",MB_OK);
 687.787 -						}
 687.788 -					}
 687.789 -					else
 687.790 -					{
 687.791 -						strcpy(Str_Tmp,"Error:");
 687.792 -						if (!s)
 687.793 -							strcat(Str_Tmp," Size must be specified.");
 687.794 -						if (!t)
 687.795 -							strcat(Str_Tmp," Type must be specified.");
 687.796 -						MessageBox(hDlg,Str_Tmp,"ERROR",MB_OK);
 687.797 -					}
 687.798 -					RWfileChanged=true;
 687.799 -					return true;
 687.800 -					break;
 687.801 -				}
 687.802 -				case ID_CANCEL:
 687.803 -				case IDCANCEL:
 687.804 -					EndDialog(hDlg, false);
 687.805 -					return false;
 687.806 -					break;
 687.807 -			}
 687.808 -			break;
 687.809 -
 687.810 -		case WM_CLOSE:
 687.811 -			EndDialog(hDlg, false);
 687.812 -			return false;
 687.813 -			break;
 687.814 -	}
 687.815 -
 687.816 -	return false;
 687.817 -}
 687.818 -
 687.819 -
 687.820 -
 687.821 -
 687.822 -void RamWatchEnableCommand(HWND hDlg, HMENU hMenu, UINT uIDEnableItem, bool enable)
 687.823 -{
 687.824 -	EnableWindow(GetDlgItem(hDlg, uIDEnableItem), (enable?TRUE:FALSE));
 687.825 -	if (hMenu != NULL) {
 687.826 -		if (uIDEnableItem == ID_WATCHES_UPDOWN) {
 687.827 -			EnableMenuItem(hMenu, IDC_C_WATCH_UP, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
 687.828 -			EnableMenuItem(hMenu, IDC_C_WATCH_DOWN, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
 687.829 -		}
 687.830 -		else
 687.831 -			EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
 687.832 -	}
 687.833 -}
 687.834 -
 687.835 -void RefreshWatchListSelectedCountControlStatus(HWND hDlg)
 687.836 -{
 687.837 -	int selCount = ListView_GetSelectedCount(GetDlgItem(hDlg,IDC_WATCHLIST));
 687.838 -	if(selCount != s_prevSelCount)
 687.839 -	{
 687.840 -		if(selCount < 2 || s_prevSelCount < 2)
 687.841 -		{
 687.842 -			RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_EDIT, selCount == 1);
 687.843 -			RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_REMOVE, selCount >= 1);
 687.844 -			RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH, WatchCount < MAX_WATCH_COUNT);
 687.845 -			RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_DUPLICATE, selCount == 1 && WatchCount < MAX_WATCH_COUNT);
 687.846 -			RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_ADDCHEAT, selCount == 1);
 687.847 -			RamWatchEnableCommand(hDlg, ramwatchmenu, ID_WATCHES_UPDOWN, selCount == 1);
 687.848 -		}
 687.849 -		s_prevSelCount = selCount;
 687.850 -	}
 687.851 -}
 687.852 -
 687.853 -LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 687.854 -{
 687.855 -	RECT r;
 687.856 -	RECT r2;
 687.857 -	int dx1, dy1, dx2, dy2;
 687.858 -	static int watchIndex=0;
 687.859 -
 687.860 -	switch(uMsg)
 687.861 -	{
 687.862 -		case WM_MOVE: {
 687.863 -			RECT wrect;
 687.864 -			GetWindowRect(hDlg,&wrect);
 687.865 -			ramw_x = wrect.left;
 687.866 -			ramw_y = wrect.top;
 687.867 -			regSetDwordValue(RAMWX, ramw_x);
 687.868 -			regSetDwordValue(RAMWY, ramw_y);
 687.869 -		}	break;
 687.870 -
 687.871 -		case WM_INITDIALOG: {
 687.872 -			GetWindowRect(hWnd, &r);  //Ramwatch window
 687.873 -			dx1 = (r.right - r.left) / 2;
 687.874 -			dy1 = (r.bottom - r.top) / 2;
 687.875 -
 687.876 -			GetWindowRect(hDlg, &r2); // TASer window
 687.877 -			dx2 = (r2.right - r2.left) / 2;
 687.878 -			dy2 = (r2.bottom - r2.top) / 2;
 687.879 -
 687.880 -			
 687.881 -			// push it away from the main window if we can
 687.882 -			const int width = (r.right-r.left);
 687.883 -			const int height = (r.bottom - r.top);
 687.884 -			const int width2 = (r2.right-r2.left); 
 687.885 -			if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN))
 687.886 -			{
 687.887 -				r.right += width;
 687.888 -				r.left += width;
 687.889 -			}
 687.890 -			else if((int)r.left - (int)width2 > 0)
 687.891 -			{
 687.892 -				r.right -= width2;
 687.893 -				r.left -= width2;
 687.894 -			}
 687.895 -			
 687.896 -			//-----------------------------------------------------------------------------------
 687.897 -			//If user has Save Window Pos selected, override default positioning
 687.898 -			if (RWSaveWindowPos)	
 687.899 -			{
 687.900 -				//If ramwindow is for some reason completely off screen, use default instead 
 687.901 -				if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN))   ) 
 687.902 -					r.left = ramw_x;	  //This also ignores cases of windows -32000 error codes
 687.903 -				//If ramwindow is for some reason completely off screen, use default instead 
 687.904 -				if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN))	)
 687.905 -					r.top = ramw_y;		  //This also ignores cases of windows -32000 error codes
 687.906 -			}
 687.907 -			//-------------------------------------------------------------------------------------
 687.908 -			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
 687.909 -			
 687.910 -			ramwatchmenu=GetMenu(hDlg);
 687.911 -			rwrecentmenu=CreateMenu();
 687.912 -			UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE);
 687.913 -			
 687.914 -			const char* names[3] = {"Address","Value","Notes"};
 687.915 -			int widths[3] = {62,64,64+51+53};
 687.916 -			init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths);
 687.917 -			if (!ResultCount)
 687.918 -				reset_address_info();
 687.919 -			else
 687.920 -				signal_new_frame();
 687.921 -			ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
 687.922 -			if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0);
 687.923 -			//if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0);
 687.924 -
 687.925 -			RamWatchAccels = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACCELERATOR1));
 687.926 -
 687.927 -			// due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here
 687.928 -			SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE);
 687.929 -
 687.930 -			Update_RAM_Watch();
 687.931 -
 687.932 -			DragAcceptFiles(hDlg, TRUE);
 687.933 -
 687.934 -			s_prevSelCount = -1;
 687.935 -			RefreshWatchListSelectedCountControlStatus(hDlg);
 687.936 -			return false;
 687.937 -		}	break;
 687.938 -		
 687.939 -		case WM_INITMENU:
 687.940 -			CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED);
 687.941 -			CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED);
 687.942 -			break;
 687.943 -
 687.944 -		case WM_ENTERMENULOOP:
 687.945 -			systemSoundClearBuffer();
 687.946 -			break;
 687.947 -
 687.948 -		case WM_MENUSELECT:
 687.949 - 		case WM_ENTERSIZEMOVE:
 687.950 -			//Clear_Sound_Buffer();
 687.951 -			break;
 687.952 -
 687.953 -		case WM_NOTIFY:
 687.954 -		{
 687.955 -			switch(wParam)
 687.956 -			{
 687.957 -				case ID_WATCHES_UPDOWN:
 687.958 -				{
 687.959 -					switch(((LPNMUPDOWN)lParam)->hdr.code)
 687.960 -					{
 687.961 -						case UDN_DELTAPOS: {
 687.962 -							int delta = ((LPNMUPDOWN)lParam)->iDelta;
 687.963 -							SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0);
 687.964 -						} break;
 687.965 -					}
 687.966 -				} break;
 687.967 -
 687.968 -				default:
 687.969 -				{
 687.970 -					LPNMHDR lP = (LPNMHDR) lParam;
 687.971 -					switch (lP->code)
 687.972 -					{
 687.973 -						case LVN_ITEMCHANGED: // selection changed event
 687.974 -						{
 687.975 -							NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP;
 687.976 -							if(pNMListView->uNewState & LVIS_FOCUSED ||
 687.977 -								(pNMListView->uNewState ^ pNMListView->uOldState) & LVIS_SELECTED)
 687.978 -							{
 687.979 -								// disable buttons that we don't have the right number of selected items for
 687.980 -								RefreshWatchListSelectedCountControlStatus(hDlg);
 687.981 -							}
 687.982 -						}	break;
 687.983 -
 687.984 -						case LVN_GETDISPINFO:
 687.985 -						{
 687.986 -							LV_DISPINFO *Item = (LV_DISPINFO *)lParam;
 687.987 -							Item->item.mask = LVIF_TEXT;
 687.988 -							Item->item.state = 0;
 687.989 -							Item->item.iImage = 0;
 687.990 -							const unsigned int iNum = Item->item.iItem;
 687.991 -							static char num[11];
 687.992 -							switch (Item->item.iSubItem)
 687.993 -							{
 687.994 -								case 0:
 687.995 -									sprintf(num,"%08X",rswatches[iNum].Address);
 687.996 -									Item->item.pszText = num;
 687.997 -									return true;
 687.998 -								case 1: {
 687.999 -									int i = rswatches[iNum].CurValue;
687.1000 -									int t = rswatches[iNum].Type;
687.1001 -									int size = rswatches[iNum].Size;
687.1002 -									const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X"));
687.1003 -									switch (size)
687.1004 -									{
687.1005 -										case 'b':
687.1006 -										default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
687.1007 -										case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
687.1008 -										case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
687.1009 -									}
687.1010 -
687.1011 -									Item->item.pszText = num;
687.1012 -								}	return true;
687.1013 -								case 2:
687.1014 -									Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : "";
687.1015 -									return true;
687.1016 -
687.1017 -								default:
687.1018 -									return false;
687.1019 -							}
687.1020 -						}
687.1021 -						case LVN_ODFINDITEM:
687.1022 -						{	
687.1023 -							// disable search by keyboard typing,
687.1024 -							// because it interferes with some of the accelerators
687.1025 -							// and it isn't very useful here anyway
687.1026 -							SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)));
687.1027 -							return 1;
687.1028 -						}
687.1029 -					}
687.1030 -				}
687.1031 -			}
687.1032 -		}	break;
687.1033 -
687.1034 -		case WM_COMMAND:
687.1035 -			switch(LOWORD(wParam))
687.1036 -			{
687.1037 -				case RAMMENU_FILE_SAVE:
687.1038 -					QuickSaveWatches();
687.1039 -					break;
687.1040 -
687.1041 -				case RAMMENU_FILE_SAVEAS:	
687.1042 -				//case IDC_C_SAVE:
687.1043 -					return Save_Watches();
687.1044 -				case RAMMENU_FILE_OPEN:
687.1045 -					return Load_Watches(true);
687.1046 -				case RAMMENU_FILE_APPEND:
687.1047 -				//case IDC_C_LOAD:
687.1048 -					return Load_Watches(false);
687.1049 -				case RAMMENU_FILE_NEW:
687.1050 -				//case IDC_C_RESET:
687.1051 -					ResetWatches();
687.1052 -					return true;
687.1053 -				case IDC_C_WATCH_REMOVE:
687.1054 -				{
687.1055 -					HWND watchListControl = GetDlgItem(hDlg, IDC_WATCHLIST);
687.1056 -					watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED);
687.1057 -					while (watchIndex >= 0)
687.1058 -					{
687.1059 -						RemoveWatch(watchIndex);
687.1060 -						ListView_DeleteItem(watchListControl, watchIndex);
687.1061 -						watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED);
687.1062 -					}
687.1063 -					RWfileChanged=true;
687.1064 -					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1065 -					return true;
687.1066 -				}
687.1067 -				case IDC_C_WATCH_EDIT:
687.1068 -					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1069 -					if(watchIndex != -1)
687.1070 -					{
687.1071 -						systemSoundClearBuffer();
687.1072 -						DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex);
687.1073 -						SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1074 -					}
687.1075 -					return true;
687.1076 -				case IDC_C_WATCH:
687.1077 -					rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0;
687.1078 -					rswatches[WatchCount].Size = 'b';
687.1079 -					rswatches[WatchCount].Type = 's';
687.1080 -					systemSoundClearBuffer();
687.1081 -					DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
687.1082 -					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1083 -					return true;
687.1084 -				case IDC_C_WATCH_DUPLICATE:
687.1085 -					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1086 -					if(watchIndex != -1)
687.1087 -					{
687.1088 -						rswatches[WatchCount].Address = rswatches[watchIndex].Address;
687.1089 -						rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian;
687.1090 -						rswatches[WatchCount].Size = rswatches[watchIndex].Size;
687.1091 -						rswatches[WatchCount].Type = rswatches[watchIndex].Type;
687.1092 -						systemSoundClearBuffer();
687.1093 -						DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
687.1094 -						SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1095 -					}
687.1096 -					return true;
687.1097 -
687.1098 -				case IDC_C_WATCH_SEPARATE:
687.1099 -					AddressWatcher separator;
687.1100 -					separator.Address = 0;
687.1101 -					separator.WrongEndian = false;
687.1102 -					separator.Size = 'S';
687.1103 -					separator.Type = 'S';
687.1104 -					InsertWatch(separator, "----------------------------");
687.1105 -					SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1106 -					return true;
687.1107 -
687.1108 -				case IDC_C_WATCH_UP:
687.1109 -				{
687.1110 -					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1111 -					if (watchIndex == 0 || watchIndex == -1)
687.1112 -						return true;
687.1113 -					void *tmp = malloc(sizeof(AddressWatcher));
687.1114 -					memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher));
687.1115 -					memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher));
687.1116 -					memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher));
687.1117 -					free(tmp);
687.1118 -					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED);
687.1119 -					ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1);
687.1120 -					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
687.1121 -					ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
687.1122 -					RWfileChanged=true;
687.1123 -					return true;
687.1124 -				}
687.1125 -				case IDC_C_WATCH_DOWN:
687.1126 -				{
687.1127 -					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1128 -					if (watchIndex >= WatchCount - 1 || watchIndex == -1)
687.1129 -						return true;
687.1130 -					void *tmp = malloc(sizeof(AddressWatcher));
687.1131 -					memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher));
687.1132 -					memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher));
687.1133 -					memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher));
687.1134 -					free(tmp);
687.1135 -					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED);
687.1136 -					ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1);
687.1137 -					ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
687.1138 -					ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
687.1139 -					RWfileChanged=true;
687.1140 -					return true;
687.1141 -				}
687.1142 -				case ID_WATCHES_UPDOWN:
687.1143 -				{
687.1144 -					int delta = ((LPNMUPDOWN)lParam)->iDelta;
687.1145 -					SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0);
687.1146 -					break;
687.1147 -				}
687.1148 -				case RAMMENU_FILE_AUTOLOAD:
687.1149 -				{
687.1150 -					AutoRWLoad ^= 1;
687.1151 -					CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED);
687.1152 -					regSetDwordValue(AUTORWLOAD, AutoRWLoad);
687.1153 -					break;
687.1154 -				}
687.1155 -				case RAMMENU_FILE_SAVEWINDOW:
687.1156 -				{
687.1157 -					RWSaveWindowPos ^=1;
687.1158 -					CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED);
687.1159 -					regSetDwordValue(RWSAVEPOS, RWSaveWindowPos);
687.1160 -					break;
687.1161 -				}
687.1162 -				case IDC_C_ADDCHEAT:
687.1163 -				{
687.1164 -					watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1165 -					if(watchIndex >= 0)
687.1166 -					{
687.1167 -						unsigned int address = rswatches[watchIndex].Address;
687.1168 -
687.1169 -						int sizeType = -1;
687.1170 -						if(rswatches[watchIndex].Size == 'b')
687.1171 -							sizeType = 0;
687.1172 -						else if(rswatches[watchIndex].Size == 'w')
687.1173 -							sizeType = 1;
687.1174 -						else if(rswatches[watchIndex].Size == 'd')
687.1175 -							sizeType = 2;
687.1176 -
687.1177 -						int numberType = -1;
687.1178 -						if(rswatches[watchIndex].Type == 's')
687.1179 -							numberType = 0;
687.1180 -						else if(rswatches[watchIndex].Type == 'u')
687.1181 -							numberType = 1;
687.1182 -						else if(rswatches[watchIndex].Type == 'h')
687.1183 -							numberType = 2;
687.1184 -
687.1185 -						if(systemCartridgeType == 0)
687.1186 -						{
687.1187 -							AddCheat dlg (address/*, hDlg*/);
687.1188 -							if(sizeType != -1) dlg.sizeType = sizeType;
687.1189 -							if(numberType != -1) dlg.numberType = numberType;
687.1190 -							systemSoundClearBuffer();
687.1191 -							dlg.DoModal();
687.1192 -						}
687.1193 -						else
687.1194 -						{
687.1195 -							AddGBCheat dlg (address/*, hDlg*/);
687.1196 -							if(sizeType != -1) dlg.sizeType = sizeType;
687.1197 -							if(numberType != -1) dlg.numberType = numberType;
687.1198 -							systemSoundClearBuffer();
687.1199 -							dlg.DoModal();
687.1200 -						}
687.1201 -					}
687.1202 -				}
687.1203 -				break;
687.1204 -				case IDOK:
687.1205 -				case IDCANCEL:
687.1206 -					RamWatchHWnd = NULL;
687.1207 -					DragAcceptFiles(hDlg, FALSE);
687.1208 -					EndDialog(hDlg, true);
687.1209 -					return true;
687.1210 -				default:
687.1211 -					if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES && LOWORD(wParam) <= RW_MENU_LAST_RECENT_FILE)
687.1212 -					OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE);
687.1213 -			}
687.1214 -			break;
687.1215 -
687.1216 -#if 0
687.1217 -		// this message is never received
687.1218 -		case WM_KEYDOWN: // handle accelerator keys
687.1219 -		{
687.1220 -			SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
687.1221 -			MSG msg;
687.1222 -			msg.hwnd = hDlg;
687.1223 -			msg.message = uMsg;
687.1224 -			msg.wParam = wParam;
687.1225 -			msg.lParam = lParam;
687.1226 -			if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg))
687.1227 -				return true;
687.1228 -		}	break;
687.1229 -#endif
687.1230 -
687.1231 -		case WM_CLOSE:
687.1232 -			SendMessage(RamWatchHWnd, WM_DESTROY, 0, 0);
687.1233 -			break;
687.1234 -
687.1235 -		case WM_DESTROY:
687.1236 -			// this is the correct place
687.1237 -			RamWatchHWnd = NULL;
687.1238 -			DragAcceptFiles(hDlg, FALSE);
687.1239 -			WriteRecentRWFiles();	// write recent menu to ini
687.1240 -			break;
687.1241 -
687.1242 -		case WM_DROPFILES:
687.1243 -		{
687.1244 -			HDROP hDrop = (HDROP)wParam;
687.1245 -			DragQueryFile(hDrop, 0, Str_Tmp, 1024);
687.1246 -			DragFinish(hDrop);
687.1247 -			return Load_Watches(true, Str_Tmp);
687.1248 -		}	break;
687.1249 -	}
687.1250 -
687.1251 -	return false;
687.1252 -}
   688.1 --- a/src/win32/ramwatch.h	Sat Mar 03 10:54:39 2012 -0600
   688.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   688.3 @@ -1,46 +0,0 @@
   688.4 -#ifndef RAMWATCH_H
   688.5 -#define RAMWATCH_H
   688.6 -
   688.7 -bool ResetWatches();
   688.8 -void OpenRWRecentFile(int memwRFileNumber);
   688.9 -extern bool AutoRWLoad;
  688.10 -extern bool RWSaveWindowPos;
  688.11 -#define MAX_RECENT_WATCHES 5
  688.12 -extern char rw_recent_files[MAX_RECENT_WATCHES][1024];
  688.13 -extern bool AskSave();
  688.14 -extern int ramw_x;
  688.15 -extern int ramw_y;
  688.16 -extern bool RWfileChanged;
  688.17 -
  688.18 -//Constants
  688.19 -#define AUTORWLOAD "RamWatchAutoLoad"
  688.20 -#define RWSAVEPOS "RamWatchSaveWindowPos"
  688.21 -#define RAMWX "RamwX"
  688.22 -#define RAMWY "RamwY"
  688.23 -
  688.24 -// AddressWatcher is self-contained now
  688.25 -struct AddressWatcher
  688.26 -{
  688.27 -	unsigned int Address; // hardware address
  688.28 -	char Size;
  688.29 -	char Type;
  688.30 -	char* comment; // NULL means no comment, non-NULL means allocated comment
  688.31 -	bool WrongEndian;
  688.32 -	unsigned int CurValue;
  688.33 -};
  688.34 -#define MAX_WATCH_COUNT 256
  688.35 -extern AddressWatcher rswatches[MAX_WATCH_COUNT];
  688.36 -extern int WatchCount; // number of valid items in rswatches
  688.37 -
  688.38 -extern char Watch_Dir[1024];
  688.39 -
  688.40 -extern HWND RamWatchHWnd;
  688.41 -extern HACCEL RamWatchAccels;
  688.42 -
  688.43 -bool InsertWatch(const AddressWatcher& Watch, char *Comment);
  688.44 -bool InsertWatch(const AddressWatcher& Watch, HWND parent=NULL); // asks user for comment
  688.45 -void Update_RAM_Watch();
  688.46 -bool Load_Watches(bool clear, const char* filename);
  688.47 -void RWAddRecentFile(const char *filename);
  688.48 -
  688.49 -#endif
   689.1 --- a/src/win32/resource.h	Sat Mar 03 10:54:39 2012 -0600
   689.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   689.3 @@ -1,1076 +0,0 @@
   689.4 -//{{NO_DEPENDENCIES}}
   689.5 -// Microsoft Visual C++ generated include file.
   689.6 -// Used by VBA.rc
   689.7 -//
   689.8 -#define IDS_UNSUPPORTED_VBA_SGM         1
   689.9 -#define IDS_CANNOT_LOAD_SGM             2
  689.10 -#define IDS_SAVE_GAME_NOT_USING_BIOS    3
  689.11 -#define IDS_SAVE_GAME_USING_BIOS        4
  689.12 -#define IDS_UNSUPPORTED_SAVE_TYPE       5
  689.13 -#define IDS_CANNOT_OPEN_FILE            6
  689.14 -#define IDS_BAD_ZIP_FILE                7
  689.15 -#define IDS_NO_IMAGE_ON_ZIP             8
  689.16 -#define IDS_ERROR_OPENING_IMAGE         9
  689.17 -#define IDS_ERROR_READING_IMAGE         10
  689.18 -#define IDS_UNSUPPORTED_BIOS_FUNCTION   11
  689.19 -#define IDS_INVALID_BIOS_FILE_SIZE      12
  689.20 -#define IDS_INVALID_CHEAT_CODE          13
  689.21 -#define IDS_UNKNOWN_ARM_OPCDOE          14
  689.22 -#define IDS_UNKNOWN_THUMB_OPCODE        15
  689.23 -#define IDS_ERROR_CREATING_FILE         16
  689.24 -#define IDS_FAILED_TO_READ_SGM          17
  689.25 -#define IDS_FAILED_TO_READ_RTC          18
  689.26 -#define IDS_UNSUPPORTED_VB_SGM          19
  689.27 -#define IDS_CANNOT_LOAD_SGM_FOR         20
  689.28 -#define IDS_ERROR_OPENING_IMAGE_FROM    21
  689.29 -#define IDS_ERROR_READING_IMAGE_FROM    22
  689.30 -#define IDS_UNSUPPORTED_ROM_SIZE        23
  689.31 -#define IDS_UNSUPPORTED_RAM_SIZE        24
  689.32 -#define IDS_UNKNOWN_CARTRIDGE_TYPE      25
  689.33 -#define IDS_MAXIMUM_NUMBER_OF_CHEATS    26
  689.34 -#define IDS_INVALID_GAMESHARK_CODE      27
  689.35 -#define IDS_INVALID_GAMEGENIE_CODE      28
  689.36 -#define IDS_INVALID_CHEAT_TO_REMOVE     29
  689.37 -#define IDS_INVALID_CHEAT_CODE_ADDRESS  30
  689.38 -#define IDS_UNSUPPORTED_CHEAT_LIST_VERSION 31
  689.39 -#define IDS_UNSUPPORTED_CHEAT_LIST_TYPE 32
  689.40 -#define IDS_INVALID_GSA_CODE            33
  689.41 -#define IDS_CANNOT_IMPORT_SNAPSHOT_FOR  34
  689.42 -#define IDS_UNSUPPORTED_SNAPSHOT_FILE   35
  689.43 -#define IDS_UNSUPPORTED_ARM_MODE        36
  689.44 -#define IDS_UNSUPPORTED_CODE_FILE       37
  689.45 -#define IDS_GSA_CODE_WARNING            38
  689.46 -#define IDS_INVALID_CBA_CODE            39
  689.47 -#define IDS_CBA_CODE_WARNING            40
  689.48 -#define IDS_OUT_OF_MEMORY               41
  689.49 -#define IDS_STRING42                    42
  689.50 -#define IDI_ICON                        101
  689.51 -#define IDD_REGISTERS                   102
  689.52 -#define IDD_DEBUG                       103
  689.53 -#define IDR_MENU                        104
  689.54 -#define IDD_ABOUT                       105
  689.55 -#define IDR_ACCELERATOR                 106
  689.56 -#define IDD_CHEATS                      107
  689.57 -#define IDD_ADD_CHEAT                   108
  689.58 -#define IDD_DIRECTORIES                 109
  689.59 -#define IDD_CONFIG                      110
  689.60 -#define IDD_GS                          111
  689.61 -#define IDD_GG                          112
  689.62 -#define IDD_CHEAT_LIST                  113
  689.63 -#define IDD_ASSOCIATIONS                114
  689.64 -#define IDR_GB_PRINTER                  115
  689.65 -#define IDD_GBA_ROM_INFO                116
  689.66 -#define IDD_GB_ROM_INFO                 117
  689.67 -#define IDD_GB_CHEAT_LIST               118
  689.68 -#define IDD_ADD_CHEAT_DLG               119
  689.69 -#define IDD_GB_PRINTER                  120
  689.70 -#define IDD_MOTION_CONFIG               121
  689.71 -#define IDD_LANG_SELECT                 122
  689.72 -#define IDD_CODE_SELECT                 123
  689.73 -#define IDD_OPENDLG                     124
  689.74 -#define IDD_MAP_VIEW                    126
  689.75 -#define IDD_PALETTE_VIEW                127
  689.76 -#define IDD_MEM_VIEWER                  128
  689.77 -#define IDD_OAM_VIEW                    130
  689.78 -#define IDD_ACCEL_EDITOR                131
  689.79 -#define IDD_TILE_VIEWER                 132
  689.80 -#define IDD_GB_COLORS                   133
  689.81 -#define IDD_DISASSEMBLE                 134
  689.82 -#define IDD_GDB_PORT                    135
  689.83 -#define IDD_GDB_WAITING                 136
  689.84 -#define IDD_LOGGING                     137
  689.85 -#define IDD_EXPORT_SPS                  138
  689.86 -#define IDD_ADDR_SIZE                   139
  689.87 -#define IDD_MODES                       140
  689.88 -#define IDD_DRIVERS                     142
  689.89 -#define IDD_THROTTLE                    143
  689.90 -#define IDD_GB_DISASSEMBLE              144
  689.91 -#define IDD_GB_OAM_VIEW                 145
  689.92 -#define IDD_GB_TILE_VIEWER              146
  689.93 -#define IDD_GB_MAP_VIEW                 147
  689.94 -#define IDD_GB_PALETTE_VIEW             148
  689.95 -#define IDD_MODE_CONFIRM                149
  689.96 -#define IDD_REWIND_INTERVAL             150
  689.97 -#define IDD_IO_VIEWER                   151
  689.98 -#define IDD_MAX_SCALE                   154
  689.99 -#define IDD_BUG_REPORT                  155
 689.100 -#define IDD_MOVIECREATE                 156
 689.101 -#define IDD_MOVIEOPEN                   157
 689.102 -#define IDD_TEXTCONFIG                  158
 689.103 -#define IDD_LUA                         159
 689.104 -#define IDD_ARCHIVEFILECHOOSER          160
 689.105 -#define IDD_RAMSEARCH                   161
 689.106 -#define IDD_EDITWATCH                   162
 689.107 -#define IDD_RAMWATCH                    163
 689.108 -#define IDD_PROMPT                      164
 689.109 -#define IDR_ACCELERATOR1                165
 689.110 -#define IDC_R0                          1000
 689.111 -#define IDC_EDIT_UP                     1000
 689.112 -#define IDC_R1                          1001
 689.113 -#define IDC_EDIT_DOWN                   1001
 689.114 -#define IDC_R2                          1002
 689.115 -#define IDC_EDIT_LEFT                   1002
 689.116 -#define IDC_R3                          1003
 689.117 -#define IDC_EDIT_RIGHT                  1003
 689.118 -#define IDC_R4                          1004
 689.119 -#define IDC_EDIT_BUTTON_A               1004
 689.120 -#define IDC_R5                          1005
 689.121 -#define IDC_EDIT_BUTTON_B               1005
 689.122 -#define IDC_R6                          1006
 689.123 -#define IDC_EDIT_BUTTON_SELECT          1006
 689.124 -#define IDC_R7                          1007
 689.125 -#define IDC_EDIT_BUTTON_START           1007
 689.126 -#define IDC_R8                          1008
 689.127 -#define ID_OK                           1008
 689.128 -#define IDC_R9                          1009
 689.129 -#define ID_CANCEL                       1009
 689.130 -#define ID_SAVE                         1009
 689.131 -#define IDC_R10                         1010
 689.132 -#define IDC_EDIT_SPEED                  1010
 689.133 -#define IDC_R11                         1011
 689.134 -#define IDC_EDIT_CAPTURE                1011
 689.135 -#define IDC_R12                         1012
 689.136 -#define IDC_EDIT_BUTTON_L               1012
 689.137 -#define IDC_R13                         1013
 689.138 -#define IDC_EDIT_BUTTON_GS              1013
 689.139 -#define IDC_R14                         1014
 689.140 -#define IDC_EDIT_BUTTON_R               1014
 689.141 -#define IDC_R15                         1015
 689.142 -#define IDC_R16                         1016
 689.143 -#define IDC_R17                         1017
 689.144 -#define IDC_N_FLAG                      1018
 689.145 -#define IDC_Z_FLAG                      1019
 689.146 -#define IDC_NEXT                        1019
 689.147 -#define IDC_C_FLAG                      1020
 689.148 -#define IDC_CONTINUE                    1020
 689.149 -#define IDC_V_FLAG                      1021
 689.150 -#define IDC_CHEAT_LIST                  1021
 689.151 -#define IDC_IRQ                         1022
 689.152 -#define IDC_START                       1022
 689.153 -#define IDC_T_FLAG                      1023
 689.154 -#define IDC_SEARCH                      1023
 689.155 -#define IDS_DIRECTX_7_REQUIRED          1024
 689.156 -#define IDC_ADD_CHEAT                   1024
 689.157 -#define IDC_OLD_VALUE                   1025
 689.158 -#define IDC_ADD_GS_CHEAT                1025
 689.159 -#define IDS_DISABLING_VIDEO_MEMORY      1025
 689.160 -#define IDC_ADD_GAMESHARK               1025
 689.161 -#define IDC_SPECIFIC_VALUE              1026
 689.162 -#define IDS_SETTING_WILL_BE_EFFECTIVE   1026
 689.163 -#define IDS_DISABLING_EMULATION_ONLY    1027
 689.164 -#define IDC_SIZE_8                      1028
 689.165 -#define IDS_FAILED_TO_OPEN_FILE         1028
 689.166 -#define IDC_SIZE_16                     1029
 689.167 -#define IDS_FAILED_TO_READ_ZIP_DIR      1029
 689.168 -#define IDC_SIZE_32                     1030
 689.169 -#define IDS_UNSUPPORTED_FILE_TYPE       1030
 689.170 -#define IDC_EQ                          1031
 689.171 -#define IDS_CANNOT_CREATE_DIRECTSOUND   1031
 689.172 -#define IDC_NE                          1032
 689.173 -#define IDS_CANNOT_SETCOOPERATIVELEVEL  1032
 689.174 -#define IDC_LT                          1033
 689.175 -#define IDS_CANNOT_CREATESOUNDBUFFER    1033
 689.176 -#define IDC_LE                          1034
 689.177 -#define IDS_CANNOT_SETFORMAT_PRIMARY    1034
 689.178 -#define IDC_GT                          1035
 689.179 -#define IDS_CANNOT_CREATESOUNDBUFFER_SEC 1035
 689.180 -#define IDC_GE                          1036
 689.181 -#define IDS_CANNOT_PLAY_PRIMARY         1036
 689.182 -#define IDC_SIGNED                      1037
 689.183 -#define IDS_SEARCH_PRODUCED_TOO_MANY    1037
 689.184 -#define IDC_UNSIGNED                    1038
 689.185 -#define IDS_NUMBER_CANNOT_BE_EMPTY      1038
 689.186 -#define IDS_INVALID_ADDRESS             1039
 689.187 -#define IDC_HEXADECIMAL                 1040
 689.188 -#define IDS_MISALIGNED_HALFWORD         1040
 689.189 -#define IDC_VALUE                       1041
 689.190 -#define IDS_MISALIGNED_WORD             1041
 689.191 -#define IDC_ADDRESS                     1042
 689.192 -#define IDS_VALUE_CANNOT_BE_EMPTY       1042
 689.193 -#define IDS_ERROR_ON_STARTDOC           1043
 689.194 -#define IDC_R                           1043
 689.195 -#define IDS_ERROR_ON_STARTPAGE          1044
 689.196 -#define IDC_G                           1044
 689.197 -#define IDS_ERROR_PRINTING_ON_STRETCH   1045
 689.198 -#define IDC_B                           1045
 689.199 -#define IDC_UPDATE                      1046
 689.200 -#define IDS_ERROR_ON_ENDPAGE            1046
 689.201 -#define IDC_TILE_NUM                    1046
 689.202 -#define IDC_GGDESC                      1047
 689.203 -#define IDS_ERROR_ON_ENDDOC             1047
 689.204 -#define IDC_FLIP                        1047
 689.205 -#define IDC_GGCODE                      1048
 689.206 -#define IDS_ERROR                       1048
 689.207 -#define IDC_PALETTE_NUM                 1048
 689.208 -#define IDC_GGADD                       1049
 689.209 -#define IDS_JOY_LEFT                    1049
 689.210 -#define IDC_GGDEL                       1050
 689.211 -#define IDS_JOY_RIGHT                   1050
 689.212 -#define IDC_GGLIST                      1051
 689.213 -#define IDS_JOY_UP                      1051
 689.214 -#define IDC_GGRES                       1052
 689.215 -#define IDS_JOY_DOWN                    1052
 689.216 -#define IDC_GGQUIT                      1053
 689.217 -#define IDS_JOY_BUTTON                  1053
 689.218 -#define IDC_GSDESC                      1054
 689.219 -#define IDC_GSCODE                      1055
 689.220 -#define IDC_GSADD                       1056
 689.221 -#define IDC_GSDEL                       1057
 689.222 -#define IDC_GSLIST                      1058
 689.223 -#define IDS_SELECT_BIOS_FILE            1058
 689.224 -#define IDC_GSRES                       1059
 689.225 -#define IDS_RESET                       1059
 689.226 -#define IDC_GSQUIT                      1060
 689.227 -#define IDS_AUTOFIRE_A_DISABLED         1060
 689.228 -#define IDC_FREEZE                      1061
 689.229 -#define IDS_AUTOFIRE_A                  1061
 689.230 -#define IDS_AUTOFIRE_B_DISABLED         1062
 689.231 -#define IDS_AUTOFIRE_B                  1063
 689.232 -#define IDS_AUTOFIRE_L_DISABLED         1064
 689.233 -#define IDS_AUTOFIRE_L                  1065
 689.234 -#define IDS_AUTOFIRE_R_DISABLED         1066
 689.235 -#define IDC_REMOVE                      1067
 689.236 -#define IDS_AUTOFIRE_R                  1067
 689.237 -#define IDC_REMOVE_ALL                  1068
 689.238 -#define IDS_SELECT_ROM                  1068
 689.239 -#define IDS_SELECT_SAVE_GAME_NAME       1069
 689.240 -#define IDC_ENABLE                      1070
 689.241 -#define IDS_LOADED_STATE                1070
 689.242 -#define IDS_LOADED_STATE_N              1071
 689.243 -#define IDS_WROTE_STATE                 1072
 689.244 -#define IDS_WROTE_STATE_N               1073
 689.245 -#define IDC_RESTORE                     1074
 689.246 -#define IDS_LOADED_BATTERY              1074
 689.247 -#define IDC_GBA                         1075
 689.248 -#define IDS_SELECT_CAPTURE_NAME         1075
 689.249 -#define IDC_AGB                         1076
 689.250 -#define IDS_SCREEN_CAPTURE              1076
 689.251 -#define IDC_BIN                         1077
 689.252 -#define IDS_ADDRESS                     1077
 689.253 -#define IDC_GB                          1078
 689.254 -#define IDS_OLD_VALUE                   1078
 689.255 -#define IDC_SGB                         1079
 689.256 -#define IDC_ROM_TITLE                   1079
 689.257 -#define IDS_NEW_VALUE                   1079
 689.258 -#define IDC_CGB                         1080
 689.259 -#define IDC_ROM_GAME_CODE               1080
 689.260 -#define IDS_ADD_CHEAT_CODE              1080
 689.261 -#define IDC_GBC                         1081
 689.262 -#define IDC_ROM_MAKER_CODE              1081
 689.263 -#define IDS_CODE                        1081
 689.264 -#define IDC_ROM_UNIT_CODE               1082
 689.265 -#define IDS_DESCRIPTION                 1082
 689.266 -#define IDC_ROM_DEVICE_TYPE             1083
 689.267 -#define IDS_STATUS                      1083
 689.268 -#define IDC_ROM_VERSION                 1084
 689.269 -#define IDS_ADD_GG_CODE                 1084
 689.270 -#define IDC_ROM_CRC                     1085
 689.271 -#define IDS_ADD_GS_CODE                 1085
 689.272 -#define IDC_ROM_COLOR                   1086
 689.273 -#define IDC_CODE                        1086
 689.274 -#define IDS_POCKET_PRINTER              1086
 689.275 -#define IDC_ROM_MAKER_NAME              1086
 689.276 -#define IDC_ROM_SIZE                    1087
 689.277 -#define IDC_DESC                        1087
 689.278 -#define IDS_UNKNOWN                     1087
 689.279 -#define IDC_ROM_RAM_SIZE                1088
 689.280 -#define IDC_ADD_GG_CHEAT                1088
 689.281 -#define IDS_NONE                        1088
 689.282 -#define IDC_ROM_DEST_CODE               1089
 689.283 -#define IDC_GB_PRINTER                  1089
 689.284 -#define IDS_FAILED_TO_LOAD_LIBRARY      1089
 689.285 -#define IDC_ROM_LIC_CODE                1090
 689.286 -#define IDC_1X                          1090
 689.287 -#define IDS_FAILED_TO_GET_LOCINFO       1090
 689.288 -#define IDC_EDIT_AUTHOR                 1090
 689.289 -#define IDC_ROM_CHECKSUM                1091
 689.290 -#define IDC_2X                          1091
 689.291 -#define IDS_SELECT_CHEAT_LIST_NAME      1091
 689.292 -#define IDC_EDIT_DESCRIPTION            1091
 689.293 -#define IDC_3X                          1092
 689.294 -#define IDS_FILTER_BIOS                 1092
 689.295 -#define IDC_4X                          1093
 689.296 -#define IDS_FILTER_ROM                  1093
 689.297 -#define IDC_ROM_MAKER_NAME2             1093
 689.298 -#define ID_PRINT                        1094
 689.299 -#define IDS_FILTER_SGM                  1094
 689.300 -#define IDC_ADD_GSA                     1095
 689.301 -#define IDC_ADD_CODE                    1095
 689.302 -#define IDS_FILTER_CHEAT_LIST           1095
 689.303 -#define IDC_TRANSLATION_BY              1096
 689.304 -#define IDS_FILTER_PNG                  1096
 689.305 -#define IDC_LANG_STRING                 1097
 689.306 -#define IDS_LOADED_CHEATS               1097
 689.307 -#define IDC_LANG_NAME                   1098
 689.308 -#define IDS_ERROR_DISP_COLOR            1098
 689.309 -#define IDS_ADD_GSA_CODE                1099
 689.310 -#define IDC_GAME_LIST                   1099
 689.311 -#define IDS_FILTER_SPS                  1100
 689.312 -#define IDS_SELECT_SNAPSHOT_FILE        1101
 689.313 -#define IDC_ADD_CODEBREAKER             1101
 689.314 -#define IDS_FILTER_SAV                  1102
 689.315 -#define IDS_SELECT_BATTERY_FILE         1103
 689.316 -#define IDS_FILTER_GBS                  1104
 689.317 -#define IDS_FILTER_GCF                  1105
 689.318 -#define IDS_SELECT_CODE_FILE            1106
 689.319 -#define IDS_SAVE_WILL_BE_LOST           1107
 689.320 -#define IDS_CONFIRM_ACTION              1108
 689.321 -#define IDS_CODES_WILL_BE_LOST          1109
 689.322 -#define IDS_FILTER_SPC                  1110
 689.323 -#define IDS_ADD_CBA_CODE                1111
 689.324 -#define IDS_FILTER_WAV                  1112
 689.325 -#define IDS_SELECT_WAV_NAME             1113
 689.326 -#define IDC_FRAME_0                     1113
 689.327 -#define IDS_FILTER_GBROM                1114
 689.328 -#define IDC_FRAME_1                     1114
 689.329 -#define IDC_BG0                         1115
 689.330 -#define IDS_FILTER_PAL                  1115
 689.331 -#define IDC_BG1                         1116
 689.332 -#define IDS_SELECT_PALETTE_NAME         1116
 689.333 -#define IDC_BG2                         1117
 689.334 -#define IDS_SEARCH_PRODUCED_NO_RESULTS  1117
 689.335 -#define IDC_BG3                         1118
 689.336 -#define IDS_ERROR_BINDING               1118
 689.337 -#define IDS_ERROR_LISTENING             1119
 689.338 -#define IDS_ERROR_CREATING_SOCKET       1120
 689.339 -#define IDS_ACK_NOT_RECEIVED            1121
 689.340 -#define IDS_ERROR_NOT_GBA_IMAGE         1122
 689.341 -#define IDS_EEPROM_NOT_SUPPORTED        1123
 689.342 -#define IDC_MAP_VIEW                    1124
 689.343 -#define IDS_FILTER_DUMP                 1124
 689.344 -#define IDC_PALETTE_VIEW                1125
 689.345 -#define IDS_SELECT_DUMP_FILE            1125
 689.346 -#define IDC_PALETTE_VIEW_OBJ            1126
 689.347 -#define IDC_REFRESH                     1126
 689.348 -#define IDS_FILTER_AVI                  1126
 689.349 -#define IDC_SAVE                        1127
 689.350 -#define IDC_GOPC                        1127
 689.351 -#define IDS_SELECT_AVI_NAME             1127
 689.352 -#define IDC_APPLY                       1127
 689.353 -#define IDS_INVALID_THROTTLE_VALUE      1128
 689.354 -#define IDC_REFRESH2                    1129
 689.355 -#define IDS_FILTER_INI                  1129
 689.356 -#define IDS_SELECT_SKIN_FILE            1130
 689.357 -#define IDC_CLOSE                       1131
 689.358 -#define IDS_FILTER_VMV                  1131
 689.359 -#define IDS_FILTER_MOVIE                1131
 689.360 -#define IDS_SELECT_MOVIE_NAME           1132
 689.361 -#define IDS_BUG_REPORT                  1133
 689.362 -#define IDS_UNSUPPORTED_MOVIE_VERSION   1134
 689.363 -#define IDS_END_OF_MOVIE                1135
 689.364 -#define IDC_COLOR                       1136
 689.365 -#define IDS_INVALID_INTERVAL_VALUE      1136
 689.366 -#define IDC_SAVE_BG                     1137
 689.367 -#define IDS_REGISTRY                    1137
 689.368 -#define IDC_SAVE_OBJ                    1138
 689.369 -#define IDC_MAP_VIEW_ZOOM               1138
 689.370 -#define IDS_MOVIE_PLAY                  1138
 689.371 -#define IDS_AUTOFIRE_DISABLED           1139
 689.372 -#define IDC_VIEWER                      1140
 689.373 -#define IDS_AUTOFIRE_ALREADY_DISABLED   1140
 689.374 -#define IDC_ADDRESSES                   1141
 689.375 -#define IDS_AUTOFIRE_START_DISABLED     1141
 689.376 -#define IDS_AUTOFIRE_START              1142
 689.377 -#define IDC_GO                          1143
 689.378 -#define IDS_AUTOFIRE_SELECT_DISABLED    1143
 689.379 -#define IDC_8_BIT                       1144
 689.380 -#define IDS_AUTOFIRE_SELECT             1144
 689.381 -#define IDC_16_BIT                      1145
 689.382 -#define IDS_AUTOFIRE_UP_DISABLED        1145
 689.383 -#define IDC_32_BIT                      1146
 689.384 -#define IDS_AUTOFIRE_UP                 1146
 689.385 -#define IDC_OAM_VIEW                    1147
 689.386 -#define IDS_AUTOFIRE_DOWN_DISABLED      1147
 689.387 -#define IDC_OAM_VIEW_ZOOM               1148
 689.388 -#define IDS_AUTOFIRE_DOWN               1148
 689.389 -#define IDS_AUTOFIRE_LEFT_DISABLED      1149
 689.390 -#define IDC_SPRITE                      1150
 689.391 -#define IDS_AUTOFIRE_LEFT               1150
 689.392 -#define IDC_POS                         1151
 689.393 -#define IDS_AUTOFIRE_RIGHT_DISABLED     1151
 689.394 -#define IDC_MODE                        1152
 689.395 -#define IDS_AUTOFIRE_RIGHT              1152
 689.396 -#define IDC_COLORS                      1153
 689.397 -#define IDC_MAPBASE                     1153
 689.398 -#define IDS_RERECORDED_STATE_N          1153
 689.399 -#define IDC_PALETTE                     1154
 689.400 -#define IDC_CHARBASE                    1154
 689.401 -#define IDS_REPLAYED_STATE_N            1154
 689.402 -#define IDC_TILE                        1155
 689.403 -#define IDC_DIM                         1155
 689.404 -#define IDC_PRIO                        1156
 689.405 -#define IDC_NUMCOLORS                   1156
 689.406 -#define IDC_SCROLLBAR                   1157
 689.407 -#define IDC_PRIORITY                    1157
 689.408 -#define IDC_MOSAIC                      1158
 689.409 -#define IDC_SIZE2                       1159
 689.410 -#define IDC_OVERFLOW                    1159
 689.411 -#define IDC_ROT                         1160
 689.412 -#define IDC_FLAGS                       1161
 689.413 -#define IDC_COMMANDS                    1162
 689.414 -#define IDC_BANK                        1162
 689.415 -#define IDC_CURRENTS                    1163
 689.416 -#define IDC_ASSIGN                      1164
 689.417 -#define IDC_RESET                       1165
 689.418 -#define IDC_EDIT_KEY                    1166
 689.419 -#define IDC_ALREADY_AFFECTED            1167
 689.420 -#define IDC_TILE_VIEW                   1168
 689.421 -#define IDC_16_COLORS                   1169
 689.422 -#define IDC_256_COLORS                  1170
 689.423 -#define IDC_CHARBASE_0                  1173
 689.424 -#define IDC_CHARBASE_1                  1174
 689.425 -#define IDC_CHARBASE_2                  1175
 689.426 -#define IDC_CHARBASE_3                  1176
 689.427 -#define IDC_PALETTE_SLIDER              1177
 689.428 -#define IDC_CHARBASE_4                  1178
 689.429 -#define IDC_COLOR_BG0                   1178
 689.430 -#define IDC_COLOR_BG1                   1179
 689.431 -#define IDC_URL                         1179
 689.432 -#define IDC_COLOR_BG2                   1180
 689.433 -#define IDC_STRETCH                     1180
 689.434 -#define IDC_COLOR_BG3                   1181
 689.435 -#define IDC_COLOR_OB0                   1182
 689.436 -#define IDC_COLOR_OB1                   1183
 689.437 -#define IDC_COLOR_OB2                   1184
 689.438 -#define IDC_COLOR_OB3                   1185
 689.439 -#define IDC_TRANSLATOR_URL              1186
 689.440 -#define IDC_STATIC1                     1187
 689.441 -#define IDC_STATIC2                     1188
 689.442 -#define IDC_STATIC3                     1189
 689.443 -#define IDC_STATIC4                     1190
 689.444 -#define IDC_DEFAULT                     1191
 689.445 -#define IDC_USER1                       1192
 689.446 -#define IDC_USER2                       1193
 689.447 -#define IDC_DISASSEMBLE                 1196
 689.448 -#define IDC_AUTOMATIC                   1199
 689.449 -#define IDC_ARM                         1200
 689.450 -#define IDC_THUMB                       1201
 689.451 -#define IDC_RECNOW                      1201
 689.452 -#define IDC_RECRESET                    1202
 689.453 -#define IDC_JOYPAD1                     1203
 689.454 -#define IDC_RECSTART                    1203
 689.455 -#define IDC_REC_NOBIOS                  1204
 689.456 -#define IDC_AUTO_UPDATE                 1204
 689.457 -#define IDC_JOYPAD2                     1204
 689.458 -#define IDC_REC_EMUBIOS                 1205
 689.459 -#define IDC_JOYPAD3                     1205
 689.460 -#define IDC_REC_GBABIOS                 1206
 689.461 -#define IDC_JOYPAD4                     1206
 689.462 -#define IDC_REC_GBABIOSINTRO            1207
 689.463 -#define IDC_MOVIE_FILENAME              1208
 689.464 -#define IDC_N                           1210
 689.465 -#define IDC_LABEL_DATE                  1210
 689.466 -#define IDC_Z                           1211
 689.467 -#define IDC_LABEL_LENGTH                1211
 689.468 -#define IDC_C                           1212
 689.469 -#define IDC_LABEL_FRAMES                1212
 689.470 -#define IDC_V                           1213
 689.471 -#define IDC_LABEL_RERECORD              1213
 689.472 -#define IDC_F                           1214
 689.473 -#define IDC_LABEL_FROM                  1214
 689.474 -#define IDC_I                           1215
 689.475 -#define IDC_T                           1216
 689.476 -#define IDC_LABEL_WARNING1              1216
 689.477 -#define IDC_PORT                        1217
 689.478 -#define IDC_LABEL_WARNING2              1217
 689.479 -#define IDC_VSCROLL                     1218
 689.480 -#define IDC_LABEL_FROM2                 1218
 689.481 -#define IDC_VERSION                     1219
 689.482 -#define IDC_VERBOSE_SWI                 1223
 689.483 -#define IDC_VERBOSE_UNALIGNED_ACCESS    1224
 689.484 -#define IDC_VERBOSE_ILLEGAL_WRITE       1225
 689.485 -#define IDC_VERBOSE_ILLEGAL_READ        1226
 689.486 -#define IDC_LOG                         1227
 689.487 -#define IDC_CLEAR                       1228
 689.488 -#define IDC_VERBOSE_DMA0                1229
 689.489 -#define IDC_VERBOSE_DMA1                1230
 689.490 -#define IDC_TILE_NUMBER                 1230
 689.491 -#define IDC_VERBOSE_DMA2                1231
 689.492 -#define IDC_XY                          1231
 689.493 -#define IDC_VERBOSE_DMA3                1232
 689.494 -#define IDC_VERBOSE_UNDEFINED           1233
 689.495 -#define IDC_TITLE                       1234
 689.496 -#define IDC_VERBOSE_AGBPRINT            1234
 689.497 -#define IDC_CURRENT_ADDRESS             1235
 689.498 -#define IDC_NOTES                       1236
 689.499 -#define IDC_CURRENT_ADDRESS_LABEL       1236
 689.500 -#define IDC_LOAD                        1238
 689.501 -#define IDC_SIZE_CONTROL                1240
 689.502 -#define IDC_MODES                       1240
 689.503 -#define IDC_DRIVERS                     1241
 689.504 -#define IDC_THROTTLE                    1242
 689.505 -#define IDC_READONLY                    1242
 689.506 -#define IDC_H                           1243
 689.507 -#define IDC_OAP                         1244
 689.508 -#define IDC_BANK_0                      1245
 689.509 -#define IDC_BANK_1                      1246
 689.510 -#define IDC_TIMER                       1247
 689.511 -#define IDC_INTERVAL                    1248
 689.512 -#define IDC_REWINDSLOTS                 1249
 689.513 -#define IDC_BIT_0                       1250
 689.514 -#define IDC_BIT_1                       1251
 689.515 -#define IDC_PREDEFINED                  1251
 689.516 -#define IDC_BIT_2                       1252
 689.517 -#define IDC_BUG_REPORT                  1252
 689.518 -#define IDC_BIT_3                       1253
 689.519 -#define IDC_COPY                        1253
 689.520 -#define IDC_BIT_4                       1254
 689.521 -#define IDC_BROWSE                      1254
 689.522 -#define IDC_BIT_5                       1255
 689.523 -#define IDC_COMBO1                      1255
 689.524 -#define IDC_MOVIE_REFRESH               1255
 689.525 -#define IDC_BIT_6                       1256
 689.526 -#define IDC_REC_GBA                     1257
 689.527 -#define IDC_BIT_7                       1257
 689.528 -#define IDC_REC_GBC                     1258
 689.529 -#define IDC_BIT_8                       1258
 689.530 -#define IDC_REC_SGB                     1259
 689.531 -#define IDC_BIT_9                       1259
 689.532 -#define IDC_REC_SGB2                    1260
 689.533 -#define IDC_BIT_10                      1260
 689.534 -#define IDC_REC_GB                      1260
 689.535 -#define IDC_BIT_11                      1261
 689.536 -#define IDC_RADIO1                      1261
 689.537 -#define IDC_BIT_12                      1262
 689.538 -#define IDC_EDIT_PAUSEFRAME             1262
 689.539 -#define IDC_BIT_13                      1263
 689.540 -#define IDC_CHECK_PAUSEFRAME            1263
 689.541 -#define IDC_BIT_14                      1264
 689.542 -#define IDC_SLIDER1                     1264
 689.543 -#define IDC_BIT_15                      1265
 689.544 -#define IDC_CHECK_HIDEBORDER            1265
 689.545 -#define IDC_RADIO_WHITE                 1266
 689.546 -#define IDC_RADIO_RED                   1267
 689.547 -#define IDC_RADIO_YELLOW                1268
 689.548 -#define IDC_RADIO_GREEN                 1269
 689.549 -#define IDC_RADIO_CYAN                  1270
 689.550 -#define IDC_RADIO_BLUE                  1271
 689.551 -#define IDC_RADIO_MAGENTA               1272
 689.552 -#define IDC_RADIO_BLACK                 1273
 689.553 -#define IDC_CHECK_OUTLINED              1274
 689.554 -#define IDC_CHECK_TRANSPARENT           1275
 689.555 -#define IDC_RADIO_PREFILTER             1276
 689.556 -#define IDC_RADIO_POSTFILTER            1277
 689.557 -#define IDC_RADIO_POSTRENDER            1278
 689.558 -#define IDC_COMMANDS_HIDDEN             1279
 689.559 -#define IDC_DECIMAL_DISPLAY             1281
 689.560 -#define IDC_ALIGN                       1282
 689.561 -#define IDC_CHEATREFRESHBUTTON          1283
 689.562 -#define IDC_EDIT_LUAPATH                1285
 689.563 -#define IDC_BUTTON_LUABROWSE            1286
 689.564 -#define IDS_FILTER_LUA                  1287
 689.565 -#define IDS_SELECT_LUA_NAME             1288
 689.566 -#define IDS_SELECT_LUA_DIR              1289
 689.567 -#define IDS_SELECT_MOVIE_DIR            1290
 689.568 -#define IDS_SELECT_ROM_DIR              1291
 689.569 -#define IDS_SELECT_GBXROM_DIR           1292
 689.570 -#define IDS_SELECT_BATTERY_DIR          1293
 689.571 -#define IDS_SELECT_SAVE_DIR             1294
 689.572 -#define IDS_SELECT_CAPTURE_DIR          1295
 689.573 -#define IDS_SELECT_AVI_DIR              1296
 689.574 -#define IDS_SELECT_WAV_DIR              1297
 689.575 -#define IDS_SELECT_CHEAT_DIR            1298
 689.576 -#define IDS_SELECT_WATCH_DIR            1299
 689.577 -#define IDS_SELECT_IPS_DIR              1300
 689.578 -#define IDS_SELECT_PLUGIN_DIR           1301
 689.579 -#define IDC_PLUGIN_DIR                  1308
 689.580 -#define IDC_WATCH_DIR                   1309
 689.581 -#define IDC_ROM_DIR                     1310
 689.582 -#define IDC_GBXROM_DIR                  1311
 689.583 -#define IDC_BATTERY_DIR                 1312
 689.584 -#define IDC_SAVE_DIR                    1313
 689.585 -#define IDC_MOVIE_DIR                   1314
 689.586 -#define IDC_CHEAT_DIR                   1315
 689.587 -#define IDC_LUA_DIR                     1316
 689.588 -#define IDC_AVI_DIR                     1317
 689.589 -#define IDC_WAV_DIR                     1318
 689.590 -#define IDC_CAPTURE_DIR                 1319
 689.591 -#define IDC_IPS_DIR                     1320
 689.592 -#define IDC_PLUGIN_PATH                 1328
 689.593 -#define IDC_WATCH_PATH                  1329
 689.594 -#define IDC_ROM_PATH                    1330
 689.595 -#define IDC_GBXROM_PATH                 1331
 689.596 -#define IDC_BATTERY_PATH                1332
 689.597 -#define IDC_SAVE_PATH                   1333
 689.598 -#define IDC_MOVIE_PATH                  1334
 689.599 -#define IDC_CHEAT_PATH                  1335
 689.600 -#define IDC_LUA_PATH                    1336
 689.601 -#define IDC_AVI_PATH                    1337
 689.602 -#define IDC_WAV_PATH                    1338
 689.603 -#define IDC_CAPTURE_PATH                1339
 689.604 -#define IDC_IPS_PATH                    1340
 689.605 -#define IDC_PLUGIN_DIR_RESET            1348
 689.606 -#define IDC_WATCH_DIR_RESET             1349
 689.607 -#define IDC_ROM_DIR_RESET               1350
 689.608 -#define IDC_GBXROM_DIR_RESET            1351
 689.609 -#define IDC_BATTERY_DIR_RESET           1352
 689.610 -#define IDC_SAVE_DIR_RESET              1353
 689.611 -#define IDC_MOVIE_DIR_RESET             1354
 689.612 -#define IDC_CHEAT_DIR_RESET             1355
 689.613 -#define IDC_LUA_DIR_RESET               1356
 689.614 -#define IDC_AVI_DIR_RESET               1357
 689.615 -#define IDC_WAV_DIR_RESET               1358
 689.616 -#define IDC_CAPTURE_DIR_RESET           1359
 689.617 -#define IDC_IPS_DIR_RESET               1360
 689.618 -#define IDC_LIST1                       1361
 689.619 -#define IDC_BUTTON_LUARUN               1362
 689.620 -#define IDC_BUTTON_LUASTOP              1363
 689.621 -#define IDC_LUACONSOLE                  1364
 689.622 -#define IDC_BUTTON_LUAEDIT              1365
 689.623 -#define IDC_LUACONSOLE_CLEAR            1366
 689.624 -#define IDC_LUACONSOLE_CHOOSEFONT       1367
 689.625 -#define IDC_ACCELEDIT_APPLY             1368
 689.626 -#define IDC_ACCELEDIT_SELECTALL         1369
 689.627 -#define IDC_ACCELEDIT_REPLACE           1370
 689.628 -#define IDC_ACCELEDIT_ONFLYKEYEDIT      1371
 689.629 -#define IDC_ACCELEDIT_PROGRESSBAR       1372
 689.630 -#define IDC_ACCELEDIT_AUTOTIMEOUT       1373
 689.631 -#define IDC_ACCELEDIT_UNDO              1374
 689.632 -#define IDC_STATIC5                     1375
 689.633 -#define ID_HELP_ABOUT                   40001
 689.634 -#define ID_FILE_EXIT                    40002
 689.635 -#define ID_OPTIONS_SOUND_MUTE           40003
 689.636 -#define ID_OPTIONS_VIDEO_VSYNC          40009
 689.637 -#define ID_OPTIONS_VIDEO_X1             40010
 689.638 -#define ID_OPTIONS_VIDEO_X2             40011
 689.639 -#define ID_OPTIONS_VIDEO_X3             40012
 689.640 -#define ID_OPTIONS_VIDEO_X4             40013
 689.641 -#define ID_FILE_PAUSE                   40014
 689.642 -#define ID_OPTIONS_EMULATOR_DIRECTORIES 40015
 689.643 -#define ID_OPTIONS_JOYPAD               40016
 689.644 -#define ID_OPTIONS_EMULATOR_SYNCHRONIZE 40017
 689.645 -#define ID_FILE_RESET                   40018
 689.646 -#define ID_FILE_LOAD                    40019
 689.647 -#define ID_OPTIONS_SOUND_DIRECTSOUNDA   40020
 689.648 -#define ID_OPTIONS_SOUND_DIRECTSOUNDB   40021
 689.649 -#define ID_OPTIONS_SOUND_DISABLE        40022
 689.650 -#define ID_OPTIONS_SOUND_OFF            40023
 689.651 -#define ID_OPTIONS_SOUND_ON             40024
 689.652 -#define ID_OPTIONS_SOUND_CHANNEL1       40025
 689.653 -#define ID_OPTIONS_SOUND_CHANNEL2       40026
 689.654 -#define ID_OPTIONS_SOUND_CHANNEL3       40027
 689.655 -#define ID_OPTIONS_SOUND_CHANNEL4       40028
 689.656 -#define ID_OPTIONS_EMULATOR_USEBIOSFILE 40029
 689.657 -#define ID_OPTIONS_EMULATOR_SELECTBIOSFILE 40030
 689.658 -#define ID_CHEATS_SEARCHFORCHEATS       40031
 689.659 -#define ID_CHEATS_ADDCHEAT              40032
 689.660 -#define ID_OPTIONS_VIDEO_DISABLESFX     40033
 689.661 -#define ID_OPTIONS_GAMEBOY_BORDER       40034
 689.662 -#define ID_FILE_SAVEGAME_SLOT1          40035
 689.663 -#define ID_FILE_SAVEGAME_SLOT2          40036
 689.664 -#define ID_FILE_SAVEGAME_SLOT3          40037
 689.665 -#define ID_FILE_SAVEGAME_SLOT4          40038
 689.666 -#define ID_FILE_SAVEGAME_SLOT5          40039
 689.667 -#define ID_FILE_SAVEGAME_SLOT6          40040
 689.668 -#define ID_FILE_SAVEGAME_SLOT7          40041
 689.669 -#define ID_FILE_SAVEGAME_SLOT8          40042
 689.670 -#define ID_FILE_SAVEGAME_SLOT9          40043
 689.671 -#define ID_FILE_SAVEGAME_SLOT10         40044
 689.672 -#define ID_FILE_LOADGAME_SLOT1          40045
 689.673 -#define ID_FILE_LOADGAME_SLOT2          40046
 689.674 -#define ID_FILE_LOADGAME_SLOT3          40047
 689.675 -#define ID_FILE_LOADGAME_SLOT4          40048
 689.676 -#define ID_FILE_LOADGAME_SLOT5          40049
 689.677 -#define ID_FILE_LOADGAME_SLOT6          40050
 689.678 -#define ID_FILE_LOADGAME_SLOT7          40051
 689.679 -#define ID_FILE_LOADGAME_SLOT8          40052
 689.680 -#define ID_FILE_LOADGAME_SLOT9          40053
 689.681 -#define ID_FILE_LOADGAME_SLOT10         40054
 689.682 -#define ID_OPTIONS_GAMEBOY_AUTOMATIC    40057
 689.683 -#define ID_OPTIONS_GAMEBOY_CGB          40058
 689.684 -#define ID_OPTIONS_GAMEBOY_GBA          40059
 689.685 -#define ID_OPTIONS_GAMEBOY_SGB          40060
 689.686 -#define ID_OPTIONS_GAMEBOY_GB           40062
 689.687 -#define ID_OPTIONS_GAMEBOY_REALCOLORS   40063
 689.688 -#define ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS 40064
 689.689 -#define ID_CHEATS_GAMEBOY               40065
 689.690 -#define ID_OPTIONS_SOUND_11KHZ          40067
 689.691 -#define ID_OPTIONS_SOUND_22KHZ          40068
 689.692 -#define ID_OPTIONS_SOUND_44KHZ          40069
 689.693 -#define ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY 40070
 689.694 -#define ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY 40071
 689.695 -#define ID_OPTIONS_PRIORITY_HIGHEST     40072
 689.696 -#define ID_OPTIONS_PRIORITY_ABOVENORMAL 40073
 689.697 -#define ID_OPTIONS_PRIORITY_NORMAL      40074
 689.698 -#define ID_OPTIONS_PRIORITY_BELOWNORMAL 40075
 689.699 -#define ID_OPTIONS_VIDEO_FULLSCREEN320X240 40076
 689.700 -#define ID_OPTIONS_VIDEO_FULLSCREEN640X480 40077
 689.701 -#define ID_OPTIONS_FILTER_NORMAL        40078
 689.702 -#define ID_OPTIONS_FILTER_2XSAI         40079
 689.703 -#define ID_OPTIONS_FILTER_SUPER2XSAI    40081
 689.704 -#define ID_OPTIONS_FILTER_SUPEREAGLE    40082
 689.705 -#define ID_OPTIONS_FILTER_TVMODE        40083
 689.706 -#define ID_CHEATS_CHEATLIST             40084
 689.707 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_A_OLD 40085
 689.708 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_B_OLD 40086
 689.709 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_L_OLD 40087
 689.710 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_R_OLD 40088
 689.711 -#define ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT 40089
 689.712 -#define ID_OPTIONS_EMULATOR_ASSOCIATE   40091
 689.713 -#define ID_OPTIONS_FILTER_DISABLEMMX    40093
 689.714 -#define ID_OPTIONS_1X                   40096
 689.715 -#define ID_OPTIONS_2X                   40097
 689.716 -#define ID_OPTIONS_3X                   40098
 689.717 -#define ID_OPTIONS_4X                   40099
 689.718 -#define ID_FILE_ROMINFORMATION          40100
 689.719 -#define ID_CHEATS_ADDCHEATCODE          40101
 689.720 -#define ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES 40102
 689.721 -#define ID_OPTIONS_JOYPAD_MOTIONCONFIGURE 40103
 689.722 -#define ID_FILE_SCREENCAPTURE           40104
 689.723 -#define ID_OPTIONS_LANGUAGE_SYSTEM      40105
 689.724 -#define ID_OPTIONS_LANGUAGE_ENGLISH     40106
 689.725 -#define ID_OPTIONS_LANGUAGE_OTHER       40107
 689.726 -#define ID_OPTIONS_GAMEBOY_PRINTER      40108
 689.727 -#define ID_FILE_RECENT_RESET            40109
 689.728 -#define ID_CHEATS_SAVECHEATLIST         40110
 689.729 -#define ID_CHEATS_LOADCHEATLIST         40111
 689.730 -#define ID_CHEATS_AUTOMATICSAVELOADCHEATS 40112
 689.731 -#define ID_FILE_IMPORT_GAMESHARKSNAPSHOT 40115
 689.732 -#define ID_FILE_IMPORT_BATTERYFILE      40116
 689.733 -#define ID_FILE_IMPORT_GAMESHARKCODEFILE 40117
 689.734 -#define ID_FILE_EXPORT_BATTERYFILE      40118
 689.735 -#define ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL 40121
 689.736 -#define ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL 40122
 689.737 -#define ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE 40123
 689.738 -#define ID_TOOLS_SOUNDRECORDING         40124
 689.739 -#define IDS_STARTSOUNDRECORDING         40125
 689.740 -#define IDS_STOPSOUNDRECORDING          40126
 689.741 -#define ID_OPTIONS_VIDEO_LAYERS_BG0     40127
 689.742 -#define ID_OPTIONS_VIDEO_LAYERS_BG1     40128
 689.743 -#define ID_OPTIONS_VIDEO_LAYERS_BG2     40129
 689.744 -#define ID_OPTIONS_VIDEO_LAYERS_BG3     40130
 689.745 -#define ID_OPTIONS_VIDEO_LAYERS_OBJ     40131
 689.746 -#define ID_OPTIONS_VIDEO_LAYERS_WIN0    40132
 689.747 -#define ID_OPTIONS_VIDEO_LAYERS_WIN1    40133
 689.748 -#define ID_OPTIONS_VIDEO_LAYERS_OBJWIN  40134
 689.749 -#define ID_FILE_OPENGAMEBOY             40135
 689.750 -#define ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION 40136
 689.751 -#define ID_DEBUG_NEXTFRAME              40137
 689.752 -#define ID_TOOLS_MAPVIEW                40138
 689.753 -#define ID_TOOLS_PALETTEVIEW            40139
 689.754 -#define ID_OPTIONS_EMULATOR_PNGFORMAT   40140
 689.755 -#define ID_OPTIONS_EMULATOR_BMPFORMAT   40141
 689.756 -#define ID_TOOLS_CUSTOMIZE_COMMON       40142
 689.757 -#define ID_TOOLS_MEMORYVIEWER           40143
 689.758 -#define ID_TOOLS_OAMVIEWER              40144
 689.759 -#define ID_TOOLS_TILEVIEWER             40146
 689.760 -#define ID_OPTIONS_GAMEBOY_COLORS       40147
 689.761 -#define ID_OPTIONS_SOUND_ECHO           40148
 689.762 -#define ID_OPTIONS_SOUND_LOWPASSFILTER  40149
 689.763 -#define ID_OPTIONS_SOUND_REVERSESTEREO  40150
 689.764 -#define ID_TOOLS_DISASSEMBLE            40151
 689.765 -#define ID_TOOLS_DEBUG_GDB              40152
 689.766 -#define ID_TOOLS_DEBUG_LOADANDWAIT      40153
 689.767 -#define ID_TOOLS_DEBUG_DISCONNECT       40154
 689.768 -#define ID_TOOLS_DEBUG_BREAK            40155
 689.769 -#define ID_TOOLS_LOGGING                40156
 689.770 -#define ID_OPTIONS_EMULATOR_SPEEDHACK   40157
 689.771 -#define ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE 40158
 689.772 -#define ID_OPTIONS_EMULATOR_REMOVEINTROSGBA 40159
 689.773 -#define ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X 40160
 689.774 -#define ID_OPTIONS_FILTER16BIT_SIMPLE2X 40161
 689.775 -#define ID_FILE_RECENT_FREEZE           40162
 689.776 -#define ID_FILE_EXPORT_GAMESHARKSNAPSHOT 40163
 689.777 -#define ID_OPTIONS_VIDEO_FULLSCREEN800X600 40164
 689.778 -#define ID_OPTIONS_FILTER16BIT_SIMPLE3X 40165
 689.779 -#define ID_OPTIONS_FILTER16BIT_SIMPLE4X 40166
 689.780 -#define ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL3X 40167
 689.781 -#define ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X 40168
 689.782 -#define ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC 40169
 689.783 -#define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM 40170
 689.784 -#define ID_OPTIONS_EMULATOR_SAVETYPE_SRAM 40171
 689.785 -#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH 40172
 689.786 -#define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR 40173
 689.787 -#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K 40174
 689.788 -#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M 40175
 689.789 -#define ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH 40176
 689.790 -#define ID_TOOLS_AVIRECORDING           40177
 689.791 -#define IDS_STARTAVIRECORDING           40178
 689.792 -#define IDS_STOPAVIRECORDING            40179
 689.793 -#define IDS_PAUSEAVIRECORDING           40180
 689.794 -#define IDS_RESUMEAVIRECORDING          40181
 689.795 -#define ID_OPTIONS_SOUND_VOLUME_1X      40182
 689.796 -#define ID_OPTIONS_SOUND_VOLUME_2X      40183
 689.797 -#define ID_OPTIONS_SOUND_VOLUME_3X      40184
 689.798 -#define ID_OPTIONS_SOUND_VOLUME_4X      40185
 689.799 -#define ID_OPTIONS_FILTER_BILINEAR      40186
 689.800 -#define ID_OPTIONS_FILTER_BILINEARPLUS  40187
 689.801 -#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE 40188
 689.802 -#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR 40189
 689.803 -#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART 40190
 689.804 -#define ID_OPTIONS_VIDEO_FULLSCREEN     40191
 689.805 -#define ID_OPTIONS_VIDEO_TRIPLEBUFFERING 40192
 689.806 -#define ID_OPTIONS_FRAMESKIP_AUTOMATIC  40194
 689.807 -#define ID_OPTIONS_EMULATOR_SHOWSPEED_NONE 40195
 689.808 -#define ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE 40196
 689.809 -#define ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED 40197
 689.810 -#define ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT 40198
 689.811 -#define ID_OPTIONS_JOYPAD_CONFIGURE_1   40199
 689.812 -#define ID_OPTIONS_JOYPAD_CONFIGURE_2   40200
 689.813 -#define ID_OPTIONS_JOYPAD_CONFIGURE_3   40201
 689.814 -#define ID_OPTIONS_JOYPAD_CONFIGURE_4   40202
 689.815 -#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1 40208
 689.816 -#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2 40209
 689.817 -#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3 40210
 689.818 -#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4 40211
 689.819 -#define ID_OPTIONS_EMULATOR_STORESETTINGSINREGISTRY 40214
 689.820 -#define ID_FILE_EXPORT_SETTINGSTOINI    40215
 689.821 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE 40216
 689.822 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER 40221
 689.823 -#define ID_SYSTEM_MAXIMIZE              40222
 689.824 -#define ID_OPTIONS_FILTER_SCANLINES     40223
 689.825 -#define ID_OPTIONS_VIDEO_RENDERMETHOD_GDI 40228
 689.826 -#define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW 40229
 689.827 -#define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D 40230
 689.828 -#define ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL 40231
 689.829 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER 40233
 689.830 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR 40234
 689.831 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DTRILINEAR 40235
 689.832 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DANISOTROPIC 40236
 689.833 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST 40237
 689.834 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR 40238
 689.835 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE 40239
 689.836 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS 40240
 689.837 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN 40245
 689.838 -#define ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN 40246
 689.839 -#define ID_OPTIONS_EMULATOR_AGBPRINT    40247
 689.840 -#define ID_OPTIONS_EMULATOR_REALTIMECLOCK 40248
 689.841 -#define ID_OPTIONS_GAMEBOY_SGB2         40249
 689.842 -#define ID_SYSTEM_MINIMIZE              40250
 689.843 -#define ID_MOVIE_RECORD                 40251
 689.844 -#define ID_MOVIE_PLAY                   40253
 689.845 -#define ID_MOVIE_STOP                   40254
 689.846 -#define ID_OPTIONS_EMULATOR_AUTOHIDEMENU 40255
 689.847 -#define ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC 40256
 689.848 -#define ID_OPTIONS_EMULATOR_REWIND      40257
 689.849 -#define ID_TOOLS_REWIND                 40258
 689.850 -#define ID_OPTIONS_EMULATOR_SKIPBIOS    40259
 689.851 -#define ID_HELP_BUGREPORT               40260
 689.852 -#define ID_HELP_FAQ                     40261
 689.853 -#define ID_OPTIONS_EMULATOR_REWINDINTERVAL 40262
 689.854 -#define ID_FILE_TOGGLEMENU              40263
 689.855 -#define ID_OPTIONS_EMULATOR_SAVETYPE_NONE 40264
 689.856 -#define ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION 40265
 689.857 -#define ID_TOOLS_IOVIEWER               40266
 689.858 -#define ID_OPTIONS_SOUND_VOLUME_5X      40270
 689.859 -#define ID_OPTIONS_SOUND_VOLUME_25X     40271
 689.860 -#define ID_CHEATS_DISABLECHEATS         40272
 689.861 -#define ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE 40273
 689.862 -#define ID_OPTIONS_FILTER_LQ2X          40275
 689.863 -#define ID_OPTIONS_FILTER_HQ2X          40276
 689.864 -#define ID_OPTIONS_FILTER_HQ2X2         40277
 689.865 -#define ID_OPTIONS_FILTER_HQ3X          40278
 689.866 -#define ID_OPTIONS_FILTER_HQ3X2         40279
 689.867 -#define ID_OPTIONS_FRAMESKIP_ACCURATEPITCH 40289
 689.868 -#define ID_OPTIONS_FRAMESKIP_ACCURATESPEED 40290
 689.869 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_6 40324
 689.870 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_15 40325
 689.871 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_25 40326
 689.872 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_37 40327
 689.873 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_50 40328
 689.874 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_75 40329
 689.875 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_87 40330
 689.876 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_100 40331
 689.877 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_112 40332
 689.878 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_125 40333
 689.879 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_150 40334
 689.880 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_200 40335
 689.881 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_300 40336
 689.882 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_400 40337
 689.883 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_600 40338
 689.884 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_800 40339
 689.885 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_1000 40340
 689.886 -#define ID_TOOLS_FRAMECOUNTER           40341
 689.887 -#define ID_TOOLS_INPUTDISPLAY           40342
 689.888 -#define ID_OPTIONS_VIDEO_FRAMESKIP_0    40350
 689.889 -#define ID_OPTIONS_VIDEO_FRAMESKIP_1    40351
 689.890 -#define ID_OPTIONS_VIDEO_FRAMESKIP_2    40352
 689.891 -#define ID_OPTIONS_VIDEO_FRAMESKIP_3    40353
 689.892 -#define ID_OPTIONS_VIDEO_FRAMESKIP_4    40354
 689.893 -#define ID_OPTIONS_VIDEO_FRAMESKIP_5    40355
 689.894 -#define ID_OPTIONS_VIDEO_FRAMESKIP_6    40356
 689.895 -#define ID_OPTIONS_VIDEO_FRAMESKIP_7    40357
 689.896 -#define ID_OPTIONS_VIDEO_FRAMESKIP_8    40358
 689.897 -#define ID_OPTIONS_VIDEO_FRAMESKIP_9    40359
 689.898 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE 40364
 689.899 -#define ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE 40365
 689.900 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_A    40366
 689.901 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_B    40367
 689.902 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_L    40368
 689.903 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_R    40369
 689.904 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_START 40370
 689.905 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT 40371
 689.906 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_UP   40372
 689.907 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN 40373
 689.908 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT 40374
 689.909 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT 40375
 689.910 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR 40376
 689.911 -#define ID_OPTIONS_SOUND_MUTEFRAMEADVANCE 40378
 689.912 -#define ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT 40382
 689.913 -#define ID_MOVIE_READONLY               40385
 689.914 -#define ID_MOVIE_RESTART_PLAY           40387
 689.915 -#define ID_MOVIE_RESUME_RECORD          40388
 689.916 -#define ID_FILE_LOADGAME_AUTOLOADMOSTRECENT 40393
 689.917 -#define ID_EMULATOR_GBALAG              40394
 689.918 -#define ID_EMULATOR_USE_OLD_FRAME_TIMING 40395
 689.919 -#define ID_EMULATOR_USE_GB_INPUT_KLUDGE 40396
 689.920 -#define ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS 40397
 689.921 -#define ID_STICKY_A                     40399
 689.922 -#define ID_STICKY_B                     40400
 689.923 -#define ID_STICKY_R                     40402
 689.924 -#define ID_STICKY_START                 40403
 689.925 -#define ID_STICKY_SELECT                40404
 689.926 -#define ID_STICKY_UP                    40405
 689.927 -#define ID_STICKY_DOWN                  40406
 689.928 -#define ID_STICKY_LEFT                  40407
 689.929 -#define ID_STICKY_RIGHT                 40408
 689.930 -#define ID_STICKY_L                     40410
 689.931 -#define ID_STICKY_CLEAR                 40412
 689.932 -#define ID_FILE_SAVEGAME_DECREMENTSLOT  40416
 689.933 -#define ID_FILE_LOADGAME_MOSTRECENT     40420
 689.934 -#define ID_FILE_LOADGAME_CURRENT        40423
 689.935 -#define ID_FILE_LOADGAME_MAKECURRENT    40424
 689.936 -#define ID_FILE_SAVEGAME_CURRENT        40427
 689.937 -#define ID_FILE_SAVEGAME_MAKECURRENT    40428
 689.938 -#define ID_FILE_SAVEGAME_OLDESTSLOT     40429
 689.939 -#define ID_FILE_SAVEGAME_INCREMENTSLOT  40430
 689.940 -#define ID_FILE_LOADGAME_MAKERECENT     40431
 689.941 -#define ID_DEBUG_FRAMESEARCH            40432
 689.942 -#define ID_DEBUG_FRAMESEARCHLOAD        40438
 689.943 -#define ID_DEBUG_FRAMESEARCHPREV        40439
 689.944 -#define ID_SELECT_SLOT1                 40440
 689.945 -#define ID_SELECT_SLOT2                 40441
 689.946 -#define ID_SELECT_SLOT3                 40442
 689.947 -#define ID_SELECT_SLOT4                 40443
 689.948 -#define ID_SELECT_SLOT5                 40444
 689.949 -#define ID_SELECT_SLOT6                 40445
 689.950 -#define ID_SELECT_SLOT7                 40446
 689.951 -#define ID_SELECT_SLOT8                 40447
 689.952 -#define ID_SELECT_SLOT9                 40448
 689.953 -#define ID_SELECT_SLOT10                40449
 689.954 -#define ID_TOOLS_DEBUG                  40450
 689.955 -#define ID_TOOLS_CUSTOMIZE              40452
 689.956 -#define ID_OPTIONS_SPEED                40453
 689.957 -#define ID_SPEED_BLA                    40454
 689.958 -#define ID_SPEED_FRAMESKIP              40455
 689.959 -#define ID_FRAMESKIP_BLA                40456
 689.960 -#define ID_SPEED_SETSPEED               40457
 689.961 -#define ID_SETSPEED_BLA                 40458
 689.962 -#define ID_SOUND_SOUNDCHANNELS          40459
 689.963 -#define ID_CHEATS_PAUSEDURINGCHEATSEARCH 40463
 689.964 -#define ID_TOOLS_LAGCOUNTER             40464
 689.965 -#define ID_FILE_LUA_OPEN                40467
 689.966 -#define ID_FILE_LUA_RELOAD              40468
 689.967 -#define ID_FILE_LUA_CLOSE_ALL           40469
 689.968 -#define ID_TOOLS_LAGCOUNTER_RESET       40470
 689.969 -#define ID_FILE_QUICKSCREENCAPTURE      40471
 689.970 -#define ID_MOVIE_END_EXIT               40480
 689.971 -#define ID_MOVIE_END_RESET              40481
 689.972 -#define ID_MOVIE_END_CLOSE              40482
 689.973 -#define ID_MOVIE_END_OPENGBA            40483
 689.974 -#define ID_MOVIE_END_OPENGBX            40484
 689.975 -#define ID_MOVIE_END_LOADGAME           40485
 689.976 -#define ID_MOVIE_END_SAVEGAME           40486
 689.977 -#define ID_MOVIE_END_PAUSE              40487
 689.978 -#define ID_MOVIE_END_RESTART            40488
 689.979 -#define ID_MOVIE_END_APPEND             40489
 689.980 -#define ID_MOVIE_END_STOP               40490
 689.981 -#define ID_MOVIE_END_KEEP               40491
 689.982 -#define ID_MOVIE_END_PLAY               40492
 689.983 -#define ID_MOVIE_END_NEW                40493
 689.984 -#define ID_MOVIE_TOOL_CONVERT           40501
 689.985 -#define ID_MOVIE_TOOL_TRUNCATE          40504
 689.986 -#define ID_MOVIE_TOOL_FIX_HEADER        40507
 689.987 -#define ID_MOVIE_TOOL_SET_PAUSE_AT      40510
 689.988 -#define ID_RAM_SEARCH                   40522
 689.989 -#define ID_RAM_WATCH                    40523
 689.990 -#define ID_MOVIE_TOOL_AUTO_CONVERT      40541
 689.991 -#define ID_MOVIE_TOOL_EXTRACT_FROM_SAVEGAME 40560
 689.992 -#define ID_MOVIE_TOOL_CONVERT_FILE          40561
 689.993 -#define RAMMENU_FILE_RECENT             40653
 689.994 -#define ID_WATCHES_MOVEUP               40664
 689.995 -#define ID_WATCHES_MOVEDOWN             40665
 689.996 -#define ID_WATCHES_EDITWATCH            40666
 689.997 -#define ID_WATCHES_REMOVEWATCH          40667
 689.998 -#define ID_WATCHES_NEWWATCH             40668
 689.999 -#define ID_WATCHES_DUPLICATEWATCH       40669
689.1000 -#define ID_WATCHES_UPDOWN               40670
689.1001 -#define ID_FILE_LUA_STOP                40671
689.1002 -#define IDC_EDIT_COMPAREVALUE           41090
689.1003 -#define IDC_EDIT_COMPAREADDRESS         41091
689.1004 -#define IDC_EDIT_COMPARECHANGES         41092
689.1005 -#define IDC_EDIT_DIFFBY                 41093
689.1006 -#define IDC_C_AUTOSEARCH                41094
689.1007 -#define IDC_EDIT_MODBY                  41095
689.1008 -#define IDC_RAMLIST                     41133
689.1009 -#define IDC_C_SEARCH                    41134
689.1010 -#define IDC_C_ADDCHEAT                  41135
689.1011 -#define IDC_C_RESET                     41136
689.1012 -#define IDC_1_BYTE                      41137
689.1013 -#define IDC_2_BYTES                     41138
689.1014 -#define IDC_C_WATCH                     41139
689.1015 -#define IDC_4_BYTES                     41140
689.1016 -#define IDC_LESSTHAN                    41141
689.1017 -#define IDC_MORETHAN                    41142
689.1018 -#define IDC_NOMORETHAN                  41143
689.1019 -#define IDC_NOLESSTHAN                  41144
689.1020 -#define IDC_EQUALTO                     41145
689.1021 -#define IDC_DIFFERENTFROM               41146
689.1022 -#define IDC_DIFFERENTBY                 41147
689.1023 -#define IDC_MODULO                      41148
689.1024 -#define IDC_HEX                         41151
689.1025 -#define IDC_C_UNDO                      41152
689.1026 -#define IDC_C_RESET_CHANGES             41153
689.1027 -#define IDC_PREVIOUSVALUE               42147
689.1028 -#define IDC_SPECIFICVALUE               42148
689.1029 -#define IDC_CHEATEDITVALUE              42156
689.1030 -#define IDC_SPECIFICADDRESS             42157
689.1031 -#define IDC_NUMBEROFCHANGES             42158
689.1032 -#define IDC_MISALIGN                    42159
689.1033 -#define IDC_WATCHLIST                   42171
689.1034 -#define IDC_C_ELIMINATE                 42174
689.1035 -#define RAMMENU_FILE_AUTOLOAD           42300
689.1036 -#define RAMMENU_FILE_APPEND             42301
689.1037 -#define RAMMENU_FILE_SAVEWINDOW         42302
689.1038 -#define RAMMENU_FILE_NEW                42303
689.1039 -#define RAMMENU_FILE_OPEN               42304
689.1040 -#define RAMMENU_FILE_SAVE               42305
689.1041 -#define RAMMENU_FILE_SAVEAS             42306
689.1042 -#define RW_MENU_FIRST_RECENT_FILE       42350
689.1043 -#define RW_MENU_LAST_RECENT_FILE        42370
689.1044 -#define ID_OPTIONS_PREFER_ARCHIVE_NAME  42400
689.1045 -#define ID_OPTIONS_PREFER_ROM_NAME      42401
689.1046 -#define ID_OPTIONS_EMULATOR_ALWAYSONTOP 42402
689.1047 -#define ID_OPTIONS_EMULATOR_BACKGROUNDINPUT 42403
689.1048 -#define ID_OPTIONS_SOUND_MUTEWHENINACTIVE 42404
689.1049 -#define ID_FILE_SLOT_DISPLAYMODIFICATIONTIME 42405
689.1050 -#define ID_TOOLS_PAUSEAVIRECORDING      42406
689.1051 -#define ID_AUTO_TAKELAGINTOACCOUNT      42407
689.1052 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG 42408
689.1053 -#define ID_FILE_FRAMEADVANCESETTINGS    42409
689.1054 -#define ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG 42410
689.1055 -#define ID_MOVIE_ASSOCIATEMOVIESWITHSAVESTATES 42411
689.1056 -#define ID_MOVIE_ASSC_WITH_SAVESTATE    42412
689.1057 -#define ID_TOOLS_EXTRACOUNTER           42413
689.1058 -#define ID_HEAD_EXTRACOUNTERRESET       42414
689.1059 -#define ID_TOOLS_EXTRACOUNTERRESET      42415
689.1060 -#define IDC_C_WATCH_DOWN                43400
689.1061 -#define IDC_C_WATCH_DUPLICATE           43401
689.1062 -#define IDC_C_WATCH_EDIT                43402
689.1063 -#define IDC_C_WATCH_REMOVE              43403
689.1064 -#define IDC_C_WATCH_UP                  43404
689.1065 -#define IDC_PROMPT_TEXT                 44000
689.1066 -#define IDC_PROMPT_TEXT2                44001
689.1067 -#define IDC_PROMPT_EDIT                 44005
689.1068 -#define IDC_C_WATCH_SEPARATE            55555
689.1069 -
689.1070 -// Next default values for new objects
689.1071 -// 
689.1072 -#ifdef APSTUDIO_INVOKED
689.1073 -#ifndef APSTUDIO_READONLY_SYMBOLS
689.1074 -#define _APS_NEXT_RESOURCE_VALUE        171
689.1075 -#define _APS_NEXT_COMMAND_VALUE         42416
689.1076 -#define _APS_NEXT_CONTROL_VALUE         1376
689.1077 -#define _APS_NEXT_SYMED_VALUE           103
689.1078 -#endif
689.1079 -#endif
   690.1 --- a/src/win32/stdafx.cpp	Sat Mar 03 10:54:39 2012 -0600
   690.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   690.3 @@ -1,8 +0,0 @@
   690.4 -// stdafx.cpp : source file that includes just the standard includes
   690.5 -//      DialogSizer.pch will be the pre-compiled header
   690.6 -//      stdafx.obj will contain the pre-compiled type information
   690.7 -
   690.8 -#include "stdafx.h"
   690.9 -
  690.10 -// TODO: reference any additional headers you need in STDAFX.H
  690.11 -// and not in this file
   691.1 --- a/src/win32/stdafx.h	Sat Mar 03 10:54:39 2012 -0600
   691.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   691.3 @@ -1,47 +0,0 @@
   691.4 -// stdafx.h : include file for standard system include files,
   691.5 -//  or project specific include files that are used frequently, but
   691.6 -//      are changed infrequently
   691.7 -//
   691.8 -
   691.9 -// some build target defines:
  691.10 -
  691.11 -#ifndef _WIN32_WINDOWS
  691.12 -///#	define _WIN32_WINDOWS 0x0410 // Windows 98 +
  691.13 -#   define _WIN32_WINDOWS 0x0500 // Windows NT +
  691.14 -///#	define _WIN32_WINDOWS 0x0501 // Windows XP +
  691.15 -#endif
  691.16 -
  691.17 -#ifndef _WIN32_WINNT
  691.18 -///#	define _WIN32_WINNT 0x0410 // Windows 98 +
  691.19 -#   define _WIN32_WINNT 0x0500 // Windows NT +
  691.20 -///#	define _WIN32_WINNT 0x0501 // Windows XP +
  691.21 -#endif
  691.22 -
  691.23 -#ifndef WINVER
  691.24 -///#	define WINVER 0x0410 // Windows 98 +
  691.25 -#   define WINVER 0x0500 // Windows NT +
  691.26 -///#	define WINVER 0x0501 // Windows XP +
  691.27 -#endif
  691.28 -
  691.29 -#if !defined(AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_)
  691.30 -#define AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_
  691.31 -
  691.32 -#if _MSC_VER > 1000
  691.33 -#pragma once
  691.34 -#endif // _MSC_VER > 1000
  691.35 -
  691.36 -// Insert your headers here
  691.37 -//#define WIN32_LEAN_AND_MEAN           // Exclude rarely-used stuff from Windows headers
  691.38 -
  691.39 -#include <afxwin.h>
  691.40 -#include <afxcmn.h>
  691.41 -#include <afxdlgs.h>
  691.42 -
  691.43 -#include "../Port.h"
  691.44 -
  691.45 -// TODO: reference additional headers your program requires here
  691.46 -
  691.47 -//{{AFX_INSERT_LOCATION}}
  691.48 -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  691.49 -
  691.50 -#endif // !defined(AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_)
   692.1 --- a/src/win32/vba.rc	Sat Mar 03 10:54:39 2012 -0600
   692.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   692.3 @@ -1,2664 +0,0 @@
   692.4 -// Microsoft Visual C++ generated resource script.
   692.5 -//
   692.6 -#include "resource.h"
   692.7 -
   692.8 -#define APSTUDIO_READONLY_SYMBOLS
   692.9 -/////////////////////////////////////////////////////////////////////////////
  692.10 -//
  692.11 -// Generated from the TEXTINCLUDE 2 resource.
  692.12 -//
  692.13 -#include "afxres.h"
  692.14 -#include "vba.rc2"
  692.15 -/////////////////////////////////////////////////////////////////////////////
  692.16 -#undef APSTUDIO_READONLY_SYMBOLS
  692.17 -
  692.18 -/////////////////////////////////////////////////////////////////////////////
  692.19 -// English (United States) resources
  692.20 -
  692.21 -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
  692.22 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
  692.23 -#pragma code_page(1252)
  692.24 -
  692.25 -/////////////////////////////////////////////////////////////////////////////
  692.26 -//
  692.27 -// Version
  692.28 -//
  692.29 -
  692.30 -#include "VersionInfo.h"
  692.31 -VS_VERSION_INFO VERSIONINFO
  692.32 - FILEVERSION    VBA_VERSIONINFO_FILEVER
  692.33 - PRODUCTVERSION VBA_VERSIONINFO_PRODUCTVER
  692.34 - FILEFLAGSMASK  0x3fL
  692.35 - FILEFLAGS      VBA_VERSIONINFO_FILEFLAGS
  692.36 - FILEOS         0x40004L
  692.37 - FILETYPE       0x1L
  692.38 - FILESUBTYPE    0x0L
  692.39 -BEGIN
  692.40 -    BLOCK "StringFileInfo"
  692.41 -    BEGIN
  692.42 -        BLOCK "040904b0"
  692.43 -        BEGIN
  692.44 -            VALUE "Comments", "VBA-RR comes with NO WARRANTY. Use it at your own risk."
  692.45 -            VALUE "CompanyName", VBA_VERSIONINFO_ORGANIZATION
  692.46 -            VALUE "FileDescription", "VisualBoyAdvance-ReRecording Emulator"
  692.47 -            VALUE "FileVersion", VBA_VERSIONINFO_STRFILEVER
  692.48 -            VALUE "InternalName", "VBA-RR"
  692.49 -            VALUE "LegalCopyright", VBA_VERSIONINFO_STRCOPYRIGHT
  692.50 -            VALUE "OriginalFilename", "VisualBoyAdvance.exe"
  692.51 -            VALUE "ProductName", "GB/C/A emulator for Windows"
  692.52 -            VALUE "ProductVersion", VBA_VERSIONINFO_STRPRODUCTVER
  692.53 -            VALUE "PrivateBuild", "0"
  692.54 -            VALUE "SpecialBuild", "0"
  692.55 -        END
  692.56 -    END
  692.57 -    BLOCK "VarFileInfo"
  692.58 -    BEGIN
  692.59 -        VALUE "Translation", 0x409, 1200
  692.60 -    END
  692.61 -END
  692.62 -
  692.63 -
  692.64 -#ifdef APSTUDIO_INVOKED
  692.65 -/////////////////////////////////////////////////////////////////////////////
  692.66 -//
  692.67 -// TEXTINCLUDE
  692.68 -//
  692.69 -
  692.70 -1 TEXTINCLUDE 
  692.71 -BEGIN
  692.72 -    "resource.h\0"
  692.73 -END
  692.74 -
  692.75 -2 TEXTINCLUDE 
  692.76 -BEGIN
  692.77 -    "#include ""afxres.h""\r\n"
  692.78 -    "#include ""vba.rc2""\0"
  692.79 -END
  692.80 -
  692.81 -3 TEXTINCLUDE 
  692.82 -BEGIN
  692.83 -    "\r\n"
  692.84 -    "\0"
  692.85 -END
  692.86 -
  692.87 -#endif    // APSTUDIO_INVOKED
  692.88 -
  692.89 -
  692.90 -/////////////////////////////////////////////////////////////////////////////
  692.91 -//
  692.92 -// Icon
  692.93 -//
  692.94 -
  692.95 -// Icon with lowest ID value placed first to ensure application icon
  692.96 -// remains consistent on all systems.
  692.97 -IDI_ICON                ICON                    "gbadvance.ico"
  692.98 -
  692.99 -/////////////////////////////////////////////////////////////////////////////
 692.100 -//
 692.101 -// Dialog
 692.102 -//
 692.103 -
 692.104 -IDD_OPENDLG DIALOG 36, 24, 202, 117
 692.105 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.106 -CAPTION "Open"
 692.107 -FONT 8, "MS Shell Dlg"
 692.108 -BEGIN
 692.109 -    LTEXT           "File &name:",1090,2,1,81,8
 692.110 -    EDITTEXT        1152,0,10,104,12,ES_AUTOHSCROLL | ES_OEMCONVERT
 692.111 -    LISTBOX         1120,1,24,104,53,LBS_SORT | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
 692.112 -    LTEXT           "&Folders:",-1,112,0,53,9
 692.113 -    LTEXT           "",1088,113,10,86,9,SS_NOPREFIX
 692.114 -    LISTBOX         1121,112,24,88,52,LBS_SORT | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
 692.115 -    LTEXT           "List files of &type:",1089,1,75,81,9
 692.116 -    COMBOBOX        1136,1,87,104,13,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
 692.117 -    LTEXT           "Dri&ves:",1091,113,76,70,9
 692.118 -    COMBOBOX        1137,112,87,71,68,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
 692.119 -    DEFPUSHBUTTON   "OK",IDOK,24,102,50,14,WS_GROUP
 692.120 -    PUSHBUTTON      "Cancel",IDCANCEL,90,102,50,14,WS_GROUP
 692.121 -END
 692.122 -
 692.123 -IDD_ABOUT DIALOGEX 0, 0, 164, 101
 692.124 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.125 -CAPTION "About VBA rerecording"
 692.126 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.127 -BEGIN
 692.128 -    DEFPUSHBUTTON   "OK",IDOK,56,80,50,14
 692.129 -    ICON            IDI_ICON,IDC_STATIC,5,12,20,20
 692.130 -    CTEXT           "VisualBoyAdvance Emulator",IDC_STATIC,14,7,134,8
 692.131 -    CTEXT           "Copyright (c) 2004 Forgotten and the VBA team",IDC_STATIC,7,35,150,8
 692.132 -    CTEXT           "http://code.google.com/p/vba-rerecording/",IDC_URL,7,55,150,8
 692.133 -    CTEXT           "Contribution by Costis",IDC_STATIC,30,45,102,8
 692.134 -    CTEXT           "Version",IDC_STATIC,46,16,70,8
 692.135 -    CTEXT           "",IDC_VERSION,36,25,98,8
 692.136 -    CTEXT           "Re-recording additions by VBA-rr team",IDC_STATIC,14,66,136,8
 692.137 -END
 692.138 -
 692.139 -IDD_DIRECTORIES DIALOGEX 0, 0, 284, 260
 692.140 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.141 -CAPTION "Directories"
 692.142 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.143 -BEGIN
 692.144 -    LTEXT           "GBA ROM:",IDC_STATIC,7,9,40,8
 692.145 -    EDITTEXT        IDC_ROM_PATH,49,7,160,14,ES_AUTOHSCROLL
 692.146 -    PUSHBUTTON      "...",IDC_ROM_DIR,213,7,24,14
 692.147 -    PUSHBUTTON      "Reset",IDC_ROM_DIR_RESET,242,7,35,14
 692.148 -    LTEXT           "GBx ROM:",IDC_STATIC,7,28,40,8
 692.149 -    EDITTEXT        IDC_GBXROM_PATH,49,26,160,14,ES_AUTOHSCROLL
 692.150 -    PUSHBUTTON      "...",IDC_GBXROM_DIR,213,26,24,14
 692.151 -    PUSHBUTTON      "Reset",IDC_GBXROM_DIR_RESET,242,26,35,14
 692.152 -    LTEXT           "Battery:",IDC_STATIC,7,47,40,8
 692.153 -    EDITTEXT        IDC_BATTERY_PATH,49,45,160,14,ES_AUTOHSCROLL
 692.154 -    PUSHBUTTON      "...",IDC_BATTERY_DIR,213,45,24,14
 692.155 -    PUSHBUTTON      "Reset",IDC_BATTERY_DIR_RESET,242,45,35,14
 692.156 -    LTEXT           "Save Game:",IDC_STATIC,7,66,40,8
 692.157 -    EDITTEXT        IDC_SAVE_PATH,49,64,160,14,ES_AUTOHSCROLL
 692.158 -    PUSHBUTTON      "...",IDC_SAVE_DIR,213,64,24,14
 692.159 -    PUSHBUTTON      "Reset",IDC_SAVE_DIR_RESET,242,64,35,14
 692.160 -    LTEXT           "Movies:",IDC_STATIC,7,85,40,8
 692.161 -    EDITTEXT        IDC_MOVIE_PATH,49,83,160,14,ES_AUTOHSCROLL
 692.162 -    PUSHBUTTON      "...",IDC_MOVIE_DIR,213,83,24,14
 692.163 -    PUSHBUTTON      "Reset",IDC_MOVIE_DIR_RESET,242,83,35,14
 692.164 -    LTEXT           "Cheats:",IDC_STATIC,7,104,40,8
 692.165 -    EDITTEXT        IDC_CHEAT_PATH,49,102,160,14,ES_AUTOHSCROLL
 692.166 -    PUSHBUTTON      "...",IDC_CHEAT_DIR,213,102,24,14
 692.167 -    PUSHBUTTON      "Reset",IDC_CHEAT_DIR_RESET,242,102,35,14
 692.168 -    LTEXT           "IPS:",IDC_STATIC,7,123,40,8
 692.169 -    EDITTEXT        IDC_IPS_PATH,49,121,160,14,ES_AUTOHSCROLL
 692.170 -    PUSHBUTTON      "...",IDC_IPS_DIR,213,121,24,14
 692.171 -    PUSHBUTTON      "Reset",IDC_IPS_DIR_RESET,242,121,35,14
 692.172 -    LTEXT           "Lua:",IDC_STATIC,7,142,40,8
 692.173 -    EDITTEXT        IDC_LUA_PATH,49,140,160,14,ES_AUTOHSCROLL
 692.174 -    PUSHBUTTON      "...",IDC_LUA_DIR,213,140,24,14
 692.175 -    PUSHBUTTON      "Reset",IDC_LUA_DIR_RESET,242,140,35,14
 692.176 -    LTEXT           "AVI:",IDC_STATIC,7,161,40,8
 692.177 -    EDITTEXT        IDC_AVI_PATH,49,159,160,14,ES_AUTOHSCROLL
 692.178 -    PUSHBUTTON      "...",IDC_AVI_DIR,213,159,24,14
 692.179 -    PUSHBUTTON      "Reset",IDC_AVI_DIR_RESET,242,159,35,14
 692.180 -    LTEXT           "WAV:",IDC_STATIC,7,180,40,8
 692.181 -    EDITTEXT        IDC_WAV_PATH,49,178,160,14,ES_AUTOHSCROLL
 692.182 -    PUSHBUTTON      "...",IDC_WAV_DIR,213,178,24,14
 692.183 -    PUSHBUTTON      "Reset",IDC_WAV_DIR_RESET,242,178,35,14
 692.184 -    LTEXT           "Capture:",IDC_STATIC,7,199,40,8
 692.185 -    EDITTEXT        IDC_CAPTURE_PATH,49,197,160,14,ES_AUTOHSCROLL
 692.186 -    PUSHBUTTON      "...",IDC_CAPTURE_DIR,213,197,23,14
 692.187 -    PUSHBUTTON      "Reset",IDC_CAPTURE_DIR_RESET,242,197,35,14
 692.188 -    LTEXT           "Watch:",IDC_STATIC,7,218,40,8
 692.189 -    EDITTEXT        IDC_WATCH_PATH,49,216,160,14,ES_AUTOHSCROLL
 692.190 -    PUSHBUTTON      "...",IDC_WATCH_DIR,213,216,23,14
 692.191 -    PUSHBUTTON      "Reset",IDC_WATCH_DIR_RESET,242,216,35,14
 692.192 -    DEFPUSHBUTTON   "OK",IDOK,88,236,50,16
 692.193 -    PUSHBUTTON      "Cancel",IDCANCEL,145,236,50,16
 692.194 -END
 692.195 -
 692.196 -IDD_CONFIG DIALOGEX 0, 0, 135, 211
 692.197 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.198 -CAPTION "Joypad setup"
 692.199 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.200 -BEGIN
 692.201 -    EDITTEXT        IDC_EDIT_UP,47,5,81,12,ES_AUTOHSCROLL
 692.202 -    EDITTEXT        IDC_EDIT_DOWN,47,19,81,12,ES_AUTOHSCROLL
 692.203 -    EDITTEXT        IDC_EDIT_LEFT,47,33,81,12,ES_AUTOHSCROLL
 692.204 -    EDITTEXT        IDC_EDIT_RIGHT,47,47,81,12,ES_AUTOHSCROLL
 692.205 -    EDITTEXT        IDC_EDIT_BUTTON_A,47,61,81,12,ES_AUTOHSCROLL
 692.206 -    EDITTEXT        IDC_EDIT_BUTTON_B,47,75,81,12,ES_AUTOHSCROLL
 692.207 -    EDITTEXT        IDC_EDIT_BUTTON_L,47,89,81,12,ES_AUTOHSCROLL
 692.208 -    EDITTEXT        IDC_EDIT_BUTTON_R,47,103,81,12,ES_AUTOHSCROLL
 692.209 -    EDITTEXT        IDC_EDIT_BUTTON_SELECT,47,117,81,12,ES_AUTOHSCROLL
 692.210 -    EDITTEXT        IDC_EDIT_BUTTON_START,47,131,81,12,ES_AUTOHSCROLL
 692.211 -    EDITTEXT        IDC_EDIT_SPEED,47,145,81,12,ES_AUTOHSCROLL
 692.212 -    EDITTEXT        IDC_EDIT_CAPTURE,47,159,81,12,ES_AUTOHSCROLL
 692.213 -    EDITTEXT        IDC_EDIT_BUTTON_GS,47,173,81,12,ES_AUTOHSCROLL
 692.214 -    PUSHBUTTON      "OK",ID_OK,20,190,40,14
 692.215 -    PUSHBUTTON      "Cancel",ID_CANCEL,74,190,40,14
 692.216 -    LTEXT           "Up:",IDC_STATIC,5,5,35,10
 692.217 -    LTEXT           "Down:",IDC_STATIC,5,19,35,10
 692.218 -    LTEXT           "Left:",IDC_STATIC,5,33,35,10
 692.219 -    LTEXT           "Right:",IDC_STATIC,5,47,35,10
 692.220 -    LTEXT           "Button A:",IDC_STATIC,5,61,40,10
 692.221 -    LTEXT           "Button B:",IDC_STATIC,5,75,40,10
 692.222 -    LTEXT           "Button L:",IDC_STATIC,5,89,40,10
 692.223 -    LTEXT           "Button R:",IDC_STATIC,5,103,40,10
 692.224 -    LTEXT           "Select:",IDC_STATIC,5,117,40,10
 692.225 -    LTEXT           "Start:",IDC_STATIC,5,131,40,10
 692.226 -    LTEXT           "Speed:",IDC_STATIC,5,145,40,10
 692.227 -    LTEXT           "Capture:",IDC_STATIC,5,159,40,10
 692.228 -    LTEXT           "GameShark:",IDC_STATIC,5,173,40,10
 692.229 -END
 692.230 -
 692.231 -IDD_CHEATS DIALOGEX 0, 0, 276, 253
 692.232 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 692.233 -CAPTION "Search for cheats"
 692.234 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.235 -BEGIN
 692.236 -    CONTROL         "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,3,5,265,111
 692.237 -    CONTROL         "Ol&d value",IDC_OLD_VALUE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,11,129,46,10
 692.238 -    CONTROL         "Specifi&c value",IDC_SPECIFIC_VALUE,"Button",BS_AUTORADIOBUTTON,11,141,61,10
 692.239 -    CONTROL         "&8 bits",IDC_SIZE_8,"Button",BS_AUTORADIOBUTTON | WS_GROUP,11,167,33,10
 692.240 -    CONTROL         "&16 bits",IDC_SIZE_16,"Button",BS_AUTORADIOBUTTON,11,179,37,10
 692.241 -    CONTROL         "&32 bits",IDC_SIZE_32,"Button",BS_AUTORADIOBUTTON,11,191,37,10
 692.242 -    CONTROL         "&Equal",IDC_EQ,"Button",BS_AUTORADIOBUTTON | WS_GROUP,100,128,34,10
 692.243 -    CONTROL         "&Not equal",IDC_NE,"Button",BS_AUTORADIOBUTTON,100,140,47,10
 692.244 -    CONTROL         "&Less than",IDC_LT,"Button",BS_AUTORADIOBUTTON,100,152,47,10
 692.245 -    CONTROL         "Le&ss or equal",IDC_LE,"Button",BS_AUTORADIOBUTTON,100,164,58,10
 692.246 -    CONTROL         "&Greater than",IDC_GT,"Button",BS_AUTORADIOBUTTON,100,176,59,10
 692.247 -    CONTROL         "G&reater or equal",IDC_GE,"Button",BS_AUTORADIOBUTTON,100,188,67,10
 692.248 -    CONTROL         "S&igned",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,202,130,38,10
 692.249 -    CONTROL         "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,202,142,46,10
 692.250 -    CONTROL         "&Hexadecimal",IDC_HEXADECIMAL,"Button",BS_AUTORADIOBUTTON,202,154,57,10
 692.251 -    CONTROL         "search u&pdates vals",IDC_UPDATE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,192,192,76,10
 692.252 -    EDITTEXT        IDC_VALUE,95,211,172,14,ES_AUTOHSCROLL
 692.253 -    PUSHBUTTON      "&Start",IDC_START,15,237,50,14,WS_GROUP
 692.254 -    PUSHBUTTON      "S&earch",IDC_SEARCH,80,236,50,14
 692.255 -    PUSHBUTTON      "&Add cheat",IDC_ADD_CHEAT,145,236,50,14
 692.256 -    DEFPUSHBUTTON   "OK",ID_OK,210,236,50,14
 692.257 -    GROUPBOX        "&Search type",IDC_STATIC,3,118,84,36
 692.258 -    GROUPBOX        "&Data size",IDC_STATIC,3,158,84,44
 692.259 -    GROUPBOX        "Compare type",IDC_STATIC,95,118,92,84
 692.260 -    GROUPBOX        "Signed/Unsigned",IDC_STATIC,192,118,76,50
 692.261 -    LTEXT           "Enter &value:",IDC_STATIC,3,214,69,8
 692.262 -    PUSHBUTTON      "Refresh New &Values",IDC_CHEATREFRESHBUTTON,192,172,75,14,NOT WS_VISIBLE
 692.263 -END
 692.264 -
 692.265 -IDD_ADD_CHEAT DIALOG 0, 0, 186, 137
 692.266 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.267 -CAPTION "Add cheat"
 692.268 -FONT 8, "MS Sans Serif"
 692.269 -BEGIN
 692.270 -    EDITTEXT        IDC_ADDRESS,60,6,123,14,ES_AUTOHSCROLL
 692.271 -    EDITTEXT        IDC_VALUE,60,24,123,14,ES_AUTOHSCROLL
 692.272 -    EDITTEXT        IDC_DESC,60,42,123,14,ES_AUTOHSCROLL
 692.273 -    CONTROL         "8-bit",IDC_SIZE_8,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,11,70,29,10
 692.274 -    CONTROL         "16-bit",IDC_SIZE_16,"Button",BS_AUTORADIOBUTTON,62,70,33,10
 692.275 -    CONTROL         "32-bit",IDC_SIZE_32,"Button",BS_AUTORADIOBUTTON,117,70,33,10
 692.276 -    CONTROL         "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,11,97,38,10
 692.277 -    CONTROL         "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,62,98,46,10
 692.278 -    CONTROL         "&Hexadecimal",IDC_HEXADECIMAL,"Button",BS_AUTORADIOBUTTON,117,98,57,10
 692.279 -    DEFPUSHBUTTON   "&OK",ID_OK,36,116,50,14,WS_GROUP
 692.280 -    PUSHBUTTON      "&Cancel",ID_CANCEL,99,116,50,14
 692.281 -    LTEXT           "&Value:",IDC_STATIC,3,27,54,8
 692.282 -    GROUPBOX        "Number format",IDC_STATIC,3,88,180,24
 692.283 -    LTEXT           "&Address:",IDC_STATIC,3,9,54,8
 692.284 -    GROUPBOX        "Size",IDC_STATIC,3,60,180,24
 692.285 -    LTEXT           "&Description:",IDC_STATIC,3,45,55,8
 692.286 -END
 692.287 -
 692.288 -IDD_CHEAT_LIST DIALOG 0, 0, 280, 250
 692.289 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.290 -CAPTION "Cheat list"
 692.291 -FONT 8, "MS Sans Serif"
 692.292 -BEGIN
 692.293 -    CONTROL         "Restore &previous values",IDC_RESTORE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,5,183,92,10
 692.294 -    PUSHBUTTON      "&Code...",IDC_ADD_CODE,9,208,64,14,WS_GROUP
 692.295 -    PUSHBUTTON      "C&heat...",IDC_ADD_CHEAT,75,208,64,14
 692.296 -    PUSHBUTTON      "&Gameshark...",IDC_ADD_GAMESHARK,141,208,64,14
 692.297 -    PUSHBUTTON      "CodeBreaker...",IDC_ADD_CODEBREAKER,206,208,64,14
 692.298 -    PUSHBUTTON      "&Remove",IDC_REMOVE,9,230,64,14
 692.299 -    PUSHBUTTON      "Remove A&ll",IDC_REMOVE_ALL,75,230,64,14
 692.300 -    PUSHBUTTON      "&Enable/Dis.",IDC_ENABLE,141,230,64,14
 692.301 -    DEFPUSHBUTTON   "&OK",ID_OK,206,230,64,14,WS_GROUP
 692.302 -    CONTROL         "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,15,269,156
 692.303 -    LTEXT           "Status legend:",IDC_STATIC,6,3,46,8
 692.304 -    LTEXT           "E: Enabled",IDC_STATIC,188,3,36,8
 692.305 -    LTEXT           "D: Disabled",IDC_STATIC,234,3,38,8
 692.306 -    GROUPBOX        "Add",IDC_STATIC,5,199,268,27
 692.307 -END
 692.308 -
 692.309 -IDD_ASSOCIATIONS DIALOG 0, 0, 116, 95
 692.310 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.311 -CAPTION "Associations"
 692.312 -FONT 8, "MS Sans Serif"
 692.313 -BEGIN
 692.314 -    CONTROL         ".gb",IDC_GB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,15,26,10
 692.315 -    CONTROL         ".sgb",IDC_SGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,29,29,10
 692.316 -    CONTROL         ".cgb",IDC_CGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,43,30,10
 692.317 -    CONTROL         ".gbc",IDC_GBC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,57,30,10
 692.318 -    CONTROL         ".gba",IDC_GBA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75,13,30,10
 692.319 -    CONTROL         ".agb",IDC_AGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75,27,30,10
 692.320 -    CONTROL         ".bin",IDC_BIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75,41,27,10
 692.321 -    DEFPUSHBUTTON   "OK",ID_OK,3,78,50,14
 692.322 -    PUSHBUTTON      "Cancel",ID_CANCEL,63,78,50,14
 692.323 -    GROUPBOX        "GBA Types",IDC_STATIC,63,3,50,51
 692.324 -    GROUPBOX        "GB Types",IDC_STATIC,3,3,50,69
 692.325 -END
 692.326 -
 692.327 -IDD_GBA_ROM_INFO DIALOG 0, 0, 220, 142
 692.328 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.329 -CAPTION "Rom information"
 692.330 -FONT 8, "MS Sans Serif"
 692.331 -BEGIN
 692.332 -    DEFPUSHBUTTON   "OK",ID_OK,84,121,50,14
 692.333 -    LTEXT           "Game title:",IDC_STATIC,7,10,60,8
 692.334 -    LTEXT           "Game code:",IDC_STATIC,7,24,60,8
 692.335 -    LTEXT           "Maker code:",IDC_STATIC,7,38,60,8
 692.336 -    LTEXT           "Main unit code:",IDC_STATIC,7,66,60,8
 692.337 -    LTEXT           "Device type:",IDC_STATIC,7,80,60,8
 692.338 -    LTEXT           "ROM version:",IDC_STATIC,7,94,60,8
 692.339 -    LTEXT           "CRC:",IDC_STATIC,7,108,60,8
 692.340 -    LTEXT           "",IDC_ROM_TITLE,80,10,133,8
 692.341 -    LTEXT           "",IDC_ROM_GAME_CODE,80,24,133,8
 692.342 -    LTEXT           "",IDC_ROM_MAKER_CODE,80,38,133,8
 692.343 -    LTEXT           "",IDC_ROM_UNIT_CODE,80,66,133,8
 692.344 -    LTEXT           "",IDC_ROM_DEVICE_TYPE,80,80,133,8
 692.345 -    LTEXT           "",IDC_ROM_VERSION,80,94,133,8
 692.346 -    LTEXT           "",IDC_ROM_CRC,80,108,133,8
 692.347 -    LTEXT           "",IDC_ROM_MAKER_NAME,80,52,133,8
 692.348 -    LTEXT           "Maker name:",IDC_STATIC,7,52,60,8
 692.349 -END
 692.350 -
 692.351 -IDD_GB_ROM_INFO DIALOG 0, 0, 220, 225
 692.352 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.353 -CAPTION "Rom information"
 692.354 -FONT 8, "MS Sans Serif"
 692.355 -BEGIN
 692.356 -    DEFPUSHBUTTON   "OK",ID_OK,84,200,50,14
 692.357 -    LTEXT           "Game title:",IDC_STATIC,7,10,60,8
 692.358 -    LTEXT           "Maker code:",IDC_STATIC,7,38,60,8
 692.359 -    LTEXT           "Unit code:",IDC_STATIC,7,68,60,8
 692.360 -    LTEXT           "Cartridge type:",IDC_STATIC,7,82,60,8
 692.361 -    LTEXT           "ROM version:",IDC_STATIC,7,152,60,8
 692.362 -    LTEXT           "CRC:",IDC_STATIC,7,166,60,8
 692.363 -    LTEXT           "",IDC_ROM_TITLE,80,10,133,8
 692.364 -    LTEXT           "",IDC_ROM_MAKER_CODE,80,38,133,8
 692.365 -    LTEXT           "",IDC_ROM_UNIT_CODE,80,68,133,8
 692.366 -    LTEXT           "",IDC_ROM_DEVICE_TYPE,80,82,133,8
 692.367 -    LTEXT           "",IDC_ROM_VERSION,80,152,133,8
 692.368 -    LTEXT           "",IDC_ROM_CRC,80,166,133,8
 692.369 -    LTEXT           "Color:",IDC_STATIC,7,24,60,8
 692.370 -    LTEXT           "",IDC_ROM_COLOR,80,24,133,8
 692.371 -    LTEXT           "ROM size:",IDC_STATIC,7,96,60,8
 692.372 -    LTEXT           "",IDC_ROM_SIZE,80,96,133,8
 692.373 -    LTEXT           "RAM size:",IDC_STATIC,7,110,60,8
 692.374 -    LTEXT           "",IDC_ROM_RAM_SIZE,80,110,133,8
 692.375 -    LTEXT           "Dest. code:",IDC_STATIC,7,124,60,8
 692.376 -    LTEXT           "",IDC_ROM_DEST_CODE,80,124,133,8
 692.377 -    LTEXT           "License code:",IDC_STATIC,7,138,60,8
 692.378 -    LTEXT           "",IDC_ROM_LIC_CODE,80,138,133,8
 692.379 -    LTEXT           "Checksum:",IDC_STATIC,7,180,60,8
 692.380 -    LTEXT           "",IDC_ROM_CHECKSUM,80,180,133,8
 692.381 -    LTEXT           "",IDC_ROM_MAKER_NAME2,80,52,133,8
 692.382 -    LTEXT           "Maker name:",IDC_STATIC,7,52,60,8
 692.383 -END
 692.384 -
 692.385 -IDD_GB_CHEAT_LIST DIALOG 0, 0, 286, 221
 692.386 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.387 -CAPTION "Gameboy Cheat List"
 692.388 -FONT 8, "MS Sans Serif"
 692.389 -BEGIN
 692.390 -    CONTROL         "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_GROUP | WS_TABSTOP,9,20,269,156
 692.391 -    PUSHBUTTON      "Add &GameGenie...",IDC_ADD_GG_CHEAT,9,183,80,14,WS_GROUP
 692.392 -    PUSHBUTTON      "&Add GameShark...",IDC_ADD_GS_CHEAT,103,183,80,14,WS_GROUP
 692.393 -    PUSHBUTTON      "&Remove",IDC_REMOVE,197,183,80,14
 692.394 -    PUSHBUTTON      "Remove A&ll",IDC_REMOVE_ALL,9,202,80,14
 692.395 -    PUSHBUTTON      "&Enable/Dis.",IDC_ENABLE,103,202,80,14
 692.396 -    DEFPUSHBUTTON   "&OK",ID_OK,197,202,80,14
 692.397 -    LTEXT           "Status legend:",IDC_STATIC,10,9,46,8
 692.398 -    LTEXT           "E: Enabled",IDC_STATIC,195,9,36,8
 692.399 -    LTEXT           "D: Disabled",IDC_STATIC,241,9,38,8
 692.400 -END
 692.401 -
 692.402 -IDD_ADD_CHEAT_DLG DIALOG 0, 0, 182, 107
 692.403 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.404 -CAPTION "Title"
 692.405 -FONT 8, "MS Sans Serif"
 692.406 -BEGIN
 692.407 -    EDITTEXT        IDC_DESC,60,7,120,14,ES_AUTOHSCROLL
 692.408 -    EDITTEXT        IDC_CODE,60,23,120,58,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
 692.409 -    DEFPUSHBUTTON   "OK",ID_OK,33,86,50,14
 692.410 -    PUSHBUTTON      "Cancel",ID_CANCEL,99,86,50,14
 692.411 -    LTEXT           "&Description:",IDC_STATIC,3,10,54,8
 692.412 -    LTEXT           "&Code:",IDC_STATIC,3,29,54,8
 692.413 -END
 692.414 -
 692.415 -IDD_GB_PRINTER DIALOG 0, 0, 178, 209
 692.416 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.417 -CAPTION "GB Printer"
 692.418 -FONT 8, "MS Sans Serif"
 692.419 -BEGIN
 692.420 -    CONTROL         "&1x",IDC_1X,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,166,22,10
 692.421 -    CONTROL         "&2x",IDC_2X,"Button",BS_AUTORADIOBUTTON,55,166,23,10
 692.422 -    CONTROL         "&3x",IDC_3X,"Button",BS_AUTORADIOBUTTON,98,166,23,10
 692.423 -    CONTROL         "&4x",IDC_4X,"Button",BS_AUTORADIOBUTTON,141,166,23,10
 692.424 -    DEFPUSHBUTTON   "&Print...",ID_PRINT,7,190,50,14,WS_GROUP
 692.425 -    PUSHBUTTON      "&Save...",ID_SAVE,64,190,50,14
 692.426 -    PUSHBUTTON      "&Close",ID_OK,121,190,50,14
 692.427 -    CONTROL         "",IDC_GB_PRINTER,"Static",SS_BLACKFRAME | WS_GROUP,7,6,162,146
 692.428 -    GROUPBOX        "Print Size",IDC_STATIC,7,156,162,25
 692.429 -END
 692.430 -
 692.431 -IDD_MOTION_CONFIG DIALOG 0, 0, 135, 78
 692.432 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.433 -CAPTION "Motion Sensor"
 692.434 -FONT 8, "MS Sans Serif"
 692.435 -BEGIN
 692.436 -    EDITTEXT        IDC_EDIT_UP,47,2,81,12,ES_AUTOHSCROLL
 692.437 -    EDITTEXT        IDC_EDIT_DOWN,47,16,81,12,ES_AUTOHSCROLL
 692.438 -    EDITTEXT        IDC_EDIT_LEFT,47,30,81,12,ES_AUTOHSCROLL
 692.439 -    EDITTEXT        IDC_EDIT_RIGHT,47,44,81,12,ES_AUTOHSCROLL
 692.440 -    PUSHBUTTON      "OK",ID_OK,20,60,40,14
 692.441 -    PUSHBUTTON      "Cancel",ID_CANCEL,74,60,40,14
 692.442 -    LTEXT           "Up:",IDC_STATIC,5,2,35,10
 692.443 -    LTEXT           "Down:",IDC_STATIC,5,16,35,10
 692.444 -    LTEXT           "Left:",IDC_STATIC,5,30,35,10
 692.445 -    LTEXT           "Right:",IDC_STATIC,5,44,35,10
 692.446 -END
 692.447 -
 692.448 -IDD_LANG_SELECT DIALOG 0, 0, 186, 68
 692.449 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.450 -CAPTION "Language selection"
 692.451 -FONT 8, "MS Sans Serif"
 692.452 -BEGIN
 692.453 -    EDITTEXT        IDC_LANG_STRING,140,25,40,14,ES_AUTOHSCROLL
 692.454 -    DEFPUSHBUTTON   "OK",ID_OK,30,49,50,14
 692.455 -    PUSHBUTTON      "Cancel",ID_CANCEL,104,49,50,14
 692.456 -    LTEXT           "Current system language is:",IDC_STATIC,6,9,123,8
 692.457 -    LTEXT           "Enter language name (3 letter):",IDC_STATIC,6,30,127,8
 692.458 -    LTEXT           "",IDC_LANG_NAME,140,9,40,8
 692.459 -END
 692.460 -
 692.461 -IDD_CODE_SELECT DIALOG 0, 0, 316, 235
 692.462 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.463 -CAPTION "Select codes to import"
 692.464 -FONT 8, "MS Sans Serif"
 692.465 -BEGIN
 692.466 -    DEFPUSHBUTTON   "OK",ID_OK,91,214,50,14
 692.467 -    PUSHBUTTON      "Cancel",ID_CANCEL,174,214,50,14
 692.468 -    LISTBOX         IDC_GAME_LIST,7,7,302,205,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
 692.469 -END
 692.470 -
 692.471 -IDD_MAP_VIEW DIALOG 0, 0, 322, 238
 692.472 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.473 -CAPTION "Map view"
 692.474 -FONT 8, "MS Sans Serif"
 692.475 -BEGIN
 692.476 -    CONTROL         "Frame 0",IDC_FRAME_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,22,41,10
 692.477 -    CONTROL         "Frame 1",IDC_FRAME_1,"Button",BS_AUTORADIOBUTTON,13,36,41,10
 692.478 -    CONTROL         "BG0",IDC_BG0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,63,30,10
 692.479 -    CONTROL         "BG1",IDC_BG1,"Button",BS_AUTORADIOBUTTON,13,77,30,10
 692.480 -    CONTROL         "BG2",IDC_BG2,"Button",BS_AUTORADIOBUTTON,13,91,30,10
 692.481 -    CONTROL         "BG3",IDC_BG3,"Button",BS_AUTORADIOBUTTON,13,105,30,10
 692.482 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,122,68,10
 692.483 -    CONTROL         "Auto update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,134,55,10
 692.484 -    PUSHBUTTON      "&Refresh",IDC_REFRESH,25,217,50,14,WS_GROUP
 692.485 -    PUSHBUTTON      "&Save...",IDC_SAVE,88,217,50,14,WS_GROUP
 692.486 -    PUSHBUTTON      "&Close",IDC_CLOSE,155,217,50,14
 692.487 -    CONTROL         "MapView",IDC_MAP_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,187,15,128,128
 692.488 -    CONTROL         "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,7,148,64,64
 692.489 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,187,164,48,47
 692.490 -    LTEXT           "",IDC_R,245,173,50,8
 692.491 -    LTEXT           "",IDC_G,245,185,50,8
 692.492 -    LTEXT           "",IDC_B,245,197,50,8
 692.493 -    GROUPBOX        "Frame",IDC_STATIC,7,11,63,37
 692.494 -    GROUPBOX        "Background",IDC_STATIC,7,52,63,67
 692.495 -    LTEXT           "",IDC_XY,129,95,53,8
 692.496 -    LTEXT           "Mode:",IDC_STATIC,80,15,34,8
 692.497 -    LTEXT           "",IDC_MODE,130,15,53,8
 692.498 -    LTEXT           "Map Base:",IDC_STATIC,80,25,35,8
 692.499 -    LTEXT           "",IDC_MAPBASE,130,25,53,8
 692.500 -    LTEXT           "Char Base:",IDC_STATIC,80,35,36,8
 692.501 -    LTEXT           "",IDC_CHARBASE,130,35,53,8
 692.502 -    LTEXT           "Size:",IDC_STATIC,80,45,37,8
 692.503 -    LTEXT           "",IDC_DIM,130,45,53,8
 692.504 -    LTEXT           "Colors:",IDC_STATIC,80,55,37,8
 692.505 -    LTEXT           "",IDC_NUMCOLORS,130,55,53,8
 692.506 -    LTEXT           "Priority:",IDC_STATIC,80,65,37,8
 692.507 -    LTEXT           "",IDC_PRIORITY,130,65,53,8
 692.508 -    LTEXT           "Mosaic:",IDC_STATIC,80,75,37,8
 692.509 -    LTEXT           "",IDC_MOSAIC,130,75,53,8
 692.510 -    LTEXT           "Overflow:",IDC_STATIC,80,85,37,8
 692.511 -    LTEXT           "",IDC_OVERFLOW,130,85,53,8
 692.512 -    LTEXT           "Address:",IDC_STATIC,80,105,37,8
 692.513 -    LTEXT           "",IDC_ADDRESS,130,105,53,8
 692.514 -    LTEXT           "Tile:",IDC_STATIC,80,115,37,8
 692.515 -    LTEXT           "",IDC_TILE_NUM,130,115,53,8
 692.516 -    LTEXT           "Flip:",IDC_STATIC,80,125,37,8
 692.517 -    LTEXT           "",IDC_FLIP,130,125,53,8
 692.518 -    LTEXT           "Palette:",IDC_STATIC,80,135,37,8
 692.519 -    LTEXT           "",IDC_PALETTE_NUM,130,135,53,8
 692.520 -END
 692.521 -
 692.522 -IDD_PALETTE_VIEW DIALOG 0, 0, 316, 266
 692.523 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.524 -CAPTION "Palette View"
 692.525 -FONT 8, "MS Sans Serif"
 692.526 -BEGIN
 692.527 -    PUSHBUTTON      "Save BG...",IDC_SAVE_BG,30,245,50,14
 692.528 -    PUSHBUTTON      "Save OBJ...",IDC_SAVE_OBJ,98,245,50,14
 692.529 -    PUSHBUTTON      "&Refresh",IDC_REFRESH2,166,245,50,14
 692.530 -    PUSHBUTTON      "&Close",IDC_CLOSE,234,245,50,14
 692.531 -    LTEXT           "",IDC_ADDRESS,53,168,50,8
 692.532 -    LTEXT           "",IDC_R,53,180,50,8
 692.533 -    LTEXT           "",IDC_G,53,192,50,8
 692.534 -    LTEXT           "",IDC_B,53,204,50,8
 692.535 -    LTEXT           "",IDC_VALUE,53,216,50,8
 692.536 -    CONTROL         "Custom1",IDC_COLOR,"VbaColorControl",WS_TABSTOP,161,168,50,50
 692.537 -    CONTROL         "PaletteViewBG",IDC_PALETTE_VIEW,"VbaPaletteViewControl",WS_TABSTOP,12,30,128,128
 692.538 -    CONTROL         "PaletteViewBG",IDC_PALETTE_VIEW_OBJ,
 692.539 -                    "VbaPaletteViewControl",WS_TABSTOP,166,30,128,128
 692.540 -    GROUPBOX        "Background",IDC_STATIC,7,20,137,143
 692.541 -    GROUPBOX        "Sprite",IDC_STATIC,161,20,137,143
 692.542 -    LTEXT           "Address:",IDC_STATIC,7,168,38,8
 692.543 -    LTEXT           "R:",IDC_STATIC,7,180,41,8
 692.544 -    LTEXT           "G:",IDC_STATIC,7,192,43,8
 692.545 -    LTEXT           "B:",IDC_STATIC,7,204,38,8
 692.546 -    LTEXT           "Value:",IDC_STATIC,7,216,38,8
 692.547 -    LTEXT           "Click on a color for more information",IDC_STATIC,7,7,302,8
 692.548 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,229,71,10
 692.549 -END
 692.550 -
 692.551 -IDD_MEM_VIEWER DIALOGEX 0, 0, 380, 178
 692.552 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.553 -CAPTION "Memory viewer"
 692.554 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.555 -BEGIN
 692.556 -    COMBOBOX        IDC_ADDRESSES,7,7,109,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
 692.557 -    CONTROL         "8-bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,120,9,29,10
 692.558 -    CONTROL         "16-bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,154,9,33,10
 692.559 -    CONTROL         "32-bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,192,9,33,10
 692.560 -    EDITTEXT        IDC_ADDRESS,238,7,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
 692.561 -    DEFPUSHBUTTON   "&Go",IDC_GO,323,7,50,14,WS_GROUP
 692.562 -    CONTROL         "Viewer",IDC_VIEWER,"VbaMemoryViewer",WS_TABSTOP,7,22,366,112
 692.563 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,139,71,10
 692.564 -    PUSHBUTTON      "&Refresh",IDC_REFRESH,67,157,50,14
 692.565 -    PUSHBUTTON      "&Load...",IDC_LOAD,132,157,50,14
 692.566 -    PUSHBUTTON      "&Save...",IDC_SAVE,197,157,50,14
 692.567 -    PUSHBUTTON      "&Close",IDC_CLOSE,262,157,50,14
 692.568 -    LTEXT           "Current address:",IDC_CURRENT_ADDRESS_LABEL,235,142,52,8
 692.569 -    EDITTEXT        IDC_CURRENT_ADDRESS,291,139,82,14,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED
 692.570 -    CONTROL         "Decimal Display",IDC_DECIMAL_DISPLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,139,66,10
 692.571 -    CONTROL         "Align to 16-byte",IDC_ALIGN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,139,65,10
 692.572 -END
 692.573 -
 692.574 -IDD_OAM_VIEW DIALOG 0, 0, 234, 185
 692.575 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.576 -CAPTION "Oam Viewer"
 692.577 -FONT 8, "MS Sans Serif"
 692.578 -BEGIN
 692.579 -    EDITTEXT        IDC_SPRITE,7,19,76,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
 692.580 -    SCROLLBAR       IDC_SCROLLBAR,7,33,76,11
 692.581 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,138,79,10
 692.582 -    PUSHBUTTON      "&Refresh",IDC_REFRESH,7,164,50,14,WS_GROUP
 692.583 -    PUSHBUTTON      "&Save...",IDC_SAVE,91,164,50,14,WS_GROUP
 692.584 -    PUSHBUTTON      "&Close",IDC_CLOSE,177,164,50,14
 692.585 -    CONTROL         "MapView",IDC_OAM_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,87,7,64,64
 692.586 -    CONTROL         "Zoom",IDC_OAM_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,163,7,64,64
 692.587 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,87,79,48,47
 692.588 -    LTEXT           "",IDC_POS,31,47,50,8
 692.589 -    LTEXT           "",IDC_MODE,31,57,50,8
 692.590 -    LTEXT           "",IDC_COLORS,31,67,50,8
 692.591 -    LTEXT           "",IDC_PALETTE,31,77,50,8
 692.592 -    LTEXT           "",IDC_TILE,31,87,50,8
 692.593 -    LTEXT           "",IDC_PRIO,31,97,50,8
 692.594 -    LTEXT           "",IDC_SIZE2,31,107,50,8
 692.595 -    LTEXT           "",IDC_ROT,31,117,50,8
 692.596 -    LTEXT           "",IDC_FLAGS,31,127,50,8
 692.597 -    LTEXT           "",IDC_R,145,88,50,8
 692.598 -    LTEXT           "",IDC_G,145,100,50,8
 692.599 -    LTEXT           "",IDC_B,145,112,50,8
 692.600 -    LTEXT           "Pos:",IDC_STATIC,7,47,24,8
 692.601 -    LTEXT           "Mode:",IDC_STATIC,7,57,24,8
 692.602 -    LTEXT           "Colors:",IDC_STATIC,7,67,24,8
 692.603 -    LTEXT           "Pal:",IDC_STATIC,7,77,24,8
 692.604 -    LTEXT           "Tile:",IDC_STATIC,7,87,24,8
 692.605 -    LTEXT           "Prio:",IDC_STATIC,7,97,24,8
 692.606 -    LTEXT           "Size:",IDC_STATIC,7,107,24,8
 692.607 -    LTEXT           "Sprite:",IDC_STATIC,7,7,50,8
 692.608 -    LTEXT           "Rot.:",IDC_STATIC,7,117,24,8
 692.609 -    LTEXT           "Flags:",IDC_STATIC,7,127,24,8
 692.610 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,150,71,10
 692.611 -END
 692.612 -
 692.613 -IDD_ACCEL_EDITOR DIALOGEX 0, 0, 320, 180
 692.614 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.615 -CAPTION "Accelerator Editor"
 692.616 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.617 -BEGIN
 692.618 -    LTEXT           "Commands:",IDC_STATIC,9,9,38,8
 692.619 -    LTEXT           "Current Keys:",IDC_STATIC1,156,9,43,8
 692.620 -    LTEXT           "Enter new accelerator:",IDC_STATIC3,156,87,99,8
 692.621 -    LTEXT           "Static",IDC_ALREADY_AFFECTED,7,162,306,8,SS_CENTERIMAGE
 692.622 -    LTEXT           "Already assigned to:",IDC_STATIC2,7,148,85,8
 692.623 -    LTEXT           "(0 to disable, millisec)",IDC_STATIC5,156,148,101,8
 692.624 -    LTEXT           "Kill focus on timeout:",IDC_STATIC4,156,136,89,8
 692.625 -    CONTROL         "",IDC_COMMANDS,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,18,139,124
 692.626 -    EDITTEXT        IDC_EDIT_KEY,156,100,100,12,ES_AUTOHSCROLL | NOT WS_TABSTOP,WS_EX_TRANSPARENT
 692.627 -    CONTROL         "",IDC_ACCELEDIT_PROGRESSBAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,156,116,100,14
 692.628 -    CONTROL         "",IDC_CURRENTS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,156,19,100,63
 692.629 -    DEFPUSHBUTTON   "&OK",ID_OK,263,7,50,14
 692.630 -    PUSHBUTTON      "&Cancel",ID_CANCEL,263,25,50,14
 692.631 -    PUSHBUTTON      "&Apply",IDC_ACCELEDIT_APPLY,264,44,49,14
 692.632 -    PUSHBUTTON      "&Insert",IDC_ASSIGN,263,82,50,14
 692.633 -    PUSHBUTTON      "&Delete",IDC_REMOVE,263,100,50,14
 692.634 -    PUSHBUTTON      "&Replace",IDC_ACCELEDIT_REPLACE,263,118,50,14
 692.635 -    EDITTEXT        IDC_ACCELEDIT_AUTOTIMEOUT,265,143,48,14,ES_AUTOHSCROLL | ES_NUMBER
 692.636 -END
 692.637 -
 692.638 -IDD_TILE_VIEWER DIALOG 0, 0, 326, 266
 692.639 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.640 -CAPTION "Tile Viewer"
 692.641 -FONT 8, "MS Sans Serif"
 692.642 -BEGIN
 692.643 -    CONTROL         "16",IDC_16_COLORS,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,20,24,10
 692.644 -    CONTROL         "256",IDC_256_COLORS,"Button",BS_AUTORADIOBUTTON,13,30,28,10
 692.645 -    CONTROL         "0x6000000",IDC_CHARBASE_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,57,51,10
 692.646 -    CONTROL         "0x6004000",IDC_CHARBASE_1,"Button",BS_AUTORADIOBUTTON,13,67,51,10
 692.647 -    CONTROL         "0x6008000",IDC_CHARBASE_2,"Button",BS_AUTORADIOBUTTON,13,77,51,10
 692.648 -    CONTROL         "0x600C000",IDC_CHARBASE_3,"Button",BS_AUTORADIOBUTTON,13,87,52,10
 692.649 -    CONTROL         "0x6010000",IDC_CHARBASE_4,"Button",BS_AUTORADIOBUTTON,13,97,49,10
 692.650 -    CONTROL         "Slider1",IDC_PALETTE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_GROUP | WS_TABSTOP,1,124,76,22
 692.651 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,149,79,10
 692.652 -    PUSHBUTTON      "Refresh",IDC_REFRESH,7,245,50,14,WS_GROUP
 692.653 -    PUSHBUTTON      "Save...",IDC_SAVE,138,245,50,14
 692.654 -    PUSHBUTTON      "Close",IDC_CLOSE,269,245,50,14
 692.655 -    CONTROL         "Custom1",IDC_TILE_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,191,7,128,128
 692.656 -    GROUPBOX        "Colors",IDC_STATIC,7,7,66,38
 692.657 -    GROUPBOX        "Char Base",IDC_STATIC,7,46,65,64
 692.658 -    CONTROL         "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,7,174,64,64
 692.659 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,98,183,48,47
 692.660 -    LTEXT           "",IDC_R,156,192,50,8
 692.661 -    LTEXT           "",IDC_G,156,204,50,8
 692.662 -    LTEXT           "",IDC_B,156,216,50,8
 692.663 -    LTEXT           "Palette:",IDC_STATIC,7,113,65,8
 692.664 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,160,71,10
 692.665 -    LTEXT           "Tile:",IDC_STATIC,79,14,41,8
 692.666 -    LTEXT           "Address:",IDC_STATIC,79,26,41,8
 692.667 -    LTEXT           "",IDC_TILE_NUMBER,135,14,50,8
 692.668 -    LTEXT           "",IDC_ADDRESS,135,26,50,8
 692.669 -END
 692.670 -
 692.671 -IDD_GB_COLORS DIALOGEX 0, 0, 169, 121
 692.672 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.673 -CAPTION "Gameboy Mono Colors"
 692.674 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.675 -BEGIN
 692.676 -    CONTROL         "Default",IDC_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,7,7,39,10
 692.677 -    CONTROL         "User 1",IDC_USER1,"Button",BS_AUTORADIOBUTTON,67,7,37,10
 692.678 -    CONTROL         "User 2",IDC_USER2,"Button",BS_AUTORADIOBUTTON,125,7,37,10
 692.679 -    COMBOBOX        IDC_PREDEFINED,7,21,155,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
 692.680 -    PUSHBUTTON      "",IDC_COLOR_BG0,15,47,28,14,WS_GROUP
 692.681 -    PUSHBUTTON      "",IDC_COLOR_BG1,52,47,28,14
 692.682 -    PUSHBUTTON      "",IDC_COLOR_BG2,89,47,28,14
 692.683 -    PUSHBUTTON      "",IDC_COLOR_BG3,126,47,28,14
 692.684 -    PUSHBUTTON      "",IDC_COLOR_OB0,15,78,28,14
 692.685 -    PUSHBUTTON      "",IDC_COLOR_OB1,52,78,28,14
 692.686 -    PUSHBUTTON      "",IDC_COLOR_OB2,89,78,28,14
 692.687 -    PUSHBUTTON      "",IDC_COLOR_OB3,126,78,28,14
 692.688 -    PUSHBUTTON      "Reset",IDC_RESET,7,100,50,14
 692.689 -    DEFPUSHBUTTON   "OK",ID_OK,59,100,50,14
 692.690 -    PUSHBUTTON      "Cancel",ID_CANCEL,111,100,50,14
 692.691 -    GROUPBOX        "Background",IDC_STATIC,8,37,154,29
 692.692 -    GROUPBOX        "Sprite",IDC_STATIC,8,67,154,30
 692.693 -END
 692.694 -
 692.695 -IDD_DISASSEMBLE DIALOG 0, 0, 402, 225
 692.696 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.697 -CAPTION "Disassemble"
 692.698 -FONT 8, "MS Sans Serif"
 692.699 -BEGIN
 692.700 -    CONTROL         "Automatic",IDC_AUTOMATIC,"Button",BS_AUTORADIOBUTTON | WS_GROUP,7,9,47,10
 692.701 -    CONTROL         "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,62,9,32,10
 692.702 -    CONTROL         "THUMB",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,103,9,42,10
 692.703 -    EDITTEXT        IDC_ADDRESS,158,7,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_GROUP
 692.704 -    DEFPUSHBUTTON   "Go",IDC_GO,232,7,50,14
 692.705 -    LISTBOX         IDC_DISASSEMBLE,7,25,276,161,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_TABSTOP
 692.706 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,191,71,10
 692.707 -    PUSHBUTTON      "Refresh",IDC_REFRESH,120,204,50,14
 692.708 -    PUSHBUTTON      "Next",IDC_NEXT,233,204,50,14
 692.709 -    PUSHBUTTON      "Close",IDC_CLOSE,346,204,50,14
 692.710 -    LTEXT           "R0:",IDC_STATIC,309,7,18,8
 692.711 -    LTEXT           "R1:",IDC_STATIC,309,15,18,8
 692.712 -    LTEXT           "R2:",IDC_STATIC,309,23,18,8
 692.713 -    LTEXT           "R3:",IDC_STATIC,309,31,18,8
 692.714 -    LTEXT           "R4:",IDC_STATIC,309,39,18,8
 692.715 -    LTEXT           "R5:",IDC_STATIC,309,47,18,8
 692.716 -    LTEXT           "R6:",IDC_STATIC,309,55,18,8
 692.717 -    LTEXT           "R7:",IDC_STATIC,309,63,18,8
 692.718 -    LTEXT           "",IDC_R0,344,7,52,8
 692.719 -    LTEXT           "",IDC_R1,344,15,52,8
 692.720 -    LTEXT           "",IDC_R2,344,23,52,8
 692.721 -    LTEXT           "",IDC_R3,344,31,52,8
 692.722 -    LTEXT           "",IDC_R4,344,39,52,8
 692.723 -    LTEXT           "",IDC_R5,344,47,52,8
 692.724 -    LTEXT           "",IDC_R6,344,55,52,8
 692.725 -    LTEXT           "",IDC_R7,344,63,52,8
 692.726 -    LTEXT           "",IDC_R8,344,71,52,8
 692.727 -    LTEXT           "",IDC_R9,344,79,52,8
 692.728 -    LTEXT           "",IDC_R10,344,87,52,8
 692.729 -    LTEXT           "",IDC_R11,344,95,52,8
 692.730 -    LTEXT           "",IDC_R12,344,103,52,8
 692.731 -    LTEXT           "",IDC_R13,344,111,52,8
 692.732 -    LTEXT           "",IDC_R14,344,119,52,8
 692.733 -    LTEXT           "",IDC_R15,344,127,52,8
 692.734 -    LTEXT           "R8:",IDC_STATIC,309,71,18,8
 692.735 -    LTEXT           "R9:",IDC_STATIC,309,79,18,8
 692.736 -    LTEXT           "R10:",IDC_STATIC,309,87,18,8
 692.737 -    LTEXT           "R11:",IDC_STATIC,309,95,18,8
 692.738 -    LTEXT           "R12:",IDC_STATIC,309,103,18,8
 692.739 -    LTEXT           "R13:",IDC_STATIC,309,111,18,8
 692.740 -    LTEXT           "R14:",IDC_STATIC,309,119,18,8
 692.741 -    LTEXT           "R15:",IDC_STATIC,309,127,18,8
 692.742 -    LTEXT           "",IDC_R16,344,135,52,8
 692.743 -    LTEXT           "R16:",IDC_STATIC,309,135,20,8
 692.744 -    CONTROL         "N",IDC_N,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,309,146,21,10
 692.745 -    CONTROL         "Z",IDC_Z,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,309,156,21,10
 692.746 -    CONTROL         "C",IDC_C,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,309,166,21,10
 692.747 -    CONTROL         "V",IDC_V,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,309,176,21,10
 692.748 -    CONTROL         "F",IDC_F,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,342,156,20,10
 692.749 -    CONTROL         "I",IDC_I,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,342,146,18,10
 692.750 -    CONTROL         "T",IDC_T,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,342,166,21,10
 692.751 -    LTEXT           "Mode:",IDC_STATIC,341,176,21,8
 692.752 -    LTEXT           "",IDC_MODE,376,176,20,8
 692.753 -    SCROLLBAR       IDC_VSCROLL,283,25,10,161,SBS_VERT
 692.754 -    PUSHBUTTON      "Goto R15",IDC_GOPC,7,204,50,14
 692.755 -END
 692.756 -
 692.757 -IDD_GDB_PORT DIALOG 0, 0, 186, 51
 692.758 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.759 -CAPTION "GDB connection"
 692.760 -FONT 8, "MS Sans Serif"
 692.761 -BEGIN
 692.762 -    DEFPUSHBUTTON   "OK",ID_OK,34,30,50,14
 692.763 -    PUSHBUTTON      "Cancel",ID_CANCEL,102,30,50,14
 692.764 -    LTEXT           "Port to wait for connection:",IDC_STATIC,7,10,105,8
 692.765 -    EDITTEXT        IDC_PORT,125,7,54,14,ES_RIGHT | ES_AUTOHSCROLL
 692.766 -END
 692.767 -
 692.768 -IDD_GDB_WAITING DIALOG 0, 0, 186, 44
 692.769 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.770 -CAPTION "Waiting..."
 692.771 -FONT 8, "MS Sans Serif"
 692.772 -BEGIN
 692.773 -    PUSHBUTTON      "Cancel",ID_CANCEL,67,23,50,14
 692.774 -    LTEXT           "Waiting for connection on port:",IDC_STATIC,7,7,117,8
 692.775 -    LTEXT           "",IDC_PORT,143,7,36,8
 692.776 -END
 692.777 -
 692.778 -IDD_LOGGING DIALOG 0, 0, 366, 218
 692.779 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.780 -CAPTION "Logging"
 692.781 -FONT 8, "MS Sans Serif"
 692.782 -BEGIN
 692.783 -    CONTROL         "SWI",IDC_VERBOSE_SWI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,17,87,10
 692.784 -    CONTROL         "Unaligned memory",IDC_VERBOSE_UNALIGNED_ACCESS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,30,87,10
 692.785 -    CONTROL         "Illegal write",IDC_VERBOSE_ILLEGAL_WRITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,43,87,10
 692.786 -    CONTROL         "Illegal read",IDC_VERBOSE_ILLEGAL_READ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,56,87,10
 692.787 -    CONTROL         "DMA 0",IDC_VERBOSE_DMA0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,69,87,10
 692.788 -    CONTROL         "DMA 1",IDC_VERBOSE_DMA1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,82,87,10
 692.789 -    CONTROL         "DMA 2",IDC_VERBOSE_DMA2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,95,87,10
 692.790 -    CONTROL         "DMA 3",IDC_VERBOSE_DMA3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,108,87,10
 692.791 -    CONTROL         "Undefined instruction",IDC_VERBOSE_UNDEFINED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,121,87,10
 692.792 -    CONTROL         "AGBPrint",IDC_VERBOSE_AGBPRINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,134,87,10
 692.793 -    EDITTEXT        IDC_LOG,107,7,252,183,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
 692.794 -    PUSHBUTTON      "Save...",IDC_SAVE,75,197,50,14
 692.795 -    PUSHBUTTON      "Clear",IDC_CLEAR,137,197,50,14
 692.796 -    DEFPUSHBUTTON   "OK",ID_OK,197,197,50,14
 692.797 -    GROUPBOX        "Verbose",IDC_STATIC,7,7,93,142
 692.798 -END
 692.799 -
 692.800 -IDD_EXPORT_SPS DIALOG 0, 0, 248, 148
 692.801 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.802 -CAPTION "Export Gameshark Snapshot"
 692.803 -FONT 8, "MS Sans Serif"
 692.804 -BEGIN
 692.805 -    EDITTEXT        IDC_TITLE,84,7,157,14,ES_AUTOHSCROLL
 692.806 -    EDITTEXT        IDC_DESC,84,27,157,14,ES_AUTOHSCROLL
 692.807 -    EDITTEXT        IDC_NOTES,84,47,157,73,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN
 692.808 -    DEFPUSHBUTTON   "OK",ID_OK,67,127,50,14
 692.809 -    PUSHBUTTON      "Cancel",ID_CANCEL,130,127,50,14
 692.810 -    LTEXT           "Title:",IDC_STATIC,7,8,62,8
 692.811 -    LTEXT           "Description:",IDC_STATIC,7,28,63,8
 692.812 -    LTEXT           "Notes:",IDC_STATIC,7,48,60,8
 692.813 -END
 692.814 -
 692.815 -IDD_ADDR_SIZE DIALOG 0, 0, 186, 67
 692.816 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.817 -CAPTION "Enter address and size"
 692.818 -FONT 8, "MS Sans Serif"
 692.819 -BEGIN
 692.820 -    EDITTEXT        IDC_ADDRESS,99,6,80,14,ES_AUTOHSCROLL
 692.821 -    EDITTEXT        IDC_SIZE_CONTROL,99,26,80,14,ES_AUTOHSCROLL
 692.822 -    DEFPUSHBUTTON   "OK",ID_OK,34,46,50,14
 692.823 -    PUSHBUTTON      "Cancel",ID_CANCEL,102,46,50,14
 692.824 -    LTEXT           "Address:",IDC_STATIC,7,11,65,8
 692.825 -    LTEXT           "Size:",IDC_STATIC,7,29,65,8
 692.826 -END
 692.827 -
 692.828 -IDD_MODES DIALOG 0, 0, 208, 129
 692.829 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.830 -CAPTION "Select video mode"
 692.831 -FONT 8, "MS Sans Serif"
 692.832 -BEGIN
 692.833 -    LISTBOX         IDC_MODES,7,18,194,80,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
 692.834 -    DEFPUSHBUTTON   "OK",ID_OK,45,108,50,14
 692.835 -    PUSHBUTTON      "Cancel",ID_CANCEL,112,108,50,14
 692.836 -    LTEXT           "Available video modes:",IDC_STATIC,7,7,194,8
 692.837 -END
 692.838 -
 692.839 -IDD_DRIVERS DIALOG 0, 0, 208, 121
 692.840 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.841 -CAPTION "Select video driver"
 692.842 -FONT 8, "MS Sans Serif"
 692.843 -BEGIN
 692.844 -    LISTBOX         IDC_DRIVERS,7,17,194,80,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
 692.845 -    DEFPUSHBUTTON   "OK",ID_OK,45,104,50,14
 692.846 -    PUSHBUTTON      "Cancel",ID_CANCEL,112,104,50,14
 692.847 -    LTEXT           "Available drivers:",IDC_STATIC,7,7,194,8
 692.848 -END
 692.849 -
 692.850 -IDD_THROTTLE DIALOGEX 0, 0, 186, 63
 692.851 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 692.852 -CAPTION "Throttle"
 692.853 -FONT 8, "MS Sans Serif", 0, 0, 0x0
 692.854 -BEGIN
 692.855 -    EDITTEXT        IDC_THROTTLE,7,20,172,14,ES_AUTOHSCROLL
 692.856 -    DEFPUSHBUTTON   "OK",ID_OK,37,42,50,14
 692.857 -    PUSHBUTTON      "Cancel",ID_CANCEL,99,42,50,14
 692.858 -    LTEXT           "Enter desired throttle (1%...1000%):",IDC_STATIC,7,7,172,8
 692.859 -END
 692.860 -
 692.861 -IDD_GB_DISASSEMBLE DIALOG 0, 0, 344, 225
 692.862 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.863 -CAPTION "GB Disassemble"
 692.864 -FONT 8, "MS Sans Serif"
 692.865 -BEGIN
 692.866 -    EDITTEXT        IDC_ADDRESS,7,7,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_GROUP
 692.867 -    DEFPUSHBUTTON   "Go",IDC_GO,81,7,50,14
 692.868 -    LISTBOX         IDC_DISASSEMBLE,7,25,222,161,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_TABSTOP
 692.869 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,191,71,10
 692.870 -    PUSHBUTTON      "Refresh",IDC_REFRESH,100,204,50,14
 692.871 -    PUSHBUTTON      "Next",IDC_NEXT,193,204,50,14
 692.872 -    PUSHBUTTON      "Close",IDC_CLOSE,287,204,50,14
 692.873 -    LTEXT           "AF:",IDC_STATIC,250,25,18,8
 692.874 -    LTEXT           "BC:",IDC_STATIC,250,35,18,8
 692.875 -    LTEXT           "DE:",IDC_STATIC,250,45,18,8
 692.876 -    LTEXT           "HL:",IDC_STATIC,250,55,18,8
 692.877 -    LTEXT           "IFF:",IDC_STATIC,250,85,18,8
 692.878 -    LTEXT           "",IDC_R0,285,25,52,8
 692.879 -    LTEXT           "",IDC_R1,285,35,52,8
 692.880 -    LTEXT           "",IDC_R2,285,45,52,8
 692.881 -    LTEXT           "",IDC_R3,285,55,52,8
 692.882 -    LTEXT           "",IDC_R6,285,85,52,8
 692.883 -    CONTROL         "N",IDC_N,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,250,109,21,10
 692.884 -    CONTROL         "Z",IDC_Z,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,250,97,21,10
 692.885 -    CONTROL         "C",IDC_C,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,250,133,21,10
 692.886 -    CONTROL         "H",IDC_H,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,250,121,21,10
 692.887 -    SCROLLBAR       IDC_VSCROLL,229,25,10,161,SBS_VERT
 692.888 -    PUSHBUTTON      "Goto PC",IDC_GOPC,7,204,50,14
 692.889 -    LTEXT           "SP:",IDC_STATIC,250,65,18,8
 692.890 -    LTEXT           "",IDC_R4,285,65,52,8
 692.891 -    LTEXT           "PC:",IDC_STATIC,250,75,18,8
 692.892 -    LTEXT           "",IDC_R5,285,75,52,8
 692.893 -END
 692.894 -
 692.895 -IDD_GB_OAM_VIEW DIALOG 0, 0, 234, 185
 692.896 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 692.897 -CAPTION "GB Oam Viewer"
 692.898 -FONT 8, "MS Sans Serif"
 692.899 -BEGIN
 692.900 -    EDITTEXT        IDC_SPRITE,7,19,76,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
 692.901 -    SCROLLBAR       IDC_SCROLLBAR,7,33,76,11
 692.902 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,138,79,10
 692.903 -    PUSHBUTTON      "&Refresh",IDC_REFRESH,7,164,50,14,WS_GROUP
 692.904 -    PUSHBUTTON      "&Save...",IDC_SAVE,91,164,50,14,WS_GROUP
 692.905 -    PUSHBUTTON      "&Close",IDC_CLOSE,177,164,50,14
 692.906 -    CONTROL         "MapView",IDC_OAM_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,87,7,64,64
 692.907 -    CONTROL         "Zoom",IDC_OAM_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,163,7,64,64
 692.908 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,87,79,48,47
 692.909 -    LTEXT           "",IDC_POS,31,47,50,8
 692.910 -    LTEXT           "",IDC_PALETTE,31,87,50,8
 692.911 -    LTEXT           "",IDC_TILE,31,57,50,8
 692.912 -    LTEXT           "",IDC_PRIO,31,67,50,8
 692.913 -    LTEXT           "",IDC_OAP,31,77,50,8
 692.914 -    LTEXT           "",IDC_FLAGS,31,97,50,8
 692.915 -    LTEXT           "",IDC_R,145,88,50,8
 692.916 -    LTEXT           "",IDC_G,145,100,50,8
 692.917 -    LTEXT           "",IDC_B,145,112,50,8
 692.918 -    LTEXT           "Pos:",IDC_STATIC,7,47,24,8
 692.919 -    LTEXT           "Pal:",IDC_STATIC,7,87,24,8
 692.920 -    LTEXT           "Tile:",IDC_STATIC,7,57,24,8
 692.921 -    LTEXT           "Prio:",IDC_STATIC,7,67,24,8
 692.922 -    LTEXT           "OAP:",IDC_STATIC,7,77,24,8
 692.923 -    LTEXT           "Sprite:",IDC_STATIC,7,7,50,8
 692.924 -    LTEXT           "Flags:",IDC_STATIC,7,97,24,8
 692.925 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,150,71,10
 692.926 -    LTEXT           "",IDC_BANK,31,107,50,8
 692.927 -    LTEXT           "Bank:",IDC_STATIC,7,107,24,8
 692.928 -END
 692.929 -
 692.930 -IDD_GB_TILE_VIEWER DIALOG 0, 0, 326, 238
 692.931 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 692.932 -CAPTION "GB Tile Viewer"
 692.933 -FONT 8, "MS Sans Serif"
 692.934 -BEGIN
 692.935 -    CONTROL         "0",IDC_BANK_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,20,20,10
 692.936 -    CONTROL         "1",IDC_BANK_1,"Button",BS_AUTORADIOBUTTON,13,30,20,10
 692.937 -    CONTROL         "0x8000",IDC_CHARBASE_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,57,39,10
 692.938 -    CONTROL         "0x8800",IDC_CHARBASE_1,"Button",BS_AUTORADIOBUTTON,13,67,39,10
 692.939 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,122,79,10
 692.940 -    PUSHBUTTON      "Refresh",IDC_REFRESH,7,217,50,14,WS_GROUP
 692.941 -    PUSHBUTTON      "Save...",IDC_SAVE,138,217,50,14
 692.942 -    PUSHBUTTON      "Close",IDC_CLOSE,269,217,50,14
 692.943 -    CONTROL         "Custom1",IDC_TILE_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,191,7,128,128
 692.944 -    GROUPBOX        "VRAM Bank",IDC_STATIC,7,7,66,38
 692.945 -    GROUPBOX        "Char Base",IDC_STATIC,7,46,65,35
 692.946 -    CONTROL         "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,7,147,64,64
 692.947 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,98,156,48,47
 692.948 -    LTEXT           "",IDC_R,156,164,50,8
 692.949 -    LTEXT           "",IDC_G,156,176,50,8
 692.950 -    LTEXT           "",IDC_B,156,188,50,8
 692.951 -    LTEXT           "Palette:",IDC_STATIC,7,86,65,8
 692.952 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,133,71,10
 692.953 -    LTEXT           "Tile:",IDC_STATIC,79,14,41,8
 692.954 -    LTEXT           "Address:",IDC_STATIC,79,26,41,8
 692.955 -    LTEXT           "",IDC_TILE_NUMBER,135,14,50,8
 692.956 -    LTEXT           "",IDC_ADDRESS,135,26,50,8
 692.957 -    CONTROL         "Slider1",IDC_PALETTE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_GROUP | WS_TABSTOP,1,98,76,22
 692.958 -END
 692.959 -
 692.960 -IDD_GB_MAP_VIEW DIALOG 0, 0, 322, 238
 692.961 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 692.962 -CAPTION "GB Map Viewer"
 692.963 -FONT 8, "MS Sans Serif"
 692.964 -BEGIN
 692.965 -    CONTROL         "0x8000",IDC_BANK_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,22,39,10
 692.966 -    CONTROL         "0x8800",IDC_BANK_1,"Button",BS_AUTORADIOBUTTON,13,36,39,10
 692.967 -    CONTROL         "0x9800",IDC_BG0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,63,39,10
 692.968 -    CONTROL         "0x9C00",IDC_BG1,"Button",BS_AUTORADIOBUTTON,13,77,40,10
 692.969 -    CONTROL         "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,122,68,10
 692.970 -    PUSHBUTTON      "&Refresh",IDC_REFRESH,25,217,50,14,WS_GROUP
 692.971 -    PUSHBUTTON      "&Save...",IDC_SAVE,88,217,50,14,WS_GROUP
 692.972 -    PUSHBUTTON      "&Close",IDC_CLOSE,155,217,50,14
 692.973 -    CONTROL         "MapView",IDC_MAP_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,187,15,128,128
 692.974 -    CONTROL         "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,7,148,64,64
 692.975 -    CONTROL         "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,187,164,48,47
 692.976 -    LTEXT           "",IDC_R,245,173,50,8
 692.977 -    LTEXT           "",IDC_G,245,185,50,8
 692.978 -    LTEXT           "",IDC_B,245,197,50,8
 692.979 -    GROUPBOX        "Char Base",IDC_STATIC,7,11,63,37
 692.980 -    GROUPBOX        "Map Base",IDC_STATIC,7,52,63,41
 692.981 -    CONTROL         "Auto update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,134,55,10
 692.982 -    LTEXT           "",IDC_XY,129,18,53,8
 692.983 -    LTEXT           "Priority:",IDC_STATIC,80,68,37,8
 692.984 -    LTEXT           "",IDC_PRIORITY,130,68,53,8
 692.985 -    LTEXT           "Address:",IDC_STATIC,80,28,37,8
 692.986 -    LTEXT           "",IDC_ADDRESS,130,28,53,8
 692.987 -    LTEXT           "Tile:",IDC_STATIC,80,38,37,8
 692.988 -    LTEXT           "",IDC_TILE_NUM,130,38,53,8
 692.989 -    LTEXT           "Flip:",IDC_STATIC,80,48,37,8
 692.990 -    LTEXT           "",IDC_FLIP,130,48,53,8
 692.991 -    LTEXT           "Palette:",IDC_STATIC,80,58,37,8
 692.992 -    LTEXT           "",IDC_PALETTE_NUM,130,58,53,8
 692.993 -END
 692.994 -
 692.995 -IDD_GB_PALETTE_VIEW DIALOG 0, 0, 196, 234
 692.996 -STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 692.997 -CAPTION "GB Palette Viewer"
 692.998 -FONT 8, "MS Sans Serif"
 692.999 -BEGIN
692.1000 -    PUSHBUTTON      "Save BG...",IDC_SAVE_BG,7,191,50,14
692.1001 -    PUSHBUTTON      "Save OBJ...",IDC_SAVE_OBJ,73,191,50,14
692.1002 -    PUSHBUTTON      "&Refresh",IDC_REFRESH2,139,191,50,14
692.1003 -    PUSHBUTTON      "&Close",IDC_CLOSE,73,213,50,14
692.1004 -    LTEXT           "",IDC_ADDRESS,53,117,50,8
692.1005 -    LTEXT           "",IDC_R,53,129,50,8
692.1006 -    LTEXT           "",IDC_G,53,141,50,8
692.1007 -    LTEXT           "",IDC_B,53,153,50,8
692.1008 -    LTEXT           "",IDC_VALUE,53,165,50,8
692.1009 -    CONTROL         "Custom1",IDC_COLOR,"VbaColorControl",WS_TABSTOP,119,117,50,50
692.1010 -    CONTROL         "PaletteViewBG",IDC_PALETTE_VIEW,"VbaPaletteViewControl",WS_TABSTOP,11,30,64,64
692.1011 -    CONTROL         "PaletteViewBG",IDC_PALETTE_VIEW_OBJ,
692.1012 -                    "VbaPaletteViewControl",WS_TABSTOP,120,30,64,64
692.1013 -    GROUPBOX        "BG",IDC_STATIC,6,20,74,81
692.1014 -    GROUPBOX        "Sprite",IDC_STATIC,115,20,74,81
692.1015 -    LTEXT           "Index:",IDC_STATIC,7,117,38,8
692.1016 -    LTEXT           "R:",IDC_STATIC,7,129,41,8
692.1017 -    LTEXT           "G:",IDC_STATIC,7,141,43,8
692.1018 -    LTEXT           "B:",IDC_STATIC,7,153,38,8
692.1019 -    LTEXT           "Value:",IDC_STATIC,7,165,38,8
692.1020 -    LTEXT           "Click on a color for more information",IDC_STATIC,7,7,182,8
692.1021 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,178,71,10
692.1022 -END
692.1023 -
692.1024 -IDD_MODE_CONFIRM DIALOG 0, 0, 186, 57
692.1025 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1026 -CAPTION "Confirm mode"
692.1027 -FONT 8, "MS Sans Serif"
692.1028 -BEGIN
692.1029 -    DEFPUSHBUTTON   "OK",ID_OK,31,36,50,14
692.1030 -    PUSHBUTTON      "Cancel",ID_CANCEL,103,36,50,14
692.1031 -    CTEXT           "Do you want to keep the current mode?",IDC_STATIC,7,7,172,8
692.1032 -    CTEXT           "",IDC_TIMER,7,19,172,8
692.1033 -END
692.1034 -
692.1035 -IDD_REWIND_INTERVAL DIALOGEX 0, 0, 188, 132
692.1036 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1037 -CAPTION "Rewind Settings"
692.1038 -FONT 8, "MS Sans Serif", 0, 0, 0x0
692.1039 -BEGIN
692.1040 -    EDITTEXT        IDC_INTERVAL,7,26,174,14,ES_AUTOHSCROLL
692.1041 -    DEFPUSHBUTTON   "OK",ID_OK,37,111,50,14
692.1042 -    PUSHBUTTON      "Cancel",ID_CANCEL,99,111,50,14
692.1043 -    LTEXT           "Enter the rewind interval (0.2 ... 600) in seconds:",IDC_STATIC,7,7,174,8
692.1044 -    LTEXT           "Or enter 0 to disable rewind.",IDC_STATIC,7,15,174,8
692.1045 -    EDITTEXT        IDC_REWINDSLOTS,7,66,174,14,ES_AUTOHSCROLL
692.1046 -    LTEXT           "Enter number of rewind slots (1...256)",IDC_STATIC,7,46,174,8
692.1047 -    LTEXT           "Or enter 0 to disable rewind.",IDC_STATIC,7,55,174,8
692.1048 -    LTEXT           "If enabled, File->Rewind will rewind the state by <interval> seconds, as many as <slots> intervals back.",IDC_STATIC,7,87,173,17
692.1049 -END
692.1050 -
692.1051 -IDD_IO_VIEWER DIALOG 0, 0, 269, 238
692.1052 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
692.1053 -CAPTION "I/O Viewer"
692.1054 -FONT 8, "MS Sans Serif"
692.1055 -BEGIN
692.1056 -    COMBOBOX        IDC_ADDRESSES,7,7,255,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
692.1057 -    RTEXT           "",IDC_VALUE,103,23,159,8
692.1058 -    CONTROL         "",IDC_BIT_15,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,34,255,10
692.1059 -    CONTROL         "",IDC_BIT_14,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,44,255,10
692.1060 -    CONTROL         "",IDC_BIT_13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,255,8
692.1061 -    CONTROL         "",IDC_BIT_12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64,255,10
692.1062 -    CONTROL         "",IDC_BIT_11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,74,255,10
692.1063 -    CONTROL         "",IDC_BIT_10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,84,255,10
692.1064 -    CONTROL         "",IDC_BIT_9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,94,255,10
692.1065 -    CONTROL         "",IDC_BIT_8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,104,255,10
692.1066 -    CONTROL         "",IDC_BIT_7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,114,255,10
692.1067 -    CONTROL         "",IDC_BIT_6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124,255,10
692.1068 -    CONTROL         "",IDC_BIT_5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,134,255,10
692.1069 -    CONTROL         "",IDC_BIT_4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,144,255,10
692.1070 -    CONTROL         "",IDC_BIT_3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,154,255,10
692.1071 -    CONTROL         "",IDC_BIT_2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,164,255,10
692.1072 -    CONTROL         "",IDC_BIT_1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,174,255,10
692.1073 -    CONTROL         "",IDC_BIT_0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,184,255,10
692.1074 -    CONTROL         "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,201,71,10
692.1075 -    DEFPUSHBUTTON   "&Refresh",IDC_REFRESH,54,221,50,14
692.1076 -    DEFPUSHBUTTON   "&Apply",IDC_APPLY,110,221,50,14
692.1077 -    PUSHBUTTON      "&Close",IDC_CLOSE,166,221,50,14
692.1078 -    LTEXT           "Value:",IDC_STATIC,7,23,72,8
692.1079 -END
692.1080 -
692.1081 -IDD_MAX_SCALE DIALOG 0, 0, 186, 68
692.1082 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1083 -CAPTION "Fullscreen scale"
692.1084 -FONT 8, "MS Sans Serif"
692.1085 -BEGIN
692.1086 -    EDITTEXT        IDC_VALUE,7,28,172,14,ES_AUTOHSCROLL
692.1087 -    DEFPUSHBUTTON   "OK",ID_OK,37,47,50,14
692.1088 -    PUSHBUTTON      "Cancel",ID_CANCEL,99,47,50,14
692.1089 -    LTEXT           "Enter the maxium fullscreen scale:",IDC_STATIC,7,7,172,8
692.1090 -    LTEXT           "Enter 0 to use maximum scale.",IDC_STATIC,7,17,172,8
692.1091 -END
692.1092 -
692.1093 -IDD_BUG_REPORT DIALOG 0, 0, 296, 186
692.1094 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1095 -CAPTION "Bug Report"
692.1096 -FONT 8, "MS Sans Serif"
692.1097 -BEGIN
692.1098 -    PUSHBUTTON      "&OK",ID_OK,157,165,50,14
692.1099 -    EDITTEXT        IDC_BUG_REPORT,11,22,278,131,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
692.1100 -    LTEXT           "Bug report data:",IDC_STATIC,7,7,282,8
692.1101 -    DEFPUSHBUTTON   "&Copy",IDC_COPY,87,164,50,14
692.1102 -END
692.1103 -
692.1104 -IDD_MOVIECREATE DIALOGEX 0, 0, 320, 168
692.1105 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1106 -CAPTION "Record Movie"
692.1107 -FONT 8, "MS Sans Serif", 0, 0, 0x1
692.1108 -BEGIN
692.1109 -    DEFPUSHBUTTON   "OK",IDOK,193,147,50,14
692.1110 -    PUSHBUTTON      "Cancel",IDCANCEL,256,147,50,14
692.1111 -    EDITTEXT        IDC_MOVIE_FILENAME,7,18,250,13,ES_AUTOHSCROLL
692.1112 -    LTEXT           "Movie File",-1,7,7,33,8
692.1113 -    PUSHBUTTON      "&Browse...",IDC_BROWSE,264,17,48,14
692.1114 -    EDITTEXT        IDC_EDIT_AUTHOR,57,35,200,14,ES_AUTOHSCROLL
692.1115 -    LTEXT           "Author:",-1,7,38,43,8,0,WS_EX_RIGHT
692.1116 -    EDITTEXT        IDC_EDIT_DESCRIPTION,57,52,255,14,ES_AUTOHSCROLL
692.1117 -    LTEXT           "Description:",-1,7,55,43,8,0,WS_EX_RIGHT
692.1118 -    GROUPBOX        "Game System",-1,116,74,85,64
692.1119 -    CONTROL         "Game Boy Advance",IDC_REC_GBA,"Button",BS_AUTORADIOBUTTON | WS_GROUP,119,86,79,10
692.1120 -    CONTROL         "Game Boy Color",IDC_REC_GBC,"Button",BS_AUTORADIOBUTTON,119,99,67,10
692.1121 -    CONTROL         "Super Game Boy",IDC_REC_SGB,"Button",BS_AUTORADIOBUTTON,119,112,69,10
692.1122 -    CONTROL         "Game Boy",IDC_REC_GB,"Button",BS_AUTORADIOBUTTON,119,124,49,10
692.1123 -    GROUPBOX        "Bios Settings",-1,214,74,86,64
692.1124 -    GROUPBOX        "Record Options",-1,18,74,85,64
692.1125 -    CONTROL         "From now (snapshot)",IDC_RECNOW,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,21,118,77,10
692.1126 -    CONTROL         "From reset (SRAM)",IDC_RECRESET,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,21,104,75,10
692.1127 -    CONTROL         "From start (power-on)",IDC_RECSTART,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,21,90,78,10
692.1128 -    CONTROL         "No BIOS",IDC_REC_NOBIOS,"Button",BS_AUTORADIOBUTTON | WS_GROUP,218,86,44,10
692.1129 -    CONTROL         "Emulator's BIOS",IDC_REC_EMUBIOS,"Button",BS_AUTORADIOBUTTON,218,99,67,10
692.1130 -    CONTROL         "GBA BIOS",IDC_REC_GBABIOS,"Button",BS_AUTORADIOBUTTON,218,112,49,10
692.1131 -    CONTROL         "GBA BIOS with intro",IDC_REC_GBABIOSINTRO,"Button",BS_AUTORADIOBUTTON,218,124,79,10
692.1132 -END
692.1133 -
692.1134 -IDD_MOVIEOPEN DIALOGEX 0, 0, 320, 240
692.1135 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1136 -CAPTION "Play Movie"
692.1137 -FONT 8, "MS Sans Serif", 0, 0, 0x0
692.1138 -BEGIN
692.1139 -    DEFPUSHBUTTON   "OK",IDOK,196,214,50,14
692.1140 -    PUSHBUTTON      "Cancel",IDCANCEL,255,214,50,14
692.1141 -    EDITTEXT        IDC_MOVIE_FILENAME,7,18,250,13,ES_AUTOHSCROLL
692.1142 -    LTEXT           "Movie File",-1,7,7,33,8
692.1143 -    PUSHBUTTON      "&Browse...",IDC_BROWSE,265,17,48,14
692.1144 -    LTEXT           "Recording Date:",-1,12,87,53,8
692.1145 -    LTEXT           "Length:",-1,40,99,25,8
692.1146 -    LTEXT           "Frames:",-1,40,111,26,8
692.1147 -    LTEXT           "Re-record Count:",-1,10,123,55,8
692.1148 -    LTEXT           "DATE",IDC_LABEL_DATE,68,87,124,8
692.1149 -    LTEXT           "LENGTH",IDC_LABEL_LENGTH,68,99,93,8
692.1150 -    LTEXT           "FRAMES",IDC_LABEL_FRAMES,68,111,67,8
692.1151 -    LTEXT           "RERECORD",IDC_LABEL_RERECORD,68,123,46,8
692.1152 -    CONTROL         "Open Read-Only",IDC_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,7,70,10
692.1153 -    LTEXT           "Press OK to start playing the movie.\nNote that this will erase or overwrite your game's SRAM,\nand may change other emulator settings.",-1,8,209,177,24
692.1154 -    LTEXT           "Movie ROM: ...",IDC_LABEL_WARNING1,8,34,300,8
692.1155 -    LTEXT           "Your ROM: ...",IDC_LABEL_WARNING2,12,43,295,9,0,WS_EX_TRANSPARENT
692.1156 -    EDITTEXT        IDC_EDIT_AUTHOR,57,54,200,12,ES_AUTOHSCROLL | ES_READONLY
692.1157 -    LTEXT           "Author:",-1,7,56,43,8,0,WS_EX_RIGHT
692.1158 -    EDITTEXT        IDC_EDIT_DESCRIPTION,57,68,255,12,ES_AUTOHSCROLL
692.1159 -    LTEXT           "Description:",-1,7,69,43,8,0,WS_EX_RIGHT
692.1160 -    GROUPBOX        "Game System",-1,112,137,85,64
692.1161 -    RADIOBUTTON     "Game Boy Advance",IDC_REC_GBA,116,149,79,10,WS_DISABLED | WS_GROUP
692.1162 -    RADIOBUTTON     "Game Boy Color",IDC_REC_GBC,116,162,67,10,WS_DISABLED
692.1163 -    RADIOBUTTON     "Super Game Boy",IDC_REC_SGB,116,175,69,10,WS_DISABLED
692.1164 -    RADIOBUTTON     "Game Boy",IDC_REC_GB,116,187,49,10,WS_DISABLED
692.1165 -    GROUPBOX        "Record Options",-1,18,137,77,64
692.1166 -    RADIOBUTTON     "From snapshot",IDC_RECNOW,22,180,62,10,WS_DISABLED | WS_GROUP | WS_TABSTOP
692.1167 -    RADIOBUTTON     "From reset/SRAM",IDC_RECRESET,22,167,70,10,WS_DISABLED | WS_TABSTOP
692.1168 -    RADIOBUTTON     "From power-on",IDC_RECSTART,22,153,63,10,WS_DISABLED | WS_TABSTOP
692.1169 -    RADIOBUTTON     "No BIOS",IDC_REC_NOBIOS,219,149,44,10,WS_DISABLED | WS_GROUP
692.1170 -    RADIOBUTTON     "Emulator's BIOS",IDC_REC_EMUBIOS,219,162,67,10,WS_DISABLED
692.1171 -    RADIOBUTTON     "GBA BIOS",IDC_REC_GBABIOS,219,175,49,10,WS_DISABLED
692.1172 -    RADIOBUTTON     "GBA BIOS with intro",IDC_REC_GBABIOSINTRO,219,187,79,10,WS_DISABLED
692.1173 -    GROUPBOX        "Bios Settings",-1,214,137,86,64
692.1174 -    PUSHBUTTON      "&Refresh",IDC_MOVIE_REFRESH,265,3,48,14
692.1175 -    EDITTEXT        IDC_EDIT_PAUSEFRAME,254,109,45,12,ES_AUTOHSCROLL
692.1176 -    CONTROL         "Pause at frame:",IDC_CHECK_PAUSEFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,110,63,10
692.1177 -    CONTROL         "Hide SGB Border",IDC_CHECK_HIDEBORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,116,123,70,10
692.1178 -END
692.1179 -
692.1180 -IDD_TEXTCONFIG DIALOGEX 0, 0, 139, 120
692.1181 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1182 -CAPTION "Text Options"
692.1183 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
692.1184 -BEGIN
692.1185 -    DEFPUSHBUTTON   "OK",IDOK,69,99,63,14
692.1186 -    PUSHBUTTON      "Cancel",IDCANCEL,7,99,53,14
692.1187 -    GROUPBOX        "Color",IDC_STATIC,7,7,54,86
692.1188 -    CONTROL         "White",IDC_RADIO_WHITE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,16,35,8
692.1189 -    CONTROL         "Red",IDC_RADIO_RED,"Button",BS_AUTORADIOBUTTON,13,25,29,8
692.1190 -    CONTROL         "Yellow",IDC_RADIO_YELLOW,"Button",BS_AUTORADIOBUTTON,13,34,36,9
692.1191 -    CONTROL         "Green",IDC_RADIO_GREEN,"Button",BS_AUTORADIOBUTTON,13,43,35,9
692.1192 -    CONTROL         "Cyan",IDC_RADIO_CYAN,"Button",BS_AUTORADIOBUTTON,13,53,33,8
692.1193 -    CONTROL         "Blue",IDC_RADIO_BLUE,"Button",BS_AUTORADIOBUTTON,13,63,29,8
692.1194 -    CONTROL         "Magenta",IDC_RADIO_MAGENTA,"Button",BS_AUTORADIOBUTTON,13,72,44,8
692.1195 -    CONTROL         "Black",IDC_RADIO_BLACK,"Button",BS_AUTORADIOBUTTON,13,82,32,8
692.1196 -    CONTROL         "Outlined",IDC_CHECK_OUTLINED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,17,43,10
692.1197 -    CONTROL         "Transparent",IDC_CHECK_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,28,55,10
692.1198 -    GROUPBOX        "Mode",IDC_STATIC,69,7,63,36
692.1199 -    GROUPBOX        "Display",IDC_STATIC,69,48,63,45
692.1200 -    CONTROL         "In Game",IDC_RADIO_PREFILTER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,73,58,43,10
692.1201 -    CONTROL         "On Game",IDC_RADIO_POSTFILTER,"Button",BS_AUTORADIOBUTTON,73,69,45,10
692.1202 -    CONTROL         "On Screen",IDC_RADIO_POSTRENDER,"Button",BS_AUTORADIOBUTTON,73,80,49,10
692.1203 -END
692.1204 -
692.1205 -IDD_LUA DIALOGEX 0, 0, 270, 150
692.1206 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
692.1207 -CAPTION "Lua Script"
692.1208 -MENU LUAWINDOW_MENU
692.1209 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
692.1210 -BEGIN
692.1211 -    PUSHBUTTON      "Browse...",IDC_BUTTON_LUABROWSE,7,31,48,16
692.1212 -    PUSHBUTTON      "Run",IDC_BUTTON_LUARUN,213,31,50,16
692.1213 -    PUSHBUTTON      "Stop",IDC_BUTTON_LUASTOP,160,31,50,16
692.1214 -    EDITTEXT        IDC_EDIT_LUAPATH,7,16,256,14,ES_AUTOHSCROLL
692.1215 -    EDITTEXT        IDC_LUACONSOLE,7,61,256,81,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
692.1216 -    LTEXT           "Output Console",IDC_STATIC,7,51,51,8
692.1217 -    LTEXT           "Script File",IDC_STATIC,7,7,32,8
692.1218 -    PUSHBUTTON      "Edit",IDC_BUTTON_LUAEDIT,58,31,46,16
692.1219 -END
692.1220 -
692.1221 -IDD_RAMSEARCH DIALOGEX 0, 0, 287, 292
692.1222 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1223 -CAPTION " RAM Search"
692.1224 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
692.1225 -BEGIN
692.1226 -    CONTROL         "",IDC_RAMLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,214,151,WS_EX_CLIENTEDGE
692.1227 -    PUSHBUTTON      "&Search",IDC_C_SEARCH,226,9,52,16
692.1228 -    PUSHBUTTON      "&Add Cheat",IDC_C_ADDCHEAT,226,145,52,16
692.1229 -    PUSHBUTTON      "&Watch",IDC_C_WATCH,226,127,52,16
692.1230 -    PUSHBUTTON      "&Reset",IDC_C_RESET,226,27,52,16
692.1231 -    PUSHBUTTON      "&Eliminate",IDC_C_ELIMINATE,226,109,52,16
692.1232 -    GROUPBOX        "Comparison Operator",IDC_STATIC,10,166,102,118,0,WS_EX_TRANSPARENT
692.1233 -    CONTROL         "Less Than",IDC_LESSTHAN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,14,178,95,11
692.1234 -    CONTROL         "Greater Than",IDC_MORETHAN,"Button",BS_AUTORADIOBUTTON,14,191,95,11
692.1235 -    CONTROL         "Less Than or Equal To",IDC_NOMORETHAN,"Button",BS_AUTORADIOBUTTON,14,204,95,11
692.1236 -    CONTROL         "Greater Than or Equal To",IDC_NOLESSTHAN,"Button",BS_AUTORADIOBUTTON,14,217,95,11
692.1237 -    CONTROL         "Equal To",IDC_EQUALTO,"Button",BS_AUTORADIOBUTTON,14,230,95,11
692.1238 -    CONTROL         "Not Equal To",IDC_DIFFERENTFROM,"Button",BS_AUTORADIOBUTTON,14,243,95,11
692.1239 -    CONTROL         "Different By:",IDC_DIFFERENTBY,"Button",BS_AUTORADIOBUTTON,14,256,52,11
692.1240 -    CONTROL         "Modulo",IDC_MODULO,"Button",BS_AUTORADIOBUTTON,14,269,35,11
692.1241 -    EDITTEXT        IDC_EDIT_DIFFBY,69,255,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
692.1242 -    EDITTEXT        IDC_EDIT_MODBY,51,267,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
692.1243 -    GROUPBOX        "Compare To / By",IDC_STATIC,118,166,153,58,0,WS_EX_TRANSPARENT
692.1244 -    CONTROL         "Previous Value",IDC_PREVIOUSVALUE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,121,176,67,10
692.1245 -    CONTROL         "Specific Value:",IDC_SPECIFICVALUE,"Button",BS_AUTORADIOBUTTON,121,187,67,10
692.1246 -    CONTROL         "Specific Address:",IDC_SPECIFICADDRESS,"Button",BS_AUTORADIOBUTTON,121,198,67,10
692.1247 -    CONTROL         "Number of Changes:",IDC_NUMBEROFCHANGES,"Button",BS_AUTORADIOBUTTON,121,209,76,10
692.1248 -    EDITTEXT        IDC_EDIT_COMPAREVALUE,203,183,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
692.1249 -    EDITTEXT        IDC_EDIT_COMPAREADDRESS,203,195,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
692.1250 -    EDITTEXT        IDC_EDIT_COMPARECHANGES,203,207,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
692.1251 -    GROUPBOX        "Data Type / Display",IDC_STATIC,196,227,75,44,0,WS_EX_TRANSPARENT
692.1252 -    CONTROL         "Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,200,237,67,8
692.1253 -    CONTROL         "Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,200,248,67,8
692.1254 -    CONTROL         "Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON,200,259,67,8
692.1255 -    CONTROL         "Autosearch",IDC_C_AUTOSEARCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,273,52,11
692.1256 -    GROUPBOX        "Data Size",IDC_STATIC,117,227,73,57,0,WS_EX_TRANSPARENT
692.1257 -    CONTROL         "1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,121,237,61,11
692.1258 -    CONTROL         "2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON,121,248,61,11
692.1259 -    CONTROL         "4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON,121,259,61,11
692.1260 -    CONTROL         "Check Misaligned",IDC_MISALIGN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,121,272,65,8
692.1261 -    PUSHBUTTON      "&Clear Change Counts",IDC_C_RESET_CHANGES,226,46,52,20,BS_MULTILINE
692.1262 -    PUSHBUTTON      "&Undo",IDC_C_UNDO,226,69,52,16,WS_DISABLED
692.1263 -    LTEXT           "Is",IDC_STATIC,92,270,12,8
692.1264 -END
692.1265 -
692.1266 -IDD_EDITWATCH DIALOGEX 0, 0, 181, 95
692.1267 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1268 -CAPTION " Edit Watch"
692.1269 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
692.1270 -BEGIN
692.1271 -    CTEXT           "Address:",IDC_SPECIFICADDRESS,18,12,35,10
692.1272 -    EDITTEXT        IDC_EDIT_COMPAREADDRESS,55,10,65,12,ES_UPPERCASE | ES_AUTOHSCROLL
692.1273 -    CTEXT           "Notes:",IDC_PROMPT_TEXT,18,24,45,10
692.1274 -    EDITTEXT        IDC_PROMPT_EDIT,55,22,65,12,ES_AUTOHSCROLL
692.1275 -    GROUPBOX        "Data Type",IDC_STATIC,14,37,75,42,0,WS_EX_TRANSPARENT
692.1276 -    CONTROL         "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,18,47,67,8
692.1277 -    CONTROL         "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,18,57,67,8
692.1278 -    CONTROL         "&Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON,18,67,67,8
692.1279 -    GROUPBOX        "Data Size",IDC_STATIC,94,37,73,42,0,WS_EX_TRANSPARENT
692.1280 -    CONTROL         "&1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,98,47,61,11
692.1281 -    CONTROL         "&2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON,98,57,61,11
692.1282 -    CONTROL         "&4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON,98,67,61,11
692.1283 -    DEFPUSHBUTTON   "&OK",IDOK,66,80,50,14
692.1284 -    PUSHBUTTON      "&Cancel",ID_CANCEL,120,80,50,14
692.1285 -END
692.1286 -
692.1287 -IDD_RAMWATCH DIALOGEX 0, 0, 269, 242
692.1288 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1289 -CAPTION " RAM Watch"
692.1290 -MENU RAMWATCH_MENU
692.1291 -FONT 8, "MS Shell Dlg", 400, 0, 0x1
692.1292 -BEGIN
692.1293 -    CONTROL         "",IDC_WATCHLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,210,222,WS_EX_CLIENTEDGE
692.1294 -    PUSHBUTTON      "&Edit",IDC_C_WATCH_EDIT,226,66,34,14
692.1295 -    PUSHBUTTON      "&Remove",IDC_C_WATCH_REMOVE,226,83,34,14
692.1296 -    PUSHBUTTON      "&New",IDC_C_WATCH,226,100,34,14
692.1297 -    PUSHBUTTON      "Duplic&ate",IDC_C_WATCH_DUPLICATE,226,117,34,14
692.1298 -    PUSHBUTTON      "Add &Cheat",IDC_C_ADDCHEAT,222,156,42,16
692.1299 -    GROUPBOX        "Watches",IDC_STATIC,222,11,42,144
692.1300 -    CONTROL         "",ID_WATCHES_UPDOWN,"msctls_updown32",WS_TABSTOP,232,23,19,36
692.1301 -    PUSHBUTTON      "Separator",IDC_C_WATCH_SEPARATE,225,135,36,14
692.1302 -END
692.1303 -
692.1304 -IDD_PROMPT DIALOGEX 0, 0, 190, 70
692.1305 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
692.1306 -CAPTION "Input Prompt"
692.1307 -FONT 8, "MS Sans Serif", 0, 0, 0x0
692.1308 -BEGIN
692.1309 -    EDITTEXT        IDC_PROMPT_EDIT,10,30,170,15,ES_AUTOHSCROLL
692.1310 -    DEFPUSHBUTTON   "OK",IDOK,100,50,50,15
692.1311 -    PUSHBUTTON      "Cancel",ID_CANCEL,40,50,50,15
692.1312 -    CTEXT           "",IDC_PROMPT_TEXT,0,3,190,8,SS_CENTERIMAGE
692.1313 -    CTEXT           "",IDC_PROMPT_TEXT2,0,15,190,8,SS_CENTERIMAGE
692.1314 -END
692.1315 -
692.1316 -
692.1317 -/////////////////////////////////////////////////////////////////////////////
692.1318 -//
692.1319 -// DESIGNINFO
692.1320 -//
692.1321 -
692.1322 -#ifdef APSTUDIO_INVOKED
692.1323 -GUIDELINES DESIGNINFO
692.1324 -BEGIN
692.1325 -    IDD_OPENDLG, DIALOG
692.1326 -    BEGIN
692.1327 -        RIGHTMARGIN, 165
692.1328 -    END
692.1329 -
692.1330 -    IDD_ABOUT, DIALOG
692.1331 -    BEGIN
692.1332 -        LEFTMARGIN, 7
692.1333 -        RIGHTMARGIN, 157
692.1334 -        TOPMARGIN, 7
692.1335 -        BOTTOMMARGIN, 94
692.1336 -    END
692.1337 -
692.1338 -    IDD_DIRECTORIES, DIALOG
692.1339 -    BEGIN
692.1340 -        LEFTMARGIN, 7
692.1341 -        RIGHTMARGIN, 277
692.1342 -        TOPMARGIN, 7
692.1343 -        BOTTOMMARGIN, 233
692.1344 -    END
692.1345 -
692.1346 -    IDD_CONFIG, DIALOG
692.1347 -    BEGIN
692.1348 -        LEFTMARGIN, 7
692.1349 -        RIGHTMARGIN, 128
692.1350 -        TOPMARGIN, 7
692.1351 -        BOTTOMMARGIN, 204
692.1352 -    END
692.1353 -
692.1354 -    IDD_CHEATS, DIALOG
692.1355 -    BEGIN
692.1356 -        LEFTMARGIN, 7
692.1357 -        RIGHTMARGIN, 269
692.1358 -        TOPMARGIN, 7
692.1359 -        BOTTOMMARGIN, 246
692.1360 -    END
692.1361 -
692.1362 -    IDD_ADD_CHEAT, DIALOG
692.1363 -    BEGIN
692.1364 -        LEFTMARGIN, 7
692.1365 -        RIGHTMARGIN, 179
692.1366 -        TOPMARGIN, 7
692.1367 -        BOTTOMMARGIN, 130
692.1368 -    END
692.1369 -
692.1370 -    IDD_CHEAT_LIST, DIALOG
692.1371 -    BEGIN
692.1372 -        LEFTMARGIN, 7
692.1373 -        RIGHTMARGIN, 273
692.1374 -        TOPMARGIN, 7
692.1375 -        BOTTOMMARGIN, 243
692.1376 -    END
692.1377 -
692.1378 -    IDD_ASSOCIATIONS, DIALOG
692.1379 -    BEGIN
692.1380 -        LEFTMARGIN, 7
692.1381 -        RIGHTMARGIN, 109
692.1382 -        TOPMARGIN, 7
692.1383 -        BOTTOMMARGIN, 88
692.1384 -    END
692.1385 -
692.1386 -    IDD_GBA_ROM_INFO, DIALOG
692.1387 -    BEGIN
692.1388 -        LEFTMARGIN, 7
692.1389 -        RIGHTMARGIN, 213
692.1390 -        TOPMARGIN, 7
692.1391 -        BOTTOMMARGIN, 135
692.1392 -    END
692.1393 -
692.1394 -    IDD_GB_ROM_INFO, DIALOG
692.1395 -    BEGIN
692.1396 -        LEFTMARGIN, 7
692.1397 -        RIGHTMARGIN, 213
692.1398 -        TOPMARGIN, 7
692.1399 -        BOTTOMMARGIN, 218
692.1400 -    END
692.1401 -
692.1402 -    IDD_GB_CHEAT_LIST, DIALOG
692.1403 -    BEGIN
692.1404 -        LEFTMARGIN, 7
692.1405 -        RIGHTMARGIN, 279
692.1406 -        TOPMARGIN, 7
692.1407 -        BOTTOMMARGIN, 214
692.1408 -    END
692.1409 -
692.1410 -    IDD_ADD_CHEAT_DLG, DIALOG
692.1411 -    BEGIN
692.1412 -        LEFTMARGIN, 7
692.1413 -        RIGHTMARGIN, 175
692.1414 -        TOPMARGIN, 7
692.1415 -        BOTTOMMARGIN, 100
692.1416 -    END
692.1417 -
692.1418 -    IDD_GB_PRINTER, DIALOG
692.1419 -    BEGIN
692.1420 -        LEFTMARGIN, 7
692.1421 -        RIGHTMARGIN, 171
692.1422 -        TOPMARGIN, 7
692.1423 -        BOTTOMMARGIN, 202
692.1424 -    END
692.1425 -
692.1426 -    IDD_MOTION_CONFIG, DIALOG
692.1427 -    BEGIN
692.1428 -        LEFTMARGIN, 7
692.1429 -        RIGHTMARGIN, 128
692.1430 -        TOPMARGIN, 7
692.1431 -        BOTTOMMARGIN, 71
692.1432 -    END
692.1433 -
692.1434 -    IDD_LANG_SELECT, DIALOG
692.1435 -    BEGIN
692.1436 -        LEFTMARGIN, 7
692.1437 -        RIGHTMARGIN, 179
692.1438 -        TOPMARGIN, 7
692.1439 -        BOTTOMMARGIN, 61
692.1440 -    END
692.1441 -
692.1442 -    IDD_CODE_SELECT, DIALOG
692.1443 -    BEGIN
692.1444 -        LEFTMARGIN, 7
692.1445 -        RIGHTMARGIN, 309
692.1446 -        TOPMARGIN, 7
692.1447 -        BOTTOMMARGIN, 228
692.1448 -    END
692.1449 -
692.1450 -    IDD_MAP_VIEW, DIALOG
692.1451 -    BEGIN
692.1452 -        LEFTMARGIN, 7
692.1453 -        RIGHTMARGIN, 315
692.1454 -        TOPMARGIN, 7
692.1455 -        BOTTOMMARGIN, 231
692.1456 -    END
692.1457 -
692.1458 -    IDD_PALETTE_VIEW, DIALOG
692.1459 -    BEGIN
692.1460 -        LEFTMARGIN, 7
692.1461 -        RIGHTMARGIN, 309
692.1462 -        TOPMARGIN, 7
692.1463 -        BOTTOMMARGIN, 259
692.1464 -    END
692.1465 -
692.1466 -    IDD_MEM_VIEWER, DIALOG
692.1467 -    BEGIN
692.1468 -        LEFTMARGIN, 7
692.1469 -        RIGHTMARGIN, 373
692.1470 -        TOPMARGIN, 7
692.1471 -        BOTTOMMARGIN, 171
692.1472 -    END
692.1473 -
692.1474 -    IDD_OAM_VIEW, DIALOG
692.1475 -    BEGIN
692.1476 -        LEFTMARGIN, 7
692.1477 -        RIGHTMARGIN, 227
692.1478 -        TOPMARGIN, 7
692.1479 -        BOTTOMMARGIN, 178
692.1480 -    END
692.1481 -
692.1482 -    IDD_ACCEL_EDITOR, DIALOG
692.1483 -    BEGIN
692.1484 -        LEFTMARGIN, 7
692.1485 -        RIGHTMARGIN, 313
692.1486 -        TOPMARGIN, 7
692.1487 -        BOTTOMMARGIN, 172
692.1488 -    END
692.1489 -
692.1490 -    IDD_TILE_VIEWER, DIALOG
692.1491 -    BEGIN
692.1492 -        LEFTMARGIN, 7
692.1493 -        RIGHTMARGIN, 319
692.1494 -        TOPMARGIN, 7
692.1495 -        BOTTOMMARGIN, 259
692.1496 -    END
692.1497 -
692.1498 -    IDD_GB_COLORS, DIALOG
692.1499 -    BEGIN
692.1500 -        LEFTMARGIN, 7
692.1501 -        RIGHTMARGIN, 162
692.1502 -        TOPMARGIN, 7
692.1503 -        BOTTOMMARGIN, 114
692.1504 -    END
692.1505 -
692.1506 -    IDD_DISASSEMBLE, DIALOG
692.1507 -    BEGIN
692.1508 -        LEFTMARGIN, 7
692.1509 -        RIGHTMARGIN, 396
692.1510 -        TOPMARGIN, 7
692.1511 -        BOTTOMMARGIN, 218
692.1512 -    END
692.1513 -
692.1514 -    IDD_GDB_PORT, DIALOG
692.1515 -    BEGIN
692.1516 -        LEFTMARGIN, 7
692.1517 -        RIGHTMARGIN, 179
692.1518 -        TOPMARGIN, 7
692.1519 -        BOTTOMMARGIN, 44
692.1520 -    END
692.1521 -
692.1522 -    IDD_GDB_WAITING, DIALOG
692.1523 -    BEGIN
692.1524 -        LEFTMARGIN, 7
692.1525 -        RIGHTMARGIN, 179
692.1526 -        TOPMARGIN, 7
692.1527 -        BOTTOMMARGIN, 37
692.1528 -    END
692.1529 -
692.1530 -    IDD_LOGGING, DIALOG
692.1531 -    BEGIN
692.1532 -        LEFTMARGIN, 7
692.1533 -        RIGHTMARGIN, 359
692.1534 -        TOPMARGIN, 7
692.1535 -        BOTTOMMARGIN, 211
692.1536 -    END
692.1537 -
692.1538 -    IDD_EXPORT_SPS, DIALOG
692.1539 -    BEGIN
692.1540 -        LEFTMARGIN, 7
692.1541 -        RIGHTMARGIN, 241
692.1542 -        TOPMARGIN, 7
692.1543 -        BOTTOMMARGIN, 141
692.1544 -    END
692.1545 -
692.1546 -    IDD_ADDR_SIZE, DIALOG
692.1547 -    BEGIN
692.1548 -        LEFTMARGIN, 7
692.1549 -        RIGHTMARGIN, 179
692.1550 -        TOPMARGIN, 7
692.1551 -        BOTTOMMARGIN, 60
692.1552 -    END
692.1553 -
692.1554 -    IDD_MODES, DIALOG
692.1555 -    BEGIN
692.1556 -        LEFTMARGIN, 7
692.1557 -        RIGHTMARGIN, 201
692.1558 -        TOPMARGIN, 7
692.1559 -        BOTTOMMARGIN, 122
692.1560 -    END
692.1561 -
692.1562 -    IDD_DRIVERS, DIALOG
692.1563 -    BEGIN
692.1564 -        LEFTMARGIN, 7
692.1565 -        RIGHTMARGIN, 201
692.1566 -        TOPMARGIN, 7
692.1567 -        BOTTOMMARGIN, 114
692.1568 -    END
692.1569 -
692.1570 -    IDD_THROTTLE, DIALOG
692.1571 -    BEGIN
692.1572 -        LEFTMARGIN, 7
692.1573 -        RIGHTMARGIN, 179
692.1574 -        TOPMARGIN, 7
692.1575 -        BOTTOMMARGIN, 56
692.1576 -    END
692.1577 -
692.1578 -    IDD_GB_DISASSEMBLE, DIALOG
692.1579 -    BEGIN
692.1580 -        LEFTMARGIN, 7
692.1581 -        RIGHTMARGIN, 337
692.1582 -        TOPMARGIN, 7
692.1583 -        BOTTOMMARGIN, 218
692.1584 -    END
692.1585 -
692.1586 -    IDD_GB_OAM_VIEW, DIALOG
692.1587 -    BEGIN
692.1588 -        LEFTMARGIN, 7
692.1589 -        RIGHTMARGIN, 227
692.1590 -        TOPMARGIN, 7
692.1591 -        BOTTOMMARGIN, 178
692.1592 -    END
692.1593 -
692.1594 -    IDD_GB_TILE_VIEWER, DIALOG
692.1595 -    BEGIN
692.1596 -        LEFTMARGIN, 7
692.1597 -        RIGHTMARGIN, 319
692.1598 -        TOPMARGIN, 7
692.1599 -        BOTTOMMARGIN, 231
692.1600 -    END
692.1601 -
692.1602 -    IDD_GB_MAP_VIEW, DIALOG
692.1603 -    BEGIN
692.1604 -        LEFTMARGIN, 7
692.1605 -        RIGHTMARGIN, 315
692.1606 -        TOPMARGIN, 7
692.1607 -        BOTTOMMARGIN, 231
692.1608 -    END
692.1609 -
692.1610 -    IDD_GB_PALETTE_VIEW, DIALOG
692.1611 -    BEGIN
692.1612 -        LEFTMARGIN, 7
692.1613 -        RIGHTMARGIN, 189
692.1614 -        TOPMARGIN, 7
692.1615 -        BOTTOMMARGIN, 227
692.1616 -    END
692.1617 -
692.1618 -    IDD_MODE_CONFIRM, DIALOG
692.1619 -    BEGIN
692.1620 -        LEFTMARGIN, 7
692.1621 -        RIGHTMARGIN, 179
692.1622 -        TOPMARGIN, 7
692.1623 -        BOTTOMMARGIN, 50
692.1624 -    END
692.1625 -
692.1626 -    IDD_REWIND_INTERVAL, DIALOG
692.1627 -    BEGIN
692.1628 -        LEFTMARGIN, 7
692.1629 -        RIGHTMARGIN, 181
692.1630 -        TOPMARGIN, 7
692.1631 -        BOTTOMMARGIN, 125
692.1632 -    END
692.1633 -
692.1634 -    IDD_IO_VIEWER, DIALOG
692.1635 -    BEGIN
692.1636 -        LEFTMARGIN, 7
692.1637 -        RIGHTMARGIN, 262
692.1638 -        TOPMARGIN, 7
692.1639 -        BOTTOMMARGIN, 235
692.1640 -    END
692.1641 -
692.1642 -    IDD_MAX_SCALE, DIALOG
692.1643 -    BEGIN
692.1644 -        LEFTMARGIN, 7
692.1645 -        RIGHTMARGIN, 179
692.1646 -        TOPMARGIN, 7
692.1647 -        BOTTOMMARGIN, 61
692.1648 -    END
692.1649 -
692.1650 -    IDD_BUG_REPORT, DIALOG
692.1651 -    BEGIN
692.1652 -        LEFTMARGIN, 7
692.1653 -        RIGHTMARGIN, 289
692.1654 -        TOPMARGIN, 7
692.1655 -        BOTTOMMARGIN, 179
692.1656 -    END
692.1657 -
692.1658 -    IDD_MOVIECREATE, DIALOG
692.1659 -    BEGIN
692.1660 -        LEFTMARGIN, 7
692.1661 -        RIGHTMARGIN, 312
692.1662 -        TOPMARGIN, 7
692.1663 -        BOTTOMMARGIN, 161
692.1664 -    END
692.1665 -
692.1666 -    IDD_MOVIEOPEN, DIALOG
692.1667 -    BEGIN
692.1668 -        LEFTMARGIN, 7
692.1669 -        RIGHTMARGIN, 313
692.1670 -        TOPMARGIN, 7
692.1671 -        BOTTOMMARGIN, 235
692.1672 -    END
692.1673 -
692.1674 -    IDD_TEXTCONFIG, DIALOG
692.1675 -    BEGIN
692.1676 -        LEFTMARGIN, 7
692.1677 -        RIGHTMARGIN, 132
692.1678 -        TOPMARGIN, 7
692.1679 -        BOTTOMMARGIN, 113
692.1680 -    END
692.1681 -
692.1682 -    IDD_RAMSEARCH, DIALOG
692.1683 -    BEGIN
692.1684 -    END
692.1685 -END
692.1686 -#endif    // APSTUDIO_INVOKED
692.1687 -
692.1688 -
692.1689 -/////////////////////////////////////////////////////////////////////////////
692.1690 -//
692.1691 -// Menu
692.1692 -//
692.1693 -
692.1694 -IDR_MENU MENU
692.1695 -BEGIN
692.1696 -    POPUP "&File"
692.1697 -    BEGIN
692.1698 -        MENUITEM "&Open GBA ROM...",            ID_FILE_OPEN
692.1699 -        MENUITEM "Open &GBx ROM...",            ID_FILE_OPENGAMEBOY
692.1700 -        POPUP "Rece&nt ROM"
692.1701 -        BEGIN
692.1702 -            MENUITEM "&Clear",                      ID_FILE_RECENT_RESET
692.1703 -            MENUITEM "&Lock",                       ID_FILE_RECENT_FREEZE
692.1704 -            MENUITEM SEPARATOR
692.1705 -            MENUITEM "Open Recent ROM #&1",         ID_FILE_MRU_FILE1
692.1706 -            MENUITEM "Open Recent ROM #&2",         ID_FILE_MRU_FILE2
692.1707 -            MENUITEM "Open Recent ROM #&3",         ID_FILE_MRU_FILE3
692.1708 -            MENUITEM "Open Recent ROM #&4",         ID_FILE_MRU_FILE4
692.1709 -            MENUITEM "Open Recent ROM #&5",         ID_FILE_MRU_FILE5
692.1710 -            MENUITEM "Open Recent ROM #&6",         ID_FILE_MRU_FILE6
692.1711 -            MENUITEM "Open Recent ROM #&7",         ID_FILE_MRU_FILE7
692.1712 -            MENUITEM "Open Recent ROM #&8",         ID_FILE_MRU_FILE8
692.1713 -            MENUITEM "Open Recent ROM #&9",         ID_FILE_MRU_FILE9
692.1714 -            MENUITEM "Open Recent ROM #1&0",        ID_FILE_MRU_FILE10
692.1715 -        END
692.1716 -        MENUITEM SEPARATOR
692.1717 -        POPUP "&Load Game"
692.1718 -        BEGIN
692.1719 -            MENUITEM "&Current Slot",               ID_FILE_LOADGAME_CURRENT
692.1720 -            MENUITEM "Most &Recent Slot",           ID_FILE_LOADGAME_MOSTRECENT
692.1721 -            MENUITEM "Load From &File...",          ID_FILE_LOAD
692.1722 -            MENUITEM SEPARATOR
692.1723 -            MENUITEM "Import &Battery File...",     ID_FILE_IMPORT_BATTERYFILE
692.1724 -            MENUITEM "Import &Gameshark Snapshot...", ID_FILE_IMPORT_GAMESHARKSNAPSHOT
692.1725 -            MENUITEM SEPARATOR
692.1726 -            MENUITEM "Slot #&1",                    ID_FILE_LOADGAME_SLOT1
692.1727 -            MENUITEM "Slot #&2",                    ID_FILE_LOADGAME_SLOT2
692.1728 -            MENUITEM "Slot #&3",                    ID_FILE_LOADGAME_SLOT3
692.1729 -            MENUITEM "Slot #&4",                    ID_FILE_LOADGAME_SLOT4
692.1730 -            MENUITEM "Slot #&5",                    ID_FILE_LOADGAME_SLOT5
692.1731 -            MENUITEM "Slot #&6",                    ID_FILE_LOADGAME_SLOT6
692.1732 -            MENUITEM "Slot #&7",                    ID_FILE_LOADGAME_SLOT7
692.1733 -            MENUITEM "Slot #&8",                    ID_FILE_LOADGAME_SLOT8
692.1734 -            MENUITEM "Slot #&9",                    ID_FILE_LOADGAME_SLOT9
692.1735 -            MENUITEM "Slot #1&0",                   ID_FILE_LOADGAME_SLOT10
692.1736 -            MENUITEM SEPARATOR
692.1737 -            MENUITEM "&Make 'Current' On Load",     ID_FILE_LOADGAME_MAKECURRENT
692.1738 -            MENUITEM "Make 'Recent' On &Load",      ID_FILE_LOADGAME_MAKERECENT
692.1739 -            MENUITEM SEPARATOR
692.1740 -            MENUITEM "&Auto Load Most Recent On Start", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT
692.1741 -        END
692.1742 -        POPUP "&Save Game"
692.1743 -        BEGIN
692.1744 -            MENUITEM "&Current Slot",               ID_FILE_SAVEGAME_CURRENT
692.1745 -            MENUITEM "&Oldest Slot",                ID_FILE_SAVEGAME_OLDESTSLOT
692.1746 -            MENUITEM "Save To &File...",            ID_FILE_SAVE
692.1747 -            MENUITEM SEPARATOR
692.1748 -            MENUITEM "Export &Battery File...",     ID_FILE_EXPORT_BATTERYFILE
692.1749 -            MENUITEM "Export &Gameshark Snapshot...", ID_FILE_EXPORT_GAMESHARKSNAPSHOT
692.1750 -            MENUITEM SEPARATOR
692.1751 -            MENUITEM "Slot #&1",                    ID_FILE_SAVEGAME_SLOT1
692.1752 -            MENUITEM "Slot #&2",                    ID_FILE_SAVEGAME_SLOT2
692.1753 -            MENUITEM "Slot #&3",                    ID_FILE_SAVEGAME_SLOT3
692.1754 -            MENUITEM "Slot #&4",                    ID_FILE_SAVEGAME_SLOT4
692.1755 -            MENUITEM "Slot #&5",                    ID_FILE_SAVEGAME_SLOT5
692.1756 -            MENUITEM "Slot #&6",                    ID_FILE_SAVEGAME_SLOT6
692.1757 -            MENUITEM "Slot #&7",                    ID_FILE_SAVEGAME_SLOT7
692.1758 -            MENUITEM "Slot #&8",                    ID_FILE_SAVEGAME_SLOT8
692.1759 -            MENUITEM "Slot #&9",                    ID_FILE_SAVEGAME_SLOT9
692.1760 -            MENUITEM "Slot #1&0",                   ID_FILE_SAVEGAME_SLOT10
692.1761 -            MENUITEM SEPARATOR
692.1762 -            MENUITEM "&Make 'Current' On Save",     ID_FILE_SAVEGAME_MAKECURRENT
692.1763 -        END
692.1764 -        POPUP "C&urrent Slot"
692.1765 -        BEGIN
692.1766 -            MENUITEM "&Increase Current Slot",      ID_FILE_SAVEGAME_INCREMENTSLOT
692.1767 -            MENUITEM "&Decrease Current Slot",      ID_FILE_SAVEGAME_DECREMENTSLOT
692.1768 -            MENUITEM SEPARATOR
692.1769 -            MENUITEM "Slot #&1",                    ID_SELECT_SLOT1
692.1770 -            MENUITEM "Slot #&2",                    ID_SELECT_SLOT2
692.1771 -            MENUITEM "Slot #&3",                    ID_SELECT_SLOT3
692.1772 -            MENUITEM "Slot #&4",                    ID_SELECT_SLOT4
692.1773 -            MENUITEM "Slot #&5",                    ID_SELECT_SLOT5
692.1774 -            MENUITEM "Slot #&6",                    ID_SELECT_SLOT6
692.1775 -            MENUITEM "Slot #&7",                    ID_SELECT_SLOT7
692.1776 -            MENUITEM "Slot #&8",                    ID_SELECT_SLOT8
692.1777 -            MENUITEM "Slot #&9",                    ID_SELECT_SLOT9
692.1778 -            MENUITEM "Slot #1&0",                   ID_SELECT_SLOT10
692.1779 -            MENUITEM SEPARATOR
692.1780 -            MENUITEM "Show &Timestamps",            ID_FILE_SLOT_DISPLAYMODIFICATIONTIME
692.1781 -        END
692.1782 -        MENUITEM SEPARATOR
692.1783 -        MENUITEM "&Pause",                      ID_FILE_PAUSE
692.1784 -        MENUITEM "&Frame Advance",              ID_DEBUG_NEXTFRAME
692.1785 -        MENUITEM "    &Account For Lag",        ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG
692.1786 -        MENUITEM "Re&wind",                     ID_TOOLS_REWIND
692.1787 -        MENUITEM "Rewind Se&ttings...",         ID_OPTIONS_EMULATOR_REWINDINTERVAL
692.1788 -        MENUITEM SEPARATOR
692.1789 -        MENUITEM "&Reset",                      ID_FILE_RESET
692.1790 -        MENUITEM "&Close",                      ID_FILE_CLOSE
692.1791 -        MENUITEM SEPARATOR
692.1792 -        MENUITEM "Rom &Information...",         ID_FILE_ROMINFORMATION
692.1793 -        MENUITEM SEPARATOR
692.1794 -        MENUITEM "E&xit",                       ID_FILE_EXIT
692.1795 -    END
692.1796 -    POPUP "&Options"
692.1797 -    BEGIN
692.1798 -        POPUP "&Input"
692.1799 -        BEGIN
692.1800 -            POPUP "&Configure Controllers"
692.1801 -            BEGIN
692.1802 -                MENUITEM "Controller &1...",            ID_OPTIONS_JOYPAD_CONFIGURE_1
692.1803 -                MENUITEM "Controller &2...",            ID_OPTIONS_JOYPAD_CONFIGURE_2
692.1804 -                MENUITEM "Controller &3...",            ID_OPTIONS_JOYPAD_CONFIGURE_3
692.1805 -                MENUITEM "Controller &4...",            ID_OPTIONS_JOYPAD_CONFIGURE_4
692.1806 -                MENUITEM SEPARATOR
692.1807 -                MENUITEM "&Motion Sensor...",           ID_OPTIONS_JOYPAD_MOTIONCONFIGURE
692.1808 -            END
692.1809 -            POPUP "&Use Controller"
692.1810 -            BEGIN
692.1811 -                MENUITEM "Controller &1",               ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1
692.1812 -                MENUITEM "Controller &2",               ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2
692.1813 -                MENUITEM "Controller &3",               ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3
692.1814 -                MENUITEM "Controller &4",               ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4
692.1815 -            END
692.1816 -            MENUITEM SEPARATOR
692.1817 -            MENUITEM "&Allow Left+Right / Up+Down", ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT
692.1818 -            MENUITEM SEPARATOR
692.1819 -            POPUP "Auto-&Fire"
692.1820 -            BEGIN
692.1821 -                MENUITEM "&A",                          ID_OPTIONS_JOYPAD_AUTOFIRE_A
692.1822 -                MENUITEM "&B",                          ID_OPTIONS_JOYPAD_AUTOFIRE_B
692.1823 -                MENUITEM "&L",                          ID_OPTIONS_JOYPAD_AUTOFIRE_L
692.1824 -                MENUITEM "&R",                          ID_OPTIONS_JOYPAD_AUTOFIRE_R
692.1825 -                MENUITEM "&Start",                      ID_OPTIONS_JOYPAD_AUTOFIRE_START
692.1826 -                MENUITEM "Selec&t",                     ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT
692.1827 -                MENUITEM "&Up",                         ID_OPTIONS_JOYPAD_AUTOFIRE_UP
692.1828 -                MENUITEM "&Down",                       ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN
692.1829 -                MENUITEM "L&eft",                       ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT
692.1830 -                MENUITEM "R&ight",                      ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT
692.1831 -                MENUITEM SEPARATOR
692.1832 -                MENUITEM "&Clear All",                  ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR
692.1833 -                MENUITEM "Account &For Lag",            ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG
692.1834 -            END
692.1835 -            POPUP "Auto-&Hold"
692.1836 -            BEGIN
692.1837 -                MENUITEM "&A",                          ID_STICKY_A
692.1838 -                MENUITEM "&B",                          ID_STICKY_B
692.1839 -                MENUITEM "&L",                          ID_STICKY_L
692.1840 -                MENUITEM "&R",                          ID_STICKY_R
692.1841 -                MENUITEM "&Start",                      ID_STICKY_START
692.1842 -                MENUITEM "Selec&t",                     ID_STICKY_SELECT
692.1843 -                MENUITEM "&Up",                         ID_STICKY_UP
692.1844 -                MENUITEM "&Down",                       ID_STICKY_DOWN
692.1845 -                MENUITEM "L&eft",                       ID_STICKY_LEFT
692.1846 -                MENUITEM "R&ight",                      ID_STICKY_RIGHT
692.1847 -                MENUITEM SEPARATOR
692.1848 -                MENUITEM "&Clear All",                  ID_STICKY_CLEAR
692.1849 -            END
692.1850 -            MENUITEM SEPARATOR
692.1851 -            MENUITEM "Customi&ze All Commands...",  ID_TOOLS_CUSTOMIZE
692.1852 -        END
692.1853 -        POPUP "&Speed"
692.1854 -        BEGIN
692.1855 -            POPUP "Set &Speed"
692.1856 -            BEGIN
692.1857 -                MENUITEM "6% (Very Slow)",              ID_OPTIONS_FRAMESKIP_THROTTLE_6
692.1858 -                MENUITEM "15%",                         ID_OPTIONS_FRAMESKIP_THROTTLE_15
692.1859 -                MENUITEM "25%",                         ID_OPTIONS_FRAMESKIP_THROTTLE_25
692.1860 -                MENUITEM "50% (Half Speed)",            ID_OPTIONS_FRAMESKIP_THROTTLE_50
692.1861 -                MENUITEM "75%",                         ID_OPTIONS_FRAMESKIP_THROTTLE_75
692.1862 -                MENUITEM "100% (Normal Speed)",         ID_OPTIONS_FRAMESKIP_THROTTLE_100
692.1863 -                MENUITEM "150%",                        ID_OPTIONS_FRAMESKIP_THROTTLE_150
692.1864 -                MENUITEM "200% (Double Speed)",         ID_OPTIONS_FRAMESKIP_THROTTLE_200
692.1865 -                MENUITEM "300%",                        ID_OPTIONS_FRAMESKIP_THROTTLE_300
692.1866 -                MENUITEM "400%",                        ID_OPTIONS_FRAMESKIP_THROTTLE_400
692.1867 -                MENUITEM "600% (Very Fast)",            ID_OPTIONS_FRAMESKIP_THROTTLE_600
692.1868 -                MENUITEM "&Other...",                   ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER
692.1869 -                MENUITEM SEPARATOR
692.1870 -                MENUITEM "&Increase",                   ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE
692.1871 -                MENUITEM "&Decrease",                   ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE
692.1872 -            END
692.1873 -            POPUP "&Frame Skip"
692.1874 -            BEGIN
692.1875 -                MENUITEM "Skip &0 (Don't Skip Any Frames)", ID_OPTIONS_VIDEO_FRAMESKIP_0
692.1876 -                MENUITEM "Skip &1 (Skip Every Other Frame)", ID_OPTIONS_VIDEO_FRAMESKIP_1
692.1877 -                MENUITEM "Skip &2 (Skip 2 Out Of Every 3 Frames)", ID_OPTIONS_VIDEO_FRAMESKIP_2
692.1878 -                MENUITEM "Skip &3",                     ID_OPTIONS_VIDEO_FRAMESKIP_3
692.1879 -                MENUITEM "Skip &4",                     ID_OPTIONS_VIDEO_FRAMESKIP_4
692.1880 -                MENUITEM "Skip &5",                     ID_OPTIONS_VIDEO_FRAMESKIP_5
692.1881 -                MENUITEM "Skip &6",                     ID_OPTIONS_VIDEO_FRAMESKIP_6
692.1882 -                MENUITEM "Skip &7",                     ID_OPTIONS_VIDEO_FRAMESKIP_7
692.1883 -                MENUITEM "Skip &8",                     ID_OPTIONS_VIDEO_FRAMESKIP_8
692.1884 -                MENUITEM "Skip &9 (Skip 9 Out Of Every 10 Frames)", ID_OPTIONS_VIDEO_FRAMESKIP_9
692.1885 -            END
692.1886 -            MENUITEM SEPARATOR
692.1887 -            MENUITEM "&Turbo Mode",                 ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE
692.1888 -            MENUITEM SEPARATOR
692.1889 -            MENUITEM "S&ynchronize Emulation Speed", ID_OPTIONS_EMULATOR_SYNCHRONIZE
692.1890 -            MENUITEM "    Accurate Sound &Pitch",   ID_OPTIONS_FRAMESKIP_ACCURATEPITCH
692.1891 -            MENUITEM "    Accurate &Emulation Speed", ID_OPTIONS_FRAMESKIP_ACCURATESPEED
692.1892 -        END
692.1893 -        MENUITEM SEPARATOR
692.1894 -        POPUP "&Video"
692.1895 -        BEGIN
692.1896 -            POPUP "&Render Method"
692.1897 -            BEGIN
692.1898 -                MENUITEM "&GDI",                        ID_OPTIONS_VIDEO_RENDERMETHOD_GDI
692.1899 -                MENUITEM SEPARATOR
692.1900 -                MENUITEM "&DirectDraw",                 ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW
692.1901 -                MENUITEM "    DDraw &Emulation Only",   ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY
692.1902 -                MENUITEM "    DDraw &Use Video Memory", ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY
692.1903 -                MENUITEM "    DDraw &Triple Buffering", ID_OPTIONS_VIDEO_TRIPLEBUFFERING
692.1904 -                MENUITEM "    DDraw &VSync",            ID_OPTIONS_VIDEO_VSYNC
692.1905 -                MENUITEM SEPARATOR
692.1906 -                MENUITEM "Direct&3D",                   ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D
692.1907 -                MENUITEM "    D3D &Nearest",            ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER
692.1908 -                MENUITEM "    D3D &Bilinear",           ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR
692.1909 -                MENUITEM SEPARATOR
692.1910 -                MENUITEM "&OpenGL",                     ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL
692.1911 -                MENUITEM "    GL Ne&arest",             ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST
692.1912 -                MENUITEM "    GL B&ilinear",            ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR
692.1913 -                MENUITEM "    GL T&riangle",            ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE
692.1914 -                MENUITEM "    GL &Quads",               ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS
692.1915 -            END
692.1916 -            MENUITEM SEPARATOR
692.1917 -            MENUITEM "&1x Window Size",             ID_OPTIONS_VIDEO_X1
692.1918 -            MENUITEM "&2x Window Size",             ID_OPTIONS_VIDEO_X2
692.1919 -            MENUITEM "&3x Window Size",             ID_OPTIONS_VIDEO_X3
692.1920 -            MENUITEM "&4x Window Size",             ID_OPTIONS_VIDEO_X4
692.1921 -            MENUITEM SEPARATOR
692.1922 -            MENUITEM "Full Screen (320x240)",       ID_OPTIONS_VIDEO_FULLSCREEN320X240
692.1923 -            MENUITEM "Full Screen (640x480)",       ID_OPTIONS_VIDEO_FULLSCREEN640X480
692.1924 -            MENUITEM "Full Screen (800x600)",       ID_OPTIONS_VIDEO_FULLSCREEN800X600
692.1925 -            MENUITEM "&Other Full Screen...",       ID_OPTIONS_VIDEO_FULLSCREEN
692.1926 -            MENUITEM SEPARATOR
692.1927 -            MENUITEM "Full Screen &Max Scale...",   ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE
692.1928 -            MENUITEM "Full Screen &Ignore Ratio",   ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT
692.1929 -            MENUITEM "Full Screen &Hide Menu",      ID_FILE_TOGGLEMENU
692.1930 -            MENUITEM "Full Screen &Auto Hide Menu", ID_OPTIONS_EMULATOR_AUTOHIDEMENU
692.1931 -            MENUITEM SEPARATOR
692.1932 -            MENUITEM "&Disable SFX",                ID_OPTIONS_VIDEO_DISABLESFX
692.1933 -            POPUP "Graphics &Layers"
692.1934 -            BEGIN
692.1935 -                MENUITEM "BG 0",                        ID_OPTIONS_VIDEO_LAYERS_BG0
692.1936 -                MENUITEM "BG 1",                        ID_OPTIONS_VIDEO_LAYERS_BG1
692.1937 -                MENUITEM "BG 2",                        ID_OPTIONS_VIDEO_LAYERS_BG2
692.1938 -                MENUITEM "BG 3",                        ID_OPTIONS_VIDEO_LAYERS_BG3
692.1939 -                MENUITEM "OBJ",                         ID_OPTIONS_VIDEO_LAYERS_OBJ
692.1940 -                MENUITEM "WIN 0",                       ID_OPTIONS_VIDEO_LAYERS_WIN0
692.1941 -                MENUITEM "WIN 1",                       ID_OPTIONS_VIDEO_LAYERS_WIN1
692.1942 -                MENUITEM "OBJ WIN",                     ID_OPTIONS_VIDEO_LAYERS_OBJWIN
692.1943 -            END
692.1944 -        END
692.1945 -        POPUP "Pixel &Filter"
692.1946 -        BEGIN
692.1947 -            POPUP "&Interframe Blending"
692.1948 -            BEGIN
692.1949 -                MENUITEM "&None",                       ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE
692.1950 -                MENUITEM SEPARATOR
692.1951 -                MENUITEM "&Motion Blur",                ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR
692.1952 -                MENUITEM "&Smart",                      ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART
692.1953 -            END
692.1954 -            MENUITEM SEPARATOR
692.1955 -            POPUP "&Miscellaneous 2x"
692.1956 -            BEGIN
692.1957 -                MENUITEM "&None",                       ID_OPTIONS_FILTER_NORMAL
692.1958 -                MENUITEM SEPARATOR
692.1959 -                MENUITEM "&TV Mode",                    ID_OPTIONS_FILTER_TVMODE
692.1960 -                MENUITEM "Scan&lines",                  ID_OPTIONS_FILTER_SCANLINES
692.1961 -                MENUITEM SEPARATOR
692.1962 -                MENUITEM "&Bilinear",                   ID_OPTIONS_FILTER_BILINEAR
692.1963 -                MENUITEM "Bilinear Pl&us",              ID_OPTIONS_FILTER_BILINEARPLUS
692.1964 -                MENUITEM SEPARATOR
692.1965 -                MENUITEM "&Motion Blur",                ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL
692.1966 -            END
692.1967 -            POPUP "&2x Magnification"
692.1968 -            BEGIN
692.1969 -                MENUITEM "Simple 2&x",                  ID_OPTIONS_FILTER16BIT_SIMPLE2X
692.1970 -                MENUITEM "&Pixelate 2x",                ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL
692.1971 -                MENUITEM SEPARATOR
692.1972 -                MENUITEM "&2xSaI",                      ID_OPTIONS_FILTER_2XSAI
692.1973 -                MENUITEM "&Super 2xSaI",                ID_OPTIONS_FILTER_SUPER2XSAI
692.1974 -                MENUITEM "Super &Eagle",                ID_OPTIONS_FILTER_SUPEREAGLE
692.1975 -                MENUITEM "&AdvanceMAME Scale2x",        ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X
692.1976 -                MENUITEM SEPARATOR
692.1977 -                MENUITEM "LQ2x",                        ID_OPTIONS_FILTER_LQ2X
692.1978 -                MENUITEM "HQ2x",                        ID_OPTIONS_FILTER_HQ2X
692.1979 -                MENUITEM "HQ2xS",                       ID_OPTIONS_FILTER_HQ2X2
692.1980 -            END
692.1981 -            POPUP "&3x Magnification"
692.1982 -            BEGIN
692.1983 -                MENUITEM "Simple 3&x",                  ID_OPTIONS_FILTER16BIT_SIMPLE3X
692.1984 -                MENUITEM "&Pixelate 3x",                ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL3X
692.1985 -                MENUITEM SEPARATOR
692.1986 -                MENUITEM "HQ3x",                        ID_OPTIONS_FILTER_HQ3X
692.1987 -                MENUITEM "HQ3xS",                       ID_OPTIONS_FILTER_HQ3X2
692.1988 -            END
692.1989 -            POPUP "&4x Magnification"
692.1990 -            BEGIN
692.1991 -                MENUITEM "Simple 4&x",                  ID_OPTIONS_FILTER16BIT_SIMPLE4X
692.1992 -                MENUITEM "&Pixelate 4x",                ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X
692.1993 -            END
692.1994 -            MENUITEM SEPARATOR
692.1995 -            MENUITEM "&Disable MMX Optimizations",  ID_OPTIONS_FILTER_DISABLEMMX
692.1996 -        END
692.1997 -        POPUP "&Audio"
692.1998 -        BEGIN
692.1999 -            MENUITEM "&Disable",                    ID_OPTIONS_SOUND_DISABLE
692.2000 -            MENUITEM SEPARATOR
692.2001 -            MENUITEM "&Mute All Channels",          ID_OPTIONS_SOUND_MUTE
692.2002 -            MENUITEM "Mute Frame &Advance",         ID_OPTIONS_SOUND_MUTEFRAMEADVANCE
692.2003 -            MENUITEM "Mute When &Inactive",         ID_OPTIONS_SOUND_MUTEWHENINACTIVE
692.2004 -            MENUITEM SEPARATOR
692.2005 -            MENUITEM "&Use Old Synchronization",    ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION
692.2006 -            MENUITEM "&Reverse Stereo",             ID_OPTIONS_SOUND_REVERSESTEREO
692.2007 -            MENUITEM SEPARATOR
692.2008 -            MENUITEM "&Echo",                       ID_OPTIONS_SOUND_ECHO
692.2009 -            MENUITEM "&Low Pass Filter",            ID_OPTIONS_SOUND_LOWPASSFILTER
692.2010 -            MENUITEM SEPARATOR
692.2011 -            POPUP "&Volume"
692.2012 -            BEGIN
692.2013 -                MENUITEM "&.25x",                       ID_OPTIONS_SOUND_VOLUME_25X
692.2014 -                MENUITEM ".&5x",                        ID_OPTIONS_SOUND_VOLUME_5X
692.2015 -                MENUITEM "&1x",                         ID_OPTIONS_SOUND_VOLUME_1X
692.2016 -                MENUITEM "&2x",                         ID_OPTIONS_SOUND_VOLUME_2X
692.2017 -                MENUITEM "&3x",                         ID_OPTIONS_SOUND_VOLUME_3X
692.2018 -                MENUITEM "&4x",                         ID_OPTIONS_SOUND_VOLUME_4X
692.2019 -            END
692.2020 -            POPUP "&Channels"
692.2021 -            BEGIN
692.2022 -                MENUITEM "&Enable All Channels",        ID_OPTIONS_SOUND_ON, CHECKED
692.2023 -                MENUITEM "&Disable All Channels",       ID_OPTIONS_SOUND_OFF
692.2024 -                MENUITEM SEPARATOR
692.2025 -                MENUITEM "Channel &1",                  ID_OPTIONS_SOUND_CHANNEL1, CHECKED
692.2026 -                MENUITEM "Channel &2",                  ID_OPTIONS_SOUND_CHANNEL2, CHECKED
692.2027 -                MENUITEM "Channel &3",                  ID_OPTIONS_SOUND_CHANNEL3, CHECKED
692.2028 -                MENUITEM "Channel &4",                  ID_OPTIONS_SOUND_CHANNEL4, CHECKED
692.2029 -                MENUITEM "Direct Sound &A",             ID_OPTIONS_SOUND_DIRECTSOUNDA, CHECKED
692.2030 -                MENUITEM "Direct Sound &B",             ID_OPTIONS_SOUND_DIRECTSOUNDB, CHECKED
692.2031 -            END
692.2032 -            MENUITEM SEPARATOR
692.2033 -            MENUITEM "&11 Khz",                     ID_OPTIONS_SOUND_11KHZ
692.2034 -            MENUITEM "&22 Khz",                     ID_OPTIONS_SOUND_22KHZ
692.2035 -            MENUITEM "&44 Khz",                     ID_OPTIONS_SOUND_44KHZ
692.2036 -        END
692.2037 -        MENUITEM SEPARATOR
692.2038 -        POPUP "&Emulation"
692.2039 -        BEGIN
692.2040 -            MENUITEM "&Real Time Clock",            ID_OPTIONS_EMULATOR_REALTIMECLOCK
692.2041 -            POPUP "Save &Type"
692.2042 -            BEGIN
692.2043 -                MENUITEM "&Automatic",                  ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC
692.2044 -                MENUITEM "&EEPROM",                     ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM
692.2045 -                MENUITEM "&SRAM",                       ID_OPTIONS_EMULATOR_SAVETYPE_SRAM
692.2046 -                MENUITEM "&Flash",                      ID_OPTIONS_EMULATOR_SAVETYPE_FLASH
692.2047 -                MENUITEM "EE&PROM+Sensor",              ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR
692.2048 -                MENUITEM "&None",                       ID_OPTIONS_EMULATOR_SAVETYPE_NONE
692.2049 -                MENUITEM SEPARATOR
692.2050 -                MENUITEM "Flash &64K",                  ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K
692.2051 -                MENUITEM "Flash &128K",                 ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M
692.2052 -                MENUITEM SEPARATOR
692.2053 -                MENUITEM "Enhanced &Detection",         ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION
692.2054 -            END
692.2055 -            MENUITEM SEPARATOR
692.2056 -            MENUITEM "GBA &Lag Reduction",          ID_EMULATOR_GBALAG
692.2057 -            MENUITEM "Use &Old Frame Timing",       ID_EMULATOR_USE_OLD_FRAME_TIMING
692.2058 -            MENUITEM "    Use &GB Null Input Kludge", ID_EMULATOR_USE_GB_INPUT_KLUDGE
692.2059 -            MENUITEM SEPARATOR
692.2060 -            MENUITEM "&Use BIOS File",              ID_OPTIONS_EMULATOR_USEBIOSFILE
692.2061 -            MENUITEM "Skip BIOS &Intro",            ID_OPTIONS_EMULATOR_SKIPBIOS
692.2062 -            MENUITEM "Select &BIOS File...",        ID_OPTIONS_EMULATOR_SELECTBIOSFILE
692.2063 -            MENUITEM SEPARATOR
692.2064 -            MENUITEM "Automatic IPS &Patching",     ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH
692.2065 -        END
692.2066 -        POPUP "Gameboy &Mode"
692.2067 -        BEGIN
692.2068 -            MENUITEM "Automatic &Detection",        ID_OPTIONS_GAMEBOY_AUTOMATIC
692.2069 -            MENUITEM "Game Boy &Advance (GBA/AGB)", ID_OPTIONS_GAMEBOY_GBA
692.2070 -            MENUITEM "Game Boy &Color (GBC/CGB)",   ID_OPTIONS_GAMEBOY_CGB
692.2071 -            MENUITEM "Game Boy Color + SGB b&orders", ID_OPTIONS_GAMEBOY_SGB2
692.2072 -            MENUITEM "&Super Game Boy (SGB)",       ID_OPTIONS_GAMEBOY_SGB
692.2073 -            MENUITEM "Game &Boy (GB)",              ID_OPTIONS_GAMEBOY_GB
692.2074 -            MENUITEM SEPARATOR
692.2075 -            MENUITEM "Border A&utomatic",           ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC
692.2076 -            MENUITEM "Border Al&ways",              ID_OPTIONS_GAMEBOY_BORDER
692.2077 -            MENUITEM SEPARATOR
692.2078 -            MENUITEM "GB &Printer",                 ID_OPTIONS_GAMEBOY_PRINTER
692.2079 -            MENUITEM SEPARATOR
692.2080 -            MENUITEM "&Real Colors",                ID_OPTIONS_GAMEBOY_REALCOLORS
692.2081 -            MENUITEM "Ga&meboy Colors",             ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS
692.2082 -            MENUITEM "Customi&ze Colors...",        ID_OPTIONS_GAMEBOY_COLORS
692.2083 -        END
692.2084 -        MENUITEM SEPARATOR
692.2085 -        POPUP "&Head-Up Display"
692.2086 -        BEGIN
692.2087 -            MENUITEM "&Frame Counter",              ID_TOOLS_FRAMECOUNTER
692.2088 -            MENUITEM "    &Lag Counter",            ID_TOOLS_LAGCOUNTER
692.2089 -            MENUITEM "    &Extra Counter",          ID_TOOLS_EXTRACOUNTER
692.2090 -            MENUITEM "    Extra Counter &Reset",    ID_TOOLS_EXTRACOUNTERRESET
692.2091 -            MENUITEM "&Input Display",              ID_TOOLS_INPUTDISPLAY
692.2092 -            MENUITEM SEPARATOR
692.2093 -            MENUITEM "&Text Display Options...",    ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS
692.2094 -            MENUITEM "Disable Status &Messages",    ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES
692.2095 -            MENUITEM SEPARATOR
692.2096 -            POPUP "Show &Speed"
692.2097 -            BEGIN
692.2098 -                MENUITEM "None",                        ID_OPTIONS_EMULATOR_SHOWSPEED_NONE
692.2099 -                MENUITEM "Percentage",                  ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE
692.2100 -                MENUITEM "Detailed",                    ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED
692.2101 -                MENUITEM SEPARATOR
692.2102 -                MENUITEM "Transparent",                 ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT
692.2103 -            END
692.2104 -        END
692.2105 -        POPUP "&Preferences"
692.2106 -        BEGIN
692.2107 -            MENUITEM "Always On &Top",              ID_OPTIONS_EMULATOR_ALWAYSONTOP
692.2108 -            MENUITEM "Enable &Background Input",    ID_OPTIONS_EMULATOR_BACKGROUNDINPUT
692.2109 -            MENUITEM "Pause When &Inactive",        ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE
692.2110 -            POPUP "Process &Priority"
692.2111 -            BEGIN
692.2112 -                MENUITEM "&Highest",                    ID_OPTIONS_PRIORITY_HIGHEST
692.2113 -                MENUITEM "&Above Normal",               ID_OPTIONS_PRIORITY_ABOVENORMAL
692.2114 -                MENUITEM "&Normal",                     ID_OPTIONS_PRIORITY_NORMAL
692.2115 -                MENUITEM "&Below Normal",               ID_OPTIONS_PRIORITY_BELOWNORMAL
692.2116 -            END
692.2117 -            MENUITEM SEPARATOR
692.2118 -            POPUP "Relevant File &Naming"
692.2119 -            BEGIN
692.2120 -                MENUITEM "Prefer On-Disk &Archive Filename", ID_OPTIONS_PREFER_ARCHIVE_NAME
692.2121 -                MENUITEM "Prefer Logical &ROM Filename", ID_OPTIONS_PREFER_ROM_NAME
692.2122 -            END
692.2123 -            MENUITEM "&Directories...",             ID_OPTIONS_EMULATOR_DIRECTORIES
692.2124 -            MENUITEM "&Associate...",               ID_OPTIONS_EMULATOR_ASSOCIATE
692.2125 -            MENUITEM SEPARATOR
692.2126 -            POPUP "UI &Language"
692.2127 -            BEGIN
692.2128 -                MENUITEM "&System",                     ID_OPTIONS_LANGUAGE_SYSTEM
692.2129 -                MENUITEM "&English",                    ID_OPTIONS_LANGUAGE_ENGLISH
692.2130 -                MENUITEM "&Other...",                   ID_OPTIONS_LANGUAGE_OTHER
692.2131 -            END
692.2132 -        END
692.2133 -    END
692.2134 -    POPUP "&Cheats"
692.2135 -    BEGIN
692.2136 -        MENUITEM "&RAM Search...",              ID_RAM_SEARCH
692.2137 -        MENUITEM "RAM &Watch...",               ID_RAM_WATCH
692.2138 -        MENUITEM SEPARATOR
692.2139 -        MENUITEM "Old &Cheat Search...",        ID_CHEATS_SEARCHFORCHEATS
692.2140 -        MENUITEM "&Pause During Cheat Search",  ID_CHEATS_PAUSEDURINGCHEATSEARCH
692.2141 -        MENUITEM SEPARATOR
692.2142 -        MENUITEM "&View Cheat List...",         ID_CHEATS_CHEATLIST
692.2143 -        MENUITEM "&Load Cheat List...",         ID_CHEATS_LOADCHEATLIST
692.2144 -        MENUITEM "&Save Cheat List...",         ID_CHEATS_SAVECHEATLIST
692.2145 -        MENUITEM "&Auto Save/Load Cheat List",  ID_CHEATS_AUTOMATICSAVELOADCHEATS
692.2146 -        MENUITEM SEPARATOR
692.2147 -        MENUITEM "Import &Gameshark Code File...", ID_FILE_IMPORT_GAMESHARKCODEFILE
692.2148 -        MENUITEM SEPARATOR
692.2149 -        MENUITEM "&Disable All Cheats",         ID_CHEATS_DISABLECHEATS
692.2150 -    END
692.2151 -    POPUP "&Tools"
692.2152 -    BEGIN
692.2153 -        POPUP "&Debug"
692.2154 -        BEGIN
692.2155 -            MENUITEM "&Disassemble...",             ID_TOOLS_DISASSEMBLE
692.2156 -            MENUITEM "&Logging...",                 ID_TOOLS_LOGGING
692.2157 -            MENUITEM "&IO Viewer...",               ID_TOOLS_IOVIEWER
692.2158 -            MENUITEM "&Map Viewer...",              ID_TOOLS_MAPVIEW
692.2159 -            MENUITEM "Memory &Viewer...",           ID_TOOLS_MEMORYVIEWER
692.2160 -            MENUITEM "&OAM Viewer...",              ID_TOOLS_OAMVIEWER
692.2161 -            MENUITEM "&Palette Viewer...",          ID_TOOLS_PALETTEVIEW
692.2162 -            MENUITEM "&Tile Viewer...",             ID_TOOLS_TILEVIEWER
692.2163 -            MENUITEM SEPARATOR
692.2164 -            MENUITEM "&AGB Print",                  ID_OPTIONS_EMULATOR_AGBPRINT
692.2165 -            POPUP "&GDB"
692.2166 -            BEGIN
692.2167 -                MENUITEM "&Wait For Connection...",     ID_TOOLS_DEBUG_GDB
692.2168 -                MENUITEM "&Load And Wait...",           ID_TOOLS_DEBUG_LOADANDWAIT
692.2169 -                MENUITEM "&Break Into GDB",             ID_TOOLS_DEBUG_BREAK
692.2170 -                MENUITEM "&Disconnect",                 ID_TOOLS_DEBUG_DISCONNECT
692.2171 -            END
692.2172 -        END
692.2173 -        MENUITEM SEPARATOR
692.2174 -        MENUITEM "Frame &Search",               ID_DEBUG_FRAMESEARCH
692.2175 -        MENUITEM "Frame Search Pre&v",          ID_DEBUG_FRAMESEARCHPREV
692.2176 -        MENUITEM "Frame Search &End",           ID_DEBUG_FRAMESEARCHLOAD
692.2177 -        MENUITEM SEPARATOR
692.2178 -        POPUP "&Lua Scripting"
692.2179 -        BEGIN
692.2180 -            MENUITEM "&New Lua Script Window...",   ID_FILE_LUA_OPEN
692.2181 -            MENUITEM "Close &All Script Windows",   ID_FILE_LUA_CLOSE_ALL
692.2182 -        END
692.2183 -        MENUITEM SEPARATOR
692.2184 -        POPUP "&Movie"
692.2185 -        BEGIN
692.2186 -            MENUITEM "&Play Movie...",              ID_MOVIE_PLAY
692.2187 -            MENUITEM "&Watch From Beginning",       ID_MOVIE_RESTART_PLAY
692.2188 -            MENUITEM SEPARATOR
692.2189 -            MENUITEM "Record &New Movie...",        ID_MOVIE_RECORD
692.2190 -            MENUITEM "&Resume/Exit Recording",      ID_MOVIE_RESUME_RECORD
692.2191 -            MENUITEM SEPARATOR
692.2192 -            MENUITEM "Read-&Only Mode",             ID_MOVIE_READONLY
692.2193 -            POPUP "When Movie &Ends"
692.2194 -            BEGIN
692.2195 -                MENUITEM "&Pause Emulator",             ID_MOVIE_END_PAUSE
692.2196 -                MENUITEM SEPARATOR
692.2197 -                MENUITEM "&Close Movie",                ID_MOVIE_END_STOP
692.2198 -                MENUITEM "&Watch From Beginning",       ID_MOVIE_END_RESTART
692.2199 -                MENUITEM "&Append If Modified",         ID_MOVIE_END_APPEND
692.2200 -                MENUITEM "&Leave Open",                 ID_MOVIE_END_KEEP
692.2201 -            END
692.2202 -            MENUITEM SEPARATOR
692.2203 -            MENUITEM "&Stop Movie",                 ID_MOVIE_STOP
692.2204 -            MENUITEM SEPARATOR
692.2205 -            POPUP "Advanced &Tools"
692.2206 -            BEGIN
692.2207 -                MENUITEM "&Convert Current To VBM 1.1", ID_MOVIE_TOOL_CONVERT
692.2208 -                MENUITEM SEPARATOR
692.2209 -                MENUITEM "&Auto Convert Opened Movie",  ID_MOVIE_TOOL_AUTO_CONVERT
692.2210 -                MENUITEM SEPARATOR
692.2211 -                MENUITEM "Fix &Header",                 ID_MOVIE_TOOL_FIX_HEADER
692.2212 -                MENUITEM SEPARATOR
692.2213 -                MENUITEM "&Truncate At Current Frame",  ID_MOVIE_TOOL_TRUNCATE
692.2214 -            END
692.2215 -            MENUITEM "&Associate With Savestates",  ID_MOVIE_ASSC_WITH_SAVESTATE
692.2216 -        END
692.2217 -        MENUITEM "Pause/Resume AVI &Recording", ID_TOOLS_PAUSEAVIRECORDING
692.2218 -        MENUITEM "Start/Stop &AVI Recording...", ID_TOOLS_AVIRECORDING
692.2219 -        MENUITEM "Start/Stop &WAV Recording...", ID_TOOLS_SOUNDRECORDING
692.2220 -        MENUITEM SEPARATOR
692.2221 -        MENUITEM "Screenshot &Capture...",      ID_FILE_SCREENCAPTURE
692.2222 -        POPUP "Screenshot &Format"
692.2223 -        BEGIN
692.2224 -            MENUITEM "&PNG",                        ID_OPTIONS_EMULATOR_PNGFORMAT
692.2225 -            MENUITEM "&BMP",                        ID_OPTIONS_EMULATOR_BMPFORMAT
692.2226 -        END
692.2227 -    END
692.2228 -    POPUP "&Help"
692.2229 -    BEGIN
692.2230 -        MENUITEM "&FAQ (Website)...",           ID_HELP_FAQ
692.2231 -        MENUITEM "&Bug Report...",              ID_HELP_BUGREPORT
692.2232 -        MENUITEM SEPARATOR
692.2233 -        MENUITEM "&About...",                   ID_HELP_ABOUT
692.2234 -    END
692.2235 -END
692.2236 -
692.2237 -RAMWATCH_MENU MENU
692.2238 -BEGIN
692.2239 -    POPUP "&File"
692.2240 -    BEGIN
692.2241 -        MENUITEM "&New List\tCtrl+N",           RAMMENU_FILE_NEW
692.2242 -        MENUITEM "&Open...\tCtrl+O",            RAMMENU_FILE_OPEN
692.2243 -        MENUITEM "&Save\tCtrl+S",               RAMMENU_FILE_SAVE
692.2244 -        MENUITEM "Sa&ve As...\tCtrl+Shift+S",   RAMMENU_FILE_SAVEAS
692.2245 -        MENUITEM "&Append File...",             RAMMENU_FILE_APPEND
692.2246 -        MENUITEM "&Recent",                     RAMMENU_FILE_RECENT
692.2247 -        MENUITEM SEPARATOR
692.2248 -        MENUITEM "Auto-&Load",                  RAMMENU_FILE_AUTOLOAD
692.2249 -        MENUITEM "Save &Window Position",       RAMMENU_FILE_SAVEWINDOW
692.2250 -        MENUITEM SEPARATOR
692.2251 -        MENUITEM "&Close\tAlt+F4",              IDCANCEL
692.2252 -    END
692.2253 -    POPUP "&Watches"
692.2254 -    BEGIN
692.2255 -        MENUITEM "&New Watch\tN",               IDC_C_WATCH
692.2256 -        MENUITEM "&Edit Watch\tE",              IDC_C_WATCH_EDIT
692.2257 -        MENUITEM "&Remove Watch\tR",            IDC_C_WATCH_REMOVE
692.2258 -        MENUITEM "Duplic&ate Watch\tA",         IDC_C_WATCH_DUPLICATE
692.2259 -        MENUITEM SEPARATOR
692.2260 -        MENUITEM "Move &Up\tU",                 IDC_C_WATCH_UP
692.2261 -        MENUITEM "Move &Down\tD",               IDC_C_WATCH_DOWN
692.2262 -    END
692.2263 -END
692.2264 -
692.2265 -LUAWINDOW_MENU MENU
692.2266 -BEGIN
692.2267 -    POPUP "Console"
692.2268 -    BEGIN
692.2269 -        MENUITEM "&Font...",                    IDC_LUACONSOLE_CHOOSEFONT
692.2270 -        MENUITEM "Clear",                       IDC_LUACONSOLE_CLEAR
692.2271 -    END
692.2272 -END
692.2273 -
692.2274 -
692.2275 -/////////////////////////////////////////////////////////////////////////////
692.2276 -//
692.2277 -// Accelerator
692.2278 -//
692.2279 -
692.2280 -IDR_ACCELERATOR ACCELERATORS
692.2281 -BEGIN
692.2282 -    "C",            ID_CHEATS_SEARCHFORCHEATS, VIRTKEY, CONTROL, NOINVERT
692.2283 -    VK_OEM_6,       ID_DEBUG_FRAMESEARCH,   VIRTKEY, NOINVERT
692.2284 -    "L",            ID_DEBUG_FRAMESEARCHLOAD, VIRTKEY, NOINVERT
692.2285 -    VK_OEM_4,       ID_DEBUG_FRAMESEARCHPREV, VIRTKEY, NOINVERT
692.2286 -    "N",            ID_DEBUG_NEXTFRAME,     VIRTKEY, CONTROL, NOINVERT
692.2287 -    VK_OEM_5,       ID_DEBUG_NEXTFRAME,     VIRTKEY, NOINVERT
692.2288 -    "X",            ID_FILE_EXIT,           VIRTKEY, CONTROL, NOINVERT
692.2289 -    "L",            ID_FILE_LOAD,           VIRTKEY, SHIFT, CONTROL, NOINVERT
692.2290 -    "L",            ID_FILE_LOADGAME_CURRENT, VIRTKEY, CONTROL, NOINVERT
692.2291 -    VK_F1,          ID_FILE_LOADGAME_SLOT1, VIRTKEY, NOINVERT
692.2292 -    VK_F10,         ID_FILE_LOADGAME_SLOT10, VIRTKEY, NOINVERT
692.2293 -    VK_F2,          ID_FILE_LOADGAME_SLOT2, VIRTKEY, NOINVERT
692.2294 -    VK_F3,          ID_FILE_LOADGAME_SLOT3, VIRTKEY, NOINVERT
692.2295 -    VK_F4,          ID_FILE_LOADGAME_SLOT4, VIRTKEY, NOINVERT
692.2296 -    VK_F5,          ID_FILE_LOADGAME_SLOT5, VIRTKEY, NOINVERT
692.2297 -    VK_F6,          ID_FILE_LOADGAME_SLOT6, VIRTKEY, NOINVERT
692.2298 -    VK_F7,          ID_FILE_LOADGAME_SLOT7, VIRTKEY, NOINVERT
692.2299 -    VK_F8,          ID_FILE_LOADGAME_SLOT8, VIRTKEY, NOINVERT
692.2300 -    VK_F9,          ID_FILE_LOADGAME_SLOT9, VIRTKEY, NOINVERT
692.2301 -    VK_F1,          ID_FILE_MRU_FILE1,      VIRTKEY, CONTROL, NOINVERT
692.2302 -    VK_F10,         ID_FILE_MRU_FILE10,     VIRTKEY, CONTROL, NOINVERT
692.2303 -    VK_F2,          ID_FILE_MRU_FILE2,      VIRTKEY, CONTROL, NOINVERT
692.2304 -    VK_F3,          ID_FILE_MRU_FILE3,      VIRTKEY, CONTROL, NOINVERT
692.2305 -    VK_F4,          ID_FILE_MRU_FILE4,      VIRTKEY, CONTROL, NOINVERT
692.2306 -    VK_F5,          ID_FILE_MRU_FILE5,      VIRTKEY, CONTROL, NOINVERT
692.2307 -    VK_F6,          ID_FILE_MRU_FILE6,      VIRTKEY, CONTROL, NOINVERT
692.2308 -    VK_F7,          ID_FILE_MRU_FILE7,      VIRTKEY, CONTROL, NOINVERT
692.2309 -    VK_F8,          ID_FILE_MRU_FILE8,      VIRTKEY, CONTROL, NOINVERT
692.2310 -    VK_F9,          ID_FILE_MRU_FILE9,      VIRTKEY, CONTROL, NOINVERT
692.2311 -    "O",            ID_FILE_OPEN,           VIRTKEY, CONTROL, NOINVERT
692.2312 -    "G",            ID_FILE_OPENGAMEBOY,    VIRTKEY, CONTROL, NOINVERT
692.2313 -    "P",            ID_FILE_PAUSE,          VIRTKEY, CONTROL, NOINVERT
692.2314 -    VK_PAUSE,       ID_FILE_PAUSE,          VIRTKEY, NOINVERT
692.2315 -    "R",            ID_FILE_RESET,          VIRTKEY, CONTROL, NOINVERT
692.2316 -    "S",            ID_FILE_SAVE,           VIRTKEY, SHIFT, CONTROL, NOINVERT
692.2317 -    "S",            ID_FILE_SAVEGAME_CURRENT, VIRTKEY, CONTROL, NOINVERT
692.2318 -    VK_F1,          ID_FILE_SAVEGAME_SLOT1, VIRTKEY, SHIFT, NOINVERT
692.2319 -    VK_F10,         ID_FILE_SAVEGAME_SLOT10, VIRTKEY, SHIFT, NOINVERT
692.2320 -    VK_F2,          ID_FILE_SAVEGAME_SLOT2, VIRTKEY, SHIFT, NOINVERT
692.2321 -    VK_F3,          ID_FILE_SAVEGAME_SLOT3, VIRTKEY, SHIFT, NOINVERT
692.2322 -    VK_F4,          ID_FILE_SAVEGAME_SLOT4, VIRTKEY, SHIFT, NOINVERT
692.2323 -    VK_F5,          ID_FILE_SAVEGAME_SLOT5, VIRTKEY, SHIFT, NOINVERT
692.2324 -    VK_F6,          ID_FILE_SAVEGAME_SLOT6, VIRTKEY, SHIFT, NOINVERT
692.2325 -    VK_F7,          ID_FILE_SAVEGAME_SLOT7, VIRTKEY, SHIFT, NOINVERT
692.2326 -    VK_F8,          ID_FILE_SAVEGAME_SLOT8, VIRTKEY, SHIFT, NOINVERT
692.2327 -    VK_F9,          ID_FILE_SAVEGAME_SLOT9, VIRTKEY, SHIFT, NOINVERT
692.2328 -    VK_ESCAPE,      ID_FILE_TOGGLEMENU,     VIRTKEY, NOINVERT
692.2329 -    "8",            ID_MOVIE_READONLY,      VIRTKEY, SHIFT, NOINVERT
692.2330 -    VK_OEM_MINUS,   ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, VIRTKEY, NOINVERT
692.2331 -    VK_OEM_PLUS,    ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, VIRTKEY, NOINVERT
692.2332 -    "1",            ID_OPTIONS_JOYPAD_AUTOFIRE_A, VIRTKEY, ALT, NOINVERT
692.2333 -    "2",            ID_OPTIONS_JOYPAD_AUTOFIRE_B, VIRTKEY, ALT, NOINVERT
692.2334 -    VK_OEM_3,       ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, VIRTKEY, ALT, NOINVERT
692.2335 -    "8",            ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN, VIRTKEY, ALT, NOINVERT
692.2336 -    "3",            ID_OPTIONS_JOYPAD_AUTOFIRE_L, VIRTKEY, ALT, NOINVERT
692.2337 -    "9",            ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT, VIRTKEY, ALT, NOINVERT
692.2338 -    "4",            ID_OPTIONS_JOYPAD_AUTOFIRE_R, VIRTKEY, ALT, NOINVERT
692.2339 -    "0",            ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT, VIRTKEY, ALT, NOINVERT
692.2340 -    "6",            ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT, VIRTKEY, ALT, NOINVERT
692.2341 -    "5",            ID_OPTIONS_JOYPAD_AUTOFIRE_START, VIRTKEY, ALT, NOINVERT
692.2342 -    "7",            ID_OPTIONS_JOYPAD_AUTOFIRE_UP, VIRTKEY, ALT, NOINVERT
692.2343 -    "1",            ID_OPTIONS_VIDEO_LAYERS_BG0, VIRTKEY, CONTROL, NOINVERT
692.2344 -    "2",            ID_OPTIONS_VIDEO_LAYERS_BG1, VIRTKEY, CONTROL, NOINVERT
692.2345 -    "3",            ID_OPTIONS_VIDEO_LAYERS_BG2, VIRTKEY, CONTROL, NOINVERT
692.2346 -    "4",            ID_OPTIONS_VIDEO_LAYERS_BG3, VIRTKEY, CONTROL, NOINVERT
692.2347 -    "5",            ID_OPTIONS_VIDEO_LAYERS_OBJ, VIRTKEY, CONTROL, NOINVERT
692.2348 -    "8",            ID_OPTIONS_VIDEO_LAYERS_OBJWIN, VIRTKEY, CONTROL, NOINVERT
692.2349 -    "6",            ID_OPTIONS_VIDEO_LAYERS_WIN0, VIRTKEY, CONTROL, NOINVERT
692.2350 -    "7",            ID_OPTIONS_VIDEO_LAYERS_WIN1, VIRTKEY, CONTROL, NOINVERT
692.2351 -    "1",            ID_SELECT_SLOT1,        VIRTKEY, NOINVERT
692.2352 -    "0",            ID_SELECT_SLOT10,       VIRTKEY, NOINVERT
692.2353 -    "2",            ID_SELECT_SLOT2,        VIRTKEY, NOINVERT
692.2354 -    "3",            ID_SELECT_SLOT3,        VIRTKEY, NOINVERT
692.2355 -    "4",            ID_SELECT_SLOT4,        VIRTKEY, NOINVERT
692.2356 -    "5",            ID_SELECT_SLOT5,        VIRTKEY, NOINVERT
692.2357 -    "6",            ID_SELECT_SLOT6,        VIRTKEY, NOINVERT
692.2358 -    "7",            ID_SELECT_SLOT7,        VIRTKEY, NOINVERT
692.2359 -    "8",            ID_SELECT_SLOT8,        VIRTKEY, NOINVERT
692.2360 -    "9",            ID_SELECT_SLOT9,        VIRTKEY, NOINVERT
692.2361 -    VK_OEM_PERIOD,  ID_TOOLS_FRAMECOUNTER,  VIRTKEY, NOINVERT
692.2362 -    VK_OEM_COMMA,   ID_TOOLS_INPUTDISPLAY,  VIRTKEY, NOINVERT
692.2363 -    "B",            ID_TOOLS_REWIND,        VIRTKEY, CONTROL, NOINVERT
692.2364 -    "R",            ID_MOVIE_RESTART_PLAY,  VIRTKEY, SHIFT, NOINVERT
692.2365 -END
692.2366 -
692.2367 -IDR_ACCELERATOR1 ACCELERATORS
692.2368 -BEGIN
692.2369 -    "N",            IDC_C_WATCH,            VIRTKEY, NOINVERT
692.2370 -    "D",            IDC_C_WATCH_DOWN,       VIRTKEY, NOINVERT
692.2371 -    "A",            IDC_C_WATCH_DUPLICATE,  VIRTKEY, NOINVERT
692.2372 -    "E",            IDC_C_WATCH_EDIT,       VIRTKEY, NOINVERT
692.2373 -    "R",            IDC_C_WATCH_REMOVE,     VIRTKEY, NOINVERT
692.2374 -    "U",            IDC_C_WATCH_UP,         VIRTKEY, NOINVERT
692.2375 -    "N",            RAMMENU_FILE_NEW,       VIRTKEY, CONTROL, NOINVERT
692.2376 -    "O",            RAMMENU_FILE_OPEN,      VIRTKEY, CONTROL, NOINVERT
692.2377 -    "S",            RAMMENU_FILE_SAVE,      VIRTKEY, CONTROL, NOINVERT
692.2378 -    "S",            RAMMENU_FILE_SAVEAS,    VIRTKEY, SHIFT, CONTROL, NOINVERT
692.2379 -END
692.2380 -
692.2381 -
692.2382 -/////////////////////////////////////////////////////////////////////////////
692.2383 -//
692.2384 -// RT_MANIFEST
692.2385 -//
692.2386 -
692.2387 -1                       RT_MANIFEST             "VisualBoyAdvance.exe.manifest"
692.2388 -
692.2389 -/////////////////////////////////////////////////////////////////////////////
692.2390 -//
692.2391 -// String Table
692.2392 -//
692.2393 -
692.2394 -STRINGTABLE
692.2395 -BEGIN
692.2396 -    IDS_STARTAVIRECORDING   "Start &AVI Recording..."
692.2397 -    IDS_STOPAVIRECORDING    "Stop &AVI Recording"
692.2398 -    IDS_PAUSEAVIRECORDING   "Pause AVI &Recording"
692.2399 -    IDS_RESUMEAVIRECORDING  "Resume AVI &Recording"
692.2400 -END
692.2401 -
692.2402 -STRINGTABLE
692.2403 -BEGIN
692.2404 -    IDS_STARTSOUNDRECORDING "Start &WAV Recording..."
692.2405 -    IDS_STOPSOUNDRECORDING  "Stop &WAV Recording"
692.2406 -END
692.2407 -
692.2408 -STRINGTABLE
692.2409 -BEGIN
692.2410 -    IDS_UNSUPPORTED_VBA_SGM "Unsupported VisualBoyAdvance save game version %d"
692.2411 -    IDS_CANNOT_LOAD_SGM     "Cannot load save game for %s"
692.2412 -    IDS_SAVE_GAME_NOT_USING_BIOS "Save game is not using the BIOS file"
692.2413 -    IDS_SAVE_GAME_USING_BIOS "Save game is using the BIOS file"
692.2414 -    IDS_UNSUPPORTED_SAVE_TYPE "Unsupported save type %d"
692.2415 -    IDS_CANNOT_OPEN_FILE    "Cannot open file %s"
692.2416 -    IDS_BAD_ZIP_FILE        "Bad ZIP file %s"
692.2417 -    IDS_NO_IMAGE_ON_ZIP     "No image found on ZIP file %s"
692.2418 -    IDS_ERROR_OPENING_IMAGE "Error opening image %s"
692.2419 -    IDS_ERROR_READING_IMAGE "Error reading image %s"
692.2420 -    IDS_UNSUPPORTED_BIOS_FUNCTION 
692.2421 -                            "Unsupported BIOS function %02x called from %08x. A BIOS file is needed in order to get correct behaviour."
692.2422 -    IDS_INVALID_BIOS_FILE_SIZE "Invalid BIOS file size"
692.2423 -    IDS_INVALID_CHEAT_CODE  "Invalid cheat code '%s'. Supported formats are:\nXXXXXXXX:YY, XXXXXXXX:YYYY, XXXXXXXX:YYYYYYYY."
692.2424 -    IDS_UNKNOWN_ARM_OPCDOE  "Unimplemented opcode %08x from %08x"
692.2425 -    IDS_UNKNOWN_THUMB_OPCODE "Unknown opcode %04x from %08x"
692.2426 -END
692.2427 -
692.2428 -STRINGTABLE
692.2429 -BEGIN
692.2430 -    IDS_ERROR_CREATING_FILE "Error creating file %s"
692.2431 -    IDS_FAILED_TO_READ_SGM  "Failed to read complete save game %s (%d)"
692.2432 -    IDS_FAILED_TO_READ_RTC  "Failed to read RTC from save game %s (continuing)"
692.2433 -    IDS_UNSUPPORTED_VB_SGM  "Unsupported VisualBoy save game version %d"
692.2434 -    IDS_CANNOT_LOAD_SGM_FOR "Cannot load save game for %s. Playing %s"
692.2435 -    IDS_ERROR_OPENING_IMAGE_FROM "Error opening image %s from zip file %s"
692.2436 -    IDS_ERROR_READING_IMAGE_FROM "Error reading image %s from zip file %s"
692.2437 -    IDS_UNSUPPORTED_ROM_SIZE "Unsupported rom size %02x"
692.2438 -    IDS_UNSUPPORTED_RAM_SIZE "Unsupported ram size %02x"
692.2439 -    IDS_UNKNOWN_CARTRIDGE_TYPE "Unknown cartridge type %02x"
692.2440 -    IDS_MAXIMUM_NUMBER_OF_CHEATS "Maximum number of cheats reached."
692.2441 -    IDS_INVALID_GAMESHARK_CODE "Invalid GameShark code: %s"
692.2442 -    IDS_INVALID_GAMEGENIE_CODE "Invalid GameGenie code: %s"
692.2443 -    IDS_INVALID_CHEAT_TO_REMOVE "Invalid cheat to remove %d"
692.2444 -    IDS_INVALID_CHEAT_CODE_ADDRESS "Invalid cheat code address: %08x"
692.2445 -    IDS_UNSUPPORTED_CHEAT_LIST_VERSION "Unsupported cheat list version %d"
692.2446 -END
692.2447 -
692.2448 -STRINGTABLE
692.2449 -BEGIN
692.2450 -    IDS_DIRECTX_7_REQUIRED  "DirectX 7.0 or greater is required to run.\nDownload at http://www.microsoft.com/directx.\n\nError found at: %s"
692.2451 -    IDS_DISABLING_VIDEO_MEMORY "Disabling Use Video Memory setting"
692.2452 -    IDS_SETTING_WILL_BE_EFFECTIVE 
692.2453 -                            "Setting will be effective the next time you start the emulator"
692.2454 -    IDS_DISABLING_EMULATION_ONLY "Disabling Emulation Only setting"
692.2455 -    IDS_FAILED_TO_OPEN_FILE "Failed to open file %s"
692.2456 -    IDS_FAILED_TO_READ_ZIP_DIR "Failed to read zip directory for file %s"
692.2457 -    IDS_UNSUPPORTED_FILE_TYPE "The file ""%s"" is an unsupported type."
692.2458 -    IDS_CANNOT_CREATE_DIRECTSOUND "Cannot create DirectSound %08x"
692.2459 -    IDS_CANNOT_SETCOOPERATIVELEVEL "Cannot SetCooperativeLevel %08x"
692.2460 -    IDS_CANNOT_CREATESOUNDBUFFER "Cannot CreateSoundBuffer %08x"
692.2461 -    IDS_CANNOT_SETFORMAT_PRIMARY "Cannot SetFormat for primary %08x"
692.2462 -    IDS_CANNOT_CREATESOUNDBUFFER_SEC "Cannot CreateSoundBuffer secondary %08x"
692.2463 -    IDS_CANNOT_PLAY_PRIMARY "Cannot Play primary %08x"
692.2464 -    IDS_SEARCH_PRODUCED_TOO_MANY 
692.2465 -                            "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches."
692.2466 -    IDS_NUMBER_CANNOT_BE_EMPTY "Number cannot be empty"
692.2467 -    IDS_INVALID_ADDRESS     "Invalid address: %08x"
692.2468 -END
692.2469 -
692.2470 -STRINGTABLE
692.2471 -BEGIN
692.2472 -    IDS_MISALIGNED_HALFWORD "Misaligned half-word address: %08x"
692.2473 -    IDS_MISALIGNED_WORD     "Misaligned word address: %08x"
692.2474 -    IDS_VALUE_CANNOT_BE_EMPTY "Value cannot be empty"
692.2475 -    IDS_ERROR_ON_STARTDOC   "Error on StartDoc"
692.2476 -    IDS_ERROR_ON_STARTPAGE  "Error on StartPage"
692.2477 -    IDS_ERROR_PRINTING_ON_STRETCH "Error printing on StretchDIBits"
692.2478 -    IDS_ERROR_ON_ENDPAGE    "Error on EndPage"
692.2479 -    IDS_ERROR_ON_ENDDOC     "Error on EndDoc"
692.2480 -    IDS_ERROR               "Error"
692.2481 -    IDS_JOY_LEFT            "Joy %d Left"
692.2482 -    IDS_JOY_RIGHT           "Joy %d Right"
692.2483 -    IDS_JOY_UP              "Joy %d Up"
692.2484 -    IDS_JOY_DOWN            "Joy %d Down"
692.2485 -    IDS_JOY_BUTTON          "Joy %d %s"
692.2486 -END
692.2487 -
692.2488 -STRINGTABLE
692.2489 -BEGIN
692.2490 -    IDS_SELECT_BIOS_FILE    "Select BIOS file"
692.2491 -    IDS_RESET               "Reset"
692.2492 -    IDS_AUTOFIRE_A_DISABLED "turbo A off"
692.2493 -    IDS_AUTOFIRE_A          "turbo A on"
692.2494 -    IDS_AUTOFIRE_B_DISABLED "turbo B off"
692.2495 -    IDS_AUTOFIRE_B          "turbo B on"
692.2496 -    IDS_AUTOFIRE_L_DISABLED "turbo L off"
692.2497 -    IDS_AUTOFIRE_L          "turbo L on"
692.2498 -    IDS_AUTOFIRE_R_DISABLED "turbo R off"
692.2499 -    IDS_AUTOFIRE_R          "turbo R on"
692.2500 -    IDS_SELECT_ROM          "Select ROM"
692.2501 -    IDS_SELECT_SAVE_GAME_NAME "Select save game name"
692.2502 -    IDS_LOADED_STATE        "Loaded state"
692.2503 -    IDS_LOADED_STATE_N      "Loaded %d"
692.2504 -END
692.2505 -
692.2506 -STRINGTABLE
692.2507 -BEGIN
692.2508 -    IDS_WROTE_STATE         "Saved state"
692.2509 -    IDS_WROTE_STATE_N       "Saved %d"
692.2510 -    IDS_LOADED_BATTERY      "Loaded battery"
692.2511 -    IDS_SELECT_CAPTURE_NAME "Select screen capture name"
692.2512 -    IDS_SCREEN_CAPTURE      "Screen capture"
692.2513 -    IDS_ADDRESS             "Address"
692.2514 -    IDS_OLD_VALUE           "Old Value"
692.2515 -    IDS_NEW_VALUE           "New Value"
692.2516 -    IDS_ADD_CHEAT_CODE      "Add cheat code"
692.2517 -    IDS_CODE                "Code"
692.2518 -    IDS_DESCRIPTION         "Description"
692.2519 -    IDS_STATUS              "Status"
692.2520 -    IDS_ADD_GG_CODE         "Add GameGenie code"
692.2521 -    IDS_ADD_GS_CODE         "Add GameShark code"
692.2522 -    IDS_POCKET_PRINTER      "Pocket Printer"
692.2523 -    IDS_UNKNOWN             "Unknown"
692.2524 -END
692.2525 -
692.2526 -STRINGTABLE
692.2527 -BEGIN
692.2528 -    IDS_NONE                "None"
692.2529 -    IDS_FAILED_TO_LOAD_LIBRARY "Failed to load library %s"
692.2530 -    IDS_FAILED_TO_GET_LOCINFO "Failed to get locale information"
692.2531 -    IDS_SELECT_CHEAT_LIST_NAME "Select cheat list name"
692.2532 -    IDS_FILTER_BIOS         "Gameboy Advance_*.bin;*.agb;*.gba;*.bios;*.zip;*.z;*.gz;*.tar_All Files_*.*__"
692.2533 -    IDS_FILTER_ROM          "All Gameboy / Gameboy Advance_*.bin;*.agb;*.gba;*.mb;*.elf;*.gb;*.sgb;*.cgb;*.gbc;*.zip;*.z;*.gz;*.7z;*.rar;*.lzma;*.bz2;*.bzip2;*.tar_All GB / GBA (uncompressed only)_*.bin;*.agb;*.gba;*.mb;*.elf;*.gb;*.sgb;*.cgb;*.gbc_Gameboy Advance (uncompressed only)_*.bin;*.agb;*.gba_Gameboy (uncompressed only)_*.gb;*.sgb;*.cgb;*.gbc_Archive Files_*.zip;*.z;*.gz;*.7z;*.rar;*.lzma;*.bz2;*.bzip2;*.tar_All Files_*.*__"
692.2534 -    IDS_FILTER_SGM          "VisualBoyAdvance Save Game_*.sgm_All Files_*.*__"
692.2535 -    IDS_FILTER_CHEAT_LIST   "VisualBoyAdvance Cheat List_*.clt_All Files_*.*__"
692.2536 -    IDS_FILTER_PNG          "PNG Image_*.png_BMP Image_*.bmp_All Files_*.*__"
692.2537 -    IDS_LOADED_CHEATS       "Loaded cheats"
692.2538 -    IDS_ERROR_DISP_COLOR    "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode."
692.2539 -    IDS_ADD_GSA_CODE        "Add GamesharkAdvance code"
692.2540 -    IDS_FILTER_SPS          "Gameshark Snapshot_*.sps_All Files_*.*__"
692.2541 -    IDS_SELECT_SNAPSHOT_FILE "Select snapshot file"
692.2542 -    IDS_FILTER_SAV          "Battery file_*.sav_Flash save_*.dat_All Files_*.*__"
692.2543 -    IDS_SELECT_BATTERY_FILE "Select battery file"
692.2544 -END
692.2545 -
692.2546 -STRINGTABLE
692.2547 -BEGIN
692.2548 -    IDS_UNSUPPORTED_CHEAT_LIST_TYPE "Unsupported cheat list type %d"
692.2549 -    IDS_INVALID_GSA_CODE    "Invalid GSA code. Format is XXXXXXXXYYYYYYYY."
692.2550 -    IDS_CANNOT_IMPORT_SNAPSHOT_FOR 
692.2551 -                            "Cannot import snapshot for %s. Current game is %s"
692.2552 -    IDS_UNSUPPORTED_SNAPSHOT_FILE "Unsupported snapshot file %s"
692.2553 -    IDS_UNSUPPORTED_ARM_MODE "Unsupported ARM mode %02x"
692.2554 -    IDS_UNSUPPORTED_CODE_FILE "Unsupported code file %s"
692.2555 -    IDS_GSA_CODE_WARNING    "Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly."
692.2556 -    IDS_INVALID_CBA_CODE    "Invalid CBA code. Format is XXXXXXXX YYYY."
692.2557 -    IDS_CBA_CODE_WARNING    "Warning: Codes seem to be for a different game.\nCodes may not work correctly."
692.2558 -    IDS_OUT_OF_MEMORY       "Failed to allocate memory for %s"
692.2559 -END
692.2560 -
692.2561 -STRINGTABLE
692.2562 -BEGIN
692.2563 -    IDS_FILTER_GBS          "Gameboy Snapshot_*.gbs_All Files_*.*__"
692.2564 -    IDS_FILTER_GCF          "Gameshark Code File_*.gcf_All Files_*.*__"
692.2565 -    IDS_SELECT_CODE_FILE    "Select code file"
692.2566 -    IDS_SAVE_WILL_BE_LOST   "Importing a snapshot file will erase any saved games and reset the emulator. Do you want to continue?"
692.2567 -    IDS_CONFIRM_ACTION      "Please confirm action"
692.2568 -    IDS_CODES_WILL_BE_LOST  "Importing a code file will erase any entered codes. Do you want to continue?"
692.2569 -    IDS_FILTER_SPC          "Gameshark Code File_*.spc;*.xpc_All Files_*.*__"
692.2570 -    IDS_ADD_CBA_CODE        "Add CodeBreakerAdvance code"
692.2571 -    IDS_FILTER_WAV          "Wave file_*.wav_All Files_*.*__"
692.2572 -    IDS_SELECT_WAV_NAME     "Select wave file name"
692.2573 -    IDS_FILTER_GBROM        "All Gameboy_*.gb;*.sgb;*.cgb;*.gbc;*.zip;*.z;*.gz;*.7z;*.rar;*.lzma;*.bz2;*.bzip2;*.tar_Gameboy_*.gb_Super Gameboy_*.sgb_Color Gameboy_*.cgb;*.gbc_All Files_*.*__"
692.2574 -    IDS_FILTER_PAL          "Windows Palette (*.PAL)_*.pal_PaintShop Palette (*.PAL)_*.pal_Adobe Color Table (*.ACT)_*.act_All Files_*.*__"
692.2575 -    IDS_SELECT_PALETTE_NAME "Select palette name:"
692.2576 -    IDS_SEARCH_PRODUCED_NO_RESULTS "Search produced no results."
692.2577 -    IDS_ERROR_BINDING       "Error binding socket. Port probably in use."
692.2578 -    IDS_ERROR_LISTENING     "Error listening on socket."
692.2579 -END
692.2580 -
692.2581 -STRINGTABLE
692.2582 -BEGIN
692.2583 -    IDS_ERROR_CREATING_SOCKET "Error creating socket."
692.2584 -    IDS_ACK_NOT_RECEIVED    "ACK not received from GDB."
692.2585 -    IDS_ERROR_NOT_GBA_IMAGE "Error: not a GBA image."
692.2586 -    IDS_EEPROM_NOT_SUPPORTED "EEPROM saves cannot be exported."
692.2587 -    IDS_FILTER_DUMP         "Memory Dump_*.dmp_All Files_*.*__"
692.2588 -    IDS_SELECT_DUMP_FILE    "Select dump file name"
692.2589 -    IDS_FILTER_AVI          "AVI File_*.avi_All Files_*.*__"
692.2590 -    IDS_SELECT_AVI_NAME     "Select AVI file name"
692.2591 -    IDS_INVALID_THROTTLE_VALUE 
692.2592 -                            "Invalid throttle value. Please enter a number between 5 and 1000."
692.2593 -    IDS_FILTER_INI          "Skin INI File_*.ini_All Files_*.*__"
692.2594 -    IDS_SELECT_SKIN_FILE    "Select the skin file name"
692.2595 -    IDS_FILTER_MOVIE        "VisualBoyAdvance Movie (.vbm)_*.vbm;*.zip;*.z;*.gz;*.7z;*.rar;*.lzma;*.bz2;*.bzip2;*.tar_VisualBoyAdvance Movie (uncompressed only)_*.vbm_Archive Files_*.zip;*.z;*.gz;*.7z;*.rar;*.lzma;*.bz2;*.bzip2;*.tar_All Files_*.*__"
692.2596 -    IDS_SELECT_MOVIE_NAME   "Select movie name"
692.2597 -    IDS_BUG_REPORT          "The bug report information is now available on the Windows Clipboard. Please paste it into any bug report made by email or on forums to help solve problems more easily."
692.2598 -    IDS_UNSUPPORTED_MOVIE_VERSION "Unsupported movie version %d."
692.2599 -    IDS_END_OF_MOVIE        "end of movie"
692.2600 -END
692.2601 -
692.2602 -STRINGTABLE
692.2603 -BEGIN
692.2604 -    IDS_INVALID_INTERVAL_VALUE 
692.2605 -                            "Invalid rewind interval value. Please enter a number between 0 and 600 seconds."
692.2606 -    IDS_REGISTRY            "VisualBoyAdvance no longer uses the registry to store its settings. Your previous settings have been exported into the file: %s"
692.2607 -    IDS_MOVIE_PLAY          "Playing a movie will load a save state which may erase your previous battery saves. Please be sure to have a saved state if you don't want to loose any previous data."
692.2608 -    IDS_AUTOFIRE_DISABLED   "autofire off"
692.2609 -    IDS_AUTOFIRE_ALREADY_DISABLED "autofire already off"
692.2610 -    IDS_AUTOFIRE_START_DISABLED "turbo Start off"
692.2611 -    IDS_AUTOFIRE_START      "turbo Start on"
692.2612 -    IDS_AUTOFIRE_SELECT_DISABLED "turbo Select off"
692.2613 -    IDS_AUTOFIRE_SELECT     "turbo Select on"
692.2614 -    IDS_AUTOFIRE_UP_DISABLED "turbo Up off"
692.2615 -    IDS_AUTOFIRE_UP         "turbo Up on"
692.2616 -    IDS_AUTOFIRE_DOWN_DISABLED "turbo Down off"
692.2617 -    IDS_AUTOFIRE_DOWN       "turbo Down on"
692.2618 -    IDS_AUTOFIRE_LEFT_DISABLED "turbo Left off"
692.2619 -    IDS_AUTOFIRE_LEFT       "turbo Left on"
692.2620 -    IDS_AUTOFIRE_RIGHT_DISABLED "turbo Right off"
692.2621 -END
692.2622 -
692.2623 -STRINGTABLE
692.2624 -BEGIN
692.2625 -    IDS_AUTOFIRE_RIGHT      "turbo Right on"
692.2626 -    IDS_RERECORDED_STATE_N  "Re-record from %d"
692.2627 -    IDS_REPLAYED_STATE_N    "Rewind to %d"
692.2628 -END
692.2629 -
692.2630 -STRINGTABLE
692.2631 -BEGIN
692.2632 -    IDS_FILTER_LUA          "Lua Script (.lua)_*.lua_All Files_*.*__"
692.2633 -    IDS_SELECT_LUA_NAME     "Select Lua script file name"
692.2634 -    IDS_SELECT_LUA_DIR      "Select Lua script file directory:"
692.2635 -    IDS_SELECT_MOVIE_DIR    "Select movie directory:"
692.2636 -    IDS_SELECT_ROM_DIR      "Select GBA ROM directory:"
692.2637 -    IDS_SELECT_GBXROM_DIR   "Select GBx ROM directory:"
692.2638 -    IDS_SELECT_BATTERY_DIR  "Select Battery directory:"
692.2639 -    IDS_SELECT_SAVE_DIR     "Select Save Directory:"
692.2640 -    IDS_SELECT_CAPTURE_DIR  "Select Capture directory:"
692.2641 -END
692.2642 -
692.2643 -STRINGTABLE
692.2644 -BEGIN
692.2645 -    IDS_SELECT_AVI_DIR      "Select AVI recording directory:"
692.2646 -    IDS_SELECT_WAV_DIR      "Select Sound recording directory:"
692.2647 -    IDS_SELECT_CHEAT_DIR    "Select Cheat list directory:"
692.2648 -    IDS_SELECT_WATCH_DIR    "Select Memory watch file directory:"
692.2649 -    IDS_SELECT_IPS_DIR      "Select IPS directory:"
692.2650 -    IDS_SELECT_PLUGIN_DIR   "Select Plugin directory:"
692.2651 -END
692.2652 -
692.2653 -#endif    // English (United States) resources
692.2654 -/////////////////////////////////////////////////////////////////////////////
692.2655 -
692.2656 -
692.2657 -
692.2658 -#ifndef APSTUDIO_INVOKED
692.2659 -/////////////////////////////////////////////////////////////////////////////
692.2660 -//
692.2661 -// Generated from the TEXTINCLUDE 3 resource.
692.2662 -//
692.2663 -
692.2664 -
692.2665 -/////////////////////////////////////////////////////////////////////////////
692.2666 -#endif    // not APSTUDIO_INVOKED
692.2667 -
   693.1 --- a/src/win32/vba.rc2	Sat Mar 03 10:54:39 2012 -0600
   693.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   693.3 @@ -1,50 +0,0 @@
   693.4 -
   693.5 -// what the hell? all this file does is cause enigmatic build errors...
   693.6 -
   693.7 -/*
   693.8 -#ifndef _MAC
   693.9 -#include "../AutoBuild.h"
  693.10 -/////////////////////////////////////////////////////////////////////////////
  693.11 -//
  693.12 -// Version
  693.13 -//
  693.14 -
  693.15 -VS_VERSION_INFO VERSIONINFO
  693.16 - FILEVERSION FILEVER
  693.17 - PRODUCTVERSION PRODUCTVER
  693.18 - FILEFLAGSMASK 0x3fL
  693.19 -#ifdef _DEBUG
  693.20 - FILEFLAGS 0x29L
  693.21 -#else
  693.22 - FILEFLAGS 0x28L
  693.23 -#endif
  693.24 - FILEOS 0x40004L
  693.25 - FILETYPE 0x1L
  693.26 - FILESUBTYPE 0x0L
  693.27 -BEGIN
  693.28 -    BLOCK "StringFileInfo"
  693.29 -    BEGIN
  693.30 -        BLOCK "040904b0"
  693.31 -        BEGIN
  693.32 -            VALUE "Comments", "VisualBoyAdvance comes with NO WARRANTY. Use it at your own risk.\0"
  693.33 -            VALUE "CompanyName", "None\0"
  693.34 -            VALUE "FileDescription", "VisualBoyAdvance emulator\0"
  693.35 -            VALUE "FileVersion", STRFILEVER
  693.36 -            VALUE "InternalName", "VisualBoyAdvance\0"
  693.37 -            VALUE "LegalCopyright", "Copyright © 2004 Forgotten and the VBA team\0"
  693.38 -            VALUE "LegalTrademarks", "\0"
  693.39 -            VALUE "OriginalFilename", "VisualBoyAdvance.exe\0"
  693.40 -            VALUE "PrivateBuild", "0\0"
  693.41 -            VALUE "ProductName", "VisualBoyAdvance emulator\0"
  693.42 -            VALUE "ProductVersion", STRPRODUCTVER
  693.43 -            VALUE "SpecialBuild", "0\0"
  693.44 -        END
  693.45 -    END
  693.46 -    BLOCK "VarFileInfo"
  693.47 -    BEGIN
  693.48 -        VALUE "Translation", 0x409, 1200
  693.49 -    END
  693.50 -END
  693.51 -
  693.52 -#endif    // !_MAC
  693.53 -*/
  693.54 \ No newline at end of file