Skip to content

Instantly share code, notes, and snippets.

@Dobby233Liu
Created April 16, 2021 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dobby233Liu/d59a305c4bfb1e6fb5fc5f8d52c956f7 to your computer and use it in GitHub Desktop.
Save Dobby233Liu/d59a305c4bfb1e6fb5fc5f8d52c956f7 to your computer and use it in GitHub Desktop.
#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