ATMlib minor optimisation
This commit is contained in:
parent
315c3c45e9
commit
7b4faf6a85
|
@ -292,11 +292,8 @@ static inline const byte *getTrackPointer(byte track) {
|
||||||
|
|
||||||
|
|
||||||
void ATMsynth::play(const byte *song) {
|
void ATMsynth::play(const byte *song) {
|
||||||
TIMSK4 = 0b00000000;// ensure interrupt is disabled
|
stop();
|
||||||
cia_count = 1;
|
cia_count = 1;
|
||||||
// cleanUp stuff first
|
|
||||||
memset(channel, 0, sizeof(channel));
|
|
||||||
ChannelActiveMute = 0b11110000;
|
|
||||||
|
|
||||||
// Initializes ATMsynth
|
// Initializes ATMsynth
|
||||||
// Sets sample rate and tick rate
|
// Sets sample rate and tick rate
|
||||||
|
@ -324,7 +321,7 @@ void ATMsynth::play(const byte *song) {
|
||||||
// Store track pointer
|
// Store track pointer
|
||||||
trackBase = (song += (trackCount << 1)) + 4;
|
trackBase = (song += (trackCount << 1)) + 4;
|
||||||
// Fetch starting points for each track
|
// Fetch starting points for each track
|
||||||
for (unsigned n = 0; n < 4; n++) {
|
for (byte n = 0; n < 4; n++) {
|
||||||
channel[n].ptr = getTrackPointer(pgm_read_byte(song++));
|
channel[n].ptr = getTrackPointer(pgm_read_byte(song++));
|
||||||
}
|
}
|
||||||
TIMSK4 = 0b00000100;// enable interrupt as last
|
TIMSK4 = 0b00000100;// enable interrupt as last
|
||||||
|
@ -603,9 +600,8 @@ void ATM_playroutine() {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(channel, 0, sizeof(channel));
|
ATMsynth::stop();
|
||||||
TIMSK4 = 0; // Disable interrupt
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,17 @@ class ATMsynth {
|
||||||
ATMsynth() {};
|
ATMsynth() {};
|
||||||
|
|
||||||
// Load and play specified song
|
// Load and play specified song
|
||||||
void play(const byte *song);
|
static void play(const byte *song);
|
||||||
|
|
||||||
// Play or Pause playback
|
// Play or Pause playback
|
||||||
void playPause();
|
static void playPause();
|
||||||
|
|
||||||
// Stop playback (unloads song)
|
// Stop playback (unloads song)
|
||||||
void stop();
|
static void stop();
|
||||||
|
|
||||||
void muteChannel(byte ch);
|
static void muteChannel(byte ch);
|
||||||
|
|
||||||
void unMuteChannel(byte ch);
|
static void unMuteChannel(byte ch);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,4 +52,4 @@ uint16_t read_vle(const byte **pp);
|
||||||
static inline const byte *getTrackPointer(byte track);
|
static inline const byte *getTrackPointer(byte track);
|
||||||
|
|
||||||
extern void ATM_playroutine() asm("ATM_playroutine");
|
extern void ATM_playroutine() asm("ATM_playroutine");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue