ATMlib minor optimisation

This commit is contained in:
Mr.Blinky 2020-06-27 01:14:04 +02:00 committed by GitHub
parent 315c3c45e9
commit 7b4faf6a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 14 deletions

View File

@ -292,11 +292,8 @@ static inline const byte *getTrackPointer(byte track) {
void ATMsynth::play(const byte *song) {
TIMSK4 = 0b00000000;// ensure interrupt is disabled
stop();
cia_count = 1;
// cleanUp stuff first
memset(channel, 0, sizeof(channel));
ChannelActiveMute = 0b11110000;
// Initializes ATMsynth
// Sets sample rate and tick rate
@ -324,7 +321,7 @@ void ATMsynth::play(const byte *song) {
// Store track pointer
trackBase = (song += (trackCount << 1)) + 4;
// 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++));
}
TIMSK4 = 0b00000100;// enable interrupt as last
@ -603,9 +600,8 @@ void ATM_playroutine() {
}
else
{
memset(channel, 0, sizeof(channel));
TIMSK4 = 0; // Disable interrupt
ATMsynth::stop();
}
}
}
}
}

View File

@ -22,17 +22,17 @@ class ATMsynth {
ATMsynth() {};
// Load and play specified song
void play(const byte *song);
static void play(const byte *song);
// Play or Pause playback
void playPause();
static void playPause();
// 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);
extern void ATM_playroutine() asm("ATM_playroutine");
#endif
#endif