Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ set(LOADTRK_SOURCES
src/sound.cpp
src/console.cpp
src/colors.cpp
src/channels.cpp
src/freqtbl.cpp
src/timer.cpp
src/sid.cpp
src/ltlog.cpp
src/ltmidi.cpp
Expand Down Expand Up @@ -100,6 +103,9 @@ set(LTRELOC_SOURCES
src/reloc.cpp
src/console.cpp
src/colors.cpp
src/channels.cpp
src/freqtbl.cpp
src/timer.cpp
src/ltlog.cpp
src/bme/bme_win.cpp
src/bme/bme_io.cpp
Expand Down
56 changes: 56 additions & 0 deletions src/channels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* LoadTracker
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "channels.h"

#include "configfile.h"

#include <cstring>

Chn chn[MAX_CHN];
unsigned char funktable[2];

void initchannels()
{
int maxChns = getMaxChannels();
Chn *cptr = &chn[0];

std::memset(chn, 0, sizeof chn);

for (int c = 0; c < maxChns; c++)
{
chn[c].trans = 0;
chn[c].instr = 1;
if (multiplier)
cptr->tempo = 6*multiplier-1;
else
cptr->tempo = 6-1;
cptr++;
}

if (multiplier)
{
funktable[0] = 9*multiplier-1;
funktable[1] = 6*multiplier-1;
}
else
{
funktable[0] = 9-1;
funktable[1] = 6-1;
}
}
62 changes: 62 additions & 0 deletions src/channels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* LoadTracker
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef CHANNELS_H
#define CHANNELS_H

#include "common.h"

struct Chn
{
unsigned char trans;
unsigned char instr;
unsigned char note;
unsigned char lastnote;
unsigned char newnote;
int pattptr;
unsigned char pattnum;
unsigned char songptr;
unsigned char repeat;
unsigned short freq;
unsigned char gate;
unsigned char wave;
unsigned short pulse;
unsigned char ptr[2];
unsigned char pulsetime;
unsigned char wavetime;
unsigned char vibtime;
unsigned char vibdelay;
unsigned char command;
unsigned char cmddata;
unsigned char newcommand;
unsigned char newcmddata;
unsigned char tick;
unsigned char tempo;
unsigned char mute;
unsigned char advance;
unsigned char gatetimer;
};

#ifndef CHANNELS_C
extern Chn chn[MAX_CHN];
extern unsigned char funktable[2];
#endif

void initchannels();

#endif
4 changes: 3 additions & 1 deletion src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "display.h"

#include "common.h"
#include "channels.h"
#include "colors.h"
#include "configfile.h"
#include "console.h"
Expand All @@ -34,6 +35,7 @@
#include "play.h"
#include "song.h"
#include "table.h"
#include "timer.h"

#include "bme_main.h"
#include "bme_snd.h"
Expand Down Expand Up @@ -531,7 +533,7 @@ void printstatus()
const char *playmode = isplaying() ? "PLAYING" : "STOPPED";
printtext(dpos.octaveX+10, dpos.octaveY, colors.CTITLE, playmode);

gettime(textbuffer);
timer.get(textbuffer);
color = isplaying() ? colors.CEDIT : colors.CMUTE;
printtext(dpos.octaveX+10, dpos.octaveY+1, color, textbuffer);

Expand Down
67 changes: 67 additions & 0 deletions src/freqtbl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* LoadTracker
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <cmath>

unsigned char freqtbllo[] =
{
0x17,0x27,0x39,0x4b,0x5f,0x74,0x8a,0xa1,0xba,0xd4,0xf0,0x0e,
0x2d,0x4e,0x71,0x96,0xbe,0xe8,0x14,0x43,0x74,0xa9,0xe1,0x1c,
0x5a,0x9c,0xe2,0x2d,0x7c,0xcf,0x28,0x85,0xe8,0x52,0xc1,0x37,
0xb4,0x39,0xc5,0x5a,0xf7,0x9e,0x4f,0x0a,0xd1,0xa3,0x82,0x6e,
0x68,0x71,0x8a,0xb3,0xee,0x3c,0x9e,0x15,0xa2,0x46,0x04,0xdc,
0xd0,0xe2,0x14,0x67,0xdd,0x79,0x3c,0x29,0x44,0x8d,0x08,0xb8,
0xa1,0xc5,0x28,0xcd,0xba,0xf1,0x78,0x53,0x87,0x1a,0x10,0x71,
0x42,0x89,0x4f,0x9b,0x74,0xe2,0xf0,0xa6,0x0e,0x33,0x20,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

unsigned char freqtblhi[] =
{
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,0x03,0x04,
0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x08,
0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0c,0x0d,0x0d,0x0e,0x0f,0x10,
0x11,0x12,0x13,0x14,0x15,0x17,0x18,0x1a,0x1b,0x1d,0x1f,0x20,
0x22,0x24,0x27,0x29,0x2b,0x2e,0x31,0x34,0x37,0x3a,0x3e,0x41,
0x45,0x49,0x4e,0x52,0x57,0x5c,0x62,0x68,0x6e,0x75,0x7c,0x83,
0x8b,0x93,0x9c,0xa5,0xaf,0xb9,0xc4,0xd0,0xdd,0xea,0xf8,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

void calculatefreqtable(double basepitch, double equaldivisionsperoctave)
{
double basefreq = basepitch * (16777216.0 / 985248.0) * std::pow(2.0, 0.25) / 32.0;

for (int c = 0; c < 8*12 ; c++)
{
double note = c;
double freq = basefreq * std::pow(2.0, note/equaldivisionsperoctave);
int intfreq = freq + 0.5;
if (intfreq > 0xffff)
intfreq = 0xffff;
freqtbllo[c] = intfreq & 0xff;
freqtblhi[c] = intfreq >> 8;
}
}
29 changes: 29 additions & 0 deletions src/freqtbl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* LoadTracker
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef FREQTBL_H
#define FREQTBL_H

#ifndef FREQTBL_C
extern unsigned char freqtbllo[];
extern unsigned char freqtblhi[];
#endif

void calculatefreqtable(double basepitch, double equaldivisionsperoctave);

#endif
29 changes: 14 additions & 15 deletions src/loadtrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

#include "config.h"

#include "channels.h"
#include "colors.h"
#include "configfile.h"
#include "console.h"
#include "display.h"
#include "freqtbl.h"
#include "instr.h"
#include "order.h"
#include "pattern.h"
Expand All @@ -34,6 +36,7 @@
#include "song.h"
#include "sound.h"
#include "table.h"
#include "timer.h"

#include "bme_main.h"
#include "bme_win.h"
Expand Down Expand Up @@ -338,6 +341,9 @@ int main(int argc, char **argv)
initchannels();
clearsong(true, true, true, true, true);

timer.setfreq(ntsc);
timer.setmult(multiplier);

// Init sound
if (!sound_init(mr, writer, sidmodel, ntsc, multiplier, interpolate, customclockrate, exsid, filterbias, combwaves))
{
Expand Down Expand Up @@ -958,6 +964,7 @@ void mousecommands()
if ((mousex >= dpos.statusTopFvX+9) && (mousex <= dpos.statusTopFvX+12))
{
ntsc ^= 1;
timer.setfreq(ntsc);
sound_init(mr, writer, sidmodel, ntsc, multiplier, interpolate, customclockrate, exsid, filterbias, combwaves);
}
if ((mousex >= dpos.statusTopFvX+14) && (mousex <= dpos.statusTopFvX+17))
Expand Down Expand Up @@ -1610,6 +1617,7 @@ void prevmultiplier()
if (multiplier > 0)
{
multiplier--;
timer.setmult(multiplier);
sound_init(mr, writer, sidmodel, ntsc, multiplier, interpolate, customclockrate, exsid, filterbias, combwaves);
}
}
Expand All @@ -1619,26 +1627,26 @@ void nextmultiplier()
if (multiplier < 16)
{
multiplier++;
timer.setmult(multiplier);
sound_init(mr, writer, sidmodel, ntsc, multiplier, interpolate, customclockrate, exsid, filterbias, combwaves);
}
}

void calculatefreqtable()
{
double basefreq = (double)basepitch * (16777216.0 / 985248.0) * std::pow(2.0, 0.25) / 32.0;
double cyclebasefreq = basefreq;
double freq = basefreq;

if (tuningcount)
{
double basefreq = (double)basepitch * (16777216.0 / 985248.0) * std::pow(2.0, 0.25) / 32.0;
double cyclebasefreq = basefreq;
double freq = basefreq;
int c = 0;
while (c < 96)
{
for (int i = 0; i < tuningcount; i++)
{
if (c < 96)
{
int intfreq = freq + 0.5;
int intfreq = static_cast<int>(freq + 0.5);
if (intfreq > 0xffff)
intfreq = 0xffff;
freqtbllo[c] = intfreq & 0xff;
Expand All @@ -1652,16 +1660,7 @@ void calculatefreqtable()
}
else
{
for (int c = 0; c < 8*12 ; c++)
{
double note = c;
double freq = basefreq * std::pow(2.0, note/(double)equaldivisionsperoctave);
int intfreq = freq + 0.5;
if (intfreq > 0xffff)
intfreq = 0xffff;
freqtbllo[c] = intfreq & 0xff;
freqtblhi[c] = intfreq >> 8;
}
calculatefreqtable(basepitch, equaldivisionsperoctave);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "configfile.h"
#include "console.h"
#include "freqtbl.h"
#include "instr.h"
#include "order.h"
#include "pattern.h"
Expand Down
Loading
Loading