Created
April 16, 2021 12:38
-
-
Save Dobby233Liu/d59a305c4bfb1e6fb5fc5f8d52c956f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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