comparison examples/tank_wars/render.cpp @ 301:e4392164b458 prerelease

RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 14:34:41 +0100
parents dbeed520b014
children 421a69d42943
comparison
equal deleted inserted replaced
300:dbeed520b014 301:e4392164b458
4 * Created on: Oct 24, 2014 4 * Created on: Oct 24, 2014
5 * Author: parallels 5 * Author: parallels
6 */ 6 */
7 7
8 8
9 #include <BeagleRT.h> 9 #include <Bela.h>
10 #include <Utilities.h> 10 #include <Utilities.h>
11 #include "game.h" 11 #include "game.h"
12 #include <rtdk.h> 12 #include <rtdk.h>
13 #include <cmath> 13 #include <cmath>
14 #include <cstdlib> 14 #include <cstdlib>
88 // userData holds an opaque pointer to a data structure that was passed 88 // userData holds an opaque pointer to a data structure that was passed
89 // in from the call to initAudio(). 89 // in from the call to initAudio().
90 // 90 //
91 // Return true on success; returning false halts the program. 91 // Return true on success; returning false halts the program.
92 92
93 bool setup(BeagleRTContext *context, void *userData) 93 bool setup(BelaContext *context, void *userData)
94 { 94 {
95 srandom(time(NULL)); 95 srandom(time(NULL));
96 96
97 // Verify we are running with matrix enabled 97 // Verify we are running with matrix enabled
98 if(context->analogFrames == 0 || context->analogChannels < 4) { 98 if(context->analogFrames == 0 || context->analogChannels < 4) {
124 setupGame(gScreenWidth, gScreenHeight); 124 setupGame(gScreenWidth, gScreenHeight);
125 gGameFrameInterval = context->analogSampleRate / gGameFramesPerSecond; 125 gGameFrameInterval = context->analogSampleRate / gGameFramesPerSecond;
126 gSamplesUntilNextFrame = gGameFrameInterval; 126 gSamplesUntilNextFrame = gGameFrameInterval;
127 127
128 // Initialise auxiliary tasks 128 // Initialise auxiliary tasks
129 if((gScreenUpdateTask = BeagleRT_createAuxiliaryTask(&screen_update, 90, 129 if((gScreenUpdateTask = Bela_createAuxiliaryTask(&screen_update, 90,
130 "beaglert-screen-update")) == 0) 130 "beaglert-screen-update")) == 0)
131 return false; 131 return false;
132 132
133 return true; 133 return true;
134 } 134 }
156 // render() is called regularly at the highest priority by the audio engine. 156 // render() is called regularly at the highest priority by the audio engine.
157 // Input and output are given from the audio hardware and the other 157 // Input and output are given from the audio hardware and the other
158 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 158 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
159 // will be 0. 159 // will be 0.
160 160
161 void render(BeagleRTContext *context, void *userData) 161 void render(BelaContext *context, void *userData)
162 { 162 {
163 int audioIndex = 0; 163 int audioIndex = 0;
164 164
165 for(unsigned int n = 0; n < context->analogFrames; n++) { 165 for(unsigned int n = 0; n < context->analogFrames; n++) {
166 for(int k = 0; k < gAudioFramesPerMatrixFrame; k++) { 166 for(int k = 0; k < gAudioFramesPerMatrixFrame; k++) {
303 303
304 // Check if we have reached the point where we should next update 304 // Check if we have reached the point where we should next update
305 if(gScreenBufferReadPointer >= gScreenBufferNextUpdateLocation && 305 if(gScreenBufferReadPointer >= gScreenBufferNextUpdateLocation &&
306 !gScreenNextBufferReady) { 306 !gScreenNextBufferReady) {
307 // Update the screen at lower priority than the audio thread 307 // Update the screen at lower priority than the audio thread
308 BeagleRT_scheduleAuxiliaryTask(gScreenUpdateTask); 308 Bela_scheduleAuxiliaryTask(gScreenUpdateTask);
309 } 309 }
310 310
311 gSampleCounter++; 311 gSampleCounter++;
312 } 312 }
313 } 313 }
329 } 329 }
330 330
331 // cleanup() is called once at the end, after the audio has stopped. 331 // cleanup() is called once at the end, after the audio has stopped.
332 // Release any resources that were allocated in setup(). 332 // Release any resources that were allocated in setup().
333 333
334 void cleanup(BeagleRTContext *context, void *userData) 334 void cleanup(BelaContext *context, void *userData)
335 { 335 {
336 // Clean up the game state 336 // Clean up the game state
337 cleanupGame(); 337 cleanupGame();
338 } 338 }