-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.c
48 lines (40 loc) · 1013 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "uart.h"
#include "ym2149.h"
#define LED PORTB5 // Digital port 13 noted the board has an led on pin 13 already(should be yellow and be right below the pin)
void set_led_out(void) {
DDRB |= 1 << LED;
}
void clear_registers(void) {
int i;
for (i=0; i<14; i++) {
send_data(i, 0);
}
}
int main() {
unsigned int i;
unsigned char data[16];
set_ym_clock();
set_bus_ctl();
initUART();
set_led_out();
clear_registers();
for/*ever*/(;;) {
for (i=0; i<16; i++) {
data[i] = getByte();
}
// Working around envelope issue (kind of). When writing on the
// envelope shape register, it resets the envelope. This cannot be
// properly expressed with the YM file format. So not using it.
// Thanks sebdel: https://github.com/sebdel
for (i=0; i<13; i++) {
send_data(i, data[i]);
}
// Have LED blink with noise (drums)
if (~data[7] & 0x38) {
PORTB |= 1 << LED;
} else {
PORTB &= ~(1 << LED);
}
}
return 0;
}