fix furnace for 32-bit

This commit is contained in:
tildearrow 2022-01-17 21:08:14 -05:00
parent a0896f949c
commit df3ae12278
8 changed files with 51 additions and 9 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@ build/
release/ release/
t/ t/
winbuild/ winbuild/
win32build/
macbuild/ macbuild/
linuxbuild/ linuxbuild/
*.swp *.swp

View file

@ -27,10 +27,11 @@ include_directories(extern/zlib ${CMAKE_CURRENT_BINARY_DIR}/extern/zlib)
if (WIN32) if (WIN32)
set(SDL_SHARED OFF) set(SDL_SHARED OFF)
set(SDL_STATIC ON)
add_subdirectory(extern/SDL) add_subdirectory(extern/SDL)
set(HAVE_SDL2 SDL2-static) set(HAVE_SDL2 SDL2-static)
set(HAVE_Z zlibstatic) set(HAVE_Z zlibstatic)
include_directories(extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include) include_directories(extern/SDL/include extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include)
else() else()
if (BUILD_GUI) if (BUILD_GUI)
set(SDL_SHARED ON) set(SDL_SHARED ON)

5
demos/README.md Normal file
View file

@ -0,0 +1,5 @@
# demos
demo songs for Furnace.
these demo songs are not under the GPL. in the case of covers, all rights are reserved to the original author.

31
scripts/release-win32.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
# make Windows release
# this script shall be run from Linux with MinGW installed!
if [ ! -e /tmp/furnace ]; then
ln -s "$PWD" /tmp/furnace || exit 1
fi
cd /tmp/furnace
if [ ! -e win32build ]; then
mkdir win32build || exit 1
fi
cd win32build
i686-w64-mingw32-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-O2" -DCMAKE_CXX_FLAGS="-O2 -Wall -Wextra -Wno-unused-parameter -Werror" -DBUILD_SHARED_LIBS=OFF .. || exit 1
make -j8 || exit 1
i686-w64-mingw32-strip -s furnace.exe || exit 1
cd ..
mkdir -p release/win32 || exit 1
cd release/win32
cp ../../LICENSE LICENSE.txt || exit 1
cp ../../win32build/furnace.exe . || exit 1
cp ../../README.md README.txt || exit 1
cp -r ../../papers papers || exit 1
zip -r furnace.zip LICENSE.txt furnace.exe README.txt papers

View file

@ -5,6 +5,8 @@
#include <math.h> #include <math.h>
#include <sndfile.h> #include <sndfile.h>
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
void DivEngine::nextOrder() { void DivEngine::nextOrder() {
curRow=0; curRow=0;
if (repeatPattern) return; if (repeatPattern) return;
@ -557,7 +559,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
case 0xc0: case 0xc1: case 0xc2: case 0xc3: // set Hz case 0xc0: case 0xc1: case 0xc2: case 0xc3: // set Hz
divider=((effect&0x3)<<8)|effectVal; divider=((effect&0x3)<<8)|effectVal;
if (divider<10) divider=10; if (divider<10) divider=10;
cycles=((int)(got.rate)<<8)/divider; cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
clockDrift=0; clockDrift=0;
break; break;
case 0xc4: // set Hz by tempo case 0xc4: // set Hz by tempo
@ -746,8 +748,8 @@ bool DivEngine::nextTick(bool noAccum) {
bool ret=false; bool ret=false;
if (divider<10) divider=10; if (divider<10) divider=10;
cycles=((int)(got.rate)<<8)/divider; cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
clockDrift+=((int)(got.rate)<<8)%divider; clockDrift+=((int)(got.rate)<<MASTER_CLOCK_PREC)%divider;
if (clockDrift>=divider) { if (clockDrift>=divider) {
clockDrift-=divider; clockDrift-=divider;
cycles++; cycles++;
@ -941,7 +943,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
memset(metroTick,0,size); memset(metroTick,0,size);
int attempts=0; int attempts=0;
int runLeftG=size<<8; int runLeftG=size<<MASTER_CLOCK_PREC;
while (++attempts<100) { while (++attempts<100) {
// 1. check whether we are done with all buffers // 1. check whether we are done with all buffers
if (runLeftG<=0) break; if (runLeftG<=0) break;
@ -949,7 +951,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
// 2. check whether we gonna tick // 2. check whether we gonna tick
if (cycles<=0) { if (cycles<=0) {
// we have to tick // we have to tick
unsigned int realPos=size-(runLeftG>>8); unsigned int realPos=size-(runLeftG>>MASTER_CLOCK_PREC);
if (realPos>=size) realPos=size-1; if (realPos>=size) realPos=size-1;
if (song.hilightA>0) { if (song.hilightA>0) {
if ((curRow%song.hilightA)==0 && ticks==1) metroTick[realPos]=1; if ((curRow%song.hilightA)==0 && ticks==1) metroTick[realPos]=1;
@ -967,7 +969,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
// 3. tick the clock and fill buffers as needed // 3. tick the clock and fill buffers as needed
if (cycles<runLeftG) { if (cycles<runLeftG) {
for (int i=0; i<song.systemLen; i++) { for (int i=0; i<song.systemLen; i++) {
int total=(cycles*runtotal[i])/(size<<8); int total=(cycles*runtotal[i])/(size<<MASTER_CLOCK_PREC);
disCont[i].acquire(runPos[i],total); disCont[i].acquire(runPos[i],total);
runLeft[i]-=total; runLeft[i]-=total;
runPos[i]+=total; runPos[i]+=total;

View file

@ -16,6 +16,7 @@
#include "IconsFontAwesome4.h" #include "IconsFontAwesome4.h"
#include "plot_nolerp.h" #include "plot_nolerp.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include <stdint.h>
#include <zlib.h> #include <zlib.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <stdexcept> #include <stdexcept>
@ -2900,7 +2901,7 @@ int FurnaceGUI::load(String path) {
return 1; return 1;
} }
ssize_t len=ftell(f); ssize_t len=ftell(f);
if (len==0x7fffffffffffffff) { if (len==(SIZE_MAX>>1)) {
perror("could not get file length"); perror("could not get file length");
lastError=fmt::sprintf("on pre tell: %s",strerror(errno)); lastError=fmt::sprintf("on pre tell: %s",strerror(errno));
fclose(f); fclose(f);

View file

@ -1,5 +1,6 @@
#include <exception> #include <exception>
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <string> #include <string>
#include "ta-log.h" #include "ta-log.h"
#include "engine/engine.h" #include "engine/engine.h"
@ -259,7 +260,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
ssize_t len=ftell(f); ssize_t len=ftell(f);
if (len==0x7fffffffffffffff) { if (len==(SIZE_MAX>>1)) {
perror("could not get file length"); perror("could not get file length");
fclose(f); fclose(f);
return 1; return 1;