While here, move more of target/ to symbolics.
#include <progenv/trackerfmt.h>
+#include <target/config.h>
+#include <avr/io.h>
.global readsongbyte
.global 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.
; ---------------------------------------------
; 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.
--- /dev/null
+#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
#include <avr/io.h>
-#include <avr/signal.h>
#include <avr/interrupt.h>
#define TRACKLEN 32
#include <progenv/types.h>
#include <progenv/gentimes.h>
#include <progenv/trackerfmt.h>
+#include <target/config.h>
volatile u8 callbackwait;
volatile u8 lastsample;
u8 light[2];
-#include "tracker/exported.h"
-
const u8 validcmds[] = "0dfijlmtvw~+=";
volatile struct oscillator {
u16 duty;
u8 waveform;
u8 volume; // 0-255
-} osc[4];
+} osc[NR_CHAN];
struct trackline {
u8 note;
u8 vpos;
s16 inertia;
u16 slur;
-} channel[4];
+} channel[NR_CHAN];
u16 resources[16 + MAXTRACK];
void playroutine() { // called at 50 Hz
u8 ch;
- u8 lights;
if(playsong) {
if(trackwait) {
if(songpos >= SONGLEN) {
playsong = 0;
} else {
- for(ch = 0; ch < 4; ch++) {
+ for(ch = 0; ch < NR_CHAN; ch++) {
u8 gottransp;
u8 transp;
}
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;
}
}
- for(ch = 0; ch < 4; ch++) {
+ for(ch = 0; ch < NR_CHAN; ch++) {
s16 vol;
u16 duty;
u16 slur;
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() {
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;