Skip to content

Commit 9e37fb6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents aafe1d6 + 9bd643d commit 9e37fb6

14 files changed

Lines changed: 451 additions & 270 deletions

.circleci/config.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: minextu/sdl2-cross-platform
6+
steps:
7+
- checkout
8+
- run:
9+
name: Init
10+
command: |
11+
echo 'export EXECNAME=${CIRCLE_PROJECT_REPONAME}' >> $BASH_ENV
12+
echo 'export BASENAME=${CIRCLE_PROJECT_REPONAME}-$(git describe --tags --always | sed -e 's/^v//')' >> $BASH_ENV
13+
mkdir artifacts
14+
- run:
15+
name: Build (Linux)
16+
command: make linux OUTPUT=${EXECNAME}
17+
- run:
18+
name: Store binary
19+
command: |
20+
zip -r artifacts/${BASENAME}-linux.zip ${EXECNAME} assets
21+
zip -j artifacts/${BASENAME}-linux.zip \
22+
LICENSE
23+
make -f Makefile.linux clean OUTPUT=${EXECNAME}
24+
- run:
25+
name: Build (Windows 32-bit)
26+
command: |
27+
PATH="/usr/i686-w64-mingw32/bin:$PATH"
28+
make linux CC=i686-w64-mingw32-g++ GCC=i686-w64-mingw32-gcc OUTPUT=${EXECNAME}.exe
29+
- run:
30+
name: Store binary
31+
command: |
32+
zip -r artifacts/${BASENAME}-win32.zip ${EXECNAME}.exe assets
33+
zip -j artifacts/${BASENAME}-win32.zip \
34+
LICENSE \
35+
/usr/i686-w64-mingw32/bin/SDL2.dll \
36+
/usr/i686-w64-mingw32/bin/SDL2_image.dll \
37+
/usr/i686-w64-mingw32/bin/libpng16-16.dll \
38+
/usr/i686-w64-mingw32/bin/zlib1.dll
39+
make -f Makefile.linux clean OUTPUT=${EXECNAME}.exe
40+
- persist_to_workspace:
41+
root: .
42+
paths:
43+
- artifacts
44+
publish-github-release:
45+
docker:
46+
- image: cibuilds/github:0.10
47+
steps:
48+
- checkout
49+
- attach_workspace:
50+
at: .
51+
- run:
52+
name: "Publish Release on GitHub"
53+
command: |
54+
VERSION=$(git describe --tags --always)
55+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/
56+
57+
workflows:
58+
version: 2
59+
test:
60+
jobs:
61+
- build:
62+
filters:
63+
branches:
64+
ignore: master
65+
tags:
66+
ignore: /.*/
67+
build-and-release:
68+
jobs:
69+
- build:
70+
filters: &release-filters
71+
branches:
72+
ignore: /.*/
73+
tags:
74+
only: /^v\d+\.\d+\.\d+$/
75+
- publish-github-release:
76+
requires:
77+
- build
78+
filters: *release-filters

Makefile.chip8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ OUTPUT=prototracker-opll
77

88
$(OUTPUT): $(CPP_SRC) $(CPP_H) $(C_OBJ)
99
g++ -Wformat -s -std=c++11 -o $@ $(CPP_SRC) $(C_OBJ) -lSDL2_image -lSDL2main `sdl2-config --cflags --libs` -march=armv7-a -mtune=cortex-a7 -ffast-math -Ofast -DSCALE=1 -DOVERSAMPLE=0 -DFULLSCREEN=1 -DSAMPLERATE=22050
10-
10+
1111
$(C_OBJ): $(C_SRC) $(C_H)
1212
gcc -c -o $@ $(C_SRC) -O3 -Wall -std=gnu99 -march=armv7-a -mtune=cortex-a7 -ffast-math -Ofast
1313

14+
clean:
15+
rm $(OUTPUT) $(C_OBJ)

Makefile.linux

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
OUTPUT=prototracker-opll
2+
CC=g++
3+
GCC=gcc
24

35
$(OUTPUT): $(CPP_SRC) $(CPP_H) $(C_OBJ)
4-
g++ -O3 -Wformat -std=c++11 -o $@ $(CPP_SRC) $(C_OBJ) -lSDL2_image -lSDL2main `sdl2-config --cflags --libs` -s
5-
6+
$(CC) -O3 -Wformat -std=c++11 -o $@ $(CPP_SRC) $(C_OBJ) -lSDL2_image -lSDL2main `sdl2-config --cflags --libs` -s -DSCALE=2
7+
68
$(C_OBJ): $(C_SRC) $(C_H)
7-
gcc -c -o $@ $(C_SRC) -O3 -Wall -std=gnu99
9+
$(GCC) -c -o $@ $(C_SRC) -O3 -Wall -std=gnu99
10+
11+
clean:
12+
rm $(OUTPUT) $(C_OBJ)

Makefile.mingw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ $(OUTPUT): $(CPP_SRC) $(CPP_H) $(C_OBJ)
55

66
$(C_OBJ): $(C_SRC) $(C_H)
77
gcc -c -o $@ $(C_SRC) -O3 -Wall -std=gnu99
8+
9+
clean:
10+
rm $(OUTPUT) $(C_OBJ)

assets/font.png

-217 Bytes
Loading

src/Context.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Emscripten.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "Emscripten.h"
22
#include "SDL.h"
3-
#include "Context.h"
43
#include <cstdlib>
54
#include "App.h"
65

7-
86
#ifdef __EMSCRIPTEN__
97

10-
extern Context* _context;
8+
#include "Prototracker.h"
9+
10+
extern Prototracker *g_prototracker;
1111

1212
#include <emscripten.h>
1313

@@ -130,7 +130,7 @@ void emNewSong()
130130
EMSCRIPTEN_KEEPALIVE
131131
const char * emRequestSong()
132132
{
133-
return _context->mainEditor.getSongBase64().c_str();
133+
return g_prototracker->getSongBase64().c_str();
134134
}
135135

136136

src/FileSection.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdlib>
66
#include <cstdio>
77
#include <cstdint>
8+
#include <cmath>
89

910
FileSection* FileSection::createSection(const char *name)
1011
{
@@ -171,6 +172,19 @@ unsigned int FileSection::readDword(int& offset) const
171172
}
172173

173174

175+
float FileSection::readFloat(int& offset) const
176+
{
177+
if (offset < 0 || offset + sizeof(float) > mSize)
178+
return NAN;
179+
180+
unsigned int returnValueRaw = read4bytes(&static_cast<char*>(mData)[offset]);
181+
182+
offset += sizeof(float);
183+
184+
return *reinterpret_cast<float*>(&returnValueRaw);
185+
}
186+
187+
174188
const char * FileSection::readString(int& offset) const
175189
{
176190
for (int i = offset ; ; ++i)
@@ -210,6 +224,16 @@ void FileSection::writeDword(unsigned int dword)
210224
}
211225

212226

227+
void FileSection::writeFloat(float value)
228+
{
229+
ensureAllocated(mSize + sizeof(unsigned int));
230+
231+
write4bytes(&static_cast<char*>(mData)[mSize], *reinterpret_cast<unsigned int*>(&value));
232+
233+
mSize += sizeof(unsigned int);
234+
}
235+
236+
213237
void FileSection::writeString(const char *str)
214238
{
215239
int strSize = strlen(str) + 1;

src/FileSection.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ class FileSection
1010

1111
/*
1212
* readByte() & readDword() return this if it failed
13+
*
14+
* NOTE: readFloat() returns NAN if it fails!
1315
*/
14-
static const int invalidRead = 0xffffffff;
16+
static constexpr int invalidRead = 0xffffffff;
1517

1618
private:
1719
char mName[nameSize + 1];
@@ -47,12 +49,14 @@ class FileSection
4749
unsigned int readByte(int& offset) const;
4850
int readSignedByte(int& offset) const;
4951
unsigned int readDword(int& offset) const;
52+
float readFloat(int& offset) const;
5053
const char * readString(int& offset) const;
5154
FileSection * readSection(int& offset) const;
5255
bool readPattern(Pattern& pattern, int effectParamCount, int& offset) const;
5356

5457
void writeByte(unsigned int byte);
5558
void writeDword(unsigned int dword);
59+
void writeFloat(float value);
5660
void writeString(const char *str);
5761
void writeSection(FileSection& section);
5862
void writePattern(Pattern& pattern);

0 commit comments

Comments
 (0)