From 490ca6e7dd8703a444e322ddd334c561e2574dca Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 11 Apr 2010 04:40:00 -0400 Subject: [PATCH] Tracker: remove export functionality --- tracker/README | 4 +- tracker/gui.c | 171 ------------------------------------------------ tracker/main.c | 4 -- tracker/stuff.h | 1 - 4 files changed, 1 insertion(+), 179 deletions(-) diff --git a/tracker/README b/tracker/README index 28dc575..85d3b8c 100644 --- a/tracker/README +++ b/tracker/README @@ -26,9 +26,7 @@ to enter notes. The keyboard layout is adapted for a US qwerty keymap. You can edit gui.c to change this to fit a Dvorak keymap instead. Press ^E (control-E) to exit without saving. Press ^W ("write") to save. Press -# to optimize the song (remove unused tracks, move tracks together) and % to -export the song into a packed format. (% will always export to two files called -"exported.s" and "exported.h" in the current working directory). +# to optimize the song (remove unused tracks, move tracks together). In the song and instrument editors, use capital A, I and D to add, insert and delete lines. In the track and instrument editors, use capital C and V for copy diff --git a/tracker/gui.c b/tracker/gui.c index a03f503..1537fbf 100644 --- a/tracker/gui.c +++ b/tracker/gui.c @@ -428,174 +428,6 @@ void optimize() { } } -static FILE *exportfile = 0; -static int exportbits = 0; -static int exportcount = 0; -static int exportseek = 0; - -void putbit(int x) { - if(x) { - exportbits |= (1 << exportcount); - } - exportcount++; - if(exportcount == 8) { - if(exportfile) { - fprintf(exportfile, "\t.byte\t0x%02x\n", exportbits); - } - exportseek++; - exportbits = 0; - exportcount = 0; - } -} - -void exportchunk(int data, int bits) { - int i; - - for(i = 0; i < bits; i++) { - putbit(!!(data & (1 << i))); - } -} - -int alignbyte() { - if(exportcount) { - if(exportfile) { - fprintf(exportfile, "\t.byte\t0x%02x\n", exportbits); - } - exportseek++; - exportbits = 0; - exportcount = 0; - } - if(exportfile) fprintf(exportfile, "\n"); - return exportseek; -} - -int packcmd(u8 ch) { - if(!ch) return 0; - if(strchr(validcmds, ch)) { - return strchr(validcmds, ch) - validcmds; - } - return 0; -} - -void exportdata(FILE *f, int maxtrack, int *resources) { - int i, j; - int nres = 0; - - exportfile = f; - exportbits = 0; - exportcount = 0; - exportseek = 0; - - for(i = 0; i < 16 + maxtrack; i++) { - // if(exportfile) fprintf(exportfile, "songdata_resources%d:\n", i); - exportchunk(resources[i], PACKSIZE_RESOURCE); - } - - resources[nres++] = alignbyte(); - - if(exportfile) fprintf(exportfile, "songdata_song:\n"); - for(i = 0; i < songlen; i++) { - for(j = 0; j < NR_CHAN; j++) { - if(song[i].transp[j]) { - exportchunk(1, 1); - exportchunk(song[i].track[j], PACKSIZE_SONGTRACK); - exportchunk(song[i].transp[j], PACKSIZE_SONGTRANS); - } else { - exportchunk(0, 1); - exportchunk(song[i].track[j], PACKSIZE_SONGTRACK); - } - } - } - - for(i = 1; i < 16; i++) { - resources[nres++] = alignbyte(); - - // 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), PACKSIZE_INSTRCMD); - exportchunk(instrument[i].line[j].param, PACKSIZE_INSTRPAR); - } - } - - exportchunk(0, PACKSIZE_INSTRCMD); - } - - for(i = 1; i <= maxtrack; i++) { - resources[nres++] = alignbyte(); - - // if(exportfile) fprintf(exportfile, "songdata_track%d:\n", i); - for(j = 0; j < tracklen; j++) { - u8 cmd = packcmd(track[i].line[j].cmd[0]); - - exportchunk(!!track[i].line[j].note, 1); - exportchunk(!!track[i].line[j].instr, 1); - exportchunk(!!cmd, 1); - - if(track[i].line[j].note) { - exportchunk(track[i].line[j].note, PACKSIZE_TRACKNOTE); - } - - if(track[i].line[j].instr) { - exportchunk(track[i].line[j].instr, PACKSIZE_TRACKINST); - } - - if(cmd) { - exportchunk(cmd, PACKSIZE_TRACKCMD); - exportchunk(track[i].line[j].param[0], PACKSIZE_TRACKPAR); - } - } - } -} - -void export(char *stem) { - int blen = strlen(stem) + 5; - char *buf = alloca(blen); - if(!buf) { - return; - } - snprintf(buf, blen, "%s.s", stem); - FILE *f = fopen(buf, "w"); - - snprintf(buf, blen, "%s.h", stem); - FILE *hf = fopen(buf, "w"); - - int i, j; - int maxtrack = 0; - int resources[256]; - - exportfile = 0; - exportbits = 0; - exportcount = 0; - exportseek = 0; - - for(i = 0; i < songlen; i++) { - for(j = 0; j < 4; j++) { - if(maxtrack < song[i].track[j]) maxtrack = song[i].track[j]; - } - } - - fprintf(f, "\t.global\tsongdata\n\n"); - - fprintf(hf, "#define MAXTRACK\t0x%02x\n", maxtrack); - fprintf(hf, "#define SONGLEN\t\t0x%02x\n", songlen); - - fprintf(f, "songdata:\n"); - - exportdata(0, maxtrack, resources); - - fprintf(f, "# "); - for(i = 0; i < 16 + maxtrack; i++) { - fprintf(f, "%04x ", resources[i]); - } - fprintf(f, "\n"); - - exportdata(f, maxtrack, resources); - - fclose(f); - fclose(hf); -} - void handleinput() { int c, x; @@ -662,9 +494,6 @@ void handleinput() { case '#': optimize(); break; - case '%': - export("export"); - break; case KEY_LEFT: switch(currtab) { case 0: diff --git a/tracker/main.c b/tracker/main.c index 92a0a71..6c35954 100644 --- a/tracker/main.c +++ b/tracker/main.c @@ -79,10 +79,6 @@ int main(int argc, char **argv) { fwrite(&res, 1, 1, f); } fclose(f); - } else if(!strcmp("--export", argv[1])) { - loadfile(argv[2]); - char *exportname = (argc > 2) ? argv[3] : "export" ; - export(exportname); } else { if(argc != 2) { err(1, "usage: %s \n", argv[0]); diff --git a/tracker/stuff.h b/tracker/stuff.h index feff1a3..2cada60 100644 --- a/tracker/stuff.h +++ b/tracker/stuff.h @@ -29,7 +29,6 @@ void guiloop(); void startplaysong(int); void startplaytrack(int); void loadfile(char *); -void export(char *); extern u8 trackpos; extern u8 playtrack; -- 2.50.1