Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdlib.h>
#include <x86.h>
#define lastIntroNote 0+26*2
#define lastNote song_LEN // very last entry in song
unsigned int soundIndex = 0; // NTS: use song only for indexing. NOTE: may want to expand
unsigned short soundWait = 0;
// NOTE: this is supposed to run per tick
void playNote(){
if (soundIndex > lastNote)
soundIndex = lastIntroNote; // jump to loop point
soundWait--;
if (soundWait != -1) // quirk: not >
return;
unsigned short _cursor = song[soundIndex++]; // ax
// ???: cx <- ah
unsigned char *freq = (freq >> 8) & 0xff; // ah
freq = freq & 0x1F; // and ah, 00011111b
// Set the frequency
IO_write(0x42, freq);
soundWait = soundWait >> 5; // SHR
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment