├── .clang-format
├── .github
├── ISSUE_TEMPLATE
│ └── bug_report.md
└── workflows
│ └── cmake.yml
├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── CONTRIBUTING.md
├── CREDITS.md
├── LICENSE
├── README.md
├── benchmark
└── bench1.cpp
├── cmake
└── PlatformGlob.cmake
├── core
├── CMakeLists.txt
├── bitops.h
├── coresignal.h
├── hostevents.h
├── hostevents_sdl.cpp
├── mathutils.h
├── timermanager.cpp
└── timermanager.h
├── cpu
└── ppc
│ ├── CMakeLists.txt
│ ├── poweropcodes.cpp
│ ├── ppcdisasm.cpp
│ ├── ppcdisasm.h
│ ├── ppcemu.h
│ ├── ppcexceptions.cpp
│ ├── ppcexec.cpp
│ ├── ppcfpopcodes.cpp
│ ├── ppcmacros.h
│ ├── ppcmmu.cpp
│ ├── ppcmmu.h
│ ├── ppcopcodes.cpp
│ └── test
│ ├── genppctests.py
│ ├── ppcdisasmtest.csv
│ ├── ppcfloattest.txt
│ ├── ppcfloattests.csv
│ ├── ppcinttest.txt
│ ├── ppcinttests.csv
│ ├── ppctests.cpp
│ └── testdisasm.cpp
├── debugger
├── CMakeLists.txt
├── debugger.cpp
└── debugger.h
├── devices
├── CMakeLists.txt
├── common
│ ├── adb
│ │ ├── adbapplejack.cpp
│ │ ├── adbapplejack.h
│ │ ├── adbbus.cpp
│ │ ├── adbbus.h
│ │ ├── adbdevice.cpp
│ │ ├── adbdevice.h
│ │ ├── adbkeyboard.cpp
│ │ ├── adbkeyboard.h
│ │ ├── adbmouse.cpp
│ │ └── adbmouse.h
│ ├── ata
│ │ ├── atabasedevice.cpp
│ │ ├── atabasedevice.h
│ │ ├── atadefs.h
│ │ ├── atahd.cpp
│ │ ├── atahd.h
│ │ ├── atapibasedevice.cpp
│ │ ├── atapibasedevice.h
│ │ ├── atapicdrom.cpp
│ │ ├── atapicdrom.h
│ │ ├── cmd646.cpp
│ │ ├── cmd646.h
│ │ ├── idechannel.cpp
│ │ └── idechannel.h
│ ├── clockgen
│ │ ├── athens.cpp
│ │ └── athens.h
│ ├── dbdma.cpp
│ ├── dbdma.h
│ ├── dmacore.h
│ ├── hwcomponent.h
│ ├── hwinterrupt.h
│ ├── i2c
│ │ ├── i2c.h
│ │ ├── i2cprom.cpp
│ │ └── i2cprom.h
│ ├── machineid.h
│ ├── mmiodevice.h
│ ├── nubus
│ │ ├── nubusutils.cpp
│ │ └── nubusutils.h
│ ├── nvram.cpp
│ ├── nvram.h
│ ├── ofnvram.cpp
│ ├── ofnvram.h
│ ├── pci
│ │ ├── bandit.cpp
│ │ ├── bandit.h
│ │ ├── dec21154.cpp
│ │ ├── dec21154.h
│ │ ├── pcibase.cpp
│ │ ├── pcibase.h
│ │ ├── pcibridge.cpp
│ │ ├── pcibridge.h
│ │ ├── pcibridgebase.cpp
│ │ ├── pcibridgebase.h
│ │ ├── pcicardbusbridge.cpp
│ │ ├── pcicardbusbridge.h
│ │ ├── pcidevice.cpp
│ │ ├── pcidevice.h
│ │ ├── pcihost.cpp
│ │ └── pcihost.h
│ ├── scsi
│ │ ├── mesh.cpp
│ │ ├── mesh.h
│ │ ├── sc53c94.cpp
│ │ ├── sc53c94.h
│ │ ├── scsi.h
│ │ ├── scsibus.cpp
│ │ ├── scsibusctrl.cpp
│ │ ├── scsibusctrl.h
│ │ ├── scsicdrom.cpp
│ │ ├── scsicdrom.h
│ │ ├── scsidevice.cpp
│ │ ├── scsihd.cpp
│ │ └── scsihd.h
│ ├── viacuda.cpp
│ └── viacuda.h
├── deviceregistry.cpp
├── deviceregistry.h
├── ethernet
│ ├── bigmac.cpp
│ ├── bigmac.h
│ ├── mace.cpp
│ └── mace.h
├── floppy
│ ├── floppyimg.cpp
│ ├── floppyimg.h
│ ├── superdrive.cpp
│ ├── superdrive.h
│ ├── swim3.cpp
│ └── swim3.h
├── ioctrl
│ ├── amic.cpp
│ ├── amic.h
│ ├── grandcentral.cpp
│ ├── heathrow.cpp
│ ├── macio.h
│ └── ohare.cpp
├── memctrl
│ ├── aspen.cpp
│ ├── aspen.h
│ ├── hammerhead.cpp
│ ├── hammerhead.h
│ ├── hmc.cpp
│ ├── hmc.h
│ ├── memctrlbase.cpp
│ ├── memctrlbase.h
│ ├── mpc106.cpp
│ ├── mpc106.h
│ ├── platinum.cpp
│ ├── platinum.h
│ ├── psx.cpp
│ ├── psx.h
│ └── spdram.h
├── serial
│ ├── chario.cpp
│ ├── chario.h
│ ├── escc.cpp
│ ├── escc.h
│ └── z85c30.h
├── sound
│ ├── awacs.cpp
│ ├── awacs.h
│ ├── burgundy.cpp
│ ├── burgundy.h
│ ├── soundserver.h
│ └── soundserver_cubeb.cpp
├── storage
│ ├── blockstoragedevice.cpp
│ ├── blockstoragedevice.h
│ ├── cdromdrive.cpp
│ └── cdromdrive.h
└── video
│ ├── appleramdac.cpp
│ ├── appleramdac.h
│ ├── atimach64defs.h
│ ├── atimach64gx.cpp
│ ├── atimach64gx.h
│ ├── atirage.cpp
│ ├── atirage.h
│ ├── control.cpp
│ ├── control.h
│ ├── display.h
│ ├── display_sdl.cpp
│ ├── displayid.cpp
│ ├── displayid.h
│ ├── pdmonboard.cpp
│ ├── pdmonboard.h
│ ├── rgb514defs.h
│ ├── saa7187.cpp
│ ├── saa7187.h
│ ├── sixty6.cpp
│ ├── sixty6.h
│ ├── taos.cpp
│ ├── taos.h
│ ├── videoctrl.cpp
│ └── videoctrl.h
├── dppcicon.ico
├── endianswap.h
├── icon.png
├── icon.rc
├── machines
├── CMakeLists.txt
├── machinebase.cpp
├── machinebase.h
├── machinebondi.cpp
├── machinecatalyst.cpp
├── machinefactory.cpp
├── machinefactory.h
├── machinegazelle.cpp
├── machinegossamer.cpp
├── machinepdm.cpp
├── machinepippin.cpp
├── machineproperties.cpp
├── machineproperties.h
├── machinetnt.cpp
└── machineyosemite.cpp
├── main.cpp
├── main.h
├── main_sdl.cpp
├── main_sdl.m
├── memaccess.h
├── thirdparty
├── CLI11
│ └── CLI11.hpp
└── loguru
│ ├── CMakeLists.txt
│ ├── loguru.cpp
│ └── loguru.hpp
├── utils
├── CMakeLists.txt
├── imgfile.h
├── imgfile_sdl.cpp
├── profiler.cpp
└── profiler.h
├── vcpkg.json
└── zdocs
├── developers
├── aboutthis.md
├── adb.md
├── amic.md
├── atirage.md
├── awacs.md
├── bebox.md
├── bmac.md
├── cpu
│ └── powerpc
│ │ ├── mmu.md
│ │ ├── mmuemu.md
│ │ └── powerpc.md
├── dbdma.md
├── get-inherited-property notes.txt
├── grackle.md
├── heathrow.md
├── ibmpower.md
├── keylargo.md
├── machines
│ └── pdmram.md
├── memorymaps.md
├── mesh.md
├── misc.md
├── motorolaatlas.md
├── openfirmware.md
├── swim3.md
├── valkyrie.md
└── viacuda.md
└── users
└── manual.md
/.clang-format:
--------------------------------------------------------------------------------
1 | Language: Cpp
2 |
3 | AccessModifierOffset: -4
4 | AlignAfterOpenBracket: AlwaysBreak
5 | AlignConsecutiveAssignments: true
6 | AlignConsecutiveDeclarations: false
7 | #AlignConsecutiveMacros: false
8 | AlignEscapedNewlines: Right
9 | AlignOperands: false
10 | AlignTrailingComments: true
11 | AllowAllArgumentsOnNextLine: true
12 | AllowAllConstructorInitializersOnNextLine: true
13 | AllowAllParametersOfDeclarationOnNextLine: true
14 | AllowShortBlocksOnASingleLine: false
15 | AllowShortCaseLabelsOnASingleLine: false
16 | AllowShortFunctionsOnASingleLine: Empty
17 | AllowShortIfStatementsOnASingleLine: Never
18 | #AllowShortLambdasOnASingleLine: All
19 | AllowShortLoopsOnASingleLine: false
20 | AlwaysBreakAfterDefinitionReturnType: None
21 | AlwaysBreakAfterReturnType: None
22 | AlwaysBreakBeforeMultilineStrings: true
23 | AlwaysBreakTemplateDeclarations: Yes
24 | BinPackArguments: false
25 | BinPackParameters: false
26 | BreakBeforeBinaryOperators: None
27 | BreakBeforeBraces: Attach
28 | BreakBeforeTernaryOperators: true
29 | BreakConstructorInitializers: BeforeComma
30 | #BreakInheritanceList: BeforeComma
31 | BreakStringLiterals: true
32 | ColumnLimit: 100
33 | CompactNamespaces: true
34 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
35 | ConstructorInitializerIndentWidth: 4
36 | ContinuationIndentWidth: 4
37 | Cpp11BracedListStyle: true
38 | DerivePointerAlignment: false
39 | FixNamespaceComments: true
40 | IncludeBlocks: Preserve
41 | IndentCaseLabels: false
42 | IndentPPDirectives: AfterHash
43 | IndentWidth: 4
44 | IndentWrappedFunctionNames: true
45 | KeepEmptyLinesAtTheStartOfBlocks: false
46 | MaxEmptyLinesToKeep: 2
47 | NamespaceIndentation: None
48 | PenaltyBreakAssignment: 50
49 | PenaltyBreakBeforeFirstCallParameter: 0
50 | PenaltyBreakComment: 100
51 | PenaltyBreakFirstLessLess: 200
52 | PenaltyBreakString: 100
53 | #PenaltyBreakTemplateDeclaration: 0
54 | PenaltyExcessCharacter: 10
55 | PenaltyReturnTypeOnItsOwnLine: 1000
56 | PointerAlignment: Left
57 | ReflowComments: true
58 | SortIncludes: true
59 | SpaceAfterCStyleCast: false
60 | #SpaceAfterLogicalNot: false
61 | SpaceAfterTemplateKeyword: true
62 | SpaceBeforeAssignmentOperators: true
63 | #SpaceBeforeCpp11BracedList: true
64 | #SpaceBeforeCtorInitializerColon: false
65 | #SpaceBeforeInheritanceColon: false
66 | SpaceBeforeParens: ControlStatements
67 | #SpaceBeforeRangeBasedForLoopColon: false
68 | #SpaceInEmptyBlock: false
69 | SpaceInEmptyParentheses: false
70 | SpacesBeforeTrailingComments: 4
71 | SpacesInAngles: false
72 | SpacesInCStyleCastParentheses: false
73 | SpacesInContainerLiterals: false
74 | SpacesInParentheses: false
75 | SpacesInSquareBrackets: false
76 | #Standard: c++17
77 | TabWidth: 4
78 | UseTab: Never
79 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 | **Device Information (please complete the following information):**
26 |
27 | - Device Type: [e.g. Desktop, Smartphone]
28 | - Host OS: [e.g. Linux 4.4, Mac OS X 10.12, Windows 7]
29 | - Host Processor: [e.g. Intel Core 2 Duo, AMD Phenom II]
30 | - Host RAM: [e.g. 4 GB]
31 | - Guest OS: [e.g. Mac OS 8.6]
32 | - Guest Processor: [e.g. PowerPC G3 (750 v.1)]
33 | - Guest ROM: [e.g. Power Mac G3 Beige]
34 | - Guest RAM: [e.g. 64 MB]
35 | - Build Date [e.g. 22/7/2019 (dd/mm/yyyy format)]
36 | - Version [e.g. 22]
37 |
38 | **Additional context**
39 | Add any other context about the problem here.
40 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore binary files
2 | out/
3 | vcpkg/
4 | *.bin
5 |
6 | # Ignore compiled object files
7 | .vs/
8 | .vscode/
9 | *.o
10 | *.out
11 | *.obj
12 | *.d
13 |
14 | # Ignore CMake system files
15 | CMakeFiles
16 | cmake_install.cmake
17 |
18 | # Ignore Visual Studio configuration files
19 | CMakeSettings.json
20 | *.vcxproj
21 | *.vcxproj.filters
22 |
23 | # Ignore Visual Studio auto-save recovery folder
24 | enc_temp_folder/
25 |
26 | # Ignore CodeLite configuration files
27 | *.workspace
28 | *.workspace.*
29 | compile_commands.json
30 | *.session
31 | *.tags
32 |
33 | # Ignore generated executables
34 | dingusppc
35 | dingusppc.exe
36 |
37 | # Ignore system files
38 | .DS_Store
39 | Thumb.db
40 | ehthumbs.db
41 |
42 | # IDE ignores
43 | build
44 | build-*
45 | *.dir
46 | *.user
47 | DerivedData
48 | *.xcodeproj/project.xcworkspace
49 | *.xcodeproj/xcuserdata
50 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "thirdparty/cubeb"]
2 | path = thirdparty/cubeb
3 | url = https://github.com/DingusDevOrg/cubeb.git
4 | [submodule "thirdparty/capstone"]
5 | path = thirdparty/capstone
6 | url = https://github.com/maximumspatium/capstone.git
7 | branch = next
8 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | General
2 | =======
3 |
4 | * Test your contributions to assure they do not break existing functionality.
5 | * Commits to the repo should be done by portions; that is, by individual functionalities of the program.
6 | * Don't use any disrespectful language.
7 |
8 | Code
9 | =======
10 |
11 | * Make sure the code can compile for all target systems - Windows, Linux, and macOS/Mac OS X.
12 | * All code must be compatible with at least C++11.
13 | * Minimize the amount of redundant code.
14 | * Avoid using absolute paths for the headers.
15 | * Code should maintain vertical alignment for better readability, for example:
16 |
17 | ```C
18 | one_hundred = 100;
19 | one_thousand = 1000;
20 | two_thousand = 2000;
21 | ```
22 |
23 | * CamelCase for class names, lowercase for variables, UPPERCASE for enumerations
24 | * Avoid redundancy in namespaces (i.e. use ViaCuda::read() instead of ViaCuda::cuda_read())
25 |
26 | Issues
27 | =======
28 |
29 | * When creating an issue ticket, note which version you are using.
30 | * If possible, reference the git hashes for the relevant commits.
31 | * Once an issue is closed, do not re-open it. Instead, reference it in a new issue ticket.
32 |
--------------------------------------------------------------------------------
/CREDITS.md:
--------------------------------------------------------------------------------
1 | # DingusPPC
2 |
3 |
4 | ## Developers
5 |
6 | - divingkatae
7 | - maximumspatium
8 | - joevt
9 | - mihaip
10 | - kkaisershot
11 |
12 | ## NT4/PPC fork
13 |
14 | - Wack0
15 |
16 | ## DevOps
17 |
18 | - Waqar144
19 | - webspacecreations
20 | - leap0x7b
21 | - sdkmap
22 | - dressupgeekout
23 | - kth5
24 | - dyharlan
25 | - roytam1
26 | - mrpapersonic
27 | - Randrianasulu
28 | - lefp
29 | - mathstuf
30 |
31 | ## Testing
32 |
33 | - LagLifeYT
34 |
35 | ## 3rd Party Libraries
36 |
37 | - [Capstone](https://github.com/capstone-engine/capstone)
38 | - [CLI11](https://github.com/CLIUtils/CLI11)
39 | - [Loguru](https://github.com/emilk/loguru)
40 | - [SDL 2](https://github.com/libsdl-org/SDL)
41 |
42 | ## Thanks
43 |
44 | - 68kmla
45 | - AppleFritter
46 | - Archive.org
47 | - Bitsavers
48 | - Blitter.net
49 | - Emaculation
50 | - GitHub
51 | - PenguinPPC
52 | - VirtuallyFun
53 | - The makers of Loguru, SDL2, Capstone, and CLI11
54 | - The developers of other PowerPC Mac emulators, past and present
55 | - All those preserving the software and source code of 68k and PowerPC Macs
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DingusPPC
2 |
3 | Written by divingkatae and maximumspatium
4 |
5 | Be warned the program is highly unfinished and could use a lot of testing. Any feedback is welcome.
6 |
7 | ## Philosophy of Use
8 |
9 | While many other PowerPC emus exist (PearPC, Sheepshaver), none of them currently attempt emulation of PowerPC Macs accurately (except for QEMU).
10 |
11 | This program aims to not only improve upon what Sheepshaver, PearPC, and other PowerPC Mac emulators have done, but also to provide a better debugging environment. This currently is designed to work best with PowerPC Old World ROMs, including those of the Power Mac 6100, 7200, and G3 Beige.
12 |
13 | ## Implemented Features
14 |
15 | This emulator has a debugging environment, complete with a disassembler. We also have implemented enough to allow Open Firmware to boot, going so far as to allow audio playback of the boot-up jingles.
16 |
17 | ## How to Use
18 |
19 | This program currently uses the command prompt to work.
20 |
21 | There are a few command line arguments one must enter when starting the program.
22 |
23 | ```
24 | -r, --realtime
25 | ```
26 |
27 | Run the emulator in runtime.
28 |
29 | ```
30 | -d, --debugger
31 | ```
32 |
33 | Enter the interactive debugger.
34 |
35 | ```
36 | -b, --bootrom TEXT:FILE
37 | ```
38 |
39 | Specifies the Boot ROM path (optional; looks for bootrom.bin by default)
40 |
41 | ```
42 | -m, --machine TEXT
43 | ```
44 |
45 | Specify machine ID (optional; will attempt to determine machine ID from the boot rom otherwise)
46 |
47 | As of now, the most complete machines are the Power Mac 6100 (SCSI emulation in progress) and the Power Mac G3 Beige (SCSI + ATA emulation in progress, No ATI Rage acceleration).
48 |
49 | ## How to Compile
50 |
51 | You need to install development tools first.
52 |
53 | At least, a C++20 compliant compiler and [CMake](https://cmake.org) are required.
54 |
55 | You will also have to recursive clone or run
56 | ```
57 | git submodule update --init --recursive
58 | ```
59 |
60 | This is because the CubeB, Capstone, and SDL2 modules are not included by default.
61 |
62 | For SDL2, Linux users may also have to run:
63 |
64 | ```
65 | sudo apt install libsdl2-dev
66 | ```
67 |
68 | CLI11 and loguru are already included in the thirdparty folder and compiled along with the rest of DingusPPC.
69 |
70 | For example, to build the project in a Unix-like environment, you will need to run
71 | the following commands in the OS terminal:
72 | ```
73 | mkdir build
74 | cd build
75 | cmake -DCMAKE_BUILD_TYPE=Release ..
76 | make dingusppc
77 | ```
78 | You may specify another build type using the variable CMAKE_BUILD_TYPE.
79 |
80 | For Raspbian, you may also need the following command:
81 | ```
82 | sudo apt install doxygen graphviz
83 | ```
84 |
85 | ## Testing
86 |
87 | DingusPPC includes a test suite for verifying the correctness of its PowerPC CPU
88 | emulation. To build the tests, use the following terminal commands:
89 | ```
90 | mkdir build
91 | cd build
92 | cmake -DCMAKE_BUILD_TYPE=Release -DDPPC_BUILD_PPC_TESTS=True ..
93 | make testppc
94 | ```
95 |
96 | ## Intended Minimum Requirements
97 |
98 | - Windows 7 or newer (64-bit), Linux 4.4 or newer, Mac OS X 10.9 or newer (64-bit)
99 | - Intel Core 2 Duo or better
100 | - 2 GB of RAM
101 | - 2 GB of Hard Disk Space
102 | - Graphics Card with a minimum resolution of 800*600
103 |
104 | ## Compiler Requirements
105 |
106 | - Any C++20 compatible compiler
107 |
--------------------------------------------------------------------------------
/cmake/PlatformGlob.cmake:
--------------------------------------------------------------------------------
1 | # Detect platform suffix
2 | if (EMSCRIPTEN)
3 | set(PLATFORM_SUFFIX "_js$")
4 | else()
5 | set(PLATFORM_SUFFIX "_sdl|_cubeb$")
6 | endif()
7 |
8 | # Function to perform a platform-specific glob
9 | function(platform_glob RESULT_VAR)
10 | set(PLATFORM_SOURCES)
11 | foreach(GLOB_PATTERN ${ARGN})
12 | file(GLOB GLOB_RESULT ${GLOB_PATTERN})
13 | foreach(FILE_PATH ${GLOB_RESULT})
14 | get_filename_component(BASE_NAME ${FILE_PATH} NAME_WE)
15 | if("${BASE_NAME}" MATCHES ${PLATFORM_SUFFIX} OR NOT "${BASE_NAME}" MATCHES "_js$|_sdl|_cubeb$")
16 | list(APPEND PLATFORM_SOURCES ${FILE_PATH})
17 | endif()
18 | endforeach()
19 | endforeach()
20 | set(${RESULT_VAR} ${PLATFORM_SOURCES} PARENT_SCOPE)
21 | endfunction()
22 |
--------------------------------------------------------------------------------
/core/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories("${PROJECT_SOURCE_DIR}"
2 | "${PROJECT_SOURCE_DIR}/thirdparty/loguru/"
3 | )
4 |
5 | platform_glob(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
6 |
7 | add_library(core OBJECT ${SOURCES})
8 | if (EMSCRIPTEN)
9 | target_link_libraries(core PRIVATE)
10 | else()
11 | target_link_libraries(core PRIVATE SDL2::SDL2)
12 | endif()
13 |
--------------------------------------------------------------------------------
/core/bitops.h:
--------------------------------------------------------------------------------
1 | /*
2 | DingusPPC - The Experimental PowerPC Macintosh emulator
3 | Copyright (C) 2018-25 divingkatae and maximum
4 | (theweirdo) spatium
5 |
6 | (Contact divingkatae#1017 or powermax#2286 on Discord for more info)
7 |
8 | This program is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program. If not, see .
20 | */
21 |
22 | /** Non-standard low-level bitwise operations. */
23 |
24 | #ifndef BIT_OPS_H
25 | #define BIT_OPS_H
26 |
27 | #include
28 |
29 | #if defined(__GNUG__) && !defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) // GCC, mybe ICC but not Clang
30 |
31 | # include
32 |
33 | # define ROTL_32(x, n) (_rotl((x), (n)))
34 | # define ROTR_32(x, n) (_rotr((x), (n)))
35 |
36 | #elif defined(_MSC_VER) // MSVC
37 |
38 | # include
39 |
40 | # define ROTL_32(x, n) (_rotl((x), (n)))
41 | # define ROTR_32(x, n) (_rotr((x), (n)))
42 |
43 | #else
44 |
45 | // cyclic rotation idioms that modern compilers will
46 | // recognize and generate very compact code for
47 | // involving specific machine instructions
48 |
49 | inline unsigned ROTL_32(unsigned x, unsigned n) {
50 | n &= 0x1F;
51 | if (n)
52 | return (x << n) | (x >> (32 - n));
53 | return x;
54 | }
55 |
56 | inline unsigned ROTR_32(unsigned x, unsigned n) {
57 | n &= 0x1F;
58 | if (n)
59 | return (x >> n) | (x << (32 - n));
60 | return x;
61 | }
62 |
63 | #endif
64 |
65 | template
66 | inline T extract_bits(T val, int pos, int len) {
67 | return (val >> pos) & ((len == sizeof(T) * 8) ? (T)-1 : ((T)1 << len) - 1);
68 | }
69 |
70 | template
71 | inline void insert_bits(T &old_val, T new_val, int pos, int len) {
72 | T mask = ((len == sizeof(T) * 8) ? (T)-1 : ((T)1 << len) - 1) << pos;
73 | old_val = (old_val & ~mask) | ((new_val << pos) & mask);
74 | }
75 |
76 | /* Return true if the specified bit is different in the given numbers. */
77 | static inline bool bit_changed(uint64_t old_val, uint64_t new_val, int bit_num) {
78 | return (old_val ^ new_val) & (1ULL << bit_num);
79 | }
80 |
81 | static inline bool bit_set(const uint64_t val, const int bit_num) {
82 | return !!(val & (1ULL << bit_num));
83 | }
84 |
85 | template
86 | inline void clear_bit(T &val, const int bit_num) {
87 | val &= ~((T)1 << bit_num);
88 | }
89 |
90 | template
91 | inline void set_bit(T &val, const int bit_num) {
92 | val |= ((T)1 << bit_num);
93 | }
94 |
95 | static inline uint32_t extract_with_wrap_around(uint32_t val, int pos, int size) {
96 | return (uint32_t)((((uint64_t)val << 32) | val) >> ((8 - (pos & 3) - size) << 3)) &
97 | ((1LL << (size << 3)) - 1);
98 | }
99 |
100 | #endif // BIT_OPS_H
101 |
--------------------------------------------------------------------------------
/core/coresignal.h:
--------------------------------------------------------------------------------
1 | /*
2 | DingusPPC - The Experimental PowerPC Macintosh emulator
3 | Copyright (C) 2018-23 divingkatae and maximum
4 | (theweirdo) spatium
5 |
6 | (Contact divingkatae#1017 or powermax#2286 on Discord for more info)
7 |
8 | This program is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program. If not, see .
20 | */
21 |
22 | /** Poor man's signals & slots mechanism implementation. */
23 |
24 | // Inspired by http://schneegans.github.io/tutorials/2015/09/20/signal-slot
25 |
26 | #ifndef CORE_SIGNAL_H
27 | #define CORE_SIGNAL_H
28 |
29 | #include
30 | #include