From: Nathaniel Wesley Filardo Date: Thu, 25 Feb 2010 06:05:26 +0000 (-0500) Subject: Introduce target/config.h X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=50054a2d08b4e1b063e5948ecef95854e4f2cdf4;p=acmetensortoys-chiptunes Introduce target/config.h While here, move more of target/ to symbolics. --- diff --git a/target/asm.S b/target/asm.S index e5795d8..7f9c5dc 100644 --- a/target/asm.S +++ b/target/asm.S @@ -1,4 +1,6 @@ #include +#include +#include .global readsongbyte .global watchdogoff @@ -32,7 +34,8 @@ watchdogoff: ret __vector_14: - ; Entire interrupt routine, worst case: 308 clocks. + ; Entire interrupt routine, worst case: + ; 308 + TARGET_AUDIO_PORT_SHIFT clocks. ; --------------------------------------------- ; Save processor state. @@ -55,10 +58,13 @@ __vector_14: ; --------------------------------------------- ; Write previously generated sample to PORTD. - ; 3 clocks. + ; 3 + TARGET_AUDIO_PORT_SHIFT clocks. - lds r24, lastsample ; 2 - out 0x0b, r24 ; 1 + lds r24, lastsample ; 2 +.rept TARGET_AUDIO_PORT_SHIFT + lsr r24 ; TARGET_AUDIO_PORT_SHIFT +.endr + out _SFR_IO_ADDR(TARGET_AUDIO_PORT), r24 ; 1 ; --------------------------------------------- ; Run the noise shift register. diff --git a/target/config.h b/target/config.h new file mode 100644 index 0000000..27b9d68 --- /dev/null +++ b/target/config.h @@ -0,0 +1,23 @@ +#ifndef _TARGET_CONFIG_H_ +#define _TARGET_CONFIG_H_ + +/* Original values for lft's hardware: */ +#if 0 + +#define TARGET_AUDIO_PORT PORTD +#define TARGET_AUDIO_PORT_SHIFT 0 +#define TARGET_LIGHT_PORT PORTC +#define TARGET_LIGHT_ZERO 0x02 +#define TARGET_LIGHT_ONE 0x10 + +#endif + +#define TARGET_AUDIO_PORT PORTC +#define TARGET_AUDIO_DDR DDRC +#define TARGET_AUDIO_PORT_SHIFT 2 +#define TARGET_LIGHT_PORT PORTB +#define TARGET_LIGHT_DDR DDRB +#define TARGET_LIGHT_ZERO 0x01 +#define TARGET_LIGHT_ONE 0x02 + +#endif diff --git a/target/main.c b/target/main.c index 5172a3d..4f91fcb 100644 --- a/target/main.c +++ b/target/main.c @@ -1,5 +1,4 @@ #include -#include #include #define TRACKLEN 32 @@ -7,6 +6,7 @@ #include #include #include +#include volatile u8 callbackwait; volatile u8 lastsample; @@ -25,8 +25,6 @@ u32 noiseseed = 1; u8 light[2]; -#include "tracker/exported.h" - const u8 validcmds[] = "0dfijlmtvw~+="; volatile struct oscillator { @@ -35,7 +33,7 @@ volatile struct oscillator { u16 duty; u8 waveform; u8 volume; // 0-255 -} osc[4]; +} osc[NR_CHAN]; struct trackline { u8 note; @@ -73,7 +71,7 @@ struct channel { u8 vpos; s16 inertia; u16 slur; -} channel[4]; +} channel[NR_CHAN]; u16 resources[16 + MAXTRACK]; @@ -170,7 +168,6 @@ void runcmd(u8 ch, u8 cmd, u8 param) { void playroutine() { // called at 50 Hz u8 ch; - u8 lights; if(playsong) { if(trackwait) { @@ -183,7 +180,7 @@ void playroutine() { // called at 50 Hz if(songpos >= SONGLEN) { playsong = 0; } else { - for(ch = 0; ch < 4; ch++) { + for(ch = 0; ch < NR_CHAN; ch++) { u8 gottransp; u8 transp; @@ -206,7 +203,7 @@ void playroutine() { // called at 50 Hz } if(playsong) { - for(ch = 0; ch < 4; ch++) { + for(ch = 0; ch < NR_CHAN; ch++) { if(channel[ch].tnum) { u8 note, instr, cmd, param; u8 fields; @@ -257,7 +254,7 @@ void playroutine() { // called at 50 Hz } } - for(ch = 0; ch < 4; ch++) { + for(ch = 0; ch < NR_CHAN; ch++) { s16 vol; u16 duty; u16 slur; @@ -306,16 +303,18 @@ void playroutine() { // called at 50 Hz channel[ch].vpos += channel[ch].vrate; } - lights = 0; if(light[0]) { light[0]--; - lights |= 0x02; - } + TARGET_LIGHT_PORT |= TARGET_LIGHT_ZERO; + } else { + TARGET_LIGHT_PORT &= ~TARGET_LIGHT_ZERO; + } if(light[1]) { light[1]--; - lights |= 0x10; + TARGET_LIGHT_PORT |= TARGET_LIGHT_ONE; + } else { + TARGET_LIGHT_PORT &= ~TARGET_LIGHT_ONE; } - PORTC = lights; } void initresources() { @@ -336,10 +335,10 @@ int main() { CLKPR = 0x80; CLKPR = 0x80; - DDRC = 0x12; - DDRD = 0xff; + TARGET_LIGHT_DDR = TARGET_LIGHT_ZERO | TARGET_LIGHT_ONE; + TARGET_AUDIO_DDR = 0xff; - PORTC = 0; + TARGET_AUDIO_PORT = 0; timetoplay = 0; trackwait = 0;