zemu 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/zemu/config.rb +312 -0
- data/lib/zemu/instance.rb +179 -0
- data/lib/zemu.rb +172 -0
- data/src/debug.c +118 -0
- data/src/debug.h +30 -0
- data/src/external/Z/API/Z/ABIs/generic/allocator.h +36 -0
- data/src/external/Z/API/Z/ABIs/generic/cipher.h +47 -0
- data/src/external/Z/API/Z/ABIs/generic/data codec.h +33 -0
- data/src/external/Z/API/Z/ABIs/generic/emulation.h +103 -0
- data/src/external/Z/API/Z/ABIs/generic/hash function.h +33 -0
- data/src/external/Z/API/Z/ABIs/generic/module.h +33 -0
- data/src/external/Z/API/Z/ABIs/generic/wave codec.h +40 -0
- data/src/external/Z/API/Z/classes/base/InitializerList.hpp +34 -0
- data/src/external/Z/API/Z/classes/base/OpaqueFunctionPointer.hpp +26 -0
- data/src/external/Z/API/Z/classes/base/OpaqueMemberFunctionPointer.hpp +26 -0
- data/src/external/Z/API/Z/classes/base/Pair.hpp +46 -0
- data/src/external/Z/API/Z/classes/base/Range.hpp +111 -0
- data/src/external/Z/API/Z/classes/base/SizedString.hpp +66 -0
- data/src/external/Z/API/Z/classes/base/Status.hpp +89 -0
- data/src/external/Z/API/Z/classes/base/Symbol.hpp +39 -0
- data/src/external/Z/API/Z/classes/base/Tuple.hpp +111 -0
- data/src/external/Z/API/Z/classes/base/Value2D.hpp +389 -0
- data/src/external/Z/API/Z/classes/base/Value3D.hpp +368 -0
- data/src/external/Z/API/Z/classes/buffering/RingBuffer.hpp +93 -0
- data/src/external/Z/API/Z/classes/buffering/TripleBuffer.hpp +68 -0
- data/src/external/Z/API/Z/classes/functional/Functor.hpp +265 -0
- data/src/external/Z/API/Z/classes/functional/MemberFunction.hpp +98 -0
- data/src/external/Z/API/Z/classes/functional/ObjectMemberFunction.hpp +172 -0
- data/src/external/Z/API/Z/classes/functional/ObjectSelector.hpp +219 -0
- data/src/external/Z/API/Z/classes/functional/Selector.hpp +146 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/AABB.hpp +81 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/AABR.hpp +685 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Box.hpp +219 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Circle.hpp +80 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Line2D.hpp +93 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Line3D.hpp +80 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Rectangle.hpp +675 -0
- data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Sphere.hpp +0 -0
- data/src/external/Z/API/Z/classes/memory/Shared.hpp +90 -0
- data/src/external/Z/API/Z/constants/base.h +35 -0
- data/src/external/Z/API/Z/constants/chemical elements.h +6385 -0
- data/src/external/Z/API/Z/constants/numbers.h +963 -0
- data/src/external/Z/API/Z/constants/version.h +15 -0
- data/src/external/Z/API/Z/formats/character set/ASCII.h +158 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP437.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP737.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP775.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP850.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP852.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP855.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP857.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP858.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP860.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP861.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP862.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP863.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP864.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP865.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP866.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP869.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP872.h +159 -0
- data/src/external/Z/API/Z/formats/character set/DOS CP874.h +159 -0
- data/src/external/Z/API/Z/formats/character set/Unicode.h +30119 -0
- data/src/external/Z/API/Z/formats/data model/I16LP32.h +19 -0
- data/src/external/Z/API/Z/formats/data model/ILP32.h +19 -0
- data/src/external/Z/API/Z/formats/data model/ILP64.h +19 -0
- data/src/external/Z/API/Z/formats/data model/IP16L32.h +19 -0
- data/src/external/Z/API/Z/formats/data model/LLP64.h +19 -0
- data/src/external/Z/API/Z/formats/data model/LP32.h +19 -0
- data/src/external/Z/API/Z/formats/data model/LP64.h +19 -0
- data/src/external/Z/API/Z/formats/data model/SILP64.h +19 -0
- data/src/external/Z/API/Z/formats/file system/FAT12.h +61 -0
- data/src/external/Z/API/Z/formats/floating-point/IEEE 754.h +141 -0
- data/src/external/Z/API/Z/formats/floating-point/x87.h +74 -0
- data/src/external/Z/API/Z/formats/image/ICNS.h +39 -0
- data/src/external/Z/API/Z/formats/keymap/Mac OS.h +284 -0
- data/src/external/Z/API/Z/formats/keymap/Z.h +141 -0
- data/src/external/Z/API/Z/formats/multimedia/Creative Voice.h +106 -0
- data/src/external/Z/API/Z/formats/multimedia/Microsoft Wave.h +49 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ACH.h +44 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/FRZ.h +54 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/PRG.h +33 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SEM.h +46 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SIT.h +34 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SNA.h +117 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SNP.h +37 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SP.h +62 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/Z80.h +117 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ZX.h +56 -0
- data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ZX82.h +70 -0
- data/src/external/Z/API/Z/formats/storage medium image/NES Game Pak/UNIF.h +26 -0
- data/src/external/Z/API/Z/formats/storage medium image/NES Game Pak/iNES.h +76 -0
- data/src/external/Z/API/Z/formats/storage medium image/audio/TAP.h +25 -0
- data/src/external/Z/API/Z/formats/storage medium image/audio/TZX.h +1185 -0
- data/src/external/Z/API/Z/formats/storage medium image/audio/Warajevo TAP.h +32 -0
- data/src/external/Z/API/Z/formats/storage medium image/floppy disk/FDI.h +45 -0
- data/src/external/Z/API/Z/functions/base/Z2D.h +583 -0
- data/src/external/Z/API/Z/functions/base/Z3D.h +712 -0
- data/src/external/Z/API/Z/functions/base/ZRange.h +137 -0
- data/src/external/Z/API/Z/functions/base/all.h +16 -0
- data/src/external/Z/API/Z/functions/base/casting.hpp +37 -0
- data/src/external/Z/API/Z/functions/base/character.h +38 -0
- data/src/external/Z/API/Z/functions/base/constructors.h +326 -0
- data/src/external/Z/API/Z/functions/base/structure.hpp +26 -0
- data/src/external/Z/API/Z/functions/base/type.hpp +60 -0
- data/src/external/Z/API/Z/functions/base/value.h +1901 -0
- data/src/external/Z/API/Z/functions/base/value.hpp +112 -0
- data/src/external/Z/API/Z/functions/buffering/ZRingBuffer.h +85 -0
- data/src/external/Z/API/Z/functions/buffering/ZTripleBuffer.h +65 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/Z2DLine.h +179 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/Z3DLine.h +168 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZAABB.h +361 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZAABR.h +1081 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZBox.h +340 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZCircle.h +142 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZRectangle.h +1267 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZSphere.h +156 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/all.h +18 -0
- data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/constructors.h +620 -0
- data/src/external/Z/API/Z/functions/time/date.h +29 -0
- data/src/external/Z/API/Z/hardware/CPU/architecture/6502.h +90 -0
- data/src/external/Z/API/Z/hardware/CPU/architecture/Z80.h +245 -0
- data/src/external/Z/API/Z/hardware/CPU/architecture/i4004.h +37 -0
- data/src/external/Z/API/Z/hardware/PSG/General Instrument/AY-3-891x.h +180 -0
- data/src/external/Z/API/Z/hardware/VDC/Ricoh/RP2C0x.h +625 -0
- data/src/external/Z/API/Z/hardware/bus/AGP.h +24 -0
- data/src/external/Z/API/Z/hardware/bus/USB.h +510 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Inves Spectrum +.h +47 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Pentagon.h +13 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Scorpion.h +13 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum + 128K.h +158 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +.h +82 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +2.h +13 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +2A.h +13 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +3.h +13 -0
- data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum.h +109 -0
- data/src/external/Z/API/Z/hardware/machine/model/console/Nintendo Entertainment System/NES-001 (NTSC).h +29 -0
- data/src/external/Z/API/Z/hardware/machine/model/console/Nintendo Entertainment System/NES-001 (PAL).h +29 -0
- data/src/external/Z/API/Z/hardware/machine/platform/computer/ZX Spectrum.h +405 -0
- data/src/external/Z/API/Z/hardware/machine/platform/console/Game Boy.h +49 -0
- data/src/external/Z/API/Z/hardware/machine/platform/console/Nintendo Entertainment System.h +350 -0
- data/src/external/Z/API/Z/hardware/storage medium/ROM cartridge/SNES Game Pak.h +238 -0
- data/src/external/Z/API/Z/inspection/C/completion.h +178 -0
- data/src/external/Z/API/Z/inspection/C/modules/C11.h +41 -0
- data/src/external/Z/API/Z/inspection/C/modules/C18.h +13 -0
- data/src/external/Z/API/Z/inspection/C/modules/C89.h +19 -0
- data/src/external/Z/API/Z/inspection/C/modules/C90.h +13 -0
- data/src/external/Z/API/Z/inspection/C/modules/C94.h +15 -0
- data/src/external/Z/API/Z/inspection/C/modules/C99.h +29 -0
- data/src/external/Z/API/Z/inspection/C/modules/KR C.h +19 -0
- data/src/external/Z/API/Z/inspection/C++/completion.h +512 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++03.h +15 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++11.h +80 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++14.h +26 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++17.h +55 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++85.h +11 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++89.h +13 -0
- data/src/external/Z/API/Z/inspection/C++/modules/C++98.h +17 -0
- data/src/external/Z/API/Z/inspection/C++.h +78 -0
- data/src/external/Z/API/Z/inspection/C.h +79 -0
- data/src/external/Z/API/Z/inspection/CPU/completion.h +56 -0
- data/src/external/Z/API/Z/inspection/CPU/detection.h +714 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/6502.h +25 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/AArch32.h +32 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/AArch64.h +32 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/Z80.h +26 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/x86-32.h +31 -0
- data/src/external/Z/API/Z/inspection/CPU/modules/x86-64.h +312 -0
- data/src/external/Z/API/Z/inspection/CPU.h +209 -0
- data/src/external/Z/API/Z/inspection/OS/completion.h +36 -0
- data/src/external/Z/API/Z/inspection/OS/detection.h +768 -0
- data/src/external/Z/API/Z/inspection/OS/modules/Linux.h +22 -0
- data/src/external/Z/API/Z/inspection/OS/modules/MS-DOS.h +16 -0
- data/src/external/Z/API/Z/inspection/OS/modules/Mac OS X.h +23 -0
- data/src/external/Z/API/Z/inspection/OS/modules/Windows.h +19 -0
- data/src/external/Z/API/Z/inspection/OS/modules/iPhone OS.h +23 -0
- data/src/external/Z/API/Z/inspection/OS.h +236 -0
- data/src/external/Z/API/Z/inspection/Objective-C/completion.h +8 -0
- data/src/external/Z/API/Z/inspection/Objective-C/modules/Objective-C v1.0.h +11 -0
- data/src/external/Z/API/Z/inspection/Objective-C/modules/Objective-C v2.0.h +15 -0
- data/src/external/Z/API/Z/inspection/Objective-C.h +51 -0
- data/src/external/Z/API/Z/inspection/Z.h +19 -0
- data/src/external/Z/API/Z/inspection/build.h +22 -0
- data/src/external/Z/API/Z/inspection/character set.h +66 -0
- data/src/external/Z/API/Z/inspection/compiler/completion.h +2885 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/Apple LLVM.h +26 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/Clang.h +1664 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/GCC.h +1366 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/SCCZ80.h +473 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/Visual C++.h +606 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/cc65.h +529 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/generic.h +13 -0
- data/src/external/Z/API/Z/inspection/compiler/modules/template.h +650 -0
- data/src/external/Z/API/Z/inspection/compiler.h +299 -0
- data/src/external/Z/API/Z/inspection/data model/completion.h +128 -0
- data/src/external/Z/API/Z/inspection/data model/deduction.h +9 -0
- data/src/external/Z/API/Z/inspection/data model/detection.h +45 -0
- data/src/external/Z/API/Z/inspection/data model.h +362 -0
- data/src/external/Z/API/Z/inspection/floating-point/completion.h +50 -0
- data/src/external/Z/API/Z/inspection/floating-point.h +324 -0
- data/src/external/Z/API/Z/inspection/language.h +163 -0
- data/src/external/Z/API/Z/inspection/platform/detection.h +9 -0
- data/src/external/Z/API/Z/inspection/platform.h +29 -0
- data/src/external/Z/API/Z/keys/C++.h +27 -0
- data/src/external/Z/API/Z/keys/C.h +29 -0
- data/src/external/Z/API/Z/keys/CPU.h +80 -0
- data/src/external/Z/API/Z/keys/OS.h +182 -0
- data/src/external/Z/API/Z/keys/Objective-C.h +17 -0
- data/src/external/Z/API/Z/keys/chemistry.h +26 -0
- data/src/external/Z/API/Z/keys/compiler.h +178 -0
- data/src/external/Z/API/Z/keys/data model.h +32 -0
- data/src/external/Z/API/Z/keys/endianness.h +24 -0
- data/src/external/Z/API/Z/keys/language.h +21 -0
- data/src/external/Z/API/Z/keys/layout.h +20 -0
- data/src/external/Z/API/Z/keys/mathematics/geometry.h +29 -0
- data/src/external/Z/API/Z/keys/mathematics/number.h +21 -0
- data/src/external/Z/API/Z/keys/order.h +18 -0
- data/src/external/Z/API/Z/keys/platform.h +87 -0
- data/src/external/Z/API/Z/keys/program.h +39 -0
- data/src/external/Z/API/Z/keys/science/chemical elements.h +200 -0
- data/src/external/Z/API/Z/keys/science/electricity.h +18 -0
- data/src/external/Z/API/Z/keys/science/magnetism.h +19 -0
- data/src/external/Z/API/Z/keys/status.h +69 -0
- data/src/external/Z/API/Z/keys/text.h +27 -0
- data/src/external/Z/API/Z/keys/value.h +88 -0
- data/src/external/Z/API/Z/macros/arguments.h +25 -0
- data/src/external/Z/API/Z/macros/casting.h +22 -0
- data/src/external/Z/API/Z/macros/character.h +159 -0
- data/src/external/Z/API/Z/macros/date.h +14 -0
- data/src/external/Z/API/Z/macros/key.h +20 -0
- data/src/external/Z/API/Z/macros/language.h +126 -0
- data/src/external/Z/API/Z/macros/language.hpp +81 -0
- data/src/external/Z/API/Z/macros/members.h +86 -0
- data/src/external/Z/API/Z/macros/pasting.h +308 -0
- data/src/external/Z/API/Z/macros/pointer.h +33 -0
- data/src/external/Z/API/Z/macros/repetition.h +283 -0
- data/src/external/Z/API/Z/macros/structure.h +104 -0
- data/src/external/Z/API/Z/macros/templating.h +407 -0
- data/src/external/Z/API/Z/macros/tokens.h +14 -0
- data/src/external/Z/API/Z/macros/type enumeration.h +43 -0
- data/src/external/Z/API/Z/macros/type selection.hpp +76 -0
- data/src/external/Z/API/Z/macros/value.h +489 -0
- data/src/external/Z/API/Z/macros/variadic pasting.h +21 -0
- data/src/external/Z/API/Z/macros/variadic selection.h +56 -0
- data/src/external/Z/API/Z/macros/variadic.h +46 -0
- data/src/external/Z/API/Z/macros/version.h +17 -0
- data/src/external/Z/API/Z/network/3/IP.h +36 -0
- data/src/external/Z/API/Z/network/4/TCP.h +24 -0
- data/src/external/Z/API/Z/network/4/UDP.h +26 -0
- data/src/external/Z/API/Z/network/7/ED2K.h +104 -0
- data/src/external/Z/API/Z/network/7/HTTP.h +100 -0
- data/src/external/Z/API/Z/traits/SelectType.hpp +71 -0
- data/src/external/Z/API/Z/traits/TernaryType.hpp +20 -0
- data/src/external/Z/API/Z/traits/Type.hpp +4516 -0
- data/src/external/Z/API/Z/traits/TypeCount.hpp +52 -0
- data/src/external/Z/API/Z/traits/TypeList.hpp +376 -0
- data/src/external/Z/API/Z/traits/base.hpp +19 -0
- data/src/external/Z/API/Z/traits/filtering.hpp +30 -0
- data/src/external/Z/API/Z/traits/mathematics.hpp +48 -0
- data/src/external/Z/API/Z/types/arguments.h +19 -0
- data/src/external/Z/API/Z/types/base.h +1655 -0
- data/src/external/Z/API/Z/types/base.hpp +169 -0
- data/src/external/Z/API/Z/types/buffering.h +27 -0
- data/src/external/Z/API/Z/types/mathematics.h +135 -0
- data/src/external/Z/API/Z/types/time.h +23 -0
- data/src/external/Z/COPYING.LESSER +165 -0
- data/src/external/Z/development/Qt Creator/Z.pro +253 -0
- data/src/external/Z/distribution/CocoaPods/Zeta.podspec +18 -0
- data/src/external/Z/distribution/Gentoo Linux/Zeta-0.1.ebuild +22 -0
- data/src/external/Z/distribution/Gentoo Linux/metadata.xml +8 -0
- data/src/external/Z/distribution/Homebrew/Zeta.rb +11 -0
- data/src/external/z80/API/emulation/CPU/Z80.h +201 -0
- data/src/external/z80/README.md +229 -0
- data/src/external/z80/building/premake4.lua +33 -0
- data/src/external/z80/development/Xcode/Z80.xcodeproj/project.pbxproj +520 -0
- data/src/external/z80/sources/Z80.c +1660 -0
- data/src/interrupt.c +6 -0
- data/src/interrupt.h +3 -0
- data/src/io.c.erb +115 -0
- data/src/io.h.erb +18 -0
- data/src/main.c +69 -0
- data/src/memory.c.erb +43 -0
- data/src/memory.h.erb +9 -0
- metadata +329 -0
@@ -0,0 +1,368 @@
|
|
1
|
+
/* Z Kit - classes/base/Value3D.hpp
|
2
|
+
_____ _______________
|
3
|
+
/_ /_/ -_/_ _/ _ |
|
4
|
+
/____/\___/ /__//___/_| Kit
|
5
|
+
Copyright (C) 2006-2018 Manuel Sainz de Baranda y Goñi.
|
6
|
+
Released under the terms of the GNU Lesser General Public License v3. */
|
7
|
+
|
8
|
+
#ifndef _Z_classes_base_Value3D_HPP_
|
9
|
+
#define _Z_classes_base_Value3D_HPP_
|
10
|
+
|
11
|
+
#ifndef _Z_classes_base_Value2D_HPP_
|
12
|
+
# include <Z/classes/base/Value2D.hpp>
|
13
|
+
#endif
|
14
|
+
|
15
|
+
|
16
|
+
#define Z_IMPLEMENTATION_COMMON \
|
17
|
+
\
|
18
|
+
typedef typename ZTypeFixedNumber(Z3D, T) Base; \
|
19
|
+
T x, y, z; \
|
20
|
+
\
|
21
|
+
Z_INLINE Value3D() Z_DEFAULTED({}) \
|
22
|
+
\
|
23
|
+
Z_CT(CPP11) Value3D(T x, T y, T z) : x(x), y(y), z(z) {} \
|
24
|
+
Z_CT(CPP11) Value3D(T x, T y) : x(x), y(y), z(T(0)) {} \
|
25
|
+
Z_CT(CPP11) Value3D(T xyz) : x(xyz), y(xyz), z(xyz) {} \
|
26
|
+
Z_CT(CPP11) Value3D(const Value2D<T> &xy) : x(xy.x), y(xy.y), z(T(0)) {} \
|
27
|
+
Z_CT(CPP11) Value3D(const Value2D<T> &xy, T z) : x(xy.x), y(xy.y), z(z) {} \
|
28
|
+
Z_CT(CPP11) Value3D(T x, const Value2D<T> &yz) : x(x), y(yz.x), z(yz.y) {} \
|
29
|
+
Z_CT(CPP11) Value3D(const Base &other) : x(other.x), y(other.y), z(other.z) {} \
|
30
|
+
\
|
31
|
+
Z_CT(CPP11) operator Boolean() const {return x != T(0) || y != T(0) || z != T(0);} \
|
32
|
+
Z_INLINE operator Base& () const {return *((Base *)this);} \
|
33
|
+
\
|
34
|
+
Z_CT(CPP11) Boolean operator ==(const Value3D &rhs) const {return x == rhs.x && y == rhs.y && z == rhs.z;} \
|
35
|
+
Z_CT(CPP11) Boolean operator !=(const Value3D &rhs) const {return x != rhs.x || y != rhs.y || z != rhs.z;} \
|
36
|
+
Z_CT(CPP11) Boolean operator <=(const Value3D &rhs) const {return x <= rhs.x && y <= rhs.y && z <= rhs.z;} \
|
37
|
+
Z_CT(CPP11) Boolean operator >=(const Value3D &rhs) const {return x >= rhs.x && y >= rhs.y && z >= rhs.z;} \
|
38
|
+
Z_CT(CPP11) Boolean operator > (const Value3D &rhs) const {return x > rhs.x && y > rhs.y && z > rhs.z;} \
|
39
|
+
Z_CT(CPP11) Boolean operator < (const Value3D &rhs) const {return x < rhs.x && y < rhs.y && z < rhs.z;} \
|
40
|
+
\
|
41
|
+
Z_CT(CPP11) Value3D operator +(const Value3D &rhs) const {return Value3D(x + rhs.x, y + rhs.y, z + rhs.z);} \
|
42
|
+
Z_CT(CPP11) Value3D operator -(const Value3D &rhs) const {return Value3D(x - rhs.x, y - rhs.y, z - rhs.z);} \
|
43
|
+
Z_CT(CPP11) Value3D operator *(const Value3D &rhs) const {return Value3D(x * rhs.x, y * rhs.y, z * rhs.z);} \
|
44
|
+
Z_CT(CPP11) Value3D operator /(const Value3D &rhs) const {return Value3D(x / rhs.x, y / rhs.y, z / rhs.z);} \
|
45
|
+
\
|
46
|
+
Z_INLINE Value3D &operator +=(const Value3D &rhs) {return *this = *this + rhs;} \
|
47
|
+
Z_INLINE Value3D &operator -=(const Value3D &rhs) {return *this = *this - rhs;} \
|
48
|
+
Z_INLINE Value3D &operator *=(const Value3D &rhs) {return *this = *this * rhs;} \
|
49
|
+
Z_INLINE Value3D &operator /=(const Value3D &rhs) {return *this = *this / rhs;} \
|
50
|
+
\
|
51
|
+
Z_CT(CPP11) Boolean operator ==(T rhs) const {return x == rhs && y == rhs && z == rhs;} \
|
52
|
+
Z_CT(CPP11) Boolean operator !=(T rhs) const {return x != rhs || y != rhs || z != rhs;} \
|
53
|
+
Z_CT(CPP11) Boolean operator <=(T rhs) const {return x <= rhs && y <= rhs && z <= rhs;} \
|
54
|
+
Z_CT(CPP11) Boolean operator >=(T rhs) const {return x >= rhs && y >= rhs && z >= rhs;} \
|
55
|
+
Z_CT(CPP11) Boolean operator > (T rhs) const {return x > rhs && y > rhs && z > rhs;} \
|
56
|
+
Z_CT(CPP11) Boolean operator < (T rhs) const {return x < rhs && y < rhs && z < rhs;} \
|
57
|
+
\
|
58
|
+
Z_CT(CPP11) Value3D operator +(T rhs) const {return Value3D(x + rhs, y + rhs, z + rhs);} \
|
59
|
+
Z_CT(CPP11) Value3D operator -(T rhs) const {return Value3D(x - rhs, y - rhs, z - rhs);} \
|
60
|
+
Z_CT(CPP11) Value3D operator *(T rhs) const {return Value3D(x * rhs, y * rhs, z * rhs);} \
|
61
|
+
Z_CT(CPP11) Value3D operator /(T rhs) const {return Value3D(x / rhs, y / rhs, z / rhs);} \
|
62
|
+
\
|
63
|
+
Z_INLINE Value3D &operator +=(T rhs) {return *this = *this + rhs;} \
|
64
|
+
Z_INLINE Value3D &operator -=(T rhs) {return *this = *this - rhs;} \
|
65
|
+
Z_INLINE Value3D &operator *=(T rhs) {return *this = *this * rhs;} \
|
66
|
+
Z_INLINE Value3D &operator /=(T rhs) {return *this = *this / rhs;} \
|
67
|
+
\
|
68
|
+
Z_INLINE T operator [](UInt index) const {return ((T *)this)[index];} \
|
69
|
+
Z_INLINE T &operator [](UInt index) {return ((T *)this)[index];} \
|
70
|
+
\
|
71
|
+
Z_CT(CPP11) Value2D<T> xy () const {return Value2D<T>(x, y);} \
|
72
|
+
Z_CT(CPP11) Value2D<T> xz () const {return Value2D<T>(x, z);} \
|
73
|
+
Z_CT(CPP11) Value2D<T> yx () const {return Value2D<T>(y, x);} \
|
74
|
+
Z_CT(CPP11) Value2D<T> yz () const {return Value2D<T>(y, z);} \
|
75
|
+
Z_CT(CPP11) Value2D<T> zx () const {return Value2D<T>(z, x);} \
|
76
|
+
Z_CT(CPP11) Value2D<T> zy () const {return Value2D<T>(z, y);} \
|
77
|
+
Z_CT(CPP11) Value3D xzy() const {return Value3D(x, z, y);} \
|
78
|
+
Z_CT(CPP11) Value3D yxz() const {return Value3D(y, x, z);} \
|
79
|
+
Z_CT(CPP11) Value3D yzx() const {return Value3D(y, z, x);} \
|
80
|
+
Z_CT(CPP11) Value3D zxy() const {return Value3D(z, x, y);} \
|
81
|
+
Z_CT(CPP11) Value3D zyx() const {return Value3D(z, y, x);} \
|
82
|
+
\
|
83
|
+
\
|
84
|
+
Z_CT(CPP11) Value3D clamp(const Value3D &minimum, const Value3D &maximum) const \
|
85
|
+
{ \
|
86
|
+
return Value3D \
|
87
|
+
(Zeta::clamp<T>(x, minimum.x, maximum.x), \
|
88
|
+
Zeta::clamp<T>(y, minimum.y, maximum.y), \
|
89
|
+
Zeta::clamp<T>(z, minimum.z, maximum.z)); \
|
90
|
+
} \
|
91
|
+
\
|
92
|
+
\
|
93
|
+
Z_CT(CPP11) Value3D clamp(T minimum, T maximum) const \
|
94
|
+
{ \
|
95
|
+
return Value3D \
|
96
|
+
(Zeta::clamp<T>(x, minimum, maximum), \
|
97
|
+
Zeta::clamp<T>(y, minimum, maximum), \
|
98
|
+
Zeta::clamp<T>(z, minimum, maximum)); \
|
99
|
+
} \
|
100
|
+
\
|
101
|
+
\
|
102
|
+
Z_CT(CPP11) Value3D cross_product(const Value3D &other) const \
|
103
|
+
{ \
|
104
|
+
return Value3D \
|
105
|
+
(y * other.z - z * other.y, \
|
106
|
+
z * other.x - x * other.z, \
|
107
|
+
x * other.y - y * other.x); \
|
108
|
+
} \
|
109
|
+
\
|
110
|
+
\
|
111
|
+
Z_CT(CPP11) T dot_product(const Value3D &other) const \
|
112
|
+
{return x * other.x + y * other.y + z * other.z;} \
|
113
|
+
\
|
114
|
+
\
|
115
|
+
Z_CT(CPP11) Value3D fit(const Value3D &other) const \
|
116
|
+
{return Value3D(T(0));} /* TODO */ \
|
117
|
+
\
|
118
|
+
\
|
119
|
+
Z_CT(CPP11) Boolean has_zero() const \
|
120
|
+
{return x == T(0) || y == T(0) || z == T(0);} \
|
121
|
+
\
|
122
|
+
\
|
123
|
+
Z_CT(CPP11) T inner_maximum() const \
|
124
|
+
{return Zeta::maximum<T>(Zeta::maximum<T>(x, y), z);} \
|
125
|
+
\
|
126
|
+
\
|
127
|
+
Z_CT(CPP11) T inner_middle() const \
|
128
|
+
{return (x + y + z) / T(3);} \
|
129
|
+
\
|
130
|
+
\
|
131
|
+
Z_CT(CPP11) T inner_minimum() const \
|
132
|
+
{return Zeta::minimum<T>(Zeta::minimum<T>(x, y), z);} \
|
133
|
+
\
|
134
|
+
\
|
135
|
+
Z_CT(CPP11) T inner_product() const \
|
136
|
+
{return x * y * z;} \
|
137
|
+
\
|
138
|
+
\
|
139
|
+
Z_CT(CPP11) T inner_sum() const \
|
140
|
+
{return x + y + z;} \
|
141
|
+
\
|
142
|
+
\
|
143
|
+
Z_CT(CPP11) Boolean is_zero() const \
|
144
|
+
{return x == T(0) && y == T(0) && z == T(0);} \
|
145
|
+
\
|
146
|
+
\
|
147
|
+
Z_CT(CPP11) Value3D maximum(const Value3D &other) const \
|
148
|
+
{ \
|
149
|
+
return Value3D \
|
150
|
+
(Zeta::maximum<T>(x, other.x), \
|
151
|
+
Zeta::maximum<T>(y, other.y), \
|
152
|
+
Zeta::maximum<T>(z, other.z)); \
|
153
|
+
} \
|
154
|
+
\
|
155
|
+
\
|
156
|
+
Z_CT(CPP11) Value3D minimum(const Value3D &other) const \
|
157
|
+
{ \
|
158
|
+
return Value3D \
|
159
|
+
(Zeta::minimum<T>(x, other.x), \
|
160
|
+
Zeta::minimum<T>(y, other.y), \
|
161
|
+
Zeta::minimum<T>(z, other.z)); \
|
162
|
+
} \
|
163
|
+
\
|
164
|
+
\
|
165
|
+
Z_CT(CPP11) Value3D middle(const Value3D &other) const \
|
166
|
+
{ \
|
167
|
+
return Value3D \
|
168
|
+
((x + other.x) / T(2), \
|
169
|
+
(y + other.y) / T(2), \
|
170
|
+
(z + other.z) / T(2)); \
|
171
|
+
} \
|
172
|
+
\
|
173
|
+
\
|
174
|
+
Z_INLINE Value3D rotate_as_axes(Value3D<SInt8> rotation) const \
|
175
|
+
{ \
|
176
|
+
Value3D result = *this; \
|
177
|
+
\
|
178
|
+
if ((rotation.x % 4) & 1) Zeta::swap<T>(&result.y, &result.z); \
|
179
|
+
if ((rotation.y % 4) & 1) Zeta::swap<T>(&result.x, &result.z); \
|
180
|
+
if ((rotation.z % 4) & 1) Zeta::swap<T>(&result.x, &result.y); \
|
181
|
+
return result; \
|
182
|
+
} \
|
183
|
+
\
|
184
|
+
\
|
185
|
+
Z_CT(CPP11) T squared_length() const \
|
186
|
+
{return x * x + y * y + z * z;} \
|
187
|
+
\
|
188
|
+
\
|
189
|
+
Z_INLINE void swap(Value3D &other) \
|
190
|
+
{Zeta::swap<Base>(this, &other);}
|
191
|
+
|
192
|
+
|
193
|
+
#define Z_IMPLEMENTATION_SIGNED \
|
194
|
+
\
|
195
|
+
Z_CT(CPP11) Value3D absolute() const \
|
196
|
+
{ \
|
197
|
+
return Value3D \
|
198
|
+
(Zeta::absolute<T>(x), \
|
199
|
+
Zeta::absolute<T>(y), \
|
200
|
+
Zeta::absolute<T>(z)); \
|
201
|
+
} \
|
202
|
+
\
|
203
|
+
\
|
204
|
+
Z_CT(CPP11) Boolean has_negative() const \
|
205
|
+
{return x < T(0) || y < T(0) || z < T(0);} \
|
206
|
+
\
|
207
|
+
\
|
208
|
+
Z_CT(CPP11) Boolean is_negative() const \
|
209
|
+
{return x < T(0) && y < T(0) && z < T(0);} \
|
210
|
+
\
|
211
|
+
\
|
212
|
+
Z_CT(CPP11) Value3D negative() const \
|
213
|
+
{return Value3D(-x, -y, -z);}
|
214
|
+
|
215
|
+
|
216
|
+
namespace Zeta {
|
217
|
+
|
218
|
+
// template <class T, UInt T_number_set = Type<T>::number_set> struct Value3D;
|
219
|
+
|
220
|
+
|
221
|
+
template <class T> struct Value3D<T, Z_NUMBER_SET_Z> {
|
222
|
+
Z_IMPLEMENTATION_COMMON
|
223
|
+
Z_IMPLEMENTATION_SIGNED
|
224
|
+
|
225
|
+
|
226
|
+
Z_CT(CPP11) Boolean is_perpendicular(const Value3D &other) const
|
227
|
+
{return !Zeta::absolute<T>(dot_product(other));}
|
228
|
+
|
229
|
+
|
230
|
+
# ifdef Z_EXTENSION_VALUE_3D_Z
|
231
|
+
Z_EXTENSION_VALUE_3D_Z
|
232
|
+
# endif
|
233
|
+
};
|
234
|
+
|
235
|
+
|
236
|
+
template <class T> struct Value3D<T, Z_NUMBER_SET_N> {
|
237
|
+
Z_IMPLEMENTATION_COMMON
|
238
|
+
|
239
|
+
|
240
|
+
# ifdef Z_EXTENSION_VALUE_3D_N
|
241
|
+
Z_EXTENSION_VALUE_3D_N
|
242
|
+
# endif
|
243
|
+
};
|
244
|
+
|
245
|
+
|
246
|
+
template <class T> struct Value3D<T, Z_NUMBER_SET_R> {
|
247
|
+
Z_IMPLEMENTATION_COMMON
|
248
|
+
Z_IMPLEMENTATION_SIGNED
|
249
|
+
|
250
|
+
|
251
|
+
Z_CT(CPP11) Value3D clamp_01() const
|
252
|
+
{
|
253
|
+
return Value3D
|
254
|
+
(Zeta::clamp_01<T>(x),
|
255
|
+
Zeta::clamp_01<T>(y),
|
256
|
+
Zeta::clamp_01<T>(z));
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
Z_CT(CPP11) Boolean has_almost_zero() const
|
261
|
+
{
|
262
|
+
return Zeta::is_almost_zero<T>(x) ||
|
263
|
+
Zeta::is_almost_zero<T>(y) ||
|
264
|
+
Zeta::is_almost_zero<T>(z);
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
Z_CT(CPP11) Boolean has_finite() const
|
269
|
+
{
|
270
|
+
return Zeta::is_finite<T>(x) ||
|
271
|
+
Zeta::is_finite<T>(y) ||
|
272
|
+
Zeta::is_finite<T>(z);
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
Z_CT(CPP11) Boolean has_infinity() const
|
277
|
+
{
|
278
|
+
return Zeta::is_infinity<T>(x) ||
|
279
|
+
Zeta::is_infinity<T>(y) ||
|
280
|
+
Zeta::is_infinity<T>(z);
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
Z_CT(CPP11) Boolean has_nan() const
|
285
|
+
{
|
286
|
+
return Zeta::is_nan<T>(x) ||
|
287
|
+
Zeta::is_nan<T>(y) ||
|
288
|
+
Zeta::is_nan<T>(z);
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
Z_CT(CPP11) Value3D inverse_lerp(const Value3D &other, T t) const
|
293
|
+
{
|
294
|
+
return Value3D
|
295
|
+
(Zeta::inverse_lerp<T>(x, other.x, t),
|
296
|
+
Zeta::inverse_lerp<T>(y, other.y, t),
|
297
|
+
Zeta::inverse_lerp<T>(z, other.z, t));
|
298
|
+
}
|
299
|
+
|
300
|
+
|
301
|
+
Z_CT(CPP11) Boolean is_almost_equal(const Value3D &other) const
|
302
|
+
{
|
303
|
+
return Zeta::are_almost_equal<T>(x, other.x) &&
|
304
|
+
Zeta::are_almost_equal<T>(y, other.y) &&
|
305
|
+
Zeta::are_almost_equal<T>(z, other.z);
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
Z_CT(CPP11) Boolean is_almost_zero() const
|
310
|
+
{
|
311
|
+
return Zeta::is_almost_zero<T>(x) &&
|
312
|
+
Zeta::is_almost_zero<T>(y) &&
|
313
|
+
Zeta::is_almost_zero<T>(z);
|
314
|
+
}
|
315
|
+
|
316
|
+
|
317
|
+
Z_CT(CPP11) Boolean is_finite() const
|
318
|
+
{
|
319
|
+
return Zeta::is_finite<T>(x) &&
|
320
|
+
Zeta::is_finite<T>(y) &&
|
321
|
+
Zeta::is_finite<T>(z);
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
Z_CT(CPP11) Boolean is_infinity() const
|
326
|
+
{
|
327
|
+
return Zeta::is_infinity<T>(x) &&
|
328
|
+
Zeta::is_infinity<T>(y) &&
|
329
|
+
Zeta::is_infinity<T>(z);
|
330
|
+
}
|
331
|
+
|
332
|
+
|
333
|
+
Z_CT(CPP11) Boolean is_nan() const
|
334
|
+
{
|
335
|
+
return Zeta::is_nan<T>(x) &&
|
336
|
+
Zeta::is_nan<T>(y) &&
|
337
|
+
Zeta::is_nan<T>(z);
|
338
|
+
}
|
339
|
+
|
340
|
+
|
341
|
+
Z_CT(CPP11) Boolean is_perpendicular(const Value3D &other) const
|
342
|
+
{return Zeta::absolute<T>(dot_product(other)) <= Type<T>::epsilon();}
|
343
|
+
|
344
|
+
|
345
|
+
Z_CT(CPP11) Value3D lerp(const Value3D &other, T t) const
|
346
|
+
{
|
347
|
+
return Value3D
|
348
|
+
(Zeta::lerp<T>(x, other.x, t),
|
349
|
+
Zeta::lerp<T>(y, other.y, t),
|
350
|
+
Zeta::lerp<T>(z, other.z, t));
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
Z_CT(CPP11) Value3D reciprocal() const
|
355
|
+
{return Value3D(T(1) / x, T(1) / y, T(1) / z);}
|
356
|
+
|
357
|
+
|
358
|
+
# ifdef Z_EXTENSION_VALUE_3D_R
|
359
|
+
Z_EXTENSION_VALUE_3D_R
|
360
|
+
# endif
|
361
|
+
};
|
362
|
+
}
|
363
|
+
|
364
|
+
|
365
|
+
#undef Z_IMPLEMENTATION_COMMON
|
366
|
+
#undef Z_IMPLEMENTATION_SIGNED
|
367
|
+
|
368
|
+
#endif // _Z_classes_base_Value3D_HPP_
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/* Z Kit - classes/buffering/RingBuffer.hpp
|
2
|
+
_____ _______________
|
3
|
+
/_ /_/ -_/_ _/ _ |
|
4
|
+
/____/\___/ /__//___/_| Kit
|
5
|
+
Copyright (C) 2006-2018 Manuel Sainz de Baranda y Goñi.
|
6
|
+
Released under the terms of the GNU Lesser General Public License v3. */
|
7
|
+
|
8
|
+
#ifndef _Z_classes_buffering_RingBuffer_HPP_
|
9
|
+
#define _Z_classes_buffering_RingBuffer_HPP_
|
10
|
+
|
11
|
+
#include <Z/types/base.hpp>
|
12
|
+
#include <Z/types/buffering.h>
|
13
|
+
#include <Z/functions/base/value.h>
|
14
|
+
|
15
|
+
#ifndef z_cpu_relax
|
16
|
+
# define z_cpu_relax() asm volatile("pause\n": : :"memory")
|
17
|
+
#endif
|
18
|
+
|
19
|
+
|
20
|
+
namespace Zeta {struct RingBuffer : public ZRingBuffer {
|
21
|
+
|
22
|
+
Z_INLINE RingBuffer() Z_DEFAULTED({})
|
23
|
+
|
24
|
+
|
25
|
+
Z_INLINE RingBuffer(void *buffers, USize buffer_size, USize buffer_count)
|
26
|
+
{initialize(buffers, buffer_size, buffer_count);}
|
27
|
+
|
28
|
+
|
29
|
+
Z_INLINE void initialize(void *buffers, USize buffer_size, USize buffer_count)
|
30
|
+
{
|
31
|
+
this->buffers = buffers;
|
32
|
+
this->buffer_size = buffer_size;
|
33
|
+
this->buffer_count = buffer_count;
|
34
|
+
this->production_index = 0;
|
35
|
+
this->consumption_index = 0;
|
36
|
+
this->fill_count = 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
Z_INLINE void *production_buffer() const
|
41
|
+
{
|
42
|
+
return buffer_count - fill_count
|
43
|
+
? (UInt8 *)buffers + production_index * buffer_size
|
44
|
+
: NULL;
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
Z_INLINE void *consumption_buffer() const
|
49
|
+
{
|
50
|
+
return fill_count
|
51
|
+
? (UInt8 *)buffers + consumption_index * buffer_size
|
52
|
+
: NULL;
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
Z_INLINE void *try_produce()
|
57
|
+
{
|
58
|
+
if (buffer_count == fill_count) return NULL;
|
59
|
+
production_index = (production_index + 1) % buffer_count;
|
60
|
+
z_type_atomic_increment_then_get(USIZE)(&fill_count);
|
61
|
+
return (UInt8 *)buffers + production_index * buffer_size;
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
Z_INLINE void *try_consume()
|
66
|
+
{
|
67
|
+
if (!fill_count) return NULL;
|
68
|
+
consumption_index = (consumption_index + 1) % buffer_count;
|
69
|
+
z_type_atomic_decrement_then_get(USIZE)(&fill_count);
|
70
|
+
return (UInt8 *)buffers + consumption_index * buffer_size;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
Z_INLINE void *produce()
|
75
|
+
{
|
76
|
+
while (buffer_count == fill_count) z_cpu_relax();
|
77
|
+
production_index = (production_index + 1) % buffer_count;
|
78
|
+
z_type_atomic_increment_then_get(USIZE)(&fill_count);
|
79
|
+
return (UInt8 *)buffers + production_index * buffer_size;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
Z_INLINE void *consume()
|
84
|
+
{
|
85
|
+
if (!fill_count) z_cpu_relax();
|
86
|
+
consumption_index = (consumption_index + 1) % buffer_count;
|
87
|
+
z_type_atomic_decrement_then_get(USIZE)(&fill_count);
|
88
|
+
return (UInt8 *)buffers + consumption_index * buffer_size;
|
89
|
+
}
|
90
|
+
};}
|
91
|
+
|
92
|
+
|
93
|
+
#endif // _Z_classes_buffering_RingBuffer_HPP_
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* Z Kit - classes/buffering/TripleBuffer.hpp
|
2
|
+
_____ _______________
|
3
|
+
/_ /_/ -_/_ _/ _ |
|
4
|
+
/____/\___/ /__//___/_| Kit
|
5
|
+
Copyright (C) 2012 Remis.
|
6
|
+
Copyright (C) 2014-2018 Manuel Sainz de Baranda y Goñi.
|
7
|
+
Released under the terms of the GNU Lesser General Public License v3. */
|
8
|
+
|
9
|
+
#ifndef _Z_classes_buffering_TripleBuffer_HPP_
|
10
|
+
#define _Z_classes_buffering_TripleBuffer_HPP_
|
11
|
+
|
12
|
+
#include <Z/types/base.hpp>
|
13
|
+
#include <Z/types/buffering.h>
|
14
|
+
#include <Z/functions/base/value.h>
|
15
|
+
|
16
|
+
|
17
|
+
namespace Zeta {struct TripleBuffer : public ZTripleBuffer {
|
18
|
+
|
19
|
+
Z_INLINE TripleBuffer() Z_DEFAULTED({})
|
20
|
+
|
21
|
+
|
22
|
+
Z_INLINE TripleBuffer(void *buffers, USize buffer_size)
|
23
|
+
{initialize(buffers, buffer_size);}
|
24
|
+
|
25
|
+
|
26
|
+
Z_INLINE void initialize(void *buffers, USize buffer_size)
|
27
|
+
{
|
28
|
+
this->buffers[0] = buffers;
|
29
|
+
this->buffers[1] = (UInt8 *)buffers + buffer_size;
|
30
|
+
this->buffers[2] = (UInt8 *)buffers + buffer_size * 2;
|
31
|
+
this->flags = 6;
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
Z_INLINE void *production_buffer () const {return buffers[(flags & 48) >> 4];}
|
36
|
+
Z_INLINE void *consumption_buffer() const {return buffers[flags & 3];}
|
37
|
+
|
38
|
+
|
39
|
+
Z_INLINE void *produce()
|
40
|
+
{
|
41
|
+
UInt8 flags, new_flags;
|
42
|
+
|
43
|
+
do {
|
44
|
+
flags = this->flags;
|
45
|
+
new_flags = 64 | ((flags & 12) << 2) | ((flags & 48) >> 2) | (flags & 3);
|
46
|
+
}
|
47
|
+
while (!z_uint8_atomic_set_if_equal(&this->flags, flags, new_flags));
|
48
|
+
|
49
|
+
return this->buffers[(new_flags & 48) >> 4];
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
Z_INLINE void *consume()
|
54
|
+
{
|
55
|
+
UInt8 flags, new_flags;
|
56
|
+
|
57
|
+
do {
|
58
|
+
if (!((flags = this->flags) & 64)) return NULL;
|
59
|
+
new_flags = (flags & 48) | ((flags & 3) << 2) | ((flags & 12) >> 2);
|
60
|
+
}
|
61
|
+
while (!z_uint8_atomic_set_if_equal(&this->flags, flags, new_flags));
|
62
|
+
|
63
|
+
return this->buffers[new_flags & 3];;
|
64
|
+
}
|
65
|
+
};}
|
66
|
+
|
67
|
+
|
68
|
+
#endif // _Z_classes_buffering_TripleBuffer_HPP_
|