]> hydra-www.ietfng.org Git - acmetensortoys-chiptunes/commitdiff
Move to progenv/trackerfmt.h PACKSIZE_* constants
authorNathaniel Wesley Filardo <nwf@pf.priv.oc.ietfng.org>
Fri, 19 Mar 2010 00:16:34 +0000 (20:16 -0400)
committerNathaniel Wesley Filardo <nwf@pf.priv.oc.ietfng.org>
Fri, 19 Mar 2010 00:16:34 +0000 (20:16 -0400)
progenv/trackerfmt.h
target/main.c
tracker/gui.c

index 1eec527dfb6cef809115f6c591896ded347cbf18..1ec4e844ff4dfb21c9cbd88e6f3a44ac2c795a42 100644 (file)
@@ -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 */
 
index 212ae23e4f2596921bea0b14fd91c84d618c21d4..03f7719f13ac3619251362de7d757a9ac4d1827b 100644 (file)
@@ -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]);
index b18909e43a816fda201da6efc65e38a2534d666a..a03f50304e872ab4b3c793862799b00361b93f6f 100644 (file)
@@ -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);
                        }
                }
        }