From 5e28fd548de9acc0551a8cdc3e92067fb438740a Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 18 Mar 2010 20:16:34 -0400 Subject: [PATCH] Move to progenv/trackerfmt.h PACKSIZE_* constants --- progenv/trackerfmt.h | 11 +++++++++++ target/main.c | 16 ++++++++-------- tracker/gui.c | 26 +++++++++++++------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/progenv/trackerfmt.h b/progenv/trackerfmt.h index 1eec527..1ec4e84 100644 --- a/progenv/trackerfmt.h +++ b/progenv/trackerfmt.h @@ -4,6 +4,17 @@ #ifndef ASSEMBLER #endif + /* Packed format sizes */ +#define PACKSIZE_RESOURCE 13 +#define PACKSIZE_SONGTRACK 6 +#define PACKSIZE_SONGTRANS 4 +#define PACKSIZE_INSTRCMD 8 +#define PACKSIZE_INSTRPAR 8 +#define PACKSIZE_TRACKNOTE 7 +#define PACKSIZE_TRACKINST 4 +#define PACKSIZE_TRACKCMD 4 +#define PACKSIZE_TRACKPAR 8 + #define NR_CHAN 4 /**< Number of channels active in the system */ #define TRACKLEN 32 /**< Rows in a track */ diff --git a/target/main.c b/target/main.c index 212ae23..03f7719 100644 --- a/target/main.c +++ b/target/main.c @@ -185,9 +185,9 @@ static void playroutine() { u8 transp; gottransp = readchunk(&songup, 1); - channel[ch].tnum = readchunk(&songup, 6); + channel[ch].tnum = readchunk(&songup, PACKSIZE_SONGTRACK); if(gottransp) { - transp = readchunk(&songup, 4); + transp = readchunk(&songup, PACKSIZE_SONGTRANS); if(transp & 0x8) transp |= 0xf0; } else { transp = 0; @@ -213,11 +213,11 @@ static void playroutine() { instr = 0; cmd = 0; param = 0; - if(fields & 1) note = readchunk(&channel[ch].trackup, 7); - if(fields & 2) instr = readchunk(&channel[ch].trackup, 4); + if(fields & 1) note = readchunk(&channel[ch].trackup, PACKSIZE_TRACKNOTE); + if(fields & 2) instr = readchunk(&channel[ch].trackup, PACKSIZE_TRACKINST); if(fields & 4) { - cmd = readchunk(&channel[ch].trackup, 4); - param = readchunk(&channel[ch].trackup, 8); + cmd = readchunk(&channel[ch].trackup, PACKSIZE_TRACKCMD); + param = readchunk(&channel[ch].trackup, PACKSIZE_TRACKPAR); } if(note) { channel[ch].tnote = note + channel[ch].transp; @@ -249,7 +249,7 @@ static void playroutine() { } trackpos++; - trackpos &= 31; + trackpos &= (TRACKLEN-1); } } } @@ -325,7 +325,7 @@ void initresources() { initup(&up, 0); for(i = 0; i < 16 + MAXTRACK; i++) { - resources[i] = readchunk(&up, 13); + resources[i] = readchunk(&up, PACKSIZE_RESOURCE); } initup(&songup, resources[0]); diff --git a/tracker/gui.c b/tracker/gui.c index b18909e..a03f503 100644 --- a/tracker/gui.c +++ b/tracker/gui.c @@ -488,21 +488,21 @@ void exportdata(FILE *f, int maxtrack, int *resources) { for(i = 0; i < 16 + maxtrack; i++) { // if(exportfile) fprintf(exportfile, "songdata_resources%d:\n", i); - exportchunk(resources[i], 13); + exportchunk(resources[i], PACKSIZE_RESOURCE); } resources[nres++] = alignbyte(); - // if(exportfile) fprintf(exportfile, "songdata_song:\n"); + if(exportfile) fprintf(exportfile, "songdata_song:\n"); for(i = 0; i < songlen; i++) { - for(j = 0; j < 4; j++) { + for(j = 0; j < NR_CHAN; j++) { if(song[i].transp[j]) { exportchunk(1, 1); - exportchunk(song[i].track[j], 6); - exportchunk(song[i].transp[j], 4); + exportchunk(song[i].track[j], PACKSIZE_SONGTRACK); + exportchunk(song[i].transp[j], PACKSIZE_SONGTRANS); } else { exportchunk(0, 1); - exportchunk(song[i].track[j], 6); + exportchunk(song[i].track[j], PACKSIZE_SONGTRACK); } } } @@ -513,12 +513,12 @@ void exportdata(FILE *f, int maxtrack, int *resources) { // if(exportfile) fprintf(exportfile, "songdata_instrument%d:\n", i); if(instrument[i].length > 1) { for(j = 0; j < instrument[i].length; j++) { - exportchunk(packcmd(instrument[i].line[j].cmd), 8); - exportchunk(instrument[i].line[j].param, 8); + exportchunk(packcmd(instrument[i].line[j].cmd), PACKSIZE_INSTRCMD); + exportchunk(instrument[i].line[j].param, PACKSIZE_INSTRPAR); } } - exportchunk(0, 8); + exportchunk(0, PACKSIZE_INSTRCMD); } for(i = 1; i <= maxtrack; i++) { @@ -533,16 +533,16 @@ void exportdata(FILE *f, int maxtrack, int *resources) { exportchunk(!!cmd, 1); if(track[i].line[j].note) { - exportchunk(track[i].line[j].note, 7); + exportchunk(track[i].line[j].note, PACKSIZE_TRACKNOTE); } if(track[i].line[j].instr) { - exportchunk(track[i].line[j].instr, 4); + exportchunk(track[i].line[j].instr, PACKSIZE_TRACKINST); } if(cmd) { - exportchunk(cmd, 4); - exportchunk(track[i].line[j].param[0], 8); + exportchunk(cmd, PACKSIZE_TRACKCMD); + exportchunk(track[i].line[j].param[0], PACKSIZE_TRACKPAR); } } } -- 2.50.1