Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ endif()

add_subdirectory(docs)
add_subdirectory(resources/music)
add_subdirectory(src/ppcore)
add_subdirectory(src/compression)
add_subdirectory(src/fx)
add_subdirectory(src/milkyplay)
Expand Down
9 changes: 8 additions & 1 deletion src/compression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ target_include_directories(compression
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../milkyplay
${CMAKE_CURRENT_SOURCE_DIR}/../ppui
${CMAKE_CURRENT_SOURCE_DIR}/../ppui/osinterface/posix
${CMAKE_CURRENT_SOURCE_DIR}/../milkyplay
${PROJECT_SOURCE_DIR}/src
)

target_link_libraries(compression
PRIVATE
ppcore
milkyplay
)

# Under macOS and Windows, build sources from Git submodules if present
Expand Down
3 changes: 3 additions & 0 deletions src/compression/Decompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#include "BasicTypes.h"
#include "SimpleVector.h"
#include "ppcore/PPString.h"
#include "ppcore/Descriptor.h"
#include "PPSystemString.h"

class XMFile;

Expand Down
29 changes: 25 additions & 4 deletions src/fx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,31 @@ add_library(fx STATIC
fpmath.h
)

set_target_properties(fx PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

target_include_directories(fx
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../ppui/osinterface/posix
${CMAKE_CURRENT_SOURCE_DIR}/../ppui
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/ppui
)

target_compile_options(fx
PRIVATE
-include cstring
)

target_compile_definitions(fx
PRIVATE
PP_INT64_TYPE=int64_t
)

target_link_libraries(fx
PRIVATE
ppcore
osinterface
)
2 changes: 1 addition & 1 deletion src/fx/FXAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef FXABSTRACT__H
#define FXABSTRACT__H

#include "BasicTypes.h"
#include "ppcore/BasicTypes.h"

class FXAbstract
{
Expand Down
3 changes: 2 additions & 1 deletion src/fx/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*
*/

#include "BasicTypes.h"
#include <cstring>
#include "ppcore/BasicTypes.h"
#include "fpmath.h"
#include "Filter.h"

Expand Down
2 changes: 1 addition & 1 deletion src/fx/Fire.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef FIRE__H
#define FIRE__H

#include "BasicTypes.h"
#include "ppcore/BasicTypes.h"
#include "FXAbstract.h"

class Fire : public FXAbstract
Expand Down
1 change: 1 addition & 0 deletions src/fx/Math3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "Math3d.h"
#include <cstring>

/////////////////////
// VectorFP struct //
Expand Down
2 changes: 2 additions & 0 deletions src/fx/ParticleBlobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

#include "ParticleBlobs.h"
#include "Math3d.h"
#include "osinterface/PPSystem.h"
#include "Filter.h"
#include "Texture.h"
#include <math.h>

#define GRIDSIZE 8
#define NUMPARTICLES (GRIDSIZE*GRIDSIZE*GRIDSIZE)
Expand Down
1 change: 1 addition & 0 deletions src/fx/TexturedGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "TexturedGrid.h"
#include "Math3d.h"
#include "osinterface/PPSystem.h"
#include "Filter.h"
#include "Texture.h"
#include <stdint.h>
Expand Down
2 changes: 2 additions & 0 deletions src/fx/fpmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
*
*/

#include <cstdint>
#include "fpmath.h"
#include "ppcore/BasicTypes.h"

#ifdef _MIPS_
extern "C" { // Use extern "c" fopp_int32r C++ file only
Expand Down
2 changes: 1 addition & 1 deletion src/fx/fpmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef FPMATH_H
#define FPMATH_H

#include "BasicTypes.h"
#include "ppcore/BasicTypes.h"

#define fpceil(x) ((x+65535)>>16)

Expand Down
5 changes: 5 additions & 0 deletions src/midi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ target_include_directories(midi
${CMAKE_CURRENT_SOURCE_DIR}/../tracker
)

target_link_libraries(midi
PRIVATE
ppcore
)

# Add platform-specific sources and include paths
if(APPLE)
target_sources(midi PRIVATE
Expand Down
1 change: 1 addition & 0 deletions src/midi/osx/MidiReceiver_CoreMIDI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <CoreMIDI/CoreMIDI.h>
#include "BasicTypes.h"
#include "ppcore/PPString.h"

class Tracker;
class PPMutex;
Expand Down
215 changes: 215 additions & 0 deletions src/ppcore/BasicTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
/*
* ppcore/BasicTypes.h
*
* Copyright 2009 Peter Barth
* Copyright 2024 Dale Whinham
*
* This file is part of Milkytracker.
*
* Milkytracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Milkytracker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Milkytracker. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef PPCORE_BASICTYPES__H
#define PPCORE_BASICTYPES__H

typedef unsigned char pp_uint8;
typedef signed char pp_int8;
typedef unsigned short pp_uint16;
typedef signed short pp_int16;
typedef unsigned int pp_uint32;
typedef signed int pp_int32;
typedef signed long long pp_int64;
typedef unsigned long long pp_uint64;

// Basic structures needed by Dictionary
struct PPPoint
{
pp_int32 x, y;

PPPoint(pp_int32 theX, pp_int32 theY) :
x(theX), y(theY)
{}

PPPoint()
{}
};

struct PPSize
{
pp_int32 width, height;

PPSize(pp_int32 theWidth, pp_int32 theHeight) :
width(theWidth), height(theHeight)
{}

PPSize()
{}

bool operator==(const PPSize& source) const
{
return (width == source.width && height == source.height);
}

bool operator!=(const PPSize& source) const
{
return !(width == source.width && height == source.height);
}

bool match(pp_int32 width, pp_int32 height) const
{
return (this->width == width && this->height == height);
}
};

struct PPRect
{
pp_int32 x1, y1, x2, y2;

PPRect(pp_int32 px1, pp_int32 py1, pp_int32 px2, pp_int32 py2) :
x1(px1), y1(py1), x2(px2), y2(py2)
{}

PPRect()
{}

pp_int32 width() const { return x2-x1; }
pp_int32 height() const { return y2-y1; }

void scale(pp_int32 scaleFactor)
{
x1 *= scaleFactor;
y1 *= scaleFactor;
x2 *= scaleFactor;
y2 *= scaleFactor;
}

bool intersect(const PPRect& rc) const
{
pp_int32 left1, left2;
pp_int32 right1, right2;
pp_int32 top1, top2;
pp_int32 bottom1, bottom2;

left1 = this->x1;
left2 = rc.x1;
right1 = this->x1 + this->width();
right2 = rc.x1 + rc.width();
top1 = this->y1;
top2 = rc.y1;
bottom1 = this->y1 + this->height();
bottom2 = rc.y1 + rc.height();

if (bottom1 < top2) return false;
if (top1 > bottom2) return false;

if (right1 < left2) return false;
if (left1 > right2) return false;

return true;
}

};

struct PPColor
{
pp_int32 r,g,b;

PPColor(pp_int32 red, pp_int32 green, pp_int32 blue) :
r(red), g(green), b(blue)
{}

PPColor() :
r(), g(), b()
{}

void validate()
{
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
}

void scale(float f)
{
r = (pp_int32)((float)r*f);
g = (pp_int32)((float)g*f);
b = (pp_int32)((float)b*f);
validate();
}

void scale(float fr, float fg, float fb)
{
r = (pp_int32)((float)r*fr);
g = (pp_int32)((float)g*fg);
b = (pp_int32)((float)b*fb);
validate();
}

void scaleFixed(pp_int32 f)
{
r = (r*f)>>16;
g = (g*f)>>16;
b = (b*f)>>16;
validate();
}

void interpolateFixed(const PPColor& col, pp_int32 f)
{
r = (f*r + col.r*(65536-f)) >> 16;
g = (f*g + col.g*(65536-f)) >> 16;
b = (f*b + col.b*(65536-f)) >> 16;
validate();
}

PPColor invert() const
{
PPColor c(255-r, 255-g, 255-b);
return c;
}

void set(pp_int32 red, pp_int32 green, pp_int32 blue)
{
r = red; g = green; b = blue;
}

void clamp()
{
if (r < 0) r = 0;
if (g < 0) g = 0;
if (b < 0) b = 0;

validate();
}

void operator+=(const PPColor& source)
{
r+=source.r;
g+=source.g;
b+=source.b;
validate();
}

bool operator==(const PPColor& source) const
{
return (r == source.r && g == source.g && b == source.b);
}

bool operator!=(const PPColor& source) const
{
return !(r == source.r && g == source.g && b == source.b);
}
};

#endif
Loading