Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jan 12, 2015
1 parent 182b43c commit bd6f59a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ OBJDIR = ./_obj/
EXENAME = spc2it
OBJS = $(addprefix $(OBJDIR), emu.o it.o main.o sound.o spc700.o)
COMMONFLAGS =
CFLAGS = $(COMMONFLAGS) -Wall
LDFLAGS = $(OBJS) -o $(EXENAME) $(COMMONFLAGS) -lm
LD = gcc $(LDFLAGS)
CC = gcc $(CFLAGS)
CFLAGS = $(COMMONFLAGS) -Wall -g
LDFLAGS = $(OBJS) -o $(EXENAME) $(COMMONFLAGS) -lm -g
LD = clang $(LDFLAGS)
CC = clang $(CFLAGS)

.PHONY: clean all

Expand Down
4 changes: 2 additions & 2 deletions it.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef IT_H
#define IT_H

#define NUM_PATT_BUFS 64
#define NUM_PATT_BUFS 128

#include "spc2ittypes.h"

Expand All @@ -24,7 +24,7 @@ void ITMix();
#define EFFECT_E 5

#define IT_PATTERN_TEMP_FILE_NAME "ittemp.tmp"
#define IT_PATTERN_MAX 200 // The original Impulse Tracker has 200 patterns max
#define IT_PATTERN_MAX 0xFD // The original Impulse Tracker has 200 patterns max
#define IT_SAMPLE_MAX 99

#define IT_MASK_NOTE 1 // 0001 (Note)
Expand Down
40 changes: 40 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,48 @@ void Usage()
printf(" -r xxx Specify IT rows per pattern [200 default]\n");
}

void CheckSizes() {
size_t u8Size = sizeof(u8);
if (!(u8Size == 1))
printf("Warning: wrong size u8: %lu \n", u8Size);
size_t u16Size = sizeof(u16);
if (!(u16Size == 2))
printf("Warning: wrong size u16: %lu \n", u16Size);
size_t u32Size = sizeof(u32);
if (!(u32Size == 4))
printf("Warning: wrong size u32: %lu \n", u32Size);
size_t u64Size = sizeof(u64);
if (!(u64Size == 8))
printf("Warning: wrong size u64: %lu \n", u64Size);
size_t s8Size = sizeof(s8);
if (!(s8Size == 1))
printf("Warning: wrong size s8: %lu \n", s8Size);
size_t s16Size = sizeof(s16);
if (!(s16Size == 2))
printf("Warning: wrong size s16: %lu \n", s16Size);
size_t s32Size = sizeof(s32);
if (!(s32Size == 4))
printf("Warning: wrong size s32: %lu \n", s32Size);
size_t s64Size = sizeof(s64);
if (!(s64Size == 8))
printf("Warning: wrong size s64: %lu \n", s64Size);
size_t ITFileHeaderSize = sizeof(ITFileHeader);
if (!(ITFileHeaderSize == 192))
printf("Warning: wrong size ITFileHeader: %lu \n", ITFileHeaderSize);
size_t ITFileSampleSize = sizeof(ITFileSample);
if (!(ITFileSampleSize == 80))
printf("Warning: wrong size ITFileSample: %lu \n", ITFileSampleSize);
size_t ITFilePatternSize = sizeof(ITFilePattern);
if (!(ITFilePatternSize == 8))
printf("Warning: wrong size ITFilePattern: %lu \n", ITFilePatternSize);
size_t SPCFileSize = sizeof(SPCFile);
if (!(SPCFileSize == 65920))
printf("Warning: wrong size SPCFile: %lu \n", SPCFileSize);
}

int main(int argc, char **argv)
{
CheckSizes();
s32 seconds, limit, done;
char fn[PATH_MAX];
s32 i;
Expand Down
18 changes: 9 additions & 9 deletions sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ static s32 decode_samp(u16 start, sndsamp **sp)
output += (s32)(((f64)s->buf[sampptr - 1] * 61 / 32) - ((f64)s->buf[sampptr - 2] * 15 / 16));
else if (filter == 3)
output += (s32)(((f64)s->buf[sampptr - 1] * 115 / 64) - ((f64)s->buf[sampptr - 2] * 13 / 16));
if (output > 32767)
output = 32767;
else if (output < -32768)
output = -32768;
if (output > 32000)
output = 32000;
else if (output < -32001)
output = -32001;
s->buf[sampptr++] = output;
output = src[brrptr] & 0x0F;
if (output > 7)
Expand All @@ -84,10 +84,10 @@ static s32 decode_samp(u16 start, sndsamp **sp)
output += (s32)(((f64)s->buf[sampptr - 1] * 61 / 32) - ((f64)s->buf[sampptr - 2] * 15 / 16));
else if (filter == 3)
output += (s32)(((f64)s->buf[sampptr - 1] * 115 / 64) - ((f64)s->buf[sampptr - 2] * 13 / 16));
if (output > 32767)
output = 32767;
else if (output < -32768)
output = -32768;
if (output > 32000)
output = 32000;
else if (output < -32001)
output = -32001;
s->buf[sampptr++] = output;
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ void SNDNoteOn(u8 v)
SNDkeys |= (1 << i);
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 2]) << 3;
if (SNDsamples[cursamp]->freq == 0)
SNDsamples[cursamp]->freq = pitch;
SNDsamples[cursamp]->freq = 32000;
// figure ADSR/GAIN
adsr1 = SPC_DSP[(i << 4) + 5];
if (adsr1 & 0x80)
Expand Down
44 changes: 0 additions & 44 deletions spc2ittypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,50 +45,6 @@ typedef struct
u8 ChannelVolume[64]; // Channel volume
} ITFileHeader;

typedef struct
{
u8 YValue;
u16 TickNumber;
} ITFileNodePoint;

typedef struct
{
u8 Flags;
u8 NodeNumber;
u8 LoopBeginning;
u8 LoopEnd;
u8 SustainLoopBeginning;
u8 SustainLoopEnd;
ITFileNodePoint NodePoints[25];
u8 Padding;
} ITFileEnvelope;

typedef struct
{
char magic[4]; // IMPI
char fileName[13]; // 8.3 DOS filename (including null termating)
u8 NewNoteAction;
u8 DuplicateCheckType;
u8 DuplicateCheckAction;
u16 FadeOut;
u8 PitchPanSeperation;
u8 PitchPanCenter;
u8 GlobalVolume;
u8 DefaultPan;
u8 RandomVolumeVariation;
u8 RandomPanningVariation;
u16 TrackerCreatorVersion; // The version of the tracker that created the IT file
u8 NumberOfSamples;
u8 Padding;
char InstrumentName[26];
u8 InitialFilterCutoff;
u8 InitialFilterResonance;
u8 MIDIChannel;
u8 MIDIProgram; //(Instrument)
u8 NoteSampleKeyboardTable[240];
ITFileEnvelope Envelopes[3];
} ITFileInstrument;

typedef struct
{
char magic[4]; // IMPS
Expand Down

0 comments on commit bd6f59a

Please sign in to comment.