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/
t/
winbuild/
win32build/
macbuild/
linuxbuild/
*.swp

View File

@ -27,10 +27,11 @@ include_directories(extern/zlib ${CMAKE_CURRENT_BINARY_DIR}/extern/zlib)
if (WIN32)
set(SDL_SHARED OFF)
set(SDL_STATIC ON)
add_subdirectory(extern/SDL)
set(HAVE_SDL2 SDL2-static)
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()
if (BUILD_GUI)
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 <sndfile.h>
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
void DivEngine::nextOrder() {
curRow=0;
if (repeatPattern) return;
@ -557,7 +559,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
case 0xc0: case 0xc1: case 0xc2: case 0xc3: // set Hz
divider=((effect&0x3)<<8)|effectVal;
if (divider<10) divider=10;
cycles=((int)(got.rate)<<8)/divider;
cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
clockDrift=0;
break;
case 0xc4: // set Hz by tempo
@ -746,8 +748,8 @@ bool DivEngine::nextTick(bool noAccum) {
bool ret=false;
if (divider<10) divider=10;
cycles=((int)(got.rate)<<8)/divider;
clockDrift+=((int)(got.rate)<<8)%divider;
cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
clockDrift+=((int)(got.rate)<<MASTER_CLOCK_PREC)%divider;
if (clockDrift>=divider) {
clockDrift-=divider;
cycles++;
@ -941,7 +943,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
memset(metroTick,0,size);
int attempts=0;
int runLeftG=size<<8;
int runLeftG=size<<MASTER_CLOCK_PREC;
while (++attempts<100) {
// 1. check whether we are done with all buffers
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
if (cycles<=0) {
// 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 (song.hilightA>0) {
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
if (cycles<runLeftG) {
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);
runLeft[i]-=total;
runPos[i]+=total;

View File

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

View File

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