├── .gitignore ├── FixedPoint ├── FixedPoint.h ├── Triangle.h └── Vector.h ├── README.md └── tests ├── .gitignore ├── bios └── erase.me ├── iso_build ├── FixedPoint.xml └── system.cnf ├── main.cpp ├── makefile ├── setup.mk ├── tests.png ├── tests └── tests.h └── tools ├── FreeImage.dll ├── LICENSE.md ├── NO$PSX.CHR ├── NO$PSX.EXE ├── NO$PSX.FNT ├── NO$PSX.INI ├── NO$PSX.INP ├── PSXLICENSE.exe ├── README.md ├── img2tim.exe ├── img2tim.txt ├── libgcc_s_dw2-1.dll ├── libstdc++-6.dll ├── mkisoxml.exe └── mkpsxiso.exe /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .vscode 3 | bios/*.BIN 4 | build 5 | bin 6 | iso -------------------------------------------------------------------------------- /FixedPoint/FixedPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef _FIXED_POINT_H_ 2 | #define _FIXED_POINT_H_ 3 | namespace ps1 4 | { 5 | template 6 | struct FixedPoint 7 | { 8 | public: 9 | using Type = StoreType; 10 | FixedPoint() : _value(0) {} 11 | FixedPoint(const FixedPoint &other) : _value(other._value) {} 12 | FixedPoint(const int& value) : _value(value << FractionBits) {} 13 | FixedPoint(const volatile int& value) : _value(value << FractionBits) {} 14 | FixedPoint(const unsigned int& value) : _value(value << FractionBits) {} 15 | FixedPoint(const long& value) : _value(value << FractionBits) {} 16 | FixedPoint(const unsigned long& value) : _value(value << FractionBits) {} 17 | FixedPoint(const short& value) : _value(value << FractionBits) {} 18 | FixedPoint(const unsigned short& value) : _value(value << FractionBits) {} 19 | FixedPoint(const float& value) : _value(value * _ONE) {} 20 | FixedPoint(const double& value) : _value(value * _ONE) {} 21 | 22 | explicit operator int() const { return AsInt(); } 23 | explicit operator long() const { return AsInt(); } 24 | explicit operator unsigned int() const { return AsInt(); } 25 | explicit operator unsigned long() const { return AsInt(); } 26 | explicit operator float() const { return AsFloat(); } 27 | explicit operator double() const { return AsFloat(); } 28 | 29 | FixedPoint &operator=(const FixedPoint &other) { _value = other._value; return *this; } 30 | 31 | constexpr bool operator==(const FixedPoint &other) const { return _value == other._value; } 32 | constexpr bool operator!=(const FixedPoint &other) const { return _value != other._value; } 33 | constexpr bool operator<(const FixedPoint &other) const { return _value < other._value; } 34 | constexpr bool operator<=(const FixedPoint &other) const { return _value <= other._value; } 35 | constexpr bool operator>(const FixedPoint &other) const { return _value > other._value; } 36 | constexpr bool operator>=(const FixedPoint &other) const { return _value >= other._value; } 37 | 38 | constexpr FixedPoint operator~() const { return set(~_value); } 39 | constexpr FixedPoint operator+() const { return *this; } 40 | constexpr FixedPoint operator-() const { return set(-_value); } 41 | 42 | constexpr FixedPoint operator+(const FixedPoint &other) const { return set(_value + other._value); } 43 | constexpr FixedPoint operator-(const FixedPoint &other) const { return set(_value - other._value); } 44 | constexpr FixedPoint operator*(const FixedPoint &other) const { return set(((IntermediateType)_value * (IntermediateType)other._value) >> FractionBits); } 45 | inline constexpr FixedPoint operator/(const FixedPoint &other) const 46 | { 47 | if constexpr (UseLibC) 48 | { 49 | if(other._value == 0) return 0; 50 | return set((((IntermediateType)_value)<> FractionBits; return *this; } 62 | FixedPoint& operator/=(const FixedPoint &other) { _value = ((((IntermediateType) _value)<>(int numBits) const { return set(_value >> numBits); } 71 | 72 | FixedPoint& operator<<=(int numBits) { _value <<= numBits; return *this;} 73 | FixedPoint& operator>>=(int numBits) { _value >>= numBits; return *this;} 74 | 75 | FixedPoint& operator++() { _value += 1<> FractionBits; } 86 | constexpr float AsFloat() const { return (float)_value / _ONE; } 87 | 88 | static constexpr FixedPoint PI() { return set(_ONE * 3.14159265359f); } 89 | static constexpr FixedPoint E() { return set(_ONE * 2.71828182845905); } 90 | static constexpr FixedPoint Zero = FixedPoint(0); 91 | static constexpr FixedPoint One = FixedPoint(1); 92 | static constexpr FixedPoint MinValue {._value = 2147483646}; 93 | static constexpr FixedPoint MaxValue = {._value = 2147483647}; 94 | static constexpr FixedPoint Epsilon() { return 0.000244140625; }; 95 | 96 | private: 97 | StoreType _value; 98 | static constexpr StoreType _ONE = 1 << FractionBits; 99 | static constexpr int INTEGER_BITS = sizeof(int) * 8 - FractionBits; 100 | static constexpr int FRACTION_MASK = (((int)0xFFFFFFFF) >> FractionBits); 101 | static constexpr int INTEGER_MASK = (-1 & ~FRACTION_MASK); 102 | static constexpr int FRACTION_RANGE = FRACTION_MASK + 1; 103 | static constexpr int MIN_INTEGER = (-2147483647 - 1) >> FractionBits; 104 | static constexpr int MAX_INTEGER = (2147483647) >> FractionBits; 105 | 106 | static constexpr FixedPoint set(StoreType value) 107 | { 108 | FixedPoint f; 109 | f._value = value; 110 | return f; 111 | } 112 | inline const unsigned int internalDivision(unsigned long long rem, unsigned int base) const 113 | { 114 | rem <<= FractionBits; 115 | unsigned long long b = base; 116 | unsigned long long res, d = 1; 117 | unsigned int high = rem >> 32; 118 | 119 | res = 0; 120 | if (high >= base) { 121 | high /= base; 122 | res = (unsigned long long)high << 32; 123 | rem -= (unsigned long long)(high * base) << 32; 124 | } 125 | 126 | while ((long long)b > 0 && b < rem) { 127 | b = b + b; 128 | d = d + d; 129 | } 130 | 131 | do { 132 | if (rem >= b) { 133 | rem -= b; 134 | res += d; 135 | } 136 | b >>= 1; 137 | d >>= 1; 138 | } while (d); 139 | 140 | return res; 141 | } 142 | 143 | inline constexpr int Divide(int a, int b) const 144 | { 145 | int s = 1; 146 | if (a < 0) { 147 | a = -a; 148 | s = -1; 149 | } 150 | if (b < 0) { 151 | b = -b; 152 | s = -s; 153 | } 154 | return internalDivision(a, b) * s; 155 | } 156 | 157 | }; //struct FixedPoint 158 | 159 | } //namespace ps1 160 | 161 | #endif //_FIXED_POINT_H_ -------------------------------------------------------------------------------- /FixedPoint/Triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRIANGLE_H_ 2 | #define _TRIANGLE_H_ 3 | namespace ps1 4 | { 5 | template 6 | struct Triangle 7 | { 8 | Vector3T vertex0, vertex1, vertex2; 9 | }; 10 | 11 | template 12 | inline const bool RayIntersectsTriangle(const Vector3T& origin, 13 | const Vector3T& direction, 14 | const TriangleT& triangle, 15 | Vector3T& intersectPoint) 16 | { 17 | typedef typename Vector3T::Float Float; 18 | const Float EPSILON = 0.01f; 19 | const Vector3T& vertex0 = triangle.vertex0; 20 | const Vector3T& vertex1 = triangle.vertex1; 21 | const Vector3T& vertex2 = triangle.vertex2; 22 | const Vector3T& edge1 = vertex1 - vertex0; 23 | const Vector3T& edge2 = vertex2 - vertex0; 24 | const Vector3T& h = direction.crossProduct(direction, edge2); 25 | 26 | const Float& a = edge1.dotProduct(edge1, h); 27 | if (a > -EPSILON && a < EPSILON) 28 | return false; // This ray is parallel to this triangle. 29 | const Float& f = Float(1.0f)/a; 30 | const Vector3T& s = origin - vertex0; 31 | const Float& u = s.dotProduct(s, h) * f; 32 | if (u < 0.0 || u > 1.0) 33 | return false; 34 | const Vector3T& q = s.crossProduct(s, edge1); 35 | const Float& v = f * direction.dotProduct(q); 36 | if (v < 0.0 || u + v > 1.0) 37 | return false; 38 | // At this stage we can compute t to find out where the intersection point is on the line. 39 | const Float& t = f * edge2.dotProduct(q); 40 | if (t > EPSILON) // ray intersection 41 | { 42 | intersectPoint = origin + direction * t; 43 | return true; 44 | } 45 | else // This means that there is a line intersection but not a ray intersection. 46 | return false; 47 | } 48 | 49 | }//namespace ps1 50 | 51 | #endif //#ifndef _TRIANGLE_H_ -------------------------------------------------------------------------------- /FixedPoint/Vector.h: -------------------------------------------------------------------------------- 1 | #ifndef _VECTOR_H_ 2 | #define _VECTOR_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace ps1 8 | { 9 | template 10 | struct Vector3F; 11 | 12 | typedef Vector3F Vector3D; 13 | typedef Vector3F SVector3D; 14 | 15 | inline void gte_ldv0_f(const VECTOR& v0) 16 | { 17 | int xy11 = ((v0.vx&0xFFFF)|(v0.vy<<16)); 18 | int z11 = v0.vz; 19 | asm volatile ("mtc2 %0, $0\n" : "+r"(xy11) : : ); 20 | asm volatile ("mtc2 %0, $1\nnop\nnop\n" : "+r"(z11) : : ); 21 | } 22 | 23 | #define gte_stlvnl( r0 ) __asm__ volatile ( \ 24 | "swc2 $25, 0( %0 );" \ 25 | "swc2 $26, 4( %0 );" \ 26 | "swc2 $27, 8( %0 )" \ 27 | : \ 28 | : "r"( r0 ) \ 29 | : "memory" ) 30 | 31 | #define gte_ldlvl( r0 ) __asm__ volatile ( \ 32 | "lwc2 $9 , 0( %0 );" \ 33 | "lwc2 $10 , 4( %0 );" \ 34 | "lwc2 $11 , 8( %0 );" \ 35 | : \ 36 | : "r"( r0 ) \ 37 | : "$t0" ) 38 | 39 | inline void gte_ldlvl_f(const VECTOR& v0) 40 | { 41 | asm volatile ("mtc2 %0, $25\n" : : "r"(v0.vx): ); 42 | asm volatile ("mtc2 %0, $26\n" : : "r"(v0.vy): ); 43 | asm volatile ("mtc2 %0, $27\n" : : "r"(v0.vz): ); 44 | } 45 | 46 | #define gte_ldlvl_1( r0 ) __asm__ volatile ( \ 47 | "mtc2 %0, $9" \ 48 | : \ 49 | : "r"( r0 ) ) 50 | 51 | #define gte_ldlvl_2( r0 ) __asm__ volatile ( \ 52 | "mtc2 %0, $10" \ 53 | : \ 54 | : "r"( r0 ) ) 55 | #define gte_ldlvl_3( r0 ) __asm__ volatile ( \ 56 | "mtc2 %0, $11" \ 57 | : \ 58 | : "r"( r0 ) ) 59 | #define gte_stmac_1() ({ u_long __value;\ 60 | __asm__ volatile ( \ 61 | ".set noreorder;" \ 62 | "mfc2 %0, $25;" \ 63 | "nop;" \ 64 | ".set reorder" \ 65 | : "=r"( __value ) :);\ 66 | __value;}) 67 | #define gte_stmac_2() ({ u_long __value;\ 68 | __asm__ volatile ( \ 69 | ".set noreorder;" \ 70 | "mfc2 %0, $26;" \ 71 | "nop;" \ 72 | ".set reorder" \ 73 | : "=r"( __value ) :);\ 74 | __value;}) 75 | #define gte_stmac_3() ({ u_long __value;\ 76 | __asm__ volatile ( \ 77 | ".set noreorder;" \ 78 | "mfc2 %0, $27;" \ 79 | "nop;" \ 80 | ".set reorder" \ 81 | : "=r"( __value ) :);\ 82 | __value;}) 83 | inline void gte_stlvnl_f(VECTOR& v0) 84 | { 85 | asm volatile ("mfc2 %0, $9\n" : "=r"(v0.vx): :); 86 | asm volatile ("mfc2 %0, $10\n" : "=r"(v0.vy): :); 87 | asm volatile ("mfc2 %0, $11\n" : "=r"(v0.vz): :); 88 | } 89 | 90 | template 91 | struct Vector3F : public VectorType 92 | { 93 | using type = decltype(VectorType::vx); 94 | Vector3F() 95 | :VectorType{0,0,0} 96 | {} 97 | Vector3F(type vx, type vy, type vz) 98 | :VectorType{.vx=vx, .vy=vy, .vz=vz} 99 | { 100 | 101 | } 102 | 103 | Vector3F(const VectorType& vector ) 104 | :VectorType{vector} 105 | { 106 | 107 | } 108 | const Vector3F operator-(const Vector3F& other) const 109 | { 110 | return {VectorType::vx - other.vx, VectorType::vy - other.vy, VectorType::vz - other.vz}; 111 | } 112 | 113 | inline static constexpr Vector3D crossProduct(const Vector3F& right) 114 | { 115 | return {((VectorType::vy*right.vz)-(VectorType::vz*right.vy)>>12), 116 | ((VectorType::vz*right.vx)-(VectorType::vx*right.vz)>>12), 117 | ((VectorType::vx*right.vy)-(VectorType::vy*right.vx)>>12) 118 | }; 119 | } 120 | 121 | inline static constexpr Vector3D crossProduct(const Vector3F& left, const Vector3F& right) 122 | { 123 | return{(((left.vy*right.vz)-(left.vz*right.vy))>>12), 124 | (((left.vz*right.vx)-(left.vx*right.vz))>>12), 125 | (((left.vx*right.vy)-(left.vy*right.vx))>>12) 126 | }; 127 | } 128 | 129 | constexpr inline int length() const 130 | { 131 | const auto dot = dotProduct(); 132 | return SquareRoot12(dot<<12); 133 | } 134 | 135 | static const int length(const Vector3F& vector) 136 | { 137 | return SquareRoot12(dotProduct(vector, vector)); 138 | } 139 | 140 | constexpr inline int dotProduct() const 141 | { 142 | if constexpr(is_same::value) 143 | { 144 | 145 | VECTOR myinput{VectorType::vx<<12, VectorType::vy<<12, VectorType::vz<<12}; 146 | gte_ldlvl(&myinput); 147 | gte_sqr12(); 148 | VECTOR out; 149 | gte_stlvnl(&out); 150 | return (out.vx+out.vy+out.vz)>>12; 151 | } 152 | else 153 | { 154 | return VectorType::vx*VectorType::vx + VectorType::vy*VectorType::vy + VectorType::vz*VectorType::vz; 155 | } 156 | } 157 | 158 | const int dotProduct(const Vector3F& other) const 159 | { 160 | return VectorType::vx*other.vx + VectorType::vy*other.vy + VectorType::vz * other.vz; 161 | } 162 | 163 | const inline SVector3D normalize() 164 | { 165 | SVector3D output; 166 | VectorNormalS(this, &output); 167 | return output; 168 | } 169 | 170 | static constexpr inline SVector3D normalize(const VectorType& input) 171 | { 172 | SVector3D output; 173 | VectorNormalS(&input, &output); 174 | return output; 175 | } 176 | 177 | operator VectorType& () 178 | { 179 | return this; 180 | } 181 | 182 | inline constexpr operator VectorType*() const 183 | { 184 | return this; 185 | } 186 | 187 | inline operator VectorType*() 188 | { 189 | return this; 190 | } 191 | }; 192 | 193 | const Vector3D operator*(const Vector3D& vector, const int other) 194 | { 195 | return {vector.vx*other,vector.vy*other,vector.vz*other}; 196 | } 197 | 198 | const Vector3D operator*(const SVector3D& vector, const int other) 199 | { 200 | return {vector.vx*other,vector.vy*other,vector.vz*other}; 201 | } 202 | 203 | 204 | const Vector3D operator+(const Vector3D& left, const auto& right) 205 | { 206 | return {left.vx+right.vx,left.vy+right.vy,left.vz+right.vz}; 207 | } 208 | 209 | const Vector3D operator+(const auto& left, const Vector3D& right) 210 | { 211 | return {left.vx+right.vx,left.vy+right.vy,left.vz+right.vz}; 212 | } 213 | 214 | 215 | } //namespace ps1 216 | 217 | #endif //#ifndef _VECTOR_H_ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PS1FixedPoint 2 | FixedPoint Arithmetic in C++ for PS1 using PSn00bSDK and modern C++ 3 | 4 | 5 | ## Setting up PSn00bSDK 6 | Please follow the author steps: https://github.com/Lameguy64/PSn00bSDK/ 7 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .vscode 3 | bios/*.BIN 4 | build 5 | bin 6 | iso -------------------------------------------------------------------------------- /tests/bios/erase.me: -------------------------------------------------------------------------------- 1 | Copy your bios file here. -------------------------------------------------------------------------------- /tests/iso_build/FixedPoint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 20 | 33 | 34 | 35 | 52 | 61 | 62 | 73 | 74 | 75 | 83 | 84 | 85 | 99 | 100 | 101 | 102 | 103 | 104 | 114 | 117 | 118 | 121 | 124 | 126 | 129 | 130 | 131 | 132 | 144 | 145 | 146 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 168 | 170 | 171 | -------------------------------------------------------------------------------- /tests/iso_build/system.cnf: -------------------------------------------------------------------------------- 1 | BOOT = cdrom:\SLUS_034.34;1 2 | TCB = 4 3 | EVENT = 16 4 | STACK = 0x80010000 5 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include <../FixedPoint/FixedPoint.h> 11 | #include <../FixedPoint/Vector.h> 12 | #include <../FixedPoint/Triangle.h> 13 | 14 | DISPENV disp[2]; 15 | DRAWENV draw[2]; 16 | int db; 17 | 18 | using ps1::FixedPoint; 19 | using ps1::Vector3F; 20 | 21 | constexpr bool USE_LIBC_CALL_FOR_64BIT_DIVISION = true; 22 | 23 | typedef FixedPoint<12, int, long long, USE_LIBC_CALL_FOR_64BIT_DIVISION> Float; 24 | typedef FixedPoint<12, short, long long, USE_LIBC_CALL_FOR_64BIT_DIVISION> SFloat; 25 | 26 | template 27 | constexpr T abs(const T& value) 28 | { 29 | if(value > 0) 30 | return value; 31 | return value * -1; 32 | } 33 | 34 | void init(void) 35 | { 36 | ResetGraph(0); 37 | 38 | SetDefDispEnv(&disp[0], 0, 0, 320, 240); 39 | SetDefDispEnv(&disp[1], 0, 240, 320, 240); 40 | 41 | SetDefDrawEnv(&draw[0], 0, 240, 320, 240); 42 | SetDefDrawEnv(&draw[1], 0, 0, 320, 240); 43 | 44 | setRGB0(&draw[0], 0, 96, 0); 45 | setRGB0(&draw[1], 0, 96, 0); 46 | draw[0].isbg = 1; 47 | draw[1].isbg = 1; 48 | 49 | db = 0; 50 | 51 | PutDispEnv(&disp[db]); 52 | PutDrawEnv(&draw[db]); 53 | 54 | FntLoad(960, 0); 55 | FntOpen(0, 8, 320, 224, 0, 100); 56 | } 57 | 58 | void display(void) 59 | { 60 | db = !db; 61 | //DrawSync(0); 62 | //VSync(0); 63 | PutDispEnv(&disp[db]); 64 | PutDrawEnv(&draw[db]); 65 | SetDispMask(1); 66 | 67 | } 68 | 69 | int main(int argc, const char *argv[]) 70 | { 71 | #define RCntIntr 0x1000 /*Interrupt mode*/ 72 | SetRCnt(RCntCNT1, 0xffff, RCntIntr); 73 | StartRCnt(RCntCNT1); 74 | int counter = 0; 75 | 76 | init(); 77 | volatile int v1 = 1; 78 | volatile int v2 = 50; 79 | volatile int v3 = 6; 80 | 81 | while(1) 82 | { 83 | Assert.Reset(); 84 | 85 | //Size tests 86 | Assert.AreEqual((int)sizeof(int), 4, __LINE__); 87 | Assert.AreEqual((int)sizeof(long), 4, __LINE__); 88 | Assert.AreEqual((int)sizeof(long long), 8, __LINE__); 89 | Assert.AreEqual((int)sizeof(Float), 4, __LINE__); 90 | Assert.AreEqual((int)sizeof(SFloat), 2, __LINE__); 91 | Assert.AreEqual((int)sizeof(ps1::Vector3D), 12, __LINE__); 92 | Assert.AreEqual((int)sizeof(ps1::SVector3D), 8, __LINE__); 93 | //Basic Float tests 94 | Assert.AreEqual(Float(1).AsFixedPoint(), 4096, __LINE__); 95 | Assert.AreEqual(Float(32).AsFixedPoint(), 131072, __LINE__); 96 | Assert.AreEqual(Float(16).AsFixedPoint(), 65536, __LINE__); 97 | 98 | Assert.AreEqual(-Float(16).AsInt(), -16, __LINE__); 99 | 100 | Assert.AreEqual((Float(16) + Float(16)), Float(32), __LINE__, "operator+"); 101 | Assert.AreEqual((Float(32) - Float(16)), Float(16), __LINE__, "operator-"); 102 | Assert.AreEqual((Float(16) * Float(2)), Float(32), __LINE__, "operator*"); 103 | Assert.AreEqual((Float(32) / Float(2)), Float(16), __LINE__, "operator/"); 104 | 105 | Assert.AreEqual( (~Float(32)).AsInt(), ~32, __LINE__, "operator~"); 106 | Assert.AreEqual( (+Float(32)).AsInt(), +32, __LINE__, "operator+"); 107 | Assert.AreEqual( (-Float(32)).AsInt(), -32, __LINE__, "operator-"); 108 | 109 | Assert.AreEqual(Float(32) == Float(32), true, __LINE__, "operator=="); 110 | Assert.AreEqual(Float(0) != Float(32), true, __LINE__, "operator!="); 111 | 112 | Assert.AreEqual(Float(31) < Float(32), true, __LINE__, "operator<"); 113 | Assert.AreEqual(Float(31) <= Float(32), true, __LINE__, "operator<="); 114 | Assert.AreEqual(Float(31) <= Float(31), true, __LINE__, "operator<="); 115 | 116 | Assert.AreEqual(Float(32) > Float(31), true, __LINE__, "operator>"); 117 | Assert.AreEqual(Float(32) >= Float(31), true, __LINE__, "operator>="); 118 | Assert.AreEqual(Float(32) >= Float(32), true, __LINE__, "operator>="); 119 | 120 | Assert.AreEqual( Float(16)+=16, Float(32), __LINE__, "operator+="); 121 | Assert.AreEqual( Float(16)-=8, Float(8), __LINE__, "operator-="); 122 | Assert.AreEqual( Float(16)*=2, Float(32), __LINE__, "operator*="); 123 | Assert.AreEqual( Float(32)/=2, Float(16), __LINE__, "operator/="); 124 | Assert.AreEqual( (Float(32)%=2).AsInt(), 32%2, __LINE__, "operator%="); 125 | 126 | Assert.AreEqual( (Float(16)|=8).AsInt(), 16|8, __LINE__, "operator|="); 127 | Assert.AreEqual( (Float(16)&=2).AsInt(), 16&2, __LINE__, "operator&="); 128 | Assert.AreEqual( (Float(32)^=2).AsInt(), 32^2, __LINE__, "operator^="); 129 | 130 | Assert.AreEqual( (Float(16)>>1).AsInt(), 16>>1, __LINE__, "operator>>"); 131 | Assert.AreEqual( (Float(16)<<1).AsInt(), 16<<1, __LINE__, "operator<<"); 132 | 133 | Assert.AreEqual( (Float(16)>>=1).AsInt(), 16>>1, __LINE__, "operator>>="); 134 | Assert.AreEqual( (Float(16)<<=1).AsInt(), 16<<1, __LINE__, "operator<<="); 135 | 136 | Assert.AreEqual( (Float(16)++).AsInt(), 17, __LINE__, "operator++"); 137 | Assert.AreEqual( (Float(16)--).AsInt(), 15, __LINE__, "operator--"); 138 | 139 | Assert.AreEqual( Float(-16).Abs(), Float(16), __LINE__, "Abs"); 140 | 141 | Assert.IsLessThan(abs(Float::PI().AsFloat() - 3.14159265359f), Float::Epsilon().AsFloat(), __LINE__); 142 | Assert.IsLessThan(abs(Float::E().AsFloat() - 2.71828182845905f), Float::Epsilon().AsFloat(), __LINE__); 143 | 144 | Assert.AreEqual(Float::FromFixedPoint(SquareRoot12(Float(49).AsFixedPoint())), Float(7), __LINE__); 145 | //round error from 5.65685424949 146 | Assert.AreEqual(Float::FromFixedPoint(SquareRoot12(Float(32).AsFixedPoint())).AsFixedPoint(), Float(5.6564f).AsFixedPoint(), __LINE__); 147 | 148 | ps1::Vector3D vector(1,50,6); 149 | const auto dot = vector.dotProduct(vector); 150 | 151 | Assert.AreEqual(dot, 2537, __LINE__); 152 | 153 | //There are some precision differences in the SquareRoot12 and sqrt 154 | Assert.AreEqual(SquareRoot12(2537<<12), Float(50.2736f).AsFixedPoint(), __LINE__); 155 | 156 | const auto magnitude = vector.length(); 157 | Assert.AreEqual(magnitude, Float(50.2736f).AsFixedPoint(), __LINE__); 158 | 159 | ps1::Vector3D svector(1,8,6); 160 | const auto smagnitude = svector.length(); 161 | Assert.AreEqual(smagnitude, Float(10.049f).AsFixedPoint(), __LINE__); 162 | 163 | 164 | 165 | const ps1::SVector3D nomalized = ps1::Vector3D::normalize(ps1::Vector3D(v1,v2,v3)); 166 | const ps1::SVector3D test(Float(0.0199f).AsFixedPoint(), Float(0.9941f).AsFixedPoint(), Float(0.1192f).AsFixedPoint()); 167 | Assert.AreEqual(nomalized.vx, test.vx, __LINE__); 168 | Assert.AreEqual(nomalized.vy, test.vy, __LINE__); 169 | Assert.AreEqual(nomalized.vz, test.vz, __LINE__); 170 | 171 | ps1::Vector3D input{Float(1.0f).AsFixedPoint(),Float(0.75f).AsFixedPoint(),Float(0.5f).AsFixedPoint()}; 172 | ps1::SVector3D output; 173 | VectorNormalS(input, output); 174 | Assert.AreEqual(output.vx, SFloat(0.742781352f).AsFixedPoint(), __LINE__); 175 | Assert.AreEqual(output.vy, SFloat(0.557086014f).AsFixedPoint(), __LINE__); 176 | Assert.AreEqual(output.vz, SFloat(0.371390676f).AsFixedPoint(), __LINE__); 177 | Assert.AreEqual((int)sizeof(input),12, __LINE__); 178 | Assert.AreEqual((int)sizeof(output),8, __LINE__); 179 | 180 | Assert.AreEqual((Float(128)/Float(4)).AsInt(), 128/4, __LINE__); 181 | Assert.AreEqual((Float(-4096)/Float(4)).AsInt(), -4096/4, __LINE__); 182 | Assert.AreEqual((Float(128)/Float(256)).AsFloat(), 128.0f/256.0f, __LINE__); 183 | Assert.AreEqual((Float(-128)/Float(256)).AsFloat(), -128.0f/256.0f, __LINE__); 184 | Assert.IsLessThan((Float(-32.15f)/Float(2.51f)).AsFloat() - (-32.15f/2.51f), 0.001f, __LINE__); 185 | 186 | const ps1::Vector3D testv(1,513,6); 187 | const auto dotv = testv.dotProduct(testv); 188 | Assert.AreEqual(dotv, 263206, __LINE__); 189 | 190 | //Performance test 191 | /* 192 | int OldValue = 0; 193 | ResetRCnt(RCntCNT1); 194 | OldValue = GetRCnt(RCntCNT1); 195 | unsigned int value = 0; 196 | //const Vector3D vectorTest(v1,v2,v3); 197 | 198 | for(int i = 200; i < 201; ++i) 199 | { 200 | ps1::Vector3D input = ps1::Vector3D(v1,i,v3); 201 | const auto output = ps1::Vector3D::normalize(input); 202 | value += output.vx; 203 | } 204 | int NewValue = GetRCnt(RCntCNT1) - OldValue; 205 | FntPrint(-1, "It took %d HBlanks! Count=%d\n", NewValue, value); 206 | 207 | ResetRCnt(RCntCNT1); 208 | OldValue = GetRCnt(RCntCNT1); 209 | value = 0; 210 | //const Vector3D vectorTest(v1,v2,v3); 211 | 212 | for(int i = 200; i < 201; ++i) 213 | { 214 | VECTOR input{v1,i,v3}; 215 | SVECTOR output; 216 | VectorNormalS(&input, &output); 217 | value += output.vx; 218 | } 219 | NewValue = GetRCnt(RCntCNT1) - OldValue; 220 | FntPrint(-1, "It took %d HBlanks! Count=%d\n", NewValue, value); 221 | */ 222 | 223 | if(Assert.ErrorCount() == 0) 224 | { 225 | FntPrint(-1, "All %d tests passed!\n", Assert.TestCount()); 226 | } 227 | else 228 | { 229 | FntPrint(-1, "%d tests failed! \n%s\n", Assert.ErrorCount(), Assert.LastError()); 230 | } 231 | 232 | 233 | FntFlush(-1); 234 | display(); 235 | counter++; 236 | } 237 | 238 | return 0; 239 | } 240 | -------------------------------------------------------------------------------- /tests/makefile: -------------------------------------------------------------------------------- 1 | include setup.mk 2 | 3 | # Project target name 4 | TARGET = FixedPoint 5 | 6 | #TOOLS 7 | MKPSXISO = tools/mkpsxiso.exe 8 | MKPSXISO_XML= iso_build/FixedPoint.xml 9 | BIN_FOLDER = bin 10 | ISO_FOLDER = iso 11 | 12 | #EMULATOR 13 | EMUBIN = D:\\Games\\Emuladores\\Playstation\\ePSXe.exe 14 | EMU_CMD = $(EMUBIN) -nogui -loadbin iso/$(TARGET).cue 15 | 16 | #ENGINE 17 | ENGINE_DIR = ..\\FixedPoint 18 | 19 | # Searches for C, C++ and S (assembler) files in local directory 20 | CFILES = $(notdir $(wildcard *.c)) 21 | CPPFILES = $(notdir $(wildcard *.cpp)) 22 | AFILES = $(notdir $(wildcard *.s)) 23 | 24 | CPPENGINE = $(notdir $(wildcard $(ENGINE_DIR)/*.cpp)) 25 | 26 | # Determine object files 27 | #ENGINEFILES = $(addprefix build/engine/,$(CPPENGINE:.cpp=.o)) 28 | 29 | OFILES = $(addprefix build/,$(CFILES:.c=.o)) \ 30 | $(addprefix build/,$(CPPFILES:.cpp=.o)) \ 31 | $(addprefix build/,$(AFILES:.s=.o)) 32 | 33 | 34 | # Project specific include and library directories 35 | # (use -I for include dirs, -L for library dirs) 36 | INCLUDE += -I. -Iengine -Itests -Iengine/include 37 | LIBDIRS += 38 | 39 | # Libraries to link 40 | LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc 41 | 42 | # C compiler flags 43 | CFLAGS = -g -O3 -fno-builtin -fdata-sections -ffunction-sections -Wno-narrowing 44 | 45 | # C++ compiler flags 46 | CPPFLAGS = $(CFLAGS) -fno-exceptions \ 47 | -fno-rtti \ 48 | -fno-unwind-tables \ 49 | -fno-threadsafe-statics \ 50 | -fno-use-cxa-atexit \ 51 | -Wno-narrowing \ 52 | -std=c++20 53 | 54 | # Assembler flags 55 | AFLAGS = -g -msoft-float 56 | 57 | # Linker flags 58 | LDFLAGS = -g -Ttext=0x80010000 -gc-sections \ 59 | -T $(GCC_BASE)/mipsel-none-elf/lib/ldscripts/elf32elmip.x 60 | 61 | 62 | all: $(OFILES) $(ENGINEFILES) 63 | @mkdir -p $(BIN_FOLDER) 64 | $(LD) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(ENGINEFILES) $(LIBS) -o bin/$(TARGET) 65 | $(ELF2X) -q $(BIN_FOLDER)/$(TARGET) $(BIN_FOLDER)/$(TARGET).exe 66 | $(ELF2X) -q $(BIN_FOLDER)/$(TARGET) $(BIN_FOLDER)/$(TARGET) 67 | 68 | iso: all 69 | @mkdir -p $(ISO_FOLDER) 70 | @rm -rf $(ISO_FOLDER)/*.cue $(ISO_FOLDER)/*.bin 71 | @$(MKPSXISO) $(MKPSXISO_XML) 72 | @mv *.cue $(ISO_FOLDER) 73 | @mv *.bin $(ISO_FOLDER) 74 | 75 | run: iso 76 | $(EMU_CMD) 77 | 78 | build/%.o: %.c 79 | @mkdir -p $(dir $@) 80 | $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 81 | 82 | build/%.o: %.cpp 83 | @mkdir -p $(dir $@) 84 | $(CXX) $(AFLAGS) $(CPPFLAGS) $(INCLUDE) -c $< -o $@ 85 | 86 | build/%.o: %.s 87 | @mkdir -p $(dir $@) 88 | $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@ 89 | 90 | 91 | 92 | build/engine/%.o: %.cpp 93 | @mkdir -p $(dir $@) 94 | $(CXX) $(AFLAGS) $(CPPFLAGS) $(INCLUDE) -c $< -o $@ 95 | 96 | 97 | 98 | 99 | 100 | clean: 101 | rm -rf build $(BIN_FOLDER) $(ISO_FOLDER) *.bin *.cue -------------------------------------------------------------------------------- /tests/setup.mk: -------------------------------------------------------------------------------- 1 | PREFIX = mipsel-none-elf- 2 | 3 | GCC_VERSION = 12.2.0 4 | 5 | PSN00B_BASE = ../../psn00bsdk/ 6 | LIBDIRS = -L$(PSN00B_BASE)libpsn00b 7 | INCLUDE = -I$(PSN00B_BASE)libpsn00b/include 8 | 9 | ELF2X = $(PSN00B_BASE)/tools/bin/elf2x 10 | 11 | GCC_BASE = /c/mipsel-none-elf 12 | GCC_BIN = $(GCC_BASE)/bin/ 13 | 14 | CC = $(GCC_BIN)$(PREFIX)gcc 15 | CXX = $(GCC_BIN)$(PREFIX)g++ 16 | AS = $(GCC_BIN)$(PREFIX)as 17 | AR = $(GCC_BIN)$(PREFIX)ar 18 | RANLIB = $(GCC_BIN)$(PREFIX)ranlib 19 | LD = $(GCC_BIN)$(PREFIX)ld -------------------------------------------------------------------------------- /tests/tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tests.png -------------------------------------------------------------------------------- /tests/tests/tests.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | constexpr int test(const char* name, bool test) 5 | { 6 | if(!test) 7 | { 8 | FntPrint(-1, "%s = FAIL!\n", name); 9 | } 10 | return test ? 0 : 1; 11 | } 12 | 13 | template 14 | struct is_same 15 | { 16 | static constexpr bool value = false; 17 | }; 18 | 19 | template 20 | struct is_same 21 | { 22 | static constexpr bool value = true; 23 | }; 24 | 25 | class _assert 26 | { 27 | private: 28 | unsigned int mTestCount = 0; 29 | unsigned int mErrorCount = 0; 30 | char LastTestWithError[256]{'\0'}; 31 | public: 32 | template 33 | void AreEqual(const testType& l, const testType& r, int line) 34 | { 35 | mTestCount++; 36 | const bool test = l == r; 37 | mErrorCount += test ? 0 : 1; 38 | if(!test) 39 | { 40 | memset(&LastTestWithError[0], '\0', 256); 41 | if constexpr (is_same::value) 42 | { 43 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %lld == %lld", __FUNCTION__, line, l, r); 44 | return; 45 | } 46 | if constexpr (is_same::value) 47 | { 48 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %lu == %lu", __FUNCTION__, line, l, r); 49 | return; 50 | } 51 | if constexpr (is_same::value) 52 | { 53 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %ld == %ld", __FUNCTION__, line, l, r); 54 | return; 55 | } 56 | if constexpr (is_same::value) 57 | { 58 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d == %d", __FUNCTION__, line, l, r); 59 | return; 60 | } 61 | if constexpr (is_same::value) 62 | { 63 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d == %d", __FUNCTION__, line, l, r); 64 | return; 65 | } 66 | if constexpr (is_same::value) 67 | { 68 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %f == %f", __FUNCTION__, line, l, r); 69 | return; 70 | } 71 | 72 | sprintf(&LastTestWithError[0], "%s LINE: %d ASSERT FAILED. Unknown type", __FUNCTION__, line); 73 | } 74 | } 75 | 76 | template 77 | void AreEqual(const testType& l, const testType& r, int line, const char* testName) 78 | { 79 | mTestCount++; 80 | const bool test = l == r; 81 | mErrorCount += test ? 0 : 1; 82 | if(!test) 83 | { 84 | memset(&LastTestWithError[0], '\0', 256); 85 | if constexpr (is_same::value) 86 | { 87 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %ll == %ll", testName, line, l, r); 88 | return; 89 | } 90 | if constexpr (is_same::value) 91 | { 92 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %lu == %lu", testName, line, l, r); 93 | return; 94 | } 95 | if constexpr (is_same::value) 96 | { 97 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %ld == %ld", testName, line, l, r); 98 | return; 99 | } 100 | if constexpr (is_same::value) 101 | { 102 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d == %d", testName, line, l, r); 103 | return; 104 | } 105 | 106 | if constexpr (is_same::value) 107 | { 108 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d == %d", testName, line, l, r); 109 | return; 110 | } 111 | 112 | if constexpr (is_same::value) 113 | { 114 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %f == %f", testName, line, l, r); 115 | return; 116 | } 117 | 118 | sprintf(&LastTestWithError[0], "%s LINE: %d ASSERT FAILED. Unknown type", testName, line); 119 | } 120 | } 121 | 122 | template 123 | void IsLessThan(const testType& l, const testType& r, int line) 124 | { 125 | mTestCount++; 126 | const bool test = l < r; 127 | mErrorCount += test ? 0 : 1; 128 | if(!test) 129 | { 130 | memset(&LastTestWithError[0], '\0', 256); 131 | if constexpr (is_same::value) 132 | { 133 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %lu < %lu", __FUNCTION__, line, l, r); 134 | return; 135 | } 136 | if constexpr (is_same::value) 137 | { 138 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %ld < %ld", __FUNCTION__, line, l, r); 139 | return; 140 | } 141 | if constexpr (is_same::value) 142 | { 143 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d < %d", __FUNCTION__, line, l, r); 144 | return; 145 | } 146 | if constexpr (is_same::value) 147 | { 148 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %d < %d", __FUNCTION__, line, l, r); 149 | return; 150 | } 151 | if constexpr (is_same::value) 152 | { 153 | sprintf(&LastTestWithError[0], "%s LINE: %d FAIL: %f < %f", __FUNCTION__, line, l, r); 154 | return; 155 | } 156 | 157 | sprintf(&LastTestWithError[0], "%s LINE: %d ASSERT FAILED. Unknown type", __FUNCTION__, line); 158 | } 159 | } 160 | 161 | const char* LastError() { return LastTestWithError; } 162 | 163 | void Reset() { mTestCount = mErrorCount = 0; } 164 | 165 | unsigned int ErrorCount() { return mErrorCount; } 166 | unsigned int TestCount() { return mTestCount; } 167 | }; 168 | 169 | _assert Assert; -------------------------------------------------------------------------------- /tests/tools/FreeImage.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/FreeImage.dll -------------------------------------------------------------------------------- /tests/tools/LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /tests/tools/NO$PSX.CHR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/NO$PSX.CHR -------------------------------------------------------------------------------- /tests/tools/NO$PSX.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/NO$PSX.EXE -------------------------------------------------------------------------------- /tests/tools/NO$PSX.FNT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/NO$PSX.FNT -------------------------------------------------------------------------------- /tests/tools/NO$PSX.INI: -------------------------------------------------------------------------------- 1 | ;no$psx 2.0 generated config file - do not edit 2 | 3 | Emulation Speed, LCD Refresh == -Realtime, Auto 4 | Sound Output Mode == 16bit stereo 5 | Sound Script File == -None 6 | Volume Control == Hardware mixer 7 | Sound Desired Sample Rate == -High (44kHz) (best) 8 | CDROM Speed == Normal (1x/2x) 9 | Video Brightness == Bright 10 | Video Output == Auto 11 | Force Screen Auto-Centering == No (as on real hardware) 12 | Render Quads as == Triangles (real PSX glitches) 13 | GTE Divisions == UNR (real PSX glitches) 14 | Use MMX == -Use MMX (if any) 15 | Default MIPS BIOS == File PSX-BIOS.ROM (if any) 16 | CDROM HC05 BIOS == Nocash High-level Clone 17 | Number of Memory Cards == Two (normal) 18 | Skip BIOS Intro == Skip (fast) 19 | Enable TTY in BIOS == Yes (debug) 20 | XA-ADPCM Interpolation == Zigzag (authentic) 21 | Game Controllers == -Joypad (digital) 22 | Xboo Port == -None/Disabled 23 | Xboo Completion == -Auto-close Upload Box 24 | Game Screen Filter == None (fast) 25 | Create Game Window at == Upper/right of Debug Window 26 | Game Screen Sizing == Strict 27 | Auto-destroy Game Window == ...when closing Debugger 28 | Auto-destroy/create Debugger == None 29 | IIgame_size == normal 30 | Number of Emulated Consoles == -Single Machine 31 | Serial Link Cable == Yes 32 | Performance Indicator == -Show Timing only if <>100% 33 | Update CPU Power Bar == Every 6 Frames (10Hz) 34 | Autosave Options == Save on Exit 35 | Load ROM-Images to == -All machines 36 | 37 | Disassembler Syntax == -Native MIPS-style 38 | Disassembler Pseudo Opcodes == -Resolve all pseudos 39 | Debug Numeric Input == -Radix 16 (hex) 40 | Clock Cycle Comments == Cycles & Sum 41 | Display Debug Info == Symbols and Source 42 | Display Debug Source TABs == 8 Columns 43 | Follow Function (ScrLock) == -Follow Code Cursor 44 | Cartridge Header == -Warn on Corrupt Cartridges 45 | Keystrokes (past pause) == -Initially Cleared 46 | Load Source Lines == -On the fly (only if needed) 47 | Access ELF File... == Loaded into separate buffer 48 | Old Input Buffer == -Save to NO{PSX.INP 49 | F5/F7 Snapshot Filename == -Snap File Menu 50 | Screenshot Target == -Screenshot File Menu 51 | Undo Run Function == -Disabled (fast) 52 | Startup Location == -Plain Debugger 53 | VCD Hardware == -None 54 | Datazone Format == -8bit DCB 55 | Datazone End Strategy == -Manually CTRL-D-entered 56 | Update I/O map == Also in Emulation mode 57 | TTY Debug Message Limit == Stop logging after 1MB 58 | Log TTY stdout == On 59 | Log MIPS tracelog == Off 60 | Log HC05 tracelog == Off 61 | Log CDROM commands == Off 62 | Log Drive mechanics == Off 63 | Log JOY commands == Off 64 | Log GPU commands == Off 65 | Log DMA transfers == Off 66 | Log IRQ interrupts == Off 67 | 68 | Override Exceptions (Ctrl+E) == -Disable all Warnings 69 | Bad I/O == Show Warning Message 70 | Memory Misalignments == Show Warning 71 | Invalid Opcodes == Show Warning 72 | Coprocessor Errors == Show Warning 73 | Maths Overflows == Show Warning 74 | Writes to Read-Only Mem == Show Warning 75 | HC05 Sub-CPU Errors == Show Warning 76 | Profiler Mode == Profiler Disabled (fast) 77 | Profiler Show Cycles == Total cycles 78 | Profiler Sub-cycles == Raw proc time 79 | Profiler Path Goto == Goto current opcode in proc 80 | Profiler Tree == Initially all collapsed 81 | Debug Font Size == Medium 7x15 82 | Courier New Patch == Use Patched font (1<>L) 83 | 84 | SNESpad Adapter == -None/Disabled (fast) 85 | SNESpad Button A == -Button A 86 | SNESpad Button B == -Button B 87 | Mouse Control Mode == -Free Move (right button=on) 88 | Joysticks/Gamepads == -Enabled 89 | 90 | Editor Font Size == Medium 7x15 91 | Editor Font Type == OEM (DOS) 92 | Initial Screen Width == Force 80 columns 93 | Autoindent == Enabled 94 | Wordwrap Line Length == 77 Columns 95 | TAB-Key Step == -8 Columns 96 | Loading TAB/CRLF Adjust == Explode TABs+CRLFs 97 | Saving TAB/SPC Adjust == Save as-is (SPCs only) 98 | Saving CRLFs == CRLF (DOS) 99 | Saving End of File == None 100 | Saving Wrapped Lines == With CR Softbreaks 101 | Debug ALT+E/Edit Button == Prompt Filename 102 | Backup Files == File.ext as File.~ex 103 | 104 | SAV/SNA File Format == Compressed (good/lz) 105 | IIautoRun == yes 106 | IIecm/cdz == delete 107 | Demangle C++ Labels == Enabled (slow) 108 | IIsymSort == name 109 | IIprpSort == clks 110 | IIprpScr == tree 111 | IItvScr == gpu 112 | IItvGrd == yes 113 | IItvScy == yes 114 | Symbolic Informations (TAB) == -Displayed 115 | IIsym == all 116 | IIset == other 117 | HelpView == SingleChapter 118 | tty_font == small 119 | tty_show == yes 120 | hlp_show == no 121 | vramviewshow == yes 122 | io10show == no 123 | io10psx == gpu 124 | IIsnd == 16bit stereo 125 | IIreg == show 126 | IIcrk == show 127 | 128 | Hack_xloc == 0000006E 129 | Hack_yloc == 0000015A 130 | Hack_ysiz == 00000019 131 | Data_ysiz == 00000006 132 | Code_xsiz == 0000004A 133 | Stck_xsiz == 00000022 134 | iXed_xloc == 00000014 135 | iXed_yloc == 00000014 136 | iXed_xsiz == 0000004F 137 | iXed_ysiz == 00000018 138 | Stat_xloc == 0000001E 139 | Stat_yloc == 0000001E 140 | Vram_xloc == 0000025D 141 | Vram_yloc == 00000106 142 | Vram_xsiz == 0000047B 143 | Vram_ysiz == 0000027B 144 | SymL_xloc == 0000001E 145 | SymL_yloc == 0000001E 146 | SymL_xsiz == 00000000 147 | SymL_ysiz == 00000000 148 | Prof_xloc == 0000001E 149 | Prof_yloc == 0000001E 150 | Prof_xsiz == 000001F0 151 | Prof_ysiz == 00000153 152 | dMsg_xloc == 0000001E 153 | dMsg_yloc == 0000001E 154 | dMsg_xsiz == 00000000 155 | dMsg_ysiz == 00000000 156 | TTY_xloc == 0000001E 157 | TTY_yloc == 0000001E 158 | TTY_xsiz == 00000050 159 | TTY_ysiz == 00000014 160 | cht_xsiz == 00000000 161 | cht_ysiz == 00000000 162 | Help_xloc == 00000014 163 | Help_yloc == 0000001E 164 | Help_xsiz == 00000230 165 | Help_ysiz == 00000320 166 | Game_xloc == 000003E9 167 | Game_yloc == 00000038 168 | Game_xsiz == 000292E7 169 | Game_ysiz == 0002936E 170 | Mixer_vol == 0000BFFF 171 | 172 | KEYB_1 == 101E18192D382C390F1C2A1D26367613 173 | KEYB_2 == A1A9A4A6594F59505175595959595959 174 | KEYB_3 == 59595959595959595902595959595959 175 | KEYB_4 == 59595959595959595903595959595959 176 | KEYB_5 == 59595959595959595904595959595959 177 | KEYB_6 == 59595959595959595905595959595959 178 | KEYB_7 == 59595959595959595906595959595959 179 | KEYB_8 == 59595959595959595907595959595959 180 | KEYB_9 == 59595959595959595908595959595959 181 | KEYB_A == 59595959595959595909595959595959 182 | KEYB_B == 5959595959595959590A595959595959 183 | KEYB_C == 5959595959595959590B595959595959 184 | JOYB_1 == 01010102030405060708090A0B0C 185 | JOYB_2 == 01020102030405060708090A0B0C 186 | JOYB_3 == 01030102030405060708090A0B0C 187 | JOYB_4 == 01040102030405060708090A0B0C 188 | JOYB_5 == 01050102030405060708090A0B0C 189 | JOYB_6 == 01060102030405060708090A0B0C 190 | JOYB_7 == 01070102030405060708090A0B0C 191 | JOYB_8 == 01080102030405060708090A0B0C 192 | JOYB_9 == 01090102030405060708090A0B0C 193 | JOYB_A == 010A0102030405060708090A0B0C 194 | JOYB_B == 010B0102030405060708090A0B0C 195 | JOYB_C == 010C0102030405060708090A0B0C 196 | 197 | -------------------------------------------------------------------------------- /tests/tools/NO$PSX.INP: -------------------------------------------------------------------------------- 1 | +D:\Dev2021\PS1FixedPoint\iso\FixedPoint.bin8D:\Dev2021\LastSurvivor\iso\SLUS_034.34.LastSurvivor.bin -------------------------------------------------------------------------------- /tests/tools/PSXLICENSE.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/PSXLICENSE.exe -------------------------------------------------------------------------------- /tests/tools/README.md: -------------------------------------------------------------------------------- 1 | # MKPSXISO 2 | MKPSXISO is basically a modern clone of BUILDCD used for building CD images of PlayStation games in the official development tools. The problem with BUILDCD however is, apart from licensing issues, its an old 16-bit DOS program which will not work natively under 64-bit versions of Windows without a DOS emulator which not only makes automated build scripts that produce ISO images messy in homebrew development but it also slows ISO creation speed considerably. BUILDCD also only produces CD images in a special image format supported by early CD burners and must be converted to an ISO format with a separate tool making the already slow ISO creation process even slower. 3 | 4 | While other ISO creation tools such as MKISOFS may work as an alternative most do not let you control the order of the files stored in the ISO image which is essential for optimizing file order to speed up access times and all do not support mixed-mode type files for CD streaming such as XA audio and MDEC video streams. MKPSXISO is made specifically to replace BUILDCD to aid in PlayStation homebrew development on modern systems as well as modification/hacking of existing PlayStation titles. MKPSXISO can also be used as a regular ISO creation tool that complies with the older ISO9660 standard with no Joliet extensions. 5 | 6 | MKPSXISO more or less replicates most of the functionality of BUILDCD but better! The most notable difference is that MKPSXISO is much faster and creates ISO images in either standalone iso or cue+bin format so that generated images can immediately be run on an emulator or burned to a CD. 7 | 8 | Another notable difference of MKPSXISO is that it injects the Sony license data correctly into the disc image which eliminates the need of having to use a separate program for properly licensing the ISO image. However, the license data is not included so one must have a copy of the official PlayStation Programmer's Tool SDK or the PsyQ SDK (both of which can be found in www.psxdev.net) for the license files to be able to take advantage of this feature. This is to avoid possible legal problems when including Sony's license data into open source programs. 9 | 10 | ## Features 11 | * Uses XML for scripting ISO projects. 12 | * Outputs ISO images directly to iso or bin+cue image format. 13 | * Injects license data into ISO image correctly. 14 | * File LBA controlled by order of files allowing for file seek optimization (just like BUILDCD). 15 | * Supports mixed-mode CD-XA stream files such as XA audio and STR video. 16 | * Supports CD-DA audio tracks from uncompressed WAV files either as plain tracks or DA/WAV files. 17 | * Can output log of all files packed with details such as LBA, size and timecode offset. 18 | 19 | ## Binary Download 20 | The latest Win32 binaries is now a release download in this repository. 21 | 22 | Older versions (probably going to be removed soon, there's no benefit to using these versions anyway): 23 | [mkpsxiso-1.20.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.20.zip) 24 | [mkpsxiso-1.19.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.19.zip) 25 | [mkpsxiso-1.18.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.18.zip) 26 | [mkpsxiso-1.15.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.15.zip) 27 | [mkpsxiso-1.14.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.14.zip) 28 | [mkpsxiso-1.10.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.10.zip) 29 | [mkpsxiso-1.06.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.06.zip) 30 | [mkpsxiso-1.04.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.04.zip) 31 | [mkpsxiso-1.00.zip](http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.00.zip) 32 | 33 | ## Compiling 34 | This tool requires tinyxml2 to compile. 35 | Compile with --std=c++11. 36 | 37 | ### Windows (make, no Netbeans) 38 | 1. Install your preferred MinGW GCC compiler. 39 | 2. Extract and compile tinyxml2 in the root of your C: drive (C:\tinyxml2). 40 | 3. Make sure the tinyxml2 library is named libtinyxml2.a. 41 | 4. Run "mingw32-make CONF=Release" in the mkpsxiso directory. 42 | 5. The result will be in "dist\Release\MinGW-Windows" named "mkpsxiso.exe". 43 | 44 | ### Windows (Netbeans) 45 | 1. Extract and compile tinyxml2 in the root of your C: drive (C:\tinyxml2). 46 | 2. Open the mkpsxiso directory as a project within the Netbeans IDE. 47 | 3. Select Release build and press F6 to compile. 48 | 4. The result will be in "dist\Release\MinGW-Windows" named "mkpsxiso.exe". 49 | 50 | ### Windows (CMake) 51 | 1. Install cygwin64 with the following: 52 | * make 53 | * cmake 54 | * gcc 55 | * tinyxml2 56 | 2. Open the cygwin64 terminal. 57 | 3. Navigate to the download of this repo. 58 | 4. Run "cmake ." to generate the make file. 59 | 5. Run "make" to compile the program. 60 | 6. The result will be in bin_win, named "mkpsxiso.exe" 61 | 62 | ### Linux (Ubuntu/CMake) 63 | 1. Install the following: 64 | * Build Essentials (gcc, g++, make) 65 | * cmake 66 | * tinyxml2 67 | 2. Open a terminal. 68 | 3. Navigate to the download of this repo. 69 | 4. Run "cmake ." to generate the make file. 70 | 5. Run "make" to compile the program. 71 | 6. The result will be in bin_nix, named "mkpsxiso" 72 | 73 | ## Issues 74 | 75 | The only known major issue that hasn't (or cannot) be resolved is that if you create a disc image with the following directory structure: 76 | ``` 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | ``` 103 | 104 | On Windows, browsing the subdirectories in dirb and dirc will not list the contents for some reason and trying to access it in a command prompt leads to a permission denied or similar error message. Disc image tools such as CDmage will display the contents of the aforementioned subdirectories without issue and the issue persists on disc images created with BuildCD suggesting it is likely an operating system related issue and not an ISO generator issue. 105 | 106 | This can be avoided by minimizing identically named directories but its best to test your generated disc image before considering it ready for release. 107 | 108 | ## Changelog 109 | 110 | **Version 1.23 (12/20/2018)** 111 | * Fixed broken LBA and timecode calculation for audio tracks integrated as files (iso::DirTreeClass::GetWavSize returns an incorrect value from the WAV file). 112 | * Updated build instructions (CodeBlocks project had been replaced with Netbeans but forgot to update instructions). 113 | 114 | **Version 1.22 (12/4/2018)** 115 | * Fixed issues with subheader detection logic and made it as a warning instead of a critical error. 116 | * Fixed bug where CD-DA length of possibly being 1 sector larger than it should. 117 | 118 | **Version 1.21 (7/8/2018)** 119 | * Corrected volume size calculation logic when DA audio files are included. Also fixed volume size value being 2 sectors larger than it should. 120 | * Corrected LBA header file output where the 150 sector pregap offset is not needed (libcd already does that). 121 | * Fixed path name being double appended when using srcdir attribute (this made mkpsxiso unable to parse an xml document produced by mkisoxml). 122 | * Added -noxa option and no_xa XML attribute to disable CD-XA attribute creation (plain ISO9660). 123 | * Fixed quiet mode preventing cue_sheet attribute from being parsed. 124 | * Added RIFF header and XA/STR subheader checks to error on improperly ripped or encoded XA/STR source files. 125 | * Improved data sector detection for STR type files (Mode2/Form1 + Mode2/Form2 interleaves). 126 | * Implemented proper EOL/EOF bits for subheaders at the ends of descriptors and files. 127 | * Fixed an XML parser bug where name attribute is used as the source file name when a source directory in a directory element is specified. 128 | * Fixed a major bug where directory record lengths are always set at 2048 bytes even for directory records spanning more than a sector resulting in missing files and directories. 129 | * Fixed incorrectly calculated record length set in the volume descriptor's root directory record. 130 | * Added copyright XML attribute for the identifiers element to specify a copyright identifier for the image file. 131 | 132 | **Version 1.20 (6/21/2018)** 133 | * ISO names being blank or garbage when compiled using Microsoft's compiler has been fixed. 134 | * Replaced tinyxml2::GetErrorLineNum() method calls to tinyxml2::ErrorLineNum() for compatibility with the latest version of tinyxml2. 135 | * Fixed incorrect file size calculated for STR and DA audio files. 136 | * DA audio type files are now set with a CD-Audio attribute making them appear as WAV files when opening them (note: it does not turn the DA audio into a WAV file, the OS supporting said attribute transparently converts it into a WAV container as you read it, one game featuring such files is Wipeout 3 for example). 137 | * Brought back mkisoxml (just needed to be recompiled with the latest GCC). 138 | 139 | **Version 1.19 (6/12/2018)** 140 | * Path table generation logic significantly reworked. Previous implementation was flawed and caused issues on games and operating systems that utilize the path table. MKPSXISO should be truly ISO9660 compliant now (apologies for the misleading remark in the 1.15 changelog). 141 | * Date stamp is now set in the root directory record in the image descriptor. 142 | * Fixed specifying only a source attribute for a file element not behaving as intended. 143 | * Fixed no error on missing CUE file when DA audio type files are found but no cue sheet was specified. 144 | 145 | **Version 1.18 (5/16/2018)** 146 | * Added support for DA audio files (files that map directly to a CD Audio track which games that use CD Audio have). 147 | * XML load error message now reports useful error details. 148 | * Parameter errors in XML script now reports with line numbers. 149 | * Fixed corrupt file names displayed when packing files. 150 | * Fixed corrupt directory names and corrected minor formatting issues of generated LBA header files. 151 | * Improved formatting of generated LBA listings. 152 | * Can now accept raw audio files for CD audio tracks. However, it assumes any file that isn't a WAV file as raw audio. 153 | * Directory record entries now handled using std::vector arrays (possibly better stability). 154 | * Replaced char strings to std::string strings inside DirTreeClass and associated typedefs. 155 | * Replaced all strcasecmp() with custom compare() function to make code fully C++14 compatible. 156 | * Included Netbeans 8.1 project. 157 | * Removed mkisoxml from download temporarily (currently too buggy, source still available). 158 | 159 | **Version 1.15 (6/16/2017)** 160 | * Directory record lengths have been tweaked to now calculate in sector multiples instead of actual bytes. This now makes ISOs generated with MKPSXISO fully ISO9660 compliant and ISO tools that threw a fit when opening ISO images generated with older versions of MKPSXISO should no longer complain. 161 | * Improved XA attribute header encoding (not really necessary but still nice to have). 162 | * Re-done README text. 163 | 164 | **Version 1.14 (6/4/2017, BIG update because I forgot to release 1.12)** 165 | * Name attribute of file entries can now be omitted provided that the source attribute is at least present. 166 | * Changed some char* strings to std::string strings. 167 | * Fixed typo in help text where -lba was referenced as -lbalist. 168 | * Fixed system and application identifiers not defaulting to PLAYSTATION when blank. 169 | * Fixed bug where mkpsxiso sometimes reports an error of specifying -o on a multi-disc ISO project when the project only has one ISO project. 170 | * Fixed a major LBA calculation bug where files written past a directory record spanning more than one sector are not assigned to an LBA address where it can safely be written. This resulted to the file getting overwritten by the directory record and thus, leads to file corruption. 171 | * Fixed file overwrite confirmation bug still being prompted when -noisogen is specified. 172 | * Fixed a bug where the length of directory records is always written with a length of 2048 bytes which may have caused some ISO browsing programs to throw a fit when browsing the generated ISO images. 173 | * Changed the format of the file LBA log completely which no longer uses a tree style format but it outputs more information of the file entries. 174 | * LBA values in generated header files are now offset by 150 sectors to take into account that sectors actually begin past 150 sectors. This may have caused direct LBA seeks to point 150 sectors behind the actual LBA on the CD. 175 | 176 | **Version 1.10 (2/23/2017)** 177 | * Can now handle as many files/directories the ISO9660 filesystem can handle without crashing or reporting an error as both a new feature and a fix for MeganGrass. 178 | * 2 second pregaps are now generated for CD audio tracks 3 and onwards in ISO projects that contain CD Audio. 179 | * Added -noisogen to disable iso generation useful for generating only an LBA listing of files in the ISO project in plain text or C header format. 180 | * Added -lbahead which is similar to -lba but outputs in C header format. 181 | * Fixed a bug where mkpsxiso would produce a 0 byte image file when an error occurs while using the -o parameter to specify the output image file. 182 | * Added optional srcdir attribute for -directory_tree- and -dir- elements (mostly intended for the new mkisoxml tool). 183 | * Added crude mkisoxml utility for quickly generating basic ISO XML projects out of a directory (can be compiled with CMake). 184 | 185 | **Version 1.06 (11/28/2016)** 186 | * Added file overwrite confirmation. 187 | * Element and attribute strings are no longer case sensitive. 188 | * File name strings from arguments are no longer passed as duplicated strings (eliminates the risk of forgetting to dealloc said strings on exit). 189 | * Added -lba option to produce a complete listing of files and directories in the ISO file system with their LBA addresses. 190 | * Added -dummy- element example in example.xml (forgot to put it in since the first release). 191 | 192 | **Version 1.05 (by electroCupcake)** 193 | * Fixed types for linux build, changed u_char and such to unsigned char. 194 | * In cygwin64 version of tinyxml2, "XML_NO_ERROR" is not defined, changed with "XML_SUCCESS" and this works on both Windows and Linux. 195 | * Converted to cmake, if you want a codeblocks project file, just run "cmake . -G "CodeBlocks - Unix Makefiles"" to create it. 196 | 197 | **Version 1.04 (9/1/2016)** 198 | * Fixed a bug where you'll get a 'Data track must only be on first track' error when creating an ISO image with more than 2 tracks even when the extra tracks are CD audio. 199 | * Duplicate file and directory entries are no longer possible to add (it'll result to weird problems anyway). 200 | 201 | **Version 1.00 (8/6/2016)** 202 | * Initial release. 203 | -------------------------------------------------------------------------------- /tests/tools/img2tim.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/img2tim.exe -------------------------------------------------------------------------------- /tests/tools/img2tim.txt: -------------------------------------------------------------------------------- 1 | img2tim by Lameguy64 of Meido-Tek Productions 2 | 3 | 4 | This tool converts almost any image file supported by FreeImage into a PlayStation standard TIM 5 | texture image file. Made to replace the bmp2tim tool that came with the PsyQ SDK with additional 6 | features not present in the original program. 7 | 8 | The program itself is still a work in progress but its complete enough as a usable tool. 9 | Alpha-blending options and better color-index conversion have yet to be implemented. 10 | 11 | 12 | Option Details: 13 | 14 | -b - Set semi-transparent bit on fully black pixels (ignored when -usealpha is specified). 15 | 16 | If the semi-transparent bit on fully black pixels (R0 G0 B0) is set, the pixel will 17 | be drawn opaque instead of transparent as fully black is treated by the PlayStation 18 | as the transparent color by default. 19 | 20 | -t - Set semi-transparent bit on non fully black pixels. 21 | 22 | This basically enables the output image to be drawn as semi-transparent since 23 | semi-transparency is only applied to pixels with the semi-transparency bit set. 24 | If the bit is not set, the pixel is always drawn opaque unless its a fully 25 | black pixel. 26 | 27 | -org < x y > - Specifies the VRAM offset of the image. 28 | 29 | Keep in mind that the width of the converted tim image may vary from the original 30 | image's resolution depending on its color depth. 16-bit has no difference, 8-bit is 31 | 1/2 of the original and 4-bit is about 1/4 of the original. No offset checking is 32 | done so its recommended to check the resulting tim file with timtool. 33 | 34 | -plt < x y > - Specifies the VRAM offset of the CLUT. 35 | 36 | CLUTs are usually 256x1 for 8-bit tims or 16x1 for 4-bit tims. No offset checking is 37 | done so its recommended to check the resulting tim file with timtool. 38 | 39 | -o < outFile > - Sets the name of the output file. 40 | 41 | -usealpha - Use the alpha channel (if available) as a transparency mask. 42 | 43 | Most useful when working with png image files that have an alpha channel and tools 44 | that utilize it, the alpha channel is used as a transparency mask when converting an 45 | image with an alpha channel. 46 | 47 | -alpt < value > - Specifies the threshold value when using the alpha channel as a transparency mask. 48 | 49 | If the alpha value of the pixel is less than the threshold (default: 127), the pixel 50 | will be converted as transparent (pixel color replaced to fully black) and opaque if 51 | above the threshold (pixel color intact). 52 | 53 | -tindex < col > - Specify color index to be treated as transparent. 54 | 55 | This option only applies to images that are 4-bit/8-bit palletized. Any pixel that has 56 | the same color-index specified will be made transparent. 57 | 58 | -tcol < r g b > - Specify RGB color value to be transparent. 59 | 60 | Applies to both non-color index and color index images. Any pixel with a matching color 61 | specified will be made transparent (replaced to fully black). 62 | 63 | -bpp < bpp > - Specify the color depth for the output TIM file. 64 | 65 | Currently, a simple color-search algorithm is used when converting images from non-indexed 66 | color depths (24-bit/16-bit) to 8-bit or 4-bit and will fail if more than 256 colors are 67 | found. 68 | 69 | Supported output color depths: 4, 8, 16, 24 -------------------------------------------------------------------------------- /tests/tools/libgcc_s_dw2-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/libgcc_s_dw2-1.dll -------------------------------------------------------------------------------- /tests/tools/libstdc++-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/libstdc++-6.dll -------------------------------------------------------------------------------- /tests/tools/mkisoxml.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/mkisoxml.exe -------------------------------------------------------------------------------- /tests/tools/mkpsxiso.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextrevisan/PS1FixedPoint/f9357a0b433125cc0a418989f921b81531f9b9d3/tests/tools/mkpsxiso.exe --------------------------------------------------------------------------------