collab/PineapplePad
git clone https://git.julia.blue/collab/PineapplePad
ca230b6
master
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 (){ 23if (frameDone ) {// fps too high 24//toggle_red(); 25 } 26frameDone = true; 27} 28 29int main (void ){ 30PLL_Init (Bus80MHz ); 31ST7735_InitR (INITR_REDTAB ); 32UART_Init ();// debugging 33ADC_Init (); 34PortF_Init (); 35DAC_Init (); 36Sound_Init (); 37Song_Init (); 38 39EnableInterrupts (); 40 41ST7735_DrawBitmap (0 ,159 ,retro ,128 ,160 ); 42//Song_Play(menu_pitch, menu_dur, menu_speed, sizeof(menu_dur)); 43Song_Play (megaman_pitch ,megaman_dur ,megaman_speed ,sizeof (megaman_dur )); 44while ((GPIO_PORTF_DATA_R & 0x10 )&& (GPIO_PORTF_DATA_R & 0x01 )) ; 45Random_Init (NVIC_ST_CURRENT_R ); 46instrument = instruments [Random () %sizeof (instruments )]; 47Song_Play (tears_pitch ,tears_dur ,tears_speed ,sizeof (tears_dur )); 48ST7735_FillScreen (0 ); 49printScore (0 ); 50initField ();// set up cubes 51Timer1_Init (clk ,1333333 );// 60 FPS 52 53while (1 ) { 54frameDone = false; 55difficulty = 1 + (ADC_In () >>9 );// slide pot input 56vel = (!(GPIO_PORTF_DATA_R & 0x10 ))// todo: replace with hardware interrupts 57- (!(GPIO_PORTF_DATA_R & 0x01 )); 58step (); 59while (!frameDone ) ; 60 } 61} 62 63int mainSound (){ 64DisableInterrupts (); 65PLL_Init (Bus80MHz ); 66DAC_Init (); 67Sound_Init (); 68Song_Init (); 69PortF_Init (); 70EnableInterrupts (); 71Song_Play (tears_pitch ,tears_dur ,tears_speed ,sizeof (tears_dur )); 72while (1 ) { 73 } 74}