diff options
| author | 2014-04-05 15:22:36 -0400 | |
|---|---|---|
| committer | 2014-04-05 15:22:36 -0400 | |
| commit | 02bcb4cfad8ab76b57b6be8a4591bc6f29246909 (patch) | |
| tree | c91a11381d5d7d0ed3f871a4c352460c3eb99c16 /src/common | |
| parent | added DISALLOW_COPY_AND_ASSIGN macro (diff) | |
| download | yuzu-02bcb4cfad8ab76b57b6be8a4591bc6f29246909.tar.gz yuzu-02bcb4cfad8ab76b57b6be8a4591bc6f29246909.tar.xz yuzu-02bcb4cfad8ab76b57b6be8a4591bc6f29246909.zip | |
Updated common_types.h to use Gekko's version w/ Rect and some useful unions
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/src/common_types.h | 132 |
1 files changed, 102 insertions, 30 deletions
diff --git a/src/common/src/common_types.h b/src/common/src/common_types.h index cbe556c7e..68f237385 100644 --- a/src/common/src/common_types.h +++ b/src/common/src/common_types.h | |||
| @@ -1,50 +1,122 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project | 1 | /** |
| 2 | // Licensed under GPLv2 | 2 | * Copyright (C) 2005-2012 Gekko Emulator |
| 3 | // Refer to the license.txt file included. | 3 | * |
| 4 | * @file common_types.h | ||
| 5 | * @author ShizZy <shizzy247@gmail.com> | ||
| 6 | * @date 2012-02-11 | ||
| 7 | * @brief Common types used throughout the project | ||
| 8 | * | ||
| 9 | * @section LICENSE | ||
| 10 | * This program is free software; you can redistribute it and/or | ||
| 11 | * modify it under the terms of the GNU General Public License as | ||
| 12 | * published by the Free Software Foundation; either version 2 of | ||
| 13 | * the License, or (at your option) any later version. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, but | ||
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 18 | * General Public License for more details at | ||
| 19 | * http://www.gnu.org/copyleft/gpl.html | ||
| 20 | * | ||
| 21 | * Official project repository can be found at: | ||
| 22 | * http://code.google.com/p/gekko-gc-emu/ | ||
| 23 | */ | ||
| 4 | 24 | ||
| 5 | 25 | #pragma once | |
| 6 | // This header contains type definitions that are shared between the Dolphin core and | ||
| 7 | // other parts of the code. Any definitions that are only used by the core should be | ||
| 8 | // placed in "common.h" instead. | ||
| 9 | |||
| 10 | #ifndef _COMMONTYPES_H_ | ||
| 11 | #define _COMMONTYPES_H_ | ||
| 12 | 26 | ||
| 13 | #ifdef _WIN32 | 27 | #ifdef _WIN32 |
| 14 | 28 | ||
| 15 | #include <tchar.h> | 29 | #include <tchar.h> |
| 16 | 30 | ||
| 17 | typedef unsigned __int8 u8; | 31 | typedef unsigned __int8 u8; ///< 8-bit unsigned byte |
| 18 | typedef unsigned __int16 u16; | 32 | typedef unsigned __int16 u16; ///< 16-bit unsigned short |
| 19 | typedef unsigned __int32 u32; | 33 | typedef unsigned __int32 u32; ///< 32-bit unsigned word |
| 20 | typedef unsigned __int64 u64; | 34 | typedef unsigned __int64 u64; ///< 64-bit unsigned int |
| 21 | 35 | ||
| 22 | typedef signed __int8 s8; | 36 | typedef signed __int8 s8; ///< 8-bit signed byte |
| 23 | typedef signed __int16 s16; | 37 | typedef signed __int16 s16; ///< 16-bit signed short |
| 24 | typedef signed __int32 s32; | 38 | typedef signed __int32 s32; ///< 32-bit signed word |
| 25 | typedef signed __int64 s64; | 39 | typedef signed __int64 s64; ///< 64-bit signed int |
| 26 | 40 | ||
| 27 | #else | 41 | #else |
| 28 | 42 | ||
| 29 | #ifndef GEKKO | 43 | typedef unsigned char u8; ///< 8-bit unsigned byte |
| 30 | 44 | typedef unsigned short u16; ///< 16-bit unsigned short | |
| 31 | typedef unsigned char u8; | 45 | typedef unsigned int u32; ///< 32-bit unsigned word |
| 32 | typedef unsigned short u16; | 46 | typedef unsigned long long u64; ///< 64-bit unsigned int |
| 33 | typedef unsigned int u32; | ||
| 34 | typedef unsigned long long u64; | ||
| 35 | 47 | ||
| 36 | typedef signed char s8; | 48 | typedef signed char s8; ///< 8-bit signed byte |
| 37 | typedef signed short s16; | 49 | typedef signed short s16; ///< 16-bit signed short |
| 38 | typedef signed int s32; | 50 | typedef signed int s32; ///< 32-bit signed word |
| 39 | typedef signed long long s64; | 51 | typedef signed long long s64; ///< 64-bit signed int |
| 40 | 52 | ||
| 41 | #endif | ||
| 42 | // For using windows lock code | 53 | // For using windows lock code |
| 43 | #define TCHAR char | 54 | #define TCHAR char |
| 44 | #define LONG int | 55 | #define LONG int |
| 45 | 56 | ||
| 46 | #endif // _WIN32 | 57 | #endif // _WIN32 |
| 47 | 58 | ||
| 59 | typedef float f32; ///< 32-bit floating point | ||
| 60 | typedef double f64; ///< 64-bit floating point | ||
| 61 | |||
| 48 | #include "swap.h" | 62 | #include "swap.h" |
| 49 | 63 | ||
| 50 | #endif // _COMMONTYPES_H_ | 64 | /// Union for fast 16-bit type casting |
| 65 | union t16 { | ||
| 66 | u8 _u8[2]; ///< 8-bit unsigned char(s) | ||
| 67 | u16 _u16; ///< 16-bit unsigned shorts(s) | ||
| 68 | }; | ||
| 69 | |||
| 70 | /// Union for fast 32-bit type casting | ||
| 71 | union t32 { | ||
| 72 | f32 _f32; ///< 32-bit floating point(s) | ||
| 73 | u32 _u32; ///< 32-bit unsigned int(s) | ||
| 74 | s32 _s32; ///< 32-bit signed int(s) | ||
| 75 | u16 _u16[2]; ///< 16-bit unsigned shorts(s) | ||
| 76 | u8 _u8[4]; ///< 8-bit unsigned char(s) | ||
| 77 | }; | ||
| 78 | |||
| 79 | /// Union for fast 64-bit type casting | ||
| 80 | union t64 { | ||
| 81 | f64 _f64; ///< 64-bit floating point | ||
| 82 | u64 _u64; ///< 64-bit unsigned long | ||
| 83 | f32 _f32[2]; ///< 32-bit floating point(s) | ||
| 84 | u32 _u32[2]; ///< 32-bit unsigned int(s) | ||
| 85 | s32 _s32[2]; ///< 32-bit signed int(s) | ||
| 86 | u16 _u16[4]; ///< 16-bit unsigned shorts(s) | ||
| 87 | u8 _u8[8]; ///< 8-bit unsigned char(s) | ||
| 88 | }; | ||
| 89 | |||
| 90 | /// Union for fast 128-bit type casting | ||
| 91 | union t128 { | ||
| 92 | struct | ||
| 93 | { | ||
| 94 | t64 ps0; ///< 64-bit paired single 0 | ||
| 95 | t64 ps1; ///< 64-bit paired single 1 | ||
| 96 | }; | ||
| 97 | __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) | ||
| 98 | }; | ||
| 99 | |||
| 100 | /// Rectangle data structure | ||
| 101 | class Rect { | ||
| 102 | public: | ||
| 103 | Rect(int x0=0, int y0=0, int x1=0, int y1=0) { | ||
| 104 | x0_ = x0; | ||
| 105 | y0_ = y0; | ||
| 106 | x1_ = x1; | ||
| 107 | y1_ = y1; | ||
| 108 | } | ||
| 109 | ~Rect() { } | ||
| 110 | |||
| 111 | int x0_; ///< Rect top left X-coordinate | ||
| 112 | int y0_; ///< Rect top left Y-coordinate | ||
| 113 | int x1_; ///< Rect bottom left X-coordinate | ||
| 114 | int y1_; ///< Rect bottom right Y-coordinate | ||
| 115 | |||
| 116 | inline u32 width() const { return abs(x1_ - x0_); } | ||
| 117 | inline u32 height() const { return abs(y1_ - y0_); } | ||
| 118 | |||
| 119 | inline bool operator == (const Rect& val) const { | ||
| 120 | return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); | ||
| 121 | } | ||
| 122 | }; | ||