]> hydra-www.ietfng.org Git - acmetensortoys-chiptunes/commitdiff
Introduce target/config.h
authorNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Thu, 25 Feb 2010 06:05:26 +0000 (01:05 -0500)
committerNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Thu, 25 Feb 2010 06:05:26 +0000 (01:05 -0500)
While here, move more of target/ to symbolics.

target/asm.S
target/config.h [new file with mode: 0644]
target/main.c

index e5795d8b301338fa77b8a2f8b644da6d2c73366a..7f9c5dcd486bdb6b73d03d4081031ec3eb11a055 100644 (file)
@@ -1,4 +1,6 @@
 #include <progenv/trackerfmt.h>
+#include <target/config.h>
+#include <avr/io.h>
 
                .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 (file)
index 0000000..27b9d68
--- /dev/null
@@ -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
index 5172a3de5ee9df3c590ba2d11cd28564685ec017..4f91fcb68446239b6c774ac85602ce83116bc768 100644 (file)
@@ -1,5 +1,4 @@
 #include <avr/io.h>
-#include <avr/signal.h>
 #include <avr/interrupt.h>
 
 #define TRACKLEN 32
@@ -7,6 +6,7 @@
 #include <progenv/types.h>
 #include <progenv/gentimes.h>
 #include <progenv/trackerfmt.h>
+#include <target/config.h>
 
 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;