aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Reisenauer <kd7tck@msn.com>2016-06-01 20:36:54 -0700
committerJoshua Reisenauer <kd7tck@msn.com>2016-06-01 20:36:54 -0700
commit21a01ec870d04116b70e206950f69c1cf9d24897 (patch)
tree45b2aff34a84bf0c1ccfb70e79a4e2e20ff46052 /src
parentae6adb173b0a89abd5185436029691ae33c1a727 (diff)
downloadraylib-21a01ec870d04116b70e206950f69c1cf9d24897.tar.gz
raylib-21a01ec870d04116b70e206950f69c1cf9d24897.zip
simplified mod
Diffstat (limited to 'src')
-rw-r--r--src/jar_mod.h44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/jar_mod.h b/src/jar_mod.h
index 93185773..2066ef07 100644
--- a/src/jar_mod.h
+++ b/src/jar_mod.h
@@ -1057,7 +1057,7 @@ bool jar_mod_init(modcontext * modctx)
if( modctx )
{
- memclear(modctx,0,sizeof(modcontext));
+ memclear(modctx, 0, sizeof(modcontext));
modctx->playrate = DEFAULT_SAMPLE_RATE;
modctx->stereo = 1;
modctx->stereo_separation = 1;
@@ -1065,9 +1065,9 @@ bool jar_mod_init(modcontext * modctx)
modctx->filter = 1;
modctx->loopcount = 0;
- for(i=0;i<PERIOD_TABLE_LENGTH - 1;i++)
+ for(i=0; i < PERIOD_TABLE_LENGTH - 1; i++)
{
- for(j=0;j<8;j++)
+ for(j=0; j < 8; j++)
{
modctx->fullperiod[(i*8) + j] = periodtable[i] - ((( periodtable[i] - periodtable[i+1] ) / 8) * j);
}
@@ -1471,15 +1471,11 @@ void jar_mod_fillbuffer( modcontext * modctx, short * outbuffer, unsigned long n
}
}
-void jar_mod_unload( modcontext * modctx)
+//resets internals for mod context
+static void jar_mod_reset( modcontext * modctx)
{
if(modctx)
{
- if(modctx->modfile)
- {
- free(modctx->modfile);
- modctx->modfile = 0;
- }
memclear(&modctx->song, 0, sizeof(modctx->song));
memclear(&modctx->sampledata, 0, sizeof(modctx->sampledata));
memclear(&modctx->patterndata, 0, sizeof(modctx->patterndata));
@@ -1493,20 +1489,32 @@ void jar_mod_unload( modcontext * modctx)
modctx->patternticksaim = 0;
modctx->sampleticksconst = 0;
modctx->loopcount = 0;
-
modctx->samplenb = 0;
-
memclear(modctx->channels, 0, sizeof(modctx->channels));
-
modctx->number_of_channels = 0;
-
modctx->mod_loaded = 0;
-
modctx->last_r_sample = 0;
modctx->last_l_sample = 0;
+
+ jar_mod_init(modctx);
+ }
+}
+
+void jar_mod_unload( modcontext * modctx)
+{
+ if(modctx)
+ {
+ if(modctx->modfile)
+ {
+ free(modctx->modfile);
+ modctx->modfile = 0;
+ }
+ jar_mod_reset(modctx);
}
}
+
+
mulong jar_mod_load_file(modcontext * modctx, char* filename)
{
mulong fsize = 0;
@@ -1567,12 +1575,8 @@ void jar_mod_seek_start(modcontext * ctx)
{
if(ctx)
{
- char* tmpmodfile = ctx->modfile;
- long size = ctx->modfilesize;
- jar_mod_init(ctx);
- jar_mod_load(ctx, tmpmodfile, size);
- ctx->modfilesize = size;
- ctx->modfile = tmpmodfile;
+ jar_mod_reset(ctx);
+ jar_mod_load(ctx, ctx->modfile, ctx->modfilesize);
}
}