From 6cf090702e81076b32bcdc4e64de11a7d605b444 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 28 Feb 2010 19:50:55 -0500 Subject: [PATCH] Eliminate character command encoding in target While here, fix a permutation in progenv/trackerfmt.h's CMD_* definitions. --- progenv/trackerfmt.h | 8 ++++---- target/main.c | 30 ++++++++++++++---------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/progenv/trackerfmt.h b/progenv/trackerfmt.h index 0a818af..e33d0e3 100644 --- a/progenv/trackerfmt.h +++ b/progenv/trackerfmt.h @@ -21,7 +21,7 @@ /** Set channel volume derivative */ #define CMD_VOLUMED 0x2 /** Set channel inertia (param << 1) */ -#define CMD_INTERTIA 0x3 +#define CMD_INERTIA 0x3 /** Set channel instrument offset */ #define CMD_IJUMP 0x4 /** Set channel bend derivative */ @@ -35,11 +35,11 @@ /** Set oscillator waveform */ #define CMD_WAVEFORM 0x9 /** Set channel instrument note (transposed) */ -#define CMD_INOTETRANS 0xA +#define CMD_INOTETRANS 0xB /** Set channel instrument note (absolute) */ -#define CMD_INOTE 0xB +#define CMD_INOTE 0xC /** Set channel vibrato depth and rate */ -#define CMD_VIBRATO 0xC +#define CMD_VIBRATO 0xA /* RESERVED 0x0D */ /* RESERVED 0x0E */ diff --git a/target/main.c b/target/main.c index 4f91fcb..4acbaf8 100644 --- a/target/main.c +++ b/target/main.c @@ -25,8 +25,6 @@ u32 noiseseed = 1; u8 light[2]; -const u8 validcmds[] = "0dfijlmtvw~+="; - volatile struct oscillator { u16 freq; u16 phase; @@ -119,44 +117,44 @@ void readinstr(u8 num, u8 pos, u8 *dest) { } void runcmd(u8 ch, u8 cmd, u8 param) { - switch(validcmds[cmd]) { - case '0': + switch(cmd) { + case CMD_ISTOP: channel[ch].inum = 0; break; - case 'd': + case CMD_DUTY: osc[ch].duty = param << 8; break; - case 'f': + case CMD_VOLUMED: channel[ch].volumed = param; break; - case 'i': + case CMD_INERTIA: channel[ch].inertia = param << 1; break; - case 'j': + case CMD_IJUMP: channel[ch].iptr = param; break; - case 'l': + case CMD_BENDD: channel[ch].bendd = param; break; - case 'm': + case CMD_DUTYD: channel[ch].dutyd = param << 6; break; - case 't': + case CMD_IWAIT: channel[ch].iwait = param; break; - case 'v': + case CMD_VOLUME: osc[ch].volume = param; break; - case 'w': + case CMD_WAVEFORM: osc[ch].waveform = param; break; - case '+': + case CMD_INOTETRANS: channel[ch].inote = param + channel[ch].tnote - 12 * 4; break; - case '=': + case CMD_INOTE: channel[ch].inote = param; break; - case '~': + case CMD_VIBRATO: if(channel[ch].vdepth != (param >> 4)) { channel[ch].vpos = 0; } -- 2.50.1