Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FATFileSystem
Revision 26:716bcd47f3ca, committed 2019-05-10
- Comitter:
- rottenegg
- Date:
- Fri May 10 21:25:27 2019 +0000
- Parent:
- 25:df39289eb8c0
- Commit message:
- FINAL_SUBMISSION; ; Changes:; WDplayer: Major Memory Leek fixed related to fclose(); Game_Manager: Tuned Scene Order and Improved Random number generator.; SceneFuctions: Added a Randomly changing Object to Scene 4.
Changed in this revision
--- a/CaMove/CaMove.cpp Thu May 09 13:27:19 2019 +0000 +++ b/CaMove/CaMove.cpp Fri May 10 21:25:27 2019 +0000 @@ -1,8 +1,6 @@ #include "CaMove.h" #include "AniPaths.h" -Serial f(USBTX,USBRX); - //Constructor CaMove::CaMove(PinName Button, PinName Pot_h, @@ -38,7 +36,7 @@ void CaMove::AIinit(int chaser) { enabled = false; _ch = 0; - _cv = 0; + _cv = 0; //Increment is speed of Chaser switch (chaser) { case 2: increment = 2;
--- a/Game_Manager/Game_Manager.cpp Thu May 09 13:27:19 2019 +0000 +++ b/Game_Manager/Game_Manager.cpp Fri May 10 21:25:27 2019 +0000 @@ -91,15 +91,15 @@ wav->intWD(All[55], true); SNC->Scenesp(*lcd,*CM,0,40,20,Fd,0,*wav); Time.stop(); - Random = (int)Time.read() % 3; + Random = ((int)(Time.read()*10)) % 3; Time.reset(); } void Game_Manager::main() { int Random; this->first_scene(Random); - PC.printf("%d",Random); - if (Random != 1) { + PC.printf("%d\n",Random); + if (Random == 1) { wav->intWD(All[55], true); SNC->Scenesp(*lcd,*CM,3,58,26,Bd,Random,*wav); //mirror } else { @@ -108,7 +108,7 @@ } wav->intWD(All[56], true); SNC->Scenesp(*lcd,*CM,4,69,19,Rt,Random,*wav); //corridor - if (!(Random != 1)) { + if (Random != 1) { SNC->set_dead(false); wav->intWD(All[56], true); SNC->Scenesp(*lcd,*CM,2,61,17,Lt,Random,*wav); //chase @@ -120,7 +120,7 @@ lcd->normalMode(); if (SNC->get_dead()) { this->endingD(); - } else if (!(Random != 1)) { + } else if (Random == 1) { this->endingG(); } else { this->endingB();
--- a/N5110_Modded/Bitmap.cpp Thu May 09 13:27:19 2019 +0000 +++ b/N5110_Modded/Bitmap.cpp Fri May 10 21:25:27 2019 +0000 @@ -1,5 +1,4 @@ #include "Bitmap.h" -Serial d(USBTX,USBRX); //Total New Process time = 0.04 Seconds (still a bit long) //Image data is Stored in DWORDS (32-bits) not Bytes (8-bits) @@ -16,7 +15,7 @@ void Bitmap::renderBMP(const char *path, unsigned int const x, unsigned int const y) { FILE *bmp = fopen(path,"r"); if (bmp == NULL) { - d.printf("fail"); + std::cerr << "failure " << path << std::endl; } unsigned char *buffer = (unsigned char*)std::malloc(4 * sizeof(unsigned char)); this->readDIB(bmp); //Reading DIB header @@ -48,7 +47,7 @@ } void Bitmap::swapEndian(FILE *bmp, unsigned char *buffer, std::bitset<32> &bits) { - std::fread(buffer,1,4,bmp); + std::fread(buffer,1,4,bmp); //Endian Swap bits = buffer[0]; bits = (bits << 8) | (std::bitset<32>)buffer[1];
--- a/SceneCreator/SceneCreator.cpp Thu May 09 13:27:19 2019 +0000 +++ b/SceneCreator/SceneCreator.cpp Fri May 10 21:25:27 2019 +0000 @@ -206,7 +206,7 @@ case 3: break; case 4: - this->obj2_scene4(lcd); + this->obj2_scene4(lcd,rng); break; } }
--- a/SceneCreator/SceneFunctions.cpp Thu May 09 13:27:19 2019 +0000 +++ b/SceneCreator/SceneFunctions.cpp Fri May 10 21:25:27 2019 +0000 @@ -286,8 +286,15 @@ lcd.drawRect((20 -_progress),18,2,18,FILL_BLACK); } } -void SceneFunctions::obj2_scene4(Bitmap &lcd) { - +void SceneFunctions::obj2_scene4(Bitmap &lcd,int rng) { + switch(rng) { + case 2: + lcd.renderBMP(MISC[0],4,2); + break; + case 0: + lcd.renderBMP(MISC[2],4,2); + break; + } } void SceneFunctions::obj3_scene4(Bitmap &lcd) { if (_progress > 7) {
--- a/SceneCreator/SceneFunctions.h Thu May 09 13:27:19 2019 +0000 +++ b/SceneCreator/SceneFunctions.h Fri May 10 21:25:27 2019 +0000 @@ -78,7 +78,7 @@ void set_scene4(CaMove &CM); //pre functions void obj1_scene4(Bitmap &lcd); - void obj2_scene4(Bitmap &lcd); + void obj2_scene4(Bitmap &lcd,int rng); void obj3_scene4(Bitmap &lcd); //pos function void event0_scene4(Bitmap &lcd,CaMove &CM,WDplayer &wav);
--- a/WDplayer/WDplayer.cpp Thu May 09 13:27:19 2019 +0000 +++ b/WDplayer/WDplayer.cpp Fri May 10 21:25:27 2019 +0000 @@ -26,7 +26,6 @@ _pwmfreq = (1.0f / samplerate); _path = path; _length = len - 44; - _fptr = NULL; _tck = 0; lock = false; vtck = 4000; @@ -34,6 +33,8 @@ if (allocate) { cache = (unsigned char*)std::calloc(4000,sizeof(unsigned char)); } + fclose(_fptr); + _fptr = NULL; }; //Inline Functions (Operates using main MCU) @@ -46,8 +47,9 @@ for (_tck = _length; _tck > 1; _tck--) { fread(buffer,1,1,_fptr); _dac->write((float)buffer[0] / 255.00f); - wait(_pwmfreq / 2.0f); //I dont like this & Playback present here + wait(_pwmfreq / 2.0f); } + fclose(_fptr); _fptr = NULL; _tck = 0; }; @@ -60,6 +62,7 @@ } //end of file reset if (_tck == _length) { + fclose(_fptr); _fptr = NULL; _tck = 0; } else { @@ -84,10 +87,11 @@ } //CORE ENGINE - Opertes on a two data Block system one to read from and one to write to. if (_tck + 2000 >= _length) { + fclose(_fptr); _fptr = NULL; _tck = 0; vtck = 0; - } else if (vtck > 2001 && !lock) { + } else if (vtck > 2001 && !lock) { //updates dependent on where Vtck is in reading 0 to 1999 is block 1 and 2001 to 4000 block 2 this->UpdateBlock1(); } else if (vtck < 1999 && lock) { this->UpdateBlock2(); @@ -129,6 +133,8 @@ void WDplayer::ISRreset() { ISR.detach(); + fclose(_fptr); + _fptr = NULL; free(cache); lock = false; vtck = 4000;
--- a/main.cpp Thu May 09 13:27:19 2019 +0000 +++ b/main.cpp Fri May 10 21:25:27 2019 +0000 @@ -19,11 +19,11 @@ int main() { if (!GM.boot_error()) { //File Checks - GM.menu(); //Splash Screen - GM.tutorial(); //Tutorial Screens - GM.main(); //Main Game - wait(1); - NVIC_SystemReset(); //this is really cheeky I know... SOFT RESET + while(1) { + GM.menu(); //Splash Screen + GM.tutorial(); //Tutorial Screens + GM.main(); //Main Game + } } - } +