Skip to content

Commit

Permalink
0.9.4-alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Jul 14, 2018
1 parent 403f767 commit 83231d9
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 234 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Pixel Perfect Engine ver 0.9.4-alpha.2
# Pixel Perfect Engine ver 0.9.4-alpha.3

2D retro graphics engine written in D by László Szerémi ([email protected], https://twitter.com/ziltoid1991, https://www.patreon.com/ShapeshiftingLizard).

Required libaries:
Derelict SDL2 https://github.com/DerelictOrg/DerelictSDL2
Derelict FI https://github.com/DerelictOrg/DerelictFI
Derelict FI https://github.com/DerelictOrg/DerelictFI (for editor only)
sdlang-d https://github.com/Abscissa/SDLang-D
libpcm https://github.com/ZILtoid1991/libPCM
cpublit https://github.com/ZILtoid1991/CPUblit
intel-intrinsics https://github.com/AuburnSounds/intel-intrinsics


See Wiki for further info and version history!
Expand Down
2 changes: 2 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ subPackage{
dependency "sdlang-d" version="==0.10.2"
dependency "derelict-sdl2" version="~>2.1.0"
dependency "CPUblit" version="*"
dependency "intel-intrinsics" version="*"
dependency "libpcm" version="*"
}
subPackage{
name "pixelperfecteditor"
Expand Down
108 changes: 0 additions & 108 deletions pixelperfectengine/src/PixelPerfectEngine/audio/adsrGen.d

This file was deleted.

11 changes: 7 additions & 4 deletions pixelperfectengine/src/PixelPerfectEngine/audio/envGen.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ public enum StageType : ubyte{
ascending = 1,
descending = 2,
sustain = 3, /// Descending until either a key release command or reaches zero.
revSustain = 4, /// Ascending until either key release or max level reached.
hold = 5, /// Keeps the value of targetLevel until holdTime.
}

/**
* Defines a single envelope stage.
*/
public struct EnvelopeStage{

public uint targetLevel; /// If reached, jumps to the next stage
public uint stepping; /// If slow enabled, it sets how much clockcycles needed for a single increment, otherwise sets the increment for each clockcycle
public byte linearity; /// 0 = Linear. Greater than 0 = Pseudolog. Less than 0 = Pseudoantilog.
mixin(bitfields!(
ubyte, "type", 2,
ubyte, "type", 3,
bool, "slow", 1,
ubyte, "unused", 5));
public byte[2] reserved;
ubyte, "unused", 4));
public ushort holdTime; /// If used, it describes the hold time in milliseconds
}

public struct EnvelopeGenerator{
private EnvelopeStage* stages;
private EnvelopeStage[] stages;
private sizediff_t currentStage;
private uint currentLevel, stepNumber;
private uint log;
Expand Down
28 changes: 13 additions & 15 deletions pixelperfectengine/src/PixelPerfectEngine/audio/firFilter.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ module PixelPerfectEngine.audio.firFilter;

public struct FiniteImpulseResponse(int L){
//static assert(L % 2 == 0);
public float[L] vals;
public short[L] vals;
}

public struct FiniteImpulseResponseFilter(int L){
FiniteImpulseResponse!L* impulseResponse;
private float[L + 3] delayLine;
private short[L + 3] delayLine;
private uint stepping;
private uint truncating;
this(FiniteImpulseResponse!L* impulseResponse){
this.impulseResponse = impulseResponse;
version(X86){
truncating = (L * 4) - 1;
truncating = (L * 8) - 1;
}else version(X86_64){
truncating = (L * 4) - 1;
truncating = (L * 8) - 1;
}else{
truncating = L - 1;
}
}
public @nogc float filter(float input){
/*public @nogc int calculate(short input){
if(stepping < 3){
delayLine[L + (L - stepping)] = input;
}
delayLine[L - stepping] = input;
version(X86){
float[4] result;
int[4] result;
asm @nogc{
mov ESI, impulseResponse[EBP];
mov EDI, delayLine[EBP];
Expand All @@ -41,14 +41,13 @@ public struct FiniteImpulseResponseFilter(int L){
mov ECX, L;
filterloop:
xor EBX, EBX;
add EBX, EDX;
mov EBX, EDX;
and EBX, EAX;
add EBX, EDI;
movups XMM0, [EBX];
movups XMM1, [ESI];
mulps XMM1, XMM0;
addps XMM2, XMM1;
pmaddwd XMM1, XMM0;
paddd XMM2, XMM1;
add ESI, 16;
add EDX, 16;
dec ECX;
Expand All @@ -60,7 +59,7 @@ public struct FiniteImpulseResponseFilter(int L){
stepping &= truncating;
return result[0] + result[1] + result[2] + result[3];
}else version(X86_64){
float[4] result;
int[4] result;
asm @nogc{
mov RSI, impulseResponse[RBP];
mov RDI, delayLine[RBP];
Expand All @@ -69,8 +68,7 @@ public struct FiniteImpulseResponseFilter(int L){
mov ECX, L;
filterloop:
xor RBX, RBX;
add RBX, RDX;
mov RBX, RDX;
and RBX, RAX;
add RBX, RDI;
movups XMM0, [RBX];
Expand All @@ -88,13 +86,13 @@ public struct FiniteImpulseResponseFilter(int L){
stepping &= truncating;
return result[0] + result[1] + result[2] + result[3];
}else{
float result;
int result;
for(int i; i < L; i++){
result += delayLine[(i + stepping) & truncating] * impulseResponse.vals[i];
}
stepping++;
stepping &= truncating;
}
}
}*/
}
23 changes: 23 additions & 0 deletions pixelperfectengine/src/PixelPerfectEngine/audio/lfo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2015-2018, by Laszlo Szeremi under the Boost license.
*
* Pixel Perfect Engine, audio.lfo module
*/

module PixelPerfectEngine.audio.lfo;

/**
* implements a low-frequency oscillator
*/

public struct LowFreqOsc(int Length){
ubyte[Length] table;
uint stepping; ///Current position
uint cycle; ///Defines how much needs to be added to the counter each cycle
uint forward; ///Steps the oscillator forward>>10 steps

public @nogc ubyte step(){
forward += cycle;
return table[forward & (Length - 1)];
}
}
Loading

0 comments on commit 83231d9

Please sign in to comment.