collab/PineapplePad

git clone https://git.julia.blue/collab/PineapplePad

Joseph RyanFinishing touchesca230b6

master
1.9 KiB74 linesraw
1#include <stdint.h>
2#include "../inc/tm4c123gh6pm.h"
3#include "../inc/PLL.h"
4#include "../inc/random.h"
5#include "../inc/ADC.h"
6#include "../inc/DAC.h"
7#include "../inc/UART.h"
8#include "../inc/Timer1.h"
9#include "../inc/ST7735.h"
10#include "../inc/graphics.h"
11#include "../inc/game.h"
12#include "../inc/IO.h"
13#include "../inc/Images.h"
14#include "../inc/sound.h"
15#include "../inc/song.h"
16
17extern "C" void DisableInterrupts(void);
18extern "C" void EnableInterrupts(void);
19
20volatile bool frameDone;
21
22void clk(){
23    if (frameDone) { // fps too high
24        //toggle_red();
25    }
26    frameDone = true;
27}
28
29int main(void){
30    PLL_Init(Bus80MHz);
31    ST7735_InitR(INITR_REDTAB);
32    UART_Init();    // debugging
33    ADC_Init();
34    PortF_Init();
35    DAC_Init();
36    Sound_Init();
37    Song_Init();
38
39    EnableInterrupts();
40
41    ST7735_DrawBitmap(0, 159, retro, 128, 160);
42    //Song_Play(menu_pitch, menu_dur, menu_speed, sizeof(menu_dur));
43    Song_Play(megaman_pitch, megaman_dur, megaman_speed, sizeof(megaman_dur));
44    while ((GPIO_PORTF_DATA_R & 0x10) && (GPIO_PORTF_DATA_R & 0x01)) ;
45    Random_Init(NVIC_ST_CURRENT_R);
46    instrument = instruments[Random() % sizeof(instruments)];
47    Song_Play(tears_pitch, tears_dur, tears_speed, sizeof(tears_dur));
48    ST7735_FillScreen(0);
49    printScore(0);
50    initField(); // set up cubes
51    Timer1_Init(clk, 1333333); // 60 FPS
52
53    while (1) {
54        frameDone = false;
55        difficulty = 1 + (ADC_In() >> 9); // slide pot input
56        vel = (!(GPIO_PORTF_DATA_R & 0x10)) // todo: replace with hardware interrupts
57              - (!(GPIO_PORTF_DATA_R & 0x01));
58        step();
59        while (!frameDone) ;
60    }
61}
62
63int mainSound(){
64    DisableInterrupts();
65    PLL_Init(Bus80MHz);
66    DAC_Init();
67    Sound_Init();
68    Song_Init();
69    PortF_Init();
70    EnableInterrupts();
71    Song_Play(tears_pitch, tears_dur, tears_speed, sizeof(tears_dur));
72    while (1) {
73    }
74}